From 8b58cdc26810af360e20f2bb1210d77fd8fb18ad Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 6 Oct 2019 07:56:43 -0400 Subject: [PATCH] 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. --- Runtime/Particle/CIntElement.cpp | 16 ++++++++++++++++ Runtime/Particle/CIntElement.hpp | 12 ++++++++++++ Runtime/Particle/CParticleDataFactory.cpp | 5 +++++ 3 files changed, 33 insertions(+) diff --git a/Runtime/Particle/CIntElement.cpp b/Runtime/Particle/CIntElement.cpp index 9d9b5ead1..ccba3bb08 100644 --- a/Runtime/Particle/CIntElement.cpp +++ b/Runtime/Particle/CIntElement.cpp @@ -284,4 +284,20 @@ int CIESubtract::GetMaxValue() const { 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(a * b); + return false; +} + +int CIERealToInt::GetMaxValue() const { + // TODO: Implement + return 1; +} + } // namespace urde diff --git a/Runtime/Particle/CIntElement.hpp b/Runtime/Particle/CIntElement.hpp index 51bf481c1..4bcf2c96e 100644 --- a/Runtime/Particle/CIntElement.hpp +++ b/Runtime/Particle/CIntElement.hpp @@ -206,4 +206,16 @@ public: int GetMaxValue() const override; }; +class CIERealToInt final : public CIntElement { + std::unique_ptr x4_a; + std::unique_ptr x8_b; + +public: + explicit CIERealToInt(std::unique_ptr&& a, std::unique_ptr&& 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 diff --git a/Runtime/Particle/CParticleDataFactory.cpp b/Runtime/Particle/CParticleDataFactory.cpp index 83f761b96..df76addd0 100644 --- a/Runtime/Particle/CParticleDataFactory.cpp +++ b/Runtime/Particle/CParticleDataFactory.cpp @@ -666,6 +666,11 @@ std::unique_ptr CParticleDataFactory::GetIntElement(CInputStream& i auto b = GetIntElement(in); return std::make_unique(std::move(a), std::move(b)); } + case SBIG('RTOI'): { + auto a = GetRealElement(in); + auto b = GetRealElement(in); + return std::make_unique(std::move(a), std::move(b)); + } case SBIG('TSCL'): { auto a = GetRealElement(in); return std::make_unique(std::move(a));