The extern/bullet from HEAD is needed to compile the gameengine in

orange
This commit is contained in:
Chris Want 2006-01-28 17:25:03 +00:00
parent b71130ca80
commit 635224802e
10 changed files with 220 additions and 61 deletions

@ -159,10 +159,6 @@ SOURCE=.\NarrowPhaseCollision\BU_VertexPoly.h
# End Source File
# Begin Source File
SOURCE=.\NarrowPhaseCollision\CollisionMargin.h
# End Source File
# Begin Source File
SOURCE=.\NarrowPhaseCollision\ContinuousConvexCollision.cpp
# End Source File
# Begin Source File
@ -203,6 +199,14 @@ SOURCE=.\NarrowPhaseCollision\GjkPairDetector.h
# End Source File
# Begin Source File
SOURCE=.\NarrowPhaseCollision\ManifoldContactAddResult.cpp
# End Source File
# Begin Source File
SOURCE=.\NarrowPhaseCollision\ManifoldContactAddResult.h
# End Source File
# Begin Source File
SOURCE=.\NarrowPhaseCollision\ManifoldPoint.h
# End Source File
# Begin Source File
@ -307,6 +311,18 @@ SOURCE=.\CollisionShapes\BoxShape.h
# End Source File
# Begin Source File
SOURCE=.\CollisionShapes\BvhTriangleMeshShape.cpp
# End Source File
# Begin Source File
SOURCE=.\CollisionShapes\BvhTriangleMeshShape.h
# End Source File
# Begin Source File
SOURCE=.\CollisionShapes\CollisionMargin.h
# End Source File
# Begin Source File
SOURCE=.\CollisionShapes\CollisionShape.cpp
# End Source File
# Begin Source File
@ -339,6 +355,14 @@ SOURCE=.\CollisionShapes\ConvexShape.h
# End Source File
# Begin Source File
SOURCE=.\CollisionShapes\ConvexTriangleCallback.cpp
# End Source File
# Begin Source File
SOURCE=.\CollisionShapes\ConvexTriangleCallback.h
# End Source File
# Begin Source File
SOURCE=.\CollisionShapes\CylinderShape.cpp
# End Source File
# Begin Source File
@ -347,6 +371,14 @@ SOURCE=.\CollisionShapes\CylinderShape.h
# End Source File
# Begin Source File
SOURCE=.\CollisionShapes\EmptyShape.cpp
# End Source File
# Begin Source File
SOURCE=.\CollisionShapes\EmptyShape.h
# End Source File
# Begin Source File
SOURCE=.\CollisionShapes\MinkowskiSumShape.cpp
# End Source File
# Begin Source File
@ -363,6 +395,14 @@ SOURCE=.\CollisionShapes\MultiSphereShape.h
# End Source File
# Begin Source File
SOURCE=.\CollisionShapes\OptimizedBvh.cpp
# End Source File
# Begin Source File
SOURCE=.\CollisionShapes\OptimizedBvh.h
# End Source File
# Begin Source File
SOURCE=.\CollisionShapes\PolyhedralConvexShape.cpp
# End Source File
# Begin Source File
@ -395,10 +435,22 @@ SOURCE=.\CollisionShapes\StridingMeshInterface.h
# End Source File
# Begin Source File
SOURCE=.\CollisionShapes\TriangleCallback.cpp
# End Source File
# Begin Source File
SOURCE=.\CollisionShapes\TriangleCallback.h
# End Source File
# Begin Source File
SOURCE=.\CollisionShapes\TriangleIndexVertexArray.cpp
# End Source File
# Begin Source File
SOURCE=.\CollisionShapes\TriangleIndexVertexArray.h
# End Source File
# Begin Source File
SOURCE=.\CollisionShapes\TriangleMesh.cpp
# End Source File
# Begin Source File

