Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErwin Coumans <blender@erwincoumans.com>2006-11-13 00:05:10 +0300
committerErwin Coumans <blender@erwincoumans.com>2006-11-13 00:05:10 +0300
commit3a1b7ece402001f2f93669a7b36c32f5e7827bab (patch)
treea91e600407b0709922b7df3fa2a53f380cf7eb76 /extern/bullet2/src/BulletCollision/CollisionShapes
parent22d97b2e346e3cb3fc38704a0460e2dd4d9a0abb (diff)
updating Bullet 2.x with latest changes. The integration + C-API will follow at some stage.
Diffstat (limited to 'extern/bullet2/src/BulletCollision/CollisionShapes')
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btBoxShape.h31
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btConvexShape.h13
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btMultiSphereShape.cpp12
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btMultiSphereShape.h4
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleBuffer.cpp41
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleBuffer.h60
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleMesh.h9
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleShape.h12
8 files changed, 172 insertions, 10 deletions
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btBoxShape.h b/extern/bullet2/src/BulletCollision/CollisionShapes/btBoxShape.h
index b137eb1150e..e85a36c0b73 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btBoxShape.h
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btBoxShape.h
@@ -255,6 +255,37 @@ public:
return "Box";
}
+ virtual int getNumPreferredPenetrationDirections() const
+ {
+ return 6;
+ }
+
+ virtual void getPreferredPenetrationDirection(int index, btVector3& penetrationVector) const
+ {
+ switch (index)
+ {
+ case 0:
+ penetrationVector.setValue(1.f,0.f,0.f);
+ break;
+ case 1:
+ penetrationVector.setValue(-1.f,0.f,0.f);
+ break;
+ case 2:
+ penetrationVector.setValue(0.f,1.f,0.f);
+ break;
+ case 3:
+ penetrationVector.setValue(0.f,-1.f,0.f);
+ break;
+ case 4:
+ penetrationVector.setValue(0.f,0.f,1.f);
+ break;
+ case 5:
+ penetrationVector.setValue(0.f,0.f,-1.f);
+ break;
+ default:
+ assert(0);
+ }
+ }
};
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btConvexShape.h b/extern/bullet2/src/BulletCollision/CollisionShapes/btConvexShape.h
index 3ffde1ba5ed..0de334b3521 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btConvexShape.h
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btConvexShape.h
@@ -26,7 +26,7 @@ subject to the following restrictions:
//todo: get rid of this btConvexCastResult thing!
struct btConvexCastResult;
-
+#define MAX_PREFERRED_PENETRATION_DIRECTIONS 10
/// btConvexShape is an abstract shape interface.
/// The explicit part provides plane-equations, the implicit part provides GetClosestPoint interface.
@@ -84,6 +84,17 @@ public:
return m_collisionMargin;
}
+ virtual int getNumPreferredPenetrationDirections() const
+ {
+ return 0;
+ }
+
+ virtual void getPreferredPenetrationDirection(int index, btVector3& penetrationVector) const
+ {
+ assert(0);
+ }
+
+
};
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btMultiSphereShape.cpp b/extern/bullet2/src/BulletCollision/CollisionShapes/btMultiSphereShape.cpp
index aaadb82eb4b..fde4d95da14 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btMultiSphereShape.cpp
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btMultiSphereShape.cpp
@@ -20,17 +20,17 @@ subject to the following restrictions:
btMultiSphereShape::btMultiSphereShape (const btVector3& inertiaHalfExtents,const btVector3* positions,const btScalar* radi,int numSpheres)
:m_inertiaHalfExtents(inertiaHalfExtents)
{
- m_minRadius = 1e30f;
+ float startMargin = 1e30f;
m_numSpheres = numSpheres;
for (int i=0;i<m_numSpheres;i++)
{
m_localPositions[i] = positions[i];
m_radi[i] = radi[i];
- if (radi[i] < m_minRadius)
- m_minRadius = radi[i];
+ if (radi[i] < startMargin)
+ startMargin = radi[i];
}
- setMargin(m_minRadius);
+ setMargin(startMargin);
}
@@ -64,7 +64,7 @@ btMultiSphereShape::btMultiSphereShape (const btVector3& inertiaHalfExtents,cons
for (i=0;i<m_numSpheres;i++)
{
- vtx = (*pos) +vec*((*rad)-m_minRadius);
+ vtx = (*pos) +vec*m_localScaling*(*rad) - vec * getMargin();
pos++;
rad++;
newDot = vec.dot(vtx);
@@ -96,7 +96,7 @@ btMultiSphereShape::btMultiSphereShape (const btVector3& inertiaHalfExtents,cons
for (int i=0;i<m_numSpheres;i++)
{
- vtx = (*pos) +vec*((*rad)-m_minRadius);
+ vtx = (*pos) +vec*m_localScaling*(*rad) - vec * getMargin();
pos++;
rad++;
newDot = vec.dot(vtx);
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btMultiSphereShape.h b/extern/bullet2/src/BulletCollision/CollisionShapes/btMultiSphereShape.h
index 6a9151df281..2dde9d3855a 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btMultiSphereShape.h
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btMultiSphereShape.h
@@ -31,9 +31,7 @@ class btMultiSphereShape : public btConvexShape
btVector3 m_inertiaHalfExtents;
int m_numSpheres;
- float m_minRadius;
-
-
+
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleBuffer.cpp b/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleBuffer.cpp
new file mode 100644
index 00000000000..078ba38fdf4
--- /dev/null
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleBuffer.cpp
@@ -0,0 +1,41 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
+
+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.
+*/
+
+#include "btTriangleBuffer.h"
+
+
+///example usage of this class:
+// btTriangleBuffer triBuf;
+// concaveShape->processAllTriangles(&triBuf,aabbMin, aabbMax);
+// for (int i=0;i<triBuf.getNumTriangles();i++)
+// {
+// const btTriangle& tri = triBuf.getTriangle(i);
+// //do something useful here with the triangle
+// }
+
+
+
+
+void btTriangleBuffer::processTriangle(btVector3* triangle,int partId,int triangleIndex)
+{
+ btTriangle tri;
+ tri.m_vertex0 = triangle[0];
+ tri.m_vertex1 = triangle[1];
+ tri.m_vertex2 = triangle[2];
+ tri.m_partId = partId;
+ tri.m_triangleIndex = triangleIndex;
+
+ m_triangleBuffer.push_back(tri);
+}
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleBuffer.h b/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleBuffer.h
new file mode 100644
index 00000000000..4f421a616c8
--- /dev/null
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleBuffer.h
@@ -0,0 +1,60 @@
+/*
+Bullet Continuous Collision Detection and Physics Library
+Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
+
+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.
+*/
+
+#ifndef BT_TRIANGLE_BUFFER_H
+#define BT_TRIANGLE_BUFFER_H
+
+#include "btTriangleCallback.h"
+#include <vector>
+
+struct btTriangle
+{
+ btVector3 m_vertex0;
+ btVector3 m_vertex1;
+ btVector3 m_vertex2;
+ int m_partId;
+ int m_triangleIndex;
+};
+
+///btTriangleBuffer can be useful to collect and store overlapping triangles between AABB and concave objects that support 'processAllTriangles'
+class btTriangleBuffer : public btTriangleCallback
+{
+
+ std::vector<btTriangle> m_triangleBuffer;
+
+public:
+
+
+ virtual void processTriangle(btVector3* triangle, int partId, int triangleIndex);
+
+ int getNumTriangles() const
+ {
+ return int(m_triangleBuffer.size());
+ }
+
+ const btTriangle& getTriangle(int index) const
+ {
+ return m_triangleBuffer[index];
+ }
+
+ void clearBuffer()
+ {
+ m_triangleBuffer.clear();
+ }
+
+};
+
+
+#endif //BT_TRIANGLE_BUFFER_H \ No newline at end of file
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleMesh.h b/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleMesh.h
index 690d1e849de..171dcf33b15 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleMesh.h
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleMesh.h
@@ -46,6 +46,15 @@ class btTriangleMesh : public btStridingMeshInterface
m_triangles.push_back(tri);
}
+ int getNumTriangles() const
+ {
+ return m_triangles.size();
+ }
+
+ const btMyTriangle& getTriangle(int index) const
+ {
+ return m_triangles[index];
+ }
//StridingMeshInterface interface implementation
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleShape.h b/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleShape.h
index 8f0a06f7586..8e6e2daa4fb 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleShape.h
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleShape.h
@@ -157,6 +157,18 @@ public:
return "Triangle";
}
+ virtual int getNumPreferredPenetrationDirections() const
+ {
+ return 2;
+ }
+
+ virtual void getPreferredPenetrationDirection(int index, btVector3& penetrationVector) const
+ {
+ calcNormal(penetrationVector);
+ if (index)
+ penetrationVector *= -1.f;
+ }
+
};