Reputation: 13369
Many of the bullet examples inherit from CommonRigidBodyBase. Objects are picked based on btPoint2PointConstraint. I have analyzed a SimpleBox example.
When a falling object is picked it starts rotate around a pick point but rotation decreases with time. After some time a picked object should become stable.
In SimpleBox example I have changed a collision shape form (1,1,1) to (2,2,2):
btBoxShape* colShape = createBoxShape(btVector3(2,2,2));
When I pick falling object (which is bigger than before) more or less at the same high above the ground it rotates much longer around pick point. Why ?
I wonder how can I control the time which is needed to stabilize object after picking. Let's assume that a gravity is fixed (9.8). I have only one idea: assign a bigger mass to the object. Are there any other parameters ?
Upvotes: 1
Views: 593
Reputation: 707
Instead of btPoint2PointConstraint
, I use btGeneric6DofConstraint
with all angular motion suppressed.
m_pickedRigidBody->setActivationState(DISABLE_DEACTIVATION);
btTransform pivot;
pivot.setIdentity();
btVector3 localPivot = m_pickedRigidBody->getCenterOfMassTransform().inverse() * rayCast.point;
pivot.setOrigin(localPivot);
btGeneric6DofConstraint* DOF6 = new btGeneric6DofConstraint(*m_pickedRigidBody, pivot, true);
bool bLimitAngularMotion = true;
if (bLimitAngularMotion) {
DOF6->setAngularLowerLimit(btVector3(0, 0, 0));
DOF6->setAngularUpperLimit(btVector3(0, 0, 0));
}
m_dynamicWorld->addConstraint(DOF6, true);
m_pickedConstraint = DOF6;
float cfm = 0.5f;
float erp = 0.5f;
for (int i = 0; i < 6; i++) {
DOF6->setParam(BT_CONSTRAINT_STOP_CFM, cfm, i);
DOF6->setParam(BT_CONSTRAINT_STOP_ERP, erp, i);
}
Upvotes: 1