rust/landgen/src/outline_template_based/outline.rs
changeset 16073 5d302b12d837
parent 16058 de01be16df95
equal deleted inserted replaced
16072:a4cbc6926439 16073:5d302b12d837
    25             polygons
    25             polygons
    26                 .iter()
    26                 .iter()
    27                 .map(|i| {
    27                 .map(|i| {
    28                     i.iter()
    28                     i.iter()
    29                         .map(|rect| {
    29                         .map(|rect| {
    30                             let (rnd_a, rnd_b) = random_numbers.gen();
    30                             let (rnd_a, rnd_b) = random_numbers.random();
    31                             play_box.top_left() + rect.quotient(rnd_a, rnd_b)
    31                             play_box.top_left() + rect.quotient(rnd_a, rnd_b)
    32                         })
    32                         })
    33                         .collect::<Vec<_>>()
    33                         .collect::<Vec<_>>()
    34                         .into()
    34                         .into()
    35                 })
    35                 })
   239         if dist_right + dist_left < min_distance as u32 * 2 + 10 {
   239         if dist_right + dist_left < min_distance as u32 * 2 + 10 {
   240             // limits are too narrow, just divide
   240             // limits are too narrow, just divide
   241             Some(mid_point)
   241             Some(mid_point)
   242         } else {
   242         } else {
   243             // select distance within [-dist_right; dist_left], keeping min_distance in mind
   243             // select distance within [-dist_right; dist_left], keeping min_distance in mind
   244             let d = random_numbers
   244             let d = random_numbers.random_range(
   245                 .gen_range(-(dist_right as i32) + min_distance..=dist_left as i32 - min_distance);
   245                 -(dist_right as i32) + min_distance..=dist_left as i32 - min_distance,
       
   246             );
   246 
   247 
   247             Some(mid_point + normal * d / normal_len as i32)
   248             Some(mid_point + normal * d / normal_len as i32)
   248         }
   249         }
   249     }
   250     }
   250 
   251