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
23 #include "clvm_cmds.h"
27 entities never clip against themselves, or their owner
29 line of sight checks trace->inopen and trace->inwater, but bullets don't
33 static void World_Physics_Init(void);
40 static void World_Physics_Shutdown(void);
41 void World_Shutdown(void)
43 World_Physics_Shutdown();
46 static void World_Physics_Start(world_t *world);
47 void World_Start(world_t *world)
49 World_Physics_Start(world);
52 static void World_Physics_End(world_t *world);
53 void World_End(world_t *world)
55 World_Physics_End(world);
58 //============================================================================
60 /// World_ClearLink is used for new headnodes
61 void World_ClearLink (link_t *l)
64 l->prev = l->next = l;
67 void World_RemoveLink (link_t *l)
69 l->next->prev = l->prev;
70 l->prev->next = l->next;
73 void World_InsertLinkBefore (link_t *l, link_t *before, int entitynumber)
75 l->entitynumber = entitynumber;
77 l->prev = before->prev;
83 ===============================================================================
87 ===============================================================================
90 void World_PrintAreaStats(world_t *world, const char *worldname)
92 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);
93 world->areagrid_stats_calls = 0;
94 world->areagrid_stats_nodechecks = 0;
95 world->areagrid_stats_entitychecks = 0;
104 void World_SetSize(world_t *world, const char *filename, const vec3_t mins, const vec3_t maxs)
108 strlcpy(world->filename, filename, sizeof(world->filename));
109 VectorCopy(mins, world->mins);
110 VectorCopy(maxs, world->maxs);
112 // the areagrid_marknumber is not allowed to be 0
113 if (world->areagrid_marknumber < 1)
114 world->areagrid_marknumber = 1;
115 // choose either the world box size, or a larger box to ensure the grid isn't too fine
116 world->areagrid_size[0] = max(world->areagrid_maxs[0] - world->areagrid_mins[0], AREA_GRID * sv_areagrid_mingridsize.value);
117 world->areagrid_size[1] = max(world->areagrid_maxs[1] - world->areagrid_mins[1], AREA_GRID * sv_areagrid_mingridsize.value);
118 world->areagrid_size[2] = max(world->areagrid_maxs[2] - world->areagrid_mins[2], AREA_GRID * sv_areagrid_mingridsize.value);
119 // figure out the corners of such a box, centered at the center of the world box
120 world->areagrid_mins[0] = (world->areagrid_mins[0] + world->areagrid_maxs[0] - world->areagrid_size[0]) * 0.5f;
121 world->areagrid_mins[1] = (world->areagrid_mins[1] + world->areagrid_maxs[1] - world->areagrid_size[1]) * 0.5f;
122 world->areagrid_mins[2] = (world->areagrid_mins[2] + world->areagrid_maxs[2] - world->areagrid_size[2]) * 0.5f;
123 world->areagrid_maxs[0] = (world->areagrid_mins[0] + world->areagrid_maxs[0] + world->areagrid_size[0]) * 0.5f;
124 world->areagrid_maxs[1] = (world->areagrid_mins[1] + world->areagrid_maxs[1] + world->areagrid_size[1]) * 0.5f;
125 world->areagrid_maxs[2] = (world->areagrid_mins[2] + world->areagrid_maxs[2] + world->areagrid_size[2]) * 0.5f;
126 // now calculate the actual useful info from that
127 VectorNegate(world->areagrid_mins, world->areagrid_bias);
128 world->areagrid_scale[0] = AREA_GRID / world->areagrid_size[0];
129 world->areagrid_scale[1] = AREA_GRID / world->areagrid_size[1];
130 world->areagrid_scale[2] = AREA_GRID / world->areagrid_size[2];
131 World_ClearLink(&world->areagrid_outside);
132 for (i = 0;i < AREA_GRIDNODES;i++)
133 World_ClearLink(&world->areagrid[i]);
134 if (developer.integer >= 10)
135 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);
144 void World_UnlinkAll(world_t *world)
148 // unlink all entities one by one
149 grid = &world->areagrid_outside;
150 while (grid->next != grid)
151 World_UnlinkEdict(PRVM_EDICT_NUM(grid->next->entitynumber));
152 for (i = 0, grid = world->areagrid;i < AREA_GRIDNODES;i++, grid++)
153 while (grid->next != grid)
154 World_UnlinkEdict(PRVM_EDICT_NUM(grid->next->entitynumber));
162 void World_UnlinkEdict(prvm_edict_t *ent)
165 for (i = 0;i < ENTITYGRIDAREAS;i++)
167 if (ent->priv.server->areagrid[i].prev)
169 World_RemoveLink (&ent->priv.server->areagrid[i]);
170 ent->priv.server->areagrid[i].prev = ent->priv.server->areagrid[i].next = NULL;
175 int World_EntitiesInBox(world_t *world, const vec3_t mins, const vec3_t maxs, int maxlist, prvm_edict_t **list)
181 int igrid[3], igridmins[3], igridmaxs[3];
183 // FIXME: if areagrid_marknumber wraps, all entities need their
184 // ent->priv.server->areagridmarknumber reset
185 world->areagrid_stats_calls++;
186 world->areagrid_marknumber++;
187 igridmins[0] = (int) floor((mins[0] + world->areagrid_bias[0]) * world->areagrid_scale[0]);
188 igridmins[1] = (int) floor((mins[1] + world->areagrid_bias[1]) * world->areagrid_scale[1]);
189 //igridmins[2] = (int) ((mins[2] + world->areagrid_bias[2]) * world->areagrid_scale[2]);
190 igridmaxs[0] = (int) floor((maxs[0] + world->areagrid_bias[0]) * world->areagrid_scale[0]) + 1;
191 igridmaxs[1] = (int) floor((maxs[1] + world->areagrid_bias[1]) * world->areagrid_scale[1]) + 1;
192 //igridmaxs[2] = (int) ((maxs[2] + world->areagrid_bias[2]) * world->areagrid_scale[2]) + 1;
193 igridmins[0] = max(0, igridmins[0]);
194 igridmins[1] = max(0, igridmins[1]);
195 //igridmins[2] = max(0, igridmins[2]);
196 igridmaxs[0] = min(AREA_GRID, igridmaxs[0]);
197 igridmaxs[1] = min(AREA_GRID, igridmaxs[1]);
198 //igridmaxs[2] = min(AREA_GRID, igridmaxs[2]);
201 // add entities not linked into areagrid because they are too big or
202 // outside the grid bounds
203 if (world->areagrid_outside.next != &world->areagrid_outside)
205 grid = &world->areagrid_outside;
206 for (l = grid->next;l != grid;l = l->next)
208 ent = PRVM_EDICT_NUM(l->entitynumber);
209 if (ent->priv.server->areagridmarknumber != world->areagrid_marknumber)
211 ent->priv.server->areagridmarknumber = world->areagrid_marknumber;
212 if (!ent->priv.server->free && BoxesOverlap(mins, maxs, ent->priv.server->areamins, ent->priv.server->areamaxs))
214 if (numlist < maxlist)
218 world->areagrid_stats_entitychecks++;
222 // add grid linked entities
223 for (igrid[1] = igridmins[1];igrid[1] < igridmaxs[1];igrid[1]++)
225 grid = world->areagrid + igrid[1] * AREA_GRID + igridmins[0];
226 for (igrid[0] = igridmins[0];igrid[0] < igridmaxs[0];igrid[0]++, grid++)
228 if (grid->next != grid)
230 for (l = grid->next;l != grid;l = l->next)
232 ent = PRVM_EDICT_NUM(l->entitynumber);
233 if (ent->priv.server->areagridmarknumber != world->areagrid_marknumber)
235 ent->priv.server->areagridmarknumber = world->areagrid_marknumber;
236 if (!ent->priv.server->free && BoxesOverlap(mins, maxs, ent->priv.server->areamins, ent->priv.server->areamaxs))
238 if (numlist < maxlist)
242 //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]);
244 world->areagrid_stats_entitychecks++;
252 void World_LinkEdict_AreaGrid(world_t *world, prvm_edict_t *ent)
255 int igrid[3], igridmins[3], igridmaxs[3], gridnum, entitynumber = PRVM_NUM_FOR_EDICT(ent);
257 if (entitynumber <= 0 || entitynumber >= prog->max_edicts || PRVM_EDICT_NUM(entitynumber) != ent)
259 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);
263 igridmins[0] = (int) floor((ent->priv.server->areamins[0] + world->areagrid_bias[0]) * world->areagrid_scale[0]);
264 igridmins[1] = (int) floor((ent->priv.server->areamins[1] + world->areagrid_bias[1]) * world->areagrid_scale[1]);
265 //igridmins[2] = (int) floor((ent->priv.server->areamins[2] + world->areagrid_bias[2]) * world->areagrid_scale[2]);
266 igridmaxs[0] = (int) floor((ent->priv.server->areamaxs[0] + world->areagrid_bias[0]) * world->areagrid_scale[0]) + 1;
267 igridmaxs[1] = (int) floor((ent->priv.server->areamaxs[1] + world->areagrid_bias[1]) * world->areagrid_scale[1]) + 1;
268 //igridmaxs[2] = (int) floor((ent->priv.server->areamaxs[2] + world->areagrid_bias[2]) * world->areagrid_scale[2]) + 1;
269 if (igridmins[0] < 0 || igridmaxs[0] > AREA_GRID || igridmins[1] < 0 || igridmaxs[1] > AREA_GRID || ((igridmaxs[0] - igridmins[0]) * (igridmaxs[1] - igridmins[1])) > ENTITYGRIDAREAS)
271 // wow, something outside the grid, store it as such
272 World_InsertLinkBefore (&ent->priv.server->areagrid[0], &world->areagrid_outside, entitynumber);
277 for (igrid[1] = igridmins[1];igrid[1] < igridmaxs[1];igrid[1]++)
279 grid = world->areagrid + igrid[1] * AREA_GRID + igridmins[0];
280 for (igrid[0] = igridmins[0];igrid[0] < igridmaxs[0];igrid[0]++, grid++, gridnum++)
281 World_InsertLinkBefore (&ent->priv.server->areagrid[gridnum], grid, entitynumber);
291 void World_LinkEdict(world_t *world, prvm_edict_t *ent, const vec3_t mins, const vec3_t maxs)
293 // unlink from old position first
294 if (ent->priv.server->areagrid[0].prev)
295 World_UnlinkEdict(ent);
297 // don't add the world
298 if (ent == prog->edicts)
301 // don't add free entities
302 if (ent->priv.server->free)
305 VectorCopy(mins, ent->priv.server->areamins);
306 VectorCopy(maxs, ent->priv.server->areamaxs);
307 World_LinkEdict_AreaGrid(world, ent);
313 //============================================================================
314 // physics engine support
315 //============================================================================
318 #define ODE_DYNAMIC 1
321 #if defined(ODE_STATIC) || defined(ODE_DYNAMIC)
326 cvar_t physics_ode_quadtree_depth = {0, "physics_ode_quadtree_depth","5", "desired subdivision level of quadtree culling space"};
327 cvar_t physics_ode_contactsurfacelayer = {0, "physics_ode_contactsurfacelayer","0", "allows objects to overlap this many units to reduce jitter"};
328 cvar_t physics_ode_worldquickstep = {0, "physics_ode_worldquickstep","1", "use dWorldQuickStep rather than dWorldStepFast1 or dWorldStep"};
329 cvar_t physics_ode_worldquickstep_iterations = {0, "physics_ode_worldquickstep_iterations","20", "parameter to dWorldQuickStep"};
330 cvar_t physics_ode_worldstepfast = {0, "physics_ode_worldstepfast","0", "use dWorldStepFast1 rather than dWorldStep"};
331 cvar_t physics_ode_worldstepfast_iterations = {0, "physics_ode_worldstepfast_iterations","20", "parameter to dWorldStepFast1"};
332 cvar_t physics_ode_contact_mu = {0, "physics_ode_contact_mu", "1", "contact solver mu parameter - friction pyramid approximation 1 (see ODE User Guide)"};
333 cvar_t physics_ode_contact_erp = {0, "physics_ode_contact_erp", "0.96", "contact solver erp parameter - Error Restitution Percent (see ODE User Guide)"};
334 cvar_t physics_ode_contact_cfm = {0, "physics_ode_contact_cfm", "0", "contact solver cfm parameter - Constraint Force Mixing (see ODE User Guide)"};
335 cvar_t physics_ode_iterationsperframe = {0, "physics_ode_iterationsperframe", "4", "divisor for time step, runs multiple physics steps per frame"};
336 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"};
337 cvar_t physics_ode_spinlimit = {0, "physics_ode_spinlimit", "10000", "reset spin velocity if it gets too large"};
339 // LordHavoc: this large chunk of definitions comes from the ODE library
346 // ODE does not use WINAPI
352 // note: dynamic builds of ODE tend to be double precision, this is not used
354 typedef double dReal;
356 typedef dReal dVector3[4];
357 typedef dReal dVector4[4];
358 typedef dReal dMatrix3[4*3];
359 typedef dReal dMatrix4[4*4];
360 typedef dReal dMatrix6[8*6];
361 typedef dReal dQuaternion[4];
363 struct dxWorld; /* dynamics world */
364 struct dxSpace; /* collision space */
365 struct dxBody; /* rigid body (dynamics object) */
366 struct dxGeom; /* geometry (collision object) */
370 struct dxTriMeshData;
372 typedef struct dxWorld *dWorldID;
373 typedef struct dxSpace *dSpaceID;
374 typedef struct dxBody *dBodyID;
375 typedef struct dxGeom *dGeomID;
376 typedef struct dxJoint *dJointID;
377 typedef struct dxJointGroup *dJointGroupID;
378 typedef struct dxTriMeshData *dTriMeshDataID;
380 typedef struct dJointFeedback
382 dVector3 f1; /* force applied to body 1 */
383 dVector3 t1; /* torque applied to body 1 */
384 dVector3 f2; /* force applied to body 2 */
385 dVector3 t2; /* torque applied to body 2 */
389 typedef enum dJointType
420 dContactFDir1 = 0x002,
421 dContactBounce = 0x004,
422 dContactSoftERP = 0x008,
423 dContactSoftCFM = 0x010,
424 dContactMotion1 = 0x020,
425 dContactMotion2 = 0x040,
426 dContactMotionN = 0x080,
427 dContactSlip1 = 0x100,
428 dContactSlip2 = 0x200,
430 dContactApprox0 = 0x0000,
431 dContactApprox1_1 = 0x1000,
432 dContactApprox1_2 = 0x2000,
433 dContactApprox1 = 0x3000
436 typedef struct dSurfaceParameters
438 /* must always be defined */
442 /* only defined if the corresponding flag is set in mode */
448 dReal motion1,motion2,motionN;
450 } dSurfaceParameters;
452 typedef struct dContactGeom
454 dVector3 pos; ///< contact position
455 dVector3 normal; ///< normal vector
456 dReal depth; ///< penetration depth
457 dGeomID g1,g2; ///< the colliding geoms
458 int side1,side2; ///< (to be documented)
462 typedef struct dContact
464 dSurfaceParameters surface;
470 typedef void dNearCallback (void *data, dGeomID o1, dGeomID o2);
473 // Order XZY or ZXY usually works best, if your Y is up.
474 #define dSAP_AXES_XYZ ((0)|(1<<2)|(2<<4))
475 #define dSAP_AXES_XZY ((0)|(2<<2)|(1<<4))
476 #define dSAP_AXES_YXZ ((1)|(0<<2)|(2<<4))
477 #define dSAP_AXES_YZX ((1)|(2<<2)|(0<<4))
478 #define dSAP_AXES_ZXY ((2)|(0<<2)|(1<<4))
479 #define dSAP_AXES_ZYX ((2)|(1<<2)|(0<<4))
481 //const char* (ODE_API *dGetConfiguration)(void);
482 //int (ODE_API *dCheckConfiguration)( const char* token );
483 int (ODE_API *dInitODE)(void);
484 //int (ODE_API *dInitODE2)(unsigned int uiInitFlags);
485 //int (ODE_API *dAllocateODEDataForThread)(unsigned int uiAllocateFlags);
486 //void (ODE_API *dCleanupODEAllDataForThread)(void);
487 void (ODE_API *dCloseODE)(void);
489 //int (ODE_API *dMassCheck)(const dMass *m);
490 //void (ODE_API *dMassSetZero)(dMass *);
491 //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);
492 //void (ODE_API *dMassSetSphere)(dMass *, dReal density, dReal radius);
493 void (ODE_API *dMassSetSphereTotal)(dMass *, dReal total_mass, dReal radius);
494 //void (ODE_API *dMassSetCapsule)(dMass *, dReal density, int direction, dReal radius, dReal length);
495 void (ODE_API *dMassSetCapsuleTotal)(dMass *, dReal total_mass, int direction, dReal radius, dReal length);
496 //void (ODE_API *dMassSetCylinder)(dMass *, dReal density, int direction, dReal radius, dReal length);
497 //void (ODE_API *dMassSetCylinderTotal)(dMass *, dReal total_mass, int direction, dReal radius, dReal length);
498 //void (ODE_API *dMassSetBox)(dMass *, dReal density, dReal lx, dReal ly, dReal lz);
499 void (ODE_API *dMassSetBoxTotal)(dMass *, dReal total_mass, dReal lx, dReal ly, dReal lz);
500 //void (ODE_API *dMassSetTrimesh)(dMass *, dReal density, dGeomID g);
501 //void (ODE_API *dMassSetTrimeshTotal)(dMass *m, dReal total_mass, dGeomID g);
502 //void (ODE_API *dMassAdjust)(dMass *, dReal newmass);
503 //void (ODE_API *dMassTranslate)(dMass *, dReal x, dReal y, dReal z);
504 //void (ODE_API *dMassRotate)(dMass *, const dMatrix3 R);
505 //void (ODE_API *dMassAdd)(dMass *a, const dMass *b);
507 dWorldID (ODE_API *dWorldCreate)(void);
508 void (ODE_API *dWorldDestroy)(dWorldID world);
509 void (ODE_API *dWorldSetGravity)(dWorldID, dReal x, dReal y, dReal z);
510 void (ODE_API *dWorldGetGravity)(dWorldID, dVector3 gravity);
511 //void (ODE_API *dWorldSetERP)(dWorldID, dReal erp);
512 //dReal (ODE_API *dWorldGetERP)(dWorldID);
513 //void (ODE_API *dWorldSetCFM)(dWorldID, dReal cfm);
514 //dReal (ODE_API *dWorldGetCFM)(dWorldID);
515 void (ODE_API *dWorldStep)(dWorldID, dReal stepsize);
516 //void (ODE_API *dWorldImpulseToForce)(dWorldID, dReal stepsize, dReal ix, dReal iy, dReal iz, dVector3 force);
517 void (ODE_API *dWorldQuickStep)(dWorldID w, dReal stepsize);
518 void (ODE_API *dWorldSetQuickStepNumIterations)(dWorldID, int num);
519 //int (ODE_API *dWorldGetQuickStepNumIterations)(dWorldID);
520 //void (ODE_API *dWorldSetQuickStepW)(dWorldID, dReal over_relaxation);
521 //dReal (ODE_API *dWorldGetQuickStepW)(dWorldID);
522 //void (ODE_API *dWorldSetContactMaxCorrectingVel)(dWorldID, dReal vel);
523 //dReal (ODE_API *dWorldGetContactMaxCorrectingVel)(dWorldID);
524 void (ODE_API *dWorldSetContactSurfaceLayer)(dWorldID, dReal depth);
525 //dReal (ODE_API *dWorldGetContactSurfaceLayer)(dWorldID);
526 void (ODE_API *dWorldStepFast1)(dWorldID, dReal stepsize, int maxiterations);
527 //void (ODE_API *dWorldSetAutoEnableDepthSF1)(dWorldID, int autoEnableDepth);
528 //int (ODE_API *dWorldGetAutoEnableDepthSF1)(dWorldID);
529 //dReal (ODE_API *dWorldGetAutoDisableLinearThreshold)(dWorldID);
530 //void (ODE_API *dWorldSetAutoDisableLinearThreshold)(dWorldID, dReal linear_threshold);
531 //dReal (ODE_API *dWorldGetAutoDisableAngularThreshold)(dWorldID);
532 //void (ODE_API *dWorldSetAutoDisableAngularThreshold)(dWorldID, dReal angular_threshold);
533 //dReal (ODE_API *dWorldGetAutoDisableLinearAverageThreshold)(dWorldID);
534 //void (ODE_API *dWorldSetAutoDisableLinearAverageThreshold)(dWorldID, dReal linear_average_threshold);
535 //dReal (ODE_API *dWorldGetAutoDisableAngularAverageThreshold)(dWorldID);
536 //void (ODE_API *dWorldSetAutoDisableAngularAverageThreshold)(dWorldID, dReal angular_average_threshold);
537 //int (ODE_API *dWorldGetAutoDisableAverageSamplesCount)(dWorldID);
538 //void (ODE_API *dWorldSetAutoDisableAverageSamplesCount)(dWorldID, unsigned int average_samples_count );
539 //int (ODE_API *dWorldGetAutoDisableSteps)(dWorldID);
540 //void (ODE_API *dWorldSetAutoDisableSteps)(dWorldID, int steps);
541 //dReal (ODE_API *dWorldGetAutoDisableTime)(dWorldID);
542 //void (ODE_API *dWorldSetAutoDisableTime)(dWorldID, dReal time);
543 //int (ODE_API *dWorldGetAutoDisableFlag)(dWorldID);
544 //void (ODE_API *dWorldSetAutoDisableFlag)(dWorldID, int do_auto_disable);
545 //dReal (ODE_API *dWorldGetLinearDampingThreshold)(dWorldID w);
546 //void (ODE_API *dWorldSetLinearDampingThreshold)(dWorldID w, dReal threshold);
547 //dReal (ODE_API *dWorldGetAngularDampingThreshold)(dWorldID w);
548 //void (ODE_API *dWorldSetAngularDampingThreshold)(dWorldID w, dReal threshold);
549 //dReal (ODE_API *dWorldGetLinearDamping)(dWorldID w);
550 //void (ODE_API *dWorldSetLinearDamping)(dWorldID w, dReal scale);
551 //dReal (ODE_API *dWorldGetAngularDamping)(dWorldID w);
552 //void (ODE_API *dWorldSetAngularDamping)(dWorldID w, dReal scale);
553 //void (ODE_API *dWorldSetDamping)(dWorldID w, dReal linear_scale, dReal angular_scale);
554 //dReal (ODE_API *dWorldGetMaxAngularSpeed)(dWorldID w);
555 //void (ODE_API *dWorldSetMaxAngularSpeed)(dWorldID w, dReal max_speed);
556 //dReal (ODE_API *dBodyGetAutoDisableLinearThreshold)(dBodyID);
557 //void (ODE_API *dBodySetAutoDisableLinearThreshold)(dBodyID, dReal linear_average_threshold);
558 //dReal (ODE_API *dBodyGetAutoDisableAngularThreshold)(dBodyID);
559 //void (ODE_API *dBodySetAutoDisableAngularThreshold)(dBodyID, dReal angular_average_threshold);
560 //int (ODE_API *dBodyGetAutoDisableAverageSamplesCount)(dBodyID);
561 //void (ODE_API *dBodySetAutoDisableAverageSamplesCount)(dBodyID, unsigned int average_samples_count);
562 //int (ODE_API *dBodyGetAutoDisableSteps)(dBodyID);
563 //void (ODE_API *dBodySetAutoDisableSteps)(dBodyID, int steps);
564 //dReal (ODE_API *dBodyGetAutoDisableTime)(dBodyID);
565 //void (ODE_API *dBodySetAutoDisableTime)(dBodyID, dReal time);
566 //int (ODE_API *dBodyGetAutoDisableFlag)(dBodyID);
567 //void (ODE_API *dBodySetAutoDisableFlag)(dBodyID, int do_auto_disable);
568 //void (ODE_API *dBodySetAutoDisableDefaults)(dBodyID);
569 //dWorldID (ODE_API *dBodyGetWorld)(dBodyID);
570 dBodyID (ODE_API *dBodyCreate)(dWorldID);
571 void (ODE_API *dBodyDestroy)(dBodyID);
572 void (ODE_API *dBodySetData)(dBodyID, void *data);
573 void * (ODE_API *dBodyGetData)(dBodyID);
574 void (ODE_API *dBodySetPosition)(dBodyID, dReal x, dReal y, dReal z);
575 void (ODE_API *dBodySetRotation)(dBodyID, const dMatrix3 R);
576 //void (ODE_API *dBodySetQuaternion)(dBodyID, const dQuaternion q);
577 void (ODE_API *dBodySetLinearVel)(dBodyID, dReal x, dReal y, dReal z);
578 void (ODE_API *dBodySetAngularVel)(dBodyID, dReal x, dReal y, dReal z);
579 const dReal * (ODE_API *dBodyGetPosition)(dBodyID);
580 //void (ODE_API *dBodyCopyPosition)(dBodyID body, dVector3 pos);
581 const dReal * (ODE_API *dBodyGetRotation)(dBodyID);
582 //void (ODE_API *dBodyCopyRotation)(dBodyID, dMatrix3 R);
583 //const dReal * (ODE_API *dBodyGetQuaternion)(dBodyID);
584 //void (ODE_API *dBodyCopyQuaternion)(dBodyID body, dQuaternion quat);
585 const dReal * (ODE_API *dBodyGetLinearVel)(dBodyID);
586 const dReal * (ODE_API *dBodyGetAngularVel)(dBodyID);
587 void (ODE_API *dBodySetMass)(dBodyID, const dMass *mass);
588 //void (ODE_API *dBodyGetMass)(dBodyID, dMass *mass);
589 //void (ODE_API *dBodyAddForce)(dBodyID, dReal fx, dReal fy, dReal fz);
590 //void (ODE_API *dBodyAddTorque)(dBodyID, dReal fx, dReal fy, dReal fz);
591 //void (ODE_API *dBodyAddRelForce)(dBodyID, dReal fx, dReal fy, dReal fz);
592 //void (ODE_API *dBodyAddRelTorque)(dBodyID, dReal fx, dReal fy, dReal fz);
593 //void (ODE_API *dBodyAddForceAtPos)(dBodyID, dReal fx, dReal fy, dReal fz, dReal px, dReal py, dReal pz);
594 //void (ODE_API *dBodyAddForceAtRelPos)(dBodyID, dReal fx, dReal fy, dReal fz, dReal px, dReal py, dReal pz);
595 //void (ODE_API *dBodyAddRelForceAtPos)(dBodyID, dReal fx, dReal fy, dReal fz, dReal px, dReal py, dReal pz);
596 //void (ODE_API *dBodyAddRelForceAtRelPos)(dBodyID, dReal fx, dReal fy, dReal fz, dReal px, dReal py, dReal pz);
597 //const dReal * (ODE_API *dBodyGetForce)(dBodyID);
598 //const dReal * (ODE_API *dBodyGetTorque)(dBodyID);
599 //void (ODE_API *dBodySetForce)(dBodyID b, dReal x, dReal y, dReal z);
600 //void (ODE_API *dBodySetTorque)(dBodyID b, dReal x, dReal y, dReal z);
601 //void (ODE_API *dBodyGetRelPointPos)(dBodyID, dReal px, dReal py, dReal pz, dVector3 result);
602 //void (ODE_API *dBodyGetRelPointVel)(dBodyID, dReal px, dReal py, dReal pz, dVector3 result);
603 //void (ODE_API *dBodyGetPointVel)(dBodyID, dReal px, dReal py, dReal pz, dVector3 result);
604 //void (ODE_API *dBodyGetPosRelPoint)(dBodyID, dReal px, dReal py, dReal pz, dVector3 result);
605 //void (ODE_API *dBodyVectorToWorld)(dBodyID, dReal px, dReal py, dReal pz, dVector3 result);
606 //void (ODE_API *dBodyVectorFromWorld)(dBodyID, dReal px, dReal py, dReal pz, dVector3 result);
607 //void (ODE_API *dBodySetFiniteRotationMode)(dBodyID, int mode);
608 //void (ODE_API *dBodySetFiniteRotationAxis)(dBodyID, dReal x, dReal y, dReal z);
609 //int (ODE_API *dBodyGetFiniteRotationMode)(dBodyID);
610 //void (ODE_API *dBodyGetFiniteRotationAxis)(dBodyID, dVector3 result);
611 //int (ODE_API *dBodyGetNumJoints)(dBodyID b);
612 //dJointID (ODE_API *dBodyGetJoint)(dBodyID, int index);
613 //void (ODE_API *dBodySetDynamic)(dBodyID);
614 //void (ODE_API *dBodySetKinematic)(dBodyID);
615 //int (ODE_API *dBodyIsKinematic)(dBodyID);
616 //void (ODE_API *dBodyEnable)(dBodyID);
617 //void (ODE_API *dBodyDisable)(dBodyID);
618 //int (ODE_API *dBodyIsEnabled)(dBodyID);
619 void (ODE_API *dBodySetGravityMode)(dBodyID b, int mode);
620 int (ODE_API *dBodyGetGravityMode)(dBodyID b);
621 //void (*dBodySetMovedCallback)(dBodyID b, void(ODE_API *callback)(dBodyID));
622 //dGeomID (ODE_API *dBodyGetFirstGeom)(dBodyID b);
623 //dGeomID (ODE_API *dBodyGetNextGeom)(dGeomID g);
624 //void (ODE_API *dBodySetDampingDefaults)(dBodyID b);
625 //dReal (ODE_API *dBodyGetLinearDamping)(dBodyID b);
626 //void (ODE_API *dBodySetLinearDamping)(dBodyID b, dReal scale);
627 //dReal (ODE_API *dBodyGetAngularDamping)(dBodyID b);
628 //void (ODE_API *dBodySetAngularDamping)(dBodyID b, dReal scale);
629 //void (ODE_API *dBodySetDamping)(dBodyID b, dReal linear_scale, dReal angular_scale);
630 //dReal (ODE_API *dBodyGetLinearDampingThreshold)(dBodyID b);
631 //void (ODE_API *dBodySetLinearDampingThreshold)(dBodyID b, dReal threshold);
632 //dReal (ODE_API *dBodyGetAngularDampingThreshold)(dBodyID b);
633 //void (ODE_API *dBodySetAngularDampingThreshold)(dBodyID b, dReal threshold);
634 //dReal (ODE_API *dBodyGetMaxAngularSpeed)(dBodyID b);
635 //void (ODE_API *dBodySetMaxAngularSpeed)(dBodyID b, dReal max_speed);
636 //int (ODE_API *dBodyGetGyroscopicMode)(dBodyID b);
637 //void (ODE_API *dBodySetGyroscopicMode)(dBodyID b, int enabled);
638 //dJointID (ODE_API *dJointCreateBall)(dWorldID, dJointGroupID);
639 //dJointID (ODE_API *dJointCreateHinge)(dWorldID, dJointGroupID);
640 //dJointID (ODE_API *dJointCreateSlider)(dWorldID, dJointGroupID);
641 dJointID (ODE_API *dJointCreateContact)(dWorldID, dJointGroupID, const dContact *);
642 //dJointID (ODE_API *dJointCreateHinge2)(dWorldID, dJointGroupID);
643 //dJointID (ODE_API *dJointCreateUniversal)(dWorldID, dJointGroupID);
644 //dJointID (ODE_API *dJointCreatePR)(dWorldID, dJointGroupID);
645 //dJointID (ODE_API *dJointCreatePU)(dWorldID, dJointGroupID);
646 //dJointID (ODE_API *dJointCreatePiston)(dWorldID, dJointGroupID);
647 //dJointID (ODE_API *dJointCreateFixed)(dWorldID, dJointGroupID);
648 //dJointID (ODE_API *dJointCreateNull)(dWorldID, dJointGroupID);
649 //dJointID (ODE_API *dJointCreateAMotor)(dWorldID, dJointGroupID);
650 //dJointID (ODE_API *dJointCreateLMotor)(dWorldID, dJointGroupID);
651 //dJointID (ODE_API *dJointCreatePlane2D)(dWorldID, dJointGroupID);
652 //void (ODE_API *dJointDestroy)(dJointID);
653 dJointGroupID (ODE_API *dJointGroupCreate)(int max_size);
654 void (ODE_API *dJointGroupDestroy)(dJointGroupID);
655 void (ODE_API *dJointGroupEmpty)(dJointGroupID);
656 //int (ODE_API *dJointGetNumBodies)(dJointID);
657 void (ODE_API *dJointAttach)(dJointID, dBodyID body1, dBodyID body2);
658 //void (ODE_API *dJointEnable)(dJointID);
659 //void (ODE_API *dJointDisable)(dJointID);
660 //int (ODE_API *dJointIsEnabled)(dJointID);
661 //void (ODE_API *dJointSetData)(dJointID, void *data);
662 //void * (ODE_API *dJointGetData)(dJointID);
663 //dJointType (ODE_API *dJointGetType)(dJointID);
664 //dBodyID (ODE_API *dJointGetBody)(dJointID, int index);
665 //void (ODE_API *dJointSetFeedback)(dJointID, dJointFeedback *);
666 //dJointFeedback *(ODE_API *dJointGetFeedback)(dJointID);
667 //void (ODE_API *dJointSetBallAnchor)(dJointID, dReal x, dReal y, dReal z);
668 //void (ODE_API *dJointSetBallAnchor2)(dJointID, dReal x, dReal y, dReal z);
669 //void (ODE_API *dJointSetBallParam)(dJointID, int parameter, dReal value);
670 //void (ODE_API *dJointSetHingeAnchor)(dJointID, dReal x, dReal y, dReal z);
671 //void (ODE_API *dJointSetHingeAnchorDelta)(dJointID, dReal x, dReal y, dReal z, dReal ax, dReal ay, dReal az);
672 //void (ODE_API *dJointSetHingeAxis)(dJointID, dReal x, dReal y, dReal z);
673 //void (ODE_API *dJointSetHingeAxisOffset)(dJointID j, dReal x, dReal y, dReal z, dReal angle);
674 //void (ODE_API *dJointSetHingeParam)(dJointID, int parameter, dReal value);
675 //void (ODE_API *dJointAddHingeTorque)(dJointID joint, dReal torque);
676 //void (ODE_API *dJointSetSliderAxis)(dJointID, dReal x, dReal y, dReal z);
677 //void (ODE_API *dJointSetSliderAxisDelta)(dJointID, dReal x, dReal y, dReal z, dReal ax, dReal ay, dReal az);
678 //void (ODE_API *dJointSetSliderParam)(dJointID, int parameter, dReal value);
679 //void (ODE_API *dJointAddSliderForce)(dJointID joint, dReal force);
680 //void (ODE_API *dJointSetHinge2Anchor)(dJointID, dReal x, dReal y, dReal z);
681 //void (ODE_API *dJointSetHinge2Axis1)(dJointID, dReal x, dReal y, dReal z);
682 //void (ODE_API *dJointSetHinge2Axis2)(dJointID, dReal x, dReal y, dReal z);
683 //void (ODE_API *dJointSetHinge2Param)(dJointID, int parameter, dReal value);
684 //void (ODE_API *dJointAddHinge2Torques)(dJointID joint, dReal torque1, dReal torque2);
685 //void (ODE_API *dJointSetUniversalAnchor)(dJointID, dReal x, dReal y, dReal z);
686 //void (ODE_API *dJointSetUniversalAxis1)(dJointID, dReal x, dReal y, dReal z);
687 //void (ODE_API *dJointSetUniversalAxis1Offset)(dJointID, dReal x, dReal y, dReal z, dReal offset1, dReal offset2);
688 //void (ODE_API *dJointSetUniversalAxis2)(dJointID, dReal x, dReal y, dReal z);
689 //void (ODE_API *dJointSetUniversalAxis2Offset)(dJointID, dReal x, dReal y, dReal z, dReal offset1, dReal offset2);
690 //void (ODE_API *dJointSetUniversalParam)(dJointID, int parameter, dReal value);
691 //void (ODE_API *dJointAddUniversalTorques)(dJointID joint, dReal torque1, dReal torque2);
692 //void (ODE_API *dJointSetPRAnchor)(dJointID, dReal x, dReal y, dReal z);
693 //void (ODE_API *dJointSetPRAxis1)(dJointID, dReal x, dReal y, dReal z);
694 //void (ODE_API *dJointSetPRAxis2)(dJointID, dReal x, dReal y, dReal z);
695 //void (ODE_API *dJointSetPRParam)(dJointID, int parameter, dReal value);
696 //void (ODE_API *dJointAddPRTorque)(dJointID j, dReal torque);
697 //void (ODE_API *dJointSetPUAnchor)(dJointID, dReal x, dReal y, dReal z);
698 //void (ODE_API *dJointSetPUAnchorOffset)(dJointID, dReal x, dReal y, dReal z, dReal dx, dReal dy, dReal dz);
699 //void (ODE_API *dJointSetPUAxis1)(dJointID, dReal x, dReal y, dReal z);
700 //void (ODE_API *dJointSetPUAxis2)(dJointID, dReal x, dReal y, dReal z);
701 //void (ODE_API *dJointSetPUAxis3)(dJointID, dReal x, dReal y, dReal z);
702 //void (ODE_API *dJointSetPUAxisP)(dJointID id, dReal x, dReal y, dReal z);
703 //void (ODE_API *dJointSetPUParam)(dJointID, int parameter, dReal value);
704 //void (ODE_API *dJointAddPUTorque)(dJointID j, dReal torque);
705 //void (ODE_API *dJointSetPistonAnchor)(dJointID, dReal x, dReal y, dReal z);
706 //void (ODE_API *dJointSetPistonAnchorOffset)(dJointID j, dReal x, dReal y, dReal z, dReal dx, dReal dy, dReal dz);
707 //void (ODE_API *dJointSetPistonParam)(dJointID, int parameter, dReal value);
708 //void (ODE_API *dJointAddPistonForce)(dJointID joint, dReal force);
709 //void (ODE_API *dJointSetFixed)(dJointID);
710 //void (ODE_API *dJointSetFixedParam)(dJointID, int parameter, dReal value);
711 //void (ODE_API *dJointSetAMotorNumAxes)(dJointID, int num);
712 //void (ODE_API *dJointSetAMotorAxis)(dJointID, int anum, int rel, dReal x, dReal y, dReal z);
713 //void (ODE_API *dJointSetAMotorAngle)(dJointID, int anum, dReal angle);
714 //void (ODE_API *dJointSetAMotorParam)(dJointID, int parameter, dReal value);
715 //void (ODE_API *dJointSetAMotorMode)(dJointID, int mode);
716 //void (ODE_API *dJointAddAMotorTorques)(dJointID, dReal torque1, dReal torque2, dReal torque3);
717 //void (ODE_API *dJointSetLMotorNumAxes)(dJointID, int num);
718 //void (ODE_API *dJointSetLMotorAxis)(dJointID, int anum, int rel, dReal x, dReal y, dReal z);
719 //void (ODE_API *dJointSetLMotorParam)(dJointID, int parameter, dReal value);
720 //void (ODE_API *dJointSetPlane2DXParam)(dJointID, int parameter, dReal value);
721 //void (ODE_API *dJointSetPlane2DYParam)(dJointID, int parameter, dReal value);
722 //void (ODE_API *dJointSetPlane2DAngleParam)(dJointID, int parameter, dReal value);
723 //void (ODE_API *dJointGetBallAnchor)(dJointID, dVector3 result);
724 //void (ODE_API *dJointGetBallAnchor2)(dJointID, dVector3 result);
725 //dReal (ODE_API *dJointGetBallParam)(dJointID, int parameter);
726 //void (ODE_API *dJointGetHingeAnchor)(dJointID, dVector3 result);
727 //void (ODE_API *dJointGetHingeAnchor2)(dJointID, dVector3 result);
728 //void (ODE_API *dJointGetHingeAxis)(dJointID, dVector3 result);
729 //dReal (ODE_API *dJointGetHingeParam)(dJointID, int parameter);
730 //dReal (ODE_API *dJointGetHingeAngle)(dJointID);
731 //dReal (ODE_API *dJointGetHingeAngleRate)(dJointID);
732 //dReal (ODE_API *dJointGetSliderPosition)(dJointID);
733 //dReal (ODE_API *dJointGetSliderPositionRate)(dJointID);
734 //void (ODE_API *dJointGetSliderAxis)(dJointID, dVector3 result);
735 //dReal (ODE_API *dJointGetSliderParam)(dJointID, int parameter);
736 //void (ODE_API *dJointGetHinge2Anchor)(dJointID, dVector3 result);
737 //void (ODE_API *dJointGetHinge2Anchor2)(dJointID, dVector3 result);
738 //void (ODE_API *dJointGetHinge2Axis1)(dJointID, dVector3 result);
739 //void (ODE_API *dJointGetHinge2Axis2)(dJointID, dVector3 result);
740 //dReal (ODE_API *dJointGetHinge2Param)(dJointID, int parameter);
741 //dReal (ODE_API *dJointGetHinge2Angle1)(dJointID);
742 //dReal (ODE_API *dJointGetHinge2Angle1Rate)(dJointID);
743 //dReal (ODE_API *dJointGetHinge2Angle2Rate)(dJointID);
744 //void (ODE_API *dJointGetUniversalAnchor)(dJointID, dVector3 result);
745 //void (ODE_API *dJointGetUniversalAnchor2)(dJointID, dVector3 result);
746 //void (ODE_API *dJointGetUniversalAxis1)(dJointID, dVector3 result);
747 //void (ODE_API *dJointGetUniversalAxis2)(dJointID, dVector3 result);
748 //dReal (ODE_API *dJointGetUniversalParam)(dJointID, int parameter);
749 //void (ODE_API *dJointGetUniversalAngles)(dJointID, dReal *angle1, dReal *angle2);
750 //dReal (ODE_API *dJointGetUniversalAngle1)(dJointID);
751 //dReal (ODE_API *dJointGetUniversalAngle2)(dJointID);
752 //dReal (ODE_API *dJointGetUniversalAngle1Rate)(dJointID);
753 //dReal (ODE_API *dJointGetUniversalAngle2Rate)(dJointID);
754 //void (ODE_API *dJointGetPRAnchor)(dJointID, dVector3 result);
755 //dReal (ODE_API *dJointGetPRPosition)(dJointID);
756 //dReal (ODE_API *dJointGetPRPositionRate)(dJointID);
757 //dReal (ODE_API *dJointGetPRAngle)(dJointID);
758 //dReal (ODE_API *dJointGetPRAngleRate)(dJointID);
759 //void (ODE_API *dJointGetPRAxis1)(dJointID, dVector3 result);
760 //void (ODE_API *dJointGetPRAxis2)(dJointID, dVector3 result);
761 //dReal (ODE_API *dJointGetPRParam)(dJointID, int parameter);
762 //void (ODE_API *dJointGetPUAnchor)(dJointID, dVector3 result);
763 //dReal (ODE_API *dJointGetPUPosition)(dJointID);
764 //dReal (ODE_API *dJointGetPUPositionRate)(dJointID);
765 //void (ODE_API *dJointGetPUAxis1)(dJointID, dVector3 result);
766 //void (ODE_API *dJointGetPUAxis2)(dJointID, dVector3 result);
767 //void (ODE_API *dJointGetPUAxis3)(dJointID, dVector3 result);
768 //void (ODE_API *dJointGetPUAxisP)(dJointID id, dVector3 result);
769 //void (ODE_API *dJointGetPUAngles)(dJointID, dReal *angle1, dReal *angle2);
770 //dReal (ODE_API *dJointGetPUAngle1)(dJointID);
771 //dReal (ODE_API *dJointGetPUAngle1Rate)(dJointID);
772 //dReal (ODE_API *dJointGetPUAngle2)(dJointID);
773 //dReal (ODE_API *dJointGetPUAngle2Rate)(dJointID);
774 //dReal (ODE_API *dJointGetPUParam)(dJointID, int parameter);
775 //dReal (ODE_API *dJointGetPistonPosition)(dJointID);
776 //dReal (ODE_API *dJointGetPistonPositionRate)(dJointID);
777 //dReal (ODE_API *dJointGetPistonAngle)(dJointID);
778 //dReal (ODE_API *dJointGetPistonAngleRate)(dJointID);
779 //void (ODE_API *dJointGetPistonAnchor)(dJointID, dVector3 result);
780 //void (ODE_API *dJointGetPistonAnchor2)(dJointID, dVector3 result);
781 //void (ODE_API *dJointGetPistonAxis)(dJointID, dVector3 result);
782 //dReal (ODE_API *dJointGetPistonParam)(dJointID, int parameter);
783 //int (ODE_API *dJointGetAMotorNumAxes)(dJointID);
784 //void (ODE_API *dJointGetAMotorAxis)(dJointID, int anum, dVector3 result);
785 //int (ODE_API *dJointGetAMotorAxisRel)(dJointID, int anum);
786 //dReal (ODE_API *dJointGetAMotorAngle)(dJointID, int anum);
787 //dReal (ODE_API *dJointGetAMotorAngleRate)(dJointID, int anum);
788 //dReal (ODE_API *dJointGetAMotorParam)(dJointID, int parameter);
789 //int (ODE_API *dJointGetAMotorMode)(dJointID);
790 //int (ODE_API *dJointGetLMotorNumAxes)(dJointID);
791 //void (ODE_API *dJointGetLMotorAxis)(dJointID, int anum, dVector3 result);
792 //dReal (ODE_API *dJointGetLMotorParam)(dJointID, int parameter);
793 //dReal (ODE_API *dJointGetFixedParam)(dJointID, int parameter);
794 //dJointID (ODE_API *dConnectingJoint)(dBodyID, dBodyID);
795 //int (ODE_API *dConnectingJointList)(dBodyID, dBodyID, dJointID*);
796 int (ODE_API *dAreConnected)(dBodyID, dBodyID);
797 int (ODE_API *dAreConnectedExcluding)(dBodyID body1, dBodyID body2, int joint_type);
799 dSpaceID (ODE_API *dSimpleSpaceCreate)(dSpaceID space);
800 dSpaceID (ODE_API *dHashSpaceCreate)(dSpaceID space);
801 dSpaceID (ODE_API *dQuadTreeSpaceCreate)(dSpaceID space, const dVector3 Center, const dVector3 Extents, int Depth);
802 //dSpaceID (ODE_API *dSweepAndPruneSpaceCreate)( dSpaceID space, int axisorder );
803 void (ODE_API *dSpaceDestroy)(dSpaceID);
804 //void (ODE_API *dHashSpaceSetLevels)(dSpaceID space, int minlevel, int maxlevel);
805 //void (ODE_API *dHashSpaceGetLevels)(dSpaceID space, int *minlevel, int *maxlevel);
806 //void (ODE_API *dSpaceSetCleanup)(dSpaceID space, int mode);
807 //int (ODE_API *dSpaceGetCleanup)(dSpaceID space);
808 //void (ODE_API *dSpaceSetSublevel)(dSpaceID space, int sublevel);
809 //int (ODE_API *dSpaceGetSublevel)(dSpaceID space);
810 //void (ODE_API *dSpaceSetManualCleanup)(dSpaceID space, int mode);
811 //int (ODE_API *dSpaceGetManualCleanup)(dSpaceID space);
812 //void (ODE_API *dSpaceAdd)(dSpaceID, dGeomID);
813 //void (ODE_API *dSpaceRemove)(dSpaceID, dGeomID);
814 //int (ODE_API *dSpaceQuery)(dSpaceID, dGeomID);
815 //void (ODE_API *dSpaceClean)(dSpaceID);
816 //int (ODE_API *dSpaceGetNumGeoms)(dSpaceID);
817 //dGeomID (ODE_API *dSpaceGetGeom)(dSpaceID, int i);
818 //int (ODE_API *dSpaceGetClass)(dSpaceID space);
820 void (ODE_API *dGeomDestroy)(dGeomID geom);
821 //void (ODE_API *dGeomSetData)(dGeomID geom, void* data);
822 //void * (ODE_API *dGeomGetData)(dGeomID geom);
823 void (ODE_API *dGeomSetBody)(dGeomID geom, dBodyID body);
824 dBodyID (ODE_API *dGeomGetBody)(dGeomID geom);
825 //void (ODE_API *dGeomSetPosition)(dGeomID geom, dReal x, dReal y, dReal z);
826 void (ODE_API *dGeomSetRotation)(dGeomID geom, const dMatrix3 R);
827 //void (ODE_API *dGeomSetQuaternion)(dGeomID geom, const dQuaternion Q);
828 //const dReal * (ODE_API *dGeomGetPosition)(dGeomID geom);
829 //void (ODE_API *dGeomCopyPosition)(dGeomID geom, dVector3 pos);
830 //const dReal * (ODE_API *dGeomGetRotation)(dGeomID geom);
831 //void (ODE_API *dGeomCopyRotation)(dGeomID geom, dMatrix3 R);
832 //void (ODE_API *dGeomGetQuaternion)(dGeomID geom, dQuaternion result);
833 //void (ODE_API *dGeomGetAABB)(dGeomID geom, dReal aabb[6]);
834 int (ODE_API *dGeomIsSpace)(dGeomID geom);
835 //dSpaceID (ODE_API *dGeomGetSpace)(dGeomID);
836 //int (ODE_API *dGeomGetClass)(dGeomID geom);
837 //void (ODE_API *dGeomSetCategoryBits)(dGeomID geom, unsigned long bits);
838 //void (ODE_API *dGeomSetCollideBits)(dGeomID geom, unsigned long bits);
839 //unsigned long (ODE_API *dGeomGetCategoryBits)(dGeomID);
840 //unsigned long (ODE_API *dGeomGetCollideBits)(dGeomID);
841 //void (ODE_API *dGeomEnable)(dGeomID geom);
842 //void (ODE_API *dGeomDisable)(dGeomID geom);
843 //int (ODE_API *dGeomIsEnabled)(dGeomID geom);
844 //void (ODE_API *dGeomSetOffsetPosition)(dGeomID geom, dReal x, dReal y, dReal z);
845 //void (ODE_API *dGeomSetOffsetRotation)(dGeomID geom, const dMatrix3 R);
846 //void (ODE_API *dGeomSetOffsetQuaternion)(dGeomID geom, const dQuaternion Q);
847 //void (ODE_API *dGeomSetOffsetWorldPosition)(dGeomID geom, dReal x, dReal y, dReal z);
848 //void (ODE_API *dGeomSetOffsetWorldRotation)(dGeomID geom, const dMatrix3 R);
849 //void (ODE_API *dGeomSetOffsetWorldQuaternion)(dGeomID geom, const dQuaternion);
850 //void (ODE_API *dGeomClearOffset)(dGeomID geom);
851 //int (ODE_API *dGeomIsOffset)(dGeomID geom);
852 //const dReal * (ODE_API *dGeomGetOffsetPosition)(dGeomID geom);
853 //void (ODE_API *dGeomCopyOffsetPosition)(dGeomID geom, dVector3 pos);
854 //const dReal * (ODE_API *dGeomGetOffsetRotation)(dGeomID geom);
855 //void (ODE_API *dGeomCopyOffsetRotation)(dGeomID geom, dMatrix3 R);
856 //void (ODE_API *dGeomGetOffsetQuaternion)(dGeomID geom, dQuaternion result);
857 int (ODE_API *dCollide)(dGeomID o1, dGeomID o2, int flags, dContactGeom *contact, int skip);
859 void (ODE_API *dSpaceCollide)(dSpaceID space, void *data, dNearCallback *callback);
860 void (ODE_API *dSpaceCollide2)(dGeomID space1, dGeomID space2, void *data, dNearCallback *callback);
862 dGeomID (ODE_API *dCreateSphere)(dSpaceID space, dReal radius);
863 //void (ODE_API *dGeomSphereSetRadius)(dGeomID sphere, dReal radius);
864 //dReal (ODE_API *dGeomSphereGetRadius)(dGeomID sphere);
865 //dReal (ODE_API *dGeomSpherePointDepth)(dGeomID sphere, dReal x, dReal y, dReal z);
867 //dGeomID (ODE_API *dCreateConvex)(dSpaceID space, dReal *_planes, unsigned int _planecount, dReal *_points, unsigned int _pointcount,unsigned int *_polygons);
868 //void (ODE_API *dGeomSetConvex)(dGeomID g, dReal *_planes, unsigned int _count, dReal *_points, unsigned int _pointcount,unsigned int *_polygons);
870 dGeomID (ODE_API *dCreateBox)(dSpaceID space, dReal lx, dReal ly, dReal lz);
871 //void (ODE_API *dGeomBoxSetLengths)(dGeomID box, dReal lx, dReal ly, dReal lz);
872 //void (ODE_API *dGeomBoxGetLengths)(dGeomID box, dVector3 result);
873 //dReal (ODE_API *dGeomBoxPointDepth)(dGeomID box, dReal x, dReal y, dReal z);
874 //dReal (ODE_API *dGeomBoxPointDepth)(dGeomID box, dReal x, dReal y, dReal z);
876 //dGeomID (ODE_API *dCreatePlane)(dSpaceID space, dReal a, dReal b, dReal c, dReal d);
877 //void (ODE_API *dGeomPlaneSetParams)(dGeomID plane, dReal a, dReal b, dReal c, dReal d);
878 //void (ODE_API *dGeomPlaneGetParams)(dGeomID plane, dVector4 result);
879 //dReal (ODE_API *dGeomPlanePointDepth)(dGeomID plane, dReal x, dReal y, dReal z);
881 dGeomID (ODE_API *dCreateCapsule)(dSpaceID space, dReal radius, dReal length);
882 //void (ODE_API *dGeomCapsuleSetParams)(dGeomID ccylinder, dReal radius, dReal length);
883 //void (ODE_API *dGeomCapsuleGetParams)(dGeomID ccylinder, dReal *radius, dReal *length);
884 //dReal (ODE_API *dGeomCapsulePointDepth)(dGeomID ccylinder, dReal x, dReal y, dReal z);
886 //dGeomID (ODE_API *dCreateCylinder)(dSpaceID space, dReal radius, dReal length);
887 //void (ODE_API *dGeomCylinderSetParams)(dGeomID cylinder, dReal radius, dReal length);
888 //void (ODE_API *dGeomCylinderGetParams)(dGeomID cylinder, dReal *radius, dReal *length);
890 //dGeomID (ODE_API *dCreateRay)(dSpaceID space, dReal length);
891 //void (ODE_API *dGeomRaySetLength)(dGeomID ray, dReal length);
892 //dReal (ODE_API *dGeomRayGetLength)(dGeomID ray);
893 //void (ODE_API *dGeomRaySet)(dGeomID ray, dReal px, dReal py, dReal pz, dReal dx, dReal dy, dReal dz);
894 //void (ODE_API *dGeomRayGet)(dGeomID ray, dVector3 start, dVector3 dir);
896 dGeomID (ODE_API *dCreateGeomTransform)(dSpaceID space);
897 void (ODE_API *dGeomTransformSetGeom)(dGeomID g, dGeomID obj);
898 //dGeomID (ODE_API *dGeomTransformGetGeom)(dGeomID g);
899 void (ODE_API *dGeomTransformSetCleanup)(dGeomID g, int mode);
900 //int (ODE_API *dGeomTransformGetCleanup)(dGeomID g);
901 //void (ODE_API *dGeomTransformSetInfo)(dGeomID g, int mode);
902 //int (ODE_API *dGeomTransformGetInfo)(dGeomID g);
904 enum { TRIMESH_FACE_NORMALS };
905 typedef int dTriCallback(dGeomID TriMesh, dGeomID RefObject, int TriangleIndex);
906 typedef void dTriArrayCallback(dGeomID TriMesh, dGeomID RefObject, const int* TriIndices, int TriCount);
907 typedef int dTriRayCallback(dGeomID TriMesh, dGeomID Ray, int TriangleIndex, dReal u, dReal v);
908 typedef int dTriTriMergeCallback(dGeomID TriMesh, int FirstTriangleIndex, int SecondTriangleIndex);
910 dTriMeshDataID (ODE_API *dGeomTriMeshDataCreate)(void);
911 void (ODE_API *dGeomTriMeshDataDestroy)(dTriMeshDataID g);
912 //void (ODE_API *dGeomTriMeshDataSet)(dTriMeshDataID g, int data_id, void* in_data);
913 //void* (ODE_API *dGeomTriMeshDataGet)(dTriMeshDataID g, int data_id);
914 //void (*dGeomTriMeshSetLastTransform)( (ODE_API *dGeomID g, dMatrix4 last_trans );
915 //dReal* (*dGeomTriMeshGetLastTransform)( (ODE_API *dGeomID g );
916 void (ODE_API *dGeomTriMeshDataBuildSingle)(dTriMeshDataID g, const void* Vertices, int VertexStride, int VertexCount, const void* Indices, int IndexCount, int TriStride);
917 //void (ODE_API *dGeomTriMeshDataBuildSingle1)(dTriMeshDataID g, const void* Vertices, int VertexStride, int VertexCount, const void* Indices, int IndexCount, int TriStride, const void* Normals);
918 //void (ODE_API *dGeomTriMeshDataBuildDouble)(dTriMeshDataID g, const void* Vertices, int VertexStride, int VertexCount, const void* Indices, int IndexCount, int TriStride);
919 //void (ODE_API *dGeomTriMeshDataBuildDouble1)(dTriMeshDataID g, const void* Vertices, int VertexStride, int VertexCount, const void* Indices, int IndexCount, int TriStride, const void* Normals);
920 //void (ODE_API *dGeomTriMeshDataBuildSimple)(dTriMeshDataID g, const dReal* Vertices, int VertexCount, const dTriIndex* Indices, int IndexCount);
921 //void (ODE_API *dGeomTriMeshDataBuildSimple1)(dTriMeshDataID g, const dReal* Vertices, int VertexCount, const dTriIndex* Indices, int IndexCount, const int* Normals);
922 //void (ODE_API *dGeomTriMeshDataPreprocess)(dTriMeshDataID g);
923 //void (ODE_API *dGeomTriMeshDataGetBuffer)(dTriMeshDataID g, unsigned char** buf, int* bufLen);
924 //void (ODE_API *dGeomTriMeshDataSetBuffer)(dTriMeshDataID g, unsigned char* buf);
925 //void (ODE_API *dGeomTriMeshSetCallback)(dGeomID g, dTriCallback* Callback);
926 //dTriCallback* (ODE_API *dGeomTriMeshGetCallback)(dGeomID g);
927 //void (ODE_API *dGeomTriMeshSetArrayCallback)(dGeomID g, dTriArrayCallback* ArrayCallback);
928 //dTriArrayCallback* (ODE_API *dGeomTriMeshGetArrayCallback)(dGeomID g);
929 //void (ODE_API *dGeomTriMeshSetRayCallback)(dGeomID g, dTriRayCallback* Callback);
930 //dTriRayCallback* (ODE_API *dGeomTriMeshGetRayCallback)(dGeomID g);
931 //void (ODE_API *dGeomTriMeshSetTriMergeCallback)(dGeomID g, dTriTriMergeCallback* Callback);
932 //dTriTriMergeCallback* (ODE_API *dGeomTriMeshGetTriMergeCallback)(dGeomID g);
933 dGeomID (ODE_API *dCreateTriMesh)(dSpaceID space, dTriMeshDataID Data, dTriCallback* Callback, dTriArrayCallback* ArrayCallback, dTriRayCallback* RayCallback);
934 //void (ODE_API *dGeomTriMeshSetData)(dGeomID g, dTriMeshDataID Data);
935 //dTriMeshDataID (ODE_API *dGeomTriMeshGetData)(dGeomID g);
936 //void (ODE_API *dGeomTriMeshEnableTC)(dGeomID g, int geomClass, int enable);
937 //int (ODE_API *dGeomTriMeshIsTCEnabled)(dGeomID g, int geomClass);
938 //void (ODE_API *dGeomTriMeshClearTCCache)(dGeomID g);
939 //dTriMeshDataID (ODE_API *dGeomTriMeshGetTriMeshDataID)(dGeomID g);
940 //void (ODE_API *dGeomTriMeshGetTriangle)(dGeomID g, int Index, dVector3* v0, dVector3* v1, dVector3* v2);
941 //void (ODE_API *dGeomTriMeshGetPoint)(dGeomID g, int Index, dReal u, dReal v, dVector3 Out);
942 //int (ODE_API *dGeomTriMeshGetTriangleCount )(dGeomID g);
943 //void (ODE_API *dGeomTriMeshDataUpdate)(dTriMeshDataID g);
945 static dllfunction_t odefuncs[] =
947 // {"dGetConfiguration", (void **) &dGetConfiguration},
948 // {"dCheckConfiguration", (void **) &dCheckConfiguration},
949 {"dInitODE", (void **) &dInitODE},
950 // {"dInitODE2", (void **) &dInitODE2},
951 // {"dAllocateODEDataForThread", (void **) &dAllocateODEDataForThread},
952 // {"dCleanupODEAllDataForThread", (void **) &dCleanupODEAllDataForThread},
953 {"dCloseODE", (void **) &dCloseODE},
954 // {"dMassCheck", (void **) &dMassCheck},
955 // {"dMassSetZero", (void **) &dMassSetZero},
956 // {"dMassSetParameters", (void **) &dMassSetParameters},
957 // {"dMassSetSphere", (void **) &dMassSetSphere},
958 {"dMassSetSphereTotal", (void **) &dMassSetSphereTotal},
959 // {"dMassSetCapsule", (void **) &dMassSetCapsule},
960 {"dMassSetCapsuleTotal", (void **) &dMassSetCapsuleTotal},
961 // {"dMassSetCylinder", (void **) &dMassSetCylinder},
962 // {"dMassSetCylinderTotal", (void **) &dMassSetCylinderTotal},
963 // {"dMassSetBox", (void **) &dMassSetBox},
964 {"dMassSetBoxTotal", (void **) &dMassSetBoxTotal},
965 // {"dMassSetTrimesh", (void **) &dMassSetTrimesh},
966 // {"dMassSetTrimeshTotal", (void **) &dMassSetTrimeshTotal},
967 // {"dMassAdjust", (void **) &dMassAdjust},
968 // {"dMassTranslate", (void **) &dMassTranslate},
969 // {"dMassRotate", (void **) &dMassRotate},
970 // {"dMassAdd", (void **) &dMassAdd},
972 {"dWorldCreate", (void **) &dWorldCreate},
973 {"dWorldDestroy", (void **) &dWorldDestroy},
974 {"dWorldSetGravity", (void **) &dWorldSetGravity},
975 {"dWorldGetGravity", (void **) &dWorldGetGravity},
976 // {"dWorldSetERP", (void **) &dWorldSetERP},
977 // {"dWorldGetERP", (void **) &dWorldGetERP},
978 // {"dWorldSetCFM", (void **) &dWorldSetCFM},
979 // {"dWorldGetCFM", (void **) &dWorldGetCFM},
980 {"dWorldStep", (void **) &dWorldStep},
981 // {"dWorldImpulseToForce", (void **) &dWorldImpulseToForce},
982 {"dWorldQuickStep", (void **) &dWorldQuickStep},
983 {"dWorldSetQuickStepNumIterations", (void **) &dWorldSetQuickStepNumIterations},
984 // {"dWorldGetQuickStepNumIterations", (void **) &dWorldGetQuickStepNumIterations},
985 // {"dWorldSetQuickStepW", (void **) &dWorldSetQuickStepW},
986 // {"dWorldGetQuickStepW", (void **) &dWorldGetQuickStepW},
987 // {"dWorldSetContactMaxCorrectingVel", (void **) &dWorldSetContactMaxCorrectingVel},
988 // {"dWorldGetContactMaxCorrectingVel", (void **) &dWorldGetContactMaxCorrectingVel},
989 {"dWorldSetContactSurfaceLayer", (void **) &dWorldSetContactSurfaceLayer},
990 // {"dWorldGetContactSurfaceLayer", (void **) &dWorldGetContactSurfaceLayer},
991 {"dWorldStepFast1", (void **) &dWorldStepFast1},
992 // {"dWorldSetAutoEnableDepthSF1", (void **) &dWorldSetAutoEnableDepthSF1},
993 // {"dWorldGetAutoEnableDepthSF1", (void **) &dWorldGetAutoEnableDepthSF1},
994 // {"dWorldGetAutoDisableLinearThreshold", (void **) &dWorldGetAutoDisableLinearThreshold},
995 // {"dWorldSetAutoDisableLinearThreshold", (void **) &dWorldSetAutoDisableLinearThreshold},
996 // {"dWorldGetAutoDisableAngularThreshold", (void **) &dWorldGetAutoDisableAngularThreshold},
997 // {"dWorldSetAutoDisableAngularThreshold", (void **) &dWorldSetAutoDisableAngularThreshold},
998 // {"dWorldGetAutoDisableLinearAverageThreshold", (void **) &dWorldGetAutoDisableLinearAverageThreshold},
999 // {"dWorldSetAutoDisableLinearAverageThreshold", (void **) &dWorldSetAutoDisableLinearAverageThreshold},
1000 // {"dWorldGetAutoDisableAngularAverageThreshold", (void **) &dWorldGetAutoDisableAngularAverageThreshold},
1001 // {"dWorldSetAutoDisableAngularAverageThreshold", (void **) &dWorldSetAutoDisableAngularAverageThreshold},
1002 // {"dWorldGetAutoDisableAverageSamplesCount", (void **) &dWorldGetAutoDisableAverageSamplesCount},
1003 // {"dWorldSetAutoDisableAverageSamplesCount", (void **) &dWorldSetAutoDisableAverageSamplesCount},
1004 // {"dWorldGetAutoDisableSteps", (void **) &dWorldGetAutoDisableSteps},
1005 // {"dWorldSetAutoDisableSteps", (void **) &dWorldSetAutoDisableSteps},
1006 // {"dWorldGetAutoDisableTime", (void **) &dWorldGetAutoDisableTime},
1007 // {"dWorldSetAutoDisableTime", (void **) &dWorldSetAutoDisableTime},
1008 // {"dWorldGetAutoDisableFlag", (void **) &dWorldGetAutoDisableFlag},
1009 // {"dWorldSetAutoDisableFlag", (void **) &dWorldSetAutoDisableFlag},
1010 // {"dWorldGetLinearDampingThreshold", (void **) &dWorldGetLinearDampingThreshold},
1011 // {"dWorldSetLinearDampingThreshold", (void **) &dWorldSetLinearDampingThreshold},
1012 // {"dWorldGetAngularDampingThreshold", (void **) &dWorldGetAngularDampingThreshold},
1013 // {"dWorldSetAngularDampingThreshold", (void **) &dWorldSetAngularDampingThreshold},
1014 // {"dWorldGetLinearDamping", (void **) &dWorldGetLinearDamping},
1015 // {"dWorldSetLinearDamping", (void **) &dWorldSetLinearDamping},
1016 // {"dWorldGetAngularDamping", (void **) &dWorldGetAngularDamping},
1017 // {"dWorldSetAngularDamping", (void **) &dWorldSetAngularDamping},
1018 // {"dWorldSetDamping", (void **) &dWorldSetDamping},
1019 // {"dWorldGetMaxAngularSpeed", (void **) &dWorldGetMaxAngularSpeed},
1020 // {"dWorldSetMaxAngularSpeed", (void **) &dWorldSetMaxAngularSpeed},
1021 // {"dBodyGetAutoDisableLinearThreshold", (void **) &dBodyGetAutoDisableLinearThreshold},
1022 // {"dBodySetAutoDisableLinearThreshold", (void **) &dBodySetAutoDisableLinearThreshold},
1023 // {"dBodyGetAutoDisableAngularThreshold", (void **) &dBodyGetAutoDisableAngularThreshold},
1024 // {"dBodySetAutoDisableAngularThreshold", (void **) &dBodySetAutoDisableAngularThreshold},
1025 // {"dBodyGetAutoDisableAverageSamplesCount", (void **) &dBodyGetAutoDisableAverageSamplesCount},
1026 // {"dBodySetAutoDisableAverageSamplesCount", (void **) &dBodySetAutoDisableAverageSamplesCount},
1027 // {"dBodyGetAutoDisableSteps", (void **) &dBodyGetAutoDisableSteps},
1028 // {"dBodySetAutoDisableSteps", (void **) &dBodySetAutoDisableSteps},
1029 // {"dBodyGetAutoDisableTime", (void **) &dBodyGetAutoDisableTime},
1030 // {"dBodySetAutoDisableTime", (void **) &dBodySetAutoDisableTime},
1031 // {"dBodyGetAutoDisableFlag", (void **) &dBodyGetAutoDisableFlag},
1032 // {"dBodySetAutoDisableFlag", (void **) &dBodySetAutoDisableFlag},
1033 // {"dBodySetAutoDisableDefaults", (void **) &dBodySetAutoDisableDefaults},
1034 // {"dBodyGetWorld", (void **) &dBodyGetWorld},
1035 {"dBodyCreate", (void **) &dBodyCreate},
1036 {"dBodyDestroy", (void **) &dBodyDestroy},
1037 {"dBodySetData", (void **) &dBodySetData},
1038 {"dBodyGetData", (void **) &dBodyGetData},
1039 {"dBodySetPosition", (void **) &dBodySetPosition},
1040 {"dBodySetRotation", (void **) &dBodySetRotation},
1041 // {"dBodySetQuaternion", (void **) &dBodySetQuaternion},
1042 {"dBodySetLinearVel", (void **) &dBodySetLinearVel},
1043 {"dBodySetAngularVel", (void **) &dBodySetAngularVel},
1044 {"dBodyGetPosition", (void **) &dBodyGetPosition},
1045 // {"dBodyCopyPosition", (void **) &dBodyCopyPosition},
1046 {"dBodyGetRotation", (void **) &dBodyGetRotation},
1047 // {"dBodyCopyRotation", (void **) &dBodyCopyRotation},
1048 // {"dBodyGetQuaternion", (void **) &dBodyGetQuaternion},
1049 // {"dBodyCopyQuaternion", (void **) &dBodyCopyQuaternion},
1050 {"dBodyGetLinearVel", (void **) &dBodyGetLinearVel},
1051 {"dBodyGetAngularVel", (void **) &dBodyGetAngularVel},
1052 {"dBodySetMass", (void **) &dBodySetMass},
1053 // {"dBodyGetMass", (void **) &dBodyGetMass},
1054 // {"dBodyAddForce", (void **) &dBodyAddForce},
1055 // {"dBodyAddTorque", (void **) &dBodyAddTorque},
1056 // {"dBodyAddRelForce", (void **) &dBodyAddRelForce},
1057 // {"dBodyAddRelTorque", (void **) &dBodyAddRelTorque},
1058 // {"dBodyAddForceAtPos", (void **) &dBodyAddForceAtPos},
1059 // {"dBodyAddForceAtRelPos", (void **) &dBodyAddForceAtRelPos},
1060 // {"dBodyAddRelForceAtPos", (void **) &dBodyAddRelForceAtPos},
1061 // {"dBodyAddRelForceAtRelPos", (void **) &dBodyAddRelForceAtRelPos},
1062 // {"dBodyGetForce", (void **) &dBodyGetForce},
1063 // {"dBodyGetTorque", (void **) &dBodyGetTorque},
1064 // {"dBodySetForce", (void **) &dBodySetForce},
1065 // {"dBodySetTorque", (void **) &dBodySetTorque},
1066 // {"dBodyGetRelPointPos", (void **) &dBodyGetRelPointPos},
1067 // {"dBodyGetRelPointVel", (void **) &dBodyGetRelPointVel},
1068 // {"dBodyGetPointVel", (void **) &dBodyGetPointVel},
1069 // {"dBodyGetPosRelPoint", (void **) &dBodyGetPosRelPoint},
1070 // {"dBodyVectorToWorld", (void **) &dBodyVectorToWorld},
1071 // {"dBodyVectorFromWorld", (void **) &dBodyVectorFromWorld},
1072 // {"dBodySetFiniteRotationMode", (void **) &dBodySetFiniteRotationMode},
1073 // {"dBodySetFiniteRotationAxis", (void **) &dBodySetFiniteRotationAxis},
1074 // {"dBodyGetFiniteRotationMode", (void **) &dBodyGetFiniteRotationMode},
1075 // {"dBodyGetFiniteRotationAxis", (void **) &dBodyGetFiniteRotationAxis},
1076 // {"dBodyGetNumJoints", (void **) &dBodyGetNumJoints},
1077 // {"dBodyGetJoint", (void **) &dBodyGetJoint},
1078 // {"dBodySetDynamic", (void **) &dBodySetDynamic},
1079 // {"dBodySetKinematic", (void **) &dBodySetKinematic},
1080 // {"dBodyIsKinematic", (void **) &dBodyIsKinematic},
1081 // {"dBodyEnable", (void **) &dBodyEnable},
1082 // {"dBodyDisable", (void **) &dBodyDisable},
1083 // {"dBodyIsEnabled", (void **) &dBodyIsEnabled},
1084 {"dBodySetGravityMode", (void **) &dBodySetGravityMode},
1085 {"dBodyGetGravityMode", (void **) &dBodyGetGravityMode},
1086 // {"dBodySetMovedCallback", (void **) &dBodySetMovedCallback},
1087 // {"dBodyGetFirstGeom", (void **) &dBodyGetFirstGeom},
1088 // {"dBodyGetNextGeom", (void **) &dBodyGetNextGeom},
1089 // {"dBodySetDampingDefaults", (void **) &dBodySetDampingDefaults},
1090 // {"dBodyGetLinearDamping", (void **) &dBodyGetLinearDamping},
1091 // {"dBodySetLinearDamping", (void **) &dBodySetLinearDamping},
1092 // {"dBodyGetAngularDamping", (void **) &dBodyGetAngularDamping},
1093 // {"dBodySetAngularDamping", (void **) &dBodySetAngularDamping},
1094 // {"dBodySetDamping", (void **) &dBodySetDamping},
1095 // {"dBodyGetLinearDampingThreshold", (void **) &dBodyGetLinearDampingThreshold},
1096 // {"dBodySetLinearDampingThreshold", (void **) &dBodySetLinearDampingThreshold},
1097 // {"dBodyGetAngularDampingThreshold", (void **) &dBodyGetAngularDampingThreshold},
1098 // {"dBodySetAngularDampingThreshold", (void **) &dBodySetAngularDampingThreshold},
1099 // {"dBodyGetMaxAngularSpeed", (void **) &dBodyGetMaxAngularSpeed},
1100 // {"dBodySetMaxAngularSpeed", (void **) &dBodySetMaxAngularSpeed},
1101 // {"dBodyGetGyroscopicMode", (void **) &dBodyGetGyroscopicMode},
1102 // {"dBodySetGyroscopicMode", (void **) &dBodySetGyroscopicMode},
1103 // {"dJointCreateBall", (void **) &dJointCreateBall},
1104 // {"dJointCreateHinge", (void **) &dJointCreateHinge},
1105 // {"dJointCreateSlider", (void **) &dJointCreateSlider},
1106 {"dJointCreateContact", (void **) &dJointCreateContact},
1107 // {"dJointCreateHinge2", (void **) &dJointCreateHinge2},
1108 // {"dJointCreateUniversal", (void **) &dJointCreateUniversal},
1109 // {"dJointCreatePR", (void **) &dJointCreatePR},
1110 // {"dJointCreatePU", (void **) &dJointCreatePU},
1111 // {"dJointCreatePiston", (void **) &dJointCreatePiston},
1112 // {"dJointCreateFixed", (void **) &dJointCreateFixed},
1113 // {"dJointCreateNull", (void **) &dJointCreateNull},
1114 // {"dJointCreateAMotor", (void **) &dJointCreateAMotor},
1115 // {"dJointCreateLMotor", (void **) &dJointCreateLMotor},
1116 // {"dJointCreatePlane2D", (void **) &dJointCreatePlane2D},
1117 // {"dJointDestroy", (void **) &dJointDestroy},
1118 {"dJointGroupCreate", (void **) &dJointGroupCreate},
1119 {"dJointGroupDestroy", (void **) &dJointGroupDestroy},
1120 {"dJointGroupEmpty", (void **) &dJointGroupEmpty},
1121 // {"dJointGetNumBodies", (void **) &dJointGetNumBodies},
1122 {"dJointAttach", (void **) &dJointAttach},
1123 // {"dJointEnable", (void **) &dJointEnable},
1124 // {"dJointDisable", (void **) &dJointDisable},
1125 // {"dJointIsEnabled", (void **) &dJointIsEnabled},
1126 // {"dJointSetData", (void **) &dJointSetData},
1127 // {"dJointGetData", (void **) &dJointGetData},
1128 // {"dJointGetType", (void **) &dJointGetType},
1129 // {"dJointGetBody", (void **) &dJointGetBody},
1130 // {"dJointSetFeedback", (void **) &dJointSetFeedback},
1131 // {"dJointGetFeedback", (void **) &dJointGetFeedback},
1132 // {"dJointSetBallAnchor", (void **) &dJointSetBallAnchor},
1133 // {"dJointSetBallAnchor2", (void **) &dJointSetBallAnchor2},
1134 // {"dJointSetBallParam", (void **) &dJointSetBallParam},
1135 // {"dJointSetHingeAnchor", (void **) &dJointSetHingeAnchor},
1136 // {"dJointSetHingeAnchorDelta", (void **) &dJointSetHingeAnchorDelta},
1137 // {"dJointSetHingeAxis", (void **) &dJointSetHingeAxis},
1138 // {"dJointSetHingeAxisOffset", (void **) &dJointSetHingeAxisOffset},
1139 // {"dJointSetHingeParam", (void **) &dJointSetHingeParam},
1140 // {"dJointAddHingeTorque", (void **) &dJointAddHingeTorque},
1141 // {"dJointSetSliderAxis", (void **) &dJointSetSliderAxis},
1142 // {"dJointSetSliderAxisDelta", (void **) &dJointSetSliderAxisDelta},
1143 // {"dJointSetSliderParam", (void **) &dJointSetSliderParam},
1144 // {"dJointAddSliderForce", (void **) &dJointAddSliderForce},
1145 // {"dJointSetHinge2Anchor", (void **) &dJointSetHinge2Anchor},
1146 // {"dJointSetHinge2Axis1", (void **) &dJointSetHinge2Axis1},
1147 // {"dJointSetHinge2Axis2", (void **) &dJointSetHinge2Axis2},
1148 // {"dJointSetHinge2Param", (void **) &dJointSetHinge2Param},
1149 // {"dJointAddHinge2Torques", (void **) &dJointAddHinge2Torques},
1150 // {"dJointSetUniversalAnchor", (void **) &dJointSetUniversalAnchor},
1151 // {"dJointSetUniversalAxis1", (void **) &dJointSetUniversalAxis1},
1152 // {"dJointSetUniversalAxis1Offset", (void **) &dJointSetUniversalAxis1Offset},
1153 // {"dJointSetUniversalAxis2", (void **) &dJointSetUniversalAxis2},
1154 // {"dJointSetUniversalAxis2Offset", (void **) &dJointSetUniversalAxis2Offset},
1155 // {"dJointSetUniversalParam", (void **) &dJointSetUniversalParam},
1156 // {"dJointAddUniversalTorques", (void **) &dJointAddUniversalTorques},
1157 // {"dJointSetPRAnchor", (void **) &dJointSetPRAnchor},
1158 // {"dJointSetPRAxis1", (void **) &dJointSetPRAxis1},
1159 // {"dJointSetPRAxis2", (void **) &dJointSetPRAxis2},
1160 // {"dJointSetPRParam", (void **) &dJointSetPRParam},
1161 // {"dJointAddPRTorque", (void **) &dJointAddPRTorque},
1162 // {"dJointSetPUAnchor", (void **) &dJointSetPUAnchor},
1163 // {"dJointSetPUAnchorOffset", (void **) &dJointSetPUAnchorOffset},
1164 // {"dJointSetPUAxis1", (void **) &dJointSetPUAxis1},
1165 // {"dJointSetPUAxis2", (void **) &dJointSetPUAxis2},
1166 // {"dJointSetPUAxis3", (void **) &dJointSetPUAxis3},
1167 // {"dJointSetPUAxisP", (void **) &dJointSetPUAxisP},
1168 // {"dJointSetPUParam", (void **) &dJointSetPUParam},
1169 // {"dJointAddPUTorque", (void **) &dJointAddPUTorque},
1170 // {"dJointSetPistonAnchor", (void **) &dJointSetPistonAnchor},
1171 // {"dJointSetPistonAnchorOffset", (void **) &dJointSetPistonAnchorOffset},
1172 // {"dJointSetPistonParam", (void **) &dJointSetPistonParam},
1173 // {"dJointAddPistonForce", (void **) &dJointAddPistonForce},
1174 // {"dJointSetFixed", (void **) &dJointSetFixed},
1175 // {"dJointSetFixedParam", (void **) &dJointSetFixedParam},
1176 // {"dJointSetAMotorNumAxes", (void **) &dJointSetAMotorNumAxes},
1177 // {"dJointSetAMotorAxis", (void **) &dJointSetAMotorAxis},
1178 // {"dJointSetAMotorAngle", (void **) &dJointSetAMotorAngle},
1179 // {"dJointSetAMotorParam", (void **) &dJointSetAMotorParam},
1180 // {"dJointSetAMotorMode", (void **) &dJointSetAMotorMode},
1181 // {"dJointAddAMotorTorques", (void **) &dJointAddAMotorTorques},
1182 // {"dJointSetLMotorNumAxes", (void **) &dJointSetLMotorNumAxes},
1183 // {"dJointSetLMotorAxis", (void **) &dJointSetLMotorAxis},
1184 // {"dJointSetLMotorParam", (void **) &dJointSetLMotorParam},
1185 // {"dJointSetPlane2DXParam", (void **) &dJointSetPlane2DXParam},
1186 // {"dJointSetPlane2DYParam", (void **) &dJointSetPlane2DYParam},
1187 // {"dJointSetPlane2DAngleParam", (void **) &dJointSetPlane2DAngleParam},
1188 // {"dJointGetBallAnchor", (void **) &dJointGetBallAnchor},
1189 // {"dJointGetBallAnchor2", (void **) &dJointGetBallAnchor2},
1190 // {"dJointGetBallParam", (void **) &dJointGetBallParam},
1191 // {"dJointGetHingeAnchor", (void **) &dJointGetHingeAnchor},
1192 // {"dJointGetHingeAnchor2", (void **) &dJointGetHingeAnchor2},
1193 // {"dJointGetHingeAxis", (void **) &dJointGetHingeAxis},
1194 // {"dJointGetHingeParam", (void **) &dJointGetHingeParam},
1195 // {"dJointGetHingeAngle", (void **) &dJointGetHingeAngle},
1196 // {"dJointGetHingeAngleRate", (void **) &dJointGetHingeAngleRate},
1197 // {"dJointGetSliderPosition", (void **) &dJointGetSliderPosition},
1198 // {"dJointGetSliderPositionRate", (void **) &dJointGetSliderPositionRate},
1199 // {"dJointGetSliderAxis", (void **) &dJointGetSliderAxis},
1200 // {"dJointGetSliderParam", (void **) &dJointGetSliderParam},
1201 // {"dJointGetHinge2Anchor", (void **) &dJointGetHinge2Anchor},
1202 // {"dJointGetHinge2Anchor2", (void **) &dJointGetHinge2Anchor2},
1203 // {"dJointGetHinge2Axis1", (void **) &dJointGetHinge2Axis1},
1204 // {"dJointGetHinge2Axis2", (void **) &dJointGetHinge2Axis2},
1205 // {"dJointGetHinge2Param", (void **) &dJointGetHinge2Param},
1206 // {"dJointGetHinge2Angle1", (void **) &dJointGetHinge2Angle1},
1207 // {"dJointGetHinge2Angle1Rate", (void **) &dJointGetHinge2Angle1Rate},
1208 // {"dJointGetHinge2Angle2Rate", (void **) &dJointGetHinge2Angle2Rate},
1209 // {"dJointGetUniversalAnchor", (void **) &dJointGetUniversalAnchor},
1210 // {"dJointGetUniversalAnchor2", (void **) &dJointGetUniversalAnchor2},
1211 // {"dJointGetUniversalAxis1", (void **) &dJointGetUniversalAxis1},
1212 // {"dJointGetUniversalAxis2", (void **) &dJointGetUniversalAxis2},
1213 // {"dJointGetUniversalParam", (void **) &dJointGetUniversalParam},
1214 // {"dJointGetUniversalAngles", (void **) &dJointGetUniversalAngles},
1215 // {"dJointGetUniversalAngle1", (void **) &dJointGetUniversalAngle1},
1216 // {"dJointGetUniversalAngle2", (void **) &dJointGetUniversalAngle2},
1217 // {"dJointGetUniversalAngle1Rate", (void **) &dJointGetUniversalAngle1Rate},
1218 // {"dJointGetUniversalAngle2Rate", (void **) &dJointGetUniversalAngle2Rate},
1219 // {"dJointGetPRAnchor", (void **) &dJointGetPRAnchor},
1220 // {"dJointGetPRPosition", (void **) &dJointGetPRPosition},
1221 // {"dJointGetPRPositionRate", (void **) &dJointGetPRPositionRate},
1222 // {"dJointGetPRAngle", (void **) &dJointGetPRAngle},
1223 // {"dJointGetPRAngleRate", (void **) &dJointGetPRAngleRate},
1224 // {"dJointGetPRAxis1", (void **) &dJointGetPRAxis1},
1225 // {"dJointGetPRAxis2", (void **) &dJointGetPRAxis2},
1226 // {"dJointGetPRParam", (void **) &dJointGetPRParam},
1227 // {"dJointGetPUAnchor", (void **) &dJointGetPUAnchor},
1228 // {"dJointGetPUPosition", (void **) &dJointGetPUPosition},
1229 // {"dJointGetPUPositionRate", (void **) &dJointGetPUPositionRate},
1230 // {"dJointGetPUAxis1", (void **) &dJointGetPUAxis1},
1231 // {"dJointGetPUAxis2", (void **) &dJointGetPUAxis2},
1232 // {"dJointGetPUAxis3", (void **) &dJointGetPUAxis3},
1233 // {"dJointGetPUAxisP", (void **) &dJointGetPUAxisP},
1234 // {"dJointGetPUAngles", (void **) &dJointGetPUAngles},
1235 // {"dJointGetPUAngle1", (void **) &dJointGetPUAngle1},
1236 // {"dJointGetPUAngle1Rate", (void **) &dJointGetPUAngle1Rate},
1237 // {"dJointGetPUAngle2", (void **) &dJointGetPUAngle2},
1238 // {"dJointGetPUAngle2Rate", (void **) &dJointGetPUAngle2Rate},
1239 // {"dJointGetPUParam", (void **) &dJointGetPUParam},
1240 // {"dJointGetPistonPosition", (void **) &dJointGetPistonPosition},
1241 // {"dJointGetPistonPositionRate", (void **) &dJointGetPistonPositionRate},
1242 // {"dJointGetPistonAngle", (void **) &dJointGetPistonAngle},
1243 // {"dJointGetPistonAngleRate", (void **) &dJointGetPistonAngleRate},
1244 // {"dJointGetPistonAnchor", (void **) &dJointGetPistonAnchor},
1245 // {"dJointGetPistonAnchor2", (void **) &dJointGetPistonAnchor2},
1246 // {"dJointGetPistonAxis", (void **) &dJointGetPistonAxis},
1247 // {"dJointGetPistonParam", (void **) &dJointGetPistonParam},
1248 // {"dJointGetAMotorNumAxes", (void **) &dJointGetAMotorNumAxes},
1249 // {"dJointGetAMotorAxis", (void **) &dJointGetAMotorAxis},
1250 // {"dJointGetAMotorAxisRel", (void **) &dJointGetAMotorAxisRel},
1251 // {"dJointGetAMotorAngle", (void **) &dJointGetAMotorAngle},
1252 // {"dJointGetAMotorAngleRate", (void **) &dJointGetAMotorAngleRate},
1253 // {"dJointGetAMotorParam", (void **) &dJointGetAMotorParam},
1254 // {"dJointGetAMotorMode", (void **) &dJointGetAMotorMode},
1255 // {"dJointGetLMotorNumAxes", (void **) &dJointGetLMotorNumAxes},
1256 // {"dJointGetLMotorAxis", (void **) &dJointGetLMotorAxis},
1257 // {"dJointGetLMotorParam", (void **) &dJointGetLMotorParam},
1258 // {"dJointGetFixedParam", (void **) &dJointGetFixedParam},
1259 // {"dConnectingJoint", (void **) &dConnectingJoint},
1260 // {"dConnectingJointList", (void **) &dConnectingJointList},
1261 {"dAreConnected", (void **) &dAreConnected},
1262 {"dAreConnectedExcluding", (void **) &dAreConnectedExcluding},
1263 {"dSimpleSpaceCreate", (void **) &dSimpleSpaceCreate},
1264 {"dHashSpaceCreate", (void **) &dHashSpaceCreate},
1265 {"dQuadTreeSpaceCreate", (void **) &dQuadTreeSpaceCreate},
1266 // {"dSweepAndPruneSpaceCreate", (void **) &dSweepAndPruneSpaceCreate},
1267 {"dSpaceDestroy", (void **) &dSpaceDestroy},
1268 // {"dHashSpaceSetLevels", (void **) &dHashSpaceSetLevels},
1269 // {"dHashSpaceGetLevels", (void **) &dHashSpaceGetLevels},
1270 // {"dSpaceSetCleanup", (void **) &dSpaceSetCleanup},
1271 // {"dSpaceGetCleanup", (void **) &dSpaceGetCleanup},
1272 // {"dSpaceSetSublevel", (void **) &dSpaceSetSublevel},
1273 // {"dSpaceGetSublevel", (void **) &dSpaceGetSublevel},
1274 // {"dSpaceSetManualCleanup", (void **) &dSpaceSetManualCleanup},
1275 // {"dSpaceGetManualCleanup", (void **) &dSpaceGetManualCleanup},
1276 // {"dSpaceAdd", (void **) &dSpaceAdd},
1277 // {"dSpaceRemove", (void **) &dSpaceRemove},
1278 // {"dSpaceQuery", (void **) &dSpaceQuery},
1279 // {"dSpaceClean", (void **) &dSpaceClean},
1280 // {"dSpaceGetNumGeoms", (void **) &dSpaceGetNumGeoms},
1281 // {"dSpaceGetGeom", (void **) &dSpaceGetGeom},
1282 // {"dSpaceGetClass", (void **) &dSpaceGetClass},
1283 {"dGeomDestroy", (void **) &dGeomDestroy},
1284 // {"dGeomSetData", (void **) &dGeomSetData},
1285 // {"dGeomGetData", (void **) &dGeomGetData},
1286 {"dGeomSetBody", (void **) &dGeomSetBody},
1287 {"dGeomGetBody", (void **) &dGeomGetBody},
1288 // {"dGeomSetPosition", (void **) &dGeomSetPosition},
1289 {"dGeomSetRotation", (void **) &dGeomSetRotation},
1290 // {"dGeomSetQuaternion", (void **) &dGeomSetQuaternion},
1291 // {"dGeomGetPosition", (void **) &dGeomGetPosition},
1292 // {"dGeomCopyPosition", (void **) &dGeomCopyPosition},
1293 // {"dGeomGetRotation", (void **) &dGeomGetRotation},
1294 // {"dGeomCopyRotation", (void **) &dGeomCopyRotation},
1295 // {"dGeomGetQuaternion", (void **) &dGeomGetQuaternion},
1296 // {"dGeomGetAABB", (void **) &dGeomGetAABB},
1297 {"dGeomIsSpace", (void **) &dGeomIsSpace},
1298 // {"dGeomGetSpace", (void **) &dGeomGetSpace},
1299 // {"dGeomGetClass", (void **) &dGeomGetClass},
1300 // {"dGeomSetCategoryBits", (void **) &dGeomSetCategoryBits},
1301 // {"dGeomSetCollideBits", (void **) &dGeomSetCollideBits},
1302 // {"dGeomGetCategoryBits", (void **) &dGeomGetCategoryBits},
1303 // {"dGeomGetCollideBits", (void **) &dGeomGetCollideBits},
1304 // {"dGeomEnable", (void **) &dGeomEnable},
1305 // {"dGeomDisable", (void **) &dGeomDisable},
1306 // {"dGeomIsEnabled", (void **) &dGeomIsEnabled},
1307 // {"dGeomSetOffsetPosition", (void **) &dGeomSetOffsetPosition},
1308 // {"dGeomSetOffsetRotation", (void **) &dGeomSetOffsetRotation},
1309 // {"dGeomSetOffsetQuaternion", (void **) &dGeomSetOffsetQuaternion},
1310 // {"dGeomSetOffsetWorldPosition", (void **) &dGeomSetOffsetWorldPosition},
1311 // {"dGeomSetOffsetWorldRotation", (void **) &dGeomSetOffsetWorldRotation},
1312 // {"dGeomSetOffsetWorldQuaternion", (void **) &dGeomSetOffsetWorldQuaternion},
1313 // {"dGeomClearOffset", (void **) &dGeomClearOffset},
1314 // {"dGeomIsOffset", (void **) &dGeomIsOffset},
1315 // {"dGeomGetOffsetPosition", (void **) &dGeomGetOffsetPosition},
1316 // {"dGeomCopyOffsetPosition", (void **) &dGeomCopyOffsetPosition},
1317 // {"dGeomGetOffsetRotation", (void **) &dGeomGetOffsetRotation},
1318 // {"dGeomCopyOffsetRotation", (void **) &dGeomCopyOffsetRotation},
1319 // {"dGeomGetOffsetQuaternion", (void **) &dGeomGetOffsetQuaternion},
1320 {"dCollide", (void **) &dCollide},
1321 {"dSpaceCollide", (void **) &dSpaceCollide},
1322 {"dSpaceCollide2", (void **) &dSpaceCollide2},
1323 {"dCreateSphere", (void **) &dCreateSphere},
1324 // {"dGeomSphereSetRadius", (void **) &dGeomSphereSetRadius},
1325 // {"dGeomSphereGetRadius", (void **) &dGeomSphereGetRadius},
1326 // {"dGeomSpherePointDepth", (void **) &dGeomSpherePointDepth},
1327 // {"dCreateConvex", (void **) &dCreateConvex},
1328 // {"dGeomSetConvex", (void **) &dGeomSetConvex},
1329 {"dCreateBox", (void **) &dCreateBox},
1330 // {"dGeomBoxSetLengths", (void **) &dGeomBoxSetLengths},
1331 // {"dGeomBoxGetLengths", (void **) &dGeomBoxGetLengths},
1332 // {"dGeomBoxPointDepth", (void **) &dGeomBoxPointDepth},
1333 // {"dGeomBoxPointDepth", (void **) &dGeomBoxPointDepth},
1334 // {"dCreatePlane", (void **) &dCreatePlane},
1335 // {"dGeomPlaneSetParams", (void **) &dGeomPlaneSetParams},
1336 // {"dGeomPlaneGetParams", (void **) &dGeomPlaneGetParams},
1337 // {"dGeomPlanePointDepth", (void **) &dGeomPlanePointDepth},
1338 {"dCreateCapsule", (void **) &dCreateCapsule},
1339 // {"dGeomCapsuleSetParams", (void **) &dGeomCapsuleSetParams},
1340 // {"dGeomCapsuleGetParams", (void **) &dGeomCapsuleGetParams},
1341 // {"dGeomCapsulePointDepth", (void **) &dGeomCapsulePointDepth},
1342 // {"dCreateCylinder", (void **) &dCreateCylinder},
1343 // {"dGeomCylinderSetParams", (void **) &dGeomCylinderSetParams},
1344 // {"dGeomCylinderGetParams", (void **) &dGeomCylinderGetParams},
1345 // {"dCreateRay", (void **) &dCreateRay},
1346 // {"dGeomRaySetLength", (void **) &dGeomRaySetLength},
1347 // {"dGeomRayGetLength", (void **) &dGeomRayGetLength},
1348 // {"dGeomRaySet", (void **) &dGeomRaySet},
1349 // {"dGeomRayGet", (void **) &dGeomRayGet},
1350 {"dCreateGeomTransform", (void **) &dCreateGeomTransform},
1351 {"dGeomTransformSetGeom", (void **) &dGeomTransformSetGeom},
1352 // {"dGeomTransformGetGeom", (void **) &dGeomTransformGetGeom},
1353 {"dGeomTransformSetCleanup", (void **) &dGeomTransformSetCleanup},
1354 // {"dGeomTransformGetCleanup", (void **) &dGeomTransformGetCleanup},
1355 // {"dGeomTransformSetInfo", (void **) &dGeomTransformSetInfo},
1356 // {"dGeomTransformGetInfo", (void **) &dGeomTransformGetInfo},
1357 {"dGeomTriMeshDataCreate", (void **) &dGeomTriMeshDataCreate},
1358 {"dGeomTriMeshDataDestroy", (void **) &dGeomTriMeshDataDestroy},
1359 // {"dGeomTriMeshDataSet", (void **) &dGeomTriMeshDataSet},
1360 // {"dGeomTriMeshDataGet", (void **) &dGeomTriMeshDataGet},
1361 // {"dGeomTriMeshSetLastTransform", (void **) &dGeomTriMeshSetLastTransform},
1362 // {"dGeomTriMeshGetLastTransform", (void **) &dGeomTriMeshGetLastTransform},
1363 {"dGeomTriMeshDataBuildSingle", (void **) &dGeomTriMeshDataBuildSingle},
1364 // {"dGeomTriMeshDataBuildSingle1", (void **) &dGeomTriMeshDataBuildSingle1},
1365 // {"dGeomTriMeshDataBuildDouble", (void **) &dGeomTriMeshDataBuildDouble},
1366 // {"dGeomTriMeshDataBuildDouble1", (void **) &dGeomTriMeshDataBuildDouble1},
1367 // {"dGeomTriMeshDataBuildSimple", (void **) &dGeomTriMeshDataBuildSimple},
1368 // {"dGeomTriMeshDataBuildSimple1", (void **) &dGeomTriMeshDataBuildSimple1},
1369 // {"dGeomTriMeshDataPreprocess", (void **) &dGeomTriMeshDataPreprocess},
1370 // {"dGeomTriMeshDataGetBuffer", (void **) &dGeomTriMeshDataGetBuffer},
1371 // {"dGeomTriMeshDataSetBuffer", (void **) &dGeomTriMeshDataSetBuffer},
1372 // {"dGeomTriMeshSetCallback", (void **) &dGeomTriMeshSetCallback},
1373 // {"dGeomTriMeshGetCallback", (void **) &dGeomTriMeshGetCallback},
1374 // {"dGeomTriMeshSetArrayCallback", (void **) &dGeomTriMeshSetArrayCallback},
1375 // {"dGeomTriMeshGetArrayCallback", (void **) &dGeomTriMeshGetArrayCallback},
1376 // {"dGeomTriMeshSetRayCallback", (void **) &dGeomTriMeshSetRayCallback},
1377 // {"dGeomTriMeshGetRayCallback", (void **) &dGeomTriMeshGetRayCallback},
1378 // {"dGeomTriMeshSetTriMergeCallback", (void **) &dGeomTriMeshSetTriMergeCallback},
1379 // {"dGeomTriMeshGetTriMergeCallback", (void **) &dGeomTriMeshGetTriMergeCallback},
1380 {"dCreateTriMesh", (void **) &dCreateTriMesh},
1381 // {"dGeomTriMeshSetData", (void **) &dGeomTriMeshSetData},
1382 // {"dGeomTriMeshGetData", (void **) &dGeomTriMeshGetData},
1383 // {"dGeomTriMeshEnableTC", (void **) &dGeomTriMeshEnableTC},
1384 // {"dGeomTriMeshIsTCEnabled", (void **) &dGeomTriMeshIsTCEnabled},
1385 // {"dGeomTriMeshClearTCCache", (void **) &dGeomTriMeshClearTCCache},
1386 // {"dGeomTriMeshGetTriMeshDataID", (void **) &dGeomTriMeshGetTriMeshDataID},
1387 // {"dGeomTriMeshGetTriangle", (void **) &dGeomTriMeshGetTriangle},
1388 // {"dGeomTriMeshGetPoint", (void **) &dGeomTriMeshGetPoint},
1389 // {"dGeomTriMeshGetTriangleCount", (void **) &dGeomTriMeshGetTriangleCount},
1390 // {"dGeomTriMeshDataUpdate", (void **) &dGeomTriMeshDataUpdate},
1394 // Handle for ODE DLL
1395 dllhandle_t ode_dll = NULL;
1399 static void World_Physics_Init(void)
1403 const char* dllnames [] =
1407 # elif defined(WIN32)
1409 # elif defined(MACOSX)
1418 Cvar_RegisterVariable(&physics_ode_quadtree_depth);
1419 Cvar_RegisterVariable(&physics_ode_contactsurfacelayer);
1420 Cvar_RegisterVariable(&physics_ode_worldquickstep);
1421 Cvar_RegisterVariable(&physics_ode_worldquickstep_iterations);
1422 Cvar_RegisterVariable(&physics_ode_worldstepfast);
1423 Cvar_RegisterVariable(&physics_ode_worldstepfast_iterations);
1424 Cvar_RegisterVariable(&physics_ode_contact_mu);
1425 Cvar_RegisterVariable(&physics_ode_contact_erp);
1426 Cvar_RegisterVariable(&physics_ode_contact_cfm);
1427 Cvar_RegisterVariable(&physics_ode_iterationsperframe);
1428 Cvar_RegisterVariable(&physics_ode_movelimit);
1429 Cvar_RegisterVariable(&physics_ode_spinlimit);
1433 if (Sys_LoadLibrary (dllnames, &ode_dll, odefuncs))
1440 if (!dCheckConfiguration("ODE_single_precision"))
1442 if (!dCheckConfiguration("ODE_double_precision"))
1446 Con_Printf("ode library not compiled for single precision - incompatible! Not using ODE physics.\n");
1448 Con_Printf("ode library not compiled for double precision - incompatible! Not using ODE physics.\n");
1450 Sys_UnloadLibrary(&ode_dll);
1458 static void World_Physics_Shutdown(void)
1467 Sys_UnloadLibrary(&ode_dll);
1475 static void World_Physics_EnableODE(world_t *world)
1477 dVector3 center, extents;
1478 if (world->physics.ode)
1484 world->physics.ode = true;
1485 VectorMAM(0.5f, world->mins, 0.5f, world->maxs, center);
1486 VectorSubtract(world->maxs, center, extents);
1487 world->physics.ode_world = dWorldCreate();
1488 world->physics.ode_space = dQuadTreeSpaceCreate(NULL, center, extents, bound(1, physics_ode_quadtree_depth.integer, 10));
1489 world->physics.ode_contactgroup = dJointGroupCreate(0);
1490 // we don't currently set dWorldSetCFM or dWorldSetERP because the defaults seem fine
1494 static void World_Physics_Start(world_t *world)
1497 if (world->physics.ode)
1499 World_Physics_EnableODE(world);
1503 static void World_Physics_End(world_t *world)
1506 if (world->physics.ode)
1508 dWorldDestroy(world->physics.ode_world);
1509 dSpaceDestroy(world->physics.ode_space);
1510 dJointGroupDestroy(world->physics.ode_contactgroup);
1511 world->physics.ode = false;
1516 void World_Physics_RemoveJointFromEntity(world_t *world, prvm_edict_t *ed)
1518 ed->priv.server->ode_joint_type = 0;
1520 if(ed->priv.server->ode_joint)
1521 dJointDestroy((dJointID)ed->priv.server->ode_joint);
1522 ed->priv.server->ode_joint = NULL;
1526 void World_Physics_RemoveFromEntity(world_t *world, prvm_edict_t *ed)
1528 // entity is not physics controlled, free any physics data
1530 ed->priv.server->ode_physics = false;
1532 if (ed->priv.server->ode_geom)
1533 dGeomDestroy((dGeomID)ed->priv.server->ode_geom);
1534 ed->priv.server->ode_geom = NULL;
1535 if (ed->priv.server->ode_body)
1539 while(dBodyGetNumJoints((dBodyID)ed->priv.server->ode_body))
1541 j = dBodyGetJoint((dBodyID)ed->priv.server->ode_body, 0);
1542 ed2 = (prvm_edict_t *) dJointGetData(j);
1543 b1 = dJointGetBody(j, 0);
1544 b2 = dJointGetBody(j, 1);
1545 if(b1 == (dBodyID)ed->priv.server->ode_body)
1548 ed2->priv.server->ode_joint_enemy = 0;
1550 if(b2 == (dBodyID)ed->priv.server->ode_body)
1553 ed2->priv.server->ode_joint_aiment = 0;
1555 dJointAttach(j, b1, b2);
1557 dBodyDestroy((dBodyID)ed->priv.server->ode_body);
1559 ed->priv.server->ode_body = NULL;
1561 if (ed->priv.server->ode_vertex3f)
1562 Mem_Free(ed->priv.server->ode_vertex3f);
1563 ed->priv.server->ode_vertex3f = NULL;
1564 ed->priv.server->ode_numvertices = 0;
1565 if (ed->priv.server->ode_element3i)
1566 Mem_Free(ed->priv.server->ode_element3i);
1567 ed->priv.server->ode_element3i = NULL;
1568 ed->priv.server->ode_numtriangles = 0;
1572 static void World_Physics_Frame_BodyToEntity(world_t *world, prvm_edict_t *ed)
1576 const dReal *r; // for some reason dBodyGetRotation returns a [3][4] matrix
1578 dBodyID body = (dBodyID)ed->priv.server->ode_body;
1580 matrix4x4_t bodymatrix;
1581 matrix4x4_t entitymatrix;
1585 vec3_t forward, left, up;
1587 vec3_t spinvelocity;
1592 val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.movetype);
1593 movetype = (int)val->_float;
1594 if (movetype != MOVETYPE_PHYSICS)
1596 val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.jointtype);if (val) jointtype = (int)val->_float;
1599 // TODO feed back data from physics
1600 case JOINTTYPE_POINT:
1602 case JOINTTYPE_HINGE:
1604 case JOINTTYPE_SLIDER:
1606 case JOINTTYPE_UNIVERSAL:
1608 case JOINTTYPE_HINGE2:
1610 case JOINTTYPE_PISTON:
1615 // store the physics engine data into the entity
1616 o = dBodyGetPosition(body);
1617 r = dBodyGetRotation(body);
1618 vel = dBodyGetLinearVel(body);
1619 avel = dBodyGetAngularVel(body);
1620 VectorCopy(o, origin);
1630 VectorCopy(vel, velocity);
1631 VectorCopy(avel, spinvelocity);
1632 Matrix4x4_FromVectors(&bodymatrix, forward, left, up, origin);
1633 Matrix4x4_Concat(&entitymatrix, &bodymatrix, &ed->priv.server->ode_offsetimatrix);
1634 Matrix4x4_ToVectors(&entitymatrix, forward, left, up, origin);
1636 AnglesFromVectors(angles, forward, up, false);
1637 VectorSet(avelocity, RAD2DEG(spinvelocity[PITCH]), RAD2DEG(spinvelocity[ROLL]), RAD2DEG(spinvelocity[YAW]));
1640 float pitchsign = 1;
1641 if(!strcmp(prog->name, "server")) // FIXME some better way?
1643 pitchsign = SV_GetPitchSign(ed);
1645 else if(!strcmp(prog->name, "client"))
1647 pitchsign = CL_GetPitchSign(ed);
1649 angles[PITCH] *= pitchsign;
1650 avelocity[PITCH] *= pitchsign;
1653 val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.origin);if (val) VectorCopy(origin, val->vector);
1654 val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.velocity);if (val) VectorCopy(velocity, val->vector);
1655 //val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.axis_forward);if (val) VectorCopy(forward, val->vector);
1656 //val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.axis_left);if (val) VectorCopy(left, val->vector);
1657 //val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.axis_up);if (val) VectorCopy(up, val->vector);
1658 //val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.spinvelocity);if (val) VectorCopy(spinvelocity, val->vector);
1659 val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.angles);if (val) VectorCopy(angles, val->vector);
1660 val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.avelocity);if (val) VectorCopy(avelocity, val->vector);
1662 // values for BodyFromEntity to check if the qc modified anything later
1663 VectorCopy(origin, ed->priv.server->ode_origin);
1664 VectorCopy(velocity, ed->priv.server->ode_velocity);
1665 VectorCopy(angles, ed->priv.server->ode_angles);
1666 VectorCopy(avelocity, ed->priv.server->ode_avelocity);
1667 ed->priv.server->ode_gravity = dBodyGetGravityMode(body);
1670 static void World_Physics_Frame_JointFromEntity(world_t *world, prvm_edict_t *ed)
1677 int enemy = 0, aiment = 0;
1678 vec3_t origin, velocity, angles, forward, left, up;
1680 VectorClear(origin);
1681 VectorClear(velocity);
1682 VectorClear(angles);
1683 val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.movetype);if (val) movetype = (int)val->_float;
1684 val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.jointtype);if (val) jointtype = (int)val->_float;
1685 val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.enemy);if (val) enemy = val->_int;
1686 val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.aiment);if (val) aiment = val->_int;
1687 val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.origin);if (val) VectorCopy(val->vector, origin);
1688 val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.velocity);if (val) VectorCopy(val->vector, velocity);
1689 val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.angles);if (val) VectorCopy(val->vector, angles);
1690 if(movetype == MOVETYPE_PHYSICS)
1691 jointtype = 0; // can't have both
1692 if(enemy <= 0 || enemy >= prog->num_edicts || prog->edicts[enemy].priv.required->free || prog->edicts[enemy].priv.server->ode_body == 0)
1694 if(aiment <= 0 || aiment >= prog->num_edicts || prog->edicts[aiment].priv.required->free || prog->edicts[aiment].priv.server->ode_body == 0)
1696 if(jointtype == ed->priv.server->ode_joint_type && VectorCompare(origin, ed->priv.server->ode_joint_origin) && VectorCompare(velocity, ed->priv.server->ode_joint_velocity) && VectorCompare(angles, ed->priv.server->ode_joint_angles) && enemy == ed->priv.server->ode_joint_enemy && aiment == ed->priv.server->ode_joint_aiment)
1697 return; // nothing to do
1698 AngleVectorsFLU(angles, forward, left, up);
1701 case JOINTTYPE_POINT:
1702 j = dJointCreateBall(world->physics.ode_world, 0);
1704 case JOINTTYPE_HINGE:
1705 j = dJointCreateHinge(world->physics.ode_world, 0);
1707 case JOINTTYPE_SLIDER:
1708 j = dJointCreateSlider(world->physics.ode_world, 0);
1710 case JOINTTYPE_UNIVERSAL:
1711 j = dJointCreateUniversal(world->physics.ode_world, 0);
1713 case JOINTTYPE_HINGE2:
1714 j = dJointCreateHinge2(world->physics.ode_world, 0);
1716 case JOINTTYPE_PISTON:
1717 j = dJointCreatePiston(world->physics.ode_world, 0);
1725 ed->priv.server->ode_joint = (void *) j;
1726 ed->priv.server->ode_joint_type = jointtype;
1727 ed->priv.server->ode_joint_enemy = enemy;
1728 ed->priv.server->ode_joint_aiment = aiment;
1729 VectorCopy(origin, ed->priv.server->ode_joint_origin);
1730 VectorCopy(velocity, ed->priv.server->ode_joint_velocity);
1731 VectorCopy(angles, ed->priv.server->ode_joint_angles);
1734 dJointSetData(j, (void *) ed);
1736 b1 = (dBodyID)prog->edicts[enemy].priv.server->ode_body;
1738 b2 = (dBodyID)prog->edicts[aiment].priv.server->ode_body;
1739 dJointAttach(j, b1, b2);
1742 case JOINTTYPE_POINT:
1743 dJointSetBallAnchor(j, origin[0], origin[1], origin[2]);
1745 case JOINTTYPE_HINGE:
1746 dJointSetHingeAnchor(j, origin[0], origin[1], origin[2]);
1747 dJointSetHingeAxis(j, forward[0], forward[1], forward[2]);
1749 case JOINTTYPE_SLIDER:
1750 dJointSetSliderAxis(j, forward[0], forward[1], forward[2]);
1752 case JOINTTYPE_UNIVERSAL:
1753 dJointSetUniversalAnchor(j, origin[0], origin[1], origin[2]);
1754 dJointSetUniversalAxis1(j, forward[0], forward[1], forward[2]);
1755 dJointSetUniversalAxis2(j, up[0], up[1], up[2]);
1757 case JOINTTYPE_HINGE2:
1758 dJointSetHinge2Anchor(j, origin[0], origin[1], origin[2]);
1759 dJointSetHinge2Axis1(j, forward[0], forward[1], forward[2]);
1760 dJointSetHinge2Axis2(j, velocity[0], velocity[1], velocity[2]);
1762 case JOINTTYPE_PISTON:
1763 dJointSetPistonAxis(j, forward[0], forward[1], forward[2]);
1767 Host_Error("what? but above the joint was valid...\n");
1773 static void World_Physics_Frame_BodyFromEntity(world_t *world, prvm_edict_t *ed)
1777 dBodyID body = (dBodyID)ed->priv.server->ode_body;
1781 dVector3 capsulerot[3];
1787 int movetype = MOVETYPE_NONE;
1790 int solid = SOLID_NOT;
1795 qboolean modified = false;
1805 vec3_t spinvelocity;
1810 vec_t massval = 1.0f;
1820 val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.solid);if (val) solid = (int)val->_float;
1821 val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.movetype);if (val) movetype = (int)val->_float;
1822 val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.movetype);if (val && val->_float) scale = val->_float;
1827 val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.modelindex);
1829 modelindex = (int)val->_float;
1830 if (world == &sv.world && modelindex >= 1 && modelindex < MAX_MODELS)
1832 model = sv.models[modelindex];
1833 mempool = sv_mempool;
1835 else if (world == &cl.world && modelindex >= 1 && modelindex < MAX_MODELS)
1837 model = cl.model_precache[modelindex];
1838 mempool = cls.levelmempool;
1848 VectorScale(model->normalmins, scale, entmins);
1849 VectorScale(model->normalmaxs, scale, entmaxs);
1850 val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.mass);if (val) massval = val->_float;
1859 //case SOLID_SLIDEBOX:
1861 case SOLID_PHYSICS_BOX:
1862 case SOLID_PHYSICS_SPHERE:
1863 case SOLID_PHYSICS_CAPSULE:
1864 val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.mins);if (val) VectorCopy(val->vector, entmins);
1865 val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.maxs);if (val) VectorCopy(val->vector, entmaxs);
1866 val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.mass);if (val) massval = val->_float;
1869 if (ed->priv.server->ode_physics)
1870 World_Physics_RemoveFromEntity(world, ed);
1874 VectorSubtract(entmaxs, entmins, geomsize);
1875 if (VectorLength2(geomsize) == 0)
1877 // we don't allow point-size physics objects...
1878 if (ed->priv.server->ode_physics)
1879 World_Physics_RemoveFromEntity(world, ed);
1883 if (movetype != MOVETYPE_PHYSICS)
1886 // check if we need to create or replace the geom
1887 if (!ed->priv.server->ode_physics
1888 || !VectorCompare(ed->priv.server->ode_mins, entmins)
1889 || !VectorCompare(ed->priv.server->ode_maxs, entmaxs)
1890 || ed->priv.server->ode_mass != massval
1891 || ed->priv.server->ode_modelindex != modelindex)
1894 World_Physics_RemoveFromEntity(world, ed);
1895 ed->priv.server->ode_physics = true;
1896 VectorCopy(entmins, ed->priv.server->ode_mins);
1897 VectorCopy(entmaxs, ed->priv.server->ode_maxs);
1898 ed->priv.server->ode_mass = massval;
1899 ed->priv.server->ode_modelindex = modelindex;
1900 VectorMAM(0.5f, entmins, 0.5f, entmaxs, geomcenter);
1901 ed->priv.server->ode_movelimit = min(geomsize[0], min(geomsize[1], geomsize[2]));
1903 if (massval * geomsize[0] * geomsize[1] * geomsize[2] == 0)
1905 if (movetype == MOVETYPE_PHYSICS)
1906 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));
1908 VectorSet(geomsize, 1.0f, 1.0f, 1.0f);
1914 ed->priv.server->ode_offsetmatrix = identitymatrix;
1917 Con_Printf("entity %i (classname %s) has no model\n", PRVM_NUM_FOR_EDICT(ed), PRVM_GetString(PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.classname)->string));
1920 // add an optimized mesh to the model containing only the SUPERCONTENTS_SOLID surfaces
1921 if (!model->brush.collisionmesh)
1922 Mod_CreateCollisionMesh(model);
1923 if (!model->brush.collisionmesh || !model->brush.collisionmesh->numtriangles)
1925 Con_Printf("entity %i (classname %s) has no geometry\n", PRVM_NUM_FOR_EDICT(ed), PRVM_GetString(PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.classname)->string));
1928 // ODE requires persistent mesh storage, so we need to copy out
1929 // the data from the model because renderer restarts could free it
1930 // during the game, additionally we need to flip the triangles...
1931 // note: ODE does preprocessing of the mesh for culling, removing
1932 // concave edges, etc., so this is not a lightweight operation
1933 ed->priv.server->ode_numvertices = numvertices = model->brush.collisionmesh->numverts;
1934 ed->priv.server->ode_vertex3f = (float *)Mem_Alloc(mempool, numvertices * sizeof(float[3]));
1935 for (vertexindex = 0, ov = ed->priv.server->ode_vertex3f, iv = model->brush.collisionmesh->vertex3f;vertexindex < numvertices;vertexindex++, ov += 3, iv += 3)
1937 ov[0] = iv[0] - geomcenter[0];
1938 ov[1] = iv[1] - geomcenter[1];
1939 ov[2] = iv[2] - geomcenter[2];
1941 ed->priv.server->ode_numtriangles = numtriangles = model->brush.collisionmesh->numtriangles;
1942 ed->priv.server->ode_element3i = (int *)Mem_Alloc(mempool, numtriangles * sizeof(int[3]));
1943 //memcpy(ed->priv.server->ode_element3i, model->brush.collisionmesh->element3i, ed->priv.server->ode_numtriangles * sizeof(int[3]));
1944 for (triangleindex = 0, oe = ed->priv.server->ode_element3i, ie = model->brush.collisionmesh->element3i;triangleindex < numtriangles;triangleindex++, oe += 3, ie += 3)
1950 Matrix4x4_CreateTranslate(&ed->priv.server->ode_offsetmatrix, geomcenter[0], geomcenter[1], geomcenter[2]);
1951 // now create the geom
1952 dataID = dGeomTriMeshDataCreate();
1953 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]));
1954 ed->priv.server->ode_body = (void *)(body = dBodyCreate(world->physics.ode_world));
1955 ed->priv.server->ode_geom = (void *)dCreateTriMesh(world->physics.ode_space, dataID, NULL, NULL, NULL);
1956 dGeomSetBody(ed->priv.server->ode_geom, body);
1957 dMassSetBoxTotal(&mass, massval, geomsize[0], geomsize[1], geomsize[2]);
1960 case SOLID_SLIDEBOX:
1962 case SOLID_PHYSICS_BOX:
1963 Matrix4x4_CreateTranslate(&ed->priv.server->ode_offsetmatrix, geomcenter[0], geomcenter[1], geomcenter[2]);
1964 ed->priv.server->ode_body = (void *)(body = dBodyCreate(world->physics.ode_world));
1965 ed->priv.server->ode_geom = (void *)dCreateBox(world->physics.ode_space, geomsize[0], geomsize[1], geomsize[2]);
1966 dMassSetBoxTotal(&mass, massval, geomsize[0], geomsize[1], geomsize[2]);
1967 dGeomSetBody(ed->priv.server->ode_geom, body);
1968 dBodySetMass(body, &mass);
1970 case SOLID_PHYSICS_SPHERE:
1971 Matrix4x4_CreateTranslate(&ed->priv.server->ode_offsetmatrix, geomcenter[0], geomcenter[1], geomcenter[2]);
1972 ed->priv.server->ode_body = (void *)(body = dBodyCreate(world->physics.ode_world));
1973 ed->priv.server->ode_geom = (void *)dCreateSphere(world->physics.ode_space, geomsize[0] * 0.5f);
1974 dMassSetSphereTotal(&mass, massval, geomsize[0] * 0.5f);
1975 dGeomSetBody(ed->priv.server->ode_geom, body);
1976 dBodySetMass(body, &mass);
1977 dBodySetData(body, (void*)ed);
1979 case SOLID_PHYSICS_CAPSULE:
1981 if (geomsize[axisindex] < geomsize[1])
1983 if (geomsize[axisindex] < geomsize[2])
1985 // the qc gives us 3 axis radius, the longest axis is the capsule
1986 // axis, since ODE doesn't like this idea we have to create a
1987 // capsule which uses the standard orientation, and apply a
1989 memset(capsulerot, 0, sizeof(capsulerot));
1991 Matrix4x4_CreateFromQuakeEntity(&ed->priv.server->ode_offsetmatrix, geomcenter[0], geomcenter[1], geomcenter[2], 0, 0, 90, 1);
1992 else if (axisindex == 1)
1993 Matrix4x4_CreateFromQuakeEntity(&ed->priv.server->ode_offsetmatrix, geomcenter[0], geomcenter[1], geomcenter[2], 90, 0, 0, 1);
1995 Matrix4x4_CreateFromQuakeEntity(&ed->priv.server->ode_offsetmatrix, geomcenter[0], geomcenter[1], geomcenter[2], 0, 0, 0, 1);
1996 radius = geomsize[!axisindex] * 0.5f; // any other axis is the radius
1997 length = geomsize[axisindex] - radius*2;
1998 // because we want to support more than one axisindex, we have to
1999 // create a transform, and turn on its cleanup setting (which will
2000 // cause the child to be destroyed when it is destroyed)
2001 ed->priv.server->ode_body = (void *)(body = dBodyCreate(world->physics.ode_world));
2002 ed->priv.server->ode_geom = (void *)dCreateCapsule(world->physics.ode_space, radius, length);
2003 dMassSetCapsuleTotal(&mass, massval, axisindex+1, radius, length);
2004 dGeomSetBody(ed->priv.server->ode_geom, body);
2005 dBodySetMass(body, &mass);
2008 Sys_Error("World_Physics_BodyFromEntity: unrecognized solid value %i was accepted by filter\n", solid);
2010 Matrix4x4_Invert_Simple(&ed->priv.server->ode_offsetimatrix, &ed->priv.server->ode_offsetmatrix);
2013 // get current data from entity
2014 VectorClear(origin);
2015 VectorClear(velocity);
2016 //VectorClear(forward);
2017 //VectorClear(left);
2019 //VectorClear(spinvelocity);
2020 VectorClear(angles);
2021 VectorClear(avelocity);
2023 val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.origin);if (val) VectorCopy(val->vector, origin);
2024 val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.velocity);if (val) VectorCopy(val->vector, velocity);
2025 //val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.axis_forward);if (val) VectorCopy(val->vector, forward);
2026 //val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.axis_left);if (val) VectorCopy(val->vector, left);
2027 //val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.axis_up);if (val) VectorCopy(val->vector, up);
2028 //val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.spinvelocity);if (val) VectorCopy(val->vector, spinvelocity);
2029 val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.angles);if (val) VectorCopy(val->vector, angles);
2030 val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.avelocity);if (val) VectorCopy(val->vector, avelocity);
2031 val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.gravity);if (val) { if(val->_float != 0.0f && val->_float < 0.5f) gravity = false; }
2032 if(ed == prog->edicts)
2035 // compatibility for legacy entities
2036 //if (!VectorLength2(forward) || solid == SOLID_BSP)
2038 AngleVectorsFLU(angles, forward, left, up);
2039 // convert single-axis rotations in avelocity to spinvelocity
2040 // FIXME: untested math - check signs
2041 VectorSet(spinvelocity, DEG2RAD(avelocity[PITCH]), DEG2RAD(avelocity[ROLL]), DEG2RAD(avelocity[YAW]));
2044 // compatibility for legacy entities
2048 case SOLID_SLIDEBOX:
2050 VectorSet(forward, 1, 0, 0);
2051 VectorSet(left, 0, 1, 0);
2052 VectorSet(up, 0, 0, 1);
2053 VectorSet(spinvelocity, 0, 0, 0);
2058 // we must prevent NANs...
2059 test = VectorLength2(origin) + VectorLength2(forward) + VectorLength2(left) + VectorLength2(up) + VectorLength2(velocity) + VectorLength2(spinvelocity);
2063 //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]);
2064 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]);
2065 test = VectorLength2(origin);
2067 VectorClear(origin);
2068 test = VectorLength2(forward) * VectorLength2(left) * VectorLength2(up);
2071 VectorSet(angles, 0, 0, 0);
2072 VectorSet(forward, 1, 0, 0);
2073 VectorSet(left, 0, 1, 0);
2074 VectorSet(up, 0, 0, 1);
2076 test = VectorLength2(velocity);
2078 VectorClear(velocity);
2079 test = VectorLength2(spinvelocity);
2082 VectorClear(avelocity);
2083 VectorClear(spinvelocity);
2087 // limit movement speed to prevent missed collisions at high speed
2088 movelimit = ed->priv.server->ode_movelimit * world->physics.ode_movelimit;
2089 test = VectorLength2(velocity);
2090 if (test > movelimit*movelimit)
2093 // scale down linear velocity to the movelimit
2094 // scale down angular velocity the same amount for consistency
2095 f = movelimit / sqrt(test);
2096 VectorScale(velocity, f, velocity);
2097 VectorScale(avelocity, f, avelocity);
2098 VectorScale(spinvelocity, f, spinvelocity);
2101 // make sure the angular velocity is not exploding
2102 spinlimit = physics_ode_spinlimit.value;
2103 test = VectorLength2(spinvelocity);
2104 if (test > spinlimit)
2107 VectorClear(avelocity);
2108 VectorClear(spinvelocity);
2111 // check if the qc edited any position data
2112 if (!VectorCompare(origin, ed->priv.server->ode_origin)
2113 || !VectorCompare(velocity, ed->priv.server->ode_velocity)
2114 || !VectorCompare(angles, ed->priv.server->ode_angles)
2115 || !VectorCompare(avelocity, ed->priv.server->ode_avelocity)
2116 || gravity != ed->priv.server->ode_gravity)
2119 // store the qc values into the physics engine
2120 body = ed->priv.server->ode_body;
2121 if (body && modified)
2124 matrix4x4_t entitymatrix;
2125 matrix4x4_t bodymatrix;
2128 float pitchsign = 1;
2129 if(!strcmp(prog->name, "server")) // FIXME some better way?
2131 pitchsign = SV_GetPitchSign(ed);
2133 else if(!strcmp(prog->name, "client"))
2135 pitchsign = CL_GetPitchSign(ed);
2137 angles[PITCH] *= pitchsign;
2138 avelocity[PITCH] *= pitchsign;
2141 Matrix4x4_FromVectors(&entitymatrix, forward, left, up, origin);
2142 Matrix4x4_Concat(&bodymatrix, &entitymatrix, &ed->priv.server->ode_offsetmatrix);
2143 Matrix4x4_ToVectors(&bodymatrix, forward, left, up, origin);
2144 r[0][0] = forward[0];
2145 r[1][0] = forward[1];
2146 r[2][0] = forward[2];
2153 dGeomSetBody(ed->priv.server->ode_geom, ed->priv.server->ode_body);
2154 dBodySetPosition(body, origin[0], origin[1], origin[2]);
2155 dBodySetRotation(body, r[0]);
2156 dBodySetLinearVel(body, velocity[0], velocity[1], velocity[2]);
2157 dBodySetAngularVel(body, spinvelocity[0], spinvelocity[1], spinvelocity[2]);
2158 dBodySetGravityMode(body, gravity);
2159 dBodySetData(body, (void*)ed);
2160 // setting body to NULL makes an immovable object
2161 if (movetype != MOVETYPE_PHYSICS)
2162 dGeomSetBody(ed->priv.server->ode_geom, 0);
2166 #define MAX_CONTACTS 16
2167 static void nearCallback (void *data, dGeomID o1, dGeomID o2)
2169 world_t *world = (world_t *)data;
2170 dContact contact[MAX_CONTACTS]; // max contacts per collision pair
2177 float bouncefactor1 = 0.0f;
2178 float bouncestop1 = 60.0f / 800.0f;
2179 float bouncefactor2 = 0.0f;
2180 float bouncestop2 = 60.0f / 800.0f;
2184 if (dGeomIsSpace(o1) || dGeomIsSpace(o2))
2186 // colliding a space with something
2187 dSpaceCollide2(o1, o2, data, &nearCallback);
2188 // Note we do not want to test intersections within a space,
2189 // only between spaces.
2190 //if (dGeomIsSpace(o1)) dSpaceCollide(o1, data, &nearCallback);
2191 //if (dGeomIsSpace(o2)) dSpaceCollide(o2, data, &nearCallback);
2195 b1 = dGeomGetBody(o1);
2196 b2 = dGeomGetBody(o2);
2198 // at least one object has to be using MOVETYPE_PHYSICS or we just don't care
2202 // exit without doing anything if the two bodies are connected by a joint
2203 if (b1 && b2 && dAreConnectedExcluding(b1, b2, dJointTypeContact))
2208 ed = (prvm_edict_t *) dBodyGetData(b1);
2211 val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.bouncefactor);
2212 if (val!=0 && val->_float)
2213 bouncefactor1 = val->_float;
2215 val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.bouncestop);
2216 if (val!=0 && val->_float)
2217 bouncestop1 = val->_float;
2223 ed = (prvm_edict_t *) dBodyGetData(b2);
2226 val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.bouncefactor);
2227 if (val!=0 && val->_float)
2228 bouncefactor2 = val->_float;
2230 val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.bouncestop);
2231 if (val!=0 && val->_float)
2232 bouncestop2 = val->_float;
2236 // merge bounce factors and bounce stop
2237 if(bouncefactor2 > 0)
2239 if(bouncefactor1 > 0)
2241 // TODO possibly better logic to merge bounce factor data?
2242 if(bouncestop2 < bouncestop1)
2243 bouncestop1 = bouncestop2;
2244 if(bouncefactor2 > bouncefactor1)
2245 bouncefactor1 = bouncefactor2;
2249 bouncestop1 = bouncestop2;
2250 bouncefactor1 = bouncefactor2;
2253 dWorldGetGravity(world->physics.ode_world, grav);
2254 bouncestop1 *= fabs(grav[2]);
2256 // generate contact points between the two non-space geoms
2257 numcontacts = dCollide(o1, o2, MAX_CONTACTS, &(contact[0].geom), sizeof(contact[0]));
2258 // add these contact points to the simulation
2259 for (i = 0;i < numcontacts;i++)
2261 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);
2262 contact[i].surface.mu = physics_ode_contact_mu.value;
2263 contact[i].surface.soft_erp = physics_ode_contact_erp.value;
2264 contact[i].surface.soft_cfm = physics_ode_contact_cfm.value;
2265 contact[i].surface.bounce = bouncefactor1;
2266 contact[i].surface.bounce_vel = bouncestop1;
2267 c = dJointCreateContact(world->physics.ode_world, world->physics.ode_contactgroup, contact + i);
2268 dJointAttach(c, b1, b2);
2273 void World_Physics_Frame(world_t *world, double frametime, double gravity)
2276 if (world->physics.ode)
2281 // copy physics properties from entities to physics engine
2284 for (i = 0, ed = prog->edicts + i;i < prog->num_edicts;i++, ed++)
2285 if (!prog->edicts[i].priv.required->free)
2286 World_Physics_Frame_BodyFromEntity(world, ed);
2287 // oh, and it must be called after all bodies were created
2288 for (i = 0, ed = prog->edicts + i;i < prog->num_edicts;i++, ed++)
2289 if (!prog->edicts[i].priv.required->free)
2290 World_Physics_Frame_JointFromEntity(world, ed);
2293 world->physics.ode_iterations = bound(1, physics_ode_iterationsperframe.integer, 1000);
2294 world->physics.ode_step = frametime / world->physics.ode_iterations;
2295 world->physics.ode_movelimit = physics_ode_movelimit.value / world->physics.ode_step;
2296 for (i = 0;i < world->physics.ode_iterations;i++)
2299 dWorldSetGravity(world->physics.ode_world, 0, 0, -gravity);
2300 // set the tolerance for closeness of objects
2301 dWorldSetContactSurfaceLayer(world->physics.ode_world, max(0, physics_ode_contactsurfacelayer.value));
2303 // run collisions for the current world state, creating JointGroup
2304 dSpaceCollide(world->physics.ode_space, (void *)world, nearCallback);
2306 // run physics (move objects, calculate new velocities)
2307 if (physics_ode_worldquickstep.integer)
2309 dWorldSetQuickStepNumIterations(world->physics.ode_world, bound(1, physics_ode_worldquickstep_iterations.integer, 200));
2310 dWorldQuickStep(world->physics.ode_world, world->physics.ode_step);
2312 else if (physics_ode_worldstepfast.integer)
2313 dWorldStepFast1(world->physics.ode_world, world->physics.ode_step, bound(1, physics_ode_worldstepfast_iterations.integer, 200));
2315 dWorldStep(world->physics.ode_world, world->physics.ode_step);
2317 // clear the JointGroup now that we're done with it
2318 dJointGroupEmpty(world->physics.ode_contactgroup);
2321 // copy physics properties from physics engine to entities
2323 for (i = 1, ed = prog->edicts + i;i < prog->num_edicts;i++, ed++)
2324 if (!prog->edicts[i].priv.required->free && PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.movetype)->_float == MOVETYPE_PHYSICS)
2325 World_Physics_Frame_BodyToEntity(world, ed);