]> git.xonotic.org Git - xonotic/xonotic.git/blob - misc/builddeps/dp.linux32/include/ode/collision_space.h
Handle errors right.
[xonotic/xonotic.git] / misc / builddeps / dp.linux32 / include / ode / collision_space.h
1 /*************************************************************************
2  *                                                                       *
3  * Open Dynamics Engine, Copyright (C) 2001-2003 Russell L. Smith.       *
4  * All rights reserved.  Email: russ@q12.org   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
23 #ifndef _ODE_COLLISION_SPACE_H_
24 #define _ODE_COLLISION_SPACE_H_
25
26 #include <ode/common.h>
27
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31
32 struct dContactGeom;
33
34 /**
35  * @brief User callback for geom-geom collision testing.
36  *
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.
40  *
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.
46  *
47  * @ingroup collide
48  */
49 typedef void dNearCallback (void *data, dGeomID o1, dGeomID o2);
50
51
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);
55
56
57 // SAP
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))
65
66 ODE_API dSpaceID dSweepAndPruneSpaceCreate( dSpaceID space, int axisorder );
67
68
69
70 ODE_API void dSpaceDestroy (dSpaceID);
71
72 ODE_API void dHashSpaceSetLevels (dSpaceID space, int minlevel, int maxlevel);
73 ODE_API void dHashSpaceGetLevels (dSpaceID space, int *minlevel, int *maxlevel);
74
75 ODE_API void dSpaceSetCleanup (dSpaceID space, int mode);
76 ODE_API int dSpaceGetCleanup (dSpaceID space);
77
78 /**
79 * @brief Sets sublevel value for a space.
80 *
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
87 * zero sublevel.
88 *
89 * @note
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
92 * value if necessary.
93 *
94 * @param space the space to modify
95 * @param sublevel the sublevel value to be assigned
96 * @ingroup collide
97 * @see dSpaceGetSublevel
98 * @see dSpaceCollide2
99 */
100 ODE_API void dSpaceSetSublevel (dSpaceID space, int sublevel);
101
102 /**
103 * @brief Gets sublevel value of a space.
104 *
105 * Sublevel affects how the space is handled in dSpaceCollide2 when it is collided
106 * with another space. See @c dSpaceSetSublevel for more details.
107 *
108 * @param space the space to query
109 * @returns the sublevel value of the space
110 * @ingroup collide
111 * @see dSpaceSetSublevel
112 * @see dSpaceCollide2
113 */
114 ODE_API int dSpaceGetSublevel (dSpaceID space);
115
116
117 /**
118 * @brief Sets manual cleanup flag for a space.
119 *
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.
123
124 * Failure to set manual cleanup flag for a space may lead to some resources 
125 * remaining leaked until the program exit.
126 *
127 * @param space the space to modify
128 * @param mode 1 for manual cleanup mode and 0 for default cleanup mode
129 * @ingroup collide
130 * @see dSpaceGetManualCleanup
131 * @see dInitODE2
132 */
133 ODE_API void dSpaceSetManualCleanup (dSpaceID space, int mode);
134
135 /**
136 * @brief Get manual cleanup flag of a space.
137 *
138 * Manual cleanup flag marks a space space as eligible for manual thread data cleanup.
139 * See @c dSpaceSetManualCleanup for more details.
140
141 * @param space the space to query
142 * @returns 1 for manual cleanup mode and 0 for default cleanup mode of the space
143 * @ingroup collide
144 * @see dSpaceSetManualCleanup
145 * @see dInitODE2
146 */
147 ODE_API int dSpaceGetManualCleanup (dSpaceID space);
148
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);
155
156 /**
157  * @brief Given a space, this returns its class.
158  *
159  * The ODE classes are:
160  *  @li dSimpleSpaceClass
161  *  @li dHashSpaceClass
162  *  @li dSweepAndPruneSpaceClass
163  *  @li dQuadTreeSpaceClass
164  *  @li dFirstUserClass
165  *  @li dLastUserClass
166  *
167  * The class id not defined by the user should be between
168  * dFirstSpaceClass and dLastSpaceClass.
169  *
170  * User-defined class will return their own number.
171  *
172  * @param space the space to query
173  * @returns The space class ID.
174  * @ingroup collide
175  */
176 ODE_API int dSpaceGetClass(dSpaceID space);
177
178 #ifdef __cplusplus
179 }
180 #endif
181
182 #endif