From 81d2eda2bf8a0d73ed7bbf077c9fa4ffcf54aa6c Mon Sep 17 00:00:00 2001 From: Germano Cavalcante Date: Fri, 4 Feb 2022 22:12:07 -0300 Subject: Fix error in b1b1a74af15b4eaa0757ad88acfbcac73b9a64fe `op` --> `op->customdata` --- .../blender/editors/space_view3d/view3d_navigate.c | 122 +++++++++++++-------- .../editors/space_view3d/view3d_navigate_zoom.c | 6 +- 2 files changed, 82 insertions(+), 46 deletions(-) (limited to 'source/blender/editors/space_view3d') diff --git a/source/blender/editors/space_view3d/view3d_navigate.c b/source/blender/editors/space_view3d/view3d_navigate.c index 98eef94d5fb..dd7f1b0d191 100644 --- a/source/blender/editors/space_view3d/view3d_navigate.c +++ b/source/blender/editors/space_view3d/view3d_navigate.c @@ -255,6 +255,15 @@ bool view3d_orbit_calc_center(bContext *C, float r_dyn_ofs[3]) return is_set; } +static bool viewops_data_init_orbit_select(bContext *C, ViewOpsData *vod) +{ + float ofs[3]; + if (view3d_orbit_calc_center(C, ofs) || (vod->use_dyn_ofs == false)) { + vod->use_dyn_ofs = true; + negate_v3_v3(vod->dyn_ofs, ofs); + } +} + static enum eViewOpsFlag viewops_flag_from_args(bool use_select, bool use_depth) { enum eViewOpsFlag flag = 0; @@ -274,19 +283,53 @@ enum eViewOpsFlag viewops_flag_from_prefs(void) (U.uiflag & USER_DEPTH_NAVIGATE) != 0); } -ViewOpsData *viewops_data_create(bContext *C, const wmEvent *event, enum eViewOpsFlag viewops_flag) +static void viewops_data_init_depth_ofs(bContext *C, ViewOpsData *vod, const int mval[2]) { - ViewOpsData *vod = MEM_callocN(sizeof(ViewOpsData), __func__); + float fallback_depth_pt[3]; - /* Store data. */ - vod->bmain = CTX_data_main(C); - vod->depsgraph = CTX_data_ensure_evaluated_depsgraph(C); - vod->scene = CTX_data_scene(C); - vod->area = CTX_wm_area(C); - vod->region = CTX_wm_region(C); - vod->v3d = vod->area->spacedata.first; - vod->rv3d = vod->region->regiondata; + view3d_operator_needs_opengl(C); /* Needed for Z-buffer drawing. */ + + negate_v3_v3(fallback_depth_pt, vod->rv3d->ofs); + + vod->use_dyn_ofs = ED_view3d_autodist( + vod->depsgraph, vod->region, vod->v3d, mval, vod->dyn_ofs, true, fallback_depth_pt); +} + +static void viewops_data_ensure_persp(ViewOpsData *vod) +{ + if (ED_view3d_persp_ensure(vod->depsgraph, vod->v3d, vod->region)) { + /* If we're switching from camera view to the perspective one, + * need to tag viewport update, so camera view and borders are properly updated. */ + ED_region_tag_redraw(vod->region); + } +} + +static void viewops_data_init_generic(ViewOpsData *vod, const wmEvent *event) +{ + RegionView3D *rv3d = vod->rv3d; + + /* set the view from the camera, if view locking is enabled. + * we may want to make this optional but for now its needed always */ + ED_view3d_camera_lock_init(vod->depsgraph, vod->v3d, vod->rv3d); + + vod->init.persp = rv3d->persp; + vod->init.dist = rv3d->dist; + vod->init.camzoom = rv3d->camzoom; + copy_qt_qt(vod->init.quat, rv3d->viewquat); + copy_v2_v2_int(vod->init.event_xy, event->xy); + copy_v2_v2_int(vod->prev.event_xy, event->xy); + + vod->init.event_type = event->type; + copy_v3_v3(vod->init.ofs, rv3d->ofs); + + copy_qt_qt(vod->curr.viewquat, rv3d->viewquat); +} +static void viewops_data_init(bContext *C, + ViewOpsData *vod, + const wmEvent *event, + enum eViewOpsFlag viewops_flag) +{ Depsgraph *depsgraph = vod->depsgraph; RegionView3D *rv3d = vod->rv3d; @@ -297,37 +340,17 @@ ViewOpsData *viewops_data_create(bContext *C, const wmEvent *event, enum eViewOp /* we need the depth info before changing any viewport options */ if (viewops_flag & VIEWOPS_FLAG_DEPTH_NAVIGATE) { - float fallback_depth_pt[3]; - - view3d_operator_needs_opengl(C); /* Needed for Z-buffer drawing. */ - - negate_v3_v3(fallback_depth_pt, rv3d->ofs); - - vod->use_dyn_ofs = ED_view3d_autodist( - depsgraph, vod->region, vod->v3d, event->mval, vod->dyn_ofs, true, fallback_depth_pt); + viewops_data_init_depth_ofs(C, vod, event->mval); } else { vod->use_dyn_ofs = false; } if (viewops_flag & VIEWOPS_FLAG_PERSP_ENSURE) { - if (ED_view3d_persp_ensure(depsgraph, vod->v3d, vod->region)) { - /* If we're switching from camera view to the perspective one, - * need to tag viewport update, so camera view and borders are properly updated. */ - ED_region_tag_redraw(vod->region); - } + viewops_data_ensure_persp(vod); } - /* set the view from the camera, if view locking is enabled. - * we may want to make this optional but for now its needed always */ - ED_view3d_camera_lock_init(depsgraph, vod->v3d, vod->rv3d); - - vod->init.persp = rv3d->persp; - vod->init.dist = rv3d->dist; - vod->init.camzoom = rv3d->camzoom; - copy_qt_qt(vod->init.quat, rv3d->viewquat); - copy_v2_v2_int(vod->init.event_xy, event->xy); - copy_v2_v2_int(vod->prev.event_xy, event->xy); + viewops_data_init_generic(vod, event); if (viewops_flag & VIEWOPS_FLAG_USE_MOUSE_INIT) { zero_v2_int(vod->init.event_xy_offset); @@ -338,16 +361,8 @@ ViewOpsData *viewops_data_create(bContext *C, const wmEvent *event, enum eViewOp vod->init.event_xy_offset[1] = BLI_rcti_cent_y(&vod->region->winrct) - event->xy[1]; } - vod->init.event_type = event->type; - copy_v3_v3(vod->init.ofs, rv3d->ofs); - - copy_qt_qt(vod->curr.viewquat, rv3d->viewquat); - if (viewops_flag & VIEWOPS_FLAG_ORBIT_SELECT) { - float ofs[3]; - if (view3d_orbit_calc_center(C, ofs) || (vod->use_dyn_ofs == false)) { - vod->use_dyn_ofs = true; - negate_v3_v3(vod->dyn_ofs, ofs); + if (viewops_data_init_orbit_select(C, vod)) { viewops_flag &= ~VIEWOPS_FLAG_DEPTH_NAVIGATE; } } @@ -419,8 +434,6 @@ ViewOpsData *viewops_data_create(bContext *C, const wmEvent *event, enum eViewOp } rv3d->rflag |= RV3D_NAVIGATING; - - return vod; } void viewops_data_free(bContext *C, ViewOpsData *vod) @@ -449,6 +462,27 @@ void viewops_data_free(bContext *C, ViewOpsData *vod) ED_region_tag_redraw(region); } +ViewOpsData *viewops_data_create(bContext *C, const wmEvent *event, enum eViewOpsFlag viewops_flag) +{ + ViewOpsData *vod = MEM_callocN(sizeof(ViewOpsData), __func__); + + /* Store data. */ + vod->bmain = CTX_data_main(C); + vod->depsgraph = CTX_data_ensure_evaluated_depsgraph(C); + vod->scene = CTX_data_scene(C); + vod->area = CTX_wm_area(C); + vod->region = CTX_wm_region(C); + vod->v3d = vod->area->spacedata.first; + vod->rv3d = vod->region->regiondata; + + /* Could do this more nicely. */ + if ((viewops_flag & VIEWOPS_FLAG_USE_MOUSE_INIT) == 0) { + viewops_flag &= ~VIEWOPS_FLAG_DEPTH_NAVIGATE; + } + + viewops_data_init(C, vod, event, viewops_flag); +} + /** \} */ /* -------------------------------------------------------------------- */ diff --git a/source/blender/editors/space_view3d/view3d_navigate_zoom.c b/source/blender/editors/space_view3d/view3d_navigate_zoom.c index d7b1daa93c2..a6c7d06c079 100644 --- a/source/blender/editors/space_view3d/view3d_navigate_zoom.c +++ b/source/blender/editors/space_view3d/view3d_navigate_zoom.c @@ -548,7 +548,8 @@ static int viewzoom_invoke(bContext *C, wmOperator *op, const wmEvent *event) (use_cursor_init && (U.uiflag & USER_ZOOM_TO_MOUSEPOS))); ED_view3d_camera_lock_autokey(vod->v3d, vod->rv3d, C, false, true); - viewops_data_free(C, op); + viewops_data_free(C, op->customdata); + op->customdata = NULL; return OPERATOR_FINISHED; } @@ -568,7 +569,8 @@ static int viewzoom_invoke(bContext *C, wmOperator *op, const wmEvent *event) static void viewzoom_cancel(bContext *C, wmOperator *op) { - viewops_data_free(C, op); + viewops_data_free(C, op->customdata); + op->customdata = NULL; } void VIEW3D_OT_zoom(wmOperatorType *ot) -- cgit v1.2.3