Shapey Key Update.

- Viesmes will now use selected armature.
- New dropdown menu in the viseme UI so the user can select which mesh to create visemes on.
- New helper function get_armature_meshes
- Added a new check before we create the new visemes to see if any exist, if there do we will remove them and create the new ones.
- fixed several issues and errors.
This commit is contained in:
Yusarina
2024-07-25 01:42:34 +01:00
parent ddb76a0c90
commit deaada347a
6 changed files with 55 additions and 30 deletions
+9 -3
View File
@@ -96,6 +96,9 @@ def get_all_meshes(context: Context) -> List[Object]:
return [obj for obj in bpy.data.objects if obj.type == 'MESH' and obj.parent == armature]
return []
def get_mesh_items(self, context):
return [(obj.name, obj.name, "") for obj in get_all_meshes(context)]
def open_web_after_delay_multi_threaded(delay: typing.Optional[float] = 1.0, url: typing.Union[str, typing.Any] = ""):
thread = threading.Thread(target=open_web_after_delay,args=[delay,url],name="open_browser_thread")
thread.start()
@@ -128,6 +131,10 @@ def sort_shape_keys(mesh: Object) -> None:
print("No shape keys found. Exiting sort function.")
return
# Set the mesh as the active object
bpy.context.view_layer.objects.active = mesh
bpy.ops.object.mode_set(mode='OBJECT')
order = [
'Basis',
'vrc.blink_left',
@@ -176,13 +183,12 @@ def sort_shape_keys(mesh: Object) -> None:
index = shape_keys.find(name)
if index != i:
print(f"Moving {name} from index {index} to {i}")
bpy.context.object.active_shape_key_index = index
while bpy.context.object.active_shape_key_index > i:
mesh.active_shape_key_index = index
while mesh.active_shape_key_index > i:
bpy.ops.object.shape_key_move(type='UP')
print("Shape key sorting completed.")
def get_shapekeys(mesh: Object, prefix: str = '') -> List[tuple]:
if not has_shapekeys(mesh):
return []
+7 -1
View File
@@ -2,7 +2,7 @@ import bpy
from ..functions.translations import t, get_languages_list, update_language
from ..core.addon_preferences import get_preference
from .common import get_armatures
from .common import get_armatures, get_mesh_items
def register() -> None:
default_language = get_preference("language", 0)
@@ -14,6 +14,12 @@ def register() -> None:
default=default_language,
update=update_language
)
bpy.types.Scene.selected_mesh = bpy.props.EnumProperty(
items=get_mesh_items,
name="Selected Mesh",
description="The currently selected mesh for viseme operations"
)
bpy.types.Scene.avatar_toolkit_language_changed = bpy.props.BoolProperty(default=False)