Skip to content

A way of reusing GridMap instances? #3

@urgood2

Description

@urgood2

Hi.
I've been using this library for a private game project but noticed a slight issue (which may stem from my lack of familiarity with the library code).
I have multiple agents that need to use the same map to pathfind at various points in the game (not necessarily batched together, which prevents me from effectively utilizing multi-agent maps as provided by this library). I've noticed that reusing gridmap objects simply by changing the goalnode will not provide correct results, and realize that the gridmap should be created anew every time I need to pathfind.

Since agents need to pathfind very often, this is a rather inefficient way to do things and I was wondering if there could be a way to reset the gridmap node information without actually creating a new gridmap every time I need a new path found?

Here is the code I use to pathfind, if it's needed (pathfindingMap is a shared pointer to a JumpPointMap instance):

`

pathfindingMap->goal_ = fudge::Coord(endX, endY); // needed for jps to work
 
auto start = fudge::Coord(startX, startY);
    
const std::vector<fudge::Coord> path0 = fudge::astar_search(
        *pathfindingMap, start, fudge::Coord(endX, endY), 
        fudge::GridMap<double>::diagonal_distance);

`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions