mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-15 16:44:36 +00:00
more arithmetic overflow warns
(cherry picked from commit 3974775b9c6bc49fba7295dcdd35e8f2cc06a0c9)
This commit is contained in:
parent
0ce2da3a23
commit
e386a360ca
5 changed files with 15 additions and 15 deletions
|
|
@ -873,10 +873,10 @@ inline ColorI LinearColorF::toColorI(const bool keepAsLinear)
|
||||||
float b = mPow(blue, gOneOverGamma);
|
float b = mPow(blue, gOneOverGamma);
|
||||||
return ColorI(U8(r * 255.0f + 0.5), U8(g * 255.0f + 0.5), U8(b * 255.0f + 0.5), U8(alpha * 255.0f + 0.5));
|
return ColorI(U8(r * 255.0f + 0.5), U8(g * 255.0f + 0.5), U8(b * 255.0f + 0.5), U8(alpha * 255.0f + 0.5));
|
||||||
#else
|
#else
|
||||||
float r = red < 0.0031308f ? 12.92f * red : 1.055 * mPow(red, 1.0f / 2.4f) - 0.055f;
|
float r = red < 0.0031308f ? 12.92f * red : 1.055f * mPow(red, 1.0f / 2.4f) - 0.055f;
|
||||||
float g = green < 0.0031308f ? 12.92f * green : 1.055 * mPow(green, 1.0f / 2.4f) - 0.055f;
|
float g = green < 0.0031308f ? 12.92f * green : 1.055f * mPow(green, 1.0f / 2.4f) - 0.055f;
|
||||||
float b = blue < 0.0031308f ? 12.92f * blue : 1.055 * mPow(blue, 1.0f / 2.4f) - 0.055f;
|
float b = blue < 0.0031308f ? 12.92f * blue : 1.055f * mPow(blue, 1.0f / 2.4f) - 0.055f;
|
||||||
return ColorI(U8(r * 255.0f + 0.5), U8(g * 255.0f + 0.5), U8(b * 255.0f + 0.5), U8(alpha * 255.0f + 0.5));
|
return ColorI(U8(r * 255.0f + 0.5f), U8(g * 255.0f + 0.5f), U8(b * 255.0f + 0.5f), U8(alpha * 255.0f + 0.5f));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -209,7 +209,7 @@ inline F32 mFmod(const F32 val, const F32 mod)
|
||||||
|
|
||||||
inline S32 mRound(const F32 val)
|
inline S32 mRound(const F32 val)
|
||||||
{
|
{
|
||||||
return (S32)floor(F64(val + 0.5f));
|
return (S32)floor(val + 0.5f);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline F32 mRound(const F32 val, const S32 n)
|
inline F32 mRound(const F32 val, const S32 n)
|
||||||
|
|
|
||||||
|
|
@ -915,7 +915,7 @@ inline bool mIsNaN( const Point2F &p )
|
||||||
/// Return negative if p0p1p2 are clockwise
|
/// Return negative if p0p1p2 are clockwise
|
||||||
inline F64 mCross(const Point2F &p0, const Point2F &p1, const Point2F &pt2)
|
inline F64 mCross(const Point2F &p0, const Point2F &p1, const Point2F &pt2)
|
||||||
{
|
{
|
||||||
return F64(p1.x - p0.x) * F64(pt2.y - p0.y) - F64(p1.y - p0.y) * F64(pt2.x - p0.x);
|
return F64((p1.x - p0.x) * (pt2.y - p0.y) - (p1.y - p0.y) * (pt2.x - p0.x));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -201,7 +201,7 @@ inline TerrainSquare* TerrainFile::findSquare( U32 level, U32 x, U32 y ) const
|
||||||
x >>= level;
|
x >>= level;
|
||||||
y >>= level;
|
y >>= level;
|
||||||
|
|
||||||
return mGridMap[level] + x + ( y << ( mGridLevels - level ) );
|
return mGridMap[level] + x + U64( y << U32( mGridLevels - level ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void TerrainFile::setHeight( U32 x, U32 y, U16 height )
|
inline void TerrainFile::setHeight( U32 x, U32 y, U16 height )
|
||||||
|
|
|
||||||
|
|
@ -527,7 +527,7 @@ public:
|
||||||
{
|
{
|
||||||
if ((index >= 0) && (index < size())) {
|
if ((index >= 0) && (index < size())) {
|
||||||
if (source->getFloat_array())
|
if (source->getFloat_array())
|
||||||
return &source->getFloat_array()->getValue()[index*stride()];
|
return &source->getFloat_array()->getValue()[(U64)(index*stride())];
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -541,9 +541,9 @@ public:
|
||||||
if ((index >= 0) && (index < size())) {
|
if ((index >= 0) && (index < size())) {
|
||||||
// could be plain strings or IDREFs
|
// could be plain strings or IDREFs
|
||||||
if (source->getName_array())
|
if (source->getName_array())
|
||||||
return source->getName_array()->getValue()[index*stride()];
|
return source->getName_array()->getValue()[(U64)(index*stride())];
|
||||||
else if (source->getIDREF_array())
|
else if (source->getIDREF_array())
|
||||||
return source->getIDREF_array()->getValue()[index*stride()].getID();
|
return source->getIDREF_array()->getValue()[(U64)(index*stride())].getID();
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
@ -708,7 +708,7 @@ template<> inline const domListOfUInts *ColladaPrimitive<domTristrips>::getTrian
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
domUint* pSrcData = &(P->getValue()[0]);
|
domUint* pSrcData = &(P->getValue()[0]);
|
||||||
size_t numTriangles = (P->getValue().getCount() / stride) - 2;
|
U64 numTriangles = (P->getValue().getCount() / stride) - 2;
|
||||||
|
|
||||||
// Convert the strip back to a triangle list
|
// Convert the strip back to a triangle list
|
||||||
domUint* v0 = pSrcData;
|
domUint* v0 = pSrcData;
|
||||||
|
|
@ -723,7 +723,7 @@ template<> inline const domListOfUInts *ColladaPrimitive<domTristrips>::getTrian
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// CCW triangle
|
// CCW triangle
|
||||||
pTriangleData->appendArray(stride*3, v0);
|
pTriangleData->appendArray((U64)(stride*3), v0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -749,7 +749,7 @@ template<> inline const domListOfUInts *ColladaPrimitive<domTrifans>::getTriangl
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
domUint* pSrcData = &(P->getValue()[0]);
|
domUint* pSrcData = &(P->getValue()[0]);
|
||||||
size_t numTriangles = (P->getValue().getCount() / stride) - 2;
|
U64 numTriangles = (P->getValue().getCount() / stride) - 2;
|
||||||
|
|
||||||
// Convert the fan back to a triangle list
|
// Convert the fan back to a triangle list
|
||||||
domUint* v0 = pSrcData + stride;
|
domUint* v0 = pSrcData + stride;
|
||||||
|
|
@ -781,7 +781,7 @@ template<> inline const domListOfUInts *ColladaPrimitive<domPolygons>::getTriang
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
domUint* pSrcData = &(P->getValue()[0]);
|
domUint* pSrcData = &(P->getValue()[0]);
|
||||||
size_t numPoints = P->getValue().getCount() / stride;
|
U64 numPoints = P->getValue().getCount() / stride;
|
||||||
|
|
||||||
// Use a simple tri-fan (centered at the first point) method of
|
// Use a simple tri-fan (centered at the first point) method of
|
||||||
// converting the polygon to triangles.
|
// converting the polygon to triangles.
|
||||||
|
|
@ -789,7 +789,7 @@ template<> inline const domListOfUInts *ColladaPrimitive<domPolygons>::getTriang
|
||||||
pSrcData += stride;
|
pSrcData += stride;
|
||||||
for (S32 iTri = 0; iTri < numPoints-2; iTri++) {
|
for (S32 iTri = 0; iTri < numPoints-2; iTri++) {
|
||||||
pTriangleData->appendArray(stride, v0);
|
pTriangleData->appendArray(stride, v0);
|
||||||
pTriangleData->appendArray(stride*2, pSrcData);
|
pTriangleData->appendArray((U64)(stride*2), pSrcData);
|
||||||
pSrcData += stride;
|
pSrcData += stride;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue