Merge branch 'main' into SP3-129-AudioSystem

This commit is contained in:
Glence 2022-09-28 17:51:40 +08:00
commit 658562bdc4
28 changed files with 5335 additions and 124 deletions

Binary file not shown.

4993
Assets/racoon.gltf Normal file

File diff suppressed because one or more lines are too long

View File

@ -144,7 +144,7 @@ if %_e%==14 (goto :done) else (goto :tinyddsloader)
:tinyddsloader :tinyddsloader
echo --------------------tinyddsloader------------------------- echo --------------------tinyddsloader-------------------------
rmdir "Dependencies/tinyddsloader" /S /Q rmdir "Dependencies/tinyddsloader" /S /Q
git clone https://github.com/benikabocha/tinyddsloader.git "Dependencies/tinyddsloader" git clone https://github.com/SHADE-DP/tinyddsloader.git "Dependencies/tinyddsloader"
:done :done
echo DONE! echo DONE!

View File

@ -82,4 +82,4 @@ project "SHADE_Application"
filter "configurations:Publish" filter "configurations:Publish"
optimize "On" optimize "On"
defines{"_RELEASE"} defines{"_RELEASE", "_PUBLISH"}

View File

@ -24,6 +24,7 @@
#include "Scene/SHSceneManager.h" #include "Scene/SHSceneManager.h"
#include "Math/Transform/SHTransformSystem.h" #include "Math/Transform/SHTransformSystem.h"
#include "Input/SHInputManagerSystem.h" #include "Input/SHInputManagerSystem.h"
#include "FRC/SHFramerateController.h"
#include "AudioSystem/SHAudioSystem.h" #include "AudioSystem/SHAudioSystem.h"
#include "AudioSystem/SHAudioListenerComponent.h" #include "AudioSystem/SHAudioListenerComponent.h"
@ -81,7 +82,7 @@ namespace Sandbox
SHADE::SHSystemManager::RegisterRoutine<SHADE::SHInputManagerSystem, SHADE::SHInputManagerSystem::InputManagerRoutine>(); SHADE::SHSystemManager::RegisterRoutine<SHADE::SHInputManagerSystem, SHADE::SHInputManagerSystem::InputManagerRoutine>();
//TODO: REMOVE AFTER PRESENTATION //TODO: REMOVE AFTER PRESENTATION
SHADE::SHAssetManager::LoadDataTemp("../../Assets/racoon.fbx"); SHADE::SHAssetManager::LoadDataTemp("../../Assets/racoon.gltf");
SHADE::SHAssetManager::LoadDataTemp("../../Assets/RaccoonBag_Color_Ver4.dds"); SHADE::SHAssetManager::LoadDataTemp("../../Assets/RaccoonBag_Color_Ver4.dds");
SHADE::SHAssetManager::LoadDataTemp("../../Assets/RaccoonPreTexturedVer1_Base9.dds"); SHADE::SHAssetManager::LoadDataTemp("../../Assets/RaccoonPreTexturedVer1_Base9.dds");
//TODO: REMOVE AFTER PRESENTATION //TODO: REMOVE AFTER PRESENTATION
@ -102,6 +103,7 @@ namespace Sandbox
#endif #endif
SHSceneManager::InitSceneManager<SBTestScene>("TestScene"); SHSceneManager::InitSceneManager<SBTestScene>("TestScene");
SHFrameRateController::UpdateFRC();
} }
void SBApplication::Update(void) void SBApplication::Update(void)
@ -110,6 +112,7 @@ namespace Sandbox
//TODO: Change true to window is open //TODO: Change true to window is open
while (!window.WindowShouldClose()) while (!window.WindowShouldClose())
{ {
SHFrameRateController::UpdateFRC();
SHSceneManager::UpdateSceneManager(); SHSceneManager::UpdateSceneManager();
SHSceneManager::SceneUpdate(1/60.0f); SHSceneManager::SceneUpdate(1/60.0f);
//#ifdef SHEDITOR //#ifdef SHEDITOR

View File

@ -42,18 +42,24 @@ namespace Sandbox
std::vector<Handle<SHMesh>> handles; std::vector<Handle<SHMesh>> handles;
for (auto const& mesh : meshes) for (auto const& mesh : meshes)
{ {
handles.push_back(graphicsSystem->AddMesh( if (mesh.meshName == "Cube.012")
mesh.header.vertexCount, {
mesh.vertexPosition.data(), handles.push_back(graphicsSystem->AddMesh(
mesh.texCoords.data(), mesh.header.vertexCount,
mesh.vertexTangent.data(), mesh.vertexPosition.data(),
mesh.vertexNormal.data(), mesh.texCoords.data(),
mesh.header.indexCount, mesh.vertexTangent.data(),
mesh.indices.data() mesh.vertexNormal.data(),
)); mesh.header.indexCount,
mesh.indices.data()
));
}
} }
graphicsSystem->BuildMeshBuffers(); graphicsSystem->BuildMeshBuffers();
//Test Textures
auto textures{ SHADE::SHAssetManager::GetAllTextures() };
// Create Materials // Create Materials
auto matInst = graphicsSystem->AddOrGetBaseMaterialInstance(); auto matInst = graphicsSystem->AddOrGetBaseMaterialInstance();

View File

@ -115,6 +115,9 @@ project "SHADE_Engine"
filter "configurations:Release" filter "configurations:Release"
postbuildcommands {"xcopy /r /y /q \"%{IncludeDir.assimp}\\bin\\Release\\assimp-vc142-mt.dll\" \"$(OutDir)\""} postbuildcommands {"xcopy /r /y /q \"%{IncludeDir.assimp}\\bin\\Release\\assimp-vc142-mt.dll\" \"$(OutDir)\""}
filter "configurations:Publish"
postbuildcommands {"xcopy /r /y /q \"%{IncludeDir.assimp}\\bin\\Release\\assimp-vc142-mt.dll\" \"$(OutDir)\""}
warnings 'Extra' warnings 'Extra'
filter "configurations:Debug" filter "configurations:Debug"
@ -131,7 +134,7 @@ project "SHADE_Engine"
filter "configurations:Publish" filter "configurations:Publish"
optimize "On" optimize "On"
defines{"_RELEASE"} defines{"_RELEASE", "_PUBLISH"}
links{"assimp-vc142-mt.lib", "librttr_core.lib", "spdlog.lib"} links{"assimp-vc142-mt.lib", "librttr_core.lib", "spdlog.lib"}
excludes excludes
{ {

View File

@ -1,11 +0,0 @@
#pragma once
#include "tinyddsloader.h"
namespace SHADE
{
struct SHDDSAsset
{
tinyddsloader::DDSFile image;
};
}

View File

@ -0,0 +1,46 @@
#pragma once
#include "tinyddsloader.h"
#include "Graphics/MiddleEnd/Textures/SHTextureLibrary.h"
#include <memory>
namespace SHADE
{
struct SHTextureAsset
{
uint32_t numBytes;
uint32_t width;
uint32_t height;
SHTexture::TextureFormat format;
std::vector<uint32_t> mipOffsets;
SHTexture::PixelChannel const * pixelData;
SHTextureAsset()
: numBytes{ 0 },
width{ 0 },
height{ 0 },
format{ SHTexture::TextureFormat::eUndefined },
pixelData{ nullptr }
{}
SHTextureAsset(SHTextureAsset const& rhs)
: numBytes{ rhs.numBytes },
width{ rhs.width },
height{ rhs.height },
format{ rhs.format },
mipOffsets{ rhs.mipOffsets },
pixelData(rhs.pixelData)
{}
//SHTextureAsset(SHTextureAsset&& rhs)
// : numBytes{ rhs.numBytes },
// width{ rhs.width },
// height{ rhs.height },
// format{ rhs.format },
// mipOffsets{ rhs.mipOffsets },
// pixelData(std::move(rhs.pixelData))
//{}
};
}

View File

@ -1,38 +0,0 @@
#include "SHpch.h"
#include "SHDDSLoader.h"
namespace SHADE
{
std::string SHDDSLoader::TinyDDSResultToString(tinyddsloader::Result value)
{
switch (value)
{
case tinyddsloader::Result::ErrorFileOpen:
return "File open err";
case tinyddsloader::Result::ErrorRead:
return "File read err";
case tinyddsloader::Result::ErrorMagicWord:
return "File header magicword err";
case tinyddsloader::Result::ErrorSize:
return "File size err";
case tinyddsloader::Result::ErrorVerify:
return "Pixel format err";
case tinyddsloader::Result::ErrorNotSupported:
return "Unsupported format";
case tinyddsloader::Result::ErrorInvalidData:
return "Invalid data";
default:
return "Unknown";
}
}
void SHDDSLoader::LoadImageAsset(AssetPath path, SHDDSAsset& asset)
{
tinyddsloader::Result loadResult = tinyddsloader::Result::Success;
loadResult = asset.image.Load(path.string().c_str());
if (loadResult != tinyddsloader::Result::Success)
{
SHLOG_ERROR("Unable to load DDS file: {} at {}", TinyDDSResultToString(loadResult), path.string());
}
}
}

View File

@ -1,18 +0,0 @@
#pragma once
#define TINYDDSLOADER_IMPLEMENTATION
#include "../SHAssetMacros.h"
#include "../Asset Types/SHDDSAsset.h"
#include "tinyddsloader.h"
#include <vector>
namespace SHADE
{
class SHDDSLoader
{
private:
static std::string TinyDDSResultToString(tinyddsloader::Result value);
public:
static void LoadImageAsset(AssetPath paths, SHDDSAsset& image);
};
}

View File

@ -100,9 +100,7 @@ namespace SHADE
| aiProcess_JoinIdenticalVertices | aiProcess_JoinIdenticalVertices
// join identical vertices/ optimize indexing // join identical vertices/ optimize indexing
| aiProcess_RemoveRedundantMaterials // remove redundant materials | aiProcess_RemoveRedundantMaterials // remove redundant materials
| aiProcess_FindInvalidData | aiProcess_FindInvalidData// detect invalid model data, such as invalid normal vectors
// detect invalid model data, such as invalid normal vectors
| aiProcess_PreTransformVertices // pre-transform all vertices
| aiProcess_FlipUVs // flip the V to match the Vulkans way of doing UVs | aiProcess_FlipUVs // flip the V to match the Vulkans way of doing UVs
); );

View File

@ -0,0 +1,48 @@
#include "SHpch.h"
#include "SHMeshWriter.h"
#include <fstream>
void SHADE::SHMeshWriter::WriteMeshBinary(SHMeshAsset const& asset, AssetPath path) noexcept
{
std::ofstream file{path, std::ios::out | std::ios::binary};
if (!file.is_open())
{
SHLOG_ERROR("Unable to open file for writing mesh file: {}", path.string());
}
file.write(
reinterpret_cast<char const*>(&(asset.header.vertexCount)),
sizeof(uint32_t)
);
file.write(
reinterpret_cast<const char*>(&(asset.header.indexCount)),
sizeof(uint32_t)
);
auto const vertexVec3Byte {sizeof(SHVec3) * asset.header.vertexCount};
auto const vertexVec2Byte {sizeof(SHVec2) * asset.header.vertexCount};
file.write(
reinterpret_cast<char const*>(asset.vertexPosition.data()),
vertexVec3Byte
);
file.write(
reinterpret_cast<char const*>(asset.vertexTangent.data()),
vertexVec3Byte
);
file.write(
reinterpret_cast<char const*>(asset.vertexNormal.data()),
vertexVec3Byte
);
file.write(
reinterpret_cast<char const*>(asset.texCoords.data()),
vertexVec2Byte
);
file.close();
}

View File

@ -0,0 +1,14 @@
#pragma once
#include "../Asset Types/SHMeshAsset.h"
#include "../SHAssetMacros.h"
namespace SHADE
{
class SHMeshWriter
{
private:
public:
static void WriteMeshBinary(SHMeshAsset const& asset, AssetPath path) noexcept;
};
}

View File

@ -0,0 +1,92 @@
#include "SHpch.h"
#include "SHTextureLoader.h"
namespace SHADE
{
std::string SHTextureLoader::TinyDDSResultToString(tinyddsloader::Result value)
{
switch (value)
{
case tinyddsloader::Result::ErrorFileOpen:
return "File open err";
case tinyddsloader::Result::ErrorRead:
return "File read err";
case tinyddsloader::Result::ErrorMagicWord:
return "File header magic word err";
case tinyddsloader::Result::ErrorSize:
return "File size err";
case tinyddsloader::Result::ErrorVerify:
return "Pixel format err";
case tinyddsloader::Result::ErrorNotSupported:
return "Unsupported format";
case tinyddsloader::Result::ErrorInvalidData:
return "Invalid data";
default:
return "Unknown";
}
}
vk::Format SHTextureLoader::ddsLoaderToVkFormat(tinyddsloader::DDSFile::DXGIFormat format, bool isLinear)
{
switch (format)
{
case tinyddsloader::DDSFile::DXGIFormat::BC1_UNorm:
case tinyddsloader::DDSFile::DXGIFormat::BC1_UNorm_SRGB:
return isLinear ? vk::Format::eBc1RgbaUnormBlock : vk::Format::eBc1RgbaSrgbBlock;
case tinyddsloader::DDSFile::DXGIFormat::BC2_UNorm:
case tinyddsloader::DDSFile::DXGIFormat::BC2_UNorm_SRGB:
return isLinear ? vk::Format::eBc2UnormBlock : vk::Format::eBc2SrgbBlock;
case tinyddsloader::DDSFile::DXGIFormat::BC3_UNorm:
case tinyddsloader::DDSFile::DXGIFormat::BC3_UNorm_SRGB:
return isLinear ? vk::Format::eBc3UnormBlock : vk::Format::eBc3SrgbBlock;
case tinyddsloader::DDSFile::DXGIFormat::BC5_UNorm:
case tinyddsloader::DDSFile::DXGIFormat::BC5_SNorm:
return isLinear ? vk::Format::eBc5UnormBlock : vk::Format::eBc5SnormBlock;
case tinyddsloader::DDSFile::DXGIFormat::R8G8B8A8_UNorm:
case tinyddsloader::DDSFile::DXGIFormat::R8G8B8A8_UNorm_SRGB:
return isLinear ? vk::Format::eR8G8B8A8Unorm : vk::Format::eR8G8B8A8Srgb;
case tinyddsloader::DDSFile::DXGIFormat::R8G8B8A8_SNorm:
return vk::Format::eR8G8B8A8Snorm;
case tinyddsloader::DDSFile::DXGIFormat::B8G8R8A8_UNorm:
case tinyddsloader::DDSFile::DXGIFormat::B8G8R8A8_UNorm_SRGB:
return isLinear ? vk::Format::eB8G8R8A8Unorm : vk::Format::eB8G8R8A8Srgb;
case tinyddsloader::DDSFile::DXGIFormat::B8G8R8X8_UNorm:
case tinyddsloader::DDSFile::DXGIFormat::B8G8R8X8_UNorm_SRGB:
return isLinear ? vk::Format::eB8G8R8A8Unorm : vk::Format::eB8G8R8Srgb;
default:
throw std::runtime_error("Unsupported DDS format.");
}
}
void SHTextureLoader::LoadImageAsset(AssetPath path, SHTextureAsset& asset)
{
tinyddsloader::Result loadResult = tinyddsloader::Result::Success;
tinyddsloader::DDSFile file;
loadResult = file.Load(path.string().c_str());
if (loadResult != tinyddsloader::Result::Success)
{
SHLOG_ERROR("Unable to load Texture file: {} at {}", TinyDDSResultToString(loadResult), path.string());
}
size_t totalBytes{ 0 };
std::vector<uint32_t> mipOff(file.GetMipCount());
for (auto i{0}; i < file.GetMipCount(); ++i)
{
mipOff.push_back(totalBytes);
totalBytes += file.GetImageData(i, 0)->m_memSlicePitch;
}
SHTexture::PixelChannel* pixel = new SHTexture::PixelChannel[totalBytes];
std::memcpy(pixel, file.GetDDSData(), totalBytes);
//pixel = std::move(reinterpret_cast<SHTexture::PixelChannel const*>(file.GetDDSData()));
asset.numBytes = totalBytes;
asset.width = file.GetWidth();
asset.height = file.GetHeight();
asset.format = ddsLoaderToVkFormat(file.GetFormat(), true);
asset.mipOffsets = std::move(mipOff);
asset.pixelData = std::move(pixel);
}
}

View File

@ -0,0 +1,19 @@
#pragma once
#define TINYDDSLOADER_IMPLEMENTATION
#include "../SHAssetMacros.h"
#include "../Asset Types/SHTextureAsset.h"
#include "tinyddsloader.h"
namespace SHADE
{
class SHTextureLoader
{
private:
static std::string TinyDDSResultToString(tinyddsloader::Result value);
static vk::Format ddsLoaderToVkFormat(tinyddsloader::DDSFile::DXGIFormat format, bool isLinear);
public:
static void LoadImageAsset(AssetPath paths, SHTextureAsset& image);
};
}

View File

@ -69,8 +69,10 @@ enum class AssetType : uint8_t
#define SCENE_EXTENSION ".SHADE" #define SCENE_EXTENSION ".SHADE"
#define PREFAB_EXTENSION ".SHPrefab" #define PREFAB_EXTENSION ".SHPrefab"
#define MATERIAL_EXTENSION ".SHMat" #define MATERIAL_EXTENSION ".SHMat"
#define TEXTURE_EXTENSION ".dds" #define TEXTURE_EXTENSION ".shtex"
#define DDS_EXTENSION ".dds"
#define FBX_EXTENSION ".fbx" #define FBX_EXTENSION ".fbx"
#define GLTF_EXTENSION ".gltf"
#define MESH_EXTENSION ".shmesh" #define MESH_EXTENSION ".shmesh"
std::string const EXTENSIONS[] = { std::string const EXTENSIONS[] = {
@ -79,12 +81,14 @@ std::string const EXTENSIONS[] = {
MATERIAL_EXTENSION, MATERIAL_EXTENSION,
IMAGE_EXTENSION, IMAGE_EXTENSION,
TEXTURE_EXTENSION, TEXTURE_EXTENSION,
DDS_EXTENSION,
MESH_EXTENSION, MESH_EXTENSION,
SCRIPT_EXTENSION, SCRIPT_EXTENSION,
SCENE_EXTENSION, SCENE_EXTENSION,
PREFAB_EXTENSION, PREFAB_EXTENSION,
AUDIO_WAV_EXTENSION, AUDIO_WAV_EXTENSION,
FBX_EXTENSION FBX_EXTENSION,
GLTF_EXTENSION
}; };
// Error flags // Error flags

View File

@ -15,7 +15,7 @@
#include "Filesystem/SHFileSystem.h" #include "Filesystem/SHFileSystem.h"
#include "Libraries/SHMeshLoader.h" #include "Libraries/SHMeshLoader.h"
#include "Libraries/SHDDSLoader.h" #include "Libraries/SHTextureLoader.h"
namespace SHADE namespace SHADE
{ {
@ -26,7 +26,7 @@ namespace SHADE
std::unordered_map<AssetID, SHAsset> SHAssetManager::assetRegistry; std::unordered_map<AssetID, SHAsset> SHAssetManager::assetRegistry;
std::unordered_map<AssetID, SHMeshAsset> SHAssetManager::meshCollection; std::unordered_map<AssetID, SHMeshAsset> SHAssetManager::meshCollection;
std::unordered_map<AssetID, SHDDSAsset> SHAssetManager::ddsCollection; std::unordered_map<AssetID, SHTextureAsset> SHAssetManager::textureCollection;
/**************************************************************************** /****************************************************************************
* \brief Static function to generate asset ID. * \brief Static function to generate asset ID.
@ -199,7 +199,7 @@ namespace SHADE
{ {
AssetPath path{ p }; AssetPath path{ p };
if (path.extension().string() == FBX_EXTENSION) if (path.extension().string() == GLTF_EXTENSION)
{ {
LoadGLTF( LoadGLTF(
{ {
@ -211,7 +211,7 @@ namespace SHADE
} }
); );
} }
else if (path.extension().string() == TEXTURE_EXTENSION) else if (path.extension().string() == DDS_EXTENSION)
{ {
LoadDDS( LoadDDS(
{ {
@ -236,10 +236,10 @@ namespace SHADE
return result; return result;
} }
std::vector<SHDDSAsset> SHAssetManager::GetAllDDS() noexcept std::vector<SHTextureAsset> SHAssetManager::GetAllTextures() noexcept
{ {
std::vector<SHDDSAsset> result; std::vector<SHTextureAsset> result;
for (auto const& dds : ddsCollection) for (auto const& dds : textureCollection)
{ {
result.push_back(dds.second); result.push_back(dds.second);
} }
@ -305,11 +305,11 @@ namespace SHADE
void SHAssetManager::LoadDDS(SHAsset asset) noexcept void SHAssetManager::LoadDDS(SHAsset asset) noexcept
{ {
SHDDSAsset image; SHTextureAsset image;
SHDDSLoader::LoadImageAsset(asset.path, image); SHTextureLoader::LoadImageAsset(asset.path, image);
ddsCollection.emplace(GenerateAssetID(AssetType::DDS), image); textureCollection.emplace(GenerateAssetID(AssetType::DDS), image);
} }
/**************************************************************************** /****************************************************************************

View File

@ -13,7 +13,7 @@
#include "SHAsset.h" #include "SHAsset.h"
#include "Asset Types/SHMeshAsset.h" #include "Asset Types/SHMeshAsset.h"
#include "Asset Types/SHDDSAsset.h" #include "Asset Types/SHTextureAsset.h"
#include "SH_API.h" #include "SH_API.h"
namespace SHADE namespace SHADE
@ -73,7 +73,7 @@ namespace SHADE
//TODO: TEMPORARY FOR TESTING GLTF & DDS //TODO: TEMPORARY FOR TESTING GLTF & DDS
static void LoadDataTemp(std::string path) noexcept; static void LoadDataTemp(std::string path) noexcept;
static std::vector<SHMeshAsset> GetAllMeshes() noexcept; static std::vector<SHMeshAsset> GetAllMeshes() noexcept;
static std::vector<SHDDSAsset> GetAllDDS() noexcept; static std::vector<SHTextureAsset> GetAllTextures() noexcept;
private: private:
/**************************************************************************** /****************************************************************************
@ -128,6 +128,6 @@ namespace SHADE
static std::unordered_map<AssetID, SHAsset> assetRegistry; static std::unordered_map<AssetID, SHAsset> assetRegistry;
static std::unordered_map<AssetID, SHMeshAsset> meshCollection; static std::unordered_map<AssetID, SHMeshAsset> meshCollection;
static std::unordered_map<AssetID, SHDDSAsset> ddsCollection; static std::unordered_map<AssetID, SHTextureAsset> textureCollection;
}; };
} }

View File

@ -9,12 +9,31 @@
consent of DigiPen Institute of Technology is prohibited. consent of DigiPen Institute of Technology is prohibited.
*********************************************************************/ *********************************************************************/
//TODO Legacy code. Delete soon
#include <chrono> #include <chrono>
#include <cassert> #include <cassert>
#include <SHpch.h> #include <SHpch.h>
#include "SHFramerateController.h" #include "SHFramerateController.h"
#include "../Tools/SHLogger.h" #include "../Tools/SHLogger.h"
namespace SHADE
{
double SHFrameRateController::rawDeltaTime = 0.0;
std::chrono::steady_clock::time_point SHFrameRateController::prevFrameTime = std::chrono::high_resolution_clock::now();
void SHFrameRateController::UpdateFRC() noexcept
{
std::chrono::duration<double> deltaTime;
deltaTime = std::chrono::high_resolution_clock::now() - prevFrameTime;
prevFrameTime = std::chrono::high_resolution_clock::now();
rawDeltaTime = deltaTime.count();
}
}
//TODO Legacy code. Delete soon
#if 0
namespace SHADE namespace SHADE
{ {
//Init statics //Init statics
@ -131,4 +150,5 @@ namespace SHADE
currentScene = nextScene; currentScene = nextScene;
} }
} }
} }
#endif

View File

@ -13,6 +13,38 @@
#define SH_FRAMERATECONTROLLER_H #define SH_FRAMERATECONTROLLER_H
#pragma once #pragma once
#include <chrono>
#include "Tools/SHLogger.h"
#include "SH_API.h"
namespace SHADE
{
class SH_API SHFrameRateController
{
private:
//Varying delta time. The actual time it took for every frame
static double rawDeltaTime;
static std::chrono::steady_clock::time_point prevFrameTime;
public:
//Gets the raw delta time
static inline double GetRawDeltaTime() noexcept
{
return rawDeltaTime;
}
//Updates the raw delta time accordingly
static void UpdateFRC() noexcept;
};
}
//TODO Legacy code. Delete soon
#if 0
#include "../Scene/SHScene.h" #include "../Scene/SHScene.h"
namespace SHADE namespace SHADE
@ -56,7 +88,19 @@ namespace SHADE
//halt execution of the current scene and prepare //halt execution of the current scene and prepare
//execution of the next //execution of the next
static inline void SetNextScene(SHScene* const next) { nextScene = next; } static inline void SetNextScene(SHScene* const next) { nextScene = next; }
}; };
} }
#endif
#endif #endif

View File

@ -165,7 +165,7 @@ namespace SHADE
return XMVector2NotEqual(V1, V2); return XMVector2NotEqual(V1, V2);
} }
float SHVec2::operator[](int index) float& SHVec2::operator[](int index)
{ {
if (index >= SIZE || index < 0) if (index >= SIZE || index < 0)
throw std::invalid_argument("Index out of range!"); throw std::invalid_argument("Index out of range!");
@ -174,11 +174,10 @@ namespace SHADE
{ {
case 0: return x; case 0: return x;
case 1: return y; case 1: return y;
default: return 0.0f;
} }
} }
float SHVec2::operator[](size_t index) float& SHVec2::operator[](size_t index)
{ {
if (index >= SIZE) if (index >= SIZE)
throw std::invalid_argument("Index out of range!"); throw std::invalid_argument("Index out of range!");
@ -187,7 +186,6 @@ namespace SHADE
{ {
case 0: return x; case 0: return x;
case 1: return y; case 1: return y;
default: return 0.0f;
} }
} }
@ -200,7 +198,6 @@ namespace SHADE
{ {
case 0: return x; case 0: return x;
case 1: return y; case 1: return y;
default: return 0.0f;
} }
} }
@ -213,7 +210,6 @@ namespace SHADE
{ {
case 0: return x; case 0: return x;
case 1: return y; case 1: return y;
default: return 0.0f;
} }
} }

