microsoft / glTF-SDK

glTF-SDK is a C++ Software Development Kit for glTF (GL Transmission Format -https://github.com/KhronosGroup/glTF).
MIT License
542 stars 100 forks source link

Changes - suggestion for the Serialization example #110

Open jimver04 opened 1 year ago

jimver04 commented 1 year ago

In the Serialization example main.cpp

perhaps it worths changing

std::vector indices;
to
std::vector indices;

and

accessorIdIndices = bufferBuilder.AddAccessor(indices, { Microsoft::glTF::TYPE_SCALAR, Microsoft::glTF::COMPONENT_UNSIGNED_SHORT}).id;

to

accessorIdIndices = bufferBuilder.AddAccessor(indices, { Microsoft::glTF::TYPE_SCALAR, Microsoft::glTF::COMPONENT_UNSIGNED_INT}).id;

because it took me days to figure out why it was not working with my data. Some meshes had more than 2^16 vertices and were scrumbled whereas some other meshes were ok.

Best, Dimitrios

bghgary commented 1 year ago

I'm not sure I understand. Why does it make more sense to use a larger index type to store the indices when the smaller type works? Maybe a comment would suffice?

jimver04 commented 1 year ago

Yes a comment would be nice there to point out that these should be changed according to the size of data, i.e. when the number of vertices > 65536

bghgary commented 1 year ago

Please open a PR. I will review and merge.

bghgary commented 11 months ago

Is this still needed?