diff --git a/flowstate_ros_bridge/src/bridges/world_bridge.cpp b/flowstate_ros_bridge/src/bridges/world_bridge.cpp index 11a0cae6..16f26765 100644 --- a/flowstate_ros_bridge/src/bridges/world_bridge.cpp +++ b/flowstate_ros_bridge/src/bridges/world_bridge.cpp @@ -191,26 +191,28 @@ absl::Status WorldBridge::Data::SendObjectVisualizationMessages( "gltf/%s_%s.glb", geometry.geometry_storage_refs().geometry_ref().substr(9), geometry.geometry_storage_refs().renderable_ref().substr(9)); - if (renderables_.contains(std::string("/") + gltf_path)) { - continue; - } - const absl::StatusOr gltf = world_->GetGltf( - geometry.geometry_storage_refs().geometry_ref(), - geometry.geometry_storage_refs().renderable_ref()); - if (!gltf.ok()) { - LOG(ERROR) << "Unable to fetch renderable for " << tf_frame_name - << ": " << gltf.status(); - continue; + const auto renderable_name = std::string("/") + gltf_path; + auto renderables_it = renderables_.find(renderable_name); + + if (renderables_it == renderables_.end()) { + const absl::StatusOr gltf = world_->GetGltf( + geometry.geometry_storage_refs().geometry_ref(), + geometry.geometry_storage_refs().renderable_ref()); + if (!gltf.ok()) { + LOG(ERROR) << "Unable to fetch renderable for " << tf_frame_name + << ": " << gltf.status(); + continue; + } + total_gltf_size += gltf->size(); + std::vector gltf_data; + gltf_data.resize(gltf->size()); + memcpy(&gltf_data[0], gltf->data(), gltf->size()); + + LOG(INFO) << "Fetched " << gltf->size() << " bytes for " + << tf_frame_name; + renderables_it = renderables_.emplace(renderable_name, std::move(gltf_data)).first; } - total_gltf_size += gltf->size(); - std::vector gltf_data; - gltf_data.resize(gltf->size()); - memcpy(&gltf_data[0], gltf->data(), gltf->size()); - - renderables_[std::string("/") + gltf_path] = std::move(gltf_data); - LOG(INFO) << "Fetched " << gltf->size() << " bytes for " - << tf_frame_name; const absl::StatusOr transform_xd = intrinsic_proto::FromProto(geometry.ref_t_shape_aff());