1 /*************************************************************************
3 * Open Dynamics Engine, Copyright (C) 2001-2003 Russell L. Smith. *
4 * All rights reserved. Email: russ@q12.org Web: www.q12.org *
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 *
13 * (2) The BSD-style license that is included with this library in *
14 * the file LICENSE-BSD.TXT. *
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. *
21 *************************************************************************/
23 #ifndef _ODE_COLLISION_SPACE_H_
24 #define _ODE_COLLISION_SPACE_H_
26 #include <ode/common.h>
35 * @brief User callback for geom-geom collision testing.
37 * @param data The user data object, as passed to dSpaceCollide.
38 * @param o1 The first geom being tested.
39 * @param o2 The second geom being test.
41 * @remarks The callback function can call dCollide on o1 and o2 to generate
42 * contact points between each pair. Then these contact points may be added
43 * to the simulation as contact joints. The user's callback function can of
44 * course chose not to call dCollide for any pair, e.g. if the user decides
45 * that those pairs should not interact.
49 typedef void dNearCallback (void *data, dGeomID o1, dGeomID o2);
52 ODE_API dSpaceID dSimpleSpaceCreate (dSpaceID space);
53 ODE_API dSpaceID dHashSpaceCreate (dSpaceID space);
54 ODE_API dSpaceID dQuadTreeSpaceCreate (dSpaceID space, const dVector3 Center, const dVector3 Extents, int Depth);
58 // Order XZY or ZXY usually works best, if your Y is up.
59 #define dSAP_AXES_XYZ ((0)|(1<<2)|(2<<4))
60 #define dSAP_AXES_XZY ((0)|(2<<2)|(1<<4))
61 #define dSAP_AXES_YXZ ((1)|(0<<2)|(2<<4))
62 #define dSAP_AXES_YZX ((1)|(2<<2)|(0<<4))
63 #define dSAP_AXES_ZXY ((2)|(0<<2)|(1<<4))
64 #define dSAP_AXES_ZYX ((2)|(1<<2)|(0<<4))
66 ODE_API dSpaceID dSweepAndPruneSpaceCreate( dSpaceID space, int axisorder );
70 ODE_API void dSpaceDestroy (dSpaceID);
72 ODE_API void dHashSpaceSetLevels (dSpaceID space, int minlevel, int maxlevel);
73 ODE_API void dHashSpaceGetLevels (dSpaceID space, int *minlevel, int *maxlevel);
75 ODE_API void dSpaceSetCleanup (dSpaceID space, int mode);
76 ODE_API int dSpaceGetCleanup (dSpaceID space);
79 * @brief Sets sublevel value for a space.
81 * Sublevel affects how the space is handled in dSpaceCollide2 when it is collided
82 * with another space. If sublevels of both spaces match, the function iterates
83 * geometries of both spaces and collides them with each other. If sublevel of one
84 * space is greater than the sublevel of another one, only the geometries of the
85 * space with greater sublevel are iterated, another space is passed into
86 * collision callback as a geometry itself. By default all the spaces are assigned
90 * The space sublevel @e IS @e NOT automatically updated when one space is inserted
91 * into another or removed from one. It is a client's responsibility to update sublevel
94 * @param space the space to modify
95 * @param sublevel the sublevel value to be assigned
97 * @see dSpaceGetSublevel
100 ODE_API void dSpaceSetSublevel (dSpaceID space, int sublevel);
103 * @brief Gets sublevel value of a space.
105 * Sublevel affects how the space is handled in dSpaceCollide2 when it is collided
106 * with another space. See @c dSpaceSetSublevel for more details.
108 * @param space the space to query
109 * @returns the sublevel value of the space
111 * @see dSpaceSetSublevel
112 * @see dSpaceCollide2
114 ODE_API int dSpaceGetSublevel (dSpaceID space);
118 * @brief Sets manual cleanup flag for a space.
120 * Manual cleanup flag marks a space as eligible for manual thread data cleanup.
121 * This function should be called for every space object right after creation in
122 * case if ODE has been initialized with @c dInitFlagManualThreadCleanup flag.
124 * Failure to set manual cleanup flag for a space may lead to some resources
125 * remaining leaked until the program exit.
127 * @param space the space to modify
128 * @param mode 1 for manual cleanup mode and 0 for default cleanup mode
130 * @see dSpaceGetManualCleanup
133 ODE_API void dSpaceSetManualCleanup (dSpaceID space, int mode);
136 * @brief Get manual cleanup flag of a space.
138 * Manual cleanup flag marks a space space as eligible for manual thread data cleanup.
139 * See @c dSpaceSetManualCleanup for more details.
141 * @param space the space to query
142 * @returns 1 for manual cleanup mode and 0 for default cleanup mode of the space
144 * @see dSpaceSetManualCleanup
147 ODE_API int dSpaceGetManualCleanup (dSpaceID space);
149 ODE_API void dSpaceAdd (dSpaceID, dGeomID);
150 ODE_API void dSpaceRemove (dSpaceID, dGeomID);
151 ODE_API int dSpaceQuery (dSpaceID, dGeomID);
152 ODE_API void dSpaceClean (dSpaceID);
153 ODE_API int dSpaceGetNumGeoms (dSpaceID);
154 ODE_API dGeomID dSpaceGetGeom (dSpaceID, int i);
157 * @brief Given a space, this returns its class.
159 * The ODE classes are:
160 * @li dSimpleSpaceClass
161 * @li dHashSpaceClass
162 * @li dSweepAndPruneSpaceClass
163 * @li dQuadTreeSpaceClass
164 * @li dFirstUserClass
167 * The class id not defined by the user should be between
168 * dFirstSpaceClass and dLastSpaceClass.
170 * User-defined class will return their own number.
172 * @param space the space to query
173 * @returns The space class ID.
176 ODE_API int dSpaceGetClass(dSpaceID space);