]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
ode: Add more #ifdefs to ensure ODE is fully disabled without -DUSEODE
authorCloudwalk <cloudwalk009@gmail.com>
Wed, 21 Jul 2021 22:14:01 +0000 (18:14 -0400)
committerCloudwalk <cloudwalk009@gmail.com>
Wed, 21 Jul 2021 22:14:01 +0000 (18:14 -0400)
cl_parse.c
csprogs.c
makefile.inc
progs.h
prvm_cmds.c
sv_main.c
sv_phys.c
world.c

index 7e228eea772df580d9f4e8adf77802635a05b3f5..7dfd3a953b81be633bf108bc7a107da958a78d49 100644 (file)
@@ -3391,8 +3391,10 @@ static void CL_NetworkTimeReceived(double newtime)
        // update the csqc's server timestamps, critical for proper sync
        CSQC_UpdateNetworkTimes(cl.mtime[0], cl.mtime[1]);
 
+#ifdef USEODE
        if (cl.mtime[0] > cl.mtime[1])
                World_Physics_Frame(&cl.world, cl.mtime[0] - cl.mtime[1], cl.movevars_gravity);
+#endif
 
        // only lerp entities that also get an update in this frame, when lerp excess is used
        if(cl_lerpexcess.value > 0)
index f74a206b09e1df120e153d436d3049c8668cae82..9800fe0a907fecff8507ee1ed21e4ad84d502f2d 100644 (file)
--- a/csprogs.c
+++ b/csprogs.c
@@ -906,8 +906,10 @@ static void CLVM_free_edict(prvm_prog_t *prog, prvm_edict_t *ed)
        World_UnlinkEdict(ed);
        memset(ed->fields.fp, 0, prog->entityfields * sizeof(prvm_vec_t));
        VM_RemoveEdictSkeleton(prog, ed);
+#ifdef USEODE
        World_Physics_RemoveFromEntity(&cl.world, ed);
        World_Physics_RemoveJointFromEntity(&cl.world, ed);
+#endif
 }
 
 static void CLVM_count_edicts(prvm_prog_t *prog)
index 16dd546f0f1035299b369385af55e67837f15fc0..98228052394476b864b993cf73a65b0b8b34761d 100644 (file)
@@ -448,6 +448,22 @@ prepare :
 
 
 #this checks USEODE when compiling so it needs the ODE flags as well
+cl_parse.o: cl_parse.c
+       $(CHECKLEVEL2)
+       $(DO_CC) $(CFLAGS_ODE)
+
+cs_progs.o: cs_progs.c
+       $(CHECKLEVEL2)
+       $(DO_CC) $(CFLAGS_ODE)
+
+sv_main.o: sv_main.c
+       $(CHECKLEVEL2)
+       $(DO_CC) $(CFLAGS_ODE)
+
+sv_phys.o: sv_phys.c
+       $(CHECKLEVEL2)
+       $(DO_CC) $(CFLAGS_ODE)
+
 prvm_cmds.o: prvm_cmds.c
        $(CHECKLEVEL2)
        $(DO_CC) $(CFLAGS_ODE)
diff --git a/progs.h b/progs.h
index 0756c35b88b428ba26fc870323ad80c2df72cb85..25ee3988c9e3aaa1e824bc190a029abebd6e85cb 100644 (file)
--- a/progs.h
+++ b/progs.h
@@ -57,6 +57,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #define ODEFUNC_FORCE       3
 #define ODEFUNC_TORQUE      4
 
+#ifdef USEODE
 typedef struct edict_odefunc_s
 {
        int type;
@@ -64,6 +65,7 @@ typedef struct edict_odefunc_s
        vec3_t v2;
        struct edict_odefunc_s *next;
 }edict_odefunc_t;
+#endif
 
 typedef struct edict_engineprivate_s
 {
@@ -109,6 +111,7 @@ typedef struct edict_engineprivate_s
        frameblend_t frameblend[MAX_FRAMEBLENDS];
        skeleton_t skeleton;
 
+#ifdef USEODE
        // physics parameters
        qbool ode_physics;
        void *ode_body;
@@ -141,6 +144,7 @@ typedef struct edict_engineprivate_s
        vec3_t ode_joint_velocity; // second joint axis
        vec3_t ode_joint_movedir; // parameters
        void *ode_massbuf;
+#endif
 }
 edict_engineprivate_t;
 
index 269aac0091813f7b30daece4aceb4e0630ff1b5c..b731bcde2468c9b0f5f3a618d0babd2115be3de5 100644 (file)
@@ -6408,6 +6408,7 @@ void VM_getsurfacetriangle(prvm_prog_t *prog)
 // physics builtins
 //
 
+#ifdef USEODE
 #define VM_physics_ApplyCmd(ed,f) if (!ed->priv.server->ode_body) VM_physics_newstackfunction(prog, ed, f); else World_Physics_ApplyCmd(ed, f)
 
 static edict_odefunc_t *VM_physics_newstackfunction(prvm_prog_t *prog, prvm_edict_t *ed, edict_odefunc_t *f)
