Skip to content

Commit 9a21648

Browse files
authored
Merge pull request #939 from louis-e/feature/elevation-terrain-improvements
Add multi-source elevation pipeline with terrain improvements
2 parents 00d02df + 8a906c9 commit 9a21648

29 files changed

Lines changed: 4987 additions & 1487 deletions

Cargo.lock

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ serde_json = "1.0"
5151
tauri = { version = "2", optional = true }
5252
tauri-plugin-log = { version = "2.6.0", optional = true }
5353
tauri-plugin-shell = { version = "2", optional = true }
54+
tiff = "0.11"
5455
tokio = { version = "1.48.0", features = ["full"], optional = true }
5556
bedrockrs_level = { git = "https://github.com/bedrock-crustaceans/bedrock-rs", rev = "7ef268b", package = "bedrockrs_level", optional = true }
5657
bedrockrs_shared = { git = "https://github.com/bedrock-crustaceans/bedrock-rs", rev = "7ef268b", package = "bedrockrs_shared", optional = true }

src/block_definitions.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,9 @@ impl Block {
239239
148 => "red_wall_banner",
240240
149 => "green_wall_banner",
241241
150 => "mossy_stone_bricks",
242+
151 => "deepslate",
243+
152 => "tuff",
244+
153 => "cobbled_deepslate",
242245
155 => "chest",
243246
156 => "red_carpet",
244247
157 => "anvil",
@@ -342,6 +345,8 @@ impl Block {
342345
255 => "light_gray_wall_banner",
343346
_ => panic!("Invalid id"),
344347
}
348+
// Note: If you want to add more blocks, please find unused ID
349+
// slots below 255 so we don't need to update to u16 or higher.
345350
}
346351

347352
pub fn properties(&self) -> Option<Value> {
@@ -896,6 +901,9 @@ pub const BLACK_WALL_BANNER: Block = Block::new(147);
896901
pub const RED_WALL_BANNER: Block = Block::new(148);
897902
pub const GREEN_WALL_BANNER: Block = Block::new(149);
898903
pub const MOSSY_STONE_BRICKS: Block = Block::new(150);
904+
pub const DEEPSLATE: Block = Block::new(151);
905+
pub const TUFF: Block = Block::new(152);
906+
pub const COBBLED_DEEPSLATE: Block = Block::new(153);
899907
pub const CHEST: Block = Block::new(155);
900908
pub const RED_CARPET: Block = Block::new(156);
901909
pub const ANVIL: Block = Block::new(157);

src/data_processing.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ pub fn generate_world_with_options(
9494
let progress_increment_prcs: f64 = 45.0 / elements_count as f64;
9595
let mut current_progress_prcs: f64 = 25.0;
9696
let mut last_emitted_progress: f64 = current_progress_prcs;
97+
let desired_updates: u64 = 500;
98+
let pb_batch_size: u64 = (elements_count as u64 / desired_updates).max(1);
99+
let mut element_counter: u64 = 0;
97100

98101
// Pre-scan: detect building relation outlines that should be suppressed.
99102
// Only applies to type=building relations (NOT type=multipolygon).
@@ -124,7 +127,10 @@ pub fn generate_world_with_options(
124127

125128
// Process all elements
126129
for element in elements.into_iter() {
127-
process_pb.inc(1);
130+
element_counter += 1;
131+
if element_counter.is_multiple_of(pb_batch_size) {
132+
process_pb.inc(pb_batch_size);
133+
}
128134
current_progress_prcs += progress_increment_prcs;
129135
if (current_progress_prcs - last_emitted_progress).abs() > 0.25 {
130136
emit_gui_progress_update(current_progress_prcs, "");
@@ -138,6 +144,11 @@ pub fn generate_world_with_options(
138144
element.kind()
139145
));
140146
} else {
147+
// Clear on every non-debug iteration so any transient warning
148+
// message set by downstream element processing (missing nodes,
149+
// etc.) doesn't stick for the rest of the run. The cost is
150+
// trivial — indicatif's set_message is just a mutex + string
151+
// compare (~20 ns), ~40 ms over a full world.
141152
process_pb.set_message("");
142153
}
143154

@@ -330,6 +341,7 @@ pub fn generate_world_with_options(
330341
// Element is dropped here, freeing its memory immediately
331342
}
332343

344+
process_pb.inc(element_counter % pb_batch_size);
333345
process_pb.finish();
334346

335347
// Drop remaining caches

0 commit comments

Comments
 (0)