Pausing rendering, warnings cleanup, more statistics
This commit is contained in:
+9
-15
@@ -1,20 +1,20 @@
|
||||
use std::time::Instant;
|
||||
use flate2::Compression;
|
||||
use flate2::write::DeflateEncoder;
|
||||
use flate2::read::DeflateDecoder;
|
||||
use byteorder::LittleEndian;
|
||||
use byteorder::ByteOrder;
|
||||
use cgmath::Point3;
|
||||
use std::io::Write;
|
||||
use std::convert::TryInto;
|
||||
use lzzzz::lz4;
|
||||
use std::io::Read;
|
||||
use crate::game::world::{WorldBlock, block};
|
||||
|
||||
pub const SIZE: usize = 32;
|
||||
const SIZE_SQ: usize = SIZE*SIZE;
|
||||
const SIZE_QB: usize = SIZE*SIZE*SIZE;
|
||||
|
||||
// 1 chunk times on i7-5930K
|
||||
// alg | size | compr | decom
|
||||
// raw 32.89kB 0.06s 1.19s
|
||||
// deflate fast 1.23kB 1.22s 5.46s
|
||||
// lz4 1.6kB 0.07s 1.23s
|
||||
|
||||
|
||||
pub struct WorldChunk {
|
||||
nodes: Box<[u32]>,
|
||||
blocks: Vec<WorldBlock>
|
||||
@@ -30,15 +30,15 @@ impl WorldChunk {
|
||||
|
||||
pub fn from_bytes(bytes: Vec<u8>) -> Self {
|
||||
let mut instance = Self::new();
|
||||
let (header_bytes, bytes) = bytes.split_at(128);
|
||||
let (node_bytes, block_bytes_compressed) = bytes.split_at((SIZE_QB*4) as usize);
|
||||
|
||||
// Header
|
||||
let (header_bytes, bytes) = bytes.split_at(128);
|
||||
let file_ver = header_bytes[0];
|
||||
let num_blocks = LittleEndian::read_u32(&header_bytes[1..5]) as usize;
|
||||
assert_eq!(file_ver, 1);
|
||||
|
||||
// Nodes
|
||||
let (node_bytes, block_bytes_compressed) = bytes.split_at((SIZE_QB*4) as usize);
|
||||
for i in 0..SIZE_QB {
|
||||
let idx = (i*4) as usize;
|
||||
let val = u32::from_le_bytes([node_bytes[idx], node_bytes[idx+1], node_bytes[idx+2], node_bytes[idx+3]]);
|
||||
@@ -79,12 +79,6 @@ impl WorldChunk {
|
||||
}
|
||||
lz4::compress_to_vec(&buf, &mut bytes, lz4::ACC_LEVEL_DEFAULT).unwrap();
|
||||
|
||||
|
||||
// alg | size | compr | decom
|
||||
// raw 32.89kB 0.06s 1.19s
|
||||
// deflate fast 1.23kB 1.22s 5.46s
|
||||
// lz4 1.6kB 0.07s 1.23s
|
||||
|
||||
bytes
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user