Back to index

supertuxkart  0.5+dfsg1
Public Member Functions | Protected Member Functions | Protected Attributes
btUprightConstraint Class Reference

#include <btUprightConstraint.h>

Inheritance diagram for btUprightConstraint:
Inheritance graph
[legend]
Collaboration diagram for btUprightConstraint:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 btUprightConstraint (btRigidBody &rbA, const btTransform &frameInA)
void setLimit (btScalar range)
void setErp (btScalar erp)
void setBounce (btScalar bounce)
void setMaxLimitForce (btScalar force)
void setLimitSoftness (btScalar softness)
void setDamping (btScalar damping)
void setDisableTime (btScalar t)
virtual void buildJacobian ()
virtual void solveConstraint (btScalar timeStep)
const btRigidBodygetRigidBodyA () const
btRigidBodygetRigidBodyA ()
const btRigidBodygetRigidBodyB () const
btRigidBodygetRigidBodyB ()
int getUserConstraintType () const
void setUserConstraintType (int userConstraintType)
void setUserConstraintId (int uid)
int getUserConstraintId () const
int getUid () const
btScalar getAppliedImpulse () const
btTypedConstraintType getConstraintType () const

Protected Member Functions

btUprightConstraintoperator= (btUprightConstraint &other)
void buildAngularJacobian (btJacobianEntry &jacAngular, const btVector3 &jointAxisW)
void solveAngularLimit (btUprightConstraintLimit *limit, btScalar timeStep, btScalar jacDiagABInv, btRigidBody *body0)

Protected Attributes

btRigidBodym_rbA
btRigidBodym_rbB
btScalar m_appliedImpulse
btScalar m_timeStep
btScalar m_ERP
btScalar m_bounce
btScalar m_damping
btScalar m_maxLimitForce
btScalar m_limitSoftness
btScalar m_hiLimit
btScalar m_loLimit
btScalar m_disable_time
btUprightConstraintLimit m_limit [2]

Detailed Description

Definition at line 39 of file btUprightConstraint.h.


Constructor & Destructor Documentation

Definition at line 90 of file btUprightConstraint.cpp.

        : btTypedConstraint(D6_CONSTRAINT_TYPE, rbA)
        , m_frameInA(frameInA)

{
      m_ERP                           = 1.0f;
      m_bounce                        = 0.0f;
      m_damping                       = 1.0f;
      m_limitSoftness                 = 1.0f;
      m_maxLimitForce                 = 3000.0f;
      m_disable_time                  = 0.0f;
      m_limit[0].m_accumulatedImpulse = 0.0f;
      m_limit[1].m_accumulatedImpulse = 0.0f;
         m_limit[ 0 ].m_axis                    = btVector3( 1, 0, 0 );
         m_limit[ 1 ].m_axis                    = btVector3( 0, 1, 0 );
         setLimit( SIMD_PI * 0.4f );
}

Here is the call graph for this function:


Member Function Documentation

void btUprightConstraint::buildAngularJacobian ( btJacobianEntry jacAngular,
const btVector3 jointAxisW 
) [protected]

Implements btTypedConstraint.

Definition at line 112 of file btUprightConstraint.cpp.

{
      btTransform worldTransform = m_rbA.getCenterOfMassTransform() * m_frameInA;
      btVector3   upAxis         = worldTransform.getBasis().getColumn(2);
      m_limit[ 0 ].m_angle          =  btAtan2( upAxis.getZ(), upAxis.getY() )-SIMD_PI/2.0f;
      m_limit[ 1 ].m_angle          = -btAtan2( upAxis.getZ(), upAxis.getX() )+SIMD_PI/2.0f;

         for ( int i = 0; i < 2; i++ )
         {
                if ( m_limit[ i ].m_angle < -SIMD_PI )
                            m_limit[ i ].m_angle += 2 * SIMD_PI;
                if ( m_limit[ i ].m_angle > SIMD_PI )
                            m_limit[ i ].m_angle -= 2 * SIMD_PI;

                new (&m_jacAng[ i ])      btJacobianEntry(  m_limit[ i ].m_axis,
                                                                                             m_rbA.getCenterOfMassTransform().getBasis().transpose(),
                                                                                             m_rbB.getCenterOfMassTransform().getBasis().transpose(),
                                                                                             m_rbA.getInvInertiaDiagLocal(),
                                                                                             m_rbB.getInvInertiaDiagLocal());
         }
}

