From 2ee2bbc0c14ab204b94d733b1d94305bbf47729b Mon Sep 17 00:00:00 2001 From: Luke Street Date: Mon, 20 Apr 2020 03:20:22 -0400 Subject: [PATCH] COmegaPirate: Fix CFlash rendering --- Runtime/MP1/World/COmegaPirate.cpp | 29 ++++++++++++++--------------- Runtime/MP1/World/COmegaPirate.hpp | 6 +++--- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/Runtime/MP1/World/COmegaPirate.cpp b/Runtime/MP1/World/COmegaPirate.cpp index 68ce227f4..16d674d25 100644 --- a/Runtime/MP1/World/COmegaPirate.cpp +++ b/Runtime/MP1/World/COmegaPirate.cpp @@ -43,7 +43,7 @@ COmegaPirate::CFlash::CFlash(TUniqueId uid, const CEntityInfo& info, const zeus: : CActor(uid, true, "Omega Pirate Flash", info, zeus::CTransform::Translate(pos), CModelData::CModelDataNull(), {}, CActorParameters::None(), kInvalidUniqueId) , xf4_delay(delay) -, m_thermalSpotBlend(EFilterType::Blend, thermalSpot) +, m_thermalSpotAdd(EFilterType::Add, thermalSpot) , m_thermalSpotSubtract(EFilterType::Subtract, thermalSpot) {} void COmegaPirate::CFlash::Accept(IVisitor& visitor) { visitor.Visit(this); } @@ -55,8 +55,8 @@ void COmegaPirate::CFlash::Think(float dt, CStateManager& mgr) { return; } - xf8_ += dt; - float intensity = xf8_; + xf8_time += dt; + float intensity = xf8_time; if (intensity <= 0.75f) { intensity /= 0.75f; } else { @@ -69,8 +69,8 @@ void COmegaPirate::CFlash::Think(float dt, CStateManager& mgr) { if (dot >= 0.f) { dVar4 = dot * dot; } - xfc_ = dVar4 * intensity; - if (xf8_ > 1.f) { + xfc_size = dVar4 * intensity; + if (xf8_time > 1.f) { mgr.FreeScriptObject(GetUniqueId()); } } @@ -90,33 +90,32 @@ void COmegaPirate::CFlash::Render(CStateManager& mgr) { return; } - float alphaMul = 35.f; + float sizeMul = 35.f; CTexturedQuadFilter* filter = nullptr; if (visor == CPlayerState::EPlayerVisor::XRay) { // CGraphics::SetBlendMode(ERglBlendMode::Subtract, ERglBlendFactor::One, ERglBlendFactor::Zero, // ERglLogicOp::Clear); filter = &m_thermalSpotSubtract; - alphaMul = 60.f; + sizeMul = 60.f; } else { // CGraphics::SetBlendMode(ERglBlendMode::Blend, ERglBlendFactor::SrcAlpha, ERglBlendFactor::One, // ERglLogicOp::Clear); - filter = &m_thermalSpotBlend; + filter = &m_thermalSpotAdd; } - CGraphics::SetModelMatrix(zeus::CTransform()); - zeus::CColor useColor{1.f, std::max(0.f, (xfc_ * alphaMul) / 255.f)}; - - const auto rightVec = CGraphics::g_GXModelView.rightVector(); - const auto upVec = CGraphics::g_GXModelView.upVector(); + float size = xfc_size * sizeMul; + const auto rightVec = size * CGraphics::g_ViewMatrix.rightVector(); + const auto upVec = size * CGraphics::g_ViewMatrix.upVector(); const auto rvS = GetTranslation() - rightVec; const auto rvP = GetTranslation() + rightVec; + CGraphics::SetModelMatrix(zeus::CTransform()); const std::array verts{{ {rvS + upVec, {0.f, 0.f}}, + {rvP + upVec, {0.f, 1.f}}, {rvS - upVec, {1.f, 0.f}}, {rvP - upVec, {1.f, 1.f}}, - {rvP + upVec, {0.f, 1.f}}, }}; - filter->drawVerts(useColor, verts); + filter->drawVerts(zeus::CColor{1.f, std::min(1.f, size)}, verts); } COmegaPirate::COmegaPirate(TUniqueId uid, std::string_view name, const CEntityInfo& info, const zeus::CTransform& xf, diff --git a/Runtime/MP1/World/COmegaPirate.hpp b/Runtime/MP1/World/COmegaPirate.hpp index 8246c4d4f..ca0306c09 100644 --- a/Runtime/MP1/World/COmegaPirate.hpp +++ b/Runtime/MP1/World/COmegaPirate.hpp @@ -10,10 +10,10 @@ private: // TToken xe8_thermalSpotToken; // CTexture* xf0_thermalSpot = nullptr; float xf4_delay; - float xf8_ = 0.f; - float xfc_ = 0.f; + float xf8_time = 0.f; + float xfc_size = 0.f; - CTexturedQuadFilter m_thermalSpotBlend; + CTexturedQuadFilter m_thermalSpotAdd; CTexturedQuadFilter m_thermalSpotSubtract; public: