diff options
Diffstat (limited to 'extern/bullet/Bullet')
-rw-r--r-- | extern/bullet/Bullet/BLI_Bullet.dsp | 60 | ||||
-rw-r--r-- | extern/bullet/Bullet/Bullet3_vc8.vcproj | 53 | ||||
-rw-r--r-- | extern/bullet/Bullet/CollisionShapes/OptimizedBvh.cpp | 52 | ||||
-rw-r--r-- | extern/bullet/Bullet/CollisionShapes/SphereShape.cpp | 36 | ||||
-rw-r--r-- | extern/bullet/Bullet/CollisionShapes/SphereShape.h | 16 |
5 files changed, 163 insertions, 54 deletions
diff --git a/extern/bullet/Bullet/BLI_Bullet.dsp b/extern/bullet/Bullet/BLI_Bullet.dsp index 48b6e8bb335..dad314f72ba 100644 --- a/extern/bullet/Bullet/BLI_Bullet.dsp +++ b/extern/bullet/Bullet/BLI_Bullet.dsp @@ -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 diff --git a/extern/bullet/Bullet/Bullet3_vc8.vcproj b/extern/bullet/Bullet/Bullet3_vc8.vcproj index b9046f451e5..4c8bc67557b 100644 --- a/extern/bullet/Bullet/Bullet3_vc8.vcproj +++ b/extern/bullet/Bullet/Bullet3_vc8.vcproj @@ -42,6 +42,7 @@ Optimization="0" AdditionalIncludeDirectories=".;..\LinearMath" PreprocessorDefinitions="_DEBUG;_LIB;WIN32;BUM_INLINED;USE_ALGEBRAIC" + ExceptionHandling="0" BasicRuntimeChecks="3" RuntimeLibrary="1" UsePrecompiledHeader="0" @@ -273,6 +274,14 @@ > </File> <File + RelativePath=".\NarrowPhaseCollision\ManifoldContactAddResult.cpp" + > + </File> + <File + RelativePath=".\NarrowPhaseCollision\ManifoldContactAddResult.h" + > + </File> + <File RelativePath=".\NarrowPhaseCollision\ManifoldPoint.h" > </File> @@ -369,6 +378,14 @@ > </File> <File + RelativePath=".\CollisionShapes\ConvexTriangleCallback.cpp" + > + </File> + <File + RelativePath=".\CollisionShapes\ConvexTriangleCallback.h" + > + </File> + <File RelativePath=".\CollisionShapes\CylinderShape.cpp" > </File> @@ -377,6 +394,14 @@ > </File> <File + RelativePath=".\CollisionShapes\EmptyShape.cpp" + > + </File> + <File + RelativePath=".\CollisionShapes\EmptyShape.h" + > + </File> + <File RelativePath=".\CollisionShapes\MinkowskiSumShape.cpp" > </File> @@ -425,6 +450,10 @@ > </File> <File + RelativePath=".\CollisionShapes\TriangleCallback.cpp" + > + </File> + <File RelativePath=".\CollisionShapes\TriangleCallback.h" > </File> @@ -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> diff --git a/extern/bullet/Bullet/CollisionShapes/OptimizedBvh.cpp b/extern/bullet/Bullet/CollisionShapes/OptimizedBvh.cpp index fe3a51883ec..a07e2919bd6 100644 --- a/extern/bullet/Bullet/CollisionShapes/OptimizedBvh.cpp +++ b/extern/bullet/Bullet/CollisionShapes/OptimizedBvh.cpp @@ -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; } diff --git a/extern/bullet/Bullet/CollisionShapes/SphereShape.cpp b/extern/bullet/Bullet/CollisionShapes/SphereShape.cpp index bbffb8137de..37d34a65948 100644 --- a/extern/bullet/Bullet/CollisionShapes/SphereShape.cpp +++ b/extern/bullet/Bullet/CollisionShapes/SphereShape.cpp @@ -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 (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 diff --git a/extern/bullet/Bullet/CollisionShapes/SphereShape.h b/extern/bullet/Bullet/CollisionShapes/SphereShape.h index 82c00ea43eb..235af6c4db2 100644 --- a/extern/bullet/Bullet/CollisionShapes/SphereShape.h +++ b/extern/bullet/Bullet/CollisionShapes/SphereShape.h @@ -20,7 +20,7 @@ class SphereShape : public ConvexShape { SimdScalar m_radius; - + public: SphereShape (SimdScalar radius); @@ -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(); + } + + }; |