Cleanup: Make some variables const.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@5854 dfc29bdd-3216-0410-991c-e03cc46cb475
master
cutealien 2019-08-17 17:52:32 +00:00
parent 5ff51c947e
commit 32585c5ed0
12 changed files with 57 additions and 57 deletions

View File

@ -158,7 +158,7 @@ namespace scene
//! Calculate how many geometric primitives are used by this meshbuffer
virtual u32 getPrimitiveCount() const
{
u32 indexCount = getIndexCount();
const u32 indexCount = getIndexCount();
switch (getPrimitiveType())
{
case scene::EPT_POINTS: return indexCount;

View File

@ -503,7 +503,7 @@ namespace video
break;
case ECF_R8G8B8:
{
u8* p = (u8*)data;
const u8* p = (u8*)data;
set(255, p[0],p[1],p[2]);
}
break;

View File

@ -324,8 +324,8 @@ inline const char* fast_atof_move(const char* in, f32& result)
if ( LOCALE_DECIMAL_POINTS.findFirst(*in) >= 0 )
{
const char* afterDecimal = ++in;
f32 decimal = strtof10(in, &afterDecimal);
size_t numDecimals = afterDecimal - in;
const f32 decimal = strtof10(in, &afterDecimal);
const size_t numDecimals = afterDecimal - in;
if (numDecimals < IRR_ATOF_TABLE_SIZE)
{
value += decimal * fast_atof_table[numDecimals];

View File

@ -76,7 +76,7 @@ public:
allocated = new_size;
// copy old data
s32 end = used < new_size ? used : new_size;
const s32 end = used < new_size ? used : new_size;
for (s32 i=0; i<end; ++i)
{

View File

@ -283,8 +283,8 @@ namespace core
// by one integer number. Also works the other way round, an integer of 1 interpreted as float
// is for example the smallest possible float number.
FloatIntUnion32 fa(a);
FloatIntUnion32 fb(b);
const FloatIntUnion32 fa(a);
const FloatIntUnion32 fb(b);
// Different signs, we could maybe get difference to 0, but so close to 0 using epsilons is better.
if ( fa.sign() != fb.sign() )
@ -296,7 +296,7 @@ namespace core
}
// Find the difference in ULPs.
int ulpsDiff = abs_(fa.i- fb.i);
const int ulpsDiff = abs_(fa.i- fb.i);
if (ulpsDiff <= maxUlpDiff)
return true;

View File

@ -686,7 +686,7 @@ public:
return *this;
--used;
u32 len = other.size()+1;
const u32 len = other.size()+1;
if (used + len > allocated)
reallocate(used + len);
@ -1435,7 +1435,7 @@ private:
array = allocator.allocate(new_size); //new T[new_size];
allocated = new_size;
u32 amount = used < new_size ? used : new_size;
const u32 amount = used < new_size ? used : new_size;
for (u32 i=0; i<amount; ++i)
array[i] = old_array[i];
@ -1479,7 +1479,7 @@ What the function does exactly depends on the LC_CTYPE of the current c locale.
\return The number of wide characters written to destination, not including the eventual terminating null character or -1 when conversion failed. */
static inline size_t multibyteToWString(string<wchar_t>& destination, const char* source)
{
u32 s = source ? (u32)strlen(source) : 0;
const u32 s = source ? (u32)strlen(source) : 0;
return multibyteToWString(destination, source, s);
}
@ -1493,7 +1493,7 @@ static size_t multibyteToWString(string<wchar_t>& destination, const char* sourc
#pragma warning(push)
#pragma warning(disable: 4996) // 'mbstowcs': This function or variable may be unsafe. Consider using mbstowcs_s instead.
#endif
size_t written = mbstowcs(destination.array, source, (size_t)sourceSize);
const size_t written = mbstowcs(destination.array, source, (size_t)sourceSize);
#if defined(_MSC_VER)
#pragma warning(pop)
#endif

View File

@ -329,13 +329,13 @@ class line2d
template <>
inline vector2df line2d<irr::f32>::getClosestPoint(const vector2df& point, bool checkOnlySegments) const
{
vector2df c = point - start;
const vector2df c = point - start;
vector2df v = end - start;
f32 d = (f32)v.getLength();
const f32 d = (f32)v.getLength();
if ( d == 0 ) // can't tell much when the line is just a single point
return start;
v /= d;
f32 t = v.dotProduct(c);
const f32 t = v.dotProduct(c);
if ( checkOnlySegments )
{

View File

@ -692,7 +692,7 @@ inline vector3df quaternion::operator* (const vector3df& v) const
// nVidia SDK implementation
vector3df uv, uuv;
vector3df qvec(X, Y, Z);
const vector3df qvec(X, Y, Z);
uv = qvec.crossProduct(v);
uuv = qvec.crossProduct(uv);
uv *= (2.0f * W);

View File

@ -315,7 +315,7 @@ public:
\return An interpolated vector. This vector is not modified. */
vector2d<T> getInterpolated(const vector2d<T>& other, f64 d) const
{
f64 inv = 1.0f - d;
const f64 inv = 1.0f - d;
return vector2d<T>((T)(other.X*inv + X*d), (T)(other.Y*inv + Y*d));
}

View File

@ -1275,7 +1275,7 @@ public:
{
u32 c;
int characters;
int items = sscanf(text, "%08x%n", &c, &characters);
const int items = sscanf(text, "%08x%n", &c, &characters);
if (items != 1 || characters != 8 )
{
CNumbersAttribute::setString(text);
@ -1768,7 +1768,7 @@ public:
virtual void getBinary(void* outdata, s32 maxLength) const _IRR_OVERRIDE_
{
s32 dataSize = maxLength;
const s32 dataSize = maxLength;
c8* datac8 = (c8*)(outdata);
s32 p = 0;
const c8* dataString = Value.c_str();
@ -1790,8 +1790,8 @@ public:
virtual void setBinary(void* data, s32 maxLength) _IRR_OVERRIDE_
{
s32 dataSize = maxLength;
c8* datac8 = (c8*)(data);
const s32 dataSize = maxLength;
const c8* datac8 = (c8*)(data);
char tmp[3];
tmp[2] = 0;
Value = "";
@ -2050,9 +2050,9 @@ public:
case 8:
{
#ifdef _MSC_VER
unsigned __int64 tmp = _strtoui64(text, NULL, 16);
const unsigned __int64 tmp = _strtoui64(text, NULL, 16);
#else
unsigned long long tmp = strtoull(text, NULL, 16);
const unsigned long long tmp = strtoull(text, NULL, 16);
#endif
val = (size_t)tmp;
}

View File

@ -78,7 +78,7 @@ void CAttributes::setAttribute(const c8* attributeName, const c8* value)
//! or 0 if attribute is not set.
core::stringc CAttributes::getAttributeAsString(const c8* attributeName, const core::stringc& defaultNotFound) const
{
IAttribute* att = getAttributeP(attributeName);
const IAttribute* att = getAttributeP(attributeName);
if (att)
return att->getString();
else
@ -90,7 +90,7 @@ core::stringc CAttributes::getAttributeAsString(const c8* attributeName, const c
//! \param target: Buffer where the string is copied to.
void CAttributes::getAttributeAsString(const c8* attributeName, char* target) const
{
IAttribute* att = getAttributeP(attributeName);
const IAttribute* att = getAttributeP(attributeName);
if (att)
{
core::stringc str = att->getString();
@ -146,7 +146,7 @@ void CAttributes::setAttribute(const c8* attributeName, const wchar_t* value)
//! or 0 if attribute is not set.
core::stringw CAttributes::getAttributeAsStringW(const c8* attributeName, const core::stringw& defaultNotFound) const
{
IAttribute* att = getAttributeP(attributeName);
const IAttribute* att = getAttributeP(attributeName);
if (att)
return att->getStringW();
else
@ -158,7 +158,7 @@ core::stringw CAttributes::getAttributeAsStringW(const c8* attributeName, const
//! \param target: Buffer where the string is copied to.
void CAttributes::getAttributeAsStringW(const c8* attributeName, wchar_t* target) const
{
IAttribute* att = getAttributeP(attributeName);
const IAttribute* att = getAttributeP(attributeName);
if (att)
{
core::stringw str = att->getStringW();
@ -201,7 +201,7 @@ void CAttributes::setAttribute(const c8* attributeName, const core::array<core::
//! Gets an attribute as an array of wide strings.
core::array<core::stringw> CAttributes::getAttributeAsArray(const c8* attributeName, const core::array<core::stringw>& defaultNotFound) const
{
IAttribute* att = getAttributeP(attributeName);
const IAttribute* att = getAttributeP(attributeName);
if (att)
return att->getArray();
else
@ -268,7 +268,7 @@ void CAttributes::setAttribute(const c8* attributeName, bool value)
//! or 0 if attribute is not set.
bool CAttributes::getAttributeAsBool(const c8* attributeName, bool defaultNotFound) const
{
IAttribute* att = getAttributeP(attributeName);
const IAttribute* att = getAttributeP(attributeName);
if (att)
return att->getBool();
else
@ -293,7 +293,7 @@ void CAttributes::setAttribute(const c8* attributeName, s32 value)
//! or 0 if attribute is not set.
s32 CAttributes::getAttributeAsInt(const c8* attributeName, irr::s32 defaultNotFound) const
{
IAttribute* att = getAttributeP(attributeName);
const IAttribute* att = getAttributeP(attributeName);
if (att)
return att->getInt();
else
@ -316,7 +316,7 @@ void CAttributes::setAttribute(const c8* attributeName, f32 value)
//! or 0 if attribute is not set.
f32 CAttributes::getAttributeAsFloat(const c8* attributeName, irr::f32 defaultNotFound) const
{
IAttribute* att = getAttributeP(attributeName);
const IAttribute* att = getAttributeP(attributeName);
if (att)
return att->getFloat();
@ -338,7 +338,7 @@ void CAttributes::setAttribute(const c8* attributeName, video::SColor value)
//! \return Returns value of the attribute previously set by setAttribute()
video::SColor CAttributes::getAttributeAsColor(const c8* attributeName, const video::SColor& defaultNotFound) const
{
IAttribute* att = getAttributeP(attributeName);
const IAttribute* att = getAttributeP(attributeName);
if (att)
return att->getColor();
else
@ -360,7 +360,7 @@ void CAttributes::setAttribute(const c8* attributeName, video::SColorf value)
//! \return Returns value of the attribute previously set by setAttribute()
video::SColorf CAttributes::getAttributeAsColorf(const c8* attributeName, const video::SColorf& defaultNotFound) const
{
IAttribute* att = getAttributeP(attributeName);
const IAttribute* att = getAttributeP(attributeName);
if (att)
return att->getColorf();
else
@ -382,7 +382,7 @@ void CAttributes::setAttribute(const c8* attributeName, const core::position2di&
//! \return Returns value of the attribute previously set by setAttribute()
core::position2di CAttributes::getAttributeAsPosition2d(const c8* attributeName, const core::position2di& defaultNotFound) const
{
IAttribute* att = getAttributeP(attributeName);
const IAttribute* att = getAttributeP(attributeName);
if (att)
return att->getPosition();
else
@ -404,7 +404,7 @@ void CAttributes::setAttribute(const c8* attributeName, const core::rect<s32>& v
//! \return Returns value of the attribute previously set by setAttribute()
core::rect<s32> CAttributes::getAttributeAsRect(const c8* attributeName, const core::rect<s32>& defaultNotFound) const
{
IAttribute* att = getAttributeP(attributeName);
const IAttribute* att = getAttributeP(attributeName);
if (att)
return att->getRect();
else
@ -426,7 +426,7 @@ void CAttributes::setAttribute(const c8* attributeName, const core::dimension2d<
//! \return Returns value of the attribute previously set by setAttribute()
core::dimension2d<u32> CAttributes::getAttributeAsDimension2d(const c8* attributeName, const core::dimension2d<u32>& defaultNotFound) const
{
IAttribute* att = getAttributeP(attributeName);
const IAttribute* att = getAttributeP(attributeName);
if (att)
return att->getDimension2d();
else
@ -458,7 +458,7 @@ void CAttributes::setAttribute(const c8* attributeName, const core::vector2df& v
//! \return Returns value of the attribute previously set by setAttribute()
core::vector3df CAttributes::getAttributeAsVector3d(const c8* attributeName, const core::vector3df& defaultNotFound) const
{
IAttribute* att = getAttributeP(attributeName);
const IAttribute* att = getAttributeP(attributeName);
if (att)
return att->getVector();
else
@ -468,7 +468,7 @@ core::vector3df CAttributes::getAttributeAsVector3d(const c8* attributeName, con
//! Gets an attribute as vector
core::vector2df CAttributes::getAttributeAsVector2d(const c8* attributeName, const core::vector2df& defaultNotFound) const
{
IAttribute* att = getAttributeP(attributeName);
const IAttribute* att = getAttributeP(attributeName);
if (att)
return att->getVector2d();
else
@ -489,7 +489,7 @@ void CAttributes::setAttribute(const c8* attributeName, void* data, s32 dataSize
//! \param attributeName: Name of the attribute to get.
void CAttributes::getAttributeAsBinaryData(const c8* attributeName, void* outData, s32 maxSizeInBytes) const
{
IAttribute* att = getAttributeP(attributeName);
const IAttribute* att = getAttributeP(attributeName);
if (att)
att->getBinary(outData, maxSizeInBytes);
}
@ -509,7 +509,7 @@ void CAttributes::setAttribute(const c8* attributeName, const char* enumValue, c
//! \return Returns value of the attribute previously set by setAttribute()
const char* CAttributes::getAttributeAsEnumeration(const c8* attributeName, const c8* defaultNotFound) const
{
IAttribute* att = getAttributeP(attributeName);
const IAttribute* att = getAttributeP(attributeName);
if (att)
return att->getEnum();
else
@ -519,7 +519,7 @@ const char* CAttributes::getAttributeAsEnumeration(const c8* attributeName, cons
//! Gets an attribute as enumeration
s32 CAttributes::getAttributeAsEnumeration(const c8* attributeName, const char* const* enumerationLiteralsToUse, s32 defaultNotFound) const
{
IAttribute* att = getAttributeP(attributeName);
const IAttribute* att = getAttributeP(attributeName);
if (enumerationLiteralsToUse && att)
{
@ -539,7 +539,7 @@ s32 CAttributes::getAttributeAsEnumeration(const c8* attributeName, const char*
//! \param attributeName: Name of the attribute to get.
void CAttributes::getAttributeEnumerationLiteralsOfEnumeration(const c8* attributeName, core::array<core::stringc>& outLiterals) const
{
IAttribute* att = getAttributeP(attributeName);
const IAttribute* att = getAttributeP(attributeName);
if (att && att->getType() == EAT_ENUM)
outLiterals = ((CEnumAttribute*)att)->EnumLiterals;
@ -560,7 +560,7 @@ void CAttributes::setAttribute(const c8* attributeName, video::ITexture* value,
//! \param attributeName: Name of the attribute to get.
video::ITexture* CAttributes::getAttributeAsTexture(const c8* attributeName, video::ITexture* defaultNotFound) const
{
IAttribute* att = getAttributeP(attributeName);
const IAttribute* att = getAttributeP(attributeName);
if (att)
return att->getTexture();
else
@ -599,7 +599,7 @@ E_ATTRIBUTE_TYPE CAttributes::getAttributeType(const c8* attributeName) const
{
E_ATTRIBUTE_TYPE ret = EAT_UNKNOWN;
IAttribute* att = getAttributeP(attributeName);
const IAttribute* att = getAttributeP(attributeName);
if (att)
ret = att->getType();
@ -619,7 +619,7 @@ E_ATTRIBUTE_TYPE CAttributes::getAttributeType(s32 index) const
//! Returns the type of an attribute
const wchar_t* CAttributes::getAttributeTypeString(const c8* attributeName, const wchar_t* defaultNotFound) const
{
IAttribute* att = getAttributeP(attributeName);
const IAttribute* att = getAttributeP(attributeName);
if (att)
return att->getTypeString();
else
@ -766,7 +766,7 @@ s32 CAttributes::getAttributeAsEnumeration(s32 index, const char* const* enumera
{
if ((u32)index < Attributes.size())
{
IAttribute* att = Attributes[index];
const IAttribute* att = Attributes[index];
if (enumerationLiteralsToUse && att)
{
@ -1027,7 +1027,7 @@ void CAttributes::setAttribute(const c8* attributeName, const core::matrix4& v)
//! Gets an attribute as a matrix4
core::matrix4 CAttributes::getAttributeAsMatrix(const c8* attributeName, const core::matrix4& defaultNotFound) const
{
IAttribute* att = getAttributeP(attributeName);
const IAttribute* att = getAttributeP(attributeName);
if (att)
return att->getMatrix();
else
@ -1074,7 +1074,7 @@ void CAttributes::setAttribute(const c8* attributeName, const core::quaternion&
//! Gets an attribute as a quaternion
core::quaternion CAttributes::getAttributeAsQuaternion(const c8* attributeName, const core::quaternion& defaultNotFound) const
{
IAttribute* att = getAttributeP(attributeName);
const IAttribute* att = getAttributeP(attributeName);
if (att)
return att->getQuaternion();
else
@ -1120,7 +1120,7 @@ void CAttributes::setAttribute(const c8* attributeName, const core::aabbox3df& v
//! Gets an attribute as a axis aligned bounding box
core::aabbox3df CAttributes::getAttributeAsBox3d(const c8* attributeName, const core::aabbox3df& defaultNotFound) const
{
IAttribute* att = getAttributeP(attributeName);
const IAttribute* att = getAttributeP(attributeName);
if (att)
return att->getBBox();
else
@ -1166,7 +1166,7 @@ void CAttributes::setAttribute(const c8* attributeName, const core::plane3df& v)
//! Gets an attribute as a 3d plane
core::plane3df CAttributes::getAttributeAsPlane3d(const c8* attributeName, const core::plane3df& defaultNotFound) const
{
IAttribute* att = getAttributeP(attributeName);
const IAttribute* att = getAttributeP(attributeName);
if (att)
return att->getPlane();
else
@ -1212,7 +1212,7 @@ void CAttributes::setAttribute(const c8* attributeName, const core::triangle3df&
//! Gets an attribute as a 3d triangle
core::triangle3df CAttributes::getAttributeAsTriangle3d(const c8* attributeName, const core::triangle3df& defaultNotFound) const
{
IAttribute* att = getAttributeP(attributeName);
const IAttribute* att = getAttributeP(attributeName);
if (att)
return att->getTriangle();
else
@ -1259,7 +1259,7 @@ void CAttributes::setAttribute(const c8* attributeName, const core::line2df& v)
//! Gets an attribute as a 2d line
core::line2df CAttributes::getAttributeAsLine2d(const c8* attributeName, const core::line2df& defaultNotFound) const
{
IAttribute* att = getAttributeP(attributeName);
const IAttribute* att = getAttributeP(attributeName);
if (att)
return att->getLine2d();
else
@ -1305,7 +1305,7 @@ void CAttributes::setAttribute(const c8* attributeName, const core::line3df& v)
//! Gets an attribute as a 3d line
core::line3df CAttributes::getAttributeAsLine3d(const c8* attributeName, const core::line3df& defaultNotFound) const
{
IAttribute* att = getAttributeP(attributeName);
const IAttribute* att = getAttributeP(attributeName);
if (att)
return att->getLine3d();
else
@ -1354,7 +1354,7 @@ void CAttributes::setAttribute(const c8* attributeName, void* userPointer)
//! \param attributeName: Name of the attribute to get.
void* CAttributes::getAttributeAsUserPointer(const c8* attributeName, void* defaultNotFound) const
{
IAttribute* att = getAttributeP(attributeName);
const IAttribute* att = getAttributeP(attributeName);
if (att)
return att->getUserPointer();
else
@ -1427,7 +1427,7 @@ bool CAttributes::read(io::IXMLReader* reader, bool readCurrentElementOnly,
}
void CAttributes::readAttributeFromXML(io::IXMLReader* reader)
void CAttributes::readAttributeFromXML(const io::IXMLReader* reader)
{
#ifdef _IRR_COMPILE_WITH_XML_
core::stringw element = reader->getNodeName();
@ -1557,7 +1557,7 @@ void CAttributes::readAttributeFromXML(io::IXMLReader* reader)
{
core::array<core::stringw> tmpArray;
s32 count = reader->getAttributeValueAsInt(L"count");
const s32 count = reader->getAttributeValueAsInt(L"count");
s32 n=0;
const core::stringw tmpName(L"value");
for (; n<count; ++n)

View File

@ -722,7 +722,7 @@ public:
protected:
void readAttributeFromXML(io::IXMLReader* reader);
void readAttributeFromXML(const io::IXMLReader* reader);
core::array<IAttribute*> Attributes;