-
Notifications
You must be signed in to change notification settings - Fork 47
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
Loading reorders vertices even though I did not use the reorder flag #61
Comments
Hi @w1th0utnam3 , thanks for opening this issue! Yes, this re-ordering behavior is expected, and is different from what the library "no reordering" means. So, maybe we should update the docs about this. When you load an OBJ file, each mesh in the file gets its own set of compact positions, indices, etc., because they are built individually when we encounter the The "no reordering" flag only effects this step, that it should export the faces without duplicating or shuffling vertices to produce vertices that use a single index to refer to all attributes. It sounds like the behavior you're looking for is to load the vertex/index/etc data into a single buffer that is referenced by all meshes, essentially a 1:1 mapping of the OBJ file content to the loaded data. Since I wrote this library tinyobjloader actually changed to provide an API like that: https://github.com/tinyobjloader/tinyobjloader#example-code-new-object-oriented-api instead; however there's a lot of convenience in having the mesh re-indexing to single index built into the library too (e.g., now I have to implement it myself for tinyobjloader projects: https://github.com/Twinklebear/ChameleonRT/blob/master/util/scene.cpp#L116-L182 ). It may be possible to rework things in tobj a bit to provide this API, along with the same |
Thanks for the reply. Your explanation makes sense, I was just not expecting this (because I didn't consider using an OBJ file for multiple meshes). So maybe in the short term a more explicit explanation of this behavior in the docs would help. For now I'm using the |
I exported the default cube from Blender:
cube.obj
And load it with tobj:
However, I get the following output:
dbg!(&model.mesh.positions);
Note how the second vertex in this output does not match the second vertex from the OBJ file.
The vertices (and all other data) is re-ordered according to the order they are used by the list of faces even though I did not specify any reordering. To me this is very unexpected and it leads to problems if I e.g. re-export the obj after some manipulation and an outside application expects the order to stay constant - or if you want to debug something and want to use vertex ids to identify them in an outside application.
Am I using the library wrong or is this undocumented intentional behavior?
The text was updated successfully, but these errors were encountered: