Somewhat working version

This commit is contained in:
Dynamitos
2023-11-26 09:40:48 +01:00
parent 7f1bc7d090
commit 89cee2e41a
10 changed files with 44 additions and 120 deletions
+1
View File
@@ -6,6 +6,7 @@ using namespace Seele::System;
KeyboardInput::KeyboardInput(PScene scene)
: ComponentSystem<Component::KeyboardInput>(scene)
{
std::memset(keys.data(), 0, sizeof(keys));
}
KeyboardInput::~KeyboardInput()
+7 -17
View File
@@ -1,32 +1,22 @@
#include "MeshUpdater.h"
#include "Component/Mesh.h"
using namespace Seele;
using namespace Seele::System;
MeshUpdater::MeshUpdater(PScene scene)
: SystemBase(scene)
: ComponentSystem<Component::Transform, Component::Mesh>(scene)
{
scene->view<Component::Mesh>([&](entt::entity id, Component::Mesh& mesh) {
meshEntities.add(id);
});
scene->constructCallback<Component::Mesh>().connect<&MeshUpdater::on_construct>(this);
scene->destroyCallback<Component::Mesh>().connect<&MeshUpdater::on_destroy>(this);
}
MeshUpdater::~MeshUpdater()
{
}
void MeshUpdater::update()
void MeshUpdater::update(Component::Transform& transform, Component::Mesh& comp)
{
}
void MeshUpdater::on_construct(entt::registry& reg, entt::entity id)
{
meshEntities.add(id);
}
void MeshUpdater::on_destroy(entt::registry& reg, entt::entity id)
{
meshEntities.remove(id, false);
for (auto& mesh : comp.asset->meshes)
{
mesh->vertexData->updateMesh(mesh, transform);
}
}
+3 -6
View File
@@ -1,5 +1,5 @@
#pragma once
#include "SystemBase.h"
#include "ComponentSystem.h"
#include "Component/Transform.h"
#include "Component/Mesh.h"
@@ -7,16 +7,13 @@ namespace Seele
{
namespace System
{
class MeshUpdater : public SystemBase
class MeshUpdater : public ComponentSystem<Component::Transform, Component::Mesh>
{
public:
MeshUpdater(PScene scene);
virtual ~MeshUpdater();
virtual void update() override;
virtual void update(Component::Transform& transform, Component::Mesh& mesh) override;
private:
Array<entt::entity> meshEntities;
void on_construct(entt::registry& reg, entt::entity id);
void on_destroy(entt::registry& reg, entt::entity id);
};
} // namespace System
} // namespace Seele