lo48576 / fbxcel-dom

FBX DOM library for Rust. // See https://github.com/lo48576/fbx-viewer for working example application // rework (total rewrite) is planned
Apache License 2.0
25 stars 10 forks source link

Negative index not allowed #12

Closed heavyrain266 closed 2 years ago

heavyrain266 commented 2 years ago

Hello, I'm co-author of bevy_fbx plugin for loading FBX in Bevy Engine, which is heavly based on your fbx-viewer code.

While trying to load Bistro Scene from Amazon's Lumberyard demo, I'm getting following error

2022-07-12T13:01:02.864866Z ERROR bevy_fbx::loader: failed to load "BistroInterior_Wine.fbx"

Caused by:
    0: Failed to load geometry mesh
    1: Failed to reconstruct UV vertices
    2: Negative index is not allowed: direct=-1

For us, it looks like UB caused by FBX file (v7.5) from Amazon and I would like to know if you have any info of how we could fix this problem, either in fbxcel(-dom) or our loader.

According to Autodesk forums, FBX uses negative values in PolygonVertexIndex which then have to be turned into possitive ones by reader.

the negative values in PolygonVertexIndex are just used to indicate the end of a polygon. It will be converted to a positive value by fbxreader according to certain rules. So you do not need to worry about them, as long as you import the FBX file, the reader will take care.

Already tried exporting it as v7.4 and changing settings in Cinema4D and that didn't helped.

lo48576 commented 2 years ago

Thank you for reporting!

Fixed and released as v0.0.8. Note that v0.0.8 requires Rust 1.56 or later (I hope this won't bother you). The relevant commit of the fix is 65b9faaf05d42de401d743a20fd30c5558676775. You can cherry-pick this if necessary.

Anyway, you are doing amazing work! I'm happy I can see my work will contribute to more people. screenshot-2022-07-13-074617+0900

heavyrain266 commented 2 years ago

Thank you very much, I really like your work. Rust version is not a problem because we always target latest stable which is 1.62 currently.