[Bf-blender-cvs] [408cbe9] HMD_viewport: minor changes ui patches copied from Severin

Galadus noreply at git.blender.org
Wed Mar 16 16:10:50 CET 2016


Commit: 408cbe918bf73472815c59fe4baa1307223817d9
Author: Galadus
Date:   Thu Mar 10 01:38:26 2016 +0100
Branches: HMD_viewport
https://developer.blender.org/rB408cbe918bf73472815c59fe4baa1307223817d9

minor changes
ui patches copied from Severin

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

M	intern/ghost/intern/GHOST_OpenHMDManager.cpp
M	intern/ghost/intern/GHOST_OpenHMDManager.h
M	intern/ghost/intern/GHOST_System.h
M	release/scripts/startup/bl_ui/properties_render_layer.py
M	source/blender/editors/interface/interface_handlers.c
M	source/blender/makesdna/DNA_scene_types.h
M	source/blender/makesrna/intern/rna_scene.c
M	source/blender/windowmanager/intern/wm_operators.c

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

diff --git a/intern/ghost/intern/GHOST_OpenHMDManager.cpp b/intern/ghost/intern/GHOST_OpenHMDManager.cpp
index 0adeb8b..7a389d3 100644
--- a/intern/ghost/intern/GHOST_OpenHMDManager.cpp
+++ b/intern/ghost/intern/GHOST_OpenHMDManager.cpp
@@ -19,7 +19,7 @@ GHOST_OpenHMDManager::GHOST_OpenHMDManager(GHOST_System& sys)
         if (num_devices > 0) {
             m_available = true;
 
-            printf("Found %i OpenHMD devices", num_devices);
+            printf("Found %i OpenHMD devices\n", num_devices);
             for (int i = 0; i < num_devices; ++i) {
                 printf("Device %i\n", i);
                 printf("vendor: %s\n", ohmd_list_gets(m_context, i, OHMD_VENDOR));
@@ -40,18 +40,6 @@ GHOST_OpenHMDManager::GHOST_OpenHMDManager(GHOST_System& sys)
     else {
         printf("Failed to create OpenHMD Context\n");
     }
-
-
-    /*
-	ohmd_device_geti(hmd, OHMD_SCREEN_HORIZONTAL_RESOLUTION, &ival);
-	ohmd_device_geti(hmd, OHMD_SCREEN_VERTICAL_RESOLUTION, &ival);
-	ohmd_device_getf(hmd, OHMD_SCREEN_HORIZONTAL_SIZE, &fval);
-	ohmd_device_getf(hmd, OHMD_SCREEN_VERTICAL_SIZE, &fval);
-	ohmd_device_getf(hmd, OHMD_LENS_HORIZONTAL_SEPARATION, &fval);
-	ohmd_device_getf(hmd, OHMD_LENS_VERTICAL_POSITION, &fval);
-	ohmd_device_getf(hmd, OHMD_LEFT_EYE_FOV, &fval);
-	ohmd_device_getf(hmd, OHMD_LEFT_EYE_ASPECT_RATIO, &fval);
-    */
 }
 
 GHOST_OpenHMDManager::~GHOST_OpenHMDManager()
@@ -76,6 +64,14 @@ bool GHOST_OpenHMDManager::processEvents()
 
         ohmd_device_getf(m_device, OHMD_ROTATION_QUAT, data->orientation);
 
+        printf("sending openhmd event with data x y z w %f %f %f %f at time %llu\n",
+               data->orientation[0],
+               data->orientation[1],
+               data->orientation[2],
+               data->orientation[3],
+               now);
+
+
         m_system.pushEvent(event);
         return true;
 	}
@@ -83,3 +79,30 @@ bool GHOST_OpenHMDManager::processEvents()
         return false;
 	}
 }
