-
-
Notifications
You must be signed in to change notification settings - Fork 21.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added ability to change A-star cost function #8146
Conversation
core/math/a_star.cpp
Outdated
|
||
float AStar::_compute_cost(int p_from_id, int p_to_id) { | ||
if (get_script_instance()) | ||
return get_script_instance()->call("_compute_cost", p_from_id, p_to_id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if there is no GDScript implementation of _compute_cost
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be done somewhat as here, I guess:
Line 574 in 73eaf81
if (get_script_instance()) { |
(Note the use of SceneStringName too, it would make it an idea faster..)
You have indentation issues, it doesn't pass our clang-format style check: https://travis-ci.org/godotengine/godot/jobs/214933818 |
what are the godot tab settings? I noticed this with my other PR also. |
One tab for indent, as you can see in all source files ;) |
Fixed tabbing and checking for existence of methods before calling. |
Now you have to fix clang-format issues (check the travis build for details) |
would someone help me work out what this job log is trying to tell me? |
@supagu it is in git patch format. Going through it reveals that you have some trailing spaces/tabs here and there around you code, which you should remove. |
oh is the - at the start of the line the current line as it is, where the + is what it things it should be changed to? |
@supagu Yeah, exactly, thats the idea (-) is remove, (+) is add, when combined it becomes "change". |
@supagu, would you also be interested in adding some documentation to AStar overall in doc/base/classes.xml? Currently, the documentation for AStar as a whole is mostly lacking. |
@tagcup I think this should be left for another PR, since the classes.xml is currently in a sad state. |
OK, but I think at least _estimate_cost and _compute_test should be added (which the functions introduced in this PR), even without description. |
They are added automatically by |
@akien-mga Fair enough, although I still think adding a few words what _estimate_cost and _compute_cost exactly are would be nice. (even a brief code comment would be clarifying) |
Now documentation can be added, clang-format seems to still be unhappy with some trailing spaces btw: https://travis-ci.org/godotengine/godot/jobs/215899027 (not easily visible on the logs, but if you select the lines starting with |
all passing, finally! was there anything else I needed to do? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, thought it would be nice if someone else checks it as well...
Could this be merged into the 2.1 branch as well ? |
Cherry-picked as 1a1e25b. |
Added _estimate_cost and _compute_cost to allow for both C++ and gdscript inheritance to customize the A-star cost function.
See discussion here for further information:
#7932