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:
authorWayde Moss <GuiltyGhost>2022-04-15 01:16:23 +0300
committerWayde Moss <wbmoss_dev@yahoo.com>2022-04-15 03:25:06 +0300
commitdb6287873cd2c79741439f4d141c4b2db517d73e (patch)
tree9c60530681f07a801e9dff7fa9ee02de3c88270d /source/blender/editors/object/object_relations.c
parent48ff456a4bda98d73042b0ef85091cf79aad8647 (diff)
Object: Set Parent (Keep Transform Without Inverse)
**Relevant to Artists:** This patch adds an option to the Parenting menu, `Object (Keep Transform Without Inverse)`, and Apply menu, `Parent Inverse`. The operators preserve the child's world transform without using the parent inverse matrix. Effectively, we set the child's origin to the parent. When the child has an identity local transform, then the child is world-space aligned with its parent (scale excluded). **Technical:** In both cases, the hidden parent inverse matrix is generally set to identity (cleared or "not used") as long as the parent has no shear. If the parent has shear, then this matrix will not be entirely cleared. It will contain shear to counter the parent's shear. This is required, otherwise the object's local matrix cannot be properly decomposed into location, rotation and scale, and thus cannot preserve the world transform. If the child's world transform has shear, then its world transform is not preserved. This is currently not supported for consistency in the handling of shear during the other parenting ops: Parent (Keep Transform), Clear [Parent] and Keep Transform. If it should work, then another patch should add the support for all of them. Reviewed By: sybren, RiggingDojo Differential Revision: https://developer.blender.org/D14581
Diffstat (limited to 'source/blender/editors/object/object_relations.c')
-rw-r--r--source/blender/editors/object/object_relations.c36
1 files changed, 30 insertions, 6 deletions
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index 7be46bdb24b..5ef8e573e27 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -936,8 +936,19 @@ static int parent_set_invoke_menu(bContext *C, wmOperatorType *ot)
RNA_boolean_set(&opptr, "keep_transform", true);
#endif
- uiItemO(
- layout, IFACE_("Object (Without Inverse)"), ICON_NONE, "OBJECT_OT_parent_no_inverse_set");
+ uiItemBooleanO(layout,
+ IFACE_("Object (Without Inverse)"),
+ ICON_NONE,
+ "OBJECT_OT_parent_no_inverse_set",
+ "keep_transform",
+ 0);
+
+ uiItemBooleanO(layout,
+ IFACE_("Object (Keep Transform Without Inverse)"),
+ ICON_NONE,
+ "OBJECT_OT_parent_no_inverse_set",
+ "keep_transform",
+ 1);
struct {
bool mesh, gpencil;
@@ -1055,6 +1066,8 @@ static int parent_noinv_set_exec(bContext *C, wmOperator *op)
Main *bmain = CTX_data_main(C);
Object *par = ED_object_active_context(C);
+ const bool keep_transform = RNA_boolean_get(op->ptr, "keep_transform");
+
DEG_id_tag_update(&par->id, ID_RECALC_TRANSFORM);
/* context iterator */
@@ -1064,16 +1077,21 @@ static int parent_noinv_set_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_ERROR, "Loop in parents");
}
else {
- /* clear inverse matrix and also the object location */
- unit_m4(ob->parentinv);
- memset(ob->loc, 0, sizeof(float[3]));
-
/* set recalc flags */
DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
/* set parenting type for object - object only... */
ob->parent = par;
ob->partype = PAROBJECT; /* NOTE: DNA define, not operator property. */
+
+ if (keep_transform) {
+ BKE_object_apply_parent_inverse(ob);
+ continue;
+ }
+
+ /* clear inverse matrix and also the object location */
+ unit_m4(ob->parentinv);
+ memset(ob->loc, 0, sizeof(float[3]));
}
}
}
@@ -1100,6 +1118,12 @@ void OBJECT_OT_parent_no_inverse_set(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ RNA_def_boolean(ot->srna,
+ "keep_transform",
+ false,
+ "Keep Transform",
+ "Preserve the world transform throughout parenting");
}
/** \} */