Index: /branches/bsp_model/src/lib/collision_reaction/cr_physics_ground_walk.cc
===================================================================
--- /branches/bsp_model/src/lib/collision_reaction/cr_physics_ground_walk.cc	(revision 8333)
+++ /branches/bsp_model/src/lib/collision_reaction/cr_physics_ground_walk.cc	(revision 8334)
@@ -53,21 +53,16 @@
 void CRPhysicsGroundWalk::reactToCollision(Collision* collision)
 {
-//   CollisionEvent* ce = collision->getCollisionEvents().front();
-//   Vector normal = ce->getGroundNormal();
-//   normal.normalize();
-//
-//   Vector position = ce->getCollisionPosition();
+  CollisionEvent* ce = collision->getCollisionEvents().front();
+  Vector normal = ce->getGroundNormal();
+  normal.normalize();
 
+  // put it back
+  PRINTF(0)("putting it back to lastPos: \n");
+  this->lastPosition.debug();
+  PRINTF(0)("current pos:\n");
+  collision->getEntityB()->getAbsCoor().debug();
 
-  if( this->lastPosition != collision->getEntityB()->getAbsCoor())
-  {
-  // put it back
-    PRINTF(0)("putting it back to: \n");
-    this->lastPosition.debug();
-    this->afterLastPosition.debug();
-
-    collision->getEntityB()->setVelocity(Vector());
-    collision->getEntityB()->setAbsCoor(this->afterLastPosition);
-  }
+  collision->getEntityB()->setVelocity(Vector());
+  collision->getEntityB()->setAbsCoor(this->lastPosition);
 }
 
Index: /branches/bsp_model/src/lib/graphics/importer/bsp_manager.cc
===================================================================
--- /branches/bsp_model/src/lib/graphics/importer/bsp_manager.cc	(revision 8333)
+++ /branches/bsp_model/src/lib/graphics/importer/bsp_manager.cc	(revision 8334)
@@ -103,5 +103,5 @@
 const void BspManager::tick(float time)
 {
- 
+
   if(!this->bspFile->MovieMaterials.empty())
   {
@@ -109,12 +109,12 @@
       while(it != this->bspFile->MovieMaterials.end())
       {
-         (*it)->tick(time); 
+         (*it)->tick(time);
         it++;
       }
  //this->bspFile->MovieMaterials.front()->tick(time );
-  
-  
-  }
-  
+
+
+  }
+
 }
 const void BspManager::draw()
