Commit: 34c97a1b003143bb79e8b08dec339b9ad13a17f6
Author: Campbell Barton
Date:   Mon Aug 27 16:02:41 2018 +1000
Branches: blender2.8
https://developer.blender.org/rB34c97a1b003143bb79e8b08dec339b9ad13a17f6

Cleanup: rename 'vindex' to 'def_nr'

Name hinted 'vertex index', where it's the index of the vertex group.

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

M       source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c
M       source/blender/gpencil_modifiers/intern/MOD_gpencil_util.h
M       source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c
M       source/blender/gpencil_modifiers/intern/MOD_gpencillattice.c
M       source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c
M       source/blender/gpencil_modifiers/intern/MOD_gpenciloffset.c
M       source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c
M       source/blender/gpencil_modifiers/intern/MOD_gpencilsmooth.c
M       source/blender/gpencil_modifiers/intern/MOD_gpencilthick.c

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

diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c 
b/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c
index d702443f022..610465c4c94 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c
@@ -122,12 +122,12 @@ bool is_stroke_affected_by_modifier(
 }
 
 /* verify if valid vertex group *and return weight */
-float get_modifier_point_weight(MDeformVert *dvert, int inverse, int vindex)
+float get_modifier_point_weight(MDeformVert *dvert, bool inverse, int def_nr)
 {
        float weight = 1.0f;
 
-       if (vindex >= 0) {
-               MDeformWeight *dw = defvert_find_index(dvert, vindex);
+       if (def_nr != -1) {
+               MDeformWeight *dw = defvert_find_index(dvert, def_nr);
                weight = dw ? dw->weight : -1.0f;
                if ((weight >= 0.0f) && (inverse == 1)) {
                        return -1.0f;
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.h 
b/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.h
index 1ca9febbdca..f2866be1391 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.h
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.h
@@ -45,7 +45,7 @@ bool is_stroke_affected_by_modifier(
         struct Object *ob, char *mlayername, int mpassindex, int minpoints,
         bGPDlayer *gpl, bGPDstroke *gps, bool inv1, bool inv2);
 
-float get_modifier_point_weight(struct MDeformVert *dvert, int inverse, int 
vindex);
+float get_modifier_point_weight(struct MDeformVert *dvert, bool inverse, int 
def_nr);
 
 void gpencil_apply_modifier_material(
        struct Main *bmain, struct Object *ob, struct Material *mat,
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c 
b/source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c
index 46d452545e2..1ba2a08acdb 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c
@@ -203,8 +203,7 @@ static void deformStroke(
                return;
        }
 
-       int vindex = defgroup_name_index(ob, mmd->vgname);
-       float weight = 1.0f;
+       const int def_nr = defgroup_name_index(ob, mmd->vgname);
 
        bPoseChannel *pchan = BKE_pose_channel_find_name(mmd->object->pose, 
mmd->subtarget);
        float dmat[4][4];
@@ -253,8 +252,8 @@ static void deformStroke(
                MDeformVert *dvert = &gps->dvert[i];
 
                /* verify vertex group */
-               weight = get_modifier_point_weight(dvert, (int)((mmd->flag & 
GP_HOOK_INVERT_VGROUP) != 0), vindex);
-               if (weight < 0) {
+               const float weight = get_modifier_point_weight(dvert, 
(mmd->flag & GP_HOOK_INVERT_VGROUP) != 0, def_nr);
+               if (weight < 0.0f) {
                        continue;
                }
                gp_hook_co_apply(&tData, weight, pt);
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencillattice.c 
b/source/blender/gpencil_modifiers/intern/MOD_gpencillattice.c
index 33bdb9c861d..55836dce1cd 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencillattice.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencillattice.c
@@ -79,8 +79,7 @@ static void deformStroke(
         Object *ob, bGPDlayer *gpl, bGPDstroke *gps)
 {
        LatticeGpencilModifierData *mmd = (LatticeGpencilModifierData *)md;
-       int vindex = defgroup_name_index(ob, mmd->vgname);
-       float weight = 1.0f;
+       const int def_nr = defgroup_name_index(ob, mmd->vgname);
 
        if (!is_stroke_affected_by_modifier(ob,
                mmd->layername, mmd->pass_index, 3, gpl, gps,
@@ -98,11 +97,10 @@ static void deformStroke(
                MDeformVert *dvert = &gps->dvert[i];
 
                /* verify vertex group */
-               weight = get_modifier_point_weight(dvert, (int)((mmd->flag & 
GP_LATTICE_INVERT_VGROUP) != 0), vindex);
-               if (weight < 0) {
+               const float weight = get_modifier_point_weight(dvert, 
(mmd->flag & GP_LATTICE_INVERT_VGROUP) != 0, def_nr);
+               if (weight < 0.0f) {
                        continue;
                }
-
                calc_latt_deform((struct LatticeDeformData *)mmd->cache_data, 
&pt->x, mmd->strength * weight);
        }
 }
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c 
b/source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c
index be361498578..d2e74a1de66 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c
@@ -110,8 +110,7 @@ static void deformStroke(
 #endif
        int sc_frame = 0;
        int sc_diff = 0;
-       int vindex = defgroup_name_index(ob, mmd->vgname);
-       float weight = 1.0f;
+       const int def_nr = defgroup_name_index(ob, mmd->vgname);
 
        /* Random generator, only init once. */
        if (mmd->rng == NULL) {
@@ -154,8 +153,8 @@ static void deformStroke(
                }
 
                /* verify vertex group */
-               weight = get_modifier_point_weight(dvert, (int)((mmd->flag & 
GP_NOISE_INVERT_VGROUP) != 0), vindex);
-               if (weight < 0) {
+               const float weight = get_modifier_point_weight(dvert, 
(mmd->flag & GP_NOISE_INVERT_VGROUP) != 0, def_nr);
+               if (weight < 0.0f) {
                        continue;
                }
 
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpenciloffset.c 
b/source/blender/gpencil_modifiers/intern/MOD_gpenciloffset.c
index a31f889c48a..f59056b2845 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpenciloffset.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpenciloffset.c
@@ -72,7 +72,7 @@ static void deformStroke(
         Object *ob, bGPDlayer *gpl, bGPDstroke *gps)
 {
        OffsetGpencilModifierData *mmd = (OffsetGpencilModifierData *)md;
-       int vindex = defgroup_name_index(ob, mmd->vgname);
+       const int def_nr = defgroup_name_index(ob, mmd->vgname);
 
        float mat[4][4];
        float loc[3], rot[3], scale[3];
@@ -89,8 +89,8 @@ static void deformStroke(
                MDeformVert *dvert = &gps->dvert[i];
 
                /* verify vertex group */
-               float weight = get_modifier_point_weight(dvert, 
(int)((mmd->flag & GP_OFFSET_INVERT_VGROUP) != 0), vindex);
-               if (weight < 0) {
+               const float weight = get_modifier_point_weight(dvert, 
(mmd->flag & GP_OFFSET_INVERT_VGROUP) != 0, def_nr);
+               if (weight < 0.0f) {
                        continue;
                }
                /* calculate matrix */
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c 
b/source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c
index e0484e19959..5c177077a98 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c
@@ -75,7 +75,7 @@ static void deformStroke(
         Object *ob, bGPDlayer *gpl, bGPDstroke *gps)
 {
        OpacityGpencilModifierData *mmd = (OpacityGpencilModifierData *)md;
-       int vindex = defgroup_name_index(ob, mmd->vgname);
+       const int def_nr = defgroup_name_index(ob, mmd->vgname);
 
        if (!is_stroke_affected_by_modifier(
                    ob,
@@ -110,8 +110,8 @@ static void deformStroke(
                        MDeformVert *dvert = &gps->dvert[i];
 
                        /* verify vertex group */
-                       float weight = get_modifier_point_weight(dvert, 
((mmd->flag & GP_OPACITY_INVERT_VGROUP) != 0), vindex);
-                       if (weight < 0) {
+                       const float weight = get_modifier_point_weight(dvert, 
(mmd->flag & GP_OPACITY_INVERT_VGROUP) != 0, def_nr);
+                       if (weight < 0.0f) {
                                pt->strength += mmd->factor - 1.0f;
                        }
                        else {
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilsmooth.c 
b/source/blender/gpencil_modifiers/intern/MOD_gpencilsmooth.c
index b5f2f0349af..d6a0721129d 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilsmooth.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilsmooth.c
@@ -67,9 +67,7 @@ static void deformStroke(
         Object *ob, bGPDlayer *gpl, bGPDstroke *gps)
 {
        SmoothGpencilModifierData *mmd = (SmoothGpencilModifierData *)md;
-       int vindex = defgroup_name_index(ob, mmd->vgname);
-       float weight = 1.0f;
-       float val;
+       const int def_nr = defgroup_name_index(ob, mmd->vgname);
 
        if (!is_stroke_affected_by_modifier(ob,
                mmd->layername, mmd->pass_index, 3, gpl, gps,
@@ -86,12 +84,13 @@ static void deformStroke(
                                MDeformVert *dvert = &gps->dvert[i];
 
                                /* verify vertex group */
-                               weight = get_modifier_point_weight(dvert, 
(int)((mmd->flag & GP_SMOOTH_INVERT_VGROUP) != 0), vindex);
-                               if (weight < 0) {
+                               const float weight = get_modifier_point_weight(
+                                       dvert, (mmd->flag & 
GP_SMOOTH_INVERT_VGROUP) != 0, def_nr);
+                               if (weight < 0.0f) {
                                        continue;
                                }
 
-                               val = mmd->factor * weight;
+                               const float val = mmd->factor * weight;
                                /* perform smoothing */
                                if (mmd->flag & GP_SMOOTH_MOD_LOCATION) {
                                        BKE_gpencil_smooth_stroke(gps, i, val);
@@ -99,7 +98,7 @@ static void deformStroke(
                                if (mmd->flag & GP_SMOOTH_MOD_STRENGTH) {
                                        BKE_gpencil_smooth_stroke_strength(gps, 
i, val);
                                }
-                               if ((mmd->flag & GP_SMOOTH_MOD_THICKNESS)  && 
(val > 0)) {
+                               if ((mmd->flag & GP_SMOOTH_MOD_THICKNESS)  && 
(val > 0.0f)) {
                                        /* thickness need to repeat process 
several times */
                                        for (int r2 = 0; r2 < r * 10; r2++) {
                                                
BKE_gpencil_smooth_stroke_thickness(gps, i, val);
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilthick.c 
b/source/blender/gpencil_modifiers/intern/MOD_gpencilthick.c
index 2c01fec1357..3b5f4dbf7c7 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilthick.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilthick.c
@@ -92,7 +92,7 @@ static void deformStroke(
         Object *ob, bGPDlayer *gpl, bGPDstroke *gps)
 {
        ThickGpencilModifierData *mmd = (ThickGpencilModifierData *)md;
-       int vindex = defgroup_name_index(ob, mmd->vgname);
+       const int def_nr = defgroup_name_index(ob, mmd->vgname);
 
        if (!is_stroke_affected_by_modifier(ob,
                mmd->layername, mmd->pass_index, 3, gpl, gps,
@@ -111,8 +111,8 @@ static void deformStroke(
                MDeformVert *dvert = &gps->dvert[i];
                float curvef = 1.0f;
                /* verify vertex group */
-               float weight = get_modifier_point_weight(dvert, 
(int)((mmd->flag & GP_THICK_INVERT_VGROUP) != 0), vindex);
-               if (weight < 0) {
+               const float weight = get_modifier_point_weight(dvert, 
(mmd->flag & GP_THICK_INVERT_VGROUP) != 0, def_nr);
+               if (weight < 0.0f) {
                        continue;
                }

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

Reply via email to