Index: trunk/src/lib/collision_reaction/Makefile.am
===================================================================
--- trunk/src/lib/collision_reaction/Makefile.am	(revision 8362)
+++ trunk/src/lib/collision_reaction/Makefile.am	(revision 8490)
@@ -9,5 +9,6 @@
                      collision_handle.cc \
                      collision_reaction.cc \
-                     cr_object_damage.cc
+                     cr_object_damage.cc \
+                     cr_physics_ground_walk.cc
 
 
@@ -19,4 +20,5 @@
                      cr_defs.h \
                      collision_reaction.h \
-                     cr_object_damage.h
+                     cr_object_damage.h \
+                     cr_physics_ground_walk.h
 
Index: trunk/src/lib/collision_reaction/collision.h
===================================================================
--- trunk/src/lib/collision_reaction/collision.h	(revision 8362)
+++ trunk/src/lib/collision_reaction/collision.h	(revision 8490)
@@ -27,5 +27,5 @@
 
     /** collides two WorldEntities @param entityA world entity A, @param entityB world entity B, @param bvA volume A @param bvB volumeB */
-    inline void collide(WorldEntity* entityA, WorldEntity* entityB) { this->entityA = entityA; this->entityB = entityB; }
+    inline void collide(WorldEntity* entityA, WorldEntity* entityB) { this->entityA = entityA; this->entityB = entityB; this->bDispatched = false; }
 
 
@@ -42,4 +42,5 @@
     /** sets the flag if it reacts @param flag true if it should react on entityB*/
     inline void setEntityBCollide(bool flag) { this->entityACollide = flag; }
+
 
     /** @returns true if this Collision has already been dispatched */
Index: trunk/src/lib/collision_reaction/collision_event.h
===================================================================
--- trunk/src/lib/collision_reaction/collision_event.h	(revision 8362)
+++ trunk/src/lib/collision_reaction/collision_event.h	(revision 8490)
@@ -25,6 +25,6 @@
   { this->entityA = entityA; this->entityB = entityB; this->bvA = bvA; this->bvB = bvB; }
   /** collides two WorldEntities @param entity world entity , @param ground ground plane, @param position position on the ground */
-  inline void collide(WorldEntity* entity, Plane* ground, Vector position)
-  { this->entityA = entity; this->ground = ground; this->position = position; }
+  inline void collide(WorldEntity* entity, WorldEntity* groundEntity, Vector normal, Vector position)
+  { this->entityA = entity; this->entityB = groundEntity, this->groundNormal = normal; this->position = position; }
 
 
@@ -38,8 +38,9 @@
   inline BoundingVolume* getBVB() const { return this->bvB; }
 
+  /** @return ground plane if collided with bsp model */
+  inline Vector getGroundNormal() { return this->groundNormal; }
 
-  inline void operator()(WorldEntity* entityA, WorldEntity* entityB, BoundingVolume* bvA, BoundingVolume* bvB) { this->collide(entityA, entityB, bvA, bvB); }
-  inline void operator()(WorldEntity* entity, Plane* ground, Vector position) { this->collide(entity, ground, position); }
-
+  /** @return position of the position, only accurate if this is a collision with the ground!!! */
+  inline Vector getCollisionPosition() { return this->position; }
 
  private:
@@ -50,5 +51,5 @@
   BoundingVolume*   bvB;                           //!< reference to the bounding volume B
 
-  Plane*            ground;                        //!< the ground plane with which it collides (only for bsp-model collisions
+  Vector            groundNormal;                  //!< the ground plane with which it collides (only for bsp-model collisions
   Vector            position;                      //!< position of the collision on the ground plane
 };
Index: trunk/src/lib/collision_reaction/collision_handle.cc
===================================================================
--- trunk/src/lib/collision_reaction/collision_handle.cc	(revision 8362)
+++ trunk/src/lib/collision_reaction/collision_handle.cc	(revision 8490)
@@ -24,4 +24,5 @@
 
 #include "cr_object_damage.h"
+#include "cr_physics_ground_walk.h"
 
 #include "debug.h"
@@ -42,20 +43,24 @@
 
   this->bCollided = false;
-  this->bDispatched = false;
-
-  if( this->type == CREngine::CR_PHYSICS_STEP_BACK)
-    this->bContinuousPoll = false;
-  else
-    this->bContinuousPoll = true;
-
-  if( this->type == CREngine::CR_OBJECT_DAMAGE)
-    this->bStopOnFirstCollision = true;
-  else
-   this->bStopOnFirstCollision = false;
+  this->bDispatched = true;
+
+  this->collisionReaction = NULL;
+  this->bContinuousPoll = false;
+  this->bStopOnFirstCollision = false;
+
 
   switch( type)
   {
+    case CREngine::CR_PHYSICS_STEP_BACK:
+//       this->collisionReaction = new CRPhysicsGroundWalk();
+      this->bContinuousPoll = true;
+      break;
+    case CREngine::CR_PHYSICS_GROUND_WALK:
+      this->collisionReaction = new CRPhysicsGroundWalk();
+      this->bContinuousPoll = true;
+      break;
     case CREngine::CR_OBJECT_DAMAGE:
       this->collisionReaction = new CRObjectDamage();
+      this->bStopOnFirstCollision = true;
       break;
     default:
@@ -71,4 +76,6 @@
 {
   // delete what has to be deleted here
+  if( this->collisionReaction != NULL)
+    delete this->collisionReaction;
 }
 
@@ -169,4 +176,5 @@
 
  c->registerCollisionEvent(collisionEvent);
+ PRINTF(0)("Registering Collision Event: %s, %s\n", collisionEvent->getEntityA()->getClassName(), collisionEvent->getEntityB()->getClassName());
 }
 
