Skip to content

Commit

Permalink
Merge pull request #95 from louis-e/floodfill-settings
Browse files Browse the repository at this point in the history
Add floodfill timeout support
  • Loading branch information
louis-e authored Dec 28, 2024
2 parents 46cf1bc + ae3a919 commit 7401036
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 16 deletions.
15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,18 @@ The project is named after the smallest city in Germany, Arnis[^2]. The city's s

## :memo: ToDo and Known Bugs
Feel free to choose an item from the To-Do or Known Bugs list, or bring your own idea to the table. Bug reports shall be raised as a Github issue. Contributions are highly welcome and appreciated!
- [ ] Memory optimization
- [ ] Mapping real coordinates to Minecraft coordinates (https://github.com/louis-e/arnis/issues/29)
- [ ] Evaluate and implement elevation (https://github.com/louis-e/arnis/issues/66)
- [ ] Fix Github Action Workflow for releasing Linux & MacOS Binary
- [ ] Evaluate and implement multithreaded region saving
- [ ] Better code documentation
- [ ] Evaluate and implement faster region saving
- [ ] Automatic new world creation instead of using an existing world
- [ ] Implement house roof types
- [ ] Refactor railway implementation
- [ ] Refactor bridges implementation
- [ ] Refactor railway implementation
- [ ] Better code documentation
- [ ] Refactor fountain structure implementation
- [ ] Automatic new world creation instead of using an existing world
- [ ] Tool for mapping real coordinates to Minecraft coordinates
- [ ] Add interior to buildings
- [ ] Evaluate and implement elevation
- [ ] Implement memory mapped storing of chunks to reduce memory usage
- [x] Memory optimization
- [x] Design and implement a GUI
- [x] Fix faulty empty chunks ([https://github.com/owengage/fastnbt/issues/120](https://github.com/owengage/fastnbt/issues/120)) (workaround found)
- [x] Setup fork of [https://github.com/aaronr/bboxfinder.com](https://github.com/aaronr/bboxfinder.com) for easy bbox picking
Expand Down
4 changes: 2 additions & 2 deletions gui-src/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -309,15 +309,15 @@ button:hover {
#bbox-coords {
width: 100%;
padding: 8px;
border: 1px solid #ccc;
border: 1px solid #fecc44;
border-radius: 4px;
font-size: 14px;
}

#bbox-coords:focus {
outline: none;
border-color: #fecc44;
box-shadow: 0 0 5px rgba(0, 123, 255, 0.5);
box-shadow: 0 0 5px #fecc44;
}


Expand Down
6 changes: 6 additions & 0 deletions gui-src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ <h2>Customization Settings</h2>
<label for="bbox-coords">Custom Bounding Box:</label>
<input type="text" id="bbox-coords" name="bbox-coords" maxlength="55" style="width: 280px;" autocomplete="one-time-code" placeholder="Format: lat,lng,lat,lng">
</div>

<!-- Floodfill Timeout Input -->
<div class="timeout-input-container">
<label for="floodfill-timeout">Floodfill Timeout (sec):</label>
<input type="number" id="floodfill-timeout" name="floodfill-timeout" min="0" step="1" value="20" style="width: 100px;" placeholder="Seconds">
</div>
</div>
</div>

Expand Down
6 changes: 5 additions & 1 deletion gui-src/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,13 @@ async function startGeneration() {

var winter_mode = document.getElementById("winter-toggle").checked;
var scale = parseFloat(document.getElementById("scale-value-slider").value);
var floodfill_timeout = parseInt(document.getElementById("floodfill-timeout").value, 10);

// Validate the floodfill timeout
floodfill_timeout = isNaN(floodfill_timeout) || floodfill_timeout < 0 ? 20 : floodfill_timeout;

// Pass the bounding box and selected world to the Rust backend
await invoke("gui_start_generation", { bboxText: selectedBBox, selectedWorld: worldPath, worldScale: scale, winterMode: winter_mode });
await invoke("gui_start_generation", { bboxText: selectedBBox, selectedWorld: worldPath, worldScale: scale, winterMode: winter_mode, floodfillTimeout: floodfill_timeout });

console.log("Generation process started.");
generationButtonEnabled = false;
Expand Down
2 changes: 1 addition & 1 deletion src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub struct Args {
#[arg(long, default_value_t = false, action = clap::ArgAction::SetTrue)]
pub debug: bool,

/// Set floodfill timeout (seconds) (optional) // TODO
/// Set floodfill timeout (seconds) (optional)
#[arg(long, value_parser = parse_duration)]
pub timeout: Option<Duration>,
}
Expand Down
2 changes: 1 addition & 1 deletion src/element_processing/highways.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ pub fn generate_highways(
let mut previous_node: Option<(i32, i32)> = None;
let mut block_type = BLACK_CONCRETE;
let mut block_range: i32 = 2;
let mut add_stripe = false; // Flag for adding stripes
let mut add_stripe = false;

// Skip if 'layer' or 'level' is negative in the tags
if let Some(layer) = element.tags().get("layer") {
Expand Down
4 changes: 2 additions & 2 deletions src/floodfill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub fn flood_fill_area(
while let Some((start_x, start_z)) = candidate_points.pop_front() {
if let Some(timeout) = timeout {
if &start_time.elapsed() > timeout {
eprintln!("Floodfill timeout"); // TODO only print when debug arg is set?
eprintln!("Floodfill timeout");
break;
}
}
Expand All @@ -70,7 +70,7 @@ pub fn flood_fill_area(
while let Some((x, z)) = queue.pop_front() {
if let Some(timeout) = timeout {
if &start_time.elapsed() > timeout {
eprintln!("Floodfill timeout"); // TODO only print when debug arg is set?
eprintln!("Floodfill timeout");
break;
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ fn gui_start_generation(
selected_world: String,
world_scale: f64,
winter_mode: bool,
floodfill_timeout: u64,
) -> Result<(), String> {
tauri::async_runtime::spawn(async move {
if let Err(e) = tokio::task::spawn_blocking(move || {
Expand Down Expand Up @@ -240,7 +241,7 @@ fn gui_start_generation(
scale: world_scale,
winter: winter_mode,
debug: false,
timeout: None,
timeout: Some(std::time::Duration::from_secs(floodfill_timeout)),
};

// Reorder bounding box coordinates for further processing
Expand Down

0 comments on commit 7401036

Please sign in to comment.