diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 08d60f67b8..b41d6ded92 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -861,7 +861,6 @@ set (PCH_SOURCES playsim/mapthinkers/dsectoreffect.cpp playsim/a_pickups.cpp playsim/a_action.cpp - playsim/a_corona.cpp playsim/a_decals.cpp playsim/a_dynlight.cpp playsim/a_flashfader.cpp diff --git a/src/playsim/a_corona.cpp b/src/playsim/a_corona.cpp deleted file mode 100644 index 0e0cb4a980..0000000000 --- a/src/playsim/a_corona.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/* -** Light Coronas -** Copyright (c) 2022 Nash Muhandes, Magnus Norddahl -** -** This software is provided 'as-is', without any express or implied -** warranty. In no event will the authors be held liable for any damages -** arising from the use of this software. -** -** Permission is granted to anyone to use this software for any purpose, -** including commercial applications, and to alter it and redistribute it -** freely, subject to the following restrictions: -** -** 1. The origin of this software must not be misrepresented; you must not -** claim that you wrote the original software. If you use this software -** in a product, an acknowledgment in the product documentation would be -** appreciated but is not required. -** 2. Altered source versions must be plainly marked as such, and must not be -** misrepresented as being the original software. -** 3. This notice may not be removed or altered from any source distribution. -*/ - - -#include "actor.h" -#include "a_corona.h" -#include "a_dynlight.h" - -IMPLEMENT_CLASS(ACorona, false, false) - -void ACorona::Tick() -{ - Super::Tick(); -} diff --git a/src/playsim/a_corona.h b/src/playsim/a_corona.h deleted file mode 100644 index 2c66f0a204..0000000000 --- a/src/playsim/a_corona.h +++ /dev/null @@ -1,38 +0,0 @@ -/* -** Light Coronas -** Copyright (c) 2022 Nash Muhandes, Magnus Norddahl -** -** This software is provided 'as-is', without any express or implied -** warranty. In no event will the authors be held liable for any damages -** arising from the use of this software. -** -** Permission is granted to anyone to use this software for any purpose, -** including commercial applications, and to alter it and redistribute it -** freely, subject to the following restrictions: -** -** 1. The origin of this software must not be misrepresented; you must not -** claim that you wrote the original software. If you use this software -** in a product, an acknowledgment in the product documentation would be -** appreciated but is not required. -** 2. Altered source versions must be plainly marked as such, and must not be -** misrepresented as being the original software. -** 3. This notice may not be removed or altered from any source distribution. -*/ - -#pragma once - -#include "actor.h" - -EXTERN_CVAR(Bool, gl_coronas) - -class AActor; - -class ACorona : public AActor -{ - DECLARE_CLASS(ACorona, AActor) - -public: - void Tick(); - - float CoronaFade = 0.0f; -}; diff --git a/src/playsim/actor.h b/src/playsim/actor.h index 4819dc603e..1b535b3162 100644 --- a/src/playsim/actor.h +++ b/src/playsim/actor.h @@ -744,7 +744,7 @@ public: const double MinVel = EQUAL_EPSILON; // Map Object definition. -class AActor : public DThinker +class AActor final : public DThinker { DECLARE_CLASS_WITH_META (AActor, DThinker, PClassActor) HAS_OBJECT_POINTERS diff --git a/src/rendering/hwrenderer/scene/hw_drawinfo.cpp b/src/rendering/hwrenderer/scene/hw_drawinfo.cpp index eb81876038..12ab05e884 100644 --- a/src/rendering/hwrenderer/scene/hw_drawinfo.cpp +++ b/src/rendering/hwrenderer/scene/hw_drawinfo.cpp @@ -44,7 +44,6 @@ #include "hw_clipper.h" #include "hw_meshcache.h" #include "v_draw.h" -#include "a_corona.h" #include "texturemanager.h" #include "actorinlines.h" #include "g_levellocals.h" @@ -571,7 +570,7 @@ void HWDrawInfo::RenderPortal(HWPortal *p, FRenderState &state, bool usestencil) } -void HWDrawInfo::DrawCorona(FRenderState& state, ACorona* corona, double dist) +void HWDrawInfo::DrawCorona(FRenderState& state, AActor* corona, float coronaFade, double dist) { spriteframe_t* sprframe = &SpriteFrames[sprites[corona->sprite].spriteframes + (size_t)corona->SpawnState->GetFrame()]; FTextureID patch = sprframe->Texture[0]; @@ -591,7 +590,7 @@ void HWDrawInfo::DrawCorona(FRenderState& state, ACorona* corona, double dist) float screenX = halfViewportWidth + clipPos.X * invW * halfViewportWidth; float screenY = halfViewportHeight - clipPos.Y * invW * halfViewportHeight; - float alpha = corona->CoronaFade * float(corona->Alpha); + float alpha = coronaFade * float(corona->Alpha); // distance-based fade - looks better IMO float distNearFadeStart = float(corona->RenderRadius()) * 0.1f; @@ -661,8 +660,10 @@ void HWDrawInfo::DrawCoronas(FRenderState& state) float timeElapsed = (screen->FrameTime - LastFrameTime) / 1000.0f; LastFrameTime = screen->FrameTime; - for (ACorona* corona : Coronas) + for (auto& coronap : Coronas) { + auto corona = coronap.first; + auto& coronaFade = coronap.second; auto cPos = corona->Vec3Offset(0., 0., corona->Height * 0.5); DVector3 direction = Viewpoint.Pos - cPos; double dist = direction.Length(); @@ -677,15 +678,15 @@ void HWDrawInfo::DrawCoronas(FRenderState& state) FTraceResults results; if (!Trace(cPos, corona->Sector, direction, dist, MF_SOLID, ML_BLOCKEVERYTHING, corona, results, 0, CheckForViewpointActor, &Viewpoint)) { - corona->CoronaFade = std::min(corona->CoronaFade + timeElapsed * fadeSpeed, 1.0f); + coronaFade = std::min(coronaFade + timeElapsed * fadeSpeed, 1.0f); } else { - corona->CoronaFade = std::max(corona->CoronaFade - timeElapsed * fadeSpeed, 0.0f); + coronaFade = std::max(coronaFade - timeElapsed * fadeSpeed, 0.0f); } - if (corona->CoronaFade > 0.0f) - DrawCorona(state, corona, dist); + if (coronaFade > 0.0f) + DrawCorona(state, corona, coronaFade, dist); } state.SetTextureMode(TM_NORMAL); diff --git a/src/rendering/hwrenderer/scene/hw_drawinfo.h b/src/rendering/hwrenderer/scene/hw_drawinfo.h index 1c32412381..34b2b968e5 100644 --- a/src/rendering/hwrenderer/scene/hw_drawinfo.h +++ b/src/rendering/hwrenderer/scene/hw_drawinfo.h @@ -150,7 +150,7 @@ struct HWDrawInfo TArray Portals; TArray Decals[2]; // the second slot is for mirrors which get rendered in a separate pass. TArray hudsprites; // These may just be stored by value. - TArray Coronas; + TArray> Coronas; TArray VisibleSurfaces; uint64_t LastFrameTime = 0; @@ -288,7 +288,7 @@ struct HWDrawInfo void DrawDecals(FRenderState &state, TArray &decals); void DrawPlayerSprites(bool hudModelStep, FRenderState &state); void DrawCoronas(FRenderState& state); - void DrawCorona(FRenderState& state, ACorona* corona, double dist); + void DrawCorona(FRenderState& state, AActor* corona, float coronaFade, double dist); void ProcessLowerMinisegs(TArray &lowersegs, FRenderState& state); void AddSubsectorToPortal(FSectorPortalGroup *portal, subsector_t *sub); diff --git a/src/rendering/hwrenderer/scene/hw_sprites.cpp b/src/rendering/hwrenderer/scene/hw_sprites.cpp index 481249ddfb..98286ae358 100644 --- a/src/rendering/hwrenderer/scene/hw_sprites.cpp +++ b/src/rendering/hwrenderer/scene/hw_sprites.cpp @@ -33,7 +33,6 @@ #include "r_sky.h" #include "r_utility.h" #include "a_pickups.h" -#include "a_corona.h" #include "d_player.h" #include "g_levellocals.h" #include "events.h" @@ -763,7 +762,7 @@ void HWSprite::Process(HWDrawInfo *di, FRenderState& state, AActor* thing, secto if (thing->IsKindOf(NAME_Corona)) { - di->Coronas.Push(static_cast(thing)); + di->Coronas.Push(std::make_pair(thing, 0)); return; } diff --git a/wadsrc/static/zscript/actors/shared/corona.zs b/wadsrc/static/zscript/actors/shared/corona.zs index b0912b8feb..7310312f28 100644 --- a/wadsrc/static/zscript/actors/shared/corona.zs +++ b/wadsrc/static/zscript/actors/shared/corona.zs @@ -26,7 +26,7 @@ * *****************************************************************************/ -class Corona : Actor abstract native +class Corona : Actor abstract { Default {