Blender  V2.59
KX_TouchEventManager.h
Go to the documentation of this file.
00001 /*
00002  * $Id: KX_TouchEventManager.h 35063 2011-02-22 10:33:14Z jesterking $
00003  *
00004  * ***** BEGIN GPL LICENSE BLOCK *****
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software Foundation,
00018  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019  *
00020  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
00021  * All rights reserved.
00022  *
00023  * The Original Code is: all of this file.
00024  *
00025  * Contributor(s): none yet.
00026  *
00027  * ***** END GPL LICENSE BLOCK *****
00028  */
00029 
00034 #ifndef __KX_TOUCHEVENTMANAGER
00035 #define __KX_TOUCHEVENTMANAGER
00036 
00037 
00038 #include "SCA_EventManager.h"
00039 #include "KX_TouchSensor.h"
00040 #include "KX_GameObject.h"
00041 
00042 #include <vector>
00043 #include <set>
00044 
00045 class SCA_ISensor;
00046 class PHY_IPhysicsEnvironment;
00047 
00048 class KX_TouchEventManager : public SCA_EventManager
00049 {
00050         typedef std::pair<PHY_IPhysicsController*, PHY_IPhysicsController*> NewCollision;
00051         PHY_IPhysicsEnvironment*        m_physEnv;
00052         
00053         std::set<NewCollision> m_newCollisions;
00054         
00055         
00056         static bool newCollisionResponse(void *client_data, 
00057                                                 void *object1,
00058                                                 void *object2,
00059                                                 const PHY_CollData *coll_data);
00060 
00061         static bool newBroadphaseResponse(void *client_data, 
00062                                                 void *object1,
00063                                                 void *object2,
00064                                                 const PHY_CollData *coll_data);
00065 
00066         virtual bool    NewHandleCollision(void* obj1,void* obj2,
00067                                                 const PHY_CollData * coll_data); 
00068 
00069 
00070 
00071 
00072 
00073 public:
00074         KX_TouchEventManager(class SCA_LogicManager* logicmgr,  
00075                 PHY_IPhysicsEnvironment* physEnv);
00076         virtual void NextFrame();
00077         virtual void    EndFrame();
00078         virtual void RegisterSensor(SCA_ISensor* sensor);
00079         virtual void RemoveSensor(SCA_ISensor* sensor);
00080         SCA_LogicManager* GetLogicManager() { return m_logicmgr;}
00081         PHY_IPhysicsEnvironment *GetPhysicsEnvironment() { return m_physEnv; }
00082         virtual void    Replace_PhysicsScene(PHY_IPhysicsEnvironment* env) { m_physEnv= env; }
00083 
00084         
00085 #ifdef WITH_CXX_GUARDEDALLOC
00086 public:
00087         void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_TouchEventManager"); }
00088         void operator delete( void *mem ) { MEM_freeN(mem); }
00089 #endif
00090 };
00091 
00092 #endif //__KX_TOUCHEVENTMANAGER
00093