@ -42,6 +42,7 @@
Optimization="0"
AdditionalIncludeDirectories=".;..\LinearMath"
PreprocessorDefinitions="_DEBUG;_LIB;WIN32;BUM_INLINED;USE_ALGEBRAIC"
ExceptionHandling="0"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
@ -272,6 +273,14 @@
RelativePath=".\NarrowPhaseCollision\GjkPairDetector.h"
>
</File>
<File
RelativePath=".\NarrowPhaseCollision\ManifoldContactAddResult.cpp"
>
</File>
<File
RelativePath=".\NarrowPhaseCollision\ManifoldContactAddResult.h"
>
</File>
<File
RelativePath=".\NarrowPhaseCollision\ManifoldPoint.h"
>
@ -368,6 +377,14 @@
RelativePath=".\CollisionShapes\ConvexShape.h"
>
</File>
<File
RelativePath=".\CollisionShapes\ConvexTriangleCallback.cpp"
>
</File>
<File
RelativePath=".\CollisionShapes\ConvexTriangleCallback.h"
>
</File>
<File
RelativePath=".\CollisionShapes\CylinderShape.cpp"
>
@ -376,6 +393,14 @@
RelativePath=".\CollisionShapes\CylinderShape.h"
>
</File>
<File
RelativePath=".\CollisionShapes\EmptyShape.cpp"
>
</File>
<File
RelativePath=".\CollisionShapes\EmptyShape.h"
>
</File>
<File
RelativePath=".\CollisionShapes\MinkowskiSumShape.cpp"
>
@ -424,6 +449,10 @@
RelativePath=".\CollisionShapes\StridingMeshInterface.h"
>
</File>
<File
RelativePath=".\CollisionShapes\TriangleCallback.cpp"
>
</File>
<File
RelativePath=".\CollisionShapes\TriangleCallback.h"
>
@ -549,6 +578,30 @@
>
</File>
</Filter>
<File
RelativePath=".\CollisionShapes\BvhTriangleMeshShape.cpp"
>
</File>
<File
RelativePath=".\CollisionShapes\BvhTriangleMeshShape.h"
>
</File>
<File
RelativePath=".\CollisionShapes\OptimizedBvh.cpp"
>
</File>
<File
RelativePath=".\CollisionShapes\OptimizedBvh.h"
>
</File>
<File
RelativePath=".\CollisionShapes\TriangleIndexVertexArray.cpp"
>
</File>
<File
RelativePath=".\CollisionShapes\TriangleIndexVertexArray.h"
>
</File>
</Files>
<Globals>
</Globals>

