BSP Collision Issues

Started by
8 comments, last by Scarfy 18 years ago
Hi, For the most part my BSP collision engine works but sometimes I find that whilst walking on a slope I just fall through. Has anyone else had an issue like that..? Could anyone suggest anything I could investigate? This happens to enemies and items too. I've also noticed that if something is bouncing up and a slope and bouncing lower and lower each time, it will eventually fall through the slope if it bounces too little. Sorry if that's vague, I'd rather avoid posting BSP code right now because it's not exactly trivial to read! :) Just looking for suggestions... :| Ta
Parallel RealitiesProject: Starfighter
Advertisement
Maybe the bsp is not messing up. Are you sure that the problem isn't the collision code?
~Mark Schadler
Collision detection is fine perfect horizontal and vertical surfaces. I guess I should google for it a bit more... collision detection was put together from tutorials so I'm guessing they're not perfect.
Parallel RealitiesProject: Starfighter
Definately sounds like a precision problem perhaps.
"Never have a battle of wits with an unarmed man. He will surely attempt to disarm you as well"~Vendayan
After every collision fix, you should push the object to above the plane, so it never actually stays in contact with the plane, but just a little above the plane. If you like, I can post the code I use to do this.
Hi,

Could you do so..? That would be great... :)
Parallel RealitiesProject: Starfighter
sounds like the way you do things is every update you apply gravity and motion to your object, then to do collision detection to see if it is passing through a plane and do a velocity flip bounce or something

I'd guess that what is happening, is as it bounces lower and lower, eventually it gets so close to the plane that your collision detection 'misses' the collision, because floating point numbers are kinda innacurate and your object might appear to be on the other side of it by random chance.

first of all, it is a good idea to lose this entire method of bounce-bounce-bounce to simulate contact with the floor
and instead develop a notion of, objects 'at rest' touching the floor and not having gravity move them anymore
This should lead to savings since an object you already know is touching the floor isnt going to need to have infinitesimal bounces and responces every update...

Additionally, if possible you should add the concept of 'inside' and 'outside' of the map, so that even if an object falls through a floor polygon, subsequent updates should realize it is outside the map and thus must have collided with the floor sometime in the past (but missed), then do a correction.

the problem might also be with how your collision responce works, do you only change the objects future velocity when it hits? or do you also reposition it to account for the fact that inbetween update intervals is when the actual collision happened, so it really has moved up a little already?
I've been doing some more work on this and I think it may be due to the objects at some point lying exactly on the plane. I'm guessing I should move they a little away from the plane that they have hit as CadeF suggested.

The response repositions the objects and also changing their velocity according to whether they slide or not.

The collision detection does this,

Removes the OnGround flag

Starts up a while loop

Adds +EPISLON or -EPSILON as needed to the tracer end point if the velocity is not 0

Sets the position of the object to the position of the current trace

Performs a slide or a bounce if needed

Removes the added EPSILON if the outputFraction is 1.0

Exits if the outputFraction < 1

If you want to see code, just ask.
Parallel RealitiesProject: Starfighter
Quote:
I've been doing some more work on this and I think it may be due to the objects at some point lying exactly on the plane. I'm guessing I should move they a little away from the plane that they have hit as CadeF suggested.

it is an inprecision problem. As muc has u lower the EPSILON u will still at some point have a case where the number is between zero and epsilon and it is taken as zero not as Epsilon. I faced this in some bsp projects, and it was due to some art stuff. BSP is NOT a general algorithm, this means if u have 2 objects above each other and one of the vertices is lsightly misplaced the whole BSP is changed and u will get many bugs. Most solutions are to always use basic solid geometry object (spheres,...) and use unary operations on them to get the shapes. Now this will result in a gd BSP but not very good art.
I've sort of solved the issue. I say sort of because it's a nasty hack,

After I have finished the movement I then lift the entity upward by EPSILON. I then trace down by a small amount (0.5 in my case). If the trace fails it has hit the ground and I then tell my object it is infact on the ground.

It sounds horrible but it doesn't have any adverse effects. Not elegant but it works.
Parallel RealitiesProject: Starfighter

This topic is closed to new replies.

Advertisement