From 24633ebd7cc6866da3e3d06fddc6f0f49a741f1d Mon Sep 17 00:00:00 2001 From: MegaMech Date: Sat, 6 Apr 2024 15:36:03 -0600 Subject: Introduce Metadata and ItemCurve Factories (#27) * Introduce metadata * Metadata works now * Cleanup * Fixes * Cleanup 2 * yaml improvement * Comment update * Rename tables to metadata * Update * Fix warnings * Implement ItemCurve * Remove unused enum * Replace static with const * Fix bug * Add const * More fixes * Fix quote bug in IncludeFactory * Fix header in ItemCurve * Fixes * Fix texture factory * updates * Clearer debug info * Fixes * Working ci8 png * Fix size output * Fix * Add gitignore for modding * Fix precision for mtx * Remove header exporter from metadata * Remove hardcoded enum * Remove tabs * Remove tabs * tlut temp fix --------- Co-authored-by: = <=> --- src/factories/GenericArrayFactory.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'src/factories/GenericArrayFactory.cpp') diff --git a/src/factories/GenericArrayFactory.cpp b/src/factories/GenericArrayFactory.cpp index 81144f5..a8b502a 100644 --- a/src/factories/GenericArrayFactory.cpp +++ b/src/factories/GenericArrayFactory.cpp @@ -24,6 +24,7 @@ std::unordered_map arrayTypeMap = { { "Vec3f", ArrayType::Vec3f }, { "Vec3s", ArrayType::Vec3s }, { "Vec3i", ArrayType::Vec3i }, + { "Vec3iu", ArrayType::Vec3iu }, { "Vec4f", ArrayType::Vec4f }, { "Vec4s", ArrayType::Vec4s }, }; @@ -42,6 +43,7 @@ std::unordered_map typeSizeMap = { { ArrayType::Vec3f, 12 }, { ArrayType::Vec3s, 6 }, { ArrayType::Vec3i, 12 }, + { ArrayType::Vec3iu, 12 }, { ArrayType::Vec4f, 16 }, { ArrayType::Vec4s, 8 }, }; @@ -60,6 +62,7 @@ std::unordered_map structCountMap = { { ArrayType::Vec3f, 3 }, { ArrayType::Vec3s, 3 }, { ArrayType::Vec3i, 3 }, + { ArrayType::Vec3iu, 3 }, { ArrayType::Vec4f, 4 }, { ArrayType::Vec4s, 4 }, }; @@ -140,6 +143,10 @@ GenericArray::GenericArray(std::vector data) : mData(std::move(data) mMaxWidth = std::max(mMaxWidth, (uint32_t)std::get(datum).width()); break; } + case ArrayType::Vec3iu: { + mMaxWidth = std::max(mMaxWidth, (uint32_t)std::get(datum).width()); + break; + } case ArrayType::Vec4f: { mMaxWidth = std::max(mMaxWidth,(uint32_t)std::get(datum).width()); mMaxPrec = std::max(mMaxPrec, (uint32_t)std::get(datum).precision()); @@ -230,6 +237,9 @@ ExportResult ArrayCodeExporter::Export(std::ostream &write, std::shared_ptr(datum), array->mMaxWidth) << ", "; break; + case ArrayType::Vec3iu: + write << FORMAT_INT(std::get(datum), array->mMaxWidth) << ", "; + break; case ArrayType::Vec4f: write << FORMAT_FLOAT(std::get(datum), array->mMaxWidth, array->mMaxPrec) << ", "; break; @@ -372,12 +382,13 @@ std::optional> GenericArrayFactory::parse(std::vect for (int i = 0; i < count; i++) { switch (arrayType) { case ArrayType::u8: { - auto x = reader.ReadUByte(); + uint8_t x = reader.ReadUByte(); data.emplace_back(x); + SPDLOG_INFO("HERE"); break; } case ArrayType::s8: { - auto x = reader.ReadInt8(); + int8_t x = reader.ReadInt8(); data.emplace_back(x); break; } @@ -447,6 +458,14 @@ std::optional> GenericArrayFactory::parse(std::vect data.emplace_back(Vec3i(vx, vy, vz)); break; } + case ArrayType::Vec3iu: { + auto vx = reader.ReadUInt32(); + auto vy = reader.ReadUInt32(); + auto vz = reader.ReadUInt32(); + + data.emplace_back(Vec3iu(vx, vy, vz)); + break; + } case ArrayType::Vec4f: { auto vx = reader.ReadFloat(); auto vy = reader.ReadFloat(); -- cgit v1.2.3