changed collision code to report supercontents, surfaceflags, and texture that was...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 22 Mar 2006 05:22:21 +0000 (05:22 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 22 Mar 2006 05:22:21 +0000 (05:22 +0000)
decals no longer stick to sky (except in stock id1 q1bsp maps which have CONTENTS_SOLID sky)

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6165 d7cf8633-e32d-0410-b094-e92efae38249

cl_collision.c
cl_particles.c
collision.c
collision.h
model_alias.c
model_brush.c
r_shadow.c
world.c
world_cs.c

index 28f908e..1e426d2 100644 (file)
@@ -101,6 +101,9 @@ trace_t CL_TraceBox(const vec3_t start, const vec3_t mins, const vec3_t maxs, co
                                if (hitent)
                                        *hitent = cl.brushmodel_entities[n];
                                Matrix4x4_Transform3x3(&ent->matrix, trace.plane.normal, cliptrace.plane.normal);
+                               cliptrace.hitsupercontents = trace.hitsupercontents;
+                               cliptrace.hitq3surfaceflags = trace.hitq3surfaceflags;
+                               cliptrace.hittexture = trace.hittexture;
                        }
                        cliptrace.startsupercontents |= trace.startsupercontents;
                }
@@ -161,6 +164,9 @@ trace_t CL_TraceBox(const vec3_t start, const vec3_t mins, const vec3_t maxs, co
                                        if (hitent)
                                                *hitent = n;
                                        Matrix4x4_Transform3x3(&ent->matrix, trace.plane.normal, cliptrace.plane.normal);
+                                       cliptrace.hitsupercontents = trace.hitsupercontents;
+                                       cliptrace.hitq3surfaceflags = trace.hitq3surfaceflags;
+                                       cliptrace.hittexture = trace.hittexture;
                                }
                                cliptrace.startsupercontents |= trace.startsupercontents;
                        }
