]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - model_brush.c
r_fakelight: 1 = use "fake" lighting (falloff-less light source at eye origin) if...
[xonotic/darkplaces.git] / model_brush.c
index 1b2367e68c848d3b1960822dd267488539f5ad2d..9c7c9ad4bef35651722accc151ba2e9093556f06 100644 (file)
@@ -2413,6 +2413,7 @@ static void Mod_Q1BSP_LoadFaces(lump_t *l)
                        // lightmap is needed on this surface (rather than duplicating the
                        // logic above)
                        loadmodel->brushq1.lightmapupdateflags[surfacenum] = true;
+                       loadmodel->lit = true;
                }
        }
 
@@ -3447,7 +3448,6 @@ void Mod_Q1BSP_Load(dp_model_t *mod, void *buffer, void *bufferend)
        dmodel_t *bm;
        float dist, modelyawradius, modelradius;
        msurface_t *surface;
-       int numshadowmeshtriangles;
        hullinfo_t hullinfo;
        int totalstylesurfaces, totalstyles, stylecounts[256], remapstyles[256];
        model_brush_lightstyleinfo_t styleinfo[256];
@@ -3575,7 +3575,7 @@ void Mod_Q1BSP_Load(dp_model_t *mod, void *buffer, void *bufferend)
        mod->numskins = 1;
 
        // make a single combined shadow mesh to allow optimized shadow volume creation
-       numshadowmeshtriangles = Mod_Q1BSP_CreateShadowMesh(loadmodel);
+       Mod_Q1BSP_CreateShadowMesh(loadmodel);
 
        if (loadmodel->brush.numsubmodels)
                loadmodel->brush.submodels = (dp_model_t **)Mem_Alloc(loadmodel->mempool, loadmodel->brush.numsubmodels * sizeof(dp_model_t *));
@@ -4507,6 +4507,8 @@ static void Mod_Q3BSP_LoadVertices(lump_t *l)
                loadmodel->brushq3.data_color4f[i * 4 + 1] = in->color4ub[1] * (1.0f / 255.0f);
                loadmodel->brushq3.data_color4f[i * 4 + 2] = in->color4ub[2] * (1.0f / 255.0f);
                loadmodel->brushq3.data_color4f[i * 4 + 3] = in->color4ub[3] * (1.0f / 255.0f);
+               if(in->color4ub[0] != 255 || in->color4ub[1] != 255 || in->color4ub[2] != 255)
+                       loadmodel->lit = true;
        }
 }
 
@@ -4958,6 +4960,7 @@ static void Mod_Q3BSP_LoadFaces(lump_t *l)
                                out->lightmaptexture = loadmodel->brushq3.data_lightmaps[n >> loadmodel->brushq3.num_lightmapmergedwidthheightdeluxepower];
                                if (loadmodel->brushq3.deluxemapping)
                                        out->deluxemaptexture = loadmodel->brushq3.data_deluxemaps[n >> loadmodel->brushq3.num_lightmapmergedwidthheightdeluxepower];
+                               loadmodel->lit = true;
                        }
                }
 
@@ -6189,10 +6192,7 @@ void Mod_CollisionBIH_TraceBox(dp_model_t *model, const frameblend_t *frameblend
                if (VectorCompare(start, end))
                        Mod_CollisionBIH_TracePoint(model, frameblend, skeleton, trace, shiftstart, hitsupercontentsmask);
                else
-               {
                        Mod_CollisionBIH_TraceLine(model, frameblend, skeleton, trace, shiftstart, shiftend, hitsupercontentsmask);
-                       VectorSubtract(trace->endpos, boxmins, trace->endpos);
-               }
                return;
        }
 
@@ -6220,6 +6220,15 @@ void Mod_CollisionBIH_TraceBrush(dp_model_t *model, const frameblend_t *frameble
 {
        float segmentmins[3], segmentmaxs[3];
 
+       if (mod_q3bsp_optimizedtraceline.integer && VectorCompare(start->mins, start->maxs) && VectorCompare(end->mins, end->maxs))
+       {
+               if (VectorCompare(start->mins, end->mins))
+                       Mod_CollisionBIH_TracePoint(model, frameblend, skeleton, trace, start->mins, hitsupercontentsmask);
+               else
+                       Mod_CollisionBIH_TraceLine(model, frameblend, skeleton, trace, start->mins, end->mins, hitsupercontentsmask);
+               return;
+       }
+
        // box trace, performed as brush trace
        memset(trace, 0, sizeof(*trace));
        trace->fraction = 1;
@@ -6573,10 +6582,7 @@ static void Mod_Q3BSP_TraceBox(dp_model_t *model, const frameblend_t *frameblend
                if (VectorCompare(start, end))
                        Mod_Q3BSP_TracePoint(model, frameblend, skeleton, trace, shiftstart, hitsupercontentsmask);
                else
-               {
                        Mod_Q3BSP_TraceLine(model, frameblend, skeleton, trace, shiftstart, shiftend, hitsupercontentsmask);
-                       VectorSubtract(trace->endpos, boxmins, trace->endpos);
-               }
                return;
        }
 
@@ -6620,6 +6626,15 @@ void Mod_Q3BSP_TraceBrush(dp_model_t *model, const frameblend_t *frameblend, con
        msurface_t *surface;
        q3mbrush_t *brush;
 
+       if (mod_q3bsp_optimizedtraceline.integer && VectorCompare(start->mins, start->maxs) && VectorCompare(end->mins, end->maxs))
+       {
+               if (VectorCompare(start->mins, end->mins))
+                       Mod_Q3BSP_TracePoint(model, frameblend, skeleton, trace, start->mins, hitsupercontentsmask);
+               else
+                       Mod_Q3BSP_TraceLine(model, frameblend, skeleton, trace, start->mins, end->mins, hitsupercontentsmask);
+               return;
+       }
+
        // box trace, performed as brush trace
        memset(trace, 0, sizeof(*trace));
        trace->fraction = 1;
@@ -6895,7 +6910,7 @@ void Mod_Q3BSP_RecursiveFindNumLeafs(mnode_t *node)
 
 void Mod_Q3BSP_Load(dp_model_t *mod, void *buffer, void *bufferend)
 {
-       int i, j, numshadowmeshtriangles, lumps;
+       int i, j, lumps;
        q3dheader_t *header;
        float corner[3], yawradius, modelradius;
 
@@ -7016,7 +7031,7 @@ void Mod_Q3BSP_Load(dp_model_t *mod, void *buffer, void *bufferend)
        loadmodel->brush.supportwateralpha = true;
 
        // make a single combined shadow mesh to allow optimized shadow volume creation
-       numshadowmeshtriangles = Mod_Q1BSP_CreateShadowMesh(loadmodel);
+       Mod_Q1BSP_CreateShadowMesh(loadmodel);
 
        loadmodel->brush.num_leafs = 0;
        Mod_Q3BSP_RecursiveFindNumLeafs(loadmodel->brush.data_nodes);