2016-02-08 05:10:17 +00:00
|
|
|
#include "CElementGen.hpp"
|
|
|
|
#include "CGenDescription.hpp"
|
2016-02-10 02:00:28 +00:00
|
|
|
#include "CParticleGlobals.hpp"
|
2016-02-11 22:38:25 +00:00
|
|
|
#include "CParticleSwoosh.hpp"
|
|
|
|
#include "CParticleElectric.hpp"
|
2016-02-13 00:57:09 +00:00
|
|
|
#include "CModel.hpp"
|
2016-02-08 05:10:17 +00:00
|
|
|
|
2016-02-15 04:00:26 +00:00
|
|
|
#include "CElementGenShaders.hpp"
|
|
|
|
|
2016-02-14 03:42:36 +00:00
|
|
|
#define MAX_GLOBAL_PARTICLES 2560
|
|
|
|
|
2016-02-13 09:02:47 +00:00
|
|
|
namespace pshag
|
2016-02-08 05:10:17 +00:00
|
|
|
{
|
2016-02-10 02:00:28 +00:00
|
|
|
static LogVisor::LogModule Log("Retro::CElementGen");
|
|
|
|
|
|
|
|
static bool s_inCreateNewParticles = false;
|
2016-02-08 05:10:17 +00:00
|
|
|
|
2016-02-09 22:52:33 +00:00
|
|
|
int CElementGen::g_ParticleAliveCount;
|
|
|
|
int CElementGen::g_ParticleSystemAliveCount;
|
2016-02-11 02:36:21 +00:00
|
|
|
s32 CElementGen::g_FreeIndex;
|
|
|
|
bool CElementGen::g_StaticListInitialized = false;
|
2016-02-13 00:57:09 +00:00
|
|
|
bool CElementGen::g_MoveRedToAlphaBuffer = false;
|
2016-02-14 03:42:36 +00:00
|
|
|
static rstl::reserved_vector<CElementGen::CParticle, MAX_GLOBAL_PARTICLES> g_StaticParticleList;
|
|
|
|
static rstl::reserved_vector<u16, MAX_GLOBAL_PARTICLES> g_StaticFreeList;
|
2016-02-15 04:00:26 +00:00
|
|
|
|
|
|
|
boo::IShaderPipeline* CElementGenShaders::m_texZTestZWrite = nullptr;
|
|
|
|
boo::IShaderPipeline* CElementGenShaders::m_texNoZTestZWrite = nullptr;
|
|
|
|
boo::IShaderPipeline* CElementGenShaders::m_texZTestNoZWrite = nullptr;
|
|
|
|
boo::IShaderPipeline* CElementGenShaders::m_texNoZTestNoZWrite = nullptr;
|
|
|
|
boo::IShaderPipeline* CElementGenShaders::m_texAdditiveZTest = nullptr;
|
|
|
|
boo::IShaderPipeline* CElementGenShaders::m_texAdditiveNoZTest = nullptr;
|
|
|
|
boo::IShaderPipeline* CElementGenShaders::m_texRedToAlphaZTest = nullptr;
|
|
|
|
boo::IShaderPipeline* CElementGenShaders::m_texRedToAlphaNoZTest = nullptr;
|
|
|
|
|
|
|
|
boo::IShaderPipeline* CElementGenShaders::m_indTexZWrite = nullptr;
|
|
|
|
boo::IShaderPipeline* CElementGenShaders::m_indTexNoZWrite = nullptr;
|
|
|
|
boo::IShaderPipeline* CElementGenShaders::m_indTexAdditive = nullptr;
|
|
|
|
|
|
|
|
boo::IShaderPipeline* CElementGenShaders::m_cindTexZWrite = nullptr;
|
|
|
|
boo::IShaderPipeline* CElementGenShaders::m_cindTexNoZWrite = nullptr;
|
|
|
|
boo::IShaderPipeline* CElementGenShaders::m_cindTexAdditive = nullptr;
|
|
|
|
|
|
|
|
boo::IShaderPipeline* CElementGenShaders::m_noTexZTestZWrite = nullptr;
|
|
|
|
boo::IShaderPipeline* CElementGenShaders::m_noTexNoZTestZWrite = nullptr;
|
|
|
|
boo::IShaderPipeline* CElementGenShaders::m_noTexZTestNoZWrite = nullptr;
|
|
|
|
boo::IShaderPipeline* CElementGenShaders::m_noTexNoZTestNoZWrite = nullptr;
|
|
|
|
boo::IShaderPipeline* CElementGenShaders::m_noTexAdditiveZTest = nullptr;
|
|
|
|
boo::IShaderPipeline* CElementGenShaders::m_noTexAdditiveNoZTest = nullptr;
|
|
|
|
|
|
|
|
boo::IVertexFormat* CElementGenShaders::m_vtxFormatTex = nullptr;
|
|
|
|
boo::IVertexFormat* CElementGenShaders::m_vtxFormatIndTex = nullptr;
|
|
|
|
boo::IVertexFormat* CElementGenShaders::m_vtxFormatNoTex = nullptr;
|
|
|
|
|
|
|
|
std::unique_ptr<CElementGenShaders::IDataBindingFactory> CElementGenShaders::m_bindFactory;
|
|
|
|
boo::GraphicsDataToken CElementGenShaders::m_gfxToken;
|
|
|
|
|
|
|
|
CElementGenShaders::EShaderClass CElementGenShaders::GetShaderClass(CElementGen& gen)
|
|
|
|
{
|
|
|
|
CGenDescription* desc = gen.x1c_genDesc.GetObj();
|
|
|
|
|
|
|
|
if (desc->x54_TEXR)
|
|
|
|
{
|
|
|
|
if (desc->x58_TIND)
|
|
|
|
return EShaderClass::IndTex;
|
|
|
|
else
|
|
|
|
return EShaderClass::Tex;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return EShaderClass::NoTex;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CElementGenShaders::BuildShaderDataBinding(CElementGen& gen)
|
|
|
|
{
|
|
|
|
CGenDescription* desc = gen.x1c_genDesc.GetObj();
|
|
|
|
boo::IShaderPipeline* regPipeline = nullptr;
|
|
|
|
boo::IShaderPipeline* redToAlphaPipeline = nullptr;
|
|
|
|
|
|
|
|
if (desc->x54_TEXR)
|
|
|
|
{
|
|
|
|
if (desc->x58_TIND)
|
|
|
|
{
|
|
|
|
if (desc->x45_30_CIND)
|
|
|
|
{
|
|
|
|
if (gen.x224_26_AAPH)
|
|
|
|
regPipeline = m_cindTexAdditive;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (gen.x224_27_ZBUF)
|
|
|
|
regPipeline = m_cindTexZWrite;
|
|
|
|
else
|
|
|
|
regPipeline = m_cindTexNoZWrite;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (gen.x224_26_AAPH)
|
|
|
|
regPipeline = m_indTexAdditive;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (gen.x224_27_ZBUF)
|
|
|
|
regPipeline = m_indTexZWrite;
|
|
|
|
else
|
|
|
|
regPipeline = m_indTexNoZWrite;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (gen.x224_28_zTest)
|
|
|
|
redToAlphaPipeline = m_texRedToAlphaZTest;
|
|
|
|
else
|
|
|
|
redToAlphaPipeline = m_texRedToAlphaNoZTest;
|
|
|
|
|
|
|
|
if (gen.x224_26_AAPH)
|
|
|
|
{
|
|
|
|
if (gen.x224_28_zTest)
|
|
|
|
regPipeline = m_texAdditiveZTest;
|
|
|
|
else
|
|
|
|
regPipeline = m_texAdditiveNoZTest;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (gen.x224_28_zTest)
|
|
|
|
{
|
|
|
|
if (gen.x224_27_ZBUF)
|
|
|
|
regPipeline = m_texZTestZWrite;
|
|
|
|
else
|
|
|
|
regPipeline = m_texZTestNoZWrite;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (gen.x224_27_ZBUF)
|
|
|
|
regPipeline = m_texNoZTestZWrite;
|
|
|
|
else
|
|
|
|
regPipeline = m_texNoZTestNoZWrite;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (gen.x224_26_AAPH)
|
|
|
|
{
|
|
|
|
if (gen.x224_28_zTest)
|
|
|
|
regPipeline = m_noTexAdditiveZTest;
|
|
|
|
else
|
|
|
|
regPipeline = m_noTexAdditiveNoZTest;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (gen.x224_28_zTest)
|
|
|
|
{
|
|
|
|
if (gen.x224_27_ZBUF)
|
|
|
|
regPipeline = m_noTexZTestZWrite;
|
|
|
|
else
|
|
|
|
regPipeline = m_noTexZTestNoZWrite;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (gen.x224_27_ZBUF)
|
|
|
|
regPipeline = m_noTexNoZTestZWrite;
|
|
|
|
else
|
|
|
|
regPipeline = m_noTexNoZTestNoZWrite;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
m_bindFactory->BuildShaderDataBinding(gen, regPipeline, redToAlphaPipeline);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CElementGenShaders::Initialize()
|
|
|
|
{
|
|
|
|
if (!CGraphics::g_BooFactory)
|
|
|
|
return;
|
|
|
|
|
|
|
|
switch (CGraphics::g_BooFactory->platform())
|
|
|
|
{
|
|
|
|
case boo::IGraphicsDataFactory::Platform::OGL:
|
|
|
|
m_bindFactory.reset(Initialize(*static_cast<boo::GLDataFactory*>(CGraphics::g_BooFactory)));
|
|
|
|
break;
|
|
|
|
#if _WIN32
|
|
|
|
case boo::IGraphicsDataFactory::Platform::D3D11:
|
|
|
|
case boo::IGraphicsDataFactory::Platform::D3D12:
|
|
|
|
m_bindFactory.reset(Initialize(*static_cast<boo::ID3DDataFactory*>(CGraphics::g_BooFactory)));
|
|
|
|
break;
|
|
|
|
#elif __APPLE__
|
|
|
|
case boo::IGraphicsDataFactory::Platform::Metal:
|
|
|
|
m_bindFactory.reset(Initialize(*static_cast<boo::MetalDataFactory*>(CGraphics::g_BooFactory)));
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_gfxToken = CGraphics::CommitResources();
|
|
|
|
}
|
|
|
|
|
|
|
|
struct SParticleInstanceTex
|
|
|
|
{
|
|
|
|
Zeus::CVector4f pos[4];
|
|
|
|
Zeus::CColor color;
|
|
|
|
Zeus::CVector2f uvs[4];
|
|
|
|
};
|
|
|
|
static std::vector<SParticleInstanceTex> g_instTexData;
|
|
|
|
|
|
|
|
struct SParticleInstanceIndTex
|
|
|
|
{
|
|
|
|
Zeus::CVector4f pos[4];
|
|
|
|
Zeus::CColor color;
|
|
|
|
Zeus::CVector4f texrTindUVs[4];
|
|
|
|
Zeus::CVector2f sceneUVs[4];
|
|
|
|
};
|
|
|
|
static std::vector<SParticleInstanceIndTex> g_instIndTexData;
|
|
|
|
|
|
|
|
struct SParticleInstanceNoTex
|
|
|
|
{
|
|
|
|
Zeus::CVector4f pos[4];
|
|
|
|
Zeus::CColor color;
|
|
|
|
};
|
|
|
|
static std::vector<SParticleInstanceNoTex> g_instNoTexData;
|
|
|
|
|
|
|
|
struct SParticleUniforms
|
|
|
|
{
|
|
|
|
Zeus::CMatrix4f mvp;
|
|
|
|
Zeus::CColor moduColor;
|
|
|
|
};
|
|
|
|
|
2016-02-09 22:52:33 +00:00
|
|
|
void CElementGen::Initialize()
|
|
|
|
{
|
2016-02-11 02:36:21 +00:00
|
|
|
if (g_StaticListInitialized)
|
|
|
|
return;
|
|
|
|
Log.report(LogVisor::Info, "Initialize - Static Particle List - ");
|
|
|
|
|
2016-02-09 22:52:33 +00:00
|
|
|
g_ParticleAliveCount = 0;
|
|
|
|
g_ParticleSystemAliveCount = 0;
|
2016-02-10 02:00:28 +00:00
|
|
|
|
2016-02-11 02:36:21 +00:00
|
|
|
g_StaticParticleList.clear();
|
2016-02-14 03:42:36 +00:00
|
|
|
g_StaticParticleList.insert(g_StaticParticleList.end(), MAX_GLOBAL_PARTICLES, CParticle());
|
2016-02-11 02:36:21 +00:00
|
|
|
|
|
|
|
g_StaticFreeList.clear();
|
2016-02-14 03:42:36 +00:00
|
|
|
for (int i=0 ; i<MAX_GLOBAL_PARTICLES ; ++i)
|
|
|
|
g_StaticFreeList.push_back(i);
|
2016-02-11 02:36:21 +00:00
|
|
|
|
2016-02-14 03:42:36 +00:00
|
|
|
g_FreeIndex = MAX_GLOBAL_PARTICLES - 1;
|
|
|
|
Log.report(LogVisor::Info, "size %d (%d each part).",
|
2016-02-15 04:00:26 +00:00
|
|
|
(sizeof(CParticle) + sizeof(u16)) * MAX_GLOBAL_PARTICLES, sizeof(CParticle));
|
2016-02-11 02:36:21 +00:00
|
|
|
g_StaticListInitialized = true;
|
2016-02-09 22:52:33 +00:00
|
|
|
|
2016-02-15 04:00:26 +00:00
|
|
|
/* Compile shaders */
|
|
|
|
CElementGenShaders::Initialize();
|
|
|
|
}
|
2016-02-11 23:05:42 +00:00
|
|
|
|
2016-02-08 05:10:17 +00:00
|
|
|
CElementGen::CElementGen(const TToken<CGenDescription>& gen,
|
|
|
|
EModelOrientationType orientType,
|
|
|
|
EOptionalSystemFlags flags)
|
2016-02-09 22:52:33 +00:00
|
|
|
: x1c_genDesc(gen), x28_orientType(orientType),
|
2016-02-13 05:16:39 +00:00
|
|
|
x226_enableOPTS((flags & EOptionalSystemFlags::Two) != EOptionalSystemFlags::None), x230_randState(x74_randomSeed)
|
2016-02-09 22:52:33 +00:00
|
|
|
{
|
2016-02-13 05:49:59 +00:00
|
|
|
CGenDescription* desc = x1c_genDesc.GetObj();
|
2016-02-11 23:05:42 +00:00
|
|
|
|
2016-02-13 05:16:39 +00:00
|
|
|
CIntElement* seedElem = desc->x1c_SEED.get();
|
|
|
|
if (seedElem)
|
2016-02-09 22:52:33 +00:00
|
|
|
{
|
2016-02-13 05:16:39 +00:00
|
|
|
int seedVal;
|
|
|
|
seedElem->GetValue(x50_curFrame, seedVal);
|
|
|
|
x74_randomSeed = seedVal;
|
2016-02-09 22:52:33 +00:00
|
|
|
}
|
2016-02-13 05:16:39 +00:00
|
|
|
x230_randState.SetSeed(x74_randomSeed);
|
2016-02-09 22:52:33 +00:00
|
|
|
++g_ParticleSystemAliveCount;
|
2016-02-11 23:05:42 +00:00
|
|
|
x224_25_LIT_ = desc->x44_29_LIT_;
|
|
|
|
x224_26_AAPH = desc->x44_26_AAPH;
|
|
|
|
x224_27_ZBUF = desc->x44_27_ZBUF;
|
|
|
|
x224_29_MBLR = desc->x44_30_MBLR;
|
2016-02-09 22:52:33 +00:00
|
|
|
|
2016-02-11 23:05:42 +00:00
|
|
|
CIntElement* mbspElem = desc->x48_MBSP.get();
|
2016-02-09 22:52:33 +00:00
|
|
|
if (mbspElem)
|
2016-02-10 02:00:28 +00:00
|
|
|
mbspElem->GetValue(x50_curFrame, x228_MBSP);
|
2016-02-15 04:00:26 +00:00
|
|
|
m_maxMBSP = x228_MBSP;
|
2016-02-09 22:52:33 +00:00
|
|
|
|
2016-02-11 23:05:42 +00:00
|
|
|
x224_30_VMD1 = desc->x45_26_VMD1;
|
|
|
|
x224_31_VMD2 = desc->x45_27_VMD2;
|
|
|
|
x225_24_VMD3 = desc->x45_28_VMD3;
|
|
|
|
x225_25_VMD4 = desc->x45_29_VMD4;
|
2016-02-09 22:52:33 +00:00
|
|
|
|
2016-02-11 23:05:42 +00:00
|
|
|
CIntElement* cssdElem = desc->xa0_CSSD.get();
|
2016-02-09 22:52:33 +00:00
|
|
|
if (cssdElem)
|
|
|
|
cssdElem->GetValue(0, x244_CSSD);
|
|
|
|
|
2016-02-11 23:05:42 +00:00
|
|
|
SChildGeneratorDesc& idts = desc->xa4_IDTS;
|
2016-02-09 22:52:33 +00:00
|
|
|
if (idts.m_found)
|
|
|
|
{
|
|
|
|
int ndsyVal = 1;
|
2016-02-11 23:05:42 +00:00
|
|
|
CIntElement* ndsyElem = desc->xb4_NDSY.get();
|
2016-02-09 22:52:33 +00:00
|
|
|
if (ndsyElem)
|
|
|
|
ndsyElem->GetValue(0, ndsyVal);
|
2016-02-11 22:38:25 +00:00
|
|
|
x248_finishPartChildren.reserve(ndsyVal + x248_finishPartChildren.size());
|
2016-02-09 22:52:33 +00:00
|
|
|
for (int i=0 ; i<ndsyVal ; ++i)
|
|
|
|
{
|
2016-02-15 02:31:46 +00:00
|
|
|
CGenDescription* chDesc = desc->xa4_IDTS.m_token.GetObj();
|
2016-02-13 05:16:39 +00:00
|
|
|
if (x226_enableOPTS && chDesc->x45_31_OPTS)
|
2016-02-09 22:52:33 +00:00
|
|
|
break;
|
2016-02-15 02:31:46 +00:00
|
|
|
x248_finishPartChildren.emplace_back(new CElementGen(desc->xa4_IDTS.m_token,
|
2016-02-13 05:16:39 +00:00
|
|
|
EModelOrientationType::Normal,
|
|
|
|
x226_enableOPTS ? EOptionalSystemFlags::Two : EOptionalSystemFlags::One));
|
2016-02-09 22:52:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-11 23:05:42 +00:00
|
|
|
CIntElement* pisyElem = desc->xc8_PISY.get();
|
2016-02-09 22:52:33 +00:00
|
|
|
if (pisyElem)
|
|
|
|
{
|
|
|
|
pisyElem->GetValue(0, x25c_PISY);
|
|
|
|
if (x25c_PISY <= 0)
|
|
|
|
x25c_PISY = 1;
|
|
|
|
}
|
|
|
|
|
2016-02-11 23:05:42 +00:00
|
|
|
CIntElement* sisyElem = desc->xcc_SISY.get();
|
2016-02-09 22:52:33 +00:00
|
|
|
if (sisyElem)
|
|
|
|
pisyElem->GetValue(0, x258_SISY);
|
|
|
|
|
2016-02-11 23:05:42 +00:00
|
|
|
CIntElement* sssdElem = desc->xe4_SSSD.get();
|
2016-02-09 22:52:33 +00:00
|
|
|
if (sssdElem)
|
|
|
|
sssdElem->GetValue(0, x270_SSSD);
|
|
|
|
|
2016-02-11 23:05:42 +00:00
|
|
|
CVectorElement* sspoElem = desc->xe8_SSPO.get();
|
2016-02-09 22:52:33 +00:00
|
|
|
if (sspoElem)
|
|
|
|
sspoElem->GetValue(0, x274_SSPO);
|
|
|
|
|
2016-02-11 23:05:42 +00:00
|
|
|
CIntElement* sesdElem = desc->xf8_SESD.get();
|
2016-02-09 22:52:33 +00:00
|
|
|
if (sesdElem)
|
|
|
|
sesdElem->GetValue(0, x290_SESD);
|
|
|
|
|
2016-02-11 23:05:42 +00:00
|
|
|
CVectorElement* sepoElem = desc->xfc_SEPO.get();
|
2016-02-09 22:52:33 +00:00
|
|
|
if (sepoElem)
|
|
|
|
sepoElem->GetValue(0, x294_SEPO);
|
|
|
|
|
2016-02-11 23:05:42 +00:00
|
|
|
CIntElement* psltElem = desc->xc_PSLT.get();
|
2016-02-09 22:52:33 +00:00
|
|
|
if (psltElem)
|
|
|
|
psltElem->GetValue(0, x214_PSLT);
|
|
|
|
|
2016-02-11 23:05:42 +00:00
|
|
|
CVectorElement* psivElem = desc->x0_PSIV.get();
|
2016-02-09 22:52:33 +00:00
|
|
|
if (psivElem)
|
|
|
|
psivElem->GetValue(0, x218_PSIV);
|
|
|
|
|
2016-02-11 23:05:42 +00:00
|
|
|
CIntElement* maxpElem = desc->x28_MAXP.get();
|
2016-02-09 22:52:33 +00:00
|
|
|
if (maxpElem)
|
2016-02-10 02:00:28 +00:00
|
|
|
maxpElem->GetValue(x50_curFrame, x70_MAXP);
|
2016-02-09 22:52:33 +00:00
|
|
|
|
2016-02-15 04:00:26 +00:00
|
|
|
x2c_particleLists.reserve(x70_MAXP);
|
2016-02-09 22:52:33 +00:00
|
|
|
if (x28_orientType == EModelOrientationType::One)
|
|
|
|
{
|
|
|
|
x3c_parentMatrices.insert(x3c_parentMatrices.end(), x70_MAXP,
|
|
|
|
Zeus::CMatrix3f::skIdentityMatrix3f);
|
|
|
|
}
|
|
|
|
|
2016-02-11 23:05:42 +00:00
|
|
|
x225_26_LINE = desc->x44_24_LINE;
|
|
|
|
x225_27_FXLL = desc->x44_25_FXLL;
|
2016-02-09 22:52:33 +00:00
|
|
|
|
2016-02-11 23:05:42 +00:00
|
|
|
CVectorElement* pofsElem = desc->x18_POFS.get();
|
2016-02-11 02:36:21 +00:00
|
|
|
if (pofsElem)
|
|
|
|
pofsElem->GetValue(x50_curFrame, x94_POFS);
|
2016-02-09 22:52:33 +00:00
|
|
|
|
2016-02-11 23:05:42 +00:00
|
|
|
CIntElement* ltypElem = desc->x100_LTYP.get();
|
2016-02-09 22:52:33 +00:00
|
|
|
if (ltypElem)
|
|
|
|
{
|
|
|
|
int ltyp;
|
2016-02-10 02:00:28 +00:00
|
|
|
ltypElem->GetValue(x50_curFrame, ltyp);
|
2016-02-13 05:16:39 +00:00
|
|
|
switch (LightType(ltyp))
|
2016-02-09 22:52:33 +00:00
|
|
|
{
|
2016-02-13 05:16:39 +00:00
|
|
|
case LightType::None:
|
2016-02-09 22:52:33 +00:00
|
|
|
default:
|
2016-02-13 05:16:39 +00:00
|
|
|
x2dc_lightType = LightType::None;
|
2016-02-09 22:52:33 +00:00
|
|
|
break;
|
2016-02-13 05:16:39 +00:00
|
|
|
case LightType::Directional:
|
|
|
|
x2dc_lightType = LightType::Directional;
|
2016-02-09 22:52:33 +00:00
|
|
|
break;
|
2016-02-13 05:16:39 +00:00
|
|
|
case LightType::Custom:
|
|
|
|
x2dc_lightType = LightType::Custom;
|
2016-02-09 22:52:33 +00:00
|
|
|
break;
|
2016-02-13 05:16:39 +00:00
|
|
|
case LightType::Spot:
|
|
|
|
x2dc_lightType = LightType::Spot;
|
2016-02-09 22:52:33 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-11 23:05:42 +00:00
|
|
|
CIntElement* lfotElem = desc->x114_LFOT.get();
|
2016-02-09 22:52:33 +00:00
|
|
|
if (lfotElem)
|
|
|
|
{
|
|
|
|
int lfot;
|
2016-02-10 02:00:28 +00:00
|
|
|
lfotElem->GetValue(x50_curFrame, lfot);
|
2016-02-09 22:52:33 +00:00
|
|
|
switch (EFalloffType(lfot))
|
|
|
|
{
|
|
|
|
case EFalloffType::Constant:
|
|
|
|
x300_falloffType = EFalloffType::Constant;
|
|
|
|
break;
|
|
|
|
case EFalloffType::Linear:
|
|
|
|
default:
|
|
|
|
x300_falloffType = EFalloffType::Linear;
|
|
|
|
break;
|
|
|
|
case EFalloffType::Quadratic:
|
|
|
|
x300_falloffType = EFalloffType::Quadratic;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2016-02-15 04:00:26 +00:00
|
|
|
|
|
|
|
m_shaderClass = CElementGenShaders::GetShaderClass(*this);
|
|
|
|
static const size_t ShadClsSizes[] =
|
|
|
|
{
|
|
|
|
sizeof(SParticleInstanceTex),
|
|
|
|
sizeof(SParticleInstanceIndTex),
|
|
|
|
sizeof(SParticleInstanceNoTex)
|
|
|
|
};
|
|
|
|
size_t maxInsts = x224_29_MBLR ? (m_maxMBSP * x70_MAXP) : x70_MAXP;
|
|
|
|
m_instBuf = CGraphics::NewDynamicGPUBuffer(boo::BufferUse::Vertex, ShadClsSizes[int(m_shaderClass)], maxInsts);
|
|
|
|
m_uniformBuf = CGraphics::NewDynamicGPUBuffer(boo::BufferUse::Uniform, sizeof(SParticleUniforms), 1);
|
|
|
|
CElementGenShaders::BuildShaderDataBinding(*this);
|
|
|
|
m_gfxToken = CGraphics::CommitResources();
|
2016-02-09 22:52:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CElementGen::~CElementGen()
|
|
|
|
{
|
|
|
|
--g_ParticleSystemAliveCount;
|
|
|
|
}
|
|
|
|
|
2016-02-10 02:00:28 +00:00
|
|
|
void CElementGen::Update(double t)
|
|
|
|
{
|
2016-02-13 05:49:59 +00:00
|
|
|
CGenDescription* desc = x1c_genDesc.GetObj();
|
2016-02-11 23:05:42 +00:00
|
|
|
CIntElement* pswtElem = desc->x10_PSWT.get();
|
2016-02-10 02:00:28 +00:00
|
|
|
if (pswtElem && !x225_28_warmedUp)
|
|
|
|
{
|
|
|
|
int pswt = 0;
|
|
|
|
pswtElem->GetValue(x50_curFrame, pswt);
|
|
|
|
if (pswt > 32)
|
|
|
|
{
|
|
|
|
Log.report(LogVisor::Info,
|
|
|
|
"Running warmup on particle system 0x%08x for %d ticks.",
|
2016-02-11 23:05:42 +00:00
|
|
|
desc, pswt);
|
2016-02-10 02:00:28 +00:00
|
|
|
InternalUpdate(pswt / 60.0);
|
|
|
|
x225_28_warmedUp = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
InternalUpdate(t);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CElementGen::InternalUpdate(double dt)
|
|
|
|
{
|
2016-02-11 02:36:21 +00:00
|
|
|
CGlobalRandom gr(x230_randState);
|
2016-02-13 05:49:59 +00:00
|
|
|
CGenDescription* desc = x1c_genDesc.GetObj();
|
2016-02-10 02:00:28 +00:00
|
|
|
|
|
|
|
double dt1 = 1 / 60.0;
|
|
|
|
if (fabs(dt - 1 / 60.0) >= 1 / 60000.0)
|
|
|
|
dt1 = dt;
|
|
|
|
double t = x50_curFrame / 60.0;
|
|
|
|
CParticleGlobals::SetEmitterTime(x50_curFrame);
|
|
|
|
|
2016-02-11 23:05:42 +00:00
|
|
|
CRealElement* pstsElem = desc->x14_PSTS.get();
|
2016-02-10 02:00:28 +00:00
|
|
|
if (pstsElem)
|
|
|
|
{
|
|
|
|
float psts;
|
|
|
|
pstsElem->GetValue(x50_curFrame, psts);
|
|
|
|
double dt1Scaled = psts * dt1;
|
|
|
|
dt1 = std::max(0.0, dt1Scaled);
|
|
|
|
}
|
|
|
|
|
|
|
|
x58_curSeconds += dt1;
|
|
|
|
|
|
|
|
if (x224_29_MBLR && dt > 0.0)
|
|
|
|
{
|
2016-02-11 23:05:42 +00:00
|
|
|
CIntElement* mbspElem = desc->x48_MBSP.get();
|
2016-02-10 02:00:28 +00:00
|
|
|
if (mbspElem)
|
|
|
|
mbspElem->GetValue(x50_curFrame, x228_MBSP);
|
2016-02-15 04:00:26 +00:00
|
|
|
x228_MBSP = std::min(x228_MBSP, m_maxMBSP);
|
2016-02-10 02:00:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int frameUpdateCount = 0;
|
|
|
|
while (t < x58_curSeconds && fabs(t - x58_curSeconds) >= 1 / 60000.0)
|
|
|
|
{
|
2016-02-11 02:36:21 +00:00
|
|
|
x2a8_aabbMin.splat(FLT_MAX);
|
|
|
|
x2b4_aabbMax.splat(FLT_MIN);
|
|
|
|
x2c0_maxSize = 0.f;
|
2016-02-10 02:00:28 +00:00
|
|
|
float grte = 0.f;
|
|
|
|
CParticleGlobals::SetEmitterTime(x50_curFrame);
|
2016-02-11 23:05:42 +00:00
|
|
|
CRealElement* grteElem = desc->x2c_GRTE.get();
|
2016-02-10 02:00:28 +00:00
|
|
|
if (grteElem->GetValue(x50_curFrame, grte))
|
|
|
|
{
|
|
|
|
x2c_particleLists.clear();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
grte = std::max(0.f, grte * x78_generatorRate);
|
2016-02-11 02:36:21 +00:00
|
|
|
x6c_generatorRemainder += grte;
|
|
|
|
int genCount = floorf(x6c_generatorRemainder);
|
|
|
|
x6c_generatorRemainder = x6c_generatorRemainder - genCount;
|
2016-02-10 02:00:28 +00:00
|
|
|
|
2016-02-11 22:38:25 +00:00
|
|
|
if (!x68_particleEmission || x50_curFrame >= x214_PSLT)
|
2016-02-11 02:36:21 +00:00
|
|
|
genCount = 0;
|
2016-02-10 02:00:28 +00:00
|
|
|
|
2016-02-11 23:05:42 +00:00
|
|
|
CIntElement* maxpElem = desc->x28_MAXP.get();
|
2016-02-10 02:00:28 +00:00
|
|
|
if (maxpElem)
|
|
|
|
maxpElem->GetValue(x50_curFrame, x70_MAXP);
|
|
|
|
|
|
|
|
UpdateExistingParticles();
|
|
|
|
|
|
|
|
CParticleGlobals::SetParticleLifetime(x214_PSLT);
|
|
|
|
bool oldBoolVal = s_inCreateNewParticles;
|
|
|
|
s_inCreateNewParticles = true;
|
2016-02-11 02:36:21 +00:00
|
|
|
CreateNewParticles(genCount);
|
2016-02-10 02:00:28 +00:00
|
|
|
s_inCreateNewParticles = oldBoolVal;
|
|
|
|
|
|
|
|
UpdatePSTranslationAndOrientation();
|
|
|
|
UpdateChildParticleSystems(1 / 60.0);
|
|
|
|
|
2016-02-13 05:16:39 +00:00
|
|
|
if (x2dc_lightType != LightType::None)
|
2016-02-10 02:00:28 +00:00
|
|
|
UpdateLightParameters();
|
|
|
|
|
|
|
|
++frameUpdateCount;
|
|
|
|
++x50_curFrame;
|
|
|
|
t += 1 / 60.0;
|
|
|
|
}
|
|
|
|
|
2016-02-11 02:36:21 +00:00
|
|
|
UpdateChildParticleSystems(-(frameUpdateCount / 60.0 - dt1));
|
2016-02-10 02:00:28 +00:00
|
|
|
if (fabs(t - x58_curSeconds) < 1 / 60000.0)
|
|
|
|
x58_curSeconds = t;
|
|
|
|
|
|
|
|
BuildParticleSystemBounds();
|
2016-02-13 05:16:39 +00:00
|
|
|
x224_24_translationDirty = false;
|
2016-02-10 02:00:28 +00:00
|
|
|
|
|
|
|
double passedTime = t - x58_curSeconds;
|
2016-02-13 05:16:39 +00:00
|
|
|
x60_timeDeltaScale = 1.0 - passedTime * 60.0;
|
2016-02-10 02:00:28 +00:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-02-11 02:36:21 +00:00
|
|
|
void CElementGen::AccumulateBounds(Zeus::CVector3f& pos, float size)
|
|
|
|
{
|
|
|
|
x2b4_aabbMax[0] = std::max(pos[0], x2b4_aabbMax[0]);
|
|
|
|
x2b4_aabbMax[1] = std::max(pos[1], x2b4_aabbMax[1]);
|
|
|
|
x2b4_aabbMax[2] = std::max(pos[2], x2b4_aabbMax[2]);
|
|
|
|
x2a8_aabbMin[0] = std::min(pos[0], x2a8_aabbMin[0]);
|
|
|
|
x2a8_aabbMin[1] = std::min(pos[1], x2a8_aabbMin[1]);
|
|
|
|
x2a8_aabbMin[2] = std::min(pos[2], x2a8_aabbMin[2]);
|
|
|
|
x2c0_maxSize = std::max(size, x2c0_maxSize);
|
|
|
|
}
|
|
|
|
|
2016-02-10 02:00:28 +00:00
|
|
|
void CElementGen::UpdateExistingParticles()
|
|
|
|
{
|
2016-02-13 05:49:59 +00:00
|
|
|
CGenDescription* desc = x1c_genDesc.GetObj();
|
2016-02-11 23:05:42 +00:00
|
|
|
|
2016-02-11 02:36:21 +00:00
|
|
|
x208_activeParticleCount = 0;
|
2016-02-10 02:00:28 +00:00
|
|
|
CParticleGlobals::SetEmitterTime(x50_curFrame);
|
2016-02-11 02:36:21 +00:00
|
|
|
for (std::vector<CParticleListItem>::iterator p = x2c_particleLists.begin();
|
|
|
|
p != x2c_particleLists.end();)
|
|
|
|
{
|
|
|
|
CElementGen::CParticle& particle = g_StaticParticleList[p->x0_partIdx];
|
|
|
|
if (particle.x0_endFrame < x50_curFrame)
|
|
|
|
{
|
|
|
|
g_StaticFreeList[++g_FreeIndex] = p->x0_partIdx;
|
|
|
|
if (p+1 == x2c_particleLists.end())
|
|
|
|
{
|
|
|
|
x2c_particleLists.pop_back();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*p = *(x2c_particleLists.end()-1);
|
|
|
|
if (x28_orientType == EModelOrientationType::One)
|
|
|
|
{
|
|
|
|
size_t i = p - x2c_particleLists.begin();
|
|
|
|
x3c_parentMatrices[i] = x3c_parentMatrices[x2c_particleLists.size()-1];
|
|
|
|
}
|
|
|
|
x2c_particleLists.pop_back();
|
|
|
|
if (p != x2c_particleLists.end())
|
|
|
|
if (particle.x0_endFrame < x50_curFrame)
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
particle.x10_prevPos = particle.x4_pos;
|
|
|
|
particle.x4_pos += particle.x1c_vel;
|
|
|
|
}
|
|
|
|
|
|
|
|
++x208_activeParticleCount;
|
|
|
|
CParticleGlobals::SetParticleLifetime(particle.x0_endFrame - particle.x28_startFrame);
|
|
|
|
int particleFrame = x50_curFrame - particle.x28_startFrame;
|
|
|
|
CParticleGlobals::UpdateParticleLifetimeTweenValues(particleFrame);
|
|
|
|
|
2016-02-11 22:38:25 +00:00
|
|
|
bool err = false;
|
2016-02-11 23:05:42 +00:00
|
|
|
CModVectorElement* vel1 = desc->x7c_VEL1.get();
|
2016-02-11 02:36:21 +00:00
|
|
|
if (vel1)
|
|
|
|
{
|
|
|
|
if (x224_30_VMD1)
|
|
|
|
{
|
2016-02-13 05:16:39 +00:00
|
|
|
Zeus::CVector3f xfVel = x1a8_orientationInverse * particle.x1c_vel;
|
|
|
|
Zeus::CVector3f xfPos = x1a8_orientationInverse * (particle.x4_pos - x7c_translation);
|
2016-02-11 02:36:21 +00:00
|
|
|
err = vel1->GetValue(particleFrame, xfVel, xfPos);
|
2016-02-11 22:38:25 +00:00
|
|
|
particle.x1c_vel = x178_orientation * xfVel;
|
|
|
|
particle.x4_pos = x178_orientation * xfPos + x7c_translation;
|
2016-02-11 02:36:21 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
err = vel1->GetValue(particleFrame, particle.x1c_vel, particle.x4_pos);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-11 23:05:42 +00:00
|
|
|
CModVectorElement* vel2 = desc->x80_VEL2.get();
|
2016-02-11 02:36:21 +00:00
|
|
|
if (vel2)
|
|
|
|
{
|
|
|
|
if (x224_31_VMD2)
|
|
|
|
{
|
2016-02-13 05:16:39 +00:00
|
|
|
Zeus::CVector3f xfVel = x1a8_orientationInverse * particle.x1c_vel;
|
|
|
|
Zeus::CVector3f xfPos = x1a8_orientationInverse * (particle.x4_pos - x7c_translation);
|
2016-02-11 02:36:21 +00:00
|
|
|
err |= vel2->GetValue(particleFrame, xfVel, xfPos);
|
2016-02-11 22:38:25 +00:00
|
|
|
particle.x1c_vel = x178_orientation * xfVel;
|
|
|
|
particle.x4_pos = x178_orientation * xfPos + x7c_translation;
|
2016-02-11 02:36:21 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
err |= vel2->GetValue(particleFrame, particle.x1c_vel, particle.x4_pos);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-11 23:05:42 +00:00
|
|
|
CModVectorElement* vel3 = desc->x84_VEL3.get();
|
2016-02-11 02:36:21 +00:00
|
|
|
if (vel3)
|
|
|
|
{
|
|
|
|
if (x225_24_VMD3)
|
|
|
|
{
|
2016-02-13 05:16:39 +00:00
|
|
|
Zeus::CVector3f xfVel = x1a8_orientationInverse * particle.x1c_vel;
|
|
|
|
Zeus::CVector3f xfPos = x1a8_orientationInverse * (particle.x4_pos - x7c_translation);
|
2016-02-11 02:36:21 +00:00
|
|
|
err |= vel3->GetValue(particleFrame, xfVel, xfPos);
|
2016-02-11 22:38:25 +00:00
|
|
|
particle.x1c_vel = x178_orientation * xfVel;
|
|
|
|
particle.x4_pos = x178_orientation * xfPos + x7c_translation;
|
2016-02-11 02:36:21 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
err |= vel3->GetValue(particleFrame, particle.x1c_vel, particle.x4_pos);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-11 23:05:42 +00:00
|
|
|
CModVectorElement* vel4 = desc->x88_VEL4.get();
|
2016-02-11 02:36:21 +00:00
|
|
|
if (vel4)
|
|
|
|
{
|
|
|
|
if (x225_25_VMD4)
|
|
|
|
{
|
2016-02-13 05:16:39 +00:00
|
|
|
Zeus::CVector3f xfVel = x1a8_orientationInverse * particle.x1c_vel;
|
|
|
|
Zeus::CVector3f xfPos = x1a8_orientationInverse * (particle.x4_pos - x7c_translation);
|
2016-02-11 02:36:21 +00:00
|
|
|
err |= vel4->GetValue(particleFrame, xfVel, xfPos);
|
2016-02-11 22:38:25 +00:00
|
|
|
particle.x1c_vel = x178_orientation * xfVel;
|
|
|
|
particle.x4_pos = x178_orientation * xfPos + x7c_translation;
|
2016-02-11 02:36:21 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
err |= vel4->GetValue(particleFrame, particle.x1c_vel, particle.x4_pos);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (x225_26_LINE)
|
|
|
|
{
|
2016-02-11 23:05:42 +00:00
|
|
|
CRealElement* leng = desc->x20_LENG.get();
|
2016-02-11 02:36:21 +00:00
|
|
|
if (leng)
|
|
|
|
err |= leng->GetValue(particleFrame, particle.x2c_lineLengthOrSize);
|
2016-02-11 23:05:42 +00:00
|
|
|
CRealElement* widt = desc->x24_WIDT.get();
|
2016-02-11 02:36:21 +00:00
|
|
|
if (widt)
|
|
|
|
err |= widt->GetValue(particleFrame, particle.x30_lineWidthOrRota);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-02-11 23:05:42 +00:00
|
|
|
CRealElement* rota = desc->x50_ROTA.get();
|
2016-02-11 02:36:21 +00:00
|
|
|
if (rota)
|
|
|
|
err |= rota->GetValue(particleFrame, particle.x30_lineWidthOrRota);
|
2016-02-11 23:05:42 +00:00
|
|
|
CRealElement* size = desc->x4c_SIZE.get();
|
2016-02-11 02:36:21 +00:00
|
|
|
if (size)
|
|
|
|
err |= size->GetValue(particleFrame, particle.x2c_lineLengthOrSize);
|
|
|
|
}
|
|
|
|
|
2016-02-11 23:05:42 +00:00
|
|
|
CColorElement* colr = desc->x30_COLR.get();
|
2016-02-11 02:36:21 +00:00
|
|
|
if (colr)
|
|
|
|
err |= colr->GetValue(particleFrame, particle.x34_color);
|
|
|
|
|
|
|
|
if (err)
|
|
|
|
particle.x0_endFrame = -1;
|
|
|
|
|
|
|
|
AccumulateBounds(particle.x4_pos, particle.x2c_lineLengthOrSize);
|
|
|
|
++p;
|
|
|
|
}
|
2016-02-10 02:00:28 +00:00
|
|
|
}
|
|
|
|
|
2016-02-11 02:36:21 +00:00
|
|
|
void CElementGen::CreateNewParticles(int count)
|
2016-02-10 02:00:28 +00:00
|
|
|
{
|
2016-02-13 05:49:59 +00:00
|
|
|
CGenDescription* desc = x1c_genDesc.GetObj();
|
2016-02-11 23:05:42 +00:00
|
|
|
|
2016-02-11 02:36:21 +00:00
|
|
|
if (!g_StaticListInitialized)
|
|
|
|
Initialize();
|
|
|
|
if (x2c_particleLists.size() >= x70_MAXP)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (count + x2c_particleLists.size() > x70_MAXP)
|
|
|
|
count = x70_MAXP - x2c_particleLists.size();
|
|
|
|
CGlobalRandom gr(x230_randState);
|
|
|
|
x2c_particleLists.reserve(x70_MAXP);
|
|
|
|
|
|
|
|
for (int i=0 ; i<count ; ++i)
|
|
|
|
{
|
|
|
|
if (g_FreeIndex < 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
s16 staticIdx = g_StaticFreeList[g_FreeIndex];
|
2016-02-13 05:16:39 +00:00
|
|
|
x2c_particleLists.emplace_back(staticIdx);
|
2016-02-11 02:36:21 +00:00
|
|
|
++x208_activeParticleCount;
|
|
|
|
if (x28_orientType == EModelOrientationType::One)
|
2016-02-11 22:38:25 +00:00
|
|
|
x3c_parentMatrices[x2c_particleLists.size()-1] = x178_orientation.buildMatrix3f();
|
2016-02-11 02:36:21 +00:00
|
|
|
|
|
|
|
CElementGen::CParticle& particle = g_StaticParticleList[staticIdx];
|
|
|
|
particle.x28_startFrame = x50_curFrame;
|
2016-02-11 23:05:42 +00:00
|
|
|
CIntElement* ltme = desc->x34_LTME.get();
|
2016-02-11 02:36:21 +00:00
|
|
|
if (ltme)
|
|
|
|
ltme->GetValue(0, particle.x0_endFrame);
|
|
|
|
CParticleGlobals::SetParticleLifetime(particle.x0_endFrame);
|
|
|
|
CParticleGlobals::UpdateParticleLifetimeTweenValues(0);
|
|
|
|
particle.x0_endFrame += x50_curFrame;
|
|
|
|
|
2016-02-11 23:05:42 +00:00
|
|
|
CColorElement* colr = desc->x30_COLR.get();
|
2016-02-11 02:36:21 +00:00
|
|
|
if (colr)
|
|
|
|
colr->GetValue(0, particle.x34_color);
|
|
|
|
else
|
|
|
|
particle.x34_color = Zeus::CColor::skWhite;
|
|
|
|
|
2016-02-11 23:05:42 +00:00
|
|
|
CEmitterElement* emtr = desc->x40_EMTR.get();
|
2016-02-11 02:36:21 +00:00
|
|
|
if (emtr)
|
|
|
|
{
|
|
|
|
emtr->GetValue(x210_curEmitterFrame, particle.x4_pos, particle.x1c_vel);
|
2016-02-13 05:16:39 +00:00
|
|
|
Zeus::CVector3f compXf1 = (xdc_globalScaleTransformInverse * x148_localScaleTransformInverse) * x7c_translation;
|
2016-02-11 22:38:25 +00:00
|
|
|
Zeus::CVector3f compXf2 = x178_orientation * particle.x4_pos;
|
2016-02-11 02:36:21 +00:00
|
|
|
particle.x4_pos = compXf1 + compXf2 + x94_POFS;
|
2016-02-11 22:38:25 +00:00
|
|
|
particle.x1c_vel = x178_orientation * particle.x1c_vel;
|
2016-02-11 02:36:21 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-02-13 05:16:39 +00:00
|
|
|
Zeus::CVector3f compXf1 = (xdc_globalScaleTransformInverse * x148_localScaleTransformInverse) * x7c_translation;
|
2016-02-11 02:36:21 +00:00
|
|
|
particle.x4_pos = compXf1 + x94_POFS;
|
|
|
|
particle.x1c_vel.zeroOut();
|
|
|
|
}
|
|
|
|
particle.x10_prevPos = particle.x4_pos;
|
|
|
|
|
|
|
|
if (x225_26_LINE)
|
|
|
|
{
|
2016-02-11 23:05:42 +00:00
|
|
|
CRealElement* leng = desc->x20_LENG.get();
|
2016-02-11 02:36:21 +00:00
|
|
|
if (leng)
|
|
|
|
leng->GetValue(0, particle.x2c_lineLengthOrSize);
|
|
|
|
else
|
|
|
|
particle.x2c_lineLengthOrSize = 1.f;
|
|
|
|
|
2016-02-11 23:05:42 +00:00
|
|
|
CRealElement* widt = desc->x24_WIDT.get();
|
2016-02-11 02:36:21 +00:00
|
|
|
if (widt)
|
|
|
|
widt->GetValue(0, particle.x30_lineWidthOrRota);
|
|
|
|
else
|
|
|
|
particle.x30_lineWidthOrRota = 1.f;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-02-11 23:05:42 +00:00
|
|
|
CRealElement* rota = desc->x50_ROTA.get();
|
2016-02-11 02:36:21 +00:00
|
|
|
if (rota)
|
|
|
|
rota->GetValue(0, particle.x30_lineWidthOrRota);
|
|
|
|
else
|
|
|
|
particle.x30_lineWidthOrRota = 0.f;
|
|
|
|
|
2016-02-11 23:05:42 +00:00
|
|
|
CRealElement* size = desc->x4c_SIZE.get();
|
2016-02-11 02:36:21 +00:00
|
|
|
if (size)
|
|
|
|
size->GetValue(0, particle.x2c_lineLengthOrSize);
|
|
|
|
else
|
|
|
|
particle.x2c_lineLengthOrSize = 0.1f;
|
|
|
|
}
|
|
|
|
|
|
|
|
AccumulateBounds(particle.x4_pos, particle.x2c_lineLengthOrSize);
|
|
|
|
++x210_curEmitterFrame;
|
|
|
|
--g_FreeIndex;
|
|
|
|
}
|
2016-02-10 02:00:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CElementGen::UpdatePSTranslationAndOrientation()
|
|
|
|
{
|
2016-02-13 05:49:59 +00:00
|
|
|
CGenDescription* desc = x1c_genDesc.GetObj();
|
2016-02-11 23:05:42 +00:00
|
|
|
|
2016-02-11 02:36:21 +00:00
|
|
|
CGlobalRandom gr(x230_randState);
|
|
|
|
if (x214_PSLT < x50_curFrame)
|
|
|
|
return;
|
|
|
|
|
2016-02-11 23:05:42 +00:00
|
|
|
CModVectorElement* psvm = desc->x4_PSVM.get();
|
2016-02-11 02:36:21 +00:00
|
|
|
if (psvm)
|
|
|
|
{
|
2016-02-11 22:38:25 +00:00
|
|
|
Zeus::CVector3f vel = x7c_translation;
|
2016-02-11 02:36:21 +00:00
|
|
|
psvm->GetValue(x50_curFrame, x218_PSIV, vel);
|
2016-02-11 22:38:25 +00:00
|
|
|
if (vel != x7c_translation)
|
2016-02-11 02:36:21 +00:00
|
|
|
{
|
2016-02-13 05:16:39 +00:00
|
|
|
x224_24_translationDirty = true;
|
2016-02-11 22:38:25 +00:00
|
|
|
x7c_translation = vel;
|
2016-02-11 02:36:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-11 22:38:25 +00:00
|
|
|
Zeus::CVector3f v = x178_orientation * x218_PSIV;
|
2016-02-11 02:36:21 +00:00
|
|
|
if (v != Zeus::CVector3f::skZero)
|
2016-02-13 05:16:39 +00:00
|
|
|
x224_24_translationDirty = true;
|
2016-02-11 22:38:25 +00:00
|
|
|
x7c_translation += v;
|
2016-02-11 02:36:21 +00:00
|
|
|
|
2016-02-11 23:05:42 +00:00
|
|
|
CVectorElement* psov = desc->x8_PSOV.get();
|
2016-02-11 02:36:21 +00:00
|
|
|
if (psov)
|
|
|
|
{
|
|
|
|
Zeus::CVector3f angles;
|
|
|
|
psov->GetValue(x50_curFrame, angles);
|
2016-02-11 22:38:25 +00:00
|
|
|
Zeus::CTransform xf(x178_orientation);
|
2016-02-11 02:36:21 +00:00
|
|
|
xf.rotateLocalX(angles[0] * M_PI / 180.f);
|
|
|
|
xf.rotateLocalY(angles[1] * M_PI / 180.f);
|
|
|
|
xf.rotateLocalZ(angles[2] * M_PI / 180.f);
|
|
|
|
SetOrientation(xf);
|
|
|
|
}
|
|
|
|
|
2016-02-11 23:05:42 +00:00
|
|
|
CVectorElement* pofs = desc->x18_POFS.get();
|
2016-02-11 02:36:21 +00:00
|
|
|
if (pofs)
|
|
|
|
pofs->GetValue(x50_curFrame, x94_POFS);
|
|
|
|
|
2016-02-11 23:05:42 +00:00
|
|
|
CVectorElement* sspo = desc->xe8_SSPO.get();
|
2016-02-11 02:36:21 +00:00
|
|
|
if (sspo)
|
|
|
|
sspo->GetValue(x50_curFrame, x274_SSPO);
|
|
|
|
|
2016-02-11 23:05:42 +00:00
|
|
|
CVectorElement* sepo = desc->xfc_SEPO.get();
|
2016-02-11 02:36:21 +00:00
|
|
|
if (sepo)
|
|
|
|
sspo->GetValue(x50_curFrame, x294_SEPO);
|
2016-02-10 02:00:28 +00:00
|
|
|
}
|
|
|
|
|
2016-02-11 06:58:33 +00:00
|
|
|
CElementGen* CElementGen::ConstructChildParticleSystem(const TToken<CGenDescription>& desc)
|
|
|
|
{
|
2016-02-11 22:38:25 +00:00
|
|
|
CElementGen* ret = new CElementGen(desc, EModelOrientationType::Normal,
|
2016-02-13 05:16:39 +00:00
|
|
|
x226_enableOPTS ? EOptionalSystemFlags::Two : EOptionalSystemFlags::One);
|
2016-02-11 22:38:25 +00:00
|
|
|
ret->SetGlobalTranslation(x88_globalTranslation);
|
|
|
|
ret->SetGlobalOrientation(x1d8_globalOrientation);
|
|
|
|
ret->SetGlobalScale(xa0_globalScale);
|
|
|
|
ret->SetLocalScale(x10c_localScale);
|
|
|
|
ret->SetTranslation(x7c_translation);
|
|
|
|
ret->SetOrientation(x178_orientation);
|
|
|
|
ret->SetParticleEmission(x68_particleEmission);
|
|
|
|
ret->SetModulationColor(x30c_moduColor);
|
|
|
|
return ret;
|
2016-02-11 06:58:33 +00:00
|
|
|
}
|
|
|
|
|
2016-02-10 02:00:28 +00:00
|
|
|
void CElementGen::UpdateChildParticleSystems(double dt)
|
|
|
|
{
|
2016-02-13 05:49:59 +00:00
|
|
|
CGenDescription* desc = x1c_genDesc.GetObj();
|
2016-02-11 23:05:42 +00:00
|
|
|
|
2016-02-11 06:58:33 +00:00
|
|
|
CGlobalRandom gr(x230_randState);
|
2016-02-11 23:05:42 +00:00
|
|
|
SChildGeneratorDesc& icts = desc->x8c_ICTS;
|
2016-02-11 22:38:25 +00:00
|
|
|
if (icts.m_found && x64_prevFrame != x50_curFrame && x244_CSSD == x50_curFrame)
|
2016-02-11 06:58:33 +00:00
|
|
|
{
|
|
|
|
int ncsyVal = 1;
|
2016-02-11 23:05:42 +00:00
|
|
|
CIntElement* ncsy = desc->x9c_NCSY.get();
|
2016-02-11 06:58:33 +00:00
|
|
|
if (ncsy)
|
|
|
|
ncsy->GetValue(x50_curFrame, ncsyVal);
|
|
|
|
|
2016-02-15 02:31:46 +00:00
|
|
|
CGenDescription* ictsDesc = icts.m_token.GetObj();
|
2016-02-13 05:16:39 +00:00
|
|
|
if (!(x226_enableOPTS && ictsDesc->x45_31_OPTS))
|
2016-02-11 06:58:33 +00:00
|
|
|
{
|
2016-02-11 22:38:25 +00:00
|
|
|
x234_activePartChildren.reserve(ncsyVal + x234_activePartChildren.size());
|
2016-02-11 06:58:33 +00:00
|
|
|
for (int i=0 ; i<ncsyVal ; ++i)
|
|
|
|
{
|
2016-02-15 02:31:46 +00:00
|
|
|
CElementGen* chGen = ConstructChildParticleSystem(icts.m_token);
|
2016-02-11 22:38:25 +00:00
|
|
|
x234_activePartChildren.emplace_back(chGen);
|
2016-02-11 06:58:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-11 23:05:42 +00:00
|
|
|
SChildGeneratorDesc& iits = desc->xb8_IITS;
|
2016-02-11 22:38:25 +00:00
|
|
|
if (iits.m_found && x64_prevFrame != x50_curFrame && x50_curFrame < x214_PSLT &&
|
2016-02-11 06:58:33 +00:00
|
|
|
x68_particleEmission == 1 && x50_curFrame >= x258_SISY &&
|
|
|
|
((x50_curFrame - x258_SISY) % x25c_PISY) == 0)
|
|
|
|
{
|
2016-02-15 02:31:46 +00:00
|
|
|
CGenDescription* iitsDesc = iits.m_token.GetObj();
|
2016-02-13 05:16:39 +00:00
|
|
|
if (!(x226_enableOPTS && iitsDesc->x45_31_OPTS))
|
2016-02-11 06:58:33 +00:00
|
|
|
{
|
2016-02-15 02:31:46 +00:00
|
|
|
CElementGen* chGen = ConstructChildParticleSystem(iits.m_token);
|
2016-02-11 22:38:25 +00:00
|
|
|
x234_activePartChildren.emplace_back(chGen);
|
2016-02-11 06:58:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-11 23:05:42 +00:00
|
|
|
CSpawnSystemKeyframeData* kssm = desc->xd0_KSSM.get();
|
2016-02-11 22:38:25 +00:00
|
|
|
if (kssm && x64_prevFrame != x50_curFrame && x50_curFrame < x214_PSLT)
|
|
|
|
{
|
|
|
|
std::vector<CSpawnSystemKeyframeData::CSpawnSystemKeyframeInfo>& systems =
|
|
|
|
kssm->GetSpawnedSystemsAtFrame(x50_curFrame);
|
|
|
|
x234_activePartChildren.reserve(x234_activePartChildren.size() + systems.size());
|
|
|
|
for (CSpawnSystemKeyframeData::CSpawnSystemKeyframeInfo& system : systems)
|
|
|
|
{
|
|
|
|
TLockedToken<CGenDescription>& token = system.GetToken();
|
2016-02-13 05:16:39 +00:00
|
|
|
if (!(x226_enableOPTS && token.GetObj()->x45_31_OPTS))
|
2016-02-11 22:38:25 +00:00
|
|
|
{
|
|
|
|
CElementGen* chGen = ConstructChildParticleSystem(token);
|
|
|
|
x234_activePartChildren.emplace_back(chGen);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-11 23:05:42 +00:00
|
|
|
SSwooshGeneratorDesc& sswh = desc->xd4_SSWH;
|
2016-02-11 22:38:25 +00:00
|
|
|
if (sswh.m_found && x64_prevFrame != x50_curFrame && x50_curFrame == x270_SSSD)
|
|
|
|
{
|
2016-02-15 02:31:46 +00:00
|
|
|
CParticleSwoosh* sswhGen = new CParticleSwoosh(sswh.m_token, 0);
|
2016-02-11 22:38:25 +00:00
|
|
|
sswhGen->SetGlobalTranslation(x88_globalTranslation);
|
|
|
|
sswhGen->SetGlobalScale(xa0_globalScale);
|
|
|
|
sswhGen->SetTranslation(x7c_translation);
|
|
|
|
sswhGen->SetOrientation(x178_orientation);
|
|
|
|
sswhGen->SetParticleEmission(x68_particleEmission);
|
|
|
|
x260_swhcChildren.emplace_back(sswhGen);
|
|
|
|
}
|
|
|
|
|
2016-02-11 23:05:42 +00:00
|
|
|
SElectricGeneratorDesc& selc = desc->xec_SELC;
|
2016-02-11 22:38:25 +00:00
|
|
|
if (selc.m_found && x64_prevFrame != x50_curFrame && x50_curFrame == x290_SESD)
|
|
|
|
{
|
2016-02-15 02:31:46 +00:00
|
|
|
CParticleElectric* selcGen = new CParticleElectric(selc.m_token);
|
2016-02-11 22:38:25 +00:00
|
|
|
selcGen->SetGlobalTranslation(x88_globalTranslation);
|
|
|
|
selcGen->SetGlobalScale(xa0_globalScale);
|
|
|
|
selcGen->SetTranslation(x7c_translation);
|
|
|
|
selcGen->SetOrientation(x178_orientation);
|
|
|
|
selcGen->SetParticleEmission(x68_particleEmission);
|
|
|
|
x280_elscChildren.emplace_back(selcGen);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (auto p = x234_activePartChildren.begin() ; p != x234_activePartChildren.end() ;)
|
|
|
|
{
|
|
|
|
std::unique_ptr<CElementGen>& ch = *p;
|
|
|
|
|
2016-02-13 05:16:39 +00:00
|
|
|
if ((x50_curFrame == x4c_internalStartFrame || x224_24_translationDirty) && x64_prevFrame != x50_curFrame)
|
2016-02-11 22:38:25 +00:00
|
|
|
{
|
|
|
|
ch->SetTranslation(x7c_translation);
|
|
|
|
ch->SetOrientation(x178_orientation);
|
|
|
|
}
|
|
|
|
|
|
|
|
ch->Update(dt);
|
|
|
|
if (ch->IsSystemDeletable())
|
|
|
|
{
|
|
|
|
p = x234_activePartChildren.erase(p);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
++p;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (auto p = x248_finishPartChildren.begin() ; p != x248_finishPartChildren.end() ;)
|
|
|
|
{
|
|
|
|
std::unique_ptr<CElementGen>& ch = *p;
|
|
|
|
|
|
|
|
if (x214_PSLT <= x50_curFrame)
|
|
|
|
{
|
|
|
|
if (x214_PSLT == x50_curFrame && x64_prevFrame != x50_curFrame)
|
|
|
|
{
|
|
|
|
ch->SetTranslation(x7c_translation);
|
|
|
|
ch->SetOrientation(x178_orientation);
|
|
|
|
}
|
|
|
|
ch->Update(dt);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ch->IsSystemDeletable())
|
|
|
|
{
|
|
|
|
p = x248_finishPartChildren.erase(p);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
++p;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (auto p = x260_swhcChildren.begin() ; p != x260_swhcChildren.end() ;)
|
|
|
|
{
|
|
|
|
std::unique_ptr<CParticleSwoosh>& ch = *p;
|
|
|
|
|
2016-02-13 05:16:39 +00:00
|
|
|
if ((x50_curFrame == x270_SSSD || x224_24_translationDirty) && x64_prevFrame != x50_curFrame)
|
2016-02-11 22:38:25 +00:00
|
|
|
{
|
|
|
|
Zeus::CVector3f trans = x7c_translation + x274_SSPO;
|
|
|
|
ch->SetTranslation(trans);
|
|
|
|
ch->SetOrientation(x178_orientation);
|
|
|
|
}
|
|
|
|
|
|
|
|
ch->Update(dt);
|
|
|
|
if (ch->IsSystemDeletable())
|
|
|
|
{
|
|
|
|
p = x260_swhcChildren.erase(p);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
++p;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (auto p = x280_elscChildren.begin() ; p != x280_elscChildren.end() ;)
|
2016-02-11 06:58:33 +00:00
|
|
|
{
|
2016-02-11 22:38:25 +00:00
|
|
|
std::unique_ptr<CParticleElectric>& ch = *p;
|
|
|
|
|
2016-02-13 05:16:39 +00:00
|
|
|
if ((x50_curFrame == x290_SESD || x224_24_translationDirty) && x64_prevFrame != x50_curFrame)
|
2016-02-11 22:38:25 +00:00
|
|
|
{
|
|
|
|
Zeus::CVector3f trans = x7c_translation + x294_SEPO;
|
|
|
|
ch->SetTranslation(trans);
|
|
|
|
ch->SetOrientation(x178_orientation);
|
|
|
|
}
|
|
|
|
|
|
|
|
ch->Update(dt);
|
|
|
|
if (ch->IsSystemDeletable())
|
|
|
|
{
|
|
|
|
p = x280_elscChildren.erase(p);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
++p;
|
2016-02-11 06:58:33 +00:00
|
|
|
}
|
|
|
|
|
2016-02-11 22:38:25 +00:00
|
|
|
x64_prevFrame = x50_curFrame;
|
2016-02-10 02:00:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CElementGen::UpdateLightParameters()
|
|
|
|
{
|
2016-02-13 05:49:59 +00:00
|
|
|
CGenDescription* desc = x1c_genDesc.GetObj();
|
2016-02-11 23:05:42 +00:00
|
|
|
|
|
|
|
CColorElement* lclr = desc->x104_LCLR.get();
|
2016-02-11 22:38:25 +00:00
|
|
|
if (lclr)
|
|
|
|
lclr->GetValue(x50_curFrame, x2e0_LCLR);
|
|
|
|
|
2016-02-11 23:05:42 +00:00
|
|
|
CRealElement* lint = desc->x108_LINT.get();
|
2016-02-11 22:38:25 +00:00
|
|
|
if (lint)
|
|
|
|
lint->GetValue(x50_curFrame, x2e4_LINT);
|
|
|
|
|
|
|
|
switch (x2dc_lightType)
|
|
|
|
{
|
|
|
|
default:
|
2016-02-13 05:16:39 +00:00
|
|
|
case LightType::None:
|
|
|
|
case LightType::Custom:
|
|
|
|
case LightType::Spot:
|
2016-02-11 22:38:25 +00:00
|
|
|
{
|
2016-02-11 23:05:42 +00:00
|
|
|
CVectorElement* loff = desc->x10c_LOFF.get();
|
2016-02-11 22:38:25 +00:00
|
|
|
if (loff)
|
|
|
|
loff->GetValue(x50_curFrame, x2e8_LOFF);
|
|
|
|
|
2016-02-11 23:05:42 +00:00
|
|
|
CRealElement* lfor = desc->x118_LFOR.get();
|
2016-02-11 22:38:25 +00:00
|
|
|
if (lfor)
|
|
|
|
lfor->GetValue(x50_curFrame, x304_LFOR);
|
|
|
|
|
2016-02-13 05:16:39 +00:00
|
|
|
if (x2dc_lightType == LightType::Spot)
|
2016-02-11 22:38:25 +00:00
|
|
|
{
|
2016-02-11 23:05:42 +00:00
|
|
|
CRealElement* lsla = desc->x11c_LSLA.get();
|
2016-02-11 22:38:25 +00:00
|
|
|
if (lsla)
|
|
|
|
lsla->GetValue(x50_curFrame, x308_LSLA);
|
|
|
|
}
|
|
|
|
}
|
2016-02-13 05:16:39 +00:00
|
|
|
case LightType::Directional:
|
2016-02-11 22:38:25 +00:00
|
|
|
{
|
2016-02-13 05:16:39 +00:00
|
|
|
if (x2dc_lightType != LightType::Custom)
|
2016-02-11 22:38:25 +00:00
|
|
|
{
|
2016-02-11 23:05:42 +00:00
|
|
|
CVectorElement* ldir = desc->x110_LDIR.get();
|
2016-02-11 22:38:25 +00:00
|
|
|
if (ldir)
|
|
|
|
ldir->GetValue(x50_curFrame, x2f4_LDIR);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 CElementGen::GetParticleCountAllInternal() const
|
|
|
|
{
|
|
|
|
u32 ret = x208_activeParticleCount;
|
|
|
|
|
|
|
|
for (const std::unique_ptr<CElementGen>& ch : x234_activePartChildren)
|
|
|
|
ret += ch->GetParticleCountAll();
|
|
|
|
|
|
|
|
for (const std::unique_ptr<CElementGen>& ch : x248_finishPartChildren)
|
|
|
|
ret += ch->GetParticleCountAll();
|
|
|
|
|
|
|
|
return ret;
|
2016-02-10 02:00:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CElementGen::BuildParticleSystemBounds()
|
2016-02-09 22:52:33 +00:00
|
|
|
{
|
2016-02-11 22:38:25 +00:00
|
|
|
Zeus::CAABox aabb;
|
|
|
|
bool accumulated = false;
|
|
|
|
|
|
|
|
for (std::unique_ptr<CElementGen>& ch : x234_activePartChildren)
|
|
|
|
{
|
|
|
|
std::pair<Zeus::CAABox, bool> chBounds = ch->GetBounds();
|
|
|
|
if (chBounds.second)
|
|
|
|
{
|
|
|
|
accumulated = true;
|
|
|
|
aabb.accumulateBounds(chBounds.first);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (std::unique_ptr<CElementGen>& ch : x248_finishPartChildren)
|
|
|
|
{
|
|
|
|
std::pair<Zeus::CAABox, bool> chBounds = ch->GetBounds();
|
|
|
|
if (chBounds.second)
|
|
|
|
{
|
|
|
|
accumulated = true;
|
|
|
|
aabb.accumulateBounds(chBounds.first);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (std::unique_ptr<CParticleSwoosh>& ch : x260_swhcChildren)
|
|
|
|
{
|
|
|
|
std::pair<Zeus::CAABox, bool> chBounds = ch->GetBounds();
|
|
|
|
if (chBounds.second)
|
|
|
|
{
|
|
|
|
accumulated = true;
|
|
|
|
aabb.accumulateBounds(chBounds.first);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (std::unique_ptr<CParticleElectric>& ch : x280_elscChildren)
|
|
|
|
{
|
|
|
|
std::pair<Zeus::CAABox, bool> chBounds = ch->GetBounds();
|
|
|
|
if (chBounds.second)
|
|
|
|
{
|
|
|
|
accumulated = true;
|
|
|
|
aabb.accumulateBounds(chBounds.first);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
x20c_recursiveParticleCount = GetParticleCountAllInternal();
|
|
|
|
if (GetParticleCount())
|
|
|
|
{
|
|
|
|
Zeus::CVector3f scale = xa0_globalScale * x2c0_maxSize;
|
2016-02-13 05:16:39 +00:00
|
|
|
Zeus::CTransform xf = (xac_globalScaleTransform * x1d8_globalOrientation) * x118_localScaleTransform;
|
2016-02-11 22:38:25 +00:00
|
|
|
Zeus::CAABox box = Zeus::CAABox(x2a8_aabbMin, x2b4_aabbMax).getTransformedAABox(xf);
|
|
|
|
Zeus::CVector3f min = box.m_min + x88_globalTranslation - scale;
|
|
|
|
Zeus::CVector3f max = box.m_max + x88_globalTranslation + scale;
|
|
|
|
x2c4_systemBounds = Zeus::CAABox(min, max);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
x2c4_systemBounds = Zeus::CAABox::skInvertedBox;
|
|
|
|
|
|
|
|
if (accumulated)
|
|
|
|
x2c4_systemBounds.accumulateBounds(aabb);
|
2016-02-09 22:52:33 +00:00
|
|
|
}
|
|
|
|
|
2016-02-11 19:18:14 +00:00
|
|
|
u32 CElementGen::GetSystemCount()
|
|
|
|
{
|
|
|
|
u32 ret = 0;
|
2016-02-11 23:05:42 +00:00
|
|
|
for (const std::unique_ptr<CElementGen>& child : x234_activePartChildren)
|
|
|
|
ret += child->GetSystemCount();
|
2016-02-11 19:18:14 +00:00
|
|
|
|
2016-02-11 23:05:42 +00:00
|
|
|
for (const std::unique_ptr<CElementGen>& child : x248_finishPartChildren)
|
|
|
|
ret += child->GetSystemCount();
|
2016-02-11 19:18:14 +00:00
|
|
|
|
|
|
|
return (ret + (x208_activeParticleCount != 0));
|
|
|
|
}
|
|
|
|
|
2016-02-09 22:52:33 +00:00
|
|
|
void CElementGen::Render()
|
2016-02-12 02:36:34 +00:00
|
|
|
{
|
2016-02-13 05:49:59 +00:00
|
|
|
CGenDescription* desc = x1c_genDesc.GetObj();
|
2016-02-12 02:36:34 +00:00
|
|
|
|
|
|
|
x22c_backupLightActive = CGraphics::g_LightActive;
|
|
|
|
CGraphics::DisableAllLights();
|
|
|
|
|
|
|
|
for (std::unique_ptr<CElementGen>& child : x234_activePartChildren)
|
|
|
|
child->Render();
|
|
|
|
|
|
|
|
if (x214_PSLT <= x50_curFrame)
|
|
|
|
for (std::unique_ptr<CElementGen>& child : x248_finishPartChildren)
|
|
|
|
child->Render();
|
|
|
|
|
|
|
|
for (std::unique_ptr<CParticleSwoosh>& child : x260_swhcChildren)
|
|
|
|
child->Render();
|
|
|
|
|
|
|
|
for (std::unique_ptr<CParticleElectric>& child : x280_elscChildren)
|
|
|
|
child->Render();
|
|
|
|
|
|
|
|
if (x2c_particleLists.size())
|
|
|
|
{
|
|
|
|
SParticleModel& pmdl = desc->x5c_PMDL;
|
|
|
|
if (pmdl.m_found || desc->x45_24_PMUS)
|
|
|
|
RenderModels();
|
|
|
|
|
|
|
|
if (x225_26_LINE)
|
|
|
|
RenderLines();
|
|
|
|
else
|
|
|
|
RenderParticles();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CElementGen::RenderModels()
|
|
|
|
{
|
2016-02-13 05:49:59 +00:00
|
|
|
CGenDescription* desc = x1c_genDesc.GetObj();
|
2016-02-13 00:57:09 +00:00
|
|
|
|
|
|
|
if (x225_29_modelsUseLights)
|
|
|
|
CGraphics::SetLightState(x22c_backupLightActive);
|
|
|
|
CGlobalRandom gr(x230_randState);
|
|
|
|
|
|
|
|
SUVElementSet uvs = {0.f, 0.f, 1.f, 1.f};
|
|
|
|
CUVElement* texr = desc->x54_TEXR.get();
|
|
|
|
CTexture* cachedTex = nullptr;
|
|
|
|
bool texConst = true;
|
|
|
|
bool moveRedToAlphaBuffer = false;
|
|
|
|
|
|
|
|
if (desc->x45_24_PMUS)
|
|
|
|
{
|
|
|
|
if (g_MoveRedToAlphaBuffer && desc->x44_31_PMAB && desc->x54_TEXR)
|
|
|
|
moveRedToAlphaBuffer = true;
|
|
|
|
|
|
|
|
if (desc->x44_31_PMAB)
|
|
|
|
{
|
|
|
|
CGraphics::SetDepthWriteMode(true, ERglEnum::LEqual, false);
|
|
|
|
if (moveRedToAlphaBuffer)
|
|
|
|
CGraphics::SetBlendMode(ERglBlendMode::Blend, ERglBlendFactor::One, ERglBlendFactor::One, ERglLogicOp::Clear);
|
|
|
|
else
|
|
|
|
CGraphics::SetBlendMode(ERglBlendMode::Blend, ERglBlendFactor::SrcAlpha, ERglBlendFactor::One, ERglLogicOp::Clear);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CGraphics::SetDepthWriteMode(true, ERglEnum::LEqual, true);
|
|
|
|
CGraphics::SetBlendMode(ERglBlendMode::Blend, ERglBlendFactor::SrcAlpha, ERglBlendFactor::InvSrcAlpha, ERglLogicOp::Clear);
|
|
|
|
}
|
2016-02-12 02:36:34 +00:00
|
|
|
|
2016-02-13 00:57:09 +00:00
|
|
|
CGraphics::SetCullMode(ERglCullMode::None);
|
|
|
|
|
|
|
|
if (texr)
|
|
|
|
{
|
|
|
|
CParticle& target = g_StaticParticleList[x2c_particleLists[0].x0_partIdx];
|
|
|
|
int partFrame = x50_curFrame - target.x28_startFrame;
|
|
|
|
cachedTex = texr->GetValueTexture(partFrame).GetObj();
|
|
|
|
cachedTex->Load(0, CTexture::EClampMode::One);
|
|
|
|
/* Shade as TEXC * RASC and TEXA * RASA */
|
|
|
|
if (moveRedToAlphaBuffer)
|
|
|
|
{
|
|
|
|
/* Color = Prev.rgb * Prev.a */
|
|
|
|
/* Alpha = Tex.r * Prev.a */
|
|
|
|
}
|
|
|
|
texConst = texr->HasConstantTexture();
|
|
|
|
texr->GetValueUV(partFrame, uvs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Zeus::CTransform orient = Zeus::CTransform::Identity();
|
|
|
|
if (desc->x45_25_PMOO)
|
|
|
|
orient = x178_orientation;
|
|
|
|
orient = orient * x1d8_globalOrientation;
|
|
|
|
|
|
|
|
CVectorElement* pmrt = desc->x70_PMRT.get();
|
|
|
|
bool pmrtConst = false;
|
|
|
|
if (pmrt)
|
|
|
|
pmrtConst = pmrt->IsFastConstant();
|
|
|
|
|
2016-02-13 05:16:39 +00:00
|
|
|
Zeus::CVector3f trans = (xdc_globalScaleTransformInverse * x148_localScaleTransformInverse) * x88_globalTranslation;
|
2016-02-13 00:57:09 +00:00
|
|
|
|
|
|
|
Zeus::CTransform rot = Zeus::CTransform::Identity();
|
|
|
|
if (pmrtConst)
|
|
|
|
{
|
|
|
|
Zeus::CVector3f pmrtVal;
|
|
|
|
pmrt->GetValue(x50_curFrame, pmrtVal);
|
|
|
|
rot = Zeus::CTransform::RotateZ(pmrtVal[2] * M_PI / 180.f);
|
|
|
|
rot.rotateLocalY(pmrtVal[1] * M_PI / 180.f);
|
|
|
|
rot.rotateLocalX(pmrtVal[0] * M_PI / 180.f);
|
|
|
|
}
|
|
|
|
rot = orient * rot;
|
|
|
|
|
|
|
|
CParticleGlobals::SetEmitterTime(x50_curFrame);
|
|
|
|
Zeus::CColor col = {1.f, 1.f, 1.f, 1.f};
|
|
|
|
|
|
|
|
Zeus::CVector3f pmopVec;
|
|
|
|
auto matrixIt = x3c_parentMatrices.begin();
|
|
|
|
for (CParticleListItem& item : x2c_particleLists)
|
|
|
|
{
|
|
|
|
CParticle& particle = g_StaticParticleList[item.x0_partIdx];
|
|
|
|
if (particle.x0_endFrame == -1)
|
|
|
|
{
|
|
|
|
++matrixIt;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
CParticleGlobals::SetParticleLifetime(particle.x0_endFrame - particle.x28_startFrame);
|
|
|
|
int partFrame = x50_curFrame - particle.x28_startFrame - 1;
|
|
|
|
CParticleGlobals::UpdateParticleLifetimeTweenValues(partFrame);
|
|
|
|
CVectorElement* pmop = desc->x6c_PMOP.get();
|
|
|
|
if (pmop)
|
|
|
|
pmop->GetValue(partFrame, pmopVec);
|
|
|
|
|
|
|
|
Zeus::CTransform partTrans = Zeus::CTransform::Translate(particle.x4_pos + trans);
|
|
|
|
if (x28_orientType == EModelOrientationType::One)
|
|
|
|
{
|
|
|
|
Zeus::CTransform partRot(*matrixIt);
|
|
|
|
Zeus::CVector3f pmopRotateOffset = (orient * partRot) * pmopVec;
|
|
|
|
partTrans = partTrans * partRot;
|
|
|
|
partTrans += pmopRotateOffset;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
partTrans += orient * pmopVec;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pmrtConst)
|
|
|
|
{
|
|
|
|
partTrans = partTrans * rot;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (pmrt)
|
|
|
|
{
|
|
|
|
Zeus::CVector3f pmrtVal;
|
|
|
|
pmrt->GetValue(partFrame, pmrtVal);
|
|
|
|
rot = Zeus::CTransform::RotateZ(pmrtVal[2] * M_PI / 180.f);
|
|
|
|
rot.rotateLocalY(pmrtVal[1] * M_PI / 180.f);
|
|
|
|
rot.rotateLocalX(pmrtVal[0] * M_PI / 180.f);
|
|
|
|
partTrans = partTrans * (orient * rot);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
partTrans = partTrans * rot;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CVectorElement* pmsc = desc->x74_PMSC.get();
|
|
|
|
if (pmsc)
|
|
|
|
{
|
|
|
|
Zeus::CVector3f pmscVal;
|
|
|
|
pmsc->GetValue(partFrame, pmscVal);
|
|
|
|
partTrans = partTrans * Zeus::CTransform::Scale(pmscVal);
|
|
|
|
}
|
|
|
|
|
|
|
|
CColorElement* pmcl = desc->x78_PMCL.get();
|
|
|
|
if (pmcl)
|
|
|
|
pmcl->GetValue(partFrame, col);
|
|
|
|
|
2016-02-13 05:16:39 +00:00
|
|
|
CGraphics::SetModelMatrix((xac_globalScaleTransform * partTrans) * x118_localScaleTransform);
|
2016-02-13 00:57:09 +00:00
|
|
|
|
|
|
|
if (desc->x45_24_PMUS)
|
|
|
|
{
|
|
|
|
if (!texConst)
|
|
|
|
{
|
|
|
|
CTexture* tex = texr->GetValueTexture(x50_curFrame - particle.x28_startFrame).GetObj();
|
|
|
|
if (tex != cachedTex)
|
|
|
|
{
|
|
|
|
tex->Load(0, CTexture::EClampMode::One);
|
|
|
|
cachedTex = tex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Draw: */
|
|
|
|
/* Pos: {0.5, 0.0, 0.5} Color: <col-variable> UV0: {uv[2], uv[3]} */
|
|
|
|
/* Pos: {-0.5, 0.0, 0.5} Color: <col-variable> UV0: {uv[0], uv[3]} */
|
|
|
|
/* Pos: {-0.5, 0.0, -0.5} Color: <col-variable> UV0: {uv[0], uv[1]} */
|
|
|
|
/* Pos: {0.5, 0.0, -0.5} Color: <col-variable> UV0: {uv[2], uv[1]} */
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-02-15 02:31:46 +00:00
|
|
|
CModel* model = desc->x5c_PMDL.m_token.GetObj();
|
2016-02-13 00:57:09 +00:00
|
|
|
if (desc->x44_31_PMAB)
|
|
|
|
{
|
|
|
|
model->Draw({3, 0, 1, col});
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (1.f == col.a)
|
|
|
|
model->Draw({0, 0, 3, Zeus::CColor::skWhite});
|
|
|
|
else
|
|
|
|
model->Draw({4, 0, 1, col});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
++matrixIt;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (x225_29_modelsUseLights)
|
|
|
|
CGraphics::DisableAllLights();
|
|
|
|
|
|
|
|
CGraphics::SetCullMode(ERglCullMode::Front);
|
|
|
|
if (moveRedToAlphaBuffer)
|
|
|
|
{
|
|
|
|
/* Restore passthrough */
|
|
|
|
}
|
2016-02-12 02:36:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CElementGen::RenderLines()
|
2016-02-15 04:00:26 +00:00
|
|
|
{
|
|
|
|
CGenDescription* desc = x1c_genDesc.GetObj();
|
|
|
|
CGlobalRandom gr(x230_randState);
|
|
|
|
|
|
|
|
Zeus::CTransform systemViewPointMatrix(CGraphics::g_ViewMatrix);
|
|
|
|
systemViewPointMatrix.m_origin.zeroOut();
|
|
|
|
Zeus::CTransform systemCameraMatrix = systemViewPointMatrix.inverse() * x1d8_globalOrientation;
|
|
|
|
systemViewPointMatrix = ((Zeus::CTransform::Translate(x88_globalTranslation) * xac_globalScaleTransform) * systemViewPointMatrix) * x118_localScaleTransform;
|
|
|
|
CGraphics::SetModelMatrix(systemViewPointMatrix);
|
|
|
|
|
|
|
|
CGraphics::SetAlphaCompare(ERglAlphaFunc::Always, 0, ERglAlphaOp::And, ERglAlphaFunc::Always, 0);
|
|
|
|
|
|
|
|
if (x224_26_AAPH)
|
|
|
|
{
|
|
|
|
CGraphics::SetDepthWriteMode(true, ERglEnum::LEqual, false);
|
|
|
|
CGraphics::SetBlendMode(ERglBlendMode::Blend, ERglBlendFactor::SrcAlpha, ERglBlendFactor::One, ERglLogicOp::Clear);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CGraphics::SetDepthWriteMode(true, ERglEnum::LEqual, true);
|
|
|
|
CGraphics::SetBlendMode(ERglBlendMode::Blend, ERglBlendFactor::SrcAlpha, ERglBlendFactor::InvSrcAlpha, ERglLogicOp::Clear);
|
|
|
|
}
|
|
|
|
|
|
|
|
CRealElement* widt = desc->x24_WIDT.get();
|
|
|
|
bool widtConst = false;
|
|
|
|
if (widt)
|
|
|
|
widtConst = widt->IsConstant();
|
|
|
|
|
|
|
|
CUVElement* texr = desc->x54_TEXR.get();
|
|
|
|
SUVElementSet uvs = {0.f, 0.f, 1.f, 1.f};
|
|
|
|
bool constTexr = true;
|
|
|
|
bool constUVs = true;
|
|
|
|
CTexture* cachedTex = nullptr;
|
|
|
|
if (texr)
|
|
|
|
{
|
|
|
|
CParticle& target = g_StaticParticleList[x2c_particleLists[0].x0_partIdx];
|
|
|
|
int partFrame = x50_curFrame - target.x28_startFrame;
|
|
|
|
cachedTex = texr->GetValueTexture(partFrame).GetObj();
|
|
|
|
cachedTex->Load(0, CTexture::EClampMode::One);
|
|
|
|
|
|
|
|
/* Set TEXC * RASC */
|
|
|
|
|
|
|
|
if (x30c_moduColor != Zeus::CColor::skBlack)
|
|
|
|
{
|
|
|
|
/* Add RASC * PREVC pass for MODU color loaded into channel mat-color */
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Pass-thru */
|
|
|
|
}
|
|
|
|
|
|
|
|
constTexr = texr->HasConstantTexture();
|
|
|
|
texr->GetValueUV(partFrame, uvs);
|
|
|
|
constUVs = texr->HasConstantUV();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Pass-thru */
|
|
|
|
}
|
|
|
|
|
|
|
|
if (widtConst)
|
|
|
|
{
|
|
|
|
float width = 1.f;
|
|
|
|
widt->GetValue(0, width);
|
|
|
|
width = std::max(0.f, std::min(width, 42.5f));
|
|
|
|
/* Set line width */
|
|
|
|
/* Start line draw of x2c_particleLists.size() * 2 */
|
|
|
|
}
|
|
|
|
|
|
|
|
for (CParticleListItem& item : x2c_particleLists)
|
|
|
|
{
|
|
|
|
CParticle& particle = g_StaticParticleList[item.x0_partIdx];
|
|
|
|
int partFrame = x50_curFrame - particle.x28_startFrame;
|
|
|
|
|
|
|
|
if (!constTexr)
|
|
|
|
{
|
|
|
|
CTexture* tex = texr->GetValueTexture(partFrame).GetObj();
|
|
|
|
if (tex != cachedTex)
|
|
|
|
{
|
|
|
|
tex->Load(0, CTexture::EClampMode::One);
|
|
|
|
cachedTex = tex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!constUVs)
|
|
|
|
texr->GetValueUV(partFrame, uvs);
|
|
|
|
|
|
|
|
Zeus::CVector3f dVec = particle.x4_pos - particle.x10_prevPos;
|
|
|
|
if (x225_27_FXLL)
|
|
|
|
if (dVec.magSquared() >= 0.f)
|
|
|
|
dVec.normalize();
|
|
|
|
|
|
|
|
Zeus::CVector3f p1 = systemCameraMatrix * particle.x4_pos;
|
|
|
|
Zeus::CVector3f p2 = systemCameraMatrix * (particle.x2c_lineLengthOrSize * dVec + particle.x4_pos);
|
|
|
|
|
|
|
|
if (widtConst)
|
|
|
|
{
|
|
|
|
/* Draw: */
|
|
|
|
/* Pos: p1 Color: particle.color UV0: {uv[0], uv[1]} */
|
|
|
|
/* Pos: p2 Color: particle.color UV0: {uv[2], uv[3]} */
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
float width = 1.f;
|
|
|
|
widt->GetValue(0, width);
|
|
|
|
width = std::max(0.f, std::min(width, 42.5f));
|
|
|
|
/* Set line width */
|
|
|
|
/* Start line draw of 2 */
|
|
|
|
|
|
|
|
/* Draw: */
|
|
|
|
/* Pos: p1 Color: particle.color UV0: {uv[0], uv[1]} */
|
|
|
|
/* Pos: p2 Color: particle.color UV0: {uv[2], uv[3]} */
|
|
|
|
/* EndDraw */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (widtConst)
|
|
|
|
{
|
|
|
|
/* EndDraw */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Restore line-width to 1.0 */
|
|
|
|
|
2016-02-12 02:36:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CElementGen::RenderParticles()
|
2016-02-13 00:57:09 +00:00
|
|
|
{
|
2016-02-13 05:49:59 +00:00
|
|
|
CGenDescription* desc = x1c_genDesc.GetObj();
|
2016-02-13 00:57:09 +00:00
|
|
|
CGlobalRandom gr(x230_randState);
|
|
|
|
|
|
|
|
CUVElement* texr = desc->x54_TEXR.get();
|
|
|
|
CUVElement* tind = desc->x58_TIND.get();
|
|
|
|
if (texr && tind)
|
|
|
|
{
|
|
|
|
RenderParticlesIndirectTexture();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
CRealElement* size = desc->x4c_SIZE.get();
|
|
|
|
if (size && size->IsConstant())
|
|
|
|
{
|
|
|
|
float sizeVal;
|
|
|
|
size->GetValue(0, sizeVal);
|
|
|
|
if (sizeVal == 0.f)
|
|
|
|
{
|
|
|
|
size->GetValue(1, sizeVal);
|
|
|
|
if (sizeVal == 0.f)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-14 03:42:36 +00:00
|
|
|
Zeus::CTransform systemViewPointMatrix(CGraphics::g_ViewMatrix);
|
|
|
|
systemViewPointMatrix.m_origin.zeroOut();
|
|
|
|
Zeus::CTransform systemCameraMatrix = systemViewPointMatrix.inverse() * x1d8_globalOrientation;
|
|
|
|
systemViewPointMatrix = ((Zeus::CTransform::Translate(x88_globalTranslation) * xac_globalScaleTransform) * systemViewPointMatrix) * x118_localScaleTransform;
|
|
|
|
CGraphics::SetModelMatrix(systemViewPointMatrix);
|
2016-02-13 00:57:09 +00:00
|
|
|
|
|
|
|
CGraphics::SetAlphaCompare(ERglAlphaFunc::Always, 0, ERglAlphaOp::And, ERglAlphaFunc::Always, 0);
|
|
|
|
|
|
|
|
SUVElementSet uvs = {0.f, 0.f, 1.f, 1.f};
|
|
|
|
bool constTexr = true;
|
|
|
|
bool constUVs = true;
|
|
|
|
CTexture* cachedTex = nullptr;
|
|
|
|
|
2016-02-15 04:00:26 +00:00
|
|
|
SParticleUniforms uniformData =
|
|
|
|
{
|
|
|
|
CGraphics::GetPerspectiveProjectionMatrix() * CGraphics::g_GXModelView.toMatrix4f(),
|
|
|
|
{1.f, 1.f, 1.f, 1.f}
|
|
|
|
};
|
|
|
|
|
2016-02-13 00:57:09 +00:00
|
|
|
if (texr)
|
|
|
|
{
|
|
|
|
CParticle& target = g_StaticParticleList[x2c_particleLists[0].x0_partIdx];
|
|
|
|
int partFrame = x50_curFrame - target.x28_startFrame;
|
|
|
|
cachedTex = texr->GetValueTexture(partFrame).GetObj();
|
|
|
|
cachedTex->Load(0, CTexture::EClampMode::One);
|
|
|
|
|
|
|
|
if (x30c_moduColor != Zeus::CColor::skBlack)
|
|
|
|
{
|
|
|
|
/* Add RASC * PREVC pass for MODU color loaded into channel mat-color */
|
2016-02-15 04:00:26 +00:00
|
|
|
uniformData.moduColor = x30c_moduColor;
|
2016-02-13 00:57:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
constTexr = texr->HasConstantTexture();
|
|
|
|
texr->GetValueUV(partFrame, uvs);
|
|
|
|
constUVs = texr->HasConstantUV();
|
|
|
|
}
|
2016-02-15 04:00:26 +00:00
|
|
|
|
|
|
|
m_uniformBuf->load(&uniformData, sizeof(SParticleUniforms));
|
2016-02-13 00:57:09 +00:00
|
|
|
|
|
|
|
if (desc->x44_28_SORT)
|
|
|
|
{
|
|
|
|
for (CParticleListItem& item : x2c_particleLists)
|
|
|
|
{
|
|
|
|
CParticle& particle = g_StaticParticleList[item.x0_partIdx];
|
2016-02-14 03:42:36 +00:00
|
|
|
item.x4_viewPoint = systemCameraMatrix * ((particle.x4_pos - particle.x10_prevPos) * x60_timeDeltaScale + particle.x10_prevPos);
|
2016-02-13 00:57:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
std::sort(x2c_particleLists.begin(), x2c_particleLists.end(),
|
|
|
|
[](const CParticleListItem& a, const CParticleListItem& b) -> bool
|
|
|
|
{return a.x4_viewPoint[1] >= b.x4_viewPoint[1];});
|
|
|
|
}
|
|
|
|
|
|
|
|
bool moveRedToAlphaBuffer = false;
|
|
|
|
if (g_MoveRedToAlphaBuffer && x224_26_AAPH)
|
|
|
|
moveRedToAlphaBuffer = true;
|
|
|
|
|
|
|
|
if (moveRedToAlphaBuffer)
|
2016-02-15 04:00:26 +00:00
|
|
|
CGraphics::SetShaderDataBinding(m_redToAlphaDataBind);
|
2016-02-13 00:57:09 +00:00
|
|
|
else
|
2016-02-15 04:00:26 +00:00
|
|
|
CGraphics::SetShaderDataBinding(m_normalDataBind);
|
2016-02-13 00:57:09 +00:00
|
|
|
|
|
|
|
int mbspVal = std::max(1, x228_MBSP);
|
|
|
|
|
|
|
|
CParticleGlobals::SetEmitterTime(x50_curFrame);
|
|
|
|
if (!x224_29_MBLR)
|
|
|
|
{
|
2016-02-15 04:00:26 +00:00
|
|
|
switch (m_shaderClass)
|
|
|
|
{
|
|
|
|
case CElementGenShaders::EShaderClass::Tex:
|
|
|
|
g_instTexData.clear();
|
|
|
|
g_instTexData.reserve(x2c_particleLists.size());
|
|
|
|
break;
|
|
|
|
case CElementGenShaders::EShaderClass::NoTex:
|
|
|
|
g_instNoTexData.clear();
|
|
|
|
g_instNoTexData.reserve(x2c_particleLists.size());
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
Log.report(LogVisor::FatalError, "unexpected particle shader class");
|
|
|
|
break;
|
|
|
|
}
|
2016-02-13 00:57:09 +00:00
|
|
|
for (CParticleListItem& item : x2c_particleLists)
|
|
|
|
{
|
|
|
|
CParticle& particle = g_StaticParticleList[item.x0_partIdx];
|
|
|
|
int partFrame = x50_curFrame - particle.x28_startFrame - 1;
|
|
|
|
Zeus::CVector3f viewPoint;
|
|
|
|
if (desc->x44_28_SORT)
|
|
|
|
viewPoint = item.x4_viewPoint;
|
|
|
|
else
|
2016-02-14 03:42:36 +00:00
|
|
|
viewPoint = systemCameraMatrix * ((particle.x4_pos - particle.x10_prevPos) * x60_timeDeltaScale + particle.x10_prevPos);
|
2016-02-13 00:57:09 +00:00
|
|
|
|
|
|
|
if (!constTexr)
|
|
|
|
{
|
|
|
|
CTexture* tex = texr->GetValueTexture(partFrame).GetObj();
|
|
|
|
if (tex != cachedTex)
|
|
|
|
{
|
|
|
|
tex->Load(0, CTexture::EClampMode::One);
|
|
|
|
cachedTex = tex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!constUVs)
|
|
|
|
{
|
|
|
|
CParticleGlobals::SetParticleLifetime(particle.x0_endFrame - particle.x28_startFrame);
|
|
|
|
CParticleGlobals::UpdateParticleLifetimeTweenValues(partFrame);
|
|
|
|
texr->GetValueUV(partFrame, uvs);
|
|
|
|
}
|
|
|
|
|
|
|
|
float size = 0.5f * particle.x2c_lineLengthOrSize;
|
|
|
|
if (0.f == particle.x30_lineWidthOrRota)
|
|
|
|
{
|
2016-02-15 04:00:26 +00:00
|
|
|
switch (m_shaderClass)
|
|
|
|
{
|
|
|
|
case CElementGenShaders::EShaderClass::Tex:
|
|
|
|
{
|
|
|
|
g_instTexData.emplace_back();
|
|
|
|
SParticleInstanceTex& inst = g_instTexData.back();
|
|
|
|
inst.pos[0] = Zeus::CVector4f{viewPoint.x + size, 0.f, viewPoint.z + size, 1.f};
|
|
|
|
inst.pos[1] = Zeus::CVector4f{viewPoint.x - size, 0.f, viewPoint.z + size, 1.f};
|
|
|
|
inst.pos[2] = Zeus::CVector4f{viewPoint.x + size, 0.f, viewPoint.z - size, 1.f};
|
|
|
|
inst.pos[3] = Zeus::CVector4f{viewPoint.x - size, 0.f, viewPoint.z - size, 1.f};
|
|
|
|
inst.color = particle.x34_color;
|
|
|
|
inst.uvs[0] = {uvs.xMax, uvs.yMax};
|
|
|
|
inst.uvs[1] = {uvs.xMin, uvs.yMax};
|
|
|
|
inst.uvs[2] = {uvs.xMax, uvs.yMin};
|
|
|
|
inst.uvs[3] = {uvs.xMin, uvs.yMin};
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CElementGenShaders::EShaderClass::NoTex:
|
|
|
|
{
|
|
|
|
g_instNoTexData.emplace_back();
|
|
|
|
SParticleInstanceNoTex& inst = g_instNoTexData.back();
|
|
|
|
inst.pos[0] = Zeus::CVector4f{viewPoint.x + size, 0.f, viewPoint.z + size, 1.f};
|
|
|
|
inst.pos[1] = Zeus::CVector4f{viewPoint.x - size, 0.f, viewPoint.z + size, 1.f};
|
|
|
|
inst.pos[2] = Zeus::CVector4f{viewPoint.x + size, 0.f, viewPoint.z - size, 1.f};
|
|
|
|
inst.pos[3] = Zeus::CVector4f{viewPoint.x - size, 0.f, viewPoint.z - size, 1.f};
|
|
|
|
inst.color = particle.x34_color;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: break;
|
|
|
|
}
|
2016-02-13 00:57:09 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
float theta = particle.x30_lineWidthOrRota * M_PI / 180.f;
|
|
|
|
float sinT = sinf(theta) * size;
|
|
|
|
float cosT = sinf(theta) * size;
|
|
|
|
|
2016-02-15 04:00:26 +00:00
|
|
|
switch (m_shaderClass)
|
|
|
|
{
|
|
|
|
case CElementGenShaders::EShaderClass::Tex:
|
|
|
|
{
|
|
|
|
g_instTexData.emplace_back();
|
|
|
|
SParticleInstanceTex& inst = g_instTexData.back();
|
|
|
|
inst.pos[0] = Zeus::CVector4f{viewPoint.x + sinT + cosT, 0.f, viewPoint.z + cosT - sinT, 1.f};
|
|
|
|
inst.pos[1] = Zeus::CVector4f{viewPoint.x + sinT - cosT, 0.f, viewPoint.z + sinT + cosT, 1.f};
|
|
|
|
inst.pos[2] = Zeus::CVector4f{viewPoint.x + (cosT - sinT), 0.f, viewPoint.z + (-cosT - sinT), 1.f};
|
|
|
|
inst.pos[3] = Zeus::CVector4f{viewPoint.x - (sinT + cosT), 0.f, viewPoint.z - (cosT - sinT), 1.f};
|
|
|
|
inst.color = particle.x34_color;
|
|
|
|
inst.uvs[0] = {uvs.xMax, uvs.yMax};
|
|
|
|
inst.uvs[1] = {uvs.xMin, uvs.yMax};
|
|
|
|
inst.uvs[2] = {uvs.xMax, uvs.yMin};
|
|
|
|
inst.uvs[3] = {uvs.xMin, uvs.yMin};
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CElementGenShaders::EShaderClass::NoTex:
|
|
|
|
{
|
|
|
|
g_instNoTexData.emplace_back();
|
|
|
|
SParticleInstanceNoTex& inst = g_instNoTexData.back();
|
|
|
|
inst.pos[0] = Zeus::CVector4f{viewPoint.x + sinT + cosT, 0.f, viewPoint.z + cosT - sinT, 1.f};
|
|
|
|
inst.pos[1] = Zeus::CVector4f{viewPoint.x + sinT - cosT, 0.f, viewPoint.z + sinT + cosT, 1.f};
|
|
|
|
inst.pos[2] = Zeus::CVector4f{viewPoint.x + (cosT - sinT), 0.f, viewPoint.z + (-cosT - sinT), 1.f};
|
|
|
|
inst.pos[3] = Zeus::CVector4f{viewPoint.x - (sinT + cosT), 0.f, viewPoint.z - (cosT - sinT), 1.f};
|
|
|
|
inst.color = particle.x34_color;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: break;
|
|
|
|
}
|
2016-02-13 00:57:09 +00:00
|
|
|
}
|
|
|
|
}
|
2016-02-15 04:00:26 +00:00
|
|
|
switch (m_shaderClass)
|
|
|
|
{
|
|
|
|
case CElementGenShaders::EShaderClass::Tex:
|
|
|
|
m_instBuf->load(g_instTexData.data(), g_instTexData.size() * sizeof(SParticleInstanceTex));
|
|
|
|
CGraphics::DrawInstances(0, 4, g_instTexData.size());
|
|
|
|
break;
|
|
|
|
case CElementGenShaders::EShaderClass::NoTex:
|
|
|
|
m_instBuf->load(g_instNoTexData.data(), g_instNoTexData.size() * sizeof(SParticleInstanceNoTex));
|
|
|
|
CGraphics::DrawInstances(0, 4, g_instNoTexData.size());
|
|
|
|
break;
|
|
|
|
default: break;
|
|
|
|
}
|
2016-02-13 00:57:09 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-02-15 04:00:26 +00:00
|
|
|
switch (m_shaderClass)
|
|
|
|
{
|
|
|
|
case CElementGenShaders::EShaderClass::Tex:
|
|
|
|
g_instTexData.clear();
|
|
|
|
g_instTexData.reserve(x2c_particleLists.size() * mbspVal);
|
|
|
|
break;
|
|
|
|
case CElementGenShaders::EShaderClass::NoTex:
|
|
|
|
g_instNoTexData.clear();
|
|
|
|
g_instNoTexData.reserve(x2c_particleLists.size() * mbspVal);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
Log.report(LogVisor::FatalError, "unexpected particle shader class");
|
|
|
|
break;
|
|
|
|
}
|
2016-02-13 00:57:09 +00:00
|
|
|
float mbspFac = 1.f / float(mbspVal);
|
|
|
|
for (CParticleListItem& item : x2c_particleLists)
|
|
|
|
{
|
|
|
|
CParticle& particle = g_StaticParticleList[item.x0_partIdx];
|
|
|
|
int partFrame = x50_curFrame - particle.x28_startFrame - 1;
|
|
|
|
|
|
|
|
if (!constTexr)
|
|
|
|
{
|
|
|
|
CTexture* tex = texr->GetValueTexture(partFrame).GetObj();
|
|
|
|
if (tex != cachedTex)
|
|
|
|
{
|
|
|
|
tex->Load(0, CTexture::EClampMode::One);
|
|
|
|
cachedTex = tex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!constUVs)
|
|
|
|
{
|
|
|
|
CParticleGlobals::SetParticleLifetime(particle.x0_endFrame - particle.x28_startFrame);
|
|
|
|
CParticleGlobals::UpdateParticleLifetimeTweenValues(partFrame);
|
|
|
|
texr->GetValueUV(partFrame, uvs);
|
|
|
|
}
|
|
|
|
|
|
|
|
Zeus::CVector3f dVec = particle.x4_pos - particle.x10_prevPos;
|
2016-02-13 05:16:39 +00:00
|
|
|
Zeus::CVector3f vec = dVec * x60_timeDeltaScale + particle.x10_prevPos;
|
2016-02-13 00:57:09 +00:00
|
|
|
Zeus::CVector3f mbspVec = dVec * mbspFac;
|
|
|
|
float size = 0.5f * particle.x2c_lineLengthOrSize;
|
|
|
|
if (0.f == particle.x30_lineWidthOrRota)
|
|
|
|
{
|
|
|
|
for (int i=0 ; i<mbspVal ; ++i)
|
|
|
|
{
|
|
|
|
vec += mbspVec;
|
2016-02-14 03:42:36 +00:00
|
|
|
Zeus::CVector3f vec2 = systemCameraMatrix * vec;
|
2016-02-15 04:00:26 +00:00
|
|
|
|
|
|
|
switch (m_shaderClass)
|
|
|
|
{
|
|
|
|
case CElementGenShaders::EShaderClass::Tex:
|
|
|
|
{
|
|
|
|
g_instTexData.emplace_back();
|
|
|
|
SParticleInstanceTex& inst = g_instTexData.back();
|
|
|
|
inst.pos[0] = Zeus::CVector4f{vec2.x + size, vec2.y, vec2.z + size, 1.f};
|
|
|
|
inst.pos[1] = Zeus::CVector4f{vec2.x - size, vec2.y, vec2.z + size, 1.f};
|
|
|
|
inst.pos[2] = Zeus::CVector4f{vec2.x + size, vec2.y, vec2.z - size, 1.f};
|
|
|
|
inst.pos[3] = Zeus::CVector4f{vec2.x - size, vec2.y, vec2.z - size, 1.f};
|
|
|
|
inst.color = particle.x34_color;
|
|
|
|
inst.uvs[0] = {uvs.xMax, uvs.yMax};
|
|
|
|
inst.uvs[1] = {uvs.xMin, uvs.yMax};
|
|
|
|
inst.uvs[2] = {uvs.xMax, uvs.yMin};
|
|
|
|
inst.uvs[3] = {uvs.xMin, uvs.yMin};
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CElementGenShaders::EShaderClass::NoTex:
|
|
|
|
{
|
|
|
|
g_instNoTexData.emplace_back();
|
|
|
|
SParticleInstanceNoTex& inst = g_instNoTexData.back();
|
|
|
|
inst.pos[0] = Zeus::CVector4f{vec2.x + size, vec2.y, vec2.z + size, 1.f};
|
|
|
|
inst.pos[1] = Zeus::CVector4f{vec2.x - size, vec2.y, vec2.z + size, 1.f};
|
|
|
|
inst.pos[2] = Zeus::CVector4f{vec2.x + size, vec2.y, vec2.z - size, 1.f};
|
|
|
|
inst.pos[3] = Zeus::CVector4f{vec2.x - size, vec2.y, vec2.z - size, 1.f};
|
|
|
|
inst.color = particle.x34_color;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: break;
|
|
|
|
}
|
2016-02-13 00:57:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
float theta = particle.x30_lineWidthOrRota * M_PI / 180.f;
|
|
|
|
float sinT = sinf(theta) * size;
|
|
|
|
float cosT = sinf(theta) * size;
|
|
|
|
|
|
|
|
for (int i=0 ; i<mbspVal ; ++i)
|
|
|
|
{
|
|
|
|
vec += mbspVec;
|
2016-02-14 03:42:36 +00:00
|
|
|
Zeus::CVector3f vec2 = systemCameraMatrix * vec;
|
2016-02-15 04:00:26 +00:00
|
|
|
|
|
|
|
switch (m_shaderClass)
|
|
|
|
{
|
|
|
|
case CElementGenShaders::EShaderClass::Tex:
|
|
|
|
{
|
|
|
|
g_instTexData.emplace_back();
|
|
|
|
SParticleInstanceTex& inst = g_instTexData.back();
|
|
|
|
inst.pos[0] = Zeus::CVector4f{vec2.x + sinT + cosT, vec2.y, vec2.z + cosT - sinT, 1.f};
|
|
|
|
inst.pos[1] = Zeus::CVector4f{vec2.x + sinT - cosT, vec2.y, vec2.z + sinT + cosT, 1.f};
|
|
|
|
inst.pos[2] = Zeus::CVector4f{vec2.x + (cosT - sinT), vec2.y, vec2.z + (-cosT - sinT), 1.f};
|
|
|
|
inst.pos[3] = Zeus::CVector4f{vec2.x - (sinT + cosT), vec2.y, vec2.z - (cosT - sinT), 1.f};
|
|
|
|
inst.color = particle.x34_color;
|
|
|
|
inst.uvs[0] = {uvs.xMax, uvs.yMax};
|
|
|
|
inst.uvs[1] = {uvs.xMin, uvs.yMax};
|
|
|
|
inst.uvs[2] = {uvs.xMax, uvs.yMin};
|
|
|
|
inst.uvs[3] = {uvs.xMin, uvs.yMin};
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CElementGenShaders::EShaderClass::NoTex:
|
|
|
|
{
|
|
|
|
g_instNoTexData.emplace_back();
|
|
|
|
SParticleInstanceNoTex& inst = g_instNoTexData.back();
|
|
|
|
inst.pos[0] = Zeus::CVector4f{vec2.x + sinT + cosT, vec2.y, vec2.z + cosT - sinT, 1.f};
|
|
|
|
inst.pos[1] = Zeus::CVector4f{vec2.x + sinT - cosT, vec2.y, vec2.z + sinT + cosT, 1.f};
|
|
|
|
inst.pos[2] = Zeus::CVector4f{vec2.x + (cosT - sinT), vec2.y, vec2.z + (-cosT - sinT), 1.f};
|
|
|
|
inst.pos[3] = Zeus::CVector4f{vec2.x - (sinT + cosT), vec2.y, vec2.z - (cosT - sinT), 1.f};
|
|
|
|
inst.color = particle.x34_color;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: break;
|
|
|
|
}
|
2016-02-13 00:57:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-02-15 04:00:26 +00:00
|
|
|
switch (m_shaderClass)
|
|
|
|
{
|
|
|
|
case CElementGenShaders::EShaderClass::Tex:
|
|
|
|
m_instBuf->load(g_instTexData.data(), g_instTexData.size() * sizeof(SParticleInstanceTex));
|
|
|
|
CGraphics::DrawInstances(0, 4, g_instTexData.size());
|
|
|
|
break;
|
|
|
|
case CElementGenShaders::EShaderClass::NoTex:
|
|
|
|
m_instBuf->load(g_instNoTexData.data(), g_instNoTexData.size() * sizeof(SParticleInstanceNoTex));
|
|
|
|
CGraphics::DrawInstances(0, 4, g_instNoTexData.size());
|
|
|
|
break;
|
|
|
|
default: break;
|
|
|
|
}
|
2016-02-13 00:57:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CElementGen::RenderParticlesIndirectTexture()
|
2016-02-09 22:52:33 +00:00
|
|
|
{
|
2016-02-13 05:49:59 +00:00
|
|
|
CGenDescription* desc = x1c_genDesc.GetObj();
|
2016-02-13 05:16:39 +00:00
|
|
|
|
2016-02-14 03:42:36 +00:00
|
|
|
Zeus::CTransform systemViewPointMatrix(CGraphics::g_ViewMatrix);
|
|
|
|
systemViewPointMatrix.m_origin.zeroOut();
|
|
|
|
Zeus::CTransform systemCameraMatrix = systemViewPointMatrix.inverse() * x1d8_globalOrientation;
|
|
|
|
systemViewPointMatrix = ((Zeus::CTransform::Translate(x88_globalTranslation) * xac_globalScaleTransform) * systemViewPointMatrix) * x118_localScaleTransform;
|
|
|
|
CGraphics::SetModelMatrix(systemViewPointMatrix);
|
|
|
|
|
|
|
|
CGraphics::SetAlphaCompare(ERglAlphaFunc::Always, 0, ERglAlphaOp::And, ERglAlphaFunc::Always, 0);
|
|
|
|
|
|
|
|
if (x224_26_AAPH)
|
|
|
|
{
|
|
|
|
CGraphics::SetDepthWriteMode(true, ERglEnum::LEqual, true);
|
|
|
|
CGraphics::SetBlendMode(ERglBlendMode::Blend, ERglBlendFactor::SrcAlpha, ERglBlendFactor::One, ERglLogicOp::Clear);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CGraphics::SetDepthWriteMode(true, ERglEnum::LEqual, x224_27_ZBUF);
|
|
|
|
CGraphics::SetBlendMode(ERglBlendMode::Blend, ERglBlendFactor::SrcAlpha, ERglBlendFactor::InvSrcAlpha, ERglLogicOp::Clear);
|
|
|
|
}
|
|
|
|
|
|
|
|
CUVElement* texr = desc->x54_TEXR.get();
|
|
|
|
CParticle& firstParticle = g_StaticParticleList[x2c_particleLists[0].x0_partIdx];
|
|
|
|
int partFrame = x50_curFrame - firstParticle.x28_startFrame;
|
|
|
|
CTexture* cachedTex = texr->GetValueTexture(partFrame).GetObj();
|
|
|
|
cachedTex->Load(0, CTexture::EClampMode::One);
|
|
|
|
|
|
|
|
SUVElementSet uvs = {0.f, 0.f, 1.f, 1.f};
|
|
|
|
bool constTexr = texr->HasConstantTexture();
|
|
|
|
texr->GetValueUV(partFrame, uvs);
|
|
|
|
bool constUVs = texr->HasConstantUV();
|
|
|
|
|
|
|
|
CUVElement* tind = desc->x58_TIND.get();
|
|
|
|
CTexture* cachedIndTex = tind->GetValueTexture(partFrame).GetObj();
|
|
|
|
cachedIndTex->Load(2, CTexture::EClampMode::One);
|
|
|
|
|
|
|
|
SUVElementSet uvsInd = {0.f, 0.f, 1.f, 1.f};
|
|
|
|
bool constIndTexr = tind->HasConstantTexture();
|
|
|
|
bool constIndUVs = tind->HasConstantUV();
|
|
|
|
tind->GetValueUV(partFrame, uvsInd);
|
2016-02-13 05:16:39 +00:00
|
|
|
|
2016-02-15 04:00:26 +00:00
|
|
|
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)
|
|
|
|
{
|
|
|
|
CParticle& particle = g_StaticParticleList[item.x0_partIdx];
|
|
|
|
item.x4_viewPoint = systemCameraMatrix * ((particle.x4_pos - particle.x10_prevPos) * x60_timeDeltaScale + particle.x10_prevPos);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::sort(x2c_particleLists.begin(), x2c_particleLists.end(),
|
|
|
|
[](const CParticleListItem& a, const CParticleListItem& b) -> bool
|
|
|
|
{return a.x4_viewPoint[1] >= b.x4_viewPoint[1];});
|
|
|
|
}
|
|
|
|
|
|
|
|
for (CParticleListItem& item : x2c_particleLists)
|
|
|
|
{
|
|
|
|
CParticle& particle = g_StaticParticleList[item.x0_partIdx];
|
|
|
|
int partFrame = x50_curFrame - particle.x28_startFrame;
|
|
|
|
Zeus::CVector3f viewPoint;
|
|
|
|
if (desc->x44_28_SORT)
|
|
|
|
viewPoint = item.x4_viewPoint;
|
|
|
|
else
|
|
|
|
viewPoint = systemCameraMatrix * ((particle.x4_pos - particle.x10_prevPos) * x60_timeDeltaScale + particle.x10_prevPos);
|
|
|
|
|
|
|
|
if (!constTexr)
|
|
|
|
{
|
|
|
|
CTexture* tex = texr->GetValueTexture(partFrame).GetObj();
|
|
|
|
if (tex != cachedTex)
|
|
|
|
{
|
|
|
|
tex->Load(0, CTexture::EClampMode::One);
|
|
|
|
cachedTex = tex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!constIndTexr)
|
|
|
|
{
|
|
|
|
CTexture* tex = tind->GetValueTexture(partFrame).GetObj();
|
|
|
|
if (tex != cachedIndTex)
|
|
|
|
{
|
|
|
|
tex->Load(2, CTexture::EClampMode::One);
|
|
|
|
cachedIndTex = tex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!constUVs)
|
|
|
|
texr->GetValueUV(partFrame, uvs);
|
|
|
|
|
|
|
|
if (!constIndUVs)
|
|
|
|
tind->GetValueUV(partFrame, uvsInd);
|
|
|
|
|
|
|
|
|
|
|
|
float size = 0.5f * particle.x2c_lineLengthOrSize;
|
|
|
|
Zeus::CVector3f p1 = {viewPoint.x - size, viewPoint.y, viewPoint.z - size};
|
|
|
|
Zeus::CVector3f p2 = {viewPoint.x + size, viewPoint.y, viewPoint.z + size};
|
|
|
|
SClipScreenRect clipRect = CGraphics::ClipScreenRectFromMS(p1, p2);
|
|
|
|
|
|
|
|
if (!clipRect.x0_valid)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* Perform render-to-texture */
|
|
|
|
|
|
|
|
/* Draw: */
|
|
|
|
/* Pos: {viewPoint.x + size, viewPoint.y, viewPoint.z + size} Color: particle.color UV0: {uva[2], uva[3]} UV1: {clip.xmax, clip.ymax} UV2: {uvb[2], uvb[3]} */
|
|
|
|
/* Pos: {viewPoint.x - size, viewPoint.y, viewPoint.z + size} Color: particle.color UV0: {uva[0], uva[3]} UV1: {clip.xmin, clip.ymax} UV2: {uvb[0], uvb[3]} */
|
|
|
|
/* Pos: {viewPoint.x - size, viewPoint.y, viewPoint.z - size} Color: particle.color UV0: {uva[0], uva[1]} UV1: {clip.xmin, clip.ymin} UV2: {uvb[0], uvb[1]} */
|
|
|
|
/* Pos: {viewPoint.x + size, viewPoint.y, viewPoint.z - size} Color: particle.color UV0: {uva[2], uva[1]} UV1: {clip.xmax, clip.ymin} UV2: {uvb[2], uvb[1]} */
|
|
|
|
}
|
2016-02-09 22:52:33 +00:00
|
|
|
}
|
|
|
|
|
2016-02-13 05:16:39 +00:00
|
|
|
void CElementGen::SetOrientation(const Zeus::CTransform& orientation)
|
2016-02-09 22:52:33 +00:00
|
|
|
{
|
2016-02-13 05:16:39 +00:00
|
|
|
x178_orientation = orientation;
|
|
|
|
x1a8_orientationInverse = x178_orientation.inverse();
|
|
|
|
|
|
|
|
for (const std::unique_ptr<CElementGen>& ch : x234_activePartChildren)
|
|
|
|
ch->SetOrientation(orientation);
|
|
|
|
|
|
|
|
for (const std::unique_ptr<CElementGen>& ch : x248_finishPartChildren)
|
|
|
|
ch->SetOrientation(orientation);
|
|
|
|
|
|
|
|
for (const std::unique_ptr<CParticleSwoosh>& ch : x260_swhcChildren)
|
|
|
|
ch->SetOrientation(orientation);
|
|
|
|
|
|
|
|
for (const std::unique_ptr<CParticleElectric>& ch : x280_elscChildren)
|
|
|
|
ch->SetOrientation(orientation);
|
2016-02-09 22:52:33 +00:00
|
|
|
}
|
|
|
|
|
2016-02-13 05:16:39 +00:00
|
|
|
void CElementGen::SetTranslation(const Zeus::CVector3f& translation)
|
2016-02-09 22:52:33 +00:00
|
|
|
{
|
2016-02-13 05:16:39 +00:00
|
|
|
x7c_translation = translation;
|
|
|
|
|
|
|
|
for (const std::unique_ptr<CElementGen>& ch : x234_activePartChildren)
|
|
|
|
ch->SetTranslation(translation);
|
|
|
|
|
|
|
|
for (const std::unique_ptr<CElementGen>& ch : x248_finishPartChildren)
|
|
|
|
ch->SetTranslation(translation);
|
|
|
|
|
|
|
|
for (const std::unique_ptr<CParticleSwoosh>& ch : x260_swhcChildren)
|
|
|
|
ch->SetTranslation(translation + x274_SSPO);
|
|
|
|
|
|
|
|
for (const std::unique_ptr<CParticleElectric>& ch : x280_elscChildren)
|
|
|
|
ch->SetTranslation(translation + x294_SEPO);
|
2016-02-09 22:52:33 +00:00
|
|
|
}
|
|
|
|
|
2016-02-13 05:16:39 +00:00
|
|
|
void CElementGen::SetGlobalOrientation(const Zeus::CTransform& rotation)
|
2016-02-09 22:52:33 +00:00
|
|
|
{
|
2016-02-13 05:16:39 +00:00
|
|
|
x1d8_globalOrientation.setRotation(rotation);
|
|
|
|
|
|
|
|
for (const std::unique_ptr<CElementGen>& ch : x234_activePartChildren)
|
|
|
|
ch->SetGlobalOrientation(x1d8_globalOrientation);
|
|
|
|
|
|
|
|
for (const std::unique_ptr<CElementGen>& ch : x248_finishPartChildren)
|
|
|
|
ch->SetGlobalOrientation(x1d8_globalOrientation);
|
|
|
|
|
|
|
|
for (const std::unique_ptr<CParticleElectric>& ch : x280_elscChildren)
|
|
|
|
ch->SetGlobalOrientation(x1d8_globalOrientation);
|
2016-02-09 22:52:33 +00:00
|
|
|
}
|
|
|
|
|
2016-02-13 05:16:39 +00:00
|
|
|
void CElementGen::SetGlobalTranslation(const Zeus::CVector3f& translation)
|
2016-02-09 22:52:33 +00:00
|
|
|
{
|
2016-02-13 05:16:39 +00:00
|
|
|
x88_globalTranslation = translation;
|
|
|
|
|
|
|
|
for (const std::unique_ptr<CElementGen>& ch : x234_activePartChildren)
|
|
|
|
ch->SetGlobalTranslation(translation);
|
|
|
|
|
|
|
|
for (const std::unique_ptr<CElementGen>& ch : x248_finishPartChildren)
|
|
|
|
ch->SetGlobalTranslation(translation);
|
|
|
|
|
|
|
|
for (const std::unique_ptr<CParticleSwoosh>& ch : x260_swhcChildren)
|
|
|
|
ch->SetGlobalTranslation(translation);
|
|
|
|
|
|
|
|
for (const std::unique_ptr<CParticleElectric>& ch : x280_elscChildren)
|
|
|
|
ch->SetGlobalTranslation(translation);
|
2016-02-09 22:52:33 +00:00
|
|
|
}
|
|
|
|
|
2016-02-13 05:16:39 +00:00
|
|
|
void CElementGen::SetGlobalScale(const Zeus::CVector3f& scale)
|
2016-02-09 22:52:33 +00:00
|
|
|
{
|
2016-02-13 05:16:39 +00:00
|
|
|
xa0_globalScale = scale;
|
|
|
|
xac_globalScaleTransform = Zeus::CTransform::Scale(scale);
|
|
|
|
xdc_globalScaleTransformInverse = Zeus::CTransform::Scale(Zeus::CVector3f::skOne / scale);
|
|
|
|
|
|
|
|
for (const std::unique_ptr<CElementGen>& ch : x234_activePartChildren)
|
|
|
|
ch->SetGlobalScale(scale);
|
|
|
|
|
|
|
|
for (const std::unique_ptr<CElementGen>& ch : x248_finishPartChildren)
|
|
|
|
ch->SetGlobalScale(scale);
|
|
|
|
|
|
|
|
for (const std::unique_ptr<CParticleSwoosh>& ch : x260_swhcChildren)
|
|
|
|
ch->SetGlobalScale(scale);
|
|
|
|
|
|
|
|
for (const std::unique_ptr<CParticleElectric>& ch : x280_elscChildren)
|
|
|
|
ch->SetGlobalScale(scale);
|
2016-02-09 22:52:33 +00:00
|
|
|
}
|
|
|
|
|
2016-02-13 05:16:39 +00:00
|
|
|
void CElementGen::SetLocalScale(const Zeus::CVector3f& scale)
|
2016-02-09 22:52:33 +00:00
|
|
|
{
|
2016-02-13 05:16:39 +00:00
|
|
|
x10c_localScale = scale;
|
|
|
|
x118_localScaleTransform = Zeus::CTransform::Scale(scale);
|
|
|
|
x148_localScaleTransformInverse = Zeus::CTransform::Scale(Zeus::CVector3f::skOne / scale);
|
|
|
|
|
|
|
|
for (const std::unique_ptr<CElementGen>& ch : x234_activePartChildren)
|
|
|
|
ch->SetLocalScale(scale);
|
|
|
|
|
|
|
|
for (const std::unique_ptr<CElementGen>& ch : x248_finishPartChildren)
|
|
|
|
ch->SetLocalScale(scale);
|
2016-02-09 22:52:33 +00:00
|
|
|
}
|
|
|
|
|
2016-02-13 05:16:39 +00:00
|
|
|
void CElementGen::SetParticleEmission(bool enabled)
|
2016-02-09 22:52:33 +00:00
|
|
|
{
|
2016-02-13 05:16:39 +00:00
|
|
|
x68_particleEmission = enabled;
|
|
|
|
|
|
|
|
for (const std::unique_ptr<CElementGen>& ch : x234_activePartChildren)
|
|
|
|
ch->SetParticleEmission(enabled);
|
|
|
|
|
|
|
|
for (const std::unique_ptr<CElementGen>& ch : x248_finishPartChildren)
|
|
|
|
ch->SetParticleEmission(enabled);
|
|
|
|
|
|
|
|
for (const std::unique_ptr<CParticleSwoosh>& ch : x260_swhcChildren)
|
|
|
|
ch->SetParticleEmission(enabled);
|
|
|
|
|
|
|
|
for (const std::unique_ptr<CParticleElectric>& ch : x280_elscChildren)
|
|
|
|
ch->SetParticleEmission(enabled);
|
2016-02-09 22:52:33 +00:00
|
|
|
}
|
|
|
|
|
2016-02-13 05:16:39 +00:00
|
|
|
void CElementGen::SetModulationColor(const Zeus::CColor& color)
|
2016-02-08 05:10:17 +00:00
|
|
|
{
|
2016-02-13 05:16:39 +00:00
|
|
|
x30c_moduColor = color;
|
|
|
|
|
|
|
|
for (const std::unique_ptr<CElementGen>& ch : x234_activePartChildren)
|
|
|
|
ch->SetModulationColor(color);
|
|
|
|
|
|
|
|
for (const std::unique_ptr<CElementGen>& ch : x248_finishPartChildren)
|
|
|
|
ch->SetModulationColor(color);
|
|
|
|
|
|
|
|
for (const std::unique_ptr<CParticleSwoosh>& ch : x260_swhcChildren)
|
|
|
|
ch->SetModulationColor(color);
|
|
|
|
|
|
|
|
for (const std::unique_ptr<CParticleElectric>& ch : x280_elscChildren)
|
|
|
|
ch->SetModulationColor(color);
|
2016-02-09 22:52:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const Zeus::CTransform& CElementGen::GetOrientation() const
|
|
|
|
{
|
2016-02-11 19:18:14 +00:00
|
|
|
return x178_orientation;
|
2016-02-09 22:52:33 +00:00
|
|
|
}
|
2016-02-08 05:10:17 +00:00
|
|
|
|
2016-02-09 22:52:33 +00:00
|
|
|
const Zeus::CVector3f& CElementGen::GetTranslation() const
|
|
|
|
{
|
2016-02-11 19:18:14 +00:00
|
|
|
return x7c_translation;
|
2016-02-09 22:52:33 +00:00
|
|
|
}
|
|
|
|
|
2016-02-13 05:49:59 +00:00
|
|
|
const Zeus::CTransform& CElementGen::GetGlobalOrientation() const
|
|
|
|
{
|
|
|
|
return x1d8_globalOrientation;
|
|
|
|
}
|
|
|
|
|
|
|
|
const Zeus::CVector3f& CElementGen::GetGlobalTranslation() const
|
|
|
|
{
|
|
|
|
return x88_globalTranslation;
|
|
|
|
}
|
|
|
|
|
2016-02-09 22:52:33 +00:00
|
|
|
const Zeus::CVector3f& CElementGen::GetGlobalScale() const
|
|
|
|
{
|
2016-02-13 05:16:39 +00:00
|
|
|
return xa0_globalScale;
|
2016-02-09 22:52:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const Zeus::CColor& CElementGen::GetModulationColor() const
|
|
|
|
{
|
2016-02-13 05:16:39 +00:00
|
|
|
return x30c_moduColor;
|
2016-02-09 22:52:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CElementGen::IsSystemDeletable() const
|
|
|
|
{
|
2016-02-13 05:16:39 +00:00
|
|
|
for (const std::unique_ptr<CElementGen>& ch : x234_activePartChildren)
|
|
|
|
if (!ch->IsSystemDeletable())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
for (const std::unique_ptr<CElementGen>& ch : x248_finishPartChildren)
|
|
|
|
if (!ch->IsSystemDeletable())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
for (const std::unique_ptr<CParticleSwoosh>& ch : x260_swhcChildren)
|
|
|
|
if (!ch->IsSystemDeletable())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
for (const std::unique_ptr<CParticleElectric>& ch : x280_elscChildren)
|
|
|
|
if (!ch->IsSystemDeletable())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (x214_PSLT < x50_curFrame && x208_activeParticleCount == 0)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
2016-02-09 22:52:33 +00:00
|
|
|
}
|
|
|
|
|
2016-02-11 22:38:25 +00:00
|
|
|
std::pair<Zeus::CAABox, bool> CElementGen::GetBounds() const
|
2016-02-09 22:52:33 +00:00
|
|
|
{
|
2016-02-13 05:16:39 +00:00
|
|
|
if (GetParticleCountAll() == 0)
|
|
|
|
return {Zeus::CAABox(), false};
|
|
|
|
else
|
|
|
|
return {x2c4_systemBounds, true};
|
2016-02-09 22:52:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
u32 CElementGen::GetParticleCount() const
|
|
|
|
{
|
2016-02-13 05:16:39 +00:00
|
|
|
return x208_activeParticleCount;
|
2016-02-09 22:52:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CElementGen::SystemHasLight() const
|
|
|
|
{
|
2016-02-13 05:16:39 +00:00
|
|
|
return x2dc_lightType != LightType::None;
|
2016-02-09 22:52:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CLight CElementGen::GetLight() const
|
|
|
|
{
|
2016-02-13 05:16:39 +00:00
|
|
|
switch (x2dc_lightType)
|
|
|
|
{
|
|
|
|
case LightType::Directional:
|
|
|
|
return CLight::BuildDirectional(x2f4_LDIR.normalized(), x2e0_LCLR * x2e4_LINT);
|
|
|
|
case LightType::Spot:
|
|
|
|
return CLight::BuildSpot(x2e8_LOFF, x2f4_LDIR.normalized(), x2e0_LCLR * x2e4_LINT, x308_LSLA);
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
float quad = x300_falloffType == EFalloffType::Quadratic ? x304_LFOR : 0.f;
|
|
|
|
float linear = x300_falloffType == EFalloffType::Linear ? x304_LFOR : 0.f;
|
|
|
|
float constant = x300_falloffType == EFalloffType::Constant ? 1.f : 0.f;
|
|
|
|
return CLight::BuildCustom(x2e8_LOFF, {1.f, 0.f, 0.f}, x2e0_LCLR,
|
|
|
|
constant, linear, quad, x2e4_LINT, 0.f, 0.f);
|
|
|
|
}
|
|
|
|
}
|
2016-02-09 22:52:33 +00:00
|
|
|
}
|
|
|
|
|
2016-02-13 05:49:59 +00:00
|
|
|
bool CElementGen::GetParticleEmission() const
|
|
|
|
{
|
|
|
|
return x68_particleEmission;
|
|
|
|
}
|
|
|
|
|
2016-02-09 22:52:33 +00:00
|
|
|
void CElementGen::DestroyParticles()
|
|
|
|
{
|
2016-02-13 05:16:39 +00:00
|
|
|
for (CParticleListItem& p : x2c_particleLists)
|
|
|
|
{
|
|
|
|
g_StaticFreeList[++g_FreeIndex] = p.x0_partIdx;
|
|
|
|
g_StaticParticleList[p.x0_partIdx].x0_endFrame = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
x2c_particleLists.clear();
|
|
|
|
x3c_parentMatrices.clear();
|
|
|
|
|
|
|
|
for (const std::unique_ptr<CElementGen>& ch : x234_activePartChildren)
|
|
|
|
ch->DestroyParticles();
|
|
|
|
|
|
|
|
for (const std::unique_ptr<CElementGen>& ch : x248_finishPartChildren)
|
|
|
|
ch->DestroyParticles();
|
2016-02-09 22:52:33 +00:00
|
|
|
}
|
|
|
|
|
2016-02-08 05:10:17 +00:00
|
|
|
}
|