void compressIndices(Mesh& mesh, Buffer& buffer, BufferUsage usage, const std::vector<UnsignedInt>& indices) { auto minmax = std::minmax_element(indices.begin(), indices.end()); /** @todo Performance hint when range can be represented by smaller value? */ std::size_t indexCount; Mesh::IndexType indexType; Containers::Array<char> data; std::tie(indexCount, indexType, data) = compressIndicesInternal(indices, *minmax.second); mesh.setIndexCount(indices.size()) .setIndexBuffer(buffer, 0, indexType, *minmax.first, *minmax.second); buffer.setData(data, usage); }
void compressIndices(Mesh* mesh, Buffer* buffer, Buffer::Usage usage, const std::vector<UnsignedInt>& indices) { auto minmax = std::minmax_element(indices.begin(), indices.end()); /** @todo Performance hint when range can be represented by smaller value? */ std::size_t indexCount; Mesh::IndexType indexType; char* data; std::tie(indexCount, indexType, data) = compressIndicesInternal(indices, *minmax.second); mesh->setIndexCount(indices.size()) ->setIndexBuffer(buffer, 0, indexType, *minmax.first, *minmax.second); buffer->setData(indexCount*Mesh::indexSize(indexType), data, usage); delete[] data; }
std::tuple<std::size_t, Mesh::IndexType, char*> compressIndices(const std::vector<UnsignedInt>& indices) { return compressIndicesInternal(indices, *std::max_element(indices.begin(), indices.end())); }