Changeset 9892 in orxonox.OLD for branches/coll_rect/src
- Timestamp:
- Oct 14, 2006, 1:25:47 AM (18 years ago)
- Location:
- branches/coll_rect/src
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/coll_rect/src/lib/collision_reaction/collision.h
r9891 r9892 53 53 54 54 55 inline bool match(const WorldEntity& entityA, WorldEntity& entityB) const { return (this->entityA == &entityA && this->entityB == &entityB); } 55 inline bool match(const WorldEntity& entityA, WorldEntity& entityB) const { 56 return ((this->entityA == &entityA && this->entityB == &entityB) || (this->entityA == &entityB && this->entityB == &entityA)); } 56 57 /** @returns true if this Collision has already been dispatched */ 57 58 inline bool isDispatched() { return this->bDispatched; } -
branches/coll_rect/src/lib/collision_reaction/collision_event.h
r9889 r9892 14 14 15 15 #include "vector.h" 16 #include "cr_engine.h" 16 17 17 18 #include "cr_defs.h" … … 33 34 34 35 /** collides two WorldEntities @param entityA world entity A, @param entityB world entity B, @param bvA volume A @param bvB volumeB */ 35 inline void collide( inttype, WorldEntity* entityA, WorldEntity* entityB, BoundingVolume* bvA, BoundingVolume* bvB)36 inline void collide(CREngine::CollisionType type, WorldEntity* entityA, WorldEntity* entityB, BoundingVolume* bvA, BoundingVolume* bvB) 36 37 { this->collisionType = type; this->entityA = entityA; this->entityB = entityB; this->bvA = bvA; this->bvB = bvB; } 37 38 /** collides two WorldEntities @param entity world entity , @param ground ground plane, @param position position on the ground */ 38 inline void collide( inttype, WorldEntity* entity, WorldEntity* groundEntity, Vector normal, Vector position, bool bInWall)39 inline void collide(CREngine::CollisionType type, WorldEntity* entity, WorldEntity* groundEntity, Vector normal, Vector position, bool bInWall) 39 40 { 40 41 this->collisionType = type; -
branches/coll_rect/src/lib/collision_reaction/collision_handle.cc
r9890 r9892 38 38 * @todo this constructor is not jet implemented - do it 39 39 */ 40 CollisionHandle::CollisionHandle (WorldEntity* owner, CREngine:: CRType type)40 CollisionHandle::CollisionHandle (WorldEntity* owner, CREngine::ReactionType type) 41 41 { 42 42 this->registerObject(this, CollisionHandle::_objectList); -
branches/coll_rect/src/lib/collision_reaction/collision_handle.h
r9890 r9892 30 30 31 31 public: 32 CollisionHandle(WorldEntity* owner, CREngine:: CRType type);32 CollisionHandle(WorldEntity* owner, CREngine::ReactionType type); 33 33 virtual ~CollisionHandle(); 34 34 … … 47 47 inline bool isContinuousPoll() const { return this->bContinuousPoll; } 48 48 /** @returns the type */ 49 inline CREngine:: CRType getType() const { return this->type; }49 inline CREngine::ReactionType getType() const { return this->type; } 50 50 51 51 void handleCollisions(); … … 61 61 private: 62 62 WorldEntity* owner; //!< the worldenity this reaction will be applied on 63 CREngine:: CRType type; //!< the reaction type63 CREngine::ReactionType type; //!< the reaction type 64 64 65 65 bool bContinuousPoll; //!< if this is true -
branches/coll_rect/src/lib/collision_reaction/collision_tube.cc
r9891 r9892 40 40 CollisionTube::CollisionTube () 41 41 { 42 42 this->registerObject(this, CollisionTube::_objectList); 43 43 } 44 44 … … 65 65 { 66 66 Collision* collision = this->_collisionList.back(); 67 68 // check if there is already a collision defined between these objects 67 69 if( collision->match(*entityA, *entityB)) 68 {} 70 { 71 CollisionEvent* collisionEvent = CREngine::getInstance()->popCollisionEventObject(); 72 collisionEvent->collide( CREngine::CR_COLLISION_TYPE_OBB, entityA, entityB, bvA, bvB); 73 collision->registerCollisionEvent( collisionEvent); 74 } 69 75 } 70 76 -
branches/coll_rect/src/lib/collision_reaction/collision_tube.h
r9891 r9892 3 3 * 4 4 * collision tube collects all collisions from all entities 5 * 6 * The collision events are saved in the _collisionList vector in a fixed hirarchy: a collision is defined by the world entities 7 * that collide. For each collision there is an entry in _collisionList. Each collision itself again contains collision events which are 8 * defined as collisions between the boundibg volumes (BV) of the world entities. This could look like this: 9 * 10 * - Collision (WorldEntity_i <=> WorldEntity_j) 11 * +- CollisionEvent( some BV <=> some other BV) 12 * +- CollisionEvent( some BV <=> some other BV) 13 * - Collision (WorldEntity_k <=> WorldEntity_l) 14 * +- CollisionEvent( some BV <=> some other BV) 15 * +- CollisionEvent( some BV <=> some other BV) 16 * +- CollisionEvent( some BV <=> some other BV) 17 * +- CollisionEvent( some BV <=> some other BV) 18 * - ... etc ... 19 * 20 * 21 * When the collisions are processed by the handleCollision() function each collision pair is checked for their reactions (since each 22 * WorldEntity can define several reactions to a collision). After all the reactions are calculated and applied the collision object is 23 * put back. 5 24 */ 6 25 … … 24 43 class CollisionReaction; 25 44 26 //! A class for defining collision reactions and storing events45 //! A class containing all CollisionEvents (structured as defined in the file doxygen tags) 27 46 class CollisionTube : public BaseObject 28 47 { … … 32 51 public: 33 52 CollisionTube(); 34 ~CollisionTube();53 virtual ~CollisionTube(); 35 54 36 55 /** @returns true if at least one of both WorldEntities are subscribed for a collision check */ -
branches/coll_rect/src/lib/collision_reaction/cr_defs.h
r9062 r9892 38 38 #define COLLISION_TYPE_AXIS_Z_NEG 6 39 39 //!< the collision is a obb collision 40 #define COLLISION_TYPE_OBB 840 #define COLLISION_TYPE_OBB 8 41 41 42 42 -
branches/coll_rect/src/lib/collision_reaction/cr_engine.cc
r9890 r9892 89 89 90 90 /** 91 * @returns an instance to a collision object. instead of creating new object this ones can be resycled 92 */ 93 Collision* CREngine::popCollisionObject() 94 { 95 if( !this->collisionsUnused.empty()) 96 { 97 this->collisionsUsed.push_back(this->collisionsUnused.back()); 98 this->collisionsUnused.pop_back(); 99 return this->collisionsUsed.back(); 100 } 101 else return NULL; 102 } 103 104 /** 105 * @return an instanco of a CollisionEvent object. instead of creating a new object this ones can be used and resycled 106 */ 107 CollisionEvent* CREngine::popCollisionEventObject() 108 { 109 if( !this->collisionEventsUnused.empty()) 110 { 111 this->collisionEventsUsed.push_back(this->collisionEventsUnused.back()); 112 this->collisionEventsUnused.pop_back(); 113 return this->collisionEventsUsed.back(); 114 } 115 else return NULL; 116 } 117 118 119 /** 91 120 * flushes the CollisionHandles and restores the CREngine to the initial state 92 121 */ … … 112 141 * @return the newly created CollisionHandle 113 142 */ 114 CollisionHandle* CREngine::subscribeReaction(WorldEntity* owner, CRType type)143 CollisionHandle* CREngine::subscribeReaction(WorldEntity* owner, ReactionType type) 115 144 { 116 145 CollisionHandle* ch = new CollisionHandle(owner, type); -
branches/coll_rect/src/lib/collision_reaction/cr_engine.h
r9889 r9892 31 31 32 32 public: 33 typedef enum CRType {34 CR_PHYSICS_MOMENTUM = 0, //!< physical reaction: conservervation of momentum35 CR_PHYSICS_STEP_BACK, //!< physical reaction: just go to the last position without collisions36 CR_PHYSICS_GROUND_WALK, //!< physical reaction: stand on the ground, no movement: simulatingsimple normal force away from the gravity force37 CR_PHYSICS_FULL_WALK, //!< physical reaction: walking on the ground (inkl. hills etc)38 CR_PHYSICS_DAMAGE, //!< physical reaction: daling damage according to the object energy and their structural stability33 typedef enum ReactionType { 34 CR_PHYSICS_MOMENTUM = 0, //!< physical reaction: conservervation of momentum 35 CR_PHYSICS_STEP_BACK, //!< physical reaction: just go to the last position without collisions 36 CR_PHYSICS_GROUND_WALK, //!< physical reaction: stand on the ground, no movement: simple normal force away from the gravity force 37 CR_PHYSICS_FULL_WALK, //!< physical reaction: walking on the ground (inkl. hills etc) 38 CR_PHYSICS_DAMAGE, //!< physical reaction: daling damage according to the object energy and their structural stability 39 39 40 CR_OBJECT_DAMAGE, //!< object raction: deals damage according to the objects specific damage potential (like weapons, nukes, etc.)41 CR_OBJECT_PICKUP, //!< object rection: calling the objects pickup functions, let them handle the collision (once!)40 CR_OBJECT_DAMAGE, //!< object raction: deals damage according to the objects specific damage potential (like weapons, nukes, etc.) 41 CR_OBJECT_PICKUP, //!< object rection: calling the objects pickup functions, let them handle the collision (once!) 42 42 43 CR_VERTEX_TRAFO, //!< vertex trafo: transforming the vertex according to the damage43 CR_VERTEX_TRAFO, //!< vertex trafo: transforming the vertex according to the damage 44 44 45 CR_SPECIAL_CALLBACK, //!< special: call a callback function45 CR_SPECIAL_CALLBACK, //!< special: call a callback function 46 46 47 47 CR_NUMBER 48 48 }; 49 50 typedef enum CollisionType { 51 CR_COLLISION_TYPE_AXIS_X = 0, //!< collision on x axis 52 CR_COLLISION_TYPE_AXIS_X_NEG, //!< collision on negative x axis 53 CR_COLLISION_TYPE_AXIS_Y, //!< collision on y axis 54 CR_COLLISION_TYPE_AXIS_Y_NEG, //!< collision on negative y axis 55 CR_COLLISION_TYPE_AXIS_Z, //!< collision on z axis 56 CR_COLLISION_TYPE_AXIS_Z_NEG, //!< collision on negative z axis 57 CR_COLLISION_TYPE_OBB, //!< object aligned bounding box collide 58 59 CR_COLLISION_TYPE_NUMBER 60 }; 61 62 63 #define COLLISION_TYPE_AXIS_X 1 64 #define COLLISION_TYPE_AXIS_X_NEG 2 65 //!< the collision axis y collision event 66 #define COLLISION_TYPE_AXIS_Y 3 67 #define COLLISION_TYPE_AXIS_Y_NEG 4 68 //!< the collision axis z collision event 69 #define COLLISION_TYPE_AXIS_Z 5 70 #define COLLISION_TYPE_AXIS_Z_NEG 6 71 //!< the collision is a obb collision 72 #define COLLISION_TYPE_OBB 8 49 73 50 74 virtual ~CREngine(void); … … 53 77 inline static CREngine* getInstance() { if (!singletonRef) singletonRef = new CREngine(); return singletonRef; }; 54 78 79 CollisionHandle* subscribeReaction(WorldEntity* worldEntity, ReactionType type); 80 bool unsubscribeReaction(CollisionHandle* collisionHandle); 81 82 83 Collision* popCollisionObject(); 84 CollisionEvent* popCollisionEventObject(); 55 85 void reset(); 56 86 57 58 CollisionHandle* subscribeReaction(WorldEntity* worldEntity, CRType type);59 60 bool unsubscribeReaction(CollisionHandle* collisionHandle);61 62 87 void handleCollisions(); 63 64 /** @returns an instance to a collision object. instead of creating new object this ones can be resycled */65 inline Collision* popCollisionObject()66 {67 if( !this->collisionsUnused.empty())68 {69 this->collisionsUsed.push_back(this->collisionsUnused.back()); this->collisionsUnused.pop_back(); return this->collisionsUsed.back();70 }71 else return NULL;72 }73 74 75 /** @return an instanco of a CollisionEvent object. instead of creating a new object this ones can be used and resycled */76 inline CollisionEvent* popCollisionEventObject()77 {78 if( !this->collisionEventsUnused.empty())79 {80 this->collisionEventsUsed.push_back(this->collisionEventsUnused.back()); this->collisionEventsUnused.pop_back(); return this->collisionEventsUsed.back();81 }82 else return NULL;83 }84 88 85 89 void debug(); -
branches/coll_rect/src/lib/collision_reaction/cr_physics_full_walk.cc
r9889 r9892 72 72 73 73 float CR_MAX_WALK_HEIGHT = 15.0f; 74 float CR_THRESHOLD = 0.2f;74 // float CR_THRESHOLD = 0.2f; 75 75 76 76 float height = 0.0f; -
branches/coll_rect/src/world_entities/world_entity.cc
r9889 r9892 302 302 * @param target1 a filter target (classID) 303 303 */ 304 void WorldEntity::subscribeReaction(CoRe::CREngine:: CRType type, const ClassID& target1)304 void WorldEntity::subscribeReaction(CoRe::CREngine::ReactionType type, const ClassID& target1) 305 305 { 306 306 this->subscribeReaction(type); … … 316 316 * @param target1 a filter target (classID) 317 317 */ 318 void WorldEntity::subscribeReaction(CoRe::CREngine:: CRType type, const ClassID& target1, const ClassID& target2)318 void WorldEntity::subscribeReaction(CoRe::CREngine::ReactionType type, const ClassID& target1, const ClassID& target2) 319 319 { 320 320 this->subscribeReaction(type); … … 331 331 * @param target1 a filter target (classID) 332 332 */ 333 void WorldEntity::subscribeReaction(CoRe::CREngine:: CRType type, const ClassID& target1, const ClassID& target2, const ClassID& target3)333 void WorldEntity::subscribeReaction(CoRe::CREngine::ReactionType type, const ClassID& target1, const ClassID& target2, const ClassID& target3) 334 334 { 335 335 this->subscribeReaction(type); … … 349 349 * @param ... the targets as classIDs 350 350 */ 351 void WorldEntity::subscribeReaction(CoRe::CREngine:: CRType type)351 void WorldEntity::subscribeReaction(CoRe::CREngine::ReactionType type) 352 352 { 353 353 if( this->collisionHandles[type] != NULL) … … 368 368 * @param type the reaction to unsubscribe 369 369 */ 370 void WorldEntity::unsubscribeReaction(CoRe::CREngine:: CRType type)370 void WorldEntity::unsubscribeReaction(CoRe::CREngine::ReactionType type) 371 371 { 372 372 if( this->collisionHandles[type] == NULL) … … 395 395 { 396 396 for( int i = 0; i < CoRe::CREngine::CR_NUMBER; i++) 397 this->unsubscribeReaction((CoRe::CREngine:: CRType)i);397 this->unsubscribeReaction((CoRe::CREngine::ReactionType)i); 398 398 399 399 // there are no reactions subscribed from now on … … 419 419 CoRe::CollisionEvent* c = CoRe::CREngine::getInstance()->popCollisionEventObject(); 420 420 assert(c != NULL); // if this should fail: we got not enough precached CollisionEvents: alter value in cr_defs.h 421 c->collide(COLLISION_TYPE_OBB, entityA, entityB, bvA, bvB);421 // c->collide(COLLISION_TYPE_OBB, entityA, entityB, bvA, bvB); 422 422 423 423 for( int i = 0; i < CoRe::CREngine::CR_NUMBER; ++i) … … 443 443 CoRe::CollisionEvent* c = CoRe::CREngine::getInstance()->popCollisionEventObject(); 444 444 assert(c != NULL); // if this should fail: we got not enough precached CollisionEvents: alter value in cr_defs.h 445 c->collide(type, entity, groundEntity, normal, position, bInWall);445 // c->collide(type, entity, groundEntity, normal, position, bInWall); 446 446 447 447 for( int i = 0; i < CoRe::CREngine::CR_NUMBER; ++i) -
branches/coll_rect/src/world_entities/world_entity.h
r9890 r9892 78 78 79 79 /* --- Collision Reaction Block --- */ 80 void subscribeReaction(CoRe::CREngine:: CRType type);81 void subscribeReaction(CoRe::CREngine:: CRType type, const ClassID& target1);82 void subscribeReaction(CoRe::CREngine:: CRType type, const ClassID& target1, const ClassID& target2);83 void subscribeReaction(CoRe::CREngine:: CRType type, const ClassID& target1, const ClassID& target2, const ClassID& target3);84 85 void unsubscribeReaction(CoRe::CREngine:: CRType type);80 void subscribeReaction(CoRe::CREngine::ReactionType type); 81 void subscribeReaction(CoRe::CREngine::ReactionType type, const ClassID& target1); 82 void subscribeReaction(CoRe::CREngine::ReactionType type, const ClassID& target1, const ClassID& target2); 83 void subscribeReaction(CoRe::CREngine::ReactionType type, const ClassID& target1, const ClassID& target2, const ClassID& target3); 84 85 void unsubscribeReaction(CoRe::CREngine::ReactionType type); 86 86 void unsubscribeReaction(); 87 87 … … 91 91 inline bool isReactive() const { return this->bReactive; } 92 92 93 CoRe::CollisionHandle* getCollisionHandle(CoRe::CREngine:: CRType type) const { return this->collisionHandles[type]; }93 CoRe::CollisionHandle* getCollisionHandle(CoRe::CREngine::ReactionType type) const { return this->collisionHandles[type]; } 94 94 95 95 /** @returns true if this entity is standing on ground (BSP model) */
Note: See TracChangeset
for help on using the changeset viewer.