tile2d
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Protected Member Functions | List of all members
World< TileData > Class Template Reference

Allows collisions between different bodies to occur. More...

#include <world.hpp>

Classes

struct  BodyElement
 
struct  Cache
 
struct  SpatialIndex
 

Public Types

using TileMapT = TileMap<TileData>
 
using TileBodyT = TileBody<TileData>
 
using BodyList = LinkedListHeader<BodyElement, FreeList<BodyElement, uint32_t>, uint32_t>
 

Public Member Functions

 World (size_t threadCount)
 Constructs a physics world.
 
WorldBodycreateTileBody (TileMapT &tileMap)
 Do not use. See createTileMap()
 
WorldBodycreateBulletBody (Float radius, const vec2 &initialLinearVelocity)
 NOT YET IMPLEMENTED. Creates a bullet body.
 
void destroyBody (WorldBody *body)
 Destroys a body, must be a type of a bullet or a tile body.
 
void update (const Float dt, size_t steps)
 Updates the body by dt.
 
Float getExecutionTimeAvg ()
 Returns the average speed of update. The stats will reset after call.
 
vec2 gravity () const
 Returns the gravity of the world.
 
void setGravity (const vec2 &gravity)
 Set the gravity of the world.
 
Grid< SpatialIndex > & grid ()
 Returns a grid refence, may be used for queries or insertions.
 

Protected Member Functions

template<class Func >
void executeOnBodies (Float timePerStep, Func &&func)
 
void updateBodies (Float timePerStep, size_t start, size_t end)
 
void batchQuery (Float timePerStep, size_t start, size_t end)
 
void insertIntoTree (WorldBody *body)
 
void eraseFromTree (WorldBody *body)
 

Detailed Description

template<class TileData>
class World< TileData >

Allows collisions between different bodies to occur.

Constructor & Destructor Documentation

◆ World()

template<class TileData >
World< TileData >::World ( size_t threadCount)
inline

Constructs a physics world.

Parameters
threadCountThe amount of threads to create to allow for additional speed up, may be 0.

Member Function Documentation

◆ createBulletBody()

template<class TileData >
WorldBody * World< TileData >::createBulletBody ( Float radius,
const vec2 & initialLinearVelocity )
inline

NOT YET IMPLEMENTED. Creates a bullet body.

Parameters
radiusThe radius of the bullet
initialLinearVelocityThe initial linear velocity of the body
Returns
The new bullet body

◆ destroyBody()

template<class TileData >
void World< TileData >::destroyBody ( WorldBody * body)
inline

Destroys a body, must be a type of a bullet or a tile body.

Parameters
bodyThe body to destroy

◆ getExecutionTimeAvg()

template<class TileData >
Float World< TileData >::getExecutionTimeAvg ( )
inline

Returns the average speed of update. The stats will reset after call.

Returns
The average time it takes for update() to proccess

◆ gravity()

template<class TileData >
vec2 World< TileData >::gravity ( ) const
inline

Returns the gravity of the world.

Returns
The gravity of the world

◆ grid()

template<class TileData >
Grid< SpatialIndex > & World< TileData >::grid ( )
inline

Returns a grid refence, may be used for queries or insertions.

Returns
The world's grid

◆ setGravity()

template<class TileData >
void World< TileData >::setGravity ( const vec2 & gravity)
inline

Set the gravity of the world.

Parameters
gravityThe new gravity

◆ update()

template<class TileData >
void World< TileData >::update ( const Float dt,
size_t steps )
inline

Updates the body by dt.

Parameters
dtThe amount of time to simulate
stepsEssentialy, the quality of the simulation. Higher steps means higher quality but is slower to process. Recommended amount is 6 if its called 60 times a second

The documentation for this class was generated from the following files: