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:
authorCampbell Barton <ideasman42@gmail.com>2020-08-25 07:32:10 +0300
committerCampbell Barton <ideasman42@gmail.com>2020-08-25 07:32:10 +0300
commit5eb7aa5ebba9cf6a88e0433ac679ad8f810c5c47 (patch)
tree393081ffac23842dbdc21d8500c9bfdfd4cb2adb /source/blender/editors/object
parent96401e2ef86809759d30cbc1d1b8ba0b666f5f4c (diff)
Fix T80077: Objects disappear when joining with a zero scaled axis
Use invert_m4_m4_safe_ortho when joining objects so zero scaled axis doesn't cause all points to be scaled to zero. Instead geometry is left un-scaled on degenerate axes. Report a warning in this case since users may want to adjust the active objects scale.
Diffstat (limited to 'source/blender/editors/object')
-rw-r--r--source/blender/editors/object/object_add.c51
1 files changed, 38 insertions, 13 deletions
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index a59d8136f47..72180d58ecb 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -3167,20 +3167,45 @@ static int object_join_exec(bContext *C, wmOperator *op)
}
}
+ int ret = OPERATOR_CANCELLED;
if (ob->type == OB_MESH) {
- return ED_mesh_join_objects_exec(C, op);
- }
- if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
- return ED_curve_join_objects_exec(C, op);
- }
- if (ob->type == OB_ARMATURE) {
- return ED_armature_join_objects_exec(C, op);
- }
- if (ob->type == OB_GPENCIL) {
- return ED_gpencil_join_objects_exec(C, op);
- }
-
- return OPERATOR_CANCELLED;
+ ret = ED_mesh_join_objects_exec(C, op);
+ }
+ else if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
+ ret = ED_curve_join_objects_exec(C, op);
+ }
+ else if (ob->type == OB_ARMATURE) {
+ ret = ED_armature_join_objects_exec(C, op);
+ }
+ else if (ob->type == OB_GPENCIL) {
+ ret = ED_gpencil_join_objects_exec(C, op);
+ }
+
+ if (ret & OPERATOR_FINISHED) {
+ /* Even though internally failure to invert is accounted for with a fallback,
+ * show a warning since the result may not be what the user expects. See T80077.
+ *
+ * Failure to invert the matrix is typically caused by zero scaled axes
+ * (which can be caused by constraints, even if the input scale isn't zero).
+ *
+ * Internally the join functions use #invert_m4_m4_safe_ortho which creates
+ * an inevitable matrix from one that has one or more degenerate axes.
+ *
+ * In most cases we don't worry about special handling for non-inevitable matrices however for
+ * joining objects there may be flat 2D objects where it's not obvious the scale is zero.
+ * In this case, using #invert_m4_m4_safe_ortho works as well as we can expect,
+ * joining the contents, flattening on the axis that's zero scaled.
+ * If the zero scale is removed, the data on this axis remains un-scaled
+ * (something that wouldn't work for #invert_m4_m4_safe). */
+ float imat_test[4][4];
+ if (!invert_m4_m4(imat_test, ob->obmat)) {
+ BKE_report(op->reports,
+ RPT_WARNING,
+ "Active object final transform has one or more zero scaled axes");
+ }
+ }
+
+ return ret;
}
void OBJECT_OT_join(wmOperatorType *ot)