Commit: 759be70ab477d4283a05039259fb7d9888570306
Author: Julian Eisel
Date:   Thu Mar 10 07:25:06 2016 +0100
Branches: HMD_viewport
https://developer.blender.org/rB759be70ab477d4283a05039259fb7d9888570306

Couple of fixes and make stuff working

===================================================================

M       release/scripts/startup/bl_ui/properties_render_layer.py
M       source/blender/editors/space_view3d/view3d_edit.c
M       source/blender/editors/space_view3d/view3d_intern.h
M       source/blender/editors/space_view3d/view3d_ops.c
M       source/blender/editors/space_view3d/view3d_view.c
M       source/blender/makesdna/DNA_scene_types.h
M       source/blender/makesdna/DNA_screen_types.h
M       source/blender/makesrna/intern/rna_scene.c
M       source/blender/windowmanager/intern/wm_operators.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/properties_render_layer.py 
b/release/scripts/startup/bl_ui/properties_render_layer.py
index 0ae63cf..2b91855 100644
--- a/release/scripts/startup/bl_ui/properties_render_layer.py
+++ b/release/scripts/startup/bl_ui/properties_render_layer.py
@@ -225,9 +225,13 @@ class RENDERLAYER_PT_views(RenderLayerButtonsPanel, Panel):
             row.label(text="Camera Suffix:")
             row.prop(rv, "camera_suffix", text="")
         else:
+            icon = 'PAUSE' if scene.hmd_running else 'PLAY'
             col = layout.column()
             col.prop(rd, "hmd_camlock")
-            col.operator("wm.hmd_view_open")
+            row = col.row(align=True)
+
+            row.operator("wm.hmd_view_open")
+            row.operator("view3d.hmd_run", text="", icon=icon)
 
 
 if __name__ == "__main__":  # only for live edit.
diff --git a/source/blender/editors/space_view3d/view3d_edit.c 
b/source/blender/editors/space_view3d/view3d_edit.c
index 74c9995..ede051e 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -4809,7 +4809,7 @@ typedef struct HMDData {
 static int hmd_refresh_poll(bContext *C)
 {
        Scene *scene = CTX_data_scene(C);
-       return (scene->r.scemode & R_HMD_USE_CAM) != 0;
+       return ((scene->r.scemode & R_HMD_IGNORE_ROT) == 0 && (scene->flag & 
SCE_HMD_RUNNING));
 }
 
 static int hmd_refresh_invoke(bContext *C, wmOperator *UNUSED(op), const 
wmEvent *event)
@@ -4845,6 +4845,109 @@ void VIEW3D_OT_hmd_refresh(wmOperatorType *ot)
        ot->flag = OPTYPE_INTERNAL;
 }
 
