diff options
author | Germano Cavalcante <germano.costa@ig.com.br> | 2022-10-23 01:31:57 +0300 |
---|---|---|
committer | Germano Cavalcante <germano.costa@ig.com.br> | 2022-10-23 01:32:06 +0300 |
commit | b70bbfadfecec049ad1ac2de7a949198ca6c15bc (patch) | |
tree | d1f749170ddfc7ef89558f3677139e8a6a732f97 /source/blender | |
parent | afec1cd33385109ac1ca41177426e7b72e174cda (diff) |
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.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/transform/transform_mode_curveshrinkfatten.c | 17 |
1 files changed, 16 insertions, 1 deletions
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)); + } } /** \} */ |