synched with trunk at revision 32129
[blender.git] / source / gameengine / Ketsji / KX_TouchEventManager.h
1 /**
2  * $Id$
3  *
4  * ***** BEGIN GPL LICENSE BLOCK *****
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software Foundation,
18  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  *
20  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
21  * All rights reserved.
22  *
23  * The Original Code is: all of this file.
24  *
25  * Contributor(s): none yet.
26  *
27  * ***** END GPL LICENSE BLOCK *****
28  */
29 #ifndef __KX_TOUCHEVENTMANAGER
30 #define __KX_TOUCHEVENTMANAGER
31
32
33 #include "SCA_EventManager.h"
34 #include "KX_TouchSensor.h"
35 #include "KX_GameObject.h"
36
37 #include <vector>
38 #include <set>
39
40 class SCA_ISensor;
41 class PHY_IPhysicsEnvironment;
42
43 class KX_TouchEventManager : public SCA_EventManager
44 {
45         typedef std::pair<PHY_IPhysicsController*, PHY_IPhysicsController*> NewCollision;
46         PHY_IPhysicsEnvironment*        m_physEnv;
47         
48         std::set<NewCollision> m_newCollisions;
49         
50         
51         static bool newCollisionResponse(void *client_data, 
52                                                 void *object1,
53                                                 void *object2,
54                                                 const PHY_CollData *coll_data);
55
56         static bool newBroadphaseResponse(void *client_data, 
57                                                 void *object1,
58                                                 void *object2,
59                                                 const PHY_CollData *coll_data);
60
61         virtual bool    NewHandleCollision(void* obj1,void* obj2,
62                                                 const PHY_CollData * coll_data); 
63
64
65
66
67
68 public:
69         KX_TouchEventManager(class SCA_LogicManager* logicmgr,  
70                 PHY_IPhysicsEnvironment* physEnv);
71         virtual void NextFrame();
72         virtual void    EndFrame();
73         virtual void RegisterSensor(SCA_ISensor* sensor);
74         virtual void RemoveSensor(SCA_ISensor* sensor);
75         SCA_LogicManager* GetLogicManager() { return m_logicmgr;}
76         PHY_IPhysicsEnvironment *GetPhysicsEnvironment() { return m_physEnv; }
77         virtual void    Replace_PhysicsScene(PHY_IPhysicsEnvironment* env) { m_physEnv= env; }
78
79         
80 #ifdef WITH_CXX_GUARDEDALLOC
81 public:
82         void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_TouchEventManager"); }
83         void operator delete( void *mem ) { MEM_freeN(mem); }
84 #endif
85 };
86
87 #endif //__KX_TOUCHEVENTMANAGER
88