From ccebbc4bb31d40afe08501585c966ff40d7ab19e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20Garc=C3=ADa=20Li=C3=B1=C3=A1n?= Date: Thu, 29 Apr 2021 12:07:13 +0200 Subject: [PATCH] Compositor: Move cull mask setter to a separate function --- simgear/scene/viewer/Compositor.cxx | 24 ++++++++++++----------- simgear/scene/viewer/Compositor.hxx | 2 ++ simgear/scene/viewer/CompositorBuffer.cxx | 1 + 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/simgear/scene/viewer/Compositor.cxx b/simgear/scene/viewer/Compositor.cxx index 2a93e980..ede9d0f2 100644 --- a/simgear/scene/viewer/Compositor.cxx +++ b/simgear/scene/viewer/Compositor.cxx @@ -160,17 +160,6 @@ Compositor::update(const osg::Matrix &view_matrix, const osg::Matrix &proj_matrix) { for (auto &pass : _passes) { - if (pass->inherit_cull_mask) { - osg::Camera *camera = pass->camera; - osg::Camera *view_camera = _view->getCamera(); - camera->setCullMask(pass->cull_mask - & view_camera->getCullMask()); - camera->setCullMaskLeft(pass->cull_mask - & view_camera->getCullMaskLeft()); - camera->setCullMaskRight(pass->cull_mask - & view_camera->getCullMaskRight()); - } - if (pass->update_callback.valid()) pass->update_callback->updatePass(*pass.get(), view_matrix, proj_matrix); } @@ -257,6 +246,19 @@ Compositor::resized() } } +void +Compositor::setCullMask(osg::Node::NodeMask cull_mask) +{ + for (auto &pass : _passes) { + 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); + } + } +} + void Compositor::addBuffer(const std::string &name, Buffer *buffer) { diff --git a/simgear/scene/viewer/Compositor.hxx b/simgear/scene/viewer/Compositor.hxx index e4b36c04..0fccc2d9 100644 --- a/simgear/scene/viewer/Compositor.hxx +++ b/simgear/scene/viewer/Compositor.hxx @@ -100,6 +100,8 @@ public: void resized(); + void setCullMask(osg::Node::NodeMask cull_mask); + osg::View *getView() const { return _view; } osg::GraphicsContext *getGraphicsContext() const { return _gc; } diff --git a/simgear/scene/viewer/CompositorBuffer.cxx b/simgear/scene/viewer/CompositorBuffer.cxx index 869cf12d..6d2b9366 100644 --- a/simgear/scene/viewer/CompositorBuffer.cxx +++ b/simgear/scene/viewer/CompositorBuffer.cxx @@ -52,6 +52,7 @@ PropStringMap buffer_format_map { {"r32f", {GL_R32F, GL_RED, GL_FLOAT}}, {"rg16f", {GL_RG16F, GL_RG, GL_FLOAT}}, {"rg32f", {GL_RG32F, GL_RG, GL_FLOAT}}, + {"r11g11b10f", {GL_R11F_G11F_B10F_EXT, GL_RGB, GL_FLOAT}}, {"depth16", {GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT}}, {"depth24", {GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT}}, {"depth32f", {GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT, GL_FLOAT}},