AnimGraphHubNodeTests.cpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include <Tests/AnimGraphFixture.h>
  9. #include <EMotionFX/Source/AnimGraph.h>
  10. #include <EMotionFX/Source/AnimGraphEntryNode.h>
  11. #include <EMotionFX/Source/AnimGraphHubNode.h>
  12. #include <EMotionFX/Source/AnimGraphMotionNode.h>
  13. #include <EMotionFX/Source/AnimGraphStateMachine.h>
  14. #include <EMotionFX/Source/EMotionFXManager.h>
  15. namespace EMotionFX
  16. {
  17. class AnimGraphHubNodeFixture_CircularEntryNodeDependency : public AnimGraphFixture
  18. {
  19. public:
  20. void ConstructGraph() override
  21. {
  22. AnimGraphFixture::ConstructGraph();
  23. AnimGraphMotionNode* motionNode = aznew AnimGraphMotionNode();
  24. motionNode->SetName("Motion0");
  25. m_rootStateMachine->AddChildNode(motionNode);
  26. m_rootStateMachine->SetEntryState(motionNode);
  27. AnimGraphStateMachine* stateMachine = aznew AnimGraphStateMachine();
  28. stateMachine->SetName("StateMachine0");
  29. m_rootStateMachine->AddChildNode(stateMachine);
  30. AnimGraphEntryNode* entryNode = aznew AnimGraphEntryNode();
  31. entryNode->SetName("EntryNode0");
  32. stateMachine->AddChildNode(entryNode);
  33. stateMachine->SetEntryState(entryNode);
  34. AnimGraphHubNode* hubNode = aznew AnimGraphHubNode();
  35. hubNode->SetName("HubNode0");
  36. m_rootStateMachine->AddChildNode(hubNode);
  37. AddTransitionWithTimeCondition(motionNode, stateMachine, 0.3f, 0.5f);
  38. AddTransitionWithTimeCondition(stateMachine, hubNode, 0.3f, 0.5f);
  39. }
  40. };
  41. TEST_F(AnimGraphHubNodeFixture_CircularEntryNodeDependency, AnimGraphHubNode_CircularEntryNodeDependency)
  42. {
  43. // Simulate for two seconds at 10 fps to make sure to reach the hub node.
  44. for (size_t i = 0; i < 20; ++i)
  45. {
  46. GetEMotionFX().Update(1.0f / 10.0f);
  47. }
  48. }
  49. } // namespace EMotionFX