- Timestamp:
- Mar 31, 2009, 8:05:51 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/bullet/BulletDynamics/ConstraintSolver/btTypedConstraint.cpp
r2662 r2882 20 20 static btRigidBody s_fixed(0, 0,0); 21 21 22 #define DEFAULT_DEBUGDRAW_SIZE btScalar(0.3f) 23 22 24 btTypedConstraint::btTypedConstraint(btTypedConstraintType type) 23 25 :m_userConstraintType(-1), … … 26 28 m_rbA(s_fixed), 27 29 m_rbB(s_fixed), 28 m_appliedImpulse(btScalar(0.)) 30 m_appliedImpulse(btScalar(0.)), 31 m_dbgDrawSize(DEFAULT_DEBUGDRAW_SIZE) 29 32 { 30 33 s_fixed.setMassProps(btScalar(0.),btVector3(btScalar(0.),btScalar(0.),btScalar(0.))); … … 36 39 m_rbA(rbA), 37 40 m_rbB(s_fixed), 38 m_appliedImpulse(btScalar(0.)) 41 m_appliedImpulse(btScalar(0.)), 42 m_dbgDrawSize(DEFAULT_DEBUGDRAW_SIZE) 39 43 { 40 44 s_fixed.setMassProps(btScalar(0.),btVector3(btScalar(0.),btScalar(0.),btScalar(0.))); … … 49 53 m_rbA(rbA), 50 54 m_rbB(rbB), 51 m_appliedImpulse(btScalar(0.)) 55 m_appliedImpulse(btScalar(0.)), 56 m_dbgDrawSize(DEFAULT_DEBUGDRAW_SIZE) 52 57 { 53 58 s_fixed.setMassProps(btScalar(0.),btVector3(btScalar(0.),btScalar(0.),btScalar(0.))); … … 55 60 } 56 61 62 63 //----------------------------------------------------------------------------- 64 65 btScalar btTypedConstraint::getMotorFactor(btScalar pos, btScalar lowLim, btScalar uppLim, btScalar vel, btScalar timeFact) 66 { 67 if(lowLim > uppLim) 68 { 69 return btScalar(1.0f); 70 } 71 else if(lowLim == uppLim) 72 { 73 return btScalar(0.0f); 74 } 75 btScalar lim_fact = btScalar(1.0f); 76 btScalar delta_max = vel / timeFact; 77 if(delta_max < btScalar(0.0f)) 78 { 79 if((pos >= lowLim) && (pos < (lowLim - delta_max))) 80 { 81 lim_fact = (lowLim - pos) / delta_max; 82 } 83 else if(pos < lowLim) 84 { 85 lim_fact = btScalar(0.0f); 86 } 87 else 88 { 89 lim_fact = btScalar(1.0f); 90 } 91 } 92 else if(delta_max > btScalar(0.0f)) 93 { 94 if((pos <= uppLim) && (pos > (uppLim - delta_max))) 95 { 96 lim_fact = (uppLim - pos) / delta_max; 97 } 98 else if(pos > uppLim) 99 { 100 lim_fact = btScalar(0.0f); 101 } 102 else 103 { 104 lim_fact = btScalar(1.0f); 105 } 106 } 107 else 108 { 109 lim_fact = btScalar(0.0f); 110 } 111 return lim_fact; 112 } // btTypedConstraint::getMotorFactor() 113 114
Note: See TracChangeset
for help on using the changeset viewer.