clean up math varsize complaints

This commit is contained in:
AzaezelX 2023-04-27 16:10:04 -05:00
parent 1230d0d280
commit 0ce2da3a23
30 changed files with 61 additions and 56 deletions

View file

@ -1173,7 +1173,7 @@ static bool enumColladaForImport(const char* shapePath, GuiTreeViewCtrl* tree, b
for (S32 i = 0; i < root->getLibrary_materials_array().getCount(); i++)
{
const domLibrary_materials* libraryMats = root->getLibrary_materials_array()[i];
stats.numMaterials += libraryMats->getMaterial_array().getCount();
stats.numMaterials += (S32)libraryMats->getMaterial_array().getCount();
for (S32 j = 0; j < libraryMats->getMaterial_array().getCount(); j++)
{
domMaterial* mat = libraryMats->getMaterial_array()[j];
@ -1267,7 +1267,7 @@ static bool enumColladaForImport(const char* shapePath, GuiTreeViewCtrl* tree, b
for (S32 i = 0; i < root->getLibrary_animation_clips_array().getCount(); i++)
{
const domLibrary_animation_clips* libraryClips = root->getLibrary_animation_clips_array()[i];
stats.numClips += libraryClips->getAnimation_clip_array().getCount();
stats.numClips += (S32)libraryClips->getAnimation_clip_array().getCount();
for (S32 j = 0; j < libraryClips->getAnimation_clip_array().getCount(); j++)
{
domAnimation_clip* clip = libraryClips->getAnimation_clip_array()[j];

View file

@ -1641,7 +1641,7 @@ void TSStatic::onInspect(GuiInspector* inspector)
{
//if (mShapeAsset == nullptr)
return;
/*
//Put the GameObject group before everything that'd be gameobject-effecting, for orginazational purposes
GuiInspectorGroup* materialGroup = inspector->findExistentGroup(StringTable->insert("Materials"));
if (!materialGroup)
@ -1709,6 +1709,7 @@ void TSStatic::onInspect(GuiInspector* inspector)
}
}
}
*/
}
#endif
DefineEngineMethod(TSStatic, getTargetName, const char*, (S32 index), (0),

View file

@ -1556,7 +1556,7 @@ U32 FunctionDeclStmtNode::compileStmt(CodeStream& codeStream, U32 ip)
// map local variables to registers for this function.
// Note we have to map these in order because the table itself is ordered by the register id.
CompilerLocalVariableToRegisterMappingTable* tbl = &getFunctionVariableMappingTable();
for (size_t i = 0; i < gFuncVars->variableNameMap.size(); ++i)
for (S32 i = 0; i < gFuncVars->variableNameMap.size(); ++i)
{
StringTableEntry varName = gFuncVars->variableNameMap[i];
tbl->add(fnName, nameSpace, varName);

View file

@ -615,7 +615,7 @@ ConsoleValue CodeBlock::exec(U32 ip, const char* functionName, Namespace* thisNa
gExecCount++;
#endif
const dsize_t TRACE_BUFFER_SIZE = 1024;
const U32 TRACE_BUFFER_SIZE = 1024;
static char traceBuffer[TRACE_BUFFER_SIZE];
U32 i;
@ -648,12 +648,12 @@ ConsoleValue CodeBlock::exec(U32 ip, const char* functionName, Namespace* thisNa
}
if (thisNamespace && thisNamespace->mName)
{
dSprintf(traceBuffer + dStrlen(traceBuffer), sizeof(traceBuffer) - dStrlen(traceBuffer),
dSprintf(traceBuffer + (U32)dStrlen(traceBuffer), sizeof(traceBuffer) - (U32)dStrlen(traceBuffer),
"%s::%s(", thisNamespace->mName, thisFunctionName);
}
else
{
dSprintf(traceBuffer + dStrlen(traceBuffer), sizeof(traceBuffer) - dStrlen(traceBuffer),
dSprintf(traceBuffer + (U32)dStrlen(traceBuffer), sizeof(traceBuffer) - (U32)dStrlen(traceBuffer),
"%s(", thisFunctionName);
}
for (i = 0; i < wantedArgc; i++)
@ -2317,12 +2317,12 @@ execFinished:
}
if (thisNamespace && thisNamespace->mName)
{
dSprintf(traceBuffer + dStrlen(traceBuffer), sizeof(traceBuffer) - dStrlen(traceBuffer),
dSprintf(traceBuffer + (U32)dStrlen(traceBuffer), sizeof(traceBuffer) - (U32)dStrlen(traceBuffer),
"%s::%s() - return %s", thisNamespace->mName, thisFunctionName, returnValue.getString());
}
else
{
dSprintf(traceBuffer + dStrlen(traceBuffer), sizeof(traceBuffer) - dStrlen(traceBuffer),
dSprintf(traceBuffer + (U32)dStrlen(traceBuffer), sizeof(traceBuffer) - (U32)dStrlen(traceBuffer),
"%s() - return %s", thisFunctionName, returnValue.getString());
}
Con::printf("%s", traceBuffer);

View file

@ -276,7 +276,7 @@ void EngineObject::debugEnumInstances( const char* className, DebugEnumInstances
//-----------------------------------------------------------------------------
void* EngineCRuntimeObjectPool::allocateObject( U32 size TORQUE_TMM_ARGS_DECL )
void* EngineCRuntimeObjectPool::allocateObject(size_t size TORQUE_TMM_ARGS_DECL )
{
#ifdef TORQUE_DISABLE_MEMORY_MANAGER
return dMalloc( size );

View file

@ -456,7 +456,7 @@ class IEngineObjectPool
/// Allocate a new object memory block of the given size.
/// @return Pointer to a new memory block or NULL on failure.
virtual void* allocateObject( U32 size TORQUE_TMM_ARGS_DECL ) = 0;
virtual void* allocateObject( size_t size TORQUE_TMM_ARGS_DECL ) = 0;
/// Return the member for the object at the given address to the
/// allocator for reuse.
@ -485,7 +485,7 @@ class EngineCRuntimeObjectPool : public IEngineObjectPool
static EngineCRuntimeObjectPool* instance() { return &smInstance; }
// IEngineObjectPool
virtual void* allocateObject( U32 size TORQUE_TMM_ARGS_DECL );
virtual void* allocateObject(size_t size TORQUE_TMM_ARGS_DECL );
virtual void freeObject( void* ptr );
};

View file

@ -849,10 +849,10 @@ inline ColorI LinearColorF::toColorI(const bool keepAsLinear)
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));
#else
float r = red < 0.0031308f ? 12.92f * red : 1.055 * 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 b = blue < 0.0031308f ? 12.92f * blue : 1.055 * 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));
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.055f * mPow(green, 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.5f));
#endif
}
}

View file

@ -582,7 +582,7 @@ char* dStristr( char* str1, const char* str2 )
// Slow but at least we have it.
U32 str2len = strlen( str2 );
U64 str2len = (U64)strlen( str2 );
while( *str1 )
{
if( strncasecmp( str1, str2, str2len ) == 0 )

View file

@ -323,7 +323,7 @@ inline U8* GBitmap::getWritableBits(const U32 in_mipLevel)
inline U8* GBitmap::getAddress(const S32 in_x, const S32 in_y, const U32 mipLevel)
{
return (getWritableBits(mipLevel) + ((in_y * getWidth(mipLevel)) + in_x) * mBytesPerPixel);
return (getWritableBits(mipLevel) + (U64)(((in_y * getWidth(mipLevel)) + in_x) * mBytesPerPixel));
}
inline const U8* GBitmap::getAddress(const S32 in_x, const S32 in_y, const U32 mipLevel) const

View file

@ -75,7 +75,7 @@ static void pngReadDataFn(png_structp png_ptr,
AssertFatal(png_get_io_ptr(png_ptr) != NULL, "No stream?");
Stream *strm = (Stream*)png_get_io_ptr(png_ptr);
bool success = strm->read(length, data);
bool success = strm->read((U32)length, data);
AssertFatal(success, "pngReadDataFn - failed to read from stream!");
}
@ -88,7 +88,7 @@ static void pngWriteDataFn(png_structp png_ptr,
AssertFatal(png_get_io_ptr(png_ptr) != NULL, "No stream?");
Stream *strm = (Stream*)png_get_io_ptr(png_ptr);
bool success = strm->write(length, data);
bool success = strm->write((U32)length, data);
AssertFatal(success, "pngWriteDataFn - failed to write to stream!");
}
@ -101,7 +101,7 @@ static void pngFlushDataFn(png_structp /*png_ptr*/)
static png_voidp pngMallocFn(png_structp /*png_ptr*/, png_size_t size)
{
return FrameAllocator::alloc(size);
return FrameAllocator::alloc((U32)size);
}
static void pngFreeFn(png_structp /*png_ptr*/, png_voidp /*mem*/)
@ -265,7 +265,7 @@ static bool sReadPNG(Stream &stream, GBitmap *bitmap)
// above...
png_read_update_info(png_ptr, info_ptr);
png_uint_32 rowBytes = png_get_rowbytes(png_ptr, info_ptr);
png_uint_32 rowBytes = (png_uint_32)png_get_rowbytes(png_ptr, info_ptr);
if (format == GFXFormatR8G8B8)
{
AssertFatal(rowBytes == width * 3,
@ -642,4 +642,4 @@ void DeferredPNGWriter::end()
png_destroy_write_struct(&mData->png_ptr, (png_infopp)NULL);
mActive = false;
}
}

View file

@ -902,7 +902,7 @@ void GuiInspectorTypeCommand::_setCommand( GuiButtonCtrl *ctrl, StringTableEntry
S32 written = dSprintf( szBuffer, len, "%s(\"", mTextEditorCommand );
expandEscape(szBuffer.address() + written, command);
written = strlen(szBuffer);
written = (S32)strlen(szBuffer);
dSprintf( szBuffer.address() + written, len - written, "\", \"%d.apply\", %d.getRoot());", getId(), getId() );
ctrl->setField( "Command", szBuffer );

View file

@ -648,17 +648,17 @@ void GuiConvexEditorCtrl::on3DMouseDragged(const Gui3DMouseEvent & event)
F32 scalar = 1;
mConvexSEL->mSurfaceUVs[mFaceSEL].scale += (Point2F(scale.x, scale.y) * scalar);
if (mConvexSEL->mSurfaceUVs[mFaceSEL].scale.x < 0.01)
mConvexSEL->mSurfaceUVs[mFaceSEL].scale.x = 0.01;
if (mConvexSEL->mSurfaceUVs[mFaceSEL].scale.x < 0.01f)
mConvexSEL->mSurfaceUVs[mFaceSEL].scale.x = 0.01f;
if (mConvexSEL->mSurfaceUVs[mFaceSEL].scale.y < 0.01)
mConvexSEL->mSurfaceUVs[mFaceSEL].scale.y = 0.01;
if (mConvexSEL->mSurfaceUVs[mFaceSEL].scale.y < 0.01f)
mConvexSEL->mSurfaceUVs[mFaceSEL].scale.y = 0.01f;
if (mConvexSEL->mSurfaceUVs[mFaceSEL].scale.x > 100)
mConvexSEL->mSurfaceUVs[mFaceSEL].scale.x = 100;
if (mConvexSEL->mSurfaceUVs[mFaceSEL].scale.x > 100.0f)
mConvexSEL->mSurfaceUVs[mFaceSEL].scale.x = 100.0f;
if (mConvexSEL->mSurfaceUVs[mFaceSEL].scale.y > 100)
mConvexSEL->mSurfaceUVs[mFaceSEL].scale.y = 100;
if (mConvexSEL->mSurfaceUVs[mFaceSEL].scale.y > 100.0f)
mConvexSEL->mSurfaceUVs[mFaceSEL].scale.y = 100.0f;
Point2F test = mConvexSEL->mSurfaceUVs[mFaceSEL].scale;
mConvexSEL->setMaskBits( ConvexShape::UpdateMask );

View file

@ -661,7 +661,7 @@ void Material::_mapMaterial()
mMapTo = mDiffuseMapName[0];
else
// use everything after the last slash
mMapTo = String(mDiffuseMapName[0]).substr(slashPos + 1, strlen(mDiffuseMapName[0]) - slashPos - 1);
mMapTo = String(mDiffuseMapName[0]).substr(slashPos + 1, (U32)strlen(mDiffuseMapName[0]) - slashPos - 1);
}
else if (!mDiffuseMapAsset->isNull())
{

View file

@ -230,7 +230,7 @@ bool ProcessedShaderMaterial::init( const FeatureSet &features,
}
if (mMaterial && mMaterial->mDiffuseMapName[0] != StringTable->EmptyString() && String(mMaterial->mDiffuseMapName[0]).startsWith("#"))
{
String texTargetBufferName = String(mMaterial->mDiffuseMapName[0]).substr(1, strlen(mMaterial->mDiffuseMapName[0]) - 1);
String texTargetBufferName = String(mMaterial->mDiffuseMapName[0]).substr(1, (U32)strlen(mMaterial->mDiffuseMapName[0]) - 1);
NamedTexTarget *texTarget = NamedTexTarget::find(texTargetBufferName);
RenderPassData* rpd = getPass(0);

View file

@ -209,7 +209,7 @@ inline F32 mFmod(const F32 val, const F32 mod)
inline S32 mRound(const F32 val)
{
return (S32)floor(val + 0.5f);
return (S32)floor(F64(val + 0.5f));
}
inline F32 mRound(const F32 val, const S32 n)

View file

@ -915,7 +915,7 @@ inline bool mIsNaN( const Point2F &p )
/// Return negative if p0p1p2 are clockwise
inline F64 mCross(const Point2F &p0, const Point2F &p1, const Point2F &pt2)
{
return (p1.x - p0.x) * (pt2.y - p0.y) - (p1.y - p0.y) * (pt2.x - p0.x);
return F64(p1.x - p0.x) * F64(pt2.y - p0.y) - F64(p1.y - p0.y) * F64(pt2.x - p0.x);
}

View file

@ -53,7 +53,7 @@ void VfsXMLPrinter::Print(const char* format, ...)
void VfsXMLPrinter::Write(const char* data, size_t size)
{
m_Stream.write(size, data);
m_Stream.write((U32)size, data);
}
void VfsXMLPrinter::Putc(char ch)
@ -250,12 +250,12 @@ void VfsXMLDocument::SetError(tinyxml2::XMLError error, int lineNum, const char*
if (format) {
size_t len = strlen(buffer);
dSprintf(buffer + len, BUFFER_SIZE - len, ": ");
dSprintf(buffer + len, (U32)(BUFFER_SIZE - len), ": ");
len = strlen(buffer);
va_list va;
va_start(va, format);
dSprintf(buffer + len, BUFFER_SIZE - len, format, va);
dSprintf(buffer + len, (U32)(BUFFER_SIZE - len), format, va);
va_end(va);
}
_errorStr.SetStr(buffer);

View file

@ -295,7 +295,7 @@ bool FileDialog::Execute()
else if (mData.mStyle & FileDialogData::FDS_MULTIPLEFILES)
{
//check if we have multiple files actually selected or not
U32 fileCount = NFD_PathSet_GetCount(&pathSet);
U32 fileCount = (U32)NFD_PathSet_GetCount(&pathSet);
if (fileCount > 1)
{
//yep, so parse through them and prep our return

View file

@ -37,6 +37,7 @@ struct _FlagMap
U32 flag;
};
#ifndef TORQUE_SDL
static _FlagMap sgButtonMap[] =
{
{ MBOk, MB_OK },
@ -65,7 +66,7 @@ static _FlagMap sgMsgBoxRetMap[] =
{ IDYES, MROk },
{ 0xffffffff, 0xffffffff }
};
#endif
//-----------------------------------------------------------------------------
static U32 getMaskFromID(_FlagMap *map, S32 id)

View file

@ -147,7 +147,7 @@ void WinConsole::printf(const char *s, ...)
// Axe the color characters.
Con::stripColorChars(buffer);
// Print it.
WriteFile(stdOut, buffer, strlen(buffer), &bytes, NULL);
WriteFile(stdOut, buffer, (U32)strlen(buffer), &bytes, NULL);
FlushFileBuffers( stdOut );
}

View file

@ -59,7 +59,7 @@ void Platform::outputDebugString( const char *string, ... )
// twice as in a multi-threaded environment, some other thread may output some
// stuff in between the two calls.
U32 length = strlen( buffer );
U32 length = (U32)strlen( buffer );
if( length == ( sizeof( buffer ) - 1 ) )
length --;

View file

@ -85,12 +85,12 @@ size_t SFXVorbisStream::_read_func( void *ptr, size_t size, size_t nmemb, void *
// Stream::read() returns true if any data was
// read, so we must track the read bytes ourselves.
U32 startByte = stream->getPosition();
stream->read( size * nmemb, ptr );
stream->read((U32)(size * nmemb), ptr );
U32 endByte = stream->getPosition();
// How many did we actually read?
U32 readBytes = ( endByte - startByte );
U32 readItems = readBytes / size;
U32 readItems = (U32)(readBytes / size);
return readItems;
}

View file

@ -115,7 +115,7 @@ void TerrainFile::_buildGridMap()
for ( S32 i = mGridLevels; i >= 0; i-- )
{
mGridMap[i] = grid;
grid += 1 << ( 2 * ( mGridLevels - i ) );
grid += (U64)1 << (U64)( 2 * ( mGridLevels - i ) );
}
for( S32 i = mGridLevels; i >= 0; i-- )

View file

@ -427,6 +427,7 @@ bool AssimpShapeLoader::fillGuiTreeView(const char* sourceShapePath, GuiTreeView
void AssimpShapeLoader::updateMaterialsScript(const Torque::Path &path)
{
return;
/*
Torque::Path scriptPath(path);
scriptPath.setFileName("materials");
scriptPath.setExtension(TORQUE_SCRIPT_EXTENSION);
@ -460,6 +461,7 @@ void AssimpShapeLoader::updateMaterialsScript(const Torque::Path &path)
return;
persistMgr.saveDirty();
*/
}
/// Check if an up-to-date cached DTS is available for this DAE file

View file

@ -512,7 +512,7 @@ void ColladaAppMesh::getPrimitives(const domGeometry* geometry)
if (!pTriData)
continue;
U32 numTriangles = pTriData->getCount() / meshPrims[iPrim]->getStride() / 3;
U32 numTriangles = (U32)(pTriData->getCount() / meshPrims[iPrim]->getStride() / 3);
if (!numTriangles)
continue;

View file

@ -195,8 +195,8 @@ DefineEngineFunction( enumColladaForImport, bool, (const char * shapePath, const
for (S32 i = 0; i < root->getLibrary_materials_array().getCount(); i++)
{
const domLibrary_materials* libraryMats = root->getLibrary_materials_array()[i];
stats.numMaterials += libraryMats->getMaterial_array().getCount();
for (S32 j = 0; j < libraryMats->getMaterial_array().getCount(); j++)
stats.numMaterials += (S32)libraryMats->getMaterial_array().getCount();
for (S32 j = 0; j < (S32)libraryMats->getMaterial_array().getCount(); j++)
{
domMaterial* mat = libraryMats->getMaterial_array()[j];
tree->insertItem(matsID, _GetNameOrId(mat), "", "", 0, 0);
@ -225,7 +225,7 @@ DefineEngineFunction( enumColladaForImport, bool, (const char * shapePath, const
for (S32 i = 0; i < root->getLibrary_animation_clips_array().getCount(); i++)
{
const domLibrary_animation_clips* libraryClips = root->getLibrary_animation_clips_array()[i];
stats.numClips += libraryClips->getAnimation_clip_array().getCount();
stats.numClips += (S32)libraryClips->getAnimation_clip_array().getCount();
for (S32 j = 0; j < libraryClips->getAnimation_clip_array().getCount(); j++)
{
domAnimation_clip* clip = libraryClips->getAnimation_clip_array()[j];

View file

@ -462,7 +462,7 @@ void updateMaterialsScript(const Torque::Path &path, bool copyTextures = false)
#endif
return;
/*
Torque::Path scriptPath(path);
scriptPath.setFileName("materials");
scriptPath.setExtension(TORQUE_SCRIPT_EXTENSION);
@ -510,6 +510,7 @@ void updateMaterialsScript(const Torque::Path &path, bool copyTextures = false)
}
persistMgr.saveDirty();
*/
}
//-----------------------------------------------------------------------------

View file

@ -831,7 +831,7 @@ template<> inline const domListOfUInts *ColladaPrimitive<domPolylist>::getTriang
pSrcData += stride;
for (S32 iTri = 0; iTri < vcount[iPoly]-2; iTri++) {
pTriangleData->appendArray(stride, v0);
pTriangleData->appendArray(stride*2, pSrcData);
pTriangleData->appendArray((U64)(stride*2), pSrcData);
pSrcData += stride;
}
pSrcData += stride;