mirror of
https://github.com/bulletphysics/bullet3
synced 2024-12-14 05:40:05 +00:00
Merge branch 'master' of github.com:erwincoumans/bullet3
This commit is contained in:
commit
e18bf1f0d6
@ -310,9 +310,16 @@ struct InteralUserConstraintData
|
|||||||
|
|
||||||
b3UserConstraint m_userConstraintData;
|
b3UserConstraint m_userConstraintData;
|
||||||
|
|
||||||
|
int m_sbHandle;
|
||||||
|
int m_sbNodeIndex;
|
||||||
|
btScalar m_sbNodeMass;
|
||||||
|
|
||||||
InteralUserConstraintData()
|
InteralUserConstraintData()
|
||||||
: m_rbConstraint(0),
|
: m_rbConstraint(0),
|
||||||
m_mbConstraint(0)
|
m_mbConstraint(0),
|
||||||
|
m_sbHandle(-1),
|
||||||
|
m_sbNodeIndex(-1),
|
||||||
|
m_sbNodeMass(-1)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -10998,6 +11005,29 @@ bool PhysicsServerCommandProcessor::processApplyExternalForceCommand(const struc
|
|||||||
rb->applyTorque(torqueWorld);
|
rb->applyTorque(torqueWorld);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (body && body->m_softBody)
|
||||||
|
{
|
||||||
|
btSoftBody* sb = body->m_softBody;
|
||||||
|
int link = clientCmd.m_externalForceArguments.m_linkIds[i];
|
||||||
|
if ((clientCmd.m_externalForceArguments.m_forceFlags[i] & EF_FORCE) != 0)
|
||||||
|
{
|
||||||
|
btVector3 forceLocal(clientCmd.m_externalForceArguments.m_forcesAndTorques[i * 3 + 0],
|
||||||
|
clientCmd.m_externalForceArguments.m_forcesAndTorques[i * 3 + 1],
|
||||||
|
clientCmd.m_externalForceArguments.m_forcesAndTorques[i * 3 + 2]);
|
||||||
|
btVector3 positionLocal(
|
||||||
|
clientCmd.m_externalForceArguments.m_positions[i * 3 + 0],
|
||||||
|
clientCmd.m_externalForceArguments.m_positions[i * 3 + 1],
|
||||||
|
clientCmd.m_externalForceArguments.m_positions[i * 3 + 2]);
|
||||||
|
|
||||||
|
btVector3 forceWorld = isLinkFrame ? forceLocal : sb->getWorldTransform().getBasis() * forceLocal;
|
||||||
|
btVector3 relPosWorld = isLinkFrame ? positionLocal : sb->getWorldTransform().getBasis() * positionLocal;
|
||||||
|
if (link >= 0 && link < sb->m_nodes.size())
|
||||||
|
{
|
||||||
|
sb->addForce(forceWorld, link);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedMemoryStatus& serverCmd = serverStatusOut;
|
SharedMemoryStatus& serverCmd = serverStatusOut;
|
||||||
@ -11232,8 +11262,13 @@ bool PhysicsServerCommandProcessor::processCreateUserConstraintCommand(const str
|
|||||||
if (bodyUniqueId<=0)
|
if (bodyUniqueId<=0)
|
||||||
{
|
{
|
||||||
//fixed anchor (mass = 0)
|
//fixed anchor (mass = 0)
|
||||||
|
InteralUserConstraintData userConstraintData;
|
||||||
|
userConstraintData.m_sbHandle = clientCmd.m_userConstraintArguments.m_parentBodyIndex;
|
||||||
|
userConstraintData.m_sbNodeIndex = nodeIndex;
|
||||||
|
userConstraintData.m_sbNodeMass = sbodyHandle->m_softBody->getMass(nodeIndex);
|
||||||
sbodyHandle->m_softBody->setMass(nodeIndex,0.0);
|
sbodyHandle->m_softBody->setMass(nodeIndex,0.0);
|
||||||
int uid = m_data->m_userConstraintUIDGenerator++;
|
int uid = m_data->m_userConstraintUIDGenerator++;
|
||||||
|
m_data->m_userConstraints.insert(uid, userConstraintData);
|
||||||
serverCmd.m_userConstraintResultArgs.m_userConstraintUniqueId = uid;
|
serverCmd.m_userConstraintResultArgs.m_userConstraintUniqueId = uid;
|
||||||
serverCmd.m_type = CMD_USER_CONSTRAINT_COMPLETED;
|
serverCmd.m_type = CMD_USER_CONSTRAINT_COMPLETED;
|
||||||
} else
|
} else
|
||||||
@ -11284,6 +11319,10 @@ bool PhysicsServerCommandProcessor::processCreateUserConstraintCommand(const str
|
|||||||
}
|
}
|
||||||
int uid = m_data->m_userConstraintUIDGenerator++;
|
int uid = m_data->m_userConstraintUIDGenerator++;
|
||||||
serverCmd.m_userConstraintResultArgs.m_userConstraintUniqueId = uid;
|
serverCmd.m_userConstraintResultArgs.m_userConstraintUniqueId = uid;
|
||||||
|
InteralUserConstraintData userConstraintData;
|
||||||
|
userConstraintData.m_sbHandle = clientCmd.m_userConstraintArguments.m_parentBodyIndex;
|
||||||
|
userConstraintData.m_sbNodeIndex = nodeIndex;
|
||||||
|
m_data->m_userConstraints.insert(uid, userConstraintData);
|
||||||
serverCmd.m_type = CMD_USER_CONSTRAINT_COMPLETED;
|
serverCmd.m_type = CMD_USER_CONSTRAINT_COMPLETED;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -11746,6 +11785,24 @@ bool PhysicsServerCommandProcessor::processCreateUserConstraintCommand(const str
|
|||||||
delete userConstraintPtr->m_rbConstraint;
|
delete userConstraintPtr->m_rbConstraint;
|
||||||
m_data->m_userConstraints.remove(userConstraintUidRemove);
|
m_data->m_userConstraints.remove(userConstraintUidRemove);
|
||||||
}
|
}
|
||||||
|
if (userConstraintPtr->m_sbHandle >= 0)
|
||||||
|
{
|
||||||
|
InternalBodyHandle* sbodyHandle = m_data->m_bodyHandles.getHandle(clientCmd.m_userConstraintArguments.m_parentBodyIndex);
|
||||||
|
if (sbodyHandle)
|
||||||
|
{
|
||||||
|
if (sbodyHandle->m_softBody)
|
||||||
|
{
|
||||||
|
if (userConstraintPtr->m_sbNodeMass >= 0)
|
||||||
|
{
|
||||||
|
sbodyHandle->m_softBody->setMass(userConstraintPtr->m_sbNodeIndex, userConstraintPtr->m_sbNodeMass);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sbodyHandle->m_softBody->removeAnchor(userConstraintPtr->m_sbNodeIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
serverCmd.m_userConstraintResultArgs.m_userConstraintUniqueId = userConstraintUidRemove;
|
serverCmd.m_userConstraintResultArgs.m_userConstraintUniqueId = userConstraintUidRemove;
|
||||||
serverCmd.m_type = CMD_REMOVE_USER_CONSTRAINT_COMPLETED;
|
serverCmd.m_type = CMD_REMOVE_USER_CONSTRAINT_COMPLETED;
|
||||||
}
|
}
|
||||||
|
@ -558,6 +558,25 @@ void btSoftBody::appendDeformableAnchor(int node, btRigidBody* body)
|
|||||||
m_deformableAnchors.push_back(c);
|
m_deformableAnchors.push_back(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void btSoftBody::removeAnchor(int node)
|
||||||
|
{
|
||||||
|
const btSoftBody::Node& n = m_nodes[node];
|
||||||
|
for (int i = 0; i < m_deformableAnchors.size(); )
|
||||||
|
{
|
||||||
|
const DeformableNodeRigidAnchor& c = m_deformableAnchors[i];
|
||||||
|
if (c.m_node == &n)
|
||||||
|
{
|
||||||
|
m_deformableAnchors.removeAtIndex(i);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
void btSoftBody::appendDeformableAnchor(int node, btMultiBodyLinkCollider* link)
|
void btSoftBody::appendDeformableAnchor(int node, btMultiBodyLinkCollider* link)
|
||||||
{
|
{
|
||||||
|
@ -927,6 +927,7 @@ public:
|
|||||||
void appendAnchor(int node,
|
void appendAnchor(int node,
|
||||||
btRigidBody* body, bool disableCollisionBetweenLinkedBodies = false, btScalar influence = 1);
|
btRigidBody* body, bool disableCollisionBetweenLinkedBodies = false, btScalar influence = 1);
|
||||||
void appendAnchor(int node, btRigidBody* body, const btVector3& localPivot, bool disableCollisionBetweenLinkedBodies = false, btScalar influence = 1);
|
void appendAnchor(int node, btRigidBody* body, const btVector3& localPivot, bool disableCollisionBetweenLinkedBodies = false, btScalar influence = 1);
|
||||||
|
void removeAnchor(int node);
|
||||||
/* Append linear joint */
|
/* Append linear joint */
|
||||||
void appendLinearJoint(const LJoint::Specs& specs, Cluster* body0, Body body1);
|
void appendLinearJoint(const LJoint::Specs& specs, Cluster* body0, Body body1);
|
||||||
void appendLinearJoint(const LJoint::Specs& specs, Body body = Body());
|
void appendLinearJoint(const LJoint::Specs& specs, Body body = Body());
|
||||||
|
Loading…
Reference in New Issue
Block a user