96 const float zoomfac_new =
clamp_f(
100 if (zoom_xy !=
NULL) {
102 rctf camera_frame_old;
103 rctf camera_frame_new;
105 const float pt_src[2] = {zoom_xy[0], zoom_xy[1]};
125 rv3d->
camdx += delta_px[0] / (region->
winx * zoomfac_px);
126 rv3d->
camdy += delta_px[1] / (region->
winy * zoomfac_px);
143 const float dist_new = rv3d->
dist * dfac;
145 if (zoom_xy !=
NULL) {
168 rv3d->
dist = dist_new;
174 rv3d->
dist = dist_new;
180 const bool zoom_invert,
181 const bool zoom_invert_force,
182 const int xy_curr[2],
183 const int xy_init[2],
185 const float val_orig,
186 double *r_timer_lastdraw)
192 float time_step = (
float)(
time - *r_timer_lastdraw);
196 fac = (
float)(xy_init[0] - xy_curr[0]);
199 fac = (
float)(xy_init[1] - xy_curr[1]);
204 if (zoom_invert != zoom_invert_force) {
208 zfac = 1.0f + ((fac / 20.0f) * time_step);
209 *r_timer_lastdraw =
time;
218 float len_new = (5 *
U.dpi_fac) + ((
float)
len_v2v2_int(ctr, xy_curr) /
U.dpi_fac);
219 float len_old = (5 *
U.dpi_fac) + ((
float)
len_v2v2_int(ctr, xy_init) /
U.dpi_fac);
222 if (zoom_invert_force) {
223 SWAP(
float, len_new, len_old);
226 zfac = val_orig * (len_old /
max_ff(len_new, 1.0f)) / val;
229 float len_new = 5 *
U.dpi_fac;
230 float len_old = 5 *
U.dpi_fac;
233 len_new += (winrct->
xmax - (xy_curr[0])) /
U.dpi_fac;
234 len_old += (winrct->
xmax - (xy_init[0])) /
U.dpi_fac;
237 len_new += (winrct->
ymax - (xy_curr[1])) /
U.dpi_fac;
238 len_old += (winrct->
ymax - (xy_init[1])) /
U.dpi_fac;
241 if (zoom_invert != zoom_invert_force) {
242 SWAP(
float, len_new, len_old);
245 zfac = val_orig * (2.0f * ((len_new /
max_ff(len_old, 1.0f)) - 1.0f) + 1.0f) / val;
253 const bool zoom_invert,
254 const bool zoom_invert_force,
255 const int xy_curr[2],
256 const int xy_init[2],
257 const int xy_offset[2],
259 const float val_orig,
260 double *r_timer_lastdraw)
262 const int xy_curr_offset[2] = {
263 xy_curr[0] + xy_offset[0],
264 xy_curr[1] + xy_offset[1],
266 const int xy_init_offset[2] = {
267 xy_init[0] + xy_offset[0],
268 xy_init[1] + xy_offset[1],
284 const bool zoom_invert,
285 const bool zoom_to_pos)
302 if (!
ELEM(zfac, 1.0f, 0.0f)) {
319 const bool zoom_invert,
320 const bool zoom_to_pos)
339 const float zfac_min = dist_range[0] / vod->
rv3d->
dist;
340 const float zfac_max = dist_range[1] / vod->
rv3d->
dist;
341 CLAMP(zfac, zfac_min, zfac_max);
361 const bool zoom_invert,
362 const bool zoom_to_pos)
377 bool use_autokey =
false;
389 switch (event->
val) {
461 v3d =
area->spacedata.first;
468 const int *zoom_xy =
NULL;
474 zoom_xy = zoom_xy_buf;
480 const float step = 1.2f;
485 if (rv3d->
dist < dist_range[1]) {
491 const float step = 1.0f / 1.2f;
496 if (rv3d->
dist > dist_range[0]) {
typedef float(TangentPoint)[2]
struct ScrArea * CTX_wm_area(const bContext *C)
struct Scene * CTX_data_scene(const bContext *C)
struct wmWindowManager * CTX_wm_manager(const bContext *C)
struct Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C)
struct ARegion * CTX_wm_region(const bContext *C)
struct wmWindow * CTX_wm_window(const bContext *C)
float BKE_screen_view3d_zoom_from_fac(float zoomfac)
float BKE_screen_view3d_zoom_to_fac(float camzoom)
MINLINE float max_ff(float a, float b)
MINLINE float clamp_f(float value, float min, float max)
MINLINE float len_v2v2_int(const int v1[2], const int v2[2])
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void negate_v3_v3(float r[3], const float a[3])
MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void negate_v3(float r[3])
MINLINE void sub_v2_v2v2(float r[2], const float a[2], const float b[2])
MINLINE void madd_v3_v3v3fl(float r[3], const float a[3], const float b[3], float f)
void BLI_rctf_translate(struct rctf *rect, float x, float y)
void BLI_rctf_transform_pt_v(const rctf *dst, const rctf *src, float xy_dst[2], const float xy_src[2])
BLI_INLINE int BLI_rcti_cent_y(const struct rcti *rct)
BLI_INLINE int BLI_rcti_cent_x(const struct rcti *rct)
struct Depsgraph Depsgraph
#define RV3D_CAMZOOM_MIN_FACTOR
#define RV3D_LOCK_FLAGS(rv3d)
#define RV3D_CAMZOOM_MAX_FACTOR
bScreen * ED_screen_animation_playing(const struct wmWindowManager *wm)
void ED_region_tag_redraw(struct ARegion *region)
bool ED_view3d_camera_lock_sync(const struct Depsgraph *depsgraph, struct View3D *v3d, struct RegionView3D *rv3d)
bool ED_view3d_camera_lock_check(const struct View3D *v3d, const struct RegionView3D *rv3d)
void ED_view3d_win_to_delta(const struct ARegion *region, const float xy_delta[2], float zfac, float r_out[3])
void ED_view3d_dist_range_get(const struct View3D *v3d, float r_dist_range[2])
bool ED_view3d_camera_lock_autokey(struct View3D *v3d, struct RegionView3D *rv3d, struct bContext *C, bool do_rotate, bool do_translate)
float ED_view3d_calc_zfac(const struct RegionView3D *rv3d, const float co[3])
bool ED_view3d_camera_lock_undo_push(const char *str, View3D *v3d, struct RegionView3D *rv3d, struct bContext *C)
bool ED_view3d_camera_lock_undo_grouped_push(const char *str, View3D *v3d, struct RegionView3D *rv3d, struct bContext *C)
void ED_view3d_calc_camera_border(const struct Scene *scene, struct Depsgraph *depsgraph, const struct ARegion *region, const struct View3D *v3d, const struct RegionView3D *rv3d, struct rctf *r_viewborder, bool no_shift)
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to used to fine tune the interpolation of the input Camera Retrieve information about the camera and how it relates to the current shading point s position CLAMP
Platform independent time functions.
const Depsgraph * depsgraph
static void area(int d1, int d2, int e1, int e2, float weights[2])
void RNA_int_set(PointerRNA *ptr, const char *name, int value)
int RNA_int_get(PointerRNA *ptr, const char *name)
bool RNA_struct_property_is_set(PointerRNA *ptr, const char *identifier)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
struct RegionView3D * rv3d
struct ViewOpsData::@577 prev
struct Depsgraph * depsgraph
struct ViewOpsData::@576 init
int(* invoke)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
int(* modal)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
bool(* poll)(struct bContext *) ATTR_WARN_UNUSED_RESULT
void(* cancel)(struct bContext *, struct wmOperator *)
int(* exec)(struct bContext *, struct wmOperator *) ATTR_WARN_UNUSED_RESULT
struct wmOperatorType * type
double PIL_check_seconds_timer(void)
void view3d_boxview_sync(struct ScrArea *area, struct ARegion *region)
void view3d_operator_properties_common(wmOperatorType *ot, const enum eV3D_OpPropFlag flag)
void viewops_data_free(bContext *C, ViewOpsData *vod)
ViewOpsData * viewops_data_create(bContext *C, const wmEvent *event, enum eViewOpsFlag viewops_flag)
enum eViewOpsFlag viewops_flag_from_prefs(void)
bool view3d_zoom_or_dolly_poll(bContext *C)
@ VIEWROT_MODAL_SWITCH_ROTATE
@ VIEWROT_MODAL_SWITCH_MOVE
@ VIEWOPS_FLAG_USE_MOUSE_INIT
@ VIEWOPS_FLAG_ORBIT_SELECT
void ED_view3d_smooth_view_force_finish(struct bContext *C, struct View3D *v3d, struct ARegion *region)
@ V3D_OP_PROP_USE_MOUSE_INIT
static void viewzoom_apply(ViewOpsData *vod, const int xy[2], const eViewZoom_Style viewzoom, const bool zoom_invert, const bool zoom_to_pos)
static void view_zoom_to_window_xy_camera(Scene *scene, Depsgraph *depsgraph, View3D *v3d, ARegion *region, float dfac, const int zoom_xy[2])
static void viewzoom_apply_3d(ViewOpsData *vod, const int xy[2], const eViewZoom_Style viewzoom, const bool zoom_invert, const bool zoom_to_pos)
static int viewzoom_modal(bContext *C, wmOperator *op, const wmEvent *event)
static float viewzoom_scale_value(const rcti *winrct, const eViewZoom_Style viewzoom, const bool zoom_invert, const bool zoom_invert_force, const int xy_curr[2], const int xy_init[2], const float val, const float val_orig, double *r_timer_lastdraw)
static int viewzoom_exec(bContext *C, wmOperator *op)
static void viewzoom_cancel(bContext *C, wmOperator *op)
void viewzoom_modal_keymap(wmKeyConfig *keyconf)
static void viewzoom_apply_camera(ViewOpsData *vod, const int xy[2], const eViewZoom_Style viewzoom, const bool zoom_invert, const bool zoom_to_pos)
static float viewzoom_scale_value_offset(const rcti *winrct, const eViewZoom_Style viewzoom, const bool zoom_invert, const bool zoom_invert_force, const int xy_curr[2], const int xy_init[2], const int xy_offset[2], const float val, const float val_orig, double *r_timer_lastdraw)
void VIEW3D_OT_zoom(wmOperatorType *ot)
static void view_zoom_to_window_xy_3d(ARegion *region, float dfac, const int zoom_xy[2])
static int viewzoom_invoke(bContext *C, wmOperator *op, const wmEvent *event)
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)
int WM_operator_name_call(bContext *C, const char *opstring, wmOperatorCallContext context, PointerRNA *properties, const wmEvent *event)
wmKeyMap * WM_modalkeymap_find(wmKeyConfig *keyconf, const char *idname)
void WM_modalkeymap_assign(wmKeyMap *km, const char *opname)
wmKeyMapItem * WM_modalkeymap_add_item(wmKeyMap *km, const KeyMapItem_Params *params, int value)
wmKeyMap * WM_modalkeymap_ensure(wmKeyConfig *keyconf, const char *idname, const EnumPropertyItem *items)
wmTimer * WM_event_add_timer(wmWindowManager *wm, wmWindow *win, int event_type, double timestep)