Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 21, 2011, 6:58:23 PM (13 years ago)
Author:
rgrieder
Message:

Merged revisions 7978 - 8096 from kicklib to kicklib2.

Location:
code/branches/kicklib2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/kicklib2

  • code/branches/kicklib2/src/external/bullet/BulletDynamics/ConstraintSolver/btTypedConstraint.cpp

    r5781 r8284  
    1717#include "btTypedConstraint.h"
    1818#include "BulletDynamics/Dynamics/btRigidBody.h"
     19#include "LinearMath/btSerializer.h"
    1920
    20 static btRigidBody s_fixed(0, 0,0);
    2121
    2222#define DEFAULT_DEBUGDRAW_SIZE btScalar(0.3f)
    2323
    24 btTypedConstraint::btTypedConstraint(btTypedConstraintType type)
    25 :m_userConstraintType(-1),
     24btTypedConstraint::btTypedConstraint(btTypedConstraintType type, btRigidBody& rbA)
     25:btTypedObject(type),
     26m_userConstraintType(-1),
    2627m_userConstraintId(-1),
    27 m_constraintType (type),
    28 m_rbA(s_fixed),
    29 m_rbB(s_fixed),
     28m_needsFeedback(false),
     29m_rbA(rbA),
     30m_rbB(getFixedBody()),
    3031m_appliedImpulse(btScalar(0.)),
    3132m_dbgDrawSize(DEFAULT_DEBUGDRAW_SIZE)
    3233{
    33         s_fixed.setMassProps(btScalar(0.),btVector3(btScalar(0.),btScalar(0.),btScalar(0.)));
    34 }
    35 btTypedConstraint::btTypedConstraint(btTypedConstraintType type, btRigidBody& rbA)
    36 :m_userConstraintType(-1),
    37 m_userConstraintId(-1),
    38 m_constraintType (type),
    39 m_rbA(rbA),
    40 m_rbB(s_fixed),
    41 m_appliedImpulse(btScalar(0.)),
    42 m_dbgDrawSize(DEFAULT_DEBUGDRAW_SIZE)
    43 {
    44                 s_fixed.setMassProps(btScalar(0.),btVector3(btScalar(0.),btScalar(0.),btScalar(0.)));
    45 
    4634}
    4735
    4836
    4937btTypedConstraint::btTypedConstraint(btTypedConstraintType type, btRigidBody& rbA,btRigidBody& rbB)
    50 :m_userConstraintType(-1),
     38:btTypedObject(type),
     39m_userConstraintType(-1),
    5140m_userConstraintId(-1),
    52 m_constraintType (type),
     41m_needsFeedback(false),
    5342m_rbA(rbA),
    5443m_rbB(rbB),
     
    5645m_dbgDrawSize(DEFAULT_DEBUGDRAW_SIZE)
    5746{
    58                 s_fixed.setMassProps(btScalar(0.),btVector3(btScalar(0.),btScalar(0.),btScalar(0.)));
    59 
    6047}
    6148
    6249
    63 //-----------------------------------------------------------------------------
     50
    6451
    6552btScalar btTypedConstraint::getMotorFactor(btScalar pos, btScalar lowLim, btScalar uppLim, btScalar vel, btScalar timeFact)
     
    11097        }
    11198        return lim_fact;
    112 } // btTypedConstraint::getMotorFactor()
     99}
    113100
     101///fills the dataBuffer and returns the struct name (and 0 on failure)
     102const char*     btTypedConstraint::serialize(void* dataBuffer, btSerializer* serializer) const
     103{
     104        btTypedConstraintData* tcd = (btTypedConstraintData*) dataBuffer;
    114105
     106        tcd->m_rbA = (btRigidBodyData*)serializer->getUniquePointer(&m_rbA);
     107        tcd->m_rbB = (btRigidBodyData*)serializer->getUniquePointer(&m_rbB);
     108        char* name = (char*) serializer->findNameForPointer(this);
     109        tcd->m_name = (char*)serializer->getUniquePointer(name);
     110        if (tcd->m_name)
     111        {
     112                serializer->serializeName(name);
     113        }
     114
     115        tcd->m_objectType = m_objectType;
     116        tcd->m_needsFeedback = m_needsFeedback;
     117        tcd->m_userConstraintId =m_userConstraintId;
     118        tcd->m_userConstraintType =m_userConstraintType;
     119
     120        tcd->m_appliedImpulse = float(m_appliedImpulse);
     121        tcd->m_dbgDrawSize = float(m_dbgDrawSize );
     122
     123        tcd->m_disableCollisionsBetweenLinkedBodies = false;
     124
     125        int i;
     126        for (i=0;i<m_rbA.getNumConstraintRefs();i++)
     127                if (m_rbA.getConstraintRef(i) == this)
     128                        tcd->m_disableCollisionsBetweenLinkedBodies = true;
     129        for (i=0;i<m_rbB.getNumConstraintRefs();i++)
     130                if (m_rbB.getConstraintRef(i) == this)
     131                        tcd->m_disableCollisionsBetweenLinkedBodies = true;
     132
     133        return "btTypedConstraintData";
     134}
     135
     136btRigidBody& btTypedConstraint::getFixedBody()
     137{
     138        static btRigidBody s_fixed(0, 0,0);
     139        s_fixed.setMassProps(btScalar(0.),btVector3(btScalar(0.),btScalar(0.),btScalar(0.)));
     140        return s_fixed;
     141}
     142
Note: See TracChangeset for help on using the changeset viewer.