Merge branch 'SP3-1-MaterialUpdate' into SP3-1-MaterialEditSupport

# Conflicts:
#	SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHMaterial.h
This commit is contained in:
Kah Wei 2022-11-16 16:45:22 +08:00
commit 760c0386a9
82 changed files with 535 additions and 192 deletions

View File

@ -8,8 +8,8 @@
//#include "Scenes/SBEditorScene.h"
#endif // SHEDITOR
#include "Tools/SHLogger.h"
#include "Tools/SHFileUtilties.h"
#include "Tools/Logger/SHLogger.h"
#include "Tools/Utilities/SHFileUtilties.h"
#include <chrono>
#include <ratio>
@ -44,7 +44,7 @@
#include "Scenes/SBMainScene.h"
#include "Serialization/Configurations/SHConfigurationManager.h"
#include "Tools/SHLogger.h"
#include "Tools/Logger/SHLogger.h"
#include "Tools/SHDebugDraw.h"
using namespace SHADE;
@ -60,6 +60,8 @@ namespace Sandbox
_In_ INT nCmdShow
)
{
SHLOG_INFO_D("Initialising SHADE engine")
// Set working directory
SHFileUtilities::SetWorkDirToExecDir();
WindowData wndData{};

View File

@ -1,6 +1,6 @@
#include "SBpch.h"
#include <Engine/SHEngine.h>
#include <Tools/SHLogger.h>
#include <Tools/Logger/SHLogger.h>
#include <Tools/SHExceptionHandler.h>
#include "Application/SBApplication.h"

View File

@ -7,7 +7,7 @@
#include "ECS_Base/System/SHSystem.h"
#include "ECS_Base/System/SHSystemRoutine.h"
#include "ECS_Base/SHECSMacros.h"
#include "Math/SHMath.h"
#include "Math/Vector/SHVec3.h"
#include <optional>
#include <FMOD/fmod_studio.hpp>
#include "SH_API.h"

View File

@ -5,7 +5,7 @@
#include "ECS_Base/Managers/SHComponentManager.h"
#include "ECS_Base/SHECSMacros.h"
#include "ECS_Base/Managers/SHEntityManager.h"
#include "Tools/SHLog.h"
#include "Tools/Logger/SHLog.h"
namespace SHADE
{

View File

@ -5,7 +5,7 @@
#include "../Managers/SHSystemManager.h"
#include "SHTestComponents.h"
#include "SHTestSystems.h"
#include "Tools/SHLogger.h"
#include "Tools/Logger/SHLogger.h"

View File

@ -23,7 +23,7 @@
#include <imgui.h>
#include "Serialization/SHSerialization.h"
#include "Tools/SHClipboardUtilities.h"
#include "Tools/Utilities/SHClipboardUtilities.h"
namespace SHADE
@ -345,10 +345,18 @@ namespace SHADE
void SHHierarchyPanel::ParentSelectedEntities(EntityID parentEID, std::vector<EntityID> const& entities) const noexcept
{
auto const& sceneGraph = SHSceneManager::GetCurrentSceneGraph();
std::vector<EntityID> entitiesToParent{};
std::ranges::copy_if(entities, std::back_inserter(entitiesToParent), [&sceneGraph](EntityID const& eid)
{
if (sceneGraph.GetParent(eid)->GetEntityID() == MAX_EID)
return true;
return false;
});
//auto const editor = SHSystemManager::GetSystem<SHEditor>();
SHEntityParentCommand::EntityParentData entityParentData;
std::vector<EntityID> parentedEIDS;
for (auto const& eid : entities)
for (auto const& eid : entitiesToParent)
{
if(eid == parentEID)
continue;

View File

@ -68,10 +68,10 @@ namespace SHADE
{
if (!component)
return;
const auto componentType = rttr::type::get<T>();
ImGui::PushID(SHFamilyID<SHComponent>::GetID<T>());
SHEditorWidgets::CheckBox("##IsActive", [component]() {return component->isActive; }, [component](bool const& active) {component->isActive = active; }, "Is Component Active");
ImGui::PopID();
ImGui::SameLine();
if (ImGui::CollapsingHeader(componentType.get_name().data()))
{
@ -216,6 +216,89 @@ namespace SHADE
}
}
else DrawContextMenu(component);
ImGui::PopID();
}
template<>
static void DrawComponent(SHRigidBodyComponent* component)
{
if(!component)
return;
ImGui::PushID(SHFamilyID<SHComponent>::GetID<SHRigidBodyComponent>());
const auto componentType = rttr::type::get<SHRigidBodyComponent>();
SHEditorWidgets::CheckBox("##IsActive", [component]() {return component->isActive; }, [component](bool const& active) {component->isActive = active; }, "Is Component Active");
ImGui::SameLine();
if (ImGui::CollapsingHeader(componentType.get_name().data()))
{
DrawContextMenu(component);
SHRigidBodyComponent::Type rbType = component->GetType();
auto enumAlign = rttr::type::get<SHRigidBodyComponent::Type>().get_enumeration();
auto names = enumAlign.get_names();
std::vector<const char*> list;
for (auto const& name : names)
list.push_back(name.data());
SHEditorWidgets::ComboBox("Type", list, [component] {return static_cast<int>(component->GetType()); }, [component, enumAlign](int const& idx)
{
auto values = enumAlign.get_values();
auto it = std::next(values.begin(), idx);
component->SetType((*it).convert<SHRigidBodyComponent::Type>());
}, "RigidBody Type");
if(rbType == SHRigidBodyComponent::Type::DYNAMIC) //Dynamic only fields
{
SHEditorWidgets::CheckBox("Use Gravity", [component]{return component->IsGravityEnabled();}, [component](bool const& value){component->SetGravityEnabled(value);}, "Gravity");
SHEditorWidgets::DragFloat("Mass", [component] {return component->GetMass(); }, [component](float const& value) {component->SetMass(value); }, "Mass");
}
if (rbType == SHRigidBodyComponent::Type::DYNAMIC || rbType == SHRigidBodyComponent::Type::KINEMATIC) //Dynamic or Kinematic only fields
{
SHEditorWidgets::DragFloat("Drag", [component] {return component->GetDrag(); }, [component](float const& value) {component->SetDrag(value); }, "Drag");
SHEditorWidgets::DragFloat("Angular Drag", [component] {return component->GetAngularDrag(); }, [component](float const& value) {component->SetAngularDrag(value); }, "Angular Drag");
SHEditorWidgets::CheckBox("Interpolate", [component] {return component->IsInterpolating(); }, [component](bool const& value) {component->SetInterpolate(value); }, "Interpolate");
SHEditorWidgets::BeginPanel(std::format("{} Constraints", ICON_FA_LOCK).data(), { ImGui::GetContentRegionAvail().x, ImGui::GetContentRegionAvail().y });
SHEditorWidgets::TextLabel("Freeze Position");
SHEditorWidgets::CheckBox("X", [component] {return component->GetFreezePositionX(); }, [component](bool const& value) {component->SetFreezePositionX(value); }, "Freeze Position - X"); ImGui::SameLine();
SHEditorWidgets::CheckBox("Y", [component] {return component->GetFreezePositionY(); }, [component](bool const& value) {component->SetFreezePositionY(value); }, "Freeze Position - Y"); ImGui::SameLine();
SHEditorWidgets::CheckBox("Z", [component] {return component->GetFreezePositionZ(); }, [component](bool const& value) {component->SetFreezePositionZ(value); }, "Freeze Position - Z");
SHEditorWidgets::TextLabel("Freeze Rotation");
SHEditorWidgets::CheckBox("X", [component] {return component->GetFreezeRotationX(); }, [component](bool const& value) {component->SetFreezeRotationX(value); }, "Freeze Rotation - X"); ImGui::SameLine();
SHEditorWidgets::CheckBox("Y", [component] {return component->GetFreezeRotationY(); }, [component](bool const& value) {component->SetFreezeRotationY(value); }, "Freeze Rotation - Y"); ImGui::SameLine();
SHEditorWidgets::CheckBox("Z", [component] {return component->GetFreezeRotationZ(); }, [component](bool const& value) {component->SetFreezeRotationZ(value); }, "Freeze Rotation - Z");
SHEditorWidgets::EndPanel();
}
//Debug Info (Read-Only)
if(ImGui::CollapsingHeader("Debug Information", ImGuiTreeNodeFlags_DefaultOpen))//Dynamic or Kinematic only fields
{
SHEditorWidgets::DragVec3("Position", { "X", "Y", "Z" }, [component] {return component->GetPosition(); }, [](SHVec3 const& value) {}, false, "Position", 0.1f, "%.3f", 0.0f, 0.0f, ImGuiSliderFlags_ReadOnly);
SHEditorWidgets::DragVec3("Rotation", { "X", "Y", "Z" }, [component] {return component->GetRotation(); }, [](SHVec3 const& value) {}, false, "Rotation", 0.1f, "%.3f", 0.0f, 0.0f, ImGuiSliderFlags_ReadOnly);
if (rbType == SHRigidBodyComponent::Type::DYNAMIC || rbType == SHRigidBodyComponent::Type::KINEMATIC) //Dynamic or Kinematic only fields
{
SHEditorWidgets::DragVec3("Velocity", { "X", "Y", "Z" }, [component] {return component->GetLinearVelocity(); }, [](SHVec3 const& value) {}, false, "Linear Velocity", 0.1f, "%.3f", 0.0f, 0.0f, ImGuiSliderFlags_ReadOnly);
SHEditorWidgets::DragVec3("Angular\nVelocity", { "X", "Y", "Z" }, [component] {return component->GetAngularVelocity(); }, [](SHVec3 const& value) {}, false, "Angular Velocity", 0.1f, "%.3f", 0.0f, 0.0f, ImGuiSliderFlags_ReadOnly);
}
if (rbType == SHRigidBodyComponent::Type::DYNAMIC) //Dynamic only fields
{
SHEditorWidgets::DragVec3("Force", { "X", "Y", "Z" }, [component] {return component->GetForce(); }, [](SHVec3 const& value) {}, false, "Force", 0.1f, "%.3f", 0.0f, 0.0f, ImGuiSliderFlags_ReadOnly);
SHEditorWidgets::DragVec3("Torque", { "X", "Y", "Z" }, [component] {return component->GetTorque(); }, [](SHVec3 const& value) {}, false, "Torque", 0.1f, "%.3f", 0.0f, 0.0f, ImGuiSliderFlags_ReadOnly);
}
}
}
else
{
DrawContextMenu(component);
}
ImGui::PopID();
}
template<>
@ -223,7 +306,8 @@ namespace SHADE
{
if (!component)
return;
ImGui::PushID(component);
ImGui::PushID(SHFamilyID<SHComponent>::GetID<SHColliderComponent>());
const auto componentType = rttr::type::get(*component);
SHEditorWidgets::CheckBox("##IsActive", [component]() {return component->isActive; }, [component](bool const& active) {component->isActive = active; }, "Is Component Active");
ImGui::SameLine();
@ -275,21 +359,12 @@ namespace SHADE
[&collider]
{
auto offset = collider->GetRotationOffset();
offset.x = SHMath::RadiansToDegrees(offset.x);
offset.y = SHMath::RadiansToDegrees(offset.y);
offset.z = SHMath::RadiansToDegrees(offset.z);
return offset;
},
[&collider](SHVec3 const& vec)
{
const SHVec3 vecInRad
{
SHMath::DegreesToRadians(vec.x)
, SHMath::DegreesToRadians(vec.y)
, SHMath::DegreesToRadians(vec.z)
};
collider->SetRotationOffset(vecInRad);
});
collider->SetRotationOffset(vec);
}, true);
SHEditorWidgets::EndPanel();
}
@ -330,6 +405,7 @@ namespace SHADE
{
if (!component)
return;
ImGui::PushID(SHFamilyID<SHComponent>::GetID<SHLightComponent>());
const auto componentType = rttr::type::get(*component);
SHEditorWidgets::CheckBox("##IsActive", [component]() {return component->isActive; }, [component](bool const& active) {component->isActive = active; }, "Is Component Active");
ImGui::SameLine();
@ -353,6 +429,7 @@ namespace SHADE
{
DrawContextMenu(component);
}
ImGui::PopID();
}
template<>
@ -360,6 +437,7 @@ namespace SHADE
{
if (!component)
return;
ImGui::PushID(SHFamilyID<SHComponent>::GetID<SHRenderable>());
const auto componentType = rttr::type::get(*component);
SHEditorWidgets::CheckBox("##IsActive", [component]() {return component->isActive; }, [component](bool const& active) {component->isActive = active; }, "Is Component Active");
ImGui::SameLine();
@ -399,5 +477,6 @@ namespace SHADE
{
DrawContextMenu(component);
}
ImGui::PopID();
}
}

View File

@ -221,13 +221,20 @@ namespace SHADE
ImGui::BeginDisabled(editor->editorState == SHEditor::State::PLAY);
if(ImGui::SmallButton(ICON_MD_PLAY_ARROW))
{
if(editor->SaveScene())
if(editor->editorState == SHEditor::State::STOP)
{
if (editor->SaveScene())
{
editor->Play();
}
}
else
{
editor->Play();
}
}
ImGui::EndDisabled();
ImGui::BeginDisabled(editor->editorState == SHEditor::State::PAUSE);
ImGui::BeginDisabled(editor->editorState == SHEditor::State::STOP || editor->editorState == SHEditor::State::PAUSE);
if(ImGui::SmallButton(ICON_MD_PAUSE))
{
editor->Pause();

View File

@ -3,7 +3,7 @@
#include <memory>
#include <unordered_map>
#include "SHEditorWindow.h"
#include "Tools/SHLog.h"
#include "Tools/Logger/SHLog.h"
namespace SHADE
{

View File

@ -85,7 +85,7 @@ namespace SHADE
shouldUpdateCamArm = ImGui::IsWindowHovered() && ImGui::IsKeyDown(ImGuiKey_LeftAlt) && ImGui::IsMouseDown(ImGuiMouseButton_Left);
if (editor->editorState != SHEditor::State::PLAY && ImGui::IsWindowFocused() && !ImGui::IsMouseDown(ImGuiMouseButton_Right))
if (editor->editorState != SHEditor::State::PLAY && !ImGui::IsAnyItemActive() && !ImGui::IsMouseDown(ImGuiMouseButton_Right))
{
if (ImGui::IsKeyReleased(ImGuiKey_W))
{
@ -151,7 +151,7 @@ namespace SHADE
if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled))
{
ImGui::BeginTooltip();
ImGui::Text("Translate [Q]");
ImGui::Text("Translate [W]");
ImGui::EndTooltip();
}
if (isTranslate)
@ -169,7 +169,7 @@ namespace SHADE
if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled))
{
ImGui::BeginTooltip();
ImGui::Text("Rotate [W]");
ImGui::Text("Rotate [E]");
ImGui::EndTooltip();
}
if (isRotate)
@ -187,7 +187,7 @@ namespace SHADE
if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled))
{
ImGui::BeginTooltip();
ImGui::Text("Scale [E]");
ImGui::Text("Scale [R]");
ImGui::EndTooltip();
}
if (isScale)

