diff options
Diffstat (limited to 'source/blender/editors/gpencil')
-rw-r--r-- | source/blender/editors/gpencil/annotate_draw.c | 38 | ||||
-rw-r--r-- | source/blender/editors/gpencil/annotate_paint.c | 87 | ||||
-rw-r--r-- | source/blender/editors/gpencil/drawgpencil.c | 12 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_brush.c | 28 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_convert.c | 16 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_edit.c | 8 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_fill.c | 81 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_intern.h | 8 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_interpolate.c | 18 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_paint.c | 83 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_primitive.c | 29 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_utils.c | 89 |
12 files changed, 261 insertions, 236 deletions
diff --git a/source/blender/editors/gpencil/annotate_draw.c b/source/blender/editors/gpencil/annotate_draw.c index 6e91be862a9..1a30555a584 100644 --- a/source/blender/editors/gpencil/annotate_draw.c +++ b/source/blender/editors/gpencil/annotate_draw.c @@ -933,7 +933,7 @@ static void annotation_draw_data_layers( } /* draw a short status message in the top-right corner */ -static void annotation_draw_status_text(const bGPdata *gpd, ARegion *ar) +static void annotation_draw_status_text(const bGPdata *gpd, ARegion *region) { /* Cannot draw any status text when drawing OpenGL Renders */ @@ -942,7 +942,7 @@ static void annotation_draw_status_text(const bGPdata *gpd, ARegion *ar) } /* Get bounds of region - Necessary to avoid problems with region overlap */ - const rcti *rect = ED_region_visible_rect(ar); + const rcti *rect = ED_region_visible_rect(region); /* for now, this should only be used to indicate when we are in stroke editmode */ if (gpd->flag & GP_DATA_STROKE_EDITMODE) { @@ -1050,7 +1050,7 @@ void ED_annotation_draw_2dimage(const bContext *C) { wmWindowManager *wm = CTX_wm_manager(C); ScrArea *sa = CTX_wm_area(C); - ARegion *ar = CTX_wm_region(C); + ARegion *region = CTX_wm_region(C); Scene *scene = CTX_data_scene(C); int offsx, offsy, sizex, sizey; @@ -1071,10 +1071,11 @@ void ED_annotation_draw_2dimage(const bContext *C) * so disabled. */ offsx = 0; offsy = 0; - sizex = ar->winx; - sizey = ar->winy; + sizex = region->winx; + sizey = region->winy; - wmOrtho2(ar->v2d.cur.xmin, ar->v2d.cur.xmax, ar->v2d.cur.ymin, ar->v2d.cur.ymax); + wmOrtho2( + region->v2d.cur.xmin, region->v2d.cur.xmax, region->v2d.cur.ymin, region->v2d.cur.ymax); dflag |= GP_DRAWDATA_ONLYV2D | GP_DRAWDATA_IEDITHACK; break; @@ -1084,8 +1085,8 @@ void ED_annotation_draw_2dimage(const bContext *C) /* just draw using standard scaling (settings here are currently ignored anyways) */ offsx = 0; offsy = 0; - sizex = ar->winx; - sizey = ar->winy; + sizex = region->winx; + sizey = region->winy; /* NOTE: I2D was used in 2.4x, but the old settings for that have been deprecated * and everything moved to standard View2d @@ -1096,8 +1097,8 @@ void ED_annotation_draw_2dimage(const bContext *C) default: /* for spacetype not yet handled */ offsx = 0; offsy = 0; - sizex = ar->winx; - sizey = ar->winy; + sizex = region->winx; + sizey = region->winy; dflag |= GP_DRAWDATA_ONLYI2D; break; @@ -1124,7 +1125,7 @@ void ED_annotation_draw_view2d(const bContext *C, bool onlyv2d) { wmWindowManager *wm = CTX_wm_manager(C); ScrArea *sa = CTX_wm_area(C); - ARegion *ar = CTX_wm_region(C); + ARegion *region = CTX_wm_region(C); Scene *scene = CTX_data_scene(C); int dflag = 0; @@ -1152,11 +1153,12 @@ void ED_annotation_draw_view2d(const bContext *C, bool onlyv2d) dflag |= GP_DRAWDATA_NO_ONIONS; } - annotation_draw_data_all(scene, gpd, 0, 0, ar->winx, ar->winy, CFRA, dflag, sa->spacetype); + annotation_draw_data_all( + scene, gpd, 0, 0, region->winx, region->winy, CFRA, dflag, sa->spacetype); /* draw status text (if in screen/pixel-space) */ if (!onlyv2d) { - annotation_draw_status_text(gpd, ar); + annotation_draw_status_text(gpd, region); } } @@ -1164,10 +1166,10 @@ void ED_annotation_draw_view2d(const bContext *C, bool onlyv2d) * Note: this gets called twice - first time with only3d=true to draw 3d-strokes, * second time with only3d=false for screen-aligned strokes */ void ED_annotation_draw_view3d( - Scene *scene, struct Depsgraph *depsgraph, View3D *v3d, ARegion *ar, bool only3d) + Scene *scene, struct Depsgraph *depsgraph, View3D *v3d, ARegion *region, bool only3d) { int dflag = 0; - RegionView3D *rv3d = ar->regiondata; + RegionView3D *rv3d = region->regiondata; int offsx, offsy, winx, winy; /* check that we have grease-pencil stuff to draw */ @@ -1181,7 +1183,7 @@ void ED_annotation_draw_view3d( * deal with the camera border, otherwise map the coords to the camera border. */ if ((rv3d->persp == RV3D_CAMOB) && !(G.f & G_FLAG_RENDER_VIEWPORT)) { rctf rectf; - ED_view3d_calc_camera_border(scene, depsgraph, ar, v3d, rv3d, &rectf, true); /* no shift */ + ED_view3d_calc_camera_border(scene, depsgraph, region, v3d, rv3d, &rectf, true); /* no shift */ offsx = round_fl_to_int(rectf.xmin); offsy = round_fl_to_int(rectf.ymin); @@ -1191,8 +1193,8 @@ void ED_annotation_draw_view3d( else { offsx = 0; offsy = 0; - winx = ar->winx; - winy = ar->winy; + winx = region->winx; + winy = region->winy; } /* set flags */ diff --git a/source/blender/editors/gpencil/annotate_paint.c b/source/blender/editors/gpencil/annotate_paint.c index f8eee8a8d39..fe163e5b6e5 100644 --- a/source/blender/editors/gpencil/annotate_paint.c +++ b/source/blender/editors/gpencil/annotate_paint.c @@ -116,7 +116,7 @@ typedef struct tGPsdata { /** area where painting originated. */ ScrArea *sa; /** region where painting originated. */ - ARegion *ar; + ARegion *region; /** needed for GP_STROKE_2DSPACE. */ View2D *v2d; /** for using the camera rect within the 3d view. */ @@ -306,7 +306,8 @@ static void gp_stroke_convertcoords(tGPsdata *p, const float mval[2], float out[ if (gpd->runtime.sbuffer_sflag & GP_STROKE_3DSPACE) { int mval_i[2]; round_v2i_v2fl(mval_i, mval); - if (gpencil_project_check(p) && (ED_view3d_autodist_simple(p->ar, mval_i, out, 0, depth))) { + if (gpencil_project_check(p) && + (ED_view3d_autodist_simple(p->region, mval_i, out, 0, depth))) { /* projecting onto 3D-Geometry * - nothing more needs to be done here, since view_autodist_simple() has already done it */ @@ -326,13 +327,13 @@ static void gp_stroke_convertcoords(tGPsdata *p, const float mval[2], float out[ */ gp_get_3d_reference(p, rvec); - zfac = ED_view3d_calc_zfac(p->ar->regiondata, rvec, NULL); + zfac = ED_view3d_calc_zfac(p->region->regiondata, rvec, NULL); - if (ED_view3d_project_float_global(p->ar, rvec, mval_prj, V3D_PROJ_TEST_NOP) == + if (ED_view3d_project_float_global(p->region, rvec, mval_prj, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) { float mval_f[2]; sub_v2_v2v2(mval_f, mval_prj, mval); - ED_view3d_win_to_delta(p->ar, mval_f, dvec, zfac); + ED_view3d_win_to_delta(p->region, mval_f, dvec, zfac); sub_v3_v3v3(out, rvec, dvec); } else { @@ -350,8 +351,8 @@ static void gp_stroke_convertcoords(tGPsdata *p, const float mval[2], float out[ /* 2d - relative to screen (viewport area) */ else { if (p->subrect == NULL) { /* normal 3D view */ - out[0] = (float)(mval[0]) / (float)(p->ar->winx) * 100; - out[1] = (float)(mval[1]) / (float)(p->ar->winy) * 100; + out[0] = (float)(mval[0]) / (float)(p->region->winx) * 100; + out[1] = (float)(mval[1]) / (float)(p->region->winy) * 100; } else { /* camera view, use subrect */ out[0] = ((mval[0] - p->subrect->xmin) / BLI_rctf_size_x(p->subrect)) * 100; @@ -522,9 +523,11 @@ static short gp_stroke_addpoint(tGPsdata *p, const float mval[2], float pressure if (gpencil_project_check(p)) { View3D *v3d = p->sa->spacedata.first; - view3d_region_operator_needs_opengl(p->win, p->ar); - ED_view3d_autodist_init( - p->depsgraph, p->ar, v3d, (ts->annotate_v3d_align & GP_PROJECT_DEPTH_STROKE) ? 1 : 0); + view3d_region_operator_needs_opengl(p->win, p->region); + ED_view3d_autodist_init(p->depsgraph, + p->region, + v3d, + (ts->annotate_v3d_align & GP_PROJECT_DEPTH_STROKE) ? 1 : 0); } /* convert screen-coordinates to appropriate coordinates (and store them) */ @@ -676,9 +679,9 @@ static void gp_stroke_newfrombuffer(tGPsdata *p) for (i = 0, ptc = gpd->runtime.sbuffer; i < gpd->runtime.sbuffer_used; i++, ptc++, pt++) { round_v2i_v2fl(mval_i, &ptc->x); - if ((ED_view3d_autodist_depth(p->ar, mval_i, depth_margin, depth_arr + i) == 0) && + if ((ED_view3d_autodist_depth(p->region, mval_i, depth_margin, depth_arr + i) == 0) && (i && (ED_view3d_autodist_depth_seg( - p->ar, mval_i, mval_prev, depth_margin + 1, depth_arr + i) == 0))) { + p->region, mval_i, mval_prev, depth_margin + 1, depth_arr + i) == 0))) { interp_depth = true; } else { @@ -794,11 +797,11 @@ static bool gp_stroke_eraser_is_occluded(tGPsdata *p, const int y) { if ((p->sa->spacetype == SPACE_VIEW3D) && (p->flags & GP_PAINTFLAG_V3D_ERASER_DEPTH)) { - RegionView3D *rv3d = p->ar->regiondata; + RegionView3D *rv3d = p->region->regiondata; const int mval_i[2] = {x, y}; float mval_3d[3]; - if (ED_view3d_autodist_simple(p->ar, mval_i, mval_3d, 0, NULL)) { + if (ED_view3d_autodist_simple(p->region, mval_i, mval_3d, 0, NULL)) { const float depth_mval = view3d_point_depth(rv3d, mval_3d); const float depth_pt = view3d_point_depth(rv3d, &pt->x); @@ -924,8 +927,8 @@ static void gp_stroke_doeraser(tGPsdata *p) if (p->sa->spacetype == SPACE_VIEW3D) { if (p->flags & GP_PAINTFLAG_V3D_ERASER_DEPTH) { View3D *v3d = p->sa->spacedata.first; - view3d_region_operator_needs_opengl(p->win, p->ar); - ED_view3d_autodist_init(p->depsgraph, p->ar, v3d, 0); + view3d_region_operator_needs_opengl(p->win, p->region); + ED_view3d_autodist_init(p->depsgraph, p->region, v3d, 0); } } @@ -967,7 +970,7 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p) Main *bmain = CTX_data_main(C); bGPdata **gpd_ptr = NULL; ScrArea *curarea = CTX_wm_area(C); - ARegion *ar = CTX_wm_region(C); + ARegion *region = CTX_wm_region(C); ToolSettings *ts = CTX_data_tool_settings(C); /* make sure the active view (at the starting time) is a 3d-view */ @@ -992,17 +995,17 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p) /* supported views first */ case SPACE_VIEW3D: { /* View3D *v3d = curarea->spacedata.first; */ - /* RegionView3D *rv3d = ar->regiondata; */ + /* RegionView3D *rv3d = region->regiondata; */ /* set current area * - must verify that region data is 3D-view (and not something else) */ /* CAUTION: If this is the "toolbar", then this will change on the first stroke */ p->sa = curarea; - p->ar = ar; + p->region = region; p->align_flag = &ts->annotate_v3d_align; - if (ar->regiondata == NULL) { + if (region->regiondata == NULL) { p->status = GP_STATUS_ERROR; if (G.debug & G_DEBUG) { printf( @@ -1018,8 +1021,8 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p) /* set current area */ p->sa = curarea; - p->ar = ar; - p->v2d = &ar->v2d; + p->region = region; + p->v2d = ®ion->v2d; p->align_flag = &ts->gpencil_v2d_align; break; } @@ -1028,8 +1031,8 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p) /* set current area */ p->sa = curarea; - p->ar = ar; - p->v2d = &ar->v2d; + p->region = region; + p->v2d = ®ion->v2d; p->align_flag = &ts->gpencil_seq_align; /* check that gpencil data is allowed to be drawn */ @@ -1047,8 +1050,8 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p) /* set the current area */ p->sa = curarea; - p->ar = ar; - p->v2d = &ar->v2d; + p->region = region; + p->v2d = ®ion->v2d; p->align_flag = &ts->gpencil_ima_align; break; } @@ -1063,8 +1066,8 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p) /* set the current area */ p->sa = curarea; - p->ar = ar; - p->v2d = &ar->v2d; + p->region = region; + p->v2d = ®ion->v2d; p->align_flag = &ts->gpencil_v2d_align; invert_m4_m4(p->imat, sc->unistabmat); @@ -1305,13 +1308,13 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps if ((*p->align_flag & GP_PROJECT_VIEWSPACE) == 0) { if (p->sa->spacetype == SPACE_VIEW3D) { View3D *v3d = p->sa->spacedata.first; - RegionView3D *rv3d = p->ar->regiondata; + RegionView3D *rv3d = p->region->regiondata; /* for camera view set the subrect */ if (rv3d->persp == RV3D_CAMOB) { /* no shift */ ED_view3d_calc_camera_border( - p->scene, depsgraph, p->ar, v3d, rv3d, &p->subrect_data, true); + p->scene, depsgraph, p->region, v3d, rv3d, &p->subrect_data, true); p->subrect = &p->subrect_data; } } @@ -1322,7 +1325,7 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps p->gsc.gpl = p->gpl; p->gsc.sa = p->sa; - p->gsc.ar = p->ar; + p->gsc.region = p->region; p->gsc.v2d = p->v2d; p->gsc.subrect_data = p->subrect_data; @@ -1359,9 +1362,9 @@ static void gp_paint_strokeend(tGPsdata *p) View3D *v3d = p->sa->spacedata.first; /* need to restore the original projection settings before packing up */ - view3d_region_operator_needs_opengl(p->win, p->ar); + view3d_region_operator_needs_opengl(p->win, p->region); ED_view3d_autodist_init( - p->depsgraph, p->ar, v3d, (ts->annotate_v3d_align & GP_PROJECT_DEPTH_STROKE) ? 1 : 0); + p->depsgraph, p->region, v3d, (ts->annotate_v3d_align & GP_PROJECT_DEPTH_STROKE) ? 1 : 0); } /* check if doing eraser or not */ @@ -1776,7 +1779,7 @@ static void annotation_draw_apply_event( /* force refresh */ /* just active area for now, since doing whole screen is too slow */ - ED_region_tag_redraw(p->ar); + ED_region_tag_redraw(p->region); } /* ------------------------------- */ @@ -2043,8 +2046,8 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) */ if (p->status == GP_STATUS_IDLING) { - ARegion *ar = CTX_wm_region(C); - p->ar = ar; + ARegion *region = CTX_wm_region(C); + p->region = region; } /* We don't pass on key events, GP is used with key-modifiers - @@ -2151,14 +2154,14 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) * NOTE: An exception here is that if launched from the toolbar, * whatever region we're now in should become the new region */ - if ((p->ar) && (p->ar->regiontype == RGN_TYPE_TOOLS)) { + if ((p->region) && (p->region->regiontype == RGN_TYPE_TOOLS)) { /* Change to whatever region is now under the mouse */ ARegion *current_region = BKE_area_find_region_xy(p->sa, RGN_TYPE_ANY, event->x, event->y); if (G.debug & G_DEBUG) { printf("found alternative region %p (old was %p) - at %d %d (sa: %d %d -> %d %d)\n", current_region, - p->ar, + p->region, event->x, event->y, p->sa->totrct.xmin, @@ -2171,7 +2174,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) /* Assume that since we found the cursor in here, it is in bounds * and that this should be the region that we begin drawing in */ - p->ar = current_region; + p->region = current_region; in_bounds = true; } else { @@ -2184,9 +2187,9 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) } } } - else if (p->ar) { + else if (p->region) { /* Perform bounds check. */ - const rcti *region_rect = ED_region_visible_rect(p->ar); + const rcti *region_rect = ED_region_visible_rect(p->region); in_bounds = BLI_rcti_isect_pt_v(region_rect, event->mval); } else { @@ -2284,7 +2287,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) /* force refresh */ /* just active area for now, since doing whole screen is too slow */ - ED_region_tag_redraw(p->ar); + ED_region_tag_redraw(p->region); /* event handled, so just tag as running modal */ estate = OPERATOR_RUNNING_MODAL; diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c index 9fef1e4948b..4d879306cec 100644 --- a/source/blender/editors/gpencil/drawgpencil.c +++ b/source/blender/editors/gpencil/drawgpencil.c @@ -1120,8 +1120,8 @@ static void gp_draw_strokes(tGPDdraw *tgpw) void ED_gp_draw_interpolation(const bContext *C, tGPDinterpolate *tgpi, const int type) { tGPDdraw tgpw; - ARegion *ar = CTX_wm_region(C); - RegionView3D *rv3d = ar->regiondata; + ARegion *region = CTX_wm_region(C); + RegionView3D *rv3d = region->regiondata; tGPDinterpolate_layer *tgpil; Object *obact = CTX_data_active_object(C); /* Drawing code is expected to run with fully evaluated depsgraph. */ @@ -1143,8 +1143,8 @@ void ED_gp_draw_interpolation(const bContext *C, tGPDinterpolate *tgpi, const in tgpw.gpd = tgpi->gpd; tgpw.offsx = 0; tgpw.offsy = 0; - tgpw.winx = tgpi->ar->winx; - tgpw.winy = tgpi->ar->winy; + tgpw.winx = tgpi->region->winx; + tgpw.winy = tgpi->region->winy; tgpw.dflag = dflag; /* turn on alpha-blending */ @@ -1180,7 +1180,7 @@ void ED_gp_draw_fill(tGPDdraw *tgpw) } /* draw a short status message in the top-right corner */ -static void UNUSED_FUNCTION(gp_draw_status_text)(const bGPdata *gpd, ARegion *ar) +static void UNUSED_FUNCTION(gp_draw_status_text)(const bGPdata *gpd, ARegion *region) { /* Cannot draw any status text when drawing OpenGL Renders */ @@ -1189,7 +1189,7 @@ static void UNUSED_FUNCTION(gp_draw_status_text)(const bGPdata *gpd, ARegion *ar } /* Get bounds of region - Necessary to avoid problems with region overlap. */ - const rcti *rect = ED_region_visible_rect(ar); + const rcti *rect = ED_region_visible_rect(region); /* for now, this should only be used to indicate when we are in stroke editmode */ if (gpd->flag & GP_DATA_STROKE_EDITMODE) { diff --git a/source/blender/editors/gpencil/gpencil_brush.c b/source/blender/editors/gpencil/gpencil_brush.c index 0c3e3294428..14354ff38f4 100644 --- a/source/blender/editors/gpencil/gpencil_brush.c +++ b/source/blender/editors/gpencil/gpencil_brush.c @@ -89,7 +89,7 @@ typedef struct tGP_BrushEditData { Object *object; ScrArea *sa; - ARegion *ar; + ARegion *region; /* Current GPencil datablock */ bGPdata *gpd; @@ -537,7 +537,7 @@ static void gp_brush_grab_calc_dvec(tGP_BrushEditData *gso) // TODO: incorporate pressure into this? // XXX: screen-space strokes in 3D space will suffer! if (gso->sa->spacetype == SPACE_VIEW3D) { - RegionView3D *rv3d = gso->ar->regiondata; + RegionView3D *rv3d = gso->region->regiondata; float *rvec = gso->object->loc; float zfac = ED_view3d_calc_zfac(rv3d, rvec, NULL); @@ -557,7 +557,7 @@ static void gp_brush_grab_calc_dvec(tGP_BrushEditData *gso) copy_v2_v2(mval_f, r); } - ED_view3d_win_to_delta(gso->ar, mval_f, gso->dvec, zfac); + ED_view3d_win_to_delta(gso->region, mval_f, gso->dvec, zfac); } else { /* 2D - just copy */ @@ -662,7 +662,7 @@ static void gp_brush_calc_midpoint(tGP_BrushEditData *gso) /* Convert mouse position to 3D space * See: gpencil_paint.c :: gp_stroke_convertcoords() */ - RegionView3D *rv3d = gso->ar->regiondata; + RegionView3D *rv3d = gso->region->regiondata; const float *rvec = gso->object->loc; float zfac = ED_view3d_calc_zfac(rv3d, rvec, NULL); @@ -671,10 +671,10 @@ static void gp_brush_calc_midpoint(tGP_BrushEditData *gso) float mval_prj[2]; float dvec[3]; - if (ED_view3d_project_float_global(gso->ar, rvec, mval_prj, V3D_PROJ_TEST_NOP) == + if (ED_view3d_project_float_global(gso->region, rvec, mval_prj, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) { sub_v2_v2v2(mval_f, mval_prj, mval_f); - ED_view3d_win_to_delta(gso->ar, mval_f, dvec, zfac); + ED_view3d_win_to_delta(gso->region, mval_f, dvec, zfac); sub_v3_v3v3(gso->dvec, rvec, dvec); } else { @@ -774,7 +774,7 @@ static bool gp_brush_twist_apply(tGP_BrushEditData *gso, /* Rotate in 2D or 3D space? */ if (gps->flag & GP_STROKE_3DSPACE) { /* Perform rotation in 3D space... */ - RegionView3D *rv3d = gso->ar->regiondata; + RegionView3D *rv3d = gso->region->regiondata; float rmat[3][3]; float axis[3]; float vec[3]; @@ -888,11 +888,11 @@ static bool gp_brush_randomize_apply(tGP_BrushEditData *gso, /* 3D: Project to 3D space */ if (gso->sa->spacetype == SPACE_VIEW3D) { bool flip; - RegionView3D *rv3d = gso->ar->regiondata; + RegionView3D *rv3d = gso->region->regiondata; float zfac = ED_view3d_calc_zfac(rv3d, &pt->x, &flip); if (flip == false) { float dvec[3]; - ED_view3d_win_to_delta(gso->gsc.ar, svec, dvec, zfac); + ED_view3d_win_to_delta(gso->gsc.region, svec, dvec, zfac); add_v3_v3(&pt->x, dvec); /* compute lock axis */ gpsculpt_compute_lock_axis(gso, pt, save_pt); @@ -1343,7 +1343,7 @@ static bool gpsculpt_brush_init(bContext *C, wmOperator *op) } gso->sa = CTX_wm_area(C); - gso->ar = CTX_wm_region(C); + gso->region = CTX_wm_region(C); /* save mask */ gso->mask = ts->gpencil_selectmode_sculpt; @@ -2094,7 +2094,7 @@ static int gpsculpt_brush_invoke(bContext *C, wmOperator *op, const wmEvent *eve /* start drawing immediately? */ if (is_modal == false) { - ARegion *ar = CTX_wm_region(C); + ARegion *region = CTX_wm_region(C); /* ensure that we'll have a new frame to draw on */ gpsculpt_brush_init_stroke(C, gso); @@ -2104,7 +2104,7 @@ static int gpsculpt_brush_invoke(bContext *C, wmOperator *op, const wmEvent *eve gpsculpt_brush_apply_event(C, op, event); /* redraw view with feedback */ - ED_region_tag_redraw(ar); + ED_region_tag_redraw(region); } return OPERATOR_RUNNING_MODAL; @@ -2297,8 +2297,8 @@ static int gpsculpt_brush_modal(bContext *C, wmOperator *op, const wmEvent *even /* Redraw region? */ if (redraw_region) { - ARegion *ar = CTX_wm_region(C); - ED_region_tag_redraw(ar); + ARegion *region = CTX_wm_region(C); + ED_region_tag_redraw(region); } /* Redraw toolsettings (brush settings)? */ diff --git a/source/blender/editors/gpencil/gpencil_convert.c b/source/blender/editors/gpencil/gpencil_convert.c index 296b4707c4b..255f17f13cc 100644 --- a/source/blender/editors/gpencil/gpencil_convert.c +++ b/source/blender/editors/gpencil/gpencil_convert.c @@ -161,7 +161,7 @@ static void gp_strokepoint_convertcoords(bContext *C, { Scene *scene = CTX_data_scene(C); View3D *v3d = CTX_wm_view3d(C); - ARegion *ar = CTX_wm_region(C); + ARegion *region = CTX_wm_region(C); /* TODO(sergey): This function might be called from a loop, but no tagging is happening in it, * so it's not that expensive to ensure evaluated depsgraph here. However, ideally all the * parameters are to wrapped into a context style struct and queried from Context once.*/ @@ -188,7 +188,7 @@ static void gp_strokepoint_convertcoords(bContext *C, /* get screen coordinate */ if (gps->flag & GP_STROKE_2DSPACE) { - View2D *v2d = &ar->v2d; + View2D *v2d = ®ion->v2d; UI_view2d_view_to_region_fl(v2d, pt->x, pt->y, &mvalf[0], &mvalf[1]); } else { @@ -197,12 +197,12 @@ static void gp_strokepoint_convertcoords(bContext *C, mvalf[1] = (((float)pt->y / 100.0f) * BLI_rctf_size_y(subrect)) + subrect->ymin; } else { - mvalf[0] = (float)pt->x / 100.0f * ar->winx; - mvalf[1] = (float)pt->y / 100.0f * ar->winy; + mvalf[0] = (float)pt->x / 100.0f * region->winx; + mvalf[1] = (float)pt->y / 100.0f * region->winy; } } - ED_view3d_win_to_3d(v3d, ar, fp, mvalf, p3d); + ED_view3d_win_to_3d(v3d, region, fp, mvalf, p3d); } } @@ -1236,16 +1236,16 @@ static void gp_stroke_norm_curve_weights(Curve *cu, const float minmax_weights[2 static int gp_camera_view_subrect(bContext *C, rctf *subrect) { View3D *v3d = CTX_wm_view3d(C); - ARegion *ar = CTX_wm_region(C); + ARegion *region = CTX_wm_region(C); if (v3d) { - RegionView3D *rv3d = ar->regiondata; + RegionView3D *rv3d = region->regiondata; /* for camera view set the subrect */ if (rv3d->persp == RV3D_CAMOB) { Scene *scene = CTX_data_scene(C); Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); - ED_view3d_calc_camera_border(scene, depsgraph, ar, v3d, rv3d, subrect, true); + ED_view3d_calc_camera_border(scene, depsgraph, region, v3d, rv3d, subrect, true); return 1; } } diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index 1931f35922a..a7e28fe1f87 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -3410,8 +3410,8 @@ static int gp_strokes_reproject_exec(bContext *C, wmOperator *op) ToolSettings *ts = CTX_data_tool_settings(C); Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Object *ob = CTX_data_active_object(C); - ARegion *ar = CTX_wm_region(C); - RegionView3D *rv3d = ar->regiondata; + ARegion *region = CTX_wm_region(C); + RegionView3D *rv3d = region->regiondata; SnapObjectContext *sctx = NULL; int oldframe = (int)DEG_get_ctime(depsgraph); @@ -3426,7 +3426,7 @@ static int gp_strokes_reproject_exec(bContext *C, wmOperator *op) int cfra_prv = INT_MIN; /* init snap context for geometry projection */ sctx = ED_transform_snap_object_context_create_view3d( - bmain, scene, depsgraph, 0, ar, CTX_wm_view3d(C)); + bmain, scene, depsgraph, 0, region, CTX_wm_view3d(C)); /* Go through each editable + selected stroke, adjusting each of its points one by one... */ GP_EDITABLE_STROKES_BEGIN (gpstroke_iter, C, gpl, gps) { @@ -3515,7 +3515,7 @@ static int gp_strokes_reproject_exec(bContext *C, wmOperator *op) float location[3] = {0.0f, 0.0f, 0.0f}; float normal[3] = {0.0f, 0.0f, 0.0f}; - ED_view3d_win_to_ray(ar, xy, &ray_start[0], &ray_normal[0]); + ED_view3d_win_to_ray(region, xy, &ray_start[0], &ray_normal[0]); if (ED_transform_snap_object_project_ray(sctx, &(const struct SnapObjectParams){ .snap_select = SNAP_ALL, diff --git a/source/blender/editors/gpencil/gpencil_fill.c b/source/blender/editors/gpencil/gpencil_fill.c index cf4ca80a331..d76ab85ad31 100644 --- a/source/blender/editors/gpencil/gpencil_fill.c +++ b/source/blender/editors/gpencil/gpencil_fill.c @@ -97,7 +97,7 @@ typedef struct tGPDfill { /** view3 where painting originated */ struct View3D *v3d; /** region where painting originated */ - struct ARegion *ar; + struct ARegion *region; /** current GP datablock */ struct bGPdata *gpd; /** current material */ @@ -237,8 +237,8 @@ static void gp_draw_datablock(tGPDfill *tgpf, const float ink[4]) tgpw.gpd = gpd; tgpw.offsx = 0; tgpw.offsy = 0; - tgpw.winx = tgpf->ar->winx; - tgpw.winy = tgpf->ar->winy; + tgpw.winx = tgpf->region->winx; + tgpw.winy = tgpf->region->winy; tgpw.dflag = 0; tgpw.disable_fill = 1; tgpw.dflag |= (GP_DRAWFILLS_ONLY3D | GP_DRAWFILLS_NOSTATUS); @@ -328,26 +328,26 @@ static bool gp_render_offscreen(tGPDfill *tgpf) } /* set temporary new size */ - tgpf->bwinx = tgpf->ar->winx; - tgpf->bwiny = tgpf->ar->winy; - tgpf->brect = tgpf->ar->winrct; - - /* resize ar */ - tgpf->ar->winrct.xmin = 0; - tgpf->ar->winrct.ymin = 0; - tgpf->ar->winrct.xmax = (int)tgpf->ar->winx * tgpf->fill_factor; - tgpf->ar->winrct.ymax = (int)tgpf->ar->winy * tgpf->fill_factor; - tgpf->ar->winx = (short)abs(tgpf->ar->winrct.xmax - tgpf->ar->winrct.xmin); - tgpf->ar->winy = (short)abs(tgpf->ar->winrct.ymax - tgpf->ar->winrct.ymin); + tgpf->bwinx = tgpf->region->winx; + tgpf->bwiny = tgpf->region->winy; + tgpf->brect = tgpf->region->winrct; + + /* resize region */ + tgpf->region->winrct.xmin = 0; + tgpf->region->winrct.ymin = 0; + tgpf->region->winrct.xmax = (int)tgpf->region->winx * tgpf->fill_factor; + tgpf->region->winrct.ymax = (int)tgpf->region->winy * tgpf->fill_factor; + tgpf->region->winx = (short)abs(tgpf->region->winrct.xmax - tgpf->region->winrct.xmin); + tgpf->region->winy = (short)abs(tgpf->region->winrct.ymax - tgpf->region->winrct.ymin); /* save new size */ - tgpf->sizex = (int)tgpf->ar->winx; - tgpf->sizey = (int)tgpf->ar->winy; + tgpf->sizex = (int)tgpf->region->winx; + tgpf->sizey = (int)tgpf->region->winy; /* adjust center */ float center[2]; - center[0] = (float)tgpf->center[0] * ((float)tgpf->ar->winx / (float)tgpf->bwinx); - center[1] = (float)tgpf->center[1] * ((float)tgpf->ar->winy / (float)tgpf->bwiny); + center[0] = (float)tgpf->center[0] * ((float)tgpf->region->winx / (float)tgpf->bwinx); + center[1] = (float)tgpf->center[1] * ((float)tgpf->region->winy / (float)tgpf->bwiny); round_v2i_v2fl(tgpf->center, center); char err_out[256] = "unknown"; @@ -402,7 +402,7 @@ static bool gp_render_offscreen(tGPDfill *tgpf) glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); ED_view3d_update_viewmat( - tgpf->depsgraph, tgpf->scene, tgpf->v3d, tgpf->ar, NULL, winmat, NULL, true); + tgpf->depsgraph, tgpf->scene, tgpf->v3d, tgpf->region, NULL, winmat, NULL, true); /* set for opengl */ GPU_matrix_projection_set(tgpf->rv3d->winmat); GPU_matrix_set(tgpf->rv3d->viewmat); @@ -930,8 +930,8 @@ static void gpencil_get_depth_array(tGPDfill *tgpf) */ if (ts->gpencil_v3d_align & GP_PROJECT_DEPTH_VIEW) { /* need to restore the original projection settings before packing up */ - view3d_region_operator_needs_opengl(tgpf->win, tgpf->ar); - ED_view3d_autodist_init(tgpf->depsgraph, tgpf->ar, tgpf->v3d, 0); + view3d_region_operator_needs_opengl(tgpf->win, tgpf->region); + ED_view3d_autodist_init(tgpf->depsgraph, tgpf->region, tgpf->v3d, 0); /* Since strokes are so fine, when using their depth we need a margin * otherwise they might get missed. */ @@ -949,9 +949,11 @@ static void gpencil_get_depth_array(tGPDfill *tgpf) int mval_i[2]; round_v2i_v2fl(mval_i, &ptc->x); - if ((ED_view3d_autodist_depth(tgpf->ar, mval_i, depth_margin, tgpf->depth_arr + i) == 0) && - (i && (ED_view3d_autodist_depth_seg( - tgpf->ar, mval_i, mval_prev, depth_margin + 1, tgpf->depth_arr + i) == 0))) { + if ((ED_view3d_autodist_depth(tgpf->region, mval_i, depth_margin, tgpf->depth_arr + i) == + 0) && + (i && + (ED_view3d_autodist_depth_seg( + tgpf->region, mval_i, mval_prev, depth_margin + 1, tgpf->depth_arr + i) == 0))) { interp_depth = true; } else { @@ -1080,7 +1082,7 @@ static void gpencil_stroke_from_buffer(tGPDfill *tgpf) for (int i = 0; i < tgpf->sbuffer_used && point2D; i++, point2D++, pt++) { /* convert screen-coordinates to 3D coordinates */ gp_stroke_convertcoords_tpoint(tgpf->scene, - tgpf->ar, + tgpf->region, tgpf->ob, tgpf->gpl, point2D, @@ -1164,12 +1166,12 @@ static void gpencil_draw_boundary_lines(const bContext *UNUSED(C), tGPDfill *tgp } /* Drawing callback for modal operator in 3d mode */ -static void gpencil_fill_draw_3d(const bContext *C, ARegion *UNUSED(ar), void *arg) +static void gpencil_fill_draw_3d(const bContext *C, ARegion *UNUSED(region), void *arg) { tGPDfill *tgpf = (tGPDfill *)arg; /* draw only in the region that originated operator. This is required for multiwindow */ - ARegion *ar = CTX_wm_region(C); - if (ar != tgpf->ar) { + ARegion *region = CTX_wm_region(C); + if (region != tgpf->region) { return; } @@ -1218,8 +1220,8 @@ static tGPDfill *gp_session_init_fill(bContext *C, wmOperator *UNUSED(op)) tgpf->scene = CTX_data_scene(C); tgpf->ob = CTX_data_active_object(C); tgpf->sa = CTX_wm_area(C); - tgpf->ar = CTX_wm_region(C); - tgpf->rv3d = tgpf->ar->regiondata; + tgpf->region = CTX_wm_region(C); + tgpf->rv3d = tgpf->region->regiondata; tgpf->v3d = tgpf->sa->spacedata.first; tgpf->depsgraph = CTX_data_ensure_evaluated_depsgraph(C); tgpf->win = CTX_wm_window(C); @@ -1290,7 +1292,7 @@ static void gpencil_fill_exit(bContext *C, wmOperator *op) /* remove drawing handler */ if (tgpf->draw_handle_3d) { - ED_region_draw_cb_exit(tgpf->ar->type, tgpf->draw_handle_3d); + ED_region_draw_cb_exit(tgpf->region->type, tgpf->draw_handle_3d); } /* delete temp image */ @@ -1394,7 +1396,7 @@ static int gpencil_fill_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSE /* Enable custom drawing handlers to show help lines */ if (tgpf->flag & GP_BRUSH_FILL_SHOW_HELPLINES) { tgpf->draw_handle_3d = ED_region_draw_cb_activate( - tgpf->ar->type, gpencil_fill_draw_3d, tgpf, REGION_DRAW_POST_VIEW); + tgpf->region->type, gpencil_fill_draw_3d, tgpf, REGION_DRAW_POST_VIEW); } WM_cursor_modal_set(CTX_wm_window(C), WM_CURSOR_PAINT_BRUSH); @@ -1426,14 +1428,15 @@ static int gpencil_fill_modal(bContext *C, wmOperator *op, const wmEvent *event) tgpf->on_back = RNA_boolean_get(op->ptr, "on_back"); /* first time the event is not enabled to show help lines */ if ((tgpf->oldkey != -1) || ((tgpf->flag & GP_BRUSH_FILL_SHOW_HELPLINES) == 0)) { - ARegion *ar = BKE_area_find_region_xy(CTX_wm_area(C), RGN_TYPE_ANY, event->x, event->y); - if (ar) { + ARegion *region = BKE_area_find_region_xy( + CTX_wm_area(C), RGN_TYPE_ANY, event->x, event->y); + if (region) { bool in_bounds = false; /* Perform bounds check */ - in_bounds = BLI_rcti_isect_pt(&ar->winrct, event->x, event->y); + in_bounds = BLI_rcti_isect_pt(®ion->winrct, event->x, event->y); - if ((in_bounds) && (ar->regiontype == RGN_TYPE_WINDOW)) { + if ((in_bounds) && (region->regiontype == RGN_TYPE_WINDOW)) { /* TODO GPXX: Verify the mouse click is right for any window size */ tgpf->center[0] = event->mval[0]; tgpf->center[1] = event->mval[1]; @@ -1461,9 +1464,9 @@ static int gpencil_fill_modal(bContext *C, wmOperator *op, const wmEvent *event) } /* restore size */ - tgpf->ar->winx = (short)tgpf->bwinx; - tgpf->ar->winy = (short)tgpf->bwiny; - tgpf->ar->winrct = tgpf->brect; + tgpf->region->winx = (short)tgpf->bwinx; + tgpf->region->winy = (short)tgpf->bwiny; + tgpf->region->winrct = tgpf->brect; /* free temp stack data */ if (tgpf->stack) { diff --git a/source/blender/editors/gpencil/gpencil_intern.h b/source/blender/editors/gpencil/gpencil_intern.h index 69ec11685fb..077b5b88118 100644 --- a/source/blender/editors/gpencil/gpencil_intern.h +++ b/source/blender/editors/gpencil/gpencil_intern.h @@ -116,7 +116,7 @@ typedef struct tGPDinterpolate { /** area where painting originated */ struct ScrArea *sa; /** region where painting originated */ - struct ARegion *ar; + struct ARegion *region; /** current GP datablock */ struct bGPdata *gpd; /** current material */ @@ -162,7 +162,7 @@ typedef struct tGPDprimitive { /** view3d where painting originated */ struct View3D *v3d; /** region where painting originated */ - struct ARegion *ar; + struct ARegion *region; /** current GP datablock */ struct bGPdata *gpd; /** current material */ @@ -252,7 +252,7 @@ typedef struct GP_SpaceConversion { struct bGPDlayer *gpl; struct ScrArea *sa; - struct ARegion *ar; + struct ARegion *region; struct View2D *v2d; rctf *subrect; /* for using the camera rect within the 3d view */ @@ -308,7 +308,7 @@ bool gp_point_xy_to_3d(const GP_SpaceConversion *gsc, /* helper to convert 2d to 3d */ void gp_stroke_convertcoords_tpoint(struct Scene *scene, - struct ARegion *ar, + struct ARegion *region, struct Object *ob, bGPDlayer *gpl, const struct tGPspoint *point2D, diff --git a/source/blender/editors/gpencil/gpencil_interpolate.c b/source/blender/editors/gpencil/gpencil_interpolate.c index ec26006eb06..940fb85f91a 100644 --- a/source/blender/editors/gpencil/gpencil_interpolate.c +++ b/source/blender/editors/gpencil/gpencil_interpolate.c @@ -335,7 +335,7 @@ static void gp_interpolate_set_points(bContext *C, tGPDinterpolate *tgpi) /* Drawing callback for modal operator in screen mode */ static void gpencil_interpolate_draw_screen(const struct bContext *C, - ARegion *UNUSED(ar), + ARegion *UNUSED(region), void *arg) { tGPDinterpolate *tgpi = (tGPDinterpolate *)arg; @@ -343,7 +343,7 @@ static void gpencil_interpolate_draw_screen(const struct bContext *C, } /* Drawing callback for modal operator in 3d mode */ -static void gpencil_interpolate_draw_3d(const bContext *C, ARegion *UNUSED(ar), void *arg) +static void gpencil_interpolate_draw_3d(const bContext *C, ARegion *UNUSED(region), void *arg) { tGPDinterpolate *tgpi = (tGPDinterpolate *)arg; ED_gp_draw_interpolation(C, tgpi, REGION_DRAW_POST_VIEW); @@ -356,8 +356,8 @@ static void gpencil_interpolate_draw_3d(const bContext *C, ARegion *UNUSED(ar), */ static void gpencil_mouse_update_shift(tGPDinterpolate *tgpi, wmOperator *op, const wmEvent *event) { - float mid = (float)(tgpi->ar->winx - tgpi->ar->winrct.xmin) / 2.0f; - float mpos = event->x - tgpi->ar->winrct.xmin; + float mid = (float)(tgpi->region->winx - tgpi->region->winrct.xmin) / 2.0f; + float mpos = event->x - tgpi->region->winrct.xmin; if (mpos >= mid) { tgpi->shift = ((mpos - mid) * tgpi->high_limit) / mid; @@ -422,10 +422,10 @@ static void gpencil_interpolate_exit(bContext *C, wmOperator *op) if (tgpi) { /* remove drawing handler */ if (tgpi->draw_handle_screen) { - ED_region_draw_cb_exit(tgpi->ar->type, tgpi->draw_handle_screen); + ED_region_draw_cb_exit(tgpi->region->type, tgpi->draw_handle_screen); } if (tgpi->draw_handle_3d) { - ED_region_draw_cb_exit(tgpi->ar->type, tgpi->draw_handle_3d); + ED_region_draw_cb_exit(tgpi->region->type, tgpi->draw_handle_3d); } /* clear status message area */ @@ -457,7 +457,7 @@ static bool gp_interpolate_set_init_values(bContext *C, wmOperator *op, tGPDinte /* set current scene and window */ tgpi->scene = CTX_data_scene(C); tgpi->sa = CTX_wm_area(C); - tgpi->ar = CTX_wm_region(C); + tgpi->region = CTX_wm_region(C); tgpi->flag = ts->gp_interpolate.flag; /* set current frame number */ @@ -555,9 +555,9 @@ static int gpencil_interpolate_invoke(bContext *C, wmOperator *op, const wmEvent * and each handler use different coord system */ tgpi->draw_handle_screen = ED_region_draw_cb_activate( - tgpi->ar->type, gpencil_interpolate_draw_screen, tgpi, REGION_DRAW_POST_PIXEL); + tgpi->region->type, gpencil_interpolate_draw_screen, tgpi, REGION_DRAW_POST_PIXEL); tgpi->draw_handle_3d = ED_region_draw_cb_activate( - tgpi->ar->type, gpencil_interpolate_draw_3d, tgpi, REGION_DRAW_POST_VIEW); + tgpi->region->type, gpencil_interpolate_draw_3d, tgpi, REGION_DRAW_POST_VIEW); /* set cursor to indicate modal */ WM_cursor_modal_set(win, WM_CURSOR_EW_SCROLL); diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index cad31ed18e5..afc0e66a8a6 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -154,7 +154,7 @@ typedef struct tGPsdata { /** area where painting originated. */ ScrArea *sa; /** region where painting originated. */ - ARegion *ar; + ARegion *region; /** needed for GP_STROKE_2DSPACE. */ View2D *v2d; /** for using the camera rect within the 3d view. */ @@ -411,7 +411,7 @@ static void gp_reproject_toplane(tGPsdata *p, bGPDstroke *gps) Object *obact = (Object *)p->ownerPtr.data; float origin[3]; - RegionView3D *rv3d = p->ar->regiondata; + RegionView3D *rv3d = p->region->regiondata; /* verify the stroke mode is CURSOR 3d space mode */ if ((gpd->runtime.sbuffer_sflag & GP_STROKE_3DSPACE) == 0) { @@ -446,7 +446,8 @@ static void gp_stroke_convertcoords(tGPsdata *p, const float mval[2], float out[ int mval_i[2]; round_v2i_v2fl(mval_i, mval); - if (gpencil_project_check(p) && (ED_view3d_autodist_simple(p->ar, mval_i, out, 0, depth))) { + if (gpencil_project_check(p) && + (ED_view3d_autodist_simple(p->region, mval_i, out, 0, depth))) { /* projecting onto 3D-Geometry * - nothing more needs to be done here, since view_autodist_simple() has already done it */ @@ -468,12 +469,12 @@ static void gp_stroke_convertcoords(tGPsdata *p, const float mval[2], float out[ * works OK, but it could of course be improved. */ gp_get_3d_reference(p, rvec); - zfac = ED_view3d_calc_zfac(p->ar->regiondata, rvec, NULL); + zfac = ED_view3d_calc_zfac(p->region->regiondata, rvec, NULL); - if (ED_view3d_project_float_global(p->ar, rvec, mval_prj, V3D_PROJ_TEST_NOP) == + if (ED_view3d_project_float_global(p->region, rvec, mval_prj, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) { sub_v2_v2v2(mval_f, mval_prj, mval); - ED_view3d_win_to_delta(p->ar, mval_f, dvec, zfac); + ED_view3d_win_to_delta(p->region, mval_f, dvec, zfac); sub_v3_v3v3(out, rvec, dvec); } else { @@ -789,7 +790,7 @@ static short gp_stroke_addpoint( ToolSettings *ts = p->scene->toolsettings; Object *obact = (Object *)p->ownerPtr.data; Depsgraph *depsgraph = p->depsgraph; - RegionView3D *rv3d = p->ar->regiondata; + RegionView3D *rv3d = p->region->regiondata; View3D *v3d = p->sa->spacedata.first; MaterialGPencilStyle *gp_style = p->material->gp_style; const int def_nr = obact->actdef - 1; @@ -954,11 +955,11 @@ static short gp_stroke_addpoint( float origin[3]; gp_get_3d_reference(p, origin); /* reproject current */ - ED_gpencil_tpoint_to_point(p->ar, origin, pt, &spt); + ED_gpencil_tpoint_to_point(p->region, origin, pt, &spt); ED_gp_project_point_to_plane(p->scene, obact, rv3d, origin, p->lock_axis - 1, &spt); /* reproject previous */ - ED_gpencil_tpoint_to_point(p->ar, origin, ptb, &spt2); + ED_gpencil_tpoint_to_point(p->region, origin, ptb, &spt2); ED_gp_project_point_to_plane(p->scene, obact, rv3d, origin, p->lock_axis - 1, &spt2); p->totpixlen += len_v3v3(&spt.x, &spt2.x) / pixsize; pt->uv_fac = p->totpixlen; @@ -1029,9 +1030,11 @@ static short gp_stroke_addpoint( * so initialize depth buffer before converting coordinates */ if (gpencil_project_check(p)) { - view3d_region_operator_needs_opengl(p->win, p->ar); - ED_view3d_autodist_init( - p->depsgraph, p->ar, v3d, (ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE) ? 1 : 0); + view3d_region_operator_needs_opengl(p->win, p->region); + ED_view3d_autodist_init(p->depsgraph, + p->region, + v3d, + (ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE) ? 1 : 0); } /* convert screen-coordinates to appropriate coordinates (and store them) */ @@ -1092,7 +1095,7 @@ static void gp_stroke_newfrombuffer(tGPsdata *p) ToolSettings *ts = p->scene->toolsettings; Depsgraph *depsgraph = p->depsgraph; Object *obact = (Object *)p->ownerPtr.data; - RegionView3D *rv3d = p->ar->regiondata; + RegionView3D *rv3d = p->region->regiondata; const int def_nr = obact->actdef - 1; const bool have_weight = (bool)BLI_findlink(&obact->defbase, def_nr); const char *align_flag = &ts->gpencil_v3d_align; @@ -1306,9 +1309,9 @@ static void gp_stroke_newfrombuffer(tGPsdata *p) round_v2i_v2fl(mval_i, &ptc->x); - if ((ED_view3d_autodist_depth(p->ar, mval_i, depth_margin, depth_arr + i) == 0) && + if ((ED_view3d_autodist_depth(p->region, mval_i, depth_margin, depth_arr + i) == 0) && (i && (ED_view3d_autodist_depth_seg( - p->ar, mval_i, mval_prev, depth_margin + 1, depth_arr + i) == 0))) { + p->region, mval_i, mval_prev, depth_margin + 1, depth_arr + i) == 0))) { interp_depth = true; } else { @@ -1528,7 +1531,7 @@ static bool gp_stroke_eraser_is_occluded(tGPsdata *p, if ((gp_settings != NULL) && (p->sa->spacetype == SPACE_VIEW3D) && (gp_settings->flag & GP_BRUSH_OCCLUDE_ERASER)) { - RegionView3D *rv3d = p->ar->regiondata; + RegionView3D *rv3d = p->region->regiondata; bGPDlayer *gpl = p->gpl; const int mval_i[2] = {x, y}; @@ -1539,7 +1542,7 @@ static bool gp_stroke_eraser_is_occluded(tGPsdata *p, /* calculate difference matrix if parent object */ ED_gpencil_parent_location(p->depsgraph, obact, p->gpd, gpl, diff_mat); - if (ED_view3d_autodist_simple(p->ar, mval_i, mval_3d, 0, NULL)) { + if (ED_view3d_autodist_simple(p->region, mval_i, mval_3d, 0, NULL)) { const float depth_mval = view3d_point_depth(rv3d, mval_3d); mul_v3_m4v3(fpt, diff_mat, &pt->x); @@ -1891,8 +1894,8 @@ static void gp_stroke_doeraser(tGPsdata *p) if (p->sa->spacetype == SPACE_VIEW3D) { if ((gp_settings != NULL) && (gp_settings->flag & GP_BRUSH_OCCLUDE_ERASER)) { View3D *v3d = p->sa->spacedata.first; - view3d_region_operator_needs_opengl(p->win, p->ar); - ED_view3d_autodist_init(p->depsgraph, p->ar, v3d, 0); + view3d_region_operator_needs_opengl(p->win, p->region); + ED_view3d_autodist_init(p->depsgraph, p->region, v3d, 0); } } @@ -2101,7 +2104,7 @@ static bool gp_session_initdata(bContext *C, wmOperator *op, tGPsdata *p) Main *bmain = CTX_data_main(C); bGPdata **gpd_ptr = NULL; ScrArea *curarea = CTX_wm_area(C); - ARegion *ar = CTX_wm_region(C); + ARegion *region = CTX_wm_region(C); ToolSettings *ts = CTX_data_tool_settings(C); Object *obact = CTX_data_active_object(C); @@ -2129,17 +2132,17 @@ static bool gp_session_initdata(bContext *C, wmOperator *op, tGPsdata *p) /* supported views first */ case SPACE_VIEW3D: { /* View3D *v3d = curarea->spacedata.first; */ - /* RegionView3D *rv3d = ar->regiondata; */ + /* RegionView3D *rv3d = region->regiondata; */ /* set current area * - must verify that region data is 3D-view (and not something else) */ /* CAUTION: If this is the "toolbar", then this will change on the first stroke */ p->sa = curarea; - p->ar = ar; + p->region = region; p->align_flag = &ts->gpencil_v3d_align; - if (ar->regiondata == NULL) { + if (region->regiondata == NULL) { p->status = GP_STATUS_ERROR; if (G.debug & G_DEBUG) { printf( @@ -2406,13 +2409,13 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps if ((*p->align_flag & GP_PROJECT_VIEWSPACE) == 0) { if (p->sa->spacetype == SPACE_VIEW3D) { View3D *v3d = p->sa->spacedata.first; - RegionView3D *rv3d = p->ar->regiondata; + RegionView3D *rv3d = p->region->regiondata; /* for camera view set the subrect */ if (rv3d->persp == RV3D_CAMOB) { /* no shift */ ED_view3d_calc_camera_border( - p->scene, depsgraph, p->ar, v3d, rv3d, &p->subrect_data, true); + p->scene, depsgraph, p->region, v3d, rv3d, &p->subrect_data, true); p->subrect = &p->subrect_data; } } @@ -2423,7 +2426,7 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps p->gsc.gpl = p->gpl; p->gsc.sa = p->sa; - p->gsc.ar = p->ar; + p->gsc.region = p->region; p->gsc.v2d = p->v2d; p->gsc.subrect_data = p->subrect_data; @@ -2453,9 +2456,9 @@ static void gp_paint_strokeend(tGPsdata *p) View3D *v3d = p->sa->spacedata.first; /* need to restore the original projection settings before packing up */ - view3d_region_operator_needs_opengl(p->win, p->ar); + view3d_region_operator_needs_opengl(p->win, p->region); ED_view3d_autodist_init( - p->depsgraph, p->ar, v3d, (ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE) ? 1 : 0); + p->depsgraph, p->region, v3d, (ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE) ? 1 : 0); } /* check if doing eraser or not */ @@ -2910,7 +2913,7 @@ static void gp_origin_get(tGPsdata *p, float origin[2]) static void gpencil_speed_guide_init(tGPsdata *p, GP_Sculpt_Guide *guide) { /* calculate initial guide values */ - RegionView3D *rv3d = p->ar->regiondata; + RegionView3D *rv3d = p->region->regiondata; float scale = 1.0f; if (rv3d->is_persp) { float vec[3]; @@ -3193,7 +3196,7 @@ static void gpencil_draw_apply_event(bContext *C, /* force refresh */ /* just active area for now, since doing whole screen is too slow */ - ED_region_tag_redraw(p->ar); + ED_region_tag_redraw(p->region); } /* ------------------------------- */ @@ -3584,7 +3587,7 @@ static bool gpencil_add_fake_events(bContext *C, wmOperator *op, const wmEvent * return added_events; } - RegionView3D *rv3d = p->ar->regiondata; + RegionView3D *rv3d = p->region->regiondata; float defaultpixsize = rv3d->pixsize * 1000.0f; int samples = (GP_MAX_INPUT_SAMPLES - input_samples + 1); float thickness = (float)brush->size; @@ -3672,8 +3675,8 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) */ if (p->status == GP_STATUS_IDLING) { - ARegion *ar = CTX_wm_region(C); - p->ar = ar; + ARegion *region = CTX_wm_region(C); + p->region = region; } /* special mode for editing control points */ @@ -3851,14 +3854,14 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) * NOTE: An exception here is that if launched from the toolbar, * whatever region we're now in should become the new region */ - if ((p->ar) && (p->ar->regiontype == RGN_TYPE_TOOLS)) { + if ((p->region) && (p->region->regiontype == RGN_TYPE_TOOLS)) { /* Change to whatever region is now under the mouse */ ARegion *current_region = BKE_area_find_region_xy(p->sa, RGN_TYPE_ANY, event->x, event->y); if (G.debug & G_DEBUG) { printf("found alternative region %p (old was %p) - at %d %d (sa: %d %d -> %d %d)\n", current_region, - p->ar, + p->region, event->x, event->y, p->sa->totrct.xmin, @@ -3871,7 +3874,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) /* Assume that since we found the cursor in here, it is in bounds * and that this should be the region that we begin drawing in */ - p->ar = current_region; + p->region = current_region; in_bounds = true; } else { @@ -3884,9 +3887,9 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) } } } - else if (p->ar) { + else if (p->region) { /* Perform bounds check using */ - const rcti *region_rect = ED_region_visible_rect(p->ar); + const rcti *region_rect = ED_region_visible_rect(p->region); in_bounds = BLI_rcti_isect_pt_v(region_rect, event->mval); } else { @@ -3942,7 +3945,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) else if (event->val == KM_RELEASE) { p->status = GP_STATUS_IDLING; op->flag |= OP_IS_MODAL_CURSOR_REGION; - ED_region_tag_redraw(p->ar); + ED_region_tag_redraw(p->region); } } @@ -4008,7 +4011,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) /* force refresh */ /* just active area for now, since doing whole screen is too slow */ - ED_region_tag_redraw(p->ar); + ED_region_tag_redraw(p->region); /* event handled, so just tag as running modal */ estate = OPERATOR_RUNNING_MODAL; diff --git a/source/blender/editors/gpencil/gpencil_primitive.c b/source/blender/editors/gpencil/gpencil_primitive.c index 77f2f5b7353..3ec14ee43b9 100644 --- a/source/blender/editors/gpencil/gpencil_primitive.c +++ b/source/blender/editors/gpencil/gpencil_primitive.c @@ -774,9 +774,9 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi) bool found_depth = false; /* need to restore the original projection settings before packing up */ - view3d_region_operator_needs_opengl(tgpi->win, tgpi->ar); + view3d_region_operator_needs_opengl(tgpi->win, tgpi->region); ED_view3d_autodist_init(tgpi->depsgraph, - tgpi->ar, + tgpi->region, tgpi->v3d, (ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE) ? 1 : 0); @@ -784,9 +784,9 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi) tGPspoint *ptc = &points2D[0]; for (i = 0; i < gps->totpoints; i++, ptc++) { round_v2i_v2fl(mval_i, &ptc->x); - if ((ED_view3d_autodist_depth(tgpi->ar, mval_i, depth_margin, depth_arr + i) == 0) && + if ((ED_view3d_autodist_depth(tgpi->region, mval_i, depth_margin, depth_arr + i) == 0) && (i && (ED_view3d_autodist_depth_seg( - tgpi->ar, mval_i, mval_prev, depth_margin + 1, depth_arr + i) == 0))) { + tgpi->region, mval_i, mval_prev, depth_margin + 1, depth_arr + i) == 0))) { interp_depth = true; } else { @@ -982,12 +982,12 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi) float origin[3]; ED_gp_get_drawing_reference(tgpi->scene, tgpi->ob, tgpi->gpl, ts->gpencil_v3d_align, origin); /* reproject current */ - ED_gpencil_tpoint_to_point(tgpi->ar, origin, tpt, &spt); + ED_gpencil_tpoint_to_point(tgpi->region, origin, tpt, &spt); ED_gp_project_point_to_plane( tgpi->scene, tgpi->ob, tgpi->rv3d, origin, tgpi->lock_axis - 1, &spt); /* reproject previous */ - ED_gpencil_tpoint_to_point(tgpi->ar, origin, tptb, &spt2); + ED_gpencil_tpoint_to_point(tgpi->region, origin, tptb, &spt2); ED_gp_project_point_to_plane( tgpi->scene, tgpi->ob, tgpi->rv3d, origin, tgpi->lock_axis - 1, &spt2); tgpi->totpixlen += len_v3v3(&spt.x, &spt2.x) / pixsize; @@ -1015,8 +1015,13 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi) } /* convert screen-coordinates to 3D coordinates */ - gp_stroke_convertcoords_tpoint( - tgpi->scene, tgpi->ar, tgpi->ob, tgpi->gpl, p2d, depth_arr ? depth_arr + i : NULL, &pt->x); + gp_stroke_convertcoords_tpoint(tgpi->scene, + tgpi->region, + tgpi->ob, + tgpi->gpl, + p2d, + depth_arr ? depth_arr + i : NULL, + &pt->x); pt->pressure = pressure; pt->strength = strength; @@ -1040,7 +1045,7 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi) for (int i = 0; i < tgpi->gpd->runtime.tot_cp_points; i++) { bGPDcontrolpoint *cp = &cps[i]; gp_stroke_convertcoords_tpoint( - tgpi->scene, tgpi->ar, tgpi->ob, tgpi->gpl, (tGPspoint *)cp, NULL, &cp->x); + tgpi->scene, tgpi->region, tgpi->ob, tgpi->gpl, (tGPspoint *)cp, NULL, &cp->x); } } @@ -1160,8 +1165,8 @@ static void gpencil_primitive_init(bContext *C, wmOperator *op) tgpi->scene = scene; tgpi->ob = CTX_data_active_object(C); tgpi->sa = CTX_wm_area(C); - tgpi->ar = CTX_wm_region(C); - tgpi->rv3d = tgpi->ar->regiondata; + tgpi->region = CTX_wm_region(C); + tgpi->rv3d = tgpi->region->regiondata; tgpi->v3d = tgpi->sa->spacedata.first; tgpi->depsgraph = CTX_data_ensure_evaluated_depsgraph(C); tgpi->win = CTX_wm_window(C); @@ -1175,7 +1180,7 @@ static void gpencil_primitive_init(bContext *C, wmOperator *op) /* set GP datablock */ tgpi->gpd = gpd; /* region where paint was originated */ - tgpi->gpd->runtime.ar = tgpi->ar; + tgpi->gpd->runtime.ar = tgpi->region; /* if brush doesn't exist, create a new set (fix damaged files from old versions) */ if ((paint->brush == NULL) || (paint->brush->gpencil_settings == NULL)) { diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c index d4eb157bf3c..9c2e0f100cc 100644 --- a/source/blender/editors/gpencil/gpencil_utils.c +++ b/source/blender/editors/gpencil/gpencil_utils.c @@ -575,7 +575,7 @@ bool ED_gpencil_stroke_color_use(Object *ob, const bGPDlayer *gpl, const bGPDstr void gp_point_conversion_init(bContext *C, GP_SpaceConversion *r_gsc) { ScrArea *sa = CTX_wm_area(C); - ARegion *ar = CTX_wm_region(C); + ARegion *region = CTX_wm_region(C); /* zero out the storage (just in case) */ memset(r_gsc, 0, sizeof(GP_SpaceConversion)); @@ -586,8 +586,8 @@ void gp_point_conversion_init(bContext *C, GP_SpaceConversion *r_gsc) r_gsc->ob = CTX_data_active_object(C); r_gsc->sa = sa; - r_gsc->ar = ar; - r_gsc->v2d = &ar->v2d; + r_gsc->region = region; + r_gsc->v2d = ®ion->v2d; /* init region-specific stuff */ if (sa->spacetype == SPACE_VIEW3D) { @@ -595,17 +595,18 @@ void gp_point_conversion_init(bContext *C, GP_SpaceConversion *r_gsc) Scene *scene = CTX_data_scene(C); struct Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); View3D *v3d = (View3D *)CTX_wm_space_data(C); - RegionView3D *rv3d = ar->regiondata; + RegionView3D *rv3d = region->regiondata; /* init 3d depth buffers */ view3d_operator_needs_opengl(C); - view3d_region_operator_needs_opengl(win, ar); - ED_view3d_autodist_init(depsgraph, ar, v3d, 0); + view3d_region_operator_needs_opengl(win, region); + ED_view3d_autodist_init(depsgraph, region, v3d, 0); /* for camera view set the subrect */ if (rv3d->persp == RV3D_CAMOB) { - ED_view3d_calc_camera_border(scene, depsgraph, ar, v3d, rv3d, &r_gsc->subrect_data, true); + ED_view3d_calc_camera_border( + scene, depsgraph, region, v3d, rv3d, &r_gsc->subrect_data, true); r_gsc->subrect = &r_gsc->subrect_data; } } @@ -680,7 +681,7 @@ void gp_apply_parent_point( void gp_point_to_xy( const GP_SpaceConversion *gsc, const bGPDstroke *gps, const bGPDspoint *pt, int *r_x, int *r_y) { - const ARegion *ar = gsc->ar; + const ARegion *region = gsc->region; const View2D *v2d = gsc->v2d; const rctf *subrect = gsc->subrect; int xyval[2]; @@ -690,7 +691,8 @@ void gp_point_to_xy( BLI_assert(!(gps->flag & GP_STROKE_2DSPACE) || (gsc->sa->spacetype != SPACE_VIEW3D)); if (gps->flag & GP_STROKE_3DSPACE) { - if (ED_view3d_project_int_global(ar, &pt->x, xyval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) { + if (ED_view3d_project_int_global(region, &pt->x, xyval, V3D_PROJ_TEST_NOP) == + V3D_PROJ_RET_OK) { *r_x = xyval[0]; *r_y = xyval[1]; } @@ -707,8 +709,8 @@ void gp_point_to_xy( else { if (subrect == NULL) { /* normal 3D view (or view space) */ - *r_x = (int)(pt->x / 100 * ar->winx); - *r_y = (int)(pt->y / 100 * ar->winy); + *r_x = (int)(pt->x / 100 * region->winx); + *r_y = (int)(pt->y / 100 * region->winy); } else { /* camera view, use subrect */ @@ -737,7 +739,7 @@ void gp_point_to_xy_fl(const GP_SpaceConversion *gsc, float *r_x, float *r_y) { - const ARegion *ar = gsc->ar; + const ARegion *region = gsc->region; const View2D *v2d = gsc->v2d; const rctf *subrect = gsc->subrect; float xyval[2]; @@ -747,7 +749,8 @@ void gp_point_to_xy_fl(const GP_SpaceConversion *gsc, BLI_assert(!(gps->flag & GP_STROKE_2DSPACE) || (gsc->sa->spacetype != SPACE_VIEW3D)); if (gps->flag & GP_STROKE_3DSPACE) { - if (ED_view3d_project_float_global(ar, &pt->x, xyval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) { + if (ED_view3d_project_float_global(region, &pt->x, xyval, V3D_PROJ_TEST_NOP) == + V3D_PROJ_RET_OK) { *r_x = xyval[0]; *r_y = xyval[1]; } @@ -776,8 +779,8 @@ void gp_point_to_xy_fl(const GP_SpaceConversion *gsc, else { if (subrect == NULL) { /* normal 3D view (or view space) */ - *r_x = (pt->x / 100.0f * ar->winx); - *r_y = (pt->y / 100.0f * ar->winy); + *r_x = (pt->x / 100.0f * region->winx); + *r_y = (pt->y / 100.0f * region->winy); } else { /* camera view, use subrect */ @@ -795,7 +798,7 @@ void gp_point_3d_to_xy(const GP_SpaceConversion *gsc, const float pt[3], float xy[2]) { - const ARegion *ar = gsc->ar; + const ARegion *region = gsc->region; const View2D *v2d = gsc->v2d; const rctf *subrect = gsc->subrect; float xyval[2]; @@ -804,7 +807,7 @@ void gp_point_3d_to_xy(const GP_SpaceConversion *gsc, BLI_assert((gsc->sa->spacetype == SPACE_VIEW3D)); if (flag & GP_STROKE_3DSPACE) { - if (ED_view3d_project_float_global(ar, pt, xyval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) { + if (ED_view3d_project_float_global(region, pt, xyval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) { xy[0] = xyval[0]; xy[1] = xyval[1]; } @@ -833,8 +836,8 @@ void gp_point_3d_to_xy(const GP_SpaceConversion *gsc, else { if (subrect == NULL) { /* normal 3D view (or view space) */ - xy[0] = (pt[0] / 100.0f * ar->winx); - xy[1] = (pt[1] / 100.0f * ar->winy); + xy[0] = (pt[0] / 100.0f * region->winx); + xy[1] = (pt[1] / 100.0f * region->winy); } else { /* camera view, use subrect */ @@ -864,7 +867,7 @@ bool gp_point_xy_to_3d(const GP_SpaceConversion *gsc, const float screen_co[2], float r_out[3]) { - const RegionView3D *rv3d = gsc->ar->regiondata; + const RegionView3D *rv3d = gsc->region->regiondata; float rvec[3]; ED_gp_get_drawing_reference( @@ -877,10 +880,10 @@ bool gp_point_xy_to_3d(const GP_SpaceConversion *gsc, copy_v2_v2(mval_f, screen_co); - if (ED_view3d_project_float_global(gsc->ar, rvec, mval_prj, V3D_PROJ_TEST_NOP) == + if (ED_view3d_project_float_global(gsc->region, rvec, mval_prj, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) { sub_v2_v2v2(mval_f, mval_prj, mval_f); - ED_view3d_win_to_delta(gsc->ar, mval_f, dvec, zfac); + ED_view3d_win_to_delta(gsc->region, mval_f, dvec, zfac); sub_v3_v3v3(r_out, rvec, dvec); return true; @@ -901,7 +904,7 @@ bool gp_point_xy_to_3d(const GP_SpaceConversion *gsc, * \param[out] r_out: The resulting 2D point data. */ void gp_stroke_convertcoords_tpoint(Scene *scene, - ARegion *ar, + ARegion *region, Object *ob, bGPDlayer *gpl, const tGPspoint *point2D, @@ -913,7 +916,7 @@ void gp_stroke_convertcoords_tpoint(Scene *scene, int mval_i[2]; round_v2i_v2fl(mval_i, &point2D->x); - if ((depth != NULL) && (ED_view3d_autodist_simple(ar, mval_i, r_out, 0, depth))) { + if ((depth != NULL) && (ED_view3d_autodist_simple(region, mval_i, r_out, 0, depth))) { /* projecting onto 3D-Geometry * - nothing more needs to be done here, since view_autodist_simple() has already done it */ @@ -928,11 +931,12 @@ void gp_stroke_convertcoords_tpoint(Scene *scene, * 3D-coordinates using the 3D-cursor as reference. */ ED_gp_get_drawing_reference(scene, ob, gpl, ts->gpencil_v3d_align, rvec); - zfac = ED_view3d_calc_zfac(ar->regiondata, rvec, NULL); + zfac = ED_view3d_calc_zfac(region->regiondata, rvec, NULL); - if (ED_view3d_project_float_global(ar, rvec, mval_prj, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) { + if (ED_view3d_project_float_global(region, rvec, mval_prj, V3D_PROJ_TEST_NOP) == + V3D_PROJ_RET_OK) { sub_v2_v2v2(mval_f, mval_prj, mval_f); - ED_view3d_win_to_delta(ar, mval_f, dvec, zfac); + ED_view3d_win_to_delta(region, mval_f, dvec, zfac); sub_v3_v3v3(r_out, rvec, dvec); } else { @@ -1668,7 +1672,7 @@ void ED_gpencil_vgroup_deselect(bContext *C, Object *ob) /* check if cursor is in drawing region */ static bool gp_check_cursor_region(bContext *C, int mval_i[2]) { - ARegion *ar = CTX_wm_region(C); + ARegion *region = CTX_wm_region(C); ScrArea *sa = CTX_wm_area(C); Object *ob = CTX_data_active_object(C); @@ -1681,11 +1685,11 @@ static bool gp_check_cursor_region(bContext *C, int mval_i[2]) if (!ELEM(sa->spacetype, SPACE_VIEW3D)) { return false; } - if ((ar) && (ar->regiontype != RGN_TYPE_WINDOW)) { + if ((region) && (region->regiontype != RGN_TYPE_WINDOW)) { return false; } - else if (ar) { - return BLI_rcti_isect_pt_v(&ar->winrct, mval_i); + else if (region) { + return BLI_rcti_isect_pt_v(®ion->winrct, mval_i); } else { return false; @@ -1748,7 +1752,7 @@ static void gp_brush_cursor_draw(bContext *C, int x, int y, void *customdata) { Scene *scene = CTX_data_scene(C); Object *ob = CTX_data_active_object(C); - ARegion *ar = CTX_wm_region(C); + ARegion *region = CTX_wm_region(C); GP_Sculpt_Settings *gset = &scene->toolsettings->gp_sculpt; bGPdata *gpd = ED_gpencil_data_get_active(C); @@ -1879,8 +1883,9 @@ static void gp_brush_cursor_draw(bContext *C, int x, int y, void *customdata) immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos, x, y); - immVertex2f( - pos, last_mouse_position[0] + ar->winrct.xmin, last_mouse_position[1] + ar->winrct.ymin); + immVertex2f(pos, + last_mouse_position[0] + region->winrct.xmin, + last_mouse_position[1] + region->winrct.ymin); immEnd(); GPU_blend(false); @@ -1992,7 +1997,7 @@ void ED_gpencil_setup_modes(bContext *C, bGPdata *gpd, int newmode) } /* helper to convert 2d to 3d for simple drawing buffer */ -static void gpencil_stroke_convertcoords(ARegion *ar, +static void gpencil_stroke_convertcoords(ARegion *region, const tGPspoint *point2D, const float origin[3], float out[3]) @@ -2004,11 +2009,12 @@ static void gpencil_stroke_convertcoords(ARegion *ar, copy_v3_v3(rvec, origin); - zfac = ED_view3d_calc_zfac(ar->regiondata, rvec, NULL); + zfac = ED_view3d_calc_zfac(region->regiondata, rvec, NULL); - if (ED_view3d_project_float_global(ar, rvec, mval_prj, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) { + if (ED_view3d_project_float_global(region, rvec, mval_prj, V3D_PROJ_TEST_NOP) == + V3D_PROJ_RET_OK) { sub_v2_v2v2(mval_f, mval_prj, mval_f); - ED_view3d_win_to_delta(ar, mval_f, dvec, zfac); + ED_view3d_win_to_delta(region, mval_f, dvec, zfac); sub_v3_v3v3(out, rvec, dvec); } else { @@ -2017,11 +2023,14 @@ static void gpencil_stroke_convertcoords(ARegion *ar, } /* convert 2d tGPspoint to 3d bGPDspoint */ -void ED_gpencil_tpoint_to_point(ARegion *ar, float origin[3], const tGPspoint *tpt, bGPDspoint *pt) +void ED_gpencil_tpoint_to_point(ARegion *region, + float origin[3], + const tGPspoint *tpt, + bGPDspoint *pt) { float p3d[3]; /* conversion to 3d format */ - gpencil_stroke_convertcoords(ar, tpt, origin, p3d); + gpencil_stroke_convertcoords(region, tpt, origin, p3d); copy_v3_v3(&pt->x, p3d); pt->pressure = tpt->pressure; |