btGeneric6DofConstraint.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640
  1. /*
  2. Bullet Continuous Collision Detection and Physics Library
  3. Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
  4. This software is provided 'as-is', without any express or implied warranty.
  5. In no event will the authors be held liable for any damages arising from the use of this software.
  6. Permission is granted to anyone to use this software for any purpose,
  7. including commercial applications, and to alter it and redistribute it freely,
  8. subject to the following restrictions:
  9. 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
  10. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
  11. 3. This notice may not be removed or altered from any source distribution.
  12. */
  13. /// 2009 March: btGeneric6DofConstraint refactored by Roman Ponomarev
  14. /// Added support for generic constraint solver through getInfo1/getInfo2 methods
  15. /*
  16. 2007-09-09
  17. btGeneric6DofConstraint Refactored by Francisco Le?n
  18. email: projectileman@yahoo.com
  19. http://gimpact.sf.net
  20. */
  21. #ifndef BT_GENERIC_6DOF_CONSTRAINT_H
  22. #define BT_GENERIC_6DOF_CONSTRAINT_H
  23. #include "bullet/LinearMath/btVector3.h"
  24. #include "btJacobianEntry.h"
  25. #include "btTypedConstraint.h"
  26. class btRigidBody;
  27. #ifdef BT_USE_DOUBLE_PRECISION
  28. #define btGeneric6DofConstraintData2 btGeneric6DofConstraintDoubleData2
  29. #define btGeneric6DofConstraintDataName "btGeneric6DofConstraintDoubleData2"
  30. #else
  31. #define btGeneric6DofConstraintData2 btGeneric6DofConstraintData
  32. #define btGeneric6DofConstraintDataName "btGeneric6DofConstraintData"
  33. #endif //BT_USE_DOUBLE_PRECISION
  34. //! Rotation Limit structure for generic joints
  35. class btRotationalLimitMotor
  36. {
  37. public:
  38. //! limit_parameters
  39. //!@{
  40. btScalar m_loLimit;//!< joint limit
  41. btScalar m_hiLimit;//!< joint limit
  42. btScalar m_targetVelocity;//!< target motor velocity
  43. btScalar m_maxMotorForce;//!< max force on motor
  44. btScalar m_maxLimitForce;//!< max force on limit
  45. btScalar m_damping;//!< Damping.
  46. btScalar m_limitSoftness;//! Relaxation factor
  47. btScalar m_normalCFM;//!< Constraint force mixing factor
  48. btScalar m_stopERP;//!< Error tolerance factor when joint is at limit
  49. btScalar m_stopCFM;//!< Constraint force mixing factor when joint is at limit
  50. btScalar m_bounce;//!< restitution factor
  51. bool m_enableMotor;
  52. //!@}
  53. //! temp_variables
  54. //!@{
  55. btScalar m_currentLimitError;//! How much is violated this limit
  56. btScalar m_currentPosition; //! current value of angle
  57. int m_currentLimit;//!< 0=free, 1=at lo limit, 2=at hi limit
  58. btScalar m_accumulatedImpulse;
  59. //!@}
  60. btRotationalLimitMotor()
  61. {
  62. m_accumulatedImpulse = 0.f;
  63. m_targetVelocity = 0;
  64. m_maxMotorForce = 0.1f;
  65. m_maxLimitForce = 300.0f;
  66. m_loLimit = 1.0f;
  67. m_hiLimit = -1.0f;
  68. m_normalCFM = 0.f;
  69. m_stopERP = 0.2f;
  70. m_stopCFM = 0.f;
  71. m_bounce = 0.0f;
  72. m_damping = 1.0f;
  73. m_limitSoftness = 0.5f;
  74. m_currentLimit = 0;
  75. m_currentLimitError = 0;
  76. m_enableMotor = false;
  77. }
  78. btRotationalLimitMotor(const btRotationalLimitMotor & limot)
  79. {
  80. m_targetVelocity = limot.m_targetVelocity;
  81. m_maxMotorForce = limot.m_maxMotorForce;
  82. m_limitSoftness = limot.m_limitSoftness;
  83. m_loLimit = limot.m_loLimit;
  84. m_hiLimit = limot.m_hiLimit;
  85. m_normalCFM = limot.m_normalCFM;
  86. m_stopERP = limot.m_stopERP;
  87. m_stopCFM = limot.m_stopCFM;
  88. m_bounce = limot.m_bounce;
  89. m_currentLimit = limot.m_currentLimit;
  90. m_currentLimitError = limot.m_currentLimitError;
  91. m_enableMotor = limot.m_enableMotor;
  92. }
  93. //! Is limited
  94. bool isLimited()
  95. {
  96. if(m_loLimit > m_hiLimit) return false;
  97. return true;
  98. }
  99. //! Need apply correction
  100. bool needApplyTorques()
  101. {
  102. if(m_currentLimit == 0 && m_enableMotor == false) return false;
  103. return true;
  104. }
  105. //! calculates error
  106. /*!
  107. calculates m_currentLimit and m_currentLimitError.
  108. */
  109. int testLimitValue(btScalar test_value);
  110. //! apply the correction impulses for two bodies
  111. btScalar solveAngularLimits(btScalar timeStep,btVector3& axis, btScalar jacDiagABInv,btRigidBody * body0, btRigidBody * body1);
  112. };
  113. class btTranslationalLimitMotor
  114. {
  115. public:
  116. btVector3 m_lowerLimit;//!< the constraint lower limits
  117. btVector3 m_upperLimit;//!< the constraint upper limits
  118. btVector3 m_accumulatedImpulse;
  119. //! Linear_Limit_parameters
  120. //!@{
  121. btScalar m_limitSoftness;//!< Softness for linear limit
  122. btScalar m_damping;//!< Damping for linear limit
  123. btScalar m_restitution;//! Bounce parameter for linear limit
  124. btVector3 m_normalCFM;//!< Constraint force mixing factor
  125. btVector3 m_stopERP;//!< Error tolerance factor when joint is at limit
  126. btVector3 m_stopCFM;//!< Constraint force mixing factor when joint is at limit
  127. //!@}
  128. bool m_enableMotor[3];
  129. btVector3 m_targetVelocity;//!< target motor velocity
  130. btVector3 m_maxMotorForce;//!< max force on motor
  131. btVector3 m_currentLimitError;//! How much is violated this limit
  132. btVector3 m_currentLinearDiff;//! Current relative offset of constraint frames
  133. int m_currentLimit[3];//!< 0=free, 1=at lower limit, 2=at upper limit
  134. btTranslationalLimitMotor()
  135. {
  136. m_lowerLimit.setValue(0.f,0.f,0.f);
  137. m_upperLimit.setValue(0.f,0.f,0.f);
  138. m_accumulatedImpulse.setValue(0.f,0.f,0.f);
  139. m_normalCFM.setValue(0.f, 0.f, 0.f);
  140. m_stopERP.setValue(0.2f, 0.2f, 0.2f);
  141. m_stopCFM.setValue(0.f, 0.f, 0.f);
  142. m_limitSoftness = 0.7f;
  143. m_damping = btScalar(1.0f);
  144. m_restitution = btScalar(0.5f);
  145. for(int i=0; i < 3; i++)
  146. {
  147. m_enableMotor[i] = false;
  148. m_targetVelocity[i] = btScalar(0.f);
  149. m_maxMotorForce[i] = btScalar(0.f);
  150. }
  151. }
  152. btTranslationalLimitMotor(const btTranslationalLimitMotor & other )
  153. {
  154. m_lowerLimit = other.m_lowerLimit;
  155. m_upperLimit = other.m_upperLimit;
  156. m_accumulatedImpulse = other.m_accumulatedImpulse;
  157. m_limitSoftness = other.m_limitSoftness ;
  158. m_damping = other.m_damping;
  159. m_restitution = other.m_restitution;
  160. m_normalCFM = other.m_normalCFM;
  161. m_stopERP = other.m_stopERP;
  162. m_stopCFM = other.m_stopCFM;
  163. for(int i=0; i < 3; i++)
  164. {
  165. m_enableMotor[i] = other.m_enableMotor[i];
  166. m_targetVelocity[i] = other.m_targetVelocity[i];
  167. m_maxMotorForce[i] = other.m_maxMotorForce[i];
  168. }
  169. }
  170. //! Test limit
  171. /*!
  172. - free means upper < lower,
  173. - locked means upper == lower
  174. - limited means upper > lower
  175. - limitIndex: first 3 are linear, next 3 are angular
  176. */
  177. inline bool isLimited(int limitIndex)
  178. {
  179. return (m_upperLimit[limitIndex] >= m_lowerLimit[limitIndex]);
  180. }
  181. inline bool needApplyForce(int limitIndex)
  182. {
  183. if(m_currentLimit[limitIndex] == 0 && m_enableMotor[limitIndex] == false) return false;
  184. return true;
  185. }
  186. int testLimitValue(int limitIndex, btScalar test_value);
  187. btScalar solveLinearAxis(
  188. btScalar timeStep,
  189. btScalar jacDiagABInv,
  190. btRigidBody& body1,const btVector3 &pointInA,
  191. btRigidBody& body2,const btVector3 &pointInB,
  192. int limit_index,
  193. const btVector3 & axis_normal_on_a,
  194. const btVector3 & anchorPos);
  195. };
  196. enum bt6DofFlags
  197. {
  198. BT_6DOF_FLAGS_CFM_NORM = 1,
  199. BT_6DOF_FLAGS_CFM_STOP = 2,
  200. BT_6DOF_FLAGS_ERP_STOP = 4
  201. };
  202. #define BT_6DOF_FLAGS_AXIS_SHIFT 3 // bits per axis
  203. /// btGeneric6DofConstraint between two rigidbodies each with a pivotpoint that descibes the axis location in local space
  204. /*!
  205. btGeneric6DofConstraint can leave any of the 6 degree of freedom 'free' or 'locked'.
  206. currently this limit supports rotational motors<br>
  207. <ul>
  208. <li> For Linear limits, use btGeneric6DofConstraint.setLinearUpperLimit, btGeneric6DofConstraint.setLinearLowerLimit. You can set the parameters with the btTranslationalLimitMotor structure accsesible through the btGeneric6DofConstraint.getTranslationalLimitMotor method.
  209. At this moment translational motors are not supported. May be in the future. </li>
  210. <li> For Angular limits, use the btRotationalLimitMotor structure for configuring the limit.
  211. This is accessible through btGeneric6DofConstraint.getLimitMotor method,
  212. This brings support for limit parameters and motors. </li>
  213. <li> Angulars limits have these possible ranges:
  214. <table border=1 >
  215. <tr>
  216. <td><b>AXIS</b></td>
  217. <td><b>MIN ANGLE</b></td>
  218. <td><b>MAX ANGLE</b></td>
  219. </tr><tr>
  220. <td>X</td>
  221. <td>-PI</td>
  222. <td>PI</td>
  223. </tr><tr>
  224. <td>Y</td>
  225. <td>-PI/2</td>
  226. <td>PI/2</td>
  227. </tr><tr>
  228. <td>Z</td>
  229. <td>-PI</td>
  230. <td>PI</td>
  231. </tr>
  232. </table>
  233. </li>
  234. </ul>
  235. */
  236. ATTRIBUTE_ALIGNED16(class) btGeneric6DofConstraint : public btTypedConstraint
  237. {
  238. protected:
  239. //! relative_frames
  240. //!@{
  241. btTransform m_frameInA;//!< the constraint space w.r.t body A
  242. btTransform m_frameInB;//!< the constraint space w.r.t body B
  243. //!@}
  244. //! Jacobians
  245. //!@{
  246. btJacobianEntry m_jacLinear[3];//!< 3 orthogonal linear constraints
  247. btJacobianEntry m_jacAng[3];//!< 3 orthogonal angular constraints
  248. //!@}
  249. //! Linear_Limit_parameters
  250. //!@{
  251. btTranslationalLimitMotor m_linearLimits;
  252. //!@}
  253. //! hinge_parameters
  254. //!@{
  255. btRotationalLimitMotor m_angularLimits[3];
  256. //!@}
  257. protected:
  258. //! temporal variables
  259. //!@{
  260. btScalar m_timeStep;
  261. btTransform m_calculatedTransformA;
  262. btTransform m_calculatedTransformB;
  263. btVector3 m_calculatedAxisAngleDiff;
  264. btVector3 m_calculatedAxis[3];
  265. btVector3 m_calculatedLinearDiff;
  266. btScalar m_factA;
  267. btScalar m_factB;
  268. bool m_hasStaticBody;
  269. btVector3 m_AnchorPos; // point betwen pivots of bodies A and B to solve linear axes
  270. bool m_useLinearReferenceFrameA;
  271. bool m_useOffsetForConstraintFrame;
  272. int m_flags;
  273. //!@}
  274. btGeneric6DofConstraint& operator=(btGeneric6DofConstraint& other)
  275. {
  276. btAssert(0);
  277. (void) other;
  278. return *this;
  279. }
  280. int setAngularLimits(btConstraintInfo2 *info, int row_offset,const btTransform& transA,const btTransform& transB,const btVector3& linVelA,const btVector3& linVelB,const btVector3& angVelA,const btVector3& angVelB);
  281. int setLinearLimits(btConstraintInfo2 *info, int row, const btTransform& transA,const btTransform& transB,const btVector3& linVelA,const btVector3& linVelB,const btVector3& angVelA,const btVector3& angVelB);
  282. void buildLinearJacobian(
  283. btJacobianEntry & jacLinear,const btVector3 & normalWorld,
  284. const btVector3 & pivotAInW,const btVector3 & pivotBInW);
  285. void buildAngularJacobian(btJacobianEntry & jacAngular,const btVector3 & jointAxisW);
  286. // tests linear limits
  287. void calculateLinearInfo();
  288. //! calcs the euler angles between the two bodies.
  289. void calculateAngleInfo();
  290. public:
  291. BT_DECLARE_ALIGNED_ALLOCATOR();
  292. ///for backwards compatibility during the transition to 'getInfo/getInfo2'
  293. bool m_useSolveConstraintObsolete;
  294. btGeneric6DofConstraint(btRigidBody& rbA, btRigidBody& rbB, const btTransform& frameInA, const btTransform& frameInB ,bool useLinearReferenceFrameA);
  295. btGeneric6DofConstraint(btRigidBody& rbB, const btTransform& frameInB, bool useLinearReferenceFrameB);
  296. //! Calcs global transform of the offsets
  297. /*!
  298. Calcs the global transform for the joint offset for body A an B, and also calcs the agle differences between the bodies.
  299. \sa btGeneric6DofConstraint.getCalculatedTransformA , btGeneric6DofConstraint.getCalculatedTransformB, btGeneric6DofConstraint.calculateAngleInfo
  300. */
  301. void calculateTransforms(const btTransform& transA,const btTransform& transB);
  302. void calculateTransforms();
  303. //! Gets the global transform of the offset for body A
  304. /*!
  305. \sa btGeneric6DofConstraint.getFrameOffsetA, btGeneric6DofConstraint.getFrameOffsetB, btGeneric6DofConstraint.calculateAngleInfo.
  306. */
  307. const btTransform & getCalculatedTransformA() const
  308. {
  309. return m_calculatedTransformA;
  310. }
  311. //! Gets the global transform of the offset for body B
  312. /*!
  313. \sa btGeneric6DofConstraint.getFrameOffsetA, btGeneric6DofConstraint.getFrameOffsetB, btGeneric6DofConstraint.calculateAngleInfo.
  314. */
  315. const btTransform & getCalculatedTransformB() const
  316. {
  317. return m_calculatedTransformB;
  318. }
  319. const btTransform & getFrameOffsetA() const
  320. {
  321. return m_frameInA;
  322. }
  323. const btTransform & getFrameOffsetB() const
  324. {
  325. return m_frameInB;
  326. }
  327. btTransform & getFrameOffsetA()
  328. {
  329. return m_frameInA;
  330. }
  331. btTransform & getFrameOffsetB()
  332. {
  333. return m_frameInB;
  334. }
  335. //! performs Jacobian calculation, and also calculates angle differences and axis
  336. virtual void buildJacobian();
  337. virtual void getInfo1 (btConstraintInfo1* info);
  338. void getInfo1NonVirtual (btConstraintInfo1* info);
  339. virtual void getInfo2 (btConstraintInfo2* info);
  340. void getInfo2NonVirtual (btConstraintInfo2* info,const btTransform& transA,const btTransform& transB,const btVector3& linVelA,const btVector3& linVelB,const btVector3& angVelA,const btVector3& angVelB);
  341. void updateRHS(btScalar timeStep);
  342. //! Get the rotation axis in global coordinates
  343. /*!
  344. \pre btGeneric6DofConstraint.buildJacobian must be called previously.
  345. */
  346. btVector3 getAxis(int axis_index) const;
  347. //! Get the relative Euler angle
  348. /*!
  349. \pre btGeneric6DofConstraint::calculateTransforms() must be called previously.
  350. */
  351. btScalar getAngle(int axis_index) const;
  352. //! Get the relative position of the constraint pivot
  353. /*!
  354. \pre btGeneric6DofConstraint::calculateTransforms() must be called previously.
  355. */
  356. btScalar getRelativePivotPosition(int axis_index) const;
  357. void setFrames(const btTransform & frameA, const btTransform & frameB);
  358. //! Test angular limit.
  359. /*!
  360. Calculates angular correction and returns true if limit needs to be corrected.
  361. \pre btGeneric6DofConstraint::calculateTransforms() must be called previously.
  362. */
  363. bool testAngularLimitMotor(int axis_index);
  364. void setLinearLowerLimit(const btVector3& linearLower)
  365. {
  366. m_linearLimits.m_lowerLimit = linearLower;
  367. }
  368. void getLinearLowerLimit(btVector3& linearLower)
  369. {
  370. linearLower = m_linearLimits.m_lowerLimit;
  371. }
  372. void setLinearUpperLimit(const btVector3& linearUpper)
  373. {
  374. m_linearLimits.m_upperLimit = linearUpper;
  375. }
  376. void getLinearUpperLimit(btVector3& linearUpper)
  377. {
  378. linearUpper = m_linearLimits.m_upperLimit;
  379. }
  380. void setAngularLowerLimit(const btVector3& angularLower)
  381. {
  382. for(int i = 0; i < 3; i++)
  383. m_angularLimits[i].m_loLimit = btNormalizeAngle(angularLower[i]);
  384. }
  385. void getAngularLowerLimit(btVector3& angularLower)
  386. {
  387. for(int i = 0; i < 3; i++)
  388. angularLower[i] = m_angularLimits[i].m_loLimit;
  389. }
  390. void setAngularUpperLimit(const btVector3& angularUpper)
  391. {
  392. for(int i = 0; i < 3; i++)
  393. m_angularLimits[i].m_hiLimit = btNormalizeAngle(angularUpper[i]);
  394. }
  395. void getAngularUpperLimit(btVector3& angularUpper)
  396. {
  397. for(int i = 0; i < 3; i++)
  398. angularUpper[i] = m_angularLimits[i].m_hiLimit;
  399. }
  400. //! Retrieves the angular limit informacion
  401. btRotationalLimitMotor * getRotationalLimitMotor(int index)
  402. {
  403. return &m_angularLimits[index];
  404. }
  405. //! Retrieves the limit informacion
  406. btTranslationalLimitMotor * getTranslationalLimitMotor()
  407. {
  408. return &m_linearLimits;
  409. }
  410. //first 3 are linear, next 3 are angular
  411. void setLimit(int axis, btScalar lo, btScalar hi)
  412. {
  413. if(axis<3)
  414. {
  415. m_linearLimits.m_lowerLimit[axis] = lo;
  416. m_linearLimits.m_upperLimit[axis] = hi;
  417. }
  418. else
  419. {
  420. lo = btNormalizeAngle(lo);
  421. hi = btNormalizeAngle(hi);
  422. m_angularLimits[axis-3].m_loLimit = lo;
  423. m_angularLimits[axis-3].m_hiLimit = hi;
  424. }
  425. }
  426. //! Test limit
  427. /*!
  428. - free means upper < lower,
  429. - locked means upper == lower
  430. - limited means upper > lower
  431. - limitIndex: first 3 are linear, next 3 are angular
  432. */
  433. bool isLimited(int limitIndex)
  434. {
  435. if(limitIndex<3)
  436. {
  437. return m_linearLimits.isLimited(limitIndex);
  438. }
  439. return m_angularLimits[limitIndex-3].isLimited();
  440. }
  441. virtual void calcAnchorPos(void); // overridable
  442. int get_limit_motor_info2( btRotationalLimitMotor * limot,
  443. const btTransform& transA,const btTransform& transB,const btVector3& linVelA,const btVector3& linVelB,const btVector3& angVelA,const btVector3& angVelB,
  444. btConstraintInfo2 *info, int row, btVector3& ax1, int rotational, int rotAllowed = false);
  445. // access for UseFrameOffset
  446. bool getUseFrameOffset() { return m_useOffsetForConstraintFrame; }
  447. void setUseFrameOffset(bool frameOffsetOnOff) { m_useOffsetForConstraintFrame = frameOffsetOnOff; }
  448. ///override the default global value of a parameter (such as ERP or CFM), optionally provide the axis (0..5).
  449. ///If no axis is provided, it uses the default axis for this constraint.
  450. virtual void setParam(int num, btScalar value, int axis = -1);
  451. ///return the local value of parameter
  452. virtual btScalar getParam(int num, int axis = -1) const;
  453. void setAxis( const btVector3& axis1, const btVector3& axis2);
  454. virtual int calculateSerializeBufferSize() const;
  455. ///fills the dataBuffer and returns the struct name (and 0 on failure)
  456. virtual const char* serialize(void* dataBuffer, btSerializer* serializer) const;
  457. };
  458. struct btGeneric6DofConstraintData
  459. {
  460. btTypedConstraintData m_typeConstraintData;
  461. btTransformFloatData m_rbAFrame; // constraint axii. Assumes z is hinge axis.
  462. btTransformFloatData m_rbBFrame;
  463. btVector3FloatData m_linearUpperLimit;
  464. btVector3FloatData m_linearLowerLimit;
  465. btVector3FloatData m_angularUpperLimit;
  466. btVector3FloatData m_angularLowerLimit;
  467. int m_useLinearReferenceFrameA;
  468. int m_useOffsetForConstraintFrame;
  469. };
  470. struct btGeneric6DofConstraintDoubleData2
  471. {
  472. btTypedConstraintDoubleData m_typeConstraintData;
  473. btTransformDoubleData m_rbAFrame; // constraint axii. Assumes z is hinge axis.
  474. btTransformDoubleData m_rbBFrame;
  475. btVector3DoubleData m_linearUpperLimit;
  476. btVector3DoubleData m_linearLowerLimit;
  477. btVector3DoubleData m_angularUpperLimit;
  478. btVector3DoubleData m_angularLowerLimit;
  479. int m_useLinearReferenceFrameA;
  480. int m_useOffsetForConstraintFrame;
  481. };
  482. SIMD_FORCE_INLINE int btGeneric6DofConstraint::calculateSerializeBufferSize() const
  483. {
  484. return sizeof(btGeneric6DofConstraintData2);
  485. }
  486. ///fills the dataBuffer and returns the struct name (and 0 on failure)
  487. SIMD_FORCE_INLINE const char* btGeneric6DofConstraint::serialize(void* dataBuffer, btSerializer* serializer) const
  488. {
  489. btGeneric6DofConstraintData2* dof = (btGeneric6DofConstraintData2*)dataBuffer;
  490. btTypedConstraint::serialize(&dof->m_typeConstraintData,serializer);
  491. m_frameInA.serialize(dof->m_rbAFrame);
  492. m_frameInB.serialize(dof->m_rbBFrame);
  493. int i;
  494. for (i=0;i<3;i++)
  495. {
  496. dof->m_angularLowerLimit.m_floats[i] = m_angularLimits[i].m_loLimit;
  497. dof->m_angularUpperLimit.m_floats[i] = m_angularLimits[i].m_hiLimit;
  498. dof->m_linearLowerLimit.m_floats[i] = m_linearLimits.m_lowerLimit[i];
  499. dof->m_linearUpperLimit.m_floats[i] = m_linearLimits.m_upperLimit[i];
  500. }
  501. dof->m_useLinearReferenceFrameA = m_useLinearReferenceFrameA? 1 : 0;
  502. dof->m_useOffsetForConstraintFrame = m_useOffsetForConstraintFrame ? 1 : 0;
  503. return btGeneric6DofConstraintDataName;
  504. }
  505. #endif //BT_GENERIC_6DOF_CONSTRAINT_H