Graphics: Clear instances in Clear method

Former-commit-id: f6314967bf15544b530db2252aa5531d78554381 [formerly 47e880626a186e8b4cd59a2d0328cdb2667af86f] [formerly 319af73dbe6f3a5cbac3bdd7e2add637c6a16ea3 [formerly a1f223482cb27227c8255d5842a38b2506ae3496]]
Former-commit-id: abae215139aadb2a1e6fd2b842db9ffafdeb326e [formerly 4e2c1dd62cf0d02982e786231b15774fb07589e0]
Former-commit-id: 16bd3eb0a451653b05b813ed8921db2746c4aaa0
This commit is contained in:
Lynix 2016-09-01 13:02:46 +02:00
parent 60ac889640
commit 41ed0395d5
6 changed files with 278 additions and 208 deletions

View File

@ -187,18 +187,11 @@ namespace Nz
drawFunc(meshData.primitiveMode, 0, indexCount);
}
}
instances.clear();
}
}
}
// And we set it back data to zero
matEntry.enabled = false;
}
}
pipelineEntry.maxInstanceCount = 0;
}
}
}

View File

@ -278,6 +278,36 @@ namespace Nz
Layer& layer = it->second;
if (layer.clearCount++ >= 100)
it = layers.erase(it);
else
{
for (auto& pipelinePair : layer.opaqueModels)
{
const MaterialPipeline* pipeline = pipelinePair.first;
auto& pipelineEntry = pipelinePair.second;
if (pipelineEntry.maxInstanceCount > 0)
{
for (auto& materialPair : pipelineEntry.materialMap)
{
auto& matEntry = materialPair.second;
if (matEntry.enabled)
{
MeshInstanceContainer& meshInstances = matEntry.meshMap;
for (auto& meshIt : meshInstances)
{
auto& meshEntry = meshIt.second;
meshEntry.instances.clear();
}
matEntry.enabled = false;
}
}
pipelineEntry.maxInstanceCount = 0;
}
}
}
}
}

View File

@ -527,6 +527,62 @@ namespace Nz
layers.erase(it++);
else
{
for (auto& pipelinePair : layer.basicSprites)
{
auto& pipelineEntry = pipelinePair.second;
if (pipelineEntry.enabled)
{
for (auto& materialPair : pipelineEntry.materialMap)
{
auto& matEntry = materialPair.second;
if (matEntry.enabled)
{
auto& overlayMap = matEntry.overlayMap;
for (auto& overlayIt : overlayMap)
{
const Texture* overlay = overlayIt.first;
auto& spriteChainVector = overlayIt.second.spriteChains;
spriteChainVector.clear();
}
matEntry.enabled = false;
}
}
pipelineEntry.enabled = false;
}
}
for (auto& pipelinePair : layer.opaqueModels)
{
auto& pipelineEntry = pipelinePair.second;
if (pipelineEntry.maxInstanceCount > 0)
{
for (auto& materialPair : pipelineEntry.materialMap)
{
const Material* material = materialPair.first;
auto& matEntry = materialPair.second;
if (matEntry.enabled)
{
MeshInstanceContainer& meshInstances = matEntry.meshMap;
for (auto& meshIt : meshInstances)
{
auto& meshEntry = meshIt.second;
meshEntry.instances.clear();
}
matEntry.enabled = false;
}
}
pipelineEntry.maxInstanceCount = 0;
}
}
layer.otherDrawables.clear();
layer.transparentModels.clear();
layer.transparentModelData.clear();

View File

@ -386,17 +386,12 @@ namespace Nz
vertexMapper.Unmap();
Renderer::DrawIndexedPrimitives(PrimitiveMode_TriangleList, 0, spriteCount * 6);
} while (spriteChain < spriteChainCount);
spriteChainVector.clear();
}
while (spriteChain < spriteChainCount);
}
}
// We set it back to zero
matEntry.enabled = false;
}
}
pipelineEntry.enabled = false;
}
}
}
@ -781,12 +776,8 @@ namespace Nz
instances.clear();
}
}
matEntry.enabled = false;
}
}
pipelineEntry.maxInstanceCount = 0;
}
}
}