diff --git a/Engine/Source/Model2/M2Cache.cpp b/Engine/Source/Model2/M2Cache.cpp index 5be4c30..cefd860 100644 --- a/Engine/Source/Model2/M2Cache.cpp +++ b/Engine/Source/Model2/M2Cache.cpp @@ -423,6 +423,13 @@ void CM2Cache::LinkToSharedUpdateList(CM2Shared* shared) { this->m_sharedUpdateList.LinkToTail(shared); } +// OFFSET: 0x0081C870 +CM2Cache::~CM2Cache() { + if (this->m_initialized) { + DebugLog("Model2: M2Destroy never called\n"); + } +} + // VERIFY: 902f5653 manual // OFFSET: 0x0081C900 CM2Cache::CM2Cache() : m_threadStart(0, 0), m_threadDone(0, 0) { diff --git a/Engine/Source/Model2/M2Cache.h b/Engine/Source/Model2/M2Cache.h index d80b5c2..febcabc 100644 --- a/Engine/Source/Model2/M2Cache.h +++ b/Engine/Source/Model2/M2Cache.h @@ -42,6 +42,7 @@ class CM2Cache { /* 10A0 */ TSExplicitList m_sharedUpdateList; CM2Cache(); + ~CM2Cache(); void BeginThread(void (*func)(void*), void* param); void ClearSharedHash(); CM2Shared* CreateShared(const char* name, uint32_t flags); diff --git a/Engine/Source/Model2/M2Light.h b/Engine/Source/Model2/M2Light.h index dee9507..aecb6d1 100644 --- a/Engine/Source/Model2/M2Light.h +++ b/Engine/Source/Model2/M2Light.h @@ -65,6 +65,8 @@ class CM2Lighting { /* 00C4 */ C4Plane m_liquidPlane; CM2Lighting(); + CM2Lighting(const CAaSphere& sphere); + void Reset(); void AddAmbient(const C3Vector& color); void AddDiffuse(const C3Vector& color, const C3Vector& dir); void AddLight(CM2Light* light); diff --git a/Engine/Source/Model2/M2Model.cpp b/Engine/Source/Model2/M2Model.cpp index 9fb4dcf..2dfaf53 100644 --- a/Engine/Source/Model2/M2Model.cpp +++ b/Engine/Source/Model2/M2Model.cpp @@ -458,7 +458,7 @@ void CM2Model::ComputeLoadProgress(int64_t& loaded, int64_t& total) { } } -// VERIFY: 7cdb0522 manual +// VERIFY: 4f897dd8 manual // OFFSET: 0x008248C0 CM2Lighting::CM2Lighting() { this->m_sphere4.c.x = 0.0f; @@ -474,7 +474,6 @@ CM2Lighting::CM2Lighting() { this->m_sunDiffuse = C3Vector(0.0f, 0.0f, 0.0f); this->m_sunSpecular = C3Vector(0.0f, 0.0f, 0.0f); this->m_sunDir = C3Vector(0.0f, 0.0f, 0.0f); -// VERIFY: 5e9baa29 auto this->m_fogColor = C3Vector(0.0f, 0.0f, 0.0f); this->m_liquidPlane.n.x = 0.0f; this->m_liquidPlane.n.y = 0.0f; @@ -7784,3 +7783,79 @@ int32_t CM2Model::Initialize(CM2Scene* scene, CM2Shared* shared, CM2Model* sourc return this->m_shared->CallbackWhenLoaded(this); } + +// VERIFY: 767a1eb1 auto +// OFFSET: 0x004D8630 +void CM2Model::SetWorldTransform(const C44Matrix& matrix) { + this->m_fFlags |= 0x8000; + this->m_worldTransform = matrix; +} + +// VERIFY: 3fa6010f auto +// OFFSET: 0x004E2730 +void CM2Lighting::Reset() { + this->m_sunAmbient = C3Vector(0.0f, 0.0f, 0.0f); + this->m_sunDiffuse = C3Vector(0.0f, 0.0f, 0.0f); + this->m_sunSpecular = C3Vector(0.0f, 0.0f, 0.0f); + this->m_sunDir = C3Vector(0.0f, 0.0f, 0.0f); + this->m_vector18 = C3Vector(0.0f, 0.0f, 0.0f); + this->m_vector24 = C3Vector(0.0f, 0.0f, 0.0f); + this->m_vector30 = C3Vector(0.0f, 0.0f, 0.0f); + this->m_vector3C = C3Vector(0.0f, 0.0f, 0.0f); + this->m_vector48 = C3Vector(0.0f, 0.0f, 0.0f); +} + +// VERIFY: 56d2a807 auto +// OFFSET: 0x004F5E20 +CAaBox CM2Model::GetBoundingBox() { + if (!(this->m_shared->m_flags & 1)) { + this->WaitForLoad(nullptr); + } + + return this->m_shared->m_data->m_bounds.m_extent; +} + +// VERIFY: d8b44604 manual +// OFFSET: 0x004F5E80 +CAaSphere CM2Model::GetBoundingSphere() { + if (!(this->m_shared->m_flags & 1)) { + this->WaitForLoad(nullptr); + } + + const M2Bounds& bounds = this->m_shared->m_data->m_bounds; + CAaSphere sphere = { C3Vector((bounds.m_extent.b.x + bounds.m_extent.t.x) * 0.5f, (bounds.m_extent.b.y + bounds.m_extent.t.y) * 0.5f, (bounds.m_extent.b.z + bounds.m_extent.t.z) * 0.5f), bounds.m_radius }; + + return sphere; +} + +// VERIFY: f3350a9a auto +// OFFSET: 0x006F1D20 +C44Matrix CM2Model::GetAnimatedWorldTransform() { + this->Animate(); + + return this->m_matrixF4 * this->m_scene->m_viewInv; +} + +// VERIFY: bf5b6c6a manual +// OFFSET: 0x00790440 +CM2Lighting::CM2Lighting(const CAaSphere& sphere) { + this->m_sphere4.c.x = 0.0f; + this->m_sphere4.r = 0.0f; + this->m_sphere4.c.y = 0.0f; + this->m_sphere4.c.z = 0.0f; + this->m_vector18 = C3Vector(0.0f, 0.0f, 0.0f); + this->m_vector24 = C3Vector(0.0f, 0.0f, 0.0f); + this->m_vector30 = C3Vector(0.0f, 0.0f, 0.0f); + this->m_vector3C = C3Vector(0.0f, 0.0f, 0.0f); + this->m_vector48 = C3Vector(0.0f, 0.0f, 0.0f); + this->m_sunAmbient = C3Vector(0.0f, 0.0f, 0.0f); + this->m_sunDiffuse = C3Vector(0.0f, 0.0f, 0.0f); + this->m_sunSpecular = C3Vector(0.0f, 0.0f, 0.0f); + this->m_sunDir = C3Vector(0.0f, 0.0f, 0.0f); + this->m_fogColor = C3Vector(0.0f, 0.0f, 0.0f); + this->m_liquidPlane.n.x = 0.0f; + this->m_liquidPlane.n.y = 0.0f; + this->m_liquidPlane.n.z = 1.0f; + this->m_liquidPlane.d = 0.0f; + this->Initialize(nullptr, sphere); +} diff --git a/Engine/Source/Model2/M2Model.h b/Engine/Source/Model2/M2Model.h index b3ef832..fc8328c 100644 --- a/Engine/Source/Model2/M2Model.h +++ b/Engine/Source/Model2/M2Model.h @@ -269,6 +269,9 @@ class CM2Model { uint32_t GetBoneSequenceId(uint32_t boneId); int32_t GetBoneSequenceInfo(uint32_t boneId, M2BoneSequenceInfo& info); float GetBoneSequenceSpeed(uint32_t boneId); + CAaBox GetBoundingBox(); + CAaSphere GetBoundingSphere(); + C44Matrix GetAnimatedWorldTransform(); CAaBox GetCurrentBoundingBox(); CAaBox GetMaxBoundingBoxPlusAttachments(); CAaSphere GetMaxBoundingSpherePlusAttachments(); @@ -339,6 +342,7 @@ class CM2Model { void SetLoadedCallback(void (*callback)(CM2Model*, void*), void* arg); void SetRibbonsEnabled(uint32_t enabled); void SetSequenceCallback(void* callback, uint64_t param); + void SetWorldTransform(const C44Matrix& matrix); void SetWorldTransform(const C3Vector& position, float rotation, float scale); void SetWorldTransform(const C3Vector& position, float rotation, float scale, const C3Vector& up, uint32_t flags); void UpdateLoaded();