How to set bits in a bitmask?
tl;dr: I have a byte as a bitmask, how do I performantly set a bit as 0 or 1?
Long story:
I have a big 2D array (6144x4096 in length) of 3D tiles (XPos, YPos, ZPos) and need to check neighbouring tiles and placing a specific water sprite depending on which neighbours are land or water. Which is a big pain in my butt, thinking of arrays or lists as something other than a simple list of individual numbers breaks my head.
Simplest approach I think is to use a bitmask and reference that in an enum. But the docs for doing stuff with bits is super arcane and designed for programmers who have been doing this since the 70's, not for hobbyist modders without brains wired for coding
Here's psuedocode from me breaking down the concept and what I'm working with, as a 2D array of vectors is too abstract to stay inside my head. Quite simple:
Get tile, check if it's super low
If it is then it's a water tile
check neighbouring tiles if they're higher
If they are, they're land
calculate which sides of the water tile border the land tiles.
Long story:
I have a big 2D array (6144x4096 in length) of 3D tiles (XPos, YPos, ZPos) and need to check neighbouring tiles and placing a specific water sprite depending on which neighbours are land or water. Which is a big pain in my butt, thinking of arrays or lists as something other than a simple list of individual numbers breaks my head.
Simplest approach I think is to use a bitmask and reference that in an enum. But the docs for doing stuff with bits is super arcane and designed for programmers who have been doing this since the 70's, not for hobbyist modders without brains wired for coding
Here's psuedocode from me breaking down the concept and what I'm working with, as a 2D array of vectors is too abstract to stay inside my head. Quite simple:
Get tile, check if it's super low
If it is then it's a water tile
check neighbouring tiles if they're higher
If they are, they're land
calculate which sides of the water tile border the land tiles.
