diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/draw/engines/gpencil/gpencil_cache_utils.c | 4 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_gpencil_types.h | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_gpencil.c | 23 |
3 files changed, 27 insertions, 2 deletions
diff --git a/source/blender/draw/engines/gpencil/gpencil_cache_utils.c b/source/blender/draw/engines/gpencil/gpencil_cache_utils.c index 63af8ecc141..e733b7e0f1f 100644 --- a/source/blender/draw/engines/gpencil/gpencil_cache_utils.c +++ b/source/blender/draw/engines/gpencil/gpencil_cache_utils.c @@ -186,6 +186,10 @@ static bool gpencil_batch_cache_valid(GpencilBatchCache *cache, bGPdata *gpd, in else if (gpd->flag & GP_DATA_CACHE_IS_DIRTY) { valid = false; } + else if (gpd->flag & GP_DATA_PYTHON_UPDATED) { + gpd->flag &= ~GP_DATA_PYTHON_UPDATED; + valid = false; + } else if (DRW_gpencil_onion_active(gpd)) { /* if onion, set as dirty always * This reduces performance, but avoid any crash in the multiple diff --git a/source/blender/makesdna/DNA_gpencil_types.h b/source/blender/makesdna/DNA_gpencil_types.h index 934ef4a4829..4ed87a487fc 100644 --- a/source/blender/makesdna/DNA_gpencil_types.h +++ b/source/blender/makesdna/DNA_gpencil_types.h @@ -481,6 +481,8 @@ typedef enum eGPdata_Flag { GP_DATA_UV_ADAPTATIVE = (1 << 19), /* Autolock not active layers */ GP_DATA_AUTOLOCK_LAYERS = (1 << 20), + /* Internal flag for python update */ + GP_DATA_PYTHON_UPDATED = (1 << 21), } eGPdata_Flag; /* gpd->onion_flag */ diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c index 9c90628f262..8c6ad207bc4 100644 --- a/source/blender/makesrna/intern/rna_gpencil.c +++ b/source/blender/makesrna/intern/rna_gpencil.c @@ -500,7 +500,7 @@ static void rna_GPencil_stroke_point_select_set(PointerRNA *ptr, const bool valu } } -static void rna_GPencil_stroke_point_add(bGPDstroke *stroke, int count, float pressure, float strength) +static void rna_GPencil_stroke_point_add(bGPDstroke *stroke, bGPdata *gpd, int count, float pressure, float strength) { if (count > 0) { /* create space at the end of the array for extra points */ @@ -525,10 +525,19 @@ static void rna_GPencil_stroke_point_add(bGPDstroke *stroke, int count, float pr } stroke->totpoints += count; + + stroke->flag |= GP_STROKE_RECALC_CACHES; + + DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY); + + gpd->flag |= GP_DATA_PYTHON_UPDATED; + DEG_id_tag_update(&gpd->id, ID_RECALC_COPY_ON_WRITE); + + WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, NULL); } } -static void rna_GPencil_stroke_point_pop(bGPDstroke *stroke, ReportList *reports, int index) +static void rna_GPencil_stroke_point_pop(bGPDstroke *stroke, ReportList *reports, bGPdata *gpd, int index) { bGPDspoint *pt_tmp = stroke->points; MDeformVert *pt_dvert = stroke->dvert; @@ -571,6 +580,12 @@ static void rna_GPencil_stroke_point_pop(bGPDstroke *stroke, ReportList *reports MEM_freeN(pt_dvert); } + stroke->flag |= GP_STROKE_RECALC_CACHES; + + DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY); + + gpd->flag |= GP_DATA_PYTHON_UPDATED; + DEG_id_tag_update(&gpd->id, ID_RECALC_COPY_ON_WRITE); WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL); } @@ -805,6 +820,8 @@ static void rna_def_gpencil_stroke_points_api(BlenderRNA *brna, PropertyRNA *cpr func = RNA_def_function(srna, "add", "rna_GPencil_stroke_point_add"); RNA_def_function_ui_description(func, "Add a new grease pencil stroke point"); + parm = RNA_def_pointer(func, "gpd", "GreasePencil", "", "Grease pencil datablock"); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); parm = RNA_def_int(func, "count", 1, 0, INT_MAX, "Number", "Number of points to add to the stroke", 0, INT_MAX); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); RNA_def_float(func, "pressure", 1.0f, 0.0f, 1.0f, "Pressure", "Pressure for newly created points", 0.0f, 1.0f); @@ -812,6 +829,8 @@ static void rna_def_gpencil_stroke_points_api(BlenderRNA *brna, PropertyRNA *cpr func = RNA_def_function(srna, "pop", "rna_GPencil_stroke_point_pop"); RNA_def_function_ui_description(func, "Remove a grease pencil stroke point"); + parm = RNA_def_pointer(func, "gpd", "GreasePencil", "", "Grease pencil datablock"); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_int(func, "index", -1, INT_MIN, INT_MAX, "Index", "point index", INT_MIN, INT_MAX); } |