[Bf-blender-cvs] [1f51672d712] master: Fix T91511: GPencil weight_get and Vertex Groups not working at expected

Antonio Vazquez noreply at git.blender.org
Mon Sep 20 11:10:51 CEST 2021


Commit: 1f51672d7126d8c0a0b962060c01632e6e07dd5f
Author: Antonio Vazquez
Date:   Mon Sep 20 11:10:31 2021 +0200
Branches: master
https://developer.blender.org/rB1f51672d7126d8c0a0b962060c01632e6e07dd5f

Fix T91511: GPencil weight_get and Vertex Groups not working at expected

The API was checking the number of total weights with the first point of the stroke and this was not valid because each point can have different number of weight elemnts,

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

M	source/blender/makesrna/intern/rna_gpencil.c

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

diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c
index f06c8a5325c..2bce5f3f4b3 100644
--- a/source/blender/makesrna/intern/rna_gpencil.c
+++ b/source/blender/makesrna/intern/rna_gpencil.c
@@ -843,17 +843,17 @@ static float rna_GPencilStrokePoints_weight_get(bGPDstroke *stroke,
     return -1.0f;
   }
 
-  if (dvert->totweight <= vertex_group_index || vertex_group_index < 0) {
-    BKE_report(reports, RPT_ERROR, "Groups: index out of range");
-    return -1.0f;
-  }
-
   if (stroke->totpoints <= point_index || point_index < 0) {
     BKE_report(reports, RPT_ERROR, "GPencilStrokePoints: index out of range");
     return -1.0f;
   }
 
   MDeformVert *pt_dvert = stroke->dvert + point_index;
+  if ((pt_dvert) && (pt_dvert->totweight <= vertex_group_index || vertex_group_index < 0)) {
+    BKE_report(reports, RPT_ERROR, "Groups: index out of range");
+    return -1.0f;
+  }
+
   MDeformWeight *dw = BKE_defvert_find_index(pt_dvert, vertex_group_index);
   if (dw) {
     return dw->weight;



More information about the Bf-blender-cvs mailing list