Here is the call graph for this function:

btScalar btTypedConstraint::getAppliedImpulse ( ) const [inline, inherited]

Definition at line 108 of file btTypedConstraint.h.

       {
              return m_appliedImpulse;
       }

Definition at line 113 of file btTypedConstraint.h.

       {
              return m_constraintType;
       }

Here is the caller graph for this function:

const btRigidBody& btTypedConstraint::getRigidBodyA ( ) const [inline, inherited]

Reimplemented in btGeneric6DofConstraint, btSliderConstraint, btConeTwistConstraint, and btHingeConstraint.

Definition at line 65 of file btTypedConstraint.h.

       {
              return m_rbA;
       }

Here is the caller graph for this function:

Definition at line 74 of file btTypedConstraint.h.

       {
              return m_rbA;
       }
const btRigidBody& btTypedConstraint::getRigidBodyB ( ) const [inline, inherited]

Reimplemented in btGeneric6DofConstraint, btSliderConstraint, btConeTwistConstraint, and btHingeConstraint.

Definition at line 69 of file btTypedConstraint.h.

       {
              return m_rbB;
       }

Here is the caller graph for this function:

Definition at line 78 of file btTypedConstraint.h.

       {
              return m_rbB;
       }
int btTypedConstraint::getUid ( ) const [inline, inherited]

Definition at line 103 of file btTypedConstraint.h.

       {
              return m_userConstraintId;   
       } 
int btTypedConstraint::getUserConstraintId ( ) const [inline, inherited]

Definition at line 98 of file btTypedConstraint.h.

       {
              return m_userConstraintId;
       }
int btTypedConstraint::getUserConstraintType ( ) const [inline, inherited]

Definition at line 83 of file btTypedConstraint.h.

       {
              return m_userConstraintType ;
       }
btUprightConstraint& btUprightConstraint::operator= ( btUprightConstraint other) [inline, protected]

Definition at line 72 of file btUprightConstraint.h.

    {
        btAssert(0);
        (void) other;
        return *this;
    }
void btUprightConstraint::setBounce ( btScalar  bounce) [inline]

Definition at line 106 of file btUprightConstraint.h.

       {
              m_bounce = bounce;
       }

Here is the caller graph for this function:

void btUprightConstraint::setDamping ( btScalar  damping) [inline]

Definition at line 118 of file btUprightConstraint.h.

       {
              m_damping = damping;
       }

Here is the caller graph for this function:

Definition at line 122 of file btUprightConstraint.h.

    {
        m_disable_time = t;
    }

Here is the caller graph for this function:

void btUprightConstraint::setErp ( btScalar  erp) [inline]

Definition at line 102 of file btUprightConstraint.h.

       {
              m_ERP = erp;
       }

Here is the caller graph for this function:

void btUprightConstraint::setLimit ( btScalar  range) [inline]

Definition at line 93 of file btUprightConstraint.h.

       {
              m_loLimit = -range;
              m_hiLimit = +range;
       }

Here is the caller graph for this function:

void btUprightConstraint::setLimitSoftness ( btScalar  softness) [inline]

Definition at line 114 of file btUprightConstraint.h.

       {
              m_limitSoftness = softness;
       }

Here is the caller graph for this function:

Definition at line 110 of file btUprightConstraint.h.

       {
              m_maxLimitForce = force;
       }

Here is the caller graph for this function:

void btTypedConstraint::setUserConstraintId ( int  uid) [inline, inherited]

Definition at line 93 of file btTypedConstraint.h.

       {
              m_userConstraintId = uid;
       }
void btTypedConstraint::setUserConstraintType ( int  userConstraintType) [inline, inherited]

Definition at line 88 of file btTypedConstraint.h.

       {
              m_userConstraintType = userConstraintType;
       };
