Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey@blender.org>2022-08-03 11:54:11 +0300
committerSergey Sharybin <sergey@blender.org>2022-08-04 17:02:44 +0300
commit665d3db3a40c1e1ec3c5c5371b29bddcf07a6f92 (patch)
treedaf07202118e1f8df71bbef69f27b7d3bb5913e4 /source/blender/blenkernel/BKE_lib_id.h
parent39a68b27b90e4dc85e9eb69364bb81fad8e36337 (diff)
Fix T99460: Allow creation new datablocks from evaluated
This changes makes it possible to copy evaluated result and put it to the original bmain. Prior to this change from the API point of view there was false perception that it is possible, while in practice it was very fragile: it only worked if the ID did not reference any evaluated IDs. This change makes it so `id.copy()` Python API call will make it so the copied ID only references original data-blocks. This sounds a bit implicit, so here is motivational aspect why it is considered better approach to all other: - There needs to be a way to support the described scenario, in the lest fragile way. Requiring to always use an explicit function call or an argument is too verbose and is easy to be missed. - The `id.copy()` is already doing implicit thing: it always adds the result to the bmain. So it might as well ensure the copied result does not reference evaluated data-blocks. - Added clarity in the documentation should address possible confusion. The limitation of this change is that the copy() of evaluated geometry will clear its reference to the shape key. This is because the key is only referenced for validness of RNA paths for drivers and the key itself might not match topology of evaluated geometry due to modifiers. Differential Revision: https://developer.blender.org/D15611
Diffstat (limited to 'source/blender/blenkernel/BKE_lib_id.h')
-rw-r--r--source/blender/blenkernel/BKE_lib_id.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_lib_id.h b/source/blender/blenkernel/BKE_lib_id.h
index 94497d9a487..148e6ec2791 100644
--- a/source/blender/blenkernel/BKE_lib_id.h
+++ b/source/blender/blenkernel/BKE_lib_id.h
@@ -453,6 +453,11 @@ struct ID *BKE_id_copy_for_duplicate(struct Main *bmain,
uint duplicate_flags,
int copy_flags);
+/* Special version of BKE_id_copy which is safe from using evaluated id as source with a copy
+ * result appearing in the main database.
+ * Takes care of the referenced data-blocks consistency. */
+struct ID *BKE_id_copy_for_use_in_bmain(struct Main *bmain, const struct ID *id);
+
/**
* Does a mere memory swap over the whole IDs data (including type-specific memory).
* \note Most internal ID data itself is not swapped (only IDProperties are).