From 9b6ea1eca42aa7a50911971265f40cba27b69e43 Mon Sep 17 00:00:00 2001 From: Thomas Barlow Date: Sat, 23 Sep 2023 23:54:53 +0100 Subject: [PATCH 1/2] Fix missing animations when converting some FBX from json to binary Animations would be missing in external software when importing FBX that have their AnimationLayer or AnimationStack element as the last element in a block. Importing such files through Blender, however, would import the animations without issue. AnimationLayer and AnimationStack elements are an exception to normal FBX behaviour in that they always need to write a block sentinel after them. However, this was not happening when the AnimationLayer was the last element in a block. With this patch, the block sentinel is now always written for AnimationLayer and AnimationStack elements. This patch should only affect FBX files converted from json to binary with the json2fbx.py script because FBX exported from Blender always writes the AnimationStack, AnimationLayer and then AnimationCurveNodes and AnimationCurves of that AnimationLayer, so the only time the AnimationLayer could be the last element in the block is when there are no animations in the AnimationLayer to begin with. --- io_scene_fbx/encode_bin.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/io_scene_fbx/encode_bin.py b/io_scene_fbx/encode_bin.py index 2970fd73f..a7e8071e2 100644 --- a/io_scene_fbx/encode_bin.py +++ b/io_scene_fbx/encode_bin.py @@ -250,9 +250,8 @@ class FBXElem: for elem in self.elems: offset = elem._calc_offsets(offset, (elem is elem_last)) offset += _BLOCK_SENTINEL_LENGTH - elif not self.props or self.id in _ELEMS_ID_ALWAYS_BLOCK_SENTINEL: - if not is_last: - offset += _BLOCK_SENTINEL_LENGTH + elif (not self.props and not is_last) or self.id in _ELEMS_ID_ALWAYS_BLOCK_SENTINEL: + offset += _BLOCK_SENTINEL_LENGTH return offset @@ -282,9 +281,8 @@ class FBXElem: assert(elem.id != b'') elem._write(write, tell, (elem is elem_last)) write(_BLOCK_SENTINEL_DATA) - elif not self.props or self.id in _ELEMS_ID_ALWAYS_BLOCK_SENTINEL: - if not is_last: - write(_BLOCK_SENTINEL_DATA) + elif (not self.props and not is_last) or self.id in _ELEMS_ID_ALWAYS_BLOCK_SENTINEL: + write(_BLOCK_SENTINEL_DATA) def _write_timedate_hack(elem_root): -- 2.30.2 From c88a33fa1d5b7fa16e8afd501fda129fae19f83e Mon Sep 17 00:00:00 2001 From: Thomas Barlow Date: Thu, 5 Oct 2023 23:01:27 +0100 Subject: [PATCH 2/2] Increase FBX IO Version --- io_scene_fbx/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/io_scene_fbx/__init__.py b/io_scene_fbx/__init__.py index 44b964174..5aaf9f92e 100644 --- a/io_scene_fbx/__init__.py +++ b/io_scene_fbx/__init__.py @@ -5,7 +5,7 @@ bl_info = { "name": "FBX format", "author": "Campbell Barton, Bastien Montagne, Jens Restemeier, @Mysteryem", - "version": (5, 8, 3), + "version": (5, 8, 4), "blender": (3, 6, 0), "location": "File > Import-Export", "description": "FBX IO meshes, UVs, vertex colors, materials, textures, cameras, lamps and actions", -- 2.30.2