Changeset 8351 for code/trunk/src/external/bullet/BulletDynamics/ConstraintSolver/btTypedConstraint.cpp
- Timestamp:
- Apr 28, 2011, 7:15:14 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/external/bullet/BulletDynamics/ConstraintSolver/btTypedConstraint.cpp
r5781 r8351 17 17 #include "btTypedConstraint.h" 18 18 #include "BulletDynamics/Dynamics/btRigidBody.h" 19 #include "LinearMath/btSerializer.h" 19 20 20 static btRigidBody s_fixed(0, 0,0);21 21 22 22 #define DEFAULT_DEBUGDRAW_SIZE btScalar(0.3f) 23 23 24 btTypedConstraint::btTypedConstraint(btTypedConstraintType type) 25 :m_userConstraintType(-1), 24 btTypedConstraint::btTypedConstraint(btTypedConstraintType type, btRigidBody& rbA) 25 :btTypedObject(type), 26 m_userConstraintType(-1), 26 27 m_userConstraintId(-1), 27 m_ constraintType (type),28 m_rbA( s_fixed),29 m_rbB( s_fixed),28 m_needsFeedback(false), 29 m_rbA(rbA), 30 m_rbB(getFixedBody()), 30 31 m_appliedImpulse(btScalar(0.)), 31 32 m_dbgDrawSize(DEFAULT_DEBUGDRAW_SIZE) 32 33 { 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 46 34 } 47 35 48 36 49 37 btTypedConstraint::btTypedConstraint(btTypedConstraintType type, btRigidBody& rbA,btRigidBody& rbB) 50 :m_userConstraintType(-1), 38 :btTypedObject(type), 39 m_userConstraintType(-1), 51 40 m_userConstraintId(-1), 52 m_ constraintType (type),41 m_needsFeedback(false), 53 42 m_rbA(rbA), 54 43 m_rbB(rbB), … … 56 45 m_dbgDrawSize(DEFAULT_DEBUGDRAW_SIZE) 57 46 { 58 s_fixed.setMassProps(btScalar(0.),btVector3(btScalar(0.),btScalar(0.),btScalar(0.)));59 60 47 } 61 48 62 49 63 //----------------------------------------------------------------------------- 50 64 51 65 52 btScalar btTypedConstraint::getMotorFactor(btScalar pos, btScalar lowLim, btScalar uppLim, btScalar vel, btScalar timeFact) … … 110 97 } 111 98 return lim_fact; 112 } // btTypedConstraint::getMotorFactor()99 } 113 100 101 ///fills the dataBuffer and returns the struct name (and 0 on failure) 102 const char* btTypedConstraint::serialize(void* dataBuffer, btSerializer* serializer) const 103 { 104 btTypedConstraintData* tcd = (btTypedConstraintData*) dataBuffer; 114 105 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 136 btRigidBody& 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.