diff --git a/CMakeLists.txt b/CMakeLists.txt index f171d5872f..f7da8054a6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -98,8 +98,7 @@ cmake_dependent_option(WITH_TGAIMPORTER "Build TgaImporter plugin" OFF "NOT WITH cmake_dependent_option(WITH_AUDIO "Build Audio library" OFF "NOT WITH_AL_INFO;NOT WITH_ANYAUDIOIMPORTER;NOT WITH_WAVAUDIOIMPORTER" ON) option(WITH_DEBUGTOOLS "Build DebugTools library" ON) cmake_dependent_option(WITH_MESHTOOLS "Build MeshTools library" ON "NOT WITH_OBJIMPORTER" ON) -option(WITH_SHAPES "Build Shapes library" OFF) -cmake_dependent_option(WITH_SCENEGRAPH "Build SceneGraph library" ON "NOT WITH_SHAPES" ON) +option(WITH_SCENEGRAPH "Build SceneGraph library" ON) option(WITH_SHADERS "Build Shaders library" 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) diff --git a/Doxyfile b/Doxyfile index e0c55ed222..c24b58fd41 100644 --- a/Doxyfile +++ b/Doxyfile @@ -243,8 +243,6 @@ ALIASES = \ "configurationvalueref{1}=@see @ref configurationvalues \"Corrade::Utility::ConfigurationValue<\1>\"" \ "configurationvalue{1}=@brief Configuration value parser and writer @xrefitem configurationvalues \"Configuration value parser and writer\" \"Configuration value parsers and writers for custom types\" Allows parsing and writing @ref \1 from and to @ref Corrade::Utility::Configuration and use it with @ref Corrade::Utility::Arguments." \ "tweakableliteral{1}=@brief Tweakable literal parser @xrefitem tweakableliterals \"Tweakable literal parser\" \"Tweakable literal parsers\" Allows using @ref \1 with @ref Corrade::Utility::Tweakable." \ - "collisionoccurenceoperator{2}=@relatesalso \1 @brief Collision occurence of @ref \1 and @ref \2 @see @ref \2::operator%(const \1&) const" \ - "collisionoperator{2}=@relatesalso \1 @brief Collision of @ref \1 and @ref \2 @see @ref \2::operator/(const \1&) const" \ "partialsupport=@xrefitem partialsupport \"Partially supported\" \"List of partially supported features\"" \ "thirdparty=@xrefitem credits-third-party \"Third-party components\" \"Third-party components\"" \ "todoc=@xrefitem todoc \"Documentation todo\" \"Documentation-related todo list\"" \ diff --git a/Doxyfile-mcss b/Doxyfile-mcss index f7f2ebb7ff..640599c656 100644 --- a/Doxyfile-mcss +++ b/Doxyfile-mcss @@ -24,8 +24,6 @@ ALIASES = \ "configurationvalueref{1}=@see @ref configurationvalues \"Corrade::Utility::ConfigurationValue<\1>\"" \ "configurationvalue{1}=@brief Configuration value parser and writer @xrefitem configurationvalues \"Configuration value parser and writer\" \"Configuration value parsers and writers for custom types\" Allows parsing and writing @ref \1 from and to @ref Corrade::Utility::Configuration and use it with @ref Corrade::Utility::Arguments." \ "tweakableliteral{1}=@brief Tweakable literal parser @xrefitem tweakableliterals \"Tweakable literal parser\" \"Tweakable literal parsers\" Allows using @ref \1 with @ref Corrade::Utility::Tweakable." \ - "collisionoccurenceoperator{2}=@relatesalso \1 @brief Collision occurence of @ref \1 and @ref \2 @see @ref \2::operator%(const \1&) const" \ - "collisionoperator{2}=@relatesalso \1 @brief Collision of @ref \1 and @ref \2 @see @ref \2::operator/(const \1&) const" \ "partialsupport=@xrefitem partialsupport \"Partially supported\" \"List of partially supported features\"" \ "thirdparty=@xrefitem credits-third-party \"Third-party components\" \"Third-party components\"" \ "todoc=@xrefitem todoc \"Documentation todo\" \"Documentation-related todo list\"" \ diff --git a/Doxyfile-public b/Doxyfile-public index 85846f4c90..7342f5bcf4 100644 --- a/Doxyfile-public +++ b/Doxyfile-public @@ -19,8 +19,6 @@ ALIASES = \ "configurationvalueref{1}=@see @ref configurationvalues \"Corrade::Utility::ConfigurationValue<\1>\"" \ "configurationvalue{1}=@brief Configuration value parser and writer @xrefitem configurationvalues \"Configuration value parser and writer\" \"Configuration value parsers and writers for custom types\" Allows parsing and writing @ref \1 from and to @ref Corrade::Utility::Configuration and use it with @ref Corrade::Utility::Arguments." \ "tweakableliteral{1}=@brief Tweakable literal parser @xrefitem tweakableliterals \"Tweakable literal parser\" \"Tweakable literal parsers\" Allows using @ref \1 with @ref Corrade::Utility::Tweakable." \ - "collisionoccurenceoperator{2}=@relatesalso \1 @brief Collision occurence of @ref \1 and @ref \2 @see @ref \2::operator%(const \1&) const" \ - "collisionoperator{2}=@relatesalso \1 @brief Collision of @ref \1 and @ref \2 @see @ref \2::operator/(const \1&) const" \ "partialsupport=@xrefitem partialsupport \"Partially supported\" \"List of partially supported features\"" \ "thirdparty=@xrefitem credits-third-party \"Third-party components\" \"Third-party components\"" \ "todoc=@todo" \ diff --git a/doc/building.dox b/doc/building.dox index 5f695d85a5..995d094a22 100644 --- a/doc/building.dox +++ b/doc/building.dox @@ -500,9 +500,9 @@ information. See also @ref corrade-cmake and @ref Corrade/Corrade.h for related info for the Corrade library. By default the engine is built with nearly everything except the @ref Audio -and @ref Shapes libraries, plugins, command-line utilities and application -libraries (see below). Using the following `WITH_*` CMake options you can -specify which parts will be built and which not: +library, plugins, command-line utilities and application libraries (see below). +Using the following `WITH_*` CMake options you can specify which parts will be +built and which not: - `WITH_AUDIO` --- Build the @ref Audio library. Depends on [OpenAL](https://www.openal.org/), not built by default. @@ -513,12 +513,9 @@ specify which parts will be built and which not: building of the Trade library. - `WITH_PRIMITIVES` --- Build the @ref Primitives library. Enables also building of the Trade library. -- `WITH_SCENEGRAPH` --- Build the @ref SceneGraph library. Enabled - automatically if `WITH_SHAPES` is enabled. +- `WITH_SCENEGRAPH` --- Build the @ref SceneGraph library - `WITH_SHADERS` --- Build the @ref Shaders library. Enables also building of the GL library. -- `WITH_SHAPES` @m_class{m-label m-danger} **deprecated** --- Build the - @ref Shapes library. Enables also building of the SceneGraph library. - `WITH_TEXT` --- Build the @ref Text library. Enables also building of the TextureTools library. - `WITH_TEXTURETOOLS` --- Build the @ref TextureTools library. Enabled diff --git a/doc/changelog-old.dox b/doc/changelog-old.dox index 15ca702051..3260db9931 100644 --- a/doc/changelog-old.dox +++ b/doc/changelog-old.dox @@ -305,8 +305,8 @@ for a high-level overview. imported data - @ref MeshTools::interleaveInto() for interleaving data into existing buffer -- @ref Shapes::Shape::collision() function as complement to - @ref Shapes::Shape::collides() +- `Shapes::Shape::collision()` function as complement to + `Shapes::Shape::collides()` - @ref Platform::GlutApplication::KeyEvent finally has more complete key support - @ref Math::Range::data() function, useful when querying range values from @@ -672,8 +672,7 @@ for a high-level overview. avoid accidental memory leaks - New translation-only transformation in @ref SceneGraph supporting also purely integral coordinates, useful e.g. for UI or 2D platformers. -- Detailed collision queries and new @ref Shapes::InvertedSphere "InvertedSphere" - shape in Shapes library +- Detailed collision queries and new `InvertedSphere` shape in Shapes library - Texture support in @ref Shaders::Flat - Mouse button queries in @ref Platform::Sdl2Application::MouseMoveEvent "Platform::*Application::MouseMoveEvent" diff --git a/doc/changelog.dox b/doc/changelog.dox index bdf3963e9b..cf2c59386a 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -266,6 +266,8 @@ See also: - Removed all aliases to @ref GL library functionality in the root namespace (and root include path) which were deprecated in 2018.04 +- Removed the `Shapes` library together with `DebugTools::ShapeRenderer`, + which was is a failed design experiment deprecated since 2018.10 - In order to be compatible with both Emscripten 1.38.27 and the versions before, all Emscripten markup is now expected to have the HTML @cb{.html} @ce element identified by @cb{.css} #canvas @ce. You need to: - update your HTML markup to use @@ -952,14 +954,13 @@ Released 2018-10-23, tagged as @subsection changelog-2018-10-deprecated Deprecated APIs -- The @ref Magnum::Shapes library is a failed design experiment and is - scheduled for removal in a future release, together with - @ref DebugTools::ShapeRenderer. Related geometry algorithms were moved to - @ref Magnum::Math::Distance and @ref Magnum::Math::Intersection; if you - need a full-fledged physics library, please have look at - [Bullet](https://bulletphysics.org), which has Magnum integration in - @ref Magnum::BulletIntegration, or at [Box2D](https://box2d.org/), which - has a @ref examples-box2d "Magnum example" as well. +- The `Shapes` library is a failed design experiment and is scheduled for + removal in a future release, together with `DebugTools::ShapeRenderer`. + Related geometry algorithms were moved to @ref Math::Distance and + @ref Math::Intersection; if you need a full-fledged physics library, please + have look at [Bullet](https://bulletphysics.org), which has Magnum + integration in @ref BulletIntegration, or at [Box2D](https://box2d.org/), + which has a @ref examples-box2d "Magnum example" as well. - @ref Platform::GlutApplication is based on an outdated toolkit and thus scheduled for removal in a future release. Please consider switching to @ref Platform::Sdl2Application or @ref Platform::GlfwApplication as soon as @@ -1010,8 +1011,8 @@ Released 2018-10-23, tagged as @subsection changelog-2018-10-compatibility Potential compatibility breakages, removed APIs -- The @ref Magnum::Shapes library is not built by default anymore due to its - deprecated status +- The `Shapes` library is not built by default anymore due to its deprecated + status - @ref Audio::Playable is now by default omnidirectional instead of having source in direction of negative Z axis (the direction has effect only when setting inner and outer cone properties of @ref Audio::Source). diff --git a/doc/cmake.dox b/doc/cmake.dox index c24bf32f5d..f694b423a6 100644 --- a/doc/cmake.dox +++ b/doc/cmake.dox @@ -115,7 +115,6 @@ the components. The optional components are: - `Primitives` --- @ref Primitives library - `SceneGraph` --- @ref SceneGraph library - `Shaders` --- @ref Shaders library -- `Shapes` @m_class{m-label m-danger} **deprecated** --- @ref Shapes library - `Text` --- @ref Text library - `TextureTools` --- @ref TextureTools library - `Trade` --- @ref Trade library diff --git a/doc/coding-style.dox b/doc/coding-style.dox index 7423f996cf..b11d306210 100644 --- a/doc/coding-style.dox +++ b/doc/coding-style.dox @@ -101,19 +101,6 @@ these are defined: The @c \@glsl command expands to \@cb{.glsl}, making it possible to have inline highlighted GLSL code snippets, similarly to @c \@cpp and @c \@cmake. -@subsubsection coding-style-documentation-commands-collisionoperator Shape collision operators - -Out-of-class operators for collision and collision occurence in Shapes -namespace should be marked with @c \@collisionoperator and @c \@collisionoccurenceoperator, -e.g.: - -@snippet coding-style.h collisionoperator - -They will appear as related functions within documentation of class for which -the operator is implemented (not of class in which the operator is -implemented), thus efficiently connecting the two classes together in the -documentation. - @subsubsection coding-style-documentation-commands-extension Links to OpenGL, Vulkan and OpenAL extensions If an OpenGL extension is referenced in the documentation, it should be done diff --git a/doc/compilation-speedup.dox b/doc/compilation-speedup.dox index b037414a2c..df12843f50 100644 --- a/doc/compilation-speedup.dox +++ b/doc/compilation-speedup.dox @@ -63,7 +63,6 @@ available, each namespace has its own: - @ref Magnum/Platform/Platform.h - @ref Magnum/SceneGraph/SceneGraph.h - @ref Magnum/Shaders/Shaders.h -- @ref Magnum/Shapes/Shapes.h - @ref Magnum/Text/Text.h - @ref Magnum/Trade/Trade.h - @ref Magnum/Ui/Ui.h diff --git a/doc/custom-buildsystems-order.dot b/doc/custom-buildsystems-order.dot index f795800482..8ab4fa1fd3 100644 --- a/doc/custom-buildsystems-order.dot +++ b/doc/custom-buildsystems-order.dot @@ -45,7 +45,6 @@ digraph "Magnum library dependency order" { MagnumPrimitives [label="Magnum\nPrimitives" class="m-info"] MagnumSceneGraph [label="Magnum\nSceneGraph" class="m-info"] MagnumShaders [label="Magnum\nShaders" class="m-info"] - MagnumShapes [label="Magnum\nShapes" class="m-dim"] MagnumText [label="Magnum\nText" class="m-info"] MagnumTextureTools [label="Magnum\nTextureTools" class="m-info"] MagnumTrade [label="Magnum\nTrade" class="m-info"] @@ -71,7 +70,6 @@ digraph "Magnum library dependency order" { MagnumDebugTools -> MagnumMeshTools [style=dotted] MagnumDebugTools -> MagnumPrimitives [style=dotted] MagnumDebugTools -> MagnumShaders [style=dotted] - MagnumDebugTools -> MagnumShapes [style=dotted class="m-dim"] MagnumDebugTools -> MagnumSceneGraph [style=dotted] MagnumGL -> Magnum @@ -87,8 +85,6 @@ digraph "Magnum library dependency order" { MagnumShaders -> MagnumGL - MagnumShapes -> MagnumSceneGraph [class="m-dim"] - MagnumText -> MagnumTextureTools MagnumText -> MagnumGL [style=dotted] diff --git a/doc/debug-tools.dox b/doc/debug-tools.dox index e1818a0333..4a83950ce3 100644 --- a/doc/debug-tools.dox +++ b/doc/debug-tools.dox @@ -61,7 +61,7 @@ Example usage: visualizing object position, rotation and scaling using @snippet MagnumDebugTools-gl.cpp debug-tools-renderers -See @ref DebugTools::ObjectRenderer and @ref DebugTools::ShapeRenderer for more +See @ref DebugTools::ObjectRenderer and @ref DebugTools::ForceRenderer for more information. */ } diff --git a/doc/features.dox b/doc/features.dox index d6b7cb96a2..cdf60989e6 100644 --- a/doc/features.dox +++ b/doc/features.dox @@ -40,8 +40,6 @@ necessary to read through everything, pick only what you need. - @subpage opengl-wrapping --- @copybrief opengl-wrapping - @subpage shaders --- @copybrief shaders - @subpage scenegraph --- @copybrief scenegraph -- @subpage shapes @m_class{m-label m-danger} **deprecated** --- - @copybrief shapes - @subpage debug-tools --- @copybrief debug-tools - @subpage ui --- @copybrief ui */ diff --git a/doc/namespaces.dox b/doc/namespaces.dox index 632c1f63fa..7855100dbe 100644 --- a/doc/namespaces.dox +++ b/doc/namespaces.dox @@ -371,44 +371,6 @@ target_link_libraries(your-app Magnum::Shaders) See @ref building, @ref cmake and @ref shaders for more information. */ -/** @dir Magnum/Shapes -@brief Namespace @ref Magnum::Shapes - -@deprecated The @ref Magnum::Shapes library is a failed design experiment and - is scheduled for removal in a future release. Related geometry algorithms - were moved to @ref Magnum::Math::Distance and @ref Magnum::Math::Intersection; - if you need a full-fledged physics library, please have look at - [Bullet](https://bulletphysics.org), which has Magnum integration in - @ref Magnum::BulletIntegration, or at [Box2D](https://box2d.org/), which - has a @ref examples-box2d "Magnum example" as well. -*/ -/** @namespace Magnum::Shapes -@brief Shape library - -@deprecated This library is a failed design experiment and is scheduled for - removal in a future release. Related geometry algorithms were moved to - @ref Math::Distance and @ref Math::Intersection; if you need a full-fledged - physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration, or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. - -Collision detection system. - -This library is built if `WITH_SHAPES` is enabled when building Magnum. To use -this library with CMake, you need to request the `Shapes` component of the -`Magnum` package and link to the `Magnum::Shapes` target: - -@code{.cmake} -find_package(Magnum REQUIRED Shapes) - -# ... -target_link_libraries(your-app Magnum::Shapes) -@endcode - -See @ref building, @ref cmake and @ref shapes for more information. -*/ - /** @dir Magnum/Text * @brief Namespace @ref Magnum::Text */ diff --git a/doc/scenegraph.dox b/doc/scenegraph.dox index 8938ba68fe..082e207560 100644 --- a/doc/scenegraph.dox +++ b/doc/scenegraph.dox @@ -208,13 +208,7 @@ for more detailed information and usage examples: - @ref SceneGraph::Animable "SceneGraph::Animable*D" --- Adds animation functionality to given object. Group of animables can be then controlled using @ref SceneGraph::AnimableGroup "SceneGraph::AnimableGroup*D". -- @ref Shapes::Shape @m_class{m-label m-danger} **deprecated** --- Adds a - collision shape to given object. Group of shapes can be then controlled - using @ref Shapes::ShapeGroup "Shapes::ShapeGroup*D". See @ref shapes for - more information. - @ref DebugTools::ObjectRenderer "DebugTools::ObjectRenderer*D", - @ref DebugTools::ShapeRenderer "DebugTools::ShapeRenderer*D" - @m_class{m-label m-danger} **deprecated**, @ref DebugTools::ForceRenderer "DebugTools::ForceRenderer*D" --- Visualize object properties, object shape or force vector for debugging purposes. See @ref debug-tools for more information. diff --git a/doc/shapes.dox b/doc/shapes.dox deleted file mode 100644 index 354459d02e..0000000000 --- a/doc/shapes.dox +++ /dev/null @@ -1,185 +0,0 @@ -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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. -*/ - -namespace Magnum { -/** @page shapes Collision detection -@brief Collection of simple shapes for high performance collision detection. - -@tableofcontents -@m_footernavigation - -@deprecated This library is a failed design experiment and is scheduled for - removal in a future release. Related geometry algorithms were moved to - @ref Magnum::Math::Distance "Math::Distance" and - @ref Magnum::Math::Intersection "Math::Intersection"; if you need a - full-fledged physics library, please have look at - [Bullet](https://bulletphysics.org), which has Magnum integration in - @ref Magnum::BulletIntegration "BulletIntegration" or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. - -The essential thing in collision detection is to define a complex object with -collection of simple shapes, for which it is easy to detect collisions. The -library is contained in @ref Shapes namespace, see its documentation for more -information about building and usage with CMake. - -These shapes can be either one-, two- or three-dimensional and they can be -grouped together using various operations. - -@section shapes-collection Available shapes - -Magnum provides a set of simple shapes for collision detection, similarly to -what is found in many other collision detection libraries. Additionally some -shapes are provided in inverted form --- e.g. inverted box detects collisions on -outside instead of inside, which might be useful for example to create bounds -around platformer game level. - -@subsection shapes-1D One-dimensional shapes - -- @ref Shapes::Point "Shapes::Point*D" --- @copybrief Shapes::Point -- @ref Shapes::Line "Shapes::Line*D" --- @copybrief Shapes::Line -- @ref Shapes::LineSegment "Shapes::LineSegment*D" --- @copybrief Shapes::LineSegment - -Because of numerical instability it's not possible to detect collisions of -line and point. Collision of two lines can be detected only in 2D. - -@subsection shapes-2D Two-dimensional shapes - -- @ref Shapes::Plane --- @copybrief Shapes::Plane - -@subsection shapes-3D Three-dimensional shapes - -- @ref Shapes::Sphere "Shapes::Sphere*D" --- @copybrief Shapes::Sphere -- @ref Shapes::InvertedSphere "Shapes::InvertedSphere*D" --- @copybrief Shapes::InvertedSphere -- @ref Shapes::Cylinder "Shapes::Cylinder*D" --- @copybrief Shapes::Cylinder -- @ref Shapes::Capsule "Shapes::Capsule*D" --- @copybrief Shapes::Capsule -- @ref Shapes::AxisAlignedBox "Shapes::AxisAlignedBox*D" --- @copybrief Shapes::AxisAlignedBox -- @ref Shapes::Box "Shapes::Box*D" --- @copybrief Shapes::Box - -The easiest (and most efficient) shape combination for detecting collisions -is point and sphere, followed by two spheres. Computing collision of two boxes -is least efficient. - -@section shapes-composition Creating shape compositions - -Shapes can be composed together using one of three available logical -operations: AND, OR and NOT. These operations are mapped to @cpp && @ce, @cpp || @ce -and @cpp ! @ce operators, so for example creating negation of logical OR of -line segment and point is simple as this: - -@code{.cpp} -Shapes::LineSegment3D segment; -Shapes::Point3D point; - -Shapes::Composition3D composition = !(segment || point); -@endcode - -@note Logical operations are not the same as set operations --- intersection of - two spheres will not generate any collision if they are disjoint, but - logical AND will if the object collides with both of them. - -@subsection shapes-simplification Providing simplified version of shape for better performance - -If there are many shapes composed together, it might hurt performance of -collision detection, because it might be testing collision with more shapes -than necessary. It's then good to specify simplified version of such shape, -so the collision detection is done on the complex one if and only if collision -was detected with the simplified shape. It is in fact logical AND using the -@cpp && @ce operator --- the collision is initially detected on first -(simplified) shape and then on the other: - -@code{.cpp} -Shapes::Sphere3D sphere; -Shapes::Box3D box; -Shapes::AxisAlignedBox3D simplified; - -Shapes::Composition3D composition = simplified && (sphere || box); -@endcode - -@section shapes-collisions Detecting shape collisions - -Shape pairs which have collision occurence detection implemented can be tested -for collision using the @cpp % @ce operator. The operator returns boolean -describing whether the collision happened or not. Example: - -@code{.cpp} -Shapes::Point3D point; -Shapes::Sphere3D sphere; - -bool collide = point % sphere; -@endcode - -As this is useful for e.g. menu handling and simple particle systems, for -serious physics you often need more information like contact point, separation -normal and penetration depth. For shape pairs which have implemented this -detailed collision detection you can use the `/` operator, which returns -@ref Shapes::Collision object. Note that unlike with the `%` operator mentioned -above, this operation is not commutative. See @ref Shapes::Collision class -documentation for more information about the returned data. Example: - -@code{.cpp} -const Shapes::Collision3D c = point/sphere; -if(c) { - Vector3 translation = c.separationNormal()*c.separationDistance(); - // translate point by translation... -} -@endcode - -@section shapes-scenegraph Integration with scene graph - -Shape can be attached to object in the scene using @ref Shapes::Shape feature. -In conjunction with @ref Shapes::ShapeGroup you can use -@ref Shapes::Shape::collides() and @ref Shapes::Shape::collision() similarly to -the @cpp % @ce and @cpp / @ce operators above. Please note that the shape group -caches the absolute transformations of all shapes and thus you need to -explicitly call @ref Shapes::ShapeGroup::setClean() before computing the -collisions if you did any modifications to the objects in the scene. - -Scenegraph-flavored equivalent to the above code: - -@code{.cpp} -Shapes::ShapeGroup3D shapes; -Object3D& a; -auto aShape = new Shapes::Shape(a, {{}, 23.0f}, &shapes); - -Object3D& b; -auto bShape = new Shapes::Shape(b, {{1.0f, 0.2f, 3.0f}}, &shapes); - -// Translate point so the objects no longer collide -shapes.setClean(); -if(aShape->collides(*bShape)) { - const Shapes::Collision3D c = aShape->collision(*bShape); - b.translate(c.separationNormal()*c.separationDistance()); -} -@endcode - -There is also @ref Shapes::ShapeGroup::firstCollision() function which returns -arbitrary first collision for given shape in whole group (or @cpp nullptr @ce, -if there isn't any collision). - -You can also use @ref DebugTools::ShapeRenderer to visualize the shapes for -debugging purposes. See also @ref scenegraph for introduction. -*/ -} diff --git a/doc/snippets/coding-style.h b/doc/snippets/coding-style.h index 4e30dc4239..e2ad2c7b8f 100644 --- a/doc/snippets/coding-style.h +++ b/doc/snippets/coding-style.h @@ -9,14 +9,6 @@ void setPolygonMode(PolygonMode mode); #endif /* [glcompatibility] */ -/* [collisionoperator] */ -/** @collisionoccurenceoperator{Point,Sphere} */ -inline bool operator%(const Point& a, const Sphere& b) { return b % a; } - -/** @collisionoperator{Point,Sphere} */ -inline Collision operator/(const Point& a, const Sphere& b) { return (b/a).reverted(); } -/* [collisionoperator] */ - /* [extension] */ /** @gl_extension{ARB,timer_query} */ /* [extension] */ diff --git a/modules/FindMagnum.cmake b/modules/FindMagnum.cmake index a69d24d2f3..8e31d3a8f5 100644 --- a/modules/FindMagnum.cmake +++ b/modules/FindMagnum.cmake @@ -63,7 +63,6 @@ # Primitives - Primitives library # SceneGraph - SceneGraph library # Shaders - Shaders library -# Shapes - Shapes library # Text - Text library # TextureTools - TextureTools library # Trade - Trade library @@ -337,9 +336,6 @@ set(_MAGNUM_LIBRARY_COMPONENT_LIST WindowlessEglApplication WindowlessGlxApplication WindowlessIosApplication WindowlessWglApplication WindowlessWindowsEglApplication CglContext EglContext GlxContext WglContext OpenGLTester) -if(MAGNUM_BUILD_DEPRECATED) - list(APPEND _MAGNUM_LIBRARY_COMPONENT_LIST Shapes) -endif() set(_MAGNUM_PLUGIN_COMPONENT_LIST AnyAudioImporter AnyImageConverter AnyImageImporter AnySceneImporter MagnumFont MagnumFontConverter ObjImporter TgaImageConverter TgaImporter @@ -352,9 +348,9 @@ set(_MAGNUM_Audio_DEPENDENCIES ) set(_MAGNUM_DebugTools_DEPENDENCIES ) if(MAGNUM_TARGET_GL) - # MeshTools, Primitives, SceneGraph, Shaders and Shapes are used only for - # GL renderers. All of this is optional, compiled in only if the base - # library was selected. + # MeshTools, Primitives, SceneGraph and Shaders are used only for GL + # renderers. All of this is optional, compiled in only if the base library + # was selected. list(APPEND _MAGNUM_DebugTools_DEPENDENCIES MeshTools Primitives SceneGraph Shaders Trade GL) set(_MAGNUM_DebugTools_MeshTools_DEPENDENCY_IS_OPTIONAL ON) set(_MAGNUM_DebugTools_Primitives_DEPENDENCY_IS_OPTIONAL ON) @@ -362,10 +358,6 @@ if(MAGNUM_TARGET_GL) set(_MAGNUM_DebugTools_Shaders_DEPENDENCY_IS_OPTIONAL ON) set(_MAGNUM_DebugTools_Trade_DEPENDENCY_IS_OPTIONAL ON) set(_MAGNUM_DebugTools_GL_DEPENDENCY_IS_OPTIONAL ON) - if(MAGNUM_BUILD_DEPRECATED) - list(APPEND _MAGNUM_DebugTools_DEPENDENCIES Shapes) - set(_MAGNUM_DebugTools_Shapes_DEPENDENCY_IS_OPTIONAL ON) - endif() endif() set(_MAGNUM_MeshTools_DEPENDENCIES ) @@ -398,9 +390,6 @@ endif() set(_MAGNUM_Primitives_DEPENDENCIES Trade) set(_MAGNUM_SceneGraph_DEPENDENCIES ) set(_MAGNUM_Shaders_DEPENDENCIES GL) -if(MAGNUM_BUILD_DEPRECATED) - set(_MAGNUM_Shapes_DEPENDENCIES SceneGraph) -endif() set(_MAGNUM_Text_DEPENDENCIES TextureTools) if(MAGNUM_TARGET_GL) list(APPEND _MAGNUM_Text_DEPENDENCIES GL) @@ -846,7 +835,6 @@ foreach(_component ${Magnum_FIND_COMPONENTS}) # No special setup for SceneGraph library # No special setup for Shaders library - # No special setup for Shapes library # Text library elseif(_component STREQUAL Text) diff --git a/package/archlinux/PKGBUILD b/package/archlinux/PKGBUILD index fef3ba2cce..a5fa2f6730 100644 --- a/package/archlinux/PKGBUILD +++ b/package/archlinux/PKGBUILD @@ -25,7 +25,6 @@ build() { -DCMAKE_BUILD_TYPE=Debug \ -DCMAKE_INSTALL_PREFIX=/usr \ -DWITH_AUDIO=ON \ - -DWITH_SHAPES=ON \ -DWITH_VK=ON \ -DWITH_GLFWAPPLICATION=ON \ -DWITH_GLUTAPPLICATION=ON \ diff --git a/package/archlinux/PKGBUILD-android-arm64 b/package/archlinux/PKGBUILD-android-arm64 index 2ccd495d66..8fa8a21c56 100644 --- a/package/archlinux/PKGBUILD-android-arm64 +++ b/package/archlinux/PKGBUILD-android-arm64 @@ -32,7 +32,6 @@ build() { -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=/opt/android-ndk/platforms/android-22/arch-arm64/usr \ -DMAGNUM_INCLUDE_INSTALL_PREFIX=/opt/android-ndk/sysroot/usr \ - -DWITH_SHAPES=ON \ -DWITH_ANYAUDIOIMPORTER=OFF \ -DWITH_ANYIMAGECONVERTER=ON \ -DWITH_ANYIMAGEIMPORTER=ON \ diff --git a/package/archlinux/PKGBUILD-clang b/package/archlinux/PKGBUILD-clang index 4a33c45377..b57884b6cc 100644 --- a/package/archlinux/PKGBUILD-clang +++ b/package/archlinux/PKGBUILD-clang @@ -29,7 +29,6 @@ build() { -DCMAKE_BUILD_TYPE=Debug \ -DCMAKE_INSTALL_PREFIX=/usr \ -DWITH_AUDIO=ON \ - -DWITH_SHAPES=ON \ -DWITH_VK=ON \ -DWITH_GLUTAPPLICATION=ON \ -DWITH_GLFWAPPLICATION=ON \ diff --git a/package/archlinux/PKGBUILD-clang-addressanitizer b/package/archlinux/PKGBUILD-clang-addressanitizer index 36e176a5b8..372677a0ae 100644 --- a/package/archlinux/PKGBUILD-clang-addressanitizer +++ b/package/archlinux/PKGBUILD-clang-addressanitizer @@ -30,7 +30,6 @@ build() { -DCMAKE_BUILD_TYPE=Debug \ -DCMAKE_INSTALL_PREFIX=/usr \ -DWITH_AUDIO=ON \ - -DWITH_SHAPES=ON \ -DWITH_VK=ON \ -DWITH_GLUTAPPLICATION=ON \ -DWITH_GLFWAPPLICATION=ON \ diff --git a/package/archlinux/PKGBUILD-clang-analyzer b/package/archlinux/PKGBUILD-clang-analyzer index 5925da055c..4ca7fce214 100644 --- a/package/archlinux/PKGBUILD-clang-analyzer +++ b/package/archlinux/PKGBUILD-clang-analyzer @@ -21,7 +21,6 @@ build() { -DCMAKE_BUILD_TYPE=Debug \ -DCMAKE_INSTALL_PREFIX=/usr \ -DWITH_AUDIO=ON \ - -DWITH_SHAPES=ON \ -DWITH_VK=ON \ -DWITH_GLUTAPPLICATION=ON \ -DWITH_GLFWAPPLICATION=ON \ diff --git a/package/archlinux/PKGBUILD-clang-libc++ b/package/archlinux/PKGBUILD-clang-libc++ index 4e87e86f94..c8b3e738de 100644 --- a/package/archlinux/PKGBUILD-clang-libc++ +++ b/package/archlinux/PKGBUILD-clang-libc++ @@ -31,7 +31,6 @@ build() { -DCMAKE_BUILD_TYPE=Debug \ -DCMAKE_INSTALL_PREFIX=/usr \ -DWITH_AUDIO=ON \ - -DWITH_SHAPES=ON \ -DWITH_VK=ON \ -DWITH_GLFWAPPLICATION=ON \ -DWITH_GLUTAPPLICATION=ON \ diff --git a/package/archlinux/PKGBUILD-coverage b/package/archlinux/PKGBUILD-coverage index 73df063388..40ba233fd2 100644 --- a/package/archlinux/PKGBUILD-coverage +++ b/package/archlinux/PKGBUILD-coverage @@ -27,7 +27,6 @@ build() { -DCMAKE_BUILD_TYPE=Debug \ -DCMAKE_INSTALL_PREFIX=/usr \ -DWITH_AUDIO=ON \ - -DWITH_SHAPES=ON \ -DWITH_VK=ON \ -DWITH_GLFWAPPLICATION=ON \ -DWITH_GLUTAPPLICATION=ON \ @@ -75,16 +74,6 @@ check() { # Keep in sync with package/ci/appveyor-lcov.sh and travis.yml, please lcov --gcov-tool="gcov-6" --directory . --capture --output-file coverage.info lcov --gcov-tool="gcov-6" --extract coverage.info "*/src/Magnum*/*" --output-file coverage.info > /dev/null - # Deprecated, we don't care about coverage anymore - lcov --gcov-tool="gcov-6" --remove coverage.info "*/src/Magnum/Shapes/*" --output-file coverage.info > /dev/null - lcov --gcov-tool="gcov-6" --remove coverage.info "*/src/Magnum/DebugTools/ShapeRenderer*" --output-file coverage.info > /dev/null - lcov --gcov-tool="gcov-6" --remove coverage.info "*/src/Magnum/DebugTools/Implementation/*BoxRenderer*" --output-file coverage.info > /dev/null - lcov --gcov-tool="gcov-6" --remove coverage.info "*/src/Magnum/DebugTools/Implementation/AbstractShapeRenderer*" --output-file coverage.info > /dev/null - lcov --gcov-tool="gcov-6" --remove coverage.info "*/src/Magnum/DebugTools/Implementation/CapsuleRenderer*" --output-file coverage.info > /dev/null - lcov --gcov-tool="gcov-6" --remove coverage.info "*/src/Magnum/DebugTools/Implementation/CylinderRenderer*" --output-file coverage.info > /dev/null - lcov --gcov-tool="gcov-6" --remove coverage.info "*/src/Magnum/DebugTools/Implementation/LineSegmentRenderer*" --output-file coverage.info > /dev/null - lcov --gcov-tool="gcov-6" --remove coverage.info "*/src/Magnum/DebugTools/Implementation/PointRenderer*" --output-file coverage.info > /dev/null - lcov --gcov-tool="gcov-6" --remove coverage.info "*/src/Magnum/DebugTools/Implementation/SphereRenderer*" --output-file coverage.info > /dev/null lcov --gcov-tool="gcov-6" --remove coverage.info "*/src/MagnumExternal/*" --output-file coverage.info > /dev/null lcov --gcov-tool="gcov-6" --remove coverage.info "*/Test/*" --output-file coverage.info > /dev/null lcov --gcov-tool="gcov-6" --remove coverage.info "*/build-coverage/src/*" --output-file coverage.info > /dev/null diff --git a/package/archlinux/PKGBUILD-emscripten b/package/archlinux/PKGBUILD-emscripten index 94b80189a3..2a182da7b4 100644 --- a/package/archlinux/PKGBUILD-emscripten +++ b/package/archlinux/PKGBUILD-emscripten @@ -29,7 +29,6 @@ build() { -DCMAKE_INSTALL_PREFIX=/usr/lib/emscripten/system \ -DMAGNUM_DEPLOY_PREFIX=/srv/http/emscripten \ -DWITH_AUDIO=ON \ - -DWITH_SHAPES=ON \ -DWITH_SDL2APPLICATION=ON \ -DWITH_WINDOWLESSEGLAPPLICATION=ON \ -DWITH_ANYAUDIOIMPORTER=ON \ diff --git a/package/archlinux/PKGBUILD-emscripten-wasm b/package/archlinux/PKGBUILD-emscripten-wasm index b8d4d05d6c..e9fb8cb98c 100644 --- a/package/archlinux/PKGBUILD-emscripten-wasm +++ b/package/archlinux/PKGBUILD-emscripten-wasm @@ -29,7 +29,6 @@ build() { -DCMAKE_INSTALL_PREFIX=/usr/lib/emscripten/system \ -DMAGNUM_DEPLOY_PREFIX=/srv/http/emscripten \ -DWITH_AUDIO=ON \ - -DWITH_SHAPES=ON \ -DWITH_SDL2APPLICATION=ON \ -DWITH_WINDOWLESSEGLAPPLICATION=ON \ -DWITH_ANYAUDIOIMPORTER=ON \ diff --git a/package/archlinux/PKGBUILD-emscripten-wasm-webgl2 b/package/archlinux/PKGBUILD-emscripten-wasm-webgl2 index 787763030d..acbafb30a6 100644 --- a/package/archlinux/PKGBUILD-emscripten-wasm-webgl2 +++ b/package/archlinux/PKGBUILD-emscripten-wasm-webgl2 @@ -30,7 +30,6 @@ build() { -DMAGNUM_DEPLOY_PREFIX=/srv/http/emscripten-webgl2 \ -DTARGET_GLES2=OFF \ -DWITH_AUDIO=ON \ - -DWITH_SHAPES=ON \ -DWITH_SDL2APPLICATION=ON \ -DWITH_WINDOWLESSEGLAPPLICATION=ON \ -DWITH_ANYAUDIOIMPORTER=ON \ diff --git a/package/archlinux/PKGBUILD-emscripten-webgl2 b/package/archlinux/PKGBUILD-emscripten-webgl2 index 9bcacb07d6..1f494032c8 100644 --- a/package/archlinux/PKGBUILD-emscripten-webgl2 +++ b/package/archlinux/PKGBUILD-emscripten-webgl2 @@ -30,7 +30,6 @@ build() { -DMAGNUM_DEPLOY_PREFIX=/srv/http/emscripten-webgl2 \ -DTARGET_GLES2=OFF \ -DWITH_AUDIO=ON \ - -DWITH_SHAPES=ON \ -DWITH_SDL2APPLICATION=ON \ -DWITH_WINDOWLESSEGLAPPLICATION=ON \ -DWITH_ANYAUDIOIMPORTER=ON \ diff --git a/package/archlinux/PKGBUILD-es2 b/package/archlinux/PKGBUILD-es2 index f36780727e..0239c30a76 100644 --- a/package/archlinux/PKGBUILD-es2 +++ b/package/archlinux/PKGBUILD-es2 @@ -23,7 +23,6 @@ build() { -DTARGET_GLES=ON \ -DTARGET_GLES2=ON \ -DWITH_AUDIO=ON \ - -DWITH_SHAPES=ON \ -DWITH_SDL2APPLICATION=ON \ -DWITH_XEGLAPPLICATION=ON \ -DWITH_WINDOWLESSEGLAPPLICATION=ON \ diff --git a/package/archlinux/PKGBUILD-es2desktop b/package/archlinux/PKGBUILD-es2desktop index 7b32e61938..ab1abb599b 100644 --- a/package/archlinux/PKGBUILD-es2desktop +++ b/package/archlinux/PKGBUILD-es2desktop @@ -24,7 +24,6 @@ build() { -DTARGET_GLES2=ON \ -DTARGET_DESKTOP_GLES=ON \ -DWITH_AUDIO=ON \ - -DWITH_SHAPES=ON \ -DWITH_GLFWAPPLICATION=ON \ -DWITH_GLXAPPLICATION=ON \ -DWITH_SDL2APPLICATION=ON \ diff --git a/package/archlinux/PKGBUILD-es3 b/package/archlinux/PKGBUILD-es3 index 03cd4bf7be..88f88add08 100644 --- a/package/archlinux/PKGBUILD-es3 +++ b/package/archlinux/PKGBUILD-es3 @@ -23,7 +23,6 @@ build() { -DTARGET_GLES=ON \ -DTARGET_GLES2=OFF \ -DWITH_AUDIO=ON \ - -DWITH_SHAPES=ON \ -DWITH_SDL2APPLICATION=ON \ -DWITH_XEGLAPPLICATION=ON \ -DWITH_WINDOWLESSEGLAPPLICATION=ON \ diff --git a/package/archlinux/PKGBUILD-es3desktop b/package/archlinux/PKGBUILD-es3desktop index 4f2828baca..4b1e9a462e 100644 --- a/package/archlinux/PKGBUILD-es3desktop +++ b/package/archlinux/PKGBUILD-es3desktop @@ -24,7 +24,6 @@ build() { -DTARGET_GLES2=OFF \ -DTARGET_DESKTOP_GLES=ON \ -DWITH_AUDIO=ON \ - -DWITH_SHAPES=ON \ -DWITH_GLFWAPPLICATION=ON \ -DWITH_GLXAPPLICATION=ON \ -DWITH_SDL2APPLICATION=ON \ diff --git a/package/archlinux/PKGBUILD-gcc48 b/package/archlinux/PKGBUILD-gcc48 index 7c9a6943ba..5398f804dd 100644 --- a/package/archlinux/PKGBUILD-gcc48 +++ b/package/archlinux/PKGBUILD-gcc48 @@ -33,7 +33,6 @@ build() { -DCMAKE_BUILD_TYPE=Debug \ -DCMAKE_INSTALL_PREFIX=/usr \ -DWITH_AUDIO=ON \ - -DWITH_SHAPES=ON \ -DWITH_GLFWAPPLICATION=ON \ -DWITH_GLUTAPPLICATION=ON \ -DWITH_GLXAPPLICATION=ON \ diff --git a/package/archlinux/PKGBUILD-mingw-w64 b/package/archlinux/PKGBUILD-mingw-w64 index f2dd952636..7bfbd6d4a8 100644 --- a/package/archlinux/PKGBUILD-mingw-w64 +++ b/package/archlinux/PKGBUILD-mingw-w64 @@ -21,7 +21,6 @@ build() { -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=/usr/i686-w64-mingw32 \ -DWITH_AUDIO=ON \ - -DWITH_SHAPES=ON \ -DWITH_GLUTAPPLICATION=ON \ -DWITH_SDL2APPLICATION=ON \ -DWITH_WINDOWLESSWGLAPPLICATION=ON \ diff --git a/package/archlinux/PKGBUILD-release b/package/archlinux/PKGBUILD-release index 8681cec8d1..177ed41ad4 100644 --- a/package/archlinux/PKGBUILD-release +++ b/package/archlinux/PKGBUILD-release @@ -21,7 +21,6 @@ build() { -DCMAKE_BUILD_TYPE=Debug \ -DCMAKE_INSTALL_PREFIX=/usr \ -DWITH_AUDIO=ON \ - -DWITH_SHAPES=ON \ -DWITH_VK=ON \ -DWITH_GLFWAPPLICATION=ON \ -DWITH_GLUTAPPLICATION=ON \ @@ -59,7 +58,6 @@ build() { -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=/usr \ -DWITH_AUDIO=ON \ - -DWITH_SHAPES=ON \ -DWITH_GLUTAPPLICATION=ON \ -DWITH_GLXAPPLICATION=ON \ -DWITH_SDL2APPLICATION=ON \ diff --git a/package/ci/appveyor-desktop-gles.bat b/package/ci/appveyor-desktop-gles.bat index f51616c595..62046e4862 100644 --- a/package/ci/appveyor-desktop-gles.bat +++ b/package/ci/appveyor-desktop-gles.bat @@ -26,7 +26,6 @@ cmake .. ^ -DTARGET_GLES2=%TARGET_GLES2% ^ -DTARGET_DESKTOP_GLES=ON ^ -DWITH_AUDIO=ON ^ - -DWITH_SHAPES=ON ^ -DWITH_SDL2APPLICATION=OFF ^ -DWITH_WINDOWLESSWGLAPPLICATION=ON ^ -DWITH_WGLCONTEXT=ON ^ diff --git a/package/ci/appveyor-desktop-mingw.bat b/package/ci/appveyor-desktop-mingw.bat index ea3971f3d8..0736ebbe01 100644 --- a/package/ci/appveyor-desktop-mingw.bat +++ b/package/ci/appveyor-desktop-mingw.bat @@ -25,7 +25,6 @@ cmake .. ^ -DCMAKE_INSTALL_PREFIX=%APPVEYOR_BUILD_FOLDER%/deps ^ -DCMAKE_PREFIX_PATH="%APPVEYOR_BUILD_FOLDER%/SDL;%APPVEYOR_BUILD_FOLDER%/openal" ^ -DWITH_AUDIO=ON ^ - -DWITH_SHAPES=ON ^ -DWITH_SDL2APPLICATION=ON ^ -DWITH_WINDOWLESSWGLAPPLICATION=ON ^ -DWITH_WGLCONTEXT=ON ^ diff --git a/package/ci/appveyor-desktop-vulkan.bat b/package/ci/appveyor-desktop-vulkan.bat index 06f8f2b837..1ecef35f3d 100644 --- a/package/ci/appveyor-desktop-vulkan.bat +++ b/package/ci/appveyor-desktop-vulkan.bat @@ -35,7 +35,6 @@ cmake .. ^ -DWITH_PRIMITIVES=OFF ^ -DWITH_SCENEGRAPH=OFF ^ -DWITH_SHADERS=OFF ^ - -DWITH_SHAPES=OFF ^ -DWITH_TEXT=OFF ^ -DWITH_TEXTURETOOLS=OFF ^ -DWITH_TRADE=OFF ^ diff --git a/package/ci/appveyor-desktop.bat b/package/ci/appveyor-desktop.bat index 90a838ddac..4f6324de00 100644 --- a/package/ci/appveyor-desktop.bat +++ b/package/ci/appveyor-desktop.bat @@ -23,7 +23,6 @@ cmake .. ^ -DCMAKE_INSTALL_PREFIX=%APPVEYOR_BUILD_FOLDER%/deps ^ -DCMAKE_PREFIX_PATH="%APPVEYOR_BUILD_FOLDER%/SDL;%APPVEYOR_BUILD_FOLDER%/openal" ^ -DWITH_AUDIO=ON ^ - -DWITH_SHAPES=ON ^ -DWITH_SDL2APPLICATION=ON ^ -DWITH_GLFWAPPLICATION=ON ^ -DWITH_WINDOWLESSWGLAPPLICATION=ON ^ diff --git a/package/ci/appveyor-lcov.sh b/package/ci/appveyor-lcov.sh index 4c8ad5fe07..9b9d7f9766 100644 --- a/package/ci/appveyor-lcov.sh +++ b/package/ci/appveyor-lcov.sh @@ -12,15 +12,5 @@ tar -xzf v1.13.tar.gz lcov-1.13/bin/lcov --gcov-tool /c/mingw-w64/x86_64-7.2.0-posix-seh-rt_v5-rev1/mingw64/bin/gcov --directory . --capture --output-file coverage.info > /dev/null lcov-1.13/bin/lcov --gcov-tool /c/mingw-w64/x86_64-7.2.0-posix-seh-rt_v5-rev1/mingw64/bin/gcov --extract coverage.info "*/src/Magnum*/*" --output-file coverage.info > /dev/null lcov-1.13/bin/lcov --gcov-tool /c/mingw-w64/x86_64-7.2.0-posix-seh-rt_v5-rev1/mingw64/bin/gcov --remove coverage.info "*/src/MagnumExternal/*" --output-file coverage.info > /dev/null -# Deprecated, we don't care about coverage anymore -lcov-1.13/bin/lcov --gcov-tool /c/mingw-w64/x86_64-7.2.0-posix-seh-rt_v5-rev1/mingw64/bin/gcov --remove coverage.info "*/src/Magnum/Shapes/*" --output-file coverage.info > /dev/null -lcov-1.13/bin/lcov --gcov-tool /c/mingw-w64/x86_64-7.2.0-posix-seh-rt_v5-rev1/mingw64/bin/gcov --remove coverage.info "*/src/Magnum/DebugTools/ShapeRenderer*" --output-file coverage.info > /dev/null -lcov-1.13/bin/lcov --gcov-tool /c/mingw-w64/x86_64-7.2.0-posix-seh-rt_v5-rev1/mingw64/bin/gcov --remove coverage.info "*/src/Magnum/DebugTools/Implementation/*BoxRenderer*" --output-file coverage.info > /dev/null -lcov-1.13/bin/lcov --gcov-tool /c/mingw-w64/x86_64-7.2.0-posix-seh-rt_v5-rev1/mingw64/bin/gcov --remove coverage.info "*/src/Magnum/DebugTools/Implementation/AbstractShapeRenderer*" --output-file coverage.info > /dev/null -lcov-1.13/bin/lcov --gcov-tool /c/mingw-w64/x86_64-7.2.0-posix-seh-rt_v5-rev1/mingw64/bin/gcov --remove coverage.info "*/src/Magnum/DebugTools/Implementation/CapsuleRenderer*" --output-file coverage.info > /dev/null -lcov-1.13/bin/lcov --gcov-tool /c/mingw-w64/x86_64-7.2.0-posix-seh-rt_v5-rev1/mingw64/bin/gcov --remove coverage.info "*/src/Magnum/DebugTools/Implementation/CylinderRenderer*" --output-file coverage.info > /dev/null -lcov-1.13/bin/lcov --gcov-tool /c/mingw-w64/x86_64-7.2.0-posix-seh-rt_v5-rev1/mingw64/bin/gcov --remove coverage.info "*/src/Magnum/DebugTools/Implementation/LineSegmentRenderer*" --output-file coverage.info > /dev/null -lcov-1.13/bin/lcov --gcov-tool /c/mingw-w64/x86_64-7.2.0-posix-seh-rt_v5-rev1/mingw64/bin/gcov --remove coverage.info "*/src/Magnum/DebugTools/Implementation/PointRenderer*" --output-file coverage.info > /dev/null -lcov-1.13/bin/lcov --gcov-tool /c/mingw-w64/x86_64-7.2.0-posix-seh-rt_v5-rev1/mingw64/bin/gcov --remove coverage.info "*/src/Magnum/DebugTools/Implementation/SphereRenderer*" --output-file coverage.info > /dev/null lcov-1.13/bin/lcov --gcov-tool /c/mingw-w64/x86_64-7.2.0-posix-seh-rt_v5-rev1/mingw64/bin/gcov --remove coverage.info "*/Test/*" --output-file coverage.info > /dev/null lcov-1.13/bin/lcov --gcov-tool /c/mingw-w64/x86_64-7.2.0-posix-seh-rt_v5-rev1/mingw64/bin/gcov --remove coverage.info "*/build/src/*" --output-file coverage.info > /dev/null diff --git a/package/ci/travis-android-arm.sh b/package/ci/travis-android-arm.sh index b4586e0589..984bdbdc62 100755 --- a/package/ci/travis-android-arm.sh +++ b/package/ci/travis-android-arm.sh @@ -56,7 +56,6 @@ cmake .. \ -DCMAKE_BUILD_TYPE=Release \ -DTARGET_GLES2=$TARGET_GLES2 \ -DWITH_AUDIO=OFF \ - -DWITH_SHAPES=ON \ -DWITH_VK=OFF \ -DWITH_ANDROIDAPPLICATION=ON \ -DWITH_EGLCONTEXT=ON \ diff --git a/package/ci/travis-desktop-gles.sh b/package/ci/travis-desktop-gles.sh index cf35f65a02..b2934cf294 100755 --- a/package/ci/travis-desktop-gles.sh +++ b/package/ci/travis-desktop-gles.sh @@ -27,7 +27,6 @@ cmake .. \ -DTARGET_GLES=ON \ -DTARGET_GLES2=$TARGET_GLES2 \ -DWITH_AUDIO=ON \ - -DWITH_SHAPES=ON \ -DWITH_VK=OFF \ -DWITH_GLFWAPPLICATION=ON \ -DWITH_SDL2APPLICATION=ON \ diff --git a/package/ci/travis-desktop-vulkan.sh b/package/ci/travis-desktop-vulkan.sh index f62a23f372..c9585e5378 100755 --- a/package/ci/travis-desktop-vulkan.sh +++ b/package/ci/travis-desktop-vulkan.sh @@ -37,7 +37,6 @@ cmake .. \ -DWITH_PRIMITIVES=OFF \ -DWITH_SCENEGRAPH=OFF \ -DWITH_SHADERS=OFF \ - -DWITH_SHAPES=OFF \ -DWITH_TEXT=OFF \ -DWITH_TEXTURETOOLS=OFF \ -DWITH_TRADE=OFF \ diff --git a/package/ci/travis-desktop.sh b/package/ci/travis-desktop.sh index c4c6128ae9..b986ccc9d9 100755 --- a/package/ci/travis-desktop.sh +++ b/package/ci/travis-desktop.sh @@ -23,7 +23,6 @@ cmake .. \ -DCMAKE_INSTALL_PREFIX=$HOME/deps \ -DCMAKE_BUILD_TYPE=Debug \ -DWITH_AUDIO=ON \ - -DWITH_SHAPES=$BUILD_DEPRECATED \ -DWITH_VK=OFF \ -DWITH_GLFWAPPLICATION=ON \ -DWITH_GLUTAPPLICATION=$WITH_GLUTAPPLICATION \ diff --git a/package/ci/travis-emscripten.sh b/package/ci/travis-emscripten.sh index 1977f42849..dfb6ca0bb6 100755 --- a/package/ci/travis-emscripten.sh +++ b/package/ci/travis-emscripten.sh @@ -49,7 +49,6 @@ cmake .. \ -DCMAKE_INSTALL_PREFIX=$HOME/deps \ -DCMAKE_FIND_ROOT_PATH=$HOME/deps \ -DWITH_AUDIO=ON \ - -DWITH_SHAPES=ON \ -DWITH_VK=OFF \ -DWITH_SDL2APPLICATION=ON \ -DWITH_WINDOWLESSEGLAPPLICATION=ON \ diff --git a/package/ci/travis-ios-simulator.sh b/package/ci/travis-ios-simulator.sh index ccf8a3934d..196d49cb5b 100755 --- a/package/ci/travis-ios-simulator.sh +++ b/package/ci/travis-ios-simulator.sh @@ -45,7 +45,6 @@ cmake .. \ -DCMAKE_PREFIX_PATH="$HOME/deps;$TRAVIS_BUILD_DIR/sdl2" \ -DTARGET_GLES2=$TARGET_GLES2 \ -DWITH_AUDIO=ON \ - -DWITH_SHAPES=ON \ -DWITH_VK=OFF \ -DWITH_SDL2APPLICATION=ON \ -DWITH_WINDOWLESSIOSAPPLICATION=ON \ diff --git a/package/ci/travis.yml b/package/ci/travis.yml index 4215015855..cbf1b8d1ed 100644 --- a/package/ci/travis.yml +++ b/package/ci/travis.yml @@ -230,16 +230,6 @@ after_success: # Keep in sync with PKBUILD-coverage and appveyor-lcov.sh, please - if [[ "$CMAKE_CXX_FLAGS" == *"--coverage"* ]]; then lcov $LCOV_EXTRA_OPTS --directory . --capture --output-file coverage.info > /dev/null; fi - if [[ "$CMAKE_CXX_FLAGS" == *"--coverage"* ]]; then lcov $LCOV_EXTRA_OPTS --extract coverage.info "*/src/Magnum*/*" --output-file coverage.info > /dev/null; fi -# Deprecated, we don't care about coverage anymore -- if [[ "$CMAKE_CXX_FLAGS" == *"--coverage"* ]]; then lcov $LCOV_EXTRA_OPTS --remove coverage.info "*/Magnum/Shapes/*" --output-file coverage.info > /dev/null; fi -- if [[ "$CMAKE_CXX_FLAGS" == *"--coverage"* ]]; then lcov $LCOV_EXTRA_OPTS --remove coverage.info "*/src/Magnum/DebugTools/ShapeRenderer*" --output-file coverage.info > /dev/null; fi -- if [[ "$CMAKE_CXX_FLAGS" == *"--coverage"* ]]; then lcov $LCOV_EXTRA_OPTS --remove coverage.info "*/src/Magnum/DebugTools/Implementation/*BoxRenderer*" --output-file coverage.info > /dev/null; fi -- if [[ "$CMAKE_CXX_FLAGS" == *"--coverage"* ]]; then lcov $LCOV_EXTRA_OPTS --remove coverage.info "*/src/Magnum/DebugTools/Implementation/AbstractShapeRenderer*" --output-file coverage.info > /dev/null; fi -- if [[ "$CMAKE_CXX_FLAGS" == *"--coverage"* ]]; then lcov $LCOV_EXTRA_OPTS --remove coverage.info "*/src/Magnum/DebugTools/Implementation/CapsuleRenderer*" --output-file coverage.info > /dev/null; fi -- if [[ "$CMAKE_CXX_FLAGS" == *"--coverage"* ]]; then lcov $LCOV_EXTRA_OPTS --remove coverage.info "*/src/Magnum/DebugTools/Implementation/CylinderRenderer*" --output-file coverage.info > /dev/null; fi -- if [[ "$CMAKE_CXX_FLAGS" == *"--coverage"* ]]; then lcov $LCOV_EXTRA_OPTS --remove coverage.info "*/src/Magnum/DebugTools/Implementation/LineSegmentRenderer*" --output-file coverage.info > /dev/null; fi -- if [[ "$CMAKE_CXX_FLAGS" == *"--coverage"* ]]; then lcov $LCOV_EXTRA_OPTS --remove coverage.info "*/src/Magnum/DebugTools/Implementation/PointRenderer*" --output-file coverage.info > /dev/null; fi -- if [[ "$CMAKE_CXX_FLAGS" == *"--coverage"* ]]; then lcov $LCOV_EXTRA_OPTS --remove coverage.info "*/src/Magnum/DebugTools/Implementation/SphereRenderer*" --output-file coverage.info > /dev/null; fi - if [[ "$CMAKE_CXX_FLAGS" == *"--coverage"* ]]; then lcov $LCOV_EXTRA_OPTS --remove coverage.info "*/MagnumExternal/*" --output-file coverage.info > /dev/null; fi - if [[ "$CMAKE_CXX_FLAGS" == *"--coverage"* ]]; then lcov $LCOV_EXTRA_OPTS --remove coverage.info "*/Test/*" --output-file coverage.info > /dev/null; fi - if [[ "$CMAKE_CXX_FLAGS" == *"--coverage"* ]]; then lcov $LCOV_EXTRA_OPTS --remove coverage.info "*/build/src/*" --output-file coverage.info > /dev/null; fi diff --git a/src/Magnum/CMakeLists.txt b/src/Magnum/CMakeLists.txt index 7b1b87cb53..0862e6bee6 100644 --- a/src/Magnum/CMakeLists.txt +++ b/src/Magnum/CMakeLists.txt @@ -161,10 +161,6 @@ if(WITH_SHADERS) add_subdirectory(Shaders) endif() -if(WITH_SHAPES) - add_subdirectory(Shapes) -endif() - if(WITH_TEXT) add_subdirectory(Text) endif() diff --git a/src/Magnum/DebugTools/CMakeLists.txt b/src/Magnum/DebugTools/CMakeLists.txt index fabe26963d..820673114e 100644 --- a/src/Magnum/DebugTools/CMakeLists.txt +++ b/src/Magnum/DebugTools/CMakeLists.txt @@ -73,42 +73,6 @@ if(TARGET_GL) list(APPEND MagnumDebugTools_PRIVATE_HEADERS Implementation/ForceRendererTransformation.h) endif() - - if(WITH_SHAPES) - if(NOT MAGNUM_BUILD_DEPRECATED) - message(FATAL_ERROR "Shapes are scheduled for removal and not available if BUILD_DEPRECATED is disabled. See the docs for alternatives.") - endif() - - list(APPEND MagnumDebugTools_SRCS - ShapeRenderer.cpp - - Implementation/AbstractBoxRenderer.cpp - Implementation/AbstractShapeRenderer.cpp - Implementation/AxisAlignedBoxRenderer.cpp - Implementation/BoxRenderer.cpp - Implementation/CapsuleRenderer.cpp - Implementation/CylinderRenderer.cpp - Implementation/LineSegmentRenderer.cpp - Implementation/PointRenderer.cpp - Implementation/SphereRenderer.cpp) - - list(APPEND MagnumDebugTools_HEADERS - ShapeRenderer.h) - - list(APPEND MagnumDebugTools_PRIVATE_HEADERS - Implementation/AbstractBoxRenderer.h - Implementation/AbstractShapeRenderer.h - Implementation/AxisAlignedBoxRenderer.h - Implementation/BoxRenderer.h - Implementation/CapsuleRenderer.h - Implementation/CapsuleRendererTransformation.h - Implementation/CylinderRenderer.h - Implementation/CylinderRendererTransformation.h - Implementation/LineSegmentRenderer.h - Implementation/LineSegmentRendererTransformation.h - Implementation/PointRenderer.h - Implementation/SphereRenderer.h) - endif() endif() # Build the TestSuite-related functionality only if it is present @@ -159,15 +123,10 @@ endif() if(TARGET_GL) target_link_libraries(MagnumDebugTools PUBLIC MagnumGL) if(WITH_SCENEGRAPH) - target_link_libraries(MagnumDebugTools PUBLIC MagnumSceneGraph) - endif() - if(WITH_SHAPES) - target_link_libraries(MagnumDebugTools PUBLIC MagnumShapes) - endif() - if(WITH_SCENEGRAPH OR WITH_SHAPES) target_link_libraries(MagnumDebugTools PUBLIC MagnumMeshTools MagnumPrimitives + MagnumSceneGraph MagnumShaders) endif() endif() @@ -200,15 +159,10 @@ if(BUILD_TESTS) if(TARGET_GL) target_link_libraries(MagnumDebugToolsTestLib PUBLIC MagnumGL) if(WITH_SCENEGRAPH) - target_link_libraries(MagnumDebugToolsTestLib PUBLIC MagnumSceneGraph) - endif() - if(WITH_SHAPES) - target_link_libraries(MagnumDebugToolsTestLib PUBLIC MagnumShapes) - endif() - if(WITH_SCENEGRAPH OR WITH_SHAPES) target_link_libraries(MagnumDebugToolsTestLib PUBLIC MagnumMeshTools MagnumPrimitives + MagnumSceneGraph MagnumShaders) endif() endif() diff --git a/src/Magnum/DebugTools/DebugTools.h b/src/Magnum/DebugTools/DebugTools.h index f446de0881..758731137c 100644 --- a/src/Magnum/DebugTools/DebugTools.h +++ b/src/Magnum/DebugTools/DebugTools.h @@ -48,15 +48,6 @@ typedef ObjectRenderer<3> ObjectRenderer3D; class ObjectRendererOptions; class ResourceManager; - -#ifdef MAGNUM_BUILD_DEPRECATED -CORRADE_IGNORE_DEPRECATED_PUSH -template class CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") ShapeRenderer; -typedef CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") ShapeRenderer<2> ShapeRenderer2D; -typedef CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") ShapeRenderer<3> ShapeRenderer3D; -class CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") ShapeRendererOptions; -CORRADE_IGNORE_DEPRECATED_POP -#endif #endif #endif diff --git a/src/Magnum/DebugTools/Implementation/AbstractBoxRenderer.cpp b/src/Magnum/DebugTools/Implementation/AbstractBoxRenderer.cpp deleted file mode 100644 index 072d1c8908..0000000000 --- a/src/Magnum/DebugTools/Implementation/AbstractBoxRenderer.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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. -*/ - -#define _MAGNUM_DO_NOT_WARN_DEPRECATED_SHAPES - -#include "AbstractBoxRenderer.h" - -#include "Magnum/GL/Mesh.h" -#include "Magnum/Primitives/Cube.h" -#include "Magnum/Primitives/Square.h" -#include "Magnum/Trade/MeshData2D.h" -#include "Magnum/Trade/MeshData3D.h" - -namespace Magnum { namespace DebugTools { namespace Implementation { - -CORRADE_IGNORE_DEPRECATED_PUSH -AbstractBoxRenderer<2>::AbstractBoxRenderer(): AbstractShapeRenderer<2>("box2d", "box2d-vertices", {}) { - if(!wireframeMesh) AbstractShapeRenderer<2>::createResources(Primitives::squareWireframe()); -} - -AbstractBoxRenderer<3>::AbstractBoxRenderer(): AbstractShapeRenderer<3>("box3d", "box3d-vertices", "box3d-indices") { - if(!wireframeMesh) AbstractShapeRenderer<3>::createResources(Primitives::cubeWireframe()); -} -CORRADE_IGNORE_DEPRECATED_POP - -}}} diff --git a/src/Magnum/DebugTools/Implementation/AbstractBoxRenderer.h b/src/Magnum/DebugTools/Implementation/AbstractBoxRenderer.h deleted file mode 100644 index 6ceaf2a7b4..0000000000 --- a/src/Magnum/DebugTools/Implementation/AbstractBoxRenderer.h +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef Magnum_DebugTools_Implementation_AbstractBoxRenderer_h -#define Magnum_DebugTools_Implementation_AbstractBoxRenderer_h -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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 "AbstractShapeRenderer.h" - -#include "Magnum/Resource.h" -#include "Magnum/Shaders/Shaders.h" - -namespace Magnum { namespace DebugTools { namespace Implementation { - -CORRADE_IGNORE_DEPRECATED_PUSH -template class AbstractBoxRenderer; - -template<> class AbstractBoxRenderer<2>: public AbstractShapeRenderer<2> { - public: - AbstractBoxRenderer(); -}; - -template<> class AbstractBoxRenderer<3>: public AbstractShapeRenderer<3> { - public: - AbstractBoxRenderer(); -}; -CORRADE_IGNORE_DEPRECATED_POP - -}}} - -#endif diff --git a/src/Magnum/DebugTools/Implementation/AbstractShapeRenderer.cpp b/src/Magnum/DebugTools/Implementation/AbstractShapeRenderer.cpp deleted file mode 100644 index edbeb7a6a2..0000000000 --- a/src/Magnum/DebugTools/Implementation/AbstractShapeRenderer.cpp +++ /dev/null @@ -1,138 +0,0 @@ -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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. -*/ - -#define _MAGNUM_DO_NOT_WARN_DEPRECATED_SHAPES - -#include "AbstractShapeRenderer.h" - -#include - -#include "Magnum/DebugTools/ResourceManager.h" -#include "Magnum/GL/AbstractShaderProgram.h" -#include "Magnum/GL/Buffer.h" -#include "Magnum/GL/Mesh.h" -#include "Magnum/MeshTools/CompressIndices.h" -#include "Magnum/Shaders/Flat.h" -#include "Magnum/Trade/MeshData2D.h" -#include "Magnum/Trade/MeshData3D.h" - -namespace Magnum { namespace DebugTools { namespace Implementation { - -CORRADE_IGNORE_DEPRECATED_PUSH -namespace { - -template ResourceKey shaderKey(); -template<> inline ResourceKey shaderKey<2>() { return ResourceKey("FlatShader2D"); } -template<> inline ResourceKey shaderKey<3>() { return ResourceKey("FlatShader3D"); } - -template void create(typename MeshData::Type&, Resource&, Resource&, Resource&); - -template<> void create<2>(Trade::MeshData2D& data, Resource& meshResource, Resource& vertexBufferResource, Resource& indexBufferResource) { - /* Vertex buffer */ - GL::Buffer* buffer = new GL::Buffer{GL::Buffer::TargetHint::Array}; - buffer->setData(data.positions(0), GL::BufferUsage::StaticDraw); - ResourceManager::instance().set(vertexBufferResource.key(), buffer, ResourceDataState::Final, ResourcePolicy::Manual); - - /* Mesh configuration */ - GL::Mesh* mesh = new GL::Mesh; - mesh->setPrimitive(data.primitive()) - .addVertexBuffer(*buffer, 0, Shaders::Flat2D::Position()); - ResourceManager::instance().set(meshResource.key(), mesh, ResourceDataState::Final, ResourcePolicy::Manual); - - /* Index buffer, if needed, if not, resource key doesn't have to be set */ - if(data.isIndexed()) { - CORRADE_INTERNAL_ASSERT(indexBufferResource.key() != ResourceKey()); - - Containers::Array indexData; - MeshIndexType indexType; - UnsignedInt indexStart, indexEnd; - std::tie(indexData, indexType, indexStart, indexEnd) = MeshTools::compressIndices(data.indices()); - - GL::Buffer* indexBuffer = new GL::Buffer{GL::Buffer::TargetHint::ElementArray}; - indexBuffer->setData(indexData, GL::BufferUsage::StaticDraw); - mesh->setCount(data.indices().size()) - .setIndexBuffer(*indexBuffer, 0, indexType, indexStart, indexEnd); - - ResourceManager::instance().set(indexBufferResource.key(), indexBuffer, ResourceDataState::Final, ResourcePolicy::Manual); - - /* The mesh is not indexed, set proper vertex count */ - } else mesh->setCount(data.positions(0).size()); -} - -template<> void create<3>(Trade::MeshData3D& data, Resource& meshResource, Resource& vertexBufferResource, Resource& indexBufferResource) { - /* Vertex buffer */ - GL::Buffer* vertexBuffer = new GL::Buffer{GL::Buffer::TargetHint::Array}; - vertexBuffer->setData(data.positions(0), GL::BufferUsage::StaticDraw); - ResourceManager::instance().set(vertexBufferResource.key(), vertexBuffer, ResourceDataState::Final, ResourcePolicy::Manual); - - /* Mesh configuration */ - GL::Mesh* mesh = new GL::Mesh; - mesh->setPrimitive(data.primitive()) - .addVertexBuffer(*vertexBuffer, 0, Shaders::Flat3D::Position()); - ResourceManager::instance().set(meshResource.key(), mesh, ResourceDataState::Final, ResourcePolicy::Manual); - - /* Index buffer, if needed, if not, resource key doesn't have to be set */ - if(data.isIndexed()) { - CORRADE_INTERNAL_ASSERT(indexBufferResource.key() != ResourceKey()); - - Containers::Array indexData; - MeshIndexType indexType; - UnsignedInt indexStart, indexEnd; - std::tie(indexData, indexType, indexStart, indexEnd) = MeshTools::compressIndices(data.indices()); - - GL::Buffer* indexBuffer = new GL::Buffer{GL::Buffer::TargetHint::ElementArray}; - indexBuffer->setData(indexData, GL::BufferUsage::StaticDraw); - mesh->setCount(data.indices().size()) - .setIndexBuffer(*indexBuffer, 0, indexType, indexStart, indexEnd); - - ResourceManager::instance().set(indexBufferResource.key(), indexBuffer, ResourceDataState::Final, ResourcePolicy::Manual); - - /* The mesh is not indexed, set proper vertex count */ - } else mesh->setCount(data.positions(0).size()); -} - -} - -template AbstractShapeRenderer::AbstractShapeRenderer(ResourceKey meshKey, ResourceKey vertexBufferKey, ResourceKey indexBufferKey) { - wireframeShader = ResourceManager::instance().get>(shaderKey()); - wireframeMesh = ResourceManager::instance().get(meshKey); - vertexBuffer = ResourceManager::instance().get(vertexBufferKey); - indexBuffer = ResourceManager::instance().get(indexBufferKey); - - if(!wireframeShader) ResourceManager::instance().set(shaderKey(), - new Shaders::Flat, ResourceDataState::Final, ResourcePolicy::Resident); -} - -template AbstractShapeRenderer::~AbstractShapeRenderer() = default; - -template void AbstractShapeRenderer::createResources(typename MeshData::Type data) { - create(data, wireframeMesh, vertexBuffer, indexBuffer); -} - -template class AbstractShapeRenderer<2>; -template class AbstractShapeRenderer<3>; -CORRADE_IGNORE_DEPRECATED_POP - -}}} diff --git a/src/Magnum/DebugTools/Implementation/AbstractShapeRenderer.h b/src/Magnum/DebugTools/Implementation/AbstractShapeRenderer.h deleted file mode 100644 index d6099daf80..0000000000 --- a/src/Magnum/DebugTools/Implementation/AbstractShapeRenderer.h +++ /dev/null @@ -1,73 +0,0 @@ -#ifndef Magnum_DebugTools_Implementation_AbstractShapeRenderer_h -#define Magnum_DebugTools_Implementation_AbstractShapeRenderer_h -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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 "Magnum/DimensionTraits.h" -#include "Magnum/Resource.h" -#include "Magnum/DebugTools/DebugTools.h" -#include "Magnum/GL/GL.h" -#include "Magnum/SceneGraph/SceneGraph.h" -#include "Magnum/Shaders/Shaders.h" -#include "Magnum/Trade/Trade.h" - -namespace Magnum { - -CORRADE_IGNORE_DEPRECATED_PUSH -namespace Shapes { namespace Implementation { - template struct AbstractShape; -}} - -namespace DebugTools { namespace Implementation { - -template struct MeshData; - -template<> struct MeshData<2> { typedef Trade::MeshData2D Type; }; -template<> struct MeshData<3> { typedef Trade::MeshData3D Type; }; - -template class AbstractShapeRenderer { - public: - AbstractShapeRenderer(ResourceKey mesh, ResourceKey vertexBuffer, ResourceKey indexBuffer); - virtual ~AbstractShapeRenderer(); - - virtual void draw(Resource& options, const MatrixTypeFor& projectionMatrix) = 0; - - protected: - /* Call only if the mesh resource isn't already present */ - void createResources(typename MeshData::Type data); - - Resource> wireframeShader; - Resource wireframeMesh; - - private: - Resource indexBuffer, vertexBuffer; -}; - -}} -CORRADE_IGNORE_DEPRECATED_POP - -} - -#endif diff --git a/src/Magnum/DebugTools/Implementation/AxisAlignedBoxRenderer.cpp b/src/Magnum/DebugTools/Implementation/AxisAlignedBoxRenderer.cpp deleted file mode 100644 index f86dca649d..0000000000 --- a/src/Magnum/DebugTools/Implementation/AxisAlignedBoxRenderer.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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. -*/ - -#define _MAGNUM_DO_NOT_WARN_DEPRECATED_SHAPES - -#include "AxisAlignedBoxRenderer.h" - -#include "Magnum/GL/Mesh.h" -#include "Magnum/DebugTools/ShapeRenderer.h" -#include "Magnum/Shapes/AxisAlignedBox.h" -#include "Magnum/Shaders/Flat.h" - -namespace Magnum { namespace DebugTools { namespace Implementation { - -CORRADE_IGNORE_DEPRECATED_PUSH -template AxisAlignedBoxRenderer::AxisAlignedBoxRenderer(const Shapes::Implementation::AbstractShape& axisAlignedBox): axisAlignedBox(static_cast>&>(axisAlignedBox).shape) {} - -template void AxisAlignedBoxRenderer::draw(Resource& options, const MatrixTypeFor& projectionMatrix) { - AbstractBoxRenderer::wireframeShader->setTransformationProjectionMatrix(projectionMatrix* - MatrixTypeFor::translation((axisAlignedBox.min()+axisAlignedBox.max())/2)* - MatrixTypeFor::scaling(axisAlignedBox.max()-axisAlignedBox.min())) - .setColor(options->color()); - AbstractBoxRenderer::wireframeMesh->draw(*AbstractBoxRenderer::wireframeShader); -} - -template class AxisAlignedBoxRenderer<2>; -template class AxisAlignedBoxRenderer<3>; -CORRADE_IGNORE_DEPRECATED_POP - -}}} diff --git a/src/Magnum/DebugTools/Implementation/AxisAlignedBoxRenderer.h b/src/Magnum/DebugTools/Implementation/AxisAlignedBoxRenderer.h deleted file mode 100644 index 51816d6d58..0000000000 --- a/src/Magnum/DebugTools/Implementation/AxisAlignedBoxRenderer.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef Magnum_DebugTools_Implementation_AxisAlignedBoxRenderer_h -#define Magnum_DebugTools_Implementation_AxisAlignedBoxRenderer_h -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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 "Magnum/Shapes/Shapes.h" - -#include "Magnum/DebugTools/Implementation/AbstractBoxRenderer.h" - -namespace Magnum { namespace DebugTools { namespace Implementation { - -CORRADE_IGNORE_DEPRECATED_PUSH -template class AxisAlignedBoxRenderer: public AbstractBoxRenderer { - public: - explicit AxisAlignedBoxRenderer(const Shapes::Implementation::AbstractShape& axisAlignedBox); - AxisAlignedBoxRenderer(Shapes::Implementation::AbstractShape&&) = delete; - - void draw(Resource& options, const MatrixTypeFor& projectionMatrix) override; - - private: - const Shapes::AxisAlignedBox& axisAlignedBox; -}; -CORRADE_IGNORE_DEPRECATED_POP - -}}} - -#endif diff --git a/src/Magnum/DebugTools/Implementation/BoxRenderer.cpp b/src/Magnum/DebugTools/Implementation/BoxRenderer.cpp deleted file mode 100644 index 7f6c648aea..0000000000 --- a/src/Magnum/DebugTools/Implementation/BoxRenderer.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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. -*/ - -#define _MAGNUM_DO_NOT_WARN_DEPRECATED_SHAPES - -#include "BoxRenderer.h" - -#include "Magnum/GL/Mesh.h" -#include "Magnum/DebugTools/ShapeRenderer.h" -#include "Magnum/Shapes/Box.h" -#include "Magnum/Shaders/Flat.h" - -namespace Magnum { namespace DebugTools { namespace Implementation { - -CORRADE_IGNORE_DEPRECATED_PUSH -template BoxRenderer::BoxRenderer(const Shapes::Implementation::AbstractShape& box): box(static_cast>&>(box).shape) {} - -template void BoxRenderer::draw(Resource& options, const MatrixTypeFor& projectionMatrix) { - AbstractBoxRenderer::wireframeShader->setTransformationProjectionMatrix(projectionMatrix*box.transformation()) - .setColor(options->color()); - AbstractBoxRenderer::wireframeMesh->draw(*AbstractBoxRenderer::wireframeShader); -} - -template class BoxRenderer<2>; -template class BoxRenderer<3>; -CORRADE_IGNORE_DEPRECATED_POP - -}}} diff --git a/src/Magnum/DebugTools/Implementation/BoxRenderer.h b/src/Magnum/DebugTools/Implementation/BoxRenderer.h deleted file mode 100644 index e15b600245..0000000000 --- a/src/Magnum/DebugTools/Implementation/BoxRenderer.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef Magnum_DebugTools_Implementation_BoxRenderer_h -#define Magnum_DebugTools_Implementation_BoxRenderer_h -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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 "Magnum/Shapes/Shapes.h" - -#include "Magnum/DebugTools/Implementation/AbstractBoxRenderer.h" - -namespace Magnum { namespace DebugTools { namespace Implementation { - -CORRADE_IGNORE_DEPRECATED_PUSH -template class BoxRenderer: public AbstractBoxRenderer { - public: - explicit BoxRenderer(const Shapes::Implementation::AbstractShape& box); - BoxRenderer(const Shapes::Implementation::AbstractShape&&) = delete; - - void draw(Resource& options, const MatrixTypeFor& projectionMatrix) override; - - private: - const Shapes::Box& box; -}; -CORRADE_IGNORE_DEPRECATED_POP - -}}} - -#endif diff --git a/src/Magnum/DebugTools/Implementation/CapsuleRenderer.cpp b/src/Magnum/DebugTools/Implementation/CapsuleRenderer.cpp deleted file mode 100644 index 611164745c..0000000000 --- a/src/Magnum/DebugTools/Implementation/CapsuleRenderer.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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. -*/ - -#define _MAGNUM_DO_NOT_WARN_DEPRECATED_SHAPES - -#include "CapsuleRenderer.h" - -#include "Magnum/DebugTools/ResourceManager.h" -#include "Magnum/DebugTools/ShapeRenderer.h" -#include "Magnum/GL/Mesh.h" -#include "Magnum/GL/MeshView.h" -#include "Magnum/Primitives/Capsule.h" -#include "Magnum/Shapes/Capsule.h" -#include "Magnum/Shaders/Flat.h" -#include "Magnum/Trade/MeshData2D.h" -#include "Magnum/Trade/MeshData3D.h" - -#include "Magnum/DebugTools/Implementation/CapsuleRendererTransformation.h" - -namespace Magnum { namespace DebugTools { namespace Implementation { - -CORRADE_IGNORE_DEPRECATED_PUSH -AbstractCapsuleRenderer<2>::AbstractCapsuleRenderer(): AbstractShapeRenderer<2>("capsule2d", "capsule2d-vertices", "capsule2d-indices") { - constexpr UnsignedInt rings = 10; - if(!wireframeMesh) createResources(Primitives::capsule2DWireframe(rings, 1, 1.0f)); - - /* Bottom hemisphere */ - if(!(bottom = ResourceManager::instance().get("capsule2d-bottom"))) { - auto view = new GL::MeshView(*wireframeMesh); - view->setCount(rings*4) - .setIndexRange(0, 0, rings*2+1); - ResourceManager::instance().set(bottom.key(), view, ResourceDataState::Final, ResourcePolicy::Manual); - } - - /* Cylinder */ - if(!(cylinder = ResourceManager::instance().get("capsule2d-cylinder"))) { - auto view = new GL::MeshView(*wireframeMesh); - view->setCount(4) - .setIndexRange(rings*4, rings*2+1, rings*2+3); - ResourceManager::instance().set(cylinder.key(), view, ResourceDataState::Final, ResourcePolicy::Manual); - } - - /* Top hemisphere */ - if(!(top = ResourceManager::instance().get("capsule2d-top"))) { - auto view = new GL::MeshView(*wireframeMesh); - view->setCount(rings*4) - .setIndexRange(rings*4+4, rings*2+3, rings*4+4); - ResourceManager::instance().set(top.key(), view, ResourceDataState::Final, ResourcePolicy::Manual); - } -} - -AbstractCapsuleRenderer<3>::AbstractCapsuleRenderer(): AbstractShapeRenderer<3>("capsule3d", "capsule3d-vertices", "capsule3d-indices") { - constexpr UnsignedInt rings = 10; - constexpr UnsignedInt segments = 40; - if(!wireframeMesh) createResources(Primitives::capsule3DWireframe(rings, 1, segments, 1.0f)); - - /* Bottom hemisphere */ - if(!(bottom = ResourceManager::instance().get("capsule3d-bottom"))) { - auto view = new GL::MeshView(*wireframeMesh); - view->setCount(rings*8) - .setIndexRange(0, 0, rings*4+1); - ResourceManager::instance().set(bottom.key(), view, ResourceDataState::Final, ResourcePolicy::Manual); - } - - /* Cylinder */ - if(!(cylinder = ResourceManager::instance().get("capsule3d-cylinder"))) { - auto view = new GL::MeshView(*wireframeMesh); - view->setCount(segments*4+8) - .setIndexRange(rings*8, rings*4+1, rings*4+segments*2+5); - ResourceManager::instance().set(cylinder.key(), view, ResourceDataState::Final, ResourcePolicy::Manual); - } - - /* Top */ - if(!(top = ResourceManager::instance().get("capsule3d-top"))) { - auto view = new GL::MeshView(*wireframeMesh); - view->setCount(rings*8) - .setIndexRange(rings*8+segments*4+8, rings*4+segments*2+5, rings*8+segments*2+6); - ResourceManager::instance().set(top.key(), view, ResourceDataState::Final, ResourcePolicy::Manual); - } -} - -AbstractCapsuleRenderer<2>::~AbstractCapsuleRenderer() = default; - -AbstractCapsuleRenderer<3>::~AbstractCapsuleRenderer() = default; - -template CapsuleRenderer::CapsuleRenderer(const Shapes::Implementation::AbstractShape& capsule): capsule(static_cast>&>(capsule).shape) {} - -template void CapsuleRenderer::draw(Resource& options, const MatrixTypeFor& projectionMatrix) { - std::array, 3> transformations = Implementation::capsuleRendererTransformation(capsule.a(), capsule.b(), capsule.radius()); - AbstractShapeRenderer::wireframeShader->setColor(options->color()); - - /* Bottom */ - AbstractShapeRenderer::wireframeShader->setTransformationProjectionMatrix(projectionMatrix*transformations[0]); - AbstractCapsuleRenderer::bottom->draw(*AbstractShapeRenderer::wireframeShader); - - /* Cylinder */ - AbstractShapeRenderer::wireframeShader->setTransformationProjectionMatrix(projectionMatrix*transformations[1]); - AbstractCapsuleRenderer::cylinder->draw(*AbstractShapeRenderer::wireframeShader); - - /* Top */ - AbstractShapeRenderer::wireframeShader->setTransformationProjectionMatrix(projectionMatrix*transformations[2]); - AbstractCapsuleRenderer::top->draw(*AbstractShapeRenderer::wireframeShader); -} - -template class CapsuleRenderer<2>; -template class CapsuleRenderer<3>; -CORRADE_IGNORE_DEPRECATED_POP - -}}} diff --git a/src/Magnum/DebugTools/Implementation/CapsuleRenderer.h b/src/Magnum/DebugTools/Implementation/CapsuleRenderer.h deleted file mode 100644 index 51d3fed323..0000000000 --- a/src/Magnum/DebugTools/Implementation/CapsuleRenderer.h +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef Magnum_DebugTools_Implementation_CapsuleRenderer_h -#define Magnum_DebugTools_Implementation_CapsuleRenderer_h -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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 "Magnum/Shapes/Shapes.h" - -#include "Magnum/DebugTools/Implementation/AbstractShapeRenderer.h" - -namespace Magnum { namespace DebugTools { namespace Implementation { - -CORRADE_IGNORE_DEPRECATED_PUSH -template class AbstractCapsuleRenderer; - -template<> class AbstractCapsuleRenderer<2>: public AbstractShapeRenderer<2> { - public: - explicit AbstractCapsuleRenderer(); - ~AbstractCapsuleRenderer(); - - protected: - Resource bottom, cylinder, top; -}; - -template<> class AbstractCapsuleRenderer<3>: public AbstractShapeRenderer<3> { - public: - explicit AbstractCapsuleRenderer(); - ~AbstractCapsuleRenderer(); - - protected: - Resource bottom, cylinder, top; -}; - -template class CapsuleRenderer: public AbstractCapsuleRenderer { - public: - explicit CapsuleRenderer(const Shapes::Implementation::AbstractShape& capsule); - CapsuleRenderer(const Shapes::Implementation::AbstractShape&&) = delete; - - void draw(Resource& options, const MatrixTypeFor& projectionMatrix) override; - - private: - const Shapes::Capsule& capsule; -}; -CORRADE_IGNORE_DEPRECATED_POP - -}}} - -#endif diff --git a/src/Magnum/DebugTools/Implementation/CapsuleRendererTransformation.h b/src/Magnum/DebugTools/Implementation/CapsuleRendererTransformation.h deleted file mode 100644 index 779bc72b51..0000000000 --- a/src/Magnum/DebugTools/Implementation/CapsuleRendererTransformation.h +++ /dev/null @@ -1,109 +0,0 @@ -#ifndef Magnum_DebugTools_Implementation_ForceRendererTransformation_h -#define Magnum_DebugTools_Implementation_ForceRendererTransformation_h -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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/DimensionTraits.h" -#include "Magnum/Magnum.h" -#include "Magnum/Math/Functions.h" -#include "Magnum/Math/Matrix3.h" -#include "Magnum/Math/Matrix4.h" - -namespace Magnum { namespace DebugTools { namespace Implementation { - -CORRADE_IGNORE_DEPRECATED_PUSH -template std::array, 3> capsuleRendererTransformation(const VectorTypeFor& a, const VectorTypeFor& b, Float radius); - -template<> std::array capsuleRendererTransformation<2>(const Vector2& a, const Vector2& b, const Float radius) { - /* Vector from capsule center to top hemisphere center */ - const Vector2 direction = 0.5f*(b - a); - const Float length = direction.length(); - - /* Capsule rotation and distance to caps after they are scaled to proper - radius (if nonzero cylinder length) */ - Matrix3 rotation; - Vector2 capDistance; - if(length >= Math::TypeTraits::epsilon()) { - rotation.up() = direction/length; - rotation.right() = rotation.up().perpendicular(); - CORRADE_INTERNAL_ASSERT(rotation.right().isNormalized()); - - capDistance = direction*(radius/length); - } - - /* Scaling and translation of all parts */ - const auto rotationScaling = rotation*Matrix3::scaling(Vector2(radius)); - return {{ - Matrix3::translation(a+capDistance)*rotationScaling, - Matrix3::translation(0.5f*(a + b))*rotation*Matrix3::scaling({radius, length}), - Matrix3::translation(b-capDistance)*rotationScaling - }}; -} - -template<> std::array capsuleRendererTransformation<3>(const Vector3& a, const Vector3& b, const Float radius) { - /* Vector from capsule center to top hemisphere center */ - const Vector3 direction = 0.5f*(b - a); - const Float length = direction.length(); - - /* Capsule rotation and distance to caps after they are scaled to proper - radius (if nonzero cylinder length) */ - Matrix4 rotation; - Vector3 capDistance; - if(length >= Math::TypeTraits::epsilon()) { - const Vector3 directionNormalized = direction/length; - const Float dot = Math::dot(directionNormalized, Vector3::zAxis()); - - /* Direction is parallel to Z axis, special rotation case */ - if(Math::abs(dot) > 1.0f - Math::TypeTraits::epsilon()) { - rotation.up() = dot*Vector3::zAxis(); - rotation.right() = Vector3::xAxis(); - rotation.backward() = -dot*Vector3::yAxis(); - - /* Common case */ - } else { - rotation.up() = directionNormalized; - rotation.right() = Math::cross(rotation.up(), Vector3::zAxis()).normalized(); - rotation.backward() = Math::cross(rotation.right(), rotation.up()); - CORRADE_INTERNAL_ASSERT(rotation.up().isNormalized() && rotation.backward().isNormalized()); - } - - capDistance = directionNormalized*radius; - } - - /* Scaling and translation of all parts */ - const auto rotationScaling = rotation*Matrix4::scaling(Vector3(radius)); - return {{ - Matrix4::translation(a+capDistance)*rotationScaling, - Matrix4::translation(0.5f*(a + b))*rotation*Matrix4::scaling({radius, length, radius}), - Matrix4::translation(b-capDistance)*rotationScaling - }}; -} -CORRADE_IGNORE_DEPRECATED_POP - -}}} - -#endif diff --git a/src/Magnum/DebugTools/Implementation/CylinderRenderer.cpp b/src/Magnum/DebugTools/Implementation/CylinderRenderer.cpp deleted file mode 100644 index 3cd3639fd2..0000000000 --- a/src/Magnum/DebugTools/Implementation/CylinderRenderer.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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. -*/ - -#define _MAGNUM_DO_NOT_WARN_DEPRECATED_SHAPES - -#include "CylinderRenderer.h" - -#include "Magnum/DebugTools/ShapeRenderer.h" -#include "Magnum/GL/Mesh.h" -#include "Magnum/Shapes/Cylinder.h" -#include "Magnum/Primitives/Cylinder.h" -#include "Magnum/Primitives/Square.h" -#include "Magnum/Shaders/Flat.h" -#include "Magnum/Trade/MeshData2D.h" -#include "Magnum/Trade/MeshData3D.h" - -#include "CylinderRendererTransformation.h" - -namespace Magnum { namespace DebugTools { namespace Implementation { - -CORRADE_IGNORE_DEPRECATED_PUSH -AbstractCylinderRenderer<2>::AbstractCylinderRenderer(): AbstractShapeRenderer<2>("cylinder2d", "cylinder2d-vertices", {}) { - if(!wireframeMesh) createResources(Primitives::squareWireframe()); -} - -AbstractCylinderRenderer<3>::AbstractCylinderRenderer(): AbstractShapeRenderer<3>("cylinder3d", "cylinder3d-vertices", "cylinder3d-indices") { - if(!wireframeMesh) createResources(Primitives::cylinderWireframe(1, 40, 1.0f)); -} - -template CylinderRenderer::CylinderRenderer(const Shapes::Implementation::AbstractShape& cylinder): cylinder(static_cast>&>(cylinder).shape) {} - -template void CylinderRenderer::draw(Resource& options, const MatrixTypeFor& projectionMatrix) { - AbstractShapeRenderer::wireframeShader->setTransformationProjectionMatrix(projectionMatrix* - Implementation::cylinderRendererTransformation(cylinder.a(), cylinder.b(), cylinder.radius())) - .setColor(options->color()); - AbstractShapeRenderer::wireframeMesh->draw(*AbstractShapeRenderer::wireframeShader); -} - -template class CylinderRenderer<2>; -template class CylinderRenderer<3>; -CORRADE_IGNORE_DEPRECATED_POP - -}}} diff --git a/src/Magnum/DebugTools/Implementation/CylinderRenderer.h b/src/Magnum/DebugTools/Implementation/CylinderRenderer.h deleted file mode 100644 index 09c15070bd..0000000000 --- a/src/Magnum/DebugTools/Implementation/CylinderRenderer.h +++ /dev/null @@ -1,61 +0,0 @@ -#ifndef Magnum_DebugTools_Implementation_CylinderRenderer_h -#define Magnum_DebugTools_Implementation_CylinderRenderer_h -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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 "Magnum/Shapes/Shapes.h" - -#include "AbstractShapeRenderer.h" - -namespace Magnum { namespace DebugTools { namespace Implementation { - -CORRADE_IGNORE_DEPRECATED_PUSH -template class AbstractCylinderRenderer; - -template<> class AbstractCylinderRenderer<2>: public AbstractShapeRenderer<2> { - public: - explicit AbstractCylinderRenderer(); -}; - -template<> class AbstractCylinderRenderer<3>: public AbstractShapeRenderer<3> { - public: - explicit AbstractCylinderRenderer(); -}; - -template class CylinderRenderer: public AbstractCylinderRenderer { - public: - explicit CylinderRenderer(const Shapes::Implementation::AbstractShape& cylinder); - CylinderRenderer(const Shapes::Implementation::AbstractShape&&) = delete; - - void draw(Resource& options, const MatrixTypeFor& projectionMatrix) override; - - private: - const Shapes::Cylinder& cylinder; -}; -CORRADE_IGNORE_DEPRECATED_POP - -}}} - -#endif diff --git a/src/Magnum/DebugTools/Implementation/CylinderRendererTransformation.h b/src/Magnum/DebugTools/Implementation/CylinderRendererTransformation.h deleted file mode 100644 index bbbb87e83a..0000000000 --- a/src/Magnum/DebugTools/Implementation/CylinderRendererTransformation.h +++ /dev/null @@ -1,91 +0,0 @@ -#ifndef Magnum_DebugTools_Implementation_ForceRendererTransformation_h -#define Magnum_DebugTools_Implementation_ForceRendererTransformation_h -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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 "Magnum/DimensionTraits.h" -#include "Magnum/Magnum.h" -#include "Magnum/Math/Functions.h" -#include "Magnum/Math/Matrix3.h" -#include "Magnum/Math/Matrix4.h" - -namespace Magnum { namespace DebugTools { namespace Implementation { - -CORRADE_IGNORE_DEPRECATED_PUSH -template MatrixTypeFor cylinderRendererTransformation(const VectorTypeFor& a, const VectorTypeFor& b, Float radius); - -template<> Matrix3 cylinderRendererTransformation<2>(const Vector2& a, const Vector2& b, const Float radius) { - /* Vector from cylinder center to top hemisphere center */ - const Vector2 direction = 0.5f*(b - a); - const Float length = direction.length(); - - /* Capsule rotation and distance to caps after they are scaled to proper - radius (if nonzero cylinder length) */ - Matrix3 rotation; - if(length >= Math::TypeTraits::epsilon()) { - rotation.up() = direction/length; - rotation.right() = rotation.up().perpendicular(); - CORRADE_INTERNAL_ASSERT(rotation.right().isNormalized()); - } - - /* Scaling and translation */ - return Matrix3::translation(0.5f*(a + b))*rotation*Matrix3::scaling({radius, length}); -} - -template<> Matrix4 cylinderRendererTransformation<3>(const Vector3& a, const Vector3& b, const Float radius) { - /* Vector from cylinder center to top hemisphere center */ - const Vector3 direction = 0.5f*(b - a); - const Float length = direction.length(); - - /* Capsule rotation and distance to caps after they are scaled to proper - radius (if nonzero cylinder length) */ - Matrix4 rotation; - if(length >= Math::TypeTraits::epsilon()) { - const Vector3 directionNormalized = direction/length; - const Float dot = Math::dot(directionNormalized, Vector3::zAxis()); - - /* Direction is parallel to Z axis, special rotation case */ - if(Math::abs(dot) > 1.0f - Math::TypeTraits::epsilon()) { - rotation.up() = dot*Vector3::zAxis(); - rotation.right() = Vector3::xAxis(); - rotation.backward() = -dot*Vector3::yAxis(); - - /* Common case */ - } else { - rotation.up() = directionNormalized; - rotation.right() = Math::cross(rotation.up(), Vector3::zAxis()).normalized(); - rotation.backward() = Math::cross(rotation.right(), rotation.up()); - CORRADE_INTERNAL_ASSERT(rotation.up().isNormalized() && rotation.backward().isNormalized()); - } - } - - /* Scaling and translation */ - return Matrix4::translation(0.5f*(a + b))*rotation*Matrix4::scaling({radius, length, radius}); -} -CORRADE_IGNORE_DEPRECATED_POP - -}}} - -#endif diff --git a/src/Magnum/DebugTools/Implementation/LineSegmentRenderer.cpp b/src/Magnum/DebugTools/Implementation/LineSegmentRenderer.cpp deleted file mode 100644 index 1867d602c5..0000000000 --- a/src/Magnum/DebugTools/Implementation/LineSegmentRenderer.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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. -*/ - -#define _MAGNUM_DO_NOT_WARN_DEPRECATED_SHAPES - -#include "LineSegmentRenderer.h" - -#include "Magnum/DebugTools/ShapeRenderer.h" -#include "Magnum/GL/Mesh.h" -#include "Magnum/Shapes/LineSegment.h" -#include "Magnum/Primitives/Line.h" -#include "Magnum/Shaders/Flat.h" -#include "Magnum/Trade/MeshData2D.h" -#include "Magnum/Trade/MeshData3D.h" - -#include "Magnum/DebugTools/Implementation/LineSegmentRendererTransformation.h" - -namespace Magnum { namespace DebugTools { namespace Implementation { - -CORRADE_IGNORE_DEPRECATED_PUSH -namespace { - template ResourceKey meshKey(); - template<> inline ResourceKey meshKey<2>() { return ResourceKey("line2d"); } - template<> inline ResourceKey meshKey<3>() { return ResourceKey("line3d"); } - - template ResourceKey vertexBufferKey(); - template<> inline ResourceKey vertexBufferKey<2>() { return ResourceKey("line2d-vertices"); } - template<> inline ResourceKey vertexBufferKey<3>() { return ResourceKey("line3d-vertices"); } - - template typename MeshData::Type meshData(); - template<> inline Trade::MeshData2D meshData<2>() { return Primitives::line2D(); } - template<> inline Trade::MeshData3D meshData<3>() { return Primitives::line3D(); } -} - -template LineSegmentRenderer::LineSegmentRenderer(const Shapes::Implementation::AbstractShape& line): AbstractShapeRenderer(meshKey(), vertexBufferKey(), {}), line(static_cast>&>(line).shape) { - if(!AbstractShapeRenderer::wireframeMesh) AbstractShapeRenderer::createResources(meshData()); -} - -template void LineSegmentRenderer::draw(Resource& options, const MatrixTypeFor& projectionMatrix) { - AbstractShapeRenderer::wireframeShader->setTransformationProjectionMatrix(projectionMatrix* - Implementation::lineSegmentRendererTransformation(line.a(), line.b())) - .setColor(options->color()); - AbstractShapeRenderer::wireframeMesh->draw(*AbstractShapeRenderer::wireframeShader); -} - -template class LineSegmentRenderer<2>; -template class LineSegmentRenderer<3>; -CORRADE_IGNORE_DEPRECATED_POP - -}}} diff --git a/src/Magnum/DebugTools/Implementation/LineSegmentRenderer.h b/src/Magnum/DebugTools/Implementation/LineSegmentRenderer.h deleted file mode 100644 index 7e594ddb8b..0000000000 --- a/src/Magnum/DebugTools/Implementation/LineSegmentRenderer.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef Magnum_DebugTools_Implementation_LineSegmentRenderer_h -#define Magnum_DebugTools_Implementation_LineSegmentRenderer_h -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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 "Magnum/Shapes/Shapes.h" - -#include "Magnum/DebugTools/Implementation/AbstractShapeRenderer.h" - -namespace Magnum { namespace DebugTools { namespace Implementation { - -CORRADE_IGNORE_DEPRECATED_PUSH -template class LineSegmentRenderer: public AbstractShapeRenderer { - public: - explicit LineSegmentRenderer(const Shapes::Implementation::AbstractShape& line); - LineSegmentRenderer(const Shapes::Implementation::AbstractShape&&) = delete; - - void draw(Resource& options, const MatrixTypeFor& projectionMatrix) override; - - private: - const Shapes::LineSegment& line; -}; -CORRADE_IGNORE_DEPRECATED_POP - -}}} - -#endif diff --git a/src/Magnum/DebugTools/Implementation/LineSegmentRendererTransformation.h b/src/Magnum/DebugTools/Implementation/LineSegmentRendererTransformation.h deleted file mode 100644 index d6efcb2899..0000000000 --- a/src/Magnum/DebugTools/Implementation/LineSegmentRendererTransformation.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef Magnum_DebugTools_Implementation_LineSegmentRendererTransformation_h -#define Magnum_DebugTools_Implementation_LineSegmentRendererTransformation_h -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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 "Magnum/DimensionTraits.h" - -namespace Magnum { namespace DebugTools { namespace Implementation { - -CORRADE_IGNORE_DEPRECATED_PUSH -template MatrixTypeFor lineSegmentRendererTransformation(const VectorTypeFor& a, const VectorTypeFor& b) { - auto transformation = MatrixTypeFor::translation(a); - transformation.right() = b - a; - return transformation; -} -CORRADE_IGNORE_DEPRECATED_POP - -}}} - -#endif diff --git a/src/Magnum/DebugTools/Implementation/PointRenderer.cpp b/src/Magnum/DebugTools/Implementation/PointRenderer.cpp deleted file mode 100644 index 624c10d452..0000000000 --- a/src/Magnum/DebugTools/Implementation/PointRenderer.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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. -*/ - -#define _MAGNUM_DO_NOT_WARN_DEPRECATED_SHAPES - -#include "PointRenderer.h" - -#include "Magnum/DebugTools/ShapeRenderer.h" -#include "Magnum/GL/Mesh.h" -#include "Magnum/Shapes/Point.h" -#include "Magnum/Primitives/Crosshair.h" -#include "Magnum/Shaders/Flat.h" -#include "Magnum/Trade/MeshData2D.h" -#include "Magnum/Trade/MeshData3D.h" - -namespace Magnum { namespace DebugTools { namespace Implementation { - -CORRADE_IGNORE_DEPRECATED_PUSH -namespace { - template ResourceKey meshKey(); - template<> inline ResourceKey meshKey<2>() { return ResourceKey("point2d"); } - template<> inline ResourceKey meshKey<3>() { return ResourceKey("point3d"); } - - template ResourceKey vertexBufferKey(); - template<> inline ResourceKey vertexBufferKey<2>() { return ResourceKey("point2d-vertices"); } - template<> inline ResourceKey vertexBufferKey<3>() { return ResourceKey("point3d-vertices"); } - - template typename MeshData::Type meshData(); - template<> inline Trade::MeshData2D meshData<2>() { return Primitives::crosshair2D(); } - template<> inline Trade::MeshData3D meshData<3>() { return Primitives::crosshair3D(); } -} - -template PointRenderer::PointRenderer(const Shapes::Implementation::AbstractShape& point): AbstractShapeRenderer(meshKey(), vertexBufferKey(), {}), point(static_cast>&>(point).shape) { - if(!AbstractShapeRenderer::wireframeMesh) AbstractShapeRenderer::createResources(meshData()); -} - -template void PointRenderer::draw(Resource& options, const MatrixTypeFor& projectionMatrix) { - /* Half scale, because the point is 2x2(x2) */ - AbstractShapeRenderer::wireframeShader->setTransformationProjectionMatrix(projectionMatrix* - MatrixTypeFor::translation(point.position())* - MatrixTypeFor::scaling(VectorTypeFor{options->pointSize()/2})) - .setColor(options->color()); - AbstractShapeRenderer::wireframeMesh->draw(*AbstractShapeRenderer::wireframeShader); -} - -template class PointRenderer<2>; -template class PointRenderer<3>; -CORRADE_IGNORE_DEPRECATED_POP - -}}} diff --git a/src/Magnum/DebugTools/Implementation/PointRenderer.h b/src/Magnum/DebugTools/Implementation/PointRenderer.h deleted file mode 100644 index 861c2fb584..0000000000 --- a/src/Magnum/DebugTools/Implementation/PointRenderer.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef Magnum_DebugTools_Implementation_PointRenderer_h -#define Magnum_DebugTools_Implementation_PointRenderer_h -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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 "Magnum/Shapes/Shapes.h" - -#include "Magnum/DebugTools/Implementation/AbstractShapeRenderer.h" - -namespace Magnum { namespace DebugTools { namespace Implementation { - -CORRADE_IGNORE_DEPRECATED_PUSH -template class PointRenderer: public AbstractShapeRenderer { - public: - explicit PointRenderer(const Shapes::Implementation::AbstractShape& point); - PointRenderer(Shapes::Implementation::AbstractShape&&) = delete; - - void draw(Resource& options, const MatrixTypeFor& projectionMatrix) override; - - private: - const Shapes::Point& point; -}; -CORRADE_IGNORE_DEPRECATED_POP - -}}} - -#endif diff --git a/src/Magnum/DebugTools/Implementation/SphereRenderer.cpp b/src/Magnum/DebugTools/Implementation/SphereRenderer.cpp deleted file mode 100644 index 0234b3fcc9..0000000000 --- a/src/Magnum/DebugTools/Implementation/SphereRenderer.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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. -*/ - -#define _MAGNUM_DO_NOT_WARN_DEPRECATED_SHAPES - -#include "SphereRenderer.h" - -#include "Magnum/DebugTools/ShapeRenderer.h" -#include "Magnum/GL/Mesh.h" -#include "Magnum/Primitives/Circle.h" -#include "Magnum/Primitives/UVSphere.h" -#include "Magnum/Shaders/Flat.h" -#include "Magnum/Shapes/Sphere.h" -#include "Magnum/Trade/MeshData2D.h" -#include "Magnum/Trade/MeshData3D.h" - -namespace Magnum { namespace DebugTools { namespace Implementation { - -CORRADE_IGNORE_DEPRECATED_PUSH -AbstractSphereRenderer<2>::AbstractSphereRenderer(): AbstractShapeRenderer<2>("sphere2d", "sphere2d-vertices", {}) { - if(!wireframeMesh) createResources(Primitives::circle2DWireframe(40)); -} - -AbstractSphereRenderer<3>::AbstractSphereRenderer(): AbstractShapeRenderer<3>("sphere3d", "sphere3d-vertices", "sphere3d-indices") { - if(!wireframeMesh) createResources(Primitives::uvSphereWireframe(20, 40)); -} - -template SphereRenderer::SphereRenderer(const Shapes::Implementation::AbstractShape& sphere): sphere(static_cast>&>(sphere).shape) {} - -template void SphereRenderer::draw(Resource& options, const MatrixTypeFor& projectionMatrix) { - AbstractShapeRenderer::wireframeShader->setTransformationProjectionMatrix(projectionMatrix* - MatrixTypeFor::translation(sphere.position())* - MatrixTypeFor::scaling(VectorTypeFor{sphere.radius()})) - .setColor(options->color()); - AbstractShapeRenderer::wireframeMesh->draw(*AbstractShapeRenderer::wireframeShader); -} - -template class SphereRenderer<2>; -template class SphereRenderer<3>; -CORRADE_IGNORE_DEPRECATED_POP - -}}} diff --git a/src/Magnum/DebugTools/Implementation/SphereRenderer.h b/src/Magnum/DebugTools/Implementation/SphereRenderer.h deleted file mode 100644 index cd941aee95..0000000000 --- a/src/Magnum/DebugTools/Implementation/SphereRenderer.h +++ /dev/null @@ -1,61 +0,0 @@ -#ifndef Magnum_DebugTools_Implementation_SphereRenderer_h -#define Magnum_DebugTools_Implementation_SphereRenderer_h -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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 "Magnum/Shapes/Shapes.h" - -#include "Magnum/DebugTools/Implementation/AbstractShapeRenderer.h" - -namespace Magnum { namespace DebugTools { namespace Implementation { - -CORRADE_IGNORE_DEPRECATED_PUSH -template class AbstractSphereRenderer; - -template<> class AbstractSphereRenderer<2>: public AbstractShapeRenderer<2> { - public: - explicit AbstractSphereRenderer(); -}; - -template<> class AbstractSphereRenderer<3>: public AbstractShapeRenderer<3> { - public: - explicit AbstractSphereRenderer(); -}; - -template class SphereRenderer: public AbstractSphereRenderer { - public: - explicit SphereRenderer(const Shapes::Implementation::AbstractShape& sphere); - SphereRenderer(const Shapes::Implementation::AbstractShape&&) = delete; - - void draw(Resource& options, const MatrixTypeFor& projectionMatrix) override; - - private: - const Shapes::Sphere& sphere; -}; -CORRADE_IGNORE_DEPRECATED_POP - -}}} - -#endif diff --git a/src/Magnum/DebugTools/ResourceManager.cpp b/src/Magnum/DebugTools/ResourceManager.cpp index b0e76de372..df5d85afbc 100644 --- a/src/Magnum/DebugTools/ResourceManager.cpp +++ b/src/Magnum/DebugTools/ResourceManager.cpp @@ -23,8 +23,6 @@ DEALINGS IN THE SOFTWARE. */ -#define _MAGNUM_DO_NOT_WARN_DEPRECATED_SHAPES - #include "ResourceManager.h" #include "Magnum/ResourceManager.hpp" @@ -35,24 +33,10 @@ #include "Magnum/GL/Mesh.h" #include "Magnum/GL/MeshView.h" -#ifdef MAGNUM_BUILD_DEPRECATED -#include "Magnum/DebugTools/ShapeRenderer.h" -#endif - namespace Magnum { namespace Implementation { - #ifdef MAGNUM_BUILD_DEPRECATED - CORRADE_IGNORE_DEPRECATED_PUSH - #endif - template struct MAGNUM_DEBUGTOOLS_EXPORT ResourceManagerLocalInstanceImplementation; - #ifdef MAGNUM_BUILD_DEPRECATED - CORRADE_IGNORE_DEPRECATED_POP - #endif + template struct MAGNUM_DEBUGTOOLS_EXPORT ResourceManagerLocalInstanceImplementation; } namespace DebugTools { @@ -60,11 +44,6 @@ namespace DebugTools { ResourceManager::ResourceManager() { setFallback(new ForceRendererOptions); setFallback(new ObjectRendererOptions); - #ifdef MAGNUM_BUILD_DEPRECATED - CORRADE_IGNORE_DEPRECATED_PUSH - setFallback(new ShapeRendererOptions); - CORRADE_IGNORE_DEPRECATED_POP - #endif } ResourceManager::~ResourceManager() = default; diff --git a/src/Magnum/DebugTools/ResourceManager.h b/src/Magnum/DebugTools/ResourceManager.h index 072349fecd..c9f2ab6f07 100644 --- a/src/Magnum/DebugTools/ResourceManager.h +++ b/src/Magnum/DebugTools/ResourceManager.h @@ -47,18 +47,6 @@ #include "Magnum/GL/Buffer.h" #include "Magnum/GL/Mesh.h" #include "Magnum/GL/MeshView.h" - -#ifdef MAGNUM_BUILD_DEPRECATED -#if !defined(Magnum_DebugTools_ShapeRenderer_h) && !defined(_MAGNUM_DO_NOT_WARN_DEPRECATED_SHAPES) -#define Magnum_DebugTools_ShapeRenderer_h_not_included -#define _MAGNUM_DO_NOT_WARN_DEPRECATED_SHAPES -#endif -#include "Magnum/DebugTools/ShapeRenderer.h" -#ifdef Magnum_DebugTools_ShapeRenderer_h_not_included -#undef Magnum_DebugTools_ShapeRenderer_h_not_included -#undef _MAGNUM_DO_NOT_WARN_DEPRECATED_SHAPES -#endif -#endif #endif #ifdef MAGNUM_TARGET_GL @@ -74,22 +62,12 @@ information. @ref MAGNUM_TARGET_GL "TARGET_GL" enabled (done by default). See @ref building-features for more information. */ -#ifdef MAGNUM_BUILD_DEPRECATED -CORRADE_IGNORE_DEPRECATED_PUSH -#endif -class MAGNUM_DEBUGTOOLS_EXPORT ResourceManager: public Magnum::ResourceManager +class MAGNUM_DEBUGTOOLS_EXPORT ResourceManager: public Magnum::ResourceManager { public: explicit ResourceManager(); ~ResourceManager(); }; -#ifdef MAGNUM_BUILD_DEPRECATED -CORRADE_IGNORE_DEPRECATED_POP -#endif #else #error this header is available only in the OpenGL build #endif diff --git a/src/Magnum/DebugTools/ShapeRenderer.cpp b/src/Magnum/DebugTools/ShapeRenderer.cpp deleted file mode 100644 index 0a79e41be8..0000000000 --- a/src/Magnum/DebugTools/ShapeRenderer.cpp +++ /dev/null @@ -1,137 +0,0 @@ -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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. -*/ - -#define _MAGNUM_DO_NOT_WARN_DEPRECATED_SHAPES - -#include "ShapeRenderer.h" - -#include "Magnum/DebugTools/ResourceManager.h" -#include "Magnum/Shapes/Composition.h" -#include "Magnum/Shapes/Shape.h" -#include "Magnum/SceneGraph/Camera.h" - -#include "Magnum/DebugTools/Implementation/AxisAlignedBoxRenderer.h" -#include "Magnum/DebugTools/Implementation/BoxRenderer.h" -#include "Magnum/DebugTools/Implementation/CapsuleRenderer.h" -#include "Magnum/DebugTools/Implementation/CylinderRenderer.h" -#include "Magnum/DebugTools/Implementation/LineSegmentRenderer.h" -#include "Magnum/DebugTools/Implementation/PointRenderer.h" -#include "Magnum/DebugTools/Implementation/SphereRenderer.h" - -namespace Magnum { namespace DebugTools { - -CORRADE_IGNORE_DEPRECATED_PUSH -namespace Implementation { - -template<> void createDebugMesh(ShapeRenderer<2>& renderer, const Shapes::Implementation::AbstractShape<2>& shape) { - switch(shape.type()) { - case Shapes::AbstractShape2D::Type::AxisAlignedBox: - renderer._renderers.push_back(new Implementation::AxisAlignedBoxRenderer<2>(shape)); - break; - case Shapes::AbstractShape2D::Type::Box: - renderer._renderers.push_back(new Implementation::BoxRenderer<2>(shape)); - break; - case Shapes::AbstractShape2D::Type::LineSegment: - renderer._renderers.push_back(new Implementation::LineSegmentRenderer<2>(shape)); - break; - case Shapes::AbstractShape2D::Type::Point: - renderer._renderers.push_back(new Implementation::PointRenderer<2>(shape)); - break; - case Shapes::AbstractShape2D::Type::Sphere: - case Shapes::AbstractShape2D::Type::InvertedSphere: /* Isn't publicly subclassed, but shouldn't matter */ - renderer._renderers.push_back(new Implementation::SphereRenderer<2>(shape)); - break; - case Shapes::AbstractShape2D::Type::Capsule: - renderer._renderers.push_back(new Implementation::CapsuleRenderer<2>(shape)); - break; - case Shapes::AbstractShape2D::Type::Cylinder: - renderer._renderers.push_back(new Implementation::CylinderRenderer<2>(shape)); - break; - case Shapes::AbstractShape2D::Type::Composition: { - const Shapes::Composition2D& composition = - static_cast&>(shape).shape; - for(std::size_t i = 0; i != composition.size(); ++i) - createDebugMesh(renderer, Shapes::Implementation::getAbstractShape(composition, i)); - } break; - default: - Warning() << "DebugTools::ShapeRenderer2D::createShapeRenderer(): type" << shape.type() << "not implemented"; - } -} - -template<> void createDebugMesh(ShapeRenderer<3>& renderer, const Shapes::Implementation::AbstractShape<3>& shape) { - switch(shape.type()) { - case Shapes::AbstractShape3D::Type::AxisAlignedBox: - renderer._renderers.push_back(new Implementation::AxisAlignedBoxRenderer<3>(shape)); - break; - case Shapes::AbstractShape3D::Type::Box: - renderer._renderers.push_back(new Implementation::BoxRenderer<3>(shape)); - break; - case Shapes::AbstractShape3D::Type::LineSegment: - renderer._renderers.push_back(new Implementation::LineSegmentRenderer<3>(shape)); - break; - case Shapes::AbstractShape3D::Type::Point: - renderer._renderers.push_back(new Implementation::PointRenderer<3>(shape)); - break; - case Shapes::AbstractShape3D::Type::Sphere: - case Shapes::AbstractShape3D::Type::InvertedSphere: /* Isn't publicly subclassed, but shouldn't matter */ - renderer._renderers.push_back(new Implementation::SphereRenderer<3>(shape)); - break; - case Shapes::AbstractShape3D::Type::Capsule: - renderer._renderers.push_back(new Implementation::CapsuleRenderer<3>(shape)); - break; - case Shapes::AbstractShape3D::Type::Cylinder: - renderer._renderers.push_back(new Implementation::CylinderRenderer<3>(shape)); - break; - case Shapes::AbstractShape3D::Type::Composition: { - const Shapes::Composition3D& composition = - static_cast&>(shape).shape; - for(std::size_t i = 0; i != composition.size(); ++i) - createDebugMesh(renderer, Shapes::Implementation::getAbstractShape(composition, i)); - } break; - default: - Warning() << "DebugTools::ShapeRenderer3D::createShapeRenderer(): type" << shape.type() << "not implemented"; - } -} - -} - -template ShapeRenderer::ShapeRenderer(Shapes::AbstractShape& shape, ResourceKey options, SceneGraph::DrawableGroup* drawables): SceneGraph::Drawable(shape.object(), drawables), _options(ResourceManager::instance().get(options)) { - Implementation::createDebugMesh(*this, Shapes::Implementation::getAbstractShape(shape)); -} - -template ShapeRenderer::~ShapeRenderer() { - for(auto i: _renderers) delete i; -} - -template void ShapeRenderer::draw(const MatrixTypeFor&, SceneGraph::Camera& camera) { - const MatrixTypeFor projectionMatrix = camera.projectionMatrix()*camera.cameraMatrix(); - for(auto i: _renderers) i->draw(_options, projectionMatrix); -} - -template class ShapeRenderer<2>; -template class ShapeRenderer<3>; -CORRADE_IGNORE_DEPRECATED_POP - -}} diff --git a/src/Magnum/DebugTools/ShapeRenderer.h b/src/Magnum/DebugTools/ShapeRenderer.h deleted file mode 100644 index b532680e21..0000000000 --- a/src/Magnum/DebugTools/ShapeRenderer.h +++ /dev/null @@ -1,250 +0,0 @@ -#ifndef Magnum_DebugTools_ShapeRenderer_h -#define Magnum_DebugTools_ShapeRenderer_h -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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. -*/ - -#ifdef MAGNUM_TARGET_GL -/** @file -@brief Class @ref Magnum::DebugTools::ShapeRenderer, @ref Magnum::DebugTools::ShapeRendererOptions, typedef @ref Magnum::DebugTools::ShapeRenderer2D, @ref Magnum::DebugTools::ShapeRenderer3D - -@deprecated The @ref Magnum::Shapes library is a failed design experiment and - is scheduled for removal in a future release. Related geometry algorithms - were moved to @ref Magnum::Math::Distance and @ref Magnum::Math::Intersection; - if you need a full-fledged physics library, please have look at - [Bullet](https://bulletphysics.org), which has Magnum integration in - @ref Magnum::BulletIntegration, or at [Box2D](https://box2d.org/), which - has a @ref examples-box2d "Magnum example" as well. -*/ -#endif - -#include "Magnum/Resource.h" -#include "Magnum/Math/Color.h" -#include "Magnum/SceneGraph/Drawable.h" -#include "Magnum/Shapes/Shapes.h" -#include "Magnum/Shapes/shapeImplementation.h" -#include "Magnum/DebugTools/DebugTools.h" -#include "Magnum/DebugTools/visibility.h" - -#ifndef MAGNUM_BUILD_DEPRECATED -#error the Shapes library is scheduled for removal, see the docs for alternatives -#endif - -/* I still have a test for this class and it shouldn't pollute the log there */ -#ifndef _MAGNUM_DO_NOT_WARN_DEPRECATED_SHAPES -CORRADE_DEPRECATED_FILE("the Shapes library is scheduled for removal, see the docs for alternatives") -#endif - -#ifdef MAGNUM_TARGET_GL -namespace Magnum { namespace DebugTools { - -CORRADE_IGNORE_DEPRECATED_PUSH -template class ShapeRenderer; - -namespace Implementation { - template class AbstractShapeRenderer; - - template void createDebugMesh(ShapeRenderer& renderer, const Shapes::Implementation::AbstractShape& shape); -} - -/** -@brief Shape renderer options - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration, or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. - -See @ref ShapeRenderer documentation for more information. - -@note This class is available only if Magnum is compiled with - @ref MAGNUM_TARGET_GL "TARGET_GL" enabled (done by default) and - `WITH_SHAPES` enabled (disabled by default). See @ref building-features for - more information. -*/ -class CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") ShapeRendererOptions { - public: - /** - * @brief Shape rendering mode - * - * @see @ref setRenderMode() - */ - enum class RenderMode: UnsignedByte { - Wireframe, /**< Wireframe rendering */ - Solid /**< Solid rendering */ - }; - - constexpr ShapeRendererOptions(): _color(1.0f), _pointSize(0.25f), _renderMode(RenderMode::Wireframe) {} - - /** @brief Shape rendering mode */ - constexpr RenderMode renderMode() const { return _renderMode; } - - /** - * @brief Set shape rendering mode - * @return Reference to self (for method chaining) - * - * Default is @ref RenderMode::Wireframe. - */ - ShapeRendererOptions& setRenderMode(RenderMode mode) { - _renderMode = mode; - return *this; - } - - /** @brief Color of rendered shape */ - constexpr Color4 color() const { return _color; } - - /** - * @brief Set color of rendered shape - * @return Reference to self (for method chaining) - * - * Default is @cpp 0xffffffff_rgbaf @ce. - */ - ShapeRendererOptions& setColor(const Color4& color) { - _color = color; - return *this; - } - - /** @brief Point size */ - constexpr Float pointSize() const { return _pointSize; } - - /** - * @brief Set point size - * @return Reference to self (for method chaining) - * - * Size of rendered crosshairs, representing @ref Shapes::Point shapes. - * Default is @cpp 0.25f @ce. - */ - ShapeRendererOptions& setPointSize(Float size) { - _pointSize = size; - return *this; - } - - private: - Color4 _color; - Float _pointSize; - RenderMode _renderMode; -}; - -/** -@brief Shape renderer - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration, or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. - -Visualizes collision shapes using wireframe primitives. See -@ref debug-tools-renderers for more information. - -@section DebugTools-ShapeRenderer-usage Basic usage - -Example code: - -@code{.cpp} -// Create some options -DebugTools::ResourceManager::instance().set("red", - DebugTools::ShapeRendererOptions().setColor({1.0f, 0.0f, 0.0f})); - -// Create debug renderer for given shape, use "red" options for it -Shapes::AbstractShape2D* shape; -new DebugTools::ShapeRenderer2D(shape, "red", debugDrawables); -@endcode - -@note This class is available only if Magnum is compiled with - @ref MAGNUM_TARGET_GL "TARGET_GL" enabled (done by default) and - `WITH_SHAPES` enabled (disabled by default). See @ref building-features for - more information. - -@see @ref ShapeRenderer2D, @ref ShapeRenderer3D, @ref ShapeRendererOptions - -@todo Different drawing style for inverted shapes? (marking the "inside" somehow) -*/ -template class CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") MAGNUM_DEBUGTOOLS_EXPORT ShapeRenderer: public SceneGraph::Drawable { - #ifndef DOXYGEN_GENERATING_OUTPUT - friend void Implementation::createDebugMesh<>(ShapeRenderer&, const Shapes::Implementation::AbstractShape&); - #endif - - public: - /** - * @brief Constructor - * @param shape Shape for which to create debug renderer - * @param options Options resource key. See - * @ref DebugTools-ShapeRenderer-usage "class documentation" for - * more information. - * @param drawables Drawable group - * - * The renderer is automatically added to shape's object features, - * @p shape must be available for the whole lifetime of the renderer - * and if it is group, it must not change its internal structure. - */ - explicit ShapeRenderer(Shapes::AbstractShape& shape, ResourceKey options = ResourceKey(), SceneGraph::DrawableGroup* drawables = nullptr); - - ~ShapeRenderer(); - - private: - void draw(const MatrixTypeFor& transformationMatrix, SceneGraph::Camera& camera) override; - - Resource _options; - std::vector*> _renderers; -}; - -/** -@brief Two-dimensional shape renderer - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration, or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. -*/ -typedef CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") ShapeRenderer<2> ShapeRenderer2D; - -/** -@brief Three-dimensional shape renderer - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration, or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. -*/ -typedef CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") ShapeRenderer<3> ShapeRenderer3D; -CORRADE_IGNORE_DEPRECATED_POP - -}} -#else -#error this header is available only in the OpenGL build -#endif - -#endif diff --git a/src/Magnum/DebugTools/Test/CMakeLists.txt b/src/Magnum/DebugTools/Test/CMakeLists.txt index fb2ab7c5fe..be14009510 100644 --- a/src/Magnum/DebugTools/Test/CMakeLists.txt +++ b/src/Magnum/DebugTools/Test/CMakeLists.txt @@ -85,18 +85,6 @@ if(WITH_TRADE) endif() if(TARGET_GL) - if(WITH_SHAPES) - corrade_add_test(DebugToolsCapsuleRendererTest CapsuleRendererTest.cpp LIBRARIES MagnumMathTestLib) - corrade_add_test(DebugToolsCylinderRendererTest CylinderRendererTest.cpp LIBRARIES MagnumMathTestLib) - corrade_add_test(DebugToolsLineSegmentRendererTest LineSegmentRendererTest.cpp LIBRARIES MagnumMathTestLib) - - set_target_properties( - DebugToolsCapsuleRendererTest - DebugToolsCylinderRendererTest - DebugToolsLineSegmentRendererTest - PROPERTIES FOLDER "Magnum/DebugTools/Test") - endif() - if(WITH_SCENEGRAPH) corrade_add_test(DebugToolsForceRendererTest ForceRendererTest.cpp LIBRARIES MagnumMathTestLib) set_target_properties(DebugToolsForceRendererTest PROPERTIES FOLDER "Magnum/DebugTools/Test") diff --git a/src/Magnum/DebugTools/Test/CapsuleRendererTest.cpp b/src/Magnum/DebugTools/Test/CapsuleRendererTest.cpp deleted file mode 100644 index 988e29bc04..0000000000 --- a/src/Magnum/DebugTools/Test/CapsuleRendererTest.cpp +++ /dev/null @@ -1,179 +0,0 @@ -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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/DebugTools/Implementation/CapsuleRendererTransformation.h" - -namespace Magnum { namespace DebugTools { namespace Test { namespace { - -struct CapsuleRendererTest: TestSuite::Tester { - explicit CapsuleRendererTest(); - - void zeroLength2D(); - void common2D(); - - void zeroLength3D(); - void parallel3D(); - void antiParallel3D(); - void common3D(); -}; - -CapsuleRendererTest::CapsuleRendererTest() { - addTests({&CapsuleRendererTest::zeroLength2D, - &CapsuleRendererTest::common2D, - - &CapsuleRendererTest::zeroLength3D, - &CapsuleRendererTest::parallel3D, - &CapsuleRendererTest::antiParallel3D, - &CapsuleRendererTest::common3D}); -} - -CORRADE_IGNORE_DEPRECATED_PUSH -void CapsuleRendererTest::zeroLength2D() { - const Vector2 a(0.5f, 3.0f); - std::array transformation = Implementation::capsuleRendererTransformation<2>(a, a, 3.5f); - - const auto scaling = Matrix2x2::fromDiagonal(Vector2(3.5f)); - CORRADE_COMPARE(transformation[0].rotationScaling(), scaling); - CORRADE_COMPARE(transformation[1].rotationScaling(), Matrix2x2::fromDiagonal({3.5f, 0.0f})); - CORRADE_COMPARE(transformation[2].rotationScaling(), scaling); - - CORRADE_COMPARE(transformation[0].translation(), a); - CORRADE_COMPARE(transformation[1].translation(), a); - CORRADE_COMPARE(transformation[2].translation(), a); -} - -void CapsuleRendererTest::common2D() { - const Vector2 a(0.5f, 3.0f); - const Vector2 b(7.5f, -1.0f); - std::array transformation = Implementation::capsuleRendererTransformation<2>(a, b, 3.5f); - - /* Vector from capsule center to top hemisphere center */ - const Vector2 up(3.5f, -2.0f); - CORRADE_COMPARE(transformation[0].up(), up.resized(3.5f)); - CORRADE_COMPARE(transformation[1].up(), up); - CORRADE_COMPARE(transformation[2].up(), up.resized(3.5f)); - - const auto right = Vector2(4.0f, 7.0f).resized(3.5f); - CORRADE_COMPARE(transformation[0].right(), right); - CORRADE_COMPARE(transformation[1].right(), right); - CORRADE_COMPARE(transformation[2].right(), right); - - /* Orthogonality */ - CORRADE_COMPARE(Math::dot(transformation[0].up(), transformation[0].right()), 0.0f); - - const Vector2 capDistance = up.resized(3.5f); - CORRADE_COMPARE(transformation[0].translation(), a+capDistance); - CORRADE_COMPARE(transformation[1].translation(), 0.5f*(a + b)); - CORRADE_COMPARE(transformation[2].translation(), b-capDistance); -} - -void CapsuleRendererTest::zeroLength3D() { - const Vector3 a(0.5f, 3.0f, 7.0f); - std::array transformation = Implementation::capsuleRendererTransformation<3>(a, a, 3.5f); - - const auto scaling = Matrix3x3::fromDiagonal(Vector3(3.5f)); - CORRADE_COMPARE(transformation[0].rotationScaling(), scaling); - CORRADE_COMPARE(transformation[1].rotationScaling(), Matrix3x3::fromDiagonal({3.5f, 0.0f, 3.5f})); - CORRADE_COMPARE(transformation[2].rotationScaling(), scaling); - - CORRADE_COMPARE(transformation[0].translation(), a); - CORRADE_COMPARE(transformation[1].translation(), a); - CORRADE_COMPARE(transformation[2].translation(), a); -} - -void CapsuleRendererTest::parallel3D() { - const Vector3 a(0.5f, 3.0f, 7.0f); - const Vector3 b(0.5f, 3.0f, 11.0f); - std::array transformation = Implementation::capsuleRendererTransformation<3>(a, b, 3.5f); - - const auto rotation = Matrix4::rotationX(Deg(90.0f)); - const auto scaling = (rotation*Matrix4::scaling(Vector3(3.5f))).rotationScaling(); - CORRADE_COMPARE(transformation[0].rotationScaling(), scaling); - CORRADE_COMPARE(transformation[1].rotationScaling(), - (rotation*Matrix4::scaling({3.5f, 2.0f, 3.5f})).rotationScaling()); - CORRADE_COMPARE(transformation[2].rotationScaling(), scaling); - - const auto capDistance = Vector3::zAxis(3.5f); - CORRADE_COMPARE(transformation[0].translation(), a+capDistance); - CORRADE_COMPARE(transformation[1].translation(), a+Vector3::zAxis(2.0f)); - CORRADE_COMPARE(transformation[2].translation(), b-capDistance); -} - -void CapsuleRendererTest::antiParallel3D() { - const Vector3 a(0.5f, 3.0f, 7.0f); - const Vector3 b(0.5f, 3.0f, 3.0f); - std::array transformation = Implementation::capsuleRendererTransformation<3>(a, b, 3.5f); - - const auto rotation = Matrix4::rotationX(-Deg(90.0f)); - const auto rotationScaling = (rotation*Matrix4::scaling(Vector3(3.5f))).rotationScaling(); - CORRADE_COMPARE(transformation[0].rotationScaling(), rotationScaling); - CORRADE_COMPARE(transformation[1].rotationScaling(), - (rotation*Matrix4::scaling({3.5f, 2.0f, 3.5f})).rotationScaling()); - CORRADE_COMPARE(transformation[2].rotationScaling(), rotationScaling); - - const auto capDistance = Vector3::zAxis(-3.5f); - CORRADE_COMPARE(transformation[0].translation(), a+capDistance); - CORRADE_COMPARE(transformation[1].translation(), a+Vector3::zAxis(-2.0f)); - CORRADE_COMPARE(transformation[2].translation(), b-capDistance); -} - -void CapsuleRendererTest::common3D() { - const Vector3 a(0.5f, 3.0f, 7.0f); - const Vector3 b(7.5f, -1.0f, 1.5f); - std::array transformation = Implementation::capsuleRendererTransformation<3>(a, b, 3.5f); - - /* Vector from capsule center to top hemisphere center */ - const Vector3 up(3.5f, -2.0f, -2.75f); - CORRADE_COMPARE(transformation[0].up(), up.resized(3.5f)); - CORRADE_COMPARE(transformation[1].up(), up); - CORRADE_COMPARE(transformation[2].up(), up.resized(3.5f)); - - const auto right = Vector3(-2.0f, -3.5f, 0.0f).resized(3.5f); - CORRADE_COMPARE(transformation[0].right(), right); - CORRADE_COMPARE(transformation[1].right(), right); - CORRADE_COMPARE(transformation[2].right(), right); - - const auto backward = Vector3(9.625f, -5.5f, 16.25f).resized(3.5f); - CORRADE_COMPARE(transformation[0].backward(), backward); - CORRADE_COMPARE(transformation[1].backward(), backward); - CORRADE_COMPARE(transformation[2].backward(), backward); - - /* Orthogonality */ - CORRADE_COMPARE(Math::dot(transformation[0].up(), transformation[0].right()), 0.0f); - CORRADE_COMPARE(Math::dot(transformation[0].up(), transformation[0].backward()), 0.0f); - CORRADE_COMPARE(Math::dot(transformation[0].right(), transformation[0].backward()), 0.0f); - - const Vector3 capDistance = up.resized(3.5f); - CORRADE_COMPARE(transformation[0].translation(), a+capDistance); - CORRADE_COMPARE(transformation[1].translation(), 0.5f*(a + b)); - CORRADE_COMPARE(transformation[2].translation(), b-capDistance); -} -CORRADE_IGNORE_DEPRECATED_POP - -}}}} - -CORRADE_TEST_MAIN(Magnum::DebugTools::Test::CapsuleRendererTest) diff --git a/src/Magnum/DebugTools/Test/CylinderRendererTest.cpp b/src/Magnum/DebugTools/Test/CylinderRendererTest.cpp deleted file mode 100644 index 6564f2f9fb..0000000000 --- a/src/Magnum/DebugTools/Test/CylinderRendererTest.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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/DebugTools/Implementation/CylinderRendererTransformation.h" - -namespace Magnum { namespace DebugTools { namespace Test { namespace { - -struct CylinderRendererTest: TestSuite::Tester { - explicit CylinderRendererTest(); - - void zeroLength2D(); - void common2D(); - - void zeroLength3D(); - void parallel3D(); - void antiParallel3D(); - void common3D(); -}; - -CylinderRendererTest::CylinderRendererTest() { - addTests({&CylinderRendererTest::zeroLength2D, - &CylinderRendererTest::common2D, - - &CylinderRendererTest::zeroLength3D, - &CylinderRendererTest::parallel3D, - &CylinderRendererTest::antiParallel3D, - &CylinderRendererTest::common3D}); -} - -CORRADE_IGNORE_DEPRECATED_PUSH -void CylinderRendererTest::zeroLength2D() { - const Vector2 a(0.5f, 3.0f); - const Matrix3 transformation = Implementation::cylinderRendererTransformation<2>(a, a, 3.5f); - - CORRADE_COMPARE(transformation.rotationScaling(), Matrix2x2::fromDiagonal({3.5f, 0.0f})); - CORRADE_COMPARE(transformation.translation(), a); -} - -void CylinderRendererTest::common2D() { - const Vector2 a(0.5f, 3.0f); - const Vector2 b(7.5f, -1.0f); - const Matrix3 transformation = Implementation::cylinderRendererTransformation<2>(a, b, 3.5f); - - /* Rotation + scaling, test orthogonality */ - CORRADE_COMPARE(transformation.up(), Vector2(3.5f, -2.0f)); - CORRADE_COMPARE(transformation.right(), Vector2(4.0f, 7.0f).resized(3.5f)); - CORRADE_COMPARE(Math::dot(transformation.up(), transformation.right()), 0.0f); - - CORRADE_COMPARE(transformation.translation(), 0.5f*(a + b)); -} - -void CylinderRendererTest::zeroLength3D() { - const Vector3 a(0.5f, 3.0f, 7.0f); - const Matrix4 transformation = Implementation::cylinderRendererTransformation<3>(a, a, 3.5f); - - CORRADE_COMPARE(transformation.rotationScaling(), Matrix3x3::fromDiagonal({3.5f, 0.0f, 3.5f})); - CORRADE_COMPARE(transformation.translation(), a); -} - -void CylinderRendererTest::parallel3D() { - const Vector3 a(0.5f, 3.0f, 7.0f); - const Vector3 b(0.5f, 3.0f, 11.0f); - const Matrix4 transformation = Implementation::cylinderRendererTransformation<3>(a, b, 3.5f); - - CORRADE_COMPARE(transformation.rotationScaling(), - (Matrix4::rotationX(Deg(90.0f))*Matrix4::scaling({3.5f, 2.0f, 3.5f})).rotationScaling()); - - CORRADE_COMPARE(transformation.translation(), a+Vector3::zAxis(2.0f)); -} - -void CylinderRendererTest::antiParallel3D() { - const Vector3 a(0.5f, 3.0f, 7.0f); - const Vector3 b(0.5f, 3.0f, 3.0f); - const Matrix4 transformation = Implementation::cylinderRendererTransformation<3>(a, b, 3.5f); - - CORRADE_COMPARE(transformation.rotationScaling(), - (Matrix4::rotationX(-Deg(90.0f))*Matrix4::scaling({3.5f, 2.0f, 3.5f})).rotationScaling()); - - CORRADE_COMPARE(transformation.translation(), a+Vector3::zAxis(-2.0f)); -} - -void CylinderRendererTest::common3D() { - const Vector3 a(0.5f, 3.0f, 7.0f); - const Vector3 b(7.5f, -1.0f, 1.5f); - const Matrix4 transformation = Implementation::cylinderRendererTransformation<3>(a, b, 3.5f); - - /* Rotation + scaling */ - CORRADE_COMPARE(transformation.up(), Vector3(3.5f, -2.0f, -2.75f)); - CORRADE_COMPARE(transformation.right(), Vector3(-2.0f, -3.5f, 0.0f).resized(3.5f)); - CORRADE_COMPARE(transformation.backward(), Vector3(9.625f, -5.5f, 16.25f).resized(3.5f)); - - /* Orthogonality */ - CORRADE_COMPARE(Math::dot(transformation.up(), transformation.right()), 0.0f); - CORRADE_COMPARE(Math::dot(transformation.up(), transformation.backward()), 0.0f); - CORRADE_COMPARE(Math::dot(transformation.right(), transformation.backward()), 0.0f); - - CORRADE_COMPARE(transformation.translation(), 0.5f*(a + b)); -} -CORRADE_IGNORE_DEPRECATED_POP - -}}}} - -CORRADE_TEST_MAIN(Magnum::DebugTools::Test::CylinderRendererTest) diff --git a/src/Magnum/DebugTools/Test/LineSegmentRendererTest.cpp b/src/Magnum/DebugTools/Test/LineSegmentRendererTest.cpp deleted file mode 100644 index 0ff4c534b4..0000000000 --- a/src/Magnum/DebugTools/Test/LineSegmentRendererTest.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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/Magnum.h" -#include "Magnum/Math/Matrix3.h" -#include "Magnum/Math/Matrix4.h" - -#include "Magnum/DebugTools/Implementation/LineSegmentRendererTransformation.h" - -namespace Magnum { namespace DebugTools { namespace Test { namespace { - -struct LineSegmentRendererTest: TestSuite::Tester { - explicit LineSegmentRendererTest(); - - void line2D(); - void line3D(); -}; - -LineSegmentRendererTest::LineSegmentRendererTest() { - addTests({&LineSegmentRendererTest::line2D, - &LineSegmentRendererTest::line3D}); -} - -CORRADE_IGNORE_DEPRECATED_PUSH -void LineSegmentRendererTest::line2D() { - const Vector2 a(-2.0f, 3.0f); - const Vector2 b(3.4f, -1.5f); - const Matrix3 matrix = Implementation::lineSegmentRendererTransformation<2>(a, b); - - CORRADE_COMPARE(matrix.transformPoint({0.0f, 0.0f}), a); - CORRADE_COMPARE(matrix.transformPoint({1.0f, 0.0f}), b); -} - -void LineSegmentRendererTest::line3D() { - const Vector3 a(-2.0f, 3.0f, 1.5f); - const Vector3 b(3.4f, -1.5f, 0.5f); - const Matrix4 matrix = Implementation::lineSegmentRendererTransformation<3>(a, b); - - CORRADE_COMPARE(matrix.transformPoint({0.0f, 0.0f, 0.0f}), a); - CORRADE_COMPARE(matrix.transformPoint({1.0f, 0.0f, 0.0f}), b); -} -CORRADE_IGNORE_DEPRECATED_POP - -}}}} - -CORRADE_TEST_MAIN(Magnum::DebugTools::Test::LineSegmentRendererTest) diff --git a/src/Magnum/Shapes/AbstractShape.cpp b/src/Magnum/Shapes/AbstractShape.cpp deleted file mode 100644 index 89ca71b784..0000000000 --- a/src/Magnum/Shapes/AbstractShape.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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. -*/ - -#define _MAGNUM_DO_NOT_WARN_DEPRECATED_SHAPES - -#include "AbstractShape.h" - -#include - -#include "Magnum/Shapes/Collision.h" -#include "Magnum/Shapes/ShapeGroup.h" -#include "Magnum/Shapes/Implementation/CollisionDispatch.h" - -namespace Magnum { namespace Shapes { - -CORRADE_IGNORE_DEPRECATED_PUSH -template AbstractShape::AbstractShape(SceneGraph::AbstractObject& object, ShapeGroup* group): SceneGraph::AbstractGroupedFeature, Float>(object, group) { - SceneGraph::AbstractFeature::setCachedTransformations(SceneGraph::CachedTransformation::Absolute); -} - -template ShapeGroup* AbstractShape::group() { - return static_cast*>(SceneGraph::AbstractGroupedFeature, Float>::group()); -} - -template const ShapeGroup* AbstractShape::group() const { - return static_cast*>(SceneGraph::AbstractGroupedFeature, Float>::group()); -} - -template auto AbstractShape::type() const -> Type { - return abstractTransformedShape().type(); -} - -template bool AbstractShape::collides(const AbstractShape& other) const { - return Implementation::collides(abstractTransformedShape(), other.abstractTransformedShape()); -} - -template Collision AbstractShape::collision(const AbstractShape& other) const { - return Implementation::collision(abstractTransformedShape(), other.abstractTransformedShape()); -} - -template void AbstractShape::markDirty() { - if(group()) group()->setDirty(); -} - -#ifndef DOXYGEN_GENERATING_OUTPUT -template class MAGNUM_SHAPES_EXPORT AbstractShape<2>; -template class MAGNUM_SHAPES_EXPORT AbstractShape<3>; -#endif -CORRADE_IGNORE_DEPRECATED_POP - -}} diff --git a/src/Magnum/Shapes/AbstractShape.h b/src/Magnum/Shapes/AbstractShape.h deleted file mode 100644 index 9429d1f739..0000000000 --- a/src/Magnum/Shapes/AbstractShape.h +++ /dev/null @@ -1,172 +0,0 @@ -#ifndef Magnum_Shapes_AbstractShape_h -#define Magnum_Shapes_AbstractShape_h -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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 Class @ref Magnum::Shapes::AbstractShape, typedef @ref Magnum::Shapes::AbstractShape2D, @ref Magnum::Shapes::AbstractShape3D - -@deprecated The @ref Magnum::Shapes library is a failed design experiment and - is scheduled for removal in a future release. Related geometry algorithms - were moved to @ref Magnum::Math::Distance and @ref Magnum::Math::Intersection; - if you need a full-fledged physics library, please have look at - [Bullet](https://bulletphysics.org), which has Magnum integration in - @ref Magnum::BulletIntegration, or at [Box2D](https://box2d.org/), which - has a @ref examples-box2d "Magnum example" as well. -*/ - -#include "Magnum/Magnum.h" -#include "Magnum/DimensionTraits.h" -#include "Magnum/SceneGraph/AbstractGroupedFeature.h" -#include "Magnum/Shapes/shapeImplementation.h" -#include "Magnum/Shapes/Shapes.h" -#include "Magnum/Shapes/visibility.h" - -/* File-level deprecation warning issued from Shapes.h */ - -namespace Magnum { namespace Shapes { - -CORRADE_IGNORE_DEPRECATED_PUSH -namespace Implementation { - template inline const AbstractShape& getAbstractShape(const Shapes::AbstractShape& shape) { - return shape.abstractTransformedShape(); - } -} - -/** -@brief Base class for object shapes - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration, or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. - -This class is not directly instantiable, use @ref Shape instead. See -@ref shapes for brief introduction. -@see @ref AbstractShape2D, @ref AbstractShape3D -*/ -template class CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") MAGNUM_SHAPES_EXPORT AbstractShape: public SceneGraph::AbstractGroupedFeature, Float> { - #ifndef CORRADE_MSVC2017_COMPATIBILITY - friend const Implementation::AbstractShape& Implementation::getAbstractShape<>(const AbstractShape&); - #else - /* Otherwise it complains that this is not a function */ - template friend const Implementation::AbstractShape& Implementation::getAbstractShape(const Shapes::AbstractShape&); - #endif - - public: - enum: UnsignedInt { - Dimensions = dimensions /**< Dimension count */ - }; - - /** @brief Shape type */ - #ifdef DOXYGEN_GENERATING_OUTPUT - enum class Type { - Point, /**< @ref Point */ - Line, /**< @ref Line */ - LineSegment, /**< @ref LineSegment "Line segment" */ - Sphere, /**< @ref Sphere */ - Capsule, /**< @ref Capsule */ - AxisAlignedBox, /**< @ref AxisAlignedBox "Axis aligned box" */ - Box, /**< @ref Box */ - Composition, /**< @ref Composition "Shape group" */ - Plane /**< @ref Plane (3D only) */ - }; - #else - typedef typename Implementation::ShapeDimensionTraits::Type Type; - #endif - - /** - * @brief Constructor - * @param object Object holding this feature - * @param group Group this shape belongs to - */ - explicit AbstractShape(SceneGraph::AbstractObject& object, ShapeGroup* group = nullptr); - - /** - * @brief Shape group containing this shape - * - * If the shape doesn't belong to any group, returns @cpp nullptr @ce. - */ - ShapeGroup* group(); - const ShapeGroup* group() const; /**< @overload */ - - /** @brief Shape type */ - Type type() const; - - /** - * @brief Detect collision with other shape - * - * Default implementation returns false. - */ - bool collides(const AbstractShape& other) const; - - /** - * @brief Collision with other shape - * - * Default implementation returns empty collision. - */ - Collision collision(const AbstractShape& other) const; - - protected: - /** Marks also the group as dirty */ - void markDirty() override; - - private: - virtual const Implementation::AbstractShape MAGNUM_SHAPES_LOCAL & abstractTransformedShape() const = 0; -}; - -/** -@brief Base class for two-dimensional object shapes - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration, or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. -*/ -typedef CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") AbstractShape<2> AbstractShape2D; - -/** -@brief Base class for three-dimensional object shapes - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration, or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. -*/ -typedef CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") AbstractShape<3> AbstractShape3D; -CORRADE_IGNORE_DEPRECATED_POP - -}} - -#endif diff --git a/src/Magnum/Shapes/AxisAlignedBox.cpp b/src/Magnum/Shapes/AxisAlignedBox.cpp deleted file mode 100644 index a4deaba594..0000000000 --- a/src/Magnum/Shapes/AxisAlignedBox.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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. -*/ - -#define _MAGNUM_DO_NOT_WARN_DEPRECATED_SHAPES - -#include "AxisAlignedBox.h" - -#include "Magnum/Math/Matrix3.h" -#include "Magnum/Math/Matrix4.h" -#include "Magnum/Shapes/Point.h" - -namespace Magnum { namespace Shapes { - -CORRADE_IGNORE_DEPRECATED_PUSH -template AxisAlignedBox AxisAlignedBox::transformed(const MatrixTypeFor& matrix) const { - return AxisAlignedBox(matrix.transformPoint(_min), - matrix.transformPoint(_max)); -} - -template bool AxisAlignedBox::operator%(const Point& other) const { - return (other.position() >= _min).all() && - (other.position() < _max).all(); -} - -#ifndef DOXYGEN_GENERATING_OUTPUT -template class MAGNUM_SHAPES_EXPORT AxisAlignedBox<2>; -template class MAGNUM_SHAPES_EXPORT AxisAlignedBox<3>; -#endif -CORRADE_IGNORE_DEPRECATED_POP - -}} diff --git a/src/Magnum/Shapes/AxisAlignedBox.h b/src/Magnum/Shapes/AxisAlignedBox.h deleted file mode 100644 index 198ccc23f2..0000000000 --- a/src/Magnum/Shapes/AxisAlignedBox.h +++ /dev/null @@ -1,153 +0,0 @@ -#ifndef Magnum_Shapes_AxisAlignedBox_h -#define Magnum_Shapes_AxisAlignedBox_h -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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 Class @ref Magnum::Shapes::AxisAlignedBox, typedef @ref Magnum::Shapes::AxisAlignedBox2D, @ref Magnum::Shapes::AxisAlignedBox3D - -@deprecated The @ref Magnum::Shapes library is a failed design experiment and - is scheduled for removal in a future release. Related geometry algorithms - were moved to @ref Magnum::Math::Distance and @ref Magnum::Math::Intersection; - if you need a full-fledged physics library, please have look at - [Bullet](https://bulletphysics.org), which has Magnum integration in - @ref Magnum::BulletIntegration, or at [Box2D](https://box2d.org/), which - has a @ref examples-box2d "Magnum example" as well. -*/ - -#include "Magnum/DimensionTraits.h" -#include "Magnum/Math/Vector3.h" -#include "Magnum/Shapes/Shapes.h" -#include "Magnum/Shapes/visibility.h" - -/* File-level deprecation warning issued from Shapes.h */ - -namespace Magnum { namespace Shapes { - -CORRADE_IGNORE_DEPRECATED_PUSH -/** -@brief Axis-aligned box - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration, or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. - -See @ref shapes for brief introduction. -@see @ref AxisAlignedBox2D, @ref AxisAlignedBox3D -@todo Assert for rotation -*/ -template class CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") MAGNUM_SHAPES_EXPORT AxisAlignedBox { - public: - enum: UnsignedInt { - Dimensions = dimensions /**< Dimension count */ - }; - - /** - * @brief Default constructor - * - * Creates zero sized box positioned at origin. - */ - constexpr /*implicit*/ AxisAlignedBox() {} - - /** @brief Constructor */ - constexpr /*implicit*/ AxisAlignedBox(const VectorTypeFor& min, const typename DimensionTraits::VectorType& max): _min(min), _max(max) {} - - /** @brief Transformed shape */ - AxisAlignedBox transformed(const MatrixTypeFor& matrix) const; - - /** @brief Minimal coordinates */ - constexpr VectorTypeFor min() const { - return _min; - } - - /** @brief Set minimal coordinates */ - void setMin(const VectorTypeFor& min) { - _min = min; - } - - /** @brief Maximal coordinates */ - constexpr VectorTypeFor max() const { - return _max; - } - - /** @brief Set maximal coordinates */ - void setMax(const VectorTypeFor& max) { - _max = max; - } - - /** @brief Collision occurence with point */ - bool operator%(const Point& other) const; - - private: - VectorTypeFor _min, _max; -}; - -/** -@brief Two-dimensional axis-aligned box - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration, or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. -*/ -typedef CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") AxisAlignedBox<2> AxisAlignedBox2D; - -/** -@brief Three-dimensional axis-aligned box - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration, or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. -*/ -typedef CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") AxisAlignedBox<3> AxisAlignedBox3D; - -/** -@collisionoccurenceoperator{Point,AxisAlignedBox} - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration, or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. -*/ -template inline CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") bool operator%(const Point& a, const AxisAlignedBox& b) { return b % a; } -CORRADE_IGNORE_DEPRECATED_POP - -}} - -#endif diff --git a/src/Magnum/Shapes/Box.cpp b/src/Magnum/Shapes/Box.cpp deleted file mode 100644 index aebeae98e5..0000000000 --- a/src/Magnum/Shapes/Box.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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. -*/ - -#define _MAGNUM_DO_NOT_WARN_DEPRECATED_SHAPES - -#include "Box.h" - -namespace Magnum { namespace Shapes { - -CORRADE_IGNORE_DEPRECATED_PUSH -template Box Box::transformed(const MatrixTypeFor& matrix) const { - return Box(matrix*_transformation); -} - -#ifndef DOXYGEN_GENERATING_OUTPUT -template class MAGNUM_SHAPES_EXPORT Box<2>; -template class MAGNUM_SHAPES_EXPORT Box<3>; -#endif -CORRADE_IGNORE_DEPRECATED_POP - -}} diff --git a/src/Magnum/Shapes/Box.h b/src/Magnum/Shapes/Box.h deleted file mode 100644 index c8e1df5c4f..0000000000 --- a/src/Magnum/Shapes/Box.h +++ /dev/null @@ -1,130 +0,0 @@ -#ifndef Magnum_Shapes_Box_h -#define Magnum_Shapes_Box_h -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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 Class @ref Magnum::Shapes::Box, typedef @ref Magnum::Shapes::Box2D, @ref Magnum::Shapes::Box3D - -@deprecated The @ref Magnum::Shapes library is a failed design experiment and - is scheduled for removal in a future release. Related geometry algorithms - were moved to @ref Magnum::Math::Distance and @ref Magnum::Math::Intersection; - if you need a full-fledged physics library, please have look at - [Bullet](https://bulletphysics.org), which has Magnum integration in - @ref Magnum::BulletIntegration, or at [Box2D](https://box2d.org/), which - has a @ref examples-box2d "Magnum example" as well. -*/ - -#include "Magnum/DimensionTraits.h" -#include "Magnum/Math/Matrix3.h" -#include "Magnum/Math/Matrix4.h" -#include "Magnum/Shapes/Shapes.h" -#include "Magnum/Shapes/visibility.h" - -/* File-level deprecation warning issued from Shapes.h */ - -namespace Magnum { namespace Shapes { - -CORRADE_IGNORE_DEPRECATED_PUSH -/** -@brief Unit-size box with assigned transformation matrix - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration, or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. - -Unit-size means that half extents are equal to 1, equivalent to e.g. sphere -radius. See @ref shapes for brief introduction. -@see @ref Box2D, @ref Box3D -@todo Use quat + position + size instead? -@todo Assert for skew -*/ -template class CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") MAGNUM_SHAPES_EXPORT Box { - public: - enum: UnsignedInt { - Dimensions = dimensions /**< Dimension count */ - }; - - /** - * @brief Default constructor - * - * Creates zero-sized box positioned at origin. - */ - constexpr /*implicit*/ Box(): _transformation{Math::ZeroInit} {} - - /** @brief Constructor */ - constexpr /*implicit*/ Box(const MatrixTypeFor& transformation): _transformation(transformation) {} - - /** @brief Transformed shape */ - Box transformed(const MatrixTypeFor& matrix) const; - - /** @brief Transformation */ - constexpr MatrixTypeFor transformation() const { - return _transformation; - } - - /** @brief Set transformation */ - void setTransformation(const MatrixTypeFor& transformation) { - _transformation = transformation; - } - - private: - MatrixTypeFor _transformation; -}; - -/** -@brief Two-dimensional box - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration, or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. -*/ -typedef CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") Box<2> Box2D; - -/** -@brief Three-dimensional box - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration, or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. -*/ -typedef CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") Box<3> Box3D; -CORRADE_IGNORE_DEPRECATED_POP - -}} - -#endif diff --git a/src/Magnum/Shapes/CMakeLists.txt b/src/Magnum/Shapes/CMakeLists.txt deleted file mode 100644 index 72f7742b8b..0000000000 --- a/src/Magnum/Shapes/CMakeLists.txt +++ /dev/null @@ -1,97 +0,0 @@ -# -# This file is part of Magnum. -# -# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 -# 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. -# - -if(NOT MAGNUM_BUILD_DEPRECATED) - message(FATAL_ERROR "Shapes are scheduled for removal and not available if BUILD_DEPRECATED is disabled. See the docs for alternatives.") -endif() - -set(MagnumShapes_SRCS - AbstractShape.cpp - AxisAlignedBox.cpp - Box.cpp - Capsule.cpp - Cylinder.cpp - Composition.cpp - Line.cpp - Plane.cpp - Point.cpp - Shape.cpp - ShapeGroup.cpp - Sphere.cpp - - shapeImplementation.cpp - - Implementation/CollisionDispatch.cpp) - -set(MagnumShapes_HEADERS - AbstractShape.h - AxisAlignedBox.h - Box.h - Capsule.h - Cylinder.h - Collision.h - Composition.h - Line.h - LineSegment.h - Shape.h - ShapeGroup.h - Shapes.h - Plane.h - Point.h - Sphere.h - - shapeImplementation.h - visibility.h) - -# Header files to display in project view of IDEs only -set(MagnumShapes_PRIVATE_HEADERS Implementation/CollisionDispatch.h) - -# Shapes library -add_library(MagnumShapes ${SHARED_OR_STATIC} - ${MagnumShapes_SRCS} - ${MagnumShapes_HEADERS} - ${MagnumShapes_PRIVATE_HEADERS}) -set_target_properties(MagnumShapes PROPERTIES - DEBUG_POSTFIX "-d" - FOLDER "Magnum/Shapes") -if(NOT BUILD_STATIC) - set_target_properties(MagnumShapes PROPERTIES VERSION ${MAGNUM_LIBRARY_VERSION} SOVERSION ${MAGNUM_LIBRARY_SOVERSION}) -elseif(BUILD_STATIC_PIC) - set_target_properties(MagnumShapes PROPERTIES POSITION_INDEPENDENT_CODE ON) -endif() -target_link_libraries(MagnumShapes PUBLIC Magnum MagnumSceneGraph) - -install(TARGETS MagnumShapes - RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR} - LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR} - ARCHIVE DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) -install(FILES ${MagnumShapes_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Shapes) - -if(BUILD_TESTS) - add_subdirectory(Test) -endif() - -# Magnum Shapes target alias for superprojects -add_library(Magnum::Shapes ALIAS MagnumShapes) diff --git a/src/Magnum/Shapes/Capsule.cpp b/src/Magnum/Shapes/Capsule.cpp deleted file mode 100644 index 786ac090d8..0000000000 --- a/src/Magnum/Shapes/Capsule.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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. -*/ - -#define _MAGNUM_DO_NOT_WARN_DEPRECATED_SHAPES - -#include "Capsule.h" - -#include "Magnum/Magnum.h" -#include "Magnum/Math/Distance.h" -#include "Magnum/Math/Functions.h" -#include "Magnum/Math/Matrix3.h" -#include "Magnum/Math/Matrix4.h" -#include "Magnum/Shapes/Point.h" -#include "Magnum/Shapes/Sphere.h" - -namespace Magnum { namespace Shapes { - -CORRADE_IGNORE_DEPRECATED_PUSH -template Capsule Capsule::transformed(const MatrixTypeFor& matrix) const { - return Capsule(matrix.transformPoint(_a), matrix.transformPoint(_b), matrix.uniformScaling()*_radius); -} - -template bool Capsule::operator%(const Point& other) const { - return Math::Distance::lineSegmentPointSquared(_a, _b, other.position()) < - Math::pow<2>(_radius); -} - -template bool Capsule::operator%(const Sphere& other) const { - return Math::Distance::lineSegmentPointSquared(_a, _b, other.position()) < - Math::pow<2>(_radius+other.radius()); -} - -#ifndef DOXYGEN_GENERATING_OUTPUT -template class MAGNUM_SHAPES_EXPORT Capsule<2>; -template class MAGNUM_SHAPES_EXPORT Capsule<3>; -#endif -CORRADE_IGNORE_DEPRECATED_POP - -}} diff --git a/src/Magnum/Shapes/Capsule.h b/src/Magnum/Shapes/Capsule.h deleted file mode 100644 index 2d0d4520f5..0000000000 --- a/src/Magnum/Shapes/Capsule.h +++ /dev/null @@ -1,178 +0,0 @@ -#ifndef Magnum_Shapes_Capsule_h -#define Magnum_Shapes_Capsule_h -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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 Class @ref Magnum::Shapes::Capsule, typedef @ref Magnum::Shapes::Capsule2D, @ref Magnum::Shapes::Capsule3D - -@deprecated The @ref Magnum::Shapes library is a failed design experiment and - is scheduled for removal in a future release. Related geometry algorithms - were moved to @ref Magnum::Math::Distance and @ref Magnum::Math::Intersection; - if you need a full-fledged physics library, please have look at - [Bullet](https://bulletphysics.org), which has Magnum integration in - @ref Magnum::BulletIntegration, or at [Box2D](https://box2d.org/), which - has a @ref examples-box2d "Magnum example" as well. -*/ - -#include "Magnum/DimensionTraits.h" -#include "Magnum/Math/Vector3.h" -#include "Magnum/Shapes/Shapes.h" -#include "Magnum/Shapes/visibility.h" - -/* File-level deprecation warning issued from Shapes.h */ - -namespace Magnum { namespace Shapes { - -CORRADE_IGNORE_DEPRECATED_PUSH -/** -@brief Capsule defined by cylinder start and end point and radius - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration, or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. - -Unlike other elements the capsule expects uniform scaling. See @ref shapes for -brief introduction. -@see @ref Capsule2D, @ref Capsule3D, @ref Cylinder -@todo Store the radius as squared value to avoid sqrt/pow? Will complicate - collision detection with sphere. -*/ -template class CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") MAGNUM_SHAPES_EXPORT Capsule { - public: - enum: UnsignedInt { - Dimensions = dimensions /**< Dimension count */ - }; - - /** - * @brief Constructor - * - * Creates zero-sized capsule at origin. - */ - constexpr /*implicit*/ Capsule(): _radius(0.0f) {} - - /** @brief Constructor */ - constexpr /*implicit*/ Capsule(const VectorTypeFor& a, const VectorTypeFor& b, Float radius): _a(a), _b(b), _radius(radius) {} - - /** @brief Transformed shape */ - Capsule transformed(const MatrixTypeFor& matrix) const; - - /** @brief Start point */ - constexpr VectorTypeFor a() const { - return _a; - } - - /** @brief Set start point */ - void setA(const VectorTypeFor& a) { - _a = a; - } - - /** @brief End point */ - constexpr VectorTypeFor b() const { - return _b; - } - - /** @brief Set end point */ - void setB(const VectorTypeFor& b) { - _b = b; - } - - /** @brief Radius */ - constexpr Float radius() const { return _radius; } - - /** @brief Set radius */ - void setRadius(Float radius) { _radius = radius; } - - /** @brief Collision occurence with point */ - bool operator%(const Point& other) const; - - /** @brief Collision occurence with sphere */ - bool operator%(const Sphere& other) const; - - private: - VectorTypeFor _a, _b; - Float _radius; -}; - -/** -@brief Two-dimensional capsule - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration, or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. -*/ -typedef CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") Capsule<2> Capsule2D; - -/** -@brief Three-dimensional capsule - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration, or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. -*/ -typedef CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") Capsule<3> Capsule3D; - -/** -@collisionoccurenceoperator{Point,Capsule} - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration, or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. -*/ -template inline CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") bool operator%(const Point& a, const Capsule& b) { return b % a; } - -/** -@collisionoccurenceoperator{Sphere,Capsule} - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration, or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. -*/ -template inline CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") bool operator%(const Sphere& a, const Capsule& b) { return b % a; } -CORRADE_IGNORE_DEPRECATED_POP - -}} - -#endif diff --git a/src/Magnum/Shapes/Collision.h b/src/Magnum/Shapes/Collision.h deleted file mode 100644 index 9cbaa40ebf..0000000000 --- a/src/Magnum/Shapes/Collision.h +++ /dev/null @@ -1,173 +0,0 @@ -#ifndef Magnum_Shapes_Collision_h -#define Magnum_Shapes_Collision_h -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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 Class @ref Magnum::Shapes::Collision, typedef @ref Magnum::Shapes::Collision2D, @ref Magnum::Shapes::Collision3D - -@deprecated The @ref Magnum::Shapes library is a failed design experiment and - is scheduled for removal in a future release. Related geometry algorithms - were moved to @ref Magnum::Math::Distance and @ref Magnum::Math::Intersection; - if you need a full-fledged physics library, please have look at - [Bullet](https://bulletphysics.org), which has Magnum integration in - @ref Magnum::BulletIntegration, or at [Box2D](https://box2d.org/), which - has a @ref examples-box2d "Magnum example" as well. -*/ - -#include "Magnum/DimensionTraits.h" -#include "Magnum/Math/Vector2.h" -#include "Magnum/Math/Vector3.h" -#include "Magnum/Shapes/Shapes.h" - -/* File-level deprecation warning issued from Shapes.h */ - -namespace Magnum { namespace Shapes { - -CORRADE_IGNORE_DEPRECATED_PUSH -/** -@brief Collision data - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration, or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. - -Contains information about collision between objects A and B, described by -contact position, separation normal and separation distance. - -If the collision occured, contact position is on object B surface, separation -normal is *normalized* vector in which direction should object A be moved to -separate the bodies, separation distance is positive and describes minimal -movement of object A in direction of separation normal after which the contact -position will no longer be colliding with object A. - -If the collision not occured, contact position and separation normal is -undefined (i.e., *not* normalized) and separation distance is negative or zero. -@see @ref Collision2D, @ref Collision3D -*/ -template class CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") Collision { - public: - /** - * @brief Default constructor - * - * Sets position, normal and separation distance to zero, as if no - * collision happened. - */ - /*implicit*/ Collision(): _separationDistance(0.0f) {} - - /** - * @brief Constructor - * - * If separation distance is positive, the separation normal is - * expected to be normalized. - */ - explicit Collision(const VectorTypeFor& position, const VectorTypeFor& separationNormal, Float separationDistance) noexcept: _position(position), _separationNormal(separationNormal), _separationDistance(separationDistance) { - CORRADE_ASSERT(_separationDistance < Math::TypeTraits::epsilon() || separationNormal.isNormalized(), "Shapes::Collision::Collision: separation normal is not normalized", ); - } - - /** - * @brief Whether the collision happened - * - * Negative or zero separation distance means that no collision - * happened. - * @see @ref separationDistance() - */ - operator bool() const { return _separationDistance > 0.0f; } - - /** @brief Collision position */ - VectorTypeFor position() const { - return _position; - } - - /** - * @brief Separation normal - * - * @see @ref separationDistance(), @ref flipped() - */ - VectorTypeFor separationNormal() const { - return _separationNormal; - } - - /** - * @brief Separation distance - * - * @see @ref separationNormal(), @ref operator bool() - */ - Float separationDistance() const { - return _separationDistance; - } - - /** - * @brief Flipped collision - * - * Returns new collision object as if the collision occured between - * flipped pair of objects, i.e. with flipped separation normal and - * contact position on surface of object A. - * @see @ref position(), @ref separationNormal() - */ - Collision flipped() const { - return Collision(_position - _separationDistance*_separationNormal, -_separationNormal, _separationDistance); - } - - private: - VectorTypeFor _position; - VectorTypeFor _separationNormal; - Float _separationDistance; -}; - -/** -@brief Two-dimensional collision data - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration, or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. -*/ -typedef CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") Collision<2> Collision2D; - -/** -@brief Three-dimensional collision data - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration, or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. -*/ -typedef CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") Collision<3> Collision3D; -CORRADE_IGNORE_DEPRECATED_POP - -}} - -#endif diff --git a/src/Magnum/Shapes/Composition.cpp b/src/Magnum/Shapes/Composition.cpp deleted file mode 100644 index 07b735859c..0000000000 --- a/src/Magnum/Shapes/Composition.cpp +++ /dev/null @@ -1,160 +0,0 @@ -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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. -*/ - -#define _MAGNUM_DO_NOT_WARN_DEPRECATED_SHAPES - -#include "Composition.h" - -#include -#include - -#include "Magnum/Shapes/Implementation/CollisionDispatch.h" - -namespace Magnum { namespace Shapes { - -CORRADE_IGNORE_DEPRECATED_PUSH -/* -Hierarchy implementation notes: - -The hierarchy is stored in flat array to provide easy access for the user and -to save some allocations. Each node has zero, one or two subnodes. Value of -`Node::rightNode` describes which child nodes exist: - - * 0 - no child subnodes - * 1 - only left subnode exists - * 2 - only right subnode exists - * >2 - both child nodes exist - -If left node exists, it is right next to current one. If right node exists, it -is at position `Node::rightNode-1` relative to current one (this applies also -when `rightNode` is equal to 2, right node is right next to current one, -because there are no left nodes). - -The node also specifies which shapes belong to it. Root node owns whole shape -array and `Node::rightShape` marks first shape belonging to the right child -node, relatively to begin. This recurses into child nodes, thus left child node -has shapes from parent's begin to parent's `rightShape`. - -Shapes are merged together by concatenating its node and shape list and adding -new node at the beginning with properly set `rightNode` and `rightShape`. -Because these values are relative to parent, they don't need to be modified -when concatenating. -*/ - -template Composition::Composition(const Composition& other): _shapes(other._shapes.size()), _nodes(other._nodes.size()) { - copyShapes(0, other); - copyNodes(0, other); -} - -template Composition::Composition(Composition&& other): _shapes(std::move(other._shapes)), _nodes(std::move(other._nodes)) { - other._shapes = nullptr; - other._nodes = nullptr; -} - -template Composition::~Composition() { - for(std::size_t i = 0; i != _shapes.size(); ++i) - delete _shapes[i]; -} - -template Composition& Composition::operator=(const Composition& other) { - for(std::size_t i = 0; i != _shapes.size(); ++i) - delete _shapes[i]; - - if(_shapes.size() != other._shapes.size()) - _shapes = Containers::Array*>(other._shapes.size()); - - if(_nodes.size() != other._nodes.size()) - _nodes = Containers::Array(other._nodes.size()); - - copyShapes(0, other); - copyNodes(0, other); - return *this; -} - -template Composition& Composition::operator=(Composition&& other) { - using std::swap; - swap(other._shapes, _shapes); - swap(other._nodes, _nodes); - return *this; -} - -template void Composition::copyShapes(const std::size_t offset, Composition&& other) { - CORRADE_INTERNAL_ASSERT(_shapes.size() >= other._shapes.size()+offset); - std::move(other._shapes.begin(), other._shapes.end(), _shapes.begin()+offset); - other._shapes = nullptr; -} - -template void Composition::copyShapes(const std::size_t offset, const Composition& other) { - CORRADE_INTERNAL_ASSERT(_shapes.size() >= other._shapes.size()+offset); - for(Implementation::AbstractShape * const* i = other._shapes.begin(), ** o = _shapes.begin()+offset; i != other._shapes.end(); ++i, ++o) - *o = (*i)->clone(); -} - -template void Composition::copyNodes(std::size_t offset, const Composition& other) { - CORRADE_INTERNAL_ASSERT(_nodes.size() >= other._nodes.size()+offset); - std::copy(other._nodes.begin(), other._nodes.end(), _nodes.begin()+offset); -} - -template Composition Composition::transformed(const MatrixTypeFor& matrix) const { - Composition out(*this); - for(Implementation::AbstractShape * const* i = _shapes.begin(), * const* o = out._shapes.begin(); i != _shapes.end(); ++i, ++o) - (*i)->transform(matrix, *o); - return out; -} - -template bool Composition::collides(const Implementation::AbstractShape& a, const std::size_t node, const std::size_t shapeBegin, const std::size_t shapeEnd) const { - /* Empty group */ - if(shapeBegin == shapeEnd) return false; - - CORRADE_INTERNAL_ASSERT(node < _nodes.size() && shapeBegin < shapeEnd); - - /* Collision on the left child. If the node is leaf one (no left child - exists), do it directly, recurse instead. */ - const bool collidesLeft = (_nodes[node].rightNode == 0 || _nodes[node].rightNode == 2) ? - Implementation::collides(a, *_shapes[shapeBegin]) : - collides(a, node+1, shapeBegin, shapeBegin+_nodes[node].rightShape); - - /* NOT operation */ - if(_nodes[node].operation == CompositionOperation::Not) - return !collidesLeft; - - /* Short-circuit evaluation for AND/OR */ - if((_nodes[node].operation == CompositionOperation::Or) == collidesLeft) - return collidesLeft; - - /* Now the collision result depends only on the right child. Similar to - collision on the left child. */ - return (_nodes[node].rightNode < 2) ? - Implementation::collides(a, *_shapes[shapeBegin+_nodes[node].rightShape]) : - collides(a, node+_nodes[node].rightNode-1, shapeBegin+_nodes[node].rightShape, shapeEnd); -} - -#ifndef DOXYGEN_GENERATING_OUTPUT -template class MAGNUM_SHAPES_EXPORT Composition<2>; -template class MAGNUM_SHAPES_EXPORT Composition<3>; -#endif -CORRADE_IGNORE_DEPRECATED_POP - -}} diff --git a/src/Magnum/Shapes/Composition.h b/src/Magnum/Shapes/Composition.h deleted file mode 100644 index f399e26d8e..0000000000 --- a/src/Magnum/Shapes/Composition.h +++ /dev/null @@ -1,395 +0,0 @@ -#ifndef Magnum_Shapes_Composition_h -#define Magnum_Shapes_Composition_h -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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 Class @ref Magnum::Shapes::Composition, typedef @ref Magnum::Shapes::Composition2D, @ref Magnum::Shapes::Composition3D, enum @ref Magnum::Shapes::CompositionOperation - -@deprecated The @ref Magnum::Shapes library is a failed design experiment and - is scheduled for removal in a future release. Related geometry algorithms - were moved to @ref Magnum::Math::Distance and @ref Magnum::Math::Intersection; - if you need a full-fledged physics library, please have look at - [Bullet](https://bulletphysics.org), which has Magnum integration in - @ref Magnum::BulletIntegration, or at [Box2D](https://box2d.org/), which - has a @ref examples-box2d "Magnum example" as well. -*/ - -#include -#include -#include -#include - -#include "Magnum/DimensionTraits.h" -#include "Magnum/Shapes/Shapes.h" -#include "Magnum/Shapes/shapeImplementation.h" -#include "Magnum/Shapes/visibility.h" - -/* File-level deprecation warning issued from Shapes.h */ - -namespace Magnum { namespace Shapes { - -CORRADE_IGNORE_DEPRECATED_PUSH -namespace Implementation { - template struct ShapeHelper; - - template inline AbstractShape& getAbstractShape(Composition& group, std::size_t i) { - return *group._shapes[i]; - } - template inline const AbstractShape& getAbstractShape(const Composition& group, std::size_t i) { - return *group._shapes[i]; - } -} - -/** -@brief Shape operation - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration, or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. -*/ -enum class CORRADE_DEPRECATED_ENUM("scheduled for removal, see the docs for alternatives") CompositionOperation: UnsignedByte { - Not, /**< Boolean NOT */ - And, /**< Boolean AND */ - Or /**< Boolean OR */ -}; - -/** -@brief Composition of shapes - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration, or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. - -Result of logical operations on shapes. See @ref shapes for brief introduction. -*/ -template class CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") MAGNUM_SHAPES_EXPORT Composition { - friend Implementation::AbstractShape& Implementation::getAbstractShape<>(Composition&, std::size_t); - friend const Implementation::AbstractShape& Implementation::getAbstractShape<>(const Composition&, std::size_t); - friend Implementation::ShapeHelper>; - - public: - enum: UnsignedInt { - Dimensions = dimensions /**< Dimension count */ - }; - - /** @brief Shape type */ - #ifdef DOXYGEN_GENERATING_OUTPUT - enum class Type { - Point, /**< @ref Point */ - Line, /**< @ref Line */ - LineSegment, /**< @ref LineSegment "Line segment" */ - Sphere, /**< @ref Sphere */ - InvertedSphere, /**< @ref InvertedSphere "Inverted sphere" */ - Cylinder, /**< @ref Cylinder */ - Capsule, /**< @ref Capsule */ - AxisAlignedBox, /**< @ref AxisAlignedBox "Axis aligned box" */ - Box, /**< @ref Box */ - Plane /**< @ref Plane (3D only) */ - }; - #else - typedef typename Implementation::ShapeDimensionTraits::Type Type; - #endif - - /** - * @brief Default constructor - * - * Creates empty composition. - */ - explicit Composition() {} - - /** - * @brief Unary operation constructor - * @param operation Unary operation - * @param a Operand - */ - template explicit Composition(CompositionOperation operation, T&& a); - - /** - * @brief Binary operation constructor - * @param operation Binary operation - * @param a Left operand - * @param b Right operand - */ - template explicit Composition(CompositionOperation operation, T&& a, U&& b); - - /** @brief Copy constructor */ - Composition(const Composition& other); - - /** @brief Move constructor */ - Composition(Composition&& other); - - ~Composition(); - - /** @brief Assigment operator */ - Composition& operator=(const Composition& other); - - /** @brief Move assignment operator */ - Composition& operator=(Composition&& other); - - /** @brief Transformed shape */ - Composition transformed(const MatrixTypeFor& matrix) const; - - /** @brief Count of shapes in the hierarchy */ - std::size_t size() const { return _shapes.size(); } - - /** @brief Type of shape at given position */ - Type type(std::size_t i) const { return _shapes[i]->type(); } - - /** @brief Shape at given position */ - template const T& get(std::size_t i) const; - - /** @brief Collision with another shape */ - #ifdef DOXYGEN_GENERATING_OUTPUT - template bool operator%(const T& other) const { - #else - template auto operator%(const T& other) const -> typename std::enable_if::type()), typename Implementation::ShapeDimensionTraits::Type>::value, bool>::type { - #endif - return collides(Implementation::Shape(other)); - } - - private: - struct Node { - std::size_t rightNode, rightShape; - CompositionOperation operation; - }; - - bool collides(const Implementation::AbstractShape& a) const { - return collides(a, 0, 0, _shapes.size()); - } - - bool collides(const Implementation::AbstractShape& a, std::size_t node, std::size_t shapeBegin, std::size_t shapeEnd) const; - - template constexpr static std::size_t shapeCount(const T&) { - return 1; - } - constexpr static std::size_t shapeCount(const Composition& hierarchy) { - return hierarchy._shapes.size(); - } - template constexpr static std::size_t nodeCount(const T&) { - return 0; - } - constexpr static std::size_t nodeCount(const Composition& hierarchy) { - return hierarchy._nodes.size(); - } - - template void copyShapes(std::size_t offset, const T& shape) { - _shapes[offset] = new Implementation::Shape(shape); - } - void copyShapes(std::size_t offset, Composition&& other); - void copyShapes(std::size_t offset, const Composition& other); - - template void copyNodes(std::size_t, const T&) {} - void copyNodes(std::size_t offset, const Composition& other); - - Containers::Array*> _shapes; - Containers::Array _nodes; -}; - -/** -@brief Two-dimensional shape composition - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration, or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. -*/ -CORRADE_IGNORE_DEPRECATED_PUSH /* Otherwise GCC warns on the typedef :/ */ -typedef CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") Composition<2> Composition2D; -CORRADE_IGNORE_DEPRECATED_POP - -/** -@brief Three-dimensional shape composition - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration, or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. -*/ -CORRADE_IGNORE_DEPRECATED_PUSH /* Otherwise GCC warns on the typedef :/ */ -typedef CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") Composition<3> Composition3D; -CORRADE_IGNORE_DEPRECATED_POP - -#ifdef DOXYGEN_GENERATING_OUTPUT -/** -@debugoperatorclassenum{Composition,Composition::Type} - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration, or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. -*/ -template Debug& operator<<(Debug& debug, typename Composition::Type value); -#endif - -/** @relates Composition -@brief Collision occurence of shape with Composition - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. -*/ -#ifdef DOXYGEN_GENERATING_OUTPUT -template inline bool operator%(const T& a, const Composition& b) { -#else -template inline CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") auto operator%(const T& a, const Composition& b) -> typename std::enable_if::type()), typename Implementation::ShapeDimensionTraits::Type>::value, bool>::type { -#endif - return b % a; -} - -#ifdef DOXYGEN_GENERATING_OUTPUT -/** @relates Composition -@brief Logical NOT of shape - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. -*/ -template inline CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") Composition operator!(T a); - -/** @relates Composition -@brief Logical AND of two shapes - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. - -[Short-circuit evaluation](http://en.wikipedia.org/wiki/Short-circuit_evaluation) -is used here, so this operation can be used for providing simplified shape -version, because collision with @p b is computed only if @p a collides. -See @ref shapes-simplification for an example. -*/ -template inline CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") Composition operator&&(T a, T b); - -/** @relates Composition -@brief Logical OR of two shapes - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. - -[Short-circuit evaluation](http://en.wikipedia.org/wiki/Short-circuit_evaluation) -is used, so if collision with @p a is detected, collision with @p b is not -computed. -*/ -template inline CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") Composition operator||(T a, T b); -#endif - -#ifndef DOXYGEN_GENERATING_OUTPUT -#define enableIfIsShapeType typename std::enable_if< \ - std::is_same::type()), typename Implementation::ShapeDimensionTraits::Type>::value, \ - Composition>::type -#define enableIfAreShapeType typename std::enable_if< \ - std::is_same::type()), typename Implementation::ShapeDimensionTraits::Type>::value && \ - std::is_same::type()), typename Implementation::ShapeDimensionTraits::Type>::value, \ - Composition>::type -template inline CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") auto operator!(T&& a) -> enableIfIsShapeType { - return Composition(CompositionOperation::Not, std::forward(a)); -} -template inline CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") auto operator&&(T&& a, U&& b) -> enableIfAreShapeType { - return Composition(CompositionOperation::And, std::forward(a), std::forward(b)); -} -template inline CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") auto operator||(T&& a, U&& b) -> enableIfAreShapeType { - return Composition(CompositionOperation::Or, std::forward(a), std::forward(b)); -} -#undef enableIfIsShapeType -#undef enableIfAreShapeType -#endif - -template template Composition::Composition(CompositionOperation operation, T&& a): _shapes(shapeCount(a)), _nodes(nodeCount(a)+1) { - CORRADE_ASSERT(operation == CompositionOperation::Not, - "Shapes::Composition::Composition(): unary operation expected", ); - _nodes[0].operation = operation; - - /* 0 = no children, 1 = left child only */ - _nodes[0].rightNode = (nodeCount(a) == 0 ? 0 : 1); - _nodes[0].rightShape = shapeCount(a); - copyNodes(1, a); - copyShapes(0, std::forward(a)); -} - -template template Composition::Composition(CompositionOperation operation, T&& a, U&& b): _shapes(shapeCount(a) + shapeCount(b)), _nodes(nodeCount(a) + nodeCount(b) + 1) { - CORRADE_ASSERT(operation != CompositionOperation::Not, - "Shapes::Composition::Composition(): binary operation expected", ); - _nodes[0].operation = operation; - - /* 0 = no children, 1 = left child only, 2 = right child only, >2 = both */ - if(nodeCount(a) == 0 && nodeCount(b) == 0) - _nodes[0].rightNode = 0; - else if(nodeCount(b) == 0) - _nodes[0].rightNode = 1; - else _nodes[0].rightNode = nodeCount(a) + 2; - - _nodes[0].rightShape = shapeCount(a); - copyNodes(1, a); - copyNodes(nodeCount(a) + 1, b); - copyShapes(shapeCount(a), std::forward(b)); - copyShapes(0, std::forward(a)); -} - -template template inline const T& Composition::get(std::size_t i) const { - CORRADE_ASSERT(_shapes[i]->type() == Implementation::TypeOf::type(), - "Shapes::Composition::get(): given shape is not of type" << Implementation::TypeOf::type() << - "but" << _shapes[i]->type(), *static_cast(nullptr)); - return static_cast*>(_shapes[i])->shape; -} -CORRADE_IGNORE_DEPRECATED_POP - -}} - -#endif diff --git a/src/Magnum/Shapes/Cylinder.cpp b/src/Magnum/Shapes/Cylinder.cpp deleted file mode 100644 index a939c601a2..0000000000 --- a/src/Magnum/Shapes/Cylinder.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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. -*/ - -#define _MAGNUM_DO_NOT_WARN_DEPRECATED_SHAPES - -#include "Cylinder.h" - -#include "Magnum/Magnum.h" -#include "Magnum/Math/Distance.h" -#include "Magnum/Math/Functions.h" -#include "Magnum/Math/Matrix3.h" -#include "Magnum/Math/Matrix4.h" -#include "Magnum/Shapes/Point.h" -#include "Magnum/Shapes/Sphere.h" - -namespace Magnum { namespace Shapes { - -CORRADE_IGNORE_DEPRECATED_PUSH -template Cylinder Cylinder::transformed(const MatrixTypeFor& matrix) const { - return Cylinder(matrix.transformPoint(_a), matrix.transformPoint(_b), matrix.uniformScaling()*_radius); -} - -template bool Cylinder::operator%(const Point& other) const { - return Math::Distance::linePointSquared(_a, _b, other.position()) < - Math::pow<2>(_radius); -} - -template bool Cylinder::operator%(const Sphere& other) const { - return Math::Distance::linePointSquared(_a, _b, other.position()) < - Math::pow<2>(_radius+other.radius()); -} - -#ifndef DOXYGEN_GENERATING_OUTPUT -template class MAGNUM_SHAPES_EXPORT Cylinder<2>; -template class MAGNUM_SHAPES_EXPORT Cylinder<3>; -#endif -CORRADE_IGNORE_DEPRECATED_POP - -}} diff --git a/src/Magnum/Shapes/Cylinder.h b/src/Magnum/Shapes/Cylinder.h deleted file mode 100644 index 72b004a689..0000000000 --- a/src/Magnum/Shapes/Cylinder.h +++ /dev/null @@ -1,178 +0,0 @@ -#ifndef Magnum_Shapes_Cylinder_h -#define Magnum_Shapes_Cylinder_h -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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 Class @ref Magnum::Shapes::Cylinder, typedef @ref Magnum::Shapes::Cylinder2D, @ref Magnum::Shapes::Cylinder3D - -@deprecated The @ref Magnum::Shapes library is a failed design experiment and - is scheduled for removal in a future release. Related geometry algorithms - were moved to @ref Magnum::Math::Distance and @ref Magnum::Math::Intersection; - if you need a full-fledged physics library, please have look at - [Bullet](https://bulletphysics.org), which has Magnum integration in - @ref Magnum::BulletIntegration, or at [Box2D](https://box2d.org/), which - has a @ref examples-box2d "Magnum example" as well. -*/ - -#include "Magnum/DimensionTraits.h" -#include "Magnum/Math/Vector3.h" -#include "Magnum/Shapes/Shapes.h" -#include "Magnum/Shapes/visibility.h" - -/* File-level deprecation warning issued from Shapes.h */ - -namespace Magnum { namespace Shapes { - -CORRADE_IGNORE_DEPRECATED_PUSH -/** -@brief Infinite cylinder defined by line and radius - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration, or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. - -Unlike other elements the cylinder expects uniform scaling. See @ref shapes for -brief introduction. -@see @ref Cylinder2D, @ref Cylinder3D, @ref Capsule -@todo Store the radius as squared value to avoid sqrt/pow? Will complicate - collision detection with sphere. -*/ -template class CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") MAGNUM_SHAPES_EXPORT Cylinder { - public: - enum: UnsignedInt { - Dimensions = dimensions /**< Dimension count */ - }; - - /** - * @brief Constructor - * - * Creates zero-sized cylinder at origin. - */ - constexpr /*implicit*/ Cylinder(): _radius(0.0f) {} - - /** @brief Constructor */ - constexpr /*implicit*/ Cylinder(const VectorTypeFor& a, const VectorTypeFor& b, Float radius): _a(a), _b(b), _radius(radius) {} - - /** @brief Transformed shape */ - Cylinder transformed(const MatrixTypeFor& matrix) const; - - /** @brief First point */ - constexpr VectorTypeFor a() const { - return _a; - } - - /** @brief Set first point */ - void setA(const VectorTypeFor& a) { - _a = a; - } - - /** @brief Second point */ - constexpr VectorTypeFor b() const { - return _b; - } - - /** @brief Set second point */ - void setB(const VectorTypeFor& b) { - _b = b; - } - - /** @brief Radius */ - constexpr Float radius() const { return _radius; } - - /** @brief Set radius */ - void setRadius(Float radius) { _radius = radius; } - - /** @brief Collision occurence with point */ - bool operator%(const Point& other) const; - - /** @brief Collision occurence with sphere */ - bool operator%(const Sphere& other) const; - - private: - VectorTypeFor _a, _b; - Float _radius; -}; - -/** -@brief Infinite two-dimensional cylinder - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration, or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. -*/ -typedef CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") Cylinder<2> Cylinder2D; - -/** -@brief Infinite three-dimensional cylinder - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration, or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. -*/ -typedef CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") Cylinder<3> Cylinder3D; - -/** -@collisionoccurenceoperator{Point,Cylinder} - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration, or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. -*/ -template inline CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") bool operator%(const Point& a, const Cylinder& b) { return b % a; } - -/** -@collisionoccurenceoperator{Sphere,Cylinder} - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration, or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. -*/ -template inline CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") bool operator%(const Sphere& a, const Cylinder& b) { return b % a; } -CORRADE_IGNORE_DEPRECATED_POP - -}} - -#endif diff --git a/src/Magnum/Shapes/Implementation/CollisionDispatch.cpp b/src/Magnum/Shapes/Implementation/CollisionDispatch.cpp deleted file mode 100644 index 0bcede6a07..0000000000 --- a/src/Magnum/Shapes/Implementation/CollisionDispatch.cpp +++ /dev/null @@ -1,133 +0,0 @@ -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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. -*/ - -#define _MAGNUM_DO_NOT_WARN_DEPRECATED_SHAPES - -#include "CollisionDispatch.h" - -#include "Magnum/Shapes/AxisAlignedBox.h" -#include "Magnum/Shapes/Box.h" -#include "Magnum/Shapes/Capsule.h" -#include "Magnum/Shapes/Cylinder.h" -#include "Magnum/Shapes/LineSegment.h" -#include "Magnum/Shapes/Plane.h" -#include "Magnum/Shapes/Point.h" -#include "Magnum/Shapes/Sphere.h" -#include "Magnum/Shapes/shapeImplementation.h" - -namespace Magnum { namespace Shapes { namespace Implementation { - -CORRADE_IGNORE_DEPRECATED_PUSH -template<> bool collides(const AbstractShape<2>& a, const AbstractShape<2>& b) { - if(a.type() < b.type()) return collides(b, a); - - switch(UnsignedInt(a.type())*UnsignedInt(b.type())) { - #define _c(aType, aClass, bType, bClass) \ - case UnsignedInt(ShapeDimensionTraits<2>::Type::aType)*UnsignedInt(ShapeDimensionTraits<2>::Type::bType): \ - return static_cast&>(a).shape % static_cast&>(b).shape; - _c(Sphere, Sphere2D, Point, Point2D) - _c(Sphere, Sphere2D, Line, Line2D) - _c(Sphere, Sphere2D, LineSegment, LineSegment2D) - _c(Sphere, Sphere2D, Sphere, Sphere2D) - - _c(InvertedSphere, InvertedSphere2D, Point, Point2D) - _c(InvertedSphere, InvertedSphere2D, Sphere, Sphere2D) - - _c(Cylinder, Cylinder2D, Point, Point2D) - _c(Cylinder, Cylinder2D, Sphere, Sphere2D) - - _c(Capsule, Capsule2D, Point, Point2D) - _c(Capsule, Capsule2D, Sphere, Sphere2D) - - _c(AxisAlignedBox, AxisAlignedBox2D, Point, Point2D) - #undef _c - } - - return false; -} - -template<> Collision<2> collision(const AbstractShape<2>& a, const AbstractShape<2>& b) { - if(a.type() < b.type()) return collision(b, a); - - switch(UnsignedInt(a.type())*UnsignedInt(b.type())) { - #define _c(aType, aClass, bType, bClass) \ - case UnsignedInt(ShapeDimensionTraits<2>::Type::aType)*UnsignedInt(ShapeDimensionTraits<2>::Type::bType): \ - return static_cast&>(a).shape / static_cast&>(b).shape; - _c(Sphere, Sphere2D, Point, Point2D) - _c(Sphere, Sphere2D, Sphere, Sphere2D) - #undef _c - } - - return {}; -} - -template<> bool collides(const AbstractShape<3>& a, const AbstractShape<3>& b) { - if(a.type() < b.type()) return collides(b, a); - - switch(UnsignedInt(a.type())*UnsignedInt(b.type())) { - #define _c(aType, aClass, bType, bClass) \ - case UnsignedInt(ShapeDimensionTraits<3>::Type::aType)*UnsignedInt(ShapeDimensionTraits<3>::Type::bType): \ - return static_cast&>(a).shape % static_cast&>(b).shape; - _c(Sphere, Sphere3D, Point, Point3D) - _c(Sphere, Sphere3D, Line, Line3D) - _c(Sphere, Sphere3D, LineSegment, LineSegment3D) - _c(Sphere, Sphere3D, Sphere, Sphere3D) - - _c(InvertedSphere, InvertedSphere3D, Point, Point3D) - _c(InvertedSphere, InvertedSphere3D, Sphere, Sphere3D) - - _c(Cylinder, Cylinder3D, Point, Point3D) - _c(Cylinder, Cylinder3D, Sphere, Sphere3D) - - _c(Capsule, Capsule3D, Point, Point3D) - _c(Capsule, Capsule3D, Sphere, Sphere3D) - - _c(AxisAlignedBox, AxisAlignedBox3D, Point, Point3D) - - _c(Plane, Plane, Line, Line3D) - _c(Plane, Plane, LineSegment, LineSegment3D) - #undef _c - } - - return false; -} - -template<> Collision<3> collision(const AbstractShape<3>& a, const AbstractShape<3>& b) { - if(a.type() < b.type()) return collision(b, a); - - switch(UnsignedInt(a.type())*UnsignedInt(b.type())) { - #define _c(aType, aClass, bType, bClass) \ - case UnsignedInt(ShapeDimensionTraits<3>::Type::aType)*UnsignedInt(ShapeDimensionTraits<3>::Type::bType): \ - return static_cast&>(a).shape / static_cast&>(b).shape; - _c(Sphere, Sphere3D, Point, Point3D) - _c(Sphere, Sphere3D, Sphere, Sphere3D) - #undef _c - } - - return {}; -} -CORRADE_IGNORE_DEPRECATED_POP - -}}} diff --git a/src/Magnum/Shapes/Implementation/CollisionDispatch.h b/src/Magnum/Shapes/Implementation/CollisionDispatch.h deleted file mode 100644 index 34ed47a640..0000000000 --- a/src/Magnum/Shapes/Implementation/CollisionDispatch.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef Magnum_Shapes_Implementation_CollisionDispatch_h -#define Magnum_Shapes_Implementation_CollisionDispatch_h -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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 "Magnum/Types.h" -#include "Magnum/Shapes/Shapes.h" - -namespace Magnum { namespace Shapes { namespace Implementation { - -CORRADE_IGNORE_DEPRECATED_PUSH -template struct AbstractShape; - -/* -Shape collision double-dispatch: - -The collision is symmetric, i.e. it doesn't matter if we test Point vs. Sphere -or Sphere vs. Point. Each type is specified by unique prime number. Then we -multiply the two numbers together and switch() on the result. Because of -multiplying two prime numbers, there is no ambiguity (the result is unique for -each combination). -*/ - -template bool collides(const AbstractShape& a, const AbstractShape& b); - -template Collision collision(const AbstractShape& a, const AbstractShape& b); -CORRADE_IGNORE_DEPRECATED_POP - -}}} - -#endif diff --git a/src/Magnum/Shapes/Line.cpp b/src/Magnum/Shapes/Line.cpp deleted file mode 100644 index 5c2d65623a..0000000000 --- a/src/Magnum/Shapes/Line.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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. -*/ - -#define _MAGNUM_DO_NOT_WARN_DEPRECATED_SHAPES - -#include "Line.h" - -#include "Magnum/Math/Matrix3.h" -#include "Magnum/Math/Matrix4.h" - -namespace Magnum { namespace Shapes { - -CORRADE_IGNORE_DEPRECATED_PUSH -template Line Line::transformed(const MatrixTypeFor& matrix) const { - return Line(matrix.transformPoint(_a), - matrix.transformPoint(_b)); -} - -/* Explicitly instantiate the templates */ -#ifndef DOXYGEN_GENERATING_OUTPUT -template class MAGNUM_SHAPES_EXPORT Line<2>; -template class MAGNUM_SHAPES_EXPORT Line<3>; -#endif -CORRADE_IGNORE_DEPRECATED_POP - -}} diff --git a/src/Magnum/Shapes/Line.h b/src/Magnum/Shapes/Line.h deleted file mode 100644 index 2197931a19..0000000000 --- a/src/Magnum/Shapes/Line.h +++ /dev/null @@ -1,138 +0,0 @@ -#ifndef Magnum_Shapes_Line_h -#define Magnum_Shapes_Line_h -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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 Class @ref Magnum::Shapes::Line, typedef @ref Magnum::Shapes::Line2D, @ref Magnum::Shapes::Line3D - -@deprecated The @ref Magnum::Shapes library is a failed design experiment and - is scheduled for removal in a future release. Related geometry algorithms - were moved to @ref Magnum::Math::Distance and @ref Magnum::Math::Intersection; - if you need a full-fledged physics library, please have look at - [Bullet](https://bulletphysics.org), which has Magnum integration in - @ref Magnum::BulletIntegration, or at [Box2D](https://box2d.org/), which - has a @ref examples-box2d "Magnum example" as well. -*/ - -#include "Magnum/DimensionTraits.h" -#include "Magnum/Math/Vector3.h" -#include "Magnum/Shapes/Shapes.h" -#include "Magnum/Shapes/visibility.h" - -/* File-level deprecation warning issued from Shapes.h */ - -namespace Magnum { namespace Shapes { - -CORRADE_IGNORE_DEPRECATED_PUSH -/** -@brief Infinite line, defined by two points - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration, or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. - -See @ref shapes for brief introduction. -@see @ref Line2D, @ref Line3D -@todo collision detection of two Line2D -*/ -template class CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") MAGNUM_SHAPES_EXPORT Line { - public: - enum: UnsignedInt { - Dimensions = dimensions /**< Dimension count */ - }; - - /** - * @brief Default constructor - * - * Creates line with both points at origin. - */ - constexpr /*implicit*/ Line() {} - - /** @brief Constructor */ - constexpr /*implicit*/ Line(const VectorTypeFor& a, const typename DimensionTraits::VectorType& b): _a(a), _b(b) {} - - /** @brief Transformed shape */ - Line transformed(const MatrixTypeFor& matrix) const; - - /** @brief First point */ - constexpr VectorTypeFor a() const { - return _a; - } - - /** @brief Set first point */ - void setA(const VectorTypeFor& a) { - _a = a; - } - - /** @brief Second point */ - constexpr VectorTypeFor b() const { - return _b; - } - - /** @brief Set second point */ - void setB(const VectorTypeFor& b) { - _b = b; - } - - private: - VectorTypeFor _a, _b; -}; - -/** -@brief Infinite two-dimensional line - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration, or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. -*/ -typedef CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") Line<2> Line2D; - -/** -@brief Infinite three-dimensional line - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration, or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. -*/ - -typedef CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") Line<3> Line3D; -CORRADE_IGNORE_DEPRECATED_POP - -}} - -#endif diff --git a/src/Magnum/Shapes/LineSegment.h b/src/Magnum/Shapes/LineSegment.h deleted file mode 100644 index 1c2f63bcea..0000000000 --- a/src/Magnum/Shapes/LineSegment.h +++ /dev/null @@ -1,111 +0,0 @@ -#ifndef Magnum_Shapes_LineSegment_h -#define Magnum_Shapes_LineSegment_h -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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 Class @ref Magnum::Shapes::LineSegment, typedef @ref Magnum::Shapes::LineSegment2D, @ref Magnum::Shapes::LineSegment3D - -@deprecated The @ref Magnum::Shapes library is a failed design experiment and - is scheduled for removal in a future release. Related geometry algorithms - were moved to @ref Magnum::Math::Distance and @ref Magnum::Math::Intersection; - if you need a full-fledged physics library, please have look at - [Bullet](https://bulletphysics.org), which has Magnum integration in - @ref Magnum::BulletIntegration, or at [Box2D](https://box2d.org/), which - has a @ref examples-box2d "Magnum example" as well. -*/ - -#include "Magnum/Shapes/Line.h" - -/* File-level deprecation warning issued from Shapes.h */ - -namespace Magnum { namespace Shapes { - -CORRADE_IGNORE_DEPRECATED_PUSH -/** -@brief Line segment, defined by starting and ending point - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration, or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. - -See @ref shapes for brief introduction. -@see @ref LineSegment2D, @ref LineSegment3D -*/ -template class CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") LineSegment: public Line { - public: - /** - * @brief Default constructor - * - * Creates line segment with both points at origin. - */ - constexpr /*implicit*/ LineSegment() {} - - /** @brief Constructor */ - constexpr /*implicit*/ LineSegment(const VectorTypeFor& a, const VectorTypeFor& b): Line(a, b) {} - - /** @brief Transformed shape */ - LineSegment transformed(const MatrixTypeFor& matrix) const { - return Line::transformed(matrix); - } - - private: - constexpr LineSegment(const Line& line): Line(line) {} -}; - -/** -@brief Two-dimensional line segment - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration, or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. -*/ -typedef CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") LineSegment<2> LineSegment2D; - -/** -@brief Three-dimensional line segment - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration, or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. -*/ -typedef CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") LineSegment<3> LineSegment3D; -CORRADE_IGNORE_DEPRECATED_POP - -}} - -#endif diff --git a/src/Magnum/Shapes/Plane.cpp b/src/Magnum/Shapes/Plane.cpp deleted file mode 100644 index 738f368526..0000000000 --- a/src/Magnum/Shapes/Plane.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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. -*/ - -#define _MAGNUM_DO_NOT_WARN_DEPRECATED_SHAPES - -#include "Plane.h" - -#include "Magnum/Math/Intersection.h" -#include "Magnum/Math/Matrix4.h" -#include "Magnum/Shapes/LineSegment.h" - -namespace Magnum { namespace Shapes { - -CORRADE_IGNORE_DEPRECATED_PUSH -Plane Plane::transformed(const Matrix4& matrix) const { - /* Using matrix.rotation() would result in two more normalizations (slow), - using .normalized() instead of matrix.uniformScaling() would not check - uniform scaling */ - return Plane(matrix.transformPoint(_position), - matrix.rotationScaling()*_normal/matrix.uniformScaling()); -} - -bool Plane::operator%(const Line3D& other) const { - Float t = Math::Intersection::planeLine(Math::planeEquation(_normal, _position), other.a(), other.b()-other.a()); - return t != t || (t != Constants::inf() && t != -Constants::inf()); -} - -bool Plane::operator%(const LineSegment3D& other) const { - Float t = Math::Intersection::planeLine(Math::planeEquation(_normal, _position), other.a(), other.b()-other.a()); - return t > 0.0f && t < 1.0f; -} -CORRADE_IGNORE_DEPRECATED_POP - -}} diff --git a/src/Magnum/Shapes/Plane.h b/src/Magnum/Shapes/Plane.h deleted file mode 100644 index c849aa100e..0000000000 --- a/src/Magnum/Shapes/Plane.h +++ /dev/null @@ -1,142 +0,0 @@ -#ifndef Magnum_Shapes_Plane_h -#define Magnum_Shapes_Plane_h -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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 Class @ref Magnum::Shapes::Plane - -@deprecated The @ref Magnum::Shapes library is a failed design experiment and - is scheduled for removal in a future release. Related geometry algorithms - were moved to @ref Magnum::Math::Distance and @ref Magnum::Math::Intersection; - if you need a full-fledged physics library, please have look at - [Bullet](https://bulletphysics.org), which has Magnum integration in - @ref Magnum::BulletIntegration, or at [Box2D](https://box2d.org/), which - has a @ref examples-box2d "Magnum example" as well. -*/ - -#include "Magnum/Magnum.h" -#include "Magnum/Math/Vector3.h" -#include "Magnum/Shapes/Shapes.h" -#include "Magnum/Shapes/visibility.h" - -/* File-level deprecation warning issued from Shapes.h */ - -namespace Magnum { namespace Shapes { - -CORRADE_IGNORE_DEPRECATED_PUSH -/** -@brief Infinite plane, defined by position and normal (3D only) - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration, or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. - -Unlike other elements the plane expects uniform scaling. See @ref shapes for -brief introduction. -*/ -class CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") MAGNUM_SHAPES_EXPORT Plane { - public: - enum: UnsignedInt { - Dimensions = 3 /**< Dimension count */ - }; - - /** - * @brief Default constructor - * - * Creates plane with zero-sized normal at origin. - */ - constexpr /*implicit*/ Plane() {} - - /** @brief Constructor */ - constexpr /*implicit*/ Plane(const Vector3& position, const Vector3& normal): _position(position), _normal(normal) {} - - /** @brief Transformed shape */ - Plane transformed(const Matrix4& matrix) const; - - /** @brief Position */ - constexpr Vector3 position() const { return _position; } - - /** @brief Set position */ - void setPosition(const Vector3& position) { - _position = position; - } - - /** @brief Normal */ - constexpr Vector3 normal() const { return _normal; } - - /** @brief Set normal */ - void setNormal(const Vector3& normal) { - _normal = normal; - } - - /** @brief Collision occurence with line */ - bool operator%(const Line3D& other) const; - - /** @brief Collision occurence with line segment */ - bool operator%(const LineSegment3D& other) const; - - private: - Vector3 _position, _normal; -}; - -/** @relatesalso Line -@brief Collision occurence of @ref Line and @ref Plane - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration, or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. - -@see @ref Plane::operator%(const Line3D&) const -*/ -inline CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") bool operator%(const Line3D& a, const Plane& b) { return b % a; } - -/** @relatesalso LineSegment -@brief Collision occurence of @ref LineSegment and @ref Plane - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration, or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. - -@see @ref Plane::operator%(const LineSegment3D&) const -*/ -inline CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") bool operator%(const LineSegment3D& a, const Plane& b) { return b % a; } -CORRADE_IGNORE_DEPRECATED_POP - -}} - -#endif diff --git a/src/Magnum/Shapes/Point.cpp b/src/Magnum/Shapes/Point.cpp deleted file mode 100644 index f7c0dac859..0000000000 --- a/src/Magnum/Shapes/Point.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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. -*/ - -#define _MAGNUM_DO_NOT_WARN_DEPRECATED_SHAPES - -#include "Point.h" - -#include "Magnum/Math/Matrix3.h" -#include "Magnum/Math/Matrix4.h" - -namespace Magnum { namespace Shapes { - -CORRADE_IGNORE_DEPRECATED_PUSH -template Point Point::transformed(const MatrixTypeFor& matrix) const { - return Point(matrix.transformPoint(_position)); -} - -#ifndef DOXYGEN_GENERATING_OUTPUT -template class MAGNUM_SHAPES_EXPORT Point<2>; -template class MAGNUM_SHAPES_EXPORT Point<3>; -#endif -CORRADE_IGNORE_DEPRECATED_POP - -}} diff --git a/src/Magnum/Shapes/Point.h b/src/Magnum/Shapes/Point.h deleted file mode 100644 index e3308548a6..0000000000 --- a/src/Magnum/Shapes/Point.h +++ /dev/null @@ -1,126 +0,0 @@ -#ifndef Magnum_Shapes_Point_h -#define Magnum_Shapes_Point_h -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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 Class @ref Magnum::Shapes::Point, typedef @ref Magnum::Shapes::Point2D, @ref Magnum::Shapes::Point3D - -@deprecated The @ref Magnum::Shapes library is a failed design experiment and - is scheduled for removal in a future release. Related geometry algorithms - were moved to @ref Magnum::Math::Distance and @ref Magnum::Math::Intersection; - if you need a full-fledged physics library, please have look at - [Bullet](https://bulletphysics.org), which has Magnum integration in - @ref Magnum::BulletIntegration, or at [Box2D](https://box2d.org/), which - has a @ref examples-box2d "Magnum example" as well. -*/ - -#include "Magnum/DimensionTraits.h" -#include "Magnum/Math/Vector3.h" -#include "Magnum/Shapes/Shapes.h" -#include "Magnum/Shapes/visibility.h" - -/* File-level deprecation warning issued from Shapes.h */ - -namespace Magnum { namespace Shapes { - -CORRADE_IGNORE_DEPRECATED_PUSH -/** -@brief Point - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration, or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. - -See @ref shapes for brief introduction. -@see @ref Point2D, @ref Point3D -*/ -template class CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") MAGNUM_SHAPES_EXPORT Point { - public: - enum: UnsignedInt { - Dimensions = dimensions /**< Dimension count */ - }; - - /** - * @brief Default constructor - * - * Creates point at origin. - */ - constexpr /*implicit*/ Point() {} - - /** @brief Constructor */ - constexpr /*implicit*/ Point(const VectorTypeFor& position): _position(position) {} - - /** @brief Transformed shape */ - Point transformed(const MatrixTypeFor& matrix) const; - - /** @brief Position */ - constexpr VectorTypeFor position() const { - return _position; - } - - /** @brief Set position */ - void setPosition(const VectorTypeFor& position) { - _position = position; - } - - private: - VectorTypeFor _position; -}; - -/** -@brief Two-dimensional point - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration, or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. -*/ -typedef CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") Point<2> Point2D; - -/** -@brief Three-dimensional point - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration, or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. -*/ -typedef CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") Point<3> Point3D; -CORRADE_IGNORE_DEPRECATED_POP - -}} - -#endif diff --git a/src/Magnum/Shapes/Shape.cpp b/src/Magnum/Shapes/Shape.cpp deleted file mode 100644 index 1498114a51..0000000000 --- a/src/Magnum/Shapes/Shape.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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. -*/ - -#define _MAGNUM_DO_NOT_WARN_DEPRECATED_SHAPES - -#include "Shape.h" - -#include "Magnum/Shapes/Composition.h" - -namespace Magnum { namespace Shapes { namespace Implementation { - -CORRADE_IGNORE_DEPRECATED_PUSH -template void ShapeHelper>::set(Shapes::Shape>& shape, const Composition& composition) { - shape._transformedShape.shape = shape._shape.shape = composition; -} - -template void ShapeHelper>::set(Shapes::Shape>& shape, Composition&& composition) { - shape._transformedShape.shape = shape._shape.shape = std::move(composition); -} - -template void ShapeHelper>::transform(Shapes::Shape>& shape, const MatrixTypeFor& absoluteTransformationMatrix) { - CORRADE_INTERNAL_ASSERT(shape._shape.shape.size() == shape._transformedShape.shape.size()); - for(std::size_t i = 0; i != shape.shape().size(); ++i) - shape._shape.shape._shapes[i]->transform(absoluteTransformationMatrix, shape._transformedShape.shape._shapes[i]); -} - -template struct MAGNUM_SHAPES_EXPORT ShapeHelper>; -template struct MAGNUM_SHAPES_EXPORT ShapeHelper>; -CORRADE_IGNORE_DEPRECATED_POP - -}}} diff --git a/src/Magnum/Shapes/Shape.h b/src/Magnum/Shapes/Shape.h deleted file mode 100644 index dd4a6f0304..0000000000 --- a/src/Magnum/Shapes/Shape.h +++ /dev/null @@ -1,178 +0,0 @@ -#ifndef Magnum_Shapes_Shape_h -#define Magnum_Shapes_Shape_h -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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 Class @ref Magnum::Shapes::Shape - -@deprecated The @ref Magnum::Shapes library is a failed design experiment and - is scheduled for removal in a future release. Related geometry algorithms - were moved to @ref Magnum::Math::Distance and @ref Magnum::Math::Intersection; - if you need a full-fledged physics library, please have look at - [Bullet](https://bulletphysics.org), which has Magnum integration in - @ref Magnum::BulletIntegration, or at [Box2D](https://box2d.org/), which - has a @ref examples-box2d "Magnum example" as well. -*/ - -#include "Magnum/Shapes/AbstractShape.h" -#include "Magnum/Shapes/Shapes.h" -#include "Magnum/Shapes/visibility.h" - -/* File-level deprecation warning issued from Shapes.h */ - -namespace Magnum { namespace Shapes { - -CORRADE_IGNORE_DEPRECATED_PUSH -namespace Implementation { - template struct ShapeHelper; -} - -/** -@brief Object shape - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration, or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. - -Adds shape for collision detection to object. Each Shape is part of -some @ref ShapeGroup, which essentially maintains a set of objects which can -collide with each other. See @ref shapes for brief introduction. - -The shape contains original shape with relative transformation under -@ref shape() and also caches a shape with absolute transformation under -@ref transformedShape(), which can be used for collision detection. To -conveniently use collision detection among many objects, you need to add the -shape to @ref ShapeGroup, which then provides collision detection for given -group of shapes using either @ref collides(), @ref collision() or -@ref ShapeGroup::firstCollision(). You can also use @ref ShapeGroup::add() and -@ref ShapeGroup::remove() later to manage e.g. collision islands. - -@code{.cpp} -Shapes::ShapeGroup3D shapes; - -Object3D object; -auto shape = new Shapes::Shape(object, {{}, 0.75f}, &shapes); - -Shapes::AbstractShape3D* firstCollision = shapes.firstCollision(shape); -@endcode - -@see @ref scenegraph, @ref ShapeGroup2D, @ref ShapeGroup3D, - @ref DebugTools::ShapeRenderer -*/ -template class CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") Shape: public AbstractShape { - friend Implementation::ShapeHelper; - - public: - /** - * @brief Constructor - * @param object Object holding this feature - * @param shape Shape - * @param group Group this shape belongs to - */ - explicit Shape(SceneGraph::AbstractObject& object, const T& shape, ShapeGroup* group = nullptr): AbstractShape(object, group) { - Implementation::ShapeHelper::set(*this, shape); - } - - /** @overload */ - explicit Shape(SceneGraph::AbstractObject& object, T&& shape, ShapeGroup* group = nullptr): AbstractShape(object, group) { - Implementation::ShapeHelper::set(*this, std::move(shape)); - } - - /** @overload */ - explicit Shape(SceneGraph::AbstractObject& object, ShapeGroup* group = nullptr): AbstractShape(object, group) {} - - /** @brief Shape */ - const T& shape() const { return _shape.shape; } - - /** - * @brief Set shape - * @return Reference to self (for method chaining) - * - * Marks the feature as dirty. - */ - Shape& setShape(const T& shape); - - /** - * @brief Transformed shape - * - * Cleans the feature before returning the shape. - */ - const T& transformedShape(); - - protected: - /** Applies transformation to associated shape. */ - void clean(const MatrixTypeFor& absoluteTransformationMatrix) override; - - private: - const Implementation::AbstractShape& abstractTransformedShape() const override { - return _transformedShape; - } - - Implementation::Shape _shape, _transformedShape; -}; - -template inline Shape& Shape::setShape(const T& shape) { - Implementation::ShapeHelper::set(*this, shape); - this->object().setDirty(); - return *this; -} - -template inline const T& Shape::transformedShape() { - this->object().setClean(); - return _transformedShape.shape; -} - -template void Shape::clean(const MatrixTypeFor& absoluteTransformationMatrix) { - Implementation::ShapeHelper::transform(*this, absoluteTransformationMatrix); -} - -namespace Implementation { - template struct ShapeHelper { - static void set(Shapes::Shape& shape, const T& s) { - shape._shape.shape = s; - } - - static void transform(Shapes::Shape& shape, const MatrixTypeFor& absoluteTransformationMatrix) { - shape._transformedShape.shape = shape._shape.shape.transformed(absoluteTransformationMatrix); - } - }; - - template struct MAGNUM_SHAPES_EXPORT ShapeHelper> { - static void set(Shapes::Shape>& shape, const Composition& composition); - static void set(Shapes::Shape>& shape, Composition&& composition); - - static void transform(Shapes::Shape>& shape, const MatrixTypeFor& absoluteTransformationMatrix); - }; -} -CORRADE_IGNORE_DEPRECATED_POP - -}} - -#endif diff --git a/src/Magnum/Shapes/ShapeGroup.cpp b/src/Magnum/Shapes/ShapeGroup.cpp deleted file mode 100644 index a317e2c691..0000000000 --- a/src/Magnum/Shapes/ShapeGroup.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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. -*/ - -#define _MAGNUM_DO_NOT_WARN_DEPRECATED_SHAPES - -#include "ShapeGroup.h" - -#include "Magnum/Shapes/AbstractShape.h" - -namespace Magnum { namespace Shapes { - -CORRADE_IGNORE_DEPRECATED_PUSH -template void ShapeGroup::setClean() { - /* Clean all objects */ - if(!this->isEmpty()) { - std::vector>> objects; - objects.reserve(this->size()); - for(std::size_t i = 0; i != this->size(); ++i) - objects.push_back((*this)[i].object()); - - SceneGraph::AbstractObject::setClean(objects); - } - - dirty = false; -} - -template AbstractShape* ShapeGroup::firstCollision(const AbstractShape& shape) { - setClean(); - for(std::size_t i = 0; i != this->size(); ++i) - if(&(*this)[i] != &shape && (*this)[i].collides(shape)) - return &(*this)[i]; - - return nullptr; -} - -#ifndef DOXYGEN_GENERATING_OUTPUT -template class MAGNUM_SHAPES_EXPORT ShapeGroup<2>; -template class MAGNUM_SHAPES_EXPORT ShapeGroup<3>; -#endif -CORRADE_IGNORE_DEPRECATED_POP - -}} diff --git a/src/Magnum/Shapes/ShapeGroup.h b/src/Magnum/Shapes/ShapeGroup.h deleted file mode 100644 index 760c7e0e33..0000000000 --- a/src/Magnum/Shapes/ShapeGroup.h +++ /dev/null @@ -1,148 +0,0 @@ -#ifndef Magnum_Shapes_ShapeGroup_h -#define Magnum_Shapes_ShapeGroup_h -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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 Class @ref Magnum::Shapes::ShapeGroup, typedef @ref Magnum::Shapes::ShapeGroup2D, @ref Magnum::Shapes::ShapeGroup3D - -@deprecated The @ref Magnum::Shapes library is a failed design experiment and - is scheduled for removal in a future release. Related geometry algorithms - were moved to @ref Magnum::Math::Distance and @ref Magnum::Math::Intersection; - if you need a full-fledged physics library, please have look at - [Bullet](https://bulletphysics.org), which has Magnum integration in - @ref Magnum::BulletIntegration, or at [Box2D](https://box2d.org/), which - has a @ref examples-box2d "Magnum example" as well. -*/ - -#include - -#include "Magnum/SceneGraph/FeatureGroup.h" -#include "Magnum/Shapes/AbstractShape.h" -#include "Magnum/Shapes/visibility.h" - -/* File-level deprecation warning issued from Shapes.h */ - -namespace Magnum { namespace Shapes { - -CORRADE_IGNORE_DEPRECATED_PUSH -/** -@brief Group of shapes - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration, or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. - -See @ref Shape for more information. See @ref shapes for brief introduction. -@see @ref scenegraph, @ref ShapeGroup2D, @ref ShapeGroup3D -*/ -template class CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") MAGNUM_SHAPES_EXPORT ShapeGroup: public SceneGraph::FeatureGroup, Float> { - friend AbstractShape; - - public: - /** - * @brief Constructor - * - * Marks the group as dirty. - */ - explicit ShapeGroup(): dirty(true) {} - - /** - * @brief Whether the group is dirty - * @return True if any object in the group is dirty, false otherwise. - */ - bool isDirty() const { return dirty; } - - /** - * @brief Set the group as dirty - * - * If some body in the group changes its transformation, it sets dirty - * status also on the group to indicate that the body and maybe also - * group state needs to be cleaned before computing collisions. - * @see @ref setClean() - */ - void setDirty() { dirty = true; } - - /** - * @brief Set the group and all bodies as clean - * - * This function is called before computing any collisions to ensure - * all objects are cleaned. - */ - void setClean(); - - /** - * @brief First collision of given shape with other shapes in the group - * - * Returns first shape colliding with given one. If there aren't any - * collisions, returns @cpp nullptr @ce. Calls @ref setClean() before - * the operation. - */ - AbstractShape* firstCollision(const AbstractShape& shape); - - private: - bool dirty; -}; - -/** -@brief Group of two-dimensional shapes - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration, or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. - -See @ref Shape for more information. -@see @ref ShapeGroup3D -*/ -typedef CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") ShapeGroup<2> ShapeGroup2D; - -/** -@brief Group of three-dimensional shapes - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration, or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. - -See @ref Shape for more information. -@see @ref ShapeGroup2D -*/ -typedef CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") ShapeGroup<3> ShapeGroup3D; -CORRADE_IGNORE_DEPRECATED_POP - -}} - -#endif diff --git a/src/Magnum/Shapes/Shapes.h b/src/Magnum/Shapes/Shapes.h deleted file mode 100644 index f426422ead..0000000000 --- a/src/Magnum/Shapes/Shapes.h +++ /dev/null @@ -1,117 +0,0 @@ -#ifndef Magnum_Shapes_Shapes_h -#define Magnum_Shapes_Shapes_h -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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::Shapes namespace - -@deprecated The @ref Magnum::Shapes library is a failed design experiment and - is scheduled for removal in a future release. Related geometry algorithms - were moved to @ref Magnum::Math::Distance and @ref Magnum::Math::Intersection; - if you need a full-fledged physics library, please have look at - [Bullet](https://bulletphysics.org), which has Magnum integration in - @ref Magnum::BulletIntegration, or at [Box2D](https://box2d.org/), which - has a @ref examples-box2d "Magnum example" as well. -*/ - -#include - -#include "Magnum/Types.h" - -#ifndef MAGNUM_BUILD_DEPRECATED -#error the Shapes library is scheduled for removal, see the docs for alternatives -#endif - -/* I still have a test for this class and it shouldn't pollute the log there */ -#ifndef _MAGNUM_DO_NOT_WARN_DEPRECATED_SHAPES -CORRADE_DEPRECATED_FILE("the Shapes library is scheduled for removal, see the docs for alternatives") -#endif - -namespace Magnum { namespace CORRADE_DEPRECATED_NAMESPACE("scheduled for removal, see the docs for alternatives") Shapes { - -CORRADE_IGNORE_DEPRECATED_PUSH -#ifndef DOXYGEN_GENERATING_OUTPUT -template class CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") AbstractShape; -typedef AbstractShape<2> CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") AbstractShape2D; -typedef AbstractShape<3> CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") AbstractShape3D; - -template class CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") AxisAlignedBox; -typedef AxisAlignedBox<2> CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") AxisAlignedBox2D; -typedef AxisAlignedBox<3> CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") AxisAlignedBox3D; - -template class CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") Box; -typedef CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") Box<2> Box2D; -typedef CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") Box<3> Box3D; - -template class CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") Capsule; -typedef CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") Capsule<2> Capsule2D; -typedef CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") Capsule<3> Capsule3D; - -template class CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") Collision; -typedef CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") Collision<2> Collision2D; -typedef CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") Collision<3> Collision3D; - -template class CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") Composition; -typedef CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") Composition<2> Composition2D; -typedef CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") Composition<3> Composition3D; - -template class CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") Cylinder; -typedef CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") Cylinder<2> Cylinder2D; -typedef CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") Cylinder<3> Cylinder3D; - -template class CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") Line; -typedef CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") Line<2> Line2D; -typedef CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") Line<3> Line3D; - -template class CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") LineSegment; -typedef CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") LineSegment<2> LineSegment2D; -typedef CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") LineSegment<3> LineSegment3D; - -template class CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") Shape; - -template class CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") ShapeGroup; -typedef CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") ShapeGroup<2> ShapeGroup2D; -typedef CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") ShapeGroup<3> ShapeGroup3D; - -template class CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") Sphere; -typedef CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") Sphere<2> Sphere2D; -typedef CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") Sphere<3> Sphere3D; - -template class CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") InvertedSphere; -typedef CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") InvertedSphere<2> InvertedSphere2D; -typedef CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") InvertedSphere<3> InvertedSphere3D; - -class CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") Plane; - -template class CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") Point; -typedef CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") Point<2> Point2D; -typedef CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") Point<3> Point3D; -#endif -CORRADE_IGNORE_DEPRECATED_POP - -}} - -#endif diff --git a/src/Magnum/Shapes/Sphere.cpp b/src/Magnum/Shapes/Sphere.cpp deleted file mode 100644 index 4ae640ab80..0000000000 --- a/src/Magnum/Shapes/Sphere.cpp +++ /dev/null @@ -1,157 +0,0 @@ -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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. -*/ - -#define _MAGNUM_DO_NOT_WARN_DEPRECATED_SHAPES - -#include "Sphere.h" - -#include "Magnum/Magnum.h" -#include "Magnum/Math/Distance.h" -#include "Magnum/Math/Functions.h" -#include "Magnum/Math/Matrix3.h" -#include "Magnum/Math/Matrix4.h" -#include "Magnum/Shapes/LineSegment.h" -#include "Magnum/Shapes/Point.h" - -namespace Magnum { namespace Shapes { - -CORRADE_IGNORE_DEPRECATED_PUSH -template Sphere Sphere::transformed(const MatrixTypeFor& matrix) const { - return Sphere(matrix.transformPoint(_position), matrix.uniformScaling()*_radius); -} - -template bool Sphere::operator%(const Point& other) const { - return (_position - other.position()).dot() < Math::pow<2>(_radius); -} - -template bool InvertedSphere::operator%(const Point& other) const { - return (other.position() - position()).dot() > Math::pow<2>(radius()); -} - -template Collision Sphere::operator/(const Point& other) const { - const VectorTypeFor separating = _position - other.position(); - const Float dot = separating.dot(); - - /* No collision occured */ - if(dot > Math::pow<2>(_radius)) return {}; - - /* Actual distance from the center */ - const Float distance = Math::sqrt(dot); - - /* Separating normal. If can't decide on direction, just move up. */ - /** @todo How to handle this in a configurable way? */ - const VectorTypeFor separatingNormal = - Math::TypeTraits::equals(dot, 0.0f) ? - VectorTypeFor::yAxis() : - separating/distance; - - /* Collision position is on the point */ - return Collision(other.position(), separatingNormal, _radius - distance); -} - -template Collision InvertedSphere::operator/(const Point& other) const { - const VectorTypeFor separating = other.position() - position(); - const Float dot = separating.dot(); - - /* No collision occured */ - if(dot < Math::pow<2>(radius())) return {}; - - /* Actual distance from the center */ - const Float distance = Math::sqrt(dot); - - /* Separating normal */ - const VectorTypeFor separatingNormal = separating/distance; - - /* Collision position is on the point */ - return Collision(other.position(), separatingNormal, distance - radius()); -} - -template bool Sphere::operator%(const Line& other) const { - return Math::Distance::linePointSquared(other.a(), other.b(), _position) < Math::pow<2>(_radius); -} - -template bool Sphere::operator%(const LineSegment& other) const { - return Math::Distance::lineSegmentPointSquared(other.a(), other.b(), _position) < Math::pow<2>(_radius); -} - -template bool Sphere::operator%(const Sphere& other) const { - return (_position - other._position).dot() < Math::pow<2>(_radius + other._radius); -} - -template bool InvertedSphere::operator%(const Sphere& other) const { - return (position() - other.position()).dot() > Math::pow<2>(radius() - other.radius()); -} - -template Collision Sphere::operator/(const Sphere& other) const { - const Float minDistance = _radius + other._radius; - const VectorTypeFor separating = _position - other._position; - const Float dot = separating.dot(); - - /* No collision occured */ - if(dot > Math::pow<2>(minDistance)) return {}; - - /* Actual distance */ - const Float distance = Math::sqrt(dot); - - /* Separating normal. If can't decide on direction, just move up. */ - /** @todo How to handle this in a configurable way? */ - const VectorTypeFor separatingNormal = - Math::TypeTraits::equals(dot, 0.0f) ? - VectorTypeFor::yAxis() : - separating/distance; - - /* Contact position is on the surface of `other`, minDistace > distance */ - return Collision(other._position + separatingNormal*other._radius, separatingNormal, minDistance - distance); -} - -template Collision InvertedSphere::operator/(const Sphere& other) const { - const Float maxDistance = radius() - other.radius(); - /** @todo How to handle inseparable shapes or shapes which can't be separated by movement only (i.e. two half-spaces)? */ - CORRADE_INTERNAL_ASSERT(maxDistance > 0.0f); - const VectorTypeFor separating = other.position() - position(); - const Float dot = separating.dot(); - - /* No collision occured */ - if(dot < Math::pow<2>(maxDistance)) return {}; - - /* Actual distance */ - const Float distance = Math::sqrt(dot); - - /* Separating normal */ - const VectorTypeFor separatingNormal = separating/distance; - - /* Contact position is on the surface of `other`, distance > maxDistance */ - return Collision(other.position() + separatingNormal*other.radius(), separatingNormal, distance - maxDistance); -} - -#ifndef DOXYGEN_GENERATING_OUTPUT -template class MAGNUM_SHAPES_EXPORT Sphere<2>; -template class MAGNUM_SHAPES_EXPORT Sphere<3>; -template class MAGNUM_SHAPES_EXPORT InvertedSphere<2>; -template class MAGNUM_SHAPES_EXPORT InvertedSphere<3>; -#endif -CORRADE_IGNORE_DEPRECATED_POP - -}} diff --git a/src/Magnum/Shapes/Sphere.h b/src/Magnum/Shapes/Sphere.h deleted file mode 100644 index 89b07d73d0..0000000000 --- a/src/Magnum/Shapes/Sphere.h +++ /dev/null @@ -1,346 +0,0 @@ -#ifndef Magnum_Shapes_Sphere_h -#define Magnum_Shapes_Sphere_h -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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 Class @ref Magnum::Shapes::Sphere, typedef @ref Magnum::Shapes::Sphere2D, @ref Magnum::Shapes::Sphere3D - -@deprecated The @ref Magnum::Shapes library is a failed design experiment and - is scheduled for removal in a future release. Related geometry algorithms - were moved to @ref Magnum::Math::Distance and @ref Magnum::Math::Intersection; - if you need a full-fledged physics library, please have look at - [Bullet](https://bulletphysics.org), which has Magnum integration in - @ref Magnum::BulletIntegration, or at [Box2D](https://box2d.org/), which - has a @ref examples-box2d "Magnum example" as well. -*/ - -#include "Magnum/DimensionTraits.h" -#include "Magnum/Math/Vector3.h" -#include "Magnum/Shapes/Shapes.h" -#include "Magnum/Shapes/Collision.h" -#include "Magnum/Shapes/visibility.h" - -/* File-level deprecation warning issued from Shapes.h */ - -namespace Magnum { namespace Shapes { - -CORRADE_IGNORE_DEPRECATED_PUSH -/** -@brief Sphere defined by position and radius - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration, or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. - -Unlike other elements the sphere expects uniform scaling. See @ref shapes for -brief introduction. -@see @ref Sphere2D, @ref Sphere3D -@todo Store the radius as squared value to avoid sqrt/pow? Will complicate - collision detection with another sphere. -*/ -template class CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") MAGNUM_SHAPES_EXPORT Sphere { - public: - enum: UnsignedInt { - Dimensions = dimensions /**< Dimension count */ - }; - - /** - * @brief Default constructor - * - * Creates zero-sized sphere at origin. - */ - constexpr /*implicit*/ Sphere(): _radius(0.0f) {} - - /** @brief Constructor */ - constexpr /*implicit*/ Sphere(const VectorTypeFor& position, Float radius): _position(position), _radius(radius) {} - - /** @brief Transformed shape */ - Sphere transformed(const MatrixTypeFor& matrix) const; - - /** @brief Position */ - constexpr VectorTypeFor position() const { - return _position; - } - - /** @brief Set position */ - void setPosition(const VectorTypeFor& position) { - _position = position; - } - - /** @brief Radius */ - constexpr Float radius() const { return _radius; } - - /** @brief Set radius */ - void setRadius(Float radius) { _radius = radius; } - - /** @brief Collision occurence with point */ - bool operator%(const Point& other) const; - - /** @brief Collision with point */ - Collision operator/(const Point& other) const; - - /** @brief Collision occurence with line */ - bool operator%(const Line& other) const; - - /** @brief Collision occurence with line segment */ - bool operator%(const LineSegment& other) const; - - /** @brief Collision occurence with sphere */ - bool operator%(const Sphere& other) const; - - /** @brief Collision with sphere */ - Collision operator/(const Sphere& other) const; - - private: - VectorTypeFor _position; - Float _radius; -}; - -/** -@brief Two-dimensional sphere - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration, or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. -*/ -typedef CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") Sphere<2> Sphere2D; - -/** -@brief Three-dimensional sphere - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration, or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. -*/ -typedef CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") Sphere<3> Sphere3D; - -/** -@brief Inverted sphere defined by position and radius - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration, or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. - -Inverted version of @ref Sphere, detecting collisions on the outside, not on -the inside. See @ref shapes for brief introduction. -@see @ref InvertedSphere2D, @ref InvertedSphere3D -*/ -template class CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") MAGNUM_SHAPES_EXPORT InvertedSphere: - #ifdef DOXYGEN_GENERATING_OUTPUT - public Sphere - #else - private Sphere - #endif -{ - public: - /** - * @brief Default constructor - * - * Creates zero-sized sphere at origin. - */ - constexpr /*implicit*/ InvertedSphere() = default; - - /** @brief Constructor */ - constexpr /*implicit*/ InvertedSphere(const VectorTypeFor& position, Float radius): Sphere(position, radius) {} - - using Sphere::Dimensions; - - /** @brief Transformed shape */ - InvertedSphere transformed(const MatrixTypeFor& matrix) const { - return Sphere::transformed(matrix); - } - - using Sphere::position; - using Sphere::setPosition; - using Sphere::radius; - using Sphere::setRadius; - - /** @brief Collision occurence with point */ - bool operator%(const Point& other) const; - - /** @brief Collision with point */ - Collision operator/(const Point& other) const; - - /** @brief Collision occurence with sphere */ - bool operator%(const Sphere& other) const; - - /** @brief Collision with sphere */ - Collision operator/(const Sphere& other) const; - - private: - constexpr /*implicit*/ InvertedSphere(const Sphere& other): Sphere(other) {} -}; - -/** -@brief Inverted two-dimensional sphere - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration, or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. -*/ -typedef CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") InvertedSphere<2> InvertedSphere2D; - -/** -@brief Inverted three-dimensional sphere - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration, or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. -*/ -typedef CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") InvertedSphere<3> InvertedSphere3D; - -/** -@collisionoccurenceoperator{Point,Sphere} - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration, or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. -*/ -template inline CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") bool operator%(const Point& a, const Sphere& b) { return b % a; } - -/** -@collisionoccurenceoperator{Point,InvertedSphere} - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration, or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. -*/ -template inline CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") bool operator%(const Point& a, const InvertedSphere& b) { return b % a; } - -/** -@collisionoperator{Point,Sphere} - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration, or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. -*/ -template inline CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") Collision operator/(const Point& a, const Sphere& b) { return (b/a).flipped(); } - -/** -@collisionoperator{Point,InvertedSphere} - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration, or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. -*/ -template inline CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") Collision operator/(const Point& a, const InvertedSphere& b) { return (b/a).flipped(); } - -/** -@collisionoccurenceoperator{Line,Sphere} - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration, or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. -*/ -template inline CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") bool operator%(const Line& a, const Sphere& b) { return b % a; } - -/** -@collisionoccurenceoperator{LineSegment,Sphere} - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration, or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. -*/ -template inline CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") bool operator%(const LineSegment& a, const Sphere& b) { return b % a; } - -/** -@collisionoccurenceoperator{Sphere,InvertedSphere} - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration, or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. -*/ -template inline CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") bool operator%(const Sphere& a, const InvertedSphere& b) { return b % a; } - -/** -@collisionoperator{Sphere,InvertedSphere} - -@deprecated The @ref Shapes library is a failed design experiment and is - scheduled for removal in a future release. Related geometry algorithms were - moved to @ref Math::Distance and @ref Math::Intersection; if you need a - full-fledged physics library, please have look at [Bullet](https://bulletphysics.org), - which has Magnum integration in @ref BulletIntegration, or at - [Box2D](https://box2d.org/), which has a @ref examples-box2d "Magnum example" - as well. -*/ -template inline CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") Collision operator/(const Sphere& a, const InvertedSphere& b) { return (b/a).flipped(); } -CORRADE_IGNORE_DEPRECATED_POP - -}} - -#endif diff --git a/src/Magnum/Shapes/Test/AxisAlignedBoxTest.cpp b/src/Magnum/Shapes/Test/AxisAlignedBoxTest.cpp deleted file mode 100644 index 3a0a73579c..0000000000 --- a/src/Magnum/Shapes/Test/AxisAlignedBoxTest.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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. -*/ - -#define _MAGNUM_DO_NOT_WARN_DEPRECATED_SHAPES - -#include "Magnum/Math/Matrix4.h" -#include "Magnum/Magnum.h" -#include "Magnum/Shapes/AxisAlignedBox.h" -#include "Magnum/Shapes/Point.h" - -#include "ShapeTestBase.h" - -namespace Magnum { namespace Shapes { namespace Test { namespace { - -struct AxisAlignedBoxTest: TestSuite::Tester { - explicit AxisAlignedBoxTest(); - - void transformed(); - void collisionPoint(); -}; - -AxisAlignedBoxTest::AxisAlignedBoxTest() { - addTests({&AxisAlignedBoxTest::transformed, - &AxisAlignedBoxTest::collisionPoint}); -} - -CORRADE_IGNORE_DEPRECATED_PUSH -void AxisAlignedBoxTest::transformed() { - const auto box = Shapes::AxisAlignedBox3D({-1.0f, -2.0f, -3.0f}, {1.0f, 2.0f, 3.0f}) - .transformed(Matrix4::translation(Vector3(1.0f))*Matrix4::scaling({2.0f, -1.0f, 1.5f})); - CORRADE_COMPARE(box.min(), Vector3(-1.0f, 3.0f, -3.5f)); - CORRADE_COMPARE(box.max(), Vector3(3.0f, -1.0f, 5.5f)); -} - -void AxisAlignedBoxTest::collisionPoint() { - Shapes::AxisAlignedBox3D box({-1.0f, -2.0f, -3.0f}, {1.0f, 2.0f, 3.0f}); - Shapes::Point3D point1({-1.5f, -1.0f, 2.0f}); - Shapes::Point3D point2({0.5f, 1.0f, -2.5f}); - - VERIFY_NOT_COLLIDES(box, point1); - VERIFY_COLLIDES(box, point2); -} -CORRADE_IGNORE_DEPRECATED_POP - -}}}} - -CORRADE_TEST_MAIN(Magnum::Shapes::Test::AxisAlignedBoxTest) diff --git a/src/Magnum/Shapes/Test/BoxTest.cpp b/src/Magnum/Shapes/Test/BoxTest.cpp deleted file mode 100644 index 0c743c36c7..0000000000 --- a/src/Magnum/Shapes/Test/BoxTest.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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 - -#define _MAGNUM_DO_NOT_WARN_DEPRECATED_SHAPES - -#include "Magnum/Magnum.h" -#include "Magnum/Math/Matrix4.h" -#include "Magnum/Shapes/Box.h" - -namespace Magnum { namespace Shapes { namespace Test { namespace { - -struct BoxTest: TestSuite::Tester { - explicit BoxTest(); - - void transformed(); -}; - -BoxTest::BoxTest() { - addTests({&BoxTest::transformed}); -} - -CORRADE_IGNORE_DEPRECATED_PUSH -void BoxTest::transformed() { - const auto box = Shapes::Box3D(Matrix4::translation({1.0f, 2.0f, -3.0f})) - .transformed(Matrix4::scaling({2.0f, -1.0f, 1.5f})); - CORRADE_COMPARE(box.transformation(), Matrix4::scaling({2.0f, -1.0f, 1.5f})*Matrix4::translation({1.0f, 2.0f, -3.0f})); -} -CORRADE_IGNORE_DEPRECATED_POP - -}}}} - -CORRADE_TEST_MAIN(Magnum::Shapes::Test::BoxTest) diff --git a/src/Magnum/Shapes/Test/CMakeLists.txt b/src/Magnum/Shapes/Test/CMakeLists.txt deleted file mode 100644 index ece3853579..0000000000 --- a/src/Magnum/Shapes/Test/CMakeLists.txt +++ /dev/null @@ -1,53 +0,0 @@ -# -# This file is part of Magnum. -# -# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 -# 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. -# - -corrade_add_test(ShapesShapeImplementationTest ShapeImplementationTest.cpp LIBRARIES MagnumShapes) -corrade_add_test(ShapesAxisAlignedBoxTest AxisAlignedBoxTest.cpp LIBRARIES MagnumShapes) -corrade_add_test(ShapesBoxTest BoxTest.cpp LIBRARIES MagnumShapes) -corrade_add_test(ShapesCapsuleTest CapsuleTest.cpp LIBRARIES MagnumShapes) -corrade_add_test(ShapesCollisionTest CollisionTest.cpp LIBRARIES MagnumShapes) -corrade_add_test(ShapesCylinderTest CylinderTest.cpp LIBRARIES MagnumShapes) -corrade_add_test(ShapesLineTest LineTest.cpp LIBRARIES MagnumShapes) -corrade_add_test(ShapesPlaneTest PlaneTest.cpp LIBRARIES MagnumShapes) -corrade_add_test(ShapesPointTest PointTest.cpp LIBRARIES MagnumShapes) -corrade_add_test(ShapesCompositionTest CompositionTest.cpp LIBRARIES MagnumShapes) -corrade_add_test(ShapesSphereTest SphereTest.cpp LIBRARIES MagnumShapes) - -corrade_add_test(ShapesShapeTest ShapeTest.cpp LIBRARIES MagnumShapes) - -set_target_properties( - ShapesShapeImplementationTest - ShapesAxisAlignedBoxTest - ShapesBoxTest - ShapesCapsuleTest - ShapesCollisionTest - ShapesCylinderTest - ShapesLineTest - ShapesPlaneTest - ShapesPointTest - ShapesCompositionTest - ShapesSphereTest - ShapesShapeTest - PROPERTIES FOLDER "Magnum/Shapes/Test") diff --git a/src/Magnum/Shapes/Test/CapsuleTest.cpp b/src/Magnum/Shapes/Test/CapsuleTest.cpp deleted file mode 100644 index b873bf5975..0000000000 --- a/src/Magnum/Shapes/Test/CapsuleTest.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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. -*/ - -#define _MAGNUM_DO_NOT_WARN_DEPRECATED_SHAPES - -#include "Magnum/Magnum.h" -#include "Magnum/Math/Matrix3.h" -#include "Magnum/Math/Matrix4.h" -#include "Magnum/Shapes/Capsule.h" -#include "Magnum/Shapes/Point.h" -#include "Magnum/Shapes/Sphere.h" - -#include "ShapeTestBase.h" - -namespace Magnum { namespace Shapes { namespace Test { namespace { - -struct CapsuleTest: TestSuite::Tester { - explicit CapsuleTest(); - - void transformed(); - void collisionPoint(); - void collisionSphere(); -}; - -CapsuleTest::CapsuleTest() { - addTests({&CapsuleTest::transformed, - &CapsuleTest::collisionPoint, - &CapsuleTest::collisionSphere}); -} - -CORRADE_IGNORE_DEPRECATED_PUSH -void CapsuleTest::transformed() { - const Shapes::Capsule3D capsule({1.0f, 2.0f, 3.0f}, {-1.0f, -2.0f, -3.0f}, 7.0f); - - const auto transformed = capsule.transformed(Matrix4::scaling(Vector3(2.0f))*Matrix4::rotation(Deg(90.0f), Vector3::zAxis())); - CORRADE_COMPARE(transformed.a(), Vector3(-4.0f, 2.0f, 6.0f)); - CORRADE_COMPARE(transformed.b(), Vector3(4.0f, -2.0f, -6.0f)); - CORRADE_COMPARE(transformed.radius(), 14.0f); -} - -void CapsuleTest::collisionPoint() { - Shapes::Capsule3D capsule({-1.0f, -1.0f, 0.0f}, {1.0f, 1.0f, 0.0f}, 2.0f); - Shapes::Point3D point({2.0f, 0.0f, 0.0f}); - Shapes::Point3D point1({2.9f, 1.0f, 0.0f}); - Shapes::Point3D point2({1.0f, 3.1f, 0.0f}); - - VERIFY_COLLIDES(capsule, point); - VERIFY_COLLIDES(capsule, point1); - VERIFY_NOT_COLLIDES(capsule, point2); -} - -void CapsuleTest::collisionSphere() { - Shapes::Capsule3D capsule({-1.0f, -1.0f, 0.0f}, {1.0f, 1.0f, 0.0f}, 2.0f); - Shapes::Sphere3D sphere({3.0f, 0.0f, 0.0f}, 0.9f); - Shapes::Sphere3D sphere1({3.5f, 1.0f, 0.0f}, 0.6f); - Shapes::Sphere3D sphere2({1.0f, 4.1f, 0.0f}, 1.0f); - - VERIFY_COLLIDES(capsule, sphere); - VERIFY_COLLIDES(capsule, sphere1); - VERIFY_NOT_COLLIDES(capsule, sphere2); -} -CORRADE_IGNORE_DEPRECATED_POP - -}}}} - -CORRADE_TEST_MAIN(Magnum::Shapes::Test::CapsuleTest) diff --git a/src/Magnum/Shapes/Test/CollisionTest.cpp b/src/Magnum/Shapes/Test/CollisionTest.cpp deleted file mode 100644 index 19c2e7eaca..0000000000 --- a/src/Magnum/Shapes/Test/CollisionTest.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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 - -#define _MAGNUM_DO_NOT_WARN_DEPRECATED_SHAPES - -#include "Magnum/Magnum.h" -#include "Magnum/Shapes/Collision.h" - -namespace Magnum { namespace Shapes { namespace Test { namespace { - -struct CollisionTest: TestSuite::Tester { - explicit CollisionTest(); - - void boolConversion(); - void flipped(); -}; - -CollisionTest::CollisionTest() { - addTests({&CollisionTest::boolConversion, - &CollisionTest::flipped}); -} - -CORRADE_IGNORE_DEPRECATED_PUSH -void CollisionTest::boolConversion() { - CORRADE_VERIFY(!Collision3D()); - CORRADE_VERIFY(!Collision3D({}, {2.0f, 0.0f, 0.0f}, 0.0f)); - CORRADE_VERIFY(!Collision3D({}, {0.0f, 0.0f, 2.0f}, -0.1f)); - CORRADE_VERIFY(Collision3D({}, {0.0f, 1.0f, 0.0f}, 0.1f)); -} - -void CollisionTest::flipped() { - const auto flipped = Collision3D({-1.0f, 0.5f, 3.0f}, {1.0f, 0.0f, 0.0f}, 0.5f).flipped(); - CORRADE_COMPARE(flipped.position(), Vector3(-1.5f, 0.5f, 3.0f)); - CORRADE_COMPARE(flipped.separationNormal(), Vector3(-1.0f, 0.0f, 0.0f)); - CORRADE_COMPARE(flipped.separationDistance(), 0.5f); -} -CORRADE_IGNORE_DEPRECATED_POP - -}}}} - -CORRADE_TEST_MAIN(Magnum::Shapes::Test::CollisionTest) diff --git a/src/Magnum/Shapes/Test/CompositionTest.cpp b/src/Magnum/Shapes/Test/CompositionTest.cpp deleted file mode 100644 index d1a6994dce..0000000000 --- a/src/Magnum/Shapes/Test/CompositionTest.cpp +++ /dev/null @@ -1,192 +0,0 @@ -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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. -*/ - -#define _MAGNUM_DO_NOT_WARN_DEPRECATED_SHAPES - -#include "Magnum/Math/Matrix3.h" -#include "Magnum/Math/Matrix4.h" -#include "Magnum/Shapes/Point.h" -#include "Magnum/Shapes/AxisAlignedBox.h" -#include "Magnum/Shapes/Composition.h" -#include "Magnum/Shapes/Sphere.h" - -#include "ShapeTestBase.h" - -namespace Magnum { namespace Shapes { namespace Test { namespace { - -struct CompositionTest: TestSuite::Tester { - explicit CompositionTest(); - - void negated(); - void anded(); - void ored(); - void multipleUnary(); - void hierarchy(); - void empty(); - - void copy(); - void move(); - void transformed(); -}; - -CompositionTest::CompositionTest() { - addTests({&CompositionTest::negated, - &CompositionTest::anded, - &CompositionTest::ored, - &CompositionTest::multipleUnary, - &CompositionTest::hierarchy, - &CompositionTest::empty, - - &CompositionTest::copy, - &CompositionTest::move, - &CompositionTest::transformed}); -} - -CORRADE_IGNORE_DEPRECATED_PUSH -void CompositionTest::negated() { - const Shapes::Composition2D a = !Shapes::Point2D(Vector2::xAxis(0.5f)); - - CORRADE_COMPARE(a.size(), 1); - CORRADE_COMPARE(a.type(0), Composition2D::Type::Point); - CORRADE_COMPARE(a.get(0).position(), Vector2::xAxis(0.5f)); - - VERIFY_NOT_COLLIDES(a, Shapes::Sphere2D({}, 1.0f)); -} - -void CompositionTest::anded() { - const Shapes::Composition2D a = Shapes::Sphere2D({}, 1.0f) && Shapes::Point2D(Vector2::xAxis(0.5f)); - - CORRADE_COMPARE(a.size(), 2); - CORRADE_COMPARE(a.type(0), Composition2D::Type::Sphere); - CORRADE_COMPARE(a.type(1), Composition2D::Type::Point); - CORRADE_COMPARE(a.get(0).position(), Vector2()); - CORRADE_COMPARE(a.get(0).radius(), 1.0f); - CORRADE_COMPARE(a.get(1).position(), Vector2::xAxis(0.5f)); - - VERIFY_NOT_COLLIDES(a, Shapes::Point2D()); - VERIFY_COLLIDES(a, Shapes::Sphere2D(Vector2::xAxis(0.5f), 0.25f)); -} - -void CompositionTest::ored() { - const Shapes::Composition2D a = Shapes::Sphere2D({}, 1.0f) || Shapes::Point2D(Vector2::xAxis(1.5f)); - - CORRADE_COMPARE(a.size(), 2); - CORRADE_COMPARE(a.type(0), Composition2D::Type::Sphere); - CORRADE_COMPARE(a.type(1), Composition2D::Type::Point); - CORRADE_COMPARE(a.get(0).position(), Vector2()); - CORRADE_COMPARE(a.get(0).radius(), 1.0f); - CORRADE_COMPARE(a.get(1).position(), Vector2::xAxis(1.5f)); - - VERIFY_COLLIDES(a, Shapes::Point2D()); - VERIFY_COLLIDES(a, Shapes::Sphere2D(Vector2::xAxis(1.5f), 0.25f)); -} - -void CompositionTest::multipleUnary() { - const Shapes::Composition2D a = !!!!Shapes::Point2D(Vector2::xAxis(0.5f)); - - CORRADE_COMPARE(a.size(), 1); - CORRADE_COMPARE(a.type(0), Composition2D::Type::Point); - CORRADE_COMPARE(a.get(0).position(), Vector2::xAxis(0.5f)); - - VERIFY_COLLIDES(a, Shapes::Sphere2D({}, 1.0f)); -} - -void CompositionTest::hierarchy() { - const Shapes::Composition3D a = Shapes::Sphere3D({}, 1.0f) && - (Shapes::Point3D(Vector3::xAxis(1.5f)) || !Shapes::AxisAlignedBox3D({}, Vector3(0.5f))); - - CORRADE_COMPARE(a.size(), 3); - CORRADE_COMPARE(a.type(0), Composition3D::Type::Sphere); - CORRADE_COMPARE(a.type(1), Composition3D::Type::Point); - CORRADE_COMPARE(a.type(2), Composition3D::Type::AxisAlignedBox); - CORRADE_COMPARE(a.get(1).position(), Vector3::xAxis(1.5f)); - - VERIFY_COLLIDES(a, Shapes::Sphere3D(Vector3::xAxis(1.5f), 0.6f)); - VERIFY_NOT_COLLIDES(a, Shapes::Point3D(Vector3(0.25f))); -} - -void CompositionTest::empty() { - const Shapes::Composition2D a; - - CORRADE_COMPARE(a.size(), 0); - - VERIFY_NOT_COLLIDES(a, Shapes::Sphere2D({}, 1.0f)); -} - -void CompositionTest::copy() { - const Shapes::Composition3D a = Shapes::Sphere3D({}, 1.0f) && - (Shapes::Point3D(Vector3::xAxis(1.5f)) || !Shapes::AxisAlignedBox3D({}, Vector3(0.5f))); - - /* Copy constructor */ - const Shapes::Composition3D b(a); - CORRADE_COMPARE(b.size(), 3); - CORRADE_COMPARE(b.get(2).max(), Vector3(0.5f)); - - /* Copy assignment */ - Shapes::Composition3D c; - c = a; - CORRADE_COMPARE(c.size(), 3); - CORRADE_COMPARE(c.get(1).position(), Vector3::xAxis(1.5f)); -} - -void CompositionTest::move() { - { - Shapes::Composition3D a = Shapes::Sphere3D({}, 1.0f) && - (Shapes::Point3D(Vector3::xAxis(1.5f)) || !Shapes::AxisAlignedBox3D({}, Vector3(0.5f))); - - /* Move constructor */ - const Shapes::Composition3D b(std::move(a)); - CORRADE_COMPARE(a.size(), 0); - CORRADE_COMPARE(b.size(), 3); - CORRADE_COMPARE(b.get(1).position(), Vector3::xAxis(1.5f)); - } { - Shapes::Composition3D a = Shapes::Sphere3D({}, 1.0f) && - (Shapes::Point3D(Vector3::xAxis(1.5f)) || !Shapes::AxisAlignedBox3D({}, Vector3(0.5f))); - - /* Move assignment */ - Shapes::Composition3D b; - b = std::move(a); - CORRADE_COMPARE(a.size(), 0); - CORRADE_COMPARE(b.size(), 3); - CORRADE_COMPARE(b.get(2).max(), Vector3(0.5f)); - } -} - -void CompositionTest::transformed() { - const Shapes::Composition2D a = Shapes::Sphere2D({}, 1.0f) && - (Shapes::Point2D(Vector2::xAxis(1.5f)) || !Shapes::AxisAlignedBox2D({}, Vector2(0.5f))); - - const Shapes::Composition2D b = a.transformed(Matrix3::translation({1.5f, -7.0f})); - CORRADE_COMPARE(b.get(0).position(), Vector2(1.5f, -7.0f)); - CORRADE_COMPARE(b.get(0).radius(), 1.0f); - CORRADE_COMPARE(b.get(1).position(), Vector2(3.0f, -7.0f)); - CORRADE_COMPARE(b.get(2).min(), Vector2(1.5f, -7.0f)); - CORRADE_COMPARE(b.get(2).max(), Vector2(2.0f, -6.5f)); -} -CORRADE_IGNORE_DEPRECATED_POP - -}}}} - -CORRADE_TEST_MAIN(Magnum::Shapes::Test::CompositionTest) diff --git a/src/Magnum/Shapes/Test/CylinderTest.cpp b/src/Magnum/Shapes/Test/CylinderTest.cpp deleted file mode 100644 index 1c15046b47..0000000000 --- a/src/Magnum/Shapes/Test/CylinderTest.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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. -*/ - -#define _MAGNUM_DO_NOT_WARN_DEPRECATED_SHAPES - -#include "Magnum/Magnum.h" -#include "Magnum/Math/Matrix3.h" -#include "Magnum/Math/Matrix4.h" -#include "Magnum/Shapes/Cylinder.h" -#include "Magnum/Shapes/Point.h" -#include "Magnum/Shapes/Sphere.h" - -#include "ShapeTestBase.h" - -namespace Magnum { namespace Shapes { namespace Test { namespace { - -struct CylinderTest: TestSuite::Tester { - explicit CylinderTest(); - - void transformed(); - void collisionPoint(); - void collisionSphere(); -}; - -CylinderTest::CylinderTest() { - addTests({&CylinderTest::transformed, - &CylinderTest::collisionPoint, - &CylinderTest::collisionSphere}); -} - -CORRADE_IGNORE_DEPRECATED_PUSH -void CylinderTest::transformed() { - const Shapes::Cylinder3D cylinder({1.0f, 2.0f, 3.0f}, {-1.0f, -2.0f, -3.0f}, 7.0f); - - const auto transformed = cylinder.transformed(Matrix4::scaling(Vector3(2.0f))*Matrix4::rotation(Deg(90.0f), Vector3::zAxis())); - CORRADE_COMPARE(transformed.a(), Vector3(-4.0f, 2.0f, 6.0f)); - CORRADE_COMPARE(transformed.b(), Vector3(4.0f, -2.0f, -6.0f)); - CORRADE_COMPARE(transformed.radius(), 14.0f); -} - -void CylinderTest::collisionPoint() { - Shapes::Cylinder3D cylinder({-1.0f, -1.0f, 0.0f}, {1.0f, 1.0f, 0.0f}, 2.0f); - Shapes::Point3D point({2.0f, 0.0f, 0.0f}); - Shapes::Point3D point1({1.0f, 3.1f, 0.0f}); - Shapes::Point3D point2({2.9f, -1.0f, 0.0f}); - - VERIFY_COLLIDES(cylinder, point); - VERIFY_COLLIDES(cylinder, point1); - VERIFY_NOT_COLLIDES(cylinder, point2); -} - -void CylinderTest::collisionSphere() { - Shapes::Cylinder3D cylinder({-1.0f, -1.0f, 0.0f}, {1.0f, 1.0f, 0.0f}, 2.0f); - Shapes::Sphere3D sphere({3.0f, 0.0f, 0.0f}, 0.9f); - Shapes::Sphere3D sphere1({1.0f, 4.1f, 0.0f}, 1.0f); - Shapes::Sphere3D sphere2({3.5f, -1.0f, 0.0f}, 0.6f); - - VERIFY_COLLIDES(cylinder, sphere); - VERIFY_COLLIDES(cylinder, sphere1); - VERIFY_NOT_COLLIDES(cylinder, sphere2); -} -CORRADE_IGNORE_DEPRECATED_POP - -}}}} - -CORRADE_TEST_MAIN(Magnum::Shapes::Test::CylinderTest) diff --git a/src/Magnum/Shapes/Test/LineTest.cpp b/src/Magnum/Shapes/Test/LineTest.cpp deleted file mode 100644 index 389825cd8c..0000000000 --- a/src/Magnum/Shapes/Test/LineTest.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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 - -#define _MAGNUM_DO_NOT_WARN_DEPRECATED_SHAPES - -#include "Magnum/Magnum.h" -#include "Magnum/Math/Matrix4.h" -#include "Magnum/Shapes/Line.h" - -namespace Magnum { namespace Shapes { namespace Test { namespace { - -struct LineTest: TestSuite::Tester { - explicit LineTest(); - - void transformed(); -}; - -LineTest::LineTest() { - addTests({&LineTest::transformed}); -} - -CORRADE_IGNORE_DEPRECATED_PUSH -void LineTest::transformed() { - const auto line = Shapes::Line3D({1.0f, 2.0f, 3.0f}, {-1.0f, -2.0f, -3.0f}) - .transformed(Matrix4::rotation(Deg(90.0f), Vector3::zAxis())); - CORRADE_COMPARE(line.a(), Vector3(-2.0f, 1.0f, 3.0f)); - CORRADE_COMPARE(line.b(), Vector3(2.0f, -1.0f, -3.0f)); -} -CORRADE_IGNORE_DEPRECATED_POP - -}}}} - -CORRADE_TEST_MAIN(Magnum::Shapes::Test::LineTest) diff --git a/src/Magnum/Shapes/Test/PlaneTest.cpp b/src/Magnum/Shapes/Test/PlaneTest.cpp deleted file mode 100644 index 0835387742..0000000000 --- a/src/Magnum/Shapes/Test/PlaneTest.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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. -*/ - -#define _MAGNUM_DO_NOT_WARN_DEPRECATED_SHAPES - -#include "Magnum/Math/Matrix4.h" -#include "Magnum/Shapes/LineSegment.h" -#include "Magnum/Shapes/Point.h" -#include "Magnum/Shapes/Plane.h" - -#include "ShapeTestBase.h" - -namespace Magnum { namespace Shapes { namespace Test { namespace { - -struct PlaneTest: TestSuite::Tester { - explicit PlaneTest(); - - void transformed(); - void collisionLine(); - void collisionLineSegment(); -}; - -PlaneTest::PlaneTest() { - addTests({&PlaneTest::transformed, - &PlaneTest::collisionLine, - &PlaneTest::collisionLineSegment}); -} - -CORRADE_IGNORE_DEPRECATED_PUSH -void PlaneTest::transformed() { - const Shapes::Plane plane({1.0f, 2.0f, 3.0f}, {Constants::sqrt2(), -Constants::sqrt2(), 0}); - - /* The normal should stay normalized after scaling */ - const auto transformed = plane.transformed(Matrix4::scaling(Vector3(2.0f))*Matrix4::rotation(Deg(90.0f), Vector3::xAxis())); - CORRADE_COMPARE(transformed.position(), Vector3(2.0f, -6.0f, 4.0f)); - CORRADE_COMPARE(transformed.normal(), Vector3(Constants::sqrt2(), 0, -Constants::sqrt2())); -} - -void PlaneTest::collisionLine() { - Shapes::Plane plane(Vector3(), Vector3::yAxis()); - Shapes::Line3D line({0.0f, 0.0f, 0.0f}, {1.0f, 0.0f, 0.0f}); - Shapes::Line3D line2({0.0f, -1.0f, 0.0f}, {1.0f, 1.0f, 0.0f}); - Shapes::Line3D line3({0.0f, 1.0f, 0.0f}, {1.0f, 1.0f, 0.0f}); - - VERIFY_COLLIDES(plane, line); - VERIFY_COLLIDES(plane, line2); - VERIFY_NOT_COLLIDES(plane, line3); -} - -void PlaneTest::collisionLineSegment() { - Shapes::Plane plane(Vector3(), Vector3::yAxis()); - Shapes::LineSegment3D line({0.0f, -0.1f, 0.0f}, {0.0f, 7.0f, 0.0f}); - Shapes::LineSegment3D line2({0.0f, 0.1f, 0.0f}, {0.0f, 7.0f, 0.0f}); - Shapes::LineSegment3D line3({0.0f, -7.0f, 0.0f}, {0.0f, -0.1f, 0.0f}); - - VERIFY_COLLIDES(plane, line); - VERIFY_NOT_COLLIDES(plane, line2); - VERIFY_NOT_COLLIDES(plane, line3); -} -CORRADE_IGNORE_DEPRECATED_POP - -}}}} - -CORRADE_TEST_MAIN(Magnum::Shapes::Test::PlaneTest) diff --git a/src/Magnum/Shapes/Test/PointTest.cpp b/src/Magnum/Shapes/Test/PointTest.cpp deleted file mode 100644 index 8d7259d4dd..0000000000 --- a/src/Magnum/Shapes/Test/PointTest.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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 - -#define _MAGNUM_DO_NOT_WARN_DEPRECATED_SHAPES - -#include "Magnum/Magnum.h" -#include "Magnum/Math/Matrix4.h" -#include "Magnum/Shapes/Point.h" - -namespace Magnum { namespace Shapes { namespace Test { namespace { - -struct PointTest: TestSuite::Tester { - explicit PointTest(); - - void transformed(); -}; - -PointTest::PointTest() { - addTests({&PointTest::transformed}); -} - -CORRADE_IGNORE_DEPRECATED_PUSH -void PointTest::transformed() { - const auto point = Shapes::Point3D({1.0f, 2.0f, 3.0f}) - .transformed(Matrix4::translation({5.0f, 6.0f, 7.0f})); - CORRADE_COMPARE(point.position(), Vector3(6.0f, 8.0f, 10.0f)); -} -CORRADE_IGNORE_DEPRECATED_POP - -}}}} - -CORRADE_TEST_MAIN(Magnum::Shapes::Test::PointTest) diff --git a/src/Magnum/Shapes/Test/ShapeImplementationTest.cpp b/src/Magnum/Shapes/Test/ShapeImplementationTest.cpp deleted file mode 100644 index d4e4a825e2..0000000000 --- a/src/Magnum/Shapes/Test/ShapeImplementationTest.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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 - -#define _MAGNUM_DO_NOT_WARN_DEPRECATED_SHAPES - -#include "Magnum/Shapes/shapeImplementation.h" - -namespace Magnum { namespace Shapes { namespace Test { namespace { - -struct ShapeImplementationTest: TestSuite::Tester { - explicit ShapeImplementationTest(); - - void debug(); -}; - -ShapeImplementationTest::ShapeImplementationTest() { - addTests({&ShapeImplementationTest::debug}); -} - -CORRADE_IGNORE_DEPRECATED_PUSH -void ShapeImplementationTest::debug() { - std::ostringstream o; - Debug(&o) << Implementation::ShapeDimensionTraits<2>::Type::Composition << Implementation::ShapeDimensionTraits<2>::Type(0xbe); - CORRADE_COMPARE(o.str(), "Shapes::Shape2D::Type::Composition Shapes::Shape2D::Type(0xbe)\n"); - - o.str({}); - Debug(&o) << Implementation::ShapeDimensionTraits<3>::Type::Plane << Implementation::ShapeDimensionTraits<3>::Type(0xbe); - CORRADE_COMPARE(o.str(), "Shapes::Shape3D::Type::Plane Shapes::Shape3D::Type(0xbe)\n"); -} -CORRADE_IGNORE_DEPRECATED_POP - -}}}} - -CORRADE_TEST_MAIN(Magnum::Shapes::Test::ShapeImplementationTest) diff --git a/src/Magnum/Shapes/Test/ShapeTest.cpp b/src/Magnum/Shapes/Test/ShapeTest.cpp deleted file mode 100644 index 88c1d1acd0..0000000000 --- a/src/Magnum/Shapes/Test/ShapeTest.cpp +++ /dev/null @@ -1,231 +0,0 @@ -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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 - -#define _MAGNUM_DO_NOT_WARN_DEPRECATED_SHAPES - -#include "Magnum/Shapes/Composition.h" -#include "Magnum/Shapes/Point.h" -#include "Magnum/Shapes/Shape.h" -#include "Magnum/Shapes/ShapeGroup.h" -#include "Magnum/Shapes/Sphere.h" -#include "Magnum/SceneGraph/MatrixTransformation2D.h" -#include "Magnum/SceneGraph/MatrixTransformation3D.h" -#include "Magnum/SceneGraph/Scene.h" - -namespace Magnum { namespace Shapes { namespace Test { namespace { - -struct ShapeTest: TestSuite::Tester { - explicit ShapeTest(); - - void clean(); - void collides(); - void collision(); - void firstCollision(); - void shapeGroup(); -}; - -typedef SceneGraph::Scene Scene2D; -typedef SceneGraph::Object Object2D; -typedef SceneGraph::Scene Scene3D; -typedef SceneGraph::Object Object3D; - -ShapeTest::ShapeTest() { - addTests({&ShapeTest::clean, - &ShapeTest::collides, - &ShapeTest::collision, - &ShapeTest::firstCollision, - &ShapeTest::shapeGroup}); -} - -CORRADE_IGNORE_DEPRECATED_PUSH -void ShapeTest::clean() { - Scene3D scene; - ShapeGroup3D shapes; - - Object3D a(&scene); - auto shape = new Shapes::Shape(a, {{1.0f, -2.0f, 3.0f}}, &shapes); - a.scale(Vector3(-2.0f)); - - Object3D b(&scene); - new Shapes::Shape(b, &shapes); - - /* Everything is dirty at the beginning */ - CORRADE_VERIFY(shapes.isDirty()); - CORRADE_VERIFY(a.isDirty()); - CORRADE_VERIFY(b.isDirty()); - - /* Cleaning object will not clean anything other */ - a.setClean(); - CORRADE_VERIFY(shapes.isDirty()); - CORRADE_VERIFY(!a.isDirty()); - CORRADE_VERIFY(b.isDirty()); - - /* Verify that the feature was actually cleaned */ - CORRADE_COMPARE(shape->transformedShape().position(), - Vector3(-2.0f, 4.0f, -6.0f)); - - /* Setting group clean will clean whole group */ - a.setDirty(); - shapes.setClean(); - CORRADE_VERIFY(!shapes.isDirty()); - CORRADE_VERIFY(!a.isDirty()); - CORRADE_VERIFY(!b.isDirty()); - - /* Setting object dirty will set also the group, but not other objects */ - b.setDirty(); - CORRADE_VERIFY(shapes.isDirty()); - CORRADE_VERIFY(!a.isDirty()); - CORRADE_VERIFY(b.isDirty()); -} - -void ShapeTest::collides() { - Scene3D scene; - ShapeGroup3D shapes; - Object3D a(&scene); - Shape aShape(a, {{1.0f, -2.0f, 3.0f}, 1.5f}, &shapes); - - { - /* Collision with point inside the sphere */ - Shape aShape2(a, {{1.0f, -2.0f, 3.0f}}, &shapes); - shapes.setClean(); - CORRADE_VERIFY(aShape.collides(aShape2)); - } { - /* No collision with point inside the sphere, but not in the same group */ - ShapeGroup3D shapes2; - Shape aShape3(a, {{1.0f, -2.0f, 3.0f}}, &shapes2); - shapes2.setClean(); - CORRADE_VERIFY(!aShape.collides(aShape3)); - } { - CORRADE_EXPECT_FAIL("Should cross-scene collision work or not?"); - /* No collision with point inside the sphere, but not in the same scene */ - Scene3D scene2; - Object3D c(&scene2); - Shape cShape(c, {{1.0f, -2.0f, 3.0f}}, &shapes); - shapes.setClean(); - CORRADE_VERIFY(!aShape.collides(cShape)); - } { - /* No collision with point outside of the sphere */ - Object3D b(&scene); - Shape bShape(b, {{3.0f, -2.0f, 3.0f}}, &shapes); - shapes.setClean(); - CORRADE_VERIFY(!aShape.collides(bShape)); - - /* Move point inside the sphere -- collision */ - b.translate(Vector3::xAxis(-1.0f)); - shapes.setClean(); - CORRADE_VERIFY(aShape.collides(bShape)); - } -} - -void ShapeTest::collision() { - Scene3D scene; - ShapeGroup3D shapes; - Object3D a(&scene); - Shape aShape(a, {{1.0f, -2.0f, 3.0f}, 1.5f}, &shapes); - - { - /* Collision with point inside the sphere */ - Shape aShape2(a, {{1.0f, -2.0f, 3.0f}}, &shapes); - shapes.setClean(); - const Collision3D collision = aShape.collision(aShape2); - CORRADE_VERIFY(collision); - CORRADE_COMPARE(collision.position(), Vector3(1.0f, -2.0f, 3.0f)); - } { - /* No collision with point inside the sphere, but not in the same group */ - ShapeGroup3D shapes2; - Shape aShape3(a, {{1.0f, -2.0f, 3.0f}}, &shapes2); - shapes2.setClean(); - CORRADE_VERIFY(!aShape.collision(aShape3)); - } { - CORRADE_EXPECT_FAIL("Should cross-scene collision work or not?"); - /* No collision with point inside the sphere, but not in the same scene */ - Scene3D scene2; - Object3D c(&scene2); - Shape cShape(c, {{1.0f, -2.0f, 3.0f}}, &shapes); - shapes.setClean(); - CORRADE_VERIFY(!aShape.collision(cShape)); - } { - /* No collision with point outside of the sphere */ - Object3D b(&scene); - Shape bShape(b, {{3.0f, -2.0f, 3.0f}}, &shapes); - shapes.setClean(); - CORRADE_VERIFY(!aShape.collision(bShape)); - - /* Move point inside the sphere -- collision */ - b.translate(Vector3::xAxis(-1.0f)); - shapes.setClean(); - const Collision3D collision = aShape.collision(bShape); - CORRADE_VERIFY(collision); - CORRADE_COMPARE(collision.position(), Vector3(2.0f, -2.0f, 3.0f)); - } -} - -void ShapeTest::firstCollision() { - Scene3D scene; - ShapeGroup3D shapes; - - Object3D a(&scene); - Shape aShape(a, {{1.0f, -2.0f, 3.0f}, 1.5f}, &shapes); - - Object3D b(&scene); - Shape bShape(b, {{3.0f, -2.0f, 3.0f}}, &shapes); - - /* No collisions initially */ - CORRADE_VERIFY(!shapes.firstCollision(aShape)); - CORRADE_VERIFY(!shapes.firstCollision(bShape)); - CORRADE_VERIFY(!shapes.isDirty()); - - /* Move point into sphere */ - b.translate(Vector3::xAxis(-1.0f)); - - /* Collision */ - CORRADE_VERIFY(shapes.isDirty()); - CORRADE_VERIFY(shapes.firstCollision(aShape) == &bShape); - CORRADE_VERIFY(shapes.firstCollision(bShape) == &aShape); - CORRADE_VERIFY(!shapes.isDirty()); -} - -void ShapeTest::shapeGroup() { - Scene2D scene; - ShapeGroup2D shapes; - - /* Verify construction */ - Object2D a(&scene); - auto shape = new Shape(a, Shapes::Sphere2D({}, 0.5f) || Shapes::Point2D({0.25f, -1.0f})); - CORRADE_COMPARE(shape->transformedShape().size(), 2); - - /* Verify the original shape is updated */ - const auto& point = shape->transformedShape().get(1); - a.translate(Vector2::xAxis(5.0f)); - a.setClean(); - CORRADE_COMPARE(point.position(), Vector2(5.25f, -1.0f)); -} -CORRADE_IGNORE_DEPRECATED_POP - -}}}} - -CORRADE_TEST_MAIN(Magnum::Shapes::Test::ShapeTest) diff --git a/src/Magnum/Shapes/Test/ShapeTestBase.h b/src/Magnum/Shapes/Test/ShapeTestBase.h deleted file mode 100644 index d93c31ff2d..0000000000 --- a/src/Magnum/Shapes/Test/ShapeTestBase.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef Magnum_Shapes_Test_ShapeTestBase_h -#define Magnum_Shapes_Test_ShapeTestBase_h -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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 - -namespace Magnum { namespace Shapes { namespace Test { namespace { - -#define VERIFY_COLLIDES(a, b) \ - CORRADE_VERIFY(a % b); \ - CORRADE_VERIFY(b % a); - -#define VERIFY_NOT_COLLIDES(a, b) \ - CORRADE_VERIFY(!(a % b)); \ - CORRADE_VERIFY(!(b % a)); - -}}}} - -#endif diff --git a/src/Magnum/Shapes/Test/SphereTest.cpp b/src/Magnum/Shapes/Test/SphereTest.cpp deleted file mode 100644 index deb2a99fa9..0000000000 --- a/src/Magnum/Shapes/Test/SphereTest.cpp +++ /dev/null @@ -1,181 +0,0 @@ -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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. -*/ - -#define _MAGNUM_DO_NOT_WARN_DEPRECATED_SHAPES - -#include "Magnum/Magnum.h" -#include "Magnum/Math/Matrix3.h" -#include "Magnum/Math/Matrix4.h" -#include "Magnum/Shapes/LineSegment.h" -#include "Magnum/Shapes/Point.h" -#include "Magnum/Shapes/Sphere.h" - -#include "ShapeTestBase.h" - -namespace Magnum { namespace Shapes { namespace Test { namespace { - -struct SphereTest: TestSuite::Tester { - explicit SphereTest(); - - void transformed(); - void collisionPoint(); - void collisionPointInverted(); - void collisionLine(); - void collisionLineSegment(); - void collisionSphere(); - void collisionSphereInverted(); -}; - -SphereTest::SphereTest() { - addTests({&SphereTest::transformed, - &SphereTest::collisionPoint, - &SphereTest::collisionPointInverted, - &SphereTest::collisionLine, - &SphereTest::collisionLineSegment, - &SphereTest::collisionSphere, - &SphereTest::collisionSphereInverted}); -} - -CORRADE_IGNORE_DEPRECATED_PUSH -void SphereTest::transformed() { - const Shapes::Sphere3D sphere({1.0f, 2.0f, 3.0f}, 7.0f); - - const auto transformed = sphere.transformed(Matrix4::scaling(Vector3(2.0f))*Matrix4::rotation(Deg(90.0f), Vector3::yAxis())); - CORRADE_COMPARE(transformed.position(), Vector3(6.0f, 4.0f, -2.0f)); - CORRADE_COMPARE(transformed.radius(), 14.0f); -} - -void SphereTest::collisionPoint() { - const Shapes::Sphere3D sphere({1.0f, 2.0f, 3.0f}, 2.0f); - - /* Collision */ - const Shapes::Point3D point({2.5f, 2.0f, 3.0f}); - const Shapes::Collision3D collision = sphere/point; - CORRADE_VERIFY(sphere%point && point%sphere); - CORRADE_COMPARE(collision.position(), point.position()); - CORRADE_COMPARE(collision.separationNormal(), -Vector3::xAxis()); - CORRADE_COMPARE(collision.separationDistance(), 0.5f); - - /* Collision, flipped */ - CORRADE_COMPARE(collision.separationNormal(), -(point/sphere).separationNormal()); - - /* Collision with ambiguous separation vector */ - const Shapes::Point3D point2(sphere.position()); - const Shapes::Collision3D collision2 = sphere/point2; - CORRADE_COMPARE(collision2.position(), point2.position()); - CORRADE_COMPARE(collision2.separationNormal(), Vector3::yAxis()); - CORRADE_COMPARE(collision2.separationDistance(), 2.0f); - - /* No collision */ - const Shapes::Point3D point3({-1.5f, 2.0f, 3.0f}); - CORRADE_VERIFY(!(sphere%point3) && !(sphere/point3)); -} - -void SphereTest::collisionPointInverted() { - const Shapes::InvertedSphere3D sphere({1.0f, 2.0f, 3.0f}, 2.0f); - - /* Collision */ - const Shapes::Point3D point({-1.5f, 2.0f, 3.0f}); - const Shapes::Collision3D collision = sphere/point; - CORRADE_VERIFY(sphere%point && point%sphere); - CORRADE_COMPARE(collision.position(), point.position()); - CORRADE_COMPARE(collision.separationNormal(), -Vector3::xAxis()); - CORRADE_COMPARE(collision.separationDistance(), 0.5f); - - /* Collision, flipped */ - CORRADE_COMPARE(collision.separationNormal(), -(point/sphere).separationNormal()); - - /* No collision */ - const Shapes::Point3D point3({2.0f, 2.0f, 3.0f}); - CORRADE_VERIFY(!(sphere%point3) && !(sphere/point3)); -} - -void SphereTest::collisionLine() { - Shapes::Sphere3D sphere({1.0f, 2.0f, 3.0f}, 2.0f); - Shapes::Line3D line({1.0f, 1.5f, 3.5f}, {1.0f, 2.5f, 2.5f}); - Shapes::Line3D line2({1.0f, 2.0f, 5.1f}, {1.0f, 3.0f, 5.1f}); - - VERIFY_COLLIDES(sphere, line); - VERIFY_NOT_COLLIDES(sphere, line2); -} - -void SphereTest::collisionLineSegment() { - Shapes::Sphere3D sphere({1.0f, 2.0f, 3.0f}, 2.0f); - Shapes::LineSegment3D line({1.0f, 2.0f, 4.9f}, {1.0f, 2.0f, 7.0f}); - Shapes::LineSegment3D line2({1.0f, 2.0f, 5.1f}, {1.0f, 2.0f, 7.0f}); - - VERIFY_COLLIDES(sphere, line); - VERIFY_NOT_COLLIDES(sphere, line2); -} - -void SphereTest::collisionSphere() { - const Shapes::Sphere3D sphere({1.0f, 2.0f, 3.0f}, 2.0f); - - /* Collision */ - const Shapes::Sphere3D sphere1({3.5f, 2.0f, 3.0f}, 1.0f); - const Shapes::Collision3D collision = sphere/sphere1; - CORRADE_VERIFY(sphere%sphere1 && sphere1%sphere); - CORRADE_COMPARE(collision.position(), sphere1.position() - Vector3::xAxis(sphere1.radius())); - CORRADE_COMPARE(collision.separationNormal(), -Vector3::xAxis()); - CORRADE_COMPARE(collision.separationDistance(), 0.5f); - - /* Collision, flipped */ - CORRADE_COMPARE(collision.separationNormal(), -(sphere1/sphere).separationNormal()); - - /* Collision with ambiguous separation vector */ - const Shapes::Sphere3D sphere2(sphere.position(), 0.5f); - const Shapes::Collision3D collision2 = sphere/sphere2; - CORRADE_COMPARE(collision2.position(), sphere2.position() + Vector3::yAxis(sphere2.radius())); - CORRADE_COMPARE(collision2.separationNormal(), Vector3::yAxis()); - CORRADE_COMPARE(collision2.separationDistance(), 2.5f); - - /* No collision */ - const Shapes::Sphere3D sphere3({-2.5f, 2.0f, 3.0f}, 1.0f); - CORRADE_VERIFY(!(sphere%sphere3) && !(sphere/sphere3)); -} - -void SphereTest::collisionSphereInverted() { - const Shapes::InvertedSphere3D sphere({1.0f, 2.0f, 3.0f}, 2.0f); - - /* Collision */ - const Shapes::Sphere3D sphere1({-0.5f, 2.0f, 3.0f}, 1.0f); - const Shapes::Collision3D collision = sphere/sphere1; - CORRADE_VERIFY(sphere%sphere1 && sphere1%sphere); - CORRADE_COMPARE(collision.position(), sphere1.position() - Vector3::xAxis(sphere1.radius())); - CORRADE_COMPARE(collision.separationNormal(), -Vector3::xAxis()); - CORRADE_COMPARE(collision.separationDistance(), 0.5f); - - /* Collision, flipped */ - CORRADE_COMPARE(collision.separationNormal(), -(sphere1/sphere).separationNormal()); - - /* No collision */ - const Shapes::Sphere3D sphere3({1.5f, 2.0f, 3.0f}, 1.0f); - CORRADE_VERIFY(!(sphere%sphere3) && !(sphere/sphere3)); -} -CORRADE_IGNORE_DEPRECATED_POP - -}}}} - -CORRADE_TEST_MAIN(Magnum::Shapes::Test::SphereTest) diff --git a/src/Magnum/Shapes/shapeImplementation.cpp b/src/Magnum/Shapes/shapeImplementation.cpp deleted file mode 100644 index a6c8f95716..0000000000 --- a/src/Magnum/Shapes/shapeImplementation.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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. -*/ - -#define _MAGNUM_DO_NOT_WARN_DEPRECATED_SHAPES - -#include "shapeImplementation.h" - -#include - -namespace Magnum { namespace Shapes { namespace Implementation { - -CORRADE_IGNORE_DEPRECATED_PUSH -Debug& operator<<(Debug& debug, ShapeDimensionTraits<2>::Type value) { - switch(value) { - /* LCOV_EXCL_START */ - #define _val(value) case ShapeDimensionTraits<2>::Type::value: return debug << "Shapes::Shape2D::Type::" #value; - _val(Point) - _val(Line) - _val(LineSegment) - _val(Sphere) - _val(InvertedSphere) - _val(Capsule) - _val(Cylinder) - _val(AxisAlignedBox) - _val(Box) - _val(Composition) - #undef _val - /* LCOV_EXCL_STOP */ - } - - return debug << "Shapes::Shape2D::Type(" << Debug::nospace << reinterpret_cast(UnsignedByte(value)) << Debug::nospace << ")"; -} - -Debug& operator<<(Debug& debug, ShapeDimensionTraits<3>::Type value) { - switch(value) { - /* LCOV_EXCL_START */ - #define _val(value) case ShapeDimensionTraits<3>::Type::value: return debug << "Shapes::Shape3D::Type::" #value; - _val(Point) - _val(Line) - _val(LineSegment) - _val(Sphere) - _val(InvertedSphere) - _val(Capsule) - _val(Cylinder) - _val(AxisAlignedBox) - _val(Box) - _val(Plane) - _val(Composition) - #undef _val - /* LCOV_EXCL_STOP */ - } - - return debug << "Shapes::Shape3D::Type(" << Debug::nospace << reinterpret_cast(UnsignedByte(value)) << Debug::nospace << ")"; -} - -template AbstractShape::~AbstractShape() = default; -template AbstractShape::AbstractShape() = default; - -template struct AbstractShape<2>; -template struct AbstractShape<3>; -CORRADE_IGNORE_DEPRECATED_POP - -}}} diff --git a/src/Magnum/Shapes/shapeImplementation.h b/src/Magnum/Shapes/shapeImplementation.h deleted file mode 100644 index b998a4fa30..0000000000 --- a/src/Magnum/Shapes/shapeImplementation.h +++ /dev/null @@ -1,189 +0,0 @@ -#ifndef Magnum_Shapes_shapeImplementation_h -#define Magnum_Shapes_shapeImplementation_h -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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 - -#include "Magnum/DimensionTraits.h" -#include "Magnum/Magnum.h" -#include "Magnum/Shapes/Shapes.h" -#include "Magnum/Shapes/visibility.h" - -namespace Magnum { namespace Shapes { namespace Implementation { - -CORRADE_IGNORE_DEPRECATED_PUSH -/* - Adding new collision type: - - 1. Add the type into the 2D/3D enums below, pick new prime number and - preserve complexity ordering - 2. Update debug output operators for changed enums - 3. Add TypeOf struct specialization (either for both 2D/3D or for only one - of them) - 4. Add the enum value to (documentation-only) enum in Composition - 5. Update doc/shapes.dox with new type - - Adding new collision detection implementation: - - 1. Update Implementation/CollisionDispatch.cpp with newly implemented - 2D/3D pair -*/ - -/* Shape type for given dimension count */ - -template struct ShapeDimensionTraits; - -template<> struct ShapeDimensionTraits<2> { - enum class Type: UnsignedByte { - Point = 1, - Line = 2, - LineSegment = 3, - Sphere = 5, - InvertedSphere = 7, - Cylinder = 11, - Capsule = 13, - AxisAlignedBox = 17, - Box = 19, - Composition = 23 - }; -}; - -template<> struct ShapeDimensionTraits<3> { - enum class Type: UnsignedByte { - Point = 1, - Line = 2, - LineSegment = 3, - Sphere = 5, - InvertedSphere = 7, - Cylinder = 11, - Capsule = 13, - AxisAlignedBox = 17, - Box = 19, - Plane = 23, - Composition = 29 - }; -}; - -MAGNUM_SHAPES_EXPORT Debug& operator<<(Debug& debug, ShapeDimensionTraits<2>::Type value); -MAGNUM_SHAPES_EXPORT Debug& operator<<(Debug& debug, ShapeDimensionTraits<3>::Type value); - -/* Enum value corresponding to given type */ - -template struct TypeOf; - -template struct TypeOf> { - constexpr static typename ShapeDimensionTraits::Type type() { - return ShapeDimensionTraits::Type::Point; - } -}; -template struct TypeOf> { - constexpr static typename ShapeDimensionTraits::Type type() { - return ShapeDimensionTraits::Type::Line; - } -}; -template struct TypeOf> { - constexpr static typename ShapeDimensionTraits::Type type() { - return ShapeDimensionTraits::Type::LineSegment; - } -}; -template struct TypeOf> { - constexpr static typename ShapeDimensionTraits::Type type() { - return ShapeDimensionTraits::Type::Sphere; - } -}; -template struct TypeOf> { - constexpr static typename ShapeDimensionTraits::Type type() { - return ShapeDimensionTraits::Type::InvertedSphere; - } -}; -template struct TypeOf> { - constexpr static typename ShapeDimensionTraits::Type type() { - return ShapeDimensionTraits::Type::Cylinder; - } -}; -template struct TypeOf> { - constexpr static typename ShapeDimensionTraits::Type type() { - return ShapeDimensionTraits::Type::Capsule; - } -}; -template struct TypeOf> { - constexpr static typename ShapeDimensionTraits::Type type() { - return ShapeDimensionTraits::Type::AxisAlignedBox; - } -}; -template struct TypeOf> { - constexpr static typename ShapeDimensionTraits::Type type() { - return ShapeDimensionTraits::Type::Box; - } -}; -template<> struct TypeOf { - constexpr static ShapeDimensionTraits<3>::Type type() { - return ShapeDimensionTraits<3>::Type::Plane; - } -}; -template struct TypeOf> { - constexpr static typename ShapeDimensionTraits::Type type() { - return ShapeDimensionTraits::Type::Composition; - } -}; - -/* Polymorphic shape wrappers */ - -template struct MAGNUM_SHAPES_EXPORT AbstractShape { - explicit AbstractShape(); - virtual ~AbstractShape(); - - virtual typename ShapeDimensionTraits::Type MAGNUM_SHAPES_LOCAL type() const = 0; - virtual AbstractShape MAGNUM_SHAPES_LOCAL * clone() const = 0; - virtual void MAGNUM_SHAPES_LOCAL transform(const MatrixTypeFor& matrix, AbstractShape* result) const = 0; -}; - -template struct Shape: AbstractShape { - T shape; - - explicit Shape() = default; - explicit Shape(const T& shape): shape(shape) {} - explicit Shape(T&& shape): shape(std::move(shape)) {} - - typename ShapeDimensionTraits::Type type() const override { - return TypeOf::type(); - } - - AbstractShape* clone() const override { - return new Shape(shape); - } - - void transform(const MatrixTypeFor& matrix, AbstractShape* result) const override { - CORRADE_INTERNAL_ASSERT(result->type() == type()); - static_cast*>(result)->shape = shape.transformed(matrix); - } -}; -CORRADE_IGNORE_DEPRECATED_POP - -}}} - -#endif diff --git a/src/Magnum/Shapes/visibility.h b/src/Magnum/Shapes/visibility.h deleted file mode 100644 index 0e471f12e4..0000000000 --- a/src/Magnum/Shapes/visibility.h +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef Magnum_Shapes_visibility_h -#define Magnum_Shapes_visibility_h -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 - 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 - #ifdef MagnumShapes_EXPORTS - #define MAGNUM_SHAPES_EXPORT CORRADE_VISIBILITY_EXPORT - #else - #define MAGNUM_SHAPES_EXPORT CORRADE_VISIBILITY_IMPORT - #endif -#else - #define MAGNUM_SHAPES_EXPORT CORRADE_VISIBILITY_STATIC -#endif -#define MAGNUM_SHAPES_LOCAL CORRADE_VISIBILITY_LOCAL -#else -#define MAGNUM_SHAPES_EXPORT -#define MAGNUM_SHAPES_LOCAL -#endif - -#endif