|
|
|
@ -11,13 +11,13 @@ var data = { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var poisson_disc_sampling: PoissonDiscSampling = PoissonDiscSampling.new() |
|
|
|
var poisson_disc_sampling: PoissonDiscSampling = PoissonDiscSampling.new() |
|
|
|
var points = [] |
|
|
|
var points = PoolByteArray() |
|
|
|
|
|
|
|
var poissons = [] |
|
|
|
|
|
|
|
|
|
|
|
signal new_poisson(points) |
|
|
|
signal new_poisson(points) |
|
|
|
|
|
|
|
|
|
|
|
func _ready(): |
|
|
|
func _ready(): |
|
|
|
reset_options(default_width, default_height, default_spacing) |
|
|
|
reset_options(default_width, default_height, default_spacing) |
|
|
|
pass |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func reset_options(width, height, spacing): |
|
|
|
func reset_options(width, height, spacing): |
|
|
|
$HBoxContainer/Properties/width/width_edit.text = str(width) |
|
|
|
$HBoxContainer/Properties/width/width_edit.text = str(width) |
|
|
|
@ -29,6 +29,10 @@ func set_data(width, height, spacing): |
|
|
|
data.height = height |
|
|
|
data.height = height |
|
|
|
data.spacing = spacing |
|
|
|
data.spacing = spacing |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func init_points(): |
|
|
|
|
|
|
|
points.resize(data.width * data.height) |
|
|
|
|
|
|
|
points.fill(0) |
|
|
|
|
|
|
|
|
|
|
|
func _on_Button_pressed(): |
|
|
|
func _on_Button_pressed(): |
|
|
|
set_data( |
|
|
|
set_data( |
|
|
|
int($HBoxContainer/Properties/width/width_edit.text), |
|
|
|
int($HBoxContainer/Properties/width/width_edit.text), |
|
|
|
@ -36,8 +40,14 @@ func _on_Button_pressed(): |
|
|
|
int($HBoxContainer/Properties/spacing/spacing_edit.text) |
|
|
|
int($HBoxContainer/Properties/spacing/spacing_edit.text) |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init_points() |
|
|
|
|
|
|
|
|
|
|
|
var rect = Rect2(Vector2(0, 0), Vector2(data.width, data.height)) |
|
|
|
var rect = Rect2(Vector2(0, 0), Vector2(data.width, data.height)) |
|
|
|
points = poisson_disc_sampling.generate_points(data.spacing, rect, 20) |
|
|
|
poissons = poisson_disc_sampling.generate_points(data.spacing, rect, 20) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for poisson in poissons: |
|
|
|
|
|
|
|
points.set(int(poisson.x) + int(poisson.y) * data.width, 1) |
|
|
|
|
|
|
|
|
|
|
|
emit_signal("new_poisson", points) |
|
|
|
emit_signal("new_poisson", points) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|