3D View: utility to get matrix from cursor
authorCampbell Barton <ideasman42@gmail.com>
Thu, 10 May 2018 10:24:07 +0000 (12:24 +0200)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 10 May 2018 10:24:07 +0000 (12:24 +0200)
source/blender/editors/include/ED_view3d.h
source/blender/editors/space_view3d/view3d_utils.c
source/blender/editors/transform/transform_manipulator_3d.c
source/blender/editors/transform/transform_orientations.c

index a34571fef44ec8c0e9ca0fb95bd3d26864b5ffef..bb86c7ba6c593c433b9961141685aaa03386eb21 100644 (file)
@@ -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]);
 
index 9ce427fb83028ebc44c9603dc283338e239e0300..bc6d174efa0824679b0c4f3b7b72169d7ff34c13 100644 (file)
@@ -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 */
index 1e9138449d02a1e7f82e6c1e01ec7e1f3348dfec..c8248fa3198bafe7619f62c816e166c2296cfc2c 100644 (file)
@@ -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;
                        }
index c1a2c99e26d6cd77592a2ed88e349bc655fda108..aeea8930ccb2e48d6284dea13f464eb987846ae9 100644 (file)
@@ -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: