[Bf-blender-cvs] [4e917eeeaff] greasepencil-object: GPencil: New operator to recalculate geometry data
Antonio Vazquez
noreply at git.blender.org
Thu Feb 13 10:08:46 CET 2020
Commit: 4e917eeeaff68aba7319df5e8ed34e54c16a0bb6
Author: Antonio Vazquez
Date: Thu Feb 13 09:56:31 2020 +0100
Branches: greasepencil-object
https://developer.blender.org/rB4e917eeeaff68aba7319df5e8ed34e54c16a0bb6
GPencil: New operator to recalculate geometry data
This operators is uded in special situations when migrate old files. As this is a specila situation, we are not going to add it to menus.
===================================================================
M source/blender/editors/gpencil/gpencil_edit.c
M source/blender/editors/gpencil/gpencil_intern.h
M source/blender/editors/gpencil/gpencil_ops.c
===================================================================
diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c
index 2387eb57421..22e17b98750 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -3690,6 +3690,43 @@ void GPENCIL_OT_reproject(wmOperatorType *ot)
ot->srna, "type", reproject_type, GP_REPROJECT_VIEW, "Projection Type", "");
}
+static int gp_recalc_geometry_exec(bContext *C, wmOperator *op)
+{
+ Object *ob = CTX_data_active_object(C);
+ if ((ob == NULL) || (ob->type != OB_GPENCIL)) {
+ return OPERATOR_CANCELLED;
+ }
+
+ bGPdata *gpd = (bGPdata *)ob->data;
+ LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
+ LISTBASE_FOREACH (bGPDframe *, gpf, &gpl->frames) {
+ LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
+ BKE_gpencil_stroke_geometry_update(gps);
+ }
+ }
+ }
+ /* update changed data */
+ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
+ WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
+ return OPERATOR_FINISHED;
+}
+
+void GPENCIL_OT_recalc_geometry(wmOperatorType *ot)
+{
+
+ /* identifiers */
+ ot->name = "Recalculate internal geometry";
+ ot->idname = "GPENCIL_OT_recalc_geometry";
+ ot->description = "Update all internal geometry data";
+
+ /* callbacks */
+ ot->exec = gp_recalc_geometry_exec;
+ ot->poll = gp_active_layer_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
/* ******************* Stroke subdivide ************************** */
/* helper to smooth */
static void gp_smooth_stroke(bContext *C, wmOperator *op)
diff --git a/source/blender/editors/gpencil/gpencil_intern.h b/source/blender/editors/gpencil/gpencil_intern.h
index 44ec381dc20..f829aa586a9 100644
--- a/source/blender/editors/gpencil/gpencil_intern.h
+++ b/source/blender/editors/gpencil/gpencil_intern.h
@@ -422,6 +422,7 @@ void GPENCIL_OT_snap_to_cursor(struct wmOperatorType *ot);
void GPENCIL_OT_snap_cursor_to_selected(struct wmOperatorType *ot);
void GPENCIL_OT_reproject(struct wmOperatorType *ot);
+void GPENCIL_OT_recalc_geometry(struct wmOperatorType *ot);
/* stroke sculpting -- */
diff --git a/source/blender/editors/gpencil/gpencil_ops.c b/source/blender/editors/gpencil/gpencil_ops.c
index 6ea32f04132..bd74db921f5 100644
--- a/source/blender/editors/gpencil/gpencil_ops.c
+++ b/source/blender/editors/gpencil/gpencil_ops.c
@@ -563,6 +563,7 @@ void ED_operatortypes_gpencil(void)
WM_operatortype_append(GPENCIL_OT_snap_cursor_to_selected);
WM_operatortype_append(GPENCIL_OT_reproject);
+ WM_operatortype_append(GPENCIL_OT_recalc_geometry);
WM_operatortype_append(GPENCIL_OT_sculpt_paint);
WM_operatortype_append(GPENCIL_OT_weight_paint);
More information about the Bf-blender-cvs
mailing list