🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

OBB-triangle and sphere-triangle contact data/manifold with SAT

Started by
1 comment, last by Randy Gaul 5 years, 7 months ago

I'm implementing my physics engine for my 3D game. So far I've been able to implement collision detection between OBB, spheres and planes. The engine generate contacts and resolve them with an iterative impulse-based approach.

The result is this (so far).

Now I need to detect and generate contacts between a height map terrain and those bounding volumes (sphere and OBB). The terrain looks like this:

KTwEd.jpg

I understand that the approach is to select the triangles under the colliding object (a subset of the terrain mesh, an heightmap) and perform a collision detection test between the triangles and the bounding volume of the colliding object (I use spheres and OBBs).

I looked into OBB/sphere - triangle collision detection and I found how to do it by applying the SAT test. What I can't get info about, or an example implementation is how to generate contact data/manifold from it. I know the contact normal and penetration can be gathered by the SAT (the normal is the axis of least penetration, and the relative overlap is the interpenetration), but I need some ad hoc code for the contact point.

In the excellent book by Millington Game Physics Engine Development I found some code that deals with the OBB-OBB case. I need something similar for OBB/sphere - triangle case.

Advertisement

For sphere to triangle you can use GJK to compute closest points between the sphere's center and the triangle. Given these, computing a manifold becomes trivial. For other convexes to triangle, I have used SAT between convex meshes. It's also possible to store adjacency information between triangles in your heightmap, and collide convex meshes against these (this way you can avoiding "interior edge" collisions by properly representing the Voronoi regions of shared edges between triangles).

Be sure to look up Dirk's resources from GDC 2013-2015 at box2d.org/downloads.

I would recommend to stop reading Ian Millington's book. It's not state of the art and uses a lot of out-dated technology. It's an OK book for an introduction to collision detection, but as you are noticing in your post, it must quickly be retired in favor of other resources.

This topic is closed to new replies.

Advertisement