Browse Source

Shapes: this library is no more either.

pull/331/head
Vladimír Vondruš 7 years ago
parent
commit
aca02f52f5
  1. 3
      CMakeLists.txt
  2. 2
      Doxyfile
  3. 2
      Doxyfile-mcss
  4. 2
      Doxyfile-public
  5. 11
      doc/building.dox
  6. 7
      doc/changelog-old.dox
  7. 21
      doc/changelog.dox
  8. 1
      doc/cmake.dox
  9. 13
      doc/coding-style.dox
  10. 1
      doc/compilation-speedup.dox
  11. 4
      doc/custom-buildsystems-order.dot
  12. 2
      doc/debug-tools.dox
  13. 2
      doc/features.dox
  14. 38
      doc/namespaces.dox
  15. 6
      doc/scenegraph.dox
  16. 185
      doc/shapes.dox
  17. 8
      doc/snippets/coding-style.h
  18. 18
      modules/FindMagnum.cmake
  19. 1
      package/archlinux/PKGBUILD
  20. 1
      package/archlinux/PKGBUILD-android-arm64
  21. 1
      package/archlinux/PKGBUILD-clang
  22. 1
      package/archlinux/PKGBUILD-clang-addressanitizer
  23. 1
      package/archlinux/PKGBUILD-clang-analyzer
  24. 1
      package/archlinux/PKGBUILD-clang-libc++
  25. 11
      package/archlinux/PKGBUILD-coverage
  26. 1
      package/archlinux/PKGBUILD-emscripten
  27. 1
      package/archlinux/PKGBUILD-emscripten-wasm
  28. 1
      package/archlinux/PKGBUILD-emscripten-wasm-webgl2
  29. 1
      package/archlinux/PKGBUILD-emscripten-webgl2
  30. 1
      package/archlinux/PKGBUILD-es2
  31. 1
      package/archlinux/PKGBUILD-es2desktop
  32. 1
      package/archlinux/PKGBUILD-es3
  33. 1
      package/archlinux/PKGBUILD-es3desktop
  34. 1
      package/archlinux/PKGBUILD-gcc48
  35. 1
      package/archlinux/PKGBUILD-mingw-w64
  36. 2
      package/archlinux/PKGBUILD-release
  37. 1
      package/ci/appveyor-desktop-gles.bat
  38. 1
      package/ci/appveyor-desktop-mingw.bat
  39. 1
      package/ci/appveyor-desktop-vulkan.bat
  40. 1
      package/ci/appveyor-desktop.bat
  41. 10
      package/ci/appveyor-lcov.sh
  42. 1
      package/ci/travis-android-arm.sh
  43. 1
      package/ci/travis-desktop-gles.sh
  44. 1
      package/ci/travis-desktop-vulkan.sh
  45. 1
      package/ci/travis-desktop.sh
  46. 1
      package/ci/travis-emscripten.sh
  47. 1
      package/ci/travis-ios-simulator.sh
  48. 10
      package/ci/travis.yml
  49. 4
      src/Magnum/CMakeLists.txt
  50. 50
      src/Magnum/DebugTools/CMakeLists.txt
  51. 9
      src/Magnum/DebugTools/DebugTools.h
  52. 48
      src/Magnum/DebugTools/Implementation/AbstractBoxRenderer.cpp
  53. 51
      src/Magnum/DebugTools/Implementation/AbstractBoxRenderer.h
  54. 138
      src/Magnum/DebugTools/Implementation/AbstractShapeRenderer.cpp
  55. 73
      src/Magnum/DebugTools/Implementation/AbstractShapeRenderer.h
  56. 52
      src/Magnum/DebugTools/Implementation/AxisAlignedBoxRenderer.cpp
  57. 49
      src/Magnum/DebugTools/Implementation/AxisAlignedBoxRenderer.h
  58. 50
      src/Magnum/DebugTools/Implementation/BoxRenderer.cpp
  59. 49
      src/Magnum/DebugTools/Implementation/BoxRenderer.h
  60. 131
      src/Magnum/DebugTools/Implementation/CapsuleRenderer.cpp
  61. 69
      src/Magnum/DebugTools/Implementation/CapsuleRenderer.h
  62. 109
      src/Magnum/DebugTools/Implementation/CapsuleRendererTransformation.h
  63. 65
      src/Magnum/DebugTools/Implementation/CylinderRenderer.cpp
  64. 61
      src/Magnum/DebugTools/Implementation/CylinderRenderer.h
  65. 91
      src/Magnum/DebugTools/Implementation/CylinderRendererTransformation.h
  66. 72
      src/Magnum/DebugTools/Implementation/LineSegmentRenderer.cpp
  67. 49
      src/Magnum/DebugTools/Implementation/LineSegmentRenderer.h
  68. 42
      src/Magnum/DebugTools/Implementation/LineSegmentRendererTransformation.h
  69. 72
      src/Magnum/DebugTools/Implementation/PointRenderer.cpp
  70. 49
      src/Magnum/DebugTools/Implementation/PointRenderer.h
  71. 64
      src/Magnum/DebugTools/Implementation/SphereRenderer.cpp
  72. 61
      src/Magnum/DebugTools/Implementation/SphereRenderer.h
  73. 23
      src/Magnum/DebugTools/ResourceManager.cpp
  74. 24
      src/Magnum/DebugTools/ResourceManager.h
  75. 137
      src/Magnum/DebugTools/ShapeRenderer.cpp
  76. 250
      src/Magnum/DebugTools/ShapeRenderer.h
  77. 12
      src/Magnum/DebugTools/Test/CMakeLists.txt
  78. 179
      src/Magnum/DebugTools/Test/CapsuleRendererTest.cpp
  79. 127
      src/Magnum/DebugTools/Test/CylinderRendererTest.cpp
  80. 70
      src/Magnum/DebugTools/Test/LineSegmentRendererTest.cpp
  81. 73
      src/Magnum/Shapes/AbstractShape.cpp
  82. 172
      src/Magnum/Shapes/AbstractShape.h
  83. 53
      src/Magnum/Shapes/AxisAlignedBox.cpp
  84. 153
      src/Magnum/Shapes/AxisAlignedBox.h
  85. 43
      src/Magnum/Shapes/Box.cpp
  86. 130
      src/Magnum/Shapes/Box.h
  87. 97
      src/Magnum/Shapes/CMakeLists.txt
  88. 61
      src/Magnum/Shapes/Capsule.cpp
  89. 178
      src/Magnum/Shapes/Capsule.h
  90. 173
      src/Magnum/Shapes/Collision.h
  91. 160
      src/Magnum/Shapes/Composition.cpp
  92. 395
      src/Magnum/Shapes/Composition.h
  93. 61
      src/Magnum/Shapes/Cylinder.cpp
  94. 178
      src/Magnum/Shapes/Cylinder.h
  95. 133
      src/Magnum/Shapes/Implementation/CollisionDispatch.cpp
  96. 53
      src/Magnum/Shapes/Implementation/CollisionDispatch.h
  97. 48
      src/Magnum/Shapes/Line.cpp
  98. 138
      src/Magnum/Shapes/Line.h
  99. 111
      src/Magnum/Shapes/LineSegment.h
  100. 56
      src/Magnum/Shapes/Plane.cpp
  101. Some files were not shown because too many files have changed in this diff Show More

3
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)

2
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\"" \

2
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\"" \

2
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" \

11
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

7
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"

21
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} <canvas> @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).

1
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

13
doc/coding-style.dox

@ -101,19 +101,6 @@ these are defined:
The @c \@glsl command expands to <tt>\@cb{.glsl}</tt>, 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

1
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

4
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]

2
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.
*/
}

2
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
*/

38
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
*/

6
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.

185
doc/shapes.dox

@ -1,185 +0,0 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019
Vladimír Vondruš <mosra@centrum.cz>
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<Shapes::Sphere3D>(a, {{}, 23.0f}, &shapes);
Object3D& b;
auto bShape = new Shapes::Shape<Shapes::Point3D>(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.
*/
}

