From 889347e958d7c7c99d50021661d7af39bcb19849 Mon Sep 17 00:00:00 2001 From: divverent Date: Tue, 31 Mar 2009 06:28:17 +0000 Subject: [PATCH] some stuff by 27: - better BSP tree splitting (experimental, option -altsplit) - also compare shaders when sorting surfaces (should give slightly more fps) - misc_model spawnflag 32: set vertex alpha from vertex color (for terrain blending) git-svn-id: svn://svn.icculus.org/netradiant/trunk@240 61c419a2-8eb2-4b30-bcec-8cead039b335 --- tools/quake3/q3map2/bsp.c | 5 +++ tools/quake3/q3map2/facebsp.c | 46 ++++++++++++++++++++++++--- tools/quake3/q3map2/light.c | 1 + tools/quake3/q3map2/lightmaps_ydnar.c | 7 ++++ tools/quake3/q3map2/model.c | 18 ++++++++--- tools/quake3/q3map2/q3map2.h | 2 ++ 6 files changed, 70 insertions(+), 9 deletions(-) diff --git a/tools/quake3/q3map2/bsp.c b/tools/quake3/q3map2/bsp.c index a908809..c04f30d 100644 --- a/tools/quake3/q3map2/bsp.c +++ b/tools/quake3/q3map2/bsp.c @@ -888,6 +888,11 @@ int BSPMain( int argc, char **argv ) Sys_Printf( "Debug portal surfaces enabled\n" ); debugPortals = qtrue; } + else if( !strcmp( argv[ i ], "-altsplit" ) ) + { + Sys_Printf( "Alternate BSP splitting (by 27) enabled\n" ); + bspAlternateSplitWeights = qtrue; + } else if( !strcmp( argv[ i ], "-bsp" ) ) Sys_Printf( "-bsp argument unnecessary\n" ); else diff --git a/tools/quake3/q3map2/facebsp.c b/tools/quake3/q3map2/facebsp.c index 270eefe..65532a1 100644 --- a/tools/quake3/q3map2/facebsp.c +++ b/tools/quake3/q3map2/facebsp.c @@ -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 ); diff --git a/tools/quake3/q3map2/light.c b/tools/quake3/q3map2/light.c index 79ebf77..9a50d82 100644 --- a/tools/quake3/q3map2/light.c +++ b/tools/quake3/q3map2/light.c @@ -403,6 +403,7 @@ void CreateEntityLights( void ) intensity = intensity * pointScale; light->photons = intensity; + light->type = EMIT_POINT; /* set falloff threshold */ diff --git a/tools/quake3/q3map2/lightmaps_ydnar.c b/tools/quake3/q3map2/lightmaps_ydnar.c index 1c994eb..8ea7aa3 100644 --- a/tools/quake3/q3map2/lightmaps_ydnar.c +++ b/tools/quake3/q3map2/lightmaps_ydnar.c @@ -875,6 +875,13 @@ static int CompareSurfaceInfo( const void *a, const void *b ) return 1; else if( aInfo->hasLightmap > bInfo->hasLightmap ) return -1; + + /* 27: then shader! */ + if (aInfo->si < bInfo->si) + return 1; + else if (aInfo->si > bInfo->si) + return -1; + /* then lightmap sample size */ if( aInfo->sampleSize < bInfo->sampleSize ) diff --git a/tools/quake3/q3map2/model.c b/tools/quake3/q3map2/model.c index 58fb184..f655370 100644 --- a/tools/quake3/q3map2/model.c +++ b/tools/quake3/q3map2/model.c @@ -382,10 +382,20 @@ void InsertModel( char *name, int frame, m4x4_t transform, remap_t *remap, shade { dv->lightmap[ j ][ 0 ] = 0.0f; dv->lightmap[ j ][ 1 ] = 0.0f; - dv->color[ j ][ 0 ] = color[ 0 ]; - dv->color[ j ][ 1 ] = color[ 1 ]; - dv->color[ j ][ 2 ] = color[ 2 ]; - dv->color[ j ][ 3 ] = color[ 3 ]; + if(spawnFlags & 32) // spawnflag 32: model color -> alpha hack + { + dv->color[ j ][ 0 ] = 255.0f; + dv->color[ j ][ 1 ] = 255.0f; + dv->color[ j ][ 2 ] = 255.0f; + dv->color[ j ][ 3 ] = color[ 0 ] * 0.3f + color[ 1 ] * 0.59f + color[ 2 ] * 0.11f; + } + else + { + dv->color[ j ][ 0 ] = color[ 0 ]; + dv->color[ j ][ 1 ] = color[ 1 ]; + dv->color[ j ][ 2 ] = color[ 2 ]; + dv->color[ j ][ 3 ] = color[ 3 ]; + } } } diff --git a/tools/quake3/q3map2/q3map2.h b/tools/quake3/q3map2/q3map2.h index b9521a8..0a6f3f3 100644 --- a/tools/quake3/q3map2/q3map2.h +++ b/tools/quake3/q3map2/q3map2.h @@ -806,6 +806,7 @@ typedef struct plane_s vec3_t normal; vec_t dist; int type; + int counter; int hash_chain; } plane_t; @@ -1953,6 +1954,7 @@ Q_EXTERN qboolean nofog Q_ASSIGN( qfalse ); Q_EXTERN qboolean noHint Q_ASSIGN( qfalse ); /* ydnar */ Q_EXTERN qboolean renameModelShaders Q_ASSIGN( qfalse ); /* ydnar */ Q_EXTERN qboolean skyFixHack Q_ASSIGN( qfalse ); /* ydnar */ +Q_EXTERN qboolean bspAlternateSplitWeights Q_ASSIGN( qfalse ); /* 27 */ Q_EXTERN int patchSubdivisions Q_ASSIGN( 8 ); /* ydnar: -patchmeta subdivisions */ -- 2.39.2