-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix problem switching from Uint16 to Uint32 indices for outlining. #8820
Conversation
Thanks for the pull request @kring!
Reviewers, don't forget to make sure that:
|
Sorry, weird edge case here, but the max is 65535 vertices, index numbers 0 through 65534. The last 16-bit value, 65535 (or -1), is reserved as a "primitive restart" value in some APIs and in glTF. So when you reach that value, you must switch to 32-bit indexing. |
Oh interesting, I didn't realize that, @emackey! I think it doesn't actually matter here because WebGL doesn't do primitive restart, and this is Cesium's in-memory representation, not a proper glTF. But it can't hurt to change to avoid possible subtle bugs later. |
Done! |
Like I said, king of glTF edge cases 👑 😄 |
Adding edge outlines usually requires adding new vertices, and when we're using a UNSIGNED_SHORT index buffer and the new vertices push us over 65536 vertices, we need to upgrade to an UNSIGNED_INT index buffer. I had previously added this capability, and wrote tests for it, but didn't have any real-world data to test it with at the time. Unfortunately, that code doesn't actually work, and will corrupt rendering of the model when it's triggered. It was all part of my plan to serve as a good illustration for everyone of the dangers of only writing tests for some code and not actually trying it with real data. 😆
The problem is that
Model
also squirrels away the bufferView'scomponentType
inModelLoadResources.indexBuffersToCreate
and then uses that to create the buffer instead of the accessor'scomponentType
in the glTF. So I'm also helping to illustrate the dangers of denormalization. 👍