Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7969 in orxonox.OLD for branches/cr/src


Ignore:
Timestamp:
May 30, 2006, 1:33:09 AM (18 years ago)
Author:
patrick
Message:

cr: collision and collision events should now be registered correctly

Location:
branches/cr/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/cr/src/lib/collision_reaction/collision_handle.cc

    r7967 r7969  
    120120void CollisionHandle::handleCollisions()
    121121{
    122 
    123   // collision reaction calculations
     122  // collision reaction calculations (for every collision there will be a reaction)
     123  vector<Collision*>::iterator it = this->collisionList.begin();
     124  for(; it < this->collisionList.end(); it++)
     125  {
     126    (*it)->handleCollisionEvents();
     127  }
    124128
    125129  // now set state to dispatched
  • branches/cr/src/world_entities/world_entity.cc

    r7958 r7969  
    3333
    3434#include "collision_handle.h"
    35 #include "collision.h"
     35#include "collision_event.h"
    3636
    3737#include <stdarg.h>
     
    7373  for(int i = 0; i < CREngine::CR_NUMBER; ++i)
    7474    this->collisionHandles[i] = NULL;
     75  this->bReactive = false;
    7576
    7677  this->toList(OM_NULL);
     
    280281  this->collisionHandles[type] = NULL;
    281282
    282   //
     283  // check if there is still any handler registered
     284  for(int i = 0; i < CREngine::CR_NUMBER; ++i)
     285  {
     286    if( this->collisionHandles[i] != NULL)
     287    {
     288      this->bReactive = true;
     289      return;
     290    }
     291  }
     292  this->bReactive = false;
    283293}
    284294
     
    292302    this->unsubscribeReaction((CREngine::CRType)i);
    293303
     304  // there are no reactions subscribed from now on
    294305  this->bReactive = false;
    295306}
     
    302313bool WorldEntity::registerCollision(WorldEntity* entityA, WorldEntity* entityB, BoundingVolume* bvA, BoundingVolume* bvB)
    303314{
     315  // is there any handler listening?
     316  if( !this->bReactive)
     317    return false;
     318
    304319  PRINTF(0)("Registering Collision: %s vs %s \n", entityA->getClassName(), entityB->getClassName());
    305320  // create a collision event
    306   Collision* c = CREngine::getInstance()->popCollisionObject();
     321  CollisionEvent* c = CREngine::getInstance()->popCollisionEventObject();
    307322  assert(c != NULL);
    308323  c->collide(entityA, entityB, bvA, bvB);
     
    310325  for(int i = 0; i < CREngine::CR_NUMBER; ++i)
    311326    if( this->collisionHandles[i] != NULL)
    312       this->collisionHandles[i]->registerCollision(c);
     327      this->collisionHandles[i]->registerCollisionEvent(c);
    313328}
    314329
Note: See TracChangeset for help on using the changeset viewer.