collision_space.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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. ODE_API void dSpaceAdd (dSpaceID, dGeomID);
  99. ODE_API void dSpaceRemove (dSpaceID, dGeomID);
  100. ODE_API int dSpaceQuery (dSpaceID, dGeomID);
  101. ODE_API void dSpaceClean (dSpaceID);
  102. ODE_API int dSpaceGetNumGeoms (dSpaceID);
  103. ODE_API dGeomID dSpaceGetGeom (dSpaceID, int i);
  104. /**
  105. * @brief Given a space, this returns its class.
  106. *
  107. * The ODE classes are:
  108. * @li dSimpleSpaceClass
  109. * @li dHashSpaceClass
  110. * @li dSweepAndPruneSpaceClass
  111. * @li dQuadTreeSpaceClass
  112. * @li dFirstUserClass
  113. * @li dLastUserClass
  114. *
  115. * The class id not defined by the user should be between
  116. * dFirstSpaceClass and dLastSpaceClass.
  117. *
  118. * User-defined class will return their own number.
  119. *
  120. * @param space the space to query
  121. * @returns The space class ID.
  122. * @ingroup collide
  123. */
  124. ODE_API int dSpaceGetClass(dSpaceID space);
  125. #ifdef __cplusplus
  126. }
  127. #endif
  128. #endif