Added some helper methods for constraints and btMatrix3x3,
Thanks to francois, See Issue 466 Prevent crash in SoftBodyDemo, when picking constraints and demo-mode switches to next demo.
This commit is contained in:
@@ -713,7 +713,7 @@ void btGeneric6DofConstraint::updateRHS(btScalar timeStep)
|
||||
}
|
||||
|
||||
|
||||
void btGeneric6DofConstraint::setFrames(const btTransform & frameA, const btTransform & frameB)
|
||||
void btGeneric6DofConstraint::setFrames(const btTransform& frameA, const btTransform& frameB)
|
||||
{
|
||||
m_frameInA = frameA;
|
||||
m_frameInB = frameB;
|
||||
@@ -1047,3 +1047,24 @@ btScalar btGeneric6DofConstraint::getParam(int num, int axis) const
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void btGeneric6DofConstraint::setAxis(const btVector3& axis1,const btVector3& axis2)
|
||||
{
|
||||
btVector3 zAxis = axis1.normalized();
|
||||
btVector3 yAxis = axis2.normalized();
|
||||
btVector3 xAxis = yAxis.cross(zAxis); // we want right coordinate system
|
||||
|
||||
btTransform frameInW;
|
||||
frameInW.setIdentity();
|
||||
frameInW.getBasis().setValue( xAxis[0], yAxis[0], zAxis[0],
|
||||
xAxis[1], yAxis[1], zAxis[1],
|
||||
xAxis[2], yAxis[2], zAxis[2]);
|
||||
|
||||
// now get constraint frame in local coordinate systems
|
||||
m_frameInA = m_rbA.getCenterOfMassTransform().inverse() * frameInW;
|
||||
m_frameInB = m_rbB.getCenterOfMassTransform().inverse() * frameInW;
|
||||
|
||||
calculateTransforms();
|
||||
}
|
||||
Reference in New Issue
Block a user