/
redgpu
/
ezEngine
Обзор
Документация
Войти
/
redgpu
/
ezEngine
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
Code/Engine/RendererCore/AnimationSystem/AnimGraph/Implementation/AnimGraphPins.cpp
212 строк
7 KB
Jan Krassnigg
Minor restructure of the animation system + better documentation (#1699)
26 окт 2025, 23:15
Не верифицирован
26 окт 2025, 23:15
61cd3f5
Код
Авторство
О чём код?
#include <RendererCore/RendererCorePCH.h> #include <RendererCore/AnimationSystem/AnimGraph/AnimController.h> #include <RendererCore/AnimationSystem/AnimGraph/AnimGraph.h> #include <RendererCore/AnimationSystem/AnimGraph/AnimGraphInstance.h> #include <RendererCore/AnimationSystem/AnimGraph/AnimGraphPins.h> // clang-format off EZ_BEGIN_DYNAMIC_REFLECTED_TYPE(ezAnimGraphPin, 1, ezRTTINoAllocator) { EZ_BEGIN_PROPERTIES { EZ_MEMBER_PROPERTY("PinIdx", m_iPinIndex)->AddAttributes(new ezHiddenAttribute()), EZ_MEMBER_PROPERTY("NumConnections", m_uiNumConnections)->AddAttributes(new ezHiddenAttribute()), } EZ_END_PROPERTIES; } EZ_END_DYNAMIC_REFLECTED_TYPE; EZ_BEGIN_DYNAMIC_REFLECTED_TYPE(ezAnimGraphInputPin, 1, ezRTTINoAllocator) EZ_END_DYNAMIC_REFLECTED_TYPE; EZ_BEGIN_DYNAMIC_REFLECTED_TYPE(ezAnimGraphOutputPin, 1, ezRTTINoAllocator) EZ_END_DYNAMIC_REFLECTED_TYPE; // clang-format on ezResult ezAnimGraphPin::Serialize(ezStreamWriter& inout_stream) const { inout_stream << m_iPinIndex; inout_stream << m_uiNumConnections; return EZ_SUCCESS; } ezResult ezAnimGraphPin::Deserialize(ezStreamReader& inout_stream) { inout_stream >> m_iPinIndex; inout_stream >> m_uiNumConnections; return EZ_SUCCESS; } ////////////////////////////////////////////////////////////////////////// // clang-format off EZ_BEGIN_DYNAMIC_REFLECTED_TYPE(ezAnimGraphTriggerInputPin, 1, ezRTTIDefaultAllocator<ezAnimGraphTriggerInputPin>) EZ_END_DYNAMIC_REFLECTED_TYPE; EZ_BEGIN_DYNAMIC_REFLECTED_TYPE(ezAnimGraphTriggerOutputPin, 1, ezRTTIDefaultAllocator<ezAnimGraphTriggerOutputPin>) EZ_END_DYNAMIC_REFLECTED_TYPE; // clang-format on void ezAnimGraphTriggerOutputPin::SetTriggered(ezAnimGraphInstance& ref_graph) const { if (m_iPinIndex < 0) return; const auto& map = ref_graph.m_pAnimGraph->m_OutputPinToInputPinMapping[ezAnimGraphPin::Trigger][m_iPinIndex]; const ezInt8 offset = +1; // bTriggered ? +1 : -1; // trigger or reset all input pins that are connected to this output pin for (ezUInt16 idx : map) { ref_graph.m_pTriggerInputPinStates[idx] += offset; } } bool ezAnimGraphTriggerInputPin::IsTriggered(ezAnimGraphInstance& ref_graph) const { if (m_iPinIndex < 0) return false; return ref_graph.m_pTriggerInputPinStates[m_iPinIndex] > 0; } bool ezAnimGraphTriggerInputPin::AreAllTriggered(ezAnimGraphInstance& ref_graph) const { return ref_graph.m_pTriggerInputPinStates[m_iPinIndex] == m_uiNumConnections; } ////////////////////////////////////////////////////////////////////////// // clang-format off EZ_BEGIN_DYNAMIC_REFLECTED_TYPE(ezAnimGraphNumberInputPin, 1, ezRTTIDefaultAllocator<ezAnimGraphNumberInputPin>) EZ_END_DYNAMIC_REFLECTED_TYPE; EZ_BEGIN_DYNAMIC_REFLECTED_TYPE(ezAnimGraphNumberOutputPin, 1, ezRTTIDefaultAllocator<ezAnimGraphNumberOutputPin>) EZ_END_DYNAMIC_REFLECTED_TYPE; // clang-format on double ezAnimGraphNumberInputPin::GetNumber(ezAnimGraphInstance& ref_graph, double fFallback /*= 0.0*/) const { if (m_iPinIndex < 0) return fFallback; return ref_graph.m_pNumberInputPinStates[m_iPinIndex]; } void ezAnimGraphNumberOutputPin::SetNumber(ezAnimGraphInstance& ref_graph, double value) const { if (m_iPinIndex < 0) return; const auto& map = ref_graph.m_pAnimGraph->m_OutputPinToInputPinMapping[ezAnimGraphPin::Number][m_iPinIndex]; // set all input pins that are connected to this output pin for (ezUInt16 idx : map) { ref_graph.m_pNumberInputPinStates[idx] = value; } } ////////////////////////////////////////////////////////////////////////// // clang-format off EZ_BEGIN_DYNAMIC_REFLECTED_TYPE(ezAnimGraphBoolInputPin, 1, ezRTTIDefaultAllocator<ezAnimGraphBoolInputPin>) EZ_END_DYNAMIC_REFLECTED_TYPE; EZ_BEGIN_DYNAMIC_REFLECTED_TYPE(ezAnimGraphBoolOutputPin, 1, ezRTTIDefaultAllocator<ezAnimGraphBoolOutputPin>) EZ_END_DYNAMIC_REFLECTED_TYPE; // clang-format on bool ezAnimGraphBoolInputPin::GetBool(ezAnimGraphInstance& ref_graph, bool bFallback /*= false */) const { if (m_iPinIndex < 0) return bFallback; return ref_graph.m_pBoolInputPinStates[m_iPinIndex]; } void ezAnimGraphBoolOutputPin::SetBool(ezAnimGraphInstance& ref_graph, bool bValue) const { if (m_iPinIndex < 0) return; const auto& map = ref_graph.m_pAnimGraph->m_OutputPinToInputPinMapping[ezAnimGraphPin::Bool][m_iPinIndex]; // set all input pins that are connected to this output pin for (ezUInt16 idx : map) { ref_graph.m_pBoolInputPinStates[idx] = bValue; } } ////////////////////////////////////////////////////////////////////////// // clang-format off EZ_BEGIN_DYNAMIC_REFLECTED_TYPE(ezAnimGraphBoneWeightsInputPin, 1, ezRTTIDefaultAllocator<ezAnimGraphBoneWeightsInputPin>) EZ_END_DYNAMIC_REFLECTED_TYPE; EZ_BEGIN_DYNAMIC_REFLECTED_TYPE(ezAnimGraphBoneWeightsOutputPin, 1, ezRTTIDefaultAllocator<ezAnimGraphBoneWeightsOutputPin>) EZ_END_DYNAMIC_REFLECTED_TYPE; // clang-format on ezAnimGraphPinDataBoneWeights* ezAnimGraphBoneWeightsInputPin::GetWeights(ezAnimController& ref_controller, ezAnimGraphInstance& ref_graph) const { if (m_iPinIndex < 0 || ref_graph.m_pBoneWeightInputPinStates[m_iPinIndex] == 0xFFFF) return nullptr; return &ref_controller.m_PinDataBoneWeights[ref_graph.m_pBoneWeightInputPinStates[m_iPinIndex]]; } void ezAnimGraphBoneWeightsOutputPin::SetWeights(ezAnimGraphInstance& ref_graph, ezAnimGraphPinDataBoneWeights* pWeights) const { if (m_iPinIndex < 0) return; const auto& map = ref_graph.m_pAnimGraph->m_OutputPinToInputPinMapping[ezAnimGraphPin::BoneWeights][m_iPinIndex]; // set all input pins that are connected to this output pin for (ezUInt16 idx : map) { ref_graph.m_pBoneWeightInputPinStates[idx] = pWeights->m_uiOwnIndex; } } ////////////////////////////////////////////////////////////////////////// // clang-format off EZ_BEGIN_DYNAMIC_REFLECTED_TYPE(ezAnimGraphLocalPoseInputPin, 1, ezRTTIDefaultAllocator<ezAnimGraphLocalPoseInputPin>) EZ_END_DYNAMIC_REFLECTED_TYPE; EZ_BEGIN_DYNAMIC_REFLECTED_TYPE(ezAnimGraphLocalPoseOutputPin, 1, ezRTTIDefaultAllocator<ezAnimGraphLocalPoseOutputPin>) EZ_END_DYNAMIC_REFLECTED_TYPE; // clang-format on ezAnimGraphPinDataLocalTransforms* ezAnimGraphLocalPoseInputPin::GetPose(ezAnimController& ref_controller, ezAnimGraphInstance& ref_graph) const { if (m_iPinIndex < 0) return nullptr; if (ref_graph.m_LocalPoseInputPinStates[m_iPinIndex].IsEmpty()) return nullptr; return &ref_controller.m_PinDataLocalTransforms[ref_graph.m_LocalPoseInputPinStates[m_iPinIndex][0]]; } void ezAnimGraphLocalPoseOutputPin::SetPose(ezAnimGraphInstance& ref_graph, ezAnimGraphPinDataLocalTransforms* pPose) const { if (m_iPinIndex < 0) return; const auto& map = ref_graph.m_pAnimGraph->m_OutputPinToInputPinMapping[ezAnimGraphPin::LocalPose][m_iPinIndex]; // set all input pins that are connected to this output pin for (ezUInt16 idx : map) { ref_graph.m_LocalPoseInputPinStates[idx].PushBack(pPose->m_uiOwnIndex); } } EZ_STATICLINK_FILE(RendererCore, RendererCore_AnimationSystem_AnimGraph_Implementation_AnimGraphPins);