]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
more ODE fixes
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 23 Oct 2009 13:01:52 +0000 (13:01 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 23 Oct 2009 13:01:52 +0000 (13:01 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@9388 d7cf8633-e32d-0410-b094-e92efae38249

model_shared.c
world.c

index d46e2baf65d7234e880c7f8e29b9e6817e436fe7..dcf5d8c763f913e7cba30163ae4f4dff632c1290 100644 (file)
@@ -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 42fd70de6a584ef5cedc8b4315ee81e3b16526ff..0df8faccc3f8a41f7503b0053f3f4ccd06d3bce9 100644 (file)
--- 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: