Fixed SHFamilyID for SHSystem and SHComponent but still have issues with SHScene
This commit is contained in:
parent
b1a799cf05
commit
114ae86a9f
|
@ -87,6 +87,11 @@ namespace Sandbox
|
||||||
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");
|
||||||
SHADE::SHAssetManager::LoadDataTemp("../../Assets/TD_Checker_Base_Color.dds");
|
SHADE::SHAssetManager::LoadDataTemp("../../Assets/TD_Checker_Base_Color.dds");
|
||||||
|
|
||||||
|
|
||||||
|
auto id = SHFamilyID<SHSystem>::GetID<SHGraphicsSystem>();
|
||||||
|
auto id2 = SHFamilyID<SHSystem>::GetID<SHGraphicsSystem>();
|
||||||
|
auto id3 = SHFamilyID<SHSystem>::GetID<SHGraphicsSystem>();
|
||||||
//TODO: REMOVE AFTER PRESENTATION
|
//TODO: REMOVE AFTER PRESENTATION
|
||||||
|
|
||||||
//SHADE::SHSystemManager::RegisterRoutine<SHADE::SHAudioSystem, SHADE::SHAudioSystem::AudioRoutine>();
|
//SHADE::SHSystemManager::RegisterRoutine<SHADE::SHAudioSystem, SHADE::SHAudioSystem::AudioRoutine>();
|
||||||
|
@ -102,7 +107,9 @@ namespace Sandbox
|
||||||
#else
|
#else
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
SHSceneManager::InitSceneManager<SBTestScene>("TestScene");
|
SHSceneManager::InitSceneManager<SBTestScene>("TestScene");
|
||||||
|
|
||||||
SHFrameRateController::UpdateFRC();
|
SHFrameRateController::UpdateFRC();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,8 +119,6 @@ namespace Sandbox
|
||||||
//TODO: Change true to window is open
|
//TODO: Change true to window is open
|
||||||
while (!window.WindowShouldClose())
|
while (!window.WindowShouldClose())
|
||||||
{
|
{
|
||||||
auto id = SystemFamily::GetID<SHTransformSystem>();
|
|
||||||
SHLOG_INFO("Transform system id in application : {} {}", id, SystemFamily::currentID);
|
|
||||||
SHFrameRateController::UpdateFRC();
|
SHFrameRateController::UpdateFRC();
|
||||||
SHSceneManager::UpdateSceneManager();
|
SHSceneManager::UpdateSceneManager();
|
||||||
SHSceneManager::SceneUpdate(1/60.0f);
|
SHSceneManager::SceneUpdate(1/60.0f);
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include "SHpch.h"
|
#include "SHpch.h"
|
||||||
#include "../SHECSMacros.h"
|
#include "../SHECSMacros.h"
|
||||||
#include "SH_API.h"
|
#include "SH_API.h"
|
||||||
|
#include "ECS_Base/General/SHFamily.h"
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
|
@ -117,4 +118,7 @@ namespace SHADE
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template class SH_API SHFamilyID<SHComponent>;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#define COMPULING_THE_DLL
|
|
||||||
#include "SHFamily.h"
|
#include "SHFamily.h"
|
||||||
#include "SHpch.h"
|
#include "SHpch.h"
|
||||||
|
|
||||||
|
|
|
@ -14,13 +14,14 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../SHECSMacros.h"
|
#include "../SHECSMacros.h"
|
||||||
|
#include "SH_API.h"
|
||||||
|
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
|
|
||||||
template<typename BaseClass>
|
template<typename BaseClass>
|
||||||
class SHFamilyID
|
class SH_API SHFamilyID
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -47,7 +48,7 @@ namespace SHADE
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//this is used to keep track of the new current ID to be assign to a new Derived class type.
|
//this is used to keep track of the new current ID to be assign to a new Derived class type.
|
||||||
static MY_DLL_EXPORT ComponentTypeID currentID;
|
static inline ComponentTypeID currentID = 0;
|
||||||
|
|
||||||
/*!*************************************************************************
|
/*!*************************************************************************
|
||||||
* \brief
|
* \brief
|
||||||
|
@ -70,20 +71,27 @@ namespace SHADE
|
||||||
* @tparam DerivedClass
|
* @tparam DerivedClass
|
||||||
* The derived class type that we are trying to get the ID of.
|
* The derived class type that we are trying to get the ID of.
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
#ifdef SH_API_EXPORT
|
||||||
template<typename DerivedClass>
|
template<typename DerivedClass>
|
||||||
static ENABLE_IF_DERIVED(ComponentTypeID, BaseClass, DerivedClass) GetID() noexcept
|
static SH_API ENABLE_IF_DERIVED(ComponentTypeID, BaseClass, DerivedClass) GetID() noexcept
|
||||||
{
|
{
|
||||||
//The first time a new derived class type call this get id, it will initialize id using the currentID from familyID class.
|
//The first time a new derived class type call this get id, it will initialize id using the currentID from familyID class.
|
||||||
static ComponentTypeID id = currentID++;
|
static ComponentTypeID id = SHFamilyID<BaseClass>::currentID++;
|
||||||
return id;
|
return id;
|
||||||
|
//return 0;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
template<typename DerivedClass>
|
||||||
|
static SH_API ENABLE_IF_DERIVED(ComponentTypeID, BaseClass, DerivedClass) GetID() noexcept;
|
||||||
|
#endif // SH_API_EXPORT
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef COMPILING_THE_DLL
|
|
||||||
template<typename BaseClass>
|
|
||||||
ComponentTypeID SHFamilyID<BaseClass>::currentID = 0;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
|
@ -68,6 +68,9 @@ namespace SHADE
|
||||||
id = ((SystemID)version << sizeof(SystemVersionID) * CHAR_BIT) + typeID;
|
id = ((SystemID)version << sizeof(SystemVersionID) * CHAR_BIT) + typeID;
|
||||||
}
|
}
|
||||||
systemContainer.emplace(id, std::make_unique<T>());
|
systemContainer.emplace(id, std::make_unique<T>());
|
||||||
|
|
||||||
|
auto size = systemContainer.size();
|
||||||
|
|
||||||
systemContainer[id].get()->systemID = id;
|
systemContainer[id].get()->systemID = id;
|
||||||
|
|
||||||
return id;
|
return id;
|
||||||
|
|
|
@ -26,14 +26,6 @@ const EntityIndex MAX_EID = 51000;
|
||||||
#define ENABLE_IF_UINT(_TYPE, _RETURN)\
|
#define ENABLE_IF_UINT(_TYPE, _RETURN)\
|
||||||
typename std::enable_if<(std::is_integral<_TYPE>::value && !std::is_signed<_TYPE>::value),_RETURN>::type
|
typename std::enable_if<(std::is_integral<_TYPE>::value && !std::is_signed<_TYPE>::value),_RETURN>::type
|
||||||
|
|
||||||
#ifdef COMPILING_THE_DLL
|
|
||||||
#ifndef MY_DLL_EXPORT
|
|
||||||
#define MY_DLL_EXPORT __declspec(dllexport)
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
#ifndef MY_DLL_EXPORT
|
|
||||||
#define MY_DLL_EXPORT __declspec(dllimport)
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -12,6 +12,7 @@
|
||||||
|
|
||||||
#include "../SHECSMacros.h"
|
#include "../SHECSMacros.h"
|
||||||
#include "SH_API.h"
|
#include "SH_API.h"
|
||||||
|
#include "ECS_Base/General/SHFamily.h"
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
|
@ -69,5 +70,9 @@ namespace SHADE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template class SH_API SHFamilyID<SHSystem>;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -89,6 +89,11 @@ namespace SHADE
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; //Enable docking
|
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; //Enable docking
|
||||||
|
|
||||||
InitFonts();
|
InitFonts();
|
||||||
|
|
||||||
|
|
||||||
|
auto id = SHFamilyID<SHSystem>::GetID<SHGraphicsSystem>();
|
||||||
|
auto id2 = SHFamilyID<SHSystem>::GetID<SHTransformSystem>();
|
||||||
|
auto id3 = SHFamilyID<SHSystem>::GetID<SHGraphicsSystem>();
|
||||||
InitBackend(sdlWindow);
|
InitBackend(sdlWindow);
|
||||||
|
|
||||||
SetStyle(Style::SHADE);
|
SetStyle(Style::SHADE);
|
||||||
|
@ -106,8 +111,6 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
(void)dt;
|
(void)dt;
|
||||||
NewFrame();
|
NewFrame();
|
||||||
auto id = SystemFamily::GetID<SHTransformSystem>();
|
|
||||||
SHLOG_INFO("Transform system id in Editor Update : {} {}", id, SystemFamily::currentID);
|
|
||||||
for (const auto& window : editorWindows | std::views::values)
|
for (const auto& window : editorWindows | std::views::values)
|
||||||
{
|
{
|
||||||
if(window->isOpen)
|
if(window->isOpen)
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "SHSceneGraph.h"
|
#include "SHSceneGraph.h"
|
||||||
|
#include "ECS_Base/General/SHFamily.h"
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
|
@ -42,6 +43,7 @@ namespace SHADE
|
||||||
virtual void Unload() = 0;
|
virtual void Unload() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template class SH_API SHFamilyID<SHScene>;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,7 +84,8 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
//prevSceneCreate = newScene;
|
//prevSceneCreate = newScene;
|
||||||
newScene = [sceneName]() { currentScene = new T(); currentScene->sceneName = sceneName; };
|
newScene = [sceneName]() { currentScene = new T(); currentScene->sceneName = sceneName; };
|
||||||
nextSceneID = SHFamilyID<SHScene>::template GetID<T>();
|
//nextSceneID = SHFamilyID<SHScene>::GetID<T>();
|
||||||
|
nextSceneID = 0;
|
||||||
|
|
||||||
sceneChanged = true;
|
sceneChanged = true;
|
||||||
}
|
}
|
||||||
|
@ -101,13 +102,13 @@ namespace SHADE
|
||||||
static std::enable_if_t<std::is_base_of_v<SHScene, T>, void> ChangeScene(std::string const& sceneName) noexcept
|
static std::enable_if_t<std::is_base_of_v<SHScene, T>, void> ChangeScene(std::string const& sceneName) noexcept
|
||||||
{
|
{
|
||||||
//check if this new Scene is current Scene (Use RestartScene instead)
|
//check if this new Scene is current Scene (Use RestartScene instead)
|
||||||
if (currentSceneID == SHFamilyID<SHScene>::template GetID<T>())
|
if (currentSceneID == SHFamilyID<SHScene>::GetID<T>())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//prevSceneCreate = newScene;
|
//prevSceneCreate = newScene;
|
||||||
newScene = [sceneName]() { currentScene = new T(); currentScene->sceneName; };
|
newScene = [sceneName]() { currentScene = new T(); currentScene->sceneName; };
|
||||||
nextSceneID = SHFamilyID<SHScene>::template GetID<T>();
|
nextSceneID = SHFamilyID<SHScene>::GetID<T>();
|
||||||
sceneChanged = true;
|
sceneChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue