From ac1bfd45c6c8eed42ad5038733b3e8271e584a30 Mon Sep 17 00:00:00 2001 From: elijah-thomas774 Date: Sun, 9 Jun 2024 22:32:39 -0400 Subject: [PATCH] lyt_util OK --- config/SOUE01/splits.txt | 4 +++ config/SOUE01/symbols.txt | 8 +++--- configure.py | 1 + include/nw4r/lyt/lyt_pane.h | 4 +-- include/nw4r/lyt/lyt_utils.h | 6 ++++ include/nw4r/math/math_types.h | 4 +-- src/nw4r/lyt/lyt_util.cpp | 51 ++++++++++++++++++++++++++++++---- 7 files changed, 64 insertions(+), 14 deletions(-) diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index 5428e745..d5a1d558 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -401,6 +401,10 @@ nw4r/lyt/lyt_common.cpp: .sdata2 start:0x8057F2E0 end:0x8057F2E8 .bss start:0x80673AA8 end:0x80673AC8 +nw4r/lyt/lyt_util.cpp: + .text start:0x804932E0 end:0x8049350C + .sdata2 start:0x8057F2E8 end:0x8057F2EC + egg/core/eggArchive.cpp: .text start:0x80493510 end:0x80494254 .data start:0x8056E820 end:0x8056E830 diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index f309f30a..50b4e003 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -26116,9 +26116,9 @@ SetVertexFormat__Q34nw4r3lyt6detailFbUc = .text:0x80492B60; // type:function siz DrawQuad__Q34nw4r3lyt6detailFRCQ34nw4r4math4VEC2RCQ34nw4r3lyt4SizeUcPA4_CQ34nw4r4math4VEC2PCQ34nw4r2ut5Color = .text:0x80492C50; // type:function size:0x560 DrawQuad__Q34nw4r3lyt6detailFRCQ34nw4r4math4VEC2RCQ34nw4r3lyt4SizeUcPA4_CQ34nw4r4math4VEC2PCQ34nw4r2ut5ColorUc = .text:0x804931B0; // type:function size:0x130 BindAnimation__Q24nw4r3lytFPQ34nw4r3lyt5GroupPQ34nw4r3lyt13AnimTransformbb = .text:0x804932E0; // type:function size:0x70 -FUN_80493350 = .text:0x80493350; // type:function size:0x78 -FUN_804933d0 = .text:0x804933D0; // type:function size:0x70 -FUN_80493440 = .text:0x80493440; // type:function size:0xCC +UnbindAnimation__Q24nw4r3lytFPQ34nw4r3lyt5GroupPQ34nw4r3lyt13AnimTransformb = .text:0x80493350; // type:function size:0x78 +SetAnimationEnable__Q24nw4r3lytFPQ34nw4r3lyt5GroupPQ34nw4r3lyt13AnimTransformbb = .text:0x804933D0; // type:function size:0x70 +IsContain__Q24nw4r3lytFPQ34nw4r3lyt4PaneRCQ34nw4r4math4VEC2 = .text:0x80493440; // type:function size:0xCC readNand__Q23EGG7ArchiveFP12NANDFileInfoPvUll = .text:0x80493510; // type:function size:0x70 __ct__Q23EGG7ArchiveFv = .text:0x80493580; // type:function size:0x70 __dt__Q23EGG7ArchiveFv = .text:0x804935F0; // type:function size:0x6C @@ -47595,7 +47595,7 @@ lbl_8057F2D8 = .sdata2:0x8057F2D8; // type:object size:0x4 data:float lbl_8057F2DC = .sdata2:0x8057F2DC; // type:object size:0x4 data:float lbl_8057F2E0 = .sdata2:0x8057F2E0; // type:object size:0x4 data:float lbl_8057F2E4 = .sdata2:0x8057F2E4; // type:object size:0x4 data:float -lbl_8057F2E8 = .sdata2:0x8057F2E8; // type:object size:0x8 data:float +lbl_8057F2E8 = .sdata2:0x8057F2E8; // type:object size:0x4 data:float eggAllocatorFuncs = .sdata2:0x8057F2F0; // type:object size:0x8 scope:local lbl_8057F2F8 = .sdata2:0x8057F2F8; // type:object size:0x4 data:float lbl_8057F300 = .sdata2:0x8057F300; // type:object size:0x8 data:double diff --git a/configure.py b/configure.py index 08bdcd94..ba317b47 100644 --- a/configure.py +++ b/configure.py @@ -367,6 +367,7 @@ config.libs = [ Object(Matching, "nw4r/lyt/lyt_resourceAccessor.cpp"), Object(Matching, "nw4r/lyt/lyt_arcResourceAccessor.cpp"), Object(Matching, "nw4r/lyt/lyt_common.cpp"), + Object(Matching, "nw4r/lyt/lyt_util.cpp"), ], [""] ), # EGG diff --git a/include/nw4r/lyt/lyt_pane.h b/include/nw4r/lyt/lyt_pane.h index b73d8d30..20c38ed3 100644 --- a/include/nw4r/lyt/lyt_pane.h +++ b/include/nw4r/lyt/lyt_pane.h @@ -50,8 +50,8 @@ public: return &mAnimList; } - const math::MTX34 *GetGlobalMtx() const { - return &mGlbMtx; + const math::MTX34 &GetGlobalMtx() const { + return mGlbMtx; } Pane *GetParent() const { return mpParent; diff --git a/include/nw4r/lyt/lyt_utils.h b/include/nw4r/lyt/lyt_utils.h index 3c5a72fd..d5ffcb18 100644 --- a/include/nw4r/lyt/lyt_utils.h +++ b/include/nw4r/lyt/lyt_utils.h @@ -8,6 +8,12 @@ namespace nw4r { namespace lyt { void BindAnimation(Group *pGroup, AnimTransform *pAnimTrans, bool bRecursive, bool bDisable); +void UnbindAnimation(Group *pGroup, AnimTransform *pAnimTrans, bool bRecusive); +void SetAnimationEnable(Group *pGroup, AnimTransform *pAnimTrans, bool bEnable, bool bRecursive); +bool IsContain(Pane *pPane, const math::VEC2 &pos); +Pane *FindHitPane(Pane *pPane, const math::VEC2 &pos); +Pane *FindHitPane(Layout *pLayout, const math::VEC2 &pos); +Pane *GetNextPane(Pane *); } // namespace lyt diff --git a/include/nw4r/math/math_types.h b/include/nw4r/math/math_types.h index f08094d4..08843736 100644 --- a/include/nw4r/math/math_types.h +++ b/include/nw4r/math/math_types.h @@ -209,10 +209,10 @@ struct MTX34 : _MTX34 { } // clang-format on - operator MtxRef() { + inline operator MtxRef() { return mtx; } - operator MtxRefConst() const { + inline operator MtxRefConst() const { return mtx; } }; diff --git a/src/nw4r/lyt/lyt_util.cpp b/src/nw4r/lyt/lyt_util.cpp index 972ab47e..33bba481 100644 --- a/src/nw4r/lyt/lyt_util.cpp +++ b/src/nw4r/lyt/lyt_util.cpp @@ -1,7 +1,8 @@ -#include -#include +#include +#include #include +#include #include namespace nw4r { @@ -9,22 +10,60 @@ namespace lyt { namespace { // Contains__Q34nw4r3lyt22@unnamed@lyt_util_cpp@FRCQ34nw4r2ut4RectRCQ34nw4r4math4VEC2 -bool Contains(const ut::Rect &rect, const math::VEC2 &point) {} +bool Contains(const ut::Rect &rect, const math::VEC2 &point) { + return (rect.left <= point.x && point.x <= rect.right) && (rect.bottom <= point.y && point.y <= rect.top); +} + } // namespace // BindAnimation__Q24nw4r3lytFPQ34nw4r3lyt5GroupPQ34nw4r3lyt13AnimTransformbb -void BindAnimation(Group *pGroup, AnimTransform *pAnimTrans, bool bRecursive, bool bDisable) {} +void BindAnimation(Group *pGroup, AnimTransform *pAnimTrans, bool bRecursive, bool bDisable) { + ut::LinkList &paneList = *pGroup->GetPaneList(); + for (ut::LinkList::Iterator it = paneList.GetBeginIter(); it != paneList.GetEndIter(); it++) { + it->mTarget->BindAnimation(pAnimTrans, bRecursive, bDisable); + } +} + +// UnbindAnimation__Q24nw4r3lytFPQ34nw4r3lyt5GroupPQ34nw4r3lyt13AnimTransformb +void UnbindAnimation(Group *pGroup, AnimTransform *pAnimTrans, bool bRecursive) { + ut::LinkList &paneList = *pGroup->GetPaneList(); + for (ut::LinkList::Iterator it = paneList.GetBeginIter(); it != paneList.GetEndIter(); it++) { + it->mTarget->UnbindAnimation(pAnimTrans, bRecursive); + } +} // SetAnimationEnable__Q24nw4r3lytFPQ34nw4r3lyt5GroupPQ34nw4r3lyt13AnimTransformbb -void SetAnimationEnable(Group *pGroup, nw4r::lyt::AnimTransform *pAnimTrans, bool bEnable, bool bRecursive) {} +void SetAnimationEnable(Group *pGroup, nw4r::lyt::AnimTransform *pAnimTrans, bool bEnable, bool bRecursive) { + ut::LinkList &paneList = *pGroup->GetPaneList(); + for (ut::LinkList::Iterator it = paneList.GetBeginIter(); it != paneList.GetEndIter(); it++) { + it->mTarget->SetAnimationEnable(pAnimTrans, bEnable, bRecursive); + } +} // IsContain__Q24nw4r3lytFPQ34nw4r3lyt4PaneRCQ34nw4r4math4VEC2 bool IsContain(Pane *pPane, const math::VEC2 &pos) { - return false; + math::MTX34 invGlbMtx; + PSMTXInverse(pPane->GetGlobalMtx(), invGlbMtx); + math::VEC3 lclPos; + PSMTXMultVec(invGlbMtx, math::VEC3(pos.x, pos.y, 0.0f), lclPos); + return Contains(pPane->GetPaneRect(), math::VEC2(lclPos.x, lclPos.y)); } // FindHitPane__Q24nw4r3lytFPQ34nw4r3lyt4PaneRCQ34nw4r4math4VEC2 Pane *FindHitPane(Pane *pPane, const math::VEC2 &pos) { + // TODO + return nullptr; +} + +// FindHitPane__Q24nw4r3lytFPQ34nw4r3lyt6LayoutRCQ34nw4r4math4VEC2 +Pane *FindHitPane(Layout *pLayout, const math::VEC2 &pos) { + // TODO + return nullptr; +} + +// GetNextPane__Q24nw4r3lytFPQ34nw4r3lyt4Pane +Pane *GetNextPane(Pane *) { + // TODO return nullptr; }