+
+bool GHOST_OpenHMDManager::available() const
+{
+    return m_available;
+}
+
+bool GHOST_OpenHMDManager::setDevice(const char* requested_vendor_name, const char* requested_device_name)
+{
+    if (!m_available) {
+        return false;
+    }
+
+    int num_devices = ohmd_ctx_probe(m_context);
+    for (int i = 0; i < num_devices; ++i) {
+        const char* device_name = ohmd_list_gets(m_context, i, OHMD_PRODUCT);
+        const char* vendor_name = ohmd_list_gets(m_context, i, OHMD_VENDOR);
+
+        if (strcmp(device_name, requested_device_name) == 0 && strcmp(vendor_name, requested_vendor_name) == 0) {
+            //can't fail
+            m_device = ohmd_list_open_device(m_context, i);
+            return true;
+        }
+    }
+
+    //couldn't find a device by that name and vendor, the old device was preserved.
+    return false;
+}
diff --git a/intern/ghost/intern/GHOST_OpenHMDManager.h b/intern/ghost/intern/GHOST_OpenHMDManager.h
index 1d20e4b..56b7966 100644
--- a/intern/ghost/intern/GHOST_OpenHMDManager.h
+++ b/intern/ghost/intern/GHOST_OpenHMDManager.h
@@ -36,8 +36,11 @@ public:
     GHOST_OpenHMDManager(GHOST_System&); // TODO maybe cut out dependency on the system? (only used for getMilliSeconds and none of the others without platform implementations use it)
     virtual ~GHOST_OpenHMDManager();
 
+    bool available() const;
     bool processEvents();
 
+    bool setDevice(const char* requested_vendor_name, const char* requested_device_name);
+
 protected:
     GHOST_System&   m_system;
 
@@ -46,59 +49,6 @@ private:
 
     ohmd_context*   m_context;
     ohmd_device*    m_device;
-
-
-
-
-
-    /*
-	// whether multi-axis functionality is available (via the OS or driver)
-	// does not imply that a device is plugged in or being used
-	virtual bool available() = 0;
-
-	// each platform's device detection should call this
-	// use standard USB/HID identifiers
-	bool setDevice(unsigned short vendor_id, unsigned short product_id);
-
-	// the latest raw axis data from the device
-	// NOTE: axis data should be in blender view coordinates
-	//       +X is to the right
-	//       +Y is up
-	//       +Z is out of the screen
-	//       for rotations, look from origin to each +axis
-	//       rotations are + when CCW, - when CW
-	// each platform is responsible for getting axis data into this form
-	// these values should not be scaled (just shuffled or flipped)
-	void updateTranslation(const short t[3], GHOST_TUns64 time);
-	void updateRotation(const short r[3], GHOST_TUns64 time);
-
-	// processes and sends most recent raw data as an NDOFMotion event
-	// returns whether an event was sent
-	bool sendMotionEvent();
-
-protected:
-	GHOST_System& m_system;
-
-private:
-	void sendButtonEvent(NDOF_ButtonT, bool press, GHOST_TUns64 time, GHOST_IWindow *);
-	void sendKeyEvent(GHOST_TKey, bool press, GHOST_TUns64 time, GHOST_IWindow *);
-
-	NDOF_DeviceT m_deviceType;
-	int m_buttonCount;
-	int m_buttonMask;
-	const NDOF_ButtonT *m_hidMap;
-
-	short m_translation[3];
-	short m_rotation[3];
-	int m_buttons; // bit field
-
-	GHOST_TUns64 m_motionTime; // in milliseconds
-	GHOST_TUns64 m_prevMotionTime; // time of most recent Motion event sent
-
-	GHOST_TProgress m_motionState;
-	bool m_motionEventPending;
-	float m_deadZone; // discard motion with each component < this
-	*/
 };
 
 #endif //__GHOST_OPENHMDMANAGER_H__
diff --git a/intern/ghost/intern/GHOST_System.h b/intern/ghost/intern/GHOST_System.h
index 9c88f95..2656f9c 100644
--- a/intern/ghost/intern/GHOST_System.h
+++ b/intern/ghost/intern/GHOST_System.h
@@ -281,6 +281,11 @@ public:
 	inline GHOST_NDOFManager *getNDOFManager() const;
 #endif
 
