mirror of
https://github.com/Relintai/broken_seals.git
synced 2024-12-25 01:17:10 +01:00
Improved the threading logic of MMMaterial's render by quite a bit. Also updated ThreadPool to get the new cleanups / fixes / api improvements required.
This commit is contained in:
parent
2a2918ddb7
commit
547197e78f
2
HEADS
2
HEADS
@ -1 +1 @@
|
|||||||
{"engine": {"3.2": "94a0fc47f7b4e90f8973f9adbfd3312579ed2825", "master": "8c73e813134001e575b6f59e3b0100471c007410", "3.x": "7d516191c66250973e227e5f9963a98ced90acf6"}, "world_generator": {"master": "260c430f11b0b591eaf4714516419aa327d2842c"}, "entity_spell_system": {"master": "cfba9403cb150d0a1c802039a5b7a8822a4f4832"}, "ui_extensions": {"master": "f82273f54cb1ab87d458c91af9554acec5c10831"}, "voxelman": {"master": "9253cc53c6fbbd78b5e4268eb498ef55b4dd0181"}, "texture_packer": {"master": "a0786956813a85b5a82093a081b90c2f8a000e6c"}, "fastnoise": {"master": "d447fd5364e9ab5a6b14184483eab23cd3fe820b"}, "mesh_data_resource": {"master": "49b594130dd80e05ef29297055a31fe8ffa09ffb"}, "procedural_animations": {"master": "f8aae42bf06b3936cc6bd24cb18e1c3ec9f78f4f"}, "ess_data": {"master": "3bd637fdd3304b64a18287a49a6b7387acf2f5de"}, "props": {"master": "2afd6eff45f9a921bdf4090ff3029def86df5cb5"}, "mesh_utils": {"master": "ca1f54268be462414ee40b9ff96276a8112276a9"}, "broken_seals_module": {"master": "2afea56eba66beeb543934edf5a38a8aa63fc79b"}, "thread_pool": {"master": "b2e8c815392052947e7386f722913a12eea543a4"}, "terraman": {"master": "ae53ad5001a720ddb2eb52c46eea65dc2242ac9f"}}
|
{"engine": {"3.2": "94a0fc47f7b4e90f8973f9adbfd3312579ed2825", "master": "8c73e813134001e575b6f59e3b0100471c007410", "3.x": "7d516191c66250973e227e5f9963a98ced90acf6"}, "world_generator": {"master": "260c430f11b0b591eaf4714516419aa327d2842c"}, "entity_spell_system": {"master": "cfba9403cb150d0a1c802039a5b7a8822a4f4832"}, "ui_extensions": {"master": "f82273f54cb1ab87d458c91af9554acec5c10831"}, "voxelman": {"master": "9253cc53c6fbbd78b5e4268eb498ef55b4dd0181"}, "texture_packer": {"master": "a0786956813a85b5a82093a081b90c2f8a000e6c"}, "fastnoise": {"master": "d447fd5364e9ab5a6b14184483eab23cd3fe820b"}, "mesh_data_resource": {"master": "49b594130dd80e05ef29297055a31fe8ffa09ffb"}, "procedural_animations": {"master": "f8aae42bf06b3936cc6bd24cb18e1c3ec9f78f4f"}, "ess_data": {"master": "3bd637fdd3304b64a18287a49a6b7387acf2f5de"}, "props": {"master": "2afd6eff45f9a921bdf4090ff3029def86df5cb5"}, "mesh_utils": {"master": "ca1f54268be462414ee40b9ff96276a8112276a9"}, "broken_seals_module": {"master": "2afea56eba66beeb543934edf5a38a8aa63fc79b"}, "thread_pool": {"master": "a02955e929fea4a4188d02850b187fa4048145a2"}, "terraman": {"master": "ae53ad5001a720ddb2eb52c46eea65dc2242ac9f"}}
|
@ -58,6 +58,8 @@ func recreate() -> void:
|
|||||||
if !_material:
|
if !_material:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
_material.cancel_render_and_wait()
|
||||||
|
|
||||||
for n in _material.nodes:
|
for n in _material.nodes:
|
||||||
var gn : GraphNode = MMGraphNode.new()
|
var gn : GraphNode = MMGraphNode.new()
|
||||||
gn.slot_colors = slot_colors
|
gn.slot_colors = slot_colors
|
||||||
@ -98,6 +100,8 @@ func set_mmmaterial(object : MMMateial):
|
|||||||
func on_graph_edit_connection_request(from: String, from_slot: int, to: String, to_slot: int):
|
func on_graph_edit_connection_request(from: String, from_slot: int, to: String, to_slot: int):
|
||||||
var from_node : GraphNode = _graph_edit.get_node(from)
|
var from_node : GraphNode = _graph_edit.get_node(from)
|
||||||
var to_node : GraphNode = _graph_edit.get_node(to)
|
var to_node : GraphNode = _graph_edit.get_node(to)
|
||||||
|
|
||||||
|
_material.cancel_render_and_wait()
|
||||||
|
|
||||||
if from_node.connect_slot(from_slot, to_node, to_slot):
|
if from_node.connect_slot(from_slot, to_node, to_slot):
|
||||||
_graph_edit.connect_node(from, from_slot, to, to_slot)
|
_graph_edit.connect_node(from, from_slot, to, to_slot)
|
||||||
@ -105,12 +109,15 @@ func on_graph_edit_connection_request(from: String, from_slot: int, to: String,
|
|||||||
func on_graph_edit_disconnection_request(from: String, from_slot: int, to: String, to_slot: int):
|
func on_graph_edit_disconnection_request(from: String, from_slot: int, to: String, to_slot: int):
|
||||||
var from_node : GraphNode = _graph_edit.get_node(from)
|
var from_node : GraphNode = _graph_edit.get_node(from)
|
||||||
var to_node : GraphNode = _graph_edit.get_node(to)
|
var to_node : GraphNode = _graph_edit.get_node(to)
|
||||||
|
|
||||||
|
_material.cancel_render_and_wait()
|
||||||
|
|
||||||
if from_node.disconnect_slot(from_slot, to_node, to_slot):
|
if from_node.disconnect_slot(from_slot, to_node, to_slot):
|
||||||
_graph_edit.disconnect_node(from, from_slot, to, to_slot)
|
_graph_edit.disconnect_node(from, from_slot, to, to_slot)
|
||||||
|
|
||||||
func on_graph_node_close_request(node : GraphNode) -> void:
|
func on_graph_node_close_request(node : GraphNode) -> void:
|
||||||
if _material:
|
if _material:
|
||||||
|
_material.cancel_render_and_wait()
|
||||||
_material.remove_node(node._node)
|
_material.remove_node(node._node)
|
||||||
recreate()
|
recreate()
|
||||||
|
|
||||||
@ -122,6 +129,8 @@ func _on_AddPopup_ok_pressed(script_path : String):
|
|||||||
return
|
return
|
||||||
|
|
||||||
ensure_objs()
|
ensure_objs()
|
||||||
|
|
||||||
|
_material.cancel_render_and_wait()
|
||||||
|
|
||||||
var sc = load(script_path)
|
var sc = load(script_path)
|
||||||
var nnode : MMNode = sc.new()
|
var nnode : MMNode = sc.new()
|
||||||
|
@ -13,12 +13,14 @@ export(Array) var nodes : Array
|
|||||||
var initialized : bool = false
|
var initialized : bool = false
|
||||||
var rendering : bool = false
|
var rendering : bool = false
|
||||||
var queued_render : bool = false
|
var queued_render : bool = false
|
||||||
var render_cancelled : bool = false
|
var job : ThreadPoolExecuteJob = ThreadPoolExecuteJob.new()
|
||||||
|
|
||||||
func initialize():
|
func initialize():
|
||||||
if !initialized:
|
if !initialized:
|
||||||
initialized = true
|
initialized = true
|
||||||
|
|
||||||
|
job.setup(self, "_thread_func")
|
||||||
|
|
||||||
for n in nodes:
|
for n in nodes:
|
||||||
n.connect("changed", self, "on_node_changed")
|
n.connect("changed", self, "on_node_changed")
|
||||||
|
|
||||||
@ -66,6 +68,8 @@ func render_non_threaded() -> void:
|
|||||||
did_render = true
|
did_render = true
|
||||||
|
|
||||||
func render_threaded() -> void:
|
func render_threaded() -> void:
|
||||||
|
job.cancelled = false
|
||||||
|
|
||||||
if rendering:
|
if rendering:
|
||||||
queued_render = true
|
queued_render = true
|
||||||
return
|
return
|
||||||
@ -73,18 +77,16 @@ func render_threaded() -> void:
|
|||||||
if !initialized:
|
if !initialized:
|
||||||
initialize()
|
initialize()
|
||||||
|
|
||||||
var j : ThreadPoolExecuteJob = ThreadPoolExecuteJob.new()
|
if !ThreadPool.has_job(job):
|
||||||
j.setup(self, "_thread_func")
|
ThreadPool.add_job(job)
|
||||||
|
|
||||||
ThreadPool.add_job(j)
|
|
||||||
|
|
||||||
func _thread_func() -> void:
|
func _thread_func() -> void:
|
||||||
if render_cancelled:
|
if job.cancelled:
|
||||||
rendering = false
|
rendering = false
|
||||||
return
|
return
|
||||||
|
|
||||||
rendering = true
|
rendering = true
|
||||||
render_cancelled = false
|
job.cancelled = false
|
||||||
|
|
||||||
var did_render : bool = true
|
var did_render : bool = true
|
||||||
|
|
||||||
@ -95,7 +97,7 @@ func _thread_func() -> void:
|
|||||||
if n && n.render(self):
|
if n && n.render(self):
|
||||||
did_render = true
|
did_render = true
|
||||||
|
|
||||||
if render_cancelled:
|
if job.cancelled:
|
||||||
rendering = false
|
rendering = false
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -105,5 +107,11 @@ func _thread_func() -> void:
|
|||||||
queued_render = false
|
queued_render = false
|
||||||
_thread_func()
|
_thread_func()
|
||||||
|
|
||||||
|
func cancel_render_and_wait() -> void:
|
||||||
|
if rendering:
|
||||||
|
ThreadPool.cancel_task_wait(job)
|
||||||
|
|
||||||
|
job.cancelled = false
|
||||||
|
|
||||||
func on_node_changed() -> void:
|
func on_node_changed() -> void:
|
||||||
call_deferred("render")
|
call_deferred("render")
|
||||||
|
Loading…
Reference in New Issue
Block a user