@@ -6426,14 +6427,17 @@ static edict_odefunc_t *VM_physics_newstackfunction(prvm_prog_t *prog, prvm_edic
        }
        return newfunc;
 }
+#endif
 
 // void(entity e, float physics_enabled) physics_enable = #;
 void VM_physics_enable(prvm_prog_t *prog)
 {
+#ifdef USEODE
        prvm_edict_t *ed;
        edict_odefunc_t f;
-       
+#endif
        VM_SAFEPARMCOUNT(2, VM_physics_enable);
+#ifdef USEODE
        ed = PRVM_G_EDICT(OFS_PARM0);
        if (!ed)
        {
@@ -6449,15 +6453,18 @@ void VM_physics_enable(prvm_prog_t *prog)
        }
        f.type = PRVM_G_FLOAT(OFS_PARM1) == 0 ? ODEFUNC_DISABLE : ODEFUNC_ENABLE;
        VM_physics_ApplyCmd(ed, &f);
+#endif
 }
 
 // void(entity e, vector force, vector relative_ofs) physics_addforce = #;
 void VM_physics_addforce(prvm_prog_t *prog)
 {
+#ifdef USEODE
        prvm_edict_t *ed;
        edict_odefunc_t f;
-       
+#endif
        VM_SAFEPARMCOUNT(3, VM_physics_addforce);
+#ifdef USEODE
        ed = PRVM_G_EDICT(OFS_PARM0);
        if (!ed)
        {
@@ -6475,15 +6482,18 @@ void VM_physics_addforce(prvm_prog_t *prog)
        VectorCopy(PRVM_G_VECTOR(OFS_PARM1), f.v1);
        VectorCopy(PRVM_G_VECTOR(OFS_PARM2), f.v2);
        VM_physics_ApplyCmd(ed, &f);
+#endif
 }
 
 // void(entity e, vector torque) physics_addtorque = #;
 void VM_physics_addtorque(prvm_prog_t *prog)
 {
+#ifdef USEODE
        prvm_edict_t *ed;
        edict_odefunc_t f;
-       
+#endif
        VM_SAFEPARMCOUNT(2, VM_physics_addtorque);
+#ifdef USEODE
        ed = PRVM_G_EDICT(OFS_PARM0);
        if (!ed)
        {
@@ -6500,6 +6510,7 @@ void VM_physics_addtorque(prvm_prog_t *prog)
        f.type = ODEFUNC_TORQUE;
        VectorCopy(PRVM_G_VECTOR(OFS_PARM1), f.v1);
        VM_physics_ApplyCmd(ed, &f);
+#endif
 }
 
 extern cvar_t prvm_coverage;
index d103ffe65c1fcba759f7a02d5f76053e2fd863ce..956b22acad367463cb547de78645fcbe8f1bfb73 100644 (file)
--- a/sv_main.c
+++ b/sv_main.c
@@ -2189,9 +2189,10 @@ static void SVVM_free_edict(prvm_prog_t *prog, prvm_edict_t *ed)
        PRVM_serveredictfloat(ed, solid) = 0;
 
        VM_RemoveEdictSkeleton(prog, ed);
+#ifdef USEODE
        World_Physics_RemoveFromEntity(&sv.world, ed);
        World_Physics_RemoveJointFromEntity(&sv.world, ed);
-
+#endif
        // make sure csqc networking is aware of the removed entity
        e = PRVM_NUM_FOR_EDICT(ed);
        sv.csqcentityversion[e] = 0;
index 5633a1d33a5d9c160b964f3b544bd73ec08a83c3..a918ea25603c7145aa59e09174643011a5e22152 100644 (file)
--- a/sv_phys.c
+++ b/sv_phys.c
@@ -3176,8 +3176,10 @@ void SV_Physics (void)
        PRVM_serverglobalfloat(frametime) = sv.frametime;
        prog->ExecuteProgram(prog, PRVM_serverfunction(StartFrame), "QC function StartFrame is missing");
 
+#ifdef USEODE
        // run physics engine
        World_Physics_Frame(&sv.world, sv.frametime, sv_gravity.value);
+#endif
 
 //
 // treat each object in turn
diff --git a/world.c b/world.c
index 39e0102cf63943b243bd7d8ade49681acdb7eb33..9bdf107911e93256f63e51d0ae7b88b25d747a5a 100644 (file)
--- a/world.c
+++ b/world.c
@@ -32,29 +32,45 @@ line of sight checks trace->inopen and trace->inwater, but bullets don't
 
 */
 
+#ifdef USEODE
 static void World_Physics_Init(void);
+#endif
 void World_Init(void)
 {
        Collision_Init();
+#ifdef USEODE
        World_Physics_Init();
+#endif
 }
 
+#ifdef USEODE
 static void World_Physics_Shutdown(void);
+#endif
 void World_Shutdown(void)
 {
+#ifdef USEODE
        World_Physics_Shutdown();
+#endif
 }
 
+#ifdef USEODE
 static void World_Physics_Start(world_t *world);
+#endif
 void World_Start(world_t *world)
 {
+#ifdef USEODE
        World_Physics_Start(world);
+#endif
 }
 
+#ifdef USEODE
 static void World_Physics_End(world_t *world);
+#endif
 void World_End(world_t *world)
 {
+#ifdef USEODE
        World_Physics_End(world);
+#endif
 }
 
 //============================================================================
@@ -1459,15 +1475,12 @@ static dllfunction_t odefuncs[] =
 //     {"dGeomTriMeshDataUpdate",                      (void **) &dGeomTriMeshDataUpdate},
        {NULL, NULL}
 };
-
 // Handle for ODE DLL
 dllhandle_t ode_dll = NULL;
 #endif
-#endif
 
 static void World_Physics_Init(void)
 {
-#ifdef USEODE
 #ifndef LINK_TO_LIBODE
        const char* dllnames [] =
        {
@@ -1551,12 +1564,9 @@ static void World_Physics_Init(void)
                }
 #endif
        }
-#endif
 }
