2 Copyright (C) 1996-1997 Id Software, Inc.
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.
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.
13 See the GNU General Public License for more details.
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.
20 // world.c -- world query functions
26 entities never clip against themselves, or their owner
28 line of sight checks trace->inopen and trace->inwater, but bullets don't
32 static void World_Physics_Init(void);
39 static void World_Physics_Shutdown(void);
40 void World_Shutdown(void)
42 World_Physics_Shutdown();
45 static void World_Physics_Start(world_t *world);
46 void World_Start(world_t *world)
48 World_Physics_Start(world);
51 static void World_Physics_End(world_t *world);
52 void World_End(world_t *world)
54 World_Physics_End(world);
57 //============================================================================
59 /// World_ClearLink is used for new headnodes
60 void World_ClearLink (link_t *l)
63 l->prev = l->next = l;
66 void World_RemoveLink (link_t *l)
68 l->next->prev = l->prev;
69 l->prev->next = l->next;
72 void World_InsertLinkBefore (link_t *l, link_t *before, int entitynumber)
74 l->entitynumber = entitynumber;
76 l->prev = before->prev;
82 ===============================================================================
86 ===============================================================================
89 void World_PrintAreaStats(world_t *world, const char *worldname)
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;
103 void World_SetSize(world_t *world, const char *filename, const vec3_t mins, const vec3_t maxs)
107 strlcpy(world->filename, filename, sizeof(world->filename));
108 VectorCopy(mins, world->mins);
109 VectorCopy(maxs, world->maxs);
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);
143 void World_UnlinkAll(world_t *world)
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));
161 void World_UnlinkEdict(prvm_edict_t *ent)
164 for (i = 0;i < ENTITYGRIDAREAS;i++)
166 if (ent->priv.server->areagrid[i].prev)
168 World_RemoveLink (&ent->priv.server->areagrid[i]);
169 ent->priv.server->areagrid[i].prev = ent->priv.server->areagrid[i].next = NULL;
174 int World_EntitiesInBox(world_t *world, const vec3_t mins, const vec3_t maxs, int maxlist, prvm_edict_t **list)
180 int igrid[3], igridmins[3], igridmaxs[3];
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]);
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)
204 grid = &world->areagrid_outside;
205 for (l = grid->next;l != grid;l = l->next)
207 ent = PRVM_EDICT_NUM(l->entitynumber);
208 if (ent->priv.server->areagridmarknumber != world->areagrid_marknumber)
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))
213 if (numlist < maxlist)
217 world->areagrid_stats_entitychecks++;
221 // add grid linked entities
222 for (igrid[1] = igridmins[1];igrid[1] < igridmaxs[1];igrid[1]++)
224 grid = world->areagrid + igrid[1] * AREA_GRID + igridmins[0];
225 for (igrid[0] = igridmins[0];igrid[0] < igridmaxs[0];igrid[0]++, grid++)
227 if (grid->next != grid)
229 for (l = grid->next;l != grid;l = l->next)
231 ent = PRVM_EDICT_NUM(l->entitynumber);
232 if (ent->priv.server->areagridmarknumber != world->areagrid_marknumber)
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))
237 if (numlist < maxlist)
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]);
243 world->areagrid_stats_entitychecks++;
251 void World_LinkEdict_AreaGrid(world_t *world, prvm_edict_t *ent)
254 int igrid[3], igridmins[3], igridmaxs[3], gridnum, entitynumber = PRVM_NUM_FOR_EDICT(ent);
256 if (entitynumber <= 0 || entitynumber >= prog->max_edicts || PRVM_EDICT_NUM(entitynumber) != ent)
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);
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)
270 // wow, something outside the grid, store it as such
271 World_InsertLinkBefore (&ent->priv.server->areagrid[0], &world->areagrid_outside, entitynumber);
276 for (igrid[1] = igridmins[1];igrid[1] < igridmaxs[1];igrid[1]++)
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);
290 void World_LinkEdict(world_t *world, prvm_edict_t *ent, const vec3_t mins, const vec3_t maxs)
292 // unlink from old position first
293 if (ent->priv.server->areagrid[0].prev)
294 World_UnlinkEdict(ent);
296 // don't add the world
297 if (ent == prog->edicts)
300 // don't add free entities
301 if (ent->priv.server->free)
304 VectorCopy(mins, ent->priv.server->areamins);
305 VectorCopy(maxs, ent->priv.server->areamaxs);
306 World_LinkEdict_AreaGrid(world, ent);
312 //============================================================================
313 // physics engine support
314 //============================================================================
317 #define ODE_DYNAMIC 1
320 #if defined(ODE_STATIC) || defined(ODE_DYNAMIC)
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"};
338 // LordHavoc: this large chunk of definitions comes from the ODE library
345 // ODE does not use WINAPI
351 // note: dynamic builds of ODE tend to be double precision, this is not used
353 typedef double dReal;
355 typedef dReal dVector3[4];
356 typedef dReal dVector4[4];
357 typedef dReal dMatrix3[4*3];
358 typedef dReal dMatrix4[4*4];
359 typedef dReal dMatrix6[8*6];
360 typedef dReal dQuaternion[4];
362 struct dxWorld; /* dynamics world */
363 struct dxSpace; /* collision space */
364 struct dxBody; /* rigid body (dynamics object) */
365 struct dxGeom; /* geometry (collision object) */
369 struct dxTriMeshData;
371 typedef struct dxWorld *dWorldID;
372 typedef struct dxSpace *dSpaceID;
373 typedef struct dxBody *dBodyID;
374 typedef struct dxGeom *dGeomID;
375 typedef struct dxJoint *dJointID;
376 typedef struct dxJointGroup *dJointGroupID;
377 typedef struct dxTriMeshData *dTriMeshDataID;
379 typedef struct dJointFeedback
381 dVector3 f1; /* force applied to body 1 */
382 dVector3 t1; /* torque applied to body 1 */
383 dVector3 f2; /* force applied to body 2 */
384 dVector3 t2; /* torque applied to body 2 */
388 typedef enum dJointType
419 dContactFDir1 = 0x002,
420 dContactBounce = 0x004,
421 dContactSoftERP = 0x008,
422 dContactSoftCFM = 0x010,
423 dContactMotion1 = 0x020,
424 dContactMotion2 = 0x040,
425 dContactMotionN = 0x080,
426 dContactSlip1 = 0x100,
427 dContactSlip2 = 0x200,
429 dContactApprox0 = 0x0000,
430 dContactApprox1_1 = 0x1000,
431 dContactApprox1_2 = 0x2000,
432 dContactApprox1 = 0x3000
435 typedef struct dSurfaceParameters
437 /* must always be defined */
441 /* only defined if the corresponding flag is set in mode */
447 dReal motion1,motion2,motionN;
449 } dSurfaceParameters;
451 typedef struct dContactGeom
453 dVector3 pos; ///< contact position
454 dVector3 normal; ///< normal vector
455 dReal depth; ///< penetration depth
456 dGeomID g1,g2; ///< the colliding geoms
457 int side1,side2; ///< (to be documented)
461 typedef struct dContact
463 dSurfaceParameters surface;
469 typedef void dNearCallback (void *data, dGeomID o1, dGeomID o2);
472 // Order XZY or ZXY usually works best, if your Y is up.
473 #define dSAP_AXES_XYZ ((0)|(1<<2)|(2<<4))
474 #define dSAP_AXES_XZY ((0)|(2<<2)|(1<<4))
475 #define dSAP_AXES_YXZ ((1)|(0<<2)|(2<<4))
476 #define dSAP_AXES_YZX ((1)|(2<<2)|(0<<4))
477 #define dSAP_AXES_ZXY ((2)|(0<<2)|(1<<4))
478 #define dSAP_AXES_ZYX ((2)|(1<<2)|(0<<4))
480 //const char* (ODE_API *dGetConfiguration)(void);
481 //int (ODE_API *dCheckConfiguration)( const char* token );
482 int (ODE_API *dInitODE)(void);
483 //int (ODE_API *dInitODE2)(unsigned int uiInitFlags);
484 //int (ODE_API *dAllocateODEDataForThread)(unsigned int uiAllocateFlags);
485 //void (ODE_API *dCleanupODEAllDataForThread)(void);
486 void (ODE_API *dCloseODE)(void);
488 //int (ODE_API *dMassCheck)(const dMass *m);
489 //void (ODE_API *dMassSetZero)(dMass *);
490 //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);
491 //void (ODE_API *dMassSetSphere)(dMass *, dReal density, dReal radius);
492 void (ODE_API *dMassSetSphereTotal)(dMass *, dReal total_mass, dReal radius);
493 //void (ODE_API *dMassSetCapsule)(dMass *, dReal density, int direction, dReal radius, dReal length);
494 void (ODE_API *dMassSetCapsuleTotal)(dMass *, dReal total_mass, int direction, dReal radius, dReal length);
495 //void (ODE_API *dMassSetCylinder)(dMass *, dReal density, int direction, dReal radius, dReal length);
496 //void (ODE_API *dMassSetCylinderTotal)(dMass *, dReal total_mass, int direction, dReal radius, dReal length);
497 //void (ODE_API *dMassSetBox)(dMass *, dReal density, dReal lx, dReal ly, dReal lz);
498 void (ODE_API *dMassSetBoxTotal)(dMass *, dReal total_mass, dReal lx, dReal ly, dReal lz);
499 //void (ODE_API *dMassSetTrimesh)(dMass *, dReal density, dGeomID g);
500 //void (ODE_API *dMassSetTrimeshTotal)(dMass *m, dReal total_mass, dGeomID g);
501 //void (ODE_API *dMassAdjust)(dMass *, dReal newmass);
502 //void (ODE_API *dMassTranslate)(dMass *, dReal x, dReal y, dReal z);
503 //void (ODE_API *dMassRotate)(dMass *, const dMatrix3 R);
504 //void (ODE_API *dMassAdd)(dMass *a, const dMass *b);
506 dWorldID (ODE_API *dWorldCreate)(void);
507 void (ODE_API *dWorldDestroy)(dWorldID world);
508 void (ODE_API *dWorldSetGravity)(dWorldID, dReal x, dReal y, dReal z);
509 void (ODE_API *dWorldGetGravity)(dWorldID, dVector3 gravity);
510 //void (ODE_API *dWorldSetERP)(dWorldID, dReal erp);
511 //dReal (ODE_API *dWorldGetERP)(dWorldID);
512 //void (ODE_API *dWorldSetCFM)(dWorldID, dReal cfm);
513 //dReal (ODE_API *dWorldGetCFM)(dWorldID);
514 void (ODE_API *dWorldStep)(dWorldID, dReal stepsize);
515 //void (ODE_API *dWorldImpulseToForce)(dWorldID, dReal stepsize, dReal ix, dReal iy, dReal iz, dVector3 force);
516 void (ODE_API *dWorldQuickStep)(dWorldID w, dReal stepsize);
517 void (ODE_API *dWorldSetQuickStepNumIterations)(dWorldID, int num);
518 //int (ODE_API *dWorldGetQuickStepNumIterations)(dWorldID);
519 //void (ODE_API *dWorldSetQuickStepW)(dWorldID, dReal over_relaxation);
520 //dReal (ODE_API *dWorldGetQuickStepW)(dWorldID);
521 //void (ODE_API *dWorldSetContactMaxCorrectingVel)(dWorldID, dReal vel);
522 //dReal (ODE_API *dWorldGetContactMaxCorrectingVel)(dWorldID);
523 void (ODE_API *dWorldSetContactSurfaceLayer)(dWorldID, dReal depth);
524 //dReal (ODE_API *dWorldGetContactSurfaceLayer)(dWorldID);
525 void (ODE_API *dWorldStepFast1)(dWorldID, dReal stepsize, int maxiterations);
526 //void (ODE_API *dWorldSetAutoEnableDepthSF1)(dWorldID, int autoEnableDepth);
527 //int (ODE_API *dWorldGetAutoEnableDepthSF1)(dWorldID);
528 //dReal (ODE_API *dWorldGetAutoDisableLinearThreshold)(dWorldID);
529 //void (ODE_API *dWorldSetAutoDisableLinearThreshold)(dWorldID, dReal linear_threshold);
530 //dReal (ODE_API *dWorldGetAutoDisableAngularThreshold)(dWorldID);
531 //void (ODE_API *dWorldSetAutoDisableAngularThreshold)(dWorldID, dReal angular_threshold);
532 //dReal (ODE_API *dWorldGetAutoDisableLinearAverageThreshold)(dWorldID);
533 //void (ODE_API *dWorldSetAutoDisableLinearAverageThreshold)(dWorldID, dReal linear_average_threshold);
534 //dReal (ODE_API *dWorldGetAutoDisableAngularAverageThreshold)(dWorldID);
535 //void (ODE_API *dWorldSetAutoDisableAngularAverageThreshold)(dWorldID, dReal angular_average_threshold);
536 //int (ODE_API *dWorldGetAutoDisableAverageSamplesCount)(dWorldID);
537 //void (ODE_API *dWorldSetAutoDisableAverageSamplesCount)(dWorldID, unsigned int average_samples_count );
538 //int (ODE_API *dWorldGetAutoDisableSteps)(dWorldID);
539 //void (ODE_API *dWorldSetAutoDisableSteps)(dWorldID, int steps);
540 //dReal (ODE_API *dWorldGetAutoDisableTime)(dWorldID);
541 //void (ODE_API *dWorldSetAutoDisableTime)(dWorldID, dReal time);
542 //int (ODE_API *dWorldGetAutoDisableFlag)(dWorldID);
543 //void (ODE_API *dWorldSetAutoDisableFlag)(dWorldID, int do_auto_disable);
544 //dReal (ODE_API *dWorldGetLinearDampingThreshold)(dWorldID w);
545 //void (ODE_API *dWorldSetLinearDampingThreshold)(dWorldID w, dReal threshold);
546 //dReal (ODE_API *dWorldGetAngularDampingThreshold)(dWorldID w);
547 //void (ODE_API *dWorldSetAngularDampingThreshold)(dWorldID w, dReal threshold);
548 //dReal (ODE_API *dWorldGetLinearDamping)(dWorldID w);
549 //void (ODE_API *dWorldSetLinearDamping)(dWorldID w, dReal scale);
550 //dReal (ODE_API *dWorldGetAngularDamping)(dWorldID w);
551 //void (ODE_API *dWorldSetAngularDamping)(dWorldID w, dReal scale);
552 //void (ODE_API *dWorldSetDamping)(dWorldID w, dReal linear_scale, dReal angular_scale);
553 //dReal (ODE_API *dWorldGetMaxAngularSpeed)(dWorldID w);
554 //void (ODE_API *dWorldSetMaxAngularSpeed)(dWorldID w, dReal max_speed);
555 //dReal (ODE_API *dBodyGetAutoDisableLinearThreshold)(dBodyID);
556 //void (ODE_API *dBodySetAutoDisableLinearThreshold)(dBodyID, dReal linear_average_threshold);
557 //dReal (ODE_API *dBodyGetAutoDisableAngularThreshold)(dBodyID);
558 //void (ODE_API *dBodySetAutoDisableAngularThreshold)(dBodyID, dReal angular_average_threshold);
559 //int (ODE_API *dBodyGetAutoDisableAverageSamplesCount)(dBodyID);
560 //void (ODE_API *dBodySetAutoDisableAverageSamplesCount)(dBodyID, unsigned int average_samples_count);
561 //int (ODE_API *dBodyGetAutoDisableSteps)(dBodyID);
562 //void (ODE_API *dBodySetAutoDisableSteps)(dBodyID, int steps);
563 //dReal (ODE_API *dBodyGetAutoDisableTime)(dBodyID);
564 //void (ODE_API *dBodySetAutoDisableTime)(dBodyID, dReal time);
565 //int (ODE_API *dBodyGetAutoDisableFlag)(dBodyID);
566 //void (ODE_API *dBodySetAutoDisableFlag)(dBodyID, int do_auto_disable);
567 //void (ODE_API *dBodySetAutoDisableDefaults)(dBodyID);
568 //dWorldID (ODE_API *dBodyGetWorld)(dBodyID);
569 dBodyID (ODE_API *dBodyCreate)(dWorldID);
570 void (ODE_API *dBodyDestroy)(dBodyID);
571 void (ODE_API *dBodySetData)(dBodyID, void *data);
572 void * (ODE_API *dBodyGetData)(dBodyID);
573 void (ODE_API *dBodySetPosition)(dBodyID, dReal x, dReal y, dReal z);
574 void (ODE_API *dBodySetRotation)(dBodyID, const dMatrix3 R);
575 //void (ODE_API *dBodySetQuaternion)(dBodyID, const dQuaternion q);
576 void (ODE_API *dBodySetLinearVel)(dBodyID, dReal x, dReal y, dReal z);
577 void (ODE_API *dBodySetAngularVel)(dBodyID, dReal x, dReal y, dReal z);
578 const dReal * (ODE_API *dBodyGetPosition)(dBodyID);
579 //void (ODE_API *dBodyCopyPosition)(dBodyID body, dVector3 pos);
580 const dReal * (ODE_API *dBodyGetRotation)(dBodyID);
581 //void (ODE_API *dBodyCopyRotation)(dBodyID, dMatrix3 R);
582 //const dReal * (ODE_API *dBodyGetQuaternion)(dBodyID);
583 //void (ODE_API *dBodyCopyQuaternion)(dBodyID body, dQuaternion quat);
584 const dReal * (ODE_API *dBodyGetLinearVel)(dBodyID);
585 const dReal * (ODE_API *dBodyGetAngularVel)(dBodyID);
586 void (ODE_API *dBodySetMass)(dBodyID, const dMass *mass);
587 //void (ODE_API *dBodyGetMass)(dBodyID, dMass *mass);
588 //void (ODE_API *dBodyAddForce)(dBodyID, dReal fx, dReal fy, dReal fz);
589 //void (ODE_API *dBodyAddTorque)(dBodyID, dReal fx, dReal fy, dReal fz);
590 //void (ODE_API *dBodyAddRelForce)(dBodyID, dReal fx, dReal fy, dReal fz);
591 //void (ODE_API *dBodyAddRelTorque)(dBodyID, dReal fx, dReal fy, dReal fz);
592 //void (ODE_API *dBodyAddForceAtPos)(dBodyID, dReal fx, dReal fy, dReal fz, dReal px, dReal py, dReal pz);
593 //void (ODE_API *dBodyAddForceAtRelPos)(dBodyID, dReal fx, dReal fy, dReal fz, dReal px, dReal py, dReal pz);
594 //void (ODE_API *dBodyAddRelForceAtPos)(dBodyID, dReal fx, dReal fy, dReal fz, dReal px, dReal py, dReal pz);
595 //void (ODE_API *dBodyAddRelForceAtRelPos)(dBodyID, dReal fx, dReal fy, dReal fz, dReal px, dReal py, dReal pz);
596 //const dReal * (ODE_API *dBodyGetForce)(dBodyID);
597 //const dReal * (ODE_API *dBodyGetTorque)(dBodyID);
598 //void (ODE_API *dBodySetForce)(dBodyID b, dReal x, dReal y, dReal z);
599 //void (ODE_API *dBodySetTorque)(dBodyID b, dReal x, dReal y, dReal z);
600 //void (ODE_API *dBodyGetRelPointPos)(dBodyID, dReal px, dReal py, dReal pz, dVector3 result);
601 //void (ODE_API *dBodyGetRelPointVel)(dBodyID, dReal px, dReal py, dReal pz, dVector3 result);
602 //void (ODE_API *dBodyGetPointVel)(dBodyID, dReal px, dReal py, dReal pz, dVector3 result);
603 //void (ODE_API *dBodyGetPosRelPoint)(dBodyID, dReal px, dReal py, dReal pz, dVector3 result);
604 //void (ODE_API *dBodyVectorToWorld)(dBodyID, dReal px, dReal py, dReal pz, dVector3 result);
605 //void (ODE_API *dBodyVectorFromWorld)(dBodyID, dReal px, dReal py, dReal pz, dVector3 result);
606 //void (ODE_API *dBodySetFiniteRotationMode)(dBodyID, int mode);
607 //void (ODE_API *dBodySetFiniteRotationAxis)(dBodyID, dReal x, dReal y, dReal z);
608 //int (ODE_API *dBodyGetFiniteRotationMode)(dBodyID);
609 //void (ODE_API *dBodyGetFiniteRotationAxis)(dBodyID, dVector3 result);
610 //int (ODE_API *dBodyGetNumJoints)(dBodyID b);
611 //dJointID (ODE_API *dBodyGetJoint)(dBodyID, int index);
612 //void (ODE_API *dBodySetDynamic)(dBodyID);
613 //void (ODE_API *dBodySetKinematic)(dBodyID);
614 //int (ODE_API *dBodyIsKinematic)(dBodyID);
615 //void (ODE_API *dBodyEnable)(dBodyID);
616 //void (ODE_API *dBodyDisable)(dBodyID);
617 //int (ODE_API *dBodyIsEnabled)(dBodyID);
618 void (ODE_API *dBodySetGravityMode)(dBodyID b, int mode);
619 int (ODE_API *dBodyGetGravityMode)(dBodyID b);
620 //void (*dBodySetMovedCallback)(dBodyID b, void(ODE_API *callback)(dBodyID));
621 //dGeomID (ODE_API *dBodyGetFirstGeom)(dBodyID b);
622 //dGeomID (ODE_API *dBodyGetNextGeom)(dGeomID g);
623 //void (ODE_API *dBodySetDampingDefaults)(dBodyID b);
624 //dReal (ODE_API *dBodyGetLinearDamping)(dBodyID b);
625 //void (ODE_API *dBodySetLinearDamping)(dBodyID b, dReal scale);
626 //dReal (ODE_API *dBodyGetAngularDamping)(dBodyID b);
627 //void (ODE_API *dBodySetAngularDamping)(dBodyID b, dReal scale);
628 //void (ODE_API *dBodySetDamping)(dBodyID b, dReal linear_scale, dReal angular_scale);
629 //dReal (ODE_API *dBodyGetLinearDampingThreshold)(dBodyID b);
630 //void (ODE_API *dBodySetLinearDampingThreshold)(dBodyID b, dReal threshold);
631 //dReal (ODE_API *dBodyGetAngularDampingThreshold)(dBodyID b);
632 //void (ODE_API *dBodySetAngularDampingThreshold)(dBodyID b, dReal threshold);
633 //dReal (ODE_API *dBodyGetMaxAngularSpeed)(dBodyID b);
634 //void (ODE_API *dBodySetMaxAngularSpeed)(dBodyID b, dReal max_speed);
635 //int (ODE_API *dBodyGetGyroscopicMode)(dBodyID b);
636 //void (ODE_API *dBodySetGyroscopicMode)(dBodyID b, int enabled);
637 //dJointID (ODE_API *dJointCreateBall)(dWorldID, dJointGroupID);
638 //dJointID (ODE_API *dJointCreateHinge)(dWorldID, dJointGroupID);
639 //dJointID (ODE_API *dJointCreateSlider)(dWorldID, dJointGroupID);
640 dJointID (ODE_API *dJointCreateContact)(dWorldID, dJointGroupID, const dContact *);
641 //dJointID (ODE_API *dJointCreateHinge2)(dWorldID, dJointGroupID);
642 //dJointID (ODE_API *dJointCreateUniversal)(dWorldID, dJointGroupID);
643 //dJointID (ODE_API *dJointCreatePR)(dWorldID, dJointGroupID);
644 //dJointID (ODE_API *dJointCreatePU)(dWorldID, dJointGroupID);
645 //dJointID (ODE_API *dJointCreatePiston)(dWorldID, dJointGroupID);
646 //dJointID (ODE_API *dJointCreateFixed)(dWorldID, dJointGroupID);
647 //dJointID (ODE_API *dJointCreateNull)(dWorldID, dJointGroupID);
648 //dJointID (ODE_API *dJointCreateAMotor)(dWorldID, dJointGroupID);
649 //dJointID (ODE_API *dJointCreateLMotor)(dWorldID, dJointGroupID);
650 //dJointID (ODE_API *dJointCreatePlane2D)(dWorldID, dJointGroupID);
651 //void (ODE_API *dJointDestroy)(dJointID);
652 dJointGroupID (ODE_API *dJointGroupCreate)(int max_size);
653 void (ODE_API *dJointGroupDestroy)(dJointGroupID);
654 void (ODE_API *dJointGroupEmpty)(dJointGroupID);
655 //int (ODE_API *dJointGetNumBodies)(dJointID);
656 void (ODE_API *dJointAttach)(dJointID, dBodyID body1, dBodyID body2);
657 //void (ODE_API *dJointEnable)(dJointID);
658 //void (ODE_API *dJointDisable)(dJointID);
659 //int (ODE_API *dJointIsEnabled)(dJointID);
660 //void (ODE_API *dJointSetData)(dJointID, void *data);
661 //void * (ODE_API *dJointGetData)(dJointID);
662 //dJointType (ODE_API *dJointGetType)(dJointID);
663 //dBodyID (ODE_API *dJointGetBody)(dJointID, int index);
664 //void (ODE_API *dJointSetFeedback)(dJointID, dJointFeedback *);
665 //dJointFeedback *(ODE_API *dJointGetFeedback)(dJointID);
666 //void (ODE_API *dJointSetBallAnchor)(dJointID, dReal x, dReal y, dReal z);
667 //void (ODE_API *dJointSetBallAnchor2)(dJointID, dReal x, dReal y, dReal z);
668 //void (ODE_API *dJointSetBallParam)(dJointID, int parameter, dReal value);
669 //void (ODE_API *dJointSetHingeAnchor)(dJointID, dReal x, dReal y, dReal z);
670 //void (ODE_API *dJointSetHingeAnchorDelta)(dJointID, dReal x, dReal y, dReal z, dReal ax, dReal ay, dReal az);
671 //void (ODE_API *dJointSetHingeAxis)(dJointID, dReal x, dReal y, dReal z);
672 //void (ODE_API *dJointSetHingeAxisOffset)(dJointID j, dReal x, dReal y, dReal z, dReal angle);
673 //void (ODE_API *dJointSetHingeParam)(dJointID, int parameter, dReal value);
674 //void (ODE_API *dJointAddHingeTorque)(dJointID joint, dReal torque);
675 //void (ODE_API *dJointSetSliderAxis)(dJointID, dReal x, dReal y, dReal z);
676 //void (ODE_API *dJointSetSliderAxisDelta)(dJointID, dReal x, dReal y, dReal z, dReal ax, dReal ay, dReal az);
677 //void (ODE_API *dJointSetSliderParam)(dJointID, int parameter, dReal value);
678 //void (ODE_API *dJointAddSliderForce)(dJointID joint, dReal force);
679 //void (ODE_API *dJointSetHinge2Anchor)(dJointID, dReal x, dReal y, dReal z);
680 //void (ODE_API *dJointSetHinge2Axis1)(dJointID, dReal x, dReal y, dReal z);
681 //void (ODE_API *dJointSetHinge2Axis2)(dJointID, dReal x, dReal y, dReal z);
682 //void (ODE_API *dJointSetHinge2Param)(dJointID, int parameter, dReal value);
683 //void (ODE_API *dJointAddHinge2Torques)(dJointID joint, dReal torque1, dReal torque2);
684 //void (ODE_API *dJointSetUniversalAnchor)(dJointID, dReal x, dReal y, dReal z);
685 //void (ODE_API *dJointSetUniversalAxis1)(dJointID, dReal x, dReal y, dReal z);
686 //void (ODE_API *dJointSetUniversalAxis1Offset)(dJointID, dReal x, dReal y, dReal z, dReal offset1, dReal offset2);
687 //void (ODE_API *dJointSetUniversalAxis2)(dJointID, dReal x, dReal y, dReal z);
688 //void (ODE_API *dJointSetUniversalAxis2Offset)(dJointID, dReal x, dReal y, dReal z, dReal offset1, dReal offset2);
689 //void (ODE_API *dJointSetUniversalParam)(dJointID, int parameter, dReal value);
690 //void (ODE_API *dJointAddUniversalTorques)(dJointID joint, dReal torque1, dReal torque2);
691 //void (ODE_API *dJointSetPRAnchor)(dJointID, dReal x, dReal y, dReal z);
692 //void (ODE_API *dJointSetPRAxis1)(dJointID, dReal x, dReal y, dReal z);
693 //void (ODE_API *dJointSetPRAxis2)(dJointID, dReal x, dReal y, dReal z);
694 //void (ODE_API *dJointSetPRParam)(dJointID, int parameter, dReal value);
695 //void (ODE_API *dJointAddPRTorque)(dJointID j, dReal torque);
696 //void (ODE_API *dJointSetPUAnchor)(dJointID, dReal x, dReal y, dReal z);
697 //void (ODE_API *dJointSetPUAnchorOffset)(dJointID, dReal x, dReal y, dReal z, dReal dx, dReal dy, dReal dz);
698 //void (ODE_API *dJointSetPUAxis1)(dJointID, dReal x, dReal y, dReal z);
699 //void (ODE_API *dJointSetPUAxis2)(dJointID, dReal x, dReal y, dReal z);
700 //void (ODE_API *dJointSetPUAxis3)(dJointID, dReal x, dReal y, dReal z);
701 //void (ODE_API *dJointSetPUAxisP)(dJointID id, dReal x, dReal y, dReal z);
702 //void (ODE_API *dJointSetPUParam)(dJointID, int parameter, dReal value);
703 //void (ODE_API *dJointAddPUTorque)(dJointID j, dReal torque);
704 //void (ODE_API *dJointSetPistonAnchor)(dJointID, dReal x, dReal y, dReal z);
705 //void (ODE_API *dJointSetPistonAnchorOffset)(dJointID j, dReal x, dReal y, dReal z, dReal dx, dReal dy, dReal dz);
706 //void (ODE_API *dJointSetPistonParam)(dJointID, int parameter, dReal value);
707 //void (ODE_API *dJointAddPistonForce)(dJointID joint, dReal force);
708 //void (ODE_API *dJointSetFixed)(dJointID);
709 //void (ODE_API *dJointSetFixedParam)(dJointID, int parameter, dReal value);
710 //void (ODE_API *dJointSetAMotorNumAxes)(dJointID, int num);
711 //void (ODE_API *dJointSetAMotorAxis)(dJointID, int anum, int rel, dReal x, dReal y, dReal z);
712 //void (ODE_API *dJointSetAMotorAngle)(dJointID, int anum, dReal angle);
713 //void (ODE_API *dJointSetAMotorParam)(dJointID, int parameter, dReal value);
714 //void (ODE_API *dJointSetAMotorMode)(dJointID, int mode);
715 //void (ODE_API *dJointAddAMotorTorques)(dJointID, dReal torque1, dReal torque2, dReal torque3);
716 //void (ODE_API *dJointSetLMotorNumAxes)(dJointID, int num);
717 //void (ODE_API *dJointSetLMotorAxis)(dJointID, int anum, int rel, dReal x, dReal y, dReal z);
718 //void (ODE_API *dJointSetLMotorParam)(dJointID, int parameter, dReal value);
719 //void (ODE_API *dJointSetPlane2DXParam)(dJointID, int parameter, dReal value);
720 //void (ODE_API *dJointSetPlane2DYParam)(dJointID, int parameter, dReal value);
721 //void (ODE_API *dJointSetPlane2DAngleParam)(dJointID, int parameter, dReal value);
722 //void (ODE_API *dJointGetBallAnchor)(dJointID, dVector3 result);
723 //void (ODE_API *dJointGetBallAnchor2)(dJointID, dVector3 result);
724 //dReal (ODE_API *dJointGetBallParam)(dJointID, int parameter);
725 //void (ODE_API *dJointGetHingeAnchor)(dJointID, dVector3 result);
726 //void (ODE_API *dJointGetHingeAnchor2)(dJointID, dVector3 result);
727 //void (ODE_API *dJointGetHingeAxis)(dJointID, dVector3 result);
728 //dReal (ODE_API *dJointGetHingeParam)(dJointID, int parameter);
729 //dReal (ODE_API *dJointGetHingeAngle)(dJointID);
730 //dReal (ODE_API *dJointGetHingeAngleRate)(dJointID);
731 //dReal (ODE_API *dJointGetSliderPosition)(dJointID);
732 //dReal (ODE_API *dJointGetSliderPositionRate)(dJointID);
733 //void (ODE_API *dJointGetSliderAxis)(dJointID, dVector3 result);
734 //dReal (ODE_API *dJointGetSliderParam)(dJointID, int parameter);
735 //void (ODE_API *dJointGetHinge2Anchor)(dJointID, dVector3 result);
736 //void (ODE_API *dJointGetHinge2Anchor2)(dJointID, dVector3 result);
737 //void (ODE_API *dJointGetHinge2Axis1)(dJointID, dVector3 result);
738 //void (ODE_API *dJointGetHinge2Axis2)(dJointID, dVector3 result);
739 //dReal (ODE_API *dJointGetHinge2Param)(dJointID, int parameter);
740 //dReal (ODE_API *dJointGetHinge2Angle1)(dJointID);
741 //dReal (ODE_API *dJointGetHinge2Angle1Rate)(dJointID);
742 //dReal (ODE_API *dJointGetHinge2Angle2Rate)(dJointID);
743 //void (ODE_API *dJointGetUniversalAnchor)(dJointID, dVector3 result);
744 //void (ODE_API *dJointGetUniversalAnchor2)(dJointID, dVector3 result);
745 //void (ODE_API *dJointGetUniversalAxis1)(dJointID, dVector3 result);
746 //void (ODE_API *dJointGetUniversalAxis2)(dJointID, dVector3 result);
747 //dReal (ODE_API *dJointGetUniversalParam)(dJointID, int parameter);
748 //void (ODE_API *dJointGetUniversalAngles)(dJointID, dReal *angle1, dReal *angle2);
749 //dReal (ODE_API *dJointGetUniversalAngle1)(dJointID);
750 //dReal (ODE_API *dJointGetUniversalAngle2)(dJointID);
751 //dReal (ODE_API *dJointGetUniversalAngle1Rate)(dJointID);
752 //dReal (ODE_API *dJointGetUniversalAngle2Rate)(dJointID);
753 //void (ODE_API *dJointGetPRAnchor)(dJointID, dVector3 result);
754 //dReal (ODE_API *dJointGetPRPosition)(dJointID);
755 //dReal (ODE_API *dJointGetPRPositionRate)(dJointID);
756 //dReal (ODE_API *dJointGetPRAngle)(dJointID);
757 //dReal (ODE_API *dJointGetPRAngleRate)(dJointID);
758 //void (ODE_API *dJointGetPRAxis1)(dJointID, dVector3 result);
759 //void (ODE_API *dJointGetPRAxis2)(dJointID, dVector3 result);
760 //dReal (ODE_API *dJointGetPRParam)(dJointID, int parameter);
761 //void (ODE_API *dJointGetPUAnchor)(dJointID, dVector3 result);
762 //dReal (ODE_API *dJointGetPUPosition)(dJointID);
763 //dReal (ODE_API *dJointGetPUPositionRate)(dJointID);
764 //void (ODE_API *dJointGetPUAxis1)(dJointID, dVector3 result);
765 //void (ODE_API *dJointGetPUAxis2)(dJointID, dVector3 result);
766 //void (ODE_API *dJointGetPUAxis3)(dJointID, dVector3 result);
767 //void (ODE_API *dJointGetPUAxisP)(dJointID id, dVector3 result);
768 //void (ODE_API *dJointGetPUAngles)(dJointID, dReal *angle1, dReal *angle2);
769 //dReal (ODE_API *dJointGetPUAngle1)(dJointID);
770 //dReal (ODE_API *dJointGetPUAngle1Rate)(dJointID);
771 //dReal (ODE_API *dJointGetPUAngle2)(dJointID);
772 //dReal (ODE_API *dJointGetPUAngle2Rate)(dJointID);
773 //dReal (ODE_API *dJointGetPUParam)(dJointID, int parameter);
774 //dReal (ODE_API *dJointGetPistonPosition)(dJointID);
775 //dReal (ODE_API *dJointGetPistonPositionRate)(dJointID);
776 //dReal (ODE_API *dJointGetPistonAngle)(dJointID);
777 //dReal (ODE_API *dJointGetPistonAngleRate)(dJointID);
778 //void (ODE_API *dJointGetPistonAnchor)(dJointID, dVector3 result);
779 //void (ODE_API *dJointGetPistonAnchor2)(dJointID, dVector3 result);
780 //void (ODE_API *dJointGetPistonAxis)(dJointID, dVector3 result);
781 //dReal (ODE_API *dJointGetPistonParam)(dJointID, int parameter);
782 //int (ODE_API *dJointGetAMotorNumAxes)(dJointID);
783 //void (ODE_API *dJointGetAMotorAxis)(dJointID, int anum, dVector3 result);
784 //int (ODE_API *dJointGetAMotorAxisRel)(dJointID, int anum);
785 //dReal (ODE_API *dJointGetAMotorAngle)(dJointID, int anum);
786 //dReal (ODE_API *dJointGetAMotorAngleRate)(dJointID, int anum);
787 //dReal (ODE_API *dJointGetAMotorParam)(dJointID, int parameter);
788 //int (ODE_API *dJointGetAMotorMode)(dJointID);
789 //int (ODE_API *dJointGetLMotorNumAxes)(dJointID);
790 //void (ODE_API *dJointGetLMotorAxis)(dJointID, int anum, dVector3 result);
791 //dReal (ODE_API *dJointGetLMotorParam)(dJointID, int parameter);
792 //dReal (ODE_API *dJointGetFixedParam)(dJointID, int parameter);
793 //dJointID (ODE_API *dConnectingJoint)(dBodyID, dBodyID);
794 //int (ODE_API *dConnectingJointList)(dBodyID, dBodyID, dJointID*);
795 int (ODE_API *dAreConnected)(dBodyID, dBodyID);
796 int (ODE_API *dAreConnectedExcluding)(dBodyID body1, dBodyID body2, int joint_type);
798 dSpaceID (ODE_API *dSimpleSpaceCreate)(dSpaceID space);
799 dSpaceID (ODE_API *dHashSpaceCreate)(dSpaceID space);
800 dSpaceID (ODE_API *dQuadTreeSpaceCreate)(dSpaceID space, const dVector3 Center, const dVector3 Extents, int Depth);
801 //dSpaceID (ODE_API *dSweepAndPruneSpaceCreate)( dSpaceID space, int axisorder );
802 void (ODE_API *dSpaceDestroy)(dSpaceID);
803 //void (ODE_API *dHashSpaceSetLevels)(dSpaceID space, int minlevel, int maxlevel);
804 //void (ODE_API *dHashSpaceGetLevels)(dSpaceID space, int *minlevel, int *maxlevel);
805 //void (ODE_API *dSpaceSetCleanup)(dSpaceID space, int mode);
806 //int (ODE_API *dSpaceGetCleanup)(dSpaceID space);
807 //void (ODE_API *dSpaceSetSublevel)(dSpaceID space, int sublevel);
808 //int (ODE_API *dSpaceGetSublevel)(dSpaceID space);
809 //void (ODE_API *dSpaceSetManualCleanup)(dSpaceID space, int mode);
810 //int (ODE_API *dSpaceGetManualCleanup)(dSpaceID space);
811 //void (ODE_API *dSpaceAdd)(dSpaceID, dGeomID);
812 //void (ODE_API *dSpaceRemove)(dSpaceID, dGeomID);
813 //int (ODE_API *dSpaceQuery)(dSpaceID, dGeomID);
814 //void (ODE_API *dSpaceClean)(dSpaceID);
815 //int (ODE_API *dSpaceGetNumGeoms)(dSpaceID);
816 //dGeomID (ODE_API *dSpaceGetGeom)(dSpaceID, int i);
817 //int (ODE_API *dSpaceGetClass)(dSpaceID space);
819 void (ODE_API *dGeomDestroy)(dGeomID geom);
820 //void (ODE_API *dGeomSetData)(dGeomID geom, void* data);
821 //void * (ODE_API *dGeomGetData)(dGeomID geom);
822 void (ODE_API *dGeomSetBody)(dGeomID geom, dBodyID body);
823 dBodyID (ODE_API *dGeomGetBody)(dGeomID geom);
824 //void (ODE_API *dGeomSetPosition)(dGeomID geom, dReal x, dReal y, dReal z);
825 void (ODE_API *dGeomSetRotation)(dGeomID geom, const dMatrix3 R);
826 //void (ODE_API *dGeomSetQuaternion)(dGeomID geom, const dQuaternion Q);
827 //const dReal * (ODE_API *dGeomGetPosition)(dGeomID geom);
828 //void (ODE_API *dGeomCopyPosition)(dGeomID geom, dVector3 pos);
829 //const dReal * (ODE_API *dGeomGetRotation)(dGeomID geom);
830 //void (ODE_API *dGeomCopyRotation)(dGeomID geom, dMatrix3 R);
831 //void (ODE_API *dGeomGetQuaternion)(dGeomID geom, dQuaternion result);
832 //void (ODE_API *dGeomGetAABB)(dGeomID geom, dReal aabb[6]);
833 int (ODE_API *dGeomIsSpace)(dGeomID geom);
834 //dSpaceID (ODE_API *dGeomGetSpace)(dGeomID);
835 //int (ODE_API *dGeomGetClass)(dGeomID geom);
836 //void (ODE_API *dGeomSetCategoryBits)(dGeomID geom, unsigned long bits);
837 //void (ODE_API *dGeomSetCollideBits)(dGeomID geom, unsigned long bits);
838 //unsigned long (ODE_API *dGeomGetCategoryBits)(dGeomID);
839 //unsigned long (ODE_API *dGeomGetCollideBits)(dGeomID);
840 //void (ODE_API *dGeomEnable)(dGeomID geom);
841 //void (ODE_API *dGeomDisable)(dGeomID geom);
842 //int (ODE_API *dGeomIsEnabled)(dGeomID geom);
843 //void (ODE_API *dGeomSetOffsetPosition)(dGeomID geom, dReal x, dReal y, dReal z);
844 //void (ODE_API *dGeomSetOffsetRotation)(dGeomID geom, const dMatrix3 R);
845 //void (ODE_API *dGeomSetOffsetQuaternion)(dGeomID geom, const dQuaternion Q);
846 //void (ODE_API *dGeomSetOffsetWorldPosition)(dGeomID geom, dReal x, dReal y, dReal z);
847 //void (ODE_API *dGeomSetOffsetWorldRotation)(dGeomID geom, const dMatrix3 R);
848 //void (ODE_API *dGeomSetOffsetWorldQuaternion)(dGeomID geom, const dQuaternion);
849 //void (ODE_API *dGeomClearOffset)(dGeomID geom);
850 //int (ODE_API *dGeomIsOffset)(dGeomID geom);
851 //const dReal * (ODE_API *dGeomGetOffsetPosition)(dGeomID geom);
852 //void (ODE_API *dGeomCopyOffsetPosition)(dGeomID geom, dVector3 pos);
853 //const dReal * (ODE_API *dGeomGetOffsetRotation)(dGeomID geom);
854 //void (ODE_API *dGeomCopyOffsetRotation)(dGeomID geom, dMatrix3 R);
855 //void (ODE_API *dGeomGetOffsetQuaternion)(dGeomID geom, dQuaternion result);
856 int (ODE_API *dCollide)(dGeomID o1, dGeomID o2, int flags, dContactGeom *contact, int skip);
858 void (ODE_API *dSpaceCollide)(dSpaceID space, void *data, dNearCallback *callback);
859 void (ODE_API *dSpaceCollide2)(dGeomID space1, dGeomID space2, void *data, dNearCallback *callback);
861 dGeomID (ODE_API *dCreateSphere)(dSpaceID space, dReal radius);
862 //void (ODE_API *dGeomSphereSetRadius)(dGeomID sphere, dReal radius);
863 //dReal (ODE_API *dGeomSphereGetRadius)(dGeomID sphere);
864 //dReal (ODE_API *dGeomSpherePointDepth)(dGeomID sphere, dReal x, dReal y, dReal z);
866 //dGeomID (ODE_API *dCreateConvex)(dSpaceID space, dReal *_planes, unsigned int _planecount, dReal *_points, unsigned int _pointcount,unsigned int *_polygons);
867 //void (ODE_API *dGeomSetConvex)(dGeomID g, dReal *_planes, unsigned int _count, dReal *_points, unsigned int _pointcount,unsigned int *_polygons);
869 dGeomID (ODE_API *dCreateBox)(dSpaceID space, dReal lx, dReal ly, dReal lz);
870 //void (ODE_API *dGeomBoxSetLengths)(dGeomID box, dReal lx, dReal ly, dReal lz);
871 //void (ODE_API *dGeomBoxGetLengths)(dGeomID box, dVector3 result);
872 //dReal (ODE_API *dGeomBoxPointDepth)(dGeomID box, dReal x, dReal y, dReal z);
873 //dReal (ODE_API *dGeomBoxPointDepth)(dGeomID box, dReal x, dReal y, dReal z);
875 //dGeomID (ODE_API *dCreatePlane)(dSpaceID space, dReal a, dReal b, dReal c, dReal d);
876 //void (ODE_API *dGeomPlaneSetParams)(dGeomID plane, dReal a, dReal b, dReal c, dReal d);
877 //void (ODE_API *dGeomPlaneGetParams)(dGeomID plane, dVector4 result);
878 //dReal (ODE_API *dGeomPlanePointDepth)(dGeomID plane, dReal x, dReal y, dReal z);
880 dGeomID (ODE_API *dCreateCapsule)(dSpaceID space, dReal radius, dReal length);
881 //void (ODE_API *dGeomCapsuleSetParams)(dGeomID ccylinder, dReal radius, dReal length);
882 //void (ODE_API *dGeomCapsuleGetParams)(dGeomID ccylinder, dReal *radius, dReal *length);
883 //dReal (ODE_API *dGeomCapsulePointDepth)(dGeomID ccylinder, dReal x, dReal y, dReal z);
885 //dGeomID (ODE_API *dCreateCylinder)(dSpaceID space, dReal radius, dReal length);
886 //void (ODE_API *dGeomCylinderSetParams)(dGeomID cylinder, dReal radius, dReal length);
887 //void (ODE_API *dGeomCylinderGetParams)(dGeomID cylinder, dReal *radius, dReal *length);
889 //dGeomID (ODE_API *dCreateRay)(dSpaceID space, dReal length);
890 //void (ODE_API *dGeomRaySetLength)(dGeomID ray, dReal length);
891 //dReal (ODE_API *dGeomRayGetLength)(dGeomID ray);
892 //void (ODE_API *dGeomRaySet)(dGeomID ray, dReal px, dReal py, dReal pz, dReal dx, dReal dy, dReal dz);
893 //void (ODE_API *dGeomRayGet)(dGeomID ray, dVector3 start, dVector3 dir);
895 dGeomID (ODE_API *dCreateGeomTransform)(dSpaceID space);
896 void (ODE_API *dGeomTransformSetGeom)(dGeomID g, dGeomID obj);
897 //dGeomID (ODE_API *dGeomTransformGetGeom)(dGeomID g);
898 void (ODE_API *dGeomTransformSetCleanup)(dGeomID g, int mode);
899 //int (ODE_API *dGeomTransformGetCleanup)(dGeomID g);
900 //void (ODE_API *dGeomTransformSetInfo)(dGeomID g, int mode);
901 //int (ODE_API *dGeomTransformGetInfo)(dGeomID g);
903 enum { TRIMESH_FACE_NORMALS };
904 typedef int dTriCallback(dGeomID TriMesh, dGeomID RefObject, int TriangleIndex);
905 typedef void dTriArrayCallback(dGeomID TriMesh, dGeomID RefObject, const int* TriIndices, int TriCount);
906 typedef int dTriRayCallback(dGeomID TriMesh, dGeomID Ray, int TriangleIndex, dReal u, dReal v);
907 typedef int dTriTriMergeCallback(dGeomID TriMesh, int FirstTriangleIndex, int SecondTriangleIndex);
909 dTriMeshDataID (ODE_API *dGeomTriMeshDataCreate)(void);
910 void (ODE_API *dGeomTriMeshDataDestroy)(dTriMeshDataID g);
911 //void (ODE_API *dGeomTriMeshDataSet)(dTriMeshDataID g, int data_id, void* in_data);
912 //void* (ODE_API *dGeomTriMeshDataGet)(dTriMeshDataID g, int data_id);
913 //void (*dGeomTriMeshSetLastTransform)( (ODE_API *dGeomID g, dMatrix4 last_trans );
914 //dReal* (*dGeomTriMeshGetLastTransform)( (ODE_API *dGeomID g );
915 void (ODE_API *dGeomTriMeshDataBuildSingle)(dTriMeshDataID g, const void* Vertices, int VertexStride, int VertexCount, const void* Indices, int IndexCount, int TriStride);
916 //void (ODE_API *dGeomTriMeshDataBuildSingle1)(dTriMeshDataID g, const void* Vertices, int VertexStride, int VertexCount, const void* Indices, int IndexCount, int TriStride, const void* Normals);
917 //void (ODE_API *dGeomTriMeshDataBuildDouble)(dTriMeshDataID g, const void* Vertices, int VertexStride, int VertexCount, const void* Indices, int IndexCount, int TriStride);
918 //void (ODE_API *dGeomTriMeshDataBuildDouble1)(dTriMeshDataID g, const void* Vertices, int VertexStride, int VertexCount, const void* Indices, int IndexCount, int TriStride, const void* Normals);
919 //void (ODE_API *dGeomTriMeshDataBuildSimple)(dTriMeshDataID g, const dReal* Vertices, int VertexCount, const dTriIndex* Indices, int IndexCount);
920 //void (ODE_API *dGeomTriMeshDataBuildSimple1)(dTriMeshDataID g, const dReal* Vertices, int VertexCount, const dTriIndex* Indices, int IndexCount, const int* Normals);
921 //void (ODE_API *dGeomTriMeshDataPreprocess)(dTriMeshDataID g);
922 //void (ODE_API *dGeomTriMeshDataGetBuffer)(dTriMeshDataID g, unsigned char** buf, int* bufLen);
923 //void (ODE_API *dGeomTriMeshDataSetBuffer)(dTriMeshDataID g, unsigned char* buf);
924 //void (ODE_API *dGeomTriMeshSetCallback)(dGeomID g, dTriCallback* Callback);
925 //dTriCallback* (ODE_API *dGeomTriMeshGetCallback)(dGeomID g);
926 //void (ODE_API *dGeomTriMeshSetArrayCallback)(dGeomID g, dTriArrayCallback* ArrayCallback);
927 //dTriArrayCallback* (ODE_API *dGeomTriMeshGetArrayCallback)(dGeomID g);
928 //void (ODE_API *dGeomTriMeshSetRayCallback)(dGeomID g, dTriRayCallback* Callback);
929 //dTriRayCallback* (ODE_API *dGeomTriMeshGetRayCallback)(dGeomID g);
930 //void (ODE_API *dGeomTriMeshSetTriMergeCallback)(dGeomID g, dTriTriMergeCallback* Callback);
931 //dTriTriMergeCallback* (ODE_API *dGeomTriMeshGetTriMergeCallback)(dGeomID g);
932 dGeomID (ODE_API *dCreateTriMesh)(dSpaceID space, dTriMeshDataID Data, dTriCallback* Callback, dTriArrayCallback* ArrayCallback, dTriRayCallback* RayCallback);
933 //void (ODE_API *dGeomTriMeshSetData)(dGeomID g, dTriMeshDataID Data);
934 //dTriMeshDataID (ODE_API *dGeomTriMeshGetData)(dGeomID g);
935 //void (ODE_API *dGeomTriMeshEnableTC)(dGeomID g, int geomClass, int enable);
936 //int (ODE_API *dGeomTriMeshIsTCEnabled)(dGeomID g, int geomClass);
937 //void (ODE_API *dGeomTriMeshClearTCCache)(dGeomID g);
938 //dTriMeshDataID (ODE_API *dGeomTriMeshGetTriMeshDataID)(dGeomID g);
939 //void (ODE_API *dGeomTriMeshGetTriangle)(dGeomID g, int Index, dVector3* v0, dVector3* v1, dVector3* v2);
940 //void (ODE_API *dGeomTriMeshGetPoint)(dGeomID g, int Index, dReal u, dReal v, dVector3 Out);
941 //int (ODE_API *dGeomTriMeshGetTriangleCount )(dGeomID g);
942 //void (ODE_API *dGeomTriMeshDataUpdate)(dTriMeshDataID g);
944 static dllfunction_t odefuncs[] =
946 // {"dGetConfiguration", (void **) &dGetConfiguration},
947 // {"dCheckConfiguration", (void **) &dCheckConfiguration},
948 {"dInitODE", (void **) &dInitODE},
949 // {"dInitODE2", (void **) &dInitODE2},
950 // {"dAllocateODEDataForThread", (void **) &dAllocateODEDataForThread},
951 // {"dCleanupODEAllDataForThread", (void **) &dCleanupODEAllDataForThread},
952 {"dCloseODE", (void **) &dCloseODE},
953 // {"dMassCheck", (void **) &dMassCheck},
954 // {"dMassSetZero", (void **) &dMassSetZero},
955 // {"dMassSetParameters", (void **) &dMassSetParameters},
956 // {"dMassSetSphere", (void **) &dMassSetSphere},
957 {"dMassSetSphereTotal", (void **) &dMassSetSphereTotal},
958 // {"dMassSetCapsule", (void **) &dMassSetCapsule},
959 {"dMassSetCapsuleTotal", (void **) &dMassSetCapsuleTotal},
960 // {"dMassSetCylinder", (void **) &dMassSetCylinder},
961 // {"dMassSetCylinderTotal", (void **) &dMassSetCylinderTotal},
962 // {"dMassSetBox", (void **) &dMassSetBox},
963 {"dMassSetBoxTotal", (void **) &dMassSetBoxTotal},
964 // {"dMassSetTrimesh", (void **) &dMassSetTrimesh},
965 // {"dMassSetTrimeshTotal", (void **) &dMassSetTrimeshTotal},
966 // {"dMassAdjust", (void **) &dMassAdjust},
967 // {"dMassTranslate", (void **) &dMassTranslate},
968 // {"dMassRotate", (void **) &dMassRotate},
969 // {"dMassAdd", (void **) &dMassAdd},
971 {"dWorldCreate", (void **) &dWorldCreate},
972 {"dWorldDestroy", (void **) &dWorldDestroy},
973 {"dWorldSetGravity", (void **) &dWorldSetGravity},
974 {"dWorldGetGravity", (void **) &dWorldGetGravity},
975 // {"dWorldSetERP", (void **) &dWorldSetERP},
976 // {"dWorldGetERP", (void **) &dWorldGetERP},
977 // {"dWorldSetCFM", (void **) &dWorldSetCFM},
978 // {"dWorldGetCFM", (void **) &dWorldGetCFM},
979 {"dWorldStep", (void **) &dWorldStep},
980 // {"dWorldImpulseToForce", (void **) &dWorldImpulseToForce},
981 {"dWorldQuickStep", (void **) &dWorldQuickStep},
982 {"dWorldSetQuickStepNumIterations", (void **) &dWorldSetQuickStepNumIterations},
983 // {"dWorldGetQuickStepNumIterations", (void **) &dWorldGetQuickStepNumIterations},
984 // {"dWorldSetQuickStepW", (void **) &dWorldSetQuickStepW},
985 // {"dWorldGetQuickStepW", (void **) &dWorldGetQuickStepW},
986 // {"dWorldSetContactMaxCorrectingVel", (void **) &dWorldSetContactMaxCorrectingVel},
987 // {"dWorldGetContactMaxCorrectingVel", (void **) &dWorldGetContactMaxCorrectingVel},
988 {"dWorldSetContactSurfaceLayer", (void **) &dWorldSetContactSurfaceLayer},
989 // {"dWorldGetContactSurfaceLayer", (void **) &dWorldGetContactSurfaceLayer},
990 {"dWorldStepFast1", (void **) &dWorldStepFast1},
991 // {"dWorldSetAutoEnableDepthSF1", (void **) &dWorldSetAutoEnableDepthSF1},
992 // {"dWorldGetAutoEnableDepthSF1", (void **) &dWorldGetAutoEnableDepthSF1},
993 // {"dWorldGetAutoDisableLinearThreshold", (void **) &dWorldGetAutoDisableLinearThreshold},
994 // {"dWorldSetAutoDisableLinearThreshold", (void **) &dWorldSetAutoDisableLinearThreshold},
995 // {"dWorldGetAutoDisableAngularThreshold", (void **) &dWorldGetAutoDisableAngularThreshold},
996 // {"dWorldSetAutoDisableAngularThreshold", (void **) &dWorldSetAutoDisableAngularThreshold},
997 // {"dWorldGetAutoDisableLinearAverageThreshold", (void **) &dWorldGetAutoDisableLinearAverageThreshold},
998 // {"dWorldSetAutoDisableLinearAverageThreshold", (void **) &dWorldSetAutoDisableLinearAverageThreshold},
999 // {"dWorldGetAutoDisableAngularAverageThreshold", (void **) &dWorldGetAutoDisableAngularAverageThreshold},
1000 // {"dWorldSetAutoDisableAngularAverageThreshold", (void **) &dWorldSetAutoDisableAngularAverageThreshold},
1001 // {"dWorldGetAutoDisableAverageSamplesCount", (void **) &dWorldGetAutoDisableAverageSamplesCount},
1002 // {"dWorldSetAutoDisableAverageSamplesCount", (void **) &dWorldSetAutoDisableAverageSamplesCount},
1003 // {"dWorldGetAutoDisableSteps", (void **) &dWorldGetAutoDisableSteps},
1004 // {"dWorldSetAutoDisableSteps", (void **) &dWorldSetAutoDisableSteps},
1005 // {"dWorldGetAutoDisableTime", (void **) &dWorldGetAutoDisableTime},
1006 // {"dWorldSetAutoDisableTime", (void **) &dWorldSetAutoDisableTime},
1007 // {"dWorldGetAutoDisableFlag", (void **) &dWorldGetAutoDisableFlag},
1008 // {"dWorldSetAutoDisableFlag", (void **) &dWorldSetAutoDisableFlag},
1009 // {"dWorldGetLinearDampingThreshold", (void **) &dWorldGetLinearDampingThreshold},
1010 // {"dWorldSetLinearDampingThreshold", (void **) &dWorldSetLinearDampingThreshold},
1011 // {"dWorldGetAngularDampingThreshold", (void **) &dWorldGetAngularDampingThreshold},
1012 // {"dWorldSetAngularDampingThreshold", (void **) &dWorldSetAngularDampingThreshold},
1013 // {"dWorldGetLinearDamping", (void **) &dWorldGetLinearDamping},
1014 // {"dWorldSetLinearDamping", (void **) &dWorldSetLinearDamping},
1015 // {"dWorldGetAngularDamping", (void **) &dWorldGetAngularDamping},
1016 // {"dWorldSetAngularDamping", (void **) &dWorldSetAngularDamping},
1017 // {"dWorldSetDamping", (void **) &dWorldSetDamping},
1018 // {"dWorldGetMaxAngularSpeed", (void **) &dWorldGetMaxAngularSpeed},
1019 // {"dWorldSetMaxAngularSpeed", (void **) &dWorldSetMaxAngularSpeed},
1020 // {"dBodyGetAutoDisableLinearThreshold", (void **) &dBodyGetAutoDisableLinearThreshold},
1021 // {"dBodySetAutoDisableLinearThreshold", (void **) &dBodySetAutoDisableLinearThreshold},
1022 // {"dBodyGetAutoDisableAngularThreshold", (void **) &dBodyGetAutoDisableAngularThreshold},
1023 // {"dBodySetAutoDisableAngularThreshold", (void **) &dBodySetAutoDisableAngularThreshold},
1024 // {"dBodyGetAutoDisableAverageSamplesCount", (void **) &dBodyGetAutoDisableAverageSamplesCount},
1025 // {"dBodySetAutoDisableAverageSamplesCount", (void **) &dBodySetAutoDisableAverageSamplesCount},
1026 // {"dBodyGetAutoDisableSteps", (void **) &dBodyGetAutoDisableSteps},
1027 // {"dBodySetAutoDisableSteps", (void **) &dBodySetAutoDisableSteps},
1028 // {"dBodyGetAutoDisableTime", (void **) &dBodyGetAutoDisableTime},
1029 // {"dBodySetAutoDisableTime", (void **) &dBodySetAutoDisableTime},
1030 // {"dBodyGetAutoDisableFlag", (void **) &dBodyGetAutoDisableFlag},
1031 // {"dBodySetAutoDisableFlag", (void **) &dBodySetAutoDisableFlag},
1032 // {"dBodySetAutoDisableDefaults", (void **) &dBodySetAutoDisableDefaults},
1033 // {"dBodyGetWorld", (void **) &dBodyGetWorld},
1034 {"dBodyCreate", (void **) &dBodyCreate},
1035 {"dBodyDestroy", (void **) &dBodyDestroy},
1036 {"dBodySetData", (void **) &dBodySetData},
1037 {"dBodyGetData", (void **) &dBodyGetData},
1038 {"dBodySetPosition", (void **) &dBodySetPosition},
1039 {"dBodySetRotation", (void **) &dBodySetRotation},
1040 // {"dBodySetQuaternion", (void **) &dBodySetQuaternion},
1041 {"dBodySetLinearVel", (void **) &dBodySetLinearVel},
1042 {"dBodySetAngularVel", (void **) &dBodySetAngularVel},
1043 {"dBodyGetPosition", (void **) &dBodyGetPosition},
1044 // {"dBodyCopyPosition", (void **) &dBodyCopyPosition},
1045 {"dBodyGetRotation", (void **) &dBodyGetRotation},
1046 // {"dBodyCopyRotation", (void **) &dBodyCopyRotation},
1047 // {"dBodyGetQuaternion", (void **) &dBodyGetQuaternion},
1048 // {"dBodyCopyQuaternion", (void **) &dBodyCopyQuaternion},
1049 {"dBodyGetLinearVel", (void **) &dBodyGetLinearVel},
1050 {"dBodyGetAngularVel", (void **) &dBodyGetAngularVel},
1051 {"dBodySetMass", (void **) &dBodySetMass},
1052 // {"dBodyGetMass", (void **) &dBodyGetMass},
1053 // {"dBodyAddForce", (void **) &dBodyAddForce},
1054 // {"dBodyAddTorque", (void **) &dBodyAddTorque},
1055 // {"dBodyAddRelForce", (void **) &dBodyAddRelForce},
1056 // {"dBodyAddRelTorque", (void **) &dBodyAddRelTorque},
1057 // {"dBodyAddForceAtPos", (void **) &dBodyAddForceAtPos},
1058 // {"dBodyAddForceAtRelPos", (void **) &dBodyAddForceAtRelPos},
1059 // {"dBodyAddRelForceAtPos", (void **) &dBodyAddRelForceAtPos},
1060 // {"dBodyAddRelForceAtRelPos", (void **) &dBodyAddRelForceAtRelPos},
1061 // {"dBodyGetForce", (void **) &dBodyGetForce},
1062 // {"dBodyGetTorque", (void **) &dBodyGetTorque},
1063 // {"dBodySetForce", (void **) &dBodySetForce},
1064 // {"dBodySetTorque", (void **) &dBodySetTorque},
1065 // {"dBodyGetRelPointPos", (void **) &dBodyGetRelPointPos},
1066 // {"dBodyGetRelPointVel", (void **) &dBodyGetRelPointVel},
1067 // {"dBodyGetPointVel", (void **) &dBodyGetPointVel},
1068 // {"dBodyGetPosRelPoint", (void **) &dBodyGetPosRelPoint},
1069 // {"dBodyVectorToWorld", (void **) &dBodyVectorToWorld},
1070 // {"dBodyVectorFromWorld", (void **) &dBodyVectorFromWorld},
1071 // {"dBodySetFiniteRotationMode", (void **) &dBodySetFiniteRotationMode},
1072 // {"dBodySetFiniteRotationAxis", (void **) &dBodySetFiniteRotationAxis},
1073 // {"dBodyGetFiniteRotationMode", (void **) &dBodyGetFiniteRotationMode},
1074 // {"dBodyGetFiniteRotationAxis", (void **) &dBodyGetFiniteRotationAxis},
1075 // {"dBodyGetNumJoints", (void **) &dBodyGetNumJoints},
1076 // {"dBodyGetJoint", (void **) &dBodyGetJoint},
1077 // {"dBodySetDynamic", (void **) &dBodySetDynamic},
1078 // {"dBodySetKinematic", (void **) &dBodySetKinematic},
1079 // {"dBodyIsKinematic", (void **) &dBodyIsKinematic},
1080 // {"dBodyEnable", (void **) &dBodyEnable},
1081 // {"dBodyDisable", (void **) &dBodyDisable},
1082 // {"dBodyIsEnabled", (void **) &dBodyIsEnabled},
1083 {"dBodySetGravityMode", (void **) &dBodySetGravityMode},
1084 {"dBodyGetGravityMode", (void **) &dBodyGetGravityMode},
1085 // {"dBodySetMovedCallback", (void **) &dBodySetMovedCallback},
1086 // {"dBodyGetFirstGeom", (void **) &dBodyGetFirstGeom},
1087 // {"dBodyGetNextGeom", (void **) &dBodyGetNextGeom},
1088 // {"dBodySetDampingDefaults", (void **) &dBodySetDampingDefaults},
1089 // {"dBodyGetLinearDamping", (void **) &dBodyGetLinearDamping},
1090 // {"dBodySetLinearDamping", (void **) &dBodySetLinearDamping},
1091 // {"dBodyGetAngularDamping", (void **) &dBodyGetAngularDamping},
1092 // {"dBodySetAngularDamping", (void **) &dBodySetAngularDamping},
1093 // {"dBodySetDamping", (void **) &dBodySetDamping},
1094 // {"dBodyGetLinearDampingThreshold", (void **) &dBodyGetLinearDampingThreshold},
1095 // {"dBodySetLinearDampingThreshold", (void **) &dBodySetLinearDampingThreshold},
1096 // {"dBodyGetAngularDampingThreshold", (void **) &dBodyGetAngularDampingThreshold},
1097 // {"dBodySetAngularDampingThreshold", (void **) &dBodySetAngularDampingThreshold},
1098 // {"dBodyGetMaxAngularSpeed", (void **) &dBodyGetMaxAngularSpeed},
1099 // {"dBodySetMaxAngularSpeed", (void **) &dBodySetMaxAngularSpeed},
1100 // {"dBodyGetGyroscopicMode", (void **) &dBodyGetGyroscopicMode},
1101 // {"dBodySetGyroscopicMode", (void **) &dBodySetGyroscopicMode},
1102 // {"dJointCreateBall", (void **) &dJointCreateBall},
1103 // {"dJointCreateHinge", (void **) &dJointCreateHinge},
1104 // {"dJointCreateSlider", (void **) &dJointCreateSlider},
1105 {"dJointCreateContact", (void **) &dJointCreateContact},
1106 // {"dJointCreateHinge2", (void **) &dJointCreateHinge2},
1107 // {"dJointCreateUniversal", (void **) &dJointCreateUniversal},
1108 // {"dJointCreatePR", (void **) &dJointCreatePR},
1109 // {"dJointCreatePU", (void **) &dJointCreatePU},
1110 // {"dJointCreatePiston", (void **) &dJointCreatePiston},
1111 // {"dJointCreateFixed", (void **) &dJointCreateFixed},
1112 // {"dJointCreateNull", (void **) &dJointCreateNull},
1113 // {"dJointCreateAMotor", (void **) &dJointCreateAMotor},
1114 // {"dJointCreateLMotor", (void **) &dJointCreateLMotor},
1115 // {"dJointCreatePlane2D", (void **) &dJointCreatePlane2D},
1116 // {"dJointDestroy", (void **) &dJointDestroy},
1117 {"dJointGroupCreate", (void **) &dJointGroupCreate},
1118 {"dJointGroupDestroy", (void **) &dJointGroupDestroy},
1119 {"dJointGroupEmpty", (void **) &dJointGroupEmpty},
1120 // {"dJointGetNumBodies", (void **) &dJointGetNumBodies},
1121 {"dJointAttach", (void **) &dJointAttach},
1122 // {"dJointEnable", (void **) &dJointEnable},
1123 // {"dJointDisable", (void **) &dJointDisable},
1124 // {"dJointIsEnabled", (void **) &dJointIsEnabled},
1125 // {"dJointSetData", (void **) &dJointSetData},
1126 // {"dJointGetData", (void **) &dJointGetData},
1127 // {"dJointGetType", (void **) &dJointGetType},
1128 // {"dJointGetBody", (void **) &dJointGetBody},
1129 // {"dJointSetFeedback", (void **) &dJointSetFeedback},
1130 // {"dJointGetFeedback", (void **) &dJointGetFeedback},
1131 // {"dJointSetBallAnchor", (void **) &dJointSetBallAnchor},
1132 // {"dJointSetBallAnchor2", (void **) &dJointSetBallAnchor2},
1133 // {"dJointSetBallParam", (void **) &dJointSetBallParam},
1134 // {"dJointSetHingeAnchor", (void **) &dJointSetHingeAnchor},
1135 // {"dJointSetHingeAnchorDelta", (void **) &dJointSetHingeAnchorDelta},
1136 // {"dJointSetHingeAxis", (void **) &dJointSetHingeAxis},
1137 // {"dJointSetHingeAxisOffset", (void **) &dJointSetHingeAxisOffset},
1138 // {"dJointSetHingeParam", (void **) &dJointSetHingeParam},
1139 // {"dJointAddHingeTorque", (void **) &dJointAddHingeTorque},
1140 // {"dJointSetSliderAxis", (void **) &dJointSetSliderAxis},
1141 // {"dJointSetSliderAxisDelta", (void **) &dJointSetSliderAxisDelta},
1142 // {"dJointSetSliderParam", (void **) &dJointSetSliderParam},
1143 // {"dJointAddSliderForce", (void **) &dJointAddSliderForce},
1144 // {"dJointSetHinge2Anchor", (void **) &dJointSetHinge2Anchor},
1145 // {"dJointSetHinge2Axis1", (void **) &dJointSetHinge2Axis1},
1146 // {"dJointSetHinge2Axis2", (void **) &dJointSetHinge2Axis2},
1147 // {"dJointSetHinge2Param", (void **) &dJointSetHinge2Param},
1148 // {"dJointAddHinge2Torques", (void **) &dJointAddHinge2Torques},
1149 // {"dJointSetUniversalAnchor", (void **) &dJointSetUniversalAnchor},
1150 // {"dJointSetUniversalAxis1", (void **) &dJointSetUniversalAxis1},
1151 // {"dJointSetUniversalAxis1Offset", (void **) &dJointSetUniversalAxis1Offset},
1152 // {"dJointSetUniversalAxis2", (void **) &dJointSetUniversalAxis2},
1153 // {"dJointSetUniversalAxis2Offset", (void **) &dJointSetUniversalAxis2Offset},
1154 // {"dJointSetUniversalParam", (void **) &dJointSetUniversalParam},
1155 // {"dJointAddUniversalTorques", (void **) &dJointAddUniversalTorques},
1156 // {"dJointSetPRAnchor", (void **) &dJointSetPRAnchor},
1157 // {"dJointSetPRAxis1", (void **) &dJointSetPRAxis1},
1158 // {"dJointSetPRAxis2", (void **) &dJointSetPRAxis2},
1159 // {"dJointSetPRParam", (void **) &dJointSetPRParam},
1160 // {"dJointAddPRTorque", (void **) &dJointAddPRTorque},
1161 // {"dJointSetPUAnchor", (void **) &dJointSetPUAnchor},
1162 // {"dJointSetPUAnchorOffset", (void **) &dJointSetPUAnchorOffset},
1163 // {"dJointSetPUAxis1", (void **) &dJointSetPUAxis1},
1164 // {"dJointSetPUAxis2", (void **) &dJointSetPUAxis2},
1165 // {"dJointSetPUAxis3", (void **) &dJointSetPUAxis3},
1166 // {"dJointSetPUAxisP", (void **) &dJointSetPUAxisP},
1167 // {"dJointSetPUParam", (void **) &dJointSetPUParam},
1168 // {"dJointAddPUTorque", (void **) &dJointAddPUTorque},
1169 // {"dJointSetPistonAnchor", (void **) &dJointSetPistonAnchor},
1170 // {"dJointSetPistonAnchorOffset", (void **) &dJointSetPistonAnchorOffset},
1171 // {"dJointSetPistonParam", (void **) &dJointSetPistonParam},
1172 // {"dJointAddPistonForce", (void **) &dJointAddPistonForce},
1173 // {"dJointSetFixed", (void **) &dJointSetFixed},
1174 // {"dJointSetFixedParam", (void **) &dJointSetFixedParam},
1175 // {"dJointSetAMotorNumAxes", (void **) &dJointSetAMotorNumAxes},
1176 // {"dJointSetAMotorAxis", (void **) &dJointSetAMotorAxis},
1177 // {"dJointSetAMotorAngle", (void **) &dJointSetAMotorAngle},
1178 // {"dJointSetAMotorParam", (void **) &dJointSetAMotorParam},
1179 // {"dJointSetAMotorMode", (void **) &dJointSetAMotorMode},
1180 // {"dJointAddAMotorTorques", (void **) &dJointAddAMotorTorques},
1181 // {"dJointSetLMotorNumAxes", (void **) &dJointSetLMotorNumAxes},
1182 // {"dJointSetLMotorAxis", (void **) &dJointSetLMotorAxis},
1183 // {"dJointSetLMotorParam", (void **) &dJointSetLMotorParam},
1184 // {"dJointSetPlane2DXParam", (void **) &dJointSetPlane2DXParam},
1185 // {"dJointSetPlane2DYParam", (void **) &dJointSetPlane2DYParam},
1186 // {"dJointSetPlane2DAngleParam", (void **) &dJointSetPlane2DAngleParam},
1187 // {"dJointGetBallAnchor", (void **) &dJointGetBallAnchor},
1188 // {"dJointGetBallAnchor2", (void **) &dJointGetBallAnchor2},
1189 // {"dJointGetBallParam", (void **) &dJointGetBallParam},
1190 // {"dJointGetHingeAnchor", (void **) &dJointGetHingeAnchor},
1191 // {"dJointGetHingeAnchor2", (void **) &dJointGetHingeAnchor2},
1192 // {"dJointGetHingeAxis", (void **) &dJointGetHingeAxis},
1193 // {"dJointGetHingeParam", (void **) &dJointGetHingeParam},
1194 // {"dJointGetHingeAngle", (void **) &dJointGetHingeAngle},
1195 // {"dJointGetHingeAngleRate", (void **) &dJointGetHingeAngleRate},
1196 // {"dJointGetSliderPosition", (void **) &dJointGetSliderPosition},
1197 // {"dJointGetSliderPositionRate", (void **) &dJointGetSliderPositionRate},
1198 // {"dJointGetSliderAxis", (void **) &dJointGetSliderAxis},
1199 // {"dJointGetSliderParam", (void **) &dJointGetSliderParam},
1200 // {"dJointGetHinge2Anchor", (void **) &dJointGetHinge2Anchor},
1201 // {"dJointGetHinge2Anchor2", (void **) &dJointGetHinge2Anchor2},
1202 // {"dJointGetHinge2Axis1", (void **) &dJointGetHinge2Axis1},
1203 // {"dJointGetHinge2Axis2", (void **) &dJointGetHinge2Axis2},
1204 // {"dJointGetHinge2Param", (void **) &dJointGetHinge2Param},
1205 // {"dJointGetHinge2Angle1", (void **) &dJointGetHinge2Angle1},
1206 // {"dJointGetHinge2Angle1Rate", (void **) &dJointGetHinge2Angle1Rate},
1207 // {"dJointGetHinge2Angle2Rate", (void **) &dJointGetHinge2Angle2Rate},
1208 // {"dJointGetUniversalAnchor", (void **) &dJointGetUniversalAnchor},
1209 // {"dJointGetUniversalAnchor2", (void **) &dJointGetUniversalAnchor2},
1210 // {"dJointGetUniversalAxis1", (void **) &dJointGetUniversalAxis1},
1211 // {"dJointGetUniversalAxis2", (void **) &dJointGetUniversalAxis2},
1212 // {"dJointGetUniversalParam", (void **) &dJointGetUniversalParam},
1213 // {"dJointGetUniversalAngles", (void **) &dJointGetUniversalAngles},
1214 // {"dJointGetUniversalAngle1", (void **) &dJointGetUniversalAngle1},
1215 // {"dJointGetUniversalAngle2", (void **) &dJointGetUniversalAngle2},
1216 // {"dJointGetUniversalAngle1Rate", (void **) &dJointGetUniversalAngle1Rate},
1217 // {"dJointGetUniversalAngle2Rate", (void **) &dJointGetUniversalAngle2Rate},
1218 // {"dJointGetPRAnchor", (void **) &dJointGetPRAnchor},
1219 // {"dJointGetPRPosition", (void **) &dJointGetPRPosition},
1220 // {"dJointGetPRPositionRate", (void **) &dJointGetPRPositionRate},
1221 // {"dJointGetPRAngle", (void **) &dJointGetPRAngle},
1222 // {"dJointGetPRAngleRate", (void **) &dJointGetPRAngleRate},
1223 // {"dJointGetPRAxis1", (void **) &dJointGetPRAxis1},
1224 // {"dJointGetPRAxis2", (void **) &dJointGetPRAxis2},
1225 // {"dJointGetPRParam", (void **) &dJointGetPRParam},
1226 // {"dJointGetPUAnchor", (void **) &dJointGetPUAnchor},
1227 // {"dJointGetPUPosition", (void **) &dJointGetPUPosition},
1228 // {"dJointGetPUPositionRate", (void **) &dJointGetPUPositionRate},
1229 // {"dJointGetPUAxis1", (void **) &dJointGetPUAxis1},
1230 // {"dJointGetPUAxis2", (void **) &dJointGetPUAxis2},
1231 // {"dJointGetPUAxis3", (void **) &dJointGetPUAxis3},
1232 // {"dJointGetPUAxisP", (void **) &dJointGetPUAxisP},
1233 // {"dJointGetPUAngles", (void **) &dJointGetPUAngles},
1234 // {"dJointGetPUAngle1", (void **) &dJointGetPUAngle1},
1235 // {"dJointGetPUAngle1Rate", (void **) &dJointGetPUAngle1Rate},
1236 // {"dJointGetPUAngle2", (void **) &dJointGetPUAngle2},
1237 // {"dJointGetPUAngle2Rate", (void **) &dJointGetPUAngle2Rate},
1238 // {"dJointGetPUParam", (void **) &dJointGetPUParam},
1239 // {"dJointGetPistonPosition", (void **) &dJointGetPistonPosition},
1240 // {"dJointGetPistonPositionRate", (void **) &dJointGetPistonPositionRate},
1241 // {"dJointGetPistonAngle", (void **) &dJointGetPistonAngle},
1242 // {"dJointGetPistonAngleRate", (void **) &dJointGetPistonAngleRate},
1243 // {"dJointGetPistonAnchor", (void **) &dJointGetPistonAnchor},
1244 // {"dJointGetPistonAnchor2", (void **) &dJointGetPistonAnchor2},
1245 // {"dJointGetPistonAxis", (void **) &dJointGetPistonAxis},
1246 // {"dJointGetPistonParam", (void **) &dJointGetPistonParam},
1247 // {"dJointGetAMotorNumAxes", (void **) &dJointGetAMotorNumAxes},
1248 // {"dJointGetAMotorAxis", (void **) &dJointGetAMotorAxis},
1249 // {"dJointGetAMotorAxisRel", (void **) &dJointGetAMotorAxisRel},
1250 // {"dJointGetAMotorAngle", (void **) &dJointGetAMotorAngle},
1251 // {"dJointGetAMotorAngleRate", (void **) &dJointGetAMotorAngleRate},
1252 // {"dJointGetAMotorParam", (void **) &dJointGetAMotorParam},
1253 // {"dJointGetAMotorMode", (void **) &dJointGetAMotorMode},
1254 // {"dJointGetLMotorNumAxes", (void **) &dJointGetLMotorNumAxes},
1255 // {"dJointGetLMotorAxis", (void **) &dJointGetLMotorAxis},
1256 // {"dJointGetLMotorParam", (void **) &dJointGetLMotorParam},
1257 // {"dJointGetFixedParam", (void **) &dJointGetFixedParam},
1258 // {"dConnectingJoint", (void **) &dConnectingJoint},
1259 // {"dConnectingJointList", (void **) &dConnectingJointList},
1260 {"dAreConnected", (void **) &dAreConnected},
1261 {"dAreConnectedExcluding", (void **) &dAreConnectedExcluding},
1262 {"dSimpleSpaceCreate", (void **) &dSimpleSpaceCreate},
1263 {"dHashSpaceCreate", (void **) &dHashSpaceCreate},
1264 {"dQuadTreeSpaceCreate", (void **) &dQuadTreeSpaceCreate},
1265 // {"dSweepAndPruneSpaceCreate", (void **) &dSweepAndPruneSpaceCreate},
1266 {"dSpaceDestroy", (void **) &dSpaceDestroy},
1267 // {"dHashSpaceSetLevels", (void **) &dHashSpaceSetLevels},
1268 // {"dHashSpaceGetLevels", (void **) &dHashSpaceGetLevels},
1269 // {"dSpaceSetCleanup", (void **) &dSpaceSetCleanup},
1270 // {"dSpaceGetCleanup", (void **) &dSpaceGetCleanup},
1271 // {"dSpaceSetSublevel", (void **) &dSpaceSetSublevel},
1272 // {"dSpaceGetSublevel", (void **) &dSpaceGetSublevel},
1273 // {"dSpaceSetManualCleanup", (void **) &dSpaceSetManualCleanup},
1274 // {"dSpaceGetManualCleanup", (void **) &dSpaceGetManualCleanup},
1275 // {"dSpaceAdd", (void **) &dSpaceAdd},
1276 // {"dSpaceRemove", (void **) &dSpaceRemove},
1277 // {"dSpaceQuery", (void **) &dSpaceQuery},
1278 // {"dSpaceClean", (void **) &dSpaceClean},
1279 // {"dSpaceGetNumGeoms", (void **) &dSpaceGetNumGeoms},
1280 // {"dSpaceGetGeom", (void **) &dSpaceGetGeom},
1281 // {"dSpaceGetClass", (void **) &dSpaceGetClass},
1282 {"dGeomDestroy", (void **) &dGeomDestroy},
1283 // {"dGeomSetData", (void **) &dGeomSetData},
1284 // {"dGeomGetData", (void **) &dGeomGetData},
1285 {"dGeomSetBody", (void **) &dGeomSetBody},
1286 {"dGeomGetBody", (void **) &dGeomGetBody},
1287 // {"dGeomSetPosition", (void **) &dGeomSetPosition},
1288 {"dGeomSetRotation", (void **) &dGeomSetRotation},
1289 // {"dGeomSetQuaternion", (void **) &dGeomSetQuaternion},
1290 // {"dGeomGetPosition", (void **) &dGeomGetPosition},
1291 // {"dGeomCopyPosition", (void **) &dGeomCopyPosition},
1292 // {"dGeomGetRotation", (void **) &dGeomGetRotation},
1293 // {"dGeomCopyRotation", (void **) &dGeomCopyRotation},
1294 // {"dGeomGetQuaternion", (void **) &dGeomGetQuaternion},
1295 // {"dGeomGetAABB", (void **) &dGeomGetAABB},
1296 {"dGeomIsSpace", (void **) &dGeomIsSpace},
1297 // {"dGeomGetSpace", (void **) &dGeomGetSpace},
1298 // {"dGeomGetClass", (void **) &dGeomGetClass},
1299 // {"dGeomSetCategoryBits", (void **) &dGeomSetCategoryBits},
1300 // {"dGeomSetCollideBits", (void **) &dGeomSetCollideBits},
1301 // {"dGeomGetCategoryBits", (void **) &dGeomGetCategoryBits},
1302 // {"dGeomGetCollideBits", (void **) &dGeomGetCollideBits},
1303 // {"dGeomEnable", (void **) &dGeomEnable},
1304 // {"dGeomDisable", (void **) &dGeomDisable},
1305 // {"dGeomIsEnabled", (void **) &dGeomIsEnabled},
1306 // {"dGeomSetOffsetPosition", (void **) &dGeomSetOffsetPosition},
1307 // {"dGeomSetOffsetRotation", (void **) &dGeomSetOffsetRotation},
1308 // {"dGeomSetOffsetQuaternion", (void **) &dGeomSetOffsetQuaternion},
1309 // {"dGeomSetOffsetWorldPosition", (void **) &dGeomSetOffsetWorldPosition},
1310 // {"dGeomSetOffsetWorldRotation", (void **) &dGeomSetOffsetWorldRotation},
1311 // {"dGeomSetOffsetWorldQuaternion", (void **) &dGeomSetOffsetWorldQuaternion},
1312 // {"dGeomClearOffset", (void **) &dGeomClearOffset},
1313 // {"dGeomIsOffset", (void **) &dGeomIsOffset},
1314 // {"dGeomGetOffsetPosition", (void **) &dGeomGetOffsetPosition},
1315 // {"dGeomCopyOffsetPosition", (void **) &dGeomCopyOffsetPosition},
1316 // {"dGeomGetOffsetRotation", (void **) &dGeomGetOffsetRotation},
1317 // {"dGeomCopyOffsetRotation", (void **) &dGeomCopyOffsetRotation},
1318 // {"dGeomGetOffsetQuaternion", (void **) &dGeomGetOffsetQuaternion},
1319 {"dCollide", (void **) &dCollide},
1320 {"dSpaceCollide", (void **) &dSpaceCollide},
1321 {"dSpaceCollide2", (void **) &dSpaceCollide2},
1322 {"dCreateSphere", (void **) &dCreateSphere},
1323 // {"dGeomSphereSetRadius", (void **) &dGeomSphereSetRadius},
1324 // {"dGeomSphereGetRadius", (void **) &dGeomSphereGetRadius},
1325 // {"dGeomSpherePointDepth", (void **) &dGeomSpherePointDepth},
1326 // {"dCreateConvex", (void **) &dCreateConvex},
1327 // {"dGeomSetConvex", (void **) &dGeomSetConvex},
1328 {"dCreateBox", (void **) &dCreateBox},
1329 // {"dGeomBoxSetLengths", (void **) &dGeomBoxSetLengths},
1330 // {"dGeomBoxGetLengths", (void **) &dGeomBoxGetLengths},
1331 // {"dGeomBoxPointDepth", (void **) &dGeomBoxPointDepth},
1332 // {"dGeomBoxPointDepth", (void **) &dGeomBoxPointDepth},
1333 // {"dCreatePlane", (void **) &dCreatePlane},
1334 // {"dGeomPlaneSetParams", (void **) &dGeomPlaneSetParams},
1335 // {"dGeomPlaneGetParams", (void **) &dGeomPlaneGetParams},
1336 // {"dGeomPlanePointDepth", (void **) &dGeomPlanePointDepth},
1337 {"dCreateCapsule", (void **) &dCreateCapsule},
1338 // {"dGeomCapsuleSetParams", (void **) &dGeomCapsuleSetParams},
1339 // {"dGeomCapsuleGetParams", (void **) &dGeomCapsuleGetParams},
1340 // {"dGeomCapsulePointDepth", (void **) &dGeomCapsulePointDepth},
1341 // {"dCreateCylinder", (void **) &dCreateCylinder},
1342 // {"dGeomCylinderSetParams", (void **) &dGeomCylinderSetParams},
1343 // {"dGeomCylinderGetParams", (void **) &dGeomCylinderGetParams},
1344 // {"dCreateRay", (void **) &dCreateRay},
1345 // {"dGeomRaySetLength", (void **) &dGeomRaySetLength},
1346 // {"dGeomRayGetLength", (void **) &dGeomRayGetLength},
1347 // {"dGeomRaySet", (void **) &dGeomRaySet},
1348 // {"dGeomRayGet", (void **) &dGeomRayGet},
1349 {"dCreateGeomTransform", (void **) &dCreateGeomTransform},
1350 {"dGeomTransformSetGeom", (void **) &dGeomTransformSetGeom},
1351 // {"dGeomTransformGetGeom", (void **) &dGeomTransformGetGeom},
1352 {"dGeomTransformSetCleanup", (void **) &dGeomTransformSetCleanup},
1353 // {"dGeomTransformGetCleanup", (void **) &dGeomTransformGetCleanup},
1354 // {"dGeomTransformSetInfo", (void **) &dGeomTransformSetInfo},
1355 // {"dGeomTransformGetInfo", (void **) &dGeomTransformGetInfo},
1356 {"dGeomTriMeshDataCreate", (void **) &dGeomTriMeshDataCreate},
1357 {"dGeomTriMeshDataDestroy", (void **) &dGeomTriMeshDataDestroy},
1358 // {"dGeomTriMeshDataSet", (void **) &dGeomTriMeshDataSet},
1359 // {"dGeomTriMeshDataGet", (void **) &dGeomTriMeshDataGet},
1360 // {"dGeomTriMeshSetLastTransform", (void **) &dGeomTriMeshSetLastTransform},
1361 // {"dGeomTriMeshGetLastTransform", (void **) &dGeomTriMeshGetLastTransform},
1362 {"dGeomTriMeshDataBuildSingle", (void **) &dGeomTriMeshDataBuildSingle},
1363 // {"dGeomTriMeshDataBuildSingle1", (void **) &dGeomTriMeshDataBuildSingle1},
1364 // {"dGeomTriMeshDataBuildDouble", (void **) &dGeomTriMeshDataBuildDouble},
1365 // {"dGeomTriMeshDataBuildDouble1", (void **) &dGeomTriMeshDataBuildDouble1},
1366 // {"dGeomTriMeshDataBuildSimple", (void **) &dGeomTriMeshDataBuildSimple},
1367 // {"dGeomTriMeshDataBuildSimple1", (void **) &dGeomTriMeshDataBuildSimple1},
1368 // {"dGeomTriMeshDataPreprocess", (void **) &dGeomTriMeshDataPreprocess},
1369 // {"dGeomTriMeshDataGetBuffer", (void **) &dGeomTriMeshDataGetBuffer},
1370 // {"dGeomTriMeshDataSetBuffer", (void **) &dGeomTriMeshDataSetBuffer},
1371 // {"dGeomTriMeshSetCallback", (void **) &dGeomTriMeshSetCallback},
1372 // {"dGeomTriMeshGetCallback", (void **) &dGeomTriMeshGetCallback},
1373 // {"dGeomTriMeshSetArrayCallback", (void **) &dGeomTriMeshSetArrayCallback},
1374 // {"dGeomTriMeshGetArrayCallback", (void **) &dGeomTriMeshGetArrayCallback},
1375 // {"dGeomTriMeshSetRayCallback", (void **) &dGeomTriMeshSetRayCallback},
1376 // {"dGeomTriMeshGetRayCallback", (void **) &dGeomTriMeshGetRayCallback},
1377 // {"dGeomTriMeshSetTriMergeCallback", (void **) &dGeomTriMeshSetTriMergeCallback},
1378 // {"dGeomTriMeshGetTriMergeCallback", (void **) &dGeomTriMeshGetTriMergeCallback},
1379 {"dCreateTriMesh", (void **) &dCreateTriMesh},
1380 // {"dGeomTriMeshSetData", (void **) &dGeomTriMeshSetData},
1381 // {"dGeomTriMeshGetData", (void **) &dGeomTriMeshGetData},
1382 // {"dGeomTriMeshEnableTC", (void **) &dGeomTriMeshEnableTC},
1383 // {"dGeomTriMeshIsTCEnabled", (void **) &dGeomTriMeshIsTCEnabled},
1384 // {"dGeomTriMeshClearTCCache", (void **) &dGeomTriMeshClearTCCache},
1385 // {"dGeomTriMeshGetTriMeshDataID", (void **) &dGeomTriMeshGetTriMeshDataID},
1386 // {"dGeomTriMeshGetTriangle", (void **) &dGeomTriMeshGetTriangle},
1387 // {"dGeomTriMeshGetPoint", (void **) &dGeomTriMeshGetPoint},
1388 // {"dGeomTriMeshGetTriangleCount", (void **) &dGeomTriMeshGetTriangleCount},
1389 // {"dGeomTriMeshDataUpdate", (void **) &dGeomTriMeshDataUpdate},
1393 // Handle for ODE DLL
1394 dllhandle_t ode_dll = NULL;
1398 static void World_Physics_Init(void)
1402 const char* dllnames [] =
1406 # elif defined(WIN32)
1408 # elif defined(MACOSX)
1417 Cvar_RegisterVariable(&physics_ode_quadtree_depth);
1418 Cvar_RegisterVariable(&physics_ode_contactsurfacelayer);
1419 Cvar_RegisterVariable(&physics_ode_worldquickstep);
1420 Cvar_RegisterVariable(&physics_ode_worldquickstep_iterations);
1421 Cvar_RegisterVariable(&physics_ode_worldstepfast);
1422 Cvar_RegisterVariable(&physics_ode_worldstepfast_iterations);
1423 Cvar_RegisterVariable(&physics_ode_contact_mu);
1424 Cvar_RegisterVariable(&physics_ode_contact_erp);
1425 Cvar_RegisterVariable(&physics_ode_contact_cfm);
1426 Cvar_RegisterVariable(&physics_ode_iterationsperframe);
1427 Cvar_RegisterVariable(&physics_ode_movelimit);
1428 Cvar_RegisterVariable(&physics_ode_spinlimit);
1432 if (Sys_LoadLibrary (dllnames, &ode_dll, odefuncs))
1439 if (!dCheckConfiguration("ODE_single_precision"))
1441 if (!dCheckConfiguration("ODE_double_precision"))
1445 Con_Printf("ode library not compiled for single precision - incompatible! Not using ODE physics.\n");
1447 Con_Printf("ode library not compiled for double precision - incompatible! Not using ODE physics.\n");
1449 Sys_UnloadLibrary(&ode_dll);
1457 static void World_Physics_Shutdown(void)
1466 Sys_UnloadLibrary(&ode_dll);
1474 static void World_Physics_EnableODE(world_t *world)
1476 dVector3 center, extents;
1477 if (world->physics.ode)
1483 world->physics.ode = true;
1484 VectorMAM(0.5f, world->mins, 0.5f, world->maxs, center);
1485 VectorSubtract(world->maxs, center, extents);
1486 world->physics.ode_world = dWorldCreate();
1487 world->physics.ode_space = dQuadTreeSpaceCreate(NULL, center, extents, bound(1, physics_ode_quadtree_depth.integer, 10));
1488 world->physics.ode_contactgroup = dJointGroupCreate(0);
1489 // we don't currently set dWorldSetCFM or dWorldSetERP because the defaults seem fine
1493 static void World_Physics_Start(world_t *world)
1496 if (world->physics.ode)
1498 World_Physics_EnableODE(world);
1502 static void World_Physics_End(world_t *world)
1505 if (world->physics.ode)
1507 dWorldDestroy(world->physics.ode_world);
1508 dSpaceDestroy(world->physics.ode_space);
1509 dJointGroupDestroy(world->physics.ode_contactgroup);
1510 world->physics.ode = false;
1515 void World_Physics_RemoveFromEntity(world_t *world, prvm_edict_t *ed)
1517 // entity is not physics controlled, free any physics data
1518 ed->priv.server->ode_physics = false;
1520 if (ed->priv.server->ode_geom)
1521 dGeomDestroy((dGeomID)ed->priv.server->ode_geom);
1522 ed->priv.server->ode_geom = NULL;
1523 if (ed->priv.server->ode_body)
1524 dBodyDestroy((dBodyID)ed->priv.server->ode_body);
1525 ed->priv.server->ode_body = NULL;
1527 if (ed->priv.server->ode_vertex3f)
1528 Mem_Free(ed->priv.server->ode_vertex3f);
1529 ed->priv.server->ode_vertex3f = NULL;
1530 ed->priv.server->ode_numvertices = 0;
1531 if (ed->priv.server->ode_element3i)
1532 Mem_Free(ed->priv.server->ode_element3i);
1533 ed->priv.server->ode_element3i = NULL;
1534 ed->priv.server->ode_numtriangles = 0;
1538 static void World_Physics_Frame_BodyToEntity(world_t *world, prvm_edict_t *ed)
1542 const dReal *r; // for some reason dBodyGetRotation returns a [3][4] matrix
1544 dBodyID body = (dBodyID)ed->priv.server->ode_body;
1546 matrix4x4_t bodymatrix;
1547 matrix4x4_t entitymatrix;
1551 vec3_t forward, left, up;
1553 vec3_t spinvelocity;
1557 val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.movetype);
1558 movetype = (int)val->_float;
1559 if (movetype != MOVETYPE_PHYSICS)
1561 // store the physics engine data into the entity
1562 o = dBodyGetPosition(body);
1563 r = dBodyGetRotation(body);
1564 vel = dBodyGetLinearVel(body);
1565 avel = dBodyGetAngularVel(body);
1566 VectorCopy(o, origin);
1576 VectorCopy(vel, velocity);
1577 VectorCopy(avel, spinvelocity);
1578 Matrix4x4_FromVectors(&bodymatrix, forward, left, up, origin);
1579 Matrix4x4_Concat(&entitymatrix, &bodymatrix, &ed->priv.server->ode_offsetimatrix);
1580 Matrix4x4_ToVectors(&entitymatrix, forward, left, up, origin);
1582 AnglesFromVectors(angles, forward, up, true);
1583 VectorSet(avelocity, RAD2DEG(spinvelocity[PITCH]), RAD2DEG(spinvelocity[ROLL]), RAD2DEG(spinvelocity[YAW]));
1585 val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.origin);if (val) VectorCopy(origin, val->vector);
1586 val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.velocity);if (val) VectorCopy(velocity, val->vector);
1587 //val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.axis_forward);if (val) VectorCopy(forward, val->vector);
1588 //val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.axis_left);if (val) VectorCopy(left, val->vector);
1589 //val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.axis_up);if (val) VectorCopy(up, val->vector);
1590 //val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.spinvelocity);if (val) VectorCopy(spinvelocity, val->vector);
1591 val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.angles);if (val) VectorCopy(angles, val->vector);
1592 val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.avelocity);if (val) VectorCopy(avelocity, val->vector);
1594 // values for BodyFromEntity to check if the qc modified anything later
1595 VectorCopy(origin, ed->priv.server->ode_origin);
1596 VectorCopy(velocity, ed->priv.server->ode_velocity);
1597 VectorCopy(angles, ed->priv.server->ode_angles);
1598 VectorCopy(avelocity, ed->priv.server->ode_avelocity);
1599 ed->priv.server->ode_gravity = dBodyGetGravityMode(body);
1602 static void World_Physics_Frame_BodyFromEntity(world_t *world, prvm_edict_t *ed)
1606 dBodyID body = (dBodyID)ed->priv.server->ode_body;
1610 dVector3 capsulerot[3];
1616 int movetype = MOVETYPE_NONE;
1619 int solid = SOLID_NOT;
1624 qboolean modified = false;
1634 vec3_t spinvelocity;
1639 vec_t massval = 1.0f;
1649 val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.solid);if (val) solid = (int)val->_float;
1650 val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.movetype);if (val) movetype = (int)val->_float;
1651 val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.movetype);if (val && val->_float) scale = val->_float;
1656 val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.modelindex);
1658 modelindex = (int)val->_float;
1659 if (world == &sv.world && modelindex >= 1 && modelindex < MAX_MODELS)
1661 model = sv.models[modelindex];
1662 mempool = sv_mempool;
1664 else if (world == &cl.world && modelindex >= 1 && modelindex < MAX_MODELS)
1666 model = cl.model_precache[modelindex];
1667 mempool = cls.levelmempool;
1677 VectorScale(model->normalmins, scale, entmins);
1678 VectorScale(model->normalmaxs, scale, entmaxs);
1679 val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.mass);if (val) massval = val->_float;
1688 //case SOLID_SLIDEBOX:
1690 case SOLID_PHYSICS_BOX:
1691 case SOLID_PHYSICS_SPHERE:
1692 case SOLID_PHYSICS_CAPSULE:
1693 val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.mins);if (val) VectorCopy(val->vector, entmins);
1694 val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.maxs);if (val) VectorCopy(val->vector, entmaxs);
1695 val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.mass);if (val) massval = val->_float;
1698 if (ed->priv.server->ode_physics)
1699 World_Physics_RemoveFromEntity(world, ed);
1703 VectorSubtract(entmaxs, entmins, geomsize);
1704 if (VectorLength2(geomsize) == 0)
1706 // we don't allow point-size physics objects...
1707 if (ed->priv.server->ode_physics)
1708 World_Physics_RemoveFromEntity(world, ed);
1712 if (movetype != MOVETYPE_PHYSICS)
1715 // check if we need to create or replace the geom
1716 if (!ed->priv.server->ode_physics
1717 || !VectorCompare(ed->priv.server->ode_mins, entmins)
1718 || !VectorCompare(ed->priv.server->ode_maxs, entmaxs)
1719 || ed->priv.server->ode_mass != massval
1720 || ed->priv.server->ode_modelindex != modelindex)
1723 World_Physics_RemoveFromEntity(world, ed);
1724 ed->priv.server->ode_physics = true;
1725 VectorCopy(entmins, ed->priv.server->ode_mins);
1726 VectorCopy(entmaxs, ed->priv.server->ode_maxs);
1727 ed->priv.server->ode_mass = massval;
1728 ed->priv.server->ode_modelindex = modelindex;
1729 VectorMAM(0.5f, entmins, 0.5f, entmaxs, geomcenter);
1730 ed->priv.server->ode_movelimit = min(geomsize[0], min(geomsize[1], geomsize[2]));
1732 if (massval * geomsize[0] * geomsize[1] * geomsize[2] == 0)
1734 if (movetype == MOVETYPE_PHYSICS)
1735 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));
1737 VectorSet(geomsize, 1.0f, 1.0f, 1.0f);
1743 ed->priv.server->ode_offsetmatrix = identitymatrix;
1746 Con_Printf("entity %i (classname %s) has no model\n", PRVM_NUM_FOR_EDICT(ed), PRVM_GetString(PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.classname)->string));
1749 // add an optimized mesh to the model containing only the SUPERCONTENTS_SOLID surfaces
1750 if (!model->brush.collisionmesh)
1751 Mod_CreateCollisionMesh(model);
1752 if (!model->brush.collisionmesh || !model->brush.collisionmesh->numtriangles)
1754 Con_Printf("entity %i (classname %s) has no geometry\n", PRVM_NUM_FOR_EDICT(ed), PRVM_GetString(PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.classname)->string));
1757 // ODE requires persistent mesh storage, so we need to copy out
1758 // the data from the model because renderer restarts could free it
1759 // during the game, additionally we need to flip the triangles...
1760 // note: ODE does preprocessing of the mesh for culling, removing
1761 // concave edges, etc., so this is not a lightweight operation
1762 ed->priv.server->ode_numvertices = numvertices = model->brush.collisionmesh->numverts;
1763 ed->priv.server->ode_vertex3f = (float *)Mem_Alloc(mempool, numvertices * sizeof(float[3]));
1764 for (vertexindex = 0, ov = ed->priv.server->ode_vertex3f, iv = model->brush.collisionmesh->vertex3f;vertexindex < numvertices;vertexindex++, ov += 3, iv += 3)
1766 ov[0] = iv[0] - geomcenter[0];
1767 ov[1] = iv[1] - geomcenter[1];
1768 ov[2] = iv[2] - geomcenter[2];
1770 ed->priv.server->ode_numtriangles = numtriangles = model->brush.collisionmesh->numtriangles;
1771 ed->priv.server->ode_element3i = (int *)Mem_Alloc(mempool, numtriangles * sizeof(int[3]));
1772 //memcpy(ed->priv.server->ode_element3i, model->brush.collisionmesh->element3i, ed->priv.server->ode_numtriangles * sizeof(int[3]));
1773 for (triangleindex = 0, oe = ed->priv.server->ode_element3i, ie = model->brush.collisionmesh->element3i;triangleindex < numtriangles;triangleindex++, oe += 3, ie += 3)
1779 Matrix4x4_CreateTranslate(&ed->priv.server->ode_offsetmatrix, geomcenter[0], geomcenter[1], geomcenter[2]);
1780 // now create the geom
1781 dataID = dGeomTriMeshDataCreate();
1782 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]));
1783 ed->priv.server->ode_body = (void *)(body = dBodyCreate(world->physics.ode_world));
1784 ed->priv.server->ode_geom = (void *)dCreateTriMesh(world->physics.ode_space, dataID, NULL, NULL, NULL);
1785 dGeomSetBody(ed->priv.server->ode_geom, body);
1786 dMassSetBoxTotal(&mass, massval, geomsize[0], geomsize[1], geomsize[2]);
1789 case SOLID_SLIDEBOX:
1791 case SOLID_PHYSICS_BOX:
1792 Matrix4x4_CreateTranslate(&ed->priv.server->ode_offsetmatrix, geomcenter[0], geomcenter[1], geomcenter[2]);
1793 ed->priv.server->ode_body = (void *)(body = dBodyCreate(world->physics.ode_world));
1794 ed->priv.server->ode_geom = (void *)dCreateBox(world->physics.ode_space, geomsize[0], geomsize[1], geomsize[2]);
1795 dMassSetBoxTotal(&mass, massval, geomsize[0], geomsize[1], geomsize[2]);
1796 dGeomSetBody(ed->priv.server->ode_geom, body);
1797 dBodySetMass(body, &mass);
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);
1808 case SOLID_PHYSICS_CAPSULE:
1810 if (geomsize[axisindex] < geomsize[1])
1812 if (geomsize[axisindex] < geomsize[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
1818 memset(capsulerot, 0, sizeof(capsulerot));
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);
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);
1837 Sys_Error("World_Physics_BodyFromEntity: unrecognized solid value %i was accepted by filter\n", solid);
1839 Matrix4x4_Invert_Simple(&ed->priv.server->ode_offsetimatrix, &ed->priv.server->ode_offsetmatrix);
1842 // get current data from entity
1843 VectorClear(origin);
1844 VectorClear(velocity);
1845 //VectorClear(forward);
1846 //VectorClear(left);
1848 //VectorClear(spinvelocity);
1849 VectorClear(angles);
1850 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 val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.gravity);if (val) { if(val->_float != 0.0f && val->_float < 0.5f) gravity = false; }
1862 // compatibility for legacy entities
1863 //if (!VectorLength2(forward) || solid == SOLID_BSP)
1865 AngleVectorsFLU(angles, forward, left, up);
1866 // convert single-axis rotations in avelocity to spinvelocity
1867 // FIXME: untested math - check signs
1868 VectorSet(spinvelocity, DEG2RAD(avelocity[PITCH]), DEG2RAD(avelocity[ROLL]), DEG2RAD(avelocity[YAW]));
1871 // compatibility for legacy entities
1875 case SOLID_SLIDEBOX:
1877 VectorSet(forward, 1, 0, 0);
1878 VectorSet(left, 0, 1, 0);
1879 VectorSet(up, 0, 0, 1);
1880 VectorSet(spinvelocity, 0, 0, 0);
1885 // we must prevent NANs...
1886 test = VectorLength2(origin) + VectorLength2(forward) + VectorLength2(left) + VectorLength2(up) + VectorLength2(velocity) + VectorLength2(spinvelocity);
1890 //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]);
1891 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]);
1892 test = VectorLength2(origin);
1894 VectorClear(origin);
1895 test = VectorLength2(forward) * VectorLength2(left) * VectorLength2(up);
1898 VectorSet(angles, 0, 0, 0);
1899 VectorSet(forward, 1, 0, 0);
1900 VectorSet(left, 0, 1, 0);
1901 VectorSet(up, 0, 0, 1);
1903 test = VectorLength2(velocity);
1905 VectorClear(velocity);
1906 test = VectorLength2(spinvelocity);
1909 VectorClear(avelocity);
1910 VectorClear(spinvelocity);
1914 // limit movement speed to prevent missed collisions at high speed
1915 movelimit = ed->priv.server->ode_movelimit * world->physics.ode_movelimit;
1916 test = VectorLength2(velocity);
1917 if (test > movelimit*movelimit)
1920 // scale down linear velocity to the movelimit
1921 // scale down angular velocity the same amount for consistency
1922 f = movelimit / sqrt(test);
1923 VectorScale(velocity, f, velocity);
1924 VectorScale(avelocity, f, avelocity);
1925 VectorScale(spinvelocity, f, spinvelocity);
1928 // make sure the angular velocity is not exploding
1929 spinlimit = physics_ode_spinlimit.value;
1930 test = VectorLength2(spinvelocity);
1931 if (test > spinlimit)
1934 VectorClear(avelocity);
1935 VectorClear(spinvelocity);
1938 // check if the qc edited any position data
1939 if (!VectorCompare(origin, ed->priv.server->ode_origin)
1940 || !VectorCompare(velocity, ed->priv.server->ode_velocity)
1941 || !VectorCompare(angles, ed->priv.server->ode_angles)
1942 || !VectorCompare(avelocity, ed->priv.server->ode_avelocity)
1943 || gravity != ed->priv.server->ode_gravity)
1946 // store the qc values into the physics engine
1947 body = ed->priv.server->ode_body;
1948 if (body && modified)
1951 matrix4x4_t entitymatrix;
1952 matrix4x4_t bodymatrix;
1953 Matrix4x4_FromVectors(&entitymatrix, forward, left, up, origin);
1954 Matrix4x4_Concat(&bodymatrix, &entitymatrix, &ed->priv.server->ode_offsetmatrix);
1955 Matrix4x4_ToVectors(&bodymatrix, forward, left, up, origin);
1956 r[0][0] = forward[0];
1957 r[1][0] = forward[1];
1958 r[2][0] = forward[2];
1965 dGeomSetBody(ed->priv.server->ode_geom, ed->priv.server->ode_body);
1966 dBodySetPosition(body, origin[0], origin[1], origin[2]);
1967 dBodySetRotation(body, r[0]);
1968 dBodySetLinearVel(body, velocity[0], velocity[1], velocity[2]);
1969 dBodySetAngularVel(body, spinvelocity[0], spinvelocity[1], spinvelocity[2]);
1970 dBodySetGravityMode(body, gravity);
1971 dBodySetData(body, (void*)ed);
1972 // setting body to NULL makes an immovable object
1973 if (movetype != MOVETYPE_PHYSICS)
1974 dGeomSetBody(ed->priv.server->ode_geom, 0);
1978 #define MAX_CONTACTS 16
1979 static void nearCallback (void *data, dGeomID o1, dGeomID o2)
1981 world_t *world = (world_t *)data;
1982 dContact contact[MAX_CONTACTS]; // max contacts per collision pair
1989 float bouncefactor1 = 0.0f;
1990 float bouncestop1 = 60.0f / 800.0f;
1991 float bouncefactor2 = 0.0f;
1992 float bouncestop2 = 60.0f / 800.0f;
1996 if (dGeomIsSpace(o1) || dGeomIsSpace(o2))
1998 // colliding a space with something
1999 dSpaceCollide2(o1, o2, data, &nearCallback);
2000 // Note we do not want to test intersections within a space,
2001 // only between spaces.
2002 //if (dGeomIsSpace(o1)) dSpaceCollide(o1, data, &nearCallback);
2003 //if (dGeomIsSpace(o2)) dSpaceCollide(o2, data, &nearCallback);
2007 b1 = dGeomGetBody(o1);
2008 b2 = dGeomGetBody(o2);
2010 // at least one object has to be using MOVETYPE_PHYSICS or we just don't care
2014 // exit without doing anything if the two bodies are connected by a joint
2015 if (b1 && b2 && dAreConnectedExcluding(b1, b2, dJointTypeContact))
2020 ed = (prvm_edict_t *) dBodyGetData(b1);
2023 val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.bouncefactor);
2024 if (val!=0 && val->_float)
2025 bouncefactor1 = val->_float;
2027 val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.bouncestop);
2028 if (val!=0 && val->_float)
2029 bouncestop1 = val->_float;
2035 ed = (prvm_edict_t *) dBodyGetData(b2);
2038 val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.bouncefactor);
2039 if (val!=0 && val->_float)
2040 bouncefactor2 = val->_float;
2042 val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.bouncestop);
2043 if (val!=0 && val->_float)
2044 bouncestop2 = val->_float;
2048 // merge bounce factors and bounce stop
2049 if(bouncefactor2 > 0)
2051 if(bouncefactor1 > 0)
2053 // TODO possibly better logic to merge bounce factor data?
2054 if(bouncestop2 < bouncestop1)
2055 bouncestop1 = bouncestop2;
2056 if(bouncefactor2 > bouncefactor1)
2057 bouncefactor1 = bouncefactor2;
2061 bouncestop1 = bouncestop2;
2062 bouncefactor1 = bouncefactor2;
2065 dWorldGetGravity(world->physics.ode_world, grav);
2066 bouncestop1 *= fabs(grav[2]);
2068 // generate contact points between the two non-space geoms
2069 numcontacts = dCollide(o1, o2, MAX_CONTACTS, &(contact[0].geom), sizeof(contact[0]));
2070 // add these contact points to the simulation
2071 for (i = 0;i < numcontacts;i++)
2073 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) | (bouncefactor1 > 0 ? dContactBounce : 0);
2074 contact[i].surface.mu = physics_ode_contact_mu.value;
2075 contact[i].surface.soft_erp = physics_ode_contact_erp.value;
2076 contact[i].surface.soft_cfm = physics_ode_contact_cfm.value;
2077 contact[i].surface.bounce = bouncefactor1;
2078 contact[i].surface.bounce_vel = bouncestop1;
2079 c = dJointCreateContact(world->physics.ode_world, world->physics.ode_contactgroup, contact + i);
2080 dJointAttach(c, b1, b2);
2085 void World_Physics_Frame(world_t *world, double frametime, double gravity)
2088 if (world->physics.ode)
2093 // copy physics properties from entities to physics engine
2095 for (i = 0, ed = prog->edicts + i;i < prog->num_edicts;i++, ed++)
2096 if (!prog->edicts[i].priv.required->free)
2097 World_Physics_Frame_BodyFromEntity(world, ed);
2099 world->physics.ode_iterations = bound(1, physics_ode_iterationsperframe.integer, 1000);
2100 world->physics.ode_step = frametime / world->physics.ode_iterations;
2101 world->physics.ode_movelimit = physics_ode_movelimit.value / world->physics.ode_step;
2102 for (i = 0;i < world->physics.ode_iterations;i++)
2105 dWorldSetGravity(world->physics.ode_world, 0, 0, -gravity);
2106 // set the tolerance for closeness of objects
2107 dWorldSetContactSurfaceLayer(world->physics.ode_world, max(0, physics_ode_contactsurfacelayer.value));
2109 // run collisions for the current world state, creating JointGroup
2110 dSpaceCollide(world->physics.ode_space, (void *)world, nearCallback);
2112 // run physics (move objects, calculate new velocities)
2113 if (physics_ode_worldquickstep.integer)
2115 dWorldSetQuickStepNumIterations(world->physics.ode_world, bound(1, physics_ode_worldquickstep_iterations.integer, 200));
2116 dWorldQuickStep(world->physics.ode_world, world->physics.ode_step);
2118 else if (physics_ode_worldstepfast.integer)
2119 dWorldStepFast1(world->physics.ode_world, world->physics.ode_step, bound(1, physics_ode_worldstepfast_iterations.integer, 200));
2121 dWorldStep(world->physics.ode_world, world->physics.ode_step);
2123 // clear the JointGroup now that we're done with it
2124 dJointGroupEmpty(world->physics.ode_contactgroup);
2127 // copy physics properties from physics engine to entities
2129 for (i = 1, ed = prog->edicts + i;i < prog->num_edicts;i++, ed++)
2130 if (!prog->edicts[i].priv.required->free && PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.movetype)->_float == MOVETYPE_PHYSICS)
2131 World_Physics_Frame_BodyToEntity(world, ed);