mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
remove unneeded mut, provide default_select_pos to secondry key event handler, and use the is_filled() over the is_opaque() to be reader friendly
This commit is contained in:
parent
82f3c3c3e8
commit
d0bd1ddb24
@ -54,7 +54,7 @@ pub(super) fn select_interactable(
|
||||
span!(_guard, "select_interactable");
|
||||
use common::{spiral::Spiral2d, terrain::TerrainChunk, vol::RectRasterableVol};
|
||||
|
||||
let nearest_dist = find_shortest_distance(&mut [
|
||||
let nearest_dist = find_shortest_distance(&[
|
||||
mine_target.map(|t| t.distance),
|
||||
entity_target.map(|t| t.distance),
|
||||
collect_target.map(|t| t.distance),
|
||||
|
@ -426,12 +426,12 @@ impl PlayState for SessionState {
|
||||
drop(client);
|
||||
|
||||
// Nearest block to consider with GameInput primary or secondary key.
|
||||
let nearest_block_dist = find_shortest_distance(&mut [
|
||||
let nearest_block_dist = find_shortest_distance(&[
|
||||
mine_target.filter(|_| is_mining).map(|t| t.distance),
|
||||
build_target.filter(|_| can_build).map(|t| t.distance),
|
||||
]);
|
||||
// Nearest block to be highlighted in the scene (self.scene.set_select_pos).
|
||||
let nearest_scene_dist = find_shortest_distance(&mut [
|
||||
let nearest_scene_dist = find_shortest_distance(&[
|
||||
nearest_block_dist,
|
||||
collect_target.filter(|_| !is_mining).map(|t| t.distance),
|
||||
]);
|
||||
@ -513,7 +513,7 @@ impl PlayState for SessionState {
|
||||
client.handle_input(
|
||||
InputKind::Secondary,
|
||||
state,
|
||||
None,
|
||||
default_select_pos,
|
||||
self.target_entity,
|
||||
);
|
||||
}
|
||||
@ -1542,7 +1542,7 @@ impl PlayState for SessionState {
|
||||
fn egui_enabled(&self) -> bool { true }
|
||||
}
|
||||
|
||||
fn find_shortest_distance(arr: &mut [Option<f32>]) -> Option<f32> {
|
||||
fn find_shortest_distance(arr: &[Option<f32>]) -> Option<f32> {
|
||||
arr.iter()
|
||||
.filter_map(|x| *x)
|
||||
.min_by(|d1, d2| OrderedFloat(*d1).cmp(&OrderedFloat(*d2)))
|
||||
|
@ -103,7 +103,7 @@ pub(super) fn targets_under_cursor(
|
||||
let (mine_pos, _, mine_cam_ray) = is_mining
|
||||
.then(|| find_pos(|b: Block| b.mine_tool().is_some()))
|
||||
.unwrap_or((None, None, None));
|
||||
let (solid_pos, place_block_pos, solid_cam_ray) = find_pos(|b: Block| b.is_opaque());
|
||||
let (solid_pos, place_block_pos, solid_cam_ray) = find_pos(|b: Block| b.is_filled());
|
||||
|
||||
// See if ray hits entities
|
||||
// Don't cast through blocks, (hence why use shortest_cam_dist from non-entity
|
||||
|
Loading…
Reference in New Issue
Block a user