cpCompat62.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /* Copyright (c) 2013 Scott Lembcke and Howling Moon Software
  2. *
  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. *
  10. * The above copyright notice and this permission notice shall be included in
  11. * all copies or substantial portions of the Software.
  12. *
  13. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  19. * SOFTWARE.
  20. */
  21. #ifndef CHIPMUNK_COMPAT_62_H
  22. #define CHIPMUNK_COMPAT_62_H
  23. #include "chipmunk/chipmunk.h"
  24. //
  25. // Body
  26. //
  27. inline cpVect cpBodyGetVelAtWorldPoint(const cpBody *body)
  28. {
  29. return cpBodyGetVelocityAtWorldPoint(body);
  30. }
  31. inline cpVect cpBodyGetVelAtLocalPoint(const cpBody *body)
  32. {
  33. return cpBodyGetVelocityAtLocalPoint(body);
  34. }
  35. inline cpVect cpBodyGetVel(const cpBody *body)
  36. {
  37. return cpBodyGetVelocity(body);
  38. }
  39. inline void cpBodySetVel(cpBody *body, cpVect velocity)
  40. {
  41. cpBodySetVelocity(body, velocity);
  42. }
  43. inline cpVect cpBodyGetPos(const cpBody *body)
  44. {
  45. return cpBodyGetPosition(body);
  46. }
  47. inline void cpBodySetPos(cpBody *body, cpVect pos)
  48. {
  49. cpBodySetPosition(body, pos);
  50. }
  51. inline cpVect cpBodyGetRot(const cpBody *body)
  52. {
  53. return cpBodyGetRotation(body);
  54. }
  55. inline cpFloat cpBodyGetAngVel(const cpBody *body)
  56. {
  57. return cpBodyGetAngularVelocity(body);
  58. }
  59. inline void cpBodySetAngVel(cpBody *body, cpFloat angularVelocity)
  60. {
  61. cpBodySetAngularVelocity(body, angularVelocity);
  62. }
  63. inline cpVect cpBodyLocal2World(const cpBody *body, const cpVect point)
  64. {
  65. return cpBodyLocalToWorld(body, point);
  66. }
  67. inline cpVect cpBodyWorld2Local(const cpBody *body, const cpVect point)
  68. {
  69. return cpBodyWorldToLocal(body, point);
  70. }
  71. inline void cpBodyApplyImpulse(cpBody *body, const cpVect j, const cpVect r)
  72. {
  73. cpBodyApplyImpulseAtWorldPoint(body, j, r);
  74. }
  75. //
  76. // Shapes
  77. //
  78. inline void cpShapeSetLayers(cpShape* shape, unsigned int layer)
  79. {
  80. cpShapeFilter filter = cpShapeGetFilter(shape);
  81. filter.mask = layer;
  82. filter.categories = layer;
  83. cpShapeSetFilter(shape, filter);
  84. }
  85. inline unsigned int cpShapeGetLayers(cpShape* shape)
  86. {
  87. cpShapeFilter filter = cpShapeGetFilter(shape);
  88. return filter.mask;
  89. }
  90. inline void cpShapeSetGroup(cpShape* shape, uintptr_t group)
  91. {
  92. cpShapeFilter filter = cpShapeGetFilter(shape);
  93. filter.group = group;
  94. cpShapeSetFilter(shape, filter);
  95. }
  96. inline uintptr_t cpShapeGetGroup(cpShape* shape)
  97. {
  98. cpShapeFilter filter = cpShapeGetFilter(shape);
  99. return filter.group;
  100. }
  101. inline int cpPolyShapeGetNumVerts(const cpShape *shape)
  102. {
  103. return cpPolyShapeGetCount(shape);
  104. }
  105. inline cpFloat cpShapeNearestPointQuery(cpShape *shape, cpVect p, cpPointQueryInfo *out)
  106. {
  107. return cpShapePointQuery(shape, p, out);
  108. }
  109. //
  110. // Space
  111. //
  112. inline cpShape* cpSpaceAddStaticShape(cpSpace *space, cpShape *shape)
  113. {
  114. return cpSpaceAddShape(space, shape);
  115. }
  116. #endif // CHIPMUNK_COMPAT_62_H