btUniversalConstraint::calculateTransforms() call necessary?

gjaegy
Posts: 178
Joined: Fri Apr 18, 2008 2:20 pm

btUniversalConstraint::calculateTransforms() call necessary?

Post by gjaegy »

Hi,

I tried to figure out, why my "btUniversalConstraint" was not being "debug rendered" at the right location.

I figured out that the debug drawer relies on "btGeneric6DofConstraint::m_calculatedTransformA" / "m_calculatedTransformB" to render the constraint.

However, these "m_calculatedTransformA" values are computed from "m_frameInA" in btGeneric6DofConstraint::calculateTransforms().

In the case of "btUniversalConstraint", "calculateTransforms()" is being called in the constructor (parent btGeneric6DofConstraint constructor call), but this happens BEFORE "m_frameInA" / "m_frameInB" are being set, hence wrong values computed for "m_calculatedTransformA" / "m_calculatedTransformB".

I solved my problem by calling "calculateTransforms()" once the constraint is created, but is that a normal behaviour ? Isn't it a bug ?

Code: Select all

btUniversalConstraint* pUniv = imNew btUniversalConstraint(*pBodyA, *pBodyB, anchor, parentAxis, childAxis);
pUniv->setLowerLimit(pConstraintUniv->m_fLowerLimitAngle1, pConstraintUniv->m_fLowerLimitAngle2);
pUniv->setUpperLimit(pConstraintUniv->m_fUpperLimitAngle1, pConstraintUniv->m_fUpperLimitAngle2);
m_pDynamicWorld->addConstraint(pUniv, imTRUE);
// below the line of code necessary to have the debug drawer rendering the constraint correctly
pUniv->calculateTransforms();