+ more consistent 'setLocalScaling' for the btCompoundShape. Full non-uniform scaling is not supported when child shapes have a rotation. If any child shapes have rotation, the best you can do is either uniform scaling, or 'baking' the non-uniform scaling into the child geometry (vertices of a convex hull for example)
+ fixed an issue with BulletWorldImporter, btBoxShape implicitShapeDimensions already includes local scaling.
This commit is contained in:
@@ -64,12 +64,14 @@ btCollisionShape* btBulletWorldImporter::convertCollisionShape( btCollisionShap
|
|||||||
btConvexInternalShapeData* bsd = (btConvexInternalShapeData*)shapeData;
|
btConvexInternalShapeData* bsd = (btConvexInternalShapeData*)shapeData;
|
||||||
btVector3 implicitShapeDimensions;
|
btVector3 implicitShapeDimensions;
|
||||||
implicitShapeDimensions.deSerializeFloat(bsd->m_implicitShapeDimensions);
|
implicitShapeDimensions.deSerializeFloat(bsd->m_implicitShapeDimensions);
|
||||||
|
btVector3 localScaling;
|
||||||
|
localScaling.deSerializeFloat(bsd->m_localScaling);
|
||||||
btVector3 margin(bsd->m_collisionMargin,bsd->m_collisionMargin,bsd->m_collisionMargin);
|
btVector3 margin(bsd->m_collisionMargin,bsd->m_collisionMargin,bsd->m_collisionMargin);
|
||||||
switch (shapeData->m_shapeType)
|
switch (shapeData->m_shapeType)
|
||||||
{
|
{
|
||||||
case BOX_SHAPE_PROXYTYPE:
|
case BOX_SHAPE_PROXYTYPE:
|
||||||
{
|
{
|
||||||
shape = createBoxShape(implicitShapeDimensions+margin);
|
shape = createBoxShape(implicitShapeDimensions/localScaling+margin);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SPHERE_SHAPE_PROXYTYPE:
|
case SPHERE_SHAPE_PROXYTYPE:
|
||||||
|
|||||||
@@ -267,18 +267,19 @@ void btCompoundShape::calculatePrincipalAxisTransform(btScalar* masses, btTransf
|
|||||||
|
|
||||||
void btCompoundShape::setLocalScaling(const btVector3& scaling)
|
void btCompoundShape::setLocalScaling(const btVector3& scaling)
|
||||||
{
|
{
|
||||||
m_localScaling = scaling;
|
|
||||||
|
|
||||||
for(int i = 0; i < m_children.size(); i++)
|
for(int i = 0; i < m_children.size(); i++)
|
||||||
{
|
{
|
||||||
btTransform childTrans = getChildTransform(i);
|
btTransform childTrans = getChildTransform(i);
|
||||||
btVector3 childScale = m_children[i].m_childShape->getLocalScaling();
|
btVector3 childScale = m_children[i].m_childShape->getLocalScaling();
|
||||||
childScale = childScale * (childTrans.getBasis() * scaling);
|
// childScale = childScale * (childTrans.getBasis() * scaling);
|
||||||
|
childScale = childScale * scaling / m_localScaling;
|
||||||
m_children[i].m_childShape->setLocalScaling(childScale);
|
m_children[i].m_childShape->setLocalScaling(childScale);
|
||||||
childTrans.setOrigin((childTrans.getOrigin())*scaling);
|
childTrans.setOrigin((childTrans.getOrigin())*scaling);
|
||||||
updateChildTransform(i, childTrans);
|
updateChildTransform(i, childTrans);
|
||||||
recalculateLocalAabb();
|
recalculateLocalAabb();
|
||||||
}
|
}
|
||||||
|
m_localScaling = scaling;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user