Manipulator: utility to get matrix w/o offset
authorCampbell Barton <ideasman42@gmail.com>
Mon, 14 May 2018 21:15:15 +0000 (23:15 +0200)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 14 May 2018 21:15:44 +0000 (23:15 +0200)
source/blender/editors/manipulator_library/manipulator_types/cage2d_manipulator.c
source/blender/windowmanager/manipulators/WM_manipulator_api.h
source/blender/windowmanager/manipulators/intern/wm_manipulator.c

index 784c03be949eb2edae72e4114b4e143a30b4e9dc..fe748f33d351f8f0525c2acf55d5ab6d5e908f8b 100644 (file)
 #define MANIPULATOR_RESIZER_SIZE 10.0f
 #define MANIPULATOR_MARGIN_OFFSET_SCALE 1.5f
 
-static void manipulator_calc_matrix_final_no_offset(
-        const wmManipulator *mpr, float orig_matrix_final_no_offset[4][4])
-{
-       float mat_identity[4][4];
-       struct WM_ManipulatorMatrixParams params = {NULL};
-       unit_m4(mat_identity);
-       params.matrix_offset = mat_identity;
-       WM_manipulator_calc_matrix_final_params(mpr, &params, orig_matrix_final_no_offset);
-}
-
 static void manipulator_calc_rect_view_scale(
         const wmManipulator *mpr, const float dims[2], float scale[2])
 {
@@ -88,7 +78,7 @@ static void manipulator_calc_rect_view_scale(
                asp[1] = dims[0] / dims[1];
        }
        float x_axis[3], y_axis[3];
-       manipulator_calc_matrix_final_no_offset(mpr, matrix_final_no_offset);
+       WM_manipulator_calc_matrix_final_no_offset(mpr, matrix_final_no_offset);
        mul_v3_mat3_m4v3(x_axis, matrix_final_no_offset, mpr->matrix_offset[0]);
        mul_v3_mat3_m4v3(y_axis, matrix_final_no_offset, mpr->matrix_offset[1]);
 
@@ -841,7 +831,7 @@ static int manipulator_cage2d_invoke(
        RectTransformInteraction *data = MEM_callocN(sizeof(RectTransformInteraction), "cage_interaction");
 
        copy_m4_m4(data->orig_matrix_offset, mpr->matrix_offset);
-       manipulator_calc_matrix_final_no_offset(mpr, data->orig_matrix_final_no_offset);
+       WM_manipulator_calc_matrix_final_no_offset(mpr, data->orig_matrix_final_no_offset);
 
        if (manipulator_window_project_2d(
                C, mpr, (const float[2]){UNPACK2(event->mval)}, 2, false, data->orig_mouse) == 0)
index 748cc18480f2af11da1d4e031cffc6a1cd7cf4bc..b88956ac28de7c0ec91ace720b76424e72699ec0 100644 (file)
@@ -125,8 +125,11 @@ struct WM_ManipulatorMatrixParams {
 void WM_manipulator_calc_matrix_final_params(
         const struct wmManipulator *mpr, const struct WM_ManipulatorMatrixParams *params,
         float r_mat[4][4]);
+void WM_manipulator_calc_matrix_final_no_offset(
+        const struct wmManipulator *mpr, float r_mat[4][4]);
 
-void WM_manipulator_calc_matrix_final(const struct wmManipulator *mpr, float r_mat[4][4]);
+void WM_manipulator_calc_matrix_final(
+        const struct wmManipulator *mpr, float r_mat[4][4]);
 
 /* properties */
 void WM_manipulator_properties_create_ptr(struct PointerRNA *ptr, struct wmManipulatorType *wt);
index 42232950cc4c5a0e7e3412db72934d71ac81f3c1..f5a8746f807ee531cd1167ac81dc39cd0a545fe6 100644 (file)
@@ -598,6 +598,22 @@ void WM_manipulator_calc_matrix_final_params(
        mul_m4_m4m4(r_mat, matrix_space, final_matrix);
 }
 
+void WM_manipulator_calc_matrix_final_no_offset(const wmManipulator *mpr, float r_mat[4][4])
+{
+       float mat_identity[4][4];
+       unit_m4(mat_identity);
+
+       WM_manipulator_calc_matrix_final_params(
+               mpr,
+               &((struct WM_ManipulatorMatrixParams) {
+                   .matrix_space = NULL,
+                   .matrix_basis = NULL,
+                   .matrix_offset = mat_identity,
+                   .scale_final = NULL,
+               }), r_mat
+       );
+}
+
 void WM_manipulator_calc_matrix_final(const wmManipulator *mpr, float r_mat[4][4])
 {
        WM_manipulator_calc_matrix_final_params(