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:
authorDavid Vogel <Dadido3>2020-07-30 19:35:34 +0300
committerSebastian Parborg <darkdefende@gmail.com>2020-07-30 19:53:35 +0300
commit820ca419e098f1ac90b499180a3206dd44692ba8 (patch)
treea2b7288ca2a8a9124b4977ae0a03cadd41282ecd /extern/bullet2
parentd3944940f9862386cfad692b9d338b670584908c (diff)
Add compound shape for rigid body simulation
This patch adds a new compound shape entry to the shape selection dropdown. It also corrects wrong inertia calculation for convex hulls, that resulted in strange behavior for small objects. The compound shape take the collision shapes from its object children and combines them. This makes it possible to create concave shapes from primitive shapes. Using this instead of the mesh collision shape is often many times faster. Reviewed By: Sergey, Sebastian Parborg Differential Revision: http://developer.blender.org/D5797
Diffstat (limited to 'extern/bullet2')
-rw-r--r--extern/bullet2/patches/btPolyhedralConvexShape_Inertia_fix.patch41
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btCompoundShape.cpp2
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp16
3 files changed, 50 insertions, 9 deletions
diff --git a/extern/bullet2/patches/btPolyhedralConvexShape_Inertia_fix.patch b/extern/bullet2/patches/btPolyhedralConvexShape_Inertia_fix.patch
new file mode 100644
index 00000000000..abafb5855dd
--- /dev/null
+++ b/extern/bullet2/patches/btPolyhedralConvexShape_Inertia_fix.patch
@@ -0,0 +1,41 @@
+diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp b/extern/bullet2/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp
+index 9095c592d87..b831e20c2f9 100644
+--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp
++++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp
+@@ -406,17 +406,17 @@ void btPolyhedralConvexShape::calculateLocalInertia(btScalar mass,btVector3& ine
+ #ifndef __SPU__
+ //not yet, return box inertia
+
+- btScalar margin = getMargin();
++ //btScalar margin = getMargin();
+
+ btTransform ident;
+ ident.setIdentity();
+ btVector3 aabbMin,aabbMax;
+- getAabb(ident,aabbMin,aabbMax);
++ getAabb(ident,aabbMin,aabbMax); // This already contains the margin
+ btVector3 halfExtents = (aabbMax-aabbMin)*btScalar(0.5);
+
+- btScalar lx=btScalar(2.)*(halfExtents.x()+margin);
+- btScalar ly=btScalar(2.)*(halfExtents.y()+margin);
+- btScalar lz=btScalar(2.)*(halfExtents.z()+margin);
++ btScalar lx=btScalar(2.)*(halfExtents.x());
++ btScalar ly=btScalar(2.)*(halfExtents.y());
++ btScalar lz=btScalar(2.)*(halfExtents.z());
+ const btScalar x2 = lx*lx;
+ const btScalar y2 = ly*ly;
+ const btScalar z2 = lz*lz;
+@@ -476,10 +476,10 @@ void btPolyhedralConvexAabbCachingShape::recalcLocalAabb()
+
+ for ( int i = 0; i < 3; ++i )
+ {
+- m_localAabbMax[i] = _supporting[i][i] + m_collisionMargin;
+- m_localAabbMin[i] = _supporting[i + 3][i] - m_collisionMargin;
++ m_localAabbMax[i] = _supporting[i][i];
++ m_localAabbMin[i] = _supporting[i + 3][i];
+ }
+-
++
+ #else
+
+ for (int i=0;i<3;i++)
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btCompoundShape.cpp b/extern/bullet2/src/BulletCollision/CollisionShapes/btCompoundShape.cpp
index e8c8c336cd2..1e7f36e0a17 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btCompoundShape.cpp
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btCompoundShape.cpp
@@ -180,7 +180,7 @@ void btCompoundShape::getAabb(const btTransform& trans,btVector3& aabbMin,btVect
localHalfExtents += btVector3(getMargin(),getMargin(),getMargin());
- btMatrix3x3 abs_b = trans.getBasis().absolute();
+ btMatrix3x3 abs_b = trans.getBasis().absolute();
btVector3 center = trans(localCenter);
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp b/extern/bullet2/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp
index 9095c592d87..b831e20c2f9 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp
@@ -406,17 +406,17 @@ void btPolyhedralConvexShape::calculateLocalInertia(btScalar mass,btVector3& ine
#ifndef __SPU__
//not yet, return box inertia
- btScalar margin = getMargin();
+ //btScalar margin = getMargin();
btTransform ident;
ident.setIdentity();
btVector3 aabbMin,aabbMax;
- getAabb(ident,aabbMin,aabbMax);
+ getAabb(ident,aabbMin,aabbMax); // This already contains the margin
btVector3 halfExtents = (aabbMax-aabbMin)*btScalar(0.5);
- btScalar lx=btScalar(2.)*(halfExtents.x()+margin);
- btScalar ly=btScalar(2.)*(halfExtents.y()+margin);
- btScalar lz=btScalar(2.)*(halfExtents.z()+margin);
+ btScalar lx=btScalar(2.)*(halfExtents.x());
+ btScalar ly=btScalar(2.)*(halfExtents.y());
+ btScalar lz=btScalar(2.)*(halfExtents.z());
const btScalar x2 = lx*lx;
const btScalar y2 = ly*ly;
const btScalar z2 = lz*lz;
@@ -476,10 +476,10 @@ void btPolyhedralConvexAabbCachingShape::recalcLocalAabb()
for ( int i = 0; i < 3; ++i )
{
- m_localAabbMax[i] = _supporting[i][i] + m_collisionMargin;
- m_localAabbMin[i] = _supporting[i + 3][i] - m_collisionMargin;
+ m_localAabbMax[i] = _supporting[i][i];
+ m_localAabbMin[i] = _supporting[i + 3][i];
}
-
+
#else
for (int i=0;i<3;i++)