]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - tools/quake2/qdata/tables.c
my own uncrustify run
[xonotic/netradiant.git] / tools / quake2 / qdata / tables.c
index 6aee61269789393613e15bb6536c57a0c7a5cf27..fa9085c135974461ae60f44545bba85c291a9701 100644 (file)
@@ -1,58 +1,78 @@
-#include "qdata.h"
-
 /*
-=============================================================================
+   Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+   For a list of contributors, see the accompanying CONTRIBUTORS file.
 
-ALPHALIGHT GENERATION
+   This file is part of GtkRadiant.
 
-Find alphamap values that best match modulated lightmap values
+   GtkRadiant is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
 
-This isn't used anymore, but I'm keeping it around...
-=============================================================================
-*/
+   GtkRadiant is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
 
-unsigned short alphamap[32*32*32];
-unsigned char  inverse16to8table[65536];
+   You should have received a copy of the GNU General Public License
+   along with GtkRadiant; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include "qdata.h"
 
 /*
-static int FindNearestColor( unsigned int color )
-{
-       int i;
-       int closest_so_far = 0;
-       float closest_distance_so_far = 100000000;
-       float d;
-       float r[2], g[2], b[2];
+   =============================================================================
 
-       // incoming color is assumed to be in 0xRRGGBB format
-       r[0] = ( color & 31 ) << 3;
-       g[0] = ( ( color >> 5 ) & 63 ) << 2;
-       b[0] = ( ( color >> 11 ) & 31 ) << 3;
+   ALPHALIGHT GENERATION
 
-       for ( i = 0; i < 256; i++ )
-       {
-               r[1] = ( d_8to24table[i] >> 0 ) & 0xFF;
-               g[1] = ( d_8to24table[i] >> 8 ) & 0xFF;
-               b[1] = ( d_8to24table[i] >> 16 ) & 0xFF;
-
-               d = ( r[1] - r[0] ) * ( r[1] - r[0] ) +
-                       ( g[1] - g[0] ) * ( g[1] - g[0] ) +
-                       ( b[1] - b[0] ) * ( b[1] - b[0] );
-
-               if ( d < closest_distance_so_far )
-               {
-                       closest_distance_so_far = d;
-                       closest_so_far = i;
-               }
-       }
+   Find alphamap values that best match modulated lightmap values
 
-       return closest_so_far;
-}
-*/
+   This isn't used anymore, but I'm keeping it around...
+   =============================================================================
+ */
+
+unsigned short alphamap[32 * 32 * 32];
+unsigned char inverse16to8table[65536];
+
+/*
+   static int FindNearestColor( unsigned int color )
+   {
+    int i;
+    int closest_so_far = 0;
+    float closest_distance_so_far = 100000000;
+    float d;
+    float r[2], g[2], b[2];
+
+    // incoming color is assumed to be in 0xRRGGBB format
+    r[0] = ( color & 31 ) << 3;
+    g[0] = ( ( color >> 5 ) & 63 ) << 2;
+    b[0] = ( ( color >> 11 ) & 31 ) << 3;
+
+    for ( i = 0; i < 256; i++ )
+    {
+        r[1] = ( d_8to24table[i] >> 0 ) & 0xFF;
+        g[1] = ( d_8to24table[i] >> 8 ) & 0xFF;
+        b[1] = ( d_8to24table[i] >> 16 ) & 0xFF;
+
+        d = ( r[1] - r[0] ) * ( r[1] - r[0] ) +
+            ( g[1] - g[0] ) * ( g[1] - g[0] ) +
+            ( b[1] - b[0] ) * ( b[1] - b[0] );
+
+        if ( d < closest_distance_so_far )
+        {
+            closest_distance_so_far = d;
+            closest_so_far = i;
+        }
+    }
+
+    return closest_so_far;
+   }
+ */
 
 extern byte BestColor( int, int, int, int, int );
 
