Skip to content

Commit

Permalink
migration 時に spring 関連の名前を付ける
Browse files Browse the repository at this point in the history
  • Loading branch information
ousttrue committed Feb 27, 2024
1 parent 646137b commit b0f75f7
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion Assets/VRM10/Runtime/Migration/MigrationVrmSpringBone.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;
using UniGLTF.Extensions.VRMC_springBone;
using UniJSON;
Expand Down Expand Up @@ -48,6 +49,23 @@ public SpringBoneGroupMigrator(UniGLTF.glTF gltf, JsonNode vrm0BoneGroup)
MigrateRootBone(vrm0Bone.GetInt32());
}
}

// fallback. default spring names
foreach (var spring in _springs)
{
if (string.IsNullOrEmpty(spring.Name) && spring.Joints.Count > 0 && spring.Joints[0].Node.HasValue)
{
var i = spring.Joints[0].Node.Value;
if (i >= 0 && i < _gltf.nodes.Count)
{
spring.Name = _gltf.nodes[i].name;
}
}
}
if (string.IsNullOrEmpty(_comment) && _springs.Count > 0)
{
_comment = _springs[0].Name;
}
}

Spring CreateSpring()
Expand Down Expand Up @@ -263,6 +281,15 @@ public static VRMC_springBone Migrate(UniGLTF.glTF gltf, JsonNode vrm0)
{
Colliders = colliderIndices.ToArray(),
};
if (colliderGroup.Colliders.Length > 0 && springBone.Colliders[colliderGroup.Colliders[0]].Node.HasValue)
{
var i = springBone.Colliders[colliderGroup.Colliders[0]].Node.Value;
if (i >= 0 && i < gltf.nodes.Count)
{
var node = gltf.nodes[i];
colliderGroup.Name = node.name;
}
}
springBone.ColliderGroups.Add(colliderGroup);
}

Expand Down

0 comments on commit b0f75f7

Please sign in to comment.