[Bf-blender-cvs] [3c51b670c51] HMD_viewport: Make interactions in HMD view work nicely

Julian Eisel noreply at git.blender.org
Tue Apr 11 21:25:50 CEST 2017


Commit: 3c51b670c51d0aa47394f33c96a02362404e975d
Author: Julian Eisel
Date:   Tue Apr 11 21:05:23 2017 +0200
Branches: HMD_viewport
https://developer.blender.org/rB3c51b670c51d0aa47394f33c96a02362404e975d

Make interactions in HMD view work nicely

This should make any interactions in HMD views work like users would
expect. Talking about things like selecting, using tools, placing 3D
cursor, ...
Same goes for HMD mirror views, their interactions should work fine
now.

I'm not so happy how we pass info about HMD state to
ED_view3d_draw_depth and ED_view3d_draw_depth_gpencil, would like to
figure out a nicer way to do that. Also continuous grab works a bit
glitchy.

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

M	intern/ghost/GHOST_C-api.h
M	intern/ghost/intern/GHOST_C-api.cpp
M	source/blender/editors/curve/editcurve_paint.c
M	source/blender/editors/gpencil/gpencil_edit.c
M	source/blender/editors/gpencil/gpencil_paint.c
M	source/blender/editors/gpencil/gpencil_utils.c
M	source/blender/editors/include/ED_view3d.h
M	source/blender/editors/interface/interface_eyedropper.c
M	source/blender/editors/screen/area.c
M	source/blender/editors/sculpt_paint/paint_image_proj.c
M	source/blender/editors/space_view3d/view3d_draw.c
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_view.c
M	source/blender/windowmanager/WM_api.h
M	source/blender/windowmanager/intern/wm_device.c
M	source/blender/windowmanager/intern/wm_event_system.c
M	source/blender/windowmanager/intern/wm_operators.c
M	source/blender/windowmanager/intern/wm_stereo.c
M	source/blender/windowmanager/intern/wm_window.c
M	source/blender/windowmanager/wm.h
M	source/blender/windowmanager/wm_event_system.h

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

diff --git a/intern/ghost/GHOST_C-api.h b/intern/ghost/GHOST_C-api.h
index dd204cf34f0..1eeb0fda3e8 100644
--- a/intern/ghost/GHOST_C-api.h
+++ b/intern/ghost/GHOST_C-api.h
@@ -946,10 +946,11 @@ extern const char *GHOST_HMDgetVendorName(int index);
 extern float       GHOST_HMDgetDeviceIPD(void);
 extern void        GHOST_HMDsetDeviceIPD(float value);
 extern float       GHOST_HMDgetLensHorizontalSeparation(void);
+extern float       GHOST_HMDgetProjectionZNear(void);
+extern float       GHOST_HMDgetProjectionZFar(void);
+extern float       GHOST_HMDgetScreenHorizontalSize(void);
 extern void        GHOST_HMDgetLeftModelviewMatrix(float r_mat[4][4]);
 extern void        GHOST_HMDgetRightModelviewMatrix(float r_mat[4][4]);
-extern void        GHOST_HMDgetLeftProjectionMatrix(float r_mat[4][4]);
-extern void        GHOST_HMDgetRightProjectionMatrix(float r_mat[4][4]);
 extern void*       GHOST_HMDgetDistortionParameters(void);
 
 #ifdef __cplusplus
diff --git a/intern/ghost/intern/GHOST_C-api.cpp b/intern/ghost/intern/GHOST_C-api.cpp
index 5d5fb5226b7..28b1bbcd50d 100644
--- a/intern/ghost/intern/GHOST_C-api.cpp
+++ b/intern/ghost/intern/GHOST_C-api.cpp
@@ -1041,56 +1041,67 @@ float GHOST_HMDgetLensHorizontalSeparation()
 #endif
 }
 
-#ifndef WITH_OPENHMD
-static void ghost_UnitMat(float r_mat[4][4])
+float GHOST_HMDgetProjectionZNear()
 {
-	r_mat[0][0] = r_mat[1][1] = r_mat[2][2] = r_mat[3][3] = 1.0f;
-	r_mat[0][1] = r_mat[0][2] = r_mat[0][3] = 0.0f;
-	r_mat[1][0] = r_mat[1][2] = r_mat[1][3] = 0.0f;
-	r_mat[2][0] = r_mat[2][1] = r_mat[2][3] = 0.0f;
-	r_mat[3][0] = r_mat[3][1] = r_mat[3][2] = 0.0f;
-}
+#ifdef WITH_OPENHMD
+	GHOST_ISystem *system = GHOST_ISystem::getSystem();
+	GHOST_OpenHMDManager *ohmd = system->getOpenHMDManager();
+	return ohmd->getProjectionZNear();
+#else
+	return -1.0f;
 #endif
+}
 
-void GHOST_HMDgetLeftModelviewMatrix(float r_mat[4][4])
+float GHOST_HMDgetProjectionZFar()
 {
 #ifdef WITH_OPENHMD
 	GHOST_ISystem *system = GHOST_ISystem::getSystem();
 	GHOST_OpenHMDManager *ohmd = system->getOpenHMDManager();
-	ohmd->getLeftEyeGLModelviewMatrix(r_mat);
+	return ohmd->getProjectionZFar();
 #else
-	ghost_UnitMat(r_mat);
+	return -1.0f;
 #endif
 }
 
-void GHOST_HMDgetRightModelviewMatrix(float r_mat[4][4])
+float GHOST_HMDgetScreenHorizontalSize()
 {
 #ifdef WITH_OPENHMD
 	GHOST_ISystem *system = GHOST_ISystem::getSystem();
 	GHOST_OpenHMDManager *ohmd = system->getOpenHMDManager();
-	ohmd->getRightEyeGLModelviewMatrix(r_mat);
+	return ohmd->getScreenHorizontalSize();
 #else
-	ghost_UnitMat(r_mat);
+	return -1.0f;
 #endif
 }
 
-void GHOST_HMDgetLeftProjectionMatrix(float r_mat[4][4])
+#ifndef WITH_OPENHMD
+static void ghost_UnitMat(float r_mat[4][4])
+{
+	r_mat[0][0] = r_mat[1][1] = r_mat[2][2] = r_mat[3][3] = 1.0f;
+	r_mat[0][1] = r_mat[0][2] = r_mat[0][3] = 0.0f;
+	r_mat[1][0] = r_mat[1][2] = r_mat[1][3] = 0.0f;
+	r_mat[2][0] = r_mat[2][1] = r_mat[2][3] = 0.0f;
+	r_mat[3][0] = r_mat[3][1] = r_mat[3][2] = 0.0f;
+}
+#endif
+
+void GHOST_HMDgetLeftModelviewMatrix(float r_mat[4][4])
 {
 #ifdef WITH_OPENHMD
 	GHOST_ISystem *system = GHOST_ISystem::getSystem();
 	GHOST_OpenHMDManager *ohmd = system->getOpenHMDManager();
-	ohmd->getLeftEyeGLProjectionMatrix(r_mat);
+	ohmd->getLeftEyeGLModelviewMatrix(r_mat);
 #else
 	ghost_UnitMat(r_mat);
 #endif
 }
 
