Index: trunk/src/lib/collision_reaction/cr_physics_ground_walk.cc
===================================================================
--- trunk/src/lib/collision_reaction/cr_physics_ground_walk.cc	(revision 9062)
+++ trunk/src/lib/collision_reaction/cr_physics_ground_walk.cc	(revision 9110)
@@ -70,12 +70,13 @@
 
 
-  float CR_MAX_WALK_HEIGHT = 2.0f;
+  float CR_MAX_WALK_HEIGHT = 15.0f;
   float CR_THRESHOLD = 0.2f;
 
-  float height = 0;
-  float front = 0;
-  float side = 0;
-
-  //PRINTF(0)("collision raction======================================\n");
+  float height = 0.0f;
+  float front = 0.0f;
+  float back = 0.0f;
+  float right = 0.0f;
+  float left = 0.0f;
+
 
   const std::vector<CollisionEvent*>* collisionEvents = &(collision->getCollisionEvents());
@@ -93,53 +94,55 @@
     switch( ce->getType())
     {
-        // collision in the x-axis
+        /* collision in the X-AXIS */
       case COLLISION_TYPE_AXIS_X:
-        front = collPos.len() - box->halfLength[0]; // should be [0]
+        front = collPos.len() - box->halfLength[0];
 
         // object is beneath the plane (ground)
         if( front <= 0.0f )
         {
-          Vector dirX = entity->getAbsDirX(); dirX.y = 0.0f; dirX.normalize();
+          Vector dirX = entity->getAbsDirX();
+          dirX.y = 0.0f;
+          dirX.normalize();
           Vector backoff = dirX * front;
-          
-          entity->setAbsCoor(entity->getLastAbsCoor());
-         // entity->shiftCoor(backoff);
-        }
-        // object is already in the wall
-        else if( ce->isInWall())
-        {
-              entity->setAbsCoor(entity->getLastAbsCoor());
-        }
-        break;
-        
+
+          entity->shiftCoor(backoff);
+        }
+        else if( ce->isInWall())
+        {
+          // object is already in the wall
+          entity->setAbsCoor(entity->getLastAbsCoor());
+        }
+        break;
+
       case COLLISION_TYPE_AXIS_X_NEG:
-        front = collPos.len() - box->halfLength[0]; // should be [0]
-
-        // object is beneath the plane (ground)
-        if( front <= 0.0f )
-        {
-          Vector dirX = entity->getAbsDirX(); dirX.y = 0.0f; dirX.normalize();
-          Vector backoff = dirX * front * -1.0f;
-          
-          entity->setAbsCoor(entity->getLastAbsCoor());
-         // entity->shiftCoor(backoff);
-        }
-        // object is already in the wall
-        else if( ce->isInWall())
-        {
-          entity->setAbsCoor(entity->getLastAbsCoor());
-        }
-        break;
-
-
-        // collision in the y-axis
+        back = collPos.len() - box->halfLength[0];
+
+        // object is beneath the plane (ground)
+        if( back <= 0.0f)
+        {
+          Vector dirX = entity->getAbsDirX();
+          dirX.y = 0.0f;
+          dirX.normalize();
+          Vector backoff = dirX * back * -1.0f;
+
+          entity->shiftCoor(backoff);
+        }
+        else if( ce->isInWall())
+        {
+          // object is already in the wall
+          entity->setAbsCoor(entity->getLastAbsCoor());
+        }
+        break;
+
+
+        /* collision in the Y-AXIS */
       case COLLISION_TYPE_AXIS_Y_NEG:
         // calulate the height above ground
