From 26863bfd94a732b4423916dcb91ee2e0578397c6 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 7 Jul 2019 09:50:02 +0200 Subject: [PATCH] - tested and fixed the attachable lights. # Conflicts: # src/g_shared/a_dynlight.cpp --- src/g_shared/a_dynlight.cpp | 10 ++++++++-- wadsrc/static/zscript/actors/actor.zs | 6 +++--- wadsrc/static/zscript/actors/shared/dynlights.zs | 12 ++++++++++++ 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/g_shared/a_dynlight.cpp b/src/g_shared/a_dynlight.cpp index a0f5d2d78..dcf44d04d 100644 --- a/src/g_shared/a_dynlight.cpp +++ b/src/g_shared/a_dynlight.cpp @@ -791,6 +791,12 @@ void AActor::SetDynamicLights() unsigned int count = 0; if (state == NULL) return; + + for (const auto def : UserLights) + { + AttachLight(count++, def); + } + if (LightAssociations.Size() > 0) { unsigned int i; @@ -871,7 +877,7 @@ int AttachLightDef(AActor *self, int _lightid, int _lightname) // Todo: Optimize. This may be too slow. auto lightdef = LightDefaults.FindEx([=](const auto &a) { - return a->GetName() == lightid; + return a->GetName() == lightname; }); if (lightdef < LightDefaults.Size()) { @@ -907,7 +913,7 @@ int AttachLightDirect(AActor *self, int _lightid, int type, int color, int radiu userlight->SetArg(LIGHT_INTENSITY, radius1); userlight->SetArg(LIGHT_SECONDARY_INTENSITY, radius2); userlight->SetFlags(LightFlags::FromInt(flags)); - float of[] = { float(ofs_x), float(ofs_y), float(ofs_z)}; + float of[] = { float(ofs_x), float(ofs_z), float(ofs_y)}; userlight->SetOffset(of); userlight->SetParameter(type == PulseLight? param*TICRATE : param*360.); userlight->SetSpotInnerAngle(spoti); diff --git a/wadsrc/static/zscript/actors/actor.zs b/wadsrc/static/zscript/actors/actor.zs index 43c4ce4ac..379347af9 100644 --- a/wadsrc/static/zscript/actors/actor.zs +++ b/wadsrc/static/zscript/actors/actor.zs @@ -1158,9 +1158,9 @@ class Actor : Thinker native action native void A_OverlayAlpha(int layer, double alph); action native void A_OverlayRenderStyle(int layer, int style); - action native bool A_AttachLightDef(Name lightid, Name lightdef); - action native bool A_AttachLight(Name lightid, int type, Color lightcolor, int radius1, int radius2, int flags, Vector3 ofs, double param, double spoti, double spoto, double spotp); - action mative bool A_RemoveLight(Name lightid); + native bool A_AttachLightDef(Name lightid, Name lightdef); + native bool A_AttachLight(Name lightid, int type, Color lightcolor, int radius1, int radius2, int flags = 0, Vector3 ofs = (0,0,0), double param = 0, double spoti = 10, double spoto = 25, double spotp = 0); + native bool A_RemoveLight(Name lightid); int ACS_NamedExecute(name script, int mapnum=0, int arg1=0, int arg2=0, int arg3=0) { diff --git a/wadsrc/static/zscript/actors/shared/dynlights.zs b/wadsrc/static/zscript/actors/shared/dynlights.zs index bc059255b..388e8f244 100644 --- a/wadsrc/static/zscript/actors/shared/dynlights.zs +++ b/wadsrc/static/zscript/actors/shared/dynlights.zs @@ -26,6 +26,18 @@ class DynamicLight : Actor LIGHT_SCALE = 3, }; + // These are for use in A_AttachLight calls. + enum LightFlag + { + LF_SUBTRACTIVE = 1, + LF_ADDITIVE = 2, + LF_DONTLIGHTSELF = 4, + LF_ATTENUATE = 8, + LF_NOSHADOWMAP = 16, + LF_DONTLIGHTACTORS = 32, + LF_SPOT = 64 + }; + enum ELightType { PointLight,