rust/landgen/src/outline_template_based/template_based.rs
branchtransitional_engine
changeset 16058 9cbd18220eb7
parent 15952 da6b67f13c12
child 16064 0caa3dfb3ba2
equal deleted inserted replaced
16057:509ecce37522 16058:9cbd18220eb7
    16     fn generate_land<T: Copy + PartialEq + Default, I: Iterator<Item = u32>>(
    16     fn generate_land<T: Copy + PartialEq + Default, I: Iterator<Item = u32>>(
    17         &self,
    17         &self,
    18         parameters: &LandGenerationParameters<T>,
    18         parameters: &LandGenerationParameters<T>,
    19         random_numbers: &mut I,
    19         random_numbers: &mut I,
    20     ) -> Land2D<T> {
    20     ) -> Land2D<T> {
    21         let mut land = Land2D::new(&self.outline_template.size, parameters.basic);
    21         let do_invert = self.outline_template.is_negative
       
    22             && (!self.outline_template.can_invert || random_numbers.next().unwrap() & 1 == 0);
       
    23         let (basic, zero) = if do_invert {
       
    24             (parameters.zero, parameters.basic)
       
    25         } else {
       
    26             (parameters.basic, parameters.zero)
       
    27         };
       
    28 
       
    29         let mut land = Land2D::new(&self.outline_template.size, basic);
    22 
    30 
    23         let mut points = OutlinePoints::from_outline_template(
    31         let mut points = OutlinePoints::from_outline_template(
    24             &self.outline_template,
    32             &self.outline_template,
    25             land.play_box(),
    33             land.play_box(),
    26             land.size().size(),
    34             land.size().size(),
    51 
    59 
    52         if !parameters.skip_bezier {
    60         if !parameters.skip_bezier {
    53             points.bezierize(5);
    61             points.bezierize(5);
    54         }
    62         }
    55 
    63 
    56         points.draw(&mut land, parameters.zero);
    64         points.draw(&mut land, zero);
    57 
    65 
    58         for p in &points.fill_points {
    66         for p in &points.fill_points {
    59             land.fill(*p, parameters.zero, parameters.zero)
    67             land.fill(*p, zero, zero)
    60         }
    68         }
    61 
    69 
    62         points.draw(&mut land, parameters.basic);
    70         points.draw(&mut land, basic);
    63 
    71 
    64         land
    72         land
    65     }
    73     }
    66 }
    74 }