saturday06 / VRM-Addon-for-Blender

VRM Importer, Exporter and Utilities for Blender 2.93 to 4.2
https://vrm-addon-for-blender.info
MIT License
1.31k stars 143 forks source link

バグ報告: VRM0命名規則に従った親指のボーン自動割り当てがうまくいかない #180

Open derodero24 opened 1 year ago

derodero24 commented 1 year ago

バグについて

親指ボーンの命名が根本から

であった場合、「ボーンの自動割り当て/Automatic Bone Assignment」機能を使うと

のようになり、正しく割り当てられない。

バグの再現方法

  1. 「VRMパネル > Operator > Create VRM Model」よりモデル作成
  2. モデルをglbやfbxなどのファイル形式でエクスポート
  3. 2のファイルをインポート

もしくは

  1. 「VRMパネル > Operator > Create VRM Model」よりモデル作成
  2. 「VRMパネル > VRM 0.x Humanoid > VRM Optional Bones 」より親指の割り当てを削除
  3. 「VRMパネル > VRM 0.x Humanoid > Automatic Bone Assignment」より自動割り当て

期待する動作 親指ボーンの命名が「proximal / intermediate / distal」形式になっていたらVRM0.xの規則に従って割り当て、 「metacarpal / proximal / distal」形式になっていたらVRM1.0の規則に従って割り当てる。

スクリーンショット

スクリーンショット 2023-01-17 15 34 27

PC環境情報

提案

ソースコード common/human_bone_mapper/human_bone_mapper.py の関数 create_human_bone_mapping() にて、vrm0規則より先にvrm1規則と比較された結果、vrm1規則とマッチしていると判定されてしまうため、vrm0規則の意味がなくなっているように思います。 「最初にマッチした規則」を採用するのではなく、「すべての規則の中で最も一致率が多い規則」を採用する方が良いのではないかと感じました。

def create_human_bone_mapping(
    armature: bpy.types.Object,
) -> Dict[str, HumanBoneSpecification]:
    for name, mapping in [
        mmd_mapping.create_config(armature),
        ready_player_me_mapping.config,
        cats_blender_plugin_fix_model_mapping.config,
        microsoft_rocketbox_mapping.config_bip01,
        microsoft_rocketbox_mapping.config_bip02,
        rigify_meta_rig_mapping.config,
        vrm_addon_mapping.config_vrm1,  // vrm0形式でもここでマッチしてreturnされてしまう
        vrm_addon_mapping.config_vrm0,  // ← 実質意味がない(?)
    ]:
        if match_mapping(armature.data, mapping):
            logger.warning(f'Treat as "{name}" bone mappings')
            return sorted_required_first(mapping)

    return {}
saturday06 commented 1 year ago

ご提案ありがとうございます。

「すべての規則の中で最も一致率が多い規則」

こちらの実装を検討します。

saturday06 commented 1 year ago

こちらのコミットで対応しました → https://github.com/saturday06/VRM-Addon-for-Blender/commit/88fccef5d84d0148e3dcaf01277860c1ecef5a0a https://github.com/saturday06/VRM-Addon-for-Blender/commit/0a8a04e32e525fafa98d5db579d9bac8ef06ea7b 次回のリリースに反映されます。ご提案ありがとうございました。

derodero24 commented 1 year ago

早急なご対応ありがとうございます!助かります!