Skip to content

Commit

Permalink
fix: prevent skinned mesh node parenting to make gltf validator happy
Browse files Browse the repository at this point in the history
  • Loading branch information
saturday06 committed Dec 15, 2024
1 parent 0dc0b72 commit 1222f26
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 15 deletions.
38 changes: 23 additions & 15 deletions src/io_scene_vrm/exporter/vrm0_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2852,23 +2852,31 @@ def write_mesh_node(

parent_node_index = None
parent_translation = None
if (
obj.parent_type in ["ARMATURE", "OBJECT"]
and (parent := self.get_export_parent_object(obj, mesh_convertible_objects))
and parent in self.export_objects
):
# TODO: 互換性のためネストしたメッシュを復元しないが、将来的には復元する
# parent_translation = parent.matrix_world.to_translation()
# parent_node_index = object_name_to_node_index.get(parent.name)
if have_skin:
# スキンがある場合はシーンのルートノードになる
pass
else:
if (
obj.parent_type in ["ARMATURE", "OBJECT"]
and (
parent := self.get_export_parent_object(
obj, mesh_convertible_objects
)
)
and parent in self.export_objects
):
# TODO: 互換性のためネストしたメッシュを復元しないが、将来的には復元する
# parent_translation = parent.matrix_world.to_translation()
# parent_node_index = object_name_to_node_index.get(parent.name)
pass

if obj.parent_type == "BONE" and (
bone := self.armature.pose.bones.get(obj.parent_bone)
):
parent_translation = (
self.armature.matrix_world @ bone.matrix
).to_translation()
parent_node_index = bone_name_to_node_index.get(obj.parent_bone)
if obj.parent_type == "BONE" and (
bone := self.armature.pose.bones.get(obj.parent_bone)
):
parent_translation = (
self.armature.matrix_world @ bone.matrix
).to_translation()
parent_node_index = bone_name_to_node_index.get(obj.parent_bone)

if parent_node_index is not None and 0 <= parent_node_index < len(node_dicts):
parent_node_dict = node_dicts[parent_node_index]
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 1222f26

Please sign in to comment.