reset text on depsgraph update

This commit is contained in:
themancalledjakob 2024-10-31 19:34:31 +01:00
parent b6d76ae958
commit e8fd0d8243

View file

@ -1485,6 +1485,20 @@ def on_frame_changed(self, dummy):
# TODO PERFORMANCE: only on demand
butils.set_text_on_curve(t)
@persistent
def on_depsgraph_update(scene, depsgraph):
for u in depsgraph.updates:
if f"{utils.prefix()}_linked_textobject" in u.id.keys() \
and f"{utils.prefix()}_type" in u.id.keys() \
and u.id[f"{utils.prefix()}_type"] == 'textobject':
linked_textobject = u.id[f"{utils.prefix()}_linked_textobject"]
if u.is_updated_geometry and len(scene.abc3d_data.available_texts) > linked_textobject and not "prevent_recursion" in u.id:
u.id["prevent_recursion"] = True
butils.set_text_on_curve(scene.abc3d_data.available_texts[linked_textobject])
elif "prevent_recursion" in u.id.keys():
del u.id["prevent_recursion"]
def register():
for cls in classes:
bpy.utils.register_class(cls)
@ -1501,6 +1515,9 @@ def register():
if on_frame_changed not in bpy.app.handlers.frame_change_post:
bpy.app.handlers.frame_change_post.append(on_frame_changed)
if on_depsgraph_update not in bpy.app.handlers.depsgraph_update_post:
bpy.app.handlers.depsgraph_update_post.append(on_depsgraph_update)
butils.run_in_main_thread(butils.clear_available_fonts)
# butils.run_in_main_thread(butils.load_installed_fonts)
butils.run_in_main_thread(butils.update_available_fonts)