diff --git a/cpp/open3d/visualization/visualizer/O3DVisualizer.cpp b/cpp/open3d/visualization/visualizer/O3DVisualizer.cpp index 49b935894b50..55e85b2d5784 100644 --- a/cpp/open3d/visualization/visualizer/O3DVisualizer.cpp +++ b/cpp/open3d/visualization/visualizer/O3DVisualizer.cpp @@ -2039,12 +2039,32 @@ struct O3DVisualizer::Impl { void UpdateSelectableGeometry() { std::vector pickable; - pickable.reserve(objects_.size()); + // Count number of meshes stored in TriangleMeshModels + size_t model_mesh_count = 0; + size_t model_count = 0; for (auto &o : objects_) { if (!IsGeometryVisible(o)) { continue; } - pickable.emplace_back(o.name, o.geometry.get(), o.tgeometry.get()); + if (o.model.get()) { + model_count++; + model_mesh_count += o.model.get()->meshes_.size(); + } + } + pickable.reserve(objects_.size() + model_mesh_count - model_count); + for (auto &o : objects_) { + if (!IsGeometryVisible(o)) { + continue; + } + if (o.model.get()) { + for (auto &g : o.model->meshes_) { + pickable.emplace_back(g.mesh_name, g.mesh.get(), + o.tgeometry.get()); + } + } else { + pickable.emplace_back(o.name, o.geometry.get(), + o.tgeometry.get()); + } } selections_->SetSelectableGeometry(pickable); }