move execution_queue in butils, cleanup

This commit is contained in:
jrkb 2024-07-10 17:14:02 +02:00
parent 07c38fcdaf
commit d7a73116fd
2 changed files with 34 additions and 40 deletions

View file

@ -1,5 +1,6 @@
import bpy
import mathutils
import queue
import importlib
# then import dependencies for our addon
@ -13,6 +14,19 @@ if "utils" in locals():
else:
from .common import utils
execution_queue = queue.Queue()
# This function can safely be called in another thread.
# The function will be executed when the timer runs the next time.
def run_in_main_thread(function):
execution_queue.put(function)
def execute_queued_functions():
while not execution_queue.empty():
function = execution_queue.get()
function()
return 1.0
def apply_all_transforms(obj):
mb = obj.matrix_basis
if hasattr(obj.data, "transform"):