Bullet Collision Detection & Physics Library
btTetrahedronShape.cpp
Go to the documentation of this file.
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 "btTetrahedronShape.h"
18
20m_numVertices(0)
21{
23}
24
26m_numVertices(0)
27{
29 addVertex(pt0);
30}
31
33m_numVertices(0)
34{
36 addVertex(pt0);
37 addVertex(pt1);
38}
39
41m_numVertices(0)
42{
44 addVertex(pt0);
45 addVertex(pt1);
46 addVertex(pt2);
47}
48
50m_numVertices(0)
51{
53 addVertex(pt0);
54 addVertex(pt1);
55 addVertex(pt2);
56 addVertex(pt3);
57}
58
59
60void btBU_Simplex1to4::getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const
61{
62#if 1
64#else
67
68 //just transform the vertices in worldspace, and take their AABB
69 for (int i=0;i<m_numVertices;i++)
70 {
71 btVector3 worldVertex = t(m_vertices[i]);
72 aabbMin.setMin(worldVertex);
73 aabbMax.setMax(worldVertex);
74 }
75#endif
76}
77
78
79
80
81
83{
86}
87
88
90{
91 return m_numVertices;
92}
93
95{
96 //euler formula, F-E+V = 2, so E = F+V-2
97
98 switch (m_numVertices)
99 {
100 case 0:
101 return 0;
102 case 1: return 0;
103 case 2: return 1;
104 case 3: return 3;
105 case 4: return 6;
106
107
108 }
109
110 return 0;
111}
112
114{
115
116 switch (m_numVertices)
117 {
118
119 case 2:
120 pa = m_vertices[0];
121 pb = m_vertices[1];
122 break;
123 case 3:
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
139 }
140 break;
141 case 4:
142 switch (i)
143 {
144 case 0:
145 pa = m_vertices[0];
146 pb = m_vertices[1];
147 break;
148 case 1:
149 pa = m_vertices[1];
150 pb = m_vertices[2];
151 break;
152 case 2:
153 pa = m_vertices[2];
154 pb = m_vertices[0];
155 break;
156 case 3:
157 pa = m_vertices[0];
158 pb = m_vertices[3];
159 break;
160 case 4:
161 pa = m_vertices[1];
162 pb = m_vertices[3];
163 break;
164 case 5:
165 pa = m_vertices[2];
166 pb = m_vertices[3];
167 break;
168 }
169
170 }
171
172
173
174
175}
176
178{
179 vtx = m_vertices[i];
180}
181
183{
184 switch (m_numVertices)
185 {
186 case 0:
187 return 0;
188 case 1:
189 return 0;
190 case 2:
191 return 0;
192 case 3:
193 return 2;
194 case 4:
195 return 4;
196 default:
197 {
198 }
199 }
200 return 0;
201}
202
203
205{
206
207}
208
210{
211 return 0;
212}
213
215{
216 return false;
217}
218
@ TETRAHEDRAL_SHAPE_PROXYTYPE
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: btScalar.h:292
#define BT_LARGE_FLOAT
Definition: btScalar.h:294
virtual void getEdge(int i, btVector3 &pa, btVector3 &pb) const
virtual int getNumEdges() const
virtual int getNumVertices() const
virtual void getVertex(int i, btVector3 &vtx) const
btVector3 m_vertices[4]
virtual void getAabb(const btTransform &t, btVector3 &aabbMin, btVector3 &aabbMax) const
getAabb's default implementation is brute force, expected derived classes to implement a fast dedicat...
virtual int getNumPlanes() const
virtual void getPlane(btVector3 &planeNormal, btVector3 &planeSupport, int i) const
void addVertex(const btVector3 &pt)
virtual int getIndex(int i) const
virtual bool isInside(const btVector3 &pt, btScalar tolerance) const
The btPolyhedralConvexAabbCachingShape adds aabb caching to the btPolyhedralConvexShape.
virtual void getAabb(const btTransform &t, btVector3 &aabbMin, btVector3 &aabbMax) const
getAabb's default implementation is brute force, expected derived classes to implement a fast dedicat...
The btTransform class supports rigid transforms with only translation and rotation and no scaling/she...
Definition: btTransform.h:34
btVector3 can be used to represent 3D points and vectors.
Definition: btVector3.h:84
void setMax(const btVector3 &other)
Set each element to the max of the current values and the values of another btVector3.
Definition: btVector3.h:621
void setValue(const btScalar &_x, const btScalar &_y, const btScalar &_z)
Definition: btVector3.h:652
void setMin(const btVector3 &other)
Set each element to the min of the current values and the values of another btVector3.
Definition: btVector3.h:638