Now the render can be cancelled.

This commit is contained in:
Relintai 2021-10-31 11:37:16 +01:00
parent ccc0a59a58
commit 2a2918ddb7

View File

@ -13,6 +13,7 @@ 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
func initialize(): func initialize():
if !initialized: if !initialized:
@ -78,7 +79,12 @@ func render_threaded() -> void:
ThreadPool.add_job(j) ThreadPool.add_job(j)
func _thread_func() -> void: func _thread_func() -> void:
if render_cancelled:
rendering = false
return
rendering = true rendering = true
render_cancelled = false
var did_render : bool = true var did_render : bool = true
@ -89,6 +95,10 @@ func _thread_func() -> void:
if n && n.render(self): if n && n.render(self):
did_render = true did_render = true
if render_cancelled:
rendering = false
return
rendering = false rendering = false
if queued_render: if queued_render: