From d7594fd5efe630db601d0361a4a289c376ab01b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 8 Jan 2025 12:59:46 +0100 Subject: [PATCH] MeshTools: remove STL-heavy generateFlatNormals() deprecated in 2019.10. And also the deprecated GenerateFlatNormals.h header alias. --- doc/changelog.dox | 4 ++ src/Magnum/MeshTools/CMakeLists.txt | 1 - src/Magnum/MeshTools/GenerateFlatNormals.h | 42 ------------------- src/Magnum/MeshTools/GenerateNormals.cpp | 37 ---------------- src/Magnum/MeshTools/GenerateNormals.h | 26 ------------ .../MeshTools/Test/GenerateNormalsTest.cpp | 39 ----------------- 6 files changed, 4 insertions(+), 145 deletions(-) delete mode 100644 src/Magnum/MeshTools/GenerateFlatNormals.h diff --git a/doc/changelog.dox b/doc/changelog.dox index 7fdd0ccbd..f6e0c5743 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -1769,6 +1769,10 @@ See also: @relativeref{Math::Frustum,begin()} / @relativeref{Math::Frustum,end()} instead - @cpp Math::swizzle() @ce, use @ref Math::gather() instead + - @cpp Magnum/MeshTools/GenerateFlatNormals.h @ce, use + @ref Magnum/MeshTools/GenerateNormals.h instead + - @ref Magnum::MeshTools::generateFlatNormals() overload that used an + excessive amount of STL - @cpp Text::FontFeature::MultiFile @ce, @cpp Text::AbstractFont::openData() @ce taking a vector of pairs, and @cpp openSingleData() @ce, use @ref Text::AbstractFont::openData() and diff --git a/src/Magnum/MeshTools/CMakeLists.txt b/src/Magnum/MeshTools/CMakeLists.txt index 1303472f1..f0f18b930 100644 --- a/src/Magnum/MeshTools/CMakeLists.txt +++ b/src/Magnum/MeshTools/CMakeLists.txt @@ -80,7 +80,6 @@ if(MAGNUM_BUILD_DEPRECATED) list(APPEND MagnumMeshTools_HEADERS CombineIndexedArrays.h FilterAttributes.h - GenerateFlatNormals.h Reference.h) endif() diff --git a/src/Magnum/MeshTools/GenerateFlatNormals.h b/src/Magnum/MeshTools/GenerateFlatNormals.h deleted file mode 100644 index e54c920c0..000000000 --- a/src/Magnum/MeshTools/GenerateFlatNormals.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef Magnum_MeshTools_GenerateFlatNormals_h -#define Magnum_MeshTools_GenerateFlatNormals_h -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, - 2020, 2021, 2022, 2023, 2024, 2025 - 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 - * @m_deprecated_since{2019,10} Use @ref Magnum/MeshTools/GenerateNormals.h instead. - */ - -#include "Magnum/configure.h" - -#ifdef MAGNUM_BUILD_DEPRECATED -#include "Magnum/MeshTools/GenerateNormals.h" -CORRADE_DEPRECATED_FILE("use Magnum/MeshTools/GenerateNormals.h instead") -#else -#error use Magnum/MeshTools/GenerateNormals.h instead -#endif - -#endif diff --git a/src/Magnum/MeshTools/GenerateNormals.cpp b/src/Magnum/MeshTools/GenerateNormals.cpp index d1aaac41b..a90e0f4b4 100644 --- a/src/Magnum/MeshTools/GenerateNormals.cpp +++ b/src/Magnum/MeshTools/GenerateNormals.cpp @@ -33,13 +33,6 @@ #include "Magnum/Math/Functions.h" #include "Magnum/Math/Vector3.h" -#ifdef MAGNUM_BUILD_DEPRECATED -#include - -#include "Magnum/MeshTools/Duplicate.h" -#include "Magnum/MeshTools/RemoveDuplicates.h" -#endif - namespace Magnum { namespace MeshTools { void generateFlatNormalsInto(const Containers::StridedArrayView1D& positions, const Containers::StridedArrayView1D& normals) { @@ -60,36 +53,6 @@ Containers::Array generateFlatNormals(const Containers::StridedArrayVie return out; } -#ifdef MAGNUM_BUILD_DEPRECATED -/* Original implementation kept verbatim as I can't be bothered rewriting it - using the new APIs (the original test is kept as well) */ -std::pair, std::vector> generateFlatNormals(const std::vector& indices, const std::vector& positions) { - CORRADE_ASSERT(!(indices.size()%3), "MeshTools::generateFlatNormals(): index count is not divisible by 3!", {}); - - /* Create normal for every triangle (assuming counterclockwise winding) */ - std::vector normalIndices; - normalIndices.reserve(indices.size()); - std::vector normals; - normals.reserve(indices.size()/3); - for(std::size_t i = 0; i != indices.size(); i += 3) { - const Vector3 normal = Math::cross(positions[indices[i+2]]-positions[indices[i+1]], - positions[indices[i]]-positions[indices[i+1]]).normalized(); - - /* Use the same normal for all three vertices of the face */ - normalIndices.push_back(normals.size()); - normalIndices.push_back(normals.size()); - normalIndices.push_back(normals.size()); - normals.push_back(normal); - } - - /* Remove duplicate normals and return */ - CORRADE_IGNORE_DEPRECATED_PUSH - normalIndices = duplicate(normalIndices, removeDuplicates(normals)); - CORRADE_IGNORE_DEPRECATED_POP - return {Utility::move(normalIndices), Utility::move(normals)}; -} -#endif - namespace { #if defined(CORRADE_TARGET_MSVC) && !defined(CORRADE_MSVC_COMPATIBILITY) && _MSC_VER >= 1920 && _MSC_VER < 1930 diff --git a/src/Magnum/MeshTools/GenerateNormals.h b/src/Magnum/MeshTools/GenerateNormals.h index 21e6d5e03..ea07e37fd 100644 --- a/src/Magnum/MeshTools/GenerateNormals.h +++ b/src/Magnum/MeshTools/GenerateNormals.h @@ -33,12 +33,6 @@ #include "Magnum/Magnum.h" #include "Magnum/MeshTools/visibility.h" -#ifdef MAGNUM_BUILD_DEPRECATED -#include /* std::pair */ -#include -#include -#endif - namespace Magnum { namespace MeshTools { /** @@ -81,26 +75,6 @@ conversions: */ MAGNUM_MESHTOOLS_EXPORT void generateFlatNormalsInto(const Containers::StridedArrayView1D& positions, const Containers::StridedArrayView1D& normals); -#ifdef MAGNUM_BUILD_DEPRECATED -/** -@brief Generate flat normals -@param indices Triangle face indices -@param positions Triangle vertex positions -@return Normal indices and vectors - -All vertices in each triangle face get the same normal vector. Removes -duplicates before returning. Expects that the position count is divisible by 3. - -@m_deprecated_since{2019,10} This will generate index buffer that's different - from the input @p indices array, so you'll need to recombine them using - @ref combineIndexedArrays() in order to have a single index array for both - vertices and normals. Because this makes the usage more complex than - strictly necessary, this function is deprecated in favor of - @ref generateFlatNormals(const Containers::StridedArrayView1D&). -*/ -CORRADE_DEPRECATED("use generateFlatNormals(const Containers::StridedArrayView1D&) instead") std::pair, std::vector> MAGNUM_MESHTOOLS_EXPORT generateFlatNormals(const std::vector& indices, const std::vector& positions); -#endif - /** @brief Generate smooth normals @param indices Triangle face indices diff --git a/src/Magnum/MeshTools/Test/GenerateNormalsTest.cpp b/src/Magnum/MeshTools/Test/GenerateNormalsTest.cpp index 18b9f0282..b0a258af8 100644 --- a/src/Magnum/MeshTools/Test/GenerateNormalsTest.cpp +++ b/src/Magnum/MeshTools/Test/GenerateNormalsTest.cpp @@ -38,20 +38,12 @@ #include "Magnum/Primitives/Cylinder.h" #include "Magnum/Trade/MeshData.h" -#ifdef MAGNUM_BUILD_DEPRECATED -#include -#include -#endif - namespace Magnum { namespace MeshTools { namespace Test { namespace { struct GenerateNormalsTest: TestSuite::Tester { explicit GenerateNormalsTest(); void flat(); - #ifdef MAGNUM_BUILD_DEPRECATED - void flatDeprecated(); - #endif void flatWrongCount(); void flatIntoWrongSize(); @@ -75,9 +67,6 @@ struct GenerateNormalsTest: TestSuite::Tester { GenerateNormalsTest::GenerateNormalsTest() { addTests({&GenerateNormalsTest::flat, - #ifdef MAGNUM_BUILD_DEPRECATED - &GenerateNormalsTest::flatDeprecated, - #endif &GenerateNormalsTest::flatWrongCount, &GenerateNormalsTest::flatIntoWrongSize, @@ -126,34 +115,6 @@ void GenerateNormalsTest::flat() { }), TestSuite::Compare::Container); } -#ifdef MAGNUM_BUILD_DEPRECATED -void GenerateNormalsTest::flatDeprecated() { - /* Two vertices connected by one edge, each wound in another direction */ - std::vector indices; - std::vector normals; - CORRADE_IGNORE_DEPRECATED_PUSH - std::tie(indices, normals) = generateFlatNormals({ - 0, 1, 2, - 1, 2, 3 - }, { - {-1.0f, 0.0f, 0.0f}, - {0.0f, -1.0f, 0.0f}, - {0.0f, 1.0f, 0.0f}, - {1.0f, 0.0f, 0.0f} - }); - CORRADE_IGNORE_DEPRECATED_POP - - CORRADE_COMPARE(indices, (std::vector{ - 0, 0, 0, - 1, 1, 1 - })); - CORRADE_COMPARE(normals, (std::vector{ - Vector3::zAxis(), - -Vector3::zAxis() - })); -} -#endif - void GenerateNormalsTest::flatWrongCount() { CORRADE_SKIP_IF_NO_ASSERT();