Reduce warnings in CGeometryCreator::createTorusMesh

Also simplify it a bit.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6224 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
cutealien 2021-06-28 12:22:04 +00:00
parent dfba4bd4e5
commit 28fd5f8a4f

View File

@ -969,8 +969,8 @@ irr::scene::IMesh* CGeometryCreator::createTorusMesh(irr::f32 majorRadius, irr::
for ( irr::u32 major = 0; major < majorLines; ++major) for ( irr::u32 major = 0; major < majorLines; ++major)
{ {
const f32 angleMajor = major*angleStepMajor; const f32 angleMajor = major*angleStepMajor;
const f32 cosMajor = cos(angleMajor); const f32 cosMajor = cosf(angleMajor);
const f32 sinMajor = sin(angleMajor); const f32 sinMajor = sinf(angleMajor);
// points of major circle // points of major circle
const core::vector3df pm(majorRadius*cosMajor, 0.f, majorRadius * sinMajor); const core::vector3df pm(majorRadius*cosMajor, 0.f, majorRadius * sinMajor);
@ -978,15 +978,11 @@ irr::scene::IMesh* CGeometryCreator::createTorusMesh(irr::f32 majorRadius, irr::
for ( irr::u32 minor = 0; minor < minorLines; ++minor) for ( irr::u32 minor = 0; minor < minorLines; ++minor)
{ {
const f32 angleMinor = minor*angleStepMinor; const f32 angleMinor = minor*angleStepMinor;
const f32 cosMinor = cos(angleMinor); const f32 cosMinor = cosf(angleMinor);
core::vector3df p; const core::vector3df n(cosMinor * cosMajor, sinf(angleMinor), cosMinor * sinMajor);
p.X = pm.X + minorRadius * cosMinor * cosMajor;
p.Z = pm.Z + minorRadius * cosMinor * sinMajor;
p.Y = minorRadius * sin(angleMinor);
const core::vector3df n((p-pm)/minorRadius);
const core::vector2df uv(angleMajor/TWO_PI, angleMinor/TWO_PI); const core::vector2df uv(angleMajor/TWO_PI, angleMinor/TWO_PI);
buffer->Vertices.push_back( video::S3DVertex(p, n, color, uv) ); buffer->Vertices.push_back( video::S3DVertex(pm+n*minorRadius, n, color, uv) );
} }
} }