8
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] */

18
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)

1
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 \

1
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 \

1
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 \

1
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 \

1
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 \

1
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 \

11
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

1
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 \

1
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 \

1
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 \

1
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 \

1
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 \

1
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 \

1
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 \

1
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 \

1
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 \

1
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 \

2
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 \

1
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 ^

1
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 ^

1
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 ^

1
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 ^

10
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

1
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 \

1
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 \

1
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 \

1
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 \

1
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 \

1
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 \

10
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

4
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()

50
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()

9
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<UnsignedInt> 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

48
src/Magnum/DebugTools/Implementation/AbstractBoxRenderer.cpp

@ -1,48 +0,0 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019
Vladimír Vondruš <mosra@centrum.cz>
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
}}}

51
src/Magnum/DebugTools/Implementation/AbstractBoxRenderer.h

@ -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š <mosra@centrum.cz>
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<UnsignedInt dimensions> 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

138
src/Magnum/DebugTools/Implementation/AbstractShapeRenderer.cpp

@ -1,138 +0,0 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019
Vladimír Vondruš <mosra@centrum.cz>
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 <Corrade/Containers/Array.h>
#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<UnsignedInt dimensions> ResourceKey shaderKey();
template<> inline ResourceKey shaderKey<2>() { return ResourceKey("FlatShader2D"); }
template<> inline ResourceKey shaderKey<3>() { return ResourceKey("FlatShader3D"); }
template<UnsignedInt dimensions> void create(typename MeshData<dimensions>::Type&, Resource<GL::Mesh>&, Resource<GL::Buffer>&, Resource<GL::Buffer>&);
template<> void create<2>(Trade::MeshData2D& data, Resource<GL::Mesh>& meshResource, Resource<GL::Buffer>& vertexBufferResource, Resource<GL::Buffer>& 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<char> 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<GL::Mesh>& meshResource, Resource<GL::Buffer>& vertexBufferResource, Resource<GL::Buffer>& 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<char> 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<UnsignedInt dimensions> AbstractShapeRenderer<dimensions>::AbstractShapeRenderer(ResourceKey meshKey, ResourceKey vertexBufferKey, ResourceKey indexBufferKey) {
wireframeShader = ResourceManager::instance().get<GL::AbstractShaderProgram, Shaders::Flat<dimensions>>(shaderKey<dimensions>());
wireframeMesh = ResourceManager::instance().get<GL::Mesh>(meshKey);
vertexBuffer = ResourceManager::instance().get<GL::Buffer>(vertexBufferKey);
indexBuffer = ResourceManager::instance().get<GL::Buffer>(indexBufferKey);
if(!wireframeShader) ResourceManager::instance().set<GL::AbstractShaderProgram>(shaderKey<dimensions>(),
new Shaders::Flat<dimensions>, ResourceDataState::Final, ResourcePolicy::Resident);
}
template<UnsignedInt dimensions> AbstractShapeRenderer<dimensions>::~AbstractShapeRenderer() = default;
template<UnsignedInt dimensions> void AbstractShapeRenderer<dimensions>::createResources(typename MeshData<dimensions>::Type data) {
create<dimensions>(data, wireframeMesh, vertexBuffer, indexBuffer);
}
template class AbstractShapeRenderer<2>;
template class AbstractShapeRenderer<3>;
CORRADE_IGNORE_DEPRECATED_POP
}}}

73
src/Magnum/DebugTools/Implementation/AbstractShapeRenderer.h

@ -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š <mosra@centrum.cz>
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<UnsignedInt> struct AbstractShape;
}}
namespace DebugTools { namespace Implementation {
template<UnsignedInt> struct MeshData;
template<> struct MeshData<2> { typedef Trade::MeshData2D Type; };
template<> struct MeshData<3> { typedef Trade::MeshData3D Type; };
template<UnsignedInt dimensions> class AbstractShapeRenderer {
public:
AbstractShapeRenderer(ResourceKey mesh, ResourceKey vertexBuffer, ResourceKey indexBuffer);
virtual ~AbstractShapeRenderer();
virtual void draw(Resource<ShapeRendererOptions>& options, const MatrixTypeFor<dimensions, Float>& projectionMatrix) = 0;
protected:
/* Call only if the mesh resource isn't already present */
void createResources(typename MeshData<dimensions>::Type data);
Resource<GL::AbstractShaderProgram, Shaders::Flat<dimensions>> wireframeShader;
Resource<GL::Mesh> wireframeMesh;
private:
Resource<GL::Buffer> indexBuffer, vertexBuffer;
};
}}
CORRADE_IGNORE_DEPRECATED_POP
}
#endif

52
src/Magnum/DebugTools/Implementation/AxisAlignedBoxRenderer.cpp

@ -1,52 +0,0 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019
Vladimír Vondruš <mosra@centrum.cz>
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<UnsignedInt dimensions> AxisAlignedBoxRenderer<dimensions>::AxisAlignedBoxRenderer(const Shapes::Implementation::AbstractShape<dimensions>& axisAlignedBox): axisAlignedBox(static_cast<const Shapes::Implementation::Shape<Shapes::AxisAlignedBox<dimensions>>&>(axisAlignedBox).shape) {}
template<UnsignedInt dimensions> void AxisAlignedBoxRenderer<dimensions>::draw(Resource<ShapeRendererOptions>& options, const MatrixTypeFor<dimensions, Float>& projectionMatrix) {
AbstractBoxRenderer<dimensions>::wireframeShader->setTransformationProjectionMatrix(projectionMatrix*
MatrixTypeFor<dimensions, Float>::translation((axisAlignedBox.min()+axisAlignedBox.max())/2)*
MatrixTypeFor<dimensions, Float>::scaling(axisAlignedBox.max()-axisAlignedBox.min()))
.setColor(options->color());
AbstractBoxRenderer<dimensions>::wireframeMesh->draw(*AbstractBoxRenderer<dimensions>::wireframeShader);
}
template class AxisAlignedBoxRenderer<2>;
template class AxisAlignedBoxRenderer<3>;
CORRADE_IGNORE_DEPRECATED_POP
}}}

49
src/Magnum/DebugTools/Implementation/AxisAlignedBoxRenderer.h

@ -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š <mosra@centrum.cz>
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<UnsignedInt dimensions> class AxisAlignedBoxRenderer: public AbstractBoxRenderer<dimensions> {
public:
explicit AxisAlignedBoxRenderer(const Shapes::Implementation::AbstractShape<dimensions>& axisAlignedBox);
AxisAlignedBoxRenderer(Shapes::Implementation::AbstractShape<dimensions>&&) = delete;
void draw(Resource<ShapeRendererOptions>& options, const MatrixTypeFor<dimensions, Float>& projectionMatrix) override;
private:
const Shapes::AxisAlignedBox<dimensions>& axisAlignedBox;
};
CORRADE_IGNORE_DEPRECATED_POP
}}}
#endif

50
src/Magnum/DebugTools/Implementation/BoxRenderer.cpp

@ -1,50 +0,0 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019
Vladimír Vondruš <mosra@centrum.cz>
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<UnsignedInt dimensions> BoxRenderer<dimensions>::BoxRenderer(const Shapes::Implementation::AbstractShape<dimensions>& box): box(static_cast<const Shapes::Implementation::Shape<Shapes::Box<dimensions>>&>(box).shape) {}
template<UnsignedInt dimensions> void BoxRenderer<dimensions>::draw(Resource<ShapeRendererOptions>& options, const MatrixTypeFor<dimensions, Float>& projectionMatrix) {
AbstractBoxRenderer<dimensions>::wireframeShader->setTransformationProjectionMatrix(projectionMatrix*box.transformation())
.setColor(options->color());
AbstractBoxRenderer<dimensions>::wireframeMesh->draw(*AbstractBoxRenderer<dimensions>::wireframeShader);
}
template class BoxRenderer<2>;
template class BoxRenderer<3>;
CORRADE_IGNORE_DEPRECATED_POP
}}}

