--- a/rust/landgen/src/wavefront_collapse/generator.rs Sun Feb 12 14:19:02 2023 +0100
+++ b/rust/landgen/src/wavefront_collapse/generator.rs Sun Feb 12 15:10:10 2023 +0100
@@ -136,7 +136,7 @@
for r in 0..grid.height() {
for c in 0..grid.width() {
- print!("{:?}", grid.get(r, c));
+ print!("{:?} ", grid.get(r, c));
}
println!();
@@ -183,7 +183,7 @@
fn test_generation() {
let wfc_gen = WavefrontCollapseLandGenerator::new(&Size::new(2048, 1024));
let landgen_params = LandGenerationParameters::new(0u32, 0xff000000u32, 0, true, true);
- let land = wfc_gen.generate_land(&landgen_params, &mut std::iter::repeat(0u32));
+ let land = wfc_gen.generate_land(&landgen_params, &mut [0u32, 1u32, 3u32, 5u32, 7u32, 11u32].into_iter().cycle());
let path = Path::new(r"output.png");
let file = File::create(path).unwrap();
--- a/rust/landgen/src/wavefront_collapse/tile_image.rs Sun Feb 12 14:19:02 2023 +0100
+++ b/rust/landgen/src/wavefront_collapse/tile_image.rs Sun Feb 12 15:10:10 2023 +0100
@@ -23,19 +23,19 @@
Self {
id: self.id.clone(),
symmetrical: self.symmetrical,
- reverse: !self.symmetrical && !self.reverse,
+ reverse: !self.reverse,
}
}
pub fn is_compatible(&self, other: &Self) -> bool {
- self.id == other.id && (self.reverse != other.reverse || self.symmetrical)
+ self.id == other.id && ((self.reverse != other.reverse) || self.symmetrical)
}
}
#[derive(Clone)]
pub struct TileImage<T, I: PartialEq + Clone> {
image: Rc<Vec2D<T>>,
- transform: Transform,
+ pub transform: Transform,
top: Edge<I>,
right: Edge<I>,
bottom: Edge<I>,
@@ -108,10 +108,10 @@
Self {
image: self.image.clone(),
transform: self.transform.rotate270(),
- top: self.left.clone(),
- right: self.top.clone(),
- bottom: self.right.clone(),
- left: self.bottom.clone(),
+ top: self.right.clone(),
+ right: self.bottom.clone(),
+ bottom: self.left.clone(),
+ left: self.top.clone(),
}
}
@@ -156,13 +156,13 @@
self.image.get(image_row, image_column)
},
Transform::Rotate90(_) => {
- let image_row = if self.transform.is_flipped() {
+ let image_row = if self.transform.is_mirrored() {
column
} else {
self.image.height().wrapping_sub(1).wrapping_sub(column)
};
- let image_column = if self.transform.is_mirrored() {
+ let image_column = if self.transform.is_flipped() {
self.image.width().wrapping_sub(1).wrapping_sub(row)
} else {
row
--- a/rust/landgen/src/wavefront_collapse/transform.rs Sun Feb 12 14:19:02 2023 +0100
+++ b/rust/landgen/src/wavefront_collapse/transform.rs Sun Feb 12 15:10:10 2023 +0100
@@ -40,6 +40,7 @@
}
pub fn is_mirrored(&self) -> bool {
+ use SymmetryTransform::*;
match self {
Id => false,
Flip => false,
@@ -49,6 +50,7 @@
}
pub fn is_flipped(&self) -> bool {
+ use SymmetryTransform::*;
match self {
Id => false,
Flip => true,
--- a/rust/landgen/src/wavefront_collapse/wavefront_collapse.rs Sun Feb 12 14:19:02 2023 +0100
+++ b/rust/landgen/src/wavefront_collapse/wavefront_collapse.rs Sun Feb 12 15:10:10 2023 +0100
@@ -141,12 +141,12 @@
}
}
} else {
- println!("We're here: {}, {}", x, y);
+ /*println!("We're here: {}, {}", x, y);
println!(
"Neighbour tiles are: {:?} {:?} {:?} {:?}",
right_tile, bottom_tile, left_tile, top_tile
);
- println!("Rules are: {:?}", self.rules);
+ println!("Rules are: {:?}", self.rules);*/
//todo!("no collapse possible - what to do?")
}