From fbad5f155743ac2259d7055c4912b96d1848b9d6 Mon Sep 17 00:00:00 2001 From: Kevin Reid Date: Thu, 10 Oct 2024 09:20:57 -0700 Subject: [PATCH] desktop: Rerun: avoid logging mostly-empty `InstancePoses3D`. --- all-is-cubes-desktop/src/glue/rerun_mesh.rs | 18 ++++++++++-------- all-is-cubes/src/rerun_glue.rs | 12 ++++++++++++ 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/all-is-cubes-desktop/src/glue/rerun_mesh.rs b/all-is-cubes-desktop/src/glue/rerun_mesh.rs index 0f8bb95a3..5b4f952d1 100644 --- a/all-is-cubes-desktop/src/glue/rerun_mesh.rs +++ b/all-is-cubes-desktop/src/glue/rerun_mesh.rs @@ -147,14 +147,16 @@ impl RerunMesher { for (i, cubes) in instances { if let Some(mesh) = self.csm.block_instance_mesh(i) { if let Some(dm) = &mesh.render_data { - dm.destination.log( - &rg::entity_path![], - &rg::archetypes::InstancePoses3D::new().with_translations( - cubes - .into_iter() - .map(|cube| rg::convert_vec(cube.lower_bounds().to_vector())), - ), - ) + let translations: &dyn re_sdk::ComponentBatch = &cubes + .into_iter() + .map(|cube| { + rg::components::PoseTranslation3D(rg::convert_vec( + cube.lower_bounds().to_vector(), + )) + }) + .collect::>(); + dm.destination + .log_component_batches(&rg::entity_path![], false, [translations]) } } } diff --git a/all-is-cubes/src/rerun_glue.rs b/all-is-cubes/src/rerun_glue.rs index eb507a8b5..ebea019ae 100644 --- a/all-is-cubes/src/rerun_glue.rs +++ b/all-is-cubes/src/rerun_glue.rs @@ -71,6 +71,18 @@ impl Destination { self.catch(|| self.stream.log_static(self.path.join(path_suffix), data)) } + pub fn log_component_batches<'a>( + &self, + path_suffix: &EntityPath, + r#static: bool, + data: impl IntoIterator, + ) { + self.catch(|| { + self.stream + .log_component_batches(self.path.join(path_suffix), r#static, data) + }) + } + pub fn clear_recursive(&self, path_suffix: &EntityPath) { // TODO: this is no longer necessary self.log(path_suffix, &archetypes::Clear::new(true));