Viewport controls

This commit is contained in:
Dynamitos
2022-11-17 16:47:42 +01:00
parent f635ee2100
commit 4ba0bf3b45
73 changed files with 627 additions and 449 deletions
+5
View File
@@ -0,0 +1,5 @@
target_sources(Engine
PRIVATE
Executor.h
Executor.cpp
SystemBase.h)
+4
View File
@@ -0,0 +1,4 @@
#include "Executor.h"
using namespace Seele;
using namespace Seele::System;
+19
View File
@@ -0,0 +1,19 @@
#pragma once
#include "MinimalEngine.h"
#include "SystemBase.h"
#include <thread_pool/thread_pool.h>
namespace Seele
{
namespace System
{
class Executor
{
public:
Executor();
~Executor();
private:
dp::thread_pool<> pool;
};
} // namespace System
} // namespace Seele
+47
View File
@@ -0,0 +1,47 @@
#pragma once
#include <entt/entt.hpp>
#include <thread_pool/thread_pool.h>
#include "Component/Component.h"
namespace Seele
{
namespace System
{
template<typename... Components>
class SystemBase
{
public:
SystemBase(entt::registry& registry) : registry(registry) {}
virtual ~SystemBase() {}
template<typename Comp>
auto getDependencies()
{
return Comp::dependencies;
}
template<typename... Dep>
auto mergeDependencies(Dep... deps)
{
return (deps | ...);
}
template<typename... Deps>
void setupView(Dependencies<Deps...>, dp::thread_pool<>&)
{
registry.view<Components..., Deps...>().each([&](Components&... comp, Deps&... deps){
//pool.enqueue_detach([&](){
int ret = (accessComponent(deps) + ...);
assert(ret == 0);
update((comp,...));
//});
});
}
void run(dp::thread_pool<>& pool)
{
setupView(mergeDependencies((getDependencies<Components>(),...)), pool);
}
virtual void update(Components&... components) = 0;
private:
entt::registry& registry;
};
} // namespace System
} // namespace Seele