light: only allow one debug mode at a time

This commit is contained in:
Eric Wasylishen 2016-05-27 12:25:51 -06:00
parent 7687e4a927
commit ca0f0448fe
3 changed files with 32 additions and 15 deletions

View File

@ -159,6 +159,17 @@ struct ltface_ctx
extern struct ltface_ctx *ltface_ctxs;
/* debug */
typedef enum {
debugmode_none = 0,
debugmode_phong,
debugmode_dirt,
debugmode_bounce
} debugmode_t;
extern debugmode_t debugmode;
/* bounce lights */
typedef struct {
@ -212,7 +223,6 @@ extern sun_t *suns;
/* dirt */
extern qboolean dirty; // should any dirtmapping take place?
extern qboolean dirtDebug;
extern int dirtMode;
extern float dirtDepth;
extern float dirtScale;
@ -231,7 +241,6 @@ extern qboolean dirtAngleSetOnCmdline;
/* bounce */
extern qboolean bounce;
extern qboolean bouncedebug;
extern vec_t bouncescale;
extern vec_t bouncecolorscale;
@ -264,7 +273,6 @@ TriangleArea(const vec3_t v0, const vec3_t v1, const vec3_t v2);
extern qboolean testFenceTextures;
extern qboolean surflight_dump;
extern qboolean phongDebug;
extern char mapfilename[1024];

View File

@ -53,7 +53,6 @@ sun_t *suns = NULL;
/* dirt */
qboolean dirty = false;
qboolean dirtDebug = false;
int dirtMode = 0;
float dirtDepth = 128.0f;
float dirtScale = 1.0f;
@ -72,7 +71,6 @@ qboolean dirtAngleSetOnCmdline = false;
/* bounce */
qboolean bounce = false;
qboolean bouncedebug = false;
vec_t bouncescale = 1.0f;
vec_t bouncecolorscale = 0.0f;
@ -102,9 +100,9 @@ int oversample = 1;
int write_litfile = 0; /* 0 for none, 1 for .lit, 2 for bspx, 3 for both */
int write_luxfile = 0; /* 0 for none, 1 for .lux, 2 for bspx, 3 for both */
qboolean onlyents = false;
qboolean phongDebug = false;
qboolean parse_escape_sequences = true;
qboolean novis = false; /* if true, don't use vis data */
debugmode_t debugmode = debugmode_none;
uint32_t *extended_texinfo_flags = NULL;
@ -1185,6 +1183,14 @@ const bsp2_dleaf_t **Face_CopyLeafList(const bsp2_t *bsp, const bsp2_dface_t *fa
return result;
}
static void
CheckNoDebugModeSet()
{
if (debugmode != debugmode_none) {
Error("Only one debug mode is allowed at a time");
}
}
/*
* ==================
* main
@ -1269,9 +1275,10 @@ main(int argc, const char **argv)
minlightDirt = true;
logprint( "Dirtmapping enabled globally\n" );
} else if ( !strcmp( argv[ i ], "-dirtdebug" ) || !strcmp( argv[ i ], "-debugdirt" ) ) {
CheckNoDebugModeSet();
dirty = true;
globalDirt = true;
dirtDebug = true;
debugmode = debugmode_dirt;
logprint( "Dirtmap debugging enabled\n" );
} else if ( !strcmp( argv[ i ], "-dirtmode" ) ) {
dirtModeSetOnCmdline = true;
@ -1314,8 +1321,9 @@ main(int argc, const char **argv)
bounce = true;
logprint( "Bounce enabled on command line\n" );
} else if ( !strcmp( argv[ i ], "-bouncedebug" ) ) {
CheckNoDebugModeSet();
bounce = true;
bouncedebug = true;
debugmode = debugmode_bounce;
logprint( "Bounce debugging mode enabled on command line\n" );
} else if ( !strcmp( argv[ i ], "-bouncescale" ) ) {
bounce = true;
@ -1345,7 +1353,8 @@ main(int argc, const char **argv)
parse_escape_sequences = false;
logprint( "Parsing escape sequences disabled\n" );
} else if ( !strcmp( argv[ i ], "-phongdebug" ) ) {
phongDebug = true;
CheckNoDebugModeSet();
debugmode = debugmode_phong;
write_litfile |= 1;
logprint( "Phong shading debug mode enabled\n" );
} else if ( !strcmp( argv[ i ], "-novis" ) ) {

View File

@ -1684,7 +1684,7 @@ LightFace_Bounce(const bsp2_t *bsp, const bsp2_dface_t *face, const lightsurf_t
/* Use dirt scaling on the indirect lighting.
* Except, not in bouncedebug mode.
*/
if (!bouncedebug) {
if (debugmode != debugmode_bounce) {
const vec_t dirtscale = Dirt_GetScaleFactor(lightsurf->occlusion[i], NULL, lightsurf);
VectorScale(indirect, dirtscale, indirect);
}
@ -2093,7 +2093,7 @@ LightFace(bsp2_dface_t *face, facesup_t *facesup, const modelinfo_t *modelinfo,
Lightmaps_Init(lightsurf, lightmaps, MAXLIGHTMAPS + 1);
/* calculate dirt (ambient occlusion) but don't use it yet */
if (dirty && !phongDebug)
if (dirty && (debugmode != debugmode_phong))
LightFace_CalculateDirt(lightsurf);
/*
@ -2102,7 +2102,7 @@ LightFace(bsp2_dface_t *face, facesup_t *facesup, const modelinfo_t *modelinfo,
* clamp any values that may have gone negative.
*/
if (!dirtDebug && !phongDebug) {
if (!(debugmode == debugmode_dirt || debugmode == debugmode_phong)) {
/* positive lights */
for (lighte = lights; (entity = *lighte); lighte++)
{
@ -2135,10 +2135,10 @@ LightFace(bsp2_dface_t *face, facesup_t *facesup, const modelinfo_t *modelinfo,
}
/* replace lightmaps with AO for debugging */
if (dirtDebug)
if (debugmode == debugmode_dirt)
LightFace_DirtDebug(lightsurf, lightmaps);
if (phongDebug)
if (debugmode == debugmode_phong)
LightFace_PhongDebug(lightsurf, lightmaps);
/* Fix any negative values */
@ -2219,7 +2219,7 @@ LightFaceIndirect(bsp2_dface_t *face, facesup_t *facesup, const modelinfo_t *mod
{
lightmap_t *lightmaps = ctx->lightmaps;
lightsurf_t *lightsurf = &ctx->lightsurf;
if (bouncedebug)
if (debugmode == debugmode_bounce)
{
Lightmap_ClearAll(lightmaps);
}