Skip to content

Conversation

ntfshard
Copy link
Contributor

@ntfshard ntfshard commented Aug 1, 2025

🦟 Bug fix

Fixes #

Summary

Adding model with Entity Tree gui plugin, or in sdf w/o material won't creating a material entity in ECM. Object will looks flat and it's not possible to change material properties in gui. Populating default material will allow to configure it in gui.

Behaviour changing: before color of model was white and after this change it will be black. According to SDF specification http://sdformat.org/spec?elem=material&ver=1.9 it's correct behaviour. So technically it's a fix

Before (no Material submenu):
Screenshot 2025-08-02 032129

After:
Screenshot 2025-08-02 033135
image

I checked this change on gz-sim8 branch (I already had all libraries compiled); I guess it should be the same on gz-sim9

Checklist

  • Signed all commits for DCO
  • Added tests
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • Consider updating Python bindings (if the library has them)
  • 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
  • Was GenAI used to generate this PR? If so, make sure to add "Generated-by" to your commits. (See this policy for more info.)

Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining Signed-off-by and Generated-by messages.

Signed-off-by: Maksim Derbasov <ntfs.hard@gmail.com>
@ntfshard ntfshard requested a review from mjcarroll as a code owner August 1, 2025 19:35
@github-actions github-actions bot added the 🏛️ ionic Gazebo Ionic label Aug 1, 2025
Signed-off-by: Maksim Derbasov <ntfs.hard@gmail.com>
sdf::Material visualMaterial;
this->dataPtr->ecm->CreateComponent(visualEntity,
components::Material(visualMaterial));
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Small suggestion to simplify the logic:

sdf::Material visualMaterial;
if (_visual->Material())
  visualMaterial = *_visual->Material();

this->dataPtr->ecm->CreateComponent(visualEntity,
  components::Material(visualMaterial));

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Lifetime of visualMaterial will be much bigger than it needed. But if you insist I can do it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure about logic simplification especially with such giant if scope, but I changed

@azeey azeey modified the milestone: Jetty Release Aug 8, 2025
@ntfshard ntfshard requested a review from arjo129 as a code owner August 13, 2025 08:41
@ntfshard ntfshard force-pushed the default_visual_for_model branch from fea4292 to 7d8d1fa Compare August 14, 2025 13:47
Signed-off-by: Maksim Derbasov <ntfs.hard@gmail.com>
Copy link

codecov bot commented Sep 5, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.02%. Comparing base (47a2580) to head (14976e9).

Additional details and impacted files
@@             Coverage Diff             @@
##           gz-sim9    #3009      +/-   ##
===========================================
- Coverage    69.07%   69.02%   -0.05%     
===========================================
  Files          347      347              
  Lines        34038    34039       +1     
===========================================
- Hits         23512    23496      -16     
- Misses       10526    10543      +17     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@azeey
Copy link
Contributor

azeey commented Oct 20, 2025

This looks good to me. Even though it's a behavior change, I don't think anyone would be relying on the old behavior. However, would you mind targetting this to main? We'll backport to gz-sim9 once it's merged.

@ntfshard ntfshard changed the base branch from gz-sim9 to main October 20, 2025 18:50
@ntfshard ntfshard requested a review from jennuine as a code owner October 20, 2025 18:50
@ntfshard ntfshard changed the base branch from main to gz-sim9 October 20, 2025 18:51
@ntfshard
Copy link
Contributor Author

ntfshard commented Oct 20, 2025

This looks good to me. Even though it's a behavior change, I don't think anyone would be relying on the old behavior. However, would you mind targetting this to main? We'll backport to gz-sim9 once it's merged.

I will create a separate PR in main, changing base is not working well

One test relied on this colour. But seems according to SDF it should be black

@ntfshard
Copy link
Contributor Author

Closing this PR due to #3139 created to main

@ntfshard ntfshard closed this Oct 20, 2025
@github-project-automation github-project-automation bot moved this from Inbox to Done in Core development Oct 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🏛️ ionic Gazebo Ionic

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants