Browse Source

Extracted Primitive enum from Mesh to MeshPrimitive.

Because we can't forward-declare class members we would need to include
whole Mesh (along with all OpenGL headers and other stuff) just to use
Primitive enum. The old Mesh::Primitive is now alias to new one, is
marked as deprecated and will be removed in future release.
pull/34/head
Vladimír Vondruš 13 years ago
parent
commit
5d9490c73b
  1. 2
      src/DebugTools/ForceRenderer.cpp
  2. 1
      src/DebugTools/Implementation/AbstractBoxRenderer.cpp
  3. 1
      src/DebugTools/Implementation/CapsuleRenderer.cpp
  4. 2
      src/DebugTools/ObjectRenderer.cpp
  5. 2
      src/Magnum.h
  6. 18
      src/Mesh.cpp
  7. 174
      src/Mesh.h
  8. 2
      src/MeshTools/FullScreenTriangle.cpp
  9. 9
      src/Primitives/Capsule.cpp
  10. 10
      src/Primitives/Capsule.h
  11. 9
      src/Primitives/Circle.cpp
  12. 4
      src/Primitives/Circle.h
  13. 5
      src/Primitives/Crosshair.cpp
  14. 4
      src/Primitives/Crosshair.h
  15. 5
      src/Primitives/Cube.cpp
  16. 4
      src/Primitives/Cube.h
  17. 5
      src/Primitives/Cylinder.cpp
  18. 4
      src/Primitives/Cylinder.h
  19. 5
      src/Primitives/Icosphere.cpp
  20. 2
      src/Primitives/Icosphere.h
  21. 3
      src/Primitives/Implementation/Spheroid.cpp
  22. 3
      src/Primitives/Implementation/WireframeSpheroid.cpp
  23. 5
      src/Primitives/Line.cpp
  24. 4
      src/Primitives/Line.h
  25. 5
      src/Primitives/Plane.cpp
  26. 4
      src/Primitives/Plane.h
  27. 5
      src/Primitives/Square.cpp
  28. 4
      src/Primitives/Square.h
  29. 5
      src/Primitives/UVSphere.cpp
  30. 8
      src/Primitives/UVSphere.h
  31. 8
      src/Test/MeshTest.cpp
  32. 4
      src/Text/Renderer.cpp
  33. 2
      src/TextureTools/DistanceField.cpp
  34. 2
      src/Trade/MeshData2D.cpp
  35. 12
      src/Trade/MeshData2D.h
  36. 2
      src/Trade/MeshData3D.cpp
  37. 12
      src/Trade/MeshData3D.h

2
src/DebugTools/ForceRenderer.cpp

