From 4ef5373756521d8c5872a1d257c2ee380f761a1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Fri, 2 Dec 2022 14:28:42 +0100 Subject: [PATCH] Add-on: add support for the `use_all_linked_data_direct` option Add support for Blender's `use_all_linked_data_direct` experimental option. This is a workaround for an issue with BAT, for which a quick solution is required by the Blender Studio (production crunch). Flamenco writes the `.flamenco.blend` file with `preferences.experimental.use_all_linked_data_direct` set to `True`, so that BAT has an easier time finding linked assets. --- CHANGELOG.md | 1 + addon/flamenco/operators.py | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b3e678b..85e69228 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ bugs in actually-released versions. - Add-on: Do a "pre-submission check" before sending files to the farm. This should provide submission errors earlier in the process, without waiting for files to be collected. - Worker: better handling of long lines from Blender/FFmpeg, splitting them up at character boundaries. - Manager: change SQLite parameters to have write-through-log journalling and less filesystem synchronisation. This reduces I/O load on the Manager. +- Add-on: Set Blender's experimental flag `use_all_linked_data_direct` to `True` on submitted files, to work around a shortcoming in BAT. See [Blender commit b8c7e93a6504](https://developer.blender.org/rBb8c7e93a6504833ee1e617523dfe2921c4fd0816) for the introduction of that flag. ## 3.1 - released 2022-10-18 diff --git a/addon/flamenco/operators.py b/addon/flamenco/operators.py index 87919770..dae8f11a 100644 --- a/addon/flamenco/operators.py +++ b/addon/flamenco/operators.py @@ -252,11 +252,15 @@ class FLAMENCO_OT_submit_job(FlamencoOpMixin, bpy.types.Operator): We can compress, since this file won't be managed by SVN and doesn't need diffability. """ render = context.scene.render + prefs = context.preferences # Remember settings we need to restore after saving. old_use_file_extension = render.use_file_extension old_use_overwrite = render.use_overwrite old_use_placeholder = render.use_placeholder + old_use_all_linked_data_direct = getattr( + prefs.experimental, "use_all_linked_data_direct", None + ) # TODO: see about disabling the denoiser (like the old Blender Cloud addon did). @@ -269,6 +273,17 @@ class FLAMENCO_OT_submit_job(FlamencoOpMixin, bpy.types.Operator): render.use_overwrite = False render.use_placeholder = False + # To work around a shortcoming of BAT, ensure that all + # indirectly-linked data is still saved as directly-linked. + # + # See `133dde41bb5b: Improve handling of (in)direclty linked status + # for linked IDs` in Blender's Git repository. + if old_use_all_linked_data_direct is not None: + self.log.info( + "Overriding prefs.experimental.use_all_linked_data_direct = True" + ) + prefs.experimental.use_all_linked_data_direct = True + filepath = Path(context.blend_data.filepath).with_suffix(".flamenco.blend") self.log.info("Saving copy to temporary file %s", filepath) bpy.ops.wm.save_as_mainfile( @@ -281,6 +296,12 @@ class FLAMENCO_OT_submit_job(FlamencoOpMixin, bpy.types.Operator): render.use_overwrite = old_use_overwrite render.use_placeholder = old_use_placeholder + # Only restore if the property exists to begin with: + if old_use_all_linked_data_direct is not None: + prefs.experimental.use_all_linked_data_direct = ( + old_use_all_linked_data_direct + ) + return filepath def _submit_files(self, context: bpy.types.Context, blendfile: Path) -> set[str]: