From 240455502119774202796da43ea5e10f68239c53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 21 Jan 2022 16:35:17 +0100 Subject: [PATCH] MeshTools: move InterleaveFlags to a dedicated header. It will now get used from headers that don't transitively include Interleave.h, and introducing that dependency would be *ew*. --- src/Magnum/MeshTools/CMakeLists.txt | 1 + src/Magnum/MeshTools/Interleave.h | 56 +-------------- src/Magnum/MeshTools/InterleaveFlags.h | 96 ++++++++++++++++++++++++++ 3 files changed, 98 insertions(+), 55 deletions(-) create mode 100644 src/Magnum/MeshTools/InterleaveFlags.h diff --git a/src/Magnum/MeshTools/CMakeLists.txt b/src/Magnum/MeshTools/CMakeLists.txt index 1bfc7e271..9f688be75 100644 --- a/src/Magnum/MeshTools/CMakeLists.txt +++ b/src/Magnum/MeshTools/CMakeLists.txt @@ -52,6 +52,7 @@ set(MagnumMeshTools_HEADERS GenerateIndices.h GenerateNormals.h Interleave.h + InterleaveFlags.h Reference.h RemoveDuplicates.h Subdivide.h diff --git a/src/Magnum/MeshTools/Interleave.h b/src/Magnum/MeshTools/Interleave.h index ece30f231..8f4ddf9e9 100644 --- a/src/Magnum/MeshTools/Interleave.h +++ b/src/Magnum/MeshTools/Interleave.h @@ -36,6 +36,7 @@ #include #include "Magnum/Magnum.h" +#include "Magnum/MeshTools/InterleaveFlags.h" #include "Magnum/MeshTools/visibility.h" #include "Magnum/Trade/Trade.h" @@ -188,61 +189,6 @@ template void interleaveInto(Containers::ArrayView bu Implementation::writeInterleaved(stride, buffer.begin(), first, next...); } -/** -@brief Interleaving behavior flag -@m_since_latest - -@see @ref InterleaveFlags, - @ref interleavedLayout(const Trade::MeshData&, UnsignedInt, Containers::ArrayView, InterleaveFlags), - @ref interleave(const Trade::MeshData&, Containers::ArrayView, InterleaveFlags), - @ref concatenate(Containers::ArrayView>, InterleaveFlags) -*/ -enum class InterleaveFlag: UnsignedInt { - /** - * If the mesh is already interleaved, preserves existing layout of the - * attributes as well as any padding or aliasing among them, keeping the - * original stride and only removing the initial offset. This can also - * preserve attributes with an implementation-specific @ref VertexFormat. - * - * If not set or if the mesh is not interleaved to begin with, a tightly - * packed stride is calculated from vertex format sizes of all attributes, - * removing all padding. In that case an implementation-specific - * @ref VertexFormat can't be used for any attribute. - */ - PreserveInterleavedAttributes = 1 << 0, - - /** - * If a mesh is indexed, makes @ref interleave(const Trade::MeshData&, Containers::ArrayView, InterleaveFlags) - * preserve the index buffer even if it's not tightly packed. Since such - * data layouts are not commonly supported by GPU APIs, this flag is not - * set by default. - * - * If not set and the index buffer is strided, a tightly packed copy with - * the same index type is allocated for the output, dropping also any - * padding before or after the original index view. In such case however, - * the index type is not allowed to be implementation-specific. - * - * Has no effect when passed to @ref interleavedLayout(const Trade::MeshData&, UnsignedInt, Containers::ArrayView, InterleaveFlags) "interleavedLayout()" - * as that function doesn't preserve the index buffer. Has no effect when - * passed to @ref concatenate(Containers::ArrayView>, InterleaveFlags) "concatenate()" - * as that function allocates a new combined index buffer anyway. - * @see @ref isMeshIndexTypeImplementationSpecific() - */ - PreserveStridedIndices = 1 << 1 -}; - -/** -@brief Interleaving behavior flags -@m_since_latest - -@see @ref interleavedLayout(const Trade::MeshData&, UnsignedInt, Containers::ArrayView, InterleaveFlags), - @ref interleave(const Trade::MeshData&, Containers::ArrayView, InterleaveFlags), - @ref concatenate(Containers::ArrayView>, InterleaveFlags) -*/ -typedef Containers::EnumSet InterleaveFlags; - -CORRADE_ENUMSET_OPERATORS(InterleaveFlags) - /** @brief If the mesh data is interleaved @m_since{2020,06} diff --git a/src/Magnum/MeshTools/InterleaveFlags.h b/src/Magnum/MeshTools/InterleaveFlags.h new file mode 100644 index 000000000..19652f160 --- /dev/null +++ b/src/Magnum/MeshTools/InterleaveFlags.h @@ -0,0 +1,96 @@ +#ifndef Magnum_MeshTools_InterleaveFlags_h +#define Magnum_MeshTools_InterleaveFlags_h +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, + 2020, 2021 Vladimír Vondruš + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. +*/ + +/** @file + * @brief Enum @ref Magnum::MeshTools::InterleaveFlag, enum set @ref Magnum::MeshTools::InterleaveFlags + * @m_since_latest + */ + +#include + +#include "Magnum/Magnum.h" + +namespace Magnum { namespace MeshTools { + +/** +@brief Interleaving behavior flag +@m_since_latest + +@see @ref InterleaveFlags, + @ref interleavedLayout(const Trade::MeshData&, UnsignedInt, Containers::ArrayView, InterleaveFlags), + @ref interleave(const Trade::MeshData&, Containers::ArrayView, InterleaveFlags), + @ref concatenate(Containers::ArrayView>, InterleaveFlags) +*/ +enum class InterleaveFlag: UnsignedInt { + /** + * If the mesh is already interleaved, preserves existing layout of the + * attributes as well as any padding or aliasing among them, keeping the + * original stride and only removing the initial offset. This can also + * preserve attributes with an implementation-specific @ref VertexFormat. + * + * If not set or if the mesh is not interleaved to begin with, a tightly + * packed stride is calculated from vertex format sizes of all attributes, + * removing all padding. In that case an implementation-specific + * @ref VertexFormat can't be used for any attribute. + */ + PreserveInterleavedAttributes = 1 << 0, + + /** + * If a mesh is indexed, makes @ref interleave(const Trade::MeshData&, Containers::ArrayView, InterleaveFlags) + * preserve the index buffer even if it's not tightly packed. Since such + * data layouts are not commonly supported by GPU APIs, this flag is not + * set by default. + * + * If not set and the index buffer is strided, a tightly packed copy with + * the same index type is allocated for the output, dropping also any + * padding before or after the original index view. In such case however, + * the index type is not allowed to be implementation-specific. + * + * Has no effect when passed to @ref interleavedLayout(const Trade::MeshData&, UnsignedInt, Containers::ArrayView, InterleaveFlags) "interleavedLayout()" + * as that function doesn't preserve the index buffer. Has no effect when + * passed to @ref concatenate(Containers::ArrayView>, InterleaveFlags) "concatenate()" + * as that function allocates a new combined index buffer anyway. + * @see @ref isMeshIndexTypeImplementationSpecific() + */ + PreserveStridedIndices = 1 << 1 +}; + +/** +@brief Interleaving behavior flags +@m_since_latest + +@see @ref interleavedLayout(const Trade::MeshData&, UnsignedInt, Containers::ArrayView, InterleaveFlags), + @ref interleave(const Trade::MeshData&, Containers::ArrayView, InterleaveFlags), + @ref concatenate(Containers::ArrayView>, InterleaveFlags) +*/ +typedef Containers::EnumSet InterleaveFlags; + +CORRADE_ENUMSET_OPERATORS(InterleaveFlags) + +}} + +#endif