Skip to content
This repository was archived by the owner on Feb 3, 2025. It is now read-only.

LensFlare: initialize OGRE compositors during plugin initialization #2764

Merged
merged 3 commits into from
Jun 27, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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
11 changes: 10 additions & 1 deletion Changelog.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
## Gazebo 9

## Gazebo 9.xx.x (202x-xx-xx)

1. LensFlare: initialize OGRE compositors during plugin initialization
* [Pull request #2762](https://github.com/osrf/gazebo/pull/2762)

1. Fixes for ARM: FindSSE, TrackedVehiclePlugin and PluginInterfaceTest
* [Pull request #2754](https://github.com/osrf/gazebo/pull/2754)
* [Pull request #2748](https://github.com/osrf/gazebo/pull/2748)

## Gazebo 9.13.1 (2020-05-28)

1. Fix multiple reflectance maps and improve performance
* [Pull request #2724](https://github.com/osrf/gazebo/pull/2742)
* [Pull request #2742](https://github.com/osrf/gazebo/pull/2742)

## Gazebo 9.13.0 (2020-04-03)

Expand Down
57 changes: 32 additions & 25 deletions gazebo/rendering/LensFlare.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ namespace gazebo
Ogre::Vector3(static_cast<double>(this->camera->ViewportWidth()),
static_cast<double>(this->camera->ViewportHeight()), 1.0));

if (!this->light)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should be able move this check to the top of the function as we don't need to set the params anymore

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{
// return if this->light is not set, we may still be initializing
return;
}

// use light's world position for lens flare position
if (this->light->Type() == "directional")
{
Expand Down Expand Up @@ -393,6 +399,32 @@ void LensFlare::SetCamera(CameraPtr _camera)
}

this->dataPtr->camera = _camera;

if (!this->dataPtr->lensFlareInstance)
{
// set up the lens flare instance
Ogre::MaterialPtr lensFlareMaterial =
Ogre::MaterialManager::getSingleton().getByName(
"Gazebo/CameraLensFlare");
lensFlareMaterial = lensFlareMaterial->clone(
"Gazebo/" + this->dataPtr->camera->Name() + "_CameraLensFlare");

this->dataPtr->lensFlareCompositorListener.reset(new
LensFlareCompositorListener(this->dataPtr->camera, nullptr));
this->dataPtr->lensFlareCompositorListener->SetScale(
this->dataPtr->lensFlareScale);

this->dataPtr->lensFlareInstance =
Ogre::CompositorManager::getSingleton().addCompositor(
this->dataPtr->camera->OgreViewport(), "CameraLensFlare/Default");
this->dataPtr->lensFlareInstance->getTechnique()->getOutputTargetPass()->
getPass(0)->setMaterial(lensFlareMaterial);

this->dataPtr->lensFlareInstance->setEnabled(true);
this->dataPtr->lensFlareInstance->addListener(
this->dataPtr->lensFlareCompositorListener.get());
}

this->dataPtr->preRenderConnection = event::Events::ConnectPreRender(
std::bind(&LensFlare::Update, this));
}
Expand Down Expand Up @@ -440,31 +472,6 @@ void LensFlare::Update()

this->dataPtr->lightName = directionalLight->Name();

if (!this->dataPtr->lensFlareInstance)
{
// set up the lens flare instance
Ogre::MaterialPtr lensFlareMaterial =
Ogre::MaterialManager::getSingleton().getByName(
"Gazebo/CameraLensFlare");
lensFlareMaterial = lensFlareMaterial->clone(
"Gazebo/" + this->dataPtr->camera->Name() + "_CameraLensFlare");

this->dataPtr->lensFlareCompositorListener.reset(new
LensFlareCompositorListener(this->dataPtr->camera, directionalLight));
this->dataPtr->lensFlareCompositorListener->SetScale(
this->dataPtr->lensFlareScale);

this->dataPtr->lensFlareInstance =
Ogre::CompositorManager::getSingleton().addCompositor(
this->dataPtr->camera->OgreViewport(), "CameraLensFlare/Default");
this->dataPtr->lensFlareInstance->getTechnique()->getOutputTargetPass()->
getPass(0)->setMaterial(lensFlareMaterial);

this->dataPtr->lensFlareInstance->setEnabled(true);
this->dataPtr->lensFlareInstance->addListener(
this->dataPtr->lensFlareCompositorListener.get());
}
else
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove brackets?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this->dataPtr->lensFlareCompositorListener->SetLight(directionalLight);
this->dataPtr->lensFlareInstance->setEnabled(true);
Expand Down