-
Notifications
You must be signed in to change notification settings - Fork 19
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
Easier heightmap access #104
Comments
My suggestion:
The reason for creating a decay map for each heightmap type (as opposed to both combined) is that if a heightmap is fetched and stored somewhere (e.g. by overwriting the local heightmap array), that heightmap type can reference the newest information independently. MemoryAs the max size of the map is typically 1024x1024, and the altitude is a value from range -64 to 320 (comfortably within the range of a numpy short), we can expect at most ~3 MiB per heightmap (numpy bool + short) if all values are saved for the full build area (~750 kiB for 512x512, ~200 kiB for 256x256, ~50 kiB for 128x128). Heightmap TypesMinecraft has four built-in heightmaps which might be of use.
In my opinion, WORLD_SURFACE and MOTION_BLOCKING are the only really useful and optimal heightmaps. Useful custom heightmaps might include:
Custom HeightmapsIn this system, it would also be possible to create custom heightmaps by providing an ignore set, although these heightmaps will always be local and cannot benefit from WorldSlices. If HTTP GDMC is also updated to permit custom heightmaps, this "ignore-list" approach would also fit in nicely. |
Putting valid heightmaps in an enum indeed makes sense (but not if we add custom heightmaps).
The heightmaps should not be global, but they could be members of
Do note that there's a difference between "a WorldSlice" and
Hmm, now that you've written out what it takes to keep a height cache up-to-date, I'm a bit concerned about the performance hit. It seems like a lot of steps for every block placement. If we implement it, I don't think it should be the default. Simply marking a height value as outdated is cheaper, but then the performance hit comes when the user requests that height value -- there's no easy to way to get a single height value from GDMC-HTTP. (Maybe this would be a good feature?)
I don't quite understand what you mean in this paragraph. Could you clarify it more? I would expect that we need separate decay maps if we only mark height values as "up-to-date"/"outdated", whereas we could do without decay maps if we fully update height values on every block placement (though see note above).
I don't think memory will be a concern. Heightmaps should only be loaded on an explicit request anyway, so the memory usage is in the user's hands.
Adding custom heightmaps is an interesting idea. A question is where the logic for them should go. I would prefer to keep If GDMC-HTTP implements custom heightmaps internally, this becomes easier: it should then certainly go in |
We can always treat built-in and custom heightmaps differently: Built-in gets invalidated, custom gets updated or invalidated based on preference.
Agreed entirely, that was bad phrasing on my part.
You're quite right, I'm being vague, mainly because I can't remember how exactly the WorldSlice and Editor.wordSlice work anymore. I think heightmap caching would be a good idea either way.
We can always store the current, outdated value and the last placed per column without updating the original value. That way, if the height is changed repeatedly without requesting the updated height, we can delay the calculation until the last moment possible. Even if we did have a way of requesting a single height via GDMC-HTTP, I feel like the response time would not be worth it for a single block.
I'm saying, I'd prefer having a decay map per heightmap type as opposed to a single decay map for any/all heightmaps in the editor. The reason for that preference is because it provides greater flexibility and allows only particular heightmaps to be invalidated, namely only those which are appropriately affected by that Block.
If you want Editor to be as minimal/slim as possible, I think you might have to rethink the Editor's architecture to be more modular.
I'd probably go for 1, unless you can think of an elegant interface for option 2. It doesn't look like GDMC-HTTP will do anything but allow for an ignore-list of blocks to emulate a custom heightmap, storing that information in the client sounds clumsy. |
There should be
Editor.getHeight
/Editor.getHeightGlobal
methods to get the height at a position, in the former case taking the transform into account.There should probably be caching functionality similar to
Editor.worldSlice
/Editor.worldSliceDecay
: a system to mark certain heights as "outdated" or update them in a cache (though updating may be costly for the more complex heightmaps). Furthermore, since GDMC HTTP now has aGET /heightmaps
endpoint (for a long time already...), it may be possible to avoid getting an entire WorldSlice in some cases.Some questions on how the height retrieval functions should work still need to be answered:
GET /heightmaps
call (every time)?getHeight
call. Should there be an explicit function for it? Should thegetHeight
function transparently request the heightmap if it wasn't loaded yet? In the last case, what range should it target?The text was updated successfully, but these errors were encountered: