diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-05-10 13:24:07 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-05-10 13:24:07 +0300 |
commit | 27da2db0caf77b2f4cae443c3d3146d517a1cc4b (patch) | |
tree | 107eea89148ff7c5b4544cc6463b1236ccd73b16 /source/blender/editors | |
parent | e6814acf13d37f002f5fe6a20594970fcd186c2e (diff) |
3D View: utility to get matrix from cursor
Diffstat (limited to 'source/blender/editors')
4 files changed, 17 insertions, 3 deletions
diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index a34571fef44..bb86c7ba6c5 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -98,6 +98,8 @@ typedef struct ViewDepths { } ViewDepths; struct View3DCursor *ED_view3d_cursor3d_get(struct Scene *scene, struct View3D *v3d); +void ED_view3d_cursor3d_calc_mat3(const struct Scene *scene, const struct View3D *v3d, float mat[3][3]); +void ED_view3d_cursor3d_calc_mat4(const struct Scene *scene, const struct View3D *v3d, float mat[4][4]); void ED_view3d_cursor3d_position(struct bContext *C, float fp[3], const int mval[2]); void ED_view3d_cursor3d_update(struct bContext *C, const int mval[2]); diff --git a/source/blender/editors/space_view3d/view3d_utils.c b/source/blender/editors/space_view3d/view3d_utils.c index 9ce427fb830..bc6d174efa0 100644 --- a/source/blender/editors/space_view3d/view3d_utils.c +++ b/source/blender/editors/space_view3d/view3d_utils.c @@ -81,6 +81,19 @@ View3DCursor *ED_view3d_cursor3d_get(Scene *scene, View3D *v3d) } } +void ED_view3d_cursor3d_calc_mat3(const Scene *scene, const View3D *v3d, float mat[3][3]) +{ + const View3DCursor *cursor = ED_view3d_cursor3d_get((Scene *)scene, (View3D *)v3d); + quat_to_mat3(mat, cursor->rotation); +} + +void ED_view3d_cursor3d_calc_mat4(const Scene *scene, const View3D *v3d, float mat[4][4]) +{ + const View3DCursor *cursor = ED_view3d_cursor3d_get((Scene *)scene, (View3D *)v3d); + quat_to_mat4(mat, cursor->rotation); + copy_v3_v3(mat[3], cursor->location); +} + Camera *ED_view3d_camera_data_get(View3D *v3d, RegionView3D *rv3d) { /* establish the camera object, so we can default to view mapping if anything is wrong with it */ diff --git a/source/blender/editors/transform/transform_manipulator_3d.c b/source/blender/editors/transform/transform_manipulator_3d.c index 1e9138449d0..c8248fa3198 100644 --- a/source/blender/editors/transform/transform_manipulator_3d.c +++ b/source/blender/editors/transform/transform_manipulator_3d.c @@ -672,7 +672,7 @@ int ED_transform_calc_manipulator_stats( case V3D_MANIP_CURSOR: { float mat[3][3]; - quat_to_mat3(mat, ED_view3d_cursor3d_get(scene, v3d)->rotation); + ED_view3d_cursor3d_calc_mat3(scene, v3d, mat); copy_m4_m3(rv3d->twmat, mat); break; } diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c index c1a2c99e26d..aeea8930ccb 100644 --- a/source/blender/editors/transform/transform_orientations.c +++ b/source/blender/editors/transform/transform_orientations.c @@ -483,9 +483,8 @@ void initTransformOrientation(bContext *C, TransInfo *t) 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); + ED_view3d_cursor3d_calc_mat3(t->scene, CTX_wm_view3d(C), t->spacemtx); break; } case V3D_MANIP_CUSTOM: |