+static int hmd_refresh_exec(bContext *C, wmOperator *op)
+{
+       wmWindowManager *wm = CTX_wm_manager(C);
+       wmWindow *win;
+       Scene *scene = CTX_data_scene(C);
+
+       for (win = wm->windows.first; win; win = win->next) {
+               if (win->screen->flag & SCREEN_FLAG_HMD_SCREEN) {
+                       break;
+               }
+       }
+       /* Sanity */
+       if (!win)
+               return (OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH);
+
+       wmWindow *winstore = CTX_wm_window(C);
+       ScrArea *sastore = CTX_wm_area(C);
+       ARegion *arstore = CTX_wm_region(C);
+       CTX_wm_window_set(C, win);
+       CTX_wm_area_set(C, win->screen->areabase.first);
+       CTX_wm_region_set(C, 
BKE_area_find_region_type(win->screen->areabase.first, RGN_TYPE_WINDOW));
+       WM_operator_name_call(C, "WM_OT_window_fullscreen_toggle", 
WM_OP_EXEC_DEFAULT, NULL);
+       View3D *v3d = CTX_wm_view3d(C);
+       RegionView3D *rv3d = CTX_wm_region_view3d(C);
+       const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
+       
+       if ((rv3d->viewlock & RV3D_LOCKED) == 0) {
+               if (rv3d->persp != RV3D_CAMOB) {
+                       Object *ob = OBACT;
+
+                       if (!rv3d->smooth_timer) {
+                               /* store settings of current view before 
allowing overwriting with camera view
+                                * only if we're not currently in a view 
transition */
+                               
+                               ED_view3d_lastview_store(rv3d);
+                       }
+
+#if 0
+                       if (G.qual == LR_ALTKEY) {
+                               if (oldcamera && 
is_an_active_object(oldcamera)) {
+                                       v3d->camera = oldcamera;
+                               }
+                               handle_view3d_lock();
+                       }
+#endif
+                       
+                       /* first get the default camera for the view lock type 
*/
+                       if (v3d->scenelock) {
+                               /* sets the camera view if available */
+                               v3d->camera = scene->camera;
+                       }
+                       else {
+                               /* use scene camera if one is not set (even 
though we're unlocked) */
+                               if (v3d->camera == NULL) {
+                                       v3d->camera = scene->camera;
+                               }
+                       }
+                       
+                       /* if the camera isn't found, check a number of options 
*/
+                       if (v3d->camera == NULL && ob && ob->type == OB_CAMERA)
+                               v3d->camera = ob;
+                       
+                       if (v3d->camera == NULL)
+                               v3d->camera = BKE_scene_camera_find(scene);
+                       
+                       /* couldnt find any useful camera, bail out */
+                       if (v3d->camera == NULL)
+                               return OPERATOR_CANCELLED;
+                       
+                       /* important these don't get out of sync for locked 
scenes */
+                       if (v3d->scenelock)
+                               scene->camera = v3d->camera;
+                       
+                       /* finally do snazzy view zooming */
+                       rv3d->persp = RV3D_CAMOB;
+                       ED_view3d_smooth_view(
+                                   C, v3d, CTX_wm_region(C), smooth_viewtx,
+                                   &(const V3D_SmoothParams) {
+                                       .camera = v3d->camera, .ofs = 
rv3d->ofs, .quat = rv3d->viewquat,
+                                       .dist = &rv3d->dist, .lens = 
&v3d->lens});
+               }
+       }
+       CTX_wm_region_set(C, arstore);
+       CTX_wm_area_set(C, sastore);
+       CTX_wm_window_set(C, winstore);
+       scene->flag ^= SCE_HMD_RUNNING;
+       return OPERATOR_FINISHED;
+}
+
+void VIEW3D_OT_hmd_run(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name = "Run HMD Session";
+       ot->description = "Start/Stop a head mounted display (virtual reality) 
session";
+       ot->idname = "VIEW3D_OT_hmd_run";
+
+       /* api callbacks */
+       ot->exec = hmd_refresh_exec;
+
+       /* flags */
+       ot->flag = OPTYPE_INTERNAL;
+}
+
 /* ************************* below the line! *********************** */
 
 
diff --git a/source/blender/editors/space_view3d/view3d_intern.h 
b/source/blender/editors/space_view3d/view3d_intern.h
index f0a36ef..f00a111 100644
--- a/source/blender/editors/space_view3d/view3d_intern.h
+++ b/source/blender/editors/space_view3d/view3d_intern.h
@@ -103,6 +103,8 @@ void VIEW3D_OT_enable_manipulator(struct wmOperatorType 
*ot);
 void VIEW3D_OT_render_border(struct wmOperatorType *ot);
 void VIEW3D_OT_clear_render_border(struct wmOperatorType *ot);
 void VIEW3D_OT_zoom_border(struct wmOperatorType *ot);
+void VIEW3D_OT_hmd_refresh(struct wmOperatorType *ot);
+void VIEW3D_OT_hmd_run(struct wmOperatorType *ot);
 
 void view3d_boxview_copy(ScrArea *sa, ARegion *ar);
 
@@ -271,7 +273,6 @@ void VIEW3D_OT_snap_cursor_to_grid(struct wmOperatorType 
*ot);
 void VIEW3D_OT_snap_cursor_to_center(struct wmOperatorType *ot);
 void VIEW3D_OT_snap_cursor_to_selected(struct wmOperatorType *ot);
 void VIEW3D_OT_snap_cursor_to_active(struct wmOperatorType *ot);
-void VIEW3D_OT_hmd_refresh(struct wmOperatorType *ot);
 
 /* space_view3d.c */
 ARegion *view3d_has_buttons_region(ScrArea *sa);
diff --git a/source/blender/editors/space_view3d/view3d_ops.c 
b/source/blender/editors/space_view3d/view3d_ops.c
index c7c5399..a5d9212 100644
--- a/source/blender/editors/space_view3d/view3d_ops.c
+++ b/source/blender/editors/space_view3d/view3d_ops.c
@@ -219,7 +219,8 @@ void view3d_operatortypes(void)
        WM_operatortype_append(VIEW3D_OT_snap_cursor_to_selected);
        WM_operatortype_append(VIEW3D_OT_snap_cursor_to_active);
        WM_operatortype_append(VIEW3D_OT_hmd_refresh);
