Commit 5023acc1 authored by Robin Eschbach's avatar Robin Eschbach
Browse files

[FIX #733] Vr module crash on initialization

parent 89539b94
......@@ -75,10 +75,11 @@ void WMVRCamera::properties()
{
m_propCondition = std::shared_ptr<WCondition>( new WCondition() );
m_vrOn = m_properties->addProperty( "Submit Frames", "Toggle submitting frames to OpenVR", false );
m_VR_fpsTrigger = m_properties->addProperty( "Log Fps", "Now", WPVBaseTypes::PV_TRIGGER_READY );
m_VR_logCameraViewMatrix = m_properties->addProperty( "Log Camera View Matrix", "Now", WPVBaseTypes::PV_TRIGGER_READY );
m_VR_resetHMDPosition = m_properties->addProperty( "Reset position", "Reset", WPVBaseTypes::PV_TRIGGER_READY );
m_vrOn = m_properties->addProperty( "Submit Frames", "Toggle submitting frames to OpenVR", false, true );
m_VR_fpsTrigger = m_properties->addProperty( "Log Fps", "Now", WPVBaseTypes::PV_TRIGGER_READY, true );
m_VR_logCameraViewMatrix = m_properties->addProperty( "Log Camera View Matrix", "Now", WPVBaseTypes::PV_TRIGGER_READY, true );
m_VR_resetHMDPosition = m_properties->addProperty( "Reset position", "Reset", WPVBaseTypes::PV_TRIGGER_READY, true );
m_VR_reinit = m_properties->addProperty( "Re-initialize VR-System", "Init", WPVBaseTypes::PV_TRIGGER_READY );
WModule::properties();
}
......@@ -148,19 +149,36 @@ void WMVRCamera::moduleMain()
// HMD Setup
/////////////////////////////////////////////////////////////////////////////////////////////////////////
if( setupVRInterface() )
{
debugLog() << "OpenVR initialized successfully";
m_vrIsInitialized = true;
}
else
ready();
while( !setupVRInterface() )
{
if( m_shutdownFlag() )
{
return;
}
errorLog() << "OpenVR failed to initialize";
m_vrRenderWidth = 1736;
m_vrRenderHeight = 1928;
m_vrIsInitialized = false;
while( m_VR_reinit->get( false ) != WPVBaseTypes::PV_TRIGGER_TRIGGERED )
{
if( m_shutdownFlag() )
{
return;
}
}
m_VR_reinit->set( WPVBaseTypes::PV_TRIGGER_READY, false );
}
m_VR_reinit->setHidden( true );
m_vrOn->setHidden( false );
m_VR_fpsTrigger->setHidden( false );
m_VR_logCameraViewMatrix->setHidden( false );
m_VR_resetHMDPosition->setHidden( false );
debugLog() << "OpenVR initialized successfully";
m_vrIsInitialized = true;
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// Render to Texture Setup
/////////////////////////////////////////////////////////////////////////////////////////////////////////
......@@ -197,7 +215,6 @@ void WMVRCamera::moduleMain()
ResetHMDPosition();
// Now, we can mark the module ready.
ready();
debugLog() << "Starting...";
// loop until the module container requests the module to quit
......
......@@ -214,6 +214,7 @@ private:
WPropTrigger m_VR_fpsTrigger; //!< A trigger for debugging the FPS while VR module is running.
WPropTrigger m_VR_logCameraViewMatrix; //!< A trigger for debugging camera matrix of VR module.
WPropTrigger m_VR_resetHMDPosition; //!< A trigger for resetting the camera to the seated zero position of the HMD device.
WPropTrigger m_VR_reinit; //!< A trigger to reinit the module if no headset was found.
vr::IVRSystem *m_vrSystem; //!< The OpenVR SDK Interface.
vr::IVRRenderModels *m_vrRenderModels; //!< The OpenVR RenderModel Interface.
......
......@@ -119,7 +119,7 @@ void WSwapUpdateCallback::submitFrame()
if( lError != vr::VRCompositorError_None || rError != vr::VRCompositorError_None )
{
m_module->errorLog() << "Links:" << lError << "|Rechts:" << rError << std::endl;
m_module->errorLog() << "Left:" << lError << " | Right:" << rError << std::endl;
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment