- Fixes issue with addon registration which just randomly broke at some point
- Fixes issue where merge armatures decided to break due to me messing up with properties.
- Fixed issue where you still had to select the mesh in the 3D Scene for viseme creation even though we have a UI selector now.
This commit is contained in:
Yusarina
2024-12-23 18:16:52 +00:00
parent bf5de6665c
commit 9ad760bfb8
6 changed files with 53 additions and 7 deletions
+14
View File
@@ -2,6 +2,20 @@ modules = None
ordered_classes = None ordered_classes = None
def register(): def register():
# Add wheel installation check
try:
import lz4
except ImportError:
import sys
import os
import site
import pip
wheels_dir = os.path.join(os.path.dirname(__file__), "wheels")
for wheel in os.listdir(wheels_dir):
if wheel.endswith(".whl"):
pip.main(['install', os.path.join(wheels_dir, wheel)])
site.addsitedir(site.getsitepackages()[0])
from .core import auto_load from .core import auto_load
print("Starting registration") print("Starting registration")
auto_load.init() auto_load.init()
+4 -1
View File
@@ -56,7 +56,10 @@ def register() -> None:
def unregister() -> None: def unregister() -> None:
"""Unregister all classes and modules in reverse order""" """Unregister all classes and modules in reverse order"""
for cls in reversed(ordered_classes): for cls in reversed(ordered_classes):
bpy.utils.unregister_class(cls) try:
bpy.utils.unregister_class(cls)
except RuntimeError:
continue
for module in modules: for module in modules:
if module.__name__ == __name__: if module.__name__ == __name__:
+14 -1
View File
@@ -370,11 +370,24 @@ class AvatarToolkitSceneProperties(PropertyGroup):
def register() -> None: def register() -> None:
"""Register the Avatar Toolkit property group""" """Register the Avatar Toolkit property group"""
logger.info("Registering Avatar Toolkit properties") logger.info("Registering Avatar Toolkit properties")
try:
bpy.utils.register_class(AvatarToolkitSceneProperties)
except ValueError:
# Class already registered, we can continue
pass
bpy.types.Scene.avatar_toolkit = PointerProperty(type=AvatarToolkitSceneProperties) bpy.types.Scene.avatar_toolkit = PointerProperty(type=AvatarToolkitSceneProperties)
logger.debug("Properties registered successfully") logger.debug("Properties registered successfully")
def unregister() -> None: def unregister() -> None:
"""Unregister the Avatar Toolkit property group""" """Unregister the Avatar Toolkit property group"""
logger.info("Unregistering Avatar Toolkit properties") logger.info("Unregistering Avatar Toolkit properties")
del bpy.types.Scene.avatar_toolkit try:
del bpy.types.Scene.avatar_toolkit
except:
pass
try:
bpy.utils.unregister_class(AvatarToolkitSceneProperties)
except RuntimeError:
pass
logger.debug("Properties unregistered successfully") logger.debug("Properties unregistered successfully")
+2 -2
View File
@@ -30,8 +30,8 @@ class AvatarToolkit_OT_MergeArmature(bpy.types.Operator):
wm.progress_begin(0, 100) wm.progress_begin(0, 100)
# Get both armatures # Get both armatures
base_armature_name: str = context.scene.merge_armature_into base_armature_name: str = context.scene.avatar_toolkit.merge_armature_into
merge_armature_name: str = context.scene.merge_armature merge_armature_name: str = context.scene.avatar_toolkit.merge_armature
base_armature: Optional[Object] = bpy.data.objects.get(base_armature_name) base_armature: Optional[Object] = bpy.data.objects.get(base_armature_name)
merge_armature: Optional[Object] = bpy.data.objects.get(merge_armature_name) merge_armature: Optional[Object] = bpy.data.objects.get(merge_armature_name)
+19 -3
View File
@@ -126,15 +126,21 @@ class ATOOLKIT_OT_preview_visemes(Operator):
@classmethod @classmethod
def poll(cls, context: Context) -> bool: def poll(cls, context: Context) -> bool:
# Check if we're in object mode first # Check if we're in object mode
if context.mode != 'OBJECT': if context.mode != 'OBJECT':
return False return False
# Get mesh from UI selection
props = context.scene.avatar_toolkit
mesh_obj = bpy.data.objects.get(props.viseme_mesh)
# Validate armature and mesh
armature = get_active_armature(context) armature = get_active_armature(context)
if not armature: if not armature:
return False return False
valid, _ = validate_armature(armature) valid, _ = validate_armature(armature)
return valid and context.active_object and context.active_object.type == 'MESH' return valid and mesh_obj and mesh_obj.type == 'MESH'
def execute(self, context: Context) -> Set[str]: def execute(self, context: Context) -> Set[str]:
props = context.scene.avatar_toolkit props = context.scene.avatar_toolkit
@@ -179,11 +185,21 @@ class ATOOLKIT_OT_create_visemes(Operator):
@classmethod @classmethod
def poll(cls, context: Context) -> bool: def poll(cls, context: Context) -> bool:
# Check if we're in object mode
if context.mode != 'OBJECT':
return False
# Get mesh from UI selection
props = context.scene.avatar_toolkit
mesh_obj = bpy.data.objects.get(props.viseme_mesh)
# Validate armature and mesh
armature = get_active_armature(context) armature = get_active_armature(context)
if not armature: if not armature:
return False return False
valid, _ = validate_armature(armature) valid, _ = validate_armature(armature)
return valid and context.active_object and context.active_object.type == 'MESH' return valid and mesh_obj and mesh_obj.type == 'MESH'
def execute(self, context: Context) -> Set[str]: def execute(self, context: Context) -> Set[str]:
props = context.scene.avatar_toolkit props = context.scene.avatar_toolkit
Binary file not shown.