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:
I don't know how to do it. I need to detect collisions and generate contact data (contact point, contact normal and interpenetration to feed my existing engine). I know I can't use a SAT because the terrain in not convex. What about ad hoc code for boxes and spheres? or is there a general approach?
I narrowed down my problem to detecting (and resolving) collisions between a simple convex collidable (sphere/OBB) and triangles (always convex). Since the terrain is stored as an height map I can easily select a subset of triangles to run the algorithm against. I can use the SAT to detect interpenetrations. But what about collision response? How can I generate the necessary contact data (collision point and collision normal) to resolve the collision?