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

Setting multiple light properties using sim::Light doesn't work properly #2532

Open
azeey opened this issue Aug 21, 2024 · 3 comments · May be fixed by #2660
Open

Setting multiple light properties using sim::Light doesn't work properly #2532

azeey opened this issue Aug 21, 2024 · 3 comments · May be fixed by #2660
Assignees
Labels
bug Something isn't working good first issue Good for newcomers help wanted We accept pull requests!

Comments

@azeey
Copy link
Contributor

azeey commented Aug 21, 2024

Environment

  • OS Version: all
  • Source or binary build? 8.6.0

Description

  • Expected behavior: Calling sim::Light::SetDiffuseColor followed by sim::Light::SetSpecularColor to work. Example:
gz::sim::Light light(light_entity);
light.SetDiffuseColor(ecm, gz::math::Color(1.0, 0.0, 0.0, 0.0));
light.SetSpecularColor(ecm, gz::math::Color(1.0, 0.0, 0.0, 0.0));
  • Actual behavior: Only the last set value takes effect. Looking at the code in

    gz-sim/src/Light.cc

    Lines 326 to 344 in 523b01b

    void Light::SetDiffuseColor(EntityComponentManager &_ecm,
    const math::Color &_color)
    {
    auto lightCmd =
    _ecm.Component<components::LightCmd>(this->dataPtr->id);
    msgs::Light lightMsg;
    msgs::Set(lightMsg.mutable_diffuse(), _color);
    if (!lightCmd)
    {
    _ecm.CreateComponent(
    this->dataPtr->id,
    components::LightCmd(lightMsg));
    }
    else
    {
    lightCmd->Data() = lightMsg;
    }
    }
    calling SetDiffuseColor or SetSpecularColor will set the LightCmd component. But if you call one after the other without a whole step in between, the LightCmd from one will overwrite the other. The code already checks if there's a LightCmd component, but instead of updating the value of the component, it always replaces it with a new value.
@azeey azeey added bug Something isn't working good first issue Good for newcomers help wanted We accept pull requests! labels Aug 21, 2024
@shr-eyas
Copy link

hi, i would like to contribute.

@azeey
Copy link
Contributor Author

azeey commented Oct 28, 2024

Thanks @shr-eyas ! I'll go ahead and assign this to you.

@shr-eyas
Copy link

hi, @azeey ! i believe i have solved the issue however, i am having issues testing it. this is my first open-source contribution and it would be great if you can provide some help/guidance.

shr-eyas added a commit to shr-eyas/gz-sim that referenced this issue Oct 29, 2024
@azeey azeey moved this from Inbox to In progress in Core development Nov 11, 2024
@azeey azeey linked a pull request Jan 7, 2025 that will close this issue
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted We accept pull requests!
Projects
Status: In progress
Development

Successfully merging a pull request may close this issue.

2 participants