From 55d9b5ae84954d369b58fc5334e75d86bf09aac1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 22 Sep 2012 20:02:55 +0200 Subject: [PATCH] MeshTools::interleave(): specialization for only one attribute array. Also minor documentation fixes. --- src/MeshTools/Interleave.h | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/MeshTools/Interleave.h b/src/MeshTools/Interleave.h index 64198e6fe..4f66df056 100644 --- a/src/MeshTools/Interleave.h +++ b/src/MeshTools/Interleave.h @@ -63,6 +63,12 @@ class Interleave { delete[] _data; } + /* Specialization for only one attribute array */ + template void operator()(Mesh* mesh, Buffer* buffer, Buffer::Usage usage, const T& attribute) { + mesh->setVertexCount(attribute.size()); + buffer->setData(attribute, usage); + } + template inline static size_t attributeCount(const T& first, const U&... next) { CORRADE_ASSERT(sizeof...(next) == 0 || attributeCount(next...) == first.size(), "MeshTools::interleave(): attribute arrays don't have the same length, nothing done.", 0); @@ -124,7 +130,7 @@ The only requirements to attribute array type is that it must have typedef function `size()` returning count of elements. In most cases it will be `std::vector` or `std::array`. -See also interleave(Mesh*, Buffer*, Buffer::Usage, const std::vector&...), +See also interleave(Mesh*, Buffer*, Buffer::Usage, const T&...), which writes the interleaved array directly into buffer of given mesh. @attention Each passed array should have the same size, if not, resulting @@ -142,12 +148,20 @@ template inline typename std::enable_ifsetData(attribute, usage); +mesh->setVertexCount(attribute.size()); +@endcode -@attention The buffer must be set as interleaved (see Mesh::addBuffer()), - otherwise this function does nothing. Binding the attributes to shader is - left to user. +@attention If there is more than one attribute array, the buffer must be set + as interleaved (see Mesh::addBuffer()), otherwise this function does + nothing. */ template inline void interleave(Mesh* mesh, Buffer* buffer, Buffer::Usage usage, const T&... attributes) { return Implementation::Interleave()(mesh, buffer, usage, attributes...);