summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErwin Coumans <erwin.coumans@gmail.com>2020-08-10 17:00:19 -0700
committerErwin Coumans <erwin.coumans@gmail.com>2020-08-10 17:00:19 -0700
commit7d9bcafda8649dee657a727bc2f5d1a4c6beb609 (patch)
treec31d261a979bfe230027fad6dd42498193b8edba
parent39500cccaade0beec53e7343f7e03597ff880b8b (diff)
downloadbullet3-7d9bcafda8649dee657a727bc2f5d1a4c6beb609.tar.gz
when using stablePDPlugin, approximate inertia by box for unsupported shapes.
-rw-r--r--examples/SharedMemory/plugins/stablePDPlugin/BulletConversion.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/examples/SharedMemory/plugins/stablePDPlugin/BulletConversion.cpp b/examples/SharedMemory/plugins/stablePDPlugin/BulletConversion.cpp
index 224afaf9a..cb6bacd33 100644
--- a/examples/SharedMemory/plugins/stablePDPlugin/BulletConversion.cpp
+++ b/examples/SharedMemory/plugins/stablePDPlugin/BulletConversion.cpp
@@ -93,6 +93,7 @@ bool btExtractJointBodyFromTempLinks(btAlignedObjectArray<TempLink>& links, Eige
collisionShape = compound->getChildShape(0);
}
}
+
switch (collisionShape->getShapeType())
{
case BOX_SHAPE_PROXYTYPE:
@@ -102,6 +103,7 @@ bool btExtractJointBodyFromTempLinks(btAlignedObjectArray<TempLink>& links, Eige
param0 = box->getHalfExtentsWithMargin()[0] * 2;
param1 = box->getHalfExtentsWithMargin()[1] * 2;
param2 = box->getHalfExtentsWithMargin()[2] * 2;
+
break;
}
case SPHERE_SHAPE_PROXYTYPE:
@@ -124,7 +126,20 @@ bool btExtractJointBodyFromTempLinks(btAlignedObjectArray<TempLink>& links, Eige
}
default:
{
- btAssert(0);
+ //approximate by its box
+ btTransform identity;
+ identity.setIdentity();
+ btVector3 aabbMin, aabbMax;
+ collisionShape->getAabb(identity, aabbMin, aabbMax);
+ btVector3 halfExtents = (aabbMax - aabbMin) * btScalar(0.5);
+ btScalar margin = collisionShape->getMargin();
+ btScalar lx = btScalar(2.) * (halfExtents.x() + margin);
+ btScalar ly = btScalar(2.) * (halfExtents.y() + margin);
+ btScalar lz = btScalar(2.) * (halfExtents.z() + margin);
+ param0 = lx;
+ param1 = ly;
+ param2 = lz;
+ shapeType = cShape::eShapeBox;
}
}
}