diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-09-18 07:03:50 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-09-18 07:04:55 +0300 |
commit | add961c2097287bb338072aae82e1564bc8714a2 (patch) | |
tree | b60fd48ad17259fce25ae5ba8d1a9d4a770d60af | |
parent | e16e17486baa82d5f15fec911ecc648ee093f628 (diff) |
Correct view orientation update in last commit
-rw-r--r-- | source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c b/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c index 07247ebad0e..b7aca5811be 100644 --- a/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c +++ b/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c @@ -128,19 +128,33 @@ static void gizmo_mesh_spin_init_setup(const bContext *UNUSED(C), wmGizmoGroup * static void gizmo_mesh_spin_init_refresh(const bContext *C, wmGizmoGroup *gzgroup); +static void gizmo_mesh_spin_init_refresh_axis_orientation( + wmGizmoGroup *gzgroup, + int axis_index, const float axis_vec[3]) +{ + GizmoGroupData_SpinInit *ggd = gzgroup->customdata; + wmGizmo *gz = ggd->gizmos.xyz_view[axis_index]; + WM_gizmo_set_matrix_rotation_from_z_axis(gz, axis_vec); + + PointerRNA *ptr = WM_gizmo_operator_set(gz, 0, ggd->data.ot_spin, NULL); + RNA_float_set_array(ptr, "axis", axis_vec); +} + + static void gizmo_mesh_spin_init_draw_prepare( const bContext *C, wmGizmoGroup *gzgroup) { GizmoGroupData_SpinInit *ggd = gzgroup->customdata; RegionView3D *rv3d = CTX_wm_region_view3d(C); + float viewinv_m3[3][3]; + copy_m3_m4(viewinv_m3, rv3d->viewinv); + /* Avoid slowdown on view adjustments. */ if ((rv3d->rflag & RV3D_NAVIGATING) == 0) { Scene *scene = CTX_data_scene(C); switch (scene->orientation_type) { case V3D_MANIP_VIEW: { - float viewinv_m3[3][3]; - copy_m3_m4(viewinv_m3, rv3d->viewinv); if (!equals_m3m3(viewinv_m3, ggd->prev.viewinv_m3)) { /* Take care calling refresh from draw_prepare, * this should be OK because it's only adjusting the cage orientation. */ @@ -150,6 +164,12 @@ static void gizmo_mesh_spin_init_draw_prepare( } } } + + /* Refresh handled above when using view orientation. */ + if (!equals_m3m3(viewinv_m3, ggd->prev.viewinv_m3)) { + gizmo_mesh_spin_init_refresh_axis_orientation(gzgroup, 3, rv3d->viewinv[2]); + copy_m3_m4(ggd->prev.viewinv_m3, rv3d->viewinv); + } } static void gizmo_mesh_spin_init_refresh(const bContext *C, wmGizmoGroup *gzgroup) @@ -170,22 +190,11 @@ static void gizmo_mesh_spin_init_refresh(const bContext *C, wmGizmoGroup *gzgrou float mat[3][3]; ED_transform_calc_orientation_from_type(C, mat); for (int i = 0; i < 3; i++) { - wmGizmo *gz = ggd->gizmos.xyz_view[i]; - WM_gizmo_set_matrix_rotation_from_z_axis(gz, mat[i]); + gizmo_mesh_spin_init_refresh_axis_orientation(gzgroup, i, mat[i]); } { - wmGizmo *gz = ggd->gizmos.xyz_view[3]; - WM_gizmo_set_matrix_rotation_from_z_axis(gz, rv3d->viewinv[2]); - } - - for (int i = 0; i < ARRAY_SIZE(ggd->gizmos.xyz_view); i++) { - wmGizmo *gz = ggd->gizmos.xyz_view[i]; - PointerRNA *ptr = WM_gizmo_operator_set(gz, 0, ggd->data.ot_spin, NULL); - PropertyRNA *prop; - if ((prop = RNA_struct_find_property(ptr, "axis"))) { - RNA_property_float_set_array(ptr, prop, gz->matrix_basis[2]); - } + gizmo_mesh_spin_init_refresh_axis_orientation(gzgroup, 3, rv3d->viewinv[2]); } /* Needed to test view orientation changes. */ |