Collision Detection inside of Hollow Bodies - best practice

Started by
4 comments, last by oliii 18 years, 2 months ago
I have recently implemented some collision detection: * Object-Object using OBB (not hollow objects!) * Object Terrain using HeightMaps Now there is one last collision that I can't figure out how to test it: CD within hollow objects like rooms, dungeons etc. The OBB doesn't seem to be well suited for this problem, since the Bounding Boxes do not need to be ligned up with the ground itself and the room can be quite big which can result in deep OBB trees. What is the "best practice" to imptlement CD inside of buildings and rooms? thanks for your help, patrick
Advertisement
Usually, it's done using per-triangle vs obb tests, with triangles stored in some kind of tree (AABB, octree, kd tree...). But you also have BSP trees constructs to do static mesh collisions.

Everything is better with Metal.

I'd say the easiest way is to modify your perception of reality.

A room isn't a single hollow object
It's 4 Simple Solid Walls that just happen to touch.
Lol, I think to clear up what daft mentioned, the walls can each be tested against your OBB. Try creating a plane for each wall to use in your collision testing. A plane as you might know is just a flat surface pointing in a certain direction. Easy as crap to test against all bounding primitives that I know of.
Also, you will want to organize your walls as smartly as possible, so you don't have to test against all of them all the time. You could do a tree structure for that if you wanted, doesn't matter to me. But organize them by room so you first find the room(s) you are in, then test against only those walls.

To note, this is really imho the best solution for rooms (dungeons included) with defined walls, floors and ceiling (lots of flat surfaces for these). But suppose you had a cave level with really rough terrain that you wanted to test against. There might be far too many planes to place in this setting, and you might be better off simply testing your OBB with a BSP tree or other collision structure.

Also, regarding plane collision. You will want to pass the collision test only if you are on the correct side of the plane, as any sane plane collision test will tell you which side of the plane it is on if it isn't intersecting. That way you won't get players "slipping through a crack" in a wall or floor. I played Dark Age of Camelot for a while and they had a couple of these that we made use of a lot. >)

Good luck!
- Enosch

hi all!

thanks for the replies! I will think about your suggestions and see what fits best in my framework.

I think extrapolating walls by planes would realy speed up the CD and if needed switching to the per triangle CD would give the required resolution on ruff terrain.

thx,
Patrick
using just hyperplanes can be a problem, due to the objects being not trivial (non-convex, convave edges and corners in rooms). Hence the use of BSP trees, or per-triangle CD with added space partitioning (AABBtree, KD trees, ect...). best of luck.

Everything is better with Metal.

This topic is closed to new replies.

Advertisement