Maniphest T96799

GPencil: Scripting weight_get cannot retrieve weights of certain vertex groups
Closed, ResolvedBUG

Assigned To
Antonio Vazquez (antoniov)
Authored By
Keny Chatain (KenyC)
Mar 26 2022, 1:25 PM
Tags
  • BF Blender
  • Grease Pencil
Subscribers
Antonio Vazquez (antoniov)
Keny Chatain (KenyC)
Pratik Borhade (PratikPB2123)

Description

System Information
Operating system: Kubuntu 21.04
Graphics card: AMD Radeon Vega 6 Graphics

Blender Version
Broken: 3.2.0.Alpha (branch: master, commit hash : 6bf51ab03a066f8cf37a061ceb8d5c12bd6ea88d, commit date: Fri, 25 Mar 2022 9:33 PM)

Short description of error

When points of a stroke belong to just one vertex group and the index of that vertex group is not zero, Python API weight_get cannot retrieve weight assigned to points.

Not resolved after T91511.

Exact steps for others to reproduce the error

Run script in attached .blend file (

).

  • Draw two strokes.
  • Create two vertex groups.
  • Assign all points in first stroke to first vertex group group.
  • Assign all points in second stroke to second vertex group.
  • Call to stroke.points.weight_get(0, 0) results in -1.0
  • Call to stroke.points.weight_get(1, 0) throws Groups: index out of range

It seems that the code in rna_GPencilStrokePoints_weight_get interprets vertex_group_index in two different ways: index in dw array MDeformVert and index of vertex group in object. It checks bounds wrt totweight but gives weights associated. I have a fix ; I'll see if I can figure out how to attach it here.

Revisions and Commits

rB Blender

Related Objects

Mentioned In
T96241: 3.1: Potential candidates for corrective releases
Mentioned Here
rB6bf51ab03a06: CMake: Give some extra space to info_cfg_option

Event Timeline

Keny Chatain (KenyC) created this task.Mar 26 2022, 1:25 PM
Pratik Borhade (PratikPB2123) changed the task status from Needs Triage to Confirmed.Mar 28 2022, 7:57 AM
Pratik Borhade (PratikPB2123) added a project: Grease Pencil.
Pratik Borhade (PratikPB2123) added a subscriber: Pratik Borhade (PratikPB2123).
Antonio Vazquez (antoniov) changed the task status from Confirmed to Needs Information from User.Mar 29 2022, 10:53 AM
Antonio Vazquez (antoniov) added a subscriber: Antonio Vazquez (antoniov).

I cannot reproduce. I guess you are mixing things in your script. I have done a test file to verify the weight API.

This blend file has a stroke with two vertex group. The first vertex group has assigned a weight of 1.0 to all points. The second vertex group has a 0.5 value for all points. Running the script you get this:

Antonio Vazquez (antoniov) changed the task status from Needs Information from User to Confirmed.Mar 29 2022, 11:14 AM
Antonio Vazquez (antoniov) claimed this task.

I looked again and I was testing the wrong thing.

Keny Chatain (KenyC) added a comment.Mar 29 2022, 11:18 AM

Indeed, the problem does not arise when there is just one stroke. Looking at the code, the one stroke vs. two strokes difference makes sense. As I understand it, weight_get checks bounds on vertex_group_index wrt totweight, which is the total number of vertex groups associated with the *stroke*, not the *object*.

Antonio Vazquez (antoniov) changed the subtype of this task from "Report" to "Bug".Mar 29 2022, 11:21 AM
In T96799#1331389, @Keny Chatain (KenyC) wrote:

Indeed, the problem does not arise when there is just one stroke. Looking at the code, the one stroke vs. two strokes difference makes sense. As I understand it, weight_get checks bounds on vertex_group_index wrt totweight, which is the total number of vertex groups associated with the *stroke*, not the *object*.

Yes, this is the problem... Fixing it!

Antonio Vazquez (antoniov) closed this task as Resolved by committing rB9450057b43cb: Fix T96799: GPencil `weight_get` API cannot retrieve weights.Mar 29 2022, 11:27 AM
Antonio Vazquez (antoniov) added a commit: rB9450057b43cb: Fix T96799: GPencil `weight_get` API cannot retrieve weights.
Philipp Oeser (lichtwerk) added a commit: rB343fc38b8d64: Fix T96799: GPencil `weight_get` API cannot retrieve weights.Mar 29 2022, 4:35 PM