Fix T60677: GP vertex groups get messed up, when deleting a group

This commit is contained in:
Antonio Vazquez 2019-01-20 20:31:11 +01:00
parent 6e57534eaa
commit 6e443b3210
Notes: blender-bot 2023-02-14 05:51:15 +01:00
Referenced by issue #60677, GP vertex groups get messed up, when deleting a group
2 changed files with 11 additions and 2 deletions

View File

@ -1209,6 +1209,15 @@ void BKE_gpencil_vgroup_remove(Object *ob, bDeformGroup *defgroup)
if (dw != NULL) {
defvert_remove_group(dvert, dw);
}
else {
/* reorganize weights in other strokes */
for (int g = 0; g < gps->dvert->totweight; g++) {
MDeformWeight *dw = &dvert->dw[g];
if ((dw != NULL) && (dw->def_nr > def_nr)) {
dw->def_nr--;
}
}
}
}
}
}

View File

@ -586,7 +586,7 @@ void DRW_gpencil_get_edit_geom(struct GpencilBatchCacheElem *be, bGPDstroke *gps
for (int i = 0; i < gps->totpoints; i++, pt++) {
/* weight paint */
if (is_weight_paint) {
float weight = (dvert && dvert->dw) ? defvert_find_weight(dvert, vgindex) : 0.0f;
float weight = (dvert && dvert->dw && (vgindex > -1)) ? defvert_find_weight(dvert, vgindex) : 0.0f;
float hue = 2.0f * (1.0f - weight) / 3.0f;
hsv_to_rgb(hue, 1.0f, 1.0f, &selectColor[0], &selectColor[1], &selectColor[2]);
selectColor[3] = 1.0f;
@ -661,7 +661,7 @@ void DRW_gpencil_get_edlin_geom(struct GpencilBatchCacheElem *be, bGPDstroke *gp
for (int i = 0; i < gps->totpoints; i++, pt++) {
/* weight paint */
if (is_weight_paint) {
float weight = (dvert && dvert->dw) ? defvert_find_weight(dvert, vgindex) : 0.0f;
float weight = (dvert && dvert->dw && (vgindex > -1)) ? defvert_find_weight(dvert, vgindex) : 0.0f;
float hue = 2.0f * (1.0f - weight) / 3.0f;
hsv_to_rgb(hue, 1.0f, 1.0f, &selectColor[0], &selectColor[1], &selectColor[2]);
selectColor[3] = 1.0f;