| 52 | |
| 53 | |
| 54 | def build_mesh(empty, p, data): |
| 55 | font = data.font() |
| 56 | current = {} |
| 57 | |
| 58 | for o in bpy.data.objects: |
| 59 | if o.parent == empty: |
| 60 | idx = int(o.name.split(".")[-1]) |
| 61 | current[idx] = o |
| 62 | |
| 63 | for idx, x in enumerate(p): |
| 64 | key = f"{font.path.stem}.{x.glyphName}" |
| 65 | prototype = bpy.data.objects[key] |
| 66 | existing = current.get(idx, None) |
| 67 | |
| 68 | if existing: |
| 69 | mesh_glyph = existing |
| 70 | else: |
| 71 | mesh_glyph = prototype.copy() |
| 72 | |
| 73 | mesh_glyph.data = prototype.data.copy() |
| 74 | mesh_glyph.name = f"{empty.name}.glyph.{idx}" |
| 75 | mesh_glyph.parent = empty |
| 76 | mesh_glyph.st2.parent = empty.name |
| 77 | |
| 78 | mesh_glyph.scale = (0.3*data.scale, 0.3*data.scale, 0.3*data.scale) |
| 79 | |
| 80 | amb = x.ambit(tx=0, ty=0) |
| 81 | # 0.003 is b/c of the 3pt fontSize hardcoded above |
| 82 | mesh_glyph.location = ( |
| 83 | amb.x + prototype.st2.meshOffsetX*0.003*data.scale, |
| 84 | 0, #mesh_glyph.location.y, |
| 85 | prototype.st2.meshOffsetY*0.003*data.scale) |
| 86 | |
| 87 | if existing is None: |
| 88 | empty.users_collection[0].objects.link(mesh_glyph) |
| 89 | |
| 90 | for idx, o in current.items(): |
| 91 | if idx >= len(p): |
| 92 | bpy.data.objects.remove(current[idx], do_unlink=True) |
| 93 | |
| 94 | |
| 95 | class T(): |