# 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
# 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
# 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
# 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
# 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
# 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
# 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
Optimization="0"
AdditionalIncludeDirectories=".;..\LinearMath"
PreprocessorDefinitions="_DEBUG;_LIB;WIN32;BUM_INLINED;USE_ALGEBRAIC"
+ ExceptionHandling="0"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
RelativePath=".\NarrowPhaseCollision\GjkPairDetector.h"
>
</File>
+ <File
+ RelativePath=".\NarrowPhaseCollision\ManifoldContactAddResult.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\NarrowPhaseCollision\ManifoldContactAddResult.h"
+ >
+ </File>
<File
RelativePath=".\NarrowPhaseCollision\ManifoldPoint.h"
>
RelativePath=".\CollisionShapes\ConvexShape.h"
>
</File>
+ <File
+ RelativePath=".\CollisionShapes\ConvexTriangleCallback.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\CollisionShapes\ConvexTriangleCallback.h"
+ >
+ </File>
<File
RelativePath=".\CollisionShapes\CylinderShape.cpp"
>
RelativePath=".\CollisionShapes\CylinderShape.h"
>
</File>
+ <File
+ RelativePath=".\CollisionShapes\EmptyShape.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\CollisionShapes\EmptyShape.h"
+ >
+ </File>
<File
RelativePath=".\CollisionShapes\MinkowskiSumShape.cpp"
>
RelativePath=".\CollisionShapes\StridingMeshInterface.h"
>
</File>
+ <File
+ RelativePath=".\CollisionShapes\TriangleCallback.cpp"
+ >
+ </File>
<File
RelativePath=".\CollisionShapes\TriangleCallback.h"
>
>
</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>
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);
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)
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;
}
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);
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);
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)
{
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)
{
curIndex++;
} else
{
- int escapeIndex = rootNode->m_escapeIndex;
+ escapeIndex = rootNode->m_escapeIndex;
rootNode += escapeIndex;
curIndex += escapeIndex;
}
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
SimdVector3 supVertex;
supVertex = LocalGetSupportingVertexWithoutMargin(vec);
- if ( GetMargin()!=0.f )
+ SimdVector3 vecnorm = vec;
+ if (SimdFuzzyZero(vecnorm .length2()))
{
- SimdVector3 vecnorm = vec;
- if (vecnorm .length2() == 0.f)
- {
- vecnorm.setValue(-1.f,-1.f,-1.f);
- }
- vecnorm.normalize();
- supVertex+= GetMargin() * vecnorm;
- }
+ 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;
}
\ No newline at end of file
{
SimdScalar m_radius;
-
+
public:
SphereShape (SimdScalar radius);
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; }
//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();
+ }
+
+
};
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
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
}
: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()
SimdVector3 m_pivotInA;
SimdVector3 m_pivotInB;
+ int m_constraintId;
public:
Point2PointConstraint(RigidBody& rbA,RigidBody& rbB, const SimdVector3& pivotInA,const SimdVector3& pivotInB);
return m_rbB;
}
+ int GetConstraintId()
+ {
+ return m_constraintId;
+ }
+
};
'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',
'Bullet/NarrowPhaseCollision/BU_CollisionPair.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',
'BulletDynamics/CollisionDispatch/EmptyCollisionAlgorithm.cpp',
<File
RelativePath="..\..\Bullet\NarrowPhaseCollision\BU_VertexPoly.h">
</File>
- <File
- RelativePath="..\..\Bullet\NarrowPhaseCollision\CollisionMargin.h">
- </File>
<File
RelativePath="..\..\Bullet\NarrowPhaseCollision\ContinuousConvexCollision.h">
</File>
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
</File>
+ <File
+ RelativePath="..\..\Bullet\CollisionShapes\BvhTriangleMeshShape.cpp">
+ </File>
<File
RelativePath="..\..\Bullet\CollisionShapes\CollisionShape.cpp">
<FileConfiguration
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
</File>
+ <File
+ RelativePath="..\..\Bullet\CollisionShapes\ConvexTriangleCallback.cpp">
+ </File>
<File
RelativePath="..\..\Bullet\CollisionShapes\CylinderShape.cpp">
<FileConfiguration
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
</File>
+ <File
+ RelativePath="..\..\Bullet\CollisionShapes\EmptyShape.cpp">
+ </File>
<File
RelativePath="..\..\Bullet\CollisionShapes\MinkowskiSumShape.cpp">
<FileConfiguration
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
</File>
+ <File
+ RelativePath="..\..\Bullet\CollisionShapes\OptimizedBvh.cpp">
+ </File>
<File
RelativePath="..\..\Bullet\CollisionShapes\PolyhedralConvexShape.cpp">
<FileConfiguration
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
<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>
<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>
<File
RelativePath="..\..\Bullet\CollisionShapes\TriangleCallback.h">
</File>
+ <File
+ RelativePath="..\..\Bullet\CollisionShapes\TriangleIndexVertexArray.h">
+ </File>
<File
RelativePath="..\..\Bullet\CollisionShapes\TriangleMesh.h">
</File>