|
DECLARE_HOOK(onAddCell, beginUpdate, preBehaviorUpdate, preDeleteDeadCellsUpdate, postBehaviorUpdate, endUpdate, allForcesAppliedToCells, destructor) std | World (size_t nThreads=0) |
| cells that are registered to be added More...
|
|
void | setParallelUpdateBehavior (bool p) |
| enables or disables the parallelisation of the cells' updateBehavior methods Only has effect if nbThreads > 0; More...
|
|
size_t | getNbThreads () |
| the size of the threadpool that can be used by plugins to launch asynchronous jobs and also directly in the world class to launch the updateBehavior methods in parallel. See setParallelUpdateBehavior. More...
|
|
void | setNbThreads (size_t n) |
|
void | registerHook (const Hooks &h, hook_t f) |
| register a single hook method. cf registerPlugins() More...
|
|
template<typename P , typename... Rest> |
void | registerPlugins (P &&p, Rest &&... otherPlugins) |
| Registers a plugin. A plugin is a class or struct that contains hooks. More...
|
|
void | registerPlugins () |
|
void | clearHooks () |
| end of recursion More...
|
|
size_t | getNbUpdates () const |
| get the number of update since the creation of the world More...
|
|
template<typename... Args> |
Cell * | createCell (Args &&... args) |
| Creates a new cell and adds it through addCell() More...
|
|
void | addCell (Cell *c) |
| adds a cell to the new cells batch (which will be added to the main cells container at the end of the update cycle - or can be forced manually) More...
|
|
void | addNewCells () |
| effectively adds the new cells that were registered by addCell triggers addCell hooks if there is something to add More...
|
|
void | allForcesHaveBeenAppliedToCells () |
| this method triggers the allForcesAppliedToCells. It should be called by the embedded physics plugin just before updating positions More...
|
|
void | setDt (double d) |
| sets the amount by which time is increased at each update() call. More...
|
|
void | setDtInS (double d) |
|
void | setDtInMn (double d) |
|
void | setDtInH (double d) |
|
double | getDt () const |
|
double | getDtInS () const |
|
double | getDtInMn () const |
|
double | getDtInH () const |
|
void | setShuffleCells (bool s) |
|
void | setUpdateBehaviorPeriod (size_t p) |
| sets the period at which the world must call the updateBehavior method of each cell. This can be useful, for example, when the physics code must run at a different timescale than the behavior code. More...
|
|
size_t | getUpdateBehaviorPeriod () const |
|
std::vector< std::pair< cell_t *, cell_t * > > | getConnectedCellsList () |
| returns a list of pair of connected cells More...
|
|
void | callUpdateBehavior () |
| calls the updateBehavior of each cell, potentially in parallel (see parallelUpdateBehavior and nbThreads) More...
|
|
void | update () |
| main update method More...
|
|
| ~World () |
| World's destructor. Triggers the destructor hooks and delete all cells. More...
|
|
| EXPORTABLE (World, KV(frame), KV(cells)) |
| @ignore More...
|
|
template<typename
Cell, typename Integrator = Euler>
class MecaCell::World< Cell, Integrator >
Where "everything" happens.
Handles the addition and deletion of cells and the main update routine. Hooks can be added either through the registerPlugin method or through the addHook and addHooks methods
- Template Parameters
-
Cell | the user's cell type |
Integrator | the type of integrator to use. Defaults to semi-explicit Euler |
Definition at line 25 of file world.hpp.
template<typename
Cell , typename Integrator = Euler>
template<typename P , typename... Rest>
Registers a plugin. A plugin is a class or struct that contains hooks.
This method takes an arbitrary number of plugin classes and registers them in the order of appearance, which is also the order in which similar hooks will be called.
Signatures of hooks methods must be void (World*) Available hooks are:
- beginUpdate: called at each world update before everything else
- preBehaviorUpdate: called the world calls every individual updateBehavior(World&) cells methods
- postBehaviorUpdate: called after updateBehavior(World&) and just before dead cells are removed (this is where death-related cleanup should be made, before the cell is automatically effectively removed from the world)
- endUpdate: called at the end of each world update routine
- addCell: called after each cell addition to the world (the new cell is thus guaranteed to be the last one in the cells container)
- destructor: called when world's destructor is called, just before all of the cells are deleted.
Definition at line 169 of file world.hpp.