diff --git a/source/blender/editors/manipulator_library/arrow2d_manipulator.c b/source/blender/editors/manipulator_library/arrow2d_manipulator.c index 159fcd658ec..5e7975d05e3 100644 --- a/source/blender/editors/manipulator_library/arrow2d_manipulator.c +++ b/source/blender/editors/manipulator_library/arrow2d_manipulator.c @@ -68,7 +68,7 @@ typedef struct ArrowManipulator2D { } ArrowManipulator2D; -static void arrow2d_draw_geom(ArrowManipulator2D *arrow, const float origin[2], const float color[4]) +static void arrow2d_draw_geom(ArrowManipulator2D *arrow, const float matrix[4][4], const float color[4]) { const float size = 0.11f; const float size_h = size / 2.0f; @@ -78,11 +78,13 @@ static void arrow2d_draw_geom(ArrowManipulator2D *arrow, const float origin[2], uint pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT); gpuPushMatrix(); - gpuTranslate2fv(origin); + gpuMultMatrix(matrix); gpuScaleUniform(arrow->manipulator.scale); gpuRotate2D(RAD2DEGF(arrow->angle)); /* local offset */ - gpuTranslate2f(arrow->manipulator.offset[0] + draw_line_ofs, arrow->manipulator.offset[1]); + gpuTranslate2f( + arrow->manipulator.matrix_offset[3][0] + draw_line_ofs, + arrow->manipulator.matrix_offset[3][1]); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -113,14 +115,14 @@ static void manipulator_arrow2d_draw(const bContext *UNUSED(C), struct wmManipul glLineWidth(mpr->line_width); glEnable(GL_BLEND); - arrow2d_draw_geom(arrow, mpr->origin, col); + arrow2d_draw_geom(arrow, mpr->matrix, col); glDisable(GL_BLEND); if (mpr->interaction_data) { ManipulatorInteraction *inter = arrow->manipulator.interaction_data; glEnable(GL_BLEND); - arrow2d_draw_geom(arrow, inter->init_origin, (const float[4]){0.5f, 0.5f, 0.5f, 0.5f}); + arrow2d_draw_geom(arrow, inter->init_matrix, (const float[4]){0.5f, 0.5f, 0.5f, 0.5f}); glDisable(GL_BLEND); } } @@ -139,7 +141,7 @@ static void manipulator_arrow2d_invoke( { ManipulatorInteraction *inter = MEM_callocN(sizeof(ManipulatorInteraction), __func__); - copy_v2_v2(inter->init_origin, mpr->origin); + copy_m4_m4(inter->init_matrix, mpr->matrix); mpr->interaction_data = inter; } @@ -152,7 +154,7 @@ static int manipulator_arrow2d_test_select( float mval_local[2]; copy_v2_v2(mval_local, mval); - sub_v2_v2(mval_local, mpr->origin); + sub_v2_v2(mval_local, mpr->matrix[3]); float line[2][2]; line[0][0] = line[0][1] = line[1][0] = 0.0f; diff --git a/source/blender/editors/manipulator_library/arrow3d_manipulator.c b/source/blender/editors/manipulator_library/arrow3d_manipulator.c index f0f7470c058..1d3cb281af1 100644 --- a/source/blender/editors/manipulator_library/arrow3d_manipulator.c +++ b/source/blender/editors/manipulator_library/arrow3d_manipulator.c @@ -89,12 +89,12 @@ typedef struct ArrowManipulator3D { /* -------------------------------------------------------------------- */ -static void manipulator_arrow_position_get(wmManipulator *mpr, float r_pos[3]) +static void manipulator_arrow_matrix_world_get(wmManipulator *mpr, float r_matrix[4][4]) { ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr; - mul_v3_v3fl(r_pos, arrow->direction, arrow->data.offset); - add_v3_v3(r_pos, arrow->manipulator.origin); + copy_m4_m4(r_matrix, arrow->manipulator.matrix); + madd_v3_v3fl(r_matrix[3], arrow->direction, arrow->data.offset); } static void arrow_draw_geom(const ArrowManipulator3D *arrow, const bool select, const float color[4]) @@ -190,10 +190,10 @@ static void arrow_draw_intern(ArrowManipulator3D *arrow, const bool select, cons float col[4]; float rot[3][3]; float mat[4][4]; - float final_pos[3]; + float final_matrix[4][4]; manipulator_color_get(&arrow->manipulator, highlight, col); - manipulator_arrow_position_get(&arrow->manipulator, final_pos); + manipulator_arrow_matrix_world_get(&arrow->manipulator, final_matrix); if (arrow->flag & ARROW_UP_VECTOR_SET) { copy_v3_v3(rot[2], arrow->direction); @@ -204,12 +204,12 @@ static void arrow_draw_intern(ArrowManipulator3D *arrow, const bool select, cons rotation_between_vecs_to_mat3(rot, up, arrow->direction); } copy_m4_m3(mat, rot); - copy_v3_v3(mat[3], final_pos); + copy_v3_v3(mat[3], final_matrix[3]); mul_mat3_m4_fl(mat, arrow->manipulator.scale); gpuPushMatrix(); gpuMultMatrix(mat); - gpuTranslate3fv(arrow->manipulator.offset); + gpuMultMatrix(arrow->manipulator.matrix_offset); glEnable(GL_BLEND); arrow_draw_geom(arrow, select, col); @@ -221,12 +221,12 @@ static void arrow_draw_intern(ArrowManipulator3D *arrow, const bool select, cons ManipulatorInteraction *inter = arrow->manipulator.interaction_data; copy_m4_m3(mat, rot); - copy_v3_v3(mat[3], inter->init_origin); + copy_v3_v3(mat[3], inter->init_matrix[3]); mul_mat3_m4_fl(mat, inter->init_scale); gpuPushMatrix(); gpuMultMatrix(mat); - gpuTranslate3fv(arrow->manipulator.offset); + gpuMultMatrix(arrow->manipulator.matrix_offset); glEnable(GL_BLEND); arrow_draw_geom(arrow, select, (const float [4]){0.5f, 0.5f, 0.5f, 0.5f}); @@ -269,7 +269,7 @@ static void manipulator_arrow_modal(bContext *C, wmManipulator *mpr, const wmEve bool use_vertical = false; - copy_v3_v3(orig_origin, inter->init_origin); + copy_v3_v3(orig_origin, inter->init_matrix[3]); orig_origin[3] = 1.0f; add_v3_v3v3(offset, orig_origin, arrow->direction); offset[3] = 1.0f; @@ -313,7 +313,7 @@ static void manipulator_arrow_modal(bContext *C, wmManipulator *mpr, const wmEve float zfac = ED_view3d_calc_zfac(rv3d, orig_origin, NULL); ED_view3d_win_to_delta(ar, dir2d_final, offset, zfac); - add_v3_v3v3(orig_origin, offset, inter->init_origin); + add_v3_v3v3(orig_origin, offset, inter->init_matrix[3]); /* calculate view vector for the new position */ if (rv3d->is_persp) { @@ -402,7 +402,7 @@ static void manipulator_arrow_invoke( inter->init_scale = mpr->scale; - manipulator_arrow_position_get(mpr, inter->init_origin); + manipulator_arrow_matrix_world_get(mpr, inter->init_matrix); mpr->interaction_data = inter; } @@ -535,7 +535,7 @@ static void MANIPULATOR_WT_arrow_3d(wmManipulatorType *wt) /* api callbacks */ wt->draw = manipulator_arrow_draw; wt->draw_select = manipulator_arrow_draw_select; - wt->position_get = manipulator_arrow_position_get; + wt->matrix_world_get = manipulator_arrow_matrix_world_get; wt->modal = manipulator_arrow_modal; wt->setup = manipulator_arrow_setup; wt->invoke = manipulator_arrow_invoke; diff --git a/source/blender/editors/manipulator_library/cage2d_manipulator.c b/source/blender/editors/manipulator_library/cage2d_manipulator.c index 9236a5ef10e..bf6c23f98e7 100644 --- a/source/blender/editors/manipulator_library/cage2d_manipulator.c +++ b/source/blender/editors/manipulator_library/cage2d_manipulator.c @@ -219,8 +219,8 @@ static void manipulator_rect_transform_draw(const bContext *UNUSED(C), wmManipul BLI_assert(cage->style != -1); gpuPushMatrix(); - gpuTranslate2f(mpr->origin[0] + mpr->offset[0], - mpr->origin[1] + mpr->offset[1]); + gpuMultMatrix(mpr->matrix); + gpuMultMatrix(mpr->matrix_offset); if (cage->style & ED_MANIPULATOR_RECT_TRANSFORM_STYLE_SCALE_UNIFORM) gpuScaleUniform(cage->scale[0]); else @@ -281,9 +281,9 @@ static int manipulator_rect_transform_test_select( float aspx = 1.0f, aspy = 1.0f; /* rotate mouse in relation to the center and relocate it */ - sub_v2_v2v2(point_local, mouse, mpr->origin); - point_local[0] -= mpr->offset[0]; - point_local[1] -= mpr->offset[1]; + sub_v2_v2v2(point_local, mouse, mpr->matrix[3]); + point_local[0] -= mpr->matrix_offset[3][0]; + point_local[1] -= mpr->matrix_offset[3][1]; //rotate_m2(matrot, -cage->transform.rotation); if (cage->style & ED_MANIPULATOR_RECT_TRANSFORM_STYLE_SCALE_UNIFORM) @@ -419,7 +419,7 @@ static void manipulator_rect_transform_invoke( Cage2D *cage = (Cage2D *)mpr; RectTransformInteraction *data = MEM_callocN(sizeof(RectTransformInteraction), "cage_interaction"); - copy_v2_v2(data->orig_offset, mpr->offset); + copy_v2_v2(data->orig_offset, mpr->matrix_offset[3]); copy_v2_v2(data->orig_scale, cage->scale); data->orig_mouse[0] = event->mval[0]; @@ -435,26 +435,26 @@ static void manipulator_rect_transform_modal( Cage2D *cage = (Cage2D *)mpr; RectTransformInteraction *data = mpr->interaction_data; /* needed here as well in case clamping occurs */ - const float orig_ofx = mpr->offset[0], orig_ofy = mpr->offset[1]; + const float orig_ofx = mpr->matrix_offset[3][0], orig_ofy = mpr->matrix_offset[3][1]; const float valuex = (event->mval[0] - data->orig_mouse[0]); const float valuey = (event->mval[1] - data->orig_mouse[1]); if (mpr->highlight_part == ED_MANIPULATOR_RECT_TRANSFORM_INTERSECT_TRANSLATE) { - mpr->offset[0] = data->orig_offset[0] + valuex; - mpr->offset[1] = data->orig_offset[1] + valuey; + mpr->matrix_offset[3][0] = data->orig_offset[0] + valuex; + mpr->matrix_offset[3][1] = data->orig_offset[1] + valuey; } else if (mpr->highlight_part == ED_MANIPULATOR_RECT_TRANSFORM_INTERSECT_SCALEX_LEFT) { - mpr->offset[0] = data->orig_offset[0] + valuex / 2.0; + mpr->matrix_offset[3][0] = data->orig_offset[0] + valuex / 2.0; cage->scale[0] = (cage->w * data->orig_scale[0] - valuex) / cage->w; } else if (mpr->highlight_part == ED_MANIPULATOR_RECT_TRANSFORM_INTERSECT_SCALEX_RIGHT) { - mpr->offset[0] = data->orig_offset[0] + valuex / 2.0; + mpr->matrix_offset[3][0] = data->orig_offset[0] + valuex / 2.0; cage->scale[0] = (cage->w * data->orig_scale[0] + valuex) / cage->w; } else if (mpr->highlight_part == ED_MANIPULATOR_RECT_TRANSFORM_INTERSECT_SCALEY_DOWN) { - mpr->offset[1] = data->orig_offset[1] + valuey / 2.0; + mpr->matrix_offset[3][1] = data->orig_offset[1] + valuey / 2.0; if (cage->style & ED_MANIPULATOR_RECT_TRANSFORM_STYLE_SCALE_UNIFORM) { cage->scale[0] = (cage->h * data->orig_scale[0] - valuey) / cage->h; @@ -464,7 +464,7 @@ static void manipulator_rect_transform_modal( } } else if (mpr->highlight_part == ED_MANIPULATOR_RECT_TRANSFORM_INTERSECT_SCALEY_UP) { - mpr->offset[1] = data->orig_offset[1] + valuey / 2.0; + mpr->matrix_offset[3][1] = data->orig_offset[1] + valuey / 2.0; if (cage->style & ED_MANIPULATOR_RECT_TRANSFORM_STYLE_SCALE_UNIFORM) { cage->scale[0] = (cage->h * data->orig_scale[0] + valuey) / cage->h; @@ -480,18 +480,18 @@ static void manipulator_rect_transform_modal( cage->scale[0] < MANIPULATOR_RECT_MIN_WIDTH / cage->w) { cage->scale[0] = max_ff(MANIPULATOR_RECT_MIN_WIDTH / cage->h, MANIPULATOR_RECT_MIN_WIDTH / cage->w); - mpr->offset[0] = orig_ofx; - mpr->offset[1] = orig_ofy; + mpr->matrix_offset[3][0] = orig_ofx; + mpr->matrix_offset[3][1] = orig_ofy; } } else { if (cage->scale[0] < MANIPULATOR_RECT_MIN_WIDTH / cage->w) { cage->scale[0] = MANIPULATOR_RECT_MIN_WIDTH / cage->w; - mpr->offset[0] = orig_ofx; + mpr->matrix_offset[3][0] = orig_ofx; } if (cage->scale[1] < MANIPULATOR_RECT_MIN_WIDTH / cage->h) { cage->scale[1] = MANIPULATOR_RECT_MIN_WIDTH / cage->h; - mpr->offset[1] = orig_ofy; + mpr->matrix_offset[3][1] = orig_ofy; } } @@ -499,7 +499,7 @@ static void manipulator_rect_transform_modal( mpr_prop = WM_manipulator_property_find(mpr, "offset"); if (mpr_prop->prop != NULL) { - RNA_property_float_set_array(&mpr_prop->ptr, mpr_prop->prop, mpr->offset); + RNA_property_float_set_array(&mpr_prop->ptr, mpr_prop->prop, mpr->matrix_offset[3]); RNA_property_update(C, &mpr_prop->ptr, mpr_prop->prop); } @@ -523,7 +523,7 @@ static void manipulator_rect_transform_property_update(wmManipulator *mpr, wmMan Cage2D *cage = (Cage2D *)mpr; if (STREQ(mpr_prop->idname, "offset")) { - manipulator_rect_transform_get_prop_value(mpr, mpr_prop, mpr->offset); + manipulator_rect_transform_get_prop_value(mpr, mpr_prop, mpr->matrix_offset[3]); } else if (STREQ(mpr_prop->idname, "scale")) { manipulator_rect_transform_get_prop_value(mpr, mpr_prop, cage->scale); diff --git a/source/blender/editors/manipulator_library/dial3d_manipulator.c b/source/blender/editors/manipulator_library/dial3d_manipulator.c index 926bf1f2bdc..0aa3e929439 100644 --- a/source/blender/editors/manipulator_library/dial3d_manipulator.c +++ b/source/blender/editors/manipulator_library/dial3d_manipulator.c @@ -110,7 +110,7 @@ static void dial_calc_matrix(const DialManipulator *dial, float mat[4][4]) rotation_between_vecs_to_mat3(rot, up, dial->direction); copy_m4_m3(mat, rot); - copy_v3_v3(mat[3], dial->manipulator.origin); + copy_v3_v3(mat[3], dial->manipulator.matrix[3]); mul_mat3_m4_fl(mat, dial->manipulator.scale); } @@ -208,12 +208,12 @@ static void dial_ghostarc_get_angles( /* we might need to invert the direction of the angles */ float view_vec[3], axis_vec[3]; - ED_view3d_global_to_vector(rv3d, dial->manipulator.origin, view_vec); + ED_view3d_global_to_vector(rv3d, dial->manipulator.matrix[3], view_vec); normalize_v3_v3(axis_vec, dial->direction); float proj_outer_rel[3]; mul_v3_project_m4_v3(proj_outer_rel, mat, co_outer); - sub_v3_v3(proj_outer_rel, dial->manipulator.origin); + sub_v3_v3(proj_outer_rel, dial->manipulator.matrix[3]); float proj_mval_new_rel[3]; float proj_mval_init_rel[3]; @@ -221,7 +221,7 @@ static void dial_ghostarc_get_angles( float ray_co[3], ray_no[3]; float ray_lambda; - plane_from_point_normal_v3(dial_plane, dial->manipulator.origin, axis_vec); + plane_from_point_normal_v3(dial_plane, dial->manipulator.matrix[3], axis_vec); if (!ED_view3d_win_to_ray(ar, v3d, inter->init_mval, ray_co, ray_no, false) || !isect_ray_plane_v3(ray_co, ray_no, dial_plane, &ray_lambda, false)) @@ -229,7 +229,7 @@ static void dial_ghostarc_get_angles( goto fail; } madd_v3_v3v3fl(proj_mval_init_rel, ray_co, ray_no, ray_lambda); - sub_v3_v3(proj_mval_init_rel, dial->manipulator.origin); + sub_v3_v3(proj_mval_init_rel, dial->manipulator.matrix[3]); if (!ED_view3d_win_to_ray(ar, v3d, mval, ray_co, ray_no, false) || !isect_ray_plane_v3(ray_co, ray_no, dial_plane, &ray_lambda, false)) @@ -237,7 +237,7 @@ static void dial_ghostarc_get_angles( goto fail; } madd_v3_v3v3fl(proj_mval_new_rel, ray_co, ray_no, ray_lambda); - sub_v3_v3(proj_mval_new_rel, dial->manipulator.origin); + sub_v3_v3(proj_mval_new_rel, dial->manipulator.matrix[3]); /* Start direction from mouse or set by user */ const float *proj_init_rel = dial->use_start_direction ? dial->start_direction : proj_mval_init_rel; @@ -284,7 +284,7 @@ static void dial_draw_intern( gpuPushMatrix(); gpuMultMatrix(mat); - gpuTranslate3fv(dial->manipulator.offset); + gpuMultMatrix(dial->manipulator.matrix_offset); /* draw rotation indicator arc first */ if ((dial->manipulator.flag & WM_MANIPULATOR_DRAW_VALUE) && @@ -335,7 +335,7 @@ static void manipulator_dial_draw_select(const bContext *C, wmManipulator *mpr, RegionView3D *rv3d = ar->regiondata; copy_v3_v3(clip_plane, rv3d->viewinv[2]); - clip_plane[3] = -dot_v3v3(rv3d->viewinv[2], mpr->origin); + clip_plane[3] = -dot_v3v3(rv3d->viewinv[2], mpr->matrix[3]); glEnable(GL_CLIP_DISTANCE0); } @@ -363,7 +363,7 @@ static void manipulator_dial_draw(const bContext *C, wmManipulator *mpr) RegionView3D *rv3d = ar->regiondata; copy_v3_v3(clip_plane, rv3d->viewinv[2]); - clip_plane[3] = -dot_v3v3(rv3d->viewinv[2], mpr->origin); + clip_plane[3] = -dot_v3v3(rv3d->viewinv[2], mpr->matrix[3]); clip_plane[3] -= 0.02 * dial->manipulator.scale; glEnable(GL_CLIP_DISTANCE0); diff --git a/source/blender/editors/manipulator_library/grab3d_manipulator.c b/source/blender/editors/manipulator_library/grab3d_manipulator.c index 136613e22c2..e9c9f13cb19 100644 --- a/source/blender/editors/manipulator_library/grab3d_manipulator.c +++ b/source/blender/editors/manipulator_library/grab3d_manipulator.c @@ -87,7 +87,7 @@ static void grab_calc_matrix(const GrabManipulator *grab, float mat[4][4]) rotation_between_vecs_to_mat3(rot, up, grab->direction); copy_m4_m3(mat, rot); - copy_v3_v3(mat[3], grab->manipulator.origin); + copy_v3_v3(mat[3], grab->manipulator.matrix[3]); mul_mat3_m4_fl(mat, grab->manipulator.scale); } @@ -160,7 +160,7 @@ static void grab3d_draw_intern( gpuTranslate3fv(inter->output.co_ofs); } gpuMultMatrix(mat); - gpuTranslate3fv(grab->manipulator.offset); + gpuMultMatrix(grab->manipulator.matrix_offset); glEnable(GL_BLEND); grab_geom_draw(grab, col, select); glDisable(GL_BLEND); @@ -169,7 +169,7 @@ static void grab3d_draw_intern( if (grab->manipulator.interaction_data) { gpuPushMatrix(); gpuMultMatrix(mat); - gpuTranslate3fv(grab->manipulator.offset); + gpuMultMatrix(grab->manipulator.matrix_offset); glEnable(GL_BLEND); grab_geom_draw(grab, (const float [4]){0.5f, 0.5f, 0.5f, 0.5f}, select); glDisable(GL_BLEND); diff --git a/source/blender/editors/manipulator_library/manipulator_library_intern.h b/source/blender/editors/manipulator_library/manipulator_library_intern.h index ec04349ec33..ce71017e7bc 100644 --- a/source/blender/editors/manipulator_library/manipulator_library_intern.h +++ b/source/blender/editors/manipulator_library/manipulator_library_intern.h @@ -50,7 +50,7 @@ typedef struct ManipulatorCommonData { typedef struct ManipulatorInteraction { float init_value; /* initial property value */ - float init_origin[3]; + float init_matrix[4][4]; float init_mval[2]; float init_offset; float init_scale; diff --git a/source/blender/editors/manipulator_library/primitive3d_manipulator.c b/source/blender/editors/manipulator_library/primitive3d_manipulator.c index 743927c4147..d8dbf4a52d6 100644 --- a/source/blender/editors/manipulator_library/primitive3d_manipulator.c +++ b/source/blender/editors/manipulator_library/primitive3d_manipulator.c @@ -118,7 +118,7 @@ static void manipulator_primitive_draw_intern( } copy_m4_m3(mat, rot); - copy_v3_v3(mat[3], prim->manipulator.origin); + copy_v3_v3(mat[3], prim->manipulator.matrix[3]); mul_mat3_m4_fl(mat, prim->manipulator.scale); gpuPushMatrix(); @@ -129,7 +129,7 @@ static void manipulator_primitive_draw_intern( col_inner[3] *= 0.5f; glEnable(GL_BLEND); - gpuTranslate3fv(prim->manipulator.offset); + gpuMultMatrix(prim->manipulator.matrix_offset); manipulator_primitive_draw_geom(col_inner, col_outer, prim->style); glDisable(GL_BLEND); @@ -143,14 +143,14 @@ static void manipulator_primitive_draw_intern( col_outer[3] = 0.8f; copy_m4_m3(mat, rot); - copy_v3_v3(mat[3], inter->init_origin); + copy_v3_v3(mat[3], inter->init_matrix[3]); mul_mat3_m4_fl(mat, inter->init_scale); gpuPushMatrix(); gpuMultMatrix(mat); glEnable(GL_BLEND); - gpuTranslate3fv(prim->manipulator.offset); + gpuMultMatrix(prim->manipulator.matrix_offset); manipulator_primitive_draw_geom(col_inner, col_outer, prim->style); glDisable(GL_BLEND); @@ -191,7 +191,7 @@ static void manipulator_primitive_invoke( { ManipulatorInteraction *inter = MEM_callocN(sizeof(ManipulatorInteraction), __func__); - copy_v3_v3(inter->init_origin, mpr->origin); + copy_m4_m4(inter->init_matrix, mpr->matrix); inter->init_scale = mpr->scale; mpr->interaction_data = inter; diff --git a/source/blender/editors/mesh/editmesh_bisect.c b/source/blender/editors/mesh/editmesh_bisect.c index 8499949f589..2145af0df86 100644 --- a/source/blender/editors/mesh/editmesh_bisect.c +++ b/source/blender/editors/mesh/editmesh_bisect.c @@ -467,7 +467,7 @@ static void manipulator_bisect_prop_depth_get( RNA_property_float_get_array(op->ptr, man->data.prop_plane_co, plane_co); RNA_property_float_get_array(op->ptr, man->data.prop_plane_no, plane_no); - value[0] = dot_v3v3(plane_no, plane_co) - dot_v3v3(plane_no, mpr->origin); + value[0] = dot_v3v3(plane_no, plane_co) - dot_v3v3(plane_no, mpr->matrix[3]); } static void manipulator_bisect_prop_depth_set( @@ -484,7 +484,7 @@ static void manipulator_bisect_prop_depth_set( RNA_property_float_get_array(op->ptr, man->data.prop_plane_no, plane); normalize_v3(plane); - plane[3] = -value[0] - dot_v3v3(plane, mpr->origin); + plane[3] = -value[0] - dot_v3v3(plane, mpr->matrix[3]); /* Keep our location, may be offset simply to be inside the viewport. */ closest_to_plane_normalized_v3(plane_co, plane, plane_co); diff --git a/source/blender/editors/mesh/editmesh_extrude.c b/source/blender/editors/mesh/editmesh_extrude.c index 42683960407..5b02bf2df8a 100644 --- a/source/blender/editors/mesh/editmesh_extrude.c +++ b/source/blender/editors/mesh/editmesh_extrude.c @@ -900,7 +900,7 @@ static void manipulator_spin_prop_depth_get( RNA_property_float_get_array(op->ptr, man->data.prop_axis_co, plane_co); RNA_property_float_get_array(op->ptr, man->data.prop_axis_no, plane_no); - value[0] = dot_v3v3(plane_no, plane_co) - dot_v3v3(plane_no, mpr->origin); + value[0] = dot_v3v3(plane_no, plane_co) - dot_v3v3(plane_no, mpr->matrix[3]); } static void manipulator_spin_prop_depth_set( @@ -917,7 +917,7 @@ static void manipulator_spin_prop_depth_set( RNA_property_float_get_array(op->ptr, man->data.prop_axis_no, plane); normalize_v3(plane); - plane[3] = -value[0] - dot_v3v3(plane, mpr->origin); + plane[3] = -value[0] - dot_v3v3(plane, mpr->matrix[3]); /* Keep our location, may be offset simply to be inside the viewport. */ closest_to_plane_normalized_v3(plane_co, plane, plane_co); diff --git a/source/blender/windowmanager/manipulators/WM_manipulator_types.h b/source/blender/windowmanager/manipulators/WM_manipulator_types.h index ec009a5e7a0..eb8641fcd7e 100644 --- a/source/blender/windowmanager/manipulators/WM_manipulator_types.h +++ b/source/blender/windowmanager/manipulators/WM_manipulator_types.h @@ -75,9 +75,9 @@ struct wmManipulator { int highlight_part; /* center of manipulator in space, 2d or 3d */ - float origin[3]; + float matrix[4][4]; /* custom offset from origin */ - float offset[3]; + float matrix_offset[4][4]; /* runtime property, set the scale while drawing on the viewport */ float scale; /* user defined scale, in addition to the original one */ @@ -193,9 +193,9 @@ typedef struct wmManipulatorType { /* manipulator-specific handler to update manipulator attributes based on the property value */ wmManipulatorFnPropertyUpdate property_update; - /* returns the final position which may be different from the origin, depending on the manipulator. - * used in calculations of scale */ - wmManipulatorFnPositionGet position_get; + /* Returns the final transformation which may be different from the 'matrix', + * depending on the manipulator. */ + wmManipulatorFnMatrixWorldGet matrix_world_get; /* activate a manipulator state when the user clicks on it */ wmManipulatorFnInvoke invoke; diff --git a/source/blender/windowmanager/manipulators/intern/wm_manipulator.c b/source/blender/windowmanager/manipulators/intern/wm_manipulator.c index f24bdb6e697..c28f8ecd331 100644 --- a/source/blender/windowmanager/manipulators/intern/wm_manipulator.c +++ b/source/blender/windowmanager/manipulators/intern/wm_manipulator.c @@ -73,6 +73,10 @@ static wmManipulator *wm_manipulator_create( wmManipulator *mpr = MEM_callocN(wt->struct_size, __func__); mpr->type = wt; + + unit_m4(mpr->matrix); + unit_m4(mpr->matrix_offset); + return mpr; } @@ -213,12 +217,12 @@ PointerRNA *WM_manipulator_set_operator(wmManipulator *mpr, const char *opname) void WM_manipulator_set_origin(wmManipulator *mpr, const float origin[3]) { - copy_v3_v3(mpr->origin, origin); + copy_v3_v3(mpr->matrix[3], origin); } void WM_manipulator_set_offset(wmManipulator *mpr, const float offset[3]) { - copy_v3_v3(mpr->offset, offset); + copy_v3_v3(mpr->matrix_offset[3], offset); } void WM_manipulator_set_flag(wmManipulator *mpr, const int flag, const bool enable) @@ -361,14 +365,14 @@ void wm_manipulator_calculate_scale(wmManipulator *mpr, const bContext *C) if (mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_SCALE_3D) { if (rv3d /*&& (U.manipulator_flag & V3D_DRAW_MANIPULATOR) == 0*/) { /* UserPref flag might be useful for later */ - if (mpr->type->position_get) { - float position[3]; + if (mpr->type->matrix_world_get) { + float matrix_world[4][4]; - mpr->type->position_get(mpr, position); - scale = ED_view3d_pixel_size(rv3d, position) * (float)U.manipulator_scale; + mpr->type->matrix_world_get(mpr, matrix_world); + scale = ED_view3d_pixel_size(rv3d, matrix_world[3]) * (float)U.manipulator_scale; } else { - scale = ED_view3d_pixel_size(rv3d, mpr->origin) * (float)U.manipulator_scale; + scale = ED_view3d_pixel_size(rv3d, mpr->matrix[3]) * (float)U.manipulator_scale; } } else { diff --git a/source/blender/windowmanager/manipulators/wm_manipulator_fn.h b/source/blender/windowmanager/manipulators/wm_manipulator_fn.h index 90eaba74de1..619911b94d7 100644 --- a/source/blender/windowmanager/manipulators/wm_manipulator_fn.h +++ b/source/blender/windowmanager/manipulators/wm_manipulator_fn.h @@ -52,7 +52,7 @@ typedef void (*wmManipulatorFnDrawSelect)(const struct bContext *, struct wmM typedef int (*wmManipulatorFnTestSelect)(struct bContext *, struct wmManipulator *, const struct wmEvent *); typedef void (*wmManipulatorFnModal)(struct bContext *, struct wmManipulator *, const struct wmEvent *, const int); typedef void (*wmManipulatorFnPropertyUpdate)(struct wmManipulator *, struct wmManipulatorProperty *); -typedef void (*wmManipulatorFnPositionGet)(struct wmManipulator *, float[]); +typedef void (*wmManipulatorFnMatrixWorldGet)(struct wmManipulator *, float[4][4]); typedef void (*wmManipulatorFnInvoke)(struct bContext *, struct wmManipulator *, const struct wmEvent *); typedef void (*wmManipulatorFnExit)(struct bContext *, struct wmManipulator *, const bool); typedef int (*wmManipulatorFnCursorGet)(struct wmManipulator *);