-void Inverse16_BuildTable( void )
-{
+void Inverse16_BuildTable( void ){
        int i;
 
        /*
@@ -72,77 +92,71 @@ void Inverse16_BuildTable( void )
        }
 }
 
-void Alphalight_Thread (int i)
-{
-       int             j;
-       float   r, g, b;
-       float   mr, mg, mb, ma;
-       float   distortion, bestdistortion;
-       float   v;
+void Alphalight_Thread( int i ){
+       int j;
+       float r, g, b;
+       float mr, mg, mb, ma;
+       float distortion, bestdistortion;
+       float v;
 
-       r = (i>>10) * (1.0/16);
-       g = ((i>>5)&31)  * (1.0/16);
-       b = (i&31) * (1.0/16);
+       r = ( i >> 10 ) * ( 1.0 / 16 );
+       g = ( ( i >> 5 ) & 31 )  * ( 1.0 / 16 );
+       b = ( i & 31 ) * ( 1.0 / 16 );
 
        bestdistortion = 999999;
-       for (j=0 ; j<16*16*16*16 ; j++)
+       for ( j = 0 ; j < 16 * 16 * 16 * 16 ; j++ )
        {
-               mr = (j>>12) * (1.0/16);
-               mg = ((j>>8)&15) * (1.0/16);
-               mb = ((j>>4)&15) * (1.0/16);
-               ma = (j&15) * (1.0/16);
-
-               v = r * 0.5 - (mr*ma + 0.5*(1.0-ma));
-               distortion = v*v;
-               v = g * 0.5 - (mg*ma + 0.5*(1.0-ma));
-               distortion += v*v;
-               v = b * 0.5 - (mb*ma + 0.5*(1.0-ma));
-               distortion += v*v;
-
-               distortion *= 1.0 + ma*4;
-
-               if (distortion < bestdistortion)
-               {
+               mr = ( j >> 12 ) * ( 1.0 / 16 );
+               mg = ( ( j >> 8 ) & 15 ) * ( 1.0 / 16 );
+               mb = ( ( j >> 4 ) & 15 ) * ( 1.0 / 16 );
+               ma = ( j & 15 ) * ( 1.0 / 16 );
+
+               v = r * 0.5 - ( mr * ma + 0.5 * ( 1.0 - ma ) );
+               distortion = v * v;
+               v = g * 0.5 - ( mg * ma + 0.5 * ( 1.0 - ma ) );
+               distortion += v * v;
+               v = b * 0.5 - ( mb * ma + 0.5 * ( 1.0 - ma ) );
+               distortion += v * v;
+
+               distortion *= 1.0 + ma * 4;
+
+               if ( distortion < bestdistortion ) {
                        bestdistortion = distortion;
                        alphamap[i] = j;
                }
        }
 }
 
-void Cmd_Alphalight (void)
-{
-       char    savename[1024];
+void Cmd_Alphalight( void ){
+       char savename[1024];
 
-       GetToken (false);
+       GetToken( false );
 
-       if (g_release)
-       {
-               ReleaseFile (token);
+       if ( g_release ) {
+               ReleaseFile( token );
                return;
        }
 
-       sprintf (savename, "%s%s", gamedir, token);
-       printf ("Building alphalight table...\n");
+       sprintf( savename, "%s%s", gamedir, token );
+       printf( "Building alphalight table...\n" );
 
-       RunThreadsOnIndividual (32*32*32, true, Alphalight_Thread);
+       RunThreadsOnIndividual( 32 * 32 * 32, true, Alphalight_Thread );
 
-       SaveFile (savename, (byte *)alphamap, sizeof(alphamap));
+       SaveFile( savename, (byte *)alphamap, sizeof( alphamap ) );
 }
 
 
-void Cmd_Inverse16Table( void )
-{
+void Cmd_Inverse16Table( void ){
        char savename[1024];
 
-       if ( g_release )
-       {
-               sprintf (savename, "pics/16to8.dat");
+       if ( g_release ) {
+               sprintf( savename, "pics/16to8.dat" );
                ReleaseFile( savename );
                return;
        }
 
-       sprintf (savename, "%spics/16to8.dat", gamedir);
-       printf ("Building inverse 16-to-8 table...\n");
+       sprintf( savename, "%spics/16to8.dat", gamedir );
+       printf( "Building inverse 16-to-8 table...\n" );
 
        Inverse16_BuildTable();