Add API to reset lateral friction coefficient.
This commit is contained in:
@@ -1240,6 +1240,17 @@ int b3ResetDynamicInfoSetMass(b3SharedMemoryCommandHandle commandHandle, int bod
|
||||
return 0;
|
||||
}
|
||||
|
||||
int b3ResetDynamicInfoSetLateralFriction(b3SharedMemoryCommandHandle commandHandle, int bodyUniqueId, int linkIndex, double lateralFriction)
|
||||
{
|
||||
struct SharedMemoryCommand* command = (struct SharedMemoryCommand*) commandHandle;
|
||||
b3Assert(command->m_type == CMD_RESET_DYNAMIC_INFO);
|
||||
command->m_resetDynamicInfoArgs.m_bodyUniqueId = bodyUniqueId;
|
||||
command->m_resetDynamicInfoArgs.m_linkIndex = linkIndex;
|
||||
command->m_resetDynamicInfoArgs.m_lateralFriction = lateralFriction;
|
||||
command->m_updateFlags |= RESET_DYNAMIC_INFO_SET_LATERAL_FRICTION;
|
||||
return 0;
|
||||
}
|
||||
|
||||
b3SharedMemoryCommandHandle b3InitCreateUserConstraintCommand(b3PhysicsClientHandle physClient, int parentBodyIndex, int parentJointIndex, int childBodyIndex, int childJointIndex, struct b3JointInfo* info)
|
||||
{
|
||||
PhysicsClient* cl = (PhysicsClient* ) physClient;
|
||||
|
||||
@@ -80,6 +80,7 @@ int b3GetDynamicInfo(b3PhysicsClientHandle physClient, int bodyUniqueId, int lin
|
||||
|
||||
b3SharedMemoryCommandHandle b3InitResetDynamicInfo(b3PhysicsClientHandle physClient);
|
||||
int b3ResetDynamicInfoSetMass(b3SharedMemoryCommandHandle commandHandle, int bodyUniqueId, int linkIndex, double mass);
|
||||
int b3ResetDynamicInfoSetLateralFriction(b3SharedMemoryCommandHandle commandHandle, int bodyUniqueId, int linkIndex, double lateralFriction);
|
||||
|
||||
b3SharedMemoryCommandHandle b3InitCreateUserConstraintCommand(b3PhysicsClientHandle physClient, int parentBodyIndex, int parentJointIndex, int childBodyIndex, int childJointIndex, struct b3JointInfo* info);
|
||||
|
||||
|
||||
@@ -3759,6 +3759,30 @@ bool PhysicsServerCommandProcessor::processCommand(const struct SharedMemoryComm
|
||||
}
|
||||
}
|
||||
|
||||
if (clientCmd.m_updateFlags & RESET_DYNAMIC_INFO_SET_LATERAL_FRICTION)
|
||||
{
|
||||
int bodyUniqueId = clientCmd.m_resetDynamicInfoArgs.m_bodyUniqueId;
|
||||
int linkIndex = clientCmd.m_resetDynamicInfoArgs.m_linkIndex;
|
||||
double lateralFriction = clientCmd.m_resetDynamicInfoArgs.m_lateralFriction;
|
||||
btAssert(bodyUniqueId >= 0);
|
||||
btAssert(linkIndex >= -1);
|
||||
|
||||
InteralBodyData* body = m_data->getHandle(bodyUniqueId);
|
||||
if (body && body->m_multiBody)
|
||||
{
|
||||
btMultiBody* mb = body->m_multiBody;
|
||||
if (linkIndex == -1)
|
||||
{
|
||||
mb->getBaseCollider()->setFriction(lateralFriction);
|
||||
}
|
||||
else
|
||||
{
|
||||
mb->getLinkCollider(linkIndex)->setFriction(lateralFriction);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SharedMemoryStatus& serverCmd =serverStatusOut;
|
||||
serverCmd.m_type = CMD_CLIENT_COMMAND_COMPLETED;
|
||||
hasStatus = true;
|
||||
|
||||
@@ -110,6 +110,7 @@ enum EnumResetDynamicInfoFlags
|
||||
{
|
||||
RESET_DYNAMIC_INFO_SET_MASS=1,
|
||||
RESET_DYNAMIC_INFO_SET_COM=2,
|
||||
RESET_DYNAMIC_INFO_SET_LATERAL_FRICTION=4,
|
||||
};
|
||||
|
||||
struct ResetDynamicInfoArgs
|
||||
@@ -118,6 +119,7 @@ struct ResetDynamicInfoArgs
|
||||
int m_linkIndex;
|
||||
double m_mass;
|
||||
double m_COM[3];
|
||||
double m_lateralFriction;
|
||||
};
|
||||
|
||||
struct SetJointFeedbackArgs
|
||||
|
||||
@@ -212,7 +212,6 @@ struct b3DynamicInfo
|
||||
{
|
||||
double m_mass;
|
||||
double m_localInertialPosition[3];
|
||||
double m_localInertialOrientation[4];
|
||||
};
|
||||
|
||||
// copied from btMultiBodyLink.h
|
||||
|
||||
Reference in New Issue
Block a user