index 8222aa2..5958617 100644 (file)
@@ -231,8 +231,10 @@ void CL_SpawnDecalParticleForPoint(const vec3_t org, float maxdist, float size,
        {
                VectorRandom(org2);
                VectorMA(org, maxdist, org2, org2);
-               trace = CL_TraceBox(org, vec3_origin, vec3_origin, org2, true, &hitent, SUPERCONTENTS_SOLID, false);
-               if (bestfrac > trace.fraction)
+               trace = CL_TraceBox(org, vec3_origin, vec3_origin, org2, true, &hitent, SUPERCONTENTS_SOLID | SUPERCONTENTS_SKY, false);
+               // take the closest trace result that doesn't end up hitting a NOMARKS
+               // surface (sky for example)
+               if (bestfrac > trace.fraction && !(trace.hitq3surfaceflags & Q3SURFACEFLAG_NOMARKS))
                {
                        bestfrac = trace.fraction;
                        besthitent = hitent;
@@ -1199,15 +1201,24 @@ void CL_MoveParticles (void)
                        VectorCopy(p->org, org);
                        if (p->bounce)
                        {
-                               if (p->type == particletype + pt_rain)
+                               trace = CL_TraceBox(oldorg, vec3_origin, vec3_origin, p->org, true, &hitent, SUPERCONTENTS_SOLID | (p->type == particletype + pt_rain ? SUPERCONTENTS_LIQUIDSMASK : 0), false);
+                               // if the trace started in or hit something of SUPERCONTENTS_NODROP
+                               // or if the trace hit something flagged as NOIMPACT
+                               // then remove the particle
+                               if (trace.hitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT || ((trace.startsupercontents | trace.hitsupercontents) & SUPERCONTENTS_NODROP))
                                {
-                                       // raindrop - splash on solid/water/slime/lava
-                                       trace = CL_TraceBox(oldorg, vec3_origin, vec3_origin, p->org, true, NULL, SUPERCONTENTS_SOLID | SUPERCONTENTS_LIQUIDSMASK, false);
-                                       if (trace.fraction < 1)
+                                       p->type = NULL;
+                                       continue;
+                               }
+                               // react if the particle hit something
+                               if (trace.fraction < 1)
+                               {
+                                       VectorCopy(trace.endpos, p->org);
+                                       if (p->type == particletype + pt_rain)
                                        {
+                                               // raindrop - splash on solid/water/slime/lava
                                                int count;
                                                // convert from a raindrop particle to a rainsplash decal
-                                               VectorCopy(trace.endpos, p->org);
                                                VectorCopy(trace.plane.normal, p->vel);
                                                VectorAdd(p->org, p->vel, p->org);
                                                p->type = particletype + pt_raindecal;
@@ -1222,24 +1233,24 @@ void CL_MoveParticles (void)
                                                while(count--)
                                                        particle(particletype + pt_spark, 0x000000, 0x707070, tex_particle, 0.25f, lhrandom(64, 255), 512, 1, 0, p->org[0], p->org[1], p->org[2], p->vel[0]*16, p->vel[1]*16, 32 + p->vel[2]*16, 0, 0, 32);
                                        }
-                               }
-                               else if (p->type == particletype + pt_blood)
-                               {
-                                       // blood - splash on solid
-                                       trace = CL_TraceBox(oldorg, vec3_origin, vec3_origin, p->org, true, &hitent, SUPERCONTENTS_SOLID, false);
-                                       if (trace.fraction < 1)
+                                       else if (p->type == particletype + pt_blood)
                                        {
-                                               // convert from a blood particle to a blood decal
-                                               VectorCopy(trace.endpos, p->org);
-                                               VectorCopy(trace.plane.normal, p->vel);
-                                               VectorAdd(p->org, p->vel, p->org);
-                                               if (cl_stainmaps.integer)
-                                                       R_Stain(p->org, 32, 32, 16, 16, p->alpha * p->size * (1.0f / 40.0f), 192, 48, 48, p->alpha * p->size * (1.0f / 40.0f));
+                                               // blood - splash on solid
+                                               if (trace.hitq3surfaceflags & Q3SURFACEFLAG_NOMARKS)
+                                               {
+                                                       p->type = NULL;
+                                                       continue;
+                                               }
                                                if (!cl_decals.integer)
                                                {
                                                        p->type = NULL;
                                                        continue;
                                                }
+                                               // convert from a blood particle to a blood decal
+                                               VectorCopy(trace.plane.normal, p->vel);
+                                               VectorAdd(p->org, p->vel, p->org);
+                                               if (cl_stainmaps.integer)
+                                                       R_Stain(p->org, 32, 32, 16, 16, p->alpha * p->size * (1.0f / 40.0f), 192, 48, 48, p->alpha * p->size * (1.0f / 40.0f));
 
                                                p->type = particletype + pt_decal;
                                                p->texnum = tex_blooddecal[rand()&7];
@@ -1254,25 +1265,19 @@ void CL_MoveParticles (void)
                                                p->gravity = 0;
                                                p->size *= 2.0f;
                                        }
-                               }
-                               else
-                               {
-                                       trace = CL_TraceBox(oldorg, vec3_origin, vec3_origin, p->org, true, NULL, SUPERCONTENTS_SOLID, false);
-                                       if (trace.fraction < 1)
+                                       else if (p->bounce < 0)
                                        {
-                                               VectorCopy(trace.endpos, p->org);
-                                               if (p->bounce < 0)
-                                               {
-                                                       p->type = NULL;
-                                                       continue;
-                                               }
-                                               else
-                                               {
-                                                       dist = DotProduct(p->vel, trace.plane.normal) * -p->bounce;
-                                                       VectorMA(p->vel, dist, trace.plane.normal, p->vel);
-                                                       if (DotProduct(p->vel, p->vel) < 0.03)
-                                                               VectorClear(p->vel);
-                                               }
+                                               // bounce -1 means remove on impact
+                                               p->type = NULL;
+                                               continue;
+                                       }
+                                       else
+                                       {
+                                               // anything else - bounce off solid
+                                               dist = DotProduct(p->vel, trace.plane.normal) * -p->bounce;
+                                               VectorMA(p->vel, dist, trace.plane.normal, p->vel);
+                                               if (DotProduct(p->vel, p->vel) < 0.03)
+                                                       VectorClear(p->vel);
                                        }
                                }
                        }
index e132341..6e27c4b 100644 (file)
@@ -133,8 +133,9 @@ float furthestplanedist_float(const float *normal, const colpointf_t *points, in
 }
 
 
-colbrushf_t *Collision_NewBrushFromPlanes(mempool_t *mempool, int numoriginalplanes, const mplane_t *originalplanes, int supercontents)
+colbrushf_t *Collision_NewBrushFromPlanes(mempool_t *mempool, int numoriginalplanes, const colplanef_t *originalplanes)
 {
+       // TODO: planesbuf could be replaced by a remapping table
        int j, k, m, w;
        int numpointsbuf = 0, maxpointsbuf = 256, numplanesbuf = 0, maxplanesbuf = 256, numelementsbuf = 0, maxelementsbuf = 256;
        colbrushf_t *brush;
@@ -261,6 +262,9 @@ 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++;
        }
 
@@ -280,7 +284,13 @@ colbrushf_t *Collision_NewBrushFromPlanes(mempool_t *mempool, int numoriginalpla
        }
 
        // allocate the brush and copy to it
-       brush = Collision_AllocBrushFloat(mempool, numpointsbuf, numplanesbuf, numelementsbuf / 3, supercontents);
+       brush = (colbrushf_t *)Mem_Alloc(mempool, sizeof(colbrushf_t) + sizeof(colpointf_t) * numpointsbuf + sizeof(colplanef_t) * numplanesbuf + sizeof(int) * numelementsbuf);
+       brush->numplanes = numplanesbuf;
+       brush->numpoints = numpointsbuf;
+       brush->numtriangles = numelementsbuf / 3;
+       brush->planes = (colplanef_t *)(brush + 1);
+       brush->points = (colpointf_t *)(brush->planes + brush->numplanes);
+       brush->elements = (int *)(brush->points + brush->numpoints);
        for (j = 0;j < brush->numpoints;j++)
        {
                brush->points[j].v[0] = pointsbuf[j].v[0];
@@ -293,6 +303,10 @@ 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];
@@ -319,20 +333,6 @@ colbrushf_t *Collision_NewBrushFromPlanes(mempool_t *mempool, int numoriginalpla
 
 
 
-colbrushf_t *Collision_AllocBrushFloat(mempool_t *mempool, int numpoints, int numplanes, int numtriangles, int supercontents)
-{
-       colbrushf_t *brush;
-       brush = (colbrushf_t *)Mem_Alloc(mempool, sizeof(colbrushf_t) + sizeof(colpointf_t) * numpoints + sizeof(colplanef_t) * numplanes + sizeof(int[3]) * numtriangles);
-       brush->supercontents = supercontents;
-       brush->numplanes = numplanes;
-       brush->numpoints = numpoints;
-       brush->numtriangles = numtriangles;
-       brush->planes = (colplanef_t *)(brush + 1);
-       brush->points = (colpointf_t *)(brush->planes + brush->numplanes);
-       brush->elements = (int *)(brush->points + brush->numpoints);
-       return brush;
-}
-
 void Collision_CalcPlanesForPolygonBrushFloat(colbrushf_t *brush)
 {
        int i;
@@ -518,16 +518,12 @@ 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, fendsolid, brushsolid;
-       float enterfrac, leavefrac, d1, d2, f, imove, newimpactnormal[3], enterfrac2;
+       int nplane, nplane2, fstartsolid = true, fendsolid = true, brushsolid, hitsupercontents = 0, hitq3surfaceflags = 0;
+       float enterfrac = -1, leavefrac = 1, d1, d2, f, imove, newimpactnormal[3], enterfrac2 = -1;
        const colplanef_t *startplane, *endplane;
+       texture_t *hittexture = NULL;
 
        VectorClear(newimpactnormal);
-       enterfrac = -1;
-       enterfrac2 = -1;
-       leavefrac = 1;
-       fstartsolid = true;
-       fendsolid = true;
 
        for (nplane = 0;nplane < thatbrush_start->numplanes + thisbrush_start->numplanes;nplane++)
        {
@@ -589,6 +585,9 @@ 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;
                                }
                        }
                }
@@ -641,6 +640,9 @@ 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->hitq3surfaceflags = thatbrush_start->planes[0].q3surfaceflags;
+                               trace->hittexture = thatbrush_start->planes[0].texture;
                                trace->realfraction = bound(0, enterfrac, 1);
                                trace->fraction = bound(0, enterfrac2, 1);
                                VectorLerp(thatbrush_start->planes[0].normal, enterfrac, thatbrush_end->planes[0].normal, trace->plane.normal);
@@ -649,6 +651,9 @@ void Collision_TraceBrushBrushFloat(trace_t *trace, const colbrushf_t *thisbrush
                else
 #endif
                {
+                       trace->hitsupercontents = hitsupercontents;
+                       trace->hitq3surfaceflags = hitq3surfaceflags;
+                       trace->hittexture = hittexture;
                        trace->realfraction = bound(0, enterfrac, 1);
                        trace->fraction = bound(0, enterfrac2, 1);
                        VectorCopy(newimpactnormal, trace->plane.normal);
@@ -659,16 +664,12 @@ 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, fendsolid, brushsolid;
-       float enterfrac, leavefrac, d1, d2, f, imove, newimpactnormal[3], enterfrac2;
+       int nplane, fstartsolid = true, fendsolid = true, brushsolid, hitsupercontents = 0, hitq3surfaceflags = 0;
+       float enterfrac = -1, leavefrac = 1, d1, d2, f, imove, newimpactnormal[3], enterfrac2 = -1;
        const colplanef_t *startplane, *endplane;
+       texture_t *hittexture = NULL;
 
        VectorClear(newimpactnormal);
-       enterfrac = -1;
-       enterfrac2 = -1;
-       leavefrac = 1;
-       fstartsolid = true;
-       fendsolid = true;
 
        for (nplane = 0;nplane < thatbrush_start->numplanes;nplane++)
        {
@@ -708,6 +709,9 @@ 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;
                                }
                        }
                }
@@ -760,6 +764,9 @@ 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->hitq3surfaceflags = hitq3surfaceflags;
+                               trace->hittexture = hittexture;
                                trace->realfraction = bound(0, enterfrac, 1);
                                trace->fraction = bound(0, enterfrac2, 1);
                                VectorLerp(thatbrush_start->planes[0].normal, enterfrac, thatbrush_end->planes[0].normal, trace->plane.normal);
@@ -768,6 +775,9 @@ void Collision_TraceLineBrushFloat(trace_t *trace, const vec3_t linestart, const
                else
 #endif
                {
+                       trace->hitsupercontents = hitsupercontents;
+                       trace->hitq3surfaceflags = hitq3surfaceflags;
+                       trace->hittexture = hittexture;
                        trace->realfraction = bound(0, enterfrac, 1);
                        trace->fraction = bound(0, enterfrac2, 1);
                        VectorCopy(newimpactnormal, trace->plane.normal);
@@ -825,7 +835,7 @@ void Collision_TraceBrushPolygonFloat(trace_t *trace, const colbrushf_t *thisbru
        Collision_TraceBrushBrushFloat(trace, thisbrush_start, thisbrush_end, &polyf_brush, &polyf_brush);
 }
 
-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, const vec3_t segmentmins, const vec3_t segmentmaxs)
+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)
 {
        int i;
        float facemins[3], facemaxs[3];
@@ -834,6 +844,12 @@ void Collision_TraceBrushTriangleMeshFloat(trace_t *trace, const colbrushf_t *th
        polyf_brush.points = polyf_points;
        polyf_brush.planes = polyf_planes;
        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;
+       }
        for (i = 0;i < numtriangles;i++, element3i += 3)
        {
                VectorCopy(vertex3f + element3i[0] * 3, polyf_points[0].v);
@@ -874,19 +890,25 @@ void Collision_TraceLinePolygonFloat(trace_t *trace, const vec3_t linestart, con
        Collision_TraceLineBrushFloat(trace, linestart, lineend, &polyf_brush, &polyf_brush);
 }
 
-void Collision_TraceLineTriangleMeshFloat(trace_t *trace, const vec3_t linestart, const vec3_t lineend, int numtriangles, const int *element3i, const float *vertex3f, int supercontents, const vec3_t segmentmins, const vec3_t segmentmaxs)
+void Collision_TraceLineTriangleMeshFloat(trace_t *trace, const vec3_t linestart, const vec3_t lineend, int numtriangles, const int *element3i, const float *vertex3f, int supercontents, int q3surfaceflags, texture_t *texture, const vec3_t segmentmins, const vec3_t segmentmaxs)
 {
        int i;
 #if 1
        // FIXME: snap vertices?
        for (i = 0;i < numtriangles;i++, element3i += 3)
-               Collision_TraceLineTriangleFloat(trace, linestart, lineend, vertex3f + element3i[0] * 3, vertex3f + element3i[1] * 3, vertex3f + element3i[2] * 3);
+               Collision_TraceLineTriangleFloat(trace, linestart, lineend, vertex3f + element3i[0] * 3, vertex3f + element3i[1] * 3, vertex3f + element3i[2] * 3, supercontents, q3surfaceflags, texture);
 #else
        polyf_brush.numpoints = 3;
        polyf_brush.numplanes = 5;
        polyf_brush.points = polyf_points;
        polyf_brush.planes = polyf_planes;
        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;
+       }
        for (i = 0;i < numtriangles;i++, element3i += 3)
        {
                float facemins[3], facemaxs[3];
@@ -915,7 +937,7 @@ static colpointf_t polyf_pointsstart[256], polyf_pointsend[256];
 static colplanef_t polyf_planesstart[256 + 2], polyf_planesend[256 + 2];
 static colbrushf_t polyf_brushstart, polyf_brushend;
 
-void Collision_TraceBrushPolygonTransformFloat(trace_t *trace, const colbrushf_t *thisbrush_start, const colbrushf_t *thisbrush_end, int numpoints, const float *points, const matrix4x4_t *polygonmatrixstart, const matrix4x4_t *polygonmatrixend, int supercontents)
+void Collision_TraceBrushPolygonTransformFloat(trace_t *trace, const colbrushf_t *thisbrush_start, const colbrushf_t *thisbrush_end, int numpoints, const float *points, const matrix4x4_t *polygonmatrixstart, const matrix4x4_t *polygonmatrixend, int supercontents, int q3surfaceflags, texture_t *texture)
 {
        int i;
        if (numpoints > 256)
@@ -937,6 +959,12 @@ void Collision_TraceBrushPolygonTransformFloat(trace_t *trace, const colbrushf_t
        polyf_brushend.supercontents = supercontents;
        for (i = 0;i < numpoints;i++)
                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;
+       }
        Collision_SnapCopyPoints(numpoints, polyf_pointsstart, polyf_pointsstart, COLLISION_SNAPSCALE, COLLISION_SNAP);
        Collision_SnapCopyPoints(numpoints, polyf_pointsend, polyf_pointsend, COLLISION_SNAPSCALE, COLLISION_SNAP);
        Collision_CalcPlanesForPolygonBrushFloat(&polyf_brushstart);
@@ -975,7 +1003,7 @@ void Collision_InitBrushForBox(void)
        }
 }
 
-colbrushf_t *Collision_BrushForBox(const matrix4x4_t *matrix, const vec3_t mins, const vec3_t maxs)
+colbrushf_t *Collision_BrushForBox(const matrix4x4_t *matrix, const vec3_t mins, const vec3_t maxs, int supercontents, int q3surfaceflags, texture_t *texture)
 {
        int i, j;
        vec3_t v;
@@ -1009,8 +1037,14 @@ colbrushf_t *Collision_BrushForBox(const matrix4x4_t *matrix, const vec3_t mins,
                        VectorNormalize(brush->planes[i].normal);
                }
        }
+       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);
+       }
        VectorCopy(brush->points[0].v, brush->mins);
        VectorCopy(brush->points[0].v, brush->maxs);
        for (j = 1;j < brush->numpoints;j++)
@@ -1032,7 +1066,7 @@ colbrushf_t *Collision_BrushForBox(const matrix4x4_t *matrix, const vec3_t mins,
        return brush;
 }
 
-void Collision_ClipTrace_BrushBox(trace_t *trace, const vec3_t cmins, const vec3_t cmaxs, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int hitsupercontentsmask)
+void Collision_ClipTrace_BrushBox(trace_t *trace, const vec3_t cmins, const vec3_t cmaxs, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int hitsupercontentsmask, int supercontents, int q3surfaceflags, texture_t *texture)
 {
        colbrushf_t *boxbrush, *thisbrush_start, *thisbrush_end;
        vec3_t startmins, startmaxs, endmins, endmaxs;
@@ -1042,9 +1076,9 @@ void Collision_ClipTrace_BrushBox(trace_t *trace, const vec3_t cmins, const vec3
        VectorAdd(start, maxs, startmaxs);
        VectorAdd(end, mins, endmins);
        VectorAdd(end, maxs, endmaxs);
-       boxbrush = Collision_BrushForBox(&identitymatrix, cmins, cmaxs);
-       thisbrush_start = Collision_BrushForBox(&identitymatrix, startmins, startmaxs);
-       thisbrush_end = Collision_BrushForBox(&identitymatrix, endmins, endmaxs);
+       boxbrush = Collision_BrushForBox(&identitymatrix, cmins, cmaxs, supercontents, q3surfaceflags, texture);
+       thisbrush_start = Collision_BrushForBox(&identitymatrix, startmins, startmaxs, 0, 0, NULL);
+       thisbrush_end = Collision_BrushForBox(&identitymatrix, endmins, endmaxs, 0, 0, NULL);
 
        memset(trace, 0, sizeof(trace_t));
        trace->hitsupercontentsmask = hitsupercontentsmask;
@@ -1106,7 +1140,7 @@ float Collision_ClipTrace_Line_Sphere(double *linestart, double *lineend, double
        return impactdist / linelength;
 }
 
-void Collision_TraceLineTriangleFloat(trace_t *trace, const vec3_t linestart, const vec3_t lineend, const float *point0, const float *point1, const float *point2)
+void Collision_TraceLineTriangleFloat(trace_t *trace, const vec3_t linestart, const vec3_t lineend, const float *point0, const float *point1, const float *point2, int supercontents, int q3surfaceflags, texture_t *texture)
 {
 #if 1
        // more optimized
@@ -1217,6 +1251,10 @@ void Collision_TraceLineTriangleFloat(trace_t *trace, const vec3_t linestart, co
        d = 1.0 / sqrt(faceplanenormallength2);
        VectorScale(faceplanenormal, d, trace->plane.normal);
        trace->plane.dist = faceplanedist * d;
+
+       trace->hitsupercontents = supercontents;
+       trace->hitq3surfaceflags = q3surfaceflags;
+       trace->hittexture = texture;
 #else
        float d1, d2, d, f, fnudged, impact[3], edgenormal[3], faceplanenormal[3], faceplanedist, edge[3];
 
@@ -1310,6 +1348,9 @@ void Collision_TraceLineTriangleFloat(trace_t *trace, const vec3_t linestart, co
        //trace->endpos[0] = linestart[0] + fnudged * (lineend[0] - linestart[0]);
        //trace->endpos[1] = linestart[1] + fnudged * (lineend[1] - linestart[1]);
        //trace->endpos[2] = linestart[2] + fnudged * (lineend[2] - linestart[2]);
+       trace->hitsupercontents = supercontents;
+       trace->hitq3surfaceflags = q3surfaceflags;
+       trace->hittexture = texture;
 #endif
 }
 
index a2ae053..d4131e6 100644 (file)
@@ -9,6 +9,7 @@ typedef struct plane_s
 }
 plane_t;
 
+struct texture_s;
 typedef struct trace_s
 {
        // if true, the entire trace was in solid (see hitsupercontentsmask)
@@ -42,6 +43,12 @@ typedef struct trace_s
        int hitsupercontentsmask;
        // the supercontents mask at the start point
        int startsupercontents;
+       // the supercontents of the impacted surface
+       int hitsupercontents;
+       // the q3 surfaceflags of the impacted surface
+       int hitq3surfaceflags;
+       // the texture of the impacted surface
+       struct texture_s *hittexture;
        // initially false, set when the start leaf is found
        // (set only by Q1BSP tracing and entity box tracing)
        int startfound;
@@ -61,6 +68,9 @@ typedef struct colplanef_s
 {
        float normal[3];
        float dist;
+       int supercontents;
+       int q3surfaceflags;
+       struct texture_s *texture;
 }
 colplanef_t;
 
@@ -88,26 +98,25 @@ typedef struct colbrushf_s
 }
 colbrushf_t;
 
-colbrushf_t *Collision_AllocBrushFloat(mempool_t *mempool, int numpoints, int numplanes, int numtriangles, int supercontents);
 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 mplane_t *originalplanes, int supercontents);
+colbrushf_t *Collision_NewBrushFromPlanes(mempool_t *mempool, int numoriginalplanes, const colplanef_t *originalplanes);
 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, const vec3_t segmentmins, const vec3_t segmentmaxs);
+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);
 void Collision_TraceLineBrushFloat(trace_t *trace, const vec3_t linestart, const vec3_t lineend, const colbrushf_t *thatbrush_start, const colbrushf_t *thatbrush_end);
 void Collision_TraceLinePolygonFloat(trace_t *trace, const vec3_t linestart, const vec3_t lineend, int numpoints, const float *points, int supercontents);
-void Collision_TraceLineTriangleMeshFloat(trace_t *trace, const vec3_t linestart, const vec3_t lineend, int numtriangles, const int *element3i, const float *vertex3f, int supercontents, const vec3_t segmentmins, const vec3_t segmentmaxs);
+void Collision_TraceLineTriangleMeshFloat(trace_t *trace, const vec3_t linestart, const vec3_t lineend, int numtriangles, const int *element3i, const float *vertex3f, int supercontents, int q3surfaceflags, texture_t *texture, const vec3_t segmentmins, const vec3_t segmentmaxs);
 void Collision_TracePointBrushFloat(trace_t *trace, const vec3_t point, const colbrushf_t *thatbrush);
 
-void Collision_TraceBrushPolygonTransformFloat(trace_t *trace, const colbrushf_t *thisbrush_start, const colbrushf_t *thisbrush_end, int numpoints, const float *points, const matrix4x4_t *polygonmatrixstart, const matrix4x4_t *polygonmatrixend, int supercontents);
+void Collision_TraceBrushPolygonTransformFloat(trace_t *trace, const colbrushf_t *thisbrush_start, const colbrushf_t *thisbrush_end, int numpoints, const float *points, const matrix4x4_t *polygonmatrixstart, const matrix4x4_t *polygonmatrixend, int supercontents, int q3surfaceflags, texture_t *texture);
 
-colbrushf_t *Collision_BrushForBox(const matrix4x4_t *matrix, const vec3_t mins, const vec3_t maxs);
+colbrushf_t *Collision_BrushForBox(const matrix4x4_t *matrix, const vec3_t mins, const vec3_t maxs, int supercontents, int q3surfaceflags, texture_t *texture);
 
 void Collision_BoundingBoxOfBrushTraceSegment(const colbrushf_t *start, const colbrushf_t *end, vec3_t mins, vec3_t maxs, float startfrac, float endfrac);
 
 float Collision_ClipTrace_Line_Sphere(double *linestart, double *lineend, double *sphereorigin, double sphereradius, double *impactpoint, double *impactnormal);
-void Collision_TraceLineTriangleFloat(trace_t *trace, const vec3_t linestart, const vec3_t lineend, const float *point0, const float *point1, const float *point2);
+void Collision_TraceLineTriangleFloat(trace_t *trace, const vec3_t linestart, const vec3_t lineend, const float *point0, const float *point1, const float *point2, int supercontents, int q3surfaceflags, texture_t *texture);
 
 // this enables rather large debugging spew!
 // settings:
index d36e737..6fd2a67 100644 (file)
@@ -234,7 +234,7 @@ static void Mod_MDLMD2MD3_TraceBox(model_t *model, int frame, trace_t *trace, co
                                vertex3f = Z_Malloc(maxvertices * sizeof(float[3]));
                        }
                        Mod_Alias_GetMesh_Vertex3f(model, frameblend, mesh, vertex3f);
-                       Collision_TraceLineTriangleMeshFloat(trace, start, end, mesh->num_triangles, mesh->data_element3i, vertex3f, SUPERCONTENTS_SOLID, segmentmins, segmentmaxs);
+                       Collision_TraceLineTriangleMeshFloat(trace, start, end, mesh->num_triangles, mesh->data_element3i, vertex3f, SUPERCONTENTS_SOLID, 0, surface->texture, segmentmins, segmentmaxs);
                }
        }
        else
@@ -252,8 +252,8 @@ static void Mod_MDLMD2MD3_TraceBox(model_t *model, int frame, trace_t *trace, co
                VectorAdd(start, boxmaxs, boxstartmaxs);
                VectorAdd(end, boxmins, boxendmins);
                VectorAdd(end, boxmaxs, boxendmaxs);
-               thisbrush_start = Collision_BrushForBox(&identitymatrix, boxstartmins, boxstartmaxs);
-               thisbrush_end = Collision_BrushForBox(&identitymatrix, boxendmins, boxendmaxs);
+               thisbrush_start = Collision_BrushForBox(&identitymatrix, boxstartmins, boxstartmaxs, 0, 0, NULL);
+               thisbrush_end = Collision_BrushForBox(&identitymatrix, boxendmins, boxendmaxs, 0, 0, NULL);
                for (i = 0, surface = model->data_surfaces;i < model->num_surfaces;i++, surface++)
                {
                        mesh = surface->groupmesh;
@@ -265,7 +265,7 @@ static void Mod_MDLMD2MD3_TraceBox(model_t *model, int frame, trace_t *trace, co
                                vertex3f = Z_Malloc(maxvertices * sizeof(float[3]));
                        }
                        Mod_Alias_GetMesh_Vertex3f(model, frameblend, mesh, vertex3f);
-                       Collision_TraceBrushTriangleMeshFloat(trace, thisbrush_start, thisbrush_end, mesh->num_triangles, mesh->data_element3i, vertex3f, SUPERCONTENTS_SOLID, segmentmins, segmentmaxs);
+                       Collision_TraceBrushTriangleMeshFloat(trace, thisbrush_start, thisbrush_end, mesh->num_triangles, mesh->data_element3i, vertex3f, SUPERCONTENTS_SOLID, 0, surface->texture, segmentmins, segmentmaxs);
                }
        }
 }
