I would appreciate a comment on how sane my approach is from someone who knows the library internals. 🙂
This is regarding the C++ library. I have a 2D simulation that has layers. There is a physical simulation on multiple layers. Objects on one layer never collide with another layer.
My implementation of Box2D for this environment is to have a b2World for each layer. This is especially nice because I can specify different Box2D simulation resolutions for different layers to make scene-specific perf tradeoffs.
A typical level in my game has 15 or so layers so I am only spawning b2Worlds for each layer that needs it in order to conserve resources.
There are times in the gameplay where an object jumps from one layer to another. In the b2World, I am making a copy of the object in one b2World and removing it from the other. I suspect I'll need to eke out what forces and torques are being applied to the object so that it is a clean transition.
Thanks for reading!
Michael Labbe
This is regarding the C++ library. I have a 2D simulation that has layers. There is a physical simulation on multiple layers. Objects on one layer never collide with another layer.
My implementation of Box2D for this environment is to have a b2World for each layer. This is especially nice because I can specify different Box2D simulation resolutions for different layers to make scene-specific perf tradeoffs.
A typical level in my game has 15 or so layers so I am only spawning b2Worlds for each layer that needs it in order to conserve resources.
There are times in the gameplay where an object jumps from one layer to another. In the b2World, I am making a copy of the object in one b2World and removing it from the other. I suspect I'll need to eke out what forces and torques are being applied to the object so that it is a clean transition.
Thanks for reading!
Michael Labbe