Skip to content

Commit

Permalink
fix ToElement, add default value
Browse files Browse the repository at this point in the history
Signed-off-by: Mabel Zhang <[email protected]>
  • Loading branch information
mabelzhang committed Jun 3, 2022
1 parent b40fe3b commit 7c47aee
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/Sky.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class sdf::Sky::Implementation
ignition::math::Color(0.8f, 0.8f, 0.8f);

/// \brief Skybox texture URI
public: std::string uri = "";
public: std::string uri = "__default__";

/// \brief The SDF element pointer used during load.
public: sdf::ElementPtr sdf;
Expand Down Expand Up @@ -213,7 +213,8 @@ Errors Sky::Load(ElementPtr _sdf)
// downstream implementation.
if (_sdf->HasElement("uri"))
{
this->dataPtr->uri = _sdf->Get<std::string>("uri", "__default__").first;
this->dataPtr->uri = _sdf->Get<std::string>("uri",
this->dataPtr->uri).first;
}

return errors;
Expand All @@ -235,6 +236,7 @@ sdf::ElementPtr Sky::ToElement() const
elem->GetElement("time")->Set(this->Time());
elem->GetElement("sunrise")->Set(this->Sunrise());
elem->GetElement("sunset")->Set(this->Sunset());
elem->GetElement("uri")->Set(this->Uri());

sdf::ElementPtr cloudElem = elem->GetElement("clouds");
cloudElem->GetElement("speed")->Set(this->CloudSpeed());
Expand All @@ -243,8 +245,5 @@ sdf::ElementPtr Sky::ToElement() const
cloudElem->GetElement("mean_size")->Set(this->CloudMeanSize());
cloudElem->GetElement("ambient")->Set(this->CloudAmbient());

sdf::ElementPtr uriElem = elem->GetElement("uri");
uriElem->GetElement("uri")->Set(this->Uri());

return elem;
}

0 comments on commit 7c47aee

Please sign in to comment.