-
Notifications
You must be signed in to change notification settings - Fork 91
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
Hexagon and HexagonGrid suggestions #511
Comments
@Zervox: Please create pull request instead. It is hard to see the actual changed code this way. PS: I agree about using array for neighbors. Need to study your pathing changes in more details later, because I don't want to break this function again and spent hours debugging much later :) |
sorry had to recreate fork as I had changed a vast majority of the files from another experiment. |
@Zervox why you closed this issue? Seems like good suggestion for HexagonGrid refactoring |
The performance of falltergeist is fairly bad, at 640x480 resolution I'm getting anywhere between 30-60 frames (mostly on the lower end), especially when I move the mouse around there's lots of stuttering. I went ahead and used perf record on linux and the function with the most overhead at 2.80% is Falltergeist::HexagonGrid::hexagonAt() The code for this function is, as of now:
So, Everytime we move the mouse pointer the engine iterates through the entire HexagonGrid of the map looking for the Hexagon under the pointer. Some ideas I had to improve this performance and remove the stuttering
Anyway I don't know if any of this is feasible and I haven't looked entirely into how the pathfinding system currently works. I'm just throwing ideas out there and I'm not the best programmer, I haven't written code in quite a while. I don't know where else to write this, there's no forum or any active places to discuss this engine |
Yes, in the engine a lot of things need to rewrite, remove unnecessary checking, such as |
I'd like to suggest to make Hexagon use std::array instead of vector(avoid dynamic creation of data) since neighbors is always 6.
Hexagon would be represented like this
std::array<Hexagon*,6> &neighbors();
in Hexagon::Hexagon() functions
HexagonGrid::HexagonGrid()
I also rewrote the the findPath as in this case dynamic data creation might actually be useful as double arrays of 200*200 which in almost all cases of the game you would still only get an array length of 15 at most.
The text was updated successfully, but these errors were encountered: