Index: branches/coll_rect/src/world_entities/world_entity.cc
===================================================================
--- branches/coll_rect/src/world_entities/world_entity.cc	(revision 9892)
+++ branches/coll_rect/src/world_entities/world_entity.cc	(revision 9896)
@@ -35,5 +35,5 @@
 #include "camera.h"
 
-#include "collision_handle.h"
+#include "collision_filter.h"
 #include "collision_event.h"
 #include "game_rules.h"
@@ -58,5 +58,5 @@
  */
 WorldEntity::WorldEntity()
-    : Synchronizeable()
+  : Synchronizeable(), collisionFilter(this)
 {
   this->registerObject(this, WorldEntity::_objectList);
@@ -78,6 +78,4 @@
 
   // reset all collision handles to NULL == unsubscribed state
-  for(int i = 0; i < CoRe::CREngine::CR_NUMBER; ++i)
-    this->collisionHandles[i] = NULL;
   this->bReactive = false;
   this->bOnGround = false;
@@ -88,11 +86,11 @@
   this->toList(OM_NULL);
 
-  registerVar( new SynchronizeableString( &this->md2TextureFileName, &this->md2TextureFileName, "md2TextureFileName", PERMISSION_MASTER_SERVER ) );
-  modelFileName_handle = registerVarId( new SynchronizeableString( &modelFileName, &modelFileName, "modelFileName", PERMISSION_MASTER_SERVER ) );
-  scaling_handle = registerVarId( new SynchronizeableFloat( &scaling, &scaling, "scaling", PERMISSION_MASTER_SERVER ) );
-  list_handle = registerVarId( new SynchronizeableInt( (int*)&objectListNumber, &list_write, "list", PERMISSION_MASTER_SERVER ) );
-
-  health_handle = registerVarId( new SynchronizeableFloat( &this->health, &this->health_write, "health", PERMISSION_MASTER_SERVER ) );
-  healthMax_handle = registerVarId( new SynchronizeableFloat( &this->healthMax, &this->healthMax_write, "maxHealth", PERMISSION_MASTER_SERVER ) );
+  this->registerVar( new SynchronizeableString( &this->md2TextureFileName, &this->md2TextureFileName, "md2TextureFileName", PERMISSION_MASTER_SERVER ) );
+  this->modelFileName_handle = registerVarId( new SynchronizeableString( &modelFileName, &modelFileName, "modelFileName", PERMISSION_MASTER_SERVER ) );
+  this->scaling_handle = registerVarId( new SynchronizeableFloat( &scaling, &scaling, "scaling", PERMISSION_MASTER_SERVER ) );
+  this->list_handle = registerVarId( new SynchronizeableInt( (int*)&objectListNumber, &list_write, "list", PERMISSION_MASTER_SERVER ) );
+
+  this->health_handle = registerVarId( new SynchronizeableFloat( &this->health, &this->health_write, "health", PERMISSION_MASTER_SERVER ) );
+  this->healthMax_handle = registerVarId( new SynchronizeableFloat( &this->healthMax, &this->healthMax_write, "maxHealth", PERMISSION_MASTER_SERVER ) );
 }
 
@@ -115,5 +113,5 @@
     delete this->healthWidget;
 
-  this->unsubscribeReaction();
+  this->unsubscribeReactions();
 }
 
@@ -304,8 +302,5 @@
 void WorldEntity::subscribeReaction(CoRe::CREngine::ReactionType type, const ClassID& target1)
 {
-  this->subscribeReaction(type);
-
-  // add the target filter
-  this->collisionHandles[type]->addTarget(target1);
+  this->collisionFilter.subscribeReaction(type, target1);
 }
 
@@ -318,9 +313,5 @@
 void WorldEntity::subscribeReaction(CoRe::CREngine::ReactionType type, const ClassID& target1, const ClassID& target2)
 {
-  this->subscribeReaction(type);
-
-  // add the target filter
-  this->collisionHandles[type]->addTarget(target1);
-  this->collisionHandles[type]->addTarget(target2);
+  this->collisionFilter.subscribeReaction(type, target1, target2);
 }
 
