mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
build positions for place versus remove block are cleaner (less likely to fail) when apply the +0.01 modifier versus -0.01 modifier selectively. this is equivalent to current master, and is simply more explicit now
This commit is contained in:
parent
f60bd80cc2
commit
c20dbe17dd
@ -494,9 +494,10 @@ impl PlayState for SessionState {
|
|||||||
if let Some(build_target) = build_target.filter(|bt| {
|
if let Some(build_target) = build_target.filter(|bt| {
|
||||||
state && can_build && is_nearest_target(shortest_dist, *bt)
|
state && can_build && is_nearest_target(shortest_dist, *bt)
|
||||||
}) {
|
}) {
|
||||||
self.inputs.select_pos = Some(build_target.position);
|
let selected_pos = build_target.kind.0;
|
||||||
|
self.inputs.select_pos = Some(selected_pos);
|
||||||
client.place_block(
|
client.place_block(
|
||||||
build_target.position_int(),
|
selected_pos.map(|p| p.floor() as i32),
|
||||||
self.selected_block,
|
self.selected_block,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
@ -20,7 +20,7 @@ pub struct Target<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
pub struct Build;
|
pub struct Build(pub Vec3<f32>);
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
pub struct Collectable;
|
pub struct Collectable;
|
||||||
@ -99,7 +99,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, 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_solid());
|
||||||
|
|
||||||
// Find shortest cam_dist of non-entity targets.
|
// Find shortest cam_dist of non-entity targets.
|
||||||
// Note that some of these targets can technically be in Air, such as the
|
// Note that some of these targets can technically be in Air, such as the
|
||||||
@ -196,11 +196,13 @@ pub(super) fn targets_under_cursor(
|
|||||||
});
|
});
|
||||||
|
|
||||||
let build_target = if can_build {
|
let build_target = if can_build {
|
||||||
solid_pos.zip(solid_cam_ray).map(|(position, ray)| Target {
|
place_block_pos
|
||||||
kind: Build,
|
.zip(solid_pos.zip(solid_cam_ray))
|
||||||
distance: ray.0,
|
.map(|(place_pos, (position, ray))| Target {
|
||||||
position,
|
kind: Build(place_pos),
|
||||||
})
|
distance: ray.0,
|
||||||
|
position,
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user