Apple contribution for OSX SSE and iOS NEON optimizations unit tests, thanks to Jordan Hubbard, Ian Ollmann and Hristo Hristov.
For OSX: cd build ./premake_osx xcode4 for iOS: cd build ./ios_build.sh ./ios_run.sh Also integrated the branches/StackAllocation to make it easier to multi-thread collision detection in the near future. It avoids changing the btCollisionObject while performing collision detection. As this is a large patch, some stuff might be temporarily broken, I'll keep an eye out on issues.
This commit is contained in:
@@ -23,7 +23,7 @@ subject to the following restrictions:
|
||||
#include "LinearMath/btMinMax.h"
|
||||
|
||||
///The btBox2dShape is a box primitive around the origin, its sides axis aligned with length specified by half extents, in local shape coordinates. When used as part of a btCollisionObject or btRigidBody it will be an oriented box in world space.
|
||||
class btBox2dShape: public btPolyhedralConvexShape
|
||||
ATTRIBUTE_ALIGNED16(class) btBox2dShape: public btPolyhedralConvexShape
|
||||
{
|
||||
|
||||
//btVector3 m_boxHalfExtents1; //use m_implicitShapeDimensions instead
|
||||
@@ -34,6 +34,8 @@ class btBox2dShape: public btPolyhedralConvexShape
|
||||
|
||||
public:
|
||||
|
||||
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||
|
||||
btVector3 getHalfExtentsWithMargin() const
|
||||
{
|
||||
btVector3 halfExtents = getHalfExtentsWithoutMargin();
|
||||
|
||||
@@ -23,7 +23,7 @@ subject to the following restrictions:
|
||||
#include "LinearMath/btMinMax.h"
|
||||
|
||||
///The btBoxShape is a box primitive around the origin, its sides axis aligned with length specified by half extents, in local shape coordinates. When used as part of a btCollisionObject or btRigidBody it will be an oriented box in world space.
|
||||
class btBoxShape: public btPolyhedralConvexShape
|
||||
ATTRIBUTE_ALIGNED16(class) btBoxShape: public btPolyhedralConvexShape
|
||||
{
|
||||
|
||||
//btVector3 m_boxHalfExtents1; //use m_implicitShapeDimensions instead
|
||||
@@ -31,6 +31,8 @@ class btBoxShape: public btPolyhedralConvexShape
|
||||
|
||||
public:
|
||||
|
||||
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||
|
||||
btVector3 getHalfExtentsWithMargin() const
|
||||
{
|
||||
btVector3 halfExtents = getHalfExtentsWithoutMargin();
|
||||
|
||||
@@ -23,7 +23,7 @@ subject to the following restrictions:
|
||||
///The btCapsuleShape represents a capsule around the Y axis, there is also the btCapsuleShapeX aligned around the X axis and btCapsuleShapeZ around the Z axis.
|
||||
///The total height is height+2*radius, so the height is just the height between the center of each 'sphere' of the capsule caps.
|
||||
///The btCapsuleShape is a convex hull of two spheres. The btMultiSphereShape is a more general collision shape that takes the convex hull of multiple sphere, so it can also represent a capsule when just using two spheres.
|
||||
class btCapsuleShape : public btConvexInternalShape
|
||||
ATTRIBUTE_ALIGNED16(class) btCapsuleShape : public btConvexInternalShape
|
||||
{
|
||||
protected:
|
||||
int m_upAxis;
|
||||
@@ -33,6 +33,9 @@ protected:
|
||||
btCapsuleShape() : btConvexInternalShape() {m_shapeType = CAPSULE_SHAPE_PROXYTYPE;};
|
||||
|
||||
public:
|
||||
|
||||
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||
|
||||
btCapsuleShape(btScalar radius,btScalar height);
|
||||
|
||||
///CollisionShape Interface
|
||||
@@ -62,8 +65,8 @@ public:
|
||||
halfExtents += btVector3(getMargin(),getMargin(),getMargin());
|
||||
btMatrix3x3 abs_b = t.getBasis().absolute();
|
||||
btVector3 center = t.getOrigin();
|
||||
btVector3 extent = btVector3(abs_b[0].dot(halfExtents),abs_b[1].dot(halfExtents),abs_b[2].dot(halfExtents));
|
||||
|
||||
btVector3 extent = halfExtents.dot3(abs_b[0], abs_b[1], abs_b[2]);
|
||||
|
||||
aabbMin = center - extent;
|
||||
aabbMax = center + extent;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ class btSerializer;
|
||||
|
||||
|
||||
///The btCollisionShape class provides an interface for collision shapes that can be shared among btCollisionObjects.
|
||||
class btCollisionShape
|
||||
ATTRIBUTE_ALIGNED16(class) btCollisionShape
|
||||
{
|
||||
protected:
|
||||
int m_shapeType;
|
||||
@@ -32,6 +32,8 @@ protected:
|
||||
|
||||
public:
|
||||
|
||||
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||
|
||||
btCollisionShape() : m_shapeType (INVALID_SHAPE_PROXYTYPE), m_userPointer(0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -182,9 +182,7 @@ void btCompoundShape::getAabb(const btTransform& trans,btVector3& aabbMin,btVect
|
||||
|
||||
btVector3 center = trans(localCenter);
|
||||
|
||||
btVector3 extent = btVector3(abs_b[0].dot(localHalfExtents),
|
||||
abs_b[1].dot(localHalfExtents),
|
||||
abs_b[2].dot(localHalfExtents));
|
||||
btVector3 extent = localHalfExtents.dot3(abs_b[0], abs_b[1], abs_b[2]);
|
||||
aabbMin = center-extent;
|
||||
aabbMax = center+extent;
|
||||
|
||||
|
||||
@@ -33,12 +33,14 @@ typedef enum PHY_ScalarType {
|
||||
|
||||
///The btConcaveShape class provides an interface for non-moving (static) concave shapes.
|
||||
///It has been implemented by the btStaticPlaneShape, btBvhTriangleMeshShape and btHeightfieldTerrainShape.
|
||||
class btConcaveShape : public btCollisionShape
|
||||
ATTRIBUTE_ALIGNED16(class) btConcaveShape : public btCollisionShape
|
||||
{
|
||||
protected:
|
||||
btScalar m_collisionMargin;
|
||||
|
||||
public:
|
||||
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||
|
||||
btConcaveShape();
|
||||
|
||||
virtual ~btConcaveShape();
|
||||
|
||||
@@ -20,7 +20,7 @@ subject to the following restrictions:
|
||||
#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" // for the types
|
||||
|
||||
///The btConeShape implements a cone shape primitive, centered around the origin and aligned with the Y axis. The btConeShapeX is aligned around the X axis and btConeShapeZ around the Z axis.
|
||||
class btConeShape : public btConvexInternalShape
|
||||
ATTRIBUTE_ALIGNED16(class) btConeShape : public btConvexInternalShape
|
||||
|
||||
{
|
||||
|
||||
@@ -32,6 +32,8 @@ class btConeShape : public btConvexInternalShape
|
||||
|
||||
|
||||
public:
|
||||
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||
|
||||
btConeShape (btScalar radius,btScalar height);
|
||||
|
||||
virtual btVector3 localGetSupportingVertex(const btVector3& vec) const;
|
||||
|
||||
@@ -21,12 +21,14 @@ subject to the following restrictions:
|
||||
|
||||
///The btConvex2dShape allows to use arbitrary convex shapes as 2d convex shapes, with the Z component assumed to be 0.
|
||||
///For 2d boxes, the btBox2dShape is recommended.
|
||||
class btConvex2dShape : public btConvexShape
|
||||
ATTRIBUTE_ALIGNED16(class) btConvex2dShape : public btConvexShape
|
||||
{
|
||||
btConvexShape* m_childConvexShape;
|
||||
|
||||
public:
|
||||
|
||||
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||
|
||||
btConvex2dShape( btConvexShape* convexChildShape);
|
||||
|
||||
virtual ~btConvex2dShape();
|
||||
|
||||
@@ -55,20 +55,17 @@ void btConvexHullShape::addPoint(const btVector3& point)
|
||||
btVector3 btConvexHullShape::localGetSupportingVertexWithoutMargin(const btVector3& vec)const
|
||||
{
|
||||
btVector3 supVec(btScalar(0.),btScalar(0.),btScalar(0.));
|
||||
btScalar newDot,maxDot = btScalar(-BT_LARGE_FLOAT);
|
||||
btScalar maxDot = btScalar(-BT_LARGE_FLOAT);
|
||||
|
||||
for (int i=0;i<m_unscaledPoints.size();i++)
|
||||
{
|
||||
btVector3 vtx = m_unscaledPoints[i] * m_localScaling;
|
||||
// Here we take advantage of dot(a, b*c) = dot(a*b, c). Note: This is true mathematically, but not numerically.
|
||||
if( 0 < m_unscaledPoints.size() )
|
||||
{
|
||||
btVector3 scaled = vec * m_localScaling;
|
||||
int index = (int) scaled.maxDot( &m_unscaledPoints[0], m_unscaledPoints.size(), maxDot); // FIXME: may violate encapsulation of m_unscaledPoints
|
||||
return m_unscaledPoints[index] * m_localScaling;
|
||||
}
|
||||
|
||||
newDot = vec.dot(vtx);
|
||||
if (newDot > maxDot)
|
||||
{
|
||||
maxDot = newDot;
|
||||
supVec = vtx;
|
||||
}
|
||||
}
|
||||
return supVec;
|
||||
return supVec;
|
||||
}
|
||||
|
||||
void btConvexHullShape::batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const
|
||||
@@ -81,23 +78,19 @@ void btConvexHullShape::batchedUnitVectorGetSupportingVertexWithoutMargin(const
|
||||
supportVerticesOut[i][3] = btScalar(-BT_LARGE_FLOAT);
|
||||
}
|
||||
}
|
||||
for (int i=0;i<m_unscaledPoints.size();i++)
|
||||
{
|
||||
btVector3 vtx = getScaledPoint(i);
|
||||
|
||||
for (int j=0;j<numVectors;j++)
|
||||
{
|
||||
const btVector3& vec = vectors[j];
|
||||
|
||||
newDot = vec.dot(vtx);
|
||||
if (newDot > supportVerticesOut[j][3])
|
||||
{
|
||||
//WARNING: don't swap next lines, the w component would get overwritten!
|
||||
supportVerticesOut[j] = vtx;
|
||||
supportVerticesOut[j][3] = newDot;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int j=0;j<numVectors;j++)
|
||||
{
|
||||
btVector3 vec = vectors[j] * m_localScaling; // dot(a*b,c) = dot(a,b*c)
|
||||
if( 0 < m_unscaledPoints.size() )
|
||||
{
|
||||
int i = (int) vec.maxDot( &m_unscaledPoints[0], m_unscaledPoints.size(), newDot);
|
||||
supportVerticesOut[j] = getScaledPoint(i);
|
||||
supportVerticesOut[j][3] = newDot;
|
||||
}
|
||||
else
|
||||
supportVerticesOut[j][3] = -BT_LARGE_FLOAT;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ subject to the following restrictions:
|
||||
///Note that when creating small shapes (derived from btConvexInternalShape),
|
||||
///you need to make sure to set a smaller collision margin, using the 'setMargin' API
|
||||
///There is a automatic mechanism 'setSafeMargin' used by btBoxShape and btCylinderShape
|
||||
class btConvexInternalShape : public btConvexShape
|
||||
ATTRIBUTE_ALIGNED16(class) btConvexInternalShape : public btConvexShape
|
||||
{
|
||||
|
||||
protected:
|
||||
@@ -44,7 +44,7 @@ class btConvexInternalShape : public btConvexShape
|
||||
|
||||
public:
|
||||
|
||||
|
||||
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||
|
||||
virtual ~btConvexInternalShape()
|
||||
{
|
||||
|
||||
@@ -28,7 +28,7 @@ void btConvexPointCloudShape::setLocalScaling(const btVector3& scaling)
|
||||
btVector3 btConvexPointCloudShape::localGetSupportingVertexWithoutMargin(const btVector3& vec0)const
|
||||
{
|
||||
btVector3 supVec(btScalar(0.),btScalar(0.),btScalar(0.));
|
||||
btScalar newDot,maxDot = btScalar(-BT_LARGE_FLOAT);
|
||||
btScalar maxDot = btScalar(-BT_LARGE_FLOAT);
|
||||
|
||||
btVector3 vec = vec0;
|
||||
btScalar lenSqr = vec.length2();
|
||||
@@ -40,51 +40,33 @@ btVector3 btConvexPointCloudShape::localGetSupportingVertexWithoutMargin(const b
|
||||
btScalar rlen = btScalar(1.) / btSqrt(lenSqr );
|
||||
vec *= rlen;
|
||||
}
|
||||
|
||||
if( m_numPoints > 0 )
|
||||
{
|
||||
// Here we take advantage of dot(a*b, c) = dot( a, b*c) to do less work. Note this transformation is true mathematically, not numerically.
|
||||
btVector3 scaled = vec * m_localScaling;
|
||||
int index = (int) vec.maxDot( &m_unscaledPoints[0], m_numPoints, maxDot); //FIXME: may violate encapsulation of m_unscaledPoints
|
||||
return getScaledPoint(index);
|
||||
}
|
||||
|
||||
|
||||
for (int i=0;i<m_numPoints;i++)
|
||||
{
|
||||
btVector3 vtx = getScaledPoint(i);
|
||||
|
||||
newDot = vec.dot(vtx);
|
||||
if (newDot > maxDot)
|
||||
{
|
||||
maxDot = newDot;
|
||||
supVec = vtx;
|
||||
}
|
||||
}
|
||||
return supVec;
|
||||
}
|
||||
|
||||
void btConvexPointCloudShape::batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const
|
||||
{
|
||||
btScalar newDot;
|
||||
//use 'w' component of supportVerticesOut?
|
||||
{
|
||||
for (int i=0;i<numVectors;i++)
|
||||
{
|
||||
supportVerticesOut[i][3] = btScalar(-BT_LARGE_FLOAT);
|
||||
}
|
||||
}
|
||||
for (int i=0;i<m_numPoints;i++)
|
||||
{
|
||||
btVector3 vtx = getScaledPoint(i);
|
||||
|
||||
for (int j=0;j<numVectors;j++)
|
||||
{
|
||||
const btVector3& vec = vectors[j];
|
||||
|
||||
newDot = vec.dot(vtx);
|
||||
if (newDot > supportVerticesOut[j][3])
|
||||
{
|
||||
//WARNING: don't swap next lines, the w component would get overwritten!
|
||||
supportVerticesOut[j] = vtx;
|
||||
supportVerticesOut[j][3] = newDot;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for( int j = 0; j < numVectors; j++ )
|
||||
{
|
||||
const btVector3& vec = vectors[j] * m_localScaling; // dot( a*c, b) = dot(a, b*c)
|
||||
btScalar maxDot;
|
||||
int index = (int) vec.maxDot( &m_unscaledPoints[0], m_numPoints, maxDot);
|
||||
supportVerticesOut[j][3] = btScalar(-BT_LARGE_FLOAT);
|
||||
if( 0 <= index )
|
||||
{
|
||||
//WARNING: don't swap next lines, the w component would get overwritten!
|
||||
supportVerticesOut[j] = getScaledPoint(index);
|
||||
supportVerticesOut[j][3] = maxDot;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,296 +1,296 @@
|
||||
/*
|
||||
Bullet Continuous Collision Detection and Physics Library
|
||||
Copyright (c) 2011 Advanced Micro Devices, Inc. http://bulletphysics.org
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it freely,
|
||||
subject to the following restrictions:
|
||||
|
||||
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.
|
||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
|
||||
///This file was written by Erwin Coumans
|
||||
///Separating axis rest based on work from Pierre Terdiman, see
|
||||
///And contact clipping based on work from Simon Hobbs
|
||||
|
||||
#include "btConvexPolyhedron.h"
|
||||
#include "LinearMath/btHashMap.h"
|
||||
|
||||
btConvexPolyhedron::btConvexPolyhedron()
|
||||
{
|
||||
|
||||
}
|
||||
btConvexPolyhedron::~btConvexPolyhedron()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
inline bool IsAlmostZero(const btVector3& v)
|
||||
{
|
||||
if(fabsf(v.x())>1e-6 || fabsf(v.y())>1e-6 || fabsf(v.z())>1e-6) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
struct btInternalVertexPair
|
||||
{
|
||||
btInternalVertexPair(short int v0,short int v1)
|
||||
:m_v0(v0),
|
||||
m_v1(v1)
|
||||
{
|
||||
if (m_v1>m_v0)
|
||||
btSwap(m_v0,m_v1);
|
||||
}
|
||||
short int m_v0;
|
||||
short int m_v1;
|
||||
int getHash() const
|
||||
{
|
||||
return m_v0+(m_v1<<16);
|
||||
}
|
||||
bool equals(const btInternalVertexPair& other) const
|
||||
{
|
||||
return m_v0==other.m_v0 && m_v1==other.m_v1;
|
||||
}
|
||||
};
|
||||
|
||||
struct btInternalEdge
|
||||
{
|
||||
btInternalEdge()
|
||||
:m_face0(-1),
|
||||
m_face1(-1)
|
||||
{
|
||||
}
|
||||
short int m_face0;
|
||||
short int m_face1;
|
||||
};
|
||||
|
||||
//
|
||||
|
||||
#ifdef TEST_INTERNAL_OBJECTS
|
||||
bool btConvexPolyhedron::testContainment() const
|
||||
{
|
||||
for(int p=0;p<8;p++)
|
||||
{
|
||||
btVector3 LocalPt;
|
||||
if(p==0) LocalPt = m_localCenter + btVector3(m_extents[0], m_extents[1], m_extents[2]);
|
||||
else if(p==1) LocalPt = m_localCenter + btVector3(m_extents[0], m_extents[1], -m_extents[2]);
|
||||
else if(p==2) LocalPt = m_localCenter + btVector3(m_extents[0], -m_extents[1], m_extents[2]);
|
||||
else if(p==3) LocalPt = m_localCenter + btVector3(m_extents[0], -m_extents[1], -m_extents[2]);
|
||||
else if(p==4) LocalPt = m_localCenter + btVector3(-m_extents[0], m_extents[1], m_extents[2]);
|
||||
else if(p==5) LocalPt = m_localCenter + btVector3(-m_extents[0], m_extents[1], -m_extents[2]);
|
||||
else if(p==6) LocalPt = m_localCenter + btVector3(-m_extents[0], -m_extents[1], m_extents[2]);
|
||||
else if(p==7) LocalPt = m_localCenter + btVector3(-m_extents[0], -m_extents[1], -m_extents[2]);
|
||||
|
||||
for(int i=0;i<m_faces.size();i++)
|
||||
{
|
||||
const btVector3 Normal(m_faces[i].m_plane[0], m_faces[i].m_plane[1], m_faces[i].m_plane[2]);
|
||||
const btScalar d = LocalPt.dot(Normal) + m_faces[i].m_plane[3];
|
||||
if(d>0.0f)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
void btConvexPolyhedron::initialize()
|
||||
{
|
||||
|
||||
btHashMap<btInternalVertexPair,btInternalEdge> edges;
|
||||
|
||||
btScalar TotalArea = 0.0f;
|
||||
|
||||
m_localCenter.setValue(0, 0, 0);
|
||||
for(int i=0;i<m_faces.size();i++)
|
||||
{
|
||||
int numVertices = m_faces[i].m_indices.size();
|
||||
int NbTris = numVertices;
|
||||
for(int j=0;j<NbTris;j++)
|
||||
{
|
||||
int k = (j+1)%numVertices;
|
||||
btInternalVertexPair vp(m_faces[i].m_indices[j],m_faces[i].m_indices[k]);
|
||||
btInternalEdge* edptr = edges.find(vp);
|
||||
btVector3 edge = m_vertices[vp.m_v1]-m_vertices[vp.m_v0];
|
||||
edge.normalize();
|
||||
|
||||
bool found = false;
|
||||
|
||||
for (int p=0;p<m_uniqueEdges.size();p++)
|
||||
{
|
||||
|
||||
if (IsAlmostZero(m_uniqueEdges[p]-edge) ||
|
||||
IsAlmostZero(m_uniqueEdges[p]+edge))
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
{
|
||||
m_uniqueEdges.push_back(edge);
|
||||
}
|
||||
|
||||
if (edptr)
|
||||
{
|
||||
btAssert(edptr->m_face0>=0);
|
||||
btAssert(edptr->m_face1<0);
|
||||
edptr->m_face1 = i;
|
||||
} else
|
||||
{
|
||||
btInternalEdge ed;
|
||||
ed.m_face0 = i;
|
||||
edges.insert(vp,ed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef USE_CONNECTED_FACES
|
||||
for(int i=0;i<m_faces.size();i++)
|
||||
{
|
||||
int numVertices = m_faces[i].m_indices.size();
|
||||
m_faces[i].m_connectedFaces.resize(numVertices);
|
||||
|
||||
for(int j=0;j<numVertices;j++)
|
||||
{
|
||||
int k = (j+1)%numVertices;
|
||||
btInternalVertexPair vp(m_faces[i].m_indices[j],m_faces[i].m_indices[k]);
|
||||
btInternalEdge* edptr = edges.find(vp);
|
||||
btAssert(edptr);
|
||||
btAssert(edptr->m_face0>=0);
|
||||
btAssert(edptr->m_face1>=0);
|
||||
|
||||
int connectedFace = (edptr->m_face0==i)?edptr->m_face1:edptr->m_face0;
|
||||
m_faces[i].m_connectedFaces[j] = connectedFace;
|
||||
}
|
||||
}
|
||||
#endif//USE_CONNECTED_FACES
|
||||
|
||||
for(int i=0;i<m_faces.size();i++)
|
||||
{
|
||||
int numVertices = m_faces[i].m_indices.size();
|
||||
int NbTris = numVertices-2;
|
||||
|
||||
const btVector3& p0 = m_vertices[m_faces[i].m_indices[0]];
|
||||
for(int j=1;j<=NbTris;j++)
|
||||
{
|
||||
int k = (j+1)%numVertices;
|
||||
const btVector3& p1 = m_vertices[m_faces[i].m_indices[j]];
|
||||
const btVector3& p2 = m_vertices[m_faces[i].m_indices[k]];
|
||||
btScalar Area = ((p0 - p1).cross(p0 - p2)).length() * 0.5f;
|
||||
btVector3 Center = (p0+p1+p2)/3.0f;
|
||||
m_localCenter += Area * Center;
|
||||
TotalArea += Area;
|
||||
}
|
||||
}
|
||||
m_localCenter /= TotalArea;
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef TEST_INTERNAL_OBJECTS
|
||||
if(1)
|
||||
{
|
||||
m_radius = FLT_MAX;
|
||||
for(int i=0;i<m_faces.size();i++)
|
||||
{
|
||||
const btVector3 Normal(m_faces[i].m_plane[0], m_faces[i].m_plane[1], m_faces[i].m_plane[2]);
|
||||
const btScalar dist = btFabs(m_localCenter.dot(Normal) + m_faces[i].m_plane[3]);
|
||||
if(dist<m_radius)
|
||||
m_radius = dist;
|
||||
}
|
||||
|
||||
|
||||
btScalar MinX = FLT_MAX;
|
||||
btScalar MinY = FLT_MAX;
|
||||
btScalar MinZ = FLT_MAX;
|
||||
btScalar MaxX = -FLT_MAX;
|
||||
btScalar MaxY = -FLT_MAX;
|
||||
btScalar MaxZ = -FLT_MAX;
|
||||
for(int i=0; i<m_vertices.size(); i++)
|
||||
{
|
||||
const btVector3& pt = m_vertices[i];
|
||||
if(pt.x()<MinX) MinX = pt.x();
|
||||
if(pt.x()>MaxX) MaxX = pt.x();
|
||||
if(pt.y()<MinY) MinY = pt.y();
|
||||
if(pt.y()>MaxY) MaxY = pt.y();
|
||||
if(pt.z()<MinZ) MinZ = pt.z();
|
||||
if(pt.z()>MaxZ) MaxZ = pt.z();
|
||||
}
|
||||
mC.setValue(MaxX+MinX, MaxY+MinY, MaxZ+MinZ);
|
||||
mE.setValue(MaxX-MinX, MaxY-MinY, MaxZ-MinZ);
|
||||
|
||||
|
||||
|
||||
// const btScalar r = m_radius / sqrtf(2.0f);
|
||||
const btScalar r = m_radius / sqrtf(3.0f);
|
||||
const int LargestExtent = mE.maxAxis();
|
||||
const btScalar Step = (mE[LargestExtent]*0.5f - r)/1024.0f;
|
||||
m_extents[0] = m_extents[1] = m_extents[2] = r;
|
||||
m_extents[LargestExtent] = mE[LargestExtent]*0.5f;
|
||||
bool FoundBox = false;
|
||||
for(int j=0;j<1024;j++)
|
||||
{
|
||||
if(testContainment())
|
||||
{
|
||||
FoundBox = true;
|
||||
break;
|
||||
}
|
||||
|
||||
m_extents[LargestExtent] -= Step;
|
||||
}
|
||||
if(!FoundBox)
|
||||
{
|
||||
m_extents[0] = m_extents[1] = m_extents[2] = r;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Refine the box
|
||||
const btScalar Step = (m_radius - r)/1024.0f;
|
||||
const int e0 = (1<<LargestExtent) & 3;
|
||||
const int e1 = (1<<e0) & 3;
|
||||
|
||||
for(int j=0;j<1024;j++)
|
||||
{
|
||||
const btScalar Saved0 = m_extents[e0];
|
||||
const btScalar Saved1 = m_extents[e1];
|
||||
m_extents[e0] += Step;
|
||||
m_extents[e1] += Step;
|
||||
|
||||
if(!testContainment())
|
||||
{
|
||||
m_extents[e0] = Saved0;
|
||||
m_extents[e1] = Saved1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void btConvexPolyhedron::project(const btTransform& trans, const btVector3& dir, btScalar& min, btScalar& max) const
|
||||
{
|
||||
min = FLT_MAX;
|
||||
max = -FLT_MAX;
|
||||
int numVerts = m_vertices.size();
|
||||
for(int i=0;i<numVerts;i++)
|
||||
{
|
||||
btVector3 pt = trans * m_vertices[i];
|
||||
btScalar dp = pt.dot(dir);
|
||||
if(dp < min) min = dp;
|
||||
if(dp > max) max = dp;
|
||||
}
|
||||
if(min>max)
|
||||
{
|
||||
btScalar tmp = min;
|
||||
min = max;
|
||||
max = tmp;
|
||||
}
|
||||
}
|
||||
/*
|
||||
Bullet Continuous Collision Detection and Physics Library
|
||||
Copyright (c) 2011 Advanced Micro Devices, Inc. http://bulletphysics.org
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it freely,
|
||||
subject to the following restrictions:
|
||||
|
||||
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.
|
||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
|
||||
///This file was written by Erwin Coumans
|
||||
///Separating axis rest based on work from Pierre Terdiman, see
|
||||
///And contact clipping based on work from Simon Hobbs
|
||||
|
||||
#include "btConvexPolyhedron.h"
|
||||
#include "LinearMath/btHashMap.h"
|
||||
|
||||
btConvexPolyhedron::btConvexPolyhedron()
|
||||
{
|
||||
|
||||
}
|
||||
btConvexPolyhedron::~btConvexPolyhedron()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
inline bool IsAlmostZero(const btVector3& v)
|
||||
{
|
||||
if(fabsf(v.x())>1e-6 || fabsf(v.y())>1e-6 || fabsf(v.z())>1e-6) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
struct btInternalVertexPair
|
||||
{
|
||||
btInternalVertexPair(short int v0,short int v1)
|
||||
:m_v0(v0),
|
||||
m_v1(v1)
|
||||
{
|
||||
if (m_v1>m_v0)
|
||||
btSwap(m_v0,m_v1);
|
||||
}
|
||||
short int m_v0;
|
||||
short int m_v1;
|
||||
int getHash() const
|
||||
{
|
||||
return m_v0+(m_v1<<16);
|
||||
}
|
||||
bool equals(const btInternalVertexPair& other) const
|
||||
{
|
||||
return m_v0==other.m_v0 && m_v1==other.m_v1;
|
||||
}
|
||||
};
|
||||
|
||||
struct btInternalEdge
|
||||
{
|
||||
btInternalEdge()
|
||||
:m_face0(-1),
|
||||
m_face1(-1)
|
||||
{
|
||||
}
|
||||
short int m_face0;
|
||||
short int m_face1;
|
||||
};
|
||||
|
||||
//
|
||||
|
||||
#ifdef TEST_INTERNAL_OBJECTS
|
||||
bool btConvexPolyhedron::testContainment() const
|
||||
{
|
||||
for(int p=0;p<8;p++)
|
||||
{
|
||||
btVector3 LocalPt;
|
||||
if(p==0) LocalPt = m_localCenter + btVector3(m_extents[0], m_extents[1], m_extents[2]);
|
||||
else if(p==1) LocalPt = m_localCenter + btVector3(m_extents[0], m_extents[1], -m_extents[2]);
|
||||
else if(p==2) LocalPt = m_localCenter + btVector3(m_extents[0], -m_extents[1], m_extents[2]);
|
||||
else if(p==3) LocalPt = m_localCenter + btVector3(m_extents[0], -m_extents[1], -m_extents[2]);
|
||||
else if(p==4) LocalPt = m_localCenter + btVector3(-m_extents[0], m_extents[1], m_extents[2]);
|
||||
else if(p==5) LocalPt = m_localCenter + btVector3(-m_extents[0], m_extents[1], -m_extents[2]);
|
||||
else if(p==6) LocalPt = m_localCenter + btVector3(-m_extents[0], -m_extents[1], m_extents[2]);
|
||||
else if(p==7) LocalPt = m_localCenter + btVector3(-m_extents[0], -m_extents[1], -m_extents[2]);
|
||||
|
||||
for(int i=0;i<m_faces.size();i++)
|
||||
{
|
||||
const btVector3 Normal(m_faces[i].m_plane[0], m_faces[i].m_plane[1], m_faces[i].m_plane[2]);
|
||||
const btScalar d = LocalPt.dot(Normal) + m_faces[i].m_plane[3];
|
||||
if(d>0.0f)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
void btConvexPolyhedron::initialize()
|
||||
{
|
||||
|
||||
btHashMap<btInternalVertexPair,btInternalEdge> edges;
|
||||
|
||||
btScalar TotalArea = 0.0f;
|
||||
|
||||
m_localCenter.setValue(0, 0, 0);
|
||||
for(int i=0;i<m_faces.size();i++)
|
||||
{
|
||||
int numVertices = m_faces[i].m_indices.size();
|
||||
int NbTris = numVertices;
|
||||
for(int j=0;j<NbTris;j++)
|
||||
{
|
||||
int k = (j+1)%numVertices;
|
||||
btInternalVertexPair vp(m_faces[i].m_indices[j],m_faces[i].m_indices[k]);
|
||||
btInternalEdge* edptr = edges.find(vp);
|
||||
btVector3 edge = m_vertices[vp.m_v1]-m_vertices[vp.m_v0];
|
||||
edge.normalize();
|
||||
|
||||
bool found = false;
|
||||
|
||||
for (int p=0;p<m_uniqueEdges.size();p++)
|
||||
{
|
||||
|
||||
if (IsAlmostZero(m_uniqueEdges[p]-edge) ||
|
||||
IsAlmostZero(m_uniqueEdges[p]+edge))
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
{
|
||||
m_uniqueEdges.push_back(edge);
|
||||
}
|
||||
|
||||
if (edptr)
|
||||
{
|
||||
btAssert(edptr->m_face0>=0);
|
||||
btAssert(edptr->m_face1<0);
|
||||
edptr->m_face1 = i;
|
||||
} else
|
||||
{
|
||||
btInternalEdge ed;
|
||||
ed.m_face0 = i;
|
||||
edges.insert(vp,ed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef USE_CONNECTED_FACES
|
||||
for(int i=0;i<m_faces.size();i++)
|
||||
{
|
||||
int numVertices = m_faces[i].m_indices.size();
|
||||
m_faces[i].m_connectedFaces.resize(numVertices);
|
||||
|
||||
for(int j=0;j<numVertices;j++)
|
||||
{
|
||||
int k = (j+1)%numVertices;
|
||||
btInternalVertexPair vp(m_faces[i].m_indices[j],m_faces[i].m_indices[k]);
|
||||
btInternalEdge* edptr = edges.find(vp);
|
||||
btAssert(edptr);
|
||||
btAssert(edptr->m_face0>=0);
|
||||
btAssert(edptr->m_face1>=0);
|
||||
|
||||
int connectedFace = (edptr->m_face0==i)?edptr->m_face1:edptr->m_face0;
|
||||
m_faces[i].m_connectedFaces[j] = connectedFace;
|
||||
}
|
||||
}
|
||||
#endif//USE_CONNECTED_FACES
|
||||
|
||||
for(int i=0;i<m_faces.size();i++)
|
||||
{
|
||||
int numVertices = m_faces[i].m_indices.size();
|
||||
int NbTris = numVertices-2;
|
||||
|
||||
const btVector3& p0 = m_vertices[m_faces[i].m_indices[0]];
|
||||
for(int j=1;j<=NbTris;j++)
|
||||
{
|
||||
int k = (j+1)%numVertices;
|
||||
const btVector3& p1 = m_vertices[m_faces[i].m_indices[j]];
|
||||
const btVector3& p2 = m_vertices[m_faces[i].m_indices[k]];
|
||||
btScalar Area = ((p0 - p1).cross(p0 - p2)).length() * 0.5f;
|
||||
btVector3 Center = (p0+p1+p2)/3.0f;
|
||||
m_localCenter += Area * Center;
|
||||
TotalArea += Area;
|
||||
}
|
||||
}
|
||||
m_localCenter /= TotalArea;
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef TEST_INTERNAL_OBJECTS
|
||||
if(1)
|
||||
{
|
||||
m_radius = FLT_MAX;
|
||||
for(int i=0;i<m_faces.size();i++)
|
||||
{
|
||||
const btVector3 Normal(m_faces[i].m_plane[0], m_faces[i].m_plane[1], m_faces[i].m_plane[2]);
|
||||
const btScalar dist = btFabs(m_localCenter.dot(Normal) + m_faces[i].m_plane[3]);
|
||||
if(dist<m_radius)
|
||||
m_radius = dist;
|
||||
}
|
||||
|
||||
|
||||
btScalar MinX = FLT_MAX;
|
||||
btScalar MinY = FLT_MAX;
|
||||
btScalar MinZ = FLT_MAX;
|
||||
btScalar MaxX = -FLT_MAX;
|
||||
btScalar MaxY = -FLT_MAX;
|
||||
btScalar MaxZ = -FLT_MAX;
|
||||
for(int i=0; i<m_vertices.size(); i++)
|
||||
{
|
||||
const btVector3& pt = m_vertices[i];
|
||||
if(pt.x()<MinX) MinX = pt.x();
|
||||
if(pt.x()>MaxX) MaxX = pt.x();
|
||||
if(pt.y()<MinY) MinY = pt.y();
|
||||
if(pt.y()>MaxY) MaxY = pt.y();
|
||||
if(pt.z()<MinZ) MinZ = pt.z();
|
||||
if(pt.z()>MaxZ) MaxZ = pt.z();
|
||||
}
|
||||
mC.setValue(MaxX+MinX, MaxY+MinY, MaxZ+MinZ);
|
||||
mE.setValue(MaxX-MinX, MaxY-MinY, MaxZ-MinZ);
|
||||
|
||||
|
||||
|
||||
// const btScalar r = m_radius / sqrtf(2.0f);
|
||||
const btScalar r = m_radius / sqrtf(3.0f);
|
||||
const int LargestExtent = mE.maxAxis();
|
||||
const btScalar Step = (mE[LargestExtent]*0.5f - r)/1024.0f;
|
||||
m_extents[0] = m_extents[1] = m_extents[2] = r;
|
||||
m_extents[LargestExtent] = mE[LargestExtent]*0.5f;
|
||||
bool FoundBox = false;
|
||||
for(int j=0;j<1024;j++)
|
||||
{
|
||||
if(testContainment())
|
||||
{
|
||||
FoundBox = true;
|
||||
break;
|
||||
}
|
||||
|
||||
m_extents[LargestExtent] -= Step;
|
||||
}
|
||||
if(!FoundBox)
|
||||
{
|
||||
m_extents[0] = m_extents[1] = m_extents[2] = r;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Refine the box
|
||||
const btScalar Step = (m_radius - r)/1024.0f;
|
||||
const int e0 = (1<<LargestExtent) & 3;
|
||||
const int e1 = (1<<e0) & 3;
|
||||
|
||||
for(int j=0;j<1024;j++)
|
||||
{
|
||||
const btScalar Saved0 = m_extents[e0];
|
||||
const btScalar Saved1 = m_extents[e1];
|
||||
m_extents[e0] += Step;
|
||||
m_extents[e1] += Step;
|
||||
|
||||
if(!testContainment())
|
||||
{
|
||||
m_extents[e0] = Saved0;
|
||||
m_extents[e1] = Saved1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void btConvexPolyhedron::project(const btTransform& trans, const btVector3& dir, btScalar& min, btScalar& max) const
|
||||
{
|
||||
min = FLT_MAX;
|
||||
max = -FLT_MAX;
|
||||
int numVerts = m_vertices.size();
|
||||
for(int i=0;i<numVerts;i++)
|
||||
{
|
||||
btVector3 pt = trans * m_vertices[i];
|
||||
btScalar dp = pt.dot(dir);
|
||||
if(dp < min) min = dp;
|
||||
if(dp > max) max = dp;
|
||||
}
|
||||
if(min>max)
|
||||
{
|
||||
btScalar tmp = min;
|
||||
min = max;
|
||||
max = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,62 +1,65 @@
|
||||
/*
|
||||
Bullet Continuous Collision Detection and Physics Library
|
||||
Copyright (c) 2011 Advanced Micro Devices, Inc. http://bulletphysics.org
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it freely,
|
||||
subject to the following restrictions:
|
||||
|
||||
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.
|
||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
|
||||
///This file was written by Erwin Coumans
|
||||
|
||||
|
||||
#ifndef _BT_POLYHEDRAL_FEATURES_H
|
||||
#define _BT_POLYHEDRAL_FEATURES_H
|
||||
|
||||
#include "LinearMath/btTransform.h"
|
||||
#include "LinearMath/btAlignedObjectArray.h"
|
||||
|
||||
#define TEST_INTERNAL_OBJECTS 1
|
||||
|
||||
|
||||
struct btFace
|
||||
{
|
||||
btAlignedObjectArray<int> m_indices;
|
||||
// btAlignedObjectArray<int> m_connectedFaces;
|
||||
btScalar m_plane[4];
|
||||
};
|
||||
|
||||
|
||||
class btConvexPolyhedron
|
||||
{
|
||||
public:
|
||||
btConvexPolyhedron();
|
||||
virtual ~btConvexPolyhedron();
|
||||
|
||||
btAlignedObjectArray<btVector3> m_vertices;
|
||||
btAlignedObjectArray<btFace> m_faces;
|
||||
btAlignedObjectArray<btVector3> m_uniqueEdges;
|
||||
|
||||
btVector3 m_localCenter;
|
||||
btVector3 m_extents;
|
||||
btScalar m_radius;
|
||||
btVector3 mC;
|
||||
btVector3 mE;
|
||||
|
||||
void initialize();
|
||||
bool testContainment() const;
|
||||
|
||||
void project(const btTransform& trans, const btVector3& dir, btScalar& min, btScalar& max) const;
|
||||
};
|
||||
|
||||
|
||||
#endif //_BT_POLYHEDRAL_FEATURES_H
|
||||
|
||||
|
||||
/*
|
||||
Bullet Continuous Collision Detection and Physics Library
|
||||
Copyright (c) 2011 Advanced Micro Devices, Inc. http://bulletphysics.org
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it freely,
|
||||
subject to the following restrictions:
|
||||
|
||||
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.
|
||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
|
||||
///This file was written by Erwin Coumans
|
||||
|
||||
|
||||
#ifndef _BT_POLYHEDRAL_FEATURES_H
|
||||
#define _BT_POLYHEDRAL_FEATURES_H
|
||||
|
||||
#include "LinearMath/btTransform.h"
|
||||
#include "LinearMath/btAlignedObjectArray.h"
|
||||
|
||||
#define TEST_INTERNAL_OBJECTS 1
|
||||
|
||||
|
||||
struct btFace
|
||||
{
|
||||
btAlignedObjectArray<int> m_indices;
|
||||
// btAlignedObjectArray<int> m_connectedFaces;
|
||||
btScalar m_plane[4];
|
||||
};
|
||||
|
||||
|
||||
ATTRIBUTE_ALIGNED16(class) btConvexPolyhedron
|
||||
{
|
||||
public:
|
||||
|
||||
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||
|
||||
btConvexPolyhedron();
|
||||
virtual ~btConvexPolyhedron();
|
||||
|
||||
btAlignedObjectArray<btVector3> m_vertices;
|
||||
btAlignedObjectArray<btFace> m_faces;
|
||||
btAlignedObjectArray<btVector3> m_uniqueEdges;
|
||||
|
||||
btVector3 m_localCenter;
|
||||
btVector3 m_extents;
|
||||
btScalar m_radius;
|
||||
btVector3 mC;
|
||||
btVector3 mE;
|
||||
|
||||
void initialize();
|
||||
bool testContainment() const;
|
||||
|
||||
void project(const btTransform& trans, const btVector3& dir, btScalar& min, btScalar& max) const;
|
||||
};
|
||||
|
||||
|
||||
#endif //_BT_POLYHEDRAL_FEATURES_H
|
||||
|
||||
|
||||
|
||||
@@ -109,19 +109,8 @@ static btVector3 convexHullSupport (const btVector3& localDirOrg, const btVector
|
||||
return supVec;
|
||||
#else
|
||||
|
||||
btScalar newDot,maxDot = btScalar(-BT_LARGE_FLOAT);
|
||||
int ptIndex = -1;
|
||||
|
||||
for (int i=0;i<numPoints;i++)
|
||||
{
|
||||
|
||||
newDot = vec.dot(points[i]);
|
||||
if (newDot > maxDot)
|
||||
{
|
||||
maxDot = newDot;
|
||||
ptIndex = i;
|
||||
}
|
||||
}
|
||||
btScalar maxDot;
|
||||
long ptIndex = vec.maxDot( points, numPoints, maxDot);
|
||||
btAssert(ptIndex >= 0);
|
||||
btVector3 supVec = points[ptIndex] * localScaling;
|
||||
return supVec;
|
||||
@@ -141,16 +130,26 @@ btVector3 btConvexShape::localGetSupportVertexWithoutMarginNonVirtual (const btV
|
||||
btBoxShape* convexShape = (btBoxShape*)this;
|
||||
const btVector3& halfExtents = convexShape->getImplicitShapeDimensions();
|
||||
|
||||
#if defined( __APPLE__ ) && (defined( BT_USE_SSE )||defined( BT_USE_NEON ))
|
||||
#if defined( BT_USE_SSE )
|
||||
return btVector3( _mm_xor_ps( _mm_and_ps( localDir.mVec128, (__m128){-0.0f, -0.0f, -0.0f, -0.0f }), halfExtents.mVec128 ));
|
||||
#elif defined( BT_USE_NEON )
|
||||
return btVector3( (float32x4_t) (((uint32x4_t) localDir.mVec128 & (uint32x4_t){ 0x80000000, 0x80000000, 0x80000000, 0x80000000}) ^ (uint32x4_t) halfExtents.mVec128 ));
|
||||
#else
|
||||
#error unknown vector arch
|
||||
#endif
|
||||
#else
|
||||
return btVector3(btFsels(localDir.x(), halfExtents.x(), -halfExtents.x()),
|
||||
btFsels(localDir.y(), halfExtents.y(), -halfExtents.y()),
|
||||
btFsels(localDir.z(), halfExtents.z(), -halfExtents.z()));
|
||||
#endif
|
||||
}
|
||||
case TRIANGLE_SHAPE_PROXYTYPE:
|
||||
{
|
||||
btTriangleShape* triangleShape = (btTriangleShape*)this;
|
||||
btVector3 dir(localDir.getX(),localDir.getY(),localDir.getZ());
|
||||
btVector3* vertices = &triangleShape->m_vertices1[0];
|
||||
btVector3 dots(dir.dot(vertices[0]), dir.dot(vertices[1]), dir.dot(vertices[2]));
|
||||
btVector3 dots = dir.dot3(vertices[0], vertices[1], vertices[2]);
|
||||
btVector3 sup = vertices[dots.maxAxis()];
|
||||
return btVector3(sup.getX(),sup.getY(),sup.getZ());
|
||||
}
|
||||
@@ -383,8 +382,8 @@ void btConvexShape::getAabbNonVirtual (const btTransform& t, btVector3& aabbMin,
|
||||
halfExtents += btVector3(margin,margin,margin);
|
||||
btMatrix3x3 abs_b = t.getBasis().absolute();
|
||||
btVector3 center = t.getOrigin();
|
||||
btVector3 extent = btVector3(abs_b[0].dot(halfExtents),abs_b[1].dot(halfExtents),abs_b[2].dot(halfExtents));
|
||||
|
||||
btVector3 extent = halfExtents.dot3(abs_b[0], abs_b[1], abs_b[2]);
|
||||
|
||||
aabbMin = center - extent;
|
||||
aabbMax = center + extent;
|
||||
break;
|
||||
@@ -417,7 +416,7 @@ void btConvexShape::getAabbNonVirtual (const btTransform& t, btVector3& aabbMin,
|
||||
halfExtents += btVector3(capsuleShape->getMarginNonVirtual(),capsuleShape->getMarginNonVirtual(),capsuleShape->getMarginNonVirtual());
|
||||
btMatrix3x3 abs_b = t.getBasis().absolute();
|
||||
btVector3 center = t.getOrigin();
|
||||
btVector3 extent = btVector3(abs_b[0].dot(halfExtents),abs_b[1].dot(halfExtents),abs_b[2].dot(halfExtents));
|
||||
btVector3 extent = halfExtents.dot3(abs_b[0], abs_b[1], abs_b[2]);
|
||||
aabbMin = center - extent;
|
||||
aabbMax = center + extent;
|
||||
}
|
||||
|
||||
@@ -22,12 +22,14 @@ subject to the following restrictions:
|
||||
|
||||
/// The btConvexTriangleMeshShape is a convex hull of a triangle mesh, but the performance is not as good as btConvexHullShape.
|
||||
/// A small benefit of this class is that it uses the btStridingMeshInterface, so you can avoid the duplication of the triangle mesh data. Nevertheless, most users should use the much better performing btConvexHullShape instead.
|
||||
class btConvexTriangleMeshShape : public btPolyhedralConvexAabbCachingShape
|
||||
ATTRIBUTE_ALIGNED16(class) btConvexTriangleMeshShape : public btPolyhedralConvexAabbCachingShape
|
||||
{
|
||||
|
||||
class btStridingMeshInterface* m_stridingMesh;
|
||||
|
||||
public:
|
||||
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||
|
||||
btConvexTriangleMeshShape(btStridingMeshInterface* meshInterface, bool calcAabb = true);
|
||||
|
||||
class btStridingMeshInterface* getMeshInterface()
|
||||
|
||||
@@ -21,7 +21,7 @@ subject to the following restrictions:
|
||||
#include "LinearMath/btVector3.h"
|
||||
|
||||
/// The btCylinderShape class implements a cylinder shape primitive, centered around the origin. Its central axis aligned with the Y axis. btCylinderShapeX is aligned with the X axis and btCylinderShapeZ around the Z axis.
|
||||
class btCylinderShape : public btConvexInternalShape
|
||||
ATTRIBUTE_ALIGNED16(class) btCylinderShape : public btConvexInternalShape
|
||||
|
||||
{
|
||||
|
||||
@@ -31,6 +31,8 @@ protected:
|
||||
|
||||
public:
|
||||
|
||||
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||
|
||||
btVector3 getHalfExtentsWithMargin() const
|
||||
{
|
||||
btVector3 halfExtents = getHalfExtentsWithoutMargin();
|
||||
@@ -128,6 +130,8 @@ public:
|
||||
class btCylinderShapeX : public btCylinderShape
|
||||
{
|
||||
public:
|
||||
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||
|
||||
btCylinderShapeX (const btVector3& halfExtents);
|
||||
|
||||
virtual btVector3 localGetSupportingVertexWithoutMargin(const btVector3& vec)const;
|
||||
@@ -149,6 +153,8 @@ public:
|
||||
class btCylinderShapeZ : public btCylinderShape
|
||||
{
|
||||
public:
|
||||
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||
|
||||
btCylinderShapeZ (const btVector3& halfExtents);
|
||||
|
||||
virtual btVector3 localGetSupportingVertexWithoutMargin(const btVector3& vec)const;
|
||||
|
||||
@@ -28,9 +28,11 @@ subject to the following restrictions:
|
||||
|
||||
/// The btEmptyShape is a collision shape without actual collision detection shape, so most users should ignore this class.
|
||||
/// It can be replaced by another shape during runtime, but the inertia tensor should be recomputed.
|
||||
class btEmptyShape : public btConcaveShape
|
||||
ATTRIBUTE_ALIGNED16(class) btEmptyShape : public btConcaveShape
|
||||
{
|
||||
public:
|
||||
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||
|
||||
btEmptyShape();
|
||||
|
||||
virtual ~btEmptyShape();
|
||||
|
||||
@@ -38,7 +38,7 @@ btHeightfieldTerrainShape::btHeightfieldTerrainShape(int heightStickWidth, int h
|
||||
// legacy constructor: support only float or unsigned char,
|
||||
// and min height is zero
|
||||
PHY_ScalarType hdt = (useFloatData) ? PHY_FLOAT : PHY_UCHAR;
|
||||
btScalar minHeight = 0.0;
|
||||
btScalar minHeight = 0.0f;
|
||||
|
||||
// previously, height = uchar * maxHeight / 65535.
|
||||
// So to preserve legacy behavior, heightScale = maxHeight / 65535
|
||||
@@ -135,9 +135,7 @@ void btHeightfieldTerrainShape::getAabb(const btTransform& t,btVector3& aabbMin,
|
||||
|
||||
btMatrix3x3 abs_b = t.getBasis().absolute();
|
||||
btVector3 center = t.getOrigin();
|
||||
btVector3 extent = btVector3(abs_b[0].dot(halfExtents),
|
||||
abs_b[1].dot(halfExtents),
|
||||
abs_b[2].dot(halfExtents));
|
||||
btVector3 extent = halfExtents.dot3(abs_b[0], abs_b[1], abs_b[2]);
|
||||
extent += btVector3(getMargin(),getMargin(),getMargin());
|
||||
|
||||
aabbMin = center - extent;
|
||||
|
||||
@@ -68,7 +68,7 @@ subject to the following restrictions:
|
||||
|
||||
For usage and testing see the TerrainDemo.
|
||||
*/
|
||||
class btHeightfieldTerrainShape : public btConcaveShape
|
||||
ATTRIBUTE_ALIGNED16(class) btHeightfieldTerrainShape : public btConcaveShape
|
||||
{
|
||||
protected:
|
||||
btVector3 m_localAabbMin;
|
||||
@@ -116,6 +116,9 @@ protected:
|
||||
PHY_ScalarType heightDataType, bool flipQuadEdges);
|
||||
|
||||
public:
|
||||
|
||||
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||
|
||||
/// preferred constructor
|
||||
/**
|
||||
This constructor supports a range of heightfield
|
||||
|
||||
@@ -20,7 +20,7 @@ subject to the following restrictions:
|
||||
#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" // for the types
|
||||
|
||||
/// The btMinkowskiSumShape is only for advanced users. This shape represents implicit based minkowski sum of two convex implicit shapes.
|
||||
class btMinkowskiSumShape : public btConvexInternalShape
|
||||
ATTRIBUTE_ALIGNED16(class) btMinkowskiSumShape : public btConvexInternalShape
|
||||
{
|
||||
|
||||
btTransform m_transA;
|
||||
@@ -30,6 +30,8 @@ class btMinkowskiSumShape : public btConvexInternalShape
|
||||
|
||||
public:
|
||||
|
||||
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||
|
||||
btMinkowskiSumShape(const btConvexShape* shapeA,const btConvexShape* shapeB);
|
||||
|
||||
virtual btVector3 localGetSupportingVertexWithoutMargin(const btVector3& vec)const;
|
||||
|
||||
@@ -39,10 +39,11 @@ btMultiSphereShape::btMultiSphereShape (const btVector3* positions,const btScala
|
||||
|
||||
}
|
||||
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN( _a, _b) ((_a) < (_b) ? (_a) : (_b))
|
||||
#endif
|
||||
btVector3 btMultiSphereShape::localGetSupportingVertexWithoutMargin(const btVector3& vec0)const
|
||||
{
|
||||
int i;
|
||||
btVector3 supVec(0,0,0);
|
||||
|
||||
btScalar maxDot(btScalar(-BT_LARGE_FLOAT));
|
||||
@@ -66,18 +67,23 @@ btMultiSphereShape::btMultiSphereShape (const btVector3* positions,const btScala
|
||||
const btScalar* rad = &m_radiArray[0];
|
||||
int numSpheres = m_localPositionArray.size();
|
||||
|
||||
for (i=0;i<numSpheres;i++)
|
||||
{
|
||||
vtx = (*pos) +vec*m_localScaling*(*rad) - vec * getMargin();
|
||||
pos++;
|
||||
rad++;
|
||||
newDot = vec.dot(vtx);
|
||||
if (newDot > maxDot)
|
||||
for( int k = 0; k < numSpheres; k+= 128 )
|
||||
{
|
||||
btVector3 temp[128];
|
||||
int inner_count = MIN( numSpheres - k, 128 );
|
||||
for( long i = 0; i < inner_count; i++ )
|
||||
{
|
||||
temp[i] = (*pos) +vec*m_localScaling*(*rad) - vec * getMargin();
|
||||
pos++;
|
||||
rad++;
|
||||
}
|
||||
long i = vec.maxDot( temp, inner_count, newDot);
|
||||
if( newDot > maxDot )
|
||||
{
|
||||
maxDot = newDot;
|
||||
supVec = vtx;
|
||||
supVec = temp[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return supVec;
|
||||
|
||||
@@ -98,18 +104,25 @@ btMultiSphereShape::btMultiSphereShape (const btVector3* positions,const btScala
|
||||
const btVector3* pos = &m_localPositionArray[0];
|
||||
const btScalar* rad = &m_radiArray[0];
|
||||
int numSpheres = m_localPositionArray.size();
|
||||
for (int i=0;i<numSpheres;i++)
|
||||
{
|
||||
vtx = (*pos) +vec*m_localScaling*(*rad) - vec * getMargin();
|
||||
pos++;
|
||||
rad++;
|
||||
newDot = vec.dot(vtx);
|
||||
if (newDot > maxDot)
|
||||
{
|
||||
maxDot = newDot;
|
||||
supportVerticesOut[j] = vtx;
|
||||
}
|
||||
}
|
||||
|
||||
for( int k = 0; k < numSpheres; k+= 128 )
|
||||
{
|
||||
btVector3 temp[128];
|
||||
int inner_count = MIN( numSpheres - k, 128 );
|
||||
for( long i = 0; i < inner_count; i++ )
|
||||
{
|
||||
temp[i] = (*pos) +vec*m_localScaling*(*rad) - vec * getMargin();
|
||||
pos++;
|
||||
rad++;
|
||||
}
|
||||
long i = vec.maxDot( temp, inner_count, newDot);
|
||||
if( newDot > maxDot )
|
||||
{
|
||||
maxDot = newDot;
|
||||
supportVerticesOut[j] = temp[i];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,13 +25,15 @@ subject to the following restrictions:
|
||||
|
||||
///The btMultiSphereShape represents the convex hull of a collection of spheres. You can create special capsules or other smooth volumes.
|
||||
///It is possible to animate the spheres for deformation, but call 'recalcLocalAabb' after changing any sphere position/radius
|
||||
class btMultiSphereShape : public btConvexInternalAabbCachingShape
|
||||
ATTRIBUTE_ALIGNED16(class) btMultiSphereShape : public btConvexInternalAabbCachingShape
|
||||
{
|
||||
|
||||
btAlignedObjectArray<btVector3> m_localPositionArray;
|
||||
btAlignedObjectArray<btScalar> m_radiArray;
|
||||
|
||||
public:
|
||||
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||
|
||||
btMultiSphereShape (const btVector3* positions,const btScalar* radi,int numSpheres);
|
||||
|
||||
///CollisionShape Interface
|
||||
|
||||
@@ -45,7 +45,7 @@ bool btPolyhedralConvexShape::initializePolyhedralFeatures()
|
||||
void* mem = btAlignedAlloc(sizeof(btConvexPolyhedron),16);
|
||||
m_polyhedron = new (mem) btConvexPolyhedron;
|
||||
|
||||
btAlignedObjectArray<btVector3> orgVertices;
|
||||
btAlignedObjectArray<btVector3> orgVertices;
|
||||
|
||||
for (int i=0;i<getNumVertices();i++)
|
||||
{
|
||||
@@ -107,9 +107,6 @@ bool btPolyhedralConvexShape::initializePolyhedralFeatures()
|
||||
int numEdges = 0;
|
||||
//compute face normals
|
||||
|
||||
btScalar maxCross2 = 0.f;
|
||||
int chosenEdge = -1;
|
||||
|
||||
do
|
||||
{
|
||||
|
||||
@@ -299,6 +296,9 @@ bool btPolyhedralConvexShape::initializePolyhedralFeatures()
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(_a, _b) ((_a) < (_b) ? (_a) : (_b))
|
||||
#endif
|
||||
|
||||
btVector3 btPolyhedralConvexShape::localGetSupportingVertexWithoutMargin(const btVector3& vec0)const
|
||||
{
|
||||
@@ -323,17 +323,19 @@ btVector3 btPolyhedralConvexShape::localGetSupportingVertexWithoutMargin(const b
|
||||
btVector3 vtx;
|
||||
btScalar newDot;
|
||||
|
||||
for (i=0;i<getNumVertices();i++)
|
||||
{
|
||||
getVertex(i,vtx);
|
||||
newDot = vec.dot(vtx);
|
||||
for( int k = 0; k < getNumVertices(); k += 128 )
|
||||
{
|
||||
btVector3 temp[128];
|
||||
int inner_count = MIN(getNumVertices() - k, 128);
|
||||
for( i = 0; i < inner_count; i++ )
|
||||
getVertex(i,temp[i]);
|
||||
i = (int) vec.maxDot( temp, inner_count, newDot);
|
||||
if (newDot > maxDot)
|
||||
{
|
||||
maxDot = newDot;
|
||||
supVec = vtx;
|
||||
}
|
||||
}
|
||||
|
||||
supVec = temp[i];
|
||||
}
|
||||
}
|
||||
|
||||
#endif //__SPU__
|
||||
return supVec;
|
||||
@@ -356,21 +358,23 @@ void btPolyhedralConvexShape::batchedUnitVectorGetSupportingVertexWithoutMargin(
|
||||
|
||||
for (int j=0;j<numVectors;j++)
|
||||
{
|
||||
|
||||
const btVector3& vec = vectors[j];
|
||||
|
||||
for (i=0;i<getNumVertices();i++)
|
||||
{
|
||||
getVertex(i,vtx);
|
||||
newDot = vec.dot(vtx);
|
||||
if (newDot > supportVerticesOut[j][3])
|
||||
{
|
||||
//WARNING: don't swap next lines, the w component would get overwritten!
|
||||
supportVerticesOut[j] = vtx;
|
||||
const btVector3& vec = vectors[j];
|
||||
|
||||
for( int k = 0; k < getNumVertices(); k += 128 )
|
||||
{
|
||||
btVector3 temp[128];
|
||||
int inner_count = MIN(getNumVertices() - k, 128);
|
||||
for( i = 0; i < inner_count; i++ )
|
||||
getVertex(i,temp[i]);
|
||||
i = (int) vec.maxDot( temp, inner_count, newDot);
|
||||
if (newDot > supportVerticesOut[j][3])
|
||||
{
|
||||
supportVerticesOut[j] = temp[i];
|
||||
supportVerticesOut[j][3] = newDot;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif //__SPU__
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ class btConvexPolyhedron;
|
||||
|
||||
|
||||
///The btPolyhedralConvexShape is an internal interface class for polyhedral convex shapes.
|
||||
class btPolyhedralConvexShape : public btConvexInternalShape
|
||||
ATTRIBUTE_ALIGNED16(class) btPolyhedralConvexShape : public btConvexInternalShape
|
||||
{
|
||||
|
||||
|
||||
@@ -31,6 +31,9 @@ protected:
|
||||
btConvexPolyhedron* m_polyhedron;
|
||||
|
||||
public:
|
||||
|
||||
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||
|
||||
|
||||
btPolyhedralConvexShape();
|
||||
|
||||
|
||||
@@ -98,9 +98,7 @@ void btScaledBvhTriangleMeshShape::getAabb(const btTransform& trans,btVector3& a
|
||||
|
||||
btVector3 center = trans(localCenter);
|
||||
|
||||
btVector3 extent = btVector3(abs_b[0].dot(localHalfExtents),
|
||||
abs_b[1].dot(localHalfExtents),
|
||||
abs_b[2].dot(localHalfExtents));
|
||||
btVector3 extent = localHalfExtents.dot3(abs_b[0], abs_b[1], abs_b[2]);
|
||||
aabbMin = center - extent;
|
||||
aabbMax = center + extent;
|
||||
|
||||
|
||||
@@ -31,6 +31,8 @@ ATTRIBUTE_ALIGNED16(class) btScaledBvhTriangleMeshShape : public btConcaveShape
|
||||
|
||||
public:
|
||||
|
||||
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||
|
||||
|
||||
btScaledBvhTriangleMeshShape(btBvhTriangleMeshShape* childShape,const btVector3& localScaling);
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ subject to the following restrictions:
|
||||
///The btShapeHull class takes a btConvexShape, builds a simplified convex hull using btConvexHull and provides triangle indices and vertices.
|
||||
///It can be useful for to simplify a complex convex object and for visualization of a non-polyhedral convex object.
|
||||
///It approximates the convex hull using the supporting vertex of 42 directions.
|
||||
class btShapeHull
|
||||
ATTRIBUTE_ALIGNED16(class) btShapeHull
|
||||
{
|
||||
protected:
|
||||
|
||||
@@ -37,6 +37,8 @@ protected:
|
||||
static btVector3* getUnitSpherePoints();
|
||||
|
||||
public:
|
||||
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||
|
||||
btShapeHull (const btConvexShape* shape);
|
||||
~btShapeHull ();
|
||||
|
||||
|
||||
@@ -31,6 +31,8 @@ protected:
|
||||
btVector3 m_localScaling;
|
||||
|
||||
public:
|
||||
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||
|
||||
btStaticPlaneShape(const btVector3& planeNormal,btScalar planeConstant);
|
||||
|
||||
virtual ~btStaticPlaneShape();
|
||||
|
||||
@@ -27,13 +27,15 @@ subject to the following restrictions:
|
||||
/// The btStridingMeshInterface is the interface class for high performance generic access to triangle meshes, used in combination with btBvhTriangleMeshShape and some other collision shapes.
|
||||
/// Using index striding of 3*sizeof(integer) it can use triangle arrays, using index striding of 1*sizeof(integer) it can handle triangle strips.
|
||||
/// It allows for sharing graphics and collision meshes. Also it provides locking/unlocking of graphics meshes that are in gpu memory.
|
||||
class btStridingMeshInterface
|
||||
ATTRIBUTE_ALIGNED16(class ) btStridingMeshInterface
|
||||
{
|
||||
protected:
|
||||
|
||||
btVector3 m_scaling;
|
||||
|
||||
public:
|
||||
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||
|
||||
btStridingMeshInterface() :m_scaling(btScalar(1.),btScalar(1.),btScalar(1.))
|
||||
{
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ subject to the following restrictions:
|
||||
|
||||
|
||||
///The btBU_Simplex1to4 implements tetrahedron, triangle, line, vertex collision shapes. In most cases it is better to use btConvexHullShape instead.
|
||||
class btBU_Simplex1to4 : public btPolyhedralConvexAabbCachingShape
|
||||
ATTRIBUTE_ALIGNED16(class) btBU_Simplex1to4 : public btPolyhedralConvexAabbCachingShape
|
||||
{
|
||||
protected:
|
||||
|
||||
@@ -30,6 +30,8 @@ protected:
|
||||
btVector3 m_vertices[4];
|
||||
|
||||
public:
|
||||
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||
|
||||
btBU_Simplex1to4();
|
||||
|
||||
btBU_Simplex1to4(const btVector3& pt0);
|
||||
|
||||
@@ -55,13 +55,9 @@ void btTriangleMeshShape::getAabb(const btTransform& trans,btVector3& aabbMin,bt
|
||||
|
||||
btVector3 center = trans(localCenter);
|
||||
|
||||
btVector3 extent = btVector3(abs_b[0].dot(localHalfExtents),
|
||||
abs_b[1].dot(localHalfExtents),
|
||||
abs_b[2].dot(localHalfExtents));
|
||||
btVector3 extent = localHalfExtents.dot3(abs_b[0], abs_b[1], abs_b[2]);
|
||||
aabbMin = center - extent;
|
||||
aabbMax = center + extent;
|
||||
|
||||
|
||||
}
|
||||
|
||||
void btTriangleMeshShape::recalcLocalAabb()
|
||||
|
||||
@@ -21,7 +21,7 @@ subject to the following restrictions:
|
||||
|
||||
|
||||
///The btTriangleMeshShape is an internal concave triangle mesh interface. Don't use this class directly, use btBvhTriangleMeshShape instead.
|
||||
class btTriangleMeshShape : public btConcaveShape
|
||||
ATTRIBUTE_ALIGNED16(class) btTriangleMeshShape : public btConcaveShape
|
||||
{
|
||||
protected:
|
||||
btVector3 m_localAabbMin;
|
||||
@@ -33,6 +33,7 @@ protected:
|
||||
btTriangleMeshShape(btStridingMeshInterface* meshInterface);
|
||||
|
||||
public:
|
||||
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||
|
||||
virtual ~btTriangleMeshShape();
|
||||
|
||||
|
||||
@@ -25,6 +25,8 @@ ATTRIBUTE_ALIGNED16(class) btTriangleShape : public btPolyhedralConvexShape
|
||||
|
||||
public:
|
||||
|
||||
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||
|
||||
btVector3 m_vertices1[3];
|
||||
|
||||
virtual int getNumVertices() const
|
||||
@@ -66,7 +68,7 @@ public:
|
||||
|
||||
btVector3 localGetSupportingVertexWithoutMargin(const btVector3& dir)const
|
||||
{
|
||||
btVector3 dots(dir.dot(m_vertices1[0]), dir.dot(m_vertices1[1]), dir.dot(m_vertices1[2]));
|
||||
btVector3 dots = dir.dot3(m_vertices1[0], m_vertices1[1], m_vertices1[2]);
|
||||
return m_vertices1[dots.maxAxis()];
|
||||
|
||||
}
|
||||
@@ -76,7 +78,7 @@ public:
|
||||
for (int i=0;i<numVectors;i++)
|
||||
{
|
||||
const btVector3& dir = vectors[i];
|
||||
btVector3 dots(dir.dot(m_vertices1[0]), dir.dot(m_vertices1[1]), dir.dot(m_vertices1[2]));
|
||||
btVector3 dots = dir.dot3(m_vertices1[0], m_vertices1[1], m_vertices1[2]);
|
||||
supportVerticesOut[i] = m_vertices1[dots.maxAxis()];
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ subject to the following restrictions:
|
||||
|
||||
///The btUniformScalingShape allows to re-use uniform scaled instances of btConvexShape in a memory efficient way.
|
||||
///Istead of using btUniformScalingShape, it is better to use the non-uniform setLocalScaling method on convex shapes that implement it.
|
||||
class btUniformScalingShape : public btConvexShape
|
||||
ATTRIBUTE_ALIGNED16(class) btUniformScalingShape : public btConvexShape
|
||||
{
|
||||
btConvexShape* m_childConvexShape;
|
||||
|
||||
@@ -29,6 +29,8 @@ class btUniformScalingShape : public btConvexShape
|
||||
|
||||
public:
|
||||
|
||||
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||
|
||||
btUniformScalingShape( btConvexShape* convexChildShape, btScalar uniformScalingFactor);
|
||||
|
||||
virtual ~btUniformScalingShape();
|
||||
|
||||
Reference in New Issue
Block a user