@@ -333,32 +324,5 @@
 void WorldEntity::subscribeReaction(CoRe::CREngine::ReactionType type, const ClassID& target1, const ClassID& target2, const ClassID& target3)
 {
-  this->subscribeReaction(type);
-
-  // add the target filter
-  this->collisionHandles[type]->addTarget(target1);
-  this->collisionHandles[type]->addTarget(target2);
-  this->collisionHandles[type]->addTarget(target3);
-}
-
-
-
-/**
- * subscribes this world entity to a collision reaction
- *  @param type the type of reaction to subscribe to
- *  @param nrOfTargets number of target filters
- *  @param ... the targets as classIDs
- */
-void WorldEntity::subscribeReaction(CoRe::CREngine::ReactionType type)
-{
-  if( this->collisionHandles[type] != NULL)
-  {
-    PRINTF(2)("Registering for a CollisionReaction already subscribed to! Skipping\n");
-    return;
-  }
-
-  this->collisionHandles[type] = CoRe::CREngine::getInstance()->subscribeReaction(this, type);
-
-  // now there is at least one collision reaction subscribed
-  this->bReactive = true;
+  this->collisionFilter.subscribeReaction(type, target1, target2, target3);
 }
 
@@ -370,20 +334,5 @@
 void WorldEntity::unsubscribeReaction(CoRe::CREngine::ReactionType type)
 {
-  if( this->collisionHandles[type] == NULL)
-    return;
-
-  CoRe::CREngine::getInstance()->unsubscribeReaction(this->collisionHandles[type]);
-  this->collisionHandles[type] = NULL;
-
-  // check if there is still any handler registered
-  for(int i = 0; i < CoRe::CREngine::CR_NUMBER; ++i)
-  {
-    if( this->collisionHandles[i] != NULL)
-    {
-      this->bReactive = true;
-      return;
-    }
-  }
-  this->bReactive = false;
+  this->collisionFilter.unsubscribeReaction(type);
 }
 
@@ -392,61 +341,7 @@
  * unsubscribes all collision reactions
  */
-void WorldEntity::unsubscribeReaction()
-{
-  for( int i = 0; i < CoRe::CREngine::CR_NUMBER; i++)
-    this->unsubscribeReaction((CoRe::CREngine::ReactionType)i);
-
-  // there are no reactions subscribed from now on
-  this->bReactive = false;
-}
-
-
-/**
- * registers a new collision event to this world entity
- *  @param entityA entity of the collision
- *  @param entityB entity of the collision
- *  @param bvA colliding bounding volume of entityA
- *  @param bvB colliding bounding volume of entityA
- */
-bool WorldEntity::registerCollision(WorldEntity* entityA, WorldEntity* entityB, BoundingVolume* bvA, BoundingVolume* bvB)
-{
-  PRINTF(5)("registering collision of type: %s vs %s\n", entityA->getClassCName(), entityB->getClassCName());
-  // is there any handler listening?
-  if( !this->bReactive)
-    return false;
-
-  // get a collision event
-  CoRe::CollisionEvent* c = CoRe::CREngine::getInstance()->popCollisionEventObject();
-  assert(c != NULL); // if this should fail: we got not enough precached CollisionEvents: alter value in cr_defs.h
-//  c->collide(COLLISION_TYPE_OBB, entityA, entityB, bvA, bvB);
-
-  for( int i = 0; i < CoRe::CREngine::CR_NUMBER; ++i)
-    if( this->collisionHandles[i] != NULL)
-      this->collisionHandles[i]->registerCollisionEvent(c);
-  return true;
-}
-
-
-/**
- * registers a new collision event to this woeld entity
- *  @param entity the entity that collides
- *  @param plane it stands on
- *  @param position it collides on the plane
- */
-bool WorldEntity::registerCollision(int type, WorldEntity* entity, WorldEntity* groundEntity, Vector normal, Vector position, bool bInWall)
-{
-  // is there any handler listening?
-  if( !this->bReactive)
-    return false;
-
-  // get a collision event
-  CoRe::CollisionEvent* c = CoRe::CREngine::getInstance()->popCollisionEventObject();
-  assert(c != NULL); // if this should fail: we got not enough precached CollisionEvents: alter value in cr_defs.h
-//  c->collide(type, entity, groundEntity, normal, position, bInWall);
-
-  for( int i = 0; i < CoRe::CREngine::CR_NUMBER; ++i)
-    if( this->collisionHandles[i] != NULL)
-      this->collisionHandles[i]->registerCollisionEvent(c);
-  return true;
+void WorldEntity::unsubscribeReactions()
+{
+  this->collisionFilter.unsubscribeReactions();
 }
 
