[Bf-blender-cvs] [5e96c438546] blender-v2.83-release: Fix T76556: Apply parenting when joining parent into object

Hans Goudey noreply at git.blender.org
Wed May 13 21:21:52 CEST 2020


Commit: 5e96c438546932ca875aa35afb8c73f9a68d62a1
Author: Hans Goudey
Date:   Wed May 13 15:21:30 2020 -0400
Branches: blender-v2.83-release
https://developer.blender.org/rB5e96c438546932ca875aa35afb8c73f9a68d62a1

Fix T76556: Apply parenting when joining parent into object

The current behavior isn't necessarily "incorrect," but it's unintuitive
and confusing. A simple fix is to apply parentinv before finishing the
operator.

However, there may still be issues when the object's parent has a parent.

Reviewed By: brecht

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

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

M	source/blender/editors/mesh/meshtools.c

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

diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c
index 8dbd468d04f..917bbe61e3d 100644
--- a/source/blender/editors/mesh/meshtools.c
+++ b/source/blender/editors/mesh/meshtools.c
@@ -314,7 +314,7 @@ int join_mesh_exec(bContext *C, wmOperator *op)
   int a, b, totcol, totmat = 0, totedge = 0, totvert = 0;
   int totloop = 0, totpoly = 0, vertofs, *matmap = NULL;
   int i, haskey = 0, edgeofs, loopofs, polyofs;
-  bool ok = false;
+  bool ok = false, join_parent = false;
   bDeformGroup *dg, *odg;
   CustomData vdata, edata, fdata, ldata, pdata;
 
@@ -346,6 +346,10 @@ int join_mesh_exec(bContext *C, wmOperator *op)
         ok = true;
       }
 
+      if ((ob->parent != NULL) && (ob_iter == ob->parent)) {
+        join_parent = true;
+      }
+
       /* check for shapekeys */
       if (me->key) {
         haskey++;
@@ -354,6 +358,13 @@ int join_mesh_exec(bContext *C, wmOperator *op)
   }
   CTX_DATA_END;
 
+  /* Apply parent transform if the active object's parent was joined to it.
+   * Note: This doesn't apply recursive parenting. */
+  if (join_parent) {
+    ob->parent = NULL;
+    BKE_object_apply_mat4_ex(ob, ob->obmat, ob->parent, ob->parentinv, false);
+  }
+
   /* that way the active object is always selected */
   if (ok == false) {
     BKE_report(op->reports, RPT_WARNING, "Active object is not a selected mesh");



More information about the Bf-blender-cvs mailing list