mirror of
https://github.com/horizon-rust/horizon.git
synced 2026-11-07 17:21:49 -10:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
510b2a9667 |
No files matched your search
@@ -1,6 +1,7 @@
|
||||
//! Horizon native client: resources, world streaming, rendering and the
|
||||
//! bindings between the validated simulation pieces and the game loop.
|
||||
#![forbid(unsafe_code)]
|
||||
pub mod remesh_probe;
|
||||
pub mod advancements;
|
||||
pub mod ambience;
|
||||
pub mod animate_tick;
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
//! TEMPORARY probe (#270), not committed.
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Mutex;
|
||||
pub static SETS: Mutex<Option<HashMap<(u16, u16), u64>>> = Mutex::new(None);
|
||||
pub static SRC: Mutex<[u64; 6]> = Mutex::new([0; 6]);
|
||||
pub fn set(old: u16, new: u16) {
|
||||
*SETS.lock().unwrap().get_or_insert_with(HashMap::new).entry((old, new)).or_default() += 1;
|
||||
}
|
||||
pub fn src(i: usize, n: u64) {
|
||||
SRC.lock().unwrap()[i] += n;
|
||||
}
|
||||
pub fn dump(t: f64, meshed: u64) {
|
||||
let sets = SETS.lock().unwrap().take().unwrap_or_default();
|
||||
let src = std::mem::take(&mut *SRC.lock().unwrap());
|
||||
let mut v: Vec<_> = sets.into_iter().collect();
|
||||
v.sort_by_key(|e| std::cmp::Reverse(e.1));
|
||||
let total: u64 = v.iter().map(|e| e.1).sum();
|
||||
eprintln!("PROBE t={t:.1} meshed={meshed} sets={total} src(set,light,lit,other,lightpos,rlit)={src:?} top={:?}", &v[..v.len().min(8)]);
|
||||
}
|
||||
@@ -607,6 +607,13 @@ impl Streaming {
|
||||
world: &mut World,
|
||||
) -> (Vec<((i32, i32, i32), SectionMesh)>, Vec<Arc<Chunk>>) {
|
||||
let mut uploads = Vec::new();
|
||||
{
|
||||
static T0: std::sync::OnceLock<std::time::Instant> = std::sync::OnceLock::new();
|
||||
static LAST: Mutex<f64> = Mutex::new(0.0);
|
||||
let t = T0.get_or_init(std::time::Instant::now).elapsed().as_secs_f64();
|
||||
let mut l = LAST.lock().unwrap();
|
||||
if t - *l >= 1.0 { *l = t; crate::remesh_probe::dump(t, self.meshed_total as u64); }
|
||||
}
|
||||
if self.paused {
|
||||
return (uploads, Vec::new());
|
||||
}
|
||||
@@ -643,7 +650,7 @@ impl Streaming {
|
||||
for dz in -1..=1 {
|
||||
for dx in -1..=1 {
|
||||
for sy in 0..SECTIONS as i32 {
|
||||
world.dirty_sections.insert((x + dx, sy, z + dz));
|
||||
if world.dirty_sections.insert((x + dx, sy, z + dz)) { crate::remesh_probe::src(2, 1); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1008,6 +1015,7 @@ impl Streaming {
|
||||
&positions,
|
||||
false,
|
||||
);
|
||||
crate::remesh_probe::src(4, changed.len() as u64);
|
||||
Self::mark_light_changes(world, &changed);
|
||||
if !self.light_snapshots.is_empty() {
|
||||
for p in positions {
|
||||
@@ -1060,7 +1068,7 @@ impl Streaming {
|
||||
continue;
|
||||
}
|
||||
last = Some(s);
|
||||
world.dirty_sections.insert((s.1, s.0, s.2));
|
||||
if world.dirty_sections.insert((s.1, s.0, s.2)) { crate::remesh_probe::src(1, 1); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,6 +197,7 @@ impl World {
|
||||
}
|
||||
let previous = Arc::make_mut(chunk).set(x & 15, y, z & 15, state.0 as u16);
|
||||
if u32::from(previous) != state.0 {
|
||||
crate::remesh_probe::set(previous, state.0 as u16);
|
||||
let watches = |id: u16| self.watched.get(usize::from(id)).copied().unwrap_or(false);
|
||||
if watches(previous) || watches(state.0 as u16) {
|
||||
self.watched_writes
|
||||
@@ -216,7 +217,7 @@ impl World {
|
||||
if !(0..SECTIONS as i32).contains(&s) {
|
||||
continue;
|
||||
}
|
||||
self.dirty_sections.insert((bx >> 4, s, bz >> 4));
|
||||
if self.dirty_sections.insert((bx >> 4, s, bz >> 4)) { crate::remesh_probe::src(0, 1); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user