Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btCylinderShape.h @ 8353

Last change on this file since 8353 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.8 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 CYLINDER_MINKOWSKI_H
17#define CYLINDER_MINKOWSKI_H
18
19#include "btBoxShape.h"
20#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" // for the types
21#include "LinearMath/btVector3.h"
22
23/// The btCylinderShape class implements a cylinder shape primitive, centered around the origin. Its central axis aligned with the Y axis. btCylinderShapeX is aligned with the X axis and btCylinderShapeZ around the Z axis.
24class btCylinderShape : public btConvexInternalShape
25
26{
27
28protected:
29
30        int     m_upAxis;
31
32public:
33
34        btVector3 getHalfExtentsWithMargin() const
35        {
36                btVector3 halfExtents = getHalfExtentsWithoutMargin();
37                btVector3 margin(getMargin(),getMargin(),getMargin());
38                halfExtents += margin;
39                return halfExtents;
40        }
41       
42        const btVector3& getHalfExtentsWithoutMargin() const
43        {
44                return m_implicitShapeDimensions;//changed in Bullet 2.63: assume the scaling and margin are included
45        }
46
47        btCylinderShape (const btVector3& halfExtents);
48       
49        void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const;
50
51        virtual void    calculateLocalInertia(btScalar mass,btVector3& inertia) const;
52
53        virtual btVector3       localGetSupportingVertexWithoutMargin(const btVector3& vec)const;
54
55        virtual void    batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const;
56
57        virtual void setMargin(btScalar collisionMargin)
58        {
59                //correct the m_implicitShapeDimensions for the margin
60                btVector3 oldMargin(getMargin(),getMargin(),getMargin());
61                btVector3 implicitShapeDimensionsWithMargin = m_implicitShapeDimensions+oldMargin;
62               
63                btConvexInternalShape::setMargin(collisionMargin);
64                btVector3 newMargin(getMargin(),getMargin(),getMargin());
65                m_implicitShapeDimensions = implicitShapeDimensionsWithMargin - newMargin;
66
67        }
68
69        virtual btVector3       localGetSupportingVertex(const btVector3& vec) const
70        {
71
72                btVector3 supVertex;
73                supVertex = localGetSupportingVertexWithoutMargin(vec);
74               
75                if ( getMargin()!=btScalar(0.) )
76                {
77                        btVector3 vecnorm = vec;
78                        if (vecnorm .length2() < (SIMD_EPSILON*SIMD_EPSILON))
79                        {
80                                vecnorm.setValue(btScalar(-1.),btScalar(-1.),btScalar(-1.));
81                        } 
82                        vecnorm.normalize();
83                        supVertex+= getMargin() * vecnorm;
84                }
85                return supVertex;
86        }
87
88
89        //use box inertia
90        //      virtual void    calculateLocalInertia(btScalar mass,btVector3& inertia) const;
91
92
93        int     getUpAxis() const
94        {
95                return m_upAxis;
96        }
97
98        virtual btScalar getRadius() const
99        {
100                return getHalfExtentsWithMargin().getX();
101        }
102
103        virtual void    setLocalScaling(const btVector3& scaling)
104        {
105                btVector3 oldMargin(getMargin(),getMargin(),getMargin());
106                btVector3 implicitShapeDimensionsWithMargin = m_implicitShapeDimensions+oldMargin;
107                btVector3 unScaledImplicitShapeDimensionsWithMargin = implicitShapeDimensionsWithMargin / m_localScaling;
108
109                btConvexInternalShape::setLocalScaling(scaling);
110
111                m_implicitShapeDimensions = (unScaledImplicitShapeDimensionsWithMargin * m_localScaling) - oldMargin;
112
113        }
114
115        //debugging
116        virtual const char*     getName()const
117        {
118                return "CylinderY";
119        }
120
121        virtual int     calculateSerializeBufferSize() const;
122
123        ///fills the dataBuffer and returns the struct name (and 0 on failure)
124        virtual const char*     serialize(void* dataBuffer, btSerializer* serializer) const;
125
126};
127
128class btCylinderShapeX : public btCylinderShape
129{
130public:
131        btCylinderShapeX (const btVector3& halfExtents);
132
133        virtual btVector3       localGetSupportingVertexWithoutMargin(const btVector3& vec)const;
134        virtual void    batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const;
135       
136                //debugging
137        virtual const char*     getName()const
138        {
139                return "CylinderX";
140        }
141
142        virtual btScalar getRadius() const
143        {
144                return getHalfExtentsWithMargin().getY();
145        }
146
147};
148
149class btCylinderShapeZ : public btCylinderShape
150{
151public:
152        btCylinderShapeZ (const btVector3& halfExtents);
153
154        virtual btVector3       localGetSupportingVertexWithoutMargin(const btVector3& vec)const;
155        virtual void    batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const;
156
157                //debugging
158        virtual const char*     getName()const
159        {
160                return "CylinderZ";
161        }
162
163        virtual btScalar getRadius() const
164        {
165                return getHalfExtentsWithMargin().getX();
166        }
167
168};
169
170///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
171struct  btCylinderShapeData
172{
173        btConvexInternalShapeData       m_convexInternalShapeData;
174
175        int     m_upAxis;
176
177        char    m_padding[4];
178};
179
180SIMD_FORCE_INLINE       int     btCylinderShape::calculateSerializeBufferSize() const
181{
182        return sizeof(btCylinderShapeData);
183}
184
185        ///fills the dataBuffer and returns the struct name (and 0 on failure)
186SIMD_FORCE_INLINE       const char*     btCylinderShape::serialize(void* dataBuffer, btSerializer* serializer) const
187{
188        btCylinderShapeData* shapeData = (btCylinderShapeData*) dataBuffer;
189       
190        btConvexInternalShape::serialize(&shapeData->m_convexInternalShapeData,serializer);
191
192        shapeData->m_upAxis = m_upAxis;
193       
194        return "btCylinderShapeData";
195}
196
197
198
199#endif //CYLINDER_MINKOWSKI_H
200
Note: See TracBrowser for help on using the repository browser.