From 8422ffb4362edc65887f6b4f10e75a847bed923c Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Fri, 2 Sep 2016 20:47:57 -0700 Subject: [PATCH 1/3] Implement GetLocatorTransform --- Editor/ViewManager.cpp | 4 ++-- Runtime/Character/CAnimData.cpp | 12 ++++++++++-- Runtime/Character/CCharLayoutInfo.cpp | 9 +++++++++ Runtime/Character/CCharLayoutInfo.hpp | 1 + 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/Editor/ViewManager.cpp b/Editor/ViewManager.cpp index a6ae2ebb7..b17390b44 100644 --- a/Editor/ViewManager.cpp +++ b/Editor/ViewManager.cpp @@ -35,7 +35,7 @@ void ViewManager::BuildTestPART(urde::IObjectStore& objStore) CAnimRes samusAnimRes(samusCharSet.id, 2, zeus::CVector3f{2.f, 2.f, 2.f}, 0, true); g_GameState->GetWorldTransitionManager()->EnableTransition(samusAnimRes, platModel.id, zeus::CVector3f::skOne, - bgModel.id, zeus::CVector3f::skOne, false); + bgModel.id, zeus::CVector3f::skOne, true); #endif SObjectTag areaTag = m_projManager.TagFromPath( @@ -70,7 +70,7 @@ void ViewManager::BuildTestPART(urde::IObjectStore& objStore) m_videoVoice = m_voiceEngine->allocateNewStereoVoice(32000, &m_voiceCallback); m_videoVoice->start(); - //m_rootView->accessContentViews().clear(); + m_rootView->accessContentViews().clear(); m_rootView->accessContentViews().push_back(m_particleView.get()); m_rootView->updateSize(); } diff --git a/Runtime/Character/CAnimData.cpp b/Runtime/Character/CAnimData.cpp index 325ac5245..b7d567c34 100644 --- a/Runtime/Character/CAnimData.cpp +++ b/Runtime/Character/CAnimData.cpp @@ -178,12 +178,20 @@ void CAnimData::CalcPlaybackAlignmentParms(const CAnimPlaybackParms& parms, zeus::CTransform CAnimData::GetLocatorTransform(CSegId id, const CCharAnimTime* time) const { - return {}; + if (id == 0xFF) + return {}; + + zeus::CTransform ret; + if (!x220_31_poseCached) + const_cast(this)->RecalcPoseBuilder(time); + + x2fc_poseBuilder.BuildTransform(id, ret); + return ret; } zeus::CTransform CAnimData::GetLocatorTransform(const std::string& name, const CCharAnimTime* time) const { - return {}; + return GetLocatorTransform(xcc_layoutData->GetSegIdFromString(name), time); } bool CAnimData::IsAnimTimeRemaining(float, const std::string& name) const diff --git a/Runtime/Character/CCharLayoutInfo.cpp b/Runtime/Character/CCharLayoutInfo.cpp index 9878f8c56..a5e0742f8 100644 --- a/Runtime/Character/CCharLayoutInfo.cpp +++ b/Runtime/Character/CCharLayoutInfo.cpp @@ -16,6 +16,15 @@ zeus::CVector3f CCharLayoutInfo::GetFromParentUnrotated(const CSegId& id) const } } +CSegId CCharLayoutInfo::GetSegIdFromString(const std::string& name) const +{ + auto it = x18_segIdMap.find(name); + if (it == x18_segIdMap.end()) + return {}; + + return (*it).second; +} + void CCharLayoutNode::Bone::read(CInputStream& in) { x0_parentId = CSegId(in); diff --git a/Runtime/Character/CCharLayoutInfo.hpp b/Runtime/Character/CCharLayoutInfo.hpp index 0b1427cc8..d9762b009 100644 --- a/Runtime/Character/CCharLayoutInfo.hpp +++ b/Runtime/Character/CCharLayoutInfo.hpp @@ -37,6 +37,7 @@ public: const std::shared_ptr& GetRootNode() const {return x0_node;} const CSegIdList& GetSegIdList() const {return x8_segIdList;} zeus::CVector3f GetFromParentUnrotated(const CSegId& id) const; + CSegId GetSegIdFromString(const std::string& name) const; }; CFactoryFnReturn FCharLayoutInfo(const SObjectTag&, CInputStream&, const CVParamTransfer&, From 5979ccaf9360b5b4bf92a2f2a0f26ca1d192513f Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Fri, 2 Sep 2016 20:50:00 -0700 Subject: [PATCH 2/3] Set CAnimData pose cached flag --- Runtime/Character/CAnimData.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Runtime/Character/CAnimData.cpp b/Runtime/Character/CAnimData.cpp index b7d567c34..06299fb41 100644 --- a/Runtime/Character/CAnimData.cpp +++ b/Runtime/Character/CAnimData.cpp @@ -183,7 +183,10 @@ zeus::CTransform CAnimData::GetLocatorTransform(CSegId id, const CCharAnimTime* zeus::CTransform ret; if (!x220_31_poseCached) + { const_cast(this)->RecalcPoseBuilder(time); + const_cast(this)->x220_31_poseCached = true; + } x2fc_poseBuilder.BuildTransform(id, ret); return ret; From 4d4288858b911a8812b20ccb4f3afa1564a8e98b Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Fri, 2 Sep 2016 20:58:41 -0700 Subject: [PATCH 3/3] Proper CAnimData::GetLocatorTransform imp --- Runtime/Character/CAnimData.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Runtime/Character/CAnimData.cpp b/Runtime/Character/CAnimData.cpp index 06299fb41..3916a37e4 100644 --- a/Runtime/Character/CAnimData.cpp +++ b/Runtime/Character/CAnimData.cpp @@ -183,12 +183,17 @@ zeus::CTransform CAnimData::GetLocatorTransform(CSegId id, const CCharAnimTime* zeus::CTransform ret; if (!x220_31_poseCached) - { const_cast(this)->RecalcPoseBuilder(time); - const_cast(this)->x220_31_poseCached = true; - } - x2fc_poseBuilder.BuildTransform(id, ret); + if (!x220_31_poseCached) + x2fc_poseBuilder.BuildTransform(id, ret); + else + { + zeus::CMatrix3f rot = x224_pose.GetRotation(id); + zeus::CVector3f offset = x224_pose.GetOffset(id); + ret.setRotation(rot); + ret.origin = offset; + } return ret; }