mirror of
https://github.com/Relintai/material-maker.git
synced 2024-12-23 21:16:54 +01:00
Fixed problem related to deferring nodes creation
This commit is contained in:
parent
88b2f4f2b8
commit
4af095afba
@ -141,11 +141,11 @@
|
||||
{
|
||||
"from": "blend_2",
|
||||
"from_port": 0,
|
||||
"to": "normal_map",
|
||||
"to": "normal_map_2",
|
||||
"to_port": 0
|
||||
},
|
||||
{
|
||||
"from": "normal_map",
|
||||
"from": "normal_map_2",
|
||||
"from_port": 0,
|
||||
"to": "Material",
|
||||
"to_port": 4
|
||||
@ -642,9 +642,11 @@
|
||||
"parameters": {
|
||||
"bevel": 0.2,
|
||||
"columns": 2,
|
||||
"corner": 0,
|
||||
"mortar": 0.05,
|
||||
"pattern": 3,
|
||||
"repeat": 2,
|
||||
"round": 0,
|
||||
"row_offset": 0.5,
|
||||
"rows": 2
|
||||
},
|
||||
@ -660,7 +662,9 @@
|
||||
"intensity": 1,
|
||||
"randomness": 1,
|
||||
"scale_x": 8,
|
||||
"scale_y": 8
|
||||
"scale_y": 8,
|
||||
"stretch_x": 1,
|
||||
"stretch_y": 1
|
||||
},
|
||||
"type": "voronoi"
|
||||
},
|
||||
@ -977,252 +981,21 @@
|
||||
"type": "graph"
|
||||
},
|
||||
{
|
||||
"connections": [
|
||||
{
|
||||
"from": "nm_convolution",
|
||||
"from_port": 0,
|
||||
"to": "nm_postprocess",
|
||||
"to_port": 0
|
||||
},
|
||||
{
|
||||
"from": "nm_postprocess",
|
||||
"from_port": 0,
|
||||
"to": "gen_outputs",
|
||||
"to_port": 0
|
||||
},
|
||||
{
|
||||
"from": "gen_inputs",
|
||||
"from_port": 0,
|
||||
"to": "buffer",
|
||||
"to_port": 0
|
||||
},
|
||||
{
|
||||
"from": "buffer",
|
||||
"from_port": 0,
|
||||
"to": "nm_convolution",
|
||||
"to_port": 0
|
||||
}
|
||||
],
|
||||
"label": "Normal Map",
|
||||
"name": "normal_map",
|
||||
"name": "normal_map_2",
|
||||
"node_position": {
|
||||
"x": 960.584229,
|
||||
"y": 273.420258
|
||||
"x": 986.357788,
|
||||
"y": 281.520294
|
||||
},
|
||||
"nodes": [
|
||||
{
|
||||
"name": "buffer",
|
||||
"node_position": {
|
||||
"x": -687.663818,
|
||||
"y": 125.60614
|
||||
},
|
||||
"parameters": {
|
||||
"lod": 0,
|
||||
"size": 11
|
||||
},
|
||||
"type": "buffer"
|
||||
},
|
||||
{
|
||||
"convolution_params": {
|
||||
"input_type": "f",
|
||||
"matrix": [
|
||||
[
|
||||
[
|
||||
-1,
|
||||
-1,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
-2,
|
||||
0
|
||||
],
|
||||
[
|
||||
1,
|
||||
-1,
|
||||
0
|
||||
]
|
||||
],
|
||||
[
|
||||
[
|
||||
-2,
|
||||
0,
|
||||
0
|
||||
],
|
||||
0,
|
||||
[
|
||||
2,
|
||||
0,
|
||||
0
|
||||
]
|
||||
],
|
||||
[
|
||||
[
|
||||
-1,
|
||||
1,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
2,
|
||||
0
|
||||
],
|
||||
[
|
||||
1,
|
||||
1,
|
||||
0
|
||||
]
|
||||
]
|
||||
],
|
||||
"output_type": "rgb",
|
||||
"x": 1,
|
||||
"y": 1
|
||||
},
|
||||
"name": "nm_convolution",
|
||||
"node_position": {
|
||||
"x": -690.25,
|
||||
"y": 174.25
|
||||
},
|
||||
"parameters": {
|
||||
"size": 11
|
||||
},
|
||||
"type": "convolution"
|
||||
},
|
||||
{
|
||||
"name": "nm_postprocess",
|
||||
"node_position": {
|
||||
"x": -690.25,
|
||||
"y": 222.25
|
||||
},
|
||||
"parameters": {
|
||||
"amount": 0.995,
|
||||
"size": 11
|
||||
},
|
||||
"shader_model": {
|
||||
"code": "",
|
||||
"global": "",
|
||||
"inputs": [
|
||||
{
|
||||
"default": "vec3(0.0)",
|
||||
"label": "",
|
||||
"name": "in",
|
||||
"type": "rgb"
|
||||
}
|
||||
],
|
||||
"instance": "",
|
||||
"name": "NormalMapPostProcess",
|
||||
"outputs": [
|
||||
{
|
||||
"rgb": "0.5*normalize($in($uv)*$amount*vec3(-1.0, 1.0, 1.0)*$size/128.0-vec3(0.0, 0.0, 1.0))+vec3(0.5)",
|
||||
"type": "rgb"
|
||||
}
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"default": 9,
|
||||
"first": 4,
|
||||
"label": "",
|
||||
"last": 11,
|
||||
"name": "size",
|
||||
"type": "size"
|
||||
},
|
||||
{
|
||||
"default": 1,
|
||||
"label": "",
|
||||
"max": 2,
|
||||
"min": 0,
|
||||
"name": "amount",
|
||||
"step": 0.005,
|
||||
"type": "float"
|
||||
}
|
||||
]
|
||||
},
|
||||
"type": "shader"
|
||||
},
|
||||
{
|
||||
"name": "gen_parameters",
|
||||
"node_position": {
|
||||
"x": -718.910156,
|
||||
"y": 26.083313
|
||||
},
|
||||
"parameters": {
|
||||
"param0": 11,
|
||||
"param1": 0.995
|
||||
},
|
||||
"type": "remote",
|
||||
"widgets": [
|
||||
{
|
||||
"label": "Size",
|
||||
"linked_widgets": [
|
||||
{
|
||||
"node": "buffer",
|
||||
"widget": "size"
|
||||
},
|
||||
{
|
||||
"node": "nm_convolution",
|
||||
"widget": "size"
|
||||
},
|
||||
{
|
||||
"node": "nm_postprocess",
|
||||
"widget": "size"
|
||||
}
|
||||
],
|
||||
"name": "param0",
|
||||
"type": "linked_control"
|
||||
},
|
||||
{
|
||||
"label": "Amount",
|
||||
"linked_widgets": [
|
||||
{
|
||||
"node": "nm_postprocess",
|
||||
"widget": "amount"
|
||||
}
|
||||
],
|
||||
"name": "param1",
|
||||
"type": "linked_control"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "gen_outputs",
|
||||
"node_position": {
|
||||
"x": -407.663818,
|
||||
"y": 151.047363
|
||||
},
|
||||
"parameters": {
|
||||
|
||||
},
|
||||
"ports": [
|
||||
{
|
||||
"name": "port0",
|
||||
"type": "rgba"
|
||||
}
|
||||
],
|
||||
"type": "ios"
|
||||
},
|
||||
{
|
||||
"name": "gen_inputs",
|
||||
"node_position": {
|
||||
"x": -870.910156,
|
||||
"y": 157.047363
|
||||
},
|
||||
"parameters": {
|
||||
|
||||
},
|
||||
"ports": [
|
||||
{
|
||||
"name": "port0",
|
||||
"type": "rgba"
|
||||
}
|
||||
],
|
||||
"type": "ios"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"amount": 0.5,
|
||||
"param0": 11,
|
||||
"param1": 0.995
|
||||
"param1": 1.02,
|
||||
"param2": 0,
|
||||
"param3": 0,
|
||||
"param4": 0,
|
||||
"size": 4
|
||||
},
|
||||
"type": "graph"
|
||||
"type": "normal_map"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -74,7 +74,10 @@ func remove_node(node) -> void:
|
||||
for c in get_connection_list():
|
||||
if c.from == node_name or c.to == node_name:
|
||||
disconnect_node(c.from, c.from_port, c.to, c.to_port)
|
||||
node.queue_free()
|
||||
if node == last_selected:
|
||||
set_last_selected(null)
|
||||
remove_child(node)
|
||||
node.free()
|
||||
send_changed_signal()
|
||||
|
||||
# Global operations on graph
|
||||
@ -106,6 +109,8 @@ func clear_view() -> void:
|
||||
clear_connections()
|
||||
for c in get_children():
|
||||
if c is GraphNode:
|
||||
if c == last_selected:
|
||||
set_last_selected(c)
|
||||
remove_child(c)
|
||||
c.free()
|
||||
|
||||
@ -358,7 +363,13 @@ func _on_ButtonTransmitsSeed_toggled(button_pressed) -> void:
|
||||
generator.transmits_seed = button_pressed
|
||||
|
||||
func _on_GraphEdit_node_selected(node) -> void:
|
||||
last_selected = node
|
||||
set_last_selected(node)
|
||||
|
||||
func set_last_selected(node) -> void:
|
||||
if node is GraphNode:
|
||||
last_selected = node
|
||||
else:
|
||||
last_selected = null
|
||||
|
||||
func _on_GraphEdit_gui_input(event) -> void:
|
||||
if event is InputEventMouseButton:
|
||||
@ -366,6 +377,5 @@ func _on_GraphEdit_gui_input(event) -> void:
|
||||
|
||||
func check_last_selected() -> void:
|
||||
if last_selected != null and !(is_instance_valid(last_selected) && last_selected.selected):
|
||||
print("Unselected")
|
||||
last_selected = null
|
||||
emit_signal("node_selected", null)
|
||||
emit_signal("node_selected", null)
|
||||
|
@ -36,14 +36,13 @@ one_shot = true
|
||||
[node name="GraphUI" type="HBoxContainer" parent="."]
|
||||
anchor_left = 1.0
|
||||
anchor_right = 1.0
|
||||
margin_left = -592.0
|
||||
margin_left = -262.0
|
||||
margin_right = -16.0
|
||||
margin_bottom = 24.0
|
||||
alignment = 2
|
||||
|
||||
[node name="SubGraphUI" type="HBoxContainer" parent="GraphUI"]
|
||||
margin_left = 330.0
|
||||
margin_right = 544.0
|
||||
margin_right = 214.0
|
||||
margin_bottom = 24.0
|
||||
size_flags_horizontal = 9
|
||||
|
||||
@ -71,8 +70,8 @@ size_flags_horizontal = 9
|
||||
icon = SubResource( 3 )
|
||||
|
||||
[node name="ButtonShowTree" type="Button" parent="GraphUI"]
|
||||
margin_left = 548.0
|
||||
margin_right = 576.0
|
||||
margin_left = 218.0
|
||||
margin_right = 246.0
|
||||
margin_bottom = 24.0
|
||||
hint_tooltip = "Show hierarchy"
|
||||
icon = SubResource( 4 )
|
||||
|
@ -513,7 +513,8 @@ func _on_Projects_tab_changed(tab) -> void:
|
||||
if c.method_name == "update_preview" or c.method_name == "update_preview_2d":
|
||||
c.source.disconnect(c.signal_name, self, c.method_name)
|
||||
new_tab.connect("graph_changed", self, "update_preview")
|
||||
new_tab.connect("node_selected", self, "on_selected_node_change")
|
||||
if !new_tab.is_connected("node_selected", self, "on_selected_node_change"):
|
||||
new_tab.connect("node_selected", self, "on_selected_node_change")
|
||||
current_tab = new_tab
|
||||
update_preview()
|
||||
|
||||
|
@ -14,13 +14,13 @@ var preview_timer : Timer = null
|
||||
func set_generator(g) -> void:
|
||||
.set_generator(g)
|
||||
generator.connect("parameter_changed", self, "on_parameter_changed")
|
||||
call_deferred("update_node")
|
||||
update_node()
|
||||
|
||||
func on_parameter_changed(p, v) -> void:
|
||||
if ignore_parameter_change == p:
|
||||
return
|
||||
if p == "__update_all__":
|
||||
call_deferred("update_node")
|
||||
update_node()
|
||||
elif controls.has(p):
|
||||
var o = controls[p]
|
||||
if o is MMFloatEdit:
|
||||
@ -158,6 +158,7 @@ func restore_preview_widget() -> void:
|
||||
func update_node() -> void:
|
||||
# Clean node
|
||||
var custom_node_buttons = null
|
||||
clear_all_slots()
|
||||
save_preview_widget()
|
||||
for c in get_children():
|
||||
remove_child(c)
|
||||
@ -327,7 +328,7 @@ func do_load_generator(file_name : String) -> void:
|
||||
var parent_generator = generator.get_parent()
|
||||
parent_generator.replace_generator(generator, new_generator)
|
||||
generator = new_generator
|
||||
call_deferred("update_node")
|
||||
update_node()
|
||||
|
||||
func save_generator() -> void:
|
||||
var dialog = FileDialog.new()
|
||||
|
@ -42,7 +42,7 @@ func update_node() -> void:
|
||||
add_control(generator.get_widget(p.name).label, control)
|
||||
if generator.widgets[i].type == "config_control" and control is OptionButton:
|
||||
var current = null
|
||||
if control.get_item_count() > 0:
|
||||
if control.get_item_count() > 0 and generator.parameters.has(p.name):
|
||||
control.selected = generator.parameters[p.name]
|
||||
current = control.get_item_text(control.selected)
|
||||
control.add_separator()
|
||||
@ -110,7 +110,8 @@ func _on_AddConfig_pressed() -> void:
|
||||
|
||||
func _on_Link_pressed(param_name) -> void:
|
||||
var link = MMNodeLink.new(get_parent())
|
||||
link.pick(controls[param_name], generator, param_name)
|
||||
if controls.has(param_name):
|
||||
link.pick(controls[param_name], generator, param_name)
|
||||
|
||||
func _on_Remote_resize_request(new_minsize) -> void:
|
||||
rect_size = new_minsize
|
||||
|
@ -1,4 +1,3 @@
|
||||
tool
|
||||
extends ColorRect
|
||||
|
||||
var generator = null
|
||||
|
Loading…
Reference in New Issue
Block a user