From 61ecd2c178bcd7451f285be58a2f9ec8bd9164a2 Mon Sep 17 00:00:00 2001 From: Isse Date: Fri, 5 May 2023 20:32:41 +0200 Subject: [PATCH] various small fixes --- common/src/figure/mod.rs | 4 ++-- common/src/states/utils.rs | 4 ++-- common/src/terrain/block.rs | 2 +- server/src/events/interaction.rs | 2 +- voxygen/src/mesh/segment.rs | 16 ++-------------- 5 files changed, 8 insertions(+), 20 deletions(-) diff --git a/common/src/figure/mod.rs b/common/src/figure/mod.rs index 8de36d2ce6..4f27c46bca 100644 --- a/common/src/figure/mod.rs +++ b/common/src/figure/mod.rs @@ -9,7 +9,7 @@ pub use self::{ }; use crate::{ - terrain::{Block, BlockKind}, + terrain::{Block, BlockKind, SpriteKind}, vol::{IntoFullPosIterator, IntoFullVolIterator, ReadVol, SizedVol, Vox, WriteVol}, volumes::dyna::Dyna, }; @@ -24,7 +24,7 @@ impl From for TerrainSegment { Err(_) | Ok(Cell::Empty) => Block::empty(), Ok(cell) => { if cell.is_hollow() { - Block::empty() + Block::air(SpriteKind::Empty) } else if cell.is_glowy() { Block::new(BlockKind::GlowingRock, cell.get_color().unwrap()) } else { diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index efe78b207b..dd5c74ef94 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -854,7 +854,7 @@ pub fn attempt_swap_equipped_weapons(data: &JoinData<'_>, update: &mut StateUpda } } -fn reach_block( +fn can_reach_block( player_pos: Vec3, block_pos: Vec3, range: f32, @@ -975,7 +975,7 @@ pub fn handle_manipulate_loadout( let sprite_interact = sprite_at_pos.and_then(Option::::from); if let Some(sprite_interact) = sprite_interact { - if reach_block( + if can_reach_block( data.pos.0, sprite_pos, MAX_PICKUP_RANGE, diff --git a/common/src/terrain/block.rs b/common/src/terrain/block.rs index f68f2f66d5..db3364f4a5 100644 --- a/common/src/terrain/block.rs +++ b/common/src/terrain/block.rs @@ -119,7 +119,7 @@ pub struct Block { } impl Vox for Block { - fn empty() -> Self { Block::empty() } + fn empty() -> Self { Block::air(SpriteKind::Empty) } fn is_empty(&self) -> bool { self.is_air() && self.get_sprite().is_none() } } diff --git a/server/src/events/interaction.rs b/server/src/events/interaction.rs index cbcc423913..a2170fc805 100644 --- a/server/src/events/interaction.rs +++ b/server/src/events/interaction.rs @@ -161,7 +161,7 @@ pub fn handle_mount_volume(server: &mut Server, rider: EcsEntity, volume_pos: Vo let mount_pos = (mat * mount_offset.0.with_w(1.0)).xyz(); let within_range = { let positions = state.ecs().read_storage::(); - positions.get(rider).map_or(false, |pos| pos.0.distance_squared(mount_pos) < MAX_SPRITE_MOUNT_RANGE * MAX_SPRITE_MOUNT_RANGE) + positions.get(rider).map_or(false, |pos| pos.0.distance_squared(mount_pos) < MAX_SPRITE_MOUNT_RANGE.powi(2)) }; let maybe_uid = state.ecs().read_storage::().get(rider).copied(); diff --git a/voxygen/src/mesh/segment.rs b/voxygen/src/mesh/segment.rs index e731150120..68b5f28703 100644 --- a/voxygen/src/mesh/segment.rs +++ b/voxygen/src/mesh/segment.rs @@ -157,20 +157,8 @@ where let greedy_size_cross = greedy_size; let draw_delta = lower_bound; - let get_light = |vol: &mut V, pos: Vec3| { - if vol.get(pos).map_or(true, |vox| vox.is_fluid()) { - 1.0 - } else { - 0.0 - } - }; - let get_ao = |vol: &mut V, pos: Vec3| { - if vol.get(pos).map_or(false, |vox| vox.is_opaque()) { - 0.0 - } else { - 1.0 - } - }; + let get_light = |vol: &mut V, pos: Vec3| vol.get(pos).map_or(true, |vox| vox.is_fluid()) as i32 as f32; + let get_ao = |vol: &mut V, pos: Vec3| vol.get(pos).map_or(false, |vox| vox.is_opaque()) as i32 as f32; let get_glow = |vol: &mut V, pos: Vec3| { vol.get(pos) .ok()