diff --git a/src/MeshInertiaCalculator.cc b/src/MeshInertiaCalculator.cc index 23d5e95310..47b7c3c230 100644 --- a/src/MeshInertiaCalculator.cc +++ b/src/MeshInertiaCalculator.cc @@ -218,6 +218,11 @@ std::optional 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 meshTriangles; gz::math::MassMatrix3d meshMassMatrix; gz::math::Pose3d centreOfMass; diff --git a/src/gui/plugins/apply_force_torque/ApplyForceTorque.cc b/src/gui/plugins/apply_force_torque/ApplyForceTorque.cc index 24a607d20f..a2ca6ce79f 100644 --- a/src/gui/plugins/apply_force_torque/ApplyForceTorque.cc +++ b/src/gui/plugins/apply_force_torque/ApplyForceTorque.cc @@ -19,7 +19,6 @@ #include #include -#include #include #include #include diff --git a/src/gui/plugins/visualization_capabilities/VisualizationCapabilities.cc b/src/gui/plugins/visualization_capabilities/VisualizationCapabilities.cc index 82e1492853..c5d24bc7ab 100644 --- a/src/gui/plugins/visualization_capabilities/VisualizationCapabilities.cc +++ b/src/gui/plugins/visualization_capabilities/VisualizationCapabilities.cc @@ -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) diff --git a/src/rendering/SceneManager.cc b/src/rendering/SceneManager.cc index ab5d0ee92b..d94e6aa8b7 100644 --- a/src/rendering/SceneManager.cc +++ b/src/rendering/SceneManager.cc @@ -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 {