Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btGhostObject.h @ 9032

Last change on this file since 9032 was 8351, checked in by rgrieder, 14 years ago

Merged kicklib2 branch back to trunk (includes former branches ois_update, mac_osx and kicklib).

Notes for updating

Linux:
You don't need an extra package for CEGUILua and Tolua, it's already shipped with CEGUI.
However you do need to make sure that the OgreRenderer is installed too with CEGUI 0.7 (may be a separate package).
Also, Orxonox now recognises if you install the CgProgramManager (a separate package available on newer Ubuntu on Debian systems).

Windows:
Download the new dependency packages versioned 6.0 and use these. If you have problems with that or if you don't like the in game console problem mentioned below, you can download the new 4.3 version of the packages (only available for Visual Studio 2005/2008).

Key new features:

  • *Support for Mac OS X*
  • Visual Studio 2010 support
  • Bullet library update to 2.77
  • OIS library update to 1.3
  • Support for CEGUI 0.7 —> Support for Arch Linux and even SuSE
  • Improved install target
  • Compiles now with GCC 4.6
  • Ogre Cg Shader plugin activated for Linux if available
  • And of course lots of bug fixes

There are also some regressions:

  • No support for CEGUI 0.5, Ogre 1.4 and boost 1.35 - 1.39 any more
  • In game console is not working in main menu for CEGUI 0.7
  • Tolua (just the C lib, not the application) and CEGUILua libraries are no longer in our repository. —> You will need to get these as well when compiling Orxonox
  • And of course lots of new bugs we don't yet know about
  • Property svn:eol-style set to native
