Skip to content

Commit 0b0dddb

Browse files
committed
addressing more comments.
1 parent 02baf4d commit 0b0dddb

File tree

3 files changed

+9
-12
lines changed

3 files changed

+9
-12
lines changed

attachments/simple_engine/engine.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -411,16 +411,8 @@ void Engine::Render() {
411411
return;
412412
}
413413

414-
// Get all active entities
415-
std::vector<Entity*> activeEntities;
416-
for (auto& entity : entities) {
417-
if (entity->IsActive()) {
418-
activeEntities.push_back(entity.get());
419-
}
420-
}
421-
422414
// Render the scene (ImGui will be rendered within the render pass)
423-
renderer->Render(activeEntities, activeCamera, imguiSystem.get());
415+
renderer->Render(entities, activeCamera, imguiSystem.get());
424416
}
425417

426418
float Engine::CalculateDeltaTime() {

attachments/simple_engine/renderer.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <unordered_map>
1010
#include <mutex>
1111
#include <algorithm>
12+
#include <memory>
1213

1314
#include "platform.h"
1415
#include "entity.h"
@@ -135,7 +136,7 @@ class Renderer {
135136
* @param camera The camera to use for rendering.
136137
* @param imguiSystem The ImGui system for UI rendering (optional).
137138
*/
138-
void Render(const std::vector<Entity*>& entities, CameraComponent* camera, ImGuiSystem* imguiSystem = nullptr);
139+
void Render(const std::vector<std::unique_ptr<Entity>>& entities, CameraComponent* camera, ImGuiSystem* imguiSystem = nullptr);
139140

140141
/**
141142
* @brief Wait for the device to be idle.

attachments/simple_engine/renderer_rendering.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ void Renderer::updateUniformBufferInternal(uint32_t currentImage, Entity* entity
504504
}
505505

506506
// Render the scene
507-
void Renderer::Render(const std::vector<Entity*>& entities, CameraComponent* camera, ImGuiSystem* imguiSystem) {
507+
void Renderer::Render(const std::vector<std::unique_ptr<Entity>>& entities, CameraComponent* camera, ImGuiSystem* imguiSystem) {
508508
// Set rendering active to prevent memory pool growth during rendering
509509
if (memoryPool) {
510510
memoryPool->setRenderingActive(true);
@@ -608,7 +608,11 @@ void Renderer::Render(const std::vector<Entity*>& entities, CameraComponent* cam
608608
vk::raii::PipelineLayout* currentLayout = nullptr;
609609

610610
// Render each entity
611-
for (auto entity : entities) {
611+
for (auto const& uptr : entities) {
612+
Entity* entity = uptr.get();
613+
if (!entity || !entity->IsActive()) {
614+
continue;
615+
}
612616
// Check if ball-only rendering is enabled and filter entities accordingly
613617
if (imguiSystem && imguiSystem->IsBallOnlyRenderingEnabled()) {
614618
// Only render entities whose names contain "Ball_"

0 commit comments

Comments
 (0)