diff --git a/Editor/ViewManager.cpp b/Editor/ViewManager.cpp index 722a7dfda..d27b618bd 100644 --- a/Editor/ViewManager.cpp +++ b/Editor/ViewManager.cpp @@ -45,6 +45,10 @@ void ViewManager::ParticleView::draw(boo::IGraphicsCommandQueue *gfxQ) if (m_vm.m_partGen) { m_vm.m_partGen->Update(1.0 / 60.0); + + if (m_vm.m_partGen->IsSystemDeletable()) + m_vm.m_partGen->Reset(); + pshag::CGraphics::SetModelMatrix(Zeus::CTransform::Identity()); pshag::CGraphics::SetViewPointMatrix(Zeus::CTransform::Identity() + Zeus::CVector3f(0.f, -10.f, 0.f)); boo::SWindowRect windowRect = m_vm.m_mainWindow->getWindowFrame(); diff --git a/Runtime/Particle/CColorElement.cpp b/Runtime/Particle/CColorElement.cpp index 2953bbdd0..433fb14a9 100644 --- a/Runtime/Particle/CColorElement.cpp +++ b/Runtime/Particle/CColorElement.cpp @@ -1,4 +1,5 @@ #include "CColorElement.hpp" +#include "CElementGen.hpp" #include "CParticleGlobals.hpp" #include "CRandom16.hpp" #include @@ -152,7 +153,7 @@ bool CCEPulse::GetValue(int frame, Zeus::CColor& valOut) const bool CCEParticleColor::GetValue(int /*frame*/, Zeus::CColor& colorOut) const { - colorOut = CParticleGlobals::g_particleMetrics->x34_pcol; + colorOut = CElementGen::g_currentParticle->x34_color; return false; } diff --git a/Runtime/Particle/CElementGen.cpp b/Runtime/Particle/CElementGen.cpp index de30d9564..1c18e8fe0 100644 --- a/Runtime/Particle/CElementGen.cpp +++ b/Runtime/Particle/CElementGen.cpp @@ -22,6 +22,7 @@ int CElementGen::g_ParticleSystemAliveCount; s32 CElementGen::g_FreeIndex; bool CElementGen::g_StaticListInitialized = false; bool CElementGen::g_MoveRedToAlphaBuffer = false; +CElementGen::CParticle* CElementGen::g_currentParticle = nullptr; static rstl::reserved_vector g_StaticParticleList; static rstl::reserved_vector g_StaticFreeList; @@ -580,6 +581,8 @@ void CElementGen::UpdateExistingParticles() p != x2c_particleLists.end();) { CElementGen::CParticle& particle = g_StaticParticleList[p->x0_partIdx]; + g_currentParticle = &particle; + if (particle.x0_endFrame < x50_curFrame) { g_StaticFreeList[++g_FreeIndex] = p->x0_partIdx; @@ -1287,6 +1290,8 @@ void CElementGen::RenderModels() for (CParticleListItem& item : x2c_particleLists) { CParticle& particle = g_StaticParticleList[item.x0_partIdx]; + g_currentParticle = &particle; + if (particle.x0_endFrame == -1) { ++matrixIt; @@ -1461,6 +1466,8 @@ void CElementGen::RenderLines() for (CParticleListItem& item : x2c_particleLists) { CParticle& particle = g_StaticParticleList[item.x0_partIdx]; + g_currentParticle = &particle; + int partFrame = x50_curFrame - particle.x28_startFrame; if (!constTexr) @@ -1611,6 +1618,8 @@ void CElementGen::RenderParticles() for (CParticleListItem& item : x2c_particleLists) { CParticle& particle = g_StaticParticleList[item.x0_partIdx]; + g_currentParticle = &particle; + int partFrame = x50_curFrame - particle.x28_startFrame - 1; Zeus::CVector3f viewPoint; if (desc->x44_28_SORT) @@ -1741,6 +1750,8 @@ void CElementGen::RenderParticles() for (CParticleListItem& item : x2c_particleLists) { CParticle& particle = g_StaticParticleList[item.x0_partIdx]; + g_currentParticle = &particle; + int partFrame = x50_curFrame - particle.x28_startFrame - 1; if (!constTexr) @@ -1912,23 +1923,6 @@ void CElementGen::RenderParticlesIndirectTexture() bool constIndUVs = tind->HasConstantUV(); tind->GetValueUV(partFrame, uvsInd); - if (!desc->x45_30_CIND) - { - /* 1. TEXC - * 2. Indirect TEXC * RASC + PREVC - */ - } - else - { - /* 1. TEXC * RASC - * 2. Indirect TEXC * PREVC - */ - } - - /* 1. TEXA - * 2. RASA * PREVA - */ - if (desc->x44_28_SORT) { for (CParticleListItem& item : x2c_particleLists) @@ -1950,6 +1944,8 @@ void CElementGen::RenderParticlesIndirectTexture() for (CParticleListItem& item : x2c_particleLists) { CParticle& particle = g_StaticParticleList[item.x0_partIdx]; + g_currentParticle = &particle; + int partFrame = x50_curFrame - particle.x28_startFrame; Zeus::CVector3f viewPoint; if (desc->x44_28_SORT) diff --git a/Runtime/Particle/CElementGen.hpp b/Runtime/Particle/CElementGen.hpp index 4f451429d..a61b6edec 100644 --- a/Runtime/Particle/CElementGen.hpp +++ b/Runtime/Particle/CElementGen.hpp @@ -60,9 +60,8 @@ public: --g_ParticleAliveCount; } }; - class CParticle + struct CParticle { - friend class CElementGen; int x0_endFrame = 0; Zeus::CVector3f x4_pos; Zeus::CVector3f x10_prevPos; @@ -72,6 +71,7 @@ public: float x30_lineWidthOrRota = 0.f; Zeus::CColor x34_color = {0.f, 0.f, 0.f, 1.f}; }; + static CParticle* g_currentParticle; private: friend class CElementGenShaders; TLockedToken x1c_genDesc; diff --git a/Runtime/Particle/CParticleGlobals.cpp b/Runtime/Particle/CParticleGlobals.cpp index 91bb91275..f15e24408 100644 --- a/Runtime/Particle/CParticleGlobals.cpp +++ b/Runtime/Particle/CParticleGlobals.cpp @@ -14,6 +14,5 @@ float CParticleGlobals::g_ParticleLifetimePercentageReal = 0.0; float CParticleGlobals::g_ParticleLifetimePercentageRemainder = 0.0; float* CParticleGlobals::g_papValues = nullptr; -CParticleGlobals::SParticleMetrics* CParticleGlobals::g_particleMetrics = nullptr; CParticleGlobals::SParticleSystem* CParticleGlobals::g_currentParticleSystem = nullptr; } diff --git a/Runtime/Particle/CParticleGlobals.hpp b/Runtime/Particle/CParticleGlobals.hpp index 9c4d8bdf6..98feb7b76 100644 --- a/Runtime/Particle/CParticleGlobals.hpp +++ b/Runtime/Particle/CParticleGlobals.hpp @@ -40,23 +40,12 @@ public: static float* g_papValues; - struct SParticleMetrics - { - Zeus::CVector3f x0_ploc; - Zeus::CVector3f x10_plco; - Zeus::CVector3f x1c_pvel; - float x2c_psll; - float x30_prlw; - Zeus::CColor x34_pcol; - }; - struct SParticleSystem { FourCC x0_type; CParticleGen* x4_system; }; - static SParticleMetrics* g_particleMetrics; static SParticleSystem* g_currentParticleSystem; }; diff --git a/Runtime/Particle/CVectorElement.cpp b/Runtime/Particle/CVectorElement.cpp index 6047eb0ac..f369a20ff 100644 --- a/Runtime/Particle/CVectorElement.cpp +++ b/Runtime/Particle/CVectorElement.cpp @@ -1,7 +1,7 @@ #include "CVectorElement.hpp" #include "CParticleGlobals.hpp" #include "CRandom16.hpp" -#include "CParticleGen.hpp" +#include "CElementGen.hpp" #include namespace pshag @@ -264,19 +264,19 @@ bool CVEPulse::GetValue(int frame, Zeus::CVector3f& valOut) const bool CVEParticleVelocity::GetValue(int /*frame*/, Zeus::CVector3f& valOut) const { - valOut = CParticleGlobals::g_particleMetrics->x1c_pvel; + valOut = CElementGen::g_currentParticle->x1c_vel; return false; } bool CVEPLCO::GetValue(int /*frame*/, Zeus::CVector3f& valOut) const { - valOut = CParticleGlobals::g_particleMetrics->x10_plco; + valOut = CElementGen::g_currentParticle->x10_prevPos; return false; } bool CVEPLOC::GetValue(int /*frame*/, Zeus::CVector3f& valOut) const { - valOut = CParticleGlobals::g_particleMetrics->x0_ploc; + valOut = CElementGen::g_currentParticle->x4_pos; return false; }