use BuildMeshAsync. remove EnableLoadBalancing

This commit is contained in:
ousttrue 2021-02-22 16:00:25 +09:00
parent a5be5e1383
commit bd0e79d627
3 changed files with 1 additions and 63 deletions

View File

@ -57,9 +57,6 @@ namespace UniGLTF
#endregion
#region Load. Build unity objects
public bool EnableLoadBalancing;
public virtual async Awaitable LoadAsync(Func<string, IDisposable> MeasureTime = null)
{
if (MeasureTime == null)
@ -145,16 +142,7 @@ namespace UniGLTF
{
using (MeasureTime("BuildMesh"))
{
MeshWithMaterials meshWithMaterials;
if (EnableLoadBalancing)
{
meshWithMaterials = await MeshImporter.BuildMeshAsync(MaterialFactory, x);
}
else
{
meshWithMaterials = MeshImporter.BuildMesh(MaterialFactory, x);
}
var meshWithMaterials = await MeshImporter.BuildMeshAsync(MaterialFactory, x);
var mesh = meshWithMaterials.Mesh;
// mesh name

View File

@ -6,29 +6,6 @@ namespace UniGLTF
{
public static class ImporterContextExtensions
{
// /// <summary>
// /// ReadAllBytes, Parse, Create GameObject
// /// </summary>
// /// <param name="path">allbytes</param>
// public static void Load(this ImporterContext self, string path)
// {
// var bytes = File.ReadAllBytes(path);
// self.Load(path, bytes);
// }
// /// <summary>
// /// Parse, Create GameObject
// /// </summary>
// /// <param name="path">gltf or glb path</param>
// /// <param name="bytes">allbytes</param>
// public static void Load(this ImporterContext self, string path, byte[] bytes)
// {
// var parser = new GltfParser();
// parser.Parse(path, bytes);
// self.Load(parser);
// self.Root.name = Path.GetFileNameWithoutExtension(path);
// }
/// <summary>
/// Build unity objects from parsed gltf
/// </summary>

View File

@ -627,33 +627,6 @@ namespace UniGLTF
}
}
public static MeshWithMaterials BuildMesh(MaterialFactory ctx, MeshImporter.MeshContext meshContext)
{
var (mesh, recalculateTangents) = _BuildMesh(meshContext);
if (recalculateTangents)
{
mesh.RecalculateTangents();
}
// 先にすべてのマテリアルを作成済みなのでテクスチャーは生成済み。Resultを使ってよい
var result = new MeshWithMaterials
{
Mesh = mesh,
Materials = meshContext.MaterialIndices.Select(x => ctx.GetMaterial(x)).ToArray()
};
if (meshContext.BlendShapes.Count > 0)
{
var emptyVertices = new Vector3[mesh.vertexCount];
foreach (var blendShape in meshContext.BlendShapes)
{
BuildBlendShape(mesh, meshContext, blendShape, emptyVertices);
}
}
return result;
}
public static async Awaitable<MeshWithMaterials> BuildMeshAsync(MaterialFactory ctx, MeshImporter.MeshContext meshContext)
{
var (mesh, recalculateTangents) = _BuildMesh(meshContext);