@ -84,28 +84,30 @@ void OptimizedBvh::Build(StridingMeshInterface* triangles)
OptimizedBvhNode* OptimizedBvh::BuildTree (NodeArray& leafNodes,int startIndex,int endIndex)
{
OptimizedBvhNode* internalNode;
int splitAxis, splitIndex, i;
int numIndices =endIndex-startIndex;
assert(numIndices>0);
int curIndex = m_curNodeIndex;
assert(numIndices>0);
if (numIndices==1)
{
return new (&m_contiguousNodes[m_curNodeIndex++]) OptimizedBvhNode(leafNodes[startIndex]);
}
//calculate Best Splitting Axis and where to split it. Sort the incoming 'leafNodes' array within range 'startIndex/endIndex'.
int splitAxis = CalcSplittingAxis(leafNodes,startIndex,endIndex);
splitAxis = CalcSplittingAxis(leafNodes,startIndex,endIndex);
int splitIndex = SortAndCalcSplittingIndex(leafNodes,startIndex,endIndex,splitAxis);
splitIndex = SortAndCalcSplittingIndex(leafNodes,startIndex,endIndex,splitAxis);
OptimizedBvhNode* internalNode = &m_contiguousNodes[m_curNodeIndex++];
internalNode = &m_contiguousNodes[m_curNodeIndex++];
internalNode->m_aabbMax.setValue(-1e30f,-1e30f,-1e30f);
internalNode->m_aabbMin.setValue(1e30f,1e30f,1e30f);
for (int i=startIndex;i<endIndex;i++)
for (i=startIndex;i<endIndex;i++)
{
internalNode->m_aabbMax.setMax(leafNodes[i].m_aabbMax);
internalNode->m_aabbMin.setMin(leafNodes[i].m_aabbMin);
@ -123,21 +125,23 @@ OptimizedBvhNode* OptimizedBvh::BuildTree (NodeArray& leafNodes,int startIndex,i
int OptimizedBvh::SortAndCalcSplittingIndex(NodeArray& leafNodes,int startIndex,int endIndex,int splitAxis)
{
int i;
int splitIndex =startIndex;
int numIndices = endIndex - startIndex;
float splitValue;
SimdVector3 means(0.f,0.f,0.f);
for (int i=startIndex;i<endIndex;i++)
for (i=startIndex;i<endIndex;i++)
{
SimdVector3 center = 0.5f*(leafNodes[i].m_aabbMax+leafNodes[i].m_aabbMin);
means+=center;
}
means *= (1.f/(float)numIndices);
float splitValue = means[splitAxis];
splitValue = means[splitAxis];
//sort leafNodes so all values larger then splitValue comes first, and smaller values start from 'splitIndex'.
for (int i=startIndex;i<endIndex;i++)
for (i=startIndex;i<endIndex;i++)
{
SimdVector3 center = 0.5f*(leafNodes[i].m_aabbMax+leafNodes[i].m_aabbMin);
if (center[splitAxis] > splitValue)
@ -159,19 +163,20 @@ int OptimizedBvh::SortAndCalcSplittingIndex(NodeArray& leafNodes,int startIndex,
int OptimizedBvh::CalcSplittingAxis(NodeArray& leafNodes,int startIndex,int endIndex)
{
int i;
SimdVector3 means(0.f,0.f,0.f);
SimdVector3 variance(0.f,0.f,0.f);
int numIndices = endIndex-startIndex;
for (int i=startIndex;i<endIndex;i++)
for (i=startIndex;i<endIndex;i++)
{
SimdVector3 center = 0.5f*(leafNodes[i].m_aabbMax+leafNodes[i].m_aabbMin);
means+=center;
}
means *= (1.f/(float)numIndices);
SimdVector3 variance(0.f,0.f,0.f);
for (int i=startIndex;i<endIndex;i++)
for (i=startIndex;i<endIndex;i++)
{
SimdVector3 center = 0.5f*(leafNodes[i].m_aabbMax+leafNodes[i].m_aabbMin);
SimdVector3 diff2 = center-means;
@ -180,18 +185,18 @@ int OptimizedBvh::CalcSplittingAxis(NodeArray& leafNodes,int startIndex,int endI
}
variance *= (1.f/ ((float)numIndices-1) );
int biggestAxis = variance.maxAxis();
return biggestAxis;
return variance.maxAxis();
}
void OptimizedBvh::ReportAabbOverlappingNodex(NodeOverlapCallback* nodeCallback,const SimdVector3& aabbMin,const SimdVector3& aabbMax) const
{
int i;
if (aabbMin.length() > 1000.f)
{
for (int i=0;i<m_leafNodes.size();i++)
for (i=0;i<m_leafNodes.size();i++)
{
const OptimizedBvhNode& node = m_leafNodes[i];
nodeCallback->ProcessNode(&node);
@ -205,10 +210,10 @@ void OptimizedBvh::ReportAabbOverlappingNodex(NodeOverlapCallback* nodeCallback,
void OptimizedBvh::WalkTree(OptimizedBvhNode* rootNode,NodeOverlapCallback* nodeCallback,const SimdVector3& aabbMin,const SimdVector3& aabbMax) const
{
bool aabbOverlap = TestAabbAgainstAabb2(aabbMin,aabbMax,rootNode->m_aabbMin,rootNode->m_aabbMax);
bool isLeafNode, aabbOverlap = TestAabbAgainstAabb2(aabbMin,aabbMax,rootNode->m_aabbMin,rootNode->m_aabbMax);
if (aabbOverlap)
{
bool isLeafNode = (!rootNode->m_leftChild && !rootNode->m_rightChild);
isLeafNode = (!rootNode->m_leftChild && !rootNode->m_rightChild);
if (isLeafNode)
{
nodeCallback->ProcessNode(rootNode);
@ -225,8 +230,9 @@ int maxIterations = 0;
void OptimizedBvh::WalkStacklessTree(OptimizedBvhNode* rootNode,NodeOverlapCallback* nodeCallback,const SimdVector3& aabbMin,const SimdVector3& aabbMax) const
{
int curIndex = 0;
int escapeIndex, curIndex = 0;
int walkIterations = 0;
bool aabbOverlap, isLeafNode;
while (curIndex < m_curNodeIndex)
{
@ -234,8 +240,8 @@ void OptimizedBvh::WalkStacklessTree(OptimizedBvhNode* rootNode,NodeOverlapCallb
assert (walkIterations < m_curNodeIndex);
walkIterations++;
bool aabbOverlap = TestAabbAgainstAabb2(aabbMin,aabbMax,rootNode->m_aabbMin,rootNode->m_aabbMax);
bool isLeafNode = (!rootNode->m_leftChild && !rootNode->m_rightChild);
aabbOverlap = TestAabbAgainstAabb2(aabbMin,aabbMax,rootNode->m_aabbMin,rootNode->m_aabbMax);
isLeafNode = (!rootNode->m_leftChild && !rootNode->m_rightChild);
if (isLeafNode && aabbOverlap)
{
@ -248,7 +254,7 @@ void OptimizedBvh::WalkStacklessTree(OptimizedBvhNode* rootNode,NodeOverlapCallb
curIndex++;
} else
{
int escapeIndex = rootNode->m_escapeIndex;
escapeIndex = rootNode->m_escapeIndex;
rootNode += escapeIndex;
curIndex += escapeIndex;
}

@ -22,14 +22,7 @@ SphereShape ::SphereShape (SimdScalar radius)
SimdVector3 SphereShape::LocalGetSupportingVertexWithoutMargin(const SimdVector3& vec)const
{
float radius = m_radius - GetMargin();
SimdScalar len = vec.length2();
if (SimdFabs(len) < 0.0001f)
{
return SimdVector3(m_localScaling[0] * radius,m_localScaling[1]*radius,m_localScaling[2]*radius);
}
return vec * (m_localScaling*(radius / SimdSqrt(len)));
return SimdVector3(0.f,0.f,0.f);
}
SimdVector3 SphereShape::LocalGetSupportingVertex(const SimdVector3& vec)const
@ -37,38 +30,31 @@ SimdVector3 SphereShape::LocalGetSupportingVertex(const SimdVector3& vec)const
SimdVector3 supVertex;
supVertex = LocalGetSupportingVertexWithoutMargin(vec);
if ( GetMargin()!=0.f )
{
SimdVector3 vecnorm = vec;
if (vecnorm .length2() == 0.f)
if (SimdFuzzyZero(vecnorm .length2()))
{
vecnorm.setValue(-1.f,-1.f,-1.f);
}
vecnorm.normalize();
supVertex+= GetMargin() * vecnorm;
}
return supVertex;
}
/*
//broken due to scaling
void SphereShape::GetAabb(const SimdTransform& t,SimdVector3& aabbMin,SimdVector3& aabbMax) const
{
const SimdVector3& center = t.getOrigin();
SimdScalar radius = m_radius;
SimdVector3 extent = m_localScaling*radius;
extent+= SimdVector3(GetMargin(),GetMargin(),GetMargin());
SimdVector3 extent(GetMargin(),GetMargin(),GetMargin());
aabbMin = center - extent;
aabbMax = center + extent;
}
*/
void SphereShape::CalculateLocalInertia(SimdScalar mass,SimdVector3& inertia)
{
SimdScalar elem = 0.4f * mass * m_radius*m_radius;
SimdScalar elem = 0.4f * mass * GetMargin()*GetMargin();
inertia[0] = inertia[1] = inertia[2] = elem;
}

@ -31,7 +31,7 @@ public:
virtual void CalculateLocalInertia(SimdScalar mass,SimdVector3& inertia);
//virtual void GetAabb(const SimdTransform& t,SimdVector3& aabbMin,SimdVector3& aabbMax) const;
virtual void GetAabb(const SimdTransform& t,SimdVector3& aabbMin,SimdVector3& aabbMax) const;
virtual int GetShapeType() const { return SPHERE_SHAPE_PROXYTYPE; }
@ -40,6 +40,18 @@ public:
//debugging
virtual char* GetName()const {return "SPHERE";}
virtual void SetMargin(float margin)
{
ConvexShape::SetMargin(margin);
}
virtual float GetMargin() const
{
//to improve gjk behaviour, use radius+margin as the full margin, so never get into the penetration case
//this means, non-uniform scaling is not supported anymore
return m_localScaling[0] * m_radius + ConvexShape::GetMargin();
}
};

@ -153,7 +153,7 @@ void ConvexConcaveCollisionAlgorithm::ProcessCollision (BroadphaseProxy* ,Broadp
if (m_convex.IsConvexShape())
{
float collisionMarginTriangle = 0.02f;//triangleMesh->GetMargin();
float collisionMarginTriangle = triangleMesh->GetMargin();
m_boxTriangleCallback.SetTimeStepAndCounters(timeStep,stepCount, collisionMarginTriangle,useContinuous);
#ifdef USE_BOX_TRIANGLE

@ -14,17 +14,20 @@
static RigidBody s_fixed(MassProps(0,SimdVector3(0.f,0.f,0.f)),0.f,0.f,1.f,1.f);
static int gConstraintId = 1;
Point2PointConstraint::Point2PointConstraint():
m_rbA(s_fixed),m_rbB(s_fixed)
{
m_constraintId = gConstraintId++;//just create some unique ID for now
s_fixed.setMassProps(0.f,SimdVector3(0.f,0.f,0.f));
}
Point2PointConstraint::Point2PointConstraint(RigidBody& rbA,RigidBody& rbB, const SimdVector3& pivotInA,const SimdVector3& pivotInB)
:m_rbA(rbA),m_rbB(rbB),m_pivotInA(pivotInA),m_pivotInB(pivotInB)
{
m_constraintId = gConstraintId++;//just create some unique ID for now
}
@ -32,6 +35,7 @@ Point2PointConstraint::Point2PointConstraint(RigidBody& rbA,const SimdVector3& p
:m_rbA(rbA),m_rbB(s_fixed),m_pivotInA(pivotInA),m_pivotInB(rbA.getCenterOfMassTransform()(pivotInA))
{
s_fixed.setMassProps(0.f,SimdVector3(1e10f,1e10f,1e10f));
m_constraintId = gConstraintId++;//just create some unique ID for now
}
void Point2PointConstraint::BuildJacobian()

@ -27,6 +27,7 @@ class Point2PointConstraint
SimdVector3 m_pivotInA;
SimdVector3 m_pivotInB;
int m_constraintId;
public:
Point2PointConstraint(RigidBody& rbA,RigidBody& rbB, const SimdVector3& pivotInA,const SimdVector3& pivotInB);
@ -50,6 +51,11 @@ public:
return m_rbB;
}
int GetConstraintId()
{
return m_constraintId;
}
};

@ -57,6 +57,12 @@ bullet_sources = ['Bullet/BroadphaseCollision/BroadphaseProxy.cpp',
'Bullet/CollisionShapes/StridingMeshInterface.cpp',
'Bullet/CollisionShapes/TriangleMesh.cpp',
'Bullet/CollisionShapes/TriangleMeshShape.cpp',
'Bullet/CollisionShapes/BvhTriangleMeshShape.cpp',
'Bullet/CollisionShapes/ConvexTriangleCallback.cpp',
'Bullet/CollisionShapes/EmptyShape.cpp',
'Bullet/CollisionShapes/OptimizedBvh.cpp',
'Bullet/CollisionShapes/TriangleCallback.cpp',
'Bullet/CollisionShapes/TriangleIndexVertexArray.cpp',
'Bullet/NarrowPhaseCollision/BU_AlgebraicPolynomialSolver.cpp',
'Bullet/NarrowPhaseCollision/BU_Collidable.cpp',
@ -73,6 +79,7 @@ bullet_sources = ['Bullet/BroadphaseCollision/BroadphaseProxy.cpp',
'Bullet/NarrowPhaseCollision/RaycastCallback.cpp',
'Bullet/NarrowPhaseCollision/SubSimplexConvexCast.cpp',
'Bullet/NarrowPhaseCollision/VoronoiSimplexSolver.cpp',
'Bullet/NarrowPhaseCollision/ManifoldContactAddResult.cpp',
'BulletDynamics/CollisionDispatch/ConvexConcaveCollisionAlgorithm.cpp',
'BulletDynamics/CollisionDispatch/ConvexConvexAlgorithm.cpp',

@ -716,9 +716,6 @@ ECHO Done
<File
RelativePath="..\..\Bullet\NarrowPhaseCollision\BU_VertexPoly.h">
</File>
<File
RelativePath="..\..\Bullet\NarrowPhaseCollision\CollisionMargin.h">
</File>
<File
RelativePath="..\..\Bullet\NarrowPhaseCollision\ContinuousConvexCollision.h">
</File>
@ -796,6 +793,9 @@ ECHO Done
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
</File>
<File
RelativePath="..\..\Bullet\CollisionShapes\BvhTriangleMeshShape.cpp">
</File>
<File
RelativePath="..\..\Bullet\CollisionShapes\CollisionShape.cpp">
<FileConfiguration
@ -904,6 +904,9 @@ ECHO Done
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
</File>
<File
RelativePath="..\..\Bullet\CollisionShapes\ConvexTriangleCallback.cpp">
</File>
<File
RelativePath="..\..\Bullet\CollisionShapes\CylinderShape.cpp">
<FileConfiguration
@ -931,6 +934,9 @@ ECHO Done
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
</File>
<File
RelativePath="..\..\Bullet\CollisionShapes\EmptyShape.cpp">
</File>
<File
RelativePath="..\..\Bullet\CollisionShapes\MinkowskiSumShape.cpp">
<FileConfiguration
@ -985,6 +991,9 @@ ECHO Done
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
</File>
<File
RelativePath="..\..\Bullet\CollisionShapes\OptimizedBvh.cpp">
</File>
<File
RelativePath="..\..\Bullet\CollisionShapes\PolyhedralConvexShape.cpp">
<FileConfiguration
@ -1093,6 +1102,12 @@ ECHO Done
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
</File>
<File
RelativePath="..\..\Bullet\CollisionShapes\TriangleCallback.cpp">
</File>
<File
RelativePath="..\..\Bullet\CollisionShapes\TriangleIndexVertexArray.cpp">
</File>
<File
RelativePath="..\..\Bullet\CollisionShapes\TriangleMesh.cpp">
<FileConfiguration
@ -1154,6 +1169,12 @@ ECHO Done
<File
RelativePath="..\..\Bullet\CollisionShapes\BoxShape.h">
</File>
<File
RelativePath="..\..\Bullet\CollisionShapes\BvhTriangleMeshShape.h">
</File>
<File
RelativePath="..\..\Bullet\CollisionShapes\CollisionMargin.h">
</File>
<File
RelativePath="..\..\Bullet\CollisionShapes\CollisionShape.h">
</File>
@ -1166,15 +1187,24 @@ ECHO Done
<File
RelativePath="..\..\Bullet\CollisionShapes\ConvexShape.h">
</File>
<File
RelativePath="..\..\Bullet\CollisionShapes\ConvexTriangleCallback.h">
</File>
<File
RelativePath="..\..\Bullet\CollisionShapes\CylinderShape.h">
</File>
<File
RelativePath="..\..\Bullet\CollisionShapes\EmptyShape.h">
</File>
<File
RelativePath="..\..\Bullet\CollisionShapes\MinkowskiSumShape.h">
</File>
<File
RelativePath="..\..\Bullet\CollisionShapes\MultiSphereShape.h">
</File>
<File
RelativePath="..\..\Bullet\CollisionShapes\OptimizedBvh.h">
</File>
<File
RelativePath="..\..\Bullet\CollisionShapes\PolyhedralConvexShape.h">
</File>
@ -1190,6 +1220,9 @@ ECHO Done
<File
RelativePath="..\..\Bullet\CollisionShapes\TriangleCallback.h">
</File>
<File
RelativePath="..\..\Bullet\CollisionShapes\TriangleIndexVertexArray.h">
</File>
<File
RelativePath="..\..\Bullet\CollisionShapes\TriangleMesh.h">
</File>