fix preflight

yup...
This commit is contained in:
AspireMint 2021-12-03 20:32:40 +01:00
parent abc6b568f9
commit 9890ecec81
2 changed files with 33 additions and 26 deletions

View File

@ -15,17 +15,8 @@ func _ready():
func get_noise_3d(x: float, y: float, z: float) -> float:
return noise.get_noise_3d(x, y, z)
class PreflightParams extends Object:
var dimension: Vector3
var origin: Vector3
var precision: int
func _init(dimension: Vector3, origin: Vector3 = Vector3(0,0,0), precision: int = 0):
self.dimension = dimension
self.origin = origin
self.precision = precision
func preflight_3d(params: PreflightParams) -> Vector2:
var origin = params.origin
var dimension = params.dimension
var precision = params.precision
@ -42,7 +33,10 @@ func preflight_3d(params: PreflightParams) -> Vector2:
for x in range(dimension.x / precision):
for y in range(dimension.y / precision):
for z in range(dimension.y / precision):
var value = noise.get_noise_3d(x*precision, y*precision, z*precision)
var shift_x = (x*precision)+origin.x
var shift_y = (y*precision)+origin.y
var shift_z = (z*precision)+origin.z
var value = noise.get_noise_3d(shift_x, shift_y, shift_z)
if value < minmax.x:
minmax.x = value
if value > minmax.y:
@ -54,3 +48,15 @@ func round_preflight(minmax: Vector2) -> Vector2:
minmax.x = floor(minmax.x*10)/10
minmax.y = ceil(minmax.y*10)/10
return minmax
################################################################################
class PreflightParams extends Object:
var dimension: Vector3
var origin: Vector3
var precision: int
func _init(dimension: Vector3, origin: Vector3 = Vector3(0,0,0), precision: int = 0):
self.dimension = dimension
self.origin = origin
self.precision = precision

View File

@ -1,9 +1,10 @@
extends Spatial
onready var Noise = get_node("/root/Noise")
var minmax_value: Vector2
export var skip_generating: bool = true
export var live_preview: bool = false
export var skip_generating: bool = false
export var live_preview: bool = true
#texture width and height in pixels
export var size: int = 500
@ -28,8 +29,18 @@ export(Array, String) var textures : Array = [
"south.png"
]
onready var minmax_value: Vector2 = _get_preflight()
func _get_preflight():
func _ready():
if not skip_generating:
_preflight()
_create_skybox()
_print_mt_table()
if not live_preview:
get_tree().quit()
_scale_sprites()
func _preflight():
var params: Noise.PreflightParams
if projection == Projection.SPHERE:
var dimension = Vector3(2*sphere_radius, 2*sphere_radius, 2*sphere_radius)
@ -38,17 +49,7 @@ func _get_preflight():
elif projection == Projection.CUBE:
var dimension = Vector3(size, size, size)
params = Noise.PreflightParams.new(dimension)
return Noise.round_preflight(Noise.preflight_3d(params))
func _ready():
if not skip_generating:
_create_skybox()
_print_mt_table()
if not live_preview:
get_tree().quit()
_scale_sprites()
minmax_value = Noise.round_preflight(Noise.preflight_3d(params))
func _create_skybox() -> void:
top()