diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-08-27 07:20:40 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-08-27 07:20:40 +0300 |
commit | 21c75bc7c560b65c1ed6fe2a7ba05d3fb59dadc6 (patch) | |
tree | 236bd61236c735890a0936ff59b7983a1664735f /source/blender/editors | |
parent | 21589dcbe01809de5c3bb4ec294a7dc3c3cf8c4e (diff) |
GP: replace custom API w/ BKE_deform API
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/gpencil/gpencil_brush.c | 15 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_data.c | 12 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_utils.c | 15 |
3 files changed, 23 insertions, 19 deletions
diff --git a/source/blender/editors/gpencil/gpencil_brush.c b/source/blender/editors/gpencil/gpencil_brush.c index 4ab344c7861..6eff4d3687f 100644 --- a/source/blender/editors/gpencil/gpencil_brush.c +++ b/source/blender/editors/gpencil/gpencil_brush.c @@ -57,6 +57,7 @@ #include "DNA_object_types.h" #include "BKE_context.h" +#include "BKE_deform.h" #include "BKE_gpencil.h" #include "BKE_library.h" #include "BKE_report.h" @@ -897,14 +898,8 @@ static bool gp_brush_weight_apply( } } /* get current weight */ - float curweight = 0.0f; - for (int i = 0; i < dvert->totweight; i++) { - MDeformWeight *gpw = &dvert->dw[i]; - if (gpw->def_nr == gso->vrgroup) { - curweight = gpw->weight; - break; - } - } + MDeformWeight *dw = defvert_verify_index(dvert, gso->vrgroup); + float curweight = dw ? dw->weight : 0.0f; if (gp_brush_invert_check(gso)) { /* reduce weight */ @@ -916,7 +911,9 @@ static bool gp_brush_weight_apply( } CLAMP(curweight, 0.0f, 1.0f); - BKE_gpencil_vgroup_add_point_weight(dvert, gso->vrgroup, curweight); + if (dw) { + dw->weight = curweight; + } /* weight should stay within [0.0, 1.0] */ if (pt->pressure < 0.0f) diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c index 006e2679c8c..d7e58609d2d 100644 --- a/source/blender/editors/gpencil/gpencil_data.c +++ b/source/blender/editors/gpencil/gpencil_data.c @@ -1764,10 +1764,8 @@ static int gpencil_vertex_group_smooth_exec(bContext *C, wmOperator *op) ptc = &gps->points[i]; } - float wa = BKE_gpencil_vgroup_use_index(dverta, def_nr); - float wb = BKE_gpencil_vgroup_use_index(dvertb, def_nr); - CLAMP_MIN(wa, 0.0f); - CLAMP_MIN(wb, 0.0f); + float wa = defvert_find_weight(dverta, def_nr); + float wb = defvert_find_weight(dvertb, def_nr); /* the optimal value is the corresponding to the interpolation of the weight * at the distance of point b @@ -1775,8 +1773,10 @@ static int gpencil_vertex_group_smooth_exec(bContext *C, wmOperator *op) const float opfac = line_point_factor_v3(&ptb->x, &pta->x, &ptc->x); const float optimal = interpf(wa, wb, opfac); /* Based on influence factor, blend between original and optimal */ - wb = interpf(wb, optimal, fac); - BKE_gpencil_vgroup_add_point_weight(dvertb, def_nr, wb); + MDeformWeight *dw = defvert_verify_index(dvertb, def_nr); + if (dw) { + dw->weight = interpf(wb, optimal, fac); + } } } } diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c index 3e05dcc3004..06747798ec7 100644 --- a/source/blender/editors/gpencil/gpencil_utils.c +++ b/source/blender/editors/gpencil/gpencil_utils.c @@ -50,6 +50,7 @@ #include "DNA_view3d_types.h" #include "BKE_action.h" +#include "BKE_deform.h" #include "BKE_main.h" #include "BKE_brush.h" #include "BKE_context.h" @@ -1225,7 +1226,10 @@ void ED_gpencil_vgroup_assign(bContext *C, Object *ob, float weight) bGPDspoint *pt = &gps->points[i]; MDeformVert *dvert = &gps->dvert[i]; if (pt->flag & GP_SPOINT_SELECT) { - BKE_gpencil_vgroup_add_point_weight(dvert, def_nr, weight); + MDeformWeight *dw = defvert_verify_index(dvert, def_nr); + if (dw) { + dw->weight = weight; + } } } } @@ -1250,7 +1254,10 @@ void ED_gpencil_vgroup_remove(bContext *C, Object *ob) MDeformVert *dvert = &gps->dvert[i]; if ((pt->flag & GP_SPOINT_SELECT) && (dvert->totweight > 0)) { - BKE_gpencil_vgroup_remove_point_weight(dvert, def_nr); + MDeformWeight *dw = defvert_find_index(dvert, def_nr); + if (dw != NULL) { + defvert_remove_group(dvert, dw); + } } } } @@ -1273,7 +1280,7 @@ void ED_gpencil_vgroup_select(bContext *C, Object *ob) } MDeformVert *dvert = &gps->dvert[i]; - if (BKE_gpencil_vgroup_use_index(dvert, def_nr) > -1.0f) { + if (defvert_find_index(dvert, def_nr) != NULL) { pt->flag |= GP_SPOINT_SELECT; gps->flag |= GP_STROKE_SELECT; } @@ -1298,7 +1305,7 @@ void ED_gpencil_vgroup_deselect(bContext *C, Object *ob) } MDeformVert *dvert = &gps->dvert[i]; - if (BKE_gpencil_vgroup_use_index(dvert, def_nr) > -1.0f) { + if (defvert_find_index(dvert, def_nr) != NULL) { pt->flag &= ~GP_SPOINT_SELECT; gps->flag |= GP_STROKE_SELECT; } |