Dynamic loading, saving, generating chunks works

This commit is contained in:
Piotrek
2021-05-13 09:13:43 +02:00
parent ab9f4c83d0
commit 57782a88ab
7 changed files with 73 additions and 55 deletions
+3 -3
View File
@@ -1,7 +1,7 @@
use std::time::Instant;
use byteorder::{ByteOrder, LittleEndian};
use std::convert::TryInto;
use cgmath::Point3;
use cgmath::Vector3;
use crate::game::world::block::WorldBlock;
//note: remember to update in main.frag
@@ -102,10 +102,10 @@ impl Content {
}
#[allow(unused)]
pub fn write(&mut self, queue: &wgpu::Queue, block_pos: &Point3<u32>, block: &WorldBlock) {
pub fn write(&mut self, queue: &wgpu::Queue, block_pos: &Vector3<i32>, block: &WorldBlock) {
// Get node
let index = (block_pos.x + NODE_TEX_SIZE as u32 * (block_pos.y + NODE_TEX_SIZE as u32 * block_pos.z)) as usize;
let index = (block_pos.x + NODE_TEX_SIZE as i32 * (block_pos.y + NODE_TEX_SIZE as i32 * block_pos.z)) as usize;
let mut value = self.node_buffer[index] as usize;
// Allocate new block