index d53885e..eded31a 100644 (file)
@@ -44,6 +44,12 @@ cvar_t mod_q3bsp_curves_collisions = {0, "mod_q3bsp_curves_collisions", "1", "en
 cvar_t mod_q3bsp_optimizedtraceline = {0, "mod_q3bsp_optimizedtraceline", "1", "whether to use optimized traceline code for line traces (as opposed to tracebox code)"};
 cvar_t mod_q3bsp_debugtracebrush = {0, "mod_q3bsp_debugtracebrush", "0", "selects different tracebrush bsp recursion algorithms (for debugging purposes only)"};
 
+static texture_t mod_q1bsp_texture_solid;
+static texture_t mod_q1bsp_texture_sky;
+static texture_t mod_q1bsp_texture_lava;
+static texture_t mod_q1bsp_texture_slime;
+static texture_t mod_q1bsp_texture_water;
+
 void Mod_BrushInit(void)
 {
 //     Cvar_RegisterVariable(&r_subdivide_size);
@@ -63,6 +69,31 @@ void Mod_BrushInit(void)
        Cvar_RegisterVariable(&mod_q3bsp_curves_collisions);
        Cvar_RegisterVariable(&mod_q3bsp_optimizedtraceline);
        Cvar_RegisterVariable(&mod_q3bsp_debugtracebrush);
+
+       memset(&mod_q1bsp_texture_solid, 0, sizeof(mod_q1bsp_texture_solid));
+       strlcpy(mod_q1bsp_texture_solid.name, "solid" , sizeof(mod_q1bsp_texture_solid.name));
+       mod_q1bsp_texture_solid.surfaceflags = 0;
+       mod_q1bsp_texture_solid.supercontents = SUPERCONTENTS_SOLID;
+
+       mod_q1bsp_texture_sky = mod_q1bsp_texture_solid;
+       strlcpy(mod_q1bsp_texture_sky.name, "sky", sizeof(mod_q1bsp_texture_sky.name));
+       mod_q1bsp_texture_sky.surfaceflags = Q3SURFACEFLAG_SKY | Q3SURFACEFLAG_NOIMPACT | Q3SURFACEFLAG_NOMARKS | Q3SURFACEFLAG_NODLIGHT | Q3SURFACEFLAG_NOLIGHTMAP;
+       mod_q1bsp_texture_sky.supercontents = SUPERCONTENTS_SKY | SUPERCONTENTS_NODROP;
+
+       mod_q1bsp_texture_lava = mod_q1bsp_texture_solid;
+       strlcpy(mod_q1bsp_texture_lava.name, "*lava", sizeof(mod_q1bsp_texture_lava.name));
+       mod_q1bsp_texture_lava.surfaceflags = Q3SURFACEFLAG_NOMARKS;
+       mod_q1bsp_texture_lava.supercontents = SUPERCONTENTS_LAVA | SUPERCONTENTS_NODROP;
+
+       mod_q1bsp_texture_slime = mod_q1bsp_texture_solid;
+       strlcpy(mod_q1bsp_texture_slime.name, "*slime", sizeof(mod_q1bsp_texture_slime.name));
+       mod_q1bsp_texture_slime.surfaceflags = Q3SURFACEFLAG_NOMARKS;
+       mod_q1bsp_texture_slime.supercontents = SUPERCONTENTS_SLIME;
+
+       mod_q1bsp_texture_water = mod_q1bsp_texture_solid;
+       strlcpy(mod_q1bsp_texture_water.name, "*water", sizeof(mod_q1bsp_texture_water.name));
+       mod_q1bsp_texture_water.surfaceflags = Q3SURFACEFLAG_NOMARKS;
+       mod_q1bsp_texture_water.supercontents = SUPERCONTENTS_WATER;
 }
 
 static mleaf_t *Mod_Q1BSP_PointInLeaf(model_t *model, const vec3_t p)
@@ -539,9 +570,9 @@ int Mod_Q1BSP_SuperContentsFromNativeContents(model_t *model, int nativecontents
                case CONTENTS_SLIME:
                        return SUPERCONTENTS_SLIME;
                case CONTENTS_LAVA:
-                       return SUPERCONTENTS_LAVA;
+                       return SUPERCONTENTS_LAVA | SUPERCONTENTS_NODROP;
                case CONTENTS_SKY:
-                       return SUPERCONTENTS_SKY;
+                       return SUPERCONTENTS_SKY | SUPERCONTENTS_NODROP;
        }
        return 0;
 }
