From 904782c8df6fb11e5bcd49b8dbaafa37083e4218 Mon Sep 17 00:00:00 2001 From: fallenoak Date: Wed, 22 Oct 2025 00:04:18 -0500 Subject: [PATCH] feat(component): add section info array --- src/component/CCharacterComponent.cpp | 25 +++++++++++++++++++++++++ src/component/CCharacterComponent.hpp | 8 ++++++++ 2 files changed, 33 insertions(+) diff --git a/src/component/CCharacterComponent.cpp b/src/component/CCharacterComponent.cpp index 5a14f72..c11191c 100644 --- a/src/component/CCharacterComponent.cpp +++ b/src/component/CCharacterComponent.cpp @@ -14,10 +14,24 @@ uint32_t CCharacterComponent::s_chrVarArrayLength; EGxTexFormat CCharacterComponent::s_gxFormat; uint32_t CCharacterComponent::s_mipLevels; PREP_FUNC* CCharacterComponent::s_prepFunc[]; +CompSectionInfo CCharacterComponent::s_sectionInfo[]; MipBits* CCharacterComponent::s_textureBuffer; MipBits* CCharacterComponent::s_textureBufferCompressed; uint32_t CCharacterComponent::s_textureSize; +CompSectionInfo CCharacterComponent::s_sectionInfoRaw[] = { + { 0, 0, 256, 128 }, // SECTION_ARM_UPPER + { 0, 128, 256, 128 }, // SECTION_ARM_LOWER + { 0, 256, 256, 64 }, // SECTION_HAND + { 256, 0, 256, 128 }, // SECTION_TORSO_UPPER + { 256, 128, 256, 64 }, // SECTION_TORSO_LOWER + { 256, 192, 256, 128 }, // SECTION_LEG_UPPER + { 256, 320, 256, 128 }, // SECTION_LEG_LOWER + { 256, 448, 256, 64 }, // SECTION_FOOT + { 0, 320, 256, 64 }, // SECTION_HEAD_UPPER + { 0, 384, 256, 128 }, // SECTION_HEAD_LOWER +}; + int32_t s_bInRenderPrep = 0; char* s_pathEnd; char s_path[STORM_MAX_PATH]; @@ -65,6 +79,17 @@ void CCharacterComponent::Initialize(EGxTexFormat textureFormat, uint32_t textur CCharacterComponent::s_mipLevels = mipLevels; CCharacterComponent::s_textureSize = 1 << mipLevels; + // Scale section info to match mip levels + for (int32_t i = 0; i < NUM_COMPONENT_VARIATIONS; i++) { + auto& info = CCharacterComponent::s_sectionInfo[i]; + auto& infoRaw = CCharacterComponent::s_sectionInfoRaw[i]; + + info.pos.x = infoRaw.pos.x >> (9 - mipLevels); + info.pos.y = infoRaw.pos.y >> (9 - mipLevels); + info.size.x = infoRaw.size.x >> (9 - mipLevels); + info.size.y = infoRaw.size.y >> (9 - mipLevels); + } + // TODO CCharacterComponent::s_gxFormat = textureFormat; diff --git a/src/component/CCharacterComponent.hpp b/src/component/CCharacterComponent.hpp index 9d84e49..866f8ce 100644 --- a/src/component/CCharacterComponent.hpp +++ b/src/component/CCharacterComponent.hpp @@ -3,6 +3,7 @@ #include "component/Types.hpp" #include "gx/Texture.hpp" +#include #include class CACHEENTRY; @@ -51,6 +52,11 @@ struct ComponentData { }; }; +struct CompSectionInfo { + C2iVector pos; + C2iVector size; +}; + class CCharacterComponent { public: // Static variables @@ -59,6 +65,8 @@ class CCharacterComponent { static EGxTexFormat s_gxFormat; static uint32_t s_mipLevels; static PREP_FUNC* s_prepFunc[NUM_COMPONENT_SECTIONS]; + static CompSectionInfo s_sectionInfo[NUM_COMPONENT_SECTIONS]; + static CompSectionInfo s_sectionInfoRaw[NUM_COMPONENT_SECTIONS]; static MipBits* s_textureBuffer; static MipBits* s_textureBufferCompressed; static uint32_t s_textureSize;