rust/landgen/src/outline_template_based/template_based.rs
branchtransitional_engine
changeset 16058 9cbd18220eb7
parent 15952 da6b67f13c12
child 16064 0caa3dfb3ba2
--- a/rust/landgen/src/outline_template_based/template_based.rs	Tue Sep 03 11:16:52 2024 +0200
+++ b/rust/landgen/src/outline_template_based/template_based.rs	Tue Sep 03 13:56:35 2024 +0200
@@ -18,7 +18,15 @@
         parameters: &LandGenerationParameters<T>,
         random_numbers: &mut I,
     ) -> Land2D<T> {
-        let mut land = Land2D::new(&self.outline_template.size, parameters.basic);
+        let do_invert = self.outline_template.is_negative
+            && (!self.outline_template.can_invert || random_numbers.next().unwrap() & 1 == 0);
+        let (basic, zero) = if do_invert {
+            (parameters.zero, parameters.basic)
+        } else {
+            (parameters.basic, parameters.zero)
+        };
+
+        let mut land = Land2D::new(&self.outline_template.size, basic);
 
         let mut points = OutlinePoints::from_outline_template(
             &self.outline_template,
@@ -53,13 +61,13 @@
             points.bezierize(5);
         }
 
-        points.draw(&mut land, parameters.zero);
+        points.draw(&mut land, zero);
 
         for p in &points.fill_points {
-            land.fill(*p, parameters.zero, parameters.zero)
+            land.fill(*p, zero, zero)
         }
 
-        points.draw(&mut land, parameters.basic);
+        points.draw(&mut land, basic);
 
         land
     }