@@ -612,6 +643,18 @@ loc0:
                        t->trace->inwater = true;
                if (num == 0)
                        t->trace->inopen = true;
+               if (num & SUPERCONTENTS_SOLID)
+                       t->trace->hittexture = &mod_q1bsp_texture_solid;
+               else if (num & SUPERCONTENTS_SKY)
+                       t->trace->hittexture = &mod_q1bsp_texture_sky;
+               else if (num & SUPERCONTENTS_LAVA)
+                       t->trace->hittexture = &mod_q1bsp_texture_lava;
+               else if (num & SUPERCONTENTS_SLIME)
+                       t->trace->hittexture = &mod_q1bsp_texture_slime;
+               else
+                       t->trace->hittexture = &mod_q1bsp_texture_water;
+               t->trace->hitq3surfaceflags = t->trace->hittexture->surfaceflags;
+               t->trace->hitsupercontents = num;
                if (num & t->trace->hitsupercontentsmask)
                {
                        // if the first leaf is solid, set startsolid
@@ -814,6 +857,12 @@ static void Mod_Q1BSP_TraceBox(struct model_s *model, int frame, trace_t *trace,
        else
                Mod_Q1BSP_RecursiveHullCheckPoint(&rhc, rhc.hull->firstclipnode);
 #endif
+       if (trace->fraction == 1)
+       {
+               trace->hitsupercontents = 0;
+               trace->hitq3surfaceflags = 0;
+               trace->hittexture = NULL;
+       }
 }
 
 void Collision_ClipTrace_Box(trace_t *trace, const vec3_t cmins, const vec3_t cmaxs, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int hitsupercontentsmask, int boxsupercontents)
@@ -1195,12 +1244,14 @@ static void Mod_Q1BSP_LoadTextures(lump_t *l)
                if (i == loadmodel->num_textures - 1)
                {
                        tx->basematerialflags |= MATERIALFLAG_WATER | MATERIALFLAG_LIGHTBOTHSIDES;
-                       tx->supercontents = SUPERCONTENTS_WATER;
+                       tx->supercontents = mod_q1bsp_texture_water.supercontents;
+                       tx->surfaceflags = mod_q1bsp_texture_water.surfaceflags;
                }
                else
                {
                        tx->basematerialflags |= MATERIALFLAG_WALL;
-                       tx->supercontents = SUPERCONTENTS_SOLID;
+                       tx->supercontents = mod_q1bsp_texture_solid.supercontents;
+                       tx->surfaceflags = mod_q1bsp_texture_solid.surfaceflags;
                }
                tx->currentframe = tx;
        }
@@ -1313,28 +1364,38 @@ static void Mod_Q1BSP_LoadTextures(lump_t *l)
                tx->basematerialflags = 0;
                if (tx->name[0] == '*')
                {
-                       // turb does not block movement
-                       tx->basematerialflags |= MATERIALFLAG_WATER | MATERIALFLAG_LIGHTBOTHSIDES;
                        // LordHavoc: some turbulent textures should not be affected by wateralpha
                        if (strncmp(tx->name,"*lava",5)
                         && strncmp(tx->name,"*teleport",9)
                         && strncmp(tx->name,"*rift",5)) // Scourge of Armagon texture
                                tx->basematerialflags |= MATERIALFLAG_WATERALPHA;
                        if (!strncmp(tx->name, "*lava", 5))
-                               tx->supercontents = SUPERCONTENTS_LAVA;
+                       {
+                               tx->supercontents = mod_q1bsp_texture_lava.supercontents;
+                               tx->surfaceflags = mod_q1bsp_texture_lava.surfaceflags;
+                       }
                        else if (!strncmp(tx->name, "*slime", 6))
-                               tx->supercontents = SUPERCONTENTS_SLIME;
+                       {
+                               tx->supercontents = mod_q1bsp_texture_slime.supercontents;
+                               tx->surfaceflags = mod_q1bsp_texture_slime.surfaceflags;
+                       }
                        else
-                               tx->supercontents = SUPERCONTENTS_WATER;
+                       {
+                               tx->supercontents = mod_q1bsp_texture_water.supercontents;
+                               tx->surfaceflags = mod_q1bsp_texture_water.surfaceflags;
+                       }
+                       tx->basematerialflags |= MATERIALFLAG_WATER | MATERIALFLAG_LIGHTBOTHSIDES;
                }
                else if (tx->name[0] == 's' && tx->name[1] == 'k' && tx->name[2] == 'y')
                {
-                       tx->supercontents = SUPERCONTENTS_SKY;
+                       tx->supercontents = mod_q1bsp_texture_sky.supercontents;
+                       tx->surfaceflags = mod_q1bsp_texture_sky.surfaceflags;
                        tx->basematerialflags |= MATERIALFLAG_SKY;
                }
                else
                {
-                       tx->supercontents = SUPERCONTENTS_SOLID;
+                       tx->supercontents = mod_q1bsp_texture_solid.supercontents;
+                       tx->surfaceflags = mod_q1bsp_texture_solid.surfaceflags;
                        tx->basematerialflags |= MATERIALFLAG_WALL;
                }
                if (tx->skin.fog)
@@ -4180,7 +4241,7 @@ static void Mod_Q3BSP_LoadBrushes(lump_t *l)
        q3dbrush_t *in;
        q3mbrush_t *out;
        int i, j, n, c, count, maxplanes;
-       mplane_t *planes;
+       colplanef_t *planes;
 
        in = (q3dbrush_t *)(mod_base + l->fileofs);
        if (l->filelen % sizeof(*in))
@@ -4213,15 +4274,18 @@ static void Mod_Q3BSP_LoadBrushes(lump_t *l)
                        maxplanes = out->numbrushsides;
                        if (planes)
                                Mem_Free(planes);
-                       planes = (mplane_t *)Mem_Alloc(tempmempool, sizeof(mplane_t) * maxplanes);
+                       planes = (colplanef_t *)Mem_Alloc(tempmempool, sizeof(colplanef_t) * maxplanes);
                }
                for (j = 0;j < out->numbrushsides;j++)
                {
                        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->texture->supercontents);
+               out->colbrushf = Collision_NewBrushFromPlanes(loadmodel->mempool, out->numbrushsides, planes);
        }
        if (planes)
                Mem_Free(planes);
@@ -5139,7 +5203,7 @@ static void Mod_Q3BSP_TraceLine_RecursiveBSPNode(trace_t *trace, model_t *model,
                        if (surface->num_collisiontriangles && surface->collisionmarkframe != markframe && BoxesOverlap(nodesegmentmins, nodesegmentmaxs, surface->mins, surface->maxs))
                        {
                                surface->collisionmarkframe = markframe;
-                               Collision_TraceLineTriangleMeshFloat(trace, linestart, lineend, surface->num_collisiontriangles, surface->data_collisionelement3i, surface->data_collisionvertex3f, surface->texture->supercontents, segmentmins, segmentmaxs);
+                               Collision_TraceLineTriangleMeshFloat(trace, linestart, lineend, surface->num_collisiontriangles, surface->data_collisionelement3i, surface->data_collisionvertex3f, surface->texture->supercontents, surface->texture->surfaceflags, surface->texture, segmentmins, segmentmaxs);
                        }
                }
        }
