migration 時に spring 関連の名前を付ける

This commit is contained in:
ousttrue
2024-02-27 19:19:42 +09:00
parent 646137b221
commit b0f75f7e26

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;
using UniGLTF.Extensions.VRMC_springBone;
using UniJSON;
@@ -48,6 +49,23 @@ namespace UniVRM10
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()
@@ -263,6 +281,15 @@ namespace UniVRM10
{
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);
}