Skip to content
Snippets Groups Projects
Commit ccc9404e authored by Jonathan Ehret's avatar Jonathan Ehret
Browse files

Merge branch 'feature/sound_source_explicit_renderer' into '4.26'

VA Sound Source: Added setting to create renderer explicit sources

See merge request !7
parents b3ccceaf a87463a8
Branches
Tags
1 merge request!7VA Sound Source: Added setting to create renderer explicit sources
......@@ -29,7 +29,7 @@ FVAImageSourceModel::FVAImageSourceModel(UWorld* World, TSharedRef<FVASoundSourc
const float R = Wall->GetReflectionValueR();
const float PowerR = ParentSource->GetPower() * R * R;
ImageSources.Add( MakeShared<FVAImageSource>(Wall, World, ParentSource->GetPosition(), ParentSource->GetRotation(), PowerR, ISName, ParentSource->GetDirectivity()) );
ImageSources.Add( MakeShared<FVAImageSource>(Wall, World, ParentSource->GetPosition(), ParentSource->GetRotation(), PowerR, ISName, ParentSource->GetExplicitRendererID(), ParentSource->GetDirectivity()) );
}
}
......@@ -179,8 +179,9 @@ FRotator FVAImageSourceModel::ComputeReflectedRot(const AVAReflectionWall* Wall,
// ******* Image Source Class *************************************** //
// ****************************************************************** //
FVAImageSourceModel::FVAImageSource::FVAImageSource(AVAReflectionWall* Wall, UWorld* World, const FVector& Position, const FRotator& Rotation, float Power, const std::string& Name, TSharedPtr<FVADirectivity> Directivity /* = nullptr */)
: FVASoundSource(World, Position, Rotation, Power, Name, Directivity)
FVAImageSourceModel::FVAImageSource::FVAImageSource(AVAReflectionWall* Wall, UWorld* World, const FVector& Position, const FRotator& Rotation, float Power,
const std::string& Name, const std::string& RendererID /* = "" */, TSharedPtr<FVADirectivity> Directivity /* = nullptr */)
: FVASoundSource(World, Position, Rotation, Power, Name, RendererID, Directivity)
, Wall(Wall)
{
if (Wall == nullptr)
......
......@@ -56,7 +56,7 @@ private:
class FVAImageSource : public FVASoundSource
{
public:
FVAImageSource(AVAReflectionWall* Wall, UWorld* World, const FVector& PosN, const FRotator& RotN, float PowerN, const std::string& NameN, TSharedPtr<FVADirectivity> Directivity = nullptr);
FVAImageSource(AVAReflectionWall* Wall, UWorld* World, const FVector& PosN, const FRotator& RotN, float PowerN, const std::string& NameN, const std::string& RendererID = "", TSharedPtr<FVADirectivity> Directivity = nullptr);
AVAReflectionWall* GetWall();
private:
AVAReflectionWall* Wall;
......
......@@ -150,8 +150,10 @@ void UVAAbstractSourceComponent::Initialize()
SpawnPosition = GetOwner()->GetTransform().GetLocation();
SpawnRotation = GetOwner()->GetTransform().GetRotation().Rotator();
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()) );
SoundSource = MakeShared<FVASoundSource>(GetWorld(), GetPosition(), GetRotation(), SoundPower, SoundSourceName);
SoundSource = MakeShared<FVASoundSource>(GetWorld(), GetPosition(), GetRotation(), SoundPower, SoundSourceName, ExplicitRendererID);
if (UVirtualRealityUtilities::IsMaster())
{
......
......@@ -14,9 +14,11 @@
// ******* Initialization ******************************************* //
// ****************************************************************** //
FVASoundSource::FVASoundSource(UWorld* World, const FVector& Position, const FRotator& Rotation, float Power, const std::string& Name /* = "" */, TSharedPtr<FVADirectivity> Directivity /* = nullptr */)
FVASoundSource::FVASoundSource(UWorld* World, const FVector& Position, const FRotator& Rotation, float Power, const std::string& Name,
const std::string& RendererID /* = "" */, TSharedPtr<FVADirectivity> Directivity /* = nullptr */)
: SoundSourceID(VA_INVALID_ID)
, Name(Name)
, RendererID(RendererID)
, Position(Position)
, Rotation(Rotation)
, bShowCones(false)
......@@ -26,7 +28,7 @@ FVASoundSource::FVASoundSource(UWorld* World, const FVector& Position, const FRo
{
bShowCones = FVAPlugin::GetDebugMode();
SoundSourceID = FVAPlugin::CreateNewSoundSource(Name, Position, Rotation, Power);
SoundSourceID = FVAPlugin::CreateNewSoundSource(Name, Position, Rotation, Power, RendererID);
if (SoundSourceID == VA_INVALID_ID)
{
FVAUtils::LogStuff("[FVASoundSource::FVASoundSource()]: Error initializing VA sound source", true);
......@@ -182,6 +184,11 @@ const std::string& FVASoundSource::GetSoundSourceName() const
return Name;
}
const std::string& FVASoundSource::GetExplicitRendererID() const
{
return RendererID;
}
FVector FVASoundSource::GetPosition() const
{
return Position;
......
......@@ -17,7 +17,7 @@ class FVASoundSource
public:
// Initialization
FVASoundSource(UWorld* World, const FVector& PosN, const FRotator& RotN, float PowerN, const std::string& NameN = "", TSharedPtr<FVADirectivity> DirectivityID = nullptr);
FVASoundSource(UWorld* World, const FVector& PosN, const FRotator& RotN, float PowerN, const std::string& NameN, const std::string& RendererID = "", TSharedPtr<FVADirectivity> DirectivityID = nullptr);
virtual ~FVASoundSource();
// Setter
......@@ -39,6 +39,7 @@ public:
// Getter
int GetSoundSourceID() const;
const std::string& GetSoundSourceName() const;
const std::string& GetExplicitRendererID() const;
FVector GetPosition() const;
FRotator GetRotation() const;
......@@ -54,6 +55,7 @@ private:
int SoundSourceID;
std::string Name;
std::string RendererID;
FVector Position;
FRotator Rotation;
......
......@@ -635,7 +635,7 @@ bool FVAPlugin::SetJetEngineRMP(const std::string& SignalSourceID, float fRPM)
// ******* Sound Sources ******************************************** //
// ****************************************************************** //
int FVAPlugin::CreateNewSoundSource(const std::string& Name, FVector Pos, FRotator Rot, const float Power, const std::string& SignalSourceID)
int FVAPlugin::CreateNewSoundSource(const std::string& Name, FVector Pos, FRotator Rot, const float Power, const std::string& RendererID, const std::string& SignalSourceID)
{
if (!ShouldInteractWithServer())
{
......@@ -660,7 +660,11 @@ int FVAPlugin::CreateNewSoundSource(const std::string& Name, FVector Pos, FRotat
try
{
const int SoundSourceID = VAServer->CreateSoundSource(Name);
int SoundSourceID;
if ( RendererID.empty() )
SoundSourceID = VAServer->CreateSoundSource(Name);
else
SoundSourceID = VAServer->CreateSoundSourceExplicitRenderer(RendererID, Name);
VAServer->SetSoundSourcePose(SoundSourceID, *TmpVAVec3, *TmpVAQuat);
......
......@@ -86,7 +86,7 @@ public:
// ******* Sound Sources ******* //
static int CreateNewSoundSource(const std::string& Name, FVector Pos = FVector(0, 0, 0),
FRotator Rot = FRotator(0, 0, 0), float Power = -1.0f, const std::string& SignalSourceID = "");
FRotator Rot = FRotator(0, 0, 0), float Power = -1.0f, const std::string& RendererID = "", const std::string & SignalSourceID = "");
// Deletes a sound source with given ID. Use with great care!
static bool DeleteSoundSource(int SoundSourceID);
static bool SetSoundSourcePosition(int SoundSourceID, FVector Pos);
......
......@@ -35,6 +35,14 @@ protected:
ClampMin = "0.0", ClampMax = "100.0", UIMin = "0.0", UIMax = "100.0"))
float SoundPower = 0.0316227749f;
// Enable to make this sound source only available to a specific VA renderer
UPROPERTY(EditAnywhere, meta = (DisplayName = "Renderer explicit", Category = "General Settings") )
bool bRendererExplicit;
// VA Renderer ID for using specific renderer. An empty string refers to a general source.
UPROPERTY(EditAnywhere, meta = (DisplayName = "Renderer ID", Category = "General Settings", EditCondition = "bRendererExplicit") )
FString RendererID = "";
// Decide whether to use manual Transform (below) or use Transform / Movement of Actor
UPROPERTY(EditAnywhere, meta = (DisplayName = "Position Settings", Category = "Position",
CustomStructureParam = "Move With the Object, At Object Spawn Point (unmovable, also reflections), Attatch to a Bone"))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment