[Bf-blender-cvs] [2d9f41b1bd1] HMD_viewport: Replace wm_device.c with wm_hmd.c, rename functions appropriately

Julian Eisel noreply at git.blender.org
Sat Apr 15 23:49:42 CEST 2017


Commit: 2d9f41b1bd134a5f8e35bf456e813c317bb844fe
Author: Julian Eisel
Date:   Sat Apr 15 23:48:12 2017 +0200
Branches: HMD_viewport
https://developer.blender.org/rB2d9f41b1bd134a5f8e35bf456e813c317bb844fe

Replace wm_device.c with wm_hmd.c, rename functions appropriately

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

M	source/blender/editors/interface/resources.c
M	source/blender/editors/space_view3d/view3d_draw.c
M	source/blender/makesrna/intern/rna_userdef.c
M	source/blender/windowmanager/CMakeLists.txt
M	source/blender/windowmanager/WM_api.h
R072	source/blender/windowmanager/intern/wm_device.c	source/blender/windowmanager/intern/wm_hmd.c
M	source/blender/windowmanager/intern/wm_operators.c
M	source/blender/windowmanager/intern/wm_window.c
M	source/blenderplayer/bad_level_call_stubs/stubs.c

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

diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c
index 3d290876200..2b465a8b5ad 100644
--- a/source/blender/editors/interface/resources.c
+++ b/source/blender/editors/interface/resources.c
@@ -2767,7 +2767,7 @@ void init_userdef_do_versions(void)
 	 */
 	{
 #ifdef WITH_INPUT_HMD
-		if (WM_device_HMD_num_devices_get() > 0) {
+		if (WM_HMD_num_devices_get() > 0) {
 			U.hmd_settings.device = 0;
 		}
 		else
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index 8b083d9885c..0db5b703671 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -338,9 +338,9 @@ static void view3d_hmd_calc_projection_matrix_from_device(
 	const float v3d_znear = v3d->near;
 	const float v3d_zfar = v3d->far;
 	const float v3d_lens = v3d->lens;
-	const float hmd_znear = WM_device_HMD_projection_z_near_get();
-	const float hmd_zfar = WM_device_HMD_projection_z_far_get();
-	const float hmd_fov = WM_device_HMD_FOV_get(is_left);
+	const float hmd_znear = WM_HMD_device_projection_z_near_get();
+	const float hmd_zfar = WM_HMD_device_projection_z_far_get();
+	const float hmd_fov = WM_HMD_device_FOV_get(is_left);
 	/* force using View3D settings which were overriden by HMD ones, using camera settings would mess up projection */
 	const char rv3d_persp = rv3d->persp;
 
@@ -369,8 +369,8 @@ static void view3d_hmd_calc_projection_matrix_from_device(
 	if (mat_type != HMD_MATRIX_CENTER) {
 		/* calculate lens offset in [-1, 1] range to apply onto projection matrix.
 		 * This follows logic of OpenHMD */
-		const float lens_sep = WM_device_HMD_lens_horizontal_separation_get();
-		const float hsize = WM_device_HMD_screen_horizontal_size_get();
+		const float lens_sep = WM_HMD_device_lens_horizontal_separation_get();
+		const float hsize = WM_HMD_device_screen_horizontal_size_get();
 		const float proj_offset = 1 - ((2 * lens_sep) / hsize);
 		float ofs_mat[4][4];
 
@@ -393,7 +393,7 @@ static void view3d_hmd_calc_modelview_matrix_from_device(
 {
 	float hmd_modelviewmat[4][4];
 
-	WM_device_HMD_modelview_matrix_get(mat_type == HMD_MATRIX_LEFT_EYE, hmd_modelviewmat);
+	WM_HMD_device_modelview_matrix_get(mat_type == HMD_MATRIX_LEFT_EYE, hmd_modelviewmat);
 
 	if (rv3d->persp == RV3D_CAMOB && v3d->camera) {
 		float v3d_modelviewmat[4][4], hmd_modelviewmat_tmp[4][4];
@@ -447,7 +447,7 @@ static void view3d_hmd_get_matrices(
 		copy_m4_m4(r_modelviewmat, rv3d->viewmat);
 
 		if (mat_type != HMD_MATRIX_CENTER) {
-			const float ipd = WM_device_HMD_IPD_get();
+			const float ipd = WM_HMD_device_IPD_get();
 			/* apply IPD */
 			r_modelviewmat[3][0]  += (ipd * 0.5f) * ((mat_type == HMD_MATRIX_LEFT_EYE) ? 1.0f : -1.0f);
 		}
@@ -4077,7 +4077,7 @@ static void view3d_main_region_draw_objects(
 	bool do_compositing = false;
 	void *hmd_distortion_params =
 #ifdef WITH_INPUT_HMD
-	        WM_window_is_running_hmd_view(win) ? WM_device_HMD_distortion_parameters_get() : NULL;
+	        WM_window_is_running_hmd_view(win) ? WM_HMD_device_distortion_parameters_get() : NULL;
 #else
 	        NULL;
 #endif
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index 28f2b2b2fac..2f6164885f0 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -586,10 +586,10 @@ static EnumPropertyItem *rna_userdef_hmd_device_itemf(
 	RNA_enum_item_add(&item, &totitem, &hmd_device_items[0]);
 
 	/* add devices */
-	for (int i = 0; i < WM_device_HMD_num_devices_get() && i < MAX_HMD_DEVICES; i++) {
+	for (int i = 0; i < WM_HMD_num_devices_get() && i < MAX_HMD_DEVICES; i++) {
 		EnumPropertyItem tmp = {i, "", 0, "", ""};
 
-		BLI_snprintf(names[i], sizeof(names[i]), "%s %s", WM_device_HMD_vendor_get(i), WM_device_HMD_name_get(i));
+		BLI_snprintf(names[i], sizeof(names[i]), "%s %s", WM_HMD_device_vendor_get(i), WM_HMD_device_name_get(i));
 		tmp.identifier = tmp.name = names[i];
 		RNA_enum_item_add(&item, &totitem, &tmp);
 	}
@@ -602,15 +602,15 @@ static EnumPropertyItem *rna_userdef_hmd_device_itemf(
 
 static void rna_userdef_hmd_device_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr))
 {
-	const int act_device = WM_device_HMD_current_get();
+	const int act_device = WM_HMD_device_active_get();
 
 	if (U.hmd_settings.device < 0) {
 		/* disabled device ('None' entry) */
-		WM_device_HMD_state_set(act_device, false);
+		WM_HMD_device_state_set(act_device, false);
 	}
 	else if (act_device != U.hmd_settings.device) {
 		/* change device */
-		WM_device_HMD_state_set(U.hmd_settings.device, true);
+		WM_HMD_device_state_set(U.hmd_settings.device, true);
 	}
 }
 
@@ -618,12 +618,12 @@ void rna_userdef_use_hmd_device_ipd_set(PointerRNA *UNUSED(ptr), int value)
 {
 	if (value) {
 		U.hmd_settings.flag |= USER_HMD_USE_DEVICE_IPD;
-		WM_device_HMD_IPD_set(U.hmd_settings.init_ipd);
+		WM_HMD_device_IPD_set(U.hmd_settings.init_ipd);
 	}
 	else {
 		U.hmd_settings.flag &= ~USER_HMD_USE_DEVICE_IPD;
-		U.hmd_settings.init_ipd = WM_device_HMD_IPD_get();
-		WM_device_HMD_IPD_set(U.hmd_settings.custom_ipd);
+		U.hmd_settings.init_ipd = WM_HMD_device_IPD_get();
+		WM_HMD_device_IPD_set(U.hmd_settings.custom_ipd);
 	}
 }
 
@@ -640,7 +640,7 @@ void rna_userdef_hmd_custom_ipd_set(PointerRNA *UNUSED(ptr), float value)
 {
 	U.hmd_settings.custom_ipd = value;
 	if ((U.hmd_settings.flag & USER_HMD_USE_DEVICE_IPD) == 0) {
-		WM_device_HMD_IPD_set(value);
+		WM_HMD_device_IPD_set(value);
 	}
 }
 
diff --git a/source/blender/windowmanager/CMakeLists.txt b/source/blender/windowmanager/CMakeLists.txt
index 36043bb1f96..9c220b1402d 100644
--- a/source/blender/windowmanager/CMakeLists.txt
+++ b/source/blender/windowmanager/CMakeLists.txt
@@ -68,7 +68,6 @@ set(SRC
 	intern/wm_subwindow.c
 	intern/wm_window.c
 	intern/wm_stereo.c
-	intern/wm_device.c
 
 	WM_api.h
 	WM_keymap.h
@@ -148,6 +147,9 @@ if(WITH_INPUT_NDOF)
 endif()
 
 if(WITH_INPUT_HMD)
+	list(APPEND SRC
+		intern/wm_hmd.c
+	)
 	add_definitions(-DWITH_INPUT_HMD)
 endif()
 
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index ec7065c75a2..bc498edeca3 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -524,28 +524,28 @@ bool        WM_event_is_ime_switch(const struct wmEvent *event);
 #endif
 
 
-/* wm_device.c */
+/* wm_hmd.c */
 
 #ifdef WITH_INPUT_HMD
 
 #define MAX_HMD_DEVICES 12
 
 /* Get/Set Wrappers */
-int         WM_device_HMD_num_devices_get(void) ATTR_WARN_UNUSED_RESULT;
-int         WM_device_HMD_current_get(void) ATTR_WARN_UNUSED_RESULT;
-const char *WM_device_HMD_name_get(int index) ATTR_WARN_UNUSED_RESULT;
-const char *WM_device_HMD_vendor_get(int index) ATTR_WARN_UNUSED_RESULT;
-float       WM_device_HMD_IPD_get(void) ATTR_WARN_UNUSED_RESULT;
-void        WM_device_HMD_IPD_set(float value);
-float       WM_device_HMD_lens_horizontal_separation_get(void) ATTR_WARN_UNUSED_RESULT;
-float       WM_device_HMD_projection_z_near_get(void);
-float       WM_device_HMD_projection_z_far_get(void);
-float       WM_device_HMD_screen_horizontal_size_get(void);
+int         WM_HMD_num_devices_get(void) ATTR_WARN_UNUSED_RESULT;
+int         WM_HMD_device_active_get(void) ATTR_WARN_UNUSED_RESULT;
+const char *WM_HMD_device_name_get(int index) ATTR_WARN_UNUSED_RESULT;
+const char *WM_HMD_device_vendor_get(int index) ATTR_WARN_UNUSED_RESULT;
+float       WM_HMD_device_IPD_get(void) ATTR_WARN_UNUSED_RESULT;
+void        WM_HMD_device_IPD_set(float value);
+float       WM_HMD_device_lens_horizontal_separation_get(void) ATTR_WARN_UNUSED_RESULT;
+float       WM_HMD_device_projection_z_near_get(void) ATTR_WARN_UNUSED_RESULT;
+float       WM_HMD_device_projection_z_far_get(void) ATTR_WARN_UNUSED_RESULT;
+float       WM_HMD_device_screen_horizontal_size_get(void) ATTR_WARN_UNUSED_RESULT;
 /* Utils */
-void WM_device_HMD_state_set(const int device, const bool enable);
-void WM_device_HMD_modelview_matrix_get(const bool is_left, float r_modelviewmat[4][4]) ATTR_NONNULL();
-float WM_device_HMD_FOV_get(const bool is_left);
-void *WM_device_HMD_distortion_parameters_get(void);
+void WM_HMD_device_state_set(const int device, const bool enable);
+void WM_HMD_device_modelview_matrix_get(const bool is_left, float r_modelviewmat[4][4]) ATTR_NONNULL();
+float WM_HMD_device_FOV_get(const bool is_left) ATTR_WARN_UNUSED_RESULT;
+void *WM_HMD_device_distortion_parameters_get(void) ATTR_WARN_UNUSED_RESULT;
 
 #endif /* WITH_INPUT_HMD */
 
diff --git a/source/blender/windowmanager/intern/wm_device.c b/source/blender/windowmanager/intern/wm_hmd.c
similarity index 72%
rename from source/blender/windowmanager/intern/wm_device.c
rename to source/blender/windowmanager/intern/wm_hmd.c
index 73f866bc7c1..bd35e014774 100644
--- a/source/blender/windowmanager/intern/wm_device.c
+++ b/source/blender/windowmanager/intern/wm_hmd.c
@@ -20,14 +20,11 @@
  * ***** END GPL LICENSE BLOCK *****
  */
 
-/** \file blender/windowmanager/intern/wm_device.c
+/** \file blender/windowmanager/intern/wm_hmd.c
  *  \ingroup wm
- *
- * Get/set functions and utilities for physical devices (GHOST wrappers).
+ *  \name Head Mounted Displays
  */
 
-#ifdef WITH_INPUT_HMD
-
 #include "BKE_context.h"
 
 #include "BLI_math.h"
@@ -41,15 +38,9 @@
 #include "wm.h"
 
 
-/* -------------------------------------------------------------------- */
-/* HMDs */
-
-/** \name Head Mounted Displays
- * \{ */
-
 /* ------ Get/Set Wrappers ------ */
 
-int WM_device_HMD_num_devices_get(void)
+int WM_HMD_num_devices_get(void)
 {
 	const int tot_devices = GHOST_HMDgetNumDevices();
 
@@ -64,18 +55,18 @@ int WM_device_HMD_num_devices_get(void)
 /**
  * Get index of currently open device.
  */
-int WM_device_HMD_current_get(void)
+int WM_HMD_device_active_get(void)
 {
 	return GHOST_HMDgetOpenDeviceIndex();
 }
 
-const char *WM_device_HMD_name_get(int index)
+const char *WM_HMD_device_name_get(int index)
 {
 	BLI_assert(index < MAX_HMD_DEVICES);
 	return GHOST_HMDgetDeviceName(index);
 }
 
-const char *WM_device_HMD_vendor_get(int index)
+const char *WM_HMD_device_vendor_get(

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list