diff options
author | Philipp Oeser <info@graphics-engineer.com> | 2021-03-17 11:21:32 +0300 |
---|---|---|
committer | Philipp Oeser <info@graphics-engineer.com> | 2021-03-20 10:14:49 +0300 |
commit | d5a705873e11510950b899caebd43ba47d69ccfa (patch) | |
tree | 1afe51b6d211ecb2e5db9e842fff7b4d609c7e08 /source/blender/editors/curve | |
parent | f65a3172a8b7513842dcf934197ed4174e37a4b5 (diff) |
Join curves: compensate for different bevel depths
When joining curves, the resulting curve will inherit the bevel depth of
the active curve, but the radii would stay the same which leads to
changed appearance when joining.
Now compensate for this taking the different bevel depths into account
(if present).
Was a feature request here (and I also think we had reports about this
-- which were usually turned down as not-a-bug):
https://blender.community/c/rightclickselect/bhhbbc/
Differential Revision: https://developer.blender.org/D10752
Diffstat (limited to 'source/blender/editors/curve')
-rw-r--r-- | source/blender/editors/curve/editcurve.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index 33ef6a5d026..c3ec87dc0d9 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -6872,6 +6872,8 @@ int ED_curve_join_objects_exec(bContext *C, wmOperator *op) * See #object_join_exec for detailed comment on why the safe version is used. */ invert_m4_m4_safe_ortho(imat, ob_active->obmat); + Curve *cu_active = ob_active->data; + CTX_DATA_BEGIN (C, Object *, ob_iter, selected_editable_objects) { if (ob_iter->type == ob_active->type) { if (ob_iter != ob_active) { @@ -6882,6 +6884,15 @@ int ED_curve_join_objects_exec(bContext *C, wmOperator *op) /* watch it: switch order here really goes wrong */ mul_m4_m4m4(cmat, imat, ob_iter->obmat); + /* Compensate for different bevel depth. */ + bool do_radius = false; + float compensate_radius = 0.0f; + if (cu->ext2 != 0.0f && cu_active->ext2 != 0.0f) { + float compensate_scale = mat4_to_scale(cmat); + compensate_radius = cu->ext2 / cu_active->ext2 * compensate_scale; + do_radius = true; + } + LISTBASE_FOREACH (Nurb *, nu, &cu->nurb) { Nurb *newnu = BKE_nurb_duplicate(nu); if (ob_active->totcol) { /* TODO, merge material lists */ @@ -6895,6 +6906,11 @@ int ED_curve_join_objects_exec(bContext *C, wmOperator *op) if ((bezt = newnu->bezt)) { a = newnu->pntsu; while (a--) { + /* Compensate for different bevel depth. */ + if (do_radius) { + bezt->radius *= compensate_radius; + } + mul_m4_v3(cmat, bezt->vec[0]); mul_m4_v3(cmat, bezt->vec[1]); mul_m4_v3(cmat, bezt->vec[2]); |