Fix update for manipulator w/ 3D cursor change
authorCampbell Barton <ideasman42@gmail.com>
Sun, 6 May 2018 14:41:32 +0000 (16:41 +0200)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 6 May 2018 14:41:32 +0000 (16:41 +0200)
source/blender/editors/space_view3d/view3d_edit.c
source/blender/editors/transform/transform_manipulator_3d.c

index 8130442ea336d34f6fb3c80975ba487a32a6908a..7e05a80781c2229a3923a3607096b7c34d10c1eb 100644 (file)
@@ -66,6 +66,7 @@
 
 #include "WM_api.h"
 #include "WM_types.h"
+#include "WM_message.h"
 
 #include "RNA_access.h"
 #include "RNA_define.h"
@@ -4606,6 +4607,12 @@ void ED_view3d_cursor3d_update(bContext *C, const int mval[2])
        else
                WM_event_add_notifier(C, NC_SCENE | NA_EDITED, scene);
 
+       {
+               struct wmMsgBus *mbus = CTX_wm_message_bus(C);
+               WM_msg_publish_rna_prop(
+                       mbus, &scene->id, scene, Scene, cursor_location);
+       }
+
        DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE);
 }
 
index 4f87fabce05148706209991b491da5f72a9ce180..afe40b94d9a2c47dd38e219f0264d78e06e5b7db 100644 (file)
@@ -1118,7 +1118,7 @@ static void manipulator_line_range(const int twtype, const short axis_type, floa
 
 static void manipulator_xform_message_subscribe(
         wmManipulatorGroup *mgroup, struct wmMsgBus *mbus,
-        bScreen *screen, ScrArea *sa, ARegion *ar, const void *type_fn)
+        Scene *scene, bScreen *screen, ScrArea *sa, ARegion *ar, const void *type_fn)
 {
        /* Subscribe to view properties */
        wmMsgSubscribeValue msg_sub_value_mpr_tag_refresh = {
@@ -1127,19 +1127,27 @@ static void manipulator_xform_message_subscribe(
                .notify = WM_manipulator_do_msg_notify_tag_refresh,
        };
 
-       PointerRNA space_ptr;
-       RNA_pointer_create(&screen->id, &RNA_SpaceView3D, sa->spacedata.first, &space_ptr);
+       PointerRNA scene_ptr;
+       RNA_id_pointer_create(&scene->id, &scene_ptr);
 
        {
+               const View3D *v3d = sa->spacedata.first;
                extern PropertyRNA rna_Scene_transform_orientation;
+               extern PropertyRNA rna_Scene_cursor_location;
                const PropertyRNA *props[] = {
                        &rna_Scene_transform_orientation,
+                       (v3d->around == V3D_AROUND_CURSOR) ? &rna_Scene_cursor_location : NULL,
                };
                for (int i = 0; i < ARRAY_SIZE(props); i++) {
-                       WM_msg_subscribe_rna(mbus, &space_ptr, props[i], &msg_sub_value_mpr_tag_refresh, __func__);
+                       if (props[i]) {
+                               WM_msg_subscribe_rna(mbus, &scene_ptr, props[i], &msg_sub_value_mpr_tag_refresh, __func__);
+                       }
                }
        }
 
+       PointerRNA space_ptr;
+       RNA_pointer_create(&screen->id, &RNA_SpaceView3D, sa->spacedata.first, &space_ptr);
+
        if (type_fn == TRANSFORM_WGT_manipulator) {
                extern PropertyRNA rna_SpaceView3D_pivot_point;
                const PropertyRNA *props[] = {
@@ -1454,10 +1462,11 @@ static void WIDGETGROUP_manipulator_refresh(const bContext *C, wmManipulatorGrou
 static void WIDGETGROUP_manipulator_message_subscribe(
         const bContext *C, wmManipulatorGroup *mgroup, struct wmMsgBus *mbus)
 {
+       Scene *scene = CTX_data_scene(C);
        bScreen *screen = CTX_wm_screen(C);
        ScrArea *sa = CTX_wm_area(C);
        ARegion *ar = CTX_wm_region(C);
-       manipulator_xform_message_subscribe(mgroup, mbus, screen, sa, ar, TRANSFORM_WGT_manipulator);
+       manipulator_xform_message_subscribe(mgroup, mbus, scene, screen, sa, ar, TRANSFORM_WGT_manipulator);
 }
 
 static void WIDGETGROUP_manipulator_draw_prepare(const bContext *C, wmManipulatorGroup *mgroup)
@@ -1674,10 +1683,11 @@ static void WIDGETGROUP_xform_cage_refresh(const bContext *C, wmManipulatorGroup
 static void WIDGETGROUP_xform_cage_message_subscribe(
         const bContext *C, wmManipulatorGroup *mgroup, struct wmMsgBus *mbus)
 {
+       Scene *scene = CTX_data_scene(C);
        bScreen *screen = CTX_wm_screen(C);
        ScrArea *sa = CTX_wm_area(C);
        ARegion *ar = CTX_wm_region(C);
-       manipulator_xform_message_subscribe(mgroup, mbus, screen, sa, ar, VIEW3D_WGT_xform_cage);
+       manipulator_xform_message_subscribe(mgroup, mbus, scene, screen, sa, ar, VIEW3D_WGT_xform_cage);
 }
 
 static void WIDGETGROUP_xform_cage_draw_prepare(const bContext *C, wmManipulatorGroup *mgroup)