Node position related fixes

Set correct position when creating a new node
Node position is now saved/loaded
Fixed row & column parameters in bricks generator
This commit is contained in:
RodZill4 2018-07-23 06:19:45 +02:00
parent 9443940d9a
commit 4c9e5762b1
6 changed files with 9 additions and 9 deletions

View File

@ -14,7 +14,7 @@ func _ready():
func get_shader_code(uv):
var rv = { defs="", code="" }
if generated_variants.empty():
rv.defs = "float "+name+"_f(vec2 uv) { return bricks(uv, vec2("+str(rows)+", "+str(columns)+"), "+str(row_offset)+", "+str(mortar)+", "+str(max(0.001, bevel))+"); }\n"
rv.defs = "float "+name+"_f(vec2 uv) { return bricks(uv, vec2("+str(columns)+", "+str(rows)+"), "+str(row_offset)+", "+str(mortar)+", "+str(max(0.001, bevel))+"); }\n"
var variant_index = generated_variants.find(uv)
if variant_index == -1:
variant_index = generated_variants.size()

View File

@ -91,7 +91,7 @@ mouse_filter = 0
mouse_default_cursor_shape = 1
size_flags_horizontal = 1
size_flags_vertical = 1
text = "3"
text = "6"
focus_mode = 2
context_menu_enabled = true
placeholder_alpha = 0.6
@ -137,7 +137,7 @@ mouse_filter = 0
mouse_default_cursor_shape = 1
size_flags_horizontal = 1
size_flags_vertical = 1
text = "6"
text = "3"
focus_mode = 2
context_menu_enabled = true
placeholder_alpha = 0.6

View File

@ -70,13 +70,14 @@ func serialize():
var type = get_script().resource_path
type = type.right(type.find_last("/")+1)
type = type.left(type.find_last("."))
var data = { name=name, type=type }
var data = { name=name, type=type, node_position={x=offset.x, y=offset.y} }
for v in _get_state_variables():
data[v] = serialize_element(get(v))
return data
func deserialize(data):
print("deserialize: "+name)
offset = Vector2(data.node_position.x, data.node_position.y)
for v in _get_state_variables():
set(v, deserialize_element(data[v]))
print(" "+v+" = "+str(deserialize_element(data[v])))

View File

@ -10,7 +10,6 @@ const MENU = [
{ name="bricks", description="Bricks" },
{ name="iqnoise", description="IQ Noise" },
{ name="perlin", description="Perlin noise" },
{ name="boolean", description="Boolean" },
{ name="transform", description="Transform" },
{ name="colorize", description="Colorize" },
{ name="blend", description="Blend" }
@ -35,7 +34,7 @@ func _on_PopupMenu_id_pressed(id):
if node_type != null:
var node = node_type.instance()
$GraphEdit.add_child(node)
node.set_begin(popup_position)
node.offset = ($GraphEdit.scroll_offset + popup_position - $GraphEdit.rect_global_position) / $GraphEdit.zoom
func _on_GraphEdit_connection_request(from, from_slot, to, to_slot):
var disconnect = $GraphEdit.get_source(to, to_slot)

View File

@ -100,10 +100,10 @@ float perlin(vec2 uv, int iterations, float turbulence) {
return f/m;
}
float Bricks_f(vec2 uv) { return bricks(uv, vec2(4, 8), 0.5, 0.1, 0.1); }
float Bricks_f(vec2 uv) { return bricks(uv, vec2(Null, Null), Null, Null, 0.2); }
void fragment() {
float Bricks_0_f = Bricks_f(UV);
vec3 Colorize_rgb = mix(vec3(0.882813,0.134491,0.134491), vec3(0.882813,0.446795,0.062073), Bricks_0_f);
vec3 Colorize_rgb = mix(vec3(0.859375,0.198059,0.198059), vec3(0.890625,0.330505,0.111328), Bricks_0_f);
vec3 Material_rgb = Colorize_rgb;
COLOR = vec4(Material_rgb, 1.0);
}
@ -181,7 +181,7 @@ mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
popup_exclusive = false
items = [ "Load texture", null, 0, false, false, 0, 0, null, "", false, "Save texture", null, 0, false, false, 1, 0, null, "", false, "Sine", null, 0, false, false, 2, 0, null, "", false, "Bricks", null, 0, false, false, 3, 0, null, "", false, "IQ Noise", null, 0, false, false, 4, 0, null, "", false, "Perlin noise", null, 0, false, false, 5, 0, null, "", false, "Boolean", null, 0, false, false, 6, 0, null, "", false, "Transform", null, 0, false, false, 7, 0, null, "", false, "Colorize", null, 0, false, false, 8, 0, null, "", false, "Blend", null, 0, false, false, 9, 0, null, "", false ]
items = [ "Load texture", null, 0, false, false, 0, 0, null, "", false, "Save texture", null, 0, false, false, 1, 0, null, "", false, "Sine", null, 0, false, false, 2, 0, null, "", false, "Bricks", null, 0, false, false, 3, 0, null, "", false, "IQ Noise", null, 0, false, false, 4, 0, null, "", false, "Perlin noise", null, 0, false, false, 5, 0, null, "", false, "Transform", null, 0, false, false, 6, 0, null, "", false, "Colorize", null, 0, false, false, 7, 0, null, "", false, "Blend", null, 0, false, false, 8, 0, null, "", false ]
hide_on_state_item_selection = false
_sections_unfolded = [ "Rect" ]

Binary file not shown.