]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
refactored end code in Collision_Trace*BrushFloat functions to fix a severe logic...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 4 Feb 2007 12:54:09 +0000 (12:54 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 4 Feb 2007 12:54:09 +0000 (12:54 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6788 d7cf8633-e32d-0410-b094-e92efae38249

collision.c

index 87c10b739b9d50ce6a1522b0a702a3776b98fbce..50812e5ec78b38ec0ce6144f84955c326c4941d3 100644 (file)
@@ -668,31 +668,33 @@ void Collision_TraceBrushBrushFloat(trace_t *trace, const colbrushf_t *thisbrush
        // at this point we know the trace overlaps the brush because it was not
        // rejected at any point in the loop above
 
-       // see if this brush can block the trace or not according to contents
-       if (trace->hitsupercontentsmask & thatbrush_start->supercontents)
+       // see if the trace started outside the brush or not
+       if (enterfrac > -1)
        {
-               if (enterfrac == -1)
+               // started outside, and overlaps, therefore there is a collision here
+               // store out the impact information
+               if (trace->hitsupercontentsmask & thatbrush_start->supercontents)
                {
-                       trace->startsupercontents |= thatbrush_start->supercontents;
-                       trace->startsolid = true;
-                       if (leavefrac < 1)
-                               trace->allsolid = true;
+                       trace->hitsupercontents = thatbrush_start->supercontents;
+                       trace->hitq3surfaceflags = hitq3surfaceflags;
+                       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);
                }
-               // store out the impact information
-               trace->hitsupercontents = thatbrush_start->supercontents;
-               trace->hitq3surfaceflags = hitq3surfaceflags;
-               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
        {
-               // this brush can not block the trace, but it can update start contents
-               if (enterfrac == -1)
-                       trace->startsupercontents |= thatbrush_start->supercontents;
+               // started inside, update startsolid and friends
+               trace->startsupercontents |= thatbrush_start->supercontents;
+               if (trace->hitsupercontentsmask & thatbrush_start->supercontents)
+               {
+                       trace->startsolid = true;
+                       if (leavefrac < 1)
+                               trace->allsolid = true;
+               }
        }
 }
 
@@ -785,31 +787,33 @@ void Collision_TraceLineBrushFloat(trace_t *trace, const vec3_t linestart, const
        // at this point we know the trace overlaps the brush because it was not
        // rejected at any point in the loop above
 
-       // see if this brush can block the trace or not according to contents
-       if (trace->hitsupercontentsmask & thatbrush_start->supercontents)
+       // see if the trace started outside the brush or not
+       if (enterfrac > -1)
        {
-               if (enterfrac == -1)
+               // started outside, and overlaps, therefore there is a collision here
+               // store out the impact information
+               if (trace->hitsupercontentsmask & thatbrush_start->supercontents)
                {
-                       trace->startsupercontents |= thatbrush_start->supercontents;
-                       trace->startsolid = true;
-                       if (leavefrac < 1)
-                               trace->allsolid = true;
+                       trace->hitsupercontents = thatbrush_start->supercontents;
+                       trace->hitq3surfaceflags = hitq3surfaceflags;
+                       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);
                }
-               // store out the impact information
-               trace->hitsupercontents = thatbrush_start->supercontents;
-               trace->hitq3surfaceflags = hitq3surfaceflags;
-               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
        {
-               // this brush can not block the trace, but it can update start contents
-               if (enterfrac == -1)
-                       trace->startsupercontents |= thatbrush_start->supercontents;
+               // started inside, update startsolid and friends
+               trace->startsupercontents |= thatbrush_start->supercontents;
+               if (trace->hitsupercontentsmask & thatbrush_start->supercontents)
+               {
+                       trace->startsolid = true;
+                       if (leavefrac < 1)
+                               trace->allsolid = true;
+               }
        }
 }