-
Notifications
You must be signed in to change notification settings - Fork 342
Populate default material for model #3009
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
Conversation
Signed-off-by: Maksim Derbasov <ntfs.hard@gmail.com>
Signed-off-by: Maksim Derbasov <ntfs.hard@gmail.com>
sdf::Material visualMaterial; | ||
this->dataPtr->ecm->CreateComponent(visualEntity, | ||
components::Material(visualMaterial)); | ||
} |
There was a problem hiding this comment.
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));
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
fea4292
to
7d8d1fa
Compare
7d8d1fa
to
ee67d37
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
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 |
I will create a separate PR in One test relied on this colour. But seems according to SDF it should be black |
Closing this PR due to #3139 created to |
🦟 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):

After:


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
codecheck
passed (See contributing)Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining
Signed-off-by
andGenerated-by
messages.