-               
+       WM_operatortype_append(VIEW3D_OT_hmd_run);
+
        transform_operatortypes();
 }
 
diff --git a/source/blender/editors/space_view3d/view3d_view.c 
b/source/blender/editors/space_view3d/view3d_view.c
index 305b4a3..273d69d 100644
--- a/source/blender/editors/space_view3d/view3d_view.c
+++ b/source/blender/editors/space_view3d/view3d_view.c
@@ -416,6 +416,7 @@ static int view3d_smoothview_invoke(bContext *C, wmOperator 
*UNUSED(op), const w
                WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d);
        }
        else {
+               WM_event_add_mousemove(C);
                ED_region_tag_redraw(CTX_wm_region(C));
        }
        
diff --git a/source/blender/makesdna/DNA_scene_types.h 
b/source/blender/makesdna/DNA_scene_types.h
index ce64c56..3d5a7ae 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -1558,10 +1558,11 @@ typedef struct Scene {
 
 /* flag */
        /* use preview range */
-#define SCER_PRV_RANGE (1<<0)
-#define SCER_LOCK_FRAME_SELECTION      (1<<1)
+#define SCER_PRV_RANGE            (1 << 0)
+#define SCER_LOCK_FRAME_SELECTION (1 << 1)
        /* timeline/keyframe jumping - only selected items (on by default) */
-#define SCE_KEYS_NO_SELONLY    (1<<2)
+#define SCE_KEYS_NO_SELONLY       (1 << 2)
+#define SCE_HMD_RUNNING           (1 << 3)
 
 /* mode (int now) */
 #define R_OSA                  0x0001
@@ -1657,7 +1658,7 @@ typedef struct Scene {
 #define R_VIEWPORT_PREVIEW     0x80000
 #define R_EXR_CACHE_FILE       0x100000
 #define R_MULTIVIEW                    0x200000
-#define R_HMD_USE_CAM          0x400000
+#define R_HMD_IGNORE_ROT       0x400000
 
 /* r->stamp */
 #define R_STAMP_TIME   0x0001
diff --git a/source/blender/makesdna/DNA_screen_types.h 
b/source/blender/makesdna/DNA_screen_types.h
index 1c11350..548e80a 100644
--- a/source/blender/makesdna/DNA_screen_types.h
+++ b/source/blender/makesdna/DNA_screen_types.h
@@ -69,7 +69,8 @@ typedef struct bScreen {
        char swap;                                                      /* 
indicator to survive swap-exchange systems */
        char skip_handling;                                     /* set to delay 
screen handling after switching back from maximized area */
        char scrubbing;                                         /* set when 
scrubbing to avoid some costly updates */
-       char pad[6];
+       short flag;
+       char pad[4];
        
        short mainwin;                                          /* screensize 
subwindow, for screenedges and global menus */
        short subwinactive;                                     /* active 
subwindow */
@@ -78,6 +79,10 @@ typedef struct bScreen {
        void *context;                                          /* context 
callback */
 } bScreen;
 
+enum eScreenFlag {
+       SCREEN_FLAG_HMD_SCREEN = (1 << 0),
+};
+
 typedef struct ScrVert {
        struct ScrVert *next, *prev, *newv;
        vec2s vec;
diff --git a/source/blender/makesrna/intern/rna_scene.c 
b/source/blender/makesrna/intern/rna_scene.c
index 92fe4a8..c3b666b 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -5924,7 +5924,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "Render Views", "");
 
        prop = RNA_def_property(srna, "hmd_camlock", PROP_BOOLEAN, PROP_NONE);
-       RNA_def_property_boolean_sdna(prop, NULL, "scemode", R_HMD_USE_CAM);
+       RNA_def_property_boolean_negative_sdna(prop, NULL, "scemode", 
R_HMD_IGNORE_ROT);
        RNA_def_property_ui_text(prop, "HMD Rotation", "Use the rotation of a 
head mounted display if available");
        RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, 
"rna_RenderSettings_hmd_camlock_update");
 
@@ -6698,6 +6698,12 @@ void RNA_def_scene(BlenderRNA *brna)
        RNA_def_property_struct_type(prop, "Depsgraph");
        RNA_def_property_ui_text(prop, "Dependency Graph", "Dependencies in the 
scene data");
 
+       prop = RNA_def_property(srna, "hmd_running", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+       RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_HMD_RUNNING);
+       RNA_def_property_ui_text(prop, "HMD Running", "");
+       RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+
        /* Nestled Data  */
        /* *** Non-Animated *** */
        RNA_define_anim

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to