- pub fn add_block(&mut self, state: &mut State, pos: Point3<i16>, block: Box<MapBlock>) {
+ pub fn update(&mut self, state: &mut State) {
+ std::mem::swap(
+ self.queue_produce.lock().unwrap().deref_mut(),
+ &mut self.queue_consume,
+ );
+ for (pos, data) in self.queue_consume.drain() {
+ self.blocks.insert(
+ pos.into(),
+ BlockModel {
+ mesh: BlockMesh::new(state, &data.vertices),
+ mesh_blend: BlockMesh::new(state, &data.vertices_blend),
+ transform: MatrixUniform::new(
+ &state.device,
+ &self.model,
+ Matrix4::from_translation(
+ block_float_pos(pos.to_vec()) + Vector3::new(8.5, 8.5, 8.5),
+ ),
+ "mapblock",
+ false,
+ ),
+ },
+ );
+ }
+ }
+
+ pub fn add_block(&self, pos: Point3<i16>, block: Box<MapBlock>) {