From d3fe5a19460f2a6c6014572cb3bf7d58105e2d2f Mon Sep 17 00:00:00 2001 From: Boondorl Date: Tue, 31 Dec 2024 23:31:27 -0500 Subject: [PATCH] Fixed corona appearing in wrong world position --- src/rendering/hwrenderer/scene/hw_drawinfo.cpp | 9 +++++---- src/rendering/hwrenderer/scene/hw_drawinfo.h | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/rendering/hwrenderer/scene/hw_drawinfo.cpp b/src/rendering/hwrenderer/scene/hw_drawinfo.cpp index 0a318b169..2991bdb76 100644 --- a/src/rendering/hwrenderer/scene/hw_drawinfo.cpp +++ b/src/rendering/hwrenderer/scene/hw_drawinfo.cpp @@ -832,7 +832,7 @@ void HWDrawInfo::RenderPortal(HWPortal *p, FRenderState &state, bool usestencil) } -void HWDrawInfo::DrawCorona(FRenderState& state, AActor* corona, float coronaFade, double dist) +void HWDrawInfo::DrawCorona(FRenderState& state, AActor* corona, float coronaFade, const DVector3& pos, double dist) { spriteframe_t* sprframe = &SpriteFrames[sprites[corona->sprite].spriteframes + (size_t)corona->SpawnState->GetFrame()]; FTextureID patch = sprframe->Texture[0]; @@ -841,7 +841,7 @@ void HWDrawInfo::DrawCorona(FRenderState& state, AActor* corona, float coronaFad if (!tex || !tex->isValid()) return; // Project the corona sprite center - FVector4 worldPos((float)corona->X(), (float)corona->Z(), (float)corona->Y(), 1.0f); + FVector4 worldPos((float)pos.X, (float)pos.Z, (float)pos.Y, 1.0f); FVector4 viewPos, clipPos; VPUniforms.mViewMatrix.multMatrixPoint(&worldPos[0], &viewPos[0]); VPUniforms.mProjectionMatrix.multMatrixPoint(&viewPos[0], &clipPos[0]); @@ -1045,7 +1045,8 @@ void HWDrawInfo::DrawCoronas(FRenderState& state) for (AActor* corona : Coronas) { auto& coronaFade = corona->specialf1; - DVector3 direction = Viewpoint.Pos - corona->PosRelative(Viewpoint.sector); + DVector3 realPos = corona->PosRelative(Viewpoint.sector); + DVector3 direction = Viewpoint.Pos - realPos; double dist = direction.Length(); // skip coronas that are too far @@ -1066,7 +1067,7 @@ void HWDrawInfo::DrawCoronas(FRenderState& state) } if (coronaFade > 0.0f) - DrawCorona(state, corona, (float)coronaFade, dist); + DrawCorona(state, corona, (float)coronaFade, realPos, dist); } state.AlphaFunc(Alpha_Greater, 0.f); diff --git a/src/rendering/hwrenderer/scene/hw_drawinfo.h b/src/rendering/hwrenderer/scene/hw_drawinfo.h index 964a49cb9..04ab8640a 100644 --- a/src/rendering/hwrenderer/scene/hw_drawinfo.h +++ b/src/rendering/hwrenderer/scene/hw_drawinfo.h @@ -328,7 +328,7 @@ public: void DrawDecals(FRenderState &state, TArray &decals); void DrawPlayerSprites(bool hudModelStep, FRenderState &state); void DrawCoronas(FRenderState& state); - void DrawCorona(FRenderState& state, AActor* corona, float coronaFade, double dist); + void DrawCorona(FRenderState& state, AActor* corona, float coronaFade, const DVector3& pos, double dist); void SetDitherTransFlags(AActor* actor);