Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/mac_osx2/src/external/bullet/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp @ 8825

Last change on this file since 8825 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: 4.6 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 "BulletCollision/CollisionShapes/btPolyhedralConvexShape.h"
17
18btPolyhedralConvexShape::btPolyhedralConvexShape() :btConvexInternalShape()
19{
20
21}
22
23
24btVector3       btPolyhedralConvexShape::localGetSupportingVertexWithoutMargin(const btVector3& vec0)const
25{
26
27
28        btVector3 supVec(0,0,0);
29#ifndef __SPU__
30        int i;
31        btScalar maxDot(btScalar(-BT_LARGE_FLOAT));
32
33        btVector3 vec = vec0;
34        btScalar lenSqr = vec.length2();
35        if (lenSqr < btScalar(0.0001))
36        {
37                vec.setValue(1,0,0);
38        } else
39        {
40                btScalar rlen = btScalar(1.) / btSqrt(lenSqr );
41                vec *= rlen;
42        }
43
44        btVector3 vtx;
45        btScalar newDot;
46
47        for (i=0;i<getNumVertices();i++)
48        {
49                getVertex(i,vtx);
50                newDot = vec.dot(vtx);
51                if (newDot > maxDot)
52                {
53                        maxDot = newDot;
54                        supVec = vtx;
55                }
56        }
57
58       
59#endif //__SPU__
60        return supVec;
61}
62
63
64
65void    btPolyhedralConvexShape::batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const
66{
67#ifndef __SPU__
68        int i;
69
70        btVector3 vtx;
71        btScalar newDot;
72
73        for (i=0;i<numVectors;i++)
74        {
75                supportVerticesOut[i][3] = btScalar(-BT_LARGE_FLOAT);
76        }
77
78        for (int j=0;j<numVectors;j++)
79        {
80       
81                const btVector3& vec = vectors[j];
82
83                for (i=0;i<getNumVertices();i++)
84                {
85                        getVertex(i,vtx);
86                        newDot = vec.dot(vtx);
87                        if (newDot > supportVerticesOut[j][3])
88                        {
89                                //WARNING: don't swap next lines, the w component would get overwritten!
90                                supportVerticesOut[j] = vtx;
91                                supportVerticesOut[j][3] = newDot;
92                        }
93                }
94        }
95#endif //__SPU__
96}
97
98
99
100void    btPolyhedralConvexShape::calculateLocalInertia(btScalar mass,btVector3& inertia) const
101{
102#ifndef __SPU__
103        //not yet, return box inertia
104
105        btScalar margin = getMargin();
106
107        btTransform ident;
108        ident.setIdentity();
109        btVector3 aabbMin,aabbMax;
110        getAabb(ident,aabbMin,aabbMax);
111        btVector3 halfExtents = (aabbMax-aabbMin)*btScalar(0.5);
112
113        btScalar lx=btScalar(2.)*(halfExtents.x()+margin);
114        btScalar ly=btScalar(2.)*(halfExtents.y()+margin);
115        btScalar lz=btScalar(2.)*(halfExtents.z()+margin);
116        const btScalar x2 = lx*lx;
117        const btScalar y2 = ly*ly;
118        const btScalar z2 = lz*lz;
119        const btScalar scaledmass = mass * btScalar(0.08333333);
120
121        inertia = scaledmass * (btVector3(y2+z2,x2+z2,x2+y2));
122#endif //__SPU__
123}
124
125
126
127void    btPolyhedralConvexAabbCachingShape::setLocalScaling(const btVector3& scaling)
128{
129        btConvexInternalShape::setLocalScaling(scaling);
130        recalcLocalAabb();
131}
132
133btPolyhedralConvexAabbCachingShape::btPolyhedralConvexAabbCachingShape()
134:btPolyhedralConvexShape(),
135m_localAabbMin(1,1,1),
136m_localAabbMax(-1,-1,-1),
137m_isLocalAabbValid(false)
138{
139}
140
141void btPolyhedralConvexAabbCachingShape::getAabb(const btTransform& trans,btVector3& aabbMin,btVector3& aabbMax) const
142{
143        getNonvirtualAabb(trans,aabbMin,aabbMax,getMargin());
144}
145
146void    btPolyhedralConvexAabbCachingShape::recalcLocalAabb()
147{
148        m_isLocalAabbValid = true;
149       
150        #if 1
151        static const btVector3 _directions[] =
152        {
153                btVector3( 1.,  0.,  0.),
154                btVector3( 0.,  1.,  0.),
155                btVector3( 0.,  0.,  1.),
156                btVector3( -1., 0.,  0.),
157                btVector3( 0., -1.,  0.),
158                btVector3( 0.,  0., -1.)
159        };
160       
161        btVector3 _supporting[] =
162        {
163                btVector3( 0., 0., 0.),
164                btVector3( 0., 0., 0.),
165                btVector3( 0., 0., 0.),
166                btVector3( 0., 0., 0.),
167                btVector3( 0., 0., 0.),
168                btVector3( 0., 0., 0.)
169        };
170       
171        batchedUnitVectorGetSupportingVertexWithoutMargin(_directions, _supporting, 6);
172       
173        for ( int i = 0; i < 3; ++i )
174        {
175                m_localAabbMax[i] = _supporting[i][i] + m_collisionMargin;
176                m_localAabbMin[i] = _supporting[i + 3][i] - m_collisionMargin;
177        }
178       
179        #else
180
181        for (int i=0;i<3;i++)
182        {
183                btVector3 vec(btScalar(0.),btScalar(0.),btScalar(0.));
184                vec[i] = btScalar(1.);
185                btVector3 tmp = localGetSupportingVertex(vec);
186                m_localAabbMax[i] = tmp[i]+m_collisionMargin;
187                vec[i] = btScalar(-1.);
188                tmp = localGetSupportingVertex(vec);
189                m_localAabbMin[i] = tmp[i]-m_collisionMargin;
190        }
191        #endif
192}
193
Note: See TracBrowser for help on using the repository browser.