diff options
author | Antonio Vazquez <blendergit@gmail.com> | 2021-09-20 12:10:31 +0300 |
---|---|---|
committer | Jeroen Bakker <jeroen@blender.org> | 2021-09-22 09:31:44 +0300 |
commit | cc31c159a1501b25df014a9b39b720e4ef8d53b3 (patch) | |
tree | 092747b43fd323b9331f833bc8d148d102745b8e | |
parent | 8235d4dea677b86804bd81bfc44a69b08ab4013c (diff) |
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,
-rw-r--r-- | source/blender/makesrna/intern/rna_gpencil.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c index 1fbbffa99d5..44de5955c41 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; |