mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 08:44:50 +00:00
Add a Caves view to the studio
The carve module registers a scene view that lists every file of the pack's caves/ folder and draws each one carved over 128 by 128 blocks under a flat surface at Y 96, with the seed generation uses. Carved space is drawn as blocks, tunnels light blue and caverns orange, so the shape of the cave shows instead of the rock around it. Four variants show the same cave in four places. Each file opens as Cave, Tunnel, Cavern and Pillars nodes, and new caves can be created from the view. BlockParts copied its map with Map.copyOf, whose open addressing takes quadratic time on the colliding hash codes of a dense block grid; one cave scene took 538 seconds. It now copies into a HashMap. A studio that connected after the bridge's first poll got no world event of its own, took the first hotload for its starting state and did not redraw. Each joining studio is now sent the world state on its own.
This commit is contained in:
1 parent
7d166df70f
commit
e862a80615
12 files changed
+638
-24
No files matched your search
@@ -2,6 +2,8 @@ package com.volmit.tooling;
|
||||
|
||||
import com.volmit.geometry.BlockPosition;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -18,8 +20,12 @@ public record BlockParts(Map<BlockPosition, Integer> partsByBlock) {
|
||||
|
||||
public BlockParts {
|
||||
Objects.requireNonNull(partsByBlock, "partsByBlock");
|
||||
partsByBlock = Map.copyOf(partsByBlock);
|
||||
// Not Map.copyOf: positions of a dense scene share hash codes, which its open addressing handles in quadratic
|
||||
// time (a million blocks take minutes), while a HashMap falls back to a tree for keys that collide.
|
||||
partsByBlock = Collections.unmodifiableMap(new HashMap<>(partsByBlock));
|
||||
partsByBlock.forEach((position, part) -> {
|
||||
Objects.requireNonNull(position, "position");
|
||||
Objects.requireNonNull(part, "part");
|
||||
if (part < 0) {
|
||||
throw new IllegalArgumentException("Block " + position + " is in part " + part + "; parts are numbered from 0");
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user