To reach our weekly goal, we need to made an algorithm which detects collision between a triangle and a cube.
At the first sight, it’s looks pretty easy, we just have to test if any vertex of the triangle is inside the cube. However there could be a case where there is no vertex of the triangle inside the cube, but an edge of the triangle cut a plane or more of the cube. So ok, let’s test the intersections between each edge of the triangle and each plane of the box. HOWEVER, there is a last case : with a big triangle and a tiny box, the three edge could never intersect the cube, but the plane of the triangle could. So we also have to test the intersection between each edge of the cube and the plane of the triangle.
Lots of test just for saying there is no collision. It would be more efficient if the “no collision” case can be prove with few tests. A way to work on it could be the SAT : Separating Axis Theorem. On projecting the two objects on an axis, and looking if there is no gap between their “shadow”, we can determine the intersection. More explaination here :
We will try to implement this method.