[#20583] Snap Cursor to Center and more View edits
Patches by Jonathan Smith (jaydez) Add a Cursor Center entry in the snap menu (Shift-S) to reset the cursor to 0,0,0. Also rename the view_center operator to view_selected to reflect better what it does (in the code only, description and name were already ok).
This commit is contained in:
@@ -200,6 +200,7 @@ class VIEW3D_MT_snap(bpy.types.Menu):
|
||||
layout.separator()
|
||||
|
||||
layout.operator("view3d.snap_cursor_to_selected", text="Cursor to Selected")
|
||||
layout.operator("view3d.snap_cursor_to_center", text="Cursor to Center")
|
||||
layout.operator("view3d.snap_cursor_to_grid", text="Cursor to Grid")
|
||||
layout.operator("view3d.snap_cursor_to_active", text="Cursor to Active")
|
||||
|
||||
|
||||
@@ -1286,7 +1286,7 @@ void VIEW3D_OT_view_all(wmOperatorType *ot)
|
||||
RNA_def_boolean(ot->srna, "center", 0, "Center", "");
|
||||
}
|
||||
|
||||
static int viewcenter_exec(bContext *C, wmOperator *op) /* like a localview without local!, was centerview() in 2.4x */
|
||||
static int viewselected_exec(bContext *C, wmOperator *op) /* like a localview without local!, was centerview() in 2.4x */
|
||||
{
|
||||
ARegion *ar= CTX_wm_region(C);
|
||||
View3D *v3d = CTX_wm_view3d(C);
|
||||
@@ -1403,16 +1403,16 @@ static int viewcenter_exec(bContext *C, wmOperator *op) /* like a localview with
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void VIEW3D_OT_view_center(wmOperatorType *ot)
|
||||
void VIEW3D_OT_view_selected(wmOperatorType *ot)
|
||||
{
|
||||
|
||||
/* identifiers */
|
||||
ot->name= "View Selected";
|
||||
ot->description = "Move the view to the selection center.";
|
||||
ot->idname= "VIEW3D_OT_view_center";
|
||||
ot->idname= "VIEW3D_OT_view_selected";
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec= viewcenter_exec;
|
||||
ot->exec= viewselected_exec;
|
||||
ot->poll= ED_operator_view3d_active;
|
||||
|
||||
/* flags */
|
||||
|
||||
@@ -73,7 +73,7 @@ void VIEW3D_OT_move(struct wmOperatorType *ot);
|
||||
void VIEW3D_OT_rotate(struct wmOperatorType *ot);
|
||||
void VIEW3D_OT_view_all(struct wmOperatorType *ot);
|
||||
void VIEW3D_OT_viewnumpad(struct wmOperatorType *ot);
|
||||
void VIEW3D_OT_view_center(struct wmOperatorType *ot);
|
||||
void VIEW3D_OT_view_selected(struct wmOperatorType *ot);
|
||||
void VIEW3D_OT_view_center_cursor(struct wmOperatorType *ot);
|
||||
void VIEW3D_OT_view_pan(struct wmOperatorType *ot);
|
||||
void VIEW3D_OT_view_persportho(struct wmOperatorType *ot);
|
||||
@@ -172,6 +172,7 @@ void VIEW3D_OT_snap_selected_to_grid(struct wmOperatorType *ot);
|
||||
void VIEW3D_OT_snap_selected_to_cursor(struct wmOperatorType *ot);
|
||||
void VIEW3D_OT_snap_selected_to_center(struct wmOperatorType *ot);
|
||||
void VIEW3D_OT_snap_cursor_to_grid(struct wmOperatorType *ot);
|
||||
void VIEW3D_OT_snap_cursor_to_center(struct wmOperatorType *ot);
|
||||
void VIEW3D_OT_snap_cursor_to_selected(struct wmOperatorType *ot);
|
||||
void VIEW3D_OT_snap_cursor_to_active(struct wmOperatorType *ot);
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ void view3d_operatortypes(void)
|
||||
WM_operatortype_append(VIEW3D_OT_view_orbit);
|
||||
WM_operatortype_append(VIEW3D_OT_view_pan);
|
||||
WM_operatortype_append(VIEW3D_OT_view_persportho);
|
||||
WM_operatortype_append(VIEW3D_OT_view_center);
|
||||
WM_operatortype_append(VIEW3D_OT_view_selected);
|
||||
WM_operatortype_append(VIEW3D_OT_view_center_cursor);
|
||||
WM_operatortype_append(VIEW3D_OT_select);
|
||||
WM_operatortype_append(VIEW3D_OT_select_border);
|
||||
@@ -96,6 +96,7 @@ void view3d_operatortypes(void)
|
||||
WM_operatortype_append(VIEW3D_OT_snap_selected_to_cursor);
|
||||
WM_operatortype_append(VIEW3D_OT_snap_selected_to_center);
|
||||
WM_operatortype_append(VIEW3D_OT_snap_cursor_to_grid);
|
||||
WM_operatortype_append(VIEW3D_OT_snap_cursor_to_center);
|
||||
WM_operatortype_append(VIEW3D_OT_snap_cursor_to_selected);
|
||||
WM_operatortype_append(VIEW3D_OT_snap_cursor_to_active);
|
||||
|
||||
@@ -126,7 +127,7 @@ void view3d_keymap(wmKeyConfig *keyconf)
|
||||
WM_keymap_verify_item(keymap, "VIEW3D_OT_rotate", MIDDLEMOUSE, KM_PRESS, 0, 0);
|
||||
WM_keymap_verify_item(keymap, "VIEW3D_OT_move", MIDDLEMOUSE, KM_PRESS, KM_SHIFT, 0);
|
||||
WM_keymap_verify_item(keymap, "VIEW3D_OT_zoom", MIDDLEMOUSE, KM_PRESS, KM_CTRL, 0);
|
||||
WM_keymap_verify_item(keymap, "VIEW3D_OT_view_center", PADPERIOD, KM_PRESS, 0, 0);
|
||||
WM_keymap_verify_item(keymap, "VIEW3D_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0);
|
||||
WM_keymap_verify_item(keymap, "VIEW3D_OT_view_center_cursor", PADPERIOD, KM_PRESS, KM_CTRL, 0);
|
||||
|
||||
WM_keymap_verify_item(keymap, "VIEW3D_OT_fly", FKEY, KM_PRESS, KM_SHIFT, 0);
|
||||
|
||||
@@ -1084,6 +1084,44 @@ void VIEW3D_OT_snap_selected_to_center(wmOperatorType *ot)
|
||||
}
|
||||
|
||||
|
||||
/* **************************************************** */
|
||||
/*New Code - Snap Cursor to Center -*/
|
||||
static int snap_curs_to_center(bContext *C, wmOperator *op)
|
||||
{
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
RegionView3D *rv3d= CTX_wm_region_data(C);
|
||||
View3D *v3d= CTX_wm_view3d(C);
|
||||
float *curs;
|
||||
curs= give_cursor(scene, v3d);
|
||||
|
||||
curs[0]= 0.0;
|
||||
curs[1]= 0.0;
|
||||
curs[2]= 0.0;
|
||||
|
||||
WM_event_add_notifier(C, NC_SCENE|ND_TRANSFORM, scene); // hrm
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void VIEW3D_OT_snap_cursor_to_center(wmOperatorType *ot)
|
||||
{
|
||||
|
||||
/* identifiers */
|
||||
ot->name= "Snap Cursor to Center";
|
||||
ot->description= "Snap cursor to the Center";
|
||||
ot->idname= "VIEW3D_OT_snap_cursor_to_center";
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec= snap_curs_to_center;
|
||||
ot->poll= ED_operator_view3d_active;
|
||||
|
||||
/* flags */
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
/* **************************************************** */
|
||||
|
||||
|
||||
int minmax_verts(Object *obedit, float *min, float *max)
|
||||
{
|
||||
TransVert *tv;
|
||||
|
||||
Reference in New Issue
Block a user