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,
This commit is contained in:
Antonio Vazquez 2021-09-20 11:10:31 +02:00 committed by Jeroen Bakker
parent 8235d4dea6
commit cc31c159a1
Notes: blender-bot 2023-02-14 07:39:44 +01:00
Referenced by issue #88449: Blender LTS: Maintenance Task 2.93
Referenced by issue #88449, Blender LTS: Maintenance Task 2.93
Referenced by issue #91511, GPencil: Scripting weight_get and Vertex Groups not working at expected with several groups
1 changed files with 5 additions and 5 deletions

View File

@ -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;