/*! * @file collision_event.h * Definition of a collision event * * A collision event represents a collision of two bouning boxes. Every CollisionEvent belongs to a Collision object that * represents the collision of two WorldEntities. * * There are different types of collisions: obb collisions and bsp collisions. Both collision types use different techniques * to represent collisions. This is why this class saves bounding boxes from the OBB as well as the planes from BSP. */ #ifndef _COLLISION_EVENT_H #define _COLLISION_EVENT_H #include "vector.h" #include "cr_engine.h" #include "cr_defs.h" class WorldEntity; class BoundingVolume; class Plane; namespace CoRe { //! A class representing a simple collision class CollisionEvent { public: CollisionEvent(); virtual ~CollisionEvent(); /** collides two WorldEntities @param entityA world entity A, @param entityB world entity B, @param bvA volume A @param bvB volumeB */ inline void collide(CREngine::CollisionType type, WorldEntity* entityA, WorldEntity* entityB, BoundingVolume* bvA, BoundingVolume* bvB) { this->collisionType = type; this->entityA = entityA; this->entityB = entityB; this->bvA = bvA; this->bvB = bvB; } /** collides two WorldEntities @param entity world entity , @param ground ground plane, @param position position on the ground */ inline void collide(CREngine::CollisionType type, WorldEntity* entity, WorldEntity* groundEntity, Vector normal, Vector position, bool bInWall) { this->collisionType = type; this->entityA = entity; this->entityB = groundEntity; this->groundNormal = normal; this->position = position; this->bInWall = bInWall; } /** @return CollisionEvent WorldEntity A */ inline const WorldEntity* getEntityA() const { return this->entityA; } /** @return CollisionEvent WorldEntity B */ inline const WorldEntity* getEntityB() const { return this->entityB; } /** @return Bounding Volume from EntityA */ inline const BoundingVolume* getBVA() const { return this->bvA; } /** @return Bounding Volume from EntityB */ inline const BoundingVolume* getBVB() const { return this->bvB; } /** @return ground plane if collided with bsp model */ inline const Vector& getGroundNormal() const { return this->groundNormal; } /** @return position of the position, only accurate if this is a collision with the ground!!! */ inline const Vector& getCollisionPosition() const { return this->position; } /** @return the type of the collision */ inline int getType() const { return this->collisionType; } /** @return true if the entity is in the wall */ inline bool isInWall() const { return this->bInWall; } private: WorldEntity* entityA; //!< the collision body A WorldEntity* entityB; //!< the collision body B BoundingVolume* bvA; //!< reference to the bounding volume A BoundingVolume* bvB; //!< reference to the bounding volume B Vector groundNormal; //!< the ground plane with which it collides (only for bsp-model collisions Vector position; //!< position of the collision on the ground plane bool bInWall; //!< true if is in wall int collisionType; //!< collision type }; } #endif /* _COLLISION_EVENT_H */