diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-11-26 05:49:17 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-11-26 06:02:09 +0300 |
commit | 74938480083a908a5d1fad448f1214b214727bf3 (patch) | |
tree | cbc5ddb594a7676e87a10fa9f2ddcbc6acef2316 /source/blender/editors/gpencil | |
parent | b4e037fe14052619e23863ca08524c97181b3292 (diff) |
3D View: remove 3D cursor
Use 3D cursor from the scene (was previously used for local-view).
Diffstat (limited to 'source/blender/editors/gpencil')
-rw-r--r-- | source/blender/editors/gpencil/annotate_paint.c | 3 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_brush.c | 6 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_convert.c | 2 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_edit.c | 9 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_fill.c | 10 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_intern.h | 2 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_paint.c | 6 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_primitive.c | 4 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_utils.c | 19 |
9 files changed, 27 insertions, 34 deletions
diff --git a/source/blender/editors/gpencil/annotate_paint.c b/source/blender/editors/gpencil/annotate_paint.c index 5a8641ed0a7..3a9b7e7306c 100644 --- a/source/blender/editors/gpencil/annotate_paint.c +++ b/source/blender/editors/gpencil/annotate_paint.c @@ -232,8 +232,7 @@ static bool gpencil_project_check(tGPsdata *p) /* get the reference point for stroke-point conversions */ static void gp_get_3d_reference(tGPsdata *p, float vec[3]) { - View3D *v3d = p->sa->spacedata.first; - const float *fp = ED_view3d_cursor3d_get(p->scene, v3d)->location; + const float *fp = p->scene->cursor.location; /* use 3D-cursor */ copy_v3_v3(vec, fp); diff --git a/source/blender/editors/gpencil/gpencil_brush.c b/source/blender/editors/gpencil/gpencil_brush.c index 657c3c8b9b6..d73b39811ce 100644 --- a/source/blender/editors/gpencil/gpencil_brush.c +++ b/source/blender/editors/gpencil/gpencil_brush.c @@ -479,9 +479,8 @@ 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) { - View3D *v3d = gso->sa->spacedata.first; RegionView3D *rv3d = gso->ar->regiondata; - float *rvec = ED_view3d_cursor3d_get(gso->scene, v3d)->location; + float *rvec = gso->scene->cursor.location; float zfac = ED_view3d_calc_zfac(rv3d, rvec, NULL); float mval_f[2]; @@ -587,9 +586,8 @@ static void gp_brush_calc_midpoint(tGP_BrushEditData *gso) /* Convert mouse position to 3D space * See: gpencil_paint.c :: gp_stroke_convertcoords() */ - View3D *v3d = gso->sa->spacedata.first; RegionView3D *rv3d = gso->ar->regiondata; - float *rvec = ED_view3d_cursor3d_get(gso->scene, v3d)->location; + const float *rvec = gso->scene->cursor.location; float zfac = ED_view3d_calc_zfac(rv3d, rvec, NULL); float mval_f[2]; diff --git a/source/blender/editors/gpencil/gpencil_convert.c b/source/blender/editors/gpencil/gpencil_convert.c index fc0464af430..013b5ff7103 100644 --- a/source/blender/editors/gpencil/gpencil_convert.c +++ b/source/blender/editors/gpencil/gpencil_convert.c @@ -174,7 +174,7 @@ static void gp_strokepoint_convertcoords( copy_v3_v3(p3d, &pt->x); } else { - const float *fp = ED_view3d_cursor3d_get(scene, v3d)->location; + const float *fp = scene->cursor.location; float mvalf[2]; /* get screen coordinate */ diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index b56d46fdc1e..89c1409f05c 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -2196,12 +2196,11 @@ static int gp_snap_to_cursor(bContext *C, wmOperator *op) bGPdata *gpd = ED_gpencil_data_get_active(C); Scene *scene = CTX_data_scene(C); - View3D *v3d = CTX_wm_view3d(C); Depsgraph *depsgraph = CTX_data_depsgraph(C); Object *obact = CTX_data_active_object(C); const bool use_offset = RNA_boolean_get(op->ptr, "use_offset"); - const float *cursor_global = ED_view3d_cursor3d_get(scene, v3d)->location; + const float *cursor_global = scene->cursor.location; for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) { /* only editable and visible layers are considered */ @@ -2288,7 +2287,7 @@ static int gp_snap_cursor_to_sel(bContext *C, wmOperator *UNUSED(op)) Depsgraph *depsgraph = CTX_data_depsgraph(C); Object *obact = CTX_data_active_object(C); - float *cursor = ED_view3d_cursor3d_get(scene, v3d)->location; + float *cursor = scene->cursor.location; float centroid[3] = {0.0f}; float min[3], max[3]; size_t count = 0; @@ -2857,10 +2856,8 @@ static int gp_strokes_reproject_exec(bContext *C, wmOperator *op) ToolSettings *ts = CTX_data_tool_settings(C); Depsgraph *depsgraph = CTX_data_depsgraph(C); Object *ob = CTX_data_active_object(C); - ScrArea *sa = CTX_wm_area(C); ARegion *ar = CTX_wm_region(C); RegionView3D *rv3d = ar->regiondata; - View3D *v3d = sa->spacedata.first; GP_SpaceConversion gsc = {NULL}; eGP_ReprojectModes mode = RNA_enum_get(op->ptr, "type"); @@ -2905,7 +2902,7 @@ static int gp_strokes_reproject_exec(bContext *C, wmOperator *op) /* Project stroke in one axis */ if (ELEM(mode, GP_REPROJECT_FRONT, GP_REPROJECT_SIDE, GP_REPROJECT_TOP)) { - ED_gp_get_drawing_reference(v3d, scene, ob, gpl, + ED_gp_get_drawing_reference(scene, ob, gpl, ts->gpencil_v3d_align, origin); int axis = 0; diff --git a/source/blender/editors/gpencil/gpencil_fill.c b/source/blender/editors/gpencil/gpencil_fill.c index 1cdc8274d32..50b7d25394d 100644 --- a/source/blender/editors/gpencil/gpencil_fill.c +++ b/source/blender/editors/gpencil/gpencil_fill.c @@ -880,10 +880,10 @@ static void gpencil_stroke_from_buffer(tGPDfill *tgpf) for (int i = 0; i < tgpf->sbuffer_size && point2D; i++, point2D++, pt++) { /* convert screen-coordinates to 3D coordinates */ gp_stroke_convertcoords_tpoint( - tgpf->scene, tgpf->ar, tgpf->v3d, tgpf->ob, - tgpf->gpl, point2D, - tgpf->depth_arr ? tgpf->depth_arr + i : NULL, - &pt->x); + tgpf->scene, tgpf->ar, tgpf->ob, + tgpf->gpl, point2D, + tgpf->depth_arr ? tgpf->depth_arr + i : NULL, + &pt->x); pt->pressure = 1.0f; pt->strength = 1.0f; @@ -920,7 +920,7 @@ static void gpencil_stroke_from_buffer(tGPDfill *tgpf) if ((tgpf->lock_axis > GP_LOCKAXIS_VIEW) && ((ts->gpencil_v3d_align & GP_PROJECT_DEPTH_VIEW) == 0)) { float origin[3]; ED_gp_get_drawing_reference( - tgpf->v3d, tgpf->scene, tgpf->ob, tgpf->gpl, + tgpf->scene, tgpf->ob, tgpf->gpl, ts->gpencil_v3d_align, origin); ED_gp_project_stroke_to_plane( tgpf->ob, tgpf->rv3d, gps, origin, diff --git a/source/blender/editors/gpencil/gpencil_intern.h b/source/blender/editors/gpencil/gpencil_intern.h index d737d34a017..a55d984cd13 100644 --- a/source/blender/editors/gpencil/gpencil_intern.h +++ b/source/blender/editors/gpencil/gpencil_intern.h @@ -221,7 +221,7 @@ bool gp_point_xy_to_3d(GP_SpaceConversion *gsc, struct Scene *scene, const float /* helper to convert 2d to 3d */ void gp_stroke_convertcoords_tpoint( struct Scene *scene, struct ARegion *ar, - struct View3D *v3d, struct Object *ob, + struct Object *ob, bGPDlayer *gpl, const struct tGPspoint *point2D, float *depth, float out[3]); diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index 3941c757a50..f932e59c869 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -285,12 +285,11 @@ static bool gpencil_project_check(tGPsdata *p) /* get the reference point for stroke-point conversions */ static void gp_get_3d_reference(tGPsdata *p, float vec[3]) { - View3D *v3d = p->sa->spacedata.first; Object *ob = NULL; if (p->ownerPtr.type == &RNA_Object) { ob = (Object *)p->ownerPtr.data; } - ED_gp_get_drawing_reference(v3d, p->scene, ob, p->gpl, *p->align_flag, vec); + ED_gp_get_drawing_reference(p->scene, ob, p->gpl, *p->align_flag, vec); } /* Stroke Editing ---------------------------- */ @@ -1774,7 +1773,6 @@ static bool gp_session_initdata(bContext *C, wmOperator *op, tGPsdata *p) ARegion *ar = CTX_wm_region(C); ToolSettings *ts = CTX_data_tool_settings(C); Object *obact = CTX_data_active_object(C); - View3D *v3d = curarea->spacedata.first; /* make sure the active view (at the starting time) is a 3d-view */ if (curarea == NULL) { @@ -1818,7 +1816,7 @@ static bool gp_session_initdata(bContext *C, wmOperator *op, tGPsdata *p) } /* if active object doesn't exist or isn't a GP Object, create one */ - float *cur = ED_view3d_cursor3d_get(p->scene, v3d)->location; + const float *cur = p->scene->cursor.location; if ((!obact) || (obact->type != OB_GPENCIL)) { /* create new default object */ obact = ED_add_gpencil_object(C, p->scene, cur); diff --git a/source/blender/editors/gpencil/gpencil_primitive.c b/source/blender/editors/gpencil/gpencil_primitive.c index a9c52741e61..9d9410d0885 100644 --- a/source/blender/editors/gpencil/gpencil_primitive.c +++ b/source/blender/editors/gpencil/gpencil_primitive.c @@ -348,7 +348,7 @@ 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->v3d, tgpi->ob, tgpi->gpl, p2d, NULL, &pt->x); + gp_stroke_convertcoords_tpoint(tgpi->scene, tgpi->ar, tgpi->ob, tgpi->gpl, p2d, NULL, &pt->x); pt->pressure = 1.0f; pt->strength = tgpi->brush->gpencil_settings->draw_strength; @@ -365,7 +365,7 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi) if (tgpi->lock_axis > GP_LOCKAXIS_VIEW) { bGPDspoint *tpt = gps->points; float origin[3]; - ED_gp_get_drawing_reference(tgpi->v3d, tgpi->scene, tgpi->ob, tgpi->gpl, + ED_gp_get_drawing_reference(tgpi->scene, tgpi->ob, tgpi->gpl, ts->gpencil_v3d_align, origin); for (int i = 0; i < gps->totpoints; i++, tpt++) { diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c index aff026955d1..73be10a537f 100644 --- a/source/blender/editors/gpencil/gpencil_utils.c +++ b/source/blender/editors/gpencil/gpencil_utils.c @@ -737,9 +737,8 @@ void gp_point_to_xy_fl( */ bool gp_point_xy_to_3d(GP_SpaceConversion *gsc, Scene *scene, const float screen_co[2], float r_out[3]) { - View3D *v3d = gsc->sa->spacedata.first; - RegionView3D *rv3d = gsc->ar->regiondata; - float *rvec = ED_view3d_cursor3d_get(scene, v3d)->location; + const RegionView3D *rv3d = gsc->ar->regiondata; + float *rvec = scene->cursor.location; float ref[3] = {rvec[0], rvec[1], rvec[2]}; float zfac = ED_view3d_calc_zfac(rv3d, rvec, NULL); @@ -771,7 +770,7 @@ bool gp_point_xy_to_3d(GP_SpaceConversion *gsc, Scene *scene, const float screen * \param[out] r_out: The resulting 2D point data */ void gp_stroke_convertcoords_tpoint( - Scene *scene, ARegion *ar, View3D *v3d, + Scene *scene, ARegion *ar, Object *ob, bGPDlayer *gpl, const tGPspoint *point2D, float *depth, float r_out[3]) @@ -793,7 +792,7 @@ void gp_stroke_convertcoords_tpoint( /* Current method just converts each point in screen-coordinates to * 3D-coordinates using the 3D-cursor as reference. */ - ED_gp_get_drawing_reference(v3d, scene, ob, gpl, ts->gpencil_v3d_align, rvec); + ED_gp_get_drawing_reference(scene, ob, gpl, ts->gpencil_v3d_align, rvec); zfac = ED_view3d_calc_zfac(ar->regiondata, rvec, NULL); if (ED_view3d_project_float_global(ar, rvec, mval_prj, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) { @@ -812,10 +811,10 @@ void gp_stroke_convertcoords_tpoint( * \param[out] r_vec : Reference point found */ void ED_gp_get_drawing_reference( - View3D *v3d, Scene *scene, Object *ob, bGPDlayer *UNUSED(gpl), + const Scene *scene, const Object *ob, bGPDlayer *UNUSED(gpl), char align_flag, float r_vec[3]) { - const float *fp = ED_view3d_cursor3d_get(scene, v3d)->location; + const float *fp = scene->cursor.location; /* if using a gpencil object at cursor mode, can use the location of the object */ if (align_flag & GP_PROJECT_VIEWSPACE) { @@ -841,7 +840,8 @@ void ED_gp_get_drawing_reference( /** * Reproject all points of the stroke to a plane locked to axis to avoid stroke offset */ -void ED_gp_project_stroke_to_plane(Object *ob, RegionView3D *rv3d, bGPDstroke *gps, const float origin[3], const int axis) +void ED_gp_project_stroke_to_plane( + const Object *ob, const RegionView3D *rv3d, bGPDstroke *gps, const float origin[3], const int axis) { float plane_normal[3]; float vn[3]; @@ -887,7 +887,8 @@ void ED_gp_project_stroke_to_plane(Object *ob, RegionView3D *rv3d, bGPDstroke *g * Reproject given point to a plane locked to axis to avoid stroke offset * \param[in, out] pt : Point to affect */ -void ED_gp_project_point_to_plane(Object *ob, RegionView3D *rv3d, const float origin[3], const int axis, bGPDspoint *pt) +void ED_gp_project_point_to_plane( + const Object *ob, const RegionView3D *rv3d, const float origin[3], const int axis, bGPDspoint *pt) { float plane_normal[3]; float vn[3]; |