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"
24 #include "cl_collision.h"
28 entities never clip against themselves, or their owner
30 line of sight checks trace->inopen and trace->inwater, but bullets don't
34 static void World_Physics_Init(void);
41 static void World_Physics_Shutdown(void);
42 void World_Shutdown(void)
44 World_Physics_Shutdown();
47 static void World_Physics_Start(world_t *world);
48 void World_Start(world_t *world)
50 World_Physics_Start(world);
53 static void World_Physics_End(world_t *world);
54 void World_End(world_t *world)
56 World_Physics_End(world);
59 //============================================================================
61 /// World_ClearLink is used for new headnodes
62 void World_ClearLink (link_t *l)
65 l->prev = l->next = l;
68 void World_RemoveLink (link_t *l)
70 l->next->prev = l->prev;
71 l->prev->next = l->next;
74 void World_InsertLinkBefore (link_t *l, link_t *before, int entitynumber)
76 l->entitynumber = entitynumber;
78 l->prev = before->prev;
84 ===============================================================================
88 ===============================================================================
91 void World_PrintAreaStats(world_t *world, const char *worldname)
93 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);
94 world->areagrid_stats_calls = 0;
95 world->areagrid_stats_nodechecks = 0;
96 world->areagrid_stats_entitychecks = 0;
105 void World_SetSize(world_t *world, const char *filename, const vec3_t mins, const vec3_t maxs)
109 strlcpy(world->filename, filename, sizeof(world->filename));
110 VectorCopy(mins, world->mins);
111 VectorCopy(maxs, world->maxs);
113 // the areagrid_marknumber is not allowed to be 0
114 if (world->areagrid_marknumber < 1)
115 world->areagrid_marknumber = 1;
116 // choose either the world box size, or a larger box to ensure the grid isn't too fine
117 world->areagrid_size[0] = max(world->maxs[0] - world->mins[0], AREA_GRID * sv_areagrid_mingridsize.value);
118 world->areagrid_size[1] = max(world->maxs[1] - world->mins[1], AREA_GRID * sv_areagrid_mingridsize.value);
119 world->areagrid_size[2] = max(world->maxs[2] - world->mins[2], AREA_GRID * sv_areagrid_mingridsize.value);
120 // figure out the corners of such a box, centered at the center of the world box
121 world->areagrid_mins[0] = (world->mins[0] + world->maxs[0] - world->areagrid_size[0]) * 0.5f;
122 world->areagrid_mins[1] = (world->mins[1] + world->maxs[1] - world->areagrid_size[1]) * 0.5f;
123 world->areagrid_mins[2] = (world->mins[2] + world->maxs[2] - world->areagrid_size[2]) * 0.5f;
124 world->areagrid_maxs[0] = (world->mins[0] + world->maxs[0] + world->areagrid_size[0]) * 0.5f;
125 world->areagrid_maxs[1] = (world->mins[1] + world->maxs[1] + world->areagrid_size[1]) * 0.5f;
126 world->areagrid_maxs[2] = (world->mins[2] + world->maxs[2] + world->areagrid_size[2]) * 0.5f;
127 // now calculate the actual useful info from that
128 VectorNegate(world->areagrid_mins, world->areagrid_bias);
129 world->areagrid_scale[0] = AREA_GRID / world->areagrid_size[0];
130 world->areagrid_scale[1] = AREA_GRID / world->areagrid_size[1];
131 world->areagrid_scale[2] = AREA_GRID / world->areagrid_size[2];
132 World_ClearLink(&world->areagrid_outside);
133 for (i = 0;i < AREA_GRIDNODES;i++)
134 World_ClearLink(&world->areagrid[i]);
135 if (developer_extra.integer)
136 Con_DPrintf("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);
145 void World_UnlinkAll(world_t *world)
149 // unlink all entities one by one
150 grid = &world->areagrid_outside;
151 while (grid->next != grid)
152 World_UnlinkEdict(PRVM_EDICT_NUM(grid->next->entitynumber));
153 for (i = 0, grid = world->areagrid;i < AREA_GRIDNODES;i++, grid++)
154 while (grid->next != grid)
155 World_UnlinkEdict(PRVM_EDICT_NUM(grid->next->entitynumber));
163 void World_UnlinkEdict(prvm_edict_t *ent)
166 for (i = 0;i < ENTITYGRIDAREAS;i++)
168 if (ent->priv.server->areagrid[i].prev)
170 World_RemoveLink (&ent->priv.server->areagrid[i]);
171 ent->priv.server->areagrid[i].prev = ent->priv.server->areagrid[i].next = NULL;
176 int World_EntitiesInBox(world_t *world, const vec3_t mins, const vec3_t maxs, int maxlist, prvm_edict_t **list)
182 int igrid[3], igridmins[3], igridmaxs[3];
184 // FIXME: if areagrid_marknumber wraps, all entities need their
185 // ent->priv.server->areagridmarknumber reset
186 world->areagrid_stats_calls++;
187 world->areagrid_marknumber++;
188 igridmins[0] = (int) floor((mins[0] + world->areagrid_bias[0]) * world->areagrid_scale[0]);
189 igridmins[1] = (int) floor((mins[1] + world->areagrid_bias[1]) * world->areagrid_scale[1]);
190 //igridmins[2] = (int) ((mins[2] + world->areagrid_bias[2]) * world->areagrid_scale[2]);
191 igridmaxs[0] = (int) floor((maxs[0] + world->areagrid_bias[0]) * world->areagrid_scale[0]) + 1;
192 igridmaxs[1] = (int) floor((maxs[1] + world->areagrid_bias[1]) * world->areagrid_scale[1]) + 1;
193 //igridmaxs[2] = (int) ((maxs[2] + world->areagrid_bias[2]) * world->areagrid_scale[2]) + 1;
194 igridmins[0] = max(0, igridmins[0]);
195 igridmins[1] = max(0, igridmins[1]);
196 //igridmins[2] = max(0, igridmins[2]);
197 igridmaxs[0] = min(AREA_GRID, igridmaxs[0]);
198 igridmaxs[1] = min(AREA_GRID, igridmaxs[1]);
199 //igridmaxs[2] = min(AREA_GRID, igridmaxs[2]);
202 // add entities not linked into areagrid because they are too big or
203 // outside the grid bounds
204 if (world->areagrid_outside.next != &world->areagrid_outside)
206 grid = &world->areagrid_outside;
207 for (l = grid->next;l != grid;l = l->next)
209 ent = PRVM_EDICT_NUM(l->entitynumber);
210 if (ent->priv.server->areagridmarknumber != world->areagrid_marknumber)
212 ent->priv.server->areagridmarknumber = world->areagrid_marknumber;
213 if (!ent->priv.server->free && BoxesOverlap(mins, maxs, ent->priv.server->areamins, ent->priv.server->areamaxs))
215 if (numlist < maxlist)
219 world->areagrid_stats_entitychecks++;
223 // add grid linked entities
224 for (igrid[1] = igridmins[1];igrid[1] < igridmaxs[1];igrid[1]++)
226 grid = world->areagrid + igrid[1] * AREA_GRID + igridmins[0];
227 for (igrid[0] = igridmins[0];igrid[0] < igridmaxs[0];igrid[0]++, grid++)
229 if (grid->next != grid)
231 for (l = grid->next;l != grid;l = l->next)
233 ent = PRVM_EDICT_NUM(l->entitynumber);
234 if (ent->priv.server->areagridmarknumber != world->areagrid_marknumber)
236 ent->priv.server->areagridmarknumber = world->areagrid_marknumber;
237 if (!ent->priv.server->free && BoxesOverlap(mins, maxs, ent->priv.server->areamins, ent->priv.server->areamaxs))
239 if (numlist < maxlist)
243 //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]);
245 world->areagrid_stats_entitychecks++;
253 void World_LinkEdict_AreaGrid(world_t *world, prvm_edict_t *ent)
256 int igrid[3], igridmins[3], igridmaxs[3], gridnum, entitynumber = PRVM_NUM_FOR_EDICT(ent);
258 if (entitynumber <= 0 || entitynumber >= prog->max_edicts || PRVM_EDICT_NUM(entitynumber) != ent)
260 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);
264 igridmins[0] = (int) floor((ent->priv.server->areamins[0] + world->areagrid_bias[0]) * world->areagrid_scale[0]);
265 igridmins[1] = (int) floor((ent->priv.server->areamins[1] + world->areagrid_bias[1]) * world->areagrid_scale[1]);
266 //igridmins[2] = (int) floor((ent->priv.server->areamins[2] + world->areagrid_bias[2]) * world->areagrid_scale[2]);
267 igridmaxs[0] = (int) floor((ent->priv.server->areamaxs[0] + world->areagrid_bias[0]) * world->areagrid_scale[0]) + 1;
268 igridmaxs[1] = (int) floor((ent->priv.server->areamaxs[1] + world->areagrid_bias[1]) * world->areagrid_scale[1]) + 1;
269 //igridmaxs[2] = (int) floor((ent->priv.server->areamaxs[2] + world->areagrid_bias[2]) * world->areagrid_scale[2]) + 1;
270 if (igridmins[0] < 0 || igridmaxs[0] > AREA_GRID || igridmins[1] < 0 || igridmaxs[1] > AREA_GRID || ((igridmaxs[0] - igridmins[0]) * (igridmaxs[1] - igridmins[1])) > ENTITYGRIDAREAS)
272 // wow, something outside the grid, store it as such
273 World_InsertLinkBefore (&ent->priv.server->areagrid[0], &world->areagrid_outside, entitynumber);
278 for (igrid[1] = igridmins[1];igrid[1] < igridmaxs[1];igrid[1]++)
280 grid = world->areagrid + igrid[1] * AREA_GRID + igridmins[0];
281 for (igrid[0] = igridmins[0];igrid[0] < igridmaxs[0];igrid[0]++, grid++, gridnum++)
282 World_InsertLinkBefore (&ent->priv.server->areagrid[gridnum], grid, entitynumber);
292 void World_LinkEdict(world_t *world, prvm_edict_t *ent, const vec3_t mins, const vec3_t maxs)
294 // unlink from old position first
295 if (ent->priv.server->areagrid[0].prev)
296 World_UnlinkEdict(ent);
298 // don't add the world
299 if (ent == prog->edicts)
302 // don't add free entities
303 if (ent->priv.server->free)
306 VectorCopy(mins, ent->priv.server->areamins);
307 VectorCopy(maxs, ent->priv.server->areamaxs);
308 World_LinkEdict_AreaGrid(world, ent);
314 //============================================================================
315 // physics engine support
316 //============================================================================
319 # define ODE_DYNAMIC 1
322 #if defined(ODE_STATIC) || defined(ODE_DYNAMIC)
326 // recent ODE trunk has dWorldStepFast1 removed
327 //#define ODE_USE_STEPFAST
330 cvar_t physics_ode_quadtree_depth = {0, "physics_ode_quadtree_depth","5", "desired subdivision level of quadtree culling space"};
331 cvar_t physics_ode_contactsurfacelayer = {0, "physics_ode_contactsurfacelayer","1", "allows objects to overlap this many units to reduce jitter"};
332 cvar_t physics_ode_worldstep = {0, "physics_ode_worldstep","2", "step function to use, 0 - dWorldStep, 1 - dWorldStepFast1, 2 - dWorldQuickStep"};
333 cvar_t physics_ode_worldstep_iterations = {0, "physics_ode_worldstep_iterations", "20", "parameter to dWorldQuickStep and dWorldStepFast1"};
334 cvar_t physics_ode_contact_mu = {0, "physics_ode_contact_mu", "1", "contact solver mu parameter - friction pyramid approximation 1 (see ODE User Guide)"};
335 cvar_t physics_ode_contact_erp = {0, "physics_ode_contact_erp", "0.96", "contact solver erp parameter - Error Restitution Percent (see ODE User Guide)"};
336 cvar_t physics_ode_contact_cfm = {0, "physics_ode_contact_cfm", "0", "contact solver cfm parameter - Constraint Force Mixing (see ODE User Guide)"};
337 cvar_t physics_ode_world_erp = {0, "physics_ode_world_erp", "-1", "world solver erp parameter - Error Restitution Percent (see ODE User Guide); use defaults when set to -1"};
338 cvar_t physics_ode_world_cfm = {0, "physics_ode_world_cfm", "-1", "world solver cfm parameter - Constraint Force Mixing (see ODE User Guide); not touched when -1"};
339 cvar_t physics_ode_world_damping = {0, "physics_ode_world_damping", "1", "enabled damping scale (see ODE User Guide), this scales all damping values, be aware that behavior depends of step type"};
340 cvar_t physics_ode_world_damping_linear = {0, "physics_ode_world_damping_linear", "0.005", "world linear damping scale (see ODE User Guide); use defaults when set to -1"};
341 cvar_t physics_ode_world_damping_linear_threshold = {0, "physics_ode_world_damping_linear_threshold", "0.01", "world linear damping threshold (see ODE User Guide); use defaults when set to -1"};
342 cvar_t physics_ode_world_damping_angular = {0, "physics_ode_world_damping_angular", "0.005", "world angular damping scale (see ODE User Guide); use defaults when set to -1"};
343 cvar_t physics_ode_world_damping_angular_threshold = {0, "physics_ode_world_damping_angular_threshold", "0.01", "world angular damping threshold (see ODE User Guide); use defaults when set to -1"};
344 cvar_t physics_ode_world_gravitymod = {0, "physics_ode_world_gravitymod", "1", "multiplies gravity got from sv_gravity, this may be needed to tweak if strong damping is used"};
345 cvar_t physics_ode_iterationsperframe = {0, "physics_ode_iterationsperframe", "1", "divisor for time step, runs multiple physics steps per frame"};
346 cvar_t physics_ode_constantstep = {0, "physics_ode_constantstep", "1", "use constant step (sys_ticrate value) instead of variable step which tends to increase stability"};
347 cvar_t physics_ode_autodisable = {0, "physics_ode_autodisable", "1", "automatic disabling of objects which dont move for long period of time, makes object stacking a lot faster"};
348 cvar_t physics_ode_autodisable_steps = {0, "physics_ode_autodisable_steps", "10", "how many steps object should be dormant to be autodisabled"};
349 cvar_t physics_ode_autodisable_time = {0, "physics_ode_autodisable_time", "0", "how many seconds object should be dormant to be autodisabled"};
350 cvar_t physics_ode_autodisable_threshold_linear = {0, "physics_ode_autodisable_threshold_linear", "0.2", "body will be disabled if it's linear move below this value"};
351 cvar_t physics_ode_autodisable_threshold_angular = {0, "physics_ode_autodisable_threshold_angular", "0.3", "body will be disabled if it's angular move below this value"};
352 cvar_t physics_ode_autodisable_threshold_samples = {0, "physics_ode_autodisable_threshold_samples", "5", "average threshold with this number of samples"};
353 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, be aware that behavior depends of step type"};
354 cvar_t physics_ode_spinlimit = {0, "physics_ode_spinlimit", "10000", "reset spin velocity if it gets too large"};
355 cvar_t physics_ode_trick_fixnan = {0, "physics_ode_trick_fixnan", "1", "engine trick that checks and fixes NaN velocity/origin/angles on objects, a value of 2 makes console prints on each fix"};
356 cvar_t physics_ode_printstats = {0, "physics_ode_printstats", "0", "print ODE stats each frame"};
357 cvar_t physics_ode = {0, "physics_ode", "0", "run ODE physics (VERY experimental and potentially buggy)"};
359 // LordHavoc: this large chunk of definitions comes from the ODE library
366 // ODE does not use WINAPI
372 // note: dynamic builds of ODE tend to be double precision, this is not used
374 typedef double dReal;
376 typedef dReal dVector3[4];
377 typedef dReal dVector4[4];
378 typedef dReal dMatrix3[4*3];
379 typedef dReal dMatrix4[4*4];
380 typedef dReal dMatrix6[8*6];
381 typedef dReal dQuaternion[4];
383 struct dxWorld; /* dynamics world */
384 struct dxSpace; /* collision space */
385 struct dxBody; /* rigid body (dynamics object) */
386 struct dxGeom; /* geometry (collision object) */
390 struct dxTriMeshData;
392 #define dInfinity 3.402823466e+38f
394 typedef struct dxWorld *dWorldID;
395 typedef struct dxSpace *dSpaceID;
396 typedef struct dxBody *dBodyID;
397 typedef struct dxGeom *dGeomID;
398 typedef struct dxJoint *dJointID;
399 typedef struct dxJointGroup *dJointGroupID;
400 typedef struct dxTriMeshData *dTriMeshDataID;
402 typedef struct dJointFeedback
404 dVector3 f1; /* force applied to body 1 */
405 dVector3 t1; /* torque applied to body 1 */
406 dVector3 f2; /* force applied to body 2 */
407 dVector3 t2; /* torque applied to body 2 */
411 typedef enum dJointType
431 #define D_ALL_PARAM_NAMES(start) \
432 /* parameters for limits and motors */ \
433 dParamLoStop = start, \
442 /* parameters for suspension */ \
443 dParamSuspensionERP, \
444 dParamSuspensionCFM, \
447 #define D_ALL_PARAM_NAMES_X(start,x) \
448 /* parameters for limits and motors */ \
449 dParamLoStop ## x = start, \
453 dParamFudgeFactor ## x, \
456 dParamStopERP ## x, \
457 dParamStopCFM ## x, \
458 /* parameters for suspension */ \
459 dParamSuspensionERP ## x, \
460 dParamSuspensionCFM ## x, \
465 D_ALL_PARAM_NAMES_X(0x100,2)
466 D_ALL_PARAM_NAMES_X(0x200,3)
468 /* add a multiple of this constant to the basic parameter numbers to get
469 * the parameters for the second, third etc axes.
485 dContactFDir1 = 0x002,
486 dContactBounce = 0x004,
487 dContactSoftERP = 0x008,
488 dContactSoftCFM = 0x010,
489 dContactMotion1 = 0x020,
490 dContactMotion2 = 0x040,
491 dContactMotionN = 0x080,
492 dContactSlip1 = 0x100,
493 dContactSlip2 = 0x200,
495 dContactApprox0 = 0x0000,
496 dContactApprox1_1 = 0x1000,
497 dContactApprox1_2 = 0x2000,
498 dContactApprox1 = 0x3000
501 typedef struct dSurfaceParameters
503 /* must always be defined */
507 /* only defined if the corresponding flag is set in mode */
513 dReal motion1,motion2,motionN;
515 } dSurfaceParameters;
517 typedef struct dContactGeom
519 dVector3 pos; ///< contact position
520 dVector3 normal; ///< normal vector
521 dReal depth; ///< penetration depth
522 dGeomID g1,g2; ///< the colliding geoms
523 int side1,side2; ///< (to be documented)
527 typedef struct dContact
529 dSurfaceParameters surface;
535 typedef void dNearCallback (void *data, dGeomID o1, dGeomID o2);
538 // Order XZY or ZXY usually works best, if your Y is up.
539 #define dSAP_AXES_XYZ ((0)|(1<<2)|(2<<4))
540 #define dSAP_AXES_XZY ((0)|(2<<2)|(1<<4))
541 #define dSAP_AXES_YXZ ((1)|(0<<2)|(2<<4))
542 #define dSAP_AXES_YZX ((1)|(2<<2)|(0<<4))
543 #define dSAP_AXES_ZXY ((2)|(0<<2)|(1<<4))
544 #define dSAP_AXES_ZYX ((2)|(1<<2)|(0<<4))
546 //const char* (ODE_API *dGetConfiguration)(void);
547 int (ODE_API *dCheckConfiguration)( const char* token );
548 int (ODE_API *dInitODE)(void);
549 //int (ODE_API *dInitODE2)(unsigned int uiInitFlags);
550 //int (ODE_API *dAllocateODEDataForThread)(unsigned int uiAllocateFlags);
551 //void (ODE_API *dCleanupODEAllDataForThread)(void);
552 void (ODE_API *dCloseODE)(void);
554 //int (ODE_API *dMassCheck)(const dMass *m);
555 //void (ODE_API *dMassSetZero)(dMass *);
556 //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);
557 //void (ODE_API *dMassSetSphere)(dMass *, dReal density, dReal radius);
558 void (ODE_API *dMassSetSphereTotal)(dMass *, dReal total_mass, dReal radius);
559 //void (ODE_API *dMassSetCapsule)(dMass *, dReal density, int direction, dReal radius, dReal length);
560 void (ODE_API *dMassSetCapsuleTotal)(dMass *, dReal total_mass, int direction, dReal radius, dReal length);
561 //void (ODE_API *dMassSetCylinder)(dMass *, dReal density, int direction, dReal radius, dReal length);
562 //void (ODE_API *dMassSetCylinderTotal)(dMass *, dReal total_mass, int direction, dReal radius, dReal length);
563 //void (ODE_API *dMassSetBox)(dMass *, dReal density, dReal lx, dReal ly, dReal lz);
564 void (ODE_API *dMassSetBoxTotal)(dMass *, dReal total_mass, dReal lx, dReal ly, dReal lz);
565 //void (ODE_API *dMassSetTrimesh)(dMass *, dReal density, dGeomID g);
566 //void (ODE_API *dMassSetTrimeshTotal)(dMass *m, dReal total_mass, dGeomID g);
567 //void (ODE_API *dMassAdjust)(dMass *, dReal newmass);
568 //void (ODE_API *dMassTranslate)(dMass *, dReal x, dReal y, dReal z);
569 //void (ODE_API *dMassRotate)(dMass *, const dMatrix3 R);
570 //void (ODE_API *dMassAdd)(dMass *a, const dMass *b);
572 dWorldID (ODE_API *dWorldCreate)(void);
573 void (ODE_API *dWorldDestroy)(dWorldID world);
574 void (ODE_API *dWorldSetGravity)(dWorldID, dReal x, dReal y, dReal z);
575 void (ODE_API *dWorldGetGravity)(dWorldID, dVector3 gravity);
576 void (ODE_API *dWorldSetERP)(dWorldID, dReal erp);
577 //dReal (ODE_API *dWorldGetERP)(dWorldID);
578 void (ODE_API *dWorldSetCFM)(dWorldID, dReal cfm);
579 //dReal (ODE_API *dWorldGetCFM)(dWorldID);
580 void (ODE_API *dWorldStep)(dWorldID, dReal stepsize);
581 //void (ODE_API *dWorldImpulseToForce)(dWorldID, dReal stepsize, dReal ix, dReal iy, dReal iz, dVector3 force);
582 void (ODE_API *dWorldQuickStep)(dWorldID w, dReal stepsize);
583 void (ODE_API *dWorldSetQuickStepNumIterations)(dWorldID, int num);
584 //int (ODE_API *dWorldGetQuickStepNumIterations)(dWorldID);
585 //void (ODE_API *dWorldSetQuickStepW)(dWorldID, dReal over_relaxation);
586 //dReal (ODE_API *dWorldGetQuickStepW)(dWorldID);
587 //void (ODE_API *dWorldSetContactMaxCorrectingVel)(dWorldID, dReal vel);
588 //dReal (ODE_API *dWorldGetContactMaxCorrectingVel)(dWorldID);
589 void (ODE_API *dWorldSetContactSurfaceLayer)(dWorldID, dReal depth);
590 //dReal (ODE_API *dWorldGetContactSurfaceLayer)(dWorldID);
591 #ifdef ODE_USE_STEPFAST
592 void (ODE_API *dWorldStepFast1)(dWorldID, dReal stepsize, int maxiterations);
594 //void (ODE_API *dWorldSetAutoEnableDepthSF1)(dWorldID, int autoEnableDepth);
595 //int (ODE_API *dWorldGetAutoEnableDepthSF1)(dWorldID);
596 //dReal (ODE_API *dWorldGetAutoDisableLinearThreshold)(dWorldID);
597 void (ODE_API *dWorldSetAutoDisableLinearThreshold)(dWorldID, dReal linear_threshold);
598 //dReal (ODE_API *dWorldGetAutoDisableAngularThreshold)(dWorldID);
599 void (ODE_API *dWorldSetAutoDisableAngularThreshold)(dWorldID, dReal angular_threshold);
600 //dReal (ODE_API *dWorldGetAutoDisableLinearAverageThreshold)(dWorldID);
601 //void (ODE_API *dWorldSetAutoDisableLinearAverageThreshold)(dWorldID, dReal linear_average_threshold);
602 //dReal (ODE_API *dWorldGetAutoDisableAngularAverageThreshold)(dWorldID);
603 //void (ODE_API *dWorldSetAutoDisableAngularAverageThreshold)(dWorldID, dReal angular_average_threshold);
604 //int (ODE_API *dWorldGetAutoDisableAverageSamplesCount)(dWorldID);
605 void (ODE_API *dWorldSetAutoDisableAverageSamplesCount)(dWorldID, unsigned int average_samples_count );
606 //int (ODE_API *dWorldGetAutoDisableSteps)(dWorldID);
607 void (ODE_API *dWorldSetAutoDisableSteps)(dWorldID, int steps);
608 //dReal (ODE_API *dWorldGetAutoDisableTime)(dWorldID);
609 void (ODE_API *dWorldSetAutoDisableTime)(dWorldID, dReal time);
610 //int (ODE_API *dWorldGetAutoDisableFlag)(dWorldID);
611 void (ODE_API *dWorldSetAutoDisableFlag)(dWorldID, int do_auto_disable);
612 //dReal (ODE_API *dWorldGetLinearDampingThreshold)(dWorldID w);
613 void (ODE_API *dWorldSetLinearDampingThreshold)(dWorldID w, dReal threshold);
614 //dReal (ODE_API *dWorldGetAngularDampingThreshold)(dWorldID w);
615 void (ODE_API *dWorldSetAngularDampingThreshold)(dWorldID w, dReal threshold);
616 //dReal (ODE_API *dWorldGetLinearDamping)(dWorldID w);
617 void (ODE_API *dWorldSetLinearDamping)(dWorldID w, dReal scale);
618 //dReal (ODE_API *dWorldGetAngularDamping)(dWorldID w);
619 void (ODE_API *dWorldSetAngularDamping)(dWorldID w, dReal scale);
620 //void (ODE_API *dWorldSetDamping)(dWorldID w, dReal linear_scale, dReal angular_scale);
621 //dReal (ODE_API *dWorldGetMaxAngularSpeed)(dWorldID w);
622 //void (ODE_API *dWorldSetMaxAngularSpeed)(dWorldID w, dReal max_speed);
623 //dReal (ODE_API *dBodyGetAutoDisableLinearThreshold)(dBodyID);
624 //void (ODE_API *dBodySetAutoDisableLinearThreshold)(dBodyID, dReal linear_average_threshold);
625 //dReal (ODE_API *dBodyGetAutoDisableAngularThreshold)(dBodyID);
626 //void (ODE_API *dBodySetAutoDisableAngularThreshold)(dBodyID, dReal angular_average_threshold);
627 //int (ODE_API *dBodyGetAutoDisableAverageSamplesCount)(dBodyID);
628 //void (ODE_API *dBodySetAutoDisableAverageSamplesCount)(dBodyID, unsigned int average_samples_count);
629 //int (ODE_API *dBodyGetAutoDisableSteps)(dBodyID);
630 //void (ODE_API *dBodySetAutoDisableSteps)(dBodyID, int steps);
631 //dReal (ODE_API *dBodyGetAutoDisableTime)(dBodyID);
632 //void (ODE_API *dBodySetAutoDisableTime)(dBodyID, dReal time);
633 //int (ODE_API *dBodyGetAutoDisableFlag)(dBodyID);
634 //void (ODE_API *dBodySetAutoDisableFlag)(dBodyID, int do_auto_disable);
635 //void (ODE_API *dBodySetAutoDisableDefaults)(dBodyID);
636 //dWorldID (ODE_API *dBodyGetWorld)(dBodyID);
637 dBodyID (ODE_API *dBodyCreate)(dWorldID);
638 void (ODE_API *dBodyDestroy)(dBodyID);
639 void (ODE_API *dBodySetData)(dBodyID, void *data);
640 void * (ODE_API *dBodyGetData)(dBodyID);
641 void (ODE_API *dBodySetPosition)(dBodyID, dReal x, dReal y, dReal z);
642 void (ODE_API *dBodySetRotation)(dBodyID, const dMatrix3 R);
643 //void (ODE_API *dBodySetQuaternion)(dBodyID, const dQuaternion q);
644 void (ODE_API *dBodySetLinearVel)(dBodyID, dReal x, dReal y, dReal z);
645 void (ODE_API *dBodySetAngularVel)(dBodyID, dReal x, dReal y, dReal z);
646 const dReal * (ODE_API *dBodyGetPosition)(dBodyID);
647 //void (ODE_API *dBodyCopyPosition)(dBodyID body, dVector3 pos);
648 const dReal * (ODE_API *dBodyGetRotation)(dBodyID);
649 //void (ODE_API *dBodyCopyRotation)(dBodyID, dMatrix3 R);
650 //const dReal * (ODE_API *dBodyGetQuaternion)(dBodyID);
651 //void (ODE_API *dBodyCopyQuaternion)(dBodyID body, dQuaternion quat);
652 const dReal * (ODE_API *dBodyGetLinearVel)(dBodyID);
653 const dReal * (ODE_API *dBodyGetAngularVel)(dBodyID);
654 void (ODE_API *dBodySetMass)(dBodyID, const dMass *mass);
655 //void (ODE_API *dBodyGetMass)(dBodyID, dMass *mass);
656 //void (ODE_API *dBodyAddForce)(dBodyID, dReal fx, dReal fy, dReal fz);
657 //void (ODE_API *dBodyAddTorque)(dBodyID, dReal fx, dReal fy, dReal fz);
658 //void (ODE_API *dBodyAddRelForce)(dBodyID, dReal fx, dReal fy, dReal fz);
659 void (ODE_API *dBodyAddRelTorque)(dBodyID, dReal fx, dReal fy, dReal fz);
660 //void (ODE_API *dBodyAddForceAtPos)(dBodyID, dReal fx, dReal fy, dReal fz, dReal px, dReal py, dReal pz);
661 void (ODE_API *dBodyAddForceAtRelPos)(dBodyID, dReal fx, dReal fy, dReal fz, dReal px, dReal py, dReal pz);
662 //void (ODE_API *dBodyAddRelForceAtPos)(dBodyID, dReal fx, dReal fy, dReal fz, dReal px, dReal py, dReal pz);
663 //void (ODE_API *dBodyAddRelForceAtRelPos)(dBodyID, dReal fx, dReal fy, dReal fz, dReal px, dReal py, dReal pz);
664 //const dReal * (ODE_API *dBodyGetForce)(dBodyID);
665 //const dReal * (ODE_API *dBodyGetTorque)(dBodyID);
666 //void (ODE_API *dBodySetForce)(dBodyID b, dReal x, dReal y, dReal z);
667 //void (ODE_API *dBodySetTorque)(dBodyID b, dReal x, dReal y, dReal z);
668 //void (ODE_API *dBodyGetRelPointPos)(dBodyID, dReal px, dReal py, dReal pz, dVector3 result);
669 //void (ODE_API *dBodyGetRelPointVel)(dBodyID, dReal px, dReal py, dReal pz, dVector3 result);
670 //void (ODE_API *dBodyGetPointVel)(dBodyID, dReal px, dReal py, dReal pz, dVector3 result);
671 //void (ODE_API *dBodyGetPosRelPoint)(dBodyID, dReal px, dReal py, dReal pz, dVector3 result);
672 //void (ODE_API *dBodyVectorToWorld)(dBodyID, dReal px, dReal py, dReal pz, dVector3 result);
673 //void (ODE_API *dBodyVectorFromWorld)(dBodyID, dReal px, dReal py, dReal pz, dVector3 result);
674 //void (ODE_API *dBodySetFiniteRotationMode)(dBodyID, int mode);
675 //void (ODE_API *dBodySetFiniteRotationAxis)(dBodyID, dReal x, dReal y, dReal z);
676 //int (ODE_API *dBodyGetFiniteRotationMode)(dBodyID);
677 //void (ODE_API *dBodyGetFiniteRotationAxis)(dBodyID, dVector3 result);
678 int (ODE_API *dBodyGetNumJoints)(dBodyID b);
679 dJointID (ODE_API *dBodyGetJoint)(dBodyID, int index);
680 //void (ODE_API *dBodySetDynamic)(dBodyID);
681 //void (ODE_API *dBodySetKinematic)(dBodyID);
682 //int (ODE_API *dBodyIsKinematic)(dBodyID);
683 void (ODE_API *dBodyEnable)(dBodyID);
684 void (ODE_API *dBodyDisable)(dBodyID);
685 int (ODE_API *dBodyIsEnabled)(dBodyID);
686 void (ODE_API *dBodySetGravityMode)(dBodyID b, int mode);
687 int (ODE_API *dBodyGetGravityMode)(dBodyID b);
688 //void (*dBodySetMovedCallback)(dBodyID b, void(ODE_API *callback)(dBodyID));
689 //dGeomID (ODE_API *dBodyGetFirstGeom)(dBodyID b);
690 //dGeomID (ODE_API *dBodyGetNextGeom)(dGeomID g);
691 //void (ODE_API *dBodySetDampingDefaults)(dBodyID b);
692 //dReal (ODE_API *dBodyGetLinearDamping)(dBodyID b);
693 //void (ODE_API *dBodySetLinearDamping)(dBodyID b, dReal scale);
694 //dReal (ODE_API *dBodyGetAngularDamping)(dBodyID b);
695 //void (ODE_API *dBodySetAngularDamping)(dBodyID b, dReal scale);
696 //void (ODE_API *dBodySetDamping)(dBodyID b, dReal linear_scale, dReal angular_scale);
697 //dReal (ODE_API *dBodyGetLinearDampingThreshold)(dBodyID b);
698 //void (ODE_API *dBodySetLinearDampingThreshold)(dBodyID b, dReal threshold);
699 //dReal (ODE_API *dBodyGetAngularDampingThreshold)(dBodyID b);
700 //void (ODE_API *dBodySetAngularDampingThreshold)(dBodyID b, dReal threshold);
701 //dReal (ODE_API *dBodyGetMaxAngularSpeed)(dBodyID b);
702 //void (ODE_API *dBodySetMaxAngularSpeed)(dBodyID b, dReal max_speed);
703 //int (ODE_API *dBodyGetGyroscopicMode)(dBodyID b);
704 //void (ODE_API *dBodySetGyroscopicMode)(dBodyID b, int enabled);
705 dJointID (ODE_API *dJointCreateBall)(dWorldID, dJointGroupID);
706 dJointID (ODE_API *dJointCreateHinge)(dWorldID, dJointGroupID);
707 dJointID (ODE_API *dJointCreateSlider)(dWorldID, dJointGroupID);
708 dJointID (ODE_API *dJointCreateContact)(dWorldID, dJointGroupID, const dContact *);
709 dJointID (ODE_API *dJointCreateHinge2)(dWorldID, dJointGroupID);
710 dJointID (ODE_API *dJointCreateUniversal)(dWorldID, dJointGroupID);
711 //dJointID (ODE_API *dJointCreatePR)(dWorldID, dJointGroupID);
712 //dJointID (ODE_API *dJointCreatePU)(dWorldID, dJointGroupID);
713 //dJointID (ODE_API *dJointCreatePiston)(dWorldID, dJointGroupID);
714 dJointID (ODE_API *dJointCreateFixed)(dWorldID, dJointGroupID);
715 //dJointID (ODE_API *dJointCreateNull)(dWorldID, dJointGroupID);
716 //dJointID (ODE_API *dJointCreateAMotor)(dWorldID, dJointGroupID);
717 //dJointID (ODE_API *dJointCreateLMotor)(dWorldID, dJointGroupID);
718 //dJointID (ODE_API *dJointCreatePlane2D)(dWorldID, dJointGroupID);
719 void (ODE_API *dJointDestroy)(dJointID);
720 dJointGroupID (ODE_API *dJointGroupCreate)(int max_size);
721 void (ODE_API *dJointGroupDestroy)(dJointGroupID);
722 void (ODE_API *dJointGroupEmpty)(dJointGroupID);
723 //int (ODE_API *dJointGetNumBodies)(dJointID);
724 void (ODE_API *dJointAttach)(dJointID, dBodyID body1, dBodyID body2);
725 //void (ODE_API *dJointEnable)(dJointID);
726 //void (ODE_API *dJointDisable)(dJointID);
727 //int (ODE_API *dJointIsEnabled)(dJointID);
728 void (ODE_API *dJointSetData)(dJointID, void *data);
729 void * (ODE_API *dJointGetData)(dJointID);
730 //dJointType (ODE_API *dJointGetType)(dJointID);
731 dBodyID (ODE_API *dJointGetBody)(dJointID, int index);
732 //void (ODE_API *dJointSetFeedback)(dJointID, dJointFeedback *);
733 //dJointFeedback *(ODE_API *dJointGetFeedback)(dJointID);
734 void (ODE_API *dJointSetBallAnchor)(dJointID, dReal x, dReal y, dReal z);
735 //void (ODE_API *dJointSetBallAnchor2)(dJointID, dReal x, dReal y, dReal z);
736 void (ODE_API *dJointSetBallParam)(dJointID, int parameter, dReal value);
737 void (ODE_API *dJointSetHingeAnchor)(dJointID, dReal x, dReal y, dReal z);
738 //void (ODE_API *dJointSetHingeAnchorDelta)(dJointID, dReal x, dReal y, dReal z, dReal ax, dReal ay, dReal az);
739 void (ODE_API *dJointSetHingeAxis)(dJointID, dReal x, dReal y, dReal z);
740 //void (ODE_API *dJointSetHingeAxisOffset)(dJointID j, dReal x, dReal y, dReal z, dReal angle);
741 void (ODE_API *dJointSetHingeParam)(dJointID, int parameter, dReal value);
742 //void (ODE_API *dJointAddHingeTorque)(dJointID joint, dReal torque);
743 void (ODE_API *dJointSetSliderAxis)(dJointID, dReal x, dReal y, dReal z);
744 //void (ODE_API *dJointSetSliderAxisDelta)(dJointID, dReal x, dReal y, dReal z, dReal ax, dReal ay, dReal az);
745 void (ODE_API *dJointSetSliderParam)(dJointID, int parameter, dReal value);
746 //void (ODE_API *dJointAddSliderForce)(dJointID joint, dReal force);
747 void (ODE_API *dJointSetHinge2Anchor)(dJointID, dReal x, dReal y, dReal z);
748 void (ODE_API *dJointSetHinge2Axis1)(dJointID, dReal x, dReal y, dReal z);
749 void (ODE_API *dJointSetHinge2Axis2)(dJointID, dReal x, dReal y, dReal z);
750 void (ODE_API *dJointSetHinge2Param)(dJointID, int parameter, dReal value);
751 //void (ODE_API *dJointAddHinge2Torques)(dJointID joint, dReal torque1, dReal torque2);
752 void (ODE_API *dJointSetUniversalAnchor)(dJointID, dReal x, dReal y, dReal z);
753 void (ODE_API *dJointSetUniversalAxis1)(dJointID, dReal x, dReal y, dReal z);
754 //void (ODE_API *dJointSetUniversalAxis1Offset)(dJointID, dReal x, dReal y, dReal z, dReal offset1, dReal offset2);
755 void (ODE_API *dJointSetUniversalAxis2)(dJointID, dReal x, dReal y, dReal z);
756 //void (ODE_API *dJointSetUniversalAxis2Offset)(dJointID, dReal x, dReal y, dReal z, dReal offset1, dReal offset2);
757 void (ODE_API *dJointSetUniversalParam)(dJointID, int parameter, dReal value);
758 //void (ODE_API *dJointAddUniversalTorques)(dJointID joint, dReal torque1, dReal torque2);
759 //void (ODE_API *dJointSetPRAnchor)(dJointID, dReal x, dReal y, dReal z);
760 //void (ODE_API *dJointSetPRAxis1)(dJointID, dReal x, dReal y, dReal z);
761 //void (ODE_API *dJointSetPRAxis2)(dJointID, dReal x, dReal y, dReal z);
762 //void (ODE_API *dJointSetPRParam)(dJointID, int parameter, dReal value);
763 //void (ODE_API *dJointAddPRTorque)(dJointID j, dReal torque);
764 //void (ODE_API *dJointSetPUAnchor)(dJointID, dReal x, dReal y, dReal z);
765 //void (ODE_API *dJointSetPUAnchorOffset)(dJointID, dReal x, dReal y, dReal z, dReal dx, dReal dy, dReal dz);
766 //void (ODE_API *dJointSetPUAxis1)(dJointID, dReal x, dReal y, dReal z);
767 //void (ODE_API *dJointSetPUAxis2)(dJointID, dReal x, dReal y, dReal z);
768 //void (ODE_API *dJointSetPUAxis3)(dJointID, dReal x, dReal y, dReal z);
769 //void (ODE_API *dJointSetPUAxisP)(dJointID id, dReal x, dReal y, dReal z);
770 //void (ODE_API *dJointSetPUParam)(dJointID, int parameter, dReal value);
771 //void (ODE_API *dJointAddPUTorque)(dJointID j, dReal torque);
772 //void (ODE_API *dJointSetPistonAnchor)(dJointID, dReal x, dReal y, dReal z);
773 //void (ODE_API *dJointSetPistonAnchorOffset)(dJointID j, dReal x, dReal y, dReal z, dReal dx, dReal dy, dReal dz);
774 //void (ODE_API *dJointSetPistonParam)(dJointID, int parameter, dReal value);
775 //void (ODE_API *dJointAddPistonForce)(dJointID joint, dReal force);
776 //void (ODE_API *dJointSetFixed)(dJointID);
777 //void (ODE_API *dJointSetFixedParam)(dJointID, int parameter, dReal value);
778 //void (ODE_API *dJointSetAMotorNumAxes)(dJointID, int num);
779 //void (ODE_API *dJointSetAMotorAxis)(dJointID, int anum, int rel, dReal x, dReal y, dReal z);
780 //void (ODE_API *dJointSetAMotorAngle)(dJointID, int anum, dReal angle);
781 //void (ODE_API *dJointSetAMotorParam)(dJointID, int parameter, dReal value);
782 //void (ODE_API *dJointSetAMotorMode)(dJointID, int mode);
783 //void (ODE_API *dJointAddAMotorTorques)(dJointID, dReal torque1, dReal torque2, dReal torque3);
784 //void (ODE_API *dJointSetLMotorNumAxes)(dJointID, int num);
785 //void (ODE_API *dJointSetLMotorAxis)(dJointID, int anum, int rel, dReal x, dReal y, dReal z);
786 //void (ODE_API *dJointSetLMotorParam)(dJointID, int parameter, dReal value);
787 //void (ODE_API *dJointSetPlane2DXParam)(dJointID, int parameter, dReal value);
788 //void (ODE_API *dJointSetPlane2DYParam)(dJointID, int parameter, dReal value);
789 //void (ODE_API *dJointSetPlane2DAngleParam)(dJointID, int parameter, dReal value);
790 //void (ODE_API *dJointGetBallAnchor)(dJointID, dVector3 result);
791 //void (ODE_API *dJointGetBallAnchor2)(dJointID, dVector3 result);
792 //dReal (ODE_API *dJointGetBallParam)(dJointID, int parameter);
793 //void (ODE_API *dJointGetHingeAnchor)(dJointID, dVector3 result);
794 //void (ODE_API *dJointGetHingeAnchor2)(dJointID, dVector3 result);
795 //void (ODE_API *dJointGetHingeAxis)(dJointID, dVector3 result);
796 //dReal (ODE_API *dJointGetHingeParam)(dJointID, int parameter);
797 //dReal (ODE_API *dJointGetHingeAngle)(dJointID);
798 //dReal (ODE_API *dJointGetHingeAngleRate)(dJointID);
799 //dReal (ODE_API *dJointGetSliderPosition)(dJointID);
800 //dReal (ODE_API *dJointGetSliderPositionRate)(dJointID);
801 //void (ODE_API *dJointGetSliderAxis)(dJointID, dVector3 result);
802 //dReal (ODE_API *dJointGetSliderParam)(dJointID, int parameter);
803 //void (ODE_API *dJointGetHinge2Anchor)(dJointID, dVector3 result);
804 //void (ODE_API *dJointGetHinge2Anchor2)(dJointID, dVector3 result);
805 //void (ODE_API *dJointGetHinge2Axis1)(dJointID, dVector3 result);
806 //void (ODE_API *dJointGetHinge2Axis2)(dJointID, dVector3 result);
807 //dReal (ODE_API *dJointGetHinge2Param)(dJointID, int parameter);
808 //dReal (ODE_API *dJointGetHinge2Angle1)(dJointID);
809 //dReal (ODE_API *dJointGetHinge2Angle1Rate)(dJointID);
810 //dReal (ODE_API *dJointGetHinge2Angle2Rate)(dJointID);
811 //void (ODE_API *dJointGetUniversalAnchor)(dJointID, dVector3 result);
812 //void (ODE_API *dJointGetUniversalAnchor2)(dJointID, dVector3 result);
813 //void (ODE_API *dJointGetUniversalAxis1)(dJointID, dVector3 result);
814 //void (ODE_API *dJointGetUniversalAxis2)(dJointID, dVector3 result);
815 //dReal (ODE_API *dJointGetUniversalParam)(dJointID, int parameter);
816 //void (ODE_API *dJointGetUniversalAngles)(dJointID, dReal *angle1, dReal *angle2);
817 //dReal (ODE_API *dJointGetUniversalAngle1)(dJointID);
818 //dReal (ODE_API *dJointGetUniversalAngle2)(dJointID);
819 //dReal (ODE_API *dJointGetUniversalAngle1Rate)(dJointID);
820 //dReal (ODE_API *dJointGetUniversalAngle2Rate)(dJointID);
821 //void (ODE_API *dJointGetPRAnchor)(dJointID, dVector3 result);
822 //dReal (ODE_API *dJointGetPRPosition)(dJointID);
823 //dReal (ODE_API *dJointGetPRPositionRate)(dJointID);
824 //dReal (ODE_API *dJointGetPRAngle)(dJointID);
825 //dReal (ODE_API *dJointGetPRAngleRate)(dJointID);
826 //void (ODE_API *dJointGetPRAxis1)(dJointID, dVector3 result);
827 //void (ODE_API *dJointGetPRAxis2)(dJointID, dVector3 result);
828 //dReal (ODE_API *dJointGetPRParam)(dJointID, int parameter);
829 //void (ODE_API *dJointGetPUAnchor)(dJointID, dVector3 result);
830 //dReal (ODE_API *dJointGetPUPosition)(dJointID);
831 //dReal (ODE_API *dJointGetPUPositionRate)(dJointID);
832 //void (ODE_API *dJointGetPUAxis1)(dJointID, dVector3 result);
833 //void (ODE_API *dJointGetPUAxis2)(dJointID, dVector3 result);
834 //void (ODE_API *dJointGetPUAxis3)(dJointID, dVector3 result);
835 //void (ODE_API *dJointGetPUAxisP)(dJointID id, dVector3 result);
836 //void (ODE_API *dJointGetPUAngles)(dJointID, dReal *angle1, dReal *angle2);
837 //dReal (ODE_API *dJointGetPUAngle1)(dJointID);
838 //dReal (ODE_API *dJointGetPUAngle1Rate)(dJointID);
839 //dReal (ODE_API *dJointGetPUAngle2)(dJointID);
840 //dReal (ODE_API *dJointGetPUAngle2Rate)(dJointID);
841 //dReal (ODE_API *dJointGetPUParam)(dJointID, int parameter);
842 //dReal (ODE_API *dJointGetPistonPosition)(dJointID);
843 //dReal (ODE_API *dJointGetPistonPositionRate)(dJointID);
844 //dReal (ODE_API *dJointGetPistonAngle)(dJointID);
845 //dReal (ODE_API *dJointGetPistonAngleRate)(dJointID);
846 //void (ODE_API *dJointGetPistonAnchor)(dJointID, dVector3 result);
847 //void (ODE_API *dJointGetPistonAnchor2)(dJointID, dVector3 result);
848 //void (ODE_API *dJointGetPistonAxis)(dJointID, dVector3 result);
849 //dReal (ODE_API *dJointGetPistonParam)(dJointID, int parameter);
850 //int (ODE_API *dJointGetAMotorNumAxes)(dJointID);
851 //void (ODE_API *dJointGetAMotorAxis)(dJointID, int anum, dVector3 result);
852 //int (ODE_API *dJointGetAMotorAxisRel)(dJointID, int anum);
853 //dReal (ODE_API *dJointGetAMotorAngle)(dJointID, int anum);
854 //dReal (ODE_API *dJointGetAMotorAngleRate)(dJointID, int anum);
855 //dReal (ODE_API *dJointGetAMotorParam)(dJointID, int parameter);
856 //int (ODE_API *dJointGetAMotorMode)(dJointID);
857 //int (ODE_API *dJointGetLMotorNumAxes)(dJointID);
858 //void (ODE_API *dJointGetLMotorAxis)(dJointID, int anum, dVector3 result);
859 //dReal (ODE_API *dJointGetLMotorParam)(dJointID, int parameter);
860 //dReal (ODE_API *dJointGetFixedParam)(dJointID, int parameter);
861 //dJointID (ODE_API *dConnectingJoint)(dBodyID, dBodyID);
862 //int (ODE_API *dConnectingJointList)(dBodyID, dBodyID, dJointID*);
863 int (ODE_API *dAreConnected)(dBodyID, dBodyID);
864 int (ODE_API *dAreConnectedExcluding)(dBodyID body1, dBodyID body2, int joint_type);
866 dSpaceID (ODE_API *dSimpleSpaceCreate)(dSpaceID space);
867 dSpaceID (ODE_API *dHashSpaceCreate)(dSpaceID space);
868 dSpaceID (ODE_API *dQuadTreeSpaceCreate)(dSpaceID space, const dVector3 Center, const dVector3 Extents, int Depth);
869 //dSpaceID (ODE_API *dSweepAndPruneSpaceCreate)( dSpaceID space, int axisorder );
870 void (ODE_API *dSpaceDestroy)(dSpaceID);
871 //void (ODE_API *dHashSpaceSetLevels)(dSpaceID space, int minlevel, int maxlevel);
872 //void (ODE_API *dHashSpaceGetLevels)(dSpaceID space, int *minlevel, int *maxlevel);
873 //void (ODE_API *dSpaceSetCleanup)(dSpaceID space, int mode);
874 //int (ODE_API *dSpaceGetCleanup)(dSpaceID space);
875 //void (ODE_API *dSpaceSetSublevel)(dSpaceID space, int sublevel);
876 //int (ODE_API *dSpaceGetSublevel)(dSpaceID space);
877 //void (ODE_API *dSpaceSetManualCleanup)(dSpaceID space, int mode);
878 //int (ODE_API *dSpaceGetManualCleanup)(dSpaceID space);
879 //void (ODE_API *dSpaceAdd)(dSpaceID, dGeomID);
880 //void (ODE_API *dSpaceRemove)(dSpaceID, dGeomID);
881 //int (ODE_API *dSpaceQuery)(dSpaceID, dGeomID);
882 //void (ODE_API *dSpaceClean)(dSpaceID);
883 //int (ODE_API *dSpaceGetNumGeoms)(dSpaceID);
884 //dGeomID (ODE_API *dSpaceGetGeom)(dSpaceID, int i);
885 //int (ODE_API *dSpaceGetClass)(dSpaceID space);
887 void (ODE_API *dGeomDestroy)(dGeomID geom);
888 void (ODE_API *dGeomSetData)(dGeomID geom, void* data);
889 void * (ODE_API *dGeomGetData)(dGeomID geom);
890 void (ODE_API *dGeomSetBody)(dGeomID geom, dBodyID body);
891 dBodyID (ODE_API *dGeomGetBody)(dGeomID geom);
892 void (ODE_API *dGeomSetPosition)(dGeomID geom, dReal x, dReal y, dReal z);
893 void (ODE_API *dGeomSetRotation)(dGeomID geom, const dMatrix3 R);
894 //void (ODE_API *dGeomSetQuaternion)(dGeomID geom, const dQuaternion Q);
895 //const dReal * (ODE_API *dGeomGetPosition)(dGeomID geom);
896 //void (ODE_API *dGeomCopyPosition)(dGeomID geom, dVector3 pos);
897 //const dReal * (ODE_API *dGeomGetRotation)(dGeomID geom);
898 //void (ODE_API *dGeomCopyRotation)(dGeomID geom, dMatrix3 R);
899 //void (ODE_API *dGeomGetQuaternion)(dGeomID geom, dQuaternion result);
900 //void (ODE_API *dGeomGetAABB)(dGeomID geom, dReal aabb[6]);
901 int (ODE_API *dGeomIsSpace)(dGeomID geom);
902 //dSpaceID (ODE_API *dGeomGetSpace)(dGeomID);
903 //int (ODE_API *dGeomGetClass)(dGeomID geom);
904 //void (ODE_API *dGeomSetCategoryBits)(dGeomID geom, unsigned long bits);
905 //void (ODE_API *dGeomSetCollideBits)(dGeomID geom, unsigned long bits);
906 //unsigned long (ODE_API *dGeomGetCategoryBits)(dGeomID);
907 //unsigned long (ODE_API *dGeomGetCollideBits)(dGeomID);
908 //void (ODE_API *dGeomEnable)(dGeomID geom);
909 //void (ODE_API *dGeomDisable)(dGeomID geom);
910 //int (ODE_API *dGeomIsEnabled)(dGeomID geom);
911 //void (ODE_API *dGeomSetOffsetPosition)(dGeomID geom, dReal x, dReal y, dReal z);
912 //void (ODE_API *dGeomSetOffsetRotation)(dGeomID geom, const dMatrix3 R);
913 //void (ODE_API *dGeomSetOffsetQuaternion)(dGeomID geom, const dQuaternion Q);
914 //void (ODE_API *dGeomSetOffsetWorldPosition)(dGeomID geom, dReal x, dReal y, dReal z);
915 //void (ODE_API *dGeomSetOffsetWorldRotation)(dGeomID geom, const dMatrix3 R);
916 //void (ODE_API *dGeomSetOffsetWorldQuaternion)(dGeomID geom, const dQuaternion);
917 //void (ODE_API *dGeomClearOffset)(dGeomID geom);
918 //int (ODE_API *dGeomIsOffset)(dGeomID geom);
919 //const dReal * (ODE_API *dGeomGetOffsetPosition)(dGeomID geom);
920 //void (ODE_API *dGeomCopyOffsetPosition)(dGeomID geom, dVector3 pos);
921 //const dReal * (ODE_API *dGeomGetOffsetRotation)(dGeomID geom);
922 //void (ODE_API *dGeomCopyOffsetRotation)(dGeomID geom, dMatrix3 R);
923 //void (ODE_API *dGeomGetOffsetQuaternion)(dGeomID geom, dQuaternion result);
924 int (ODE_API *dCollide)(dGeomID o1, dGeomID o2, int flags, dContactGeom *contact, int skip);
926 void (ODE_API *dSpaceCollide)(dSpaceID space, void *data, dNearCallback *callback);
927 void (ODE_API *dSpaceCollide2)(dGeomID space1, dGeomID space2, void *data, dNearCallback *callback);
929 dGeomID (ODE_API *dCreateSphere)(dSpaceID space, dReal radius);
930 //void (ODE_API *dGeomSphereSetRadius)(dGeomID sphere, dReal radius);
931 //dReal (ODE_API *dGeomSphereGetRadius)(dGeomID sphere);
932 //dReal (ODE_API *dGeomSpherePointDepth)(dGeomID sphere, dReal x, dReal y, dReal z);
934 //dGeomID (ODE_API *dCreateConvex)(dSpaceID space, dReal *_planes, unsigned int _planecount, dReal *_points, unsigned int _pointcount,unsigned int *_polygons);
935 //void (ODE_API *dGeomSetConvex)(dGeomID g, dReal *_planes, unsigned int _count, dReal *_points, unsigned int _pointcount,unsigned int *_polygons);
937 dGeomID (ODE_API *dCreateBox)(dSpaceID space, dReal lx, dReal ly, dReal lz);
938 //void (ODE_API *dGeomBoxSetLengths)(dGeomID box, dReal lx, dReal ly, dReal lz);
939 //void (ODE_API *dGeomBoxGetLengths)(dGeomID box, dVector3 result);
940 //dReal (ODE_API *dGeomBoxPointDepth)(dGeomID box, dReal x, dReal y, dReal z);
941 //dReal (ODE_API *dGeomBoxPointDepth)(dGeomID box, dReal x, dReal y, dReal z);
943 //dGeomID (ODE_API *dCreatePlane)(dSpaceID space, dReal a, dReal b, dReal c, dReal d);
944 //void (ODE_API *dGeomPlaneSetParams)(dGeomID plane, dReal a, dReal b, dReal c, dReal d);
945 //void (ODE_API *dGeomPlaneGetParams)(dGeomID plane, dVector4 result);
946 //dReal (ODE_API *dGeomPlanePointDepth)(dGeomID plane, dReal x, dReal y, dReal z);
948 dGeomID (ODE_API *dCreateCapsule)(dSpaceID space, dReal radius, dReal length);
949 //void (ODE_API *dGeomCapsuleSetParams)(dGeomID ccylinder, dReal radius, dReal length);
950 //void (ODE_API *dGeomCapsuleGetParams)(dGeomID ccylinder, dReal *radius, dReal *length);
951 //dReal (ODE_API *dGeomCapsulePointDepth)(dGeomID ccylinder, dReal x, dReal y, dReal z);
953 //dGeomID (ODE_API *dCreateCylinder)(dSpaceID space, dReal radius, dReal length);
954 //void (ODE_API *dGeomCylinderSetParams)(dGeomID cylinder, dReal radius, dReal length);
955 //void (ODE_API *dGeomCylinderGetParams)(dGeomID cylinder, dReal *radius, dReal *length);
957 //dGeomID (ODE_API *dCreateRay)(dSpaceID space, dReal length);
958 //void (ODE_API *dGeomRaySetLength)(dGeomID ray, dReal length);
959 //dReal (ODE_API *dGeomRayGetLength)(dGeomID ray);
960 //void (ODE_API *dGeomRaySet)(dGeomID ray, dReal px, dReal py, dReal pz, dReal dx, dReal dy, dReal dz);
961 //void (ODE_API *dGeomRayGet)(dGeomID ray, dVector3 start, dVector3 dir);
963 dGeomID (ODE_API *dCreateGeomTransform)(dSpaceID space);
964 void (ODE_API *dGeomTransformSetGeom)(dGeomID g, dGeomID obj);
965 //dGeomID (ODE_API *dGeomTransformGetGeom)(dGeomID g);
966 void (ODE_API *dGeomTransformSetCleanup)(dGeomID g, int mode);
967 //int (ODE_API *dGeomTransformGetCleanup)(dGeomID g);
968 //void (ODE_API *dGeomTransformSetInfo)(dGeomID g, int mode);
969 //int (ODE_API *dGeomTransformGetInfo)(dGeomID g);
971 enum { TRIMESH_FACE_NORMALS };
972 typedef int dTriCallback(dGeomID TriMesh, dGeomID RefObject, int TriangleIndex);
973 typedef void dTriArrayCallback(dGeomID TriMesh, dGeomID RefObject, const int* TriIndices, int TriCount);
974 typedef int dTriRayCallback(dGeomID TriMesh, dGeomID Ray, int TriangleIndex, dReal u, dReal v);
975 typedef int dTriTriMergeCallback(dGeomID TriMesh, int FirstTriangleIndex, int SecondTriangleIndex);
977 dTriMeshDataID (ODE_API *dGeomTriMeshDataCreate)(void);
978 void (ODE_API *dGeomTriMeshDataDestroy)(dTriMeshDataID g);
979 //void (ODE_API *dGeomTriMeshDataSet)(dTriMeshDataID g, int data_id, void* in_data);
980 //void* (ODE_API *dGeomTriMeshDataGet)(dTriMeshDataID g, int data_id);
981 //void (*dGeomTriMeshSetLastTransform)( (ODE_API *dGeomID g, dMatrix4 last_trans );
982 //dReal* (*dGeomTriMeshGetLastTransform)( (ODE_API *dGeomID g );
983 void (ODE_API *dGeomTriMeshDataBuildSingle)(dTriMeshDataID g, const void* Vertices, int VertexStride, int VertexCount, const void* Indices, int IndexCount, int TriStride);
984 //void (ODE_API *dGeomTriMeshDataBuildSingle1)(dTriMeshDataID g, const void* Vertices, int VertexStride, int VertexCount, const void* Indices, int IndexCount, int TriStride, const void* Normals);
985 //void (ODE_API *dGeomTriMeshDataBuildDouble)(dTriMeshDataID g, const void* Vertices, int VertexStride, int VertexCount, const void* Indices, int IndexCount, int TriStride);
986 //void (ODE_API *dGeomTriMeshDataBuildDouble1)(dTriMeshDataID g, const void* Vertices, int VertexStride, int VertexCount, const void* Indices, int IndexCount, int TriStride, const void* Normals);
987 //void (ODE_API *dGeomTriMeshDataBuildSimple)(dTriMeshDataID g, const dReal* Vertices, int VertexCount, const dTriIndex* Indices, int IndexCount);
988 //void (ODE_API *dGeomTriMeshDataBuildSimple1)(dTriMeshDataID g, const dReal* Vertices, int VertexCount, const dTriIndex* Indices, int IndexCount, const int* Normals);
989 //void (ODE_API *dGeomTriMeshDataPreprocess)(dTriMeshDataID g);
990 //void (ODE_API *dGeomTriMeshDataGetBuffer)(dTriMeshDataID g, unsigned char** buf, int* bufLen);
991 //void (ODE_API *dGeomTriMeshDataSetBuffer)(dTriMeshDataID g, unsigned char* buf);
992 //void (ODE_API *dGeomTriMeshSetCallback)(dGeomID g, dTriCallback* Callback);
993 //dTriCallback* (ODE_API *dGeomTriMeshGetCallback)(dGeomID g);
994 //void (ODE_API *dGeomTriMeshSetArrayCallback)(dGeomID g, dTriArrayCallback* ArrayCallback);
995 //dTriArrayCallback* (ODE_API *dGeomTriMeshGetArrayCallback)(dGeomID g);
996 //void (ODE_API *dGeomTriMeshSetRayCallback)(dGeomID g, dTriRayCallback* Callback);
997 //dTriRayCallback* (ODE_API *dGeomTriMeshGetRayCallback)(dGeomID g);
998 //void (ODE_API *dGeomTriMeshSetTriMergeCallback)(dGeomID g, dTriTriMergeCallback* Callback);
999 //dTriTriMergeCallback* (ODE_API *dGeomTriMeshGetTriMergeCallback)(dGeomID g);
1000 dGeomID (ODE_API *dCreateTriMesh)(dSpaceID space, dTriMeshDataID Data, dTriCallback* Callback, dTriArrayCallback* ArrayCallback, dTriRayCallback* RayCallback);
1001 //void (ODE_API *dGeomTriMeshSetData)(dGeomID g, dTriMeshDataID Data);
1002 //dTriMeshDataID (ODE_API *dGeomTriMeshGetData)(dGeomID g);
1003 //void (ODE_API *dGeomTriMeshEnableTC)(dGeomID g, int geomClass, int enable);
1004 //int (ODE_API *dGeomTriMeshIsTCEnabled)(dGeomID g, int geomClass);
1005 //void (ODE_API *dGeomTriMeshClearTCCache)(dGeomID g);
1006 //dTriMeshDataID (ODE_API *dGeomTriMeshGetTriMeshDataID)(dGeomID g);
1007 //void (ODE_API *dGeomTriMeshGetTriangle)(dGeomID g, int Index, dVector3* v0, dVector3* v1, dVector3* v2);
1008 //void (ODE_API *dGeomTriMeshGetPoint)(dGeomID g, int Index, dReal u, dReal v, dVector3 Out);
1009 //int (ODE_API *dGeomTriMeshGetTriangleCount )(dGeomID g);
1010 //void (ODE_API *dGeomTriMeshDataUpdate)(dTriMeshDataID g);
1012 static dllfunction_t odefuncs[] =
1014 // {"dGetConfiguration", (void **) &dGetConfiguration},
1015 {"dCheckConfiguration", (void **) &dCheckConfiguration},
1016 {"dInitODE", (void **) &dInitODE},
1017 // {"dInitODE2", (void **) &dInitODE2},
1018 // {"dAllocateODEDataForThread", (void **) &dAllocateODEDataForThread},
1019 // {"dCleanupODEAllDataForThread", (void **) &dCleanupODEAllDataForThread},
1020 {"dCloseODE", (void **) &dCloseODE},
1021 // {"dMassCheck", (void **) &dMassCheck},
1022 // {"dMassSetZero", (void **) &dMassSetZero},
1023 // {"dMassSetParameters", (void **) &dMassSetParameters},
1024 // {"dMassSetSphere", (void **) &dMassSetSphere},
1025 {"dMassSetSphereTotal", (void **) &dMassSetSphereTotal},
1026 // {"dMassSetCapsule", (void **) &dMassSetCapsule},
1027 {"dMassSetCapsuleTotal", (void **) &dMassSetCapsuleTotal},
1028 // {"dMassSetCylinder", (void **) &dMassSetCylinder},
1029 // {"dMassSetCylinderTotal", (void **) &dMassSetCylinderTotal},
1030 // {"dMassSetBox", (void **) &dMassSetBox},
1031 {"dMassSetBoxTotal", (void **) &dMassSetBoxTotal},
1032 // {"dMassSetTrimesh", (void **) &dMassSetTrimesh},
1033 // {"dMassSetTrimeshTotal", (void **) &dMassSetTrimeshTotal},
1034 // {"dMassAdjust", (void **) &dMassAdjust},
1035 // {"dMassTranslate", (void **) &dMassTranslate},
1036 // {"dMassRotate", (void **) &dMassRotate},
1037 // {"dMassAdd", (void **) &dMassAdd},
1039 {"dWorldCreate", (void **) &dWorldCreate},
1040 {"dWorldDestroy", (void **) &dWorldDestroy},
1041 {"dWorldSetGravity", (void **) &dWorldSetGravity},
1042 {"dWorldGetGravity", (void **) &dWorldGetGravity},
1043 {"dWorldSetERP", (void **) &dWorldSetERP},
1044 // {"dWorldGetERP", (void **) &dWorldGetERP},
1045 {"dWorldSetCFM", (void **) &dWorldSetCFM},
1046 // {"dWorldGetCFM", (void **) &dWorldGetCFM},
1047 {"dWorldStep", (void **) &dWorldStep},
1048 // {"dWorldImpulseToForce", (void **) &dWorldImpulseToForce},
1049 {"dWorldQuickStep", (void **) &dWorldQuickStep},
1050 {"dWorldSetQuickStepNumIterations", (void **) &dWorldSetQuickStepNumIterations},
1051 // {"dWorldGetQuickStepNumIterations", (void **) &dWorldGetQuickStepNumIterations},
1052 // {"dWorldSetQuickStepW", (void **) &dWorldSetQuickStepW},
1053 // {"dWorldGetQuickStepW", (void **) &dWorldGetQuickStepW},
1054 // {"dWorldSetContactMaxCorrectingVel", (void **) &dWorldSetContactMaxCorrectingVel},
1055 // {"dWorldGetContactMaxCorrectingVel", (void **) &dWorldGetContactMaxCorrectingVel},
1056 {"dWorldSetContactSurfaceLayer", (void **) &dWorldSetContactSurfaceLayer},
1057 // {"dWorldGetContactSurfaceLayer", (void **) &dWorldGetContactSurfaceLayer},
1058 #ifdef ODE_USE_STEPFAST
1059 {"dWorldStepFast1", (void **) &dWorldStepFast1},
1061 // {"dWorldSetAutoEnableDepthSF1", (void **) &dWorldSetAutoEnableDepthSF1},
1062 // {"dWorldGetAutoEnableDepthSF1", (void **) &dWorldGetAutoEnableDepthSF1},
1063 // {"dWorldGetAutoDisableLinearThreshold", (void **) &dWorldGetAutoDisableLinearThreshold},
1064 {"dWorldSetAutoDisableLinearThreshold", (void **) &dWorldSetAutoDisableLinearThreshold},
1065 // {"dWorldGetAutoDisableAngularThreshold", (void **) &dWorldGetAutoDisableAngularThreshold},
1066 {"dWorldSetAutoDisableAngularThreshold", (void **) &dWorldSetAutoDisableAngularThreshold},
1067 // {"dWorldGetAutoDisableLinearAverageThreshold", (void **) &dWorldGetAutoDisableLinearAverageThreshold},
1068 // {"dWorldSetAutoDisableLinearAverageThreshold", (void **) &dWorldSetAutoDisableLinearAverageThreshold},
1069 // {"dWorldGetAutoDisableAngularAverageThreshold", (void **) &dWorldGetAutoDisableAngularAverageThreshold},
1070 // {"dWorldSetAutoDisableAngularAverageThreshold", (void **) &dWorldSetAutoDisableAngularAverageThreshold},
1071 // {"dWorldGetAutoDisableAverageSamplesCount", (void **) &dWorldGetAutoDisableAverageSamplesCount},
1072 {"dWorldSetAutoDisableAverageSamplesCount", (void **) &dWorldSetAutoDisableAverageSamplesCount},
1073 // {"dWorldGetAutoDisableSteps", (void **) &dWorldGetAutoDisableSteps},
1074 {"dWorldSetAutoDisableSteps", (void **) &dWorldSetAutoDisableSteps},
1075 // {"dWorldGetAutoDisableTime", (void **) &dWorldGetAutoDisableTime},
1076 {"dWorldSetAutoDisableTime", (void **) &dWorldSetAutoDisableTime},
1077 // {"dWorldGetAutoDisableFlag", (void **) &dWorldGetAutoDisableFlag},
1078 {"dWorldSetAutoDisableFlag", (void **) &dWorldSetAutoDisableFlag},
1079 // {"dWorldGetLinearDampingThreshold", (void **) &dWorldGetLinearDampingThreshold},
1080 {"dWorldSetLinearDampingThreshold", (void **) &dWorldSetLinearDampingThreshold},
1081 // {"dWorldGetAngularDampingThreshold", (void **) &dWorldGetAngularDampingThreshold},
1082 {"dWorldSetAngularDampingThreshold", (void **) &dWorldSetAngularDampingThreshold},
1083 // {"dWorldGetLinearDamping", (void **) &dWorldGetLinearDamping},
1084 {"dWorldSetLinearDamping", (void **) &dWorldSetLinearDamping},
1085 // {"dWorldGetAngularDamping", (void **) &dWorldGetAngularDamping},
1086 {"dWorldSetAngularDamping", (void **) &dWorldSetAngularDamping},
1087 // {"dWorldSetDamping", (void **) &dWorldSetDamping},
1088 // {"dWorldGetMaxAngularSpeed", (void **) &dWorldGetMaxAngularSpeed},
1089 // {"dWorldSetMaxAngularSpeed", (void **) &dWorldSetMaxAngularSpeed},
1090 // {"dBodyGetAutoDisableLinearThreshold", (void **) &dBodyGetAutoDisableLinearThreshold},
1091 // {"dBodySetAutoDisableLinearThreshold", (void **) &dBodySetAutoDisableLinearThreshold},
1092 // {"dBodyGetAutoDisableAngularThreshold", (void **) &dBodyGetAutoDisableAngularThreshold},
1093 // {"dBodySetAutoDisableAngularThreshold", (void **) &dBodySetAutoDisableAngularThreshold},
1094 // {"dBodyGetAutoDisableAverageSamplesCount", (void **) &dBodyGetAutoDisableAverageSamplesCount},
1095 // {"dBodySetAutoDisableAverageSamplesCount", (void **) &dBodySetAutoDisableAverageSamplesCount},
1096 // {"dBodyGetAutoDisableSteps", (void **) &dBodyGetAutoDisableSteps},
1097 // {"dBodySetAutoDisableSteps", (void **) &dBodySetAutoDisableSteps},
1098 // {"dBodyGetAutoDisableTime", (void **) &dBodyGetAutoDisableTime},
1099 // {"dBodySetAutoDisableTime", (void **) &dBodySetAutoDisableTime},
1100 // {"dBodyGetAutoDisableFlag", (void **) &dBodyGetAutoDisableFlag},
1101 // {"dBodySetAutoDisableFlag", (void **) &dBodySetAutoDisableFlag},
1102 // {"dBodySetAutoDisableDefaults", (void **) &dBodySetAutoDisableDefaults},
1103 // {"dBodyGetWorld", (void **) &dBodyGetWorld},
1104 {"dBodyCreate", (void **) &dBodyCreate},
1105 {"dBodyDestroy", (void **) &dBodyDestroy},
1106 {"dBodySetData", (void **) &dBodySetData},
1107 {"dBodyGetData", (void **) &dBodyGetData},
1108 {"dBodySetPosition", (void **) &dBodySetPosition},
1109 {"dBodySetRotation", (void **) &dBodySetRotation},
1110 // {"dBodySetQuaternion", (void **) &dBodySetQuaternion},
1111 {"dBodySetLinearVel", (void **) &dBodySetLinearVel},
1112 {"dBodySetAngularVel", (void **) &dBodySetAngularVel},
1113 {"dBodyGetPosition", (void **) &dBodyGetPosition},
1114 // {"dBodyCopyPosition", (void **) &dBodyCopyPosition},
1115 {"dBodyGetRotation", (void **) &dBodyGetRotation},
1116 // {"dBodyCopyRotation", (void **) &dBodyCopyRotation},
1117 // {"dBodyGetQuaternion", (void **) &dBodyGetQuaternion},
1118 // {"dBodyCopyQuaternion", (void **) &dBodyCopyQuaternion},
1119 {"dBodyGetLinearVel", (void **) &dBodyGetLinearVel},
1120 {"dBodyGetAngularVel", (void **) &dBodyGetAngularVel},
1121 {"dBodySetMass", (void **) &dBodySetMass},
1122 // {"dBodyGetMass", (void **) &dBodyGetMass},
1123 // {"dBodyAddForce", (void **) &dBodyAddForce},
1124 // {"dBodyAddTorque", (void **) &dBodyAddTorque},
1125 // {"dBodyAddRelForce", (void **) &dBodyAddRelForce},
1126 {"dBodyAddRelTorque", (void **) &dBodyAddRelTorque},
1127 // {"dBodyAddForceAtPos", (void **) &dBodyAddForceAtPos},
1128 {"dBodyAddForceAtRelPos", (void **) &dBodyAddForceAtRelPos},
1129 // {"dBodyAddRelForceAtPos", (void **) &dBodyAddRelForceAtPos},
1130 // {"dBodyAddRelForceAtRelPos", (void **) &dBodyAddRelForceAtRelPos},
1131 // {"dBodyGetForce", (void **) &dBodyGetForce},
1132 // {"dBodyGetTorque", (void **) &dBodyGetTorque},
1133 // {"dBodySetForce", (void **) &dBodySetForce},
1134 // {"dBodySetTorque", (void **) &dBodySetTorque},
1135 // {"dBodyGetRelPointPos", (void **) &dBodyGetRelPointPos},
1136 // {"dBodyGetRelPointVel", (void **) &dBodyGetRelPointVel},
1137 // {"dBodyGetPointVel", (void **) &dBodyGetPointVel},
1138 // {"dBodyGetPosRelPoint", (void **) &dBodyGetPosRelPoint},
1139 // {"dBodyVectorToWorld", (void **) &dBodyVectorToWorld},
1140 // {"dBodyVectorFromWorld", (void **) &dBodyVectorFromWorld},
1141 // {"dBodySetFiniteRotationMode", (void **) &dBodySetFiniteRotationMode},
1142 // {"dBodySetFiniteRotationAxis", (void **) &dBodySetFiniteRotationAxis},
1143 // {"dBodyGetFiniteRotationMode", (void **) &dBodyGetFiniteRotationMode},
1144 // {"dBodyGetFiniteRotationAxis", (void **) &dBodyGetFiniteRotationAxis},
1145 {"dBodyGetNumJoints", (void **) &dBodyGetNumJoints},
1146 {"dBodyGetJoint", (void **) &dBodyGetJoint},
1147 // {"dBodySetDynamic", (void **) &dBodySetDynamic},
1148 // {"dBodySetKinematic", (void **) &dBodySetKinematic},
1149 // {"dBodyIsKinematic", (void **) &dBodyIsKinematic},
1150 {"dBodyEnable", (void **) &dBodyEnable},
1151 {"dBodyDisable", (void **) &dBodyDisable},
1152 {"dBodyIsEnabled", (void **) &dBodyIsEnabled},
1153 {"dBodySetGravityMode", (void **) &dBodySetGravityMode},
1154 {"dBodyGetGravityMode", (void **) &dBodyGetGravityMode},
1155 // {"dBodySetMovedCallback", (void **) &dBodySetMovedCallback},
1156 // {"dBodyGetFirstGeom", (void **) &dBodyGetFirstGeom},
1157 // {"dBodyGetNextGeom", (void **) &dBodyGetNextGeom},
1158 // {"dBodySetDampingDefaults", (void **) &dBodySetDampingDefaults},
1159 // {"dBodyGetLinearDamping", (void **) &dBodyGetLinearDamping},
1160 // {"dBodySetLinearDamping", (void **) &dBodySetLinearDamping},
1161 // {"dBodyGetAngularDamping", (void **) &dBodyGetAngularDamping},
1162 // {"dBodySetAngularDamping", (void **) &dBodySetAngularDamping},
1163 // {"dBodySetDamping", (void **) &dBodySetDamping},
1164 // {"dBodyGetLinearDampingThreshold", (void **) &dBodyGetLinearDampingThreshold},
1165 // {"dBodySetLinearDampingThreshold", (void **) &dBodySetLinearDampingThreshold},
1166 // {"dBodyGetAngularDampingThreshold", (void **) &dBodyGetAngularDampingThreshold},
1167 // {"dBodySetAngularDampingThreshold", (void **) &dBodySetAngularDampingThreshold},
1168 // {"dBodyGetMaxAngularSpeed", (void **) &dBodyGetMaxAngularSpeed},
1169 // {"dBodySetMaxAngularSpeed", (void **) &dBodySetMaxAngularSpeed},
1170 // {"dBodyGetGyroscopicMode", (void **) &dBodyGetGyroscopicMode},
1171 // {"dBodySetGyroscopicMode", (void **) &dBodySetGyroscopicMode},
1172 {"dJointCreateBall", (void **) &dJointCreateBall},
1173 {"dJointCreateHinge", (void **) &dJointCreateHinge},
1174 {"dJointCreateSlider", (void **) &dJointCreateSlider},
1175 {"dJointCreateContact", (void **) &dJointCreateContact},
1176 {"dJointCreateHinge2", (void **) &dJointCreateHinge2},
1177 {"dJointCreateUniversal", (void **) &dJointCreateUniversal},
1178 // {"dJointCreatePR", (void **) &dJointCreatePR},
1179 // {"dJointCreatePU", (void **) &dJointCreatePU},
1180 // {"dJointCreatePiston", (void **) &dJointCreatePiston},
1181 {"dJointCreateFixed", (void **) &dJointCreateFixed},
1182 // {"dJointCreateNull", (void **) &dJointCreateNull},
1183 // {"dJointCreateAMotor", (void **) &dJointCreateAMotor},
1184 // {"dJointCreateLMotor", (void **) &dJointCreateLMotor},
1185 // {"dJointCreatePlane2D", (void **) &dJointCreatePlane2D},
1186 {"dJointDestroy", (void **) &dJointDestroy},
1187 {"dJointGroupCreate", (void **) &dJointGroupCreate},
1188 {"dJointGroupDestroy", (void **) &dJointGroupDestroy},
1189 {"dJointGroupEmpty", (void **) &dJointGroupEmpty},
1190 // {"dJointGetNumBodies", (void **) &dJointGetNumBodies},
1191 {"dJointAttach", (void **) &dJointAttach},
1192 // {"dJointEnable", (void **) &dJointEnable},
1193 // {"dJointDisable", (void **) &dJointDisable},
1194 // {"dJointIsEnabled", (void **) &dJointIsEnabled},
1195 {"dJointSetData", (void **) &dJointSetData},
1196 {"dJointGetData", (void **) &dJointGetData},
1197 // {"dJointGetType", (void **) &dJointGetType},
1198 {"dJointGetBody", (void **) &dJointGetBody},
1199 // {"dJointSetFeedback", (void **) &dJointSetFeedback},
1200 // {"dJointGetFeedback", (void **) &dJointGetFeedback},
1201 {"dJointSetBallAnchor", (void **) &dJointSetBallAnchor},
1202 // {"dJointSetBallAnchor2", (void **) &dJointSetBallAnchor2},
1203 {"dJointSetBallParam", (void **) &dJointSetBallParam},
1204 {"dJointSetHingeAnchor", (void **) &dJointSetHingeAnchor},
1205 // {"dJointSetHingeAnchorDelta", (void **) &dJointSetHingeAnchorDelta},
1206 {"dJointSetHingeAxis", (void **) &dJointSetHingeAxis},
1207 // {"dJointSetHingeAxisOffset", (void **) &dJointSetHingeAxisOffset},
1208 {"dJointSetHingeParam", (void **) &dJointSetHingeParam},
1209 // {"dJointAddHingeTorque", (void **) &dJointAddHingeTorque},
1210 {"dJointSetSliderAxis", (void **) &dJointSetSliderAxis},
1211 // {"dJointSetSliderAxisDelta", (void **) &dJointSetSliderAxisDelta},
1212 {"dJointSetSliderParam", (void **) &dJointSetSliderParam},
1213 // {"dJointAddSliderForce", (void **) &dJointAddSliderForce},
1214 {"dJointSetHinge2Anchor", (void **) &dJointSetHinge2Anchor},
1215 {"dJointSetHinge2Axis1", (void **) &dJointSetHinge2Axis1},
1216 {"dJointSetHinge2Axis2", (void **) &dJointSetHinge2Axis2},
1217 {"dJointSetHinge2Param", (void **) &dJointSetHinge2Param},
1218 // {"dJointAddHinge2Torques", (void **) &dJointAddHinge2Torques},
1219 {"dJointSetUniversalAnchor", (void **) &dJointSetUniversalAnchor},
1220 {"dJointSetUniversalAxis1", (void **) &dJointSetUniversalAxis1},
1221 // {"dJointSetUniversalAxis1Offset", (void **) &dJointSetUniversalAxis1Offset},
1222 {"dJointSetUniversalAxis2", (void **) &dJointSetUniversalAxis2},
1223 // {"dJointSetUniversalAxis2Offset", (void **) &dJointSetUniversalAxis2Offset},
1224 {"dJointSetUniversalParam", (void **) &dJointSetUniversalParam},
1225 // {"dJointAddUniversalTorques", (void **) &dJointAddUniversalTorques},
1226 // {"dJointSetPRAnchor", (void **) &dJointSetPRAnchor},
1227 // {"dJointSetPRAxis1", (void **) &dJointSetPRAxis1},
1228 // {"dJointSetPRAxis2", (void **) &dJointSetPRAxis2},
1229 // {"dJointSetPRParam", (void **) &dJointSetPRParam},
1230 // {"dJointAddPRTorque", (void **) &dJointAddPRTorque},
1231 // {"dJointSetPUAnchor", (void **) &dJointSetPUAnchor},
1232 // {"dJointSetPUAnchorOffset", (void **) &dJointSetPUAnchorOffset},
1233 // {"dJointSetPUAxis1", (void **) &dJointSetPUAxis1},
1234 // {"dJointSetPUAxis2", (void **) &dJointSetPUAxis2},
1235 // {"dJointSetPUAxis3", (void **) &dJointSetPUAxis3},
1236 // {"dJointSetPUAxisP", (void **) &dJointSetPUAxisP},
1237 // {"dJointSetPUParam", (void **) &dJointSetPUParam},
1238 // {"dJointAddPUTorque", (void **) &dJointAddPUTorque},
1239 // {"dJointSetPistonAnchor", (void **) &dJointSetPistonAnchor},
1240 // {"dJointSetPistonAnchorOffset", (void **) &dJointSetPistonAnchorOffset},
1241 // {"dJointSetPistonParam", (void **) &dJointSetPistonParam},
1242 // {"dJointAddPistonForce", (void **) &dJointAddPistonForce},
1243 // {"dJointSetFixed", (void **) &dJointSetFixed},
1244 // {"dJointSetFixedParam", (void **) &dJointSetFixedParam},
1245 // {"dJointSetAMotorNumAxes", (void **) &dJointSetAMotorNumAxes},
1246 // {"dJointSetAMotorAxis", (void **) &dJointSetAMotorAxis},
1247 // {"dJointSetAMotorAngle", (void **) &dJointSetAMotorAngle},
1248 // {"dJointSetAMotorParam", (void **) &dJointSetAMotorParam},
1249 // {"dJointSetAMotorMode", (void **) &dJointSetAMotorMode},
1250 // {"dJointAddAMotorTorques", (void **) &dJointAddAMotorTorques},
1251 // {"dJointSetLMotorNumAxes", (void **) &dJointSetLMotorNumAxes},
1252 // {"dJointSetLMotorAxis", (void **) &dJointSetLMotorAxis},
1253 // {"dJointSetLMotorParam", (void **) &dJointSetLMotorParam},
1254 // {"dJointSetPlane2DXParam", (void **) &dJointSetPlane2DXParam},
1255 // {"dJointSetPlane2DYParam", (void **) &dJointSetPlane2DYParam},
1256 // {"dJointSetPlane2DAngleParam", (void **) &dJointSetPlane2DAngleParam},
1257 // {"dJointGetBallAnchor", (void **) &dJointGetBallAnchor},
1258 // {"dJointGetBallAnchor2", (void **) &dJointGetBallAnchor2},
1259 // {"dJointGetBallParam", (void **) &dJointGetBallParam},
1260 // {"dJointGetHingeAnchor", (void **) &dJointGetHingeAnchor},
1261 // {"dJointGetHingeAnchor2", (void **) &dJointGetHingeAnchor2},
1262 // {"dJointGetHingeAxis", (void **) &dJointGetHingeAxis},
1263 // {"dJointGetHingeParam", (void **) &dJointGetHingeParam},
1264 // {"dJointGetHingeAngle", (void **) &dJointGetHingeAngle},
1265 // {"dJointGetHingeAngleRate", (void **) &dJointGetHingeAngleRate},
1266 // {"dJointGetSliderPosition", (void **) &dJointGetSliderPosition},
1267 // {"dJointGetSliderPositionRate", (void **) &dJointGetSliderPositionRate},
1268 // {"dJointGetSliderAxis", (void **) &dJointGetSliderAxis},
1269 // {"dJointGetSliderParam", (void **) &dJointGetSliderParam},
1270 // {"dJointGetHinge2Anchor", (void **) &dJointGetHinge2Anchor},
1271 // {"dJointGetHinge2Anchor2", (void **) &dJointGetHinge2Anchor2},
1272 // {"dJointGetHinge2Axis1", (void **) &dJointGetHinge2Axis1},
1273 // {"dJointGetHinge2Axis2", (void **) &dJointGetHinge2Axis2},
1274 // {"dJointGetHinge2Param", (void **) &dJointGetHinge2Param},
1275 // {"dJointGetHinge2Angle1", (void **) &dJointGetHinge2Angle1},
1276 // {"dJointGetHinge2Angle1Rate", (void **) &dJointGetHinge2Angle1Rate},
1277 // {"dJointGetHinge2Angle2Rate", (void **) &dJointGetHinge2Angle2Rate},
1278 // {"dJointGetUniversalAnchor", (void **) &dJointGetUniversalAnchor},
1279 // {"dJointGetUniversalAnchor2", (void **) &dJointGetUniversalAnchor2},
1280 // {"dJointGetUniversalAxis1", (void **) &dJointGetUniversalAxis1},
1281 // {"dJointGetUniversalAxis2", (void **) &dJointGetUniversalAxis2},
1282 // {"dJointGetUniversalParam", (void **) &dJointGetUniversalParam},
1283 // {"dJointGetUniversalAngles", (void **) &dJointGetUniversalAngles},
1284 // {"dJointGetUniversalAngle1", (void **) &dJointGetUniversalAngle1},
1285 // {"dJointGetUniversalAngle2", (void **) &dJointGetUniversalAngle2},
1286 // {"dJointGetUniversalAngle1Rate", (void **) &dJointGetUniversalAngle1Rate},
1287 // {"dJointGetUniversalAngle2Rate", (void **) &dJointGetUniversalAngle2Rate},
1288 // {"dJointGetPRAnchor", (void **) &dJointGetPRAnchor},
1289 // {"dJointGetPRPosition", (void **) &dJointGetPRPosition},
1290 // {"dJointGetPRPositionRate", (void **) &dJointGetPRPositionRate},
1291 // {"dJointGetPRAngle", (void **) &dJointGetPRAngle},
1292 // {"dJointGetPRAngleRate", (void **) &dJointGetPRAngleRate},
1293 // {"dJointGetPRAxis1", (void **) &dJointGetPRAxis1},
1294 // {"dJointGetPRAxis2", (void **) &dJointGetPRAxis2},
1295 // {"dJointGetPRParam", (void **) &dJointGetPRParam},
1296 // {"dJointGetPUAnchor", (void **) &dJointGetPUAnchor},
1297 // {"dJointGetPUPosition", (void **) &dJointGetPUPosition},
1298 // {"dJointGetPUPositionRate", (void **) &dJointGetPUPositionRate},
1299 // {"dJointGetPUAxis1", (void **) &dJointGetPUAxis1},
1300 // {"dJointGetPUAxis2", (void **) &dJointGetPUAxis2},
1301 // {"dJointGetPUAxis3", (void **) &dJointGetPUAxis3},
1302 // {"dJointGetPUAxisP", (void **) &dJointGetPUAxisP},
1303 // {"dJointGetPUAngles", (void **) &dJointGetPUAngles},
1304 // {"dJointGetPUAngle1", (void **) &dJointGetPUAngle1},
1305 // {"dJointGetPUAngle1Rate", (void **) &dJointGetPUAngle1Rate},
1306 // {"dJointGetPUAngle2", (void **) &dJointGetPUAngle2},
1307 // {"dJointGetPUAngle2Rate", (void **) &dJointGetPUAngle2Rate},
1308 // {"dJointGetPUParam", (void **) &dJointGetPUParam},
1309 // {"dJointGetPistonPosition", (void **) &dJointGetPistonPosition},
1310 // {"dJointGetPistonPositionRate", (void **) &dJointGetPistonPositionRate},
1311 // {"dJointGetPistonAngle", (void **) &dJointGetPistonAngle},
1312 // {"dJointGetPistonAngleRate", (void **) &dJointGetPistonAngleRate},
1313 // {"dJointGetPistonAnchor", (void **) &dJointGetPistonAnchor},
1314 // {"dJointGetPistonAnchor2", (void **) &dJointGetPistonAnchor2},
1315 // {"dJointGetPistonAxis", (void **) &dJointGetPistonAxis},
1316 // {"dJointGetPistonParam", (void **) &dJointGetPistonParam},
1317 // {"dJointGetAMotorNumAxes", (void **) &dJointGetAMotorNumAxes},
1318 // {"dJointGetAMotorAxis", (void **) &dJointGetAMotorAxis},
1319 // {"dJointGetAMotorAxisRel", (void **) &dJointGetAMotorAxisRel},
1320 // {"dJointGetAMotorAngle", (void **) &dJointGetAMotorAngle},
1321 // {"dJointGetAMotorAngleRate", (void **) &dJointGetAMotorAngleRate},
1322 // {"dJointGetAMotorParam", (void **) &dJointGetAMotorParam},
1323 // {"dJointGetAMotorMode", (void **) &dJointGetAMotorMode},
1324 // {"dJointGetLMotorNumAxes", (void **) &dJointGetLMotorNumAxes},
1325 // {"dJointGetLMotorAxis", (void **) &dJointGetLMotorAxis},
1326 // {"dJointGetLMotorParam", (void **) &dJointGetLMotorParam},
1327 // {"dJointGetFixedParam", (void **) &dJointGetFixedParam},
1328 // {"dConnectingJoint", (void **) &dConnectingJoint},
1329 // {"dConnectingJointList", (void **) &dConnectingJointList},
1330 {"dAreConnected", (void **) &dAreConnected},
1331 {"dAreConnectedExcluding", (void **) &dAreConnectedExcluding},
1332 {"dSimpleSpaceCreate", (void **) &dSimpleSpaceCreate},
1333 {"dHashSpaceCreate", (void **) &dHashSpaceCreate},
1334 {"dQuadTreeSpaceCreate", (void **) &dQuadTreeSpaceCreate},
1335 // {"dSweepAndPruneSpaceCreate", (void **) &dSweepAndPruneSpaceCreate},
1336 {"dSpaceDestroy", (void **) &dSpaceDestroy},
1337 // {"dHashSpaceSetLevels", (void **) &dHashSpaceSetLevels},
1338 // {"dHashSpaceGetLevels", (void **) &dHashSpaceGetLevels},
1339 // {"dSpaceSetCleanup", (void **) &dSpaceSetCleanup},
1340 // {"dSpaceGetCleanup", (void **) &dSpaceGetCleanup},
1341 // {"dSpaceSetSublevel", (void **) &dSpaceSetSublevel},
1342 // {"dSpaceGetSublevel", (void **) &dSpaceGetSublevel},
1343 // {"dSpaceSetManualCleanup", (void **) &dSpaceSetManualCleanup},
1344 // {"dSpaceGetManualCleanup", (void **) &dSpaceGetManualCleanup},
1345 // {"dSpaceAdd", (void **) &dSpaceAdd},
1346 // {"dSpaceRemove", (void **) &dSpaceRemove},
1347 // {"dSpaceQuery", (void **) &dSpaceQuery},
1348 // {"dSpaceClean", (void **) &dSpaceClean},
1349 // {"dSpaceGetNumGeoms", (void **) &dSpaceGetNumGeoms},
1350 // {"dSpaceGetGeom", (void **) &dSpaceGetGeom},
1351 // {"dSpaceGetClass", (void **) &dSpaceGetClass},
1352 {"dGeomDestroy", (void **) &dGeomDestroy},
1353 {"dGeomSetData", (void **) &dGeomSetData},
1354 {"dGeomGetData", (void **) &dGeomGetData},
1355 {"dGeomSetBody", (void **) &dGeomSetBody},
1356 {"dGeomGetBody", (void **) &dGeomGetBody},
1357 {"dGeomSetPosition", (void **) &dGeomSetPosition},
1358 {"dGeomSetRotation", (void **) &dGeomSetRotation},
1359 // {"dGeomSetQuaternion", (void **) &dGeomSetQuaternion},
1360 // {"dGeomGetPosition", (void **) &dGeomGetPosition},
1361 // {"dGeomCopyPosition", (void **) &dGeomCopyPosition},
1362 // {"dGeomGetRotation", (void **) &dGeomGetRotation},
1363 // {"dGeomCopyRotation", (void **) &dGeomCopyRotation},
1364 // {"dGeomGetQuaternion", (void **) &dGeomGetQuaternion},
1365 // {"dGeomGetAABB", (void **) &dGeomGetAABB},
1366 {"dGeomIsSpace", (void **) &dGeomIsSpace},
1367 // {"dGeomGetSpace", (void **) &dGeomGetSpace},
1368 // {"dGeomGetClass", (void **) &dGeomGetClass},
1369 // {"dGeomSetCategoryBits", (void **) &dGeomSetCategoryBits},
1370 // {"dGeomSetCollideBits", (void **) &dGeomSetCollideBits},
1371 // {"dGeomGetCategoryBits", (void **) &dGeomGetCategoryBits},
1372 // {"dGeomGetCollideBits", (void **) &dGeomGetCollideBits},
1373 // {"dGeomEnable", (void **) &dGeomEnable},
1374 // {"dGeomDisable", (void **) &dGeomDisable},
1375 // {"dGeomIsEnabled", (void **) &dGeomIsEnabled},
1376 // {"dGeomSetOffsetPosition", (void **) &dGeomSetOffsetPosition},
1377 // {"dGeomSetOffsetRotation", (void **) &dGeomSetOffsetRotation},
1378 // {"dGeomSetOffsetQuaternion", (void **) &dGeomSetOffsetQuaternion},
1379 // {"dGeomSetOffsetWorldPosition", (void **) &dGeomSetOffsetWorldPosition},
1380 // {"dGeomSetOffsetWorldRotation", (void **) &dGeomSetOffsetWorldRotation},
1381 // {"dGeomSetOffsetWorldQuaternion", (void **) &dGeomSetOffsetWorldQuaternion},
1382 // {"dGeomClearOffset", (void **) &dGeomClearOffset},
1383 // {"dGeomIsOffset", (void **) &dGeomIsOffset},
1384 // {"dGeomGetOffsetPosition", (void **) &dGeomGetOffsetPosition},
1385 // {"dGeomCopyOffsetPosition", (void **) &dGeomCopyOffsetPosition},
1386 // {"dGeomGetOffsetRotation", (void **) &dGeomGetOffsetRotation},
1387 // {"dGeomCopyOffsetRotation", (void **) &dGeomCopyOffsetRotation},
1388 // {"dGeomGetOffsetQuaternion", (void **) &dGeomGetOffsetQuaternion},
1389 {"dCollide", (void **) &dCollide},
1390 {"dSpaceCollide", (void **) &dSpaceCollide},
1391 {"dSpaceCollide2", (void **) &dSpaceCollide2},
1392 {"dCreateSphere", (void **) &dCreateSphere},
1393 // {"dGeomSphereSetRadius", (void **) &dGeomSphereSetRadius},
1394 // {"dGeomSphereGetRadius", (void **) &dGeomSphereGetRadius},
1395 // {"dGeomSpherePointDepth", (void **) &dGeomSpherePointDepth},
1396 // {"dCreateConvex", (void **) &dCreateConvex},
1397 // {"dGeomSetConvex", (void **) &dGeomSetConvex},
1398 {"dCreateBox", (void **) &dCreateBox},
1399 // {"dGeomBoxSetLengths", (void **) &dGeomBoxSetLengths},
1400 // {"dGeomBoxGetLengths", (void **) &dGeomBoxGetLengths},
1401 // {"dGeomBoxPointDepth", (void **) &dGeomBoxPointDepth},
1402 // {"dGeomBoxPointDepth", (void **) &dGeomBoxPointDepth},
1403 // {"dCreatePlane", (void **) &dCreatePlane},
1404 // {"dGeomPlaneSetParams", (void **) &dGeomPlaneSetParams},
1405 // {"dGeomPlaneGetParams", (void **) &dGeomPlaneGetParams},
1406 // {"dGeomPlanePointDepth", (void **) &dGeomPlanePointDepth},
1407 {"dCreateCapsule", (void **) &dCreateCapsule},
1408 // {"dGeomCapsuleSetParams", (void **) &dGeomCapsuleSetParams},
1409 // {"dGeomCapsuleGetParams", (void **) &dGeomCapsuleGetParams},
1410 // {"dGeomCapsulePointDepth", (void **) &dGeomCapsulePointDepth},
1411 // {"dCreateCylinder", (void **) &dCreateCylinder},
1412 // {"dGeomCylinderSetParams", (void **) &dGeomCylinderSetParams},
1413 // {"dGeomCylinderGetParams", (void **) &dGeomCylinderGetParams},
1414 // {"dCreateRay", (void **) &dCreateRay},
1415 // {"dGeomRaySetLength", (void **) &dGeomRaySetLength},
1416 // {"dGeomRayGetLength", (void **) &dGeomRayGetLength},
1417 // {"dGeomRaySet", (void **) &dGeomRaySet},
1418 // {"dGeomRayGet", (void **) &dGeomRayGet},
1419 {"dCreateGeomTransform", (void **) &dCreateGeomTransform},
1420 {"dGeomTransformSetGeom", (void **) &dGeomTransformSetGeom},
1421 // {"dGeomTransformGetGeom", (void **) &dGeomTransformGetGeom},
1422 {"dGeomTransformSetCleanup", (void **) &dGeomTransformSetCleanup},
1423 // {"dGeomTransformGetCleanup", (void **) &dGeomTransformGetCleanup},
1424 // {"dGeomTransformSetInfo", (void **) &dGeomTransformSetInfo},
1425 // {"dGeomTransformGetInfo", (void **) &dGeomTransformGetInfo},
1426 {"dGeomTriMeshDataCreate", (void **) &dGeomTriMeshDataCreate},
1427 {"dGeomTriMeshDataDestroy", (void **) &dGeomTriMeshDataDestroy},
1428 // {"dGeomTriMeshDataSet", (void **) &dGeomTriMeshDataSet},
1429 // {"dGeomTriMeshDataGet", (void **) &dGeomTriMeshDataGet},
1430 // {"dGeomTriMeshSetLastTransform", (void **) &dGeomTriMeshSetLastTransform},
1431 // {"dGeomTriMeshGetLastTransform", (void **) &dGeomTriMeshGetLastTransform},
1432 {"dGeomTriMeshDataBuildSingle", (void **) &dGeomTriMeshDataBuildSingle},
1433 // {"dGeomTriMeshDataBuildSingle1", (void **) &dGeomTriMeshDataBuildSingle1},
1434 // {"dGeomTriMeshDataBuildDouble", (void **) &dGeomTriMeshDataBuildDouble},
1435 // {"dGeomTriMeshDataBuildDouble1", (void **) &dGeomTriMeshDataBuildDouble1},
1436 // {"dGeomTriMeshDataBuildSimple", (void **) &dGeomTriMeshDataBuildSimple},
1437 // {"dGeomTriMeshDataBuildSimple1", (void **) &dGeomTriMeshDataBuildSimple1},
1438 // {"dGeomTriMeshDataPreprocess", (void **) &dGeomTriMeshDataPreprocess},
1439 // {"dGeomTriMeshDataGetBuffer", (void **) &dGeomTriMeshDataGetBuffer},
1440 // {"dGeomTriMeshDataSetBuffer", (void **) &dGeomTriMeshDataSetBuffer},
1441 // {"dGeomTriMeshSetCallback", (void **) &dGeomTriMeshSetCallback},
1442 // {"dGeomTriMeshGetCallback", (void **) &dGeomTriMeshGetCallback},
1443 // {"dGeomTriMeshSetArrayCallback", (void **) &dGeomTriMeshSetArrayCallback},
1444 // {"dGeomTriMeshGetArrayCallback", (void **) &dGeomTriMeshGetArrayCallback},
1445 // {"dGeomTriMeshSetRayCallback", (void **) &dGeomTriMeshSetRayCallback},
1446 // {"dGeomTriMeshGetRayCallback", (void **) &dGeomTriMeshGetRayCallback},
1447 // {"dGeomTriMeshSetTriMergeCallback", (void **) &dGeomTriMeshSetTriMergeCallback},
1448 // {"dGeomTriMeshGetTriMergeCallback", (void **) &dGeomTriMeshGetTriMergeCallback},
1449 {"dCreateTriMesh", (void **) &dCreateTriMesh},
1450 // {"dGeomTriMeshSetData", (void **) &dGeomTriMeshSetData},
1451 // {"dGeomTriMeshGetData", (void **) &dGeomTriMeshGetData},
1452 // {"dGeomTriMeshEnableTC", (void **) &dGeomTriMeshEnableTC},
1453 // {"dGeomTriMeshIsTCEnabled", (void **) &dGeomTriMeshIsTCEnabled},
1454 // {"dGeomTriMeshClearTCCache", (void **) &dGeomTriMeshClearTCCache},
1455 // {"dGeomTriMeshGetTriMeshDataID", (void **) &dGeomTriMeshGetTriMeshDataID},
1456 // {"dGeomTriMeshGetTriangle", (void **) &dGeomTriMeshGetTriangle},
1457 // {"dGeomTriMeshGetPoint", (void **) &dGeomTriMeshGetPoint},
1458 // {"dGeomTriMeshGetTriangleCount", (void **) &dGeomTriMeshGetTriangleCount},
1459 // {"dGeomTriMeshDataUpdate", (void **) &dGeomTriMeshDataUpdate},
1463 // Handle for ODE DLL
1464 dllhandle_t ode_dll = NULL;
1468 static void World_Physics_Init(void)
1472 const char* dllnames [] =
1476 # elif defined(MACOSX)
1485 Cvar_RegisterVariable(&physics_ode_quadtree_depth);
1486 Cvar_RegisterVariable(&physics_ode_contactsurfacelayer);
1487 Cvar_RegisterVariable(&physics_ode_worldstep);
1488 Cvar_RegisterVariable(&physics_ode_worldstep_iterations);
1489 Cvar_RegisterVariable(&physics_ode_contact_mu);
1490 Cvar_RegisterVariable(&physics_ode_contact_erp);
1491 Cvar_RegisterVariable(&physics_ode_contact_cfm);
1492 Cvar_RegisterVariable(&physics_ode_world_erp);
1493 Cvar_RegisterVariable(&physics_ode_world_cfm);
1494 Cvar_RegisterVariable(&physics_ode_world_damping);
1495 Cvar_RegisterVariable(&physics_ode_world_damping_linear);
1496 Cvar_RegisterVariable(&physics_ode_world_damping_linear_threshold);
1497 Cvar_RegisterVariable(&physics_ode_world_damping_angular);
1498 Cvar_RegisterVariable(&physics_ode_world_damping_angular_threshold);
1499 Cvar_RegisterVariable(&physics_ode_world_gravitymod);
1500 Cvar_RegisterVariable(&physics_ode_iterationsperframe);
1501 Cvar_RegisterVariable(&physics_ode_constantstep);
1502 Cvar_RegisterVariable(&physics_ode_movelimit);
1503 Cvar_RegisterVariable(&physics_ode_spinlimit);
1504 Cvar_RegisterVariable(&physics_ode_trick_fixnan);
1505 Cvar_RegisterVariable(&physics_ode_autodisable);
1506 Cvar_RegisterVariable(&physics_ode_autodisable_steps);
1507 Cvar_RegisterVariable(&physics_ode_autodisable_time);
1508 Cvar_RegisterVariable(&physics_ode_autodisable_threshold_linear);
1509 Cvar_RegisterVariable(&physics_ode_autodisable_threshold_angular);
1510 Cvar_RegisterVariable(&physics_ode_autodisable_threshold_samples);
1511 Cvar_RegisterVariable(&physics_ode_printstats);
1512 Cvar_RegisterVariable(&physics_ode);
1516 if (Sys_LoadLibrary (dllnames, &ode_dll, odefuncs))
1523 if (!dCheckConfiguration("ODE_single_precision"))
1525 if (!dCheckConfiguration("ODE_double_precision"))
1529 Con_Printf("ODE library not compiled for single precision - incompatible! Not using ODE physics.\n");
1531 Con_Printf("ODE library not compiled for double precision - incompatible! Not using ODE physics.\n");
1533 Sys_UnloadLibrary(&ode_dll);
1539 Con_Printf("ODE library loaded with single precision.\n");
1541 Con_Printf("ODE library loaded with double precision.\n");
1549 static void World_Physics_Shutdown(void)
1558 Sys_UnloadLibrary(&ode_dll);
1566 static void World_Physics_UpdateODE(world_t *world)
1570 odeworld = (dWorldID)world->physics.ode_world;
1573 if (physics_ode_world_erp.value >= 0)
1574 dWorldSetERP(odeworld, physics_ode_world_erp.value);
1575 if (physics_ode_world_cfm.value >= 0)
1576 dWorldSetCFM(odeworld, physics_ode_world_cfm.value);
1578 if (physics_ode_world_damping.integer)
1580 dWorldSetLinearDamping(odeworld, (physics_ode_world_damping_linear.value >= 0) ? (physics_ode_world_damping_linear.value * physics_ode_world_damping.value) : 0);
1581 dWorldSetLinearDampingThreshold(odeworld, (physics_ode_world_damping_linear_threshold.value >= 0) ? (physics_ode_world_damping_linear_threshold.value * physics_ode_world_damping.value) : 0);
1582 dWorldSetAngularDamping(odeworld, (physics_ode_world_damping_angular.value >= 0) ? (physics_ode_world_damping_angular.value * physics_ode_world_damping.value) : 0);
1583 dWorldSetAngularDampingThreshold(odeworld, (physics_ode_world_damping_angular_threshold.value >= 0) ? (physics_ode_world_damping_angular_threshold.value * physics_ode_world_damping.value) : 0);
1587 dWorldSetLinearDamping(odeworld, 0);
1588 dWorldSetLinearDampingThreshold(odeworld, 0);
1589 dWorldSetAngularDamping(odeworld, 0);
1590 dWorldSetAngularDampingThreshold(odeworld, 0);
1593 dWorldSetAutoDisableFlag(odeworld, (physics_ode_autodisable.integer) ? 1 : 0);
1594 if (physics_ode_autodisable.integer)
1596 dWorldSetAutoDisableSteps(odeworld, bound(1, physics_ode_autodisable_steps.integer, 100));
1597 dWorldSetAutoDisableTime(odeworld, physics_ode_autodisable_time.value);
1598 dWorldSetAutoDisableAverageSamplesCount(odeworld, bound(1, physics_ode_autodisable_threshold_samples.integer, 100));
1599 dWorldSetAutoDisableLinearThreshold(odeworld, physics_ode_autodisable_threshold_linear.value);
1600 dWorldSetAutoDisableAngularThreshold(odeworld, physics_ode_autodisable_threshold_angular.value);
1604 static void World_Physics_EnableODE(world_t *world)
1606 dVector3 center, extents;
1607 if (world->physics.ode)
1613 world->physics.ode = true;
1614 VectorMAM(0.5f, world->mins, 0.5f, world->maxs, center);
1615 VectorSubtract(world->maxs, center, extents);
1616 world->physics.ode_world = dWorldCreate();
1617 world->physics.ode_space = dQuadTreeSpaceCreate(NULL, center, extents, bound(1, physics_ode_quadtree_depth.integer, 10));
1618 world->physics.ode_contactgroup = dJointGroupCreate(0);
1620 World_Physics_UpdateODE(world);
1624 static void World_Physics_Start(world_t *world)
1627 if (world->physics.ode)
1629 World_Physics_EnableODE(world);
1633 static void World_Physics_End(world_t *world)
1636 if (world->physics.ode)
1638 dWorldDestroy((dWorldID)world->physics.ode_world);
1639 dSpaceDestroy((dSpaceID)world->physics.ode_space);
1640 dJointGroupDestroy((dJointGroupID)world->physics.ode_contactgroup);
1641 world->physics.ode = false;
1646 void World_Physics_RemoveJointFromEntity(world_t *world, prvm_edict_t *ed)
1648 ed->priv.server->ode_joint_type = 0;
1650 if(ed->priv.server->ode_joint)
1651 dJointDestroy((dJointID)ed->priv.server->ode_joint);
1652 ed->priv.server->ode_joint = NULL;
1656 void World_Physics_RemoveFromEntity(world_t *world, prvm_edict_t *ed)
1658 edict_odefunc_t *f, *nf;
1660 // entity is not physics controlled, free any physics data
1661 ed->priv.server->ode_physics = false;
1663 if (ed->priv.server->ode_geom)
1664 dGeomDestroy((dGeomID)ed->priv.server->ode_geom);
1665 ed->priv.server->ode_geom = NULL;
1666 if (ed->priv.server->ode_body)
1671 while(dBodyGetNumJoints((dBodyID)ed->priv.server->ode_body))
1673 j = dBodyGetJoint((dBodyID)ed->priv.server->ode_body, 0);
1674 ed2 = (prvm_edict_t *) dJointGetData(j);
1675 b1 = dJointGetBody(j, 0);
1676 b2 = dJointGetBody(j, 1);
1677 if(b1 == (dBodyID)ed->priv.server->ode_body)
1680 ed2->priv.server->ode_joint_enemy = 0;
1682 if(b2 == (dBodyID)ed->priv.server->ode_body)
1685 ed2->priv.server->ode_joint_aiment = 0;
1687 dJointAttach(j, b1, b2);
1689 dBodyDestroy((dBodyID)ed->priv.server->ode_body);
1691 ed->priv.server->ode_body = NULL;
1693 if (ed->priv.server->ode_vertex3f)
1694 Mem_Free(ed->priv.server->ode_vertex3f);
1695 ed->priv.server->ode_vertex3f = NULL;
1696 ed->priv.server->ode_numvertices = 0;
1697 if (ed->priv.server->ode_element3i)
1698 Mem_Free(ed->priv.server->ode_element3i);
1699 ed->priv.server->ode_element3i = NULL;
1700 ed->priv.server->ode_numtriangles = 0;
1701 if(ed->priv.server->ode_massbuf)
1702 Mem_Free(ed->priv.server->ode_massbuf);
1703 ed->priv.server->ode_massbuf = NULL;
1704 // clear functions stack
1705 for(f = ed->priv.server->ode_func; f; f = nf)
1710 ed->priv.server->ode_func = NULL;
1713 void World_Physics_ApplyCmd(prvm_edict_t *ed, edict_odefunc_t *f)
1715 dBodyID body = (dBodyID)ed->priv.server->ode_body;
1720 case ODEFUNC_ENABLE:
1723 case ODEFUNC_DISABLE:
1726 case ODEFUNC_RELFORCEATPOS:
1728 dBodyAddForceAtRelPos(body, f->v1[0], f->v1[1], f->v1[2], f->v2[0], f->v2[1], f->v2[2]);
1730 case ODEFUNC_RELTORQUE:
1732 dBodyAddRelTorque(body, f->v1[0], f->v1[1], f->v1[2]);
1741 static void World_Physics_Frame_BodyToEntity(world_t *world, prvm_edict_t *ed)
1745 const dReal *r; // for some reason dBodyGetRotation returns a [3][4] matrix
1747 dBodyID body = (dBodyID)ed->priv.server->ode_body;
1749 matrix4x4_t bodymatrix;
1750 matrix4x4_t entitymatrix;
1753 vec3_t forward, left, up;
1755 vec3_t spinvelocity;
1760 movetype = (int)PRVM_gameedictfloat(ed, movetype);
1761 if (movetype != MOVETYPE_PHYSICS)
1763 jointtype = (int)PRVM_gameedictfloat(ed, jointtype);
1766 // TODO feed back data from physics
1767 case JOINTTYPE_POINT:
1769 case JOINTTYPE_HINGE:
1771 case JOINTTYPE_SLIDER:
1773 case JOINTTYPE_UNIVERSAL:
1775 case JOINTTYPE_HINGE2:
1777 case JOINTTYPE_FIXED:
1782 // store the physics engine data into the entity
1783 o = dBodyGetPosition(body);
1784 r = dBodyGetRotation(body);
1785 vel = dBodyGetLinearVel(body);
1786 avel = dBodyGetAngularVel(body);
1787 VectorCopy(o, origin);
1797 VectorCopy(vel, velocity);
1798 VectorCopy(avel, spinvelocity);
1799 Matrix4x4_FromVectors(&bodymatrix, forward, left, up, origin);
1800 Matrix4x4_Concat(&entitymatrix, &bodymatrix, &ed->priv.server->ode_offsetimatrix);
1801 Matrix4x4_ToVectors(&entitymatrix, forward, left, up, origin);
1803 AnglesFromVectors(angles, forward, up, false);
1804 VectorSet(avelocity, RAD2DEG(spinvelocity[PITCH]), RAD2DEG(spinvelocity[ROLL]), RAD2DEG(spinvelocity[YAW]));
1807 float pitchsign = 1;
1808 if(!strcmp(prog->name, "server")) // FIXME some better way?
1810 pitchsign = SV_GetPitchSign(ed);
1812 else if(!strcmp(prog->name, "client"))
1814 pitchsign = CL_GetPitchSign(ed);
1816 angles[PITCH] *= pitchsign;
1817 avelocity[PITCH] *= pitchsign;
1820 VectorCopy(origin, PRVM_gameedictvector(ed, origin));
1821 VectorCopy(velocity, PRVM_gameedictvector(ed, velocity));
1822 //VectorCopy(forward, PRVM_gameedictvector(ed, axis_forward));
1823 //VectorCopy(left, PRVM_gameedictvector(ed, axis_left));
1824 //VectorCopy(up, PRVM_gameedictvector(ed, axis_up));
1825 //VectorCopy(spinvelocity, PRVM_gameedictvector(ed, spinvelocity));
1826 VectorCopy(angles, PRVM_gameedictvector(ed, angles));
1827 VectorCopy(avelocity, PRVM_gameedictvector(ed, avelocity));
1829 // values for BodyFromEntity to check if the qc modified anything later
1830 VectorCopy(origin, ed->priv.server->ode_origin);
1831 VectorCopy(velocity, ed->priv.server->ode_velocity);
1832 VectorCopy(angles, ed->priv.server->ode_angles);
1833 VectorCopy(avelocity, ed->priv.server->ode_avelocity);
1834 ed->priv.server->ode_gravity = dBodyGetGravityMode(body) != 0;
1836 if(!strcmp(prog->name, "server")) // FIXME some better way?
1839 SV_LinkEdict_TouchAreaGrid(ed);
1843 static void World_Physics_Frame_JointFromEntity(world_t *world, prvm_edict_t *ed)
1850 int enemy = 0, aiment = 0;
1851 vec3_t origin, velocity, angles, forward, left, up, movedir;
1852 vec_t CFM, ERP, FMax, Stop, Vel;
1853 VectorClear(origin);
1854 VectorClear(velocity);
1855 VectorClear(angles);
1856 VectorClear(movedir);
1857 movetype = (int)PRVM_gameedictfloat(ed, movetype);
1858 jointtype = (int)PRVM_gameedictfloat(ed, jointtype);
1859 enemy = PRVM_gameedictedict(ed, enemy);
1860 aiment = PRVM_gameedictedict(ed, aiment);
1861 VectorCopy(PRVM_gameedictvector(ed, origin), origin);
1862 VectorCopy(PRVM_gameedictvector(ed, velocity), velocity);
1863 VectorCopy(PRVM_gameedictvector(ed, angles), angles);
1864 VectorCopy(PRVM_gameedictvector(ed, movedir), movedir);
1865 if(movetype == MOVETYPE_PHYSICS)
1866 jointtype = 0; // can't have both
1867 if(enemy <= 0 || enemy >= prog->num_edicts || prog->edicts[enemy].priv.required->free || prog->edicts[enemy].priv.server->ode_body == 0)
1869 if(aiment <= 0 || aiment >= prog->num_edicts || prog->edicts[aiment].priv.required->free || prog->edicts[aiment].priv.server->ode_body == 0)
1871 // see http://www.ode.org/old_list_archives/2006-January/017614.html
1872 // we want to set ERP? make it fps independent and work like a spring constant
1873 // note: if movedir[2] is 0, it becomes ERP = 1, CFM = 1.0 / (H * K)
1874 if(movedir[0] > 0 && movedir[1] > 0)
1876 float K = movedir[0];
1877 float D = movedir[1];
1878 float R = 2.0 * D * sqrt(K); // we assume D is premultiplied by sqrt(sprungMass)
1879 CFM = 1.0 / (world->physics.ode_step * K + R); // always > 0
1880 ERP = world->physics.ode_step * K * CFM;
1885 else if(movedir[1] < 0)
1890 FMax = -movedir[1]; // TODO do we need to multiply with world.physics.ode_step?
1891 Stop = movedir[2] > 0 ? movedir[2] : dInfinity;
1893 else // movedir[0] > 0, movedir[1] == 0 or movedir[0] < 0, movedir[1] >= 0
1901 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 && VectorCompare(movedir, ed->priv.server->ode_joint_movedir))
1902 return; // nothing to do
1903 AngleVectorsFLU(angles, forward, left, up);
1906 case JOINTTYPE_POINT:
1907 j = dJointCreateBall((dWorldID)world->physics.ode_world, 0);
1909 case JOINTTYPE_HINGE:
1910 j = dJointCreateHinge((dWorldID)world->physics.ode_world, 0);
1912 case JOINTTYPE_SLIDER:
1913 j = dJointCreateSlider((dWorldID)world->physics.ode_world, 0);
1915 case JOINTTYPE_UNIVERSAL:
1916 j = dJointCreateUniversal((dWorldID)world->physics.ode_world, 0);
1918 case JOINTTYPE_HINGE2:
1919 j = dJointCreateHinge2((dWorldID)world->physics.ode_world, 0);
1921 case JOINTTYPE_FIXED:
1922 j = dJointCreateFixed((dWorldID)world->physics.ode_world, 0);
1930 if(ed->priv.server->ode_joint)
1932 //Con_Printf("deleted old joint %i\n", (int) (ed - prog->edicts));
1933 dJointAttach((dJointID)ed->priv.server->ode_joint, 0, 0);
1934 dJointDestroy((dJointID)ed->priv.server->ode_joint);
1936 ed->priv.server->ode_joint = (void *) j;
1937 ed->priv.server->ode_joint_type = jointtype;
1938 ed->priv.server->ode_joint_enemy = enemy;
1939 ed->priv.server->ode_joint_aiment = aiment;
1940 VectorCopy(origin, ed->priv.server->ode_joint_origin);
1941 VectorCopy(velocity, ed->priv.server->ode_joint_velocity);
1942 VectorCopy(angles, ed->priv.server->ode_joint_angles);
1943 VectorCopy(movedir, ed->priv.server->ode_joint_movedir);
1946 //Con_Printf("made new joint %i\n", (int) (ed - prog->edicts));
1947 dJointSetData(j, (void *) ed);
1949 b1 = (dBodyID)prog->edicts[enemy].priv.server->ode_body;
1951 b2 = (dBodyID)prog->edicts[aiment].priv.server->ode_body;
1952 dJointAttach(j, b1, b2);
1956 case JOINTTYPE_POINT:
1957 dJointSetBallAnchor(j, origin[0], origin[1], origin[2]);
1959 case JOINTTYPE_HINGE:
1960 dJointSetHingeAnchor(j, origin[0], origin[1], origin[2]);
1961 dJointSetHingeAxis(j, forward[0], forward[1], forward[2]);
1962 dJointSetHingeParam(j, dParamFMax, FMax);
1963 dJointSetHingeParam(j, dParamHiStop, Stop);
1964 dJointSetHingeParam(j, dParamLoStop, -Stop);
1965 dJointSetHingeParam(j, dParamStopCFM, CFM);
1966 dJointSetHingeParam(j, dParamStopERP, ERP);
1967 dJointSetHingeParam(j, dParamVel, Vel);
1969 case JOINTTYPE_SLIDER:
1970 dJointSetSliderAxis(j, forward[0], forward[1], forward[2]);
1971 dJointSetSliderParam(j, dParamFMax, FMax);
1972 dJointSetSliderParam(j, dParamHiStop, Stop);
1973 dJointSetSliderParam(j, dParamLoStop, -Stop);
1974 dJointSetSliderParam(j, dParamStopCFM, CFM);
1975 dJointSetSliderParam(j, dParamStopERP, ERP);
1976 dJointSetSliderParam(j, dParamVel, Vel);
1978 case JOINTTYPE_UNIVERSAL:
1979 dJointSetUniversalAnchor(j, origin[0], origin[1], origin[2]);
1980 dJointSetUniversalAxis1(j, forward[0], forward[1], forward[2]);
1981 dJointSetUniversalAxis2(j, up[0], up[1], up[2]);
1982 dJointSetUniversalParam(j, dParamFMax, FMax);
1983 dJointSetUniversalParam(j, dParamHiStop, Stop);
1984 dJointSetUniversalParam(j, dParamLoStop, -Stop);
1985 dJointSetUniversalParam(j, dParamStopCFM, CFM);
1986 dJointSetUniversalParam(j, dParamStopERP, ERP);
1987 dJointSetUniversalParam(j, dParamVel, Vel);
1988 dJointSetUniversalParam(j, dParamFMax2, FMax);
1989 dJointSetUniversalParam(j, dParamHiStop2, Stop);
1990 dJointSetUniversalParam(j, dParamLoStop2, -Stop);
1991 dJointSetUniversalParam(j, dParamStopCFM2, CFM);
1992 dJointSetUniversalParam(j, dParamStopERP2, ERP);
1993 dJointSetUniversalParam(j, dParamVel2, Vel);
1995 case JOINTTYPE_HINGE2:
1996 dJointSetHinge2Anchor(j, origin[0], origin[1], origin[2]);
1997 dJointSetHinge2Axis1(j, forward[0], forward[1], forward[2]);
1998 dJointSetHinge2Axis2(j, velocity[0], velocity[1], velocity[2]);
1999 dJointSetHinge2Param(j, dParamFMax, FMax);
2000 dJointSetHinge2Param(j, dParamHiStop, Stop);
2001 dJointSetHinge2Param(j, dParamLoStop, -Stop);
2002 dJointSetHinge2Param(j, dParamStopCFM, CFM);
2003 dJointSetHinge2Param(j, dParamStopERP, ERP);
2004 dJointSetHinge2Param(j, dParamVel, Vel);
2005 dJointSetHinge2Param(j, dParamFMax2, FMax);
2006 dJointSetHinge2Param(j, dParamHiStop2, Stop);
2007 dJointSetHinge2Param(j, dParamLoStop2, -Stop);
2008 dJointSetHinge2Param(j, dParamStopCFM2, CFM);
2009 dJointSetHinge2Param(j, dParamStopERP2, ERP);
2010 dJointSetHinge2Param(j, dParamVel2, Vel);
2012 case JOINTTYPE_FIXED:
2016 Sys_Error("what? but above the joint was valid...\n");
2024 static void World_Physics_Frame_BodyFromEntity(world_t *world, prvm_edict_t *ed)
2028 dBodyID body = (dBodyID)ed->priv.server->ode_body;
2031 const dReal *ovelocity, *ospinvelocity;
2033 dVector3 capsulerot[3];
2039 int movetype = MOVETYPE_NONE;
2042 int solid = SOLID_NOT;
2046 qboolean modified = false;
2056 vec3_t spinvelocity;
2061 vec_t massval = 1.0f;
2067 edict_odefunc_t *func, *nextf;
2073 VectorClear(entmins);
2074 VectorClear(entmaxs);
2075 solid = (int)PRVM_gameedictfloat(ed, solid);
2076 movetype = (int)PRVM_gameedictfloat(ed, movetype);
2077 scale = PRVM_gameedictfloat(ed, scale);if (!scale) scale = 1.0f;
2079 if (world == &sv.world)
2080 mempool = sv_mempool;
2081 else if (world == &cl.world)
2082 mempool = cls.levelmempool;
2089 case SOLID_PHYSICS_TRIMESH:
2090 modelindex = (int)PRVM_gameedictfloat(ed, modelindex);
2091 if (world == &sv.world)
2092 model = SV_GetModelByIndex(modelindex);
2093 else if (world == &cl.world)
2094 model = CL_GetModelByIndex(modelindex);
2099 VectorScale(model->normalmins, scale, entmins);
2100 VectorScale(model->normalmaxs, scale, entmaxs);
2101 massval = PRVM_gameedictfloat(ed, mass);
2110 //case SOLID_SLIDEBOX:
2112 case SOLID_PHYSICS_BOX:
2113 case SOLID_PHYSICS_SPHERE:
2114 case SOLID_PHYSICS_CAPSULE:
2115 VectorCopy(PRVM_gameedictvector(ed, mins), entmins);
2116 VectorCopy(PRVM_gameedictvector(ed, maxs), entmaxs);
2117 massval = PRVM_gameedictfloat(ed, mass);
2120 if (ed->priv.server->ode_physics)
2121 World_Physics_RemoveFromEntity(world, ed);
2125 VectorSubtract(entmaxs, entmins, geomsize);
2126 if (VectorLength2(geomsize) == 0)
2128 // we don't allow point-size physics objects...
2129 if (ed->priv.server->ode_physics)
2130 World_Physics_RemoveFromEntity(world, ed);
2134 if (movetype != MOVETYPE_PHYSICS)
2137 // check if we need to create or replace the geom
2138 if (!ed->priv.server->ode_physics
2139 || !VectorCompare(ed->priv.server->ode_mins, entmins)
2140 || !VectorCompare(ed->priv.server->ode_maxs, entmaxs)
2141 || ed->priv.server->ode_mass != massval
2142 || ed->priv.server->ode_modelindex != modelindex)
2145 World_Physics_RemoveFromEntity(world, ed);
2146 ed->priv.server->ode_physics = true;
2147 VectorCopy(entmins, ed->priv.server->ode_mins);
2148 VectorCopy(entmaxs, ed->priv.server->ode_maxs);
2149 ed->priv.server->ode_mass = massval;
2150 ed->priv.server->ode_modelindex = modelindex;
2151 VectorMAM(0.5f, entmins, 0.5f, entmaxs, geomcenter);
2152 ed->priv.server->ode_movelimit = min(geomsize[0], min(geomsize[1], geomsize[2]));
2154 if (massval * geomsize[0] * geomsize[1] * geomsize[2] == 0)
2156 if (movetype == MOVETYPE_PHYSICS)
2157 Con_Printf("entity %i (classname %s) .mass * .size_x * .size_y * .size_z == 0\n", PRVM_NUM_FOR_EDICT(ed), PRVM_GetString(PRVM_gameedictstring(ed, classname)));
2159 VectorSet(geomsize, 1.0f, 1.0f, 1.0f);
2165 case SOLID_PHYSICS_TRIMESH:
2166 ed->priv.server->ode_offsetmatrix = identitymatrix;
2169 Con_Printf("entity %i (classname %s) has no model\n", PRVM_NUM_FOR_EDICT(ed), PRVM_GetString(PRVM_gameedictstring(ed, classname)));
2172 // add an optimized mesh to the model containing only the SUPERCONTENTS_SOLID surfaces
2173 if (!model->brush.collisionmesh)
2174 Mod_CreateCollisionMesh(model);
2175 if (!model->brush.collisionmesh || !model->brush.collisionmesh->numtriangles)
2177 Con_Printf("entity %i (classname %s) has no geometry\n", PRVM_NUM_FOR_EDICT(ed), PRVM_GetString(PRVM_gameedictstring(ed, classname)));
2180 // ODE requires persistent mesh storage, so we need to copy out
2181 // the data from the model because renderer restarts could free it
2182 // during the game, additionally we need to flip the triangles...
2183 // note: ODE does preprocessing of the mesh for culling, removing
2184 // concave edges, etc., so this is not a lightweight operation
2185 ed->priv.server->ode_numvertices = numvertices = model->brush.collisionmesh->numverts;
2186 ed->priv.server->ode_vertex3f = (float *)Mem_Alloc(mempool, numvertices * sizeof(float[3]));
2187 for (vertexindex = 0, ov = ed->priv.server->ode_vertex3f, iv = model->brush.collisionmesh->vertex3f;vertexindex < numvertices;vertexindex++, ov += 3, iv += 3)
2189 ov[0] = iv[0] - geomcenter[0];
2190 ov[1] = iv[1] - geomcenter[1];
2191 ov[2] = iv[2] - geomcenter[2];
2193 ed->priv.server->ode_numtriangles = numtriangles = model->brush.collisionmesh->numtriangles;
2194 ed->priv.server->ode_element3i = (int *)Mem_Alloc(mempool, numtriangles * sizeof(int[3]));
2195 //memcpy(ed->priv.server->ode_element3i, model->brush.collisionmesh->element3i, ed->priv.server->ode_numtriangles * sizeof(int[3]));
2196 for (triangleindex = 0, oe = ed->priv.server->ode_element3i, ie = model->brush.collisionmesh->element3i;triangleindex < numtriangles;triangleindex++, oe += 3, ie += 3)
2202 Matrix4x4_CreateTranslate(&ed->priv.server->ode_offsetmatrix, geomcenter[0], geomcenter[1], geomcenter[2]);
2203 // now create the geom
2204 dataID = dGeomTriMeshDataCreate();
2205 dGeomTriMeshDataBuildSingle((dTriMeshDataID)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]));
2206 ed->priv.server->ode_geom = (void *)dCreateTriMesh((dSpaceID)world->physics.ode_space, (dTriMeshDataID)dataID, NULL, NULL, NULL);
2207 dMassSetBoxTotal(&mass, massval, geomsize[0], geomsize[1], geomsize[2]);
2210 case SOLID_SLIDEBOX:
2212 case SOLID_PHYSICS_BOX:
2214 Matrix4x4_CreateTranslate(&ed->priv.server->ode_offsetmatrix, geomcenter[0], geomcenter[1], geomcenter[2]);
2215 ed->priv.server->ode_geom = (void *)dCreateBox((dSpaceID)world->physics.ode_space, geomsize[0], geomsize[1], geomsize[2]);
2216 dMassSetBoxTotal(&mass, massval, geomsize[0], geomsize[1], geomsize[2]);
2218 case SOLID_PHYSICS_SPHERE:
2219 Matrix4x4_CreateTranslate(&ed->priv.server->ode_offsetmatrix, geomcenter[0], geomcenter[1], geomcenter[2]);
2220 ed->priv.server->ode_geom = (void *)dCreateSphere((dSpaceID)world->physics.ode_space, geomsize[0] * 0.5f);
2221 dMassSetSphereTotal(&mass, massval, geomsize[0] * 0.5f);
2223 case SOLID_PHYSICS_CAPSULE:
2225 if (geomsize[axisindex] < geomsize[1])
2227 if (geomsize[axisindex] < geomsize[2])
2229 // the qc gives us 3 axis radius, the longest axis is the capsule
2230 // axis, since ODE doesn't like this idea we have to create a
2231 // capsule which uses the standard orientation, and apply a
2233 memset(capsulerot, 0, sizeof(capsulerot));
2235 Matrix4x4_CreateFromQuakeEntity(&ed->priv.server->ode_offsetmatrix, geomcenter[0], geomcenter[1], geomcenter[2], 0, 0, 90, 1);
2236 else if (axisindex == 1)
2237 Matrix4x4_CreateFromQuakeEntity(&ed->priv.server->ode_offsetmatrix, geomcenter[0], geomcenter[1], geomcenter[2], 90, 0, 0, 1);
2239 Matrix4x4_CreateFromQuakeEntity(&ed->priv.server->ode_offsetmatrix, geomcenter[0], geomcenter[1], geomcenter[2], 0, 0, 0, 1);
2240 radius = geomsize[!axisindex] * 0.5f; // any other axis is the radius
2241 length = geomsize[axisindex] - radius*2;
2242 // because we want to support more than one axisindex, we have to
2243 // create a transform, and turn on its cleanup setting (which will
2244 // cause the child to be destroyed when it is destroyed)
2245 ed->priv.server->ode_geom = (void *)dCreateCapsule((dSpaceID)world->physics.ode_space, radius, length);
2246 dMassSetCapsuleTotal(&mass, massval, axisindex+1, radius, length);
2249 Sys_Error("World_Physics_BodyFromEntity: unrecognized solid value %i was accepted by filter\n", solid);
2250 // this goto only exists to prevent warnings from the compiler
2251 // about uninitialized variables (mass), while allowing it to
2252 // catch legitimate uninitialized variable warnings
2255 Matrix4x4_Invert_Simple(&ed->priv.server->ode_offsetimatrix, &ed->priv.server->ode_offsetmatrix);
2256 ed->priv.server->ode_massbuf = Mem_Alloc(mempool, sizeof(mass));
2257 memcpy(ed->priv.server->ode_massbuf, &mass, sizeof(dMass));
2260 if(ed->priv.server->ode_geom)
2261 dGeomSetData((dGeomID)ed->priv.server->ode_geom, (void*)ed);
2262 if (movetype == MOVETYPE_PHYSICS && ed->priv.server->ode_geom)
2264 if (ed->priv.server->ode_body == NULL)
2266 ed->priv.server->ode_body = (void *)(body = dBodyCreate((dWorldID)world->physics.ode_world));
2267 dGeomSetBody((dGeomID)ed->priv.server->ode_geom, body);
2268 dBodySetData(body, (void*)ed);
2269 dBodySetMass(body, (dMass *) ed->priv.server->ode_massbuf);
2275 if (ed->priv.server->ode_body != NULL)
2277 if(ed->priv.server->ode_geom)
2278 dGeomSetBody((dGeomID)ed->priv.server->ode_geom, 0);
2279 dBodyDestroy((dBodyID) ed->priv.server->ode_body);
2280 ed->priv.server->ode_body = NULL;
2285 // get current data from entity
2286 VectorClear(origin);
2287 VectorClear(velocity);
2288 //VectorClear(forward);
2289 //VectorClear(left);
2291 //VectorClear(spinvelocity);
2292 VectorClear(angles);
2293 VectorClear(avelocity);
2295 VectorCopy(PRVM_gameedictvector(ed, origin), origin);
2296 VectorCopy(PRVM_gameedictvector(ed, velocity), velocity);
2297 //VectorCopy(PRVM_gameedictvector(ed, axis_forward), forward);
2298 //VectorCopy(PRVM_gameedictvector(ed, axis_left), left);
2299 //VectorCopy(PRVM_gameedictvector(ed, axis_up), up);
2300 //VectorCopy(PRVM_gameedictvector(ed, spinvelocity), spinvelocity);
2301 VectorCopy(PRVM_gameedictvector(ed, angles), angles);
2302 VectorCopy(PRVM_gameedictvector(ed, avelocity), avelocity);
2303 if (PRVM_gameedictfloat(ed, gravity) != 0.0f && PRVM_gameedictfloat(ed, gravity) < 0.5f) gravity = false;
2304 if (ed == prog->edicts)
2307 // compatibility for legacy entities
2308 //if (!VectorLength2(forward) || solid == SOLID_BSP)
2310 float pitchsign = 1;
2311 vec3_t qangles, qavelocity;
2312 VectorCopy(angles, qangles);
2313 VectorCopy(avelocity, qavelocity);
2315 if(!strcmp(prog->name, "server")) // FIXME some better way?
2317 pitchsign = SV_GetPitchSign(ed);
2319 else if(!strcmp(prog->name, "client"))
2321 pitchsign = CL_GetPitchSign(ed);
2323 qangles[PITCH] *= pitchsign;
2324 qavelocity[PITCH] *= pitchsign;
2326 AngleVectorsFLU(qangles, forward, left, up);
2327 // convert single-axis rotations in avelocity to spinvelocity
2328 // FIXME: untested math - check signs
2329 VectorSet(spinvelocity, DEG2RAD(qavelocity[PITCH]), DEG2RAD(qavelocity[ROLL]), DEG2RAD(qavelocity[YAW]));
2332 // compatibility for legacy entities
2336 case SOLID_SLIDEBOX:
2338 VectorSet(forward, 1, 0, 0);
2339 VectorSet(left, 0, 1, 0);
2340 VectorSet(up, 0, 0, 1);
2341 VectorSet(spinvelocity, 0, 0, 0);
2346 // we must prevent NANs...
2347 if (physics_ode_trick_fixnan.integer)
2349 test = VectorLength2(origin) + VectorLength2(forward) + VectorLength2(left) + VectorLength2(up) + VectorLength2(velocity) + VectorLength2(spinvelocity);
2353 //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_gameedictstring(ed, classname)), 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]);
2354 if (physics_ode_trick_fixnan.integer >= 2)
2355 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_gameedictstring(ed, classname)), origin[0], origin[1], origin[2], velocity[0], velocity[1], velocity[2], angles[0], angles[1], angles[2], avelocity[0], avelocity[1], avelocity[2]);
2356 test = VectorLength2(origin);
2358 VectorClear(origin);
2359 test = VectorLength2(forward) * VectorLength2(left) * VectorLength2(up);
2362 VectorSet(angles, 0, 0, 0);
2363 VectorSet(forward, 1, 0, 0);
2364 VectorSet(left, 0, 1, 0);
2365 VectorSet(up, 0, 0, 1);
2367 test = VectorLength2(velocity);
2369 VectorClear(velocity);
2370 test = VectorLength2(spinvelocity);
2373 VectorClear(avelocity);
2374 VectorClear(spinvelocity);
2379 // check if the qc edited any position data
2380 if (!VectorCompare(origin, ed->priv.server->ode_origin)
2381 || !VectorCompare(velocity, ed->priv.server->ode_velocity)
2382 || !VectorCompare(angles, ed->priv.server->ode_angles)
2383 || !VectorCompare(avelocity, ed->priv.server->ode_avelocity)
2384 || gravity != ed->priv.server->ode_gravity)
2387 // store the qc values into the physics engine
2388 body = (dBodyID)ed->priv.server->ode_body;
2389 if (modified && ed->priv.server->ode_geom)
2392 matrix4x4_t entitymatrix;
2393 matrix4x4_t bodymatrix;
2396 Con_Printf("entity %i got changed by QC\n", (int) (ed - prog->edicts));
2397 if(!VectorCompare(origin, ed->priv.server->ode_origin))
2398 Con_Printf(" origin: %f %f %f -> %f %f %f\n", ed->priv.server->ode_origin[0], ed->priv.server->ode_origin[1], ed->priv.server->ode_origin[2], origin[0], origin[1], origin[2]);
2399 if(!VectorCompare(velocity, ed->priv.server->ode_velocity))
2400 Con_Printf(" velocity: %f %f %f -> %f %f %f\n", ed->priv.server->ode_velocity[0], ed->priv.server->ode_velocity[1], ed->priv.server->ode_velocity[2], velocity[0], velocity[1], velocity[2]);
2401 if(!VectorCompare(angles, ed->priv.server->ode_angles))
2402 Con_Printf(" angles: %f %f %f -> %f %f %f\n", ed->priv.server->ode_angles[0], ed->priv.server->ode_angles[1], ed->priv.server->ode_angles[2], angles[0], angles[1], angles[2]);
2403 if(!VectorCompare(avelocity, ed->priv.server->ode_avelocity))
2404 Con_Printf(" avelocity: %f %f %f -> %f %f %f\n", ed->priv.server->ode_avelocity[0], ed->priv.server->ode_avelocity[1], ed->priv.server->ode_avelocity[2], avelocity[0], avelocity[1], avelocity[2]);
2405 if(gravity != ed->priv.server->ode_gravity)
2406 Con_Printf(" gravity: %i -> %i\n", ed->priv.server->ode_gravity, gravity);
2409 // values for BodyFromEntity to check if the qc modified anything later
2410 VectorCopy(origin, ed->priv.server->ode_origin);
2411 VectorCopy(velocity, ed->priv.server->ode_velocity);
2412 VectorCopy(angles, ed->priv.server->ode_angles);
2413 VectorCopy(avelocity, ed->priv.server->ode_avelocity);
2414 ed->priv.server->ode_gravity = gravity;
2416 Matrix4x4_FromVectors(&entitymatrix, forward, left, up, origin);
2417 Matrix4x4_Concat(&bodymatrix, &entitymatrix, &ed->priv.server->ode_offsetmatrix);
2418 Matrix4x4_ToVectors(&bodymatrix, forward, left, up, origin);
2419 r[0][0] = forward[0];
2420 r[1][0] = forward[1];
2421 r[2][0] = forward[2];
2430 if(movetype == MOVETYPE_PHYSICS)
2432 dGeomSetBody((dGeomID)ed->priv.server->ode_geom, body);
2433 dBodySetPosition(body, origin[0], origin[1], origin[2]);
2434 dBodySetRotation(body, r[0]);
2435 dBodySetLinearVel(body, velocity[0], velocity[1], velocity[2]);
2436 dBodySetAngularVel(body, spinvelocity[0], spinvelocity[1], spinvelocity[2]);
2437 dBodySetGravityMode(body, gravity);
2441 dGeomSetBody((dGeomID)ed->priv.server->ode_geom, body);
2442 dBodySetPosition(body, origin[0], origin[1], origin[2]);
2443 dBodySetRotation(body, r[0]);
2444 dBodySetLinearVel(body, velocity[0], velocity[1], velocity[2]);
2445 dBodySetAngularVel(body, spinvelocity[0], spinvelocity[1], spinvelocity[2]);
2446 dBodySetGravityMode(body, gravity);
2447 dGeomSetBody((dGeomID)ed->priv.server->ode_geom, 0);
2452 // no body... then let's adjust the parameters of the geom directly
2453 dGeomSetBody((dGeomID)ed->priv.server->ode_geom, 0); // just in case we previously HAD a body (which should never happen)
2454 dGeomSetPosition((dGeomID)ed->priv.server->ode_geom, origin[0], origin[1], origin[2]);
2455 dGeomSetRotation((dGeomID)ed->priv.server->ode_geom, r[0]);
2462 // limit movement speed to prevent missed collisions at high speed
2463 ovelocity = dBodyGetLinearVel(body);
2464 ospinvelocity = dBodyGetAngularVel(body);
2465 movelimit = ed->priv.server->ode_movelimit * world->physics.ode_movelimit;
2466 test = VectorLength2(ovelocity);
2467 if (test > movelimit*movelimit)
2469 // scale down linear velocity to the movelimit
2470 // scale down angular velocity the same amount for consistency
2471 f = movelimit / sqrt(test);
2472 VectorScale(ovelocity, f, velocity);
2473 VectorScale(ospinvelocity, f, spinvelocity);
2474 dBodySetLinearVel(body, velocity[0], velocity[1], velocity[2]);
2475 dBodySetAngularVel(body, spinvelocity[0], spinvelocity[1], spinvelocity[2]);
2478 // make sure the angular velocity is not exploding
2479 spinlimit = physics_ode_spinlimit.value;
2480 test = VectorLength2(ospinvelocity);
2481 if (test > spinlimit)
2483 dBodySetAngularVel(body, 0, 0, 0);
2486 // apply functions and clear stack
2487 for(func = ed->priv.server->ode_func; func; func = nextf)
2490 World_Physics_ApplyCmd(ed, func);
2493 ed->priv.server->ode_func = NULL;
2497 #define MAX_CONTACTS 16
2498 static void nearCallback (void *data, dGeomID o1, dGeomID o2)
2500 world_t *world = (world_t *)data;
2501 dContact contact[MAX_CONTACTS]; // max contacts per collision pair
2507 float bouncefactor1 = 0.0f;
2508 float bouncestop1 = 60.0f / 800.0f;
2509 float bouncefactor2 = 0.0f;
2510 float bouncestop2 = 60.0f / 800.0f;
2512 prvm_edict_t *ed1, *ed2;
2514 if (dGeomIsSpace(o1) || dGeomIsSpace(o2))
2516 // colliding a space with something
2517 dSpaceCollide2(o1, o2, data, &nearCallback);
2518 // Note we do not want to test intersections within a space,
2519 // only between spaces.
2520 //if (dGeomIsSpace(o1)) dSpaceCollide(o1, data, &nearCallback);
2521 //if (dGeomIsSpace(o2)) dSpaceCollide(o2, data, &nearCallback);
2525 b1 = dGeomGetBody(o1);
2526 b2 = dGeomGetBody(o2);
2528 // at least one object has to be using MOVETYPE_PHYSICS or we just don't care
2532 // exit without doing anything if the two bodies are connected by a joint
2533 if (b1 && b2 && dAreConnectedExcluding(b1, b2, dJointTypeContact))
2536 ed1 = (prvm_edict_t *) dGeomGetData(o1);
2537 if(ed1 && ed1->priv.server->free)
2541 bouncefactor1 = PRVM_gameedictfloat(ed1, bouncefactor);
2542 bouncestop1 = PRVM_gameedictfloat(ed1, bouncestop);
2544 bouncestop1 = 60.0f / 800.0f;
2547 ed2 = (prvm_edict_t *) dGeomGetData(o2);
2548 if(ed2 && ed2->priv.server->free)
2552 bouncefactor2 = PRVM_gameedictfloat(ed2, bouncefactor);
2553 bouncestop2 = PRVM_gameedictfloat(ed2, bouncestop);
2555 bouncestop2 = 60.0f / 800.0f;
2558 if(!strcmp(prog->name, "server"))
2560 if(ed1 && PRVM_serveredictfunction(ed1, touch))
2562 SV_LinkEdict_TouchAreaGrid_Call(ed1, ed2 ? ed2 : prog->edicts);
2564 if(ed2 && PRVM_serveredictfunction(ed2, touch))
2566 SV_LinkEdict_TouchAreaGrid_Call(ed2, ed1 ? ed1 : prog->edicts);
2570 // merge bounce factors and bounce stop
2571 if(bouncefactor2 > 0)
2573 if(bouncefactor1 > 0)
2575 // TODO possibly better logic to merge bounce factor data?
2576 if(bouncestop2 < bouncestop1)
2577 bouncestop1 = bouncestop2;
2578 if(bouncefactor2 > bouncefactor1)
2579 bouncefactor1 = bouncefactor2;
2583 bouncestop1 = bouncestop2;
2584 bouncefactor1 = bouncefactor2;
2587 dWorldGetGravity((dWorldID)world->physics.ode_world, grav);
2588 bouncestop1 *= fabs(grav[2]);
2590 // generate contact points between the two non-space geoms
2591 numcontacts = dCollide(o1, o2, MAX_CONTACTS, &(contact[0].geom), sizeof(contact[0]));
2592 // add these contact points to the simulation
2593 for (i = 0;i < numcontacts;i++)
2595 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);
2596 contact[i].surface.mu = physics_ode_contact_mu.value;
2597 contact[i].surface.soft_erp = physics_ode_contact_erp.value;
2598 contact[i].surface.soft_cfm = physics_ode_contact_cfm.value;
2599 contact[i].surface.bounce = bouncefactor1;
2600 contact[i].surface.bounce_vel = bouncestop1;
2601 c = dJointCreateContact((dWorldID)world->physics.ode_world, (dJointGroupID)world->physics.ode_contactgroup, contact + i);
2602 dJointAttach(c, b1, b2);
2607 void World_Physics_Frame(world_t *world, double frametime, double gravity)
2609 double tdelta, tdelta2, tdelta3, simulationtime, collisiontime;
2611 tdelta = Sys_DoubleTime();
2613 if (world->physics.ode && physics_ode.integer)
2618 world->physics.ode_iterations = bound(1, physics_ode_iterationsperframe.integer, 1000);
2619 if (physics_ode_constantstep.integer)
2620 world->physics.ode_step = sys_ticrate.value / world->physics.ode_iterations;
2622 world->physics.ode_step = frametime / world->physics.ode_iterations;
2623 world->physics.ode_movelimit = physics_ode_movelimit.value / world->physics.ode_step;
2624 World_Physics_UpdateODE(world);
2626 // copy physics properties from entities to physics engine
2629 for (i = 0, ed = prog->edicts + i;i < prog->num_edicts;i++, ed++)
2630 if (!prog->edicts[i].priv.required->free)
2631 World_Physics_Frame_BodyFromEntity(world, ed);
2632 // oh, and it must be called after all bodies were created
2633 for (i = 0, ed = prog->edicts + i;i < prog->num_edicts;i++, ed++)
2634 if (!prog->edicts[i].priv.required->free)
2635 World_Physics_Frame_JointFromEntity(world, ed);
2638 tdelta2 = Sys_DoubleTime();
2640 for (i = 0;i < world->physics.ode_iterations;i++)
2643 dWorldSetGravity((dWorldID)world->physics.ode_world, 0, 0, -gravity * physics_ode_world_gravitymod.value);
2644 // set the tolerance for closeness of objects
2645 dWorldSetContactSurfaceLayer((dWorldID)world->physics.ode_world, max(0, physics_ode_contactsurfacelayer.value));
2647 // run collisions for the current world state, creating JointGroup
2648 tdelta3 = Sys_DoubleTime();
2649 dSpaceCollide((dSpaceID)world->physics.ode_space, (void *)world, nearCallback);
2650 collisiontime += (Sys_DoubleTime() - tdelta3)*10000;
2652 // run physics (move objects, calculate new velocities)
2653 if (physics_ode_worldstep.integer == 2)
2655 dWorldSetQuickStepNumIterations((dWorldID)world->physics.ode_world, bound(1, physics_ode_worldstep_iterations.integer, 200));
2656 dWorldQuickStep((dWorldID)world->physics.ode_world, world->physics.ode_step);
2658 #ifdef ODE_USE_STEPFAST
2659 else if (physics_ode_worldstep.integer == 1)
2660 dWorldStepFast1((dWorldID)world->physics.ode_world, world->physics.ode_step, bound(1, physics_ode_worldstep_iterations.integer, 200));
2663 dWorldStep((dWorldID)world->physics.ode_world, world->physics.ode_step);
2665 // clear the JointGroup now that we're done with it
2666 dJointGroupEmpty((dJointGroupID)world->physics.ode_contactgroup);
2668 simulationtime = (Sys_DoubleTime() - tdelta2)*10000;
2670 // copy physics properties from physics engine to entities and do some stats
2673 for (i = 1, ed = prog->edicts + i;i < prog->num_edicts;i++, ed++)
2674 if (!prog->edicts[i].priv.required->free)
2675 World_Physics_Frame_BodyToEntity(world, ed);
2678 if (physics_ode_printstats.integer)
2682 world->physics.ode_numobjects = 0;
2683 world->physics.ode_activeovjects = 0;
2684 for (i = 1, ed = prog->edicts + i;i < prog->num_edicts;i++, ed++)
2686 if (prog->edicts[i].priv.required->free)
2688 body = (dBodyID)prog->edicts[i].priv.server->ode_body;
2691 world->physics.ode_numobjects++;
2692 if (dBodyIsEnabled(body))
2693 world->physics.ode_activeovjects++;
2695 Con_Printf("ODE Stats(%s): %3.01f (%3.01f collision) %3.01f total : %i objects %i active %i disabled\n", prog->name, simulationtime, collisiontime, (Sys_DoubleTime() - tdelta)*10000, world->physics.ode_numobjects, world->physics.ode_activeovjects, (world->physics.ode_numobjects - world->physics.ode_activeovjects));