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_H_
24
#define _ODE_COLLISION_H_
26
#include <ode/common.h>
27
#include <ode/collision_space.h>
28
#include <ode/contact.h>
34
/* ************************************************************************ */
35
/* general functions */
37
void dGeomDestroy (dGeomID);
38
void dGeomSetData (dGeomID, void *);
39
void *dGeomGetData (dGeomID);
40
void dGeomSetBody (dGeomID, dBodyID);
41
dBodyID dGeomGetBody (dGeomID);
42
void dGeomSetPosition (dGeomID, dReal x, dReal y, dReal z);
43
void dGeomSetRotation (dGeomID, const dMatrix3 R);
44
void dGeomSetQuaternion (dGeomID, const dQuaternion);
45
const dReal * dGeomGetPosition (dGeomID);
46
const dReal * dGeomGetRotation (dGeomID);
47
void dGeomGetQuaternion (dGeomID, dQuaternion result);
48
void dGeomGetAABB (dGeomID, dReal aabb[6]);
49
int dGeomIsSpace (dGeomID);
50
dSpaceID dGeomGetSpace (dGeomID);
51
int dGeomGetClass (dGeomID);
52
void dGeomSetCategoryBits (dGeomID, unsigned long bits);
53
void dGeomSetCollideBits (dGeomID, unsigned long bits);
54
unsigned long dGeomGetCategoryBits (dGeomID);
55
unsigned long dGeomGetCollideBits (dGeomID);
56
void dGeomEnable (dGeomID);
57
void dGeomDisable (dGeomID);
58
int dGeomIsEnabled (dGeomID);
60
/* ************************************************************************ */
61
/* collision detection */
63
int dCollide (dGeomID o1, dGeomID o2, int flags, dContactGeom *contact,
65
void dSpaceCollide (dSpaceID space, void *data, dNearCallback *callback);
66
void dSpaceCollide2 (dGeomID o1, dGeomID o2, void *data,
67
dNearCallback *callback);
69
/* ************************************************************************ */
70
/* standard classes */
72
/* the maximum number of user classes that are supported */
77
/* class numbers - each geometry object needs a unique number */
89
dSimpleSpaceClass = dFirstSpaceClass,
92
dLastSpaceClass = dQuadTreeSpaceClass,
95
dLastUserClass = dFirstUserClass + dMaxUserClasses - 1,
100
dGeomID dCreateSphere (dSpaceID space, dReal radius);
101
void dGeomSphereSetRadius (dGeomID sphere, dReal radius);
102
dReal dGeomSphereGetRadius (dGeomID sphere);
103
dReal dGeomSpherePointDepth (dGeomID sphere, dReal x, dReal y, dReal z);
105
dGeomID dCreateBox (dSpaceID space, dReal lx, dReal ly, dReal lz);
106
void dGeomBoxSetLengths (dGeomID box, dReal lx, dReal ly, dReal lz);
107
void dGeomBoxGetLengths (dGeomID box, dVector3 result);
108
dReal dGeomBoxPointDepth (dGeomID box, dReal x, dReal y, dReal z);
110
dGeomID dCreatePlane (dSpaceID space, dReal a, dReal b, dReal c, dReal d);
111
void dGeomPlaneSetParams (dGeomID plane, dReal a, dReal b, dReal c, dReal d);
112
void dGeomPlaneGetParams (dGeomID plane, dVector4 result);
113
dReal dGeomPlanePointDepth (dGeomID plane, dReal x, dReal y, dReal z);
115
dGeomID dCreateCCylinder (dSpaceID space, dReal radius, dReal length);
116
void dGeomCCylinderSetParams (dGeomID ccylinder, dReal radius, dReal length);
117
void dGeomCCylinderGetParams (dGeomID ccylinder, dReal *radius, dReal *length);
118
dReal dGeomCCylinderPointDepth (dGeomID ccylinder, dReal x, dReal y, dReal z);
120
dGeomID dCreateRay (dSpaceID space, dReal length);
121
void dGeomRaySetLength (dGeomID ray, dReal length);
122
dReal dGeomRayGetLength (dGeomID ray);
123
void dGeomRaySet (dGeomID ray, dReal px, dReal py, dReal pz,
124
dReal dx, dReal dy, dReal dz);
125
void dGeomRayGet (dGeomID ray, dVector3 start, dVector3 dir);
128
* Set/get ray flags that influence ray collision detection.
129
* These flags are currently only noticed by the trimesh collider, because
130
* they can make a major differences there.
132
void dGeomRaySetParams (dGeomID g, int FirstContact, int BackfaceCull);
133
void dGeomRayGetParams (dGeomID g, int *FirstContact, int *BackfaceCull);
134
void dGeomRaySetClosestHit (dGeomID g, int closestHit);
135
int dGeomRayGetClosestHit (dGeomID g);
137
#include "collision_trimesh.h"
139
dGeomID dCreateGeomTransform (dSpaceID space);
140
void dGeomTransformSetGeom (dGeomID g, dGeomID obj);
141
dGeomID dGeomTransformGetGeom (dGeomID g);
142
void dGeomTransformSetCleanup (dGeomID g, int mode);
143
int dGeomTransformGetCleanup (dGeomID g);
144
void dGeomTransformSetInfo (dGeomID g, int mode);
145
int dGeomTransformGetInfo (dGeomID g);
147
/* ************************************************************************ */
148
/* utility functions */
150
void dClosestLineSegmentPoints (const dVector3 a1, const dVector3 a2,
151
const dVector3 b1, const dVector3 b2,
152
dVector3 cp1, dVector3 cp2);
154
int dBoxTouchesBox (const dVector3 _p1, const dMatrix3 R1,
155
const dVector3 side1, const dVector3 _p2,
156
const dMatrix3 R2, const dVector3 side2);
158
void dInfiniteAABB (dGeomID geom, dReal aabb[6]);
161
/* ************************************************************************ */
164
typedef void dGetAABBFn (dGeomID, dReal aabb[6]);
165
typedef int dColliderFn (dGeomID o1, dGeomID o2,
166
int flags, dContactGeom *contact, int skip);
167
typedef dColliderFn * dGetColliderFnFn (int num);
168
typedef void dGeomDtorFn (dGeomID o);
169
typedef int dAABBTestFn (dGeomID o1, dGeomID o2, dReal aabb[6]);
171
typedef struct dGeomClass {
173
dGetColliderFnFn *collider;
175
dAABBTestFn *aabb_test;
179
int dCreateGeomClass (const dGeomClass *classptr);
180
void * dGeomGetClassData (dGeomID);
181
dGeomID dCreateGeom (int classnum);
183
/* ************************************************************************ */