Skip to content

Commit

Permalink
path: Make distinction between cardinal/diagonal checks more clear.
Browse files Browse the repository at this point in the history
  • Loading branch information
heinezen committed Jul 19, 2024
1 parent 1718ec4 commit 711294f
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions libopenage/pathfinding/flow_field.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ void FlowField::build(const std::shared_ptr<IntegrationField> &integration_field
// Find the neighbor with the smallest cost.
flow_dir_t direction = static_cast<flow_dir_t>(flow_cell & FLOW_DIR_MASK);
auto smallest_cost = INTEGRATED_COST_UNREACHABLE;

// Cardinal directions
if (y > 0) {
auto cost = integrate_cells[idx - this->size].cost;
if (cost == INTEGRATED_COST_UNREACHABLE) {
Expand Down Expand Up @@ -135,6 +137,7 @@ void FlowField::build(const std::shared_ptr<IntegrationField> &integration_field
}
}

// Diagonal directions
if (x < this->size - 1 and y > 0
and not(directions_unreachable & 0x01 and directions_unreachable & 0x02)) {
auto cost = integrate_cells[idx - this->size + 1].cost;
Expand Down

0 comments on commit 711294f

Please sign in to comment.