FBX2glTF icon indicating copy to clipboard operation
FBX2glTF copied to clipboard

Importing 3d models has non-deterministic behavior

Open DmLvkvch opened this issue 4 years ago • 7 comments

Hi! I had a problem that the build for linux does not work (I'm not sure about all the models, but it fell on mine) with optimization -O0 (without optimizations), its failed here

the same problem with artefacts for mac and windows (they are also non deterministic with or without compiler optimizations such as -O1 -O2 -O3).

also the model can be either converted or not converted from launch to launch . I think it may be due to too serious compiler optimizations (mb some variables store trash values).

here channel.index can store negative value (in my case it was -1). So i hot-fixed it as shown below so that the converter would not fall with segmentation fault , but I'm sure it's the wrong solution.

Raw2gltf.cpp#L170

        const RawChannel& channel = animation.channels[channelIx];
        //new code
        if(channel.nodeIndex < 0)
        {
          continue;
        }
        // end new code
        const RawNode& node = raw.GetNode(channel.nodeIndex);

Maybe someone fixed it or have the same problem?

DmLvkvch avatar Apr 19 '22 14:04 DmLvkvch

Can you provide a small case I can use to verify it's fixed.

fire avatar May 12 '22 17:05 fire

I made a pr here https://github.com/V-Sekai/FBX2glTF/pull/15. Will need to test.

fire avatar May 23 '22 23:05 fire

sorry for the late reply So, here is an example of a model (cat.zip) where the converter crashes. You can try to build converter tool without compiler optimizations (because on linux that problem does not always occur on release build). Without optimizations this problem always occurs.

my fork with edited cmake

ex. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 )

if (NOT MSVC)
  # Disable annoying & spammy warning from FBX SDK header file
  target_compile_options(libFBX2glTF PRIVATE
    "-Wno-null-dereference"
    "-Wunused"
    "-O0"
    )
  target_compile_options(FBX2glTF PRIVATE
    "-Wno-null-dereference"
    "-Wunused"
    "-O0"
    )
endif()

here is converted model (so maybe this solution works correctly) image

cat.zip

P.S. origin converter v0.9.7 convert this model correctly (https://github.com/facebookincubator/FBX2glTF/releases) . maybe this can help

DmLvkvch avatar Jun 03 '22 07:06 DmLvkvch

I'll test turning off optimizations.

fire avatar Jun 03 '22 08:06 fire

I'm not able to work on this for a short period of time.

fire avatar Jun 06 '22 13:06 fire

I am looking into this.

fire avatar Nov 12 '22 16:11 fire

There is some work here to check if the latest build still has this problem. For a future me or a different person.

fire avatar Dec 18 '22 15:12 fire