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.
This commit is contained in:
Sybren A. Stüvel 2022-12-02 14:28:42 +01:00
parent 21b2114505
commit 4ef5373756
2 changed files with 22 additions and 0 deletions

View File

@ -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. - 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. - 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. - 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 ## 3.1 - released 2022-10-18

View File

@ -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. We can compress, since this file won't be managed by SVN and doesn't need diffability.
""" """
render = context.scene.render render = context.scene.render
prefs = context.preferences
# Remember settings we need to restore after saving. # Remember settings we need to restore after saving.
old_use_file_extension = render.use_file_extension old_use_file_extension = render.use_file_extension
old_use_overwrite = render.use_overwrite old_use_overwrite = render.use_overwrite
old_use_placeholder = render.use_placeholder 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). # 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_overwrite = False
render.use_placeholder = 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") filepath = Path(context.blend_data.filepath).with_suffix(".flamenco.blend")
self.log.info("Saving copy to temporary file %s", filepath) self.log.info("Saving copy to temporary file %s", filepath)
bpy.ops.wm.save_as_mainfile( 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_overwrite = old_use_overwrite
render.use_placeholder = old_use_placeholder 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 return filepath
def _submit_files(self, context: bpy.types.Context, blendfile: Path) -> set[str]: def _submit_files(self, context: bpy.types.Context, blendfile: Path) -> set[str]: