Compositor: Move cull mask setter to a separate function

This commit is contained in:
Fernando García Liñán 2021-04-29 12:07:13 +02:00
parent fa40a6d1b8
commit ccebbc4bb3
3 changed files with 16 additions and 11 deletions

View File

@ -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)
{

View File

@ -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; }

View File

@ -52,6 +52,7 @@ PropStringMap<BufferFormat> 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}},