49
src/Magnum/DebugTools/Implementation/BoxRenderer.h

@ -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š <mosra@centrum.cz>
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<UnsignedInt dimensions> class BoxRenderer: public AbstractBoxRenderer<dimensions> {
public:
explicit BoxRenderer(const Shapes::Implementation::AbstractShape<dimensions>& box);
BoxRenderer(const Shapes::Implementation::AbstractShape<dimensions>&&) = delete;
void draw(Resource<ShapeRendererOptions>& options, const MatrixTypeFor<dimensions, Float>& projectionMatrix) override;
private:
const Shapes::Box<dimensions>& box;
};
CORRADE_IGNORE_DEPRECATED_POP
}}}
#endif

131
src/Magnum/DebugTools/Implementation/CapsuleRenderer.cpp

@ -1,131 +0,0 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019
Vladimír Vondruš <mosra@centrum.cz>
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<GL::MeshView>("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<GL::MeshView>("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<GL::MeshView>("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<GL::MeshView>("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<GL::MeshView>("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<GL::MeshView>("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<UnsignedInt dimensions> CapsuleRenderer<dimensions>::CapsuleRenderer(const Shapes::Implementation::AbstractShape<dimensions>& capsule): capsule(static_cast<const Shapes::Implementation::Shape<Shapes::Capsule<dimensions>>&>(capsule).shape) {}
template<UnsignedInt dimensions> void CapsuleRenderer<dimensions>::draw(Resource<ShapeRendererOptions>& options, const MatrixTypeFor<dimensions, Float>& projectionMatrix) {
std::array<MatrixTypeFor<dimensions, Float>, 3> transformations = Implementation::capsuleRendererTransformation<dimensions>(capsule.a(), capsule.b(), capsule.radius());
AbstractShapeRenderer<dimensions>::wireframeShader->setColor(options->color());
/* Bottom */
AbstractShapeRenderer<dimensions>::wireframeShader->setTransformationProjectionMatrix(projectionMatrix*transformations[0]);
AbstractCapsuleRenderer<dimensions>::bottom->draw(*AbstractShapeRenderer<dimensions>::wireframeShader);
/* Cylinder */
AbstractShapeRenderer<dimensions>::wireframeShader->setTransformationProjectionMatrix(projectionMatrix*transformations[1]);
AbstractCapsuleRenderer<dimensions>::cylinder->draw(*AbstractShapeRenderer<dimensions>::wireframeShader);
/* Top */
AbstractShapeRenderer<dimensions>::wireframeShader->setTransformationProjectionMatrix(projectionMatrix*transformations[2]);
AbstractCapsuleRenderer<dimensions>::top->draw(*AbstractShapeRenderer<dimensions>::wireframeShader);
}
template class CapsuleRenderer<2>;
template class CapsuleRenderer<3>;
CORRADE_IGNORE_DEPRECATED_POP
}}}

69
src/Magnum/DebugTools/Implementation/CapsuleRenderer.h

@ -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š <mosra@centrum.cz>
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<UnsignedInt dimensions> class AbstractCapsuleRenderer;
template<> class AbstractCapsuleRenderer<2>: public AbstractShapeRenderer<2> {
public:
explicit AbstractCapsuleRenderer();
~AbstractCapsuleRenderer();
protected:
Resource<GL::MeshView> bottom, cylinder, top;
};
template<> class AbstractCapsuleRenderer<3>: public AbstractShapeRenderer<3> {
public:
explicit AbstractCapsuleRenderer();
~AbstractCapsuleRenderer();
protected:
Resource<GL::MeshView> bottom, cylinder, top;
};
template<UnsignedInt dimensions> class CapsuleRenderer: public AbstractCapsuleRenderer<dimensions> {
public:
explicit CapsuleRenderer(const Shapes::Implementation::AbstractShape<dimensions>& capsule);
CapsuleRenderer(const Shapes::Implementation::AbstractShape<dimensions>&&) = delete;
void draw(Resource<ShapeRendererOptions>& options, const MatrixTypeFor<dimensions, Float>& projectionMatrix) override;
private:
const Shapes::Capsule<dimensions>& capsule;
};
CORRADE_IGNORE_DEPRECATED_POP
}}}
#endif

109
src/Magnum/DebugTools/Implementation/CapsuleRendererTransformation.h

@ -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š <mosra@centrum.cz>
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 <array>
#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<UnsignedInt dimensions> std::array<MatrixTypeFor<dimensions, Float>, 3> capsuleRendererTransformation(const VectorTypeFor<dimensions, Float>& a, const VectorTypeFor<dimensions, Float>& b, Float radius);
template<> std::array<Matrix3, 3> 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<Float>::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<Matrix4, 3> 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<Float>::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<Float>::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

65
src/Magnum/DebugTools/Implementation/CylinderRenderer.cpp

@ -1,65 +0,0 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019
Vladimír Vondruš <mosra@centrum.cz>
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<UnsignedInt dimensions> CylinderRenderer<dimensions>::CylinderRenderer(const Shapes::Implementation::AbstractShape<dimensions>& cylinder): cylinder(static_cast<const Shapes::Implementation::Shape<Shapes::Cylinder<dimensions>>&>(cylinder).shape) {}
template<UnsignedInt dimensions> void CylinderRenderer<dimensions>::draw(Resource<ShapeRendererOptions>& options, const MatrixTypeFor<dimensions, Float>& projectionMatrix) {
AbstractShapeRenderer<dimensions>::wireframeShader->setTransformationProjectionMatrix(projectionMatrix*
Implementation::cylinderRendererTransformation<dimensions>(cylinder.a(), cylinder.b(), cylinder.radius()))
.setColor(options->color());
AbstractShapeRenderer<dimensions>::wireframeMesh->draw(*AbstractShapeRenderer<dimensions>::wireframeShader);
}
template class CylinderRenderer<2>;
template class CylinderRenderer<3>;
CORRADE_IGNORE_DEPRECATED_POP
}}}

61
src/Magnum/DebugTools/Implementation/CylinderRenderer.h

@ -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š <mosra@centrum.cz>
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<UnsignedInt dimensions> class AbstractCylinderRenderer;
template<> class AbstractCylinderRenderer<2>: public AbstractShapeRenderer<2> {
public:
explicit AbstractCylinderRenderer();
};
template<> class AbstractCylinderRenderer<3>: public AbstractShapeRenderer<3> {
public:
explicit AbstractCylinderRenderer();
};
template<UnsignedInt dimensions> class CylinderRenderer: public AbstractCylinderRenderer<dimensions> {
public:
explicit CylinderRenderer(const Shapes::Implementation::AbstractShape<dimensions>& cylinder);
CylinderRenderer(const Shapes::Implementation::AbstractShape<dimensions>&&) = delete;
void draw(Resource<ShapeRendererOptions>& options, const MatrixTypeFor<dimensions, Float>& projectionMatrix) override;
private:
const Shapes::Cylinder<dimensions>& cylinder;
};
CORRADE_IGNORE_DEPRECATED_POP
}}}
#endif

91
src/Magnum/DebugTools/Implementation/CylinderRendererTransformation.h