-
 static void World_Physics_Shutdown(void)
 {
-#ifdef USEODE
 #ifndef LINK_TO_LIBODE
        if (ode_dll)
 #endif
@@ -1567,10 +1577,8 @@ static void World_Physics_Shutdown(void)
                ode_dll = NULL;
 #endif
        }
-#endif
 }
 
-#ifdef USEODE
 static void World_Physics_UpdateODE(world_t *world)
 {
        dWorldID odeworld;
@@ -1627,20 +1635,16 @@ static void World_Physics_EnableODE(world_t *world)
 
        World_Physics_UpdateODE(world);
 }
-#endif
 
 static void World_Physics_Start(world_t *world)
 {
-#ifdef USEODE
        if (world->physics.ode)
                return;
        World_Physics_EnableODE(world);
-#endif
 }
 
 static void World_Physics_End(world_t *world)
 {
-#ifdef USEODE
        if (world->physics.ode)
        {
                dWorldDestroy((dWorldID)world->physics.ode_world);
@@ -1648,17 +1652,14 @@ static void World_Physics_End(world_t *world)
                dJointGroupDestroy((dJointGroupID)world->physics.ode_contactgroup);
                world->physics.ode = false;
        }
-#endif
 }
 
 void World_Physics_RemoveJointFromEntity(world_t *world, prvm_edict_t *ed)
 {
        ed->priv.server->ode_joint_type = 0;
-#ifdef USEODE
        if(ed->priv.server->ode_joint)
                dJointDestroy((dJointID)ed->priv.server->ode_joint);
        ed->priv.server->ode_joint = NULL;
-#endif
 }
 
 void World_Physics_RemoveFromEntity(world_t *world, prvm_edict_t *ed)
@@ -1667,7 +1668,6 @@ void World_Physics_RemoveFromEntity(world_t *world, prvm_edict_t *ed)
 
        // entity is not physics controlled, free any physics data
        ed->priv.server->ode_physics = false;
-#ifdef USEODE
        if (ed->priv.server->ode_geom)
                dGeomDestroy((dGeomID)ed->priv.server->ode_geom);
        ed->priv.server->ode_geom = NULL;
@@ -1697,7 +1697,6 @@ void World_Physics_RemoveFromEntity(world_t *world, prvm_edict_t *ed)
                dBodyDestroy((dBodyID)ed->priv.server->ode_body);
        }
        ed->priv.server->ode_body = NULL;
-#endif
        if (ed->priv.server->ode_vertex3f)
                Mem_Free(ed->priv.server->ode_vertex3f);
        ed->priv.server->ode_vertex3f = NULL;
@@ -1720,7 +1719,6 @@ void World_Physics_RemoveFromEntity(world_t *world, prvm_edict_t *ed)
 
 void World_Physics_ApplyCmd(prvm_edict_t *ed, edict_odefunc_t *f)
 {
-#ifdef USEODE
        dBodyID body = (dBodyID)ed->priv.server->ode_body;
 
        switch(f->type)
@@ -1742,10 +1740,8 @@ void World_Physics_ApplyCmd(prvm_edict_t *ed, edict_odefunc_t *f)
        default:
                break;
        }
-#endif
 }
 
-#ifdef USEODE
 static void World_Physics_Frame_BodyToEntity(world_t *world, prvm_edict_t *ed)
 {
        prvm_prog_t *prog = world->prog;
@@ -3006,11 +3002,9 @@ static void nearCallback (void *data, dGeomID o1, dGeomID o2)
                dJointAttach(c, b1, b2);
        }
 }
-#endif
 
 void World_Physics_Frame(world_t *world, double frametime, double gravity)
 {
-#ifdef USEODE
        prvm_prog_t *prog = world->prog;
        double tdelta, tdelta2, tdelta3, simulationtime, collisiontime;
 
@@ -3117,5 +3111,5 @@ void World_Physics_Frame(world_t *world, double frametime, double gravity)
                        }
                }
        }
-#endif
 }
+#endif