From 75ffa09792278a16700bba8d126e769d1a8eb535 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 19 Jan 2015 02:32:48 +0100 Subject: [PATCH] Fixed errors from last merge Former-commit-id: 850eadf5e233d0d6efad039b6bd943f05384df7d --- src/Nazara/Graphics/ForwardRenderQueue.cpp | 133 ++++++++++++++++----- 1 file changed, 105 insertions(+), 28 deletions(-) diff --git a/src/Nazara/Graphics/ForwardRenderQueue.cpp b/src/Nazara/Graphics/ForwardRenderQueue.cpp index 37d41cb5c..c12658a8d 100644 --- a/src/Nazara/Graphics/ForwardRenderQueue.cpp +++ b/src/Nazara/Graphics/ForwardRenderQueue.cpp @@ -85,11 +85,22 @@ void NzForwardRenderQueue::AddBillboards(const NzMaterial* material, unsigned in if (!alphaPtr) alphaPtr.Reset(&defaultAlpha, 0); // Pareil - std::vector& billboardVec = billboards[material]; - unsigned int prevSize = billboardVec.size(); - billboardVec.resize(prevSize + count); + auto it = billboards.find(material); + if (it == billboards.end()) + { + BatchedBillboardEntry entry(this, ResourceType_Material); + entry.materialListener = material; - BillboardData* billboardData = &billboardVec[prevSize]; + it = billboards.insert(std::make_pair(material, std::move(entry))).first; + } + + BatchedBillboardEntry& entry = it->second; + + auto& billboardVector = entry.billboards; + unsigned int prevSize = billboardVector.size(); + billboardVector.resize(prevSize + count); + + BillboardData* billboardData = &billboardVector[prevSize]; for (unsigned int i = 0; i < count; ++i) { billboardData->center = *positionPtr++; @@ -111,11 +122,22 @@ void NzForwardRenderQueue::AddBillboards(const NzMaterial* material, unsigned in if (!colorPtr) colorPtr.Reset(&NzColor::White, 0); // Pareil - std::vector& billboardVec = billboards[material]; - unsigned int prevSize = billboardVec.size(); - billboardVec.resize(prevSize + count); + auto it = billboards.find(material); + if (it == billboards.end()) + { + BatchedBillboardEntry entry(this, ResourceType_Material); + entry.materialListener = material; - BillboardData* billboardData = &billboardVec[prevSize]; + it = billboards.insert(std::make_pair(material, std::move(entry))).first; + } + + BatchedBillboardEntry& entry = it->second; + + auto& billboardVector = entry.billboards; + unsigned int prevSize = billboardVector.size(); + billboardVector.resize(prevSize + count); + + BillboardData* billboardData = &billboardVector[prevSize]; for (unsigned int i = 0; i < count; ++i) { float sin = std::sin(NzToRadians(*anglePtr)); @@ -143,11 +165,22 @@ void NzForwardRenderQueue::AddBillboards(const NzMaterial* material, unsigned in if (!alphaPtr) alphaPtr.Reset(&defaultAlpha, 0); // Pareil - std::vector& billboardVec = billboards[material]; - unsigned int prevSize = billboardVec.size(); - billboardVec.resize(prevSize + count); + auto it = billboards.find(material); + if (it == billboards.end()) + { + BatchedBillboardEntry entry(this, ResourceType_Material); + entry.materialListener = material; - BillboardData* billboardData = &billboardVec[prevSize]; + it = billboards.insert(std::make_pair(material, std::move(entry))).first; + } + + BatchedBillboardEntry& entry = it->second; + + auto& billboardVector = entry.billboards; + unsigned int prevSize = billboardVector.size(); + billboardVector.resize(prevSize + count); + + BillboardData* billboardData = &billboardVector[prevSize]; for (unsigned int i = 0; i < count; ++i) { float sin = std::sin(NzToRadians(*anglePtr)); @@ -173,11 +206,22 @@ void NzForwardRenderQueue::AddBillboards(const NzMaterial* material, unsigned in if (!colorPtr) colorPtr.Reset(&NzColor::White, 0); // Pareil - std::vector& billboardVec = billboards[material]; - unsigned int prevSize = billboardVec.size(); - billboardVec.resize(prevSize + count); + auto it = billboards.find(material); + if (it == billboards.end()) + { + BatchedBillboardEntry entry(this, ResourceType_Material); + entry.materialListener = material; - BillboardData* billboardData = &billboardVec[prevSize]; + it = billboards.insert(std::make_pair(material, std::move(entry))).first; + } + + BatchedBillboardEntry& entry = it->second; + + auto& billboardVector = entry.billboards; + unsigned int prevSize = billboardVector.size(); + billboardVector.resize(prevSize + count); + + BillboardData* billboardData = &billboardVector[prevSize]; for (unsigned int i = 0; i < count; ++i) { billboardData->center = *positionPtr++; @@ -201,11 +245,22 @@ void NzForwardRenderQueue::AddBillboards(const NzMaterial* material, unsigned in if (!alphaPtr) alphaPtr.Reset(&defaultAlpha, 0); // Pareil - std::vector& billboardVec = billboards[material]; - unsigned int prevSize = billboardVec.size(); - billboardVec.resize(prevSize + count); + auto it = billboards.find(material); + if (it == billboards.end()) + { + BatchedBillboardEntry entry(this, ResourceType_Material); + entry.materialListener = material; - BillboardData* billboardData = &billboardVec[prevSize]; + it = billboards.insert(std::make_pair(material, std::move(entry))).first; + } + + BatchedBillboardEntry& entry = it->second; + + auto& billboardVector = entry.billboards; + unsigned int prevSize = billboardVector.size(); + billboardVector.resize(prevSize + count); + + BillboardData* billboardData = &billboardVector[prevSize]; for (unsigned int i = 0; i < count; ++i) { billboardData->center = *positionPtr++; @@ -227,11 +282,22 @@ void NzForwardRenderQueue::AddBillboards(const NzMaterial* material, unsigned in if (!colorPtr) colorPtr.Reset(&NzColor::White, 0); // Pareil - std::vector& billboardVec = billboards[material]; - unsigned int prevSize = billboardVec.size(); - billboardVec.resize(prevSize + count); + auto it = billboards.find(material); + if (it == billboards.end()) + { + BatchedBillboardEntry entry(this, ResourceType_Material); + entry.materialListener = material; - BillboardData* billboardData = &billboardVec[prevSize]; + it = billboards.insert(std::make_pair(material, std::move(entry))).first; + } + + BatchedBillboardEntry& entry = it->second; + + auto& billboardVector = entry.billboards; + unsigned int prevSize = billboardVector.size(); + billboardVector.resize(prevSize + count); + + BillboardData* billboardData = &billboardVector[prevSize]; for (unsigned int i = 0; i < count; ++i) { float sin = std::sin(NzToRadians(*anglePtr)); @@ -259,11 +325,22 @@ void NzForwardRenderQueue::AddBillboards(const NzMaterial* material, unsigned in if (!alphaPtr) alphaPtr.Reset(&defaultAlpha, 0); // Pareil - std::vector& billboardVec = billboards[material]; - unsigned int prevSize = billboardVec.size(); - billboardVec.resize(prevSize + count); + auto it = billboards.find(material); + if (it == billboards.end()) + { + BatchedBillboardEntry entry(this, ResourceType_Material); + entry.materialListener = material; - BillboardData* billboardData = &billboardVec[prevSize]; + it = billboards.insert(std::make_pair(material, std::move(entry))).first; + } + + BatchedBillboardEntry& entry = it->second; + + auto& billboardVector = entry.billboards; + unsigned int prevSize = billboardVector.size(); + billboardVector.resize(prevSize + count); + + BillboardData* billboardData = &billboardVector[prevSize]; for (unsigned int i = 0; i < count; ++i) { float sin = std::sin(NzToRadians(*anglePtr));