make scene interaction be targeted exactly on mining blocks (removing abnormal Empty labels), and don't reset position to None in the middle of mining.

This commit is contained in:
anomaluridae 2021-08-09 16:48:49 -07:00
parent ff91da8b52
commit f20b5f0b49
2 changed files with 3 additions and 6 deletions

View File

@ -436,15 +436,12 @@ impl PlayState for SessionState {
build_target.map(|bt| self.scene.set_select_pos(Some(bt.position_int())));
} else {
self.scene.set_select_pos(None);
self.inputs.select_pos = entity_target.map(|et| et.position());
}
// Throw out distance info, it will be useful in the future
self.target_entity = entity_target.and_then(Target::entity);
// controller only wants 1 target
// set default using entity_target as the selected_pos, and update per event
self.inputs.select_pos = entity_target.map(|et| et.position());
macro_rules! entity_event_handler {
($input: expr, $pressed: expr) => {
let mut client = self.client.borrow_mut();

View File

@ -106,7 +106,7 @@ pub(super) fn targets_under_cursor(
Ok(Some(_)) if player_cylinder.min_distance(*cam_pos + *cam_dir * (cam_dist + 0.01)) <= MAX_PICKUP_RANGE
) {
(
Some(*cam_pos + *cam_dir * (cam_dist + 0.01)),
Some(*cam_pos + *cam_dir * cam_dist),
Some(*cam_pos + *cam_dir * (cam_dist - 0.01)),
cam_ray
)
@ -129,7 +129,7 @@ pub(super) fn targets_under_cursor(
(d, Ok(Some(_))) => Some(d),
_ => None,
}).min_by(|d1, d2| d1.partial_cmp(d2).unwrap())
.unwrap_or(MAX_TARGET_RANGE);
.unwrap_or(MAX_PICKUP_RANGE);
// See if ray hits entities
// Currently treated as spheres