diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Batching/SHBatch.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/Batching/SHBatch.cpp index a4d3cb50..f4a229bb 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Batching/SHBatch.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Batching/SHBatch.cpp @@ -35,7 +35,7 @@ namespace SHADE throw std::invalid_argument("Attempted to create a SHBatch with an invalid SHPipeline!"); } - void SHBatch::Add(Handle renderable) + void SHBatch::Add(const SHRenderable* renderable) { // Check if we have a SubBatch with the same mesh yet auto subBatch = std::find_if(subBatches.begin(), subBatches.end(), [&](const SHSubBatch& batch) @@ -54,7 +54,7 @@ namespace SHADE subBatch->Renderables.insert(renderable); } - void SHBatch::Remove(Handle renderable) + void SHBatch::Remove(const SHRenderable* renderable) { // Check if we have a SubBatch with the same mesh yet auto subBatch = std::find_if(subBatches.begin(), subBatches.end(), [&](const SHSubBatch& batch) @@ -136,7 +136,7 @@ namespace SHADE }); // Fill in buffers (CPU) - for (Handle renderable : subBatch.Renderables) + for (const SHRenderable* renderable : subBatch.Renderables) { // Transform transformData.emplace_back(renderable->TransformMatrix); diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Batching/SHBatch.h b/SHADE_Engine/src/Graphics/MiddleEnd/Batching/SHBatch.h index e87c16ef..8bc32f8f 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Batching/SHBatch.h +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Batching/SHBatch.h @@ -49,7 +49,7 @@ namespace SHADE /* Data Members */ /*-----------------------------------------------------------------------------*/ Handle Mesh; - std::unordered_set> Renderables; + std::unordered_set Renderables; }; /***********************************************************************************/ /*! @@ -68,8 +68,8 @@ namespace SHADE /*-----------------------------------------------------------------------------*/ /* Usage Functions */ /*-----------------------------------------------------------------------------*/ - void Add(Handle renderable); - void Remove(Handle renderable); + void Add(const SHRenderable* renderable); + void Remove(const SHRenderable* renderable); void Clear(); void Build(Handle device, Handle cmdBuffer); void Draw(Handle cmdBuffer); diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Batching/SHBatcher.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/Batching/SHBatcher.cpp index ced97876..2843ebb6 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Batching/SHBatcher.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Batching/SHBatcher.cpp @@ -21,6 +21,7 @@ of DigiPen Institute of Technology is prohibited. #include "Graphics/Commands/SHVkCommandBuffer.h" #include "Graphics/MiddleEnd/Interface/SHMaterialInstance.h" #include "Graphics/Pipeline/SHVkPipeline.h" +#include "ECS_Base/Managers/SHComponentManager.h" namespace SHADE { @@ -30,7 +31,7 @@ namespace SHADE void SHBatcher::Init(const std::vector& _renderables, Handle _renderGraph) { renderables = &_renderables; - renderGraph = _renderGraph; + renderGraph = _renderGraph; } /*---------------------------------------------------------------------------------*/ @@ -38,8 +39,9 @@ namespace SHADE /*---------------------------------------------------------------------------------*/ void SHBatcher::PrepareBatches() { - // Iterate through all renderables and send it into the batching - for (auto iter = renderables->cbegin(); iter != renderables->cend(); ++iter) + // Iterate through all renderables and send it into the batching + auto& renderables = SHComponentManager::GetDense(); + for (auto iter = renderables.cbegin(); iter != renderables.cend(); ++iter) { AddToBatch(iter->GetHandle()); } diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Batching/SHSuperBatch.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/Batching/SHSuperBatch.cpp index 6ca498f3..34887b12 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Batching/SHSuperBatch.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Batching/SHSuperBatch.cpp @@ -30,7 +30,7 @@ namespace SHADE /*---------------------------------------------------------------------------------*/ /* Usage Functions */ /*---------------------------------------------------------------------------------*/ - void SHSuperBatch::Add(Handle renderable) noexcept + void SHSuperBatch::Add(const SHRenderable* renderable) noexcept { const Handle PIPELINE = renderable->GetMaterial()->GetBaseMaterial()->GetPipeline(); @@ -52,7 +52,7 @@ namespace SHADE batch->Add(renderable); } - void SHSuperBatch::Remove(Handle renderable) noexcept + void SHSuperBatch::Remove(const SHRenderable* renderable) noexcept { const Handle PIPELINE = renderable->GetMaterial()->GetBaseMaterial()->GetPipeline(); diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Batching/SHSuperBatch.h b/SHADE_Engine/src/Graphics/MiddleEnd/Batching/SHSuperBatch.h index 55f23dbb..dbae5bc9 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Batching/SHSuperBatch.h +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Batching/SHSuperBatch.h @@ -52,8 +52,8 @@ namespace SHADE /*-----------------------------------------------------------------------------*/ /* Usage Functions */ /*-----------------------------------------------------------------------------*/ - void Add(Handle renderable) noexcept; - void Remove(Handle renderable) noexcept; + void Add(const SHRenderable* renderable) noexcept; + void Remove(const SHRenderable* renderable) noexcept; void Clear() noexcept; void Build(Handle device, Handle cmdBuffer) noexcept; void Draw(Handle cmdBuffer) noexcept;