3
0

AnimAudioComponent.cpp 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603
  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/PlatformDef.h>
  9. #include <AzCore/Component/TransformBus.h>
  10. #include <AzCore/RTTI/BehaviorContext.h>
  11. #include <AzCore/Serialization/SerializeContext.h>
  12. #include <AzCore/Serialization/EditContext.h>
  13. #include <Integration/Components/AnimAudioComponent.h>
  14. #include <LmbrCentral/Audio/AudioProxyComponentBus.h>
  15. #include <LmbrCentral/Animation/SkeletalHierarchyRequestBus.h>
  16. #include <MathConversion.h>
  17. namespace EMotionFX
  18. {
  19. namespace Integration
  20. {
  21. void AudioTriggerEvent::Reflect(AZ::ReflectContext* context)
  22. {
  23. if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
  24. {
  25. serializeContext->Class<AudioTriggerEvent>()
  26. ->Version(0)
  27. ->Field("event", &AudioTriggerEvent::m_eventName)
  28. ->Field("trigger", &AudioTriggerEvent::m_triggerName)
  29. ->Field("joint", &AudioTriggerEvent::m_jointName);
  30. }
  31. }
  32. void AnimAudioComponent::AddTriggerEvent(const AZStd::string& eventName, const AZStd::string& triggerName, const AZStd::string& jointName)
  33. {
  34. AZ::Entity* entity = GetEntity();
  35. AZ_Assert(entity, "Component must be added to entity prior to adding an audio trigger event.");
  36. if (entity->GetState() == AZ::Entity::State::Active)
  37. {
  38. AddTriggerEventInternal(eventName, triggerName, jointName);
  39. }
  40. else
  41. {
  42. m_eventsToAdd.emplace_back(eventName, triggerName, jointName);
  43. }
  44. }
  45. void AnimAudioComponent::ClearTriggerEvents()
  46. {
  47. m_eventsToAdd.clear();
  48. m_eventsToRemove.clear();
  49. m_eventTriggerMap.clear();
  50. }
  51. void AnimAudioComponent::RemoveTriggerEvent(const AZStd::string& eventName)
  52. {
  53. const AZ::Crc32 eventCrc(eventName.c_str());
  54. const AZ::Entity* entity = GetEntity();
  55. AZ_Assert(entity, "Component must be added to entity prior to removing an audio trigger event.");
  56. if (entity->GetState() == AZ::Entity::State::Active)
  57. {
  58. RemoveTriggerEventInternal(eventCrc);
  59. }
  60. else
  61. {
  62. m_eventsToRemove.push_back(eventCrc);
  63. }
  64. }
  65. bool AnimAudioComponent::ExecuteSourceTrigger(
  66. const Audio::TAudioControlID triggerID,
  67. const Audio::TAudioControlID& sourceID,
  68. const AZStd::string& jointName)
  69. {
  70. if (triggerID == INVALID_AUDIO_CONTROL_ID)
  71. {
  72. return false;
  73. }
  74. bool success = false;
  75. AZ::s32 jointId = -1;
  76. LmbrCentral::SkeletalHierarchyRequestBus::EventResult(jointId, GetEntityId(),
  77. &LmbrCentral::SkeletalHierarchyRequestBus::Events::GetJointIndexByName, jointName.c_str());
  78. if (jointId < 0)
  79. {
  80. if (jointName.empty())
  81. {
  82. AZ_Warning("Editor", false, "'ExecuteSourceTrigger' called on default entity proxy. If this was the intent, a more explicit practice would be requesting this via the AudioProxyComponentBus.");
  83. LmbrCentral::AudioProxyComponentRequestBus::EventResult(success, GetEntityId(), &LmbrCentral::AudioProxyComponentRequests::ExecuteSourceTrigger, triggerID, sourceID);
  84. }
  85. else
  86. {
  87. AZ_Warning("Editor", false, "Joint not found. 'ExecuteSourceTrigger' call not performed on joint '%s'", jointName.c_str());
  88. }
  89. return success;
  90. }
  91. for (auto const& iter : m_jointProxies)
  92. {
  93. if (iter.first == jointId)
  94. {
  95. if (Audio::IAudioProxy* proxy = iter.second)
  96. {
  97. proxy->ExecuteSourceTrigger(triggerID, sourceID);
  98. success = true;
  99. }
  100. }
  101. }
  102. return success;
  103. }
  104. bool AnimAudioComponent::ExecuteTrigger(
  105. const Audio::TAudioControlID triggerID,
  106. const AZStd::string& jointName)
  107. {
  108. if (triggerID == INVALID_AUDIO_CONTROL_ID)
  109. {
  110. return false;
  111. }
  112. bool success = false;
  113. AZ::s32 jointId = -1;
  114. LmbrCentral::SkeletalHierarchyRequestBus::EventResult(jointId, GetEntityId(),
  115. &LmbrCentral::SkeletalHierarchyRequestBus::Events::GetJointIndexByName, jointName.c_str());
  116. if (jointId < 0)
  117. {
  118. if (jointName.empty())
  119. {
  120. AZ_Warning("Editor", false, "'ExecuteTrigger' called on default entity proxy. If this was the intent, a more explicit practice would be requesting this via the AudioProxyComponentBus.");
  121. LmbrCentral::AudioProxyComponentRequestBus::EventResult(success, GetEntityId(), &LmbrCentral::AudioProxyComponentRequests::ExecuteTrigger, triggerID);
  122. }
  123. else
  124. {
  125. AZ_Warning("Editor", false, "Joint not found. 'ExecuteTrigger' call not performed on joint '%s'", jointName.c_str());
  126. }
  127. return success;
  128. }
  129. for (auto const& iter : m_jointProxies)
  130. {
  131. if (iter.first == jointId)
  132. {
  133. if (Audio::IAudioProxy* proxy = iter.second)
  134. {
  135. proxy->ExecuteTrigger(triggerID);
  136. success = true;
  137. }
  138. }
  139. }
  140. return success;
  141. }
  142. void AnimAudioComponent::KillTrigger(const Audio::TAudioControlID triggerId, const AZStd::string* jointName)
  143. {
  144. AZ::s32 jointId = -1;
  145. if (jointName)
  146. {
  147. LmbrCentral::SkeletalHierarchyRequestBus::EventResult(jointId, GetEntityId(),
  148. &LmbrCentral::SkeletalHierarchyRequestBus::Events::GetJointIndexByName, jointName->c_str());
  149. if (jointId < 0)
  150. {
  151. if (jointName->empty())
  152. {
  153. AZ_Warning("Editor", false, "'KillTrigger' called on default entity proxy. If this was the intent, a more explicit practice would be requesting this via the AudioProxyComponentBus.");
  154. LmbrCentral::AudioProxyComponentRequestBus::Event(GetEntityId(), &LmbrCentral::AudioProxyComponentRequests::KillTrigger, triggerId);
  155. }
  156. else
  157. {
  158. AZ_Warning("Editor", false, "Joint not found. 'KillTrigger' call not performed on joint '%s'", jointName->c_str());
  159. }
  160. return;
  161. }
  162. }
  163. for (auto const& iter : m_jointProxies)
  164. {
  165. if (!jointName || iter.first == jointId)
  166. {
  167. if (Audio::IAudioProxy* proxy = iter.second)
  168. {
  169. proxy->StopTrigger(triggerId);
  170. }
  171. }
  172. }
  173. }
  174. void AnimAudioComponent::KillAllTriggers(const AZStd::string* jointName)
  175. {
  176. AZ::s32 jointId = -1;
  177. if (jointName)
  178. {
  179. LmbrCentral::SkeletalHierarchyRequestBus::EventResult(jointId, GetEntityId(),
  180. &LmbrCentral::SkeletalHierarchyRequestBus::Events::GetJointIndexByName, jointName->c_str());
  181. if (jointId < 0)
  182. {
  183. if (jointName->empty())
  184. {
  185. AZ_Warning("Editor", false, "'KillAllTrigger' called on default entity proxy. If this was the intent, a more explicit practice would be requesting this via the AudioProxyComponentBus.");
  186. LmbrCentral::AudioProxyComponentRequestBus::Event(GetEntityId(), &LmbrCentral::AudioProxyComponentRequests::KillAllTriggers);
  187. }
  188. else
  189. {
  190. AZ_Warning("Editor", false, "Joint not found. 'KillAllTrigger' call not performed on joint '%s'", jointName->c_str());
  191. }
  192. return;
  193. }
  194. }
  195. for (auto const& iter : m_jointProxies)
  196. {
  197. if (!jointName || iter.first == jointId)
  198. {
  199. if (Audio::IAudioProxy* proxy = iter.second)
  200. {
  201. proxy->StopAllTriggers();
  202. }
  203. }
  204. }
  205. }
  206. void AnimAudioComponent::SetRtpcValue(const Audio::TAudioControlID rtpcID, float value, const AZStd::string* jointName)
  207. {
  208. AZ::s32 jointId = -1;
  209. if (jointName)
  210. {
  211. LmbrCentral::SkeletalHierarchyRequestBus::EventResult(jointId, GetEntityId(),
  212. &LmbrCentral::SkeletalHierarchyRequestBus::Events::GetJointIndexByName, jointName->c_str());
  213. if (jointId < 0)
  214. {
  215. if (jointName->empty())
  216. {
  217. AZ_Warning("Editor", false, "'SetRtpcValue' called on default entity proxy. If this was the intent, a more explicit practice would be requesting this via the AudioProxyComponentBus.");
  218. LmbrCentral::AudioProxyComponentRequestBus::Event(GetEntityId(), &LmbrCentral::AudioProxyComponentRequests::SetRtpcValue, rtpcID, value);
  219. }
  220. else
  221. {
  222. AZ_Warning("Editor", false, "Joint not found. 'SetRtpcValue' call not performed on joint '%s'", jointName->c_str());
  223. }
  224. return;
  225. }
  226. }
  227. for (auto const& iter : m_jointProxies)
  228. {
  229. if (!jointName || iter.first == jointId)
  230. {
  231. if (Audio::IAudioProxy* proxy = iter.second)
  232. {
  233. proxy->SetRtpcValue(rtpcID, value);
  234. }
  235. }
  236. }
  237. }
  238. void AnimAudioComponent::SetSwitchState(const Audio::TAudioControlID switchID, const Audio::TAudioSwitchStateID stateID, const AZStd::string* jointName)
  239. {
  240. AZ::s32 jointId = -1;
  241. if (jointName)
  242. {
  243. LmbrCentral::SkeletalHierarchyRequestBus::EventResult(jointId, GetEntityId(),
  244. &LmbrCentral::SkeletalHierarchyRequestBus::Events::GetJointIndexByName, jointName->c_str());
  245. if (jointId < 0)
  246. {
  247. if (jointName->empty())
  248. {
  249. AZ_Warning("Editor", false, "'SetSwitchState' called on default entity proxy. If this was the intent, a more explicit practice would be requesting this via the AudioProxyComponentBus.");
  250. LmbrCentral::AudioProxyComponentRequestBus::Event(GetEntityId(), &LmbrCentral::AudioProxyComponentRequests::SetSwitchState, switchID, stateID);
  251. }
  252. else
  253. {
  254. AZ_Warning("Editor", false, "Joint not found. 'SetSwitchState' call not performed on joint '%s'", jointName->c_str());
  255. }
  256. return;
  257. }
  258. }
  259. for (auto const& iter : m_jointProxies)
  260. {
  261. if (!jointName || iter.first == jointId)
  262. {
  263. if (Audio::IAudioProxy* proxy = iter.second)
  264. {
  265. proxy->SetSwitchState(switchID, stateID);
  266. }
  267. }
  268. }
  269. }
  270. void AnimAudioComponent::SetEnvironmentAmount(const Audio::TAudioEnvironmentID environmentID, float amount, const AZStd::string* jointName)
  271. {
  272. AZ::s32 jointId = -1;
  273. if (jointName)
  274. {
  275. LmbrCentral::SkeletalHierarchyRequestBus::EventResult(jointId, GetEntityId(),
  276. &LmbrCentral::SkeletalHierarchyRequestBus::Events::GetJointIndexByName, jointName->c_str());
  277. if (jointId < 0)
  278. {
  279. if (jointName->empty())
  280. {
  281. AZ_Warning("Editor", false, "'SetEnvironmentAmount' called on default entity proxy. If this was the intent, a more explicit practice would be requesting this via the AudioProxyComponentBus.");
  282. LmbrCentral::AudioProxyComponentRequestBus::Event(GetEntityId(), &LmbrCentral::AudioProxyComponentRequests::SetEnvironmentAmount, environmentID, amount);
  283. }
  284. else
  285. {
  286. AZ_Warning("Editor", false, "Joint not found. 'SetEnvironmentAmount' call not performed on joint '%s'", jointName->c_str());
  287. }
  288. return;
  289. }
  290. }
  291. for (auto const& iter : m_jointProxies)
  292. {
  293. if (!jointName || iter.first == jointId)
  294. {
  295. if (Audio::IAudioProxy* proxy = iter.second)
  296. {
  297. proxy->SetEnvironmentAmount(environmentID, amount);
  298. }
  299. }
  300. }
  301. }
  302. void AnimAudioComponent::ReportTriggerStarted([[maybe_unused]] Audio::TAudioControlID triggerId)
  303. {
  304. if (!m_activeVoices)
  305. {
  306. AZ::TickBus::Handler::BusConnect();
  307. AZ::TransformNotificationBus::Handler::BusConnect(GetEntityId());
  308. }
  309. ++m_activeVoices;
  310. }
  311. void AnimAudioComponent::ReportTriggerFinished([[maybe_unused]] Audio::TAudioControlID triggerId)
  312. {
  313. --m_activeVoices;
  314. if (!m_activeVoices)
  315. {
  316. AZ::TickBus::Handler::BusDisconnect();
  317. AZ::TransformNotificationBus::Handler::BusDisconnect(GetEntityId());
  318. }
  319. }
  320. void AnimAudioComponent::Init()
  321. {
  322. }
  323. void AnimAudioComponent::Activate()
  324. {
  325. AZStd::for_each(m_eventsToAdd.begin(), m_eventsToAdd.end(), [this](const auto& triggerEvent)
  326. {
  327. AddTriggerEventInternal(triggerEvent.m_eventName, triggerEvent.m_triggerName, triggerEvent.m_jointName);
  328. });
  329. m_eventsToAdd.clear();
  330. AZStd::for_each(m_eventsToRemove.begin(), m_eventsToRemove.end(), [this](const auto& eventCrc)
  331. {
  332. RemoveTriggerEventInternal(eventCrc);
  333. });
  334. m_eventsToRemove.clear();
  335. ActivateJointProxies();
  336. ActorNotificationBus::Handler::BusConnect(GetEntityId());
  337. Audio::AudioTriggerNotificationBus::Handler::BusConnect(Audio::TriggerNotificationIdType{ GetEntityId() });
  338. AnimAudioComponentRequestBus::Handler::BusConnect(GetEntityId());
  339. }
  340. void AnimAudioComponent::Deactivate()
  341. {
  342. AZ::TickBus::Handler::BusDisconnect();
  343. AZ::TransformNotificationBus::Handler::BusDisconnect(GetEntityId());
  344. m_activeVoices = 0;
  345. DeactivateJointProxies();
  346. ActorNotificationBus::Handler::BusDisconnect(GetEntityId());
  347. Audio::AudioTriggerNotificationBus::Handler::BusDisconnect(Audio::TriggerNotificationIdType{ GetEntityId() });
  348. AnimAudioComponentRequestBus::Handler::BusDisconnect(GetEntityId());
  349. }
  350. void AnimAudioComponent::OnTick(float deltaTime, AZ::ScriptTimePoint time)
  351. {
  352. AZ_UNUSED(deltaTime);
  353. AZ_UNUSED(time);
  354. for (auto& iter : m_jointProxies)
  355. {
  356. if (Audio::IAudioProxy* proxy = iter.second)
  357. {
  358. AZ::Transform jointTransform = AZ::Transform::CreateIdentity();
  359. auto getJointTransform = &LmbrCentral::SkeletalHierarchyRequestBus::Events::GetJointTransformCharacterRelative;
  360. LmbrCentral::SkeletalHierarchyRequestBus::EventResult(jointTransform, GetEntityId(), getJointTransform, iter.first);
  361. Audio::SATLWorldPosition atlTransform(m_transform * jointTransform);
  362. proxy->SetPosition(m_transform * jointTransform);
  363. }
  364. }
  365. }
  366. void AnimAudioComponent::OnTransformChanged(const AZ::Transform& local, const AZ::Transform& world)
  367. {
  368. AZ_UNUSED(local);
  369. m_transform = world;
  370. }
  371. void AnimAudioComponent::OnMotionEvent(EMotionFX::Integration::MotionEvent motionEvent)
  372. {
  373. // 1. Check if event is registered
  374. auto eventIter = m_eventTriggerMap.find(AZ::Crc32(motionEvent.m_eventTypeName));
  375. if (!motionEvent.m_isEventStart || eventIter == m_eventTriggerMap.end())
  376. {
  377. return;
  378. }
  379. // 2. If registered but jointId is unset, play on ProxyComponent's proxy
  380. const AZ::s32 jointId = eventIter->second.GetJointId();
  381. if (jointId < 0)
  382. {
  383. LmbrCentral::AudioProxyComponentRequestBus::Event(GetEntityId(), &LmbrCentral::AudioProxyComponentRequests::ExecuteTrigger,
  384. eventIter->second.GetTriggerId());
  385. return;
  386. }
  387. // 3. If no joint is registered with the component, then don't play anything
  388. // (If joints can be removed, then this would occur when event mapping and
  389. // event call still exist)
  390. auto jointIter = m_jointProxies.find(jointId);
  391. if (jointIter == m_jointProxies.end())
  392. {
  393. return;
  394. }
  395. // 4. If we have a joint proxy, update its position and play request.
  396. if (Audio::IAudioProxy* proxy = jointIter->second)
  397. {
  398. const Audio::TAudioControlID triggerId = eventIter->second.GetTriggerId();
  399. AZ::Transform jointTransform = AZ::Transform::CreateIdentity();
  400. const auto getJointTransform = &LmbrCentral::SkeletalHierarchyRequestBus::Events::GetJointTransformCharacterRelative;
  401. LmbrCentral::SkeletalHierarchyRequestBus::EventResult(jointTransform, GetEntityId(), getJointTransform, jointId);
  402. const Audio::SATLWorldPosition atlTransform(m_transform * jointTransform);
  403. proxy->SetPosition(atlTransform);
  404. proxy->ExecuteTrigger(triggerId);
  405. }
  406. }
  407. void AnimAudioComponent::Reflect(AZ::ReflectContext* context)
  408. {
  409. AudioTriggerEvent::Reflect(context);
  410. if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
  411. {
  412. serializeContext->Class<AnimAudioComponent, AZ::Component>()
  413. ->Version(0)
  414. ->Field("AudioTriggerEvents", &AnimAudioComponent::m_eventsToAdd);
  415. }
  416. if (auto behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
  417. {
  418. behaviorContext->EBus<EMotionFX::Integration::AnimAudioComponentRequestBus>("AnimAudioComponentRequestBus")
  419. ->Attribute(AZ::Script::Attributes::Category, "Animation")
  420. ->Event("AddTriggerEvent", &AnimAudioComponentRequestBus::Events::AddTriggerEvent)
  421. ->Event("ClearTriggerEvents", &AnimAudioComponentRequestBus::Events::ClearTriggerEvents)
  422. ->Event("RemoveTriggerEvent", &AnimAudioComponentRequestBus::Events::RemoveTriggerEvent);
  423. }
  424. }
  425. void AnimAudioComponent::AddTriggerEventInternal(const AZStd::string& eventName, const AZStd::string& triggerName, const AZStd::string& jointName)
  426. {
  427. Audio::TAudioControlID triggerId = INVALID_AUDIO_CONTROL_ID;
  428. if (auto audioSystem = AZ::Interface<Audio::IAudioSystem>::Get();
  429. audioSystem != nullptr)
  430. {
  431. triggerId = audioSystem->GetAudioTriggerID(triggerName.c_str());
  432. }
  433. if (triggerId == INVALID_AUDIO_CONTROL_ID)
  434. {
  435. AZ_Warning("Editor", false, "Audio trigger '%s' not found. Trigger not registered for motion event '%s'",
  436. triggerName.c_str(), eventName.c_str());
  437. }
  438. else
  439. {
  440. AZ::s32 jointId = -1;
  441. if (!jointName.empty())
  442. {
  443. LmbrCentral::SkeletalHierarchyRequestBus::EventResult(jointId, GetEntityId(),
  444. &LmbrCentral::SkeletalHierarchyRequestBus::Events::GetJointIndexByName, jointName.c_str());
  445. if (jointId < 0)
  446. {
  447. AZ_Warning("Editor", false, "Joint name '%s' not found: anim event '%s' audio trigger '%s' will be played on default proxy",
  448. jointName.c_str(),
  449. eventName.c_str(),
  450. triggerName.c_str());
  451. }
  452. }
  453. const AZ::Crc32 eventCrc(eventName.c_str());
  454. RemoveTriggerEventInternal(eventCrc);
  455. auto entity = GetEntity();
  456. AZ_Assert(entity, "AnimAudioComponent must be attached to entity prior to adding a trigger event");
  457. m_eventTriggerMap.emplace(eventCrc, TriggerEventData(*entity, triggerId, jointId));
  458. }
  459. }
  460. void AnimAudioComponent::RemoveTriggerEventInternal(const AZ::Crc32& eventCrc)
  461. {
  462. const auto iter = m_eventTriggerMap.find(eventCrc);
  463. if (iter != m_eventTriggerMap.end())
  464. {
  465. m_eventTriggerMap.erase(iter);
  466. }
  467. }
  468. void AnimAudioComponent::ActivateJointProxies()
  469. {
  470. const AZ::Entity* entity = GetEntity();
  471. AZ_Assert(entity, "Parent entity not found");
  472. const AZStd::string& name = entity->GetName();
  473. for (auto& eventIter : m_eventTriggerMap)
  474. {
  475. const AZ::s32 jointId = eventIter.second.GetJointId();
  476. if (jointId >= 0)
  477. {
  478. auto jointIter = m_jointProxies.find(eventIter.second.GetJointId());
  479. if (jointIter == m_jointProxies.end())
  480. {
  481. Audio::IAudioProxy* proxy = nullptr;
  482. if (auto audioSystem = AZ::Interface<Audio::IAudioSystem>::Get();
  483. audioSystem != nullptr)
  484. {
  485. proxy = audioSystem->GetAudioProxy();
  486. AZ_Assert(proxy, "Failed to get free audio proxy");
  487. AZStd::string proxyName = AZStd::string::format("%s:%d", name.c_str(), jointId);
  488. proxy->Initialize(proxyName.c_str(),
  489. reinterpret_cast<void*>(static_cast<uintptr_t>(static_cast<AZ::u64>(GetEntityId()))));
  490. proxy->SetObstructionCalcType(Audio::ObstructionType::Ignore);
  491. m_jointProxies.emplace(jointId, proxy);
  492. }
  493. }
  494. }
  495. }
  496. }
  497. void AnimAudioComponent::DeactivateJointProxies()
  498. {
  499. for (auto& iter : m_jointProxies)
  500. {
  501. if (Audio::IAudioProxy* proxy = iter.second)
  502. {
  503. proxy->StopAllTriggers();
  504. proxy->Release();
  505. }
  506. }
  507. m_jointProxies.clear();
  508. }
  509. AnimAudioComponent::TriggerEventData::TriggerEventData(const AZ::Entity& entity, Audio::TAudioControlID triggerId, AZ::s32 jointId)
  510. : m_jointId(jointId)
  511. , m_triggerId(triggerId)
  512. {
  513. AZ_UNUSED(entity);
  514. }
  515. AZ::s32 AnimAudioComponent::TriggerEventData::GetJointId() const
  516. {
  517. return m_jointId;
  518. }
  519. Audio::TAudioControlID AnimAudioComponent::TriggerEventData::GetTriggerId() const
  520. {
  521. return m_triggerId;
  522. }
  523. } // namespace Integration
  524. } // namespace EMotionFX