@@ -5214,7 +5278,7 @@ static void Mod_Q3BSP_TraceBrush_RecursiveBSPNode(trace_t *trace, model_t *model
                        if (surface->num_collisiontriangles && surface->collisionmarkframe != markframe && BoxesOverlap(nodesegmentmins, nodesegmentmaxs, surface->mins, surface->maxs))
                        {
                                surface->collisionmarkframe = markframe;
-                               Collision_TraceBrushTriangleMeshFloat(trace, thisbrush_start, thisbrush_end, surface->num_collisiontriangles, surface->data_collisionelement3i, surface->data_collisionvertex3f, surface->texture->supercontents, segmentmins, segmentmaxs);
+                               Collision_TraceBrushTriangleMeshFloat(trace, thisbrush_start, thisbrush_end, surface->num_collisiontriangles, surface->data_collisionelement3i, surface->data_collisionvertex3f, surface->texture->supercontents, surface->texture->surfaceflags, surface->texture, segmentmins, segmentmaxs);
                        }
                }
        }
@@ -5262,7 +5326,7 @@ static void Mod_Q3BSP_TraceBox(model_t *model, int frame, trace_t *trace, const
                                if (mod_q3bsp_curves_collisions.integer)
                                        for (i = 0, surface = model->data_surfaces + model->firstmodelsurface;i < model->nummodelsurfaces;i++, surface++)
                                                if (surface->num_collisiontriangles)
-                                                       Collision_TraceLineTriangleMeshFloat(trace, start, end, surface->num_collisiontriangles, surface->data_collisionelement3i, surface->data_collisionvertex3f, surface->texture->supercontents, segmentmins, segmentmaxs);
+                                                       Collision_TraceLineTriangleMeshFloat(trace, start, end, surface->num_collisiontriangles, surface->data_collisionelement3i, surface->data_collisionvertex3f, surface->texture->supercontents, surface->texture->surfaceflags, surface->texture, segmentmins, segmentmaxs);
                        }
                        else
                                Mod_Q3BSP_TraceLine_RecursiveBSPNode(trace, model, model->brush.data_nodes, start, end, 0, 1, start, end, ++markframe, segmentmins, segmentmaxs);
