diff --git a/doc/changelog.dox b/doc/changelog.dox index 26126e384..e05be33db 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -53,6 +53,33 @@ See also: @subsection changelog-latest-deprecated Deprecated APIs +- Class @cpp Primitives::Capsule2D @ce and @cpp Primitives::Capsule3D @ce is + deprecated, use @ref Primitives::capsule2DWireframe(), + @ref Primitives::capsule3DSolid() and @ref Primitives::capsule3DWireframe() + free functions instead +- Class @cpp Primitives::Circle @ce is deprecated, use + @ref Primitives::circle2DSolid() and @ref Primitives::circle2DWireframe() + instead +- Class @cpp Primitives::Crosshair2D @ce and @cpp Primitives::Crosshair3D @ce + is deprecated, use @ref Primitives::crosshair2D() and + @ref Primitives::crosshair3D() free function instead +- Class @cpp Primitives::Cube @ce is deprecated, use @ref Primitives::cubeSolid(), + @ref Primitives::cubeSolidStrip() and @ref Primitives::cubeWireframe() free + functions instead +- Class @cpp Primitives::Cylinder @ce is deprecated, use + @ref Primitives::cylinderSolid(), @ref Primitives::cylinderWireframe() free + functions instead +- Class @cpp Primitives::Icosphere @ce is deprecated, use the + @ref Primitives::icosphereSolid() free function instead +- Class @cpp Primitives::Plane @ce is deprecated, use + @ref Primitives::planeSolid() and @ref Primitives::planeWireframe() free + functions instead +- Class @cpp Primitives::Square @ce is deprecated, use + @ref Primitives::squareSolid() and @ref Primitives::squareWireframe() free + functions instead +- Class @cpp Primitives::UVSphere @ce is deprecated, use + @ref Primitives::uvSphereSolid() and @ref Primitives::uvSphereWireframe() + free functions instead - @cpp Shaders::*Vector::setVectorTexture() @ce, @cpp Shaders::Flat::setTexture() @ce, @cpp Shaders::Phong::setAmbientTexture() @ce, @cpp Shaders::Phong::setDiffuseTexture() @ce, @cpp Shaders::Phong::setSpecularTexture() @ce and @cpp Shaders::Phong::setTextures() @ce diff --git a/doc/generated/shaders.cpp b/doc/generated/shaders.cpp index 29c22b36f..2e9445934 100644 --- a/doc/generated/shaders.cpp +++ b/doc/generated/shaders.cpp @@ -152,7 +152,7 @@ namespace { std::string ShaderVisualizer::phong() { std::unique_ptr vertices, indices; Mesh mesh{NoCreate}; - std::tie(mesh, vertices, indices) = MeshTools::compile(Primitives::UVSphere::solid(16, 32), BufferUsage::StaticDraw); + std::tie(mesh, vertices, indices) = MeshTools::compile(Primitives::uvSphereSolid(16, 32), BufferUsage::StaticDraw); Shaders::Phong shader; shader.setAmbientColor(0x22272e_rgbf) @@ -171,7 +171,7 @@ std::string ShaderVisualizer::phong() { std::string ShaderVisualizer::meshVisualizer() { std::unique_ptr vertices, indices; Mesh mesh{NoCreate}; - std::tie(mesh, vertices, indices) = MeshTools::compile(Primitives::Icosphere::solid(1), BufferUsage::StaticDraw); + std::tie(mesh, vertices, indices) = MeshTools::compile(Primitives::icosphereSolid(1), BufferUsage::StaticDraw); const Matrix4 projection = Projection*Transformation* Matrix4::rotationZ(13.7_degf)* @@ -191,7 +191,7 @@ std::string ShaderVisualizer::meshVisualizer() { std::string ShaderVisualizer::flat() { std::unique_ptr vertices, indices; Mesh mesh{NoCreate}; - std::tie(mesh, vertices, indices) = MeshTools::compile(Primitives::UVSphere::solid(16, 32), BufferUsage::StaticDraw); + std::tie(mesh, vertices, indices) = MeshTools::compile(Primitives::uvSphereSolid(16, 32), BufferUsage::StaticDraw); Shaders::Flat3D shader; shader.setColor(BaseColor) @@ -203,7 +203,7 @@ std::string ShaderVisualizer::flat() { } std::string ShaderVisualizer::vertexColor() { - Trade::MeshData3D sphere = Primitives::UVSphere::solid(32, 64); + Trade::MeshData3D sphere = Primitives::uvSphereSolid(32, 64); /* Color vertices nearest to given position */ auto target = Vector3{2.0f, 2.0f, 7.0f}.normalized(); @@ -248,7 +248,7 @@ std::string ShaderVisualizer::vector() { Mesh mesh{NoCreate}; std::unique_ptr vertices; - std::tie(mesh, vertices, std::ignore) = MeshTools::compile(Primitives::Square::solid(Primitives::Square::TextureCoords::Generate), BufferUsage::StaticDraw); + std::tie(mesh, vertices, std::ignore) = MeshTools::compile(Primitives::squareSolid(Primitives::SquareTextureCoords::Generate), BufferUsage::StaticDraw); Shaders::Vector2D shader; shader.setColor(BaseColor) @@ -282,7 +282,7 @@ std::string ShaderVisualizer::distanceFieldVector() { Mesh mesh{NoCreate}; std::unique_ptr vertices; - std::tie(mesh, vertices, std::ignore) = MeshTools::compile(Primitives::Square::solid(Primitives::Square::TextureCoords::Generate), BufferUsage::StaticDraw); + std::tie(mesh, vertices, std::ignore) = MeshTools::compile(Primitives::squareSolid(Primitives::SquareTextureCoords::Generate), BufferUsage::StaticDraw); Shaders::DistanceFieldVector2D shader; shader.setColor(BaseColor) diff --git a/doc/snippets/Magnum.cpp b/doc/snippets/Magnum.cpp index ea88d21db..138753cb4 100644 --- a/doc/snippets/Magnum.cpp +++ b/doc/snippets/Magnum.cpp @@ -794,7 +794,7 @@ mesh.setPrimitive(MeshPrimitive::Triangles) { /* [Mesh-interleaved] */ /* Non-indexed primitive with positions and normals */ -Trade::MeshData3D plane = Primitives::Plane::solid(); +Trade::MeshData3D plane = Primitives::planeSolid(); /* Fill a vertex buffer with interleaved position and normal data */ Buffer buffer; @@ -844,7 +844,7 @@ mesh.setPrimitive(MeshPrimitive::Triangles) { /* [Mesh-indexed-tools] */ // Indexed primitive -Trade::MeshData3D cube = Primitives::Cube::solid(); +Trade::MeshData3D cube = Primitives::cubeSolid(); // Fill vertex buffer with interleaved position and normal data Buffer vertexBuffer; diff --git a/src/Magnum/DebugTools/Implementation/AbstractBoxRenderer.cpp b/src/Magnum/DebugTools/Implementation/AbstractBoxRenderer.cpp index 40d6659f7..31d07aadb 100644 --- a/src/Magnum/DebugTools/Implementation/AbstractBoxRenderer.cpp +++ b/src/Magnum/DebugTools/Implementation/AbstractBoxRenderer.cpp @@ -34,11 +34,11 @@ namespace Magnum { namespace DebugTools { namespace Implementation { AbstractBoxRenderer<2>::AbstractBoxRenderer(): AbstractShapeRenderer<2>("box2d", "box2d-vertices", {}) { - if(!wireframeMesh) AbstractShapeRenderer<2>::createResources(Primitives::Square::wireframe()); + if(!wireframeMesh) AbstractShapeRenderer<2>::createResources(Primitives::squareWireframe()); } AbstractBoxRenderer<3>::AbstractBoxRenderer(): AbstractShapeRenderer<3>("box3d", "box3d-vertices", "box3d-indices") { - if(!wireframeMesh) AbstractShapeRenderer<3>::createResources(Primitives::Cube::wireframe()); + if(!wireframeMesh) AbstractShapeRenderer<3>::createResources(Primitives::cubeWireframe()); } template class AbstractBoxRenderer<2>; diff --git a/src/Magnum/DebugTools/Implementation/CapsuleRenderer.cpp b/src/Magnum/DebugTools/Implementation/CapsuleRenderer.cpp index c640105a8..925734dd4 100644 --- a/src/Magnum/DebugTools/Implementation/CapsuleRenderer.cpp +++ b/src/Magnum/DebugTools/Implementation/CapsuleRenderer.cpp @@ -41,7 +41,7 @@ namespace Magnum { namespace DebugTools { namespace Implementation { AbstractCapsuleRenderer<2>::AbstractCapsuleRenderer(): AbstractShapeRenderer<2>("capsule2d", "capsule2d-vertices", "capsule2d-indices") { constexpr UnsignedInt rings = 10; - if(!wireframeMesh) createResources(Primitives::Capsule2D::wireframe(rings, 1, 1.0f)); + if(!wireframeMesh) createResources(Primitives::capsule2DWireframe(rings, 1, 1.0f)); /* Bottom hemisphere */ if(!(bottom = ResourceManager::instance().get("capsule2d-bottom"))) { @@ -71,7 +71,7 @@ AbstractCapsuleRenderer<2>::AbstractCapsuleRenderer(): AbstractShapeRenderer<2>( AbstractCapsuleRenderer<3>::AbstractCapsuleRenderer(): AbstractShapeRenderer<3>("capsule3d", "capsule3d-vertices", "capsule3d-indices") { constexpr UnsignedInt rings = 10; constexpr UnsignedInt segments = 40; - if(!wireframeMesh) createResources(Primitives::Capsule3D::wireframe(rings, 1, segments, 1.0f)); + if(!wireframeMesh) createResources(Primitives::capsule3DWireframe(rings, 1, segments, 1.0f)); /* Bottom hemisphere */ if(!(bottom = ResourceManager::instance().get("capsule3d-bottom"))) { diff --git a/src/Magnum/DebugTools/Implementation/CylinderRenderer.cpp b/src/Magnum/DebugTools/Implementation/CylinderRenderer.cpp index 47978a663..4ec520b22 100644 --- a/src/Magnum/DebugTools/Implementation/CylinderRenderer.cpp +++ b/src/Magnum/DebugTools/Implementation/CylinderRenderer.cpp @@ -39,11 +39,11 @@ namespace Magnum { namespace DebugTools { namespace Implementation { AbstractCylinderRenderer<2>::AbstractCylinderRenderer(): AbstractShapeRenderer<2>("cylinder2d", "cylinder2d-vertices", {}) { - if(!wireframeMesh) createResources(Primitives::Square::wireframe()); + if(!wireframeMesh) createResources(Primitives::squareWireframe()); } AbstractCylinderRenderer<3>::AbstractCylinderRenderer(): AbstractShapeRenderer<3>("cylinder3d", "cylinder3d-vertices", "cylinder3d-indices") { - if(!wireframeMesh) createResources(Primitives::Cylinder::wireframe(1, 40, 1.0f)); + if(!wireframeMesh) createResources(Primitives::cylinderWireframe(1, 40, 1.0f)); } template CylinderRenderer::CylinderRenderer(const Shapes::Implementation::AbstractShape& cylinder): cylinder(static_cast>&>(cylinder).shape) {} diff --git a/src/Magnum/DebugTools/Implementation/LineSegmentRenderer.cpp b/src/Magnum/DebugTools/Implementation/LineSegmentRenderer.cpp index 2c7ad974a..9a51b3320 100644 --- a/src/Magnum/DebugTools/Implementation/LineSegmentRenderer.cpp +++ b/src/Magnum/DebugTools/Implementation/LineSegmentRenderer.cpp @@ -47,8 +47,8 @@ namespace { template<> inline ResourceKey vertexBufferKey<3>() { return ResourceKey("line3d-vertices"); } template typename MeshData::Type meshData(); - template<> inline Trade::MeshData2D meshData<2>() { return Primitives::Line2D::wireframe(); } - template<> inline Trade::MeshData3D meshData<3>() { return Primitives::Line3D::wireframe(); } + template<> inline Trade::MeshData2D meshData<2>() { return Primitives::line2D(); } + template<> inline Trade::MeshData3D meshData<3>() { return Primitives::line3D(); } } template LineSegmentRenderer::LineSegmentRenderer(const Shapes::Implementation::AbstractShape& line): AbstractShapeRenderer(meshKey(), vertexBufferKey(), {}), line(static_cast>&>(line).shape) { diff --git a/src/Magnum/DebugTools/Implementation/PointRenderer.cpp b/src/Magnum/DebugTools/Implementation/PointRenderer.cpp index 15079e150..7851bb7e7 100644 --- a/src/Magnum/DebugTools/Implementation/PointRenderer.cpp +++ b/src/Magnum/DebugTools/Implementation/PointRenderer.cpp @@ -45,8 +45,8 @@ namespace { template<> inline ResourceKey vertexBufferKey<3>() { return ResourceKey("point3d-vertices"); } template typename MeshData::Type meshData(); - template<> inline Trade::MeshData2D meshData<2>() { return Primitives::Crosshair2D::wireframe(); } - template<> inline Trade::MeshData3D meshData<3>() { return Primitives::Crosshair3D::wireframe(); } + template<> inline Trade::MeshData2D meshData<2>() { return Primitives::crosshair2D(); } + template<> inline Trade::MeshData3D meshData<3>() { return Primitives::crosshair3D(); } } template PointRenderer::PointRenderer(const Shapes::Implementation::AbstractShape& point): AbstractShapeRenderer(meshKey(), vertexBufferKey(), {}), point(static_cast>&>(point).shape) { diff --git a/src/Magnum/DebugTools/Implementation/SphereRenderer.cpp b/src/Magnum/DebugTools/Implementation/SphereRenderer.cpp index 0af88488e..cd7b11ba4 100644 --- a/src/Magnum/DebugTools/Implementation/SphereRenderer.cpp +++ b/src/Magnum/DebugTools/Implementation/SphereRenderer.cpp @@ -37,11 +37,11 @@ namespace Magnum { namespace DebugTools { namespace Implementation { AbstractSphereRenderer<2>::AbstractSphereRenderer(): AbstractShapeRenderer<2>("sphere2d", "sphere2d-vertices", {}) { - if(!wireframeMesh) createResources(Primitives::Circle::wireframe(40)); + if(!wireframeMesh) createResources(Primitives::circle2DWireframe(40)); } AbstractSphereRenderer<3>::AbstractSphereRenderer(): AbstractShapeRenderer<3>("sphere3d", "sphere3d-vertices", "sphere3d-indices") { - if(!wireframeMesh) createResources(Primitives::UVSphere::wireframe(20, 40)); + if(!wireframeMesh) createResources(Primitives::uvSphereWireframe(20, 40)); } template SphereRenderer::SphereRenderer(const Shapes::Implementation::AbstractShape& sphere): sphere(static_cast>&>(sphere).shape) {} diff --git a/src/Magnum/MeshTools/Test/SubdivideRemoveDuplicatesBenchmark.cpp b/src/Magnum/MeshTools/Test/SubdivideRemoveDuplicatesBenchmark.cpp index cc2afcc9c..69fde7d1c 100644 --- a/src/Magnum/MeshTools/Test/SubdivideRemoveDuplicatesBenchmark.cpp +++ b/src/Magnum/MeshTools/Test/SubdivideRemoveDuplicatesBenchmark.cpp @@ -56,7 +56,7 @@ namespace { void SubdivideRemoveDuplicatesBenchmark::subdivide() { CORRADE_BENCHMARK(3) { - Trade::MeshData3D icosphere = Primitives::Icosphere::solid(0); + Trade::MeshData3D icosphere = Primitives::icosphereSolid(0); /* Subdivide 5 times */ for(std::size_t i = 0; i != 5; ++i) @@ -66,7 +66,7 @@ void SubdivideRemoveDuplicatesBenchmark::subdivide() { void SubdivideRemoveDuplicatesBenchmark::subdivideAndRemoveDuplicatesAfter() { CORRADE_BENCHMARK(3) { - Trade::MeshData3D icosphere = Primitives::Icosphere::solid(0); + Trade::MeshData3D icosphere = Primitives::icosphereSolid(0); /* Subdivide 5 times */ for(std::size_t i = 0; i != 5; ++i) @@ -79,7 +79,7 @@ void SubdivideRemoveDuplicatesBenchmark::subdivideAndRemoveDuplicatesAfter() { void SubdivideRemoveDuplicatesBenchmark::subdivideAndRemoveDuplicatesInBetween() { CORRADE_BENCHMARK(3) { - Trade::MeshData3D icosphere = Primitives::Icosphere::solid(0); + Trade::MeshData3D icosphere = Primitives::icosphereSolid(0); /* Subdivide 5 times and remove duplicates during the operation */ for(std::size_t i = 0; i != 5; ++i) { diff --git a/src/Magnum/Primitives/Axis.h b/src/Magnum/Primitives/Axis.h index 2f3d947cd..d54b32c31 100644 --- a/src/Magnum/Primitives/Axis.h +++ b/src/Magnum/Primitives/Axis.h @@ -39,6 +39,7 @@ namespace Magnum { namespace Primitives { Two color-coded arrows for visualizing orientation (XY is RG). Indexed @ref MeshPrimitive::Lines with vertex colors. +@see @ref axis3D(), @ref crosshair2D(), @ref line2D() */ MAGNUM_PRIMITIVES_EXPORT Trade::MeshData2D axis2D(); @@ -47,6 +48,7 @@ MAGNUM_PRIMITIVES_EXPORT Trade::MeshData2D axis2D(); Three color-coded arrows for visualizing orientation (XYZ is RGB). Indexed @ref MeshPrimitive::Lines with vertex colors. +@see @ref axis2D(), @ref crosshair3D(), @ref line3D() */ MAGNUM_PRIMITIVES_EXPORT Trade::MeshData3D axis3D(); diff --git a/src/Magnum/Primitives/Capsule.cpp b/src/Magnum/Primitives/Capsule.cpp index 0317fd6d7..f6d123a2c 100644 --- a/src/Magnum/Primitives/Capsule.cpp +++ b/src/Magnum/Primitives/Capsule.cpp @@ -35,8 +35,9 @@ namespace Magnum { namespace Primitives { -Trade::MeshData2D Capsule2D::wireframe(UnsignedInt hemisphereRings, UnsignedInt cylinderRings, Float halfLength) { - CORRADE_ASSERT(hemisphereRings >= 1 && cylinderRings >= 1, "Capsule must have at least one hemisphere ring, one cylinder ring and three segments", +Trade::MeshData2D capsule2DWireframe(const UnsignedInt hemisphereRings, const UnsignedInt cylinderRings, const Float halfLength) { + CORRADE_ASSERT(hemisphereRings >= 1 && cylinderRings >= 1, + "Primitives::capsule2DWireframe(): at least one hemisphere ring and one cylinder ring expected", (Trade::MeshData2D{MeshPrimitive::Triangles, {}, {}, {}, {}, nullptr})); std::vector positions; @@ -91,11 +92,12 @@ Trade::MeshData2D Capsule2D::wireframe(UnsignedInt hemisphereRings, UnsignedInt return Trade::MeshData2D{MeshPrimitive::Lines, std::move(indices), {std::move(positions)}, {}, {}, nullptr}; } -Trade::MeshData3D Capsule3D::solid(UnsignedInt hemisphereRings, UnsignedInt cylinderRings, UnsignedInt segments, Float halfLength, TextureCoords textureCoords) { - CORRADE_ASSERT(hemisphereRings >= 1 && cylinderRings >= 1 && segments >= 3, "Capsule must have at least one hemisphere ring, one cylinder ring and three segments", +Trade::MeshData3D capsule3DSolid(const UnsignedInt hemisphereRings, const UnsignedInt cylinderRings, const UnsignedInt segments, const Float halfLength, const CapsuleTextureCoords textureCoords) { + CORRADE_ASSERT(hemisphereRings >= 1 && cylinderRings >= 1 && segments >= 3, + "Primitives::capsule3DSolid(): at least one hemisphere ring, one cylinder ring and three segments expected", (Trade::MeshData3D{MeshPrimitive::Triangles, {}, {}, {}, {}, {}, nullptr})); - Implementation::Spheroid capsule(segments, textureCoords == TextureCoords::Generate ? + Implementation::Spheroid capsule(segments, textureCoords == CapsuleTextureCoords::Generate ? Implementation::Spheroid::TextureCoords::Generate : Implementation::Spheroid::TextureCoords::DontGenerate); @@ -126,8 +128,9 @@ Trade::MeshData3D Capsule3D::solid(UnsignedInt hemisphereRings, UnsignedInt cyli return capsule.finalize(); } -Trade::MeshData3D Capsule3D::wireframe(const UnsignedInt hemisphereRings, const UnsignedInt cylinderRings, const UnsignedInt segments, const Float halfLength) { - CORRADE_ASSERT(hemisphereRings >= 1 && cylinderRings >= 1 && segments >= 4 && segments%4 == 0, "Primitives::Capsule::wireframe(): improper parameters", +Trade::MeshData3D capsule3DWireframe(const UnsignedInt hemisphereRings, const UnsignedInt cylinderRings, const UnsignedInt segments, const Float halfLength) { + CORRADE_ASSERT(hemisphereRings >= 1 && cylinderRings >= 1 && segments >= 4 && segments%4 == 0, + "Primitives::capsule3DWireframe(): at least one hemisphere and cylinder ring and multiples of 4 segments expected", (Trade::MeshData3D{MeshPrimitive::Triangles, {}, {}, {}, {}, {}, nullptr})); Implementation::WireframeSpheroid capsule(segments/4); @@ -148,4 +151,18 @@ Trade::MeshData3D Capsule3D::wireframe(const UnsignedInt hemisphereRings, const return capsule.finalize(); } +#ifdef MAGNUM_BUILD_DEPRECATED +Trade::MeshData2D Capsule2D::wireframe(const UnsignedInt hemisphereRings, const UnsignedInt cylinderRings, const Float halfLength) { + return capsule2DWireframe(hemisphereRings, cylinderRings, halfLength); +} + +Trade::MeshData3D Capsule3D::solid(const UnsignedInt hemisphereRings, const UnsignedInt cylinderRings, const UnsignedInt segments, const Float halfLength, const CapsuleTextureCoords textureCoords) { + return capsule3DSolid(hemisphereRings, cylinderRings, segments, halfLength, textureCoords); +} + +Trade::MeshData3D Capsule3D::wireframe(const UnsignedInt hemisphereRings, const UnsignedInt cylinderRings, const UnsignedInt segments, const Float halfLength) { + return capsule3DWireframe(hemisphereRings, cylinderRings, segments, halfLength); +} +#endif + }} diff --git a/src/Magnum/Primitives/Capsule.h b/src/Magnum/Primitives/Capsule.h index cfb052149..1dc569d13 100644 --- a/src/Magnum/Primitives/Capsule.h +++ b/src/Magnum/Primitives/Capsule.h @@ -26,84 +26,119 @@ */ /** @file - * @brief Class @ref Magnum::Primitives::Capsule2D, @ref Magnum::Primitives::Capsule3D + * @brief Function @ref Magnum::Primitives::capsule2DWireframe(), @ref Magnum::Primitives::capsule3DSolid(), @ref Magnum::Primitives::capsule3DWireframe() */ #include "Magnum/Primitives/visibility.h" #include "Magnum/Trade/Trade.h" +#ifdef MAGNUM_BUILD_DEPRECATED +#include +#endif + namespace Magnum { namespace Primitives { /** -@brief 2D capsule primitive +@brief Wireframe 2D capsule +@param hemisphereRings Number of (line) rings for each hemisphere. Must be + larger or equal to @cpp 1 @ce. +@param cylinderRings Number of (line) rings for cylinder. Must be larger or + equal to @cpp 1 @ce. +@param halfLength Half the length of cylinder part + +Cylinder of radius @cpp 1.0f @ce along Y axis with hemispheres instead of caps. +Indexed @ref MeshPrimitive::Lines. +@see @ref capsule3DSolid(), @ref capsule3DWireframe(), @ref circle2DWireframe(), + @ref squareWireframe() +*/ +MAGNUM_PRIMITIVES_EXPORT Trade::MeshData2D capsule2DWireframe(UnsignedInt hemisphereRings, UnsignedInt cylinderRings, Float halfLength); + +#ifdef MAGNUM_BUILD_DEPRECATED +/** +@brief 2D capsule +@deprecated Use @ref capsule2DWireframe() instead. +*/ +struct MAGNUM_PRIMITIVES_EXPORT Capsule2D { + /** @copybrief capsule2DWireframe() + * @deprecated Use @ref capsule2DWireframe() instead. + */ + CORRADE_DEPRECATED("use capsule2DWireframe() instead") static Trade::MeshData2D wireframe(UnsignedInt hemisphereRings, UnsignedInt cylinderRings, Float halfLength); +}; +#endif + +/** +@brief Whether to generate capsule texture coordinates -Cylinder of radius `1` along Y axis with hemispheres instead of caps. +@see @ref capsule3DSolid() */ -class MAGNUM_PRIMITIVES_EXPORT Capsule2D { - public: - /** - * @brief Wireframe capsule - * @param hemisphereRings Number of (line) rings for each hemisphere. - * Must be larger or equal to 1. - * @param cylinderRings Number of (line) rings for cylinder. Must be - * larger or equal to 1. - * @param halfLength Half the length of cylinder part - * - * Indexed @ref MeshPrimitive::Lines. - */ - static Trade::MeshData2D wireframe(UnsignedInt hemisphereRings, UnsignedInt cylinderRings, Float halfLength); +enum class CapsuleTextureCoords: UnsignedByte { + DontGenerate, /**< Don't generate texture coordinates */ + Generate /**< Generate texture coordinates */ }; /** -@brief 3D capsule primitive +@brief Solid 3D capsule +@param hemisphereRings Number of (face) rings for each hemisphere. Must be + larger or equal to @cpp 1 @ce. +@param cylinderRings Number of (face) rings for cylinder. Must be larger or + equal to @cpp 1 @ce. +@param segments Number of (face) segments. Must be larger or equal to + @cpp 3 @ce. +@param halfLength Half the length of cylinder part +@param textureCoords Whether to generate texture coordinates -Cylinder of radius `1` along Y axis with hemispheres instead of caps. +Cylinder of radius @cpp 1.0f @ce along Y axis with hemispheres instead of caps. +Indexed @ref MeshPrimitive::Triangles with normals and optional 2D texture +coordinates. If texture coordinates are generated, vertices of one segment are +duplicated for texture wrapping. + +The capsule is by default created with radius set to @f$ 1.0 @f$. In order to +get radius @f$ r @f$, length @f$ l @f$ and preserve correct normals, set +@p halfLength to @f$ 0.5 \frac{l}{r} @f$ and then scale all +@ref Trade::MeshData3D::positions() by @f$ r @f$, for example using +@ref MeshTools::transformPointsInPlace(). +@see @ref capsule3DWireframe(), @ref capsule2DWireframe(), @ref cylinderSolid() +*/ +MAGNUM_PRIMITIVES_EXPORT Trade::MeshData3D capsule3DSolid(UnsignedInt hemisphereRings, UnsignedInt cylinderRings, UnsignedInt segments, Float halfLength, CapsuleTextureCoords textureCoords = CapsuleTextureCoords::DontGenerate); + +/** +@brief Wireframe 3D capsule +@param hemisphereRings Number of (line) rings for each hemisphere. Must be + larger or equal to @cpp 1 @ce. +@param cylinderRings Number of (line) rings for cylinder. Must be larger or + equal to @cpp 1 @ce. +@param segments Number of line segments. Must be larger or equal to + @cpp 4 @ce and multiple of @cpp 4 @ce. +@param halfLength Half the length of cylinder part + +Cylinder of radius @cpp 1.0f @ce along Y axis with hemispheres instead of caps. +Indexed @ref MeshPrimitive::Lines. +@see @ref capsule2DWireframe(), @ref capsule3DSolid(), @ref cylinderSolid() */ -class MAGNUM_PRIMITIVES_EXPORT Capsule3D { - public: - /** @brief Whether to generate texture coordinates */ - enum class TextureCoords: UnsignedByte { - Generate, /**< Generate texture coordinates */ - DontGenerate /**< Don't generate texture coordinates */ - }; - - /** - * @brief Solid capsule - * @param hemisphereRings Number of (face) rings for each hemisphere. - * Must be larger or equal to 1. - * @param cylinderRings Number of (face) rings for cylinder. Must be - * larger or equal to 1. - * @param segments Number of (face) segments. Must be larger or - * equal to 3. - * @param halfLength Half the length of cylinder part - * @param textureCoords Whether to generate texture coordinates. - * - * Indexed @ref MeshPrimitive::Triangles with normals and optional 2D - * texture coordinates. If texture coordinates are generated, vertices - * of one segment are duplicated for texture wrapping. - * - * The capsule is by default created with radius set to @cpp 1.0f @ce. - * In order to get radius @f$ r @f$, length @f$ l @f$ and preserve - * correct normals, set @p halfLength to @f$ 0.5 \frac{l}{r} @f$ and - * then scale all @ref Trade::MeshData3D::positions() by @f$ r @f$, for - * example using @ref MeshTools::transformPointsInPlace(). - */ - static Trade::MeshData3D solid(UnsignedInt hemisphereRings, UnsignedInt cylinderRings, UnsignedInt segments, Float halfLength, TextureCoords textureCoords = TextureCoords::DontGenerate); - - /** - * @brief Wireframe capsule - * @param hemisphereRings Number of (line) rings for each hemisphere. - * Must be larger or equal to 1. - * @param cylinderRings Number of (line) rings for cylinder. Must be - * larger or equal to 1. - * @param segments Number of line segments. Must be larger or - * equal to 4 and multiple of 4. - * @param halfLength Half the length of cylinder part - * - * Indexed @ref MeshPrimitive::Lines. - */ - static Trade::MeshData3D wireframe(UnsignedInt hemisphereRings, UnsignedInt cylinderRings, UnsignedInt segments, Float halfLength); +MAGNUM_PRIMITIVES_EXPORT Trade::MeshData3D capsule3DWireframe(UnsignedInt hemisphereRings, UnsignedInt cylinderRings, UnsignedInt segments, Float halfLength); + +#ifdef MAGNUM_BUILD_DEPRECATED +/** +@brief 3D capsule +@deprecated Use @ref capsule3DSolid() or @ref capsule3DWireframe() instead. +*/ +struct MAGNUM_PRIMITIVES_EXPORT Capsule3D { + /** @brief @copybrief CapsuleTextureCoords + * @deprecated Use @ref CapsuleTextureCoords instead. + */ + typedef CORRADE_DEPRECATED("use CapsuleTextureCoords instead") CapsuleTextureCoords TextureCoords; + + /** @brief @copybrief capsule3DSolid() + * @deprecated Use @ref capsule3DSolid() instead. + */ + CORRADE_DEPRECATED("use capsule3DSolid() instead") static Trade::MeshData3D solid(UnsignedInt hemisphereRings, UnsignedInt cylinderRings, UnsignedInt segments, Float halfLength, CapsuleTextureCoords textureCoords = CapsuleTextureCoords::DontGenerate); + + /** @brief @copybrief capsule3DWireframe() + * @deprecated Use @ref capsule3DWireframe() instead. + */ + CORRADE_DEPRECATED("use capsule3DWireframe() instead") static Trade::MeshData3D wireframe(UnsignedInt hemisphereRings, UnsignedInt cylinderRings, UnsignedInt segments, Float halfLength); }; +#endif }} diff --git a/src/Magnum/Primitives/Circle.cpp b/src/Magnum/Primitives/Circle.cpp index ab117ad32..272d38778 100644 --- a/src/Magnum/Primitives/Circle.cpp +++ b/src/Magnum/Primitives/Circle.cpp @@ -32,8 +32,8 @@ namespace Magnum { namespace Primitives { -Trade::MeshData2D Circle::solid(UnsignedInt segments) { - CORRADE_ASSERT(segments >= 3, "Primitives::Circle::solid(): segments must be >= 3", +Trade::MeshData2D circle2DSolid(const UnsignedInt segments) { + CORRADE_ASSERT(segments >= 3, "Primitives::circle2DSolid(): segments must be >= 3", (Trade::MeshData2D{MeshPrimitive::TriangleFan, {}, {}, {}, {}, nullptr})); std::vector positions; @@ -53,8 +53,8 @@ Trade::MeshData2D Circle::solid(UnsignedInt segments) { return Trade::MeshData2D{MeshPrimitive::TriangleFan, {}, {std::move(positions)}, {}, {}, nullptr}; } -Trade::MeshData2D Circle::wireframe(UnsignedInt segments) { - CORRADE_ASSERT(segments >= 3, "Primitives::Circle::wireframe(): segments must be >= 3", +Trade::MeshData2D circle2DWireframe(const UnsignedInt segments) { + CORRADE_ASSERT(segments >= 3, "Primitives::circle2DWireframe(): segments must be >= 3", (Trade::MeshData2D{MeshPrimitive::LineLoop, {}, {}, {}, {}, nullptr})); std::vector positions; @@ -70,4 +70,14 @@ Trade::MeshData2D Circle::wireframe(UnsignedInt segments) { return Trade::MeshData2D{MeshPrimitive::LineLoop, {}, {std::move(positions)}, {}, {}, nullptr}; } +#ifdef MAGNUM_BUILD_DEPRECATED +Trade::MeshData2D Circle::solid(const UnsignedInt segments) { + return circle2DSolid(segments); +} + +Trade::MeshData2D Circle::wireframe(const UnsignedInt segments) { + return circle2DWireframe(segments); +} +#endif + }} diff --git a/src/Magnum/Primitives/Circle.h b/src/Magnum/Primitives/Circle.h index 23999839d..c9941ac4e 100644 --- a/src/Magnum/Primitives/Circle.h +++ b/src/Magnum/Primitives/Circle.h @@ -26,39 +26,53 @@ */ /** @file - * @brief Class @ref Magnum::Primitives::Circle + * @brief Function @ref Magnum::Primitives::circle2DSolid(), @ref Magnum::Primitives::circle2DWireframe() */ #include "Magnum/Primitives/visibility.h" #include "Magnum/Trade/Trade.h" +#ifdef MAGNUM_BUILD_DEPRECATED +#include +#endif + namespace Magnum { namespace Primitives { /** -@brief 2D circle primitive +@brief Solid 2D circle +@param segments Number of segments. Must be greater or equal to @cpp 3 @ce. + +Circle with radius @cpp 1.0f @ce. Non-indexed @ref MeshPrimitive::TriangleFan. +@see @ref circle2DWireframe() +*/ +MAGNUM_PRIMITIVES_EXPORT Trade::MeshData2D circle2DSolid(UnsignedInt segments); + +/** +@brief Wireframe 2D circle +@param segments Number of segments. Must be greater or equal to @cpp 3 @ce. -Circle with radius `1`. +Circle with radius @cpp 1.0f @ce. Non-indexed @ref MeshPrimitive::LineLoop. +@see @ref circle2DSolid() */ -class MAGNUM_PRIMITIVES_EXPORT Circle { - public: - /** - * @brief Solid circle - * @param segments Number of segments. Must be greater or equal to 3. - * - * Non-indexed @ref MeshPrimitive::TriangleFan. - */ - static Trade::MeshData2D solid(UnsignedInt segments); - - /** - * @brief Wireframe circle - * @param segments Number of segments. Must be greater or equal to 3. - * - * Non-indexed @ref MeshPrimitive::LineLoop. - */ - static Trade::MeshData2D wireframe(UnsignedInt segments); - - Circle() = delete; +MAGNUM_PRIMITIVES_EXPORT Trade::MeshData2D circle2DWireframe(UnsignedInt segments); + +#ifdef MAGNUM_BUILD_DEPRECATED +/** +@brief 2D circle primitive +@deprecated Use @ref circle2DSolid() or @ref circle2DWireframe() instead. +*/ +struct MAGNUM_PRIMITIVES_EXPORT Circle { + /** @brief @copybrief circle2DSolid() + * @deprecated Use @ref circle2DSolid() instead. + */ + CORRADE_DEPRECATED("use circle2DSolid() instead") static Trade::MeshData2D solid(UnsignedInt segments); + + /** @brief @copybrief circle2DWireframe() + * @deprecated Use @ref circle2DWireframe() instead. + */ + CORRADE_DEPRECATED("use circle2DWireframe() instead") static Trade::MeshData2D wireframe(UnsignedInt segments); }; +#endif }} diff --git a/src/Magnum/Primitives/Crosshair.cpp b/src/Magnum/Primitives/Crosshair.cpp index 854382100..9ca7932fd 100644 --- a/src/Magnum/Primitives/Crosshair.cpp +++ b/src/Magnum/Primitives/Crosshair.cpp @@ -32,14 +32,14 @@ namespace Magnum { namespace Primitives { -Trade::MeshData2D Crosshair2D::wireframe() { +Trade::MeshData2D crosshair2D() { return Trade::MeshData2D{MeshPrimitive::Lines, {}, {{ {-1.0f, 0.0f}, {1.0f, 0.0f}, { 0.0f, -1.0f}, {0.0f, 1.0f} }}, {}, {}, nullptr}; } -Trade::MeshData3D Crosshair3D::wireframe() { +Trade::MeshData3D crosshair3D() { return Trade::MeshData3D{MeshPrimitive::Lines, {}, {{ {-1.0f, 0.0f, 0.0f}, {1.0f, 0.0f, 0.0f}, { 0.0f, -1.0f, 0.0f}, {0.0f, 1.0f, 0.0f}, @@ -47,4 +47,14 @@ Trade::MeshData3D Crosshair3D::wireframe() { }}, {}, {}, {}, nullptr}; } +#ifdef MAGNUM_BUILD_DEPRECATED +Trade::MeshData2D Crosshair2D::wireframe() { + return crosshair2D(); +} + +Trade::MeshData3D Crosshair3D::wireframe() { + return crosshair3D(); +} +#endif + }} diff --git a/src/Magnum/Primitives/Crosshair.h b/src/Magnum/Primitives/Crosshair.h index 130c2a35c..c7d505ff2 100644 --- a/src/Magnum/Primitives/Crosshair.h +++ b/src/Magnum/Primitives/Crosshair.h @@ -26,41 +26,59 @@ */ /** @file - * @brief Class @ref Magnum::Primitives::Crosshair2D, @ref Magnum::Primitives::Crosshair3D + * @brief Function @ref Magnum::Primitives::crosshair2D(), @ref Magnum::Primitives::crosshair3D() */ #include "Magnum/Primitives/visibility.h" #include "Magnum/Trade/Trade.h" +#ifdef MAGNUM_BUILD_DEPRECATED +#include +#endif + namespace Magnum { namespace Primitives { /** -@brief 2D crosshair primitive +@brief 2D crosshair -2x2 wireframe crosshair (two crossed lines), non-indexed -@ref MeshPrimitive::Lines. +2x2 crosshair (two crossed lines), non-indexed @ref MeshPrimitive::Lines. +@see @ref crosshair3D(), @ref axis2D(), @ref line2D() */ -class MAGNUM_PRIMITIVES_EXPORT Crosshair2D { - public: - /** @brief Wireframe crosshair */ - static Trade::MeshData2D wireframe(); +MAGNUM_PRIMITIVES_EXPORT Trade::MeshData2D crosshair2D(); - Crosshair2D() = delete; +#ifdef MAGNUM_BUILD_DEPRECATED +/** +@brief 2D crosshair +@deprecated Use @ref crosshair2D() instead. +*/ +struct MAGNUM_PRIMITIVES_EXPORT Crosshair2D { + /** @brief @copybrief crosshair2D() + * @deprecated Use @ref crosshair2D() instead. + */ + CORRADE_DEPRECATED("use crosshair2D() instead") static Trade::MeshData2D wireframe(); }; +#endif /** -@brief 3D crosshair primitive +@brief 3D crosshair -2x2x2 wireframe crosshair (three crossed lines), non-indexed -@ref MeshPrimitive::Lines. +2x2x2 crosshair (three crossed lines), non-indexed @ref MeshPrimitive::Lines. +@see @ref crosshair2D(), @ref axis2D(), @ref line3D() */ -class MAGNUM_PRIMITIVES_EXPORT Crosshair3D { - public: - /** @brief Wireframe crosshair */ - static Trade::MeshData3D wireframe(); +MAGNUM_PRIMITIVES_EXPORT Trade::MeshData3D crosshair3D(); - Crosshair3D() = delete; +#ifdef MAGNUM_BUILD_DEPRECATED +/** +@brief 3D crosshair +@deprecated Use @ref crosshair3D() instead. +*/ +struct MAGNUM_PRIMITIVES_EXPORT Crosshair3D { + /** @brief @copybrief crosshair3D() + * @deprecated Use @ref crosshair3D() instead. + */ + CORRADE_DEPRECATED("use crosshair3D() instead") static Trade::MeshData3D wireframe(); }; +#endif }} diff --git a/src/Magnum/Primitives/Cube.cpp b/src/Magnum/Primitives/Cube.cpp index afa1fe935..b6e25add0 100644 --- a/src/Magnum/Primitives/Cube.cpp +++ b/src/Magnum/Primitives/Cube.cpp @@ -31,7 +31,7 @@ namespace Magnum { namespace Primitives { -Trade::MeshData3D Cube::solid() { +Trade::MeshData3D cubeSolid() { return Trade::MeshData3D{MeshPrimitive::Triangles, { 0, 1, 2, 0, 2, 3, /* +Z */ 4, 5, 6, 4, 6, 7, /* +X */ @@ -102,7 +102,7 @@ Trade::MeshData3D Cube::solid() { }}, {}, {}, nullptr}; } -Trade::MeshData3D Cube::solidStrip() { +Trade::MeshData3D cubeSolidStrip() { /* Sources: https://twitter.com/Donzanoid/status/436843034966507520 http://www.asmcommunity.net/forums/topic/?id=6284#post-45209 @@ -144,7 +144,7 @@ Trade::MeshData3D Cube::solidStrip() { }}, {}, {}, {}, nullptr}; } -Trade::MeshData3D Cube::wireframe() { +Trade::MeshData3D cubeWireframe() { return Trade::MeshData3D{MeshPrimitive::Lines, { 0, 1, 1, 2, 2, 3, 3, 0, /* +Z */ 4, 5, 5, 6, 6, 7, 7, 4, /* -Z */ @@ -163,4 +163,18 @@ Trade::MeshData3D Cube::wireframe() { }}, {}, {}, {}, nullptr}; } +#ifdef MAGNUM_BUILD_DEPRECATED +Trade::MeshData3D Cube::solid() { + return cubeSolid(); +} + +Trade::MeshData3D Cube::solidStrip() { + return cubeSolidStrip(); +} + +Trade::MeshData3D Cube::wireframe() { + return cubeWireframe(); +} +#endif + }} diff --git a/src/Magnum/Primitives/Cube.h b/src/Magnum/Primitives/Cube.h index 9b91d51ba..676b55f9e 100644 --- a/src/Magnum/Primitives/Cube.h +++ b/src/Magnum/Primitives/Cube.h @@ -26,45 +26,66 @@ */ /** @file - * @brief Class @ref Magnum::Primitives::Cube + * @brief Function @ref Magnum::Primitives::cubeSolid(), @ref Magnum::Primitives::cubeSolidStrip(), @ref Magnum::Primitives::cubeWireframe() */ #include "Magnum/Primitives/visibility.h" #include "Magnum/Trade/Trade.h" +#ifdef MAGNUM_BUILD_DEPRECATED +#include +#endif + namespace Magnum { namespace Primitives { /** -@brief 3D cube primitive +@brief Solid 3D cube + +Indexed @ref MeshPrimitive::Triangles with flat normals. +@see @ref cubeSolidStrip(), @ref cubeWireframe() +*/ +MAGNUM_PRIMITIVES_EXPORT Trade::MeshData3D cubeSolid(); + +/** +@brief Solid 3D cube as a single strip + +Non-indexed @ref MeshPrimitive::TriangleStrip. Just positions, no +normals or anything else. +@see @ref cubeSolid(), @ref cubeWireframe() +*/ +MAGNUM_PRIMITIVES_EXPORT Trade::MeshData3D cubeSolidStrip(); + +/** +@brief Wireframe 3D cube + +Indexed @ref MeshPrimitive::Lines. +@see @ref cubeSolid(), @ref cubeSolidStrip() +*/ +MAGNUM_PRIMITIVES_EXPORT Trade::MeshData3D cubeWireframe(); -2x2x2 cube. +#ifdef MAGNUM_BUILD_DEPRECATED +/** +@brief 3D cube +@deprecated Use @ref cubeSolid(), @ref cubeSolidStrip() or @ref cubeWireframe() + instead. */ -class MAGNUM_PRIMITIVES_EXPORT Cube { - public: - /** - * @brief Solid cube - * - * Indexed @ref MeshPrimitive::Triangles with flat normals. - */ - static Trade::MeshData3D solid(); - - /** - * @brief Solid cube as a single strip - * - * Non-indexed @ref MeshPrimitive::TriangleStrip. Just positions, no - * normals or anything else. - */ - static Trade::MeshData3D solidStrip(); - - /** - * @brief Wireframe cube - * - * Indexed @ref MeshPrimitive::Lines. - */ - static Trade::MeshData3D wireframe(); - - Cube() = delete; +struct MAGNUM_PRIMITIVES_EXPORT Cube { + /** @brief @copybrief cubeSolid() + * @deprecated Use @ref cubeSolid() instead. + */ + CORRADE_DEPRECATED("use cubeSolid() instead") static Trade::MeshData3D solid(); + + /** @brief @copybrief cubeSolidStrip() + * @deprecated Use @ref cubeSolidStrip() instead. + */ + CORRADE_DEPRECATED("use cubeSolidStrip() instead") static Trade::MeshData3D solidStrip(); + + /** @brief @copybrief cubeWireframe() + * @deprecated Use @ref cubeWireframe() instead. + */ + CORRADE_DEPRECATED("use cubeWireframe() instead") static Trade::MeshData3D wireframe(); }; +#endif }} diff --git a/src/Magnum/Primitives/Cylinder.cpp b/src/Magnum/Primitives/Cylinder.cpp index 599d698ce..a7781e47a 100644 --- a/src/Magnum/Primitives/Cylinder.cpp +++ b/src/Magnum/Primitives/Cylinder.cpp @@ -33,40 +33,42 @@ namespace Magnum { namespace Primitives { -Trade::MeshData3D Cylinder::solid(const UnsignedInt rings, const UnsignedInt segments, const Float halfLength, const Flags flags) { - CORRADE_ASSERT(rings >= 1 && segments >= 3, "Primitives::Cylinder::solid(): cylinder must have at least one ring and three segments", +Trade::MeshData3D cylinderSolid(const UnsignedInt rings, const UnsignedInt segments, const Float halfLength, const CylinderFlags flags) { + CORRADE_ASSERT(rings >= 1 && segments >= 3, + "Primitives::cylinderSolid(): at least one ring and three segments expected", (Trade::MeshData3D{MeshPrimitive::Triangles, {}, {}, {}, {}, {}, nullptr})); - Implementation::Spheroid cylinder(segments, flags & Flag::GenerateTextureCoords ? Implementation::Spheroid::TextureCoords::Generate : Implementation::Spheroid::TextureCoords::DontGenerate); + Implementation::Spheroid cylinder(segments, flags & CylinderFlag::GenerateTextureCoords ? Implementation::Spheroid::TextureCoords::Generate : Implementation::Spheroid::TextureCoords::DontGenerate); const Float length = 2.0f*halfLength; - const Float textureCoordsV = flags & Flag::CapEnds ? 1.0f/(length+2.0f) : 0.0f; + const Float textureCoordsV = flags & CylinderFlag::CapEnds ? 1.0f/(length+2.0f) : 0.0f; /* Bottom cap */ - if(flags & Flag::CapEnds) { + if(flags & CylinderFlag::CapEnds) { cylinder.capVertex(-halfLength, -1.0f, 0.0f); cylinder.capVertexRing(-halfLength, textureCoordsV, Vector3::yAxis(-1.0f)); } /* Vertex rings */ - cylinder.cylinderVertexRings(rings+1, -halfLength, length/rings, textureCoordsV, length/(rings*(flags & Flag::CapEnds ? length + 2.0f : length))); + cylinder.cylinderVertexRings(rings+1, -halfLength, length/rings, textureCoordsV, length/(rings*(flags & CylinderFlag::CapEnds ? length + 2.0f : length))); /* Top cap */ - if(flags & Flag::CapEnds) { + if(flags & CylinderFlag::CapEnds) { cylinder.capVertexRing(halfLength, 1.0f - textureCoordsV, Vector3::yAxis(1.0f)); cylinder.capVertex(halfLength, 1.0f, 1.0f); } /* Faces */ - if(flags & Flag::CapEnds) cylinder.bottomFaceRing(); - cylinder.faceRings(rings, flags & Flag::CapEnds ? (1 + segments) : 0); - if(flags & Flag::CapEnds) cylinder.topFaceRing(); + if(flags & CylinderFlag::CapEnds) cylinder.bottomFaceRing(); + cylinder.faceRings(rings, flags & CylinderFlag::CapEnds ? (1 + segments) : 0); + if(flags & CylinderFlag::CapEnds) cylinder.topFaceRing(); return cylinder.finalize(); } -Trade::MeshData3D Cylinder::wireframe(const UnsignedInt rings, const UnsignedInt segments, const Float halfLength) { - CORRADE_ASSERT(rings >= 1 && segments >= 4 && segments%4 == 0, "Primitives::Cylinder::wireframe(): improper parameters", +Trade::MeshData3D cylinderWireframe(const UnsignedInt rings, const UnsignedInt segments, const Float halfLength) { + CORRADE_ASSERT(rings >= 1 && segments >= 4 && segments%4 == 0, + "Primitives::cylinderWireframe(): at least one ring and multiples of 4 segments expected", (Trade::MeshData3D{MeshPrimitive::Lines, {}, {}, {}, {}, {}, nullptr})); Implementation::WireframeSpheroid cylinder(segments/4); @@ -83,4 +85,14 @@ Trade::MeshData3D Cylinder::wireframe(const UnsignedInt rings, const UnsignedInt return cylinder.finalize(); } +#ifdef MAGNUM_BUILD_DEPRECATED +Trade::MeshData3D Cylinder::solid(const UnsignedInt rings, const UnsignedInt segments, const Float halfLength, const CylinderFlags flags) { + return cylinderSolid(rings, segments, halfLength, flags); +} + +Trade::MeshData3D Cylinder::wireframe(const UnsignedInt rings, const UnsignedInt segments, const Float halfLength) { + return cylinderWireframe(rings, segments, halfLength); +} +#endif + }} diff --git a/src/Magnum/Primitives/Cylinder.h b/src/Magnum/Primitives/Cylinder.h index bb1201471..8e6578faf 100644 --- a/src/Magnum/Primitives/Cylinder.h +++ b/src/Magnum/Primitives/Cylinder.h @@ -26,7 +26,7 @@ */ /** @file - * @brief Class @ref Magnum::Primitives::Cylinder + * @brief Function @ref Magnum::Primitives::cylinderSolid(), @ref Magnum::Primitives::cylinderWireframe() */ #include @@ -38,65 +38,89 @@ namespace Magnum { namespace Primitives { /** -@brief 3D cylinder primitive +@brief Cylinder flag -Cylinder along Y axis of radius `1`. +@see @ref CylinderFlags, @ref cylinderSolid() */ -class MAGNUM_PRIMITIVES_EXPORT Cylinder { - public: - /** - * @brief Flag - * - * @see @ref Flags, @ref solid(), @ref wireframe() - */ - enum class Flag { - GenerateTextureCoords = 1, /**< Generate texture coordinates */ - CapEnds /**< Cap ends */ - }; - - /** - * @brief Flags - * - * @see @ref solid(), @ref wireframe() - */ - typedef Containers::EnumSet Flags; - - /** - * @brief Solid cylinder - * @param rings Number of (face) rings. Must be larger or - * equal to 1. - * @param segments Number of (face) segments. Must be larger or - * equal to 3. - * @param halfLength Half the cylinder length - * @param flags Flags - * - * Indexed @ref MeshPrimitive::Triangles with normals, optional 2D - * texture coordinates and optional capped ends. If texture coordinates - * are generated, vertices of one segment are duplicated for texture - * wrapping. - * - * The cylinder is by default created with radius set to @cpp 1.0f @ce. - * In order to get radius @f$ r @f$, length @f$ l @f$ and preserve - * correct normals, set @p halfLength to @f$ 0.5 \frac{l}{r} @f$ and - * then scale all @ref Trade::MeshData3D::positions() by @f$ r @f$, for - * example using @ref MeshTools::transformPointsInPlace(). - */ - static Trade::MeshData3D solid(UnsignedInt rings, UnsignedInt segments, Float halfLength, Flags flags = Flags()); - - /** - * @brief Wireframe cylinder - * @param rings Number of (line) rings. Must be larger or equal - * to 1. - * @param segments Number of (line) segments. Must be larger or - * equal to 4 and multiple of 4. - * @param halfLength Half the cylinder length - * - * Indexed @ref MeshPrimitive::Lines. - */ - static Trade::MeshData3D wireframe(UnsignedInt rings, UnsignedInt segments, Float halfLength); +enum class CylinderFlag { + GenerateTextureCoords = 1 << 0, /**< Generate texture coordinates */ + CapEnds = 1 << 1 /**< Cap ends */ }; -CORRADE_ENUMSET_OPERATORS(Cylinder::Flags) +/** +@brief Cylinder flags + +@see @ref cylinderSolid() +*/ +typedef Containers::EnumSet CylinderFlags; + +CORRADE_ENUMSET_OPERATORS(CylinderFlags) + +/** +@brief Solid 3D cylinder +@param rings Number of (face) rings. Must be larger or equal to + @cpp 1 @ce. +@param segments Number of (face) segments. Must be larger or equal to + @cpp 3 @ce. +@param halfLength Half the cylinder length +@param flags Flags + +Cylinder along Y axis of radius @cpp 1.0f @ce. Indexed +@ref MeshPrimitive::Triangles with normals, optional 2D texture coordinates and +optional capped ends. If texture coordinates are generated, vertices of one +segment are duplicated for texture wrapping. + + +The cylinder is by default created with radius set to @f$ 1.0 @f$. In order to +get radius @f$ r @f$, length @f$ l @f$ and preserve correct normals, set +@p halfLength to @f$ 0.5 \frac{l}{r} @f$ and then scale all +@ref Trade::MeshData3D::positions() by @f$ r @f$, for example using +@ref MeshTools::transformPointsInPlace(). +@see @ref cylinderWireframe() +*/ +MAGNUM_PRIMITIVES_EXPORT Trade::MeshData3D cylinderSolid(UnsignedInt rings, UnsignedInt segments, Float halfLength, CylinderFlags flags = {}); + +/** +@brief Wireframe 3D cylinder +@param rings Number of (line) rings. Must be larger or equal to + @cpp 1 @ce. +@param segments Number of (line) segments. Must be larger or equal to + @cpp 4 @ce and multiple of @cpp 4 @ce. +@param halfLength Half the cylinder length + +Cylinder along Y axis of radius @cpp 1.0f @ce. Indexed +@ref MeshPrimitive::Lines. +@see @ref cylinderSolid() +*/ +MAGNUM_PRIMITIVES_EXPORT Trade::MeshData3D cylinderWireframe(UnsignedInt rings, UnsignedInt segments, Float halfLength); + +#ifdef MAGNUM_BUILD_DEPRECATED +/** +@brief 3D cylinder +@deprecated Use @ref cylinderSolid() or @ref cylinderWireframe() instead. +*/ +struct MAGNUM_PRIMITIVES_EXPORT Cylinder { + /** @brief @copybrief CylinderFlag + * @deprecated Use @ref CylinderFlag instead. + */ + typedef CORRADE_DEPRECATED("use CylinderFlag instead") CylinderFlag Flag; + + /** @brief @copybrief CylinderFlags + * @deprecated Use @ref CylinderFlags instead. + */ + typedef CORRADE_DEPRECATED("use CylinderFlags instead") CylinderFlags Flags; + + /** @brief @copybrief cylinderSolid() + * @deprecated Use @ref cylinderSolid() instead. + */ + CORRADE_DEPRECATED("use cylinderSolid() instead") static Trade::MeshData3D solid(UnsignedInt rings, UnsignedInt segments, Float halfLength, CylinderFlags flags = {}); + + /** @brief @copybrief cylinderWireframe() + * @deprecated Use @ref cylinderWireframe() instead. + */ + CORRADE_DEPRECATED("use cylinderWireframe() instead") static Trade::MeshData3D wireframe(UnsignedInt rings, UnsignedInt segments, Float halfLength); +}; +#endif }} diff --git a/src/Magnum/Primitives/Icosphere.cpp b/src/Magnum/Primitives/Icosphere.cpp index be6ef114b..f7b7ca035 100644 --- a/src/Magnum/Primitives/Icosphere.cpp +++ b/src/Magnum/Primitives/Icosphere.cpp @@ -34,7 +34,7 @@ namespace Magnum { namespace Primitives { -Trade::MeshData3D Icosphere::solid(const UnsignedInt subdivisions) { +Trade::MeshData3D icosphereSolid(const UnsignedInt subdivisions) { std::vector indices{ 1, 2, 6, 1, 7, 2, @@ -84,4 +84,10 @@ Trade::MeshData3D Icosphere::solid(const UnsignedInt subdivisions) { return Trade::MeshData3D{MeshPrimitive::Triangles, std::move(indices), {std::move(positions)}, {std::move(normals)}, {}, {}, nullptr}; } +#ifdef MAGNUM_BUILD_DEPRECATED +Trade::MeshData3D Icosphere::solid(const UnsignedInt subdivisions) { + return icosphereSolid(subdivisions); +} +#endif + }} diff --git a/src/Magnum/Primitives/Icosphere.h b/src/Magnum/Primitives/Icosphere.h index 21f0bfbdc..df96855cd 100644 --- a/src/Magnum/Primitives/Icosphere.h +++ b/src/Magnum/Primitives/Icosphere.h @@ -26,29 +26,40 @@ */ /** @file - * @brief Class @ref Magnum::Primitives::Icosphere + * @brief Function @ref Magnum::Primitives::icosphereSolid() */ #include "Magnum/Primitives/visibility.h" #include "Magnum/Trade/Trade.h" +#ifdef MAGNUM_BUILD_DEPRECATED +#include +#endif + namespace Magnum { namespace Primitives { /** -@brief 3D icosphere primitive +@brief Solid 3D icosphere +@param subdivisions Number of subdivisions + +Sphere with radius @cpp 1.0f @ce. Indexed @ref MeshPrimitive::Triangles with +normals. +@see @ref uvSphereSolid(), @ref uvSphereWireframe() +*/ +MAGNUM_PRIMITIVES_EXPORT Trade::MeshData3D icosphereSolid(UnsignedInt subdivisions); -Sphere with radius `1`. +#ifdef MAGNUM_BUILD_DEPRECATED +/** +@brief 3D icosphere +@deprecated Use @ref icosphereSolid() instead. */ -class MAGNUM_PRIMITIVES_EXPORT Icosphere { - public: - /** - * @brief Solid icosphere - * @param subdivisions Number of subdivisions - * - * Indexed @ref MeshPrimitive::Triangles with normals. - */ - static Trade::MeshData3D solid(UnsignedInt subdivisions); +struct MAGNUM_PRIMITIVES_EXPORT Icosphere { + /** @brief @copybrief icosphereSolid() + * @deprecated Use @ref icosphereSolid() instead. + */ + CORRADE_DEPRECATED("use icosphereSolid() instead") static Trade::MeshData3D solid(UnsignedInt subdivisions); }; +#endif }} diff --git a/src/Magnum/Primitives/Line.cpp b/src/Magnum/Primitives/Line.cpp index 6b8ad7279..d1183aba8 100644 --- a/src/Magnum/Primitives/Line.cpp +++ b/src/Magnum/Primitives/Line.cpp @@ -32,16 +32,26 @@ namespace Magnum { namespace Primitives { -Trade::MeshData2D Line2D::wireframe() { +Trade::MeshData2D line2D() { return Trade::MeshData2D{MeshPrimitive::Lines, {}, {{ {0.0f, 0.0f}, {1.0f, 0.0f} }}, {}, {}, nullptr}; } -Trade::MeshData3D Line3D::wireframe() { +Trade::MeshData3D line3D() { return Trade::MeshData3D{MeshPrimitive::Lines, {}, {{ {0.0f, 0.0f, 0.0f}, {1.0f, 0.0f, 0.0f}, }}, {}, {}, {}, nullptr}; } +#ifdef MAGNUM_BUILD_DEPRECATED +Trade::MeshData2D Line2D::wireframe() { + return line2D(); +} + +Trade::MeshData3D Line3D::wireframe() { + return line3D(); +} +#endif + }} diff --git a/src/Magnum/Primitives/Line.h b/src/Magnum/Primitives/Line.h index 057eda345..4f573ba91 100644 --- a/src/Magnum/Primitives/Line.h +++ b/src/Magnum/Primitives/Line.h @@ -26,42 +26,60 @@ */ /** @file - * @brief Class @ref Magnum::Primitives::Line2D, @ref Magnum::Primitives::Line3D + * @brief Function @ref Magnum::Primitives::line2D(), @ref Magnum::Primitives::line3D() */ #include "Magnum/Primitives/visibility.h" #include "Magnum/Trade/Trade.h" +#ifdef MAGNUM_BUILD_DEPRECATED +#include +#endif + namespace Magnum { namespace Primitives { /** -@brief 2D line primitive +@brief 2D line Unit-size line in direction of positive X axis. Non-indexed @ref MeshPrimitive::Lines. +@see @ref line3D(), @ref axis2D(), @ref crosshair2D() */ -class MAGNUM_PRIMITIVES_EXPORT Line2D { - public: - /** @brief Wireframe line */ - static Trade::MeshData2D wireframe(); - - Line2D() = delete; -}; +MAGNUM_PRIMITIVES_EXPORT Trade::MeshData2D line2D(); /** -@brief 3D line primitive +@brief 3D line Unit-size line in direction of positive X axis. Non-indexed @ref MeshPrimitive::Lines. +@see @ref line2D(), @ref axis3D(), @ref crosshair3D() */ -class MAGNUM_PRIMITIVES_EXPORT Line3D { - public: - /** @brief Wireframe line */ - static Trade::MeshData3D wireframe(); +MAGNUM_PRIMITIVES_EXPORT Trade::MeshData3D line3D(); - Line3D() = delete; +#ifdef MAGNUM_BUILD_DEPRECATED +/** +@brief 2D line +@deprecated Use @ref line2D() instead. +*/ +struct MAGNUM_PRIMITIVES_EXPORT Line2D { + /** @brief @copybrief line2D() + * @deprecated Use @ref line2D() instead. + */ + CORRADE_DEPRECATED("use line2D() instead") static Trade::MeshData2D wireframe(); }; +/** +@brief 3D line +@deprecated Use @ref line3D() instead. +*/ +struct MAGNUM_PRIMITIVES_EXPORT Line3D { + /** @brief @copybrief line3D() + * @deprecated Use @ref line3D() instead. + */ + CORRADE_DEPRECATED("use line3D() instead") static Trade::MeshData3D wireframe(); +}; +#endif + }} #endif diff --git a/src/Magnum/Primitives/Plane.cpp b/src/Magnum/Primitives/Plane.cpp index 00bdb7644..d21e41728 100644 --- a/src/Magnum/Primitives/Plane.cpp +++ b/src/Magnum/Primitives/Plane.cpp @@ -31,9 +31,9 @@ namespace Magnum { namespace Primitives { -Trade::MeshData3D Plane::solid(const TextureCoords textureCoords) { +Trade::MeshData3D planeSolid(const PlaneTextureCoords textureCoords) { std::vector> coords; - if(textureCoords == TextureCoords::Generate) coords.push_back({ + if(textureCoords == PlaneTextureCoords::Generate) coords.push_back({ {1.0f, 0.0f}, {1.0f, 1.0f}, {0.0f, 0.0f}, @@ -53,7 +53,7 @@ Trade::MeshData3D Plane::solid(const TextureCoords textureCoords) { }}, std::move(coords), {}, nullptr}; } -Trade::MeshData3D Plane::wireframe() { +Trade::MeshData3D planeWireframe() { return Trade::MeshData3D{MeshPrimitive::LineLoop, {}, {{ {-1.0f, -1.0f, 0.0f}, {1.0f, -1.0f, 0.0f}, @@ -62,4 +62,14 @@ Trade::MeshData3D Plane::wireframe() { }}, {}, {}, {}, nullptr}; } +#ifdef MAGNUM_BUILD_DEPRECATED +Trade::MeshData3D Plane::solid(const PlaneTextureCoords textureCoords) { + return planeSolid(textureCoords); +} + +Trade::MeshData3D Plane::wireframe() { + return planeWireframe(); +} +#endif + }} diff --git a/src/Magnum/Primitives/Plane.h b/src/Magnum/Primitives/Plane.h index deae5e07a..558235c7d 100644 --- a/src/Magnum/Primitives/Plane.h +++ b/src/Magnum/Primitives/Plane.h @@ -26,47 +26,69 @@ */ /** @file - * @brief Class @ref Magnum::Primitives::Plane + * @brief Function @ref Magnum::Primitives::planeSolid(), @ref Magnum::Primitives::planeWireframe() */ #include "Magnum/Trade/Trade.h" #include "Magnum/Primitives/visibility.h" +#ifdef MAGNUM_BUILD_DEPRECATED +#include +#endif + namespace Magnum { namespace Primitives { /** -@brief 3D plane primitive +@brief Whether to generate plane texture coordinates + +@see @ref planeSolid() +*/ +enum class PlaneTextureCoords: UnsignedByte { + DontGenerate, /**< Don't generate texture coordinates */ + + /** Generate texture coordinates with origin in bottom left corner. */ + Generate +}; + +/** +@brief Solid 3D plane + +2x2 plane. Non-indexed @ref MeshPrimitive::TriangleStrip on the XY plane with +normals in positive Z direction. +@see @ref planeWireframe(), @ref squareSolid() +*/ +MAGNUM_PRIMITIVES_EXPORT Trade::MeshData3D planeSolid(PlaneTextureCoords textureCoords = PlaneTextureCoords::DontGenerate); + +/** +@brief Wireframe 3D plane -2x2 plane. -@see @ref Square +2x2 plane. Non-indexed @ref MeshPrimitive::LineLoop on the XY plane. +@see @ref planeSolid(), @ref squareWireframe() */ -class MAGNUM_PRIMITIVES_EXPORT Plane { - public: - /** @brief Whether to generate texture coordinates */ - enum class TextureCoords: UnsignedByte { - DontGenerate, /**< Don't generate texture coordinates */ - - /** Generate texture coordinates with origin in bottom left corner. */ - Generate - }; - - /** - * @brief Solid plane - * - * Non-indexed @ref MeshPrimitive::TriangleStrip with normals in - * positive Z direction. - */ - static Trade::MeshData3D solid(TextureCoords textureCoords = TextureCoords::DontGenerate); - - /** - * @brief Wireframe plane - * - * Non-indexed @ref MeshPrimitive::LineLoop. - */ - static Trade::MeshData3D wireframe(); - - Plane() = delete; +MAGNUM_PRIMITIVES_EXPORT Trade::MeshData3D planeWireframe(); + +#ifdef MAGNUM_BUILD_DEPRECATED +/** +@brief 3D plane +@deprecated Use @ref planeSolid() or @ref planeWireframe() instead. +*/ +struct MAGNUM_PRIMITIVES_EXPORT Plane { + /** @brief @copybrief PlaneTextureCoords + * @deprecated Use @ref PlaneTextureCoords instead. + */ + typedef CORRADE_DEPRECATED("use PlaneTextureCoords instead") PlaneTextureCoords TextureCoords; + + /** @brief @copybrief planeSolid() + * @deprecated Use @ref planeSolid() instead. + */ + CORRADE_DEPRECATED("use planeSolid() instead") static Trade::MeshData3D solid(PlaneTextureCoords textureCoords = PlaneTextureCoords::DontGenerate); + + /** @brief @copybrief planeWireframe() + * @deprecated Use @ref planeWireframe() instead. + */ + CORRADE_DEPRECATED("use planeWireframe() instead") static Trade::MeshData3D wireframe(); }; +#endif }} diff --git a/src/Magnum/Primitives/Square.cpp b/src/Magnum/Primitives/Square.cpp index 36e9a59d7..1dc5d7cf9 100644 --- a/src/Magnum/Primitives/Square.cpp +++ b/src/Magnum/Primitives/Square.cpp @@ -31,9 +31,9 @@ namespace Magnum { namespace Primitives { -Trade::MeshData2D Square::solid(const TextureCoords textureCoords) { +Trade::MeshData2D squareSolid(const SquareTextureCoords textureCoords) { std::vector> coords; - if(textureCoords == TextureCoords::Generate) coords.push_back({ + if(textureCoords == SquareTextureCoords::Generate) coords.push_back({ {1.0f, 0.0f}, {1.0f, 1.0f}, {0.0f, 0.0f}, @@ -48,7 +48,7 @@ Trade::MeshData2D Square::solid(const TextureCoords textureCoords) { }}, std::move(coords), {}, nullptr}; } -Trade::MeshData2D Square::wireframe() { +Trade::MeshData2D squareWireframe() { return Trade::MeshData2D{MeshPrimitive::LineLoop, {}, {{ {-1.0f, -1.0f}, {1.0f, -1.0f}, @@ -57,4 +57,14 @@ Trade::MeshData2D Square::wireframe() { }}, {}, {}, nullptr}; } +#ifdef MAGNUM_BUILD_DEPRECATED +Trade::MeshData2D Square::solid(const SquareTextureCoords textureCoords) { + return squareSolid(textureCoords); +} + +Trade::MeshData2D Square::wireframe() { + return squareWireframe(); +} +#endif + }} diff --git a/src/Magnum/Primitives/Square.h b/src/Magnum/Primitives/Square.h index 3bcf725ec..6ec853b37 100644 --- a/src/Magnum/Primitives/Square.h +++ b/src/Magnum/Primitives/Square.h @@ -26,46 +26,68 @@ */ /** @file - * @brief Class @ref Magnum::Primitives::Square + * @brief Function @ref Magnum::Primitives::squareSolid(), @ref Magnum::Primitives::squareWireframe() */ #include "Magnum/Primitives/visibility.h" #include "Magnum/Trade/Trade.h" +#ifdef MAGNUM_BUILD_DEPRECATED +#include +#endif + namespace Magnum { namespace Primitives { /** -@brief 2D square primitive +@brief Whether to generate square texture coordinates + +@see @ref squareSolid() +*/ +enum class SquareTextureCoords: UnsignedByte { + DontGenerate, /**< Don't generate texture coordinates */ + + /** Generate texture coordinates with origin in bottom left corner. */ + Generate +}; + +/** +@brief Solid 2D square + +2x2 square. Non-indexed @ref MeshPrimitive::TriangleStrip. +@see @ref squareWireframe(), @ref planeSolid() +*/ +MAGNUM_PRIMITIVES_EXPORT Trade::MeshData2D squareSolid(SquareTextureCoords textureCoords = SquareTextureCoords::DontGenerate); + +/** +@brief Wireframe 2D square -2x2 square. -@see @ref Plane +2x2 square. Non-indexed @ref MeshPrimitive::LineLoop. +@see @ref squareSolid(), @ref planeWireframe() */ -class MAGNUM_PRIMITIVES_EXPORT Square { - public: - /** @brief Whether to generate texture coordinates */ - enum class TextureCoords: UnsignedByte { - DontGenerate, /**< Don't generate texture coordinates */ - - /** Generate texture coordinates with origin in bottom left corner. */ - Generate - }; - - /** - * @brief Solid square - * - * Non-indexed @ref MeshPrimitive::TriangleStrip. - */ - static Trade::MeshData2D solid(TextureCoords textureCoords = TextureCoords::DontGenerate); - - /** - * @brief Wireframe square - * - * Non-indexed @ref MeshPrimitive::LineLoop. - */ - static Trade::MeshData2D wireframe(); - - Square() = delete; +MAGNUM_PRIMITIVES_EXPORT Trade::MeshData2D squareWireframe(); + +#ifdef MAGNUM_BUILD_DEPRECATED +/** +@brief 2D square +@deprecated Use @ref squareSolid() or @ref squareWireframe() instead. +*/ +struct MAGNUM_PRIMITIVES_EXPORT Square { + /** @brief @copybrief SquareTextureCoords + * @deprecated Use @ref SquareTextureCoords instead. + */ + typedef CORRADE_DEPRECATED("use SquareTextureCoords instead") SquareTextureCoords TextureCoords; + + /** @brief @copybrief squareSolid() + * @deprecated Use @ref squareWireframe() instead. + */ + CORRADE_DEPRECATED("use squareSolid() instead") static Trade::MeshData2D solid(SquareTextureCoords textureCoords = SquareTextureCoords::DontGenerate); + + /** @brief @copybrief squareWireframe() + * @deprecated Use @ref squareWireframe() instead. + */ + CORRADE_DEPRECATED("use squareWireframe() instead") static Trade::MeshData2D wireframe(); }; +#endif }} diff --git a/src/Magnum/Primitives/Test/CapsuleTest.cpp b/src/Magnum/Primitives/Test/CapsuleTest.cpp index 31943d1ce..655e845ba 100644 --- a/src/Magnum/Primitives/Test/CapsuleTest.cpp +++ b/src/Magnum/Primitives/Test/CapsuleTest.cpp @@ -51,7 +51,7 @@ CapsuleTest::CapsuleTest() { } void CapsuleTest::wireframe2D() { - Trade::MeshData2D capsule = Capsule2D::wireframe(2, 4, 0.5f); + Trade::MeshData2D capsule = capsule2DWireframe(2, 4, 0.5f); CORRADE_COMPARE_AS(capsule.positions(0), (std::vector{ {0.0f, -1.5f}, @@ -95,7 +95,7 @@ void CapsuleTest::wireframe2D() { } void CapsuleTest::solid3DWithoutTextureCoords() { - Trade::MeshData3D capsule = Capsule3D::solid(2, 4, 3, 0.5f); + Trade::MeshData3D capsule = capsule3DSolid(2, 4, 3, 0.5f); CORRADE_COMPARE_AS(capsule.positions(0), (std::vector{ {0.0f, -1.5f, 0.0f}, @@ -178,7 +178,7 @@ void CapsuleTest::solid3DWithoutTextureCoords() { } void CapsuleTest::solid3DWithTextureCoords() { - Trade::MeshData3D capsule = Capsule3D::solid(2, 2, 3, 0.5f, Capsule3D::TextureCoords::Generate); + Trade::MeshData3D capsule = capsule3DSolid(2, 2, 3, 0.5f, CapsuleTextureCoords::Generate); CORRADE_COMPARE_AS(capsule.positions(0), (std::vector{ {0.0f, -1.5f, 0.0f}, @@ -253,7 +253,7 @@ void CapsuleTest::solid3DWithTextureCoords() { } void CapsuleTest::wireframe3D() { - Trade::MeshData3D capsule = Capsule3D::wireframe(2, 2, 8, 0.5f); + Trade::MeshData3D capsule = capsule3DWireframe(2, 2, 8, 0.5f); CORRADE_COMPARE_AS(capsule.positions(0), (std::vector{ {0.0f, -1.5f, 0.0f}, diff --git a/src/Magnum/Primitives/Test/CircleTest.cpp b/src/Magnum/Primitives/Test/CircleTest.cpp index 447b5d082..51a7aea16 100644 --- a/src/Magnum/Primitives/Test/CircleTest.cpp +++ b/src/Magnum/Primitives/Test/CircleTest.cpp @@ -45,7 +45,7 @@ CircleTest::CircleTest() { } void CircleTest::solid() { - Trade::MeshData2D circle = Primitives::Circle::solid(8); + Trade::MeshData2D circle = Primitives::circle2DSolid(8); CORRADE_VERIFY(!circle.isIndexed()); CORRADE_COMPARE(circle.primitive(), MeshPrimitive::TriangleFan); @@ -60,7 +60,7 @@ void CircleTest::solid() { } void CircleTest::wireframe() { - Trade::MeshData2D circle = Primitives::Circle::wireframe(8); + Trade::MeshData2D circle = Primitives::circle2DWireframe(8); CORRADE_VERIFY(!circle.isIndexed()); CORRADE_COMPARE(circle.primitive(), MeshPrimitive::LineLoop); diff --git a/src/Magnum/Primitives/Test/CrosshairTest.cpp b/src/Magnum/Primitives/Test/CrosshairTest.cpp index 9bcc5f759..f9caa4497 100644 --- a/src/Magnum/Primitives/Test/CrosshairTest.cpp +++ b/src/Magnum/Primitives/Test/CrosshairTest.cpp @@ -46,7 +46,7 @@ CrosshairTest::CrosshairTest() { } void CrosshairTest::twoDimensions() { - Trade::MeshData2D crosshair = Primitives::Crosshair2D::wireframe(); + Trade::MeshData2D crosshair = Primitives::crosshair2D(); CORRADE_VERIFY(!crosshair.isIndexed()); CORRADE_COMPARE(crosshair.primitive(), MeshPrimitive::Lines); @@ -54,7 +54,7 @@ void CrosshairTest::twoDimensions() { } void CrosshairTest::threeDimensions() { - Trade::MeshData3D crosshair = Primitives::Crosshair3D::wireframe(); + Trade::MeshData3D crosshair = Primitives::crosshair3D(); CORRADE_VERIFY(!crosshair.isIndexed()); CORRADE_COMPARE(crosshair.primitive(), MeshPrimitive::Lines); diff --git a/src/Magnum/Primitives/Test/CubeTest.cpp b/src/Magnum/Primitives/Test/CubeTest.cpp index 4daa965d7..298e0250f 100644 --- a/src/Magnum/Primitives/Test/CubeTest.cpp +++ b/src/Magnum/Primitives/Test/CubeTest.cpp @@ -47,7 +47,7 @@ CubeTest::CubeTest() { } void CubeTest::solid() { - Trade::MeshData3D cube = Primitives::Cube::solid(); + Trade::MeshData3D cube = Primitives::cubeSolid(); CORRADE_COMPARE(cube.primitive(), MeshPrimitive::Triangles); CORRADE_COMPARE(cube.indices().size(), 36); @@ -56,7 +56,7 @@ void CubeTest::solid() { } void CubeTest::solidStrip() { - Trade::MeshData3D cube = Primitives::Cube::solidStrip(); + Trade::MeshData3D cube = Primitives::cubeSolidStrip(); CORRADE_VERIFY(!cube.isIndexed()); CORRADE_COMPARE(cube.primitive(), MeshPrimitive::TriangleStrip); @@ -65,7 +65,7 @@ void CubeTest::solidStrip() { } void CubeTest::wireframe() { - Trade::MeshData3D cube = Primitives::Cube::wireframe(); + Trade::MeshData3D cube = Primitives::cubeWireframe(); CORRADE_COMPARE(cube.primitive(), MeshPrimitive::Lines); CORRADE_COMPARE(cube.indices().size(), 24); diff --git a/src/Magnum/Primitives/Test/CylinderTest.cpp b/src/Magnum/Primitives/Test/CylinderTest.cpp index d228ed10c..959e4181d 100644 --- a/src/Magnum/Primitives/Test/CylinderTest.cpp +++ b/src/Magnum/Primitives/Test/CylinderTest.cpp @@ -47,7 +47,7 @@ CylinderTest::CylinderTest() { } void CylinderTest::solidWithoutAnything() { - Trade::MeshData3D cylinder = Cylinder::solid(2, 3, 1.5f); + Trade::MeshData3D cylinder = cylinderSolid(2, 3, 1.5f); CORRADE_COMPARE_AS(cylinder.positions(0), (std::vector{ {0.0f, -1.5f, 1.0f}, @@ -84,7 +84,7 @@ void CylinderTest::solidWithoutAnything() { } void CylinderTest::solidWithTextureCoordsAndCaps() { - Trade::MeshData3D cylinder = Cylinder::solid(2, 3, 1.5f, Cylinder::Flag::GenerateTextureCoords|Cylinder::Flag::CapEnds); + Trade::MeshData3D cylinder = cylinderSolid(2, 3, 1.5f, CylinderFlag::GenerateTextureCoords|CylinderFlag::CapEnds); /* First and last ring are duplicated because they have different normals */ CORRADE_COMPARE_AS(cylinder.positions(0), (std::vector{ @@ -191,7 +191,7 @@ void CylinderTest::solidWithTextureCoordsAndCaps() { } void CylinderTest::wireframe() { - Trade::MeshData3D cylinder = Cylinder::wireframe(2, 8, 0.5f); + Trade::MeshData3D cylinder = cylinderWireframe(2, 8, 0.5f); CORRADE_COMPARE_AS(cylinder.positions(0), (std::vector{ {0.0f, -0.5f, 1.0f}, diff --git a/src/Magnum/Primitives/Test/IcosphereTest.cpp b/src/Magnum/Primitives/Test/IcosphereTest.cpp index 7f0faef51..2e70c4525 100644 --- a/src/Magnum/Primitives/Test/IcosphereTest.cpp +++ b/src/Magnum/Primitives/Test/IcosphereTest.cpp @@ -42,7 +42,7 @@ IcosphereTest::IcosphereTest() { } void IcosphereTest::count() { - Trade::MeshData3D data = Primitives::Icosphere::solid(2); + Trade::MeshData3D data = Primitives::icosphereSolid(2); CORRADE_COMPARE(data.positionArrayCount(), 1); CORRADE_COMPARE(data.normalArrayCount(), 1); diff --git a/src/Magnum/Primitives/Test/LineTest.cpp b/src/Magnum/Primitives/Test/LineTest.cpp index dbe61ed6f..141995efe 100644 --- a/src/Magnum/Primitives/Test/LineTest.cpp +++ b/src/Magnum/Primitives/Test/LineTest.cpp @@ -46,7 +46,7 @@ LineTest::LineTest() { } void LineTest::twoDimensions() { - Trade::MeshData2D line = Primitives::Line2D::wireframe(); + Trade::MeshData2D line = Primitives::line2D(); CORRADE_VERIFY(!line.isIndexed()); CORRADE_COMPARE(line.primitive(), MeshPrimitive::Lines); @@ -54,7 +54,7 @@ void LineTest::twoDimensions() { } void LineTest::threeDimensions() { - Trade::MeshData3D line = Primitives::Line3D::wireframe(); + Trade::MeshData3D line = Primitives::line3D(); CORRADE_VERIFY(!line.isIndexed()); CORRADE_COMPARE(line.primitive(), MeshPrimitive::Lines); diff --git a/src/Magnum/Primitives/Test/PlaneTest.cpp b/src/Magnum/Primitives/Test/PlaneTest.cpp index 1c97a22ef..02d153b75 100644 --- a/src/Magnum/Primitives/Test/PlaneTest.cpp +++ b/src/Magnum/Primitives/Test/PlaneTest.cpp @@ -45,7 +45,7 @@ PlaneTest::PlaneTest() { } void PlaneTest::solid() { - Trade::MeshData3D plane = Primitives::Plane::solid(); + Trade::MeshData3D plane = Primitives::planeSolid(); CORRADE_VERIFY(!plane.isIndexed()); CORRADE_COMPARE(plane.primitive(), MeshPrimitive::TriangleStrip); @@ -54,7 +54,7 @@ void PlaneTest::solid() { } void PlaneTest::wireframe() { - Trade::MeshData3D plane = Primitives::Plane::wireframe(); + Trade::MeshData3D plane = Primitives::planeWireframe(); CORRADE_VERIFY(!plane.isIndexed()); CORRADE_COMPARE(plane.primitive(), MeshPrimitive::LineLoop); diff --git a/src/Magnum/Primitives/Test/SquareTest.cpp b/src/Magnum/Primitives/Test/SquareTest.cpp index 0b5182c42..543709259 100644 --- a/src/Magnum/Primitives/Test/SquareTest.cpp +++ b/src/Magnum/Primitives/Test/SquareTest.cpp @@ -45,7 +45,7 @@ SquareTest::SquareTest() { } void SquareTest::solid() { - Trade::MeshData2D square = Primitives::Square::solid(); + Trade::MeshData2D square = Primitives::squareSolid(); CORRADE_VERIFY(!square.isIndexed()); CORRADE_COMPARE(square.primitive(), MeshPrimitive::TriangleStrip); @@ -53,7 +53,7 @@ void SquareTest::solid() { } void SquareTest::wireframe() { - Trade::MeshData2D square = Primitives::Square::wireframe(); + Trade::MeshData2D square = Primitives::squareWireframe(); CORRADE_VERIFY(!square.isIndexed()); CORRADE_COMPARE(square.primitive(), MeshPrimitive::LineLoop); diff --git a/src/Magnum/Primitives/Test/UVSphereTest.cpp b/src/Magnum/Primitives/Test/UVSphereTest.cpp index 90aec218b..99337073f 100644 --- a/src/Magnum/Primitives/Test/UVSphereTest.cpp +++ b/src/Magnum/Primitives/Test/UVSphereTest.cpp @@ -47,7 +47,7 @@ UVSphereTest::UVSphereTest() { } void UVSphereTest::solidWithoutTextureCoords() { - Trade::MeshData3D sphere = UVSphere::solid(3, 3); + Trade::MeshData3D sphere = uvSphereSolid(3, 3); CORRADE_COMPARE_AS(sphere.positions(0), (std::vector{ {0.0f, -1.0f, 0.0f}, @@ -85,7 +85,7 @@ void UVSphereTest::solidWithoutTextureCoords() { } void UVSphereTest::solidWithTextureCoords() { - Trade::MeshData3D sphere = UVSphere::solid(3, 3, UVSphere::TextureCoords::Generate); + Trade::MeshData3D sphere = uvSphereSolid(3, 3, UVSphereTextureCoords::Generate); CORRADE_COMPARE_AS(sphere.positions(0), (std::vector{ {0.0f, -1.0f, 0.0f}, @@ -127,7 +127,7 @@ void UVSphereTest::solidWithTextureCoords() { } void UVSphereTest::wireframe() { - Trade::MeshData3D sphere = UVSphere::wireframe(6, 8); + Trade::MeshData3D sphere = uvSphereWireframe(6, 8); CORRADE_COMPARE_AS(sphere.positions(0), (std::vector{ {0.0f, -1.0f, 0.0f}, diff --git a/src/Magnum/Primitives/UVSphere.cpp b/src/Magnum/Primitives/UVSphere.cpp index 4f11739dc..ff94a726e 100644 --- a/src/Magnum/Primitives/UVSphere.cpp +++ b/src/Magnum/Primitives/UVSphere.cpp @@ -33,11 +33,12 @@ namespace Magnum { namespace Primitives { -Trade::MeshData3D UVSphere::solid(UnsignedInt rings, UnsignedInt segments, TextureCoords textureCoords) { - CORRADE_ASSERT(rings >= 2 && segments >= 3, "UVSphere must have at least two rings and three segments", +Trade::MeshData3D uvSphereSolid(UnsignedInt rings, UnsignedInt segments, UVSphereTextureCoords textureCoords) { + CORRADE_ASSERT(rings >= 2 && segments >= 3, + "Primitives::uvSphereSolid(): at least two rings and three segments expected", (Trade::MeshData3D{MeshPrimitive::Triangles, {}, {}, {}, {}, {}, nullptr})); - Implementation::Spheroid sphere(segments, textureCoords == TextureCoords::Generate ? + Implementation::Spheroid sphere(segments, textureCoords == UVSphereTextureCoords::Generate ? Implementation::Spheroid::TextureCoords::Generate : Implementation::Spheroid::TextureCoords::DontGenerate); @@ -61,8 +62,9 @@ Trade::MeshData3D UVSphere::solid(UnsignedInt rings, UnsignedInt segments, Textu return sphere.finalize(); } -Trade::MeshData3D UVSphere::wireframe(const UnsignedInt rings, const UnsignedInt segments) { - CORRADE_ASSERT(rings >= 2 && rings%2 == 0 && segments >= 4 && segments%2 == 0, "Primitives::UVSphere::wireframe(): improper parameters", +Trade::MeshData3D uvSphereWireframe(const UnsignedInt rings, const UnsignedInt segments) { + CORRADE_ASSERT(rings >= 2 && rings%2 == 0 && segments >= 4 && segments%2 == 0, + "Primitives::uvSphereWireframe(): multiples of 2 rings and multiples of 4 segments expected", (Trade::MeshData3D{MeshPrimitive::Triangles, {}, {}, {}, {}, {}, nullptr})); Implementation::WireframeSpheroid sphere(segments/4); @@ -75,4 +77,14 @@ Trade::MeshData3D UVSphere::wireframe(const UnsignedInt rings, const UnsignedInt return sphere.finalize(); } +#ifdef MAGNUM_BUILD_DEPRECATED +Trade::MeshData3D UVSphere::solid(const UnsignedInt rings, const UnsignedInt segments, const UVSphereTextureCoords textureCoords) { + return uvSphereSolid(rings, segments, textureCoords); +} + +Trade::MeshData3D UVSphere::wireframe(const UnsignedInt rings, const UnsignedInt segments) { + return uvSphereWireframe(rings, segments); +} +#endif + }} diff --git a/src/Magnum/Primitives/UVSphere.h b/src/Magnum/Primitives/UVSphere.h index 633019cd4..8e88ef15b 100644 --- a/src/Magnum/Primitives/UVSphere.h +++ b/src/Magnum/Primitives/UVSphere.h @@ -26,53 +26,78 @@ */ /** @file - * @brief Class @ref Magnum::Primitives::UVSphere + * @brief Class @ref Magnum::Primitives::uvSphereSolid(), @ref Magnum::Primitives::uvSphereWireframe() */ #include "Magnum/Trade/Trade.h" #include "Magnum/Primitives/visibility.h" +#ifdef MAGNUM_BUILD_DEPRECATED +#include +#endif + namespace Magnum { namespace Primitives { /** -@brief 3D UV sphere primitive +@brief Whether to generate UV sphere texture coordinates -Sphere with radius `1`. +@see @ref uvSphereSolid() */ -class MAGNUM_PRIMITIVES_EXPORT UVSphere { - public: - /** @brief Whether to generate texture coordinates */ - enum class TextureCoords: UnsignedByte { - Generate, /**< Generate texture coordinates */ - DontGenerate /**< Don't generate texture coordinates */ - }; - - /** - * @brief Solid UV sphere - * @param rings Number of (face) rings. Must be larger or equal - * to 2. - * @param segments Number of (face) segments. Must be larger or - * equal to 3. - * @param textureCoords Whether to generate texture coordinates. - * - * Indexed @ref MeshPrimitive::Triangles with normals and optional 2D - * texture coordinates. If texture coordinates are generated, vertices - * of one segment are duplicated for texture wrapping. - */ - static Trade::MeshData3D solid(UnsignedInt rings, UnsignedInt segments, TextureCoords textureCoords = TextureCoords::DontGenerate); - - /** - * @brief Wireframe UV sphere - * @param rings Number of (line) rings. Must be larger or equal - * to 2 and multiple of 2. - * @param segments Number of (line) segments. Must be larger or - * equal to 4 and multiple of 4. - * - * Indexed @ref MeshPrimitive::Lines. - */ - static Trade::MeshData3D wireframe(UnsignedInt rings, UnsignedInt segments); +enum class UVSphereTextureCoords: UnsignedByte { + DontGenerate, /**< Don't generate texture coordinates */ + Generate /**< Generate texture coordinates */ }; +/** +@brief Solid 3D UV sphere +@param rings Number of (face) rings. Must be larger or equal to + @cpp 2 @ce. +@param segments Number of (face) segments. Must be larger or + equal to @cpp 3 @ce. +@param textureCoords Whether to generate texture coordinates + +Sphere with radius @cpp 1.0f @ce. Indexed @ref MeshPrimitive::Triangles with +normals and optional 2D texture coordinates. If texture coordinates are +generated, vertices of one segment are duplicated for texture wrapping. +@see @ref icosphereSolid() +*/ +MAGNUM_PRIMITIVES_EXPORT Trade::MeshData3D uvSphereSolid(UnsignedInt rings, UnsignedInt segments, UVSphereTextureCoords textureCoords = UVSphereTextureCoords::DontGenerate); + +/** +@brief Wireframe 3D UV sphere +@param rings Number of (line) rings. Must be larger or equal to + @cpp 2 @ce and multiple of @cpp 2 @ce. +@param segments Number of (line) segments. Must be larger or equal to + @cpp 4 @ce and multiple of @cpp 4 @ce. + +Sphere with radius @cpp 1.0f @ce. Indexed @ref MeshPrimitive::Lines. +@see @ref icosphereSolid() +*/ +MAGNUM_PRIMITIVES_EXPORT Trade::MeshData3D uvSphereWireframe(UnsignedInt rings, UnsignedInt segments); + +#ifdef MAGNUM_BUILD_DEPRECATED +/** +@brief 3D UV sphere +@deprecated Use @ref uvSphereSolid() or @ref uvSphereWireframe() instead. +*/ +struct MAGNUM_PRIMITIVES_EXPORT UVSphere { + /** @brief @copybrief UVSphereTextureCoords + * @deprecated Use @ref UVSphereTextureCoords instead. + */ + typedef CORRADE_DEPRECATED("use UVSphereTextureCoords instead") UVSphereTextureCoords TextureCoords; + + /** @brief @copybrief uvSphereSolid() + * @deprecated Use @ref uvSphereSolid() instead. + */ + CORRADE_DEPRECATED("use uvSphereSolid() instead") static Trade::MeshData3D solid(UnsignedInt rings, UnsignedInt segments, UVSphereTextureCoords textureCoords = UVSphereTextureCoords::DontGenerate); + + /** @brief @copybrief uvSphereWireframe() + * @deprecated Use @ref uvSphereWireframe() instead. + */ + CORRADE_DEPRECATED("use uvSphereWireframe() instead") static Trade::MeshData3D wireframe(UnsignedInt rings, UnsignedInt segments); +}; +#endif + }} #endif