Commit: b26c9dfcb2ef19054f23cceb9988e8a8cce24b12
Author: Bastien Montagne
Date:   Mon Feb 4 17:27:01 2019 +0100
Branches: master
https://developer.blender.org/rBb26c9dfcb2ef19054f23cceb9988e8a8cce24b12

Cleanup: initial regrouping of ID create/copy flags.

Those two first sets of flags should represent some common use cases.
The goal here is to reduce verbosity of calls to BKE_id_copy_ex, and
help make it more obvious the 'common behaviours' of ID copying across
codebase.

===================================================================

M       source/blender/blenkernel/BKE_library.h
M       source/blender/blenkernel/intern/library.c
M       source/blender/blenkernel/intern/particle_system.c
M       source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc

===================================================================

diff --git a/source/blender/blenkernel/BKE_library.h 
b/source/blender/blenkernel/BKE_library.h
index 6584a975671..0438ac95ce2 100644
--- a/source/blender/blenkernel/BKE_library.h
+++ b/source/blender/blenkernel/BKE_library.h
@@ -105,6 +105,15 @@ enum {
        LIB_ID_COPY_KEEP_LIB           = 1 << 25,
        /* EXCEPTION! Deep-copy shapekeys used by copied obdata ID. */
        LIB_ID_COPY_SHAPEKEY           = 1 << 26,
+
+       /* *** Helper 'defines' gathering most common flag sets. *** */
+       /* Shapekeys are not real ID's, more like local data to geometry IDs... 
*/
+       LIB_ID_COPY_DEFAULT            = LIB_ID_COPY_SHAPEKEY,
+       /* Generate a local copy, outside of bmain, to work on (used by COW 
e.g.). */
+       LIB_ID_COPY_LOCALIZE           = LIB_ID_CREATE_NO_MAIN |
+                                        LIB_ID_CREATE_NO_USER_REFCOUNT |
+                                        LIB_ID_CREATE_NO_DEG_TAG |
+                                        LIB_ID_COPY_CACHES,
 };
 
 void BKE_libblock_copy_ex(struct Main *bmain, const struct ID *id, struct ID 
**r_newid, const int flag);
diff --git a/source/blender/blenkernel/intern/library.c 
b/source/blender/blenkernel/intern/library.c
index d4009912300..1cf07c8c669 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -715,7 +715,7 @@ bool BKE_id_copy_ex(Main *bmain, const ID *id, ID 
**r_newid, const int flag)
  */
 bool BKE_id_copy(Main *bmain, const ID *id, ID **newid)
 {
-       return BKE_id_copy_ex(bmain, id, newid, LIB_ID_COPY_SHAPEKEY);
+       return BKE_id_copy_ex(bmain, id, newid, LIB_ID_COPY_DEFAULT);
 }
 
 /** Does a mere memory swap over the whole IDs data (including type-specific 
memory).
diff --git a/source/blender/blenkernel/intern/particle_system.c 
b/source/blender/blenkernel/intern/particle_system.c
index 008ef0b02bf..77422ca20e3 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -4195,10 +4195,7 @@ static ParticleSettings 
*particle_settings_localize(ParticleSettings *particle_s
        BKE_id_copy_ex(NULL,
                       (ID *)&particle_settings->id,
                       (ID **)&particle_settings_local,
-                      (LIB_ID_CREATE_NO_MAIN |
-                       LIB_ID_CREATE_NO_USER_REFCOUNT |
-                       LIB_ID_CREATE_NO_DEG_TAG |
-                       LIB_ID_COPY_CACHES));
+                      LIB_ID_COPY_LOCALIZE);
        return particle_settings_local;
 }
 
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc 
b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
index 4db27e2ddf5..78b3776455f 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
@@ -290,11 +290,8 @@ bool id_copy_inplace_no_main(const ID *id, ID *newid)
        bool result = BKE_id_copy_ex(NULL,
                                     (ID *)id_for_copy,
                                     &newid,
-                                    (LIB_ID_CREATE_NO_MAIN |
-                                     LIB_ID_CREATE_NO_USER_REFCOUNT |
-                                     LIB_ID_CREATE_NO_ALLOCATE |
-                                     LIB_ID_CREATE_NO_DEG_TAG |
-                                     LIB_ID_COPY_CACHES));
+                                    (LIB_ID_COPY_LOCALIZE |
+                                     LIB_ID_CREATE_NO_ALLOCATE));
 
 #ifdef NESTED_ID_NASTY_WORKAROUND
        if (result) {

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to