How does map collision detection work for Source/BSP style maps?

Started by
2 comments, last by JoeJ 1 year, 5 months ago

This might be a really dumb question, but I am genuinely curious. Are there any good resources on how Source or similar game engines handle rigidbody collision with the static map? The reason why is because I am mainly curious how these game engines handle preventing rigidbodies from being in the “negative space” or the out of bounds area of the map. I mean, you can still put these objects in these regions, but they won't behave like normal physics objects in these regions and the game engine tries to push these objects outside of these regions. This is unlike other ways I have seen to handle collisions in maps, where a rigid body always seems to have a small potential to fall off the map. Suppose I want to make a game engine that mainly handles indoor maps not unlike Source, and I want to avoid these objects from stably existing out of bounds, how would I go about implementing this? Does this have something to do with the way these maps are constructed (ie. brushes, bsp, etc) that makes this possible?

Advertisement

Are we talking like a 3D object in a 3D world map? I am typically just careful to have no holes in the map geometry. There is simply no way to get out of bounds from an in-bounds area. If you have gravity you can also check for a situation where a player (or object) has dropped below a certain altitude and just move them to a safe spot. This is still a bug of course, but at least it can keep things from crashing.

The caveat here is that I'm sweeping spheres and capsules rather than using a physics engine. I've heard that objects can move through thin sold walls if moving too fast with most physics engines. This can't happen with sweeping (assuming no bugs) but I gather there is a performance cost. If you are using this for avatars or other things that can be simply bounded by spheres and capsules, it's probably not a big deal. If you want very general physics however, You might have to go for some other solution.

nathan29299292 said:
Does this have something to do with the way these maps are constructed (ie. brushes, bsp, etc) that makes this possible?

BSP has the advantage that it gives a robust definition of solid and empty space. Meshes don't enable a quick test, even if they are manifold (which mostly they are not). Thus meshes only define a surface, but no solid or empty space.

BSP also supports fast point queries or ray tracing. So colliding spheres or capsules against it is fast and robust, and likely the same applies to convex polyhedra.

But if i have to guess, this was used for games like Quake or HL1, but likely not anymore for HL2. For the latter, i assume they converted BSP to meshes, and Havok physics used its default support of static meshes for collision detection.
That's really just a guess, but HL2 had many static models which were not part of BVH, so they needed mesh support anyway, and mixing different representations of geometry and acceleration structures feels complex but no win.

This topic is closed to new replies.

Advertisement