GltfDuplicatedNameConversionRule.FixNames

This commit is contained in:
ousttrue
2025-04-17 15:33:16 +09:00
parent 67e620bb25
commit 6ead0f2099
6 changed files with 16 additions and 6 deletions

View File

@@ -204,6 +204,16 @@ namespace UniGLTF
}
}
// `v0.129.0` GlbLowLevelParser.Parse からこちらに移動
public static void FixNames(glTF GLTF)
{
FixMeshNameUnique(GLTF);
FixTextureNameUnique(GLTF);
FixMaterialNameUnique(GLTF);
FixNodeName(GLTF);
FixAnimationNameUnique(GLTF);
}
public static void FixNodeNameUnique(glTF GLTF)
{
var m_uniqueNameSet = new HashSet<string>();

View File

@@ -155,11 +155,7 @@ namespace UniGLTF
await awaitCaller.Run(() =>
{
// `v0.129.0` GlbLowLevelParser.Parse からこちらに移動
GltfDuplicatedNameConversionRule.FixMeshNameUnique(GLTF);
GltfDuplicatedNameConversionRule.FixTextureNameUnique(GLTF);
GltfDuplicatedNameConversionRule.FixMaterialNameUnique(GLTF);
GltfDuplicatedNameConversionRule.FixNodeName(GLTF);
GltfDuplicatedNameConversionRule.FixAnimationNameUnique(GLTF);
GltfDuplicatedNameConversionRule.FixNames(GLTF);
});
}

View File

@@ -35,7 +35,7 @@ namespace UniGLTF
var parser = new GlbLowLevelParser("Test", data.ToGlbBytes());
using (var parsed = parser.Parse())
{
GltfDuplicatedNameConversionRule.FixTextureNameUnique(parsed.GLTF);
GltfDuplicatedNameConversionRule.FixNames(parsed.GLTF);
Assert.AreEqual("FooBar", parsed.GLTF.textures[0].name);
// NOTE: 大文字小文字が違うだけの名前は、同一としてみなされ、Suffix が付く。

View File

@@ -69,6 +69,7 @@ namespace VRM
var path = AliciaPath;
using (var data = new GlbFileParser(path).Parse())
{
GltfDuplicatedNameConversionRule.FixNames(data.GLTF);
var vrmImporter = new VRMImporterContext(new VRMData(data), null);
var materialParam = new BuiltInVrmMaterialDescriptorGenerator(vrmImporter.VRM).Get(data, 0);
Assert.AreEqual("VRM/MToon", materialParam.Shader.name);

View File

@@ -61,6 +61,7 @@ namespace VRM
new ArraySegment<byte>(Array.Empty<byte>())
))
{
GltfDuplicatedNameConversionRule.FixNames(data.GLTF);
var vrm = new glTF_VRM_extensions
{
materialProperties = new List<glTF_VRM_Material>
@@ -124,6 +125,7 @@ namespace VRM
new ArraySegment<byte>(Array.Empty<byte>())
))
{
GltfDuplicatedNameConversionRule.FixNames(data.GLTF);
var vrm = new glTF_VRM_extensions
{
materialProperties = new List<glTF_VRM_Material>

View File

@@ -23,6 +23,7 @@ namespace UniVRM10
var migratedBytes = MigrationVrm.Migrate(File.ReadAllBytes(AliciaPath));
using (var data = new GlbLowLevelParser(AliciaPath, migratedBytes).Parse())
{
GltfDuplicatedNameConversionRule.FixNames(data.GLTF);
var matDesc = new BuiltInVrm10MaterialDescriptorGenerator().Get(data, 0);
Assert.AreEqual("Alicia_body", matDesc.Name);