View File

@ -10,7 +10,7 @@
//#==============================================================#
//|| SHADE Includes ||
//#==============================================================#
#include "Tools/SHLogger.h"
#include "Tools/Logger/SHLogger.h"
#include "Tools/SHException.h"
#include "ECS_Base/Managers/SHSystemManager.h"

View File

@ -15,7 +15,7 @@
#include "ECS_Base/System/SHSystemRoutine.h"
#include "Resource/SHHandle.h"
#include "EditorWindow/SHEditorWindow.h"
#include "Tools/SHLog.h"
#include "Tools/Logger/SHLog.h"
#include "Gizmos/SHTransformGizmo.h"
#include "Events/SHEventDefines.h"
#include "Events/SHEvent.h"

View File

@ -166,14 +166,14 @@ namespace SHADE
const ImGuiWindow* const window = ImGui::GetCurrentWindow();
if (window->SkipItems)
return false;
static constexpr float defaultLabelColWidth = 80.0f;
const ImGuiContext& g = *GImGui;
bool valueChanged = false;
ImGui::BeginGroup();
ImGui::PushID(label.c_str());
PushMultiItemsWidthsAndLabels(componentLabels, 0.0f);
ImGui::BeginColumns("DragVecCol", 2, ImGuiOldColumnFlags_NoBorder | ImGuiOldColumnFlags_NoResize);
ImGui::SetColumnWidth(-1, 80.0f);
ImGui::SetColumnWidth(-1, defaultLabelColWidth);
ImGui::Text(label.c_str());
if (isHovered)
*isHovered |= ImGui::IsItemHovered();
@ -219,7 +219,7 @@ namespace SHADE
}
bool const changed = DragN<float, 2>(label, componentLabels, { &values.x, &values.y }, speed, displayFormat, valueMin, valueMax, flags);
static bool startRecording = false;
if (changed)
if (!(flags & ImGuiSliderFlags_ReadOnly) && changed)
{
if(isAnAngleInRad)
{
@ -255,7 +255,7 @@ namespace SHADE
bool isHovered = false;
bool const changed = DragN<float, 3>(label, componentLabels, { &values.x, &values.y, &values.z }, speed, displayFormat, valueMin, valueMax, flags, &isHovered);
static bool startRecording = false;
if (changed)
if (!(flags & ImGuiSliderFlags_ReadOnly) && changed)
{
SHVec3 old = get();
if(isAnAngleInRad)
@ -293,7 +293,7 @@ namespace SHADE
}
bool const changed = DragN<float, 4>(label, componentLabels, { &values.x, &values.y, &values.z, &values.w }, speed, displayFormat, valueMin, valueMax, flags);
static bool startRecording = false;
if (changed)
if (!(flags & ImGuiSliderFlags_ReadOnly) && changed)
{
if(isAnAngleInRad)
{

View File

@ -12,11 +12,11 @@
//TODO Legacy code. Delete soon
#include <SHpch.h>
#include <chrono>
#include <cassert>
#include <SHpch.h>
#include "SHFramerateController.h"
#include "../Tools/SHLogger.h"
namespace SHADE
{

View File

@ -3,7 +3,7 @@
#include "SHVkCommandPool.h"
#include "Graphics/Devices/SHVkLogicalDevice.h"
#include "SHVkCommandPool.h"
#include "Tools/SHLogger.h"
#include "Tools/Logger/SHLogger.h"
#include "Graphics/Renderpass/SHVkRenderpass.h"
#include "Graphics/Framebuffer/SHVkFramebuffer.h"
#include "Graphics/Pipeline/SHVkPipeline.h"

View File

@ -3,7 +3,7 @@
#include "Graphics/Devices/SHVkLogicalDevice.h"
#include "Graphics/Instance/SHVkInstance.h"
#include "Resource/SHResourceLibrary.h"
#include "Tools/SHLogger.h"
#include "Tools/Logger/SHLogger.h"
namespace SHADE
{

View File

@ -1,6 +1,6 @@
#include "SHPch.h"
#include "SHValidationLayersQuery.h"
#include "Tools/SHLogger.h"
#include "Tools/Logger/SHLogger.h"
namespace SHADE
{

View File

@ -3,8 +3,8 @@
#include "SHVkDebugMessenger.h"
#include "SHVulkanDebugUtil.h"
#include "Graphics/Instance/SHVkInstance.h"
#include "Tools/SHLogger.h"
//#include "Tools/SHLogger.h"
#include "Tools/Logger/SHLogger.h"
//#include "Tools/Logger/SHLogger.h"
namespace SHADE
{

View File

@ -1,6 +1,6 @@
#include "SHPch.h"
#include "SHVulkanDebugUtil.h"
#include "Tools/SHLogger.h"
#include "Tools/Logger/SHLogger.h"
namespace SHADE
{

View File

@ -6,7 +6,7 @@
#include "SHVkDescriptorPool.h"
#include "Graphics/Devices/SHVkLogicalDevice.h"
#include "Graphics/Descriptors/SHVkDescriptorSetLayout.h"
#include "Tools/SHLogger.h"
#include "Tools/Logger/SHLogger.h"
#include "Graphics/Images/SHVkImage.h"
#include "Graphics/Images/SHVkImageView.h"
#include "Graphics/Images/SHVkSampler.h"

View File

@ -2,7 +2,7 @@
#include "SHVkLogicalDevice.h"
#include "SHVkPhysicalDevice.h"
#include "Graphics/Instance/SHVkInstance.h"
#include "Tools/SHLogger.h"
#include "Tools/Logger/SHLogger.h"
#include "Graphics/Windowing/Surface/SHVkSurface.h"
#include "Graphics/Swapchain/SHVkSwapchain.h"
#include "Graphics/Commands/SHVkCommandPool.h"

View File

@ -3,7 +3,7 @@
#include <iostream>
#include <vector>
#include <set>
#include "Tools/SHLogger.h"
#include "Tools/Logger/SHLogger.h"
namespace SHADE
{

View File

@ -3,7 +3,7 @@
#include <unordered_map>
#include "SHVkPhysicalDeviceLibrary.h"
#include "Graphics/Instance/SHVkInstance.h"
#include "Tools/SHLogger.h"
#include "Tools/Logger/SHLogger.h"
namespace SHADE
{

View File

@ -3,7 +3,7 @@
#include "Graphics/Images/SHVkImageView.h"
#include "Graphics/Images/SHVkImage.h"
#include "Graphics/Renderpass/SHVkRenderpass.h"
#include "Tools/SHLogger.h"
#include "Tools/Logger/SHLogger.h"
#include "Graphics/Devices/SHVkLogicalDevice.h"
namespace SHADE

View File

@ -2,7 +2,7 @@
#include "SHVkImage.h"
#include "Graphics/Devices/SHVkLogicalDevice.h"
#include "Graphics/Debugging/SHVulkanDebugUtil.h"
#include "Tools/SHLogger.h"
#include "Tools/Logger/SHLogger.h"
#include "SHVkImageView.h"
#include "Graphics/Instance/SHVkInstance.h"
#include "Graphics/Buffers/SHVkBuffer.h"

View File

@ -2,7 +2,7 @@
#include "SHVkImageView.h"
#include "SHVkImage.h"
#include "Graphics/Devices/SHVkLogicalDevice.h"
#include "Tools/SHLogger.h"
#include "Tools/Logger/SHLogger.h"
namespace SHADE
{

View File

@ -3,7 +3,7 @@
#include "Graphics/Debugging/SHValidationLayersQuery.h"
#include "Graphics/Debugging/SHVkDebugMessenger.h"
#include "Graphics/Devices/SHVkPhysicalDeviceLibrary.h"
#include "Tools/SHLogger.h"
#include "Tools/Logger/SHLogger.h"
#include "Graphics/Devices/SHVkPhysicalDeviceLibrary.h"
//#include <vulkan/vulkan_win32.h>

View File

@ -22,7 +22,7 @@ of DigiPen Institute of Technology is prohibited.
#include "Graphics/MiddleEnd/Interface/SHMaterialInstance.h"
#include "Graphics/Pipeline/SHVkPipeline.h"
#include "ECS_Base/Managers/SHComponentManager.h"
#include "Tools/SHLogger.h"
#include "Tools/Logger/SHLogger.h"
namespace SHADE
{

View File

@ -5,7 +5,7 @@
#include "Graphics/Pipeline/SHVkPipelineLayout.h"
#include "Graphics/Descriptors/SHVkDescriptorSetLayout.h"
#include "Graphics/MiddleEnd/Lights/SHLightData.h"
#include "Tools/SHUtilities.h"
#include "Tools/Utilities/SHUtilities.h"
namespace SHADE
{

View File

@ -17,6 +17,7 @@ of DigiPen Institute of Technology is prohibited.
// Project Includes
#include "Resource/SHHandle.h"
#include "SHCommonTypes.h"
#include "SH_API.h"
namespace SHADE
{
@ -35,7 +36,7 @@ namespace SHADE
Describes a Pipeline along with it's associated properties for this instance.
*/
/***********************************************************************************/
class SHMaterial : public ISelfHandle<SHMaterial>
class SH_API SHMaterial : public ISelfHandle<SHMaterial>
{
public:
/*-----------------------------------------------------------------------------*/

View File

@ -15,7 +15,7 @@ of DigiPen Institute of Technology is prohibited.
#include "SHGraphicsConstants.h"
#include "SHMaterial.h"
#include "Graphics/Pipeline/SHVkPipeline.h"
#include "Tools/SHLogger.h"
#include "Tools/Logger/SHLogger.h"
namespace SHADE
{

View File

@ -43,9 +43,9 @@ namespace SHADE
/*-----------------------------------------------------------------------------*/
struct OverrideData
{
size_t Index;
size_t DataSize;
size_t StoredDataOffset;
uint32_t Index;
uint32_t DataSize;
uint32_t StoredDataOffset;
};
/*-----------------------------------------------------------------------------*/

View File

@ -11,6 +11,7 @@ of DigiPen Institute of Technology is prohibited.
*//*************************************************************************************/
#pragma once
#include "SHMaterialInstance.h"
#include "SHMaterial.h"
namespace SHADE
{
@ -34,9 +35,20 @@ namespace SHADE
dataStore.reset(new char[dataStoreSize]);
}
// Check if this was stored before
const uint32_t VAR_IDX = SHADER_INFO->GetVariableIndex(key);
auto existingOverride = std::find_if(overrideData.begin(), overrideData.end(), [&](const OverrideData& od)
{
return od.Index == VAR_IDX;
});
// Otherwise, create it
if (existingOverride == overrideData.end())
{
OverrideData od;
od.Index = SHADER_INFO->GetVariableIndex(key);
od.Index = VAR_IDX;
od.DataSize = sizeof(T);
if (overrideData.empty())
{
od.StoredDataOffset = 0;
@ -47,12 +59,14 @@ namespace SHADE
od.StoredDataOffset = lastInsertedData.StoredDataOffset + lastInsertedData.DataSize;
}
// Get offset and modify the memory directly
T* dataPtr = reinterpret_cast<T*>(dataStore.get() + od.StoredDataOffset);
*dataPtr = value;
// Save the override data information
overrideData.emplace_back(std::move(od));
existingOverride = overrideData.end() - 1;
}
// Get offset and modify the memory directly
T* dataPtr = reinterpret_cast<T*>(dataStore.get() + existingOverride->StoredDataOffset);
*dataPtr = value;
// Flag
dataWasChanged = true;
@ -73,8 +87,19 @@ namespace SHADE
{
return PROP_IDX == data.Index;
});
// No overrides, we get from the base material instead
if (prop == overrideData.end())
{
if (baseMaterial)
{
return baseMaterial->GetProperty<T>(key);
}
else
{
throw std::invalid_argument("Attempted to get an property that was not set previously!");
}
}
// Get offset and return the memory directly
T* dataPtr = reinterpret_cast<T*>(dataStore.get() + prop->StoredDataOffset);

View File

@ -91,6 +91,7 @@ namespace SHADE
{
SHGraphicsSystem* gfxSystem = SHSystemManager::GetSystem<SHGraphicsSystem>();
material = gfxSystem->AddMaterialInstanceCopy(sharedMaterial);
matChanged = true;
}
return material;

View File

@ -15,7 +15,7 @@ of DigiPen Institute of Technology is prohibited.
#include "Graphics/Commands/SHVkCommandBuffer.h"
#include "Graphics/Instance/SHVkInstance.h"
#include "Tools/SHLogger.h"
#include "Tools/Logger/SHLogger.h"
#include "SHRenderer.h"
#include "Resource/SHResourceLibrary.h"
#include "Graphics/RenderGraph/SHRenderGraph.h"

View File

@ -1,7 +1,7 @@
#include "SHpch.h"
#include "SHLightingSubSystem.h"
#include "Graphics/MiddleEnd/GlobalData/SHGraphicsGlobalData.h"
#include "Tools/SHUtilities.h"
#include "Tools/Utilities/SHUtilities.h"
#include "Graphics/Devices/SHVkLogicalDevice.h"
#include "Graphics/Buffers/SHVkBuffer.h"
#include "Graphics/Descriptors/SHVkDescriptorSetGroup.h"

View File

@ -1,6 +1,6 @@
#include "SHPch.h"
#include "SHRenderContext.h"
#include "Tools/SHLogger.h"
#include "Tools/Logger/SHLogger.h"
#include "Graphics/Devices/SHVkLogicalDevice.h"
#include "Graphics/Swapchain/SHVkSwapchain.h"

View File

@ -19,7 +19,7 @@ of DigiPen Institute of Technology is prohibited.
#include "Graphics/Buffers/SHVkBuffer.h"
#include "Graphics/Commands/SHVkCommandBuffer.h"
#include "Graphics/SHVkUtil.h"
#include "Tools/SHLogger.h"
#include "Tools/Logger/SHLogger.h"
#include "Graphics/MiddleEnd/Interface/SHGraphicsConstants.h"
#include "Graphics/Descriptors/SHVkDescriptorSetGroup.h"
#include "Graphics/Images/SHVkImage.h"

View File

@ -2,7 +2,7 @@
#include "SHVkPipelineLayout.h"
#include "Graphics/Devices/SHVkLogicalDevice.h"
#include "Graphics/Shaders/SHVkShaderModule.h"
#include "Tools/SHLogger.h"
#include "Tools/Logger/SHLogger.h"
#include "Graphics/Instance/SHVkInstance.h"
namespace SHADE

View File

@ -1,6 +1,6 @@
#include "SHPch.h"
#include "SHVkQueue.h"
#include "Tools/SHLogger.h"
#include "Tools/Logger/SHLogger.h"
#include "Graphics/Devices/SHVkLogicalDevice.h"
#include "Graphics/Synchronization/SHVkSemaphore.h"
#include "Graphics/Synchronization/SHVkFence.h"

View File

@ -7,7 +7,7 @@
#include "Graphics/Images/SHVkImageView.h"
#include "Graphics/Framebuffer/SHVkFramebuffer.h"
#include "Graphics/Buffers/SHVkBuffer.h"
#include "Tools/SHLogger.h"
#include "Tools/Logger/SHLogger.h"
#include "SHAttachmentDescInitParams.h"
#include "SHRenderGraphStorage.h"
#include "Graphics/RenderGraph/SHRenderGraphNodeCompute.h"

View File

@ -1,6 +1,6 @@
#include "SHPch.h"
#include "SHShaderBlockInterface.h"
#include "Tools/SHLogger.h"
#include "Tools/Logger/SHLogger.h"
namespace SHADE
{

View File

@ -1,6 +1,6 @@
#include "SHPch.h"
#include "SHShaderReflected.h"
#include "Tools/SHLogger.h"
#include "Tools/Logger/SHLogger.h"
#include "Graphics/Instance/SHVkInstance.h"

View File

@ -2,7 +2,7 @@
#include "SHVkShaderModule.h"
#include "Graphics/Devices/SHVkLogicalDevice.h"
#include "Graphics/Debugging/SHVulkanDebugUtil.h"
#include "Tools/SHLogger.h"
#include "Tools/Logger/SHLogger.h"
namespace SHADE
{

View File

@ -3,7 +3,7 @@
#include "Graphics/Devices/SHVkPhysicalDevice.h"
#include "Graphics/Devices/SHVkLogicalDevice.h"
#include "Graphics/Windowing/Surface/SHVkSurface.h"
#include "Tools/SHLogger.h"
#include "Tools/Logger/SHLogger.h"
#include "Graphics/Images/SHVkImage.h"
#include "Graphics/Instance/SHVkInstance.h"

View File

@ -4,7 +4,7 @@
#include "Graphics/Devices/SHVkLogicalDevice.h"
#include "Graphics/Instance/SHVkInstance.h"
#include "Graphics/Debugging/SHVulkanDebugUtil.h"
#include "Tools/SHLogger.h"
#include "Tools/Logger/SHLogger.h"
namespace SHADE
{

View File

@ -483,6 +483,16 @@ namespace SHADE
return result;
}
SHMatrix SHMatrix::Transform(const SHVec3& pos, const SHVec3& eulerAngles, const SHVec3& scale) noexcept
{
return Scale(scale) * Rotate(eulerAngles) * Translate(pos);
}
SHMatrix SHMatrix::Transform(const SHVec3& pos, const SHQuaternion& rot, const SHVec3& scale) noexcept
{
return Scale(scale) * Rotate(rot) * Translate(pos);
}
SHMatrix SHMatrix::LookAtRH(const SHVec3& eye, const SHVec3& target, const SHVec3& up) noexcept
{
SHMatrix result;

View File

@ -149,6 +149,9 @@ namespace SHADE
[[nodiscard]] static SHMatrix Scale (float x, float y, float z) noexcept;
[[nodiscard]] static SHMatrix Scale (const SHVec3& scale) noexcept;
[[nodiscard]] static SHMatrix Transform (const SHVec3& pos, const SHVec3& eulerAngles, const SHVec3& scale) noexcept;
[[nodiscard]] static SHMatrix Transform (const SHVec3& pos, const SHQuaternion& rot, const SHVec3& scale) noexcept;
[[nodiscard]] static SHMatrix LookAtRH (const SHVec3& eye, const SHVec3& target, const SHVec3& up) noexcept;
[[nodiscard]] static SHMatrix LookAtLH (const SHVec3& eye, const SHVec3& target, const SHVec3& up) noexcept;
[[nodiscard]] static SHMatrix CamToWorldRH (const SHVec3& pos, const SHVec3& forward, const SHVec3& up) noexcept;

View File

@ -16,7 +16,7 @@
#include "Vector/SHVec3.h"
#include "SHMatrix.h"
#include "SHMathHelpers.h"
#include "Tools/SHLogger.h"
#include "Tools/Logger/SHLogger.h"
using namespace DirectX;

View File

@ -14,7 +14,7 @@
#include "SHVec2.h"
// Project Headers
#include "Math/SHMatrix.h"
#include "Tools/SHLogger.h"
#include "Tools/Logger/SHLogger.h"
using namespace DirectX;

View File

@ -15,7 +15,7 @@
// Project Headers
#include "Math/SHMatrix.h"
#include "Math/SHQuaternion.h"
#include "Tools/SHLogger.h"
#include "Tools/Logger/SHLogger.h"
using namespace DirectX;

View File

@ -15,7 +15,7 @@
// Project Headers
#include "Math/SHMatrix.h"
#include "Math/SHColour.h"
#include "Tools/SHLogger.h"
#include "Tools/Logger/SHLogger.h"
using namespace DirectX;

View File

@ -15,7 +15,7 @@
// Project Headers
#include "ECS_Base/Managers/SHEntityManager.h"
#include "Tools/SHUtilities.h"
#include "Tools/Utilities/SHUtilities.h"
namespace SHADE
{

View File

@ -16,7 +16,7 @@
#include "ECS_Base/System/SHSystemRoutine.h"
#include "Math/SHColour.h"
#include "SHPhysicsSystem.h"
#include "Tools/SHUtilities.h"
#include "Tools/Utilities/SHUtilities.h"
namespace SHADE
{

View File

@ -20,7 +20,7 @@ of DigiPen Institute of Technology is prohibited.
#include "Assets/Asset Types/SHAssetIncludes.h"
#include "Graphics/MiddleEnd/Interface/SHGraphicsSystem.h"
#include "ECS_Base/Managers/SHSystemManager.h"
#include "Tools/SHLog.h"
#include "Tools/Logger/SHLog.h"
#include "Graphics/Shaders/SHVkShaderModule.h"
#include "Graphics/Devices/SHVkLogicalDevice.h"
#include "Graphics/MiddleEnd/Materials/SHMaterialSpec.h"

View File

@ -37,5 +37,5 @@
#include <span>
#include "Common/SHCommonTypes.h"
#include "Tools/SHLogger.h"
#include "Tools/Logger/SHLogger.h"
#include "Tools/SHException.h"

View File

@ -20,7 +20,7 @@ of DigiPen Institute of Technology is prohibited.
#include <array>
// External Dependencies
#include <shlwapi.h> // PathRemoveFileSpecA
#include "Tools/SHLogger.h"
#include "Tools/Logger/SHLogger.h"
namespace SHADE
{

View File

@ -19,8 +19,8 @@ of DigiPen Institute of Technology is prohibited.
#include <memory> // std::shared_ptr
#include <thread> // std::this_thread::sleep_for
// Project Headers
#include "Tools/SHLogger.h"
#include "Tools/SHStringUtils.h"
#include "Tools/Logger/SHLogger.h"
#include "Tools/Utilities/SHStringUtilities.h"
#include "ECS_Base/Events/SHEntityDestroyedEvent.h"
#include "Events/SHEvent.h"
#include "Events/SHEventReceiver.h"
@ -616,7 +616,7 @@ namespace SHADE
auto err = GetLastError();
std::ostringstream oss;
oss << "[ScriptEngine] Failed to launch process. Error code: " << std::hex << err
<< " (" << SHStringUtils::GetWin32ErrorMessage(err) << ")";
<< " (" << SHStringUtilities::GetWin32ErrorMessage(err) << ")";
throw std::runtime_error(oss.str());
}
@ -630,7 +630,7 @@ namespace SHADE
auto err = GetLastError();
std::ostringstream oss;
oss << "[ScriptEngine] Failed to query process. Error code: " << std::hex << err
<< " (" << SHStringUtils::GetWin32ErrorMessage(err) << ")";
<< " (" << SHStringUtilities::GetWin32ErrorMessage(err) << ")";
throw std::runtime_error(oss.str());
}
@ -647,7 +647,7 @@ namespace SHADE
std::wstring SHScriptEngine::generateBuildCommand(bool debug)
{
std::wostringstream oss;
oss << "dotnet build \"" << SHStringUtils::StrToWstr(CSPROJ_PATH) << "\" -c ";
oss << "dotnet build \"" << SHStringUtilities::StrToWstr(CSPROJ_PATH) << "\" -c ";
oss << debug ? "Debug" : "Release";
oss << " -o \"./tmp/\" -fl -flp:LogFile=build.log;Verbosity=quiet -r \"win-x64\"";
return oss.str();

View File

@ -179,7 +179,9 @@ namespace SHADE
{
if (ComponentType* component = SHComponentManager::GetComponent_s<ComponentType>(eid))
{
componentsNode[rttr::type::get<ComponentType>().get_name().data()] = YAML::convert<ComponentType>::encode(*component);
auto componentNode = YAML::convert<ComponentType>::encode(*component);
componentNode[IsActive.data()] = component->isActive;
componentsNode[rttr::type::get<ComponentType>().get_name().data()] = componentNode;
}
}

View File

@ -9,11 +9,13 @@
#include "ECS_Base/Managers/SHComponentManager.h"
#include "Graphics/MiddleEnd/Materials/SHMaterialSpec.h"
#include "Tools/SHLog.h"
#include "Tools/Logger/SHLog.h"
namespace SHADE
{
static constexpr std::string_view IsActive = "IsActive";
using AssetQueue = std::unordered_map<AssetID, AssetType>;
struct SHSerializationHelper
{
@ -118,9 +120,9 @@ namespace SHADE
YAML::Node node{};
if (!component)
return node;
auto componentType = rttr::type::get<ComponentType>();
node = RTTRToNode(*component);
node[IsActive.data()] = component->isActive;
return node;
}
@ -198,6 +200,9 @@ namespace SHADE
auto componentNode = componentsNode[rttrType.get_name().data()];
if (!componentNode.IsDefined())
return;
if(componentNode[IsActive.data()].IsDefined())
component->isActive = componentNode[IsActive.data()].as<bool>();
auto properties = rttrType.get_properties();
for (auto const& prop : properties)
{
@ -227,8 +232,10 @@ namespace SHADE
auto component = SHComponentManager::GetComponent_s<ComponentType>(eid);
if (componentsNode.IsNull() && !component)
return;
YAML::convert<ComponentType>::decode(GetComponentNode<ComponentType>(componentsNode, eid), *component);
auto componentNode = GetComponentNode<ComponentType>(componentsNode, eid);
if (componentNode[IsActive.data()].IsDefined())
component->isActive = componentNode[IsActive.data()].as<bool>();
YAML::convert<ComponentType>::decode(componentNode, *component);
}
template <typename ComponentType, std::enable_if_t<std::is_base_of_v<SHComponent, ComponentType>, bool> = true>

View File

@ -44,13 +44,6 @@ namespace SHADE
SHLOG_FLOOR()
}
#ifdef _DEBUG
void SHLog::Trace(const std::string& msg) noexcept
{
SHLOG_TRACE(msg)
}
#endif
void SHLog_Info(const char* msg) noexcept
{
SHLOG_INFO(msg)

View File

@ -323,34 +323,6 @@ namespace SHADE
SHLOG_FLOOR()
}
#ifdef _DEBUG
void SHLogger::LogTrace(const std::string& msg) noexcept
{
SHLOG_TRACE(msg)
}
void SHLogger::LogVerboseTrace(const std::string& msg, const std::source_location& src) noexcept
{
const bool SHOW_SRC_FILE = configFlags & (1U << 3);
const bool SHOW_SRC_LINE = configFlags & (1U << 4);
std::stringstream ss;
ss << "[";
if (SHOW_SRC_FILE)
{
ss << std::filesystem::path(src.file_name()).filename().string() << ", ";
if (SHOW_SRC_LINE)
{
ss << src.line() << ", ";
}
}
ss << src.function_name() << "] " << msg;
SHLOG_TRACE(ss.str())
}
#endif
/*-----------------------------------------------------------------------------------*/
/* Private Function Member Definitions */
/*-----------------------------------------------------------------------------------*/

View File

@ -177,8 +177,34 @@ namespace SHADE
/*-------------------------------------------------------------------------------------*/
#ifdef _DEBUG
#define SHLOG_TRACE(format, ...) SHADE::SHLogger::UseTrivialPattern(); SPDLOG_LOGGER_TRACE(spdlog::get(SHLOGGER_NAME), format, ## __VA_ARGS__);
#define SHLOGV_TRACE(format, ...) SHADE::SHLogger::UseVerbosePattern(); SPDLOG_LOGGER_TRACE(spdlog::get(SHLOGGER_NAME), format, ## __VA_ARGS__);
#define SHLOG_INFO_D(format, ...) SHADE::SHLogger::UseTrivialPattern(); SPDLOG_LOGGER_INFO(spdlog::get(SHLOGGER_NAME), format, ## __VA_ARGS__);
#define SHLOGV_INFO_D(format, ...) SHADE::SHLogger::UseVerbosePattern(); SPDLOG_LOGGER_INFO(spdlog::get(SHLOGGER_NAME), format, ## __VA_ARGS__);
#define SHLOG_WARNING_D(format, ...) SHADE::SHLogger::UseTrivialPattern(); SPDLOG_LOGGER_WARN(spdlog::get(SHLOGGER_NAME), format, ## __VA_ARGS__);
#define SHLOGV_WARNING_D(format, ...) SHADE::SHLogger::UseVerbosePattern(); SPDLOG_LOGGER_WARN(spdlog::get(SHLOGGER_NAME), format, ## __VA_ARGS__);
#define SHLOG_ERROR_D(format, ...) SHADE::SHLogger::UseTrivialPattern(); SPDLOG_LOGGER_ERROR(spdlog::get(SHLOGGER_NAME), format, ## __VA_ARGS__);
#define SHLOGV_ERROR_D(format, ...) SHADE::SHLogger::UseVerbosePattern(); SPDLOG_LOGGER_ERROR(spdlog::get(SHLOGGER_NAME), format, ## __VA_ARGS__);
#define SHLOG_CRITICAL_D(format, ...) SHADE::SHLogger::UseTrivialPattern(); SPDLOG_LOGGER_CRITICAL(spdlog::get(SHLOGGER_NAME), format, ## __VA_ARGS__);
#define SHLOGV_CRITICAL_D(format, ...) SHADE::SHLogger::UseVerbosePattern(); SPDLOG_LOGGER_CRITICAL(spdlog::get(SHLOGGER_NAME), format, ## __VA_ARGS__);
#else
#define SHLOG_INFO_D(format, ...)
#define SHLOGV_INFO_D(format, ...)
#define SHLOG_WARNING_D(format, ...)
#define SHLOGV_WARNING_D(format, ...)
#define SHLOG_ERROR_D(format, ...)
#define SHLOGV_ERROR_D(format, ...)
#define SHLOG_CRITICAL_D(format, ...)
#define SHLOGV_CRITICAL_D(format, ...)
#endif
#define SHLOG_INFO(format, ...) SHADE::SHLogger::UseTrivialPattern(); SPDLOG_LOGGER_INFO(spdlog::get(SHLOGGER_NAME), format, ## __VA_ARGS__);

View File

@ -18,7 +18,7 @@
#include <cstdlib>
// Project Headers
#include "SHLogger.h"
#include "Logger/SHLogger.h"
namespace SHADE
{

View File

@ -12,10 +12,8 @@
// Primary Header
#include "SHExceptionHandler.h"
// Project Headers
#include "SHException.h"
#include "SHLogger.h"
namespace SHADE
{

View File

@ -1,5 +1,5 @@
/************************************************************************************//*!
\file StringUtilities.cpp
\file SHStringUtilities.cpp
\author Tng Kah Wei, kahwei.tng, 390009620
\par email: kahwei.tng\@digipen.edu
\date Nov 29, 2021
@ -12,22 +12,22 @@ of DigiPen Institute of Technology is prohibited.
// Precompiled Header
#include <SHpch.h>
// Primary Header
#include "SHStringUtils.h"
#include "SHStringUtilities.h"
namespace SHADE
{
/*---------------------------------------------------------------------------------*/
/* Utility Functions */
/*---------------------------------------------------------------------------------*/
std::vector<std::string> SHStringUtils::Split(const std::string& str, const char& delim)
std::vector<std::string> SHStringUtilities::Split(const std::string& str, const char& delim)
{
return Split<char>(str, delim);
}
std::vector<std::wstring> SHStringUtils::Split(const std::wstring& str, const wchar_t& delim)
std::vector<std::wstring> SHStringUtilities::Split(const std::wstring& str, const wchar_t& delim)
{
return Split<wchar_t>(str, delim);
}
std::string SHStringUtils::WstrToStr(const std::wstring& wstr)
std::string SHStringUtilities::WstrToStr(const std::wstring& wstr)
{
static std::vector<char> buffer;
const int STR_SIZE = WideCharToMultiByte(CP_UTF8, 0, wstr.data(), static_cast<int>(wstr.size()), nullptr, 0, nullptr, nullptr) + 1 /* Null Terminator */;
@ -35,7 +35,7 @@ namespace SHADE
WideCharToMultiByte(CP_UTF8, 0, wstr.data(), static_cast<int>(wstr.size()), buffer.data(), MAX_PATH, nullptr, nullptr);
return std::string(buffer.data());
}
std::wstring SHStringUtils::StrToWstr(const std::string& str)
std::wstring SHStringUtilities::StrToWstr(const std::string& str)
{
static std::vector<wchar_t> buffer;
const int WSTR_SIZE = MultiByteToWideChar(CP_UTF8, 0, str.data(), static_cast<int>(str.size()), nullptr, 0) + 1 /* Null Terminator */;
@ -44,7 +44,7 @@ namespace SHADE
return std::wstring(buffer.data());
}
std::string SHStringUtils::GetWin32ErrorMessage(unsigned long errorCode)
std::string SHStringUtilities::GetWin32ErrorMessage(unsigned long errorCode)
{
return std::system_category().message(errorCode);
}

View File

@ -1,5 +1,5 @@
/************************************************************************************//*!
\file StringUtilities.h
\file SHStringUtilities.h
\author Tng Kah Wei, kahwei.tng, 390009620
\par email: kahwei.tng\@digipen.edu
\date Nov 29, 2021
@ -19,7 +19,7 @@ namespace SHADE
/// <summary>
/// Contains useful functions for operating on strings.
/// </summary>
class SHStringUtils
class SHStringUtilities
{
public:
/*-----------------------------------------------------------------------------*/
@ -74,8 +74,8 @@ namespace SHADE
/*-------------------------------------------------------------------------------*/
/* Constructors/Destructors */
/*-------------------------------------------------------------------------------*/
SHStringUtils() = delete;
SHStringUtilities() = delete;
};
}
#include "SHStringUtils.hpp"
#include "SHStringUtilities.hpp"

View File

@ -1,5 +1,5 @@
/************************************************************************************//*!
\file StringUtilities.hpp
\file SHStringUtilities.hpp
\author Tng Kah Wei, kahwei.tng, 390009620
\par email: kahwei.tng\@digipen.edu
\date Nov 29, 2021
@ -12,7 +12,7 @@ of DigiPen Institute of Technology is prohibited.
*//*************************************************************************************/
#pragma once
// Primary Header
#include "SHStringUtils.h"
#include "SHStringUtilities.h"
namespace SHADE
{
@ -20,7 +20,7 @@ namespace SHADE
/* Template Function Definitions */
/*-------------------------------------------------------------------------------*/
template<typename T>
inline std::vector<std::basic_string<T>> SHStringUtils::Split(const std::basic_string<T>& str, const T& delim)
inline std::vector<std::basic_string<T>> SHStringUtilities::Split(const std::basic_string<T>& str, const T& delim)
{
std::vector<std::basic_string<T>> results;
std::basic_string<T> remaining = str;

View File

@ -39,13 +39,15 @@ project "SHADE_Managed"
"%{IncludeDir.dotnet}\\include",
"%{IncludeDir.reactphysics3d}\\include",
"%{IncludeDir.VULKAN}\\include",
"%{IncludeDir.fmod}\\include",
"%{wks.location}/SHADE_Engine/src"
}
libdirs
{
"%{IncludeDir.RTTR}/lib",
"%{IncludeDir.SDL}/lib"
"%{IncludeDir.SDL}/lib",
"%{IncludeDir.fmod}/lib"
}
links
@ -93,16 +95,19 @@ project "SHADE_Managed"
symbols "On"
defines {"_DEBUG"}
links{"librttr_core_d.lib"}
links{"fmodstudioL_vc.lib", "fmodL_vc.lib"}
filter "configurations:Release"
optimize "On"
defines{"_RELEASE"}
links{"librttr_core.lib"}
links{"fmodstudio_vc.lib", "fmod_vc.lib"}
filter "configurations:Publish"
optimize "On"
defines{"_RELEASE"}
links{"librttr_core.lib"}
links{"fmodstudio_vc.lib", "fmod_vc.lib"}
require "vstudio"

View File

@ -0,0 +1,101 @@
/************************************************************************************//*!
\file Audio.cxx
\author Tng Kah Wei, kahwei.tng, 390009620
\par email: kahwei.tng\@digipen.edu
\date Nov 16, 2022
\brief Contains the function definitions of the managed Audio static class.
Note: This file is written in C++17/CLI.
Copyright (C) 2022 DigiPen Institute of Technology.
Reproduction or disclosure of this file or its contents without the prior written consent
of DigiPen Institute of Technology is prohibited.
*//*************************************************************************************/
// Precompiled Header
#include "SHpch.h"
// Primary Header
#include "Audio.hxx"
// External Dependencies
#include "AudioSystem/SHAudioSystem.h"
#include "ECS_Base/Managers/SHSystemManager.h"
#include "Utility/Convert.hxx"
namespace SHADE
{
/*-----------------------------------------------------------------------------*/
/* Properties */
/*-----------------------------------------------------------------------------*/
float Audio::BGMVolume::get()
{
auto audioSys = SHSystemManager::GetSystem<SHAudioSystem>();
return audioSys->GetBgmVolume();
}
void Audio::BGMVolume::set(float value)
{
auto audioSys = SHSystemManager::GetSystem<SHAudioSystem>();
audioSys->SetBgmVolume(System::Math::Clamp(value, 0.0f, 1.0f));
}
float Audio::SFXVolume::get()
{
auto audioSys = SHSystemManager::GetSystem<SHAudioSystem>();
return audioSys->GetSfxVolume();
}
void Audio::SFXVolume::set(float value)
{
auto audioSys = SHSystemManager::GetSystem<SHAudioSystem>();
audioSys->SetSfxVolume(System::Math::Clamp(value, 0.0f, 1.0f));
}
float Audio::MasterVolume::get()
{
auto audioSys = SHSystemManager::GetSystem<SHAudioSystem>();
return audioSys->GetMasterVolume();
}
void Audio::MasterVolume::set(float value)
{
auto audioSys = SHSystemManager::GetSystem<SHAudioSystem>();
audioSys->SetMasterVolume(System::Math::Clamp(value, 0.0f, 1.0f));
}
bool Audio::IsPaused::get()
{
auto audioSys = SHSystemManager::GetSystem<SHAudioSystem>();
return audioSys->GetPaused();
}
void Audio::IsPaused::set(bool value)
{
auto audioSys = SHSystemManager::GetSystem<SHAudioSystem>();
audioSys->SetPaused(value);
}
/*-----------------------------------------------------------------------------*/
/* Playback Control Functions */
/*-----------------------------------------------------------------------------*/
void Audio::PlaySFXOnce2D(System::String^ path)
{
auto audioSys = SHSystemManager::GetSystem<SHAudioSystem>();
audioSys->PlayEventOnce(Convert::ToNative(path).data());
}
void Audio::PlaySFXOnce3D(System::String^ path, GameObject gameObject)
{
auto audioSys = SHSystemManager::GetSystem<SHAudioSystem>();
audioSys->PlayEventOnce(Convert::ToNative(path).data(), true, gameObject.GetEntity(), true);
}
void Audio::PlayBGMOnce2D(System::String^ path)
{
auto audioSys = SHSystemManager::GetSystem<SHAudioSystem>();
audioSys->PlayEventOnce(Convert::ToNative(path).data(), false);
}
void Audio::PlayBGMOnce3D(System::String^ path, GameObject gameObject)
{
auto audioSys = SHSystemManager::GetSystem<SHAudioSystem>();
audioSys->PlayEventOnce(Convert::ToNative(path).data(), false, gameObject.GetEntity(), true);
}
void Audio::StopAllSounds()
{
auto audioSys = SHSystemManager::GetSystem<SHAudioSystem>();
audioSys->StopAllSounds();
}
}

View File

@ -0,0 +1,103 @@
/************************************************************************************//*!
\file Audio.hxx
\author Tng Kah Wei, kahwei.tng, 390009620
\par email: kahwei.tng\@digipen.edu
\date Nov 16, 2022
\brief Contains the definitions of the managed Audio static class.
Note: This file is written in C++17/CLI.
Copyright (C) 2022 DigiPen Institute of Technology.
Reproduction or disclosure of this file or its contents without the prior written consent
of DigiPen Institute of Technology is prohibited.
*//*************************************************************************************/
#pragma once
#include "Engine/GameObject.hxx"
namespace SHADE
{
/// <summary>
/// Static class that contains the functions for interfacing with the Audio system.
/// </summary>
public ref class Audio abstract sealed
{
public:
/*-----------------------------------------------------------------------------*/
/* Properties */
/*-----------------------------------------------------------------------------*/
/// <summary>
/// Volume of background music playback. Clamped between 0.0 and 1.0.
/// </summary>
static property float BGMVolume
{
float get();
void set(float value);
}
/// <summary>
/// Volume of sound effects playback. Clamped between 0.0 and 1.0.
/// </summary>
static property float SFXVolume
{
float get();
void set(float value);
}
/// <summary>
/// Overall volume for all audio playback. Clamped between 0.0 and 1.0.
/// </summary>
static property float MasterVolume
{
float get();
void set(float value);
}
/// <summary>
/// Whether or not all audio playback is paused.
/// </summary>
static property bool IsPaused
{
bool get();
void set(bool value);
}
/*-----------------------------------------------------------------------------*/
/* Playback Control Functions */
/*-----------------------------------------------------------------------------*/
/// <summary>
/// Plays a sound effect without looping without spatial attenuation.
/// </summary>
/// <param name="path">
/// Path to the audio file relative to the working directory.
/// </param>
static void PlaySFXOnce2D(System::String^ path);
/// <summary>
/// Plays a sound effect without looping with spatial attenuation.
/// </summary>
/// <param name="path">
/// Path to the audio file relative to the working directory.
/// </param>
/// <param name="gameObject">
/// Object whose position is used to play the sound effect.
/// </param>
static void PlaySFXOnce3D(System::String^ path, GameObject gameObject);
/// <summary>
/// Plays background music without looping without spatial attenuation.
/// </summary>
/// <param name="path">
/// Path to the audio file relative to the working directory.
/// </param>
static void PlayBGMOnce2D(System::String^ path);
/// <summary>
/// Plays background music without looping with spatial attenuation.
/// </summary>
/// <param name="path">
/// Path to the audio file relative to the working directory.
/// </param>
/// <param name="gameObject">
/// Object whose position is used to play the background music.
/// </param>
static void PlayBGMOnce3D(System::String^ path, GameObject gameObject);
/// <summary>
/// Stops playback of all sound effects and music.
/// </summary>
static void StopAllSounds();
};
}

View File

@ -26,7 +26,7 @@ of DigiPen Institute of Technology is prohibited.
#include "Physics/Interface/SHRigidBodyComponent.h"
#include "Scene/SHSceneManager.h"
#include "Scene/SHSceneGraph.h"
#include "Tools/SHLog.h"
#include "Tools/Logger/SHLog.h"
#include "Graphics\MiddleEnd\Interface\SHRenderable.h"
// Project Headers
#include "Utility/Convert.hxx"

View File

@ -52,7 +52,7 @@ namespace SHADE
Vector3 Vector3::GetNormalised()
{
return *this / GetSqrMagnitude();
return *this / GetMagnitude();
}
float Vector3::GetMagnitude()

View File

@ -20,7 +20,7 @@ of DigiPen Institute of Technology is prohibited.
#include <sstream>
// External Dependencies
#include "ECS_Base/Managers/SHEntityManager.h"
#include "Tools/SHLog.h"
#include "Tools/Logger/SHLog.h"
// Project Headers
#include "Utility/Debug.hxx"
#include "Utility/Convert.hxx"

View File

@ -19,7 +19,7 @@ of DigiPen Institute of Technology is prohibited.
// Standard Libraries
#include <sstream>
// External Libraries
#include "Tools/SHLog.h"
#include "Tools/Logger/SHLog.h"
// Project Headers
#include "Convert.hxx"