[Bf-blender-cvs] [bacadeb] HMD_viewport: Add build option WITH_INPUT_HMD

Julian Eisel noreply at git.blender.org
Tue Mar 29 01:53:14 CEST 2016


Commit: bacadeb8c47263ca74f80e727ee83e9d931a1108
Author: Julian Eisel
Date:   Tue Mar 29 01:42:40 2016 +0200
Branches: HMD_viewport
https://developer.blender.org/rBbacadeb8c47263ca74f80e727ee83e9d931a1108

Add build option WITH_INPUT_HMD

If we later want to support other drivers aside from OpenHMD, we only want OpenHMD to work at the low GHOST level. The new option is for the higher, driver independent level.
Since currently only OpenHMD is supported, I added a compile warning for the case HMD input is enabled and OpenHMD is disabled. Also added a compile error for the case OpenHMD is enabled and HMD input is disabled.

This means we now have 3 HMD build options:
* WITH_INPUT_HMD - General HMD support
* WITH_OPENHMD - OpenHMD driver support
* WITH_OPENHMD_DYNLOAD - Dynamic runtime OpenHMD deps loading

Actually, _INPUT_HMD isn't totally correct since it does more than just input, but wanted to stick to naming conventions.

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

M	CMakeLists.txt
M	intern/ghost/CMakeLists.txt
M	intern/ghost/intern/GHOST_C-api.cpp
M	source/blender/blenkernel/CMakeLists.txt
M	source/blender/blenkernel/intern/camera.c
M	source/blender/editors/screen/CMakeLists.txt
M	source/blender/editors/screen/screen_ops.c
M	source/blender/editors/space_view3d/CMakeLists.txt
M	source/blender/editors/space_view3d/view3d_draw.c
M	source/blender/makesdna/CMakeLists.txt
M	source/blender/makesdna/DNA_windowmanager_types.h
M	source/blender/makesrna/intern/CMakeLists.txt
M	source/blender/makesrna/intern/rna_scene.c
M	source/blender/makesrna/intern/rna_userdef.c
M	source/blender/makesrna/intern/rna_wm.c
M	source/blender/windowmanager/CMakeLists.txt
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

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

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7e9f86a..a747bf9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -354,7 +354,9 @@ if(WIN32)
 endif()
 option(WITH_INPUT_NDOF "Enable NDOF input devices (SpaceNavigator and friends)" ${_init_INPUT_NDOF})
 
-option(WITH_OPENHMD "Enable OpenHMD support in Blender (Head Mounted Displays for VR support)" ON)
+# IMD - actually not really input, there's also some other stuff for it
+option(WITH_INPUT_HMD "Enable HMD support in Blender (Head Mounted Displays for VR support)" ON)
+option(WITH_OPENHMD "Enable OpenHMD driver library" ON)
 option(WITH_OPENHMD_DYNLOAD "Dynamically load OpenHMD dependencies at runtime" OFF)
 mark_as_advanced(WITH_OPENHMD_DYNLOAD)
 
@@ -634,6 +636,15 @@ if(WITH_PYTHON_MODULE AND WITH_PYTHON_INSTALL)
 	message(FATAL_ERROR "WITH_PYTHON_MODULE requires WITH_PYTHON_INSTALL to be OFF")
 endif()
 
+if(WITH_INPUT_HMD AND NOT WITH_OPENHMD)
+	message(WARNING "WITH_INPUT_HMD is enabled, but OpenHMD driver (WITH_OPENHMD) is disabled. "
+					"Only a limited set of HMD features will be available.")
+endif()
+
+if(WITH_OPENHMD AND NOT WITH_INPUT_HMD)
+	message(FATAL_ERROR "WITH_OPENHMD requires WITH_INPUT_HMD")
+endif()
+
 
 # may as well build python module without a UI
 if(WITH_PYTHON_MODULE)
diff --git a/intern/ghost/CMakeLists.txt b/intern/ghost/CMakeLists.txt
index 7312a50..c94b957 100644
--- a/intern/ghost/CMakeLists.txt
+++ b/intern/ghost/CMakeLists.txt
@@ -113,6 +113,9 @@ if(WITH_INPUT_NDOF)
 endif()
 
 
+if (WITH_INPUT_HMD)
+	add_definitions(-DWITH_INPUT_HMD)
+endif()
 if(WITH_OPENHMD)
 	add_definitions(-DWITH_OPENHMD)
 	if(WITH_OPENHMD_DYNLOAD)
diff --git a/intern/ghost/intern/GHOST_C-api.cpp b/intern/ghost/intern/GHOST_C-api.cpp
index 1435894..fe9fc7f 100644
--- a/intern/ghost/intern/GHOST_C-api.cpp
+++ b/intern/ghost/intern/GHOST_C-api.cpp
@@ -933,48 +933,68 @@ void GHOST_EndIME(GHOST_WindowHandle windowhandle)
 
 #endif  /* WITH_INPUT_IME */
 
-#ifdef WITH_OPENHMD
+#ifdef WITH_INPUT_HMD
 
 int GHOST_HMDgetNumDevices()
 {
+#ifdef WITH_OPENHMD
 	GHOST_ISystem *system = GHOST_ISystem::getSystem();
 	GHOST_OpenHMDManager *ohmd = system->getOpenHMDManager();
 	return ohmd->getNumDevices();
+#else
+	return 0;
+#endif
 }
 
 void GHOST_HMDopenDevice(int index)
 {
+#ifdef WITH_OPENHMD
 	GHOST_ISystem *system = GHOST_ISystem::getSystem();
 	GHOST_OpenHMDManager *ohmd = system->getOpenHMDManager();
 	ohmd->openDevice(index);
+#endif
 }
 
 void GHOST_HMDcloseDevice()
 {
+#ifdef WITH_OPENHMD
 	GHOST_ISystem *system = GHOST_ISystem::getSystem();
 	GHOST_OpenHMDManager *ohmd = system->getOpenHMDManager();
 	ohmd->closeDevice();
+#endif
 }
 
 int GHOST_HMDgetOpenDeviceIndex()
 {
+#ifdef WITH_OPENHMD
 	GHOST_ISystem *system = GHOST_ISystem::getSystem();
 	GHOST_OpenHMDManager *ohmd = system->getOpenHMDManager();
 	return ohmd->getDeviceIndex();
+#else
+	return -1;
+#endif
 }
 
 const char *GHOST_HMDgetDeviceName(int index)
 {
+#ifdef WITH_OPENHMD
 	GHOST_ISystem *system = GHOST_ISystem::getSystem();
 	GHOST_OpenHMDManager *ohmd = system->getOpenHMDManager();
 	return ohmd->getDeviceName(index);
+#else
+	return NULL;
+#endif
 }
 
 float GHOST_HMDgetDeviceIPD()
 {
+#ifdef WITH_OPENHMD
 	GHOST_ISystem *system = GHOST_ISystem::getSystem();
 	GHOST_OpenHMDManager *ohmd = system->getOpenHMDManager();
 	return ohmd->getEyeIPD();
+#else
+	return 0.0f;
+#endif
 }
 
 #endif
diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt
index 7311f33..8f349bc 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -368,6 +368,10 @@ if(WITH_IMAGE_HDR)
 	add_definitions(-DWITH_HDR)
 endif()
 
+if(WITH_INPUT_HMD)
+	add_definitions(-DWITH_INPUT_HMD)
+endif()
+
 if(WITH_CODEC_AVI)
 	list(APPEND INC
 		../avi
diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c
index be6593e..e4e178c 100644
--- a/source/blender/blenkernel/intern/camera.c
+++ b/source/blender/blenkernel/intern/camera.c
@@ -725,11 +725,15 @@ static void camera_stereo3d_model_matrix(Object *camera, const bool is_left, flo
 	float fac = 1.0f;
 	float fac_signed;
 
-	const bool use_device_ipd = data->stereo.flag & CAM_S3D_CUSTOM_IPD;
-	float interocular_distance = use_device_ipd ? WM_device_HMD_IPD_get() : data->stereo.interocular_distance;
-	float convergence_distance = data->stereo.convergence_distance;
-	short convergence_mode = data->stereo.convergence_mode;
-	short pivot = data->stereo.pivot;
+	const float interocular_distance =
+#ifdef WITH_INPUT_HMD
+	        (data->stereo.flag & CAM_S3D_CUSTOM_IPD) ? WM_device_HMD_IPD_get() : data->stereo.interocular_distance;
+#else
+	        data->stereo.interocular_distance;
+#endif
+	const float convergence_distance = data->stereo.convergence_distance;
+	const short convergence_mode = data->stereo.convergence_mode;
+	const short pivot = data->stereo.pivot;
 
 	if (((pivot == CAM_S3D_PIVOT_LEFT) && is_left) ||
 	    ((pivot == CAM_S3D_PIVOT_RIGHT) && !is_left))
diff --git a/source/blender/editors/screen/CMakeLists.txt b/source/blender/editors/screen/CMakeLists.txt
index ed86ffa..40a3334 100644
--- a/source/blender/editors/screen/CMakeLists.txt
+++ b/source/blender/editors/screen/CMakeLists.txt
@@ -49,6 +49,10 @@ set(SRC
 	screen_intern.h
 )
 
+if(WITH_INPUT_HMD)
+	add_definitions(-DWITH_INPUT_HMD)
+endif()
+
 if(WITH_INTERNATIONAL)
 	add_definitions(-DWITH_INTERNATIONAL)
 endif()
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index b6258c7..05a51f3 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -2443,8 +2443,12 @@ static void SCREEN_OT_screen_set(wmOperatorType *ot)
 
 static int screen_maximize_area_poll(bContext *C)
 {
-	wmWindowManager *wm = CTX_wm_manager(C);
-	return ED_operator_areaactive(C) && !(wm->win_hmd && wm->win_hmd == CTX_wm_window(C));
+	return ED_operator_areaactive(C) &&
+#ifdef WITH_INPUT_HMD
+	        !(CTX_wm_manager(C)->win_hmd == CTX_wm_window(C));
+#else
+	        true;
+#endif
 }
 
 /* function to be called outside UI context, or for redo */
diff --git a/source/blender/editors/space_view3d/CMakeLists.txt b/source/blender/editors/space_view3d/CMakeLists.txt
index 059b384..950f489 100644
--- a/source/blender/editors/space_view3d/CMakeLists.txt
+++ b/source/blender/editors/space_view3d/CMakeLists.txt
@@ -82,6 +82,10 @@ endif()
 
 add_definitions(${GL_DEFINITIONS})
 
+if(WITH_INPUT_HMD)
+	add_definitions(-DWITH_INPUT_HMD)
+endif()
+
 if(WITH_INTERNATIONAL)
 	add_definitions(-DWITH_INTERNATIONAL)
 endif()
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index 02498e1..8a35f98 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -4043,9 +4043,14 @@ void view3d_main_region_draw(const bContext *C, ARegion *ar)
 	const char *grid_unit = NULL;
 	rcti border_rect;
 	bool render_border, clip_border;
-	const bool HMD_view = ((wm->win_hmd == CTX_wm_window(C)) &&
-	                       (scene->r.views_format == SCE_VIEWS_FORMAT_HMD) &&
-	                       (scene->flag & SCE_HMD_RUNNING));
+	const bool HMD_view =
+#ifdef WITH_INPUT_HMD
+	        ((CTX_wm_manager(C)->win_hmd == CTX_wm_window(C)) &&
+	         (scene->r.views_format == SCE_VIEWS_FORMAT_HMD) &&
+	         (scene->flag & SCE_HMD_RUNNING));
+#else
+	        false;
+#endif
 
 	/* if we only redraw render border area, skip opengl draw and also
 	 * don't do scissor because it's already set */
diff --git a/source/blender/makesdna/CMakeLists.txt b/source/blender/makesdna/CMakeLists.txt
index c609070..d9cd9fe 100644
--- a/source/blender/makesdna/CMakeLists.txt
+++ b/source/blender/makesdna/CMakeLists.txt
@@ -27,4 +27,8 @@ if(WITH_FREESTYLE)
 	add_definitions(-DWITH_FREESTYLE)
 endif()
 
+if(WITH_INPUT_HMD)
+	add_definitions(-DWITH_INPUT_HMD)
+endif()
+
 add_subdirectory(intern)
diff --git a/source/blender/makesdna/DNA_windowmanager_types.h b/source/blender/makesdna/DNA_windowmanager_types.h
index 30980e9..463cdda 100644
--- a/source/blender/makesdna/DNA_windowmanager_types.h
+++ b/source/blender/makesdna/DNA_windowmanager_types.h
@@ -122,6 +122,13 @@ typedef struct ReportTimerInfo {
 
 /* reports need to be before wmWindowManager */
 
+#ifdef WITH_INPUT_HMD
+#  define win_hmd win_hmd
+#else
+#  ifdef __GNUC__
+#    define win_hmd win_hmd __attribute__ ((deprecated))
+#  endif
+#endif
 
 /* windowmanager is saved, tag WMAN */
 typedef struct wmWindowManager {
@@ -159,6 +166,10 @@ typedef struct wmWindowManager {
 	char par[7];
 } wmWindowManager;
 
+#ifdef win_hmd
+#  undef win_hmd
+#endif
+
 /* wmWindowManager.initialized */
 enum {
 	WM_INIT_WINDOW = (1<<0),
diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt
index 31bf0c9..f75f5b6 100644
--- a/source/blender/makesrna/intern/CMakeLists.txt
+++ b/source/blender/makesrna/intern/CMakeLists.txt
@@ -223,6 +223,10 @@ if(WITH_IMAGE_FRAMESERVER)
 	add_definitions(-DWITH_FRAMESERVER)
 endif()
 
+if(WITH_INPUT_HMD)
+	add_definitions(-DWITH_INPUT_HMD)
+endif()
+
 if(WITH_AUDASPACE)
 	add_definitions(${AUDASPACE_DEFINITIONS})
 
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 9ce3d94..a196d75 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -812,6 +812,7 @@ static void rna_RenderSettings_stereoViews_begin(CollectionPropertyIterator *ite
 	rna_iterator_listbase_begin(iter, &rd->views, rna_RenderSettings_stereoViews_skip);
 }
 
+#ifdef WITH_INPUT_HMD
 static void rna_RenderSettings_hmd_camlock_update(
         struct Main *UNUSED(main), struct Scene *scene,
         struct PointerRNA *UNUSED(ptr))
@@ -866,6 +867,7 @@ static void rna_RenderSettings_hmd_view_lensdist_set(PointerRNA *ptr, int value)
 		}
 	}
 }
+#endif /* WITH_INPUT_HMD */
 
 static char *rna_RenderSettings_path(PointerRNA *UNUSED(ptr))
 {
@@ -5289,7 +5291,9 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
 		                        "Single stereo camera system, adjust the ster

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list