Changeset 9893 in orxonox.OLD for branches/coll_rect/src/lib/collision_reaction/collision_handle.cc
- Timestamp:
- Oct 19, 2006, 3:37:40 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/coll_rect/src/lib/collision_reaction/collision_handle.cc
r9892 r9893 108 108 this->targetList.push_back(target); 109 109 PRINTF(5)("addTarget: %i \n", target.id()); 110 }111 112 113 /**114 * registers a new Collision Object115 * @param entityA WorldEntity A of the collision116 * @param entityB WorldEntity B of the collision117 * if a there is already a collision object with the same stats118 * registration will be skipped and the last collision object is returned119 */120 Collision* CollisionHandle::registerCollision(WorldEntity* entityA, WorldEntity* entityB)121 {122 //first get the collision object, multiple sources123 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 entity132 CollisionHandle* ch = entityB->getCollisionHandle(this->type);133 if( ch != NULL)134 ch->registerSharedCollision(c);135 }136 else137 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 register146 *147 * This is used for internal collision registration: sharing the collision objects between Collision Reactions148 * Therefore dispatching it only once149 */150 void CollisionHandle::registerSharedCollision(Collision* collision)151 {152 // fist check if we are listening for this Collision153 if( !this->filterCollision(collision))154 return;155 156 // set the state to not dispatched157 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 handle167 * @param collision the collision objects containing all collision informations168 */169 void CollisionHandle::registerCollisionEvent(CollisionEvent* collisionEvent)170 {171 if( !this->filterCollisionEvent(collisionEvent))172 return;173 174 // set the state to not dispatched175 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 object179 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 list189 */190 void CollisionHandle::flushCollisions()191 {192 this->collisionList.clear();193 110 } 194 111
Note: See TracChangeset
for help on using the changeset viewer.