tile2d
|
For developers looking to improve tile2d and need to understand how tile2d works this page exists. I'll only be explainig the major details such as the multi threading aspect, not a line by line breakdown.
t2d::World<> employs a set number of threads based on the value passed through its constructor. Each threads has its own cache structure it uses to speed up processing of rigid bodies by reducing the calls to malloc() and free(). It should be noted that after the main thread has assigned work to all other threads, it will then assign itself a task to execute, ensuring that if the passed thread count is 0 we can still execute some work. The work executed is rigid body integration, reinserting rigid bodies, and doing spatial queries for a set of rigid bodies.
Because of how heavily bound a TileMap and a TileBody are together, they must be essentaily created together, thus the reason for the user having to call createTileMap() instead of somePool.constructTileMap() and world.createTileBody(someTileMap). If the latter were to be used, it would be both a more boiler plate and bug prone approach.