b2_time_step.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // MIT License
  2. // Copyright (c) 2019 Erin Catto
  3. // Permission is hereby granted, free of charge, to any person obtaining a copy
  4. // of this software and associated documentation files (the "Software"), to deal
  5. // in the Software without restriction, including without limitation the rights
  6. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7. // copies of the Software, and to permit persons to whom the Software is
  8. // furnished to do so, subject to the following conditions:
  9. // The above copyright notice and this permission notice shall be included in all
  10. // copies or substantial portions of the Software.
  11. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  13. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  14. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  15. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  16. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  17. // SOFTWARE.
  18. #ifndef B2_TIME_STEP_H
  19. #define B2_TIME_STEP_H
  20. #include "b2_api.h"
  21. #include "b2_math.h"
  22. /// Profiling data. Times are in milliseconds.
  23. struct B2_API b2Profile
  24. {
  25. float step;
  26. float collide;
  27. float solve;
  28. float solveInit;
  29. float solveVelocity;
  30. float solvePosition;
  31. float broadphase;
  32. float solveTOI;
  33. };
  34. /// This is an internal structure.
  35. struct B2_API b2TimeStep
  36. {
  37. float dt; // time step
  38. float inv_dt; // inverse time step (0 if dt == 0).
  39. float dtRatio; // dt * inv_dt0
  40. int32 velocityIterations;
  41. int32 positionIterations;
  42. bool warmStarting;
  43. };
  44. /// This is an internal structure.
  45. struct B2_API b2Position
  46. {
  47. b2Vec2 c;
  48. float a;
  49. };
  50. /// This is an internal structure.
  51. struct B2_API b2Velocity
  52. {
  53. b2Vec2 v;
  54. float w;
  55. };
  56. /// Solver Data
  57. struct B2_API b2SolverData
  58. {
  59. b2TimeStep step;
  60. b2Position* positions;
  61. b2Velocity* velocities;
  62. };
  63. #endif