From 66339e3bfafbcf9afaa14b284d7ab22a4312c3be Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Thu, 11 Feb 2016 11:18:14 -0800 Subject: [PATCH 1/2] GetSystemCount --- Runtime/CDvdFile.hpp | 6 ++- Runtime/Particle/CElementGen.cpp | 77 ++++++++++++++++++++++---------- Runtime/Particle/CElementGen.hpp | 7 ++- 3 files changed, 63 insertions(+), 27 deletions(-) diff --git a/Runtime/CDvdFile.hpp b/Runtime/CDvdFile.hpp index 999b677ab..9a222bf2f 100644 --- a/Runtime/CDvdFile.hpp +++ b/Runtime/CDvdFile.hpp @@ -6,7 +6,10 @@ namespace Retro { -const char* DecodeARAMFile(const char* name); +static const char* DecodeARAMFile(const char* name) +{ + return (strncmp(name, "aram:", 5) == 0 ? name + 5 : name); +} enum class ESeekOrigin { @@ -44,7 +47,6 @@ public: static void ARAMARAMXferCallback(u32) {} static void DVDARAMXferCallback(s32, DVDFileInfo*) {} }; - } #endif // __RETRO_CDVDFILE_HPP__ diff --git a/Runtime/Particle/CElementGen.cpp b/Runtime/Particle/CElementGen.cpp index fe3edaed1..6f4d20da5 100644 --- a/Runtime/Particle/CElementGen.cpp +++ b/Runtime/Particle/CElementGen.cpp @@ -369,10 +369,10 @@ void CElementGen::UpdateExistingParticles() if (x224_30_VMD1) { Zeus::CVector3f xfVel = x1a8 * particle.x1c_vel; - Zeus::CVector3f xfPos = x1a8 * (particle.x4_pos - x7c); + Zeus::CVector3f xfPos = x1a8 * (particle.x4_pos - x7c_translation); err = vel1->GetValue(particleFrame, xfVel, xfPos); - particle.x1c_vel = x178 * xfVel; - particle.x4_pos = x178 * xfPos + x7c; + particle.x1c_vel = x178_orientation * xfVel; + particle.x4_pos = x178_orientation * xfPos + x7c_translation; } else { @@ -386,10 +386,10 @@ void CElementGen::UpdateExistingParticles() if (x224_31_VMD2) { Zeus::CVector3f xfVel = x1a8 * particle.x1c_vel; - Zeus::CVector3f xfPos = x1a8 * (particle.x4_pos - x7c); + Zeus::CVector3f xfPos = x1a8 * (particle.x4_pos - x7c_translation); err |= vel2->GetValue(particleFrame, xfVel, xfPos); - particle.x1c_vel = x178 * xfVel; - particle.x4_pos = x178 * xfPos + x7c; + particle.x1c_vel = x178_orientation * xfVel; + particle.x4_pos = x178_orientation * xfPos + x7c_translation; } else { @@ -403,10 +403,10 @@ void CElementGen::UpdateExistingParticles() if (x225_24_VMD3) { Zeus::CVector3f xfVel = x1a8 * particle.x1c_vel; - Zeus::CVector3f xfPos = x1a8 * (particle.x4_pos - x7c); + Zeus::CVector3f xfPos = x1a8 * (particle.x4_pos - x7c_translation); err |= vel3->GetValue(particleFrame, xfVel, xfPos); - particle.x1c_vel = x178 * xfVel; - particle.x4_pos = x178 * xfPos + x7c; + particle.x1c_vel = x178_orientation * xfVel; + particle.x4_pos = x178_orientation * xfPos + x7c_translation; } else { @@ -420,10 +420,10 @@ void CElementGen::UpdateExistingParticles() if (x225_25_VMD4) { Zeus::CVector3f xfVel = x1a8 * particle.x1c_vel; - Zeus::CVector3f xfPos = x1a8 * (particle.x4_pos - x7c); + Zeus::CVector3f xfPos = x1a8 * (particle.x4_pos - x7c_translation); err |= vel4->GetValue(particleFrame, xfVel, xfPos); - particle.x1c_vel = x178 * xfVel; - particle.x4_pos = x178 * xfPos + x7c; + particle.x1c_vel = x178_orientation * xfVel; + particle.x4_pos = x178_orientation * xfPos + x7c_translation; } else { @@ -483,7 +483,7 @@ void CElementGen::CreateNewParticles(int count) x2c_particleLists.push_back(staticIdx); ++x208_activeParticleCount; if (x28_orientType == EModelOrientationType::One) - x3c_parentMatrices[x2c_particleLists.size()-1] = x178.buildMatrix3f(); + x3c_parentMatrices[x2c_particleLists.size()-1] = x178_orientation.buildMatrix3f(); CElementGen::CParticle& particle = g_StaticParticleList[staticIdx]; particle.x28_startFrame = x50_curFrame; @@ -504,14 +504,14 @@ void CElementGen::CreateNewParticles(int count) if (emtr) { emtr->GetValue(x210_curEmitterFrame, particle.x4_pos, particle.x1c_vel); - Zeus::CVector3f compXf1 = (xdc * x148) * x7c; - Zeus::CVector3f compXf2 = x178 * particle.x4_pos; + Zeus::CVector3f compXf1 = (xdc * x148) * x7c_translation; + Zeus::CVector3f compXf2 = x178_orientation * particle.x4_pos; particle.x4_pos = compXf1 + compXf2 + x94_POFS; - particle.x1c_vel = x178 * particle.x1c_vel; + particle.x1c_vel = x178_orientation * particle.x1c_vel; } else { - Zeus::CVector3f compXf1 = (xdc * x148) * x7c; + Zeus::CVector3f compXf1 = (xdc * x148) * x7c_translation; particle.x4_pos = compXf1 + x94_POFS; particle.x1c_vel.zeroOut(); } @@ -561,26 +561,26 @@ void CElementGen::UpdatePSTranslationAndOrientation() CModVectorElement* psvm = x1c_genDesc.GetObj()->x4_PSVM.get(); if (psvm) { - Zeus::CVector3f vel = x7c; + Zeus::CVector3f vel = x7c_translation; psvm->GetValue(x50_curFrame, x218_PSIV, vel); - if (vel != x7c) + if (vel != x7c_translation) { x224_24 = true; - x7c = vel; + x7c_translation = vel; } } - Zeus::CVector3f v = x178 * x218_PSIV; + Zeus::CVector3f v = x178_orientation * x218_PSIV; if (v != Zeus::CVector3f::skZero) x224_24 = true; - x7c += v; + x7c_translation += v; CVectorElement* psov = x1c_genDesc.GetObj()->x8_PSOV.get(); if (psov) { Zeus::CVector3f angles; psov->GetValue(x50_curFrame, angles); - Zeus::CTransform xf(x178); + Zeus::CTransform xf(x178_orientation); xf.rotateLocalX(angles[0] * M_PI / 180.f); xf.rotateLocalY(angles[1] * M_PI / 180.f); xf.rotateLocalZ(angles[2] * M_PI / 180.f); @@ -612,6 +612,35 @@ void CElementGen::BuildParticleSystemBounds() { } +u32 CElementGen::GetSystemCount() +{ + u32 ret = 0; + for (const CElementGen& child : x234_children) + ret += child.GetSystemCount(); + + for (const CElementGen& child : x248_children) + ret += child.GetSystemCount(); + + return (ret + (x208_activeParticleCount != 0)); +} + +u32 CElementGen::GetParticleCountAll() +{ + return x20c; +} + +u32 CElementGen::GetParticleCountAllInternal() +{ + u32 ret = x208_activeParticleCount; + for (const CElementGen& child : x234_children) + ret += child.GetParticleCountAll(); + + for (const CElementGen& child : x248_children) + ret += child.GetParticleCountAll(); + + return ret; +} + void CElementGen::Render() { } @@ -650,10 +679,12 @@ void CElementGen::SetModulationColor(const Zeus::CColor&) const Zeus::CTransform& CElementGen::GetOrientation() const { + return x178_orientation; } const Zeus::CVector3f& CElementGen::GetTranslation() const { + return x7c_translation; } const Zeus::CVector3f& CElementGen::GetGlobalScale() const diff --git a/Runtime/Particle/CElementGen.hpp b/Runtime/Particle/CElementGen.hpp index 31edf480c..10aee81c9 100644 --- a/Runtime/Particle/CElementGen.hpp +++ b/Runtime/Particle/CElementGen.hpp @@ -73,7 +73,7 @@ private: int x70_MAXP = 0; u16 x74 = 99; float x78_generatorRate = 1.f; - Zeus::CVector3f x7c; + Zeus::CVector3f x7c_translation; Zeus::CVector3f x88_globalTranslation; Zeus::CVector3f x94_POFS; float xa0 = 1.f; @@ -86,7 +86,7 @@ private: float x114 = 1.f; Zeus::CTransform x118 = Zeus::CTransform::Identity(); Zeus::CTransform x148 = Zeus::CTransform::Identity(); - Zeus::CTransform x178 = Zeus::CTransform::Identity(); + Zeus::CTransform x178_orientation = Zeus::CTransform::Identity(); Zeus::CTransform x1a8 = Zeus::CTransform::Identity(); Zeus::CTransform x1d8_globalOrientation = Zeus::CTransform::Identity(); u32 x208_activeParticleCount = 0; @@ -186,6 +186,9 @@ public: void UpdateChildParticleSystems(double); void UpdateLightParameters(); void BuildParticleSystemBounds(); + u32 GetSystemCount(); + u32 GetParticleCountAll(); + u32 GetParticleCountAllInternal(); virtual void Update(double); bool InternalUpdate(double); From aa1bceb6052598e0083b6e3a4093060d40c7e850 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Thu, 11 Feb 2016 12:32:42 -0800 Subject: [PATCH 2/2] Add GAPC and GEMT --- Runtime/Particle/CIntElement.cpp | 12 ++++++++++++ Runtime/Particle/CIntElement.hpp | 12 ++++++++++++ Runtime/Particle/CParticleDataFactory.cpp | 8 ++++++++ 3 files changed, 32 insertions(+) diff --git a/Runtime/Particle/CIntElement.cpp b/Runtime/Particle/CIntElement.cpp index d7223a6cd..cd11e8583 100644 --- a/Runtime/Particle/CIntElement.cpp +++ b/Runtime/Particle/CIntElement.cpp @@ -207,6 +207,18 @@ bool CIEGTCP::GetValue(int frame, int& valOut) const return false; } +bool CIEGAPC::GetValue(int frame, int &valOut) const +{ + /* TODO: Do */ + return false; +} + +bool CIEGEMT::GetValue(int frame, int &valOut) const +{ + /* TODO: Do */ + return false; +} + bool CIEModulo::GetValue(int frame, int& valOut) const { int a, b; diff --git a/Runtime/Particle/CIntElement.hpp b/Runtime/Particle/CIntElement.hpp index 61bd45b4b..d29fac435 100644 --- a/Runtime/Particle/CIntElement.hpp +++ b/Runtime/Particle/CIntElement.hpp @@ -158,6 +158,18 @@ public: bool GetValue(int frame, int& valOut) const; }; +class CIEGAPC : public CIntElement +{ +public: + bool GetValue(int frame, int &valOut) const; +}; + +class CIEGEMT : public CIntElement +{ +public: + bool GetValue(int frame, int &valOut) const; +}; + class CIEModulo : public CIntElement { std::unique_ptr x4_a; diff --git a/Runtime/Particle/CParticleDataFactory.cpp b/Runtime/Particle/CParticleDataFactory.cpp index ad88b0c5b..4238be54b 100644 --- a/Runtime/Particle/CParticleDataFactory.cpp +++ b/Runtime/Particle/CParticleDataFactory.cpp @@ -739,10 +739,18 @@ CIntElement* CParticleDataFactory::GetIntElement(CInputStream& in) CRealElement* a = GetRealElement(in); return new CIETimeScale(a); } + case SBIG('GAPC'): + { + return new CIEGAPC; + } case SBIG('GTCP'): { return new CIEGTCP; } + case SBIG('GEMT'): + { + return new GIEGEMT; + } case SBIG('MODU'): { CIntElement* a = GetIntElement(in);