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

Handle null mesh pointers #2341

Merged
merged 1 commit into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
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
Loading