Added ResourceListenerWrapper

This class wraps the call to
Resource::AddResourceListener/RemoveResourceListener using RAII and help
a lot with some of the dependencies.
Thanks to this, the render queues now handle their resources listening
properly.

Former-commit-id: 7f215ffa4ccadcc4f44f777656970e92ce01087a
This commit is contained in:
Lynix
2015-01-18 23:59:01 +01:00
parent a6183fae69
commit 8f9ea9db17
33 changed files with 602 additions and 411 deletions

View File

@@ -54,17 +54,17 @@ bool NzDeferredGeometryPass::Process(const NzScene* scene, unsigned int firstWor
for (auto& matIt : m_renderQueue->opaqueModels)
{
bool& used = std::get<0>(matIt.second);
if (used)
auto& matEntry = matIt.second;
if (matEntry.enabled)
{
bool& renderQueueInstancing = std::get<1>(matIt.second);
NzDeferredRenderQueue::MeshInstanceContainer& meshInstances = std::get<2>(matIt.second);
NzDeferredRenderQueue::MeshInstanceContainer& meshInstances = matEntry.meshMap;
if (!meshInstances.empty())
{
const NzMaterial* material = matIt.first;
bool useInstancing = instancingEnabled && renderQueueInstancing;
bool useInstancing = instancingEnabled && matEntry.instancingEnabled;
// On commence par récupérer le programme du matériau
nzUInt32 flags = nzShaderFlags_Deferred;
@@ -88,8 +88,9 @@ bool NzDeferredGeometryPass::Process(const NzScene* scene, unsigned int firstWor
for (auto& meshIt : meshInstances)
{
const NzMeshData& meshData = meshIt.first;
std::vector<NzMatrix4f>& instances = meshIt.second;
auto& meshEntry = meshIt.second;
std::vector<NzMatrix4f>& instances = meshEntry.instances;
if (!instances.empty())
{
const NzIndexBuffer* indexBuffer = meshData.indexBuffer;
@@ -158,8 +159,8 @@ bool NzDeferredGeometryPass::Process(const NzScene* scene, unsigned int firstWor
}
// Et on remet à zéro les données
renderQueueInstancing = false;
used = false;
matEntry.enabled = false;
matEntry.instancingEnabled = false;
}
}