is_solid() detects both solid rock and sprites (e.g. mineable ore). when in build mode, would like to be able to still mine if user cursor is over a mineable ore. so need to properly cast the build ray to use opaque (not fillable) blocks to get the proper position, vs the mineable block which may be nearer

This commit is contained in:
anomaluridae 2021-09-14 23:40:49 -07:00
parent aa86c86cb6
commit 82f3c3c3e8
2 changed files with 2 additions and 1 deletions

View File

@ -217,6 +217,7 @@ impl Block {
} }
} }
// Filled blocks or sprites
#[inline] #[inline]
pub fn is_solid(&self) -> bool { pub fn is_solid(&self) -> bool {
self.get_sprite() self.get_sprite()

View File

@ -103,7 +103,7 @@ pub(super) fn targets_under_cursor(
let (mine_pos, _, mine_cam_ray) = is_mining let (mine_pos, _, mine_cam_ray) = is_mining
.then(|| find_pos(|b: Block| b.mine_tool().is_some())) .then(|| find_pos(|b: Block| b.mine_tool().is_some()))
.unwrap_or((None, None, None)); .unwrap_or((None, None, None));
let (solid_pos, place_block_pos, solid_cam_ray) = find_pos(|b: Block| b.is_solid()); let (solid_pos, place_block_pos, solid_cam_ray) = find_pos(|b: Block| b.is_opaque());
// See if ray hits entities // See if ray hits entities
// Don't cast through blocks, (hence why use shortest_cam_dist from non-entity // Don't cast through blocks, (hence why use shortest_cam_dist from non-entity