diff options
Diffstat (limited to 'source/blender/editors/gpencil/gpencil_utils.c')
-rw-r--r-- | source/blender/editors/gpencil/gpencil_utils.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c index 0a35dd90f02..4ee3bdd587e 100644 --- a/source/blender/editors/gpencil/gpencil_utils.c +++ b/source/blender/editors/gpencil/gpencil_utils.c @@ -66,6 +66,8 @@ #include "ED_clip.h" #include "ED_view3d.h" +#include "DEG_depsgraph.h" + #include "gpencil_intern.h" /* ******************************************************** */ @@ -203,15 +205,15 @@ bGPdata *ED_gpencil_data_get_active(const bContext *C) /* -------------------------------------------------------- */ // XXX: this should be removed... We really shouldn't duplicate logic like this! -bGPdata *ED_gpencil_data_get_active_v3d(Scene *scene, View3D *v3d) +bGPdata *ED_gpencil_data_get_active_v3d(Scene *scene, ViewLayer *view_layer) { - Base *base = scene->basact; + Base *base = view_layer->basact; bGPdata *gpd = NULL; /* We have to make sure active object is actually visible and selected, else we must use default scene gpd, * to be consistent with ED_gpencil_data_get_active's behavior. */ - if (base && TESTBASE(v3d, base)) { + if (base && TESTBASE(base)) { gpd = base->object->gpd; } return gpd ? gpd : scene->gpd; @@ -521,7 +523,6 @@ bGPDpalettecolor *ED_gpencil_stroke_getcolor(bGPdata *gpd, bGPDstroke *gps) */ void gp_point_conversion_init(bContext *C, GP_SpaceConversion *r_gsc) { - Main *bmain = CTX_data_main(C); ScrArea *sa = CTX_wm_area(C); ARegion *ar = CTX_wm_region(C); @@ -538,6 +539,7 @@ void gp_point_conversion_init(bContext *C, GP_SpaceConversion *r_gsc) if (sa->spacetype == SPACE_VIEW3D) { wmWindow *win = CTX_wm_window(C); Scene *scene = CTX_data_scene(C); + struct Depsgraph *depsgraph = CTX_data_depsgraph(C); View3D *v3d = (View3D *)CTX_wm_space_data(C); RegionView3D *rv3d = ar->regiondata; @@ -545,11 +547,11 @@ void gp_point_conversion_init(bContext *C, GP_SpaceConversion *r_gsc) view3d_operator_needs_opengl(C); view3d_region_operator_needs_opengl(win, ar); - ED_view3d_autodist_init(bmain, scene, ar, v3d, 0); + ED_view3d_autodist_init(depsgraph, ar, v3d, 0); /* for camera view set the subrect */ if (rv3d->persp == RV3D_CAMOB) { - ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &r_gsc->subrect_data, true); /* no shift */ + ED_view3d_calc_camera_border(scene, CTX_data_depsgraph(C), ar, v3d, rv3d, &r_gsc->subrect_data, true); /* no shift */ r_gsc->subrect = &r_gsc->subrect_data; } } @@ -744,7 +746,7 @@ bool gp_point_xy_to_3d(GP_SpaceConversion *gsc, Scene *scene, const float screen { View3D *v3d = gsc->sa->spacedata.first; RegionView3D *rv3d = gsc->ar->regiondata; - float *rvec = ED_view3d_cursor3d_get(scene, v3d); + float *rvec = ED_view3d_cursor3d_get(scene, v3d)->location; float ref[3] = {rvec[0], rvec[1], rvec[2]}; float zfac = ED_view3d_calc_zfac(rv3d, rvec, NULL); @@ -914,8 +916,8 @@ bool gp_smooth_stroke_thickness(bGPDstroke *gps, int i, float inf) ptc = &gps->points[after]; /* the optimal value is the corresponding to the interpolation of the pressure - * at the distance of point b - */ + * at the distance of point b + */ float fac = line_point_factor_v3(&ptb->x, &pta->x, &ptc->x); float optimal = (1.0f - fac) * pta->pressure + fac * ptc->pressure; @@ -963,7 +965,7 @@ void gp_subdivide_stroke(bGPDstroke *gps, const int new_totpoints) * \param gps Stroke data * \param brush Brush data */ -void gp_randomize_stroke(bGPDstroke *gps, bGPDbrush *brush) +void gp_randomize_stroke(bGPDstroke *gps, bGPDbrush *brush, RNG *rng) { bGPDspoint *pt1, *pt2, *pt3; float v1[3]; @@ -996,10 +998,10 @@ void gp_randomize_stroke(bGPDstroke *gps, bGPDbrush *brush) for (int i = 1; i < gps->totpoints - 1; ++i) { bGPDspoint *pt = &gps->points[i]; /* get vector with shift (apply a division because random is too sensitive */ - const float fac = BLI_frand() * (brush->draw_random_sub / 10.0f); + const float fac = BLI_rng_get_float(rng) * (brush->draw_random_sub / 10.0f); float svec[3]; copy_v3_v3(svec, ortho); - if (BLI_frand() > 0.5f) { + if (BLI_rng_get_float(rng) > 0.5f) { mul_v3_fl(svec, -fac); } else { |