From 1032a09865ad362207d48b35120644e7fc0fabcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Tue, 14 Dec 2021 12:49:45 +0100 Subject: [PATCH] SceneTools: new library. Nothing to see here so far. --- CMakeLists.txt | 3 +- doc/building.dox | 2 + doc/changelog.dox | 6 ++ doc/cmake.dox | 1 + doc/custom-buildsystems-order.dot | 3 + doc/namespaces.dox | 26 +++++++++ modules/FindMagnum.cmake | 8 ++- src/Magnum/CMakeLists.txt | 4 ++ src/Magnum/SceneTools/CMakeLists.txt | 71 +++++++++++++++++++++++ src/Magnum/SceneTools/SceneTools.h | 42 ++++++++++++++ src/Magnum/SceneTools/Test/CMakeLists.txt | 24 ++++++++ src/Magnum/SceneTools/visibility.h | 48 +++++++++++++++ 12 files changed, 234 insertions(+), 4 deletions(-) create mode 100644 src/Magnum/SceneTools/CMakeLists.txt create mode 100644 src/Magnum/SceneTools/SceneTools.h create mode 100644 src/Magnum/SceneTools/Test/CMakeLists.txt create mode 100644 src/Magnum/SceneTools/visibility.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 49af07d85..0f506b783 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -113,11 +113,12 @@ cmake_dependent_option(WITH_AUDIO "Build Audio library" OFF "NOT WITH_AL_INFO;NO option(WITH_DEBUGTOOLS "Build DebugTools library" ON) cmake_dependent_option(WITH_MESHTOOLS "Build MeshTools library" ON "NOT WITH_OBJIMPORTER;NOT WITH_SCENECONVERTER" ON) option(WITH_SCENEGRAPH "Build SceneGraph library" ON) +option(WITH_SCENETOOLS "Build SceneTools library" ON) option(WITH_SHADERS "Build Shaders library" ON) cmake_dependent_option(WITH_SHADERTOOLS "Build ShaderTools library" ON "NOT WITH_SHADERCONVERTER" ON) cmake_dependent_option(WITH_TEXT "Build Text library" ON "NOT WITH_FONTCONVERTER;NOT WITH_MAGNUMFONT;NOT WITH_MAGNUMFONTCONVERTER" ON) cmake_dependent_option(WITH_TEXTURETOOLS "Build TextureTools library" ON "NOT WITH_TEXT;NOT WITH_DISTANCEFIELDCONVERTER" ON) -cmake_dependent_option(WITH_TRADE "Build Trade library" ON "NOT WITH_MESHTOOLS;NOT WITH_PRIMITIVES;NOT WITH_IMAGECONVERTER;NOT WITH_ANYIMAGEIMPORTER;NOT WITH_ANYIMAGECONVERTER;NOT WITH_ANYSCENEIMPORTER;NOT WITH_OBJIMPORTER;NOT WITH_TGAIMAGECONVERTER;NOT WITH_TGAIMPORTER" ON) +cmake_dependent_option(WITH_TRADE "Build Trade library" ON "NOT WITH_MESHTOOLS;NOT WITH_PRIMITIVES;NOT WITH_SCENETOOLS;NOT WITH_IMAGECONVERTER;NOT WITH_ANYIMAGEIMPORTER;NOT WITH_ANYIMAGECONVERTER;NOT WITH_ANYSCENEIMPORTER;NOT WITH_OBJIMPORTER;NOT WITH_TGAIMAGECONVERTER;NOT WITH_TGAIMPORTER" ON) cmake_dependent_option(WITH_GL "Build GL library" ON "NOT WITH_SHADERS;NOT WITH_GL_INFO;NOT WITH_ANDROIDAPPLICATION;NOT WITH_WINDOWLESSIOSAPPLICATION;NOT WITH_CGLCONTEXT;NOT WITH_GLXAPPLICATION;NOT WITH_GLXCONTEXT;NOT WITH_XEGLAPPLICATION;NOT WITH_WINDOWLESSWGLAPPLICATION;NOT WITH_WGLCONTEXT;NOT WITH_WINDOWLESSWINDOWSEGLAPPLICATION;NOT WITH_DISTANCEFIELDCONVERTER" ON) option(WITH_PRIMITIVES "Build Primitives library" ON) diff --git a/doc/building.dox b/doc/building.dox index cae547137..20cb14138 100644 --- a/doc/building.dox +++ b/doc/building.dox @@ -488,6 +488,8 @@ specify which parts will be built and which not: - `WITH_PRIMITIVES` --- Build the @ref Primitives library. Enables also building of the Trade library. - `WITH_SCENEGRAPH` --- Build the @ref SceneGraph library +- `WITH_SCENETOOLS` --- Build the @ref SceneTools library. Enables also + building of the Trade library. - `WITH_SHADERS` --- Build the @ref Shaders library. Enables also building of the GL library. - `WITH_SHADERTOOLS` --- Build the @ref ShaderTools library diff --git a/doc/changelog.dox b/doc/changelog.dox index e75c9322c..f282dc127 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -177,6 +177,12 @@ See also: - Added @ref SceneGraph::Object::move() +@subsubsection changelog-latest-new-scenetools SceneTools library + +- New @ref SceneTools library that'll be a home for various whole-scene + optimization algorithms such as hierarchy flattening, redundant node + removal and such + @subsubsection changelog-latest-new-shaders Shaders library - All builtin shaders now have opt-in support for uniform buffers on desktop, diff --git a/doc/cmake.dox b/doc/cmake.dox index 34198240b..e58cd3950 100644 --- a/doc/cmake.dox +++ b/doc/cmake.dox @@ -196,6 +196,7 @@ the components. The optional components are: - `MeshTools` --- @ref MeshTools library - `Primitives` --- @ref Primitives library - `SceneGraph` --- @ref SceneGraph library +- `SceneTools` --- @ref SceneTools library - `Shaders` --- @ref Shaders library - `ShaderTools` --- @ref ShaderTools library - `Text` --- @ref Text library diff --git a/doc/custom-buildsystems-order.dot b/doc/custom-buildsystems-order.dot index 39e9ab7d5..cc5dc7800 100644 --- a/doc/custom-buildsystems-order.dot +++ b/doc/custom-buildsystems-order.dot @@ -44,6 +44,7 @@ digraph "Magnum library dependency order" { MagnumOpenGLTester [label="Magnum\nOpenGLTester" class="m-info"] MagnumPrimitives [label="Magnum\nPrimitives" class="m-info"] MagnumSceneGraph [label="Magnum\nSceneGraph" class="m-info"] + MagnumSceneTools [label="Magnum\nSceneTools" class="m-info"] MagnumShaders [label="Magnum\nShaders" class="m-info"] MagnumShaderTools [label="Magnum\nShaderTools" class="m-info"] MagnumText [label="Magnum\nText" class="m-info"] @@ -83,6 +84,8 @@ digraph "Magnum library dependency order" { MagnumPrimitives -> MagnumMeshTools MagnumPrimitives -> MagnumTrade + MagnumSceneTools -> MagnumTrade + MagnumSceneGraph -> Magnum MagnumShaders -> MagnumGL diff --git a/doc/namespaces.dox b/doc/namespaces.dox index e996bef79..d33a8a239 100644 --- a/doc/namespaces.dox +++ b/doc/namespaces.dox @@ -419,6 +419,32 @@ target_link_libraries(your-app PRIVATE Magnum::SceneGraph) See @ref building, @ref cmake and @ref scenegraph for more information. */ +/** @dir Magnum/SceneTools + * @brief Namespace @ref Magnum::SceneTools + * @m_since_latest + */ +/** @namespace Magnum::SceneTools +@brief Scene tools +@m_since_latest + +Scene manipulation and optimization tools. + +This library is built if `WITH_SCENETOOLS` is enabled when building Magnum. To +use this library with CMake, request the `SceneTools` component of the +`Magnum` package and link to the `Magnum::SceneTools` target: + +@code{.cmake} +find_package(Magnum REQUIRED SceneTools) + +# ... +target_link_libraries(your-app PRIVATE Magnum::SceneTools) +@endcode + +Additional utilities are built separately. See the +@ref magnum-sceneconverter "magnum-sceneconverter" utility documentation, +@ref building and @ref cmake for more information. +*/ + /** @dir Magnum/Shaders * @brief Namespace @ref Magnum::Shaders */ diff --git a/modules/FindMagnum.cmake b/modules/FindMagnum.cmake index e1fb257b2..9d2c1a6c9 100644 --- a/modules/FindMagnum.cmake +++ b/modules/FindMagnum.cmake @@ -60,6 +60,7 @@ # MeshTools - MeshTools library # Primitives - Primitives library # SceneGraph - SceneGraph library +# SceneTools - SceneTools library # Shaders - Shaders library # ShaderTools - ShaderTools library # Text - Text library @@ -229,7 +230,7 @@ foreach(_component ${Magnum_FIND_COMPONENTS}) # Unrolling the transitive dependencies here so this doesn't need to be # after resolving inter-component dependencies. Listing also all plugins. - if(_component MATCHES "^(Audio|DebugTools|MeshTools|Primitives|ShaderTools|Text|TextureTools|Trade|.+Importer|.+ImageConverter|.+Font|.+ShaderConverter)$") + if(_component MATCHES "^(Audio|DebugTools|MeshTools|Primitives|SceneTools|ShaderTools|Text|TextureTools|Trade|.+Importer|.+ImageConverter|.+Font|.+ShaderConverter)$") set(_MAGNUM_${_COMPONENT}_CORRADE_DEPENDENCIES PluginManager) endif() @@ -354,8 +355,8 @@ endif() # Component distinction (listing them explicitly to avoid mistakes with finding # components from other repositories) set(_MAGNUM_LIBRARY_COMPONENTS - Audio DebugTools GL MeshTools Primitives SceneGraph Shaders ShaderTools - Text TextureTools Trade + Audio DebugTools GL MeshTools Primitives SceneGraph SceneTools Shaders + ShaderTools Text TextureTools Trade WindowlessEglApplication EglContext OpenGLTester) set(_MAGNUM_PLUGIN_COMPONENTS AnyAudioImporter AnyImageConverter AnyImageImporter AnySceneConverter @@ -452,6 +453,7 @@ if(MAGNUM_TARGET_GL) list(APPEND _MAGNUM_Primitives_DEPENDENCIES GL) endif() set(_MAGNUM_SceneGraph_DEPENDENCIES ) +set(_MAGNUM_SceneTools_DEPENDENCIES Trade) set(_MAGNUM_Shaders_DEPENDENCIES GL) set(_MAGNUM_Text_DEPENDENCIES TextureTools) if(MAGNUM_TARGET_GL) diff --git a/src/Magnum/CMakeLists.txt b/src/Magnum/CMakeLists.txt index befc8e7fe..5c991ecc3 100644 --- a/src/Magnum/CMakeLists.txt +++ b/src/Magnum/CMakeLists.txt @@ -214,6 +214,10 @@ if(WITH_SCENEGRAPH) add_subdirectory(SceneGraph) endif() +if(WITH_SCENETOOLS) + add_subdirectory(SceneTools) +endif() + if(WITH_SHADERS) add_subdirectory(Shaders) endif() diff --git a/src/Magnum/SceneTools/CMakeLists.txt b/src/Magnum/SceneTools/CMakeLists.txt new file mode 100644 index 000000000..2e882bc0d --- /dev/null +++ b/src/Magnum/SceneTools/CMakeLists.txt @@ -0,0 +1,71 @@ +# +# 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. +# + +set(MagnumSceneTools_HEADERS + SceneTools.h + + visibility.h) + +# Main SceneTools library +add_library(MagnumSceneTools INTERFACE + ${MagnumSceneTools_HEADERS}) +set_target_properties(MagnumSceneTools PROPERTIES + DEBUG_POSTFIX "-d" + FOLDER "Magnum/SceneTools") +if(NOT BUILD_STATIC) + set_target_properties(MagnumSceneTools PROPERTIES VERSION ${MAGNUM_LIBRARY_VERSION} SOVERSION ${MAGNUM_LIBRARY_SOVERSION}) +elseif(BUILD_STATIC_PIC) + set_target_properties(MagnumSceneTools PROPERTIES POSITION_INDEPENDENT_CODE ON) +endif() +#target_link_libraries(MagnumSceneTools PUBLIC + #Magnum + #MagnumTrade) + +install(TARGETS MagnumSceneTools + RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR} + LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR} + ARCHIVE DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) +install(FILES ${MagnumSceneTools_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/SceneTools) + +if(BUILD_TESTS) + # Library with graceful assert for testing + add_library(MagnumSceneToolsTestLib INTERFACE ) + #set_target_properties(MagnumSceneToolsTestLib PROPERTIES + #DEBUG_POSTFIX "-d" + #FOLDER "Magnum/SceneTools") + #target_compile_definitions(MagnumSceneToolsTestLib PRIVATE + #"CORRADE_GRACEFUL_ASSERT" "MagnumSceneTools_EXPORTS") + if(BUILD_STATIC_PIC) + set_target_properties(MagnumSceneToolsTestLib PROPERTIES POSITION_INDEPENDENT_CODE ON) + endif() + #target_link_libraries(MagnumSceneToolsTestLib PUBLIC + #Magnum + #MagnumTrade) + + add_subdirectory(Test) +endif() + +# Magnum SceneTools target alias for superprojects +add_library(Magnum::SceneTools ALIAS MagnumSceneTools) diff --git a/src/Magnum/SceneTools/SceneTools.h b/src/Magnum/SceneTools/SceneTools.h new file mode 100644 index 000000000..4447c64eb --- /dev/null +++ b/src/Magnum/SceneTools/SceneTools.h @@ -0,0 +1,42 @@ +#ifndef Magnum_SceneTools_SceneTools_h +#define Magnum_SceneTools_SceneTools_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 Forward declarations for the @ref Magnum::SceneTools namespace + * @m_since_latest + */ + +#include "Magnum/configure.h" + +namespace Magnum { namespace SceneTools { + +#ifndef DOXYGEN_GENERATING_OUTPUT +#endif + +}} + +#endif diff --git a/src/Magnum/SceneTools/Test/CMakeLists.txt b/src/Magnum/SceneTools/Test/CMakeLists.txt new file mode 100644 index 000000000..69069041f --- /dev/null +++ b/src/Magnum/SceneTools/Test/CMakeLists.txt @@ -0,0 +1,24 @@ +# +# 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. +# diff --git a/src/Magnum/SceneTools/visibility.h b/src/Magnum/SceneTools/visibility.h new file mode 100644 index 000000000..08f112c58 --- /dev/null +++ b/src/Magnum/SceneTools/visibility.h @@ -0,0 +1,48 @@ +#ifndef Magnum_SceneTools_visibility_h +#define Magnum_SceneTools_visibility_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. +*/ + +#include + +#include "Magnum/configure.h" + +#ifndef DOXYGEN_GENERATING_OUTPUT +#ifndef MAGNUM_BUILD_STATIC + #if defined(MagnumSceneTools_EXPORTS) || defined(MagnumSceneToolsObjects_EXPORTS) + #define MAGNUM_SCENETOOLS_EXPORT CORRADE_VISIBILITY_EXPORT + #else + #define MAGNUM_SCENETOOLS_EXPORT CORRADE_VISIBILITY_IMPORT + #endif +#else + #define MAGNUM_SCENETOOLS_EXPORT CORRADE_VISIBILITY_STATIC +#endif +#define MAGNUM_SCENETOOLS_LOCAL CORRADE_VISIBILITY_LOCAL +#else +#define MAGNUM_SCENETOOLS_EXPORT +#define MAGNUM_SCENETOOLS_LOCAL +#endif + +#endif