-        height = collPos.y - box->halfLength[1];
-
-
-        // object is beneath the plane (ground)
-        if(height >= 0.0f && height <= 0.0001f) break ;// Do nothing
-        else if( height < 0.0f )
+        height = collPos.len() - box->halfLength[1];
+
+
+        // object is beneath the plane (ground)
+        //         if(height >= 0.0f && height <= 0.0001f) break ;// Do nothing
+        if( height < 0.0f && -height < CR_MAX_WALK_HEIGHT)
         {
           entity->shiftCoor(Vector(0.0f, -height + 0.00001, 0.0f));
@@ -160,36 +163,38 @@
 
 
+        /* collision in the Z-AXIS */
+      case COLLISION_TYPE_AXIS_Z:
+
+        right = collPos.len()  - box->halfLength[2];
+
+        // object is beneath the plane (ground)
+        if( right <= 0.0f )
+        {
+          Vector dirZ = entity->getAbsDirZ();
+          dirZ.y = 0.0f;
+          dirZ.normalize();
+          Vector backoff = dirZ * right;
+          entity->shiftCoor(backoff);
+        }
+        else if( ce->isInWall())
+        {
+          // object is already in the wall
+          entity->setAbsCoor(entity->getLastAbsCoor());
+        }
+        break;
+
+
         // collision in the z-axis
-      case COLLISION_TYPE_AXIS_Z:
-
-        side = collPos.len()  - box->halfLength[2]; // should be [2]
-
-        // object is beneath the plane (ground)
-        if( side <= 0.0f )
-        {
-          entity->setAbsCoor(entity->getAbsCoor());
-          Vector dirZ = entity->getAbsDirZ(); dirZ.y = 0.0f; dirZ.normalize();
-          Vector backoff = dirZ * side;
-          entity->shiftCoor(backoff);
-        }
-        // object is already in the wall
-        else if( ce->isInWall())
-        {
-          entity->setAbsCoor(entity->getLastAbsCoor());
-        }
-        break;
-        
-        
-         // collision in the z-axis
       case COLLISION_TYPE_AXIS_Z_NEG:
 
-        side = collPos.len()  - box->halfLength[2]; // should be [2]
-
-        // object is beneath the plane (ground)
-        if( side <= 0.0f )
-        {
-         
-          Vector dirZ = entity->getAbsDirZ(); dirZ.y = 0.0f; dirZ.normalize();
-          Vector backoff = dirZ * side*-1.0f;
+        left = collPos.len()  - box->halfLength[2];
+
+        // object is beneath the plane (ground)
+        if( left <= 0.0f )
+        {
+          Vector dirZ = entity->getAbsDirZ();
+          dirZ.y = 0.0f;
+          dirZ.normalize();
+          Vector backoff = dirZ * left*-1.0f;
           entity->shiftCoor(backoff);
         }
@@ -209,75 +214,4 @@
 
 
-#if 0
-  if( box != NULL)
-    height = ( ce->getCollisionPosition() - collision->getEntityB()->getAbsCoor() )*(-1.0f) ;
-  else
-    height = ce->getCollisionPosition() - collision->getEntityB()->getAbsCoor() ;
-
-
-  if( box != NULL)
-  {
-
-
-    if(ce->getCollisionPosition().x <= 0.9 && ce->getGroundNormal().len() <= 1.4f)
-    {
-      collision->getEntityB()->setAbsCoor(collision->getEntityB()->getLastAbsCoor());
-      return;
-    }
-    if(ce->getCollisionPosition().z <= 0.9 && ce->getGroundNormal().len() <= 1.4f)
-    {
-      collision->getEntityB()->setAbsCoor(collision->getEntityB()->getLastAbsCoor());
-      return;
-    }
-
-    if(ce->getGroundNormal().len() <= 0.1f)
-    {
-      collision->getEntityB()->setAbsCoor(collision->getEntityB()->getLastAbsCoor());
-      return;
-    }
-
-
-    if(ce->getGroundNormal().len() >= 1.4f)
-    {
-      downspeed++;
-      collision->getEntityB()->setAbsCoor(collision->getEntityB()->getAbsCoor() + Vector(0.0,-0.08*downspeed,0.0));
-      return;
-    }
-
-
-    if(height.y > box->halfLength[1] + 0.0f ) // Above ground
-    {
-      if(height.y < box->halfLength[1] + 2.3f) // Snap in
-      {
-        downspeed = 0;
-        collision->getEntityB()->setAbsCoor(collision->getEntityB()->getAbsCoor() - Vector(0.0,height.y  - box->halfLength[1] - 0.0f,0.0));
-      } else
-      {
-        downspeed++;
-        collision->getEntityB()->setAbsCoor(collision->getEntityB()->getAbsCoor() + Vector(0.0,-0.08*downspeed,0.0));
-      }
-
-    }
-    else
-    {
-      if(height.y <  box->halfLength[1] + 0.0f   /* && height.y  >  - 55.0f*/) // below ground
-      {
-        //if(downspeed <= 0) downspeed =1;
-        collision->getEntityB()->setAbsCoor(collision->getEntityB()->getAbsCoor() + Vector(0.0, -height.y  +  box->halfLength[1] + 2.0f,0.0));
-        //collision->getEntityB()->setVelocity(Vector(0.0,0.0,0.0));
-        downspeed = 0;
-      }
-
-    }
-
-  }// if(box!= NULL)
-#endif
-  /*
-  PRINTF(0)("Collision with Ground: \n");
-  collision->getEntityB()->getAbsCoor().debug();
-  collision->getEntityB()->setVelocity(Vector());
-  collision->getEntityB()->setAbsCoor(this->lastPositions[1]);
-
-  */
 
 }
