BlendSpaceTests.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  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 <AzCore/Math/IntersectPoint.h>
  9. #include <EMotionFX/Source/BlendSpaceParamEvaluator.h>
  10. #include <Tests/BlendSpaceFixture.h>
  11. namespace EMotionFX
  12. {
  13. class BlendSpaceParamEvaluatorFixture
  14. : public BlendSpaceFixture
  15. {
  16. public:
  17. void TearDown() override
  18. {
  19. m_motionInstance->Destroy();
  20. m_evaluator->Destroy();
  21. BlendSpaceFixture::TearDown();
  22. }
  23. void PrepareTest(Motion* motion, BlendSpaceParamEvaluator* evaluator)
  24. {
  25. ASSERT_NE(motion, nullptr) << "Expected a valid motion.";
  26. m_motionInstance = MotionInstance::Create(motion, m_actorInstance);
  27. m_evaluator = evaluator;
  28. m_value = m_evaluator->ComputeParamValue(*m_motionInstance);
  29. }
  30. public:
  31. MotionInstance* m_motionInstance = nullptr;
  32. BlendSpaceParamEvaluator* m_evaluator = nullptr;
  33. float m_value = -1.0f;
  34. };
  35. TEST_F(BlendSpaceParamEvaluatorFixture, BlendSpaceParamEvaluatorNoneTest)
  36. {
  37. PrepareTest(m_idleMotion, aznew BlendSpaceParamEvaluatorNone());
  38. EXPECT_FLOAT_EQ(m_value, 0.0f) << "Expected 0.0 from the none evaluator.";
  39. }
  40. TEST_F(BlendSpaceParamEvaluatorFixture, BlendSpaceMoveSpeedParamEvaluatorTest)
  41. {
  42. PrepareTest(m_forwardMotion, aznew BlendSpaceMoveSpeedParamEvaluator());
  43. EXPECT_FLOAT_EQ(m_value, 1.0f) << "Expected a move speed of 1.0 unit per second.";
  44. }
  45. TEST_F(BlendSpaceParamEvaluatorFixture, BlendSpaceTurnSpeedParamEvaluatorTest)
  46. {
  47. PrepareTest(m_rotateLeftMotion, aznew BlendSpaceTurnSpeedParamEvaluator());
  48. EXPECT_TRUE(AZ::IsClose(m_value, -0.5f, 0.001f))
  49. << "Expected a turn speed of -0.5 radians per second. Negative because we prefer the convention of clockwise being positive turn speed.";
  50. }
  51. TEST_F(BlendSpaceParamEvaluatorFixture, BlendSpaceTravelDirectionParamEvaluatorTest)
  52. {
  53. PrepareTest(m_forwardStrafe45, aznew BlendSpaceTravelDirectionParamEvaluator());
  54. EXPECT_TRUE(AZ::IsClose(m_value, AZ::DegToRad(45.0f), 0.001f))
  55. << "Expected a travel direction of 45 degrees.";
  56. }
  57. TEST_F(BlendSpaceParamEvaluatorFixture, BlendSpaceTravelSlopeParamEvaluatorTest)
  58. {
  59. PrepareTest(m_forwardSlope45, aznew BlendSpaceTravelSlopeParamEvaluator());
  60. EXPECT_TRUE(AZ::IsClose(m_value, AZ::DegToRad(45.0f), 0.001f))
  61. << "";
  62. }
  63. TEST_F(BlendSpaceParamEvaluatorFixture, BlendSpaceTurnAngleParamEvaluatorTest)
  64. {
  65. PrepareTest(m_rotateLeftMotion, aznew BlendSpaceTurnAngleParamEvaluator());
  66. EXPECT_TRUE(AZ::IsClose(m_value, -0.5f, 0.001f))
  67. << "Expected a turn angle of -0.5 radians over the full motion.";
  68. }
  69. TEST_F(BlendSpaceParamEvaluatorFixture, BlendSpaceTravelDistanceParamEvaluatorTest)
  70. {
  71. PrepareTest(m_forwardStrafe45, aznew BlendSpaceTravelDistanceParamEvaluator());
  72. EXPECT_TRUE(AZ::IsClose(m_value, AZ::Vector2(1.0f, 1.0f).GetLength(), 0.001f))
  73. << "Expected travel distance of Vec3(1.0, 1.0).Length().";
  74. }
  75. TEST_F(BlendSpaceParamEvaluatorFixture, BlendSpaceLeftRightVelocityParamEvaluatorTest)
  76. {
  77. PrepareTest(m_strafeMotion, aznew BlendSpaceLeftRightVelocityParamEvaluator());
  78. EXPECT_TRUE(AZ::IsClose(m_value, 1.0f, 0.001f))
  79. << "Expected strafe velocity 1.0 units per second.";
  80. }
  81. TEST_F(BlendSpaceParamEvaluatorFixture, BlendSpaceFrontBackVelocityParamEvaluatorTest)
  82. {
  83. PrepareTest(m_forwardMotion, aznew BlendSpaceFrontBackVelocityParamEvaluator());
  84. EXPECT_TRUE(AZ::IsClose(m_value, 1.0f, 0.001f))
  85. << "Expected forward velocity 1.0 units per second.";
  86. }
  87. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  88. TEST_F(BlendSpace1DFixture, MotionCoordinatesTest)
  89. {
  90. const AZStd::vector<BlendSpaceNode::BlendSpaceMotion>& motions = m_blendSpace1DNode->GetMotions();
  91. BlendSpace1DNode::UniqueData* uniqueData = static_cast<BlendSpace1DNode::UniqueData*>(m_blendSpace1DNode->FindOrCreateUniqueNodeData(m_animGraphInstance));
  92. EXPECT_EQ(motions.size(), 3);
  93. EXPECT_EQ(uniqueData->m_motionCoordinates.size(), 3);
  94. EXPECT_EQ(uniqueData->m_motionCoordinates[0], 0.0f);
  95. EXPECT_EQ(uniqueData->m_motionCoordinates[1], 1.0f);
  96. EXPECT_EQ(uniqueData->m_motionCoordinates[2], 2.0f);
  97. }
  98. TEST_F(BlendSpace1DFixture, EvaluationOutOfBounds)
  99. {
  100. m_floatNodeX->SetValue(-1.0f);
  101. GetEMotionFX().Update(0.1f);
  102. BlendSpace1DNode::UniqueData* uniqueData = static_cast<BlendSpace1DNode::UniqueData*>(m_blendSpace1DNode->FindOrCreateUniqueNodeData(m_animGraphInstance));
  103. EXPECT_EQ(uniqueData->m_currentPosition, -1.0f);
  104. EXPECT_EQ(uniqueData->m_blendInfos.size(), 1) << "Expected to only have one fully active motion.";
  105. EXPECT_EQ(uniqueData->m_currentSegment.m_segmentIndex, InvalidIndex32);
  106. EXPECT_EQ(uniqueData->m_blendInfos[0].m_motionIndex, 0);
  107. EXPECT_EQ(uniqueData->m_blendInfos[0].m_weight, 1.0f);
  108. }
  109. TEST_F(BlendSpace1DFixture, EvaluationOnMotionPoint)
  110. {
  111. m_floatNodeX->SetValue(0.0f);
  112. GetEMotionFX().Update(0.1f);
  113. BlendSpace1DNode::UniqueData* uniqueData = static_cast<BlendSpace1DNode::UniqueData*>(m_blendSpace1DNode->FindOrCreateUniqueNodeData(m_animGraphInstance));
  114. EXPECT_EQ(uniqueData->m_currentPosition, 0.0f);
  115. EXPECT_EQ(uniqueData->m_currentSegment.m_segmentIndex, 0);
  116. EXPECT_EQ(uniqueData->m_blendInfos.size(), 2);
  117. EXPECT_EQ(uniqueData->m_blendInfos[0].m_motionIndex, 0);
  118. EXPECT_EQ(uniqueData->m_blendInfos[0].m_weight, 1.0f);
  119. EXPECT_EQ(uniqueData->m_blendInfos[1].m_motionIndex, 1);
  120. EXPECT_EQ(uniqueData->m_blendInfos[1].m_weight, 0.0f);
  121. }
  122. TEST_F(BlendSpace1DFixture, EvaluationInsideSegment)
  123. {
  124. m_floatNodeX->SetValue(0.5f);
  125. GetEMotionFX().Update(0.1f);
  126. BlendSpace1DNode::UniqueData* uniqueData = static_cast<BlendSpace1DNode::UniqueData*>(m_blendSpace1DNode->FindOrCreateUniqueNodeData(m_animGraphInstance));
  127. EXPECT_EQ(uniqueData->m_currentPosition, 0.5f);
  128. EXPECT_EQ(uniqueData->m_blendInfos.size(), 2);
  129. EXPECT_EQ(uniqueData->m_currentSegment.m_segmentIndex, 0);
  130. EXPECT_EQ(uniqueData->m_blendInfos[0].m_motionIndex, 0);
  131. EXPECT_EQ(uniqueData->m_blendInfos[0].m_weight, 0.5f);
  132. EXPECT_EQ(uniqueData->m_blendInfos[1].m_motionIndex, 1);
  133. EXPECT_EQ(uniqueData->m_blendInfos[1].m_weight, 0.5f);
  134. }
  135. TEST_F(BlendSpace1DFixture, EventsTest_OnMotionPoint_MostActive)
  136. {
  137. m_blendSpace1DNode->SetEventFilterMode(BlendSpaceNode::EBlendSpaceEventMode::BSEVENTMODE_MOST_ACTIVE_MOTION);
  138. EXPECT_CALL(*m_eventHandler, OnEvent(testing::_)).Times(1);
  139. m_floatNodeX->SetValue(0.0f);
  140. GetEMotionFX().Update(0.2f);
  141. }
  142. TEST_F(BlendSpace1DFixture, EventsTest_OnMotionPoint_AllActive)
  143. {
  144. m_blendSpace1DNode->SetEventFilterMode(BlendSpaceNode::EBlendSpaceEventMode::BSEVENTMODE_ALL_ACTIVE_MOTIONS);
  145. EXPECT_CALL(*m_eventHandler, OnEvent(testing::_)).Times(1);
  146. m_floatNodeX->SetValue(0.0f);
  147. GetEMotionFX().Update(0.2f);
  148. }
  149. TEST_F(BlendSpace1DFixture, EventsTest_OnMotionPoint_None)
  150. {
  151. m_blendSpace1DNode->SetEventFilterMode(BlendSpaceNode::EBlendSpaceEventMode::BSEVENTMODE_NONE);
  152. EXPECT_CALL(*m_eventHandler, OnEvent(testing::_)).Times(0);
  153. m_floatNodeX->SetValue(0.0f);
  154. GetEMotionFX().Update(0.2f);
  155. }
  156. TEST_F(BlendSpace1DFixture, EventsTest_InsideSegment_MostActive)
  157. {
  158. m_blendSpace1DNode->SetEventFilterMode(BlendSpaceNode::EBlendSpaceEventMode::BSEVENTMODE_MOST_ACTIVE_MOTION);
  159. EXPECT_CALL(*m_eventHandler, OnEvent(testing::_)).Times(1);
  160. m_floatNodeX->SetValue(0.5f);
  161. GetEMotionFX().Update(0.2f);
  162. }
  163. TEST_F(BlendSpace1DFixture, EventsTest_InsideSegment_AllActive)
  164. {
  165. m_blendSpace1DNode->SetEventFilterMode(BlendSpaceNode::EBlendSpaceEventMode::BSEVENTMODE_ALL_ACTIVE_MOTIONS);
  166. EXPECT_CALL(*m_eventHandler, OnEvent(testing::_)).Times(2);
  167. m_floatNodeX->SetValue(0.5f);
  168. GetEMotionFX().Update(0.2f);
  169. }
  170. TEST_F(BlendSpace1DFixture, EventsTest_InsideSegment_None)
  171. {
  172. m_blendSpace1DNode->SetEventFilterMode(BlendSpaceNode::EBlendSpaceEventMode::BSEVENTMODE_NONE);
  173. EXPECT_CALL(*m_eventHandler, OnEvent(testing::_)).Times(0);
  174. m_floatNodeX->SetValue(0.5f);
  175. GetEMotionFX().Update(0.2f);
  176. }
  177. TEST_F(BlendSpace1DFixture, ComputeMotionCoordinates_Nullptr_Asserts_FT)
  178. {
  179. AZ_TEST_START_TRACE_SUPPRESSION;
  180. AZ::Vector2 testVec(0.0f, 0.0f);
  181. m_blendSpace1DNode->ComputeMotionCoordinates("", nullptr, testVec);
  182. AZ_TEST_STOP_TRACE_SUPPRESSION(1);
  183. }
  184. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  185. TEST_F(BlendSpace2DFixture, MotionCoordinatesTest)
  186. {
  187. const AZStd::vector<BlendSpaceNode::BlendSpaceMotion>& motions = m_blendSpace2DNode->GetMotions();
  188. BlendSpace2DNode::UniqueData* uniqueData = static_cast<BlendSpace2DNode::UniqueData*>(m_blendSpace2DNode->FindOrCreateUniqueNodeData(m_animGraphInstance));
  189. EXPECT_EQ(motions.size(), 4);
  190. EXPECT_EQ(uniqueData->m_motionCoordinates.size(), 4);
  191. EXPECT_EQ(uniqueData->m_motionCoordinates[0], AZ::Vector2(0.0f, 0.0f));
  192. EXPECT_EQ(uniqueData->m_motionCoordinates[1], AZ::Vector2(1.0f, 0.0f));
  193. EXPECT_EQ(uniqueData->m_motionCoordinates[2], AZ::Vector2(2.0f, 0.0f));
  194. EXPECT_EQ(uniqueData->m_motionCoordinates[3], AZ::Vector2(1.0f, 1.0f));
  195. EXPECT_EQ(uniqueData->m_normMotionPositions[0], AZ::Vector2(-1.0f, -1.0f));
  196. EXPECT_EQ(uniqueData->m_normMotionPositions[1], AZ::Vector2(0.0f, -1.0f));
  197. EXPECT_EQ(uniqueData->m_normMotionPositions[2], AZ::Vector2(1.0f, -1.0f));
  198. EXPECT_EQ(uniqueData->m_normMotionPositions[3], AZ::Vector2(0.0f, 1.0f));
  199. EXPECT_EQ(uniqueData->m_rangeMin, AZ::Vector2(0.0f, 0.0f));
  200. EXPECT_EQ(uniqueData->m_rangeMax, AZ::Vector2(2.0f, 1.0f));
  201. EXPECT_EQ(uniqueData->m_rangeCenter, AZ::Vector2(1.0f, 0.5f));
  202. EXPECT_EQ(uniqueData->m_normalizationScale, AZ::Vector2(1.0f, 2.0f));
  203. }
  204. TEST_F(BlendSpace2DFixture, TriangulationTest)
  205. {
  206. const AZStd::vector<BlendSpaceNode::BlendSpaceMotion>& motions = m_blendSpace2DNode->GetMotions();
  207. BlendSpace2DNode::UniqueData* uniqueData = static_cast<BlendSpace2DNode::UniqueData*>(m_blendSpace2DNode->FindOrCreateUniqueNodeData(m_animGraphInstance));
  208. EXPECT_EQ(motions.size(), 4);
  209. EXPECT_EQ(uniqueData->m_triangles.size(), 2);
  210. /*
  211. run 2 *
  212. |\
  213. | \
  214. | \
  215. | \
  216. | \
  217. forward 1 * * 3 Strafe
  218. | /
  219. | /
  220. | /
  221. | /
  222. |/
  223. idle 0 *
  224. */
  225. EXPECT_EQ(uniqueData->m_triangles[0], BlendSpace2DNode::Triangle(1, 0, 3));
  226. EXPECT_EQ(uniqueData->m_triangles[1], BlendSpace2DNode::Triangle(2, 1, 3));
  227. }
  228. TEST_F(BlendSpace2DFixture, EvaluationAtMotionPoint)
  229. {
  230. BlendSpace2DNode::UniqueData* uniqueData = static_cast<BlendSpace2DNode::UniqueData*>(m_blendSpace2DNode->FindOrCreateUniqueNodeData(m_animGraphInstance));
  231. // Idle corner point
  232. m_floatNodeX->SetValue(0.0f);
  233. m_floatNodeY->SetValue(0.0f);
  234. GetEMotionFX().Update(0.1f);
  235. EXPECT_EQ(uniqueData->m_currentTriangle.m_triangleIndex, 0);
  236. EXPECT_EQ(uniqueData->m_currentEdge.m_edgeIndex, InvalidIndex32);
  237. EXPECT_EQ(uniqueData->m_currentTriangle.m_weights[0], 0.0f);
  238. EXPECT_EQ(uniqueData->m_currentTriangle.m_weights[1], 1.0f); // Idle is the second point
  239. EXPECT_EQ(uniqueData->m_currentTriangle.m_weights[2], 0.0f);
  240. EXPECT_EQ(uniqueData->m_currentPosition, AZ::Vector2(0.0f, 0.0f));
  241. EXPECT_EQ(uniqueData->m_normCurrentPosition, AZ::Vector2(-1.0f, -1.0f));
  242. }
  243. TEST_F(BlendSpace2DFixture, EvaluationOnTriangleEdge)
  244. {
  245. BlendSpace2DNode::UniqueData* uniqueData = static_cast<BlendSpace2DNode::UniqueData*>(m_blendSpace2DNode->FindOrCreateUniqueNodeData(m_animGraphInstance));
  246. // Edge between idle and forward
  247. m_floatNodeX->SetValue(0.5f);
  248. m_floatNodeY->SetValue(0.0f);
  249. GetEMotionFX().Update(0.1f);
  250. EXPECT_EQ(uniqueData->m_currentTriangle.m_triangleIndex, 0);
  251. EXPECT_EQ(uniqueData->m_currentEdge.m_edgeIndex, InvalidIndex32);
  252. EXPECT_EQ(uniqueData->m_currentTriangle.m_weights[0], 0.5f); // Forward
  253. EXPECT_EQ(uniqueData->m_currentTriangle.m_weights[1], 0.5f); // Idle
  254. EXPECT_EQ(uniqueData->m_currentTriangle.m_weights[2], 0.0f);
  255. EXPECT_EQ(uniqueData->m_currentPosition, AZ::Vector2(0.5f, 0.0f));
  256. EXPECT_EQ(uniqueData->m_normCurrentPosition, AZ::Vector2(-0.5f, -1.0f));
  257. }
  258. TEST_F(BlendSpace2DFixture, EvaluationOutsideOfEdge)
  259. {
  260. BlendSpace2DNode::UniqueData* uniqueData = static_cast<BlendSpace2DNode::UniqueData*>(m_blendSpace2DNode->FindOrCreateUniqueNodeData(m_animGraphInstance));
  261. m_floatNodeX->SetValue(0.5f);
  262. m_floatNodeY->SetValue(-1.0f);
  263. GetEMotionFX().Update(0.1f);
  264. EXPECT_EQ(uniqueData->m_currentTriangle.m_triangleIndex, InvalidIndex32);
  265. EXPECT_EQ(uniqueData->m_currentEdge.m_edgeIndex, 3);
  266. // In case the evaluation point is on an edge, m_u will be used as interpolation weight.
  267. EXPECT_EQ(uniqueData->m_currentEdge.m_u, 0.5f); // Mid between forward and idle edge
  268. EXPECT_EQ(uniqueData->m_currentPosition, AZ::Vector2(0.5f, -1.0f));
  269. EXPECT_EQ(uniqueData->m_normCurrentPosition, AZ::Vector2(-0.5f, -3.0f));
  270. }
  271. TEST_F(BlendSpace2DFixture, EvaluationInsideTriangle)
  272. {
  273. BlendSpace2DNode::UniqueData* uniqueData = static_cast<BlendSpace2DNode::UniqueData*>(m_blendSpace2DNode->FindOrCreateUniqueNodeData(m_animGraphInstance));
  274. m_floatNodeX->SetValue(0.5f);
  275. m_floatNodeY->SetValue(0.25f);
  276. GetEMotionFX().Update(0.1f);
  277. EXPECT_EQ(uniqueData->m_currentTriangle.m_triangleIndex, 0);
  278. EXPECT_EQ(uniqueData->m_currentEdge.m_edgeIndex, InvalidIndex32);
  279. EXPECT_EQ(uniqueData->m_currentPosition, AZ::Vector2(0.5f, 0.25f));
  280. EXPECT_EQ(uniqueData->m_normCurrentPosition, AZ::Vector2(-0.5f, -0.5f));
  281. const uint16_t* indices = uniqueData->m_triangles[0].m_vertIndices;
  282. const AZ::Vector2& a = uniqueData->m_normMotionPositions[indices[0]];
  283. const AZ::Vector2& b = uniqueData->m_normMotionPositions[indices[1]];
  284. const AZ::Vector2& c = uniqueData->m_normMotionPositions[indices[2]];
  285. const AZ::Vector2& p = uniqueData->m_normCurrentPosition;
  286. const AZ::Vector3 barycentricCoordinates = AZ::Intersect::Barycentric(
  287. AZ::Vector3(a.GetX(), a.GetY(), 0.0f),
  288. AZ::Vector3(b.GetX(), b.GetY(), 0.0f),
  289. AZ::Vector3(c.GetX(), c.GetY(), 0.0f),
  290. AZ::Vector3(p.GetX(), p.GetY(), 0.0f));
  291. EXPECT_TRUE(AZ::IsClose(barycentricCoordinates.GetX(), 0.25f, 0.001f));
  292. EXPECT_TRUE(AZ::IsClose(barycentricCoordinates.GetY(), 0.5f, 0.001f));
  293. EXPECT_TRUE(AZ::IsClose(barycentricCoordinates.GetZ(), 0.25f, 0.001f));
  294. EXPECT_TRUE(AZ::IsClose(uniqueData->m_currentTriangle.m_weights[0], barycentricCoordinates.GetX(), 0.001f)); // Idle
  295. EXPECT_TRUE(AZ::IsClose(uniqueData->m_currentTriangle.m_weights[1], barycentricCoordinates.GetY(), 0.001f)); // Forward
  296. EXPECT_TRUE(AZ::IsClose(uniqueData->m_currentTriangle.m_weights[2], barycentricCoordinates.GetZ(), 0.001f)); // Strafe
  297. }
  298. TEST_F(BlendSpace2DFixture, EventsTest_InsideTriangle_MostActive)
  299. {
  300. m_blendSpace2DNode->SetEventFilterMode(BlendSpaceNode::EBlendSpaceEventMode::BSEVENTMODE_MOST_ACTIVE_MOTION);
  301. EXPECT_CALL(*m_eventHandler, OnEvent(testing::_)).Times(1);
  302. m_floatNodeX->SetValue(0.5f);
  303. m_floatNodeY->SetValue(0.25f);
  304. GetEMotionFX().Update(0.2f);
  305. }
  306. TEST_F(BlendSpace2DFixture, EventsTest_InsideTriangle_AllActive)
  307. {
  308. m_blendSpace2DNode->SetEventFilterMode(BlendSpaceNode::EBlendSpaceEventMode::BSEVENTMODE_ALL_ACTIVE_MOTIONS);
  309. EXPECT_CALL(*m_eventHandler, OnEvent(testing::_)).Times(3);
  310. m_floatNodeX->SetValue(0.5f);
  311. m_floatNodeY->SetValue(0.25f);
  312. GetEMotionFX().Update(0.2f);
  313. }
  314. TEST_F(BlendSpace2DFixture, EventsTest_InsideTriangle_None)
  315. {
  316. m_blendSpace2DNode->SetEventFilterMode(BlendSpaceNode::EBlendSpaceEventMode::BSEVENTMODE_NONE);
  317. EXPECT_CALL(*m_eventHandler, OnEvent(testing::_)).Times(0);
  318. m_floatNodeX->SetValue(0.5f);
  319. m_floatNodeY->SetValue(0.25f);
  320. GetEMotionFX().Update(0.2f);
  321. }
  322. TEST_F(BlendSpace2DFixture, EventsTest_OnTriangleEdge_MostActive)
  323. {
  324. m_blendSpace2DNode->SetEventFilterMode(BlendSpaceNode::EBlendSpaceEventMode::BSEVENTMODE_MOST_ACTIVE_MOTION);
  325. EXPECT_CALL(*m_eventHandler, OnEvent(testing::_)).Times(1);
  326. m_floatNodeX->SetValue(0.5f);
  327. m_floatNodeY->SetValue(0.0f);
  328. GetEMotionFX().Update(0.2f);
  329. }
  330. TEST_F(BlendSpace2DFixture, EventsTest_OnTriangleEdge_AllActive)
  331. {
  332. m_blendSpace2DNode->SetEventFilterMode(BlendSpaceNode::EBlendSpaceEventMode::BSEVENTMODE_ALL_ACTIVE_MOTIONS);
  333. EXPECT_CALL(*m_eventHandler, OnEvent(testing::_)).Times(2);
  334. m_floatNodeX->SetValue(0.5f);
  335. m_floatNodeY->SetValue(0.0f);
  336. GetEMotionFX().Update(0.2f);
  337. }
  338. TEST_F(BlendSpace2DFixture, EventsTest_AtMotionPoint_MostActive)
  339. {
  340. m_blendSpace2DNode->SetEventFilterMode(BlendSpaceNode::EBlendSpaceEventMode::BSEVENTMODE_MOST_ACTIVE_MOTION);
  341. EXPECT_CALL(*m_eventHandler, OnEvent(testing::_)).Times(1);
  342. m_floatNodeX->SetValue(0.0f);
  343. m_floatNodeY->SetValue(0.0f);
  344. GetEMotionFX().Update(0.2f);
  345. }
  346. TEST_F(BlendSpace2DFixture, EventsTest_AtMotionPoint_AllActive)
  347. {
  348. m_blendSpace2DNode->SetEventFilterMode(BlendSpaceNode::EBlendSpaceEventMode::BSEVENTMODE_ALL_ACTIVE_MOTIONS);
  349. EXPECT_CALL(*m_eventHandler, OnEvent(testing::_)).Times(1);
  350. m_floatNodeX->SetValue(0.0f);
  351. m_floatNodeY->SetValue(0.0f);
  352. GetEMotionFX().Update(0.2f);
  353. }
  354. TEST_F(BlendSpace2DFixture, MotionCoordinates_Nullptr_Asserts_FT)
  355. {
  356. AZ_TEST_START_TRACE_SUPPRESSION;
  357. AZ::Vector2 testVec(0.0f, 0.0f);
  358. m_blendSpace2DNode->ComputeMotionCoordinates("", nullptr, testVec);
  359. AZ_TEST_STOP_TRACE_SUPPRESSION(1);
  360. }
  361. } // namespace EMotionFX