]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
fixed collision bug on q3 light cones and other non-solid brushes that are not axial...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 8 Jun 2006 11:16:52 +0000 (11:16 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 8 Jun 2006 11:16:52 +0000 (11:16 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6439 d7cf8633-e32d-0410-b094-e92efae38249

collision.c
collision.h
model_brush.c

index fb7da1bbe8cd7463204696f86ec2d26cf5f62937..82e65b0a4cb90fe690282e2466c2fe214db963aa 100644 (file)
@@ -133,7 +133,7 @@ float furthestplanedist_float(const float *normal, const colpointf_t *points, in
 }
 
 
-colbrushf_t *Collision_NewBrushFromPlanes(mempool_t *mempool, int numoriginalplanes, const colplanef_t *originalplanes)
+colbrushf_t *Collision_NewBrushFromPlanes(mempool_t *mempool, int numoriginalplanes, const colplanef_t *originalplanes, int supercontents)
 {
        // TODO: planesbuf could be replaced by a remapping table
        int j, k, m, w;
@@ -262,7 +262,6 @@ colbrushf_t *Collision_NewBrushFromPlanes(mempool_t *mempool, int numoriginalpla
                // add the new plane
                VectorCopy(originalplanes[j].normal, planesbuf[numplanesbuf].normal);
                planesbuf[numplanesbuf].dist = originalplanes[j].dist;
-               planesbuf[numplanesbuf].supercontents = originalplanes[j].supercontents;
                planesbuf[numplanesbuf].q3surfaceflags = originalplanes[j].q3surfaceflags;
                planesbuf[numplanesbuf].texture = originalplanes[j].texture;
                numplanesbuf++;
@@ -285,6 +284,7 @@ colbrushf_t *Collision_NewBrushFromPlanes(mempool_t *mempool, int numoriginalpla
 
        // allocate the brush and copy to it
        brush = (colbrushf_t *)Mem_Alloc(mempool, sizeof(colbrushf_t) + sizeof(colpointf_t) * numpointsbuf + sizeof(colplanef_t) * numplanesbuf + sizeof(int) * numelementsbuf);
+       brush->supercontents = supercontents;
        brush->numplanes = numplanesbuf;
        brush->numpoints = numpointsbuf;
        brush->numtriangles = numelementsbuf / 3;
@@ -303,10 +303,8 @@ colbrushf_t *Collision_NewBrushFromPlanes(mempool_t *mempool, int numoriginalpla
                brush->planes[j].normal[1] = planesbuf[j].normal[1];
                brush->planes[j].normal[2] = planesbuf[j].normal[2];
                brush->planes[j].dist = planesbuf[j].dist;
-               brush->planes[j].supercontents = planesbuf[j].supercontents;
                brush->planes[j].q3surfaceflags = planesbuf[j].q3surfaceflags;
                brush->planes[j].texture = planesbuf[j].texture;
-               brush->supercontents |= brush->planes[j].supercontents;
        }
        for (j = 0;j < brush->numtriangles * 3;j++)
                brush->elements[j] = elementsbuf[j];
@@ -518,7 +516,7 @@ colbrushf_t *Collision_AllocBrushFromPermanentPolygonFloat(mempool_t *mempool, i
 // NOTE: start and end of each brush pair must have same numplanes/numpoints
 void Collision_TraceBrushBrushFloat(trace_t *trace, const colbrushf_t *thisbrush_start, const colbrushf_t *thisbrush_end, const colbrushf_t *thatbrush_start, const colbrushf_t *thatbrush_end)
 {
-       int nplane, nplane2, fstartsolid = true, fendsolid = true, brushsolid, hitsupercontents = 0, hitq3surfaceflags = 0;
+       int nplane, nplane2, fstartsolid = true, fendsolid = true, brushsolid, hitq3surfaceflags = 0;
        float enterfrac = -1, leavefrac = 1, d1, d2, f, imove, newimpactnormal[3], enterfrac2 = -1;
        const colplanef_t *startplane, *endplane;
        texture_t *hittexture = NULL;
@@ -585,7 +583,6 @@ void Collision_TraceBrushBrushFloat(trace_t *trace, const colbrushf_t *thisbrush
                                        enterfrac = f;
                                        enterfrac2 = f - collision_impactnudge.value * imove;
                                        VectorLerp(startplane->normal, enterfrac, endplane->normal, newimpactnormal);
-                                       hitsupercontents = startplane->supercontents;
                                        hitq3surfaceflags = startplane->q3surfaceflags;
                                        hittexture = startplane->texture;
                                }
@@ -640,7 +637,7 @@ void Collision_TraceBrushBrushFloat(trace_t *trace, const colbrushf_t *thisbrush
                        if (enterfrac < trace->realfraction)
                        {
                                enterfrac2 = enterfrac - collision_impactnudge.value * imove;
-                               trace->hitsupercontents = thatbrush_start->planes[0].supercontents;
+                               trace->hitsupercontents = thatbrush_start->supercontents;
                                trace->hitq3surfaceflags = thatbrush_start->planes[0].q3surfaceflags;
                                trace->hittexture = thatbrush_start->planes[0].texture;
                                trace->realfraction = bound(0, enterfrac, 1);
@@ -651,7 +648,7 @@ void Collision_TraceBrushBrushFloat(trace_t *trace, const colbrushf_t *thisbrush
                else
 #endif
                {
-                       trace->hitsupercontents = hitsupercontents;
+                       trace->hitsupercontents = thatbrush_start->supercontents;
                        trace->hitq3surfaceflags = hitq3surfaceflags;
                        trace->hittexture = hittexture;
                        trace->realfraction = bound(0, enterfrac, 1);
@@ -664,7 +661,7 @@ void Collision_TraceBrushBrushFloat(trace_t *trace, const colbrushf_t *thisbrush
 // NOTE: start and end brush pair must have same numplanes/numpoints
 void Collision_TraceLineBrushFloat(trace_t *trace, const vec3_t linestart, const vec3_t lineend, const colbrushf_t *thatbrush_start, const colbrushf_t *thatbrush_end)
 {
-       int nplane, fstartsolid = true, fendsolid = true, brushsolid, hitsupercontents = 0, hitq3surfaceflags = 0;
+       int nplane, fstartsolid = true, fendsolid = true, brushsolid, hitq3surfaceflags = 0;
        float enterfrac = -1, leavefrac = 1, d1, d2, f, imove, newimpactnormal[3], enterfrac2 = -1;
        const colplanef_t *startplane, *endplane;
        texture_t *hittexture = NULL;
@@ -709,7 +706,6 @@ void Collision_TraceLineBrushFloat(trace_t *trace, const vec3_t linestart, const
                                        enterfrac = f;
                                        enterfrac2 = f - collision_impactnudge.value * imove;
                                        VectorLerp(startplane->normal, enterfrac, endplane->normal, newimpactnormal);
-                                       hitsupercontents = startplane->supercontents;
                                        hitq3surfaceflags = startplane->q3surfaceflags;
                                        hittexture = startplane->texture;
                                }
@@ -764,7 +760,7 @@ void Collision_TraceLineBrushFloat(trace_t *trace, const vec3_t linestart, const
                        if (enterfrac < trace->realfraction)
                        {
                                enterfrac2 = enterfrac - collision_impactnudge.value * imove;
-                               trace->hitsupercontents = hitsupercontents;
+                               trace->hitsupercontents = thatbrush_start->supercontents;
                                trace->hitq3surfaceflags = hitq3surfaceflags;
                                trace->hittexture = hittexture;
                                trace->realfraction = bound(0, enterfrac, 1);
@@ -775,7 +771,7 @@ void Collision_TraceLineBrushFloat(trace_t *trace, const vec3_t linestart, const
                else
 #endif
                {
-                       trace->hitsupercontents = hitsupercontents;
+                       trace->hitsupercontents = thatbrush_start->supercontents;
                        trace->hitq3surfaceflags = hitq3surfaceflags;
                        trace->hittexture = hittexture;
                        trace->realfraction = bound(0, enterfrac, 1);
@@ -846,7 +842,6 @@ void Collision_TraceBrushTriangleMeshFloat(trace_t *trace, const colbrushf_t *th
        polyf_brush.supercontents = supercontents;
        for (i = 0;i < polyf_brush.numplanes;i++)
        {
-               polyf_brush.planes[i].supercontents = supercontents;
                polyf_brush.planes[i].q3surfaceflags = q3surfaceflags;
                polyf_brush.planes[i].texture = texture;
        }
@@ -961,7 +956,6 @@ void Collision_TraceBrushPolygonTransformFloat(trace_t *trace, const colbrushf_t
                Matrix4x4_Transform(polygonmatrixend, points + i * 3, polyf_brushend.points[i].v);
        for (i = 0;i < polyf_brushstart.numplanes;i++)
        {
-               polyf_brushstart.planes[i].supercontents = supercontents;
                polyf_brushstart.planes[i].q3surfaceflags = q3surfaceflags;
                polyf_brushstart.planes[i].texture = texture;
        }
@@ -1038,7 +1032,6 @@ colbrushf_t *Collision_BrushForBox(const matrix4x4_t *matrix, const vec3_t mins,
        brush->supercontents = supercontents;
        for (j = 0;j < brush->numplanes;j++)
        {
-               brush->planes[j].supercontents = supercontents;
                brush->planes[j].q3surfaceflags = q3surfaceflags;
                brush->planes[j].texture = texture;
                brush->planes[j].dist = furthestplanedist_float(brush->planes[j].normal, brush->points, brush->numpoints);
index 23370c69f084af95999e98c767f79974fb720040..bb539f5eef44903804987eefa61b984cc940783e 100644 (file)
@@ -66,11 +66,10 @@ colpointf_t;
 
 typedef struct colplanef_s
 {
+       struct texture_s *texture;
+       int q3surfaceflags;
        float normal[3];
        float dist;
-       int supercontents;
-       int q3surfaceflags;
-       struct texture_s *texture;
 }
 colplanef_t;
 
@@ -100,7 +99,7 @@ colbrushf_t;
 
 void Collision_CalcPlanesForPolygonBrushFloat(colbrushf_t *brush);
 colbrushf_t *Collision_AllocBrushFromPermanentPolygonFloat(mempool_t *mempool, int numpoints, float *points, int supercontents);
-colbrushf_t *Collision_NewBrushFromPlanes(mempool_t *mempool, int numoriginalplanes, const colplanef_t *originalplanes);
+colbrushf_t *Collision_NewBrushFromPlanes(mempool_t *mempool, int numoriginalplanes, const colplanef_t *originalplanes, int supercontents);
 void Collision_TraceBrushBrushFloat(trace_t *trace, const colbrushf_t *thisbrush_start, const colbrushf_t *thisbrush_end, const colbrushf_t *thatbrush_start, const colbrushf_t *thatbrush_end);
 void Collision_TraceBrushPolygonFloat(trace_t *trace, const colbrushf_t *thisbrush_start, const colbrushf_t *thisbrush_end, int numpoints, const float *points, int supercontents);
 void Collision_TraceBrushTriangleMeshFloat(trace_t *trace, const colbrushf_t *thisbrush_start, const colbrushf_t *thisbrush_end, int numtriangles, const int *element3i, const float *vertex3f, int supercontents, int q3surfaceflags, texture_t *texture, const vec3_t segmentmins, const vec3_t segmentmaxs);
index 3cda0c0b8a4f5afd837d8279b998501ec7de7fae..a6825e0d33c760674a75ad9851e1682d6fd712ea 100644 (file)
@@ -903,12 +903,12 @@ void Collision_ClipTrace_Box(trace_t *trace, const vec3_t cmins, const vec3_t cm
        cbox_planes[3].normal[0] =  0;cbox_planes[3].normal[1] = -1;cbox_planes[3].normal[2] =  0;cbox_planes[3].dist = maxs[1] - cmins[1];
        cbox_planes[4].normal[0] =  0;cbox_planes[4].normal[1] =  0;cbox_planes[4].normal[2] =  1;cbox_planes[4].dist = cmaxs[2] - mins[2];
        cbox_planes[5].normal[0] =  0;cbox_planes[5].normal[1] =  0;cbox_planes[5].normal[2] = -1;cbox_planes[5].dist = maxs[2] - cmins[2];
-       cbox_planes[0].supercontents = boxsupercontents;cbox_planes[0].q3surfaceflags = boxq3surfaceflags;cbox_planes[0].texture = boxtexture;
-       cbox_planes[1].supercontents = boxsupercontents;cbox_planes[1].q3surfaceflags = boxq3surfaceflags;cbox_planes[1].texture = boxtexture;
-       cbox_planes[2].supercontents = boxsupercontents;cbox_planes[2].q3surfaceflags = boxq3surfaceflags;cbox_planes[2].texture = boxtexture;
-       cbox_planes[3].supercontents = boxsupercontents;cbox_planes[3].q3surfaceflags = boxq3surfaceflags;cbox_planes[3].texture = boxtexture;
-       cbox_planes[4].supercontents = boxsupercontents;cbox_planes[4].q3surfaceflags = boxq3surfaceflags;cbox_planes[4].texture = boxtexture;
-       cbox_planes[5].supercontents = boxsupercontents;cbox_planes[5].q3surfaceflags = boxq3surfaceflags;cbox_planes[5].texture = boxtexture;
+       cbox_planes[0].q3surfaceflags = boxq3surfaceflags;cbox_planes[0].texture = boxtexture;
+       cbox_planes[1].q3surfaceflags = boxq3surfaceflags;cbox_planes[1].texture = boxtexture;
+       cbox_planes[2].q3surfaceflags = boxq3surfaceflags;cbox_planes[2].texture = boxtexture;
+       cbox_planes[3].q3surfaceflags = boxq3surfaceflags;cbox_planes[3].texture = boxtexture;
+       cbox_planes[4].q3surfaceflags = boxq3surfaceflags;cbox_planes[4].texture = boxtexture;
+       cbox_planes[5].q3surfaceflags = boxq3surfaceflags;cbox_planes[5].texture = boxtexture;
        memset(trace, 0, sizeof(trace_t));
        trace->hitsupercontentsmask = hitsupercontentsmask;
        trace->fraction = 1;
@@ -4493,12 +4493,11 @@ static void Mod_Q3BSP_LoadBrushes(lump_t *l)
                {
                        VectorCopy(out->firstbrushside[j].plane->normal, planes[j].normal);
                        planes[j].dist = out->firstbrushside[j].plane->dist;
-                       planes[j].supercontents = out->firstbrushside[j].texture->supercontents;
                        planes[j].q3surfaceflags = out->firstbrushside[j].texture->surfaceflags;
                        planes[j].texture = out->firstbrushside[j].texture;
                }
                // make the colbrush from the planes
-               out->colbrushf = Collision_NewBrushFromPlanes(loadmodel->mempool, out->numbrushsides, planes);
+               out->colbrushf = Collision_NewBrushFromPlanes(loadmodel->mempool, out->numbrushsides, planes, out->texture->supercontents);
        }
        if (planes)
                Mem_Free(planes);