fp: Improve the A* situation, but its not quite fixed yet
This commit is contained in:
parent
a8f5aa41a5
commit
1062e138d6
@ -481,7 +481,8 @@ static Dqn_Slice<Dqn_V2I> FP_Game_AStarPathFind(FP_Game *game,
|
||||
DQN_DEFER { Dqn_DSMap_Deinit(&astar_info); };
|
||||
|
||||
// NOTE: Enumerate the entities that are collidable ============================================
|
||||
auto zone_enum_collidables = Dqn_Profiler_BeginZoneWithIndex(DQN_STRING8("FP_Update: A* enumerate collidables"), FP_ProfileZone_FPUpdate_AStarEnumerateCollidables);
|
||||
bool dest_tile_is_non_traversable = false;
|
||||
auto zone_enum_collidables = Dqn_Profiler_BeginZoneWithIndex(DQN_STRING8("FP_Update: A* enumerate collidables"), FP_ProfileZone_FPUpdate_AStarEnumerateCollidables);
|
||||
for (FP_GameEntityIterator it = {}; FP_Game_DFSPreOrderWalkEntityTree(game, &it, game->root_entity); ) {
|
||||
FP_GameEntity const *walk_entity = it.entity;
|
||||
if (entity == walk_entity->handle)
|
||||
@ -502,6 +503,9 @@ static Dqn_Slice<Dqn_V2I> FP_Game_AStarPathFind(FP_Game *game,
|
||||
FP_GameAStarNode *node = Dqn_DSMap_MakeKeyU64(&astar_info, tile_u64).value;
|
||||
node->non_traversable = true;
|
||||
node->tile = Dqn_V2I_InitNx2(x, y);
|
||||
|
||||
if (node->tile == dest_tile)
|
||||
dest_tile_is_non_traversable = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -556,6 +560,16 @@ static Dqn_Slice<Dqn_V2I> FP_Game_AStarPathFind(FP_Game *game,
|
||||
Dqn_DSMapResult<FP_GameAStarNode> next_cost_result = Dqn_DSMap_MakeKeyU64(&astar_info, next_tile_u64);
|
||||
next_cost_result.value->tile = next_tile;
|
||||
|
||||
// NOTE: We got as close as possible, we know it's impossible to
|
||||
// reach, we will stop here.
|
||||
// TODO(doyle): Doesn't work in the general case, what if there's a
|
||||
// 2 consecutive blocks that are not traversable, we will never
|
||||
// realise that
|
||||
if (dest_tile == next_tile && dest_tile_is_non_traversable) {
|
||||
Dqn_FArray_Clear(&frontier);
|
||||
break;
|
||||
}
|
||||
|
||||
if (next_cost_result.value->non_traversable)
|
||||
continue;
|
||||
|
||||
@ -599,6 +613,7 @@ static Dqn_Slice<Dqn_V2I> FP_Game_AStarPathFind(FP_Game *game,
|
||||
}
|
||||
Dqn_Profiler_EndZone(zone_astar_expand);
|
||||
|
||||
#if 0
|
||||
TELY_Renderer *renderer = &platform->renderer;
|
||||
for (uint32_t old_index = 1 /*Sentinel*/; old_index < astar_info.occupied; old_index++) {
|
||||
Dqn_DSMapSlot<FP_GameAStarNode> const *slot = astar_info.slots + old_index;
|
||||
@ -606,6 +621,7 @@ static Dqn_Slice<Dqn_V2I> FP_Game_AStarPathFind(FP_Game *game,
|
||||
Dqn_V2 pos = FP_Game_TilePosToWorldPos(game, node->tile) + (game->tile_size * .5f);
|
||||
TELY_Render_CircleColourV4(renderer, pos, 4.f, TELY_RenderShapeMode_Fill, TELY_COLOUR_BLUE_CADET_V4);
|
||||
}
|
||||
#endif
|
||||
|
||||
Dqn_usize slice_size = 0;
|
||||
for (Dqn_V2I it = last_successful_tile; it != src_tile; slice_size++) {
|
||||
|
Loading…
Reference in New Issue
Block a user