diff --git a/src/Magnum/MeshTools/CompressIndices.cpp b/src/Magnum/MeshTools/CompressIndices.cpp index 919d64bfb..b1bb1f50d 100644 --- a/src/Magnum/MeshTools/CompressIndices.cpp +++ b/src/Magnum/MeshTools/CompressIndices.cpp @@ -35,19 +35,14 @@ namespace Magnum { namespace MeshTools { namespace { -template constexpr Mesh::IndexType indexType(); -template<> constexpr Mesh::IndexType indexType() { return Mesh::IndexType::UnsignedByte; } -template<> constexpr Mesh::IndexType indexType() { return Mesh::IndexType::UnsignedShort; } -template<> constexpr Mesh::IndexType indexType() { return Mesh::IndexType::UnsignedInt; } - -template inline std::pair, Mesh::IndexType> compress(const std::vector& indices) { +template inline Containers::Array compress(const std::vector& indices) { Containers::Array buffer(indices.size()*sizeof(T)); for(std::size_t i = 0; i != indices.size(); ++i) { T index = static_cast(indices[i]); std::memcpy(buffer.begin()+i*sizeof(T), &index, sizeof(T)); } - return {std::move(buffer), indexType()}; + return buffer; } } @@ -55,24 +50,28 @@ template inline std::pair, Mesh::IndexType> com std::tuple, Mesh::IndexType, UnsignedInt, UnsignedInt> compressIndices(const std::vector& indices) { /** @todo Performance hint when range can be represented by smaller value? */ auto minmax = std::minmax_element(indices.begin(), indices.end()); - std::pair, Mesh::IndexType> typeData; + Containers::Array data; + Mesh::IndexType type; switch(Math::log(256, *minmax.second)) { case 0: - typeData = compress(indices); + data = compress(indices); + type = Mesh::IndexType::UnsignedByte; break; case 1: - typeData = compress(indices); + data = compress(indices); + type = Mesh::IndexType::UnsignedShort; break; case 2: case 3: - typeData = compress(indices); + data = compress(indices); + type = Mesh::IndexType::UnsignedInt; break; default: CORRADE_ASSERT(false, "MeshTools::compressIndices(): no type able to index" << *minmax.second << "elements.", {}); } - return std::make_tuple(std::move(typeData.first), typeData.second, *minmax.first, *minmax.second); + return std::make_tuple(std::move(data), type, *minmax.first, *minmax.second); } }}