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

Use double sided field in material msg #599

Merged
merged 2 commits into from
Feb 1, 2021
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
16 changes: 2 additions & 14 deletions src/Conversions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -272,12 +272,7 @@ msgs::Material ignition::gazebo::convert(const sdf::Material &_in)
msgs::Set(out.mutable_emissive(), _in.Emissive());
out.set_render_order(_in.RenderOrder());
out.set_lighting(_in.Lighting());

// todo(anyone) add double_sided field to msgs::Material
auto data = out.mutable_header()->add_data();
data->set_key("double_sided");
std::string *value = data->add_value();
*value = std::to_string(_in.DoubleSided());
out.set_double_sided(_in.DoubleSided());

sdf::Pbr *pbr = _in.PbrMaterial();
if (pbr)
Expand Down Expand Up @@ -333,14 +328,7 @@ sdf::Material ignition::gazebo::convert(const msgs::Material &_in)
out.SetEmissive(msgs::Convert(_in.emissive()));
out.SetRenderOrder(_in.render_order());
out.SetLighting(_in.lighting());

// todo(anyone) add double_sided field to msgs::Material
for (int i = 0; i < _in.header().data_size(); ++i)
{
const auto &data = _in.header().data(i);
if (data.key() == "double_sided" && data.value_size() > 0)
out.SetDoubleSided(math::parseInt(data.value(0)));
}
out.SetDoubleSided(_in.double_sided());

if (_in.has_pbr())
{
Expand Down
8 changes: 1 addition & 7 deletions src/Conversions_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,6 @@ TEST(Conversions, Material)
material.SetEmissive(ignition::math::Color(1.3f, 1.4f, 1.5f, 1.6f));
material.SetLighting(true);
material.SetRenderOrder(2.5);

// todo(anyone) add double_sided field to msgs::Material
material.SetDoubleSided(true);

sdf::Pbr pbr;
Expand Down Expand Up @@ -239,11 +237,7 @@ TEST(Conversions, Material)
msgs::Convert(materialMsg.emissive()));
EXPECT_TRUE(materialMsg.lighting());
EXPECT_DOUBLE_EQ(2.5, materialMsg.render_order());

// todo(anyone) double_sided is temporarily stored in header
// Need to add double_sided field to msgs::Material
bool doubleSided = math::parseInt(materialMsg.header().data(0).value(0));
EXPECT_TRUE(doubleSided);
EXPECT_TRUE(materialMsg.double_sided());

EXPECT_TRUE(materialMsg.has_pbr());
const auto &pbrMsg = materialMsg.pbr();
Expand Down