Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btTriangleShape.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: 4.4 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 OBB_TRIANGLE_MINKOWSKI_H
17#define OBB_TRIANGLE_MINKOWSKI_H
18
19#include "btConvexShape.h"
20#include "btBoxShape.h"
21
22ATTRIBUTE_ALIGNED16(class) btTriangleShape : public btPolyhedralConvexShape
23{
24
25
26public:
27
28        btVector3       m_vertices1[3];
29
30        virtual int getNumVertices() const
31        {
32                return 3;
33        }
34
35        btVector3& getVertexPtr(int index)
36        {
37                return m_vertices1[index];
38        }
39
40        const btVector3& getVertexPtr(int index) const
41        {
42                return m_vertices1[index];
43        }
44        virtual void getVertex(int index,btVector3& vert) const
45        {
46                vert = m_vertices1[index];
47        }
48
49        virtual int getNumEdges() const
50        {
51                return 3;
52        }
53       
54        virtual void getEdge(int i,btVector3& pa,btVector3& pb) const
55        {
56                getVertex(i,pa);
57                getVertex((i+1)%3,pb);
58        }
59
60
61        virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax)const 
62        {
63//              btAssert(0);
64                getAabbSlow(t,aabbMin,aabbMax);
65        }
66
67        btVector3 localGetSupportingVertexWithoutMargin(const btVector3& dir)const 
68        {
69                btVector3 dots(dir.dot(m_vertices1[0]), dir.dot(m_vertices1[1]), dir.dot(m_vertices1[2]));
70                return m_vertices1[dots.maxAxis()];
71
72        }
73
74        virtual void    batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const
75        {
76                for (int i=0;i<numVectors;i++)
77                {
78                        const btVector3& dir = vectors[i];
79                        btVector3 dots(dir.dot(m_vertices1[0]), dir.dot(m_vertices1[1]), dir.dot(m_vertices1[2]));
80                        supportVerticesOut[i] = m_vertices1[dots.maxAxis()];
81                }
82
83        }
84
85        btTriangleShape() : btPolyhedralConvexShape ()
86    {
87                m_shapeType = TRIANGLE_SHAPE_PROXYTYPE;
88        }
89
90        btTriangleShape(const btVector3& p0,const btVector3& p1,const btVector3& p2) : btPolyhedralConvexShape ()
91    {
92                m_shapeType = TRIANGLE_SHAPE_PROXYTYPE;
93        m_vertices1[0] = p0;
94        m_vertices1[1] = p1;
95        m_vertices1[2] = p2;
96    }
97
98
99        virtual void getPlane(btVector3& planeNormal,btVector3& planeSupport,int i) const
100        {
101                getPlaneEquation(i,planeNormal,planeSupport);
102        }
103
104        virtual int     getNumPlanes() const
105        {
106                return 1;
107        }
108
109        void calcNormal(btVector3& normal) const
110        {
111                normal = (m_vertices1[1]-m_vertices1[0]).cross(m_vertices1[2]-m_vertices1[0]);
112                normal.normalize();
113        }
114
115        virtual void getPlaneEquation(int i, btVector3& planeNormal,btVector3& planeSupport) const
116        {
117                (void)i;
118                calcNormal(planeNormal);
119                planeSupport = m_vertices1[0];
120        }
121
122        virtual void    calculateLocalInertia(btScalar mass,btVector3& inertia) const
123        {
124                (void)mass;
125                btAssert(0);
126                inertia.setValue(btScalar(0.),btScalar(0.),btScalar(0.));
127        }
128
129                virtual bool isInside(const btVector3& pt,btScalar tolerance) const
130        {
131                btVector3 normal;
132                calcNormal(normal);
133                //distance to plane
134                btScalar dist = pt.dot(normal);
135                btScalar planeconst = m_vertices1[0].dot(normal);
136                dist -= planeconst;
137                if (dist >= -tolerance && dist <= tolerance)
138                {
139                        //inside check on edge-planes
140                        int i;
141                        for (i=0;i<3;i++)
142                        {
143                                btVector3 pa,pb;
144                                getEdge(i,pa,pb);
145                                btVector3 edge = pb-pa;
146                                btVector3 edgeNormal = edge.cross(normal);
147                                edgeNormal.normalize();
148                                btScalar dist = pt.dot( edgeNormal);
149                                btScalar edgeConst = pa.dot(edgeNormal);
150                                dist -= edgeConst;
151                                if (dist < -tolerance)
152                                        return false;
153                        }
154                       
155                        return true;
156                }
157
158                return false;
159        }
160                //debugging
161                virtual const char*     getName()const
162                {
163                        return "Triangle";
164                }
165
166                virtual int             getNumPreferredPenetrationDirections() const
167                {
168                        return 2;
169                }
170               
171                virtual void    getPreferredPenetrationDirection(int index, btVector3& penetrationVector) const
172                {
173                        calcNormal(penetrationVector);
174                        if (index)
175                                penetrationVector *= btScalar(-1.);
176                }
177
178
179};
180
181#endif //OBB_TRIANGLE_MINKOWSKI_H
182
Note: See TracBrowser for help on using the repository browser.