Skip to content
Snippets Groups Projects
Commit 50403963 authored by David Gilbert's avatar David Gilbert :bug:
Browse files

Replace deprecated GetComponentsByClass function

parent 97513198
No related branches found
No related tags found
1 merge request!10Replace deprecated GetComponentsByClass function
...@@ -95,18 +95,19 @@ void UVAAbstractSourceComponent::UpdateSkeletalMeshIfAttachToBone() ...@@ -95,18 +95,19 @@ void UVAAbstractSourceComponent::UpdateSkeletalMeshIfAttachToBone()
bool bFoundSkelMesh = false; bool bFoundSkelMesh = false;
while (!bFoundSkelMesh && Owner != nullptr) while (!bFoundSkelMesh && Owner != nullptr)
{ {
TArray<UActorComponent*> MeshComponents = Owner->GetComponentsByClass(USkeletalMeshComponent::StaticClass()); TArray<USkeletalMeshComponent*> MeshComponents;
for (UActorComponent* Component : MeshComponents) Owner->GetComponents(MeshComponents);
for (USkeletalMeshComponent* Component : MeshComponents)
{ {
USkeletalMeshComponent* MeshComp = Cast<USkeletalMeshComponent>(Component); if (Component && Component->DoesSocketExist(FName(*BoneName)))
if (MeshComp && MeshComp->DoesSocketExist(FName(*BoneName)))
{ {
//found the right mesh component //found the right mesh component
SkeletalMeshComponent = MeshComp; SkeletalMeshComponent = Component;
bFoundSkelMesh = true; bFoundSkelMesh = true;
break; break;
} }
} }
Owner = Owner->GetAttachParentActor(); Owner = Owner->GetAttachParentActor();
} }
...@@ -138,7 +139,8 @@ void UVAAbstractSourceComponent::Initialize() ...@@ -138,7 +139,8 @@ void UVAAbstractSourceComponent::Initialize()
// If no Rec Actor found spawn one with default parameters // If no Rec Actor found spawn one with default parameters
if (ReceiverActorTmp == nullptr) if (ReceiverActorTmp == nullptr)
{ {
FVAUtils::LogStuff("[UVASourceComponent::BeginPlay()]: No AVAReceiver found! Spawning one with default values", false); FVAUtils::LogStuff(
"[UVASourceComponent::BeginPlay()]: No AVAReceiver found! Spawning one with default values", false);
ReceiverActorTmp = this->GetWorld()->SpawnActor<AVAReceiverActor>(AVAReceiverActor::StaticClass()); ReceiverActorTmp = this->GetWorld()->SpawnActor<AVAReceiverActor>(AVAReceiverActor::StaticClass());
} }
} }
...@@ -151,8 +153,12 @@ void UVAAbstractSourceComponent::Initialize() ...@@ -151,8 +153,12 @@ void UVAAbstractSourceComponent::Initialize()
{ {
FVAPlugin::SetUseVA(false); FVAPlugin::SetUseVA(false);
FVAUtils::OpenMessageBox("There are more than 1 Receiver Actors in the world. Stopping VAPlugin. Make sure to remove the wrong one.", true); FVAUtils::OpenMessageBox(
FVAUtils::LogStuff("[UVASourceComponent::BeginPlay()]: More than 1 Receiver found! Stopping VAPlugin. Make sure to remove the wrong one", true); "There are more than 1 Receiver Actors in the world. Stopping VAPlugin. Make sure to remove the wrong one.",
true);
FVAUtils::LogStuff(
"[UVASourceComponent::BeginPlay()]: More than 1 Receiver found! Stopping VAPlugin. Make sure to remove the wrong one",
true);
return; return;
} }
...@@ -169,9 +175,11 @@ void UVAAbstractSourceComponent::Initialize() ...@@ -169,9 +175,11 @@ void UVAAbstractSourceComponent::Initialize()
SpawnRotation = GetOwner()->GetTransform().GetRotation().Rotator(); SpawnRotation = GetOwner()->GetTransform().GetRotation().Rotator();
const std::string ExplicitRendererID = bRendererExplicit ? std::string( TCHAR_TO_UTF8(*RendererID) ): ""; // Empty ID => general source const std::string ExplicitRendererID = bRendererExplicit ? std::string(TCHAR_TO_UTF8(*RendererID)) : "";
// Empty ID => general source
const std::string SoundSourceName = std::string(TCHAR_TO_UTF8(*GetName())); const std::string SoundSourceName = std::string(TCHAR_TO_UTF8(*GetName()));
SoundSource = MakeShared<FVASoundSource>(GetWorld(), GetPosition(), GetRotation(), SoundPower, SoundSourceName, ExplicitRendererID); SoundSource = MakeShared<FVASoundSource>(GetWorld(), GetPosition(), GetRotation(), SoundPower, SoundSourceName,
ExplicitRendererID);
if (UVirtualRealityUtilities::IsMaster()) if (UVirtualRealityUtilities::IsMaster())
{ {
...@@ -234,7 +242,8 @@ bool UVAAbstractSourceComponent::SetSignalSourceID(const std::string& SignalSour ...@@ -234,7 +242,8 @@ bool UVAAbstractSourceComponent::SetSignalSourceID(const std::string& SignalSour
{ {
if (!SoundSource.IsValid()) if (!SoundSource.IsValid())
{ {
FVAUtils::OpenMessageBox(FString("[UVASourceComponent::SetSignalSourceID]: VA sound source not initialized"), true); FVAUtils::OpenMessageBox(FString("[UVASourceComponent::SetSignalSourceID]: VA sound source not initialized"),
true);
return false; return false;
} }
if (!SoundSource->SetSignalSource(SignalSourceID)) if (!SoundSource->SetSignalSource(SignalSourceID))
...@@ -309,7 +318,6 @@ bool UVAAbstractSourceComponent::GetHandleReflections() const ...@@ -309,7 +318,6 @@ bool UVAAbstractSourceComponent::GetHandleReflections() const
} }
// ****************************************************************** // // ****************************************************************** //
// ******* Sound Pose *********************************************** // // ******* Sound Pose *********************************************** //
// ****************************************************************** // // ****************************************************************** //
...@@ -451,7 +459,6 @@ bool UVAAbstractSourceComponent::SetOffsetRotation(const FRotator Rot) ...@@ -451,7 +459,6 @@ bool UVAAbstractSourceComponent::SetOffsetRotation(const FRotator Rot)
} }
// ****************************************************************** // // ****************************************************************** //
// ******* Directivity stuff **************************************** // // ******* Directivity stuff **************************************** //
// ****************************************************************** // // ****************************************************************** //
...@@ -516,7 +523,6 @@ FString UVAAbstractSourceComponent::GetDirectivityFileName() const ...@@ -516,7 +523,6 @@ FString UVAAbstractSourceComponent::GetDirectivityFileName() const
} }
// ****************************************************************** // // ****************************************************************** //
// ******* Graphical Representation ********************************* // // ******* Graphical Representation ********************************* //
// ****************************************************************** // // ****************************************************************** //
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment