From d0d796781b08e7df88399d258f870edfe0dc0611 Mon Sep 17 00:00:00 2001 From: Glence Date: Mon, 26 Sep 2022 15:50:07 +0800 Subject: [PATCH] remove audiosourcecomponent --- SHADE_Application/premake5.lua | 3 +- .../src/Application/SBApplication.cpp | 3 +- .../AudioSystem/SHAudioListenerComponent.cpp | 10 +- .../AudioSystem/SHAudioListenerComponent.h | 11 +-- .../AudioSystem/SHAudioSourceComponent.cpp | 98 ++++++------------- .../src/AudioSystem/SHAudioSystem.cpp | 5 +- 6 files changed, 45 insertions(+), 85 deletions(-) diff --git a/SHADE_Application/premake5.lua b/SHADE_Application/premake5.lua index 7e3675aa..c79d436e 100644 --- a/SHADE_Application/premake5.lua +++ b/SHADE_Application/premake5.lua @@ -34,7 +34,8 @@ project "SHADE_Application" "%{IncludeDir.VULKAN}/include", "%{IncludeDir.VMA}/include", "%{IncludeDir.VULKAN}/Source/SPIRV-Reflect", - "%{IncludeDir.fmod}/include" + "%{IncludeDir.fmod}/include", + "%{IncludeDir.RTTR}\\include" } externalwarnings "Off" diff --git a/SHADE_Application/src/Application/SBApplication.cpp b/SHADE_Application/src/Application/SBApplication.cpp index 6030963e..a7aa1cb7 100644 --- a/SHADE_Application/src/Application/SBApplication.cpp +++ b/SHADE_Application/src/Application/SBApplication.cpp @@ -25,7 +25,6 @@ #include "Math/Transform/SHTransformSystem.h" #include "Input/SHInputManagerSystem.h" #include "AudioSystem/SHAudioSystem.h" -#include "AudioSystem/SHAudioSourceComponent.h" #include "AudioSystem/SHAudioListenerComponent.h" #include "Scenes/SBTestScene.h" @@ -81,7 +80,7 @@ namespace Sandbox SHADE::SHSystemManager::RegisterRoutine(); SHADE::SHSystemManager::RegisterRoutine(); - SHADE::SHComponentManager::CreateComponentSparseSet(); + //SHADE::SHComponentManager::CreateComponentSparseSet(); SHADE::SHComponentManager::CreateComponentSparseSet(); // Set up graphics system and windows diff --git a/SHADE_Engine/src/AudioSystem/SHAudioListenerComponent.cpp b/SHADE_Engine/src/AudioSystem/SHAudioListenerComponent.cpp index 342d4702..988b2781 100644 --- a/SHADE_Engine/src/AudioSystem/SHAudioListenerComponent.cpp +++ b/SHADE_Engine/src/AudioSystem/SHAudioListenerComponent.cpp @@ -10,7 +10,7 @@ #include "SHpch.h" #include "SHAudioListenerComponent.h" -//#include "ECS_Base/System/SHSystemManager.h" +#include "ECS_Base/Managers/SHSystemManager.h" namespace SHADE { @@ -34,22 +34,22 @@ namespace SHADE return up; } - void SHAudioListenerComponent::SetPos(SHVec3 p) + void SHAudioListenerComponent::SetPos(const SHVec3 p) { pos = p; } - void SHAudioListenerComponent::SetVel(SHVec3 v) + void SHAudioListenerComponent::SetVel(const SHVec3 v) { vel = v; } - void SHAudioListenerComponent::SetForward(SHVec3 f) + void SHAudioListenerComponent::SetForward(const SHVec3 f) { forward = f; } - void SHAudioListenerComponent::SetUp(SHVec3 u) + void SHAudioListenerComponent::SetUp(const SHVec3 u) { up = u; } diff --git a/SHADE_Engine/src/AudioSystem/SHAudioListenerComponent.h b/SHADE_Engine/src/AudioSystem/SHAudioListenerComponent.h index d0e39bdc..e0fa8104 100644 --- a/SHADE_Engine/src/AudioSystem/SHAudioListenerComponent.h +++ b/SHADE_Engine/src/AudioSystem/SHAudioListenerComponent.h @@ -24,16 +24,15 @@ namespace SHADE ~SHAudioListenerComponent() = default; const SHVec3 GetPos() const; + void SetPos(const SHVec3 p); + const SHVec3 GetVel() const; const SHVec3 GetForward() const; const SHVec3 GetUp() const; - void SetPos(SHVec3 p); - void SetVel(SHVec3 v); - void SetForward(SHVec3 f); - void SetUp(SHVec3 u); - - + void SetVel(const SHVec3 v); + void SetForward(const SHVec3 f); + void SetUp(const SHVec3 u); private: SHVec3 pos{}, vel{}, forward{}, up{ 0.f,1.f,0.f }; diff --git a/SHADE_Engine/src/AudioSystem/SHAudioSourceComponent.cpp b/SHADE_Engine/src/AudioSystem/SHAudioSourceComponent.cpp index 891ea1e1..2d623ede 100644 --- a/SHADE_Engine/src/AudioSystem/SHAudioSourceComponent.cpp +++ b/SHADE_Engine/src/AudioSystem/SHAudioSourceComponent.cpp @@ -15,75 +15,39 @@ namespace SHADE { - /** - * @brief play the sound - * - * @param index where the sound is in the index - */ - void SHAudioSourceComponent::PlaySoundSFX(EntityID id, bool loop, bool spatial, float min , float max ) - { - SHSystemManager::GetSystem()->PlaySFX(id, GetEID(),loop,spatial, min, max); - } + /** + * @brief play the sound + * + * @param index where the sound is in the index + */ + void SHAudioSourceComponent::PlaySoundSFX(EntityID id, bool loop, bool spatial, float min , float max ) + { + SHSystemManager::GetSystem()->PlaySFX(id, GetEID(),loop,spatial, min, max); + } - //void SHAudioSourceComponent::PlayOneShot(const char* path, bool isSFX, bool spatial) - //{ - // auto AudioSystem = dynamic_cast(SHSystemManager::GetSystem("Audio")); - // AudioSystem->PlayEventOnce(path, isSFX, spatial ? GetEID() : MAX_EID, spatial); - //} + void SHAudioSourceComponent::PlaySoundBGM(EntityID id, bool loop, bool spatial, float min, float max) + { + SHSystemManager::GetSystem()->PlayBGM(id, GetEID(), loop, spatial, min, max); + } - //void SHAudioSourceComponent::PlayEvent(const char* path, bool isSFX, bool spatial) - //{ - // auto AudioSystem = dynamic_cast(SHSystemManager::GetSystem("Audio")); + /** + * @brief Stop the sound + * + * @param index where the sound is in the index + */ + void SHAudioSourceComponent::StopSound(EntityID id) + { + SHSystemManager::GetSystem()->StopSound(id); + } - // auto guid = AudioSystem->GetEventGUID(path); - // if (guid.has_value()) - // { - // if (FMOD::Studio::EventInstance* instance = AudioSystem->CreateEventInstance(guid.value())) - // { - // eventInstances.push_back(instance); - // AudioSystem->PlayEventInstance(instance, isSFX, GetEID(), spatial); - // } - // } - //} - - void SHAudioSourceComponent::PlaySoundBGM(EntityID id, bool loop, bool spatial, float min, float max) - { - SHSystemManager::GetSystem()->PlayBGM(id, GetEID(), loop, spatial, min, max); - } - - /** - * @brief Stop the sound - * - * @param index where the sound is in the index - */ - void SHAudioSourceComponent::StopSound(EntityID id) - { - SHSystemManager::GetSystem()->StopSound(id); - } - - /** - * @brief Mute the sound - * - * @param index where the sound is in the index - */ - void SHAudioSourceComponent::SetMute(EntityID id, bool mute) - { - SHSystemManager::GetSystem()->SetMute(id, mute); - } - - //void SHAudioSourceComponent::PlayEventInstance(size_t index, bool isSFX, bool spatial) - //{ - // if (index < eventInstances.size()) - // { - // eventInstances[index]->start(); - // dynamic_cast(SHSystemManager::GetSystem("Audio"))->PlayEventInstance(eventInstances[index], isSFX, GetEID(), spatial); - // } - //} - - //void SHAudioSourceComponent::StopEventInstance(size_t index) - //{ - // if(index < eventInstances.size()) - // eventInstances[index]->stop(FMOD_STUDIO_STOP_ALLOWFADEOUT); - //} + /** + * @brief Mute the sound + * + * @param index where the sound is in the index + */ + void SHAudioSourceComponent::SetMute(EntityID id, bool mute) + { + SHSystemManager::GetSystem()->SetMute(id, mute); + } } diff --git a/SHADE_Engine/src/AudioSystem/SHAudioSystem.cpp b/SHADE_Engine/src/AudioSystem/SHAudioSystem.cpp index c0ad46cd..16b047bd 100644 --- a/SHADE_Engine/src/AudioSystem/SHAudioSystem.cpp +++ b/SHADE_Engine/src/AudioSystem/SHAudioSystem.cpp @@ -1,5 +1,4 @@ #include "SHpch.h" -//#include "ECS_Base/System/SHSystemManager.h" #include "SHAudioSystem.h" #include "Scene/SHSceneManager.h" #include "ECS_Base/Managers/SHComponentManager.h" @@ -10,8 +9,6 @@ #include "AudioSystem/SHAudioListenerComponent.h" #include "AudioSystem/SHAudioSourceComponent.h" -//#include "ECS_Base/System/SHComponentManager.h" -//#include "Resource Manager/SHResourceManager.h" #include "Math/Transform/SHTransformComponent.h" #pragma warning(push) #pragma warning(disable:26812) //disable warning about preference of enum class over enum as ImGuizmo uses enums @@ -29,7 +26,7 @@ namespace SHADE , masterGroup(nullptr) , audioChannels() , result(FMOD_RESULT_FORCEINT) - , bgmVolume(0.5F) + , bgmVolume(1.F) , sfxVolume(1.F) , masterVolume(1.0F) , version(0)