Skip to content
Snippets Groups Projects
Commit da5afd48 authored by Florent Berthaut's avatar Florent Berthaut
Browse files

Fixed array in tunnels and midi values

parent 8ac31f1c
No related branches found
No related tags found
No related merge requests found
...@@ -136,7 +136,7 @@ func _get_ivmi_type(): ...@@ -136,7 +136,7 @@ func _get_ivmi_type():
return _ivmi_type return _ivmi_type
func _process(delta): func _process(delta):
if !Engine.is_editor_hint(): if is_inside_tree():
#get cam dist if needed #get cam dist if needed
if _properties["distance_to_camera"]._listen: if _properties["distance_to_camera"]._listen:
var cam_pos = get_viewport().get_camera_3d().to_global(Vector3(0,0,0)) var cam_pos = get_viewport().get_camera_3d().to_global(Vector3(0,0,0))
......
...@@ -56,11 +56,14 @@ func _update_slices() : ...@@ -56,11 +56,14 @@ func _update_slices() :
s.scale.z = 0.5 s.scale.z = 0.5
s.rotation_degrees.x = 0 s.rotation_degrees.x = 0
for param in tunnel_preset_array[_preset_index]: for param in tunnel_preset_array[_preset_index]:
var value var value : float
if param.data_type == DATA_TYPE.array: if param.data_type == DATA_TYPE.array:
value = _find_value_in_array(ratio,param.array) value = _find_value_in_array(ratio,param.array)
else: else:
value = param.curve.sample(ratio) value = param.curve.sample(ratio)
if value > 1.0 :
value/=127
match param.name: match param.name:
"tunnel_color_scale" : "tunnel_color_scale" :
...@@ -94,6 +97,8 @@ func _physics_process(delta): ...@@ -94,6 +97,8 @@ func _physics_process(delta):
value = _find_value_in_array(ratio,param.array) value = _find_value_in_array(ratio,param.array)
else: else:
value = param.curve.sample(ratio) value = param.curve.sample(ratio)
if value > 1.0 :
value/=127
col.set_property(param.name, [value]) col.set_property(param.name, [value])
func get_extent(): func get_extent():
...@@ -101,10 +106,11 @@ func get_extent(): ...@@ -101,10 +106,11 @@ func get_extent():
# Find the highest vec.x < x in the array # Find the highest vec.x < x in the array
func _find_value_in_array(x,array): func _find_value_in_array(x,array):
var val : float = array[array.size()-1].y
for vec in array: for vec in array:
if x<=vec.x: if vec.x<=x:
return vec.y val = vec.y
return array[array.size()-1].y return val
func _cycle_preset(): func _cycle_preset():
_preset_index = (_preset_index+1)%tunnel_preset_array.size() _preset_index = (_preset_index+1)%tunnel_preset_array.size()
......
[gd_scene load_steps=2 format=2] [gd_scene load_steps=2 format=3 uid="uid://dnssxrdl7c38r"]
[ext_resource path="res://addons/ivmi-builder/techniques/control/Tunnel/TunnelPreset.gd" type="Script" id=1] [ext_resource type="Script" path="res://addons/ivmi-builder/techniques/control/Tunnel/TunnelPreset.gd" id="1"]
[node name="TunnelPreset" type="Node3D"] [node name="TunnelPreset" type="Node3D"]
script = ExtResource( 1 ) script = ExtResource("1")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment