Skip to content

Commit

Permalink
feedback
Browse files Browse the repository at this point in the history
Signed-off-by: Dharini Dutia <[email protected]>
  • Loading branch information
quarkytale committed Jan 5, 2024
1 parent 26c61ca commit 60f05db
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
19 changes: 11 additions & 8 deletions src/SdfEntityCreator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -817,17 +817,20 @@ Entity SdfEntityCreator::CreateEntities(const sdf::Visual *_visual)
std::optional<MaterialParser::MaterialValues> parsed =
this->dataPtr->materialParser.GetMaterialValues(scriptName);

if(!parsed.has_value()) {
if(parsed.has_value())
{
visualMaterial.SetAmbient
(parsed->ambient.value_or(visualMaterial.Ambient()));
visualMaterial.SetDiffuse
(parsed->diffuse.value_or(visualMaterial.Diffuse()));
visualMaterial.SetSpecular
(parsed->specular.value_or(visualMaterial.Specular()));
}
else
{
gzwarn << "Material " << scriptName <<
" not recognized, using default." << std::endl;
}

visualMaterial.SetAmbient
(parsed->ambient.value_or(visualMaterial.Ambient()));
visualMaterial.SetDiffuse
(parsed->diffuse.value_or(visualMaterial.Diffuse()));
visualMaterial.SetSpecular
(parsed->specular.value_or(visualMaterial.Specular()));
}
}
this->dataPtr->ecm->CreateComponent(visualEntity,
Expand Down
8 changes: 4 additions & 4 deletions src/rendering/MaterialParser/MaterialParser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void MaterialParser::Load()
std::optional<MaterialParser::MaterialValues> MaterialParser::GetMaterialValues(
const std::string& material)
{
MaterialValues values;
std::optional<MaterialValues> values;
std::map<std::string, ConfigNode *> scripts =
this->configLoader.getAllConfigScripts();

Expand All @@ -66,15 +66,15 @@ std::optional<MaterialParser::MaterialValues> MaterialParser::GetMaterialValues(
if (ambientNode) {
std::vector<float> ambientValues;
ambientNode->getValuesInFloat(ambientValues);
values.ambient = gz::math::Color(ambientValues[0],
values->ambient = gz::math::Color(ambientValues[0],
ambientValues[1], ambientValues[2]);
}

ConfigNode * diffuseNode = passNode->findChild("diffuse");
if (diffuseNode) {
std::vector<float> diffuseValues;
diffuseNode->getValuesInFloat(diffuseValues);
values.diffuse = gz::math::Color(diffuseValues[0],
values->diffuse = gz::math::Color(diffuseValues[0],
diffuseValues[1], diffuseValues[2]);
}

Expand All @@ -84,7 +84,7 @@ std::optional<MaterialParser::MaterialValues> MaterialParser::GetMaterialValues(
specularNode->getValuesInFloat(specularValues);
// Using first four values for specular as
// Gazebo doesn't support shininess
values.specular = gz::math::Color(specularValues[0],
values->specular = gz::math::Color(specularValues[0],
specularValues[1], specularValues[2], specularValues[3]);
}
}
Expand Down

0 comments on commit 60f05db

Please sign in to comment.