Commit: 3609e8868c806719933478f934c329b5af68d5c3
Author: TheOnlyJoey
Date:   Thu Mar 17 21:05:45 2016 +0100
Branches: HMD_viewport
https://developer.blender.org/rB3609e8868c806719933478f934c329b5af68d5c3

Added check for nan events from OpenHMD

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

M       intern/ghost/intern/GHOST_OpenHMDManager.cpp
M       intern/ghost/intern/GHOST_OpenHMDManager.h
M       intern/ghost/intern/GHOST_System.cpp

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

diff --git a/intern/ghost/intern/GHOST_OpenHMDManager.cpp 
b/intern/ghost/intern/GHOST_OpenHMDManager.cpp
index b7f384f..e3956cd 100644
--- a/intern/ghost/intern/GHOST_OpenHMDManager.cpp
+++ b/intern/ghost/intern/GHOST_OpenHMDManager.cpp
@@ -78,7 +78,8 @@ bool GHOST_OpenHMDManager::processEvents()
                GHOST_TEventOpenHMDData* data = (GHOST_TEventOpenHMDData*) 
event->getData();
 
                ohmd_ctx_update(m_context);
-               getRotationQuat(data->orientation);
+               if (!getRotationQuat(data->orientation))
+                       return false;
 
                m_system.pushEvent(event);
                return true;
@@ -171,19 +172,22 @@ const char *GHOST_OpenHMDManager::getPath() const
        return ohmd_list_gets(m_context, m_deviceIndex, OHMD_PATH);
 }
 
-void GHOST_OpenHMDManager::getRotationQuat(float orientation[4]) const
+bool GHOST_OpenHMDManager::getRotationQuat(float orientation[4]) const
 {
        if (!m_available) {
-               return;
+               return false;
        }
 
        float tmp[4];
-       ohmd_device_getf(m_device, OHMD_ROTATION_QUAT, tmp);
+       if (ohmd_device_getf(m_device, OHMD_ROTATION_QUAT, tmp) < 0)
+               return false;
 
        orientation[0] = tmp[3];
        orientation[1] = tmp[0];
        orientation[2] = tmp[1];
        orientation[3] = tmp[2];
+
+       return true;
 }
 
 void GHOST_OpenHMDManager::getLeftEyeGLModelviewMatrix(float mat[16]) const
diff --git a/intern/ghost/intern/GHOST_OpenHMDManager.h 
b/intern/ghost/intern/GHOST_OpenHMDManager.h
index e87bd85..20f0537 100644
--- a/intern/ghost/intern/GHOST_OpenHMDManager.h
+++ b/intern/ghost/intern/GHOST_OpenHMDManager.h
@@ -98,7 +98,7 @@ public:
         * \param orientation   The absolute orientation of the device, as 
quaternion, in blender format (w,x,y,z)
         *  Nothing is written if available() is false.
         */
-       void    getRotationQuat(float orientation[4]) const;
+       bool    getRotationQuat(float orientation[4]) const;
 
        /**
         * \param mat   A "ready to use" OpenGL style 4x4 matrix with a 
modelview matrix for the left eye of the HMD.
diff --git a/intern/ghost/intern/GHOST_System.cpp 
b/intern/ghost/intern/GHOST_System.cpp
index 9cd25b9..506a351 100644
--- a/intern/ghost/intern/GHOST_System.cpp
+++ b/intern/ghost/intern/GHOST_System.cpp
@@ -223,6 +223,8 @@ bool GHOST_System::processEvents(bool waitForEvent)
        }
 #endif
 
+       (void)waitForEvent; //silence!
+
        return anyProcessed;
 }

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

Reply via email to