]> git.rm.cloudns.org Git - xonotic/netradiant.git/commitdiff
Small improvements
authoruis <uis9936@gmail.com>
Fri, 22 Dec 2023 21:16:49 +0000 (00:16 +0300)
committeruis <uis9936@gmail.com>
Fri, 22 Dec 2023 21:16:49 +0000 (00:16 +0300)
tools/quake3/q3map2/light_bounce.c
tools/quake3/q3map2/light_ydnar.c

index d34c6ed21b34e3bd1d300a82f72e521137310447..b0b838b8ccea11094e34b50f3dc1745e0dc64384 100644 (file)
@@ -263,7 +263,7 @@ qboolean RadSampleImage( byte *pixels, int width, int height, float st[ 2 ], flo
 #define SAMPLE_GRANULARITY  6
 
 static void RadSample( int lightmapNum, bspDrawSurface_t *ds, rawLightmap_t *lm, shaderInfo_t *si, radWinding_t *rw, vec3_t average, vec3_t gradient, int *style ){
-       int i, j, k, l, v, x, y, samples, avgcolor;
+       int i, j, k, l, v, x, y, samples, avgcolor, f_superSample;
        vec3_t color, mins, maxs;
        vec4_t textureColor;
        float alpha, alphaI, bf;
@@ -316,6 +316,7 @@ static void RadSample( int lightmapNum, bspDrawSurface_t *ds, rawLightmap_t *lm,
        /* sample lightmap */
        else
        {
+               f_superSample = (float)superSample;
                /* fracture the winding into a fan (including degenerate tris) */
                for ( v = 1; v < ( rw->numVerts - 1 ) && samples < MAX_SAMPLES; v++ )
                {
@@ -335,7 +336,7 @@ static void RadSample( int lightmapNum, bspDrawSurface_t *ds, rawLightmap_t *lm,
                                                blend[ 0 ] = i;
                                                blend[ 1 ] = j;
                                                blend[ 2 ] = k;
-                                               bf = ( 1.0 / ( blend[ 0 ] + blend[ 1 ] + blend[ 2 ] ) );
+                                               bf = ( 1.0f / ( blend[ 0 ] + blend[ 1 ] + blend[ 2 ] ) );
                                                VectorScale( blend, bf, blend );
 
                                                /* create a blended sample */
@@ -352,8 +353,10 @@ static void RadSample( int lightmapNum, bspDrawSurface_t *ds, rawLightmap_t *lm,
                                                }
 
                                                /* get lightmap xy coords */
-                                               x = lightmap[ 0 ] / (float) superSample;
-                                               y = lightmap[ 1 ] / (float) superSample;
+                                               /* xy = clamp(lightmap/superSample, 0, lm - 1)*/
+                                               x = lightmap[ 0 ] / f_superSample;
+                                               y = lightmap[ 1 ] / f_superSample;
+
                                                if ( x < 0 ) {
                                                        x = 0;
                                                }
index e244d943702264316618a350a1bb8c34cff743e6..eee4a17362c7ddf71d218aca2de8a4a9be6c73d4 100644 (file)
@@ -1258,6 +1258,7 @@ void MapRawLightmap( int rawLightmapNum ){
           ----------------------------------------------------------------- */
 
        /* walk the luxels */
+       /* FIXME: superSample is int, no need in floor() */
        radius = floor( superSample / 2 );
        radius = radius > 0 ? radius : 1.0f;
        radius += 1.0f;