light: add -surflight_dump option to export generated surface lights to a map file
This commit is contained in:
parent
81cefad71a
commit
e6fcf3d6da
|
|
@ -159,5 +159,8 @@ void SetupDirt();
|
|||
void WorldToTexCoord(const vec3_t world, const texinfo_t *tex, vec_t coord[2]);
|
||||
|
||||
extern qboolean testFenceTextures;
|
||||
extern qboolean surflight_dump;
|
||||
|
||||
extern char mapfilename[1024];
|
||||
|
||||
#endif /* __LIGHT_LIGHT_H__ */
|
||||
|
|
|
|||
|
|
@ -1037,6 +1037,24 @@ WriteEntitiesToString(bsp2_t *bsp)
|
|||
* =======================================================================
|
||||
*/
|
||||
|
||||
FILE *surflights_dump_file;
|
||||
char surflights_dump_filename[1024];
|
||||
|
||||
void
|
||||
WriteEntityToFile(FILE *f, entity_t *entity)
|
||||
{
|
||||
const epair_t *epair;
|
||||
|
||||
if (!entity->epairs)
|
||||
return;
|
||||
|
||||
fprintf(f, "{\n");
|
||||
for (epair = entity->epairs; epair; epair = epair->next) {
|
||||
fprintf(f, "\"%s\" \"%s\"\n", epair->key, epair->value);
|
||||
}
|
||||
fprintf(f, "}\n");
|
||||
}
|
||||
|
||||
static void CreateSurfaceLight(const vec3_t origin, const vec3_t normal, const entity_t *surflight_template)
|
||||
{
|
||||
entity_t *entity = DuplicateEntity(surflight_template);
|
||||
|
|
@ -1051,7 +1069,13 @@ static void CreateSurfaceLight(const vec3_t origin, const vec3_t normal, const e
|
|||
entity->spotlight = true;
|
||||
VectorCopy(normal, entity->spotvec);
|
||||
}
|
||||
|
||||
|
||||
/* export it to a map file for debugging */
|
||||
if (surflight_dump) {
|
||||
SetKeyValue(entity, "origin", VecStr(origin));
|
||||
WriteEntityToFile(surflights_dump_file, entity);
|
||||
}
|
||||
|
||||
num_lights++;
|
||||
}
|
||||
|
||||
|
|
@ -1239,6 +1263,13 @@ static void MakeSurfaceLights(const bsp2_t *bsp)
|
|||
if (!num_surfacelight_templates)
|
||||
return;
|
||||
|
||||
if (surflight_dump) {
|
||||
strcpy(surflights_dump_filename, mapfilename);
|
||||
StripExtension(surflights_dump_filename);
|
||||
strcat(surflights_dump_filename, "-surflights.map");
|
||||
surflights_dump_file = fopen(surflights_dump_filename, "w");
|
||||
}
|
||||
|
||||
/* Create the surface lights */
|
||||
qboolean *face_visited = (qboolean *)calloc(bsp->numfaces, sizeof(qboolean));
|
||||
for (i=0; i<bsp->numleafs; i++) {
|
||||
|
|
@ -1284,4 +1315,9 @@ static void MakeSurfaceLights(const bsp2_t *bsp)
|
|||
for (i=0;i<num_surfacelight_templates;i++) {
|
||||
surfacelight_templates[i]->light.light = 0;
|
||||
}
|
||||
|
||||
if (surflights_dump_file) {
|
||||
fclose(surflights_dump_file);
|
||||
printf("wrote surface lights to '%s'\n", surflights_dump_filename);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ qboolean dirtGainSetOnCmdline = false;
|
|||
qboolean dirtAngleSetOnCmdline = false;
|
||||
|
||||
qboolean testFenceTextures = false;
|
||||
qboolean surflight_dump = false;
|
||||
|
||||
byte *filebase; // start of lightmap data
|
||||
static byte *file_p; // start of free space after data
|
||||
|
|
@ -80,6 +81,8 @@ qboolean write_luxfile = false;
|
|||
qboolean onlyents = false;
|
||||
qboolean parse_escape_sequences = false;
|
||||
|
||||
char mapfilename[1024];
|
||||
|
||||
void
|
||||
GetFileSpace(byte **lightdata, byte **colordata, byte **deluxdata, int size)
|
||||
{
|
||||
|
|
@ -383,7 +386,9 @@ main(int argc, const char **argv)
|
|||
surflight_subdivide = atof( argv[ ++i ] );
|
||||
surflight_subdivide = qmin(qmax(surflight_subdivide, 64.0f), 2048.0f);
|
||||
logprint( "Using surface light subdivision size of %f\n", surflight_subdivide);
|
||||
} else if ( !strcmp( argv[ i ], "-sunsamples" ) ) {
|
||||
} else if ( !strcmp( argv[ i ], "-surflight_dump" ) ) {
|
||||
surflight_dump = true;
|
||||
} else if ( !strcmp( argv[ i ], "-sunsamples" ) ) {
|
||||
sunsamples = atof( argv[ ++i ] );
|
||||
sunsamples = qmin(qmax(sunsamples, 8), 2048);
|
||||
logprint( "Using sunsamples of %d\n", sunsamples);
|
||||
|
|
@ -404,7 +409,7 @@ main(int argc, const char **argv)
|
|||
" [-light num] [-addmin] [-anglescale|-anglesense]\n"
|
||||
" [-dist n] [-range n] [-gate n] [-lit] [-lux]\n"
|
||||
" [-dirt] [-dirtdebug] [-dirtmode n] [-dirtdepth n] [-dirtscale n] [-dirtgain n] [-dirtangle n]\n"
|
||||
" [-soft [n]] [-fence] [-gamma n] [-surflight_subdivide n] [-onlyents] [-sunsamples n] [-parse_escape_sequences] bspfile\n");
|
||||
" [-soft [n]] [-fence] [-gamma n] [-surflight_subdivide n] [-surflight_dump] [-onlyents] [-sunsamples n] [-parse_escape_sequences] bspfile\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
|
@ -431,6 +436,7 @@ main(int argc, const char **argv)
|
|||
start = I_FloatTime();
|
||||
|
||||
strcpy(source, argv[i]);
|
||||
strcpy(mapfilename, argv[i]);
|
||||
StripExtension(source);
|
||||
DefaultExtension(source, ".bsp");
|
||||
LoadBSPFile(source, &bspdata);
|
||||
|
|
|
|||
Loading…
Reference in New Issue