@ -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š <mosra@centrum.cz>
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<UnsignedInt dimensions> MatrixTypeFor<dimensions, Float> cylinderRendererTransformation(const VectorTypeFor<dimensions, Float>& a, const VectorTypeFor<dimensions, Float>& 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<Float>::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<Float>::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<Float>::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

72
src/Magnum/DebugTools/Implementation/LineSegmentRenderer.cpp

@ -1,72 +0,0 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019
Vladimír Vondruš <mosra@centrum.cz>
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<UnsignedInt dimensions> ResourceKey meshKey();
template<> inline ResourceKey meshKey<2>() { return ResourceKey("line2d"); }
template<> inline ResourceKey meshKey<3>() { return ResourceKey("line3d"); }
template<UnsignedInt dimensions> ResourceKey vertexBufferKey();
template<> inline ResourceKey vertexBufferKey<2>() { return ResourceKey("line2d-vertices"); }
template<> inline ResourceKey vertexBufferKey<3>() { return ResourceKey("line3d-vertices"); }
template<UnsignedInt dimensions> typename MeshData<dimensions>::Type meshData();
template<> inline Trade::MeshData2D meshData<2>() { return Primitives::line2D(); }
template<> inline Trade::MeshData3D meshData<3>() { return Primitives::line3D(); }
}
template<UnsignedInt dimensions> LineSegmentRenderer<dimensions>::LineSegmentRenderer(const Shapes::Implementation::AbstractShape<dimensions>& line): AbstractShapeRenderer<dimensions>(meshKey<dimensions>(), vertexBufferKey<dimensions>(), {}), line(static_cast<const Shapes::Implementation::Shape<Shapes::LineSegment<dimensions>>&>(line).shape) {
if(!AbstractShapeRenderer<dimensions>::wireframeMesh) AbstractShapeRenderer<dimensions>::createResources(meshData<dimensions>());
}
template<UnsignedInt dimensions> void LineSegmentRenderer<dimensions>::draw(Resource<ShapeRendererOptions>& options, const MatrixTypeFor<dimensions, Float>& projectionMatrix) {
AbstractShapeRenderer<dimensions>::wireframeShader->setTransformationProjectionMatrix(projectionMatrix*
Implementation::lineSegmentRendererTransformation<dimensions>(line.a(), line.b()))
.setColor(options->color());
AbstractShapeRenderer<dimensions>::wireframeMesh->draw(*AbstractShapeRenderer<dimensions>::wireframeShader);
}
template class LineSegmentRenderer<2>;
template class LineSegmentRenderer<3>;
CORRADE_IGNORE_DEPRECATED_POP
}}}

49
src/Magnum/DebugTools/Implementation/LineSegmentRenderer.h

@ -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š <mosra@centrum.cz>
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<UnsignedInt dimensions> class LineSegmentRenderer: public AbstractShapeRenderer<dimensions> {
public:
explicit LineSegmentRenderer(const Shapes::Implementation::AbstractShape<dimensions>& line);
LineSegmentRenderer(const Shapes::Implementation::AbstractShape<dimensions>&&) = delete;
void draw(Resource<ShapeRendererOptions>& options, const MatrixTypeFor<dimensions, Float>& projectionMatrix) override;
private:
const Shapes::LineSegment<dimensions>& line;
};
CORRADE_IGNORE_DEPRECATED_POP
}}}
#endif

42
src/Magnum/DebugTools/Implementation/LineSegmentRendererTransformation.h

@ -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š <mosra@centrum.cz>
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<UnsignedInt dimensions> MatrixTypeFor<dimensions, Float> lineSegmentRendererTransformation(const VectorTypeFor<dimensions, Float>& a, const VectorTypeFor<dimensions, Float>& b) {
auto transformation = MatrixTypeFor<dimensions, Float>::translation(a);
transformation.right() = b - a;
return transformation;
}
CORRADE_IGNORE_DEPRECATED_POP
}}}
#endif

72
src/Magnum/DebugTools/Implementation/PointRenderer.cpp

@ -1,72 +0,0 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019
Vladimír Vondruš <mosra@centrum.cz>
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<UnsignedInt dimensions> ResourceKey meshKey();
template<> inline ResourceKey meshKey<2>() { return ResourceKey("point2d"); }
template<> inline ResourceKey meshKey<3>() { return ResourceKey("point3d"); }
template<UnsignedInt dimensions> ResourceKey vertexBufferKey();
template<> inline ResourceKey vertexBufferKey<2>() { return ResourceKey("point2d-vertices"); }
template<> inline ResourceKey vertexBufferKey<3>() { return ResourceKey("point3d-vertices"); }
template<UnsignedInt dimensions> typename MeshData<dimensions>::Type meshData();
template<> inline Trade::MeshData2D meshData<2>() { return Primitives::crosshair2D(); }
template<> inline Trade::MeshData3D meshData<3>() { return Primitives::crosshair3D(); }
}
template<UnsignedInt dimensions> PointRenderer<dimensions>::PointRenderer(const Shapes::Implementation::AbstractShape<dimensions>& point): AbstractShapeRenderer<dimensions>(meshKey<dimensions>(), vertexBufferKey<dimensions>(), {}), point(static_cast<const Shapes::Implementation::Shape<Shapes::Point<dimensions>>&>(point).shape) {
if(!AbstractShapeRenderer<dimensions>::wireframeMesh) AbstractShapeRenderer<dimensions>::createResources(meshData<dimensions>());
}
template<UnsignedInt dimensions> void PointRenderer<dimensions>::draw(Resource<ShapeRendererOptions>& options, const MatrixTypeFor<dimensions, Float>& projectionMatrix) {
/* Half scale, because the point is 2x2(x2) */
AbstractShapeRenderer<dimensions>::wireframeShader->setTransformationProjectionMatrix(projectionMatrix*
MatrixTypeFor<dimensions, Float>::translation(point.position())*
MatrixTypeFor<dimensions, Float>::scaling(VectorTypeFor<dimensions, Float>{options->pointSize()/2}))
.setColor(options->color());
AbstractShapeRenderer<dimensions>::wireframeMesh->draw(*AbstractShapeRenderer<dimensions>::wireframeShader);
}
template class PointRenderer<2>;
template class PointRenderer<3>;
CORRADE_IGNORE_DEPRECATED_POP
}}}

49
src/Magnum/DebugTools/Implementation/PointRenderer.h

@ -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š <mosra@centrum.cz>
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<UnsignedInt dimensions> class PointRenderer: public AbstractShapeRenderer<dimensions> {
public:
explicit PointRenderer(const Shapes::Implementation::AbstractShape<dimensions>& point);
PointRenderer(Shapes::Implementation::AbstractShape<dimensions>&&) = delete;
void draw(Resource<ShapeRendererOptions>& options, const MatrixTypeFor<dimensions, Float>& projectionMatrix) override;
private:
const Shapes::Point<dimensions>& point;
};
CORRADE_IGNORE_DEPRECATED_POP
}}}
#endif

64
src/Magnum/DebugTools/Implementation/SphereRenderer.cpp

@ -1,64 +0,0 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019
Vladimír Vondruš <mosra@centrum.cz>
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<UnsignedInt dimensions> SphereRenderer<dimensions>::SphereRenderer(const Shapes::Implementation::AbstractShape<dimensions>& sphere): sphere(static_cast<const Shapes::Implementation::Shape<Shapes::Sphere<dimensions>>&>(sphere).shape) {}
template<UnsignedInt dimensions> void SphereRenderer<dimensions>::draw(Resource<ShapeRendererOptions>& options, const MatrixTypeFor<dimensions, Float>& projectionMatrix) {
AbstractShapeRenderer<dimensions>::wireframeShader->setTransformationProjectionMatrix(projectionMatrix*
MatrixTypeFor<dimensions, Float>::translation(sphere.position())*
MatrixTypeFor<dimensions, Float>::scaling(VectorTypeFor<dimensions, Float>{sphere.radius()}))
.setColor(options->color());
AbstractShapeRenderer<dimensions>::wireframeMesh->draw(*AbstractShapeRenderer<dimensions>::wireframeShader);
}
template class SphereRenderer<2>;
template class SphereRenderer<3>;
CORRADE_IGNORE_DEPRECATED_POP
}}}

61
src/Magnum/DebugTools/Implementation/SphereRenderer.h

