Fix inversion parameters being disregarded default tip
authorunC0Rr
Sun, 26 Jan 2025 21:29:54 +0100
changeset 16062 288df7b85efc
parent 16061 a73830f5c5cc
Fix inversion parameters being disregarded
rust/landgen/src/wavefront_collapse/generator.rs
rust/lib-hwengine-future/src/lib.rs
rust/mapgen/src/template/wavefront_collapse.rs
--- a/rust/landgen/src/wavefront_collapse/generator.rs	Sun Jan 26 20:51:38 2025 +0100
+++ b/rust/landgen/src/wavefront_collapse/generator.rs	Sun Jan 26 21:29:54 2025 +0100
@@ -56,6 +56,8 @@
     pub size: Size,
     pub tiles: Vec<TileDescription>,
     pub edges: NonStrictComplexEdgesDescription,
+    pub can_invert: bool,
+    pub is_negative: bool,
     pub wrap: bool,
 }
 
--- a/rust/lib-hwengine-future/src/lib.rs	Sun Jan 26 20:51:38 2025 +0100
+++ b/rust/lib-hwengine-future/src/lib.rs	Sun Jan 26 21:29:54 2025 +0100
@@ -108,11 +108,17 @@
     let mut map_gen = MapGenerator::<WfcTemplate>::new(data_path);
     map_gen.import_yaml_templates(&yaml_templates);
 
-    let params = LandGenerationParameters::new(0u16, 0x8000u16, feature_size, false, false);
     let template = map_gen
         .get_template(template_type, &mut random_numbers_gen)
         .expect("Error reading wfc templates file")
         .clone();
+    let (zero, basic) =
+        if template.is_negative || (template.can_invert && random_numbers_gen.get_random(2) == 0) {
+            (0x8000u16, 0u16)
+        } else {
+            (0u16, 0x8000u16)
+        };
+    let params = LandGenerationParameters::new(zero, basic, feature_size, false, false);
     let landgen = map_gen.build_generator(template);
     let collision = landgen.generate_land(&params, &mut random_numbers_gen);
     let size = collision.size().size();
--- a/rust/mapgen/src/template/wavefront_collapse.rs	Sun Jan 26 20:51:38 2025 +0100
+++ b/rust/mapgen/src/template/wavefront_collapse.rs	Sun Jan 26 21:29:54 2025 +0100
@@ -100,6 +100,8 @@
                 .map(|TileDescriptionHelper(t)| t.clone())
                 .collect(),
             wrap: desc.wrap,
+            can_invert: desc.can_invert,
+            is_negative: desc.is_negative,
             edges: NonStrictComplexEdgesDescription {
                 top,
                 right,