Commit: d5a705873e11510950b899caebd43ba47d69ccfa
Author: Philipp Oeser
Date:   Wed Mar 17 09:21:32 2021 +0100
Branches: master
https://developer.blender.org/rBd5a705873e11510950b899caebd43ba47d69ccfa

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

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

M       source/blender/editors/curve/editcurve.c

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

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]);

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to