[fixed]CPLYMeshFileLoader checks wrong vertex count

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
randomMesh
Posts: 1186
Joined: Fri Dec 29, 2006 12:04 am

[fixed]CPLYMeshFileLoader checks wrong vertex count

Post 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. :)
Last edited by randomMesh on Wed Jan 08, 2020 11:13 am, edited 2 times in total.
"Whoops..."
CuteAlien
Admin
Posts: 9643
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: CPLYMeshFileLoader checks wrong vertex count

Post 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 :-)
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
CuteAlien
Admin
Posts: 9643
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: [fixed]CPLYMeshFileLoader checks wrong vertex count

Post 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 :-)
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply