Ray Tracing Dynamic Mesh

Alright, so I’ve got a pretty good voxel world going right now (Random world generation, divided into chunks, physics, etc.), so I’ve decided to try to allow the player to break blocks, so I read up on ray tracing, and I’ve got it going great, the player can break the top layer of blocks… However any layers under that aren’t being picked up by the ray trace, so I marked the collision with a sphere, and it turns out that the ray is still colliding with the original block (the one on the top layer…).

My Update Chunk Method:

  1. Get every face that is adjacent to air, and get it’s vertices and UV mapping, and then store them in an arraylist.
  2. Take the arraylists, convert them to array, and then use them to update the mesh buffer.
  3. Call UpdateBounds() for the mesh, and UpdateModelBounds() for the spatial.
  4. Remove the rigid body control, create a new one, and finally attach the new rigid body control.

Is there anything that I’m obviously missing? If not, I can make a test-case…

If you are using the default JME collision stuff then when you modify the mesh you will need to reset the collision data, too. The method name escapes me at the moment.

But really, in this case the default BVH stuff that JME does is keeping a lot of data around and is slower than if you just did a block/grid-based intersection test yourself. The math and algorithm is only of medium complexity.

I never thought about that, but I could simple (ish) trig to achieve that…

I’ll look into doing that a bit later, right now I’m just going for something that works, optimizations (like this) I’m planning on doing after I’ve established minimal functionality for each part.

Thanks for the help, it worked like a charm.

For future reference the method was [java]mesh.createCollisionData()[/java]