rust/landgen/src/wavefront_collapse/tile_image.rs
branchtransitional_engine
changeset 15954 9502611bffc1
parent 15951 5f00829c55ec
equal deleted inserted replaced
15953:d46ad15c6dec 15954:9502611bffc1
     9     symmetrical: bool,
     9     symmetrical: bool,
    10     reverse: bool,
    10     reverse: bool,
    11 }
    11 }
    12 
    12 
    13 impl<I: PartialEq + Clone> Edge<I> {
    13 impl<I: PartialEq + Clone> Edge<I> {
       
    14     #[inline]
    14     pub fn new(id: I, symmetrical: bool) -> Self {
    15     pub fn new(id: I, symmetrical: bool) -> Self {
    15         Self {
    16         Self {
    16             id,
    17             id,
    17             symmetrical,
    18             symmetrical,
    18             reverse: false,
    19             reverse: false,
    19         }
    20         }
    20     }
    21     }
    21 
    22 
       
    23     #[inline]
    22     pub fn reversed(&self) -> Self {
    24     pub fn reversed(&self) -> Self {
    23         Self {
    25         Self {
    24             id: self.id.clone(),
    26             id: self.id.clone(),
    25             symmetrical: self.symmetrical,
    27             symmetrical: self.symmetrical,
    26             reverse: !self.symmetrical && !self.reverse,
    28             reverse: !self.symmetrical && !self.reverse,
    27         }
    29         }
    28     }
    30     }
    29 
    31 
       
    32     #[inline]
    30     pub fn is_compatible(&self, other: &Self) -> bool {
    33     pub fn is_compatible(&self, other: &Self) -> bool {
    31         self.id == other.id && ((self.reverse != other.reverse) || self.symmetrical)
    34         self.id == other.id && ((self.reverse != other.reverse) || self.symmetrical)
    32     }
    35     }
    33 }
    36 }
    34 
    37 
   113             bottom: self.left.clone(),
   116             bottom: self.left.clone(),
   114             left: self.top.clone(),
   117             left: self.top.clone(),
   115         }
   118         }
   116     }
   119     }
   117 
   120 
       
   121     #[inline]
   118     pub fn right_edge(&self) -> &Edge<I> {
   122     pub fn right_edge(&self) -> &Edge<I> {
   119         &self.right
   123         &self.right
   120     }
   124     }
   121 
   125 
       
   126     #[inline]
   122     pub fn bottom_edge(&self) -> &Edge<I> {
   127     pub fn bottom_edge(&self) -> &Edge<I> {
   123         &self.bottom
   128         &self.bottom
   124     }
   129     }
   125 
   130 
       
   131     #[inline]
   126     pub fn left_edge(&self) -> &Edge<I> {
   132     pub fn left_edge(&self) -> &Edge<I> {
   127         &self.left
   133         &self.left
   128     }
   134     }
   129 
   135 
       
   136     #[inline]
   130     pub fn top_edge(&self) -> &Edge<I> {
   137     pub fn top_edge(&self) -> &Edge<I> {
   131         &self.top
   138         &self.top
   132     }
   139     }
   133 
   140 
       
   141     #[inline]
   134     pub fn size(&self) -> Size {
   142     pub fn size(&self) -> Size {
   135         match self.transform {
   143         match self.transform {
   136             Transform::Rotate0(_) => self.image.size(),
   144             Transform::Rotate0(_) => self.image.size(),
   137             Transform::Rotate90(_) => Size::new(self.image.size().height, self.image.size().width),
   145             Transform::Rotate90(_) => Size::new(self.image.size().height, self.image.size().width),
   138         }
   146         }
   139     }
   147     }
   140 
   148 
       
   149     #[inline]
   141     pub fn get(&self, row: usize, column: usize) -> Option<&T> {
   150     pub fn get(&self, row: usize, column: usize) -> Option<&T> {
   142         match self.transform {
   151         match self.transform {
   143             Transform::Rotate0(_) => {
   152             Transform::Rotate0(_) => {
   144                 let image_row = if self.transform.is_flipped() {
   153                 let image_row = if self.transform.is_flipped() {
   145                     self.image.height().wrapping_sub(1).wrapping_sub(row)
   154                     self.image.height().wrapping_sub(1).wrapping_sub(row)