// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp #include #include namespace Nz { template void RenderQueue::Clear() { m_orderedRenderQueue.clear(); m_data.clear(); } template void RenderQueue::Insert(RenderData&& data) { m_data.emplace_back(std::move(data)); } template template void RenderQueue::Sort(IndexFunc&& func) { m_orderedRenderQueue.clear(); m_orderedRenderQueue.reserve(m_data.size()); std::size_t dataIndex = 0; for (const RenderData& renderData : m_data) m_orderedRenderQueue.emplace_back(func(renderData), dataIndex++); RenderQueueInternal::Sort(); } template typename RenderQueue::const_iterator RenderQueue::begin() const { return const_iterator(this, 0); } template bool RenderQueue::empty() const { return m_orderedRenderQueue.empty(); } template typename RenderQueue::const_iterator RenderQueue::end() const { return const_iterator(this, m_orderedRenderQueue.size()); } template typename RenderQueue::size_type RenderQueue::size() const { return m_orderedRenderQueue.size(); } template const RenderData& RenderQueue::GetData(std::size_t i) const { NazaraAssert(i < m_orderedRenderQueue.size(), "Cannot dereference post-end iterator"); return m_data[m_orderedRenderQueue[i].second]; } template RenderQueue::const_iterator::const_iterator(const RenderQueue* queue, std::size_t nextId) : m_nextDataId(nextId), m_queue(queue) { } template RenderQueue::const_iterator::const_iterator(const const_iterator& it) : m_nextDataId(it.m_nextDataId), m_queue(it.m_queue) { } template const RenderData& RenderQueue::const_iterator::operator*() const { return m_queue->GetData(m_nextDataId); } template typename RenderQueue::const_iterator& RenderQueue::const_iterator::operator=(const const_iterator& it) { m_nextDataId = it.m_nextDataId; m_queue = it.m_queue; return *this; } template typename RenderQueue::const_iterator& RenderQueue::const_iterator::operator++() { ++m_nextDataId; return *this; } template typename RenderQueue::const_iterator RenderQueue::const_iterator::operator++(int) { return iterator(m_queue, m_nextDataId++); } template bool RenderQueue::const_iterator::operator==(const typename RenderQueue::const_iterator& rhs) const { NazaraAssert(m_queue == rhs.m_queue, "Cannot compare iterator coming from different queues"); return m_nextDataId == rhs.m_nextDataId; } template bool RenderQueue::const_iterator::operator!=(const typename RenderQueue::const_iterator& rhs) const { return !operator==(rhs); } template void RenderQueue::const_iterator::swap(typename RenderQueue::const_iterator& rhs) { NazaraAssert(m_queue == rhs.m_queue, "Cannot swap iterator coming from different queues"); using std::swap; swap(m_nextDataId, rhs.m_nextDataId); } }