[Bf-blender-cvs] [b70bbfadfec] master: Fix T102000: Curve Shrink Fatten doesn't work for zero radius

Germano Cavalcante noreply at git.blender.org
Sun Oct 23 00:33:08 CEST 2022


Commit: b70bbfadfecec049ad1ac2de7a949198ca6c15bc
Author: Germano Cavalcante
Date:   Sat Oct 22 19:31:57 2022 -0300
Branches: master
https://developer.blender.org/rBb70bbfadfecec049ad1ac2de7a949198ca6c15bc

Fix T102000: Curve Shrink Fatten doesn't work for zero radius

Kind of intentional regression on rB2d1fe736fabd.

But the solution now is (theoretically) better than adding a hard coded
threshold.

For cases with zero radius, the new radius is now the offset of the
ratio projected onto the plane of the origin point.

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

M	source/blender/editors/transform/transform_mode_curveshrinkfatten.c

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

diff --git a/source/blender/editors/transform/transform_mode_curveshrinkfatten.c b/source/blender/editors/transform/transform_mode_curveshrinkfatten.c
index f7f9e14b8ac..76ce7b29619 100644
--- a/source/blender/editors/transform/transform_mode_curveshrinkfatten.c
+++ b/source/blender/editors/transform/transform_mode_curveshrinkfatten.c
@@ -8,6 +8,7 @@
 #include <stdlib.h>
 
 #include "BLI_math.h"
+#include "BLI_math_bits.h"
 #include "BLI_string.h"
 
 #include "BKE_context.h"
@@ -62,7 +63,14 @@ static void applyCurveShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
       }
 
       if (td->val) {
-        *td->val = td->ival * ratio;
+        if (td->ival == 0.0f && ratio > 1.0f) {
+          /* Allow Shrink/Fatten for zero radius. */
+          *td->val = (ratio - 1.0f) * uint_as_float(POINTER_AS_UINT(t->custom.mode.data));
+        }
+        else {
+          *td->val = td->ival * ratio;
+        }
+
         /* apply PET */
         *td->val = interpf(*td->val, td->ival, td->factor);
         CLAMP_MIN(*td->val, 0.0f);
@@ -92,6 +100,13 @@ void initCurveShrinkFatten(TransInfo *t)
   t->num.unit_type[0] = B_UNIT_NONE;
 
   t->flag |= T_NO_CONSTRAINT;
+
+  if ((t->spacetype == SPACE_VIEW3D) && (t->region->regiontype == RGN_TYPE_WINDOW)) {
+    /* Save a factor to multiply the ratio and use in zero radius cases. */
+    RegionView3D *rv3d = t->region->regiondata;
+    float scale_factor = rv3d->pixsize * t->mouse.factor * t->zfac;
+    t->custom.mode.data = POINTER_FROM_UINT(float_as_uint(scale_factor));
+  }
 }
 
 /** \} */



More information about the Bf-blender-cvs mailing list