File size: 5.5 KB
Line 
1/*
2Bullet Continuous Collision Detection and Physics Library
3Copyright (c) 2003-2008 Erwin Coumans  http://bulletphysics.com
4
5This software is provided 'as-is', without any express or implied warranty.
6In no event will the authors be held liable for any damages arising from the use of this software.
7Permission is granted to anyone to use this software for any purpose,
8including commercial applications, and to alter it and redistribute it freely,
9subject to the following restrictions:
10
111. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
122. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
133. This notice may not be removed or altered from any source distribution.
14*/
15
16#ifndef BT_GHOST_OBJECT_H
17#define BT_GHOST_OBJECT_H
18
19
20#include "btCollisionObject.h"
21#include "BulletCollision/BroadphaseCollision/btOverlappingPairCallback.h"
22#include "LinearMath/btAlignedAllocator.h"
23#include "BulletCollision/BroadphaseCollision/btOverlappingPairCache.h"
24#include "btCollisionWorld.h"
25
26class btConvexShape;
27
28class btDispatcher;
29
30///The btGhostObject can keep track of all objects that are overlapping
31///By default, this overlap is based on the AABB
32///This is useful for creating a character controller, collision sensors/triggers, explosions etc.
33///We plan on adding rayTest and other queries for the btGhostObject
34ATTRIBUTE_ALIGNED16(class) btGhostObject : public btCollisionObject
35{
36protected:
37
38        btAlignedObjectArray<btCollisionObject*> m_overlappingObjects;
39
40public:
41
42        btGhostObject();
43
44        virtual ~btGhostObject();
45
46        void    convexSweepTest(const class btConvexShape* castShape, const btTransform& convexFromWorld, const btTransform& convexToWorld, btCollisionWorld::ConvexResultCallback& resultCallback, btScalar allowedCcdPenetration = 0.f) const;
47
48        void    rayTest(const btVector3& rayFromWorld, const btVector3& rayToWorld, btCollisionWorld::RayResultCallback& resultCallback) const; 
49
50        ///this method is mainly for expert/internal use only.
51        virtual void    addOverlappingObjectInternal(btBroadphaseProxy* otherProxy, btBroadphaseProxy* thisProxy=0);
52        ///this method is mainly for expert/internal use only.
53        virtual void    removeOverlappingObjectInternal(btBroadphaseProxy* otherProxy,btDispatcher* dispatcher,btBroadphaseProxy* thisProxy=0);
54
55        int     getNumOverlappingObjects() const
56        {
57                return m_overlappingObjects.size();
58        }
59
60        btCollisionObject*      getOverlappingObject(int index)
61        {
62                return m_overlappingObjects[index];
63        }
64
65        const btCollisionObject*        getOverlappingObject(int index) const
66        {
67                return m_overlappingObjects[index];
68        }
69
70        btAlignedObjectArray<btCollisionObject*>&       getOverlappingPairs()
71        {
72                return m_overlappingObjects;
73        }
74
75        const btAlignedObjectArray<btCollisionObject*>  getOverlappingPairs() const
76        {
77                return m_overlappingObjects;
78        }
79
80        //
81        // internal cast
82        //
83
84        static const btGhostObject*     upcast(const btCollisionObject* colObj)
85        {
86                if (colObj->getInternalType()==CO_GHOST_OBJECT)
87                        return (const btGhostObject*)colObj;
88                return 0;
89        }
90        static btGhostObject*                   upcast(btCollisionObject* colObj)
91        {
92                if (colObj->getInternalType()==CO_GHOST_OBJECT)
93                        return (btGhostObject*)colObj;
94                return 0;
95        }
96
97};
98
99class   btPairCachingGhostObject : public btGhostObject
100{
101        btHashedOverlappingPairCache*   m_hashPairCache;
102
103public:
104
105        btPairCachingGhostObject();
106
107        virtual ~btPairCachingGhostObject();
108
109        ///this method is mainly for expert/internal use only.
110        virtual void    addOverlappingObjectInternal(btBroadphaseProxy* otherProxy, btBroadphaseProxy* thisProxy=0);
111
112        virtual void    removeOverlappingObjectInternal(btBroadphaseProxy* otherProxy,btDispatcher* dispatcher,btBroadphaseProxy* thisProxy=0);
113
114        btHashedOverlappingPairCache*   getOverlappingPairCache()
115        {
116                return m_hashPairCache;
117        }
118
119};
120
121
122
123///The btGhostPairCallback interfaces and forwards adding and removal of overlapping pairs from the btBroadphaseInterface to btGhostObject.
124class btGhostPairCallback : public btOverlappingPairCallback
125{
126       
127public:
128        btGhostPairCallback()
129        {
130        }
131
132        virtual ~btGhostPairCallback()
133        {
134               
135        }
136
137        virtual btBroadphasePair*       addOverlappingPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1)
138        {
139                btCollisionObject* colObj0 = (btCollisionObject*) proxy0->m_clientObject;
140                btCollisionObject* colObj1 = (btCollisionObject*) proxy1->m_clientObject;
141                btGhostObject* ghost0 =                 btGhostObject::upcast(colObj0);
142                btGhostObject* ghost1 =                 btGhostObject::upcast(colObj1);
143                if (ghost0)
144                        ghost0->addOverlappingObjectInternal(proxy1, proxy0);
145                if (ghost1)
146                        ghost1->addOverlappingObjectInternal(proxy0, proxy1);
147                return 0;
148        }
149
150        virtual void*   removeOverlappingPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,btDispatcher* dispatcher)
151        {
152                btCollisionObject* colObj0 = (btCollisionObject*) proxy0->m_clientObject;
153                btCollisionObject* colObj1 = (btCollisionObject*) proxy1->m_clientObject;
154                btGhostObject* ghost0 =                 btGhostObject::upcast(colObj0);
155                btGhostObject* ghost1 =                 btGhostObject::upcast(colObj1);
156                if (ghost0)
157                        ghost0->removeOverlappingObjectInternal(proxy1,dispatcher,proxy0);
158                if (ghost1)
159                        ghost1->removeOverlappingObjectInternal(proxy0,dispatcher,proxy1);
160                return 0;
161        }
162
163        virtual void    removeOverlappingPairsContainingProxy(btBroadphaseProxy* /*proxy0*/,btDispatcher* /*dispatcher*/)
164        {
165                btAssert(0);
166                //need to keep track of all ghost objects and call them here
167                //m_hashPairCache->removeOverlappingPairsContainingProxy(proxy0,dispatcher);
168        }
169
170       
171
172};
173
174#endif
175
Note: See TracBrowser for help on using the repository browser.