Fix in generic 6dof constraint, when springs/limits/motors are combined

Added btGeneric6DofConstraint::getRelativePivotPosition to read relative linear position of the constraint frame (pivot)
This commit is contained in:
erwin.coumans
2009-06-06 01:09:06 +00:00
parent ee664e7750
commit a9141d5daf
2 changed files with 21 additions and 6 deletions

View File

@@ -22,9 +22,11 @@ http://gimpact.sf.net
#include "btGeneric6DofConstraint.h" #include "btGeneric6DofConstraint.h"
#include "BulletDynamics/Dynamics/btRigidBody.h" #include "BulletDynamics/Dynamics/btRigidBody.h"
#include "LinearMath/btTransformUtil.h" #include "LinearMath/btTransformUtil.h"
#include "LinearMath/btTransformUtil.h"
#include <new> #include <new>
#define D6_USE_OBSOLETE_METHOD false #define D6_USE_OBSOLETE_METHOD false
@@ -661,10 +663,15 @@ btVector3 btGeneric6DofConstraint::getAxis(int axis_index) const
} }
btScalar btGeneric6DofConstraint::getRelativePivotPosition(int axisIndex) const
btScalar btGeneric6DofConstraint::getAngle(int axis_index) const
{ {
return m_calculatedAxisAngleDiff[axis_index]; return m_calculatedLinearDiff[axisIndex];
}
btScalar btGeneric6DofConstraint::getAngle(int axisIndex) const
{
return m_calculatedAxisAngleDiff[axisIndex];
} }
@@ -724,7 +731,7 @@ int btGeneric6DofConstraint::get_limit_motor_info2(
J2[srow+1] = -ax1[1]; J2[srow+1] = -ax1[1];
J2[srow+2] = -ax1[2]; J2[srow+2] = -ax1[2];
} }
if((!rotational) && limit) if((!rotational))
{ {
btVector3 ltd; // Linear Torque Decoupling vector btVector3 ltd; // Linear Torque Decoupling vector
btVector3 c = m_calculatedTransformB.getOrigin() - body0->getCenterOfMassPosition(); btVector3 c = m_calculatedTransformB.getOrigin() - body0->getCenterOfMassPosition();
@@ -749,6 +756,7 @@ int btGeneric6DofConstraint::get_limit_motor_info2(
if(!limit) if(!limit)
{ {
btScalar tag_vel = rotational ? limot->m_targetVelocity : -limot->m_targetVelocity; btScalar tag_vel = rotational ? limot->m_targetVelocity : -limot->m_targetVelocity;
btScalar mot_fact = getMotorFactor( limot->m_currentPosition, btScalar mot_fact = getMotorFactor( limot->m_currentPosition,
limot->m_loLimit, limot->m_loLimit,
limot->m_hiLimit, limot->m_hiLimit,

View File

@@ -382,14 +382,21 @@ public:
//! Get the relative Euler angle //! Get the relative Euler angle
/*! /*!
\pre btGeneric6DofConstraint.buildJacobian must be called previously. \pre btGeneric6DofConstraint::calculateTransforms() must be called previously.
*/ */
btScalar getAngle(int axis_index) const; btScalar getAngle(int axis_index) const;
//! Get the relative position of the constraint pivot
/*!
\pre btGeneric6DofConstraint::calculateTransforms() must be called previously.
*/
btScalar getRelativePivotPosition(int axis_index) const;
//! Test angular limit. //! Test angular limit.
/*! /*!
Calculates angular correction and returns true if limit needs to be corrected. Calculates angular correction and returns true if limit needs to be corrected.
\pre btGeneric6DofConstraint.buildJacobian must be called previously. \pre btGeneric6DofConstraint::calculateTransforms() must be called previously.
*/ */
bool testAngularLimitMotor(int axis_index); bool testAngularLimitMotor(int axis_index);