@@ -5283,8 +5347,8 @@ static void Mod_Q3BSP_TraceBox(model_t *model, int frame, trace_t *trace, const
                VectorAdd(start, boxmaxs, boxstartmaxs);
                VectorAdd(end, boxmins, boxendmins);
                VectorAdd(end, boxmaxs, boxendmaxs);
-               thisbrush_start = Collision_BrushForBox(&identitymatrix, boxstartmins, boxstartmaxs);
-               thisbrush_end = Collision_BrushForBox(&identitymatrix, boxendmins, boxendmaxs);
+               thisbrush_start = Collision_BrushForBox(&identitymatrix, boxstartmins, boxstartmaxs, 0, 0, NULL);
+               thisbrush_end = Collision_BrushForBox(&identitymatrix, boxendmins, boxendmaxs, 0, 0, NULL);
                if (model->brush.submodel)
                {
                        for (i = 0, brush = model->brush.data_brushes + model->firstmodelbrush;i < model->nummodelbrushes;i++, brush++)
@@ -5293,7 +5357,7 @@ static void Mod_Q3BSP_TraceBox(model_t *model, int frame, trace_t *trace, const
                        if (mod_q3bsp_curves_collisions.integer)
                                for (i = 0, surface = model->data_surfaces + model->firstmodelsurface;i < model->nummodelsurfaces;i++, surface++)
                                        if (surface->num_collisiontriangles)
-                                               Collision_TraceBrushTriangleMeshFloat(trace, thisbrush_start, thisbrush_end, surface->num_collisiontriangles, surface->data_collisionelement3i, surface->data_collisionvertex3f, surface->texture->supercontents, segmentmins, segmentmaxs);
+                                               Collision_TraceBrushTriangleMeshFloat(trace, thisbrush_start, thisbrush_end, surface->num_collisiontriangles, surface->data_collisionelement3i, surface->data_collisionvertex3f, surface->texture->supercontents, surface->texture->surfaceflags, surface->texture, segmentmins, segmentmaxs);
                }
                else
                        Mod_Q3BSP_TraceBrush_RecursiveBSPNode(trace, model, model->brush.data_nodes, thisbrush_start, thisbrush_end, ++markframe, segmentmins, segmentmaxs);
index dfa7d99..a255a51 100644 (file)
@@ -2267,6 +2267,8 @@ void R_Shadow_SetupEntityLight(const entity_render_t *ent)
 
 void R_Shadow_DrawEntityLight(entity_render_t *ent, int numsurfaces, int *surfacelist)
 {
+       if (!ent->model->DrawLight)
+               return;
        R_Shadow_SetupEntityLight(ent);
        if (ent == r_refdef.worldentity)
                ent->model->DrawLight(ent, numsurfaces, surfacelist);
diff --git a/world.c b/world.c
index 646204f..b294e22 100644 (file)
--- a/world.c
+++ b/world.c
@@ -682,6 +682,9 @@ trace_t SV_Move(const vec3_t start, const vec3_t mins, const vec3_t maxs, const
                        VectorCopy(trace.endpos, cliptrace.endpos);
                        cliptrace.plane = trace.plane;
                        cliptrace.ent = touch;
+                       cliptrace.hitsupercontents = trace.hitsupercontents;
+                       cliptrace.hitq3surfaceflags = trace.hitq3surfaceflags;
+                       cliptrace.hittexture = trace.hittexture;
                }
                cliptrace.startsupercontents |= trace.startsupercontents;
        }
index 4a24d25..a3837e4 100644 (file)
@@ -690,6 +690,9 @@ trace_t CSSV_Move(const vec3_t start, const vec3_t mins, const vec3_t maxs, cons
                        VectorCopy(trace.endpos, cliptrace.endpos);
                        cliptrace.plane = trace.plane;
                        cliptrace.ent = touch;
+                       cliptrace.hitsupercontents = trace.hitsupercontents;
+                       cliptrace.hitq3surfaceflags = trace.hitq3surfaceflags;
+                       cliptrace.hittexture = trace.hittexture;
                }
                cliptrace.startsupercontents |= trace.startsupercontents;
        }