Skip to content

Commit

Permalink
Remove unused MeshSourceData (#2036)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wumpf authored May 4, 2023
1 parent 8b17bf5 commit d7469e3
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 46 deletions.
20 changes: 5 additions & 15 deletions crates/re_viewer/src/misc/caches/mesh_cache.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use std::sync::Arc;

use re_log_types::{MeshFormat, MeshId};
use re_log_types::{Mesh3D, MeshId};
use re_renderer::RenderContext;

use crate::{mesh_loader::LoadedMesh, ui::view_spatial::MeshSourceData};
use crate::mesh_loader::LoadedMesh;

// ----------------------------------------------------------------------------

Expand All @@ -14,29 +14,19 @@ impl MeshCache {
pub fn load(
&mut self,
name: &str,
mesh_data: &MeshSourceData,
mesh: &Mesh3D,
render_ctx: &mut RenderContext,
) -> Option<Arc<LoadedMesh>> {
crate::profile_function!();

let mesh_id = mesh_data.mesh_id();
let mesh_id = mesh.mesh_id();

self.0
.entry(mesh_id)
.or_insert_with(|| {
re_log::debug!("Loading CPU mesh {name:?}…");

let result = match mesh_data {
MeshSourceData::Mesh3D(mesh3d) => {
LoadedMesh::load(name.to_owned(), mesh3d, render_ctx)
}
MeshSourceData::StaticGlb(_mesh_id, glb_bytes) => LoadedMesh::load_raw(
name.to_owned(),
MeshFormat::Glb,
glb_bytes,
render_ctx,
),
};
let result = LoadedMesh::load(name.to_owned(), mesh, render_ctx);

match result {
Ok(cpu_mesh) => Some(Arc::new(cpu_mesh)),
Expand Down
4 changes: 2 additions & 2 deletions crates/re_viewer/src/misc/caches/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ use re_log_types::component_types;
/// Does memoization of different things for the immediate mode UI.
#[derive(Default)]
pub struct Caches {
/// For displaying images efficiently in immediate mode.
/// Cached decoded tensors.
pub decode: tensor_decode_cache::DecodeCache,

/// For displaying meshes efficiently in immediate mode.
/// Cached loaded meshes (from file or converted from user data).
pub mesh: mesh_cache::MeshCache,

tensor_stats: nohash_hasher::IntMap<component_types::TensorId, TensorStats>,
Expand Down
2 changes: 1 addition & 1 deletion crates/re_viewer/src/ui/view_spatial/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ mod ui_2d;
mod ui_3d;
pub mod ui_renderer_bridge;

pub use self::scene::{Image, MeshSource, MeshSourceData, SceneSpatial, UiLabel, UiLabelTarget};
pub use self::scene::{Image, MeshSource, SceneSpatial, UiLabel, UiLabelTarget};
pub use self::space_camera_3d::SpaceCamera3D;
pub use ui::{SpatialNavigationMode, ViewSpatialState};
pub use ui_2d::view_2d;
Expand Down
23 changes: 1 addition & 22 deletions crates/re_viewer/src/ui/view_spatial/scene/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use ahash::HashMap;
use re_data_store::{EntityPath, InstancePathHash};
use re_log_types::{
component_types::{ClassId, InstanceKey, KeypointId},
DecodedTensor, MeshId,
DecodedTensor,
};
use re_renderer::{renderer::TexturedRect, Color32, OutlineMaskPreference, Size};

Expand All @@ -27,27 +27,6 @@ pub use self::picking::{PickingContext, PickingHitType, PickingRayHit, PickingRe
pub use self::primitives::SceneSpatialPrimitives;
use scene_part::ScenePart;

// ----------------------------------------------------------------------------

pub enum MeshSourceData {
Mesh3D(re_log_types::Mesh3D),

/// Static meshes that are embedded in the player
///
/// Not used as of writing but may come back.
#[allow(dead_code)]
StaticGlb(MeshId, &'static [u8]),
}

impl MeshSourceData {
pub fn mesh_id(&self) -> MeshId {
match self {
MeshSourceData::Mesh3D(mesh) => mesh.mesh_id(),
MeshSourceData::StaticGlb(id, _) => *id,
}
}
}

/// TODO(andreas): Scene should only care about converted rendering primitive.
pub struct MeshSource {
pub picking_instance_hash: InstancePathHash,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::{
misc::{SpaceViewHighlights, TransformCache, ViewerContext},
ui::{
scene::SceneQuery,
view_spatial::{MeshSource, MeshSourceData, SceneSpatial},
view_spatial::{MeshSource, SceneSpatial},
DefaultColor,
},
};
Expand Down Expand Up @@ -46,11 +46,7 @@ impl MeshPart {
if let Some(mesh) = ctx
.cache
.mesh
.load(
&ent_path.to_string(),
&MeshSourceData::Mesh3D(mesh),
ctx.render_ctx,
)
.load(&ent_path.to_string(), &mesh, ctx.render_ctx)
.map(|cpu_mesh| MeshSource {
picking_instance_hash,
world_from_mesh: world_from_obj,
Expand Down

0 comments on commit d7469e3

Please sign in to comment.