diff --git a/CMakeLists.txt b/CMakeLists.txt index d98aa733b..e49cb0386 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,10 +35,10 @@ cmake_dependent_option(TARGET_DESKTOP_GLES "Build for OpenGL ES on desktop" OFF # Parts of the library option(WITH_DEBUGTOOLS "Build DebugTools library" ON) cmake_dependent_option(WITH_MESHTOOLS "Build MeshTools library" ON "NOT WITH_DEBUGTOOLS" ON) -cmake_dependent_option(WITH_PHYSICS "Build Physics library" ON "NOT WITH_DEBUGTOOLS" ON) cmake_dependent_option(WITH_PRIMITIVES "Builf Primitives library" ON "NOT WITH_DEBUGTOOLS" ON) -cmake_dependent_option(WITH_SCENEGRAPH "Build SceneGraph library" ON "NOT WITH_DEBUGTOOLS;NOT WITH_PHYSICS" ON) +cmake_dependent_option(WITH_SCENEGRAPH "Build SceneGraph library" ON "NOT WITH_DEBUGTOOLS;NOT WITH_SHAPES" ON) cmake_dependent_option(WITH_SHADERS "Build Shaders library" ON "NOT WITH_DEBUGTOOLS" ON) +cmake_dependent_option(WITH_SHAPES "Build Shapes library" ON "NOT WITH_DEBUGTOOLS" ON) option(WITH_TEXT "Build Text library" ON) cmake_dependent_option(WITH_TEXTURETOOLS "Build TextureTools library" ON "NOT WITH_TEXT" ON) option(WITH_MAGNUMINFO "Build magnum-info utility" ON) diff --git a/doc/building.dox b/doc/building.dox index 7b9132cf4..67f412056 100644 --- a/doc/building.dox +++ b/doc/building.dox @@ -97,17 +97,17 @@ below). Using `WITH_*` CMake parameters you can specify which parts will be buil and which not: - `WITH_DEBUGTOOLS` - DebugTools library. Enables also building of MeshTools, - Physics, Primitives, SceneGraph and Shaders libraries. + Primitives, SceneGraph, Shaders and Shapes libraries. - `WITH_MESHTOOLS` - MeshTools library. Enabled automatically if `WITH_DEBUGTOOLS` is enabled. - - `WITH_PHYSICS` - Physics library. Enables also building of SceneGraph - library. Enabled automatically if `WITH_DEBUGTOOLS` is enabled. - `WITH_PRIMITIVES` - Primitives library. Enabled automatically if `WITH_DEBUGTOOLS` is enabled. - `WITH_SCENEGRAPH` - SceneGraph library. Enabled automatically if `WITH_DEBUGTOOLS` - or `WITH_PHYSICS` is enabled. + or `WITH_SHAPES` is enabled. - `WITH_SHADERS` - Shaders library. Enabled automatically if `WITH_DEBUGTOOLS` is enabled. + - `WITH_SHAPES` - Shapes library. Enables also building of SceneGraph library. + Enabled automatically if `WITH_DEBUGTOOLS` is enabled. - `WITH_TEXT` - Text library. Enables also building of TextureTools library. - `WITH_TEXTURETOOLS` - TextureTools library. Enabled automatically if `WITH_TEXT` is enabled. diff --git a/doc/cmake.dox b/doc/cmake.dox index ad07c3acd..b23a19c51 100644 --- a/doc/cmake.dox +++ b/doc/cmake.dox @@ -51,13 +51,13 @@ components. The base library depends on %Corrade, OpenGL and GLEW libraries (or OpenGL ES libraries). Additional dependencies are specified by the components. The optional components are: -- `%DebugTools` -- DebugTools library (depends on `%MeshTools`, `%Physics`, - `%Primitives`, `%SceneGraph` and `%Shaders` components) +- `%DebugTools` -- DebugTools library (depends on `%MeshTools`, + `%Primitives`, `%SceneGraph`, `%Shaders` and `%Shapes` components) - `%MeshTools` -- MeshTools library -- `%Physics` -- Physics library (depends on `%SceneGraph` component) - `%Primitives` -- Primitives library - `%SceneGraph` -- SceneGraph library - `%Shaders` -- Shaders library +- `%Shapes` -- Shapes library (depends on `%SceneGraph` component) - `%Text` -- Text library (depends on `%TextureTools` component) - `%TextureTools` -- TextureTools library diff --git a/doc/coding-style.dox b/doc/coding-style.dox index 68a8ea39f..a5ed9e5d8 100644 --- a/doc/coding-style.dox +++ b/doc/coding-style.dox @@ -100,9 +100,9 @@ void setPolygonMode(PolygonMode mode); Additionally to @c \@todoc, @c \@debugoperator @c \@configurationvalue and @c \@configurationvalueref (same as in Corrade), these are defined: -@subsubsection documentation-commands-collisionoperator Physics collision operators +@subsubsection documentation-commands-collisionoperator Shape collision operators -Out-of-class operators for collision in Physics namespace should be marked with +Out-of-class operators for collision in Shapes namespace should be marked with @c \@collisionoperator, e.g.: @code // @collisionoperator{Point,Sphere} diff --git a/doc/collision-detection.dox b/doc/collision-detection.dox index e263492a0..1288c2b8b 100644 --- a/doc/collision-detection.dox +++ b/doc/collision-detection.dox @@ -22,7 +22,7 @@ DEALINGS IN THE SOFTWARE. */ -namespace Magnum { namespace Physics { +namespace Magnum { namespace Shapes { /** @page collision-detection Collision detection @brief Collection of simple shapes for high performance collision detection. @@ -37,23 +37,23 @@ together using various operations. @subsection collision-detection-shapes1D One-dimensional shapes -- @ref Physics::Point "Physics::Point*D" - @copybrief Physics::Point -- @ref Physics::Line "Physics::Line*D" - @copybrief Physics::Line -- @ref Physics::LineSegment "Physics::LineSegment*D" - @copybrief Physics::LineSegment +- @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 collision-detection-shapes2D Two-dimensional shapes -- Physics::Plane - @copybrief Physics::Plane +- Shapes::Plane - @copybrief Shapes::Plane @subsection collision-detection-shapes3D Three-dimensional shapes -- @ref Physics::Sphere "Physics::Sphere*D" - @copybrief Physics::Sphere -- @ref Physics::Capsule "Physics::Capsule*D" - @copybrief Physics::Capsule -- @ref Physics::AxisAlignedBox "Physics::AxisAlignedBox*D" - @copybrief Physics::AxisAlignedBox -- @ref Physics::Box "Physics::Box*D" - @copybrief Physics::Box +- @ref Shapes::Sphere "Shapes::Sphere*D" - @copybrief Shapes::Sphere +- @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 @@ -66,10 +66,10 @@ operations: AND, OR and NOT. These operations are mapped to operator&&(), operator||() and operator!(), so for example creating negation of logical OR of line segment and point is simple as this: @code -Physics::LineSegment3D segment; -Physics::Point3D point; +Shapes::LineSegment3D segment; +Shapes::Point3D point; -Physics::ShapeGroup3D group = !(segment || point); +Shapes::ShapeGroup3D group = !(segment || point); @endcode @note Logical operations are not the same as set operations -- intersection of @@ -90,10 +90,10 @@ was not possible to change their properties such as sphere radius without recreating the group again. You can, however, explicitly pass a reference to original object, so you can change it later: @code -Physics::LineSegment3D segment; -Physics::Point3D point; +Shapes::LineSegment3D segment; +Shapes::Point3D point; -Physics::ShapeGroup3D group = !(segment || std::ref(point)); +Shapes::ShapeGroup3D group = !(segment || std::ref(point)); point.setPosition({1.0f, -6.0f, 0.5f}); @endcode @@ -112,11 +112,11 @@ was detected with the simplified shape. It is in fact logical AND using operator&&() - the collision is initially detected on first (simplified) shape and then on the other: @code -Physics::Sphere3D sphere; -Physics::Box3D box; -Physics::AxisAlignedBox3D simplified; +Shapes::Sphere3D sphere; +Shapes::Box3D box; +Shapes::AxisAlignedBox3D simplified; -Physics::ShapeGroup3D object = simplified && (sphere || box); +Shapes::ShapeGroup3D object = simplified && (sphere || box); @endcode @section collision-detection-shape-collisions Detecting shape collisions @@ -124,8 +124,8 @@ Physics::ShapeGroup3D object = simplified && (sphere || box); Shape pairs which have collision detection implemented can be tested for collision using operator%(), for example: @code -Physics::Point3D point; -Physics::Sphere3D sphere; +Shapes::Point3D point; +Shapes::Sphere3D sphere; bool collide = point % sphere; @endcode diff --git a/doc/compilation-speedup.dox b/doc/compilation-speedup.dox index f05196e0a..efdd3db0a 100644 --- a/doc/compilation-speedup.dox +++ b/doc/compilation-speedup.dox @@ -46,9 +46,9 @@ available, each namespace has its own: - Math/Math.h - Magnum.h - DebugTools/DebugTools.h - - Physics/Physics.h - SceneGraph/SceneGraph.h - Shaders/Shaders.h + - Shapes/Shapes.h - Text/Text.h - Trade/Trade.h diff --git a/doc/namespaces.dox b/doc/namespaces.dox index e60a77c03..ba44f7f93 100644 --- a/doc/namespaces.dox +++ b/doc/namespaces.dox @@ -155,16 +155,15 @@ This library is built when `WITH_SHADERS` is enabled and found as `%Shaders` component in CMake. See @ref building and @ref cmake for more information. */ -/** @dir Physics - * @brief Namespace Magnum::Physics +/** @dir Shapes + * @brief Namespace Magnum::Shapes */ -/** @namespace Magnum::Physics -@brief %Physics library +/** @namespace Magnum::Shapes +@brief %Shape library -Collision detection system and rigid body objects. See @ref collision-detection -for introduction. +Collision detection system. See @ref collision-detection for introduction. -This library is built when `WITH_PHYSICS` is enabled and found as `%Physics` +This library is built when `WITH_SHAPES` is enabled and found as `%Shapes` component in CMake. See @ref building and @ref cmake for more information. */ diff --git a/modules/FindMagnum.cmake b/modules/FindMagnum.cmake index fbfe1387f..7c871037a 100644 --- a/modules/FindMagnum.cmake +++ b/modules/FindMagnum.cmake @@ -14,13 +14,13 @@ # components. The base library depends on Corrade, OpenGL and GLEW # libraries. Additional dependencies are specified by the components. The # optional components are: -# DebugTools - DebugTools library (depends on MeshTools, Physics, -# Primitives, SceneGraph and Shaders components) +# DebugTools - DebugTools library (depends on MeshTools, Primitives, +# SceneGraph, Shaders and Shapes components) # MeshTools - MeshTools library -# Physics - Physics library (depends on SceneGraph component) # Primitives - Primitives library # SceneGraph - SceneGraph library # Shaders - Shaders library +# Shapes - Shapes library (depends on SceneGraph component) # Text - Text library (depends on TextureTools component) # TextureTools - TextureTools library # GlutApplication - GLUT application (depends on GLUT library) @@ -232,11 +232,6 @@ foreach(component ${Magnum_FIND_COMPONENTS}) set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES CompressIndices.h) endif() - # Physics library - if(${component} STREQUAL Physics) - set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES Physics.h) - endif() - # Primitives library if(${component} STREQUAL Primitives) set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES Cube.h) @@ -252,6 +247,11 @@ foreach(component ${Magnum_FIND_COMPONENTS}) set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES Shaders.h) endif() + # Shapes library + if(${component} STREQUAL Shapes) + set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES Shapes.h) + endif() + # Text library if(${component} STREQUAL Text) set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES Text.h) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0ae0fee42..dd3d4661f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -194,10 +194,6 @@ if(WITH_MESHTOOLS) add_subdirectory(MeshTools) endif() -if(WITH_PHYSICS) - add_subdirectory(Physics) -endif() - if(WITH_PRIMITIVES) add_subdirectory(Primitives) endif() @@ -210,6 +206,10 @@ if(WITH_SHADERS) add_subdirectory(Shaders) endif() +if(WITH_SHAPES) + add_subdirectory(Shapes) +endif() + if(WITH_TEXT) add_subdirectory(Text) endif() diff --git a/src/DebugTools/CMakeLists.txt b/src/DebugTools/CMakeLists.txt index bbad443ce..8295748fe 100644 --- a/src/DebugTools/CMakeLists.txt +++ b/src/DebugTools/CMakeLists.txt @@ -55,10 +55,10 @@ endif() target_link_libraries(MagnumDebugTools Magnum MagnumMeshTools - MagnumPhysics MagnumPrimitives MagnumSceneGraph - MagnumShaders) + MagnumShaders + MagnumShapes) install(TARGETS MagnumDebugTools DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) install(FILES ${MagnumDebugTools_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/DebugTools) diff --git a/src/DebugTools/Implementation/AbstractShapeRenderer.h b/src/DebugTools/Implementation/AbstractShapeRenderer.h index a20134871..bbc96185b 100644 --- a/src/DebugTools/Implementation/AbstractShapeRenderer.h +++ b/src/DebugTools/Implementation/AbstractShapeRenderer.h @@ -33,7 +33,7 @@ namespace Magnum { -namespace Physics { namespace Implementation { +namespace Shapes { namespace Implementation { template struct AbstractShape; }} diff --git a/src/DebugTools/Implementation/AxisAlignedBoxRenderer.cpp b/src/DebugTools/Implementation/AxisAlignedBoxRenderer.cpp index 00ac739f6..faaf5cb5c 100644 --- a/src/DebugTools/Implementation/AxisAlignedBoxRenderer.cpp +++ b/src/DebugTools/Implementation/AxisAlignedBoxRenderer.cpp @@ -26,12 +26,12 @@ #include "Mesh.h" #include "DebugTools/ShapeRenderer.h" -#include "Physics/AxisAlignedBox.h" +#include "Shapes/AxisAlignedBox.h" #include "Shaders/Flat.h" namespace Magnum { namespace DebugTools { namespace Implementation { -template AxisAlignedBoxRenderer::AxisAlignedBoxRenderer(const Physics::Implementation::AbstractShape* axisAlignedBox): axisAlignedBox(static_cast>*>(axisAlignedBox)->shape) {} +template AxisAlignedBoxRenderer::AxisAlignedBoxRenderer(const Shapes::Implementation::AbstractShape* axisAlignedBox): axisAlignedBox(static_cast>*>(axisAlignedBox)->shape) {} template void AxisAlignedBoxRenderer::draw(Resource& options, const typename DimensionTraits::MatrixType& projectionMatrix) { this->wireframeShader->setTransformationProjectionMatrix(projectionMatrix* diff --git a/src/DebugTools/Implementation/AxisAlignedBoxRenderer.h b/src/DebugTools/Implementation/AxisAlignedBoxRenderer.h index fe59ca713..2af4617cd 100644 --- a/src/DebugTools/Implementation/AxisAlignedBoxRenderer.h +++ b/src/DebugTools/Implementation/AxisAlignedBoxRenderer.h @@ -26,7 +26,7 @@ #include "AbstractBoxRenderer.h" -#include "Physics/Physics.h" +#include "Shapes/Shapes.h" #include "corradeCompatibility.h" @@ -34,12 +34,12 @@ namespace Magnum { namespace DebugTools { namespace Implementation { template class AxisAlignedBoxRenderer: public AbstractBoxRenderer { public: - AxisAlignedBoxRenderer(const Physics::Implementation::AbstractShape* axisAlignedBox); + AxisAlignedBoxRenderer(const Shapes::Implementation::AbstractShape* axisAlignedBox); void draw(Resource& options, const typename DimensionTraits::MatrixType& projectionMatrix) override; private: - const Physics::AxisAlignedBox& axisAlignedBox; + const Shapes::AxisAlignedBox& axisAlignedBox; }; }}} diff --git a/src/DebugTools/Implementation/BoxRenderer.cpp b/src/DebugTools/Implementation/BoxRenderer.cpp index 4b515883b..87b64ae26 100644 --- a/src/DebugTools/Implementation/BoxRenderer.cpp +++ b/src/DebugTools/Implementation/BoxRenderer.cpp @@ -26,12 +26,12 @@ #include "Mesh.h" #include "DebugTools/ShapeRenderer.h" -#include "Physics/Box.h" +#include "Shapes/Box.h" #include "Shaders/Flat.h" namespace Magnum { namespace DebugTools { namespace Implementation { -template BoxRenderer::BoxRenderer(const Physics::Implementation::AbstractShape* box): box(static_cast>*>(box)->shape) {} +template BoxRenderer::BoxRenderer(const Shapes::Implementation::AbstractShape* box): box(static_cast>*>(box)->shape) {} template void BoxRenderer::draw(Resource& options, const typename DimensionTraits::MatrixType& projectionMatrix) { this->wireframeShader->setTransformationProjectionMatrix(projectionMatrix*box.transformation()) diff --git a/src/DebugTools/Implementation/BoxRenderer.h b/src/DebugTools/Implementation/BoxRenderer.h index 0f93b9a4a..20afc7ee9 100644 --- a/src/DebugTools/Implementation/BoxRenderer.h +++ b/src/DebugTools/Implementation/BoxRenderer.h @@ -26,7 +26,7 @@ #include "AbstractBoxRenderer.h" -#include "Physics/Physics.h" +#include "Shapes/Shapes.h" #include "corradeCompatibility.h" @@ -34,12 +34,12 @@ namespace Magnum { namespace DebugTools { namespace Implementation { template class BoxRenderer: public AbstractBoxRenderer { public: - BoxRenderer(const Physics::Implementation::AbstractShape* box); + BoxRenderer(const Shapes::Implementation::AbstractShape* box); void draw(Resource& options, const typename DimensionTraits::MatrixType& projectionMatrix) override; private: - const Physics::Box& box; + const Shapes::Box& box; }; }}} diff --git a/src/DebugTools/Implementation/LineSegmentRenderer.cpp b/src/DebugTools/Implementation/LineSegmentRenderer.cpp index 51fc909ad..4436c3064 100644 --- a/src/DebugTools/Implementation/LineSegmentRenderer.cpp +++ b/src/DebugTools/Implementation/LineSegmentRenderer.cpp @@ -26,7 +26,7 @@ #include "Mesh.h" #include "DebugTools/ShapeRenderer.h" -#include "Physics/LineSegment.h" +#include "Shapes/LineSegment.h" #include "Primitives/Line.h" #include "Shaders/Flat.h" #include "Trade/MeshData2D.h" @@ -50,7 +50,7 @@ namespace { template<> inline Trade::MeshData3D meshData<3>() { return Primitives::Line3D::wireframe(); } } -template LineSegmentRenderer::LineSegmentRenderer(const Physics::Implementation::AbstractShape* line): AbstractShapeRenderer(meshKey(), vertexBufferKey(), {}), line(static_cast>*>(line)->shape) { +template LineSegmentRenderer::LineSegmentRenderer(const Shapes::Implementation::AbstractShape* line): AbstractShapeRenderer(meshKey(), vertexBufferKey(), {}), line(static_cast>*>(line)->shape) { if(!this->wireframeMesh) this->createResources(meshData()); } diff --git a/src/DebugTools/Implementation/LineSegmentRenderer.h b/src/DebugTools/Implementation/LineSegmentRenderer.h index 2152cefd3..550557dc9 100644 --- a/src/DebugTools/Implementation/LineSegmentRenderer.h +++ b/src/DebugTools/Implementation/LineSegmentRenderer.h @@ -26,7 +26,7 @@ #include "AbstractShapeRenderer.h" -#include "Physics/Physics.h" +#include "Shapes/Shapes.h" #include "corradeCompatibility.h" @@ -34,12 +34,12 @@ namespace Magnum { namespace DebugTools { namespace Implementation { template class LineSegmentRenderer: public AbstractShapeRenderer { public: - LineSegmentRenderer(const Physics::Implementation::AbstractShape* line); + LineSegmentRenderer(const Shapes::Implementation::AbstractShape* line); void draw(Resource& options, const typename DimensionTraits::MatrixType& projectionMatrix) override; private: - const Physics::LineSegment& line; + const Shapes::LineSegment& line; }; }}} diff --git a/src/DebugTools/Implementation/PointRenderer.cpp b/src/DebugTools/Implementation/PointRenderer.cpp index c1799ac64..7827ca856 100644 --- a/src/DebugTools/Implementation/PointRenderer.cpp +++ b/src/DebugTools/Implementation/PointRenderer.cpp @@ -26,7 +26,7 @@ #include "Mesh.h" #include "DebugTools/ShapeRenderer.h" -#include "Physics/Point.h" +#include "Shapes/Point.h" #include "Primitives/Crosshair.h" #include "Shaders/Flat.h" #include "Trade/MeshData2D.h" @@ -48,7 +48,7 @@ namespace { template<> inline Trade::MeshData3D meshData<3>() { return Primitives::Crosshair3D::wireframe(); } } -template PointRenderer::PointRenderer(const Physics::Implementation::AbstractShape* point): AbstractShapeRenderer(meshKey(), vertexBufferKey(), {}), point(static_cast>*>(point)->shape) { +template PointRenderer::PointRenderer(const Shapes::Implementation::AbstractShape* point): AbstractShapeRenderer(meshKey(), vertexBufferKey(), {}), point(static_cast>*>(point)->shape) { if(!this->wireframeMesh) this->createResources(meshData()); } diff --git a/src/DebugTools/Implementation/PointRenderer.h b/src/DebugTools/Implementation/PointRenderer.h index 4aeea85b9..a017c1649 100644 --- a/src/DebugTools/Implementation/PointRenderer.h +++ b/src/DebugTools/Implementation/PointRenderer.h @@ -26,7 +26,7 @@ #include "AbstractShapeRenderer.h" -#include "Physics/Physics.h" +#include "Shapes/Shapes.h" #include "corradeCompatibility.h" @@ -34,12 +34,12 @@ namespace Magnum { namespace DebugTools { namespace Implementation { template class PointRenderer: public AbstractShapeRenderer { public: - PointRenderer(const Physics::Implementation::AbstractShape* point); + PointRenderer(const Shapes::Implementation::AbstractShape* point); void draw(Resource& options, const typename DimensionTraits::MatrixType& projectionMatrix) override; private: - const Physics::Point& point; + const Shapes::Point& point; }; }}} diff --git a/src/DebugTools/Implementation/SphereRenderer.cpp b/src/DebugTools/Implementation/SphereRenderer.cpp index 859fe6120..3649d05b0 100644 --- a/src/DebugTools/Implementation/SphereRenderer.cpp +++ b/src/DebugTools/Implementation/SphereRenderer.cpp @@ -26,7 +26,7 @@ #include "Mesh.h" #include "DebugTools/ShapeRenderer.h" -#include "Physics/Sphere.h" +#include "Shapes/Sphere.h" #include "Primitives/Circle.h" #include "Shaders/Flat.h" #include "Trade/MeshData2D.h" @@ -37,7 +37,7 @@ AbstractSphereRenderer<2>::AbstractSphereRenderer(): AbstractShapeRenderer<2>("s if(!wireframeMesh) createResources(Primitives::Circle::wireframe(40)); } -template SphereRenderer::SphereRenderer(const Physics::Implementation::AbstractShape* sphere): sphere(static_cast>*>(sphere)->shape) {} +template SphereRenderer::SphereRenderer(const Shapes::Implementation::AbstractShape* sphere): sphere(static_cast>*>(sphere)->shape) {} template void SphereRenderer::draw(Resource& options, const typename DimensionTraits::MatrixType& projectionMatrix) { this->wireframeShader->setTransformationProjectionMatrix(projectionMatrix* diff --git a/src/DebugTools/Implementation/SphereRenderer.h b/src/DebugTools/Implementation/SphereRenderer.h index 4822ee899..3c1a89649 100644 --- a/src/DebugTools/Implementation/SphereRenderer.h +++ b/src/DebugTools/Implementation/SphereRenderer.h @@ -26,7 +26,7 @@ #include "AbstractShapeRenderer.h" -#include "Physics/Physics.h" +#include "Shapes/Shapes.h" #include "corradeCompatibility.h" @@ -41,12 +41,12 @@ template<> class AbstractSphereRenderer<2>: public AbstractShapeRenderer<2> { template class SphereRenderer: public AbstractSphereRenderer { public: - SphereRenderer(const Physics::Implementation::AbstractShape* sphere); + SphereRenderer(const Shapes::Implementation::AbstractShape* sphere); void draw(Resource& options, const typename DimensionTraits::MatrixType& projectionMatrix) override; private: - const Physics::Sphere& sphere; + const Shapes::Sphere& sphere; }; }}} diff --git a/src/DebugTools/ResourceManager.h b/src/DebugTools/ResourceManager.h index 3820cbcea..ccf907718 100644 --- a/src/DebugTools/ResourceManager.h +++ b/src/DebugTools/ResourceManager.h @@ -36,7 +36,7 @@ #include "../ResourceManager.h" #include "SceneGraph/SceneGraph.h" -#include "Physics/Physics.h" +#include "Shapes/Shapes.h" #include "DebugTools.h" #include "magnumDebugToolsVisibility.h" diff --git a/src/DebugTools/ShapeRenderer.cpp b/src/DebugTools/ShapeRenderer.cpp index c205d5d7a..eaaefe838 100644 --- a/src/DebugTools/ShapeRenderer.cpp +++ b/src/DebugTools/ShapeRenderer.cpp @@ -25,8 +25,8 @@ #include "ShapeRenderer.h" #include "ResourceManager.h" -#include "Physics/Composition.h" -#include "Physics/Shape.h" +#include "Shapes/Composition.h" +#include "Shapes/Shape.h" #include "SceneGraph/AbstractCamera.h" #include "Implementation/AxisAlignedBoxRenderer.h" @@ -39,27 +39,27 @@ namespace Magnum { namespace DebugTools { namespace Implementation { -template<> void createDebugMesh(ShapeRenderer<2>* renderer, const Physics::Implementation::AbstractShape<2>* shape) { +template<> void createDebugMesh(ShapeRenderer<2>* renderer, const Shapes::Implementation::AbstractShape<2>* shape) { switch(shape->type()) { - case Physics::AbstractShape2D::Type::AxisAlignedBox: + case Shapes::AbstractShape2D::Type::AxisAlignedBox: renderer->renderers.push_back(new Implementation::AxisAlignedBoxRenderer<2>(shape)); break; - case Physics::AbstractShape2D::Type::Box: + case Shapes::AbstractShape2D::Type::Box: renderer->renderers.push_back(new Implementation::BoxRenderer<2>(shape)); break; - case Physics::AbstractShape2D::Type::LineSegment: + case Shapes::AbstractShape2D::Type::LineSegment: renderer->renderers.push_back(new Implementation::LineSegmentRenderer<2>(shape)); break; - case Physics::AbstractShape2D::Type::Point: + case Shapes::AbstractShape2D::Type::Point: renderer->renderers.push_back(new Implementation::PointRenderer<2>(shape)); break; - case Physics::AbstractShape2D::Type::Composition: { - const Physics::Composition2D& composition = - static_cast*>(shape)->shape; + case Shapes::AbstractShape2D::Type::Composition: { + const Shapes::Composition2D& composition = + static_cast*>(shape)->shape; for(std::size_t i = 0; i != composition.size(); ++i) - createDebugMesh(renderer, Physics::Implementation::getAbstractShape(composition, i)); + createDebugMesh(renderer, Shapes::Implementation::getAbstractShape(composition, i)); } break; - case Physics::AbstractShape2D::Type::Sphere: + case Shapes::AbstractShape2D::Type::Sphere: renderer->renderers.push_back(new Implementation::SphereRenderer<2>(shape)); break; default: @@ -67,25 +67,25 @@ template<> void createDebugMesh(ShapeRenderer<2>* renderer, const Physics::Imple } } -template<> void createDebugMesh(ShapeRenderer<3>* renderer, const Physics::Implementation::AbstractShape<3>* shape) { +template<> void createDebugMesh(ShapeRenderer<3>* renderer, const Shapes::Implementation::AbstractShape<3>* shape) { switch(shape->type()) { - case Physics::AbstractShape3D::Type::AxisAlignedBox: + case Shapes::AbstractShape3D::Type::AxisAlignedBox: renderer->renderers.push_back(new Implementation::AxisAlignedBoxRenderer<3>(shape)); break; - case Physics::AbstractShape3D::Type::Box: + case Shapes::AbstractShape3D::Type::Box: renderer->renderers.push_back(new Implementation::BoxRenderer<3>(shape)); break; - case Physics::AbstractShape3D::Type::LineSegment: + case Shapes::AbstractShape3D::Type::LineSegment: renderer->renderers.push_back(new Implementation::LineSegmentRenderer<3>(shape)); break; - case Physics::AbstractShape3D::Type::Point: + case Shapes::AbstractShape3D::Type::Point: renderer->renderers.push_back(new Implementation::PointRenderer<3>(shape)); break; - case Physics::AbstractShape3D::Type::Composition: { - const Physics::Composition3D& composition = - static_cast*>(shape)->shape; + case Shapes::AbstractShape3D::Type::Composition: { + const Shapes::Composition3D& composition = + static_cast*>(shape)->shape; for(std::size_t i = 0; i != composition.size(); ++i) - createDebugMesh(renderer, Physics::Implementation::getAbstractShape(composition, i)); + createDebugMesh(renderer, Shapes::Implementation::getAbstractShape(composition, i)); } break; default: Warning() << "DebugTools::ShapeRenderer3D::createShapeRenderer(): type" << shape->type() << "not implemented"; @@ -94,8 +94,8 @@ template<> void createDebugMesh(ShapeRenderer<3>* renderer, const Physics::Imple } -template ShapeRenderer::ShapeRenderer(Physics::AbstractShape* shape, ResourceKey options, SceneGraph::DrawableGroup* drawables): SceneGraph::Drawable(shape->object(), drawables), options(ResourceManager::instance()->get(options)) { - Implementation::createDebugMesh(this, Physics::Implementation::getAbstractShape(shape)); +template ShapeRenderer::ShapeRenderer(Shapes::AbstractShape* shape, ResourceKey options, SceneGraph::DrawableGroup* drawables): SceneGraph::Drawable(shape->object(), drawables), options(ResourceManager::instance()->get(options)) { + Implementation::createDebugMesh(this, Shapes::Implementation::getAbstractShape(shape)); } template ShapeRenderer::~ShapeRenderer() { diff --git a/src/DebugTools/ShapeRenderer.h b/src/DebugTools/ShapeRenderer.h index 17561b609..2e2ba75d0 100644 --- a/src/DebugTools/ShapeRenderer.h +++ b/src/DebugTools/ShapeRenderer.h @@ -31,8 +31,8 @@ #include "Color.h" #include "Resource.h" #include "SceneGraph/Drawable.h" -#include "Physics/Physics.h" -#include "Physics/shapeImplementation.h" +#include "Shapes/Shapes.h" +#include "Shapes/shapeImplementation.h" #include "magnumDebugToolsVisibility.h" @@ -46,7 +46,7 @@ template class ShapeRenderer; namespace Implementation { template class AbstractShapeRenderer; - template void createDebugMesh(ShapeRenderer* renderer, const Physics::Implementation::AbstractShape* shape); + template void createDebugMesh(ShapeRenderer* renderer, const Shapes::Implementation::AbstractShape* shape); } /** @@ -103,7 +103,7 @@ class ShapeRendererOptions { * @brief Set point size * @return Pointer to self (for method chaining) * - * Size of rendered crosshairs, representing Physics::Point shapes. + * Size of rendered crosshairs, representing Shapes::Point shapes. * Default is `0.25f`. */ inline ShapeRendererOptions* setPointSize(Float size) { @@ -132,14 +132,14 @@ DebugTools::ResourceManager::instance()->set("red", (new DebugTools::ShapeRender ->setColor({1.0f, 0.0f, 0.0f})); // Create debug renderer for given shape, use "red" options for it -Physics::ObjectShape2D* shape; +Shapes::ObjectShape2D* shape; new DebugTools::ShapeRenderer2D(shape, "red", debugDrawables); @endcode @see ShapeRenderer2D, ShapeRenderer3D */ template class MAGNUM_DEBUGTOOLS_EXPORT ShapeRenderer: public SceneGraph::Drawable { - friend void Implementation::createDebugMesh<>(ShapeRenderer*, const Physics::Implementation::AbstractShape*); + friend void Implementation::createDebugMesh<>(ShapeRenderer*, const Shapes::Implementation::AbstractShape*); public: /** @@ -154,7 +154,7 @@ template class MAGNUM_DEBUGTOOLS_EXPORT ShapeRenderer: p * @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(Physics::AbstractShape* shape, ResourceKey options = ResourceKey(), SceneGraph::DrawableGroup* drawables = nullptr); + explicit ShapeRenderer(Shapes::AbstractShape* shape, ResourceKey options = ResourceKey(), SceneGraph::DrawableGroup* drawables = nullptr); ~ShapeRenderer(); diff --git a/src/Physics/AbstractShape.cpp b/src/Shapes/AbstractShape.cpp similarity index 91% rename from src/Physics/AbstractShape.cpp rename to src/Shapes/AbstractShape.cpp index 08cd192ac..5a7ae3342 100644 --- a/src/Physics/AbstractShape.cpp +++ b/src/Shapes/AbstractShape.cpp @@ -26,10 +26,10 @@ #include -#include "Physics/ShapeGroup.h" -#include "Physics/Implementation/CollisionDispatch.h" +#include "Shapes/ShapeGroup.h" +#include "Shapes/Implementation/CollisionDispatch.h" -namespace Magnum { namespace Physics { +namespace Magnum { namespace Shapes { template AbstractShape::AbstractShape(SceneGraph::AbstractObject* object, ShapeGroup* group): SceneGraph::AbstractGroupedFeature>(object, group) { this->setCachedTransformations(SceneGraph::AbstractFeature::CachedTransformation::Absolute); @@ -56,8 +56,8 @@ template void AbstractShape::markDirty() { } #ifndef DOXYGEN_GENERATING_OUTPUT -template class MAGNUM_PHYSICS_EXPORT AbstractShape<2>; -template class MAGNUM_PHYSICS_EXPORT AbstractShape<3>; +template class MAGNUM_SHAPES_EXPORT AbstractShape<2>; +template class MAGNUM_SHAPES_EXPORT AbstractShape<3>; #endif }} diff --git a/src/Physics/AbstractShape.h b/src/Shapes/AbstractShape.h similarity index 85% rename from src/Physics/AbstractShape.h rename to src/Shapes/AbstractShape.h index 6d1ada5ab..7df35692e 100644 --- a/src/Physics/AbstractShape.h +++ b/src/Shapes/AbstractShape.h @@ -1,5 +1,5 @@ -#ifndef Magnum_Physics_AbstractShape_h -#define Magnum_Physics_AbstractShape_h +#ifndef Magnum_Shapes_AbstractShape_h +#define Magnum_Shapes_AbstractShape_h /* This file is part of Magnum. @@ -25,19 +25,19 @@ */ /** @file - * @brief Class Magnum::Physics::AbstractShape, typedef Magnum::Physics::AbstractShape2D, Magnum::Physics::AbstractShape3D + * @brief Class Magnum::Shapes::AbstractShape, typedef Magnum::Shapes::AbstractShape2D, Magnum::Shapes::AbstractShape3D */ #include "Magnum.h" #include "DimensionTraits.h" -#include "Physics/magnumPhysicsVisibility.h" -#include "Physics/shapeImplementation.h" +#include "Shapes/magnumShapesVisibility.h" +#include "Shapes/shapeImplementation.h" #include "SceneGraph/AbstractGroupedFeature.h" -namespace Magnum { namespace Physics { +namespace Magnum { namespace Shapes { namespace Implementation { - template inline const AbstractShape* getAbstractShape(const Physics::AbstractShape* shape) { + template inline const AbstractShape* getAbstractShape(const Shapes::AbstractShape* shape) { return shape->abstractTransformedShape(); } } @@ -48,7 +48,7 @@ namespace Implementation { This class is not directly instantiable, see Shape instead. @see AbstractShape2D, AbstractShape3D */ -template class MAGNUM_PHYSICS_EXPORT AbstractShape: public SceneGraph::AbstractGroupedFeature> { +template class MAGNUM_SHAPES_EXPORT AbstractShape: public SceneGraph::AbstractGroupedFeature> { friend const Implementation::AbstractShape* Implementation::getAbstractShape<>(const AbstractShape*); public: @@ -105,7 +105,7 @@ template class MAGNUM_PHYSICS_EXPORT AbstractShape: publ void markDirty() override; private: - virtual const Implementation::AbstractShape MAGNUM_PHYSICS_LOCAL * abstractTransformedShape() const = 0; + virtual const Implementation::AbstractShape MAGNUM_SHAPES_LOCAL * abstractTransformedShape() const = 0; }; /** @brief Base class for two-dimensional object shapes */ diff --git a/src/Physics/AxisAlignedBox.cpp b/src/Shapes/AxisAlignedBox.cpp similarity index 91% rename from src/Physics/AxisAlignedBox.cpp rename to src/Shapes/AxisAlignedBox.cpp index c4ea7e9bb..d5474755f 100644 --- a/src/Physics/AxisAlignedBox.cpp +++ b/src/Shapes/AxisAlignedBox.cpp @@ -26,9 +26,9 @@ #include "Math/Matrix3.h" #include "Math/Matrix4.h" -#include "Physics/Point.h" +#include "Shapes/Point.h" -namespace Magnum { namespace Physics { +namespace Magnum { namespace Shapes { template AxisAlignedBox AxisAlignedBox::transformed(const typename DimensionTraits::MatrixType& matrix) const { return AxisAlignedBox(matrix.transformPoint(_min), @@ -41,8 +41,8 @@ template bool AxisAlignedBox::operator%(cons } #ifndef DOXYGEN_GENERATING_OUTPUT -template class MAGNUM_PHYSICS_EXPORT AxisAlignedBox<2>; -template class MAGNUM_PHYSICS_EXPORT AxisAlignedBox<3>; +template class MAGNUM_SHAPES_EXPORT AxisAlignedBox<2>; +template class MAGNUM_SHAPES_EXPORT AxisAlignedBox<3>; #endif }} diff --git a/src/Physics/AxisAlignedBox.h b/src/Shapes/AxisAlignedBox.h similarity index 89% rename from src/Physics/AxisAlignedBox.h rename to src/Shapes/AxisAlignedBox.h index 7b20e215f..174596f06 100644 --- a/src/Physics/AxisAlignedBox.h +++ b/src/Shapes/AxisAlignedBox.h @@ -1,5 +1,5 @@ -#ifndef Magnum_Physics_AxisAlignedBox_h -#define Magnum_Physics_AxisAlignedBox_h +#ifndef Magnum_Shapes_AxisAlignedBox_h +#define Magnum_Shapes_AxisAlignedBox_h /* This file is part of Magnum. @@ -25,15 +25,15 @@ */ /** @file - * @brief Class Magnum::Physics::AxisAlignedBox, typedef Magnum::Physics::AxisAlignedBox2D, Magnum::Physics.:AxisAlignedBox3D + * @brief Class Magnum::Shapes::AxisAlignedBox, typedef Magnum::Shapes::AxisAlignedBox2D, Magnum::Shapes.:AxisAlignedBox3D */ #include "Math/Vector3.h" #include "DimensionTraits.h" -#include "Physics/Physics.h" -#include "Physics/magnumPhysicsVisibility.h" +#include "Shapes/Shapes.h" +#include "Shapes/magnumShapesVisibility.h" -namespace Magnum { namespace Physics { +namespace Magnum { namespace Shapes { /** @brief Axis-aligned box @@ -43,7 +43,7 @@ radius. @see AxisAlignedBox2D, AxisAlignedBox3D @todo Assert for rotation */ -template class MAGNUM_PHYSICS_EXPORT AxisAlignedBox { +template class MAGNUM_SHAPES_EXPORT AxisAlignedBox { public: enum: UnsignedInt { Dimensions = dimensions /**< Dimension count */ diff --git a/src/Physics/Box.cpp b/src/Shapes/Box.cpp similarity index 97% rename from src/Physics/Box.cpp rename to src/Shapes/Box.cpp index cf410ac91..6282784ee 100644 --- a/src/Physics/Box.cpp +++ b/src/Shapes/Box.cpp @@ -24,7 +24,7 @@ #include "Box.h" -namespace Magnum { namespace Physics { +namespace Magnum { namespace Shapes { template Box Box::transformed(const typename DimensionTraits::MatrixType& matrix) const { return Box(matrix*_transformation); diff --git a/src/Physics/Box.h b/src/Shapes/Box.h similarity index 90% rename from src/Physics/Box.h rename to src/Shapes/Box.h index d5a0af5db..ffd0db344 100644 --- a/src/Physics/Box.h +++ b/src/Shapes/Box.h @@ -1,5 +1,5 @@ -#ifndef Magnum_Physics_Box_h -#define Magnum_Physics_Box_h +#ifndef Magnum_Shapes_Box_h +#define Magnum_Shapes_Box_h /* This file is part of Magnum. @@ -25,15 +25,15 @@ */ /** @file - * @brief Class Magnum::Physics::Box, typedef Magnum::Physics::Box2D, Magnum::Physics::Box3D + * @brief Class Magnum::Shapes::Box, typedef Magnum::Shapes::Box2D, Magnum::Shapes::Box3D */ #include "Math/Matrix3.h" #include "Math/Matrix4.h" #include "DimensionTraits.h" -#include "Physics/magnumPhysicsVisibility.h" +#include "Shapes/magnumShapesVisibility.h" -namespace Magnum { namespace Physics { +namespace Magnum { namespace Shapes { /** @brief Unit-size box with assigned transformation matrix @@ -44,7 +44,7 @@ radius. @see Box2D, Box3D @todo Assert for skew */ -template class MAGNUM_PHYSICS_EXPORT Box { +template class MAGNUM_SHAPES_EXPORT Box { public: enum: UnsignedInt { Dimensions = dimensions /**< Dimension count */ diff --git a/src/Physics/CMakeLists.txt b/src/Shapes/CMakeLists.txt similarity index 78% rename from src/Physics/CMakeLists.txt rename to src/Shapes/CMakeLists.txt index 87b16c9b1..189a1f07e 100644 --- a/src/Physics/CMakeLists.txt +++ b/src/Shapes/CMakeLists.txt @@ -22,7 +22,7 @@ # DEALINGS IN THE SOFTWARE. # -set(MagnumPhysics_SRCS +set(MagnumShapes_SRCS AbstractShape.cpp AxisAlignedBox.cpp Box.cpp @@ -39,7 +39,7 @@ set(MagnumPhysics_SRCS Implementation/CollisionDispatch.cpp) -set(MagnumPhysics_HEADERS +set(MagnumShapes_HEADERS AbstractShape.h AxisAlignedBox.h Box.h @@ -49,23 +49,23 @@ set(MagnumPhysics_HEADERS LineSegment.h Shape.h ShapeGroup.h - Physics.h + Shapes.h Plane.h Point.h Sphere.h - magnumPhysicsVisibility.h + magnumShapesVisibility.h shapeImplementation.h) -add_library(MagnumPhysics ${SHARED_OR_STATIC} ${MagnumPhysics_SRCS}) +add_library(MagnumShapes ${SHARED_OR_STATIC} ${MagnumShapes_SRCS}) if(BUILD_STATIC_PIC) # TODO: CMake 2.8.9 has this as POSITION_INDEPENDENT_CODE property - set_target_properties(MagnumPhysics PROPERTIES COMPILE_FLAGS ${CMAKE_SHARED_LIBRARY_CXX_FLAGS}) + set_target_properties(MagnumShapes PROPERTIES COMPILE_FLAGS ${CMAKE_SHARED_LIBRARY_CXX_FLAGS}) endif() -target_link_libraries(MagnumPhysics Magnum MagnumSceneGraph) +target_link_libraries(MagnumShapes Magnum MagnumSceneGraph) -install(TARGETS MagnumPhysics DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) -install(FILES ${MagnumPhysics_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Physics) +install(TARGETS MagnumShapes DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) +install(FILES ${MagnumShapes_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Shapes) if(BUILD_TESTS) add_subdirectory(Test) diff --git a/src/Physics/Capsule.cpp b/src/Shapes/Capsule.cpp similarity index 92% rename from src/Physics/Capsule.cpp rename to src/Shapes/Capsule.cpp index 08fd06ec4..69c543ec9 100644 --- a/src/Physics/Capsule.cpp +++ b/src/Shapes/Capsule.cpp @@ -29,12 +29,12 @@ #include "Math/Matrix4.h" #include "Math/Geometry/Distance.h" #include "Magnum.h" -#include "Physics/Point.h" -#include "Physics/Sphere.h" +#include "Shapes/Point.h" +#include "Shapes/Sphere.h" using namespace Magnum::Math::Geometry; -namespace Magnum { namespace Physics { +namespace Magnum { namespace Shapes { template Capsule Capsule::transformed(const typename DimensionTraits::MatrixType& matrix) const { return Capsule(matrix.transformPoint(_a), matrix.transformPoint(_b), @@ -52,8 +52,8 @@ template bool Capsule::operator%(const Spher } #ifndef DOXYGEN_GENERATING_OUTPUT -template class MAGNUM_PHYSICS_EXPORT Capsule<2>; -template class MAGNUM_PHYSICS_EXPORT Capsule<3>; +template class MAGNUM_SHAPES_EXPORT Capsule<2>; +template class MAGNUM_SHAPES_EXPORT Capsule<3>; #endif }} diff --git a/src/Physics/Capsule.h b/src/Shapes/Capsule.h similarity index 91% rename from src/Physics/Capsule.h rename to src/Shapes/Capsule.h index 7965f4b12..8541e0db9 100644 --- a/src/Physics/Capsule.h +++ b/src/Shapes/Capsule.h @@ -1,5 +1,5 @@ -#ifndef Magnum_Physics_Capsule_h -#define Magnum_Physics_Capsule_h +#ifndef Magnum_Shapes_Capsule_h +#define Magnum_Shapes_Capsule_h /* This file is part of Magnum. @@ -25,15 +25,15 @@ */ /** @file - * @brief Class Magnum::Physics::Capsule, typedef Magnum::Physics::Capsule2D, Magnum::Physics::Capsule3D + * @brief Class Magnum::Shapes::Capsule, typedef Magnum::Shapes::Capsule2D, Magnum::Shapes::Capsule3D */ #include "Math/Vector3.h" #include "DimensionTraits.h" -#include "Physics/Physics.h" -#include "Physics/magnumPhysicsVisibility.h" +#include "Shapes/Shapes.h" +#include "Shapes/magnumShapesVisibility.h" -namespace Magnum { namespace Physics { +namespace Magnum { namespace Shapes { /** @brief %Capsule defined by cylinder start and end point and radius @@ -43,7 +43,7 @@ applying transformation, the scale factor is averaged from all axes. @see Capsule2D, Capsule3D @todo Assert for asymmetric scaling */ -template class MAGNUM_PHYSICS_EXPORT Capsule { +template class MAGNUM_SHAPES_EXPORT Capsule { public: enum: UnsignedInt { Dimensions = dimensions /**< Dimension count */ diff --git a/src/Physics/Composition.cpp b/src/Shapes/Composition.cpp similarity index 97% rename from src/Physics/Composition.cpp rename to src/Shapes/Composition.cpp index aab3ed112..3bc721b73 100644 --- a/src/Physics/Composition.cpp +++ b/src/Shapes/Composition.cpp @@ -27,9 +27,9 @@ #include #include -#include "Physics/Implementation/CollisionDispatch.h" +#include "Shapes/Implementation/CollisionDispatch.h" -namespace Magnum { namespace Physics { +namespace Magnum { namespace Shapes { /* Hierarchy implementation notes: @@ -160,8 +160,8 @@ template bool Composition::collides(const Im } #ifndef DOXYGEN_GENERATING_OUTPUT -template class MAGNUM_PHYSICS_EXPORT Composition<2>; -template class MAGNUM_PHYSICS_EXPORT Composition<3>; +template class MAGNUM_SHAPES_EXPORT Composition<2>; +template class MAGNUM_SHAPES_EXPORT Composition<3>; #endif }} diff --git a/src/Physics/Composition.h b/src/Shapes/Composition.h similarity index 94% rename from src/Physics/Composition.h rename to src/Shapes/Composition.h index 9a6cf879a..ae19d4239 100644 --- a/src/Physics/Composition.h +++ b/src/Shapes/Composition.h @@ -1,5 +1,5 @@ -#ifndef Magnum_Physics_Composition_h -#define Magnum_Physics_Composition_h +#ifndef Magnum_Shapes_Composition_h +#define Magnum_Shapes_Composition_h /* This file is part of Magnum. @@ -25,7 +25,7 @@ */ /** @file - * @brief Class Magnum::Physics::Composition, enum Magnum::Physics::CompositionOperation + * @brief Class Magnum::Shapes::Composition, enum Magnum::Shapes::CompositionOperation */ #include @@ -33,11 +33,11 @@ #include #include "DimensionTraits.h" -#include "Physics/Physics.h" -#include "Physics/magnumPhysicsVisibility.h" -#include "Physics/shapeImplementation.h" +#include "Shapes/Shapes.h" +#include "Shapes/magnumShapesVisibility.h" +#include "Shapes/shapeImplementation.h" -namespace Magnum { namespace Physics { +namespace Magnum { namespace Shapes { namespace Implementation { template struct ShapeHelper; @@ -63,7 +63,7 @@ enum class CompositionOperation: UnsignedByte { Result of logical operations on shapes. See @ref collision-detection for brief introduction. */ -template class MAGNUM_PHYSICS_EXPORT Composition { +template class MAGNUM_SHAPES_EXPORT Composition { friend Implementation::AbstractShape* Implementation::getAbstractShape<>(Composition&, std::size_t); friend const Implementation::AbstractShape* Implementation::getAbstractShape<>(const Composition&, std::size_t); friend struct Implementation::ShapeHelper>; @@ -193,7 +193,7 @@ typedef Composition<2> Composition2D; typedef Composition<3> Composition3D; #ifdef DOXYGEN_GENERATING_OUTPUT -/** @debugoperator{Magnum::Physics::Composition} */ +/** @debugoperator{Magnum::Shapes::Composition} */ template Debug operator<<(Debug debug, typename Composition::Type value); #endif @@ -257,7 +257,7 @@ template inline auto operator||(T&& a, U&& b) -> enableIfAreSh template template Composition::Composition(CompositionOperation operation, T&& a): _shapeCount(shapeCount(a)), _nodeCount(nodeCount(a)+1), _shapes(new Implementation::AbstractShape*[_shapeCount]), _nodes(new Node[_nodeCount]) { CORRADE_ASSERT(operation == CompositionOperation::Not, - "Physics::Composition::Composition(): unary operation expected", ); + "Shapes::Composition::Composition(): unary operation expected", ); _nodes[0].operation = operation; /* 0 = no children, 1 = left child only */ @@ -269,7 +269,7 @@ template template Composition::Comp template template Composition::Composition(CompositionOperation operation, T&& a, U&& b): _shapeCount(shapeCount(a) + shapeCount(b)), _nodeCount(nodeCount(a) + nodeCount(b) + 1), _shapes(new Implementation::AbstractShape*[_shapeCount]), _nodes(new Node[_nodeCount]) { CORRADE_ASSERT(operation != CompositionOperation::Not, - "Physics::Composition::Composition(): binary operation expected", ); + "Shapes::Composition::Composition(): binary operation expected", ); _nodes[0].operation = operation; /* 0 = no children, 1 = left child only, 2 = right child only, >2 = both */ @@ -288,7 +288,7 @@ template template Composition template inline const T& Composition::get(std::size_t i) const { CORRADE_ASSERT(_shapes[i]->type() == Implementation::TypeOf::type(), - "Physics::Composition::get(): given shape is not of type" << Implementation::TypeOf::type() << + "Shapes::Composition::get(): given shape is not of type" << Implementation::TypeOf::type() << "but" << _shapes[i]->type(), *static_cast(nullptr)); return static_cast*>(_shapes[i])->shape; } diff --git a/src/Physics/Implementation/CollisionDispatch.cpp b/src/Shapes/Implementation/CollisionDispatch.cpp similarity index 94% rename from src/Physics/Implementation/CollisionDispatch.cpp rename to src/Shapes/Implementation/CollisionDispatch.cpp index 7377ab6c5..703d7b11c 100644 --- a/src/Physics/Implementation/CollisionDispatch.cpp +++ b/src/Shapes/Implementation/CollisionDispatch.cpp @@ -24,16 +24,16 @@ #include "CollisionDispatch.h" -#include "Physics/AxisAlignedBox.h" -#include "Physics/Box.h" -#include "Physics/Capsule.h" -#include "Physics/LineSegment.h" -#include "Physics/Plane.h" -#include "Physics/Point.h" -#include "Physics/Sphere.h" -#include "Physics/shapeImplementation.h" - -namespace Magnum { namespace Physics { namespace Implementation { +#include "Shapes/AxisAlignedBox.h" +#include "Shapes/Box.h" +#include "Shapes/Capsule.h" +#include "Shapes/LineSegment.h" +#include "Shapes/Plane.h" +#include "Shapes/Point.h" +#include "Shapes/Sphere.h" +#include "Shapes/shapeImplementation.h" + +namespace Magnum { namespace Shapes { namespace Implementation { namespace { inline constexpr UnsignedInt operator*(ShapeDimensionTraits<2>::Type a, ShapeDimensionTraits<2>::Type b) { diff --git a/src/Physics/Implementation/CollisionDispatch.h b/src/Shapes/Implementation/CollisionDispatch.h similarity index 90% rename from src/Physics/Implementation/CollisionDispatch.h rename to src/Shapes/Implementation/CollisionDispatch.h index 53b51ef46..99517c970 100644 --- a/src/Physics/Implementation/CollisionDispatch.h +++ b/src/Shapes/Implementation/CollisionDispatch.h @@ -1,5 +1,5 @@ -#ifndef Magnum_Physics_Implementation_CollisionDispatch_h -#define Magnum_Physics_Implementation_CollisionDispatch_h +#ifndef Magnum_Shapes_Implementation_CollisionDispatch_h +#define Magnum_Shapes_Implementation_CollisionDispatch_h /* This file is part of Magnum. @@ -26,7 +26,7 @@ #include "Types.h" -namespace Magnum { namespace Physics { namespace Implementation { +namespace Magnum { namespace Shapes { namespace Implementation { template struct AbstractShape; diff --git a/src/Physics/Line.cpp b/src/Shapes/Line.cpp similarity index 97% rename from src/Physics/Line.cpp rename to src/Shapes/Line.cpp index 50d265cae..abbdb5d9a 100644 --- a/src/Physics/Line.cpp +++ b/src/Shapes/Line.cpp @@ -27,7 +27,7 @@ #include "Math/Matrix3.h" #include "Math/Matrix4.h" -namespace Magnum { namespace Physics { +namespace Magnum { namespace Shapes { template Line Line::transformed(const typename DimensionTraits::MatrixType& matrix) const { return Line(matrix.transformPoint(_a), diff --git a/src/Physics/Line.h b/src/Shapes/Line.h similarity index 90% rename from src/Physics/Line.h rename to src/Shapes/Line.h index c83e0f409..be416483d 100644 --- a/src/Physics/Line.h +++ b/src/Shapes/Line.h @@ -1,5 +1,5 @@ -#ifndef Magnum_Physics_Line_h -#define Magnum_Physics_Line_h +#ifndef Magnum_Shapes_Line_h +#define Magnum_Shapes_Line_h /* This file is part of Magnum. @@ -25,14 +25,14 @@ */ /** @file - * @brief Class Magnum::Physics::Line, typedef Magnum::Physics::Line2D, Magnum::Physics::Line3D + * @brief Class Magnum::Shapes::Line, typedef Magnum::Shapes::Line2D, Magnum::Shapes::Line3D */ #include "Math/Vector3.h" #include "DimensionTraits.h" -#include "Physics/magnumPhysicsVisibility.h" +#include "Shapes/magnumShapesVisibility.h" -namespace Magnum { namespace Physics { +namespace Magnum { namespace Shapes { /** @brief Infinite line, defined by two points @@ -40,7 +40,7 @@ namespace Magnum { namespace Physics { @see Line2D, Line3D @todo collision detection of two Line2D */ -template class MAGNUM_PHYSICS_EXPORT Line { +template class MAGNUM_SHAPES_EXPORT Line { public: enum: UnsignedInt { Dimensions = dimensions /**< Dimension count */ diff --git a/src/Physics/LineSegment.h b/src/Shapes/LineSegment.h similarity index 91% rename from src/Physics/LineSegment.h rename to src/Shapes/LineSegment.h index b55504a30..592ae1dcf 100644 --- a/src/Physics/LineSegment.h +++ b/src/Shapes/LineSegment.h @@ -1,5 +1,5 @@ -#ifndef Magnum_Physics_LineSegment_h -#define Magnum_Physics_LineSegment_h +#ifndef Magnum_Shapes_LineSegment_h +#define Magnum_Shapes_LineSegment_h /* This file is part of Magnum. @@ -25,12 +25,12 @@ */ /** @file - * @brief Class Magnum::Physics::LineSegment, typedef Magnum::Physics::LineSegment2D, Magnum::Physics::LineSegment3D + * @brief Class Magnum::Shapes::LineSegment, typedef Magnum::Shapes::LineSegment2D, Magnum::Shapes::LineSegment3D */ #include "Line.h" -namespace Magnum { namespace Physics { +namespace Magnum { namespace Shapes { /** @brief %Line segment, defined by starting and ending point diff --git a/src/Physics/Plane.cpp b/src/Shapes/Plane.cpp similarity index 96% rename from src/Physics/Plane.cpp rename to src/Shapes/Plane.cpp index c0211bb34..e62d5a15f 100644 --- a/src/Physics/Plane.cpp +++ b/src/Shapes/Plane.cpp @@ -28,11 +28,11 @@ #include "Math/Matrix4.h" #include "Math/Geometry/Intersection.h" -#include "Physics/LineSegment.h" +#include "Shapes/LineSegment.h" using namespace Magnum::Math::Geometry; -namespace Magnum { namespace Physics { +namespace Magnum { namespace Shapes { Plane Plane::transformed(const Matrix4& matrix) const { return Plane(matrix.transformPoint(_position), diff --git a/src/Physics/Plane.h b/src/Shapes/Plane.h similarity index 91% rename from src/Physics/Plane.h rename to src/Shapes/Plane.h index 42e54f005..bc6ecce85 100644 --- a/src/Physics/Plane.h +++ b/src/Shapes/Plane.h @@ -1,5 +1,5 @@ -#ifndef Magnum_Physics_Plane_h -#define Magnum_Physics_Plane_h +#ifndef Magnum_Shapes_Plane_h +#define Magnum_Shapes_Plane_h /* This file is part of Magnum. @@ -25,18 +25,18 @@ */ /** @file - * @brief Class Magnum::Physics::Plane + * @brief Class Magnum::Shapes::Plane */ #include "Math/Vector3.h" #include "Magnum.h" -#include "Physics/Physics.h" -#include "Physics/magnumPhysicsVisibility.h" +#include "Shapes/Shapes.h" +#include "Shapes/magnumShapesVisibility.h" -namespace Magnum { namespace Physics { +namespace Magnum { namespace Shapes { /** @brief Infinite plane, defined by position and normal (3D only) */ -class MAGNUM_PHYSICS_EXPORT Plane { +class MAGNUM_SHAPES_EXPORT Plane { public: enum: UnsignedInt { Dimensions = 3 /**< Dimension count */ diff --git a/src/Physics/Point.cpp b/src/Shapes/Point.cpp similarity index 97% rename from src/Physics/Point.cpp rename to src/Shapes/Point.cpp index a215ae973..5631e1137 100644 --- a/src/Physics/Point.cpp +++ b/src/Shapes/Point.cpp @@ -27,7 +27,7 @@ #include "Math/Matrix3.h" #include "Math/Matrix4.h" -namespace Magnum { namespace Physics { +namespace Magnum { namespace Shapes { template Point Point::transformed(const typename DimensionTraits::MatrixType& matrix) const { return Point(matrix.transformPoint(_position)); diff --git a/src/Physics/Point.h b/src/Shapes/Point.h similarity index 88% rename from src/Physics/Point.h rename to src/Shapes/Point.h index b44bf3dd6..a64f1621d 100644 --- a/src/Physics/Point.h +++ b/src/Shapes/Point.h @@ -1,5 +1,5 @@ -#ifndef Magnum_Physics_Point_h -#define Magnum_Physics_Point_h +#ifndef Magnum_Shapes_Point_h +#define Magnum_Shapes_Point_h /* This file is part of Magnum. @@ -25,21 +25,21 @@ */ /** @file - * @brief Class Magnum::Physics::Point, typedef Magnum::Physics::Point2D, Magnum::Physics::Point3D + * @brief Class Magnum::Shapes::Point, typedef Magnum::Shapes::Point2D, Magnum::Shapes::Point3D */ #include "Math/Vector3.h" #include "DimensionTraits.h" -#include "Physics/magnumPhysicsVisibility.h" +#include "Shapes/magnumShapesVisibility.h" -namespace Magnum { namespace Physics { +namespace Magnum { namespace Shapes { /** @brief %Point @see Point2D, Point3D */ -template class MAGNUM_PHYSICS_EXPORT Point { +template class MAGNUM_SHAPES_EXPORT Point { public: enum: UnsignedInt { Dimensions = dimensions /**< Dimension count */ diff --git a/src/Physics/Shape.cpp b/src/Shapes/Shape.cpp similarity index 75% rename from src/Physics/Shape.cpp rename to src/Shapes/Shape.cpp index 47a74e8e2..ed8d477a2 100644 --- a/src/Physics/Shape.cpp +++ b/src/Shapes/Shape.cpp @@ -24,25 +24,25 @@ #include "Shape.h" -#include "Physics/Composition.h" +#include "Shapes/Composition.h" -namespace Magnum { namespace Physics { namespace Implementation { +namespace Magnum { namespace Shapes { namespace Implementation { -template void ShapeHelper>::set(Physics::Shape>& shape, const Composition& composition) { +template void ShapeHelper>::set(Shapes::Shape>& shape, const Composition& composition) { shape._transformedShape.shape = shape._shape.shape = composition; } -template void ShapeHelper>::set(Physics::Shape>& shape, Composition&& composition) { +template void ShapeHelper>::set(Shapes::Shape>& shape, Composition&& composition) { shape._transformedShape.shape = shape._shape.shape = std::move(composition); } -template void ShapeHelper>::transform(Physics::Shape>& shape, const typename DimensionTraits::MatrixType& absoluteTransformationMatrix) { +template void ShapeHelper>::transform(Shapes::Shape>& shape, const typename DimensionTraits::MatrixType& absoluteTransformationMatrix) { CORRADE_INTERNAL_ASSERT(shape._shape.shape.size() == shape._transformedShape.shape.size()); for(std::size_t i = 0; i != shape.shape().size(); ++i) shape._shape.shape._shapes[i]->transform(absoluteTransformationMatrix, shape._transformedShape.shape._shapes[i]); } -template struct MAGNUM_PHYSICS_EXPORT ShapeHelper>; -template struct MAGNUM_PHYSICS_EXPORT ShapeHelper>; +template struct MAGNUM_SHAPES_EXPORT ShapeHelper>; +template struct MAGNUM_SHAPES_EXPORT ShapeHelper>; }}} diff --git a/src/Physics/Shape.h b/src/Shapes/Shape.h similarity index 79% rename from src/Physics/Shape.h rename to src/Shapes/Shape.h index ebf62d3ff..e16274961 100644 --- a/src/Physics/Shape.h +++ b/src/Shapes/Shape.h @@ -1,5 +1,5 @@ -#ifndef Magnum_Physics_Shape_h -#define Magnum_Physics_Shape_h +#ifndef Magnum_Shapes_Shape_h +#define Magnum_Shapes_Shape_h /* This file is part of Magnum. @@ -25,15 +25,15 @@ */ /** @file - * @brief Class Magnum::Physics::Shape + * @brief Class Magnum::Shapes::Shape */ -#include "Physics/AbstractShape.h" -#include "Physics/Physics.h" +#include "Shapes/AbstractShape.h" +#include "Shapes/Shapes.h" -#include "magnumPhysicsVisibility.h" +#include "magnumShapesVisibility.h" -namespace Magnum { namespace Physics { +namespace Magnum { namespace Shapes { namespace Implementation { template struct ShapeHelper; @@ -52,16 +52,16 @@ Add the feature to the object and some shape group (you can also use ShapeGroup::add() and ShapeGroup::remove() later) and configure the shape. @code -Physics::ShapeGroup3D shapes; +Shapes::ShapeGroup3D shapes; Object3D* object; -auto shape = new Physics::Shape(object, {{}, 0.75f}, &shapes); +auto shape = new Shapes::Shape(object, {{}, 0.75f}, &shapes); @endcode @see @ref scenegraph, ShapeGroup2D, ShapeGroup3D, DebugTools::ShapeRenderer */ -template class MAGNUM_PHYSICS_EXPORT Shape: public AbstractShape { +template class MAGNUM_SHAPES_EXPORT Shape: public AbstractShape { friend struct Implementation::ShapeHelper; public: @@ -130,20 +130,20 @@ template void Shape::clean(const typename DimensionTraits struct ShapeHelper { - inline static void set(Physics::Shape& shape, const T& s) { + inline static void set(Shapes::Shape& shape, const T& s) { shape._shape.shape = s; } - inline static void transform(Physics::Shape& shape, const typename DimensionTraits::MatrixType& absoluteTransformationMatrix) { + inline static void transform(Shapes::Shape& shape, const typename DimensionTraits::MatrixType& absoluteTransformationMatrix) { shape._transformedShape.shape = shape._shape.shape.transformed(absoluteTransformationMatrix); } }; - template struct MAGNUM_PHYSICS_EXPORT ShapeHelper> { - static void set(Physics::Shape>& shape, const Composition& composition); - static void set(Physics::Shape>& shape, Composition&& composition); + template struct MAGNUM_SHAPES_EXPORT ShapeHelper> { + static void set(Shapes::Shape>& shape, const Composition& composition); + static void set(Shapes::Shape>& shape, Composition&& composition); - static void transform(Physics::Shape>& shape, const typename DimensionTraits::MatrixType& absoluteTransformationMatrix); + static void transform(Shapes::Shape>& shape, const typename DimensionTraits::MatrixType& absoluteTransformationMatrix); }; } diff --git a/src/Physics/ShapeGroup.cpp b/src/Shapes/ShapeGroup.cpp similarity index 91% rename from src/Physics/ShapeGroup.cpp rename to src/Shapes/ShapeGroup.cpp index 0e9707be5..bd4810f1f 100644 --- a/src/Physics/ShapeGroup.cpp +++ b/src/Shapes/ShapeGroup.cpp @@ -24,9 +24,9 @@ #include "ShapeGroup.h" -#include "Physics/AbstractShape.h" +#include "Shapes/AbstractShape.h" -namespace Magnum { namespace Physics { +namespace Magnum { namespace Shapes { template void ShapeGroup::setClean() { /* Clean all objects */ @@ -51,8 +51,8 @@ template AbstractShape* ShapeGroup; -template class MAGNUM_PHYSICS_EXPORT ShapeGroup<3>; +template class MAGNUM_SHAPES_EXPORT ShapeGroup<2>; +template class MAGNUM_SHAPES_EXPORT ShapeGroup<3>; #endif }} diff --git a/src/Physics/ShapeGroup.h b/src/Shapes/ShapeGroup.h similarity index 87% rename from src/Physics/ShapeGroup.h rename to src/Shapes/ShapeGroup.h index 53f4f0c25..c71030b63 100644 --- a/src/Physics/ShapeGroup.h +++ b/src/Shapes/ShapeGroup.h @@ -1,5 +1,5 @@ -#ifndef Magnum_Physics_ShapeGroup_h -#define Magnum_Physics_ShapeGroup_h +#ifndef Magnum_Shapes_ShapeGroup_h +#define Magnum_Shapes_ShapeGroup_h /* This file is part of Magnum. @@ -25,17 +25,17 @@ */ /** @file - * @brief Class Magnum::Physics::ShapeGroup, typedef Magnum::Physics::ShapeGroup2D, Magnum::Physics::ShapeGroup3D + * @brief Class Magnum::Shapes::ShapeGroup, typedef Magnum::Shapes::ShapeGroup2D, Magnum::Shapes::ShapeGroup3D */ #include -#include "Physics/AbstractShape.h" +#include "Shapes/AbstractShape.h" #include "SceneGraph/FeatureGroup.h" -#include "magnumPhysicsVisibility.h" +#include "magnumShapesVisibility.h" -namespace Magnum { namespace Physics { +namespace Magnum { namespace Shapes { /** @brief Group of shapes @@ -43,7 +43,7 @@ namespace Magnum { namespace Physics { See Shape for more information. @see @ref scenegraph, ShapeGroup2D, ShapeGroup3D */ -template class MAGNUM_PHYSICS_EXPORT ShapeGroup: public SceneGraph::FeatureGroup> { +template class MAGNUM_SHAPES_EXPORT ShapeGroup: public SceneGraph::FeatureGroup> { friend class AbstractShape; public: diff --git a/src/Physics/Physics.h b/src/Shapes/Shapes.h similarity index 93% rename from src/Physics/Physics.h rename to src/Shapes/Shapes.h index f0f9a7dfc..dfc0d0fd7 100644 --- a/src/Physics/Physics.h +++ b/src/Shapes/Shapes.h @@ -1,5 +1,5 @@ -#ifndef Magnum_Physics_Physics_h -#define Magnum_Physics_Physics_h +#ifndef Magnum_Shapes_Shapes_h +#define Magnum_Shapes_Shapes_h /* This file is part of Magnum. @@ -25,12 +25,12 @@ */ /** @file - * @brief Forward declarations for Magnum::Physics namespace + * @brief Forward declarations for Magnum::Shapes namespace */ #include "Types.h" -namespace Magnum { namespace Physics { +namespace Magnum { namespace Shapes { /** @todoc remove when doxygen is sane again */ #ifndef DOXYGEN_GENERATING_OUTPUT diff --git a/src/Physics/Sphere.cpp b/src/Shapes/Sphere.cpp similarity index 93% rename from src/Physics/Sphere.cpp rename to src/Shapes/Sphere.cpp index fe3602c0e..154641c09 100644 --- a/src/Physics/Sphere.cpp +++ b/src/Shapes/Sphere.cpp @@ -29,12 +29,12 @@ #include "Math/Matrix4.h" #include "Math/Geometry/Distance.h" #include "Magnum.h" -#include "Physics/LineSegment.h" -#include "Physics/Point.h" +#include "Shapes/LineSegment.h" +#include "Shapes/Point.h" using namespace Magnum::Math::Geometry; -namespace Magnum { namespace Physics { +namespace Magnum { namespace Shapes { namespace { template static typename DimensionTraits::VectorType unitVector(); @@ -70,8 +70,8 @@ template bool Sphere::operator%(const Sphere } #ifndef DOXYGEN_GENERATING_OUTPUT -template class MAGNUM_PHYSICS_EXPORT Sphere<2>; -template class MAGNUM_PHYSICS_EXPORT Sphere<3>; +template class MAGNUM_SHAPES_EXPORT Sphere<2>; +template class MAGNUM_SHAPES_EXPORT Sphere<3>; #endif }} diff --git a/src/Physics/Sphere.h b/src/Shapes/Sphere.h similarity index 91% rename from src/Physics/Sphere.h rename to src/Shapes/Sphere.h index ec6cbff4b..42db3cbef 100644 --- a/src/Physics/Sphere.h +++ b/src/Shapes/Sphere.h @@ -1,5 +1,5 @@ -#ifndef Magnum_Physics_Sphere_h -#define Magnum_Physics_Sphere_h +#ifndef Magnum_Shapes_Sphere_h +#define Magnum_Shapes_Sphere_h /* This file is part of Magnum. @@ -25,15 +25,15 @@ */ /** @file - * @brief Class Magnum::Physics::Sphere, typedef Magnum::Physics::Sphere2D, Magnum::Physics::Sphere3D + * @brief Class Magnum::Shapes::Sphere, typedef Magnum::Shapes::Sphere2D, Magnum::Shapes::Sphere3D */ #include "Math/Vector3.h" #include "DimensionTraits.h" -#include "Physics/Physics.h" -#include "Physics/magnumPhysicsVisibility.h" +#include "Shapes/Shapes.h" +#include "Shapes/magnumShapesVisibility.h" -namespace Magnum { namespace Physics { +namespace Magnum { namespace Shapes { /** @brief %Sphere defined by position and radius @@ -43,7 +43,7 @@ applying transformation, the scale factor is averaged from all axes. @see Sphere2D, Sphere3D @todo Assert for asymmetric scaling */ -template class MAGNUM_PHYSICS_EXPORT Sphere { +template class MAGNUM_SHAPES_EXPORT Sphere { public: enum: UnsignedInt { Dimensions = dimensions /**< Dimension count */ diff --git a/src/Physics/Test/AxisAlignedBoxTest.cpp b/src/Shapes/Test/AxisAlignedBoxTest.cpp similarity index 81% rename from src/Physics/Test/AxisAlignedBoxTest.cpp rename to src/Shapes/Test/AxisAlignedBoxTest.cpp index 08db66ccb..ad53cbf00 100644 --- a/src/Physics/Test/AxisAlignedBoxTest.cpp +++ b/src/Shapes/Test/AxisAlignedBoxTest.cpp @@ -24,12 +24,12 @@ #include "Math/Matrix4.h" #include "Magnum.h" -#include "Physics/AxisAlignedBox.h" -#include "Physics/Point.h" +#include "Shapes/AxisAlignedBox.h" +#include "Shapes/Point.h" #include "ShapeTestBase.h" -namespace Magnum { namespace Physics { namespace Test { +namespace Magnum { namespace Shapes { namespace Test { class AxisAlignedBoxTest: public Corrade::TestSuite::Tester { public: @@ -45,16 +45,16 @@ AxisAlignedBoxTest::AxisAlignedBoxTest() { } void AxisAlignedBoxTest::transformed() { - const auto box = Physics::AxisAlignedBox3D({-1.0f, -2.0f, -3.0f}, {1.0f, 2.0f, 3.0f}) + const auto box = Shapes::AxisAlignedBox3D({-1.0f, -2.0f, -3.0f}, {1.0f, 2.0f, 3.0f}) .transformed(Matrix4::translation(Vector3(1.0f))*Matrix4::scaling({2.0f, -1.0f, 1.5f})); CORRADE_COMPARE(box.min(), Vector3(-1.0f, 3.0f, -3.5f)); CORRADE_COMPARE(box.max(), Vector3(3.0f, -1.0f, 5.5f)); } void AxisAlignedBoxTest::collisionPoint() { - Physics::AxisAlignedBox3D box({-1.0f, -2.0f, -3.0f}, {1.0f, 2.0f, 3.0f}); - Physics::Point3D point1({-1.5f, -1.0f, 2.0f}); - Physics::Point3D point2({0.5f, 1.0f, -2.5f}); + Shapes::AxisAlignedBox3D box({-1.0f, -2.0f, -3.0f}, {1.0f, 2.0f, 3.0f}); + Shapes::Point3D point1({-1.5f, -1.0f, 2.0f}); + Shapes::Point3D point2({0.5f, 1.0f, -2.5f}); VERIFY_NOT_COLLIDES(box, point1); VERIFY_COLLIDES(box, point2); @@ -62,4 +62,4 @@ void AxisAlignedBoxTest::collisionPoint() { }}} -CORRADE_TEST_MAIN(Magnum::Physics::Test::AxisAlignedBoxTest) +CORRADE_TEST_MAIN(Magnum::Shapes::Test::AxisAlignedBoxTest) diff --git a/src/Physics/Test/BoxTest.cpp b/src/Shapes/Test/BoxTest.cpp similarity index 88% rename from src/Physics/Test/BoxTest.cpp rename to src/Shapes/Test/BoxTest.cpp index 006273ab5..96f49bb40 100644 --- a/src/Physics/Test/BoxTest.cpp +++ b/src/Shapes/Test/BoxTest.cpp @@ -26,9 +26,9 @@ #include "Math/Matrix4.h" #include "Magnum.h" -#include "Physics/Box.h" +#include "Shapes/Box.h" -namespace Magnum { namespace Physics { namespace Test { +namespace Magnum { namespace Shapes { namespace Test { class BoxTest: public Corrade::TestSuite::Tester { public: @@ -42,11 +42,11 @@ BoxTest::BoxTest() { } void BoxTest::transformed() { - const auto box = Physics::Box3D(Matrix4::translation({1.0f, 2.0f, -3.0f})) + const auto box = Shapes::Box3D(Matrix4::translation({1.0f, 2.0f, -3.0f})) .transformed(Matrix4::scaling({2.0f, -1.0f, 1.5f})); CORRADE_COMPARE(box.transformation(), Matrix4::scaling({2.0f, -1.0f, 1.5f})*Matrix4::translation({1.0f, 2.0f, -3.0f})); } }}} -CORRADE_TEST_MAIN(Magnum::Physics::Test::BoxTest) +CORRADE_TEST_MAIN(Magnum::Shapes::Test::BoxTest) diff --git a/src/Physics/Test/CMakeLists.txt b/src/Shapes/Test/CMakeLists.txt similarity index 60% rename from src/Physics/Test/CMakeLists.txt rename to src/Shapes/Test/CMakeLists.txt index 47c7812e6..2615b6d99 100644 --- a/src/Physics/Test/CMakeLists.txt +++ b/src/Shapes/Test/CMakeLists.txt @@ -22,14 +22,14 @@ # DEALINGS IN THE SOFTWARE. # -corrade_add_test(PhysicsShapeImplementationTest ShapeImplementationTest.cpp LIBRARIES MagnumPhysics) -corrade_add_test(PhysicsAxisAlignedBoxTest AxisAlignedBoxTest.cpp LIBRARIES MagnumPhysics) -corrade_add_test(PhysicsBoxTest BoxTest.cpp LIBRARIES MagnumPhysics) -corrade_add_test(PhysicsCapsuleTest CapsuleTest.cpp LIBRARIES MagnumPhysics) -corrade_add_test(PhysicsLineTest LineTest.cpp LIBRARIES MagnumPhysics) -corrade_add_test(PhysicsPlaneTest PlaneTest.cpp LIBRARIES MagnumPhysics) -corrade_add_test(PhysicsPointTest PointTest.cpp LIBRARIES MagnumPhysics) -corrade_add_test(PhysicsCompositionTest CompositionTest.cpp LIBRARIES MagnumPhysics) -corrade_add_test(PhysicsSphereTest SphereTest.cpp LIBRARIES MagnumPhysics) +corrade_add_test(ShapesShapeImplementationTest ShapeImplementationTest.cpp LIBRARIES MagnumShapes) +corrade_add_test(ShapesAxisAlignedBoxTest AxisAlignedBoxTest.cpp LIBRARIES MagnumShapes) +corrade_add_test(ShapesBoxTest BoxTest.cpp LIBRARIES MagnumShapes) +corrade_add_test(ShapesCapsuleTest CapsuleTest.cpp LIBRARIES MagnumShapes) +corrade_add_test(ShapesLineTest LineTest.cpp LIBRARIES MagnumShapes) +corrade_add_test(ShapesPlaneTest PlaneTest.cpp LIBRARIES MagnumShapes) +corrade_add_test(ShapesPointTest PointTest.cpp LIBRARIES MagnumShapes) +corrade_add_test(ShapesCompositionTest CompositionTest.cpp LIBRARIES MagnumShapes) +corrade_add_test(ShapesSphereTest SphereTest.cpp LIBRARIES MagnumShapes) -corrade_add_test(PhysicsShapeTest ShapeTest.cpp LIBRARIES MagnumPhysics) +corrade_add_test(ShapesShapeTest ShapeTest.cpp LIBRARIES MagnumShapes) diff --git a/src/Physics/Test/CapsuleTest.cpp b/src/Shapes/Test/CapsuleTest.cpp similarity index 76% rename from src/Physics/Test/CapsuleTest.cpp rename to src/Shapes/Test/CapsuleTest.cpp index 02c305038..18d3912ad 100644 --- a/src/Physics/Test/CapsuleTest.cpp +++ b/src/Shapes/Test/CapsuleTest.cpp @@ -24,13 +24,13 @@ #include "Math/Matrix4.h" #include "Magnum.h" -#include "Physics/Capsule.h" -#include "Physics/Point.h" -#include "Physics/Sphere.h" +#include "Shapes/Capsule.h" +#include "Shapes/Point.h" +#include "Shapes/Sphere.h" #include "ShapeTestBase.h" -namespace Magnum { namespace Physics { namespace Test { +namespace Magnum { namespace Shapes { namespace Test { class CapsuleTest: public Corrade::TestSuite::Tester { public: @@ -49,7 +49,7 @@ CapsuleTest::CapsuleTest() { } void CapsuleTest::transformed() { - const Physics::Capsule3D capsule({1.0f, 2.0f, 3.0f}, {-1.0f, -2.0f, -3.0f}, 7.0f); + const Shapes::Capsule3D capsule({1.0f, 2.0f, 3.0f}, {-1.0f, -2.0f, -3.0f}, 7.0f); const auto transformed = capsule.transformed(Matrix4::rotation(Deg(90.0f), Vector3::zAxis())); CORRADE_COMPARE(transformed.a(), Vector3(-2.0f, 1.0f, 3.0f)); @@ -62,10 +62,10 @@ void CapsuleTest::transformed() { } void CapsuleTest::collisionPoint() { - Physics::Capsule3D capsule({-1.0f, -1.0f, 0.0f}, {1.0f, 1.0f, 0.0f}, 2.0f); - Physics::Point3D point({2.0f, 0.0f, 0.0f}); - Physics::Point3D point1({2.9f, 1.0f, 0.0f}); - Physics::Point3D point2({1.0f, 3.1f, 0.0f}); + Shapes::Capsule3D capsule({-1.0f, -1.0f, 0.0f}, {1.0f, 1.0f, 0.0f}, 2.0f); + Shapes::Point3D point({2.0f, 0.0f, 0.0f}); + Shapes::Point3D point1({2.9f, 1.0f, 0.0f}); + Shapes::Point3D point2({1.0f, 3.1f, 0.0f}); VERIFY_COLLIDES(capsule, point); VERIFY_COLLIDES(capsule, point1); @@ -73,10 +73,10 @@ void CapsuleTest::collisionPoint() { } void CapsuleTest::collisionSphere() { - Physics::Capsule3D capsule({-1.0f, -1.0f, 0.0f}, {1.0f, 1.0f, 0.0f}, 2.0f); - Physics::Sphere3D sphere({3.0f, 0.0f, 0.0f}, 0.9f); - Physics::Sphere3D sphere1({3.5f, 1.0f, 0.0f}, 0.6f); - Physics::Sphere3D sphere2({1.0f, 4.1f, 0.0f}, 1.0f); + Shapes::Capsule3D capsule({-1.0f, -1.0f, 0.0f}, {1.0f, 1.0f, 0.0f}, 2.0f); + Shapes::Sphere3D sphere({3.0f, 0.0f, 0.0f}, 0.9f); + Shapes::Sphere3D sphere1({3.5f, 1.0f, 0.0f}, 0.6f); + Shapes::Sphere3D sphere2({1.0f, 4.1f, 0.0f}, 1.0f); VERIFY_COLLIDES(capsule, sphere); VERIFY_COLLIDES(capsule, sphere1); @@ -85,4 +85,4 @@ void CapsuleTest::collisionSphere() { }}} -CORRADE_TEST_MAIN(Magnum::Physics::Test::CapsuleTest) +CORRADE_TEST_MAIN(Magnum::Shapes::Test::CapsuleTest) diff --git a/src/Physics/Test/CompositionTest.cpp b/src/Shapes/Test/CompositionTest.cpp similarity index 58% rename from src/Physics/Test/CompositionTest.cpp rename to src/Shapes/Test/CompositionTest.cpp index c7b9c5419..001879f1d 100644 --- a/src/Physics/Test/CompositionTest.cpp +++ b/src/Shapes/Test/CompositionTest.cpp @@ -25,14 +25,14 @@ #include #include "Math/Matrix4.h" -#include "Physics/Point.h" -#include "Physics/AxisAlignedBox.h" -#include "Physics/Composition.h" -#include "Physics/Sphere.h" +#include "Shapes/Point.h" +#include "Shapes/AxisAlignedBox.h" +#include "Shapes/Composition.h" +#include "Shapes/Sphere.h" #include "ShapeTestBase.h" -namespace Magnum { namespace Physics { namespace Test { +namespace Magnum { namespace Shapes { namespace Test { class CompositionTest: public Corrade::TestSuite::Tester { public: @@ -56,75 +56,75 @@ CompositionTest::CompositionTest() { } void CompositionTest::negated() { - const Physics::Composition2D a = !Physics::Point2D(Vector2::xAxis(0.5f)); + const Shapes::Composition2D a = !Shapes::Point2D(Vector2::xAxis(0.5f)); CORRADE_COMPARE(a.size(), 1); CORRADE_COMPARE(a.type(0), Composition2D::Type::Point); - CORRADE_COMPARE(a.get(0).position(), Vector2::xAxis(0.5f)); + CORRADE_COMPARE(a.get(0).position(), Vector2::xAxis(0.5f)); - VERIFY_NOT_COLLIDES(a, Physics::Sphere2D({}, 1.0f)); + VERIFY_NOT_COLLIDES(a, Shapes::Sphere2D({}, 1.0f)); } void CompositionTest::anded() { - const Physics::Composition2D a = Physics::Sphere2D({}, 1.0f) && Physics::Point2D(Vector2::xAxis(0.5f)); + const Shapes::Composition2D a = Shapes::Sphere2D({}, 1.0f) && Shapes::Point2D(Vector2::xAxis(0.5f)); CORRADE_COMPARE(a.size(), 2); CORRADE_COMPARE(a.type(0), Composition2D::Type::Sphere); CORRADE_COMPARE(a.type(1), Composition2D::Type::Point); - CORRADE_COMPARE(a.get(0).position(), Vector2()); - CORRADE_COMPARE(a.get(0).radius(), 1.0f); - CORRADE_COMPARE(a.get(1).position(), Vector2::xAxis(0.5f)); + CORRADE_COMPARE(a.get(0).position(), Vector2()); + CORRADE_COMPARE(a.get(0).radius(), 1.0f); + CORRADE_COMPARE(a.get(1).position(), Vector2::xAxis(0.5f)); - VERIFY_NOT_COLLIDES(a, Physics::Point2D()); - VERIFY_COLLIDES(a, Physics::Sphere2D(Vector2::xAxis(0.5f), 0.25f)); + VERIFY_NOT_COLLIDES(a, Shapes::Point2D()); + VERIFY_COLLIDES(a, Shapes::Sphere2D(Vector2::xAxis(0.5f), 0.25f)); } void CompositionTest::ored() { - const Physics::Composition2D a = Physics::Sphere2D({}, 1.0f) || Physics::Point2D(Vector2::xAxis(1.5f)); + const Shapes::Composition2D a = Shapes::Sphere2D({}, 1.0f) || Shapes::Point2D(Vector2::xAxis(1.5f)); CORRADE_COMPARE(a.size(), 2); CORRADE_COMPARE(a.type(0), Composition2D::Type::Sphere); CORRADE_COMPARE(a.type(1), Composition2D::Type::Point); - CORRADE_COMPARE(a.get(0).position(), Vector2()); - CORRADE_COMPARE(a.get(0).radius(), 1.0f); - CORRADE_COMPARE(a.get(1).position(), Vector2::xAxis(1.5f)); + CORRADE_COMPARE(a.get(0).position(), Vector2()); + CORRADE_COMPARE(a.get(0).radius(), 1.0f); + CORRADE_COMPARE(a.get(1).position(), Vector2::xAxis(1.5f)); - VERIFY_COLLIDES(a, Physics::Point2D()); - VERIFY_COLLIDES(a, Physics::Sphere2D(Vector2::xAxis(1.5f), 0.25f)); + VERIFY_COLLIDES(a, Shapes::Point2D()); + VERIFY_COLLIDES(a, Shapes::Sphere2D(Vector2::xAxis(1.5f), 0.25f)); } void CompositionTest::multipleUnary() { - const Physics::Composition2D a = !!!!Physics::Point2D(Vector2::xAxis(0.5f)); + const Shapes::Composition2D a = !!!!Shapes::Point2D(Vector2::xAxis(0.5f)); CORRADE_COMPARE(a.size(), 1); CORRADE_COMPARE(a.type(0), Composition2D::Type::Point); - CORRADE_COMPARE(a.get(0).position(), Vector2::xAxis(0.5f)); + CORRADE_COMPARE(a.get(0).position(), Vector2::xAxis(0.5f)); - VERIFY_COLLIDES(a, Physics::Sphere2D({}, 1.0f)); + VERIFY_COLLIDES(a, Shapes::Sphere2D({}, 1.0f)); } void CompositionTest::hierarchy() { - const Physics::Composition3D a = Physics::Sphere3D({}, 1.0f) && - (Physics::Point3D(Vector3::xAxis(1.5f)) || !Physics::AxisAlignedBox3D({}, Vector3(0.5f))); + const Shapes::Composition3D a = Shapes::Sphere3D({}, 1.0f) && + (Shapes::Point3D(Vector3::xAxis(1.5f)) || !Shapes::AxisAlignedBox3D({}, Vector3(0.5f))); CORRADE_COMPARE(a.size(), 3); CORRADE_COMPARE(a.type(0), Composition3D::Type::Sphere); CORRADE_COMPARE(a.type(1), Composition3D::Type::Point); CORRADE_COMPARE(a.type(2), Composition3D::Type::AxisAlignedBox); - CORRADE_COMPARE(a.get(1).position(), Vector3::xAxis(1.5f)); + CORRADE_COMPARE(a.get(1).position(), Vector3::xAxis(1.5f)); - VERIFY_COLLIDES(a, Physics::Sphere3D(Vector3::xAxis(1.5f), 0.6f)); - VERIFY_NOT_COLLIDES(a, Physics::Point3D(Vector3(0.25f))); + VERIFY_COLLIDES(a, Shapes::Sphere3D(Vector3::xAxis(1.5f), 0.6f)); + VERIFY_NOT_COLLIDES(a, Shapes::Point3D(Vector3(0.25f))); } void CompositionTest::empty() { - const Physics::Composition2D a; + const Shapes::Composition2D a; CORRADE_COMPARE(a.size(), 0); - VERIFY_NOT_COLLIDES(a, Physics::Sphere2D({}, 1.0f)); + VERIFY_NOT_COLLIDES(a, Shapes::Sphere2D({}, 1.0f)); } }}} -CORRADE_TEST_MAIN(Magnum::Physics::Test::CompositionTest) +CORRADE_TEST_MAIN(Magnum::Shapes::Test::CompositionTest) diff --git a/src/Physics/Test/LineTest.cpp b/src/Shapes/Test/LineTest.cpp similarity index 88% rename from src/Physics/Test/LineTest.cpp rename to src/Shapes/Test/LineTest.cpp index e398ed013..bf97fbc5d 100644 --- a/src/Physics/Test/LineTest.cpp +++ b/src/Shapes/Test/LineTest.cpp @@ -26,9 +26,9 @@ #include "Math/Matrix4.h" #include "Magnum.h" -#include "Physics/Line.h" +#include "Shapes/Line.h" -namespace Magnum { namespace Physics { namespace Test { +namespace Magnum { namespace Shapes { namespace Test { class LineTest: public Corrade::TestSuite::Tester { public: @@ -42,7 +42,7 @@ LineTest::LineTest() { } void LineTest::transformed() { - const auto line = Physics::Line3D({1.0f, 2.0f, 3.0f}, {-1.0f, -2.0f, -3.0f}) + const auto line = Shapes::Line3D({1.0f, 2.0f, 3.0f}, {-1.0f, -2.0f, -3.0f}) .transformed(Matrix4::rotation(Deg(90.0f), Vector3::zAxis())); CORRADE_COMPARE(line.a(), Vector3(-2.0f, 1.0f, 3.0f)); CORRADE_COMPARE(line.b(), Vector3(2.0f, -1.0f, -3.0f)); @@ -50,4 +50,4 @@ void LineTest::transformed() { }}} -CORRADE_TEST_MAIN(Magnum::Physics::Test::LineTest) +CORRADE_TEST_MAIN(Magnum::Shapes::Test::LineTest) diff --git a/src/Physics/Test/PlaneTest.cpp b/src/Shapes/Test/PlaneTest.cpp similarity index 75% rename from src/Physics/Test/PlaneTest.cpp rename to src/Shapes/Test/PlaneTest.cpp index c857229df..66c2b5649 100644 --- a/src/Physics/Test/PlaneTest.cpp +++ b/src/Shapes/Test/PlaneTest.cpp @@ -23,13 +23,13 @@ */ #include "Math/Matrix4.h" -#include "Physics/LineSegment.h" -#include "Physics/Point.h" -#include "Physics/Plane.h" +#include "Shapes/LineSegment.h" +#include "Shapes/Point.h" +#include "Shapes/Plane.h" #include "ShapeTestBase.h" -namespace Magnum { namespace Physics { namespace Test { +namespace Magnum { namespace Shapes { namespace Test { class PlaneTest: public Corrade::TestSuite::Tester { public: @@ -47,7 +47,7 @@ PlaneTest::PlaneTest() { } void PlaneTest::transformed() { - const Physics::Plane plane({1.0f, 2.0f, 3.0f}, {Constants::sqrt2(), -Constants::sqrt2(), 0}); + const Shapes::Plane plane({1.0f, 2.0f, 3.0f}, {Constants::sqrt2(), -Constants::sqrt2(), 0}); const auto transformed = plane.transformed(Matrix4::rotation(Deg(90.0f), Vector3::xAxis())); CORRADE_COMPARE(transformed.position(), Vector3(1.0f, -3.0f, 2.0f)); @@ -60,10 +60,10 @@ void PlaneTest::transformed() { } void PlaneTest::collisionLine() { - Physics::Plane plane(Vector3(), Vector3::yAxis()); - Physics::Line3D line({0.0f, 0.0f, 0.0f}, {1.0f, 0.0f, 0.0f}); - Physics::Line3D line2({0.0f, -1.0f, 0.0f}, {1.0f, 1.0f, 0.0f}); - Physics::Line3D line3({0.0f, 1.0f, 0.0f}, {1.0f, 1.0f, 0.0f}); + Shapes::Plane plane(Vector3(), Vector3::yAxis()); + Shapes::Line3D line({0.0f, 0.0f, 0.0f}, {1.0f, 0.0f, 0.0f}); + Shapes::Line3D line2({0.0f, -1.0f, 0.0f}, {1.0f, 1.0f, 0.0f}); + Shapes::Line3D line3({0.0f, 1.0f, 0.0f}, {1.0f, 1.0f, 0.0f}); VERIFY_COLLIDES(plane, line); VERIFY_COLLIDES(plane, line2); @@ -71,10 +71,10 @@ void PlaneTest::collisionLine() { } void PlaneTest::collisionLineSegment() { - Physics::Plane plane(Vector3(), Vector3::yAxis()); - Physics::LineSegment3D line({0.0f, -0.1f, 0.0f}, {0.0f, 7.0f, 0.0f}); - Physics::LineSegment3D line2({0.0f, 0.1f, 0.0f}, {0.0f, 7.0f, 0.0f}); - Physics::LineSegment3D line3({0.0f, -7.0f, 0.0f}, {0.0f, -0.1f, 0.0f}); + Shapes::Plane plane(Vector3(), Vector3::yAxis()); + Shapes::LineSegment3D line({0.0f, -0.1f, 0.0f}, {0.0f, 7.0f, 0.0f}); + Shapes::LineSegment3D line2({0.0f, 0.1f, 0.0f}, {0.0f, 7.0f, 0.0f}); + Shapes::LineSegment3D line3({0.0f, -7.0f, 0.0f}, {0.0f, -0.1f, 0.0f}); VERIFY_COLLIDES(plane, line); VERIFY_NOT_COLLIDES(plane, line2); @@ -83,4 +83,4 @@ void PlaneTest::collisionLineSegment() { }}} -CORRADE_TEST_MAIN(Magnum::Physics::Test::PlaneTest) +CORRADE_TEST_MAIN(Magnum::Shapes::Test::PlaneTest) diff --git a/src/Physics/Test/PointTest.cpp b/src/Shapes/Test/PointTest.cpp similarity index 89% rename from src/Physics/Test/PointTest.cpp rename to src/Shapes/Test/PointTest.cpp index 741484a26..c10641284 100644 --- a/src/Physics/Test/PointTest.cpp +++ b/src/Shapes/Test/PointTest.cpp @@ -26,9 +26,9 @@ #include "Math/Matrix4.h" #include "Magnum.h" -#include "Physics/Point.h" +#include "Shapes/Point.h" -namespace Magnum { namespace Physics { namespace Test { +namespace Magnum { namespace Shapes { namespace Test { class PointTest: public Corrade::TestSuite::Tester { public: @@ -42,11 +42,11 @@ PointTest::PointTest() { } void PointTest::transformed() { - const auto point = Physics::Point3D({1.0f, 2.0f, 3.0f}) + const auto point = Shapes::Point3D({1.0f, 2.0f, 3.0f}) .transformed(Matrix4::translation({5.0f, 6.0f, 7.0f})); CORRADE_COMPARE(point.position(), Vector3(6.0f, 8.0f, 10.0f)); } }}} -CORRADE_TEST_MAIN(Magnum::Physics::Test::PointTest) +CORRADE_TEST_MAIN(Magnum::Shapes::Test::PointTest) diff --git a/src/Physics/Test/ShapeImplementationTest.cpp b/src/Shapes/Test/ShapeImplementationTest.cpp similarity index 85% rename from src/Physics/Test/ShapeImplementationTest.cpp rename to src/Shapes/Test/ShapeImplementationTest.cpp index 57371a19c..0aa2c21f7 100644 --- a/src/Physics/Test/ShapeImplementationTest.cpp +++ b/src/Shapes/Test/ShapeImplementationTest.cpp @@ -25,9 +25,9 @@ #include #include -#include "Physics/shapeImplementation.h" +#include "Shapes/shapeImplementation.h" -namespace Magnum { namespace Physics { namespace Test { +namespace Magnum { namespace Shapes { namespace Test { class ShapeImplementationTest: public Corrade::TestSuite::Tester { public: @@ -43,13 +43,13 @@ ShapeImplementationTest::ShapeImplementationTest() { void ShapeImplementationTest::debug() { std::ostringstream o; Debug(&o) << Implementation::ShapeDimensionTraits<2>::Type::Composition; - CORRADE_COMPARE(o.str(), "Physics::Shape2D::Type::Composition\n"); + CORRADE_COMPARE(o.str(), "Shapes::Shape2D::Type::Composition\n"); o.str({}); Debug(&o) << Implementation::ShapeDimensionTraits<3>::Type::Plane; - CORRADE_COMPARE(o.str(), "Physics::Shape3D::Type::Plane\n"); + CORRADE_COMPARE(o.str(), "Shapes::Shape3D::Type::Plane\n"); } }}} -CORRADE_TEST_MAIN(Magnum::Physics::Test::ShapeImplementationTest) +CORRADE_TEST_MAIN(Magnum::Shapes::Test::ShapeImplementationTest) diff --git a/src/Physics/Test/ShapeTest.cpp b/src/Shapes/Test/ShapeTest.cpp similarity index 82% rename from src/Physics/Test/ShapeTest.cpp rename to src/Shapes/Test/ShapeTest.cpp index 369606bab..bfd9a58f6 100644 --- a/src/Physics/Test/ShapeTest.cpp +++ b/src/Shapes/Test/ShapeTest.cpp @@ -24,16 +24,16 @@ #include -#include "Physics/ShapeGroup.h" -#include "Physics/Shape.h" -#include "Physics/Point.h" -#include "Physics/Composition.h" -#include "Physics/Sphere.h" +#include "Shapes/ShapeGroup.h" +#include "Shapes/Shape.h" +#include "Shapes/Point.h" +#include "Shapes/Composition.h" +#include "Shapes/Sphere.h" #include "SceneGraph/MatrixTransformation2D.h" #include "SceneGraph/MatrixTransformation3D.h" #include "SceneGraph/Scene.h" -namespace Magnum { namespace Physics { namespace Test { +namespace Magnum { namespace Shapes { namespace Test { class ShapeTest: public Corrade::TestSuite::Tester { public: @@ -60,11 +60,11 @@ void ShapeTest::clean() { ShapeGroup3D shapes; Object3D a(&scene); - auto shape = new Physics::Shape(&a, {{1.0f, -2.0f, 3.0f}}, &shapes); + auto shape = new Shapes::Shape(&a, {{1.0f, -2.0f, 3.0f}}, &shapes); a.scale(Vector3(-2.0f)); Object3D b(&scene); - new Physics::Shape(&b, &shapes); + new Shapes::Shape(&b, &shapes); /* Everything is dirty at the beginning */ CORRADE_VERIFY(shapes.isDirty()); @@ -100,13 +100,13 @@ void ShapeTest::firstCollision() { ShapeGroup3D shapes; Object3D a(&scene); - auto aShape = new Shape(&a, {{1.0f, -2.0f, 3.0f}, 1.5f}, &shapes); + auto aShape = new Shape(&a, {{1.0f, -2.0f, 3.0f}, 1.5f}, &shapes); Object3D b(&scene); - auto bShape = new Shape(&b, {{3.0f, -2.0f, 3.0f}}, &shapes); + auto bShape = new Shape(&b, {{3.0f, -2.0f, 3.0f}}, &shapes); Object3D c(&scene); - new Shape(&c, &shapes); + new Shape(&c, &shapes); /* No collisions initially */ CORRADE_VERIFY(!shapes.firstCollision(aShape)); @@ -129,11 +129,11 @@ void ShapeTest::shapeGroup() { /* Verify construction */ Object2D a(&scene); - auto shape = new Shape(&a, Physics::Sphere2D({}, 0.5f) || Physics::Point2D({0.25f, -1.0f})); + auto shape = new Shape(&a, Shapes::Sphere2D({}, 0.5f) || Shapes::Point2D({0.25f, -1.0f})); CORRADE_COMPARE(shape->transformedShape().size(), 2); /* Verify the original shape is updated */ - const auto& point = shape->transformedShape().get(1); + const auto& point = shape->transformedShape().get(1); a.translate(Vector2::xAxis(5.0f)); a.setClean(); CORRADE_COMPARE(point.position(), Vector2(5.25f, -1.0f)); @@ -141,4 +141,4 @@ void ShapeTest::shapeGroup() { }}} -CORRADE_TEST_MAIN(Magnum::Physics::Test::ShapeTest) +CORRADE_TEST_MAIN(Magnum::Shapes::Test::ShapeTest) diff --git a/src/Physics/Test/ShapeTestBase.h b/src/Shapes/Test/ShapeTestBase.h similarity index 91% rename from src/Physics/Test/ShapeTestBase.h rename to src/Shapes/Test/ShapeTestBase.h index 52ff4a130..348cc3ee7 100644 --- a/src/Physics/Test/ShapeTestBase.h +++ b/src/Shapes/Test/ShapeTestBase.h @@ -1,5 +1,5 @@ -#ifndef Magnum_Physics_Test_ShapeTestBase_h -#define Magnum_Physics_Test_ShapeTestBase_h +#ifndef Magnum_Shapes_Test_ShapeTestBase_h +#define Magnum_Shapes_Test_ShapeTestBase_h /* This file is part of Magnum. @@ -26,7 +26,7 @@ #include -namespace Magnum { namespace Physics { namespace Test { +namespace Magnum { namespace Shapes { namespace Test { #define VERIFY_COLLIDES(a, b) \ CORRADE_VERIFY(a % b); \ diff --git a/src/Physics/Test/SphereTest.cpp b/src/Shapes/Test/SphereTest.cpp similarity index 75% rename from src/Physics/Test/SphereTest.cpp rename to src/Shapes/Test/SphereTest.cpp index 30167fd5e..a7dca7036 100644 --- a/src/Physics/Test/SphereTest.cpp +++ b/src/Shapes/Test/SphereTest.cpp @@ -24,13 +24,13 @@ #include "Math/Matrix4.h" #include "Magnum.h" -#include "Physics/LineSegment.h" -#include "Physics/Point.h" -#include "Physics/Sphere.h" +#include "Shapes/LineSegment.h" +#include "Shapes/Point.h" +#include "Shapes/Sphere.h" #include "ShapeTestBase.h" -namespace Magnum { namespace Physics { namespace Test { +namespace Magnum { namespace Shapes { namespace Test { class SphereTest: public Corrade::TestSuite::Tester { public: @@ -52,7 +52,7 @@ SphereTest::SphereTest() { } void SphereTest::transformed() { - const Physics::Sphere3D sphere({1.0f, 2.0f, 3.0f}, 7.0f); + const Shapes::Sphere3D sphere({1.0f, 2.0f, 3.0f}, 7.0f); const auto transformed = sphere.transformed(Matrix4::rotation(Deg(90.0f), Vector3::yAxis())); CORRADE_COMPARE(transformed.position(), Vector3(3.0f, 2.0f, -1.0f)); @@ -69,36 +69,36 @@ void SphereTest::transformed() { } void SphereTest::collisionPoint() { - Physics::Sphere3D sphere({1.0f, 2.0f, 3.0f}, 2.0f); - Physics::Point3D point({1.0f, 3.0f, 3.0f}); - Physics::Point3D point2({1.0f, 3.0f, 1.0f}); + Shapes::Sphere3D sphere({1.0f, 2.0f, 3.0f}, 2.0f); + Shapes::Point3D point({1.0f, 3.0f, 3.0f}); + Shapes::Point3D point2({1.0f, 3.0f, 1.0f}); VERIFY_COLLIDES(sphere, point); VERIFY_NOT_COLLIDES(sphere, point2); } void SphereTest::collisionLine() { - Physics::Sphere3D sphere({1.0f, 2.0f, 3.0f}, 2.0f); - Physics::Line3D line({1.0f, 1.5f, 3.5f}, {1.0f, 2.5f, 2.5f}); - Physics::Line3D line2({1.0f, 2.0f, 5.1f}, {1.0f, 3.0f, 5.1f}); + Shapes::Sphere3D sphere({1.0f, 2.0f, 3.0f}, 2.0f); + Shapes::Line3D line({1.0f, 1.5f, 3.5f}, {1.0f, 2.5f, 2.5f}); + Shapes::Line3D line2({1.0f, 2.0f, 5.1f}, {1.0f, 3.0f, 5.1f}); VERIFY_COLLIDES(sphere, line); VERIFY_NOT_COLLIDES(sphere, line2); } void SphereTest::collisionLineSegment() { - Physics::Sphere3D sphere({1.0f, 2.0f, 3.0f}, 2.0f); - Physics::LineSegment3D line({1.0f, 2.0f, 4.9f}, {1.0f, 2.0f, 7.0f}); - Physics::LineSegment3D line2({1.0f, 2.0f, 5.1f}, {1.0f, 2.0f, 7.0f}); + Shapes::Sphere3D sphere({1.0f, 2.0f, 3.0f}, 2.0f); + Shapes::LineSegment3D line({1.0f, 2.0f, 4.9f}, {1.0f, 2.0f, 7.0f}); + Shapes::LineSegment3D line2({1.0f, 2.0f, 5.1f}, {1.0f, 2.0f, 7.0f}); VERIFY_COLLIDES(sphere, line); VERIFY_NOT_COLLIDES(sphere, line2); } void SphereTest::collisionSphere() { - Physics::Sphere3D sphere({1.0f, 2.0f, 3.0f}, 2.0f); - Physics::Sphere3D sphere1({1.0f, 3.0f, 5.0f}, 1.0f); - Physics::Sphere3D sphere2({1.0f, 3.0f, 0.0f}, 1.0f); + Shapes::Sphere3D sphere({1.0f, 2.0f, 3.0f}, 2.0f); + Shapes::Sphere3D sphere1({1.0f, 3.0f, 5.0f}, 1.0f); + Shapes::Sphere3D sphere2({1.0f, 3.0f, 0.0f}, 1.0f); VERIFY_COLLIDES(sphere, sphere1); VERIFY_NOT_COLLIDES(sphere, sphere2); @@ -106,4 +106,4 @@ void SphereTest::collisionSphere() { }}} -CORRADE_TEST_MAIN(Magnum::Physics::Test::SphereTest) +CORRADE_TEST_MAIN(Magnum::Shapes::Test::SphereTest) diff --git a/src/Physics/magnumPhysicsVisibility.h b/src/Shapes/magnumShapesVisibility.h similarity index 80% rename from src/Physics/magnumPhysicsVisibility.h rename to src/Shapes/magnumShapesVisibility.h index e7d67f908..c5f8fa30f 100644 --- a/src/Physics/magnumPhysicsVisibility.h +++ b/src/Shapes/magnumShapesVisibility.h @@ -1,5 +1,5 @@ -#ifndef Magnum_Physics_magnumPhysicsVisibility_h -#define Magnum_Physics_magnumPhysicsVisibility_h +#ifndef Magnum_Shapes_magnumShapesVisibility_h +#define Magnum_Shapes_magnumShapesVisibility_h /* This file is part of Magnum. @@ -26,11 +26,11 @@ #include -#ifdef MagnumPhysics_EXPORTS - #define MAGNUM_PHYSICS_EXPORT CORRADE_VISIBILITY_EXPORT +#ifdef MagnumShapes_EXPORTS + #define MAGNUM_SHAPES_EXPORT CORRADE_VISIBILITY_EXPORT #else - #define MAGNUM_PHYSICS_EXPORT CORRADE_VISIBILITY_IMPORT + #define MAGNUM_SHAPES_EXPORT CORRADE_VISIBILITY_IMPORT #endif -#define MAGNUM_PHYSICS_LOCAL CORRADE_VISIBILITY_LOCAL +#define MAGNUM_SHAPES_LOCAL CORRADE_VISIBILITY_LOCAL #endif diff --git a/src/Physics/shapeImplementation.cpp b/src/Shapes/shapeImplementation.cpp similarity index 88% rename from src/Physics/shapeImplementation.cpp rename to src/Shapes/shapeImplementation.cpp index 40a199ea0..1b3b57973 100644 --- a/src/Physics/shapeImplementation.cpp +++ b/src/Shapes/shapeImplementation.cpp @@ -26,11 +26,11 @@ #include -namespace Magnum { namespace Physics { namespace Implementation { +namespace Magnum { namespace Shapes { namespace Implementation { Debug operator<<(Debug debug, ShapeDimensionTraits<2>::Type value) { switch(value) { - #define _val(value) case ShapeDimensionTraits<2>::Type::value: return debug << "Physics::Shape2D::Type::" #value; + #define _val(value) case ShapeDimensionTraits<2>::Type::value: return debug << "Shapes::Shape2D::Type::" #value; _val(Point) _val(Line) _val(LineSegment) @@ -42,12 +42,12 @@ Debug operator<<(Debug debug, ShapeDimensionTraits<2>::Type value) { #undef _val } - return debug << "Physics::Shape2D::Type::(unknown)"; + return debug << "Shapes::Shape2D::Type::(unknown)"; } Debug operator<<(Debug debug, ShapeDimensionTraits<3>::Type value) { switch(value) { - #define _val(value) case ShapeDimensionTraits<3>::Type::value: return debug << "Physics::Shape3D::Type::" #value; + #define _val(value) case ShapeDimensionTraits<3>::Type::value: return debug << "Shapes::Shape3D::Type::" #value; _val(Point) _val(Line) _val(LineSegment) @@ -60,7 +60,7 @@ Debug operator<<(Debug debug, ShapeDimensionTraits<3>::Type value) { #undef _val } - return debug << "Physics::Shape3D::Type::(unknown)"; + return debug << "Shapes::Shape3D::Type::(unknown)"; } template AbstractShape::~AbstractShape() = default; diff --git a/src/Physics/shapeImplementation.h b/src/Shapes/shapeImplementation.h similarity index 75% rename from src/Physics/shapeImplementation.h rename to src/Shapes/shapeImplementation.h index dde2a6e33..868d9215d 100644 --- a/src/Physics/shapeImplementation.h +++ b/src/Shapes/shapeImplementation.h @@ -1,5 +1,5 @@ -#ifndef Magnum_Physics_shapeImplementation_h -#define Magnum_Physics_shapeImplementation_h +#ifndef Magnum_Shapes_shapeImplementation_h +#define Magnum_Shapes_shapeImplementation_h /* This file is part of Magnum. @@ -29,10 +29,10 @@ #include "DimensionTraits.h" #include "Magnum.h" -#include "Physics/Physics.h" -#include "Physics/magnumPhysicsVisibility.h" +#include "Shapes/Shapes.h" +#include "Shapes/magnumShapesVisibility.h" -namespace Magnum { namespace Physics { namespace Implementation { +namespace Magnum { namespace Shapes { namespace Implementation { /* Shape type for given dimension count */ @@ -65,54 +65,54 @@ template<> struct ShapeDimensionTraits<3> { }; }; -Debug MAGNUM_PHYSICS_EXPORT operator<<(Debug debug, ShapeDimensionTraits<2>::Type value); -Debug MAGNUM_PHYSICS_EXPORT operator<<(Debug debug, ShapeDimensionTraits<3>::Type value); +Debug MAGNUM_SHAPES_EXPORT operator<<(Debug debug, ShapeDimensionTraits<2>::Type value); +Debug MAGNUM_SHAPES_EXPORT operator<<(Debug debug, ShapeDimensionTraits<3>::Type value); /* Enum value corresponding to given type */ template struct TypeOf; -template struct TypeOf> { +template struct TypeOf> { inline constexpr static typename ShapeDimensionTraits::Type type() { return ShapeDimensionTraits::Type::Point; } }; -template struct TypeOf> { +template struct TypeOf> { inline constexpr static typename ShapeDimensionTraits::Type type() { return ShapeDimensionTraits::Type::Line; } }; -template struct TypeOf> { +template struct TypeOf> { inline constexpr static typename ShapeDimensionTraits::Type type() { return ShapeDimensionTraits::Type::LineSegment; } }; -template struct TypeOf> { +template struct TypeOf> { inline constexpr static typename ShapeDimensionTraits::Type type() { return ShapeDimensionTraits::Type::Sphere; } }; -template struct TypeOf> { +template struct TypeOf> { inline constexpr static typename ShapeDimensionTraits::Type type() { return ShapeDimensionTraits::Type::Capsule; } }; -template struct TypeOf> { +template struct TypeOf> { inline constexpr static typename ShapeDimensionTraits::Type type() { return ShapeDimensionTraits::Type::AxisAlignedBox; } }; -template struct TypeOf> { +template struct TypeOf> { inline constexpr static typename ShapeDimensionTraits::Type type() { return ShapeDimensionTraits::Type::Box; } }; -template<> struct TypeOf { +template<> struct TypeOf { inline constexpr static typename ShapeDimensionTraits<3>::Type type() { return ShapeDimensionTraits<3>::Type::Plane; } }; -template struct TypeOf> { +template struct TypeOf> { inline constexpr static typename ShapeDimensionTraits::Type type() { return ShapeDimensionTraits::Type::Composition; } @@ -120,13 +120,13 @@ template struct TypeOf> /* Polymorphic shape wrappers */ -template struct MAGNUM_PHYSICS_EXPORT AbstractShape { +template struct MAGNUM_SHAPES_EXPORT AbstractShape { explicit AbstractShape(); virtual ~AbstractShape(); - virtual typename ShapeDimensionTraits::Type MAGNUM_PHYSICS_LOCAL type() const = 0; - virtual AbstractShape MAGNUM_PHYSICS_LOCAL * clone() const = 0; - virtual void MAGNUM_PHYSICS_LOCAL transform(const typename DimensionTraits::MatrixType& matrix, AbstractShape* result) const = 0; + virtual typename ShapeDimensionTraits::Type MAGNUM_SHAPES_LOCAL type() const = 0; + virtual AbstractShape MAGNUM_SHAPES_LOCAL * clone() const = 0; + virtual void MAGNUM_SHAPES_LOCAL transform(const typename DimensionTraits::MatrixType& matrix, AbstractShape* result) const = 0; }; template struct Shape: AbstractShape {