diff --git a/CMakeLists.txt b/CMakeLists.txt index 671f83980..43c0ba2e5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -152,7 +152,7 @@ elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR set(SYSTEM_HTS_ENGINE_DEFAULT 1) endif() - find_package(osgXR 0.3) + find_package(osgXR 0.3.3) if (osgXR_FOUND) set(ENABLE_OSGXR_DEFAULT 1) endif() diff --git a/src/Viewer/VRManager.cxx b/src/Viewer/VRManager.cxx index 5159614b3..3dd9ddb76 100644 --- a/src/Viewer/VRManager.cxx +++ b/src/Viewer/VRManager.cxx @@ -20,6 +20,7 @@ #include +#include #include #include
@@ -32,6 +33,7 @@ VRManager::VRManager() : _reloadCompositorCallback(new ReloadCompositorCallback(this)), _propXrLayersValidation("/sim/vr/openxr/layers/validation"), _propXrExtensionsDepthInfo("/sim/vr/openxr/extensions/depth-info"), + _propXrExtensionsVisibilityMask("/sim/vr/openxr/extensions/visibility-mask"), _propXrRuntimeName("/sim/vr/openxr/runtime/name"), _propXrSystemName("/sim/vr/openxr/system/name"), _propStateString("/sim/vr/state-string"), @@ -39,6 +41,7 @@ VRManager::VRManager() : _propRunning("/sim/vr/running"), _propEnabled("/sim/vr/enabled"), _propDepthInfo("/sim/vr/depth-info"), + _propVisibilityMask("/sim/vr/visibility-mask"), _propValidationLayer("/sim/vr/validation-layer"), _propMode("/sim/vr/mode"), _propSwapchainMode("/sim/vr/swapchain-mode"), @@ -46,6 +49,7 @@ VRManager::VRManager() : _propMirrorMode("/sim/vr/mirror-mode"), _listenerEnabled(this, &osgXR::Manager::setEnabled), _listenerDepthInfo(this, &VRManager::setDepthInfo), + _listenerVisibilityMask(this, &VRManager::setVisibilityMask), _listenerValidationLayer(this, &VRManager::setValidationLayer), _listenerMode(this, &VRManager::setVRMode), _listenerSwapchainMode(this, &VRManager::setSwapchainMode), @@ -57,6 +61,10 @@ VRManager::VRManager() : _settings->setApp("FlightGear", fgVersion); _settings->preferEnvBlendMode(osgXR::Settings::OPAQUE); + // Inform osgXR what node masks to use + setVisibilityMaskNodeMasks(simgear::NodeMask::LEFT_BIT, + simgear::NodeMask::RIGHT_BIT); + // Hook into viewer, but don't enable VR just yet osgViewer::View *view = globals->get_renderer()->getView(); if (view) { @@ -68,6 +76,7 @@ VRManager::VRManager() : _propEnabled.node(true)->addChangeListener(&_listenerEnabled, true); _propDepthInfo.node(true)->addChangeListener(&_listenerDepthInfo, true); + _propVisibilityMask.node(true)->addChangeListener(&_listenerVisibilityMask, true); _propValidationLayer.node(true)->addChangeListener(&_listenerValidationLayer, true); _propMode.node(true)->addChangeListener(&_listenerMode, true); _propSwapchainMode.node(true)->addChangeListener(&_listenerSwapchainMode, true); @@ -96,6 +105,7 @@ void VRManager::syncReadOnlyProperties() { _propXrLayersValidation = hasValidationLayer(); _propXrExtensionsDepthInfo = hasDepthInfoExtension(); + _propXrExtensionsVisibilityMask = hasVisibilityMaskExtension(); _propXrRuntimeName = getRuntimeName(); _propXrSystemName = getSystemName(); @@ -128,6 +138,12 @@ void VRManager::setDepthInfo(bool depthInfo) syncSettings(); } +void VRManager::setVisibilityMask(bool visibilityMask) +{ + _settings->setVisibilityMask(visibilityMask); + syncSettings(); +} + void VRManager::setVRMode(const char * mode) { osgXR::Settings::VRMode vrMode = osgXR::Settings::VRMODE_AUTOMATIC; diff --git a/src/Viewer/VRManager.hxx b/src/Viewer/VRManager.hxx index 71694a1bf..95d156d67 100644 --- a/src/Viewer/VRManager.hxx +++ b/src/Viewer/VRManager.hxx @@ -78,6 +78,7 @@ class VRManager : public osgXR::Manager void setValidationLayer(bool validationLayer); void setDepthInfo(bool depthInfo); + void setVisibilityMask(bool visibilityMask); void setVRMode(const char * mode); void setSwapchainMode(const char * mode); @@ -110,6 +111,7 @@ class VRManager : public osgXR::Manager SGPropObjBool _propXrLayersValidation; SGPropObjBool _propXrExtensionsDepthInfo; + SGPropObjBool _propXrExtensionsVisibilityMask; SGPropObjString _propXrRuntimeName; SGPropObjString _propXrSystemName; @@ -119,6 +121,7 @@ class VRManager : public osgXR::Manager SGPropObjBool _propEnabled; SGPropObjBool _propDepthInfo; + SGPropObjBool _propVisibilityMask; SGPropObjBool _propValidationLayer; SGPropObjString _propMode; SGPropObjString _propSwapchainMode; @@ -154,6 +157,7 @@ class VRManager : public osgXR::Manager ListenerBool _listenerEnabled; ListenerBool _listenerDepthInfo; + ListenerBool _listenerVisibilityMask; ListenerBool _listenerValidationLayer; ListenerString _listenerMode; ListenerString _listenerSwapchainMode;