More mesh shading changes
This commit is contained in:
@@ -4,18 +4,29 @@ using namespace Seele;
|
||||
using namespace Seele::System;
|
||||
|
||||
MeshUpdater::MeshUpdater(PScene scene)
|
||||
: ComponentSystem<Component::Transform, Component::Mesh>(scene)
|
||||
: SystemBase(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(Component::Transform& transform, Component::Mesh& meshComp)
|
||||
void MeshUpdater::update()
|
||||
{
|
||||
for(const auto& mesh : meshComp.asset->meshes)
|
||||
{
|
||||
mesh->vertexData->updateMesh(transform, mesh);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
#include "ComponentSystem.h"
|
||||
#include "SystemBase.h"
|
||||
#include "Component/Transform.h"
|
||||
#include "Component/Mesh.h"
|
||||
|
||||
@@ -7,13 +7,16 @@ namespace Seele
|
||||
{
|
||||
namespace System
|
||||
{
|
||||
class MeshUpdater : public ComponentSystem<Component::Transform, Component::Mesh>
|
||||
class MeshUpdater : public SystemBase
|
||||
{
|
||||
public:
|
||||
MeshUpdater(PScene scene);
|
||||
virtual ~MeshUpdater();
|
||||
virtual void update(Component::Transform& transform, Component::Mesh& mesh) override;
|
||||
virtual void update() 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
|
||||
Reference in New Issue
Block a user