diff options
author | Antonio Vazquez <blendergit@gmail.com> | 2021-02-05 21:14:35 +0300 |
---|---|---|
committer | Antonio Vazquez <blendergit@gmail.com> | 2021-02-05 21:15:12 +0300 |
commit | faf45091b454bb99089e82533b12b549efb1a5c7 (patch) | |
tree | 760e42f79440d3252b6fcd6e59b627df74d677ff /source/blender/makesrna/intern | |
parent | 5dc87a3ca5f32b87d3cdf5f54a9d3a30f5b4fae0 (diff) |
GPencil: New python API to force stroke triangulation data update
In some python scripts, the coordinates of the points are manipulated, but there are no way to force the recalculation and need hack to force the refresh.
The new api allows to call to the refresh function directly.
example: `gp_stroke.points.update()`
Diffstat (limited to 'source/blender/makesrna/intern')
-rw-r--r-- | source/blender/makesrna/intern/rna_gpencil.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c index 209dc21d386..4d9c53df013 100644 --- a/source/blender/makesrna/intern/rna_gpencil.c +++ b/source/blender/makesrna/intern/rna_gpencil.c @@ -816,6 +816,21 @@ static void rna_GPencil_stroke_point_pop(ID *id, WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL); } +static void rna_GPencil_stroke_point_update(ID *id, bGPDstroke *stroke) +{ + bGPdata *gpd = (bGPdata *)id; + + /* Calc geometry data. */ + if (stroke) { + BKE_gpencil_stroke_geometry_update(gpd, stroke); + + DEG_id_tag_update(&gpd->id, + ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_COPY_ON_WRITE); + + WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL); + } +} + static bGPDstroke *rna_GPencil_stroke_new(bGPDframe *frame) { bGPDstroke *stroke = BKE_gpencil_stroke_new(0, 0, 1.0f); @@ -1274,6 +1289,10 @@ static void rna_def_gpencil_stroke_points_api(BlenderRNA *brna, PropertyRNA *cpr RNA_def_function_ui_description(func, "Remove a grease pencil stroke point"); RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID); RNA_def_int(func, "index", -1, INT_MIN, INT_MAX, "Index", "point index", INT_MIN, INT_MAX); + + func = RNA_def_function(srna, "update", "rna_GPencil_stroke_point_update"); + RNA_def_function_ui_description(func, "Recalculate internal triangulation data"); + RNA_def_function_flag(func, FUNC_USE_SELF_ID); } /* This information is read only and it can be used by add-ons */ |