BatcherDispatcher should now account for mesh changes properly
This commit is contained in:
parent
ec9aa4bb6e
commit
b35ca86ae9
|
@ -74,11 +74,12 @@ namespace SHADE
|
||||||
|
|
||||||
void SHBatch::Remove(const SHRenderable* renderable)
|
void SHBatch::Remove(const SHRenderable* renderable)
|
||||||
{
|
{
|
||||||
// Check if we have a SubBatch with the same mesh yet
|
// Check if we have a SubBatch with the existing mesh yet (if changed, we use the old mesh)
|
||||||
|
Handle<SHMesh> prevSubBatchMesh = renderable->HasMeshChanged() ? renderable->GetPrevMesh() : renderable->GetMesh();
|
||||||
auto subBatch = std::find_if(subBatches.begin(), subBatches.end(), [&](const SHSubBatch& batch)
|
auto subBatch = std::find_if(subBatches.begin(), subBatches.end(), [&](const SHSubBatch& batch)
|
||||||
{
|
{
|
||||||
return batch.Mesh == renderable->GetMesh();
|
return batch.Mesh == prevSubBatchMesh;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Attempt to remove if it exists
|
// Attempt to remove if it exists
|
||||||
if (subBatch == subBatches.end())
|
if (subBatch == subBatches.end())
|
||||||
|
@ -88,9 +89,7 @@ namespace SHADE
|
||||||
|
|
||||||
// Check if other renderables in subBatches contain the same material instance
|
// Check if other renderables in subBatches contain the same material instance
|
||||||
bool matUnused = true;
|
bool matUnused = true;
|
||||||
|
|
||||||
Handle<SHMaterialInstance> matToCheck = renderable->HasMaterialChanged() ? renderable->GetPrevMaterial() : renderable->GetMaterial();
|
Handle<SHMaterialInstance> matToCheck = renderable->HasMaterialChanged() ? renderable->GetPrevMaterial() : renderable->GetMaterial();
|
||||||
|
|
||||||
for (const auto& sb : subBatches)
|
for (const auto& sb : subBatches)
|
||||||
{
|
{
|
||||||
// Check material usage
|
// Check material usage
|
||||||
|
|
|
@ -37,9 +37,9 @@ namespace SHADE
|
||||||
|
|
||||||
// Check if we have a batch with the same pipeline first
|
// Check if we have a batch with the same pipeline first
|
||||||
auto batch = std::find_if(batches.begin(), batches.end(), [&](const SHBatch& batch)
|
auto batch = std::find_if(batches.begin(), batches.end(), [&](const SHBatch& batch)
|
||||||
{
|
{
|
||||||
return batch.GetPipeline() == PIPELINE;
|
return batch.GetPipeline() == PIPELINE;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// Create one if not found
|
// Create one if not found
|
||||||
|
|
|
@ -709,8 +709,8 @@ namespace SHADE
|
||||||
if (!renderable.HasChanged())
|
if (!renderable.HasChanged())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Remove from old material's SuperBatch
|
// Remove from the SuperBatch it is previously in (prevMat if mat has changed)
|
||||||
Handle<SHMaterialInstance> prevMaterial = renderable.GetPrevMaterial();
|
Handle<SHMaterialInstance> prevMaterial = renderable.HasMaterialChanged() ? renderable.GetPrevMaterial() : renderable.GetMaterial();
|
||||||
if (prevMaterial)
|
if (prevMaterial)
|
||||||
{
|
{
|
||||||
Handle<SHSuperBatch> oldSuperBatch = prevMaterial->GetBaseMaterial()->GetPipeline()->GetPipelineState().GetSubpass()->GetSuperBatch();
|
Handle<SHSuperBatch> oldSuperBatch = prevMaterial->GetBaseMaterial()->GetPipeline()->GetPipelineState().GetSubpass()->GetSuperBatch();
|
||||||
|
|
Loading…
Reference in New Issue