From 42d5836cfac3510911861c05ddaf027d86ac17f6 Mon Sep 17 00:00:00 2001 From: anomaluridae Date: Mon, 13 Sep 2021 18:56:13 -0700 Subject: [PATCH] properly use the target vs pickup range, in choosing the interactable. when finding the target_entity, use the proper limited dist range (cast_dist) with the proper upper bounds. --- common/src/consts.rs | 2 ++ voxygen/src/session/interactable.rs | 4 ++-- voxygen/src/session/target.rs | 6 ++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/common/src/consts.rs b/common/src/consts.rs index 48c0adfaac..8bd4bbe1fe 100644 --- a/common/src/consts.rs +++ b/common/src/consts.rs @@ -1,6 +1,8 @@ // The limit on distance between the entity and a collectible (squared) pub const MAX_PICKUP_RANGE: f32 = 5.0; pub const MAX_MOUNT_RANGE: f32 = 14.0; +/// Max distance an entity can be "targeted" +pub const MAX_TARGET_RANGE: f32 = 300.0; pub const GRAVITY: f32 = 25.0; pub const FRIC_GROUND: f32 = 0.15; diff --git a/voxygen/src/session/interactable.rs b/voxygen/src/session/interactable.rs index 9f8c9629fc..6a4cbc9303 100644 --- a/voxygen/src/session/interactable.rs +++ b/voxygen/src/session/interactable.rs @@ -6,7 +6,7 @@ use super::target::{self, Target}; use client::Client; use common::{ comp, - consts::MAX_PICKUP_RANGE, + consts::{MAX_PICKUP_RANGE, MAX_TARGET_RANGE}, terrain::Block, util::find_dist::{Cube, Cylinder, FindDist}, vol::ReadVol, @@ -62,7 +62,7 @@ pub(super) fn select_interactable( if let Some(interactable) = entity_target .and_then(|t| { - if t.distance < MAX_PICKUP_RANGE { + if t.distance < MAX_TARGET_RANGE { let entity = t.kind.0; Some(Interactable::Entity(entity)) } else { diff --git a/voxygen/src/session/target.rs b/voxygen/src/session/target.rs index 39e6ecba82..28ad6320d2 100644 --- a/voxygen/src/session/target.rs +++ b/voxygen/src/session/target.rs @@ -5,7 +5,7 @@ use vek::*; use client::{self, Client}; use common::{ comp, - consts::MAX_PICKUP_RANGE, + consts::{MAX_PICKUP_RANGE, MAX_TARGET_RANGE}, terrain::Block, util::find_dist::{Cylinder, FindDist}, vol::ReadVol, @@ -35,8 +35,6 @@ impl Target { pub fn position_int(self) -> Vec3 { self.position.map(|p| p.floor() as i32) } } -/// Max distance an entity can be "targeted" -const MAX_TARGET_RANGE: f32 = 300.0; /// Calculate what the cursor is pointing at within the 3d scene #[allow(clippy::type_complexity)] pub(super) fn targets_under_cursor( @@ -168,7 +166,7 @@ pub(super) fn targets_under_cursor( let seg_ray = LineSegment3 { start: cam_pos, - end: cam_pos + cam_dir * shortest_cam_dist, + end: cam_pos + cam_dir * cast_dist, }; // TODO: fuzzy borders let entity_target = nearby