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, prvm_prog_t *prog)
109 strlcpy(world->filename, filename, sizeof(world->filename));
110 VectorCopy(mins, world->mins);
111 VectorCopy(maxs, world->maxs);
114 // the areagrid_marknumber is not allowed to be 0
115 if (world->areagrid_marknumber < 1)
116 world->areagrid_marknumber = 1;
117 // choose either the world box size, or a larger box to ensure the grid isn't too fine
118 world->areagrid_size[0] = max(world->maxs[0] - world->mins[0], AREA_GRID * sv_areagrid_mingridsize.value);
119 world->areagrid_size[1] = max(world->maxs[1] - world->mins[1], AREA_GRID * sv_areagrid_mingridsize.value);
120 world->areagrid_size[2] = max(world->maxs[2] - world->mins[2], AREA_GRID * sv_areagrid_mingridsize.value);
121 // figure out the corners of such a box, centered at the center of the world box
122 world->areagrid_mins[0] = (world->mins[0] + world->maxs[0] - world->areagrid_size[0]) * 0.5f;
123 world->areagrid_mins[1] = (world->mins[1] + world->maxs[1] - world->areagrid_size[1]) * 0.5f;
124 world->areagrid_mins[2] = (world->mins[2] + world->maxs[2] - world->areagrid_size[2]) * 0.5f;
125 world->areagrid_maxs[0] = (world->mins[0] + world->maxs[0] + world->areagrid_size[0]) * 0.5f;
126 world->areagrid_maxs[1] = (world->mins[1] + world->maxs[1] + world->areagrid_size[1]) * 0.5f;
127 world->areagrid_maxs[2] = (world->mins[2] + world->maxs[2] + world->areagrid_size[2]) * 0.5f;
128 // now calculate the actual useful info from that
129 VectorNegate(world->areagrid_mins, world->areagrid_bias);
130 world->areagrid_scale[0] = AREA_GRID / world->areagrid_size[0];
131 world->areagrid_scale[1] = AREA_GRID / world->areagrid_size[1];
132 world->areagrid_scale[2] = AREA_GRID / world->areagrid_size[2];
133 World_ClearLink(&world->areagrid_outside);
134 for (i = 0;i < AREA_GRIDNODES;i++)
135 World_ClearLink(&world->areagrid[i]);
136 if (developer_extra.integer)
137 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);
146 void World_UnlinkAll(world_t *world)
148 prvm_prog_t *prog = world->prog;
151 // unlink all entities one by one
152 grid = &world->areagrid_outside;
153 while (grid->next != grid)
154 World_UnlinkEdict(PRVM_EDICT_NUM(grid->next->entitynumber));
155 for (i = 0, grid = world->areagrid;i < AREA_GRIDNODES;i++, grid++)
156 while (grid->next != grid)
157 World_UnlinkEdict(PRVM_EDICT_NUM(grid->next->entitynumber));
165 void World_UnlinkEdict(prvm_edict_t *ent)
168 for (i = 0;i < ENTITYGRIDAREAS;i++)
170 if (ent->priv.server->areagrid[i].prev)
172 World_RemoveLink (&ent->priv.server->areagrid[i]);
173 ent->priv.server->areagrid[i].prev = ent->priv.server->areagrid[i].next = NULL;
178 int World_EntitiesInBox(world_t *world, const vec3_t requestmins, const vec3_t requestmaxs, int maxlist, prvm_edict_t **list)
180 prvm_prog_t *prog = world->prog;
185 vec3_t paddedmins, paddedmaxs;
186 int igrid[3], igridmins[3], igridmaxs[3];
188 VectorSet(paddedmins, requestmins[0] - 1.0f, requestmins[1] - 1.0f, requestmins[2] - 1.0f);
189 VectorSet(paddedmaxs, requestmaxs[0] + 1.0f, requestmaxs[1] + 1.0f, requestmaxs[2] + 1.0f);
191 // FIXME: if areagrid_marknumber wraps, all entities need their
192 // ent->priv.server->areagridmarknumber reset
193 world->areagrid_stats_calls++;
194 world->areagrid_marknumber++;
195 igridmins[0] = (int) floor((paddedmins[0] + world->areagrid_bias[0]) * world->areagrid_scale[0]);
196 igridmins[1] = (int) floor((paddedmins[1] + world->areagrid_bias[1]) * world->areagrid_scale[1]);
197 //igridmins[2] = (int) ((paddedmins[2] + world->areagrid_bias[2]) * world->areagrid_scale[2]);
198 igridmaxs[0] = (int) floor((paddedmaxs[0] + world->areagrid_bias[0]) * world->areagrid_scale[0]) + 1;
199 igridmaxs[1] = (int) floor((paddedmaxs[1] + world->areagrid_bias[1]) * world->areagrid_scale[1]) + 1;
200 //igridmaxs[2] = (int) ((paddedmaxs[2] + world->areagrid_bias[2]) * world->areagrid_scale[2]) + 1;
201 igridmins[0] = max(0, igridmins[0]);
202 igridmins[1] = max(0, igridmins[1]);
203 //igridmins[2] = max(0, igridmins[2]);
204 igridmaxs[0] = min(AREA_GRID, igridmaxs[0]);
205 igridmaxs[1] = min(AREA_GRID, igridmaxs[1]);
206 //igridmaxs[2] = min(AREA_GRID, igridmaxs[2]);
208 // paranoid debugging
209 //VectorSet(igridmins, 0, 0, 0);VectorSet(igridmaxs, AREA_GRID, AREA_GRID, AREA_GRID);
212 // add entities not linked into areagrid because they are too big or
213 // outside the grid bounds
214 if (world->areagrid_outside.next != &world->areagrid_outside)
216 grid = &world->areagrid_outside;
217 for (l = grid->next;l != grid;l = l->next)
219 ent = PRVM_EDICT_NUM(l->entitynumber);
220 if (ent->priv.server->areagridmarknumber != world->areagrid_marknumber)
222 ent->priv.server->areagridmarknumber = world->areagrid_marknumber;
223 if (!ent->priv.server->free && BoxesOverlap(paddedmins, paddedmaxs, ent->priv.server->areamins, ent->priv.server->areamaxs))
225 if (numlist < maxlist)
229 world->areagrid_stats_entitychecks++;
233 // add grid linked entities
234 for (igrid[1] = igridmins[1];igrid[1] < igridmaxs[1];igrid[1]++)
236 grid = world->areagrid + igrid[1] * AREA_GRID + igridmins[0];
237 for (igrid[0] = igridmins[0];igrid[0] < igridmaxs[0];igrid[0]++, grid++)
239 if (grid->next != grid)
241 for (l = grid->next;l != grid;l = l->next)
243 ent = PRVM_EDICT_NUM(l->entitynumber);
244 if (ent->priv.server->areagridmarknumber != world->areagrid_marknumber)
246 ent->priv.server->areagridmarknumber = world->areagrid_marknumber;
247 if (!ent->priv.server->free && BoxesOverlap(paddedmins, paddedmaxs, ent->priv.server->areamins, ent->priv.server->areamaxs))
249 if (numlist < maxlist)
253 //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]);
255 world->areagrid_stats_entitychecks++;
263 static void World_LinkEdict_AreaGrid(world_t *world, prvm_edict_t *ent)
265 prvm_prog_t *prog = world->prog;
267 int igrid[3], igridmins[3], igridmaxs[3], gridnum, entitynumber = PRVM_NUM_FOR_EDICT(ent);
269 if (entitynumber <= 0 || entitynumber >= prog->max_edicts || PRVM_EDICT_NUM(entitynumber) != ent)
271 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);
275 igridmins[0] = (int) floor((ent->priv.server->areamins[0] + world->areagrid_bias[0]) * world->areagrid_scale[0]);
276 igridmins[1] = (int) floor((ent->priv.server->areamins[1] + world->areagrid_bias[1]) * world->areagrid_scale[1]);
277 //igridmins[2] = (int) floor((ent->priv.server->areamins[2] + world->areagrid_bias[2]) * world->areagrid_scale[2]);
278 igridmaxs[0] = (int) floor((ent->priv.server->areamaxs[0] + world->areagrid_bias[0]) * world->areagrid_scale[0]) + 1;
279 igridmaxs[1] = (int) floor((ent->priv.server->areamaxs[1] + world->areagrid_bias[1]) * world->areagrid_scale[1]) + 1;
280 //igridmaxs[2] = (int) floor((ent->priv.server->areamaxs[2] + world->areagrid_bias[2]) * world->areagrid_scale[2]) + 1;
281 if (igridmins[0] < 0 || igridmaxs[0] > AREA_GRID || igridmins[1] < 0 || igridmaxs[1] > AREA_GRID || ((igridmaxs[0] - igridmins[0]) * (igridmaxs[1] - igridmins[1])) > ENTITYGRIDAREAS)
283 // wow, something outside the grid, store it as such
284 World_InsertLinkBefore (&ent->priv.server->areagrid[0], &world->areagrid_outside, entitynumber);
289 for (igrid[1] = igridmins[1];igrid[1] < igridmaxs[1];igrid[1]++)
291 grid = world->areagrid + igrid[1] * AREA_GRID + igridmins[0];
292 for (igrid[0] = igridmins[0];igrid[0] < igridmaxs[0];igrid[0]++, grid++, gridnum++)
293 World_InsertLinkBefore (&ent->priv.server->areagrid[gridnum], grid, entitynumber);
303 void World_LinkEdict(world_t *world, prvm_edict_t *ent, const vec3_t mins, const vec3_t maxs)
305 prvm_prog_t *prog = world->prog;
306 // unlink from old position first
307 if (ent->priv.server->areagrid[0].prev)
308 World_UnlinkEdict(ent);
310 // don't add the world
311 if (ent == prog->edicts)
314 // don't add free entities
315 if (ent->priv.server->free)
318 VectorCopy(mins, ent->priv.server->areamins);
319 VectorCopy(maxs, ent->priv.server->areamaxs);
320 World_LinkEdict_AreaGrid(world, ent);
326 //============================================================================
327 // physics engine support
328 //============================================================================
331 # define ODE_DYNAMIC 1
334 #if defined(ODE_STATIC) || defined(ODE_DYNAMIC)
338 // recent ODE trunk has dWorldStepFast1 removed
339 //#define ODE_USE_STEPFAST
342 cvar_t physics_ode_quadtree_depth = {0, "physics_ode_quadtree_depth","5", "desired subdivision level of quadtree culling space"};
343 cvar_t physics_ode_contactsurfacelayer = {0, "physics_ode_contactsurfacelayer","1", "allows objects to overlap this many units to reduce jitter"};
344 cvar_t physics_ode_worldstep = {0, "physics_ode_worldstep","2", "step function to use, 0 - dWorldStep, 1 - dWorldStepFast1, 2 - dWorldQuickStep"};
345 cvar_t physics_ode_worldstep_iterations = {0, "physics_ode_worldstep_iterations", "20", "parameter to dWorldQuickStep and dWorldStepFast1"};
346 cvar_t physics_ode_contact_mu = {0, "physics_ode_contact_mu", "1", "contact solver mu parameter - friction pyramid approximation 1 (see ODE User Guide)"};
347 cvar_t physics_ode_contact_erp = {0, "physics_ode_contact_erp", "0.96", "contact solver erp parameter - Error Restitution Percent (see ODE User Guide)"};
348 cvar_t physics_ode_contact_cfm = {0, "physics_ode_contact_cfm", "0", "contact solver cfm parameter - Constraint Force Mixing (see ODE User Guide)"};
349 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"};
350 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"};
351 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"};
352 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"};
353 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"};
354 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"};
355 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"};
356 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"};
357 cvar_t physics_ode_iterationsperframe = {0, "physics_ode_iterationsperframe", "1", "divisor for time step, runs multiple physics steps per frame"};
358 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"};
359 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"};
360 cvar_t physics_ode_autodisable_steps = {0, "physics_ode_autodisable_steps", "10", "how many steps object should be dormant to be autodisabled"};
361 cvar_t physics_ode_autodisable_time = {0, "physics_ode_autodisable_time", "0", "how many seconds object should be dormant to be autodisabled"};
362 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"};
363 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"};
364 cvar_t physics_ode_autodisable_threshold_samples = {0, "physics_ode_autodisable_threshold_samples", "5", "average threshold with this number of samples"};
365 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"};
366 cvar_t physics_ode_spinlimit = {0, "physics_ode_spinlimit", "10000", "reset spin velocity if it gets too large"};
367 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"};
368 cvar_t physics_ode_printstats = {0, "physics_ode_printstats", "0", "print ODE stats each frame"};
369 cvar_t physics_ode = {0, "physics_ode", "0", "run ODE physics (VERY experimental and potentially buggy)"};
371 // LordHavoc: this large chunk of definitions comes from the ODE library
378 // ODE does not use WINAPI
384 // note: dynamic builds of ODE tend to be double precision, this is not used
386 typedef double dReal;
388 typedef dReal dVector3[4];
389 typedef dReal dVector4[4];
390 typedef dReal dMatrix3[4*3];
391 typedef dReal dMatrix4[4*4];
392 typedef dReal dMatrix6[8*6];
393 typedef dReal dQuaternion[4];
395 struct dxWorld; /* dynamics world */
396 struct dxSpace; /* collision space */
397 struct dxBody; /* rigid body (dynamics object) */
398 struct dxGeom; /* geometry (collision object) */
402 struct dxTriMeshData;
404 #define dInfinity 3.402823466e+38f
406 typedef struct dxWorld *dWorldID;
407 typedef struct dxSpace *dSpaceID;
408 typedef struct dxBody *dBodyID;
409 typedef struct dxGeom *dGeomID;
410 typedef struct dxJoint *dJointID;
411 typedef struct dxJointGroup *dJointGroupID;
412 typedef struct dxTriMeshData *dTriMeshDataID;
414 typedef struct dJointFeedback
416 dVector3 f1; /* force applied to body 1 */
417 dVector3 t1; /* torque applied to body 1 */
418 dVector3 f2; /* force applied to body 2 */
419 dVector3 t2; /* torque applied to body 2 */
423 typedef enum dJointType
443 #define D_ALL_PARAM_NAMES(start) \
444 /* parameters for limits and motors */ \
445 dParamLoStop = start, \
454 /* parameters for suspension */ \
455 dParamSuspensionERP, \
456 dParamSuspensionCFM, \
459 #define D_ALL_PARAM_NAMES_X(start,x) \
460 /* parameters for limits and motors */ \
461 dParamLoStop ## x = start, \
465 dParamFudgeFactor ## x, \
468 dParamStopERP ## x, \
469 dParamStopCFM ## x, \
470 /* parameters for suspension */ \
471 dParamSuspensionERP ## x, \
472 dParamSuspensionCFM ## x, \
477 D_ALL_PARAM_NAMES_X(0x100,2)
478 D_ALL_PARAM_NAMES_X(0x200,3)
480 /* add a multiple of this constant to the basic parameter numbers to get
481 * the parameters for the second, third etc axes.
497 dContactFDir1 = 0x002,
498 dContactBounce = 0x004,
499 dContactSoftERP = 0x008,
500 dContactSoftCFM = 0x010,
501 dContactMotion1 = 0x020,
502 dContactMotion2 = 0x040,
503 dContactMotionN = 0x080,
504 dContactSlip1 = 0x100,
505 dContactSlip2 = 0x200,
507 dContactApprox0 = 0x0000,
508 dContactApprox1_1 = 0x1000,
509 dContactApprox1_2 = 0x2000,
510 dContactApprox1 = 0x3000
513 typedef struct dSurfaceParameters
515 /* must always be defined */
519 /* only defined if the corresponding flag is set in mode */
525 dReal motion1,motion2,motionN;
527 } dSurfaceParameters;
529 typedef struct dContactGeom
531 dVector3 pos; ///< contact position
532 dVector3 normal; ///< normal vector
533 dReal depth; ///< penetration depth
534 dGeomID g1,g2; ///< the colliding geoms
535 int side1,side2; ///< (to be documented)
539 typedef struct dContact
541 dSurfaceParameters surface;
547 typedef void dNearCallback (void *data, dGeomID o1, dGeomID o2);
550 // Order XZY or ZXY usually works best, if your Y is up.
551 #define dSAP_AXES_XYZ ((0)|(1<<2)|(2<<4))
552 #define dSAP_AXES_XZY ((0)|(2<<2)|(1<<4))
553 #define dSAP_AXES_YXZ ((1)|(0<<2)|(2<<4))
554 #define dSAP_AXES_YZX ((1)|(2<<2)|(0<<4))
555 #define dSAP_AXES_ZXY ((2)|(0<<2)|(1<<4))
556 #define dSAP_AXES_ZYX ((2)|(1<<2)|(0<<4))
558 //const char* (ODE_API *dGetConfiguration)(void);
559 int (ODE_API *dCheckConfiguration)( const char* token );
560 int (ODE_API *dInitODE)(void);
561 //int (ODE_API *dInitODE2)(unsigned int uiInitFlags);
562 //int (ODE_API *dAllocateODEDataForThread)(unsigned int uiAllocateFlags);
563 //void (ODE_API *dCleanupODEAllDataForThread)(void);
564 void (ODE_API *dCloseODE)(void);
566 //int (ODE_API *dMassCheck)(const dMass *m);
567 //void (ODE_API *dMassSetZero)(dMass *);
568 //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);
569 //void (ODE_API *dMassSetSphere)(dMass *, dReal density, dReal radius);
570 void (ODE_API *dMassSetSphereTotal)(dMass *, dReal total_mass, dReal radius);
571 //void (ODE_API *dMassSetCapsule)(dMass *, dReal density, int direction, dReal radius, dReal length);
572 void (ODE_API *dMassSetCapsuleTotal)(dMass *, dReal total_mass, int direction, dReal radius, dReal length);
573 //void (ODE_API *dMassSetCylinder)(dMass *, dReal density, int direction, dReal radius, dReal length);
574 void (ODE_API *dMassSetCylinderTotal)(dMass *, dReal total_mass, int direction, dReal radius, dReal length);
575 //void (ODE_API *dMassSetBox)(dMass *, dReal density, dReal lx, dReal ly, dReal lz);
576 void (ODE_API *dMassSetBoxTotal)(dMass *, dReal total_mass, dReal lx, dReal ly, dReal lz);
577 //void (ODE_API *dMassSetTrimesh)(dMass *, dReal density, dGeomID g);
578 //void (ODE_API *dMassSetTrimeshTotal)(dMass *m, dReal total_mass, dGeomID g);
579 //void (ODE_API *dMassAdjust)(dMass *, dReal newmass);
580 //void (ODE_API *dMassTranslate)(dMass *, dReal x, dReal y, dReal z);
581 //void (ODE_API *dMassRotate)(dMass *, const dMatrix3 R);
582 //void (ODE_API *dMassAdd)(dMass *a, const dMass *b);
584 dWorldID (ODE_API *dWorldCreate)(void);
585 void (ODE_API *dWorldDestroy)(dWorldID world);
586 void (ODE_API *dWorldSetGravity)(dWorldID, dReal x, dReal y, dReal z);
587 void (ODE_API *dWorldGetGravity)(dWorldID, dVector3 gravity);
588 void (ODE_API *dWorldSetERP)(dWorldID, dReal erp);
589 //dReal (ODE_API *dWorldGetERP)(dWorldID);
590 void (ODE_API *dWorldSetCFM)(dWorldID, dReal cfm);
591 //dReal (ODE_API *dWorldGetCFM)(dWorldID);
592 void (ODE_API *dWorldStep)(dWorldID, dReal stepsize);
593 //void (ODE_API *dWorldImpulseToForce)(dWorldID, dReal stepsize, dReal ix, dReal iy, dReal iz, dVector3 force);
594 void (ODE_API *dWorldQuickStep)(dWorldID w, dReal stepsize);
595 void (ODE_API *dWorldSetQuickStepNumIterations)(dWorldID, int num);
596 //int (ODE_API *dWorldGetQuickStepNumIterations)(dWorldID);
597 //void (ODE_API *dWorldSetQuickStepW)(dWorldID, dReal over_relaxation);
598 //dReal (ODE_API *dWorldGetQuickStepW)(dWorldID);
599 //void (ODE_API *dWorldSetContactMaxCorrectingVel)(dWorldID, dReal vel);
600 //dReal (ODE_API *dWorldGetContactMaxCorrectingVel)(dWorldID);
601 void (ODE_API *dWorldSetContactSurfaceLayer)(dWorldID, dReal depth);
602 //dReal (ODE_API *dWorldGetContactSurfaceLayer)(dWorldID);
603 #ifdef ODE_USE_STEPFAST
604 void (ODE_API *dWorldStepFast1)(dWorldID, dReal stepsize, int maxiterations);
606 //void (ODE_API *dWorldSetAutoEnableDepthSF1)(dWorldID, int autoEnableDepth);
607 //int (ODE_API *dWorldGetAutoEnableDepthSF1)(dWorldID);
608 //dReal (ODE_API *dWorldGetAutoDisableLinearThreshold)(dWorldID);
609 void (ODE_API *dWorldSetAutoDisableLinearThreshold)(dWorldID, dReal linear_threshold);
610 //dReal (ODE_API *dWorldGetAutoDisableAngularThreshold)(dWorldID);
611 void (ODE_API *dWorldSetAutoDisableAngularThreshold)(dWorldID, dReal angular_threshold);
612 //dReal (ODE_API *dWorldGetAutoDisableLinearAverageThreshold)(dWorldID);
613 //void (ODE_API *dWorldSetAutoDisableLinearAverageThreshold)(dWorldID, dReal linear_average_threshold);
614 //dReal (ODE_API *dWorldGetAutoDisableAngularAverageThreshold)(dWorldID);
615 //void (ODE_API *dWorldSetAutoDisableAngularAverageThreshold)(dWorldID, dReal angular_average_threshold);
616 //int (ODE_API *dWorldGetAutoDisableAverageSamplesCount)(dWorldID);
617 void (ODE_API *dWorldSetAutoDisableAverageSamplesCount)(dWorldID, unsigned int average_samples_count );
618 //int (ODE_API *dWorldGetAutoDisableSteps)(dWorldID);
619 void (ODE_API *dWorldSetAutoDisableSteps)(dWorldID, int steps);
620 //dReal (ODE_API *dWorldGetAutoDisableTime)(dWorldID);
621 void (ODE_API *dWorldSetAutoDisableTime)(dWorldID, dReal time);
622 //int (ODE_API *dWorldGetAutoDisableFlag)(dWorldID);
623 void (ODE_API *dWorldSetAutoDisableFlag)(dWorldID, int do_auto_disable);
624 //dReal (ODE_API *dWorldGetLinearDampingThreshold)(dWorldID w);
625 void (ODE_API *dWorldSetLinearDampingThreshold)(dWorldID w, dReal threshold);
626 //dReal (ODE_API *dWorldGetAngularDampingThreshold)(dWorldID w);
627 void (ODE_API *dWorldSetAngularDampingThreshold)(dWorldID w, dReal threshold);
628 //dReal (ODE_API *dWorldGetLinearDamping)(dWorldID w);
629 void (ODE_API *dWorldSetLinearDamping)(dWorldID w, dReal scale);
630 //dReal (ODE_API *dWorldGetAngularDamping)(dWorldID w);
631 void (ODE_API *dWorldSetAngularDamping)(dWorldID w, dReal scale);
632 //void (ODE_API *dWorldSetDamping)(dWorldID w, dReal linear_scale, dReal angular_scale);
633 //dReal (ODE_API *dWorldGetMaxAngularSpeed)(dWorldID w);
634 //void (ODE_API *dWorldSetMaxAngularSpeed)(dWorldID w, dReal max_speed);
635 //dReal (ODE_API *dBodyGetAutoDisableLinearThreshold)(dBodyID);
636 //void (ODE_API *dBodySetAutoDisableLinearThreshold)(dBodyID, dReal linear_average_threshold);
637 //dReal (ODE_API *dBodyGetAutoDisableAngularThreshold)(dBodyID);
638 //void (ODE_API *dBodySetAutoDisableAngularThreshold)(dBodyID, dReal angular_average_threshold);
639 //int (ODE_API *dBodyGetAutoDisableAverageSamplesCount)(dBodyID);
640 //void (ODE_API *dBodySetAutoDisableAverageSamplesCount)(dBodyID, unsigned int average_samples_count);
641 //int (ODE_API *dBodyGetAutoDisableSteps)(dBodyID);
642 //void (ODE_API *dBodySetAutoDisableSteps)(dBodyID, int steps);
643 //dReal (ODE_API *dBodyGetAutoDisableTime)(dBodyID);
644 //void (ODE_API *dBodySetAutoDisableTime)(dBodyID, dReal time);
645 //int (ODE_API *dBodyGetAutoDisableFlag)(dBodyID);
646 //void (ODE_API *dBodySetAutoDisableFlag)(dBodyID, int do_auto_disable);
647 //void (ODE_API *dBodySetAutoDisableDefaults)(dBodyID);
648 //dWorldID (ODE_API *dBodyGetWorld)(dBodyID);
649 dBodyID (ODE_API *dBodyCreate)(dWorldID);
650 void (ODE_API *dBodyDestroy)(dBodyID);
651 void (ODE_API *dBodySetData)(dBodyID, void *data);
652 void * (ODE_API *dBodyGetData)(dBodyID);
653 void (ODE_API *dBodySetPosition)(dBodyID, dReal x, dReal y, dReal z);
654 void (ODE_API *dBodySetRotation)(dBodyID, const dMatrix3 R);
655 //void (ODE_API *dBodySetQuaternion)(dBodyID, const dQuaternion q);
656 void (ODE_API *dBodySetLinearVel)(dBodyID, dReal x, dReal y, dReal z);
657 void (ODE_API *dBodySetAngularVel)(dBodyID, dReal x, dReal y, dReal z);
658 const dReal * (ODE_API *dBodyGetPosition)(dBodyID);
659 //void (ODE_API *dBodyCopyPosition)(dBodyID body, dVector3 pos);
660 const dReal * (ODE_API *dBodyGetRotation)(dBodyID);
661 //void (ODE_API *dBodyCopyRotation)(dBodyID, dMatrix3 R);
662 //const dReal * (ODE_API *dBodyGetQuaternion)(dBodyID);
663 //void (ODE_API *dBodyCopyQuaternion)(dBodyID body, dQuaternion quat);
664 const dReal * (ODE_API *dBodyGetLinearVel)(dBodyID);
665 const dReal * (ODE_API *dBodyGetAngularVel)(dBodyID);
666 void (ODE_API *dBodySetMass)(dBodyID, const dMass *mass);
667 //void (ODE_API *dBodyGetMass)(dBodyID, dMass *mass);
668 //void (ODE_API *dBodyAddForce)(dBodyID, dReal fx, dReal fy, dReal fz);
669 //void (ODE_API *dBodyAddTorque)(dBodyID, dReal fx, dReal fy, dReal fz);
670 //void (ODE_API *dBodyAddRelForce)(dBodyID, dReal fx, dReal fy, dReal fz);
671 void (ODE_API *dBodyAddRelTorque)(dBodyID, dReal fx, dReal fy, dReal fz);
672 //void (ODE_API *dBodyAddForceAtPos)(dBodyID, dReal fx, dReal fy, dReal fz, dReal px, dReal py, dReal pz);
673 void (ODE_API *dBodyAddForceAtRelPos)(dBodyID, dReal fx, dReal fy, dReal fz, dReal px, dReal py, dReal pz);
674 //void (ODE_API *dBodyAddRelForceAtPos)(dBodyID, dReal fx, dReal fy, dReal fz, dReal px, dReal py, dReal pz);
675 //void (ODE_API *dBodyAddRelForceAtRelPos)(dBodyID, dReal fx, dReal fy, dReal fz, dReal px, dReal py, dReal pz);
676 //const dReal * (ODE_API *dBodyGetForce)(dBodyID);
677 //const dReal * (ODE_API *dBodyGetTorque)(dBodyID);
678 //void (ODE_API *dBodySetForce)(dBodyID b, dReal x, dReal y, dReal z);
679 //void (ODE_API *dBodySetTorque)(dBodyID b, dReal x, dReal y, dReal z);
680 //void (ODE_API *dBodyGetRelPointPos)(dBodyID, dReal px, dReal py, dReal pz, dVector3 result);
681 //void (ODE_API *dBodyGetRelPointVel)(dBodyID, dReal px, dReal py, dReal pz, dVector3 result);
682 //void (ODE_API *dBodyGetPointVel)(dBodyID, dReal px, dReal py, dReal pz, dVector3 result);
683 //void (ODE_API *dBodyGetPosRelPoint)(dBodyID, dReal px, dReal py, dReal pz, dVector3 result);
684 //void (ODE_API *dBodyVectorToWorld)(dBodyID, dReal px, dReal py, dReal pz, dVector3 result);
685 //void (ODE_API *dBodyVectorFromWorld)(dBodyID, dReal px, dReal py, dReal pz, dVector3 result);
686 //void (ODE_API *dBodySetFiniteRotationMode)(dBodyID, int mode);
687 //void (ODE_API *dBodySetFiniteRotationAxis)(dBodyID, dReal x, dReal y, dReal z);
688 //int (ODE_API *dBodyGetFiniteRotationMode)(dBodyID);
689 //void (ODE_API *dBodyGetFiniteRotationAxis)(dBodyID, dVector3 result);
690 int (ODE_API *dBodyGetNumJoints)(dBodyID b);
691 dJointID (ODE_API *dBodyGetJoint)(dBodyID, int index);
692 //void (ODE_API *dBodySetDynamic)(dBodyID);
693 //void (ODE_API *dBodySetKinematic)(dBodyID);
694 //int (ODE_API *dBodyIsKinematic)(dBodyID);
695 void (ODE_API *dBodyEnable)(dBodyID);
696 void (ODE_API *dBodyDisable)(dBodyID);
697 int (ODE_API *dBodyIsEnabled)(dBodyID);
698 void (ODE_API *dBodySetGravityMode)(dBodyID b, int mode);
699 int (ODE_API *dBodyGetGravityMode)(dBodyID b);
700 //void (*dBodySetMovedCallback)(dBodyID b, void(ODE_API *callback)(dBodyID));
701 //dGeomID (ODE_API *dBodyGetFirstGeom)(dBodyID b);
702 //dGeomID (ODE_API *dBodyGetNextGeom)(dGeomID g);
703 //void (ODE_API *dBodySetDampingDefaults)(dBodyID b);
704 //dReal (ODE_API *dBodyGetLinearDamping)(dBodyID b);
705 //void (ODE_API *dBodySetLinearDamping)(dBodyID b, dReal scale);
706 //dReal (ODE_API *dBodyGetAngularDamping)(dBodyID b);
707 //void (ODE_API *dBodySetAngularDamping)(dBodyID b, dReal scale);
708 //void (ODE_API *dBodySetDamping)(dBodyID b, dReal linear_scale, dReal angular_scale);
709 //dReal (ODE_API *dBodyGetLinearDampingThreshold)(dBodyID b);
710 //void (ODE_API *dBodySetLinearDampingThreshold)(dBodyID b, dReal threshold);
711 //dReal (ODE_API *dBodyGetAngularDampingThreshold)(dBodyID b);
712 //void (ODE_API *dBodySetAngularDampingThreshold)(dBodyID b, dReal threshold);
713 //dReal (ODE_API *dBodyGetMaxAngularSpeed)(dBodyID b);
714 //void (ODE_API *dBodySetMaxAngularSpeed)(dBodyID b, dReal max_speed);
715 //int (ODE_API *dBodyGetGyroscopicMode)(dBodyID b);
716 //void (ODE_API *dBodySetGyroscopicMode)(dBodyID b, int enabled);
717 dJointID (ODE_API *dJointCreateBall)(dWorldID, dJointGroupID);
718 dJointID (ODE_API *dJointCreateHinge)(dWorldID, dJointGroupID);
719 dJointID (ODE_API *dJointCreateSlider)(dWorldID, dJointGroupID);
720 dJointID (ODE_API *dJointCreateContact)(dWorldID, dJointGroupID, const dContact *);
721 dJointID (ODE_API *dJointCreateHinge2)(dWorldID, dJointGroupID);
722 dJointID (ODE_API *dJointCreateUniversal)(dWorldID, dJointGroupID);
723 //dJointID (ODE_API *dJointCreatePR)(dWorldID, dJointGroupID);
724 //dJointID (ODE_API *dJointCreatePU)(dWorldID, dJointGroupID);
725 //dJointID (ODE_API *dJointCreatePiston)(dWorldID, dJointGroupID);
726 dJointID (ODE_API *dJointCreateFixed)(dWorldID, dJointGroupID);
727 //dJointID (ODE_API *dJointCreateNull)(dWorldID, dJointGroupID);
728 //dJointID (ODE_API *dJointCreateAMotor)(dWorldID, dJointGroupID);
729 //dJointID (ODE_API *dJointCreateLMotor)(dWorldID, dJointGroupID);
730 //dJointID (ODE_API *dJointCreatePlane2D)(dWorldID, dJointGroupID);
731 void (ODE_API *dJointDestroy)(dJointID);
732 dJointGroupID (ODE_API *dJointGroupCreate)(int max_size);
733 void (ODE_API *dJointGroupDestroy)(dJointGroupID);
734 void (ODE_API *dJointGroupEmpty)(dJointGroupID);
735 //int (ODE_API *dJointGetNumBodies)(dJointID);
736 void (ODE_API *dJointAttach)(dJointID, dBodyID body1, dBodyID body2);
737 //void (ODE_API *dJointEnable)(dJointID);
738 //void (ODE_API *dJointDisable)(dJointID);
739 //int (ODE_API *dJointIsEnabled)(dJointID);
740 void (ODE_API *dJointSetData)(dJointID, void *data);
741 void * (ODE_API *dJointGetData)(dJointID);
742 //dJointType (ODE_API *dJointGetType)(dJointID);
743 dBodyID (ODE_API *dJointGetBody)(dJointID, int index);
744 //void (ODE_API *dJointSetFeedback)(dJointID, dJointFeedback *);
745 //dJointFeedback *(ODE_API *dJointGetFeedback)(dJointID);
746 void (ODE_API *dJointSetBallAnchor)(dJointID, dReal x, dReal y, dReal z);
747 //void (ODE_API *dJointSetBallAnchor2)(dJointID, dReal x, dReal y, dReal z);
748 void (ODE_API *dJointSetBallParam)(dJointID, int parameter, dReal value);
749 void (ODE_API *dJointSetHingeAnchor)(dJointID, dReal x, dReal y, dReal z);
750 //void (ODE_API *dJointSetHingeAnchorDelta)(dJointID, dReal x, dReal y, dReal z, dReal ax, dReal ay, dReal az);
751 void (ODE_API *dJointSetHingeAxis)(dJointID, dReal x, dReal y, dReal z);
752 //void (ODE_API *dJointSetHingeAxisOffset)(dJointID j, dReal x, dReal y, dReal z, dReal angle);
753 void (ODE_API *dJointSetHingeParam)(dJointID, int parameter, dReal value);
754 //void (ODE_API *dJointAddHingeTorque)(dJointID joint, dReal torque);
755 void (ODE_API *dJointSetSliderAxis)(dJointID, dReal x, dReal y, dReal z);
756 //void (ODE_API *dJointSetSliderAxisDelta)(dJointID, dReal x, dReal y, dReal z, dReal ax, dReal ay, dReal az);
757 void (ODE_API *dJointSetSliderParam)(dJointID, int parameter, dReal value);
758 //void (ODE_API *dJointAddSliderForce)(dJointID joint, dReal force);
759 void (ODE_API *dJointSetHinge2Anchor)(dJointID, dReal x, dReal y, dReal z);
760 void (ODE_API *dJointSetHinge2Axis1)(dJointID, dReal x, dReal y, dReal z);
761 void (ODE_API *dJointSetHinge2Axis2)(dJointID, dReal x, dReal y, dReal z);
762 void (ODE_API *dJointSetHinge2Param)(dJointID, int parameter, dReal value);
763 //void (ODE_API *dJointAddHinge2Torques)(dJointID joint, dReal torque1, dReal torque2);
764 void (ODE_API *dJointSetUniversalAnchor)(dJointID, dReal x, dReal y, dReal z);
765 void (ODE_API *dJointSetUniversalAxis1)(dJointID, dReal x, dReal y, dReal z);
766 //void (ODE_API *dJointSetUniversalAxis1Offset)(dJointID, dReal x, dReal y, dReal z, dReal offset1, dReal offset2);
767 void (ODE_API *dJointSetUniversalAxis2)(dJointID, dReal x, dReal y, dReal z);
768 //void (ODE_API *dJointSetUniversalAxis2Offset)(dJointID, dReal x, dReal y, dReal z, dReal offset1, dReal offset2);
769 void (ODE_API *dJointSetUniversalParam)(dJointID, int parameter, dReal value);
770 //void (ODE_API *dJointAddUniversalTorques)(dJointID joint, dReal torque1, dReal torque2);
771 //void (ODE_API *dJointSetPRAnchor)(dJointID, dReal x, dReal y, dReal z);
772 //void (ODE_API *dJointSetPRAxis1)(dJointID, dReal x, dReal y, dReal z);
773 //void (ODE_API *dJointSetPRAxis2)(dJointID, dReal x, dReal y, dReal z);
774 //void (ODE_API *dJointSetPRParam)(dJointID, int parameter, dReal value);
775 //void (ODE_API *dJointAddPRTorque)(dJointID j, dReal torque);
776 //void (ODE_API *dJointSetPUAnchor)(dJointID, dReal x, dReal y, dReal z);
777 //void (ODE_API *dJointSetPUAnchorOffset)(dJointID, dReal x, dReal y, dReal z, dReal dx, dReal dy, dReal dz);
778 //void (ODE_API *dJointSetPUAxis1)(dJointID, dReal x, dReal y, dReal z);
779 //void (ODE_API *dJointSetPUAxis2)(dJointID, dReal x, dReal y, dReal z);
780 //void (ODE_API *dJointSetPUAxis3)(dJointID, dReal x, dReal y, dReal z);
781 //void (ODE_API *dJointSetPUAxisP)(dJointID id, dReal x, dReal y, dReal z);
782 //void (ODE_API *dJointSetPUParam)(dJointID, int parameter, dReal value);
783 //void (ODE_API *dJointAddPUTorque)(dJointID j, dReal torque);
784 //void (ODE_API *dJointSetPistonAnchor)(dJointID, dReal x, dReal y, dReal z);
785 //void (ODE_API *dJointSetPistonAnchorOffset)(dJointID j, dReal x, dReal y, dReal z, dReal dx, dReal dy, dReal dz);
786 //void (ODE_API *dJointSetPistonParam)(dJointID, int parameter, dReal value);
787 //void (ODE_API *dJointAddPistonForce)(dJointID joint, dReal force);
788 //void (ODE_API *dJointSetFixed)(dJointID);
789 //void (ODE_API *dJointSetFixedParam)(dJointID, int parameter, dReal value);
790 //void (ODE_API *dJointSetAMotorNumAxes)(dJointID, int num);
791 //void (ODE_API *dJointSetAMotorAxis)(dJointID, int anum, int rel, dReal x, dReal y, dReal z);
792 //void (ODE_API *dJointSetAMotorAngle)(dJointID, int anum, dReal angle);
793 //void (ODE_API *dJointSetAMotorParam)(dJointID, int parameter, dReal value);
794 //void (ODE_API *dJointSetAMotorMode)(dJointID, int mode);
795 //void (ODE_API *dJointAddAMotorTorques)(dJointID, dReal torque1, dReal torque2, dReal torque3);
796 //void (ODE_API *dJointSetLMotorNumAxes)(dJointID, int num);
797 //void (ODE_API *dJointSetLMotorAxis)(dJointID, int anum, int rel, dReal x, dReal y, dReal z);
798 //void (ODE_API *dJointSetLMotorParam)(dJointID, int parameter, dReal value);
799 //void (ODE_API *dJointSetPlane2DXParam)(dJointID, int parameter, dReal value);
800 //void (ODE_API *dJointSetPlane2DYParam)(dJointID, int parameter, dReal value);
801 //void (ODE_API *dJointSetPlane2DAngleParam)(dJointID, int parameter, dReal value);
802 //void (ODE_API *dJointGetBallAnchor)(dJointID, dVector3 result);
803 //void (ODE_API *dJointGetBallAnchor2)(dJointID, dVector3 result);
804 //dReal (ODE_API *dJointGetBallParam)(dJointID, int parameter);
805 //void (ODE_API *dJointGetHingeAnchor)(dJointID, dVector3 result);
806 //void (ODE_API *dJointGetHingeAnchor2)(dJointID, dVector3 result);
807 //void (ODE_API *dJointGetHingeAxis)(dJointID, dVector3 result);
808 //dReal (ODE_API *dJointGetHingeParam)(dJointID, int parameter);
809 //dReal (ODE_API *dJointGetHingeAngle)(dJointID);
810 //dReal (ODE_API *dJointGetHingeAngleRate)(dJointID);
811 //dReal (ODE_API *dJointGetSliderPosition)(dJointID);
812 //dReal (ODE_API *dJointGetSliderPositionRate)(dJointID);
813 //void (ODE_API *dJointGetSliderAxis)(dJointID, dVector3 result);
814 //dReal (ODE_API *dJointGetSliderParam)(dJointID, int parameter);
815 //void (ODE_API *dJointGetHinge2Anchor)(dJointID, dVector3 result);
816 //void (ODE_API *dJointGetHinge2Anchor2)(dJointID, dVector3 result);
817 //void (ODE_API *dJointGetHinge2Axis1)(dJointID, dVector3 result);
818 //void (ODE_API *dJointGetHinge2Axis2)(dJointID, dVector3 result);
819 //dReal (ODE_API *dJointGetHinge2Param)(dJointID, int parameter);
820 //dReal (ODE_API *dJointGetHinge2Angle1)(dJointID);
821 //dReal (ODE_API *dJointGetHinge2Angle1Rate)(dJointID);
822 //dReal (ODE_API *dJointGetHinge2Angle2Rate)(dJointID);
823 //void (ODE_API *dJointGetUniversalAnchor)(dJointID, dVector3 result);
824 //void (ODE_API *dJointGetUniversalAnchor2)(dJointID, dVector3 result);
825 //void (ODE_API *dJointGetUniversalAxis1)(dJointID, dVector3 result);
826 //void (ODE_API *dJointGetUniversalAxis2)(dJointID, dVector3 result);
827 //dReal (ODE_API *dJointGetUniversalParam)(dJointID, int parameter);
828 //void (ODE_API *dJointGetUniversalAngles)(dJointID, dReal *angle1, dReal *angle2);
829 //dReal (ODE_API *dJointGetUniversalAngle1)(dJointID);
830 //dReal (ODE_API *dJointGetUniversalAngle2)(dJointID);
831 //dReal (ODE_API *dJointGetUniversalAngle1Rate)(dJointID);
832 //dReal (ODE_API *dJointGetUniversalAngle2Rate)(dJointID);
833 //void (ODE_API *dJointGetPRAnchor)(dJointID, dVector3 result);
834 //dReal (ODE_API *dJointGetPRPosition)(dJointID);
835 //dReal (ODE_API *dJointGetPRPositionRate)(dJointID);
836 //dReal (ODE_API *dJointGetPRAngle)(dJointID);
837 //dReal (ODE_API *dJointGetPRAngleRate)(dJointID);
838 //void (ODE_API *dJointGetPRAxis1)(dJointID, dVector3 result);
839 //void (ODE_API *dJointGetPRAxis2)(dJointID, dVector3 result);
840 //dReal (ODE_API *dJointGetPRParam)(dJointID, int parameter);
841 //void (ODE_API *dJointGetPUAnchor)(dJointID, dVector3 result);
842 //dReal (ODE_API *dJointGetPUPosition)(dJointID);
843 //dReal (ODE_API *dJointGetPUPositionRate)(dJointID);
844 //void (ODE_API *dJointGetPUAxis1)(dJointID, dVector3 result);
845 //void (ODE_API *dJointGetPUAxis2)(dJointID, dVector3 result);
846 //void (ODE_API *dJointGetPUAxis3)(dJointID, dVector3 result);
847 //void (ODE_API *dJointGetPUAxisP)(dJointID id, dVector3 result);
848 //void (ODE_API *dJointGetPUAngles)(dJointID, dReal *angle1, dReal *angle2);
849 //dReal (ODE_API *dJointGetPUAngle1)(dJointID);
850 //dReal (ODE_API *dJointGetPUAngle1Rate)(dJointID);
851 //dReal (ODE_API *dJointGetPUAngle2)(dJointID);
852 //dReal (ODE_API *dJointGetPUAngle2Rate)(dJointID);
853 //dReal (ODE_API *dJointGetPUParam)(dJointID, int parameter);
854 //dReal (ODE_API *dJointGetPistonPosition)(dJointID);
855 //dReal (ODE_API *dJointGetPistonPositionRate)(dJointID);
856 //dReal (ODE_API *dJointGetPistonAngle)(dJointID);
857 //dReal (ODE_API *dJointGetPistonAngleRate)(dJointID);
858 //void (ODE_API *dJointGetPistonAnchor)(dJointID, dVector3 result);
859 //void (ODE_API *dJointGetPistonAnchor2)(dJointID, dVector3 result);
860 //void (ODE_API *dJointGetPistonAxis)(dJointID, dVector3 result);
861 //dReal (ODE_API *dJointGetPistonParam)(dJointID, int parameter);
862 //int (ODE_API *dJointGetAMotorNumAxes)(dJointID);
863 //void (ODE_API *dJointGetAMotorAxis)(dJointID, int anum, dVector3 result);
864 //int (ODE_API *dJointGetAMotorAxisRel)(dJointID, int anum);
865 //dReal (ODE_API *dJointGetAMotorAngle)(dJointID, int anum);
866 //dReal (ODE_API *dJointGetAMotorAngleRate)(dJointID, int anum);
867 //dReal (ODE_API *dJointGetAMotorParam)(dJointID, int parameter);
868 //int (ODE_API *dJointGetAMotorMode)(dJointID);
869 //int (ODE_API *dJointGetLMotorNumAxes)(dJointID);
870 //void (ODE_API *dJointGetLMotorAxis)(dJointID, int anum, dVector3 result);
871 //dReal (ODE_API *dJointGetLMotorParam)(dJointID, int parameter);
872 //dReal (ODE_API *dJointGetFixedParam)(dJointID, int parameter);
873 //dJointID (ODE_API *dConnectingJoint)(dBodyID, dBodyID);
874 //int (ODE_API *dConnectingJointList)(dBodyID, dBodyID, dJointID*);
875 int (ODE_API *dAreConnected)(dBodyID, dBodyID);
876 int (ODE_API *dAreConnectedExcluding)(dBodyID body1, dBodyID body2, int joint_type);
878 dSpaceID (ODE_API *dSimpleSpaceCreate)(dSpaceID space);
879 dSpaceID (ODE_API *dHashSpaceCreate)(dSpaceID space);
880 dSpaceID (ODE_API *dQuadTreeSpaceCreate)(dSpaceID space, const dVector3 Center, const dVector3 Extents, int Depth);
881 //dSpaceID (ODE_API *dSweepAndPruneSpaceCreate)( dSpaceID space, int axisorder );
882 void (ODE_API *dSpaceDestroy)(dSpaceID);
883 //void (ODE_API *dHashSpaceSetLevels)(dSpaceID space, int minlevel, int maxlevel);
884 //void (ODE_API *dHashSpaceGetLevels)(dSpaceID space, int *minlevel, int *maxlevel);
885 //void (ODE_API *dSpaceSetCleanup)(dSpaceID space, int mode);
886 //int (ODE_API *dSpaceGetCleanup)(dSpaceID space);
887 //void (ODE_API *dSpaceSetSublevel)(dSpaceID space, int sublevel);
888 //int (ODE_API *dSpaceGetSublevel)(dSpaceID space);
889 //void (ODE_API *dSpaceSetManualCleanup)(dSpaceID space, int mode);
890 //int (ODE_API *dSpaceGetManualCleanup)(dSpaceID space);
891 //void (ODE_API *dSpaceAdd)(dSpaceID, dGeomID);
892 //void (ODE_API *dSpaceRemove)(dSpaceID, dGeomID);
893 //int (ODE_API *dSpaceQuery)(dSpaceID, dGeomID);
894 //void (ODE_API *dSpaceClean)(dSpaceID);
895 //int (ODE_API *dSpaceGetNumGeoms)(dSpaceID);
896 //dGeomID (ODE_API *dSpaceGetGeom)(dSpaceID, int i);
897 //int (ODE_API *dSpaceGetClass)(dSpaceID space);
899 void (ODE_API *dGeomDestroy)(dGeomID geom);
900 void (ODE_API *dGeomSetData)(dGeomID geom, void* data);
901 void * (ODE_API *dGeomGetData)(dGeomID geom);
902 void (ODE_API *dGeomSetBody)(dGeomID geom, dBodyID body);
903 dBodyID (ODE_API *dGeomGetBody)(dGeomID geom);
904 void (ODE_API *dGeomSetPosition)(dGeomID geom, dReal x, dReal y, dReal z);
905 void (ODE_API *dGeomSetRotation)(dGeomID geom, const dMatrix3 R);
906 //void (ODE_API *dGeomSetQuaternion)(dGeomID geom, const dQuaternion Q);
907 //const dReal * (ODE_API *dGeomGetPosition)(dGeomID geom);
908 //void (ODE_API *dGeomCopyPosition)(dGeomID geom, dVector3 pos);
909 //const dReal * (ODE_API *dGeomGetRotation)(dGeomID geom);
910 //void (ODE_API *dGeomCopyRotation)(dGeomID geom, dMatrix3 R);
911 //void (ODE_API *dGeomGetQuaternion)(dGeomID geom, dQuaternion result);
912 //void (ODE_API *dGeomGetAABB)(dGeomID geom, dReal aabb[6]);
913 int (ODE_API *dGeomIsSpace)(dGeomID geom);
914 //dSpaceID (ODE_API *dGeomGetSpace)(dGeomID);
915 //int (ODE_API *dGeomGetClass)(dGeomID geom);
916 //void (ODE_API *dGeomSetCategoryBits)(dGeomID geom, unsigned long bits);
917 //void (ODE_API *dGeomSetCollideBits)(dGeomID geom, unsigned long bits);
918 //unsigned long (ODE_API *dGeomGetCategoryBits)(dGeomID);
919 //unsigned long (ODE_API *dGeomGetCollideBits)(dGeomID);
920 //void (ODE_API *dGeomEnable)(dGeomID geom);
921 //void (ODE_API *dGeomDisable)(dGeomID geom);
922 //int (ODE_API *dGeomIsEnabled)(dGeomID geom);
923 //void (ODE_API *dGeomSetOffsetPosition)(dGeomID geom, dReal x, dReal y, dReal z);
924 //void (ODE_API *dGeomSetOffsetRotation)(dGeomID geom, const dMatrix3 R);
925 //void (ODE_API *dGeomSetOffsetQuaternion)(dGeomID geom, const dQuaternion Q);
926 //void (ODE_API *dGeomSetOffsetWorldPosition)(dGeomID geom, dReal x, dReal y, dReal z);
927 //void (ODE_API *dGeomSetOffsetWorldRotation)(dGeomID geom, const dMatrix3 R);
928 //void (ODE_API *dGeomSetOffsetWorldQuaternion)(dGeomID geom, const dQuaternion);
929 //void (ODE_API *dGeomClearOffset)(dGeomID geom);
930 //int (ODE_API *dGeomIsOffset)(dGeomID geom);
931 //const dReal * (ODE_API *dGeomGetOffsetPosition)(dGeomID geom);
932 //void (ODE_API *dGeomCopyOffsetPosition)(dGeomID geom, dVector3 pos);
933 //const dReal * (ODE_API *dGeomGetOffsetRotation)(dGeomID geom);
934 //void (ODE_API *dGeomCopyOffsetRotation)(dGeomID geom, dMatrix3 R);
935 //void (ODE_API *dGeomGetOffsetQuaternion)(dGeomID geom, dQuaternion result);
936 int (ODE_API *dCollide)(dGeomID o1, dGeomID o2, int flags, dContactGeom *contact, int skip);
938 void (ODE_API *dSpaceCollide)(dSpaceID space, void *data, dNearCallback *callback);
939 void (ODE_API *dSpaceCollide2)(dGeomID space1, dGeomID space2, void *data, dNearCallback *callback);
941 dGeomID (ODE_API *dCreateSphere)(dSpaceID space, dReal radius);
942 //void (ODE_API *dGeomSphereSetRadius)(dGeomID sphere, dReal radius);
943 //dReal (ODE_API *dGeomSphereGetRadius)(dGeomID sphere);
944 //dReal (ODE_API *dGeomSpherePointDepth)(dGeomID sphere, dReal x, dReal y, dReal z);
946 //dGeomID (ODE_API *dCreateConvex)(dSpaceID space, dReal *_planes, unsigned int _planecount, dReal *_points, unsigned int _pointcount,unsigned int *_polygons);
947 //void (ODE_API *dGeomSetConvex)(dGeomID g, dReal *_planes, unsigned int _count, dReal *_points, unsigned int _pointcount,unsigned int *_polygons);
949 dGeomID (ODE_API *dCreateBox)(dSpaceID space, dReal lx, dReal ly, dReal lz);
950 //void (ODE_API *dGeomBoxSetLengths)(dGeomID box, dReal lx, dReal ly, dReal lz);
951 //void (ODE_API *dGeomBoxGetLengths)(dGeomID box, dVector3 result);
952 //dReal (ODE_API *dGeomBoxPointDepth)(dGeomID box, dReal x, dReal y, dReal z);
953 //dReal (ODE_API *dGeomBoxPointDepth)(dGeomID box, dReal x, dReal y, dReal z);
955 //dGeomID (ODE_API *dCreatePlane)(dSpaceID space, dReal a, dReal b, dReal c, dReal d);
956 //void (ODE_API *dGeomPlaneSetParams)(dGeomID plane, dReal a, dReal b, dReal c, dReal d);
957 //void (ODE_API *dGeomPlaneGetParams)(dGeomID plane, dVector4 result);
958 //dReal (ODE_API *dGeomPlanePointDepth)(dGeomID plane, dReal x, dReal y, dReal z);
960 dGeomID (ODE_API *dCreateCapsule)(dSpaceID space, dReal radius, dReal length);
961 //void (ODE_API *dGeomCapsuleSetParams)(dGeomID ccylinder, dReal radius, dReal length);
962 //void (ODE_API *dGeomCapsuleGetParams)(dGeomID ccylinder, dReal *radius, dReal *length);
963 //dReal (ODE_API *dGeomCapsulePointDepth)(dGeomID ccylinder, dReal x, dReal y, dReal z);
965 dGeomID (ODE_API *dCreateCylinder)(dSpaceID space, dReal radius, dReal length);
966 //void (ODE_API *dGeomCylinderSetParams)(dGeomID cylinder, dReal radius, dReal length);
967 //void (ODE_API *dGeomCylinderGetParams)(dGeomID cylinder, dReal *radius, dReal *length);
969 //dGeomID (ODE_API *dCreateRay)(dSpaceID space, dReal length);
970 //void (ODE_API *dGeomRaySetLength)(dGeomID ray, dReal length);
971 //dReal (ODE_API *dGeomRayGetLength)(dGeomID ray);
972 //void (ODE_API *dGeomRaySet)(dGeomID ray, dReal px, dReal py, dReal pz, dReal dx, dReal dy, dReal dz);
973 //void (ODE_API *dGeomRayGet)(dGeomID ray, dVector3 start, dVector3 dir);
975 dGeomID (ODE_API *dCreateGeomTransform)(dSpaceID space);
976 void (ODE_API *dGeomTransformSetGeom)(dGeomID g, dGeomID obj);
977 //dGeomID (ODE_API *dGeomTransformGetGeom)(dGeomID g);
978 void (ODE_API *dGeomTransformSetCleanup)(dGeomID g, int mode);
979 //int (ODE_API *dGeomTransformGetCleanup)(dGeomID g);
980 //void (ODE_API *dGeomTransformSetInfo)(dGeomID g, int mode);
981 //int (ODE_API *dGeomTransformGetInfo)(dGeomID g);
983 enum { TRIMESH_FACE_NORMALS };
984 typedef int dTriCallback(dGeomID TriMesh, dGeomID RefObject, int TriangleIndex);
985 typedef void dTriArrayCallback(dGeomID TriMesh, dGeomID RefObject, const int* TriIndices, int TriCount);
986 typedef int dTriRayCallback(dGeomID TriMesh, dGeomID Ray, int TriangleIndex, dReal u, dReal v);
987 typedef int dTriTriMergeCallback(dGeomID TriMesh, int FirstTriangleIndex, int SecondTriangleIndex);
989 dTriMeshDataID (ODE_API *dGeomTriMeshDataCreate)(void);
990 void (ODE_API *dGeomTriMeshDataDestroy)(dTriMeshDataID g);
991 //void (ODE_API *dGeomTriMeshDataSet)(dTriMeshDataID g, int data_id, void* in_data);
992 //void* (ODE_API *dGeomTriMeshDataGet)(dTriMeshDataID g, int data_id);
993 //void (*dGeomTriMeshSetLastTransform)( (ODE_API *dGeomID g, dMatrix4 last_trans );
994 //dReal* (*dGeomTriMeshGetLastTransform)( (ODE_API *dGeomID g );
995 void (ODE_API *dGeomTriMeshDataBuildSingle)(dTriMeshDataID g, const void* Vertices, int VertexStride, int VertexCount, const void* Indices, int IndexCount, int TriStride);
996 //void (ODE_API *dGeomTriMeshDataBuildSingle1)(dTriMeshDataID g, const void* Vertices, int VertexStride, int VertexCount, const void* Indices, int IndexCount, int TriStride, const void* Normals);
997 //void (ODE_API *dGeomTriMeshDataBuildDouble)(dTriMeshDataID g, const void* Vertices, int VertexStride, int VertexCount, const void* Indices, int IndexCount, int TriStride);
998 //void (ODE_API *dGeomTriMeshDataBuildDouble1)(dTriMeshDataID g, const void* Vertices, int VertexStride, int VertexCount, const void* Indices, int IndexCount, int TriStride, const void* Normals);
999 //void (ODE_API *dGeomTriMeshDataBuildSimple)(dTriMeshDataID g, const dReal* Vertices, int VertexCount, const dTriIndex* Indices, int IndexCount);
1000 //void (ODE_API *dGeomTriMeshDataBuildSimple1)(dTriMeshDataID g, const dReal* Vertices, int VertexCount, const dTriIndex* Indices, int IndexCount, const int* Normals);
1001 //void (ODE_API *dGeomTriMeshDataPreprocess)(dTriMeshDataID g);
1002 //void (ODE_API *dGeomTriMeshDataGetBuffer)(dTriMeshDataID g, unsigned char** buf, int* bufLen);
1003 //void (ODE_API *dGeomTriMeshDataSetBuffer)(dTriMeshDataID g, unsigned char* buf);
1004 //void (ODE_API *dGeomTriMeshSetCallback)(dGeomID g, dTriCallback* Callback);
1005 //dTriCallback* (ODE_API *dGeomTriMeshGetCallback)(dGeomID g);
1006 //void (ODE_API *dGeomTriMeshSetArrayCallback)(dGeomID g, dTriArrayCallback* ArrayCallback);
1007 //dTriArrayCallback* (ODE_API *dGeomTriMeshGetArrayCallback)(dGeomID g);
1008 //void (ODE_API *dGeomTriMeshSetRayCallback)(dGeomID g, dTriRayCallback* Callback);
1009 //dTriRayCallback* (ODE_API *dGeomTriMeshGetRayCallback)(dGeomID g);
1010 //void (ODE_API *dGeomTriMeshSetTriMergeCallback)(dGeomID g, dTriTriMergeCallback* Callback);
1011 //dTriTriMergeCallback* (ODE_API *dGeomTriMeshGetTriMergeCallback)(dGeomID g);
1012 dGeomID (ODE_API *dCreateTriMesh)(dSpaceID space, dTriMeshDataID Data, dTriCallback* Callback, dTriArrayCallback* ArrayCallback, dTriRayCallback* RayCallback);
1013 //void (ODE_API *dGeomTriMeshSetData)(dGeomID g, dTriMeshDataID Data);
1014 //dTriMeshDataID (ODE_API *dGeomTriMeshGetData)(dGeomID g);
1015 //void (ODE_API *dGeomTriMeshEnableTC)(dGeomID g, int geomClass, int enable);
1016 //int (ODE_API *dGeomTriMeshIsTCEnabled)(dGeomID g, int geomClass);
1017 //void (ODE_API *dGeomTriMeshClearTCCache)(dGeomID g);
1018 //dTriMeshDataID (ODE_API *dGeomTriMeshGetTriMeshDataID)(dGeomID g);
1019 //void (ODE_API *dGeomTriMeshGetTriangle)(dGeomID g, int Index, dVector3* v0, dVector3* v1, dVector3* v2);
1020 //void (ODE_API *dGeomTriMeshGetPoint)(dGeomID g, int Index, dReal u, dReal v, dVector3 Out);
1021 //int (ODE_API *dGeomTriMeshGetTriangleCount )(dGeomID g);
1022 //void (ODE_API *dGeomTriMeshDataUpdate)(dTriMeshDataID g);
1024 static dllfunction_t odefuncs[] =
1026 // {"dGetConfiguration", (void **) &dGetConfiguration},
1027 {"dCheckConfiguration", (void **) &dCheckConfiguration},
1028 {"dInitODE", (void **) &dInitODE},
1029 // {"dInitODE2", (void **) &dInitODE2},
1030 // {"dAllocateODEDataForThread", (void **) &dAllocateODEDataForThread},
1031 // {"dCleanupODEAllDataForThread", (void **) &dCleanupODEAllDataForThread},
1032 {"dCloseODE", (void **) &dCloseODE},
1033 // {"dMassCheck", (void **) &dMassCheck},
1034 // {"dMassSetZero", (void **) &dMassSetZero},
1035 // {"dMassSetParameters", (void **) &dMassSetParameters},
1036 // {"dMassSetSphere", (void **) &dMassSetSphere},
1037 {"dMassSetSphereTotal", (void **) &dMassSetSphereTotal},
1038 // {"dMassSetCapsule", (void **) &dMassSetCapsule},
1039 {"dMassSetCapsuleTotal", (void **) &dMassSetCapsuleTotal},
1040 // {"dMassSetCylinder", (void **) &dMassSetCylinder},
1041 {"dMassSetCylinderTotal", (void **) &dMassSetCylinderTotal},
1042 // {"dMassSetBox", (void **) &dMassSetBox},
1043 {"dMassSetBoxTotal", (void **) &dMassSetBoxTotal},
1044 // {"dMassSetTrimesh", (void **) &dMassSetTrimesh},
1045 // {"dMassSetTrimeshTotal", (void **) &dMassSetTrimeshTotal},
1046 // {"dMassAdjust", (void **) &dMassAdjust},
1047 // {"dMassTranslate", (void **) &dMassTranslate},
1048 // {"dMassRotate", (void **) &dMassRotate},
1049 // {"dMassAdd", (void **) &dMassAdd},
1051 {"dWorldCreate", (void **) &dWorldCreate},
1052 {"dWorldDestroy", (void **) &dWorldDestroy},
1053 {"dWorldSetGravity", (void **) &dWorldSetGravity},
1054 {"dWorldGetGravity", (void **) &dWorldGetGravity},
1055 {"dWorldSetERP", (void **) &dWorldSetERP},
1056 // {"dWorldGetERP", (void **) &dWorldGetERP},
1057 {"dWorldSetCFM", (void **) &dWorldSetCFM},
1058 // {"dWorldGetCFM", (void **) &dWorldGetCFM},
1059 {"dWorldStep", (void **) &dWorldStep},
1060 // {"dWorldImpulseToForce", (void **) &dWorldImpulseToForce},
1061 {"dWorldQuickStep", (void **) &dWorldQuickStep},
1062 {"dWorldSetQuickStepNumIterations", (void **) &dWorldSetQuickStepNumIterations},
1063 // {"dWorldGetQuickStepNumIterations", (void **) &dWorldGetQuickStepNumIterations},
1064 // {"dWorldSetQuickStepW", (void **) &dWorldSetQuickStepW},
1065 // {"dWorldGetQuickStepW", (void **) &dWorldGetQuickStepW},
1066 // {"dWorldSetContactMaxCorrectingVel", (void **) &dWorldSetContactMaxCorrectingVel},
1067 // {"dWorldGetContactMaxCorrectingVel", (void **) &dWorldGetContactMaxCorrectingVel},
1068 {"dWorldSetContactSurfaceLayer", (void **) &dWorldSetContactSurfaceLayer},
1069 // {"dWorldGetContactSurfaceLayer", (void **) &dWorldGetContactSurfaceLayer},
1070 #ifdef ODE_USE_STEPFAST
1071 {"dWorldStepFast1", (void **) &dWorldStepFast1},
1073 // {"dWorldSetAutoEnableDepthSF1", (void **) &dWorldSetAutoEnableDepthSF1},
1074 // {"dWorldGetAutoEnableDepthSF1", (void **) &dWorldGetAutoEnableDepthSF1},
1075 // {"dWorldGetAutoDisableLinearThreshold", (void **) &dWorldGetAutoDisableLinearThreshold},
1076 {"dWorldSetAutoDisableLinearThreshold", (void **) &dWorldSetAutoDisableLinearThreshold},
1077 // {"dWorldGetAutoDisableAngularThreshold", (void **) &dWorldGetAutoDisableAngularThreshold},
1078 {"dWorldSetAutoDisableAngularThreshold", (void **) &dWorldSetAutoDisableAngularThreshold},
1079 // {"dWorldGetAutoDisableLinearAverageThreshold", (void **) &dWorldGetAutoDisableLinearAverageThreshold},
1080 // {"dWorldSetAutoDisableLinearAverageThreshold", (void **) &dWorldSetAutoDisableLinearAverageThreshold},
1081 // {"dWorldGetAutoDisableAngularAverageThreshold", (void **) &dWorldGetAutoDisableAngularAverageThreshold},
1082 // {"dWorldSetAutoDisableAngularAverageThreshold", (void **) &dWorldSetAutoDisableAngularAverageThreshold},
1083 // {"dWorldGetAutoDisableAverageSamplesCount", (void **) &dWorldGetAutoDisableAverageSamplesCount},
1084 {"dWorldSetAutoDisableAverageSamplesCount", (void **) &dWorldSetAutoDisableAverageSamplesCount},
1085 // {"dWorldGetAutoDisableSteps", (void **) &dWorldGetAutoDisableSteps},
1086 {"dWorldSetAutoDisableSteps", (void **) &dWorldSetAutoDisableSteps},
1087 // {"dWorldGetAutoDisableTime", (void **) &dWorldGetAutoDisableTime},
1088 {"dWorldSetAutoDisableTime", (void **) &dWorldSetAutoDisableTime},
1089 // {"dWorldGetAutoDisableFlag", (void **) &dWorldGetAutoDisableFlag},
1090 {"dWorldSetAutoDisableFlag", (void **) &dWorldSetAutoDisableFlag},
1091 // {"dWorldGetLinearDampingThreshold", (void **) &dWorldGetLinearDampingThreshold},
1092 {"dWorldSetLinearDampingThreshold", (void **) &dWorldSetLinearDampingThreshold},
1093 // {"dWorldGetAngularDampingThreshold", (void **) &dWorldGetAngularDampingThreshold},
1094 {"dWorldSetAngularDampingThreshold", (void **) &dWorldSetAngularDampingThreshold},
1095 // {"dWorldGetLinearDamping", (void **) &dWorldGetLinearDamping},
1096 {"dWorldSetLinearDamping", (void **) &dWorldSetLinearDamping},
1097 // {"dWorldGetAngularDamping", (void **) &dWorldGetAngularDamping},
1098 {"dWorldSetAngularDamping", (void **) &dWorldSetAngularDamping},
1099 // {"dWorldSetDamping", (void **) &dWorldSetDamping},
1100 // {"dWorldGetMaxAngularSpeed", (void **) &dWorldGetMaxAngularSpeed},
1101 // {"dWorldSetMaxAngularSpeed", (void **) &dWorldSetMaxAngularSpeed},
1102 // {"dBodyGetAutoDisableLinearThreshold", (void **) &dBodyGetAutoDisableLinearThreshold},
1103 // {"dBodySetAutoDisableLinearThreshold", (void **) &dBodySetAutoDisableLinearThreshold},
1104 // {"dBodyGetAutoDisableAngularThreshold", (void **) &dBodyGetAutoDisableAngularThreshold},
1105 // {"dBodySetAutoDisableAngularThreshold", (void **) &dBodySetAutoDisableAngularThreshold},
1106 // {"dBodyGetAutoDisableAverageSamplesCount", (void **) &dBodyGetAutoDisableAverageSamplesCount},
1107 // {"dBodySetAutoDisableAverageSamplesCount", (void **) &dBodySetAutoDisableAverageSamplesCount},
1108 // {"dBodyGetAutoDisableSteps", (void **) &dBodyGetAutoDisableSteps},
1109 // {"dBodySetAutoDisableSteps", (void **) &dBodySetAutoDisableSteps},
1110 // {"dBodyGetAutoDisableTime", (void **) &dBodyGetAutoDisableTime},
1111 // {"dBodySetAutoDisableTime", (void **) &dBodySetAutoDisableTime},
1112 // {"dBodyGetAutoDisableFlag", (void **) &dBodyGetAutoDisableFlag},
1113 // {"dBodySetAutoDisableFlag", (void **) &dBodySetAutoDisableFlag},
1114 // {"dBodySetAutoDisableDefaults", (void **) &dBodySetAutoDisableDefaults},
1115 // {"dBodyGetWorld", (void **) &dBodyGetWorld},
1116 {"dBodyCreate", (void **) &dBodyCreate},
1117 {"dBodyDestroy", (void **) &dBodyDestroy},
1118 {"dBodySetData", (void **) &dBodySetData},
1119 {"dBodyGetData", (void **) &dBodyGetData},
1120 {"dBodySetPosition", (void **) &dBodySetPosition},
1121 {"dBodySetRotation", (void **) &dBodySetRotation},
1122 // {"dBodySetQuaternion", (void **) &dBodySetQuaternion},
1123 {"dBodySetLinearVel", (void **) &dBodySetLinearVel},
1124 {"dBodySetAngularVel", (void **) &dBodySetAngularVel},
1125 {"dBodyGetPosition", (void **) &dBodyGetPosition},
1126 // {"dBodyCopyPosition", (void **) &dBodyCopyPosition},
1127 {"dBodyGetRotation", (void **) &dBodyGetRotation},
1128 // {"dBodyCopyRotation", (void **) &dBodyCopyRotation},
1129 // {"dBodyGetQuaternion", (void **) &dBodyGetQuaternion},
1130 // {"dBodyCopyQuaternion", (void **) &dBodyCopyQuaternion},
1131 {"dBodyGetLinearVel", (void **) &dBodyGetLinearVel},
1132 {"dBodyGetAngularVel", (void **) &dBodyGetAngularVel},
1133 {"dBodySetMass", (void **) &dBodySetMass},
1134 // {"dBodyGetMass", (void **) &dBodyGetMass},
1135 // {"dBodyAddForce", (void **) &dBodyAddForce},
1136 // {"dBodyAddTorque", (void **) &dBodyAddTorque},
1137 // {"dBodyAddRelForce", (void **) &dBodyAddRelForce},
1138 {"dBodyAddRelTorque", (void **) &dBodyAddRelTorque},
1139 // {"dBodyAddForceAtPos", (void **) &dBodyAddForceAtPos},
1140 {"dBodyAddForceAtRelPos", (void **) &dBodyAddForceAtRelPos},
1141 // {"dBodyAddRelForceAtPos", (void **) &dBodyAddRelForceAtPos},
1142 // {"dBodyAddRelForceAtRelPos", (void **) &dBodyAddRelForceAtRelPos},
1143 // {"dBodyGetForce", (void **) &dBodyGetForce},
1144 // {"dBodyGetTorque", (void **) &dBodyGetTorque},
1145 // {"dBodySetForce", (void **) &dBodySetForce},
1146 // {"dBodySetTorque", (void **) &dBodySetTorque},
1147 // {"dBodyGetRelPointPos", (void **) &dBodyGetRelPointPos},
1148 // {"dBodyGetRelPointVel", (void **) &dBodyGetRelPointVel},
1149 // {"dBodyGetPointVel", (void **) &dBodyGetPointVel},
1150 // {"dBodyGetPosRelPoint", (void **) &dBodyGetPosRelPoint},
1151 // {"dBodyVectorToWorld", (void **) &dBodyVectorToWorld},
1152 // {"dBodyVectorFromWorld", (void **) &dBodyVectorFromWorld},
1153 // {"dBodySetFiniteRotationMode", (void **) &dBodySetFiniteRotationMode},
1154 // {"dBodySetFiniteRotationAxis", (void **) &dBodySetFiniteRotationAxis},
1155 // {"dBodyGetFiniteRotationMode", (void **) &dBodyGetFiniteRotationMode},
1156 // {"dBodyGetFiniteRotationAxis", (void **) &dBodyGetFiniteRotationAxis},
1157 {"dBodyGetNumJoints", (void **) &dBodyGetNumJoints},
1158 {"dBodyGetJoint", (void **) &dBodyGetJoint},
1159 // {"dBodySetDynamic", (void **) &dBodySetDynamic},
1160 // {"dBodySetKinematic", (void **) &dBodySetKinematic},
1161 // {"dBodyIsKinematic", (void **) &dBodyIsKinematic},
1162 {"dBodyEnable", (void **) &dBodyEnable},
1163 {"dBodyDisable", (void **) &dBodyDisable},
1164 {"dBodyIsEnabled", (void **) &dBodyIsEnabled},
1165 {"dBodySetGravityMode", (void **) &dBodySetGravityMode},
1166 {"dBodyGetGravityMode", (void **) &dBodyGetGravityMode},
1167 // {"dBodySetMovedCallback", (void **) &dBodySetMovedCallback},
1168 // {"dBodyGetFirstGeom", (void **) &dBodyGetFirstGeom},
1169 // {"dBodyGetNextGeom", (void **) &dBodyGetNextGeom},
1170 // {"dBodySetDampingDefaults", (void **) &dBodySetDampingDefaults},
1171 // {"dBodyGetLinearDamping", (void **) &dBodyGetLinearDamping},
1172 // {"dBodySetLinearDamping", (void **) &dBodySetLinearDamping},
1173 // {"dBodyGetAngularDamping", (void **) &dBodyGetAngularDamping},
1174 // {"dBodySetAngularDamping", (void **) &dBodySetAngularDamping},
1175 // {"dBodySetDamping", (void **) &dBodySetDamping},
1176 // {"dBodyGetLinearDampingThreshold", (void **) &dBodyGetLinearDampingThreshold},
1177 // {"dBodySetLinearDampingThreshold", (void **) &dBodySetLinearDampingThreshold},
1178 // {"dBodyGetAngularDampingThreshold", (void **) &dBodyGetAngularDampingThreshold},
1179 // {"dBodySetAngularDampingThreshold", (void **) &dBodySetAngularDampingThreshold},
1180 // {"dBodyGetMaxAngularSpeed", (void **) &dBodyGetMaxAngularSpeed},
1181 // {"dBodySetMaxAngularSpeed", (void **) &dBodySetMaxAngularSpeed},
1182 // {"dBodyGetGyroscopicMode", (void **) &dBodyGetGyroscopicMode},
1183 // {"dBodySetGyroscopicMode", (void **) &dBodySetGyroscopicMode},
1184 {"dJointCreateBall", (void **) &dJointCreateBall},
1185 {"dJointCreateHinge", (void **) &dJointCreateHinge},
1186 {"dJointCreateSlider", (void **) &dJointCreateSlider},
1187 {"dJointCreateContact", (void **) &dJointCreateContact},
1188 {"dJointCreateHinge2", (void **) &dJointCreateHinge2},
1189 {"dJointCreateUniversal", (void **) &dJointCreateUniversal},
1190 // {"dJointCreatePR", (void **) &dJointCreatePR},
1191 // {"dJointCreatePU", (void **) &dJointCreatePU},
1192 // {"dJointCreatePiston", (void **) &dJointCreatePiston},
1193 {"dJointCreateFixed", (void **) &dJointCreateFixed},
1194 // {"dJointCreateNull", (void **) &dJointCreateNull},
1195 // {"dJointCreateAMotor", (void **) &dJointCreateAMotor},
1196 // {"dJointCreateLMotor", (void **) &dJointCreateLMotor},
1197 // {"dJointCreatePlane2D", (void **) &dJointCreatePlane2D},
1198 {"dJointDestroy", (void **) &dJointDestroy},
1199 {"dJointGroupCreate", (void **) &dJointGroupCreate},
1200 {"dJointGroupDestroy", (void **) &dJointGroupDestroy},
1201 {"dJointGroupEmpty", (void **) &dJointGroupEmpty},
1202 // {"dJointGetNumBodies", (void **) &dJointGetNumBodies},
1203 {"dJointAttach", (void **) &dJointAttach},
1204 // {"dJointEnable", (void **) &dJointEnable},
1205 // {"dJointDisable", (void **) &dJointDisable},
1206 // {"dJointIsEnabled", (void **) &dJointIsEnabled},
1207 {"dJointSetData", (void **) &dJointSetData},
1208 {"dJointGetData", (void **) &dJointGetData},
1209 // {"dJointGetType", (void **) &dJointGetType},
1210 {"dJointGetBody", (void **) &dJointGetBody},
1211 // {"dJointSetFeedback", (void **) &dJointSetFeedback},
1212 // {"dJointGetFeedback", (void **) &dJointGetFeedback},
1213 {"dJointSetBallAnchor", (void **) &dJointSetBallAnchor},
1214 // {"dJointSetBallAnchor2", (void **) &dJointSetBallAnchor2},
1215 {"dJointSetBallParam", (void **) &dJointSetBallParam},
1216 {"dJointSetHingeAnchor", (void **) &dJointSetHingeAnchor},
1217 // {"dJointSetHingeAnchorDelta", (void **) &dJointSetHingeAnchorDelta},
1218 {"dJointSetHingeAxis", (void **) &dJointSetHingeAxis},
1219 // {"dJointSetHingeAxisOffset", (void **) &dJointSetHingeAxisOffset},
1220 {"dJointSetHingeParam", (void **) &dJointSetHingeParam},
1221 // {"dJointAddHingeTorque", (void **) &dJointAddHingeTorque},
1222 {"dJointSetSliderAxis", (void **) &dJointSetSliderAxis},
1223 // {"dJointSetSliderAxisDelta", (void **) &dJointSetSliderAxisDelta},
1224 {"dJointSetSliderParam", (void **) &dJointSetSliderParam},
1225 // {"dJointAddSliderForce", (void **) &dJointAddSliderForce},
1226 {"dJointSetHinge2Anchor", (void **) &dJointSetHinge2Anchor},
1227 {"dJointSetHinge2Axis1", (void **) &dJointSetHinge2Axis1},
1228 {"dJointSetHinge2Axis2", (void **) &dJointSetHinge2Axis2},
1229 {"dJointSetHinge2Param", (void **) &dJointSetHinge2Param},
1230 // {"dJointAddHinge2Torques", (void **) &dJointAddHinge2Torques},
1231 {"dJointSetUniversalAnchor", (void **) &dJointSetUniversalAnchor},
1232 {"dJointSetUniversalAxis1", (void **) &dJointSetUniversalAxis1},
1233 // {"dJointSetUniversalAxis1Offset", (void **) &dJointSetUniversalAxis1Offset},
1234 {"dJointSetUniversalAxis2", (void **) &dJointSetUniversalAxis2},
1235 // {"dJointSetUniversalAxis2Offset", (void **) &dJointSetUniversalAxis2Offset},
1236 {"dJointSetUniversalParam", (void **) &dJointSetUniversalParam},
1237 // {"dJointAddUniversalTorques", (void **) &dJointAddUniversalTorques},
1238 // {"dJointSetPRAnchor", (void **) &dJointSetPRAnchor},
1239 // {"dJointSetPRAxis1", (void **) &dJointSetPRAxis1},
1240 // {"dJointSetPRAxis2", (void **) &dJointSetPRAxis2},
1241 // {"dJointSetPRParam", (void **) &dJointSetPRParam},
1242 // {"dJointAddPRTorque", (void **) &dJointAddPRTorque},
1243 // {"dJointSetPUAnchor", (void **) &dJointSetPUAnchor},
1244 // {"dJointSetPUAnchorOffset", (void **) &dJointSetPUAnchorOffset},
1245 // {"dJointSetPUAxis1", (void **) &dJointSetPUAxis1},
1246 // {"dJointSetPUAxis2", (void **) &dJointSetPUAxis2},
1247 // {"dJointSetPUAxis3", (void **) &dJointSetPUAxis3},
1248 // {"dJointSetPUAxisP", (void **) &dJointSetPUAxisP},
1249 // {"dJointSetPUParam", (void **) &dJointSetPUParam},
1250 // {"dJointAddPUTorque", (void **) &dJointAddPUTorque},
1251 // {"dJointSetPistonAnchor", (void **) &dJointSetPistonAnchor},
1252 // {"dJointSetPistonAnchorOffset", (void **) &dJointSetPistonAnchorOffset},
1253 // {"dJointSetPistonParam", (void **) &dJointSetPistonParam},
1254 // {"dJointAddPistonForce", (void **) &dJointAddPistonForce},
1255 // {"dJointSetFixed", (void **) &dJointSetFixed},
1256 // {"dJointSetFixedParam", (void **) &dJointSetFixedParam},
1257 // {"dJointSetAMotorNumAxes", (void **) &dJointSetAMotorNumAxes},
1258 // {"dJointSetAMotorAxis", (void **) &dJointSetAMotorAxis},
1259 // {"dJointSetAMotorAngle", (void **) &dJointSetAMotorAngle},
1260 // {"dJointSetAMotorParam", (void **) &dJointSetAMotorParam},
1261 // {"dJointSetAMotorMode", (void **) &dJointSetAMotorMode},
1262 // {"dJointAddAMotorTorques", (void **) &dJointAddAMotorTorques},
1263 // {"dJointSetLMotorNumAxes", (void **) &dJointSetLMotorNumAxes},
1264 // {"dJointSetLMotorAxis", (void **) &dJointSetLMotorAxis},
1265 // {"dJointSetLMotorParam", (void **) &dJointSetLMotorParam},
1266 // {"dJointSetPlane2DXParam", (void **) &dJointSetPlane2DXParam},
1267 // {"dJointSetPlane2DYParam", (void **) &dJointSetPlane2DYParam},
1268 // {"dJointSetPlane2DAngleParam", (void **) &dJointSetPlane2DAngleParam},
1269 // {"dJointGetBallAnchor", (void **) &dJointGetBallAnchor},
1270 // {"dJointGetBallAnchor2", (void **) &dJointGetBallAnchor2},
1271 // {"dJointGetBallParam", (void **) &dJointGetBallParam},
1272 // {"dJointGetHingeAnchor", (void **) &dJointGetHingeAnchor},
1273 // {"dJointGetHingeAnchor2", (void **) &dJointGetHingeAnchor2},
1274 // {"dJointGetHingeAxis", (void **) &dJointGetHingeAxis},
1275 // {"dJointGetHingeParam", (void **) &dJointGetHingeParam},
1276 // {"dJointGetHingeAngle", (void **) &dJointGetHingeAngle},
1277 // {"dJointGetHingeAngleRate", (void **) &dJointGetHingeAngleRate},
1278 // {"dJointGetSliderPosition", (void **) &dJointGetSliderPosition},
1279 // {"dJointGetSliderPositionRate", (void **) &dJointGetSliderPositionRate},
1280 // {"dJointGetSliderAxis", (void **) &dJointGetSliderAxis},
1281 // {"dJointGetSliderParam", (void **) &dJointGetSliderParam},
1282 // {"dJointGetHinge2Anchor", (void **) &dJointGetHinge2Anchor},
1283 // {"dJointGetHinge2Anchor2", (void **) &dJointGetHinge2Anchor2},
1284 // {"dJointGetHinge2Axis1", (void **) &dJointGetHinge2Axis1},
1285 // {"dJointGetHinge2Axis2", (void **) &dJointGetHinge2Axis2},
1286 // {"dJointGetHinge2Param", (void **) &dJointGetHinge2Param},
1287 // {"dJointGetHinge2Angle1", (void **) &dJointGetHinge2Angle1},
1288 // {"dJointGetHinge2Angle1Rate", (void **) &dJointGetHinge2Angle1Rate},
1289 // {"dJointGetHinge2Angle2Rate", (void **) &dJointGetHinge2Angle2Rate},
1290 // {"dJointGetUniversalAnchor", (void **) &dJointGetUniversalAnchor},
1291 // {"dJointGetUniversalAnchor2", (void **) &dJointGetUniversalAnchor2},
1292 // {"dJointGetUniversalAxis1", (void **) &dJointGetUniversalAxis1},
1293 // {"dJointGetUniversalAxis2", (void **) &dJointGetUniversalAxis2},
1294 // {"dJointGetUniversalParam", (void **) &dJointGetUniversalParam},
1295 // {"dJointGetUniversalAngles", (void **) &dJointGetUniversalAngles},
1296 // {"dJointGetUniversalAngle1", (void **) &dJointGetUniversalAngle1},
1297 // {"dJointGetUniversalAngle2", (void **) &dJointGetUniversalAngle2},
1298 // {"dJointGetUniversalAngle1Rate", (void **) &dJointGetUniversalAngle1Rate},
1299 // {"dJointGetUniversalAngle2Rate", (void **) &dJointGetUniversalAngle2Rate},
1300 // {"dJointGetPRAnchor", (void **) &dJointGetPRAnchor},
1301 // {"dJointGetPRPosition", (void **) &dJointGetPRPosition},
1302 // {"dJointGetPRPositionRate", (void **) &dJointGetPRPositionRate},
1303 // {"dJointGetPRAngle", (void **) &dJointGetPRAngle},
1304 // {"dJointGetPRAngleRate", (void **) &dJointGetPRAngleRate},
1305 // {"dJointGetPRAxis1", (void **) &dJointGetPRAxis1},
1306 // {"dJointGetPRAxis2", (void **) &dJointGetPRAxis2},
1307 // {"dJointGetPRParam", (void **) &dJointGetPRParam},
1308 // {"dJointGetPUAnchor", (void **) &dJointGetPUAnchor},
1309 // {"dJointGetPUPosition", (void **) &dJointGetPUPosition},
1310 // {"dJointGetPUPositionRate", (void **) &dJointGetPUPositionRate},
1311 // {"dJointGetPUAxis1", (void **) &dJointGetPUAxis1},
1312 // {"dJointGetPUAxis2", (void **) &dJointGetPUAxis2},
1313 // {"dJointGetPUAxis3", (void **) &dJointGetPUAxis3},
1314 // {"dJointGetPUAxisP", (void **) &dJointGetPUAxisP},
1315 // {"dJointGetPUAngles", (void **) &dJointGetPUAngles},
1316 // {"dJointGetPUAngle1", (void **) &dJointGetPUAngle1},
1317 // {"dJointGetPUAngle1Rate", (void **) &dJointGetPUAngle1Rate},
1318 // {"dJointGetPUAngle2", (void **) &dJointGetPUAngle2},
1319 // {"dJointGetPUAngle2Rate", (void **) &dJointGetPUAngle2Rate},
1320 // {"dJointGetPUParam", (void **) &dJointGetPUParam},
1321 // {"dJointGetPistonPosition", (void **) &dJointGetPistonPosition},
1322 // {"dJointGetPistonPositionRate", (void **) &dJointGetPistonPositionRate},
1323 // {"dJointGetPistonAngle", (void **) &dJointGetPistonAngle},
1324 // {"dJointGetPistonAngleRate", (void **) &dJointGetPistonAngleRate},
1325 // {"dJointGetPistonAnchor", (void **) &dJointGetPistonAnchor},
1326 // {"dJointGetPistonAnchor2", (void **) &dJointGetPistonAnchor2},
1327 // {"dJointGetPistonAxis", (void **) &dJointGetPistonAxis},
1328 // {"dJointGetPistonParam", (void **) &dJointGetPistonParam},
1329 // {"dJointGetAMotorNumAxes", (void **) &dJointGetAMotorNumAxes},
1330 // {"dJointGetAMotorAxis", (void **) &dJointGetAMotorAxis},
1331 // {"dJointGetAMotorAxisRel", (void **) &dJointGetAMotorAxisRel},
1332 // {"dJointGetAMotorAngle", (void **) &dJointGetAMotorAngle},
1333 // {"dJointGetAMotorAngleRate", (void **) &dJointGetAMotorAngleRate},
1334 // {"dJointGetAMotorParam", (void **) &dJointGetAMotorParam},
1335 // {"dJointGetAMotorMode", (void **) &dJointGetAMotorMode},
1336 // {"dJointGetLMotorNumAxes", (void **) &dJointGetLMotorNumAxes},
1337 // {"dJointGetLMotorAxis", (void **) &dJointGetLMotorAxis},
1338 // {"dJointGetLMotorParam", (void **) &dJointGetLMotorParam},
1339 // {"dJointGetFixedParam", (void **) &dJointGetFixedParam},
1340 // {"dConnectingJoint", (void **) &dConnectingJoint},
1341 // {"dConnectingJointList", (void **) &dConnectingJointList},
1342 {"dAreConnected", (void **) &dAreConnected},
1343 {"dAreConnectedExcluding", (void **) &dAreConnectedExcluding},
1344 {"dSimpleSpaceCreate", (void **) &dSimpleSpaceCreate},
1345 {"dHashSpaceCreate", (void **) &dHashSpaceCreate},
1346 {"dQuadTreeSpaceCreate", (void **) &dQuadTreeSpaceCreate},
1347 // {"dSweepAndPruneSpaceCreate", (void **) &dSweepAndPruneSpaceCreate},
1348 {"dSpaceDestroy", (void **) &dSpaceDestroy},
1349 // {"dHashSpaceSetLevels", (void **) &dHashSpaceSetLevels},
1350 // {"dHashSpaceGetLevels", (void **) &dHashSpaceGetLevels},
1351 // {"dSpaceSetCleanup", (void **) &dSpaceSetCleanup},
1352 // {"dSpaceGetCleanup", (void **) &dSpaceGetCleanup},
1353 // {"dSpaceSetSublevel", (void **) &dSpaceSetSublevel},
1354 // {"dSpaceGetSublevel", (void **) &dSpaceGetSublevel},
1355 // {"dSpaceSetManualCleanup", (void **) &dSpaceSetManualCleanup},
1356 // {"dSpaceGetManualCleanup", (void **) &dSpaceGetManualCleanup},
1357 // {"dSpaceAdd", (void **) &dSpaceAdd},
1358 // {"dSpaceRemove", (void **) &dSpaceRemove},
1359 // {"dSpaceQuery", (void **) &dSpaceQuery},
1360 // {"dSpaceClean", (void **) &dSpaceClean},
1361 // {"dSpaceGetNumGeoms", (void **) &dSpaceGetNumGeoms},
1362 // {"dSpaceGetGeom", (void **) &dSpaceGetGeom},
1363 // {"dSpaceGetClass", (void **) &dSpaceGetClass},
1364 {"dGeomDestroy", (void **) &dGeomDestroy},
1365 {"dGeomSetData", (void **) &dGeomSetData},
1366 {"dGeomGetData", (void **) &dGeomGetData},
1367 {"dGeomSetBody", (void **) &dGeomSetBody},
1368 {"dGeomGetBody", (void **) &dGeomGetBody},
1369 {"dGeomSetPosition", (void **) &dGeomSetPosition},
1370 {"dGeomSetRotation", (void **) &dGeomSetRotation},
1371 // {"dGeomSetQuaternion", (void **) &dGeomSetQuaternion},
1372 // {"dGeomGetPosition", (void **) &dGeomGetPosition},
1373 // {"dGeomCopyPosition", (void **) &dGeomCopyPosition},
1374 // {"dGeomGetRotation", (void **) &dGeomGetRotation},
1375 // {"dGeomCopyRotation", (void **) &dGeomCopyRotation},
1376 // {"dGeomGetQuaternion", (void **) &dGeomGetQuaternion},
1377 // {"dGeomGetAABB", (void **) &dGeomGetAABB},
1378 {"dGeomIsSpace", (void **) &dGeomIsSpace},
1379 // {"dGeomGetSpace", (void **) &dGeomGetSpace},
1380 // {"dGeomGetClass", (void **) &dGeomGetClass},
1381 // {"dGeomSetCategoryBits", (void **) &dGeomSetCategoryBits},
1382 // {"dGeomSetCollideBits", (void **) &dGeomSetCollideBits},
1383 // {"dGeomGetCategoryBits", (void **) &dGeomGetCategoryBits},
1384 // {"dGeomGetCollideBits", (void **) &dGeomGetCollideBits},
1385 // {"dGeomEnable", (void **) &dGeomEnable},
1386 // {"dGeomDisable", (void **) &dGeomDisable},
1387 // {"dGeomIsEnabled", (void **) &dGeomIsEnabled},
1388 // {"dGeomSetOffsetPosition", (void **) &dGeomSetOffsetPosition},
1389 // {"dGeomSetOffsetRotation", (void **) &dGeomSetOffsetRotation},
1390 // {"dGeomSetOffsetQuaternion", (void **) &dGeomSetOffsetQuaternion},
1391 // {"dGeomSetOffsetWorldPosition", (void **) &dGeomSetOffsetWorldPosition},
1392 // {"dGeomSetOffsetWorldRotation", (void **) &dGeomSetOffsetWorldRotation},
1393 // {"dGeomSetOffsetWorldQuaternion", (void **) &dGeomSetOffsetWorldQuaternion},
1394 // {"dGeomClearOffset", (void **) &dGeomClearOffset},
1395 // {"dGeomIsOffset", (void **) &dGeomIsOffset},
1396 // {"dGeomGetOffsetPosition", (void **) &dGeomGetOffsetPosition},
1397 // {"dGeomCopyOffsetPosition", (void **) &dGeomCopyOffsetPosition},
1398 // {"dGeomGetOffsetRotation", (void **) &dGeomGetOffsetRotation},
1399 // {"dGeomCopyOffsetRotation", (void **) &dGeomCopyOffsetRotation},
1400 // {"dGeomGetOffsetQuaternion", (void **) &dGeomGetOffsetQuaternion},
1401 {"dCollide", (void **) &dCollide},
1402 {"dSpaceCollide", (void **) &dSpaceCollide},
1403 {"dSpaceCollide2", (void **) &dSpaceCollide2},
1404 {"dCreateSphere", (void **) &dCreateSphere},
1405 // {"dGeomSphereSetRadius", (void **) &dGeomSphereSetRadius},
1406 // {"dGeomSphereGetRadius", (void **) &dGeomSphereGetRadius},
1407 // {"dGeomSpherePointDepth", (void **) &dGeomSpherePointDepth},
1408 // {"dCreateConvex", (void **) &dCreateConvex},
1409 // {"dGeomSetConvex", (void **) &dGeomSetConvex},
1410 {"dCreateBox", (void **) &dCreateBox},
1411 // {"dGeomBoxSetLengths", (void **) &dGeomBoxSetLengths},
1412 // {"dGeomBoxGetLengths", (void **) &dGeomBoxGetLengths},
1413 // {"dGeomBoxPointDepth", (void **) &dGeomBoxPointDepth},
1414 // {"dGeomBoxPointDepth", (void **) &dGeomBoxPointDepth},
1415 // {"dCreatePlane", (void **) &dCreatePlane},
1416 // {"dGeomPlaneSetParams", (void **) &dGeomPlaneSetParams},
1417 // {"dGeomPlaneGetParams", (void **) &dGeomPlaneGetParams},
1418 // {"dGeomPlanePointDepth", (void **) &dGeomPlanePointDepth},
1419 {"dCreateCapsule", (void **) &dCreateCapsule},
1420 // {"dGeomCapsuleSetParams", (void **) &dGeomCapsuleSetParams},
1421 // {"dGeomCapsuleGetParams", (void **) &dGeomCapsuleGetParams},
1422 // {"dGeomCapsulePointDepth", (void **) &dGeomCapsulePointDepth},
1423 {"dCreateCylinder", (void **) &dCreateCylinder},
1424 // {"dGeomCylinderSetParams", (void **) &dGeomCylinderSetParams},
1425 // {"dGeomCylinderGetParams", (void **) &dGeomCylinderGetParams},
1426 // {"dCreateRay", (void **) &dCreateRay},
1427 // {"dGeomRaySetLength", (void **) &dGeomRaySetLength},
1428 // {"dGeomRayGetLength", (void **) &dGeomRayGetLength},
1429 // {"dGeomRaySet", (void **) &dGeomRaySet},
1430 // {"dGeomRayGet", (void **) &dGeomRayGet},
1431 {"dCreateGeomTransform", (void **) &dCreateGeomTransform},
1432 {"dGeomTransformSetGeom", (void **) &dGeomTransformSetGeom},
1433 // {"dGeomTransformGetGeom", (void **) &dGeomTransformGetGeom},
1434 {"dGeomTransformSetCleanup", (void **) &dGeomTransformSetCleanup},
1435 // {"dGeomTransformGetCleanup", (void **) &dGeomTransformGetCleanup},
1436 // {"dGeomTransformSetInfo", (void **) &dGeomTransformSetInfo},
1437 // {"dGeomTransformGetInfo", (void **) &dGeomTransformGetInfo},
1438 {"dGeomTriMeshDataCreate", (void **) &dGeomTriMeshDataCreate},
1439 {"dGeomTriMeshDataDestroy", (void **) &dGeomTriMeshDataDestroy},
1440 // {"dGeomTriMeshDataSet", (void **) &dGeomTriMeshDataSet},
1441 // {"dGeomTriMeshDataGet", (void **) &dGeomTriMeshDataGet},
1442 // {"dGeomTriMeshSetLastTransform", (void **) &dGeomTriMeshSetLastTransform},
1443 // {"dGeomTriMeshGetLastTransform", (void **) &dGeomTriMeshGetLastTransform},
1444 {"dGeomTriMeshDataBuildSingle", (void **) &dGeomTriMeshDataBuildSingle},
1445 // {"dGeomTriMeshDataBuildSingle1", (void **) &dGeomTriMeshDataBuildSingle1},
1446 // {"dGeomTriMeshDataBuildDouble", (void **) &dGeomTriMeshDataBuildDouble},
1447 // {"dGeomTriMeshDataBuildDouble1", (void **) &dGeomTriMeshDataBuildDouble1},
1448 // {"dGeomTriMeshDataBuildSimple", (void **) &dGeomTriMeshDataBuildSimple},
1449 // {"dGeomTriMeshDataBuildSimple1", (void **) &dGeomTriMeshDataBuildSimple1},
1450 // {"dGeomTriMeshDataPreprocess", (void **) &dGeomTriMeshDataPreprocess},
1451 // {"dGeomTriMeshDataGetBuffer", (void **) &dGeomTriMeshDataGetBuffer},
1452 // {"dGeomTriMeshDataSetBuffer", (void **) &dGeomTriMeshDataSetBuffer},
1453 // {"dGeomTriMeshSetCallback", (void **) &dGeomTriMeshSetCallback},
1454 // {"dGeomTriMeshGetCallback", (void **) &dGeomTriMeshGetCallback},
1455 // {"dGeomTriMeshSetArrayCallback", (void **) &dGeomTriMeshSetArrayCallback},
1456 // {"dGeomTriMeshGetArrayCallback", (void **) &dGeomTriMeshGetArrayCallback},
1457 // {"dGeomTriMeshSetRayCallback", (void **) &dGeomTriMeshSetRayCallback},
1458 // {"dGeomTriMeshGetRayCallback", (void **) &dGeomTriMeshGetRayCallback},
1459 // {"dGeomTriMeshSetTriMergeCallback", (void **) &dGeomTriMeshSetTriMergeCallback},
1460 // {"dGeomTriMeshGetTriMergeCallback", (void **) &dGeomTriMeshGetTriMergeCallback},
1461 {"dCreateTriMesh", (void **) &dCreateTriMesh},
1462 // {"dGeomTriMeshSetData", (void **) &dGeomTriMeshSetData},
1463 // {"dGeomTriMeshGetData", (void **) &dGeomTriMeshGetData},
1464 // {"dGeomTriMeshEnableTC", (void **) &dGeomTriMeshEnableTC},
1465 // {"dGeomTriMeshIsTCEnabled", (void **) &dGeomTriMeshIsTCEnabled},
1466 // {"dGeomTriMeshClearTCCache", (void **) &dGeomTriMeshClearTCCache},
1467 // {"dGeomTriMeshGetTriMeshDataID", (void **) &dGeomTriMeshGetTriMeshDataID},
1468 // {"dGeomTriMeshGetTriangle", (void **) &dGeomTriMeshGetTriangle},
1469 // {"dGeomTriMeshGetPoint", (void **) &dGeomTriMeshGetPoint},
1470 // {"dGeomTriMeshGetTriangleCount", (void **) &dGeomTriMeshGetTriangleCount},
1471 // {"dGeomTriMeshDataUpdate", (void **) &dGeomTriMeshDataUpdate},
1475 // Handle for ODE DLL
1476 dllhandle_t ode_dll = NULL;
1480 static void World_Physics_Init(void)
1484 const char* dllnames [] =
1488 # elif defined(MACOSX)
1497 Cvar_RegisterVariable(&physics_ode_quadtree_depth);
1498 Cvar_RegisterVariable(&physics_ode_contactsurfacelayer);
1499 Cvar_RegisterVariable(&physics_ode_worldstep);
1500 Cvar_RegisterVariable(&physics_ode_worldstep_iterations);
1501 Cvar_RegisterVariable(&physics_ode_contact_mu);
1502 Cvar_RegisterVariable(&physics_ode_contact_erp);
1503 Cvar_RegisterVariable(&physics_ode_contact_cfm);
1504 Cvar_RegisterVariable(&physics_ode_world_erp);
1505 Cvar_RegisterVariable(&physics_ode_world_cfm);
1506 Cvar_RegisterVariable(&physics_ode_world_damping);
1507 Cvar_RegisterVariable(&physics_ode_world_damping_linear);
1508 Cvar_RegisterVariable(&physics_ode_world_damping_linear_threshold);
1509 Cvar_RegisterVariable(&physics_ode_world_damping_angular);
1510 Cvar_RegisterVariable(&physics_ode_world_damping_angular_threshold);
1511 Cvar_RegisterVariable(&physics_ode_world_gravitymod);
1512 Cvar_RegisterVariable(&physics_ode_iterationsperframe);
1513 Cvar_RegisterVariable(&physics_ode_constantstep);
1514 Cvar_RegisterVariable(&physics_ode_movelimit);
1515 Cvar_RegisterVariable(&physics_ode_spinlimit);
1516 Cvar_RegisterVariable(&physics_ode_trick_fixnan);
1517 Cvar_RegisterVariable(&physics_ode_autodisable);
1518 Cvar_RegisterVariable(&physics_ode_autodisable_steps);
1519 Cvar_RegisterVariable(&physics_ode_autodisable_time);
1520 Cvar_RegisterVariable(&physics_ode_autodisable_threshold_linear);
1521 Cvar_RegisterVariable(&physics_ode_autodisable_threshold_angular);
1522 Cvar_RegisterVariable(&physics_ode_autodisable_threshold_samples);
1523 Cvar_RegisterVariable(&physics_ode_printstats);
1524 Cvar_RegisterVariable(&physics_ode);
1528 if (Sys_LoadLibrary (dllnames, &ode_dll, odefuncs))
1535 if (!dCheckConfiguration("ODE_single_precision"))
1537 if (!dCheckConfiguration("ODE_double_precision"))
1541 Con_Printf("ODE library not compiled for single precision - incompatible! Not using ODE physics.\n");
1543 Con_Printf("ODE library not compiled for double precision - incompatible! Not using ODE physics.\n");
1545 Sys_UnloadLibrary(&ode_dll);
1551 Con_Printf("ODE library loaded with single precision.\n");
1553 Con_Printf("ODE library loaded with double precision.\n");
1561 static void World_Physics_Shutdown(void)
1570 Sys_UnloadLibrary(&ode_dll);
1578 static void World_Physics_UpdateODE(world_t *world)
1582 odeworld = (dWorldID)world->physics.ode_world;
1585 if (physics_ode_world_erp.value >= 0)
1586 dWorldSetERP(odeworld, physics_ode_world_erp.value);
1587 if (physics_ode_world_cfm.value >= 0)
1588 dWorldSetCFM(odeworld, physics_ode_world_cfm.value);
1590 if (physics_ode_world_damping.integer)
1592 dWorldSetLinearDamping(odeworld, (physics_ode_world_damping_linear.value >= 0) ? (physics_ode_world_damping_linear.value * physics_ode_world_damping.value) : 0);
1593 dWorldSetLinearDampingThreshold(odeworld, (physics_ode_world_damping_linear_threshold.value >= 0) ? (physics_ode_world_damping_linear_threshold.value * physics_ode_world_damping.value) : 0);
1594 dWorldSetAngularDamping(odeworld, (physics_ode_world_damping_angular.value >= 0) ? (physics_ode_world_damping_angular.value * physics_ode_world_damping.value) : 0);
1595 dWorldSetAngularDampingThreshold(odeworld, (physics_ode_world_damping_angular_threshold.value >= 0) ? (physics_ode_world_damping_angular_threshold.value * physics_ode_world_damping.value) : 0);
1599 dWorldSetLinearDamping(odeworld, 0);
1600 dWorldSetLinearDampingThreshold(odeworld, 0);
1601 dWorldSetAngularDamping(odeworld, 0);
1602 dWorldSetAngularDampingThreshold(odeworld, 0);
1605 dWorldSetAutoDisableFlag(odeworld, (physics_ode_autodisable.integer) ? 1 : 0);
1606 if (physics_ode_autodisable.integer)
1608 dWorldSetAutoDisableSteps(odeworld, bound(1, physics_ode_autodisable_steps.integer, 100));
1609 dWorldSetAutoDisableTime(odeworld, physics_ode_autodisable_time.value);
1610 dWorldSetAutoDisableAverageSamplesCount(odeworld, bound(1, physics_ode_autodisable_threshold_samples.integer, 100));
1611 dWorldSetAutoDisableLinearThreshold(odeworld, physics_ode_autodisable_threshold_linear.value);
1612 dWorldSetAutoDisableAngularThreshold(odeworld, physics_ode_autodisable_threshold_angular.value);
1616 static void World_Physics_EnableODE(world_t *world)
1618 dVector3 center, extents;
1619 if (world->physics.ode)
1625 world->physics.ode = true;
1626 VectorMAM(0.5f, world->mins, 0.5f, world->maxs, center);
1627 VectorSubtract(world->maxs, center, extents);
1628 world->physics.ode_world = dWorldCreate();
1629 world->physics.ode_space = dQuadTreeSpaceCreate(NULL, center, extents, bound(1, physics_ode_quadtree_depth.integer, 10));
1630 world->physics.ode_contactgroup = dJointGroupCreate(0);
1632 World_Physics_UpdateODE(world);
1636 static void World_Physics_Start(world_t *world)
1639 if (world->physics.ode)
1641 World_Physics_EnableODE(world);
1645 static void World_Physics_End(world_t *world)
1648 if (world->physics.ode)
1650 dWorldDestroy((dWorldID)world->physics.ode_world);
1651 dSpaceDestroy((dSpaceID)world->physics.ode_space);
1652 dJointGroupDestroy((dJointGroupID)world->physics.ode_contactgroup);
1653 world->physics.ode = false;
1658 void World_Physics_RemoveJointFromEntity(world_t *world, prvm_edict_t *ed)
1660 ed->priv.server->ode_joint_type = 0;
1662 if(ed->priv.server->ode_joint)
1663 dJointDestroy((dJointID)ed->priv.server->ode_joint);
1664 ed->priv.server->ode_joint = NULL;
1668 void World_Physics_RemoveFromEntity(world_t *world, prvm_edict_t *ed)
1670 edict_odefunc_t *f, *nf;
1672 // entity is not physics controlled, free any physics data
1673 ed->priv.server->ode_physics = false;
1675 if (ed->priv.server->ode_geom)
1676 dGeomDestroy((dGeomID)ed->priv.server->ode_geom);
1677 ed->priv.server->ode_geom = NULL;
1678 if (ed->priv.server->ode_body)
1683 while(dBodyGetNumJoints((dBodyID)ed->priv.server->ode_body))
1685 j = dBodyGetJoint((dBodyID)ed->priv.server->ode_body, 0);
1686 ed2 = (prvm_edict_t *) dJointGetData(j);
1687 b1 = dJointGetBody(j, 0);
1688 b2 = dJointGetBody(j, 1);
1689 if(b1 == (dBodyID)ed->priv.server->ode_body)
1692 ed2->priv.server->ode_joint_enemy = 0;
1694 if(b2 == (dBodyID)ed->priv.server->ode_body)
1697 ed2->priv.server->ode_joint_aiment = 0;
1699 dJointAttach(j, b1, b2);
1701 dBodyDestroy((dBodyID)ed->priv.server->ode_body);
1703 ed->priv.server->ode_body = NULL;
1705 if (ed->priv.server->ode_vertex3f)
1706 Mem_Free(ed->priv.server->ode_vertex3f);
1707 ed->priv.server->ode_vertex3f = NULL;
1708 ed->priv.server->ode_numvertices = 0;
1709 if (ed->priv.server->ode_element3i)
1710 Mem_Free(ed->priv.server->ode_element3i);
1711 ed->priv.server->ode_element3i = NULL;
1712 ed->priv.server->ode_numtriangles = 0;
1713 if(ed->priv.server->ode_massbuf)
1714 Mem_Free(ed->priv.server->ode_massbuf);
1715 ed->priv.server->ode_massbuf = NULL;
1716 // clear functions stack
1717 for(f = ed->priv.server->ode_func; f; f = nf)
1722 ed->priv.server->ode_func = NULL;
1725 void World_Physics_ApplyCmd(prvm_edict_t *ed, edict_odefunc_t *f)
1727 dBodyID body = (dBodyID)ed->priv.server->ode_body;
1732 case ODEFUNC_ENABLE:
1735 case ODEFUNC_DISABLE:
1738 case ODEFUNC_RELFORCEATPOS:
1740 dBodyAddForceAtRelPos(body, f->v1[0], f->v1[1], f->v1[2], f->v2[0], f->v2[1], f->v2[2]);
1742 case ODEFUNC_RELTORQUE:
1744 dBodyAddRelTorque(body, f->v1[0], f->v1[1], f->v1[2]);
1753 static void World_Physics_Frame_BodyToEntity(world_t *world, prvm_edict_t *ed)
1755 prvm_prog_t *prog = world->prog;
1758 const dReal *r; // for some reason dBodyGetRotation returns a [3][4] matrix
1760 dBodyID body = (dBodyID)ed->priv.server->ode_body;
1762 matrix4x4_t bodymatrix;
1763 matrix4x4_t entitymatrix;
1766 vec3_t forward, left, up;
1768 vec3_t spinvelocity;
1773 movetype = (int)PRVM_gameedictfloat(ed, movetype);
1774 if (movetype != MOVETYPE_PHYSICS)
1776 jointtype = (int)PRVM_gameedictfloat(ed, jointtype);
1779 // TODO feed back data from physics
1780 case JOINTTYPE_POINT:
1782 case JOINTTYPE_HINGE:
1784 case JOINTTYPE_SLIDER:
1786 case JOINTTYPE_UNIVERSAL:
1788 case JOINTTYPE_HINGE2:
1790 case JOINTTYPE_FIXED:
1795 // store the physics engine data into the entity
1796 o = dBodyGetPosition(body);
1797 r = dBodyGetRotation(body);
1798 vel = dBodyGetLinearVel(body);
1799 avel = dBodyGetAngularVel(body);
1800 VectorCopy(o, origin);
1810 VectorCopy(vel, velocity);
1811 VectorCopy(avel, spinvelocity);
1812 Matrix4x4_FromVectors(&bodymatrix, forward, left, up, origin);
1813 Matrix4x4_Concat(&entitymatrix, &bodymatrix, &ed->priv.server->ode_offsetimatrix);
1814 Matrix4x4_ToVectors(&entitymatrix, forward, left, up, origin);
1816 AnglesFromVectors(angles, forward, up, false);
1817 VectorSet(avelocity, RAD2DEG(spinvelocity[PITCH]), RAD2DEG(spinvelocity[ROLL]), RAD2DEG(spinvelocity[YAW]));
1820 float pitchsign = 1;
1821 if(prog == SVVM_prog) // FIXME some better way?
1823 pitchsign = SV_GetPitchSign(prog, ed);
1825 else if(prog == CLVM_prog)
1827 pitchsign = CL_GetPitchSign(prog, ed);
1829 angles[PITCH] *= pitchsign;
1830 avelocity[PITCH] *= pitchsign;
1833 VectorCopy(origin, PRVM_gameedictvector(ed, origin));
1834 VectorCopy(velocity, PRVM_gameedictvector(ed, velocity));
1835 //VectorCopy(forward, PRVM_gameedictvector(ed, axis_forward));
1836 //VectorCopy(left, PRVM_gameedictvector(ed, axis_left));
1837 //VectorCopy(up, PRVM_gameedictvector(ed, axis_up));
1838 //VectorCopy(spinvelocity, PRVM_gameedictvector(ed, spinvelocity));
1839 VectorCopy(angles, PRVM_gameedictvector(ed, angles));
1840 VectorCopy(avelocity, PRVM_gameedictvector(ed, avelocity));
1842 // values for BodyFromEntity to check if the qc modified anything later
1843 VectorCopy(origin, ed->priv.server->ode_origin);
1844 VectorCopy(velocity, ed->priv.server->ode_velocity);
1845 VectorCopy(angles, ed->priv.server->ode_angles);
1846 VectorCopy(avelocity, ed->priv.server->ode_avelocity);
1847 ed->priv.server->ode_gravity = dBodyGetGravityMode(body) != 0;
1849 if(prog == SVVM_prog) // FIXME some better way?
1852 SV_LinkEdict_TouchAreaGrid(ed);
1856 static void World_Physics_Frame_JointFromEntity(world_t *world, prvm_edict_t *ed)
1858 prvm_prog_t *prog = world->prog;
1864 int enemy = 0, aiment = 0;
1865 vec3_t origin, velocity, angles, forward, left, up, movedir;
1866 vec_t CFM, ERP, FMax, Stop, Vel;
1867 VectorClear(origin);
1868 VectorClear(velocity);
1869 VectorClear(angles);
1870 VectorClear(movedir);
1871 movetype = (int)PRVM_gameedictfloat(ed, movetype);
1872 jointtype = (int)PRVM_gameedictfloat(ed, jointtype);
1873 enemy = PRVM_gameedictedict(ed, enemy);
1874 aiment = PRVM_gameedictedict(ed, aiment);
1875 VectorCopy(PRVM_gameedictvector(ed, origin), origin);
1876 VectorCopy(PRVM_gameedictvector(ed, velocity), velocity);
1877 VectorCopy(PRVM_gameedictvector(ed, angles), angles);
1878 VectorCopy(PRVM_gameedictvector(ed, movedir), movedir);
1879 if(movetype == MOVETYPE_PHYSICS)
1880 jointtype = 0; // can't have both
1881 if(enemy <= 0 || enemy >= prog->num_edicts || prog->edicts[enemy].priv.required->free || prog->edicts[enemy].priv.server->ode_body == 0)
1883 if(aiment <= 0 || aiment >= prog->num_edicts || prog->edicts[aiment].priv.required->free || prog->edicts[aiment].priv.server->ode_body == 0)
1885 // see http://www.ode.org/old_list_archives/2006-January/017614.html
1886 // we want to set ERP? make it fps independent and work like a spring constant
1887 // note: if movedir[2] is 0, it becomes ERP = 1, CFM = 1.0 / (H * K)
1888 if(movedir[0] > 0 && movedir[1] > 0)
1890 float K = movedir[0];
1891 float D = movedir[1];
1892 float R = 2.0 * D * sqrt(K); // we assume D is premultiplied by sqrt(sprungMass)
1893 CFM = 1.0 / (world->physics.ode_step * K + R); // always > 0
1894 ERP = world->physics.ode_step * K * CFM;
1899 else if(movedir[1] < 0)
1904 FMax = -movedir[1]; // TODO do we need to multiply with world.physics.ode_step?
1905 Stop = movedir[2] > 0 ? movedir[2] : dInfinity;
1907 else // movedir[0] > 0, movedir[1] == 0 or movedir[0] < 0, movedir[1] >= 0
1915 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))
1916 return; // nothing to do
1917 AngleVectorsFLU(angles, forward, left, up);
1920 case JOINTTYPE_POINT:
1921 j = dJointCreateBall((dWorldID)world->physics.ode_world, 0);
1923 case JOINTTYPE_HINGE:
1924 j = dJointCreateHinge((dWorldID)world->physics.ode_world, 0);
1926 case JOINTTYPE_SLIDER:
1927 j = dJointCreateSlider((dWorldID)world->physics.ode_world, 0);
1929 case JOINTTYPE_UNIVERSAL:
1930 j = dJointCreateUniversal((dWorldID)world->physics.ode_world, 0);
1932 case JOINTTYPE_HINGE2:
1933 j = dJointCreateHinge2((dWorldID)world->physics.ode_world, 0);
1935 case JOINTTYPE_FIXED:
1936 j = dJointCreateFixed((dWorldID)world->physics.ode_world, 0);
1944 if(ed->priv.server->ode_joint)
1946 //Con_Printf("deleted old joint %i\n", (int) (ed - prog->edicts));
1947 dJointAttach((dJointID)ed->priv.server->ode_joint, 0, 0);
1948 dJointDestroy((dJointID)ed->priv.server->ode_joint);
1950 ed->priv.server->ode_joint = (void *) j;
1951 ed->priv.server->ode_joint_type = jointtype;
1952 ed->priv.server->ode_joint_enemy = enemy;
1953 ed->priv.server->ode_joint_aiment = aiment;
1954 VectorCopy(origin, ed->priv.server->ode_joint_origin);
1955 VectorCopy(velocity, ed->priv.server->ode_joint_velocity);
1956 VectorCopy(angles, ed->priv.server->ode_joint_angles);
1957 VectorCopy(movedir, ed->priv.server->ode_joint_movedir);
1960 //Con_Printf("made new joint %i\n", (int) (ed - prog->edicts));
1961 dJointSetData(j, (void *) ed);
1963 b1 = (dBodyID)prog->edicts[enemy].priv.server->ode_body;
1965 b2 = (dBodyID)prog->edicts[aiment].priv.server->ode_body;
1966 dJointAttach(j, b1, b2);
1970 case JOINTTYPE_POINT:
1971 dJointSetBallAnchor(j, origin[0], origin[1], origin[2]);
1973 case JOINTTYPE_HINGE:
1974 dJointSetHingeAnchor(j, origin[0], origin[1], origin[2]);
1975 dJointSetHingeAxis(j, forward[0], forward[1], forward[2]);
1976 dJointSetHingeParam(j, dParamFMax, FMax);
1977 dJointSetHingeParam(j, dParamHiStop, Stop);
1978 dJointSetHingeParam(j, dParamLoStop, -Stop);
1979 dJointSetHingeParam(j, dParamStopCFM, CFM);
1980 dJointSetHingeParam(j, dParamStopERP, ERP);
1981 dJointSetHingeParam(j, dParamVel, Vel);
1983 case JOINTTYPE_SLIDER:
1984 dJointSetSliderAxis(j, forward[0], forward[1], forward[2]);
1985 dJointSetSliderParam(j, dParamFMax, FMax);
1986 dJointSetSliderParam(j, dParamHiStop, Stop);
1987 dJointSetSliderParam(j, dParamLoStop, -Stop);
1988 dJointSetSliderParam(j, dParamStopCFM, CFM);
1989 dJointSetSliderParam(j, dParamStopERP, ERP);
1990 dJointSetSliderParam(j, dParamVel, Vel);
1992 case JOINTTYPE_UNIVERSAL:
1993 dJointSetUniversalAnchor(j, origin[0], origin[1], origin[2]);
1994 dJointSetUniversalAxis1(j, forward[0], forward[1], forward[2]);
1995 dJointSetUniversalAxis2(j, up[0], up[1], up[2]);
1996 dJointSetUniversalParam(j, dParamFMax, FMax);
1997 dJointSetUniversalParam(j, dParamHiStop, Stop);
1998 dJointSetUniversalParam(j, dParamLoStop, -Stop);
1999 dJointSetUniversalParam(j, dParamStopCFM, CFM);
2000 dJointSetUniversalParam(j, dParamStopERP, ERP);
2001 dJointSetUniversalParam(j, dParamVel, Vel);
2002 dJointSetUniversalParam(j, dParamFMax2, FMax);
2003 dJointSetUniversalParam(j, dParamHiStop2, Stop);
2004 dJointSetUniversalParam(j, dParamLoStop2, -Stop);
2005 dJointSetUniversalParam(j, dParamStopCFM2, CFM);
2006 dJointSetUniversalParam(j, dParamStopERP2, ERP);
2007 dJointSetUniversalParam(j, dParamVel2, Vel);
2009 case JOINTTYPE_HINGE2:
2010 dJointSetHinge2Anchor(j, origin[0], origin[1], origin[2]);
2011 dJointSetHinge2Axis1(j, forward[0], forward[1], forward[2]);
2012 dJointSetHinge2Axis2(j, velocity[0], velocity[1], velocity[2]);
2013 dJointSetHinge2Param(j, dParamFMax, FMax);
2014 dJointSetHinge2Param(j, dParamHiStop, Stop);
2015 dJointSetHinge2Param(j, dParamLoStop, -Stop);
2016 dJointSetHinge2Param(j, dParamStopCFM, CFM);
2017 dJointSetHinge2Param(j, dParamStopERP, ERP);
2018 dJointSetHinge2Param(j, dParamVel, Vel);
2019 dJointSetHinge2Param(j, dParamFMax2, FMax);
2020 dJointSetHinge2Param(j, dParamHiStop2, Stop);
2021 dJointSetHinge2Param(j, dParamLoStop2, -Stop);
2022 dJointSetHinge2Param(j, dParamStopCFM2, CFM);
2023 dJointSetHinge2Param(j, dParamStopERP2, ERP);
2024 dJointSetHinge2Param(j, dParamVel2, Vel);
2026 case JOINTTYPE_FIXED:
2030 Sys_Error("what? but above the joint was valid...\n");
2038 static void World_Physics_Frame_BodyFromEntity(world_t *world, prvm_edict_t *ed)
2040 prvm_prog_t *prog = world->prog;
2043 dBodyID body = (dBodyID)ed->priv.server->ode_body;
2046 const dReal *ovelocity, *ospinvelocity;
2048 dVector3 capsulerot[3];
2054 int movetype = MOVETYPE_NONE;
2057 int solid = SOLID_NOT;
2061 qboolean modified = false;
2071 vec3_t spinvelocity;
2076 vec_t massval = 1.0f;
2082 edict_odefunc_t *func, *nextf;
2088 VectorClear(entmins);
2089 VectorClear(entmaxs);
2090 solid = (int)PRVM_gameedictfloat(ed, solid);
2091 movetype = (int)PRVM_gameedictfloat(ed, movetype);
2092 scale = PRVM_gameedictfloat(ed, scale);if (!scale) scale = 1.0f;
2094 mempool = prog->progs_mempool;
2099 case SOLID_PHYSICS_TRIMESH:
2100 modelindex = (int)PRVM_gameedictfloat(ed, modelindex);
2101 if (world == &sv.world)
2102 model = SV_GetModelByIndex(modelindex);
2103 else if (world == &cl.world)
2104 model = CL_GetModelByIndex(modelindex);
2109 VectorScale(model->normalmins, scale, entmins);
2110 VectorScale(model->normalmaxs, scale, entmaxs);
2111 massval = PRVM_gameedictfloat(ed, mass);
2120 //case SOLID_SLIDEBOX:
2122 case SOLID_PHYSICS_BOX:
2123 case SOLID_PHYSICS_SPHERE:
2124 case SOLID_PHYSICS_CAPSULE:
2125 VectorCopy(PRVM_gameedictvector(ed, mins), entmins);
2126 VectorCopy(PRVM_gameedictvector(ed, maxs), entmaxs);
2127 massval = PRVM_gameedictfloat(ed, mass);
2130 if (ed->priv.server->ode_physics)
2131 World_Physics_RemoveFromEntity(world, ed);
2135 VectorSubtract(entmaxs, entmins, geomsize);
2136 if (VectorLength2(geomsize) == 0)
2138 // we don't allow point-size physics objects...
2139 if (ed->priv.server->ode_physics)
2140 World_Physics_RemoveFromEntity(world, ed);
2144 if (movetype != MOVETYPE_PHYSICS)
2147 // get friction from entity
2148 if (PRVM_gameedictfloat(ed, friction))
2149 ed->priv.server->ode_friction = PRVM_gameedictfloat(ed, friction);
2151 ed->priv.server->ode_friction = 1.0;
2153 // check if we need to create or replace the geom
2154 if (!ed->priv.server->ode_physics
2155 || !VectorCompare(ed->priv.server->ode_mins, entmins)
2156 || !VectorCompare(ed->priv.server->ode_maxs, entmaxs)
2157 || ed->priv.server->ode_mass != massval
2158 || ed->priv.server->ode_modelindex != modelindex)
2161 World_Physics_RemoveFromEntity(world, ed);
2162 ed->priv.server->ode_physics = true;
2163 VectorCopy(entmins, ed->priv.server->ode_mins);
2164 VectorCopy(entmaxs, ed->priv.server->ode_maxs);
2165 ed->priv.server->ode_mass = massval;
2166 ed->priv.server->ode_modelindex = modelindex;
2167 VectorMAM(0.5f, entmins, 0.5f, entmaxs, geomcenter);
2168 if (PRVM_gameedictvector(ed, massofs))
2169 VectorCopy(geomcenter, PRVM_gameedictvector(ed, massofs));
2171 VectorMAM(0.5f, entmins, 0.5f, entmaxs, geomcenter);
2172 ed->priv.server->ode_movelimit = min(geomsize[0], min(geomsize[1], geomsize[2]));
2173 if (massval * geomsize[0] * geomsize[1] * geomsize[2] == 0)
2175 if (movetype == MOVETYPE_PHYSICS)
2176 Con_Printf("entity %i (classname %s) .mass * .size_x * .size_y * .size_z == 0\n", PRVM_NUM_FOR_EDICT(ed), PRVM_GetString(prog, PRVM_gameedictstring(ed, classname)));
2178 VectorSet(geomsize, 1.0f, 1.0f, 1.0f);
2184 case SOLID_PHYSICS_TRIMESH:
2185 ed->priv.server->ode_offsetmatrix = identitymatrix;
2188 Con_Printf("entity %i (classname %s) has no model\n", PRVM_NUM_FOR_EDICT(ed), PRVM_GetString(prog, PRVM_gameedictstring(ed, classname)));
2191 // add an optimized mesh to the model containing only the SUPERCONTENTS_SOLID surfaces
2192 if (!model->brush.collisionmesh)
2193 Mod_CreateCollisionMesh(model);
2194 if (!model->brush.collisionmesh || !model->brush.collisionmesh->numtriangles)
2196 Con_Printf("entity %i (classname %s) has no geometry\n", PRVM_NUM_FOR_EDICT(ed), PRVM_GetString(prog, PRVM_gameedictstring(ed, classname)));
2199 // ODE requires persistent mesh storage, so we need to copy out
2200 // the data from the model because renderer restarts could free it
2201 // during the game, additionally we need to flip the triangles...
2202 // note: ODE does preprocessing of the mesh for culling, removing
2203 // concave edges, etc., so this is not a lightweight operation
2204 ed->priv.server->ode_numvertices = numvertices = model->brush.collisionmesh->numverts;
2205 ed->priv.server->ode_vertex3f = (float *)Mem_Alloc(mempool, numvertices * sizeof(float[3]));
2206 for (vertexindex = 0, ov = ed->priv.server->ode_vertex3f, iv = model->brush.collisionmesh->vertex3f;vertexindex < numvertices;vertexindex++, ov += 3, iv += 3)
2208 ov[0] = iv[0] - geomcenter[0];
2209 ov[1] = iv[1] - geomcenter[1];
2210 ov[2] = iv[2] - geomcenter[2];
2212 ed->priv.server->ode_numtriangles = numtriangles = model->brush.collisionmesh->numtriangles;
2213 ed->priv.server->ode_element3i = (int *)Mem_Alloc(mempool, numtriangles * sizeof(int[3]));
2214 //memcpy(ed->priv.server->ode_element3i, model->brush.collisionmesh->element3i, ed->priv.server->ode_numtriangles * sizeof(int[3]));
2215 for (triangleindex = 0, oe = ed->priv.server->ode_element3i, ie = model->brush.collisionmesh->element3i;triangleindex < numtriangles;triangleindex++, oe += 3, ie += 3)
2221 Matrix4x4_CreateTranslate(&ed->priv.server->ode_offsetmatrix, geomcenter[0], geomcenter[1], geomcenter[2]);
2222 // now create the geom
2223 dataID = dGeomTriMeshDataCreate();
2224 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]));
2225 ed->priv.server->ode_geom = (void *)dCreateTriMesh((dSpaceID)world->physics.ode_space, (dTriMeshDataID)dataID, NULL, NULL, NULL);
2226 dMassSetBoxTotal(&mass, massval, geomsize[0], geomsize[1], geomsize[2]);
2229 case SOLID_SLIDEBOX:
2231 case SOLID_PHYSICS_BOX:
2233 Matrix4x4_CreateTranslate(&ed->priv.server->ode_offsetmatrix, geomcenter[0], geomcenter[1], geomcenter[2]);
2234 ed->priv.server->ode_geom = (void *)dCreateBox((dSpaceID)world->physics.ode_space, geomsize[0], geomsize[1], geomsize[2]);
2235 dMassSetBoxTotal(&mass, massval, geomsize[0], geomsize[1], geomsize[2]);
2237 case SOLID_PHYSICS_SPHERE:
2238 Matrix4x4_CreateTranslate(&ed->priv.server->ode_offsetmatrix, geomcenter[0], geomcenter[1], geomcenter[2]);
2239 ed->priv.server->ode_geom = (void *)dCreateSphere((dSpaceID)world->physics.ode_space, geomsize[0] * 0.5f);
2240 dMassSetSphereTotal(&mass, massval, geomsize[0] * 0.5f);
2242 case SOLID_PHYSICS_CAPSULE:
2243 case SOLID_PHYSICS_CYLINDER:
2245 if (geomsize[axisindex] < geomsize[1])
2247 if (geomsize[axisindex] < geomsize[2])
2249 // the qc gives us 3 axis radius, the longest axis is the capsule
2250 // axis, since ODE doesn't like this idea we have to create a
2251 // capsule which uses the standard orientation, and apply a
2253 memset(capsulerot, 0, sizeof(capsulerot));
2255 Matrix4x4_CreateFromQuakeEntity(&ed->priv.server->ode_offsetmatrix, geomcenter[0], geomcenter[1], geomcenter[2], 0, 0, 90, 1);
2256 else if (axisindex == 1)
2257 Matrix4x4_CreateFromQuakeEntity(&ed->priv.server->ode_offsetmatrix, geomcenter[0], geomcenter[1], geomcenter[2], 90, 0, 0, 1);
2259 Matrix4x4_CreateFromQuakeEntity(&ed->priv.server->ode_offsetmatrix, geomcenter[0], geomcenter[1], geomcenter[2], 0, 0, 0, 1);
2260 radius = geomsize[!axisindex] * 0.5f; // any other axis is the radius
2261 length = geomsize[axisindex] - radius*2;
2262 // because we want to support more than one axisindex, we have to
2263 // create a transform, and turn on its cleanup setting (which will
2264 // cause the child to be destroyed when it is destroyed)
2265 if (solid == SOLID_PHYSICS_CAPSULE)
2267 ed->priv.server->ode_geom = (void *)dCreateCapsule((dSpaceID)world->physics.ode_space, radius, length);
2268 dMassSetCapsuleTotal(&mass, massval, axisindex+1, radius, length);
2272 ed->priv.server->ode_geom = (void *)dCreateCylinder((dSpaceID)world->physics.ode_space, radius, length);
2273 dMassSetCylinderTotal(&mass, massval, axisindex+1, radius, length);
2277 Sys_Error("World_Physics_BodyFromEntity: unrecognized solid value %i was accepted by filter\n", solid);
2278 // this goto only exists to prevent warnings from the compiler
2279 // about uninitialized variables (mass), while allowing it to
2280 // catch legitimate uninitialized variable warnings
2283 Matrix4x4_Invert_Simple(&ed->priv.server->ode_offsetimatrix, &ed->priv.server->ode_offsetmatrix);
2284 ed->priv.server->ode_massbuf = Mem_Alloc(mempool, sizeof(mass));
2285 memcpy(ed->priv.server->ode_massbuf, &mass, sizeof(dMass));
2288 if (ed->priv.server->ode_geom)
2289 dGeomSetData((dGeomID)ed->priv.server->ode_geom, (void*)ed);
2290 if (movetype == MOVETYPE_PHYSICS && ed->priv.server->ode_geom)
2292 if (ed->priv.server->ode_body == NULL)
2294 ed->priv.server->ode_body = (void *)(body = dBodyCreate((dWorldID)world->physics.ode_world));
2295 dGeomSetBody((dGeomID)ed->priv.server->ode_geom, body);
2296 dBodySetData(body, (void*)ed);
2297 dBodySetMass(body, (dMass *) ed->priv.server->ode_massbuf);
2303 if (ed->priv.server->ode_body != NULL)
2305 if(ed->priv.server->ode_geom)
2306 dGeomSetBody((dGeomID)ed->priv.server->ode_geom, 0);
2307 dBodyDestroy((dBodyID) ed->priv.server->ode_body);
2308 ed->priv.server->ode_body = NULL;
2313 // get current data from entity
2314 VectorClear(origin);
2315 VectorClear(velocity);
2316 //VectorClear(forward);
2317 //VectorClear(left);
2319 //VectorClear(spinvelocity);
2320 VectorClear(angles);
2321 VectorClear(avelocity);
2323 VectorCopy(PRVM_gameedictvector(ed, origin), origin);
2324 VectorCopy(PRVM_gameedictvector(ed, velocity), velocity);
2325 //VectorCopy(PRVM_gameedictvector(ed, axis_forward), forward);
2326 //VectorCopy(PRVM_gameedictvector(ed, axis_left), left);
2327 //VectorCopy(PRVM_gameedictvector(ed, axis_up), up);
2328 //VectorCopy(PRVM_gameedictvector(ed, spinvelocity), spinvelocity);
2329 VectorCopy(PRVM_gameedictvector(ed, angles), angles);
2330 VectorCopy(PRVM_gameedictvector(ed, avelocity), avelocity);
2331 if (PRVM_gameedictfloat(ed, gravity) != 0.0f && PRVM_gameedictfloat(ed, gravity) < 0.5f) gravity = false;
2332 if (ed == prog->edicts)
2335 // compatibility for legacy entities
2336 //if (!VectorLength2(forward) || solid == SOLID_BSP)
2338 float pitchsign = 1;
2339 vec3_t qangles, qavelocity;
2340 VectorCopy(angles, qangles);
2341 VectorCopy(avelocity, qavelocity);
2343 if(prog == SVVM_prog) // FIXME some better way?
2345 pitchsign = SV_GetPitchSign(prog, ed);
2347 else if(prog == CLVM_prog)
2349 pitchsign = CL_GetPitchSign(prog, ed);
2351 qangles[PITCH] *= pitchsign;
2352 qavelocity[PITCH] *= pitchsign;
2354 AngleVectorsFLU(qangles, forward, left, up);
2355 // convert single-axis rotations in avelocity to spinvelocity
2356 // FIXME: untested math - check signs
2357 VectorSet(spinvelocity, DEG2RAD(qavelocity[PITCH]), DEG2RAD(qavelocity[ROLL]), DEG2RAD(qavelocity[YAW]));
2360 // compatibility for legacy entities
2364 case SOLID_SLIDEBOX:
2366 VectorSet(forward, 1, 0, 0);
2367 VectorSet(left, 0, 1, 0);
2368 VectorSet(up, 0, 0, 1);
2369 VectorSet(spinvelocity, 0, 0, 0);
2374 // we must prevent NANs...
2375 if (physics_ode_trick_fixnan.integer)
2377 test = VectorLength2(origin) + VectorLength2(forward) + VectorLength2(left) + VectorLength2(up) + VectorLength2(velocity) + VectorLength2(spinvelocity);
2381 //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]);
2382 if (physics_ode_trick_fixnan.integer >= 2)
2383 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(prog, 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]);
2384 test = VectorLength2(origin);
2386 VectorClear(origin);
2387 test = VectorLength2(forward) * VectorLength2(left) * VectorLength2(up);
2390 VectorSet(angles, 0, 0, 0);
2391 VectorSet(forward, 1, 0, 0);
2392 VectorSet(left, 0, 1, 0);
2393 VectorSet(up, 0, 0, 1);
2395 test = VectorLength2(velocity);
2397 VectorClear(velocity);
2398 test = VectorLength2(spinvelocity);
2401 VectorClear(avelocity);
2402 VectorClear(spinvelocity);
2407 // check if the qc edited any position data
2408 if (!VectorCompare(origin, ed->priv.server->ode_origin)
2409 || !VectorCompare(velocity, ed->priv.server->ode_velocity)
2410 || !VectorCompare(angles, ed->priv.server->ode_angles)
2411 || !VectorCompare(avelocity, ed->priv.server->ode_avelocity)
2412 || gravity != ed->priv.server->ode_gravity)
2415 // store the qc values into the physics engine
2416 body = (dBodyID)ed->priv.server->ode_body;
2417 if (modified && ed->priv.server->ode_geom)
2420 matrix4x4_t entitymatrix;
2421 matrix4x4_t bodymatrix;
2424 Con_Printf("entity %i got changed by QC\n", (int) (ed - prog->edicts));
2425 if(!VectorCompare(origin, ed->priv.server->ode_origin))
2426 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]);
2427 if(!VectorCompare(velocity, ed->priv.server->ode_velocity))
2428 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]);
2429 if(!VectorCompare(angles, ed->priv.server->ode_angles))
2430 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]);
2431 if(!VectorCompare(avelocity, ed->priv.server->ode_avelocity))
2432 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]);
2433 if(gravity != ed->priv.server->ode_gravity)
2434 Con_Printf(" gravity: %i -> %i\n", ed->priv.server->ode_gravity, gravity);
2436 // values for BodyFromEntity to check if the qc modified anything later
2437 VectorCopy(origin, ed->priv.server->ode_origin);
2438 VectorCopy(velocity, ed->priv.server->ode_velocity);
2439 VectorCopy(angles, ed->priv.server->ode_angles);
2440 VectorCopy(avelocity, ed->priv.server->ode_avelocity);
2441 ed->priv.server->ode_gravity = gravity;
2443 Matrix4x4_FromVectors(&entitymatrix, forward, left, up, origin);
2444 Matrix4x4_Concat(&bodymatrix, &entitymatrix, &ed->priv.server->ode_offsetmatrix);
2445 Matrix4x4_ToVectors(&bodymatrix, forward, left, up, origin);
2446 r[0][0] = forward[0];
2447 r[1][0] = forward[1];
2448 r[2][0] = forward[2];
2457 if(movetype == MOVETYPE_PHYSICS)
2459 dGeomSetBody((dGeomID)ed->priv.server->ode_geom, body);
2460 dBodySetPosition(body, origin[0], origin[1], origin[2]);
2461 dBodySetRotation(body, r[0]);
2462 dBodySetLinearVel(body, velocity[0], velocity[1], velocity[2]);
2463 dBodySetAngularVel(body, spinvelocity[0], spinvelocity[1], spinvelocity[2]);
2464 dBodySetGravityMode(body, gravity);
2468 dGeomSetBody((dGeomID)ed->priv.server->ode_geom, body);
2469 dBodySetPosition(body, origin[0], origin[1], origin[2]);
2470 dBodySetRotation(body, r[0]);
2471 dBodySetLinearVel(body, velocity[0], velocity[1], velocity[2]);
2472 dBodySetAngularVel(body, spinvelocity[0], spinvelocity[1], spinvelocity[2]);
2473 dBodySetGravityMode(body, gravity);
2474 dGeomSetBody((dGeomID)ed->priv.server->ode_geom, 0);
2479 // no body... then let's adjust the parameters of the geom directly
2480 dGeomSetBody((dGeomID)ed->priv.server->ode_geom, 0); // just in case we previously HAD a body (which should never happen)
2481 dGeomSetPosition((dGeomID)ed->priv.server->ode_geom, origin[0], origin[1], origin[2]);
2482 dGeomSetRotation((dGeomID)ed->priv.server->ode_geom, r[0]);
2489 // limit movement speed to prevent missed collisions at high speed
2490 ovelocity = dBodyGetLinearVel(body);
2491 ospinvelocity = dBodyGetAngularVel(body);
2492 movelimit = ed->priv.server->ode_movelimit * world->physics.ode_movelimit;
2493 test = VectorLength2(ovelocity);
2494 if (test > movelimit*movelimit)
2496 // scale down linear velocity to the movelimit
2497 // scale down angular velocity the same amount for consistency
2498 f = movelimit / sqrt(test);
2499 VectorScale(ovelocity, f, velocity);
2500 VectorScale(ospinvelocity, f, spinvelocity);
2501 dBodySetLinearVel(body, velocity[0], velocity[1], velocity[2]);
2502 dBodySetAngularVel(body, spinvelocity[0], spinvelocity[1], spinvelocity[2]);
2505 // make sure the angular velocity is not exploding
2506 spinlimit = physics_ode_spinlimit.value;
2507 test = VectorLength2(ospinvelocity);
2508 if (test > spinlimit)
2510 dBodySetAngularVel(body, 0, 0, 0);
2513 // apply functions and clear stack
2514 for(func = ed->priv.server->ode_func; func; func = nextf)
2517 World_Physics_ApplyCmd(ed, func);
2520 ed->priv.server->ode_func = NULL;
2524 #define MAX_CONTACTS 16
2525 static void nearCallback (void *data, dGeomID o1, dGeomID o2)
2527 world_t *world = (world_t *)data;
2528 prvm_prog_t *prog = world->prog;
2529 dContact contact[MAX_CONTACTS]; // max contacts per collision pair
2535 float bouncefactor1 = 0.0f;
2536 float bouncestop1 = 60.0f / 800.0f;
2537 float bouncefactor2 = 0.0f;
2538 float bouncestop2 = 60.0f / 800.0f;
2540 prvm_edict_t *ed1, *ed2;
2542 if (dGeomIsSpace(o1) || dGeomIsSpace(o2))
2544 // colliding a space with something
2545 dSpaceCollide2(o1, o2, data, &nearCallback);
2546 // Note we do not want to test intersections within a space,
2547 // only between spaces.
2548 //if (dGeomIsSpace(o1)) dSpaceCollide(o1, data, &nearCallback);
2549 //if (dGeomIsSpace(o2)) dSpaceCollide(o2, data, &nearCallback);
2553 b1 = dGeomGetBody(o1);
2554 b2 = dGeomGetBody(o2);
2556 // at least one object has to be using MOVETYPE_PHYSICS or we just don't care
2560 // exit without doing anything if the two bodies are connected by a joint
2561 if (b1 && b2 && dAreConnectedExcluding(b1, b2, dJointTypeContact))
2564 ed1 = (prvm_edict_t *) dGeomGetData(o1);
2565 if(ed1 && ed1->priv.server->free)
2569 bouncefactor1 = PRVM_gameedictfloat(ed1, bouncefactor);
2570 bouncestop1 = PRVM_gameedictfloat(ed1, bouncestop);
2572 bouncestop1 = 60.0f / 800.0f;
2575 ed2 = (prvm_edict_t *) dGeomGetData(o2);
2576 if(ed2 && ed2->priv.server->free)
2580 bouncefactor2 = PRVM_gameedictfloat(ed2, bouncefactor);
2581 bouncestop2 = PRVM_gameedictfloat(ed2, bouncestop);
2583 bouncestop2 = 60.0f / 800.0f;
2586 if(prog == SVVM_prog)
2588 if(ed1 && PRVM_serveredictfunction(ed1, touch))
2590 SV_LinkEdict_TouchAreaGrid_Call(ed1, ed2 ? ed2 : prog->edicts);
2592 if(ed2 && PRVM_serveredictfunction(ed2, touch))
2594 SV_LinkEdict_TouchAreaGrid_Call(ed2, ed1 ? ed1 : prog->edicts);
2598 // merge bounce factors and bounce stop
2599 if(bouncefactor2 > 0)
2601 if(bouncefactor1 > 0)
2603 // TODO possibly better logic to merge bounce factor data?
2604 if(bouncestop2 < bouncestop1)
2605 bouncestop1 = bouncestop2;
2606 if(bouncefactor2 > bouncefactor1)
2607 bouncefactor1 = bouncefactor2;
2611 bouncestop1 = bouncestop2;
2612 bouncefactor1 = bouncefactor2;
2615 dWorldGetGravity((dWorldID)world->physics.ode_world, grav);
2616 bouncestop1 *= fabs(grav[2]);
2618 // generate contact points between the two non-space geoms
2619 numcontacts = dCollide(o1, o2, MAX_CONTACTS, &(contact[0].geom), sizeof(contact[0]));
2620 // add these contact points to the simulation
2621 for (i = 0;i < numcontacts;i++)
2623 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);
2624 contact[i].surface.mu = physics_ode_contact_mu.value * ed1->priv.server->ode_friction * ed2->priv.server->ode_friction;
2625 contact[i].surface.soft_erp = physics_ode_contact_erp.value;
2626 contact[i].surface.soft_cfm = physics_ode_contact_cfm.value;
2627 contact[i].surface.bounce = bouncefactor1;
2628 contact[i].surface.bounce_vel = bouncestop1;
2629 c = dJointCreateContact((dWorldID)world->physics.ode_world, (dJointGroupID)world->physics.ode_contactgroup, contact + i);
2630 dJointAttach(c, b1, b2);
2635 void World_Physics_Frame(world_t *world, double frametime, double gravity)
2637 prvm_prog_t *prog = world->prog;
2638 double tdelta, tdelta2, tdelta3, simulationtime, collisiontime;
2640 tdelta = Sys_DirtyTime();
2642 if (world->physics.ode && physics_ode.integer)
2647 world->physics.ode_iterations = bound(1, physics_ode_iterationsperframe.integer, 1000);
2648 if (physics_ode_constantstep.integer)
2649 world->physics.ode_step = sys_ticrate.value / world->physics.ode_iterations;
2651 world->physics.ode_step = frametime / world->physics.ode_iterations;
2652 world->physics.ode_movelimit = physics_ode_movelimit.value / world->physics.ode_step;
2653 World_Physics_UpdateODE(world);
2655 // copy physics properties from entities to physics engine
2658 for (i = 0, ed = prog->edicts + i;i < prog->num_edicts;i++, ed++)
2659 if (!prog->edicts[i].priv.required->free)
2660 World_Physics_Frame_BodyFromEntity(world, ed);
2661 // oh, and it must be called after all bodies were created
2662 for (i = 0, ed = prog->edicts + i;i < prog->num_edicts;i++, ed++)
2663 if (!prog->edicts[i].priv.required->free)
2664 World_Physics_Frame_JointFromEntity(world, ed);
2667 tdelta2 = Sys_DirtyTime();
2669 for (i = 0;i < world->physics.ode_iterations;i++)
2672 dWorldSetGravity((dWorldID)world->physics.ode_world, 0, 0, -gravity * physics_ode_world_gravitymod.value);
2673 // set the tolerance for closeness of objects
2674 dWorldSetContactSurfaceLayer((dWorldID)world->physics.ode_world, max(0, physics_ode_contactsurfacelayer.value));
2676 // run collisions for the current world state, creating JointGroup
2677 tdelta3 = Sys_DirtyTime();
2678 dSpaceCollide((dSpaceID)world->physics.ode_space, (void *)world, nearCallback);
2679 collisiontime += (Sys_DirtyTime() - tdelta3)*10000;
2681 // run physics (move objects, calculate new velocities)
2682 if (physics_ode_worldstep.integer == 2)
2684 dWorldSetQuickStepNumIterations((dWorldID)world->physics.ode_world, bound(1, physics_ode_worldstep_iterations.integer, 200));
2685 dWorldQuickStep((dWorldID)world->physics.ode_world, world->physics.ode_step);
2687 #ifdef ODE_USE_STEPFAST
2688 else if (physics_ode_worldstep.integer == 1)
2689 dWorldStepFast1((dWorldID)world->physics.ode_world, world->physics.ode_step, bound(1, physics_ode_worldstep_iterations.integer, 200));
2692 dWorldStep((dWorldID)world->physics.ode_world, world->physics.ode_step);
2694 // clear the JointGroup now that we're done with it
2695 dJointGroupEmpty((dJointGroupID)world->physics.ode_contactgroup);
2697 simulationtime = (Sys_DirtyTime() - tdelta2)*10000;
2699 // copy physics properties from physics engine to entities and do some stats
2702 for (i = 1, ed = prog->edicts + i;i < prog->num_edicts;i++, ed++)
2703 if (!prog->edicts[i].priv.required->free)
2704 World_Physics_Frame_BodyToEntity(world, ed);
2707 if (physics_ode_printstats.integer)
2711 world->physics.ode_numobjects = 0;
2712 world->physics.ode_activeovjects = 0;
2713 for (i = 1, ed = prog->edicts + i;i < prog->num_edicts;i++, ed++)
2715 if (prog->edicts[i].priv.required->free)
2717 body = (dBodyID)prog->edicts[i].priv.server->ode_body;
2720 world->physics.ode_numobjects++;
2721 if (dBodyIsEnabled(body))
2722 world->physics.ode_activeovjects++;
2724 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_DirtyTime() - tdelta)*10000, world->physics.ode_numobjects, world->physics.ode_activeovjects, (world->physics.ode_numobjects - world->physics.ode_activeovjects));