2
0

btBatchedConstraints.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. #ifndef BT_BATCHED_CONSTRAINTS_H
  14. #define BT_BATCHED_CONSTRAINTS_H
  15. #include "LinearMath/btThreads.h"
  16. #include "LinearMath/btAlignedObjectArray.h"
  17. #include "BulletDynamics/ConstraintSolver/btSolverBody.h"
  18. #include "BulletDynamics/ConstraintSolver/btSolverConstraint.h"
  19. class btIDebugDraw;
  20. struct btBatchedConstraints
  21. {
  22. enum BatchingMethod
  23. {
  24. BATCHING_METHOD_SPATIAL_GRID_2D,
  25. BATCHING_METHOD_SPATIAL_GRID_3D,
  26. BATCHING_METHOD_COUNT
  27. };
  28. struct Range
  29. {
  30. int begin;
  31. int end;
  32. Range() : begin(0), end(0) {}
  33. Range(int _beg, int _end) : begin(_beg), end(_end) {}
  34. };
  35. btAlignedObjectArray<int> m_constraintIndices;
  36. btAlignedObjectArray<Range> m_batches; // each batch is a range of indices in the m_constraintIndices array
  37. btAlignedObjectArray<Range> m_phases; // each phase is range of indices in the m_batches array
  38. btAlignedObjectArray<char> m_phaseGrainSize; // max grain size for each phase
  39. btAlignedObjectArray<int> m_phaseOrder; // phases can be done in any order, so we can randomize the order here
  40. btIDebugDraw* m_debugDrawer;
  41. static bool s_debugDrawBatches;
  42. btBatchedConstraints() { m_debugDrawer = NULL; }
  43. void setup(btConstraintArray* constraints,
  44. const btAlignedObjectArray<btSolverBody>& bodies,
  45. BatchingMethod batchingMethod,
  46. int minBatchSize,
  47. int maxBatchSize,
  48. btAlignedObjectArray<char>* scratchMemory);
  49. bool validate(btConstraintArray* constraints, const btAlignedObjectArray<btSolverBody>& bodies) const;
  50. };
  51. #endif // BT_BATCHED_CONSTRAINTS_H