- Home /
concave dynamic meshes collision
I have a dynamic player created mesh that can be concave and need to collide with another dynamic player created mesh that can be concave too. I have a mesh collider for both the whole shapesmeshes but they aren't colliding since unity do not detect collision for concave mesh colliders, only convex ones. I can't have convex mesh colliders since my meshes do need to go one inside the other in some cases. I already tried with multiple child colliders since my dynamic meshes are made of voxels but these primitive colliders become too many for unity to handle (there can be thousand of them). I thought of grouping some voxels togheter to create less mesh colliders and try to keep them convex but this solution is also too slow.
Anyone knows of a better and performance wise solution?
Thanks for your suggestion! Yes my meshes are made of cubic "voxels", I know it's not a proper definition but I used it to try to be be as clear as possible :-) You are right and my meshes are created from a 3D array of 4096 element (16x16x16) so I know where any solid block is so I already hide buried faces of my blocks. I thought about your suggestion but I will still have big problems if my mesh is full of random placed empty block (I am using this situation for benchmark as a worst case scenario) because a convex decomposition algorythm will probably create thousands of children too or maybe I do not understand these methods and I am wrong!
maybe I can try to implement my sort of collision using raytraces? Even if I prune all the surface of voxels that can't collide I will still need thousand of raytraces to calculate collision in a satisfactory way. I really can't find a solution
Answer by Jeff-Kesselman · May 03, 2014 at 10:28 PM
You're on the right track, but you need to group the colliders into a few convex objects.
There have been multiple papers and articles written on techniques to split concave objects into the minimal set of convex ones. Id suggest you google and start reading.
Edit: It occurs to me that you a r calling these "voxels" (a bit of a misnomer but just something that many people are confused with these days.) If that means that they are totally filling or not-filling squares in a grid, you could use an octree approach to subdividing them into 3Dsquare areas.
With a bit of cleverness, if that was still too many, you could then recombine ones that share common faces along an axis.
Thanks for your suggestion! Yes my meshes are made of cubic "voxels", I know it's not a proper definition but I used it to try to be be as clear as possible :-) You are right and my meshes are created from a 3D array of 4096 element (16x16x16) so I know where any solid block is so I already hide buried faces of my blocks. I thought about your suggestion but I will still have big problems if my mesh is full of random placed empty block (I am using this situation for benchmark as a worst case scenario) because a convex decomposition algorythm will probably create thousands of children too or maybe I do not understand these methods and I am wrong!
Your answer
Follow this Question
Related Questions
I need a concave mesh collider to work with a rigidbody 0 Answers
Rigidbody bowls/baskets - is there a better way? 0 Answers
MeshCollider Collision Table 2 Answers
adding a mesh collider to this heightmap script properly 1 Answer
Is it better to use Mesh Colliders on Mass Projects or Box Colliders? 2 Answers