Support get body state for deformable objects so that it retrieves the best fit rigid transform

This commit is contained in:
Xuchen Han 2020-03-16 12:09:28 -07:00
parent 3c9dde54a2
commit cab8b84a8f
3 changed files with 10 additions and 3 deletions

View File

@ -7482,7 +7482,8 @@ bool PhysicsServerCommandProcessor::processRequestActualStateCommand(const struc
serverCmd.m_sendActualStateArgs.m_rootLocalInertialFrame[6] =
body->m_rootLocalInertialFrame.getRotation()[3];
btVector3 center_of_mass(sb->getCenterOfMass());
btVector3 center_of_mass(sb->getCenterOfMass());
sb->updateTransform();
btTransform tr = sb->getWorldTransform();
//base position in world space, cartesian
stateDetails->m_actualStateQ[0] = center_of_mass[0];

View File

@ -1034,6 +1034,12 @@ void btSoftBody::setAngularVelocity(const btVector3& angVel)
}
}
//
void btSoftBody::updateTransform()
{
setWorldTransform(getRigidTransform());
}
//
btTransform btSoftBody::getRigidTransform()
{

View File

@ -819,8 +819,6 @@ public:
btAlignedObjectArray<bool> m_clusterConnectivity; //cluster connectivity, for self-collision
btTransform m_worldTransform;
btVector3 m_windVelocity;
btScalar m_restLengthScale;
@ -972,6 +970,8 @@ public:
void setLinearVelocity(const btVector3& linVel);
/* Set the angular velocity of the center of mass */
void setAngularVelocity(const btVector3& angVel);
/* Update the world transform to the best fit rigid transform */
void updateTransform();
/* Get best fit rigid transform */
btTransform getRigidTransform();
/* Transform to given pose */