Skip to content
This repository was archived by the owner on Nov 13, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@ bevy_utilities = { path = "bevy_utilities" }
building-blocks = { path = "..", features = ["glam", "mesh", "sdfu"] }
utilities = { path = "../crates/utilities", features = ["simdnoise"]}

[dependencies.bevy]
version = "0.5"
# git = "https://github.com/bevyengine/bevy"
# rev = "94c41840"
# path = "../../../bevy"
default-features = false
features = ["bevy_wgpu", "bevy_winit", "render", "png", "x11"]

[dependencies]
bevy-inspector-egui = "0.6"

[[example]]
name = "mesh_showcase"
path = "mesh_showcase/mesh_showcase.rs"
Expand Down
35 changes: 35 additions & 0 deletions examples/lod_terrain/lod_terrain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ use voxel_map::{MapConfig, VoxelMap};

use building_blocks::core::prelude::*;

use bevy_inspector_egui::{Inspectable, InspectorPlugin};
use bevy_utilities::{
bevy::{
diagnostic::{Diagnostics, FrameTimeDiagnosticsPlugin},
pbr::AmbientLight,
prelude::*,
render::camera::PerspectiveProjection,
Expand Down Expand Up @@ -69,12 +71,45 @@ fn run_example<Map: VoxelMap>() {
.add_plugin(WireframePlugin)
.add_plugin(LookTransformPlugin)
.add_plugin(FpsCameraPlugin)
.add_plugin(FrameTimeDiagnosticsPlugin::default())
.add_plugin(InspectorPlugin::<DiagnosticsInspectable>::new())
.add_startup_system(setup::<Map>.system())
.add_system(level_of_detail_system::<Map>.system())
.add_system(mesh_generator_system::<Map>.system())
.add_system(movement_sensitivity.system())
.add_system(diagnostics.system())
.run();
}

#[derive(Inspectable, Default)]
pub struct DiagnosticsInspectable {
fps: f64,
}

fn diagnostics(
diagnostics: Res<Diagnostics>,
mut diagnostics_inspectable: ResMut<DiagnosticsInspectable>,
) {
if let Some(diagnostic) = diagnostics.get(FrameTimeDiagnosticsPlugin::FPS) {
if let Some(value) = diagnostic.value() {
diagnostics_inspectable.fps = value;
}
}
}

fn movement_sensitivity(
keyboard: Res<Input<KeyCode>>,
mut controllers: Query<&mut FpsCameraController>,
) {
if let Ok(mut controller) = controllers.single_mut() {
if keyboard.pressed(KeyCode::LControl) {
controller.translate_sensitivity = 5.;
} else {
controller.translate_sensitivity = 0.5;
}
}
}

fn setup<Map: VoxelMap>(
map_config: Res<MapConfig>,
mut commands: Commands,
Expand Down