aboutsummaryrefslogtreecommitdiff
path: root/azalea/src/pathfinder/moves/basic.rs
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2026-01-15 09:18:28 -0900
committermat <git@matdoes.dev>2026-01-16 04:14:36 +0930
commit914f881dd834aef67755f2e0fd4989253fc9f794 (patch)
tree0075816dff58f5458e48d56bd1874cc8c67114fa /azalea/src/pathfinder/moves/basic.rs
parent9c8cf7adea6da1c76d96f447b71345f63146be10 (diff)
downloadazalea-drasl-914f881dd834aef67755f2e0fd4989253fc9f794.tar.xz
minor pathfinder optimizations and api+doc improvements
Diffstat (limited to 'azalea/src/pathfinder/moves/basic.rs')
-rw-r--r--azalea/src/pathfinder/moves/basic.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/azalea/src/pathfinder/moves/basic.rs b/azalea/src/pathfinder/moves/basic.rs
index 2814641c..b0df32e4 100644
--- a/azalea/src/pathfinder/moves/basic.rs
+++ b/azalea/src/pathfinder/moves/basic.rs
@@ -94,6 +94,9 @@ fn ascend_move(ctx: &mut PathfinderCtx, pos: RelBlockPos) {
return;
}
+ let base_cost =
+ f32::max(WALK_ONE_BLOCK_COST, *JUMP_ONE_BLOCK_COST) + JUMP_PENALTY + break_cost_1;
+
for dir in CardinalDirection::iter() {
if let Some(stair_facing) = stair_facing {
let expected_stair_facing = cardinal_direction_to_facing_property(dir);
@@ -109,10 +112,7 @@ fn ascend_move(ctx: &mut PathfinderCtx, pos: RelBlockPos) {
continue;
}
- let cost = f32::max(WALK_ONE_BLOCK_COST, *JUMP_ONE_BLOCK_COST)
- + JUMP_PENALTY
- + break_cost_1
- + break_cost_2;
+ let cost = base_cost + break_cost_2;
ctx.edges.push(Edge {
movement: astar::Movement {
@@ -271,8 +271,8 @@ fn descend_move(ctx: &mut PathfinderCtx, pos: RelBlockPos) {
FALL_N_BLOCKS_COST
.get(fall_distance as usize)
.copied()
- // avoid panicking if we fall more than the size of FALL_N_BLOCKS_COST
- // probably not possible but just in case
+ // this isn't possible because we already checked bounds on the fall distance,
+ // but it might be faster to default?
.unwrap_or(f32::INFINITY),
CENTER_AFTER_FALL_COST,
)