Fix scale-cage refresh w/ view orientation
authorCampbell Barton <ideasman42@gmail.com>
Tue, 11 Sep 2018 21:19:37 +0000 (07:19 +1000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 11 Sep 2018 21:27:46 +0000 (07:27 +1000)
source/blender/editors/transform/transform_gizmo_3d.c

index 0ccf5ed072c3e9b9d5a6ddeb5151abac6ee48e57..f3509f62faa1083146ce71f6864f5f0cadf48ae5 100644 (file)
@@ -1711,6 +1711,10 @@ void TRANSFORM_GGT_gizmo(wmGizmoGroupType *gzgt)
 
 struct XFormCageWidgetGroup {
        wmGizmo *gizmo;
 
 struct XFormCageWidgetGroup {
        wmGizmo *gizmo;
+       /* Only for view orientation. */
+       struct {
+               float viewinv_m3[3][3];
+       } prev;
 };
 
 static bool WIDGETGROUP_xform_cage_poll(const bContext *C, wmGizmoGroupType *gzgt)
 };
 
 static bool WIDGETGROUP_xform_cage_poll(const bContext *C, wmGizmoGroupType *gzgt)
@@ -1822,6 +1826,9 @@ static void WIDGETGROUP_xform_cage_refresh(const bContext *C, wmGizmoGroup *gzgr
                        }
                }
        }
                        }
                }
        }
+
+       /* Needed to test view orientation changes. */
+       copy_m3_m4(xgzgroup->prev.viewinv_m3, rv3d->viewinv);
 }
 
 static void WIDGETGROUP_xform_cage_message_subscribe(
 }
 
 static void WIDGETGROUP_xform_cage_message_subscribe(
@@ -1838,7 +1845,6 @@ static void WIDGETGROUP_xform_cage_draw_prepare(const bContext *C, wmGizmoGroup
 {
        struct XFormCageWidgetGroup *xgzgroup = gzgroup->customdata;
        wmGizmo *gz = xgzgroup->gizmo;
 {
        struct XFormCageWidgetGroup *xgzgroup = gzgroup->customdata;
        wmGizmo *gz = xgzgroup->gizmo;
-
        ViewLayer *view_layer = CTX_data_view_layer(C);
        Object *ob = OBACT(view_layer);
        if (ob && ob->mode & OB_MODE_EDIT) {
        ViewLayer *view_layer = CTX_data_view_layer(C);
        Object *ob = OBACT(view_layer);
        if (ob && ob->mode & OB_MODE_EDIT) {
@@ -1847,6 +1853,25 @@ static void WIDGETGROUP_xform_cage_draw_prepare(const bContext *C, wmGizmoGroup
        else {
                unit_m4(gz->matrix_space);
        }
        else {
                unit_m4(gz->matrix_space);
        }
+
+       RegionView3D *rv3d = CTX_wm_region_view3d(C);
+       /* 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, xgzgroup->prev.viewinv_m3)) {
+                                       /* Take care calling refresh from draw_prepare,
+                                        * this should be OK because it's only adjusting the cage orientation. */
+                                       WIDGETGROUP_xform_cage_refresh(C, gzgroup);
+                               }
+                               break;
+                       }
+               }
+       }
 }
 
 void VIEW3D_GGT_xform_cage(wmGizmoGroupType *gzgt)
 }
 
 void VIEW3D_GGT_xform_cage(wmGizmoGroupType *gzgt)