Page MenuHome

Fix T76556: Apply parenting when joining parent into object
ClosedPublic

Authored by Hans Goudey (HooglyBoogly) on May 13 2020, 8:29 PM.

Details

Summary

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

BeforeAfter

However, this doesn't resolve recursive parenting like in the video below. That wouldn't be too complicated to write, but I thought it would be better to keep this patch simple.

Diff Detail

Repository
rB Blender
Branch
object-join-parent (branched from master)
Build Status
Buildable 8036
Build 8036: arc lint + arc unit

Event Timeline

Hans Goudey (HooglyBoogly) requested review of this revision.May 13 2020, 8:29 PM
Hans Goudey (HooglyBoogly) created this revision.
This revision is now accepted and ready to land.May 13 2020, 8:50 PM

Applying the parent transformation for all selected parents could look something like this:

static void object_apply_parents_selected(bContext *C, Object *ob, float m[4][4])
{
  Object *ob_iter = ob;
  while (ob_iter != NULL) {
    Object *parent = ob_iter->parent;

    if ((parent != NULL) && parent->IS_SELECTED_EDITABLE) {
      mul_m4_m4m4(m, m, ob_iter->parentinv);
    }

    ob_iter = parent;

    if (ob_iter == ob) {
      /* Parent cycle detected, get out! */
      return;
    }
  }
}

That might be more trouble than it's worth though. For instance, what if only some objects in the parent "chain" are selected?

Seems more trouble than it's worth, I think this simple fix is ok.