Changeset View
Changeset View
Standalone View
Standalone View
source/gameengine/Ketsji/KX_CollisionEventManager.h
- This file was moved from source/gameengine/Ketsji/KX_TouchEventManager.h.
| Context not available. | |||||
| * ***** END GPL LICENSE BLOCK ***** | * ***** END GPL LICENSE BLOCK ***** | ||||
| */ | */ | ||||
| /** \file KX_TouchEventManager.h | /** \file KX_CollisionEventManager.h | ||||
| * \ingroup ketsji | * \ingroup ketsji | ||||
| */ | */ | ||||
| Context not available. | |||||
| #include "SCA_EventManager.h" | #include "SCA_EventManager.h" | ||||
| #include "KX_TouchSensor.h" | #include "KX_CollisionSensor.h" | ||||
| #include "KX_GameObject.h" | #include "KX_GameObject.h" | ||||
| #include <vector> | #include <vector> | ||||
| Context not available. | |||||
| class SCA_ISensor; | class SCA_ISensor; | ||||
| class PHY_IPhysicsEnvironment; | class PHY_IPhysicsEnvironment; | ||||
| class KX_TouchEventManager : public SCA_EventManager | class KX_CollisionEventManager : public SCA_EventManager | ||||
| { | { | ||||
| /** | /** | ||||
| * Contains two colliding objects and the first contact point. | * Contains two colliding objects and the first contact point. | ||||
| */ | */ | ||||
| class NewCollision { | class NewCollision | ||||
| { | |||||
| public: | public: | ||||
| PHY_IPhysicsController *first; | PHY_IPhysicsController *first; | ||||
| PHY_IPhysicsController *second; | PHY_IPhysicsController *second; | ||||
| PHY_CollData *colldata; | const PHY_CollData *colldata; | ||||
| /** | /** | ||||
| * Creates a copy of the given PHY_CollData; freeing that copy should be done by the owner of | * Creates a copy of the given PHY_CollData; freeing that copy should be done by the owner of | ||||
| * the NewCollision object. | * the NewCollision object. | ||||
| * | * | ||||
| * This allows us to efficiently store NewCollision objects in a std::set without creating more | * This allows us to efficiently store NewCollision objects in a std::set without creating more | ||||
| * copies of colldata, as the NewCollision copy constructor reuses the pointer and doesn't clone | * copies of colldata, as the NewCollision copy constructor reuses the pointer and doesn't clone | ||||
| * it again. */ | * it again. */ | ||||
| NewCollision(PHY_IPhysicsController *first, | NewCollision(PHY_IPhysicsController *first, | ||||
| PHY_IPhysicsController *second, | PHY_IPhysicsController *second, | ||||
| const PHY_CollData *colldata); | const PHY_CollData *colldata); | ||||
| Context not available. | |||||
| bool operator<(const NewCollision &other) const; | bool operator<(const NewCollision &other) const; | ||||
| }; | }; | ||||
| PHY_IPhysicsEnvironment* m_physEnv; | PHY_IPhysicsEnvironment *m_physEnv; | ||||
| std::set<NewCollision> m_newCollisions; | |||||
| static bool newCollisionResponse(void *client_data, | |||||
| void *object1, | |||||
| void *object2, | |||||
| const PHY_CollData *coll_data); | |||||
| static bool newBroadphaseResponse(void *client_data, | |||||
| void *object1, | |||||
| void *object2, | |||||
| const PHY_CollData *coll_data); | |||||
| virtual bool NewHandleCollision(void* obj1,void* obj2, | std::set<NewCollision> m_newCollisions; | ||||
| const PHY_CollData * coll_data); | |||||
| static bool newCollisionResponse(void *client_data, | |||||
| void *object1, | |||||
| void *object2, | |||||
| const PHY_CollData *coll_data); | |||||
| static bool newBroadphaseResponse(void *client_data, | |||||
| void *object1, | |||||
| void *object2, | |||||
| const PHY_CollData *coll_data); | |||||
| virtual bool NewHandleCollision(void *obj1, void *obj2, | |||||
| const PHY_CollData *coll_data); | |||||
| void RemoveNewCollisions(); | |||||
| public: | public: | ||||
| KX_TouchEventManager(class SCA_LogicManager* logicmgr, | KX_CollisionEventManager(class SCA_LogicManager *logicmgr, | ||||
| PHY_IPhysicsEnvironment* physEnv); | PHY_IPhysicsEnvironment *physEnv); | ||||
| virtual ~KX_CollisionEventManager(); | |||||
| virtual void NextFrame(); | virtual void NextFrame(); | ||||
| virtual void EndFrame(); | virtual void EndFrame(); | ||||
| virtual void RegisterSensor(SCA_ISensor* sensor); | virtual void RegisterSensor(SCA_ISensor *sensor); | ||||
| virtual void RemoveSensor(SCA_ISensor* sensor); | virtual void RemoveSensor(SCA_ISensor *sensor); | ||||
| SCA_LogicManager* GetLogicManager() { return m_logicmgr;} | |||||
| PHY_IPhysicsEnvironment *GetPhysicsEnvironment() { return m_physEnv; } | SCA_LogicManager *GetLogicManager() | ||||
| { | |||||
| return m_logicmgr; | |||||
| } | |||||
| PHY_IPhysicsEnvironment *GetPhysicsEnvironment() | |||||
| { | |||||
| return m_physEnv; | |||||
| } | |||||
| #ifdef WITH_CXX_GUARDEDALLOC | #ifdef WITH_CXX_GUARDEDALLOC | ||||
| MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_TouchEventManager") | MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_CollisionEventManager") | ||||
| #endif | #endif | ||||
| }; | }; | ||||
| #endif /* __KX_TOUCHEVENTMANAGER_H__ */ | #endif // __KX_TOUCHEVENTMANAGER_H__ | ||||
| Context not available. | |||||