I want to detect collisions of very complex moving objects (about 500.000 vertices each Object - CAD models)
I`m trying to solve the problem since a month and cant find a working solution.
I`ve already tried:
- Splitting the Objects, to make them convex (like the asset ConcaveCollider) → Too many parts and too long calculating time.
- Raycasting Meshpoints → Too many points.
- ignoring the physics → doesnt work on meshs.
- mesh bounds → too inaccurate.
- …
“Is Trigger” wihthout “convex” is exaytly what I need. But since Unity5 it isnt possible anymore.
Has somebody another idea or solution?
Thank you for your help.
We have achieved this during the physics coursework in c++ MSc.
There is no easy way exposed by Unity that I am aware of, but it’s totally possible.
So the idea was to detect collisions with the object which is concave and is moving.
I solved it the following way:
-
First of all, overlap the entire 500000 vert mesh into a Bounding Box to allow for some sort of broad phase check. If the incoming, possible collider is outside of the bounding box - we are definitely not colliding with the mesh, stop right there.
Of course, this requires you to be in the local space of our big mesh, I talk about it in 4), later
-
since the mesh is built of triangles - store them in an Octree datastructure or better - KD binary search tree. This happens only once, during the pre-computation stage and not during the game.
-
each triangle of our big mesh can be treated as a plane - it’s flat, has 3 points and has a normal.
-
since you want the mesh to rotate, before you test for collisions with its triangles, you need to bring the potential colliding objects in the mesh’s local space. You do this by multiplying the incoming potential colliding object by the inverse model matrix of our big mesh (assuming the incoming object is in the world space already. Otherwise, multiply by its model matrix to bring it in world space, and THEN by the inverse model matrix of our big mesh to bring it into our mesh’s local space)
-
test its triangles against the triangles of our big mesh, in the corresponding octree’s section.
test if the point is behind a triangle the same way as you would test if a point is behind a plane. That is- using dot product between the plane’s normal AND the vector from the plane to point. If it’s negative -point is behind the plane.
Igor
Thank you for your fast answer.
I`m not sure whether I understand your solution.
Sounds for me like raycasting?
I thnik the problem will be that I have to much points to test?