Movie.cpp 57 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861
  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/Component/Entity.h>
  9. #include <AzCore/Serialization/SerializeContext.h>
  10. #include <AzCore/std/containers/map.h>
  11. #include <AzCore/std/containers/unordered_map.h>
  12. #include <AzCore/Time/ITime.h>
  13. #include <AzFramework/Components/CameraBus.h>
  14. #include <Maestro/Bus/SequenceComponentBus.h>
  15. #include "Movie.h"
  16. #include "AnimSplineTrack.h"
  17. #include "AnimSerializer.h"
  18. #include "AnimSequence.h"
  19. #include "CVarNode.h"
  20. #include "ScriptVarNode.h"
  21. #include "SceneNode.h"
  22. #include "EventNode.h"
  23. #include "AnimPostFXNode.h"
  24. #include "AnimScreenFaderNode.h"
  25. #include "CommentNode.h"
  26. #include "LayerNode.h"
  27. #include "ShadowsSetupNode.h"
  28. #include <MathConversion.h>
  29. #include <ISystem.h>
  30. #include <ILog.h>
  31. #include <IConsole.h>
  32. #include <IRenderer.h>
  33. #include <Maestro/Types/AnimNodeType.h>
  34. #include <Maestro/Types/SequenceType.h>
  35. #include <Maestro/Types/AnimParamType.h>
  36. int CMovieSystem::m_mov_NoCutscenes = 0;
  37. float CMovieSystem::m_mov_cameraPrecacheTime = 1.f;
  38. #if !defined(_RELEASE)
  39. int CMovieSystem::m_mov_DebugEvents = 0;
  40. int CMovieSystem::m_mov_debugCamShake = 0;
  41. #endif
  42. #if !defined(_RELEASE)
  43. struct SMovieSequenceAutoComplete
  44. : public IConsoleArgumentAutoComplete
  45. {
  46. virtual int GetCount() const
  47. {
  48. return gEnv->pMovieSystem->GetNumSequences();
  49. }
  50. virtual const char* GetValue(int nIndex) const
  51. {
  52. IAnimSequence* sequence = gEnv->pMovieSystem->GetSequence(nIndex);
  53. if (sequence)
  54. {
  55. return sequence->GetName();
  56. }
  57. return "";
  58. }
  59. };
  60. #endif //#if !defined(_RELEASE)
  61. #if !defined(_RELEASE)
  62. static SMovieSequenceAutoComplete s_movieSequenceAutoComplete;
  63. #endif
  64. //////////////////////////////////////////////////////////////////////////
  65. // Serialization for anim nodes & param types
  66. #define REGISTER_NODE_TYPE(name) assert(!m_animNodeEnumToStringMap.contains(AnimNodeType::name)); \
  67. m_animNodeEnumToStringMap[AnimNodeType::name] = AZ_STRINGIZE(name); \
  68. m_animNodeStringToEnumMap[AnimParamSystemString(AZ_STRINGIZE(name))] = AnimNodeType::name;
  69. #define REGISTER_PARAM_TYPE(name) assert(!m_animParamEnumToStringMap.contains(AnimParamType::name)); \
  70. m_animParamEnumToStringMap[AnimParamType::name] = AZ_STRINGIZE(name); \
  71. m_animParamStringToEnumMap[AnimParamSystemString(AZ_STRINGIZE(name))] = AnimParamType::name;
  72. // If you get an assert in this function, it means two node types have the same enum value.
  73. void CMovieSystem::RegisterNodeTypes()
  74. {
  75. REGISTER_NODE_TYPE(Entity)
  76. REGISTER_NODE_TYPE(Director)
  77. REGISTER_NODE_TYPE(Camera)
  78. REGISTER_NODE_TYPE(CVar)
  79. REGISTER_NODE_TYPE(ScriptVar)
  80. REGISTER_NODE_TYPE(Material)
  81. REGISTER_NODE_TYPE(Event)
  82. REGISTER_NODE_TYPE(Group)
  83. REGISTER_NODE_TYPE(Layer)
  84. REGISTER_NODE_TYPE(Comment)
  85. REGISTER_NODE_TYPE(RadialBlur)
  86. REGISTER_NODE_TYPE(ColorCorrection)
  87. REGISTER_NODE_TYPE(DepthOfField)
  88. REGISTER_NODE_TYPE(ScreenFader)
  89. REGISTER_NODE_TYPE(Light)
  90. REGISTER_NODE_TYPE(ShadowSetup)
  91. REGISTER_NODE_TYPE(Alembic)
  92. REGISTER_NODE_TYPE(GeomCache)
  93. REGISTER_NODE_TYPE(Environment)
  94. REGISTER_NODE_TYPE(AzEntity)
  95. REGISTER_NODE_TYPE(Component)
  96. }
  97. // If you get an assert in this function, it means two param types have the same enum value.
  98. void CMovieSystem::RegisterParamTypes()
  99. {
  100. REGISTER_PARAM_TYPE(FOV)
  101. REGISTER_PARAM_TYPE(Position)
  102. REGISTER_PARAM_TYPE(Rotation)
  103. REGISTER_PARAM_TYPE(Scale)
  104. REGISTER_PARAM_TYPE(Event)
  105. REGISTER_PARAM_TYPE(Visibility)
  106. REGISTER_PARAM_TYPE(Camera)
  107. REGISTER_PARAM_TYPE(Animation)
  108. REGISTER_PARAM_TYPE(Sound)
  109. REGISTER_PARAM_TYPE(Sequence)
  110. REGISTER_PARAM_TYPE(Console)
  111. REGISTER_PARAM_TYPE(Music) ///@deprecated in 1.11, left in for legacy serialization
  112. REGISTER_PARAM_TYPE(Float)
  113. REGISTER_PARAM_TYPE(LookAt)
  114. REGISTER_PARAM_TYPE(TrackEvent)
  115. REGISTER_PARAM_TYPE(ShakeAmplitudeA)
  116. REGISTER_PARAM_TYPE(ShakeAmplitudeB)
  117. REGISTER_PARAM_TYPE(ShakeFrequencyA)
  118. REGISTER_PARAM_TYPE(ShakeFrequencyB)
  119. REGISTER_PARAM_TYPE(ShakeMultiplier)
  120. REGISTER_PARAM_TYPE(ShakeNoise)
  121. REGISTER_PARAM_TYPE(ShakeWorking)
  122. REGISTER_PARAM_TYPE(ShakeAmpAMult)
  123. REGISTER_PARAM_TYPE(ShakeAmpBMult)
  124. REGISTER_PARAM_TYPE(ShakeFreqAMult)
  125. REGISTER_PARAM_TYPE(ShakeFreqBMult)
  126. REGISTER_PARAM_TYPE(DepthOfField)
  127. REGISTER_PARAM_TYPE(FocusDistance)
  128. REGISTER_PARAM_TYPE(FocusRange)
  129. REGISTER_PARAM_TYPE(BlurAmount)
  130. REGISTER_PARAM_TYPE(Capture)
  131. REGISTER_PARAM_TYPE(TransformNoise)
  132. REGISTER_PARAM_TYPE(TimeWarp)
  133. REGISTER_PARAM_TYPE(FixedTimeStep)
  134. REGISTER_PARAM_TYPE(NearZ)
  135. REGISTER_PARAM_TYPE(Goto)
  136. REGISTER_PARAM_TYPE(PositionX)
  137. REGISTER_PARAM_TYPE(PositionY)
  138. REGISTER_PARAM_TYPE(PositionZ)
  139. REGISTER_PARAM_TYPE(RotationX)
  140. REGISTER_PARAM_TYPE(RotationY)
  141. REGISTER_PARAM_TYPE(RotationZ)
  142. REGISTER_PARAM_TYPE(ScaleX)
  143. REGISTER_PARAM_TYPE(ScaleY)
  144. REGISTER_PARAM_TYPE(ScaleZ)
  145. REGISTER_PARAM_TYPE(ColorR)
  146. REGISTER_PARAM_TYPE(ColorG)
  147. REGISTER_PARAM_TYPE(ColorB)
  148. REGISTER_PARAM_TYPE(CommentText)
  149. REGISTER_PARAM_TYPE(ScreenFader)
  150. REGISTER_PARAM_TYPE(LightDiffuse)
  151. REGISTER_PARAM_TYPE(LightRadius)
  152. REGISTER_PARAM_TYPE(LightDiffuseMult)
  153. REGISTER_PARAM_TYPE(LightHDRDynamic)
  154. REGISTER_PARAM_TYPE(LightSpecularMult)
  155. REGISTER_PARAM_TYPE(LightSpecPercentage)
  156. REGISTER_PARAM_TYPE(MaterialDiffuse)
  157. REGISTER_PARAM_TYPE(MaterialSpecular)
  158. REGISTER_PARAM_TYPE(MaterialEmissive)
  159. REGISTER_PARAM_TYPE(MaterialEmissiveIntensity)
  160. REGISTER_PARAM_TYPE(MaterialOpacity)
  161. REGISTER_PARAM_TYPE(MaterialSmoothness)
  162. REGISTER_PARAM_TYPE(TimeRanges)
  163. REGISTER_PARAM_TYPE(Physics)
  164. REGISTER_PARAM_TYPE(GSMCache)
  165. REGISTER_PARAM_TYPE(ShutterSpeed)
  166. REGISTER_PARAM_TYPE(Physicalize)
  167. REGISTER_PARAM_TYPE(PhysicsDriven)
  168. REGISTER_PARAM_TYPE(SunLongitude)
  169. REGISTER_PARAM_TYPE(SunLatitude)
  170. REGISTER_PARAM_TYPE(MoonLongitude)
  171. REGISTER_PARAM_TYPE(MoonLatitude)
  172. REGISTER_PARAM_TYPE(ProceduralEyes)
  173. }
  174. namespace Internal
  175. {
  176. float ApplyDeltaTimeOverrideIfEnabled(float deltaTime)
  177. {
  178. if (auto* timeSystem = AZ::Interface<AZ::ITime>::Get())
  179. {
  180. const AZ::TimeUs deltatimeOverride = timeSystem->GetSimulationTickDeltaOverride();
  181. if (deltatimeOverride != AZ::Time::ZeroTimeUs)
  182. {
  183. deltaTime = AZ::TimeUsToSeconds(deltatimeOverride);
  184. }
  185. }
  186. return deltaTime;
  187. }
  188. } // namespace Internal
  189. //////////////////////////////////////////////////////////////////////////
  190. CMovieSystem::CMovieSystem(ISystem* pSystem)
  191. {
  192. m_pSystem = pSystem;
  193. m_bRecording = false;
  194. m_pCallback = nullptr;
  195. m_pUser = nullptr;
  196. m_bPaused = false;
  197. m_bEnableCameraShake = true;
  198. m_bCutscenesPausedInEditor = true;
  199. m_sequenceStopBehavior = eSSB_GotoEndTime;
  200. m_lastUpdateTime = AZ::Time::ZeroTimeUs;
  201. m_bStartCapture = false;
  202. m_captureFrame = -1;
  203. m_bEndCapture = false;
  204. m_fixedTimeStepBackUp = AZ::Time::ZeroTimeUs;
  205. m_cvar_capture_frame_once = nullptr;
  206. m_cvar_capture_folder = nullptr;
  207. m_cvar_sys_maxTimeStepForMovieSystem = nullptr;
  208. m_cvar_capture_frames = nullptr;
  209. m_cvar_capture_file_prefix = nullptr;
  210. m_bPhysicsEventsEnabled = true;
  211. m_bBatchRenderMode = false;
  212. m_nextSequenceId = 1;
  213. REGISTER_CVAR2("mov_NoCutscenes", &m_mov_NoCutscenes, 0, 0, "Disable playing of Cut-Scenes");
  214. REGISTER_CVAR2("mov_cameraPrecacheTime", &m_mov_cameraPrecacheTime, 1.f, VF_NULL, "");
  215. m_mov_overrideCam = REGISTER_STRING("mov_overrideCam", "", VF_NULL, "Set the camera used for the sequence which overrides the camera track info in the sequence.\nUse the Camera Name for Object Entity Cameras (Legacy) or the Entity ID for Component Entity Cameras.");
  216. DoNodeStaticInitialisation();
  217. RegisterNodeTypes();
  218. RegisterParamTypes();
  219. }
  220. //////////////////////////////////////////////////////////////////////////
  221. CMovieSystem::CMovieSystem()
  222. : CMovieSystem(gEnv->pSystem)
  223. {
  224. }
  225. //////////////////////////////////////////////////////////////////////////
  226. void CMovieSystem::DoNodeStaticInitialisation()
  227. {
  228. CAnimPostFXNode::Initialize();
  229. CAnimSceneNode::Initialize();
  230. CAnimScreenFaderNode::Initialize();
  231. CCommentNode::Initialize();
  232. CLayerNode::Initialize();
  233. }
  234. //////////////////////////////////////////////////////////////////////////
  235. IAnimSequence* CMovieSystem::CreateSequence(const char* sequenceName, bool load, uint32 id, SequenceType sequenceType, AZ::EntityId entityId)
  236. {
  237. if (!load)
  238. {
  239. id = m_nextSequenceId++;
  240. }
  241. IAnimSequence* sequence = aznew CAnimSequence(this, id, sequenceType);
  242. sequence->SetName(sequenceName);
  243. sequence->SetSequenceEntityId(entityId);
  244. m_sequences.push_back(sequence);;
  245. return sequence;
  246. }
  247. //////////////////////////////////////////////////////////////////////////
  248. IAnimSequence* CMovieSystem::FindLegacySequenceByName(const char* pSequenceName) const
  249. {
  250. assert(pSequenceName);
  251. if (!pSequenceName)
  252. {
  253. return NULL;
  254. }
  255. for (Sequences::const_iterator it = m_sequences.begin(); it != m_sequences.end(); ++it)
  256. {
  257. IAnimSequence* pCurrentSequence = it->get();
  258. const char* fullname = pCurrentSequence->GetName();
  259. if (_stricmp(fullname, pSequenceName) == 0)
  260. {
  261. return pCurrentSequence;
  262. }
  263. }
  264. return NULL;
  265. }
  266. //////////////////////////////////////////////////////////////////////////
  267. IAnimSequence* CMovieSystem::FindSequence(const AZ::EntityId& componentEntitySequenceId) const
  268. {
  269. IAnimSequence* retSequence = nullptr;
  270. if (componentEntitySequenceId.IsValid())
  271. {
  272. for (Sequences::const_iterator it = m_sequences.begin(); it != m_sequences.end(); ++it)
  273. {
  274. const AZ::EntityId& seqOwnerId = it->get()->GetSequenceEntityId();
  275. if (seqOwnerId == componentEntitySequenceId)
  276. {
  277. retSequence = it->get();
  278. break;
  279. }
  280. }
  281. }
  282. return retSequence;
  283. }
  284. //////////////////////////////////////////////////////////////////////////
  285. IAnimSequence* CMovieSystem::FindSequenceById(uint32 id) const
  286. {
  287. if (id == 0 || id >= m_nextSequenceId)
  288. {
  289. return NULL;
  290. }
  291. for (Sequences::const_iterator it = m_sequences.begin(); it != m_sequences.end(); ++it)
  292. {
  293. IAnimSequence* pCurrentSequence = it->get();
  294. if (id == pCurrentSequence->GetId())
  295. {
  296. return pCurrentSequence;
  297. }
  298. }
  299. return NULL;
  300. }
  301. //////////////////////////////////////////////////////////////////////////
  302. bool CMovieSystem::FindSequence(IAnimSequence* sequence, PlayingSequences::const_iterator& sequenceIteratorOut) const
  303. {
  304. PlayingSequences::const_iterator itend = m_playingSequences.end();
  305. for (sequenceIteratorOut = m_playingSequences.begin(); sequenceIteratorOut != itend; ++sequenceIteratorOut)
  306. {
  307. if (sequenceIteratorOut->sequence == sequence)
  308. {
  309. return true;
  310. }
  311. }
  312. return false;
  313. }
  314. //////////////////////////////////////////////////////////////////////////
  315. bool CMovieSystem::FindSequence(IAnimSequence* sequence, PlayingSequences::iterator& sequenceIteratorOut)
  316. {
  317. PlayingSequences::const_iterator itend = m_playingSequences.end();
  318. for (sequenceIteratorOut = m_playingSequences.begin(); sequenceIteratorOut != itend; ++sequenceIteratorOut)
  319. {
  320. if (sequenceIteratorOut->sequence == sequence)
  321. {
  322. return true;
  323. }
  324. }
  325. return false;
  326. }
  327. //////////////////////////////////////////////////////////////////////////
  328. IAnimSequence* CMovieSystem::GetSequence(int i) const
  329. {
  330. assert(i >= 0 && i < GetNumSequences());
  331. if (i < 0 || i >= GetNumSequences())
  332. {
  333. return NULL;
  334. }
  335. return m_sequences[i].get();
  336. }
  337. //////////////////////////////////////////////////////////////////////////
  338. int CMovieSystem::GetNumSequences() const
  339. {
  340. return static_cast<int>(m_sequences.size());
  341. }
  342. //////////////////////////////////////////////////////////////////////////
  343. IAnimSequence* CMovieSystem::GetPlayingSequence(int i) const
  344. {
  345. assert(i >= 0 && i < GetNumPlayingSequences());
  346. if (i < 0 || i >= GetNumPlayingSequences())
  347. {
  348. return NULL;
  349. }
  350. return m_playingSequences[i].sequence.get();
  351. }
  352. //////////////////////////////////////////////////////////////////////////
  353. int CMovieSystem::GetNumPlayingSequences() const
  354. {
  355. return static_cast<int>(m_playingSequences.size());
  356. }
  357. //////////////////////////////////////////////////////////////////////////
  358. void CMovieSystem::AddSequence(IAnimSequence* sequence)
  359. {
  360. m_sequences.push_back(sequence);
  361. }
  362. //////////////////////////////////////////////////////////////////////////
  363. bool CMovieSystem::IsCutScenePlaying() const
  364. {
  365. const uint numPlayingSequences = static_cast<uint>(m_playingSequences.size());
  366. for (uint i = 0; i < numPlayingSequences; ++i)
  367. {
  368. const IAnimSequence* pAnimSequence = m_playingSequences[i].sequence.get();
  369. if (pAnimSequence && (pAnimSequence->GetFlags() & IAnimSequence::eSeqFlags_CutScene) != 0)
  370. {
  371. return true;
  372. }
  373. }
  374. return false;
  375. }
  376. //////////////////////////////////////////////////////////////////////////
  377. void CMovieSystem::RemoveSequence(IAnimSequence* sequence)
  378. {
  379. AZ_Assert(sequence != nullptr, "sequence should not be nullptr.");
  380. if (sequence)
  381. {
  382. IMovieCallback* callback = GetCallback();
  383. SetCallback(nullptr);
  384. StopSequence(sequence);
  385. // remove from m_newlyActivatedSequences in the edge case something was added but not processed yet.
  386. for (auto iter = m_newlyActivatedSequences.begin(); iter != m_newlyActivatedSequences.end(); ++iter)
  387. {
  388. if (sequence == *iter)
  389. {
  390. m_newlyActivatedSequences.erase(iter);
  391. break;
  392. }
  393. }
  394. for (Sequences::iterator iter = m_sequences.begin(); iter != m_sequences.end(); ++iter)
  395. {
  396. if (sequence == *iter)
  397. {
  398. m_movieListenerMap.erase(sequence);
  399. m_sequences.erase(iter);
  400. break;
  401. }
  402. }
  403. SetCallback(callback);
  404. }
  405. }
  406. //////////////////////////////////////////////////////////////////////////
  407. void CMovieSystem::OnSetSequenceId(uint32 sequenceId)
  408. {
  409. if (sequenceId >= m_nextSequenceId)
  410. {
  411. m_nextSequenceId = sequenceId + 1;
  412. }
  413. }
  414. //////////////////////////////////////////////////////////////////////////
  415. int CMovieSystem::OnSequenceRenamed(const char* before, const char* after)
  416. {
  417. assert(before && after);
  418. if (before == NULL || after == NULL)
  419. {
  420. return 0;
  421. }
  422. if (_stricmp(before, after) == 0)
  423. {
  424. return 0;
  425. }
  426. int count = 0;
  427. // For every sequence,
  428. for (Sequences::iterator it = m_sequences.begin(); it != m_sequences.end(); ++it)
  429. {
  430. // Find a director node, if any.
  431. for (int k = 0; k < (*it)->GetNodeCount(); ++k)
  432. {
  433. IAnimNode* node = (*it)->GetNode(k);
  434. if (node->GetType() != AnimNodeType::Director)
  435. {
  436. continue;
  437. }
  438. // If there is a director node, check whether it has a sequence track.
  439. IAnimTrack* track = node->GetTrackForParameter(AnimParamType::Sequence);
  440. if (track)
  441. {
  442. for (int m = 0; m < track->GetNumKeys(); ++m)
  443. {
  444. ISequenceKey seqKey;
  445. track->GetKey(m, &seqKey);
  446. // For each key that refers the sequence, update the name.
  447. if (!seqKey.szSelection.empty() && (_stricmp(seqKey.szSelection.c_str(), before) == 0))
  448. {
  449. seqKey.szSelection = after;
  450. track->SetKey(m, &seqKey);
  451. ++count;
  452. }
  453. }
  454. }
  455. break;
  456. }
  457. }
  458. return count;
  459. }
  460. //////////////////////////////////////////////////////////////////////////
  461. int CMovieSystem::OnCameraRenamed(const char* before, const char* after)
  462. {
  463. int count = 0;
  464. // For every sequence,
  465. for (Sequences::iterator it = m_sequences.begin(); it != m_sequences.end(); ++it)
  466. {
  467. // Find a director node, if any.
  468. for (int k = 0; k < (*it)->GetNodeCount(); ++k)
  469. {
  470. IAnimNode* node = (*it)->GetNode(k);
  471. if (node->GetType() != AnimNodeType::Director)
  472. {
  473. continue;
  474. }
  475. // If there is a director node, check whether it has a camera track.
  476. IAnimTrack* track = node->GetTrackForParameter(AnimParamType::Camera);
  477. if (track)
  478. {
  479. for (int m = 0; m < track->GetNumKeys(); ++m)
  480. {
  481. ISelectKey selKey;
  482. track->GetKey(m, &selKey);
  483. // For each key that refers the camera, update the name.
  484. if (_stricmp(selKey.szSelection.c_str(), before) == 0)
  485. {
  486. selKey.szSelection = after;
  487. track->SetKey(m, &selKey);
  488. ++count;
  489. }
  490. }
  491. }
  492. break;
  493. }
  494. }
  495. // For every sequence,
  496. for (Sequences::iterator it = m_sequences.begin(); it != m_sequences.end(); ++it)
  497. {
  498. // Find camera nodes.
  499. for (int k = 0; k < (*it)->GetNodeCount(); ++k)
  500. {
  501. IAnimNode* node = (*it)->GetNode(k);
  502. if (node->GetType() != AnimNodeType::Camera)
  503. {
  504. continue;
  505. }
  506. // Update its name, if it's a corresponding one.
  507. if (_stricmp(node->GetName(), before) == 0)
  508. {
  509. node->SetName(after);
  510. }
  511. }
  512. }
  513. return count;
  514. }
  515. //////////////////////////////////////////////////////////////////////////
  516. void CMovieSystem::RemoveAllSequences()
  517. {
  518. IMovieCallback* pCallback = GetCallback();
  519. SetCallback(NULL);
  520. InternalStopAllSequences(true, false);
  521. m_sequences.clear();
  522. for (TMovieListenerMap::iterator it = m_movieListenerMap.begin(); it != m_movieListenerMap.end(); )
  523. {
  524. if (it->first)
  525. {
  526. m_movieListenerMap.erase(it++);
  527. }
  528. else
  529. {
  530. ++it;
  531. }
  532. }
  533. SetCallback(pCallback);
  534. }
  535. //////////////////////////////////////////////////////////////////////////
  536. void CMovieSystem::PlaySequence(const char* pSequenceName, IAnimSequence* pParentSeq, bool bResetFx, bool bTrackedSequence, float startTime, float endTime)
  537. {
  538. IAnimSequence* sequence = FindLegacySequenceByName(pSequenceName);
  539. if (sequence)
  540. {
  541. PlaySequence(sequence, pParentSeq, bResetFx, bTrackedSequence, startTime, endTime);
  542. }
  543. else
  544. {
  545. gEnv->pLog->Log ("CMovieSystem::PlaySequence: Error: Sequence \"%s\" not found", pSequenceName);
  546. }
  547. }
  548. //////////////////////////////////////////////////////////////////////////
  549. void CMovieSystem::PlaySequence(IAnimSequence* sequence, IAnimSequence* parentSeq,
  550. bool bResetFx, bool bTrackedSequence, float startTime, float endTime)
  551. {
  552. assert(sequence != 0);
  553. if (!sequence || IsPlaying(sequence))
  554. {
  555. return;
  556. }
  557. if ((sequence->GetFlags() & IAnimSequence::eSeqFlags_CutScene) || (sequence->GetFlags() & IAnimSequence::eSeqFlags_NoHUD))
  558. {
  559. // Don't play cut-scene if this console variable set.
  560. if (m_mov_NoCutscenes != 0)
  561. {
  562. return;
  563. }
  564. }
  565. // If this sequence is cut scene disable player.
  566. if (sequence->GetFlags() & IAnimSequence::eSeqFlags_CutScene)
  567. {
  568. OnCameraCut();
  569. sequence->SetParentSequence(parentSeq);
  570. if (!gEnv->IsEditing() || !m_bCutscenesPausedInEditor)
  571. {
  572. if (m_pUser)
  573. {
  574. m_pUser->BeginCutScene(sequence, sequence->GetCutSceneFlags(), bResetFx);
  575. }
  576. }
  577. }
  578. sequence->Activate();
  579. sequence->Resume();
  580. static_cast<CAnimSequence*>(sequence)->OnStart();
  581. PlayingSequence ps;
  582. ps.sequence = sequence;
  583. ps.startTime = startTime == -FLT_MAX ? sequence->GetTimeRange().start : startTime;
  584. ps.endTime = endTime == -FLT_MAX ? sequence->GetTimeRange().end : endTime;
  585. ps.currentTime = startTime == -FLT_MAX ? sequence->GetTimeRange().start : startTime;
  586. ps.currentSpeed = 1.0f;
  587. ps.trackedSequence = bTrackedSequence;
  588. ps.bSingleFrame = false;
  589. // Make sure all members are initialized before pushing.
  590. m_playingSequences.push_back(ps);
  591. // tell all interested listeners
  592. NotifyListeners(sequence, IMovieListener::eMovieEvent_Started);
  593. }
  594. void CMovieSystem::NotifyListeners(IAnimSequence* sequence, IMovieListener::EMovieEvent event)
  595. {
  596. ////////////////////////////////
  597. // Legacy Notification System
  598. TMovieListenerMap::iterator found (m_movieListenerMap.find(sequence));
  599. if (found != m_movieListenerMap.end())
  600. {
  601. TMovieListenerVec listForSeq = (*found).second;
  602. TMovieListenerVec::iterator iter (listForSeq.begin());
  603. while (iter != listForSeq.end())
  604. {
  605. (*iter)->OnMovieEvent(event, sequence);
  606. ++iter;
  607. }
  608. }
  609. // 'NULL' ones are listeners interested in every sequence. Do not send "update" here
  610. if (event != IMovieListener::eMovieEvent_Updated)
  611. {
  612. TMovieListenerMap::iterator found2 (m_movieListenerMap.find((IAnimSequence*)0));
  613. if (found2 != m_movieListenerMap.end())
  614. {
  615. TMovieListenerVec listForSeq = (*found2).second;
  616. TMovieListenerVec::iterator iter (listForSeq.begin());
  617. while (iter != listForSeq.end())
  618. {
  619. (*iter)->OnMovieEvent(event, sequence);
  620. ++iter;
  621. }
  622. }
  623. }
  624. /////////////////////////////////////
  625. // SequenceComponentNotification EBus
  626. const AZ::EntityId& sequenceComponentEntityId = sequence->GetSequenceEntityId();
  627. switch (event)
  628. {
  629. /*
  630. * When a sequence is stopped, Resume is called just before stopped (not sure why). To ensure that a OnStop notification is sent out after the Resume,
  631. * notifications for eMovieEvent_Started and eMovieEvent_Stopped are handled in IAnimSequence::OnStart and IAnimSequence::OnStop
  632. */
  633. case IMovieListener::eMovieEvent_Aborted:
  634. {
  635. Maestro::SequenceComponentNotificationBus::Event(sequenceComponentEntityId, &Maestro::SequenceComponentNotificationBus::Events::OnAbort, GetPlayingTime(sequence));
  636. break;
  637. }
  638. case IMovieListener::eMovieEvent_Updated:
  639. {
  640. Maestro::SequenceComponentNotificationBus::Event(sequenceComponentEntityId, &Maestro::SequenceComponentNotificationBus::Events::OnUpdate, GetPlayingTime(sequence));
  641. break;
  642. }
  643. default:
  644. {
  645. // do nothing for unhandled IMovieListener events
  646. break;
  647. }
  648. }
  649. }
  650. //////////////////////////////////////////////////////////////////////////
  651. bool CMovieSystem::StopSequence(const char* pSequenceName)
  652. {
  653. IAnimSequence* sequence = FindLegacySequenceByName(pSequenceName);
  654. if (sequence)
  655. {
  656. return StopSequence(sequence);
  657. }
  658. return false;
  659. }
  660. //////////////////////////////////////////////////////////////////////////
  661. bool CMovieSystem::StopSequence(IAnimSequence* sequence)
  662. {
  663. return InternalStopSequence(sequence, false, true);
  664. }
  665. //////////////////////////////////////////////////////////////////////////
  666. void CMovieSystem::InternalStopAllSequences(bool bAbort, bool bAnimate)
  667. {
  668. while (!m_playingSequences.empty())
  669. {
  670. InternalStopSequence(m_playingSequences.begin()->sequence.get(), bAbort, bAnimate);
  671. }
  672. stl::free_container(m_playingSequences);
  673. }
  674. //////////////////////////////////////////////////////////////////////////
  675. bool CMovieSystem::InternalStopSequence(IAnimSequence* sequence, bool bAbort, bool bAnimate)
  676. {
  677. assert(sequence != 0);
  678. PlayingSequences::iterator it;
  679. if (!FindSequence(sequence, it))
  680. {
  681. return false;
  682. }
  683. if (bAnimate && sequence->IsActivated())
  684. {
  685. if (m_sequenceStopBehavior == eSSB_GotoEndTime)
  686. {
  687. SAnimContext ac;
  688. ac.singleFrame = true;
  689. ac.time = sequence->GetTimeRange().end;
  690. sequence->Animate(ac);
  691. }
  692. else if (m_sequenceStopBehavior == eSSB_GotoStartTime)
  693. {
  694. SAnimContext ac;
  695. ac.singleFrame = true;
  696. ac.time = sequence->GetTimeRange().start;
  697. sequence->Animate(ac);
  698. }
  699. sequence->Deactivate();
  700. }
  701. // If this sequence is cut scene end it.
  702. if (sequence->GetFlags() & IAnimSequence::eSeqFlags_CutScene)
  703. {
  704. if (!gEnv->IsEditing() || !m_bCutscenesPausedInEditor)
  705. {
  706. if (m_pUser)
  707. {
  708. m_pUser->EndCutScene(sequence, sequence->GetCutSceneFlags(true));
  709. }
  710. }
  711. sequence->SetParentSequence(NULL);
  712. }
  713. // tell all interested listeners
  714. NotifyListeners(sequence, bAbort ? IMovieListener::eMovieEvent_Aborted : IMovieListener::eMovieEvent_Stopped);
  715. // erase the sequence after notifying listeners so if they choose to they can get the ending time of this sequence
  716. if (FindSequence(sequence, it))
  717. {
  718. m_playingSequences.erase(it);
  719. }
  720. sequence->Resume();
  721. static_cast<CAnimSequence*>(sequence)->OnStop();
  722. return true;
  723. }
  724. //////////////////////////////////////////////////////////////////////////
  725. bool CMovieSystem::AbortSequence(IAnimSequence* sequence, bool bLeaveTime)
  726. {
  727. return InternalStopSequence(sequence, true, !bLeaveTime);
  728. }
  729. //////////////////////////////////////////////////////////////////////////
  730. void CMovieSystem::StopAllSequences()
  731. {
  732. InternalStopAllSequences(false, true);
  733. }
  734. //////////////////////////////////////////////////////////////////////////
  735. void CMovieSystem::StopAllCutScenes()
  736. {
  737. bool bAnyStoped;
  738. PlayingSequences::iterator next;
  739. do
  740. {
  741. bAnyStoped = false;
  742. for (PlayingSequences::iterator it = m_playingSequences.begin(); it != m_playingSequences.end(); it = next)
  743. {
  744. next = it;
  745. ++next;
  746. IAnimSequence* pCurrentSequence = it->sequence.get();
  747. if (pCurrentSequence->GetFlags() & IAnimSequence::eSeqFlags_CutScene)
  748. {
  749. bAnyStoped = true;
  750. StopSequence(pCurrentSequence);
  751. break;
  752. }
  753. }
  754. } while (bAnyStoped);
  755. if (m_playingSequences.empty())
  756. {
  757. stl::free_container(m_playingSequences);
  758. }
  759. }
  760. //////////////////////////////////////////////////////////////////////////
  761. bool CMovieSystem::IsPlaying(IAnimSequence* sequence) const
  762. {
  763. if (nullptr == sequence)
  764. {
  765. return false;
  766. }
  767. for (PlayingSequences::const_iterator it = m_playingSequences.begin(); it != m_playingSequences.end(); ++it)
  768. {
  769. if (it->sequence->GetSequenceEntityId() == sequence->GetSequenceEntityId())
  770. {
  771. return true;
  772. }
  773. }
  774. return false;
  775. }
  776. //////////////////////////////////////////////////////////////////////////
  777. void CMovieSystem::Reset(bool bPlayOnReset, bool bSeekToStart)
  778. {
  779. InternalStopAllSequences(true, false);
  780. // Reset all sequences.
  781. for (Sequences::const_iterator iter = m_sequences.cbegin(); iter != m_sequences.cend(); ++iter)
  782. {
  783. IAnimSequence* pCurrentSequence = iter->get();
  784. NotifyListeners(pCurrentSequence, IMovieListener::eMovieEvent_Started);
  785. pCurrentSequence->Reset(bSeekToStart);
  786. NotifyListeners(pCurrentSequence, IMovieListener::eMovieEvent_Stopped);
  787. }
  788. if (bPlayOnReset)
  789. {
  790. for (Sequences::iterator iter = m_sequences.begin(); iter != m_sequences.end(); ++iter)
  791. {
  792. IAnimSequence* pCurrentSequence = iter->get();
  793. if (pCurrentSequence->GetFlags() & IAnimSequence::eSeqFlags_PlayOnReset)
  794. {
  795. PlaySequence(pCurrentSequence);
  796. }
  797. }
  798. }
  799. // un-pause the movie system
  800. m_bPaused = false;
  801. // Reset camera.
  802. SCameraParams CamParams = GetCameraParams();
  803. CamParams.cameraEntityId.SetInvalid();
  804. CamParams.fov = 0.0f;
  805. CamParams.justActivated = true;
  806. SetCameraParams(CamParams);
  807. }
  808. //////////////////////////////////////////////////////////////////////////
  809. void CMovieSystem::PlayOnLoadSequences()
  810. {
  811. for (Sequences::const_iterator sit = m_sequences.cbegin(); sit != m_sequences.cend(); ++sit)
  812. {
  813. IAnimSequence* sequence = sit->get();
  814. if (sequence->GetFlags() & IAnimSequence::eSeqFlags_PlayOnReset)
  815. {
  816. PlaySequence(sequence);
  817. }
  818. }
  819. // Reset camera.
  820. SCameraParams CamParams = GetCameraParams();
  821. CamParams.cameraEntityId.SetInvalid();
  822. CamParams.fov = 0.0f;
  823. CamParams.justActivated = true;
  824. SetCameraParams(CamParams);
  825. }
  826. //////////////////////////////////////////////////////////////////////////
  827. void CMovieSystem::StillUpdate()
  828. {
  829. if (!gEnv->IsEditor())
  830. {
  831. return;
  832. }
  833. for (PlayingSequences::iterator it = m_playingSequences.begin(); it != m_playingSequences.end(); ++it)
  834. {
  835. PlayingSequence& playingSequence = *it;
  836. playingSequence.sequence->StillUpdate();
  837. }
  838. // Check for end capture here while in the editor.
  839. // In some cases, we might have signaled an end capture when leaving Game mode,
  840. // but ControlCapture hasn't been given a tick by Game to actually end the capture.
  841. // So make sure any pending end capture signaled gets shutdown here.
  842. CheckForEndCapture();
  843. }
  844. //////////////////////////////////////////////////////////////////////////
  845. void CMovieSystem::ShowPlayedSequencesDebug()
  846. {
  847. float y = 10.0f;
  848. AZStd::vector<const char*> names;
  849. AZStd::vector<float> rows;
  850. constexpr f32 green[4] = {0, 1, 0, 1};
  851. constexpr f32 purple[4] = {1, 0, 1, 1};
  852. constexpr f32 white[4] = {1, 1, 1, 1};
  853. //TODO: needs an implementation
  854. auto Draw2dLabel = [](float /*x*/,float /*y*/,float /*depth*/,const f32* /*color*/,bool /*center*/, const char* /*fmt*/, ...) {};
  855. for (PlayingSequences::iterator it = m_playingSequences.begin(); it != m_playingSequences.end(); ++it)
  856. {
  857. PlayingSequence& playingSequence = *it;
  858. if (playingSequence.sequence == nullptr)
  859. {
  860. continue;
  861. }
  862. const char* fullname = playingSequence.sequence->GetName();
  863. Draw2dLabel(1.0f, y, 1.3f, green, false, "Sequence %s : %f (x %f)", fullname, playingSequence.currentTime, playingSequence.currentSpeed);
  864. y += 16.0f;
  865. for (int i = 0; i < playingSequence.sequence->GetNodeCount(); ++i)
  866. {
  867. // Checks nodes which happen to be in several sequences.
  868. // Those can be a bug, since several sequences may try to control the same entity.
  869. const char* name = playingSequence.sequence->GetNode(i)->GetName();
  870. bool alreadyThere = false;
  871. for (size_t k = 0; k < names.size(); ++k)
  872. {
  873. if (strcmp(names[k], name) == 0)
  874. {
  875. alreadyThere = true;
  876. break;
  877. }
  878. }
  879. if (alreadyThere == false)
  880. {
  881. names.push_back(name);
  882. }
  883. Draw2dLabel((21.0f + 100.0f * i), ((i % 2) ? (y + 8.0f) : y), 1.0f, alreadyThere ? white : purple, false, "%s", name);
  884. }
  885. y += 32.0f;
  886. }
  887. }
  888. //////////////////////////////////////////////////////////////////////////
  889. void CMovieSystem::PreUpdate(float deltaTime)
  890. {
  891. // Sequences can be spawned in game via a dynamic slice, so process newly activated sequences to see
  892. // if they should be auto played.
  893. for (auto iter = m_newlyActivatedSequences.begin(); iter != m_newlyActivatedSequences.end(); ++iter)
  894. {
  895. IAnimSequence* sequence = *iter;
  896. if (sequence->GetFlags() & IAnimSequence::eSeqFlags_PlayOnReset && !IsPlaying(sequence))
  897. {
  898. PlaySequence(sequence);
  899. }
  900. }
  901. m_newlyActivatedSequences.clear();
  902. UpdateInternal(Internal::ApplyDeltaTimeOverrideIfEnabled(deltaTime), true);
  903. }
  904. //////////////////////////////////////////////////////////////////////////
  905. void CMovieSystem::PostUpdate(float deltaTime)
  906. {
  907. UpdateInternal(Internal::ApplyDeltaTimeOverrideIfEnabled(deltaTime), false);
  908. }
  909. //////////////////////////////////////////////////////////////////////////
  910. void CMovieSystem::UpdateInternal(const float deltaTime, const bool bPreUpdate)
  911. {
  912. SAnimContext animContext;
  913. if (m_bPaused)
  914. {
  915. return;
  916. }
  917. // don't update more than once if dt==0.0
  918. const AZ::TimeUs curTime = AZ::GetLastSimulationTickTime();
  919. if (deltaTime == 0.0f && curTime == m_lastUpdateTime && !gEnv->IsEditor())
  920. {
  921. return;
  922. }
  923. m_lastUpdateTime = curTime;
  924. float fps = 60.0f;
  925. std::vector<IAnimSequence*> stopSequences;
  926. const size_t numPlayingSequences = m_playingSequences.size();
  927. for (size_t i = 0; i < numPlayingSequences; ++i)
  928. {
  929. PlayingSequence& playingSequence = m_playingSequences[i];
  930. if (playingSequence.sequence->IsPaused())
  931. {
  932. continue;
  933. }
  934. const float scaledTimeDelta = deltaTime * playingSequence.currentSpeed;
  935. // Increase play time in pre-update
  936. if (bPreUpdate)
  937. {
  938. playingSequence.currentTime += scaledTimeDelta;
  939. }
  940. // Skip sequence if current update does not apply
  941. const bool bSequenceEarlyUpdate = (playingSequence.sequence->GetFlags() & IAnimSequence::eSeqFlags_EarlyMovieUpdate) != 0;
  942. if ((bPreUpdate && !bSequenceEarlyUpdate ) || (!bPreUpdate && bSequenceEarlyUpdate)
  943. )
  944. {
  945. continue;
  946. }
  947. int nSeqFlags = playingSequence.sequence->GetFlags();
  948. if ((nSeqFlags& IAnimSequence::eSeqFlags_CutScene) && m_mov_NoCutscenes != 0)
  949. {
  950. // Don't play cut-scene if no cut scenes console variable set.
  951. stopSequences.push_back(playingSequence.sequence.get());
  952. continue;
  953. }
  954. animContext.time = playingSequence.currentTime;
  955. animContext.sequence = playingSequence.sequence.get();
  956. animContext.dt = scaledTimeDelta;
  957. animContext.fps = fps;
  958. animContext.startTime = playingSequence.startTime;
  959. // Check time out of range, setting up playingSequence for the next Update
  960. bool wasLooped = false;
  961. // Add a tolerance to this check because we want currentTime == currentTime to keep
  962. // animating so the last frame is animated. This comes into play with a fixed time step
  963. // like when capturing render output.
  964. const float precisionTolerance = 0.0001f;
  965. if ((playingSequence.currentTime - precisionTolerance) > playingSequence.endTime)
  966. {
  967. int seqFlags = playingSequence.sequence->GetFlags();
  968. bool isLoop = ((seqFlags& IAnimSequence::eSeqFlags_OutOfRangeLoop) != 0);
  969. bool isConstant = ((seqFlags& IAnimSequence::eSeqFlags_OutOfRangeConstant) != 0);
  970. if (m_bBatchRenderMode || (!isLoop && !isConstant))
  971. {
  972. // If we're batch rendering or no out-of-range type specified sequence stopped when time reaches end of range.
  973. // Queue sequence for stopping.
  974. if (playingSequence.trackedSequence == false)
  975. {
  976. stopSequences.push_back(playingSequence.sequence.get());
  977. }
  978. continue;
  979. }
  980. // note we'll never get here if in batchRenderMode or if outOfRange is set to 'Once' (not loop or constant)
  981. if (isLoop)
  982. {
  983. // Time wrap's back to the start of the time range.
  984. playingSequence.currentTime = playingSequence.startTime; // should there be a fmodf here?
  985. wasLooped = true;
  986. }
  987. // Time just continues normally past the end of time range for isConstant (nothing to do for isConstant)
  988. }
  989. else
  990. {
  991. NotifyListeners(playingSequence.sequence.get(), IMovieListener::eMovieEvent_Updated);
  992. }
  993. animContext.singleFrame = playingSequence.bSingleFrame;
  994. playingSequence.bSingleFrame = false;
  995. // Animate sequence. (Can invalidate iterator)
  996. playingSequence.sequence->Animate(animContext);
  997. // we call OnLoop() *after* Animate() to reset sounds (for CAnimSceneNodes), for the next update (the looped update)
  998. if (wasLooped)
  999. {
  1000. playingSequence.sequence->OnLoop();
  1001. }
  1002. }
  1003. #if !defined(_RELEASE)
  1004. if (m_mov_DebugEvents)
  1005. {
  1006. ShowPlayedSequencesDebug();
  1007. }
  1008. #endif //#if !defined(_RELEASE)
  1009. // Stop queued sequences.
  1010. for (int i = 0; i < (int)stopSequences.size(); i++)
  1011. {
  1012. StopSequence(stopSequences[i]);
  1013. }
  1014. }
  1015. //////////////////////////////////////////////////////////////////////////
  1016. void CMovieSystem::Render()
  1017. {
  1018. for (PlayingSequences::iterator it = m_playingSequences.begin(); it != m_playingSequences.end(); ++it)
  1019. {
  1020. PlayingSequence& playingSequence = *it;
  1021. playingSequence.sequence->Render();
  1022. }
  1023. }
  1024. //////////////////////////////////////////////////////////////////////////
  1025. void CMovieSystem::Callback(IMovieCallback::ECallbackReason reason, IAnimNode* pNode)
  1026. {
  1027. if (m_pCallback)
  1028. {
  1029. m_pCallback->OnMovieCallback(reason, pNode);
  1030. }
  1031. }
  1032. //////////////////////////////////////////////////////////////////////////
  1033. void CMovieSystem::Reflect(AZ::ReflectContext* context)
  1034. {
  1035. if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
  1036. {
  1037. serializeContext->Class<CMovieSystem>()
  1038. ->Version(1)
  1039. ->Field("Sequences", &CMovieSystem::m_sequences);
  1040. }
  1041. AnimSerializer::ReflectAnimTypes(context);
  1042. }
  1043. //////////////////////////////////////////////////////////////////////////
  1044. void CMovieSystem::SetCameraParams(const SCameraParams& Params)
  1045. {
  1046. m_ActiveCameraParams = Params;
  1047. // Make sure the camera entity is valid
  1048. if (m_ActiveCameraParams.cameraEntityId.IsValid())
  1049. {
  1050. // Component Camera
  1051. AZ::Entity* entity = nullptr;
  1052. AZ::ComponentApplicationBus::BroadcastResult(entity, &AZ::ComponentApplicationBus::Events::FindEntity, m_ActiveCameraParams.cameraEntityId);
  1053. if (entity)
  1054. {
  1055. // Make sure the camera component was not removed from an entity that is used as a camera.
  1056. if (!(entity->FindComponent(CameraComponentTypeId) || entity->FindComponent(EditorCameraComponentTypeId)))
  1057. {
  1058. // if this entity does not have a camera component, do not use it.
  1059. m_ActiveCameraParams.cameraEntityId.SetInvalid();
  1060. }
  1061. }
  1062. }
  1063. if (m_pUser)
  1064. {
  1065. m_pUser->SetActiveCamera(m_ActiveCameraParams);
  1066. }
  1067. if (m_pCallback)
  1068. {
  1069. m_pCallback->OnSetCamera(m_ActiveCameraParams);
  1070. }
  1071. }
  1072. //////////////////////////////////////////////////////////////////////////
  1073. void CMovieSystem::SendGlobalEvent(const char* pszEvent)
  1074. {
  1075. if (m_pUser)
  1076. {
  1077. m_pUser->SendGlobalEvent(pszEvent);
  1078. }
  1079. }
  1080. //////////////////////////////////////////////////////////////////////////
  1081. void CMovieSystem::Pause()
  1082. {
  1083. m_bPaused = true;
  1084. }
  1085. //////////////////////////////////////////////////////////////////////////
  1086. void CMovieSystem::Resume()
  1087. {
  1088. m_bPaused = false;
  1089. }
  1090. //////////////////////////////////////////////////////////////////////////
  1091. void CMovieSystem::PauseCutScenes()
  1092. {
  1093. m_bCutscenesPausedInEditor = true;
  1094. if (m_pUser != nullptr)
  1095. {
  1096. for (PlayingSequences::iterator it = m_playingSequences.begin(); it != m_playingSequences.end(); ++it)
  1097. {
  1098. if (it->sequence->GetFlags() & IAnimSequence::eSeqFlags_CutScene)
  1099. {
  1100. m_pUser->EndCutScene(it->sequence.get(), it->sequence->GetCutSceneFlags(true));
  1101. }
  1102. }
  1103. }
  1104. }
  1105. //////////////////////////////////////////////////////////////////////////
  1106. void CMovieSystem::ResumeCutScenes()
  1107. {
  1108. if (m_mov_NoCutscenes != 0)
  1109. {
  1110. return;
  1111. }
  1112. m_bCutscenesPausedInEditor = false;
  1113. if (m_pUser != nullptr)
  1114. {
  1115. for (PlayingSequences::iterator it = m_playingSequences.begin(); it != m_playingSequences.end(); ++it)
  1116. {
  1117. if (it->sequence->GetFlags() & IAnimSequence::eSeqFlags_CutScene)
  1118. {
  1119. m_pUser->BeginCutScene(it->sequence.get(), it->sequence->GetCutSceneFlags(), true);
  1120. }
  1121. }
  1122. }
  1123. }
  1124. //////////////////////////////////////////////////////////////////////////
  1125. float CMovieSystem::GetPlayingTime(IAnimSequence* sequence)
  1126. {
  1127. if (!sequence || !IsPlaying(sequence))
  1128. {
  1129. return -1.0;
  1130. }
  1131. PlayingSequences::const_iterator it;
  1132. if (FindSequence(sequence, it))
  1133. {
  1134. return it->currentTime;
  1135. }
  1136. return -1.0f;
  1137. }
  1138. float CMovieSystem::GetPlayingSpeed(IAnimSequence* sequence)
  1139. {
  1140. if (!sequence || !IsPlaying(sequence))
  1141. {
  1142. return -1.0f;
  1143. }
  1144. PlayingSequences::const_iterator it;
  1145. if (FindSequence(sequence, it))
  1146. {
  1147. return it->currentSpeed;
  1148. }
  1149. return -1.0f;
  1150. }
  1151. bool CMovieSystem::SetPlayingTime(IAnimSequence* sequence, float fTime)
  1152. {
  1153. if (!sequence || !IsPlaying(sequence))
  1154. {
  1155. return false;
  1156. }
  1157. PlayingSequences::iterator it;
  1158. if (FindSequence(sequence, it) && !(sequence->GetFlags() & IAnimSequence::eSeqFlags_NoSeek))
  1159. {
  1160. it->currentTime = fTime;
  1161. it->bSingleFrame = true;
  1162. NotifyListeners(sequence, IMovieListener::eMovieEvent_Updated);
  1163. return true;
  1164. }
  1165. return false;
  1166. }
  1167. bool CMovieSystem::SetPlayingSpeed(IAnimSequence* sequence, float fSpeed)
  1168. {
  1169. if (!sequence)
  1170. {
  1171. return false;
  1172. }
  1173. PlayingSequences::iterator it;
  1174. if (FindSequence(sequence, it) && !(sequence->GetFlags() & IAnimSequence::eSeqFlags_NoSpeed))
  1175. {
  1176. NotifyListeners(sequence, IMovieListener::eMovieEvent_Updated);
  1177. it->currentSpeed = fSpeed;
  1178. return true;
  1179. }
  1180. return false;
  1181. }
  1182. bool CMovieSystem::GetStartEndTime(IAnimSequence* sequence, float& fStartTime, float& fEndTime)
  1183. {
  1184. fStartTime = 0.0f;
  1185. fEndTime = 0.0f;
  1186. if (!sequence || !IsPlaying(sequence))
  1187. {
  1188. return false;
  1189. }
  1190. PlayingSequences::const_iterator it;
  1191. if (FindSequence(sequence, it))
  1192. {
  1193. fStartTime = it->startTime;
  1194. fEndTime = it->endTime;
  1195. return true;
  1196. }
  1197. return false;
  1198. }
  1199. bool CMovieSystem::SetStartEndTime(IAnimSequence* pSeq, const float fStartTime, const float fEndTime)
  1200. {
  1201. if (!pSeq || !IsPlaying(pSeq))
  1202. {
  1203. return false;
  1204. }
  1205. PlayingSequences::iterator it;
  1206. if (FindSequence(pSeq, it))
  1207. {
  1208. it->startTime = fStartTime;
  1209. it->endTime = fEndTime;
  1210. return true;
  1211. }
  1212. return false;
  1213. }
  1214. void CMovieSystem::SetSequenceStopBehavior(ESequenceStopBehavior behavior)
  1215. {
  1216. m_sequenceStopBehavior = behavior;
  1217. }
  1218. IMovieSystem::ESequenceStopBehavior CMovieSystem::GetSequenceStopBehavior()
  1219. {
  1220. return m_sequenceStopBehavior;
  1221. }
  1222. bool CMovieSystem::AddMovieListener(IAnimSequence* sequence, IMovieListener* pListener)
  1223. {
  1224. assert (pListener != 0);
  1225. if (sequence != NULL && std::find(m_sequences.begin(), m_sequences.end(), sequence) == m_sequences.end())
  1226. {
  1227. gEnv->pLog->Log ("CMovieSystem::AddMovieListener: Sequence %p unknown to CMovieSystem", sequence);
  1228. return false;
  1229. }
  1230. return stl::push_back_unique(m_movieListenerMap[sequence], pListener);
  1231. }
  1232. bool CMovieSystem::RemoveMovieListener(IAnimSequence* sequence, IMovieListener* pListener)
  1233. {
  1234. assert (pListener != 0);
  1235. if (sequence != NULL
  1236. && std::find(m_sequences.begin(), m_sequences.end(), sequence) == m_sequences.end())
  1237. {
  1238. gEnv->pLog->Log ("CMovieSystem::AddMovieListener: Sequence %p unknown to CMovieSystem", sequence);
  1239. return false;
  1240. }
  1241. return stl::find_and_erase(m_movieListenerMap[sequence], pListener);
  1242. }
  1243. #if !defined(_RELEASE)
  1244. void CMovieSystem::GoToFrameCmd(IConsoleCmdArgs* pArgs)
  1245. {
  1246. if (pArgs->GetArgCount() < 3)
  1247. {
  1248. gEnv->pLog->LogError("GoToFrame failed! You should provide two arguments of 'sequence name' & 'frame time'.");
  1249. return;
  1250. }
  1251. const char* pSeqName = pArgs->GetArg(1);
  1252. float targetFrame = (float)atof(pArgs->GetArg(2));
  1253. ((CMovieSystem*)gEnv->pMovieSystem)->GoToFrame(pSeqName, targetFrame);
  1254. }
  1255. #endif //#if !defined(_RELEASE)
  1256. #if !defined(_RELEASE)
  1257. void CMovieSystem::ListSequencesCmd([[maybe_unused]] IConsoleCmdArgs* pArgs)
  1258. {
  1259. int numSequences = gEnv->pMovieSystem->GetNumSequences();
  1260. for (int i = 0; i < numSequences; i++)
  1261. {
  1262. IAnimSequence* pSeq = gEnv->pMovieSystem->GetSequence(i);
  1263. if (pSeq)
  1264. {
  1265. CryLogAlways("%s", pSeq->GetName());
  1266. }
  1267. }
  1268. }
  1269. #endif //#if !defined(_RELEASE)
  1270. #if !defined(_RELEASE)
  1271. void CMovieSystem::PlaySequencesCmd(IConsoleCmdArgs* pArgs)
  1272. {
  1273. const char* sequenceName = pArgs->GetArg(1);
  1274. gEnv->pMovieSystem->PlaySequence(sequenceName, nullptr, false, false);
  1275. }
  1276. #endif //#if !defined(_RELEASE)
  1277. void CMovieSystem::GoToFrame(const char* seqName, float targetFrame)
  1278. {
  1279. assert(seqName != NULL);
  1280. if (gEnv->IsEditor() && gEnv->IsEditorGameMode() == false)
  1281. {
  1282. AZStd::string editorCmd = AZStd::string::format("mov_goToFrameEditor %s %f", seqName, targetFrame);
  1283. gEnv->pConsole->ExecuteString(editorCmd.c_str());
  1284. return;
  1285. }
  1286. for (PlayingSequences::iterator it = m_playingSequences.begin();
  1287. it != m_playingSequences.end(); ++it)
  1288. {
  1289. PlayingSequence& ps = *it;
  1290. const char* fullname = ps.sequence->GetName();
  1291. if (strcmp(fullname, seqName) == 0)
  1292. {
  1293. assert(ps.sequence->GetTimeRange().start <= targetFrame && targetFrame <= ps.sequence->GetTimeRange().end);
  1294. ps.currentTime = targetFrame;
  1295. ps.bSingleFrame = true;
  1296. break;
  1297. }
  1298. }
  1299. }
  1300. void CMovieSystem::EnableFixedStepForCapture(float step)
  1301. {
  1302. if (auto* timeSystem = AZ::Interface<AZ::ITime>::Get())
  1303. {
  1304. m_fixedTimeStepBackUp = timeSystem->GetSimulationTickDeltaOverride();
  1305. timeSystem->SetSimulationTickDeltaOverride(AZ::SecondsToTimeUs(step));
  1306. }
  1307. if (nullptr == m_cvar_sys_maxTimeStepForMovieSystem)
  1308. {
  1309. m_cvar_sys_maxTimeStepForMovieSystem = gEnv->pConsole->GetCVar("sys_maxTimeStepForMovieSystem");
  1310. }
  1311. // Make sure the max step for the movie system is big enough
  1312. m_maxTimeStepForMovieSystemBackUp = m_cvar_sys_maxTimeStepForMovieSystem->GetFVal();
  1313. if (step > m_maxTimeStepForMovieSystemBackUp)
  1314. {
  1315. m_cvar_sys_maxTimeStepForMovieSystem->Set(step);
  1316. }
  1317. }
  1318. void CMovieSystem::DisableFixedStepForCapture()
  1319. {
  1320. if (auto* timeSystem = AZ::Interface<AZ::ITime>::Get())
  1321. {
  1322. timeSystem->SetSimulationTickDeltaOverride(m_fixedTimeStepBackUp);
  1323. }
  1324. m_cvar_sys_maxTimeStepForMovieSystem->Set(m_maxTimeStepForMovieSystemBackUp);
  1325. }
  1326. void CMovieSystem::StartCapture(const ICaptureKey& key, int frame)
  1327. {
  1328. m_bStartCapture = true;
  1329. m_captureKey = key;
  1330. m_captureFrame = frame;
  1331. }
  1332. void CMovieSystem::EndCapture()
  1333. {
  1334. m_bEndCapture = true;
  1335. }
  1336. void CMovieSystem::CheckForEndCapture()
  1337. {
  1338. if (m_bEndCapture)
  1339. {
  1340. m_captureFrame = -1;
  1341. m_cvar_capture_frames->Set(0);
  1342. m_bEndCapture = false;
  1343. }
  1344. }
  1345. void CMovieSystem::ControlCapture()
  1346. {
  1347. #if !defined(NDEBUG)
  1348. bool bBothStartAndEnd = m_bStartCapture && m_bEndCapture;
  1349. assert(!bBothStartAndEnd);
  1350. #endif
  1351. bool bAllCVarsReady
  1352. = m_cvar_capture_frame_once && m_cvar_capture_folder && m_cvar_capture_frames;
  1353. if (!bAllCVarsReady)
  1354. {
  1355. m_cvar_capture_frame_once = gEnv->pConsole->GetCVar("capture_frame_once");
  1356. m_cvar_capture_folder = gEnv->pConsole->GetCVar("capture_folder");
  1357. m_cvar_capture_frames = gEnv->pConsole->GetCVar("capture_frames");
  1358. m_cvar_capture_file_prefix = gEnv->pConsole->GetCVar("capture_file_prefix");
  1359. }
  1360. bAllCVarsReady
  1361. = m_cvar_capture_frame_once
  1362. && m_cvar_capture_folder && m_cvar_capture_frames
  1363. && m_cvar_capture_file_prefix;
  1364. assert(bAllCVarsReady);
  1365. if (!bAllCVarsReady)
  1366. {
  1367. m_bStartCapture = m_bEndCapture = false;
  1368. return;
  1369. }
  1370. if (m_bStartCapture)
  1371. {
  1372. m_cvar_capture_frame_once->Set(m_captureKey.once ? 1 : 0);
  1373. m_cvar_capture_folder->Set(m_captureKey.folder.c_str());
  1374. m_cvar_capture_file_prefix->Set(m_captureKey.prefix.c_str());
  1375. // one-based frame number, zero disables capture.
  1376. m_cvar_capture_frames->Set(1 + m_captureFrame);
  1377. m_bStartCapture = false;
  1378. }
  1379. CheckForEndCapture();
  1380. }
  1381. //////////////////////////////////////////////////////////////////////////
  1382. bool CMovieSystem::IsCapturing() const
  1383. {
  1384. return m_cvar_capture_frames ? m_cvar_capture_frames->GetIVal() != 0 : false;
  1385. }
  1386. //////////////////////////////////////////////////////////////////////////
  1387. void CMovieSystem::SerializeNodeType(AnimNodeType& animNodeType, XmlNodeRef& xmlNode, bool bLoading, const uint version, int flags)
  1388. {
  1389. static const char* kType = "Type";
  1390. if (bLoading)
  1391. {
  1392. // Old serialization values that are no longer
  1393. // defined in IMovieSystem.h, but needed for conversion:
  1394. static const int kOldParticleNodeType = 0x18;
  1395. animNodeType = AnimNodeType::Invalid;
  1396. // In old versions there was special code for particles
  1397. // that is now handles by generic entity node code
  1398. if (version == 0 && static_cast<int>(animNodeType) == kOldParticleNodeType)
  1399. {
  1400. animNodeType = AnimNodeType::Entity;
  1401. return;
  1402. }
  1403. // Convert light nodes that are not part of a light
  1404. // animation set to common entity nodes
  1405. if (version <= 1 && animNodeType == AnimNodeType::Light && !(flags & IAnimSequence::eSeqFlags_LightAnimationSet))
  1406. {
  1407. animNodeType = AnimNodeType::Entity;
  1408. return;
  1409. }
  1410. if (version <= 2)
  1411. {
  1412. int type;
  1413. if (xmlNode->getAttr(kType, type))
  1414. {
  1415. animNodeType = (AnimNodeType)type;
  1416. }
  1417. return;
  1418. }
  1419. else
  1420. {
  1421. XmlString nodeTypeString;
  1422. if (xmlNode->getAttr(kType, nodeTypeString))
  1423. {
  1424. assert(m_animNodeStringToEnumMap.find(nodeTypeString.c_str()) != m_animNodeStringToEnumMap.end());
  1425. animNodeType = stl::find_in_map(m_animNodeStringToEnumMap, nodeTypeString.c_str(), AnimNodeType::Invalid);
  1426. }
  1427. }
  1428. }
  1429. else
  1430. {
  1431. const char* pTypeString = "Invalid";
  1432. assert(m_animNodeEnumToStringMap.find(animNodeType) != m_animNodeEnumToStringMap.end());
  1433. pTypeString = m_animNodeEnumToStringMap[animNodeType].c_str();
  1434. xmlNode->setAttr(kType, pTypeString);
  1435. }
  1436. }
  1437. namespace CAnimParamTypeXmlNames
  1438. {
  1439. static const char* kParamUserValue = "paramUserValue";
  1440. static const char* kVirtualPropertyName = "virtualPropertyName";
  1441. }
  1442. //////////////////////////////////////////////////////////////////////////
  1443. void CMovieSystem::LoadParamTypeFromXml(CAnimParamType& animParamType, const XmlNodeRef& xmlNode, const uint version)
  1444. {
  1445. static const char* kByNameAttrName = "paramIdIsName";
  1446. animParamType.m_type = AnimParamType::Invalid;
  1447. if (version <= 6)
  1448. {
  1449. static const char* kParamId = "paramId";
  1450. if (xmlNode->haveAttr(kByNameAttrName))
  1451. {
  1452. XmlString name;
  1453. if (xmlNode->getAttr(kParamId, name))
  1454. {
  1455. animParamType.m_type = AnimParamType::ByString;
  1456. animParamType.m_name = name.c_str();
  1457. }
  1458. }
  1459. else
  1460. {
  1461. int type;
  1462. xmlNode->getAttr(kParamId, type);
  1463. animParamType.m_type = (AnimParamType)type;
  1464. }
  1465. }
  1466. else
  1467. {
  1468. static const char* kParamType = "paramType";
  1469. XmlString paramTypeString;
  1470. if (xmlNode->getAttr(kParamType, paramTypeString))
  1471. {
  1472. if (paramTypeString == "ByString")
  1473. {
  1474. animParamType.m_type = AnimParamType::ByString;
  1475. XmlString userValue;
  1476. xmlNode->getAttr(CAnimParamTypeXmlNames::kParamUserValue, userValue);
  1477. animParamType.m_name = userValue;
  1478. }
  1479. else if (paramTypeString == "User")
  1480. {
  1481. animParamType.m_type = AnimParamType::User;
  1482. int type;
  1483. xmlNode->getAttr(CAnimParamTypeXmlNames::kParamUserValue, type);
  1484. animParamType.m_type = (AnimParamType)type;
  1485. }
  1486. else
  1487. {
  1488. XmlString virtualPropertyValue;
  1489. if (xmlNode->getAttr(CAnimParamTypeXmlNames::kVirtualPropertyName, virtualPropertyValue))
  1490. {
  1491. animParamType.m_name = virtualPropertyValue;
  1492. }
  1493. assert(m_animParamStringToEnumMap.find(paramTypeString.c_str()) != m_animParamStringToEnumMap.end());
  1494. animParamType.m_type = stl::find_in_map(m_animParamStringToEnumMap, paramTypeString.c_str(), AnimParamType::Invalid);
  1495. }
  1496. }
  1497. }
  1498. }
  1499. //////////////////////////////////////////////////////////////////////////
  1500. void CMovieSystem::SaveParamTypeToXml(const CAnimParamType& animParamType, XmlNodeRef& xmlNode)
  1501. {
  1502. static const char* kParamType = "paramType";
  1503. const char* pTypeString = "Invalid";
  1504. if (animParamType.m_type == AnimParamType::ByString)
  1505. {
  1506. pTypeString = "ByString";
  1507. xmlNode->setAttr(CAnimParamTypeXmlNames::kParamUserValue, animParamType.m_name.c_str());
  1508. }
  1509. else if (animParamType.m_type >= AnimParamType::User)
  1510. {
  1511. pTypeString = "User";
  1512. xmlNode->setAttr(CAnimParamTypeXmlNames::kParamUserValue, (int)animParamType.m_type);
  1513. }
  1514. else
  1515. {
  1516. if (!animParamType.m_name.empty())
  1517. {
  1518. // we have a named parameter that is NOT an AnimParamType::ByString (handled above). This is used for VirtualProperty names for Component Entities.
  1519. xmlNode->setAttr(CAnimParamTypeXmlNames::kVirtualPropertyName, animParamType.m_name.c_str());
  1520. }
  1521. assert(m_animParamEnumToStringMap.find(animParamType.m_type) != m_animParamEnumToStringMap.end());
  1522. pTypeString = m_animParamEnumToStringMap[animParamType.m_type].c_str();
  1523. }
  1524. xmlNode->setAttr(kParamType, pTypeString);
  1525. }
  1526. //////////////////////////////////////////////////////////////////////////
  1527. void CMovieSystem::SerializeParamType(CAnimParamType& animParamType, XmlNodeRef& xmlNode, bool bLoading, const uint version)
  1528. {
  1529. if (bLoading)
  1530. {
  1531. LoadParamTypeFromXml(animParamType, xmlNode, version);
  1532. }
  1533. else
  1534. {
  1535. SaveParamTypeToXml(animParamType, xmlNode);
  1536. }
  1537. }
  1538. //////////////////////////////////////////////////////////////////////////
  1539. const char* CMovieSystem::GetParamTypeName(const CAnimParamType& animParamType)
  1540. {
  1541. if (animParamType.m_type == AnimParamType::ByString)
  1542. {
  1543. return animParamType.GetName();
  1544. }
  1545. else if (animParamType.m_type >= AnimParamType::User)
  1546. {
  1547. return "User";
  1548. }
  1549. else
  1550. {
  1551. if (m_animParamEnumToStringMap.contains(animParamType.m_type))
  1552. {
  1553. return m_animParamEnumToStringMap[animParamType.m_type].c_str();
  1554. }
  1555. }
  1556. return "Invalid";
  1557. }
  1558. //////////////////////////////////////////////////////////////////////////
  1559. void CMovieSystem::OnCameraCut()
  1560. {
  1561. }
  1562. void CMovieSystem::LogUserNotificationMsg([[maybe_unused]] const AZStd::string& msg)
  1563. {
  1564. #if !defined(_RELEASE)
  1565. if (!m_notificationLogMsgs.empty())
  1566. {
  1567. m_notificationLogMsgs.append("\n");
  1568. }
  1569. m_notificationLogMsgs.append(msg);
  1570. #endif
  1571. AZ_Warning("TrackView", false, "%s", msg.c_str());
  1572. }
  1573. void CMovieSystem::ClearUserNotificationMsgs()
  1574. {
  1575. #if !defined(_RELEASE)
  1576. m_notificationLogMsgs.clear();
  1577. #endif
  1578. }
  1579. const AZStd::string& CMovieSystem::GetUserNotificationMsgs() const
  1580. {
  1581. #if !defined(_RELEASE)
  1582. return m_notificationLogMsgs;
  1583. #else
  1584. static AZStd::string emptyMsg;
  1585. return emptyMsg;
  1586. #endif
  1587. }
  1588. //////////////////////////////////////////////////////////////////////////
  1589. void CMovieSystem::OnSequenceActivated(IAnimSequence* sequence)
  1590. {
  1591. // Queue for processing, sequences will be removed after checked for auto start.
  1592. m_newlyActivatedSequences.push_back(sequence);
  1593. }
  1594. #ifdef MOVIESYSTEM_SUPPORT_EDITING
  1595. //////////////////////////////////////////////////////////////////////////
  1596. AnimNodeType CMovieSystem::GetNodeTypeFromString(const char* pString) const
  1597. {
  1598. return stl::find_in_map(m_animNodeStringToEnumMap, pString, AnimNodeType::Invalid);
  1599. }
  1600. //////////////////////////////////////////////////////////////////////////
  1601. CAnimParamType CMovieSystem::GetParamTypeFromString(const char* pString) const
  1602. {
  1603. const AnimParamType paramType = stl::find_in_map(m_animParamStringToEnumMap, pString, AnimParamType::Invalid);
  1604. if (paramType != AnimParamType::Invalid)
  1605. {
  1606. return CAnimParamType(paramType);
  1607. }
  1608. return CAnimParamType(pString);
  1609. }
  1610. #endif