AkRoomComponent.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627
  1. /*******************************************************************************
  2. The content of this file includes portions of the proprietary AUDIOKINETIC Wwise
  3. Technology released in source code form as part of the game integration package.
  4. The content of this file may not be used without valid licenses to the
  5. AUDIOKINETIC Wwise Technology.
  6. Note that the use of the game engine is subject to the Unreal(R) Engine End User
  7. License Agreement at https://www.unrealengine.com/en-US/eula/unreal
  8. License Usage
  9. Licensees holding valid licenses to the AUDIOKINETIC Wwise Technology may use
  10. this file in accordance with the end user license agreement provided with the
  11. software or, alternatively, in accordance with the terms contained
  12. in a written agreement between you and Audiokinetic Inc.
  13. Copyright (c) 2023 Audiokinetic Inc.
  14. *******************************************************************************/
  15. /*=============================================================================
  16. AkRoomComponent.cpp:
  17. =============================================================================*/
  18. #include "AkRoomComponent.h"
  19. #include "AkComponentHelpers.h"
  20. #include "AkAcousticPortal.h"
  21. #include "AkAudioDevice.h"
  22. #include "AkGeometryComponent.h"
  23. #include "AkLateReverbComponent.h"
  24. #include "AkSurfaceReflectorSetComponent.h"
  25. #include "Components/BrushComponent.h"
  26. #include "GameFramework/Volume.h"
  27. #include "Model.h"
  28. #include "EngineUtils.h"
  29. #include "AkAudioEvent.h"
  30. #include "AkSettings.h"
  31. #include "Wwise/API/WwiseSpatialAudioAPI.h"
  32. #if WITH_EDITOR
  33. #include "AkDrawRoomComponent.h"
  34. #include "AkSpatialAudioHelper.h"
  35. #endif
  36. #define MOVEMENT_STOP_TIMEOUT 0.1f
  37. /*------------------------------------------------------------------------------------
  38. UAkRoomComponent
  39. ------------------------------------------------------------------------------------*/
  40. UAkRoomComponent::UAkRoomComponent(const class FObjectInitializer& ObjectInitializer) :
  41. Super(ObjectInitializer)
  42. {
  43. Parent = NULL;
  44. WallOcclusion = 1.0f;
  45. bEnable = true;
  46. bUseAttachParentBound = true;
  47. AutoPost = false;
  48. PrimaryComponentTick.bCanEverTick = true;
  49. PrimaryComponentTick.bStartWithTickEnabled = true;
  50. bTickInEditor = true;
  51. #if WITH_EDITOR
  52. if (AkSpatialAudioHelper::GetObjectReplacedEvent())
  53. {
  54. AkSpatialAudioHelper::GetObjectReplacedEvent()->AddUObject(this, &UAkRoomComponent::HandleObjectsReplaced);
  55. }
  56. bWantsOnUpdateTransform = true;
  57. bWantsInitializeComponent = true;
  58. #else
  59. bWantsOnUpdateTransform = bDynamic;
  60. #endif
  61. }
  62. FName UAkRoomComponent::GetName() const
  63. {
  64. return Parent->GetFName();
  65. }
  66. bool UAkRoomComponent::HasEffectOnLocation(const FVector& Location) const
  67. {
  68. // Need to add a small radius, because on the Mac, EncompassesPoint returns false if
  69. // Location is exactly equal to the Volume's location
  70. static float RADIUS = 0.01f;
  71. return RoomIsActive() && EncompassesPoint(Location, RADIUS);
  72. }
  73. bool UAkRoomComponent::RoomIsActive() const
  74. {
  75. return IsValid(Parent) && bEnable && !IsRunningCommandlet();
  76. }
  77. void UAkRoomComponent::OnRegister()
  78. {
  79. Super::OnRegister();
  80. SetRelativeTransform(FTransform::Identity);
  81. InitializeParent();
  82. // We want to add / update the room both in BeginPlay and OnRegister. BeginPlay for aux bus and reverb level assignment, OnRegister for portal room assignment and visualization
  83. if (!IsRegisteredWithWwise)
  84. AddSpatialAudioRoom();
  85. else
  86. UpdateSpatialAudioRoom();
  87. #if WITH_EDITOR
  88. if (GetDefault<UAkSettings>()->VisualizeRoomsAndPortals)
  89. {
  90. InitializeDrawComponent();
  91. }
  92. #endif
  93. }
  94. void UAkRoomComponent::OnUnregister()
  95. {
  96. Super::OnUnregister();
  97. RemoveSpatialAudioRoom();
  98. }
  99. #if WITH_EDITOR
  100. void UAkRoomComponent::OnComponentCreated()
  101. {
  102. Super::OnComponentCreated();
  103. RegisterVisEnabledCallback();
  104. }
  105. void UAkRoomComponent::InitializeComponent()
  106. {
  107. Super::InitializeComponent();
  108. RegisterVisEnabledCallback();
  109. }
  110. void UAkRoomComponent::PostLoad()
  111. {
  112. Super::PostLoad();
  113. RegisterVisEnabledCallback();
  114. }
  115. void UAkRoomComponent::OnComponentDestroyed(bool bDestroyingHierarchy)
  116. {
  117. UAkSettings* AkSettings = GetMutableDefault<UAkSettings>();
  118. AkSettings->OnShowRoomsPortalsChanged.Remove(ShowRoomsChangedHandle);
  119. ShowRoomsChangedHandle.Reset();
  120. DestroyDrawComponent();
  121. }
  122. #endif // WITH_EDITOR
  123. void UAkRoomComponent::TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction * ThisTickFunction)
  124. {
  125. #if WITH_EDITOR
  126. if (bRequiresDeferredBeginPlay)
  127. {
  128. BeginPlayInternal();
  129. bRequiresDeferredBeginPlay = false;
  130. }
  131. #endif
  132. // In PIE, only update in tick if bDynamic is true (simulate the behaviour in the no-editor game build).
  133. bool bUpdate = true;
  134. #if WITH_EDITOR
  135. if (AkComponentHelpers::IsInGameWorld(this))
  136. bUpdate = bDynamic;
  137. #endif
  138. if (bUpdate)
  139. {
  140. if (Moving)
  141. {
  142. SecondsSinceMovement += DeltaTime;
  143. if (SecondsSinceMovement >= MOVEMENT_STOP_TIMEOUT)
  144. {
  145. FAkAudioDevice* AkAudioDevice = FAkAudioDevice::Get();
  146. if (AkAudioDevice != nullptr)
  147. {
  148. AkAudioDevice->ReindexRoom(this);
  149. AkAudioDevice->PortalsNeedRoomUpdate(GetWorld());
  150. }
  151. Moving = false;
  152. }
  153. }
  154. if ((bEnable && !IsRegisteredWithWwise) || (!bEnable && IsRegisteredWithWwise))
  155. {
  156. FAkAudioDevice* AkAudioDevice = FAkAudioDevice::Get();
  157. if (AkAudioDevice != nullptr)
  158. {
  159. if (IsRegisteredWithWwise)
  160. RemoveSpatialAudioRoom();
  161. else
  162. AddSpatialAudioRoom();
  163. }
  164. }
  165. }
  166. }
  167. #if WITH_EDITOR
  168. void UAkRoomComponent::BeginDestroy()
  169. {
  170. Super::BeginDestroy();
  171. if (AkSpatialAudioHelper::GetObjectReplacedEvent())
  172. {
  173. AkSpatialAudioHelper::GetObjectReplacedEvent()->RemoveAll(this);
  174. }
  175. }
  176. void UAkRoomComponent::HandleObjectsReplaced(const TMap<UObject*, UObject*>& ReplacementMap)
  177. {
  178. if (ReplacementMap.Contains(Parent))
  179. {
  180. InitializeParent();
  181. if (!IsRegisteredWithWwise)
  182. AddSpatialAudioRoom();
  183. else
  184. UpdateSpatialAudioRoom();
  185. }
  186. if (ReplacementMap.Contains(GeometryComponent))
  187. {
  188. GeometryComponent = AkComponentHelpers::GetChildComponentOfType<UAkAcousticTextureSetComponent>(*Parent);
  189. if (GeometryComponent == nullptr || GeometryComponent->HasAnyFlags(RF_Transient) || GeometryComponent->IsBeingDestroyed())
  190. {
  191. GeometryComponent = NewObject<UAkGeometryComponent>(Parent, TEXT("GeometryComponent"));
  192. UAkGeometryComponent* GeomComp = Cast<UAkGeometryComponent>(GeometryComponent);
  193. GeomComp->MeshType = AkMeshType::CollisionMesh;
  194. GeomComp->bWasAddedByRoom = true;
  195. GeometryComponent->AttachToComponent(Parent, FAttachmentTransformRules::KeepRelativeTransform);
  196. GeometryComponent->RegisterComponent();
  197. if (!RoomIsActive())
  198. GeomComp->RemoveGeometry();
  199. }
  200. SendGeometry();
  201. UpdateSpatialAudioRoom();
  202. }
  203. }
  204. void UAkRoomComponent::RegisterVisEnabledCallback()
  205. {
  206. if (!ShowRoomsChangedHandle.IsValid())
  207. {
  208. UAkSettings* AkSettings = GetMutableDefault<UAkSettings>();
  209. ShowRoomsChangedHandle = AkSettings->OnShowRoomsPortalsChanged.AddLambda([this, AkSettings]()
  210. {
  211. if (AkSettings->VisualizeRoomsAndPortals)
  212. {
  213. InitializeDrawComponent();
  214. }
  215. else
  216. {
  217. DestroyDrawComponent();
  218. }
  219. });
  220. }
  221. }
  222. void UAkRoomComponent::InitializeDrawComponent()
  223. {
  224. if (AActor* Owner = GetOwner())
  225. {
  226. if (DrawRoomComponent == nullptr)
  227. {
  228. DrawRoomComponent = NewObject<UDrawRoomComponent>(Owner, NAME_None, RF_Transactional | RF_TextExportTransient);
  229. DrawRoomComponent->SetupAttachment(this);
  230. DrawRoomComponent->SetIsVisualizationComponent(true);
  231. DrawRoomComponent->CreationMethod = CreationMethod;
  232. DrawRoomComponent->RegisterComponentWithWorld(GetWorld());
  233. DrawRoomComponent->MarkRenderStateDirty();
  234. }
  235. }
  236. }
  237. void UAkRoomComponent::DestroyDrawComponent()
  238. {
  239. if (DrawRoomComponent != nullptr)
  240. {
  241. DrawRoomComponent->DestroyComponent();
  242. DrawRoomComponent = nullptr;
  243. }
  244. }
  245. #endif
  246. void UAkRoomComponent::OnUpdateTransform(EUpdateTransformFlags UpdateTransformFlags, ETeleportType Teleport)
  247. {
  248. Moving = true;
  249. SecondsSinceMovement = 0.0f;
  250. }
  251. bool UAkRoomComponent::MoveComponentImpl(
  252. const FVector & Delta,
  253. const FQuat & NewRotation,
  254. bool bSweep,
  255. FHitResult * Hit,
  256. EMoveComponentFlags MoveFlags,
  257. ETeleportType Teleport)
  258. {
  259. if (AkComponentHelpers::DoesMovementRecenterChild(this, Parent, Delta))
  260. Super::MoveComponentImpl(Delta, NewRotation, bSweep, Hit, MoveFlags, Teleport);
  261. return false;
  262. }
  263. void UAkRoomComponent::InitializeParent()
  264. {
  265. USceneComponent* SceneParent = GetAttachParent();
  266. if (SceneParent != nullptr)
  267. {
  268. Parent = Cast<UPrimitiveComponent>(SceneParent);
  269. if (!Parent)
  270. {
  271. bEnable = false;
  272. AkComponentHelpers::LogAttachmentError(this, SceneParent, "UPrimitiveComponent");
  273. return;
  274. }
  275. UBodySetup* bodySetup = Parent->GetBodySetup();
  276. if (bodySetup == nullptr || !AkComponentHelpers::HasSimpleCollisionGeometry(bodySetup))
  277. {
  278. if (UBrushComponent* brush = Cast<UBrushComponent>(Parent))
  279. brush->BuildSimpleBrushCollision();
  280. else
  281. AkComponentHelpers::LogSimpleGeometryWarning(Parent, this);
  282. }
  283. }
  284. }
  285. FString UAkRoomComponent::GetRoomName()
  286. {
  287. FString nameStr = UObject::GetName();
  288. AActor* roomOwner = GetOwner();
  289. if (roomOwner != nullptr)
  290. {
  291. #if WITH_EDITOR
  292. nameStr = roomOwner->GetActorLabel();
  293. #else
  294. nameStr = roomOwner->GetName();
  295. #endif
  296. if (Parent != nullptr)
  297. {
  298. TInlineComponentArray<UAkRoomComponent*> RoomComponents;
  299. roomOwner->GetComponents(RoomComponents);
  300. if (RoomComponents.Num() > 1)
  301. nameStr.Append(FString("_").Append(Parent->GetName()));
  302. }
  303. }
  304. return nameStr;
  305. }
  306. void UAkRoomComponent::GetRoomParams(AkRoomParams& outParams)
  307. {
  308. FAkAudioDevice* AkAudioDevice = FAkAudioDevice::Get();
  309. if (!AkAudioDevice)
  310. return;
  311. if (IsValid(Parent))
  312. {
  313. AkComponentHelpers::GetPrimitiveUpAndFront(*Parent, outParams.Up, outParams.Front);
  314. }
  315. outParams.TransmissionLoss = WallOcclusion;
  316. UAkLateReverbComponent* ReverbComp = GetReverbComponent();
  317. if (ReverbComp && ReverbComp->bEnable)
  318. {
  319. if (UNLIKELY(!ReverbComp->AuxBus && ReverbComp->AuxBusName.IsEmpty()))
  320. {
  321. outParams.ReverbAuxBus = AK_INVALID_AUX_ID;
  322. }
  323. else
  324. {
  325. outParams.ReverbAuxBus = ReverbComp->GetAuxBusId();
  326. }
  327. outParams.ReverbLevel = ReverbComp->SendLevel;
  328. }
  329. if (GeometryComponent != nullptr)
  330. outParams.GeometryInstanceID = GeometryComponent->GetGeometrySetID();
  331. outParams.RoomGameObj_AuxSendLevelToSelf = AuxSendLevel;
  332. outParams.RoomGameObj_KeepRegistered = AkAudioEvent == NULL && EventName.IsEmpty() ? false : true;
  333. const UAkSettings* AkSettings = GetDefault<UAkSettings>();
  334. if (AkSettings != nullptr && AkSettings->ReverbRTPCsInUse())
  335. outParams.RoomGameObj_KeepRegistered = true;
  336. }
  337. UPrimitiveComponent* UAkRoomComponent::GetPrimitiveParent() const
  338. {
  339. return Parent;
  340. }
  341. void UAkRoomComponent::AddSpatialAudioRoom()
  342. {
  343. if (RoomIsActive())
  344. {
  345. SendGeometry();
  346. FAkAudioDevice* AkAudioDevice = FAkAudioDevice::Get();
  347. IWwiseSpatialAudioAPI* SpatialAudio = IWwiseSpatialAudioAPI::Get();
  348. if (AkAudioDevice && SpatialAudio)
  349. {
  350. AkRoomParams Params;
  351. GetRoomParams(Params);
  352. AkAudioDevice->AddRoom(this, Params);
  353. IsRegisteredWithWwise = true;
  354. if (GetOwner() != nullptr && IsRegisteredWithWwise && (GetWorld()->WorldType == EWorldType::Game || GetWorld()->WorldType == EWorldType::PIE))
  355. {
  356. UAkLateReverbComponent* pRvbComp = GetReverbComponent();
  357. if (pRvbComp != nullptr)
  358. pRvbComp->UpdateRTPCs(this);
  359. }
  360. }
  361. }
  362. }
  363. void UAkRoomComponent::UpdateSpatialAudioRoom()
  364. {
  365. FAkAudioDevice* AkAudioDevice = FAkAudioDevice::Get();
  366. IWwiseSpatialAudioAPI* SpatialAudio = IWwiseSpatialAudioAPI::Get();
  367. if (RoomIsActive() && AkAudioDevice && SpatialAudio && IsRegisteredWithWwise)
  368. {
  369. AkRoomParams Params;
  370. GetRoomParams(Params);
  371. AkAudioDevice->UpdateRoom(this, Params);
  372. if (GetOwner() != nullptr && (GetWorld()->WorldType == EWorldType::Game || GetWorld()->WorldType == EWorldType::PIE))
  373. {
  374. UAkLateReverbComponent* pRvbComp = GetReverbComponent();
  375. if (pRvbComp != nullptr)
  376. pRvbComp->UpdateRTPCs(this);
  377. }
  378. }
  379. }
  380. void UAkRoomComponent::RemoveSpatialAudioRoom()
  381. {
  382. if (Parent && !IsRunningCommandlet())
  383. {
  384. RemoveGeometry();
  385. FAkAudioDevice* AkAudioDevice = FAkAudioDevice::Get();
  386. if (AkAudioDevice)
  387. {
  388. if (GetOwner() != nullptr && (GetWorld()->WorldType == EWorldType::Game || GetWorld()->WorldType == EWorldType::PIE))
  389. {
  390. // stop all sounds posted on the room
  391. Stop();
  392. }
  393. AkAudioDevice->RemoveRoom(this);
  394. IsRegisteredWithWwise = false;
  395. }
  396. }
  397. }
  398. int32 UAkRoomComponent::PostAssociatedAkEvent(int32 CallbackMask, const FOnAkPostEventCallback& PostEventCallback)
  399. {
  400. AkPlayingID playingID = AK_INVALID_PLAYING_ID;
  401. if (!HasActiveEvents())
  402. playingID = PostAkEvent(AkAudioEvent, CallbackMask, PostEventCallback, EventName);
  403. return playingID;
  404. }
  405. AkPlayingID UAkRoomComponent::PostAkEventByNameWithDelegate(
  406. UAkAudioEvent* AkEvent,
  407. const FString& in_EventName,
  408. int32 CallbackMask, const FOnAkPostEventCallback& PostEventCallback)
  409. {
  410. AkPlayingID PlayingID = AK_INVALID_PLAYING_ID;
  411. auto AudioDevice = FAkAudioDevice::Get();
  412. if (AudioDevice)
  413. {
  414. const AkUInt32 ShortID = AudioDevice->GetShortID(AkEvent, in_EventName);
  415. PlayingID = AudioDevice->PostEventOnAkGameObject(ShortID, this, PostEventCallback, CallbackMask);
  416. }
  417. return PlayingID;
  418. }
  419. void UAkRoomComponent::BeginPlay()
  420. {
  421. Super::BeginPlay();
  422. #if WITH_EDITOR
  423. // If we're PIE, or somehow otherwise in a game world in editor, simulate the bDynamic behaviour.
  424. if (AkComponentHelpers::IsInGameWorld(this))
  425. {
  426. bWantsOnUpdateTransform = bDynamic;
  427. }
  428. if (AkComponentHelpers::ShouldDeferBeginPlay(this))
  429. bRequiresDeferredBeginPlay = true;
  430. else
  431. BeginPlayInternal();
  432. #else
  433. BeginPlayInternal();
  434. PrimaryComponentTick.bCanEverTick = bDynamic;
  435. PrimaryComponentTick.bStartWithTickEnabled = bDynamic;
  436. #endif
  437. }
  438. void UAkRoomComponent::BeginPlayInternal()
  439. {
  440. GeometryComponent = AkComponentHelpers::GetChildComponentOfType<UAkAcousticTextureSetComponent>(*Parent);
  441. if (GeometryComponent == nullptr || GeometryComponent->HasAnyFlags(RF_Transient) || GeometryComponent->IsBeingDestroyed())
  442. {
  443. static const FName GeometryComponentName = TEXT("GeometryComponent");
  444. GeometryComponent = NewObject<UAkGeometryComponent>(Parent, GeometryComponentName);
  445. UAkGeometryComponent* geom = Cast<UAkGeometryComponent>(GeometryComponent);
  446. geom->MeshType = AkMeshType::CollisionMesh;
  447. geom->bWasAddedByRoom = true;
  448. GeometryComponent->AttachToComponent(Parent, FAttachmentTransformRules::KeepRelativeTransform);
  449. GeometryComponent->RegisterComponent();
  450. if (!RoomIsActive())
  451. geom->RemoveGeometry();
  452. }
  453. // We want to add / update the room both in BeginPlay and OnRegister. BeginPlay for aux bus and reverb level assignment, OnRegister for portal room assignment and visualization
  454. if (!IsRegisteredWithWwise)
  455. {
  456. AddSpatialAudioRoom();
  457. }
  458. else
  459. {
  460. SendGeometry();
  461. UpdateSpatialAudioRoom();
  462. }
  463. if (AutoPost)
  464. {
  465. if (!HasActiveEvents())
  466. PostAssociatedAkEvent(0, FOnAkPostEventCallback());
  467. }
  468. }
  469. void UAkRoomComponent::EndPlay(EEndPlayReason::Type EndPlayReason)
  470. {
  471. if (bEventPosted)
  472. {
  473. Stop();
  474. }
  475. Super::EndPlay(EndPlayReason);
  476. }
  477. void UAkRoomComponent::SetGeometryComponent(UAkAcousticTextureSetComponent* textureSetComponent)
  478. {
  479. if (GeometryComponent != nullptr)
  480. {
  481. RemoveGeometry();
  482. }
  483. GeometryComponent = textureSetComponent;
  484. if (RoomIsActive())
  485. {
  486. SendGeometry();
  487. UpdateSpatialAudioRoom();
  488. }
  489. }
  490. #if WITH_EDITOR
  491. void UAkRoomComponent::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
  492. {
  493. Super::PostEditChangeProperty(PropertyChangedEvent);
  494. //Call add again to update the room parameters, if it has already been added.
  495. if (IsRegisteredWithWwise)
  496. UpdateSpatialAudioRoom();
  497. }
  498. #endif
  499. bool UAkRoomComponent::EncompassesPoint(FVector Point, float SphereRadius/*=0.f*/, float* OutDistanceToPoint/*=nullptr*/) const
  500. {
  501. if (IsValid(Parent))
  502. {
  503. return AkComponentHelpers::EncompassesPoint(*Parent, Point, SphereRadius, OutDistanceToPoint);
  504. }
  505. FString actorString = FString("NONE");
  506. if (GetOwner() != nullptr)
  507. actorString = GetOwner()->GetName();
  508. UE_LOG(LogAkAudio, Error, TEXT("UAkRoomComponent::EncompassesPoint : Error. In actor %s, AkRoomComponent %s has an invalid Parent."), *actorString, *UObject::GetName());
  509. return false;
  510. }
  511. void UAkRoomComponent::SendGeometry()
  512. {
  513. if (GeometryComponent)
  514. {
  515. UAkGeometryComponent* GeometryComp = Cast<UAkGeometryComponent>(GeometryComponent);
  516. if (GeometryComp && GeometryComp->bWasAddedByRoom)
  517. {
  518. if (!GeometryComp->GetGeometryHasBeenSent())
  519. GeometryComp->SendGeometry();
  520. if (!GeometryComp->GetGeometryInstanceHasBeenSent())
  521. GeometryComp->UpdateGeometry();
  522. }
  523. UAkSurfaceReflectorSetComponent* SurfaceReflector = Cast<UAkSurfaceReflectorSetComponent>(GeometryComponent);
  524. if (SurfaceReflector && !SurfaceReflector->bEnableSurfaceReflectors)
  525. {
  526. if (!SurfaceReflector->GetGeometryHasBeenSent())
  527. SurfaceReflector->SendSurfaceReflectorSet();
  528. if (!SurfaceReflector->GetGeometryInstanceHasBeenSent())
  529. SurfaceReflector->UpdateSurfaceReflectorSet();
  530. }
  531. }
  532. }
  533. void UAkRoomComponent::RemoveGeometry()
  534. {
  535. if (IsValid(GeometryComponent))
  536. {
  537. UAkGeometryComponent* GeometryComp = Cast<UAkGeometryComponent>(GeometryComponent);
  538. if (GeometryComp && GeometryComp->bWasAddedByRoom)
  539. {
  540. GeometryComp->RemoveGeometry();
  541. }
  542. UAkSurfaceReflectorSetComponent* SurfaceReflector = Cast<UAkSurfaceReflectorSetComponent>(GeometryComponent);
  543. if (SurfaceReflector && !SurfaceReflector->bEnableSurfaceReflectors)
  544. {
  545. SurfaceReflector->RemoveSurfaceReflectorSet();
  546. }
  547. }
  548. }
  549. UAkLateReverbComponent* UAkRoomComponent::GetReverbComponent()
  550. {
  551. UAkLateReverbComponent* pRvbComp = nullptr;
  552. if (Parent != nullptr)
  553. {
  554. pRvbComp = AkComponentHelpers::GetChildComponentOfType<UAkLateReverbComponent>(*Parent);
  555. }
  556. return pRvbComp;
  557. }