Efficient setup in constantly changing voxel world.

Okay working on a personal project here, Terraria like setup, 2d, blocks and the like.

I want to have circular objects, and other item physics in the game. Now, Box2D would work for this normally, but we're talking a world made up of voxel chunks that can change constantly.

The amount of memory and CPU time that would be wasted attempting to keep track of this entire (up to 10x10k for 100 million block) world as small Box2D cube shapes would be ridiculous.

On this note, if you have worked with Box2D more then I have (probably a certainty if you've really done much with it) might you have an idea how to fix this issue? The world will have other living NPCs and such in it so physics need to be all across the active world or at least in several areas. Trailing worlds have more broad macro effects, so physics won't be active on them.


Anyone know of an efficient way to srt this up?
Maybe you could look into using chain shapes to only hold the ground surface. That would be much less information.
Here's an example 🙂
http://www.ludumdare.com/compo/ludum-da ... w&uid=7091
Hmmm but the drawbacks are that you would need to be careful when you break a loop to form an 'island', and you would probably still need a grid to store info about what ground type exists at each location.

Hey, your comment about using circle shapes gave me another idea - what if the grid was filled with circles instead of squares? Circles use less memory and cpu, and would still allow you to use a grid (I'm guessing the chain shapes idea will be too much work and probably not the game style you are looking for either).

Either way, you don't need to have box2d shapes through the whole grid, only at the ground surface.
Thanks for the idea. The ground/block type at each location is handled separately, all Box2D will ever interface to them through so far is a logical operator to find if it is sold.

Original thread: https://box2d.org/forum/viewtopic.php?t=7990