Minor code cleanup

Mostly const fixes in headers to make it easier for users to have more warnings enabled in static code analysis
Also updating our own rules a bit (kicking some out we won't need yet).

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6583 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
cutealien
2024-01-01 15:29:28 +00:00
parent 2fdb1fc156
commit bff1a50c34
14 changed files with 53 additions and 59 deletions

View File

@ -239,10 +239,8 @@ IMesh* CGeometryCreator::createHillPlaneMesh(
vtx.Color.set(255,255,255,255);
// create vertices from left-front to right-back
u32 x;
f32 sx=0.f, tsx=0.f;
for (x=0; x<tileCount.Width; ++x)
for (u32 x=0; x<tileCount.Width; ++x)
{
f32 sy=0.f, tsy=0.f;
for (u32 y=0; y<tileCount.Height; ++y)
@ -265,7 +263,7 @@ IMesh* CGeometryCreator::createHillPlaneMesh(
// create indices
for (x=0; x<tileCount.Width-1; ++x)
for (u32 x=0; x<tileCount.Width-1; ++x)
{
for (u32 y=0; y<tileCount.Height-1; ++y)
{
@ -499,13 +497,13 @@ IMesh* CGeometryCreator::createTerrainMesh(video::IImage* texture,
if (buffer->Vertices.size())
{
c8 textureName[64];
// create texture for this block
video::IImage* img = driver->createImage(texture->getColorFormat(), core::dimension2d<u32>(core::floor32(blockSize.Width*thRel.X), core::floor32(blockSize.Height*thRel.Y)));
texture->copyTo(img, core::position2di(0,0), core::recti(
core::position2d<s32>(core::floor32(processed.X*thRel.X), core::floor32(processed.Y*thRel.Y)),
core::dimension2d<u32>(core::floor32(blockSize.Width*thRel.X), core::floor32(blockSize.Height*thRel.Y))), 0);
c8 textureName[64];
sprintf(textureName, "terrain%u_%u", tm, mesh->getMeshBufferCount());
buffer->Material.setTexture(0, driver->addTexture(textureName, img));
@ -665,7 +663,6 @@ IMesh* CGeometryCreator::createSphereMesh(f32 radius, u32 polyCountX, u32 polyCo
const f64 AngleY = core::PI / polyCountY;
u32 i=0;
f64 axz;
// we don't start at 0.
@ -676,7 +673,7 @@ IMesh* CGeometryCreator::createSphereMesh(f32 radius, u32 polyCountX, u32 polyCo
{
ay += AngleY;
const f64 sinay = sin(ay);
axz = 0;
f64 axz = 0;
// calculate the necessary vertices without the doubled one
for (u32 xz = 0;xz < polyCountX; ++xz)
@ -754,13 +751,12 @@ IMesh* CGeometryCreator::createCylinderMesh(f32 radius, f32 length,
const f32 recTessellation = core::reciprocal((f32)tessellation);
const f32 angleStep = (core::PI * 2.f ) * recTessellation;
u32 i;
video::S3DVertex v;
v.Color = color;
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 )
for (u32 i = 0; i <= tessellation; ++i )
{
const f32 angle = angleStep * i;
v.Pos.X = radius * cosf(angle);
@ -790,7 +786,7 @@ IMesh* CGeometryCreator::createCylinderMesh(f32 radius, f32 length,
}
const u32 nonWrappedSize = tessellation*2;
for (i=0; i != nonWrappedSize; i += 2)
for (u32 i=0; i != nonWrappedSize; i += 2)
{
buffer->Indices.push_back(i + 2);
buffer->Indices.push_back(i + 0);
@ -814,7 +810,7 @@ IMesh* CGeometryCreator::createCylinderMesh(f32 radius, f32 length,
u32 index = buffer->Vertices.size() - 1;
for ( i = 0; i != nonWrappedSize; i += 2 )
for (u32 i = 0; i != nonWrappedSize; i += 2 )
{
buffer->Indices.push_back(index);
buffer->Indices.push_back(i + 0);
@ -836,7 +832,7 @@ IMesh* CGeometryCreator::createCylinderMesh(f32 radius, f32 length,
index = buffer->Vertices.size() - 1;
for ( i = 0; i != nonWrappedSize; i += 2 )
for (u32 i = 0; i != nonWrappedSize; i += 2 )
{
buffer->Indices.push_back(i + 1);
buffer->Indices.push_back(index);
@ -988,8 +984,8 @@ irr::scene::IMesh* CGeometryCreator::createTorusMesh(irr::f32 majorRadius, irr::
core::swap(angleStart, angleEnd);
const f32 radStart = angleStart * core::DEGTORAD;
const f32 radEnd = angleEnd * core::DEGTORAD;
const f32 radMajor = radEnd-radStart;
const f32 radStepMajor = radMajor / majorSegments;
const f32 radMajorLen = radEnd-radStart;
const f32 radStepMajor = radMajorLen / majorSegments;
const f32 TWO_PI = 2.f*core::PI;
const f32 radStepMinor = TWO_PI / minorSegments;

View File

@ -197,7 +197,6 @@ IMeshBuffer* CIrrMeshFileLoader::readMeshBuffer(io::IXMLReader* reader)
if (vertexTypeName1 == vertexType)
{
buffer = new CDynamicMeshBuffer(irr::video::EVT_STANDARD, itype);
}
else
if (vertexTypeName2 == vertexType)
@ -209,8 +208,11 @@ IMeshBuffer* CIrrMeshFileLoader::readMeshBuffer(io::IXMLReader* reader)
{
buffer = new CDynamicMeshBuffer(irr::video::EVT_TANGENTS, itype);
}
buffer->getVertexBuffer().reallocate(vertexCount);
buffer->Material = material;
if ( buffer )
{
buffer->getVertexBuffer().reallocate(vertexCount);
buffer->Material = material;
}
}
else
if (indicesSectionName == nodeName)

View File

@ -247,6 +247,7 @@
<Rule Id="C26432" Action="None" />
<Rule Id="C26435" Action="None" />
<Rule Id="C26438" Action="None" />
<Rule Id="C26439" Action="None" />
<Rule Id="C26440" Action="None" />
<Rule Id="C26443" Action="None" />
<Rule Id="C26444" Action="None" />
@ -257,6 +258,7 @@
<Rule Id="C26449" Action="None" />
<Rule Id="C26451" Action="None" />
<Rule Id="C26455" Action="None" />
<Rule Id="C26458" Action="None" />
<Rule Id="C26459" Action="None" />
<Rule Id="C26461" Action="None" />
<Rule Id="C26466" Action="None" />
@ -274,6 +276,7 @@
<Rule Id="C26496" Action="Warning" />
<Rule Id="C26497" Action="None" />
<Rule Id="C26814" Action="None" />
<Rule Id="C26821" Action="None" />
<Rule Id="C28204" Action="None" />
<Rule Id="C28205" Action="None" />
<Rule Id="C28209" Action="None" />

View File

@ -162,7 +162,7 @@
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='SDL-Debug|Win32'">true</LinkIncremental>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='SDL-Debug|x64'">true</LinkIncremental>
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Irrlicht.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
@ -180,7 +180,7 @@
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='SDL-Debug|Win32'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='SDL-Debug|x64'" />
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Static lib - Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Static lib - Debug|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Static lib - Debug|x64'">Irrlicht.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Static lib - Debug|Win32'" />
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Static lib - Debug|x64'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Static lib - Debug|Win32'" />

View File

@ -1438,12 +1438,6 @@
<ClInclude Include="..\..\include\EDeviceTypes.h">
<Filter>include</Filter>
</ClInclude>
<ClInclude Include="..\..\include\EMeshBufferTypes.h">
<Filter>include\scene</Filter>
</ClInclude>
<ClInclude Include="..\..\include\ESceneNodeUpdateAbs.h">
<Filter>include\scene</Filter>
</ClInclude>
<ClInclude Include="CBufferRenderNode.h">
<Filter>Irrlicht\scene\sceneNodes</Filter>
</ClInclude>