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