mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'sharp/zoomy-worldgen' of gitlab.com:veloren/veloren into sharp/zoomy-worldgen
This commit is contained in:
commit
ca2abbb792
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -6991,6 +6991,7 @@ dependencies = [
|
|||||||
"egui",
|
"egui",
|
||||||
"egui_winit_platform",
|
"egui_winit_platform",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
|
"num 0.4.0",
|
||||||
"veloren-client",
|
"veloren-client",
|
||||||
"veloren-common",
|
"veloren-common",
|
||||||
"veloren-voxygen-dynlib",
|
"veloren-voxygen-dynlib",
|
||||||
|
@ -73,6 +73,7 @@ where
|
|||||||
"quinn_proto::connection=info",
|
"quinn_proto::connection=info",
|
||||||
"veloren_server::persistence::character=info",
|
"veloren_server::persistence::character=info",
|
||||||
"veloren_server::settings=info",
|
"veloren_server::settings=info",
|
||||||
|
"veloren_voxygen::audio::sfx=info",
|
||||||
];
|
];
|
||||||
|
|
||||||
for s in default_directives {
|
for s in default_directives {
|
||||||
|
@ -14,6 +14,7 @@ common = {package = "veloren-common", path = "../../common"}
|
|||||||
egui = "0.12"
|
egui = "0.12"
|
||||||
egui_winit_platform = "0.8"
|
egui_winit_platform = "0.8"
|
||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4.0"
|
||||||
|
num = "0.4"
|
||||||
voxygen-dynlib = {package = "veloren-voxygen-dynlib", path = "../dynlib", optional = true}
|
voxygen-dynlib = {package = "veloren-voxygen-dynlib", path = "../dynlib", optional = true}
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ use egui::{
|
|||||||
widgets::plot::Curve,
|
widgets::plot::Curve,
|
||||||
CollapsingHeader, Color32, Grid, Pos2, ScrollArea, Slider, Ui, Window,
|
CollapsingHeader, Color32, Grid, Pos2, ScrollArea, Slider, Ui, Window,
|
||||||
};
|
};
|
||||||
|
use num::{ToPrimitive, Zero};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
admin::draw_admin_commands_window, character_states::draw_char_state_group,
|
admin::draw_admin_commands_window, character_states::draw_char_state_group,
|
||||||
@ -82,6 +83,7 @@ impl AdminCommandState {
|
|||||||
pub struct EguiDebugInfo {
|
pub struct EguiDebugInfo {
|
||||||
pub frame_time: Duration,
|
pub frame_time: Duration,
|
||||||
pub ping_ms: f64,
|
pub ping_ms: f64,
|
||||||
|
pub mesh_active: usize,
|
||||||
pub mesh_todo: usize,
|
pub mesh_todo: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,11 +92,73 @@ pub struct EguiInnerState {
|
|||||||
admin_command_state: AdminCommandState,
|
admin_command_state: AdminCommandState,
|
||||||
max_entity_distance: f32,
|
max_entity_distance: f32,
|
||||||
selected_entity_cylinder_height: f32,
|
selected_entity_cylinder_height: f32,
|
||||||
frame_times: Vec<f32>,
|
plots: EguiPlots,
|
||||||
mesh_todos: Vec<usize>,
|
|
||||||
windows: EguiWindows,
|
windows: EguiWindows,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub struct EguiPlots {
|
||||||
|
frame_times: EguiPlot<f32>,
|
||||||
|
chunks_active_meshing: EguiPlot<usize>,
|
||||||
|
chunks_pending_meshing: EguiPlot<usize>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for EguiPlots {
|
||||||
|
fn default() -> Self {
|
||||||
|
const DATA_POINT_LIMIT: usize = 2000;
|
||||||
|
|
||||||
|
Self {
|
||||||
|
frame_times: EguiPlot::<f32>::new("Frame Times".to_owned(), DATA_POINT_LIMIT),
|
||||||
|
chunks_active_meshing: EguiPlot::<usize>::new(
|
||||||
|
"Chunks Active Meshing".to_owned(),
|
||||||
|
DATA_POINT_LIMIT,
|
||||||
|
),
|
||||||
|
chunks_pending_meshing: EguiPlot::<usize>::new(
|
||||||
|
"Chunks Pending Meshing".to_owned(),
|
||||||
|
DATA_POINT_LIMIT,
|
||||||
|
),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct EguiPlot<T> {
|
||||||
|
title: String,
|
||||||
|
data_points: Vec<T>,
|
||||||
|
/// The number of data points that will be retained and displayed in the
|
||||||
|
/// plot
|
||||||
|
data_point_limit: usize,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T: Clone + Copy + ToPrimitive + Zero> EguiPlot<T> {
|
||||||
|
fn new(title: String, data_point_limit: usize) -> Self {
|
||||||
|
Self {
|
||||||
|
title,
|
||||||
|
data_points: vec![T::zero(); data_point_limit],
|
||||||
|
data_point_limit,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn maintain(&mut self, value: T) {
|
||||||
|
self.data_points.push(value);
|
||||||
|
if self.data_points.len() > self.data_point_limit {
|
||||||
|
self.data_points.remove(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn current_value(&self) -> T { self.data_points.last().map(|x| *x).unwrap_or(T::zero()) }
|
||||||
|
|
||||||
|
fn plot(&self, color: Color32) -> Plot {
|
||||||
|
Plot::new(self.title.to_owned()).curve(
|
||||||
|
Curve::from_values_iter(
|
||||||
|
self.data_points
|
||||||
|
.iter()
|
||||||
|
.enumerate()
|
||||||
|
.map(|(i, x)| Value::new(i as f64, x.to_f64().unwrap())),
|
||||||
|
)
|
||||||
|
.color(color),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Default)]
|
#[derive(Clone, Default)]
|
||||||
pub struct EguiWindows {
|
pub struct EguiWindows {
|
||||||
admin_commands: bool,
|
admin_commands: bool,
|
||||||
@ -102,6 +166,7 @@ pub struct EguiWindows {
|
|||||||
egui_settings: bool,
|
egui_settings: bool,
|
||||||
egui_memory: bool,
|
egui_memory: bool,
|
||||||
frame_time: bool,
|
frame_time: bool,
|
||||||
|
engine_performance: bool,
|
||||||
ecs_entities: bool,
|
ecs_entities: bool,
|
||||||
experimental_shaders: bool,
|
experimental_shaders: bool,
|
||||||
}
|
}
|
||||||
@ -113,8 +178,7 @@ impl Default for EguiInnerState {
|
|||||||
selected_entity_info: None,
|
selected_entity_info: None,
|
||||||
max_entity_distance: 100000.0,
|
max_entity_distance: 100000.0,
|
||||||
selected_entity_cylinder_height: 10.0,
|
selected_entity_cylinder_height: 10.0,
|
||||||
frame_times: Vec::new(),
|
plots: EguiPlots::default(),
|
||||||
mesh_todos: Vec::new(),
|
|
||||||
windows: EguiWindows::default(),
|
windows: EguiWindows::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -231,16 +295,17 @@ pub fn maintain_egui_inner(
|
|||||||
|
|
||||||
if let Some(debug_info) = debug_info.as_ref() {
|
if let Some(debug_info) = debug_info.as_ref() {
|
||||||
egui_state
|
egui_state
|
||||||
|
.plots
|
||||||
.frame_times
|
.frame_times
|
||||||
.push(debug_info.frame_time.as_nanos() as f32);
|
.maintain(debug_info.frame_time.as_nanos() as f32);
|
||||||
if egui_state.frame_times.len() > 250 {
|
egui_state
|
||||||
egui_state.frame_times.remove(0);
|
.plots
|
||||||
}
|
.chunks_active_meshing
|
||||||
|
.maintain(debug_info.mesh_active);
|
||||||
egui_state.mesh_todos.push(debug_info.mesh_todo);
|
egui_state
|
||||||
if egui_state.mesh_todos.len() > 2000 {
|
.plots
|
||||||
egui_state.mesh_todos.remove(0);
|
.chunks_pending_meshing
|
||||||
}
|
.maintain(debug_info.mesh_todo);
|
||||||
};
|
};
|
||||||
|
|
||||||
let start_pos = Pos2 { x: 300.0, y: 0.0 };
|
let start_pos = Pos2 { x: 300.0, y: 0.0 };
|
||||||
@ -260,6 +325,7 @@ pub fn maintain_egui_inner(
|
|||||||
ui.checkbox(&mut windows.admin_commands, "Admin Commands");
|
ui.checkbox(&mut windows.admin_commands, "Admin Commands");
|
||||||
ui.checkbox(&mut windows.ecs_entities, "ECS Entities");
|
ui.checkbox(&mut windows.ecs_entities, "ECS Entities");
|
||||||
ui.checkbox(&mut windows.frame_time, "Frame Time");
|
ui.checkbox(&mut windows.frame_time, "Frame Time");
|
||||||
|
ui.checkbox(&mut windows.engine_performance, "Engine Performance");
|
||||||
ui.checkbox(&mut windows.experimental_shaders, "Experimental Shaders");
|
ui.checkbox(&mut windows.experimental_shaders, "Experimental Shaders");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -296,41 +362,43 @@ pub fn maintain_egui_inner(
|
|||||||
ctx.memory_ui(ui);
|
ctx.memory_ui(ui);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Window::new("Engine Performance")
|
||||||
|
.open(&mut windows.engine_performance)
|
||||||
|
.default_width(200.0)
|
||||||
|
.default_height(400.0)
|
||||||
|
.show(ctx, |ui| {
|
||||||
|
ui.label(format!(
|
||||||
|
"Active Meshing: {}",
|
||||||
|
egui_state.plots.chunks_active_meshing.current_value()
|
||||||
|
));
|
||||||
|
let chunks_active_meshing_plot = egui_state
|
||||||
|
.plots
|
||||||
|
.chunks_active_meshing
|
||||||
|
.plot(Color32::from_rgb(241, 80, 88))
|
||||||
|
.height(250.0);
|
||||||
|
ui.add(chunks_active_meshing_plot);
|
||||||
|
|
||||||
|
ui.add_space(10.0);
|
||||||
|
|
||||||
|
ui.label(format!(
|
||||||
|
"Pending Meshing: {}",
|
||||||
|
egui_state.plots.chunks_pending_meshing.current_value()
|
||||||
|
));
|
||||||
|
let chunks_pending_meshing_plot = egui_state
|
||||||
|
.plots
|
||||||
|
.chunks_pending_meshing
|
||||||
|
.plot(Color32::from_rgb(45, 91, 215))
|
||||||
|
.height(250.0);
|
||||||
|
ui.add(chunks_pending_meshing_plot);
|
||||||
|
});
|
||||||
|
|
||||||
Window::new("Frame Time")
|
Window::new("Frame Time")
|
||||||
.open(&mut windows.frame_time)
|
.open(&mut windows.frame_time)
|
||||||
.default_width(200.0)
|
.default_width(200.0)
|
||||||
.default_height(200.0)
|
.default_height(200.0)
|
||||||
.show(ctx, |ui| {
|
.show(ctx, |ui| {
|
||||||
let plot = Plot::new("Frame Time")
|
let plot = egui_state.plots.frame_times.plot(Color32::RED).height(50.0);
|
||||||
.curve(Curve::from_values_iter(
|
|
||||||
egui_state
|
|
||||||
.frame_times
|
|
||||||
.iter()
|
|
||||||
.enumerate()
|
|
||||||
.map(|(i, x)| Value::new(i as f64, *x)),
|
|
||||||
))
|
|
||||||
.height(50.0);
|
|
||||||
ui.add(plot);
|
ui.add(plot);
|
||||||
|
|
||||||
ui.add_space(20.0);
|
|
||||||
|
|
||||||
ui.label(format!(
|
|
||||||
"Pending Meshing: {}",
|
|
||||||
&egui_state.mesh_todos.last().unwrap_or(&0usize)
|
|
||||||
));
|
|
||||||
let mesh_todo_plot = Plot::new("Chunks Pending Meshing")
|
|
||||||
.curve(
|
|
||||||
Curve::from_values_iter(
|
|
||||||
egui_state
|
|
||||||
.mesh_todos
|
|
||||||
.iter()
|
|
||||||
.enumerate()
|
|
||||||
.map(|(i, x)| Value::new(i as f64, (*x) as f64)),
|
|
||||||
)
|
|
||||||
.color(Color32::from_rgb(45, 91, 215)),
|
|
||||||
)
|
|
||||||
.height(200.0);
|
|
||||||
ui.add(mesh_todo_plot);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if windows.ecs_entities {
|
if windows.ecs_entities {
|
||||||
|
@ -362,6 +362,10 @@ pub struct Terrain<V: RectRasterableVol = TerrainChunk> {
|
|||||||
|
|
||||||
impl Terrain {
|
impl Terrain {
|
||||||
pub fn chunks_pending_meshing_count(&self) -> usize { self.mesh_todo.iter().len() }
|
pub fn chunks_pending_meshing_count(&self) -> usize { self.mesh_todo.iter().len() }
|
||||||
|
|
||||||
|
pub fn chunks_active_meshing_count(&self) -> usize {
|
||||||
|
self.mesh_todos_active.load(Ordering::Relaxed) as usize
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TerrainChunkData {
|
impl TerrainChunkData {
|
||||||
|
@ -1106,6 +1106,7 @@ impl PlayState for SessionState {
|
|||||||
let debug_info = debug_info.map(|debug_info| EguiDebugInfo {
|
let debug_info = debug_info.map(|debug_info| EguiDebugInfo {
|
||||||
frame_time: debug_info.frame_time,
|
frame_time: debug_info.frame_time,
|
||||||
ping_ms: debug_info.ping_ms,
|
ping_ms: debug_info.ping_ms,
|
||||||
|
mesh_active: self.scene.terrain().chunks_active_meshing_count(),
|
||||||
mesh_todo: self.scene.terrain().chunks_pending_meshing_count(),
|
mesh_todo: self.scene.terrain().chunks_pending_meshing_count(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user