mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-08-25 20:16:05 -05:00
migration 時に spring 関連の名前を付ける
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user