From 0c5a28f03c44503019f3f8a500b88e84bbc8e3c0 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Tue, 23 Feb 2016 01:16:40 -0800 Subject: [PATCH 1/2] Update hecl --- hecl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hecl b/hecl index 2ff161839..2b65259a7 160000 --- a/hecl +++ b/hecl @@ -1 +1 @@ -Subproject commit 2ff161839491dd42362a680221f5ef4bc95f32cc +Subproject commit 2b65259a7e6b8b274e8135a8023fd74bbf3c77f2 From 88cbb2b6598887a2e7169cabb5ad522363be7995 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Tue, 23 Feb 2016 02:34:19 -0800 Subject: [PATCH 2/2] Add DSPC factory --- Runtime/Particle/CDecalDataFactory.cpp | 124 ++++++++++++++++++ Runtime/Particle/CDecalDataFactory.hpp | 6 +- Runtime/Particle/CDecalDescription.hpp | 32 +++++ .../Particle/CParticleSwooshDataFactory.cpp | 6 +- 4 files changed, 164 insertions(+), 4 deletions(-) diff --git a/Runtime/Particle/CDecalDataFactory.cpp b/Runtime/Particle/CDecalDataFactory.cpp index 8427e1e9b..b6264daae 100644 --- a/Runtime/Particle/CDecalDataFactory.cpp +++ b/Runtime/Particle/CDecalDataFactory.cpp @@ -1,14 +1,138 @@ #include "CDecalDataFactory.hpp" #include "CDecalDescription.hpp" +#include "CParticleDataFactory.hpp" #include "CSimplePool.hpp" +#include "CRandom16.hpp" namespace pshag { +static LogVisor::LogModule Log("pshag::CDecalDataFactory"); + +using CPF = CParticleDataFactory; CDecalDescription* CDecalDataFactory::GetGeneratorDesc(CInputStream& in, CSimplePool* resPool) { + return CreateGeneratorDescription(in, resPool); +} + +CDecalDescription* CDecalDataFactory::CreateGeneratorDescription(CInputStream& in, CSimplePool* resPool) +{ + FourCC clsId = CPF::GetClassID(in); + if (clsId == FOURCC('DPSM')) + { + CDecalDescription* desc = new CDecalDescription; + if (CreateDPSM(desc, in, resPool)) + return desc; + else + delete desc; + } return nullptr; } + +bool CDecalDataFactory::CreateDPSM(CDecalDescription* desc, CInputStream& in, CSimplePool* resPool) +{ + CRandom16 rand{99}; + CGlobalRandom gr{rand}; + FourCC clsId = CPF::GetClassID(in); + + while(clsId != SBIG('_END')) + { + bool loadFirstDesc = false; + switch(clsId) + { + case SBIG('1SZE'): + case SBIG('1LFT'): + case SBIG('1ROT'): + case SBIG('1OFF'): + case SBIG('1CLR'): + case SBIG('1TEX'): + case SBIG('1ADD'): + loadFirstDesc = true; + case SBIG('2LFT'): + case SBIG('2SZE'): + case SBIG('2ROT'): + case SBIG('2OFF'): + case SBIG('2CLR'): + case SBIG('2TEX'): + case SBIG('2ADD'): + if (loadFirstDesc) + GetQuadDecalInfo(in, resPool, clsId, desc->x0_Quad); + else + GetQuadDecalInfo(in, resPool, clsId, desc->x1c_Quad); + break; + + case SBIG('DMDL'): + desc->x38_DMDL = CPF::GetModel(in, resPool); + break; + case SBIG('DFLT'): + desc->x48_DFLT.reset(CPF::GetIntElement(in)); + break; + case SBIG('DMOP'): + desc->x4c_DMOP.reset(CPF::GetVectorElement(in)); + break; + case SBIG('DMRT'): + desc->x50_DMRT.reset(CPF::GetVectorElement(in)); + break; + case SBIG('DMSC'): + desc->x54_DMSC.reset(CPF::GetVectorElement(in)); + break; + case SBIG('DMCL'): + desc->x58_DMCL.reset(CPF::GetColorElement(in)); + break; + case SBIG('DMAB'): + desc->x5c_24_DMAB = CPF::GetBool(in); + break; + case SBIG('DMOO'): + desc->x5c_25_DMOO = CPF::GetBool(in); + break; + default: + { + uint32_t clsName = clsId.toUint32(); + Log.report(LogVisor::FatalError, "Unknown DPSC class %.4s @%" PRIi64, &clsName, in.position()); + return false; + } + } + + clsId = CPF::GetClassID(in); + } + return true; +} + +void CDecalDataFactory::GetQuadDecalInfo(CInputStream& in, CSimplePool* resPool, FourCC clsId, SQuadDescr& quad) +{ + switch(clsId) + { + case SBIG('1LFT'): + case SBIG('2LFT'): + quad.x0_LFT.reset(CPF::GetIntElement(in)); + break; + case SBIG('1SZE'): + case SBIG('2SZE'): + quad.x4_SZE.reset(CPF::GetRealElement(in)); + break; + case SBIG('1ROT'): + case SBIG('2ROT'): + quad.x8_ROT.reset(CPF::GetRealElement(in)); + break; + case SBIG('1OFF'): + case SBIG('2OFF'): + quad.xc_OFF.reset(CPF::GetVectorElement(in)); + break; + case SBIG('1CLR'): + case SBIG('2CLR'): + quad.x10_CLR.reset(CPF::GetColorElement(in)); + break; + case SBIG('1TEX'): + case SBIG('2TEX'): + quad.x14_TEX.reset(CPF::GetTextureElement(in, resPool)); + break; + case SBIG('1ADD'): + case SBIG('2ADD'): + quad.x18_ADD = CPF::GetBool(in); + break; + } +} + std::unique_ptr FDecalDataFactory(const SObjectTag &tag, CInputStream &in, const CVParamTransfer &vparms) { CSimplePool* sp = static_cast(static_cast*>(vparms.GetObj())->GetParam()); diff --git a/Runtime/Particle/CDecalDataFactory.hpp b/Runtime/Particle/CDecalDataFactory.hpp index 55bb7d22e..586399c23 100644 --- a/Runtime/Particle/CDecalDataFactory.hpp +++ b/Runtime/Particle/CDecalDataFactory.hpp @@ -9,15 +9,17 @@ namespace pshag { +struct SQuadDescr; class CDecalDescription; class CSimplePool; class CDecalDataFactory { + static bool CreateDPSM(CDecalDescription* desc,CInputStream& in,CSimplePool* resPool); + static CDecalDescription* CreateGeneratorDescription(CInputStream& in, CSimplePool* resPool); + static void GetQuadDecalInfo(CInputStream& in, CSimplePool* resPool, FourCC clsId, SQuadDescr& quad); public: static CDecalDescription* GetGeneratorDesc(CInputStream& in,CSimplePool* resPool); - static CDecalDescription* CreateGeneratorDescription(CInputStream& in, CSimplePool* resPool); - static bool CreateDPSM(CDecalDescription* desc,CInputStream& in,CSimplePool* resPool); }; std::unique_ptr FDecalDataFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& vparms); diff --git a/Runtime/Particle/CDecalDescription.hpp b/Runtime/Particle/CDecalDescription.hpp index 8c0fc81ca..75bb0aa83 100644 --- a/Runtime/Particle/CDecalDescription.hpp +++ b/Runtime/Particle/CDecalDescription.hpp @@ -1,10 +1,42 @@ #ifndef __PSHAG_CDECALDESCRIPTION_HPP__ #define __PSHAG_CDECALDESCRIPTION_HPP__ +#include "CRealElement.hpp" +#include "CIntElement.hpp" +#include "CVectorElement.hpp" +#include "CColorElement.hpp" +#include "CUVElement.hpp" +#include "CParticleDataFactory.hpp" + namespace pshag { +struct SQuadDescr +{ + std::unique_ptr x0_LFT; + std::unique_ptr x4_SZE; + std::unique_ptr x8_ROT; + std::unique_ptr xc_OFF; + std::unique_ptr x10_CLR; + std::unique_ptr x14_TEX; + bool x18_ADD = false; +}; + class CDecalDescription { +public: + SQuadDescr x0_Quad; + SQuadDescr x1c_Quad; + SParticleModel x38_DMDL; + std::unique_ptr x48_DFLT; + std::unique_ptr x4c_DMOP; + std::unique_ptr x50_DMRT; + std::unique_ptr x54_DMSC; + std::unique_ptr x58_DMCL; + union + { + struct { bool x5c_24_DMAB : 1; bool x5c_25_DMOO : 1;}; + u8 dummy = 0; + }; }; } diff --git a/Runtime/Particle/CParticleSwooshDataFactory.cpp b/Runtime/Particle/CParticleSwooshDataFactory.cpp index c8b3431f0..f4cc0759c 100644 --- a/Runtime/Particle/CParticleSwooshDataFactory.cpp +++ b/Runtime/Particle/CParticleSwooshDataFactory.cpp @@ -23,8 +23,10 @@ CSwooshDescription*CParticleSwooshDataFactory::CreateGeneratorDescription(CInput if (clsId == FOURCC('SWSH')) { CSwooshDescription* desc = new CSwooshDescription; - CreateWPSM(desc, in, resPool); - return desc; + if (CreateWPSM(desc, in, resPool)) + return desc; + else + delete desc; } return nullptr; }