Voxel Collision

Layla
Posts: 3
Joined: Sat Sep 21, 2013 8:05 pm

Voxel Collision

Post by Layla »

For over a year now I've been trying to integrate a physics engine into my environment that's made up of a uniform grid, either a block is in a cell there or there isn't, simple. First I tried doing it the dumb way, converting everything to triangles. This is not ideal because it's very slow to update the shape when the environment is constantly changing, it also uses up unnecessary memory when the environment is already represented as a flat array of bytes.

Recently I noticed that I could make a custom concave shape and submit triangles on the fly. This is a much better solution and it's the best I've come up with so far but I still don't see why any triangles need to be submitted at all. Would it be possible to have a custom shape to calculate contact points directly from the grid data?

Also, when bodies go to sleep and the environment changes, what is the best way to refresh contact points and wake any objects only in the area that changed?

Here's my code for my custom shape, it's very simple but this is by far the best way I've come up with to solve this.
https://gist.github.com/aylaylay/4c1459f7e8ad2841a38f

Another problem is that ragdolls get stuck a lot, mostly just feet and hands as they are quite small. Is there a better way to stop that from happening? I've tried everything. Running the simulation with a higher Hz helps but it still doesn't completely stop it from happening and it makes the performance terrible. CCD doesn't seem to help either.

I think it could help if triangles were single sided but I've searched the forums and there's no easy way to do this at all.

https://www.youtube.com/watch?v=Rw7sjHhK6SE