Add CIEDeath from MP2/3

This commit is contained in:
Phillip Stephens 2021-06-10 14:19:59 -07:00
parent 073af40c4d
commit 2369083b50
Signed by: Antidote
GPG Key ID: F8BEE4C83DACA60D
4 changed files with 74 additions and 40 deletions

View File

@ -53,7 +53,7 @@ bool CIEKeyframeEmitter::GetValue([[maybe_unused]] int frame, int& valOut) const
return false;
}
int CIEKeyframeEmitter::GetMaxValue() const { return *std::max_element(x18_keys.cbegin(), x18_keys.cend()); }
// int CIEKeyframeEmitter::GetMaxValue() const { return *std::max_element(x18_keys.cbegin(), x18_keys.cend()); }
bool CIEDeath::GetValue(int frame, int& valOut) const {
x4_a->GetValue(frame, valOut);
@ -63,7 +63,7 @@ bool CIEDeath::GetValue(int frame, int& valOut) const {
return frame > b;
}
int CIEDeath::GetMaxValue() const { return x4_a->GetMaxValue(); }
// int CIEDeath::GetMaxValue() const { return x4_a->GetMaxValue(); }
bool CIEClamp::GetValue(int frame, int& valOut) const {
int a, b;
@ -74,7 +74,7 @@ bool CIEClamp::GetValue(int frame, int& valOut) const {
valOut = std::clamp(valOut, a, b);
return false;
}
/*
int CIEClamp::GetMaxValue() const {
const int a = x4_min->GetMaxValue();
const int b = x8_max->GetMaxValue();
@ -82,6 +82,7 @@ int CIEClamp::GetMaxValue() const {
return std::clamp(valOut, a, b);
}
*/
bool CIETimeChain::GetValue(int frame, int& valOut) const {
int v;
@ -92,7 +93,7 @@ bool CIETimeChain::GetValue(int frame, int& valOut) const {
return x4_a->GetValue(frame, valOut);
}
int CIETimeChain::GetMaxValue() const { return std::max(x8_b->GetMaxValue(), x4_a->GetMaxValue()); }
// int CIETimeChain::GetMaxValue() const { return std::max(x8_b->GetMaxValue(), x4_a->GetMaxValue()); }
bool CIEAdd::GetValue(int frame, int& valOut) const {
int a, b;
@ -102,18 +103,20 @@ bool CIEAdd::GetValue(int frame, int& valOut) const {
return false;
}
/*
int CIEAdd::GetMaxValue() const {
const int a = x4_a->GetMaxValue();
const int b = x8_b->GetMaxValue();
return a + b;
}
*/
bool CIEConstant::GetValue([[maybe_unused]] int frame, int& valOut) const {
valOut = x4_val;
return false;
}
int CIEConstant::GetMaxValue() const { return x4_val; }
// int CIEConstant::GetMaxValue() const { return x4_val; }
bool CIEImpulse::GetValue(int frame, int& valOut) const {
if (frame == 0)
@ -123,7 +126,7 @@ bool CIEImpulse::GetValue(int frame, int& valOut) const {
return false;
}
int CIEImpulse::GetMaxValue() const { return x4_a->GetMaxValue(); }
// int CIEImpulse::GetMaxValue() const { return x4_a->GetMaxValue(); }
bool CIELifetimePercent::GetValue(int frame, int& valOut) const {
int a;
@ -133,12 +136,14 @@ bool CIELifetimePercent::GetValue(int frame, int& valOut) const {
return false;
}
/*
int CIELifetimePercent::GetMaxValue() const {
const int a = std::max(0, x4_percentVal->GetMaxValue());
// Assume 10000 frames max (not ideal estimate)
return int((float(a) / 100.0f) * 10000 + 0.5f);
}
*/
bool CIEInitialRandom::GetValue(int frame, int& valOut) const {
if (frame == 0) {
@ -150,7 +155,7 @@ bool CIEInitialRandom::GetValue(int frame, int& valOut) const {
return false;
}
int CIEInitialRandom::GetMaxValue() const { return x8_b->GetMaxValue(); }
// int CIEInitialRandom::GetMaxValue() const { return x8_b->GetMaxValue(); }
bool CIEPulse::GetValue(int frame, int& valOut) const {
int a, b;
@ -169,7 +174,7 @@ bool CIEPulse::GetValue(int frame, int& valOut) const {
return false;
}
int CIEPulse::GetMaxValue() const { return std::max(xc_aVal->GetMaxValue(), x10_bVal->GetMaxValue()); }
// int CIEPulse::GetMaxValue() const { return std::max(xc_aVal->GetMaxValue(), x10_bVal->GetMaxValue()); }
bool CIEMultiply::GetValue(int frame, int& valOut) const {
int a, b;
@ -179,7 +184,16 @@ bool CIEMultiply::GetValue(int frame, int& valOut) const {
return false;
}
int CIEMultiply::GetMaxValue() const { return x4_a->GetMaxValue() * x8_b->GetMaxValue(); }
// int CIEMultiply::GetMaxValue() const { return x4_a->GetMaxValue() * x8_b->GetMaxValue(); }
bool CIEDivide::GetValue(s32 frame, s32& out) const {
int divisor = 0;
int dividend = 0;
x4_dividend->GetValue(frame, dividend);
x8_divisor->GetValue(frame, divisor);
out = divisor == 0 ? dividend : dividend / divisor;
return false;
}
bool CIESampleAndHold::GetValue(int frame, int& valOut) const {
if (x8_nextSampleFrame < frame) {
@ -195,7 +209,7 @@ bool CIESampleAndHold::GetValue(int frame, int& valOut) const {
return false;
}
int CIESampleAndHold::GetMaxValue() const { return x4_sampleSource->GetMaxValue(); }
// int CIESampleAndHold::GetMaxValue() const { return x4_sampleSource->GetMaxValue(); }
bool CIERandom::GetValue(int frame, int& valOut) const {
int a, b;
@ -207,13 +221,14 @@ bool CIERandom::GetValue(int frame, int& valOut) const {
valOut = CRandom16::GetRandomNumber()->Next();
return false;
}
/*
int CIERandom::GetMaxValue() const {
if (x4_min->GetMaxValue() > 0)
return x8_max->GetMaxValue();
else
return 65535;
}
*/
bool CIETimeScale::GetValue(int frame, int& valOut) const {
float a;
@ -222,28 +237,28 @@ bool CIETimeScale::GetValue(int frame, int& valOut) const {
return false;
}
int CIETimeScale::GetMaxValue() const { return 10000; /* Assume 10000 frames max (not ideal estimate) */ }
// int CIETimeScale::GetMaxValue() const { return 10000; /* Assume 10000 frames max (not ideal estimate) */ }
bool CIEGetCumulativeParticleCount::GetValue([[maybe_unused]] int frame, int& valOut) const {
valOut = CParticleGlobals::instance()->m_currentParticleSystem->x4_system->GetCumulativeParticleCount();
return false;
}
int CIEGetCumulativeParticleCount::GetMaxValue() const { return 256; }
// int CIEGetCumulativeParticleCount::GetMaxValue() const { return 256; }
bool CIEGetActiveParticleCount::GetValue([[maybe_unused]] int frame, int& valOut) const {
valOut = CParticleGlobals::instance()->m_currentParticleSystem->x4_system->GetParticleCount();
return false;
}
int CIEGetActiveParticleCount::GetMaxValue() const { return 256; }
// int CIEGetActiveParticleCount::GetMaxValue() const { return 256; }
bool CIEGetEmitterTime::GetValue([[maybe_unused]] int frame, int& valOut) const {
valOut = CParticleGlobals::instance()->m_currentParticleSystem->x4_system->GetEmitterTime();
return false;
}
int CIEGetEmitterTime::GetMaxValue() const { return 10000; /* Assume 10000 frames max (not ideal estimate) */ }
// int CIEGetEmitterTime::GetMaxValue() const { return 10000; /* Assume 10000 frames max (not ideal estimate) */ }
bool CIEModulo::GetValue(int frame, int& valOut) const {
int a, b;
@ -255,7 +270,7 @@ bool CIEModulo::GetValue(int frame, int& valOut) const {
valOut = a;
return false;
}
/*
int CIEModulo::GetMaxValue() const {
const int a = x4_a->GetMaxValue();
const int b = x8_b->GetMaxValue();
@ -266,6 +281,7 @@ int CIEModulo::GetMaxValue() const {
return a;
}
*/
bool CIESubtract::GetValue(int frame, int& valOut) const {
int a, b;
@ -274,13 +290,13 @@ bool CIESubtract::GetValue(int frame, int& valOut) const {
valOut = a - b;
return false;
}
/*
int CIESubtract::GetMaxValue() const {
const int a = x4_a->GetMaxValue();
const int b = x8_b->GetMaxValue();
return a - b;
}
*/
bool CIERealToInt::GetValue(int frame, int& valOut) const {
float a = 0.0f;
float b = 1.0f;
@ -291,10 +307,11 @@ bool CIERealToInt::GetValue(int frame, int& valOut) const {
valOut = static_cast<int>(a * b);
return false;
}
/*
int CIERealToInt::GetMaxValue() const {
// TODO: Implement
return 1;
}
*/
} // namespace metaforce

View File

@ -21,7 +21,7 @@ class CIEKeyframeEmitter : public CIntElement {
public:
explicit CIEKeyframeEmitter(CInputStream& in);
bool GetValue(int frame, int& valOut) const override;
int GetMaxValue() const override;
// int GetMaxValue() const override;
};
class CIEDeath : public CIntElement {
@ -32,7 +32,7 @@ public:
CIEDeath(std::unique_ptr<CIntElement>&& a, std::unique_ptr<CIntElement>&& b)
: x4_a(std::move(a)), x8_b(std::move(b)) {}
bool GetValue(int frame, int& valOut) const override;
int GetMaxValue() const override;
// int GetMaxValue() const override;
};
class CIEClamp : public CIntElement {
@ -44,7 +44,7 @@ public:
CIEClamp(std::unique_ptr<CIntElement>&& a, std::unique_ptr<CIntElement>&& b, std::unique_ptr<CIntElement>&& c)
: x4_min(std::move(a)), x8_max(std::move(b)), xc_val(std::move(c)) {}
bool GetValue(int frame, int& valOut) const override;
int GetMaxValue() const override;
// int GetMaxValue() const override;
};
class CIETimeChain : public CIntElement {
@ -56,7 +56,7 @@ public:
CIETimeChain(std::unique_ptr<CIntElement>&& a, std::unique_ptr<CIntElement>&& b, std::unique_ptr<CIntElement>&& c)
: x4_a(std::move(a)), x8_b(std::move(b)), xc_swFrame(std::move(c)) {}
bool GetValue(int frame, int& valOut) const override;
int GetMaxValue() const override;
// int GetMaxValue() const override;
};
class CIEAdd : public CIntElement {
@ -66,7 +66,7 @@ class CIEAdd : public CIntElement {
public:
CIEAdd(std::unique_ptr<CIntElement>&& a, std::unique_ptr<CIntElement>&& b) : x4_a(std::move(a)), x8_b(std::move(b)) {}
bool GetValue(int frame, int& valOut) const override;
int GetMaxValue() const override;
// int GetMaxValue() const override;
};
class CIEConstant : public CIntElement {
@ -75,7 +75,7 @@ class CIEConstant : public CIntElement {
public:
explicit CIEConstant(int val) : x4_val(val) {}
bool GetValue(int frame, int& valOut) const override;
int GetMaxValue() const override;
// int GetMaxValue() const override;
};
class CIEImpulse : public CIntElement {
@ -84,7 +84,7 @@ class CIEImpulse : public CIntElement {
public:
explicit CIEImpulse(std::unique_ptr<CIntElement>&& a) : x4_a(std::move(a)) {}
bool GetValue(int frame, int& valOut) const override;
int GetMaxValue() const override;
// int GetMaxValue() const override;
};
class CIELifetimePercent : public CIntElement {
@ -93,7 +93,7 @@ class CIELifetimePercent : public CIntElement {
public:
explicit CIELifetimePercent(std::unique_ptr<CIntElement>&& a) : x4_percentVal(std::move(a)) {}
bool GetValue(int frame, int& valOut) const override;
int GetMaxValue() const override;
// int GetMaxValue() const override;
};
class CIEInitialRandom : public CIntElement {
@ -104,7 +104,7 @@ public:
CIEInitialRandom(std::unique_ptr<CIntElement>&& a, std::unique_ptr<CIntElement>&& b)
: x4_a(std::move(a)), x8_b(std::move(b)) {}
bool GetValue(int frame, int& valOut) const override;
int GetMaxValue() const override;
// int GetMaxValue() const override;
};
class CIEPulse : public CIntElement {
@ -118,7 +118,7 @@ public:
std::unique_ptr<CIntElement>&& d)
: x4_aDuration(std::move(a)), x8_bDuration(std::move(b)), xc_aVal(std::move(c)), x10_bVal(std::move(d)) {}
bool GetValue(int frame, int& valOut) const override;
int GetMaxValue() const override;
// int GetMaxValue() const override;
};
class CIEMultiply : public CIntElement {
@ -129,7 +129,19 @@ public:
CIEMultiply(std::unique_ptr<CIntElement>&& a, std::unique_ptr<CIntElement>&& b)
: x4_a(std::move(a)), x8_b(std::move(b)) {}
bool GetValue(int frame, int& valOut) const override;
int GetMaxValue() const override;
// int GetMaxValue() const override;
};
class CIEDivide : public CIntElement {
std::unique_ptr<CIntElement> x4_dividend;
std::unique_ptr<CIntElement> x8_divisor;
public:
CIEDivide(std::unique_ptr<CIntElement>&& dividend, std::unique_ptr<CIntElement>&& divisor)
: x4_dividend(std::move(dividend)), x8_divisor(std::move(divisor)) {}
bool GetValue(int frame, int& valOut) const override;
// int GetMaxValue() const override { return 0; }
};
class CIESampleAndHold : public CIntElement {
@ -143,7 +155,7 @@ public:
CIESampleAndHold(std::unique_ptr<CIntElement>&& a, std::unique_ptr<CIntElement>&& b, std::unique_ptr<CIntElement>&& c)
: x4_sampleSource(std::move(a)), xc_waitFramesMin(std::move(b)), x10_waitFramesMax(std::move(c)) {}
bool GetValue(int frame, int& valOut) const override;
int GetMaxValue() const override;
// int GetMaxValue() const override;
};
class CIERandom : public CIntElement {
@ -154,7 +166,7 @@ public:
CIERandom(std::unique_ptr<CIntElement>&& a, std::unique_ptr<CIntElement>&& b)
: x4_min(std::move(a)), x8_max(std::move(b)) {}
bool GetValue(int frame, int& valOut) const override;
int GetMaxValue() const override;
// int GetMaxValue() const override;
};
class CIETimeScale : public CIntElement {
@ -163,25 +175,25 @@ class CIETimeScale : public CIntElement {
public:
explicit CIETimeScale(std::unique_ptr<CRealElement>&& a) : x4_a(std::move(a)) {}
bool GetValue(int frame, int& valOut) const override;
int GetMaxValue() const override;
// int GetMaxValue() const override;
};
class CIEGetCumulativeParticleCount : public CIntElement {
public:
bool GetValue(int frame, int& valOut) const override;
int GetMaxValue() const override;
// int GetMaxValue() const override;
};
class CIEGetActiveParticleCount : public CIntElement {
public:
bool GetValue(int frame, int& valOut) const override;
int GetMaxValue() const override;
// int GetMaxValue() const override;
};
class CIEGetEmitterTime : public CIntElement {
public:
bool GetValue(int frame, int& valOut) const override;
int GetMaxValue() const override;
// int GetMaxValue() const override;
};
class CIEModulo : public CIntElement {
@ -192,7 +204,7 @@ public:
CIEModulo(std::unique_ptr<CIntElement>&& a, std::unique_ptr<CIntElement>&& b)
: x4_a(std::move(a)), x8_b(std::move(b)) {}
bool GetValue(int frame, int& valOut) const override;
int GetMaxValue() const override;
// int GetMaxValue() const override;
};
class CIESubtract : public CIntElement {
@ -203,7 +215,7 @@ public:
CIESubtract(std::unique_ptr<CIntElement>&& a, std::unique_ptr<CIntElement>&& b)
: x4_a(std::move(a)), x8_b(std::move(b)) {}
bool GetValue(int frame, int& valOut) const override;
int GetMaxValue() const override;
// int GetMaxValue() const override;
};
class CIERealToInt final : public CIntElement {
@ -215,7 +227,7 @@ public:
: x4_a{std::move(a)}, x8_b{std::move(b)} {}
bool GetValue(int frame, int& valOut) const override;
int GetMaxValue() const override;
// int GetMaxValue() const override;
};
} // namespace metaforce

View File

@ -658,6 +658,11 @@ std::unique_ptr<CIntElement> CParticleDataFactory::GetIntElement(CInputStream& i
auto b = GetIntElement(in);
return std::make_unique<CIEMultiply>(std::move(a), std::move(b));
}
case SBIG('DIVD'): {
auto a = GetIntElement(in);
auto b = GetIntElement(in);
return std::make_unique<CIEDivide>(std::move(a), std::move(b));
}
case SBIG('SPAH'): {
auto a = GetIntElement(in);
auto b = GetIntElement(in);

View File

@ -24,7 +24,7 @@ public:
class CIntElement : public IElement {
public:
virtual bool GetValue(int frame, int& valOut) const = 0;
virtual int GetMaxValue() const = 0;
// virtual int GetMaxValue() const = 0; Deprecated and unused
};
class CVectorElement : public IElement {