From c488aa115be226fdadad3c087cf80374f7f89cb3 Mon Sep 17 00:00:00 2001 From: Garux Date: Thu, 14 Nov 2024 22:02:38 +0500 Subject: [PATCH] * -globalflag : add surface flag to every bsp shader. Reusable, e.g. -globalflag slick -globalflag nodamage. --- docs/Complete_list_of_command_line_parameters.htm | 1 + docs/changelog-custom.txt | 1 + tools/quake3/q3map2/bsp.cpp | 4 ++++ tools/quake3/q3map2/help.cpp | 1 + tools/quake3/q3map2/q3map2.h | 1 + tools/quake3/q3map2/shaders.cpp | 1 + 6 files changed, 9 insertions(+) diff --git a/docs/Complete_list_of_command_line_parameters.htm b/docs/Complete_list_of_command_line_parameters.htm index c2a0fbc4..b5c72807 100644 --- a/docs/Complete_list_of_command_line_parameters.htm +++ b/docs/Complete_list_of_command_line_parameters.htm @@ -140,6 +140,7 @@ td.formatted_questions ol { margin-top: 0px; margin-bottom: 0px; }
  • -flares: Turn on support for flares
  • -flat: Enable flat shading (good for combining with -celshader)
  • -fulldetail: Treat detail brushes as structural ones
  • +
  • -globalflag surfaceparm: Add surface flag to every bsp shader. Reusable, e.g. -globalflag slick -globalflag nodamage.
  • -keeplights: Keep light entities in the BSP file after compile
  • -keepmodels: Keep misc_model entities in the BSP file after compile
  • -leaktest: Abort if a leak was found
  • diff --git a/docs/changelog-custom.txt b/docs/changelog-custom.txt index 2fb42ad7..ccccd6df 100644 --- a/docs/changelog-custom.txt +++ b/docs/changelog-custom.txt @@ -177,6 +177,7 @@ Q3map2: * generate shaders to force nomipmaps flag on external lightmap images created by lightstyles and external lms hacks * -nobrushsnap: disable brush vertices snapping (of drawsurfs) (experimental, keep eye on meta merge efficiency) * improved brush faces triangulation wrt degenerate triangles production (non -maxarea algorithm) + * -globalflag : add surface flag to every bsp shader. Reusable, e.g. -globalflag slick -globalflag nodamage. diff --git a/tools/quake3/q3map2/bsp.cpp b/tools/quake3/q3map2/bsp.cpp index 2dabdcc9..56ff189a 100644 --- a/tools/quake3/q3map2/bsp.cpp +++ b/tools/quake3/q3map2/bsp.cpp @@ -867,6 +867,10 @@ int BSPMain( Args& args ){ Sys_Printf( "No oBs!\n" ); g_noob = true; } + while ( args.takeArg( "-globalflag" ) ) { + ApplySurfaceParm( args.takeNext(), nullptr, &g_globalSurfaceFlags, nullptr ); + Sys_Printf( "g_globalSurfaceFlags: 0x%.8X\n", g_globalSurfaceFlags ); + } while ( args.takeArg( "-autocaulk" ) ) { Sys_Printf( "\trunning in autocaulk mode\n" ); g_autocaulk = true; diff --git a/tools/quake3/q3map2/help.cpp b/tools/quake3/q3map2/help.cpp index c72b8722..87f115c8 100644 --- a/tools/quake3/q3map2/help.cpp +++ b/tools/quake3/q3map2/help.cpp @@ -101,6 +101,7 @@ static void HelpBsp() {"-flares", "Turn on support for flares"}, {"-flat", "Enable flat shading (good for combining with -celshader)"}, {"-fulldetail", "Treat detail brushes as structural ones"}, + {"-globalflag ", "Add surface flag to every bsp shader. Reusable, e.g. -globalflag slick -globalflag nodamage."}, {"-keeplights", "Keep light entities in the BSP file after compile"}, {"-keepmodels", "Keep misc_model entities in the BSP file after compile"}, {"-leaktest", "Abort if a leak was found"}, diff --git a/tools/quake3/q3map2/q3map2.h b/tools/quake3/q3map2/q3map2.h index 79fbe208..694413ea 100644 --- a/tools/quake3/q3map2/q3map2.h +++ b/tools/quake3/q3map2/q3map2.h @@ -1768,6 +1768,7 @@ inline float clipDepthGlobal = 2.0f; inline int metaAdequateScore = -1; inline int metaGoodScore = -1; inline bool g_noob; +inline int g_globalSurfaceFlags; inline String64 globalCelShader; inline bool keepLights; inline bool keepModels; diff --git a/tools/quake3/q3map2/shaders.cpp b/tools/quake3/q3map2/shaders.cpp index 25c8cc09..928810be 100644 --- a/tools/quake3/q3map2/shaders.cpp +++ b/tools/quake3/q3map2/shaders.cpp @@ -646,6 +646,7 @@ static void FinishShader( shaderInfo_t *si ){ if( g_noob && !( si->compileFlags & C_OB ) ){ ApplySurfaceParm( "noob", nullptr, &si->surfaceFlags, nullptr ); } + si->surfaceFlags |= g_globalSurfaceFlags; /* set to finished */ si->finished = true;