metaforce/Runtime/Particle/CDecal.cpp

76 lines
1.8 KiB
C++
Raw Normal View History

2016-08-04 22:24:28 +00:00
#include "CDecal.hpp"
namespace urde
{
2017-01-22 17:36:25 +00:00
CRandom16 CDecal::sDecalRandom(99);
bool CDecal::sMoveRedToAphaBuffer = false;
2016-08-04 22:24:28 +00:00
CDecal::CDecal(const TToken<CDecalDescription>& desc, const zeus::CTransform& xf)
: x0_description(desc),
xc_transform(xf),
x3c_decalQuad1(0, 0.f),
x48_decalQuad2(0, 0.f)
{
CGlobalRandom gr(sDecalRandom);
2017-01-22 17:36:25 +00:00
x5c_31_quad1Invalid = InitQuad(x3c_decalQuad1, x0_description.GetObj()->x0_Quad);
x5c_30_quad2Invalid = InitQuad(x48_decalQuad2, x0_description.GetObj()->x1c_Quad);
CDecalDescription* d = x0_description.GetObj();
if (d->x38_DMDL)
{
if (d->x48_DLFT)
d->x48_DLFT->GetValue(0, x54_lifetime);
else
x54_lifetime = 0x7FFFFF;
if (d->x50_DMRT)
d->x50_DMRT->GetValue(0, x60_rotation);
}
else
x5c_29_modelInvalid = true;
2016-08-04 22:24:28 +00:00
}
2017-01-22 17:36:25 +00:00
bool CDecal::InitQuad(CDecal::CQuadDecal& quad, const CDecalDescription::SQuadDescr& desc)
2016-08-04 22:24:28 +00:00
{
if (desc.x14_TEX)
{
if (desc.x0_LFT)
desc.x0_LFT->GetValue(0, quad.x4_lifetime);
else
quad.x4_lifetime = 0x7FFFFF;
if (desc.x8_ROT)
{
desc.x8_ROT->GetValue(0, quad.x8_rotation);
2017-01-22 17:36:25 +00:00
quad.x0_24_invalid = desc.x8_ROT->IsConstant();
2016-08-04 22:24:28 +00:00
}
if (desc.x4_SZE)
{
2017-01-22 17:36:25 +00:00
quad.x0_24_invalid = desc.x4_SZE->IsConstant();
float size = 1.f;
desc.x4_SZE->GetValue(0, size);
quad.x0_24_invalid = size <= 1.f;
2016-08-04 22:24:28 +00:00
}
2017-01-22 17:36:25 +00:00
if (desc.xc_OFF)
quad.x0_24_invalid = desc.xc_OFF->IsFastConstant();
return false;
2016-08-04 22:24:28 +00:00
}
2017-01-22 17:36:25 +00:00
quad.x0_24_invalid = false;
return true;
}
void CDecal::SetGlobalSeed(u16 seed)
{
sDecalRandom.SetSeed(seed);
2016-08-04 22:24:28 +00:00
}
2017-01-22 17:36:25 +00:00
void CDecal::SetMoveRedToAlphaBuffer(bool move)
{
sMoveRedToAphaBuffer = move;
}
2016-08-04 22:24:28 +00:00
}