Skip to content

Commit

Permalink
Remove texture_key from AnyMesh::Asset
Browse files Browse the repository at this point in the history
- Add #derive[(Clone)] instead of impl Clone for MeshInstance
  • Loading branch information
EtaLoop committed Oct 11, 2024
1 parent f634de5 commit 38f4044
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 29 deletions.
1 change: 0 additions & 1 deletion crates/viewer/re_renderer/src/importer/stl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ pub enum StlImportError {
pub fn load_stl_from_buffer(
buffer: &[u8],
ctx: &RenderContext,
_texture_key: u64,
) -> Result<Vec<MeshInstance>, StlImportError> {
re_tracing::profile_function!();

Expand Down
15 changes: 1 addition & 14 deletions crates/viewer/re_renderer/src/renderer/mesh_renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ impl DrawData for MeshDrawData {
type Renderer = MeshRenderer;
}

#[derive(Clone)]
pub struct MeshInstance {
/// Gpu mesh used by this instance
pub gpu_mesh: Arc<GpuMesh>,
Expand All @@ -131,20 +132,6 @@ pub struct MeshInstance {
pub picking_layer_id: PickingLayerId,
}

impl Clone for MeshInstance {
#[inline]
fn clone(&self) -> Self {
Self {
gpu_mesh: self.gpu_mesh.clone(),
mesh: self.mesh.clone(),
world_from_mesh: self.world_from_mesh,
additive_tint: self.additive_tint,
outline_mask_ids: self.outline_mask_ids,
picking_layer_id: self.picking_layer_id,
}
}
}

impl MeshInstance {
/// Creates a new instance of a mesh with all fields set to default except for required ones.
pub fn new(gpu_mesh: Arc<GpuMesh>) -> Self {
Expand Down
4 changes: 0 additions & 4 deletions crates/viewer/re_space_view_spatial/src/mesh_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ pub struct MeshCache(HashMap<RowId, HashMap<MeshCacheKey, Option<Arc<LoadedMesh>
pub enum AnyMesh<'a> {
Asset {
asset: &'a re_types::archetypes::Asset3D,

/// If there are any textures associated with that asset (albedo etc), they use this
/// hash for texture manager lookup.
texture_key: u64,
},
Mesh {
mesh: &'a re_types::archetypes::Mesh3D,
Expand Down
12 changes: 3 additions & 9 deletions crates/viewer/re_space_view_spatial/src/mesh_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ impl LoadedMesh {
) -> anyhow::Result<Self> {
// TODO(emilk): load CpuMesh in background thread.
match mesh {
AnyMesh::Asset { asset, texture_key } => {
Ok(Self::load_asset3d(name, asset, texture_key, render_ctx)?)
}
AnyMesh::Asset { asset } => Ok(Self::load_asset3d(name, asset, render_ctx)?),
AnyMesh::Mesh { mesh, texture_key } => {
Ok(Self::load_mesh3d(name, mesh, texture_key, render_ctx)?)
}
Expand All @@ -47,7 +45,6 @@ impl LoadedMesh {
media_type: &MediaType,
asset3d: &Asset3D,
render_ctx: &RenderContext,
texture_key: u64,
) -> anyhow::Result<Self> {
re_tracing::profile_function!();

Expand All @@ -58,9 +55,7 @@ impl LoadedMesh {
re_renderer::importer::gltf::load_gltf_from_buffer(&name, bytes, render_ctx)?
}
MediaType::OBJ => re_renderer::importer::obj::load_obj_from_buffer(bytes, render_ctx)?,
MediaType::STL => {
re_renderer::importer::stl::load_stl_from_buffer(bytes, render_ctx, texture_key)?
}
MediaType::STL => re_renderer::importer::stl::load_stl_from_buffer(bytes, render_ctx)?,
_ => anyhow::bail!("{media_type} files are not supported"),
};

Expand Down Expand Up @@ -88,15 +83,14 @@ impl LoadedMesh {
fn load_asset3d(
name: String,
asset3d: &Asset3D,
texture_key: u64,
render_ctx: &RenderContext,
) -> anyhow::Result<Self> {
re_tracing::profile_function!();

let media_type =
MediaType::or_guess_from_data(asset3d.media_type.clone(), asset3d.blob.as_slice())
.ok_or_else(|| anyhow::anyhow!("couldn't guess media type"))?;
let slf = Self::load_asset3d_parts(name, &media_type, asset3d, render_ctx, texture_key)?;
let slf = Self::load_asset3d_parts(name, &media_type, asset3d, render_ctx)?;

Ok(slf)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ impl Asset3DVisualizer {
media_type: data.media_type.clone().map(Into::into),
albedo_factor: data.albedo_factor.copied(),
},
texture_key: re_log_types::hash::Hash64::hash(&key).hash64(),
},
render_ctx,
)
Expand Down

0 comments on commit 38f4044

Please sign in to comment.