void btUprightConstraint::solveAngularLimit ( btUprightConstraintLimit limit,
btScalar  timeStep,
btScalar  jacDiagABInv,
btRigidBody body0 
) [protected]

Definition at line 28 of file btUprightConstraint.cpp.

{
       
       // Work out if limit is violated
    if(limit->m_angle>=m_loLimit && limit->m_angle<=m_hiLimit) return;

    limit->m_currentLimitError = (limit->m_angle<m_loLimit) 
                               ? limit->m_angle - m_loLimit
                               : limit->m_angle - m_hiLimit;

       btScalar targetVelocity       = -m_ERP*limit->m_currentLimitError/(3.1415f/8.0f*timeStep);
       btScalar maxMotorForce        = m_maxLimitForce;

    maxMotorForce *= timeStep;

    // current velocity difference
    btVector3 angularVelocity       = body0->getAngularVelocity();
    btScalar  axisAngularVelocity   = limit->m_axis.dot( angularVelocity );
 
     // correction velocity
    btScalar motorVelocity          = m_limitSoftness*(targetVelocity  - m_damping*axisAngularVelocity);

    // correction impulse
    btScalar unclippedMotorImpulse = (1+m_bounce)*motorVelocity*jacDiagABInv;

       // clip correction impulse
    btScalar clippedMotorImpulse = unclippedMotorImpulse;

    //todo: should clip against accumulated impulse

    if (unclippedMotorImpulse>0.0f)
    {
        clippedMotorImpulse =  unclippedMotorImpulse > maxMotorForce? maxMotorForce: unclippedMotorImpulse;
    }
    else
    {
        clippedMotorImpulse =  unclippedMotorImpulse < -maxMotorForce ? -maxMotorForce: unclippedMotorImpulse;
    }

       // sort with accumulated impulses
    btScalar      lo = btScalar(-1e30);
    btScalar      hi = btScalar(1e30);

    btScalar oldaccumImpulse = limit->m_accumulatedImpulse;

    btScalar sum = oldaccumImpulse + clippedMotorImpulse;

       limit->m_accumulatedImpulse = sum > hi ? btScalar(0.) : sum < lo ? btScalar(0.) : sum;

    clippedMotorImpulse = limit->m_accumulatedImpulse - oldaccumImpulse;

    btVector3 motorImp = clippedMotorImpulse * limit->m_axis;
    body0->applyTorqueImpulse(motorImp);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void btUprightConstraint::solveConstraint ( btScalar  timeStep) [virtual]

Implements btTypedConstraint.

Definition at line 138 of file btUprightConstraint.cpp.

{
    m_timeStep = timeStep;

    // Update disable time and return if constraint is still disabled
    if(m_disable_time>0.0f)
    {
        m_disable_time -= timeStep;
        if(m_disable_time>0.0f) return;
    }

       solveAngularLimit( &m_limit[ 0 ], m_timeStep, btScalar(1.) / m_jacAng[ 0 ].getDiagonal(), &m_rbA );
       solveAngularLimit( &m_limit[ 1 ], m_timeStep, btScalar(1.) / m_jacAng[ 1 ].getDiagonal(), &m_rbA );
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 50 of file btTypedConstraint.h.

Definition at line 60 of file btUprightConstraint.h.

Definition at line 61 of file btUprightConstraint.h.

Definition at line 66 of file btUprightConstraint.h.

Definition at line 59 of file btUprightConstraint.h.

Definition at line 64 of file btUprightConstraint.h.

Definition at line 68 of file btUprightConstraint.h.

Definition at line 63 of file btUprightConstraint.h.

Definition at line 65 of file btUprightConstraint.h.

Definition at line 62 of file btUprightConstraint.h.

btRigidBody& btTypedConstraint::m_rbA [protected, inherited]

Definition at line 48 of file btTypedConstraint.h.

btRigidBody& btTypedConstraint::m_rbB [protected, inherited]

Definition at line 49 of file btTypedConstraint.h.

temporal variables

Definition at line 52 of file btUprightConstraint.h.


The documentation for this class was generated from the following files: