mirror of https://github.com/AxioDL/metaforce.git
CIntElement: Add class to handle RTOI int elements
Within the int element handling code, there seems to be a missing implementation (with the FourCC 'RTOI'), which seems to take two 32-bit floating point values, multiplies them, then converts the result to a 32-bit integer.
This commit is contained in:
parent
5f0f3ea45c
commit
8b58cdc268
|
@ -284,4 +284,20 @@ int CIESubtract::GetMaxValue() const {
|
||||||
return a - b;
|
return a - b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CIERealToInt::GetValue(int frame, int& valOut) const {
|
||||||
|
float a = 0.0f;
|
||||||
|
float b = 1.0f;
|
||||||
|
|
||||||
|
x8_b->GetValue(frame, b);
|
||||||
|
x4_a->GetValue(frame, a);
|
||||||
|
|
||||||
|
valOut = static_cast<int>(a * b);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CIERealToInt::GetMaxValue() const {
|
||||||
|
// TODO: Implement
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace urde
|
} // namespace urde
|
||||||
|
|
|
@ -206,4 +206,16 @@ public:
|
||||||
int GetMaxValue() const override;
|
int GetMaxValue() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class CIERealToInt final : public CIntElement {
|
||||||
|
std::unique_ptr<CRealElement> x4_a;
|
||||||
|
std::unique_ptr<CRealElement> x8_b;
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit CIERealToInt(std::unique_ptr<CRealElement>&& a, std::unique_ptr<CRealElement>&& b)
|
||||||
|
: x4_a{std::move(a)}, x8_b{std::move(b)} {}
|
||||||
|
|
||||||
|
bool GetValue(int frame, int& valOut) const override;
|
||||||
|
int GetMaxValue() const override;
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace urde
|
} // namespace urde
|
||||||
|
|
|
@ -666,6 +666,11 @@ std::unique_ptr<CIntElement> CParticleDataFactory::GetIntElement(CInputStream& i
|
||||||
auto b = GetIntElement(in);
|
auto b = GetIntElement(in);
|
||||||
return std::make_unique<CIERandom>(std::move(a), std::move(b));
|
return std::make_unique<CIERandom>(std::move(a), std::move(b));
|
||||||
}
|
}
|
||||||
|
case SBIG('RTOI'): {
|
||||||
|
auto a = GetRealElement(in);
|
||||||
|
auto b = GetRealElement(in);
|
||||||
|
return std::make_unique<CIERealToInt>(std::move(a), std::move(b));
|
||||||
|
}
|
||||||
case SBIG('TSCL'): {
|
case SBIG('TSCL'): {
|
||||||
auto a = GetRealElement(in);
|
auto a = GetRealElement(in);
|
||||||
return std::make_unique<CIETimeScale>(std::move(a));
|
return std::make_unique<CIETimeScale>(std::move(a));
|
||||||
|
|
Loading…
Reference in New Issue