Use approximate byte count for the terrain recv graph.

This commit is contained in:
Avi Weinstock 2021-06-26 22:38:52 -04:00
parent 6ba512efc8
commit c2106e158f
3 changed files with 12 additions and 2 deletions

View File

@ -2123,7 +2123,9 @@ impl Client {
cnt += 1;
#[cfg(feature = "tracy")]
{
terrain_cnt += 1;
if let ServerGeneral::TerrainChunkUpdate { chunk, .. } = &msg {
terrain_cnt += chunk.as_ref().map(|x| x.approx_len()).unwrap_or(0);
}
}
self.handle_server_terrain_msg(msg)?;
}

View File

@ -756,7 +756,7 @@ pub fn write_image_terrain<
pub struct WireChonk<VIE: VoxelImageEncoding, P: PackingFormula, M: Clone, S: RectVolSize> {
zmin: i32,
zmax: i32,
data: VIE::Output,
pub(crate) data: VIE::Output,
below: Block,
above: Block,
meta: M,

View File

@ -74,6 +74,14 @@ pub enum SerializedTerrainChunk {
}
impl SerializedTerrainChunk {
pub fn approx_len(&self) -> usize {
match self {
SerializedTerrainChunk::DeflatedChonk(data) => data.data.len(),
SerializedTerrainChunk::QuadPng(data) => data.data.data.len(),
SerializedTerrainChunk::TriPng(data) => data.data.data.len(),
}
}
pub fn via_heuristic(chunk: &TerrainChunk, lossy_compression: bool) -> Self {
if lossy_compression && (chunk.get_max_z() - chunk.get_min_z() <= 128) {
Self::quadpng(chunk)