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

Max looped chunk doesn't equal actual maximum chunk #1

Open
KleeSup opened this issue Jan 22, 2024 · 0 comments
Open

Max looped chunk doesn't equal actual maximum chunk #1

KleeSup opened this issue Jan 22, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@KleeSup
Copy link
Owner

KleeSup commented Jan 22, 2024

Doesn't take in a chunk that wasn't fully filled by the rectangle because the division does down-casting.
Therefore, this would be the right approach:

//in Helper class
public static int intDivCastUp(int a, float div){
  float result = a / div;
  return result % 1 != 0 ? (int)(result+1) : (int)(result)
}

float inv = 1f / chunkSize;
int chunksX = Helper.intDivCastUp(maxX, div);
int chunksY = Helper.intDivCastUp(maxY, div);
@KleeSup KleeSup added the bug Something isn't working label Jan 22, 2024
@KleeSup KleeSup self-assigned this Jan 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant