diff --git a/changes.txt b/changes.txt index 0000a6de..d851b6af 100644 --- a/changes.txt +++ b/changes.txt @@ -1,6 +1,9 @@ -------------------------- Changes in 1.9 (not yet released) +- createCylinderMesh and createConeMesh in GeometryCreator tessellation numbers now for full instead of semi-circle. + Double your tessellation numbers to get same results as in 1.8 + Sorry had to break as old solution didn't allow for odd numbers. Also was documented otherwise, so was a bug. - Change in UV's for top/bottom center vertex in CGeometryCreator::createCylinderMesh - Add some default UV's in CGeometryCreator::createConeMesh - Bugfix: CTriangleSelector::getTriangles with bounding-box parameter no longer ignores an additionally passed matrix transformation in the box check diff --git a/include/IGeometryCreator.h b/include/IGeometryCreator.h index 5e411432..aa2e1c2f 100644 --- a/include/IGeometryCreator.h +++ b/include/IGeometryCreator.h @@ -135,8 +135,8 @@ public: //! Create an arrow mesh, composed of a cylinder and a cone. /** - \param tessellationCylinder Number of quads composing half the cylinder. - \param tessellationCone Number of triangles composing half the cone's roof. + \param tessellationCylinder Number of quads composing the cylinder. + \param tessellationCone Number of triangles composing the cone's roof. \param height Total height of the arrow \param cylinderHeight Total height of the cylinder, should be lesser than total height @@ -147,8 +147,8 @@ public: \param colorCone color of the cone \return Generated mesh. */ - virtual IMesh* createArrowMesh(const u32 tessellationCylinder = 4, - const u32 tessellationCone = 8, const f32 height = 1.f, + virtual IMesh* createArrowMesh(const u32 tessellationCylinder = 16, + const u32 tessellationCone = 16, const f32 height = 1.f, const f32 cylinderHeight = 0.6f, const f32 widthCylinder = 0.05f, const f32 widthCone = 0.3f, const video::SColor colorCylinder = 0xFFFFFFFF, const video::SColor colorCone = 0xFFFFFFFF) const =0; @@ -168,7 +168,7 @@ public: /** \param radius Radius of the cylinder. \param length Length of the cylinder. - \param tessellation Number of quads around half the circumference of the cylinder. + \param tessellation Number of quads around the circumference of the cylinder. \param color The color of the cylinder. \param closeTop If true, close the ends of the cylinder, otherwise leave them open. \param oblique X-offset (shear) of top compared to bottom. @@ -191,7 +191,7 @@ public: /** \param radius Radius of the cone. \param length Length of the cone. - \param tessellation Number of triangles around half the circumference of the cone. + \param tessellation Number of triangles around the circumference of the cone. \param colorTop The color of the top of the cone. \param colorBottom The color of the bottom of the cone. \param oblique (to be documented) diff --git a/source/Irrlicht/CGeometryCreator.cpp b/source/Irrlicht/CGeometryCreator.cpp index 8aa12ba9..eb6e772d 100644 --- a/source/Irrlicht/CGeometryCreator.cpp +++ b/source/Irrlicht/CGeometryCreator.cpp @@ -748,16 +748,17 @@ IMesh* CGeometryCreator::createCylinderMesh(f32 radius, f32 length, { SMeshBuffer* buffer = new SMeshBuffer(); + if ( tessellation < 2 ) + tessellation = 2; + const f32 recTessellation = core::reciprocal((f32)tessellation); - const f32 recTessellationHalf = recTessellation * 0.5f; const f32 angleStep = (core::PI * 2.f ) * recTessellation; - const f32 angleStepHalf = angleStep*0.5f; u32 i; video::S3DVertex v; v.Color = color; - buffer->Vertices.reallocate(tessellation*4+4+(closeTop?2:1)); - buffer->Indices.reallocate((tessellation*2+1)*(closeTop?12:9)); + buffer->Vertices.reallocate(tessellation*2+2+(closeTop?2:1)); + buffer->Indices.reallocate(tessellation*(closeTop?12:9)); f32 tcx = 0.f; for ( i = 0; i <= tessellation; ++i ) { @@ -775,30 +776,6 @@ IMesh* CGeometryCreator::createCylinderMesh(f32 radius, f32 length, v.TCoords.Y=0.f; buffer->Vertices.push_back(v); - v.Pos.X += oblique; - v.Pos.Y = length; - switch (normalType) - { - case 0: v.Normal = v.Pos; break; - case 1: v.Normal = core::vector3df(v.Pos.X-oblique, 0, v.Pos.Z); break; - } - v.Normal.normalize(); - v.TCoords.Y=1.f; - buffer->Vertices.push_back(v); - - v.Pos.X = radius * cosf(angle + angleStepHalf); - v.Pos.Y = 0.f; - v.Pos.Z = radius * sinf(angle + angleStepHalf); - switch (normalType) - { - case 0: v.Normal = v.Pos; break; - case 1: v.Normal = v.Pos; break; - } - v.Normal.normalize(); - v.TCoords.X=tcx+recTessellationHalf; - v.TCoords.Y=0.f; - buffer->Vertices.push_back(v); - v.Pos.X += oblique; v.Pos.Y = length; switch (normalType) @@ -812,8 +789,7 @@ IMesh* CGeometryCreator::createCylinderMesh(f32 radius, f32 length, tcx += recTessellation; } - // indices for the main hull part - const u32 nonWrappedSize = tessellation* 4; + const u32 nonWrappedSize = tessellation*2; for (i=0; i != nonWrappedSize; i += 2) { buffer->Indices.push_back(i + 2); @@ -825,15 +801,6 @@ IMesh* CGeometryCreator::createCylinderMesh(f32 radius, f32 length, buffer->Indices.push_back(i + 3); } - // two closing quads between end and start - buffer->Indices.push_back(0); - buffer->Indices.push_back(i + 0); - buffer->Indices.push_back(i + 1); - - buffer->Indices.push_back(0); - buffer->Indices.push_back(i + 1); - buffer->Indices.push_back(1); - // close down v.Pos.X = 0.f; v.Pos.Y = 0.f; @@ -854,10 +821,6 @@ IMesh* CGeometryCreator::createCylinderMesh(f32 radius, f32 length, buffer->Indices.push_back(i + 2); } - buffer->Indices.push_back(index); - buffer->Indices.push_back(i + 0); - buffer->Indices.push_back(0); - if (closeTop) { // close top @@ -879,10 +842,6 @@ IMesh* CGeometryCreator::createCylinderMesh(f32 radius, f32 length, buffer->Indices.push_back(index); buffer->Indices.push_back(i + 3); } - - buffer->Indices.push_back(i + 1); - buffer->Indices.push_back(index); - buffer->Indices.push_back(1); } buffer->recalculateBoundingBox(); @@ -903,10 +862,6 @@ IMesh* CGeometryCreator::createConeMesh(f32 radius, f32 length, u32 tessellation { SMeshBuffer* buffer = new SMeshBuffer(); - // TODO: For backward compatibility tessellation is per semi-circle - // We probably need another parameter to allow odd numbered tesselation without breaking existing code :-( - if ( tessellation > 0 ) - tessellation = 2*tessellation; if ( tessellation < 2 ) tessellation = 2; diff --git a/tests/media/Burning's Video-testGeometryCreator.png b/tests/media/Burning's Video-testGeometryCreator.png index 99866377..c1f3a339 100644 Binary files a/tests/media/Burning's Video-testGeometryCreator.png and b/tests/media/Burning's Video-testGeometryCreator.png differ diff --git a/tests/tests-last-passed-at.txt b/tests/tests-last-passed-at.txt index 5109c5ce..b43c0c91 100644 --- a/tests/tests-last-passed-at.txt +++ b/tests/tests-last-passed-at.txt @@ -1,4 +1,4 @@ Tests finished. 72 tests of 72 passed. Compiled as DEBUG -Test suite pass at GMT Wed Dec 13 16:04:52 2023 +Test suite pass at GMT Sun Dec 31 17:50:49 2023