mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-09-11 13:29:41 -05:00
UniGLTF から MeshUtility への依存を削除
This commit is contained in:
@@ -2,8 +2,7 @@
|
||||
"name": "UniGLTF",
|
||||
"references": [
|
||||
"UniUnlit",
|
||||
"ShaderProperty.Runtime",
|
||||
"MeshUtility"
|
||||
"ShaderProperty.Runtime"
|
||||
],
|
||||
"optionalUnityReferences": [],
|
||||
"includePlatforms": [],
|
||||
|
||||
@@ -1,16 +1,8 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MeshUtility
|
||||
namespace UniGLTF
|
||||
{
|
||||
public struct MeshWithRenderer
|
||||
{
|
||||
public Mesh Mesh;
|
||||
[Obsolete("Use Renderer")]
|
||||
public Renderer Rendererer { get { return Renderer; } set { Renderer = value; } }
|
||||
public Renderer Renderer;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public struct MeshExportInfo
|
||||
{
|
||||
@@ -74,14 +66,14 @@ namespace MeshUtility
|
||||
foreach (var m in materials)
|
||||
{
|
||||
var currentState = MaterialUseVertexColor(m)
|
||||
? MeshUtility.MeshExportInfo.VertexColorState.ExistsAndIsUsed
|
||||
: MeshUtility.MeshExportInfo.VertexColorState.ExistsButNotUsed
|
||||
? MeshExportInfo.VertexColorState.ExistsAndIsUsed
|
||||
: MeshExportInfo.VertexColorState.ExistsButNotUsed
|
||||
;
|
||||
if (state.HasValue)
|
||||
{
|
||||
if (state.Value != currentState)
|
||||
{
|
||||
state = MeshUtility.MeshExportInfo.VertexColorState.ExistsAndMixed;
|
||||
state = MeshExportInfo.VertexColorState.ExistsAndMixed;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2af6d95e4a0e06944b34d891d798b88b
|
||||
guid: 14f3566dfa5223944bf4bdc936f58270
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -42,9 +42,9 @@ namespace UniGLTF
|
||||
|
||||
var colorAccessorIndex = -1;
|
||||
|
||||
var vColorState = MeshUtility.MeshExportInfo.DetectVertexColor(mesh, materials);
|
||||
if (vColorState == MeshUtility.MeshExportInfo.VertexColorState.ExistsAndIsUsed // VColor使っている
|
||||
|| vColorState == MeshUtility.MeshExportInfo.VertexColorState.ExistsAndMixed // VColorを使っているところと使っていないところが混在(とりあえずExportする)
|
||||
var vColorState = MeshExportInfo.DetectVertexColor(mesh, materials);
|
||||
if (vColorState == MeshExportInfo.VertexColorState.ExistsAndIsUsed // VColor使っている
|
||||
|| vColorState == MeshExportInfo.VertexColorState.ExistsAndMixed // VColorを使っているところと使っていないところが混在(とりあえずExportする)
|
||||
)
|
||||
{
|
||||
// UniUnlit で Multiply 設定になっている
|
||||
@@ -251,8 +251,16 @@ namespace UniGLTF
|
||||
};
|
||||
}
|
||||
|
||||
public struct MeshWithRenderer
|
||||
{
|
||||
public Mesh Mesh;
|
||||
[Obsolete("Use Renderer")]
|
||||
public Renderer Rendererer { get { return Renderer; } set { Renderer = value; } }
|
||||
public Renderer Renderer;
|
||||
}
|
||||
|
||||
public static IEnumerable<(Mesh, glTFMesh, Dictionary<int, int>)> ExportMeshes(glTF gltf, int bufferIndex,
|
||||
List<MeshUtility.MeshWithRenderer> unityMeshes, List<Material> unityMaterials,
|
||||
List<MeshWithRenderer> unityMeshes, List<Material> unityMaterials,
|
||||
MeshExportSettings settings)
|
||||
{
|
||||
for (int i = 0; i < unityMeshes.Count; ++i)
|
||||
|
||||
@@ -253,7 +253,7 @@ namespace UniGLTF
|
||||
|
||||
#region Meshes
|
||||
var unityMeshes = Nodes
|
||||
.Select(x => new MeshUtility.MeshWithRenderer
|
||||
.Select(x => new MeshExporter.MeshWithRenderer
|
||||
{
|
||||
Mesh = x.GetSharedMesh(),
|
||||
Renderer = x.GetComponent<Renderer>(),
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
"name": "VRM Consortium"
|
||||
},
|
||||
"dependencies": {
|
||||
"com.vrmc.vrmshaders": "0.62.0",
|
||||
"com.vrmc.meshutility": "0.62.0"
|
||||
"com.vrmc.vrmshaders": "0.62.0"
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using MeshUtility;
|
||||
using MeshUtility.M17N;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MeshUtility.Validators
|
||||
namespace VRM
|
||||
{
|
||||
public static class HumanoidValidator
|
||||
{
|
||||
@@ -73,7 +74,7 @@ namespace MeshUtility.Validators
|
||||
return Vector3.Cross(lr, Vector3.up);
|
||||
}
|
||||
|
||||
public static IReadOnlyList<MeshExportInfo> MeshInformations;
|
||||
public static IReadOnlyList<UniGLTF.MeshExportInfo> MeshInformations;
|
||||
public static bool EnableFreeze;
|
||||
|
||||
public static IEnumerable<Validation> Validate(GameObject ExportRoot)
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9013f2150f3c6d943a6f6b6394f7a1ff
|
||||
guid: d6dd0ca0faa486f4a8aa3bb895e2c697
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -16,7 +16,7 @@ namespace VRM
|
||||
/// </summary>
|
||||
/// <param name="path">出力先</param>
|
||||
/// <param name="settings">エクスポート設定</param>
|
||||
public static void Export(string path, GameObject exportRoot, VRMMetaObject meta, VRMExportSettings settings, IReadOnlyList<MeshUtility.MeshExportInfo> info)
|
||||
public static void Export(string path, GameObject exportRoot, VRMMetaObject meta, VRMExportSettings settings, IReadOnlyList<MeshExportInfo> info)
|
||||
{
|
||||
List<GameObject> destroy = new List<GameObject>();
|
||||
try
|
||||
@@ -137,7 +137,7 @@ namespace VRM
|
||||
/// <param name="settings"></param>
|
||||
/// <param name="destroy">作業が終わったらDestoryするべき一時オブジェクト</param>
|
||||
static void Export(string path, GameObject exportRoot, VRMMetaObject meta,
|
||||
VRMExportSettings settings, IReadOnlyList<MeshUtility.MeshExportInfo> info,
|
||||
VRMExportSettings settings, IReadOnlyList<UniGLTF.MeshExportInfo> info,
|
||||
List<GameObject> destroy)
|
||||
{
|
||||
var target = exportRoot;
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using MeshUtility;
|
||||
using UniGLTF;
|
||||
using UnityEngine;
|
||||
|
||||
namespace VRM
|
||||
@@ -56,14 +57,14 @@ namespace VRM
|
||||
return false;
|
||||
}
|
||||
|
||||
public List<MeshUtility.MeshExportInfo> Meshes = new List<MeshUtility.MeshExportInfo>();
|
||||
public List<MeshExportInfo> Meshes = new List<MeshExportInfo>();
|
||||
|
||||
public int ExpectedExportByteSize => Meshes.Where(x => x.IsRendererActive).Sum(x => x.ExportByteSize);
|
||||
|
||||
List<Validation> m_validations = new List<Validation>();
|
||||
public IEnumerable<Validation> Validations => m_validations;
|
||||
|
||||
public static void CalcMeshSize(ref MeshUtility.MeshExportInfo info,
|
||||
public static void CalcMeshSize(ref MeshExportInfo info,
|
||||
string relativePath, VRMExportSettings settings, IReadOnlyList<BlendShapeClip> clips)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
@@ -133,11 +134,11 @@ namespace VRM
|
||||
sb.Append($") x {info.Mesh.vertexCount}");
|
||||
switch (info.VertexColor)
|
||||
{
|
||||
case MeshUtility.MeshExportInfo.VertexColorState.ExistsAndIsUsed:
|
||||
case MeshUtility.MeshExportInfo.VertexColorState.ExistsAndMixed: // エクスポートする
|
||||
case MeshExportInfo.VertexColorState.ExistsAndIsUsed:
|
||||
case MeshExportInfo.VertexColorState.ExistsAndMixed: // エクスポートする
|
||||
sb.Insert(0, "[use vcolor]");
|
||||
break;
|
||||
case MeshUtility.MeshExportInfo.VertexColorState.ExistsButNotUsed:
|
||||
case MeshExportInfo.VertexColorState.ExistsButNotUsed:
|
||||
sb.Insert(0, "[remove vcolor]");
|
||||
break;
|
||||
}
|
||||
@@ -151,7 +152,7 @@ namespace VRM
|
||||
info.Summary = sb.ToString();
|
||||
}
|
||||
|
||||
bool TryGetMeshInfo(GameObject root, Renderer renderer, IReadOnlyList<BlendShapeClip> clips, VRMExportSettings settings, out MeshUtility.MeshExportInfo info)
|
||||
bool TryGetMeshInfo(GameObject root, Renderer renderer, IReadOnlyList<BlendShapeClip> clips, VRMExportSettings settings, out MeshExportInfo info)
|
||||
{
|
||||
info = default;
|
||||
if (root == null)
|
||||
@@ -187,7 +188,7 @@ namespace VRM
|
||||
return false;
|
||||
}
|
||||
|
||||
info.VertexColor = MeshUtility.MeshExportInfo.DetectVertexColor(info.Mesh, info.Renderer.sharedMaterials);
|
||||
info.VertexColor = MeshExportInfo.DetectVertexColor(info.Mesh, info.Renderer.sharedMaterials);
|
||||
|
||||
var relativePath = UniGLTF.UnityExtensions.RelativePathFrom(renderer.transform, root.transform);
|
||||
CalcMeshSize(ref info, relativePath, settings, clips);
|
||||
@@ -217,7 +218,7 @@ namespace VRM
|
||||
|
||||
foreach (var renderer in ExportRoot.GetComponentsInChildren<Renderer>(true))
|
||||
{
|
||||
if (TryGetMeshInfo(ExportRoot, renderer, clips, settings, out MeshUtility.MeshExportInfo info))
|
||||
if (TryGetMeshInfo(ExportRoot, renderer, clips, settings, out MeshExportInfo info))
|
||||
{
|
||||
Meshes.Add(info);
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace VRM
|
||||
);
|
||||
}
|
||||
|
||||
void DrawElement(int i, MeshUtility.MeshExportInfo info)
|
||||
void DrawElement(int i, UniGLTF.MeshExportInfo info)
|
||||
{
|
||||
var r = GUILayoutUtility.GetRect(GUIContent.none, GUIStyle.none, GUILayout.Height(EditorGUIUtility.singleLineHeight * 3 + 20));
|
||||
var col0 = 32;
|
||||
|
||||
@@ -95,7 +95,7 @@ namespace VRM
|
||||
|
||||
// default setting
|
||||
m_settings.PoseFreeze =
|
||||
MeshUtility.Validators.HumanoidValidator.HasRotationOrScale(root)
|
||||
HumanoidValidator.HasRotationOrScale(root)
|
||||
|| m_meshes.Meshes.Any(x => x.ExportBlendShapeCount > 0 && !x.HasSkinning)
|
||||
;
|
||||
}
|
||||
@@ -153,8 +153,8 @@ namespace VRM
|
||||
|
||||
IEnumerable<MeshUtility.Validator> ValidatorFactory()
|
||||
{
|
||||
MeshUtility.Validators.HumanoidValidator.MeshInformations = m_meshes.Meshes;
|
||||
MeshUtility.Validators.HumanoidValidator.EnableFreeze = m_settings.PoseFreeze;
|
||||
HumanoidValidator.MeshInformations = m_meshes.Meshes;
|
||||
HumanoidValidator.EnableFreeze = m_settings.PoseFreeze;
|
||||
VRMExporterValidator.ReduceBlendshape = m_settings.ReduceBlendshape;
|
||||
|
||||
yield return MeshUtility.Validators.HierarchyValidator.Validate;
|
||||
@@ -163,7 +163,7 @@ namespace VRM
|
||||
yield break;
|
||||
}
|
||||
|
||||
yield return MeshUtility.Validators.HumanoidValidator.Validate;
|
||||
yield return HumanoidValidator.Validate;
|
||||
yield return VRMExporterValidator.Validate;
|
||||
yield return VRMSpringBoneValidator.Validate;
|
||||
|
||||
@@ -269,7 +269,7 @@ namespace VRM
|
||||
{
|
||||
switch (meshInfo.VertexColor)
|
||||
{
|
||||
case MeshUtility.MeshExportInfo.VertexColorState.ExistsAndMixed:
|
||||
case UniGLTF.MeshExportInfo.VertexColorState.ExistsAndMixed:
|
||||
MeshUtility.Validation.Warning($"{meshInfo.Renderer}: Both vcolor.multiply and not multiply unlit materials exist").DrawGUI();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -129,8 +129,7 @@ namespace VRM
|
||||
""name"": ""VRM Consortium""
|
||||
}},
|
||||
""dependencies"": {{
|
||||
""com.vrmc.vrmshaders"": ""{1}"",
|
||||
""com.vrmc.meshutility"": ""{1}""
|
||||
""com.vrmc.vrmshaders"": ""{1}""
|
||||
}}
|
||||
}}");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user