Fix FBX char type being interpreted as bool #104914

Merged
Thomas Barlow merged 2 commits from Mysteryem/blender-addons:fbx_fix_char_type into main 2023-09-26 03:44:45 +02:00

2 Commits

Author SHA1 Message Date
Thomas Barlow 4869899fad Increase FBX IO version 2023-09-26 02:40:53 +01:00
Thomas Barlow bd73b9c44d Fix FBX char type being interpreted as bool
Blender has been interpreting the FBX 'C' type as bool, however, it is
actually an 8-bit integer that is separate from the already existing
byte/int8 type. FBX does have 'B' as a bool type, but it seems to be
unused.

FBX Converter displays what it calls "byte" ('Z' type) numerically,
but displays what it calls "int8" ('C' type) with both the numeric value
and the ascii character for that value, which leads me to believe that
this 'C' type should be interpreted as a single `char`. While there
doesn't appear to be many places that the 'C' type is used, it appears
to usually be set to a printable character.

Python doesn't have a `char` type, so the single `char` is read and
written as `bytes` with length equal to 1.

There are no expected changes to the import or export of FBX files with
this patch because the only FBX element that was incorrectly being
exported as a bool is now exported as the '\x01' char, which has the
same raw value as the `True` value that was being exported before.

The main benefit to this patch is that FBX files converted to .json with
fbx2json.py (and optionally back to .fbx with json2fbx.py) will now
maintain any 'C' type values instead of reducing them to True or False.

Additionally, should FBX files using the 'B' bool type be encountered in
the future, they are now supported.
2023-09-25 04:23:05 +01:00