@@ -319,7 +319,7 @@
     if(this->bspFile->Materials[curFace.texture].animated) {
      // glBlendFunc(GL_ZERO,GL_ONE);
-   
-    
-      
+
+
+
       if(this->bspFile->Materials[curFace.texture].aviMat->getStatus() == 2) this->bspFile->Materials[curFace.texture].aviMat->start(0);
       //this->bspFile->Materials[curFace.texture].aviMat->tick(0.005);
@@ -328,5 +328,5 @@
       glBindTexture(GL_TEXTURE_2D, n );
       this->lastTex = curFace.texture;
-      
+
     } else {
       this->bspFile->Materials[curFace.texture].mat->select();
@@ -755,9 +755,10 @@
 
   float EPSILON = 0.000001;
-  float  endDistance = (end)->x * (node->plane.x) +(end)->y * (node->plane.y) +(end)->z * (node->plane.z)  - node->d;
-  float  startDistance = (start)->x * (node->plane.x)+ (start)->y * (node->plane.y)+ (start)->z * (node->plane.z)- node->d;
-
-
-  if(node->isLeaf) {
+
+  float endDistance = end->dot(node->plane) - node->d;
+  float startDistance = start->dot(node->plane) - node->d;
+
+
+  if( node->isLeaf) {
     leaf& curLeaf = this->bspFile->leaves[node->leafIndex];
     for (int i = 0; i <  curLeaf.n_leafbrushes ; i++) {
@@ -812,10 +813,7 @@
 
     // STEP 3: calculate the middle point for the first side
-    middleFraction = startFraction +
-                     (endFraction - startFraction) * fraction1;
-
-    middle.x = start->x + fraction1 * (end->x - start->x);
-    middle.y = start->y + fraction1 * (end->y - start->y);
-    middle.z = start->z + fraction1 * (end->z - start->z);
+    middleFraction = startFraction + (endFraction - startFraction) * fraction1;
+    middle = (*start) + ((*end) - (*start)) * fraction1;
+
 
     // STEP 4: check the first side
@@ -827,10 +825,6 @@
 
     // STEP 5: calculate the middle point for the second side
-    middleFraction = startFraction +
-                     (endFraction - startFraction) * fraction2;
-
-    middle.x = start->x + fraction2 * (end->x - start->x);
-    middle.y = start->y + fraction2 * (end->y - start->y);
-    middle.z = start->z + fraction2 * (end->z - start->z);
+    middleFraction = startFraction + (endFraction - startFraction) * fraction2;
+    middle = (*start) + ((*end) - (*start)) * fraction2;
 
     // STEP 6: check the second side
@@ -886,14 +880,7 @@
   dest.z  += forwardDir.z;
   */
-  
+
   dest = worldEntity->getAbsCoor();
   Vector out = dest;
-
-
-
-
-
-
-
 
 
@@ -913,26 +900,5 @@
     Vector out1;
     Vector out2;
-    /*
-    this->checkCollisionRayN(this->root,0.0f,1.0f, &position1, &dest1 );
-    if(this->outputFraction == 1.0f)  out1 = dest;
-    else {(
-      collision = true;
-      out1.x = position1.x + (dest1.x -position1.x) * this->outputFraction;
-      out1.y = position1.y + (dest1.y -position1.y) * this->outputFraction;
-      out1.z = position1.z + (dest1.z - position1.z) * this->outputFraction;
-
-    }
-
-    this->checkCollisionRayN(this->root,0.0f,1.0f, &position2, &dest2 );
-    if(this->outputFraction == 1.0f) out2= dest;
-    else {
-      collision = true;
-      out2.x = position2.x + (dest2.x -position2.x) * this->outputFraction;
-      out2.y = position2.y + (dest2.y -position2.y) * this->outputFraction;
-      out2.z = position2.z + (dest2.z - position2.z) * this->outputFraction;
-
-    }
-
-    */
+
 
     float height = 40;
@@ -940,8 +906,10 @@
 
     this->checkCollisionRayN(this->root,0.0f,1.0f, &position, &dest );
-    if(this->outputFraction == 1.0f)
+
+    if( this->outputFraction == 1.0f)
     {
       if(this->outputAllSolid)
       {
+        PRINTF(0)("this output all solid\n");
         this->collPlane = new plane;
         this->collPlane->x = 1.0f;
@@ -949,12 +917,13 @@
         this->collPlane->z = 0.0f;
         collision = true;
-        
       }
-      else collision = false;
+      else
+        collision = false;
+
+
       out = dest;
-      
     }
     else {
-      
+
       collision = true;
       out.x = position.x + (dest.x -position.x) * this->outputFraction;
@@ -968,20 +937,11 @@
       //this->drawDebugCube(&out1);
       //this->drawDebugCube(&out2);
-
       //this->drawDebugCube(&out3);
-
-    }
-
-
-
+    }
     // Return the normal here: Normal's stored in this->collPlane;
-
     if(collision ) {
       PRINTF(0)("We got a collision!! Are you sure: outputFraction = %f\n", this->outputFraction);
       worldEntity->registerCollision(this->parent, worldEntity, Vector(this->collPlane->x, this->collPlane->y, this->collPlane->z), out);
     }
-      //worldEntity->collidesWithGround(out,out1,out2);
-//     registerCollision(WorldEntity* entity, Vector(this->collPlane.x, ), Vector position);
-
   }
 
