- refactored Corona actor so that class AActor can be final again.

This commit is contained in:
Christoph Oelckers 2023-09-17 21:54:31 +02:00
parent b708356f90
commit 26b162b7d1
8 changed files with 14 additions and 85 deletions

View file

@ -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

View file

@ -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();
}

View file

@ -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;
};

View file

@ -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

View file

@ -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);

View file

@ -150,7 +150,7 @@ struct HWDrawInfo
TArray<HWPortal *> Portals;
TArray<HWDecal *> Decals[2]; // the second slot is for mirrors which get rendered in a separate pass.
TArray<HUDSprite> hudsprites; // These may just be stored by value.
TArray<ACorona*> Coronas;
TArray<std::pair<AActor*, float>> Coronas;
TArray<LevelMeshSurface*> VisibleSurfaces;
uint64_t LastFrameTime = 0;
@ -288,7 +288,7 @@ struct HWDrawInfo
void DrawDecals(FRenderState &state, TArray<HWDecal *> &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<seg_t *> &lowersegs, FRenderState& state);
void AddSubsectorToPortal(FSectorPortalGroup *portal, subsector_t *sub);

View file

@ -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<ACorona*>(thing));
di->Coronas.Push(std::make_pair(thing, 0));
return;
}

View file

@ -26,7 +26,7 @@
*
*****************************************************************************/
class Corona : Actor abstract native
class Corona : Actor abstract
{
Default
{