-
Notifications
You must be signed in to change notification settings - Fork 929
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
Fixed hex-space draw function to avoid overlaps #2609
base: main
Are you sure you want to change the base?
Fixed hex-space draw function to avoid overlaps #2609
Conversation
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
Thanks for this! I quickly scanned the code, and it made sense. I want to take a closer look, hopefully soon, to see if stuff can be simplified a bit. In the meantime, could you add a before and after of, say, a 20x20 grid next to what you already provided (which looks great, btw)? |
Thank you for your response! I’ve added grid images with a 10x10 layout (as the 20x20 grid didn’t look as clean in the screenshot) while keeping the same line-dot pattern for better clarity. |
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.
Again, thanks a lot for this PR. It's great to see how you solved the problem!
I have left a variety of suggestions for improving the code of this PR. If you have any questions, don't hesitate to ask.
for more information, see https://pre-commit.ci
…hhoker/mesa into fix-hex-tile-overlapping
There is still one issue unresolved regarding the alignment of hexes. Make the change shown below: loc[:, 0] = loc[:, 0] * x_spacing + ((loc[:, 1]-1) % 2) * (x_spacing / 2) |
@quaquel I don't know if you were able to see the review I started, in which I clearly attached images of your suggestion not working, so just to make sure I am attaching one image again, your suggestion offsets the placement of agents. I don't know if this is the intended behavior, if it is I shall change the code. |
I had missed that reply. Sorry. I'll try to take a closer look myself later this week. |
Finally had time to look at this again. My suggestion only changed the agent location, but the same correction evidently also needs to be made to the hex centers: so However, while figuring this out, I discovered 2 other bugs (which are also present in the current code).
This is most definitely not right and seems to be related to mixing up row and column indexing. I'll try to figure this out asap. |
…hhoker/mesa into fix-hex-tile-overlapping
for more information, see https://pre-commit.ci
I have added the reviewed changes, including the new empty |
Yes this issue predates your PR. See #2632 |
I suggest we first merge #2632 so I can fully visually check this PR. |
I have merged the bugfix and updated this PR by rebasing. |
Summary
This PR fixes the overlapping of hex-tiles.
Before:
After:
Grid
Before:
After:
Bug / Issue
fixes #2438
Implementation
The old code used
RegularPolygon
to gather hexagon shapes and assemble them usingPatchCollection
. In the new implementation, all six vertices are calculated using simple math and the origin coordinates, then combined at the end usingLineCollection
to avoid duplicate edges.No breaking changes have been made to the API.
Testing
Tested using building a custom model, found no errors.