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

Transparent mode #878

Merged
merged 11 commits into from
Jul 5, 2021
Merged

Transparent mode #878

merged 11 commits into from
Jul 5, 2021

Conversation

atharva-18
Copy link
Contributor

@atharva-18 atharva-18 commented Jun 23, 2021

🎉 New feature

Summary

Adds transparent mode to debug models. This is done by setting the transparency value of the material of the target visual.
transparent_ mode

Ogre1 doesn't seem to work for me (along with Align Tool's transparent mode). Can someone confirm?
transparent_mode_ogre1

Test it

Test it by selecting an entity and View -> Transparent

Checklist

  • Signed all commits for DCO
  • Added tests
  • Added example and/or tutorial
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers

Note to maintainers: Remember to use Squash-Merge

Signed-off-by: Atharva Pusalkar <[email protected]>
Copy link
Contributor

@ahcorde ahcorde left a comment

Choose a reason for hiding this comment

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

there are some conflicts

Copy link
Contributor

@iche033 iche033 left a comment

Choose a reason for hiding this comment

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

nice, transparency is working for me.

/// \param[in] _ecm The entity-component manager
public: void FindWireframeVisualLinks(const EntityComponentManager &_ecm);
public: void FindVisualLinks(const EntityComponentManager &_ecm);
Copy link
Contributor

Choose a reason for hiding this comment

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

PopulateViewModeVisualLinks? probably not the best naming suggestion I have but I was thinking ways to make the name more expressive and representative of what it's doing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -95,6 +96,9 @@ class ignition::gazebo::SceneManagerPrivate
/// \brief Map of sensor entity in Gazebo to sensor pointers.
public: std::map<Entity, rendering::SensorPtr> sensors;

/// \brief The map of the original transparency values for the nodes.
public: std::map<std::string, double> originalTransparency;
Copy link
Contributor

Choose a reason for hiding this comment

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

consider removing items from this map when visuals are removed from the scene.

Copy link
Contributor Author

Choose a reason for hiding this comment

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


// Geometry material
auto geomMat = geom->Material();
if (nullptr == geomMat)
Copy link
Contributor

Choose a reason for hiding this comment

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

One additional check: if (nullptr == geomMat || visMat == geomMat) - just in case if we start setting materials to visuals with unique set to false, which would cause the geometry to get the same material as the parent visual. In this case, we wouldn't need to further update the transparency of the same material.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -2229,6 +2312,113 @@ void RenderUtilPrivate::LowlightNode(const rendering::NodePtr &_node)
}
}

/////////////////////////////////////////////////
void RenderUtil::ViewTransparent(const Entity &_entity)
Copy link
Contributor

Choose a reason for hiding this comment

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

the 3 View***(const Entity &_entity) functions are very similar. Is it possible to merge them or refactor some code in to functions so they can be reused?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

8cf713c

We may need to make similar changes to #861, after it is merged.

Signed-off-by: Atharva Pusalkar <[email protected]>
Signed-off-by: Atharva Pusalkar <[email protected]>
}

// Find all existing child links for this entity
std::vector<Entity> links = this->FindChildLinks(_entity);
Copy link
Contributor

Choose a reason for hiding this comment

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

how about std::vector<Entity> links = std::move(this->FindChildLinks(_entity)); to avoid copying the vector

Copy link
Contributor Author

Choose a reason for hiding this comment

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

// Find all existing child links for this entity
std::vector<Entity> links = this->FindChildLinks(_entity);

for (const auto &link : links)
Copy link
Contributor

Choose a reason for hiding this comment

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

wrap this block with { ..} brackets

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -1593,6 +1597,16 @@ void SceneManager::RemoveEntity(Entity _id)
auto it = this->dataPtr->visuals.find(_id);
if (it != this->dataPtr->visuals.end())
{
// Remove visual's original transparency from map
rendering::VisualPtr vis = this->dataPtr->visuals[_id];
Copy link
Contributor

Choose a reason for hiding this comment

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

rendering::VisualPtr vis = it->second to avoid another lookup

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Signed-off-by: Atharva Pusalkar <[email protected]>
Signed-off-by: Atharva Pusalkar <[email protected]>
Signed-off-by: Atharva Pusalkar <[email protected]>
Copy link
Contributor

@ahcorde ahcorde left a comment

Choose a reason for hiding this comment

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

Some conflicts

@ahcorde ahcorde enabled auto-merge (squash) July 2, 2021 10:27
@ahcorde ahcorde disabled auto-merge July 2, 2021 14:21
Copy link
Contributor

@ahcorde ahcorde left a comment

Choose a reason for hiding this comment

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

Conflicts because of the Inertia PR

@atharva-18
Copy link
Contributor Author

@ahcorde I resolved the conflicts and updated the inertia mode to use the newer functions

@ahcorde ahcorde merged commit 2e8419b into gazebosim:main Jul 5, 2021
@osrf-triage
Copy link

This pull request has been mentioned on Gazebo Community. There might be relevant details there:

https://community.gazebosim.org/t/google-summer-of-code-2021-new-gui-widgets-in-ignition-gazebo/1081/1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏯 fortress Ignition Fortress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants