Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/archive/environment2/src/external/bullet/BulletCollision/CollisionShapes/btCompoundShape.h @ 10255

Last change on this file since 10255 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: 6.3 KB
Line 
1/*
2Bullet Continuous Collision Detection and Physics Library
3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
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 COMPOUND_SHAPE_H
17#define COMPOUND_SHAPE_H
18
19#include "btCollisionShape.h"
20
21#include "LinearMath/btVector3.h"
22#include "LinearMath/btTransform.h"
23#include "LinearMath/btMatrix3x3.h"
24#include "btCollisionMargin.h"
25#include "LinearMath/btAlignedObjectArray.h"
26
27//class btOptimizedBvh;
28struct btDbvt;
29
30ATTRIBUTE_ALIGNED16(struct) btCompoundShapeChild
31{
32        BT_DECLARE_ALIGNED_ALLOCATOR();
33
34        btTransform                     m_transform;
35        btCollisionShape*       m_childShape;
36        int                                     m_childShapeType;
37        btScalar                        m_childMargin;
38        struct btDbvtNode*      m_node;
39};
40
41SIMD_FORCE_INLINE bool operator==(const btCompoundShapeChild& c1, const btCompoundShapeChild& c2)
42{
43        return  ( c1.m_transform      == c2.m_transform &&
44                c1.m_childShape     == c2.m_childShape &&
45                c1.m_childShapeType == c2.m_childShapeType &&
46                c1.m_childMargin    == c2.m_childMargin );
47}
48
49/// The btCompoundShape allows to store multiple other btCollisionShapes
50/// This allows for moving concave collision objects. This is more general then the static concave btBvhTriangleMeshShape.
51/// It has an (optional) dynamic aabb tree to accelerate early rejection tests.
52/// @todo: This aabb tree can also be use to speed up ray tests on btCompoundShape, see http://code.google.com/p/bullet/issues/detail?id=25
53/// Currently, removal of child shapes is only supported when disabling the aabb tree (pass 'false' in the constructor of btCompoundShape)
54ATTRIBUTE_ALIGNED16(class) btCompoundShape      : public btCollisionShape
55{
56        btAlignedObjectArray<btCompoundShapeChild> m_children;
57        btVector3                                               m_localAabbMin;
58        btVector3                                               m_localAabbMax;
59
60        btDbvt*                                                 m_dynamicAabbTree;
61
62        ///increment m_updateRevision when adding/removing/replacing child shapes, so that some caches can be updated
63        int                                                             m_updateRevision;
64
65        btScalar        m_collisionMargin;
66
67protected:
68        btVector3       m_localScaling;
69
70public:
71        BT_DECLARE_ALIGNED_ALLOCATOR();
72
73        btCompoundShape(bool enableDynamicAabbTree = true);
74
75        virtual ~btCompoundShape();
76
77        void    addChildShape(const btTransform& localTransform,btCollisionShape* shape);
78
79        /// Remove all children shapes that contain the specified shape
80        virtual void removeChildShape(btCollisionShape* shape);
81
82        void removeChildShapeByIndex(int childShapeindex);
83
84
85        int             getNumChildShapes() const
86        {
87                return int (m_children.size());
88        }
89
90        btCollisionShape* getChildShape(int index)
91        {
92                return m_children[index].m_childShape;
93        }
94        const btCollisionShape* getChildShape(int index) const
95        {
96                return m_children[index].m_childShape;
97        }
98
99        btTransform&    getChildTransform(int index)
100        {
101                return m_children[index].m_transform;
102        }
103        const btTransform&      getChildTransform(int index) const
104        {
105                return m_children[index].m_transform;
106        }
107
108        ///set a new transform for a child, and update internal data structures (local aabb and dynamic tree)
109        void    updateChildTransform(int childIndex, const btTransform& newChildTransform);
110
111
112        btCompoundShapeChild* getChildList()
113        {
114                return &m_children[0];
115        }
116
117        ///getAabb's default implementation is brute force, expected derived classes to implement a fast dedicated version
118        virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const;
119
120        /** Re-calculate the local Aabb. Is called at the end of removeChildShapes.
121        Use this yourself if you modify the children or their transforms. */
122        virtual void recalculateLocalAabb(); 
123
124        virtual void    setLocalScaling(const btVector3& scaling);
125
126        virtual const btVector3& getLocalScaling() const 
127        {
128                return m_localScaling;
129        }
130
131        virtual void    calculateLocalInertia(btScalar mass,btVector3& inertia) const;
132
133        virtual void    setMargin(btScalar margin)
134        {
135                m_collisionMargin = margin;
136        }
137        virtual btScalar        getMargin() const
138        {
139                return m_collisionMargin;
140        }
141        virtual const char*     getName()const
142        {
143                return "Compound";
144        }
145
146
147        btDbvt*                                                 getDynamicAabbTree()
148        {
149                return m_dynamicAabbTree;
150        }
151
152        void createAabbTreeFromChildren();
153
154        ///computes the exact moment of inertia and the transform from the coordinate system defined by the principal axes of the moment of inertia
155        ///and the center of mass to the current coordinate system. "masses" points to an array of masses of the children. The resulting transform
156        ///"principal" has to be applied inversely to all children transforms in order for the local coordinate system of the compound
157        ///shape to be centered at the center of mass and to coincide with the principal axes. This also necessitates a correction of the world transform
158        ///of the collision object by the principal transform.
159        void calculatePrincipalAxisTransform(btScalar* masses, btTransform& principal, btVector3& inertia) const;
160
161        int     getUpdateRevision() const
162        {
163                return m_updateRevision;
164        }
165
166        virtual int     calculateSerializeBufferSize() const;
167
168        ///fills the dataBuffer and returns the struct name (and 0 on failure)
169        virtual const char*     serialize(void* dataBuffer, btSerializer* serializer) const;
170
171
172};
173
174///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
175struct btCompoundShapeChildData
176{
177        btTransformFloatData    m_transform;
178        btCollisionShapeData    *m_childShape;
179        int                                             m_childShapeType;
180        float                                   m_childMargin;
181};
182
183///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
184struct  btCompoundShapeData
185{
186        btCollisionShapeData            m_collisionShapeData;
187
188        btCompoundShapeChildData        *m_childShapePtr;
189
190        int                                                     m_numChildShapes;
191
192        float   m_collisionMargin;
193
194};
195
196
197SIMD_FORCE_INLINE       int     btCompoundShape::calculateSerializeBufferSize() const
198{
199        return sizeof(btCompoundShapeData);
200}
201
202
203
204
205
206
207
208#endif //COMPOUND_SHAPE_H
Note: See TracBrowser for help on using the repository browser.