1
0
Fork 0

Fix hotspots being shown for a single frame after startup

FGRenderer::update() happens after the CameraGroup is updated, which causes the
Compositor to use the previous frame cull mask. Setting the cull masks
explicitly during FGRenderer::update() fixes the issue.
This commit is contained in:
Fernando García Liñán 2021-04-29 12:18:50 +02:00
parent 94c202375c
commit 558a498850
3 changed files with 19 additions and 8 deletions

View file

@ -816,6 +816,15 @@ CameraGroup* CameraGroup::buildCameraGroup(osgViewer::View* view,
return cgroup; return cgroup;
} }
void CameraGroup::setCameraCullMasks(osg::Node::NodeMask nm)
{
for (auto& info : _cameras) {
if (info->flags & CameraInfo::GUI)
continue;
info->compositor->setCullMask(nm);
}
}
void CameraGroup::resized() void CameraGroup::resized()
{ {
for (const auto &info : _cameras) for (const auto &info : _cameras)

View file

@ -176,6 +176,9 @@ public:
* current viewport. * current viewport.
*/ */
void setCameraParameters(float vfov, float aspectRatio); void setCameraParameters(float vfov, float aspectRatio);
/** Set the cull mask on all non-GUI cameras
*/
void setCameraCullMasks(osg::Node::NodeMask nm);
/** Update camera properties after a resize event. /** Update camera properties after a resize event.
*/ */
void resized(); void resized();

View file

@ -854,15 +854,14 @@ FGRenderer::update( ) {
l->get_sun_angle()*SGD_RADIANS_TO_DEGREES); l->get_sun_angle()*SGD_RADIANS_TO_DEGREES);
_updateVisitor->setVisibility(actual_visibility); _updateVisitor->setVisibility(actual_visibility);
simgear::GroundLightManager::instance()->update(_updateVisitor.get()); simgear::GroundLightManager::instance()->update(_updateVisitor.get());
}
osg::Node::NodeMask cullMask = ~simgear::LIGHTS_BITS & ~simgear::PICK_BIT; osg::Node::NodeMask cullMask = ~simgear::LIGHTS_BITS & ~simgear::PICK_BIT;
cullMask |= simgear::GroundLightManager::instance() cullMask |= simgear::GroundLightManager::instance()
->getLightNodeMask(_updateVisitor.get()); ->getLightNodeMask(_updateVisitor.get());
if (_panel_hotspots->getBoolValue()) if (_panel_hotspots->getBoolValue())
cullMask |= simgear::PICK_BIT; cullMask |= simgear::PICK_BIT;
camera->setCullMask(cullMask); CameraGroup::getDefault()->setCameraCullMasks(cullMask);
camera->setCullMaskLeft(cullMask);
camera->setCullMaskRight(cullMask);
}
} }
void void