Concave Mesh Collisions

Have been playing around with a technique for concave mesh collisions.

Each time this PG https://www.babylonjs-playground.com/#3PFMJH#2 is run the green and blue stars are randomly rotated and the y position for the blue star is randomly placed between -3 and 3. The two concave stars move towards each other and stop when they touch.

Probably a lot of optimization to be done but its been fun.

TL;DR
This is the technique
An icosphere, (S) is placed around the concave mesh (M). A ray is sent out from every vertex of (M) and a map created between each vertex of (M) and the face of (S) that the ray hits.

Babylon.js Playground.

This mapping is an indication of which faces of (S) lie in the same forward direction of (M). So for a given forward direction of (M) a net of rays are sent from a plane through the middle of (S) to determine which faces of (S) are the forward faces. Each of these forward faces contains the map showing the matching forward vertices of (M). From these forward faces rays are sent out in the forward direction of (M)

https://www.babylonjs-playground.com/#3PFMJH#1

Any rotation of (M) is inversely applied to the forward direction before the faces of (S) hit by the rays are determined.

A stopping distance (about twice the pixel speed per frame of the concave meshes) is set and the meshes halt when either the first is close enough to the second or then vice versa.

7 Likes

so interesting stuff i try make the GPU picking system that picked a single pixel of mesh
that system not have any limitation and that work well but i lost some fps :frowning: