I use a hinge2constraint. hinge2constraint inherit from btGeneric6DofSpringConstraint, Therefore hinge2constraint can have a spring behavior, but I don't need it.
Now i was confused that i can not disable the spring behavior of Hinge2Constraint, event thougt I use enableSpring(n, false).
code is following
firstly there is function:
btHinge2Constraint* getHinge2C(btRigidBody &rbA, btRigidBody &rbB, btVector3 &anchor, btVector3 &axis1, btVector3 &axis2)
{
btHinge2Constraint* hinge2;
hinge2 = new btHinge2Constraint(rbA, rbB, anchor, axis1, axis2);
hinge2->setLinearLowerLimit(btVector3(0,0,0));
hinge2->setLinearUpperLimit(btVector3(0,0,0));
hinge2->setAngularUpperLimit(btVector3(-0.f, 0.f, 0.0));
hinge2->setAngularLowerLimit(btVector3( 0, 0.f, -0.0));
hinge2->enableSpring(0, false);
hinge2->enableSpring(1, false);
hinge2->enableSpring(2, false);
hinge2->enableSpring(3, false);
hinge2->enableSpring(4, false);
hinge2->enableSpring(5, false);
return hinge2;
}
I use this function and ....
proximal_joint[1] = getHinge2C(*metacarpal[0], *proximal[1], btVector3(origin_2_x, origin_2_y, 0), parentAxis, childAxis);
proximal_joint[1]->setAngularUpperLimit(btVector3(1.f, 0.f, 0));
proximal_joint[1]->setAngularLowerLimit(btVector3( -1.f, 0.f, 0));
m_dynamicsWorld->addConstraint(proximal_joint[1]);
thanks for advising.
//=======================================
I find the reason is the code: m_dynamicsWorld->addConstraint(proximal_joint[1]);
when i use m_dynamicsWorld->addConstraint(proximal_joint[1], ture); //disable collision detection between linked bodys
I see the linked body bouncing around so I though it was because the spring. In fact, it is not.
because I use a hinge2 joint linke two capsule, when they are linked tight , it will contact to each other when one of the capsule is moving. so it looks like there is a spring make the capsule stop at the initial position.
[solved]disable the spring behavior of Hinge2Constraint?
-
lica
- Posts: 1
- Joined: Thu May 12, 2011 7:50 am