@ -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š <mosra@centrum.cz>
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<UnsignedInt dimensions> class AbstractSphereRenderer;
template<> class AbstractSphereRenderer<2>: public AbstractShapeRenderer<2> {
public:
explicit AbstractSphereRenderer();
};
template<> class AbstractSphereRenderer<3>: public AbstractShapeRenderer<3> {
public:
explicit AbstractSphereRenderer();
};
template<UnsignedInt dimensions> class SphereRenderer: public AbstractSphereRenderer<dimensions> {
public:
explicit SphereRenderer(const Shapes::Implementation::AbstractShape<dimensions>& sphere);
SphereRenderer(const Shapes::Implementation::AbstractShape<dimensions>&&) = delete;
void draw(Resource<ShapeRendererOptions>& options, const MatrixTypeFor<dimensions, Float>& projectionMatrix) override;
private:
const Shapes::Sphere<dimensions>& sphere;
};
CORRADE_IGNORE_DEPRECATED_POP
}}}
#endif

23
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<ResourceManagerLocalInstance, GL::AbstractShaderProgram, GL::Buffer, GL::Mesh, GL::MeshView, DebugTools::ForceRendererOptions, DebugTools::ObjectRendererOptions
#ifdef MAGNUM_BUILD_DEPRECATED
, DebugTools::ShapeRendererOptions
#endif
>;
#ifdef MAGNUM_BUILD_DEPRECATED
CORRADE_IGNORE_DEPRECATED_POP
#endif
template struct MAGNUM_DEBUGTOOLS_EXPORT ResourceManagerLocalInstanceImplementation<ResourceManagerLocalInstance, GL::AbstractShaderProgram, GL::Buffer, GL::Mesh, GL::MeshView, DebugTools::ForceRendererOptions, DebugTools::ObjectRendererOptions>;
}
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;

24
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<Magnum::Implementation::ResourceManagerLocalInstance, GL::AbstractShaderProgram, GL::Buffer, GL::Mesh, GL::MeshView, DebugTools::ForceRendererOptions, DebugTools::ObjectRendererOptions
#ifdef MAGNUM_BUILD_DEPRECATED
, DebugTools::ShapeRendererOptions
#endif
>
class MAGNUM_DEBUGTOOLS_EXPORT ResourceManager: public Magnum::ResourceManager<Magnum::Implementation::ResourceManagerLocalInstance, GL::AbstractShaderProgram, GL::Buffer, GL::Mesh, GL::MeshView, DebugTools::ForceRendererOptions, DebugTools::ObjectRendererOptions>
{
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

137
src/Magnum/DebugTools/ShapeRenderer.cpp

@ -1,137 +0,0 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019
Vladimír Vondruš <mosra@centrum.cz>
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<const Shapes::Implementation::Shape<Shapes::Composition2D>&>(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<const Shapes::Implementation::Shape<Shapes::Composition3D>&>(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<UnsignedInt dimensions> ShapeRenderer<dimensions>::ShapeRenderer(Shapes::AbstractShape<dimensions>& shape, ResourceKey options, SceneGraph::DrawableGroup<dimensions, Float>* drawables): SceneGraph::Drawable<dimensions, Float>(shape.object(), drawables), _options(ResourceManager::instance().get<ShapeRendererOptions>(options)) {
Implementation::createDebugMesh(*this, Shapes::Implementation::getAbstractShape(shape));
}
template<UnsignedInt dimensions> ShapeRenderer<dimensions>::~ShapeRenderer() {
for(auto i: _renderers) delete i;
}
template<UnsignedInt dimensions> void ShapeRenderer<dimensions>::draw(const MatrixTypeFor<dimensions, Float>&, SceneGraph::Camera<dimensions, Float>& camera) {
const MatrixTypeFor<dimensions, Float> 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
}}

250
src/Magnum/DebugTools/ShapeRenderer.h

@ -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š <mosra@centrum.cz>
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<UnsignedInt> class ShapeRenderer;
namespace Implementation {
template<UnsignedInt> class AbstractShapeRenderer;
template<UnsignedInt dimensions> void createDebugMesh(ShapeRenderer<dimensions>& renderer, const Shapes::Implementation::AbstractShape<dimensions>& 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<UnsignedInt dimensions> class CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") MAGNUM_DEBUGTOOLS_EXPORT ShapeRenderer: public SceneGraph::Drawable<dimensions, Float> {
#ifndef DOXYGEN_GENERATING_OUTPUT
friend void Implementation::createDebugMesh<>(ShapeRenderer<dimensions>&, const Shapes::Implementation::AbstractShape<dimensions>&);
#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<dimensions>& shape, ResourceKey options = ResourceKey(), SceneGraph::DrawableGroup<dimensions, Float>* drawables = nullptr);
~ShapeRenderer();
private:
void draw(const MatrixTypeFor<dimensions, Float>& transformationMatrix, SceneGraph::Camera<dimensions, Float>& camera) override;
Resource<ShapeRendererOptions> _options;
std::vector<Implementation::AbstractShapeRenderer<dimensions>*> _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

12
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")

179
src/Magnum/DebugTools/Test/CapsuleRendererTest.cpp

@ -1,179 +0,0 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019
Vladimír Vondruš <mosra@centrum.cz>
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 <Corrade/TestSuite/Tester.h>
#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<Matrix3, 3> 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<Matrix3, 3> 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<Matrix4, 3> 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<Matrix4, 3> 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<Matrix4, 3> 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<Matrix4, 3> 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)

127
src/Magnum/DebugTools/Test/CylinderRendererTest.cpp

@ -1,127 +0,0 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019
Vladimír Vondruš <mosra@centrum.cz>
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 <Corrade/TestSuite/Tester.h>
#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)

70
src/Magnum/DebugTools/Test/LineSegmentRendererTest.cpp

@ -1,70 +0,0 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019
Vladimír Vondruš <mosra@centrum.cz>
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 <Corrade/TestSuite/Tester.h>
#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)

73
src/Magnum/Shapes/AbstractShape.cpp

@ -1,73 +0,0 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019
Vladimír Vondruš <mosra@centrum.cz>
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 <Corrade/Utility/Debug.h>
#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<UnsignedInt dimensions> AbstractShape<dimensions>::AbstractShape(SceneGraph::AbstractObject<dimensions, Float>& object, ShapeGroup<dimensions>* group): SceneGraph::AbstractGroupedFeature<dimensions, AbstractShape<dimensions>, Float>(object, group) {
SceneGraph::AbstractFeature<dimensions, Float>::setCachedTransformations(SceneGraph::CachedTransformation::Absolute);
}
template<UnsignedInt dimensions> ShapeGroup<dimensions>* AbstractShape<dimensions>::group() {
return static_cast<ShapeGroup<dimensions>*>(SceneGraph::AbstractGroupedFeature<dimensions, AbstractShape<dimensions>, Float>::group());
}
template<UnsignedInt dimensions> const ShapeGroup<dimensions>* AbstractShape<dimensions>::group() const {
return static_cast<const ShapeGroup<dimensions>*>(SceneGraph::AbstractGroupedFeature<dimensions, AbstractShape<dimensions>, Float>::group());
}
template<UnsignedInt dimensions> auto AbstractShape<dimensions>::type() const -> Type {
return abstractTransformedShape().type();
}
template<UnsignedInt dimensions> bool AbstractShape<dimensions>::collides(const AbstractShape<dimensions>& other) const {
return Implementation::collides(abstractTransformedShape(), other.abstractTransformedShape());
}
template<UnsignedInt dimensions> Collision<dimensions> AbstractShape<dimensions>::collision(const AbstractShape<dimensions>& other) const {
return Implementation::collision(abstractTransformedShape(), other.abstractTransformedShape());
}
template<UnsignedInt dimensions> void AbstractShape<dimensions>::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
}}

172
src/Magnum/Shapes/AbstractShape.h

@ -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š <mosra@centrum.cz>
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<UnsignedInt dimensions> inline const AbstractShape<dimensions>& getAbstractShape(const Shapes::AbstractShape<dimensions>& 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<UnsignedInt dimensions> class CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") MAGNUM_SHAPES_EXPORT AbstractShape: public SceneGraph::AbstractGroupedFeature<dimensions, AbstractShape<dimensions>, Float> {
#ifndef CORRADE_MSVC2017_COMPATIBILITY
friend const Implementation::AbstractShape<dimensions>& Implementation::getAbstractShape<>(const AbstractShape<dimensions>&);
#else
/* Otherwise it complains that this is not a function */
template<UnsignedInt dimensions_> friend const Implementation::AbstractShape<dimensions_>& Implementation::getAbstractShape(const Shapes::AbstractShape<dimensions_>&);
#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<dimensions>::Type Type;
#endif
/**
* @brief Constructor
* @param object Object holding this feature
* @param group Group this shape belongs to
*/
explicit AbstractShape(SceneGraph::AbstractObject<dimensions, Float>& object, ShapeGroup<dimensions>* group = nullptr);
/**
* @brief Shape group containing this shape
*
* If the shape doesn't belong to any group, returns @cpp nullptr @ce.
*/
ShapeGroup<dimensions>* group();
const ShapeGroup<dimensions>* group() const; /**< @overload */
/** @brief Shape type */
Type type() const;
/**
* @brief Detect collision with other shape
*
* Default implementation returns false.
*/
bool collides(const AbstractShape<dimensions>& other) const;
/**
* @brief Collision with other shape
*
* Default implementation returns empty collision.
*/
Collision<dimensions> collision(const AbstractShape<dimensions>& other) const;
protected:
/** Marks also the group as dirty */
void markDirty() override;
private:
virtual const Implementation::AbstractShape<dimensions> 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

53
src/Magnum/Shapes/AxisAlignedBox.cpp

@ -1,53 +0,0 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019
Vladimír Vondruš <mosra@centrum.cz>
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<UnsignedInt dimensions> AxisAlignedBox<dimensions> AxisAlignedBox<dimensions>::transformed(const MatrixTypeFor<dimensions, Float>& matrix) const {
return AxisAlignedBox<dimensions>(matrix.transformPoint(_min),
matrix.transformPoint(_max));
}
template<UnsignedInt dimensions> bool AxisAlignedBox<dimensions>::operator%(const Point<dimensions>& 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
}}

153
src/Magnum/Shapes/AxisAlignedBox.h

@ -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š <mosra@centrum.cz>
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<UnsignedInt dimensions> 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<dimensions, Float>& min, const typename DimensionTraits<dimensions, Float>::VectorType& max): _min(min), _max(max) {}
/** @brief Transformed shape */
AxisAlignedBox<dimensions> transformed(const MatrixTypeFor<dimensions, Float>& matrix) const;
/** @brief Minimal coordinates */
constexpr VectorTypeFor<dimensions, Float> min() const {
return _min;
}
/** @brief Set minimal coordinates */
void setMin(const VectorTypeFor<dimensions, Float>& min) {
_min = min;
}
/** @brief Maximal coordinates */
constexpr VectorTypeFor<dimensions, Float> max() const {
return _max;
}
/** @brief Set maximal coordinates */
void setMax(const VectorTypeFor<dimensions, Float>& max) {
_max = max;
}
/** @brief Collision occurence with point */
bool operator%(const Point<dimensions>& other) const;
private:
VectorTypeFor<dimensions, Float> _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<UnsignedInt dimensions> inline CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") bool operator%(const Point<dimensions>& a, const AxisAlignedBox<dimensions>& b) { return b % a; }
CORRADE_IGNORE_DEPRECATED_POP
}}
#endif

