]> git.xonotic.org Git - xonotic/xonotic.git/blob - misc/builddeps/dp.linux32/include/ode/odecpp_collision.h
Handle errors right.
[xonotic/xonotic.git] / misc / builddeps / dp.linux32 / include / ode / odecpp_collision.h
1 /*************************************************************************
2  *                                                                       *
3  * Open Dynamics Engine, Copyright (C) 2001,2002 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 /* C++ interface for new collision API */
24
25
26 #ifndef _ODE_ODECPP_COLLISION_H_
27 #define _ODE_ODECPP_COLLISION_H_
28 #ifdef __cplusplus
29
30 //#include <ode/error.h>
31
32 //namespace ode {
33
34 class dGeom {
35   // intentionally undefined, don't use these
36   dGeom (dGeom &);
37   void operator= (dGeom &);
38
39 protected:
40   dGeomID _id;
41
42   dGeom()
43     { _id = 0; }
44 public:
45   ~dGeom()
46     { if (_id) dGeomDestroy (_id); }
47
48   dGeomID id() const
49     { return _id; }
50   operator dGeomID() const
51     { return _id; }
52
53   void destroy() {
54     if (_id) dGeomDestroy (_id);
55     _id = 0;
56   }
57
58   int getClass() const
59     { return dGeomGetClass (_id); }
60
61   dSpaceID getSpace() const
62     { return dGeomGetSpace (_id); }
63
64   void setData (void *data)
65     { dGeomSetData (_id,data); }
66   void *getData() const
67     { return dGeomGetData (_id); }
68
69   void setBody (dBodyID b)
70     { dGeomSetBody (_id,b); }
71   dBodyID getBody() const
72     { return dGeomGetBody (_id); }
73
74   void setPosition (dReal x, dReal y, dReal z)
75     { dGeomSetPosition (_id,x,y,z); }
76   const dReal * getPosition() const
77     { return dGeomGetPosition (_id); }
78
79   void setRotation (const dMatrix3 R)
80     { dGeomSetRotation (_id,R); }
81   const dReal * getRotation() const
82     { return dGeomGetRotation (_id); }
83     
84   void setQuaternion (const dQuaternion quat)
85     { dGeomSetQuaternion (_id,quat); }
86   void getQuaternion (dQuaternion quat) const
87     { dGeomGetQuaternion (_id,quat); }
88
89   void getAABB (dReal aabb[6]) const
90     { dGeomGetAABB (_id, aabb); }
91
92   int isSpace()
93     { return dGeomIsSpace (_id); }
94
95   void setCategoryBits (unsigned long bits)
96     { dGeomSetCategoryBits (_id, bits); }
97   void setCollideBits (unsigned long bits)
98     { dGeomSetCollideBits (_id, bits); }
99   unsigned long getCategoryBits()
100     { return dGeomGetCategoryBits (_id); }
101   unsigned long getCollideBits()
102     { return dGeomGetCollideBits (_id); }
103
104   void enable()
105     { dGeomEnable (_id); }
106   void disable()
107     { dGeomDisable (_id); }
108   int isEnabled()
109     { return dGeomIsEnabled (_id); }
110   
111   void getRelPointPos (dReal px, dReal py, dReal pz, dVector3 result) const
112     { dGeomGetRelPointPos (_id, px, py, pz, result); }
113   void getRelPointPos (const dVector3 p, dVector3 result) const
114     { getRelPointPos (p[0], p[1], p[2], result); }
115
116   void getPosRelPoint (dReal px, dReal py, dReal pz, dVector3 result) const
117     { dGeomGetPosRelPoint (_id, px, py, pz, result); }
118   void getPosRelPoint (const dVector3 p, dVector3 result) const
119     { getPosRelPoint (p[0], p[1], p[2], result); }
120
121   void vectorToWorld (dReal px, dReal py, dReal pz, dVector3 result) const
122     { dGeomVectorToWorld (_id, px, py, pz, result); }
123   void vectorToWorld (const dVector3 p, dVector3 result) const
124     { vectorToWorld (p[0], p[1], p[2], result); }
125
126   void vectorFromWorld (dReal px, dReal py, dReal pz, dVector3 result) const
127     { dGeomVectorFromWorld (_id, px, py, pz, result); }
128   void vectorFromWorld (const dVector3 p, dVector3 result) const
129     { vectorFromWorld (p[0], p[1], p[2], result); }
130   
131   void collide2 (dGeomID g, void *data, dNearCallback *callback)
132     { dSpaceCollide2 (_id,g,data,callback); }
133 };
134
135
136 class dSpace : public dGeom {
137   // intentionally undefined, don't use these
138   dSpace (dSpace &);
139   void operator= (dSpace &);
140
141 protected:
142   // the default constructor is protected so that you
143   // can't instance this class. you must instance one
144   // of its subclasses instead.
145   dSpace () { _id = 0; }
146
147 public:
148   dSpaceID id() const
149     { return (dSpaceID) _id; }
150   operator dSpaceID() const
151     { return (dSpaceID) _id; }
152
153   void setCleanup (int mode)
154     { dSpaceSetCleanup (id(), mode); }
155   int getCleanup()
156     { return dSpaceGetCleanup (id()); }
157
158   void add (dGeomID x)
159     { dSpaceAdd (id(), x); }
160   void remove (dGeomID x)
161     { dSpaceRemove (id(), x); }
162   int query (dGeomID x)
163     { return dSpaceQuery (id(),x); }
164
165   int getNumGeoms()
166     { return dSpaceGetNumGeoms (id()); }
167   dGeomID getGeom (int i)
168     { return dSpaceGetGeom (id(),i); }
169
170   void collide (void *data, dNearCallback *callback)
171     { dSpaceCollide (id(),data,callback); }
172 };
173
174
175 class dSimpleSpace : public dSpace {
176   // intentionally undefined, don't use these
177   dSimpleSpace (dSimpleSpace &);
178   void operator= (dSimpleSpace &);
179
180 public:
181   dSimpleSpace ()
182     { _id = (dGeomID) dSimpleSpaceCreate (0); }
183   dSimpleSpace (dSpace &space)
184     { _id = (dGeomID) dSimpleSpaceCreate (space.id()); }
185   dSimpleSpace (dSpaceID space)
186     { _id = (dGeomID) dSimpleSpaceCreate (space); }
187 };
188
189
190 class dHashSpace : public dSpace {
191   // intentionally undefined, don't use these
192   dHashSpace (dHashSpace &);
193   void operator= (dHashSpace &);
194
195 public:
196   dHashSpace ()
197     { _id = (dGeomID) dHashSpaceCreate (0); }
198   dHashSpace (dSpace &space)
199     { _id = (dGeomID) dHashSpaceCreate (space.id()); }
200   dHashSpace (dSpaceID space)
201     { _id = (dGeomID) dHashSpaceCreate (space); }
202
203   void setLevels (int minlevel, int maxlevel)
204     { dHashSpaceSetLevels (id(),minlevel,maxlevel); }
205 };
206
207
208 class dQuadTreeSpace : public dSpace {
209   // intentionally undefined, don't use these
210   dQuadTreeSpace (dQuadTreeSpace &);
211   void operator= (dQuadTreeSpace &);
212
213 public:
214   dQuadTreeSpace (const dVector3 center, const dVector3 extents, int depth)
215     { _id = (dGeomID) dQuadTreeSpaceCreate (0,center,extents,depth); }
216   dQuadTreeSpace (dSpace &space, const dVector3 center, const dVector3 extents, int depth)
217     { _id = (dGeomID) dQuadTreeSpaceCreate (space.id(),center,extents,depth); }
218   dQuadTreeSpace (dSpaceID space, const dVector3 center, const dVector3 extents, int depth)
219     { _id = (dGeomID) dQuadTreeSpaceCreate (space,center,extents,depth); }
220 };
221
222
223 class dSphere : public dGeom {
224   // intentionally undefined, don't use these
225   dSphere (dSphere &);
226   void operator= (dSphere &);
227
228 public:
229   dSphere () { }
230   dSphere (dReal radius)
231     { _id = dCreateSphere (0, radius); }
232   dSphere (dSpace &space, dReal radius)
233     { _id = dCreateSphere (space.id(), radius); }
234   dSphere (dSpaceID space, dReal radius)
235     { _id = dCreateSphere (space, radius); }
236
237   void create (dSpaceID space, dReal radius) {
238     if (_id) dGeomDestroy (_id);
239     _id = dCreateSphere (space, radius);
240   }
241
242   void setRadius (dReal radius)
243     { dGeomSphereSetRadius (_id, radius); }
244   dReal getRadius() const
245     { return dGeomSphereGetRadius (_id); }
246 };
247
248
249 class dBox : public dGeom {
250   // intentionally undefined, don't use these
251   dBox (dBox &);
252   void operator= (dBox &);
253
254 public:
255   dBox () { }
256   dBox (dReal lx, dReal ly, dReal lz)
257     { _id = dCreateBox (0,lx,ly,lz); }
258   dBox (dSpace &space, dReal lx, dReal ly, dReal lz)
259     { _id = dCreateBox (space,lx,ly,lz); }
260   dBox (dSpaceID space, dReal lx, dReal ly, dReal lz)
261     { _id = dCreateBox (space,lx,ly,lz); }
262
263   void create (dSpaceID space, dReal lx, dReal ly, dReal lz) {
264     if (_id) dGeomDestroy (_id);
265     _id = dCreateBox (space,lx,ly,lz);
266   }
267
268   void setLengths (dReal lx, dReal ly, dReal lz)
269     { dGeomBoxSetLengths (_id, lx, ly, lz); }
270   void getLengths (dVector3 result) const
271     { dGeomBoxGetLengths (_id,result); }
272 };
273
274
275 class dPlane : public dGeom {
276   // intentionally undefined, don't use these
277   dPlane (dPlane &);
278   void operator= (dPlane &);
279
280 public:
281   dPlane() { }
282   dPlane (dReal a, dReal b, dReal c, dReal d)
283     { _id = dCreatePlane (0,a,b,c,d); }
284   dPlane (dSpace &space, dReal a, dReal b, dReal c, dReal d)
285     { _id = dCreatePlane (space.id(),a,b,c,d); }
286   dPlane (dSpaceID space, dReal a, dReal b, dReal c, dReal d)
287     { _id = dCreatePlane (space,a,b,c,d); }
288
289   void create (dSpaceID space, dReal a, dReal b, dReal c, dReal d) {
290     if (_id) dGeomDestroy (_id);
291     _id = dCreatePlane (space,a,b,c,d);
292   }
293
294   void setParams (dReal a, dReal b, dReal c, dReal d)
295     { dGeomPlaneSetParams (_id, a, b, c, d); }
296   void getParams (dVector4 result) const
297     { dGeomPlaneGetParams (_id,result); }
298 };
299
300
301 class dCapsule : public dGeom {
302   // intentionally undefined, don't use these
303   dCapsule (dCapsule &);
304   void operator= (dCapsule &);
305
306 public:
307   dCapsule() { }
308   dCapsule (dReal radius, dReal length)
309     { _id = dCreateCapsule (0,radius,length); }
310   dCapsule (dSpace &space, dReal radius, dReal length)
311     { _id = dCreateCapsule (space.id(),radius,length); }
312   dCapsule (dSpaceID space, dReal radius, dReal length)
313     { _id = dCreateCapsule (space,radius,length); }
314
315   void create (dSpaceID space, dReal radius, dReal length) {
316     if (_id) dGeomDestroy (_id);
317     _id = dCreateCapsule (space,radius,length);
318   }
319
320   void setParams (dReal radius, dReal length)
321     { dGeomCapsuleSetParams (_id, radius, length); }
322   void getParams (dReal *radius, dReal *length) const
323     { dGeomCapsuleGetParams (_id,radius,length); }
324 };
325
326
327 class dCylinder : public dGeom {
328   // intentionally undefined, don't use these
329   dCylinder (dCylinder &);
330   void operator= (dCylinder &);
331
332 public:
333   dCylinder() { }
334   dCylinder (dReal radius, dReal length)
335     { _id = dCreateCylinder (0,radius,length); }
336   dCylinder (dSpace &space, dReal radius, dReal length)
337     { _id = dCreateCylinder (space.id(),radius,length); }
338   dCylinder (dSpaceID space, dReal radius, dReal length)
339     { _id = dCreateCylinder (space,radius,length); }
340
341   void create (dSpaceID space, dReal radius, dReal length) {
342     if (_id) dGeomDestroy (_id);
343     _id = dCreateCylinder (space,radius,length);
344   }
345
346   void setParams (dReal radius, dReal length)
347     { dGeomCylinderSetParams (_id, radius, length); }
348   void getParams (dReal *radius, dReal *length) const
349     { dGeomCylinderGetParams (_id,radius,length); }
350 };
351
352
353 class dRay : public dGeom {
354   // intentionally undefined, don't use these
355   dRay (dRay &);
356   void operator= (dRay &);
357
358 public:
359   dRay() { }
360   dRay (dReal length)
361     { _id = dCreateRay (0,length); }
362   dRay (dSpace &space, dReal length)
363     { _id = dCreateRay (space.id(),length); }
364   dRay (dSpaceID space, dReal length)
365     { _id = dCreateRay (space,length); }
366
367   void create (dSpaceID space, dReal length) {
368     if (_id) dGeomDestroy (_id);
369     _id = dCreateRay (space,length);
370   }
371
372   void setLength (dReal length)
373     { dGeomRaySetLength (_id, length); }
374   dReal getLength()
375     { return dGeomRayGetLength (_id); }
376
377   void set (dReal px, dReal py, dReal pz, dReal dx, dReal dy, dReal dz)
378     { dGeomRaySet (_id, px, py, pz, dx, dy, dz); }
379   void get (dVector3 start, dVector3 dir)
380     { dGeomRayGet (_id, start, dir); }
381
382   void setParams (int firstContact, int backfaceCull)
383     { dGeomRaySetParams (_id, firstContact, backfaceCull); }
384   void getParams (int *firstContact, int *backfaceCull)
385     { dGeomRayGetParams (_id, firstContact, backfaceCull); }
386   void setClosestHit (int closestHit)
387     { dGeomRaySetClosestHit (_id, closestHit); }
388   int getClosestHit()
389     { return dGeomRayGetClosestHit (_id); }
390 };
391
392
393 class dGeomTransform : public dGeom {
394   // intentionally undefined, don't use these
395   dGeomTransform (dGeomTransform &);
396   void operator= (dGeomTransform &);
397
398 public:
399   dGeomTransform() { }
400   dGeomTransform (dSpace &space)
401     { _id = dCreateGeomTransform (space.id()); }
402   dGeomTransform (dSpaceID space)
403     { _id = dCreateGeomTransform (space); }
404
405   void create (dSpaceID space=0) {
406     if (_id) dGeomDestroy (_id);
407     _id = dCreateGeomTransform (space);
408   }
409
410   void setGeom (dGeomID geom)
411     { dGeomTransformSetGeom (_id, geom); }
412   dGeomID getGeom() const
413     { return dGeomTransformGetGeom (_id); }
414
415   void setCleanup (int mode)
416     { dGeomTransformSetCleanup (_id,mode); }
417   int getCleanup ()
418     { return dGeomTransformGetCleanup (_id); }
419
420   void setInfo (int mode)
421     { dGeomTransformSetInfo (_id,mode); }
422   int getInfo()
423     { return dGeomTransformGetInfo (_id); }
424 };
425
426 //}
427
428 #endif
429 #endif