mirror of
https://github.com/whoahq/whoa.git
synced 2026-02-02 00:32:45 +03:00
feat(component): use ObjectAlloc to allocate CCharacterComponent
This commit is contained in:
parent
f5aa37368a
commit
0fce98aabc
@ -8,6 +8,7 @@
|
|||||||
#include "model/CM2Model.hpp"
|
#include "model/CM2Model.hpp"
|
||||||
#include "object/Types.hpp"
|
#include "object/Types.hpp"
|
||||||
#include "util/CStatus.hpp"
|
#include "util/CStatus.hpp"
|
||||||
|
#include <common/ObjectAlloc.hpp>
|
||||||
#include <storm/Memory.hpp>
|
#include <storm/Memory.hpp>
|
||||||
#include <storm/String.hpp>
|
#include <storm/String.hpp>
|
||||||
|
|
||||||
@ -70,6 +71,7 @@ int32_t s_itemPriority[NUM_ITEM_SLOT][NUM_COMPONENT_SECTIONS] = {
|
|||||||
#define SECTION_HL_ITEM_PRIORITIES 0
|
#define SECTION_HL_ITEM_PRIORITIES 0
|
||||||
|
|
||||||
int32_t s_bInRenderPrep = 0;
|
int32_t s_bInRenderPrep = 0;
|
||||||
|
uint32_t* s_componentHeap;
|
||||||
char* s_pathEnd;
|
char* s_pathEnd;
|
||||||
char s_path[STORM_MAX_PATH];
|
char s_path[STORM_MAX_PATH];
|
||||||
CStatus s_status;
|
CStatus s_status;
|
||||||
@ -77,8 +79,17 @@ CStatus s_status;
|
|||||||
#define TEXTURE_INDEX(section, texture) (3 * section + texture)
|
#define TEXTURE_INDEX(section, texture) (3 * section + texture)
|
||||||
|
|
||||||
CCharacterComponent* CCharacterComponent::AllocComponent() {
|
CCharacterComponent* CCharacterComponent::AllocComponent() {
|
||||||
// TODO ObjectAlloc
|
uint32_t memHandle;
|
||||||
return STORM_NEW(CCharacterComponent);
|
void* mem;
|
||||||
|
|
||||||
|
if (!ObjectAlloc(*s_componentHeap, &memHandle, &mem, false)) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto component = new (mem) CCharacterComponent();
|
||||||
|
component->m_memHandle = memHandle;
|
||||||
|
|
||||||
|
return component;
|
||||||
}
|
}
|
||||||
|
|
||||||
HTEXTURE CCharacterComponent::CreateTexture(const char* fileName, CStatus* status) {
|
HTEXTURE CCharacterComponent::CreateTexture(const char* fileName, CStatus* status) {
|
||||||
@ -94,7 +105,12 @@ void CCharacterComponent::Initialize() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CCharacterComponent::Initialize(EGxTexFormat textureFormat, uint32_t textureLevel, int32_t thread, int32_t compress) {
|
void CCharacterComponent::Initialize(EGxTexFormat textureFormat, uint32_t textureLevel, int32_t thread, int32_t compress) {
|
||||||
// TODO
|
if (!s_componentHeap) {
|
||||||
|
auto heapId = static_cast<uint32_t*>(STORM_ALLOC(sizeof(uint32_t)));
|
||||||
|
*heapId = ObjectAllocAddHeap(sizeof(CCharacterComponent), 32, "CCharacterComponent", true);
|
||||||
|
|
||||||
|
s_componentHeap = heapId;
|
||||||
|
}
|
||||||
|
|
||||||
s_pathEnd = s_path;
|
s_pathEnd = s_path;
|
||||||
|
|
||||||
|
|||||||
@ -71,6 +71,7 @@ class CCharacterComponent {
|
|||||||
// Member variables
|
// Member variables
|
||||||
uint32_t m_flags = 0x1 | 0x2 | 0x4;
|
uint32_t m_flags = 0x1 | 0x2 | 0x4;
|
||||||
uint32_t m_sectionDirty = 0xFFFFFFFF;
|
uint32_t m_sectionDirty = 0xFFFFFFFF;
|
||||||
|
uint32_t m_memHandle;
|
||||||
EGxTexFormat m_textureFormat = CCharacterComponent::s_gxFormat;
|
EGxTexFormat m_textureFormat = CCharacterComponent::s_gxFormat;
|
||||||
ComponentData m_data;
|
ComponentData m_data;
|
||||||
HTEXTURE m_baseTexture = nullptr;
|
HTEXTURE m_baseTexture = nullptr;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user