@@ -338,7 +338,7 @@ namespace gf {
338338 continue ;
339339 }
340340
341- const float updated_distance = m_data (heap_data.position ).distance + cost_function (heap_data.position , position, cell, m_grid );
341+ const float updated_distance = m_data (heap_data.position ).distance + cost_function (heap_data.position , position);
342342
343343 if (updated_distance < m_data (position).distance ) {
344344 auto & data = m_data (position);
@@ -443,19 +443,7 @@ namespace gf {
443443 m_data (origin).distance = 0 .0f ;
444444 m_data (origin).state = AStarState::Open;
445445
446- // for (auto position : m_cells.position_range()) {
447- // const auto cell = m_cells(position);
448- //
449- // if (!cell.test(CellProperty::Walkable)) {
450- // continue;
451- // }
452- //
453- // AStarHeapData data = {};
454- // data.position = position;
455- // data.distance = m_data(position).distance;
456- //
457- // m_data(position).handle = m_heap.push(data);
458- // }
446+ m_heap.push ({ origin, 0 .0f });
459447 }
460448
461449 void compute_node (AStarHeapData heap_data, RouteCostFunction& cost_function, Flags<CellNeighborQuery> flags)
@@ -477,7 +465,7 @@ namespace gf {
477465 continue ;
478466 }
479467
480- const float updated_distance = m_data (heap_data.position ).distance + cost_function (heap_data.position , position, cell, m_grid );
468+ const float updated_distance = m_data (heap_data.position ).distance + cost_function (heap_data.position , position);
481469
482470 if (updated_distance < m_data (position).distance ) {
483471 auto & data = m_data (position);
@@ -550,14 +538,14 @@ namespace gf {
550538 flags |= CellNeighborQuery::Diagonal;
551539 }
552540
553- auto cost_function = [cost](Vec2I position, Vec2I neighbor, Flags<CellProperty> neighbor_properties, const AnyGrid& grid )
541+ auto cost_function = [cost, this ](Vec2I position, Vec2I neighbor)
554542 {
555- const bool is_diagonal = grid .are_diagonal_neighbors (position, neighbor);
543+ const bool is_diagonal = m_grid .are_diagonal_neighbors (position, neighbor);
556544 assert (cost.diagonal > 0 || !is_diagonal);
557545
558546 float neighbor_cost = is_diagonal ? cost.diagonal : cost.cardinal ;
559547
560- if (neighbor_properties .test (CellProperty::Blocked)) {
548+ if (m_cells (neighbor) .test (CellProperty::Blocked)) {
561549 neighbor_cost += cost.blocked ;
562550 }
563551
0 commit comments