[Bf-blender-cvs] [1aeeb0bd699] greasepencil-object: Remove and move weight when remove vertex group
Antonio Vazquez
noreply at git.blender.org
Mon Jul 31 13:19:38 CEST 2017
Commit: 1aeeb0bd699056b308350f7c58a3fab4248ece39
Author: Antonio Vazquez
Date: Mon Jul 31 11:34:51 2017 +0200
Branches: greasepencil-object
https://developer.blender.org/rB1aeeb0bd699056b308350f7c58a3fab4248ece39
Remove and move weight when remove vertex group
When remove a vertex group, moves the index of other weights
===================================================================
M source/blender/blenkernel/intern/gpencil.c
===================================================================
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index 80e79fe3e80..95bfdf661fa 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -1694,7 +1694,33 @@ BoundBox *BKE_gpencil_boundbox_get(Object *ob)
/* remove a vertex group */
void BKE_gpencil_vgroup_remove(Object *ob, bDeformGroup *defgroup)
{
+ bGPdata *gpd = ob->gpd;
+ bGPDspoint *pt = NULL;
+ bGPDweight *gpw = NULL;
+ const int def_nr = BLI_findindex(&ob->defbase, defgroup);
+
/* Remove points data */
+ if (gpd) {
+ for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
+ for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf->next) {
+ for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
+ for (int i = 0; i < gps->totpoints; ++i) {
+ pt = &gps->points[i];
+ for (int i2 = 0; i2 < pt->totweight; ++i2) {
+ gpw = &pt->weights[i2];
+ if (gpw->index == def_nr) {
+ BKE_gpencil_vgroup_remove_point_weight(pt, def_nr);
+ }
+ /* if index is greater, must be moved one back */
+ if (gpw->index > def_nr) {
+ --gpw->index;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
/* Remove the group */
BLI_freelinkN(&ob->defbase, defgroup);
More information about the Bf-blender-cvs
mailing list