Manipulator: run callback when calculating the final matrix
authorCampbell Barton <ideasman42@gmail.com>
Wed, 30 Aug 2017 07:53:32 +0000 (17:53 +1000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 30 Aug 2017 08:04:42 +0000 (18:04 +1000)
source/blender/editors/manipulator_library/manipulator_types/arrow3d_manipulator.c
source/blender/editors/manipulator_library/manipulator_types/dial3d_manipulator.c
source/blender/editors/manipulator_library/manipulator_types/grab3d_manipulator.c
source/blender/windowmanager/manipulators/intern/wm_manipulator.c

index 5c984de2e2776c311920a66cac1c70cc472f6147..21ebbba46cfc169491614f098a4432832d73019b 100644 (file)
@@ -184,16 +184,11 @@ static void arrow_draw_intern(ArrowManipulator3D *arrow, const bool select, cons
 {
        wmManipulator *mpr = &arrow->manipulator;
        float color[4];
-       float matrix_basis_adjust[4][4];
        float matrix_final[4][4];
 
        manipulator_color_get(mpr, highlight, color);
-       manipulator_arrow_matrix_basis_get(mpr, matrix_basis_adjust);
 
-       WM_manipulator_calc_matrix_final_params(
-               mpr, &((struct WM_ManipulatorMatrixParams) {
-                   .matrix_basis = matrix_basis_adjust,
-               }), matrix_final);
+       WM_manipulator_calc_matrix_final(mpr, matrix_final);
 
        gpuPushMatrix();
        gpuMultMatrix(matrix_final);
index 257ccfa88d8089ae5166d6f820c24ac55d38a36e..f637b098cca43f6536511872cd2223a5c6250212 100644 (file)
@@ -96,7 +96,9 @@ typedef struct DialInteraction {
 #define DIAL_WIDTH       1.0f
 #define DIAL_RESOLUTION 32
 
-
+/**
+ * We can't use this for the #wmManipulatorType.matrix_basis_get callback, it conflicts with depth picking.
+ */
 static void dial_calc_matrix(const wmManipulator *mpr, float mat[4][4])
 {
        float rot[3][3];
index 37ad31db6429f36913c9046ead09e381e6d23450..fd1f5a0cf25f8e18ecabdfef5686741e6a8db502 100644 (file)
@@ -175,15 +175,7 @@ static void grab3d_draw_intern(
        float matrix_align[4][4];
 
        manipulator_color_get(mpr, highlight, color);
-
-       {
-               float matrix_basis_adjust[4][4];
-               manipulator_grab_matrix_basis_get(mpr, matrix_basis_adjust);
-               WM_manipulator_calc_matrix_final_params(
-                       mpr, &((struct WM_ManipulatorMatrixParams) {
-                           .matrix_basis = matrix_basis_adjust,
-                       }), matrix_final);
-       }
+       WM_manipulator_calc_matrix_final(mpr, matrix_final);
 
        gpuPushMatrix();
        gpuMultMatrix(matrix_final);
@@ -293,14 +285,7 @@ static int manipulator_grab_invoke(
        }
 #endif
 
-       {
-               float matrix_basis_adjust[4][4];
-               manipulator_grab_matrix_basis_get(mpr, matrix_basis_adjust);
-               WM_manipulator_calc_matrix_final_params(
-                       mpr, &((struct WM_ManipulatorMatrixParams) {
-                           .matrix_basis = matrix_basis_adjust,
-                       }), inter->init_matrix_final);
-       }
+       WM_manipulator_calc_matrix_final(mpr, inter->init_matrix_final);
 
        mpr->interaction_data = inter;
 
index ee7c10aa50b368d4e4b5d958580cc2430b1d4d90..5693c4854c99adcd48b5b973a5bc3b33c2c47285 100644 (file)
@@ -541,8 +541,12 @@ void WM_manipulator_calc_matrix_final_params(
        const float *scale_final = params->scale_final ? params->scale_final : &mpr->scale_final;
 
        float final_matrix[4][4];
-
-       copy_m4_m4(final_matrix, matrix_basis);
+       if (params->matrix_basis == NULL && mpr->type->matrix_basis_get) {
+               mpr->type->matrix_basis_get(mpr, final_matrix);
+       }
+       else {
+               copy_m4_m4(final_matrix, matrix_basis);
+       }
 
        if (mpr->flag & WM_MANIPULATOR_DRAW_OFFSET_SCALE) {
                mul_mat3_m4_fl(final_matrix, *scale_final);
@@ -561,10 +565,10 @@ void WM_manipulator_calc_matrix_final(const wmManipulator *mpr, float r_mat[4][4
        WM_manipulator_calc_matrix_final_params(
                mpr,
                &((struct WM_ManipulatorMatrixParams) {
-                   .matrix_space = mpr->matrix_space,
-                   .matrix_basis = mpr->matrix_basis,
-                   .matrix_offset = mpr->matrix_offset,
-                   .scale_final = &mpr->scale_final,
+                   .matrix_space = NULL,
+                   .matrix_basis = NULL,
+                   .matrix_offset = NULL,
+                   .scale_final = NULL,
                }), r_mat
        );
 }