Skip to content

Commit

Permalink
Enable picking points from TriangleMeshModels in O3D Visualizer (#5978)
Browse files Browse the repository at this point in the history
* Allow TriangleModel meshes to be selected
* Use mesh name instead of object name
  • Loading branch information
errissa authored Mar 8, 2023
1 parent f2ae73d commit 8869397
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions cpp/open3d/visualization/visualizer/O3DVisualizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2026,12 +2026,32 @@ struct O3DVisualizer::Impl {

void UpdateSelectableGeometry() {
std::vector<SceneWidget::PickableGeometry> 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);
}
Expand Down

0 comments on commit 8869397

Please sign in to comment.