feat(component): add section info array

This commit is contained in:
fallenoak 2025-10-22 00:04:18 -05:00
parent 9e25e6246f
commit 904782c8df
No known key found for this signature in database
GPG Key ID: 7628F8E61AEA070D
2 changed files with 33 additions and 0 deletions

View File

@ -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;

View File

@ -3,6 +3,7 @@
#include "component/Types.hpp"
#include "gx/Texture.hpp"
#include <tempest/Vector.hpp>
#include <cstdint>
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;