diff options
| author | inspectredc <inspectredc@gmail.com> | 2024-04-01 02:47:17 +0100 |
|---|---|---|
| committer | Lywx <kiritodev01@gmail.com> | 2024-03-31 19:54:13 -0600 |
| commit | c2303489e81fb2c4d496822d9856e7665fefd45e (patch) | |
| tree | 29b985f2ab03d242cfc2303dee87edb68c301f89 | |
| parent | c9385ad3649599f953a8d50c35d3d67aff2b7ae7 (diff) | |
better formatting for structs
| -rw-r--r-- | src/factories/GenericArrayFactory.cpp | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/factories/GenericArrayFactory.cpp b/src/factories/GenericArrayFactory.cpp index e1c5149..e5d6e0f 100644 --- a/src/factories/GenericArrayFactory.cpp +++ b/src/factories/GenericArrayFactory.cpp @@ -47,6 +47,24 @@ std::unordered_map<ArrayType, size_t> typeSizeMap = { { ArrayType::Vec4s, 8 }, }; +std::unordered_map<ArrayType, size_t> structCountMap = { + { ArrayType::u8, 1 }, + { ArrayType::s8, 1 }, + { ArrayType::u16, 1 }, + { ArrayType::s16, 1 }, + { ArrayType::u32, 1 }, + { ArrayType::s32, 1 }, + { ArrayType::u64, 1 }, + { ArrayType::f32, 1 }, + { ArrayType::f64, 1 }, + { ArrayType::Vec2f, 2 }, + { ArrayType::Vec3f, 3 }, + { ArrayType::Vec3s, 3 }, + { ArrayType::Vec3i, 3 }, + { ArrayType::Vec4f, 4 }, + { ArrayType::Vec4s, 4 }, +}; + static int GetPrecision(float f) { int p = 0; int shift = 1; @@ -161,7 +179,7 @@ ExportResult ArrayCodeExporter::Export(std::ostream &write, std::shared_ptr<IPar write << type << " " << symbol << "[] = {"; - int columnCount = 120 / (array->mMaxWidth + 8); + int columnCount = 120 / (structCountMap.at(arrayType) * array->mMaxWidth + 8); int i = 0; for (auto &datum : array->mData) { if ((i++ % columnCount) == 0) { |
