MotionInstanceTests.cpp 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751
  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 <EMotionFX/Source/Motion.h>
  9. #include <EMotionFX/Source/MotionInstance.h>
  10. #include <EMotionFX/Source/MotionManager.h>
  11. #include <EMotionFX/Source/MotionData/NonUniformMotionData.h>
  12. #include <Integration/System/SystemCommon.h>
  13. #include <Tests/SystemComponentFixture.h>
  14. #include <Tests/TestAssetCode/SimpleActors.h>
  15. #include <Tests/TestAssetCode/ActorFactory.h>
  16. #include <AzCore/Math/MathUtils.h>
  17. #include <vector>
  18. namespace EMotionFX
  19. {
  20. // The start state of the motion instance.
  21. struct MotionInstanceInputState
  22. {
  23. float m_currentTime;
  24. float m_playSpeed;
  25. bool m_freezeAtLLastFrame;
  26. AZ::u32 m_numCurrentLoops;
  27. AZ::u32 m_maxNumLoops;
  28. EPlayMode m_playMode;
  29. };
  30. // The expected output state of the motion instance.
  31. struct MotionInstanceOutputState
  32. {
  33. float m_currentTime;
  34. float m_lastCurrentTime;
  35. AZ::u32 m_numLoops;
  36. bool m_hasEnded;
  37. bool m_hasLooped;
  38. bool m_isFrozen;
  39. };
  40. // Test parameters (input and expected output).
  41. struct MotionInstanceTestParams
  42. {
  43. MotionInstanceInputState m_inputState;
  44. MotionInstanceOutputState m_outputState;
  45. float m_deltaTime;
  46. };
  47. class MotionInstanceFixture
  48. : public SystemComponentFixture
  49. , public ::testing::WithParamInterface<MotionInstanceTestParams>
  50. {
  51. public:
  52. void SetUp() override
  53. {
  54. SystemComponentFixture::SetUp();
  55. m_motion = aznew Motion("MotionInstanceTest");
  56. m_motion->SetMotionData(aznew NonUniformMotionData());
  57. m_motion->GetMotionData()->SetDuration(1.0f);
  58. m_actor = ActorFactory::CreateAndInit<SimpleJointChainActor>(5);
  59. ASSERT_NE(m_actor.get(), nullptr) << "Expected actor to not be a nullptr.";
  60. m_actorInstance = ActorInstance::Create(m_actor.get());
  61. ASSERT_NE(m_actorInstance, nullptr) << "Expected actor instance to not be a nullptr.";
  62. m_motionInstance = MotionInstance::Create(m_motion, m_actorInstance);
  63. ASSERT_NE(m_motionInstance, nullptr) << "Expected motion instance to not be a nullptr.";
  64. }
  65. void TearDown() override
  66. {
  67. if (m_motionInstance)
  68. {
  69. m_motionInstance->Destroy();
  70. }
  71. if (m_motion)
  72. {
  73. m_motion->Destroy();
  74. }
  75. if (m_actorInstance)
  76. {
  77. m_actorInstance->Destroy();
  78. }
  79. m_actor.reset();
  80. SystemComponentFixture::TearDown();
  81. }
  82. void InitMotionInstance(const MotionInstanceInputState& state)
  83. {
  84. m_motionInstance->SetCurrentTime(state.m_currentTime, true);
  85. m_motionInstance->SetPlaySpeed(state.m_playSpeed);
  86. m_motionInstance->SetFreezeAtLastFrame(state.m_freezeAtLLastFrame);
  87. m_motionInstance->SetNumCurrentLoops(state.m_numCurrentLoops);
  88. m_motionInstance->SetMaxLoops(state.m_maxNumLoops);
  89. m_motionInstance->SetPlayMode(state.m_playMode);
  90. }
  91. void VerifyOutputState(const MotionInstanceOutputState& state)
  92. {
  93. EXPECT_TRUE(AZ::IsClose(m_motionInstance->GetCurrentTime(), state.m_currentTime, AZ::Constants::FloatEpsilon)) << "Expected the current play time to be different.";
  94. EXPECT_TRUE(AZ::IsClose(m_motionInstance->GetLastCurrentTime(), state.m_lastCurrentTime, AZ::Constants::FloatEpsilon)) << "Expected the last current play time to be different.";
  95. EXPECT_EQ(m_motionInstance->GetNumCurrentLoops(), state.m_numLoops) << "Expected the current number of loops to be different.";
  96. EXPECT_EQ(m_motionInstance->GetHasEnded(), state.m_hasEnded) << "Expected the has ended state to be different.";
  97. EXPECT_EQ(m_motionInstance->GetHasLooped(), state.m_hasLooped) << "Expected the looped state to be different.";
  98. EXPECT_EQ(m_motionInstance->GetIsFrozen(), state.m_isFrozen) << "Expected the frozen state to be different.";
  99. }
  100. protected:
  101. AZStd::unique_ptr<Actor> m_actor;
  102. ActorInstance* m_actorInstance = nullptr;
  103. Motion* m_motion = nullptr;
  104. MotionInstance* m_motionInstance = nullptr;
  105. };
  106. TEST_P(MotionInstanceFixture, Update)
  107. {
  108. // Initialize the motion instance in our input state.
  109. const MotionInstanceTestParams& params = GetParam();
  110. InitMotionInstance(params.m_inputState);
  111. // Perform an update.
  112. m_motionInstance->Update(params.m_deltaTime);
  113. // Verify the expected output.
  114. VerifyOutputState(params.m_outputState);
  115. }
  116. std::vector<MotionInstanceTestParams> motionInstanceTestParams
  117. {
  118. //////////////////////////////// FORWARD PLAYBACK ////////////////////////////////////
  119. { // [0] Forward just a little bit in time.
  120. { // Input state.
  121. 0.0f, // Current play time, in seconds.
  122. 1.0f, // Play speed.
  123. false, // Freeze at the last frame?
  124. 0, // Current number of loops.
  125. EMFX_LOOPFOREVER, // Maximum loops allowed.
  126. PLAYMODE_FORWARD // The play mode.
  127. },
  128. { // Expected output state.
  129. 0.1f, // Current play time.
  130. 0.0f, // Last current play time.
  131. 0, // Current loops.
  132. false, // Has this motion ended?
  133. false, // Has looped?
  134. false, // Are we in a frozen state?
  135. },
  136. 0.1f // Delta update time, in seconds.
  137. },
  138. { // [1] Forward the exact full amount of the motion's duration, triggering a loop.
  139. { // Input state.
  140. 0.0f, // Current play time, in seconds.
  141. 1.0f, // Play speed.
  142. false, // Freeze at the last frame?
  143. 0, // Current number of loops.
  144. EMFX_LOOPFOREVER, // Maximum loops allowed.
  145. PLAYMODE_FORWARD // The play mode.
  146. },
  147. { // Expected output state.
  148. 0.0f, // Current play time.
  149. 0.0f, // Last current play time.
  150. 1, // Current loops.
  151. false, // Has this motion ended?
  152. true, // Has looped?
  153. false, // Are we in a frozen state?
  154. },
  155. 1.0f // Delta update time, in seconds.
  156. },
  157. { // [2] Start near the end, trigger a loop by wrapping around.
  158. { // Input state.
  159. 0.9f, // Current play time, in seconds.
  160. 1.0f, // Play speed.
  161. false, // Freeze at the last frame?
  162. 0, // Current number of loops.
  163. EMFX_LOOPFOREVER, // Maximum loops allowed.
  164. PLAYMODE_FORWARD // The play mode.
  165. },
  166. { // Expected output state.
  167. 0.1f, // Current play time.
  168. 0.9f, // Last current play time.
  169. 1, // Current loops.
  170. false, // Has this motion ended?
  171. true, // Has looped?
  172. false, // Are we in a frozen state?
  173. },
  174. 0.2f // Delta update time, in seconds.
  175. },
  176. { // [3] Update with a time value that is 3x as large as the motion duration.
  177. { // Input state.
  178. 0.5f, // Current play time, in seconds.
  179. 1.0f, // Play speed.
  180. false, // Freeze at the last frame?
  181. 0, // Current number of loops.
  182. EMFX_LOOPFOREVER, // Maximum loops allowed.
  183. PLAYMODE_FORWARD // The play mode.
  184. },
  185. { // Expected output state.
  186. 0.5f, // Current play time.
  187. 0.5f, // Last current play time.
  188. 1, // Current loops. This currently isn't 3, as we currently do not support handling multiple loops in one update.
  189. false, // Has this motion ended?
  190. true, // Has looped?
  191. false, // Are we in a frozen state?
  192. },
  193. 3.0f // Delta update time, in seconds.
  194. },
  195. { // [4] Start out of range, in negative time.
  196. { // Input state.
  197. -3.5f, // Current play time, in seconds.
  198. 1.0f, // Play speed.
  199. false, // Freeze at the last frame?
  200. 0, // Current number of loops.
  201. EMFX_LOOPFOREVER, // Maximum loops allowed.
  202. PLAYMODE_FORWARD // The play mode.
  203. },
  204. { // Expected output state.
  205. 0.2f, // Current play time.
  206. -3.5f, // Last current play time.
  207. 0, // Current loops.
  208. false, // Has this motion ended?
  209. false, // Has looped?
  210. false, // Are we in a frozen state?
  211. },
  212. 0.2f // Delta update time, in seconds.
  213. },
  214. { // [5] Start out of range, past the duration.
  215. { // Input state.
  216. 3.5f, // Current play time, in seconds.
  217. 1.0f, // Play speed.
  218. false, // Freeze at the last frame?
  219. 0, // Current number of loops.
  220. EMFX_LOOPFOREVER, // Maximum loops allowed.
  221. PLAYMODE_FORWARD // The play mode.
  222. },
  223. { // Expected output state.
  224. 0.1f, // Current play time.
  225. 3.5f, // Last current play time.
  226. 1, // Current loops.
  227. false, // Has this motion ended?
  228. true, // Has looped?
  229. false, // Are we in a frozen state?
  230. },
  231. 0.1f // Delta update time, in seconds.
  232. },
  233. //////////////////////////////// BACKWARD PLAYBACK ////////////////////////////////////
  234. { // [6] Progress just a little bit in time.
  235. { // Input state.
  236. 0.5f, // Current play time, in seconds.
  237. 1.0f, // Play speed.
  238. false, // Freeze at the last frame?
  239. 0, // Current number of loops.
  240. EMFX_LOOPFOREVER, // Maximum loops allowed.
  241. PLAYMODE_BACKWARD // The play mode.
  242. },
  243. { // Expected output state.
  244. 0.4f, // Current play time.
  245. 0.5f, // Last current play time.
  246. 0, // Current loops.
  247. false, // Has this motion ended?
  248. false, // Has looped?
  249. false, // Are we in a frozen state?
  250. },
  251. 0.1f // Delta update time, in seconds.
  252. },
  253. { // [7] Progress the exact full amount of the motion's duration, triggering a loop.
  254. { // Input state.
  255. 1.0f, // Current play time, in seconds.
  256. 1.0f, // Play speed.
  257. false, // Freeze at the last frame?
  258. 0, // Current number of loops.
  259. EMFX_LOOPFOREVER, // Maximum loops allowed.
  260. PLAYMODE_BACKWARD // The play mode.
  261. },
  262. { // Expected output state.
  263. 1.0f, // Current play time.
  264. 1.0f, // Last current play time.
  265. 1, // Current loops.
  266. false, // Has this motion ended?
  267. true, // Has looped?
  268. false, // Are we in a frozen state?
  269. },
  270. 1.0f // Delta update time, in seconds.
  271. },
  272. { // [8] Start near the beginning, trigger a loop by wrapping around.
  273. { // Input state.
  274. 0.1f, // Current play time, in seconds.
  275. 1.0f, // Play speed.
  276. false, // Freeze at the last frame?
  277. 0, // Current number of loops.
  278. EMFX_LOOPFOREVER, // Maximum loops allowed.
  279. PLAYMODE_BACKWARD // The play mode.
  280. },
  281. { // Expected output state.
  282. 0.9f, // Current play time.
  283. 0.1f, // Last current play time.
  284. 1, // Current loops.
  285. false, // Has this motion ended?
  286. true, // Has looped?
  287. false, // Are we in a frozen state?
  288. },
  289. 0.2f // Delta update time, in seconds.
  290. },
  291. { // [9] Update with a time value that is 3x as large as the motion duration.
  292. { // Input state.
  293. 0.5f, // Current play time, in seconds.
  294. 1.0f, // Play speed.
  295. false, // Freeze at the last frame?
  296. 0, // Current number of loops.
  297. EMFX_LOOPFOREVER, // Maximum loops allowed.
  298. PLAYMODE_BACKWARD // The play mode.
  299. },
  300. { // Expected output state.
  301. 0.5f, // Current play time.
  302. 0.5f, // Last current play time.
  303. 1, // Current loops. This currently isn't 3, as we currently do not support handling multiple loops in one update.
  304. false, // Has this motion ended?
  305. true, // Has looped?
  306. false, // Are we in a frozen state?
  307. },
  308. 3.0f // Delta update time, in seconds.
  309. },
  310. { // [10] Start out of range, in negative time.
  311. { // Input state.
  312. -3.5f, // Current play time, in seconds.
  313. 1.0f, // Play speed.
  314. false, // Freeze at the last frame?
  315. 0, // Current number of loops.
  316. EMFX_LOOPFOREVER, // Maximum loops allowed.
  317. PLAYMODE_BACKWARD // The play mode.
  318. },
  319. { // Expected output state.
  320. 0.9f, // Current play time.
  321. -3.5f, // Last current play time.
  322. 1, // Current loops.
  323. false, // Has this motion ended?
  324. true, // Has looped?
  325. false, // Are we in a frozen state?
  326. },
  327. 0.1f // Delta update time, in seconds.
  328. },
  329. { // [11] Start out of range, past the duration.
  330. { // Input state.
  331. 3.5f, // Current play time, in seconds.
  332. 1.0f, // Play speed.
  333. false, // Freeze at the last frame?
  334. 0, // Current number of loops.
  335. EMFX_LOOPFOREVER, // Maximum loops allowed.
  336. PLAYMODE_BACKWARD // The play mode.
  337. },
  338. { // Expected output state.
  339. 0.9f, // Current play time.
  340. 3.5f, // Last current play time.
  341. 0, // Current loops.
  342. false, // Has this motion ended?
  343. false, // Has looped?
  344. false, // Are we in a frozen state?
  345. },
  346. 0.1f // Delta update time, in seconds.
  347. },
  348. //////////////////////////////// FORWARD PLAYBACK WHILE FREEZING AT LAST FRAME, ONE LOOP MAX ////////////////////////////////////
  349. { // [12] Forward just a little bit in time.
  350. { // Input state.
  351. 0.0f, // Current play time, in seconds.
  352. 1.0f, // Play speed.
  353. true, // Freeze at the last frame?
  354. 0, // Current number of loops.
  355. 1, // Maximum loops allowed.
  356. PLAYMODE_FORWARD // The play mode.
  357. },
  358. { // Expected output state.
  359. 0.1f, // Current play time.
  360. 0.0f, // Last current play time.
  361. 0, // Current loops.
  362. false, // Has this motion ended?
  363. false, // Has looped?
  364. false, // Are we in a frozen state?
  365. },
  366. 0.1f // Delta update time, in seconds.
  367. },
  368. { // [13] Forward the exact full amount of the motion's duration, triggering a loop.
  369. { // Input state.
  370. 0.0f, // Current play time, in seconds.
  371. 1.0f, // Play speed.
  372. true, // Freeze at the last frame?
  373. 0, // Current number of loops.
  374. 1, // Maximum loops allowed.
  375. PLAYMODE_FORWARD // The play mode.
  376. },
  377. { // Expected output state.
  378. 1.0f, // Current play time.
  379. 0.0f, // Last current play time.
  380. 1, // Current loops.
  381. true, // Has this motion ended?
  382. true, // Has looped?
  383. true, // Are we in a frozen state?
  384. },
  385. 1.0f // Delta update time, in seconds.
  386. },
  387. { // [14] Start near the end, trigger a loop by wrapping around.
  388. { // Input state.
  389. 0.9f, // Current play time, in seconds.
  390. 1.0f, // Play speed.
  391. true, // Freeze at the last frame?
  392. 0, // Current number of loops.
  393. 1, // Maximum loops allowed.
  394. PLAYMODE_FORWARD // The play mode.
  395. },
  396. { // Expected output state.
  397. 1.0f, // Current play time.
  398. 0.9f, // Last current play time.
  399. 1, // Current loops.
  400. true, // Has this motion ended?
  401. true, // Has looped?
  402. true, // Are we in a frozen state?
  403. },
  404. 0.2f // Delta update time, in seconds.
  405. },
  406. { // [15] Update with a time value that is 3x as large as the motion duration.
  407. { // Input state.
  408. 0.5f, // Current play time, in seconds.
  409. 1.0f, // Play speed.
  410. true, // Freeze at the last frame?
  411. 0, // Current number of loops.
  412. 1, // Maximum loops allowed.
  413. PLAYMODE_FORWARD // The play mode.
  414. },
  415. { // Expected output state.
  416. 1.0f, // Current play time.
  417. 0.5f, // Last current play time.
  418. 1, // Current loops. This currently isn't 3, as we currently do not support handling multiple loops in one update.
  419. true, // Has this motion ended?
  420. true, // Has looped?
  421. true, // Are we in a frozen state?
  422. },
  423. 3.0f // Delta update time, in seconds.
  424. },
  425. { // [16] Start out of range, in negative time.
  426. { // Input state.
  427. -3.5f, // Current play time, in seconds.
  428. 1.0f, // Play speed.
  429. true, // Freeze at the last frame?
  430. 0, // Current number of loops.
  431. 1, // Maximum loops allowed.
  432. PLAYMODE_FORWARD // The play mode.
  433. },
  434. { // Expected output state.
  435. 0.1f, // Current play time.
  436. -3.5f, // Last current play time.
  437. 0, // Current loops.
  438. false, // Has this motion ended?
  439. false, // Has looped?
  440. false, // Are we in a frozen state?
  441. },
  442. 0.1f // Delta update time, in seconds.
  443. },
  444. { // [17] Start out of range, past the duration.
  445. { // Input state.
  446. 3.5f, // Current play time, in seconds.
  447. 1.0f, // Play speed.
  448. true, // Freeze at the last frame?
  449. 0, // Current number of loops.
  450. 1, // Maximum loops allowed.
  451. PLAYMODE_FORWARD // The play mode.
  452. },
  453. { // Expected output state.
  454. 1.0f, // Current play time.
  455. 3.5f, // Last current play time.
  456. 1, // Current loops.
  457. true, // Has this motion ended?
  458. true, // Has looped?
  459. true, // Are we in a frozen state?
  460. },
  461. 0.1f // Delta update time, in seconds.
  462. },
  463. //////////////////////////////// BACKWARD PLAYBACK WHILE FREEZING AT LAST FRAME, ONE LOOP MAX ////////////////////////////////////
  464. { // [18] Forward just a little bit in time.
  465. { // Input state.
  466. 1.0f, // Current play time, in seconds.
  467. 1.0f, // Play speed.
  468. true, // Freeze at the last frame?
  469. 0, // Current number of loops.
  470. 1, // Maximum loops allowed.
  471. PLAYMODE_BACKWARD // The play mode.
  472. },
  473. { // Expected output state.
  474. 0.9f, // Current play time.
  475. 1.0f, // Last current play time.
  476. 0, // Current loops.
  477. false, // Has this motion ended?
  478. false, // Has looped?
  479. false, // Are we in a frozen state?
  480. },
  481. 0.1f // Delta update time, in seconds.
  482. },
  483. { // [19] Forward the exact full amount of the motion's duration, triggering a loop.
  484. { // Input state.
  485. 1.0f, // Current play time, in seconds.
  486. 1.0f, // Play speed.
  487. true, // Freeze at the last frame?
  488. 0, // Current number of loops.
  489. 1, // Maximum loops allowed.
  490. PLAYMODE_BACKWARD // The play mode.
  491. },
  492. { // Expected output state.
  493. 0.0f, // Current play time.
  494. 1.0f, // Last current play time.
  495. 1, // Current loops.
  496. true, // Has this motion ended?
  497. true, // Has looped?
  498. true, // Are we in a frozen state?
  499. },
  500. 1.0f // Delta update time, in seconds.
  501. },
  502. { // [20] Start near the end, trigger a loop by wrapping around.
  503. { // Input state.
  504. 0.1f, // Current play time, in seconds.
  505. 1.0f, // Play speed.
  506. true, // Freeze at the last frame?
  507. 0, // Current number of loops.
  508. 1, // Maximum loops allowed.
  509. PLAYMODE_BACKWARD // The play mode.
  510. },
  511. { // Expected output state.
  512. 0.0f, // Current play time.
  513. 0.1f, // Last current play time.
  514. 1, // Current loops.
  515. true, // Has this motion ended?
  516. true, // Has looped?
  517. true, // Are we in a frozen state?
  518. },
  519. 0.2f // Delta update time, in seconds.
  520. },
  521. { // [21] Update with a time value that is 3x as large as the motion duration.
  522. { // Input state.
  523. 0.5f, // Current play time, in seconds.
  524. 1.0f, // Play speed.
  525. true, // Freeze at the last frame?
  526. 0, // Current number of loops.
  527. 1, // Maximum loops allowed.
  528. PLAYMODE_BACKWARD // The play mode.
  529. },
  530. { // Expected output state.
  531. 0.0f, // Current play time.
  532. 0.5f, // Last current play time.
  533. 1, // Current loops. This currently isn't 3, as we currently do not support handling multiple loops in one update.
  534. true, // Has this motion ended?
  535. true, // Has looped?
  536. true, // Are we in a frozen state?
  537. },
  538. 3.0f // Delta update time, in seconds.
  539. },
  540. { // [22] Start out of range, in negative time.
  541. { // Input state.
  542. -3.5f, // Current play time, in seconds.
  543. 1.0f, // Play speed.
  544. true, // Freeze at the last frame?
  545. 0, // Current number of loops.
  546. 1, // Maximum loops allowed.
  547. PLAYMODE_BACKWARD // The play mode.
  548. },
  549. { // Expected output state.
  550. 0.0f, // Current play time.
  551. -3.5f, // Last current play time.
  552. 1, // Current loops.
  553. true, // Has this motion ended?
  554. true, // Has looped?
  555. true, // Are we in a frozen state?
  556. },
  557. 0.1f // Delta update time, in seconds.
  558. },
  559. { // [23] Start out of range, past the duration.
  560. { // Input state.
  561. 3.5f, // Current play time, in seconds.
  562. 1.0f, // Play speed.
  563. true, // Freeze at the last frame?
  564. 0, // Current number of loops.
  565. 1, // Maximum loops allowed.
  566. PLAYMODE_BACKWARD // The play mode.
  567. },
  568. { // Expected output state.
  569. 0.9f, // Current play time.
  570. 3.5f, // Last current play time.
  571. 0, // Current loops.
  572. false, // Has this motion ended?
  573. false, // Has looped?
  574. false, // Are we in a frozen state?
  575. },
  576. 0.1f // Delta update time, in seconds.
  577. },
  578. //////////////////////////////// PLAYSPEED TESTS ////////////////////////////////////
  579. { // [24] Forward just a little bit in time, with increased play speed.
  580. { // Input state.
  581. 0.0f, // Current play time, in seconds.
  582. 3.0f, // Play speed.
  583. false, // Freeze at the last frame?
  584. 0, // Current number of loops.
  585. EMFX_LOOPFOREVER, // Maximum loops allowed.
  586. PLAYMODE_FORWARD // The play mode.
  587. },
  588. { // Expected output state.
  589. 0.3f, // Current play time.
  590. 0.0f, // Last current play time.
  591. 0, // Current loops.
  592. false, // Has this motion ended?
  593. false, // Has looped?
  594. false, // Are we in a frozen state?
  595. },
  596. 0.1f // Delta update time, in seconds.
  597. },
  598. { // [25] Forward in time but wrap around, with higher play speed.
  599. { // Input state.
  600. 0.9f, // Current play time, in seconds.
  601. 3.0f, // Play speed.
  602. false, // Freeze at the last frame?
  603. 0, // Current number of loops.
  604. EMFX_LOOPFOREVER, // Maximum loops allowed.
  605. PLAYMODE_FORWARD // The play mode.
  606. },
  607. { // Expected output state.
  608. 0.2f, // Current play time.
  609. 0.9f, // Last current play time.
  610. 1, // Current loops.
  611. false, // Has this motion ended?
  612. true, // Has looped?
  613. false, // Are we in a frozen state?
  614. },
  615. 0.1f // Delta update time, in seconds.
  616. },
  617. { // [26] Backward with increased play speed.
  618. { // Input state.
  619. 1.0f, // Current play time, in seconds.
  620. 3.0f, // Play speed.
  621. false, // Freeze at the last frame?
  622. 0, // Current number of loops.
  623. EMFX_LOOPFOREVER, // Maximum loops allowed.
  624. PLAYMODE_BACKWARD // The play mode.
  625. },
  626. { // Expected output state.
  627. 0.7f, // Current play time.
  628. 1.0f, // Last current play time.
  629. 0, // Current loops.
  630. false, // Has this motion ended?
  631. false, // Has looped?
  632. false, // Are we in a frozen state?
  633. },
  634. 0.1f // Delta update time, in seconds.
  635. },
  636. { // [27] Backward in time but wrap around, with higher play speed.
  637. { // Input state.
  638. 0.1f, // Current play time, in seconds.
  639. 3.0f, // Play speed.
  640. false, // Freeze at the last frame?
  641. 0, // Current number of loops.
  642. EMFX_LOOPFOREVER, // Maximum loops allowed.
  643. PLAYMODE_BACKWARD // The play mode.
  644. },
  645. { // Expected output state.
  646. 0.8f, // Current play time.
  647. 0.1f, // Last current play time.
  648. 1, // Current loops.
  649. false, // Has this motion ended?
  650. true, // Has looped?
  651. false, // Are we in a frozen state?
  652. },
  653. 0.1f // Delta update time, in seconds.
  654. },
  655. //////////////////////////////// MISC TESTS ////////////////////////////////////
  656. { // [28] Zero time delta.
  657. { // Input state.
  658. 0.3f, // Current play time, in seconds.
  659. 1.0f, // Play speed.
  660. false, // Freeze at the last frame?
  661. 0, // Current number of loops.
  662. EMFX_LOOPFOREVER, // Maximum loops allowed.
  663. PLAYMODE_FORWARD // The play mode.
  664. },
  665. { // Expected output state.
  666. 0.3f, // Current play time.
  667. 0.3f, // Last current play time.
  668. 0, // Current loops.
  669. false, // Has this motion ended?
  670. false, // Has looped?
  671. false, // Are we in a frozen state?
  672. },
  673. 0.0f // Delta update time, in seconds.
  674. },
  675. { // [29] Zero time delta while on the motion duration edge.
  676. { // Input state.
  677. 1.0f, // Current play time, in seconds.
  678. 1.0f, // Play speed.
  679. false, // Freeze at the last frame?
  680. 0, // Current number of loops.
  681. EMFX_LOOPFOREVER, // Maximum loops allowed.
  682. PLAYMODE_FORWARD // The play mode.
  683. },
  684. { // Expected output state.
  685. 1.0f, // Current play time.
  686. 1.0f, // Last current play time.
  687. 0, // Current loops.
  688. false, // Has this motion ended?
  689. false, // Has looped?
  690. false, // Are we in a frozen state?
  691. },
  692. 0.0f // Delta update time, in seconds.
  693. },
  694. { // [30] Negative delta time.
  695. { // Input state.
  696. 0.2f, // Current play time, in seconds.
  697. 1.0f, // Play speed.
  698. false, // Freeze at the last frame?
  699. 0, // Current number of loops.
  700. EMFX_LOOPFOREVER, // Maximum loops allowed.
  701. PLAYMODE_FORWARD // The play mode.
  702. },
  703. { // Expected output state.
  704. 0.2f, // Current play time.
  705. 0.2f, // Last current play time.
  706. 0, // Current loops.
  707. false, // Has this motion ended?
  708. false, // Has looped?
  709. false, // Are we in a frozen state?
  710. },
  711. -0.5f // Delta update time, in seconds.
  712. }
  713. };
  714. INSTANTIATE_TEST_CASE_P(MotionInstanceTests, MotionInstanceFixture, ::testing::ValuesIn(motionInstanceTestParams));
  715. } // namespace EMotionFX