Page 1 of 1

[fixed]CPLYMeshFileLoader checks wrong vertex count

Posted: Wed Jan 08, 2020 7:45 am
by randomMesh
Hi,

i think i have discovered a subtle bug in the CPLYMeshFileLoader.

Code: Select all

 
CDynamicMeshBuffer *mb = new CDynamicMeshBuffer(video::EVT_STANDARD, vertCount > 65565 ? video::EIT_32BIT : video::EIT_16BIT);
 
Shouldn't it check for vertex count > 65536 instead of 65565?

Edit:

CNullDriver checks for

Code: Select all

 
if ((iType==EIT_16BIT) && (vertexCount>65536))
 
and CSoftwareDriver checks for

Code: Select all

 
if (clippedIndices.size() + tClpBuf.size() < 65535)
 
while CTerrainSceneNode checks for

Code: Select all

 
if (numVertices <= 65536)
 
It's quite a mess. :)

Re: CPLYMeshFileLoader checks wrong vertex count

Posted: Wed Jan 08, 2020 10:37 am
by CuteAlien
Thanks - changed to 65535 in svn trunk r6052.
edit: Me stupid, should really be 65536 in this case. Will fix again in the evening.
edit2: Ehm... 65535 it is I think as that's the largest index number and that's what should matter here. So it's wrong in the checks in other places. I'll get back to it later ...
edit3: And I'm back to thinking it's 65536 - as that many vertices fit into index 0-65535. Hehe - I really shouldn't try to do quick fixes before my first coffee :-)

Re: [fixed]CPLYMeshFileLoader checks wrong vertex count

Posted: Wed Jan 08, 2020 11:19 am
by CuteAlien
Still no coffee, but commited once more - this time with 65536.
CSoftwareDriver ... not sure - have to check that one (edit: Yeah, I guess it could do one more, but as I have no test-meshes for this specific case I'm not going to mess with SoftwareDriver).
CTerrainSceneNode should be correct.
What confused me was that the number of vertices for a 16-bit meshbuffer doesn't fit in a 16-bit type. But the index certainly does. And all better than 65565 :-)