[Bf-blender-cvs] [2b64b4d90d6] master: Fix T90973: GPencil - Add buttons to move up and down vertex groups

Antonio Vazquez noreply at git.blender.org
Thu Aug 26 22:00:28 CEST 2021


Commit: 2b64b4d90d677dd0055f966814df76486ebbd7dc
Author: Antonio Vazquez
Date:   Thu Aug 26 21:57:59 2021 +0200
Branches: master
https://developer.blender.org/rB2b64b4d90d677dd0055f966814df76486ebbd7dc

Fix T90973: GPencil - Add buttons to move up and down vertex groups


These buttons were in Meshes but not for Grease Pencil. This patch add them in order to keep consistency.

Reviewed By: HooglyBoogly

Maniphest Tasks: T90973

Differential Revision: https://developer.blender.org/D12328

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

M	release/scripts/startup/bl_ui/properties_data_gpencil.py
M	source/blender/editors/object/object_vgroup.c

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

diff --git a/release/scripts/startup/bl_ui/properties_data_gpencil.py b/release/scripts/startup/bl_ui/properties_data_gpencil.py
index b273eee4e19..793c4a52350 100644
--- a/release/scripts/startup/bl_ui/properties_data_gpencil.py
+++ b/release/scripts/startup/bl_ui/properties_data_gpencil.py
@@ -342,6 +342,11 @@ class DATA_PT_gpencil_vertex_groups(ObjectButtonsPanel, Panel):
         col.operator("object.vertex_group_add", icon='ADD', text="")
         col.operator("object.vertex_group_remove", icon='REMOVE', text="").all = False
 
+        if group:
+            col.separator()
+            col.operator("object.vertex_group_move", icon='TRIA_UP', text="").direction = 'UP'
+            col.operator("object.vertex_group_move", icon='TRIA_DOWN', text="").direction = 'DOWN'
+
         if ob.vertex_groups:
             row = layout.row()
 
diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c
index 7a42c9d5d8b..f0ab082cd9c 100644
--- a/source/blender/editors/object/object_vgroup.c
+++ b/source/blender/editors/object/object_vgroup.c
@@ -28,6 +28,7 @@
 #include "MEM_guardedalloc.h"
 
 #include "DNA_curve_types.h"
+#include "DNA_gpencil_types.h"
 #include "DNA_lattice_types.h"
 #include "DNA_mesh_types.h"
 #include "DNA_meshdata_types.h"
@@ -39,6 +40,7 @@
 #include "BLI_alloca.h"
 #include "BLI_array.h"
 #include "BLI_blenlib.h"
+#include "BLI_listbase.h"
 #include "BLI_math.h"
 #include "BLI_utildefines.h"
 #include "BLI_utildefines_stack.h"
@@ -4083,16 +4085,38 @@ static int vgroup_do_remap(Object *ob, const char *name_array, wmOperator *op)
   }
   else {
     int dvert_tot = 0;
+    /* Grease pencil stores vertex groups separately for each stroke,
+     * so remap each stroke's weights separately. */
+    if (ob->type == OB_GPENCIL) {
+      bGPdata *gpd = ob->data;
+      LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
+        LISTBASE_FOREACH (bGPDframe *, gpf, &gpl->frames) {
+          LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
+            dvert = gps->dvert;
+            dvert_tot = gps->totpoints;
+            if (dvert) {
+              while (dvert_tot--) {
+                if (dvert->totweight) {
+                  BKE_defvert_remap(dvert, sort_map, defbase_tot);
+                }
+                dvert++;
+              }
+            }
+          }
+        }
+      }
+    }
+    else {
+      BKE_object_defgroup_array_get(ob->data, &dvert, &dvert_tot);
 
-    BKE_object_defgroup_array_get(ob->data, &dvert, &dvert_tot);
-
-    /* Create as necessary. */
-    if (dvert) {
-      while (dvert_tot--) {
-        if (dvert->totweight) {
-          BKE_defvert_remap(dvert, sort_map, defbase_tot);
+      /* Create as necessary. */
+      if (dvert) {
+        while (dvert_tot--) {
+          if (dvert->totweight) {
+            BKE_defvert_remap(dvert, sort_map, defbase_tot);
+          }
+          dvert++;
         }
-        dvert++;
       }
     }
   }



More information about the Bf-blender-cvs mailing list