From 9d152e2773f28d4fb7066010d2ae9099873cb6fd Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Mon, 4 Jan 2010 01:02:33 +0100 Subject: Corrected edge & vertex collision --- src/Game.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/Game.cpp') diff --git a/src/Game.cpp b/src/Game.cpp index f583312..aea829f 100644 --- a/src/Game.cpp +++ b/src/Game.cpp @@ -131,10 +131,10 @@ void Game::run(int delta) { vmml::vec3f origMove = playerMove; - bool ok = false; + bool collision = true; - while(!ok) { - ok = true; + while(collision) { + collision = false; MathUtil::Plane nearestPlane; float nearestDistance; @@ -150,8 +150,8 @@ void Game::run(int delta) { vmml::vec3f intersection = p.intersection(MathUtil::Ray(playerPos, playerMove)); float distance = intersection.squared_distance(playerPos); - if(ok || distance < nearestDistance) { - ok = false; + if(!collision || distance < nearestDistance) { + collision = true; nearestPlane = p; nearestDistance = distance; @@ -164,7 +164,7 @@ void Game::run(int delta) { } } - if(!ok) { + if(collision) { vmml::vec3f move; if(playerMove.dot(nearestPlane.getNormal()) == 0) -- cgit v1.2.3