[Bf-blender-cvs] [b454a122331] master: Separate operators (mesh/curve/armature/gpencil): take user preferences into account for duplicating actions

Philipp Oeser noreply at git.blender.org
Tue Mar 3 10:04:57 CET 2020


Commit: b454a1223317c8d05bc09a745f85eae22be658e8
Author: Philipp Oeser
Date:   Wed Oct 23 12:28:32 2019 +0200
Branches: master
https://developer.blender.org/rBb454a1223317c8d05bc09a745f85eae22be658e8

Separate operators (mesh/curve/armature/gpencil): take user preferences
into account for duplicating actions

Previously actions remained linked after duplication, now this is based
on the User Preferences (PreferencesEdit.use_duplicate_action).

note: default is ON here, so this changes default behavior of separate
operators.

First intuition was to respect _all_ preferences here (e.g. also
duplicating materials if chosen in the User Preferences) but after
consideration this is probably not what the User would expect from such
'modeling' opertions (e.g. separate by loose parts resulting in possibly
many duplicate materials)

Fixes T71038

Maniphest Tasks: T71038

Differential Revision: https://developer.blender.org/D6120

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

M	source/blender/editors/armature/armature_relations.c
M	source/blender/editors/curve/editcurve.c
M	source/blender/editors/gpencil/gpencil_edit.c
M	source/blender/editors/mesh/editmesh_tools.c

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

diff --git a/source/blender/editors/armature/armature_relations.c b/source/blender/editors/armature/armature_relations.c
index ae0501d14ef..b800714cd14 100644
--- a/source/blender/editors/armature/armature_relations.c
+++ b/source/blender/editors/armature/armature_relations.c
@@ -667,8 +667,9 @@ static int separate_armature_exec(bContext *C, wmOperator *op)
 
     /* 2) duplicate base */
 
-    /* only duplicate linked armature */
-    Base *base_new = ED_object_add_duplicate(bmain, scene, view_layer, base_old, USER_DUP_ARM);
+    /* Only duplicate linked armature but take into account user preferences for duplicating actions. */
+    short dupflag = USER_DUP_ARM | (U.dupflag & USER_DUP_ACT);
+    Base *base_new = ED_object_add_duplicate(bmain, scene, view_layer, base_old, dupflag);
     Object *ob_new = base_new->object;
 
     DEG_relations_tag_update(bmain);
diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c
index 072cbb29378..902e45dde5a 100644
--- a/source/blender/editors/curve/editcurve.c
+++ b/source/blender/editors/curve/editcurve.c
@@ -1405,12 +1405,15 @@ static int separate_exec(bContext *C, wmOperator *op)
     }
 
     /* 2. Duplicate the object and data. */
+
+    /* Take into account user preferences for duplicating actions. */
+    short dupflag = (U.dupflag & USER_DUP_ACT);
+
     newbase = ED_object_add_duplicate(bmain,
                                       scene,
                                       view_layer,
                                       oldbase,
-                                      /* 0 = fully linked. */
-                                      0);
+                                      dupflag);
     DEG_relations_tag_update(bmain);
 
     newob = newbase->object;
diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c
index d710e59c569..ee4a26475b9 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -4092,8 +4092,11 @@ static int gp_stroke_separate_exec(bContext *C, wmOperator *op)
 
   const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd_src);
 
-  /* create a new object */
-  base_new = ED_object_add_duplicate(bmain, scene, view_layer, base_old, 0);
+  /* Create a new object. */
+  /* Take into account user preferences for duplicating actions. */
+  short dupflag = (U.dupflag & USER_DUP_ACT);
+
+  base_new = ED_object_add_duplicate(bmain, scene, view_layer, base_old, dupflag);
   ob_dst = base_new->object;
   ob_dst->mode = OB_MODE_OBJECT;
   /* create new grease pencil datablock */
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c
index 4003a7dd7bb..2176bbceb5f 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -3929,7 +3929,9 @@ static Base *mesh_separate_tagged(
   CustomData_bmesh_init_pool(&bm_new->ldata, bm_mesh_allocsize_default.totloop, BM_LOOP);
   CustomData_bmesh_init_pool(&bm_new->pdata, bm_mesh_allocsize_default.totface, BM_FACE);
 
-  base_new = ED_object_add_duplicate(bmain, scene, view_layer, base_old, USER_DUP_MESH);
+  /* Take into account user preferences for duplicating actions. */
+  short dupflag = USER_DUP_MESH | (U.dupflag & USER_DUP_ACT);
+  base_new = ED_object_add_duplicate(bmain, scene, view_layer, base_old, dupflag);
 
   /* normally would call directly after but in this case delay recalc */
   /* DAG_relations_tag_update(bmain); */
@@ -3999,7 +4001,9 @@ static Base *mesh_separate_arrays(Main *bmain,
   CustomData_bmesh_init_pool(&bm_new->ldata, faces_len * 3, BM_LOOP);
   CustomData_bmesh_init_pool(&bm_new->pdata, faces_len, BM_FACE);
 
-  base_new = ED_object_add_duplicate(bmain, scene, view_layer, base_old, USER_DUP_MESH);
+  /* Take into account user preferences for duplicating actions. */
+  short dupflag = USER_DUP_MESH | (U.dupflag & USER_DUP_ACT);
+  base_new = ED_object_add_duplicate(bmain, scene, view_layer, base_old, dupflag);
 
   /* normally would call directly after but in this case delay recalc */
   /* DAG_relations_tag_update(bmain); */



More information about the Bf-blender-cvs mailing list