From d397007288d349ac7a1bd8bc6ef974cd365fd220 Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Fri, 15 Dec 2023 15:03:09 +0100 Subject: [PATCH] addressing reviews --- crates/re_data_source/src/data_loader/loader_archetype.rs | 2 +- crates/re_types/Cargo.toml | 1 - crates/re_types/src/archetypes/points3d_ext.rs | 8 ++++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/crates/re_data_source/src/data_loader/loader_archetype.rs b/crates/re_data_source/src/data_loader/loader_archetype.rs index 08ecf6d11e82..f903e78b9dff 100644 --- a/crates/re_data_source/src/data_loader/loader_archetype.rs +++ b/crates/re_data_source/src/data_loader/loader_archetype.rs @@ -176,7 +176,7 @@ fn load_point_cloud( { // TODO(#4532): `.ply` data loader should support 2D point cloud & meshes let points3d = re_types::archetypes::Points3D::from_file_contents(contents)?; - DataRow::from_archetype(RowId::new(), timepoint, entity_path.clone(), &points3d)? + DataRow::from_archetype(RowId::new(), timepoint, entity_path, &points3d)? }, // ]; diff --git a/crates/re_types/Cargo.toml b/crates/re_types/Cargo.toml index c3fc2972f7a7..80117e1a6b6b 100644 --- a/crates/re_types/Cargo.toml +++ b/crates/re_types/Cargo.toml @@ -66,7 +66,6 @@ half = { workspace = true, features = ["bytemuck"] } infer.workspace = true itertools.workspace = true linked-hash-map.workspace = true -mime_guess.workspace = true mime_guess2.workspace = true ndarray.workspace = true once_cell.workspace = true diff --git a/crates/re_types/src/archetypes/points3d_ext.rs b/crates/re_types/src/archetypes/points3d_ext.rs index e9522945b7ba..03fbc6de2080 100644 --- a/crates/re_types/src/archetypes/points3d_ext.rs +++ b/crates/re_types/src/archetypes/points3d_ext.rs @@ -13,7 +13,7 @@ impl Points3D { /// /// The media type will be inferred from the path (extension), or the contents if that fails. #[cfg(not(target_arch = "wasm32"))] - pub fn from_file(filepath: &std::path::Path) -> anyhow::Result { + pub fn from_file_path(filepath: &std::path::Path) -> anyhow::Result { use anyhow::Context as _; let file = std::fs::File::open(filepath) @@ -38,6 +38,8 @@ impl Points3D { } fn from_ply(ply: &ply_rs::ply::Ply) -> Points3D { + re_tracing::profile_function!(); + use std::borrow::Cow; use linked_hash_map::LinkedHashMap; @@ -125,6 +127,7 @@ fn from_ply(ply: &ply_rs::ply::Ply) -> Points3D { const PROP_RED: &str = "red"; const PROP_GREEN: &str = "green"; const PROP_BLUE: &str = "blue"; + const PROP_ALPHA: &str = "alpha"; const PROP_RADIUS: &str = "radius"; const PROP_LABEL: &str = "label"; @@ -148,7 +151,8 @@ fn from_ply(ply: &ply_rs::ply::Ply) -> Points3D { props.get(PROP_GREEN).and_then(u8), props.get(PROP_BLUE).and_then(u8), ) { - this.color = Some(Color::new((r, g, b))); + let a = props.get(PROP_ALPHA).and_then(u8).unwrap_or(255); + this.color = Some(Color::new((r, g, b, a))); }; if let Some(radius) = props.get(PROP_RADIUS).and_then(f32) {