Skip to content

Commit

Permalink
only cull via indices
Browse files Browse the repository at this point in the history
  • Loading branch information
kayhhh committed Aug 7, 2024
1 parent 1018708 commit 5d97e6e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 105 deletions.
97 changes: 0 additions & 97 deletions crates/bevy_vrm/src/first_person.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,97 +39,6 @@ pub static RENDER_LAYERS: LazyLock<HashMap<FirstPersonFlag, RenderLayers>> = 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);

Expand Down Expand Up @@ -217,12 +126,6 @@ pub(crate) fn handle_setup_events(
let mut to_remove = to_remove.into_iter().collect::<Vec<_>>();
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) => {
Expand Down
11 changes: 3 additions & 8 deletions crates/vrm_viewer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ struct Settings {
pub render_layer: RenderLayer,
}

const VRM_PATH: &str = "alicia.vrm";

fn setup(mut commands: Commands, mut settings: ResMut<Settings>) {
commands.spawn((
Camera3dBundle {
Expand Down Expand Up @@ -93,7 +91,7 @@ fn setup(mut commands: Commands, mut settings: ResMut<Settings>) {
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(
Expand All @@ -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);
}
}
}
Expand Down

0 comments on commit 5d97e6e

Please sign in to comment.