[Bf-blender-cvs] [a21c36a2723] greasepencil-object: Remove custom set origin operator

Antonio Vazquez noreply at git.blender.org
Sat Jul 8 17:40:25 CEST 2017


Commit: a21c36a27234893bb30639ac924daf914092c437
Author: Antonio Vazquez
Date:   Sat Jul 8 17:38:56 2017 +0200
Branches: greasepencil-object
https://developer.blender.org/rBa21c36a27234893bb30639ac924daf914092c437

Remove custom set origin operator

This change has been integrated in standard set origin operator

===================================================================

M	release/scripts/startup/bl_ui/properties_grease_pencil_common.py
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/release/scripts/startup/bl_ui/properties_grease_pencil_common.py b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
index 8585a44b40a..01ed2019fdb 100644
--- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
+++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
@@ -221,7 +221,6 @@ class GreasePencilStrokeEditPanel:
         if is_3d_view:
             layout.separator()
             layout.operator_menu_enum("gpencil.reproject", text="Reproject Strokes...", property="type")
-            layout.operator_menu_enum("gpencil.origin_to_cursor", "type", text="Set Origin")
 
 
 class GreasePencilAnimationPanel:
@@ -744,15 +743,6 @@ class GPENCIL_MT_snap(Menu):
         layout.operator("view3d.snap_cursor_to_grid", text="Cursor to Grid")
 
 
-class GPENCIL_MT_origin(Menu):
-    bl_label = "Set GPencil Origin"
-
-    def draw(self, context):
-        layout = self.layout
-
-        layout.operator("gpencil.origin_to_cursor", text="Origin to 3D Cursor", icon="CURSOR")
-
-
 class GPENCIL_MT_gpencil_edit_specials(Menu):
     bl_label = "GPencil Specials"
 
@@ -1299,7 +1289,6 @@ classes = (
     GPENCIL_PIE_tools_more,
     GPENCIL_PIE_sculpt,
     GPENCIL_MT_snap,
-    GPENCIL_MT_origin,
     GPENCIL_MT_gpencil_edit_specials,
     GPENCIL_UL_brush,
     GPENCIL_UL_palettecolor,
diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c
index 6de0c9dac12..eebe6094a99 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -2564,97 +2564,3 @@ void GPENCIL_OT_stroke_subdivide(wmOperatorType *ot)
 	RNA_def_property_flag(prop, PROP_SKIP_SAVE);
 
 }