43
src/Magnum/Shapes/Box.cpp

@ -1,43 +0,0 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019
Vladimír Vondruš <mosra@centrum.cz>
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<UnsignedInt dimensions> Box<dimensions> Box<dimensions>::transformed(const MatrixTypeFor<dimensions, Float>& matrix) const {
return Box<dimensions>(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
}}

130
src/Magnum/Shapes/Box.h

@ -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š <mosra@centrum.cz>
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<UnsignedInt dimensions> 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<dimensions, Float>& transformation): _transformation(transformation) {}
/** @brief Transformed shape */
Box<dimensions> transformed(const MatrixTypeFor<dimensions, Float>& matrix) const;
/** @brief Transformation */
constexpr MatrixTypeFor<dimensions, Float> transformation() const {
return _transformation;
}
/** @brief Set transformation */
void setTransformation(const MatrixTypeFor<dimensions, Float>& transformation) {
_transformation = transformation;
}
private:
MatrixTypeFor<dimensions, Float> _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

97
src/Magnum/Shapes/CMakeLists.txt

@ -1,97 +0,0 @@
#
# This file is part of Magnum.
#
# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019
# Vladimír Vondruš <mosra@centrum.cz>
#
# 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)

61
src/Magnum/Shapes/Capsule.cpp

@ -1,61 +0,0 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019
Vladimír Vondruš <mosra@centrum.cz>
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<UnsignedInt dimensions> Capsule<dimensions> Capsule<dimensions>::transformed(const MatrixTypeFor<dimensions, Float>& matrix) const {
return Capsule<dimensions>(matrix.transformPoint(_a), matrix.transformPoint(_b), matrix.uniformScaling()*_radius);
}
template<UnsignedInt dimensions> bool Capsule<dimensions>::operator%(const Point<dimensions>& other) const {
return Math::Distance::lineSegmentPointSquared(_a, _b, other.position()) <
Math::pow<2>(_radius);
}
template<UnsignedInt dimensions> bool Capsule<dimensions>::operator%(const Sphere<dimensions>& 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
}}

178
src/Magnum/Shapes/Capsule.h

@ -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š <mosra@centrum.cz>
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<UnsignedInt dimensions> 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<dimensions, Float>& a, const VectorTypeFor<dimensions, Float>& b, Float radius): _a(a), _b(b), _radius(radius) {}
/** @brief Transformed shape */
Capsule<dimensions> transformed(const MatrixTypeFor<dimensions, Float>& matrix) const;
/** @brief Start point */
constexpr VectorTypeFor<dimensions, Float> a() const {
return _a;
}
/** @brief Set start point */
void setA(const VectorTypeFor<dimensions, Float>& a) {
_a = a;
}
/** @brief End point */
constexpr VectorTypeFor<dimensions, Float> b() const {
return _b;
}
/** @brief Set end point */
void setB(const VectorTypeFor<dimensions, Float>& 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<dimensions>& other) const;
/** @brief Collision occurence with sphere */
bool operator%(const Sphere<dimensions>& other) const;
private:
VectorTypeFor<dimensions, Float> _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<UnsignedInt dimensions> inline CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") bool operator%(const Point<dimensions>& a, const Capsule<dimensions>& 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<UnsignedInt dimensions> inline CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") bool operator%(const Sphere<dimensions>& a, const Capsule<dimensions>& b) { return b % a; }
CORRADE_IGNORE_DEPRECATED_POP
}}
#endif

173
src/Magnum/Shapes/Collision.h

