Skip to content

Commit

Permalink
Update UpdateGeomSize().
Browse files Browse the repository at this point in the history
Signed-off-by: Carlos Agüero <[email protected]>
  • Loading branch information
caguero committed Aug 30, 2021
1 parent 831ddfa commit f126b66
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/gui/plugins/scene3d/Scene3D.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3082,12 +3082,15 @@ bool Scene3D::UpdateGeomSize(sdf::ElementPtr &_modelElem,
return false;

sdf::ElementPtr linkElem = _modelElem->GetElement("link");
if (!linkElem->HasElement("visual"))
return false;

bool scaled = false;
for (auto label : {"visual", "collision"})
{
if (!linkElem->HasElement(label))
continue;

sdf::ElementPtr elem = linkElem->GetElement(label);

if (!elem->HasElement("geometry"))
continue;

Expand All @@ -3099,6 +3102,7 @@ bool Scene3D::UpdateGeomSize(sdf::ElementPtr &_modelElem,
ignition::math::Vector3d geomBoxSize = _scale * size;

geomElem->GetElement("box")->GetElement("size")->Set(geomBoxSize);
scaled = true;
}
else if (geomElem->HasElement("sphere"))
{
Expand All @@ -3107,6 +3111,7 @@ bool Scene3D::UpdateGeomSize(sdf::ElementPtr &_modelElem,
double newRadius = _scale.Max();
double geomRadius = newRadius * radius;
geomElem->GetElement("sphere")->GetElement("radius")->Set(geomRadius);
scaled = true;
}
else if (geomElem->HasElement("cylinder"))
{
Expand All @@ -3118,12 +3123,16 @@ bool Scene3D::UpdateGeomSize(sdf::ElementPtr &_modelElem,
double geomLength = _scale.Z() * length;
geomElem->GetElement("cylinder")->GetElement("radius")->Set(geomRadius);
geomElem->GetElement("cylinder")->GetElement("length")->Set(geomLength);
scaled = true;
}
else if (geomElem->HasElement("mesh"))
{
geomElem->GetElement("mesh")->GetElement("scale")->Set(_scale);
scaled = true;
}
}

return true;
return scaled;
}

/////////////////////////////////////////////////
Expand Down

0 comments on commit f126b66

Please sign in to comment.