Bullet Collision Detection & Physics Library
btTetrahedronShape.cpp
Go to the documentation of this file.
1 /*
2 Bullet Continuous Collision Detection and Physics Library
3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org
4 
5 This software is provided 'as-is', without any express or implied warranty.
6 In no event will the authors be held liable for any damages arising from the use of this software.
7 Permission is granted to anyone to use this software for any purpose,
8 including commercial applications, and to alter it and redistribute it freely,
9 subject to the following restrictions:
10 
11 1. 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.
12 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
13 3. This notice may not be removed or altered from any source distribution.
14 */
15 
16 #include "btTetrahedronShape.h"
17 #include "LinearMath/btMatrix3x3.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 
59 void 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 {
79  m_vertices[m_numVertices++] = pt;
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 
109 void btBU_Simplex1to4::getEdge(int i, btVector3& pa, btVector3& pb) const
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 
165 void btBU_Simplex1to4::getVertex(int i, btVector3& vtx) const
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 }
btBU_Simplex1to4::getNumEdges
virtual int getNumEdges() const
Definition: btTetrahedronShape.cpp:88
btBU_Simplex1to4::getNumVertices
virtual int getNumVertices() const
Definition: btTetrahedronShape.cpp:83
btVector3::setValue
void setValue(const btScalar &_x, const btScalar &_y, const btScalar &_z)
Definition: btVector3.h:640
btScalar
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: btScalar.h:294
btTetrahedronShape.h
btMatrix3x3.h
btBU_Simplex1to4::getIndex
virtual int getIndex(int i) const
Definition: btTetrahedronShape.cpp:195
btBU_Simplex1to4::m_numVertices
int m_numVertices
Definition: btTetrahedronShape.h:27
btBU_Simplex1to4::getNumPlanes
virtual int getNumPlanes() const
Definition: btTetrahedronShape.cpp:170
btBU_Simplex1to4::getVertex
virtual void getVertex(int i, btVector3 &vtx) const
Definition: btTetrahedronShape.cpp:165
btBU_Simplex1to4::getPlane
virtual void getPlane(btVector3 &planeNormal, btVector3 &planeSupport, int i) const
Definition: btTetrahedronShape.cpp:191
btCollisionShape::m_shapeType
int m_shapeType
Definition: btCollisionShape.h:30
btBU_Simplex1to4::btBU_Simplex1to4
btBU_Simplex1to4()
Definition: btTetrahedronShape.cpp:19
btBU_Simplex1to4::addVertex
void addVertex(const btVector3 &pt)
Definition: btTetrahedronShape.cpp:77
TETRAHEDRAL_SHAPE_PROXYTYPE
Definition: btBroadphaseProxy.h:32
btPolyhedralConvexAabbCachingShape
The btPolyhedralConvexAabbCachingShape adds aabb caching to the btPolyhedralConvexShape.
Definition: btPolyhedralConvexShape.h:67
BT_LARGE_FLOAT
#define BT_LARGE_FLOAT
Definition: btScalar.h:296
btBU_Simplex1to4::getEdge
virtual void getEdge(int i, btVector3 &pa, btVector3 &pb) const
Definition: btTetrahedronShape.cpp:109
btVector3::setMax
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
btTransform
The btTransform class supports rigid transforms with only translation and rotation and no scaling/she...
Definition: btTransform.h:28
btVector3
btVector3 can be used to represent 3D points and vectors.
Definition: btVector3.h:80
btBU_Simplex1to4::isInside
virtual bool isInside(const btVector3 &pt, btScalar tolerance) const
Definition: btTetrahedronShape.cpp:200
btBU_Simplex1to4::getAabb
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...
Definition: btTetrahedronShape.cpp:59
btPolyhedralConvexAabbCachingShape::recalcLocalAabb
void recalcLocalAabb()
Definition: btPolyhedralConvexShape.cpp:505
btVector3::setMin
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
btBU_Simplex1to4::m_vertices
btVector3 m_vertices[4]
Definition: btTetrahedronShape.h:28
btPolyhedralConvexAabbCachingShape::getAabb
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...
Definition: btPolyhedralConvexShape.cpp:500