Trade: make creation of non-owning MeshData references easier.
While 27f6cc309d made it easier to create
references to attribute-less meshes by avoiding a branch on
attributeCount() (and then using a constructor with explicit vertex
count), code still had to branch on isIndexed() because indices() could
be called only on indexed meshes. This change allows code like
Trade::MeshData reference{data.primitive(),
{}, data.indexData(), Trade::MeshIndexData{data.indices()},
{}, data.vertexData(), Trade::meshAttributeDataNonOwningArray(data.attributeData()),
data.vertexCount()};
which works correctly for all cases and doesn't introduce extra branches
and code paths that would need to be tested. While definitely better, I
might still give up at some point and introduce some
Trade::MeshData::nonOwningImmutableReference() helper for this.
@ -2107,6 +2111,8 @@ template<class T> constexpr MeshAttributeData::MeshAttributeData(MeshAttribute n
template<classT>constexprMeshAttributeData::MeshAttributeData(MeshAttributename,constContainers::StridedArrayView2D<T>&data)noexcept:MeshAttributeData{name,Implementation::vertexFormatFor<typenamestd::remove_const<T>::type>(),UnsignedShort(data.size()[1]),Containers::StridedArrayView1D<constvoid>{{data.data(),~std::size_t{}},data.size()[0],data.stride()[0]},(CORRADE_CONSTEXPR_ASSERT(data.stride()[1]==sizeof(T),"Trade::MeshAttributeData: second view dimension is not contiguous"),nullptr)}{}
template<classT>constexprMeshAttributeData::MeshAttributeData(MeshAttributename,constContainers::StridedArrayView2D<T>&data)noexcept:MeshAttributeData{name,Implementation::vertexFormatFor<typenamestd::remove_const<T>::type>(),UnsignedShort(data.size()[1]),Containers::StridedArrayView1D<constvoid>{{data.data(),~std::size_t{}},data.size()[0],data.stride()[0]},(CORRADE_CONSTEXPR_ASSERT(data.stride()[1]==sizeof(T),"Trade::MeshAttributeData: second view dimension is not contiguous"),nullptr)}{}