diff --git a/src/Primitives/Capsule.cpp b/src/Primitives/Capsule.cpp index 94b6b8e5d..6ac9a6317 100644 --- a/src/Primitives/Capsule.cpp +++ b/src/Primitives/Capsule.cpp @@ -20,11 +20,11 @@ namespace Magnum { namespace Primitives { -Capsule::Capsule(std::uint32_t hemisphereRings, std::uint32_t cylinderRings, std::uint32_t segments, GLfloat length, TextureCoords textureCoords): MeshData3D(Mesh::Primitive::Triangles, new std::vector, {new std::vector()}, {new std::vector()}, textureCoords == TextureCoords::Generate ? std::vector*>{new std::vector()} : std::vector*>()), segments(segments), textureCoords(textureCoords) { +Capsule::Capsule(UnsignedInt hemisphereRings, UnsignedInt cylinderRings, UnsignedInt segments, Float length, TextureCoords textureCoords): MeshData3D(Mesh::Primitive::Triangles, new std::vector, {new std::vector()}, {new std::vector()}, textureCoords == TextureCoords::Generate ? std::vector*>{new std::vector()} : std::vector*>()), segments(segments), textureCoords(textureCoords) { CORRADE_ASSERT(hemisphereRings >= 1 && cylinderRings >= 1 && segments >= 3, "Capsule must have at least one hemisphere ring, one cylinder ring and three segments", ); - GLfloat height = 2.0f+length; - GLfloat hemisphereTextureCoordsVIncrement = 1.0f/(hemisphereRings*height); + Float height = 2.0f+length; + Float hemisphereTextureCoordsVIncrement = 1.0f/(hemisphereRings*height); Rad hemisphereRingAngleIncrement = Rad(Constants::pi())/(2*hemisphereRings); /* Bottom cap vertex */ @@ -48,9 +48,9 @@ Capsule::Capsule(std::uint32_t hemisphereRings, std::uint32_t cylinderRings, std topFaceRing(); } -Capsule::Capsule(std::uint32_t segments, TextureCoords textureCoords): MeshData3D(Mesh::Primitive::Triangles, new std::vector, {new std::vector()}, {new std::vector()}, textureCoords == TextureCoords::Generate ? std::vector*>{new std::vector()} : std::vector*>()), segments(segments), textureCoords(textureCoords) {} +Capsule::Capsule(UnsignedInt segments, TextureCoords textureCoords): MeshData3D(Mesh::Primitive::Triangles, new std::vector, {new std::vector()}, {new std::vector()}, textureCoords == TextureCoords::Generate ? std::vector*>{new std::vector()} : std::vector*>()), segments(segments), textureCoords(textureCoords) {} -void Capsule::capVertex(GLfloat y, GLfloat normalY, GLfloat textureCoordsV) { +void Capsule::capVertex(Float y, Float normalY, Float textureCoordsV) { positions(0)->push_back({0.0f, y, 0.0f}); normals(0)->push_back({0.0f, normalY, 0.0f}); @@ -58,15 +58,15 @@ void Capsule::capVertex(GLfloat y, GLfloat normalY, GLfloat textureCoordsV) { textureCoords2D(0)->push_back({0.5, textureCoordsV}); } -void Capsule::hemisphereVertexRings(std::uint32_t count, GLfloat centerY, Rad startRingAngle, Rad ringAngleIncrement, GLfloat startTextureCoordsV, GLfloat textureCoordsVIncrement) { +void Capsule::hemisphereVertexRings(UnsignedInt count, Float centerY, Rad startRingAngle, Rad ringAngleIncrement, Float startTextureCoordsV, Float textureCoordsVIncrement) { Rad segmentAngleIncrement = 2*Rad(Constants::pi())/segments; - GLfloat x, y, z; - for(std::uint32_t i = 0; i != count; ++i) { + Float x, y, z; + for(UnsignedInt i = 0; i != count; ++i) { Rad ringAngle = startRingAngle + i*ringAngleIncrement; x = z = Math::cos(ringAngle); y = Math::sin(ringAngle); - for(std::uint32_t j = 0; j != segments; ++j) { + for(UnsignedInt j = 0; j != segments; ++j) { Rad segmentAngle = j*segmentAngleIncrement; positions(0)->push_back({x*Math::sin(segmentAngle), centerY+y, z*Math::cos(segmentAngle)}); normals(0)->push_back({x*Math::sin(segmentAngle), y, z*Math::cos(segmentAngle)}); @@ -84,10 +84,10 @@ void Capsule::hemisphereVertexRings(std::uint32_t count, GLfloat centerY, Rad st } } -void Capsule::cylinderVertexRings(std::uint32_t count, GLfloat startY, GLfloat yIncrement, GLfloat startTextureCoordsV, GLfloat textureCoordsVIncrement) { +void Capsule::cylinderVertexRings(UnsignedInt count, Float startY, Float yIncrement, Float startTextureCoordsV, Float textureCoordsVIncrement) { Rad segmentAngleIncrement = 2*Rad(Constants::pi())/segments; - for(std::uint32_t i = 0; i != count; ++i) { - for(std::uint32_t j = 0; j != segments; ++j) { + for(UnsignedInt i = 0; i != count; ++i) { + for(UnsignedInt j = 0; j != segments; ++j) { Rad segmentAngle = j*segmentAngleIncrement; positions(0)->push_back({Math::sin(segmentAngle), startY, Math::cos(segmentAngle)}); normals(0)->push_back({Math::sin(segmentAngle), 0.0f, Math::cos(segmentAngle)}); @@ -108,7 +108,7 @@ void Capsule::cylinderVertexRings(std::uint32_t count, GLfloat startY, GLfloat y } void Capsule::bottomFaceRing() { - for(std::uint32_t j = 0; j != segments; ++j) { + for(UnsignedInt j = 0; j != segments; ++j) { /* Bottom vertex */ indices()->push_back(0); @@ -121,16 +121,16 @@ void Capsule::bottomFaceRing() { } } -void Capsule::faceRings(std::uint32_t count, std::uint32_t offset) { - std::uint32_t vertexSegments = segments + (textureCoords == TextureCoords::Generate ? 1 : 0); +void Capsule::faceRings(UnsignedInt count, UnsignedInt offset) { + UnsignedInt vertexSegments = segments + (textureCoords == TextureCoords::Generate ? 1 : 0); - for(std::uint32_t i = 0; i != count; ++i) { - for(std::uint32_t j = 0; j != segments; ++j) { - std::uint32_t bottomLeft = i*vertexSegments+j+offset; - std::uint32_t bottomRight = ((j != segments-1 || textureCoords == TextureCoords::Generate) ? + for(UnsignedInt i = 0; i != count; ++i) { + for(UnsignedInt j = 0; j != segments; ++j) { + UnsignedInt bottomLeft = i*vertexSegments+j+offset; + UnsignedInt bottomRight = ((j != segments-1 || textureCoords == TextureCoords::Generate) ? i*vertexSegments+j+1+offset : i*segments+offset); - std::uint32_t topLeft = bottomLeft+vertexSegments; - std::uint32_t topRight = bottomRight+vertexSegments; + UnsignedInt topLeft = bottomLeft+vertexSegments; + UnsignedInt topRight = bottomRight+vertexSegments; indices()->push_back(bottomLeft); indices()->push_back(bottomRight); @@ -143,9 +143,9 @@ void Capsule::faceRings(std::uint32_t count, std::uint32_t offset) { } void Capsule::topFaceRing() { - std::uint32_t vertexSegments = segments + (textureCoords == TextureCoords::Generate ? 1 : 0); + UnsignedInt vertexSegments = segments + (textureCoords == TextureCoords::Generate ? 1 : 0); - for(std::uint32_t j = 0; j != segments; ++j) { + for(UnsignedInt j = 0; j != segments; ++j) { /* Bottom left vertex */ indices()->push_back(normals(0)->size()-vertexSegments+j-1); diff --git a/src/Primitives/Capsule.h b/src/Primitives/Capsule.h index 1ae25f78b..461478796 100644 --- a/src/Primitives/Capsule.h +++ b/src/Primitives/Capsule.h @@ -55,19 +55,19 @@ class Capsule: public Trade::MeshData3D { * If texture coordinates are generated, vertices of one segment are * duplicated for texture wrapping. */ - explicit MAGNUM_PRIMITIVES_EXPORT Capsule(std::uint32_t hemisphereRings, std::uint32_t cylinderRings, std::uint32_t segments, GLfloat length, TextureCoords textureCoords = TextureCoords::DontGenerate); + explicit MAGNUM_PRIMITIVES_EXPORT Capsule(UnsignedInt hemisphereRings, UnsignedInt cylinderRings, UnsignedInt segments, Float length, TextureCoords textureCoords = TextureCoords::DontGenerate); private: - Capsule(std::uint32_t segments, TextureCoords textureCoords); + Capsule(UnsignedInt segments, TextureCoords textureCoords); - void capVertex(GLfloat y, GLfloat normalY, GLfloat textureCoordsV); - void hemisphereVertexRings(std::uint32_t count, GLfloat centerY, Rad startRingAngle, Rad ringAngleIncrement, GLfloat startTextureCoordsV, GLfloat textureCoordsVIncrement); - void cylinderVertexRings(std::uint32_t count, GLfloat startY, GLfloat yIncrement, GLfloat startTextureCoordsV, GLfloat textureCoordsVIncrement); + void capVertex(Float y, Float normalY, Float textureCoordsV); + void hemisphereVertexRings(UnsignedInt count, Float centerY, Rad startRingAngle, Rad ringAngleIncrement, Float startTextureCoordsV, Float textureCoordsVIncrement); + void cylinderVertexRings(UnsignedInt count, Float startY, Float yIncrement, Float startTextureCoordsV, Float textureCoordsVIncrement); void bottomFaceRing(); - void faceRings(std::uint32_t count, std::uint32_t offset = 1); + void faceRings(UnsignedInt count, UnsignedInt offset = 1); void topFaceRing(); - std::uint32_t segments; + UnsignedInt segments; TextureCoords textureCoords; }; diff --git a/src/Primitives/Cube.cpp b/src/Primitives/Cube.cpp index 6c63afdc6..9319d341c 100644 --- a/src/Primitives/Cube.cpp +++ b/src/Primitives/Cube.cpp @@ -21,7 +21,7 @@ namespace Magnum { namespace Primitives { Trade::MeshData3D Cube::solid() { - return Trade::MeshData3D(Mesh::Primitive::Triangles, new std::vector{ + return Trade::MeshData3D(Mesh::Primitive::Triangles, new std::vector{ 0, 1, 2, 0, 2, 3, /* +Z */ 4, 5, 6, 4, 6, 7, /* +X */ 8, 9, 10, 8, 10, 11, /* +Y */ @@ -92,7 +92,7 @@ Trade::MeshData3D Cube::solid() { } Trade::MeshData3D Cube::wireframe() { - return Trade::MeshData3D(Mesh::Primitive::Lines, new std::vector{ + return Trade::MeshData3D(Mesh::Primitive::Lines, new std::vector{ 0, 1, 1, 2, 2, 3, 3, 0, /* +Z */ 4, 5, 5, 6, 6, 7, 7, 4, /* -Z */ 1, 5, 2, 6, /* +X */ diff --git a/src/Primitives/Cylinder.cpp b/src/Primitives/Cylinder.cpp index 8b47b67f4..b51e991f5 100644 --- a/src/Primitives/Cylinder.cpp +++ b/src/Primitives/Cylinder.cpp @@ -20,11 +20,11 @@ namespace Magnum { namespace Primitives { -Cylinder::Cylinder(std::uint32_t rings, std::uint32_t segments, GLfloat length, Flags flags): Capsule(segments, flags & Flag::GenerateTextureCoords ? TextureCoords::Generate : TextureCoords::DontGenerate) { +Cylinder::Cylinder(UnsignedInt rings, UnsignedInt segments, Float length, Flags flags): Capsule(segments, flags & Flag::GenerateTextureCoords ? TextureCoords::Generate : TextureCoords::DontGenerate) { CORRADE_ASSERT(rings >= 1 && segments >= 3, "Cylinder must have at least one ring and three segments", ); - GLfloat y = length*0.5f; - GLfloat textureCoordsV = flags & Flag::CapEnds ? 1.0f/(length+2.0f) : 0.0f; + Float y = length*0.5f; + Float textureCoordsV = flags & Flag::CapEnds ? 1.0f/(length+2.0f) : 0.0f; /* Bottom cap */ if(flags & Flag::CapEnds) { @@ -47,10 +47,10 @@ Cylinder::Cylinder(std::uint32_t rings, std::uint32_t segments, GLfloat length, if(flags & Flag::CapEnds) topFaceRing(); } -void Cylinder::capVertexRing(GLfloat y, GLfloat textureCoordsV, const Vector3& normal) { +void Cylinder::capVertexRing(Float y, Float textureCoordsV, const Vector3& normal) { Rad segmentAngleIncrement = 2*Rad(Constants::pi())/segments; - for(std::uint32_t i = 0; i != segments; ++i) { + for(UnsignedInt i = 0; i != segments; ++i) { Rad segmentAngle = i*segmentAngleIncrement; positions(0)->push_back({Math::sin(segmentAngle), y, Math::cos(segmentAngle)}); normals(0)->push_back(normal); diff --git a/src/Primitives/Cylinder.h b/src/Primitives/Cylinder.h index a5b35beb8..1e8be915c 100644 --- a/src/Primitives/Cylinder.h +++ b/src/Primitives/Cylinder.h @@ -60,10 +60,10 @@ class Cylinder: public Capsule { * If texture coordinates are generated, vertices of one segment are * duplicated for texture wrapping. */ - explicit MAGNUM_PRIMITIVES_EXPORT Cylinder(std::uint32_t rings, std::uint32_t segments, GLfloat length, Flags flags = Flags()); + explicit MAGNUM_PRIMITIVES_EXPORT Cylinder(UnsignedInt rings, UnsignedInt segments, Float length, Flags flags = Flags()); private: - void capVertexRing(GLfloat y, GLfloat textureCoordsV, const Vector3& normal); + void capVertexRing(Float y, Float textureCoordsV, const Vector3& normal); }; CORRADE_ENUMSET_OPERATORS(Cylinder::Flags) diff --git a/src/Primitives/Icosphere.cpp b/src/Primitives/Icosphere.cpp index f7e003ba3..0dbd56845 100644 --- a/src/Primitives/Icosphere.cpp +++ b/src/Primitives/Icosphere.cpp @@ -19,7 +19,7 @@ namespace Magnum { namespace Primitives { -Icosphere<0>::Icosphere(): MeshData3D(Mesh::Primitive::Triangles, new std::vector{ +Icosphere<0>::Icosphere(): MeshData3D(Mesh::Primitive::Triangles, new std::vector{ 1, 2, 6, 1, 7, 2, 3, 4, 5, diff --git a/src/Primitives/Test/CapsuleTest.cpp b/src/Primitives/Test/CapsuleTest.cpp index 84177dc4a..d37ae82d9 100644 --- a/src/Primitives/Test/CapsuleTest.cpp +++ b/src/Primitives/Test/CapsuleTest.cpp @@ -94,7 +94,7 @@ void CapsuleTest::withoutTextureCoords() { {0.0f, 1.0f, 0.0f} }), Container); - CORRADE_COMPARE_AS(*capsule.indices(), (std::vector{ + CORRADE_COMPARE_AS(*capsule.indices(), (std::vector{ 0, 2, 1, 0, 3, 2, 0, 1, 3, 1, 2, 5, 1, 5, 4, 2, 3, 6, 2, 6, 5, 3, 1, 4, 3, 4, 6, 4, 5, 8, 4, 8, 7, 5, 6, 9, 5, 9, 8, 6, 4, 7, 6, 7, 9, @@ -169,7 +169,7 @@ void CapsuleTest::withTextureCoords() { {0.5f, 1.0f} }), Container); - CORRADE_COMPARE_AS(*capsule.indices(), (std::vector{ + CORRADE_COMPARE_AS(*capsule.indices(), (std::vector{ 0, 2, 1, 0, 3, 2, 0, 4, 3, 1, 2, 6, 1, 6, 5, 2, 3, 7, 2, 7, 6, 3, 4, 8, 3, 8, 7, 5, 6, 10, 5, 10, 9, 6, 7, 11, 6, 11, 10, 7, 8, 12, 7, 12, 11, diff --git a/src/Primitives/Test/CylinderTest.cpp b/src/Primitives/Test/CylinderTest.cpp index 5e847a984..76cc5562e 100644 --- a/src/Primitives/Test/CylinderTest.cpp +++ b/src/Primitives/Test/CylinderTest.cpp @@ -67,7 +67,7 @@ void CylinderTest::withoutAnything() { {-0.866025f, 0.0f, -0.5f} }), Container); - CORRADE_COMPARE_AS(*cylinder.indices(), (std::vector{ + CORRADE_COMPARE_AS(*cylinder.indices(), (std::vector{ 0, 1, 4, 0, 4, 3, 1, 2, 5, 1, 5, 4, 2, 0, 3, 2, 3, 5, 3, 4, 7, 3, 7, 6, 4, 5, 8, 4, 8, 7, 5, 3, 6, 5, 6, 8 }), Container); @@ -169,7 +169,7 @@ void CylinderTest::withTextureCoordsAndCaps() { {0.5f, 1.0f} }), Container); - CORRADE_COMPARE_AS(*cylinder.indices(), (std::vector{ + CORRADE_COMPARE_AS(*cylinder.indices(), (std::vector{ 0, 2, 1, 0, 3, 2, 0, 4, 3, 1, 2, 6, 1, 6, 5, 2, 3, 7, 2, 7, 6, 3, 4, 8, 3, 8, 7, 5, 6, 10, 5, 10, 9, 6, 7, 11, 6, 11, 10, 7, 8, 12, 7, diff --git a/src/Primitives/Test/UVSphereTest.cpp b/src/Primitives/Test/UVSphereTest.cpp index 494a6f4d0..3ede74162 100644 --- a/src/Primitives/Test/UVSphereTest.cpp +++ b/src/Primitives/Test/UVSphereTest.cpp @@ -67,7 +67,7 @@ void UVSphereTest::withoutTextureCoords() { {0.0f, 1.0f, 0.0f} }), Container); - CORRADE_COMPARE_AS(*sphere.indices(), (std::vector{ + CORRADE_COMPARE_AS(*sphere.indices(), (std::vector{ 0, 2, 1, 0, 3, 2, 0, 1, 3, 1, 2, 5, 1, 5, 4, 2, 3, 6, 2, 6, 5, 3, 1, 4, 3, 4, 6, 4, 5, 7, 5, 6, 7, 6, 4, 7 @@ -109,7 +109,7 @@ void UVSphereTest::withTextureCoords() { {0.5f, 1.0f} }), Container); - CORRADE_COMPARE_AS(*sphere.indices(), (std::vector{ + CORRADE_COMPARE_AS(*sphere.indices(), (std::vector{ 0, 2, 1, 0, 3, 2, 0, 4, 3, 1, 2, 6, 1, 6, 5, 2, 3, 7, 2, 7, 6, 3, 4, 8, 3, 8, 7, 5, 6, 9, 6, 7, 9, 7, 8, 9 diff --git a/src/Primitives/UVSphere.cpp b/src/Primitives/UVSphere.cpp index 0746be437..5e898d9ce 100644 --- a/src/Primitives/UVSphere.cpp +++ b/src/Primitives/UVSphere.cpp @@ -19,10 +19,10 @@ namespace Magnum { namespace Primitives { -UVSphere::UVSphere(std::uint32_t rings, std::uint32_t segments, TextureCoords textureCoords): Capsule(segments, textureCoords) { +UVSphere::UVSphere(UnsignedInt rings, UnsignedInt segments, TextureCoords textureCoords): Capsule(segments, textureCoords) { CORRADE_ASSERT(rings >= 2 && segments >= 3, "UVSphere must have at least two rings and three segments", ); - GLfloat textureCoordsVIncrement = 1.0f/rings; + Float textureCoordsVIncrement = 1.0f/rings; Rad ringAngleIncrement = Rad(Constants::pi())/rings; /* Bottom cap vertex */ diff --git a/src/Primitives/UVSphere.h b/src/Primitives/UVSphere.h index d2cd6400e..b23c6f702 100644 --- a/src/Primitives/UVSphere.h +++ b/src/Primitives/UVSphere.h @@ -42,7 +42,7 @@ class UVSphere: public Capsule { * If texture coordinates are generated, vertices of one segment are * duplicated for texture wrapping. */ - explicit MAGNUM_PRIMITIVES_EXPORT UVSphere(std::uint32_t rings, std::uint32_t segments, TextureCoords textureCoords = TextureCoords::DontGenerate); + explicit MAGNUM_PRIMITIVES_EXPORT UVSphere(UnsignedInt rings, UnsignedInt segments, TextureCoords textureCoords = TextureCoords::DontGenerate); }; }}