b3GpuGenericConstraint.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /*
  2. Copyright (c) 2013 Advanced Micro Devices, Inc.
  3. This software is provided 'as-is', without any express or implied warranty.
  4. In no event will the authors be held liable for any damages arising from the use of this software.
  5. Permission is granted to anyone to use this software for any purpose,
  6. including commercial applications, and to alter it and redistribute it freely,
  7. subject to the following restrictions:
  8. 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.
  9. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
  10. 3. This notice may not be removed or altered from any source distribution.
  11. */
  12. //Originally written by Erwin Coumans
  13. #ifndef B3_GPU_GENERIC_CONSTRAINT_H
  14. #define B3_GPU_GENERIC_CONSTRAINT_H
  15. #include "Bullet3Common/b3Quaternion.h"
  16. struct b3RigidBodyData;
  17. enum B3_CONSTRAINT_FLAGS
  18. {
  19. B3_CONSTRAINT_FLAG_ENABLED = 1,
  20. };
  21. enum b3GpuGenericConstraintType
  22. {
  23. B3_GPU_POINT2POINT_CONSTRAINT_TYPE = 3,
  24. B3_GPU_FIXED_CONSTRAINT_TYPE = 4,
  25. // B3_HINGE_CONSTRAINT_TYPE,
  26. // B3_CONETWIST_CONSTRAINT_TYPE,
  27. // B3_D6_CONSTRAINT_TYPE,
  28. // B3_SLIDER_CONSTRAINT_TYPE,
  29. // B3_CONTACT_CONSTRAINT_TYPE,
  30. // B3_D6_SPRING_CONSTRAINT_TYPE,
  31. // B3_GEAR_CONSTRAINT_TYPE,
  32. B3_GPU_MAX_CONSTRAINT_TYPE
  33. };
  34. struct b3GpuConstraintInfo2
  35. {
  36. // integrator parameters: frames per second (1/stepsize), default error
  37. // reduction parameter (0..1).
  38. b3Scalar fps, erp;
  39. // for the first and second body, pointers to two (linear and angular)
  40. // n*3 jacobian sub matrices, stored by rows. these matrices will have
  41. // been initialized to 0 on entry. if the second body is zero then the
  42. // J2xx pointers may be 0.
  43. b3Scalar *m_J1linearAxis, *m_J1angularAxis, *m_J2linearAxis, *m_J2angularAxis;
  44. // elements to jump from one row to the next in J's
  45. int rowskip;
  46. // right hand sides of the equation J*v = c + cfm * lambda. cfm is the
  47. // "constraint force mixing" vector. c is set to zero on entry, cfm is
  48. // set to a constant value (typically very small or zero) value on entry.
  49. b3Scalar *m_constraintError, *cfm;
  50. // lo and hi limits for variables (set to -/+ infinity on entry).
  51. b3Scalar *m_lowerLimit, *m_upperLimit;
  52. // findex vector for variables. see the LCP solver interface for a
  53. // description of what this does. this is set to -1 on entry.
  54. // note that the returned indexes are relative to the first index of
  55. // the constraint.
  56. int* findex;
  57. // number of solver iterations
  58. int m_numIterations;
  59. //damping of the velocity
  60. b3Scalar m_damping;
  61. };
  62. B3_ATTRIBUTE_ALIGNED16(struct)
  63. b3GpuGenericConstraint
  64. {
  65. int m_constraintType;
  66. int m_rbA;
  67. int m_rbB;
  68. float m_breakingImpulseThreshold;
  69. b3Vector3 m_pivotInA;
  70. b3Vector3 m_pivotInB;
  71. b3Quaternion m_relTargetAB;
  72. int m_flags;
  73. int m_uid;
  74. int m_padding[2];
  75. int getRigidBodyA() const
  76. {
  77. return m_rbA;
  78. }
  79. int getRigidBodyB() const
  80. {
  81. return m_rbB;
  82. }
  83. const b3Vector3& getPivotInA() const
  84. {
  85. return m_pivotInA;
  86. }
  87. const b3Vector3& getPivotInB() const
  88. {
  89. return m_pivotInB;
  90. }
  91. int isEnabled() const
  92. {
  93. return m_flags & B3_CONSTRAINT_FLAG_ENABLED;
  94. }
  95. float getBreakingImpulseThreshold() const
  96. {
  97. return m_breakingImpulseThreshold;
  98. }
  99. ///internal method used by the constraint solver, don't use them directly
  100. void getInfo1(unsigned int* info, const b3RigidBodyData* bodies);
  101. ///internal method used by the constraint solver, don't use them directly
  102. void getInfo2(b3GpuConstraintInfo2 * info, const b3RigidBodyData* bodies);
  103. };
  104. #endif //B3_GPU_GENERIC_CONSTRAINT_H