-void GHOST_HMDgetRightProjectionMatrix(float r_mat[4][4])
+void GHOST_HMDgetRightModelviewMatrix(float r_mat[4][4])
 {
 #ifdef WITH_OPENHMD
 	GHOST_ISystem *system = GHOST_ISystem::getSystem();
 	GHOST_OpenHMDManager *ohmd = system->getOpenHMDManager();
-	ohmd->getRightEyeGLProjectionMatrix(r_mat);
+	ohmd->getRightEyeGLModelviewMatrix(r_mat);
 #else
 	ghost_UnitMat(r_mat);
 #endif
diff --git a/source/blender/editors/curve/editcurve_paint.c b/source/blender/editors/curve/editcurve_paint.c
index 34e026a3ef4..a6015550e97 100644
--- a/source/blender/editors/curve/editcurve_paint.c
+++ b/source/blender/editors/curve/editcurve_paint.c
@@ -1162,12 +1162,14 @@ static int curve_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event)
 			if ((cps->depth_mode == CURVE_PAINT_PROJECT_SURFACE) &&
 			    (v3d->drawtype > OB_WIRE))
 			{
+				const bool is_hmd_view = WM_window_is_hmd_view(CTX_wm_manager(C), CTX_wm_window(C));
+
 				view3d_get_transformation(cdd->vc.ar, cdd->vc.rv3d, NULL, &cdd->mats);
 
 				/* needed or else the draw matrix can be incorrect */
 				view3d_operator_needs_opengl(C);
 
-				ED_view3d_autodist_init(cdd->vc.scene, cdd->vc.ar, cdd->vc.v3d, 0);
+				ED_view3d_autodist_init(cdd->vc.scene, cdd->vc.ar, cdd->vc.v3d, 0, is_hmd_view);
 
 				if (cdd->vc.rv3d->depths) {
 					cdd->vc.rv3d->depths->damaged = true;
diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c
index 601a86b97cb..90c89e9c250 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -2010,8 +2010,10 @@ static int gp_strokes_reproject_exec(bContext *C, wmOperator *op)
 	
 	/* init autodist for geometry projection */
 	if (mode == GP_REPROJECT_SURFACE) {
+		const bool is_hmd_view = WM_window_is_hmd_view(CTX_wm_manager(C), CTX_wm_window(C));
+
 		view3d_region_operator_needs_opengl(CTX_wm_window(C), gsc.ar);
-		ED_view3d_autodist_init(scene, gsc.ar, CTX_wm_view3d(C), 0);
+		ED_view3d_autodist_init(scene, gsc.ar, CTX_wm_view3d(C), 0, is_hmd_view);
 	}
 	
 	// TODO: For deforming geometry workflow, create new frames?
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index 5879306b06c..8e890d97342 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -113,7 +113,8 @@ typedef enum eGPencil_PaintFlags {
  */
 typedef struct tGPsdata {
 	Scene *scene;       /* current scene from context */
-	
+
+	wmWindowManager *wm; /* window manager where painting originated */
 	wmWindow *win;      /* window where painting originated */
 	ScrArea *sa;        /* area where painting originated */
 	ARegion *ar;        /* region where painting originated */
@@ -634,9 +635,12 @@ static short gp_stroke_addpoint(tGPsdata *p, const int mval[2], float pressure,
 			 */
 			if (gpencil_project_check(p)) {
 				View3D *v3d = p->sa->spacedata.first;
+				const bool is_hmd_view = WM_window_is_hmd_view(p->wm, p->win);
 				
 				view3d_region_operator_needs_opengl(p->win, p->ar);
-				ED_view3d_autodist_init(p->scene, p->ar, v3d, (p->gpd->flag & GP_DATA_DEPTH_STROKE) ? 1 : 0);
+				ED_view3d_autodist_init(p->scene, p->ar, v3d,
+				                        (p->gpd->flag & GP_DATA_DEPTH_STROKE) ? 1 : 0,
+				                        is_hmd_view);
 			}
 			
 			/* convert screen-coordinates to appropriate coordinates (and store them) */
@@ -1236,9 +1240,10 @@ static void gp_stroke_doeraser(tGPsdata *p)
 	if (p->sa->spacetype == SPACE_VIEW3D) {
 		if (p->flags & GP_PAINTFLAG_V3D_ERASER_DEPTH) {
 			View3D *v3d = p->sa->spacedata.first;
+			const bool is_hmd_view = WM_window_is_hmd_view(p->wm, p->win);
 			
 			view3d_region_operator_needs_opengl(p->win, p->ar);
-			ED_view3d_autodist_init(p->scene, p->ar, v3d, 0);
+			ED_view3d_autodist_init(p->scene, p->ar, v3d, 0, is_hmd_view);
 		}
 	}
 	
@@ -1390,8 +1395,9 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p)
 		return 0;
 	}
 	
-	/* pass on current scene and window */
+	/* pass on context info */
 	p->scene = CTX_data_scene(C);
+	p->wm = CTX_wm_manager(C);
 	p->win = CTX_wm_window(C);
 	
 	unit_m4(p->imat);
@@ -1799,10 +1805,11 @@ static void gp_paint_strokeend(tGPsdata *p)
 	 */
 	if (gpencil_project_check(p)) {
 		View3D *v3d = p->sa->spacedata.first;
+		const bool is_hmd_view = WM_window_is_hmd_view(p->wm, p->win);
 		
 		/* need to restore the original projection settings before packing up */
 		view3d_region_operator_needs_opengl(p->win, p->ar);
-		ED_view3d_autodist_init(p->scene, p->ar, v3d, (p->gpd->flag & GP_DATA_DEPTH_STROKE) ? 1 : 0);
+		ED_view3d_autodist_init(p->scene, p->ar, v3d, (p->gpd->flag & GP_DATA_DEPTH_STROKE) ? 1 : 0, is_hmd_view);
 	}
 	
 	/* check if doing eraser or not */
diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c
index 76e85f20c36..fa726e98f50 100644
--- a/source/blender/editors/gpencil/gpencil_utils.c
+++ b/source/blender/editors/gpencil/gpencil_utils.c
@@ -523,12 +523,13 @@ void gp_point_conversion_init(bContext *C, GP_SpaceConversion *r_gsc)
 		Scene *scene = CTX_data_scene(C);
 		View3D *v3d = (View3D *)CTX_wm_space_data(C);
 		RegionView3D *rv3d = ar->regiondata;
+		const bool is_hmd_view = WM_window_is_hmd_view(CTX_wm_manager(C), CTX_wm_window(C));
 		
 		/* init 3d depth buffers */
 		view3d_operator_needs_opengl(C);
 		
 		view3d_region_operator_needs_opengl(win, ar);
-		ED_view3d_autodist_init(scene, ar, v3d, 0);
+		ED_view3d_autodist_init(scene, ar, v3d, 0, is_hmd_view);
 		
 		/* for camera view set the subrect */
 		if (rv3d->persp == RV3D_CAMOB) {
diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h
index 8658a542ade..ebb32e9dc1f 100644
--- a/source/blender/editors/include/ED_view3d.h
+++ b/source/blender/editors/include/ED_view3d.h
@@ -291,10 +291,13 @@ unsigned int ED_view3d_backbuf_sample(struct ViewContext *vc, int x, int y);
 bool ED_view3d_autodist(
         struct Scene *scene, struct ARegion *ar, struct View3D *v3d,
         const int mval[2], float mouse_worldloc[3],
-        const bool alphaoverride, const float fallback_depth_pt[3]);
+        const bool alphaoverride, const bool is_hmd_view,
+        const float fallback_depth_pt[3]);
 
 /* only draw so ED_view3d_autodist_simple can be called many times after */
-void ED_view3d_autodist_init(struct Scene *scene, struct ARegion *ar, struct View3D *v3d, int mode);
+void ED_view3d_autodist_init(
+        struct Scene *scene, struct ARegion *ar, struct View3D *v3d,
+        int mode, bool is_hmd_view);
 bool ED_view3d_autodist_simple(struct ARegion *ar, const int mval[2], float mouse_worldloc[3], int margin, float *force_depth);
 bool ED_view3d_autodist_depth(struct ARegion *ar, const int mval[2], int margin, float *depth);
 bool ED_view3d_auto

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list