From 57834c438bb8e4b18ee514e2fbbebdd1d2ddd8ea Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Tue, 20 Sep 2016 16:07:37 -0600 Subject: [PATCH] light: add "_lightignore" model key --- include/light/light.hh | 7 ++-- light/ltface.cc | 50 +++++++++++++++++------------ testmaps/lightstest1.map | 69 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 103 insertions(+), 23 deletions(-) diff --git a/include/light/light.hh b/include/light/light.hh index 9df87b1e..d50c0394 100644 --- a/include/light/light.hh +++ b/include/light/light.hh @@ -217,6 +217,7 @@ public: lockable_vec_t minlight, shadow, shadowself, dirt, phong, phong_angle; lockable_string_t minlight_exclude; lockable_vec3_t minlight_color; + lockable_bool_t lightignore; float getResolvedPhongAngle() const { const float s = phong_angle.floatValue(); @@ -240,7 +241,9 @@ public: phong { "phong", 0 }, phong_angle { "phong_angle", 0 }, minlight_exclude { "minlight_exclude", "" }, - minlight_color { "minlight_color", 255, 255, 255, vec3_transformer_t::NORMALIZE_COLOR_TO_255 } + minlight_color { "minlight_color", 255, 255, 255, vec3_transformer_t::NORMALIZE_COLOR_TO_255 }, + lightignore { "lightignore", false } + { VectorSet(offset, 0, 0, 0); } @@ -248,7 +251,7 @@ public: settingsdict_t settings() { return {{ &minlight, &shadow, &shadowself, &dirt, &phong, &phong_angle, - &minlight_exclude, &minlight_color + &minlight_exclude, &minlight_color, &lightignore }}; } }; diff --git a/light/ltface.cc b/light/ltface.cc index f1a0eb0e..05e82773 100644 --- a/light/ltface.cc +++ b/light/ltface.cc @@ -1512,6 +1512,10 @@ LightFace_Min(const bsp2_t *bsp, const bsp2_dface_t *face, Lightmap_Save(lightmaps, lightsurf, lightmap, 0); } + // FIXME: Refactor this? + if (lightsurf->modelinfo->lightignore.boolValue()) + return; + /* Cast rays for local minlight entities */ const dmodel_t *shadowself = modelinfo->shadowself.boolValue() ? modelinfo->model : NULL; for (const auto &entity : GetLights()) { @@ -2351,19 +2355,21 @@ LightFace(bsp2_dface_t *face, facesup_t *facesup, const modelinfo_t *modelinfo, total_samplepoints += lightsurf->numpoints; /* positive lights */ - for (const auto &entity : GetLights()) - { - if (entity.getFormula() == LF_LOCALMIN) - continue; - if (entity.light.floatValue() > 0) - LightFace_Entity(bsp, &entity, lightsurf, lightmaps); - } - for ( const sun_t &sun : GetSuns() ) - if (sun.sunlight > 0) - LightFace_Sky (&sun, lightsurf, lightmaps); + if (!modelinfo->lightignore.boolValue()) { + for (const auto &entity : GetLights()) + { + if (entity.getFormula() == LF_LOCALMIN) + continue; + if (entity.light.floatValue() > 0) + LightFace_Entity(bsp, &entity, lightsurf, lightmaps); + } + for ( const sun_t &sun : GetSuns() ) + if (sun.sunlight > 0) + LightFace_Sky (&sun, lightsurf, lightmaps); - /* add indirect lighting */ - LightFace_Bounce(ctx->bsp, face, lightsurf, lightmaps); + /* add indirect lighting */ + LightFace_Bounce(ctx->bsp, face, lightsurf, lightmaps); + } /* minlight - Use the greater of global or model minlight. */ if (lightsurf->minlight > cfg.minlight.floatValue()) @@ -2377,16 +2383,18 @@ LightFace(bsp2_dface_t *face, facesup_t *facesup, const modelinfo_t *modelinfo, } /* negative lights */ - for (const auto &entity : GetLights()) - { - if (entity.getFormula() == LF_LOCALMIN) - continue; - if (entity.light.floatValue() < 0) - LightFace_Entity(bsp, &entity, lightsurf, lightmaps); + if (!modelinfo->lightignore.boolValue()) { + for (const auto &entity : GetLights()) + { + if (entity.getFormula() == LF_LOCALMIN) + continue; + if (entity.light.floatValue() < 0) + LightFace_Entity(bsp, &entity, lightsurf, lightmaps); + } + for (const sun_t &sun : GetSuns()) + if (sun.sunlight < 0) + LightFace_Sky (&sun, lightsurf, lightmaps); } - for (const sun_t &sun : GetSuns()) - if (sun.sunlight < 0) - LightFace_Sky (&sun, lightsurf, lightmaps); } /* bounce debug */ diff --git a/testmaps/lightstest1.map b/testmaps/lightstest1.map index c4931dde..99fa5f36 100644 --- a/testmaps/lightstest1.map +++ b/testmaps/lightstest1.map @@ -5,6 +5,7 @@ "classname" "worldspawn" "wad" "free_wad.wad;fence.wad" "light" "4" +"_dirt" "1" // brush 0 { ( 1184 -640 80 ) ( 1184 -640 81 ) ( 1184 -639 80 ) narrow 64 -0 -0 1 1 @@ -1957,3 +1958,71 @@ "delay" "2" "style" "2" } +// entity 84 +{ +"classname" "func_wall" +"_lightignore" "1" +"_shadowself" "1" +// brush 0 +{ +( 592 -384 112 ) ( 656 -384 128 ) ( 656 -384 112 ) brownmetal -0 48 -0 1 1 +( 592 -480 112 ) ( 592 -368 128 ) ( 592 -480 128 ) brownmetal -0 48 -0 1 1 +( 592 -480 112 ) ( 656 -368 112 ) ( 592 -368 112 ) brownmetal -0 16 -0 1 1 +( 592 -480 144 ) ( 656 -368 144 ) ( 656 -480 144 ) brownmetal -0 16 -0 1 1 +( 592 -368 112 ) ( 656 -368 128 ) ( 592 -368 128 ) brownmetal -0 48 -0 1 1 +( 656 -480 112 ) ( 656 -368 128 ) ( 656 -368 112 ) brownmetal -0 48 -0 1 1 +} +// brush 1 +{ +( 592 -480 112 ) ( 656 -480 128 ) ( 656 -480 112 ) brownmetal -0 48 -0 1 1 +( 592 -576 112 ) ( 592 -464 128 ) ( 592 -576 128 ) brownmetal 32 48 -0 1 1 +( 592 -576 112 ) ( 656 -464 112 ) ( 592 -464 112 ) brownmetal -0 -16 -0 1 1 +( 592 -576 144 ) ( 656 -464 144 ) ( 656 -576 144 ) brownmetal -0 -16 -0 1 1 +( 592 -464 112 ) ( 656 -464 128 ) ( 592 -464 128 ) brownmetal -0 48 -0 1 1 +( 656 -576 112 ) ( 656 -464 128 ) ( 656 -464 112 ) brownmetal 32 48 -0 1 1 +} +// brush 2 +{ +( 592 -480 80 ) ( 656 -480 96 ) ( 656 -480 80 ) brownmetal 64 80 0 1 1 +( 592 -480 80 ) ( 592 -368 96 ) ( 592 -480 96 ) brownmetal 64 80 0 1 1 +( 592 -480 80 ) ( 656 -368 80 ) ( 592 -368 80 ) brownmetal 64 80 0 1 1 +( 592 -480 112 ) ( 656 -368 112 ) ( 656 -480 112 ) brownmetal -0 16 -0 1 1 +( 592 -368 80 ) ( 656 -368 96 ) ( 592 -368 96 ) brownmetal 64 80 0 1 1 +( 656 -480 80 ) ( 656 -368 96 ) ( 656 -368 80 ) brownmetal 64 80 0 1 1 +} +} +// entity 85 +{ +"classname" "func_wall" +"_lightignore" "1" +"_minlight" "100" +"_minlight_color" "50 50 255" +"_shadowself" "1" +// brush 0 +{ +( 592 -560 128 ) ( 656 -560 144 ) ( 656 -560 128 ) brownmetal -0 -0 -0 1 1 +( 592 -656 128 ) ( 592 -544 144 ) ( 592 -656 144 ) brownmetal 48 -0 -0 1 1 +( 592 -656 128 ) ( 656 -544 128 ) ( 592 -544 128 ) brownmetal -0 -32 -0 1 1 +( 592 -656 160 ) ( 656 -544 160 ) ( 656 -656 160 ) brownmetal -0 -32 -0 1 1 +( 592 -544 128 ) ( 656 -544 144 ) ( 592 -544 144 ) brownmetal -0 -0 -0 1 1 +( 656 -656 128 ) ( 656 -544 144 ) ( 656 -544 128 ) brownmetal 48 -0 -0 1 1 +} +// brush 1 +{ +( 592 -656 128 ) ( 656 -656 144 ) ( 656 -656 128 ) brownmetal -0 -0 -0 1 1 +( 592 -752 128 ) ( 592 -640 144 ) ( 592 -752 144 ) brownmetal 16 -0 -0 1 1 +( 592 -752 128 ) ( 656 -640 128 ) ( 592 -640 128 ) brownmetal -0 -0 -0 1 1 +( 592 -752 160 ) ( 656 -640 160 ) ( 656 -752 160 ) brownmetal -0 -0 -0 1 1 +( 592 -640 128 ) ( 656 -640 144 ) ( 592 -640 144 ) brownmetal -0 -0 -0 1 1 +( 656 -752 128 ) ( 656 -640 144 ) ( 656 -640 128 ) brownmetal 16 -0 -0 1 1 +} +// brush 2 +{ +( 592 -656 96 ) ( 656 -656 112 ) ( 656 -656 96 ) brownmetal -0 32 -0 1 1 +( 592 -656 96 ) ( 592 -544 112 ) ( 592 -656 112 ) brownmetal 48 32 -0 1 1 +( 592 -656 96 ) ( 656 -544 96 ) ( 592 -544 96 ) brownmetal -0 -32 -0 1 1 +( 592 -656 128 ) ( 656 -544 128 ) ( 656 -656 128 ) brownmetal -0 -32 -0 1 1 +( 592 -544 96 ) ( 656 -544 112 ) ( 592 -544 112 ) brownmetal -0 32 -0 1 1 +( 656 -656 96 ) ( 656 -544 112 ) ( 656 -544 96 ) brownmetal 48 32 -0 1 1 +} +}