Hello community,
I have successfully implemented a compound collider based on primitives (In my case cubes). Now I have to implement the exact collision on polygon level.
The built-in methods CCD and speculative CCD did not sound to me the right ones since they seemed to be targeting fast moving objects. That would not be a requirement in my case.
My idea was the outlined stepwise approach below. Any feedback would be highly welcome regarding:
- Have I missed a built-in unity feature that would make it easier
- if yes: starting point how to do it better
- Assumption of algorithm: Correct to avoid using MeshCollider as long as possible
My scenario:
- A tool e.g. a chisel (marked red) is hitting a sculpture (marked in blue). The sculpture consists of multiple convex shapes with box colliders
- Technically: Tool has a rigidbody attached and the collisionproivder is marked as trigger
- Need for exact collision: box collider don’t mesh the underlying mesh exactly
Planned stepwise approach (see also attached picture Step 0 = starting situation; Steps 1 - 3 as described above)
1. Standard box collider test with cubes
Done between: Box colliders of tool and all box colliders of the convex shapes within the shape
Yields: Multiple convex shapes that collided with tool based on box colliders
2. Filter relevant edges against box collider tool
Done between: Edges of relevant sculpture shapes against box collider tool that collided
How done:
My ideas is to do a check with multiple raycasts. Each fired ray would exactly match one edge of the convex shape. Since the cube based collider is also convex testing the edges should be enough. Per tested edge the result is stored (Hit at all; convex shape; which collider within the tool hit).
What is the result:
- Relevant convex shapes that need to be tested exactly (=> relevant if at least one ray check hit)
- Relevant edges for exact test (Only those collided with the simplified bounding box tool)
3. Exact raycast check against exact tool meshcollider
Raycheck as before per relevant edge against tool with exact mesh collider. Raytest is limited per layer to the mesh collider. If at least one ray collided there is a collision.
