Skip to content
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

Improve map grid size handling, fix fullscreen map cutting off #35

Merged
merged 5 commits into from
Sep 10, 2024

Conversation

leumasme
Copy link
Contributor

@leumasme leumasme commented Sep 8, 2024

First commit makes the grid size dynamic instead of a constant 5x5. Fixes #34

Other 2 commits clean things up and make the grid able to be non-square, e.g. 5 tiles in width and 3 tiles in height.
This should reduce the amount of work done. when playing in fullscreen on a 1920x1080 screen, only 3x5=15 tiles are used instead of 5x5=25.
I have not benchmarked the actual impact of this as I'm not sure how to do this here.
These also create changes in public functions, which may count as a breaking (major version increase) change, depending on your versioning.
If these other things are unwanted, I can drop the commits.

All changes are tested ingame. Proper review and testing would still be appreciated as i find this codebase a bit confusing.

@CLAassistant
Copy link

CLAassistant commented Sep 8, 2024

CLA assistant check
All committers have signed the CLA.

@@ -74,14 +73,13 @@ public class GridRenderer
private FloatBuffer winPosBuf;
private FloatBuffer objPosBuf;

public GridRenderer(int gridSize)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leave the API as is, use wrappers to clamp the inputs to a new scheme.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The input will get overwritten anyway when the gridSize gets recalculated next (I think the caller has no useful purpose for passing a gridSize here).
I could leave a constructor that accepts a gridSize but just discards it to call the normal constructor for API compatability (As added initially, removed in second commit)
If that doesn't satisfy, I don't know what you mean; please clarify.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did mean to keep public API breakage to an absolute minimum. You never know, where it would be called, and you can't possibly fix every dependent code you don't control.

Copy link
Member

@mysticdrew mysticdrew Sep 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it works fine in gtnh pack it can be removed

Copy link
Contributor Author

@leumasme leumasme Sep 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Confirmed compatability with a recent GTNH nightly.
Also confirmed compatability with VisualProspecting overlays.
Compatability with TCNodeTracker overlays couldn't be tested because TCNodeTracker appears to be fully broken in nightly.

I can still restore api compatability if it's preferred (already have that stashed anyway), although methods such as public setGridSize would have to be empty dummy methods.

Copy link
Member

@mysticdrew mysticdrew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please update the doc/changelog.html
you can replace the current line item in there.

This is very similar, almost identical in places to the changes I did to fix this in 1.12.2, did you decompile that code to look? It's fine if you did, just curious.

Other than the change log update, looks great, thanks a lot.

@leumasme
Copy link
Contributor Author

did you decompile that code to look?

I did take a look at the recalculation logic, but I think that was the only sensible way to implement this anyway. Looks like later releases still use a square tile size though(?); I wonder what the performance impact of that is.
As a note, the formula for the required tile size was also slightly suboptimal in the version I looked at;
ceil(windowsize / tilesize) + 1 may calculate a number that's larger than required (e.g. 4 for 1080p -> 5 tiles to make it odd, even though only 3 are required)
ceil(windowsize / tilesize + 0.5) is more accurate to represent the possibility panning away from the center by up to half a tile, and correctly yields 3 for 1080p screen height, 512 tile size

@mysticdrew mysticdrew merged commit f4631f5 into TeamJM:master Sep 10, 2024
2 checks passed
@Lyfts Lyfts mentioned this pull request Sep 26, 2024
@mysticdrew
Copy link
Member

@leumasme see #36

@leumasme
Copy link
Contributor Author

Looks like minimap calculation is coming up with needing only 1x1 tiles? Maybe just let it be minimum 3x3, think that should fix it (not 100% sure). Alternatively change formula to be ceil(cells)+1 instead of ceil(cells+0.5), the exact thing I wrote about before... But that may result in some unnecessary work done on specific resolutions.
Sadly I'm not home for the next 4 days so I can't do it myself, sorry for the bug.

@mysticdrew
Copy link
Member

I am also going to be very busy until next week. Users can use the old version until a fix can be completed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sides of fullscreen map cut off on larger screens
4 participants