diff --git a/config/GM8E01_00/symbols.txt b/config/GM8E01_00/symbols.txt index 070d8f72..71ede773 100644 --- a/config/GM8E01_00/symbols.txt +++ b/config/GM8E01_00/symbols.txt @@ -1256,8 +1256,8 @@ __dt__6CIOWinFv = .text:0x80052BA4; // type:function size:0x68 scope:global __ct__6CIOWinFRCQ24rstl66basic_string,Q24rstl17rmemory_allocator> = .text:0x80052C0C; // type:function size:0x40 scope:global UpdateSfxEmitters__6CActorFv = .text:0x80052C4C; // type:function size:0x88 scope:global CanDrawStatic__6CActorCFv = .text:0x80052CD4; // type:function size:0x98 scope:global -CreateShadow__6CActorFb = .text:0x80052D6C; // type:function size:0x70 scope:global -CreateShadow__6CActorFv = .text:0x80052DDC; // type:function size:0xB0 scope:global +SetDrawShadow__6CActorFb = .text:0x80052D6C; // type:function size:0x70 scope:global +CreateShadowIfNeeded__6CActorFv = .text:0x80052DDC; // type:function size:0xB0 scope:global SetTranslation__6CActorFRC9CVector3f = .text:0x80052E8C; // type:function size:0x44 scope:global GetScaledLocatorTransform__6CActorCFRCQ24rstl66basic_string,Q24rstl17rmemory_allocator> = .text:0x80052ED0; // type:function size:0x30 scope:global GetLocatorTransform__6CActorCFRCQ24rstl66basic_string,Q24rstl17rmemory_allocator> = .text:0x80052F00; // type:function size:0x30 scope:global @@ -1276,7 +1276,7 @@ AcceptScriptMsg__6CActorF20EScriptObjectMessage9TUniqueIdR13CStateManager = .tex SetActive__6CActorFb = .text:0x8005384C; // type:function size:0x54 scope:global SetMaterialFilter__6CActorFRC15CMaterialFilter = .text:0x800538A0; // type:function size:0x1C scope:global GetMaterialFilter__6CActorCFv = .text:0x800538BC; // type:function size:0x8 scope:global -fn_800538C4 = .text:0x800538C4; // type:function size:0x5C +SetActorLights__6CActorFQ24rstl24auto_ptr<12CActorLights> = .text:0x800538C4; // type:function size:0x5C SetCalculateLighting__6CActorFb = .text:0x80053920; // type:function size:0xC8 scope:global IsModelOpaque__6CActorCFRC13CStateManager = .text:0x800539E8; // type:function size:0xA8 scope:global GetScanObjectIndicatorPosition__6CActorCFRC13CStateManager = .text:0x80053A90; // type:function size:0x1E0 scope:global @@ -5608,7 +5608,7 @@ SetModulationColorAllActiveEffects__17CParticleDatabaseFRC6CColor = .text:0x800B SuspendAllActiveEffectsForParticleDB__17CParticleDatabaseFR13CStateManagerRQ24rstl236map,Q24rstl17rmemory_allocator>,Q24rstl28auto_ptr<16CParticleGenInfo>,Q24rstl81less,Q24rstl17rmemory_allocator>>,Q24rstl17rmemory_allocator> = .text:0x800B7B94; // type:function size:0xA4 scope:global SuspendAllActiveEffects__17CParticleDatabaseFR13CStateManager = .text:0x800B7C38; // type:function size:0x58 scope:global DeleteAllLightsForParticleDB__17CParticleDatabaseFR13CStateManager = .text:0x800B7C90; // type:function size:0xA0 scope:global -DeleteAllLights__17CParticleDatabaseCFR13CStateManager = .text:0x800B7D30; // type:function size:0x7C scope:global +DeleteAllLights__17CParticleDatabaseFR13CStateManager = .text:0x800B7D30; // type:function size:0x7C scope:global RenderParticleGenMapMasked__17CParticleDatabaseFRCQ24rstl236map,Q24rstl17rmemory_allocator>,Q24rstl28auto_ptr<16CParticleGenInfo>,Q24rstl81less,Q24rstl17rmemory_allocator>>,Q24rstl17rmemory_allocator>ii = .text:0x800B7DAC; // type:function size:0xA4 scope:global RenderParticleGenMap__17CParticleDatabaseFRCQ24rstl236map,Q24rstl17rmemory_allocator>,Q24rstl28auto_ptr<16CParticleGenInfo>,Q24rstl81less,Q24rstl17rmemory_allocator>>,Q24rstl17rmemory_allocator> = .text:0x800B7E50; // type:function size:0x7C scope:global RenderSystemsToBeDrawnLastMasked__17CParticleDatabaseCFii = .text:0x800B7ECC; // type:function size:0x58 scope:global diff --git a/config/GM8E01_01/symbols.txt b/config/GM8E01_01/symbols.txt index 639675d8..a0e276c6 100644 --- a/config/GM8E01_01/symbols.txt +++ b/config/GM8E01_01/symbols.txt @@ -1256,8 +1256,8 @@ __dt__6CIOWinFv = .text:0x80052C20; // type:function size:0x68 scope:global __ct__6CIOWinFRCQ24rstl66basic_string,Q24rstl17rmemory_allocator> = .text:0x80052C88; // type:function size:0x40 scope:global UpdateSfxEmitters__6CActorFv = .text:0x80052CC8; // type:function size:0x88 scope:global CanDrawStatic__6CActorCFv = .text:0x80052D50; // type:function size:0x98 scope:global -CreateShadow__6CActorFb = .text:0x80052DE8; // type:function size:0x70 scope:global -CreateShadow__6CActorFv = .text:0x80052E58; // type:function size:0xB0 scope:global +SetDrawShadow__6CActorFb = .text:0x80052DE8; // type:function size:0x70 scope:global +CreateShadowIfNeeded__6CActorFv = .text:0x80052E58; // type:function size:0xB0 scope:global SetTranslation__6CActorFRC9CVector3f = .text:0x80052F08; // type:function size:0x44 scope:global GetScaledLocatorTransform__6CActorCFRCQ24rstl66basic_string,Q24rstl17rmemory_allocator> = .text:0x80052F4C; // type:function size:0x30 scope:global GetLocatorTransform__6CActorCFRCQ24rstl66basic_string,Q24rstl17rmemory_allocator> = .text:0x80052F7C; // type:function size:0x30 scope:global @@ -1276,7 +1276,7 @@ AcceptScriptMsg__6CActorF20EScriptObjectMessage9TUniqueIdR13CStateManager = .tex SetActive__6CActorFb = .text:0x800538C8; // type:function size:0x54 scope:global SetMaterialFilter__6CActorFRC15CMaterialFilter = .text:0x8005391C; // type:function size:0x1C scope:global GetMaterialFilter__6CActorCFv = .text:0x80053938; // type:function size:0x8 scope:global -fn_800538C4 = .text:0x80053940; // type:function size:0x5C scope:global +SetActorLights__6CActorFQ24rstl24auto_ptr<12CActorLights> = .text:0x80053940; // type:function size:0x5C scope:global SetCalculateLighting__6CActorFb = .text:0x8005399C; // type:function size:0xC8 scope:global IsModelOpaque__6CActorCFRC13CStateManager = .text:0x80053A64; // type:function size:0xA8 scope:global GetScanObjectIndicatorPosition__6CActorCFRC13CStateManager = .text:0x80053B0C; // type:function size:0x1E0 scope:global @@ -5610,7 +5610,7 @@ SetModulationColorAllActiveEffects__17CParticleDatabaseFRC6CColor = .text:0x800B SuspendAllActiveEffectsForParticleDB__17CParticleDatabaseFR13CStateManagerRQ24rstl236map,Q24rstl17rmemory_allocator>,Q24rstl28auto_ptr<16CParticleGenInfo>,Q24rstl81less,Q24rstl17rmemory_allocator>>,Q24rstl17rmemory_allocator> = .text:0x800B7C10; // type:function size:0xA4 scope:global SuspendAllActiveEffects__17CParticleDatabaseFR13CStateManager = .text:0x800B7CB4; // type:function size:0x58 scope:global DeleteAllLightsForParticleDB__17CParticleDatabaseFR13CStateManager = .text:0x800B7D0C; // type:function size:0xA0 scope:global -DeleteAllLights__17CParticleDatabaseCFR13CStateManager = .text:0x800B7DAC; // type:function size:0x7C scope:global +DeleteAllLights__17CParticleDatabaseFR13CStateManager = .text:0x800B7DAC; // type:function size:0x7C scope:global RenderParticleGenMapMasked__17CParticleDatabaseFRCQ24rstl236map,Q24rstl17rmemory_allocator>,Q24rstl28auto_ptr<16CParticleGenInfo>,Q24rstl81less,Q24rstl17rmemory_allocator>>,Q24rstl17rmemory_allocator>ii = .text:0x800B7E28; // type:function size:0xA4 scope:global RenderParticleGenMap__17CParticleDatabaseFRCQ24rstl236map,Q24rstl17rmemory_allocator>,Q24rstl28auto_ptr<16CParticleGenInfo>,Q24rstl81less,Q24rstl17rmemory_allocator>>,Q24rstl17rmemory_allocator> = .text:0x800B7ECC; // type:function size:0x7C scope:global RenderSystemsToBeDrawnLastMasked__17CParticleDatabaseCFii = .text:0x800B7F48; // type:function size:0x58 scope:global diff --git a/include/Kyoto/Audio/CSfxManager.hpp b/include/Kyoto/Audio/CSfxManager.hpp index 8f587e86..d27b0fcd 100644 --- a/include/Kyoto/Audio/CSfxManager.hpp +++ b/include/Kyoto/Audio/CSfxManager.hpp @@ -82,13 +82,14 @@ public: static const ushort kInternalInvalidSfxId; // 0xFFFF static const int kAllAreas; // 0xFFFFFFFF static CSfxHandle AddEmitter(const ushort id, const CVector3f& pos, const CVector3f& dir, - const bool useAcoustics, const bool looped, const short prio = kMedPriority, - const int areaId = kAllAreas); - static CSfxHandle AddEmitter(const ushort id, const CVector3f& pos, const CVector3f& dir, uchar vol, - const bool useAcoustics, const bool looped, const short prio = kMedPriority, - const int areaId = kAllAreas); + const bool useAcoustics, const bool looped, + const short prio = kMedPriority, const int areaId = kAllAreas); + static CSfxHandle AddEmitter(const ushort id, const CVector3f& pos, const CVector3f& dir, + uchar vol, const bool useAcoustics, const bool looped, + const short prio = kMedPriority, const int areaId = kAllAreas); static CSfxHandle AddEmitter(CAudioSys::C3DEmitterParmData& parmData, bool useAcoustics, - short prio, bool looped, int areaId = kAllAreas); + const short prio = kMedPriority, const bool looped = false, + int areaId = kAllAreas); static void AddListener(ESfxChannels channel, const CVector3f& pos, const CVector3f& dir, const CVector3f& vec1, const CVector3f& vec2, float f1, float f2, diff --git a/include/Kyoto/Graphics/CModelFlags.hpp b/include/Kyoto/Graphics/CModelFlags.hpp index f2fa4bf7..fb296afd 100644 --- a/include/Kyoto/Graphics/CModelFlags.hpp +++ b/include/Kyoto/Graphics/CModelFlags.hpp @@ -11,6 +11,7 @@ public: kT_Opaque = 0, kT_One = 1, // ? kT_Two = 2, // ? + kT_Four = 4, // ? kT_Blend = 5, kT_Additive = 7, }; diff --git a/include/Kyoto/TToken.hpp b/include/Kyoto/TToken.hpp index 2623046c..46cf89fa 100644 --- a/include/Kyoto/TToken.hpp +++ b/include/Kyoto/TToken.hpp @@ -34,10 +34,13 @@ class TCachedToken : public TToken< T > { public: TCachedToken() {} TCachedToken(const CToken& token) : TToken< T >(token), x8_item(nullptr) {} + // __ct__23TCachedToken<8CTexture>FRC23TCachedToken<8CTexture> + // __as__21TCachedToken<6CModel>FRC21TCachedToken<6CModel> - T* operator*() { return x8_item; } + // T* operator*() { return x8_item; } + T* GetObject() const { return x8_item; } - bool IsLoaded() { + bool TryCache() { if (x8_item != nullptr) { return true; } @@ -49,6 +52,11 @@ public: } } + // Lock__23TCachedToken<8CTexture>Fv + // GetObject__23TCachedToken<8CTexture>CFv + // TryCache__23TCachedToken<8CTexture>Fv + // GetToken__21TCachedToken<6CModel>CFv + void Unlock() { x8_item = nullptr; TToken< T >::Unlock(); diff --git a/include/MetroidPrime/CActor.hpp b/include/MetroidPrime/CActor.hpp index 794b119a..546240b7 100644 --- a/include/MetroidPrime/CActor.hpp +++ b/include/MetroidPrime/CActor.hpp @@ -6,9 +6,10 @@ #include "Collision/CMaterialFilter.hpp" #include "Collision/CMaterialList.hpp" +#include "MetroidPrime/ActorCommon.hpp" #include "MetroidPrime/CEntity.hpp" #include "MetroidPrime/CModelData.hpp" -#include "MetroidPrime/ActorCommon.hpp" + #include "Kyoto/Audio/CSfxHandle.hpp" #include "Kyoto/Graphics/CColor.hpp" @@ -103,7 +104,7 @@ public: void DrawTouchBounds() const; bool IsModelOpaque(const CStateManager& mgr) const; void RenderInternal(const CStateManager& mgr) const; - void CreateShadow(bool); + void CreateShadowIfNeeded(); const CTransform4f& GetTransform() const { return x34_transform; } void SetTransform(const CTransform4f& xf) { @@ -119,6 +120,11 @@ public: CTransform4f GetLocatorTransform(const rstl::string& segName) const; CTransform4f GetScaledLocatorTransform(const rstl::string& segName) const; float GetYaw() const; + float GetPitch() const; + void SetActorLights(rstl::auto_ptr< CActorLights > lights); + void SetInFluid(bool b, TUniqueId uid); + CScannableObjectInfo* GetScannableObjectInfo() const; + void MoveScannableObjectInfoToActor(CActor* actor, CStateManager& mgr); /// ???? bool NullModel() const { return !GetAnimationData() && !GetModelData()->HasNormalModel(); } @@ -168,10 +174,10 @@ public: void SetTransformDirtySpare(bool b) { xe4_28_transformDirty = b; } void SetPreRenderHasMoved(bool b) { xe4_29_actorLightsDirty = b; } void SetPreRenderClipped(bool b) { xe4_30_outOfFrustum = b; } - void SetCalculateLighting(bool b) { xe4_31_calculateLighting = b; } - void SetDrawShadow(bool b) { xe5_24_shadowEnabled = b; } + void SetCalculateLighting(bool b); + void SetDrawShadow(bool b); void SetShadowDirty(bool b) { xe5_25_shadowDirty = b; } - void SetMuted(bool b) { xe5_26_muted = b; } + void SetMuted(bool b); void SetThermalFlags(EThermalFlags flags) { xe6_27_thermalVisorFlags = flags; } void SetRenderParticleDatabaseInside(bool b) { xe6_29_renderParticleDBInside = b; } void SetTargetable(bool b) { xe7_31_targetable = b; } @@ -192,10 +198,10 @@ public: const CAABox& GetRenderBoundsCached() const { return x9c_renderBounds; } void SetRenderBounds(const CAABox& bounds) { x9c_renderBounds = bounds; } - // 000c0ec8 00001c 801711a8 4 GetUseInSortedLists__6CActorCFv CActor.o + bool GetUseInSortedLists() const; void SetUseInSortedLists(bool use); - // 000c0ef8 00001c 801711d8 4 GetCallTouch__6CActorCFv CActor.o - void SetCallTouch(bool); + bool GetCallTouch() const; + void SetCallTouch(bool value); // GetOrbitDistanceCheck__6CActorCFv // GetCalculateLighting__6CActorCFv // GetDrawShadow__6CActorCFv @@ -203,6 +209,9 @@ public: // GetRenderParticleDatabaseInside__6CActorCFv // HasModelParticles__6CActorCFv void SetVolume(uchar volume); + void SetSoundEventPitchBend(int); + CSfxHandle GetSfxHandle() const; + bool CanDrawStatic() const; private: CTransform4f x34_transform; diff --git a/include/MetroidPrime/CAnimData.hpp b/include/MetroidPrime/CAnimData.hpp index 77533473..85b1d7ca 100644 --- a/include/MetroidPrime/CAnimData.hpp +++ b/include/MetroidPrime/CAnimData.hpp @@ -118,7 +118,7 @@ public: CCharAnimTime GetTimeOfUserEvent(EUserEventType type, const CCharAnimTime& time) const; // GetAdvancementDeltas__9CAnimDataCFRC13CCharAnimTimeRC13CCharAnimTime // Touch__9CAnimDataCFRC13CSkinnedModeli - // InitializeEffects__9CAnimDataFR13CStateManagerRC9CVector3f + void InitializeEffects(CStateManager&, TAreaId, const CVector3f&); // SetPhase__9CAnimDataFf -> SetPhase__11IAnimReaderFf void SetPhase(float ph); void AddAdditiveAnimation(uint idx, float weight, bool active, bool fadeOut); diff --git a/include/MetroidPrime/CModelData.hpp b/include/MetroidPrime/CModelData.hpp index da7dbe0e..a8211dae 100644 --- a/include/MetroidPrime/CModelData.hpp +++ b/include/MetroidPrime/CModelData.hpp @@ -90,7 +90,9 @@ public: CAABox GetBounds(const CTransform4f& xf) const; CAABox GetBounds() const; bool IsLoaded(int shaderIdx) const; + bool IsDefinitelyOpaque(EWhichModel which) const; + CTransform4f GetLocatorTransform(const rstl::string& name) const; CTransform4f GetScaledLocatorTransform(const rstl::string& name) const; bool HasAnimation() const { return !xc_animData.null(); } diff --git a/include/MetroidPrime/CParticleDatabase.hpp b/include/MetroidPrime/CParticleDatabase.hpp index 24e8c264..7b04cf7a 100644 --- a/include/MetroidPrime/CParticleDatabase.hpp +++ b/include/MetroidPrime/CParticleDatabase.hpp @@ -24,6 +24,7 @@ public: void SetParticleEffectState(const rstl::string& name, bool active, CStateManager& mgr); void RenderSystemsToBeDrawnFirst() const; void RenderSystemsToBeDrawnLast() const; + void DeleteAllLights(CStateManager& mgr); bool AreAnySystemsDrawnWithModel() const { return xb4_25_anySystemsDrawnWithModel; } diff --git a/include/MetroidPrime/CStateManager.hpp b/include/MetroidPrime/CStateManager.hpp index f98f1f1d..8b960ca3 100644 --- a/include/MetroidPrime/CStateManager.hpp +++ b/include/MetroidPrime/CStateManager.hpp @@ -137,6 +137,7 @@ public: TUniqueId AllocateUniqueId(); const rstl::string& HashInstanceName(CInputStream& in); bool SwapOutAllPossibleMemory(); + void UpdateObjectInLists(CEntity&); void BuildNearList(TEntityList& nearList, const CVector3f& pos, const CVector3f& dir, float mag, const CMaterialFilter&, const CActor*) const; diff --git a/include/rstl/single_ptr.hpp b/include/rstl/single_ptr.hpp index 68cac0e8..bbb823e6 100644 --- a/include/rstl/single_ptr.hpp +++ b/include/rstl/single_ptr.hpp @@ -11,20 +11,32 @@ class single_ptr { public: single_ptr() : x0_ptr(nullptr) {} single_ptr(T* ptr) : x0_ptr(ptr) {} - ~single_ptr() { delete x0_ptr; } - T* get() const { return x0_ptr; } - // const T* get() const { return x0_ptr; } - T* operator->() { return x0_ptr; } - const T* operator->() const { return x0_ptr; } single_ptr(const single_ptr& other) : x0_ptr(other.x0_ptr) { other.x0_ptr = nullptr; } + ~single_ptr() { delete x0_ptr; } + + single_ptr& operator=(single_ptr& other) { + if (&other == this) { + return *this; + } + delete x0_ptr; + x0_ptr = other.x0_ptr; + other.x0_ptr = nullptr; + return *this; + } + single_ptr& operator=(T* const ptr) { delete x0_ptr; x0_ptr = ptr; return *this; } - bool null() const { return x0_ptr == nullptr; } + + T* get() const { return x0_ptr; } + // const T* get() const { return x0_ptr; } + T* operator->() const { return x0_ptr; } T& operator*() { return *x0_ptr; } const T& operator*() const { return *x0_ptr; } + + bool null() const { return x0_ptr == nullptr; } T* release() { T* ptr = x0_ptr; x0_ptr = nullptr; diff --git a/src/MetroidPrime/CActor.cpp b/src/MetroidPrime/CActor.cpp index bd2b8cce..a7fdba7c 100644 --- a/src/MetroidPrime/CActor.cpp +++ b/src/MetroidPrime/CActor.cpp @@ -5,6 +5,7 @@ #include "MetroidPrime/CActorModelParticles.hpp" #include "MetroidPrime/CActorParameters.hpp" #include "MetroidPrime/CAnimData.hpp" +#include "MetroidPrime/CDamageVulnerability.hpp" #include "MetroidPrime/CGameArea.hpp" #include "MetroidPrime/CModelData.hpp" #include "MetroidPrime/CSimpleShadow.hpp" @@ -96,8 +97,8 @@ CActor::CActor(TUniqueId uid, bool active, const rstl::string& name, const CEnti } const CAssetId scanId = params.GetScannable().GetScannableObject0(); if (scanId != kInvalidAssetId) { - x98_scanObjectInfo = - rs_new TCachedToken< CScannableObjectInfo >(gpSimplePool->GetObj(SObjectTag('SCAN', scanId))); + x98_scanObjectInfo = rs_new TCachedToken< CScannableObjectInfo >( + gpSimplePool->GetObj(SObjectTag('SCAN', scanId))); x98_scanObjectInfo->Lock(); } } @@ -353,6 +354,7 @@ void CActor::Render(const CStateManager& mgr) const { DrawTouchBounds(); } +// TODO nonmatching void CActor::RenderInternal(const CStateManager& mgr) const { CModelData::EWhichModel which = CModelData::GetRenderingModel(mgr); if (which == CModelData::kWM_ThermalHot) { @@ -386,4 +388,444 @@ void CActor::RenderInternal(const CStateManager& mgr) const { } } GetModelData()->Render(which, x34_transform, x90_actorLights.get(), xb4_drawFlags); -}; +} + +float CActor::GetYaw() const { + float sq = sqrt(x34_transform.Get11() * x34_transform.Get11() + + x34_transform.Get01() * x34_transform.Get01()); + if (sq > 0.001f) { + double ret = -atan2(x34_transform.Get01(), x34_transform.Get11()); + return ret; + } + return 0.f; +} + +float CActor::GetPitch() const { + float sq = CMath::SqrtF(x34_transform.Get11() * x34_transform.Get11() + + x34_transform.Get01() * x34_transform.Get01()); + double ret = -atan2(-x34_transform.Get21(), sq); + return ret; +} + +CHealthInfo* CActor::HealthInfo(CStateManager& mgr) { return nullptr; } + +const CDamageVulnerability* CActor::GetDamageVulnerability() const { + return &CDamageVulnerability::NormalVulnerabilty(); +} + +const CDamageVulnerability* CActor::GetDamageVulnerability(const CVector3f&, const CVector3f&, + const CDamageInfo&) const { + return GetDamageVulnerability(); +} + +rstl::optional_object< CAABox > CActor::GetTouchBounds() const { + return rstl::optional_object_null(); +} + +void CActor::Touch(CActor&, CStateManager&) {} + +bool CActor::GetUseInSortedLists() const { return xe5_27_useInSortedLists; } + +void CActor::SetUseInSortedLists(bool use) { xe5_27_useInSortedLists = use; } + +bool CActor::GetCallTouch() const { return xe5_28_callTouch; } + +void CActor::SetCallTouch(bool value) { xe5_28_callTouch = value; } + +void CActor::AddMaterial(EMaterialTypes mat1, CStateManager& mgr) { + x68_material.Add(mat1); + mgr.UpdateObjectInLists(*this); +} + +void CActor::AddMaterial(EMaterialTypes mat1, EMaterialTypes mat2, CStateManager& mgr) { + x68_material.Add(mat1); + x68_material.Add(mat2); + mgr.UpdateObjectInLists(*this); +} + +void CActor::AddMaterial(EMaterialTypes mat1, EMaterialTypes mat2, EMaterialTypes mat3, + CStateManager& mgr) { + x68_material.Add(mat1); + x68_material.Add(mat2); + x68_material.Add(mat3); + mgr.UpdateObjectInLists(*this); +} + +void CActor::AddMaterial(EMaterialTypes mat1, EMaterialTypes mat2, EMaterialTypes mat3, + EMaterialTypes mat4, CStateManager& mgr) { + x68_material.Add(mat1); + x68_material.Add(mat2); + x68_material.Add(mat3); + x68_material.Add(mat4); + mgr.UpdateObjectInLists(*this); +} + +void CActor::AddMaterial(EMaterialTypes mat1, EMaterialTypes mat2, EMaterialTypes mat3, + EMaterialTypes mat4, EMaterialTypes mat5, CStateManager& mgr) { + x68_material.Add(mat1); + x68_material.Add(mat2); + x68_material.Add(mat3); + x68_material.Add(mat4); + x68_material.Add(mat5); + mgr.UpdateObjectInLists(*this); +} + +void CActor::RemoveMaterial(EMaterialTypes mat1, CStateManager& mgr) { + x68_material.Remove(mat1); + mgr.UpdateObjectInLists(*this); +} + +void CActor::RemoveMaterial(EMaterialTypes mat1, EMaterialTypes mat2, CStateManager& mgr) { + + x68_material.Remove(mat1); + x68_material.Remove(mat2); + mgr.UpdateObjectInLists(*this); +} + +void CActor::RemoveMaterial(EMaterialTypes mat1, EMaterialTypes mat2, EMaterialTypes mat3, + CStateManager& mgr) { + + x68_material.Remove(mat1); + x68_material.Remove(mat2); + x68_material.Remove(mat3); + mgr.UpdateObjectInLists(*this); +} + +void CActor::RemoveMaterial(EMaterialTypes mat1, EMaterialTypes mat2, EMaterialTypes mat3, + EMaterialTypes mat4, CStateManager& mgr) { + + x68_material.Remove(mat1); + x68_material.Remove(mat2); + x68_material.Remove(mat3); + x68_material.Remove(mat4); + mgr.UpdateObjectInLists(*this); +} + +EWeaponCollisionResponseTypes CActor::GetCollisionResponseType(const CVector3f&, const CVector3f&, + const CWeaponMode&, int) const { + return kWCR_OtherProjectile; +} + +CVector3f CActor::GetOrbitPosition(const CStateManager&) const { + return x34_transform.GetTranslation(); +} + +CVector3f CActor::GetAimPosition(const CStateManager&, float) const { + return x34_transform.GetTranslation(); +} + +CVector3f CActor::GetHomingPosition(const CStateManager& mgr, float f) const { + return GetAimPosition(mgr, f); +} + +// TODO nonmatching +CVector3f CActor::GetScanObjectIndicatorPosition(const CStateManager& mgr) const { + const CGameCamera& cam = mgr.GetCameraManager()->GetCurrentCamera(mgr); + CVector3f orbitPos = GetOrbitPosition(mgr); + float mag = (GetTranslation() - orbitPos).Magnitude(); + CVector3f size = x9c_renderBounds.GetMaxPoint() - x9c_renderBounds.GetMinPoint(); + float max = rstl::max_val(size.GetY(), rstl::max_val(size.GetX(), size.GetZ())) * 0.5f; + float clip = mag - cam.GetNearClipDistance() - 0.1f; + float v = rstl::max_val(clip, max); + CVector3f dist = (orbitPos - GetTranslation()).AsNormalized(); + return orbitPos - v * dist; +} + +bool CActor::IsModelOpaque(const CStateManager& mgr) const { + if (xe5_31_pointGeneratorParticles) { + return false; + } else if (!HasModelData()) { + return true; + } else if (static_cast< char >(xb4_drawFlags.GetTrans()) > 4) { + return false; + } else { + CModelData::EWhichModel which = CModelData::GetRenderingModel(mgr); + return x64_modelData->IsDefinitelyOpaque(which); + } +} + +void CActor::SetCalculateLighting(bool b) { + if (x90_actorLights.null()) { + x90_actorLights = rs_new CActorLights(8, CVector3f::Zero(), 4, 4); + } + xe4_31_calculateLighting = b; +} + +void CActor::SetActorLights(rstl::auto_ptr< CActorLights > lights) { + x90_actorLights = lights.release(); + xe4_31_calculateLighting = true; +} + +const CMaterialFilter& CActor::GetMaterialFilter() const { return x70_materialFilter; } + +void CActor::SetMaterialFilter(const CMaterialFilter& filter) { x70_materialFilter = filter; } + +void CActor::SetActive(const bool active) { + SetTransformDirty(true); + SetTransformDirtySpare(true); + SetPreRenderHasMoved(true); + xe7_29_drawEnabled = active; // no setter? + CEntity::SetActive(active); +} + +void CActor::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) { + switch (msg) { + case kSM_Activate: { + if (!GetActive()) { + xbc_time = CGraphics::GetSecondsMod900(); + } + break; + } + case kSM_Deactivate: { + RemoveEmitter(); + break; + } + case kSM_Deleted: { + RemoveEmitter(); + if (HasModelData() && AnimationData() != nullptr) { + AnimationData()->GetParticleDB().DeleteAllLights(mgr); + } + break; + } + case kSM_Registered: { + if (!x98_scanObjectInfo.null()) { + AddMaterial(kMT_Scannable, mgr); + } else { + RemoveMaterial(kMT_Scannable, mgr); + } + if (HasAnimation()) { + AnimationData()->InitializeEffects(mgr, GetAreaId(), GetModelData()->GetScale()); + } + break; + } + case kSM_AddSplashInhabitant: { + SetInFluid(true, uid); + break; + } + case kSM_RemoveSplashInhabitant: { + SetInFluid(false, kInvalidUniqueId); + break; + } + case kSM_InitializedInArea: { + rstl::vector< SConnection >::const_iterator iter = GetConnectionList().begin(); + for (; iter != GetConnectionList().end(); ++iter) { + if (iter->x0_state != kSS_Default) { + continue; + } + CActor* act = TCastToPtr< CActor >(mgr.ObjectById(mgr.GetIdForScript(iter->x8_objId))); + if (act != nullptr && xc6_nextDrawNode == kInvalidUniqueId) { + xc6_nextDrawNode = act->GetUniqueId(); + } + } + break; + } + default: + break; + } + CEntity::AcceptScriptMsg(msg, uid, mgr); +} + +CAABox CActor::GetSortingBounds(const CStateManager& mgr) const { return GetRenderBoundsCached(); } + +void CActor::FluidFXThink(EFluidState, CScriptWater&, CStateManager&) {} + +void CActor::OnScanStateChange(EScanState state, CStateManager& mgr) { + switch (state) { + case kSS_Start: + SendScriptMsgs(kSS_ScanStart, mgr, kSM_None); + break; + case kSS_Processing: + SendScriptMsgs(kSS_ScanProcessing, mgr, kSM_None); + break; + case kSS_Done: + SendScriptMsgs(kSS_ScanDone, mgr, kSM_None); + break; + } +} + +CScannableObjectInfo* CActor::GetScannableObjectInfo() const { + if (x98_scanObjectInfo.null()) { + return nullptr; + } + + if (x98_scanObjectInfo->TryCache()) { + return x98_scanObjectInfo->GetObject(); + } + + return nullptr; +} + +void CActor::MoveScannableObjectInfoToActor(CActor* actor, CStateManager& mgr) { + if (actor == nullptr) { + return; + } + + actor->x98_scanObjectInfo = x98_scanObjectInfo; + actor->AddMaterial(kMT_Scannable, mgr); + RemoveMaterial(kMT_Scannable, mgr); +} + +void CActor::SetMuted(bool b) { + xe5_26_muted = b; + RemoveEmitter(); +} + +void CActor::SetVolume(uchar volume) { + if (CSfxHandle handle = x8c_loopingSfxHandle) { + CSfxManager::UpdateEmitter(handle, GetTranslation(), CVector3f::Zero(), volume); + } + xd4_maxVol = volume; +} + +void CActor::SetSoundEventPitchBend(int v) { + xe6_30_enablePitchBend = true; + xc0_pitchBend = v; + if (x8c_loopingSfxHandle) { + CSfxManager::PitchBend(x8c_loopingSfxHandle, v); + } +} + +CSfxHandle CActor::GetSfxHandle() const { return x8c_loopingSfxHandle; } + +void CActor::SetInFluid(bool in, TUniqueId uid) { + if (in) { + xe6_24_fluidCounter += 1; + xc4_fluidId = uid; + } else if (xe6_24_fluidCounter != 0) { + xe6_24_fluidCounter--; + if (xe6_24_fluidCounter == 0) { + xc4_fluidId = kInvalidUniqueId; + } + } +} + +// TODO nonmatching +void CActor::ProcessSoundEvent(int sfxId, float weight, int flags, float fallOff, float maxDist, + uchar minVol, uchar maxVol, const CVector3f& toListener, + const CVector3f& position, int aid, CStateManager& mgr, + bool translateId) { + if (toListener.MagSquared() >= maxDist * maxDist) { + return; + } + ushort id = translateId ? CSfxManager::TranslateSFXID(static_cast< ushort >(sfxId)) + : static_cast< ushort >(sfxId); + + uint musyxFlags = 0x1; // Continuous parameter update + if (flags & 0x8) { + musyxFlags |= 0x8; // Doppler FX + } + + CAudioSys::C3DEmitterParmData parms(position, CVector3f::Zero(), maxDist, fallOff, musyxFlags, id, + maxVol, minVol, false, 0x7f); + + bool useAcoustics = (flags & 0x80) == 0; + bool looping = (sfxId & 0x80000000) != 0; + bool nonEmitter = (sfxId & 0x40000000) != 0; + + if (mgr.Random()->Float() > weight) { + return; + } + + if (looping) { + ushort curId = x88_sfxId; + if (!x8c_loopingSfxHandle) { + CSfxHandle handle; + if (nonEmitter) { + handle = CSfxManager::SfxStart(id, 1.f, 0.f, true, CSfxManager::kMedPriority, true, aid); + } else { + handle = CSfxManager::AddEmitter(parms, useAcoustics, CSfxManager::kMedPriority, true, aid); + } + if (handle) { + x88_sfxId = id; + x8c_loopingSfxHandle = handle; + if (xe6_30_enablePitchBend) { + CSfxManager::PitchBend(handle, xc0_pitchBend); + } + } + } else if (curId == id) { + CSfxManager::UpdateEmitter(x8c_loopingSfxHandle, parms.x0_pos, parms.xc_dir, maxVol); + } else if (flags & 0x4) { + CSfxManager::RemoveEmitter(x8c_loopingSfxHandle); + CSfxHandle handle = + CSfxManager::AddEmitter(parms, useAcoustics, CSfxManager::kMedPriority, true, aid); + if (handle) { + x88_sfxId = id; + x8c_loopingSfxHandle = handle; + if (xe6_30_enablePitchBend) { + CSfxManager::PitchBend(handle, xc0_pitchBend); + } + } + } + } else { + CSfxHandle handle; + if (nonEmitter) { + handle = + CSfxManager::SfxStart(id, 1.f, 0.f, useAcoustics, CSfxManager::kMedPriority, false, aid); + } else { + handle = CSfxManager::AddEmitter(parms, useAcoustics, CSfxManager::kMedPriority, false, aid); + } + if ((sfxId & 0x20000000) != 0 /* continuous update */) { + xd8_nonLoopingSfxHandles[xe4_24_nextNonLoopingSfxHandle] = handle; + xe4_24_nextNonLoopingSfxHandle = + (xe4_24_nextNonLoopingSfxHandle + 1) % xd8_nonLoopingSfxHandles.size(); + } + + if (xe6_30_enablePitchBend) { + CSfxManager::PitchBend(handle, xc0_pitchBend); + } + } +} + +CTransform4f CActor::GetLocatorTransform(const rstl::string& segName) const { + return GetModelData()->GetLocatorTransform(segName); +} + +CTransform4f CActor::GetScaledLocatorTransform(const rstl::string& segName) const { + return GetModelData()->GetScaledLocatorTransform(segName); +} + +void CActor::SetTranslation(const CVector3f& vec) { + x34_transform.SetTranslation(vec); + SetTransformDirty(true); + SetTransformDirtySpare(true); + SetPreRenderHasMoved(true); +} + +void CActor::CreateShadowIfNeeded() { + if (!x94_simpleShadow.null()) { + return; + } + + if (HasModelData()) { + x94_simpleShadow = rs_new CSimpleShadow(1.f, 1.f, 20.f, 0.05f); + } +} + +void CActor::SetDrawShadow(bool enabled) { + if (enabled) { + CreateShadowIfNeeded(); + if (!xe5_24_shadowEnabled && !x94_simpleShadow.null()) { + xe5_25_shadowDirty = true; + } + } + xe5_24_shadowEnabled = enabled; +} + +// TODO nonmatching +bool CActor::CanDrawStatic() const { + if (!GetActive() || !HasModelData() || static_cast< char >(xb4_drawFlags.GetTrans()) > 4) + return false; + + if (HasModelData() && GetAnimationData() == nullptr) + return true; + + return false; +} + +void CActor::UpdateSfxEmitters() { + uint count = xd8_nonLoopingSfxHandles.size(); + for (uint i = 0; i < count; ++i) { + CSfxManager::UpdateEmitter(xd8_nonLoopingSfxHandles[i], GetTranslation(), CVector3f::Zero(), + xd4_maxVol); + } +} diff --git a/src/MetroidPrime/CMapArea.cpp b/src/MetroidPrime/CMapArea.cpp index f6ba0f0a..51239161 100644 --- a/src/MetroidPrime/CMapArea.cpp +++ b/src/MetroidPrime/CMapArea.cpp @@ -88,7 +88,7 @@ CMapArea::CMapArea(CInputStream& in, uint size) CMapArea::~CMapArea() { lbl_805A8EB0 -= x34_size + sizeof(*this); - CFrameDelayedKiller::sub_8036cc1c(true, x44_buf.release()); + CFrameDelayedKiller::fn_8036CC1C(true, x44_buf.release()); } void CMapArea::PostConstruct() { diff --git a/src/MetroidPrime/Enemies/CPuffer.cpp b/src/MetroidPrime/Enemies/CPuffer.cpp index cebe2c59..f5db30f6 100644 --- a/src/MetroidPrime/Enemies/CPuffer.cpp +++ b/src/MetroidPrime/Enemies/CPuffer.cpp @@ -38,7 +38,7 @@ CPuffer::CPuffer(TUniqueId uid, const rstl::string& name, const CEntityInfo& inf , x5c0_move(CVector3f::Zero()) , x5cc_(kInvalidUniqueId) , x5d0_enabledParticles(0) { - CreateShadow(false); + SetDrawShadow(false); GetKnockBackCtrl().SetImpulseDurationIdx(1); x574_cloudEffect.Lock(); BodyCtrl()->SetRestrictedFlyerMoveSpeed(hoverSpeed); diff --git a/src/MetroidPrime/ScriptObjects/CScriptActor.cpp b/src/MetroidPrime/ScriptObjects/CScriptActor.cpp index 92db35ae..19eabf88 100644 --- a/src/MetroidPrime/ScriptObjects/CScriptActor.cpp +++ b/src/MetroidPrime/ScriptObjects/CScriptActor.cpp @@ -39,7 +39,7 @@ CScriptActor::CScriptActor(TUniqueId uid, const rstl::string& name, const CEntit , x2e3_24_isPlayerActor(false) { if (HasModelData()) { if (castsShadow) { - CreateShadow(true); + SetDrawShadow(true); } if (HasAnimation()) { diff --git a/src/MetroidPrime/ScriptObjects/CScriptGenerator.cpp b/src/MetroidPrime/ScriptObjects/CScriptGenerator.cpp index 3ac81b5d..f2927c4e 100644 --- a/src/MetroidPrime/ScriptObjects/CScriptGenerator.cpp +++ b/src/MetroidPrime/ScriptObjects/CScriptGenerator.cpp @@ -154,7 +154,7 @@ void CScriptGenerator::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sende mData->SetScale(rnd * mData->GetScale()); } - stateMgr.SendScriptMsg(genObj, GetUniqueId(), kSM_Activate); + stateMgr.DeliverScriptMsg(genObj, GetUniqueId(), kSM_Activate); } } diff --git a/src/MetroidPrime/ScriptObjects/CScriptMazeNode.cpp b/src/MetroidPrime/ScriptObjects/CScriptMazeNode.cpp index 65441128..e4182888 100644 --- a/src/MetroidPrime/ScriptObjects/CScriptMazeNode.cpp +++ b/src/MetroidPrime/ScriptObjects/CScriptMazeNode.cpp @@ -354,7 +354,7 @@ void CScriptMazeNode::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, C x13c_24_hasPuddle = true; } if (x13c_25_hasGate) { -#ifndef NON_MATCHING +#if !NONMATCHING // Unused CTransform4f xf = GetTransform(); #endif diff --git a/src/MetroidPrime/ScriptObjects/CScriptPlatform.cpp b/src/MetroidPrime/ScriptObjects/CScriptPlatform.cpp index 8d4d691e..8d7611da 100644 --- a/src/MetroidPrime/ScriptObjects/CScriptPlatform.cpp +++ b/src/MetroidPrime/ScriptObjects/CScriptPlatform.cpp @@ -147,7 +147,7 @@ void CScriptPlatform::AddRider(rstl::vector< SRiders >& riders, TUniqueId riderI CVector3f rideePos = ridee->GetTranslation(); rider.x8_transform.SetTranslation( ridee->GetTransform().TransposeRotate(act->GetTranslation() - rideePos)); - mgr.SendScriptMsg(act, ridee->GetUniqueId(), kSM_AddPlatformRider); + mgr.DeliverScriptMsg(act, ridee->GetUniqueId(), kSM_AddPlatformRider); } riders.reserve(riders.size() + 1); riders.push_back(rider); @@ -174,15 +174,14 @@ void CScriptPlatform::DecayRiders(rstl::vector< SRiders >& riders, float dt, CSt it->x4_decayTimer -= dt; if (it->x4_decayTimer <= 0.f) { mgr.SendScriptMsgAlways(it->x0_uid, kInvalidUniqueId, kSM_AddPlatformRider); -#ifdef NON_MATCHING +#if NONMATCHING it = riders.erase(it); #else // Oops, forgot to reassign the iterator riders.erase(it); #endif } else { - // TODO: likely it++ (post-increment) but not matching - it = it + 1; + it++; } } } @@ -213,7 +212,7 @@ void CScriptPlatform::MoveRiders(CStateManager& mgr, float dt, bool active, act->MoveCollisionPrimitive(CVector3f::Zero()); if (collision) { AddRider(collidedRiders, act->GetUniqueId(), act, mgr); -#ifdef NON_MATCHING +#if NONMATCHING it = riders.erase(it); #else // Oops, forgot to reassign the iterator (again) diff --git a/src/MetroidPrime/Weapons/CPlasmaBeam.cpp b/src/MetroidPrime/Weapons/CPlasmaBeam.cpp index 3005008f..47e7a368 100644 --- a/src/MetroidPrime/Weapons/CPlasmaBeam.cpp +++ b/src/MetroidPrime/Weapons/CPlasmaBeam.cpp @@ -74,7 +74,7 @@ void CPlasmaBeam::Update(float dt, CStateManager& mgr) { return; if (CGunWeapon::IsLoaded() && !x22c_24_loaded) { - x22c_24_loaded = x21c_plasma2nd1.IsLoaded(); + x22c_24_loaded = x21c_plasma2nd1.TryCache(); if (x22c_24_loaded) CreateBeam(mgr); } diff --git a/src/MetroidPrime/Weapons/CPowerBeam.cpp b/src/MetroidPrime/Weapons/CPowerBeam.cpp index 18b0c932..41b09dc4 100644 --- a/src/MetroidPrime/Weapons/CPowerBeam.cpp +++ b/src/MetroidPrime/Weapons/CPowerBeam.cpp @@ -94,7 +94,7 @@ void CPowerBeam::Update(float dt, CStateManager& mgr) { return; if (CGunWeapon::IsLoaded() && !x244_25_loaded) { - x244_25_loaded = x21c_shotSmoke.IsLoaded() && x228_power2nd1.IsLoaded(); + x244_25_loaded = x21c_shotSmoke.TryCache() && x228_power2nd1.TryCache(); if (x244_25_loaded) { x234_shotSmokeGen = rs_new CElementGen(x21c_shotSmoke); x234_shotSmokeGen->SetParticleEmission(false);