Closed niemandkun closed 2 years ago
Any update on this @maintainers?
Thank you @niemandkun! While waiting for an official build, I created a local subclass of IndexedAStarPathFinder based on your code and it works like a charm.
I like this solution; it allows keeping the current behavior for users who want that, and switching to .equals()
as in #96 for users who want that. Just as importantly, it allows arbitrary custom behavior, which seems to be needed very often in game development. With the inlining that HotSpot performs, I would suspect the overhead for the method call is low, and if inlined to just a == b
, it would probably be faster than a call to a.equals(b)
each time. Probably not a terribly significant amount of overhead, anyway. I'll merge this and run benchmarks; in the unlikely case that it has a severe performance penalty, I could roll back, but I feel like there should really be some solution to the node equality problem.
Related to issues https://github.com/libgdx/gdx-ai/issues/67 and https://github.com/libgdx/gdx-ai/issues/99 (pathfinding uses identity to determine when destination reached).
This PR replaces identity check during indexed A* search with
StopCondition
. With this interface users will be able to define custom criteria to interrupt the search.There is already a PR opened on these issues (https://github.com/libgdx/gdx-ai/pull/96), but solution introduced in my PR is more general and maintains backward compatibility: simple replacing
==
with.equals
may break some projects, where difference between two checks is crucial for correct work.