From ed1b1d633849325d645806c1acfb1604234774b5 Mon Sep 17 00:00:00 2001 From: Marco Hladik Date: Thu, 20 Jan 2022 14:58:05 -0800 Subject: [PATCH] vmap: Detect 'generatelightmaps' inside prop_static to decide whether or not to bake an entity into the .bsp or not. --- tools/vmap/bspfile_abstract.c | 10 +++++++++- tools/vmap/model.c | 8 ++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/tools/vmap/bspfile_abstract.c b/tools/vmap/bspfile_abstract.c index d3c593d..f8e86f5 100644 --- a/tools/vmap/bspfile_abstract.c +++ b/tools/vmap/bspfile_abstract.c @@ -834,12 +834,20 @@ void UnparseEntities( void ){ /* ydnar: certain entities get stripped from bsp file */ value2 = ValueForKey( &entities[ i ], "classname" ); if ( !Q_stricmp( value2, "misc_model" ) || - !Q_stricmp( value2, "prop_static" ) || !Q_stricmp( value2, "_decal" ) || !Q_stricmp( value2, "_skybox" ) ) { continue; } + /* only strip prop_statics that are built into the bsp */ + if (!Q_stricmp( value2, "prop_static" )) { + int foo; + foo = IntForKey(&entities[i], "generatelightmaps"); + + if (foo == 1) + continue; + } + /* add beginning brace */ strcat( end, "{\n" ); end += 2; diff --git a/tools/vmap/model.c b/tools/vmap/model.c index 1b66359..803a4b8 100644 --- a/tools/vmap/model.c +++ b/tools/vmap/model.c @@ -689,6 +689,7 @@ void AddTriangleModels( entity_t *e ){ float temp, baseLightmapScale, lightmapScale; float shadeAngle; int lightmapSampleSize; + int genlightMap; vec3_t origin, scale, angles; m4x4_t transform; epair_t *ep; @@ -745,6 +746,12 @@ void AddTriangleModels( entity_t *e ){ continue; } + /* only bake into the map if we're generating lightmaps */ + genlightMap = IntForKey( e2, "generatelightmaps" ); + + if (genlightMap != 1) + continue; + /* ydnar: added support for md3 models on non-worldspawn models */ target = ValueForKey( e2, "target" ); if ( strcmp( target, targetName ) ) { @@ -931,6 +938,7 @@ void AddTriangleModels( entity_t *e ){ /* insert the model */ InsertModel( model, skin, frame, transform, remap, celShader, mapEntityNum, castShadows, recvShadows, spawnFlags, lightmapScale, lightmapSampleSize, shadeAngle ); + printf("Inserting model %s\n", model); /* free shader remappings */ while ( remap != NULL )