@ -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š <mosra@centrum.cz>
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<UnsignedInt dimensions> 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<dimensions, Float>& position, const VectorTypeFor<dimensions, Float>& separationNormal, Float separationDistance) noexcept: _position(position), _separationNormal(separationNormal), _separationDistance(separationDistance) {
CORRADE_ASSERT(_separationDistance < Math::TypeTraits<Float>::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<dimensions, Float> position() const {
return _position;
}
/**
* @brief Separation normal
*
* @see @ref separationDistance(), @ref flipped()
*/
VectorTypeFor<dimensions, Float> 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<dimensions> flipped() const {
return Collision<dimensions>(_position - _separationDistance*_separationNormal, -_separationNormal, _separationDistance);
}
private:
VectorTypeFor<dimensions, Float> _position;
VectorTypeFor<dimensions, Float> _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

160
src/Magnum/Shapes/Composition.cpp

@ -1,160 +0,0 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019
Vladimír Vondruš <mosra@centrum.cz>
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 <algorithm>
#include <Corrade/Utility/Assert.h>
#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<UnsignedInt dimensions> Composition<dimensions>::Composition(const Composition<dimensions>& other): _shapes(other._shapes.size()), _nodes(other._nodes.size()) {
copyShapes(0, other);
copyNodes(0, other);
}
template<UnsignedInt dimensions> Composition<dimensions>::Composition(Composition<dimensions>&& other): _shapes(std::move(other._shapes)), _nodes(std::move(other._nodes)) {
other._shapes = nullptr;
other._nodes = nullptr;
}
template<UnsignedInt dimensions> Composition<dimensions>::~Composition() {
for(std::size_t i = 0; i != _shapes.size(); ++i)
delete _shapes[i];
}
template<UnsignedInt dimensions> Composition<dimensions>& Composition<dimensions>::operator=(const Composition<dimensions>& other) {
for(std::size_t i = 0; i != _shapes.size(); ++i)
delete _shapes[i];
if(_shapes.size() != other._shapes.size())
_shapes = Containers::Array<Implementation::AbstractShape<dimensions>*>(other._shapes.size());
if(_nodes.size() != other._nodes.size())
_nodes = Containers::Array<Node>(other._nodes.size());
copyShapes(0, other);
copyNodes(0, other);
return *this;
}
template<UnsignedInt dimensions> Composition<dimensions>& Composition<dimensions>::operator=(Composition<dimensions>&& other) {
using std::swap;
swap(other._shapes, _shapes);
swap(other._nodes, _nodes);
return *this;
}
template<UnsignedInt dimensions> void Composition<dimensions>::copyShapes(const std::size_t offset, Composition<dimensions>&& 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<UnsignedInt dimensions> void Composition<dimensions>::copyShapes(const std::size_t offset, const Composition<dimensions>& other) {
CORRADE_INTERNAL_ASSERT(_shapes.size() >= other._shapes.size()+offset);
for(Implementation::AbstractShape<dimensions> * const* i = other._shapes.begin(), ** o = _shapes.begin()+offset; i != other._shapes.end(); ++i, ++o)
*o = (*i)->clone();
}
template<UnsignedInt dimensions> void Composition<dimensions>::copyNodes(std::size_t offset, const Composition<dimensions>& other) {
CORRADE_INTERNAL_ASSERT(_nodes.size() >= other._nodes.size()+offset);
std::copy(other._nodes.begin(), other._nodes.end(), _nodes.begin()+offset);
}
template<UnsignedInt dimensions> Composition<dimensions> Composition<dimensions>::transformed(const MatrixTypeFor<dimensions, Float>& matrix) const {
Composition<dimensions> out(*this);
for(Implementation::AbstractShape<dimensions> * const* i = _shapes.begin(), * const* o = out._shapes.begin(); i != _shapes.end(); ++i, ++o)
(*i)->transform(matrix, *o);
return out;
}
template<UnsignedInt dimensions> bool Composition<dimensions>::collides(const Implementation::AbstractShape<dimensions>& 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
}}

395
src/Magnum/Shapes/Composition.h

@ -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š <mosra@centrum.cz>
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 <type_traits>
#include <utility>
#include <Corrade/Containers/Array.h>
#include <Corrade/Utility/Assert.h>
#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<class> struct ShapeHelper;
template<UnsignedInt dimensions> inline AbstractShape<dimensions>& getAbstractShape(Composition<dimensions>& group, std::size_t i) {
return *group._shapes[i];
}
template<UnsignedInt dimensions> inline const AbstractShape<dimensions>& getAbstractShape(const Composition<dimensions>& 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<UnsignedInt dimensions> class CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") MAGNUM_SHAPES_EXPORT Composition {
friend Implementation::AbstractShape<dimensions>& Implementation::getAbstractShape<>(Composition<dimensions>&, std::size_t);
friend const Implementation::AbstractShape<dimensions>& Implementation::getAbstractShape<>(const Composition<dimensions>&, std::size_t);
friend Implementation::ShapeHelper<Composition<dimensions>>;
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<dimensions>::Type Type;
#endif
/**
* @brief Default constructor
*
* Creates empty composition.
*/
explicit Composition() {}
/**
* @brief Unary operation constructor
* @param operation Unary operation
* @param a Operand
*/
template<class T> explicit Composition(CompositionOperation operation, T&& a);
/**
* @brief Binary operation constructor
* @param operation Binary operation
* @param a Left operand
* @param b Right operand
*/
template<class T, class U> explicit Composition(CompositionOperation operation, T&& a, U&& b);
/** @brief Copy constructor */
Composition(const Composition<dimensions>& other);
/** @brief Move constructor */
Composition(Composition<dimensions>&& other);
~Composition();
/** @brief Assigment operator */
Composition<dimensions>& operator=(const Composition<dimensions>& other);
/** @brief Move assignment operator */
Composition<dimensions>& operator=(Composition<dimensions>&& other);
/** @brief Transformed shape */
Composition<dimensions> transformed(const MatrixTypeFor<dimensions, Float>& 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<class T> const T& get(std::size_t i) const;
/** @brief Collision with another shape */
#ifdef DOXYGEN_GENERATING_OUTPUT
template<class T> bool operator%(const T& other) const {
#else
template<class T> auto operator%(const T& other) const -> typename std::enable_if<std::is_same<decltype(Implementation::TypeOf<T>::type()), typename Implementation::ShapeDimensionTraits<dimensions>::Type>::value, bool>::type {
#endif
return collides(Implementation::Shape<T>(other));
}
private:
struct Node {
std::size_t rightNode, rightShape;
CompositionOperation operation;
};
bool collides(const Implementation::AbstractShape<dimensions>& a) const {
return collides(a, 0, 0, _shapes.size());
}
bool collides(const Implementation::AbstractShape<dimensions>& a, std::size_t node, std::size_t shapeBegin, std::size_t shapeEnd) const;
template<class T> constexpr static std::size_t shapeCount(const T&) {
return 1;
}
constexpr static std::size_t shapeCount(const Composition<dimensions>& hierarchy) {
return hierarchy._shapes.size();
}
template<class T> constexpr static std::size_t nodeCount(const T&) {
return 0;
}
constexpr static std::size_t nodeCount(const Composition<dimensions>& hierarchy) {
return hierarchy._nodes.size();
}
template<class T> void copyShapes(std::size_t offset, const T& shape) {
_shapes[offset] = new Implementation::Shape<T>(shape);
}
void copyShapes(std::size_t offset, Composition<dimensions>&& other);
void copyShapes(std::size_t offset, const Composition<dimensions>& other);
template<class T> void copyNodes(std::size_t, const T&) {}
void copyNodes(std::size_t offset, const Composition<dimensions>& other);
Containers::Array<Implementation::AbstractShape<dimensions>*> _shapes;
Containers::Array<Node> _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<UnsignedInt dimensions> Debug& operator<<(Debug& debug, typename Composition<dimensions>::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<UnsignedInt dimensions, class T> inline bool operator%(const T& a, const Composition<dimensions>& b) {
#else
template<UnsignedInt dimensions, class T> inline CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") auto operator%(const T& a, const Composition<dimensions>& b) -> typename std::enable_if<std::is_same<decltype(Implementation::TypeOf<T>::type()), typename Implementation::ShapeDimensionTraits<dimensions>::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<class T> inline CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") Composition<T::Dimensions> 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<class T> inline CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") Composition<T::Dimensions> 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<class T> inline CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") Composition<T::Dimensions> operator||(T a, T b);
#endif
#ifndef DOXYGEN_GENERATING_OUTPUT
#define enableIfIsShapeType typename std::enable_if< \
std::is_same<decltype(Implementation::TypeOf<T>::type()), typename Implementation::ShapeDimensionTraits<T::Dimensions>::Type>::value, \
Composition<T::Dimensions>>::type
#define enableIfAreShapeType typename std::enable_if< \
std::is_same<decltype(Implementation::TypeOf<T>::type()), typename Implementation::ShapeDimensionTraits<T::Dimensions>::Type>::value && \
std::is_same<decltype(Implementation::TypeOf<U>::type()), typename Implementation::ShapeDimensionTraits<T::Dimensions>::Type>::value, \
Composition<T::Dimensions>>::type
template<class T> inline CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") auto operator!(T&& a) -> enableIfIsShapeType {
return Composition<T::Dimensions>(CompositionOperation::Not, std::forward<T>(a));
}
template<class T, class U> inline CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") auto operator&&(T&& a, U&& b) -> enableIfAreShapeType {
return Composition<T::Dimensions>(CompositionOperation::And, std::forward<T>(a), std::forward<U>(b));
}
template<class T, class U> inline CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") auto operator||(T&& a, U&& b) -> enableIfAreShapeType {
return Composition<T::Dimensions>(CompositionOperation::Or, std::forward<T>(a), std::forward<U>(b));
}
#undef enableIfIsShapeType
#undef enableIfAreShapeType
#endif
template<UnsignedInt dimensions> template<class T> Composition<dimensions>::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<T>(a));
}
template<UnsignedInt dimensions> template<class T, class U> Composition<dimensions>::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<U>(b));
copyShapes(0, std::forward<T>(a));
}
template<UnsignedInt dimensions> template<class T> inline const T& Composition<dimensions>::get(std::size_t i) const {
CORRADE_ASSERT(_shapes[i]->type() == Implementation::TypeOf<T>::type(),
"Shapes::Composition::get(): given shape is not of type" << Implementation::TypeOf<T>::type() <<
"but" << _shapes[i]->type(), *static_cast<T*>(nullptr));
return static_cast<Implementation::Shape<T>*>(_shapes[i])->shape;
}
CORRADE_IGNORE_DEPRECATED_POP
}}
#endif

