feat(model): load attachments in CM2Model::InitializeLoaded

This commit is contained in:
fallenoak 2025-10-13 12:03:38 -05:00
parent 4168a96bd2
commit 67264fbaf6
No known key found for this signature in database
GPG Key ID: 7628F8E61AEA070D
3 changed files with 20 additions and 2 deletions

View File

@ -970,7 +970,19 @@ int32_t CM2Model::InitializeLoaded() {
} }
} }
// TODO // TODO texture transforms
if (this->m_shared->m_data->attachments.Count()) {
this->m_attachments = reinterpret_cast<M2ModelAttachment*>(&data[0]);
data += (sizeof(M2ModelAttachment) * this->m_shared->m_data->attachments.Count());
for (int32_t i = 0; i < this->m_shared->m_data->attachments.Count(); i++) {
new (&this->m_attachments[i]) M2ModelAttachment();
auto& modelAttachment = this->m_attachments[i];
modelAttachment.visible = true;
}
}
if (this->m_shared->m_data->lights.Count()) { if (this->m_shared->m_data->lights.Count()) {
this->m_lights = reinterpret_cast<M2ModelLight*>(&data[0]); this->m_lights = reinterpret_cast<M2ModelLight*>(&data[0]);

View File

@ -13,6 +13,7 @@ class CM2Scene;
class CM2Shared; class CM2Shared;
struct M2Batch; struct M2Batch;
struct M2Data; struct M2Data;
struct M2ModelAttachment;
struct M2ModelBone; struct M2ModelBone;
struct M2ModelBoneSeq; struct M2ModelBoneSeq;
struct M2ModelCamera; struct M2ModelCamera;
@ -82,7 +83,7 @@ class CM2Model {
CM2Model** m_animatePrev = nullptr; CM2Model** m_animatePrev = nullptr;
CM2Model* m_animateNext = nullptr; CM2Model* m_animateNext = nullptr;
CM2Model* m_attachParent = nullptr; CM2Model* m_attachParent = nullptr;
// TODO m_attachments; (presumably M2ModelAttachment) M2ModelAttachment* m_attachments = nullptr;
uint32_t m_attachId = -1; uint32_t m_attachId = -1;
uint32_t m_attachIndex = 0xFFFF; uint32_t m_attachIndex = 0xFFFF;
CM2Model* m_attachList = nullptr; CM2Model* m_attachList = nullptr;

View File

@ -10,6 +10,8 @@
template<class T> template<class T>
class M2Track; class M2Track;
class CM2Model;
template<class T> template<class T>
struct M2ModelTrack { struct M2ModelTrack {
uint32_t currentKey = 0; uint32_t currentKey = 0;
@ -18,6 +20,9 @@ struct M2ModelTrack {
}; };
struct M2ModelAttachment { struct M2ModelAttachment {
CM2Model* model = nullptr;
int32_t linkPoint = 0;
bool visible = false;
}; };
struct M2ModelBoneSeq { struct M2ModelBoneSeq {