parent
b9bd72f979
commit
20fb69465b
3 changed files with 168 additions and 72 deletions
35
__init__.py
35
__init__.py
|
@ -383,10 +383,10 @@ class ABC3D_PT_FontList(bpy.types.Panel):
|
|||
row.scale_y = scale_y
|
||||
row.label(text=text)
|
||||
row = layout.row()
|
||||
oper = row.operator(f"{__name__}.load_font",
|
||||
oper_lf = row.operator(f"{__name__}.load_font",
|
||||
text='Load all glyphs in memory')
|
||||
oper.font_name = font_name
|
||||
oper.face_name = face_name
|
||||
oper_lf.font_name = font_name
|
||||
oper_lf.face_name = face_name
|
||||
|
||||
|
||||
class ABC3D_PT_TextPlacement(bpy.types.Panel):
|
||||
|
@ -914,6 +914,7 @@ class ABC3D_OT_RemoveText(bpy.types.Operator):
|
|||
def delif(o, p):
|
||||
if p in o:
|
||||
del o[p]
|
||||
delif(mom, f"{utils.prefix()}_type")
|
||||
delif(mom, f"{utils.prefix()}_linked_textobject")
|
||||
delif(mom, f"{utils.prefix()}_font_name")
|
||||
delif(mom, f"{utils.prefix()}_face_name")
|
||||
|
@ -1046,7 +1047,7 @@ class ABC3D_OT_PlaceText(bpy.types.Operator):
|
|||
# t.text)
|
||||
# or this:
|
||||
# butils.set_text_on_curve(t)
|
||||
# else:
|
||||
else:
|
||||
butils.ShowMessageBox(
|
||||
title="No object selected",
|
||||
message=(
|
||||
|
@ -1372,7 +1373,7 @@ class ABC3D_OT_CreateFontFromObjects(bpy.types.Operator):
|
|||
font_name,
|
||||
face_name,
|
||||
glyph_id,
|
||||
o)
|
||||
bpy.types.PointerProperty(o))
|
||||
|
||||
# TODO: is there a better way to iterate over a CollectionProperty?
|
||||
found = False
|
||||
|
@ -1484,7 +1485,6 @@ def detect_text():
|
|||
|
||||
|
||||
def load_used_glyphs():
|
||||
print("LOAD USED GLYPHS")
|
||||
scene = bpy.context.scene
|
||||
abc3d_data = scene.abc3d_data
|
||||
for t in abc3d_data.available_texts:
|
||||
|
@ -1528,19 +1528,33 @@ def on_frame_changed(self, dummy):
|
|||
# TODO PERFORMANCE: only on demand
|
||||
butils.set_text_on_curve(t)
|
||||
|
||||
depsgraph_updates_locked = False
|
||||
def unlock_depsgraph_updates():
|
||||
global depsgraph_updates_locked
|
||||
depsgraph_updates_locked = False
|
||||
|
||||
def lock_depsgraph_updates():
|
||||
global depsgraph_updates_locked
|
||||
depsgraph_updates_locked = True
|
||||
if bpy.app.timers.is_registered(unlock_depsgraph_updates):
|
||||
bpy.app.timers.unregister(unlock_depsgraph_updates)
|
||||
bpy.app.timers.register(unlock_depsgraph_updates, first_interval=1)
|
||||
|
||||
import time
|
||||
@persistent
|
||||
def on_depsgraph_update(scene, depsgraph):
|
||||
if not bpy.context.mode.startswith("EDIT"):
|
||||
global depsgraph_updates_locked
|
||||
if not bpy.context.mode.startswith("EDIT") and not depsgraph_updates_locked:
|
||||
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:
|
||||
lock_depsgraph_updates()
|
||||
def later():
|
||||
if not "lock_depsgraph_update_ntimes" in scene.abc3d_data \
|
||||
or scene.abc3d_data["lock_depsgraph_update_ntimes"] == 0:
|
||||
print("******* not yet")
|
||||
or scene.abc3d_data["lock_depsgraph_update_ntimes"] <= 0:
|
||||
butils.set_text_on_curve(
|
||||
scene.abc3d_data.available_texts[linked_textobject])
|
||||
elif scene.abc3d_data["lock_depsgraph_update_ntimes"] > 0:
|
||||
|
@ -1596,6 +1610,9 @@ def unregister():
|
|||
if on_frame_changed in bpy.app.handlers.frame_change_post:
|
||||
bpy.app.handlers.frame_change_post.remove(on_frame_changed)
|
||||
|
||||
if on_depsgraph_update in bpy.app.handlers.depsgraph_update_post:
|
||||
bpy.app.handlers.depsgraph_update_post.remove(on_depsgraph_update)
|
||||
|
||||
del bpy.types.Scene.abc3d_data
|
||||
print(f"UNREGISTER {bl_info['name']}")
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue