Perf improvement

This commit is contained in:
Danny McGee
2023-09-27 23:41:50 -04:00
parent a60d86f2d2
commit 3dba0ee868
+23 -2
View File
@@ -5,6 +5,8 @@ use bevy::{
render::render_resource::{AsBindGroup, ShaderRef},
};
use crate::orbit_cam::{self, OrbitCam};
pub struct TestScenePlugin;
impl Plugin for TestScenePlugin {
@@ -14,10 +16,17 @@ impl Plugin for TestScenePlugin {
prepass_enabled: true,
..default()
})
.add_systems(Startup, spawn_scene);
.add_systems(Startup, spawn_scene)
.add_systems(
Update,
move_plane_with_camera.after(orbit_cam::pan_orbit_camera),
);
}
}
#[derive(Component)]
struct WorldGridPlane;
fn spawn_scene(
mut cmd: Commands,
mut meshes: ResMut<Assets<Mesh>>,
@@ -53,16 +62,28 @@ fn spawn_scene(
cmd.spawn((
MaterialMeshBundle {
mesh: meshes.add(Mesh::from(shape::Plane {
size: 10_000.0,
size: 200.0,
subdivisions: 0,
})),
material: mat_proc_grid.add(ProceduralGridMaterial {}),
..default()
},
NotShadowCaster,
WorldGridPlane,
));
}
fn move_plane_with_camera(
mut plane: Query<(&WorldGridPlane, &mut Transform)>,
camera: Query<&OrbitCam>,
) {
let &OrbitCam { focus, .. } = camera.single();
let (_, mut xform) = plane.single_mut();
xform.translation.x = focus.x;
xform.translation.z = focus.z;
}
#[derive(AsBindGroup, Clone, TypePath, TypeUuid)]
#[uuid = "CE331A13-F247-4F5B-A75E-670B2BD5776A"]
struct ProceduralGridMaterial {}