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
20 m_numVertices(0)
21{
23}
24
26 m_numVertices(0)
27{
29 addVertex(pt0);
30}
31
33 m_numVertices(0)
34{
36 addVertex(pt0);
37 addVertex(pt1);
38}
39
41 m_numVertices(0)
42{
44 addVertex(pt0);
45 addVertex(pt1);
46 addVertex(pt2);
47}
48
50 m_numVertices(0)
51{
53 addVertex(pt0);
54 addVertex(pt1);
55 addVertex(pt2);
56 addVertex(pt3);
57}
58
59void btBU_Simplex1to4::getAabb(const btTransform& t, btVector3& aabbMin, btVector3& aabbMax) const
60{
61#if 1
63#else
66
67 //just transform the vertices in worldspace, and take their AABB
68 for (int i = 0; i < m_numVertices; i++)
69 {
70 btVector3 worldVertex = t(m_vertices[i]);
71 aabbMin.setMin(worldVertex);
72 aabbMax.setMax(worldVertex);
73 }
74#endif
75}
76
78{
81}
82
84{
85 return m_numVertices;
86}
87
89{
90 //euler formula, F-E+V = 2, so E = F+V-2
91
92 switch (m_numVertices)
93 {
94 case 0:
95 return 0;
96 case 1:
97 return 0;
98 case 2:
99 return 1;
100 case 3:
101 return 3;
102 case 4:
103 return 6;
104 }
105
106 return 0;
107}
108
110{
111 switch (m_numVertices)
112 {
113 case 2:
114 pa = m_vertices[0];
115 pb = m_vertices[1];
116 break;
117 case 3:
118 switch (i)
119 {
120 case 0:
121 pa = m_vertices[0];
122 pb = m_vertices[1];
123 break;
124 case 1:
125 pa = m_vertices[1];
126 pb = m_vertices[2];
127 break;
128 case 2:
129 pa = m_vertices[2];
130 pb = m_vertices[0];
131 break;
132 }
133 break;
134 case 4:
135 switch (i)
136 {
137 case 0:
138 pa = m_vertices[0];
139 pb = m_vertices[1];
140 break;
141 case 1:
142 pa = m_vertices[1];
143 pb = m_vertices[2];
144 break;
145 case 2:
146 pa = m_vertices[2];
147 pb = m_vertices[0];
148 break;
149 case 3:
150 pa = m_vertices[0];
151 pb = m_vertices[3];
152 break;
153 case 4:
154 pa = m_vertices[1];
155 pb = m_vertices[3];
156 break;
157 case 5:
158 pa = m_vertices[2];
159 pb = m_vertices[3];
160 break;
161 }
162 }
163}
164
166{
167 vtx = m_vertices[i];
168}
169
171{
172 switch (m_numVertices)
173 {
174 case 0:
175 return 0;
176 case 1:
177 return 0;
178 case 2:
179 return 0;
180 case 3:
181 return 2;
182 case 4:
183 return 4;
184 default:
185 {
186 }
187 }
188 return 0;
189}
190
192{
193}
194
196{
197 return 0;
198}
199
201{
202 return false;
203}
@ TETRAHEDRAL_SHAPE_PROXYTYPE
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: btScalar.h:314
#define BT_LARGE_FLOAT
Definition: btScalar.h:316
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:30
btVector3 can be used to represent 3D points and vectors.
Definition: btVector3.h:82
void setMax(const btVector3 &other)
Set each element to the max of the current values and the values of another btVector3.
Definition: btVector3.h:609
void setValue(const btScalar &_x, const btScalar &_y, const btScalar &_z)
Definition: btVector3.h:640
void setMin(const btVector3 &other)
Set each element to the min of the current values and the values of another btVector3.
Definition: btVector3.h:626