Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorAntonioya <blendergit@gmail.com>2018-12-20 14:35:06 +0300
committerAntonioya <blendergit@gmail.com>2018-12-20 14:37:12 +0300
commite79f401ffa7d5354dde01073bbb4b7dd742fd32b (patch)
tree208a8959c598e295b14106317aba0c725bff3b09 /source
parentc02f67fa8ae56c8b9e5015b0228de9844a015b71 (diff)
GP: New Python update API functions (WIP)
For strokes: myframe.strokes.update(mystroke) For datablock: gpencil = bpy.data.grease_pencil['gpencil'] gpencil.update() Still need a manual refresh of viewport.
Diffstat (limited to 'source')
-rw-r--r--source/blender/makesrna/intern/rna_gpencil.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c
index 9c90628f262..5acfa6c1b47 100644
--- a/source/blender/makesrna/intern/rna_gpencil.c
+++ b/source/blender/makesrna/intern/rna_gpencil.c
@@ -596,6 +596,18 @@ static void rna_GPencil_stroke_remove(bGPDframe *frame, ReportList *reports, Poi
WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL);
}
+static void rna_GPencil_stroke_update(bGPDframe *frame, ReportList *reports, PointerRNA *stroke_ptr)
+{
+ bGPDstroke *stroke = stroke_ptr->data;
+ if (BLI_findindex(&frame->strokes, stroke) == -1) {
+ BKE_report(reports, RPT_ERROR, "Stroke not found in grease pencil frame");
+ return;
+ }
+ stroke->flag |= GP_STROKE_RECALC_CACHES;
+
+ WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
+}
+
static void rna_GPencil_stroke_select_set(PointerRNA *ptr, const bool value)
{
bGPDstroke *gps = ptr->data;
@@ -725,6 +737,14 @@ static void rna_GPencil_clear(bGPdata *gpd)
WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
}
+static void rna_GPencil_update_data(bGPdata *gpd)
+{
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_COPY_ON_WRITE);
+
+ WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL);
+}
+
static void rna_GpencilVertex_groups_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
bGPDstroke *gps = ptr->data;
@@ -992,6 +1012,13 @@ static void rna_def_gpencil_strokes_api(BlenderRNA *brna, PropertyRNA *cprop)
parm = RNA_def_pointer(func, "stroke", "GPencilStroke", "Stroke", "The stroke to remove");
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
+
+ func = RNA_def_function(srna, "update", "rna_GPencil_stroke_update");
+ RNA_def_function_ui_description(func, "Update stroke geometry");
+ RNA_def_function_flag(func, FUNC_USE_REPORTS);
+ parm = RNA_def_pointer(func, "stroke", "GPencilStroke", "Stroke", "The stroke to remove");
+ RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
+ RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
}
static void rna_def_gpencil_frame(BlenderRNA *brna)
@@ -1628,6 +1655,9 @@ static void rna_def_gpencil_data(BlenderRNA *brna)
/* API Functions */
func = RNA_def_function(srna, "clear", "rna_GPencil_clear");
RNA_def_function_ui_description(func, "Remove all the Grease Pencil data");
+
+ func = RNA_def_function(srna, "update", "rna_GPencil_update_data");
+ RNA_def_function_ui_description(func, "Force internal data update");
}
/* --- */