Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btTetrahedronShape.cpp @ 5738

Last change on this file since 5738 was 5738, checked in by landauf, 15 years ago

merged libraries2 back to trunk

  • Property svn:eol-style set to native
File size: 3.8 KB
Line 
1
2/*
3Bullet Continuous Collision Detection and Physics Library
4Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
5
6This software is provided 'as-is', without any express or implied warranty.
7In no event will the authors be held liable for any damages arising from the use of this software.
8Permission is granted to anyone to use this software for any purpose,
9including commercial applications, and to alter it and redistribute it freely,
10subject to the following restrictions:
11
121. 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.
132. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
143. This notice may not be removed or altered from any source distribution.
15*/
16#include "btTetrahedronShape.h"
17#include "LinearMath/btMatrix3x3.h"
18
19btBU_Simplex1to4::btBU_Simplex1to4() : btPolyhedralConvexShape (),
20m_numVertices(0)
21{
22        m_shapeType = TETRAHEDRAL_SHAPE_PROXYTYPE;
23}
24
25btBU_Simplex1to4::btBU_Simplex1to4(const btVector3& pt0) : btPolyhedralConvexShape (),
26m_numVertices(0)
27{
28        m_shapeType = TETRAHEDRAL_SHAPE_PROXYTYPE;
29        addVertex(pt0);
30}
31
32btBU_Simplex1to4::btBU_Simplex1to4(const btVector3& pt0,const btVector3& pt1) : btPolyhedralConvexShape (),
33m_numVertices(0)
34{
35        m_shapeType = TETRAHEDRAL_SHAPE_PROXYTYPE;
36        addVertex(pt0);
37        addVertex(pt1);
38}
39
40btBU_Simplex1to4::btBU_Simplex1to4(const btVector3& pt0,const btVector3& pt1,const btVector3& pt2) : btPolyhedralConvexShape (),
41m_numVertices(0)
42{
43        m_shapeType = TETRAHEDRAL_SHAPE_PROXYTYPE;
44        addVertex(pt0);
45        addVertex(pt1);
46        addVertex(pt2);
47}
48
49btBU_Simplex1to4::btBU_Simplex1to4(const btVector3& pt0,const btVector3& pt1,const btVector3& pt2,const btVector3& pt3) : btPolyhedralConvexShape (),
50m_numVertices(0)
51{
52        m_shapeType = TETRAHEDRAL_SHAPE_PROXYTYPE;
53        addVertex(pt0);
54        addVertex(pt1);
55        addVertex(pt2);
56        addVertex(pt3);
57}
58
59
60
61
62
63void btBU_Simplex1to4::addVertex(const btVector3& pt)
64{
65        m_vertices[m_numVertices++] = pt;
66
67        recalcLocalAabb();
68}
69
70
71int     btBU_Simplex1to4::getNumVertices() const
72{
73        return m_numVertices;
74}
75
76int btBU_Simplex1to4::getNumEdges() const
77{
78        //euler formula, F-E+V = 2, so E = F+V-2
79
80        switch (m_numVertices)
81        {
82        case 0:
83                return 0;
84        case 1: return 0;
85        case 2: return 1;
86        case 3: return 3;
87        case 4: return 6;
88
89
90        }
91
92        return 0;
93}
94
95void btBU_Simplex1to4::getEdge(int i,btVector3& pa,btVector3& pb) const
96{
97       
98    switch (m_numVertices)
99        {
100
101        case 2: 
102                pa = m_vertices[0];
103                pb = m_vertices[1];
104                break;
105        case 3: 
106                switch (i)
107                {
108                case 0:
109                        pa = m_vertices[0];
110                        pb = m_vertices[1];
111                        break;
112                case 1:
113                        pa = m_vertices[1];
114                        pb = m_vertices[2];
115                        break;
116                case 2:
117                        pa = m_vertices[2];
118                        pb = m_vertices[0];
119                        break;
120
121                }
122                break;
123        case 4: 
124                switch (i)
125                {
126                case 0:
127                        pa = m_vertices[0];
128                        pb = m_vertices[1];
129                        break;
130                case 1:
131                        pa = m_vertices[1];
132                        pb = m_vertices[2];
133                        break;
134                case 2:
135                        pa = m_vertices[2];
136                        pb = m_vertices[0];
137                        break;
138                case 3:
139                        pa = m_vertices[0];
140                        pb = m_vertices[3];
141                        break;
142                case 4:
143                        pa = m_vertices[1];
144                        pb = m_vertices[3];
145                        break;
146                case 5:
147                        pa = m_vertices[2];
148                        pb = m_vertices[3];
149                        break;
150                }
151
152        }
153
154
155
156
157}
158
159void btBU_Simplex1to4::getVertex(int i,btVector3& vtx) const
160{
161        vtx = m_vertices[i];
162}
163
164int     btBU_Simplex1to4::getNumPlanes() const
165{
166        switch (m_numVertices)
167        {
168        case 0:
169                        return 0;
170        case 1:
171                        return 0;
172        case 2:
173                        return 0;
174        case 3:
175                        return 2;
176        case 4:
177                        return 4;
178        default:
179                {
180                }
181        }
182        return 0;
183}
184
185
186void btBU_Simplex1to4::getPlane(btVector3&, btVector3& ,int ) const
187{
188       
189}
190
191int btBU_Simplex1to4::getIndex(int ) const
192{
193        return 0;
194}
195
196bool btBU_Simplex1to4::isInside(const btVector3& ,btScalar ) const
197{
198        return false;
199}
200
Note: See TracBrowser for help on using the repository browser.