]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
make the endpos-in-solid workaround a cvar collision_endposnudge
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 4 Dec 2009 12:32:45 +0000 (12:32 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 4 Dec 2009 12:32:45 +0000 (12:32 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@9535 d7cf8633-e32d-0410-b094-e92efae38249

cl_collision.c
collision.c
collision.h
sv_phys.c

index f4744885794fd2a0a141d7cff21d3c0f83605766..959309386d84b7db0271dfd96725d72d0fcae3c5 100644 (file)
@@ -18,12 +18,12 @@ float CL_SelectTraceLine(const vec3_t start, const vec3_t end, vec3_t impact, ve
        vec3_t end;
        vec_t len = 0;
 
-       if(!VectorCompare(start, pEnd))
+       if(!VectorCompare(start, pEnd) && collision_endposnudge.value > 0)
        {
                // TRICK: make the trace 1 qu longer!
                VectorSubtract(pEnd, start, end);
                len = VectorNormalizeLength(end);
-               VectorAdd(pEnd, end, end);
+               VectorMA(pEnd, collision_endposnudge.value, end, end);
        }
        else
                VectorCopy(pEnd, end);
@@ -72,7 +72,7 @@ float CL_SelectTraceLine(const vec3_t start, const vec3_t end, vec3_t impact, ve
                Matrix4x4_Transform(&ent->inversematrix, end, endtransformed);
                Collision_ClipTrace_Box(&trace, ent->model->normalmins, ent->model->normalmaxs, starttransformed, vec3_origin, vec3_origin, endtransformed, SUPERCONTENTS_SOLID, SUPERCONTENTS_SOLID, 0, NULL);
 #ifdef COLLISION_STUPID_TRACE_ENDPOS_IN_SOLID_WORKAROUND
-               if(!VectorCompare(start, pEnd))
+               if(!VectorCompare(start, pEnd) && collision_endposnudge.value > 0)
                        Collision_ShortenTrace(&trace, len / (len + 1), pEnd);
 #endif
                if (maxrealfrac < trace.realfraction)
@@ -463,12 +463,12 @@ trace_t CL_TraceLine(const vec3_t start, const vec3_t end, int type, prvm_edict_
        vec3_t end;
        vec_t len = 0;
 
-       if(!VectorCompare(start, pEnd))
+       if(!VectorCompare(start, pEnd) && collision_endposnudge.value > 0)
        {
                // TRICK: make the trace 1 qu longer!
                VectorSubtract(pEnd, start, end);
                len = VectorNormalizeLength(end);
-               VectorAdd(pEnd, end, end);
+               VectorMA(pEnd, collision_endposnudge.value, end, end);
        }
        else
                VectorCopy(pEnd, end);
@@ -657,7 +657,7 @@ skipnetworkplayers:
 
 finished:
 #ifdef COLLISION_STUPID_TRACE_ENDPOS_IN_SOLID_WORKAROUND
-       if(!VectorCompare(start, pEnd))
+       if(!VectorCompare(start, pEnd) && collision_endposnudge.value > 0)
                Collision_ShortenTrace(&cliptrace, len / (len + 1), pEnd);
 #endif
        return cliptrace;
@@ -701,12 +701,12 @@ trace_t CL_TraceBox(const vec3_t start, const vec3_t mins, const vec3_t maxs, co
        vec3_t end;
        vec_t len = 0;
 
-       if(!VectorCompare(start, pEnd))
+       if(!VectorCompare(start, pEnd) && collision_endposnudge.value > 0)
        {
                // TRICK: make the trace 1 qu longer!
                VectorSubtract(pEnd, start, end);
                len = VectorNormalizeLength(end);
-               VectorAdd(pEnd, end, end);
+               VectorMA(pEnd, collision_endposnudge.value, end, end);
        }
        else
                VectorCopy(pEnd, end);
@@ -918,7 +918,7 @@ skipnetworkplayers:
 
 finished:
 #ifdef COLLISION_STUPID_TRACE_ENDPOS_IN_SOLID_WORKAROUND
-       if(!VectorCompare(start, pEnd))
+       if(!VectorCompare(start, pEnd) && collision_endposnudge.value > 0)
                Collision_ShortenTrace(&cliptrace, len / (len + 1), pEnd);
 #endif
        return cliptrace;
index e5b07548788bbd28ab5c1f0ca275c766accb1d65..89bc6f636b08f5557ea6f5ced3ec64d3c0b57a83 100644 (file)
@@ -15,6 +15,9 @@ cvar_t collision_endnudge = {0, "collision_endnudge", "0", "how much to bias col
 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)"};
+#ifdef COLLISION_STUPID_TRACE_ENDPOS_IN_SOLID_WORKAROUND
+cvar_t collision_endposnudge = {0, "collision_endposnudge", "0", "workaround to fix trace_endpos sometimes being returned where it would be inside solid by making that collision hit (recommended: values like 1)"};
+#endif
 
 void Collision_Init (void)
 {
@@ -24,6 +27,9 @@ void Collision_Init (void)
        Cvar_RegisterVariable(&collision_enternudge);
        Cvar_RegisterVariable(&collision_leavenudge);
        Cvar_RegisterVariable(&collision_prefernudgedfraction);
+#ifdef COLLISION_STUPID_TRACE_ENDPOS_IN_SOLID_WORKAROUND
+       Cvar_RegisterVariable(&collision_endposnudge);
+#endif
 }
 
 
index e673381ede73576993b707e370340d8f8b1e5a25..52c52e87c14997c535a01f96cafed97b7238d603 100644 (file)
@@ -171,8 +171,11 @@ void Collision_ShortenTrace(trace_t *trace, float shorten_factor, const vec3_t e
 // 3 = spew detailed trace flow (bsp tree recursion info)
 #define COLLISIONPARANOID 0
 
-// make every trace 1qu longer, and shorten the result, to work around a stupid bug somewhere
-//#define COLLISION_STUPID_TRACE_ENDPOS_IN_SOLID_WORKAROUND
+// make every trace <collision_endposnudge>qu longer, and shorten the result, to work around a stupid bug somewhere
+#define COLLISION_STUPID_TRACE_ENDPOS_IN_SOLID_WORKAROUND
+#ifdef COLLISION_STUPID_TRACE_ENDPOS_IN_SOLID_WORKAROUND
+extern cvar_t collision_endposnudge;
+#endif
 
 
 #endif
index 6c9d2db7cb34d12fe765139734133c6e156fff30..75b7942d64b4b1c56926c4124ba975b295ca8a2d 100644 (file)
--- a/sv_phys.c
+++ b/sv_phys.c
@@ -271,12 +271,12 @@ trace_t SV_TraceLine(const vec3_t start, const vec3_t end, int type, prvm_edict_
        vec3_t end;
        vec_t len = 0;
 
-       if(!VectorCompare(start, pEnd))
+       if(!VectorCompare(start, pEnd) && collision_endposnudge.value > 0)
        {
                // TRICK: make the trace 1 qu longer!
                VectorSubtract(pEnd, start, end);
                len = VectorNormalizeLength(end);
-               VectorAdd(pEnd, end, end);
+               VectorMA(pEnd, collision_endposnudge.value, end, end);
        }
        else
                VectorCopy(pEnd, end);
@@ -397,7 +397,7 @@ trace_t SV_TraceLine(const vec3_t start, const vec3_t end, int type, prvm_edict_
 
 finished:
 #ifdef COLLISION_STUPID_TRACE_ENDPOS_IN_SOLID_WORKAROUND
-       if(!VectorCompare(start, pEnd))
+       if(!VectorCompare(start, pEnd) && collision_endposnudge.value > 0)
                Collision_ShortenTrace(&cliptrace, len / (len + 1), pEnd);
 #endif
        return cliptrace;
@@ -450,12 +450,12 @@ trace_t SV_TraceBox(const vec3_t start, const vec3_t mins, const vec3_t maxs, co
        vec3_t end;
        vec_t len = 0;
 
-       if(!VectorCompare(start, pEnd))
+       if(!VectorCompare(start, pEnd) && collision_endposnudge.value > 0)
        {
                // TRICK: make the trace 1 qu longer!
                VectorSubtract(pEnd, start, end);
                len = VectorNormalizeLength(end);
-               VectorAdd(pEnd, end, end);
+               VectorMA(pEnd, collision_endposnudge.value, end, end);
        }
        else
                VectorCopy(pEnd, end);
@@ -597,7 +597,7 @@ trace_t SV_TraceBox(const vec3_t start, const vec3_t mins, const vec3_t maxs, co
 
 finished:
 #ifdef COLLISION_STUPID_TRACE_ENDPOS_IN_SOLID_WORKAROUND
-       if(!VectorCompare(start, pEnd))
+       if(!VectorCompare(start, pEnd) && collision_endposnudge.value > 0)
                Collision_ShortenTrace(&cliptrace, len / (len + 1), pEnd);
 #endif
        return cliptrace;