mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Added egui plot showing the count of chunks pending meshing
This commit is contained in:
parent
957467e114
commit
7cee43b32d
@ -82,6 +82,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_todo: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct EguiInnerState {
|
pub struct EguiInnerState {
|
||||||
@ -90,6 +91,7 @@ pub struct EguiInnerState {
|
|||||||
max_entity_distance: f32,
|
max_entity_distance: f32,
|
||||||
selected_entity_cylinder_height: f32,
|
selected_entity_cylinder_height: f32,
|
||||||
frame_times: Vec<f32>,
|
frame_times: Vec<f32>,
|
||||||
|
mesh_todos: Vec<usize>,
|
||||||
windows: EguiWindows,
|
windows: EguiWindows,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,6 +114,7 @@ impl Default for EguiInnerState {
|
|||||||
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(),
|
frame_times: Vec::new(),
|
||||||
|
mesh_todos: Vec::new(),
|
||||||
windows: EguiWindows::default(),
|
windows: EguiWindows::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -233,6 +236,11 @@ pub fn maintain_egui_inner(
|
|||||||
if egui_state.frame_times.len() > 250 {
|
if egui_state.frame_times.len() > 250 {
|
||||||
egui_state.frame_times.remove(0);
|
egui_state.frame_times.remove(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
egui_state.mesh_todos.push(debug_info.mesh_todo);
|
||||||
|
if egui_state.mesh_todos.len() > 2000 {
|
||||||
|
egui_state.mesh_todos.remove(0);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let start_pos = Pos2 { x: 300.0, y: 0.0 };
|
let start_pos = Pos2 { x: 300.0, y: 0.0 };
|
||||||
@ -293,14 +301,36 @@ pub fn maintain_egui_inner(
|
|||||||
.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").curve(Curve::from_values_iter(
|
let plot = Plot::new("Frame Time")
|
||||||
|
.curve(Curve::from_values_iter(
|
||||||
egui_state
|
egui_state
|
||||||
.frame_times
|
.frame_times
|
||||||
.iter()
|
.iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(i, x)| Value::new(i as f64, *x)),
|
.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 {
|
||||||
|
@ -360,6 +360,10 @@ pub struct Terrain<V: RectRasterableVol = TerrainChunk> {
|
|||||||
phantom: PhantomData<V>,
|
phantom: PhantomData<V>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Terrain {
|
||||||
|
pub fn chunks_pending_meshing_count(&self) -> usize { self.mesh_todo.iter().len() }
|
||||||
|
}
|
||||||
|
|
||||||
impl TerrainChunkData {
|
impl TerrainChunkData {
|
||||||
pub fn can_shadow_sun(&self) -> bool { self.visible.is_visible() || self.can_shadow_sun }
|
pub fn can_shadow_sun(&self) -> bool { self.visible.is_visible() || self.can_shadow_sun }
|
||||||
}
|
}
|
||||||
@ -951,7 +955,13 @@ impl<V: RectRasterableVol> Terrain<V> {
|
|||||||
.filter(|todo| !todo.is_worker_active)
|
.filter(|todo| !todo.is_worker_active)
|
||||||
// TODO: BinaryHeap
|
// TODO: BinaryHeap
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
todo.sort_unstable_by_key(|todo| ((todo.pos.as_::<i64>() * TerrainChunk::RECT_SIZE.as_::<i64>()).distance_squared(mesh_focus_pos), todo.started_tick));
|
todo.sort_unstable_by_key(|todo| {
|
||||||
|
(
|
||||||
|
(todo.pos.as_::<i64>() * TerrainChunk::RECT_SIZE.as_::<i64>())
|
||||||
|
.distance_squared(mesh_focus_pos),
|
||||||
|
todo.started_tick,
|
||||||
|
)
|
||||||
|
});
|
||||||
|
|
||||||
for (todo, chunk) in todo.into_iter()
|
for (todo, chunk) in todo.into_iter()
|
||||||
.filter(|todo| !todo.is_worker_active)
|
.filter(|todo| !todo.is_worker_active)
|
||||||
|
@ -1103,13 +1103,16 @@ impl PlayState for SessionState {
|
|||||||
// Maintain egui (debug interface)
|
// Maintain egui (debug interface)
|
||||||
#[cfg(feature = "egui-ui")]
|
#[cfg(feature = "egui-ui")]
|
||||||
if global_state.settings.interface.egui_enabled() {
|
if global_state.settings.interface.egui_enabled() {
|
||||||
|
let debug_info = debug_info.map(|debug_info| EguiDebugInfo {
|
||||||
|
frame_time: debug_info.frame_time,
|
||||||
|
ping_ms: debug_info.ping_ms,
|
||||||
|
mesh_todo: self.scene.terrain().chunks_pending_meshing_count(),
|
||||||
|
});
|
||||||
|
|
||||||
let settings_change = global_state.egui_state.maintain(
|
let settings_change = global_state.egui_state.maintain(
|
||||||
&mut self.client.borrow_mut(),
|
&mut self.client.borrow_mut(),
|
||||||
&mut self.scene,
|
&mut self.scene,
|
||||||
debug_info.map(|debug_info| EguiDebugInfo {
|
debug_info,
|
||||||
frame_time: debug_info.frame_time,
|
|
||||||
ping_ms: debug_info.ping_ms,
|
|
||||||
}),
|
|
||||||
&global_state.settings,
|
&global_state.settings,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user