61
src/Magnum/Shapes/Cylinder.cpp

@ -1,61 +0,0 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019
Vladimír Vondruš <mosra@centrum.cz>
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<UnsignedInt dimensions> Cylinder<dimensions> Cylinder<dimensions>::transformed(const MatrixTypeFor<dimensions, Float>& matrix) const {
return Cylinder<dimensions>(matrix.transformPoint(_a), matrix.transformPoint(_b), matrix.uniformScaling()*_radius);
}
template<UnsignedInt dimensions> bool Cylinder<dimensions>::operator%(const Point<dimensions>& other) const {
return Math::Distance::linePointSquared(_a, _b, other.position()) <
Math::pow<2>(_radius);
}
template<UnsignedInt dimensions> bool Cylinder<dimensions>::operator%(const Sphere<dimensions>& 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
}}

178
src/Magnum/Shapes/Cylinder.h

@ -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š <mosra@centrum.cz>
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<UnsignedInt dimensions> 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<dimensions, Float>& a, const VectorTypeFor<dimensions, Float>& b, Float radius): _a(a), _b(b), _radius(radius) {}
/** @brief Transformed shape */
Cylinder<dimensions> transformed(const MatrixTypeFor<dimensions, Float>& matrix) const;
/** @brief First point */
constexpr VectorTypeFor<dimensions, Float> a() const {
return _a;
}
/** @brief Set first point */
void setA(const VectorTypeFor<dimensions, Float>& a) {
_a = a;
}
/** @brief Second point */
constexpr VectorTypeFor<dimensions, Float> b() const {
return _b;
}
/** @brief Set second point */
void setB(const VectorTypeFor<dimensions, Float>& 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<dimensions>& other) const;
/** @brief Collision occurence with sphere */
bool operator%(const Sphere<dimensions>& other) const;
private:
VectorTypeFor<dimensions, Float> _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<UnsignedInt dimensions> inline CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") bool operator%(const Point<dimensions>& a, const Cylinder<dimensions>& 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<UnsignedInt dimensions> inline CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") bool operator%(const Sphere<dimensions>& a, const Cylinder<dimensions>& b) { return b % a; }
CORRADE_IGNORE_DEPRECATED_POP
}}
#endif

133
src/Magnum/Shapes/Implementation/CollisionDispatch.cpp

@ -1,133 +0,0 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019
Vladimír Vondruš <mosra@centrum.cz>
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<const Shape<aClass>&>(a).shape % static_cast<const Shape<bClass>&>(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<const Shape<aClass>&>(a).shape / static_cast<const Shape<bClass>&>(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<const Shape<aClass>&>(a).shape % static_cast<const Shape<bClass>&>(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<const Shape<aClass>&>(a).shape / static_cast<const Shape<bClass>&>(b).shape;
_c(Sphere, Sphere3D, Point, Point3D)
_c(Sphere, Sphere3D, Sphere, Sphere3D)
#undef _c
}
return {};
}
CORRADE_IGNORE_DEPRECATED_POP
}}}

53
src/Magnum/Shapes/Implementation/CollisionDispatch.h

@ -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š <mosra@centrum.cz>
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<UnsignedInt> 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<UnsignedInt dimensions> bool collides(const AbstractShape<dimensions>& a, const AbstractShape<dimensions>& b);
template<UnsignedInt dimensions> Collision<dimensions> collision(const AbstractShape<dimensions>& a, const AbstractShape<dimensions>& b);
CORRADE_IGNORE_DEPRECATED_POP
}}}
#endif

48
src/Magnum/Shapes/Line.cpp

@ -1,48 +0,0 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019
Vladimír Vondruš <mosra@centrum.cz>
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<UnsignedInt dimensions> Line<dimensions> Line<dimensions>::transformed(const MatrixTypeFor<dimensions, Float>& matrix) const {
return Line<dimensions>(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
}}

138
src/Magnum/Shapes/Line.h

@ -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š <mosra@centrum.cz>
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<UnsignedInt dimensions> 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<dimensions, Float>& a, const typename DimensionTraits<dimensions, Float>::VectorType& b): _a(a), _b(b) {}
/** @brief Transformed shape */
Line<dimensions> transformed(const MatrixTypeFor<dimensions, Float>& matrix) const;
/** @brief First point */
constexpr VectorTypeFor<dimensions, Float> a() const {
return _a;
}
/** @brief Set first point */
void setA(const VectorTypeFor<dimensions, Float>& a) {
_a = a;
}
/** @brief Second point */
constexpr VectorTypeFor<dimensions, Float> b() const {
return _b;
}
/** @brief Set second point */
void setB(const VectorTypeFor<dimensions, Float>& b) {
_b = b;
}
private:
VectorTypeFor<dimensions, Float> _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

111
src/Magnum/Shapes/LineSegment.h

@ -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š <mosra@centrum.cz>
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<UnsignedInt dimensions> class CORRADE_DEPRECATED("scheduled for removal, see the docs for alternatives") LineSegment: public Line<dimensions> {
public:
/**
* @brief Default constructor
*
* Creates line segment with both points at origin.
*/
constexpr /*implicit*/ LineSegment() {}
/** @brief Constructor */
constexpr /*implicit*/ LineSegment(const VectorTypeFor<dimensions, Float>& a, const VectorTypeFor<dimensions, Float>& b): Line<dimensions>(a, b) {}
/** @brief Transformed shape */
LineSegment<dimensions> transformed(const MatrixTypeFor<dimensions, Float>& matrix) const {
return Line<dimensions>::transformed(matrix);
}
private:
constexpr LineSegment(const Line<dimensions>& line): Line<dimensions>(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

56
src/Magnum/Shapes/Plane.cpp

@ -1,56 +0,0 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019
Vladimír Vondruš <mosra@centrum.cz>
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
}}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save