Performance optimization for btCompoundShape::setLocalScaling
Thanks to Mirza, See Issue 487 backward compatibility fix for recent improvement in btRaycastVehicle 'rollinfluence' Thanks to Mihail, See Issue 468
This commit is contained in:
@@ -85,7 +85,7 @@ void btCompoundShape::addChildShape(const btTransform& localTransform,btCollisio
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void btCompoundShape::updateChildTransform(int childIndex, const btTransform& newChildTransform)
|
void btCompoundShape::updateChildTransform(int childIndex, const btTransform& newChildTransform,bool shouldRecalculateLocalAabb)
|
||||||
{
|
{
|
||||||
m_children[childIndex].m_transform = newChildTransform;
|
m_children[childIndex].m_transform = newChildTransform;
|
||||||
|
|
||||||
@@ -99,7 +99,10 @@ void btCompoundShape::updateChildTransform(int childIndex, const btTransform& ne
|
|||||||
m_dynamicAabbTree->update(m_children[childIndex].m_node,bounds);
|
m_dynamicAabbTree->update(m_children[childIndex].m_node,bounds);
|
||||||
}
|
}
|
||||||
|
|
||||||
recalculateLocalAabb();
|
if (shouldRecalculateLocalAabb)
|
||||||
|
{
|
||||||
|
recalculateLocalAabb();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void btCompoundShape::removeChildShapeByIndex(int childShapeIndex)
|
void btCompoundShape::removeChildShapeByIndex(int childShapeIndex)
|
||||||
@@ -283,10 +286,12 @@ void btCompoundShape::setLocalScaling(const btVector3& scaling)
|
|||||||
childScale = childScale * scaling / m_localScaling;
|
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,false);
|
||||||
recalculateLocalAabb();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_localScaling = scaling;
|
m_localScaling = scaling;
|
||||||
|
recalculateLocalAabb();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
///set a new transform for a child, and update internal data structures (local aabb and dynamic tree)
|
///set a new transform for a child, and update internal data structures (local aabb and dynamic tree)
|
||||||
void updateChildTransform(int childIndex, const btTransform& newChildTransform);
|
void updateChildTransform(int childIndex, const btTransform& newChildTransform, bool shouldRecalculateLocalAabb = true);
|
||||||
|
|
||||||
|
|
||||||
btCompoundShapeChild* getChildList()
|
btCompoundShapeChild* getChildList()
|
||||||
|
|||||||
@@ -699,7 +699,7 @@ void btRaycastVehicle::updateFriction(btScalar timeStep)
|
|||||||
|
|
||||||
#if defined ROLLING_INFLUENCE_FIX // fix. It only worked if car's up was along Y - VT.
|
#if defined ROLLING_INFLUENCE_FIX // fix. It only worked if car's up was along Y - VT.
|
||||||
btVector3 vChassisWorldUp = getRigidBody()->getCenterOfMassTransform().getBasis().getColumn(1);
|
btVector3 vChassisWorldUp = getRigidBody()->getCenterOfMassTransform().getBasis().getColumn(1);
|
||||||
rel_pos -= vChassisWorldUp * (vChassisWorldUp.dot(rel_pos) * wheelInfo.m_rollInfluence);
|
rel_pos -= vChassisWorldUp * (vChassisWorldUp.dot(rel_pos) * (1.f-wheelInfo.m_rollInfluence));
|
||||||
#else
|
#else
|
||||||
rel_pos[m_indexUpAxis] *= wheelInfo.m_rollInfluence;
|
rel_pos[m_indexUpAxis] *= wheelInfo.m_rollInfluence;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user