CamWorld sliding collisions

Greetings all,

I posted a new demo featuring camworld sliding collisions on my site at:

This zip is only the EXE and the bitmaps. I’ll post the code after I’ve had a chance to clean it up.

I’m working on an engine for my detective game. My plan is for all movement to be either perpendicular to or parallel to the XZ plane. The user will be able to LOOK in any direction but only be able to move thusly.

This demo only support shapes that are a prism, rectangle parallel to or perpendicular to the XZ plane, sphere or cyliner/cone/partial cone parallel to the Y axis. The “offset distance” I’ve employed is 2. I should have made that configurable but oh well. When I move this code into my engine I’ll make sure to do that.

There are a couple of robots walking around the room. I was going to add code to make the robots push you but I got lazy . Also, the up/down sliding collisions for the prisms doesn’t work yet.

The controls are the cursor keys, shift left/right to strafe, and PgUp/PgDn to move up and down.

I plan to add a “climbability” flag to the objects - meaning for shapes like a sidewalk or steps or a ramp, you don’t slide along it, you slide or pop up it.

I also plan to relax as many of the very rigid assumptions I’ve made as possible. For example, nobody’s going to want to play my game if all they get to see are prisms, spheres and cylinders . I’m still thinking about how I want to implement sliding collisions with Milkshape models. I’ll probably but invisible forms around them to approximate them - won’t be perfect but may be better than nothing.

Now to get to the main points of my post:

  1. I welcome any comments or criticisms about the demo, as much as could be elicited without actually looking at the code.

  2. I’m really starting to wonder if the approach I took is making it too hard. The first sliding collisions demo I read was from All he does is sphere/polygon collide with every triangle in the world (I’m sure he’d BSP or Octree it if was “huge”), and move the camera back along the triangle’s normal if it was too close. At first I thought his approach wouldn’t work if there were acute angles between 2 triangles but now I’m not so sure. I’ll do more analysis and report my findings.

Has anyone else thought this through/experimented with this? How do you handle camworld sliding collisions when you don’t have the luxury of dozens of 90-degree angles, or if you have a lot of polygons that are small compared to the “offset distance”? Or what you have many small triangles creating a convex form that the user walks in to?

I might be making it too hard, I need to give it more of my own thought, but I’d certainly like to hear other people’s thoughts if you’ve already been down this road.


The code is going to be pretty bad no matter how much I clean it up so I might as well post it:

the main routine is CalculateNewLocation in main.cpp which either spits out the same X, Y and Z that were passed into it, or adjusts them according to the direction the camera was moving. Each of the objects’ classes has AdjustForSlidingCollisions methods which determine if the user is moving along or perpendicular to the XZ plane and adjust accordingly when appropriate.

Comments and insults alike welcome .