mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-09 04:27:42 +00:00
All MP1 element decls in
This commit is contained in:
@@ -0,0 +1,109 @@
|
||||
#include "CRealElement.hpp"
|
||||
#include "CParticleGlobals.hpp"
|
||||
|
||||
namespace Retro
|
||||
{
|
||||
|
||||
CREKeyframeEmitter::CREKeyframeEmitter(CInputStream& in)
|
||||
{
|
||||
x4_percent = in.readUint32Big();
|
||||
x8_a = in.readUint32Big();
|
||||
xc_b = in.readBool();
|
||||
xd_c = in.readBool();
|
||||
x10_d = in.readUint32Big();
|
||||
x14_e = in.readUint32Big();
|
||||
|
||||
u32 count = in.readUint32Big();
|
||||
x18_keys.reserve(count);
|
||||
for (u32 i=0 ; i<count ; ++i)
|
||||
x18_keys.push_back(in.readFloatBig());
|
||||
}
|
||||
|
||||
bool CREKeyframeEmitter::GetValue(int frame, float& valOut) const
|
||||
{
|
||||
if (!x4_percent)
|
||||
{
|
||||
int emitterTime = CParticleGlobals::g_emitterTimeInt;
|
||||
int calcKey = emitterTime;
|
||||
if (xc_b)
|
||||
{
|
||||
if (emitterTime >= x10_d)
|
||||
{
|
||||
int v1 = emitterTime - x14_e;
|
||||
int v2 = x10_d - x14_e;
|
||||
calcKey = v1 / v2;
|
||||
calcKey *= v2;
|
||||
calcKey = v1 - calcKey;
|
||||
calcKey += x14_e;
|
||||
}
|
||||
valOut = x18_keys[calcKey];
|
||||
}
|
||||
else
|
||||
{
|
||||
int x10_d_m1 = x10_d - 1;
|
||||
if (x10_d_m1 < calcKey)
|
||||
calcKey = x10_d_m1;
|
||||
valOut = x18_keys[calcKey];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int ltPerc = CParticleGlobals::g_particleLifetimePercentTweenInt;
|
||||
float ltPercRem = CParticleGlobals::g_particleLifetimePercentTweenIntFloatRem;
|
||||
if (ltPerc == 100)
|
||||
valOut = x18_keys[100];
|
||||
else
|
||||
valOut = x18_keys[ltPerc+1] * ltPercRem + (1.0f - ltPercRem) * x18_keys[ltPerc];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CRELifetimeTween::GetValue(int frame, float& valOut) const
|
||||
{
|
||||
float ltFac = frame / CParticleGlobals::g_particleLifetimeFloat;
|
||||
float a, b;
|
||||
x4_a->GetValue(frame, a);
|
||||
x8_b->GetValue(frame, b);
|
||||
valOut = b * ltFac + (1.0f - ltFac) * a;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CREConstant::GetValue(int frame, float& valOut) const
|
||||
{
|
||||
valOut = x4_val;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CRETimeChain::GetValue(int frame, float& valOut) const
|
||||
{
|
||||
int v;
|
||||
xc_c->GetValue(frame, v);
|
||||
if (frame >= v)
|
||||
return x8_b->GetValue(frame, valOut);
|
||||
else
|
||||
return x4_a->GetValue(frame, valOut);
|
||||
}
|
||||
|
||||
bool CREAdd::GetValue(int frame, float& valOut) const
|
||||
{
|
||||
float a, b;
|
||||
x4_a->GetValue(frame, a);
|
||||
x8_b->GetValue(frame, b);
|
||||
valOut = a + b;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CREClamp::GetValue(int frame, float &valOut) const
|
||||
{
|
||||
float a, b;
|
||||
x4_a->GetValue(frame, a);
|
||||
x8_b->GetValue(frame, b);
|
||||
xc_c->GetValue(frame, valOut);
|
||||
if (valOut > b)
|
||||
valOut = b;
|
||||
if (valOut < a)
|
||||
valOut = a;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user