Not logged in, Join Here! or Log In Below:  
 
News Articles Search    
 

 Home / General Programming / Has somebody written code about bsp tree for collision detection? Account Manager
 
Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.
 
guokiller

May 07, 2005, 08:32 AM

I am writting a program about a bsp tree to decide whether I have a collision detection.Now I have a little problem.
If I have a collision
//Here is what Iˇˇwrote.It's about my action in every frame
bool collision=false;

move_function()
{

if(forward)//move forward
{
if(collision==false)
forward_function()
collision=false;
}

}

collision_detect_funtion()
{
//if there is a collision,collision =true,or false;
collision=bspCollision_test();
}

in every frame,if I was near to a wall,I could suddenly stopped at the wall,but
I can't move any more.And I don't know why
Do you have any better methods for collision detection?Thanks

 
Wernaeh

May 07, 2005, 08:42 AM

Hi there.

There are two possibilities:

a) You're stuck in the wall. That is, because of floating point imprecision, you moved so you are a little bit within the wall, and now when moving back, your not able to leave the wall completely. To cure, just check if your movement vector points into the direction of the wall. If it doesn't, don't collide.

b) You're not stuck, but don't slide. This happens when you can still move back, but don't naturally glide along the wall. You simply need to implement some gliding method to cure this problem. For example, project your collision normal onto the colliding bsp node plane, and move along that normal for the length of the movement vector that still sticks into the wall.

You might want to have a look at a collision detection tutorial written by Telemachos (google is your friend). There also is a valuable paper on MDK's collision detection based on bsp trees on gamasutra somewhere.

Cheers,
- Wernaeh

 
This thread contains 2 messages.
 
 
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.