]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
added collision_prefernudgedfraction cvar (defaults to 1), which should improve colli...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 18 Jan 2007 10:44:24 +0000 (10:44 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 18 Jan 2007 10:44:24 +0000 (10:44 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6700 d7cf8633-e32d-0410-b094-e92efae38249

collision.c
model_brush.c

index c41a2ff417246121e5b7e71e3d6cd741a9ceb43f..20fc83997119c3973d3561eafe3d08651e93806d 100644 (file)
@@ -12,6 +12,7 @@ cvar_t collision_startnudge = {0, "collision_startnudge", "0", "how much to bias
 cvar_t collision_endnudge = {0, "collision_endnudge", "0", "how much to bias collision trace end"};
 cvar_t collision_enternudge = {0, "collision_enternudge", "0", "how much to bias collision entry fraction"};
 cvar_t collision_leavenudge = {0, "collision_leavenudge", "0", "how much to bias collision exit fraction"};
+cvar_t collision_prefernudgedfraction = {0, "collision_prefernudgedfraction", "1", "whether to sort collision events by nudged fraction (1) or real fraction (0)"};
 
 void Collision_Init (void)
 {
@@ -20,6 +21,7 @@ void Collision_Init (void)
        Cvar_RegisterVariable(&collision_endnudge);
        Cvar_RegisterVariable(&collision_enternudge);
        Cvar_RegisterVariable(&collision_leavenudge);
+       Cvar_RegisterVariable(&collision_prefernudgedfraction);
 }
 
 
@@ -682,6 +684,8 @@ void Collision_TraceBrushBrushFloat(trace_t *trace, const colbrushf_t *thisbrush
                trace->hittexture = hittexture;
                trace->realfraction = bound(0, enterfrac, 1);
                trace->fraction = bound(0, enterfrac2, 1);
+               if (collision_prefernudgedfraction.integer)
+                       trace->realfraction = trace->fraction;
                VectorCopy(newimpactnormal, trace->plane.normal);
        }
        else
@@ -797,6 +801,8 @@ void Collision_TraceLineBrushFloat(trace_t *trace, const vec3_t linestart, const
                trace->hittexture = hittexture;
                trace->realfraction = bound(0, enterfrac, 1);
                trace->fraction = bound(0, enterfrac2, 1);
+               if (collision_prefernudgedfraction.integer)
+                       trace->realfraction = trace->fraction;
                VectorCopy(newimpactnormal, trace->plane.normal);
        }
        else
@@ -1263,6 +1269,9 @@ void Collision_TraceLineTriangleFloat(trace_t *trace, const vec3_t linestart, co
        // (the main fraction remains perfect)
        trace->fraction = f - collision_impactnudge.value * d;
 
+       if (collision_prefernudgedfraction.integer)
+               trace->realfraction = trace->fraction;
+
        // store the new trace plane (because collisions only happen from
        // the front this is always simply the triangle normal, never flipped)
        d = 1.0 / sqrt(faceplanenormallength2);
index 75398747848c6a7b10abca21dfda967e9cfe4e59..8f907bfb7198aa289bfe6f8289eae5ac325dbbc9 100644 (file)
@@ -614,6 +614,7 @@ RecursiveHullCheckTraceInfo_t;
 #define HULLCHECKSTATE_SOLID 1
 #define HULLCHECKSTATE_DONE 2
 
+extern cvar_t collision_prefernudgedfraction;
 static int Mod_Q1BSP_RecursiveHullCheck(RecursiveHullCheckTraceInfo_t *t, int num, double p1f, double p2f, double p1[3], double p2[3])
 {
        // status variables, these don't need to be saved on the stack when
@@ -768,6 +769,9 @@ loc0:
        midf = (t1 - DIST_EPSILON) / (t1 - t2);
        t->trace->fraction = bound(0, midf, 1);
 
+       if (collision_prefernudgedfraction.integer)
+               t->trace->realfraction = t->trace->fraction;
+
 #if COLLISIONPARANOID >= 3
        Con_Print("D");
 #endif