Core: Add packed linked data-blocks
This adds support for packed linked data. This is a key part of an improved asset workflow in Blender. Packed IDs remain considered as linked data (i.e. they cannot be edited), but they are stored in the current blendfile. This means that they: * Are not lost in case the library data becomes unavailable. * Are not changed in case the library data is updated. These packed IDs are de-duplicated across blend-files, so e.g. if a shot file and several of its dependencies all use the same util geometry node, there will be a single copy of that geometry node in the shot file. In case there are several versions of a same ID (e.g. linked at different moments from a same library, which has been modified in-between), there will be several packed IDs. Name collisions are averted by storing these packed IDs into a new type of 'archive' libraries (and their namespaces). These libraries: * Only contain packed IDs. * Are owned and managed by their 'real' library data-block, called an 'archive parent'. For more in-depth, technical design: #132167 UI/UX design: #140870 Co-authored-by: Bastien Montagne <bastien@blender.org> Pull Request: https://projects.blender.org/blender/blender/pulls/133801
This commit is contained in:
committed by
Bastien Montagne
parent
44194579a5
commit
4e4976804e
@@ -182,3 +182,52 @@ class TestBlendLibLinkHelper(TestHelper):
|
||||
bpy.ops.wm.save_as_mainfile(filepath=output_lib_path, check_existing=False, compress=False)
|
||||
|
||||
return output_lib_path
|
||||
|
||||
def init_lib_data_packed_indirect_lib(self):
|
||||
output_dir = self.args.output_dir
|
||||
self.ensure_path(output_dir)
|
||||
|
||||
# Create an indirect library containing a material, and an image texture.
|
||||
self.reset_blender()
|
||||
|
||||
self.gen_indirect_library_data_()
|
||||
|
||||
# Take care to keep the name unique so multiple test jobs can run at once.
|
||||
output_lib_path = os.path.join(output_dir, self.unique_blendfile_name("blendlib_indirect_material"))
|
||||
|
||||
bpy.ops.wm.save_as_mainfile(filepath=output_lib_path, check_existing=False, compress=False)
|
||||
|
||||
# Create a main library containing object etc., and linking material from indirect library.
|
||||
self.reset_blender()
|
||||
|
||||
self.gen_library_data_()
|
||||
|
||||
link_dir = os.path.join(output_lib_path, "Material")
|
||||
bpy.ops.wm.link(directory=link_dir, filename="LibMaterial")
|
||||
|
||||
ma = bpy.data.pack_linked_ids_hierarchy(bpy.data.materials[0])
|
||||
|
||||
me = bpy.data.meshes[0]
|
||||
me.materials.append(ma)
|
||||
|
||||
bpy.ops.outliner.orphans_purge()
|
||||
|
||||
self.assertEqual(len(bpy.data.materials), 1)
|
||||
self.assertTrue(bpy.data.materials[0].is_linked_packed)
|
||||
|
||||
self.assertEqual(len(bpy.data.images), 1)
|
||||
self.assertTrue(bpy.data.images[0].is_linked_packed)
|
||||
|
||||
self.assertEqual(len(bpy.data.libraries), 2)
|
||||
self.assertFalse(bpy.data.libraries[0].is_archive)
|
||||
self.assertTrue(bpy.data.libraries[1].is_archive)
|
||||
self.assertIn(bpy.data.libraries[1].name, bpy.data.libraries[0].archive_libraries)
|
||||
|
||||
output_dir = self.args.output_dir
|
||||
self.ensure_path(output_dir)
|
||||
# Take care to keep the name unique so multiple test jobs can run at once.
|
||||
output_lib_path = os.path.join(output_dir, self.unique_blendfile_name("blendlib_indirect_main"))
|
||||
|
||||
bpy.ops.wm.save_as_mainfile(filepath=output_lib_path, check_existing=False, compress=False)
|
||||
|
||||
return output_lib_path
|
||||
|
||||
Reference in New Issue
Block a user