Cleanup: rename 'vindex' to 'def_nr'
Name hinted 'vertex index', where it's the index of the vertex group.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user