Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Eisel <julian@blender.org>2020-03-06 18:56:42 +0300
committerJulian Eisel <julian@blender.org>2020-03-06 19:19:23 +0300
commitb2ee1770d4c31078518f4ec9edd5196a41345162 (patch)
tree6b7f6ff9057322245fc3b3407bece3f1c0cb3eb5 /source/blender/editors/space_view3d/view3d_utils.c
parentb825a95ec311a169d33fe21e28418f11a516c82f (diff)
Cleanup: Rename ARegion variables from ar to region
The old convention was easy to confuse with ScrArea. Part of https://developer.blender.org/T74432. This is mostly a batch rename with some manual fixing. Only single word variable names are changed, no prefixed/suffixed names. Brecht van Lommel and Campbell Barton both gave me a green light for this convention change. Also ran clan clang format on affected files.
Diffstat (limited to 'source/blender/editors/space_view3d/view3d_utils.c')
-rw-r--r--source/blender/editors/space_view3d/view3d_utils.c148
1 files changed, 74 insertions, 74 deletions
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(&region->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)