]> git.xonotic.org Git - xonotic/netradiant.git/blobdiff - tools/quake3/q3map2/surface.c
Merge commit 'f73cc19a6166fc04269f953c980175779f81b9b0' into garux-merge
[xonotic/netradiant.git] / tools / quake3 / q3map2 / surface.c
index c8c6e4f433fe2d067615dea3bac49fba8963c341..96f7270c8d4b37067a3dce8f9d3fb93c04e8b80f 100644 (file)
@@ -598,7 +598,7 @@ void ClassifySurfaces( int numSurfs, mapDrawSurface_t *ds ){
                   ----------------------------------------------------------------- */
 
                /* vertex lit surfaces don't need this information */
-               if ( si->compileFlags & C_VERTEXLIT || ds->type == SURFACE_TRIANGLES ) {
+               if ( si->compileFlags & C_VERTEXLIT || ds->type == SURFACE_TRIANGLES || nolm == qtrue ) {
                        VectorClear( ds->lightmapAxis );
                        //%     VectorClear( ds->lightmapVecs[ 2 ] );
                        ds->sampleSize = 0;
@@ -781,6 +781,10 @@ byte GetShaderIndexForPoint( indexMap_t *im, vec3_t eMins, vec3_t eMaxs, vec3_t
 }
 
 
+#define snprintf_ignore(s, n, format, ...) do { \
+    size_t __n = snprintf(s, n, format, __VA_ARGS__); \
+    if (n >= n) {} /* truncated, ignore */ \
+} while (0)
 
 /*
    GetIndexedShader() - ydnar
@@ -827,10 +831,10 @@ shaderInfo_t *GetIndexedShader( shaderInfo_t *parent, indexMap_t *im, int numPoi
 
        /* make a shader name */
        if ( minShaderIndex == maxShaderIndex ) {
-               sprintf( shader, "textures/%s_%d", im->shader, maxShaderIndex );
+               snprintf_ignore( shader, sizeof shader, "textures/%s_%d", im->shader, maxShaderIndex );
        }
        else{
-               sprintf( shader, "textures/%s_%dto%d", im->shader, minShaderIndex, maxShaderIndex );
+               snprintf_ignore( shader, sizeof shader, "textures/%s_%dto%d", im->shader, minShaderIndex, maxShaderIndex );
        }
 
        /* get the shader */
@@ -926,17 +930,17 @@ mapDrawSurface_t *DrawSurfaceForSide( entity_t *e, brush_t *b, side_t *s, windin
        /* ydnar: sky hack/fix for GL_CLAMP borders on ati cards */
        if ( skyFixHack && si->skyParmsImageBase[ 0 ] != '\0' ) {
                //%     Sys_FPrintf( SYS_VRB, "Enabling sky hack for shader %s using env %s\n", si->shader, si->skyParmsImageBase );
-               sprintf( tempShader, "%s_lf", si->skyParmsImageBase );
+               snprintf_ignore( tempShader, sizeof tempShader, "%s_lf", si->skyParmsImageBase );
                DrawSurfaceForShader( tempShader );
-               sprintf( tempShader, "%s_rt", si->skyParmsImageBase );
+               snprintf_ignore( tempShader, sizeof tempShader, "%s_rt", si->skyParmsImageBase );
                DrawSurfaceForShader( tempShader );
-               sprintf( tempShader, "%s_ft", si->skyParmsImageBase );
+               snprintf_ignore( tempShader, sizeof tempShader, "%s_ft", si->skyParmsImageBase );
                DrawSurfaceForShader( tempShader );
-               sprintf( tempShader, "%s_bk", si->skyParmsImageBase );
+               snprintf_ignore( tempShader, sizeof tempShader, "%s_bk", si->skyParmsImageBase );
                DrawSurfaceForShader( tempShader );
-               sprintf( tempShader, "%s_up", si->skyParmsImageBase );
+               snprintf_ignore( tempShader, sizeof tempShader, "%s_up", si->skyParmsImageBase );
                DrawSurfaceForShader( tempShader );
-               sprintf( tempShader, "%s_dn", si->skyParmsImageBase );
+               snprintf_ignore( tempShader, sizeof tempShader, "%s_dn", si->skyParmsImageBase );
                DrawSurfaceForShader( tempShader );
        }
 
@@ -2051,6 +2055,8 @@ int FilterPointIntoTree_r( vec3_t point, mapDrawSurface_t *ds, node_t *node ){
        return AddReferenceToLeaf( ds, node );
 }
 
+
+
 /*
    FilterPointConvexHullIntoTree_r() - ydnar
    filters the convex hull of multiple points from a surface into the tree
@@ -2101,6 +2107,7 @@ int FilterPointConvexHullIntoTree_r( vec3_t **points, int npoints, mapDrawSurfac
 }
 
 
+
 /*
    FilterWindingIntoTree_r() - ydnar
    filters a winding from a drawsurface into the tree
@@ -2183,7 +2190,7 @@ int FilterWindingIntoTree_r( winding_t *w, mapDrawSurface_t *ds, node_t *node ){
                        if ( DotProduct( plane1, reverse ) > 0.999f && fabs( plane1[ 3 ] - reverse[ 3 ] ) < 0.001f ) {
                                return FilterWindingIntoTree_r( w, ds, node->children[ 1 ] );
                        }
-            #else
+                       #else
                        (void) plane2;
                        /* div0: this is the cholera (doesn't hit enough) */
 
@@ -2590,6 +2597,8 @@ void EmitFlareSurface( mapDrawSurface_t *ds ){
        numSurfacesByType[ ds->type ]++;
 }
 
+
+
 /*
    EmitPatchSurface()
    emits a bsp patch drawsurface
@@ -2697,6 +2706,8 @@ void EmitPatchSurface( entity_t *e, mapDrawSurface_t *ds ){
        numSurfacesByType[ ds->type ]++;
 }
 
+
+
 /*
    OptimizeTriangleSurface() - ydnar
    optimizes the vertex/index data in a triangle surface
@@ -2967,6 +2978,7 @@ static void EmitFaceSurface( mapDrawSurface_t *ds ){
 }
 
 
+
 /*
    MakeDebugPortalSurfs_r() - ydnar
    generates drawsurfaces for passable portals in the bsp
@@ -3279,7 +3291,7 @@ int AddSurfaceModelsToTriangle_r( mapDrawSurface_t *ds, surfaceModel_t *model, b
                        }
 
                        /* insert the model */
-                       InsertModel( (char *) model->model, 0, 0, transform, NULL, ds->celShader, ds->entityNum, ds->castShadows, ds->recvShadows, 0, ds->lightmapScale, 0, 0 );
+                       InsertModel( (char *) model->model, 0, 0, transform, NULL, ds->celShader, ds->entityNum, ds->castShadows, ds->recvShadows, 0, ds->lightmapScale, 0, 0, clipDepthGlobal );
 
                        /* return to sender */
                        return 1;
@@ -3649,10 +3661,10 @@ void FilterDrawsurfsIntoTree( entity_t *e, tree_t *tree ){
                }
 
                /* ydnar: remap shader */
-               if ( ds->shaderInfo->remapShader && ds->shaderInfo->remapShader[ 0 ] ) {
+/*             if ( ds->shaderInfo->remapShader && ds->shaderInfo->remapShader[ 0 ] ) {
                        ds->shaderInfo = ShaderInfoForShader( ds->shaderInfo->remapShader );
                }
-
+*/
                /* ydnar: gs mods: handle the various types of surfaces */
                switch ( ds->type )
                {