Skip to content

Commit

Permalink
Merge pull request #1617 from ousttrue/fix10/spring_bone_import
Browse files Browse the repository at this point in the history
joint が複数の chain に所属する場合に AddComponent に失敗する
  • Loading branch information
ousttrue authored Apr 19, 2022
2 parents 45aab79 + 5b815a8 commit 2f6b522
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion Assets/VRM10/Runtime/IO/Vrm10Importer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,17 @@ async Task LoadSpringBoneAsync(IAwaitCaller awaitCaller, Vrm10Instance controlle
// に基づきデフォルト値を補う

// node is required
var joint = Nodes[gltfJoint.Node.Value].gameObject.AddComponent<VRM10SpringBoneJoint>();
var go = Nodes[gltfJoint.Node.Value].gameObject;
var joint = go.GetComponent<VRM10SpringBoneJoint>();
if (joint != null)
{
// 仕様違反。マイグレーションで発生しうるのと、エクスポーターでの除外などがされていないので、
// エラーにせずに飛ばす
Debug.LogWarning($"duplicated spring joint: {Data.TargetPath}");
continue;
}

joint = go.AddComponent<VRM10SpringBoneJoint>();
joint.m_jointRadius = gltfJoint.HitRadius.GetValueOrDefault(0.0f);
joint.m_dragForce = gltfJoint.DragForce.GetValueOrDefault(0.5f);
joint.m_gravityDir = gltfJoint.GravityDir != null ? Vector3InvertX(gltfJoint.GravityDir) : Vector3.down;
Expand Down

0 comments on commit 2f6b522

Please sign in to comment.