mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-06 14:56:47 +02:00
random start collasped_propagated
This commit is contained in:
@@ -1,8 +1,22 @@
|
|||||||
use <_impl/_tiles_wfc_impl.scad>;
|
use <_impl/_tiles_wfc_impl.scad>;
|
||||||
|
use <../util/rand.scad>;
|
||||||
|
|
||||||
// An implementation of [Wave Function Collapse](https://github.com/mxgmn/WaveFunctionCollapse)
|
// An implementation of [Wave Function Collapse](https://github.com/mxgmn/WaveFunctionCollapse)
|
||||||
function tile_wfc(size, sample) =
|
function tile_wfc(size, sample) =
|
||||||
tilemap_generate(tilemap(size[0], size[1], sample));
|
let(
|
||||||
|
tm = tilemap(size[0], size[1], sample),
|
||||||
|
wf = tilemap_wf(tm),
|
||||||
|
// random start
|
||||||
|
x = floor(rand(size[0] * 0.25, size[0] * 0.75)),
|
||||||
|
y = floor(rand(size[1] * 0.25, size[1] * 0.75)),
|
||||||
|
first_collasped_propagated = tilemap_propagate([
|
||||||
|
tilemap_width(tm),
|
||||||
|
tilemap_height(tm),
|
||||||
|
tilemap_compatibilities(tm),
|
||||||
|
wf_collapse(wf, x, y)
|
||||||
|
], x, y)
|
||||||
|
)
|
||||||
|
tilemap_generate(first_collasped_propagated);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user