Files
blender-vrm/editor/spring_bone1/migration.py
小煜 091ad6a49a feat: Add VRM Blender addon with complete import/export functionality
- Add core VRM addon infrastructure with manifest and registration
- Add common utilities module with file system, logging, and conversion helpers
- Add human bone mapper with support for multiple rigging standards (Mixamo, MMD, Unreal, Rigify, etc.)
- Add VRM 0.x and 1.x format support with property groups and handlers
- Add editor UI panels for VRM metadata, spring bones, and MToon materials
- Add exporter with glTF2 extension support for VRM format serialization
- Add importer with scene reconstruction and armature generation
- Add MToon shader support with auto-setup and material migration
- Add spring bone physics simulation with constraint handling
- Add node constraint editor for advanced rigging control
- Add comprehensive validation and error handling with user dialogs
- Add scene watcher for real-time property synchronization
- Add workspace management and preference system
- Include Python cache files and Blender manifest configuration
- This is the initial commit establishing the complete VRM addon ecosystem for Blender
2026-01-01 14:21:56 +08:00

62 lines
2.1 KiB
Python

# SPDX-License-Identifier: MIT OR GPL-3.0-or-later
from bpy.types import Armature, Context, Object
from ..extension import get_armature_extension
def migrate_blender_object(armature: Armature) -> None:
ext = get_armature_extension(armature)
if tuple(ext.addon_version) >= (2, 3, 27):
return
for collider in ext.spring_bone1.colliders:
bpy_object = collider.pop("blender_object", None)
if isinstance(bpy_object, Object):
collider.bpy_object = bpy_object
def fixup_gravity_dir(armature: Armature) -> None:
ext = get_armature_extension(armature)
if tuple(ext.addon_version) <= (2, 14, 3):
for spring in ext.spring_bone1.springs:
for joint in spring.joints:
joint.gravity_dir = [
joint.gravity_dir[0],
joint.gravity_dir[2],
joint.gravity_dir[1],
]
if tuple(ext.addon_version) <= (2, 14, 10):
for spring in ext.spring_bone1.springs:
for joint in spring.joints:
joint.gravity_dir = [
joint.gravity_dir[0],
-joint.gravity_dir[1],
joint.gravity_dir[2],
]
if tuple(ext.addon_version) <= (2, 15, 3):
for spring in ext.spring_bone1.springs:
for joint in spring.joints:
gravity_dir = list(joint.gravity_dir)
joint.gravity_dir = (gravity_dir[0] + 1, 0, 0) # Make a change
joint.gravity_dir = gravity_dir
def fixup_collider_group_name(armature: Armature) -> None:
ext = get_armature_extension(armature)
if tuple(ext.addon_version) <= (2, 20, 38):
spring_bone = get_armature_extension(armature).spring_bone1
for collider_group in spring_bone.collider_groups:
collider_group.fix_index()
def migrate(_context: Context, armature: Object) -> None:
armature_data = armature.data
if not isinstance(armature_data, Armature):
return
migrate_blender_object(armature_data)
fixup_gravity_dir(armature_data)
fixup_collider_group_name(armature_data)