From 99d1581c27c2db48bc1e9c60737cb57fb22bc181 Mon Sep 17 00:00:00 2001 From: nashmuhandes Date: Sat, 25 Mar 2017 14:59:33 +0800 Subject: [PATCH] Added "DontLightActors" flag for dynamic lights. Actors will not be illuminated by lights that are given this flag. --- src/g_shared/a_dynlight.h | 1 + src/g_shared/a_dynlightdata.cpp | 23 +++++++++++++++++++++-- src/gl/scene/gl_spritelight.cpp | 2 +- src/scripting/thingdef_data.cpp | 1 + src/swrenderer/things/r_sprite.cpp | 2 +- 5 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/g_shared/a_dynlight.h b/src/g_shared/a_dynlight.h index 1a1862957..893bbfbee 100644 --- a/src/g_shared/a_dynlight.h +++ b/src/g_shared/a_dynlight.h @@ -27,6 +27,7 @@ enum #define MF4_DONTLIGHTSELF MF4_SEESDAGGERS #define MF4_ATTENUATE MF4_INCOMBAT #define MF4_NOSHADOWMAP MF4_STANDSTILL +#define MF4_DONTLIGHTACTORS MF4_EXTREMEDEATH enum ELightType { diff --git a/src/g_shared/a_dynlightdata.cpp b/src/g_shared/a_dynlightdata.cpp index 160ddea5f..7db1f8f7c 100644 --- a/src/g_shared/a_dynlightdata.cpp +++ b/src/g_shared/a_dynlightdata.cpp @@ -127,6 +127,7 @@ public: void SetDontLightSelf(bool add) { m_dontlightself = add; } void SetAttenuate(bool on) { m_attenuate = on; } void SetHalo(bool halo) { m_halo = halo; } + void SetDontLightActors(bool on) { m_dontlightactors = on; } void OrderIntensities() { @@ -144,7 +145,7 @@ protected: DVector3 m_Pos; ELightType m_type; int8_t m_attenuate; - bool m_subtractive, m_additive, m_halo, m_dontlightself; + bool m_subtractive, m_additive, m_halo, m_dontlightself, m_dontlightactors; bool m_swapped = false; }; @@ -187,6 +188,7 @@ void FLightDefaults::ApplyProperties(ADynamicLight * light) const if (m_subtractive) light->flags4 |= MF4_SUBTRACTIVE; if (m_additive) light->flags4 |= MF4_ADDITIVE; if (m_dontlightself) light->flags4 |= MF4_DONTLIGHTSELF; + if (m_dontlightactors) light->flags4 |= MF4_DONTLIGHTACTORS; light->m_tickCount = 0; if (m_type == PulseLight) { @@ -236,6 +238,7 @@ static const char *LightTags[]= "halo", "dontlightself", "attenuate", + "dontlightactors", NULL }; @@ -256,7 +259,8 @@ enum { LIGHTTAG_ADDITIVE, LIGHTTAG_HALO, LIGHTTAG_DONTLIGHTSELF, - LIGHTTAG_ATTENUATE + LIGHTTAG_ATTENUATE, + LIGHTTAG_DONTLIGHTACTORS, }; @@ -394,6 +398,9 @@ static void ParsePointLight(FScanner &sc) case LIGHTTAG_ATTENUATE: defaults->SetAttenuate(ParseInt(sc) != 0); break; + case LIGHTTAG_DONTLIGHTACTORS: + defaults->SetDontLightActors(ParseInt(sc) != 0); + break; default: sc.ScriptError("Unknown tag: %s\n", sc.String); } @@ -476,6 +483,9 @@ static void ParsePulseLight(FScanner &sc) case LIGHTTAG_ATTENUATE: defaults->SetAttenuate(ParseInt(sc) != 0); break; + case LIGHTTAG_DONTLIGHTACTORS: + defaults->SetDontLightActors(ParseInt(sc) != 0); + break; default: sc.ScriptError("Unknown tag: %s\n", sc.String); } @@ -560,6 +570,9 @@ void ParseFlickerLight(FScanner &sc) case LIGHTTAG_ATTENUATE: defaults->SetAttenuate(ParseInt(sc) != 0); break; + case LIGHTTAG_DONTLIGHTACTORS: + defaults->SetDontLightActors(ParseInt(sc) != 0); + break; default: sc.ScriptError("Unknown tag: %s\n", sc.String); } @@ -643,6 +656,9 @@ void ParseFlickerLight2(FScanner &sc) case LIGHTTAG_ATTENUATE: defaults->SetAttenuate(ParseInt(sc) != 0); break; + case LIGHTTAG_DONTLIGHTACTORS: + defaults->SetDontLightActors(ParseInt(sc) != 0); + break; default: sc.ScriptError("Unknown tag: %s\n", sc.String); } @@ -723,6 +739,9 @@ static void ParseSectorLight(FScanner &sc) case LIGHTTAG_ATTENUATE: defaults->SetAttenuate(ParseInt(sc) != 0); break; + case LIGHTTAG_DONTLIGHTACTORS: + defaults->SetDontLightActors(ParseInt(sc) != 0); + break; default: sc.ScriptError("Unknown tag: %s\n", sc.String); } diff --git a/src/gl/scene/gl_spritelight.cpp b/src/gl/scene/gl_spritelight.cpp index 3283f0086..793a10c7c 100644 --- a/src/gl/scene/gl_spritelight.cpp +++ b/src/gl/scene/gl_spritelight.cpp @@ -62,7 +62,7 @@ void gl_SetDynSpriteLight(AActor *self, float x, float y, float z, subsector_t * while (node) { light=node->lightsource; - if (light->visibletoplayer && !(light->flags2&MF2_DORMANT) && (!(light->flags4&MF4_DONTLIGHTSELF) || light->target != self)) + if (light->visibletoplayer && !(light->flags2&MF2_DORMANT) && (!(light->flags4&MF4_DONTLIGHTSELF) || light->target != self) && !(light->flags4&MF4_DONTLIGHTACTORS)) { float dist; diff --git a/src/scripting/thingdef_data.cpp b/src/scripting/thingdef_data.cpp index 32363abdc..01a79dfc1 100644 --- a/src/scripting/thingdef_data.cpp +++ b/src/scripting/thingdef_data.cpp @@ -488,6 +488,7 @@ static FFlagDef DynLightFlagDefs[] = DEFINE_FLAG(MF4, DONTLIGHTSELF, ADynamicLight, flags4), DEFINE_FLAG(MF4, ATTENUATE, ADynamicLight, flags4), DEFINE_FLAG(MF4, NOSHADOWMAP, ADynamicLight, flags4), + DEFINE_FLAG(MF4, DONTLIGHTACTORS, ADynamicLight, flags4), }; static FFlagDef PowerSpeedFlagDefs[] = diff --git a/src/swrenderer/things/r_sprite.cpp b/src/swrenderer/things/r_sprite.cpp index 2e8a0f3aa..c98e9dcc6 100644 --- a/src/swrenderer/things/r_sprite.cpp +++ b/src/swrenderer/things/r_sprite.cpp @@ -237,7 +237,7 @@ namespace swrenderer while (node != nullptr) { ADynamicLight *light = node->lightsource; - if (light->visibletoplayer && !(light->flags2&MF2_DORMANT) && (!(light->flags4&MF4_DONTLIGHTSELF) || light->target != thing)) + if (light->visibletoplayer && !(light->flags2&MF2_DORMANT) && (!(light->flags4&MF4_DONTLIGHTSELF) || light->target != thing) && !(light->flags4&MF4_DONTLIGHTACTORS)) { float lx = (float)(light->X() - thing->X()); float ly = (float)(light->Y() - thing->Y());