@@ -186,4 +194,11 @@
 void CollisionHandle::handleCollisions()
 {
+  // if continuous poll poll the reaction
+  if( this->bContinuousPoll && !this->bCollided)
+  {
+    this->collisionReaction->update(this->owner);
+    return;
+  }
+
   // collision reaction calculations (for every collision there will be a reaction)
   vector<Collision*>::iterator it = this->collisionList.begin();
@@ -214,9 +229,15 @@
   {
     if( collisionEvent->getEntityA() == this->owner) {
-      if( collisionEvent->getEntityA()->isA((ClassID)(*it)))
+      if( collisionEvent->getEntityB()->isA((ClassID)(*it))) {
+        PRINTF(0)("I am: %s colliding with: %s is a %i filter ok\n", owner->getClassName(),
+                  collisionEvent->getEntityB()->getClassName(), *it);
         return true; }
+    }
     else {
-      if( collisionEvent->getEntityB()->isA((ClassID)(*it)))
-        return true; }
+      if( collisionEvent->getEntityA()->isA((ClassID)(*it))) {
+        PRINTF(0)("I am: %s colliding with: %s is a %i filter ok\n", owner->getClassName(),
+                  collisionEvent->getEntityA()->getClassName(), *it);
+      return true; }
+    }
   }
 
Index: trunk/src/lib/collision_reaction/collision_handle.h
===================================================================
--- trunk/src/lib/collision_reaction/collision_handle.h	(revision 8362)
+++ trunk/src/lib/collision_reaction/collision_handle.h	(revision 8490)
@@ -41,4 +41,6 @@
     /** @returns true if this handle should be pulled also if there are no collisions */
     inline bool isContinuousPoll() const { return this->bContinuousPoll; }
+    /** @returns the type */
+    inline CREngine::CRType getType() const { return this->type; }
 
     void handleCollisions();
Index: trunk/src/lib/collision_reaction/collision_reaction.h
===================================================================
--- trunk/src/lib/collision_reaction/collision_reaction.h	(revision 8362)
+++ trunk/src/lib/collision_reaction/collision_reaction.h	(revision 8490)
@@ -12,4 +12,6 @@
 
 class Collision;
+class WorldEntity;
+
 
 //! A class representing a simple collision
@@ -23,4 +25,7 @@
     virtual void reactToCollision(Collision* collision) = 0;
 
+    virtual void update(WorldEntity* owner) {}
+
+    /** use this to do some collision offline calculations, only called for bContinuousPoll == true */
     inline bool isContinuousPoll() const { return this->bContinuousPoll; }
 
