- fixed some warnings in OBJ model code.

(This clearly shows that using 'long' as parameters in any interface must be stopped. It is fundamentally unsafe to have a type whose size is not reliable - it's either an int-sized nor a pointer sized value, depending on the platform, and essentially worthless.)
This commit is contained in:
Christoph Oelckers 2018-09-15 12:27:14 +02:00
parent 2d53ad6f10
commit 53ee7cfc7b

View file

@ -54,7 +54,7 @@ bool FOBJModel::Load(const char* fn, int lumpnum, const char* buffer, int length
}
if (nlpos == -1)
{
nlpos = objBuf.Len();
nlpos = (long)objBuf.Len();
}
FString lineStr(objBuf.GetChars() + bpos, nlpos - bpos);
mtlUsages.Push(lineStr);
@ -72,7 +72,7 @@ bool FOBJModel::Load(const char* fn, int lumpnum, const char* buffer, int length
nlpos = objBuf.IndexOf('\n', bpos);
if (nlpos == -1)
{
nlpos = objBuf.Len();
nlpos = (long)objBuf.Len();
}
memcpy(wObjBuf + bpos, mtlUsages[i].GetChars(), nlpos - bpos);
}
@ -384,10 +384,10 @@ void FOBJModel::BuildVertexBuffer(FModelRenderer *renderer)
{
// https://www.khronos.org/opengl/wiki/Calculating_a_Surface_Normal
// Find other sides of triangle
int nextSidx = side + 2;
auto nextSidx = side + 2;
if (nextSidx >= 3) nextSidx -= 3;
int lastSidx = side + 1;
auto lastSidx = side + 1;
if (lastSidx >= 3) lastSidx -= 3;
OBJFaceSide &nextSide = surfaces[i].tris[j].sides[nextSidx];