diff options
Diffstat (limited to 'source/blender/editors/space_view3d')
16 files changed, 899 insertions, 873 deletions
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index df743415fec..a8514967748 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -89,9 +89,9 @@ RegionView3D *ED_view3d_context_rv3d(bContext *C) if (rv3d == NULL) { ScrArea *sa = CTX_wm_area(C); if (sa && sa->spacetype == SPACE_VIEW3D) { - ARegion *ar = BKE_area_find_region_active_win(sa); - if (ar) { - rv3d = ar->regiondata; + ARegion *region = BKE_area_find_region_active_win(sa); + if (region) { + rv3d = region->regiondata; } } } @@ -99,7 +99,7 @@ RegionView3D *ED_view3d_context_rv3d(bContext *C) } /* ideally would return an rv3d but in some cases the region is needed too - * so return that, the caller can then access the ar->regiondata */ + * so return that, the caller can then access the region->regiondata */ bool ED_view3d_context_user_region(bContext *C, View3D **r_v3d, ARegion **r_ar) { ScrArea *sa = CTX_wm_area(C); @@ -108,28 +108,28 @@ bool ED_view3d_context_user_region(bContext *C, View3D **r_v3d, ARegion **r_ar) *r_ar = NULL; if (sa && sa->spacetype == SPACE_VIEW3D) { - ARegion *ar = CTX_wm_region(C); + ARegion *region = CTX_wm_region(C); View3D *v3d = (View3D *)sa->spacedata.first; - if (ar) { + if (region) { RegionView3D *rv3d; - if ((ar->regiontype == RGN_TYPE_WINDOW) && (rv3d = ar->regiondata) && + if ((region->regiontype == RGN_TYPE_WINDOW) && (rv3d = region->regiondata) && (rv3d->viewlock & RV3D_LOCKED) == 0) { *r_v3d = v3d; - *r_ar = ar; + *r_ar = region; return true; } else { ARegion *ar_unlock_user = NULL; ARegion *ar_unlock = NULL; - for (ar = sa->regionbase.first; ar; ar = ar->next) { + for (region = sa->regionbase.first; region; region = region->next) { /* find the first unlocked rv3d */ - if (ar->regiondata && ar->regiontype == RGN_TYPE_WINDOW) { - rv3d = ar->regiondata; + if (region->regiondata && region->regiontype == RGN_TYPE_WINDOW) { + rv3d = region->regiondata; if ((rv3d->viewlock & RV3D_LOCKED) == 0) { - ar_unlock = ar; + ar_unlock = region; if (rv3d->persp == RV3D_PERSP || rv3d->persp == RV3D_CAMOB) { - ar_unlock_user = ar; + ar_unlock_user = region; break; } } @@ -201,16 +201,16 @@ void ED_view3d_check_mats_rv3d(struct RegionView3D *rv3d) } #endif -void ED_view3d_stop_render_preview(wmWindowManager *wm, ARegion *ar) +void ED_view3d_stop_render_preview(wmWindowManager *wm, ARegion *region) { - RegionView3D *rv3d = ar->regiondata; + RegionView3D *rv3d = region->regiondata; if (rv3d->render_engine) { #ifdef WITH_PYTHON BPy_BEGIN_ALLOW_THREADS; #endif - WM_jobs_kill_type(wm, ar, WM_JOB_TYPE_RENDER_PREVIEW); + WM_jobs_kill_type(wm, region, WM_JOB_TYPE_RENDER_PREVIEW); #ifdef WITH_PYTHON BPy_END_ALLOW_THREADS; @@ -226,11 +226,11 @@ void ED_view3d_shade_update(Main *bmain, View3D *v3d, ScrArea *sa) wmWindowManager *wm = bmain->wm.first; if (v3d->shading.type != OB_RENDER) { - ARegion *ar; + ARegion *region; - for (ar = sa->regionbase.first; ar; ar = ar->next) { - if ((ar->regiontype == RGN_TYPE_WINDOW) && ar->regiondata) { - ED_view3d_stop_render_preview(wm, ar); + for (region = sa->regionbase.first; region; region = region->next) { + if ((region->regiontype == RGN_TYPE_WINDOW) && region->regiondata) { + ED_view3d_stop_render_preview(wm, region); break; } } @@ -241,7 +241,7 @@ void ED_view3d_shade_update(Main *bmain, View3D *v3d, ScrArea *sa) static SpaceLink *view3d_new(const ScrArea *UNUSED(sa), const Scene *scene) { - ARegion *ar; + ARegion *region; View3D *v3d; RegionView3D *rv3d; @@ -252,44 +252,44 @@ static SpaceLink *view3d_new(const ScrArea *UNUSED(sa), const Scene *scene) } /* tool header */ - ar = MEM_callocN(sizeof(ARegion), "tool header for view3d"); + region = MEM_callocN(sizeof(ARegion), "tool header for view3d"); - BLI_addtail(&v3d->regionbase, ar); - ar->regiontype = RGN_TYPE_TOOL_HEADER; - ar->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP; - ar->flag = RGN_FLAG_HIDDEN | RGN_FLAG_HIDDEN_BY_USER; + BLI_addtail(&v3d->regionbase, region); + region->regiontype = RGN_TYPE_TOOL_HEADER; + region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP; + region->flag = RGN_FLAG_HIDDEN | RGN_FLAG_HIDDEN_BY_USER; /* header */ - ar = MEM_callocN(sizeof(ARegion), "header for view3d"); + region = MEM_callocN(sizeof(ARegion), "header for view3d"); - BLI_addtail(&v3d->regionbase, ar); - ar->regiontype = RGN_TYPE_HEADER; - ar->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP; + BLI_addtail(&v3d->regionbase, region); + region->regiontype = RGN_TYPE_HEADER; + region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP; /* tool shelf */ - ar = MEM_callocN(sizeof(ARegion), "toolshelf for view3d"); + region = MEM_callocN(sizeof(ARegion), "toolshelf for view3d"); - BLI_addtail(&v3d->regionbase, ar); - ar->regiontype = RGN_TYPE_TOOLS; - ar->alignment = RGN_ALIGN_LEFT; - ar->flag = RGN_FLAG_HIDDEN; + BLI_addtail(&v3d->regionbase, region); + region->regiontype = RGN_TYPE_TOOLS; + region->alignment = RGN_ALIGN_LEFT; + region->flag = RGN_FLAG_HIDDEN; /* buttons/list view */ - ar = MEM_callocN(sizeof(ARegion), "buttons for view3d"); + region = MEM_callocN(sizeof(ARegion), "buttons for view3d"); - BLI_addtail(&v3d->regionbase, ar); - ar->regiontype = RGN_TYPE_UI; - ar->alignment = RGN_ALIGN_RIGHT; - ar->flag = RGN_FLAG_HIDDEN; + BLI_addtail(&v3d->regionbase, region); + region->regiontype = RGN_TYPE_UI; + region->alignment = RGN_ALIGN_RIGHT; + region->flag = RGN_FLAG_HIDDEN; /* main region */ - ar = MEM_callocN(sizeof(ARegion), "main region for view3d"); + region = MEM_callocN(sizeof(ARegion), "main region for view3d"); - BLI_addtail(&v3d->regionbase, ar); - ar->regiontype = RGN_TYPE_WINDOW; + BLI_addtail(&v3d->regionbase, region); + region->regiontype = RGN_TYPE_WINDOW; - ar->regiondata = MEM_callocN(sizeof(RegionView3D), "region view3d"); - rv3d = ar->regiondata; + region->regiondata = MEM_callocN(sizeof(RegionView3D), "region view3d"); + rv3d = region->regiondata; rv3d->viewquat[0] = 1.0f; rv3d->persp = RV3D_PERSP; rv3d->view = RV3D_VIEW_USER; @@ -353,7 +353,7 @@ static SpaceLink *view3d_duplicate(SpaceLink *sl) } /* add handlers, stuff you only do once or on area/region changes */ -static void view3d_main_region_init(wmWindowManager *wm, ARegion *ar) +static void view3d_main_region_init(wmWindowManager *wm, ARegion *region) { ListBase *lb; wmKeyMap *keymap; @@ -362,78 +362,78 @@ static void view3d_main_region_init(wmWindowManager *wm, ARegion *ar) /* important to be before Pose keymap since they can both be enabled at once */ keymap = WM_keymap_ensure(wm->defaultconf, "Paint Face Mask (Weight, Vertex, Texture)", 0, 0); - WM_event_add_keymap_handler(&ar->handlers, keymap); + WM_event_add_keymap_handler(®ion->handlers, keymap); keymap = WM_keymap_ensure(wm->defaultconf, "Paint Vertex Selection (Weight, Vertex)", 0, 0); - WM_event_add_keymap_handler(&ar->handlers, keymap); + WM_event_add_keymap_handler(®ion->handlers, keymap); /* Before 'Pose' so weight paint menus aren't overridden by pose menus. */ keymap = WM_keymap_ensure(wm->defaultconf, "Weight Paint", 0, 0); - WM_event_add_keymap_handler(&ar->handlers, keymap); + WM_event_add_keymap_handler(®ion->handlers, keymap); keymap = WM_keymap_ensure(wm->defaultconf, "Vertex Paint", 0, 0); - WM_event_add_keymap_handler(&ar->handlers, keymap); + WM_event_add_keymap_handler(®ion->handlers, keymap); /* pose is not modal, operator poll checks for this */ keymap = WM_keymap_ensure(wm->defaultconf, "Pose", 0, 0); - WM_event_add_keymap_handler(&ar->handlers, keymap); + WM_event_add_keymap_handler(®ion->handlers, keymap); keymap = WM_keymap_ensure(wm->defaultconf, "Object Mode", 0, 0); - WM_event_add_keymap_handler(&ar->handlers, keymap); + WM_event_add_keymap_handler(®ion->handlers, keymap); keymap = WM_keymap_ensure(wm->defaultconf, "Paint Curve", 0, 0); - WM_event_add_keymap_handler(&ar->handlers, keymap); + WM_event_add_keymap_handler(®ion->handlers, keymap); keymap = WM_keymap_ensure(wm->defaultconf, "Curve", 0, 0); - WM_event_add_keymap_handler(&ar->handlers, keymap); + WM_event_add_keymap_handler(®ion->handlers, keymap); keymap = WM_keymap_ensure(wm->defaultconf, "Image Paint", 0, 0); - WM_event_add_keymap_handler(&ar->handlers, keymap); + WM_event_add_keymap_handler(®ion->handlers, keymap); keymap = WM_keymap_ensure(wm->defaultconf, "Sculpt", 0, 0); - WM_event_add_keymap_handler(&ar->handlers, keymap); + WM_event_add_keymap_handler(®ion->handlers, keymap); keymap = WM_keymap_ensure(wm->defaultconf, "Mesh", 0, 0); - WM_event_add_keymap_handler(&ar->handlers, keymap); + WM_event_add_keymap_handler(®ion->handlers, keymap); keymap = WM_keymap_ensure(wm->defaultconf, "Armature", 0, 0); - WM_event_add_keymap_handler(&ar->handlers, keymap); + WM_event_add_keymap_handler(®ion->handlers, keymap); keymap = WM_keymap_ensure(wm->defaultconf, "Metaball", 0, 0); - WM_event_add_keymap_handler(&ar->handlers, keymap); + WM_event_add_keymap_handler(®ion->handlers, keymap); keymap = WM_keymap_ensure(wm->defaultconf, "Lattice", 0, 0); - WM_event_add_keymap_handler(&ar->handlers, keymap); + WM_event_add_keymap_handler(®ion->handlers, keymap); keymap = WM_keymap_ensure(wm->defaultconf, "Particle", 0, 0); - WM_event_add_keymap_handler(&ar->handlers, keymap); + WM_event_add_keymap_handler(®ion->handlers, keymap); /* editfont keymap swallows all... */ keymap = WM_keymap_ensure(wm->defaultconf, "Font", 0, 0); - WM_event_add_keymap_handler(&ar->handlers, keymap); + WM_event_add_keymap_handler(®ion->handlers, keymap); keymap = WM_keymap_ensure(wm->defaultconf, "Object Non-modal", 0, 0); - WM_event_add_keymap_handler(&ar->handlers, keymap); + WM_event_add_keymap_handler(®ion->handlers, keymap); keymap = WM_keymap_ensure(wm->defaultconf, "Frames", 0, 0); - WM_event_add_keymap_handler(&ar->handlers, keymap); + WM_event_add_keymap_handler(®ion->handlers, keymap); /* own keymap, last so modes can override it */ keymap = WM_keymap_ensure(wm->defaultconf, "3D View Generic", SPACE_VIEW3D, 0); - WM_event_add_keymap_handler(&ar->handlers, keymap); + WM_event_add_keymap_handler(®ion->handlers, keymap); keymap = WM_keymap_ensure(wm->defaultconf, "3D View", SPACE_VIEW3D, 0); - WM_event_add_keymap_handler(&ar->handlers, keymap); + WM_event_add_keymap_handler(®ion->handlers, keymap); /* add drop boxes */ lb = WM_dropboxmap_find("View3D", SPACE_VIEW3D, RGN_TYPE_WINDOW); - WM_event_add_dropbox_handler(&ar->handlers, lb); + WM_event_add_dropbox_handler(®ion->handlers, lb); } -static void view3d_main_region_exit(wmWindowManager *wm, ARegion *ar) +static void view3d_main_region_exit(wmWindowManager *wm, ARegion *region) { - ED_view3d_stop_render_preview(wm, ar); + ED_view3d_stop_render_preview(wm, region); } static bool view3d_ob_drop_poll(bContext *UNUSED(C), @@ -632,9 +632,9 @@ static void view3d_widgets(void) } /* type callback, not region itself */ -static void view3d_main_region_free(ARegion *ar) +static void view3d_main_region_free(ARegion *region) { - RegionView3D *rv3d = ar->regiondata; + RegionView3D *rv3d = region->regiondata; if (rv3d) { if (rv3d->localvd) { @@ -659,7 +659,7 @@ static void view3d_main_region_free(ARegion *ar) } MEM_freeN(rv3d); - ar->regiondata = NULL; + region->regiondata = NULL; } } @@ -688,11 +688,11 @@ static void *view3d_main_region_duplicate(void *poin) } static void view3d_main_region_listener( - wmWindow *UNUSED(win), ScrArea *sa, ARegion *ar, wmNotifier *wmn, const Scene *scene) + wmWindow *UNUSED(win), ScrArea *sa, ARegion *region, wmNotifier *wmn, const Scene *scene) { View3D *v3d = sa->spacedata.first; - RegionView3D *rv3d = ar->regiondata; - wmGizmoMap *gzmap = ar->gizmo_map; + RegionView3D *rv3d = region->regiondata; + wmGizmoMap *gzmap = region->gizmo_map; /* context changes */ switch (wmn->category) { @@ -705,17 +705,17 @@ static void view3d_main_region_listener( switch (wmn->data) { case ND_KEYFRAME_PROP: case ND_NLA_ACTCHANGE: - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); break; case ND_NLA: case ND_KEYFRAME: if (ELEM(wmn->action, NA_EDITED, NA_ADDED, NA_REMOVED)) { - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); } break; case ND_ANIMCHAN: if (ELEM(wmn->action, NA_EDITED, NA_ADDED, NA_REMOVED, NA_SELECTED)) { - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); } break; } @@ -724,14 +724,14 @@ static void view3d_main_region_listener( switch (wmn->data) { case ND_SCENEBROWSE: case ND_LAYER_CONTENT: - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); WM_gizmomap_tag_refresh(gzmap); break; case ND_LAYER: if (wmn->reference) { BKE_screen_view3d_sync(v3d, wmn->reference); } - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); WM_gizmomap_tag_refresh(gzmap); break; case ND_OB_ACTIVE: @@ -743,7 +743,7 @@ static void view3d_main_region_listener( case ND_RENDER_OPTIONS: case ND_MARKERS: case ND_MODE: - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); WM_gizmomap_tag_refresh(gzmap); break; case ND_WORLD: @@ -752,14 +752,14 @@ static void view3d_main_region_listener( case ND_DRAW_RENDER_VIEWPORT: { if (v3d->camera && (scene == wmn->reference)) { if (rv3d->persp == RV3D_CAMOB) { - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); } } break; } } if (wmn->action == NA_EDITED) { - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); } break; case NC_OBJECT: @@ -775,13 +775,13 @@ static void view3d_main_region_listener( case ND_PARTICLE: case ND_POINTCACHE: case ND_LOD: - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); WM_gizmomap_tag_refresh(gzmap); break; } switch (wmn->action) { case NA_ADDED: - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); break; } break; @@ -792,16 +792,16 @@ static void view3d_main_region_listener( ATTR_FALLTHROUGH; } case ND_DATA: - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); WM_gizmomap_tag_refresh(gzmap); break; case ND_VERTEX_GROUP: - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); break; } switch (wmn->action) { case NA_EDITED: - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); break; } break; @@ -810,7 +810,7 @@ static void view3d_main_region_listener( case ND_DRAW_RENDER_VIEWPORT: { if (v3d->camera && (v3d->camera->data == wmn->reference)) { if (rv3d->persp == RV3D_CAMOB) { - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); } } break; @@ -819,17 +819,17 @@ static void view3d_main_region_listener( break; case NC_GROUP: /* all group ops for now */ - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); break; case NC_BRUSH: switch (wmn->action) { case NA_EDITED: - ED_region_tag_redraw_cursor(ar); + ED_region_tag_redraw_cursor(region); break; case NA_SELECTED: /* used on brush changes - needed because 3d cursor * has to be drawn if clone brush is selected */ - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); break; } break; @@ -842,11 +842,11 @@ static void view3d_main_region_listener( * * How to solve? */ - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); break; case ND_SHADING_DRAW: case ND_SHADING_LINKS: - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); break; } break; @@ -857,7 +857,7 @@ static void view3d_main_region_listener( break; case ND_WORLD: /* Needed for updating world materials */ - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); break; } break; @@ -867,10 +867,10 @@ static void view3d_main_region_listener( /* TODO(sergey): This is a bit too much, but needed to * handle updates from new depsgraph. */ - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); break; case ND_LIGHTING_DRAW: - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); WM_gizmomap_tag_refresh(gzmap); break; } @@ -881,15 +881,15 @@ static void view3d_main_region_listener( case NC_IMAGE: /* this could be more fine grained checks if we had * more context than just the region */ - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); break; case NC_TEXTURE: /* same as above */ - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); break; case NC_MOVIECLIP: if (wmn->data == ND_DISPLAY || wmn->action == NA_EDITED) { - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); } break; case NC_SPACE: @@ -897,36 +897,36 @@ static void view3d_main_region_listener( if (wmn->subtype == NS_VIEW3D_GPU) { rv3d->rflag |= RV3D_GPULIGHT_UPDATE; } - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); WM_gizmomap_tag_refresh(gzmap); } break; case NC_ID: if (wmn->action == NA_RENAME) { - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); } break; case NC_SCREEN: switch (wmn->data) { case ND_ANIMPLAY: case ND_SKETCH: - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); break; case ND_LAYOUTBROWSE: case ND_LAYOUTDELETE: case ND_LAYOUTSET: WM_gizmomap_tag_refresh(gzmap); - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); break; case ND_LAYER: - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); break; } break; case NC_GPENCIL: if (wmn->data == ND_DATA || ELEM(wmn->action, NA_EDITED, NA_SELECTED)) { - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); } break; } @@ -937,7 +937,7 @@ static void view3d_main_region_message_subscribe(const struct bContext *C, struct Scene *UNUSED(scene), struct bScreen *UNUSED(screen), struct ScrArea *sa, - struct ARegion *ar, + struct ARegion *region, struct wmMsgBus *mbus) { /* Developer note: there are many properties that impact 3D view drawing, @@ -968,8 +968,8 @@ static void view3d_main_region_message_subscribe(const struct bContext *C, }; wmMsgSubscribeValue msg_sub_value_region_tag_redraw = { - .owner = ar, - .user_data = ar, + .owner = region, + .user_data = region, .notify = ED_region_do_msg_notify_tag_redraw, }; @@ -979,7 +979,7 @@ static void view3d_main_region_message_subscribe(const struct bContext *C, } /* Subscribe to a handful of other properties. */ - RegionView3D *rv3d = ar->regiondata; + RegionView3D *rv3d = region->regiondata; WM_msg_subscribe_rna_anon_prop(mbus, RenderSettings, engine, &msg_sub_value_region_tag_redraw); WM_msg_subscribe_rna_anon_prop( @@ -1013,7 +1013,7 @@ static void view3d_main_region_message_subscribe(const struct bContext *C, { wmMsgSubscribeValue msg_sub_value_region_tag_refresh = { - .owner = ar, + .owner = region, .user_data = sa, .notify = WM_toolsystem_do_msg_notify_tag_refresh, }; @@ -1022,31 +1022,31 @@ static void view3d_main_region_message_subscribe(const struct bContext *C, } } -static void view3d_main_region_cursor(wmWindow *win, ScrArea *sa, ARegion *ar) +static void view3d_main_region_cursor(wmWindow *win, ScrArea *sa, ARegion *region) { - if (!WM_cursor_set_from_tool(win, sa, ar)) { + if (!WM_cursor_set_from_tool(win, sa, region)) { WM_cursor_set(win, WM_CURSOR_DEFAULT); } } /* add handlers, stuff you only do once or on area/region changes */ -static void view3d_header_region_init(wmWindowManager *wm, ARegion *ar) +static void view3d_header_region_init(wmWindowManager *wm, ARegion *region) { wmKeyMap *keymap = WM_keymap_ensure(wm->defaultconf, "3D View Generic", SPACE_VIEW3D, 0); - WM_event_add_keymap_handler(&ar->handlers, keymap); + WM_event_add_keymap_handler(®ion->handlers, keymap); - ED_region_header_init(ar); + ED_region_header_init(region); } -static void view3d_header_region_draw(const bContext *C, ARegion *ar) +static void view3d_header_region_draw(const bContext *C, ARegion *region) { - ED_region_header(C, ar); + ED_region_header(C, region); } static void view3d_header_region_listener(wmWindow *UNUSED(win), ScrArea *UNUSED(sa), - ARegion *ar, + ARegion *region, wmNotifier *wmn, const Scene *UNUSED(scene)) { @@ -1063,25 +1063,25 @@ static void view3d_header_region_listener(wmWindow *UNUSED(win), case ND_TOOLSETTINGS: case ND_LAYER_CONTENT: case ND_RENDER_OPTIONS: - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); break; } break; case NC_SPACE: if (wmn->data == ND_SPACE_VIEW3D) { - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); } break; case NC_GPENCIL: if (wmn->data & ND_GPENCIL_EDITMODE) { - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); } else if (wmn->action == NA_EDITED) { - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); } break; case NC_BRUSH: - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); break; } @@ -1092,22 +1092,22 @@ static void view3d_header_region_listener(wmWindow *UNUSED(win), switch (wmn->category) { case NC_WM: if (wmn->data == ND_HISTORY) { - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); } break; case NC_SCENE: if (wmn->data == ND_MODE) { - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); } break; case NC_SPACE: if (wmn->data == ND_SPACE_VIEW3D) { - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); } break; case NC_GPENCIL: if (wmn->data == ND_DATA) { - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); } break; } @@ -1119,7 +1119,7 @@ static void view3d_header_region_message_subscribe(const struct bContext *UNUSED struct Scene *UNUSED(scene), struct bScreen *UNUSED(screen), struct ScrArea *UNUSED(sa), - struct ARegion *ar, + struct ARegion *region, struct wmMsgBus *mbus) { wmMsgParams_RNA msg_key_params = {{0}}; @@ -1130,8 +1130,8 @@ static void view3d_header_region_message_subscribe(const struct bContext *UNUSED }; wmMsgSubscribeValue msg_sub_value_region_tag_redraw = { - .owner = ar, - .user_data = ar, + .owner = region, + .user_data = region, .notify = ED_region_do_msg_notify_tag_redraw, }; @@ -1142,18 +1142,18 @@ static void view3d_header_region_message_subscribe(const struct bContext *UNUSED } /* add handlers, stuff you only do once or on area/region changes */ -static void view3d_buttons_region_init(wmWindowManager *wm, ARegion *ar) +static void view3d_buttons_region_init(wmWindowManager *wm, ARegion *region) { wmKeyMap *keymap; - ED_region_panels_init(wm, ar); + ED_region_panels_init(wm, region); keymap = WM_keymap_ensure(wm->defaultconf, "3D View Generic", SPACE_VIEW3D, 0); - WM_event_add_keymap_handler(&ar->handlers, keymap); + WM_event_add_keymap_handler(®ion->handlers, keymap); } void ED_view3d_buttons_region_layout_ex(const bContext *C, - ARegion *ar, + ARegion *region, const char *category_override) { const enum eContextObjectMode mode = CTX_data_mode_enum(C); @@ -1236,7 +1236,7 @@ void ED_view3d_buttons_region_layout_ex(const bContext *C, break; } - ListBase *paneltypes = &ar->type->paneltypes; + ListBase *paneltypes = ®ion->type->paneltypes; /* Allow drawing 3D view toolbar from non 3D view space type. */ if (category_override != NULL) { @@ -1246,17 +1246,18 @@ void ED_view3d_buttons_region_layout_ex(const bContext *C, } const bool vertical = true; - ED_region_panels_layout_ex(C, ar, paneltypes, contexts_base, -1, vertical, category_override); + ED_region_panels_layout_ex( + C, region, paneltypes, contexts_base, -1, vertical, category_override); } -static void view3d_buttons_region_layout(const bContext *C, ARegion *ar) +static void view3d_buttons_region_layout(const bContext *C, ARegion *region) { - ED_view3d_buttons_region_layout_ex(C, ar, NULL); + ED_view3d_buttons_region_layout_ex(C, region, NULL); } static void view3d_buttons_region_listener(wmWindow *UNUSED(win), ScrArea *UNUSED(sa), - ARegion *ar, + ARegion *region, wmNotifier *wmn, const Scene *UNUSED(scene)) { @@ -1266,12 +1267,12 @@ static void view3d_buttons_region_listener(wmWindow *UNUSED(win), switch (wmn->data) { case ND_KEYFRAME_PROP: case ND_NLA_ACTCHANGE: - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); break; case ND_NLA: case ND_KEYFRAME: if (ELEM(wmn->action, NA_EDITED, NA_ADDED, NA_REMOVED)) { - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); } break; } @@ -1286,12 +1287,12 @@ static void view3d_buttons_region_listener(wmWindow *UNUSED(win), case ND_LAYER: case ND_LAYER_CONTENT: case ND_TOOLSETTINGS: - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); break; } switch (wmn->action) { case NA_EDITED: - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); break; } break; @@ -1304,7 +1305,7 @@ static void view3d_buttons_region_listener(wmWindow *UNUSED(win), case ND_DRAW: case ND_KEYS: case ND_MODIFIER: - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); break; } break; @@ -1313,62 +1314,62 @@ static void view3d_buttons_region_listener(wmWindow *UNUSED(win), case ND_DATA: case ND_VERTEX_GROUP: case ND_SELECT: - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); break; } if (wmn->action == NA_EDITED) { - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); } break; case NC_TEXTURE: case NC_MATERIAL: /* for brush textures */ - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); break; case NC_BRUSH: /* NA_SELECTED is used on brush changes */ if (ELEM(wmn->action, NA_EDITED, NA_SELECTED)) { - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); } break; case NC_SPACE: if (wmn->data == ND_SPACE_VIEW3D) { - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); } break; case NC_ID: if (wmn->action == NA_RENAME) { - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); } break; case NC_GPENCIL: if ((wmn->data & (ND_DATA | ND_GPENCIL_EDITMODE)) || (wmn->action == NA_EDITED)) { - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); } break; case NC_IMAGE: /* Update for the image layers in texture paint. */ if (wmn->action == NA_EDITED) { - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); } break; } } /* add handlers, stuff you only do once or on area/region changes */ -static void view3d_tools_region_init(wmWindowManager *wm, ARegion *ar) +static void view3d_tools_region_init(wmWindowManager *wm, ARegion *region) { wmKeyMap *keymap; - ED_region_panels_init(wm, ar); + ED_region_panels_init(wm, region); keymap = WM_keymap_ensure(wm->defaultconf, "3D View Generic", SPACE_VIEW3D, 0); - WM_event_add_keymap_handler(&ar->handlers, keymap); + WM_event_add_keymap_handler(®ion->handlers, keymap); } -static void view3d_tools_region_draw(const bContext *C, ARegion *ar) +static void view3d_tools_region_draw(const bContext *C, ARegion *region) { - ED_region_panels_ex(C, ar, (const char *[]){CTX_data_mode_string(C), NULL}, -1, true); + ED_region_panels_ex(C, region, (const char *[]){CTX_data_mode_string(C), NULL}, -1, true); } /* area (not region) level listener */ @@ -1473,7 +1474,7 @@ static int view3d_context(const bContext *C, const char *member, bContextDataRes static void view3d_id_remap(ScrArea *sa, SpaceLink *slink, ID *old_id, ID *new_id) { View3D *v3d; - ARegion *ar; + ARegion *region; bool is_local = false; if (!ELEM(GS(old_id->name), ID_OB, ID_MA, ID_IM, ID_MC)) { @@ -1487,10 +1488,10 @@ static void view3d_id_remap(ScrArea *sa, SpaceLink *slink, ID *old_id, ID *new_i /* 3D view might be inactive, in that case needs to use slink->regionbase */ ListBase *regionbase = (slink == sa->spacedata.first) ? &sa->regionbase : &slink->regionbase; - for (ar = regionbase->first; ar; ar = ar->next) { - if (ar->regiontype == RGN_TYPE_WINDOW) { - RegionView3D *rv3d = is_local ? ((RegionView3D *)ar->regiondata)->localvd : - ar->regiondata; + for (region = regionbase->first; region; region = region->next) { + if (region->regiontype == RGN_TYPE_WINDOW) { + RegionView3D *rv3d = is_local ? ((RegionView3D *)region->regiondata)->localvd : + region->regiondata; if (rv3d && (rv3d->persp == RV3D_CAMOB)) { rv3d->persp = RV3D_PERSP; } diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 101e04664ec..4e2aada1e26 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -111,20 +111,20 @@ void ED_view3d_update_viewmat(Depsgraph *depsgraph, Scene *scene, View3D *v3d, - ARegion *ar, + ARegion *region, float viewmat[4][4], float winmat[4][4], const rcti *rect, bool offscreen) { - RegionView3D *rv3d = ar->regiondata; + RegionView3D *rv3d = region->regiondata; /* setup window matrices */ if (winmat) { copy_m4_m4(rv3d->winmat, winmat); } else { - view3d_winmatrix_set(depsgraph, ar, v3d, rect); + view3d_winmatrix_set(depsgraph, region, v3d, rect); } /* setup view matrix */ @@ -134,8 +134,8 @@ void ED_view3d_update_viewmat(Depsgraph *depsgraph, else { float rect_scale[2]; if (rect) { - rect_scale[0] = (float)BLI_rcti_size_x(rect) / (float)ar->winx; - rect_scale[1] = (float)BLI_rcti_size_y(rect) / (float)ar->winy; + rect_scale[0] = (float)BLI_rcti_size_x(rect) / (float)region->winx; + rect_scale[1] = (float)BLI_rcti_size_y(rect) / (float)region->winy; } /* note: calls BKE_object_where_is_calc for camera... */ view3d_viewmatrix_set(depsgraph, scene, v3d, rv3d, rect ? rect_scale : NULL); @@ -150,12 +150,12 @@ void ED_view3d_update_viewmat(Depsgraph *depsgraph, /* store window coordinates scaling/offset */ if (!offscreen && rv3d->persp == RV3D_CAMOB && v3d->camera) { rctf cameraborder; - ED_view3d_calc_camera_border(scene, depsgraph, ar, v3d, rv3d, &cameraborder, false); - rv3d->viewcamtexcofac[0] = (float)ar->winx / BLI_rctf_size_x(&cameraborder); - rv3d->viewcamtexcofac[1] = (float)ar->winy / BLI_rctf_size_y(&cameraborder); + ED_view3d_calc_camera_border(scene, depsgraph, region, v3d, rv3d, &cameraborder, false); + rv3d->viewcamtexcofac[0] = (float)region->winx / BLI_rctf_size_x(&cameraborder); + rv3d->viewcamtexcofac[1] = (float)region->winy / BLI_rctf_size_y(&cameraborder); - rv3d->viewcamtexcofac[2] = -rv3d->viewcamtexcofac[0] * cameraborder.xmin / (float)ar->winx; - rv3d->viewcamtexcofac[3] = -rv3d->viewcamtexcofac[1] * cameraborder.ymin / (float)ar->winy; + rv3d->viewcamtexcofac[2] = -rv3d->viewcamtexcofac[0] * cameraborder.xmin / (float)region->winx; + rv3d->viewcamtexcofac[3] = -rv3d->viewcamtexcofac[1] * cameraborder.ymin / (float)region->winy; } else { rv3d->viewcamtexcofac[0] = rv3d->viewcamtexcofac[1] = 1.0f; @@ -183,7 +183,7 @@ void ED_view3d_update_viewmat(Depsgraph *depsgraph, len_sc = (float)max_ii(BLI_rcti_size_x(rect), BLI_rcti_size_y(rect)); } else { - len_sc = (float)MAX2(ar->winx, ar->winy); + len_sc = (float)MAX2(region->winx, region->winy); } rv3d->pixsize = len_px / len_sc; @@ -193,14 +193,14 @@ void ED_view3d_update_viewmat(Depsgraph *depsgraph, static void view3d_main_region_setup_view(Depsgraph *depsgraph, Scene *scene, View3D *v3d, - ARegion *ar, + ARegion *region, float viewmat[4][4], float winmat[4][4], const rcti *rect) { - RegionView3D *rv3d = ar->regiondata; + RegionView3D *rv3d = region->regiondata; - ED_view3d_update_viewmat(depsgraph, scene, v3d, ar, viewmat, winmat, rect, false); + ED_view3d_update_viewmat(depsgraph, scene, v3d, region, viewmat, winmat, rect, false); /* set for opengl */ GPU_matrix_projection_set(rv3d->winmat); @@ -210,12 +210,12 @@ static void view3d_main_region_setup_view(Depsgraph *depsgraph, static void view3d_main_region_setup_offscreen(Depsgraph *depsgraph, Scene *scene, View3D *v3d, - ARegion *ar, + ARegion *region, float viewmat[4][4], float winmat[4][4]) { - RegionView3D *rv3d = ar->regiondata; - ED_view3d_update_viewmat(depsgraph, scene, v3d, ar, viewmat, winmat, NULL, true); + RegionView3D *rv3d = region->regiondata; + ED_view3d_update_viewmat(depsgraph, scene, v3d, region, viewmat, winmat, NULL, true); /* set for opengl */ GPU_matrix_projection_set(rv3d->winmat); @@ -264,7 +264,7 @@ static bool view3d_stereo3d_active(wmWindow *win, Scene *scene, View3D *v3d, Reg * view3d)main_region_setup_view() code to account for that. */ static void view3d_stereo3d_setup( - Depsgraph *depsgraph, Scene *scene, View3D *v3d, ARegion *ar, const rcti *rect) + Depsgraph *depsgraph, Scene *scene, View3D *v3d, ARegion *region, const rcti *rect) { bool is_left; const char *names[2] = {STEREO_LEFT_NAME, STEREO_RIGHT_NAME}; @@ -293,7 +293,7 @@ static void view3d_stereo3d_setup( data_eval->shiftx = BKE_camera_multiview_shift_x(&scene->r, v3d->camera, viewname); BKE_camera_multiview_view_matrix(&scene->r, v3d->camera, is_left, viewmat); - view3d_main_region_setup_view(depsgraph, scene, v3d, ar, viewmat, NULL, rect); + view3d_main_region_setup_view(depsgraph, scene, v3d, region, viewmat, NULL, rect); data_eval->shiftx = shiftx; BLI_thread_unlock(LOCK_VIEW3D); @@ -307,7 +307,7 @@ static void view3d_stereo3d_setup( v3d->camera = camera; BKE_camera_multiview_view_matrix(&scene->r, camera, false, viewmat); - view3d_main_region_setup_view(depsgraph, scene, v3d, ar, viewmat, NULL, rect); + view3d_main_region_setup_view(depsgraph, scene, v3d, region, viewmat, NULL, rect); v3d->camera = view_ob; BLI_thread_unlock(LOCK_VIEW3D); @@ -320,20 +320,20 @@ static void view3d_stereo3d_setup( void ED_view3d_draw_setup_view(wmWindow *win, Depsgraph *depsgraph, Scene *scene, - ARegion *ar, + ARegion *region, View3D *v3d, float viewmat[4][4], float winmat[4][4], const rcti *rect) { - RegionView3D *rv3d = ar->regiondata; + RegionView3D *rv3d = region->regiondata; /* Setup the view matrix. */ if (view3d_stereo3d_active(win, scene, v3d, rv3d)) { - view3d_stereo3d_setup(depsgraph, scene, v3d, ar, rect); + view3d_stereo3d_setup(depsgraph, scene, v3d, region, rect); } else { - view3d_main_region_setup_view(depsgraph, scene, v3d, ar, viewmat, winmat, rect); + view3d_main_region_setup_view(depsgraph, scene, v3d, region, viewmat, winmat, rect); } } @@ -345,7 +345,7 @@ void ED_view3d_draw_setup_view(wmWindow *win, static void view3d_camera_border(const Scene *scene, struct Depsgraph *depsgraph, - const ARegion *ar, + const ARegion *region, const View3D *v3d, const RegionView3D *rv3d, rctf *r_viewborder, @@ -362,7 +362,7 @@ static void view3d_camera_border(const Scene *scene, if (no_zoom) { params.zoom = 1.0f; } - BKE_camera_params_compute_viewplane(¶ms, ar->winx, ar->winy, 1.0f, 1.0f); + BKE_camera_params_compute_viewplane(¶ms, region->winx, region->winy, 1.0f, 1.0f); rect_view = params.viewplane; /* get camera viewplane */ @@ -381,38 +381,38 @@ static void view3d_camera_border(const Scene *scene, /* get camera border within viewport */ r_viewborder->xmin = ((rect_camera.xmin - rect_view.xmin) / BLI_rctf_size_x(&rect_view)) * - ar->winx; + region->winx; r_viewborder->xmax = ((rect_camera.xmax - rect_view.xmin) / BLI_rctf_size_x(&rect_view)) * - ar->winx; + region->winx; r_viewborder->ymin = ((rect_camera.ymin - rect_view.ymin) / BLI_rctf_size_y(&rect_view)) * - ar->winy; + region->winy; r_viewborder->ymax = ((rect_camera.ymax - rect_view.ymin) / BLI_rctf_size_y(&rect_view)) * - ar->winy; + region->winy; } void ED_view3d_calc_camera_border_size(const Scene *scene, Depsgraph *depsgraph, - const ARegion *ar, + const ARegion *region, const View3D *v3d, const RegionView3D *rv3d, float r_size[2]) { rctf viewborder; - view3d_camera_border(scene, depsgraph, ar, v3d, rv3d, &viewborder, true, true); + view3d_camera_border(scene, depsgraph, region, v3d, rv3d, &viewborder, true, true); r_size[0] = BLI_rctf_size_x(&viewborder); r_size[1] = BLI_rctf_size_y(&viewborder); } void ED_view3d_calc_camera_border(const Scene *scene, Depsgraph *depsgraph, - const ARegion *ar, + const ARegion *region, const View3D *v3d, const RegionView3D *rv3d, rctf *r_viewborder, const bool no_shift) { - view3d_camera_border(scene, depsgraph, ar, v3d, rv3d, r_viewborder, no_shift, false); + view3d_camera_border(scene, depsgraph, region, v3d, rv3d, r_viewborder, no_shift, false); } static void drawviewborder_grid3(uint shdr_pos, float x1, float x2, float y1, float y2, float fac) @@ -495,14 +495,14 @@ static void drawviewborder_triangle( immEnd(); } -static void drawviewborder(Scene *scene, Depsgraph *depsgraph, ARegion *ar, View3D *v3d) +static void drawviewborder(Scene *scene, Depsgraph *depsgraph, ARegion *region, View3D *v3d) { float x1, x2, y1, y2; float x1i, x2i, y1i, y2i; rctf viewborder; Camera *ca = NULL; - RegionView3D *rv3d = ar->regiondata; + RegionView3D *rv3d = region->regiondata; if (v3d->camera == NULL) { return; @@ -511,7 +511,7 @@ static void drawviewborder(Scene *scene, Depsgraph *depsgraph, ARegion *ar, View ca = v3d->camera->data; } - ED_view3d_calc_camera_border(scene, depsgraph, ar, v3d, rv3d, &viewborder, false); + ED_view3d_calc_camera_border(scene, depsgraph, region, v3d, rv3d, &viewborder, false); /* the offsets */ x1 = viewborder.xmin; y1 = viewborder.ymin; @@ -541,8 +541,8 @@ static void drawviewborder(Scene *scene, Depsgraph *depsgraph, ARegion *ar, View /* passepartout, specified in camera edit buttons */ if (ca && (ca->flag & CAM_SHOWPASSEPARTOUT) && ca->passepartalpha > 0.000001f) { - const float winx = (ar->winx + 1); - const float winy = (ar->winy + 1); + const float winx = (region->winx + 1); + const float winy = (region->winy + 1); float alpha = 1.0f; @@ -753,7 +753,7 @@ static void drawviewborder(Scene *scene, Depsgraph *depsgraph, ARegion *ar, View } } -static void drawrenderborder(ARegion *ar, View3D *v3d) +static void drawrenderborder(ARegion *region, View3D *v3d) { /* use the same program for everything */ uint shdr_pos = GPU_vertformat_attr_add( @@ -773,19 +773,19 @@ static void drawrenderborder(ARegion *ar, View3D *v3d) immUniform1f("dash_factor", 0.5f); imm_draw_box_wire_2d(shdr_pos, - v3d->render_border.xmin * ar->winx, - v3d->render_border.ymin * ar->winy, - v3d->render_border.xmax * ar->winx, - v3d->render_border.ymax * ar->winy); + v3d->render_border.xmin * region->winx, + v3d->render_border.ymin * region->winy, + v3d->render_border.xmax * region->winx, + v3d->render_border.ymax * region->winy); immUnbindProgram(); } -void ED_view3d_draw_depth(Depsgraph *depsgraph, ARegion *ar, View3D *v3d, bool alphaoverride) +void ED_view3d_draw_depth(Depsgraph *depsgraph, ARegion *region, View3D *v3d, bool alphaoverride) { struct bThemeState theme_state; Scene *scene = DEG_get_evaluated_scene(depsgraph); - RegionView3D *rv3d = ar->regiondata; + RegionView3D *rv3d = region->regiondata; short flag = v3d->flag; float glalphaclip = U.glalphaclip; @@ -800,7 +800,7 @@ void ED_view3d_draw_depth(Depsgraph *depsgraph, ARegion *ar, View3D *v3d, bool a UI_Theme_Store(&theme_state); UI_SetTheme(SPACE_VIEW3D, RGN_TYPE_WINDOW); - ED_view3d_draw_setup_view(NULL, depsgraph, scene, ar, v3d, NULL, NULL, NULL); + ED_view3d_draw_setup_view(NULL, depsgraph, scene, region, v3d, NULL, NULL, NULL); GPU_clear(GPU_DEPTH_BIT); @@ -813,17 +813,17 @@ void ED_view3d_draw_depth(Depsgraph *depsgraph, ARegion *ar, View3D *v3d, bool a GPU_depth_test(true); /* Needed in cases the view-port isn't already setup. */ - WM_draw_region_viewport_ensure(ar, SPACE_VIEW3D); - WM_draw_region_viewport_bind(ar); + WM_draw_region_viewport_ensure(region, SPACE_VIEW3D); + WM_draw_region_viewport_bind(region); - GPUViewport *viewport = WM_draw_region_get_viewport(ar, 0); + GPUViewport *viewport = WM_draw_region_get_viewport(region, 0); /* When Blender is starting, a click event can trigger a depth test while the viewport is not * yet available. */ if (viewport != NULL) { - DRW_draw_depth_loop(depsgraph, ar, v3d, viewport, false); + DRW_draw_depth_loop(depsgraph, region, v3d, viewport, false); } - WM_draw_region_viewport_unbind(ar); + WM_draw_region_viewport_unbind(region); if (RV3D_CLIPPING_ENABLED(v3d, rv3d)) { ED_view3d_clipping_disable(); @@ -1140,18 +1140,18 @@ static void draw_rotation_guide(const RegionView3D *rv3d) /** * Render and camera border */ -static void view3d_draw_border(const bContext *C, ARegion *ar) +static void view3d_draw_border(const bContext *C, ARegion *region) { Scene *scene = CTX_data_scene(C); Depsgraph *depsgraph = CTX_data_expect_evaluated_depsgraph(C); - RegionView3D *rv3d = ar->regiondata; + RegionView3D *rv3d = region->regiondata; View3D *v3d = CTX_wm_view3d(C); if (rv3d->persp == RV3D_CAMOB) { - drawviewborder(scene, depsgraph, ar, v3d); + drawviewborder(scene, depsgraph, region, v3d); } else if (v3d->flag2 & V3D_RENDER_BORDER) { - drawrenderborder(ar, v3d); + drawrenderborder(region, v3d); } } @@ -1255,9 +1255,9 @@ static const char *view3d_get_name(View3D *v3d, RegionView3D *rv3d) return name; } -static void draw_viewport_name(ARegion *ar, View3D *v3d, int xoffset, int *yoffset) +static void draw_viewport_name(ARegion *region, View3D *v3d, int xoffset, int *yoffset) { - RegionView3D *rv3d = ar->regiondata; + RegionView3D *rv3d = region->regiondata; const char *name = view3d_get_name(v3d, rv3d); const char *name_array[3] = {name, NULL, NULL}; int name_array_len = 1; @@ -1470,9 +1470,9 @@ static void draw_grid_unit_name( /** * Information drawn on top of the solid plates and composed data */ -void view3d_draw_region_info(const bContext *C, ARegion *ar) +void view3d_draw_region_info(const bContext *C, ARegion *region) { - RegionView3D *rv3d = ar->regiondata; + RegionView3D *rv3d = region->regiondata; View3D *v3d = CTX_wm_view3d(C); Scene *scene = CTX_data_scene(C); wmWindowManager *wm = CTX_wm_manager(C); @@ -1486,12 +1486,12 @@ void view3d_draw_region_info(const bContext *C, ARegion *ar) #endif /* correct projection matrix */ - ED_region_pixelspace(ar); + ED_region_pixelspace(region); /* local coordinate visible rect inside region, to accommodate overlapping ui */ - const rcti *rect = ED_region_visible_rect(ar); + const rcti *rect = ED_region_visible_rect(region); - view3d_draw_border(C, ar); + view3d_draw_border(C, region); view3d_draw_grease_pencil(C); BLF_batch_draw_begin(); @@ -1519,7 +1519,7 @@ void view3d_draw_region_info(const bContext *C, ARegion *ar) ED_scene_draw_fps(scene, xoffset, &yoffset); } else if (U.uiflag & USER_SHOW_VIEWPORTNAME) { - draw_viewport_name(ar, v3d, xoffset, &yoffset); + draw_viewport_name(region, v3d, xoffset, &yoffset); } if (U.uiflag & USER_DRAWVIEWINFO) { @@ -1547,12 +1547,12 @@ void view3d_draw_region_info(const bContext *C, ARegion *ar) /** \name Draw Viewport Contents * \{ */ -static void view3d_draw_view(const bContext *C, ARegion *ar) +static void view3d_draw_view(const bContext *C, ARegion *region) { ED_view3d_draw_setup_view(CTX_wm_window(C), CTX_data_expect_evaluated_depsgraph(C), CTX_data_scene(C), - ar, + region, CTX_wm_view3d(C), NULL, NULL, @@ -1578,12 +1578,12 @@ RenderEngineType *ED_view3d_engine_type(Scene *scene, int drawtype) } } -void view3d_main_region_draw(const bContext *C, ARegion *ar) +void view3d_main_region_draw(const bContext *C, ARegion *region) { Main *bmain = CTX_data_main(C); View3D *v3d = CTX_wm_view3d(C); - view3d_draw_view(C, ar); + view3d_draw_view(C, region); DRW_cache_free_old_batches(bmain); GPU_free_images_old(bmain); @@ -1608,7 +1608,7 @@ void view3d_main_region_draw(const bContext *C, ARegion *ar) static void view3d_stereo3d_setup_offscreen(Depsgraph *depsgraph, Scene *scene, View3D *v3d, - ARegion *ar, + ARegion *region, float winmat[4][4], const char *viewname) { @@ -1618,14 +1618,14 @@ static void view3d_stereo3d_setup_offscreen(Depsgraph *depsgraph, const bool is_left = STREQ(viewname, STEREO_LEFT_NAME); BKE_camera_multiview_view_matrix(&scene->r, v3d->camera, is_left, viewmat); - view3d_main_region_setup_offscreen(depsgraph, scene, v3d, ar, viewmat, winmat); + view3d_main_region_setup_offscreen(depsgraph, scene, v3d, region, viewmat, winmat); } else { /* SCE_VIEWS_FORMAT_MULTIVIEW */ float viewmat[4][4]; Object *camera = BKE_camera_multiview_render(scene, v3d->camera, viewname); BKE_camera_multiview_view_matrix(&scene->r, camera, false, viewmat); - view3d_main_region_setup_offscreen(depsgraph, scene, v3d, ar, viewmat, winmat); + view3d_main_region_setup_offscreen(depsgraph, scene, v3d, region, viewmat, winmat); } } @@ -1633,7 +1633,7 @@ void ED_view3d_draw_offscreen(Depsgraph *depsgraph, Scene *scene, eDrawType drawtype, View3D *v3d, - ARegion *ar, + ARegion *region, int winx, int winy, float viewmat[4][4], @@ -1645,20 +1645,20 @@ void ED_view3d_draw_offscreen(Depsgraph *depsgraph, GPUOffScreen *ofs, GPUViewport *viewport) { - RegionView3D *rv3d = ar->regiondata; + RegionView3D *rv3d = region->regiondata; RenderEngineType *engine_type = ED_view3d_engine_type(scene, drawtype); /* set temporary new size */ - int bwinx = ar->winx; - int bwiny = ar->winy; - rcti brect = ar->winrct; + int bwinx = region->winx; + int bwiny = region->winy; + rcti brect = region->winrct; - ar->winx = winx; - ar->winy = winy; - ar->winrct.xmin = 0; - ar->winrct.ymin = 0; - ar->winrct.xmax = winx; - ar->winrct.ymax = winy; + region->winx = winx; + region->winy = winy; + region->winrct.xmin = 0; + region->winrct.ymin = 0; + region->winrct.xmax = winx; + region->winrct.ymax = winy; struct bThemeState theme_state; UI_Theme_Store(&theme_state); @@ -1680,20 +1680,20 @@ void ED_view3d_draw_offscreen(Depsgraph *depsgraph, if ((viewname != NULL && viewname[0] != '\0') && (viewmat == NULL) && rv3d->persp == RV3D_CAMOB && v3d->camera) { - view3d_stereo3d_setup_offscreen(depsgraph, scene, v3d, ar, winmat, viewname); + view3d_stereo3d_setup_offscreen(depsgraph, scene, v3d, region, winmat, viewname); } else { - view3d_main_region_setup_offscreen(depsgraph, scene, v3d, ar, viewmat, winmat); + view3d_main_region_setup_offscreen(depsgraph, scene, v3d, region, viewmat, winmat); } /* main drawing call */ DRW_draw_render_loop_offscreen( - depsgraph, engine_type, ar, v3d, do_sky, do_color_management, ofs, viewport); + depsgraph, engine_type, region, v3d, do_sky, do_color_management, ofs, viewport); /* restore size */ - ar->winx = bwinx; - ar->winy = bwiny; - ar->winrct = brect; + region->winx = bwinx; + region->winy = bwiny; + region->winrct = brect; GPU_matrix_pop_projection(); GPU_matrix_pop(); @@ -1713,7 +1713,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(Depsgraph *depsgraph, Scene *scene, eDrawType drawtype, View3D *v3d, - ARegion *ar, + ARegion *region, int sizex, int sizey, eImBufFlags imbuf_flag, @@ -1723,7 +1723,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(Depsgraph *depsgraph, GPUOffScreen *ofs, char err_out[256]) { - RegionView3D *rv3d = ar->regiondata; + RegionView3D *rv3d = region->regiondata; const bool draw_sky = (alpha_mode == R_ADDSKY); /* view state */ @@ -1807,7 +1807,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(Depsgraph *depsgraph, scene, drawtype, v3d, - ar, + region, sizex, sizey, NULL, @@ -1869,13 +1869,13 @@ ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Depsgraph *depsgraph, char err_out[256]) { View3D v3d = {NULL}; - ARegion ar = {NULL}; + ARegion region = {NULL}; RegionView3D rv3d = {{{0}}}; /* connect data */ - v3d.regionbase.first = v3d.regionbase.last = &ar; - ar.regiondata = &rv3d; - ar.regiontype = RGN_TYPE_WINDOW; + v3d.regionbase.first = v3d.regionbase.last = ®ion; + region.regiondata = &rv3d; + region.regiontype = RGN_TYPE_WINDOW; v3d.camera = camera; View3DShading *source_shading_settings = &scene->display.shading; @@ -1932,7 +1932,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Depsgraph *depsgraph, scene, drawtype, &v3d, - &ar, + ®ion, width, height, imbuf_flag, @@ -1996,13 +1996,16 @@ void ED_view3d_clipping_enable(void) /** * \note Only use in object mode. */ -static void validate_object_select_id( - struct Depsgraph *depsgraph, ViewLayer *view_layer, ARegion *ar, View3D *v3d, Object *obact) +static void validate_object_select_id(struct Depsgraph *depsgraph, + ViewLayer *view_layer, + ARegion *region, + View3D *v3d, + Object *obact) { Object *obact_eval = DEG_get_evaluated_object(depsgraph, obact); - BLI_assert(ar->regiontype == RGN_TYPE_WINDOW); - UNUSED_VARS_NDEBUG(ar); + BLI_assert(region->regiontype == RGN_TYPE_WINDOW); + UNUSED_VARS_NDEBUG(region); if (obact_eval && (obact_eval->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT) || BKE_paint_select_face_test(obact_eval))) { @@ -2062,19 +2065,19 @@ void ED_view3d_select_id_validate(ViewContext *vc) /* TODO: Create a flag in `DRW_manager` because the drawing is no longer * made on the backbuffer in this case. */ if (vc->v3d->flag & V3D_INVALID_BACKBUF) { - validate_object_select_id(vc->depsgraph, vc->view_layer, vc->ar, vc->v3d, vc->obact); + validate_object_select_id(vc->depsgraph, vc->view_layer, vc->region, vc->v3d, vc->obact); } } void ED_view3d_backbuf_depth_validate(ViewContext *vc) { if (vc->v3d->flag & V3D_INVALID_BACKBUF) { - ARegion *ar = vc->ar; + ARegion *region = vc->region; Object *obact_eval = DEG_get_evaluated_object(vc->depsgraph, vc->obact); if (obact_eval && ((obact_eval->base_flag & BASE_VISIBLE_DEPSGRAPH) != 0)) { - GPUViewport *viewport = WM_draw_region_get_viewport(ar, 0); - DRW_draw_depth_object(vc->ar, vc->v3d, viewport, obact_eval); + GPUViewport *viewport = WM_draw_region_get_viewport(region, 0); + DRW_draw_depth_object(vc->region, vc->v3d, viewport, obact_eval); } vc->v3d->flag &= ~V3D_INVALID_BACKBUF; @@ -2085,21 +2088,21 @@ void ED_view3d_backbuf_depth_validate(ViewContext *vc) * allow for small values [0.5 - 2.5], * and large values, FLT_MAX by clamping by the area size */ -int ED_view3d_backbuf_sample_size_clamp(ARegion *ar, const float dist) +int ED_view3d_backbuf_sample_size_clamp(ARegion *region, const float dist) { - return (int)min_ff(ceilf(dist), (float)max_ii(ar->winx, ar->winx)); + return (int)min_ff(ceilf(dist), (float)max_ii(region->winx, region->winx)); } /* *********************** */ -void view3d_update_depths_rect(ARegion *ar, ViewDepths *d, rcti *rect) +void view3d_update_depths_rect(ARegion *region, ViewDepths *d, rcti *rect) { /* clamp rect by region */ rcti r = { .xmin = 0, - .xmax = ar->winx - 1, + .xmax = region->winx - 1, .ymin = 0, - .ymax = ar->winy - 1, + .ymax = region->winy - 1, }; /* Constrain rect to depth bounds */ @@ -2136,7 +2139,7 @@ void view3d_update_depths_rect(ARegion *ar, ViewDepths *d, rcti *rect) } if (d->damaged) { - GPUViewport *viewport = WM_draw_region_get_viewport(ar, 0); + GPUViewport *viewport = WM_draw_region_get_viewport(region, 0); view3d_opengl_read_Z_pixels(viewport, rect, d->depths); glGetDoublev(GL_DEPTH_RANGE, d->depth_range); d->damaged = false; @@ -2144,9 +2147,9 @@ void view3d_update_depths_rect(ARegion *ar, ViewDepths *d, rcti *rect) } /* Note, with nouveau drivers the glReadPixels() is very slow. [#24339]. */ -void ED_view3d_depth_update(ARegion *ar) +void ED_view3d_depth_update(ARegion *region) { - RegionView3D *rv3d = ar->regiondata; + RegionView3D *rv3d = region->regiondata; /* Create storage for, and, if necessary, copy depth buffer. */ if (!rv3d->depths) { @@ -2154,9 +2157,9 @@ void ED_view3d_depth_update(ARegion *ar) } if (rv3d->depths) { ViewDepths *d = rv3d->depths; - if (d->w != ar->winx || d->h != ar->winy || !d->depths) { - d->w = ar->winx; - d->h = ar->winy; + if (d->w != region->winx || d->h != region->winy || !d->depths) { + d->w = region->winx; + d->h = region->winy; if (d->depths) { MEM_freeN(d->depths); } @@ -2165,7 +2168,7 @@ void ED_view3d_depth_update(ARegion *ar) } if (d->damaged) { - GPUViewport *viewport = WM_draw_region_get_viewport(ar, 0); + GPUViewport *viewport = WM_draw_region_get_viewport(region, 0); rcti r = { .xmin = 0, .xmax = d->w, @@ -2203,17 +2206,17 @@ float view3d_depth_near(ViewDepths *d) return far == far_real ? FLT_MAX : far; } -void ED_view3d_draw_depth_gpencil(Depsgraph *depsgraph, Scene *scene, ARegion *ar, View3D *v3d) +void ED_view3d_draw_depth_gpencil(Depsgraph *depsgraph, Scene *scene, ARegion *region, View3D *v3d) { /* Setup view matrix. */ - ED_view3d_draw_setup_view(NULL, depsgraph, scene, ar, v3d, NULL, NULL, NULL); + ED_view3d_draw_setup_view(NULL, depsgraph, scene, region, v3d, NULL, NULL, NULL); GPU_clear(GPU_DEPTH_BIT); GPU_depth_test(true); - GPUViewport *viewport = WM_draw_region_get_viewport(ar, 0); - DRW_draw_depth_loop_gpencil(depsgraph, ar, v3d, viewport); + GPUViewport *viewport = WM_draw_region_get_viewport(region, 0); + DRW_draw_depth_loop_gpencil(depsgraph, region, v3d, viewport); GPU_depth_test(false); } @@ -2368,9 +2371,9 @@ static bool view3d_main_region_do_render_draw(const Scene *scene) } bool ED_view3d_calc_render_border( - const Scene *scene, Depsgraph *depsgraph, View3D *v3d, ARegion *ar, rcti *rect) + const Scene *scene, Depsgraph *depsgraph, View3D *v3d, ARegion *region, rcti *rect) { - RegionView3D *rv3d = ar->regiondata; + RegionView3D *rv3d = region->regiondata; bool use_border; /* Test if there is a 3d view rendering. */ @@ -2393,7 +2396,7 @@ bool ED_view3d_calc_render_border( /* Compute border. */ if (rv3d->persp == RV3D_CAMOB) { rctf viewborder; - ED_view3d_calc_camera_border(scene, depsgraph, ar, v3d, rv3d, &viewborder, false); + ED_view3d_calc_camera_border(scene, depsgraph, region, v3d, rv3d, &viewborder, false); rect->xmin = viewborder.xmin + scene->r.border.xmin * BLI_rctf_size_x(&viewborder); rect->ymin = viewborder.ymin + scene->r.border.ymin * BLI_rctf_size_y(&viewborder); @@ -2401,14 +2404,14 @@ bool ED_view3d_calc_render_border( rect->ymax = viewborder.ymin + scene->r.border.ymax * BLI_rctf_size_y(&viewborder); } else { - rect->xmin = v3d->render_border.xmin * ar->winx; - rect->xmax = v3d->render_border.xmax * ar->winx; - rect->ymin = v3d->render_border.ymin * ar->winy; - rect->ymax = v3d->render_border.ymax * ar->winy; + rect->xmin = v3d->render_border.xmin * region->winx; + rect->xmax = v3d->render_border.xmax * region->winx; + rect->ymin = v3d->render_border.ymin * region->winy; + rect->ymax = v3d->render_border.ymax * region->winy; } - BLI_rcti_translate(rect, ar->winrct.xmin, ar->winrct.ymin); - BLI_rcti_isect(&ar->winrct, rect, rect); + BLI_rcti_translate(rect, region->winrct.xmin, region->winrct.ymin); + BLI_rcti_isect(®ion->winrct, rect, rect); return true; } diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 6d4995285c2..00b696da756 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -130,7 +130,7 @@ typedef struct ViewOpsData { Main *bmain; Scene *scene; ScrArea *sa; - ARegion *ar; + ARegion *region; View3D *v3d; RegionView3D *rv3d; Depsgraph *depsgraph; @@ -232,9 +232,9 @@ static void viewops_data_alloc(bContext *C, wmOperator *op) vod->depsgraph = CTX_data_ensure_evaluated_depsgraph(C); vod->scene = CTX_data_scene(C); vod->sa = CTX_wm_area(C); - vod->ar = CTX_wm_region(C); + vod->region = CTX_wm_region(C); vod->v3d = vod->sa->spacedata.first; - vod->rv3d = vod->ar->regiondata; + vod->rv3d = vod->region->regiondata; } void view3d_orbit_apply_dyn_ofs(float r_ofs[3], @@ -401,17 +401,17 @@ static void viewops_data_create(bContext *C, negate_v3_v3(fallback_depth_pt, rv3d->ofs); vod->use_dyn_ofs = ED_view3d_autodist( - depsgraph, vod->ar, vod->v3d, event->mval, vod->dyn_ofs, true, fallback_depth_pt); + depsgraph, vod->region, vod->v3d, event->mval, vod->dyn_ofs, true, fallback_depth_pt); } else { vod->use_dyn_ofs = false; } if (viewops_flag & VIEWOPS_FLAG_PERSP_ENSURE) { - if (ED_view3d_persp_ensure(depsgraph, vod->v3d, vod->ar)) { + 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->ar); + ED_region_tag_redraw(vod->region); } } @@ -432,8 +432,8 @@ static void viewops_data_create(bContext *C, } else { /* Simulate the event starting in the middle of the region. */ - vod->init.event_xy_offset[0] = BLI_rcti_cent_x(&vod->ar->winrct) - event->x; - vod->init.event_xy_offset[1] = BLI_rcti_cent_y(&vod->ar->winrct) - event->y; + vod->init.event_xy_offset[0] = BLI_rcti_cent_x(&vod->region->winrct) - event->x; + vod->init.event_xy_offset[1] = BLI_rcti_cent_y(&vod->region->winrct) - event->y; } vod->init.event_type = event->type; @@ -483,9 +483,10 @@ static void viewops_data_create(bContext *C, negate_v3_v3(rv3d->ofs, dvec); } else { - const float mval_ar_mid[2] = {(float)vod->ar->winx / 2.0f, (float)vod->ar->winy / 2.0f}; + const float mval_ar_mid[2] = {(float)vod->region->winx / 2.0f, + (float)vod->region->winy / 2.0f}; - ED_view3d_win_to_3d(vod->v3d, vod->ar, vod->dyn_ofs, mval_ar_mid, rv3d->ofs); + ED_view3d_win_to_3d(vod->v3d, vod->region, vod->dyn_ofs, mval_ar_mid, rv3d->ofs); negate_v3(rv3d->ofs); } negate_v3(vod->dyn_ofs); @@ -494,7 +495,7 @@ static void viewops_data_create(bContext *C, } /* For dolly */ - ED_view3d_win_to_vector(vod->ar, (const float[2]){UNPACK2(event->mval)}, vod->init.mousevec); + ED_view3d_win_to_vector(vod->region, (const float[2]){UNPACK2(event->mval)}, vod->init.mousevec); { const int event_xy_offset[2] = { @@ -502,7 +503,7 @@ static void viewops_data_create(bContext *C, event->y + vod->init.event_xy_offset[1], }; /* For rotation with trackball rotation. */ - calctrackballvec(&vod->ar->winrct, event_xy_offset, vod->init.trackvec); + calctrackballvec(&vod->region->winrct, event_xy_offset, vod->init.trackvec); } { @@ -521,10 +522,10 @@ static void viewops_data_create(bContext *C, static void viewops_data_free(bContext *C, wmOperator *op) { - ARegion *ar; + ARegion *region; if (op->customdata) { ViewOpsData *vod = op->customdata; - ar = vod->ar; + region = vod->region; vod->rv3d->rflag &= ~RV3D_NAVIGATING; if (vod->timer) { @@ -535,12 +536,12 @@ static void viewops_data_free(bContext *C, wmOperator *op) op->customdata = NULL; } else { - ar = CTX_wm_region(C); + region = CTX_wm_region(C); } /* Need to redraw because drawing code uses RV3D_NAVIGATING to draw * faster while navigation operator runs. */ - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); } /** \} */ @@ -741,7 +742,7 @@ static void viewrotate_apply(ViewOpsData *vod, const int event_xy[2]) event_xy[0] + vod->init.event_xy_offset[0], event_xy[1] + vod->init.event_xy_offset[1], }; - calctrackballvec(&vod->ar->winrct, event_xy_offset, newvec); + calctrackballvec(&vod->region->winrct, event_xy_offset, newvec); } sub_v3_v3v3(dvec, newvec, vod->init.trackvec); @@ -858,7 +859,7 @@ static void viewrotate_apply(ViewOpsData *vod, const int event_xy[2]) ED_view3d_camera_lock_sync(vod->depsgraph, vod->v3d, rv3d); - ED_region_tag_redraw(vod->ar); + ED_region_tag_redraw(vod->region); } static int viewrotate_modal(bContext *C, wmOperator *op, const wmEvent *event) @@ -939,7 +940,7 @@ static int viewrotate_invoke(bContext *C, wmOperator *op, const wmEvent *event) return OPERATOR_PASS_THROUGH; } - ED_view3d_smooth_view_force_finish(C, vod->v3d, vod->ar); + ED_view3d_smooth_view_force_finish(C, vod->v3d, vod->region); viewops_data_create(C, op, @@ -986,10 +987,10 @@ static int viewrotate_invoke(bContext *C, wmOperator *op, const wmEvent *event) static bool view3d_camera_user_poll(bContext *C) { View3D *v3d; - ARegion *ar; + ARegion *region; - if (ED_view3d_context_user_region(C, &v3d, &ar)) { - RegionView3D *rv3d = ar->regiondata; + if (ED_view3d_context_user_region(C, &v3d, ®ion)) { + RegionView3D *rv3d = region->regiondata; if (rv3d->persp == RV3D_CAMOB) { return 1; } @@ -1102,11 +1103,11 @@ static float view3d_ndof_pan_speed_calc(RegionView3D *rv3d) */ static void view3d_ndof_pan_zoom(const struct wmNDOFMotionData *ndof, ScrArea *sa, - ARegion *ar, + ARegion *region, const bool has_translate, const bool has_zoom) { - RegionView3D *rv3d = ar->regiondata; + RegionView3D *rv3d = region->regiondata; float view_inv[4]; float pan_vec[3]; @@ -1159,25 +1160,25 @@ static void view3d_ndof_pan_zoom(const struct wmNDOFMotionData *ndof, sub_v3_v3(rv3d->ofs, pan_vec); if (rv3d->viewlock & RV3D_BOXVIEW) { - view3d_boxview_sync(sa, ar); + view3d_boxview_sync(sa, region); } } } static void view3d_ndof_orbit(const struct wmNDOFMotionData *ndof, ScrArea *sa, - ARegion *ar, + ARegion *region, ViewOpsData *vod, const bool apply_dyn_ofs) { View3D *v3d = sa->spacedata.first; - RegionView3D *rv3d = ar->regiondata; + RegionView3D *rv3d = region->regiondata; float view_inv[4]; BLI_assert((rv3d->viewlock & RV3D_LOCKED) == 0); - ED_view3d_persp_ensure(vod->depsgraph, v3d, ar); + ED_view3d_persp_ensure(vod->depsgraph, v3d, region); rv3d->view = RV3D_VIEW_USER; @@ -1385,7 +1386,7 @@ static int ndof_orbit_invoke(bContext *C, wmOperator *op, const wmEvent *event) C, op, event, viewops_flag_from_args((U.uiflag & USER_ORBIT_SELECTION) != 0, false)); vod = op->customdata; - ED_view3d_smooth_view_force_finish(C, vod->v3d, vod->ar); + ED_view3d_smooth_view_force_finish(C, vod->v3d, vod->region); v3d = vod->v3d; rv3d = vod->rv3d; @@ -1403,12 +1404,12 @@ static int ndof_orbit_invoke(bContext *C, wmOperator *op, const wmEvent *event) const bool has_zoom = (ndof->tvec[2] != 0.0f) && !rv3d->is_persp; if (has_translate || has_zoom) { - view3d_ndof_pan_zoom(ndof, vod->sa, vod->ar, has_translate, has_zoom); + view3d_ndof_pan_zoom(ndof, vod->sa, vod->region, has_translate, has_zoom); xform_flag |= HAS_TRANSLATE; } if (has_rotation) { - view3d_ndof_orbit(ndof, vod->sa, vod->ar, vod, true); + view3d_ndof_orbit(ndof, vod->sa, vod->region, vod, true); xform_flag |= HAS_ROTATE; } } @@ -1419,7 +1420,7 @@ static int ndof_orbit_invoke(bContext *C, wmOperator *op, const wmEvent *event) v3d, rv3d, C, xform_flag & HAS_ROTATE, xform_flag & HAS_TRANSLATE); } - ED_region_tag_redraw(vod->ar); + ED_region_tag_redraw(vod->region); viewops_data_free(C, op); @@ -1467,7 +1468,7 @@ static int ndof_orbit_zoom_invoke(bContext *C, wmOperator *op, const wmEvent *ev vod = op->customdata; - ED_view3d_smooth_view_force_finish(C, vod->v3d, vod->ar); + ED_view3d_smooth_view_force_finish(C, vod->v3d, vod->region); v3d = vod->v3d; rv3d = vod->rv3d; @@ -1486,7 +1487,7 @@ static int ndof_orbit_zoom_invoke(bContext *C, wmOperator *op, const wmEvent *ev const bool has_zoom = (ndof->tvec[2] != 0.0f) && ED_view3d_offset_lock_check(v3d, rv3d); if (has_translate || has_zoom) { - view3d_ndof_pan_zoom(ndof, vod->sa, vod->ar, has_translate, true); + view3d_ndof_pan_zoom(ndof, vod->sa, vod->region, has_translate, true); xform_flag |= HAS_TRANSLATE; } } @@ -1516,7 +1517,7 @@ static int ndof_orbit_zoom_invoke(bContext *C, wmOperator *op, const wmEvent *ev if (!is_orbit_around_pivot) { ED_view3d_distance_set(rv3d, 0.0f); } - view3d_ndof_orbit(ndof, vod->sa, vod->ar, vod, is_orbit_around_pivot); + view3d_ndof_orbit(ndof, vod->sa, vod->region, vod, is_orbit_around_pivot); xform_flag |= HAS_ROTATE; if (!is_orbit_around_pivot) { ED_view3d_distance_set(rv3d, dist_backup); @@ -1524,7 +1525,7 @@ static int ndof_orbit_zoom_invoke(bContext *C, wmOperator *op, const wmEvent *ev } if (has_translate || has_zoom) { - view3d_ndof_pan_zoom(ndof, vod->sa, vod->ar, has_translate, has_zoom); + view3d_ndof_pan_zoom(ndof, vod->sa, vod->region, has_translate, has_zoom); xform_flag |= HAS_TRANSLATE; } } @@ -1535,7 +1536,7 @@ static int ndof_orbit_zoom_invoke(bContext *C, wmOperator *op, const wmEvent *ev v3d, rv3d, C, xform_flag & HAS_ROTATE, xform_flag & HAS_TRANSLATE); } - ED_region_tag_redraw(vod->ar); + ED_region_tag_redraw(vod->region); viewops_data_free(C, op); @@ -1589,10 +1590,10 @@ static int ndof_pan_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *e if (ndof->progress != P_FINISHING) { ScrArea *sa = CTX_wm_area(C); - ARegion *ar = CTX_wm_region(C); + ARegion *region = CTX_wm_region(C); if (has_translate || has_zoom) { - view3d_ndof_pan_zoom(ndof, sa, ar, has_translate, has_zoom); + view3d_ndof_pan_zoom(ndof, sa, region, has_translate, has_zoom); xform_flag |= HAS_TRANSLATE; } } @@ -1711,13 +1712,13 @@ void viewmove_modal_keymap(wmKeyConfig *keyconf) static void viewmove_apply(ViewOpsData *vod, int x, int y) { if (ED_view3d_offset_lock_check(vod->v3d, vod->rv3d)) { - vod->rv3d->ofs_lock[0] -= ((vod->prev.event_xy[0] - x) * 2.0f) / (float)vod->ar->winx; - vod->rv3d->ofs_lock[1] -= ((vod->prev.event_xy[1] - y) * 2.0f) / (float)vod->ar->winy; + vod->rv3d->ofs_lock[0] -= ((vod->prev.event_xy[0] - x) * 2.0f) / (float)vod->region->winx; + vod->rv3d->ofs_lock[1] -= ((vod->prev.event_xy[1] - y) * 2.0f) / (float)vod->region->winy; } else if ((vod->rv3d->persp == RV3D_CAMOB) && !ED_view3d_camera_lock_check(vod->v3d, vod->rv3d)) { const float zoomfac = BKE_screen_view3d_zoom_to_fac(vod->rv3d->camzoom) * 2.0f; - vod->rv3d->camdx += (vod->prev.event_xy[0] - x) / (vod->ar->winx * zoomfac); - vod->rv3d->camdy += (vod->prev.event_xy[1] - y) / (vod->ar->winy * zoomfac); + vod->rv3d->camdx += (vod->prev.event_xy[0] - x) / (vod->region->winx * zoomfac); + vod->rv3d->camdy += (vod->prev.event_xy[1] - y) / (vod->region->winy * zoomfac); CLAMP(vod->rv3d->camdx, -1.0f, 1.0f); CLAMP(vod->rv3d->camdy, -1.0f, 1.0f); } @@ -1727,12 +1728,12 @@ static void viewmove_apply(ViewOpsData *vod, int x, int y) mval_f[0] = x - vod->prev.event_xy[0]; mval_f[1] = y - vod->prev.event_xy[1]; - ED_view3d_win_to_delta(vod->ar, mval_f, dvec, vod->init.zfac); + ED_view3d_win_to_delta(vod->region, mval_f, dvec, vod->init.zfac); add_v3_v3(vod->rv3d->ofs, dvec); if (vod->rv3d->viewlock & RV3D_BOXVIEW) { - view3d_boxview_sync(vod->sa, vod->ar); + view3d_boxview_sync(vod->sa, vod->region); } } @@ -1741,7 +1742,7 @@ static void viewmove_apply(ViewOpsData *vod, int x, int y) ED_view3d_camera_lock_sync(vod->depsgraph, vod->v3d, vod->rv3d); - ED_region_tag_redraw(vod->ar); + ED_region_tag_redraw(vod->region); } static int viewmove_modal(bContext *C, wmOperator *op, const wmEvent *event) @@ -1813,7 +1814,7 @@ static int viewmove_invoke(bContext *C, wmOperator *op, const wmEvent *event) (use_cursor_init ? VIEWOPS_FLAG_USE_MOUSE_INIT : 0)); vod = op->customdata; - ED_view3d_smooth_view_force_finish(C, vod->v3d, vod->ar); + ED_view3d_smooth_view_force_finish(C, vod->v3d, vod->region); if (event->type == MOUSEPAN) { /* invert it, trackpad scroll follows same principle as 2d windows this way */ @@ -1901,10 +1902,14 @@ void viewzoom_modal_keymap(wmKeyConfig *keyconf) * \param zoom_xy: Optionally zoom to window location * (coords compatible w/ #wmEvent.x, y). Use when not NULL. */ -static void view_zoom_to_window_xy_camera( - Scene *scene, Depsgraph *depsgraph, View3D *v3d, ARegion *ar, float dfac, const int zoom_xy[2]) -{ - RegionView3D *rv3d = ar->regiondata; +static void view_zoom_to_window_xy_camera(Scene *scene, + Depsgraph *depsgraph, + View3D *v3d, + ARegion *region, + float dfac, + const int zoom_xy[2]) +{ + RegionView3D *rv3d = region->regiondata; const float zoomfac = BKE_screen_view3d_zoom_to_fac(rv3d->camzoom); const float zoomfac_new = clamp_f( zoomfac * (1.0f / dfac), RV3D_CAMZOOM_MIN_FACTOR, RV3D_CAMZOOM_MAX_FACTOR); @@ -1919,14 +1924,14 @@ static void view_zoom_to_window_xy_camera( float pt_dst[2]; float delta_px[2]; - ED_view3d_calc_camera_border(scene, depsgraph, ar, v3d, rv3d, &camera_frame_old, false); - BLI_rctf_translate(&camera_frame_old, ar->winrct.xmin, ar->winrct.ymin); + ED_view3d_calc_camera_border(scene, depsgraph, region, v3d, rv3d, &camera_frame_old, false); + BLI_rctf_translate(&camera_frame_old, region->winrct.xmin, region->winrct.ymin); rv3d->camzoom = camzoom_new; CLAMP(rv3d->camzoom, RV3D_CAMZOOM_MIN, RV3D_CAMZOOM_MAX); - ED_view3d_calc_camera_border(scene, depsgraph, ar, v3d, rv3d, &camera_frame_new, false); - BLI_rctf_translate(&camera_frame_new, ar->winrct.xmin, ar->winrct.ymin); + ED_view3d_calc_camera_border(scene, depsgraph, region, v3d, rv3d, &camera_frame_new, false); + BLI_rctf_translate(&camera_frame_new, region->winrct.xmin, region->winrct.ymin); BLI_rctf_transform_pt_v(&camera_frame_new, &camera_frame_old, pt_dst, pt_src); sub_v2_v2v2(delta_px, pt_dst, pt_src); @@ -1935,8 +1940,8 @@ static void view_zoom_to_window_xy_camera( * mapped back to the camera (same logic as panning in camera view) */ zoomfac_px = BKE_screen_view3d_zoom_to_fac(rv3d->camzoom) * 2.0f; - rv3d->camdx += delta_px[0] / (ar->winx * zoomfac_px); - rv3d->camdy += delta_px[1] / (ar->winy * zoomfac_px); + rv3d->camdx += delta_px[0] / (region->winx * zoomfac_px); + rv3d->camdy += delta_px[1] / (region->winy * zoomfac_px); CLAMP(rv3d->camdx, -1.0f, 1.0f); CLAMP(rv3d->camdy, -1.0f, 1.0f); } @@ -1950,9 +1955,9 @@ static void view_zoom_to_window_xy_camera( * \param zoom_xy: Optionally zoom to window location * (coords compatible w/ #wmEvent.x, y). Use when not NULL. */ -static void view_zoom_to_window_xy_3d(ARegion *ar, float dfac, const int zoom_xy[2]) +static void view_zoom_to_window_xy_3d(ARegion *region, float dfac, const int zoom_xy[2]) { - RegionView3D *rv3d = ar->regiondata; + RegionView3D *rv3d = region->regiondata; const float dist_new = rv3d->dist * dfac; if (zoom_xy != NULL) { @@ -1965,12 +1970,12 @@ static void view_zoom_to_window_xy_3d(ARegion *ar, float dfac, const int zoom_xy negate_v3_v3(tpos, rv3d->ofs); - mval_f[0] = (float)(((zoom_xy[0] - ar->winrct.xmin) * 2) - ar->winx) / 2.0f; - mval_f[1] = (float)(((zoom_xy[1] - ar->winrct.ymin) * 2) - ar->winy) / 2.0f; + mval_f[0] = (float)(((zoom_xy[0] - region->winrct.xmin) * 2) - region->winx) / 2.0f; + mval_f[1] = (float)(((zoom_xy[1] - region->winrct.ymin) * 2) - region->winy) / 2.0f; /* Project cursor position into 3D space */ zfac = ED_view3d_calc_zfac(rv3d, tpos, NULL); - ED_view3d_win_to_delta(ar, mval_f, dvec, zfac); + ED_view3d_win_to_delta(region, mval_f, dvec, zfac); /* Calculate view target position for dolly */ add_v3_v3v3(tvec, tpos, dvec); @@ -2102,7 +2107,7 @@ static void viewzoom_apply_camera(ViewOpsData *vod, float zoomfac_prev = BKE_screen_view3d_zoom_to_fac(vod->init.camzoom) * 2.0f; float zoomfac = BKE_screen_view3d_zoom_to_fac(vod->rv3d->camzoom) * 2.0f; - zfac = viewzoom_scale_value_offset(&vod->ar->winrct, + zfac = viewzoom_scale_value_offset(&vod->region->winrct, viewzoom, zoom_invert, true, @@ -2119,12 +2124,12 @@ static void viewzoom_apply_camera(ViewOpsData *vod, view_zoom_to_window_xy_camera(vod->scene, vod->depsgraph, vod->v3d, - vod->ar, + vod->region, zfac, zoom_to_pos ? vod->prev.event_xy : NULL); } - ED_region_tag_redraw(vod->ar); + ED_region_tag_redraw(vod->region); } static void viewzoom_apply_3d(ViewOpsData *vod, @@ -2138,7 +2143,7 @@ static void viewzoom_apply_3d(ViewOpsData *vod, ED_view3d_dist_range_get(vod->v3d, dist_range); - zfac = viewzoom_scale_value_offset(&vod->ar->winrct, + zfac = viewzoom_scale_value_offset(&vod->region->winrct, viewzoom, zoom_invert, false, @@ -2154,19 +2159,19 @@ static void viewzoom_apply_3d(ViewOpsData *vod, const float zfac_max = dist_range[1] / vod->rv3d->dist; CLAMP(zfac, zfac_min, zfac_max); - view_zoom_to_window_xy_3d(vod->ar, zfac, zoom_to_pos ? vod->prev.event_xy : NULL); + view_zoom_to_window_xy_3d(vod->region, zfac, zoom_to_pos ? vod->prev.event_xy : NULL); } /* these limits were in old code too */ CLAMP(vod->rv3d->dist, dist_range[0], dist_range[1]); if (vod->rv3d->viewlock & RV3D_BOXVIEW) { - view3d_boxview_sync(vod->sa, vod->ar); + view3d_boxview_sync(vod->sa, vod->region); } ED_view3d_camera_lock_sync(vod->depsgraph, vod->v3d, vod->rv3d); - ED_region_tag_redraw(vod->ar); + ED_region_tag_redraw(vod->region); } static void viewzoom_apply(ViewOpsData *vod, @@ -2253,7 +2258,7 @@ static int viewzoom_exec(bContext *C, wmOperator *op) View3D *v3d; RegionView3D *rv3d; ScrArea *sa; - ARegion *ar; + ARegion *region; bool use_cam_zoom; float dist_range[2]; @@ -2264,15 +2269,15 @@ static int viewzoom_exec(bContext *C, wmOperator *op) ViewOpsData *vod = op->customdata; sa = vod->sa; - ar = vod->ar; + region = vod->region; } else { sa = CTX_wm_area(C); - ar = CTX_wm_region(C); + region = CTX_wm_region(C); } v3d = sa->spacedata.first; - rv3d = ar->regiondata; + rv3d = region->regiondata; use_cam_zoom = (rv3d->persp == RV3D_CAMOB) && !(rv3d->is_persp && ED_view3d_camera_lock_check(v3d, rv3d)); @@ -2281,9 +2286,9 @@ static int viewzoom_exec(bContext *C, wmOperator *op) const int *zoom_xy = NULL; if (use_cursor_init && (U.uiflag & USER_ZOOM_TO_MOUSEPOS)) { zoom_xy_buf[0] = RNA_struct_property_is_set(op->ptr, "mx") ? RNA_int_get(op->ptr, "mx") : - ar->winx / 2; + region->winx / 2; zoom_xy_buf[1] = RNA_struct_property_is_set(op->ptr, "my") ? RNA_int_get(op->ptr, "my") : - ar->winy / 2; + region->winy / 2; zoom_xy = zoom_xy_buf; } @@ -2293,28 +2298,28 @@ static int viewzoom_exec(bContext *C, wmOperator *op) const float step = 1.2f; /* this min and max is also in viewmove() */ if (use_cam_zoom) { - view_zoom_to_window_xy_camera(scene, depsgraph, v3d, ar, step, zoom_xy); + view_zoom_to_window_xy_camera(scene, depsgraph, v3d, region, step, zoom_xy); } else { if (rv3d->dist < dist_range[1]) { - view_zoom_to_window_xy_3d(ar, step, zoom_xy); + view_zoom_to_window_xy_3d(region, step, zoom_xy); } } } else { const float step = 1.0f / 1.2f; if (use_cam_zoom) { - view_zoom_to_window_xy_camera(scene, depsgraph, v3d, ar, step, zoom_xy); + view_zoom_to_window_xy_camera(scene, depsgraph, v3d, region, step, zoom_xy); } else { if (rv3d->dist > dist_range[0]) { - view_zoom_to_window_xy_3d(ar, step, zoom_xy); + view_zoom_to_window_xy_3d(region, step, zoom_xy); } } } if (rv3d->viewlock & RV3D_BOXVIEW) { - view3d_boxview_sync(sa, ar); + view3d_boxview_sync(sa, region); } ED_view3d_depth_tag_update(rv3d); @@ -2322,7 +2327,7 @@ static int viewzoom_exec(bContext *C, wmOperator *op) ED_view3d_camera_lock_sync(depsgraph, v3d, rv3d); ED_view3d_camera_lock_autokey(v3d, rv3d, C, false, true); - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); viewops_data_free(C, op); @@ -2345,7 +2350,7 @@ static int viewzoom_invoke(bContext *C, wmOperator *op, const wmEvent *event) (use_cursor_init ? VIEWOPS_FLAG_USE_MOUSE_INIT : 0)); vod = op->customdata; - ED_view3d_smooth_view_force_finish(C, vod->v3d, vod->ar); + ED_view3d_smooth_view_force_finish(C, vod->v3d, vod->region); /* if one or the other zoom position aren't set, set from event */ if (!RNA_struct_property_is_set(op->ptr, "mx") || !RNA_struct_property_is_set(op->ptr, "my")) { @@ -2477,9 +2482,9 @@ static bool viewdolly_offset_lock_check(bContext *C, wmOperator *op) } } -static void view_dolly_to_vector_3d(ARegion *ar, float orig_ofs[3], float dvec[3], float dfac) +static void view_dolly_to_vector_3d(ARegion *region, float orig_ofs[3], float dvec[3], float dfac) { - RegionView3D *rv3d = ar->regiondata; + RegionView3D *rv3d = region->regiondata; madd_v3_v3v3fl(rv3d->ofs, orig_ofs, dvec, -(1.0f - dfac)); } @@ -2491,12 +2496,12 @@ static void viewdolly_apply(ViewOpsData *vod, const int xy[2], const short zoom_ float len1, len2; if (U.uiflag & USER_ZOOM_HORIZ) { - len1 = (vod->ar->winrct.xmax - xy[0]) + 5; - len2 = (vod->ar->winrct.xmax - vod->init.event_xy[0]) + 5; + len1 = (vod->region->winrct.xmax - xy[0]) + 5; + len2 = (vod->region->winrct.xmax - vod->init.event_xy[0]) + 5; } else { - len1 = (vod->ar->winrct.ymax - xy[1]) + 5; - len2 = (vod->ar->winrct.ymax - vod->init.event_xy[1]) + 5; + len1 = (vod->region->winrct.ymax - xy[1]) + 5; + len2 = (vod->region->winrct.ymax - vod->init.event_xy[1]) + 5; } if (zoom_invert) { SWAP(float, len1, len2); @@ -2506,16 +2511,16 @@ static void viewdolly_apply(ViewOpsData *vod, const int xy[2], const short zoom_ } if (zfac != 1.0f) { - view_dolly_to_vector_3d(vod->ar, vod->init.ofs, vod->init.mousevec, zfac); + view_dolly_to_vector_3d(vod->region, vod->init.ofs, vod->init.mousevec, zfac); } if (vod->rv3d->viewlock & RV3D_BOXVIEW) { - view3d_boxview_sync(vod->sa, vod->ar); + view3d_boxview_sync(vod->sa, vod->region); } ED_view3d_camera_lock_sync(vod->depsgraph, vod->v3d, vod->rv3d); - ED_region_tag_redraw(vod->ar); + ED_region_tag_redraw(vod->region); } static int viewdolly_modal(bContext *C, wmOperator *op, const wmEvent *event) @@ -2576,7 +2581,7 @@ static int viewdolly_exec(bContext *C, wmOperator *op) View3D *v3d; RegionView3D *rv3d; ScrArea *sa; - ARegion *ar; + ARegion *region; float mousevec[3]; const int delta = RNA_int_get(op->ptr, "delta"); @@ -2585,18 +2590,18 @@ static int viewdolly_exec(bContext *C, wmOperator *op) ViewOpsData *vod = op->customdata; sa = vod->sa; - ar = vod->ar; + region = vod->region; copy_v3_v3(mousevec, vod->init.mousevec); } else { sa = CTX_wm_area(C); - ar = CTX_wm_region(C); - negate_v3_v3(mousevec, ((RegionView3D *)ar->regiondata)->viewinv[2]); + region = CTX_wm_region(C); + negate_v3_v3(mousevec, ((RegionView3D *)region->regiondata)->viewinv[2]); normalize_v3(mousevec); } v3d = sa->spacedata.first; - rv3d = ar->regiondata; + rv3d = region->regiondata; const bool use_cursor_init = RNA_boolean_get(op->ptr, "use_cursor_init"); @@ -2605,17 +2610,17 @@ static int viewdolly_exec(bContext *C, wmOperator *op) normalize_v3_v3(mousevec, rv3d->viewinv[2]); } - view_dolly_to_vector_3d(ar, rv3d->ofs, mousevec, delta < 0 ? 0.2f : 1.8f); + view_dolly_to_vector_3d(region, rv3d->ofs, mousevec, delta < 0 ? 0.2f : 1.8f); if (rv3d->viewlock & RV3D_BOXVIEW) { - view3d_boxview_sync(sa, ar); + view3d_boxview_sync(sa, region); } ED_view3d_depth_tag_update(rv3d); ED_view3d_camera_lock_sync(CTX_data_ensure_evaluated_depsgraph(C), v3d, rv3d); - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); viewops_data_free(C, op); @@ -2641,7 +2646,7 @@ static int viewdolly_invoke(bContext *C, wmOperator *op, const wmEvent *event) return OPERATOR_PASS_THROUGH; } - ED_view3d_smooth_view_force_finish(C, vod->v3d, vod->ar); + ED_view3d_smooth_view_force_finish(C, vod->v3d, vod->region); /* needs to run before 'viewops_data_create' so the backup 'rv3d->ofs' is correct */ /* switch from camera view when: */ @@ -2654,7 +2659,7 @@ static int viewdolly_invoke(bContext *C, wmOperator *op, const wmEvent *event) else { vod->rv3d->persp = RV3D_PERSP; } - ED_region_tag_redraw(vod->ar); + ED_region_tag_redraw(vod->region); } const bool use_cursor_init = RNA_boolean_get(op->ptr, "use_cursor_init"); @@ -2767,17 +2772,17 @@ static bool view3d_object_skip_minmax(const View3D *v3d, static void view3d_from_minmax(bContext *C, View3D *v3d, - ARegion *ar, + ARegion *region, const float min[3], const float max[3], bool ok_dist, const int smooth_viewtx) { - RegionView3D *rv3d = ar->regiondata; + RegionView3D *rv3d = region->regiondata; float afm[3]; float size; - ED_view3d_smooth_view_force_finish(C, v3d, ar); + ED_view3d_smooth_view_force_finish(C, v3d, region); /* SMOOTHVIEW */ float new_ofs[3]; @@ -2811,7 +2816,7 @@ static void view3d_from_minmax(bContext *C, if (ok_dist) { Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); new_dist = ED_view3d_radius_to_dist( - v3d, ar, depsgraph, persp, true, (size / 2) * VIEW3D_MARGIN); + 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); @@ -2826,7 +2831,7 @@ static void view3d_from_minmax(bContext *C, rv3d->persp = RV3D_PERSP; ED_view3d_smooth_view(C, v3d, - ar, + region, smooth_viewtx, &(const V3D_SmoothParams){ .camera_old = v3d->camera, @@ -2837,7 +2842,7 @@ static void view3d_from_minmax(bContext *C, else { ED_view3d_smooth_view(C, v3d, - ar, + region, smooth_viewtx, &(const V3D_SmoothParams){ .ofs = new_ofs, @@ -2859,14 +2864,14 @@ static void view3d_from_minmax_multi(bContext *C, const int smooth_viewtx) { ScrArea *sa = CTX_wm_area(C); - ARegion *ar; - for (ar = sa->regionbase.first; ar; ar = ar->next) { - if (ar->regiontype == RGN_TYPE_WINDOW) { - RegionView3D *rv3d = ar->regiondata; + ARegion *region; + for (region = sa->regionbase.first; region; region = region->next) { + if (region->regiontype == RGN_TYPE_WINDOW) { + RegionView3D *rv3d = region->regiondata; /* 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, ar, min, max, ok_dist, smooth_viewtx); + view3d_from_minmax(C, v3d, region, min, max, ok_dist, smooth_viewtx); } } } @@ -2874,7 +2879,7 @@ static void view3d_from_minmax_multi(bContext *C, static int view3d_all_exec(bContext *C, wmOperator *op) { - ARegion *ar = CTX_wm_region(C); + ARegion *region = CTX_wm_region(C); View3D *v3d = CTX_wm_view3d(C); RegionView3D *rv3d = CTX_wm_region_view3d(C); Scene *scene = CTX_data_scene(C); @@ -2882,7 +2887,7 @@ static int view3d_all_exec(bContext *C, wmOperator *op) ViewLayer *view_layer_eval = DEG_get_evaluated_view_layer(depsgraph); Base *base_eval; const bool use_all_regions = RNA_boolean_get(op->ptr, "use_all_regions"); - const bool skip_camera = (ED_view3d_camera_lock_check(v3d, ar->regiondata) || + const bool skip_camera = (ED_view3d_camera_lock_check(v3d, region->regiondata) || /* any one of the regions may be locked */ (use_all_regions && v3d->flag2 & V3D_LOCK_CAMERA)); const bool center = RNA_boolean_get(op->ptr, "center"); @@ -2928,7 +2933,7 @@ static int view3d_all_exec(bContext *C, wmOperator *op) } if (!changed) { - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); /* TODO - should this be cancel? * I think no, because we always move the cursor, with or without * object, but in this case there is no change in the scene, @@ -2943,7 +2948,7 @@ static int view3d_all_exec(bContext *C, wmOperator *op) view3d_from_minmax_multi(C, v3d, min, max, true, smooth_viewtx); } else { - view3d_from_minmax(C, v3d, ar, min, max, true, smooth_viewtx); + view3d_from_minmax(C, v3d, region, min, max, true, smooth_viewtx); } return OPERATOR_FINISHED; @@ -2979,7 +2984,7 @@ void VIEW3D_OT_view_all(wmOperatorType *ot) /* like a localview without local!, was centerview() in 2.4x */ static int viewselected_exec(bContext *C, wmOperator *op) { - ARegion *ar = CTX_wm_region(C); + ARegion *region = CTX_wm_region(C); View3D *v3d = CTX_wm_view3d(C); RegionView3D *rv3d = CTX_wm_region_view3d(C); Scene *scene = CTX_data_scene(C); @@ -2989,12 +2994,12 @@ static int viewselected_exec(bContext *C, wmOperator *op) Object *obedit = CTX_data_edit_object(C); const bGPdata *gpd_eval = ob_eval && (ob_eval->type == OB_GPENCIL) ? ob_eval->data : NULL; const bool is_gp_edit = gpd_eval ? GPENCIL_ANY_MODE(gpd_eval) : false; - const bool is_face_map = ((is_gp_edit == false) && ar->gizmo_map && - WM_gizmomap_is_any_selected(ar->gizmo_map)); + const bool is_face_map = ((is_gp_edit == false) && region->gizmo_map && + WM_gizmomap_is_any_selected(region->gizmo_map)); float min[3], max[3]; bool ok = false, ok_dist = true; const bool use_all_regions = RNA_boolean_get(op->ptr, "use_all_regions"); - const bool skip_camera = (ED_view3d_camera_lock_check(v3d, ar->regiondata) || + const bool skip_camera = (ED_view3d_camera_lock_check(v3d, region->regiondata) || /* 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); @@ -3038,7 +3043,7 @@ static int viewselected_exec(bContext *C, wmOperator *op) } } else if (is_face_map) { - ok = WM_gizmomap_minmax(ar->gizmo_map, true, true, min, max); + ok = WM_gizmomap_minmax(region->gizmo_map, true, true, min, max); } else if (obedit) { /* only selected */ @@ -3101,7 +3106,7 @@ static int viewselected_exec(bContext *C, wmOperator *op) view3d_from_minmax_multi(C, v3d, min, max, ok_dist, smooth_viewtx); } else { - view3d_from_minmax(C, v3d, ar, min, max, ok_dist, smooth_viewtx); + view3d_from_minmax(C, v3d, region, min, max, ok_dist, smooth_viewtx); } return OPERATOR_FINISHED; @@ -3234,15 +3239,16 @@ static int viewcenter_cursor_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); if (rv3d) { - ARegion *ar = CTX_wm_region(C); + ARegion *region = CTX_wm_region(C); const int smooth_viewtx = WM_operator_smooth_viewtx_get(op); - ED_view3d_smooth_view_force_finish(C, v3d, ar); + ED_view3d_smooth_view_force_finish(C, v3d, region); /* non camera center */ float new_ofs[3]; negate_v3_v3(new_ofs, scene->cursor.location); - ED_view3d_smooth_view(C, v3d, ar, smooth_viewtx, &(const V3D_SmoothParams){.ofs = new_ofs}); + ED_view3d_smooth_view( + C, v3d, region, smooth_viewtx, &(const V3D_SmoothParams){.ofs = new_ofs}); /* smooth view does viewlock RV3D_BOXVIEW copy */ } @@ -3275,27 +3281,28 @@ static int viewcenter_pick_invoke(bContext *C, wmOperator *op, const wmEvent *ev { View3D *v3d = CTX_wm_view3d(C); RegionView3D *rv3d = CTX_wm_region_view3d(C); - ARegion *ar = CTX_wm_region(C); + ARegion *region = CTX_wm_region(C); if (rv3d) { struct Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); float new_ofs[3]; const int smooth_viewtx = WM_operator_smooth_viewtx_get(op); - ED_view3d_smooth_view_force_finish(C, v3d, ar); + ED_view3d_smooth_view_force_finish(C, v3d, region); view3d_operator_needs_opengl(C); - if (ED_view3d_autodist(depsgraph, ar, v3d, event->mval, new_ofs, false, NULL)) { + if (ED_view3d_autodist(depsgraph, region, v3d, event->mval, new_ofs, false, NULL)) { /* pass */ } else { /* fallback to simple pan */ negate_v3_v3(new_ofs, rv3d->ofs); - ED_view3d_win_to_3d_int(v3d, ar, new_ofs, event->mval, new_ofs); + ED_view3d_win_to_3d_int(v3d, region, new_ofs, event->mval, new_ofs); } negate_v3(new_ofs); - ED_view3d_smooth_view(C, v3d, ar, smooth_viewtx, &(const V3D_SmoothParams){.ofs = new_ofs}); + ED_view3d_smooth_view( + C, v3d, region, smooth_viewtx, &(const V3D_SmoothParams){.ofs = new_ofs}); } return OPERATOR_FINISHED; @@ -3330,20 +3337,20 @@ static int view3d_center_camera_exec(bContext *C, wmOperator *UNUSED(op)) float size[2]; View3D *v3d; - ARegion *ar; + ARegion *region; RegionView3D *rv3d; /* no NULL check is needed, poll checks */ - ED_view3d_context_user_region(C, &v3d, &ar); - rv3d = ar->regiondata; + ED_view3d_context_user_region(C, &v3d, ®ion); + rv3d = region->regiondata; rv3d->camdx = rv3d->camdy = 0.0f; - ED_view3d_calc_camera_border_size(scene, depsgraph, ar, v3d, rv3d, size); + ED_view3d_calc_camera_border_size(scene, depsgraph, region, v3d, rv3d, size); /* 4px is just a little room from the edge of the area */ - xfac = (float)ar->winx / (float)(size[0] + 4); - yfac = (float)ar->winy / (float)(size[1] + 4); + xfac = (float)region->winx / (float)(size[0] + 4); + yfac = (float)region->winy / (float)(size[1] + 4); rv3d->camzoom = BKE_screen_view3d_zoom_from_fac(min_ff(xfac, yfac)); CLAMP(rv3d->camzoom, RV3D_CAMZOOM_MIN, RV3D_CAMZOOM_MAX); @@ -3409,7 +3416,7 @@ void VIEW3D_OT_view_center_lock(wmOperatorType *ot) static int render_border_exec(bContext *C, wmOperator *op) { View3D *v3d = CTX_wm_view3d(C); - ARegion *ar = CTX_wm_region(C); + ARegion *region = CTX_wm_region(C); RegionView3D *rv3d = ED_view3d_context_rv3d(C); Scene *scene = CTX_data_scene(C); @@ -3424,13 +3431,13 @@ static int render_border_exec(bContext *C, wmOperator *op) if (rv3d->persp == RV3D_CAMOB) { Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); - ED_view3d_calc_camera_border(scene, depsgraph, ar, v3d, rv3d, &vb, false); + ED_view3d_calc_camera_border(scene, depsgraph, region, v3d, rv3d, &vb, false); } else { vb.xmin = 0; vb.ymin = 0; - vb.xmax = ar->winx; - vb.ymax = ar->winy; + vb.xmax = region->winx; + vb.ymax = region->winy; } border.xmin = ((float)rect.xmin - vb.xmin) / BLI_rctf_size_x(&vb); @@ -3562,7 +3569,7 @@ void VIEW3D_OT_clear_render_border(wmOperatorType *ot) static int view3d_zoom_border_exec(bContext *C, wmOperator *op) { - ARegion *ar = CTX_wm_region(C); + ARegion *region = CTX_wm_region(C); View3D *v3d = CTX_wm_view3d(C); RegionView3D *rv3d = CTX_wm_region_view3d(C); const int smooth_viewtx = WM_operator_smooth_viewtx_get(op); @@ -3592,14 +3599,14 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op) ED_view3d_dist_range_get(v3d, dist_range); /* Get Z Depths, needed for perspective, nice for ortho */ - ED_view3d_draw_depth(CTX_data_ensure_evaluated_depsgraph(C), ar, v3d, true); + ED_view3d_draw_depth(CTX_data_ensure_evaluated_depsgraph(C), region, v3d, true); { /* avoid allocating the whole depth buffer */ ViewDepths depth_temp = {0}; /* avoid view3d_update_depths() for speed. */ - view3d_update_depths_rect(ar, &depth_temp, &rect); + view3d_update_depths_rect(region, &depth_temp, &rect); /* find the closest Z pixel */ depth_close = view3d_depth_near(&depth_temp); @@ -3619,8 +3626,8 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } /* convert border to 3d coordinates */ - if ((!ED_view3d_unproject(ar, cent[0], cent[1], depth_close, p)) || - (!ED_view3d_unproject(ar, rect.xmin, rect.ymin, depth_close, p_corner))) { + if ((!ED_view3d_unproject(region, cent[0], cent[1], depth_close, p)) || + (!ED_view3d_unproject(region, rect.xmin, rect.ymin, depth_close, p_corner))) { return OPERATOR_CANCELLED; } @@ -3634,13 +3641,13 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op) } else { /* orthographic */ /* find the current window width and height */ - vb[0] = ar->winx; - vb[1] = ar->winy; + vb[0] = region->winx; + vb[1] = region->winy; new_dist = rv3d->dist; /* convert the drawn rectangle into 3d space */ - if (depth_close != FLT_MAX && ED_view3d_unproject(ar, cent[0], cent[1], depth_close, p)) { + if (depth_close != FLT_MAX && ED_view3d_unproject(region, cent[0], cent[1], depth_close, p)) { negate_v3_v3(new_ofs, p); } else { @@ -3658,7 +3665,7 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op) mval_f[0] = (rect.xmin + rect.xmax - vb[0]) / 2.0f; mval_f[1] = (rect.ymin + rect.ymax - vb[1]) / 2.0f; - ED_view3d_win_to_delta(ar, mval_f, dvec, zfac); + ED_view3d_win_to_delta(region, mval_f, dvec, zfac); /* center the view to the center of the rectangle */ sub_v3_v3(new_ofs, dvec); } @@ -3687,7 +3694,7 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op) ED_view3d_smooth_view(C, v3d, - ar, + region, smooth_viewtx, &(const V3D_SmoothParams){ .ofs = new_ofs, @@ -3695,7 +3702,7 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op) }); if (rv3d->viewlock & RV3D_BOXVIEW) { - view3d_boxview_sync(CTX_wm_area(C), ar); + view3d_boxview_sync(CTX_wm_area(C), region); } return OPERATOR_FINISHED; @@ -3733,14 +3740,14 @@ void VIEW3D_OT_zoom_border(wmOperatorType *ot) static void view3d_set_1_to_1_viewborder(Scene *scene, Depsgraph *depsgraph, - ARegion *ar, + ARegion *region, View3D *v3d) { - RegionView3D *rv3d = ar->regiondata; + RegionView3D *rv3d = region->regiondata; float size[2]; int im_width = (scene->r.size * scene->r.xsch) / 100; - ED_view3d_calc_camera_border_size(scene, depsgraph, ar, v3d, rv3d, size); + ED_view3d_calc_camera_border_size(scene, depsgraph, region, v3d, rv3d, size); rv3d->camzoom = BKE_screen_view3d_zoom_from_fac((float)im_width / size[0]); CLAMP(rv3d->camzoom, RV3D_CAMZOOM_MIN, RV3D_CAMZOOM_MAX); @@ -3752,12 +3759,12 @@ static int view3d_zoom_1_to_1_camera_exec(bContext *C, wmOperator *UNUSED(op)) Scene *scene = CTX_data_scene(C); View3D *v3d; - ARegion *ar; + ARegion *region; /* no NULL check is needed, poll checks */ - ED_view3d_context_user_region(C, &v3d, &ar); + ED_view3d_context_user_region(C, &v3d, ®ion); - view3d_set_1_to_1_viewborder(scene, depsgraph, ar, v3d); + view3d_set_1_to_1_viewborder(scene, depsgraph, region, v3d); WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d); @@ -3802,7 +3809,7 @@ static const EnumPropertyItem prop_view_items[] = { */ static void axis_set_view(bContext *C, View3D *v3d, - ARegion *ar, + ARegion *region, const float quat_[4], char view, char view_axis_roll, @@ -3810,7 +3817,7 @@ static void axis_set_view(bContext *C, const float *align_to_quat, const int smooth_viewtx) { - RegionView3D *rv3d = ar->regiondata; /* no NULL check is needed, poll checks */ + RegionView3D *rv3d = region->regiondata; /* no NULL check is needed, poll checks */ float quat[4]; const short orig_persp = rv3d->persp; @@ -3828,7 +3835,7 @@ static void axis_set_view(bContext *C, } if (rv3d->viewlock & RV3D_LOCKED) { - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); return; } @@ -3843,7 +3850,7 @@ static void axis_set_view(bContext *C, /* to camera */ ED_view3d_smooth_view(C, v3d, - ar, + region, smooth_viewtx, &(const V3D_SmoothParams){ .camera_old = v3d->camera, @@ -3865,7 +3872,7 @@ static void axis_set_view(bContext *C, ED_view3d_smooth_view(C, v3d, - ar, + region, smooth_viewtx, &(const V3D_SmoothParams){ .ofs = ofs, @@ -3888,7 +3895,7 @@ static void axis_set_view(bContext *C, /* no camera involved */ ED_view3d_smooth_view(C, v3d, - ar, + region, smooth_viewtx, &(const V3D_SmoothParams){ .quat = quat, @@ -3900,7 +3907,7 @@ static void axis_set_view(bContext *C, static int view_axis_exec(bContext *C, wmOperator *op) { View3D *v3d; - ARegion *ar; + ARegion *region; RegionView3D *rv3d; static int perspo = RV3D_PERSP; int viewnum; @@ -3908,10 +3915,10 @@ static int view_axis_exec(bContext *C, wmOperator *op) const int smooth_viewtx = WM_operator_smooth_viewtx_get(op); /* no NULL check is needed, poll checks */ - ED_view3d_context_user_region(C, &v3d, &ar); - rv3d = ar->regiondata; + ED_view3d_context_user_region(C, &v3d, ®ion); + rv3d = region->regiondata; - ED_view3d_smooth_view_force_finish(C, v3d, ar); + ED_view3d_smooth_view_force_finish(C, v3d, region); viewnum = RNA_enum_get(op->ptr, "type"); @@ -3998,7 +4005,8 @@ static int view_axis_exec(bContext *C, wmOperator *op) const int nextperspo = (rv3d->persp == RV3D_CAMOB) ? rv3d->lpersp : perspo; float quat[4]; ED_view3d_quat_from_axis_view(viewnum, view_axis_roll, quat); - axis_set_view(C, v3d, ar, quat, viewnum, view_axis_roll, nextperspo, align_quat, smooth_viewtx); + axis_set_view( + C, v3d, region, quat, viewnum, view_axis_roll, nextperspo, align_quat, smooth_viewtx); perspo = rv3d->persp; @@ -4040,15 +4048,15 @@ void VIEW3D_OT_view_axis(wmOperatorType *ot) static int view_camera_exec(bContext *C, wmOperator *op) { View3D *v3d; - ARegion *ar; + ARegion *region; RegionView3D *rv3d; const int smooth_viewtx = WM_operator_smooth_viewtx_get(op); /* no NULL check is needed, poll checks */ - ED_view3d_context_user_region(C, &v3d, &ar); - rv3d = ar->regiondata; + ED_view3d_context_user_region(C, &v3d, ®ion); + rv3d = region->regiondata; - ED_view3d_smooth_view_force_finish(C, v3d, ar); + ED_view3d_smooth_view_force_finish(C, v3d, region); if ((rv3d->viewlock & RV3D_LOCKED) == 0) { /* lastview - */ @@ -4111,7 +4119,7 @@ static int view_camera_exec(bContext *C, wmOperator *op) rv3d->persp = RV3D_CAMOB; ED_view3d_smooth_view(C, v3d, - ar, + region, smooth_viewtx, &(const V3D_SmoothParams){ .camera = v3d->camera, @@ -4126,7 +4134,7 @@ static int view_camera_exec(bContext *C, wmOperator *op) /* does view3d_smooth_view too */ axis_set_view(C, v3d, - ar, + region, rv3d->lviewquat, rv3d->lview, rv3d->lview_axis_roll, @@ -4180,7 +4188,7 @@ static const EnumPropertyItem prop_view_orbit_items[] = { static int vieworbit_exec(bContext *C, wmOperator *op) { View3D *v3d; - ARegion *ar; + ARegion *region; RegionView3D *rv3d; int orbitdir; char view_opposite; @@ -4191,8 +4199,8 @@ static int vieworbit_exec(bContext *C, wmOperator *op) /* no NULL check is needed, poll checks */ v3d = CTX_wm_view3d(C); - ar = CTX_wm_region(C); - rv3d = ar->regiondata; + region = CTX_wm_region(C); + rv3d = region->regiondata; /* support for switching to the opposite view (even when in locked views) */ view_opposite = (fabsf(angle) == (float)M_PI) ? ED_view3d_axis_view_opposite(rv3d->view) : @@ -4201,11 +4209,11 @@ static int vieworbit_exec(bContext *C, wmOperator *op) if ((rv3d->viewlock & RV3D_LOCKED) && (view_opposite == RV3D_VIEW_USER)) { /* no NULL check is needed, poll checks */ - ED_view3d_context_user_region(C, &v3d, &ar); - rv3d = ar->regiondata; + ED_view3d_context_user_region(C, &v3d, ®ion); + rv3d = region->regiondata; } - ED_view3d_smooth_view_force_finish(C, v3d, ar); + ED_view3d_smooth_view_force_finish(C, v3d, region); if ((rv3d->viewlock & RV3D_LOCKED) == 0 || (view_opposite != RV3D_VIEW_USER)) { if ((rv3d->persp != RV3D_CAMOB) || ED_view3d_camera_lock_check(v3d, rv3d)) { @@ -4215,7 +4223,7 @@ static int vieworbit_exec(bContext *C, wmOperator *op) if (view_opposite == RV3D_VIEW_USER) { const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); - ED_view3d_persp_ensure(depsgraph, v3d, ar); + ED_view3d_persp_ensure(depsgraph, v3d, region); } if (ELEM(orbitdir, V3D_VIEW_STEPLEFT, V3D_VIEW_STEPRIGHT)) { @@ -4261,7 +4269,7 @@ static int vieworbit_exec(bContext *C, wmOperator *op) ED_view3d_smooth_view(C, v3d, - ar, + region, smooth_viewtx, &(const V3D_SmoothParams){ .quat = quat_new, @@ -4306,9 +4314,9 @@ void VIEW3D_OT_view_orbit(wmOperatorType *ot) * \{ */ static void view_roll_angle( - ARegion *ar, float quat[4], const float orig_quat[4], const float dvec[3], float angle) + ARegion *region, float quat[4], const float orig_quat[4], const float dvec[3], float angle) { - RegionView3D *rv3d = ar->regiondata; + RegionView3D *rv3d = region->regiondata; float quat_mul[4]; /* camera axis */ @@ -4329,14 +4337,14 @@ static void viewroll_apply(ViewOpsData *vod, int x, int UNUSED(y)) { float len1, len2, tot; - tot = vod->ar->winrct.xmax - vod->ar->winrct.xmin; - len1 = (vod->ar->winrct.xmax - x) / tot; - len2 = (vod->ar->winrct.xmax - vod->init.event_xy[0]) / tot; + tot = vod->region->winrct.xmax - vod->region->winrct.xmin; + len1 = (vod->region->winrct.xmax - x) / tot; + len2 = (vod->region->winrct.xmax - vod->init.event_xy[0]) / tot; angle = (len1 - len2) * (float)M_PI * 4.0f; } if (angle != 0.0f) { - view_roll_angle(vod->ar, vod->rv3d->viewquat, vod->init.quat, vod->init.mousevec, angle); + view_roll_angle(vod->region, vod->rv3d->viewquat, vod->init.quat, vod->init.mousevec, angle); } if (vod->use_dyn_ofs) { @@ -4345,12 +4353,12 @@ static void viewroll_apply(ViewOpsData *vod, int x, int UNUSED(y)) } if (vod->rv3d->viewlock & RV3D_BOXVIEW) { - view3d_boxview_sync(vod->sa, vod->ar); + view3d_boxview_sync(vod->sa, vod->region); } ED_view3d_camera_lock_sync(vod->depsgraph, vod->v3d, vod->rv3d); - ED_region_tag_redraw(vod->ar); + ED_region_tag_redraw(vod->region); } static int viewroll_modal(bContext *C, wmOperator *op, const wmEvent *event) @@ -4417,21 +4425,21 @@ static int viewroll_exec(bContext *C, wmOperator *op) { View3D *v3d; RegionView3D *rv3d; - ARegion *ar; + ARegion *region; if (op->customdata) { ViewOpsData *vod = op->customdata; - ar = vod->ar; + region = vod->region; v3d = vod->v3d; } else { - ED_view3d_context_user_region(C, &v3d, &ar); + ED_view3d_context_user_region(C, &v3d, ®ion); } - rv3d = ar->regiondata; + rv3d = region->regiondata; if ((rv3d->persp != RV3D_CAMOB) || ED_view3d_camera_lock_check(v3d, rv3d)) { - ED_view3d_smooth_view_force_finish(C, v3d, ar); + ED_view3d_smooth_view_force_finish(C, v3d, region); int type = RNA_enum_get(op->ptr, "type"); float angle = (type == 0) ? RNA_float_get(op->ptr, "angle") : DEG2RADF(U.pad_rot_angle); @@ -4446,7 +4454,7 @@ static int viewroll_exec(bContext *C, wmOperator *op) normalize_v3_v3(mousevec, rv3d->viewinv[2]); negate_v3(mousevec); - view_roll_angle(ar, quat_new, rv3d->viewquat, mousevec, angle); + view_roll_angle(region, quat_new, rv3d->viewquat, mousevec, angle); const float *dyn_ofs_pt = NULL; float dyn_ofs[3]; @@ -4459,7 +4467,7 @@ static int viewroll_exec(bContext *C, wmOperator *op) ED_view3d_smooth_view(C, v3d, - ar, + region, smooth_viewtx, &(const V3D_SmoothParams){ .quat = quat_new, @@ -4490,7 +4498,7 @@ static int viewroll_invoke(bContext *C, wmOperator *op, const wmEvent *event) viewops_data_create(C, op, event, viewops_flag_from_prefs()); vod = op->customdata; - ED_view3d_smooth_view_force_finish(C, vod->v3d, vod->ar); + ED_view3d_smooth_view_force_finish(C, vod->v3d, vod->region); /* overwrite the mouse vector with the view direction */ normalize_v3_v3(vod->init.mousevec, vod->rv3d->viewinv[2]); @@ -4632,12 +4640,12 @@ void VIEW3D_OT_view_pan(wmOperatorType *ot) static int viewpersportho_exec(bContext *C, wmOperator *UNUSED(op)) { View3D *v3d_dummy; - ARegion *ar; + ARegion *region; RegionView3D *rv3d; /* no NULL check is needed, poll checks */ - ED_view3d_context_user_region(C, &v3d_dummy, &ar); - rv3d = ar->regiondata; + ED_view3d_context_user_region(C, &v3d_dummy, ®ion); + rv3d = region->regiondata; if ((rv3d->viewlock & RV3D_LOCKED) == 0) { if (rv3d->persp != RV3D_ORTHO) { @@ -4646,7 +4654,7 @@ static int viewpersportho_exec(bContext *C, wmOperator *UNUSED(op)) else { rv3d->persp = RV3D_PERSP; } - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); } return OPERATOR_FINISHED; @@ -4872,7 +4880,7 @@ void ED_view3d_clipping_local(RegionView3D *rv3d, float mat[4][4]) static int view3d_clipping_exec(bContext *C, wmOperator *op) { - ARegion *ar = CTX_wm_region(C); + ARegion *region = CTX_wm_region(C); RegionView3D *rv3d = CTX_wm_region_view3d(C); rcti rect; @@ -4882,7 +4890,7 @@ static int view3d_clipping_exec(bContext *C, wmOperator *op) rv3d->clipbb = MEM_callocN(sizeof(BoundBox), "clipbb"); /* NULL object because we don't want it in object space */ - ED_view3d_clipping_calc(rv3d->clipbb, rv3d->clip, ar, NULL, &rect); + ED_view3d_clipping_calc(rv3d->clipbb, rv3d->clip, region, NULL, &rect); return OPERATOR_FINISHED; } @@ -4890,11 +4898,11 @@ static int view3d_clipping_exec(bContext *C, wmOperator *op) static int view3d_clipping_invoke(bContext *C, wmOperator *op, const wmEvent *event) { RegionView3D *rv3d = CTX_wm_region_view3d(C); - ARegion *ar = CTX_wm_region(C); + ARegion *region = CTX_wm_region(C); if (rv3d->rflag & RV3D_CLIPPING) { rv3d->rflag &= ~RV3D_CLIPPING; - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); if (rv3d->clipbb) { MEM_freeN(rv3d->clipbb); } @@ -4942,9 +4950,9 @@ void ED_view3d_cursor3d_position(bContext *C, const bool use_depth, float cursor_co[3]) { - ARegion *ar = CTX_wm_region(C); + ARegion *region = CTX_wm_region(C); View3D *v3d = CTX_wm_view3d(C); - RegionView3D *rv3d = ar->regiondata; + RegionView3D *rv3d = region->regiondata; bool flip; bool depth_used = false; @@ -4967,7 +4975,7 @@ void ED_view3d_cursor3d_position(bContext *C, struct Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); view3d_operator_needs_opengl(C); - if (ED_view3d_autodist(depsgraph, ar, v3d, mval, cursor_co, true, NULL)) { + if (ED_view3d_autodist(depsgraph, region, v3d, mval, cursor_co, true, NULL)) { depth_used = true; } } @@ -4975,7 +4983,7 @@ void ED_view3d_cursor3d_position(bContext *C, if (depth_used == false) { float depth_pt[3]; copy_v3_v3(depth_pt, cursor_co); - ED_view3d_win_to_3d_int(v3d, ar, depth_pt, mval, cursor_co); + ED_view3d_win_to_3d_int(v3d, region, depth_pt, mval, cursor_co); } } @@ -4989,8 +4997,8 @@ void ED_view3d_cursor3d_position_rotation(bContext *C, Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); View3D *v3d = CTX_wm_view3d(C); - ARegion *ar = CTX_wm_region(C); - RegionView3D *rv3d = ar->regiondata; + ARegion *region = CTX_wm_region(C); + RegionView3D *rv3d = region->regiondata; /* XXX, caller should check. */ if (rv3d == NULL) { @@ -5020,7 +5028,7 @@ void ED_view3d_cursor3d_position_rotation(bContext *C, float ray_co[3]; struct SnapObjectContext *snap_context = ED_transform_snap_object_context_create_view3d( - bmain, scene, CTX_data_ensure_evaluated_depsgraph(C), 0, ar, v3d); + bmain, scene, CTX_data_ensure_evaluated_depsgraph(C), 0, region, v3d); float obmat[4][4]; Object *ob_dummy = NULL; @@ -5102,8 +5110,8 @@ void ED_view3d_cursor3d_update(bContext *C, { Scene *scene = CTX_data_scene(C); View3D *v3d = CTX_wm_view3d(C); - ARegion *ar = CTX_wm_region(C); - RegionView3D *rv3d = ar->regiondata; + ARegion *region = CTX_wm_region(C); + RegionView3D *rv3d = region->regiondata; View3DCursor *cursor_curr = &scene->cursor; View3DCursor cursor_prev = *cursor_curr; @@ -5137,11 +5145,11 @@ void ED_view3d_cursor3d_update(bContext *C, float co_2d_curr[2], co_2d_prev[2]; if ((ED_view3d_project_float_global( - ar, cursor_prev.location, co_2d_prev, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) && + region, cursor_prev.location, co_2d_prev, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) && (ED_view3d_project_float_global( - ar, cursor_curr->location, co_2d_curr, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK)) { - rv3d->ofs_lock[0] += (co_2d_curr[0] - co_2d_prev[0]) / (ar->winx * 0.5f); - rv3d->ofs_lock[1] += (co_2d_curr[1] - co_2d_prev[1]) / (ar->winy * 0.5f); + region, cursor_curr->location, co_2d_curr, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK)) { + rv3d->ofs_lock[0] += (co_2d_curr[0] - co_2d_prev[0]) / (region->winx * 0.5f); + rv3d->ofs_lock[1] += (co_2d_curr[1] - co_2d_prev[1]) / (region->winy * 0.5f); } } else { diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c index 165e4c7c6a3..eb7b1412fde 100644 --- a/source/blender/editors/space_view3d/view3d_fly.c +++ b/source/blender/editors/space_view3d/view3d_fly.c @@ -142,7 +142,7 @@ typedef struct FlyInfo { /* context stuff */ RegionView3D *rv3d; View3D *v3d; - ARegion *ar; + ARegion *region; struct Depsgraph *depsgraph; Scene *scene; @@ -211,7 +211,7 @@ static void flyApply_ndof(bContext *C, FlyInfo *fly, bool is_confirm); #endif /* WITH_INPUT_NDOF */ static int flyApply(bContext *C, struct FlyInfo *fly, bool force_autokey); -static void drawFlyPixel(const struct bContext *UNUSED(C), ARegion *UNUSED(ar), void *arg) +static void drawFlyPixel(const struct bContext *UNUSED(C), ARegion *UNUSED(region), void *arg) { FlyInfo *fly = arg; rctf viewborder; @@ -220,7 +220,7 @@ static void drawFlyPixel(const struct bContext *UNUSED(C), ARegion *UNUSED(ar), if (ED_view3d_cameracontrol_object_get(fly->v3d_camera_control)) { ED_view3d_calc_camera_border( - fly->scene, fly->depsgraph, fly->ar, fly->v3d, fly->rv3d, &viewborder, false); + fly->scene, fly->depsgraph, fly->region, fly->v3d, fly->rv3d, &viewborder, false); xoff = viewborder.xmin; yoff = viewborder.ymin; } @@ -296,7 +296,7 @@ static bool initFlyInfo(bContext *C, FlyInfo *fly, wmOperator *op, const wmEvent fly->rv3d = CTX_wm_region_view3d(C); fly->v3d = CTX_wm_view3d(C); - fly->ar = CTX_wm_region(C); + fly->region = CTX_wm_region(C); fly->depsgraph = CTX_data_expect_evaluated_depsgraph(C); fly->scene = CTX_data_scene(C); @@ -353,7 +353,7 @@ static bool initFlyInfo(bContext *C, FlyInfo *fly, wmOperator *op, const wmEvent fly->time_lastdraw = fly->time_lastwheel = PIL_check_seconds_timer(); fly->draw_handle_pixel = ED_region_draw_cb_activate( - fly->ar->type, drawFlyPixel, fly, REGION_DRAW_POST_PIXEL); + fly->region->type, drawFlyPixel, fly, REGION_DRAW_POST_PIXEL); fly->rv3d->rflag |= RV3D_NAVIGATING; @@ -371,7 +371,7 @@ static bool initFlyInfo(bContext *C, FlyInfo *fly, wmOperator *op, const wmEvent /* calculate center */ if (ED_view3d_cameracontrol_object_get(fly->v3d_camera_control)) { ED_view3d_calc_camera_border( - fly->scene, fly->depsgraph, fly->ar, fly->v3d, fly->rv3d, &viewborder, false); + fly->scene, fly->depsgraph, fly->region, fly->v3d, fly->rv3d, &viewborder, false); fly->width = BLI_rctf_size_x(&viewborder); fly->height = BLI_rctf_size_y(&viewborder); @@ -380,16 +380,17 @@ static bool initFlyInfo(bContext *C, FlyInfo *fly, wmOperator *op, const wmEvent fly->center_mval[1] = viewborder.ymin + fly->height / 2; } else { - fly->width = fly->ar->winx; - fly->height = fly->ar->winy; + fly->width = fly->region->winx; + fly->height = fly->region->winy; fly->center_mval[0] = fly->width / 2; fly->center_mval[1] = fly->height / 2; } /* center the mouse, probably the UI mafia are against this but without its quite annoying */ - WM_cursor_warp( - win, fly->ar->winrct.xmin + fly->center_mval[0], fly->ar->winrct.ymin + fly->center_mval[1]); + WM_cursor_warp(win, + fly->region->winrct.xmin + fly->center_mval[0], + fly->region->winrct.ymin + fly->center_mval[1]); return 1; } @@ -424,7 +425,7 @@ static int flyEnd(bContext *C, FlyInfo *fly) WM_event_remove_timer(CTX_wm_manager(C), win, fly->timer); - ED_region_draw_cb_exit(fly->ar->type, fly->draw_handle_pixel); + ED_region_draw_cb_exit(fly->region->type, fly->draw_handle_pixel); ED_view3d_cameracontrol_release(fly->v3d_camera_control, fly->state == FLY_CANCEL); @@ -786,7 +787,7 @@ static int flyApply(bContext *C, FlyInfo *fly, bool is_confirm) } /* scale the mouse movement by this value - scales mouse movement to the view size - * moffset[0] / (ar->winx-xmargin * 2) - window size minus margin (same for y) + * moffset[0] / (region->winx-xmargin * 2) - window size minus margin (same for y) * * the mouse moves isn't linear */ diff --git a/source/blender/editors/space_view3d/view3d_gizmo_camera.c b/source/blender/editors/space_view3d/view3d_gizmo_camera.c index 8e279b2d11a..23845a64ad8 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_camera.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_camera.c @@ -253,13 +253,13 @@ static void WIDGETGROUP_camera_message_subscribe(const bContext *C, wmGizmoGroup *gzgroup, struct wmMsgBus *mbus) { - ARegion *ar = CTX_wm_region(C); + ARegion *region = CTX_wm_region(C); ViewLayer *view_layer = CTX_data_view_layer(C); Object *ob = OBACT(view_layer); Camera *ca = ob->data; wmMsgSubscribeValue msg_sub_value_gz_tag_refresh = { - .owner = ar, + .owner = region, .user_data = gzgroup->parent_gzmap, .notify = WM_gizmo_do_msg_notify_tag_refresh, }; @@ -403,8 +403,8 @@ static bool WIDGETGROUP_camera_view_poll(const bContext *C, wmGizmoGroupType *UN return false; } - ARegion *ar = CTX_wm_region(C); - RegionView3D *rv3d = ar->regiondata; + ARegion *region = CTX_wm_region(C); + RegionView3D *rv3d = region->regiondata; if (rv3d->persp == RV3D_CAMOB) { if (scene->r.mode & R_BORDER) { /* TODO: support overrides. */ @@ -441,22 +441,22 @@ static void WIDGETGROUP_camera_view_draw_prepare(const bContext *C, wmGizmoGroup { struct CameraViewWidgetGroup *viewgroup = gzgroup->customdata; - ARegion *ar = CTX_wm_region(C); + ARegion *region = CTX_wm_region(C); /* Drawing code should happen with fully evaluated graph. */ struct Depsgraph *depsgraph = CTX_data_expect_evaluated_depsgraph(C); - RegionView3D *rv3d = ar->regiondata; + RegionView3D *rv3d = region->regiondata; if (rv3d->persp == RV3D_CAMOB) { Scene *scene = CTX_data_scene(C); View3D *v3d = CTX_wm_view3d(C); ED_view3d_calc_camera_border( - scene, depsgraph, ar, v3d, rv3d, &viewgroup->state.view_border, false); + scene, depsgraph, region, v3d, rv3d, &viewgroup->state.view_border, false); } else { viewgroup->state.view_border = (rctf){ .xmin = 0, .ymin = 0, - .xmax = ar->winx, - .ymax = ar->winy, + .xmax = region->winx, + .ymax = region->winy, }; } @@ -473,8 +473,8 @@ static void WIDGETGROUP_camera_view_refresh(const bContext *C, wmGizmoGroup *gzg struct CameraViewWidgetGroup *viewgroup = gzgroup->customdata; View3D *v3d = CTX_wm_view3d(C); - ARegion *ar = CTX_wm_region(C); - RegionView3D *rv3d = ar->regiondata; + ARegion *region = CTX_wm_region(C); + RegionView3D *rv3d = region->regiondata; Scene *scene = CTX_data_scene(C); viewgroup->scene = scene; diff --git a/source/blender/editors/space_view3d/view3d_gizmo_navigate.c b/source/blender/editors/space_view3d/view3d_gizmo_navigate.c index 25dd5b69f98..0d55fcda6a9 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_navigate.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_navigate.c @@ -239,14 +239,14 @@ static void WIDGETGROUP_navigate_setup(const bContext *C, wmGizmoGroup *gzgroup) static void WIDGETGROUP_navigate_draw_prepare(const bContext *C, wmGizmoGroup *gzgroup) { struct NavigateWidgetGroup *navgroup = gzgroup->customdata; - ARegion *ar = CTX_wm_region(C); - const RegionView3D *rv3d = ar->regiondata; + ARegion *region = CTX_wm_region(C); + const RegionView3D *rv3d = region->regiondata; for (int i = 0; i < 3; i++) { copy_v3_v3(navgroup->gz_array[GZ_INDEX_ROTATE]->matrix_offset[i], rv3d->viewmat[i]); } - const rcti *rect_visible = ED_region_visible_rect(ar); + const rcti *rect_visible = ED_region_visible_rect(region); if ((navgroup->state.rect_visible.xmax == rect_visible->xmax) && (navgroup->state.rect_visible.ymax == rect_visible->ymax) && diff --git a/source/blender/editors/space_view3d/view3d_gizmo_preselect_type.c b/source/blender/editors/space_view3d/view3d_gizmo_preselect_type.c index eec5ec3da34..0a5b27a4d15 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_preselect_type.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_preselect_type.c @@ -158,7 +158,7 @@ static int gizmo_preselect_elem_test_select(bContext *C, wmGizmo *gz, const int float vert_p_co[3], vert_co[3]; float mval_f[2] = {UNPACK2(vc.mval)}; mul_v3_m4v3(vert_co, gz_ele->bases[base_index_vert]->object->obmat, vert->co); - ED_view3d_project(vc.ar, vert_co, vert_p_co); + ED_view3d_project(vc.region, vert_co, vert_p_co); float len = len_v2v2(vert_p_co, mval_f); if (len < 35) { best.ele = (BMElem *)eve_test; @@ -226,8 +226,8 @@ static int gizmo_preselect_elem_test_select(bContext *C, wmGizmo *gz, const int RNA_int_set(gz->ptr, "face_index", gz_ele->face_index); if (best.ele) { - ARegion *ar = CTX_wm_region(C); - ED_region_tag_redraw_editor_overlays(ar); + ARegion *region = CTX_wm_region(C); + ED_region_tag_redraw_editor_overlays(region); } // return best.eed ? 0 : -1; @@ -382,8 +382,8 @@ static int gizmo_preselect_edgering_test_select(bContext *C, wmGizmo *gz, const RNA_int_set(gz->ptr, "object_index", gz_ring->base_index); RNA_int_set(gz->ptr, "edge_index", gz_ring->edge_index); - ARegion *ar = CTX_wm_region(C); - ED_region_tag_redraw_editor_overlays(ar); + ARegion *region = CTX_wm_region(C); + ED_region_tag_redraw_editor_overlays(region); } // return best.eed ? 0 : -1; diff --git a/source/blender/editors/space_view3d/view3d_gizmo_ruler.c b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c index db120b246c7..99789a512d3 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_ruler.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c @@ -111,7 +111,7 @@ typedef struct RulerInfo { /* wm state */ wmWindow *win; ScrArea *sa; - ARegion *ar; /* re-assigned every modal update */ + ARegion *region; /* re-assigned every modal update */ /* Track changes in state. */ struct { @@ -201,7 +201,7 @@ static bool view3d_ruler_pick(wmGizmoGroup *gzgroup, int *r_co_index) { RulerInfo *ruler_info = gzgroup->customdata; - ARegion *ar = ruler_info->ar; + ARegion *region = ruler_info->region; bool found = false; float dist_best = RULER_PICK_DIST_SQ; @@ -214,7 +214,7 @@ static bool view3d_ruler_pick(wmGizmoGroup *gzgroup, /* should these be checked? - ok for now not to */ for (j = 0; j < 3; j++) { - ED_view3d_project_float_global(ar, ruler_item->co[j], co_ss[j], V3D_PROJ_TEST_NOP); + ED_view3d_project_float_global(region, ruler_item->co[j], co_ss[j], V3D_PROJ_TEST_NOP); } if (ruler_item->flag & RULERITEM_USE_ANGLE) { @@ -292,7 +292,7 @@ static void ruler_state_set(bContext *C, RulerInfo *ruler_info, int state) CTX_data_scene(C), CTX_data_ensure_evaluated_depsgraph(C), 0, - ruler_info->ar, + ruler_info->region, CTX_wm_view3d(C)); } else { @@ -304,7 +304,7 @@ static void ruler_state_set(bContext *C, RulerInfo *ruler_info, int state) static void view3d_ruler_item_project(RulerInfo *ruler_info, float r_co[3], const int xy[2]) { - ED_view3d_win_to_3d_int(ruler_info->sa->spacedata.first, ruler_info->ar, r_co, xy, r_co); + ED_view3d_win_to_3d_int(ruler_info->sa->spacedata.first, ruler_info->region, r_co, xy, r_co); } /* use for mousemove events */ @@ -543,8 +543,8 @@ static void gizmo_ruler_draw(const bContext *C, wmGizmo *gz) UnitSettings *unit = &scene->unit; RulerInfo *ruler_info = gz->parent_gzgroup->customdata; RulerItem *ruler_item = (RulerItem *)gz; - ARegion *ar = ruler_info->ar; - RegionView3D *rv3d = ar->regiondata; + ARegion *region = ruler_info->region; + RegionView3D *rv3d = region->regiondata; const float cap_size = 4.0f; const float bg_margin = 4.0f * U.pixelsize; const float arc_size = 64.0f * U.pixelsize; @@ -579,7 +579,7 @@ static void gizmo_ruler_draw(const bContext *C, wmGizmo *gz) /* should these be checked? - ok for now not to */ for (j = 0; j < 3; j++) { - ED_view3d_project_float_global(ar, ruler_item->co[j], co_ss[j], V3D_PROJ_TEST_NOP); + ED_view3d_project_float_global(region, ruler_item->co[j], co_ss[j], V3D_PROJ_TEST_NOP); } GPU_blend(true); @@ -649,7 +649,7 @@ static void gizmo_ruler_draw(const bContext *C, wmGizmo *gz) for (j = 0; j <= arc_steps; j++) { madd_v3_v3v3fl(co_tmp, ruler_item->co[1], dir_tmp, px_scale); - ED_view3d_project_float_global(ar, co_tmp, arc_ss_coord, V3D_PROJ_TEST_NOP); + ED_view3d_project_float_global(region, co_tmp, arc_ss_coord, V3D_PROJ_TEST_NOP); mul_qt_v3(quat, dir_tmp); immVertex2fv(shdr_pos, arc_ss_coord); @@ -859,7 +859,7 @@ static void gizmo_ruler_draw(const bContext *C, wmGizmo *gz) const float size = 2.5f * UI_GetThemeValuef(TH_VERTEX_SIZE); float co_ss_snap[3]; ED_view3d_project_float_global( - ar, ruler_item->co[inter->co_index], co_ss_snap, V3D_PROJ_TEST_NOP); + region, ruler_item->co[inter->co_index], co_ss_snap, V3D_PROJ_TEST_NOP); uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); @@ -901,10 +901,10 @@ static int gizmo_ruler_modal(bContext *C, int exit_code = OPERATOR_RUNNING_MODAL; RulerInfo *ruler_info = gz->parent_gzgroup->customdata; RulerItem *ruler_item = (RulerItem *)gz; - ARegion *ar = CTX_wm_region(C); + ARegion *region = CTX_wm_region(C); bool do_cursor_update = false; - ruler_info->ar = ar; + ruler_info->region = region; switch (event->type) { case MOUSEMOVE: { @@ -933,7 +933,7 @@ static int gizmo_ruler_modal(bContext *C, ruler_info->drag_state_prev.do_thickness = do_thickness; if (do_draw) { - ED_region_tag_redraw_editor_overlays(ar); + ED_region_tag_redraw_editor_overlays(region); } return exit_code; } @@ -946,7 +946,7 @@ static int gizmo_ruler_invoke(bContext *C, wmGizmo *gz, const wmEvent *event) RulerInteraction *inter = MEM_callocN(sizeof(RulerInteraction), __func__); gz->interaction_data = inter; - ARegion *ar = ruler_info->ar; + ARegion *region = ruler_info->region; const float mval_fl[2] = {UNPACK2(event->mval)}; @@ -963,8 +963,10 @@ static int gizmo_ruler_invoke(bContext *C, wmGizmo *gz, const wmEvent *event) float co_ss[2][2]; float fac; - ED_view3d_project_float_global(ar, ruler_item_pick->co[0], co_ss[0], V3D_PROJ_TEST_NOP); - ED_view3d_project_float_global(ar, ruler_item_pick->co[2], co_ss[1], V3D_PROJ_TEST_NOP); + ED_view3d_project_float_global( + region, ruler_item_pick->co[0], co_ss[0], V3D_PROJ_TEST_NOP); + ED_view3d_project_float_global( + region, ruler_item_pick->co[2], co_ss[1], V3D_PROJ_TEST_NOP); fac = line_point_factor_v2(mval_fl, co_ss[0], co_ss[1]); CLAMP(fac, 0.0f, 1.0f); @@ -1060,10 +1062,10 @@ static void WIDGETGROUP_ruler_setup(const bContext *C, wmGizmoGroup *gzgroup) wmWindow *win = CTX_wm_window(C); ScrArea *sa = CTX_wm_area(C); - ARegion *ar = CTX_wm_region(C); + ARegion *region = CTX_wm_region(C); ruler_info->win = win; ruler_info->sa = sa; - ruler_info->ar = ar; + ruler_info->region = region; gzgroup->customdata = ruler_info; } @@ -1100,16 +1102,16 @@ static bool view3d_ruler_poll(bContext *C) static int view3d_ruler_add_invoke(bContext *C, wmOperator *op, const wmEvent *event) { - ARegion *ar = CTX_wm_region(C); + ARegion *region = CTX_wm_region(C); View3D *v3d = CTX_wm_view3d(C); - RegionView3D *rv3d = ar->regiondata; + RegionView3D *rv3d = region->regiondata; if (v3d->gizmo_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_TOOL)) { BKE_report(op->reports, RPT_WARNING, "Gizmos hidden in this view"); return OPERATOR_CANCELLED; } - wmGizmoMap *gzmap = ar->gizmo_map; + wmGizmoMap *gzmap = region->gizmo_map; wmGizmoGroup *gzgroup = WM_gizmomap_group_find(gzmap, view3d_gzgt_ruler_id); const bool use_depth = (v3d->shading.type >= OB_SOLID); @@ -1162,7 +1164,7 @@ void VIEW3D_OT_ruler_add(wmOperatorType *ot) static int view3d_ruler_remove_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { - ARegion *ar = CTX_wm_region(C); + ARegion *region = CTX_wm_region(C); View3D *v3d = CTX_wm_view3d(C); if (v3d->gizmo_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_TOOL)) { @@ -1170,7 +1172,7 @@ static int view3d_ruler_remove_invoke(bContext *C, wmOperator *op, const wmEvent return OPERATOR_CANCELLED; } - wmGizmoMap *gzmap = ar->gizmo_map; + wmGizmoMap *gzmap = region->gizmo_map; wmGizmoGroup *gzgroup = WM_gizmomap_group_find(gzmap, view3d_gzgt_ruler_id); if (gzgroup) { RulerInfo *ruler_info = gzgroup->customdata; @@ -1187,7 +1189,7 @@ static int view3d_ruler_remove_invoke(bContext *C, wmOperator *op, const wmEvent /* Update the annotation layer. */ view3d_ruler_to_gpencil(C, gzgroup); - ED_region_tag_redraw_editor_overlays(ar); + ED_region_tag_redraw_editor_overlays(region); return OPERATOR_FINISHED; } } diff --git a/source/blender/editors/space_view3d/view3d_gizmo_tool_generic.c b/source/blender/editors/space_view3d/view3d_gizmo_tool_generic.c index 75d0384182b..2a07128b227 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_tool_generic.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_tool_generic.c @@ -164,10 +164,10 @@ static void WIDGETGROUP_gizmo_message_subscribe(const bContext *C, wmGizmoGroup *gzgroup, struct wmMsgBus *mbus) { - ARegion *ar = CTX_wm_region(C); + ARegion *region = CTX_wm_region(C); wmMsgSubscribeValue msg_sub_value_gz_tag_refresh = { - .owner = ar, + .owner = region, .user_data = gzgroup->parent_gzmap, .notify = WM_gizmo_do_msg_notify_tag_refresh, }; diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index c1690445a41..2ced545a108 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -91,8 +91,8 @@ void VIEW3D_OT_zoom_border(struct wmOperatorType *ot); void VIEW3D_OT_toggle_shading(struct wmOperatorType *ot); void VIEW3D_OT_toggle_xray(struct wmOperatorType *ot); -void view3d_boxview_copy(struct ScrArea *sa, struct ARegion *ar); -void view3d_boxview_sync(struct ScrArea *sa, struct ARegion *ar); +void view3d_boxview_copy(struct ScrArea *sa, struct ARegion *region); +void view3d_boxview_sync(struct ScrArea *sa, struct ARegion *region); void view3d_orbit_apply_dyn_ofs(float r_ofs[3], const float ofs_old[3], @@ -120,18 +120,18 @@ void VIEW3D_OT_fly(struct wmOperatorType *ot); void VIEW3D_OT_walk(struct wmOperatorType *ot); /* view3d_draw.c */ -void view3d_main_region_draw(const struct bContext *C, struct ARegion *ar); -void view3d_draw_region_info(const struct bContext *C, struct ARegion *ar); +void view3d_main_region_draw(const struct bContext *C, struct ARegion *region); +void view3d_draw_region_info(const struct bContext *C, struct ARegion *region); void ED_view3d_draw_depth(struct Depsgraph *depsgraph, - struct ARegion *ar, + struct ARegion *region, View3D *v3d, bool alphaoverride); /* view3d_draw_legacy.c */ void ED_view3d_draw_depth_gpencil(struct Depsgraph *depsgraph, Scene *scene, - struct ARegion *ar, + struct ARegion *region, View3D *v3d); void ED_view3d_draw_select_loop(struct Depsgraph *depsgraph, @@ -139,16 +139,16 @@ void ED_view3d_draw_select_loop(struct Depsgraph *depsgraph, Scene *scene, struct ViewLayer *view_layer, View3D *v3d, - struct ARegion *ar, + struct ARegion *region, bool use_obedit_skip, bool use_nearest); void ED_view3d_draw_depth_loop(struct Depsgraph *depsgraph, Scene *scene, - struct ARegion *ar, + struct ARegion *region, View3D *v3d); -void view3d_update_depths_rect(struct ARegion *ar, struct ViewDepths *d, struct rcti *rect); +void view3d_update_depths_rect(struct ARegion *region, struct ViewDepths *d, struct rcti *rect); float view3d_depth_near(struct ViewDepths *d); /* view3d_select.c */ @@ -183,22 +183,22 @@ void ED_view3d_smooth_view_ex(const struct Depsgraph *depsgraph, struct wmWindow *win, struct ScrArea *sa, struct View3D *v3d, - struct ARegion *ar, + struct ARegion *region, const int smooth_viewtx, const V3D_SmoothParams *sview); void ED_view3d_smooth_view(struct bContext *C, struct View3D *v3d, - struct ARegion *ar, + struct ARegion *region, const int smooth_viewtx, const V3D_SmoothParams *sview); void ED_view3d_smooth_view_force_finish(struct bContext *C, struct View3D *v3d, - struct ARegion *ar); + struct ARegion *region); void view3d_winmatrix_set(struct Depsgraph *depsgraph, - struct ARegion *ar, + struct ARegion *region, const View3D *v3d, const rcti *rect); void view3d_viewmatrix_set(struct Depsgraph *depsgraph, diff --git a/source/blender/editors/space_view3d/view3d_iterators.c b/source/blender/editors/space_view3d/view3d_iterators.c index f6fa6f6fb45..b446ba74b56 100644 --- a/source/blender/editors/space_view3d/view3d_iterators.c +++ b/source/blender/editors/space_view3d/view3d_iterators.c @@ -73,7 +73,7 @@ typedef struct foreachScreenEdge_userData { int index); void *userData; ViewContext vc; - rctf win_rect; /* copy of: vc.ar->winx/winy, use for faster tests, minx/y will always be 0 */ + rctf win_rect; /* copy of: vc.region->winx/winy, use for faster tests, minx/y will always be 0 */ eV3DProjTest clip_flag; } foreachScreenEdge_userData; @@ -105,7 +105,7 @@ static void meshobject_foreachScreenVert__mapFunc(void *userData, if (!(mv->flag & ME_HIDE)) { float screen_co[2]; - if (ED_view3d_project_float_object(data->vc.ar, co, screen_co, data->clip_flag) != + if (ED_view3d_project_float_object(data->vc.region, co, screen_co, data->clip_flag) != V3D_PROJ_RET_OK) { return; } @@ -154,7 +154,7 @@ static void mesh_foreachScreenVert__mapFunc(void *userData, if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) { float screen_co[2]; - if (ED_view3d_project_float_object(data->vc.ar, co, screen_co, data->clip_flag) != + if (ED_view3d_project_float_object(data->vc.region, co, screen_co, data->clip_flag) != V3D_PROJ_RET_OK) { return; } @@ -204,11 +204,11 @@ static void mesh_foreachScreenEdge__mapFunc(void *userData, float screen_co_b[2]; eV3DProjTest clip_flag_nowin = data->clip_flag & ~V3D_PROJ_TEST_CLIP_WIN; - if (ED_view3d_project_float_object(data->vc.ar, v0co, screen_co_a, clip_flag_nowin) != + if (ED_view3d_project_float_object(data->vc.region, v0co, screen_co_a, clip_flag_nowin) != V3D_PROJ_RET_OK) { return; } - if (ED_view3d_project_float_object(data->vc.ar, v1co, screen_co_b, clip_flag_nowin) != + if (ED_view3d_project_float_object(data->vc.region, v1co, screen_co_b, clip_flag_nowin) != V3D_PROJ_RET_OK) { return; } @@ -243,8 +243,8 @@ void mesh_foreachScreenEdge(ViewContext *vc, data.win_rect.xmin = 0; data.win_rect.ymin = 0; - data.win_rect.xmax = vc->ar->winx; - data.win_rect.ymax = vc->ar->winy; + data.win_rect.xmax = vc->region->winx; + data.win_rect.ymax = vc->region->winy; data.func = func; data.userData = userData; @@ -289,11 +289,11 @@ static void mesh_foreachScreenEdge_clip_bb_segment__mapFunc(void *userData, eV3DProjTest clip_flag_nowin = data->clip_flag & ~(V3D_PROJ_TEST_CLIP_WIN | V3D_PROJ_TEST_CLIP_BB); - if (ED_view3d_project_float_object(data->vc.ar, v0co_clip, screen_co_a, clip_flag_nowin) != + if (ED_view3d_project_float_object(data->vc.region, v0co_clip, screen_co_a, clip_flag_nowin) != V3D_PROJ_RET_OK) { return; } - if (ED_view3d_project_float_object(data->vc.ar, v1co_clip, screen_co_b, clip_flag_nowin) != + if (ED_view3d_project_float_object(data->vc.region, v1co_clip, screen_co_b, clip_flag_nowin) != V3D_PROJ_RET_OK) { return; } @@ -332,8 +332,8 @@ void mesh_foreachScreenEdge_clip_bb_segment(ViewContext *vc, data.win_rect.xmin = 0; data.win_rect.ymin = 0; - data.win_rect.xmax = vc->ar->winx; - data.win_rect.ymax = vc->ar->winy; + data.win_rect.xmax = vc->region->winx; + data.win_rect.ymax = vc->region->winy; data.func = func; data.userData = userData; @@ -362,7 +362,7 @@ static void mesh_foreachScreenFace__mapFunc(void *userData, if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) { float screen_co[2]; - if (ED_view3d_project_float_object(data->vc.ar, cent, screen_co, data->clip_flag) == + if (ED_view3d_project_float_object(data->vc.region, cent, screen_co, data->clip_flag) == V3D_PROJ_RET_OK) { data->func(data->userData, efa, screen_co, index); } @@ -430,7 +430,7 @@ void nurbs_foreachScreenVert(ViewContext *vc, float screen_co[2]; if ((vc->v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_CU_HANDLES) == 0) { - if (ED_view3d_project_float_object(vc->ar, + if (ED_view3d_project_float_object(vc->region, bezt->vec[1], screen_co, V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN) == @@ -439,21 +439,21 @@ void nurbs_foreachScreenVert(ViewContext *vc, } } else { - if (ED_view3d_project_float_object(vc->ar, + if (ED_view3d_project_float_object(vc->region, bezt->vec[0], screen_co, V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN) == V3D_PROJ_RET_OK) { func(userData, nu, NULL, bezt, 0, screen_co); } - if (ED_view3d_project_float_object(vc->ar, + if (ED_view3d_project_float_object(vc->region, bezt->vec[1], screen_co, V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN) == V3D_PROJ_RET_OK) { func(userData, nu, NULL, bezt, 1, screen_co); } - if (ED_view3d_project_float_object(vc->ar, + if (ED_view3d_project_float_object(vc->region, bezt->vec[2], screen_co, V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN) == @@ -471,7 +471,7 @@ void nurbs_foreachScreenVert(ViewContext *vc, if (bp->hide == 0) { float screen_co[2]; if (ED_view3d_project_float_object( - vc->ar, bp->vec, screen_co, V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN) == + vc->region, bp->vec, screen_co, V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN) == V3D_PROJ_RET_OK) { func(userData, nu, bp, NULL, -1, screen_co); } @@ -498,7 +498,8 @@ void mball_foreachScreenElem(struct ViewContext *vc, for (ml = mb->editelems->first; ml; ml = ml->next) { float screen_co[2]; - if (ED_view3d_project_float_object(vc->ar, &ml->x, screen_co, clip_flag) == V3D_PROJ_RET_OK) { + if (ED_view3d_project_float_object(vc->region, &ml->x, screen_co, clip_flag) == + V3D_PROJ_RET_OK) { func(userData, ml, screen_co); } } @@ -529,7 +530,7 @@ void lattice_foreachScreenVert(ViewContext *vc, for (i = 0; i < N; i++, bp++, co += 3) { if (bp->hide == 0) { float screen_co[2]; - if (ED_view3d_project_float_object(vc->ar, dl ? co : bp->vec, screen_co, clip_flag) == + if (ED_view3d_project_float_object(vc->region, dl ? co : bp->vec, screen_co, clip_flag) == V3D_PROJ_RET_OK) { func(userData, bp, screen_co); } @@ -559,7 +560,7 @@ void armature_foreachScreenBone(struct ViewContext *vc, int points_proj_tot = 0; /* project head location to screenspace */ - if (ED_view3d_project_float_object(vc->ar, ebone->head, screen_co_a, clip_flag) == + if (ED_view3d_project_float_object(vc->region, ebone->head, screen_co_a, clip_flag) == V3D_PROJ_RET_OK) { points_proj_tot++; } @@ -569,7 +570,7 @@ void armature_foreachScreenBone(struct ViewContext *vc, } /* project tail location to screenspace */ - if (ED_view3d_project_float_object(vc->ar, ebone->tail, screen_co_b, clip_flag) == + if (ED_view3d_project_float_object(vc->region, ebone->tail, screen_co_b, clip_flag) == V3D_PROJ_RET_OK) { points_proj_tot++; } @@ -611,8 +612,8 @@ void pose_foreachScreenBone(struct ViewContext *vc, int points_proj_tot = 0; /* project head location to screenspace */ - if (ED_view3d_project_float_object(vc->ar, pchan_eval->pose_head, screen_co_a, clip_flag) == - V3D_PROJ_RET_OK) { + if (ED_view3d_project_float_object( + vc->region, pchan_eval->pose_head, screen_co_a, clip_flag) == V3D_PROJ_RET_OK) { points_proj_tot++; } else { @@ -621,8 +622,8 @@ void pose_foreachScreenBone(struct ViewContext *vc, } /* project tail location to screenspace */ - if (ED_view3d_project_float_object(vc->ar, pchan_eval->pose_tail, screen_co_b, clip_flag) == - V3D_PROJ_RET_OK) { + if (ED_view3d_project_float_object( + vc->region, pchan_eval->pose_tail, screen_co_b, clip_flag) == V3D_PROJ_RET_OK) { points_proj_tot++; } else { diff --git a/source/blender/editors/space_view3d/view3d_project.c b/source/blender/editors/space_view3d/view3d_project.c index 56c8b4bcbe9..10791bd1c9f 100644 --- a/source/blender/editors/space_view3d/view3d_project.c +++ b/source/blender/editors/space_view3d/view3d_project.c @@ -47,7 +47,7 @@ /** * \note use #ED_view3d_ob_project_mat_get to get the projection matrix */ -void ED_view3d_project_float_v2_m4(const ARegion *ar, +void ED_view3d_project_float_v2_m4(const ARegion *region, const float co[3], float r_co[2], float mat[4][4]) @@ -61,8 +61,8 @@ void ED_view3d_project_float_v2_m4(const ARegion *ar, mul_m4_v4(mat, vec4); if (vec4[3] > FLT_EPSILON) { - r_co[0] = (float)(ar->winx / 2.0f) + (ar->winx / 2.0f) * vec4[0] / vec4[3]; - r_co[1] = (float)(ar->winy / 2.0f) + (ar->winy / 2.0f) * vec4[1] / vec4[3]; + r_co[0] = (float)(region->winx / 2.0f) + (region->winx / 2.0f) * vec4[0] / vec4[3]; + r_co[1] = (float)(region->winy / 2.0f) + (region->winy / 2.0f) * vec4[1] / vec4[3]; } else { zero_v2(r_co); @@ -72,7 +72,7 @@ void ED_view3d_project_float_v2_m4(const ARegion *ar, /** * \note use #ED_view3d_ob_project_mat_get to get projecting mat */ -void ED_view3d_project_float_v3_m4(const ARegion *ar, +void ED_view3d_project_float_v3_m4(const ARegion *region, const float vec[3], float r_co[3], float mat[4][4]) @@ -86,8 +86,8 @@ void ED_view3d_project_float_v3_m4(const ARegion *ar, mul_m4_v4(mat, vec4); if (vec4[3] > FLT_EPSILON) { - r_co[0] = (float)(ar->winx / 2.0f) + (ar->winx / 2.0f) * vec4[0] / vec4[3]; - r_co[1] = (float)(ar->winy / 2.0f) + (ar->winy / 2.0f) * vec4[1] / vec4[3]; + r_co[0] = (float)(region->winx / 2.0f) + (region->winx / 2.0f) * vec4[0] / vec4[3]; + r_co[1] = (float)(region->winy / 2.0f) + (region->winy / 2.0f) * vec4[1] / vec4[3]; r_co[2] = vec4[2] / vec4[3]; } else { @@ -98,10 +98,10 @@ void ED_view3d_project_float_v3_m4(const ARegion *ar, /* Clipping Projection Functions * ***************************** */ -eV3DProjStatus ED_view3d_project_base(const struct ARegion *ar, struct Base *base) +eV3DProjStatus ED_view3d_project_base(const struct ARegion *region, struct Base *base) { eV3DProjStatus ret = ED_view3d_project_short_global( - ar, base->object->obmat[3], &base->sx, V3D_PROJ_TEST_CLIP_DEFAULT); + region, base->object->obmat[3], &base->sx, V3D_PROJ_TEST_CLIP_DEFAULT); if (ret != V3D_PROJ_RET_OK) { base->sx = IS_CLIPPED; @@ -115,7 +115,7 @@ eV3DProjStatus ED_view3d_project_base(const struct ARegion *ar, struct Base *bas * - 'rv3d->perspmat', is_local == false * - 'rv3d->persmatob', is_local == true */ -static eV3DProjStatus ed_view3d_project__internal(const ARegion *ar, +static eV3DProjStatus ed_view3d_project__internal(const ARegion *region, const float perspmat[4][4], const bool is_local, /* normally hidden */ const float co[3], @@ -128,7 +128,7 @@ static eV3DProjStatus ed_view3d_project__internal(const ARegion *ar, BLI_assert((flag & V3D_PROJ_TEST_ALL) == flag); if (flag & V3D_PROJ_TEST_CLIP_BB) { - RegionView3D *rv3d = ar->regiondata; + RegionView3D *rv3d = region->regiondata; if (rv3d->rflag & RV3D_CLIPPING) { if (ED_view3d_clipping_test(rv3d, co, is_local)) { return V3D_PROJ_RET_CLIP_BB; @@ -143,10 +143,10 @@ static eV3DProjStatus ed_view3d_project__internal(const ARegion *ar, if (((flag & V3D_PROJ_TEST_CLIP_ZERO) == 0) || (fabsf(vec4[3]) > (float)BL_ZERO_CLIP)) { if (((flag & V3D_PROJ_TEST_CLIP_NEAR) == 0) || (vec4[3] > (float)BL_NEAR_CLIP)) { const float scalar = (vec4[3] != 0.0f) ? (1.0f / vec4[3]) : 0.0f; - const float fx = ((float)ar->winx / 2.0f) * (1.0f + (vec4[0] * scalar)); - if (((flag & V3D_PROJ_TEST_CLIP_WIN) == 0) || (fx > 0.0f && fx < (float)ar->winx)) { - const float fy = ((float)ar->winy / 2.0f) * (1.0f + (vec4[1] * scalar)); - if (((flag & V3D_PROJ_TEST_CLIP_WIN) == 0) || (fy > 0.0f && fy < (float)ar->winy)) { + const float fx = ((float)region->winx / 2.0f) * (1.0f + (vec4[0] * scalar)); + if (((flag & V3D_PROJ_TEST_CLIP_WIN) == 0) || (fx > 0.0f && fx < (float)region->winx)) { + const float fy = ((float)region->winy / 2.0f) * (1.0f + (vec4[1] * scalar)); + if (((flag & V3D_PROJ_TEST_CLIP_WIN) == 0) || (fy > 0.0f && fy < (float)region->winy)) { r_co[0] = fx; r_co[1] = fy; @@ -174,7 +174,7 @@ static eV3DProjStatus ed_view3d_project__internal(const ARegion *ar, return V3D_PROJ_RET_OK; } -eV3DProjStatus ED_view3d_project_short_ex(const ARegion *ar, +eV3DProjStatus ED_view3d_project_short_ex(const ARegion *region, float perspmat[4][4], const bool is_local, const float co[3], @@ -182,7 +182,7 @@ eV3DProjStatus ED_view3d_project_short_ex(const ARegion *ar, const eV3DProjTest flag) { float tvec[2]; - eV3DProjStatus ret = ed_view3d_project__internal(ar, perspmat, is_local, co, tvec, flag); + eV3DProjStatus ret = ed_view3d_project__internal(region, perspmat, is_local, co, tvec, flag); if (ret == V3D_PROJ_RET_OK) { if ((tvec[0] > -32700.0f && tvec[0] < 32700.0f) && (tvec[1] > -32700.0f && tvec[1] < 32700.0f)) { @@ -196,7 +196,7 @@ eV3DProjStatus ED_view3d_project_short_ex(const ARegion *ar, return ret; } -eV3DProjStatus ED_view3d_project_int_ex(const ARegion *ar, +eV3DProjStatus ED_view3d_project_int_ex(const ARegion *region, float perspmat[4][4], const bool is_local, const float co[3], @@ -204,7 +204,7 @@ eV3DProjStatus ED_view3d_project_int_ex(const ARegion *ar, const eV3DProjTest flag) { float tvec[2]; - eV3DProjStatus ret = ed_view3d_project__internal(ar, perspmat, is_local, co, tvec, flag); + eV3DProjStatus ret = ed_view3d_project__internal(region, perspmat, is_local, co, tvec, flag); if (ret == V3D_PROJ_RET_OK) { if ((tvec[0] > -2140000000.0f && tvec[0] < 2140000000.0f) && (tvec[1] > -2140000000.0f && tvec[1] < 2140000000.0f)) { @@ -218,7 +218,7 @@ eV3DProjStatus ED_view3d_project_int_ex(const ARegion *ar, return ret; } -eV3DProjStatus ED_view3d_project_float_ex(const ARegion *ar, +eV3DProjStatus ED_view3d_project_float_ex(const ARegion *region, float perspmat[4][4], const bool is_local, const float co[3], @@ -226,7 +226,7 @@ eV3DProjStatus ED_view3d_project_float_ex(const ARegion *ar, const eV3DProjTest flag) { float tvec[2]; - eV3DProjStatus ret = ed_view3d_project__internal(ar, perspmat, is_local, co, tvec, flag); + eV3DProjStatus ret = ed_view3d_project__internal(region, perspmat, is_local, co, tvec, flag); if (ret == V3D_PROJ_RET_OK) { if (isfinite(tvec[0]) && isfinite(tvec[1])) { copy_v2_v2(r_co, tvec); @@ -239,63 +239,63 @@ eV3DProjStatus ED_view3d_project_float_ex(const ARegion *ar, } /* --- short --- */ -eV3DProjStatus ED_view3d_project_short_global(const ARegion *ar, +eV3DProjStatus ED_view3d_project_short_global(const ARegion *region, const float co[3], short r_co[2], const eV3DProjTest flag) { - RegionView3D *rv3d = ar->regiondata; - return ED_view3d_project_short_ex(ar, rv3d->persmat, false, co, r_co, flag); + RegionView3D *rv3d = region->regiondata; + return ED_view3d_project_short_ex(region, rv3d->persmat, false, co, r_co, flag); } /* object space, use ED_view3d_init_mats_rv3d before calling */ -eV3DProjStatus ED_view3d_project_short_object(const ARegion *ar, +eV3DProjStatus ED_view3d_project_short_object(const ARegion *region, const float co[3], short r_co[2], const eV3DProjTest flag) { - RegionView3D *rv3d = ar->regiondata; + RegionView3D *rv3d = region->regiondata; ED_view3d_check_mats_rv3d(rv3d); - return ED_view3d_project_short_ex(ar, rv3d->persmatob, true, co, r_co, flag); + return ED_view3d_project_short_ex(region, rv3d->persmatob, true, co, r_co, flag); } /* --- int --- */ -eV3DProjStatus ED_view3d_project_int_global(const ARegion *ar, +eV3DProjStatus ED_view3d_project_int_global(const ARegion *region, const float co[3], int r_co[2], const eV3DProjTest flag) { - RegionView3D *rv3d = ar->regiondata; - return ED_view3d_project_int_ex(ar, rv3d->persmat, false, co, r_co, flag); + RegionView3D *rv3d = region->regiondata; + return ED_view3d_project_int_ex(region, rv3d->persmat, false, co, r_co, flag); } /* object space, use ED_view3d_init_mats_rv3d before calling */ -eV3DProjStatus ED_view3d_project_int_object(const ARegion *ar, +eV3DProjStatus ED_view3d_project_int_object(const ARegion *region, const float co[3], int r_co[2], const eV3DProjTest flag) { - RegionView3D *rv3d = ar->regiondata; + RegionView3D *rv3d = region->regiondata; ED_view3d_check_mats_rv3d(rv3d); - return ED_view3d_project_int_ex(ar, rv3d->persmatob, true, co, r_co, flag); + return ED_view3d_project_int_ex(region, rv3d->persmatob, true, co, r_co, flag); } /* --- float --- */ -eV3DProjStatus ED_view3d_project_float_global(const ARegion *ar, +eV3DProjStatus ED_view3d_project_float_global(const ARegion *region, const float co[3], float r_co[2], const eV3DProjTest flag) { - RegionView3D *rv3d = ar->regiondata; - return ED_view3d_project_float_ex(ar, rv3d->persmat, false, co, r_co, flag); + RegionView3D *rv3d = region->regiondata; + return ED_view3d_project_float_ex(region, rv3d->persmat, false, co, r_co, flag); } /* object space, use ED_view3d_init_mats_rv3d before calling */ -eV3DProjStatus ED_view3d_project_float_object(const ARegion *ar, +eV3DProjStatus ED_view3d_project_float_object(const ARegion *region, const float co[3], float r_co[2], const eV3DProjTest flag) { - RegionView3D *rv3d = ar->regiondata; + RegionView3D *rv3d = region->regiondata; ED_view3d_check_mats_rv3d(rv3d); - return ED_view3d_project_float_ex(ar, rv3d->persmatob, true, co, r_co, flag); + return ED_view3d_project_float_ex(region, rv3d->persmatob, true, co, r_co, flag); } /* More Generic Window/Ray/Vector projection functions @@ -338,7 +338,7 @@ float ED_view3d_calc_zfac(const RegionView3D *rv3d, const float co[3], bool *r_f } static void view3d_win_to_ray_segment(struct Depsgraph *depsgraph, - const ARegion *ar, + const ARegion *region, const View3D *v3d, const float mval[2], float r_ray_co[3], @@ -346,7 +346,7 @@ static void view3d_win_to_ray_segment(struct Depsgraph *depsgraph, float r_ray_start[3], float r_ray_end[3]) { - RegionView3D *rv3d = ar->regiondata; + RegionView3D *rv3d = region->regiondata; float _ray_co[3], _ray_dir[3], start_offset, end_offset; if (!r_ray_co) { @@ -356,8 +356,8 @@ static void view3d_win_to_ray_segment(struct Depsgraph *depsgraph, r_ray_dir = _ray_dir; } - ED_view3d_win_to_origin(ar, mval, r_ray_co); - ED_view3d_win_to_vector(ar, mval, r_ray_dir); + ED_view3d_win_to_origin(region, mval, r_ray_co); + ED_view3d_win_to_vector(region, mval, r_ray_dir); if ((rv3d->is_persp == false) && (rv3d->persp != RV3D_CAMOB)) { end_offset = v3d->clip_end / 2.0f; @@ -391,7 +391,7 @@ bool ED_view3d_clip_segment(const RegionView3D *rv3d, float ray_start[3], float * In orthographic view the resulting ray_normal will match the view vector. * This version also returns the ray_co point of the ray on window plane, useful to fix precision * issues esp. with ortho view, where default ray_start is set rather far away. - * \param ar: The region (used for the window width and height). + * \param region: The region (used for the window width and height). * \param v3d: The 3d viewport (used for near clipping value). * \param mval: The area relative 2d location (such as event->mval, converted into float[2]). * \param r_ray_co: The world-space point where the ray intersects the window plane. @@ -401,7 +401,7 @@ bool ED_view3d_clip_segment(const RegionView3D *rv3d, float ray_start[3], float * \return success, false if the ray is totally clipped. */ bool ED_view3d_win_to_ray_clipped_ex(struct Depsgraph *depsgraph, - const ARegion *ar, + const ARegion *region, const View3D *v3d, const float mval[2], float r_ray_co[3], @@ -412,11 +412,11 @@ bool ED_view3d_win_to_ray_clipped_ex(struct Depsgraph *depsgraph, float ray_end[3]; view3d_win_to_ray_segment( - depsgraph, ar, v3d, mval, r_ray_co, r_ray_normal, r_ray_start, ray_end); + depsgraph, region, v3d, mval, r_ray_co, r_ray_normal, r_ray_start, ray_end); /* bounds clipping */ if (do_clip_planes) { - return ED_view3d_clip_segment(ar->regiondata, r_ray_start, ray_end); + return ED_view3d_clip_segment(region->regiondata, r_ray_start, ray_end); } return true; @@ -427,7 +427,7 @@ bool ED_view3d_win_to_ray_clipped_ex(struct Depsgraph *depsgraph, * This ray_start is located at the viewpoint, ray_normal is the direction towards mval. * ray_start is clipped by the view near limit so points in front of it are always in view. * In orthographic view the resulting ray_normal will match the view vector. - * \param ar: The region (used for the window width and height). + * \param region: The region (used for the window width and height). * \param v3d: The 3d viewport (used for near clipping value). * \param mval: The area relative 2d location (such as event->mval, converted into float[2]). * \param r_ray_start: The world-space point where the ray intersects the window plane. @@ -436,7 +436,7 @@ bool ED_view3d_win_to_ray_clipped_ex(struct Depsgraph *depsgraph, * \return success, false if the ray is totally clipped. */ bool ED_view3d_win_to_ray_clipped(struct Depsgraph *depsgraph, - const ARegion *ar, + const ARegion *region, const View3D *v3d, const float mval[2], float r_ray_start[3], @@ -444,13 +444,13 @@ bool ED_view3d_win_to_ray_clipped(struct Depsgraph *depsgraph, const bool do_clip_planes) { return ED_view3d_win_to_ray_clipped_ex( - depsgraph, ar, v3d, mval, NULL, r_ray_normal, r_ray_start, do_clip_planes); + depsgraph, region, v3d, mval, NULL, r_ray_normal, r_ray_start, do_clip_planes); } /** * Calculate a 3d viewpoint and direction vector from 2d window coordinates. * This ray_start is located at the viewpoint, ray_normal is the direction towards mval. - * \param ar: The region (used for the window width and height). + * \param region: The region (used for the window width and height). * \param mval: The area relative 2d location (such as event->mval, converted into float[2]). * \param r_ray_start: The world-space point where the ray intersects the window plane. * \param r_ray_normal: The normalized world-space direction of towards mval. @@ -458,13 +458,13 @@ bool ED_view3d_win_to_ray_clipped(struct Depsgraph *depsgraph, * \note Ignores view near/far clipping, * to take this into account use #ED_view3d_win_to_ray_clipped. */ -void ED_view3d_win_to_ray(const ARegion *ar, +void ED_view3d_win_to_ray(const ARegion *region, const float mval[2], float r_ray_start[3], float r_ray_normal[3]) { - ED_view3d_win_to_origin(ar, mval, r_ray_start); - ED_view3d_win_to_vector(ar, mval, r_ray_normal); + ED_view3d_win_to_origin(region, mval, r_ray_start); + ED_view3d_win_to_vector(region, mval, r_ray_normal); } /** @@ -499,22 +499,22 @@ void ED_view3d_global_to_vector(const RegionView3D *rv3d, const float coord[3], /* very similar to ED_view3d_win_to_3d() but has no advantage, de-duplicating */ #if 0 -bool view3d_get_view_aligned_coordinate(ARegion *ar, +bool view3d_get_view_aligned_coordinate(ARegion *region, float fp[3], const int mval[2], const bool do_fallback) { - RegionView3D *rv3d = ar->regiondata; + RegionView3D *rv3d = region->regiondata; float dvec[3]; int mval_cpy[2]; eV3DProjStatus ret; - ret = ED_view3d_project_int_global(ar, fp, mval_cpy, V3D_PROJ_TEST_NOP); + ret = ED_view3d_project_int_global(region, fp, mval_cpy, V3D_PROJ_TEST_NOP); if (ret == V3D_PROJ_RET_OK) { const float mval_f[2] = {(float)(mval_cpy[0] - mval[0]), (float)(mval_cpy[1] - mval[1])}; const float zfac = ED_view3d_calc_zfac(rv3d, fp, NULL); - ED_view3d_win_to_delta(ar, mval_f, dvec, zfac); + ED_view3d_win_to_delta(region, mval_f, dvec, zfac); sub_v3_v3(fp, dvec); return true; @@ -523,7 +523,7 @@ bool view3d_get_view_aligned_coordinate(ARegion *ar, /* fallback to the view center */ if (do_fallback) { negate_v3_v3(fp, rv3d->ofs); - return view3d_get_view_aligned_coordinate(ar, fp, mval, false); + return view3d_get_view_aligned_coordinate(region, fp, mval, false); } else { return false; @@ -534,18 +534,18 @@ bool view3d_get_view_aligned_coordinate(ARegion *ar, /** * Calculate a 3d location from 2d window coordinates. - * \param ar: The region (used for the window width and height). + * \param region: The region (used for the window width and height). * \param depth_pt: The reference location used to calculate the Z depth. * \param mval: The area relative location (such as event->mval converted to floats). * \param r_out: The resulting world-space location. */ void ED_view3d_win_to_3d(const View3D *v3d, - const ARegion *ar, + const ARegion *region, const float depth_pt[3], const float mval[2], float r_out[3]) { - RegionView3D *rv3d = ar->regiondata; + RegionView3D *rv3d = region->regiondata; float ray_origin[3]; float ray_direction[3]; @@ -555,7 +555,7 @@ void ED_view3d_win_to_3d(const View3D *v3d, float plane[4]; copy_v3_v3(ray_origin, rv3d->viewinv[3]); - ED_view3d_win_to_vector(ar, mval, ray_direction); + ED_view3d_win_to_vector(region, mval, ray_direction); /* note, we could use isect_line_plane_v3() * however we want the intersection to be infront of the view no matter what, @@ -566,16 +566,16 @@ void ED_view3d_win_to_3d(const View3D *v3d, lambda = fabsf(lambda); } else { - float dx = (2.0f * mval[0] / (float)ar->winx) - 1.0f; - float dy = (2.0f * mval[1] / (float)ar->winy) - 1.0f; + float dx = (2.0f * mval[0] / (float)region->winx) - 1.0f; + float dy = (2.0f * mval[1] / (float)region->winy) - 1.0f; if (rv3d->persp == RV3D_CAMOB) { /* ortho camera needs offset applied */ const Camera *cam = v3d->camera->data; - const int sensor_fit = BKE_camera_sensor_fit(cam->sensor_fit, ar->winx, ar->winy); + const int sensor_fit = BKE_camera_sensor_fit(cam->sensor_fit, region->winx, region->winy); const float zoomfac = BKE_screen_view3d_zoom_to_fac(rv3d->camzoom) * 4.0f; - const float aspx = ar->winx / (float)ar->winy; - const float aspy = ar->winy / (float)ar->winx; + const float aspx = region->winx / (float)region->winy; + const float aspy = region->winy / (float)region->winx; const float shiftx = cam->shiftx * 0.5f * (sensor_fit == CAMERA_SENSOR_FIT_HOR ? 1.0f : aspy); const float shifty = cam->shifty * 0.5f * @@ -596,24 +596,24 @@ void ED_view3d_win_to_3d(const View3D *v3d, } void ED_view3d_win_to_3d_int(const View3D *v3d, - const ARegion *ar, + const ARegion *region, const float depth_pt[3], const int mval[2], float r_out[3]) { const float mval_fl[2] = {mval[0], mval[1]}; - ED_view3d_win_to_3d(v3d, ar, depth_pt, mval_fl, r_out); + ED_view3d_win_to_3d(v3d, region, depth_pt, mval_fl, r_out); } -bool ED_view3d_win_to_3d_on_plane(const ARegion *ar, +bool ED_view3d_win_to_3d_on_plane(const ARegion *region, const float plane[4], const float mval[2], const bool do_clip, float r_out[3]) { float ray_co[3], ray_no[3]; - ED_view3d_win_to_origin(ar, mval, ray_co); - ED_view3d_win_to_vector(ar, mval, ray_no); + ED_view3d_win_to_origin(region, mval, ray_co); + ED_view3d_win_to_vector(region, mval, ray_no); float lambda; if (isect_ray_plane_v3(ray_co, ray_no, plane, &lambda, do_clip)) { madd_v3_v3v3fl(r_out, ray_co, ray_no, lambda); @@ -622,28 +622,34 @@ bool ED_view3d_win_to_3d_on_plane(const ARegion *ar, return false; } -bool ED_view3d_win_to_3d_on_plane_int( - const ARegion *ar, const float plane[4], const int mval[2], const bool do_clip, float r_out[3]) +bool ED_view3d_win_to_3d_on_plane_int(const ARegion *region, + const float plane[4], + const int mval[2], + const bool do_clip, + float r_out[3]) { const float mval_fl[2] = {mval[0], mval[1]}; - return ED_view3d_win_to_3d_on_plane(ar, plane, mval_fl, do_clip, r_out); + return ED_view3d_win_to_3d_on_plane(region, plane, mval_fl, do_clip, r_out); } /** * Calculate a 3d difference vector from 2d window offset. * note that #ED_view3d_calc_zfac() must be called first to determine * the depth used to calculate the delta. - * \param ar: The region (used for the window width and height). + * \param region: The region (used for the window width and height). * \param mval: The area relative 2d difference (such as event->mval[0] - other_x). * \param out: The resulting world-space delta. */ -void ED_view3d_win_to_delta(const ARegion *ar, const float mval[2], float out[3], const float zfac) +void ED_view3d_win_to_delta(const ARegion *region, + const float mval[2], + float out[3], + const float zfac) { - RegionView3D *rv3d = ar->regiondata; + RegionView3D *rv3d = region->regiondata; float dx, dy; - dx = 2.0f * mval[0] * zfac / ar->winx; - dy = 2.0f * mval[1] * zfac / ar->winy; + dx = 2.0f * mval[0] * zfac / region->winx; + dy = 2.0f * mval[1] * zfac / region->winy; out[0] = (rv3d->persinv[0][0] * dx + rv3d->persinv[1][0] * dy); out[1] = (rv3d->persinv[0][1] * dx + rv3d->persinv[1][1] * dy); @@ -656,19 +662,19 @@ void ED_view3d_win_to_delta(const ARegion *ar, const float mval[2], float out[3] * Since far clip can be a very large value resulting in numeric precision issues, * the origin in this case is close to zero coordinate. * - * \param ar: The region (used for the window width and height). + * \param region: The region (used for the window width and height). * \param mval: The area relative 2d location (such as event->mval converted to floats). * \param out: The resulting normalized world-space direction vector. */ -void ED_view3d_win_to_origin(const ARegion *ar, const float mval[2], float out[3]) +void ED_view3d_win_to_origin(const ARegion *region, const float mval[2], float out[3]) { - RegionView3D *rv3d = ar->regiondata; + RegionView3D *rv3d = region->regiondata; if (rv3d->is_persp) { copy_v3_v3(out, rv3d->viewinv[3]); } else { - out[0] = 2.0f * mval[0] / ar->winx - 1.0f; - out[1] = 2.0f * mval[1] / ar->winy - 1.0f; + out[0] = 2.0f * mval[0] / region->winx - 1.0f; + out[1] = 2.0f * mval[1] / region->winy - 1.0f; if (rv3d->persp == RV3D_CAMOB) { out[2] = -1.0f; @@ -690,17 +696,17 @@ void ED_view3d_win_to_origin(const ARegion *ar, const float mval[2], float out[3 * for perspective view, get the vector direction to * the mouse cursor as a normalized vector. * - * \param ar: The region (used for the window width and height). + * \param region: The region (used for the window width and height). * \param mval: The area relative 2d location (such as event->mval converted to floats). * \param out: The resulting normalized world-space direction vector. */ -void ED_view3d_win_to_vector(const ARegion *ar, const float mval[2], float out[3]) +void ED_view3d_win_to_vector(const ARegion *region, const float mval[2], float out[3]) { - RegionView3D *rv3d = ar->regiondata; + RegionView3D *rv3d = region->regiondata; if (rv3d->is_persp) { - out[0] = 2.0f * (mval[0] / ar->winx) - 1.0f; - out[1] = 2.0f * (mval[1] / ar->winy) - 1.0f; + out[0] = 2.0f * (mval[0] / region->winx) - 1.0f; + out[1] = 2.0f * (mval[1] / region->winy) - 1.0f; out[2] = -0.5f; mul_project_m4_v3(rv3d->persinv, out); sub_v3_v3(out, rv3d->viewinv[3]); @@ -717,7 +723,7 @@ void ED_view3d_win_to_vector(const ARegion *ar, const float mval[2], float out[3 * ray_start and ray_end are clipped by the view near and far limits * so points along this line are always in view. * In orthographic view all resulting segments will be parallel. - * \param ar: The region (used for the window width and height). + * \param region: The region (used for the window width and height). * \param v3d: The 3d viewport (used for near and far clipping range). * \param mval: The area relative 2d location (such as event->mval, converted into float[2]). * \param r_ray_start: The world-space starting point of the segment. @@ -726,18 +732,18 @@ void ED_view3d_win_to_vector(const ARegion *ar, const float mval[2], float out[3 * \return success, false if the segment is totally clipped. */ bool ED_view3d_win_to_segment_clipped(struct Depsgraph *depsgraph, - const ARegion *ar, + const ARegion *region, View3D *v3d, const float mval[2], float r_ray_start[3], float r_ray_end[3], const bool do_clip_planes) { - view3d_win_to_ray_segment(depsgraph, ar, v3d, mval, NULL, NULL, r_ray_start, r_ray_end); + view3d_win_to_ray_segment(depsgraph, region, v3d, mval, NULL, NULL, r_ray_start, r_ray_end); /* bounds clipping */ if (do_clip_planes) { - return ED_view3d_clip_segment((RegionView3D *)ar->regiondata, r_ray_start, r_ray_end); + return ED_view3d_clip_segment((RegionView3D *)region->regiondata, r_ray_start, r_ray_end); } return true; @@ -767,21 +773,21 @@ void ED_view3d_ob_project_mat_get_from_obmat(const RegionView3D *rv3d, /** * Convert between region relative coordinates (x,y) and depth component z and * a point in world space. */ -void ED_view3d_project(const struct ARegion *ar, const float world[3], float region[3]) +void ED_view3d_project(const struct ARegion *region, const float world[3], float r_region_co[3]) { // viewport is set up to make coordinates relative to the region, not window - RegionView3D *rv3d = ar->regiondata; - int viewport[4] = {0, 0, ar->winx, ar->winy}; + RegionView3D *rv3d = region->regiondata; + int viewport[4] = {0, 0, region->winx, region->winy}; - GPU_matrix_project(world, rv3d->viewmat, rv3d->winmat, viewport, region); + GPU_matrix_project(world, rv3d->viewmat, rv3d->winmat, viewport, r_region_co); } bool ED_view3d_unproject( - const struct ARegion *ar, float regionx, float regiony, float regionz, float world[3]) + const struct ARegion *region, float regionx, float regiony, float regionz, float world[3]) { - RegionView3D *rv3d = ar->regiondata; - int viewport[4] = {0, 0, ar->winx, ar->winy}; - float region[3] = {regionx, regiony, regionz}; + RegionView3D *rv3d = region->regiondata; + int viewport[4] = {0, 0, region->winx, region->winy}; + float region_co[3] = {regionx, regiony, regionz}; - return GPU_matrix_unproject(region, rv3d->viewmat, rv3d->winmat, viewport, world); + return GPU_matrix_unproject(region_co, rv3d->viewmat, rv3d->winmat, viewport, world); } diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 89baf60bd8c..7649bd45a1a 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -124,7 +124,7 @@ void ED_view3d_viewcontext_init(bContext *C, ViewContext *vc, Depsgraph *depsgra { memset(vc, 0, sizeof(ViewContext)); vc->C = C; - vc->ar = CTX_wm_region(C); + vc->region = CTX_wm_region(C); vc->bmain = CTX_data_main(C); vc->depsgraph = depsgraph; vc->scene = CTX_data_scene(C); @@ -589,7 +589,7 @@ static bool do_lasso_select_objects(ViewContext *vc, for (base = vc->view_layer->object_bases.first; base; base = base->next) { if (BASE_SELECTABLE(v3d, base)) { /* use this to avoid un-needed lasso lookups */ const bool is_select = base->flag & BASE_SELECTED; - const bool is_inside = ((ED_view3d_project_base(vc->ar, base) == V3D_PROJ_RET_OK) && + const bool is_inside = ((ED_view3d_project_base(vc->region, base) == V3D_PROJ_RET_OK) && BLI_lasso_is_point_inside( mcords, moves, base->sx, base->sy, IS_CLIPPED)); const int sel_op_result = ED_select_op_action_deselected(sel_op, is_select, is_inside); @@ -836,7 +836,7 @@ static bool do_lasso_select_mesh(ViewContext *vc, editselect_buf_cache_init_with_generic_userdata(wm_userdata, vc, ts->selectmode); esel = wm_userdata->data; esel->select_bitmap = DRW_select_buffer_bitmap_from_poly( - vc->depsgraph, vc->ar, vc->v3d, mcords, moves, &rect, NULL); + vc->depsgraph, vc->region, vc->v3d, mcords, moves, &rect, NULL); } } @@ -1151,7 +1151,7 @@ static bool do_lasso_select_paintvert(ViewContext *vc, editselect_buf_cache_init_with_generic_userdata(wm_userdata, vc, SCE_SELECT_VERTEX); esel = wm_userdata->data; esel->select_bitmap = DRW_select_buffer_bitmap_from_poly( - vc->depsgraph, vc->ar, vc->v3d, mcords, moves, &rect, NULL); + vc->depsgraph, vc->region, vc->v3d, mcords, moves, &rect, NULL); } } @@ -1210,7 +1210,7 @@ static bool do_lasso_select_paintface(ViewContext *vc, editselect_buf_cache_init_with_generic_userdata(wm_userdata, vc, SCE_SELECT_FACE); esel = wm_userdata->data; esel->select_bitmap = DRW_select_buffer_bitmap_from_poly( - vc->depsgraph, vc->ar, vc->v3d, mcords, moves, &rect, NULL); + vc->depsgraph, vc->region, vc->v3d, mcords, moves, &rect, NULL); } if (esel->select_bitmap) { @@ -1566,7 +1566,7 @@ static Base *object_mouse_select_menu(bContext *C, } else { const int dist = 15 * U.pixelsize; - if (ED_view3d_project_base(vc->ar, base) == V3D_PROJ_RET_OK) { + if (ED_view3d_project_base(vc->region, base) == V3D_PROJ_RET_OK) { const int delta_px[2] = {base->sx - mval[0], base->sy - mval[1]}; if (len_manhattan_v2_int(delta_px) < dist) { ok = true; @@ -1971,7 +1971,7 @@ static bool ed_object_select_pick(bContext *C, /* setup view context for argument to callbacks */ ED_view3d_viewcontext_init(C, &vc, depsgraph); - ARegion *ar = CTX_wm_region(C); + ARegion *region = CTX_wm_region(C); Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); View3D *v3d = CTX_wm_view3d(C); @@ -2015,7 +2015,7 @@ static bool ed_object_select_pick(bContext *C, while (base) { if (BASE_SELECTABLE(v3d, base)) { float screen_co[2]; - if (ED_view3d_project_float_global(ar, + if (ED_view3d_project_float_global(region, base->object->obmat[3], screen_co, V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN | @@ -2600,7 +2600,7 @@ static bool do_paintvert_box_select(ViewContext *vc, editselect_buf_cache_init_with_generic_userdata(wm_userdata, vc, SCE_SELECT_VERTEX); esel = wm_userdata->data; esel->select_bitmap = DRW_select_buffer_bitmap_from_rect( - vc->depsgraph, vc->ar, vc->v3d, rect, NULL); + vc->depsgraph, vc->region, vc->v3d, rect, NULL); } if (esel->select_bitmap != NULL) { changed |= edbm_backbuf_check_and_select_verts_obmode(me, esel, sel_op); @@ -2655,7 +2655,7 @@ static bool do_paintface_box_select(ViewContext *vc, editselect_buf_cache_init_with_generic_userdata(wm_userdata, vc, SCE_SELECT_FACE); esel = wm_userdata->data; esel->select_bitmap = DRW_select_buffer_bitmap_from_rect( - vc->depsgraph, vc->ar, vc->v3d, rect, NULL); + vc->depsgraph, vc->region, vc->v3d, rect, NULL); } if (esel->select_bitmap != NULL) { changed |= edbm_backbuf_check_and_select_faces_obmode(me, esel, sel_op); @@ -2857,7 +2857,7 @@ static bool do_mesh_box_select(ViewContext *vc, editselect_buf_cache_init_with_generic_userdata(wm_userdata, vc, ts->selectmode); esel = wm_userdata->data; esel->select_bitmap = DRW_select_buffer_bitmap_from_rect( - vc->depsgraph, vc->ar, vc->v3d, rect, NULL); + vc->depsgraph, vc->region, vc->v3d, rect, NULL); } } @@ -3456,7 +3456,7 @@ static bool mesh_circle_select(ViewContext *vc, if (use_zbuf) { if (esel->select_bitmap == NULL) { esel->select_bitmap = DRW_select_buffer_bitmap_from_circle( - vc->depsgraph, vc->ar, vc->v3d, mval, (int)(rad + 1.0f), NULL); + vc->depsgraph, vc->region, vc->v3d, mval, (int)(rad + 1.0f), NULL); } } @@ -3528,7 +3528,7 @@ static bool paint_facesel_circle_select(ViewContext *vc, { struct EditSelectBuf_Cache *esel = wm_userdata->data; esel->select_bitmap = DRW_select_buffer_bitmap_from_circle( - vc->depsgraph, vc->ar, vc->v3d, mval, (int)(rad + 1.0f), NULL); + vc->depsgraph, vc->region, vc->v3d, mval, (int)(rad + 1.0f), NULL); if (esel->select_bitmap != NULL) { changed |= edbm_backbuf_check_and_select_faces_obmode(me, esel, sel_op); MEM_freeN(esel->select_bitmap); @@ -3583,7 +3583,7 @@ static bool paint_vertsel_circle_select(ViewContext *vc, if (use_zbuf) { struct EditSelectBuf_Cache *esel = wm_userdata->data; esel->select_bitmap = DRW_select_buffer_bitmap_from_circle( - vc->depsgraph, vc->ar, vc->v3d, mval, (int)(rad + 1.0f), NULL); + vc->depsgraph, vc->region, vc->v3d, mval, (int)(rad + 1.0f), NULL); if (esel->select_bitmap != NULL) { changed |= edbm_backbuf_check_and_select_verts_obmode(me, esel, sel_op); MEM_freeN(esel->select_bitmap); @@ -3999,7 +3999,7 @@ static bool object_circle_select(ViewContext *vc, for (base = FIRSTBASE(view_layer); base; base = base->next) { if (BASE_SELECTABLE(v3d, base) && ((base->flag & BASE_SELECTED) != select_flag)) { float screen_co[2]; - if (ED_view3d_project_float_global(vc->ar, + if (ED_view3d_project_float_global(vc->region, base->object->obmat[3], screen_co, V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN | diff --git a/source/blender/editors/space_view3d/view3d_utils.c b/source/blender/editors/space_view3d/view3d_utils.c index 08a4947dc18..f6ec5c93e7f 100644 --- a/source/blender/editors/space_view3d/view3d_utils.c +++ b/source/blender/editors/space_view3d/view3d_utils.c @@ -181,21 +181,21 @@ bool ED_view3d_viewplane_get(Depsgraph *depsgraph, void view3d_operator_needs_opengl(const bContext *C) { wmWindow *win = CTX_wm_window(C); - ARegion *ar = CTX_wm_region(C); + ARegion *region = CTX_wm_region(C); - view3d_region_operator_needs_opengl(win, ar); + view3d_region_operator_needs_opengl(win, region); } -void view3d_region_operator_needs_opengl(wmWindow *UNUSED(win), ARegion *ar) +void view3d_region_operator_needs_opengl(wmWindow *UNUSED(win), ARegion *region) { /* for debugging purpose, context should always be OK */ - if ((ar == NULL) || (ar->regiontype != RGN_TYPE_WINDOW)) { + if ((region == NULL) || (region->regiontype != RGN_TYPE_WINDOW)) { printf("view3d_region_operator_needs_opengl error, wrong region\n"); } else { - RegionView3D *rv3d = ar->regiondata; + RegionView3D *rv3d = region->regiondata; - wmViewport(&ar->winrct); // TODO: bad + wmViewport(®ion->winrct); // TODO: bad GPU_matrix_projection_set(rv3d->winmat); GPU_matrix_set(rv3d->viewmat); } @@ -230,7 +230,7 @@ bool ED_view3d_context_activate(bContext *C) { bScreen *sc = CTX_wm_screen(C); ScrArea *sa = CTX_wm_area(C); - ARegion *ar; + ARegion *region; /* sa can be NULL when called from python */ if (sa == NULL || sa->spacetype != SPACE_VIEW3D) { @@ -241,14 +241,14 @@ bool ED_view3d_context_activate(bContext *C) return false; } - ar = BKE_area_find_region_active_win(sa); - if (ar == NULL) { + region = BKE_area_find_region_active_win(sa); + if (region == NULL) { return false; } /* bad context switch .. */ CTX_wm_area_set(C, sa); - CTX_wm_region_set(C, ar); + CTX_wm_region_set(C, region); return true; } @@ -277,7 +277,7 @@ void ED_view3d_clipping_calc_from_boundbox(float clip[4][4], } void ED_view3d_clipping_calc( - BoundBox *bb, float planes[4][4], const ARegion *ar, const Object *ob, const rcti *rect) + BoundBox *bb, float planes[4][4], const ARegion *region, const Object *ob, const rcti *rect) { /* init in case unproject fails */ memset(bb->vec, 0, sizeof(bb->vec)); @@ -288,8 +288,8 @@ void ED_view3d_clipping_calc( float xs = (val == 0 || val == 3) ? rect->xmin : rect->xmax; float ys = (val == 0 || val == 1) ? rect->ymin : rect->ymax; - ED_view3d_unproject(ar, xs, ys, 0.0, bb->vec[val]); - ED_view3d_unproject(ar, xs, ys, 1.0, bb->vec[4 + val]); + ED_view3d_unproject(region, xs, ys, 0.0, bb->vec[val]); + ED_view3d_unproject(region, xs, ys, 1.0, bb->vec[4 + val]); } /* optionally transform to object space */ @@ -453,9 +453,9 @@ void ED_view3d_persp_switch_from_camera(const Depsgraph *depsgraph, * * shared with NDOF. */ -bool ED_view3d_persp_ensure(const Depsgraph *depsgraph, View3D *v3d, ARegion *ar) +bool ED_view3d_persp_ensure(const Depsgraph *depsgraph, View3D *v3d, ARegion *region) { - RegionView3D *rv3d = ar->regiondata; + RegionView3D *rv3d = region->regiondata; const bool autopersp = (U.uiflag & USER_AUTOPERSP) != 0; BLI_assert((rv3d->viewlock & RV3D_LOCKED) == 0); @@ -664,28 +664,28 @@ bool ED_view3d_camera_lock_autokey(View3D *v3d, static void view3d_boxview_clip(ScrArea *sa) { - ARegion *ar; + ARegion *region; BoundBox *bb = MEM_callocN(sizeof(BoundBox), "clipbb"); float clip[6][4]; float x1 = 0.0f, y1 = 0.0f, z1 = 0.0f, ofs[3] = {0.0f, 0.0f, 0.0f}; int val; /* create bounding box */ - for (ar = sa->regionbase.first; ar; ar = ar->next) { - if (ar->regiontype == RGN_TYPE_WINDOW) { - RegionView3D *rv3d = ar->regiondata; + for (region = sa->regionbase.first; region; region = region->next) { + if (region->regiontype == RGN_TYPE_WINDOW) { + RegionView3D *rv3d = region->regiondata; if (rv3d->viewlock & RV3D_BOXCLIP) { if (ELEM(rv3d->view, RV3D_VIEW_TOP, RV3D_VIEW_BOTTOM)) { - if (ar->winx > ar->winy) { + if (region->winx > region->winy) { x1 = rv3d->dist; } else { - x1 = ar->winx * rv3d->dist / ar->winy; + x1 = region->winx * rv3d->dist / region->winy; } - if (ar->winx > ar->winy) { - y1 = ar->winy * rv3d->dist / ar->winx; + if (region->winx > region->winy) { + y1 = region->winy * rv3d->dist / region->winx; } else { y1 = rv3d->dist; @@ -695,8 +695,8 @@ static void view3d_boxview_clip(ScrArea *sa) else if (ELEM(rv3d->view, RV3D_VIEW_FRONT, RV3D_VIEW_BACK)) { ofs[2] = rv3d->ofs[2]; - if (ar->winx > ar->winy) { - z1 = ar->winy * rv3d->dist / ar->winx; + if (region->winx > region->winy) { + z1 = region->winy * rv3d->dist / region->winx; } else { z1 = rv3d->dist; @@ -743,9 +743,9 @@ static void view3d_boxview_clip(ScrArea *sa) } /* create bounding box */ - for (ar = sa->regionbase.first; ar; ar = ar->next) { - if (ar->regiontype == RGN_TYPE_WINDOW) { - RegionView3D *rv3d = ar->regiondata; + for (region = sa->regionbase.first; region; region = region->next) { + if (region->regiontype == RGN_TYPE_WINDOW) { + RegionView3D *rv3d = region->regiondata; if (rv3d->viewlock & RV3D_BOXCLIP) { rv3d->rflag |= RV3D_CLIPPING; @@ -808,14 +808,14 @@ static void view3d_boxview_sync_axis(RegionView3D *rv3d_dst, RegionView3D *rv3d_ } /* sync center/zoom view of region to others, for view transforms */ -void view3d_boxview_sync(ScrArea *sa, ARegion *ar) +void view3d_boxview_sync(ScrArea *sa, ARegion *region) { ARegion *artest; - RegionView3D *rv3d = ar->regiondata; + RegionView3D *rv3d = region->regiondata; short clip = 0; for (artest = sa->regionbase.first; artest; artest = artest->next) { - if (artest != ar && artest->regiontype == RGN_TYPE_WINDOW) { + if (artest != region && artest->regiontype == RGN_TYPE_WINDOW) { RegionView3D *rv3dtest = artest->regiondata; if (rv3dtest->viewlock & RV3D_LOCKED) { @@ -834,14 +834,14 @@ void view3d_boxview_sync(ScrArea *sa, ARegion *ar) } /* for home, center etc */ -void view3d_boxview_copy(ScrArea *sa, ARegion *ar) +void view3d_boxview_copy(ScrArea *sa, ARegion *region) { ARegion *artest; - RegionView3D *rv3d = ar->regiondata; + RegionView3D *rv3d = region->regiondata; bool clip = false; for (artest = sa->regionbase.first; artest; artest = artest->next) { - if (artest != ar && artest->regiontype == RGN_TYPE_WINDOW) { + if (artest != region && artest->regiontype == RGN_TYPE_WINDOW) { RegionView3D *rv3dtest = artest->regiondata; if (rv3dtest->viewlock) { @@ -860,10 +860,10 @@ void view3d_boxview_copy(ScrArea *sa, ARegion *ar) } /* 'clip' is used to know if our clip setting has changed */ -void ED_view3d_quadview_update(ScrArea *sa, ARegion *ar, bool do_clip) +void ED_view3d_quadview_update(ScrArea *sa, ARegion *region, bool do_clip) { ARegion *ar_sync = NULL; - RegionView3D *rv3d = ar->regiondata; + RegionView3D *rv3d = region->regiondata; short viewlock; /* this function copies flags from the first of the 3 other quadview * regions to the 2 other, so it assumes this is the region whose @@ -879,9 +879,9 @@ void ED_view3d_quadview_update(ScrArea *sa, ARegion *ar, bool do_clip) viewlock &= ~RV3D_BOXCLIP; } - for (; ar; ar = ar->prev) { - if (ar->alignment == RGN_ALIGN_QSPLIT) { - rv3d = ar->regiondata; + for (; region; region = region->prev) { + if (region->alignment == RGN_ALIGN_QSPLIT) { + rv3d = region->regiondata; rv3d->viewlock = viewlock; if (do_clip && (viewlock & RV3D_BOXCLIP) == 0) { @@ -891,7 +891,7 @@ void ED_view3d_quadview_update(ScrArea *sa, ARegion *ar, bool do_clip) /* use ar_sync so we sync with one of the aligned views below * else the view jumps on changing view settings like 'clip' * since it copies from the perspective view */ - ar_sync = ar; + ar_sync = region; } } @@ -902,9 +902,9 @@ void ED_view3d_quadview_update(ScrArea *sa, ARegion *ar, bool do_clip) /* ensure locked regions have an axis, locked user views don't make much sense */ if (viewlock & RV3D_LOCKED) { int index_qsplit = 0; - for (ar = sa->regionbase.first; ar; ar = ar->next) { - if (ar->alignment == RGN_ALIGN_QSPLIT) { - rv3d = ar->regiondata; + for (region = sa->regionbase.first; region; region = region->next) { + if (region->alignment == RGN_ALIGN_QSPLIT) { + rv3d = region->regiondata; if (rv3d->viewlock) { if (!RV3D_VIEW_IS_AXIS(rv3d->view) || (rv3d->view_axis_roll != RV3D_VIEW_AXIS_ROLL_0)) { rv3d->view = ED_view3d_lock_view_from_index(index_qsplit); @@ -927,7 +927,7 @@ void ED_view3d_quadview_update(ScrArea *sa, ARegion *ar, bool do_clip) /** \name View Auto-Depth Utilities * \{ */ -static float view_autodist_depth_margin(ARegion *ar, const int mval[2], int margin) +static float view_autodist_depth_margin(ARegion *region, const int mval[2], int margin) { ViewDepths depth_temp = {0}; rcti rect; @@ -944,7 +944,7 @@ static float view_autodist_depth_margin(ARegion *ar, const int mval[2], int marg BLI_rcti_init_pt_radius(&rect, mval, margin); } - view3d_update_depths_rect(ar, &depth_temp, &rect); + view3d_update_depths_rect(region, &depth_temp, &rect); depth_close = view3d_depth_near(&depth_temp); MEM_SAFE_FREE(depth_temp.depths); return depth_close; @@ -958,7 +958,7 @@ static float view_autodist_depth_margin(ARegion *ar, const int mval[2], int marg * \param fallback_depth_pt: Use this points depth when no depth can be found. */ bool ED_view3d_autodist(Depsgraph *depsgraph, - ARegion *ar, + ARegion *region, View3D *v3d, const int mval[2], float mouse_worldloc[3], @@ -971,12 +971,12 @@ bool ED_view3d_autodist(Depsgraph *depsgraph, bool depth_ok = false; /* Get Z Depths, needed for perspective, nice for ortho */ - ED_view3d_draw_depth(depsgraph, ar, v3d, alphaoverride); + ED_view3d_draw_depth(depsgraph, region, v3d, alphaoverride); /* Attempt with low margin's first */ i = 0; do { - depth_close = view_autodist_depth_margin(ar, mval, margin_arr[i++] * U.pixelsize); + depth_close = view_autodist_depth_margin(region, mval, margin_arr[i++] * U.pixelsize); depth_ok = (depth_close != FLT_MAX); } while ((depth_ok == false) && (i < ARRAY_SIZE(margin_arr))); @@ -984,13 +984,13 @@ bool ED_view3d_autodist(Depsgraph *depsgraph, float centx = (float)mval[0] + 0.5f; float centy = (float)mval[1] + 0.5f; - if (ED_view3d_unproject(ar, centx, centy, depth_close, mouse_worldloc)) { + if (ED_view3d_unproject(region, centx, centy, depth_close, mouse_worldloc)) { return true; } } if (fallback_depth_pt) { - ED_view3d_win_to_3d_int(v3d, ar, fallback_depth_pt, mval, mouse_worldloc); + ED_view3d_win_to_3d_int(v3d, region, fallback_depth_pt, mval, mouse_worldloc); return true; } else { @@ -998,16 +998,16 @@ bool ED_view3d_autodist(Depsgraph *depsgraph, } } -void ED_view3d_autodist_init(Depsgraph *depsgraph, ARegion *ar, View3D *v3d, int mode) +void ED_view3d_autodist_init(Depsgraph *depsgraph, ARegion *region, View3D *v3d, int mode) { /* Get Z Depths, needed for perspective, nice for ortho */ switch (mode) { case 0: - ED_view3d_draw_depth(depsgraph, ar, v3d, true); + ED_view3d_draw_depth(depsgraph, region, v3d, true); break; case 1: { Scene *scene = DEG_get_evaluated_scene(depsgraph); - ED_view3d_draw_depth_gpencil(depsgraph, scene, ar, v3d); + ED_view3d_draw_depth_gpencil(depsgraph, scene, region, v3d); break; } } @@ -1015,7 +1015,7 @@ void ED_view3d_autodist_init(Depsgraph *depsgraph, ARegion *ar, View3D *v3d, int /* no 4x4 sampling, run #ED_view3d_autodist_init first */ bool ED_view3d_autodist_simple( - ARegion *ar, const int mval[2], float mouse_worldloc[3], int margin, float *force_depth) + ARegion *region, const int mval[2], float mouse_worldloc[3], int margin, float *force_depth) { float depth; @@ -1024,7 +1024,7 @@ bool ED_view3d_autodist_simple( depth = *force_depth; } else { - depth = view_autodist_depth_margin(ar, mval, margin); + depth = view_autodist_depth_margin(region, mval, margin); } if (depth == FLT_MAX) { @@ -1033,12 +1033,12 @@ bool ED_view3d_autodist_simple( float centx = (float)mval[0] + 0.5f; float centy = (float)mval[1] + 0.5f; - return ED_view3d_unproject(ar, centx, centy, depth, mouse_worldloc); + return ED_view3d_unproject(region, centx, centy, depth, mouse_worldloc); } -bool ED_view3d_autodist_depth(ARegion *ar, const int mval[2], int margin, float *depth) +bool ED_view3d_autodist_depth(ARegion *region, const int mval[2], int margin, float *depth) { - *depth = view_autodist_depth_margin(ar, mval, margin); + *depth = view_autodist_depth_margin(region, mval, margin); return (*depth != FLT_MAX); } @@ -1046,7 +1046,7 @@ bool ED_view3d_autodist_depth(ARegion *ar, const int mval[2], int margin, float static bool depth_segment_cb(int x, int y, void *userData) { struct { - ARegion *ar; + ARegion *region; int margin; float depth; } *data = userData; @@ -1056,7 +1056,7 @@ static bool depth_segment_cb(int x, int y, void *userData) mval[0] = x; mval[1] = y; - depth = view_autodist_depth_margin(data->ar, mval, data->margin); + depth = view_autodist_depth_margin(data->region, mval, data->margin); if (depth != FLT_MAX) { data->depth = depth; @@ -1068,17 +1068,17 @@ static bool depth_segment_cb(int x, int y, void *userData) } bool ED_view3d_autodist_depth_seg( - ARegion *ar, const int mval_sta[2], const int mval_end[2], int margin, float *depth) + ARegion *region, const int mval_sta[2], const int mval_end[2], int margin, float *depth) { struct { - ARegion *ar; + ARegion *region; int margin; float depth; } data = {NULL}; int p1[2]; int p2[2]; - data.ar = ar; + data.region = region; data.margin = margin; data.depth = FLT_MAX; @@ -1129,14 +1129,14 @@ float ED_view3d_radius_to_dist_ortho(const float lens, const float radius) * + * </pre> * - * \param ar: Can be NULL if \a use_aspect is false. + * \param region: Can be NULL if \a use_aspect is false. * \param persp: Allow the caller to tell what kind of perspective to use (ortho/view/camera) * \param use_aspect: Increase the distance to account for non 1:1 view aspect. * \param radius: The radius will be fitted exactly, * typically pre-scaled by a margin (#VIEW3D_MARGIN). */ float ED_view3d_radius_to_dist(const View3D *v3d, - const ARegion *ar, + const ARegion *region, const struct Depsgraph *depsgraph, const char persp, const bool use_aspect, @@ -1184,18 +1184,18 @@ float ED_view3d_radius_to_dist(const View3D *v3d, } if (use_aspect) { - const RegionView3D *rv3d = ar->regiondata; + const RegionView3D *rv3d = region->regiondata; float winx, winy; if (persp == RV3D_CAMOB) { /* camera frame x/y in pixels */ - winx = ar->winx / rv3d->viewcamtexcofac[0]; - winy = ar->winy / rv3d->viewcamtexcofac[1]; + winx = region->winx / rv3d->viewcamtexcofac[0]; + winy = region->winy / rv3d->viewcamtexcofac[1]; } else { - winx = ar->winx; - winy = ar->winy; + winx = region->winx; + winy = region->winy; } if (winx && winy) { @@ -1568,7 +1568,7 @@ bool ED_view3d_depth_read_cached_normal(const ViewContext *vc, bool depths_valid[9] = {false}; float coords[9][3] = {{0}}; - ARegion *ar = vc->ar; + ARegion *region = vc->region; const ViewDepths *depths = vc->rv3d->depths; for (int x = 0, i = 0; x < 2; x++) { @@ -1577,7 +1577,7 @@ bool ED_view3d_depth_read_cached_normal(const ViewContext *vc, const double depth = (double)ED_view3d_depth_read_cached(vc, mval_ofs); if ((depth > depths->depth_range[0]) && (depth < depths->depth_range[1])) { - if (ED_view3d_depth_unproject(ar, mval_ofs, depth, coords[i])) { + if (ED_view3d_depth_unproject(region, mval_ofs, depth, coords[i])) { depths_valid[i] = true; } } @@ -1614,14 +1614,14 @@ bool ED_view3d_depth_read_cached_normal(const ViewContext *vc, } } -bool ED_view3d_depth_unproject(const ARegion *ar, +bool ED_view3d_depth_unproject(const ARegion *region, const int mval[2], const double depth, float r_location_world[3]) { float centx = (float)mval[0] + 0.5f; float centy = (float)mval[1] + 0.5f; - return ED_view3d_unproject(ar, centx, centy, depth, r_location_world); + return ED_view3d_unproject(region, centx, centy, depth, r_location_world); } void ED_view3d_depth_tag_update(RegionView3D *rv3d) diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 4658198e4e1..9b0c987c451 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -129,11 +129,11 @@ void ED_view3d_smooth_view_ex( wmWindow *win, ScrArea *sa, View3D *v3d, - ARegion *ar, + ARegion *region, const int smooth_viewtx, const V3D_SmoothParams *sview) { - RegionView3D *rv3d = ar->regiondata; + RegionView3D *rv3d = region->regiondata; struct SmoothView3DStore sms = {{0}}; bool ok = false; @@ -292,16 +292,16 @@ void ED_view3d_smooth_view_ex( } if (rv3d->viewlock & RV3D_BOXVIEW) { - view3d_boxview_copy(sa, ar); + view3d_boxview_copy(sa, region); } - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); } } void ED_view3d_smooth_view(bContext *C, View3D *v3d, - ARegion *ar, + ARegion *region, const int smooth_viewtx, const struct V3D_SmoothParams *sview) { @@ -310,13 +310,13 @@ void ED_view3d_smooth_view(bContext *C, wmWindow *win = CTX_wm_window(C); ScrArea *sa = CTX_wm_area(C); - ED_view3d_smooth_view_ex(depsgraph, wm, win, sa, v3d, ar, smooth_viewtx, sview); + ED_view3d_smooth_view_ex(depsgraph, wm, win, sa, v3d, region, smooth_viewtx, sview); } /* only meant for timer usage */ -static void view3d_smoothview_apply(bContext *C, View3D *v3d, ARegion *ar, bool sync_boxview) +static void view3d_smoothview_apply(bContext *C, View3D *v3d, ARegion *region, bool sync_boxview) { - RegionView3D *rv3d = ar->regiondata; + RegionView3D *rv3d = region->regiondata; struct SmoothView3DStore *sms = rv3d->sms; float step, step_inv; @@ -385,7 +385,7 @@ static void view3d_smoothview_apply(bContext *C, View3D *v3d, ARegion *ar, bool } if (sync_boxview && (rv3d->viewlock & RV3D_BOXVIEW)) { - view3d_boxview_copy(CTX_wm_area(C), ar); + view3d_boxview_copy(CTX_wm_area(C), region); } /* note: this doesn't work right because the v3d->lens is now used in ortho mode r51636, @@ -397,22 +397,22 @@ static void view3d_smoothview_apply(bContext *C, View3D *v3d, ARegion *ar, bool WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d); } else { - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); } } static int view3d_smoothview_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event) { View3D *v3d = CTX_wm_view3d(C); - ARegion *ar = CTX_wm_region(C); - RegionView3D *rv3d = ar->regiondata; + ARegion *region = CTX_wm_region(C); + RegionView3D *rv3d = region->regiondata; /* escape if not our timer */ if (rv3d->smooth_timer == NULL || rv3d->smooth_timer != event->customdata) { return OPERATOR_PASS_THROUGH; } - view3d_smoothview_apply(C, v3d, ar, true); + view3d_smoothview_apply(C, v3d, region, true); return OPERATOR_FINISHED; } @@ -421,19 +421,19 @@ static int view3d_smoothview_invoke(bContext *C, wmOperator *UNUSED(op), const w * Apply the smoothview immediately, use when we need to start a new view operation. * (so we don't end up half-applying a view operation when pressing keys quickly). */ -void ED_view3d_smooth_view_force_finish(bContext *C, View3D *v3d, ARegion *ar) +void ED_view3d_smooth_view_force_finish(bContext *C, View3D *v3d, ARegion *region) { - RegionView3D *rv3d = ar->regiondata; + RegionView3D *rv3d = region->regiondata; if (rv3d && rv3d->sms) { rv3d->sms->time_allowed = 0.0; /* force finishing */ - view3d_smoothview_apply(C, v3d, ar, false); + view3d_smoothview_apply(C, v3d, region, false); /* force update of view matrix so tools that run immediately after * can use them without redrawing first */ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = CTX_data_scene(C); - ED_view3d_update_viewmat(depsgraph, scene, v3d, ar, NULL, NULL, NULL, false); + ED_view3d_update_viewmat(depsgraph, scene, v3d, region, NULL, NULL, NULL, false); } } @@ -462,13 +462,13 @@ static int view3d_camera_to_view_exec(bContext *C, wmOperator *UNUSED(op)) { const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); View3D *v3d; - ARegion *ar; + ARegion *region; RegionView3D *rv3d; ObjectTfmProtectedChannels obtfm; - ED_view3d_context_user_region(C, &v3d, &ar); - rv3d = ar->regiondata; + ED_view3d_context_user_region(C, &v3d, ®ion); + rv3d = region->regiondata; ED_view3d_lastview_store(rv3d); @@ -489,10 +489,10 @@ static int view3d_camera_to_view_exec(bContext *C, wmOperator *UNUSED(op)) static bool view3d_camera_to_view_poll(bContext *C) { View3D *v3d; - ARegion *ar; + ARegion *region; - if (ED_view3d_context_user_region(C, &v3d, &ar)) { - RegionView3D *rv3d = ar->regiondata; + if (ED_view3d_context_user_region(C, &v3d, ®ion)) { + RegionView3D *rv3d = region->regiondata; if (v3d && v3d->camera && !ID_IS_LINKED(v3d->camera)) { if (rv3d && (rv3d->viewlock & RV3D_LOCKED) == 0) { if (rv3d->persp != RV3D_CAMOB) { @@ -651,7 +651,7 @@ static void sync_viewport_camera_smoothview(bContext *C, static int view3d_setobjectascamera_exec(bContext *C, wmOperator *op) { View3D *v3d; - ARegion *ar; + ARegion *region; RegionView3D *rv3d; Scene *scene = CTX_data_scene(C); @@ -660,8 +660,8 @@ static int view3d_setobjectascamera_exec(bContext *C, wmOperator *op) const int smooth_viewtx = WM_operator_smooth_viewtx_get(op); /* no NULL check is needed, poll checks */ - ED_view3d_context_user_region(C, &v3d, &ar); - rv3d = ar->regiondata; + ED_view3d_context_user_region(C, &v3d, ®ion); + rv3d = region->regiondata; if (ob) { Object *camera_old = (rv3d->persp == RV3D_CAMOB) ? V3D_CAMERA_SCENE(scene, v3d) : NULL; @@ -678,7 +678,7 @@ static int view3d_setobjectascamera_exec(bContext *C, wmOperator *op) ED_view3d_smooth_view(C, v3d, - ar, + region, smooth_viewtx, &(const V3D_SmoothParams){ .camera_old = camera_old, @@ -732,15 +732,18 @@ void VIEW3D_OT_object_as_camera(wmOperatorType *ot) /** * \param rect: optional for picking (can be NULL). */ -void view3d_winmatrix_set(Depsgraph *depsgraph, ARegion *ar, const View3D *v3d, const rcti *rect) +void view3d_winmatrix_set(Depsgraph *depsgraph, + ARegion *region, + const View3D *v3d, + const rcti *rect) { - RegionView3D *rv3d = ar->regiondata; + RegionView3D *rv3d = region->regiondata; rctf viewplane; float clipsta, clipend; bool is_ortho; is_ortho = ED_view3d_viewplane_get( - depsgraph, v3d, rv3d, ar->winx, ar->winy, &viewplane, &clipsta, &clipend, NULL); + depsgraph, v3d, rv3d, region->winx, region->winy, &viewplane, &clipsta, &clipend, NULL); rv3d->is_persp = !is_ortho; #if 0 @@ -758,10 +761,10 @@ void view3d_winmatrix_set(Depsgraph *depsgraph, ARegion *ar, const View3D *v3d, if (rect) { /* picking */ rctf r; - r.xmin = viewplane.xmin + (BLI_rctf_size_x(&viewplane) * (rect->xmin / (float)ar->winx)); - r.ymin = viewplane.ymin + (BLI_rctf_size_y(&viewplane) * (rect->ymin / (float)ar->winy)); - r.xmax = viewplane.xmin + (BLI_rctf_size_x(&viewplane) * (rect->xmax / (float)ar->winx)); - r.ymax = viewplane.ymin + (BLI_rctf_size_y(&viewplane) * (rect->ymax / (float)ar->winy)); + r.xmin = viewplane.xmin + (BLI_rctf_size_x(&viewplane) * (rect->xmin / (float)region->winx)); + r.ymin = viewplane.ymin + (BLI_rctf_size_y(&viewplane) * (rect->ymin / (float)region->winy)); + r.xmax = viewplane.xmin + (BLI_rctf_size_x(&viewplane) * (rect->xmax / (float)region->winx)); + r.ymax = viewplane.ymin + (BLI_rctf_size_y(&viewplane) * (rect->ymax / (float)region->winy)); viewplane = r; } @@ -991,7 +994,7 @@ int view3d_opengl_select(ViewContext *vc, Depsgraph *depsgraph = vc->depsgraph; Scene *scene = vc->scene; View3D *v3d = vc->v3d; - ARegion *ar = vc->ar; + ARegion *region = vc->region; rcti rect; int hits = 0; const bool use_obedit_skip = (OBEDIT_FROM_VIEW_LAYER(vc->view_layer) != NULL) && @@ -1093,7 +1096,8 @@ int view3d_opengl_select(ViewContext *vc, /* Important we use the 'viewmat' and don't re-calculate since * the object & bone view locking takes 'rect' into account, see: T51629. */ - ED_view3d_draw_setup_view(vc->win, depsgraph, scene, ar, v3d, vc->rv3d->viewmat, NULL, &rect); + ED_view3d_draw_setup_view( + vc->win, depsgraph, scene, region, v3d, vc->rv3d->viewmat, NULL, &rect); if (!XRAY_ACTIVE(v3d)) { GPU_depth_test(true); @@ -1117,7 +1121,7 @@ int view3d_opengl_select(ViewContext *vc, }; draw_surface = false; DRW_draw_select_loop(depsgraph, - ar, + region, v3d, use_obedit_skip, draw_surface, @@ -1147,7 +1151,7 @@ int view3d_opengl_select(ViewContext *vc, /* If are not in wireframe mode, we need to use the mesh surfaces to check for hits */ draw_surface = (v3d->shading.type > OB_WIRE) || !XRAY_ENABLED(v3d); DRW_draw_select_loop(depsgraph, - ar, + region, v3d, use_obedit_skip, draw_surface, @@ -1161,7 +1165,7 @@ int view3d_opengl_select(ViewContext *vc, } G.f &= ~G_FLAG_PICKSEL; - ED_view3d_draw_setup_view(vc->win, depsgraph, scene, ar, v3d, vc->rv3d->viewmat, NULL, NULL); + ED_view3d_draw_setup_view(vc->win, depsgraph, scene, region, v3d, vc->rv3d->viewmat, NULL, NULL); if (!XRAY_ACTIVE(v3d)) { GPU_depth_test(false); @@ -1287,16 +1291,16 @@ static bool view3d_localview_init(const Depsgraph *depsgraph, return false; } - ARegion *ar; + ARegion *region; v3d->localvd = MEM_mallocN(sizeof(View3D), "localview"); memcpy(v3d->localvd, v3d, sizeof(View3D)); v3d->local_view_uuid = local_view_bit; - for (ar = sa->regionbase.first; ar; ar = ar->next) { - if (ar->regiontype == RGN_TYPE_WINDOW) { - RegionView3D *rv3d = ar->regiondata; + for (region = sa->regionbase.first; region; region = region->next) { + if (region->regiontype == RGN_TYPE_WINDOW) { + RegionView3D *rv3d = region->regiondata; bool ok_dist = true; /* New view values. */ @@ -1324,7 +1328,7 @@ static bool view3d_localview_init(const Depsgraph *depsgraph, if (ok_dist) { dist_new = ED_view3d_radius_to_dist( - v3d, ar, depsgraph, rv3d->persp, true, (size / 2) * VIEW3D_MARGIN); + v3d, region, depsgraph, rv3d->persp, true, (size / 2) * VIEW3D_MARGIN); if (rv3d->persp == RV3D_PERSP) { /* Don't zoom closer than the near clipping plane. */ @@ -1337,7 +1341,7 @@ static bool view3d_localview_init(const Depsgraph *depsgraph, win, sa, v3d, - ar, + region, smooth_viewtx, &(const V3D_SmoothParams){ .camera_old = camera_old, @@ -1382,9 +1386,9 @@ static void view3d_localview_exit(const Depsgraph *depsgraph, MEM_freeN(v3d->localvd); v3d->localvd = NULL; - for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) { - if (ar->regiontype == RGN_TYPE_WINDOW) { - RegionView3D *rv3d = ar->regiondata; + for (ARegion *region = sa->regionbase.first; region; region = region->next) { + if (region->regiontype == RGN_TYPE_WINDOW) { + RegionView3D *rv3d = region->regiondata; if (rv3d->localvd == NULL) { continue; @@ -1405,7 +1409,7 @@ static void view3d_localview_exit(const Depsgraph *depsgraph, win, sa, v3d, - ar, + region, smooth_viewtx, &(const V3D_SmoothParams){ .camera_old = camera_old_rv3d, diff --git a/source/blender/editors/space_view3d/view3d_walk.c b/source/blender/editors/space_view3d/view3d_walk.c index 846bf11ee9d..fcacc24b0c8 100644 --- a/source/blender/editors/space_view3d/view3d_walk.c +++ b/source/blender/editors/space_view3d/view3d_walk.c @@ -187,7 +187,7 @@ typedef struct WalkInfo { /* context stuff */ RegionView3D *rv3d; View3D *v3d; - ARegion *ar; + ARegion *region; struct Depsgraph *depsgraph; Scene *scene; @@ -290,7 +290,7 @@ static void walkApply_ndof(bContext *C, WalkInfo *walk, bool is_confirm); static int walkApply(bContext *C, struct WalkInfo *walk, bool force_autokey); static float getVelocityZeroTime(const float gravity, const float velocity); -static void drawWalkPixel(const struct bContext *UNUSED(C), ARegion *ar, void *arg) +static void drawWalkPixel(const struct bContext *UNUSED(C), ARegion *region, void *arg) { /* draws an aim/cross in the center */ WalkInfo *walk = arg; @@ -302,13 +302,13 @@ static void drawWalkPixel(const struct bContext *UNUSED(C), ARegion *ar, void *a if (ED_view3d_cameracontrol_object_get(walk->v3d_camera_control)) { ED_view3d_calc_camera_border( - walk->scene, walk->depsgraph, ar, walk->v3d, walk->rv3d, &viewborder, false); + walk->scene, walk->depsgraph, region, walk->v3d, walk->rv3d, &viewborder, false); xoff = viewborder.xmin + BLI_rctf_size_x(&viewborder) * 0.5f; yoff = viewborder.ymin + BLI_rctf_size_y(&viewborder) * 0.5f; } else { - xoff = walk->ar->winx / 2; - yoff = walk->ar->winy / 2; + xoff = walk->region->winx / 2; + yoff = walk->region->winy / 2; } GPUVertFormat *format = immVertexFormat(); @@ -452,7 +452,7 @@ static bool initWalkInfo(bContext *C, WalkInfo *walk, wmOperator *op) walk->rv3d = CTX_wm_region_view3d(C); walk->v3d = CTX_wm_view3d(C); - walk->ar = CTX_wm_region(C); + walk->region = CTX_wm_region(C); walk->depsgraph = CTX_data_ensure_evaluated_depsgraph(C); walk->scene = CTX_data_scene(C); @@ -546,12 +546,12 @@ static bool initWalkInfo(bContext *C, WalkInfo *walk, wmOperator *op) walk->time_lastdraw = PIL_check_seconds_timer(); walk->draw_handle_pixel = ED_region_draw_cb_activate( - walk->ar->type, drawWalkPixel, walk, REGION_DRAW_POST_PIXEL); + walk->region->type, drawWalkPixel, walk, REGION_DRAW_POST_PIXEL); walk->rv3d->rflag |= RV3D_NAVIGATING; walk->snap_context = ED_transform_snap_object_context_create_view3d( - bmain, walk->scene, CTX_data_ensure_evaluated_depsgraph(C), 0, walk->ar, walk->v3d); + bmain, walk->scene, CTX_data_ensure_evaluated_depsgraph(C), 0, walk->region, walk->v3d); walk->v3d_camera_control = ED_view3d_cameracontrol_acquire( walk->depsgraph, @@ -561,24 +561,24 @@ static bool initWalkInfo(bContext *C, WalkInfo *walk, wmOperator *op) (U.uiflag & USER_CAM_LOCK_NO_PARENT) == 0); /* center the mouse */ - walk->center_mval[0] = walk->ar->winx * 0.5f; - walk->center_mval[1] = walk->ar->winy * 0.5f; + walk->center_mval[0] = walk->region->winx * 0.5f; + walk->center_mval[1] = walk->region->winy * 0.5f; #ifdef USE_PIXELSIZE_NATIVE_SUPPORT - walk->center_mval[0] += walk->ar->winrct.xmin; - walk->center_mval[1] += walk->ar->winrct.ymin; + walk->center_mval[0] += walk->region->winrct.xmin; + walk->center_mval[1] += walk->region->winrct.ymin; WM_cursor_compatible_xy(win, &walk->center_mval[0], &walk->center_mval[1]); - walk->center_mval[0] -= walk->ar->winrct.xmin; - walk->center_mval[1] -= walk->ar->winrct.ymin; + walk->center_mval[0] -= walk->region->winrct.xmin; + walk->center_mval[1] -= walk->region->winrct.ymin; #endif copy_v2_v2_int(walk->prev_mval, walk->center_mval); WM_cursor_warp(win, - walk->ar->winrct.xmin + walk->center_mval[0], - walk->ar->winrct.ymin + walk->center_mval[1]); + walk->region->winrct.xmin + walk->center_mval[0], + walk->region->winrct.ymin + walk->center_mval[1]); /* remove the mouse cursor temporarily */ WM_cursor_modal_set(win, WM_CURSOR_NONE); @@ -616,7 +616,7 @@ static int walkEnd(bContext *C, WalkInfo *walk) WM_event_remove_timer(CTX_wm_manager(C), win, walk->timer); - ED_region_draw_cb_exit(walk->ar->type, walk->draw_handle_pixel); + ED_region_draw_cb_exit(walk->region->type, walk->draw_handle_pixel); ED_transform_snap_object_context_destroy(walk->snap_context); @@ -639,8 +639,8 @@ static int walkEnd(bContext *C, WalkInfo *walk) { /* center the mouse */ WM_cursor_warp(win, - walk->ar->winrct.xmin + walk->center_mval[0], - walk->ar->winrct.ymin + walk->center_mval[1]); + walk->region->winrct.xmin + walk->center_mval[0], + walk->region->winrct.ymin + walk->center_mval[1]); } if (walk->state == WALK_CONFIRM) { @@ -670,8 +670,8 @@ static void walkEvent(bContext *C, WalkInfo *walk, const wmEvent *event) * ideally we shouldn't have to worry about this, see: T45361 */ wmWindow *win = CTX_wm_window(C); WM_cursor_warp(win, - walk->ar->winrct.xmin + walk->center_mval[0], - walk->ar->winrct.ymin + walk->center_mval[1]); + walk->region->winrct.xmin + walk->center_mval[0], + walk->region->winrct.ymin + walk->center_mval[1]); } return; } @@ -708,8 +708,8 @@ static void walkEvent(bContext *C, WalkInfo *walk, const wmEvent *event) #endif { WM_cursor_warp(win, - walk->ar->winrct.xmin + walk->center_mval[0], - walk->ar->winrct.ymin + walk->center_mval[1]); + walk->region->winrct.xmin + walk->center_mval[0], + walk->region->winrct.ymin + walk->center_mval[1]); copy_v2_v2_int(walk->prev_mval, walk->center_mval); } } @@ -964,7 +964,7 @@ static int walkApply(bContext *C, WalkInfo *walk, bool is_confirm) * a walk loop where the user can move move the view as if they are in a walk game */ RegionView3D *rv3d = walk->rv3d; - ARegion *ar = walk->ar; + ARegion *region = walk->region; /* 3x3 copy of the view matrix so we can move along the view axis */ float mat[3][3]; @@ -1032,7 +1032,7 @@ static int walkApply(bContext *C, WalkInfo *walk, bool is_confirm) float y; /* relative offset */ - y = (float)moffset[1] / ar->winy; + y = (float)moffset[1] / region->winy; /* speed factor */ y *= WALK_ROTATE_FAC; @@ -1072,7 +1072,7 @@ static int walkApply(bContext *C, WalkInfo *walk, bool is_confirm) } /* relative offset */ - x = (float)moffset[0] / ar->winx; + x = (float)moffset[0] / region->winx; /* speed factor */ x *= WALK_ROTATE_FAC; |