Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/archive/environment2/src/external/bullet/BulletCollision/CollisionShapes/btCylinderShape.cpp @ 12373

Last change on this file since 12373 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.7 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#include "btCylinderShape.h"
17
18btCylinderShape::btCylinderShape (const btVector3& halfExtents)
19:btConvexInternalShape(),
20m_upAxis(1)
21{
22        btVector3 margin(getMargin(),getMargin(),getMargin());
23        m_implicitShapeDimensions = (halfExtents * m_localScaling) - margin;
24        m_shapeType = CYLINDER_SHAPE_PROXYTYPE;
25}
26
27
28btCylinderShapeX::btCylinderShapeX (const btVector3& halfExtents)
29:btCylinderShape(halfExtents)
30{
31        m_upAxis = 0;
32
33}
34
35
36btCylinderShapeZ::btCylinderShapeZ (const btVector3& halfExtents)
37:btCylinderShape(halfExtents)
38{
39        m_upAxis = 2;
40
41}
42
43void btCylinderShape::getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const
44{
45        btTransformAabb(getHalfExtentsWithoutMargin(),getMargin(),t,aabbMin,aabbMax);
46}
47
48void    btCylinderShape::calculateLocalInertia(btScalar mass,btVector3& inertia) const
49{
50        //approximation of box shape, todo: implement cylinder shape inertia before people notice ;-)
51        btVector3 halfExtents = getHalfExtentsWithMargin();
52
53        btScalar lx=btScalar(2.)*(halfExtents.x());
54        btScalar ly=btScalar(2.)*(halfExtents.y());
55        btScalar lz=btScalar(2.)*(halfExtents.z());
56
57        inertia.setValue(mass/(btScalar(12.0)) * (ly*ly + lz*lz),
58                                        mass/(btScalar(12.0)) * (lx*lx + lz*lz),
59                                        mass/(btScalar(12.0)) * (lx*lx + ly*ly));
60
61}
62
63
64SIMD_FORCE_INLINE btVector3 CylinderLocalSupportX(const btVector3& halfExtents,const btVector3& v) 
65{
66const int cylinderUpAxis = 0;
67const int XX = 1;
68const int YY = 0;
69const int ZZ = 2;
70
71        //mapping depends on how cylinder local orientation is
72        // extents of the cylinder is: X,Y is for radius, and Z for height
73
74
75        btScalar radius = halfExtents[XX];
76        btScalar halfHeight = halfExtents[cylinderUpAxis];
77
78
79    btVector3 tmp;
80        btScalar d ;
81
82    btScalar s = btSqrt(v[XX] * v[XX] + v[ZZ] * v[ZZ]);
83    if (s != btScalar(0.0))
84        {
85        d = radius / s; 
86                tmp[XX] = v[XX] * d;
87                tmp[YY] = v[YY] < 0.0 ? -halfHeight : halfHeight;
88                tmp[ZZ] = v[ZZ] * d;
89                return tmp;
90        }
91    else
92        {
93            tmp[XX] = radius;
94                tmp[YY] = v[YY] < 0.0 ? -halfHeight : halfHeight;
95                tmp[ZZ] = btScalar(0.0);
96                return tmp;
97    }
98
99
100}
101
102
103
104
105
106
107inline  btVector3 CylinderLocalSupportY(const btVector3& halfExtents,const btVector3& v) 
108{
109
110const int cylinderUpAxis = 1;
111const int XX = 0;
112const int YY = 1;
113const int ZZ = 2;
114
115
116        btScalar radius = halfExtents[XX];
117        btScalar halfHeight = halfExtents[cylinderUpAxis];
118
119
120    btVector3 tmp;
121        btScalar d ;
122
123    btScalar s = btSqrt(v[XX] * v[XX] + v[ZZ] * v[ZZ]);
124    if (s != btScalar(0.0))
125        {
126        d = radius / s; 
127                tmp[XX] = v[XX] * d;
128                tmp[YY] = v[YY] < 0.0 ? -halfHeight : halfHeight;
129                tmp[ZZ] = v[ZZ] * d;
130                return tmp;
131        }
132    else
133        {
134            tmp[XX] = radius;
135                tmp[YY] = v[YY] < 0.0 ? -halfHeight : halfHeight;
136                tmp[ZZ] = btScalar(0.0);
137                return tmp;
138    }
139
140}
141
142inline btVector3 CylinderLocalSupportZ(const btVector3& halfExtents,const btVector3& v) 
143{
144const int cylinderUpAxis = 2;
145const int XX = 0;
146const int YY = 2;
147const int ZZ = 1;
148
149        //mapping depends on how cylinder local orientation is
150        // extents of the cylinder is: X,Y is for radius, and Z for height
151
152
153        btScalar radius = halfExtents[XX];
154        btScalar halfHeight = halfExtents[cylinderUpAxis];
155
156
157    btVector3 tmp;
158        btScalar d ;
159
160    btScalar s = btSqrt(v[XX] * v[XX] + v[ZZ] * v[ZZ]);
161    if (s != btScalar(0.0))
162        {
163        d = radius / s; 
164                tmp[XX] = v[XX] * d;
165                tmp[YY] = v[YY] < 0.0 ? -halfHeight : halfHeight;
166                tmp[ZZ] = v[ZZ] * d;
167                return tmp;
168        }
169    else
170        {
171            tmp[XX] = radius;
172                tmp[YY] = v[YY] < 0.0 ? -halfHeight : halfHeight;
173                tmp[ZZ] = btScalar(0.0);
174                return tmp;
175    }
176
177
178}
179
180btVector3       btCylinderShapeX::localGetSupportingVertexWithoutMargin(const btVector3& vec)const
181{
182        return CylinderLocalSupportX(getHalfExtentsWithoutMargin(),vec);
183}
184
185
186btVector3       btCylinderShapeZ::localGetSupportingVertexWithoutMargin(const btVector3& vec)const
187{
188        return CylinderLocalSupportZ(getHalfExtentsWithoutMargin(),vec);
189}
190btVector3       btCylinderShape::localGetSupportingVertexWithoutMargin(const btVector3& vec)const
191{
192        return CylinderLocalSupportY(getHalfExtentsWithoutMargin(),vec);
193}
194
195void    btCylinderShape::batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const
196{
197        for (int i=0;i<numVectors;i++)
198        {
199                supportVerticesOut[i] = CylinderLocalSupportY(getHalfExtentsWithoutMargin(),vectors[i]);
200        }
201}
202
203void    btCylinderShapeZ::batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const
204{
205        for (int i=0;i<numVectors;i++)
206        {
207                supportVerticesOut[i] = CylinderLocalSupportZ(getHalfExtentsWithoutMargin(),vectors[i]);
208        }
209}
210
211
212
213
214void    btCylinderShapeX::batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const
215{
216        for (int i=0;i<numVectors;i++)
217        {
218                supportVerticesOut[i] = CylinderLocalSupportX(getHalfExtentsWithoutMargin(),vectors[i]);
219        }
220}
221
222
Note: See TracBrowser for help on using the repository browser.