From 8dfd6fd4fc805ac9d1c0e783486384d76dfcce18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 20 Nov 2013 12:40:34 +0100 Subject: [PATCH] Trade: convenience MeshData*D::has*() functions. Makes it more intuitive (and shorter) than calling `if(data.textureCoords2DArrayCount())`. --- src/Trade/MeshData2D.h | 9 ++++++++- src/Trade/MeshData3D.h | 12 +++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/Trade/MeshData2D.h b/src/Trade/MeshData2D.h index 43b7ac6fb..bed9b2d3e 100644 --- a/src/Trade/MeshData2D.h +++ b/src/Trade/MeshData2D.h @@ -83,7 +83,11 @@ class MAGNUM_EXPORT MeshData2D { std::vector& indices(); const std::vector& indices() const; /**< @overload */ - /** @brief Count of position arrays */ + /** + * @brief Count of position arrays + * + * There is always at least one. + */ UnsignedInt positionArrayCount() const { return _positions.size(); } /** @@ -95,6 +99,9 @@ class MAGNUM_EXPORT MeshData2D { std::vector& positions(UnsignedInt id); const std::vector& positions(UnsignedInt id) const; /**< @overload */ + /** @brief Whether the data contain any 2D texture coordinates */ + bool hasTextureCoords2D() const { return !_textureCoords2D.empty(); } + /** @brief Count of 2D texture coordinate arrays */ UnsignedInt textureCoords2DArrayCount() const { return _textureCoords2D.size(); } diff --git a/src/Trade/MeshData3D.h b/src/Trade/MeshData3D.h index c1cffca6f..d157da1cc 100644 --- a/src/Trade/MeshData3D.h +++ b/src/Trade/MeshData3D.h @@ -84,7 +84,11 @@ class MAGNUM_EXPORT MeshData3D { std::vector& indices(); const std::vector& indices() const; /**< @overload */ - /** @brief Count of position arrays */ + /** + * @brief Count of position arrays + * + * There is always at least one. + */ UnsignedInt positionArrayCount() const { return _positions.size(); } /** @@ -96,6 +100,9 @@ class MAGNUM_EXPORT MeshData3D { std::vector& positions(UnsignedInt id); const std::vector& positions(UnsignedInt id) const; /**< @overload */ + /** @brief Whether the data contain any normals */ + bool hasNormals() const { return !_normals.empty(); } + /** @brief Count of normal arrays */ UnsignedInt normalArrayCount() const { return _normals.size(); } @@ -108,6 +115,9 @@ class MAGNUM_EXPORT MeshData3D { std::vector& normals(UnsignedInt id); const std::vector& normals(UnsignedInt id) const; /**< @overload */ + /** @brief Whether the data contain any 2D texture coordinates */ + bool hasTextureCoords2D() const { return !_textureCoords2D.empty(); } + /** @brief Count of 2D texture coordinate arrays */ UnsignedInt textureCoords2DArrayCount() const { return _textureCoords2D.size(); }