1 | |
---|
2 | /* |
---|
3 | Bullet Continuous Collision Detection and Physics Library |
---|
4 | Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ |
---|
5 | |
---|
6 | This software is provided 'as-is', without any express or implied warranty. |
---|
7 | In no event will the authors be held liable for any damages arising from the use of this software. |
---|
8 | Permission is granted to anyone to use this software for any purpose, |
---|
9 | including commercial applications, and to alter it and redistribute it freely, |
---|
10 | subject to the following restrictions: |
---|
11 | |
---|
12 | 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. |
---|
13 | 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. |
---|
14 | 3. This notice may not be removed or altered from any source distribution. |
---|
15 | */ |
---|
16 | #include "btTetrahedronShape.h" |
---|
17 | #include "LinearMath/btMatrix3x3.h" |
---|
18 | |
---|
19 | btBU_Simplex1to4::btBU_Simplex1to4() : btPolyhedralConvexShape (), |
---|
20 | m_numVertices(0) |
---|
21 | { |
---|
22 | m_shapeType = TETRAHEDRAL_SHAPE_PROXYTYPE; |
---|
23 | } |
---|
24 | |
---|
25 | btBU_Simplex1to4::btBU_Simplex1to4(const btPoint3& pt0) : btPolyhedralConvexShape (), |
---|
26 | m_numVertices(0) |
---|
27 | { |
---|
28 | m_shapeType = TETRAHEDRAL_SHAPE_PROXYTYPE; |
---|
29 | addVertex(pt0); |
---|
30 | } |
---|
31 | |
---|
32 | btBU_Simplex1to4::btBU_Simplex1to4(const btPoint3& pt0,const btPoint3& pt1) : btPolyhedralConvexShape (), |
---|
33 | m_numVertices(0) |
---|
34 | { |
---|
35 | m_shapeType = TETRAHEDRAL_SHAPE_PROXYTYPE; |
---|
36 | addVertex(pt0); |
---|
37 | addVertex(pt1); |
---|
38 | } |
---|
39 | |
---|
40 | btBU_Simplex1to4::btBU_Simplex1to4(const btPoint3& pt0,const btPoint3& pt1,const btPoint3& pt2) : btPolyhedralConvexShape (), |
---|
41 | m_numVertices(0) |
---|
42 | { |
---|
43 | m_shapeType = TETRAHEDRAL_SHAPE_PROXYTYPE; |
---|
44 | addVertex(pt0); |
---|
45 | addVertex(pt1); |
---|
46 | addVertex(pt2); |
---|
47 | } |
---|
48 | |
---|
49 | btBU_Simplex1to4::btBU_Simplex1to4(const btPoint3& pt0,const btPoint3& pt1,const btPoint3& pt2,const btPoint3& pt3) : btPolyhedralConvexShape (), |
---|
50 | m_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 | |
---|
63 | void btBU_Simplex1to4::addVertex(const btPoint3& pt) |
---|
64 | { |
---|
65 | m_vertices[m_numVertices++] = pt; |
---|
66 | |
---|
67 | recalcLocalAabb(); |
---|
68 | } |
---|
69 | |
---|
70 | |
---|
71 | int btBU_Simplex1to4::getNumVertices() const |
---|
72 | { |
---|
73 | return m_numVertices; |
---|
74 | } |
---|
75 | |
---|
76 | int 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 | |
---|
95 | void btBU_Simplex1to4::getEdge(int i,btPoint3& pa,btPoint3& 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 | |
---|
159 | void btBU_Simplex1to4::getVertex(int i,btPoint3& vtx) const |
---|
160 | { |
---|
161 | vtx = m_vertices[i]; |
---|
162 | } |
---|
163 | |
---|
164 | int 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 | |
---|
186 | void btBU_Simplex1to4::getPlane(btVector3&, btPoint3& ,int ) const |
---|
187 | { |
---|
188 | |
---|
189 | } |
---|
190 | |
---|
191 | int btBU_Simplex1to4::getIndex(int ) const |
---|
192 | { |
---|
193 | return 0; |
---|
194 | } |
---|
195 | |
---|
196 | bool btBU_Simplex1to4::isInside(const btPoint3& ,btScalar ) const |
---|
197 | { |
---|
198 | return false; |
---|
199 | } |
---|
200 | |
---|