mirror of
https://github.com/Relintai/broken_seals.git
synced 2024-12-21 13:16:49 +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:
|
||||
return
|
||||
|
||||
_material.cancel_render_and_wait()
|
||||
|
||||
for n in _material.nodes:
|
||||
var gn : GraphNode = MMGraphNode.new()
|
||||
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):
|
||||
var from_node : GraphNode = _graph_edit.get_node(from)
|
||||
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):
|
||||
_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):
|
||||
var from_node : GraphNode = _graph_edit.get_node(from)
|
||||
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):
|
||||
_graph_edit.disconnect_node(from, from_slot, to, to_slot)
|
||||
|
||||
func on_graph_node_close_request(node : GraphNode) -> void:
|
||||
if _material:
|
||||
_material.cancel_render_and_wait()
|
||||
_material.remove_node(node._node)
|
||||
recreate()
|
||||
|
||||
@ -122,6 +129,8 @@ func _on_AddPopup_ok_pressed(script_path : String):
|
||||
return
|
||||
|
||||
ensure_objs()
|
||||
|
||||
_material.cancel_render_and_wait()
|
||||
|
||||
var sc = load(script_path)
|
||||
var nnode : MMNode = sc.new()
|
||||
|
@ -13,12 +13,14 @@ export(Array) var nodes : Array
|
||||
var initialized : bool = false
|
||||
var rendering : bool = false
|
||||
var queued_render : bool = false
|
||||
var render_cancelled : bool = false
|
||||
var job : ThreadPoolExecuteJob = ThreadPoolExecuteJob.new()
|
||||
|
||||
func initialize():
|
||||
if !initialized:
|
||||
initialized = true
|
||||
|
||||
job.setup(self, "_thread_func")
|
||||
|
||||
for n in nodes:
|
||||
n.connect("changed", self, "on_node_changed")
|
||||
|
||||
@ -66,6 +68,8 @@ func render_non_threaded() -> void:
|
||||
did_render = true
|
||||
|
||||
func render_threaded() -> void:
|
||||
job.cancelled = false
|
||||
|
||||
if rendering:
|
||||
queued_render = true
|
||||
return
|
||||
@ -73,18 +77,16 @@ func render_threaded() -> void:
|
||||
if !initialized:
|
||||
initialize()
|
||||
|
||||
var j : ThreadPoolExecuteJob = ThreadPoolExecuteJob.new()
|
||||
j.setup(self, "_thread_func")
|
||||
|
||||
ThreadPool.add_job(j)
|
||||
if !ThreadPool.has_job(job):
|
||||
ThreadPool.add_job(job)
|
||||
|
||||
func _thread_func() -> void:
|
||||
if render_cancelled:
|
||||
if job.cancelled:
|
||||
rendering = false
|
||||
return
|
||||
|
||||
rendering = true
|
||||
render_cancelled = false
|
||||
job.cancelled = false
|
||||
|
||||
var did_render : bool = true
|
||||
|
||||
@ -95,7 +97,7 @@ func _thread_func() -> void:
|
||||
if n && n.render(self):
|
||||
did_render = true
|
||||
|
||||
if render_cancelled:
|
||||
if job.cancelled:
|
||||
rendering = false
|
||||
return
|
||||
|
||||
@ -105,5 +107,11 @@ func _thread_func() -> void:
|
||||
queued_render = false
|
||||
_thread_func()
|
||||
|
||||
func cancel_render_and_wait() -> void:
|
||||
if rendering:
|
||||
ThreadPool.cancel_task_wait(job)
|
||||
|
||||
job.cancelled = false
|
||||
|
||||
func on_node_changed() -> void:
|
||||
call_deferred("render")
|
||||
|
Loading…
Reference in New Issue
Block a user