collision_space.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. /*************************************************************************
  2. * *
  3. * Open Dynamics Engine, Copyright (C) 2001-2003 Russell L. Smith. *
  4. * All rights reserved. Email: [email protected] Web: www.q12.org *
  5. * *
  6. * This library is free software; you can redistribute it and/or *
  7. * modify it under the terms of EITHER: *
  8. * (1) The GNU Lesser General Public License as published by the Free *
  9. * Software Foundation; either version 2.1 of the License, or (at *
  10. * your option) any later version. The text of the GNU Lesser *
  11. * General Public License is included with this library in the *
  12. * file LICENSE.TXT. *
  13. * (2) The BSD-style license that is included with this library in *
  14. * the file LICENSE-BSD.TXT. *
  15. * *
  16. * This library is distributed in the hope that it will be useful, *
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
  19. * LICENSE.TXT and LICENSE-BSD.TXT for more details. *
  20. * *
  21. *************************************************************************/
  22. #ifndef _ODE_COLLISION_SPACE_H_
  23. #define _ODE_COLLISION_SPACE_H_
  24. #include <ode/common.h>
  25. #ifdef __cplusplus
  26. extern "C" {
  27. #endif
  28. struct dContactGeom;
  29. /**
  30. * @brief User callback for geom-geom collision testing.
  31. *
  32. * @param data The user data object, as passed to dSpaceCollide.
  33. * @param o1 The first geom being tested.
  34. * @param o2 The second geom being test.
  35. *
  36. * @remarks The callback function can call dCollide on o1 and o2 to generate
  37. * contact points between each pair. Then these contact points may be added
  38. * to the simulation as contact joints. The user's callback function can of
  39. * course chose not to call dCollide for any pair, e.g. if the user decides
  40. * that those pairs should not interact.
  41. *
  42. * @ingroup collide
  43. */
  44. typedef void dNearCallback (void *data, dGeomID o1, dGeomID o2);
  45. ODE_API dSpaceID dSimpleSpaceCreate (dSpaceID space);
  46. ODE_API dSpaceID dHashSpaceCreate (dSpaceID space);
  47. ODE_API dSpaceID dQuadTreeSpaceCreate (dSpaceID space, const dVector3 Center, const dVector3 Extents, int Depth);
  48. /* SAP */
  49. /* Order XZY or ZXY usually works best, if your Y is up. */
  50. #define dSAP_AXES_XYZ ((0)|(1<<2)|(2<<4))
  51. #define dSAP_AXES_XZY ((0)|(2<<2)|(1<<4))
  52. #define dSAP_AXES_YXZ ((1)|(0<<2)|(2<<4))
  53. #define dSAP_AXES_YZX ((1)|(2<<2)|(0<<4))
  54. #define dSAP_AXES_ZXY ((2)|(0<<2)|(1<<4))
  55. #define dSAP_AXES_ZYX ((2)|(1<<2)|(0<<4))
  56. ODE_API dSpaceID dSweepAndPruneSpaceCreate( dSpaceID space, int axisorder );
  57. ODE_API void dSpaceDestroy (dSpaceID);
  58. ODE_API void dHashSpaceSetLevels (dSpaceID space, int minlevel, int maxlevel);
  59. ODE_API void dHashSpaceGetLevels (dSpaceID space, int *minlevel, int *maxlevel);
  60. ODE_API void dSpaceSetCleanup (dSpaceID space, int mode);
  61. ODE_API int dSpaceGetCleanup (dSpaceID space);
  62. /**
  63. * @brief Sets sublevel value for a space.
  64. *
  65. * Sublevel affects how the space is handled in dSpaceCollide2 when it is collided
  66. * with another space. If sublevels of both spaces match, the function iterates
  67. * geometries of both spaces and collides them with each other. If sublevel of one
  68. * space is greater than the sublevel of another one, only the geometries of the
  69. * space with greater sublevel are iterated, another space is passed into
  70. * collision callback as a geometry itself. By default all the spaces are assigned
  71. * zero sublevel.
  72. *
  73. * @note
  74. * The space sublevel @e IS @e NOT automatically updated when one space is inserted
  75. * into another or removed from one. It is a client's responsibility to update sublevel
  76. * value if necessary.
  77. *
  78. * @param space the space to modify
  79. * @param sublevel the sublevel value to be assigned
  80. * @ingroup collide
  81. * @see dSpaceGetSublevel
  82. * @see dSpaceCollide2
  83. */
  84. ODE_API void dSpaceSetSublevel (dSpaceID space, int sublevel);
  85. /**
  86. * @brief Gets sublevel value of a space.
  87. *
  88. * Sublevel affects how the space is handled in dSpaceCollide2 when it is collided
  89. * with another space. See @c dSpaceSetSublevel for more details.
  90. *
  91. * @param space the space to query
  92. * @returns the sublevel value of the space
  93. * @ingroup collide
  94. * @see dSpaceSetSublevel
  95. * @see dSpaceCollide2
  96. */
  97. ODE_API int dSpaceGetSublevel (dSpaceID space);
  98. /**
  99. * @brief Sets manual cleanup flag for a space.
  100. *
  101. * Manual cleanup flag marks a space as eligible for manual thread data cleanup.
  102. * This function should be called for every space object right after creation in
  103. * case if ODE has been initialized with @c dInitFlagManualThreadCleanup flag.
  104. *
  105. * Failure to set manual cleanup flag for a space may lead to some resources
  106. * remaining leaked until the program exit.
  107. *
  108. * @param space the space to modify
  109. * @param mode 1 for manual cleanup mode and 0 for default cleanup mode
  110. * @ingroup collide
  111. * @see dSpaceGetManualCleanup
  112. * @see dInitODE2
  113. */
  114. ODE_API void dSpaceSetManualCleanup (dSpaceID space, int mode);
  115. /**
  116. * @brief Get manual cleanup flag of a space.
  117. *
  118. * Manual cleanup flag marks a space space as eligible for manual thread data cleanup.
  119. * See @c dSpaceSetManualCleanup for more details.
  120. *
  121. * @param space the space to query
  122. * @returns 1 for manual cleanup mode and 0 for default cleanup mode of the space
  123. * @ingroup collide
  124. * @see dSpaceSetManualCleanup
  125. * @see dInitODE2
  126. */
  127. ODE_API int dSpaceGetManualCleanup (dSpaceID space);
  128. ODE_API void dSpaceAdd (dSpaceID, dGeomID);
  129. ODE_API void dSpaceRemove (dSpaceID, dGeomID);
  130. ODE_API int dSpaceQuery (dSpaceID, dGeomID);
  131. ODE_API void dSpaceClean (dSpaceID);
  132. ODE_API int dSpaceGetNumGeoms (dSpaceID);
  133. ODE_API dGeomID dSpaceGetGeom (dSpaceID, int i);
  134. /**
  135. * @brief Given a space, this returns its class.
  136. *
  137. * The ODE classes are:
  138. * @li dSimpleSpaceClass
  139. * @li dHashSpaceClass
  140. * @li dSweepAndPruneSpaceClass
  141. * @li dQuadTreeSpaceClass
  142. * @li dFirstUserClass
  143. * @li dLastUserClass
  144. *
  145. * The class id not defined by the user should be between
  146. * dFirstSpaceClass and dLastSpaceClass.
  147. *
  148. * User-defined class will return their own number.
  149. *
  150. * @param space the space to query
  151. * @returns The space class ID.
  152. * @ingroup collide
  153. */
  154. ODE_API int dSpaceGetClass(dSpaceID space);
  155. #ifdef __cplusplus
  156. }
  157. #endif
  158. #endif