Merge pull request #2354 from fuchuyuan/loadRigidbody
add support to load rigidbody
This commit is contained in:
@@ -7043,7 +7043,8 @@ bool PhysicsServerCommandProcessor::processRequestActualStateCommand(const struc
|
||||
|
||||
hasStatus = true;
|
||||
}
|
||||
else if (body && body->m_rigidBody){
|
||||
else if (body && body->m_rigidBody)
|
||||
{
|
||||
btRigidBody* rb = body->m_rigidBody;
|
||||
SharedMemoryStatus& serverCmd = serverStatusOut;
|
||||
serverCmd.m_type = CMD_ACTUAL_STATE_UPDATE_COMPLETED;
|
||||
@@ -7053,8 +7054,21 @@ bool PhysicsServerCommandProcessor::processRequestActualStateCommand(const struc
|
||||
serverCmd.m_numDataStreamBytes = sizeof(SendActualStateSharedMemoryStorage);
|
||||
serverCmd.m_sendActualStateArgs.m_stateDetails = 0;
|
||||
|
||||
int totalDegreeOfFreedomQ = 0;
|
||||
int totalDegreeOfFreedomU = 0;
|
||||
serverCmd.m_sendActualStateArgs.m_rootLocalInertialFrame[0] =
|
||||
body->m_rootLocalInertialFrame.getOrigin()[0];
|
||||
serverCmd.m_sendActualStateArgs.m_rootLocalInertialFrame[1] =
|
||||
body->m_rootLocalInertialFrame.getOrigin()[1];
|
||||
serverCmd.m_sendActualStateArgs.m_rootLocalInertialFrame[2] =
|
||||
body->m_rootLocalInertialFrame.getOrigin()[2];
|
||||
|
||||
serverCmd.m_sendActualStateArgs.m_rootLocalInertialFrame[3] =
|
||||
body->m_rootLocalInertialFrame.getRotation()[0];
|
||||
serverCmd.m_sendActualStateArgs.m_rootLocalInertialFrame[4] =
|
||||
body->m_rootLocalInertialFrame.getRotation()[1];
|
||||
serverCmd.m_sendActualStateArgs.m_rootLocalInertialFrame[5] =
|
||||
body->m_rootLocalInertialFrame.getRotation()[2];
|
||||
serverCmd.m_sendActualStateArgs.m_rootLocalInertialFrame[6] =
|
||||
body->m_rootLocalInertialFrame.getRotation()[3];
|
||||
|
||||
btTransform tr = rb->getWorldTransform();
|
||||
//base position in world space, cartesian
|
||||
@@ -7067,7 +7081,7 @@ bool PhysicsServerCommandProcessor::processRequestActualStateCommand(const struc
|
||||
stateDetails->m_actualStateQ[4] = tr.getRotation()[1];
|
||||
stateDetails->m_actualStateQ[5] = tr.getRotation()[2];
|
||||
stateDetails->m_actualStateQ[6] = tr.getRotation()[3];
|
||||
totalDegreeOfFreedomQ += 7; //pos + quaternion
|
||||
int totalDegreeOfFreedomQ = 7; //pos + quaternion
|
||||
|
||||
//base linear velocity (in world space, cartesian)
|
||||
stateDetails->m_actualStateQdot[0] = rb->getLinearVelocity()[0];
|
||||
@@ -7078,7 +7092,7 @@ bool PhysicsServerCommandProcessor::processRequestActualStateCommand(const struc
|
||||
stateDetails->m_actualStateQdot[3] = rb->getAngularVelocity()[0];
|
||||
stateDetails->m_actualStateQdot[4] = rb->getAngularVelocity()[1];
|
||||
stateDetails->m_actualStateQdot[5] = rb->getAngularVelocity()[2];
|
||||
totalDegreeOfFreedomU += 6; //3 linear and 3 angular DOF
|
||||
int totalDegreeOfFreedomU = 6; //3 linear and 3 angular DOF
|
||||
|
||||
serverCmd.m_sendActualStateArgs.m_numDegreeOfFreedomQ = totalDegreeOfFreedomQ;
|
||||
serverCmd.m_sendActualStateArgs.m_numDegreeOfFreedomU = totalDegreeOfFreedomU;
|
||||
@@ -8775,6 +8789,19 @@ bool PhysicsServerCommandProcessor::processGetDynamicsInfoCommand(const struct S
|
||||
}
|
||||
hasStatus = true;
|
||||
}
|
||||
else if (body && body->m_rigidBody)
|
||||
{
|
||||
SharedMemoryStatus& serverCmd = serverStatusOut;
|
||||
serverCmd.m_type = CMD_GET_DYNAMICS_INFO_COMPLETED;
|
||||
|
||||
btRigidBody* rb = body->m_rigidBody;
|
||||
serverCmd.m_dynamicsInfo.m_lateralFrictionCoeff = rb->getFriction();
|
||||
serverCmd.m_dynamicsInfo.m_rollingFrictionCoeff = rb->getRollingFriction();
|
||||
serverCmd.m_dynamicsInfo.m_spinningFrictionCoeff = rb->getSpinningFriction();
|
||||
serverCmd.m_dynamicsInfo.m_angularDamping = rb->getAngularDamping();
|
||||
serverCmd.m_dynamicsInfo.m_linearDamping = rb->getLinearDamping();
|
||||
serverCmd.m_dynamicsInfo.m_mass = rb->getMass();
|
||||
}
|
||||
#ifndef SKIP_SOFT_BODY_MULTI_BODY_DYNAMICS_WORLD
|
||||
else if (body && body->m_softBody){
|
||||
//todo: @fuchuyuan implement dynamics info
|
||||
|
||||
@@ -259,6 +259,7 @@ public:
|
||||
m_invMass = m_linearFactor * m_inverseMass;
|
||||
}
|
||||
btScalar getInvMass() const { return m_inverseMass; }
|
||||
btScalar getMass() const { return m_inverseMass == btScalar(0.) ? btScalar(0.) : btScalar(1.0) / m_inverseMass; }
|
||||
const btMatrix3x3& getInvInertiaTensorWorld() const
|
||||
{
|
||||
return m_invInertiaTensorWorld;
|
||||
|
||||
Reference in New Issue
Block a user