]> git.xonotic.org Git - xonotic/darkplaces.git/blob - world.c
removed .axis_forward, .axis_left, .axis_up, .spinvelocity, now the only
[xonotic/darkplaces.git] / world.c
1 /*
2 Copyright (C) 1996-1997 Id Software, Inc.
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
13 See the GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18
19 */
20 // world.c -- world query functions
21
22 #include "quakedef.h"
23
24 /*
25
26 entities never clip against themselves, or their owner
27
28 line of sight checks trace->inopen and trace->inwater, but bullets don't
29
30 */
31
32 static void World_Physics_Init(void);
33 void World_Init(void)
34 {
35         Collision_Init();
36         World_Physics_Init();
37 }
38
39 static void World_Physics_Shutdown(void);
40 void World_Shutdown(void)
41 {
42         World_Physics_Shutdown();
43 }
44
45 static void World_Physics_Start(world_t *world);
46 void World_Start(world_t *world)
47 {
48         World_Physics_Start(world);
49 }
50
51 static void World_Physics_End(world_t *world);
52 void World_End(world_t *world)
53 {
54         World_Physics_End(world);
55 }
56
57 //============================================================================
58
59 /// World_ClearLink is used for new headnodes
60 void World_ClearLink (link_t *l)
61 {
62         l->entitynumber = 0;
63         l->prev = l->next = l;
64 }
65
66 void World_RemoveLink (link_t *l)
67 {
68         l->next->prev = l->prev;
69         l->prev->next = l->next;
70 }
71
72 void World_InsertLinkBefore (link_t *l, link_t *before, int entitynumber)
73 {
74         l->entitynumber = entitynumber;
75         l->next = before;
76         l->prev = before->prev;
77         l->prev->next = l;
78         l->next->prev = l;
79 }
80
81 /*
82 ===============================================================================
83
84 ENTITY AREA CHECKING
85
86 ===============================================================================
87 */
88
89 void World_PrintAreaStats(world_t *world, const char *worldname)
90 {
91         Con_Printf("%s areagrid check stats: %d calls %d nodes (%f per call) %d entities (%f per call)\n", worldname, world->areagrid_stats_calls, world->areagrid_stats_nodechecks, (double) world->areagrid_stats_nodechecks / (double) world->areagrid_stats_calls, world->areagrid_stats_entitychecks, (double) world->areagrid_stats_entitychecks / (double) world->areagrid_stats_calls);
92         world->areagrid_stats_calls = 0;
93         world->areagrid_stats_nodechecks = 0;
94         world->areagrid_stats_entitychecks = 0;
95 }
96
97 /*
98 ===============
99 World_SetSize
100
101 ===============
102 */
103 void World_SetSize(world_t *world, const char *filename, const vec3_t mins, const vec3_t maxs)
104 {
105         int i;
106
107         strlcpy(world->filename, filename, sizeof(world->filename));
108         VectorCopy(mins, world->mins);
109         VectorCopy(maxs, world->maxs);
110
111         // the areagrid_marknumber is not allowed to be 0
112         if (world->areagrid_marknumber < 1)
113                 world->areagrid_marknumber = 1;
114         // choose either the world box size, or a larger box to ensure the grid isn't too fine
115         world->areagrid_size[0] = max(world->areagrid_maxs[0] - world->areagrid_mins[0], AREA_GRID * sv_areagrid_mingridsize.value);
116         world->areagrid_size[1] = max(world->areagrid_maxs[1] - world->areagrid_mins[1], AREA_GRID * sv_areagrid_mingridsize.value);
117         world->areagrid_size[2] = max(world->areagrid_maxs[2] - world->areagrid_mins[2], AREA_GRID * sv_areagrid_mingridsize.value);
118         // figure out the corners of such a box, centered at the center of the world box
119         world->areagrid_mins[0] = (world->areagrid_mins[0] + world->areagrid_maxs[0] - world->areagrid_size[0]) * 0.5f;
120         world->areagrid_mins[1] = (world->areagrid_mins[1] + world->areagrid_maxs[1] - world->areagrid_size[1]) * 0.5f;
121         world->areagrid_mins[2] = (world->areagrid_mins[2] + world->areagrid_maxs[2] - world->areagrid_size[2]) * 0.5f;
122         world->areagrid_maxs[0] = (world->areagrid_mins[0] + world->areagrid_maxs[0] + world->areagrid_size[0]) * 0.5f;
123         world->areagrid_maxs[1] = (world->areagrid_mins[1] + world->areagrid_maxs[1] + world->areagrid_size[1]) * 0.5f;
124         world->areagrid_maxs[2] = (world->areagrid_mins[2] + world->areagrid_maxs[2] + world->areagrid_size[2]) * 0.5f;
125         // now calculate the actual useful info from that
126         VectorNegate(world->areagrid_mins, world->areagrid_bias);
127         world->areagrid_scale[0] = AREA_GRID / world->areagrid_size[0];
128         world->areagrid_scale[1] = AREA_GRID / world->areagrid_size[1];
129         world->areagrid_scale[2] = AREA_GRID / world->areagrid_size[2];
130         World_ClearLink(&world->areagrid_outside);
131         for (i = 0;i < AREA_GRIDNODES;i++)
132                 World_ClearLink(&world->areagrid[i]);
133         if (developer.integer >= 10)
134                 Con_Printf("areagrid settings: divisions %ix%ix1 : box %f %f %f : %f %f %f size %f %f %f grid %f %f %f (mingrid %f)\n", AREA_GRID, AREA_GRID, world->areagrid_mins[0], world->areagrid_mins[1], world->areagrid_mins[2], world->areagrid_maxs[0], world->areagrid_maxs[1], world->areagrid_maxs[2], world->areagrid_size[0], world->areagrid_size[1], world->areagrid_size[2], 1.0f / world->areagrid_scale[0], 1.0f / world->areagrid_scale[1], 1.0f / world->areagrid_scale[2], sv_areagrid_mingridsize.value);
135 }
136
137 /*
138 ===============
139 World_UnlinkAll
140
141 ===============
142 */
143 void World_UnlinkAll(world_t *world)
144 {
145         int i;
146         link_t *grid;
147         // unlink all entities one by one
148         grid = &world->areagrid_outside;
149         while (grid->next != grid)
150                 World_UnlinkEdict(PRVM_EDICT_NUM(grid->next->entitynumber));
151         for (i = 0, grid = world->areagrid;i < AREA_GRIDNODES;i++, grid++)
152                 while (grid->next != grid)
153                         World_UnlinkEdict(PRVM_EDICT_NUM(grid->next->entitynumber));
154 }
155
156 /*
157 ===============
158
159 ===============
160 */
161 void World_UnlinkEdict(prvm_edict_t *ent)
162 {
163         int i;
164         for (i = 0;i < ENTITYGRIDAREAS;i++)
165         {
166                 if (ent->priv.server->areagrid[i].prev)
167                 {
168                         World_RemoveLink (&ent->priv.server->areagrid[i]);
169                         ent->priv.server->areagrid[i].prev = ent->priv.server->areagrid[i].next = NULL;
170                 }
171         }
172 }
173
174 int World_EntitiesInBox(world_t *world, const vec3_t mins, const vec3_t maxs, int maxlist, prvm_edict_t **list)
175 {
176         int numlist;
177         link_t *grid;
178         link_t *l;
179         prvm_edict_t *ent;
180         int igrid[3], igridmins[3], igridmaxs[3];
181
182         // FIXME: if areagrid_marknumber wraps, all entities need their
183         // ent->priv.server->areagridmarknumber reset
184         world->areagrid_stats_calls++;
185         world->areagrid_marknumber++;
186         igridmins[0] = (int) floor((mins[0] + world->areagrid_bias[0]) * world->areagrid_scale[0]);
187         igridmins[1] = (int) floor((mins[1] + world->areagrid_bias[1]) * world->areagrid_scale[1]);
188         //igridmins[2] = (int) ((mins[2] + world->areagrid_bias[2]) * world->areagrid_scale[2]);
189         igridmaxs[0] = (int) floor((maxs[0] + world->areagrid_bias[0]) * world->areagrid_scale[0]) + 1;
190         igridmaxs[1] = (int) floor((maxs[1] + world->areagrid_bias[1]) * world->areagrid_scale[1]) + 1;
191         //igridmaxs[2] = (int) ((maxs[2] + world->areagrid_bias[2]) * world->areagrid_scale[2]) + 1;
192         igridmins[0] = max(0, igridmins[0]);
193         igridmins[1] = max(0, igridmins[1]);
194         //igridmins[2] = max(0, igridmins[2]);
195         igridmaxs[0] = min(AREA_GRID, igridmaxs[0]);
196         igridmaxs[1] = min(AREA_GRID, igridmaxs[1]);
197         //igridmaxs[2] = min(AREA_GRID, igridmaxs[2]);
198
199         numlist = 0;
200         // add entities not linked into areagrid because they are too big or
201         // outside the grid bounds
202         if (world->areagrid_outside.next != &world->areagrid_outside)
203         {
204                 grid = &world->areagrid_outside;
205                 for (l = grid->next;l != grid;l = l->next)
206                 {
207                         ent = PRVM_EDICT_NUM(l->entitynumber);
208                         if (ent->priv.server->areagridmarknumber != world->areagrid_marknumber)
209                         {
210                                 ent->priv.server->areagridmarknumber = world->areagrid_marknumber;
211                                 if (!ent->priv.server->free && BoxesOverlap(mins, maxs, ent->priv.server->areamins, ent->priv.server->areamaxs))
212                                 {
213                                         if (numlist < maxlist)
214                                                 list[numlist] = ent;
215                                         numlist++;
216                                 }
217                                 world->areagrid_stats_entitychecks++;
218                         }
219                 }
220         }
221         // add grid linked entities
222         for (igrid[1] = igridmins[1];igrid[1] < igridmaxs[1];igrid[1]++)
223         {
224                 grid = world->areagrid + igrid[1] * AREA_GRID + igridmins[0];
225                 for (igrid[0] = igridmins[0];igrid[0] < igridmaxs[0];igrid[0]++, grid++)
226                 {
227                         if (grid->next != grid)
228                         {
229                                 for (l = grid->next;l != grid;l = l->next)
230                                 {
231                                         ent = PRVM_EDICT_NUM(l->entitynumber);
232                                         if (ent->priv.server->areagridmarknumber != world->areagrid_marknumber)
233                                         {
234                                                 ent->priv.server->areagridmarknumber = world->areagrid_marknumber;
235                                                 if (!ent->priv.server->free && BoxesOverlap(mins, maxs, ent->priv.server->areamins, ent->priv.server->areamaxs))
236                                                 {
237                                                         if (numlist < maxlist)
238                                                                 list[numlist] = ent;
239                                                         numlist++;
240                                                 }
241                                                 //Con_Printf("%d %f %f %f %f %f %f : %d : %f %f %f %f %f %f\n", BoxesOverlap(mins, maxs, ent->priv.server->areamins, ent->priv.server->areamaxs), ent->priv.server->areamins[0], ent->priv.server->areamins[1], ent->priv.server->areamins[2], ent->priv.server->areamaxs[0], ent->priv.server->areamaxs[1], ent->priv.server->areamaxs[2], PRVM_NUM_FOR_EDICT(ent), mins[0], mins[1], mins[2], maxs[0], maxs[1], maxs[2]);
242                                         }
243                                         world->areagrid_stats_entitychecks++;
244                                 }
245                         }
246                 }
247         }
248         return numlist;
249 }
250
251 void World_LinkEdict_AreaGrid(world_t *world, prvm_edict_t *ent)
252 {
253         link_t *grid;
254         int igrid[3], igridmins[3], igridmaxs[3], gridnum, entitynumber = PRVM_NUM_FOR_EDICT(ent);
255
256         if (entitynumber <= 0 || entitynumber >= prog->max_edicts || PRVM_EDICT_NUM(entitynumber) != ent)
257         {
258                 Con_Printf ("World_LinkEdict_AreaGrid: invalid edict %p (edicts is %p, edict compared to prog->edicts is %i)\n", (void *)ent, (void *)prog->edicts, entitynumber);
259                 return;
260         }
261
262         igridmins[0] = (int) floor((ent->priv.server->areamins[0] + world->areagrid_bias[0]) * world->areagrid_scale[0]);
263         igridmins[1] = (int) floor((ent->priv.server->areamins[1] + world->areagrid_bias[1]) * world->areagrid_scale[1]);
264         //igridmins[2] = (int) floor((ent->priv.server->areamins[2] + world->areagrid_bias[2]) * world->areagrid_scale[2]);
265         igridmaxs[0] = (int) floor((ent->priv.server->areamaxs[0] + world->areagrid_bias[0]) * world->areagrid_scale[0]) + 1;
266         igridmaxs[1] = (int) floor((ent->priv.server->areamaxs[1] + world->areagrid_bias[1]) * world->areagrid_scale[1]) + 1;
267         //igridmaxs[2] = (int) floor((ent->priv.server->areamaxs[2] + world->areagrid_bias[2]) * world->areagrid_scale[2]) + 1;
268         if (igridmins[0] < 0 || igridmaxs[0] > AREA_GRID || igridmins[1] < 0 || igridmaxs[1] > AREA_GRID || ((igridmaxs[0] - igridmins[0]) * (igridmaxs[1] - igridmins[1])) > ENTITYGRIDAREAS)
269         {
270                 // wow, something outside the grid, store it as such
271                 World_InsertLinkBefore (&ent->priv.server->areagrid[0], &world->areagrid_outside, entitynumber);
272                 return;
273         }
274
275         gridnum = 0;
276         for (igrid[1] = igridmins[1];igrid[1] < igridmaxs[1];igrid[1]++)
277         {
278                 grid = world->areagrid + igrid[1] * AREA_GRID + igridmins[0];
279                 for (igrid[0] = igridmins[0];igrid[0] < igridmaxs[0];igrid[0]++, grid++, gridnum++)
280                         World_InsertLinkBefore (&ent->priv.server->areagrid[gridnum], grid, entitynumber);
281         }
282 }
283
284 /*
285 ===============
286 World_LinkEdict
287
288 ===============
289 */
290 void World_LinkEdict(world_t *world, prvm_edict_t *ent, const vec3_t mins, const vec3_t maxs)
291 {
292         // unlink from old position first
293         if (ent->priv.server->areagrid[0].prev)
294                 World_UnlinkEdict(ent);
295
296         // don't add the world
297         if (ent == prog->edicts)
298                 return;
299
300         // don't add free entities
301         if (ent->priv.server->free)
302                 return;
303
304         VectorCopy(mins, ent->priv.server->areamins);
305         VectorCopy(maxs, ent->priv.server->areamaxs);
306         World_LinkEdict_AreaGrid(world, ent);
307 }
308
309
310
311
312 //============================================================================
313 // physics engine support
314 //============================================================================
315
316 #ifndef ODE_STATIC
317 #define ODE_DYNAMIC 1
318 #endif
319
320 #if defined(ODE_STATIC) || defined(ODE_DYNAMIC)
321 #define USEODE 1
322 #endif
323
324 #ifdef USEODE
325 cvar_t physics_ode_quadtree_depth = {0, "physics_ode_quadtree_depth","5", "desired subdivision level of quadtree culling space"};
326 cvar_t physics_ode_contactsurfacelayer = {0, "physics_ode_contactsurfacelayer","0", "allows objects to overlap this many units to reduce jitter"};
327 cvar_t physics_ode_worldquickstep = {0, "physics_ode_worldquickstep","1", "use dWorldQuickStep rather than dWorldStepFast1 or dWorldStep"};
328 cvar_t physics_ode_worldquickstep_iterations = {0, "physics_ode_worldquickstep_iterations","20", "parameter to dWorldQuickStep"};
329 cvar_t physics_ode_worldstepfast = {0, "physics_ode_worldstepfast","0", "use dWorldStepFast1 rather than dWorldStep"};
330 cvar_t physics_ode_worldstepfast_iterations = {0, "physics_ode_worldstepfast_iterations","20", "parameter to dWorldStepFast1"};
331 cvar_t physics_ode_contact_mu = {0, "physics_ode_contact_mu", "1", "contact solver mu parameter - friction pyramid approximation 1 (see ODE User Guide)"};
332 cvar_t physics_ode_contact_erp = {0, "physics_ode_contact_erp", "0.96", "contact solver erp parameter - Error Restitution Percent (see ODE User Guide)"};
333 cvar_t physics_ode_contact_cfm = {0, "physics_ode_contact_cfm", "0", "contact solver cfm parameter - Constraint Force Mixing (see ODE User Guide)"};
334 cvar_t physics_ode_iterationsperframe = {0, "physics_ode_iterationsperframe", "4", "divisor for time step, runs multiple physics steps per frame"};
335 cvar_t physics_ode_movelimit = {0, "physics_ode_movelimit", "0.5", "clamp velocity if a single move would exceed this percentage of object thickness, to prevent flying through walls"};
336 cvar_t physics_ode_spinlimit = {0, "physics_ode_spinlimit", "10000", "reset spin velocity if it gets too large"};
337
338 // LordHavoc: this large chunk of definitions comes from the ODE library
339 // include files.
340
341 #ifdef ODE_STATIC
342 #include "ode/ode.h"
343 #else
344 #ifdef WINAPI
345 #define ODE_API WINAPI
346 #else
347 #define ODE_API
348 #endif
349
350 // note: dynamic builds of ODE tend to be double precision, this is not used
351 // for static builds
352 typedef double dReal;
353
354 typedef dReal dVector3[4];
355 typedef dReal dVector4[4];
356 typedef dReal dMatrix3[4*3];
357 typedef dReal dMatrix4[4*4];
358 typedef dReal dMatrix6[8*6];
359 typedef dReal dQuaternion[4];
360
361 struct dxWorld;         /* dynamics world */
362 struct dxSpace;         /* collision space */
363 struct dxBody;          /* rigid body (dynamics object) */
364 struct dxGeom;          /* geometry (collision object) */
365 struct dxJoint;
366 struct dxJointNode;
367 struct dxJointGroup;
368 struct dxTriMeshData;
369
370 typedef struct dxWorld *dWorldID;
371 typedef struct dxSpace *dSpaceID;
372 typedef struct dxBody *dBodyID;
373 typedef struct dxGeom *dGeomID;
374 typedef struct dxJoint *dJointID;
375 typedef struct dxJointGroup *dJointGroupID;
376 typedef struct dxTriMeshData *dTriMeshDataID;
377
378 typedef struct dJointFeedback
379 {
380         dVector3 f1;            /* force applied to body 1 */
381         dVector3 t1;            /* torque applied to body 1 */
382         dVector3 f2;            /* force applied to body 2 */
383         dVector3 t2;            /* torque applied to body 2 */
384 }
385 dJointFeedback;
386
387 typedef enum dJointType
388 {
389         dJointTypeNone = 0,
390         dJointTypeBall,
391         dJointTypeHinge,
392         dJointTypeSlider,
393         dJointTypeContact,
394         dJointTypeUniversal,
395         dJointTypeHinge2,
396         dJointTypeFixed,
397         dJointTypeNull,
398         dJointTypeAMotor,
399         dJointTypeLMotor,
400         dJointTypePlane2D,
401         dJointTypePR,
402         dJointTypePU,
403         dJointTypePiston
404 }
405 dJointType;
406
407 typedef struct dMass
408 {
409         dReal mass;
410         dVector3 c;
411         dMatrix3 I;
412 }
413 dMass;
414
415 enum
416 {
417         dContactMu2                     = 0x001,
418         dContactFDir1           = 0x002,
419         dContactBounce          = 0x004,
420         dContactSoftERP         = 0x008,
421         dContactSoftCFM         = 0x010,
422         dContactMotion1         = 0x020,
423         dContactMotion2         = 0x040,
424         dContactMotionN         = 0x080,
425         dContactSlip1           = 0x100,
426         dContactSlip2           = 0x200,
427         
428         dContactApprox0         = 0x0000,
429         dContactApprox1_1       = 0x1000,
430         dContactApprox1_2       = 0x2000,
431         dContactApprox1         = 0x3000
432 };
433
434 typedef struct dSurfaceParameters
435 {
436         /* must always be defined */
437         int mode;
438         dReal mu;
439
440         /* only defined if the corresponding flag is set in mode */
441         dReal mu2;
442         dReal bounce;
443         dReal bounce_vel;
444         dReal soft_erp;
445         dReal soft_cfm;
446         dReal motion1,motion2,motionN;
447         dReal slip1,slip2;
448 } dSurfaceParameters;
449
450 typedef struct dContactGeom
451 {
452         dVector3 pos;          ///< contact position
453         dVector3 normal;       ///< normal vector
454         dReal depth;           ///< penetration depth
455         dGeomID g1,g2;         ///< the colliding geoms
456         int side1,side2;       ///< (to be documented)
457 }
458 dContactGeom;
459
460 typedef struct dContact
461 {
462         dSurfaceParameters surface;
463         dContactGeom geom;
464         dVector3 fdir1;
465 }
466 dContact;
467
468 typedef void dNearCallback (void *data, dGeomID o1, dGeomID o2);
469
470 // SAP
471 // Order XZY or ZXY usually works best, if your Y is up.
472 #define dSAP_AXES_XYZ  ((0)|(1<<2)|(2<<4))
473 #define dSAP_AXES_XZY  ((0)|(2<<2)|(1<<4))
474 #define dSAP_AXES_YXZ  ((1)|(0<<2)|(2<<4))
475 #define dSAP_AXES_YZX  ((1)|(2<<2)|(0<<4))
476 #define dSAP_AXES_ZXY  ((2)|(0<<2)|(1<<4))
477 #define dSAP_AXES_ZYX  ((2)|(1<<2)|(0<<4))
478
479 const char*     (ODE_API *dGetConfiguration)(void);
480 int             (ODE_API *dCheckConfiguration)( const char* token );
481 int             (ODE_API *dInitODE)(void);
482 //int             (ODE_API *dInitODE2)(unsigned int uiInitFlags);
483 int             (ODE_API *dAllocateODEDataForThread)(unsigned int uiAllocateFlags);
484 void            (ODE_API *dCleanupODEAllDataForThread)(void);
485 void            (ODE_API *dCloseODE)(void);
486
487 //int             (ODE_API *dMassCheck)(const dMass *m);
488 //void            (ODE_API *dMassSetZero)(dMass *);
489 //void            (ODE_API *dMassSetParameters)(dMass *, dReal themass, dReal cgx, dReal cgy, dReal cgz, dReal I11, dReal I22, dReal I33, dReal I12, dReal I13, dReal I23);
490 //void            (ODE_API *dMassSetSphere)(dMass *, dReal density, dReal radius);
491 void            (ODE_API *dMassSetSphereTotal)(dMass *, dReal total_mass, dReal radius);
492 //void            (ODE_API *dMassSetCapsule)(dMass *, dReal density, int direction, dReal radius, dReal length);
493 void            (ODE_API *dMassSetCapsuleTotal)(dMass *, dReal total_mass, int direction, dReal radius, dReal length);
494 //void            (ODE_API *dMassSetCylinder)(dMass *, dReal density, int direction, dReal radius, dReal length);
495 //void            (ODE_API *dMassSetCylinderTotal)(dMass *, dReal total_mass, int direction, dReal radius, dReal length);
496 //void            (ODE_API *dMassSetBox)(dMass *, dReal density, dReal lx, dReal ly, dReal lz);
497 void            (ODE_API *dMassSetBoxTotal)(dMass *, dReal total_mass, dReal lx, dReal ly, dReal lz);
498 //void            (ODE_API *dMassSetTrimesh)(dMass *, dReal density, dGeomID g);
499 //void            (ODE_API *dMassSetTrimeshTotal)(dMass *m, dReal total_mass, dGeomID g);
500 //void            (ODE_API *dMassAdjust)(dMass *, dReal newmass);
501 //void            (ODE_API *dMassTranslate)(dMass *, dReal x, dReal y, dReal z);
502 //void            (ODE_API *dMassRotate)(dMass *, const dMatrix3 R);
503 //void            (ODE_API *dMassAdd)(dMass *a, const dMass *b);
504 //
505 dWorldID        (ODE_API *dWorldCreate)(void);
506 void            (ODE_API *dWorldDestroy)(dWorldID world);
507 void            (ODE_API *dWorldSetGravity)(dWorldID, dReal x, dReal y, dReal z);
508 //void            (ODE_API *dWorldGetGravity)(dWorldID, dVector3 gravity);
509 //void            (ODE_API *dWorldSetERP)(dWorldID, dReal erp);
510 //dReal           (ODE_API *dWorldGetERP)(dWorldID);
511 //void            (ODE_API *dWorldSetCFM)(dWorldID, dReal cfm);
512 //dReal           (ODE_API *dWorldGetCFM)(dWorldID);
513 void            (ODE_API *dWorldStep)(dWorldID, dReal stepsize);
514 //void            (ODE_API *dWorldImpulseToForce)(dWorldID, dReal stepsize, dReal ix, dReal iy, dReal iz, dVector3 force);
515 void            (ODE_API *dWorldQuickStep)(dWorldID w, dReal stepsize);
516 void            (ODE_API *dWorldSetQuickStepNumIterations)(dWorldID, int num);
517 //int             (ODE_API *dWorldGetQuickStepNumIterations)(dWorldID);
518 //void            (ODE_API *dWorldSetQuickStepW)(dWorldID, dReal over_relaxation);
519 //dReal           (ODE_API *dWorldGetQuickStepW)(dWorldID);
520 //void            (ODE_API *dWorldSetContactMaxCorrectingVel)(dWorldID, dReal vel);
521 //dReal           (ODE_API *dWorldGetContactMaxCorrectingVel)(dWorldID);
522 void            (ODE_API *dWorldSetContactSurfaceLayer)(dWorldID, dReal depth);
523 //dReal           (ODE_API *dWorldGetContactSurfaceLayer)(dWorldID);
524 void            (ODE_API *dWorldStepFast1)(dWorldID, dReal stepsize, int maxiterations);
525 //void            (ODE_API *dWorldSetAutoEnableDepthSF1)(dWorldID, int autoEnableDepth);
526 //int             (ODE_API *dWorldGetAutoEnableDepthSF1)(dWorldID);
527 //dReal           (ODE_API *dWorldGetAutoDisableLinearThreshold)(dWorldID);
528 //void            (ODE_API *dWorldSetAutoDisableLinearThreshold)(dWorldID, dReal linear_threshold);
529 //dReal           (ODE_API *dWorldGetAutoDisableAngularThreshold)(dWorldID);
530 //void            (ODE_API *dWorldSetAutoDisableAngularThreshold)(dWorldID, dReal angular_threshold);
531 //dReal           (ODE_API *dWorldGetAutoDisableLinearAverageThreshold)(dWorldID);
532 //void            (ODE_API *dWorldSetAutoDisableLinearAverageThreshold)(dWorldID, dReal linear_average_threshold);
533 //dReal           (ODE_API *dWorldGetAutoDisableAngularAverageThreshold)(dWorldID);
534 //void            (ODE_API *dWorldSetAutoDisableAngularAverageThreshold)(dWorldID, dReal angular_average_threshold);
535 //int             (ODE_API *dWorldGetAutoDisableAverageSamplesCount)(dWorldID);
536 //void            (ODE_API *dWorldSetAutoDisableAverageSamplesCount)(dWorldID, unsigned int average_samples_count );
537 //int             (ODE_API *dWorldGetAutoDisableSteps)(dWorldID);
538 //void            (ODE_API *dWorldSetAutoDisableSteps)(dWorldID, int steps);
539 //dReal           (ODE_API *dWorldGetAutoDisableTime)(dWorldID);
540 //void            (ODE_API *dWorldSetAutoDisableTime)(dWorldID, dReal time);
541 //int             (ODE_API *dWorldGetAutoDisableFlag)(dWorldID);
542 //void            (ODE_API *dWorldSetAutoDisableFlag)(dWorldID, int do_auto_disable);
543 //dReal           (ODE_API *dWorldGetLinearDampingThreshold)(dWorldID w);
544 //void            (ODE_API *dWorldSetLinearDampingThreshold)(dWorldID w, dReal threshold);
545 //dReal           (ODE_API *dWorldGetAngularDampingThreshold)(dWorldID w);
546 //void            (ODE_API *dWorldSetAngularDampingThreshold)(dWorldID w, dReal threshold);
547 //dReal           (ODE_API *dWorldGetLinearDamping)(dWorldID w);
548 //void            (ODE_API *dWorldSetLinearDamping)(dWorldID w, dReal scale);
549 //dReal           (ODE_API *dWorldGetAngularDamping)(dWorldID w);
550 //void            (ODE_API *dWorldSetAngularDamping)(dWorldID w, dReal scale);
551 //void            (ODE_API *dWorldSetDamping)(dWorldID w, dReal linear_scale, dReal angular_scale);
552 //dReal           (ODE_API *dWorldGetMaxAngularSpeed)(dWorldID w);
553 //void            (ODE_API *dWorldSetMaxAngularSpeed)(dWorldID w, dReal max_speed);
554 //dReal           (ODE_API *dBodyGetAutoDisableLinearThreshold)(dBodyID);
555 //void            (ODE_API *dBodySetAutoDisableLinearThreshold)(dBodyID, dReal linear_average_threshold);
556 //dReal           (ODE_API *dBodyGetAutoDisableAngularThreshold)(dBodyID);
557 //void            (ODE_API *dBodySetAutoDisableAngularThreshold)(dBodyID, dReal angular_average_threshold);
558 //int             (ODE_API *dBodyGetAutoDisableAverageSamplesCount)(dBodyID);
559 //void            (ODE_API *dBodySetAutoDisableAverageSamplesCount)(dBodyID, unsigned int average_samples_count);
560 //int             (ODE_API *dBodyGetAutoDisableSteps)(dBodyID);
561 //void            (ODE_API *dBodySetAutoDisableSteps)(dBodyID, int steps);
562 //dReal           (ODE_API *dBodyGetAutoDisableTime)(dBodyID);
563 //void            (ODE_API *dBodySetAutoDisableTime)(dBodyID, dReal time);
564 //int             (ODE_API *dBodyGetAutoDisableFlag)(dBodyID);
565 //void            (ODE_API *dBodySetAutoDisableFlag)(dBodyID, int do_auto_disable);
566 //void            (ODE_API *dBodySetAutoDisableDefaults)(dBodyID);
567 //dWorldID        (ODE_API *dBodyGetWorld)(dBodyID);
568 dBodyID         (ODE_API *dBodyCreate)(dWorldID);
569 void            (ODE_API *dBodyDestroy)(dBodyID);
570 void            (ODE_API *dBodySetData)(dBodyID, void *data);
571 //void *          (ODE_API *dBodyGetData)(dBodyID);
572 void            (ODE_API *dBodySetPosition)(dBodyID, dReal x, dReal y, dReal z);
573 void            (ODE_API *dBodySetRotation)(dBodyID, const dMatrix3 R);
574 //void            (ODE_API *dBodySetQuaternion)(dBodyID, const dQuaternion q);
575 void            (ODE_API *dBodySetLinearVel)(dBodyID, dReal x, dReal y, dReal z);
576 void            (ODE_API *dBodySetAngularVel)(dBodyID, dReal x, dReal y, dReal z);
577 const dReal *   (ODE_API *dBodyGetPosition)(dBodyID);
578 //void            (ODE_API *dBodyCopyPosition)(dBodyID body, dVector3 pos);
579 const dReal *   (ODE_API *dBodyGetRotation)(dBodyID);
580 //void            (ODE_API *dBodyCopyRotation)(dBodyID, dMatrix3 R);
581 //const dReal *   (ODE_API *dBodyGetQuaternion)(dBodyID);
582 //void            (ODE_API *dBodyCopyQuaternion)(dBodyID body, dQuaternion quat);
583 const dReal *   (ODE_API *dBodyGetLinearVel)(dBodyID);
584 const dReal *   (ODE_API *dBodyGetAngularVel)(dBodyID);
585 void            (ODE_API *dBodySetMass)(dBodyID, const dMass *mass);
586 //void            (ODE_API *dBodyGetMass)(dBodyID, dMass *mass);
587 //void            (ODE_API *dBodyAddForce)(dBodyID, dReal fx, dReal fy, dReal fz);
588 //void            (ODE_API *dBodyAddTorque)(dBodyID, dReal fx, dReal fy, dReal fz);
589 //void            (ODE_API *dBodyAddRelForce)(dBodyID, dReal fx, dReal fy, dReal fz);
590 //void            (ODE_API *dBodyAddRelTorque)(dBodyID, dReal fx, dReal fy, dReal fz);
591 //void            (ODE_API *dBodyAddForceAtPos)(dBodyID, dReal fx, dReal fy, dReal fz, dReal px, dReal py, dReal pz);
592 //void            (ODE_API *dBodyAddForceAtRelPos)(dBodyID, dReal fx, dReal fy, dReal fz, dReal px, dReal py, dReal pz);
593 //void            (ODE_API *dBodyAddRelForceAtPos)(dBodyID, dReal fx, dReal fy, dReal fz, dReal px, dReal py, dReal pz);
594 //void            (ODE_API *dBodyAddRelForceAtRelPos)(dBodyID, dReal fx, dReal fy, dReal fz, dReal px, dReal py, dReal pz);
595 //const dReal *   (ODE_API *dBodyGetForce)(dBodyID);
596 //const dReal *   (ODE_API *dBodyGetTorque)(dBodyID);
597 //void            (ODE_API *dBodySetForce)(dBodyID b, dReal x, dReal y, dReal z);
598 //void            (ODE_API *dBodySetTorque)(dBodyID b, dReal x, dReal y, dReal z);
599 //void            (ODE_API *dBodyGetRelPointPos)(dBodyID, dReal px, dReal py, dReal pz, dVector3 result);
600 //void            (ODE_API *dBodyGetRelPointVel)(dBodyID, dReal px, dReal py, dReal pz, dVector3 result);
601 //void            (ODE_API *dBodyGetPointVel)(dBodyID, dReal px, dReal py, dReal pz, dVector3 result);
602 //void            (ODE_API *dBodyGetPosRelPoint)(dBodyID, dReal px, dReal py, dReal pz, dVector3 result);
603 //void            (ODE_API *dBodyVectorToWorld)(dBodyID, dReal px, dReal py, dReal pz, dVector3 result);
604 //void            (ODE_API *dBodyVectorFromWorld)(dBodyID, dReal px, dReal py, dReal pz, dVector3 result);
605 //void            (ODE_API *dBodySetFiniteRotationMode)(dBodyID, int mode);
606 //void            (ODE_API *dBodySetFiniteRotationAxis)(dBodyID, dReal x, dReal y, dReal z);
607 //int             (ODE_API *dBodyGetFiniteRotationMode)(dBodyID);
608 //void            (ODE_API *dBodyGetFiniteRotationAxis)(dBodyID, dVector3 result);
609 //int             (ODE_API *dBodyGetNumJoints)(dBodyID b);
610 //dJointID        (ODE_API *dBodyGetJoint)(dBodyID, int index);
611 //void            (ODE_API *dBodySetDynamic)(dBodyID);
612 //void            (ODE_API *dBodySetKinematic)(dBodyID);
613 //int             (ODE_API *dBodyIsKinematic)(dBodyID);
614 //void            (ODE_API *dBodyEnable)(dBodyID);
615 //void            (ODE_API *dBodyDisable)(dBodyID);
616 //int             (ODE_API *dBodyIsEnabled)(dBodyID);
617 //void            (ODE_API *dBodySetGravityMode)(dBodyID b, int mode);
618 //int             (ODE_API *dBodyGetGravityMode)(dBodyID b);
619 //void            (*dBodySetMovedCallback)(dBodyID b, void(ODE_API *callback)(dBodyID));
620 //dGeomID         (ODE_API *dBodyGetFirstGeom)(dBodyID b);
621 //dGeomID         (ODE_API *dBodyGetNextGeom)(dGeomID g);
622 //void            (ODE_API *dBodySetDampingDefaults)(dBodyID b);
623 //dReal           (ODE_API *dBodyGetLinearDamping)(dBodyID b);
624 //void            (ODE_API *dBodySetLinearDamping)(dBodyID b, dReal scale);
625 //dReal           (ODE_API *dBodyGetAngularDamping)(dBodyID b);
626 //void            (ODE_API *dBodySetAngularDamping)(dBodyID b, dReal scale);
627 //void            (ODE_API *dBodySetDamping)(dBodyID b, dReal linear_scale, dReal angular_scale);
628 //dReal           (ODE_API *dBodyGetLinearDampingThreshold)(dBodyID b);
629 //void            (ODE_API *dBodySetLinearDampingThreshold)(dBodyID b, dReal threshold);
630 //dReal           (ODE_API *dBodyGetAngularDampingThreshold)(dBodyID b);
631 //void            (ODE_API *dBodySetAngularDampingThreshold)(dBodyID b, dReal threshold);
632 //dReal           (ODE_API *dBodyGetMaxAngularSpeed)(dBodyID b);
633 //void            (ODE_API *dBodySetMaxAngularSpeed)(dBodyID b, dReal max_speed);
634 //int             (ODE_API *dBodyGetGyroscopicMode)(dBodyID b);
635 //void            (ODE_API *dBodySetGyroscopicMode)(dBodyID b, int enabled);
636 //dJointID        (ODE_API *dJointCreateBall)(dWorldID, dJointGroupID);
637 //dJointID        (ODE_API *dJointCreateHinge)(dWorldID, dJointGroupID);
638 //dJointID        (ODE_API *dJointCreateSlider)(dWorldID, dJointGroupID);
639 dJointID        (ODE_API *dJointCreateContact)(dWorldID, dJointGroupID, const dContact *);
640 //dJointID        (ODE_API *dJointCreateHinge2)(dWorldID, dJointGroupID);
641 //dJointID        (ODE_API *dJointCreateUniversal)(dWorldID, dJointGroupID);
642 //dJointID        (ODE_API *dJointCreatePR)(dWorldID, dJointGroupID);
643 //dJointID        (ODE_API *dJointCreatePU)(dWorldID, dJointGroupID);
644 //dJointID        (ODE_API *dJointCreatePiston)(dWorldID, dJointGroupID);
645 //dJointID        (ODE_API *dJointCreateFixed)(dWorldID, dJointGroupID);
646 //dJointID        (ODE_API *dJointCreateNull)(dWorldID, dJointGroupID);
647 //dJointID        (ODE_API *dJointCreateAMotor)(dWorldID, dJointGroupID);
648 //dJointID        (ODE_API *dJointCreateLMotor)(dWorldID, dJointGroupID);
649 //dJointID        (ODE_API *dJointCreatePlane2D)(dWorldID, dJointGroupID);
650 //void            (ODE_API *dJointDestroy)(dJointID);
651 dJointGroupID   (ODE_API *dJointGroupCreate)(int max_size);
652 void            (ODE_API *dJointGroupDestroy)(dJointGroupID);
653 void            (ODE_API *dJointGroupEmpty)(dJointGroupID);
654 //int             (ODE_API *dJointGetNumBodies)(dJointID);
655 void            (ODE_API *dJointAttach)(dJointID, dBodyID body1, dBodyID body2);
656 //void            (ODE_API *dJointEnable)(dJointID);
657 //void            (ODE_API *dJointDisable)(dJointID);
658 //int             (ODE_API *dJointIsEnabled)(dJointID);
659 //void            (ODE_API *dJointSetData)(dJointID, void *data);
660 //void *          (ODE_API *dJointGetData)(dJointID);
661 //dJointType      (ODE_API *dJointGetType)(dJointID);
662 //dBodyID         (ODE_API *dJointGetBody)(dJointID, int index);
663 //void            (ODE_API *dJointSetFeedback)(dJointID, dJointFeedback *);
664 //dJointFeedback *(ODE_API *dJointGetFeedback)(dJointID);
665 //void            (ODE_API *dJointSetBallAnchor)(dJointID, dReal x, dReal y, dReal z);
666 //void            (ODE_API *dJointSetBallAnchor2)(dJointID, dReal x, dReal y, dReal z);
667 //void            (ODE_API *dJointSetBallParam)(dJointID, int parameter, dReal value);
668 //void            (ODE_API *dJointSetHingeAnchor)(dJointID, dReal x, dReal y, dReal z);
669 //void            (ODE_API *dJointSetHingeAnchorDelta)(dJointID, dReal x, dReal y, dReal z, dReal ax, dReal ay, dReal az);
670 //void            (ODE_API *dJointSetHingeAxis)(dJointID, dReal x, dReal y, dReal z);
671 //void            (ODE_API *dJointSetHingeAxisOffset)(dJointID j, dReal x, dReal y, dReal z, dReal angle);
672 //void            (ODE_API *dJointSetHingeParam)(dJointID, int parameter, dReal value);
673 //void            (ODE_API *dJointAddHingeTorque)(dJointID joint, dReal torque);
674 //void            (ODE_API *dJointSetSliderAxis)(dJointID, dReal x, dReal y, dReal z);
675 //void            (ODE_API *dJointSetSliderAxisDelta)(dJointID, dReal x, dReal y, dReal z, dReal ax, dReal ay, dReal az);
676 //void            (ODE_API *dJointSetSliderParam)(dJointID, int parameter, dReal value);
677 //void            (ODE_API *dJointAddSliderForce)(dJointID joint, dReal force);
678 //void            (ODE_API *dJointSetHinge2Anchor)(dJointID, dReal x, dReal y, dReal z);
679 //void            (ODE_API *dJointSetHinge2Axis1)(dJointID, dReal x, dReal y, dReal z);
680 //void            (ODE_API *dJointSetHinge2Axis2)(dJointID, dReal x, dReal y, dReal z);
681 //void            (ODE_API *dJointSetHinge2Param)(dJointID, int parameter, dReal value);
682 //void            (ODE_API *dJointAddHinge2Torques)(dJointID joint, dReal torque1, dReal torque2);
683 //void            (ODE_API *dJointSetUniversalAnchor)(dJointID, dReal x, dReal y, dReal z);
684 //void            (ODE_API *dJointSetUniversalAxis1)(dJointID, dReal x, dReal y, dReal z);
685 //void            (ODE_API *dJointSetUniversalAxis1Offset)(dJointID, dReal x, dReal y, dReal z, dReal offset1, dReal offset2);
686 //void            (ODE_API *dJointSetUniversalAxis2)(dJointID, dReal x, dReal y, dReal z);
687 //void            (ODE_API *dJointSetUniversalAxis2Offset)(dJointID, dReal x, dReal y, dReal z, dReal offset1, dReal offset2);
688 //void            (ODE_API *dJointSetUniversalParam)(dJointID, int parameter, dReal value);
689 //void            (ODE_API *dJointAddUniversalTorques)(dJointID joint, dReal torque1, dReal torque2);
690 //void            (ODE_API *dJointSetPRAnchor)(dJointID, dReal x, dReal y, dReal z);
691 //void            (ODE_API *dJointSetPRAxis1)(dJointID, dReal x, dReal y, dReal z);
692 //void            (ODE_API *dJointSetPRAxis2)(dJointID, dReal x, dReal y, dReal z);
693 //void            (ODE_API *dJointSetPRParam)(dJointID, int parameter, dReal value);
694 //void            (ODE_API *dJointAddPRTorque)(dJointID j, dReal torque);
695 //void            (ODE_API *dJointSetPUAnchor)(dJointID, dReal x, dReal y, dReal z);
696 //void            (ODE_API *dJointSetPUAnchorOffset)(dJointID, dReal x, dReal y, dReal z, dReal dx, dReal dy, dReal dz);
697 //void            (ODE_API *dJointSetPUAxis1)(dJointID, dReal x, dReal y, dReal z);
698 //void            (ODE_API *dJointSetPUAxis2)(dJointID, dReal x, dReal y, dReal z);
699 //void            (ODE_API *dJointSetPUAxis3)(dJointID, dReal x, dReal y, dReal z);
700 //void            (ODE_API *dJointSetPUAxisP)(dJointID id, dReal x, dReal y, dReal z);
701 //void            (ODE_API *dJointSetPUParam)(dJointID, int parameter, dReal value);
702 //void            (ODE_API *dJointAddPUTorque)(dJointID j, dReal torque);
703 //void            (ODE_API *dJointSetPistonAnchor)(dJointID, dReal x, dReal y, dReal z);
704 //void            (ODE_API *dJointSetPistonAnchorOffset)(dJointID j, dReal x, dReal y, dReal z, dReal dx, dReal dy, dReal dz);
705 //void            (ODE_API *dJointSetPistonParam)(dJointID, int parameter, dReal value);
706 //void            (ODE_API *dJointAddPistonForce)(dJointID joint, dReal force);
707 //void            (ODE_API *dJointSetFixed)(dJointID);
708 //void            (ODE_API *dJointSetFixedParam)(dJointID, int parameter, dReal value);
709 //void            (ODE_API *dJointSetAMotorNumAxes)(dJointID, int num);
710 //void            (ODE_API *dJointSetAMotorAxis)(dJointID, int anum, int rel, dReal x, dReal y, dReal z);
711 //void            (ODE_API *dJointSetAMotorAngle)(dJointID, int anum, dReal angle);
712 //void            (ODE_API *dJointSetAMotorParam)(dJointID, int parameter, dReal value);
713 //void            (ODE_API *dJointSetAMotorMode)(dJointID, int mode);
714 //void            (ODE_API *dJointAddAMotorTorques)(dJointID, dReal torque1, dReal torque2, dReal torque3);
715 //void            (ODE_API *dJointSetLMotorNumAxes)(dJointID, int num);
716 //void            (ODE_API *dJointSetLMotorAxis)(dJointID, int anum, int rel, dReal x, dReal y, dReal z);
717 //void            (ODE_API *dJointSetLMotorParam)(dJointID, int parameter, dReal value);
718 //void            (ODE_API *dJointSetPlane2DXParam)(dJointID, int parameter, dReal value);
719 //void            (ODE_API *dJointSetPlane2DYParam)(dJointID, int parameter, dReal value);
720 //void            (ODE_API *dJointSetPlane2DAngleParam)(dJointID, int parameter, dReal value);
721 //void            (ODE_API *dJointGetBallAnchor)(dJointID, dVector3 result);
722 //void            (ODE_API *dJointGetBallAnchor2)(dJointID, dVector3 result);
723 //dReal           (ODE_API *dJointGetBallParam)(dJointID, int parameter);
724 //void            (ODE_API *dJointGetHingeAnchor)(dJointID, dVector3 result);
725 //void            (ODE_API *dJointGetHingeAnchor2)(dJointID, dVector3 result);
726 //void            (ODE_API *dJointGetHingeAxis)(dJointID, dVector3 result);
727 //dReal           (ODE_API *dJointGetHingeParam)(dJointID, int parameter);
728 //dReal           (ODE_API *dJointGetHingeAngle)(dJointID);
729 //dReal           (ODE_API *dJointGetHingeAngleRate)(dJointID);
730 //dReal           (ODE_API *dJointGetSliderPosition)(dJointID);
731 //dReal           (ODE_API *dJointGetSliderPositionRate)(dJointID);
732 //void            (ODE_API *dJointGetSliderAxis)(dJointID, dVector3 result);
733 //dReal           (ODE_API *dJointGetSliderParam)(dJointID, int parameter);
734 //void            (ODE_API *dJointGetHinge2Anchor)(dJointID, dVector3 result);
735 //void            (ODE_API *dJointGetHinge2Anchor2)(dJointID, dVector3 result);
736 //void            (ODE_API *dJointGetHinge2Axis1)(dJointID, dVector3 result);
737 //void            (ODE_API *dJointGetHinge2Axis2)(dJointID, dVector3 result);
738 //dReal           (ODE_API *dJointGetHinge2Param)(dJointID, int parameter);
739 //dReal           (ODE_API *dJointGetHinge2Angle1)(dJointID);
740 //dReal           (ODE_API *dJointGetHinge2Angle1Rate)(dJointID);
741 //dReal           (ODE_API *dJointGetHinge2Angle2Rate)(dJointID);
742 //void            (ODE_API *dJointGetUniversalAnchor)(dJointID, dVector3 result);
743 //void            (ODE_API *dJointGetUniversalAnchor2)(dJointID, dVector3 result);
744 //void            (ODE_API *dJointGetUniversalAxis1)(dJointID, dVector3 result);
745 //void            (ODE_API *dJointGetUniversalAxis2)(dJointID, dVector3 result);
746 //dReal           (ODE_API *dJointGetUniversalParam)(dJointID, int parameter);
747 //void            (ODE_API *dJointGetUniversalAngles)(dJointID, dReal *angle1, dReal *angle2);
748 //dReal           (ODE_API *dJointGetUniversalAngle1)(dJointID);
749 //dReal           (ODE_API *dJointGetUniversalAngle2)(dJointID);
750 //dReal           (ODE_API *dJointGetUniversalAngle1Rate)(dJointID);
751 //dReal           (ODE_API *dJointGetUniversalAngle2Rate)(dJointID);
752 //void            (ODE_API *dJointGetPRAnchor)(dJointID, dVector3 result);
753 //dReal           (ODE_API *dJointGetPRPosition)(dJointID);
754 //dReal           (ODE_API *dJointGetPRPositionRate)(dJointID);
755 //dReal           (ODE_API *dJointGetPRAngle)(dJointID);
756 //dReal           (ODE_API *dJointGetPRAngleRate)(dJointID);
757 //void            (ODE_API *dJointGetPRAxis1)(dJointID, dVector3 result);
758 //void            (ODE_API *dJointGetPRAxis2)(dJointID, dVector3 result);
759 //dReal           (ODE_API *dJointGetPRParam)(dJointID, int parameter);
760 //void            (ODE_API *dJointGetPUAnchor)(dJointID, dVector3 result);
761 //dReal           (ODE_API *dJointGetPUPosition)(dJointID);
762 //dReal           (ODE_API *dJointGetPUPositionRate)(dJointID);
763 //void            (ODE_API *dJointGetPUAxis1)(dJointID, dVector3 result);
764 //void            (ODE_API *dJointGetPUAxis2)(dJointID, dVector3 result);
765 //void            (ODE_API *dJointGetPUAxis3)(dJointID, dVector3 result);
766 //void            (ODE_API *dJointGetPUAxisP)(dJointID id, dVector3 result);
767 //void            (ODE_API *dJointGetPUAngles)(dJointID, dReal *angle1, dReal *angle2);
768 //dReal           (ODE_API *dJointGetPUAngle1)(dJointID);
769 //dReal           (ODE_API *dJointGetPUAngle1Rate)(dJointID);
770 //dReal           (ODE_API *dJointGetPUAngle2)(dJointID);
771 //dReal           (ODE_API *dJointGetPUAngle2Rate)(dJointID);
772 //dReal           (ODE_API *dJointGetPUParam)(dJointID, int parameter);
773 //dReal           (ODE_API *dJointGetPistonPosition)(dJointID);
774 //dReal           (ODE_API *dJointGetPistonPositionRate)(dJointID);
775 //dReal           (ODE_API *dJointGetPistonAngle)(dJointID);
776 //dReal           (ODE_API *dJointGetPistonAngleRate)(dJointID);
777 //void            (ODE_API *dJointGetPistonAnchor)(dJointID, dVector3 result);
778 //void            (ODE_API *dJointGetPistonAnchor2)(dJointID, dVector3 result);
779 //void            (ODE_API *dJointGetPistonAxis)(dJointID, dVector3 result);
780 //dReal           (ODE_API *dJointGetPistonParam)(dJointID, int parameter);
781 //int             (ODE_API *dJointGetAMotorNumAxes)(dJointID);
782 //void            (ODE_API *dJointGetAMotorAxis)(dJointID, int anum, dVector3 result);
783 //int             (ODE_API *dJointGetAMotorAxisRel)(dJointID, int anum);
784 //dReal           (ODE_API *dJointGetAMotorAngle)(dJointID, int anum);
785 //dReal           (ODE_API *dJointGetAMotorAngleRate)(dJointID, int anum);
786 //dReal           (ODE_API *dJointGetAMotorParam)(dJointID, int parameter);
787 //int             (ODE_API *dJointGetAMotorMode)(dJointID);
788 //int             (ODE_API *dJointGetLMotorNumAxes)(dJointID);
789 //void            (ODE_API *dJointGetLMotorAxis)(dJointID, int anum, dVector3 result);
790 //dReal           (ODE_API *dJointGetLMotorParam)(dJointID, int parameter);
791 //dReal           (ODE_API *dJointGetFixedParam)(dJointID, int parameter);
792 //dJointID        (ODE_API *dConnectingJoint)(dBodyID, dBodyID);
793 //int             (ODE_API *dConnectingJointList)(dBodyID, dBodyID, dJointID*);
794 int             (ODE_API *dAreConnected)(dBodyID, dBodyID);
795 int             (ODE_API *dAreConnectedExcluding)(dBodyID body1, dBodyID body2, int joint_type);
796 //
797 dSpaceID        (ODE_API *dSimpleSpaceCreate)(dSpaceID space);
798 dSpaceID        (ODE_API *dHashSpaceCreate)(dSpaceID space);
799 dSpaceID        (ODE_API *dQuadTreeSpaceCreate)(dSpaceID space, const dVector3 Center, const dVector3 Extents, int Depth);
800 dSpaceID        (ODE_API *dSweepAndPruneSpaceCreate)( dSpaceID space, int axisorder );
801 void            (ODE_API *dSpaceDestroy)(dSpaceID);
802 //void            (ODE_API *dHashSpaceSetLevels)(dSpaceID space, int minlevel, int maxlevel);
803 //void            (ODE_API *dHashSpaceGetLevels)(dSpaceID space, int *minlevel, int *maxlevel);
804 //void            (ODE_API *dSpaceSetCleanup)(dSpaceID space, int mode);
805 //int             (ODE_API *dSpaceGetCleanup)(dSpaceID space);
806 //void            (ODE_API *dSpaceSetSublevel)(dSpaceID space, int sublevel);
807 //int             (ODE_API *dSpaceGetSublevel)(dSpaceID space);
808 //void            (ODE_API *dSpaceSetManualCleanup)(dSpaceID space, int mode);
809 //int             (ODE_API *dSpaceGetManualCleanup)(dSpaceID space);
810 //void            (ODE_API *dSpaceAdd)(dSpaceID, dGeomID);
811 //void            (ODE_API *dSpaceRemove)(dSpaceID, dGeomID);
812 //int             (ODE_API *dSpaceQuery)(dSpaceID, dGeomID);
813 //void            (ODE_API *dSpaceClean)(dSpaceID);
814 //int             (ODE_API *dSpaceGetNumGeoms)(dSpaceID);
815 //dGeomID         (ODE_API *dSpaceGetGeom)(dSpaceID, int i);
816 //int             (ODE_API *dSpaceGetClass)(dSpaceID space);
817 //
818 void            (ODE_API *dGeomDestroy)(dGeomID geom);
819 //void            (ODE_API *dGeomSetData)(dGeomID geom, void* data);
820 //void *          (ODE_API *dGeomGetData)(dGeomID geom);
821 void            (ODE_API *dGeomSetBody)(dGeomID geom, dBodyID body);
822 dBodyID         (ODE_API *dGeomGetBody)(dGeomID geom);
823 //void            (ODE_API *dGeomSetPosition)(dGeomID geom, dReal x, dReal y, dReal z);
824 void            (ODE_API *dGeomSetRotation)(dGeomID geom, const dMatrix3 R);
825 //void            (ODE_API *dGeomSetQuaternion)(dGeomID geom, const dQuaternion Q);
826 //const dReal *   (ODE_API *dGeomGetPosition)(dGeomID geom);
827 //void            (ODE_API *dGeomCopyPosition)(dGeomID geom, dVector3 pos);
828 //const dReal *   (ODE_API *dGeomGetRotation)(dGeomID geom);
829 //void            (ODE_API *dGeomCopyRotation)(dGeomID geom, dMatrix3 R);
830 //void            (ODE_API *dGeomGetQuaternion)(dGeomID geom, dQuaternion result);
831 //void            (ODE_API *dGeomGetAABB)(dGeomID geom, dReal aabb[6]);
832 int             (ODE_API *dGeomIsSpace)(dGeomID geom);
833 //dSpaceID        (ODE_API *dGeomGetSpace)(dGeomID);
834 //int             (ODE_API *dGeomGetClass)(dGeomID geom);
835 //void            (ODE_API *dGeomSetCategoryBits)(dGeomID geom, unsigned long bits);
836 //void            (ODE_API *dGeomSetCollideBits)(dGeomID geom, unsigned long bits);
837 //unsigned long   (ODE_API *dGeomGetCategoryBits)(dGeomID);
838 //unsigned long   (ODE_API *dGeomGetCollideBits)(dGeomID);
839 //void            (ODE_API *dGeomEnable)(dGeomID geom);
840 //void            (ODE_API *dGeomDisable)(dGeomID geom);
841 //int             (ODE_API *dGeomIsEnabled)(dGeomID geom);
842 //void            (ODE_API *dGeomSetOffsetPosition)(dGeomID geom, dReal x, dReal y, dReal z);
843 //void            (ODE_API *dGeomSetOffsetRotation)(dGeomID geom, const dMatrix3 R);
844 //void            (ODE_API *dGeomSetOffsetQuaternion)(dGeomID geom, const dQuaternion Q);
845 //void            (ODE_API *dGeomSetOffsetWorldPosition)(dGeomID geom, dReal x, dReal y, dReal z);
846 //void            (ODE_API *dGeomSetOffsetWorldRotation)(dGeomID geom, const dMatrix3 R);
847 //void            (ODE_API *dGeomSetOffsetWorldQuaternion)(dGeomID geom, const dQuaternion);
848 //void            (ODE_API *dGeomClearOffset)(dGeomID geom);
849 //int             (ODE_API *dGeomIsOffset)(dGeomID geom);
850 //const dReal *   (ODE_API *dGeomGetOffsetPosition)(dGeomID geom);
851 //void            (ODE_API *dGeomCopyOffsetPosition)(dGeomID geom, dVector3 pos);
852 //const dReal *   (ODE_API *dGeomGetOffsetRotation)(dGeomID geom);
853 //void            (ODE_API *dGeomCopyOffsetRotation)(dGeomID geom, dMatrix3 R);
854 //void            (ODE_API *dGeomGetOffsetQuaternion)(dGeomID geom, dQuaternion result);
855 int             (ODE_API *dCollide)(dGeomID o1, dGeomID o2, int flags, dContactGeom *contact, int skip);
856 //
857 void            (ODE_API *dSpaceCollide)(dSpaceID space, void *data, dNearCallback *callback);
858 void            (ODE_API *dSpaceCollide2)(dGeomID space1, dGeomID space2, void *data, dNearCallback *callback);
859 //
860 dGeomID         (ODE_API *dCreateSphere)(dSpaceID space, dReal radius);
861 //void            (ODE_API *dGeomSphereSetRadius)(dGeomID sphere, dReal radius);
862 //dReal           (ODE_API *dGeomSphereGetRadius)(dGeomID sphere);
863 //dReal           (ODE_API *dGeomSpherePointDepth)(dGeomID sphere, dReal x, dReal y, dReal z);
864 //
865 //dGeomID         (ODE_API *dCreateConvex)(dSpaceID space, dReal *_planes, unsigned int _planecount, dReal *_points, unsigned int _pointcount,unsigned int *_polygons);
866 //void            (ODE_API *dGeomSetConvex)(dGeomID g, dReal *_planes, unsigned int _count, dReal *_points, unsigned int _pointcount,unsigned int *_polygons);
867 //
868 dGeomID         (ODE_API *dCreateBox)(dSpaceID space, dReal lx, dReal ly, dReal lz);
869 //void            (ODE_API *dGeomBoxSetLengths)(dGeomID box, dReal lx, dReal ly, dReal lz);
870 //void            (ODE_API *dGeomBoxGetLengths)(dGeomID box, dVector3 result);
871 //dReal           (ODE_API *dGeomBoxPointDepth)(dGeomID box, dReal x, dReal y, dReal z);
872 //dReal           (ODE_API *dGeomBoxPointDepth)(dGeomID box, dReal x, dReal y, dReal z);
873 //
874 //dGeomID         (ODE_API *dCreatePlane)(dSpaceID space, dReal a, dReal b, dReal c, dReal d);
875 //void            (ODE_API *dGeomPlaneSetParams)(dGeomID plane, dReal a, dReal b, dReal c, dReal d);
876 //void            (ODE_API *dGeomPlaneGetParams)(dGeomID plane, dVector4 result);
877 //dReal           (ODE_API *dGeomPlanePointDepth)(dGeomID plane, dReal x, dReal y, dReal z);
878 //
879 dGeomID         (ODE_API *dCreateCapsule)(dSpaceID space, dReal radius, dReal length);
880 //void            (ODE_API *dGeomCapsuleSetParams)(dGeomID ccylinder, dReal radius, dReal length);
881 //void            (ODE_API *dGeomCapsuleGetParams)(dGeomID ccylinder, dReal *radius, dReal *length);
882 //dReal           (ODE_API *dGeomCapsulePointDepth)(dGeomID ccylinder, dReal x, dReal y, dReal z);
883 //
884 //dGeomID         (ODE_API *dCreateCylinder)(dSpaceID space, dReal radius, dReal length);
885 //void            (ODE_API *dGeomCylinderSetParams)(dGeomID cylinder, dReal radius, dReal length);
886 //void            (ODE_API *dGeomCylinderGetParams)(dGeomID cylinder, dReal *radius, dReal *length);
887 //
888 //dGeomID         (ODE_API *dCreateRay)(dSpaceID space, dReal length);
889 //void            (ODE_API *dGeomRaySetLength)(dGeomID ray, dReal length);
890 //dReal           (ODE_API *dGeomRayGetLength)(dGeomID ray);
891 //void            (ODE_API *dGeomRaySet)(dGeomID ray, dReal px, dReal py, dReal pz, dReal dx, dReal dy, dReal dz);
892 //void            (ODE_API *dGeomRayGet)(dGeomID ray, dVector3 start, dVector3 dir);
893 //
894 dGeomID         (ODE_API *dCreateGeomTransform)(dSpaceID space);
895 void            (ODE_API *dGeomTransformSetGeom)(dGeomID g, dGeomID obj);
896 //dGeomID         (ODE_API *dGeomTransformGetGeom)(dGeomID g);
897 void            (ODE_API *dGeomTransformSetCleanup)(dGeomID g, int mode);
898 //int             (ODE_API *dGeomTransformGetCleanup)(dGeomID g);
899 //void            (ODE_API *dGeomTransformSetInfo)(dGeomID g, int mode);
900 //int             (ODE_API *dGeomTransformGetInfo)(dGeomID g);
901
902 enum { TRIMESH_FACE_NORMALS };
903 typedef int dTriCallback(dGeomID TriMesh, dGeomID RefObject, int TriangleIndex);
904 typedef void dTriArrayCallback(dGeomID TriMesh, dGeomID RefObject, const int* TriIndices, int TriCount);
905 typedef int dTriRayCallback(dGeomID TriMesh, dGeomID Ray, int TriangleIndex, dReal u, dReal v);
906 typedef int dTriTriMergeCallback(dGeomID TriMesh, int FirstTriangleIndex, int SecondTriangleIndex);
907
908 dTriMeshDataID  (ODE_API *dGeomTriMeshDataCreate)(void);
909 void            (ODE_API *dGeomTriMeshDataDestroy)(dTriMeshDataID g);
910 //void            (ODE_API *dGeomTriMeshDataSet)(dTriMeshDataID g, int data_id, void* in_data);
911 //void*           (ODE_API *dGeomTriMeshDataGet)(dTriMeshDataID g, int data_id);
912 //void            (*dGeomTriMeshSetLastTransform)( (ODE_API *dGeomID g, dMatrix4 last_trans );
913 //dReal*          (*dGeomTriMeshGetLastTransform)( (ODE_API *dGeomID g );
914 void            (ODE_API *dGeomTriMeshDataBuildSingle)(dTriMeshDataID g, const void* Vertices, int VertexStride, int VertexCount,  const void* Indices, int IndexCount, int TriStride);
915 //void            (ODE_API *dGeomTriMeshDataBuildSingle1)(dTriMeshDataID g, const void* Vertices, int VertexStride, int VertexCount,  const void* Indices, int IndexCount, int TriStride, const void* Normals);
916 //void            (ODE_API *dGeomTriMeshDataBuildDouble)(dTriMeshDataID g,  const void* Vertices,  int VertexStride, int VertexCount,  const void* Indices, int IndexCount, int TriStride);
917 //void            (ODE_API *dGeomTriMeshDataBuildDouble1)(dTriMeshDataID g,  const void* Vertices,  int VertexStride, int VertexCount,  const void* Indices, int IndexCount, int TriStride, const void* Normals);
918 //void            (ODE_API *dGeomTriMeshDataBuildSimple)(dTriMeshDataID g, const dReal* Vertices, int VertexCount, const dTriIndex* Indices, int IndexCount);
919 //void            (ODE_API *dGeomTriMeshDataBuildSimple1)(dTriMeshDataID g, const dReal* Vertices, int VertexCount, const dTriIndex* Indices, int IndexCount, const int* Normals);
920 //void            (ODE_API *dGeomTriMeshDataPreprocess)(dTriMeshDataID g);
921 //void            (ODE_API *dGeomTriMeshDataGetBuffer)(dTriMeshDataID g, unsigned char** buf, int* bufLen);
922 //void            (ODE_API *dGeomTriMeshDataSetBuffer)(dTriMeshDataID g, unsigned char* buf);
923 //void            (ODE_API *dGeomTriMeshSetCallback)(dGeomID g, dTriCallback* Callback);
924 //dTriCallback*   (ODE_API *dGeomTriMeshGetCallback)(dGeomID g);
925 //void            (ODE_API *dGeomTriMeshSetArrayCallback)(dGeomID g, dTriArrayCallback* ArrayCallback);
926 //dTriArrayCallback* (ODE_API *dGeomTriMeshGetArrayCallback)(dGeomID g);
927 //void            (ODE_API *dGeomTriMeshSetRayCallback)(dGeomID g, dTriRayCallback* Callback);
928 //dTriRayCallback* (ODE_API *dGeomTriMeshGetRayCallback)(dGeomID g);
929 //void            (ODE_API *dGeomTriMeshSetTriMergeCallback)(dGeomID g, dTriTriMergeCallback* Callback);
930 //dTriTriMergeCallback* (ODE_API *dGeomTriMeshGetTriMergeCallback)(dGeomID g);
931 dGeomID         (ODE_API *dCreateTriMesh)(dSpaceID space, dTriMeshDataID Data, dTriCallback* Callback, dTriArrayCallback* ArrayCallback, dTriRayCallback* RayCallback);
932 //void            (ODE_API *dGeomTriMeshSetData)(dGeomID g, dTriMeshDataID Data);
933 //dTriMeshDataID  (ODE_API *dGeomTriMeshGetData)(dGeomID g);
934 //void            (ODE_API *dGeomTriMeshEnableTC)(dGeomID g, int geomClass, int enable);
935 //int             (ODE_API *dGeomTriMeshIsTCEnabled)(dGeomID g, int geomClass);
936 //void            (ODE_API *dGeomTriMeshClearTCCache)(dGeomID g);
937 //dTriMeshDataID  (ODE_API *dGeomTriMeshGetTriMeshDataID)(dGeomID g);
938 //void            (ODE_API *dGeomTriMeshGetTriangle)(dGeomID g, int Index, dVector3* v0, dVector3* v1, dVector3* v2);
939 //void            (ODE_API *dGeomTriMeshGetPoint)(dGeomID g, int Index, dReal u, dReal v, dVector3 Out);
940 //int             (ODE_API *dGeomTriMeshGetTriangleCount )(dGeomID g);
941 //void            (ODE_API *dGeomTriMeshDataUpdate)(dTriMeshDataID g);
942
943 static dllfunction_t odefuncs[] =
944 {
945         {"dGetConfiguration",                                                   (void **) &dGetConfiguration},
946         {"dCheckConfiguration",                                                 (void **) &dCheckConfiguration},
947         {"dInitODE",                                                                    (void **) &dInitODE},
948 //      {"dInitODE2",                                                                   (void **) &dInitODE2},
949         {"dAllocateODEDataForThread",                                   (void **) &dAllocateODEDataForThread},
950         {"dCleanupODEAllDataForThread",                                 (void **) &dCleanupODEAllDataForThread},
951         {"dCloseODE",                                                                   (void **) &dCloseODE},
952 //      {"dMassCheck",                                                                  (void **) &dMassCheck},
953 //      {"dMassSetZero",                                                                (void **) &dMassSetZero},
954 //      {"dMassSetParameters",                                                  (void **) &dMassSetParameters},
955 //      {"dMassSetSphere",                                                              (void **) &dMassSetSphere},
956         {"dMassSetSphereTotal",                                                 (void **) &dMassSetSphereTotal},
957 //      {"dMassSetCapsule",                                                             (void **) &dMassSetCapsule},
958         {"dMassSetCapsuleTotal",                                                (void **) &dMassSetCapsuleTotal},
959 //      {"dMassSetCylinder",                                                    (void **) &dMassSetCylinder},
960 //      {"dMassSetCylinderTotal",                                               (void **) &dMassSetCylinderTotal},
961 //      {"dMassSetBox",                                                                 (void **) &dMassSetBox},
962         {"dMassSetBoxTotal",                                                    (void **) &dMassSetBoxTotal},
963 //      {"dMassSetTrimesh",                                                             (void **) &dMassSetTrimesh},
964 //      {"dMassSetTrimeshTotal",                                                (void **) &dMassSetTrimeshTotal},
965 //      {"dMassAdjust",                                                                 (void **) &dMassAdjust},
966 //      {"dMassTranslate",                                                              (void **) &dMassTranslate},
967 //      {"dMassRotate",                                                                 (void **) &dMassRotate},
968 //      {"dMassAdd",                                                                    (void **) &dMassAdd},
969
970         {"dWorldCreate",                                                                (void **) &dWorldCreate},
971         {"dWorldDestroy",                                                               (void **) &dWorldDestroy},
972         {"dWorldSetGravity",                                                    (void **) &dWorldSetGravity},
973 //      {"dWorldGetGravity",                                                    (void **) &dWorldGetGravity},
974 //      {"dWorldSetERP",                                                                (void **) &dWorldSetERP},
975 //      {"dWorldGetERP",                                                                (void **) &dWorldGetERP},
976 //      {"dWorldSetCFM",                                                                (void **) &dWorldSetCFM},
977 //      {"dWorldGetCFM",                                                                (void **) &dWorldGetCFM},
978         {"dWorldStep",                                                                  (void **) &dWorldStep},
979 //      {"dWorldImpulseToForce",                                                (void **) &dWorldImpulseToForce},
980         {"dWorldQuickStep",                                                             (void **) &dWorldQuickStep},
981         {"dWorldSetQuickStepNumIterations",                             (void **) &dWorldSetQuickStepNumIterations},
982 //      {"dWorldGetQuickStepNumIterations",                             (void **) &dWorldGetQuickStepNumIterations},
983 //      {"dWorldSetQuickStepW",                                                 (void **) &dWorldSetQuickStepW},
984 //      {"dWorldGetQuickStepW",                                                 (void **) &dWorldGetQuickStepW},
985 //      {"dWorldSetContactMaxCorrectingVel",                    (void **) &dWorldSetContactMaxCorrectingVel},
986 //      {"dWorldGetContactMaxCorrectingVel",                    (void **) &dWorldGetContactMaxCorrectingVel},
987         {"dWorldSetContactSurfaceLayer",                                (void **) &dWorldSetContactSurfaceLayer},
988 //      {"dWorldGetContactSurfaceLayer",                                (void **) &dWorldGetContactSurfaceLayer},
989         {"dWorldStepFast1",                                                             (void **) &dWorldStepFast1},
990 //      {"dWorldSetAutoEnableDepthSF1",                                 (void **) &dWorldSetAutoEnableDepthSF1},
991 //      {"dWorldGetAutoEnableDepthSF1",                                 (void **) &dWorldGetAutoEnableDepthSF1},
992 //      {"dWorldGetAutoDisableLinearThreshold",                 (void **) &dWorldGetAutoDisableLinearThreshold},
993 //      {"dWorldSetAutoDisableLinearThreshold",                 (void **) &dWorldSetAutoDisableLinearThreshold},
994 //      {"dWorldGetAutoDisableAngularThreshold",                (void **) &dWorldGetAutoDisableAngularThreshold},
995 //      {"dWorldSetAutoDisableAngularThreshold",                (void **) &dWorldSetAutoDisableAngularThreshold},
996 //      {"dWorldGetAutoDisableLinearAverageThreshold",  (void **) &dWorldGetAutoDisableLinearAverageThreshold},
997 //      {"dWorldSetAutoDisableLinearAverageThreshold",  (void **) &dWorldSetAutoDisableLinearAverageThreshold},
998 //      {"dWorldGetAutoDisableAngularAverageThreshold", (void **) &dWorldGetAutoDisableAngularAverageThreshold},
999 //      {"dWorldSetAutoDisableAngularAverageThreshold", (void **) &dWorldSetAutoDisableAngularAverageThreshold},
1000 //      {"dWorldGetAutoDisableAverageSamplesCount",             (void **) &dWorldGetAutoDisableAverageSamplesCount},
1001 //      {"dWorldSetAutoDisableAverageSamplesCount",             (void **) &dWorldSetAutoDisableAverageSamplesCount},
1002 //      {"dWorldGetAutoDisableSteps",                                   (void **) &dWorldGetAutoDisableSteps},
1003 //      {"dWorldSetAutoDisableSteps",                                   (void **) &dWorldSetAutoDisableSteps},
1004 //      {"dWorldGetAutoDisableTime",                                    (void **) &dWorldGetAutoDisableTime},
1005 //      {"dWorldSetAutoDisableTime",                                    (void **) &dWorldSetAutoDisableTime},
1006 //      {"dWorldGetAutoDisableFlag",                                    (void **) &dWorldGetAutoDisableFlag},
1007 //      {"dWorldSetAutoDisableFlag",                                    (void **) &dWorldSetAutoDisableFlag},
1008 //      {"dWorldGetLinearDampingThreshold",                             (void **) &dWorldGetLinearDampingThreshold},
1009 //      {"dWorldSetLinearDampingThreshold",                             (void **) &dWorldSetLinearDampingThreshold},
1010 //      {"dWorldGetAngularDampingThreshold",                    (void **) &dWorldGetAngularDampingThreshold},
1011 //      {"dWorldSetAngularDampingThreshold",                    (void **) &dWorldSetAngularDampingThreshold},
1012 //      {"dWorldGetLinearDamping",                                              (void **) &dWorldGetLinearDamping},
1013 //      {"dWorldSetLinearDamping",                                              (void **) &dWorldSetLinearDamping},
1014 //      {"dWorldGetAngularDamping",                                             (void **) &dWorldGetAngularDamping},
1015 //      {"dWorldSetAngularDamping",                                             (void **) &dWorldSetAngularDamping},
1016 //      {"dWorldSetDamping",                                                    (void **) &dWorldSetDamping},
1017 //      {"dWorldGetMaxAngularSpeed",                                    (void **) &dWorldGetMaxAngularSpeed},
1018 //      {"dWorldSetMaxAngularSpeed",                                    (void **) &dWorldSetMaxAngularSpeed},
1019 //      {"dBodyGetAutoDisableLinearThreshold",                  (void **) &dBodyGetAutoDisableLinearThreshold},
1020 //      {"dBodySetAutoDisableLinearThreshold",                  (void **) &dBodySetAutoDisableLinearThreshold},
1021 //      {"dBodyGetAutoDisableAngularThreshold",                 (void **) &dBodyGetAutoDisableAngularThreshold},
1022 //      {"dBodySetAutoDisableAngularThreshold",                 (void **) &dBodySetAutoDisableAngularThreshold},
1023 //      {"dBodyGetAutoDisableAverageSamplesCount",              (void **) &dBodyGetAutoDisableAverageSamplesCount},
1024 //      {"dBodySetAutoDisableAverageSamplesCount",              (void **) &dBodySetAutoDisableAverageSamplesCount},
1025 //      {"dBodyGetAutoDisableSteps",                                    (void **) &dBodyGetAutoDisableSteps},
1026 //      {"dBodySetAutoDisableSteps",                                    (void **) &dBodySetAutoDisableSteps},
1027 //      {"dBodyGetAutoDisableTime",                                             (void **) &dBodyGetAutoDisableTime},
1028 //      {"dBodySetAutoDisableTime",                                             (void **) &dBodySetAutoDisableTime},
1029 //      {"dBodyGetAutoDisableFlag",                                             (void **) &dBodyGetAutoDisableFlag},
1030 //      {"dBodySetAutoDisableFlag",                                             (void **) &dBodySetAutoDisableFlag},
1031 //      {"dBodySetAutoDisableDefaults",                                 (void **) &dBodySetAutoDisableDefaults},
1032 //      {"dBodyGetWorld",                                                               (void **) &dBodyGetWorld},
1033         {"dBodyCreate",                                                                 (void **) &dBodyCreate},
1034         {"dBodyDestroy",                                                                (void **) &dBodyDestroy},
1035         {"dBodySetData",                                                                (void **) &dBodySetData},
1036 //      {"dBodyGetData",                                                                (void **) &dBodyGetData},
1037         {"dBodySetPosition",                                                    (void **) &dBodySetPosition},
1038         {"dBodySetRotation",                                                    (void **) &dBodySetRotation},
1039 //      {"dBodySetQuaternion",                                                  (void **) &dBodySetQuaternion},
1040         {"dBodySetLinearVel",                                                   (void **) &dBodySetLinearVel},
1041         {"dBodySetAngularVel",                                                  (void **) &dBodySetAngularVel},
1042         {"dBodyGetPosition",                                                    (void **) &dBodyGetPosition},
1043 //      {"dBodyCopyPosition",                                                   (void **) &dBodyCopyPosition},
1044         {"dBodyGetRotation",                                                    (void **) &dBodyGetRotation},
1045 //      {"dBodyCopyRotation",                                                   (void **) &dBodyCopyRotation},
1046 //      {"dBodyGetQuaternion",                                                  (void **) &dBodyGetQuaternion},
1047 //      {"dBodyCopyQuaternion",                                                 (void **) &dBodyCopyQuaternion},
1048         {"dBodyGetLinearVel",                                                   (void **) &dBodyGetLinearVel},
1049         {"dBodyGetAngularVel",                                                  (void **) &dBodyGetAngularVel},
1050         {"dBodySetMass",                                                                (void **) &dBodySetMass},
1051 //      {"dBodyGetMass",                                                                (void **) &dBodyGetMass},
1052 //      {"dBodyAddForce",                                                               (void **) &dBodyAddForce},
1053 //      {"dBodyAddTorque",                                                              (void **) &dBodyAddTorque},
1054 //      {"dBodyAddRelForce",                                                    (void **) &dBodyAddRelForce},
1055 //      {"dBodyAddRelTorque",                                                   (void **) &dBodyAddRelTorque},
1056 //      {"dBodyAddForceAtPos",                                                  (void **) &dBodyAddForceAtPos},
1057 //      {"dBodyAddForceAtRelPos",                                               (void **) &dBodyAddForceAtRelPos},
1058 //      {"dBodyAddRelForceAtPos",                                               (void **) &dBodyAddRelForceAtPos},
1059 //      {"dBodyAddRelForceAtRelPos",                                    (void **) &dBodyAddRelForceAtRelPos},
1060 //      {"dBodyGetForce",                                                               (void **) &dBodyGetForce},
1061 //      {"dBodyGetTorque",                                                              (void **) &dBodyGetTorque},
1062 //      {"dBodySetForce",                                                               (void **) &dBodySetForce},
1063 //      {"dBodySetTorque",                                                              (void **) &dBodySetTorque},
1064 //      {"dBodyGetRelPointPos",                                                 (void **) &dBodyGetRelPointPos},
1065 //      {"dBodyGetRelPointVel",                                                 (void **) &dBodyGetRelPointVel},
1066 //      {"dBodyGetPointVel",                                                    (void **) &dBodyGetPointVel},
1067 //      {"dBodyGetPosRelPoint",                                                 (void **) &dBodyGetPosRelPoint},
1068 //      {"dBodyVectorToWorld",                                                  (void **) &dBodyVectorToWorld},
1069 //      {"dBodyVectorFromWorld",                                                (void **) &dBodyVectorFromWorld},
1070 //      {"dBodySetFiniteRotationMode",                                  (void **) &dBodySetFiniteRotationMode},
1071 //      {"dBodySetFiniteRotationAxis",                                  (void **) &dBodySetFiniteRotationAxis},
1072 //      {"dBodyGetFiniteRotationMode",                                  (void **) &dBodyGetFiniteRotationMode},
1073 //      {"dBodyGetFiniteRotationAxis",                                  (void **) &dBodyGetFiniteRotationAxis},
1074 //      {"dBodyGetNumJoints",                                                   (void **) &dBodyGetNumJoints},
1075 //      {"dBodyGetJoint",                                                               (void **) &dBodyGetJoint},
1076 //      {"dBodySetDynamic",                                                             (void **) &dBodySetDynamic},
1077 //      {"dBodySetKinematic",                                                   (void **) &dBodySetKinematic},
1078 //      {"dBodyIsKinematic",                                                    (void **) &dBodyIsKinematic},
1079 //      {"dBodyEnable",                                                                 (void **) &dBodyEnable},
1080 //      {"dBodyDisable",                                                                (void **) &dBodyDisable},
1081 //      {"dBodyIsEnabled",                                                              (void **) &dBodyIsEnabled},
1082 //      {"dBodySetGravityMode",                                                 (void **) &dBodySetGravityMode},
1083 //      {"dBodyGetGravityMode",                                                 (void **) &dBodyGetGravityMode},
1084 //      {"dBodySetMovedCallback",                                               (void **) &dBodySetMovedCallback},
1085 //      {"dBodyGetFirstGeom",                                                   (void **) &dBodyGetFirstGeom},
1086 //      {"dBodyGetNextGeom",                                                    (void **) &dBodyGetNextGeom},
1087 //      {"dBodySetDampingDefaults",                                             (void **) &dBodySetDampingDefaults},
1088 //      {"dBodyGetLinearDamping",                                               (void **) &dBodyGetLinearDamping},
1089 //      {"dBodySetLinearDamping",                                               (void **) &dBodySetLinearDamping},
1090 //      {"dBodyGetAngularDamping",                                              (void **) &dBodyGetAngularDamping},
1091 //      {"dBodySetAngularDamping",                                              (void **) &dBodySetAngularDamping},
1092 //      {"dBodySetDamping",                                                             (void **) &dBodySetDamping},
1093 //      {"dBodyGetLinearDampingThreshold",                              (void **) &dBodyGetLinearDampingThreshold},
1094 //      {"dBodySetLinearDampingThreshold",                              (void **) &dBodySetLinearDampingThreshold},
1095 //      {"dBodyGetAngularDampingThreshold",                             (void **) &dBodyGetAngularDampingThreshold},
1096 //      {"dBodySetAngularDampingThreshold",                             (void **) &dBodySetAngularDampingThreshold},
1097 //      {"dBodyGetMaxAngularSpeed",                                             (void **) &dBodyGetMaxAngularSpeed},
1098 //      {"dBodySetMaxAngularSpeed",                                             (void **) &dBodySetMaxAngularSpeed},
1099 //      {"dBodyGetGyroscopicMode",                                              (void **) &dBodyGetGyroscopicMode},
1100 //      {"dBodySetGyroscopicMode",                                              (void **) &dBodySetGyroscopicMode},
1101 //      {"dJointCreateBall",                                                    (void **) &dJointCreateBall},
1102 //      {"dJointCreateHinge",                                                   (void **) &dJointCreateHinge},
1103 //      {"dJointCreateSlider",                                                  (void **) &dJointCreateSlider},
1104         {"dJointCreateContact",                                                 (void **) &dJointCreateContact},
1105 //      {"dJointCreateHinge2",                                                  (void **) &dJointCreateHinge2},
1106 //      {"dJointCreateUniversal",                                               (void **) &dJointCreateUniversal},
1107 //      {"dJointCreatePR",                                                              (void **) &dJointCreatePR},
1108 //      {"dJointCreatePU",                                                              (void **) &dJointCreatePU},
1109 //      {"dJointCreatePiston",                                                  (void **) &dJointCreatePiston},
1110 //      {"dJointCreateFixed",                                                   (void **) &dJointCreateFixed},
1111 //      {"dJointCreateNull",                                                    (void **) &dJointCreateNull},
1112 //      {"dJointCreateAMotor",                                                  (void **) &dJointCreateAMotor},
1113 //      {"dJointCreateLMotor",                                                  (void **) &dJointCreateLMotor},
1114 //      {"dJointCreatePlane2D",                                                 (void **) &dJointCreatePlane2D},
1115 //      {"dJointDestroy",                                                               (void **) &dJointDestroy},
1116         {"dJointGroupCreate",                                                   (void **) &dJointGroupCreate},
1117         {"dJointGroupDestroy",                                                  (void **) &dJointGroupDestroy},
1118         {"dJointGroupEmpty",                                                    (void **) &dJointGroupEmpty},
1119 //      {"dJointGetNumBodies",                                                  (void **) &dJointGetNumBodies},
1120         {"dJointAttach",                                                                (void **) &dJointAttach},
1121 //      {"dJointEnable",                                                                (void **) &dJointEnable},
1122 //      {"dJointDisable",                                                               (void **) &dJointDisable},
1123 //      {"dJointIsEnabled",                                                             (void **) &dJointIsEnabled},
1124 //      {"dJointSetData",                                                               (void **) &dJointSetData},
1125 //      {"dJointGetData",                                                               (void **) &dJointGetData},
1126 //      {"dJointGetType",                                                               (void **) &dJointGetType},
1127 //      {"dJointGetBody",                                                               (void **) &dJointGetBody},
1128 //      {"dJointSetFeedback",                                                   (void **) &dJointSetFeedback},
1129 //      {"dJointGetFeedback",                                                   (void **) &dJointGetFeedback},
1130 //      {"dJointSetBallAnchor",                                                 (void **) &dJointSetBallAnchor},
1131 //      {"dJointSetBallAnchor2",                                                (void **) &dJointSetBallAnchor2},
1132 //      {"dJointSetBallParam",                                                  (void **) &dJointSetBallParam},
1133 //      {"dJointSetHingeAnchor",                                                (void **) &dJointSetHingeAnchor},
1134 //      {"dJointSetHingeAnchorDelta",                                   (void **) &dJointSetHingeAnchorDelta},
1135 //      {"dJointSetHingeAxis",                                                  (void **) &dJointSetHingeAxis},
1136 //      {"dJointSetHingeAxisOffset",                                    (void **) &dJointSetHingeAxisOffset},
1137 //      {"dJointSetHingeParam",                                                 (void **) &dJointSetHingeParam},
1138 //      {"dJointAddHingeTorque",                                                (void **) &dJointAddHingeTorque},
1139 //      {"dJointSetSliderAxis",                                                 (void **) &dJointSetSliderAxis},
1140 //      {"dJointSetSliderAxisDelta",                                    (void **) &dJointSetSliderAxisDelta},
1141 //      {"dJointSetSliderParam",                                                (void **) &dJointSetSliderParam},
1142 //      {"dJointAddSliderForce",                                                (void **) &dJointAddSliderForce},
1143 //      {"dJointSetHinge2Anchor",                                               (void **) &dJointSetHinge2Anchor},
1144 //      {"dJointSetHinge2Axis1",                                                (void **) &dJointSetHinge2Axis1},
1145 //      {"dJointSetHinge2Axis2",                                                (void **) &dJointSetHinge2Axis2},
1146 //      {"dJointSetHinge2Param",                                                (void **) &dJointSetHinge2Param},
1147 //      {"dJointAddHinge2Torques",                                              (void **) &dJointAddHinge2Torques},
1148 //      {"dJointSetUniversalAnchor",                                    (void **) &dJointSetUniversalAnchor},
1149 //      {"dJointSetUniversalAxis1",                                             (void **) &dJointSetUniversalAxis1},
1150 //      {"dJointSetUniversalAxis1Offset",                               (void **) &dJointSetUniversalAxis1Offset},
1151 //      {"dJointSetUniversalAxis2",                                             (void **) &dJointSetUniversalAxis2},
1152 //      {"dJointSetUniversalAxis2Offset",                               (void **) &dJointSetUniversalAxis2Offset},
1153 //      {"dJointSetUniversalParam",                                             (void **) &dJointSetUniversalParam},
1154 //      {"dJointAddUniversalTorques",                                   (void **) &dJointAddUniversalTorques},
1155 //      {"dJointSetPRAnchor",                                                   (void **) &dJointSetPRAnchor},
1156 //      {"dJointSetPRAxis1",                                                    (void **) &dJointSetPRAxis1},
1157 //      {"dJointSetPRAxis2",                                                    (void **) &dJointSetPRAxis2},
1158 //      {"dJointSetPRParam",                                                    (void **) &dJointSetPRParam},
1159 //      {"dJointAddPRTorque",                                                   (void **) &dJointAddPRTorque},
1160 //      {"dJointSetPUAnchor",                                                   (void **) &dJointSetPUAnchor},
1161 //      {"dJointSetPUAnchorOffset",                                             (void **) &dJointSetPUAnchorOffset},
1162 //      {"dJointSetPUAxis1",                                                    (void **) &dJointSetPUAxis1},
1163 //      {"dJointSetPUAxis2",                                                    (void **) &dJointSetPUAxis2},
1164 //      {"dJointSetPUAxis3",                                                    (void **) &dJointSetPUAxis3},
1165 //      {"dJointSetPUAxisP",                                                    (void **) &dJointSetPUAxisP},
1166 //      {"dJointSetPUParam",                                                    (void **) &dJointSetPUParam},
1167 //      {"dJointAddPUTorque",                                                   (void **) &dJointAddPUTorque},
1168 //      {"dJointSetPistonAnchor",                                               (void **) &dJointSetPistonAnchor},
1169 //      {"dJointSetPistonAnchorOffset",                                 (void **) &dJointSetPistonAnchorOffset},
1170 //      {"dJointSetPistonParam",                                                (void **) &dJointSetPistonParam},
1171 //      {"dJointAddPistonForce",                                                (void **) &dJointAddPistonForce},
1172 //      {"dJointSetFixed",                                                              (void **) &dJointSetFixed},
1173 //      {"dJointSetFixedParam",                                                 (void **) &dJointSetFixedParam},
1174 //      {"dJointSetAMotorNumAxes",                                              (void **) &dJointSetAMotorNumAxes},
1175 //      {"dJointSetAMotorAxis",                                                 (void **) &dJointSetAMotorAxis},
1176 //      {"dJointSetAMotorAngle",                                                (void **) &dJointSetAMotorAngle},
1177 //      {"dJointSetAMotorParam",                                                (void **) &dJointSetAMotorParam},
1178 //      {"dJointSetAMotorMode",                                                 (void **) &dJointSetAMotorMode},
1179 //      {"dJointAddAMotorTorques",                                              (void **) &dJointAddAMotorTorques},
1180 //      {"dJointSetLMotorNumAxes",                                              (void **) &dJointSetLMotorNumAxes},
1181 //      {"dJointSetLMotorAxis",                                                 (void **) &dJointSetLMotorAxis},
1182 //      {"dJointSetLMotorParam",                                                (void **) &dJointSetLMotorParam},
1183 //      {"dJointSetPlane2DXParam",                                              (void **) &dJointSetPlane2DXParam},
1184 //      {"dJointSetPlane2DYParam",                                              (void **) &dJointSetPlane2DYParam},
1185 //      {"dJointSetPlane2DAngleParam",                                  (void **) &dJointSetPlane2DAngleParam},
1186 //      {"dJointGetBallAnchor",                                                 (void **) &dJointGetBallAnchor},
1187 //      {"dJointGetBallAnchor2",                                                (void **) &dJointGetBallAnchor2},
1188 //      {"dJointGetBallParam",                                                  (void **) &dJointGetBallParam},
1189 //      {"dJointGetHingeAnchor",                                                (void **) &dJointGetHingeAnchor},
1190 //      {"dJointGetHingeAnchor2",                                               (void **) &dJointGetHingeAnchor2},
1191 //      {"dJointGetHingeAxis",                                                  (void **) &dJointGetHingeAxis},
1192 //      {"dJointGetHingeParam",                                                 (void **) &dJointGetHingeParam},
1193 //      {"dJointGetHingeAngle",                                                 (void **) &dJointGetHingeAngle},
1194 //      {"dJointGetHingeAngleRate",                                             (void **) &dJointGetHingeAngleRate},
1195 //      {"dJointGetSliderPosition",                                             (void **) &dJointGetSliderPosition},
1196 //      {"dJointGetSliderPositionRate",                                 (void **) &dJointGetSliderPositionRate},
1197 //      {"dJointGetSliderAxis",                                                 (void **) &dJointGetSliderAxis},
1198 //      {"dJointGetSliderParam",                                                (void **) &dJointGetSliderParam},
1199 //      {"dJointGetHinge2Anchor",                                               (void **) &dJointGetHinge2Anchor},
1200 //      {"dJointGetHinge2Anchor2",                                              (void **) &dJointGetHinge2Anchor2},
1201 //      {"dJointGetHinge2Axis1",                                                (void **) &dJointGetHinge2Axis1},
1202 //      {"dJointGetHinge2Axis2",                                                (void **) &dJointGetHinge2Axis2},
1203 //      {"dJointGetHinge2Param",                                                (void **) &dJointGetHinge2Param},
1204 //      {"dJointGetHinge2Angle1",                                               (void **) &dJointGetHinge2Angle1},
1205 //      {"dJointGetHinge2Angle1Rate",                                   (void **) &dJointGetHinge2Angle1Rate},
1206 //      {"dJointGetHinge2Angle2Rate",                                   (void **) &dJointGetHinge2Angle2Rate},
1207 //      {"dJointGetUniversalAnchor",                                    (void **) &dJointGetUniversalAnchor},
1208 //      {"dJointGetUniversalAnchor2",                                   (void **) &dJointGetUniversalAnchor2},
1209 //      {"dJointGetUniversalAxis1",                                             (void **) &dJointGetUniversalAxis1},
1210 //      {"dJointGetUniversalAxis2",                                             (void **) &dJointGetUniversalAxis2},
1211 //      {"dJointGetUniversalParam",                                             (void **) &dJointGetUniversalParam},
1212 //      {"dJointGetUniversalAngles",                                    (void **) &dJointGetUniversalAngles},
1213 //      {"dJointGetUniversalAngle1",                                    (void **) &dJointGetUniversalAngle1},
1214 //      {"dJointGetUniversalAngle2",                                    (void **) &dJointGetUniversalAngle2},
1215 //      {"dJointGetUniversalAngle1Rate",                                (void **) &dJointGetUniversalAngle1Rate},
1216 //      {"dJointGetUniversalAngle2Rate",                                (void **) &dJointGetUniversalAngle2Rate},
1217 //      {"dJointGetPRAnchor",                                                   (void **) &dJointGetPRAnchor},
1218 //      {"dJointGetPRPosition",                                                 (void **) &dJointGetPRPosition},
1219 //      {"dJointGetPRPositionRate",                                             (void **) &dJointGetPRPositionRate},
1220 //      {"dJointGetPRAngle",                                                    (void **) &dJointGetPRAngle},
1221 //      {"dJointGetPRAngleRate",                                                (void **) &dJointGetPRAngleRate},
1222 //      {"dJointGetPRAxis1",                                                    (void **) &dJointGetPRAxis1},
1223 //      {"dJointGetPRAxis2",                                                    (void **) &dJointGetPRAxis2},
1224 //      {"dJointGetPRParam",                                                    (void **) &dJointGetPRParam},
1225 //      {"dJointGetPUAnchor",                                                   (void **) &dJointGetPUAnchor},
1226 //      {"dJointGetPUPosition",                                                 (void **) &dJointGetPUPosition},
1227 //      {"dJointGetPUPositionRate",                                             (void **) &dJointGetPUPositionRate},
1228 //      {"dJointGetPUAxis1",                                                    (void **) &dJointGetPUAxis1},
1229 //      {"dJointGetPUAxis2",                                                    (void **) &dJointGetPUAxis2},
1230 //      {"dJointGetPUAxis3",                                                    (void **) &dJointGetPUAxis3},
1231 //      {"dJointGetPUAxisP",                                                    (void **) &dJointGetPUAxisP},
1232 //      {"dJointGetPUAngles",                                                   (void **) &dJointGetPUAngles},
1233 //      {"dJointGetPUAngle1",                                                   (void **) &dJointGetPUAngle1},
1234 //      {"dJointGetPUAngle1Rate",                                               (void **) &dJointGetPUAngle1Rate},
1235 //      {"dJointGetPUAngle2",                                                   (void **) &dJointGetPUAngle2},
1236 //      {"dJointGetPUAngle2Rate",                                               (void **) &dJointGetPUAngle2Rate},
1237 //      {"dJointGetPUParam",                                                    (void **) &dJointGetPUParam},
1238 //      {"dJointGetPistonPosition",                                             (void **) &dJointGetPistonPosition},
1239 //      {"dJointGetPistonPositionRate",                                 (void **) &dJointGetPistonPositionRate},
1240 //      {"dJointGetPistonAngle",                                                (void **) &dJointGetPistonAngle},
1241 //      {"dJointGetPistonAngleRate",                                    (void **) &dJointGetPistonAngleRate},
1242 //      {"dJointGetPistonAnchor",                                               (void **) &dJointGetPistonAnchor},
1243 //      {"dJointGetPistonAnchor2",                                              (void **) &dJointGetPistonAnchor2},
1244 //      {"dJointGetPistonAxis",                                                 (void **) &dJointGetPistonAxis},
1245 //      {"dJointGetPistonParam",                                                (void **) &dJointGetPistonParam},
1246 //      {"dJointGetAMotorNumAxes",                                              (void **) &dJointGetAMotorNumAxes},
1247 //      {"dJointGetAMotorAxis",                                                 (void **) &dJointGetAMotorAxis},
1248 //      {"dJointGetAMotorAxisRel",                                              (void **) &dJointGetAMotorAxisRel},
1249 //      {"dJointGetAMotorAngle",                                                (void **) &dJointGetAMotorAngle},
1250 //      {"dJointGetAMotorAngleRate",                                    (void **) &dJointGetAMotorAngleRate},
1251 //      {"dJointGetAMotorParam",                                                (void **) &dJointGetAMotorParam},
1252 //      {"dJointGetAMotorMode",                                                 (void **) &dJointGetAMotorMode},
1253 //      {"dJointGetLMotorNumAxes",                                              (void **) &dJointGetLMotorNumAxes},
1254 //      {"dJointGetLMotorAxis",                                                 (void **) &dJointGetLMotorAxis},
1255 //      {"dJointGetLMotorParam",                                                (void **) &dJointGetLMotorParam},
1256 //      {"dJointGetFixedParam",                                                 (void **) &dJointGetFixedParam},
1257 //      {"dConnectingJoint",                                                    (void **) &dConnectingJoint},
1258 //      {"dConnectingJointList",                                                (void **) &dConnectingJointList},
1259         {"dAreConnected",                                                               (void **) &dAreConnected},
1260         {"dAreConnectedExcluding",                                              (void **) &dAreConnectedExcluding},
1261         {"dSimpleSpaceCreate",                                                  (void **) &dSimpleSpaceCreate},
1262         {"dHashSpaceCreate",                                                    (void **) &dHashSpaceCreate},
1263         {"dQuadTreeSpaceCreate",                                                (void **) &dQuadTreeSpaceCreate},
1264         {"dSweepAndPruneSpaceCreate",                                   (void **) &dSweepAndPruneSpaceCreate},
1265         {"dSpaceDestroy",                                                               (void **) &dSpaceDestroy},
1266 //      {"dHashSpaceSetLevels",                                                 (void **) &dHashSpaceSetLevels},
1267 //      {"dHashSpaceGetLevels",                                                 (void **) &dHashSpaceGetLevels},
1268 //      {"dSpaceSetCleanup",                                                    (void **) &dSpaceSetCleanup},
1269 //      {"dSpaceGetCleanup",                                                    (void **) &dSpaceGetCleanup},
1270 //      {"dSpaceSetSublevel",                                                   (void **) &dSpaceSetSublevel},
1271 //      {"dSpaceGetSublevel",                                                   (void **) &dSpaceGetSublevel},
1272 //      {"dSpaceSetManualCleanup",                                              (void **) &dSpaceSetManualCleanup},
1273 //      {"dSpaceGetManualCleanup",                                              (void **) &dSpaceGetManualCleanup},
1274 //      {"dSpaceAdd",                                                                   (void **) &dSpaceAdd},
1275 //      {"dSpaceRemove",                                                                (void **) &dSpaceRemove},
1276 //      {"dSpaceQuery",                                                                 (void **) &dSpaceQuery},
1277 //      {"dSpaceClean",                                                                 (void **) &dSpaceClean},
1278 //      {"dSpaceGetNumGeoms",                                                   (void **) &dSpaceGetNumGeoms},
1279 //      {"dSpaceGetGeom",                                                               (void **) &dSpaceGetGeom},
1280 //      {"dSpaceGetClass",                                                              (void **) &dSpaceGetClass},
1281         {"dGeomDestroy",                                                                (void **) &dGeomDestroy},
1282 //      {"dGeomSetData",                                                                (void **) &dGeomSetData},
1283 //      {"dGeomGetData",                                                                (void **) &dGeomGetData},
1284         {"dGeomSetBody",                                                                (void **) &dGeomSetBody},
1285         {"dGeomGetBody",                                                                (void **) &dGeomGetBody},
1286 //      {"dGeomSetPosition",                                                    (void **) &dGeomSetPosition},
1287         {"dGeomSetRotation",                                                    (void **) &dGeomSetRotation},
1288 //      {"dGeomSetQuaternion",                                                  (void **) &dGeomSetQuaternion},
1289 //      {"dGeomGetPosition",                                                    (void **) &dGeomGetPosition},
1290 //      {"dGeomCopyPosition",                                                   (void **) &dGeomCopyPosition},
1291 //      {"dGeomGetRotation",                                                    (void **) &dGeomGetRotation},
1292 //      {"dGeomCopyRotation",                                                   (void **) &dGeomCopyRotation},
1293 //      {"dGeomGetQuaternion",                                                  (void **) &dGeomGetQuaternion},
1294 //      {"dGeomGetAABB",                                                                (void **) &dGeomGetAABB},
1295         {"dGeomIsSpace",                                                                (void **) &dGeomIsSpace},
1296 //      {"dGeomGetSpace",                                                               (void **) &dGeomGetSpace},
1297 //      {"dGeomGetClass",                                                               (void **) &dGeomGetClass},
1298 //      {"dGeomSetCategoryBits",                                                (void **) &dGeomSetCategoryBits},
1299 //      {"dGeomSetCollideBits",                                                 (void **) &dGeomSetCollideBits},
1300 //      {"dGeomGetCategoryBits",                                                (void **) &dGeomGetCategoryBits},
1301 //      {"dGeomGetCollideBits",                                                 (void **) &dGeomGetCollideBits},
1302 //      {"dGeomEnable",                                                                 (void **) &dGeomEnable},
1303 //      {"dGeomDisable",                                                                (void **) &dGeomDisable},
1304 //      {"dGeomIsEnabled",                                                              (void **) &dGeomIsEnabled},
1305 //      {"dGeomSetOffsetPosition",                                              (void **) &dGeomSetOffsetPosition},
1306 //      {"dGeomSetOffsetRotation",                                              (void **) &dGeomSetOffsetRotation},
1307 //      {"dGeomSetOffsetQuaternion",                                    (void **) &dGeomSetOffsetQuaternion},
1308 //      {"dGeomSetOffsetWorldPosition",                                 (void **) &dGeomSetOffsetWorldPosition},
1309 //      {"dGeomSetOffsetWorldRotation",                                 (void **) &dGeomSetOffsetWorldRotation},
1310 //      {"dGeomSetOffsetWorldQuaternion",                               (void **) &dGeomSetOffsetWorldQuaternion},
1311 //      {"dGeomClearOffset",                                                    (void **) &dGeomClearOffset},
1312 //      {"dGeomIsOffset",                                                               (void **) &dGeomIsOffset},
1313 //      {"dGeomGetOffsetPosition",                                              (void **) &dGeomGetOffsetPosition},
1314 //      {"dGeomCopyOffsetPosition",                                             (void **) &dGeomCopyOffsetPosition},
1315 //      {"dGeomGetOffsetRotation",                                              (void **) &dGeomGetOffsetRotation},
1316 //      {"dGeomCopyOffsetRotation",                                             (void **) &dGeomCopyOffsetRotation},
1317 //      {"dGeomGetOffsetQuaternion",                                    (void **) &dGeomGetOffsetQuaternion},
1318         {"dCollide",                                                                    (void **) &dCollide},
1319         {"dSpaceCollide",                                                               (void **) &dSpaceCollide},
1320         {"dSpaceCollide2",                                                              (void **) &dSpaceCollide2},
1321         {"dCreateSphere",                                                               (void **) &dCreateSphere},
1322 //      {"dGeomSphereSetRadius",                                                (void **) &dGeomSphereSetRadius},
1323 //      {"dGeomSphereGetRadius",                                                (void **) &dGeomSphereGetRadius},
1324 //      {"dGeomSpherePointDepth",                                               (void **) &dGeomSpherePointDepth},
1325 //      {"dCreateConvex",                                                               (void **) &dCreateConvex},
1326 //      {"dGeomSetConvex",                                                              (void **) &dGeomSetConvex},
1327         {"dCreateBox",                                                                  (void **) &dCreateBox},
1328 //      {"dGeomBoxSetLengths",                                                  (void **) &dGeomBoxSetLengths},
1329 //      {"dGeomBoxGetLengths",                                                  (void **) &dGeomBoxGetLengths},
1330 //      {"dGeomBoxPointDepth",                                                  (void **) &dGeomBoxPointDepth},
1331 //      {"dGeomBoxPointDepth",                                                  (void **) &dGeomBoxPointDepth},
1332 //      {"dCreatePlane",                                                                (void **) &dCreatePlane},
1333 //      {"dGeomPlaneSetParams",                                                 (void **) &dGeomPlaneSetParams},
1334 //      {"dGeomPlaneGetParams",                                                 (void **) &dGeomPlaneGetParams},
1335 //      {"dGeomPlanePointDepth",                                                (void **) &dGeomPlanePointDepth},
1336         {"dCreateCapsule",                                                              (void **) &dCreateCapsule},
1337 //      {"dGeomCapsuleSetParams",                                               (void **) &dGeomCapsuleSetParams},
1338 //      {"dGeomCapsuleGetParams",                                               (void **) &dGeomCapsuleGetParams},
1339 //      {"dGeomCapsulePointDepth",                                              (void **) &dGeomCapsulePointDepth},
1340 //      {"dCreateCylinder",                                                             (void **) &dCreateCylinder},
1341 //      {"dGeomCylinderSetParams",                                              (void **) &dGeomCylinderSetParams},
1342 //      {"dGeomCylinderGetParams",                                              (void **) &dGeomCylinderGetParams},
1343 //      {"dCreateRay",                                                                  (void **) &dCreateRay},
1344 //      {"dGeomRaySetLength",                                                   (void **) &dGeomRaySetLength},
1345 //      {"dGeomRayGetLength",                                                   (void **) &dGeomRayGetLength},
1346 //      {"dGeomRaySet",                                                                 (void **) &dGeomRaySet},
1347 //      {"dGeomRayGet",                                                                 (void **) &dGeomRayGet},
1348         {"dCreateGeomTransform",                                                (void **) &dCreateGeomTransform},
1349         {"dGeomTransformSetGeom",                                               (void **) &dGeomTransformSetGeom},
1350 //      {"dGeomTransformGetGeom",                                               (void **) &dGeomTransformGetGeom},
1351         {"dGeomTransformSetCleanup",                                    (void **) &dGeomTransformSetCleanup},
1352 //      {"dGeomTransformGetCleanup",                                    (void **) &dGeomTransformGetCleanup},
1353 //      {"dGeomTransformSetInfo",                                               (void **) &dGeomTransformSetInfo},
1354 //      {"dGeomTransformGetInfo",                                               (void **) &dGeomTransformGetInfo},
1355         {"dGeomTriMeshDataCreate",                      (void **) &dGeomTriMeshDataCreate},
1356         {"dGeomTriMeshDataDestroy",                     (void **) &dGeomTriMeshDataDestroy},
1357 //      {"dGeomTriMeshDataSet",                         (void **) &dGeomTriMeshDataSet},
1358 //      {"dGeomTriMeshDataGet",                         (void **) &dGeomTriMeshDataGet},
1359 //      {"dGeomTriMeshSetLastTransform",                (void **) &dGeomTriMeshSetLastTransform},
1360 //      {"dGeomTriMeshGetLastTransform",                (void **) &dGeomTriMeshGetLastTransform},
1361         {"dGeomTriMeshDataBuildSingle",                 (void **) &dGeomTriMeshDataBuildSingle},
1362 //      {"dGeomTriMeshDataBuildSingle1",                (void **) &dGeomTriMeshDataBuildSingle1},
1363 //      {"dGeomTriMeshDataBuildDouble",                 (void **) &dGeomTriMeshDataBuildDouble},
1364 //      {"dGeomTriMeshDataBuildDouble1",                (void **) &dGeomTriMeshDataBuildDouble1},
1365 //      {"dGeomTriMeshDataBuildSimple",                 (void **) &dGeomTriMeshDataBuildSimple},
1366 //      {"dGeomTriMeshDataBuildSimple1",                (void **) &dGeomTriMeshDataBuildSimple1},
1367 //      {"dGeomTriMeshDataPreprocess",                  (void **) &dGeomTriMeshDataPreprocess},
1368 //      {"dGeomTriMeshDataGetBuffer",                   (void **) &dGeomTriMeshDataGetBuffer},
1369 //      {"dGeomTriMeshDataSetBuffer",                   (void **) &dGeomTriMeshDataSetBuffer},
1370 //      {"dGeomTriMeshSetCallback",                     (void **) &dGeomTriMeshSetCallback},
1371 //      {"dGeomTriMeshGetCallback",                     (void **) &dGeomTriMeshGetCallback},
1372 //      {"dGeomTriMeshSetArrayCallback",                (void **) &dGeomTriMeshSetArrayCallback},
1373 //      {"dGeomTriMeshGetArrayCallback",                (void **) &dGeomTriMeshGetArrayCallback},
1374 //      {"dGeomTriMeshSetRayCallback",                  (void **) &dGeomTriMeshSetRayCallback},
1375 //      {"dGeomTriMeshGetRayCallback",                  (void **) &dGeomTriMeshGetRayCallback},
1376 //      {"dGeomTriMeshSetTriMergeCallback",             (void **) &dGeomTriMeshSetTriMergeCallback},
1377 //      {"dGeomTriMeshGetTriMergeCallback",             (void **) &dGeomTriMeshGetTriMergeCallback},
1378         {"dCreateTriMesh",                              (void **) &dCreateTriMesh},
1379 //      {"dGeomTriMeshSetData",                         (void **) &dGeomTriMeshSetData},
1380 //      {"dGeomTriMeshGetData",                         (void **) &dGeomTriMeshGetData},
1381 //      {"dGeomTriMeshEnableTC",                        (void **) &dGeomTriMeshEnableTC},
1382 //      {"dGeomTriMeshIsTCEnabled",                     (void **) &dGeomTriMeshIsTCEnabled},
1383 //      {"dGeomTriMeshClearTCCache",                    (void **) &dGeomTriMeshClearTCCache},
1384 //      {"dGeomTriMeshGetTriMeshDataID",                (void **) &dGeomTriMeshGetTriMeshDataID},
1385 //      {"dGeomTriMeshGetTriangle",                     (void **) &dGeomTriMeshGetTriangle},
1386 //      {"dGeomTriMeshGetPoint",                        (void **) &dGeomTriMeshGetPoint},
1387 //      {"dGeomTriMeshGetTriangleCount",                (void **) &dGeomTriMeshGetTriangleCount},
1388 //      {"dGeomTriMeshDataUpdate",                      (void **) &dGeomTriMeshDataUpdate},
1389         {NULL, NULL}
1390 };
1391
1392 // Handle for ODE DLL
1393 dllhandle_t ode_dll = NULL;
1394 #endif
1395 #endif
1396
1397 static void World_Physics_Init(void)
1398 {
1399 #ifdef USEODE
1400 #ifdef ODE_DYNAMIC
1401         const char* dllnames [] =
1402         {
1403 # if defined(WIN64)
1404                 "libode1_64.dll",
1405 # elif defined(WIN32)
1406                 "libode1.dll",
1407 # elif defined(MACOSX)
1408                 "libode.1.dylib",
1409 # else
1410                 "libode.so.1",
1411 # endif
1412                 NULL
1413         };
1414 #endif
1415
1416         Cvar_RegisterVariable(&physics_ode_quadtree_depth);
1417         Cvar_RegisterVariable(&physics_ode_contactsurfacelayer);
1418         Cvar_RegisterVariable(&physics_ode_worldquickstep);
1419         Cvar_RegisterVariable(&physics_ode_worldquickstep_iterations);
1420         Cvar_RegisterVariable(&physics_ode_worldstepfast);
1421         Cvar_RegisterVariable(&physics_ode_worldstepfast_iterations);
1422         Cvar_RegisterVariable(&physics_ode_contact_mu);
1423         Cvar_RegisterVariable(&physics_ode_contact_erp);
1424         Cvar_RegisterVariable(&physics_ode_contact_cfm);
1425         Cvar_RegisterVariable(&physics_ode_iterationsperframe);
1426         Cvar_RegisterVariable(&physics_ode_movelimit);
1427         Cvar_RegisterVariable(&physics_ode_spinlimit);
1428
1429 #ifdef ODE_DYNAMIC
1430         // Load the DLL
1431         if (Sys_LoadLibrary (dllnames, &ode_dll, odefuncs))
1432 #endif
1433         {
1434                 dInitODE();
1435 //              dInitODE2(0);
1436 #ifdef ODE_DNYAMIC
1437 # ifdef dSINGLE
1438                 if (!dCheckConfiguration("ODE_single_precision"))
1439 # else
1440                 if (!dCheckConfiguration("ODE_double_precision"))
1441 # endif
1442                 {
1443 # ifdef dSINGLE
1444                         Con_Printf("ode library not compiled for single precision - incompatible!  Not using ODE physics.\n");
1445 # else
1446                         Con_Printf("ode library not compiled for double precision - incompatible!  Not using ODE physics.\n");
1447 # endif
1448                         Sys_UnloadLibrary(&ode_dll);
1449                         ode_dll = NULL;
1450                 }
1451 #endif
1452         }
1453 #endif
1454 }
1455
1456 static void World_Physics_Shutdown(void)
1457 {
1458 #ifdef USEODE
1459 #ifdef ODE_DYNAMIC
1460         if (ode_dll)
1461 #endif
1462         {
1463                 dCloseODE();
1464 #ifdef ODE_DYNAMIC
1465                 Sys_UnloadLibrary(&ode_dll);
1466                 ode_dll = NULL;
1467 #endif
1468         }
1469 #endif
1470 }
1471
1472 #ifdef USEODE
1473 static void World_Physics_EnableODE(world_t *world)
1474 {
1475         dVector3 center, extents;
1476         if (world->physics.ode)
1477                 return;
1478 #ifdef ODE_DYNAMIC
1479         if (!ode_dll)
1480                 return;
1481 #endif
1482         world->physics.ode = true;
1483         VectorMAM(0.5f, world->mins, 0.5f, world->maxs, center);
1484         VectorSubtract(world->maxs, center, extents);
1485         world->physics.ode_world = dWorldCreate();
1486         world->physics.ode_space = dQuadTreeSpaceCreate(NULL, center, extents, bound(1, physics_ode_quadtree_depth.integer, 10));
1487         world->physics.ode_contactgroup = dJointGroupCreate(0);
1488         // we don't currently set dWorldSetCFM or dWorldSetERP because the defaults seem fine
1489 }
1490 #endif
1491
1492 static void World_Physics_Start(world_t *world)
1493 {
1494 #ifdef USEODE
1495         if (world->physics.ode)
1496                 return;
1497         World_Physics_EnableODE(world);
1498 #endif
1499 }
1500
1501 static void World_Physics_End(world_t *world)
1502 {
1503 #ifdef USEODE
1504         if (world->physics.ode)
1505         {
1506                 dWorldDestroy(world->physics.ode_world);
1507                 dSpaceDestroy(world->physics.ode_space);
1508                 dJointGroupDestroy(world->physics.ode_contactgroup);
1509                 world->physics.ode = false;
1510         }
1511 #endif
1512 }
1513
1514 void World_Physics_RemoveFromEntity(world_t *world, prvm_edict_t *ed)
1515 {
1516         // entity is not physics controlled, free any physics data
1517         ed->priv.server->ode_physics = false;
1518 #ifdef USEODE
1519         if (ed->priv.server->ode_geom)
1520                 dGeomDestroy((dGeomID)ed->priv.server->ode_geom);
1521         ed->priv.server->ode_geom = NULL;
1522         if (ed->priv.server->ode_body)
1523                 dBodyDestroy((dBodyID)ed->priv.server->ode_body);
1524         ed->priv.server->ode_body = NULL;
1525 #endif
1526         if (ed->priv.server->ode_vertex3f)
1527                 Mem_Free(ed->priv.server->ode_vertex3f);
1528         ed->priv.server->ode_vertex3f = NULL;
1529         ed->priv.server->ode_numvertices = 0;
1530         if (ed->priv.server->ode_element3i)
1531                 Mem_Free(ed->priv.server->ode_element3i);
1532         ed->priv.server->ode_element3i = NULL;
1533         ed->priv.server->ode_numtriangles = 0;
1534 }
1535
1536 #ifdef USEODE
1537 static void World_Physics_Frame_BodyToEntity(world_t *world, prvm_edict_t *ed)
1538 {
1539         const dReal *avel;
1540         const dReal *o;
1541         const dReal *r; // for some reason dBodyGetRotation returns a [3][4] matrix
1542         const dReal *vel;
1543         dBodyID body = (dBodyID)ed->priv.server->ode_body;
1544         int movetype;
1545         matrix4x4_t bodymatrix;
1546         matrix4x4_t entitymatrix;
1547         prvm_eval_t *val;
1548         vec3_t angles;
1549         vec3_t avelocity;
1550         vec3_t forward, left, up;
1551         vec3_t origin;
1552         vec3_t spinvelocity;
1553         vec3_t velocity;
1554         if (!body)
1555                 return;
1556         val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.movetype);
1557         movetype = (int)val->_float;
1558         if (movetype != MOVETYPE_PHYSICS)
1559                 return;
1560         // store the physics engine data into the entity
1561         o = dBodyGetPosition(body);
1562         r = dBodyGetRotation(body);
1563         vel = dBodyGetLinearVel(body);
1564         avel = dBodyGetAngularVel(body);
1565         VectorCopy(o, origin);
1566         forward[0] = r[0];
1567         forward[1] = r[4];
1568         forward[2] = r[8];
1569         left[0] = r[1];
1570         left[1] = r[5];
1571         left[2] = r[9];
1572         up[0] = r[2];
1573         up[1] = r[6];
1574         up[2] = r[10];
1575         VectorCopy(vel, velocity);
1576         VectorCopy(avel, spinvelocity);
1577         Matrix4x4_FromVectors(&bodymatrix, forward, left, up, origin);
1578         Matrix4x4_Concat(&entitymatrix, &bodymatrix, &ed->priv.server->ode_offsetimatrix);
1579         Matrix4x4_ToVectors(&entitymatrix, forward, left, up, origin);
1580
1581         AnglesFromVectors(angles, forward, up, true);
1582         VectorSet(avelocity, RAD2DEG(spinvelocity[PITCH]), RAD2DEG(spinvelocity[YAW]), RAD2DEG(spinvelocity[ROLL]));
1583
1584         val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.origin);if (val) VectorCopy(origin, val->vector);
1585         val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.velocity);if (val) VectorCopy(velocity, val->vector);
1586         //val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.axis_forward);if (val) VectorCopy(forward, val->vector);
1587         //val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.axis_left);if (val) VectorCopy(left, val->vector);
1588         //val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.axis_up);if (val) VectorCopy(up, val->vector);
1589         //val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.spinvelocity);if (val) VectorCopy(spinvelocity, val->vector);
1590         val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.angles);if (val) VectorCopy(angles, val->vector);
1591         val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.avelocity);if (val) VectorCopy(avelocity, val->vector);
1592
1593         // values for BodyFromEntity to check if the qc modified anything later
1594         VectorCopy(origin, ed->priv.server->ode_origin);
1595         VectorCopy(velocity, ed->priv.server->ode_velocity);
1596         VectorCopy(angles, ed->priv.server->ode_angles);
1597         VectorCopy(avelocity, ed->priv.server->ode_avelocity);
1598 }
1599
1600 static void World_Physics_Frame_BodyFromEntity(world_t *world, prvm_edict_t *ed)
1601 {
1602         const float *iv;
1603         const int *ie;
1604         dBodyID body = (dBodyID)ed->priv.server->ode_body;
1605         dMass mass;
1606         dReal test;
1607         void *dataID;
1608         dVector3 capsulerot[3];
1609         dp_model_t *model;
1610         float *ov;
1611         int *oe;
1612         int axisindex;
1613         int modelindex = 0;
1614         int movetype = MOVETYPE_NONE;
1615         int numtriangles;
1616         int numvertices;
1617         int solid = SOLID_NOT;
1618         int triangleindex;
1619         int vertexindex;
1620         mempool_t *mempool;
1621         prvm_eval_t *val;
1622         qboolean modified = false;
1623         vec3_t angles;
1624         vec3_t avelocity;
1625         vec3_t entmaxs;
1626         vec3_t entmins;
1627         vec3_t forward;
1628         vec3_t geomcenter;
1629         vec3_t geomsize;
1630         vec3_t left;
1631         vec3_t origin;
1632         vec3_t spinvelocity;
1633         vec3_t up;
1634         vec3_t velocity;
1635         vec_t f;
1636         vec_t length;
1637         vec_t massval = 1.0f;
1638         vec_t movelimit;
1639         vec_t radius;
1640         vec_t scale = 1.0f;
1641         vec_t spinlimit;
1642 #ifdef ODE_DYNAMIC
1643         if (!ode_dll)
1644                 return;
1645 #endif
1646         val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.solid);if (val) solid = (int)val->_float;
1647         val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.movetype);if (val) movetype = (int)val->_float;
1648         val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.movetype);if (val && val->_float) scale = val->_float;
1649         modelindex = 0;
1650         switch(solid)
1651         {
1652         case SOLID_BSP:
1653                 val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.modelindex);
1654                 if (val)
1655                         modelindex = (int)val->_float;
1656                 if (world == &sv.world && modelindex >= 1 && modelindex < MAX_MODELS)
1657                 {
1658                         model = sv.models[modelindex];
1659                         mempool = sv_mempool;
1660                 }
1661                 else if (world == &cl.world && modelindex >= 1 && modelindex < MAX_MODELS)
1662                 {
1663                         model = cl.model_precache[modelindex];
1664                         mempool = cls.levelmempool;
1665                 }
1666                 else
1667                 {
1668                         model = NULL;
1669                         mempool = NULL;
1670                         modelindex = 0;
1671                 }
1672                 if (model)
1673                 {
1674                         VectorScale(model->normalmins, scale, entmins);
1675                         VectorScale(model->normalmaxs, scale, entmaxs);
1676                         val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.mass);if (val) massval = val->_float;
1677                 }
1678                 else
1679                 {
1680                         modelindex = 0;
1681                         massval = 1.0f;
1682                 }
1683                 break;
1684         case SOLID_BBOX:
1685         //case SOLID_SLIDEBOX:
1686         case SOLID_CORPSE:
1687         case SOLID_PHYSICS_BOX:
1688         case SOLID_PHYSICS_SPHERE:
1689         case SOLID_PHYSICS_CAPSULE:
1690                 val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.mins);if (val) VectorCopy(val->vector, entmins);
1691                 val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.maxs);if (val) VectorCopy(val->vector, entmaxs);
1692                 val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.mass);if (val) massval = val->_float;
1693                 break;
1694         default:
1695                 if (ed->priv.server->ode_physics)
1696                         World_Physics_RemoveFromEntity(world, ed);
1697                 return;
1698         }
1699
1700         VectorSubtract(entmaxs, entmins, geomsize);
1701         if (VectorLength2(geomsize) == 0)
1702         {
1703                 // we don't allow point-size physics objects...
1704                 if (ed->priv.server->ode_physics)
1705                         World_Physics_RemoveFromEntity(world, ed);
1706                 return;
1707         }
1708
1709         if (movetype != MOVETYPE_PHYSICS)
1710                 massval = 1.0f;
1711
1712         // check if we need to create or replace the geom
1713         if (!ed->priv.server->ode_physics
1714          || !VectorCompare(ed->priv.server->ode_mins, entmins)
1715          || !VectorCompare(ed->priv.server->ode_maxs, entmaxs)
1716          || ed->priv.server->ode_mass != massval
1717          || ed->priv.server->ode_modelindex != modelindex)
1718         {
1719                 modified = true;
1720                 World_Physics_RemoveFromEntity(world, ed);
1721                 ed->priv.server->ode_physics = true;
1722                 VectorCopy(entmins, ed->priv.server->ode_mins);
1723                 VectorCopy(entmaxs, ed->priv.server->ode_maxs);
1724                 ed->priv.server->ode_mass = massval;
1725                 ed->priv.server->ode_modelindex = modelindex;
1726                 VectorMAM(0.5f, entmins, 0.5f, entmaxs, geomcenter);
1727                 ed->priv.server->ode_movelimit = min(geomsize[0], min(geomsize[1], geomsize[2]));
1728
1729                 if (massval * geomsize[0] * geomsize[1] * geomsize[2] == 0)
1730                 {
1731                         if (movetype == MOVETYPE_PHYSICS)
1732                                 Con_Printf("entity %i (classname %s) .mass * .size_x * .size_y * .size_z == 0\n", PRVM_NUM_FOR_EDICT(ed), PRVM_GetString(PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.classname)->string));
1733                         massval = 1.0f;
1734                         VectorSet(geomsize, 1.0f, 1.0f, 1.0f);
1735                 }
1736
1737                 switch(solid)
1738                 {
1739                 case SOLID_BSP:
1740                         ed->priv.server->ode_offsetmatrix = identitymatrix;
1741                         if (!model)
1742                         {
1743                                 Con_Printf("entity %i (classname %s) has no model\n", PRVM_NUM_FOR_EDICT(ed), PRVM_GetString(PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.classname)->string));
1744                                 break;
1745                         }
1746                         // add an optimized mesh to the model containing only the SUPERCONTENTS_SOLID surfaces
1747                         if (!model->brush.collisionmesh)
1748                                 Mod_CreateCollisionMesh(model);
1749                         if (!model->brush.collisionmesh || !model->brush.collisionmesh->numtriangles)
1750                         {
1751                                 Con_Printf("entity %i (classname %s) has no geometry\n", PRVM_NUM_FOR_EDICT(ed), PRVM_GetString(PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.classname)->string));
1752                                 break;
1753                         }
1754                         // ODE requires persistent mesh storage, so we need to copy out
1755                         // the data from the model because renderer restarts could free it
1756                         // during the game, additionally we need to flip the triangles...
1757                         // note: ODE does preprocessing of the mesh for culling, removing
1758                         // concave edges, etc., so this is not a lightweight operation
1759                         ed->priv.server->ode_numvertices = numvertices = model->brush.collisionmesh->numverts;
1760                         ed->priv.server->ode_vertex3f = (float *)Mem_Alloc(mempool, numvertices * sizeof(float[3]));
1761                         for (vertexindex = 0, ov = ed->priv.server->ode_vertex3f, iv = model->brush.collisionmesh->vertex3f;vertexindex < numvertices;vertexindex++, ov += 3, iv += 3)
1762                         {
1763                                 ov[0] = iv[0] - geomcenter[0];
1764                                 ov[1] = iv[1] - geomcenter[1];
1765                                 ov[2] = iv[2] - geomcenter[2];
1766                         }
1767                         ed->priv.server->ode_numtriangles = numtriangles = model->brush.collisionmesh->numtriangles;
1768                         ed->priv.server->ode_element3i = (int *)Mem_Alloc(mempool, numtriangles * sizeof(int[3]));
1769                         //memcpy(ed->priv.server->ode_element3i, model->brush.collisionmesh->element3i, ed->priv.server->ode_numtriangles * sizeof(int[3]));
1770                         for (triangleindex = 0, oe = ed->priv.server->ode_element3i, ie = model->brush.collisionmesh->element3i;triangleindex < numtriangles;triangleindex++, oe += 3, ie += 3)
1771                         {
1772                                 oe[0] = ie[2];
1773                                 oe[1] = ie[1];
1774                                 oe[2] = ie[0];
1775                         }
1776                         Matrix4x4_CreateTranslate(&ed->priv.server->ode_offsetmatrix, geomcenter[0], geomcenter[1], geomcenter[2]);
1777                         // now create the geom
1778                         dataID = dGeomTriMeshDataCreate();
1779                         dGeomTriMeshDataBuildSingle(dataID, (void*)ed->priv.server->ode_vertex3f, sizeof(float[3]), ed->priv.server->ode_numvertices, ed->priv.server->ode_element3i, ed->priv.server->ode_numtriangles*3, sizeof(int[3]));
1780                         ed->priv.server->ode_body = (void *)(body = dBodyCreate(world->physics.ode_world));
1781                         ed->priv.server->ode_geom = (void *)dCreateTriMesh(world->physics.ode_space, dataID, NULL, NULL, NULL);
1782                         dGeomSetBody(ed->priv.server->ode_geom, body);
1783                         dMassSetBoxTotal(&mass, massval, geomsize[0], geomsize[1], geomsize[2]);
1784                         dBodySetMass(body, &mass);
1785                         dBodySetData(body, (void*)ed);
1786                         break;
1787                 case SOLID_BBOX:
1788                 case SOLID_SLIDEBOX:
1789                 case SOLID_CORPSE:
1790                 case SOLID_PHYSICS_BOX:
1791                         Matrix4x4_CreateTranslate(&ed->priv.server->ode_offsetmatrix, geomcenter[0], geomcenter[1], geomcenter[2]);
1792                         ed->priv.server->ode_body = (void *)(body = dBodyCreate(world->physics.ode_world));
1793                         ed->priv.server->ode_geom = (void *)dCreateBox(world->physics.ode_space, geomsize[0], geomsize[1], geomsize[2]);
1794                         dMassSetBoxTotal(&mass, massval, geomsize[0], geomsize[1], geomsize[2]);
1795                         dGeomSetBody(ed->priv.server->ode_geom, body);
1796                         dBodySetMass(body, &mass);
1797                         dBodySetData(body, (void*)ed);
1798                         break;
1799                 case SOLID_PHYSICS_SPHERE:
1800                         Matrix4x4_CreateTranslate(&ed->priv.server->ode_offsetmatrix, geomcenter[0], geomcenter[1], geomcenter[2]);
1801                         ed->priv.server->ode_body = (void *)(body = dBodyCreate(world->physics.ode_world));
1802                         ed->priv.server->ode_geom = (void *)dCreateSphere(world->physics.ode_space, geomsize[0] * 0.5f);
1803                         dMassSetSphereTotal(&mass, massval, geomsize[0] * 0.5f);
1804                         dGeomSetBody(ed->priv.server->ode_geom, body);
1805                         dBodySetMass(body, &mass);
1806                         dBodySetData(body, (void*)ed);
1807                         break;
1808                 case SOLID_PHYSICS_CAPSULE:
1809                         axisindex = 0;
1810                         if (geomsize[axisindex] < geomsize[1])
1811                                 axisindex = 1;
1812                         if (geomsize[axisindex] < geomsize[2])
1813                                 axisindex = 2;
1814                         // the qc gives us 3 axis radius, the longest axis is the capsule
1815                         // axis, since ODE doesn't like this idea we have to create a
1816                         // capsule which uses the standard orientation, and apply a
1817                         // transform to it
1818                         memset(capsulerot, 0, sizeof(capsulerot));
1819                         if (axisindex == 0)
1820                                 Matrix4x4_CreateFromQuakeEntity(&ed->priv.server->ode_offsetmatrix, geomcenter[0], geomcenter[1], geomcenter[2], 0, 0, 90, 1);
1821                         else if (axisindex == 1)
1822                                 Matrix4x4_CreateFromQuakeEntity(&ed->priv.server->ode_offsetmatrix, geomcenter[0], geomcenter[1], geomcenter[2], 90, 0, 0, 1);
1823                         else
1824                                 Matrix4x4_CreateFromQuakeEntity(&ed->priv.server->ode_offsetmatrix, geomcenter[0], geomcenter[1], geomcenter[2], 0, 0, 0, 1);
1825                         radius = geomsize[!axisindex] * 0.5f; // any other axis is the radius
1826                         length = geomsize[axisindex] - radius*2;
1827                         // because we want to support more than one axisindex, we have to
1828                         // create a transform, and turn on its cleanup setting (which will
1829                         // cause the child to be destroyed when it is destroyed)
1830                         ed->priv.server->ode_body = (void *)(body = dBodyCreate(world->physics.ode_world));
1831                         ed->priv.server->ode_geom = (void *)dCreateCapsule(world->physics.ode_space, radius, length);
1832                         dMassSetCapsuleTotal(&mass, massval, axisindex+1, radius, length);
1833                         dGeomSetBody(ed->priv.server->ode_geom, body);
1834                         dBodySetMass(body, &mass);
1835                         dBodySetData(body, (void*)ed);
1836                         break;
1837                 default:
1838                         Sys_Error("World_Physics_BodyFromEntity: unrecognized solid value %i was accepted by filter\n", solid);
1839                 }
1840                 Matrix4x4_Invert_Simple(&ed->priv.server->ode_offsetimatrix, &ed->priv.server->ode_offsetmatrix);
1841         }
1842
1843         // get current data from entity
1844         VectorClear(origin);
1845         VectorClear(velocity);
1846         //VectorClear(forward);
1847         //VectorClear(left);
1848         //VectorClear(up);
1849         //VectorClear(spinvelocity);
1850         VectorClear(angles);
1851         VectorClear(avelocity);
1852         val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.origin);if (val) VectorCopy(val->vector, origin);
1853         val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.velocity);if (val) VectorCopy(val->vector, velocity);
1854         //val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.axis_forward);if (val) VectorCopy(val->vector, forward);
1855         //val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.axis_left);if (val) VectorCopy(val->vector, left);
1856         //val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.axis_up);if (val) VectorCopy(val->vector, up);
1857         //val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.spinvelocity);if (val) VectorCopy(val->vector, spinvelocity);
1858         val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.angles);if (val) VectorCopy(val->vector, angles);
1859         val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.avelocity);if (val) VectorCopy(val->vector, avelocity);
1860
1861         // compatibility for legacy entities
1862         //if (!VectorLength2(forward) || solid == SOLID_BSP)
1863         {
1864                 AngleVectorsFLU(angles, forward, left, up);
1865                 // convert single-axis rotations in avelocity to spinvelocity
1866                 // FIXME: untested math - check signs
1867                 VectorSet(spinvelocity, DEG2RAD(avelocity[PITCH]), DEG2RAD(avelocity[ROLL]), DEG2RAD(avelocity[YAW]));
1868         }
1869
1870         // compatibility for legacy entities
1871         switch (solid)
1872         {
1873         case SOLID_BBOX:
1874         case SOLID_SLIDEBOX:
1875         case SOLID_CORPSE:
1876                 VectorSet(forward, 1, 0, 0);
1877                 VectorSet(left, 0, 1, 0);
1878                 VectorSet(up, 0, 0, 1);
1879                 VectorSet(spinvelocity, 0, 0, 0);
1880                 break;
1881         }
1882
1883
1884         // we must prevent NANs...
1885         test = VectorLength2(origin) + VectorLength2(forward) + VectorLength2(left) + VectorLength2(up) + VectorLength2(velocity) + VectorLength2(spinvelocity);
1886         if (IS_NAN(test))
1887         {
1888                 modified = true;
1889                 //Con_Printf("Fixing NAN values on entity %i : .classname = \"%s\" .origin = '%f %f %f' .velocity = '%f %f %f' .axis_forward = '%f %f %f' .axis_left = '%f %f %f' .axis_up = %f %f %f' .spinvelocity = '%f %f %f'\n", PRVM_NUM_FOR_EDICT(ed), PRVM_GetString(PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.classname)->string), origin[0], origin[1], origin[2], velocity[0], velocity[1], velocity[2], forward[0], forward[1], forward[2], left[0], left[1], left[2], up[0], up[1], up[2], spinvelocity[0], spinvelocity[1], spinvelocity[2]);
1890                 Con_Printf("Fixing NAN values on entity %i : .classname = \"%s\" .origin = '%f %f %f' .velocity = '%f %f %f' .angles = '%f %f %f' .avelocity = '%f %f %f'\n", PRVM_NUM_FOR_EDICT(ed), PRVM_GetString(PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.classname)->string), origin[0], origin[1], origin[2], velocity[0], velocity[1], velocity[2], angles[0], angles[1], angles[2], avelocity[0], avelocity[1], avelocity[2]);
1891                 test = VectorLength2(origin);
1892                 if (IS_NAN(test))
1893                         VectorClear(origin);
1894                 test = VectorLength2(forward) * VectorLength2(left) * VectorLength2(up);
1895                 if (IS_NAN(test))
1896                 {
1897                         VectorSet(angles, 0, 0, 0);
1898                         VectorSet(forward, 1, 0, 0);
1899                         VectorSet(left, 0, 1, 0);
1900                         VectorSet(up, 0, 0, 1);
1901                 }
1902                 test = VectorLength2(velocity);
1903                 if (IS_NAN(test))
1904                         VectorClear(velocity);
1905                 test = VectorLength2(spinvelocity);
1906                 if (IS_NAN(test))
1907                 {
1908                         VectorClear(avelocity);
1909                         VectorClear(spinvelocity);
1910                 }
1911         }
1912
1913         // limit movement speed to prevent missed collisions at high speed
1914         movelimit = ed->priv.server->ode_movelimit * world->physics.ode_movelimit;
1915         test = VectorLength2(velocity);
1916         if (test > movelimit*movelimit)
1917         {
1918                 modified = true;
1919                 // scale down linear velocity to the movelimit
1920                 // scale down angular velocity the same amount for consistency
1921                 f = movelimit / sqrt(test);
1922                 VectorScale(velocity, f, velocity);
1923                 VectorScale(avelocity, f, avelocity);
1924                 VectorScale(spinvelocity, f, spinvelocity);
1925         }
1926
1927         // make sure the angular velocity is not exploding
1928         spinlimit = physics_ode_spinlimit.value;
1929         test = VectorLength2(spinvelocity);
1930         if (test > spinlimit)
1931         {
1932                 modified = true;
1933                 VectorClear(avelocity);
1934                 VectorClear(spinvelocity);
1935         }
1936
1937         // check if the qc edited any position data
1938         if (!VectorCompare(origin, ed->priv.server->ode_origin)
1939          || !VectorCompare(velocity, ed->priv.server->ode_velocity)
1940          || !VectorCompare(angles, ed->priv.server->ode_angles)
1941          || !VectorCompare(avelocity, ed->priv.server->ode_avelocity))
1942                 modified = true;
1943
1944         // store the qc values into the physics engine
1945         body = ed->priv.server->ode_body;
1946         if (body && modified)
1947         {
1948                 dVector3 r[3];
1949                 matrix4x4_t entitymatrix;
1950                 matrix4x4_t bodymatrix;
1951                 Matrix4x4_FromVectors(&entitymatrix, forward, left, up, origin);
1952                 Matrix4x4_Concat(&bodymatrix, &entitymatrix, &ed->priv.server->ode_offsetmatrix);
1953                 Matrix4x4_ToVectors(&bodymatrix, forward, left, up, origin);
1954                 r[0][0] = forward[0];
1955                 r[1][0] = forward[1];
1956                 r[2][0] = forward[2];
1957                 r[0][1] = left[0];
1958                 r[1][1] = left[1];
1959                 r[2][1] = left[2];
1960                 r[0][2] = up[0];
1961                 r[1][2] = up[1];
1962                 r[2][2] = up[2];
1963                 dGeomSetBody(ed->priv.server->ode_geom, ed->priv.server->ode_body);
1964                 dBodySetPosition(body, origin[0], origin[1], origin[2]);
1965                 dBodySetRotation(body, r[0]);
1966                 dBodySetLinearVel(body, velocity[0], velocity[1], velocity[2]);
1967                 dBodySetAngularVel(body, spinvelocity[0], spinvelocity[1], spinvelocity[2]);
1968                 // setting body to NULL makes an immovable object
1969                 if (movetype != MOVETYPE_PHYSICS)
1970                         dGeomSetBody(ed->priv.server->ode_geom, 0);
1971         }
1972 }
1973
1974 #define MAX_CONTACTS 16
1975 static void nearCallback (void *data, dGeomID o1, dGeomID o2)
1976 {
1977         world_t *world = (world_t *)data;
1978         dContact contact[MAX_CONTACTS]; // max contacts per collision pair
1979         dBodyID b1;
1980         dBodyID b2;
1981         dJointID c;
1982         int i;
1983         int numcontacts;
1984
1985         if (dGeomIsSpace(o1) || dGeomIsSpace(o2))
1986         {
1987                 // colliding a space with something
1988                 dSpaceCollide2(o1, o2, data, &nearCallback);
1989                 // Note we do not want to test intersections within a space,
1990                 // only between spaces.
1991                 //if (dGeomIsSpace(o1)) dSpaceCollide(o1, data, &nearCallback);
1992                 //if (dGeomIsSpace(o2)) dSpaceCollide(o2, data, &nearCallback);
1993                 return;
1994         }
1995
1996         b1 = dGeomGetBody(o1);
1997         b2 = dGeomGetBody(o2);
1998
1999         // at least one object has to be using MOVETYPE_PHYSICS or we just don't care
2000         if (!b1 && !b2)
2001                 return;
2002
2003         // exit without doing anything if the two bodies are connected by a joint
2004         if (b1 && b2 && dAreConnectedExcluding(b1, b2, dJointTypeContact))
2005                 return;
2006
2007         // generate contact points between the two non-space geoms
2008         numcontacts = dCollide(o1, o2, MAX_CONTACTS, &(contact[0].geom), sizeof(contact[0]));
2009         // add these contact points to the simulation
2010         for (i = 0;i < numcontacts;i++)
2011         {
2012                 contact[i].surface.mode = (physics_ode_contact_mu.value != -1 ? dContactApprox1 : 0) | (physics_ode_contact_erp.value != -1 ? dContactSoftERP : 0) | (physics_ode_contact_cfm.value != -1 ? dContactSoftCFM : 0);
2013                 contact[i].surface.mu = physics_ode_contact_mu.value;
2014                 contact[i].surface.soft_erp = physics_ode_contact_erp.value;
2015                 contact[i].surface.soft_cfm = physics_ode_contact_cfm.value;
2016                 c = dJointCreateContact(world->physics.ode_world, world->physics.ode_contactgroup, contact + i);
2017                 dJointAttach(c, b1, b2);
2018         }
2019 }
2020 #endif
2021
2022 void World_Physics_Frame(world_t *world, double frametime, double gravity)
2023 {
2024 #ifdef USEODE
2025         if (world->physics.ode)
2026         {
2027                 int i;
2028                 prvm_edict_t *ed;
2029
2030                 // copy physics properties from entities to physics engine
2031                 if (prog)
2032                         for (i = 0, ed = prog->edicts + i;i < prog->num_edicts;i++, ed++)
2033                                 if (!prog->edicts[i].priv.required->free)
2034                                         World_Physics_Frame_BodyFromEntity(world, ed);
2035
2036                 world->physics.ode_iterations = bound(1, physics_ode_iterationsperframe.integer, 1000);
2037                 world->physics.ode_step = frametime / world->physics.ode_iterations;
2038                 world->physics.ode_movelimit = physics_ode_movelimit.value / world->physics.ode_step;
2039                 for (i = 0;i < world->physics.ode_iterations;i++)
2040                 {
2041                         // set the gravity
2042                         dWorldSetGravity(world->physics.ode_world, 0, 0, -gravity);
2043                         // set the tolerance for closeness of objects
2044                         dWorldSetContactSurfaceLayer(world->physics.ode_world, max(0, physics_ode_contactsurfacelayer.value));
2045
2046                         // run collisions for the current world state, creating JointGroup
2047                         dSpaceCollide(world->physics.ode_space, (void *)world, nearCallback);
2048
2049                         // run physics (move objects, calculate new velocities)
2050                         if (physics_ode_worldquickstep.integer)
2051                         {
2052                                 dWorldSetQuickStepNumIterations(world->physics.ode_world, bound(1, physics_ode_worldquickstep_iterations.integer, 200));
2053                                 dWorldQuickStep(world->physics.ode_world, world->physics.ode_step);
2054                         }
2055                         else if (physics_ode_worldstepfast.integer)
2056                                 dWorldStepFast1(world->physics.ode_world, world->physics.ode_step, bound(1, physics_ode_worldstepfast_iterations.integer, 200));
2057                         else
2058                                 dWorldStep(world->physics.ode_world, world->physics.ode_step);
2059
2060                         // clear the JointGroup now that we're done with it
2061                         dJointGroupEmpty(world->physics.ode_contactgroup);
2062                 }
2063
2064                 // copy physics properties from physics engine to entities
2065                 if (prog)
2066                         for (i = 1, ed = prog->edicts + i;i < prog->num_edicts;i++, ed++)
2067                                 if (!prog->edicts[i].priv.required->free && PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.movetype)->_float == MOVETYPE_PHYSICS)
2068                                         World_Physics_Frame_BodyToEntity(world, ed);
2069         }
2070 #endif
2071 }