Skip to content

Commit

Permalink
Check null mesh (gazebosim#2341)
Browse files Browse the repository at this point in the history
Signed-off-by: Ian Chen <[email protected]>
Signed-off-by: Gaurav Kumar <[email protected]>
  • Loading branch information
iche033 authored and GauravKumar9920 committed Mar 30, 2024
1 parent 1716fe5 commit 8ca57b4
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
5 changes: 5 additions & 0 deletions src/MeshInertiaCalculator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,11 @@ std::optional<gz::math::Inertiald> MeshInertiaCalculator::operator()
// Load the Mesh
gz::common::MeshManager *meshManager = gz::common::MeshManager::Instance();
mesh = meshManager->Load(fullPath);
if (!mesh)
{
gzerr << "Failed to load mesh: " << fullPath << std::endl;
return std::nullopt;
}
std::vector<Triangle> meshTriangles;
gz::math::MassMatrix3d meshMassMatrix;
gz::math::Pose3d centreOfMass;
Expand Down
1 change: 0 additions & 1 deletion src/gui/plugins/apply_force_torque/ApplyForceTorque.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include <mutex>
#include <string>

#include <gz/common/MeshManager.hh>
#include <gz/common/MouseEvent.hh>
#include <gz/gui/Application.hh>
#include <gz/gui/GuiEvents.hh>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1245,7 +1245,14 @@ rendering::GeometryPtr VisualizationCapabilitiesPrivate::CreateGeometry(
gz::common::MeshManager *meshManager =
gz::common::MeshManager::Instance();
descriptor.mesh = meshManager->Load(descriptor.meshName);
geom = this->scene->CreateMesh(descriptor);
if (descriptor.mesh)
{
geom = this->scene->CreateMesh(descriptor);
}
else
{
gzerr << "Failed to load mesh: " << descriptor.meshName << std::endl;
}
scale = _geom.MeshShape()->Scale();
}
else if (_geom.Type() == sdf::GeometryType::HEIGHTMAP)
Expand Down
10 changes: 8 additions & 2 deletions src/rendering/SceneManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -813,8 +813,14 @@ rendering::GeometryPtr SceneManager::LoadGeometry(const sdf::Geometry &_geom,
rendering::MeshDescriptor descriptor;
descriptor.meshName = name;
descriptor.mesh = meshManager->MeshByName(name);

geom = this->dataPtr->scene->CreateMesh(descriptor);
if (descriptor.mesh)
{
geom = this->dataPtr->scene->CreateMesh(descriptor);
}
else
{
gzerr << "Unable to find the polyline mesh: " << name << std::endl;
}
}
else
{
Expand Down

0 comments on commit 8ca57b4

Please sign in to comment.