Bullet Collision Detection & Physics Library
btTriangleMeshShape.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 "btTriangleMeshShape.h"
22
23
25: btConcaveShape (), m_meshInterface(meshInterface)
26{
28 if(meshInterface->hasPremadeAabb())
29 {
31 }
32 else
33 {
35 }
36}
37
38
40{
41
42}
43
44
45
46
48{
49
53
54 btMatrix3x3 abs_b = trans.getBasis().absolute();
55
56 btVector3 center = trans(localCenter);
57
59 aabbMin = center - extent;
60 aabbMax = center + extent;
61}
62
64{
65 for (int i=0;i<3;i++)
66 {
68 vec[i] = btScalar(1.);
71 vec[i] = btScalar(-1.);
74 }
75}
76
77
78
80{
81
83public:
84
88
91
92 {
94 }
95
97 {
98 (void)partId;
100 for (int i=0;i<3;i++)
101 {
103 if (dot > m_maxDot)
104 {
105 m_maxDot = dot;
107 }
108 }
109 }
110
112 {
114 }
115
117 {
119 }
120
121};
122
123
125{
126 m_meshInterface->setScaling(scaling);
128}
129
131{
132 return m_meshInterface->getScaling();
133}
134
135
136
137
138
139
140//#define DEBUG_TRIANGLE_MESH
141
142
143
145{
147 {
149 btVector3 m_aabbMin;
150 btVector3 m_aabbMax;
151
153 :m_callback(callback),
154 m_aabbMin(aabbMin),
155 m_aabbMax(aabbMax)
156 {
157 }
158
159 virtual void internalProcessTriangleIndex(btVector3* triangle,int partId,int triangleIndex)
160 {
161 if (TestTriangleAgainstAabb2(&triangle[0],m_aabbMin,m_aabbMax))
162 {
163 //check aabb in triangle-space, before doing this
164 m_callback->processTriangle(triangle,partId,triangleIndex);
165 }
166
167 }
168
169 };
170
172
174}
175
176
177
178
179
181{
182 (void)mass;
183 //moving concave objects not supported
184 btAssert(0);
185 inertia.setValue(btScalar(0.),btScalar(0.),btScalar(0.));
186}
187
188
190{
192
195
197
199
201
202 supportVertex = supportCallback.GetSupportVertexLocal();
203
204 return supportVertex;
205}
206
207
bool TestTriangleAgainstAabb2(const btVector3 *vertices, const btVector3 &aabbMin, const btVector3 &aabbMax)
conservative test for overlap between triangle and aabb
Definition btAabbUtil2.h:59
@ TRIANGLE_MESH_SHAPE_PROXYTYPE
const T & btMax(const T &a, const T &b)
Definition btMinMax.h:29
btScalar dot(const btQuaternion &q1, const btQuaternion &q2)
Calculate the dot product between two quaternions.
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
#define btAssert(x)
Definition btScalar.h:131
SupportVertexCallback(const btVector3 &supportVecWorld, const btTransform &trans)
virtual void processTriangle(btVector3 *triangle, int partId, int triangleIndex)
The btConcaveShape class provides an interface for non-moving (static) concave shapes.
virtual btScalar getMargin() const
btScalar m_collisionMargin
The btMatrix3x3 class implements a 3x3 rotation matrix, to perform linear algebra in combination with...
Definition btMatrix3x3.h:48
btMatrix3x3 absolute() const
Return the matrix with all values non negative.
The btStridingMeshInterface is the interface class for high performance generic access to triangle me...
const btVector3 & getScaling() const
void setScaling(const btVector3 &scaling)
virtual void InternalProcessAllTriangles(btInternalTriangleIndexCallback *callback, const btVector3 &aabbMin, const btVector3 &aabbMax) const
The btTransform class supports rigid transforms with only translation and rotation and no scaling/she...
Definition btTransform.h:34
btMatrix3x3 & getBasis()
Return the basis matrix for the rotation.
void setIdentity()
Set this transformation to the identity.
The btTriangleCallback provides a callback for each overlapping triangle when calling processAllTrian...
virtual void getAabb(const btTransform &t, btVector3 &aabbMin, btVector3 &aabbMax) const
getAabb returns the axis aligned bounding box in the coordinate frame of the given transform t.
btTriangleMeshShape(btStridingMeshInterface *meshInterface)
btTriangleMeshShape constructor has been disabled/protected, so that users will not mistakenly use th...
virtual void calculateLocalInertia(btScalar mass, btVector3 &inertia) const
virtual void processAllTriangles(btTriangleCallback *callback, const btVector3 &aabbMin, const btVector3 &aabbMax) const
virtual btVector3 localGetSupportingVertex(const btVector3 &vec) const
virtual void setLocalScaling(const btVector3 &scaling)
btStridingMeshInterface * m_meshInterface
virtual const btVector3 & getLocalScaling() const
btVector3 can be used to represent 3D points and vectors.
Definition btVector3.h:84
btScalar dot(const btVector3 &v) const
Return the dot product.
Definition btVector3.h:235
btVector3 dot3(const btVector3 &v0, const btVector3 &v1, const btVector3 &v2) const
Definition btVector3.h:731