38 lines
1.3 KiB
C++
38 lines
1.3 KiB
C++
//
|
|
// Created by sebastian on 29.07.26.
|
|
//
|
|
|
|
#include "MeshRenderSystem.h"
|
|
|
|
#include "ecs/standardComponents/HighlightComponent.h"
|
|
#include "ecs/standardComponents/MeshComponent.h"
|
|
#include "ecs/standardComponents/TransformComponent.h"
|
|
#include "spdlog/spdlog.h"
|
|
|
|
|
|
void engine::MeshRenderSystem::update(engine::EntityRegistry ®istry, engine::RenderQueue &renderQueue) {
|
|
renderState.apply();
|
|
auto transforms = registry.getPool<engine::TransformComponent>();
|
|
auto meshes = registry.getPool<engine::MeshComponent>();
|
|
|
|
for (auto& [entity, mesh] : meshes)
|
|
{
|
|
if (!transforms.has(entity))
|
|
continue;
|
|
|
|
auto& transform = transforms.get(entity);
|
|
// spdlog::info("Entity {}: pos=({}, {}, {})", entity.value(),
|
|
// transform.m_position.x, transform.m_position.y, transform.m_position.z);
|
|
|
|
RenderCommand renderCommand(mesh.model, transform.computeModelMatrix());
|
|
if (registry.hasComponent<HighlightComponent>(entity)) {
|
|
auto hightlightComponent = registry.getComponent<HighlightComponent>(entity);
|
|
renderCommand.tintColor = hightlightComponent.highlightColor;
|
|
renderCommand.tintIntensity = hightlightComponent.intensity;
|
|
}
|
|
renderQueue.submit(renderCommand);
|
|
}
|
|
|
|
|
|
}
|