From 5d97e6e0ae58116a91f7191a34e342a961abf3e1 Mon Sep 17 00:00:00 2001 From: Kayh Date: Tue, 6 Aug 2024 23:56:13 -0400 Subject: [PATCH] only cull via indices --- crates/bevy_vrm/src/first_person.rs | 97 ----------------------------- crates/vrm_viewer/src/lib.rs | 11 +--- 2 files changed, 3 insertions(+), 105 deletions(-) diff --git a/crates/bevy_vrm/src/first_person.rs b/crates/bevy_vrm/src/first_person.rs index 7c316c7..8f390a3 100644 --- a/crates/bevy_vrm/src/first_person.rs +++ b/crates/bevy_vrm/src/first_person.rs @@ -39,97 +39,6 @@ pub static RENDER_LAYERS: LazyLock> = Laz map }); -macro_rules! call_vertex_vec { - ($enum_val:expr, $index:expr, $method:ident) => { - match $enum_val { - VertexAttributeValues::Float32(ref mut vec) => { - vec.$method($index); - } - VertexAttributeValues::Sint32(ref mut vec) => { - vec.$method($index); - } - VertexAttributeValues::Uint32(ref mut vec) => { - vec.$method($index); - } - VertexAttributeValues::Float32x2(ref mut vec) => { - vec.$method($index); - } - VertexAttributeValues::Sint32x2(ref mut vec) => { - vec.$method($index); - } - VertexAttributeValues::Uint32x2(ref mut vec) => { - vec.$method($index); - } - VertexAttributeValues::Float32x3(ref mut vec) => { - vec.$method($index); - } - VertexAttributeValues::Sint32x3(ref mut vec) => { - vec.$method($index); - } - VertexAttributeValues::Uint32x3(ref mut vec) => { - vec.$method($index); - } - VertexAttributeValues::Float32x4(ref mut vec) => { - vec.$method($index); - } - VertexAttributeValues::Sint32x4(ref mut vec) => { - vec.$method($index); - } - VertexAttributeValues::Uint32x4(ref mut vec) => { - vec.$method($index); - } - VertexAttributeValues::Sint16x2(ref mut vec) => { - vec.$method($index); - } - VertexAttributeValues::Snorm16x2(ref mut vec) => { - vec.$method($index); - } - VertexAttributeValues::Uint16x2(ref mut vec) => { - vec.$method($index); - } - VertexAttributeValues::Unorm16x2(ref mut vec) => { - vec.$method($index); - } - VertexAttributeValues::Sint16x4(ref mut vec) => { - vec.$method($index); - } - VertexAttributeValues::Snorm16x4(ref mut vec) => { - vec.$method($index); - } - VertexAttributeValues::Uint16x4(ref mut vec) => { - vec.$method($index); - } - VertexAttributeValues::Unorm16x4(ref mut vec) => { - vec.$method($index); - } - VertexAttributeValues::Sint8x2(ref mut vec) => { - vec.$method($index); - } - VertexAttributeValues::Snorm8x2(ref mut vec) => { - vec.$method($index); - } - VertexAttributeValues::Uint8x2(ref mut vec) => { - vec.$method($index); - } - VertexAttributeValues::Unorm8x2(ref mut vec) => { - vec.$method($index); - } - VertexAttributeValues::Sint8x4(ref mut vec) => { - vec.$method($index); - } - VertexAttributeValues::Snorm8x4(ref mut vec) => { - vec.$method($index); - } - VertexAttributeValues::Uint8x4(ref mut vec) => { - vec.$method($index); - } - VertexAttributeValues::Unorm8x4(ref mut vec) => { - vec.$method($index); - } - } - }; -} - #[derive(Event)] pub struct SetupFirstPerson(pub Entity); @@ -217,12 +126,6 @@ pub(crate) fn handle_setup_events( let mut to_remove = to_remove.into_iter().collect::>(); to_remove.sort_by(|a, b| b.cmp(a)); - for (_, values) in mesh.attributes_mut() { - for i in to_remove.iter().copied() { - call_vertex_vec!(values, i, remove); - } - } - if let Some(indices) = mesh.indices_mut() { match indices { Indices::U16(vec) => { diff --git a/crates/vrm_viewer/src/lib.rs b/crates/vrm_viewer/src/lib.rs index 9ecaa08..179c3c9 100644 --- a/crates/vrm_viewer/src/lib.rs +++ b/crates/vrm_viewer/src/lib.rs @@ -63,8 +63,6 @@ struct Settings { pub render_layer: RenderLayer, } -const VRM_PATH: &str = "alicia.vrm"; - fn setup(mut commands: Commands, mut settings: ResMut) { commands.spawn(( Camera3dBundle { @@ -93,7 +91,7 @@ fn setup(mut commands: Commands, mut settings: ResMut) { let mut transform = Transform::default(); transform.rotate_y(PI); - settings.model = VRM_PATH.to_string(); + settings.model = "alicia.vrm".to_string(); } fn set_render_layers( @@ -112,11 +110,8 @@ fn set_render_layers( if flag != *prev { *prev = flag; - let layers = RENDER_LAYERS[&flag].clone(); - - commands - .entity(entity) - .insert(layers.union(&RenderLayers::layer(0))); + let layers = RenderLayers::layer(0).union(&RENDER_LAYERS[&flag]); + commands.entity(entity).insert(layers); } } }