-
-enum {
-	GP_ORIGIN_TO_CURSOR = 0
-};
-
-/* Poll callback for origin operators */
-/* We only allow these in the 3D view and edit mode
-*/
-static int gp_origin_to_cursor_poll(bContext *C)
-{
-	Object *obact = CTX_data_active_object(C);
-	bGPdata *gpd = CTX_data_gpencil_data(C);
-	ScrArea *sa = CTX_wm_area(C);
-
-	return (obact) && (obact->type == OB_GPENCIL) && (gpd != NULL) && ((sa != NULL) && (sa->spacetype == SPACE_VIEW3D));
-}
-
-/* --------------------------------- */
-
-static int gp_origin_to_cursor_exec(bContext *C, wmOperator *op)
-{
-	Scene *scene = CTX_data_scene(C);
-	View3D *v3d = CTX_wm_view3d(C);
-
-	bGPdata *gpd = ED_gpencil_data_get_active(C);
-	Object *obact = CTX_data_active_object(C);
-	int centermode = RNA_enum_get(op->ptr, "type");
-	bGPDspoint *pt;
-
-	float imat[3][3], bmat[3][3];
-	const float *cursor_loc = ED_view3d_cursor3d_get(scene, v3d);
-	float offset_global[3];
-	float offset_local[3];
-	int i;
-
-	if ((!obact) || (obact->type != OB_GPENCIL) || (!obact->gpd)) {
-		return OPERATOR_CANCELLED;
-	}
-
-	if (centermode == GP_ORIGIN_TO_CURSOR) {
-		/* move pivot point to 3D cursor location */
-		WM_operator_name_call(C, "VIEW3D_OT_snap_selected_to_cursor", WM_OP_EXEC_REGION_WIN, NULL);
-
-		sub_v3_v3v3(offset_global, cursor_loc, obact->obmat[3]);
-		copy_m3_m4(bmat, obact->obmat);
-		invert_m3_m3(imat, bmat);
-		mul_m3_v3(imat, offset_global);
-		mul_v3_m3v3(offset_local, imat, offset_global);
-
-		/* recalculate all strokes (all layers are considered without evaluating lock attributtes) */
-		for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
-			for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf->next) {
-				for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
-					/* skip strokes that are invalid for current view */
-					if (ED_gpencil_stroke_can_use(C, gps) == false)
-						continue;
-
-					for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
-						sub_v3_v3(&pt->x, offset_local);
-					}
-				}
-			}
-		}
-
-		BKE_gpencil_batch_cache_dirty(gpd);
-		WM_event_add_notifier(C, NC_SCENE | NC_GPENCIL, NULL);
-	}
-
-	return OPERATOR_FINISHED;
-}
-
-void GPENCIL_OT_origin_to_cursor(wmOperatorType *ot)
-{
-	static EnumPropertyItem prop_set_center_types[] = {
-		{ GP_ORIGIN_TO_CURSOR, "ORIGIN_CURSOR", 0, "Origin to 3D Cursor",
-		"Move strokes origin to position of the 3D cursor" },
-		{ 0, NULL, 0, NULL, NULL }
-	};
-
-	/* identifiers */
-	ot->name = "Origin to 3D cursor";
-	ot->idname = "GPENCIL_OT_origin_to_cursor";
-	ot->description = "Set origing to current 3D cursor location moving pivot point and recalcule strokes";
-
-	/* callbacks */
-	ot->invoke = WM_menu_invoke;
-	ot->exec = gp_origin_to_cursor_exec;
-	ot->poll = gp_origin_to_cursor_poll;
-
-	/* flags */
-	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
-	ot->prop = RNA_def_enum(ot->srna, "type", prop_set_center_types, 0, "Type", "");
-}
diff --git a/source/blender/editors/gpencil/gpencil_intern.h b/source/blender/editors/gpencil/gpencil_intern.h
index 8ac3aa1e54b..98adebf779a 100644
--- a/source/blender/editors/gpencil/gpencil_intern.h
+++ b/source/blender/editors/gpencil/gpencil_intern.h
@@ -186,8 +186,6 @@ void GPENCIL_OT_snap_to_cursor(struct wmOperatorType *ot);
 void GPENCIL_OT_snap_cursor_to_selected(struct wmOperatorType *ot);
 void GPENCIL_OT_snap_cursor_to_center(struct wmOperatorType *ot);
 
-void GPENCIL_OT_origin_to_cursor(struct wmOperatorType *ot);
-
 void GPENCIL_OT_reproject(struct wmOperatorType *ot);
 
 /* stroke sculpting -- */
diff --git a/source/blender/editors/gpencil/gpencil_ops.c b/source/blender/editors/gpencil/gpencil_ops.c
index 9e25ab57d03..6bf2e2ab9d8 100644
--- a/source/blender/editors/gpencil/gpencil_ops.c
+++ b/source/blender/editors/gpencil/gpencil_ops.c
@@ -294,9 +294,6 @@ static void ed_keymap_gpencil_editing(wmKeyConfig *keyconf)
 	/* snap */
 	WM_keymap_add_menu(keymap, "GPENCIL_MT_snap", SKEY, KM_PRESS, KM_SHIFT, 0);
 	
-	/* set origin */
-	WM_keymap_add_menu(keymap, "GPENCIL_MT_origin", CKEY, KM_PRESS, KM_ALT | KM_SHIFT | KM_CTRL, 0);
-
 	/* convert to geometry */
 	WM_keymap_add_item(keymap, "GPENCIL_OT_convert", CKEY, KM_PRESS, KM_ALT, 0);
 	
@@ -539,8 +536,6 @@ void ED_operatortypes_gpencil(void)
 	WM_operatortype_append(GPENCIL_OT_snap_to_cursor);
 	WM_operatortype_append(GPENCIL_OT_snap_cursor_to_selected);
 	
-	WM_operatortype_append(GPENCIL_OT_origin_to_cursor);
-
 	WM_operatortype_append(GPENCIL_OT_reproject);
 	
 	WM_operatortype_append(GPENCIL_OT_brush_paint);




More information about the Bf-blender-cvs mailing list