Make outline template generator behave more like old engine transitional_engine
authorunC0Rr
Tue, 03 Sep 2024 11:16:52 +0200
branchtransitional_engine
changeset 16028 509ecce37522
parent 16027 d4675c190fa5
child 16029 9cbd18220eb7
Make outline template generator behave more like old engine
rust/landgen/src/outline_template_based/outline.rs
--- a/rust/landgen/src/outline_template_based/outline.rs	Tue Sep 03 11:16:16 2024 +0200
+++ b/rust/landgen/src/outline_template_based/outline.rs	Tue Sep 03 11:16:52 2024 +0200
@@ -65,6 +65,7 @@
         &self,
         segment: Line,
         distance_divisor: u32,
+        distance_limiting_factor: u32,
         random_numbers: &mut I,
     ) -> Option<Point> {
         #[inline]
@@ -117,7 +118,7 @@
             }
         }
 
-        let min_distance = 40;
+        let min_distance = distance_divisor as i32;
         // new point should fall inside this box
         let map_box = self.play_box.with_margin(min_distance);
 
@@ -225,7 +226,7 @@
             }
         }
 
-        let max_dist = normal_len * 100 / distance_divisor;
+        let max_dist = normal_len * 128 / distance_limiting_factor;
         dist_left = min(dist_left, max_dist);
         dist_right = min(dist_right, max_dist);
 
@@ -246,13 +247,14 @@
     fn divide_edges<I: Iterator<Item = u32>>(
         &mut self,
         distance_divisor: u32,
+        distance_limiting_factor: u32,
         random_numbers: &mut I,
     ) {
         for is in 0..self.islands.len() {
             let mut i = 0;
             while i < self.islands[is].edges_count() {
                 let segment = self.islands[is].get_edge(i);
-                if let Some(new_point) = self.divide_edge(segment, distance_divisor, random_numbers)
+                if let Some(new_point) = self.divide_edge(segment, distance_divisor, distance_limiting_factor, random_numbers)
                 {
                     self.islands[is].split_edge(i, new_point);
                     i += 2;
@@ -274,9 +276,11 @@
         distance_divisor: u32,
         random_numbers: &mut I,
     ) {
+        let distance_limiting_factor = 100 + random_numbers.next().unwrap() as u32 % 8 * 10;
+
         loop {
             let old_len = self.total_len();
-            self.divide_edges(distance_divisor, random_numbers);
+            self.divide_edges(distance_divisor, distance_limiting_factor, random_numbers);
 
             if self.total_len() == old_len {
                 break;