From a48186c5d74b3d353c5c65cd4a930dd98cc9a603 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 8 May 2018 14:18:09 +0200 Subject: Orientation for 3D cursor Currently set when setting the cursor location, optionally used as an orientation type. Intended for use by tools too. See: D3208 --- source/blender/editors/transform/transform.c | 2 +- source/blender/editors/transform/transform_constraints.c | 4 ++++ source/blender/editors/transform/transform_generics.c | 2 +- source/blender/editors/transform/transform_manipulator_3d.c | 9 ++++++++- source/blender/editors/transform/transform_orientations.c | 7 +++++++ 5 files changed, 21 insertions(+), 3 deletions(-) (limited to 'source/blender/editors/transform') diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 6b36e738cc0..41cc2087dea 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -2953,7 +2953,7 @@ static void initBend(TransInfo *t) data = MEM_callocN(sizeof(*data), __func__); - curs = ED_view3d_cursor3d_get(t->scene, t->view); + curs = ED_view3d_cursor3d_get(t->scene, t->view)->location; copy_v3_v3(data->warp_sta, curs); ED_view3d_win_to_3d(t->sa->spacedata.first, t->ar, curs, mval_fl, data->warp_end); diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c index bd03c0cedba..0b222e54a67 100644 --- a/source/blender/editors/transform/transform_constraints.c +++ b/source/blender/editors/transform/transform_constraints.c @@ -689,6 +689,10 @@ void setUserConstraint(TransInfo *t, short orientation, int mode, const char fte BLI_snprintf(text, sizeof(text), ftext, IFACE_("view")); setConstraint(t, t->spacemtx, mode, text); break; + case V3D_MANIP_CURSOR: + BLI_snprintf(text, sizeof(text), ftext, IFACE_("cursor")); + setConstraint(t, t->spacemtx, mode, text); + break; case V3D_MANIP_GIMBAL: BLI_snprintf(text, sizeof(text), ftext, IFACE_("gimbal")); setConstraint(t, t->spacemtx, mode, text); diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index 195c2ef3986..c3acf8c4350 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -1791,7 +1791,7 @@ void calculateCenterCursor(TransInfo *t, float r_center[3]) { const float *cursor; - cursor = ED_view3d_cursor3d_get(t->scene, t->view); + cursor = ED_view3d_cursor3d_get(t->scene, t->view)->location; copy_v3_v3(r_center, cursor); /* If edit or pose mode, move cursor in local space */ diff --git a/source/blender/editors/transform/transform_manipulator_3d.c b/source/blender/editors/transform/transform_manipulator_3d.c index c3c4abbda37..502cff9a243 100644 --- a/source/blender/editors/transform/transform_manipulator_3d.c +++ b/source/blender/editors/transform/transform_manipulator_3d.c @@ -669,6 +669,13 @@ int ED_transform_calc_manipulator_stats( copy_m4_m3(rv3d->twmat, mat); break; } + case V3D_MANIP_CURSOR: + { + float mat[3][3]; + quat_to_mat3(mat, ED_view3d_cursor3d_get(scene, v3d)->rotation); + copy_m4_m3(rv3d->twmat, mat); + break; + } case V3D_MANIP_CUSTOM: { TransformOrientation *custom_orientation = BKE_scene_transform_orientation_find( @@ -1083,7 +1090,7 @@ static void manipulator_prepare_mat( copy_v3_v3(rv3d->twmat[3], tbounds->center); break; case V3D_AROUND_CURSOR: - copy_v3_v3(rv3d->twmat[3], ED_view3d_cursor3d_get(scene, v3d)); + copy_v3_v3(rv3d->twmat[3], ED_view3d_cursor3d_get(scene, v3d)->location); break; } } diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c index 9e6f4847b5b..c1a2c99e26d 100644 --- a/source/blender/editors/transform/transform_orientations.c +++ b/source/blender/editors/transform/transform_orientations.c @@ -481,6 +481,13 @@ void initTransformOrientation(bContext *C, TransInfo *t) unit_m3(t->spacemtx); } break; + case V3D_MANIP_CURSOR: + { + const View3DCursor *cursor = ED_view3d_cursor3d_get(t->scene, CTX_wm_view3d(C)); + BLI_strncpy(t->spacename, IFACE_("cursor"), sizeof(t->spacename)); + quat_to_mat3(t->spacemtx, cursor->rotation); + break; + } case V3D_MANIP_CUSTOM: BLI_strncpy(t->spacename, t->custom_orientation->name, sizeof(t->spacename)); -- cgit v1.2.3