Skip to content

Commit

Permalink
Fixed corona appearing in wrong world position
Browse files Browse the repository at this point in the history
  • Loading branch information
Boondorl authored and nashmuhandes committed Jan 1, 2025
1 parent 4c5375c commit d3fe5a1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/rendering/hwrenderer/scene/hw_drawinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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]);
Expand Down Expand Up @@ -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
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/rendering/hwrenderer/scene/hw_drawinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ struct HWDrawInfo
void DrawDecals(FRenderState &state, TArray<HWDecal *> &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);

Expand Down

0 comments on commit d3fe5a1

Please sign in to comment.