View Full Version : False positive result during collision detection

10-12-2014, 09:20 AM
Hello everybody

I'm struggling with finishing my collision detection algorithm.
Generally, everything's working fine, except for false-positive results gotten on perpendicular walls.

Think of a case, when there is a floor, made of two cubes near sticked to eachotner, that are on the same height (look at example below). The collision happens between them, despite, they are on the same height.
The same would happen on walls, made of two cubes etc. (poorly drawn example (http://i1050.photobucket.com/albums/s418/robwypior/example_zps77be89cd.jpg~original))

This leads to collision with small obstacles, like a little stone on the floor, that player should be able to step on, or stairs, which shouldn't happen.

My collision detection code looks like this:

Collision &c = collisions[i]; // Repeat this code for every possible collision
const glm::vec3 &n = c.Normal(); // Get colliding surface normal
float dot = glm::dot(vel, n);
if (dot < 0.0f)
glm::vec3 res = n * dot;
vel -= res; // Vel - movement velocity

How to prevent such a short walls and obstacles to collide?