diff options
author | Bastien Montagne <bastien@blender.org> | 2021-09-17 17:22:29 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2021-09-22 17:55:39 +0300 |
commit | 794c2828af60af02a38381c2a9a81f9046381074 (patch) | |
tree | 3c2c5c595c1c7e7f8a31598aa149ff6a4333b54c /source/blender/makesrna | |
parent | 707bcd5693aedc0c1a461bbb0ce88680e32de561 (diff) |
Initial implementation of local ID re-use when appending.
This commit adds to ID struct a new optional 'weak reference' to a
linked ID (in the form of a blend file library path and full ID name).
This can then be used on next append to try to find a matching local ID
instead of re-making the linked data local again.
Ref. T90545
NOTE: ID re-use will be disabled for regular append for the time being
(3.0 release), and only used for assets. Therefore, this commit should
not change anything user-wise.
Differential Revision: https://developer.blender.org/D12545
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r-- | source/blender/makesrna/intern/rna_ID.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c index eb887e1881b..1113ac0eb45 100644 --- a/source/blender/makesrna/intern/rna_ID.c +++ b/source/blender/makesrna/intern/rna_ID.c @@ -1936,6 +1936,15 @@ static void rna_def_ID(BlenderRNA *brna) RNA_def_property_override_flag(prop, PROPOVERRIDE_NO_COMPARISON); RNA_def_property_ui_text(prop, "Library", "Library file the data-block is linked from"); + prop = RNA_def_pointer(srna, + "library_weak_reference", + "LibraryWeakReference", + "Library Weak Reference", + "Weak reference to a data-block in another library .blend file (used to " + "re-use already appended data instead of appending new copies)"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_override_flag(prop, PROPOVERRIDE_NO_COMPARISON); + prop = RNA_def_property(srna, "asset_data", PROP_POINTER, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_override_flag(prop, PROPOVERRIDE_NO_COMPARISON); @@ -2143,6 +2152,31 @@ static void rna_def_library(BlenderRNA *brna) RNA_def_function_ui_description(func, "Reload this library and all its linked data-blocks"); } +static void rna_def_library_weak_reference(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "LibraryWeakReference", NULL); + RNA_def_struct_ui_text( + srna, + "LibraryWeakReference", + "Read-only external reference to a linked data-block and its library file"); + + prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH); + RNA_def_property_string_sdna(prop, NULL, "library_filepath"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "File Path", "Path to the library .blend file"); + + prop = RNA_def_property(srna, "id_name", PROP_STRING, PROP_FILEPATH); + RNA_def_property_string_sdna(prop, NULL, "library_id_name"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text( + prop, + "ID name", + "Full ID name in the library .blend file (including the two leading 'id type' chars)"); +} + /** * \attention This is separate from the above. It allows for RNA functions to * return an IDProperty *. See MovieClip.metadata for a usage example. @@ -2175,6 +2209,7 @@ void RNA_def_ID(BlenderRNA *brna) rna_def_ID_properties(brna); rna_def_ID_materials(brna); rna_def_library(brna); + rna_def_library_weak_reference(brna); rna_def_idproperty_wrap_ptr(brna); } |