Changeset 9893 in orxonox.OLD for branches/coll_rect/src
- Timestamp:
- Oct 19, 2006, 3:37:40 PM (18 years ago)
- Location:
- branches/coll_rect/src/lib/collision_reaction
- Files:
-
- 6 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 -
branches/coll_rect/src/lib/collision_reaction/collision_handle.h
r9892 r9893 36 36 37 37 void addTarget(const ClassID& target); 38 Collision* registerCollision(WorldEntity* entityA, WorldEntity* entityB);39 void registerSharedCollision(Collision* collision);40 void registerCollisionEvent(CollisionEvent* collisionEvent);41 38 42 39 /** @returns true if regiestered some new collision events in this tick frame */ -
branches/coll_rect/src/lib/collision_reaction/collision_tube.cc
r9892 r9893 67 67 68 68 // check if there is already a collision defined between these objects 69 if( collision->match(*entityA, *entityB))69 if( !collision->match(*entityA, *entityB)) 70 70 { 71 CollisionEvent* collisionEvent = CREngine::getInstance()->popCollisionEventObject(); 72 collisionEvent->collide( CREngine::CR_COLLISION_TYPE_OBB, entityA, entityB, bvA, bvB); 73 collision->registerCollisionEvent( collisionEvent); 71 collision = CREngine::getInstance()->popCollisionObject(); 72 collision->collide( entityA, entityB); 74 73 } 74 75 // now register the new collision event 76 CollisionEvent* collisionEvent = CREngine::getInstance()->popCollisionEventObject(); 77 collisionEvent->collide( CREngine::CR_COLLISION_TYPE_OBB, entityA, entityB, bvA, bvB); 78 collision->registerCollisionEvent( collisionEvent); 75 79 } 76 80 … … 85 89 * @param bInWall true if the entity is in the ground material 86 90 */ 87 void CollisionTube::registerCollisionEvent( inttype, WorldEntity* entity, WorldEntity* groundEntity,91 void CollisionTube::registerCollisionEvent(CREngine::CollisionType type, WorldEntity* entity, WorldEntity* groundEntity, 88 92 const Vector& normal, const Vector& position, bool bInWall) 89 93 { 90 // 94 Collision* collision = this->_collisionList.back(); 95 96 // check if there is already a collision defined between these objects 97 if( !collision->match(*entity, *groundEntity)) 98 { 99 collision = CREngine::getInstance()->popCollisionObject(); 100 collision->collide( entity, groundEntity); 101 } 102 103 // now register the new collision event 104 CollisionEvent* collisionEvent = CREngine::getInstance()->popCollisionEventObject(); 105 collisionEvent->collide( type, entity, groundEntity, normal, position, bInWall); 106 collision->registerCollisionEvent( collisionEvent); 91 107 } 108 109 110 /** 111 * checks if two objects are 112 */ 113 bool CollisionTube::needCollisionChecking(const WorldEntity& entityA, const WorldEntity& entityB) 114 { 115 //if( !this->isReactive( entityA, entityB) ) 116 // return false; 117 118 //if( entityA->) 119 120 } 121 92 122 93 123 /** -
branches/coll_rect/src/lib/collision_reaction/collision_tube.h
r9892 r9893 56 56 inline bool isReactive(const WorldEntity& entityA, const WorldEntity& entityB) const 57 57 { return (entityA.isReactive() && entityB.isReactive()); } 58 bool needCollisionChecking(const WorldEntity& entityA, const WorldEntity& entityB); 58 59 59 60 void registerCollisionEvent(WorldEntity* entityA, WorldEntity* entityB, BoundingVolume* bvA, BoundingVolume* bvB); 60 void registerCollisionEvent( inttype, WorldEntity* entity, WorldEntity* groundEntity,61 void registerCollisionEvent(CREngine::CollisionType type, WorldEntity* entity, WorldEntity* groundEntity, 61 62 const Vector& normal, const Vector& position, bool bInWall = false); 62 63 -
branches/coll_rect/src/lib/collision_reaction/cr_defs.h
r9892 r9893 28 28 29 29 30 //!< the collision axis x collision event31 #define COLLISION_TYPE_AXIS_X 132 #define COLLISION_TYPE_AXIS_X_NEG 233 //!< the collision axis y collision event34 #define COLLISION_TYPE_AXIS_Y 335 #define COLLISION_TYPE_AXIS_Y_NEG 436 //!< the collision axis z collision event37 #define COLLISION_TYPE_AXIS_Z 538 #define COLLISION_TYPE_AXIS_Z_NEG 639 //!< the collision is a obb collision40 #define COLLISION_TYPE_OBB 841 42 30 43 31 #endif /* _NETWORK_MANAGER */ -
branches/coll_rect/src/lib/collision_reaction/cr_engine.cc
r9892 r9893 123 123 { 124 124 // first clear all CollisionHandles 125 126 125 std::vector<CollisionHandle*>::iterator it = this->collisionHandles.begin(); 127 126 for(; it < this->collisionHandles.end(); it++)
Note: See TracChangeset
for help on using the changeset viewer.