+    /**
+     * \return A pointer to our OpenHMD manager.
+     */
+    inline GHOST_OpenHMDManager *getOpenHMDManager() const;
+
 	/**
 	 * Returns the state of all modifier keys.
 	 * \param keys	The state of all modifier keys (true == pressed).
@@ -388,6 +393,11 @@ inline GHOST_NDOFManager *GHOST_System::getNDOFManager() const
 {
 	return m_ndofManager;
 }
+
+inline GHOST_OpenHMDManager *GHOST_System::getOpenHMDManager() const
+{
+    return m_openHMDManager;
+}
 #endif
 
 #endif // __GHOST_SYSTEM_H__
diff --git a/release/scripts/startup/bl_ui/properties_render_layer.py b/release/scripts/startup/bl_ui/properties_render_layer.py
index 9b8bc23..13150c5 100644
--- a/release/scripts/startup/bl_ui/properties_render_layer.py
+++ b/release/scripts/startup/bl_ui/properties_render_layer.py
@@ -206,15 +206,14 @@ class RENDERLAYER_PT_views(RenderLayerButtonsPanel, Panel):
         row = layout.row()
         row.prop(rd, "views_format", expand=True)
 
-        if basic_stereo:
+        if rd.views_format == 'STEREO_3D':
             row = layout.row()
             row.template_list("RENDERLAYER_UL_renderviews", "name", rd, "stereo_views", rd.views, "active_index", rows=2)
 
             row = layout.row()
             row.label(text="File Suffix:")
             row.prop(rv, "file_suffix", text="")
-
-        else:
+        elif rd.views_format == 'MULTIVIEW':
             row = layout.row()
             row.template_list("RENDERLAYER_UL_renderviews", "name", rd, "views", rd.views, "active_index", rows=2)
 
@@ -225,6 +224,10 @@ class RENDERLAYER_PT_views(RenderLayerButtonsPanel, Panel):
             row = layout.row()
             row.label(text="Camera Suffix:")
             row.prop(rv, "camera_suffix", text="")
+        else:
+            col = layout.column()
+            col.prop(rd, "hmd_camera_lock")
+            col.operator("wm.hmd_view_open")
 
 
 if __name__ == "__main__":  # only for live edit.
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 86e863a..89f718b 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -9836,16 +9836,6 @@ static int ui_region_handler(bContext *C, const wmEvent *event, void *UNUSED(use
 	/* delayed apply callbacks */
 	ui_apply_but_funcs_after(C);
 
-	if (event->type == EVT_VR_TRANSFORM) {
-        float* trans = event->customdata;
-
-        printf("Got EVT_VR_TRANSFORM event, transform is w x y z %f %f %f %f\n",
-               trans[0],
-               trans[1],
-               trans[2],
-               trans[3]);
-	}
-
 	return retval;
 }
 
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index c4f0395..005cfe6 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -108,7 +108,7 @@ typedef struct QuicktimeCodecData {
 
 	char			qtcodecname[128];
 } QuicktimeCodecData;
-	
+
 typedef struct QuicktimeCodecSettings {
 	/* Codec settings detailed for 2.5 implementation*/
 	int codecType; /* Types defined in quicktime_export.h */
@@ -123,7 +123,7 @@ typedef struct QuicktimeCodecSettings {
 	int	minTemporalQuality; /* in 0-100 scale, to be translated in 0-1024 for qt use */
 	int	keyFrameRate;
 	int	bitRate;	/* bitrate in bps */
-	
+
 	/* Audio Codec settings */
 	int audiocodecType;
 	int audioSampleRate;
@@ -176,23 +176,23 @@ typedef struct AudioData {
 /* Render Layer */
 typedef struct SceneRenderLayer {
 	struct SceneRenderLayer *next, *prev;
-	
+
 	char name[64];	/* MAX_NAME */
-	
+
 	struct Material *mat_override;
 	struct Group *light_override;
-	
+
 	unsigned int lay;		  /* scene->lay itself has priority over this */
 	unsigned int lay_zmask;	  /* has to be after lay, this is for Z-masking */
 	unsigned int lay_exclude; /* not used by internal, exclude */
 	int layflag;
-	
+
 	int passflag;			/* pass_xor has to be after passflag */
 	int pass_xor;
 
 	int samples;
 	float pass_alpha_threshold;
-	
+
 	struct FreestyleConfig freestyleConfig;
 } SceneRenderLayer;
 
@@ -271,6 +271,7 @@ typedef struct SceneRenderView {
 enum {
 	SCE_VIEWS_FORMAT_STEREO_3D = 0,
 	SCE_VIEWS_FORMAT_MULTIVIEW = 1,
+	SCE_VIEWS_FORMAT_HMD       = 2,
 };
 
 /* ImageFormatData.views_output */
@@ -510,7 +511,7 @@ typedef enum BakePassFilter {
 
 typedef struct RenderData {
 	struct ImageFormatData im_format;
-	
+
 	struct AviCodecData *avicodecdata;
 	struct QuicktimeCodecData *qtcodecdata;
 	struct QuicktimeCodecSettings qtcodecsettings;
@@ -539,13 +540,13 @@ typede

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list