Index: trunk/src/lib/collision_reaction/cr_engine.cc
===================================================================
--- trunk/src/lib/collision_reaction/cr_engine.cc	(revision 8362)
+++ trunk/src/lib/collision_reaction/cr_engine.cc	(revision 8490)
@@ -126,8 +126,6 @@
 {
   std::vector<CollisionHandle*>::iterator it;
-  for( it = this->collisionHandles.begin(); it != this->collisionHandles.end(); it++)
-  {
-    if( *it == collisionHandle)
-    {
+  for( it = this->collisionHandles.begin(); it != this->collisionHandles.end(); it++)  {
+    if( *it == collisionHandle) {
       this->collisionHandles.erase(it);
       delete collisionHandle;
@@ -147,5 +145,5 @@
   for( it = this->collisionHandles.begin(); it != this->collisionHandles.end(); it++)
   {
-    if( (*it)->isCollided() || (*it)->isContinuousPoll())  //does it have any collisions to report at all
+    if( !(*it)->isDispatched() || (*it)->isContinuousPoll())  //does it have any collisions to report at all
     {
       (*it)->handleCollisions();
Index: trunk/src/lib/collision_reaction/cr_object_damage.cc
===================================================================
--- trunk/src/lib/collision_reaction/cr_object_damage.cc	(revision 8362)
+++ trunk/src/lib/collision_reaction/cr_object_damage.cc	(revision 8490)
@@ -54,7 +54,7 @@
 void CRObjectDamage::reactToCollision(Collision* collision)
 {
-  float damage;
+  float damage = 0.0f;
 
-  PRINTF(0)("Dealing damage - Handling collision: %s vs %s\n",
+  PRINTF(4)("Dealing damage - Handling collision: %s vs %s\n",
             collision->getEntityA()->getClassName(),
             collision->getEntityB()->getClassName());
@@ -65,5 +65,5 @@
     collision->getEntityA()->decreaseHealth(damage);
   }
-  PRINTF(0)("Dealing damage - %f damage to %s \n", damage, collision->getEntityA()->getClassName());
+  PRINTF(4)("Dealing damage - %f damage to %s \n", damage, collision->getEntityA()->getClassName());
 
   if( collision->isEntityBCollide()) {
@@ -71,5 +71,5 @@
     collision->getEntityB()->decreaseHealth(damage);
   }
-  PRINTF(0)("Dealing damage - %f damage to %s \n", damage, collision->getEntityB()->getClassName());
+  PRINTF(4)("Dealing damage - %f damage to %s \n", damage, collision->getEntityB()->getClassName());
 
   collision->flushCollisionEvents();
Index: trunk/src/lib/collision_reaction/cr_physics_ground_walk.cc
===================================================================
--- trunk/src/lib/collision_reaction/cr_physics_ground_walk.cc	(revision 8490)
+++ trunk/src/lib/collision_reaction/cr_physics_ground_walk.cc	(revision 8490)
@@ -0,0 +1,88 @@
+/*
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2004 orx
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   ### File Specific:
+   main-programmer: Patrick Boenzli
+   co-programmer: ...
+*/
+
+#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_COLLISION_REACTION
+
+#include "collision.h"
+#include "collision_event.h"
+
+#include "physics_interface.h"
+
+#include "world_entity.h"
+#include "cr_physics_ground_walk.h"
+
+#include "debug.h"
+
+#include <vector>
+
+using namespace std;
+
+
+/**
+ *  standard constructor
+ */
+CRPhysicsGroundWalk::CRPhysicsGroundWalk ()
+  : CollisionReaction()
+{
+  this->setClassID(CL_CR_PHYSICS_GROUND_WALK, "CRPhysicsGroundWalk");
+}
+
+
+/**
+ *  standard deconstructor
+ */
+CRPhysicsGroundWalk::~CRPhysicsGroundWalk ()
+{
+}
+
+
+/**
+ * caluculates and applys the reaction to a specific collision
+ *  @param collision the collision
+ */
+void CRPhysicsGroundWalk::reactToCollision(Collision* collision)
+{
+  CollisionEvent* ce = collision->getCollisionEvents().front();
+  Vector normal = ce->getGroundNormal();
+  normal.normalize();
+
+  // put it back
+//   PRINTF(0)("putting it back to lastPos: \n");
+//   this->lastPositions[0].debug();
+//   PRINTF(0)("current pos:\n");
+//   collision->getEntityB()->getAbsCoor().debug();
+
+  PRINTF(0)("Collision with Ground: \n");
+  collision->getEntityB()->getAbsCoor().debug();
+
+  //collision->getEntityB()->setVelocity(Vector());
+  //collision->getEntityB()->setAbsCoor(this->lastPositions[5]);
+}
+
+
+
+/**
+ * use this to do some collision offline calculations, only called for bContinuousPoll == true
+ */
+void CRPhysicsGroundWalk::update(WorldEntity* owner)
+{
+  for( int i = 9; i > 0; i--) {
+    this->lastPositions[i] = this->lastPositions[i-1];
+//     PRINTF(0)("lastPosition[%i]: %f, %f, %f\n", i, lastPositions[i].x, lastPositions[i].y, lastPositions[i].z);
+  }
+  this->lastPositions[0] = owner->getAbsCoor();
+}
+
+
Index: trunk/src/lib/collision_reaction/cr_physics_ground_walk.h
===================================================================
--- trunk/src/lib/collision_reaction/cr_physics_ground_walk.h	(revision 8490)
+++ trunk/src/lib/collision_reaction/cr_physics_ground_walk.h	(revision 8490)
@@ -0,0 +1,33 @@
+/*!
+ * @file cr_object_damage.h
+ *  Definition of a collision reaction: dealing damage to an object
+ */
+
+#ifndef _CR_PHYSICS_GROUND_WALK_H
+#define _CR_PHYSICS_GROUND_WALK_H
+
+#include "collision_reaction.h"
+
+
+class Collision;
+
+//! A class representing a reaction to a collision: dealing damage to an object
+class CRPhysicsGroundWalk : public CollisionReaction
+{
+  public:
+    CRPhysicsGroundWalk();
+    virtual ~CRPhysicsGroundWalk();
+
+    virtual void reactToCollision(Collision* collision);
+
+    virtual void update(WorldEntity* entity);
+
+  private:
+    Vector       lastPosition;                //!< vector with the last valid position
+    Vector       afterLastPosition;           //!< vector for the after last
+    Quaternion   lastDirection;               //!< quat with the last valid direction
+
+    Vector       lastPositions[10];           //!< last 10 positions
+};
+
+#endif /* _CR_PHYSICS_GROUND_WALK_H */