@ -86,7 +86,7 @@ template<UnsignedInt dimensions> ForceRenderer<dimensions>::ForceRenderer(SceneG
ResourceManager::instance().set(this->indexBuffer.key(), indexBuffer, ResourceDataState::Final, ResourcePolicy::Manual); ResourceManager::instance().set(this->indexBuffer.key(), indexBuffer, ResourceDataState::Final, ResourcePolicy::Manual);
Mesh* mesh = new Mesh; Mesh* mesh = new Mesh;
mesh->setPrimitive(Mesh::Primitive::Lines) mesh->setPrimitive(MeshPrimitive::Lines)
.setIndexCount(indices.size()) .setIndexCount(indices.size())
.addVertexBuffer(*vertexBuffer, 0, .addVertexBuffer(*vertexBuffer, 0,
typename Shaders::Flat<dimensions>::Position(Shaders::Flat<dimensions>::Position::Components::Two)) typename Shaders::Flat<dimensions>::Position(Shaders::Flat<dimensions>::Position::Components::Two))

1
src/DebugTools/Implementation/AbstractBoxRenderer.cpp

@ -24,6 +24,7 @@
#include "AbstractBoxRenderer.h" #include "AbstractBoxRenderer.h"
#include "Mesh.h"
#include "Primitives/Cube.h" #include "Primitives/Cube.h"
#include "Primitives/Square.h" #include "Primitives/Square.h"
#include "Trade/MeshData2D.h" #include "Trade/MeshData2D.h"

1
src/DebugTools/Implementation/CapsuleRenderer.cpp

@ -24,6 +24,7 @@
#include "CapsuleRenderer.h" #include "CapsuleRenderer.h"
#include "Mesh.h"
#include "MeshView.h" #include "MeshView.h"
#include "DebugTools/ResourceManager.h" #include "DebugTools/ResourceManager.h"
#include "DebugTools/ShapeRenderer.h" #include "DebugTools/ShapeRenderer.h"

2
src/DebugTools/ObjectRenderer.cpp

@ -164,7 +164,7 @@ template<UnsignedInt dimensions> ObjectRenderer<dimensions>::ObjectRenderer(Scen
indexBuffer->setData(Renderer<dimensions>::indices, BufferUsage::StaticDraw); indexBuffer->setData(Renderer<dimensions>::indices, BufferUsage::StaticDraw);
ResourceManager::instance().set(this->indexBuffer.key(), indexBuffer, ResourceDataState::Final, ResourcePolicy::Manual); ResourceManager::instance().set(this->indexBuffer.key(), indexBuffer, ResourceDataState::Final, ResourcePolicy::Manual);
mesh->setPrimitive(Mesh::Primitive::Lines) mesh->setPrimitive(MeshPrimitive::Lines)
.setIndexCount(Renderer<dimensions>::indices.size()) .setIndexCount(Renderer<dimensions>::indices.size())
.addVertexBuffer(*vertexBuffer, 0, .addVertexBuffer(*vertexBuffer, 0,
typename Shaders::VertexColor<dimensions>::Position(), typename Shaders::VertexColor<dimensions>::Position(),

2
src/Magnum.h

@ -582,6 +582,8 @@ typedef ImageReference<1> ImageReference1D;
typedef ImageReference<2> ImageReference2D; typedef ImageReference<2> ImageReference2D;
typedef ImageReference<3> ImageReference3D; typedef ImageReference<3> ImageReference3D;
enum class MeshPrimitive: GLenum;
class Mesh; class Mesh;
class MeshView; class MeshView;

18
src/Mesh.cpp

@ -82,7 +82,7 @@ std::size_t Mesh::indexSize(IndexType type) {
CORRADE_ASSERT_UNREACHABLE(); CORRADE_ASSERT_UNREACHABLE();
} }
Mesh::Mesh(Primitive primitive): _primitive(primitive), _vertexCount(0), _indexCount(0) Mesh::Mesh(MeshPrimitive primitive): _primitive(primitive), _vertexCount(0), _indexCount(0)
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
, _indexStart(0), _indexEnd(0) , _indexStart(0), _indexEnd(0)
#endif #endif
@ -379,9 +379,9 @@ void Mesh::unbindImplementationDefault() {
void Mesh::unbindImplementationVAO() {} void Mesh::unbindImplementationVAO() {}
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT
Debug operator<<(Debug debug, Mesh::Primitive value) { Debug operator<<(Debug debug, MeshPrimitive value) {
switch(value) { switch(value) {
#define _c(value) case Mesh::Primitive::value: return debug << "Mesh::Primitive::" #value; #define _c(value) case MeshPrimitive::value: return debug << "MeshPrimitive::" #value;
_c(Points) _c(Points)
_c(LineStrip) _c(LineStrip)
_c(LineLoop) _c(LineLoop)
@ -401,7 +401,7 @@ Debug operator<<(Debug debug, Mesh::Primitive value) {
#undef _c #undef _c
} }
return debug << "Mesh::Primitive::(invalid)"; return debug << "MeshPrimitive::(invalid)";
} }
Debug operator<<(Debug debug, Mesh::IndexType value) { Debug operator<<(Debug debug, Mesh::IndexType value) {
@ -421,9 +421,9 @@ Debug operator<<(Debug debug, Mesh::IndexType value) {
namespace Corrade { namespace Utility { namespace Corrade { namespace Utility {
std::string ConfigurationValue<Magnum::Mesh::Primitive>::toString(Magnum::Mesh::Primitive value, ConfigurationValueFlags) { std::string ConfigurationValue<Magnum::MeshPrimitive>::toString(Magnum::MeshPrimitive value, ConfigurationValueFlags) {
switch(value) { switch(value) {
#define _c(value) case Magnum::Mesh::Primitive::value: return #value; #define _c(value) case Magnum::MeshPrimitive::value: return #value;
_c(Points) _c(Points)
_c(LineStrip) _c(LineStrip)
_c(LineLoop) _c(LineLoop)
@ -446,8 +446,8 @@ std::string ConfigurationValue<Magnum::Mesh::Primitive>::toString(Magnum::Mesh::
return {}; return {};
} }
Magnum::Mesh::Primitive ConfigurationValue<Magnum::Mesh::Primitive>::fromString(const std::string& stringValue, ConfigurationValueFlags) { Magnum::MeshPrimitive ConfigurationValue<Magnum::MeshPrimitive>::fromString(const std::string& stringValue, ConfigurationValueFlags) {
#define _c(value) if(stringValue == #value) return Magnum::Mesh::Primitive::value; #define _c(value) if(stringValue == #value) return Magnum::MeshPrimitive::value;
_c(LineStrip) _c(LineStrip)
_c(LineLoop) _c(LineLoop)
_c(Lines) _c(Lines)
@ -465,7 +465,7 @@ Magnum::Mesh::Primitive ConfigurationValue<Magnum::Mesh::Primitive>::fromString(
#endif #endif
#undef _c #undef _c
return Magnum::Mesh::Primitive::Points; return Magnum::MeshPrimitive::Points;
} }
std::string ConfigurationValue<Magnum::Mesh::IndexType>::toString(Magnum::Mesh::IndexType value, ConfigurationValueFlags) { std::string ConfigurationValue<Magnum::Mesh::IndexType>::toString(Magnum::Mesh::IndexType value, ConfigurationValueFlags) {

174
src/Mesh.h

@ -35,6 +35,80 @@
namespace Magnum { namespace Magnum {
/**
* @brief %Mesh primitive type
*
* @see @ref Mesh::primitive(), @ref Mesh::setPrimitive()
*/
enum class MeshPrimitive: GLenum {
/** Single points. */
Points = GL_POINTS,
/**
* First two vertices define first line segment, each following
* vertex defines another segment.
*/
LineStrip = GL_LINE_STRIP,
/** Line strip, last and first vertex are connected together. */
LineLoop = GL_LINE_LOOP,
/**
* Each pair of vertices defines a single line, lines aren't
* connected together.
*/
Lines = GL_LINES,
#ifndef MAGNUM_TARGET_GLES
/**
* Line strip with adjacency information.
* @requires_gl32 %Extension @extension{ARB,geometry_shader4}
*/
LineStripAdjacency = GL_LINE_STRIP_ADJACENCY,
/**
* Lines with adjacency information.
* @requires_gl32 %Extension @extension{ARB,geometry_shader4}
*/
LinesAdjacency = GL_LINES_ADJACENCY,
#endif
/**
* First three vertices define first triangle, each following
* vertex defines another triangle.
*/
TriangleStrip = GL_TRIANGLE_STRIP,
/**
* First vertex is center, each following vertex is connected to
* previous and center vertex.
*/
TriangleFan = GL_TRIANGLE_FAN,
/** Each three vertices define one triangle. */
Triangles = GL_TRIANGLES,
#ifndef MAGNUM_TARGET_GLES
/**
* Triangle strip with adjacency information.
* @requires_gl32 %Extension @extension{ARB,geometry_shader4}
*/
TriangleStripAdjacency = GL_TRIANGLE_STRIP_ADJACENCY,
/**
* Triangles with adjacency information.
* @requires_gl32 %Extension @extension{ARB,geometry_shader4}
*/
TrianglesAdjacency = GL_TRIANGLES_ADJACENCY,
/**
* Patches.
* @requires_gl40 %Extension @extension{ARB,tessellation_shader}
*/
Patches = GL_PATCHES
#endif
};
/** /**
@brief %Mesh @brief %Mesh
@ -86,7 +160,7 @@ static constexpr Vector3 positions[30] = {
vertexBuffer.setData(positions, BufferUsage::StaticDraw); vertexBuffer.setData(positions, BufferUsage::StaticDraw);
// Set primitive and vertex count, add the buffer and specify its layout // Set primitive and vertex count, add the buffer and specify its layout
mesh.setPrimitive(Mesh::Primitive::Triangles) mesh.setPrimitive(MeshPrimitive::Triangles)
.setVertexCount(30) .setVertexCount(30)
.addVertexBuffer(vertexBuffer, 0, MyShader::Position()); .addVertexBuffer(vertexBuffer, 0, MyShader::Position());
@endcode @endcode
@ -135,7 +209,7 @@ static constexpr GLubyte indices[75] = {
indexBuffer.setData(indices, BufferUsage::StaticDraw); indexBuffer.setData(indices, BufferUsage::StaticDraw);
// Set primitive, index count, specify the buffers // Set primitive, index count, specify the buffers
mesh.setPrimitive(Mesh::Primitive::Triangles) mesh.setPrimitive(MeshPrimitive::Triangles)
.setIndexCount(75) .setIndexCount(75)
.addVertexBuffer(vertexBuffer, 0, MyShader::Position()) .addVertexBuffer(vertexBuffer, 0, MyShader::Position())
.setIndexBuffer(indexBuffer, 0, Mesh::IndexType::UnsignedByte, 176, 229); .setIndexBuffer(indexBuffer, 0, Mesh::IndexType::UnsignedByte, 176, 229);
@ -238,79 +312,13 @@ class MAGNUM_EXPORT Mesh {
friend class MeshView; friend class MeshView;
public: public:
#ifdef MAGNUM_BUILD_DEPRECATED
/** /**
* @brief Primitive type * @copybrief MeshPrimitive
* * @deprecated Use @ref Magnum::MeshPrimitive "MeshPrimitive" instead.
* @see @ref primitive(), @ref setPrimitive()
*/ */
enum class Primitive: GLenum { typedef CORRADE_DEPRECATED("use MeshPrimitive instead") MeshPrimitive Primitive;
/** Single points. */ #endif
Points = GL_POINTS,
/**
* First two vertices define first line segment, each following
* vertex defines another segment.
*/
LineStrip = GL_LINE_STRIP,
/** Line strip, last and first vertex are connected together. */
LineLoop = GL_LINE_LOOP,
/**
* Each pair of vertices defines a single line, lines aren't
* connected together.
*/
Lines = GL_LINES,
#ifndef MAGNUM_TARGET_GLES
/**
* Line strip with adjacency information.
* @requires_gl32 %Extension @extension{ARB,geometry_shader4}
*/
LineStripAdjacency = GL_LINE_STRIP_ADJACENCY,
/**
* Lines with adjacency information.
* @requires_gl32 %Extension @extension{ARB,geometry_shader4}
*/
LinesAdjacency = GL_LINES_ADJACENCY,
#endif
/**
* First three vertices define first triangle, each following
* vertex defines another triangle.
*/
TriangleStrip = GL_TRIANGLE_STRIP,
/**
* First vertex is center, each following vertex is connected to
* previous and center vertex.
*/
TriangleFan = GL_TRIANGLE_FAN,
/** Each three vertices define one triangle. */
Triangles = GL_TRIANGLES,
#ifndef MAGNUM_TARGET_GLES
/**
* Triangle strip with adjacency information.
* @requires_gl32 %Extension @extension{ARB,geometry_shader4}
*/
TriangleStripAdjacency = GL_TRIANGLE_STRIP_ADJACENCY,
/**
* Triangles with adjacency information.
* @requires_gl32 %Extension @extension{ARB,geometry_shader4}
*/
TrianglesAdjacency = GL_TRIANGLES_ADJACENCY,
/**
* Patches.
* @requires_gl40 %Extension @extension{ARB,tessellation_shader}
*/
Patches = GL_PATCHES
#endif
};
/** /**
* @brief Index type * @brief Index type
@ -377,7 +385,7 @@ class MAGNUM_EXPORT Mesh {
* @see @ref setPrimitive(), @ref setVertexCount(), @fn_gl{GenVertexArrays} * @see @ref setPrimitive(), @ref setVertexCount(), @fn_gl{GenVertexArrays}
* (if @extension{APPLE,vertex_array_object} is available) * (if @extension{APPLE,vertex_array_object} is available)
*/ */
explicit Mesh(Primitive primitive = Primitive::Triangles); explicit Mesh(MeshPrimitive primitive = MeshPrimitive::Triangles);
/** @brief Copying is not allowed */ /** @brief Copying is not allowed */
Mesh(const Mesh&) = delete; Mesh(const Mesh&) = delete;
@ -407,16 +415,16 @@ class MAGNUM_EXPORT Mesh {
std::size_t indexSize() const { return indexSize(_indexType); } std::size_t indexSize() const { return indexSize(_indexType); }
/** @brief Primitive type */ /** @brief Primitive type */
Primitive primitive() const { return _primitive; } MeshPrimitive primitive() const { return _primitive; }
/** /**
* @brief Set primitive type * @brief Set primitive type
* @return Reference to self (for method chaining) * @return Reference to self (for method chaining)
* *
* Default is @ref Primitive::Triangles. * Default is @ref MeshPrimitive::Triangles.
* @see @ref setVertexCount(), @ref addVertexBuffer() * @see @ref setVertexCount(), @ref addVertexBuffer()
*/ */
Mesh& setPrimitive(Primitive primitive) { Mesh& setPrimitive(MeshPrimitive primitive) {
_primitive = primitive; _primitive = primitive;
return *this; return *this;
} }
@ -743,7 +751,7 @@ class MAGNUM_EXPORT Mesh {
static MAGNUM_LOCAL UnbindImplementation unbindImplementation; static MAGNUM_LOCAL UnbindImplementation unbindImplementation;
GLuint _id; GLuint _id;
Primitive _primitive; MeshPrimitive _primitive;
Int _vertexCount, _indexCount; Int _vertexCount, _indexCount;
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
UnsignedInt _indexStart, _indexEnd; UnsignedInt _indexStart, _indexEnd;
@ -762,7 +770,7 @@ class MAGNUM_EXPORT Mesh {
}; };
/** @debugoperator{Magnum::Mesh} */ /** @debugoperator{Magnum::Mesh} */
Debug MAGNUM_EXPORT operator<<(Debug debug, Mesh::Primitive value); Debug MAGNUM_EXPORT operator<<(Debug debug, MeshPrimitive value);
/** @debugoperator{Magnum::Mesh} */ /** @debugoperator{Magnum::Mesh} */
Debug MAGNUM_EXPORT operator<<(Debug debug, Mesh::IndexType value); Debug MAGNUM_EXPORT operator<<(Debug debug, Mesh::IndexType value);
@ -772,7 +780,7 @@ Debug MAGNUM_EXPORT operator<<(Debug debug, Mesh::IndexType value);
namespace Corrade { namespace Utility { namespace Corrade { namespace Utility {
/** @configurationvalue{Magnum::Mesh} */ /** @configurationvalue{Magnum::Mesh} */
template<> struct MAGNUM_EXPORT ConfigurationValue<Magnum::Mesh::Primitive> { template<> struct MAGNUM_EXPORT ConfigurationValue<Magnum::MeshPrimitive> {
ConfigurationValue() = delete; ConfigurationValue() = delete;
/** /**
@ -780,14 +788,14 @@ template<> struct MAGNUM_EXPORT ConfigurationValue<Magnum::Mesh::Primitive> {
* *
* If the value is invalid, returns empty string. * If the value is invalid, returns empty string.
*/ */
static std::string toString(Magnum::Mesh::Primitive value, ConfigurationValueFlags); static std::string toString(Magnum::MeshPrimitive value, ConfigurationValueFlags);
/** /**
* @brief Reads enum value as string * @brief Reads enum value as string
* *
* If the value is invalid, returns @ref Magnum::Mesh::Primitive::Points "Mesh::Primitive::Points". * If the value is invalid, returns @ref Magnum::MeshPrimitive::Points "MeshPrimitive::Points".
*/ */
static Magnum::Mesh::Primitive fromString(const std::string& stringValue, ConfigurationValueFlags); static Magnum::MeshPrimitive fromString(const std::string& stringValue, ConfigurationValueFlags);
}; };
/** @configurationvalue{Magnum::Mesh} */ /** @configurationvalue{Magnum::Mesh} */

2
src/MeshTools/FullScreenTriangle.cpp

@ -34,7 +34,7 @@ namespace Magnum { namespace MeshTools {
std::pair<Buffer*, Mesh> fullScreenTriangle() { std::pair<Buffer*, Mesh> fullScreenTriangle() {
Mesh mesh; Mesh mesh;
mesh.setPrimitive(Mesh::Primitive::Triangles) mesh.setPrimitive(MeshPrimitive::Triangles)
.setVertexCount(3); .setVertexCount(3);
Buffer* buffer = nullptr; Buffer* buffer = nullptr;

9
src/Primitives/Capsule.cpp

@ -26,6 +26,7 @@
#include "Math/Vector3.h" #include "Math/Vector3.h"
#include "Math/Functions.h" #include "Math/Functions.h"
#include "Mesh.h"
#include "Primitives/Implementation/Spheroid.h" #include "Primitives/Implementation/Spheroid.h"
#include "Primitives/Implementation/WireframeSpheroid.h" #include "Primitives/Implementation/WireframeSpheroid.h"
#include "Trade/MeshData2D.h" #include "Trade/MeshData2D.h"
@ -34,7 +35,7 @@
namespace Magnum { namespace Primitives { namespace Magnum { namespace Primitives {
Trade::MeshData2D Capsule2D::wireframe(UnsignedInt hemisphereRings, UnsignedInt cylinderRings, Float halfLength) { 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(Mesh::Primitive::Lines, std::vector<UnsignedInt>{}, std::vector<std::vector<Vector2>>{}, std::vector<std::vector<Vector2>>{})); CORRADE_ASSERT(hemisphereRings >= 1 && cylinderRings >= 1, "Capsule must have at least one hemisphere ring, one cylinder ring and three segments", Trade::MeshData2D(MeshPrimitive::Lines, std::vector<UnsignedInt>{}, std::vector<std::vector<Vector2>>{}, std::vector<std::vector<Vector2>>{}));
std::vector<Vector2> positions; std::vector<Vector2> positions;
positions.reserve(hemisphereRings*4+2+(cylinderRings-1)*2); positions.reserve(hemisphereRings*4+2+(cylinderRings-1)*2);
@ -85,11 +86,11 @@ Trade::MeshData2D Capsule2D::wireframe(UnsignedInt hemisphereRings, UnsignedInt
{UnsignedInt(positions.size())-3, UnsignedInt(positions.size())-1, {UnsignedInt(positions.size())-3, UnsignedInt(positions.size())-1,
UnsignedInt(positions.size())-2, UnsignedInt(positions.size())-1}); UnsignedInt(positions.size())-2, UnsignedInt(positions.size())-1});
return Trade::MeshData2D(Mesh::Primitive::Lines, std::move(indices), {std::move(positions)}, std::vector<std::vector<Vector2>>{}); return Trade::MeshData2D(MeshPrimitive::Lines, std::move(indices), {std::move(positions)}, std::vector<std::vector<Vector2>>{});
} }
Trade::MeshData3D Capsule3D::solid(UnsignedInt hemisphereRings, UnsignedInt cylinderRings, UnsignedInt segments, Float halfLength, TextureCoords textureCoords) { 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(Mesh::Primitive::Triangles, std::vector<UnsignedInt>{}, std::vector<std::vector<Vector3>>{}, std::vector<std::vector<Vector3>>{}, std::vector<std::vector<Vector2>>{})); CORRADE_ASSERT(hemisphereRings >= 1 && cylinderRings >= 1 && segments >= 3, "Capsule must have at least one hemisphere ring, one cylinder ring and three segments", Trade::MeshData3D(MeshPrimitive::Triangles, std::vector<UnsignedInt>{}, std::vector<std::vector<Vector3>>{}, std::vector<std::vector<Vector3>>{}, std::vector<std::vector<Vector2>>{}));
Implementation::Spheroid capsule(segments, textureCoords == TextureCoords::Generate ? Implementation::Spheroid capsule(segments, textureCoords == TextureCoords::Generate ?
Implementation::Spheroid::TextureCoords::Generate : Implementation::Spheroid::TextureCoords::Generate :
@ -123,7 +124,7 @@ Trade::MeshData3D Capsule3D::solid(UnsignedInt hemisphereRings, UnsignedInt cyli
} }
Trade::MeshData3D Capsule3D::wireframe(const UnsignedInt hemisphereRings, const UnsignedInt cylinderRings, const UnsignedInt segments, const Float halfLength) { 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(Mesh::Primitive::Lines, std::vector<UnsignedInt>{}, std::vector<std::vector<Vector3>>{}, std::vector<std::vector<Vector3>>{}, std::vector<std::vector<Vector2>>{})); CORRADE_ASSERT(hemisphereRings >= 1 && cylinderRings >= 1 && segments >= 4 && segments%4 == 0, "Primitives::Capsule::wireframe(): improper parameters", Trade::MeshData3D(MeshPrimitive::Lines, std::vector<UnsignedInt>{}, std::vector<std::vector<Vector3>>{}, std::vector<std::vector<Vector3>>{}, std::vector<std::vector<Vector2>>{}));
Implementation::WireframeSpheroid capsule(segments/4); Implementation::WireframeSpheroid capsule(segments/4);

10
src/Primitives/Capsule.h

@ -48,7 +48,7 @@ class MAGNUM_PRIMITIVES_EXPORT Capsule2D {
* larger or equal to 1. * larger or equal to 1.
* @param halfLength Half the length of cylinder part * @param halfLength Half the length of cylinder part
* *
* Indexed @ref Mesh::Primitive "Lines". * Indexed @ref MeshPrimitive::Lines.
*/ */
static Trade::MeshData2D wireframe(UnsignedInt hemisphereRings, UnsignedInt cylinderRings, Float halfLength); static Trade::MeshData2D wireframe(UnsignedInt hemisphereRings, UnsignedInt cylinderRings, Float halfLength);
}; };
@ -77,9 +77,9 @@ class MAGNUM_PRIMITIVES_EXPORT Capsule3D {
* @param halfLength Half the length of cylinder part * @param halfLength Half the length of cylinder part
* @param textureCoords Whether to generate texture coordinates. * @param textureCoords Whether to generate texture coordinates.
* *
* Indexed @ref Mesh::Primitive "Triangles" with normals and optional * Indexed @ref MeshPrimitive::Triangles with normals and optional 2D
* 2D texture coordinates. If texture coordinates are generated, * texture coordinates. If texture coordinates are generated, vertices
* vertices of one segment are duplicated for texture wrapping. * of one segment are duplicated for texture wrapping.
*/ */
static Trade::MeshData3D solid(UnsignedInt hemisphereRings, UnsignedInt cylinderRings, UnsignedInt segments, Float halfLength, TextureCoords textureCoords = TextureCoords::DontGenerate); static Trade::MeshData3D solid(UnsignedInt hemisphereRings, UnsignedInt cylinderRings, UnsignedInt segments, Float halfLength, TextureCoords textureCoords = TextureCoords::DontGenerate);
@ -93,7 +93,7 @@ class MAGNUM_PRIMITIVES_EXPORT Capsule3D {
* equal to 4 and multiple of 4. * equal to 4 and multiple of 4.
* @param halfLength Half the length of cylinder part * @param halfLength Half the length of cylinder part
* *
* Indexed @ref Mesh::Primitive "Lines". * Indexed @ref MeshPrimitive::Lines.
*/ */
static Trade::MeshData3D wireframe(UnsignedInt hemisphereRings, UnsignedInt cylinderRings, UnsignedInt segments, Float halfLength); static Trade::MeshData3D wireframe(UnsignedInt hemisphereRings, UnsignedInt cylinderRings, UnsignedInt segments, Float halfLength);
}; };

9
src/Primitives/Circle.cpp

@ -26,13 +26,14 @@
#include "Math/Functions.h" #include "Math/Functions.h"
#include "Math/Vector2.h" #include "Math/Vector2.h"
#include "Mesh.h"
#include "Trade/MeshData2D.h" #include "Trade/MeshData2D.h"
namespace Magnum { namespace Primitives { namespace Magnum { namespace Primitives {
Trade::MeshData2D Circle::solid(UnsignedInt segments) { Trade::MeshData2D Circle::solid(UnsignedInt segments) {
CORRADE_ASSERT(segments >= 3, "Primitives::Circle::solid(): segments must be >= 3", CORRADE_ASSERT(segments >= 3, "Primitives::Circle::solid(): segments must be >= 3",
Trade::MeshData2D(Mesh::Primitive::TriangleFan, std::vector<UnsignedInt>{}, std::vector<std::vector<Vector2>>{}, std::vector<std::vector<Vector2>>{})); Trade::MeshData2D(MeshPrimitive::TriangleFan, std::vector<UnsignedInt>{}, std::vector<std::vector<Vector2>>{}, std::vector<std::vector<Vector2>>{}));
std::vector<Vector2> positions; std::vector<Vector2> positions;
positions.reserve(segments+1); positions.reserve(segments+1);
@ -47,12 +48,12 @@ Trade::MeshData2D Circle::solid(UnsignedInt segments) {
positions.emplace_back(Math::cos(angle), Math::sin(angle)); positions.emplace_back(Math::cos(angle), Math::sin(angle));
} }
return Trade::MeshData2D(Mesh::Primitive::TriangleFan, std::vector<UnsignedInt>{}, {std::move(positions)}, std::vector<std::vector<Vector2>>{}); return Trade::MeshData2D(MeshPrimitive::TriangleFan, std::vector<UnsignedInt>{}, {std::move(positions)}, std::vector<std::vector<Vector2>>{});
} }
Trade::MeshData2D Circle::wireframe(UnsignedInt segments) { Trade::MeshData2D Circle::wireframe(UnsignedInt segments) {
CORRADE_ASSERT(segments >= 3, "Primitives::Circle::wireframe(): segments must be >= 3", CORRADE_ASSERT(segments >= 3, "Primitives::Circle::wireframe(): segments must be >= 3",
Trade::MeshData2D(Mesh::Primitive::LineLoop, std::vector<UnsignedInt>{}, std::vector<std::vector<Vector2>>{}, std::vector<std::vector<Vector2>>{})); Trade::MeshData2D(MeshPrimitive::LineLoop, std::vector<UnsignedInt>{}, std::vector<std::vector<Vector2>>{}, std::vector<std::vector<Vector2>>{}));
std::vector<Vector2> positions; std::vector<Vector2> positions;
positions.reserve(segments); positions.reserve(segments);
@ -64,7 +65,7 @@ Trade::MeshData2D Circle::wireframe(UnsignedInt segments) {
positions.emplace_back(Math::cos(angle), Math::sin(angle)); positions.emplace_back(Math::cos(angle), Math::sin(angle));
} }
return Trade::MeshData2D(Mesh::Primitive::LineLoop, std::vector<UnsignedInt>{}, {std::move(positions)}, std::vector<std::vector<Vector2>>{}); return Trade::MeshData2D(MeshPrimitive::LineLoop, std::vector<UnsignedInt>{}, {std::move(positions)}, std::vector<std::vector<Vector2>>{});
} }
}} }}

4
src/Primitives/Circle.h

@ -45,7 +45,7 @@ class MAGNUM_PRIMITIVES_EXPORT Circle {
* @brief Solid circle * @brief Solid circle
* @param segments Number of segments. Must be greater or equal to 3. * @param segments Number of segments. Must be greater or equal to 3.
* *
* Non-indexed @ref Mesh::Primitive "TriangleFan". * Non-indexed @ref MeshPrimitive::TriangleFan.
*/ */
static Trade::MeshData2D solid(UnsignedInt segments); static Trade::MeshData2D solid(UnsignedInt segments);
@ -53,7 +53,7 @@ class MAGNUM_PRIMITIVES_EXPORT Circle {
* @brief Wireframe circle * @brief Wireframe circle
* @param segments Number of segments. Must be greater or equal to 3. * @param segments Number of segments. Must be greater or equal to 3.
* *
* Non-indexed @ref Mesh::Primitive "LineLoop". * Non-indexed @ref MeshPrimitive::LineLoop.
*/ */
static Trade::MeshData2D wireframe(UnsignedInt segments); static Trade::MeshData2D wireframe(UnsignedInt segments);

5
src/Primitives/Crosshair.cpp

@ -25,20 +25,21 @@
#include "Crosshair.h" #include "Crosshair.h"
#include "Math/Vector3.h" #include "Math/Vector3.h"
#include "Mesh.h"
#include "Trade/MeshData2D.h" #include "Trade/MeshData2D.h"
#include "Trade/MeshData3D.h" #include "Trade/MeshData3D.h"
namespace Magnum { namespace Primitives { namespace Magnum { namespace Primitives {
Trade::MeshData2D Crosshair2D::wireframe() { Trade::MeshData2D Crosshair2D::wireframe() {
return Trade::MeshData2D(Mesh::Primitive::Lines, std::vector<UnsignedInt>{}, {{ return Trade::MeshData2D(MeshPrimitive::Lines, std::vector<UnsignedInt>{}, {{
{-1.0f, 0.0f}, {1.0f, 0.0f}, {-1.0f, 0.0f}, {1.0f, 0.0f},
{ 0.0f, -1.0f}, {0.0f, 1.0f} { 0.0f, -1.0f}, {0.0f, 1.0f}
}}, std::vector<std::vector<Vector2>>{}); }}, std::vector<std::vector<Vector2>>{});
} }
Trade::MeshData3D Crosshair3D::wireframe() { Trade::MeshData3D Crosshair3D::wireframe() {
return Trade::MeshData3D(Mesh::Primitive::Lines, std::vector<UnsignedInt>{}, {{ return Trade::MeshData3D(MeshPrimitive::Lines, std::vector<UnsignedInt>{}, {{
{-1.0f, 0.0f, 0.0f}, {1.0f, 0.0f, 0.0f}, {-1.0f, 0.0f, 0.0f}, {1.0f, 0.0f, 0.0f},
{ 0.0f, -1.0f, 0.0f}, {0.0f, 1.0f, 0.0f}, { 0.0f, -1.0f, 0.0f}, {0.0f, 1.0f, 0.0f},
{ 0.0f, 0.0f, -1.0f}, {0.0f, 0.0f, 1.0f} { 0.0f, 0.0f, -1.0f}, {0.0f, 0.0f, 1.0f}

4
src/Primitives/Crosshair.h

@ -38,7 +38,7 @@ namespace Magnum { namespace Primitives {
@brief 2D crosshair primitive @brief 2D crosshair primitive
2x2 wireframe crosshair (two crossed lines), non-indexed 2x2 wireframe crosshair (two crossed lines), non-indexed
@ref Mesh::Primitive "Lines". @ref MeshPrimitive::Lines.
*/ */
class MAGNUM_PRIMITIVES_EXPORT Crosshair2D { class MAGNUM_PRIMITIVES_EXPORT Crosshair2D {
public: public:
@ -52,7 +52,7 @@ class MAGNUM_PRIMITIVES_EXPORT Crosshair2D {
@brief 3D crosshair primitive @brief 3D crosshair primitive
2x2x2 wireframe crosshair (three crossed lines), non-indexed 2x2x2 wireframe crosshair (three crossed lines), non-indexed
@ref Mesh::Primitive "Lines". @ref MeshPrimitive::Lines.
*/ */
class MAGNUM_PRIMITIVES_EXPORT Crosshair3D { class MAGNUM_PRIMITIVES_EXPORT Crosshair3D {
public: public:

5
src/Primitives/Cube.cpp

@ -25,12 +25,13 @@
#include "Cube.h" #include "Cube.h"
#include "Math/Vector3.h" #include "Math/Vector3.h"
#include "Mesh.h"
#include "Trade/MeshData3D.h" #include "Trade/MeshData3D.h"
namespace Magnum { namespace Primitives { namespace Magnum { namespace Primitives {
Trade::MeshData3D Cube::solid() { Trade::MeshData3D Cube::solid() {
return Trade::MeshData3D(Mesh::Primitive::Triangles, { return Trade::MeshData3D(MeshPrimitive::Triangles, {
0, 1, 2, 0, 2, 3, /* +Z */ 0, 1, 2, 0, 2, 3, /* +Z */
4, 5, 6, 4, 6, 7, /* +X */ 4, 5, 6, 4, 6, 7, /* +X */
8, 9, 10, 8, 10, 11, /* +Y */ 8, 9, 10, 8, 10, 11, /* +Y */
@ -101,7 +102,7 @@ Trade::MeshData3D Cube::solid() {
} }
Trade::MeshData3D Cube::wireframe() { Trade::MeshData3D Cube::wireframe() {
return Trade::MeshData3D(Mesh::Primitive::Lines, { return Trade::MeshData3D(MeshPrimitive::Lines, {
0, 1, 1, 2, 2, 3, 3, 0, /* +Z */ 0, 1, 1, 2, 2, 3, 3, 0, /* +Z */
4, 5, 5, 6, 6, 7, 7, 4, /* -Z */ 4, 5, 5, 6, 6, 7, 7, 4, /* -Z */
1, 5, 2, 6, /* +X */ 1, 5, 2, 6, /* +X */

4
src/Primitives/Cube.h

@ -44,14 +44,14 @@ class MAGNUM_PRIMITIVES_EXPORT Cube {
/** /**
* @brief Solid cube * @brief Solid cube
* *
* Indexed @ref Mesh::Primitive "Triangles" with flat normals. * Indexed @ref MeshPrimitive::Triangles with flat normals.
*/ */
static Trade::MeshData3D solid(); static Trade::MeshData3D solid();
/** /**
* @brief Wireframe cube * @brief Wireframe cube
* *
* Indexed @ref Mesh::Primitive "Lines". * Indexed @ref MeshPrimitive::Lines.
*/ */
static Trade::MeshData3D wireframe(); static Trade::MeshData3D wireframe();

5
src/Primitives/Cylinder.cpp

@ -25,6 +25,7 @@
#include "Cylinder.h" #include "Cylinder.h"
#include "Math/Vector3.h" #include "Math/Vector3.h"
#include "Mesh.h"
#include "Primitives/Implementation/Spheroid.h" #include "Primitives/Implementation/Spheroid.h"
#include "Primitives/Implementation/WireframeSpheroid.h" #include "Primitives/Implementation/WireframeSpheroid.h"
#include "Trade/MeshData3D.h" #include "Trade/MeshData3D.h"
@ -32,7 +33,7 @@
namespace Magnum { namespace Primitives { namespace Magnum { namespace Primitives {
Trade::MeshData3D Cylinder::solid(const UnsignedInt rings, const UnsignedInt segments, const Float halfLength, const Flags flags) { 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(Mesh::Primitive::Triangles, std::vector<UnsignedInt>{}, std::vector<std::vector<Vector3>>{}, std::vector<std::vector<Vector3>>{}, std::vector<std::vector<Vector2>>{})); CORRADE_ASSERT(rings >= 1 && segments >= 3, "Primitives::Cylinder::solid(): cylinder must have at least one ring and three segments", Trade::MeshData3D(MeshPrimitive::Triangles, std::vector<UnsignedInt>{}, std::vector<std::vector<Vector3>>{}, std::vector<std::vector<Vector3>>{}, std::vector<std::vector<Vector2>>{}));
Implementation::Spheroid cylinder(segments, flags & Flag::GenerateTextureCoords ? Implementation::Spheroid::TextureCoords::Generate : Implementation::Spheroid::TextureCoords::DontGenerate); Implementation::Spheroid cylinder(segments, flags & Flag::GenerateTextureCoords ? Implementation::Spheroid::TextureCoords::Generate : Implementation::Spheroid::TextureCoords::DontGenerate);
@ -63,7 +64,7 @@ Trade::MeshData3D Cylinder::solid(const UnsignedInt rings, const UnsignedInt seg
} }
Trade::MeshData3D Cylinder::wireframe(const UnsignedInt rings, const UnsignedInt segments, const Float halfLength) { 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(Mesh::Primitive::Lines, std::vector<UnsignedInt>{}, std::vector<std::vector<Vector3>>{}, std::vector<std::vector<Vector3>>{}, std::vector<std::vector<Vector2>>{})); CORRADE_ASSERT(rings >= 1 && segments >= 4 && segments%4 == 0, "Primitives::Cylinder::wireframe(): improper parameters", Trade::MeshData3D(MeshPrimitive::Lines, std::vector<UnsignedInt>{}, std::vector<std::vector<Vector3>>{}, std::vector<std::vector<Vector3>>{}, std::vector<std::vector<Vector2>>{}));
Implementation::WireframeSpheroid cylinder(segments/4); Implementation::WireframeSpheroid cylinder(segments/4);

4
src/Primitives/Cylinder.h

@ -65,7 +65,7 @@ class MAGNUM_PRIMITIVES_EXPORT Cylinder {
* @param halfLength Half the cylinder length * @param halfLength Half the cylinder length
* @param flags Flags * @param flags Flags
* *
* Indexed @ref Mesh::Primitive "Triangles" with normals, optional 2D * Indexed @ref MeshPrimitive::Triangles with normals, optional 2D
* texture coordinates and optional capped ends. If texture coordinates * texture coordinates and optional capped ends. If texture coordinates
* are generated, vertices of one segment are duplicated for texture * are generated, vertices of one segment are duplicated for texture
* wrapping. * wrapping.
@ -80,7 +80,7 @@ class MAGNUM_PRIMITIVES_EXPORT Cylinder {
* equal to 4 and multiple of 4. * equal to 4 and multiple of 4.
* @param halfLength Half the cylinder length * @param halfLength Half the cylinder length
* *
* Indexed @ref Mesh::Primitive "Lines". * Indexed @ref MeshPrimitive::Lines.
*/ */
static Trade::MeshData3D wireframe(UnsignedInt rings, UnsignedInt segments, Float halfLength); static Trade::MeshData3D wireframe(UnsignedInt rings, UnsignedInt segments, Float halfLength);
}; };

5
src/Primitives/Icosphere.cpp

@ -25,9 +25,10 @@
#include "Icosphere.h" #include "Icosphere.h"
#include "Math/Vector3.h" #include "Math/Vector3.h"
#include "Trade/MeshData3D.h" #include "Mesh.h"
#include "MeshTools/Subdivide.h" #include "MeshTools/Subdivide.h"
#include "MeshTools/RemoveDuplicates.h" #include "MeshTools/RemoveDuplicates.h"
#include "Trade/MeshData3D.h"
namespace Magnum { namespace Primitives { namespace Magnum { namespace Primitives {
@ -78,7 +79,7 @@ Trade::MeshData3D Icosphere::solid(const UnsignedInt subdivisions) {
MeshTools::removeDuplicates(indices, positions); MeshTools::removeDuplicates(indices, positions);
std::vector<Vector3> normals(positions); std::vector<Vector3> normals(positions);
return Trade::MeshData3D(Mesh::Primitive::Triangles, std::move(indices), {std::move(positions)}, {std::move(normals)}, std::vector<std::vector<Vector2>>{}); return Trade::MeshData3D(MeshPrimitive::Triangles, std::move(indices), {std::move(positions)}, {std::move(normals)}, std::vector<std::vector<Vector2>>{});
} }
}} }}

2
src/Primitives/Icosphere.h

@ -45,7 +45,7 @@ class MAGNUM_PRIMITIVES_EXPORT Icosphere {
* @brief Solid icosphere * @brief Solid icosphere
* @param subdivisions Number of subdivisions * @param subdivisions Number of subdivisions
* *
* Indexed @ref Mesh::Primitive "Triangles" with normals. * Indexed @ref MeshPrimitive::Triangles with normals.
*/ */
static Trade::MeshData3D solid(UnsignedInt subdivisions); static Trade::MeshData3D solid(UnsignedInt subdivisions);
}; };

3
src/Primitives/Implementation/Spheroid.cpp

@ -26,6 +26,7 @@
#include "Math/Functions.h" #include "Math/Functions.h"
#include "Math/Vector3.h" #include "Math/Vector3.h"
#include "Mesh.h"
#include "Trade/MeshData3D.h" #include "Trade/MeshData3D.h"
namespace Magnum { namespace Primitives { namespace Implementation { namespace Magnum { namespace Primitives { namespace Implementation {
@ -161,7 +162,7 @@ void Spheroid::capVertexRing(Float y, Float textureCoordsV, const Vector3& norma
} }
Trade::MeshData3D Spheroid::finalize() { Trade::MeshData3D Spheroid::finalize() {
return Trade::MeshData3D(Mesh::Primitive::Triangles, std::move(indices), {std::move(positions)}, {std::move(normals)}, return Trade::MeshData3D(MeshPrimitive::Triangles, std::move(indices), {std::move(positions)}, {std::move(normals)},
textureCoords == TextureCoords::Generate ? std::vector<std::vector<Vector2>>{std::move(textureCoords2D)} : std::vector<std::vector<Vector2>>()); textureCoords == TextureCoords::Generate ? std::vector<std::vector<Vector2>>{std::move(textureCoords2D)} : std::vector<std::vector<Vector2>>());
} }

3
src/Primitives/Implementation/WireframeSpheroid.cpp

@ -26,6 +26,7 @@
#include "Math/Functions.h" #include "Math/Functions.h"
#include "Math/Vector3.h" #include "Math/Vector3.h"
#include "Mesh.h"
#include "Trade/MeshData3D.h" #include "Trade/MeshData3D.h"
namespace Magnum { namespace Primitives { namespace Implementation { namespace Magnum { namespace Primitives { namespace Implementation {
@ -109,7 +110,7 @@ void WireframeSpheroid::cylinder() {
} }
Trade::MeshData3D WireframeSpheroid::finalize() { Trade::MeshData3D WireframeSpheroid::finalize() {
return Trade::MeshData3D(Mesh::Primitive::Lines, std::move(_indices), {std::move(_positions)}, std::vector<std::vector<Vector3>>{}, std::vector<std::vector<Vector2>>{}); return Trade::MeshData3D(MeshPrimitive::Lines, std::move(_indices), {std::move(_positions)}, std::vector<std::vector<Vector3>>{}, std::vector<std::vector<Vector2>>{});
} }
}}} }}}

5
src/Primitives/Line.cpp

@ -25,19 +25,20 @@
#include "Line.h" #include "Line.h"
#include "Math/Vector3.h" #include "Math/Vector3.h"
#include "Mesh.h"
#include "Trade/MeshData2D.h" #include "Trade/MeshData2D.h"
#include "Trade/MeshData3D.h" #include "Trade/MeshData3D.h"
namespace Magnum { namespace Primitives { namespace Magnum { namespace Primitives {
Trade::MeshData2D Line2D::wireframe() { Trade::MeshData2D Line2D::wireframe() {
return Trade::MeshData2D(Mesh::Primitive::Lines, std::vector<UnsignedInt>{}, {{ return Trade::MeshData2D(MeshPrimitive::Lines, std::vector<UnsignedInt>{}, {{
{0.0f, 0.0f}, {1.0f, 0.0f} {0.0f, 0.0f}, {1.0f, 0.0f}
}}, std::vector<std::vector<Vector2>>{}); }}, std::vector<std::vector<Vector2>>{});
} }
Trade::MeshData3D Line3D::wireframe() { Trade::MeshData3D Line3D::wireframe() {
return Trade::MeshData3D(Mesh::Primitive::Lines, std::vector<UnsignedInt>{}, {{ return Trade::MeshData3D(MeshPrimitive::Lines, std::vector<UnsignedInt>{}, {{
{0.0f, 0.0f, 0.0f}, {1.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 0.0f}, {1.0f, 0.0f, 0.0f},
}}, std::vector<std::vector<Vector3>>{}, std::vector<std::vector<Vector2>>{}); }}, std::vector<std::vector<Vector3>>{}, std::vector<std::vector<Vector2>>{});
} }

4
src/Primitives/Line.h

@ -38,7 +38,7 @@ namespace Magnum { namespace Primitives {
@brief 2D line primitive @brief 2D line primitive
Unit-size line in direction of positive X axis. Non-indexed Unit-size line in direction of positive X axis. Non-indexed
@ref Mesh::Primitive "Lines". @ref MeshPrimitive::Lines.
*/ */
class MAGNUM_PRIMITIVES_EXPORT Line2D { class MAGNUM_PRIMITIVES_EXPORT Line2D {
public: public:
@ -52,7 +52,7 @@ class MAGNUM_PRIMITIVES_EXPORT Line2D {
@brief 3D line primitive @brief 3D line primitive
Unit-size line in direction of positive X axis. Non-indexed Unit-size line in direction of positive X axis. Non-indexed
@ref Mesh::Primitive "Lines". @ref MeshPrimitive::Lines.
*/ */
class MAGNUM_PRIMITIVES_EXPORT Line3D { class MAGNUM_PRIMITIVES_EXPORT Line3D {
public: public:

5
src/Primitives/Plane.cpp

@ -25,6 +25,7 @@
#include "Plane.h" #include "Plane.h"
#include "Math/Vector3.h" #include "Math/Vector3.h"
#include "Mesh.h"
#include "Trade/MeshData3D.h" #include "Trade/MeshData3D.h"
namespace Magnum { namespace Primitives { namespace Magnum { namespace Primitives {
@ -38,7 +39,7 @@ Trade::MeshData3D Plane::solid(const TextureCoords textureCoords) {
{0.0f, 1.0f} {0.0f, 1.0f}
}); });
return Trade::MeshData3D(Mesh::Primitive::TriangleStrip, std::vector<UnsignedInt>{}, {{ return Trade::MeshData3D(MeshPrimitive::TriangleStrip, std::vector<UnsignedInt>{}, {{
{1.0f, -1.0f, 0.0f}, {1.0f, -1.0f, 0.0f},
{1.0f, 1.0f, 0.0f}, {1.0f, 1.0f, 0.0f},
{-1.0f, -1.0f, 0.0f}, {-1.0f, -1.0f, 0.0f},
@ -52,7 +53,7 @@ Trade::MeshData3D Plane::solid(const TextureCoords textureCoords) {
} }
Trade::MeshData3D Plane::wireframe() { Trade::MeshData3D Plane::wireframe() {
return Trade::MeshData3D(Mesh::Primitive::LineLoop, std::vector<UnsignedInt>{}, {{ return Trade::MeshData3D(MeshPrimitive::LineLoop, std::vector<UnsignedInt>{}, {{
{-1.0f, -1.0f, 0.0f}, {-1.0f, -1.0f, 0.0f},
{1.0f, -1.0f, 0.0f}, {1.0f, -1.0f, 0.0f},
{1.0f, 1.0f, 0.0f}, {1.0f, 1.0f, 0.0f},

4
src/Primitives/Plane.h

@ -53,7 +53,7 @@ class MAGNUM_PRIMITIVES_EXPORT Plane {
/** /**
* @brief Solid plane * @brief Solid plane
* *
* Non-indexed @ref Mesh::Primitive "TriangleStrip" with normals in * Non-indexed @ref MeshPrimitive::TriangleStrip with normals in
* positive Z direction. * positive Z direction.
*/ */
static Trade::MeshData3D solid(TextureCoords textureCoords = TextureCoords::DontGenerate); static Trade::MeshData3D solid(TextureCoords textureCoords = TextureCoords::DontGenerate);
@ -61,7 +61,7 @@ class MAGNUM_PRIMITIVES_EXPORT Plane {
/** /**
* @brief Wireframe plane * @brief Wireframe plane
* *
* Non-indexed @ref Mesh::Primitive "LineLoop". * Non-indexed @ref MeshPrimitive::LineLoop.
*/ */
static Trade::MeshData3D wireframe(); static Trade::MeshData3D wireframe();

5
src/Primitives/Square.cpp

@ -25,6 +25,7 @@
#include "Square.h" #include "Square.h"
#include "Math/Vector2.h" #include "Math/Vector2.h"
#include "Mesh.h"
#include "Trade/MeshData2D.h" #include "Trade/MeshData2D.h"
namespace Magnum { namespace Primitives { namespace Magnum { namespace Primitives {
@ -38,7 +39,7 @@ Trade::MeshData2D Square::solid(const TextureCoords textureCoords) {
{0.0f, 1.0f} {0.0f, 1.0f}
}); });
return Trade::MeshData2D(Mesh::Primitive::TriangleStrip, std::vector<UnsignedInt>{}, {{ return Trade::MeshData2D(MeshPrimitive::TriangleStrip, std::vector<UnsignedInt>{}, {{
{1.0f, -1.0f}, {1.0f, -1.0f},
{1.0f, 1.0f}, {1.0f, 1.0f},
{-1.0f, -1.0f}, {-1.0f, -1.0f},
@ -47,7 +48,7 @@ Trade::MeshData2D Square::solid(const TextureCoords textureCoords) {
} }
Trade::MeshData2D Square::wireframe() { Trade::MeshData2D Square::wireframe() {
return Trade::MeshData2D(Mesh::Primitive::LineLoop, std::vector<UnsignedInt>{}, {{ return Trade::MeshData2D(MeshPrimitive::LineLoop, std::vector<UnsignedInt>{}, {{
{-1.0f, -1.0f}, {-1.0f, -1.0f},
{1.0f, -1.0f}, {1.0f, -1.0f},
{1.0f, 1.0f}, {1.0f, 1.0f},

4
src/Primitives/Square.h

@ -53,14 +53,14 @@ class MAGNUM_PRIMITIVES_EXPORT Square {
/** /**
* @brief Solid square * @brief Solid square
* *
* Non-indexed @ref Mesh::Primitive "TriangleStrip". * Non-indexed @ref MeshPrimitive::TriangleStrip.
*/ */
static Trade::MeshData2D solid(TextureCoords textureCoords = TextureCoords::DontGenerate); static Trade::MeshData2D solid(TextureCoords textureCoords = TextureCoords::DontGenerate);
/** /**
* @brief Wireframe square * @brief Wireframe square
* *
* Non-indexed @ref Mesh::Primitive "LineLoop." * Non-indexed @ref MeshPrimitive::LineLoop.
*/ */
static Trade::MeshData2D wireframe(); static Trade::MeshData2D wireframe();

5
src/Primitives/UVSphere.cpp

@ -25,6 +25,7 @@
#include "UVSphere.h" #include "UVSphere.h"
#include "Math/Vector3.h" #include "Math/Vector3.h"
#include "Mesh.h"
#include "Primitives/Implementation/Spheroid.h" #include "Primitives/Implementation/Spheroid.h"
#include "Primitives/Implementation/WireframeSpheroid.h" #include "Primitives/Implementation/WireframeSpheroid.h"
#include "Trade/MeshData3D.h" #include "Trade/MeshData3D.h"
@ -32,7 +33,7 @@
namespace Magnum { namespace Primitives { namespace Magnum { namespace Primitives {
Trade::MeshData3D UVSphere::solid(UnsignedInt rings, UnsignedInt segments, TextureCoords textureCoords) { 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(Mesh::Primitive::Triangles, std::vector<UnsignedInt>{}, std::vector<std::vector<Vector3>>{}, std::vector<std::vector<Vector3>>{}, std::vector<std::vector<Vector2>>{})); CORRADE_ASSERT(rings >= 2 && segments >= 3, "UVSphere must have at least two rings and three segments", Trade::MeshData3D(MeshPrimitive::Triangles, std::vector<UnsignedInt>{}, std::vector<std::vector<Vector3>>{}, std::vector<std::vector<Vector3>>{}, std::vector<std::vector<Vector2>>{}));
Implementation::Spheroid sphere(segments, textureCoords == TextureCoords::Generate ? Implementation::Spheroid sphere(segments, textureCoords == TextureCoords::Generate ?
Implementation::Spheroid::TextureCoords::Generate : Implementation::Spheroid::TextureCoords::Generate :
@ -59,7 +60,7 @@ Trade::MeshData3D UVSphere::solid(UnsignedInt rings, UnsignedInt segments, Textu
} }
Trade::MeshData3D UVSphere::wireframe(const UnsignedInt rings, const UnsignedInt segments) { 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(Mesh::Primitive::Lines, std::vector<UnsignedInt>{}, std::vector<std::vector<Vector3>>{}, std::vector<std::vector<Vector3>>{}, std::vector<std::vector<Vector2>>{})); CORRADE_ASSERT(rings >= 2 && rings%2 == 0 && segments >= 4 && segments%2 == 0, "Primitives::UVSphere::wireframe(): improper parameters", Trade::MeshData3D(MeshPrimitive::Lines, std::vector<UnsignedInt>{}, std::vector<std::vector<Vector3>>{}, std::vector<std::vector<Vector3>>{}, std::vector<std::vector<Vector2>>{}));
Implementation::WireframeSpheroid sphere(segments/4); Implementation::WireframeSpheroid sphere(segments/4);

8
src/Primitives/UVSphere.h

@ -54,9 +54,9 @@ class MAGNUM_PRIMITIVES_EXPORT UVSphere {
* equal to 3. * equal to 3.
* @param textureCoords Whether to generate texture coordinates. * @param textureCoords Whether to generate texture coordinates.
* *
* Indexed @ref Mesh::Primitive "Triangles" with normals and optional * Indexed @ref MeshPrimitive::Triangles with normals and optional 2D
* 2D texture coordinates. If texture coordinates are generated, * texture coordinates. If texture coordinates are generated, vertices
* vertices of one segment are duplicated for texture wrapping. * of one segment are duplicated for texture wrapping.
*/ */
static Trade::MeshData3D solid(UnsignedInt rings, UnsignedInt segments, TextureCoords textureCoords = TextureCoords::DontGenerate); static Trade::MeshData3D solid(UnsignedInt rings, UnsignedInt segments, TextureCoords textureCoords = TextureCoords::DontGenerate);
@ -67,7 +67,7 @@ class MAGNUM_PRIMITIVES_EXPORT UVSphere {
* @param segments Number of (line) segments. Must be larger or * @param segments Number of (line) segments. Must be larger or
* equal to 4 and multiple of 4. * equal to 4 and multiple of 4.
* *
* Indexed @ref Mesh::Primitive "Lines". * Indexed @ref MeshPrimitive::Lines.
*/ */
static Trade::MeshData3D wireframe(UnsignedInt rings, UnsignedInt segments); static Trade::MeshData3D wireframe(UnsignedInt rings, UnsignedInt segments);
}; };

8
src/Test/MeshTest.cpp

@ -49,8 +49,8 @@ MeshTest::MeshTest() {
void MeshTest::debugPrimitive() { void MeshTest::debugPrimitive() {
std::ostringstream o; std::ostringstream o;
Debug(&o) << Mesh::Primitive::TriangleFan; Debug(&o) << MeshPrimitive::TriangleFan;
CORRADE_COMPARE(o.str(), "Mesh::Primitive::TriangleFan\n"); CORRADE_COMPARE(o.str(), "MeshPrimitive::TriangleFan\n");
} }
void MeshTest::debugIndexType() { void MeshTest::debugIndexType() {
@ -62,9 +62,9 @@ void MeshTest::debugIndexType() {
void MeshTest::configurationPrimitive() { void MeshTest::configurationPrimitive() {
Utility::Configuration c; Utility::Configuration c;
c.setValue("primitive", Mesh::Primitive::LineStrip); c.setValue("primitive", MeshPrimitive::LineStrip);
CORRADE_COMPARE(c.value("primitive"), "LineStrip"); CORRADE_COMPARE(c.value("primitive"), "LineStrip");
CORRADE_COMPARE(c.value<Mesh::Primitive>("primitive"), Mesh::Primitive::LineStrip); CORRADE_COMPARE(c.value<MeshPrimitive>("primitive"), MeshPrimitive::LineStrip);
} }
void MeshTest::configurationIndexType() { void MeshTest::configurationIndexType() {

4
src/Text/Renderer.cpp

@ -211,7 +211,7 @@ std::tuple<Mesh, Range2D> renderInternal(AbstractFont& font, const GlyphCache& c
/* Configure mesh except for vertex buffer (depends on dimension count, done /* Configure mesh except for vertex buffer (depends on dimension count, done
in subclass) */ in subclass) */
Mesh mesh; Mesh mesh;
mesh.setPrimitive(Mesh::Primitive::Triangles) mesh.setPrimitive(MeshPrimitive::Triangles)
.setIndexCount(indexCount) .setIndexCount(indexCount)
.setIndexBuffer(indexBuffer, 0, indexType, 0, vertexCount); .setIndexBuffer(indexBuffer, 0, indexType, 0, vertexCount);
@ -317,7 +317,7 @@ AbstractRenderer::AbstractRenderer(AbstractFont& font, const GlyphCache& cache,
#endif #endif
/* Vertex buffer configuration depends on dimension count, done in subclass */ /* Vertex buffer configuration depends on dimension count, done in subclass */
_mesh.setPrimitive(Mesh::Primitive::Triangles); _mesh.setPrimitive(MeshPrimitive::Triangles);
} }
AbstractRenderer::~AbstractRenderer() {} AbstractRenderer::~AbstractRenderer() {}

2
src/TextureTools/DistanceField.cpp

@ -175,7 +175,7 @@ void distanceField(Texture2D& input, Texture2D& output, const Range2Di& rectangl
} }
Mesh mesh; Mesh mesh;
mesh.setPrimitive(Mesh::Primitive::Triangles) mesh.setPrimitive(MeshPrimitive::Triangles)
.setVertexCount(3); .setVertexCount(3);
/* Older GLSL doesn't have gl_VertexID, vertices must be supplied explicitly */ /* Older GLSL doesn't have gl_VertexID, vertices must be supplied explicitly */

2
src/Trade/MeshData2D.cpp

@ -28,7 +28,7 @@
namespace Magnum { namespace Trade { namespace Magnum { namespace Trade {
MeshData2D::MeshData2D(Mesh::Primitive primitive, std::vector<UnsignedInt> indices, std::vector<std::vector<Vector2>> positions, std::vector<std::vector<Vector2>> textureCoords2D): _primitive(primitive), _indices(std::move(indices)), _positions(std::move(positions)), _textureCoords2D(std::move(textureCoords2D)) { MeshData2D::MeshData2D(MeshPrimitive primitive, std::vector<UnsignedInt> indices, std::vector<std::vector<Vector2>> positions, std::vector<std::vector<Vector2>> textureCoords2D): _primitive(primitive), _indices(std::move(indices)), _positions(std::move(positions)), _textureCoords2D(std::move(textureCoords2D)) {
CORRADE_ASSERT(!_positions.empty(), "Trade::MeshData2D: no position array specified", ); CORRADE_ASSERT(!_positions.empty(), "Trade::MeshData2D: no position array specified", );
} }

12
src/Trade/MeshData2D.h

@ -28,9 +28,11 @@
* @brief Class Magnum::Trade::MeshData2D * @brief Class Magnum::Trade::MeshData2D
*/ */
#include <string> #include <vector>
#include "Mesh.h" #include "Magnum.h"
#include "magnumVisibility.h"
namespace Magnum { namespace Trade { namespace Magnum { namespace Trade {
@ -53,7 +55,7 @@ class MAGNUM_EXPORT MeshData2D {
* @param textureCoords2D Two-dimensional texture coordinate arrays, * @param textureCoords2D Two-dimensional texture coordinate arrays,
* if present * if present
*/ */
explicit MeshData2D(Mesh::Primitive primitive, std::vector<UnsignedInt> indices, std::vector<std::vector<Vector2>> positions, std::vector<std::vector<Vector2>> textureCoords2D); explicit MeshData2D(MeshPrimitive primitive, std::vector<UnsignedInt> indices, std::vector<std::vector<Vector2>> positions, std::vector<std::vector<Vector2>> textureCoords2D);
/** @brief Copying is not allowed */ /** @brief Copying is not allowed */
MeshData2D(const MeshData2D&) = delete; MeshData2D(const MeshData2D&) = delete;
@ -70,7 +72,7 @@ class MAGNUM_EXPORT MeshData2D {
MeshData2D& operator=(MeshData2D&&); MeshData2D& operator=(MeshData2D&&);
/** @brief Primitive */ /** @brief Primitive */
Mesh::Primitive primitive() const { return _primitive; } MeshPrimitive primitive() const { return _primitive; }
/** @brief Whether the mesh is indexed */ /** @brief Whether the mesh is indexed */
bool isIndexed() const { return !_indices.empty(); } bool isIndexed() const { return !_indices.empty(); }
@ -115,7 +117,7 @@ class MAGNUM_EXPORT MeshData2D {
const std::vector<Vector2>& textureCoords2D(UnsignedInt id) const; /**< @overload */ const std::vector<Vector2>& textureCoords2D(UnsignedInt id) const; /**< @overload */
private: private:
Mesh::Primitive _primitive; MeshPrimitive _primitive;
std::vector<UnsignedInt> _indices; std::vector<UnsignedInt> _indices;
std::vector<std::vector<Vector2>> _positions; std::vector<std::vector<Vector2>> _positions;
std::vector<std::vector<Vector2>> _textureCoords2D; std::vector<std::vector<Vector2>> _textureCoords2D;

2
src/Trade/MeshData3D.cpp

@ -28,7 +28,7 @@
namespace Magnum { namespace Trade { namespace Magnum { namespace Trade {
MeshData3D::MeshData3D(Mesh::Primitive primitive, std::vector<UnsignedInt> indices, std::vector<std::vector<Vector3>> positions, std::vector<std::vector<Vector3>> normals, std::vector<std::vector<Vector2>> textureCoords2D): _primitive(primitive), _indices(std::move(indices)), _positions(std::move(positions)), _normals(std::move(normals)), _textureCoords2D(std::move(textureCoords2D)) { MeshData3D::MeshData3D(MeshPrimitive primitive, std::vector<UnsignedInt> indices, std::vector<std::vector<Vector3>> positions, std::vector<std::vector<Vector3>> normals, std::vector<std::vector<Vector2>> textureCoords2D): _primitive(primitive), _indices(std::move(indices)), _positions(std::move(positions)), _normals(std::move(normals)), _textureCoords2D(std::move(textureCoords2D)) {
CORRADE_ASSERT(!_positions.empty(), "Trade::MeshData3D: no position array specified", ); CORRADE_ASSERT(!_positions.empty(), "Trade::MeshData3D: no position array specified", );
} }

12
src/Trade/MeshData3D.h

@ -28,9 +28,11 @@
* @brief Class Magnum::Trade::MeshData3D * @brief Class Magnum::Trade::MeshData3D
*/ */
#include <string> #include <vector>
#include "Mesh.h" #include "Magnum.h"
#include "magnumVisibility.h"
namespace Magnum { namespace Trade { namespace Magnum { namespace Trade {
@ -54,7 +56,7 @@ class MAGNUM_EXPORT MeshData3D {
* @param textureCoords2D Two-dimensional texture coordinate arrays, * @param textureCoords2D Two-dimensional texture coordinate arrays,
* if present * if present
*/ */
explicit MeshData3D(Mesh::Primitive primitive, std::vector<UnsignedInt> indices, std::vector<std::vector<Vector3>> positions, std::vector<std::vector<Vector3>> normals, std::vector<std::vector<Vector2>> textureCoords2D); explicit MeshData3D(MeshPrimitive primitive, std::vector<UnsignedInt> indices, std::vector<std::vector<Vector3>> positions, std::vector<std::vector<Vector3>> normals, std::vector<std::vector<Vector2>> textureCoords2D);
/** @brief Copying is not allowed */ /** @brief Copying is not allowed */
MeshData3D(const MeshData3D&) = delete; MeshData3D(const MeshData3D&) = delete;
@ -71,7 +73,7 @@ class MAGNUM_EXPORT MeshData3D {
MeshData3D& operator=(MeshData3D&&); MeshData3D& operator=(MeshData3D&&);
/** @brief Primitive */ /** @brief Primitive */
Mesh::Primitive primitive() const { return _primitive; } MeshPrimitive primitive() const { return _primitive; }
/** @brief Whether the mesh is indexed */ /** @brief Whether the mesh is indexed */
bool isIndexed() const { return !_indices.empty(); } bool isIndexed() const { return !_indices.empty(); }
@ -131,7 +133,7 @@ class MAGNUM_EXPORT MeshData3D {
const std::vector<Vector2>& textureCoords2D(UnsignedInt id) const; /**< @overload */ const std::vector<Vector2>& textureCoords2D(UnsignedInt id) const; /**< @overload */
private: private:
Mesh::Primitive _primitive; MeshPrimitive _primitive;
std::vector<UnsignedInt> _indices; std::vector<UnsignedInt> _indices;
std::vector<std::vector<Vector3>> _positions; std::vector<std::vector<Vector3>> _positions;
std::vector<std::vector<Vector3>> _normals; std::vector<std::vector<Vector3>> _normals;

Loading…
Cancel
Save