From 86cca99dfa1cc61a9d27e26d8c1f28183dc30ab5 Mon Sep 17 00:00:00 2001 From: divverent Date: Fri, 23 Oct 2009 13:01:52 +0000 Subject: [PATCH] more ODE fixes git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@9388 d7cf8633-e32d-0410-b094-e92efae38249 --- model_shared.c | 1 + world.c | 23 ++++++++++++++--------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/model_shared.c b/model_shared.c index d46e2baf..dcf5d8c7 100644 --- a/model_shared.c +++ b/model_shared.c @@ -1263,6 +1263,7 @@ void Mod_CreateCollisionMesh(dp_model_t *mod) if (!mempool && mod->brush.parentmodel) mempool = mod->brush.parentmodel->mempool; // make a single combined collision mesh for physics engine use + // TODO rewrite this to use the collision brushes as source, to fix issues with e.g. common/caulk which creates no drawsurface numcollisionmeshtriangles = 0; for (k = 0;k < mod->nummodelsurfaces;k++) { diff --git a/world.c b/world.c index 42fd70de..0df8facc 100644 --- a/world.c +++ b/world.c @@ -1731,7 +1731,7 @@ static void World_Physics_Frame_JointFromEntity(world_t *world, prvm_edict_t *ed int enemy = 0, aiment = 0; vec3_t origin, velocity, angles, forward, left, up, movedir; prvm_eval_t *val; - float H = (!strcmp(prog->name, "server") ? sv.frametime : cl.mtime[0] - cl.mtime[1]) / world->physics.ode_iterations; + float H = (!strcmp(prog->name, "server") ? sv.frametime : cl.mtime[0] - cl.mtime[1]) / bound(1, physics_ode_iterationsperframe.integer, 1000); VectorClear(origin); VectorClear(velocity); VectorClear(angles); @@ -1789,6 +1789,12 @@ static void World_Physics_Frame_JointFromEntity(world_t *world, prvm_edict_t *ed j = 0; break; } + if(ed->priv.server->ode_joint) + { + //Con_Printf("deleted old joint %i\n", (int) (ed - prog->edicts)); + dJointAttach(ed->priv.server->ode_joint, 0, 0); + dJointDestroy(ed->priv.server->ode_joint); + } ed->priv.server->ode_joint = (void *) j; ed->priv.server->ode_joint_type = jointtype; ed->priv.server->ode_joint_enemy = enemy; @@ -1799,6 +1805,7 @@ static void World_Physics_Frame_JointFromEntity(world_t *world, prvm_edict_t *ed VectorCopy(movedir, ed->priv.server->ode_joint_movedir); if(j) { + //Con_Printf("made new joint %i\n", (int) (ed - prog->edicts)); dJointSetData(j, (void *) ed); if(enemy) b1 = (dBodyID)prog->edicts[enemy].priv.server->ode_body; @@ -1806,10 +1813,7 @@ static void World_Physics_Frame_JointFromEntity(world_t *world, prvm_edict_t *ed b2 = (dBodyID)prog->edicts[aiment].priv.server->ode_body; dJointAttach(j, b1, b2); #define SETPARAMS(t,id) \ - if(movedir[0] > 0) \ - dJointSet##t##Param(j, dParamCFM##id, movedir[0]); \ - else if(movedir[0] < 0) \ - dJointSet##t##Param(j, dParamCFM##id, 0); \ + dJointSet##t##Param(j, dParamStopCFM##id, movedir[0]); \ if(movedir[1] > 0) \ { \ dJointSet##t##Param(j, dParamLoStop##id, 0); \ @@ -1817,11 +1821,12 @@ static void World_Physics_Frame_JointFromEntity(world_t *world, prvm_edict_t *ed dJointSet##t##Param(j, dParamFMax##id, movedir[1]); \ } \ else \ + { \ + dJointSet##t##Param(j, dParamLoStop##id, -dInfinity); \ + dJointSet##t##Param(j, dParamHiStop##id, dInfinity); \ dJointSet##t##Param(j, dParamFMax##id, -movedir[1]); \ - if(movedir[2] > 0) \ - dJointSet##t##Param(j, dParamStopERP##id, movedir[2]); \ - else if(movedir[2] < 0) \ - dJointSet##t##Param(j, dParamStopERP##id, 0) + } \ + dJointSet##t##Param(j, dParamStopERP##id, movedir[2]) switch(jointtype) { case JOINTTYPE_POINT: -- 2.39.2