Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 19, 2006, 3:37:40 PM (18 years ago)
Author:
patrick
Message:

collision reactions now only registered with collision tube. no compile

File:
1 edited

Legend:

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

    r9892 r9893  
    108108    this->targetList.push_back(target);
    109109    PRINTF(5)("addTarget: %i \n", target.id());
    110   }
    111 
    112 
    113   /**
    114    * registers a new Collision Object
    115    *  @param entityA WorldEntity A of the collision
    116    *  @param entityB WorldEntity B of the collision
    117    * if a there is already a collision object with the same stats
    118    * registration will be skipped and the last collision object is returned
    119    */
    120   Collision* CollisionHandle::registerCollision(WorldEntity* entityA, WorldEntity* entityB)
    121   {
    122     //first get the collision object, multiple sources
    123     Collision* c;
    124     if( this->collisionList.empty() ||
    125         ((this->collisionList.back())->getEntityA() != entityA && (this->collisionList.back())->getEntityB() != entityB ))
    126     {
    127       c = CREngine::getInstance()->popCollisionObject();
    128       c->collide(entityA, entityB);
    129       this->collisionList.push_back(c);
    130 
    131       // now register it as a shared collision with the other collision entity
    132       CollisionHandle* ch = entityB->getCollisionHandle(this->type);
    133       if( ch != NULL)
    134         ch->registerSharedCollision(c);
    135     }
    136     else
    137       c = this->collisionList.back();
    138 
    139     return c;
    140   }
    141 
    142 
    143   /**
    144    * register a Collision to the Collision handle.
    145    *  @param collision the collision object to register
    146    *
    147    * This is used for internal collision registration: sharing the collision objects between Collision Reactions
    148    * Therefore dispatching it only once
    149    */
    150   void CollisionHandle::registerSharedCollision(Collision* collision)
    151   {
    152     // fist check if we are listening for this Collision
    153     if( !this->filterCollision(collision))
    154       return;
    155 
    156     // set the state to not dispatched
    157     this->bDispatched = false;
    158     this->bCollided = true;
    159     collision->setEntityBCollide(true);
    160 
    161     this->collisionList.push_back(collision);
    162   }
    163 
    164 
    165   /**
    166    * this is the function to be called on a collision event for this handle
    167    *  @param collision the collision objects containing all collision informations
    168    */
    169   void CollisionHandle::registerCollisionEvent(CollisionEvent* collisionEvent)
    170   {
    171     if( !this->filterCollisionEvent(collisionEvent))
    172       return;
    173 
    174     // set the state to not dispatched
    175     this->bDispatched = false;
    176     this->bCollided = true;
    177 
    178     // checks if these WorldEntities have already collided or if its a new collision -> create a new Collision object
    179     Collision* c = this->registerCollision(collisionEvent->getEntityA(), collisionEvent->getEntityB());
    180     c->setEntityACollide(true);
    181 
    182     c->registerCollisionEvent(collisionEvent);
    183     PRINTF(5)("Registering Collision Event: %s, %s\n", collisionEvent->getEntityA()->getClassCName(), collisionEvent->getEntityB()->getClassCName());
    184   }
    185 
    186 
    187   /**
    188    * flushes the collision list
    189    */
    190   void CollisionHandle::flushCollisions()
    191   {
    192     this->collisionList.clear();
    193110  }
    194111
Note: See TracChangeset for help on using the changeset viewer.