raysan5 / raylib

A simple and easy-to-use library to enjoy videogames programming
http://www.raylib.com
zlib License
21.6k stars 2.19k forks source link

Mesh struct layout limits meshes to 64k vertices. (edit: when using indices) #807

Closed sanderboer closed 5 years ago

sanderboer commented 5 years ago

Hi, I am using raylib as a front-end for playing around with the opencascade cad lib. This means to me framerate is secondary to shape fidelity and as such, big meshes (100k+ polys) are not unheard of.

I started noticing that the mesher I wrote worked fine until I hit 64k vertices. I think it is the fact that Mesh uses unsigned short for mesh.indices.

I thought I could be cheeky and just change the struct in rlgl.h and raylib.h (and some usage in models.c) but my meshes are now not rendering, although the app does not crash, which is also weird. Apparently there is some profound opengl voodoo I overlooked and let's be honest, not wanting to submerge myself in opengl sourcery is why I am using raylib to begin with =)

Is there a compelling reason to limit the size of the mesh vertices, I can imagine portability may be impacted perhaps ? Or, also probable, did I bork my mesher ?

thank you for this lib, it is really what I was looking for.

S

sanderboer commented 5 years ago

NB: I refactored my mesher to not use indices, and now vertexCount and triangleCount could be the botleneck; these are int, which could potentially be an issue on platforms where int is 2bytes wide instead of 4 (desktop).

sanderboer commented 5 years ago

fyi here's an example of a generated mesh (90k verts): https://imgur.com/a/QkxtnGM

a3f commented 5 years ago

these are int, which could potentially be an issue on platforms where int is 2bytes wide instead of 4 (desktop).

We don't support any such platforms though.

raysan5 commented 5 years ago

Hey @sanderboer! Indices were set as short due to restrictions on OpenGL ES 2.0 (Android, HTML5, Raspberry Pi). Avoiding indices is the best option, vertex count shouldn't be a problem for static meshes.

Your use of raylib for CAD seems very interesting to me, please, keep me updated with your progress! You can join us at raylib Discord server and show your progress on showcase channel!

lf94 commented 11 months ago

For what it's worth, I've hit this limit too.

Pantong51 commented 11 months ago

Heads up(maybe i'll make a gist or w/e) editing to set indices to an unsigned int instead of short is very easily. I still need to get mesh optimizer to work correctly, i keep screwing up the normal's...