diff --git a/Assets/UniGLTF/Runtime/MeshUtility/MeshIntegrator.cs b/Assets/UniGLTF/Runtime/MeshUtility/MeshIntegrator.cs index fb0fb02f2..cc400b853 100644 --- a/Assets/UniGLTF/Runtime/MeshUtility/MeshIntegrator.cs +++ b/Assets/UniGLTF/Runtime/MeshUtility/MeshIntegrator.cs @@ -76,30 +76,11 @@ namespace UniGLTF.MeshUtility } } - public MeshIntegrator(IReadOnlyList excludes) + public MeshIntegrator(IEnumerable excludes) { if (excludes != null) { - foreach (var exclude in excludes) - { - if (exclude is SkinnedMeshRenderer smr) - { - if (smr.sharedMesh != null) - { - _excludes.Add(smr.sharedMesh); - } - } - else if (exclude is MeshRenderer mr) - { - if (mr.GetComponent() is MeshFilter mf) - { - if (mf.sharedMesh != null) - { - _excludes.Add(mf.sharedMesh); - } - } - } - } + _excludes.AddRange(excludes); } Result = new MeshIntegrationResult(); @@ -174,7 +155,7 @@ namespace UniGLTF.MeshUtility return; } var bindpose = bone.worldToLocalMatrix; - + BoneWeights.AddRange(Enumerable.Range(0, mesh.vertices.Length) .Select(x => new BoneWeight() { @@ -182,10 +163,10 @@ namespace UniGLTF.MeshUtility weight0 = 1, }) ); - + BindPoses.Add(bindpose); Bones.Add(bone); - + for (int i = 0; i < mesh.subMeshCount; ++i) { var indices = mesh.GetIndices(i).Select(x => x + indexOffset); diff --git a/Assets/UniGLTF/Runtime/MeshUtility/MeshIntegratorUtility.cs b/Assets/UniGLTF/Runtime/MeshUtility/MeshIntegratorUtility.cs index cf7158353..facdc9238 100644 --- a/Assets/UniGLTF/Runtime/MeshUtility/MeshIntegratorUtility.cs +++ b/Assets/UniGLTF/Runtime/MeshUtility/MeshIntegratorUtility.cs @@ -16,7 +16,7 @@ namespace UniGLTF.MeshUtility /// /// BlendShapeを保持するSkinnedMeshRendererのみ/BlendShapeを保持しないSkinnedMeshRenderer + MeshRenderer /// - public static MeshIntegrationResult Integrate(GameObject go, bool onlyBlendShapeRenderers, IReadOnlyList excludes = null) + public static MeshIntegrationResult Integrate(GameObject go, bool onlyBlendShapeRenderers, IEnumerable excludes = null) { // レンダラから情報を集める var integrator = new MeshUtility.MeshIntegrator(excludes); diff --git a/Assets/VRM/Editor/SkinnedMeshUtility/MeshIntegratorEditor.cs b/Assets/VRM/Editor/SkinnedMeshUtility/MeshIntegratorEditor.cs index e49189608..793972b4c 100644 --- a/Assets/VRM/Editor/SkinnedMeshUtility/MeshIntegratorEditor.cs +++ b/Assets/VRM/Editor/SkinnedMeshUtility/MeshIntegratorEditor.cs @@ -26,7 +26,7 @@ namespace VRM SkinnedMeshUtility.IsPrefab(Selection.activeObject); } - public static List Integrate(GameObject prefab, UniGLTF.UnityPath writeAssetPath, IReadOnlyList excludes) + public static List Integrate(GameObject prefab, UniGLTF.UnityPath writeAssetPath, IEnumerable excludes) { Undo.RecordObject(prefab, "Mesh Integration"); var instance = SkinnedMeshUtility.InstantiatePrefab(prefab); diff --git a/Assets/VRM/Editor/SkinnedMeshUtility/MeshIntegratorWizard.cs b/Assets/VRM/Editor/SkinnedMeshUtility/MeshIntegratorWizard.cs index bd9477183..4a196af92 100644 --- a/Assets/VRM/Editor/SkinnedMeshUtility/MeshIntegratorWizard.cs +++ b/Assets/VRM/Editor/SkinnedMeshUtility/MeshIntegratorWizard.cs @@ -128,7 +128,7 @@ namespace VRM void OnValidate() { if (m_root == null - || !PrefabUtility.IsPartOfAnyPrefab(m_root)) + || !PrefabUtility.IsPartOfAnyPrefab(m_root) || m_root.transform.parent != null) { Debug.LogWarning("Invalidate"); m_uniqueMaterials = new Material[] { }; @@ -196,7 +196,28 @@ namespace VRM return; } - var excludes = m_excludes.Where(x => x.Renderer != null && x.Exclude).Select(x => x.Renderer).ToArray(); + var excludes = new List(); + foreach (var exclude in m_excludes) + { + if (exclude.Renderer is SkinnedMeshRenderer smr) + { + if (smr.sharedMesh != null) + { + excludes.Add(smr.sharedMesh); + } + } + else if (exclude.Renderer is MeshRenderer mr) + { + if (mr.GetComponent() is MeshFilter mf) + { + if (mf.sharedMesh != null) + { + excludes.Add(mf.sharedMesh); + } + } + } + } + integrationResults = MeshIntegratorEditor.Integrate(m_root, assetPath, excludes).Select(x => x.MeshMap).ToArray(); } diff --git a/Assets/VRM/Runtime/SkinnedMeshUtility/VRMMeshIntegratorUtility.cs b/Assets/VRM/Runtime/SkinnedMeshUtility/VRMMeshIntegratorUtility.cs index 48f9fcb66..81f61e0d5 100644 --- a/Assets/VRM/Runtime/SkinnedMeshUtility/VRMMeshIntegratorUtility.cs +++ b/Assets/VRM/Runtime/SkinnedMeshUtility/VRMMeshIntegratorUtility.cs @@ -39,7 +39,7 @@ namespace VRM return true; } - public static List Integrate(GameObject root, List blendshapeClips, IReadOnlyList excludes) + public static List Integrate(GameObject root, List blendshapeClips, IEnumerable excludes) { var result = new List();