rust/landgen/src/wavefront_collapse/tile_image.rs
changeset 16080 2fc37552b587
parent 16079 65c017453e83
equal deleted inserted replaced
16079:65c017453e83 16080:2fc37552b587
     6 #[derive(PartialEq, Clone, Debug)]
     6 #[derive(PartialEq, Clone, Debug)]
     7 pub struct Edge<I: PartialEq + Clone> {
     7 pub struct Edge<I: PartialEq + Clone> {
     8     id: I,
     8     id: I,
     9     symmetrical: bool,
     9     symmetrical: bool,
    10     reverse: bool,
    10     reverse: bool,
       
    11     hard_match: bool,
    11 }
    12 }
    12 
    13 
    13 impl<I: PartialEq + Clone> Edge<I> {
    14 impl<I: PartialEq + Clone> Edge<I> {
    14     #[inline]
    15     #[inline]
    15     pub fn new(id: I, symmetrical: bool) -> Self {
    16     pub fn new(id: I, symmetrical: bool, hard_match: bool) -> Self {
    16         Self {
    17         Self {
    17             id,
    18             id,
    18             symmetrical,
    19             symmetrical,
    19             reverse: false,
    20             reverse: false,
       
    21             hard_match,
    20         }
    22         }
    21     }
    23     }
    22 
    24 
    23     #[inline]
    25     #[inline]
    24     pub fn reversed(&self) -> Self {
    26     pub fn reversed(&self) -> Self {
    25         Self {
    27         Self {
    26             id: self.id.clone(),
    28             id: self.id.clone(),
    27             symmetrical: self.symmetrical,
    29             symmetrical: self.symmetrical,
    28             reverse: !self.symmetrical && !self.reverse,
    30             reverse: !self.symmetrical && !self.reverse,
    29         }
    31             hard_match: self.hard_match,
       
    32         }
       
    33     }
       
    34 
       
    35     #[inline]
       
    36     pub fn hard_match(&self) -> bool {
       
    37         self.hard_match
    30     }
    38     }
    31 
    39 
    32     #[inline]
    40     #[inline]
    33     pub fn is_compatible(&self, other: &Self) -> bool {
    41     pub fn is_compatible(&self, other: &Self) -> bool {
    34         self.id == other.id && ((self.reverse != other.reverse) || self.symmetrical)
    42         self.id == other.id && ((self.reverse != other.reverse) || self.symmetrical)