View File

@ -81,8 +81,8 @@ namespace SHADE
[[nodiscard]] bool operator== (const SHVec2& rhs) const noexcept; [[nodiscard]] bool operator== (const SHVec2& rhs) const noexcept;
[[nodiscard]] bool operator!= (const SHVec2& rhs) const noexcept; [[nodiscard]] bool operator!= (const SHVec2& rhs) const noexcept;
[[nodiscard]] float operator[] (int index); [[nodiscard]] float& operator[] (int index);
[[nodiscard]] float operator[] (size_t index); [[nodiscard]] float& operator[] (size_t index);
[[nodiscard]] float operator[] (int index) const; [[nodiscard]] float operator[] (int index) const;
[[nodiscard]] float operator[] (size_t index) const; [[nodiscard]] float operator[] (size_t index) const;

View File

@ -171,7 +171,7 @@ namespace SHADE
return XMVector3NotEqual(V1, V2); return XMVector3NotEqual(V1, V2);
} }
float SHVec3::operator[](int index) float& SHVec3::operator[](int index)
{ {
if (index >= SIZE || index < 0) if (index >= SIZE || index < 0)
throw std::invalid_argument("Index out of range!"); throw std::invalid_argument("Index out of range!");
@ -181,11 +181,10 @@ namespace SHADE
case 0: return x; case 0: return x;
case 1: return y; case 1: return y;
case 2: return z; case 2: return z;
default: return 0.0f;
} }
} }
float SHVec3::operator[](size_t index) float& SHVec3::operator[](size_t index)
{ {
if (index >= SIZE) if (index >= SIZE)
throw std::invalid_argument("Index out of range!"); throw std::invalid_argument("Index out of range!");
@ -195,7 +194,6 @@ namespace SHADE
case 0: return x; case 0: return x;
case 1: return y; case 1: return y;
case 2: return z; case 2: return z;
default: return 0.0f;
} }
} }
@ -209,7 +207,6 @@ namespace SHADE
case 0: return x; case 0: return x;
case 1: return y; case 1: return y;
case 2: return z; case 2: return z;
default: return 0.0f;
} }
} }
@ -223,7 +220,6 @@ namespace SHADE
case 0: return x; case 0: return x;
case 1: return y; case 1: return y;
case 2: return z; case 2: return z;
default: return 0.0f;
} }
} }

View File

@ -86,8 +86,8 @@ namespace SHADE
[[nodiscard]] bool operator== (const SHVec3& rhs) const noexcept; [[nodiscard]] bool operator== (const SHVec3& rhs) const noexcept;
[[nodiscard]] bool operator!= (const SHVec3& rhs) const noexcept; [[nodiscard]] bool operator!= (const SHVec3& rhs) const noexcept;
[[nodiscard]] float operator[] (int index); [[nodiscard]] float& operator[] (int index);
[[nodiscard]] float operator[] (size_t index); [[nodiscard]] float& operator[] (size_t index);
[[nodiscard]] float operator[] (int index) const; [[nodiscard]] float operator[] (int index) const;
[[nodiscard]] float operator[] (size_t index) const; [[nodiscard]] float operator[] (size_t index) const;

View File

@ -161,7 +161,7 @@ namespace SHADE
return XMVector4NotEqual(V1, V2); return XMVector4NotEqual(V1, V2);
} }
float SHVec4::operator[](int index) float& SHVec4::operator[](int index)
{ {
if (index >= SIZE || index < 0) if (index >= SIZE || index < 0)
throw std::invalid_argument("Index out of range!"); throw std::invalid_argument("Index out of range!");
@ -172,11 +172,10 @@ namespace SHADE
case 1: return y; case 1: return y;
case 2: return z; case 2: return z;
case 3: return w; case 3: return w;
default: return 0.0f;
} }
} }
float SHVec4::operator[](size_t index) float& SHVec4::operator[](size_t index)
{ {
if (index >= SIZE) if (index >= SIZE)
throw std::invalid_argument("Index out of range!"); throw std::invalid_argument("Index out of range!");
@ -187,7 +186,6 @@ namespace SHADE
case 1: return y; case 1: return y;
case 2: return z; case 2: return z;
case 3: return w; case 3: return w;
default: return 0.0f;
} }
} }
@ -202,7 +200,6 @@ namespace SHADE
case 1: return y; case 1: return y;
case 2: return z; case 2: return z;
case 3: return w; case 3: return w;
default: return 0.0f;
} }
} }
@ -217,7 +214,6 @@ namespace SHADE
case 1: return y; case 1: return y;
case 2: return z; case 2: return z;
case 3: return w; case 3: return w;
default: return 0.0f;
} }
} }

View File

@ -80,8 +80,8 @@ namespace SHADE
[[nodiscard]] bool operator== (const SHVec4& rhs) const noexcept; [[nodiscard]] bool operator== (const SHVec4& rhs) const noexcept;
[[nodiscard]] bool operator!= (const SHVec4& rhs) const noexcept; [[nodiscard]] bool operator!= (const SHVec4& rhs) const noexcept;
[[nodiscard]] float operator[] (int index); [[nodiscard]] float& operator[] (int index);
[[nodiscard]] float operator[] (size_t index); [[nodiscard]] float& operator[] (size_t index);
[[nodiscard]] float operator[] (int index) const; [[nodiscard]] float operator[] (int index) const;
[[nodiscard]] float operator[] (size_t index) const; [[nodiscard]] float operator[] (size_t index) const;

View File

@ -99,7 +99,7 @@ namespace SHADE
using EntityNodeMap = std::unordered_map<EntityID, SHSceneNode*>; using EntityNodeMap = std::unordered_map<EntityID, SHSceneNode*>;
using UnaryPredicate = void (*)(SHSceneNode*); using UnaryPredicate = std::function<void(SHSceneNode*)>;
/*---------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/