Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not overwrite reserved visibility flags in ogre2 (Garden) #784

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ogre2/src/Ogre2Camera.cc
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,12 @@ void Ogre2Camera::SetFarClipPlane(const double _far)
//////////////////////////////////////////////////
void Ogre2Camera::SetVisibilityMask(uint32_t _mask)
{
if (_mask & ~Ogre::VisibilityFlags::RESERVED_VISIBILITY_FLAGS)
{
gzerr << "Ogre2Camera::SetVisibilityMask: Mask bits " << std::hex
<< ~Ogre::VisibilityFlags::RESERVED_VISIBILITY_FLAGS << std::dec
<< " are set but will be ignored by ogre2 backend." << std::endl;
}
BaseSensor::SetVisibilityMask(_mask);
if (this->renderTexture)
this->renderTexture->SetVisibilityMask(_mask);
Expand Down
12 changes: 6 additions & 6 deletions ogre2/src/Ogre2DepthCamera.cc
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ void Ogre2DepthCamera::CreateDepthTexture()
static_cast<Ogre::CompositorPassSceneDef *>(
colorTargetDef->addPass(Ogre::PASS_SCENE));
passScene->mShadowNode = this->dataPtr->kShadowNodeName;
passScene->mVisibilityMask = GZ_VISIBILITY_ALL;
passScene->setVisibilityMask(GZ_VISIBILITY_ALL);
passScene->mIncludeOverlays = false;
passScene->mFirstRQ = 0u;
passScene->mLastRQ = 2u;
Expand Down Expand Up @@ -748,7 +748,7 @@ void Ogre2DepthCamera::CreateDepthTexture()
Ogre::CompositorPassSceneDef *passScene =
static_cast<Ogre::CompositorPassSceneDef *>(
colorTargetDef->addPass(Ogre::PASS_SCENE));
passScene->mVisibilityMask = GZ_VISIBILITY_ALL;
passScene->setVisibilityMask(GZ_VISIBILITY_ALL);
// todo(anyone) PbsMaterialsShadowNode is hardcoded.
// Although this may be just fine
passScene->mShadowNode = this->dataPtr->kShadowNodeName;
Expand All @@ -770,8 +770,8 @@ void Ogre2DepthCamera::CreateDepthTexture()
this->FarClipPlane(),
this->FarClipPlane()));
// depth texute does not contain particles
passScene->mVisibilityMask = GZ_VISIBILITY_ALL
& ~Ogre2ParticleEmitter::kParticleVisibilityFlags;
passScene->setVisibilityMask(
GZ_VISIBILITY_ALL & ~Ogre2ParticleEmitter::kParticleVisibilityFlags);
}

Ogre::CompositorTargetDef *particleTargetDef =
Expand All @@ -784,8 +784,8 @@ void Ogre2DepthCamera::CreateDepthTexture()
particleTargetDef->addPass(Ogre::PASS_SCENE));
passScene->setAllLoadActions(Ogre::LoadAction::Clear);
passScene->setAllClearColours(Ogre::ColourValue::Black);
passScene->mVisibilityMask =
Ogre2ParticleEmitter::kParticleVisibilityFlags;
passScene->setVisibilityMask(
Ogre2ParticleEmitter::kParticleVisibilityFlags);
}

// rt0 target - converts depth to xyz
Expand Down
8 changes: 2 additions & 6 deletions ogre2/src/Ogre2GpuRays.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1195,12 +1195,8 @@ void Ogre2GpuRays::UpdateRenderTarget1stPass()
Ogre::vector<Ogre::TextureGpu *>::type swappedTargets;
swappedTargets.reserve(2u);

// set visibility mask and '&' it with GZ_VISIBILITY_ALL (0x0FFFFFFF)
// to make sure the fist 4 bits are 0 otherwise lidar will not be able
// to detect heightmaps
this->dataPtr->mainPassSceneDef->mVisibilityMask =
(this->VisibilityMask() & GZ_VISIBILITY_ALL)
& ~Ogre2ParticleEmitter::kParticleVisibilityFlags;
this->dataPtr->mainPassSceneDef->setVisibilityMask(
this->VisibilityMask() & ~Ogre2ParticleEmitter::kParticleVisibilityFlags);

// update the compositors
for (auto i : this->dataPtr->cubeFaceIdx)
Expand Down
4 changes: 2 additions & 2 deletions ogre2/src/Ogre2RenderTarget.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ class Ogre2RenderTargetCompositorListener :
Ogre::Viewport *vp = scenePass->getCamera()->getLastViewport();
if (vp == nullptr) return;
// make sure we do not alter the reserved visibility flags
uint32_t f = this->ogreRenderTarget->VisibilityMask() |
~Ogre::VisibilityFlags::RESERVED_VISIBILITY_FLAGS;
uint32_t f = this->ogreRenderTarget->VisibilityMask() &
Ogre::VisibilityFlags::RESERVED_VISIBILITY_FLAGS;
// apply the new visibility mask
uint32_t flags = f & vp->getVisibilityMask();
vp->_setVisibilityMask(flags, vp->getLightVisibilityMask());
Expand Down
2 changes: 1 addition & 1 deletion ogre2/src/Ogre2SelectionBuffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ void Ogre2SelectionBuffer::CreateRTTBuffer()
colorTargetDef->addPass(Ogre::PASS_SCENE));
passScene->setAllLoadActions(Ogre::LoadAction::Clear);
passScene->setAllClearColours(Ogre::ColourValue::Black);
passScene->mVisibilityMask = GZ_VISIBILITY_SELECTABLE;
passScene->setVisibilityMask(GZ_VISIBILITY_SELECTABLE);
}

Ogre::CompositorTargetDef *targetDef = nodeDef->addTargetPass("rt");
Expand Down
4 changes: 2 additions & 2 deletions ogre2/src/Ogre2ThermalCamera.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1009,8 +1009,8 @@ void Ogre2ThermalCamera::CreateThermalTexture()
passScene->setAllLoadActions(Ogre::LoadAction::Clear);
passScene->setAllClearColours(Ogre::ColourValue(0, 0, 0));
// thermal camera should not see particles
passScene->mVisibilityMask = GZ_VISIBILITY_ALL &
~Ogre2ParticleEmitter::kParticleVisibilityFlags;
passScene->setVisibilityMask(
GZ_VISIBILITY_ALL & ~Ogre2ParticleEmitter::kParticleVisibilityFlags);
}

// rt_input target - converts to thermal
Expand Down