[9890] | 1 | /* |
---|
| 2 | orxonox - the future of 3D-vertical-scrollers |
---|
| 3 | |
---|
| 4 | Copyright (C) 2004 orx |
---|
| 5 | |
---|
| 6 | This program is free software; you can redistribute it and/or modify |
---|
| 7 | it under the terms of the GNU General Public License as published by |
---|
| 8 | the Free Software Foundation; either version 2, or (at your option) |
---|
| 9 | any later version. |
---|
| 10 | |
---|
| 11 | ### File Specific: |
---|
| 12 | main-programmer: Patrick Boenzli |
---|
| 13 | */ |
---|
| 14 | |
---|
| 15 | #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_COLLISION_REACTION |
---|
| 16 | |
---|
| 17 | #include "collision_tube.h" |
---|
| 18 | |
---|
| 19 | #include "world_entity.h" |
---|
| 20 | |
---|
| 21 | #include "collision.h" |
---|
| 22 | #include "collision_event.h" |
---|
| 23 | #include "collision_reaction.h" |
---|
| 24 | |
---|
| 25 | #include "cr_object_damage.h" |
---|
| 26 | #include "cr_physics_ground_walk.h" |
---|
| 27 | #include "cr_physics_full_walk.h" |
---|
| 28 | |
---|
| 29 | |
---|
| 30 | |
---|
| 31 | namespace CoRe |
---|
| 32 | { |
---|
| 33 | |
---|
| 34 | ObjectListDefinition(CollisionTube); |
---|
| 35 | |
---|
[9896] | 36 | CollisionTube* CollisionTube::instance = NULL; |
---|
| 37 | |
---|
| 38 | |
---|
[9890] | 39 | /** |
---|
| 40 | * standard constructor |
---|
| 41 | * @todo this constructor is not jet implemented - do it |
---|
| 42 | */ |
---|
| 43 | CollisionTube::CollisionTube () |
---|
| 44 | { |
---|
[9892] | 45 | this->registerObject(this, CollisionTube::_objectList); |
---|
[9890] | 46 | } |
---|
| 47 | |
---|
| 48 | |
---|
| 49 | /** |
---|
| 50 | * standard deconstructor |
---|
| 51 | */ |
---|
| 52 | CollisionTube::~CollisionTube () |
---|
| 53 | { |
---|
| 54 | this->_collisionList.clear(); |
---|
| 55 | } |
---|
| 56 | |
---|
[9891] | 57 | |
---|
| 58 | /** |
---|
| 59 | * registers a new CollisionEvent |
---|
| 60 | * @param entityA one collision object |
---|
| 61 | * @param entityB the other collision objectName |
---|
| 62 | * @param bvA bounding volume of object A |
---|
| 63 | * @param bvB bounding volume of object B |
---|
| 64 | * |
---|
| 65 | * this function doesn't check if the entities in question actualy are registered for any collisions |
---|
| 66 | */ |
---|
| 67 | void CollisionTube::registerCollisionEvent(WorldEntity* entityA, WorldEntity* entityB, BoundingVolume* bvA, BoundingVolume* bvB) |
---|
| 68 | { |
---|
| 69 | Collision* collision = this->_collisionList.back(); |
---|
[9892] | 70 | |
---|
| 71 | // check if there is already a collision defined between these objects |
---|
[9893] | 72 | if( !collision->match(*entityA, *entityB)) |
---|
[9892] | 73 | { |
---|
[9893] | 74 | collision = CREngine::getInstance()->popCollisionObject(); |
---|
| 75 | collision->collide( entityA, entityB); |
---|
[9892] | 76 | } |
---|
[9893] | 77 | |
---|
| 78 | // now register the new collision event |
---|
| 79 | CollisionEvent* collisionEvent = CREngine::getInstance()->popCollisionEventObject(); |
---|
| 80 | collisionEvent->collide( CREngine::CR_COLLISION_TYPE_OBB, entityA, entityB, bvA, bvB); |
---|
| 81 | collision->registerCollisionEvent( collisionEvent); |
---|
[9891] | 82 | } |
---|
| 83 | |
---|
| 84 | |
---|
| 85 | /** |
---|
| 86 | * registers a new CollisionEvent, only used by ground to object collision (eg. bsp model) |
---|
| 87 | * @param type type of collision as stated in cr_def.h |
---|
| 88 | * @param entity the WorldEntity colliding with the ground |
---|
| 89 | * @param groundEntity the WorldEntity representing the ground |
---|
| 90 | * @param normal the normal vector for the ground (up) - not always specified |
---|
| 91 | * @param position the position of the collision relative to the object center |
---|
| 92 | * @param bInWall true if the entity is in the ground material |
---|
| 93 | */ |
---|
[9893] | 94 | void CollisionTube::registerCollisionEvent(CREngine::CollisionType type, WorldEntity* entity, WorldEntity* groundEntity, |
---|
[9891] | 95 | const Vector& normal, const Vector& position, bool bInWall) |
---|
| 96 | { |
---|
[9893] | 97 | Collision* collision = this->_collisionList.back(); |
---|
| 98 | |
---|
| 99 | // check if there is already a collision defined between these objects |
---|
| 100 | if( !collision->match(*entity, *groundEntity)) |
---|
| 101 | { |
---|
| 102 | collision = CREngine::getInstance()->popCollisionObject(); |
---|
| 103 | collision->collide( entity, groundEntity); |
---|
| 104 | } |
---|
| 105 | |
---|
| 106 | // now register the new collision event |
---|
| 107 | CollisionEvent* collisionEvent = CREngine::getInstance()->popCollisionEventObject(); |
---|
| 108 | collisionEvent->collide( type, entity, groundEntity, normal, position, bInWall); |
---|
| 109 | collision->registerCollisionEvent( collisionEvent); |
---|
[9891] | 110 | } |
---|
| 111 | |
---|
[9893] | 112 | |
---|
[9891] | 113 | /** |
---|
[9893] | 114 | * checks if two objects are |
---|
| 115 | */ |
---|
| 116 | bool CollisionTube::needCollisionChecking(const WorldEntity& entityA, const WorldEntity& entityB) |
---|
| 117 | { |
---|
| 118 | //if( !this->isReactive( entityA, entityB) ) |
---|
| 119 | // return false; |
---|
| 120 | |
---|
| 121 | //if( entityA->) |
---|
| 122 | |
---|
| 123 | } |
---|
| 124 | |
---|
| 125 | |
---|
| 126 | /** |
---|
[9891] | 127 | * handles all collisions in registered in this tube |
---|
| 128 | */ |
---|
| 129 | void CollisionTube::handleCollisions() |
---|
| 130 | { |
---|
| 131 | // |
---|
| 132 | } |
---|
| 133 | |
---|
| 134 | |
---|
[9890] | 135 | } |
---|
| 136 | |
---|