SParticleMetrics is a lie

This commit is contained in:
Jack Andersen 2016-02-24 20:23:35 -10:00
parent c3a1fec4a5
commit 2e6d7c26e2
7 changed files with 25 additions and 36 deletions

View File

@ -45,6 +45,10 @@ void ViewManager::ParticleView::draw(boo::IGraphicsCommandQueue *gfxQ)
if (m_vm.m_partGen) if (m_vm.m_partGen)
{ {
m_vm.m_partGen->Update(1.0 / 60.0); 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::SetModelMatrix(Zeus::CTransform::Identity());
pshag::CGraphics::SetViewPointMatrix(Zeus::CTransform::Identity() + Zeus::CVector3f(0.f, -10.f, 0.f)); pshag::CGraphics::SetViewPointMatrix(Zeus::CTransform::Identity() + Zeus::CVector3f(0.f, -10.f, 0.f));
boo::SWindowRect windowRect = m_vm.m_mainWindow->getWindowFrame(); boo::SWindowRect windowRect = m_vm.m_mainWindow->getWindowFrame();

View File

@ -1,4 +1,5 @@
#include "CColorElement.hpp" #include "CColorElement.hpp"
#include "CElementGen.hpp"
#include "CParticleGlobals.hpp" #include "CParticleGlobals.hpp"
#include "CRandom16.hpp" #include "CRandom16.hpp"
#include <math.h> #include <math.h>
@ -152,7 +153,7 @@ bool CCEPulse::GetValue(int frame, Zeus::CColor& valOut) const
bool CCEParticleColor::GetValue(int /*frame*/, Zeus::CColor& colorOut) const bool CCEParticleColor::GetValue(int /*frame*/, Zeus::CColor& colorOut) const
{ {
colorOut = CParticleGlobals::g_particleMetrics->x34_pcol; colorOut = CElementGen::g_currentParticle->x34_color;
return false; return false;
} }

View File

@ -22,6 +22,7 @@ int CElementGen::g_ParticleSystemAliveCount;
s32 CElementGen::g_FreeIndex; s32 CElementGen::g_FreeIndex;
bool CElementGen::g_StaticListInitialized = false; bool CElementGen::g_StaticListInitialized = false;
bool CElementGen::g_MoveRedToAlphaBuffer = false; bool CElementGen::g_MoveRedToAlphaBuffer = false;
CElementGen::CParticle* CElementGen::g_currentParticle = nullptr;
static rstl::reserved_vector<CElementGen::CParticle, MAX_GLOBAL_PARTICLES> g_StaticParticleList; static rstl::reserved_vector<CElementGen::CParticle, MAX_GLOBAL_PARTICLES> g_StaticParticleList;
static rstl::reserved_vector<u16, MAX_GLOBAL_PARTICLES> g_StaticFreeList; static rstl::reserved_vector<u16, MAX_GLOBAL_PARTICLES> g_StaticFreeList;
@ -580,6 +581,8 @@ void CElementGen::UpdateExistingParticles()
p != x2c_particleLists.end();) p != x2c_particleLists.end();)
{ {
CElementGen::CParticle& particle = g_StaticParticleList[p->x0_partIdx]; CElementGen::CParticle& particle = g_StaticParticleList[p->x0_partIdx];
g_currentParticle = &particle;
if (particle.x0_endFrame < x50_curFrame) if (particle.x0_endFrame < x50_curFrame)
{ {
g_StaticFreeList[++g_FreeIndex] = p->x0_partIdx; g_StaticFreeList[++g_FreeIndex] = p->x0_partIdx;
@ -1287,6 +1290,8 @@ void CElementGen::RenderModels()
for (CParticleListItem& item : x2c_particleLists) for (CParticleListItem& item : x2c_particleLists)
{ {
CParticle& particle = g_StaticParticleList[item.x0_partIdx]; CParticle& particle = g_StaticParticleList[item.x0_partIdx];
g_currentParticle = &particle;
if (particle.x0_endFrame == -1) if (particle.x0_endFrame == -1)
{ {
++matrixIt; ++matrixIt;
@ -1461,6 +1466,8 @@ void CElementGen::RenderLines()
for (CParticleListItem& item : x2c_particleLists) for (CParticleListItem& item : x2c_particleLists)
{ {
CParticle& particle = g_StaticParticleList[item.x0_partIdx]; CParticle& particle = g_StaticParticleList[item.x0_partIdx];
g_currentParticle = &particle;
int partFrame = x50_curFrame - particle.x28_startFrame; int partFrame = x50_curFrame - particle.x28_startFrame;
if (!constTexr) if (!constTexr)
@ -1611,6 +1618,8 @@ void CElementGen::RenderParticles()
for (CParticleListItem& item : x2c_particleLists) for (CParticleListItem& item : x2c_particleLists)
{ {
CParticle& particle = g_StaticParticleList[item.x0_partIdx]; CParticle& particle = g_StaticParticleList[item.x0_partIdx];
g_currentParticle = &particle;
int partFrame = x50_curFrame - particle.x28_startFrame - 1; int partFrame = x50_curFrame - particle.x28_startFrame - 1;
Zeus::CVector3f viewPoint; Zeus::CVector3f viewPoint;
if (desc->x44_28_SORT) if (desc->x44_28_SORT)
@ -1741,6 +1750,8 @@ void CElementGen::RenderParticles()
for (CParticleListItem& item : x2c_particleLists) for (CParticleListItem& item : x2c_particleLists)
{ {
CParticle& particle = g_StaticParticleList[item.x0_partIdx]; CParticle& particle = g_StaticParticleList[item.x0_partIdx];
g_currentParticle = &particle;
int partFrame = x50_curFrame - particle.x28_startFrame - 1; int partFrame = x50_curFrame - particle.x28_startFrame - 1;
if (!constTexr) if (!constTexr)
@ -1912,23 +1923,6 @@ void CElementGen::RenderParticlesIndirectTexture()
bool constIndUVs = tind->HasConstantUV(); bool constIndUVs = tind->HasConstantUV();
tind->GetValueUV(partFrame, uvsInd); 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) if (desc->x44_28_SORT)
{ {
for (CParticleListItem& item : x2c_particleLists) for (CParticleListItem& item : x2c_particleLists)
@ -1950,6 +1944,8 @@ void CElementGen::RenderParticlesIndirectTexture()
for (CParticleListItem& item : x2c_particleLists) for (CParticleListItem& item : x2c_particleLists)
{ {
CParticle& particle = g_StaticParticleList[item.x0_partIdx]; CParticle& particle = g_StaticParticleList[item.x0_partIdx];
g_currentParticle = &particle;
int partFrame = x50_curFrame - particle.x28_startFrame; int partFrame = x50_curFrame - particle.x28_startFrame;
Zeus::CVector3f viewPoint; Zeus::CVector3f viewPoint;
if (desc->x44_28_SORT) if (desc->x44_28_SORT)

View File

@ -60,9 +60,8 @@ public:
--g_ParticleAliveCount; --g_ParticleAliveCount;
} }
}; };
class CParticle struct CParticle
{ {
friend class CElementGen;
int x0_endFrame = 0; int x0_endFrame = 0;
Zeus::CVector3f x4_pos; Zeus::CVector3f x4_pos;
Zeus::CVector3f x10_prevPos; Zeus::CVector3f x10_prevPos;
@ -72,6 +71,7 @@ public:
float x30_lineWidthOrRota = 0.f; float x30_lineWidthOrRota = 0.f;
Zeus::CColor x34_color = {0.f, 0.f, 0.f, 1.f}; Zeus::CColor x34_color = {0.f, 0.f, 0.f, 1.f};
}; };
static CParticle* g_currentParticle;
private: private:
friend class CElementGenShaders; friend class CElementGenShaders;
TLockedToken<CGenDescription> x1c_genDesc; TLockedToken<CGenDescription> x1c_genDesc;

View File

@ -14,6 +14,5 @@ float CParticleGlobals::g_ParticleLifetimePercentageReal = 0.0;
float CParticleGlobals::g_ParticleLifetimePercentageRemainder = 0.0; float CParticleGlobals::g_ParticleLifetimePercentageRemainder = 0.0;
float* CParticleGlobals::g_papValues = nullptr; float* CParticleGlobals::g_papValues = nullptr;
CParticleGlobals::SParticleMetrics* CParticleGlobals::g_particleMetrics = nullptr;
CParticleGlobals::SParticleSystem* CParticleGlobals::g_currentParticleSystem = nullptr; CParticleGlobals::SParticleSystem* CParticleGlobals::g_currentParticleSystem = nullptr;
} }

View File

@ -40,23 +40,12 @@ public:
static float* g_papValues; 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 struct SParticleSystem
{ {
FourCC x0_type; FourCC x0_type;
CParticleGen* x4_system; CParticleGen* x4_system;
}; };
static SParticleMetrics* g_particleMetrics;
static SParticleSystem* g_currentParticleSystem; static SParticleSystem* g_currentParticleSystem;
}; };

View File

@ -1,7 +1,7 @@
#include "CVectorElement.hpp" #include "CVectorElement.hpp"
#include "CParticleGlobals.hpp" #include "CParticleGlobals.hpp"
#include "CRandom16.hpp" #include "CRandom16.hpp"
#include "CParticleGen.hpp" #include "CElementGen.hpp"
#include <math.h> #include <math.h>
namespace pshag namespace pshag
@ -264,19 +264,19 @@ bool CVEPulse::GetValue(int frame, Zeus::CVector3f& valOut) const
bool CVEParticleVelocity::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; return false;
} }
bool CVEPLCO::GetValue(int /*frame*/, Zeus::CVector3f& valOut) const bool CVEPLCO::GetValue(int /*frame*/, Zeus::CVector3f& valOut) const
{ {
valOut = CParticleGlobals::g_particleMetrics->x10_plco; valOut = CElementGen::g_currentParticle->x10_prevPos;
return false; return false;
} }
bool CVEPLOC::GetValue(int /*frame*/, Zeus::CVector3f& valOut) const bool CVEPLOC::GetValue(int /*frame*/, Zeus::CVector3f& valOut) const
{ {
valOut = CParticleGlobals::g_particleMetrics->x0_ploc; valOut = CElementGen::g_currentParticle->x4_pos;
return false; return false;
} }