Formatted EVERYTHING
This commit is contained in:
@@ -3,16 +3,8 @@
|
||||
using namespace Seele;
|
||||
using namespace Seele::System;
|
||||
|
||||
CameraUpdater::CameraUpdater(PScene scene)
|
||||
: ComponentSystem(scene)
|
||||
{
|
||||
}
|
||||
CameraUpdater::CameraUpdater(PScene scene) : ComponentSystem(scene) {}
|
||||
|
||||
CameraUpdater::~CameraUpdater()
|
||||
{
|
||||
}
|
||||
CameraUpdater::~CameraUpdater() {}
|
||||
|
||||
void CameraUpdater::update(Component::Camera& camera)
|
||||
{
|
||||
camera.buildViewMatrix();
|
||||
}
|
||||
void CameraUpdater::update(Component::Camera& camera) { camera.buildViewMatrix(); }
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
#pragma once
|
||||
#include "ComponentSystem.h"
|
||||
#include "Component/Camera.h"
|
||||
#include "ComponentSystem.h"
|
||||
|
||||
namespace Seele
|
||||
{
|
||||
namespace System
|
||||
{
|
||||
class CameraUpdater : public ComponentSystem<Component::Camera>
|
||||
{
|
||||
public:
|
||||
namespace Seele {
|
||||
namespace System {
|
||||
class CameraUpdater : public ComponentSystem<Component::Camera> {
|
||||
public:
|
||||
CameraUpdater(PScene scene);
|
||||
virtual ~CameraUpdater();
|
||||
|
||||
virtual void update(Component::Camera& camera);
|
||||
private:
|
||||
|
||||
private:
|
||||
};
|
||||
}
|
||||
}
|
||||
} // namespace System
|
||||
} // namespace Seele
|
||||
@@ -1,43 +1,28 @@
|
||||
#pragma once
|
||||
#include "SystemBase.h"
|
||||
#include "Component/Component.h"
|
||||
#include "Component/Camera.h"
|
||||
#include "Component/Component.h"
|
||||
#include "SystemBase.h"
|
||||
|
||||
namespace Seele
|
||||
{
|
||||
namespace System
|
||||
{
|
||||
template<typename... Components>
|
||||
class ComponentSystem : public SystemBase
|
||||
{
|
||||
public:
|
||||
namespace Seele {
|
||||
namespace System {
|
||||
template <typename... Components> class ComponentSystem : public SystemBase {
|
||||
public:
|
||||
ComponentSystem(PScene scene) : SystemBase(scene) {}
|
||||
virtual ~ComponentSystem() {}
|
||||
template<has_dependencies Comp>
|
||||
auto getDependencies()
|
||||
{
|
||||
return Comp::dependencies;
|
||||
}
|
||||
template<typename Comp>
|
||||
Dependencies<> getDependencies()
|
||||
{
|
||||
return Dependencies<>();
|
||||
}
|
||||
template<typename... Deps>
|
||||
void setupView(Dependencies<Deps...>)
|
||||
{
|
||||
//List<std::function<void()>> work;
|
||||
registry.view<Components..., Deps...>().each([&](entt::entity id, Components&... comp, Deps&... deps){
|
||||
//work.add([&]() {
|
||||
(accessComponent(deps), ...);
|
||||
update(comp...);
|
||||
update(id, comp...);
|
||||
template <has_dependencies Comp> auto getDependencies() { return Comp::dependencies; }
|
||||
template <typename Comp> Dependencies<> getDependencies() { return Dependencies<>(); }
|
||||
template <typename... Deps> void setupView(Dependencies<Deps...>) {
|
||||
// List<std::function<void()>> work;
|
||||
registry.view<Components..., Deps...>().each([&](entt::entity id, Components&... comp, Deps&... deps) {
|
||||
// work.add([&]() {
|
||||
(accessComponent(deps), ...);
|
||||
update(comp...);
|
||||
update(id, comp...);
|
||||
//});
|
||||
});
|
||||
//getThreadPool().runAndWait(std::move(work));
|
||||
// getThreadPool().runAndWait(std::move(work));
|
||||
}
|
||||
virtual void run(double delta) override
|
||||
{
|
||||
virtual void run(double delta) override {
|
||||
SystemBase::run(delta);
|
||||
setupView((getDependencies<Components>() | ...));
|
||||
}
|
||||
|
||||
@@ -2,13 +2,10 @@
|
||||
#include "MinimalEngine.h"
|
||||
#include "SystemBase.h"
|
||||
|
||||
namespace Seele
|
||||
{
|
||||
namespace System
|
||||
{
|
||||
class Executor
|
||||
{
|
||||
public:
|
||||
namespace Seele {
|
||||
namespace System {
|
||||
class Executor {
|
||||
public:
|
||||
Executor();
|
||||
~Executor();
|
||||
};
|
||||
|
||||
@@ -3,18 +3,11 @@
|
||||
using namespace Seele;
|
||||
using namespace Seele::System;
|
||||
|
||||
KeyboardInput::KeyboardInput(PScene scene)
|
||||
: ComponentSystem<Component::KeyboardInput>(scene)
|
||||
{
|
||||
std::memset(keys.data(), 0, sizeof(keys));
|
||||
}
|
||||
KeyboardInput::KeyboardInput(PScene scene) : ComponentSystem<Component::KeyboardInput>(scene) { std::memset(keys.data(), 0, sizeof(keys)); }
|
||||
|
||||
KeyboardInput::~KeyboardInput()
|
||||
{
|
||||
}
|
||||
KeyboardInput::~KeyboardInput() {}
|
||||
|
||||
void KeyboardInput::update(Component::KeyboardInput& input)
|
||||
{
|
||||
void KeyboardInput::update(Component::KeyboardInput& input) {
|
||||
std::memcpy(input.keys.data(), keys.data(), sizeof(keys));
|
||||
input.deltaX = deltaX;
|
||||
input.deltaY = deltaY;
|
||||
@@ -32,31 +25,23 @@ void KeyboardInput::update(Component::KeyboardInput& input)
|
||||
scrollY = 0;
|
||||
}
|
||||
|
||||
void KeyboardInput::keyCallback(KeyCode code, InputAction action, KeyModifier)
|
||||
{
|
||||
keys[code] = action != InputAction::RELEASE;
|
||||
}
|
||||
void KeyboardInput::keyCallback(KeyCode code, InputAction action, KeyModifier) { keys[code] = action != InputAction::RELEASE; }
|
||||
|
||||
void KeyboardInput::mouseCallback(double x, double y)
|
||||
{
|
||||
void KeyboardInput::mouseCallback(double x, double y) {
|
||||
mouseX = x;
|
||||
mouseY = y;
|
||||
}
|
||||
|
||||
void KeyboardInput::mouseButtonCallback(MouseButton button, InputAction action, KeyModifier)
|
||||
{
|
||||
if (button == MouseButton::MOUSE_BUTTON_1)
|
||||
{
|
||||
void KeyboardInput::mouseButtonCallback(MouseButton button, InputAction action, KeyModifier) {
|
||||
if (button == MouseButton::MOUSE_BUTTON_1) {
|
||||
mouse1 = action != InputAction::RELEASE;
|
||||
}
|
||||
if (button == MouseButton::MOUSE_BUTTON_2)
|
||||
{
|
||||
if (button == MouseButton::MOUSE_BUTTON_2) {
|
||||
mouse2 = action != InputAction::RELEASE;
|
||||
}
|
||||
}
|
||||
|
||||
void KeyboardInput::scrollCallback(double xScroll, double yScroll)
|
||||
{
|
||||
void KeyboardInput::scrollCallback(double xScroll, double yScroll) {
|
||||
scrollX = xScroll;
|
||||
scrollY = yScroll;
|
||||
}
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
#pragma once
|
||||
#include "ComponentSystem.h"
|
||||
#include "Component/KeyboardInput.h"
|
||||
#include "ComponentSystem.h"
|
||||
|
||||
namespace Seele
|
||||
{
|
||||
namespace System
|
||||
{
|
||||
class KeyboardInput : public ComponentSystem<Component::KeyboardInput>
|
||||
{
|
||||
public:
|
||||
namespace Seele {
|
||||
namespace System {
|
||||
class KeyboardInput : public ComponentSystem<Component::KeyboardInput> {
|
||||
public:
|
||||
KeyboardInput(PScene scene);
|
||||
virtual ~KeyboardInput();
|
||||
virtual void update(Component::KeyboardInput& input) override;
|
||||
@@ -16,7 +13,8 @@ public:
|
||||
void mouseCallback(double xPos, double yPos);
|
||||
void mouseButtonCallback(MouseButton button, InputAction action, KeyModifier modifier);
|
||||
void scrollCallback(double xScroll, double yScroll);
|
||||
private:
|
||||
|
||||
private:
|
||||
Seele::StaticArray<bool, (size_t)KeyCode::KEY_LAST> keys;
|
||||
bool mouse1 = false;
|
||||
bool mouse2 = false;
|
||||
@@ -30,5 +28,5 @@ private:
|
||||
float scrollY = 0;
|
||||
};
|
||||
DEFINE_REF(KeyboardInput)
|
||||
}
|
||||
}
|
||||
} // namespace System
|
||||
} // namespace Seele
|
||||
@@ -3,23 +3,12 @@
|
||||
using namespace Seele;
|
||||
using namespace Seele::System;
|
||||
|
||||
LightGather::LightGather(PScene scene)
|
||||
: SystemBase(scene)
|
||||
, lightEnv(scene->getLightEnvironment())
|
||||
{
|
||||
}
|
||||
LightGather::LightGather(PScene scene) : SystemBase(scene), lightEnv(scene->getLightEnvironment()) {}
|
||||
|
||||
LightGather::~LightGather()
|
||||
{
|
||||
}
|
||||
LightGather::~LightGather() {}
|
||||
|
||||
void LightGather::update()
|
||||
{
|
||||
void LightGather::update() {
|
||||
lightEnv->reset();
|
||||
scene->view<Component::PointLight>([this](Component::PointLight& pointLight) {
|
||||
lightEnv->addPointLight(pointLight);
|
||||
});
|
||||
scene->view<Component::DirectionalLight>([this](Component::DirectionalLight& dirLight) {
|
||||
lightEnv->addDirectionalLight(dirLight);
|
||||
});
|
||||
scene->view<Component::PointLight>([this](Component::PointLight& pointLight) { lightEnv->addPointLight(pointLight); });
|
||||
scene->view<Component::DirectionalLight>([this](Component::DirectionalLight& dirLight) { lightEnv->addDirectionalLight(dirLight); });
|
||||
}
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
#pragma once
|
||||
#include "SystemBase.h"
|
||||
|
||||
namespace Seele
|
||||
{
|
||||
namespace System
|
||||
{
|
||||
class LightGather : public SystemBase
|
||||
{
|
||||
public:
|
||||
namespace Seele {
|
||||
namespace System {
|
||||
class LightGather : public SystemBase {
|
||||
public:
|
||||
LightGather(PScene scene);
|
||||
virtual ~LightGather();
|
||||
virtual void update() override;
|
||||
private:
|
||||
|
||||
private:
|
||||
PLightEnvironment lightEnv;
|
||||
};
|
||||
}
|
||||
}
|
||||
} // namespace System
|
||||
} // namespace Seele
|
||||
@@ -5,19 +5,12 @@
|
||||
using namespace Seele;
|
||||
using namespace Seele::System;
|
||||
|
||||
MeshUpdater::MeshUpdater(PScene scene)
|
||||
: ComponentSystem<Component::Transform, Component::Mesh>(scene)
|
||||
{
|
||||
}
|
||||
MeshUpdater::MeshUpdater(PScene scene) : ComponentSystem<Component::Transform, Component::Mesh>(scene) {}
|
||||
|
||||
MeshUpdater::~MeshUpdater()
|
||||
{
|
||||
}
|
||||
MeshUpdater::~MeshUpdater() {}
|
||||
|
||||
void MeshUpdater::update(entt::entity id, Component::Transform& transform, Component::Mesh& comp)
|
||||
{
|
||||
for (uint32 i = 0; i < comp.asset->meshes.size(); ++i)
|
||||
{
|
||||
void MeshUpdater::update(entt::entity id, Component::Transform& transform, Component::Mesh& comp) {
|
||||
for (uint32 i = 0; i < comp.asset->meshes.size(); ++i) {
|
||||
comp.asset->meshes[i]->vertexData->updateMesh(id, i, comp.asset->meshes[i], transform);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
#pragma once
|
||||
#include "ComponentSystem.h"
|
||||
#include "Component/Transform.h"
|
||||
#include "Component/Mesh.h"
|
||||
#include "Component/Transform.h"
|
||||
#include "ComponentSystem.h"
|
||||
|
||||
namespace Seele
|
||||
{
|
||||
namespace System
|
||||
{
|
||||
class MeshUpdater : public ComponentSystem<Component::Transform, Component::Mesh>
|
||||
{
|
||||
public:
|
||||
MeshUpdater(PScene scene);
|
||||
virtual ~MeshUpdater();
|
||||
virtual void update(entt::entity id, Component::Transform& transform, Component::Mesh& mesh) override;
|
||||
private:
|
||||
namespace Seele {
|
||||
namespace System {
|
||||
class MeshUpdater : public ComponentSystem<Component::Transform, Component::Mesh> {
|
||||
public:
|
||||
MeshUpdater(PScene scene);
|
||||
virtual ~MeshUpdater();
|
||||
virtual void update(entt::entity id, Component::Transform& transform, Component::Mesh& mesh) override;
|
||||
|
||||
private:
|
||||
};
|
||||
} // namespace System
|
||||
} // namespace Seele
|
||||
@@ -1,24 +1,21 @@
|
||||
#pragma once
|
||||
#include <entt/entt.hpp>
|
||||
#include "ThreadPool.h"
|
||||
#include "Scene/Scene.h"
|
||||
#include "ThreadPool.h"
|
||||
#include <entt/entt.hpp>
|
||||
|
||||
namespace Seele
|
||||
{
|
||||
namespace System
|
||||
{
|
||||
class SystemBase
|
||||
{
|
||||
public:
|
||||
namespace Seele {
|
||||
namespace System {
|
||||
class SystemBase {
|
||||
public:
|
||||
SystemBase(PScene scene) : registry(scene->registry), scene(scene) {}
|
||||
virtual ~SystemBase() {}
|
||||
virtual void run(double delta)
|
||||
{
|
||||
virtual void run(double delta) {
|
||||
deltaTime = delta;
|
||||
update();
|
||||
}
|
||||
virtual void update() {}
|
||||
protected:
|
||||
|
||||
protected:
|
||||
double deltaTime;
|
||||
entt::registry& registry;
|
||||
PScene scene;
|
||||
|
||||
@@ -2,14 +2,10 @@
|
||||
|
||||
using namespace Seele;
|
||||
|
||||
void SystemGraph::addSystem(System::OSystemBase system)
|
||||
{
|
||||
systems.add(std::move(system));
|
||||
}
|
||||
void SystemGraph::addSystem(System::OSystemBase system) { systems.add(std::move(system)); }
|
||||
|
||||
void SystemGraph::run(float deltaTime)
|
||||
{
|
||||
for(auto& system : systems) {
|
||||
void SystemGraph::run(float deltaTime) {
|
||||
for (auto& system : systems) {
|
||||
system->run(deltaTime);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
#pragma once
|
||||
#include "ThreadPool.h"
|
||||
#include "Containers/Array.h"
|
||||
#include "SystemBase.h"
|
||||
#include "ThreadPool.h"
|
||||
|
||||
namespace Seele
|
||||
{
|
||||
class SystemGraph
|
||||
{
|
||||
public:
|
||||
namespace Seele {
|
||||
class SystemGraph {
|
||||
public:
|
||||
void addSystem(System::OSystemBase system);
|
||||
void run(float deltaTime);
|
||||
private:
|
||||
|
||||
private:
|
||||
Array<System::OSystemBase> systems;
|
||||
};
|
||||
DEFINE_REF(SystemGraph)
|
||||
} // namespace Seele;
|
||||
} // namespace Seele
|
||||
Reference in New Issue
Block a user