Dynamic Voxel Body Considerations

Post Reply
Frizzil
Posts: 2
Joined: Mon Nov 09, 2015 9:11 am

Dynamic Voxel Body Considerations

Post by Frizzil »

Hi all, first post here (apologies in advance),

I'm currently working on a voxel engine that loads terrain in 3D chunks, and I want to support separate "bodies" of voxel data. The only missing part of my implementation of this feature is the physics aspect (I just started integrating JBullet with my application with success thus far.) My questions are, in order of importance:
  1. Is it both supported and reasonably fast to have a physics object consisting of a dynamic rigid body, with multiple triangle meshes in a compound shape? Theoretically this is how my voxel bodies would be implemented. I particularly want angular momentum related functionality, but I've read this may be an issue. If this isn't really feasible, is there a better way?
  2. Would such an object be capable of swapping out meshes efficiently as they are loaded and LODed?
  3. This may be over-ambitious, but I'd like to support very large physics scenes, such that I might run out of floating-point precision. Is it feasible to "wrap" the physics scene by relativizing every object to a focal point that moves in large, fixed increments as the camera moves about? Any major considerations here? Is there a better approach?
  4. Would there be any problems giving individual voxel bodies their own gravitational pull? I assume I could implement this by manually applying forces to objects in a given range of any body. This might rely on bullet providing some method of querying boxes or sphere for nearby objects... just an ordinary collision query I suppose?
Thanks in advance, hopefully my questions aren't too specific to garner an answer.
d3x0r
Posts: 51
Joined: Tue Dec 11, 2012 9:59 pm

Re: Dynamic Voxel Body Considerations

Post by d3x0r »

I would think a compound body of multiple cube shapes would be more efficient. Since voxels are all the same size; just one instance of the shape needs to be created and the box collider looks more efficient than triangle mesh. Each shape added to a compound shape has a transform within the compound object applied.

Gravity is actually represented in the rigid body that is moving; so you do need to update the vector from external sources.

the physics doesn't nessecarily have to be exactly the same scale as what you see; it could be scaled down; so a single voxel would be 1 unit in the physics engine... and more in visible space. Not sure how 'big' you mean... but if a voxel is 1m ... 1.0e30 is ... well... 1 light year is 9.461e+15m so ... 100,000,000,000,000 light years is within limit of single float precision. Although if you have sectors that are compound objects you could re-bias them to the player location
d3x0r
Posts: 51
Joined: Tue Dec 11, 2012 9:59 pm

Re: Dynamic Voxel Body Considerations

Post by d3x0r »

Actually was just thinking - that scale will lose precision... it's really only good for 6.7 million range. which is like 1/8 the earth circumferance in meters and only 2/3 the moon's circumferance... but still pretty darn large.
Frizzil
Posts: 2
Joined: Mon Nov 09, 2015 9:11 am

Re: Dynamic Voxel Body Considerations

Post by Frizzil »

Hmm, the idea of decomposing into cubes is interesting, but not directly applicable since my voxels are meshed via Marching Cubes (and potentially via Dual Contouring in the future), which gives a relatively smooth mesh. Maybe there's another way to apply the general idea though, as an optimization? Assuming the existing optimizations for triangle meshes aren't already better.

That's what I figured for gravity -- the world has a constant, but I can also set it on a per-rigid-body basis every frame.

I was just going to say that about the precision. :) Yeah, 1/8th the Earth's circumference is definitely a lot, but my goal is to be able to move at ridiculous Dragon Ball Z levels of speed, and to have a massive sense of scale, so I could still possibly run out. Maybe. So I thought it was worth asking.
d3x0r
Posts: 51
Joined: Tue Dec 11, 2012 9:59 pm

Re: Dynamic Voxel Body Considerations

Post by d3x0r »

Frizzil wrote:Hmm, the idea of decomposing into cubes is interesting, but not directly applicable since my voxels are meshed via Marching Cubes (and potentially via Dual Contouring in the future), which gives a relatively smooth mesh. Maybe there's another way to apply the general idea though, as an optimization? Assuming the existing optimizations for triangle meshes aren't already better.

That's what I figured for gravity -- the world has a constant, but I can also set it on a per-rigid-body basis every frame.
I see; *shrug* either way (cube shapes or mesh shapes or even just single mesh patches) still has to process all the elements to find collisions...

the gravity that's set in the world is copied to each body as it is added to the world; so modifying the gravity constant after adding the bodies doesn't do anything.
Post Reply