# How is terrain collision handled

GJK can be used for all shapes but what if the points in a figure aren't indexed, then how can we get the Minkowski space by adding the correct pairs of points even though we don't know them, and also there might be too many points in the heightmap? Do some game engines also precompute contact points for static colliders?

• GJK can be used for all convex shapes. Terrain is generally not convex, so it's not an appropriate starting point for considering terrain collisions. Are you specifically thinking of heightmap based terrain, or voxel based, or something else? Commented Oct 3, 2023 at 22:32
• Is the collision of the terrain divided into several more abstract shapes?
– Nato
Commented Oct 7, 2023 at 19:03
• It can be, but again it depends on your situation. Can you edit your question to clarify what kind of terrain you're working with / how you've built it? Commented Oct 7, 2023 at 19:30
• I have a new idea: all of the terrain's vertices are put into a list, with each one's index being x+y+z, and we try to check a single point against it, which is also in the array. Then we search the array for the 3 closest points to the point we would like to check, then use normal techniques with triangles and points to see if it's inside, would this be efficient enough?
– Nato
Commented Jan 13 at 18:11
• If you mean that x+y+z as literal addition, that's a terrible idea that will result in a pile of index collisions. I think you'd be better off querying a heightmap, signed distance field, or sparse octree. But as I told you three months ago, to give you accurate help, we need you to edit your question to detail what kind of terrain you're using and how you've built it, plus what needs to collide against it. Commented Jan 13 at 19:12