]> de.git.xonotic.org Git - xonotic/netradiant.git/commitdiff
Merge commit 'e744bb6dadcd57fff460b7e6409ecd61bfe272c7' into master-merge
authorThomas Debesse <dev@illwieckz.net>
Mon, 20 Jun 2022 02:26:20 +0000 (04:26 +0200)
committerThomas Debesse <dev@illwieckz.net>
Mon, 20 Jun 2022 02:26:20 +0000 (04:26 +0200)
1  2 
tools/quake3/q3map2/main.c
tools/quake3/q3map2/map.c
tools/quake3/q3map2/shaders.c

index 63e941787a74281711dc4ab3a2572d1596772927,7589af125b6e8dbb44a57af32d661cf0d9af6e70..e3f5742b6f3b521ffeeee27a16dc70b620d43a2a
@@@ -132,7 -132,7 +132,7 @@@ int ShiftBSPMain( int argc, char **arg
                }
        }
  
-       /* get scale */
+       /* get shift */
        // if(argc-2 >= i) // always true
        scale[2] = scale[1] = scale[0] = atof( argv[ argc - 2 ] );
        if ( argc - 3 >= i ) {
        Sys_Printf( "--- ShiftBSP ---\n" );
        Sys_FPrintf( SYS_VRB, "%9d entities\n", numEntities );
  
-       /* scale entity keys */
+       /* shift entity keys */
        for ( i = 0; i < numBSPEntities && i < numEntities; i++ )
        {
-               /* scale origin */
+               /* shift origin */
                GetVectorForKey( &entities[ i ], "origin", vec );
                if ( ( vec[ 0 ] || vec[ 1 ] || vec[ 2 ] ) ) {
                        if ( !strncmp( ValueForKey( &entities[i], "classname" ), "info_player_", 12 ) ) {
  
        }
  
-       /* scale models */
+       /* shift models */
        for ( i = 0; i < numBSPModels; i++ )
        {
                bspModels[ i ].mins[0] += scale[0];
                bspModels[ i ].maxs[2] += scale[2];
        }
  
-       /* scale nodes */
+       /* shift nodes */
        for ( i = 0; i < numBSPNodes; i++ )
        {
                bspNodes[ i ].mins[0] += scale[0];
                bspNodes[ i ].maxs[2] += scale[2];
        }
  
-       /* scale leafs */
+       /* shift leafs */
        for ( i = 0; i < numBSPLeafs; i++ )
        {
                bspLeafs[ i ].mins[0] += scale[0];
                bspLeafs[ i ].maxs[1] += scale[1];
                bspLeafs[ i ].maxs[2] += scale[2];
        }
- /*
-       if ( texscale ) {
-               Sys_Printf( "Using texture unlocking (and probably breaking texture alignment a lot)\n" );
-               old_xyzst = safe_malloc( sizeof( *old_xyzst ) * numBSPDrawVerts * 5 );
-               for ( i = 0; i < numBSPDrawVerts; i++ )
-               {
-                       old_xyzst[5 * i + 0] = bspDrawVerts[i].xyz[0];
-                       old_xyzst[5 * i + 1] = bspDrawVerts[i].xyz[1];
-                       old_xyzst[5 * i + 2] = bspDrawVerts[i].xyz[2];
-                       old_xyzst[5 * i + 3] = bspDrawVerts[i].st[0];
-                       old_xyzst[5 * i + 4] = bspDrawVerts[i].st[1];
-               }
-       }
- */
-       /* scale drawverts */
+       /* shift drawverts */
        for ( i = 0; i < numBSPDrawVerts; i++ )
        {
                bspDrawVerts[i].xyz[0] += scale[0];
                bspDrawVerts[i].xyz[1] += scale[1];
                bspDrawVerts[i].xyz[2] += scale[2];
- //            bspDrawVerts[i].normal[0] /= scale[0];
- //            bspDrawVerts[i].normal[1] /= scale[1];
- //            bspDrawVerts[i].normal[2] /= scale[2];
- //            VectorNormalize( bspDrawVerts[i].normal, bspDrawVerts[i].normal );
        }
- /*
-       if ( texscale ) {
-               for ( i = 0; i < numBSPDrawSurfaces; i++ )
-               {
-                       switch ( bspDrawSurfaces[i].surfaceType )
-                       {
-                       case SURFACE_FACE:
-                       case SURFACE_META:
-                               if ( bspDrawSurfaces[i].numIndexes % 3 ) {
-                                       Error( "Not a triangulation!" );
-                               }
-                               for ( j = bspDrawSurfaces[i].firstIndex; j < bspDrawSurfaces[i].firstIndex + bspDrawSurfaces[i].numIndexes; j += 3 )
-                               {
-                                       int ia = bspDrawIndexes[j] + bspDrawSurfaces[i].firstVert, ib = bspDrawIndexes[j + 1] + bspDrawSurfaces[i].firstVert, ic = bspDrawIndexes[j + 2] + bspDrawSurfaces[i].firstVert;
-                                       bspDrawVert_t *a = &bspDrawVerts[ia], *b = &bspDrawVerts[ib], *c = &bspDrawVerts[ic];
-                                       float *oa = &old_xyzst[ia * 5], *ob = &old_xyzst[ib * 5], *oc = &old_xyzst[ic * 5];
-                                       // extrapolate:
-                                       //   a->xyz -> oa
-                                       //   b->xyz -> ob
-                                       //   c->xyz -> oc
-                                       ExtrapolateTexcoords(
-                                               &oa[0], &oa[3],
-                                               &ob[0], &ob[3],
-                                               &oc[0], &oc[3],
-                                               a->xyz, a->st,
-                                               b->xyz, b->st,
-                                               c->xyz, c->st );
-                               }
-                               break;
-                       }
-               }
-       }
- */
-       /* scale planes */
+       /* shift planes */
+       vec3_t point;
  
        for ( i = 0; i < numBSPPlanes; i++ )
        {
-               if ( bspPlanes[ i ].dist > 0 ){
-                               if ( bspPlanes[ i ].normal[0] ){
-                                       bspPlanes[ i ].dist += scale[0];
-                                       continue;
-                               }
-                               else if ( bspPlanes[ i ].normal[1] ){
-                                       bspPlanes[ i ].dist += scale[1];
-                                       continue;
-                               }
-                               else if ( bspPlanes[ i ].normal[2] ){
-                                       bspPlanes[ i ].dist += scale[2];
-                                       continue;
-                               }
+               //find point on plane
+               for ( j=0; j<3; j++ ){
+                       if ( fabs( bspPlanes[ i ].normal[j] ) > 0.5 ){
+                               point[j] = bspPlanes[ i ].dist / bspPlanes[ i ].normal[j];
+                               point[(j+1)%3] = point[(j+2)%3] = 0;
+                               break;
+                       }
                }
-               else{
-                               if ( bspPlanes[ i ].normal[0] ){
-                                       bspPlanes[ i ].dist -= scale[0];
-                                       continue;
-                               }
-                               else if ( bspPlanes[ i ].normal[1] ){
-                                       bspPlanes[ i ].dist -= scale[1];
-                                       continue;
-                               }
-                               else if ( bspPlanes[ i ].normal[2] ){
-                                       bspPlanes[ i ].dist -= scale[2];
-                                       continue;
-                               }
+               //shift point
+               for ( j=0; j<3; j++ ){
+                       point[j] += scale[j];
                }
+               //calc new plane dist
+               bspPlanes[ i ].dist = DotProduct( point, bspPlanes[ i ].normal );
        }
  
- /*    if ( uniform ) {
-               for ( i = 0; i < numBSPPlanes; i++ )
-               {
-                       bspPlanes[ i ].dist += scale[0];
-               }
-       }
-       else
-       {
-               for ( i = 0; i < numBSPPlanes; i++ )
-               {
- //                    bspPlanes[ i ].normal[0] /= scale[0];
- //                    bspPlanes[ i ].normal[1] /= scale[1];
- //                    bspPlanes[ i ].normal[2] /= scale[2];
-                       f = 1 / VectorLength( bspPlanes[i].normal );
-                       VectorScale( bspPlanes[i].normal, f, bspPlanes[i].normal );
-                       bspPlanes[ i ].dist *= f;
-               }
-       }*/
        /* scale gridsize */
        /*
        GetVectorForKey( &entities[ 0 ], "gridsize", vec );
@@@ -381,16 -300,14 +300,16 @@@ int main( int argc, char **argv )
                /* -help */
                if ( !strcmp( argv[ i ], "-h" ) || !strcmp( argv[ i ], "--help" )
                        || !strcmp( argv[ i ], "-help" ) ) {
 -                      HelpMain(argv[i+1]);
 +                      HelpMain( ( i + 1 < argc ) ? argv[ i + 1 ] : NULL );
                        return 0;
                }
  
                /* -connect */
                if ( !strcmp( argv[ i ], "-connect" ) ) {
 -                      argv[ i ] = NULL;
 -                      i++;
 +                      if ( ++i >= argc || !argv[ i ] ) {
 +                              Error( "Out of arguments: No address specified after %s", argv[ i - 1 ] );
 +                      }
 +                      argv[ i - 1 ] = NULL;
                        Broadcast_Setup( argv[ i ] );
                        argv[ i ] = NULL;
                }
  
                /* patch subdivisions */
                else if ( !strcmp( argv[ i ], "-subdivisions" ) ) {
 -                      argv[ i ] = NULL;
 -                      i++;
 +                      if ( ++i >= argc || !argv[ i ] ) {
 +                              Error( "Out of arguments: No value specified after %s", argv[ i - 1 ] );
 +                      }
 +                      argv[ i - 1 ] = NULL;
                        patchSubdivisions = atoi( argv[ i ] );
                        argv[ i ] = NULL;
                        if ( patchSubdivisions <= 0 ) {
  
                /* threads */
                else if ( !strcmp( argv[ i ], "-threads" ) ) {
 -                      argv[ i ] = NULL;
 -                      i++;
 +                      if ( ++i >= argc || !argv[ i ] ) {
 +                              Error( "Out of arguments: No value specified after %s", argv[ i - 1 ] );
 +                      }
 +                      argv[ i - 1 ] = NULL;
                        numthreads = atoi( argv[ i ] );
                        argv[ i ] = NULL;
                }
  
        Sys_Printf( "Q3Map         - v1.0r (c) 1999 Id Software Inc.\n" );
        Sys_Printf( "Q3Map (ydnar) - v" Q3MAP_VERSION "\n" );
 -      Sys_Printf( "NetRadiant    - v" RADIANT_VERSION " " __DATE__ " " __TIME__ "\n" );
 +      Sys_Printf( RADIANT_NAME "    - v" RADIANT_VERSION " " __DATE__ " " __TIME__ "\n" );
        Sys_Printf( "%s\n", Q3MAP_MOTD );
  
        /* ydnar: new path initialization */
        }
  
        /* ydnar: otherwise create a bsp */
 -      else{
 +      else {
 +              /* used to write Smokin'Guns like tex file */
 +              compile_map = qtrue;
 +
                r = BSPMain( argc, argv );
        }
  
index fabbcc8331485c85dd9ba85caa6742f6181b69c6,82bf961e21cbd520884e73be16bf93a08a102a3e..aae88ae84bc56e3144bd3f09511631bbec6b248c
@@@ -164,10 -164,10 +164,10 @@@ qboolean SnapNormal( vec3_t normal )
        // normalized).  The original SnapNormal() didn't snap such vectors - it
        // only snapped vectors that were near a perfect axis.
  
-       //adjusting vectors, that were near a perfect axis, with bigger epsilon
+       //adjusting vectors, that are near perfect axis, with bigger epsilon
        //they cause precision errors
  
-       /*
        if ( ( normal[0] != 0.0 || normal[1] != 0.0 ) && fabs(normal[0]) < 0.00025 && fabs(normal[1]) < 0.00025){
                normal[0] = normal[1] = 0.0;
                adjusted = qtrue;
                normal[2] = normal[1] = 0.0;
                adjusted = qtrue;
        }
-       */
  
        /*
        for ( i=0; i<30; i++ )
@@@ -1561,7 -1561,8 +1561,7 @@@ void LoadEntityIndexMap( entity_t *e )
        }
  
        /* create a new index map */
 -      im = safe_malloc( sizeof( *im ) );
 -      memset( im, 0, sizeof( *im ) );
 +      im = safe_malloc0( sizeof( *im ) );
  
        /* set it up */
        im->w = w;
index 8ac0463a6418ea8ba0d0ada41348560ddaf5ec2c,208dec4829782a28963df225bc309fd0addcdc12..bedeccfc1edc47a02f4cec5babe53fb19be4551a
@@@ -70,7 -70,7 +70,7 @@@ void ColorMod( colorMod_t *cm, int numV
                        VectorSet( mult, 1.0f, 1.0f, 1.0f );
                        mult[ 3 ] = 1.0f;
                        VectorSet( add, 0.0f, 0.0f, 0.0f );
-                       mult[ 3 ] = 0.0f;
+                       add[ 3 ] = 0.0f;
  
                        /* switch on type */
                        switch ( cm2->type )
@@@ -1275,7 -1275,8 +1275,7 @@@ static void ParseShaderFile( const cha
                        else if ( !Q_stricmp( token, "sun" ) /* sof2 */ || !Q_stricmp( token, "q3map_sun" ) || !Q_stricmp( token, "q3map_sunExt" ) ) {
                                float a, b;
                                sun_t       *sun;
 -                              qboolean ext;
 -
 +                              qboolean ext = qfalse;
  
                                /* ydnar: extended sun directive? */
                                if ( !Q_stricmp( token, "q3map_sunext" ) ) {
                                }
  
                                /* allocate sun */
 -                              sun = safe_malloc( sizeof( *sun ) );
 -                              memset( sun, 0, sizeof( *sun ) );
 +                              sun = safe_malloc0( sizeof( *sun ) );
  
                                /* set style */
                                sun->style = si->lightStyle;
                                        surfaceModel_t  *model;
  
                                        /* allocate new model and attach it */
 -                                      model = safe_malloc( sizeof( *model ) );
 -                                      memset( model, 0, sizeof( *model ) );
 +                                      model = safe_malloc0( sizeof( *model ) );
                                        model->next = si->surfaceModel;
                                        si->surfaceModel = model;
  
  
  
                                        /* allocate new foliage struct and attach it */
 -                                      foliage = safe_malloc( sizeof( *foliage ) );
 -                                      memset( foliage, 0, sizeof( *foliage ) );
 +                                      foliage = safe_malloc0( sizeof( *foliage ) );
                                        foliage->next = si->foliage;
                                        si->foliage = foliage;
  
                                        alpha = ( !Q_stricmp( token, "q3map_alphaGen" ) || !Q_stricmp( token, "q3map_alphaMod" ) ) ? 1 : 0;
  
                                        /* allocate new colormod */
 -                                      cm = safe_malloc( sizeof( *cm ) );
 -                                      memset( cm, 0, sizeof( *cm ) );
 +                                      cm = safe_malloc0( sizeof( *cm ) );
  
                                        /* attach to shader */
                                        if ( si->colorMod == NULL ) {