summaryrefslogtreecommitdiff
path: root/src/factories/GenericArrayFactory.cpp
diff options
context:
space:
mode:
authorMegaMech <MegaMech@users.noreply.github.com>2024-04-06 15:36:03 -0600
committerGitHub <noreply@github.com>2024-04-06 15:36:03 -0600
commit24633ebd7cc6866da3e3d06fddc6f0f49a741f1d (patch)
tree357a563fae006b04ded941ee534b1d6522f3fc32 /src/factories/GenericArrayFactory.cpp
parentad667b705dad3476a1ae803f23588c55baab2ee4 (diff)
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: = <=>
Diffstat (limited to 'src/factories/GenericArrayFactory.cpp')
-rw-r--r--src/factories/GenericArrayFactory.cpp23
1 files changed, 21 insertions, 2 deletions
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<std::string, ArrayType> 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<ArrayType, size_t> 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<ArrayType, size_t> 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<ArrayDatum> data) : mData(std::move(data)
mMaxWidth = std::max(mMaxWidth, (uint32_t)std::get<Vec3i>(datum).width());
break;
}
+ case ArrayType::Vec3iu: {
+ mMaxWidth = std::max(mMaxWidth, (uint32_t)std::get<Vec3iu>(datum).width());
+ break;
+ }
case ArrayType::Vec4f: {
mMaxWidth = std::max(mMaxWidth,(uint32_t)std::get<Vec4f>(datum).width());
mMaxPrec = std::max(mMaxPrec, (uint32_t)std::get<Vec4f>(datum).precision());
@@ -230,6 +237,9 @@ ExportResult ArrayCodeExporter::Export(std::ostream &write, std::shared_ptr<IPar
case ArrayType::Vec3i:
write << FORMAT_INT(std::get<Vec3i>(datum), array->mMaxWidth) << ", ";
break;
+ case ArrayType::Vec3iu:
+ write << FORMAT_INT(std::get<Vec3iu>(datum), array->mMaxWidth) << ", ";
+ break;
case ArrayType::Vec4f:
write << FORMAT_FLOAT(std::get<Vec4f>(datum), array->mMaxWidth, array->mMaxPrec) << ", ";
break;
@@ -372,12 +382,13 @@ std::optional<std::shared_ptr<IParsedData>> 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<std::shared_ptr<IParsedData>> 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();