WIP: Custom build, mostly selection options #105712
|
@ -99,6 +99,26 @@ void view3d_operator_properties_common(wmOperatorType *ot, const enum eV3D_OpPro
|
|||
if (flag & V3D_OP_PROP_USE_MOUSE_INIT) {
|
||||
WM_operator_properties_use_cursor_init(ot);
|
||||
}
|
||||
|
||||
if (flag & V3D_OP_PROP_FRAME_SELECTED_DISTANCE) {
|
||||
PropertyRNA *prop;
|
||||
prop = RNA_def_int(ot->srna,
|
||||
"frame_selected_distance",
|
||||
0,
|
||||
0,
|
||||
1000,
|
||||
"Camera Offset",
|
||||
"Distance to put camera from selected",
|
||||
0,
|
||||
1000);
|
||||
|
||||
}
|
||||
|
||||
if (flag & V3D_OP_PROP_ZOOM_SPEED) {
|
||||
PropertyRNA *prop;
|
||||
prop = RNA_def_float(
|
||||
ot->srna, "zoom_speed", 1.2f, 1.001, 10, "Zoom Speed", "Speed to zoom camera", 1.001f, 10);
|
||||
}
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
@ -652,7 +672,8 @@ static void view3d_from_minmax(bContext *C,
|
|||
const float min[3],
|
||||
const float max[3],
|
||||
bool ok_dist,
|
||||
const int smooth_viewtx)
|
||||
const int smooth_viewtx,
|
||||
const int view_dist)
|
||||
{
|
||||
RegionView3D *rv3d = region->regiondata;
|
||||
float afm[3];
|
||||
|
@ -695,7 +716,7 @@ static void view3d_from_minmax(bContext *C,
|
|||
v3d, region, depsgraph, persp, true, (size / 2) * VIEW3D_MARGIN);
|
||||
if (rv3d->is_persp) {
|
||||
/* don't zoom closer than the near clipping plane */
|
||||
new_dist = max_ff(new_dist, v3d->clip_start * 1.5f);
|
||||
new_dist = max_ff(new_dist, v3d->clip_start * 1.5f + view_dist);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -741,7 +762,8 @@ static void view3d_from_minmax_multi(bContext *C,
|
|||
const float min[3],
|
||||
const float max[3],
|
||||
const bool ok_dist,
|
||||
const int smooth_viewtx)
|
||||
const int smooth_viewtx,
|
||||
const int view_dist)
|
||||
{
|
||||
ScrArea *area = CTX_wm_area(C);
|
||||
ARegion *region;
|
||||
|
@ -751,7 +773,7 @@ static void view3d_from_minmax_multi(bContext *C,
|
|||
/* when using all regions, don't jump out of camera view,
|
||||
* but _do_ allow locked cameras to be moved */
|
||||
if ((rv3d->persp != RV3D_CAMOB) || ED_view3d_camera_lock_check(v3d, rv3d)) {
|
||||
view3d_from_minmax(C, v3d, region, min, max, ok_dist, smooth_viewtx);
|
||||
view3d_from_minmax(C, v3d, region, min, max, ok_dist, smooth_viewtx, view_dist);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -831,10 +853,10 @@ static int view3d_all_exec(bContext *C, wmOperator *op)
|
|||
ED_view3d_smooth_view_undo_begin(C, area);
|
||||
|
||||
if (use_all_regions) {
|
||||
view3d_from_minmax_multi(C, v3d, min, max, true, smooth_viewtx);
|
||||
view3d_from_minmax_multi(C, v3d, min, max, true, smooth_viewtx, 0);
|
||||
}
|
||||
else {
|
||||
view3d_from_minmax(C, v3d, region, min, max, true, smooth_viewtx);
|
||||
view3d_from_minmax(C, v3d, region, min, max, true, smooth_viewtx, 0);
|
||||
}
|
||||
|
||||
ED_view3d_smooth_view_undo_end(C, area, op->type->name, false);
|
||||
|
@ -893,6 +915,7 @@ static int viewselected_exec(bContext *C, wmOperator *op)
|
|||
/* any one of the regions may be locked */
|
||||
(use_all_regions && v3d->flag2 & V3D_LOCK_CAMERA));
|
||||
const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
|
||||
const int view_dist = RNA_int_get(op->ptr, "frame_selected_distance");
|
||||
|
||||
INIT_MINMAX(min, max);
|
||||
if (is_face_map) {
|
||||
|
@ -1007,10 +1030,10 @@ static int viewselected_exec(bContext *C, wmOperator *op)
|
|||
ED_view3d_smooth_view_undo_begin(C, area);
|
||||
|
||||
if (use_all_regions) {
|
||||
view3d_from_minmax_multi(C, v3d, min, max, ok_dist, smooth_viewtx);
|
||||
view3d_from_minmax_multi(C, v3d, min, max, ok_dist, smooth_viewtx, view_dist);
|
||||
}
|
||||
else {
|
||||
view3d_from_minmax(C, v3d, region, min, max, ok_dist, smooth_viewtx);
|
||||
view3d_from_minmax(C, v3d, region, min, max, ok_dist, smooth_viewtx, view_dist);
|
||||
}
|
||||
|
||||
ED_view3d_smooth_view_undo_end(C, area, op->type->name, false);
|
||||
|
@ -1033,7 +1056,8 @@ void VIEW3D_OT_view_selected(wmOperatorType *ot)
|
|||
ot->flag = 0;
|
||||
|
||||
/* properties */
|
||||
view3d_operator_properties_common(ot, V3D_OP_PROP_USE_ALL_REGIONS);
|
||||
view3d_operator_properties_common(
|
||||
ot, V3D_OP_PROP_USE_ALL_REGIONS | V3D_OP_PROP_FRAME_SELECTED_DISTANCE);
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
|
|
@ -34,6 +34,8 @@ enum eV3D_OpPropFlag {
|
|||
V3D_OP_PROP_DELTA = (1 << 1),
|
||||
V3D_OP_PROP_USE_ALL_REGIONS = (1 << 2),
|
||||
V3D_OP_PROP_USE_MOUSE_INIT = (1 << 3),
|
||||
V3D_OP_PROP_FRAME_SELECTED_DISTANCE = (1 << 4),
|
||||
V3D_OP_PROP_ZOOM_SPEED = (1 << 5),
|
||||
};
|
||||
|
||||
enum {
|
||||
|
|
|
@ -506,9 +506,10 @@ static int viewzoom_exec(bContext *C, wmOperator *op)
|
|||
}
|
||||
|
||||
ED_view3d_dist_range_get(v3d, dist_range);
|
||||
const float zoom_speed = RNA_float_get(op->ptr, "zoom_speed");
|
||||
|
||||
if (delta < 0) {
|
||||
const float step = 1.2f;
|
||||
const float step = zoom_speed;
|
||||
if (use_cam_zoom) {
|
||||
view_zoom_to_window_xy_camera(scene, depsgraph, v3d, region, step, zoom_xy);
|
||||
}
|
||||
|
@ -519,7 +520,7 @@ static int viewzoom_exec(bContext *C, wmOperator *op)
|
|||
}
|
||||
}
|
||||
else {
|
||||
const float step = 1.0f / 1.2f;
|
||||
const float step = 1.0f / zoom_speed;
|
||||
if (use_cam_zoom) {
|
||||
view_zoom_to_window_xy_camera(scene, depsgraph, v3d, region, step, zoom_xy);
|
||||
}
|
||||
|
@ -631,8 +632,9 @@ void VIEW3D_OT_zoom(wmOperatorType *ot)
|
|||
ot->flag = OPTYPE_BLOCKING | OPTYPE_GRAB_CURSOR_XY;
|
||||
|
||||
/* properties */
|
||||
view3d_operator_properties_common(
|
||||
ot, V3D_OP_PROP_DELTA | V3D_OP_PROP_MOUSE_CO | V3D_OP_PROP_USE_MOUSE_INIT);
|
||||
view3d_operator_properties_common(ot,
|
||||
V3D_OP_PROP_DELTA | V3D_OP_PROP_MOUSE_CO |
|
||||
V3D_OP_PROP_USE_MOUSE_INIT | V3D_OP_PROP_ZOOM_SPEED);
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
|
Loading…
Reference in New Issue