working on scene management

This commit is contained in:
2025-05-18 18:30:18 +02:00
parent be29d9a3be
commit 18190ac7a5
8 changed files with 42 additions and 59 deletions

View File

@@ -43,19 +43,19 @@ namespace Scop
VkCommandBuffer cmd = renderer.GetActiveCommandBuffer();
pipeline.BindPipeline(cmd, 0, {});
for(auto actor : scene.GetActors())
for(const auto& actor : scene.GetActors())
{
if(!actor->IsVisible())
if(!actor.IsVisible())
continue;
ModelData model_data;
model_data.model_mat = Mat4f::Identity();
model_data.model_mat.SetTranslation(actor->GetPosition() - actor->GetModel().GetCenter());
model_data.model_mat.SetScale(actor->GetScale());
model_data.model_mat = Mat4f::Translate(-actor->GetModel().GetCenter()) * Mat4f::Rotate(actor->GetOrientation()) * model_data.model_mat;
model_data.model_mat.SetTranslation(actor.GetPosition() - actor.GetModel().GetCenter());
model_data.model_mat.SetScale(actor.GetScale());
model_data.model_mat = Mat4f::Translate(-actor.GetModel().GetCenter()) * Mat4f::Rotate(actor.GetOrientation()) * model_data.model_mat;
model_data.normal_mat = model_data.model_mat;
model_data.normal_mat.Inverse().Transpose();
RenderCore::Get().vkCmdPushConstants(cmd, pipeline.GetPipelineLayout(), VK_SHADER_STAGE_VERTEX_BIT, 0, sizeof(ModelData), &model_data);
actor->GetModel().Draw(cmd, *data.matrices_set, pipeline, *data.albedo_set, renderer.GetDrawCallsCounterRef(), renderer.GetPolygonDrawnCounterRef(), renderer.GetCurrentFrameIndex());
actor.GetModel().Draw(cmd, *data.matrices_set, pipeline, *data.albedo_set, renderer.GetDrawCallsCounterRef(), renderer.GetPolygonDrawnCounterRef(), renderer.GetCurrentFrameIndex());
}
pipeline.EndPipeline(cmd);
}