From 1d0a99a0770da0fea0290885a1b96324aad44ee8 Mon Sep 17 00:00:00 2001 From: James Hogan Date: Sat, 18 Sep 2021 08:27:24 +0100 Subject: [PATCH] Add LEFT & RIGHT nodemask bits Add LEFT_BIT and RIGHT_BIT node masks, which are only shown on the left or right viewports. These will be used for eye specific visibility masks with VR. --- simgear/scene/util/RenderConstants.hxx | 5 ++++- simgear/scene/viewer/Compositor.cxx | 4 ++-- simgear/scene/viewer/CompositorPass.cxx | 5 +++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/simgear/scene/util/RenderConstants.hxx b/simgear/scene/util/RenderConstants.hxx index eec6ac95..41740975 100644 --- a/simgear/scene/util/RenderConstants.hxx +++ b/simgear/scene/util/RenderConstants.hxx @@ -45,7 +45,10 @@ enum NodeMask { // eventually for other models? MODEL_BIT = (1 << 12), MODELLIGHT_BIT = (1 << 13), - PERMANENTLIGHT_BIT = (1 << 14) + PERMANENTLIGHT_BIT = (1 << 14), + // Used for per-eye VR visibility masks + LEFT_BIT = (1 << 15), + RIGHT_BIT = (1 << 16) }; // Theory of bin numbering: diff --git a/simgear/scene/viewer/Compositor.cxx b/simgear/scene/viewer/Compositor.cxx index b0cb67e0..5e2f5fce 100644 --- a/simgear/scene/viewer/Compositor.cxx +++ b/simgear/scene/viewer/Compositor.cxx @@ -374,8 +374,8 @@ Compositor::setCullMask(osg::Node::NodeMask cull_mask) if (pass->inherit_cull_mask) { osg::Camera *camera = pass->camera; camera->setCullMask(pass->cull_mask & cull_mask); - camera->setCullMaskLeft(pass->cull_mask & cull_mask); - camera->setCullMaskRight(pass->cull_mask & cull_mask); + camera->setCullMaskLeft(pass->cull_mask & cull_mask & ~RIGHT_BIT); + camera->setCullMaskRight(pass->cull_mask & cull_mask & ~LEFT_BIT); } } } diff --git a/simgear/scene/viewer/CompositorPass.cxx b/simgear/scene/viewer/CompositorPass.cxx index 9d850c23..bf3f74b9 100644 --- a/simgear/scene/viewer/CompositorPass.cxx +++ b/simgear/scene/viewer/CompositorPass.cxx @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -167,8 +168,8 @@ PassBuilder::build(Compositor *compositor, const SGPropertyNode *root, std::stoul(root->getStringValue("cull-mask", "0xffffffff"), nullptr, 0); pass->cull_mask = cull_mask; camera->setCullMask(pass->cull_mask); - camera->setCullMaskLeft(pass->cull_mask); - camera->setCullMaskRight(pass->cull_mask); + camera->setCullMaskLeft(pass->cull_mask & ~RIGHT_BIT); + camera->setCullMaskRight(pass->cull_mask & ~LEFT_BIT); osg::Vec4f clear_color(0.0f, 0.0f, 0.0f, 1.0f); const SGPropertyNode *p_clear_color = root->getChild("clear-color");