]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - tools/quake3/q3map2/facebsp.c
some stuff by 27:
[xonotic/netradiant.git] / tools / quake3 / q3map2 / facebsp.c
index 270eefe280014c415b15031a73ed1b331834a0f9..65532a17acea0976a5a7e6ab91d6942b01ae5e05 100644 (file)
@@ -89,7 +89,10 @@ static void SelectSplitPlaneNum( node_t *node, face_t *list, int *splitPlaneNum,
        vec3_t          normal;
        float           dist;
        int                     planenum;
-       
+       float       sizeBias;
+
+       //int frontC,backC,splitsC,facingC;
+
        
        /* ydnar: set some defaults */
        *splitPlaneNum = -1; /* leaf */
@@ -118,6 +121,7 @@ static void SelectSplitPlaneNum( node_t *node, face_t *list, int *splitPlaneNum,
        bestValue = -99999;
        bestSplit = list;
        
+
        for( split = list; split; split = split->next )
                split->checked = qfalse;
        
@@ -146,15 +150,38 @@ static void SelectSplitPlaneNum( node_t *node, face_t *list, int *splitPlaneNum,
                                back++;
                        }
                }
-               value =  5*facing - 5*splits; // - abs(front-back);
-               if ( plane->type < 3 ) {
-                       value+=5;               // axial is better
+
+               if(bspAlternateSplitWeights)
+               {
+                       // from 27
+
+                       //Bigger is better
+                       sizeBias=WindingArea(split->w);
+
+                       //Base score = 20000 perfectly balanced 
+                       value = 20000-(abs(front-back));
+                       value -= plane->counter;// If we've already used this plane sometime in the past try not to use it again 
+                       value -= facing ;       // if we're going to have alot of other surfs use this plane, we want to get it in quickly.
+                       value -= splits*5;        //more splits = bad
+                       value +=  sizeBias*10; //We want a huge score bias based on plane size
                }
-               value += split->priority;               // prioritize hints higher
+               else
+               {
+                       value =  5*facing - 5*splits; // - abs(front-back);
+                       if ( plane->type < 3 ) {
+                               value+=5;               // axial is better
+                       }
+               }
+
+         value += split->priority;             // prioritize hints higher
 
                if ( value > bestValue ) {
                        bestValue = value;
                        bestSplit = split;
+                       //frontC=front;
+                       //backC=back;
+                       //splitsC=splits;
+                       //facingC=facing;
                }
        }
        
@@ -162,9 +189,13 @@ static void SelectSplitPlaneNum( node_t *node, face_t *list, int *splitPlaneNum,
        if( bestValue == -99999 )
                return;
        
+       //Sys_FPrintf (SYS_VRB, "F: %d B:%d S:%d FA:%ds\n",frontC,backC,splitsC,facingC );
+
        /* set best split data */
        *splitPlaneNum = bestSplit->planenum;
        *compileFlags = bestSplit->compileFlags;
+
+   if (*splitPlaneNum>-1) mapplanes[ *splitPlaneNum ].counter++;
 }
 
 
@@ -324,6 +355,11 @@ tree_t *FaceBSP( face_t *list ) {
        }
        Sys_FPrintf( SYS_VRB, "%9d faces\n", count );
 
+   for( i = 0; i < nummapplanes; i++)
+   {
+      mapplanes[ i ].counter=0;
+   }
+
        tree->headnode = AllocNode();
        VectorCopy( tree->mins, tree->headnode->mins );
        VectorCopy( tree->maxs, tree->headnode->maxs );