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

Fix light preview parameters #2982

Merged
merged 3 commits into from
Jan 4, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions gazebo/gui/LightMaker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ bool LightMaker::Init()
this->dataPtr->light->Load();
scene->AddLight(this->dataPtr->light);

this->msg.clear_name();
this->dataPtr->light->UpdateFromMsg(this->msg);
this->dataPtr->light->SetLightType(this->lightTypename);
this->dataPtr->light->SetPosition(ignition::math::Vector3d(0, 0, 1));
if (this->lightTypename == "directional")
Expand Down
6 changes: 6 additions & 0 deletions gazebo/gui/LightMaker_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ void LightMaker_TEST::PointLight()
// Check there's a light in the scene -- this is the preview
light = scene->LightByName("__default__");
QVERIFY(light != NULL);
const auto previewLight = light;

// Check that the light appeared in the center of the screen
ignition::math::Vector3d startPos = pointLightMaker->EntityPosition();
Expand Down Expand Up @@ -98,6 +99,11 @@ void LightMaker_TEST::PointLight()
light = scene->LightByName("user_point_light_0");
QVERIFY(light != NULL);

QVERIFY(light->LightType() == previewLight->LightType());
QVERIFY(light->DiffuseColor() == previewLight->DiffuseColor());
QVERIFY(light->SpecularColor() == previewLight->SpecularColor());
QVERIFY(light->Direction() == previewLight->Direction());

// Terminate
mainWindow->close();
delete mainWindow;
Expand Down
14 changes: 10 additions & 4 deletions gazebo/rendering/Light.cc
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,20 @@ void Light::UpdateSDFFromMsg(const msgs::Light &_msg)
//////////////////////////////////////////////////
void Light::UpdateFromMsg(ConstLightPtr &_msg)
{
this->UpdateSDFFromMsg(*_msg);
this->UpdateFromMsg(*_msg);
peci1 marked this conversation as resolved.
Show resolved Hide resolved
}

//////////////////////////////////////////////////
void Light::UpdateFromMsg(const msgs::Light &_msg)
{
this->UpdateSDFFromMsg(_msg);

this->Update();

if (_msg->has_pose())
if (_msg.has_pose())
{
this->SetPosition(msgs::ConvertIgn(_msg->pose().position()));
this->SetRotation(msgs::ConvertIgn(_msg->pose().orientation()));
this->SetPosition(msgs::ConvertIgn(_msg.pose().position()));
this->SetRotation(msgs::ConvertIgn(_msg.pose().orientation()));
}
}

Expand Down
4 changes: 4 additions & 0 deletions gazebo/rendering/Light.hh
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,10 @@ namespace gazebo
/// \param[in] _msg Light message to update from
public: void UpdateFromMsg(ConstLightPtr &_msg);

/// \brief Update a light source from a message.
/// \param[in] _msg Light message to update from
public: void UpdateFromMsg(const msgs::Light &_msg);

/// \brief Clone the light with a new name
/// \param[in] _name Name of the cloned light.
/// \param[in] _scene Scene to contain the light.
Expand Down