mirror of
https://github.com/bulletphysics/bullet3.git
synced 2026-11-11 18:35:34 +00:00
Merge branch 'master' of github.com:erwincoumans/bullet3
This commit is contained in:
@@ -260,6 +260,17 @@ B3_SHARED_API void b3LoadMJCFCommandSetFlags(b3SharedMemoryCommandHandle command
|
||||
}
|
||||
}
|
||||
|
||||
B3_SHARED_API void b3LoadMJCFCommandSetUseMultiBody(b3SharedMemoryCommandHandle commandHandle, int useMultiBody)
|
||||
{
|
||||
struct SharedMemoryCommand* command = (struct SharedMemoryCommand*)commandHandle;
|
||||
b3Assert(command->m_type == CMD_LOAD_MJCF);
|
||||
if (command->m_type == CMD_LOAD_MJCF)
|
||||
{
|
||||
command->m_updateFlags |= URDF_ARGS_USE_MULTIBODY;
|
||||
command->m_mjcfArguments.m_useMultiBody = useMultiBody;
|
||||
}
|
||||
}
|
||||
|
||||
B3_SHARED_API b3SharedMemoryCommandHandle b3LoadSoftBodyCommandInit(b3PhysicsClientHandle physClient, const char* fileName)
|
||||
{
|
||||
PhysicsClient* cl = (PhysicsClient*)physClient;
|
||||
@@ -3296,6 +3307,18 @@ B3_SHARED_API int b3ChangeDynamicsInfoSetJointLimitForce(b3SharedMemoryCommandHa
|
||||
return 0;
|
||||
}
|
||||
|
||||
B3_SHARED_API int b3ChangeDynamicsInfoSetSleepThreshold(b3SharedMemoryCommandHandle commandHandle, int bodyUniqueId, double sleepThreshold)
|
||||
{
|
||||
struct SharedMemoryCommand* command = (struct SharedMemoryCommand*)commandHandle;
|
||||
b3Assert(command->m_type == CMD_CHANGE_DYNAMICS_INFO);
|
||||
command->m_changeDynamicsInfoArgs.m_bodyUniqueId = bodyUniqueId;
|
||||
command->m_changeDynamicsInfoArgs.m_sleepThreshold = sleepThreshold;
|
||||
command->m_updateFlags |= CHANGE_DYNAMICS_INFO_SET_SLEEP_THRESHOLD;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
B3_SHARED_API int b3ChangeDynamicsInfoSetDynamicType(b3SharedMemoryCommandHandle commandHandle, int bodyUniqueId, int linkIndex, int dynamicType)
|
||||
{
|
||||
struct SharedMemoryCommand* command = (struct SharedMemoryCommand*)commandHandle;
|
||||
|
||||
@@ -156,7 +156,8 @@ extern "C"
|
||||
B3_SHARED_API int b3ChangeDynamicsInfoSetJointLimit(b3SharedMemoryCommandHandle commandHandle, int bodyUniqueId, int linkIndex, double jointLowerLimit, double jointUpperLimit);
|
||||
B3_SHARED_API int b3ChangeDynamicsInfoSetJointLimitForce(b3SharedMemoryCommandHandle commandHandle, int bodyUniqueId, int linkIndex, double jointLimitForce);
|
||||
B3_SHARED_API int b3ChangeDynamicsInfoSetDynamicType(b3SharedMemoryCommandHandle commandHandle, int bodyUniqueId, int linkIndex, int dynamicType);
|
||||
|
||||
|
||||
B3_SHARED_API int b3ChangeDynamicsInfoSetSleepThreshold(b3SharedMemoryCommandHandle commandHandle, int bodyUniqueId, double sleepThreshold);
|
||||
|
||||
B3_SHARED_API int b3ChangeDynamicsInfoSetLateralFriction(b3SharedMemoryCommandHandle commandHandle, int bodyUniqueId, int linkIndex, double lateralFriction);
|
||||
B3_SHARED_API int b3ChangeDynamicsInfoSetSpinningFriction(b3SharedMemoryCommandHandle commandHandle, int bodyUniqueId, int linkIndex, double friction);
|
||||
@@ -415,6 +416,8 @@ extern "C"
|
||||
B3_SHARED_API b3SharedMemoryCommandHandle b3LoadMJCFCommandInit(b3PhysicsClientHandle physClient, const char* fileName);
|
||||
B3_SHARED_API b3SharedMemoryCommandHandle b3LoadMJCFCommandInit2(b3SharedMemoryCommandHandle commandHandle, const char* fileName);
|
||||
B3_SHARED_API void b3LoadMJCFCommandSetFlags(b3SharedMemoryCommandHandle commandHandle, int flags);
|
||||
B3_SHARED_API void b3LoadMJCFCommandSetUseMultiBody(b3SharedMemoryCommandHandle commandHandle, int useMultiBody);
|
||||
|
||||
|
||||
///compute the forces to achieve an acceleration, given a state q and qdot using inverse dynamics
|
||||
B3_SHARED_API b3SharedMemoryCommandHandle b3CalculateInverseDynamicsCommandInit(b3PhysicsClientHandle physClient, int bodyUniqueId,
|
||||
|
||||
@@ -2771,6 +2771,9 @@ void PhysicsServerCommandProcessor::createEmptyDynamicsWorld(int flags)
|
||||
#endif
|
||||
}
|
||||
|
||||
//may help improve run-time performance for many sleeping objects
|
||||
m_data->m_dynamicsWorld->setForceUpdateAllAabbs(false);
|
||||
|
||||
//Workaround: in a VR application, where we avoid synchronizing between GFX/Physics threads, we don't want to resize this array, so pre-allocate it
|
||||
m_data->m_dynamicsWorld->getCollisionObjectArray().reserve(128 * 1024);
|
||||
|
||||
@@ -9761,6 +9764,11 @@ bool PhysicsServerCommandProcessor::processChangeDynamicsInfoCommand(const struc
|
||||
mb->setAngularDamping(clientCmd.m_changeDynamicsInfoArgs.m_angularDamping);
|
||||
}
|
||||
|
||||
if (clientCmd.m_updateFlags & CHANGE_DYNAMICS_INFO_SET_SLEEP_THRESHOLD)
|
||||
{
|
||||
mb->setSleepThreshold(clientCmd.m_changeDynamicsInfoArgs.m_sleepThreshold);
|
||||
}
|
||||
|
||||
if (linkIndex == -1)
|
||||
{
|
||||
if (mb->getBaseCollider())
|
||||
@@ -10045,6 +10053,7 @@ bool PhysicsServerCommandProcessor::processChangeDynamicsInfoCommand(const struc
|
||||
btRigidBody* rb = 0;
|
||||
if (body && body->m_rigidBody)
|
||||
{
|
||||
|
||||
if (linkIndex == -1)
|
||||
{
|
||||
rb = body->m_rigidBody;
|
||||
@@ -10180,6 +10189,13 @@ bool PhysicsServerCommandProcessor::processChangeDynamicsInfoCommand(const struc
|
||||
m_data->m_dynamicsWorld->addCollisionObject(rb, collisionFilterGroup, collisionFilterMask);
|
||||
}
|
||||
}
|
||||
|
||||
if (clientCmd.m_updateFlags & CHANGE_DYNAMICS_INFO_SET_SLEEP_THRESHOLD)
|
||||
{
|
||||
btScalar threshold2 = btSqrt(clientCmd.m_changeDynamicsInfoArgs.m_sleepThreshold);
|
||||
rb->setSleepingThresholds(threshold2,threshold2);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
#ifndef SKIP_SOFT_BODY_MULTI_BODY_DYNAMICS_WORLD
|
||||
@@ -10373,6 +10389,12 @@ bool PhysicsServerCommandProcessor::processGetDynamicsInfoCommand(const struct S
|
||||
serverCmd.m_dynamicsInfo.m_bodyType = BT_RIGID_BODY;
|
||||
|
||||
btRigidBody* rb = body->m_rigidBody;
|
||||
|
||||
|
||||
serverCmd.m_dynamicsInfo.m_localInertialDiagonal[0] = rb->getLocalInertia()[0];
|
||||
serverCmd.m_dynamicsInfo.m_localInertialDiagonal[1] = rb->getLocalInertia()[1];
|
||||
serverCmd.m_dynamicsInfo.m_localInertialDiagonal[2] = rb->getLocalInertia()[2];
|
||||
|
||||
serverCmd.m_dynamicsInfo.m_lateralFrictionCoeff = rb->getFriction();
|
||||
serverCmd.m_dynamicsInfo.m_rollingFrictionCoeff = rb->getRollingFriction();
|
||||
serverCmd.m_dynamicsInfo.m_spinningFrictionCoeff = rb->getSpinningFriction();
|
||||
@@ -14612,7 +14634,12 @@ bool PhysicsServerCommandProcessor::pickBody(const btVector3& rayFromWorld, cons
|
||||
{
|
||||
m_data->m_pickedBody = body;
|
||||
m_data->m_savedActivationState = body->getActivationState();
|
||||
if (m_data->m_savedActivationState==ISLAND_SLEEPING)
|
||||
{
|
||||
m_data->m_savedActivationState = ACTIVE_TAG;
|
||||
}
|
||||
m_data->m_pickedBody->setActivationState(DISABLE_DEACTIVATION);
|
||||
m_data->m_pickedBody->setDeactivationTime(0);
|
||||
//printf("pickPos=%f,%f,%f\n",pickPos.getX(),pickPos.getY(),pickPos.getZ());
|
||||
btVector3 localPivot = body->getCenterOfMassTransform().inverse() * pickPos;
|
||||
btPoint2PointConstraint* p2p = new btPoint2PointConstraint(*body, localPivot);
|
||||
|
||||
@@ -174,6 +174,7 @@ enum EnumChangeDynamicsInfoFlags
|
||||
CHANGE_DYNAMICS_INFO_SET_JOINT_LIMITS = 1 << 18,
|
||||
CHANGE_DYNAMICS_INFO_SET_JOINT_LIMIT_MAX_FORCE = 1 << 19,
|
||||
CHANGE_DYNAMICS_INFO_SET_DYNAMIC_TYPE = 1 << 20,
|
||||
CHANGE_DYNAMICS_INFO_SET_SLEEP_THRESHOLD = 1 << 21,
|
||||
};
|
||||
|
||||
struct ChangeDynamicsInfoArgs
|
||||
@@ -205,6 +206,9 @@ struct ChangeDynamicsInfoArgs
|
||||
double m_jointLimitForce;
|
||||
|
||||
int m_dynamicType;
|
||||
|
||||
double m_sleepThreshold;
|
||||
|
||||
};
|
||||
|
||||
struct GetDynamicsInfoArgs
|
||||
|
||||
Reference in New Issue
Block a user