private StoreCache( IReadOnlyList <AggregateTypeCacheExpiration> aggregateTypeCacheExpirations, IStore store) { _aggregateCache = new AggregateCache(aggregateTypeCacheExpirations); _store = store; }
public static void MergeBuffers(Mesh result, AggregateCache cache, Vector3[] vertices0, Vector3[] normals0, Vector2[] uv0, int[] triangles0, int vertCount0, int triCount0, Vector3[] vertices1, Vector3[] normals1, Vector2[] uv1, int[] triangles1, int vertCount1, int triCount1 ) { int totalVerts = vertCount0 + vertCount1; Vector3[] aVertices = new Vector3[totalVerts]; Vector3[] aNormals = new Vector3[totalVerts]; Vector2[] aUVs = new Vector2[totalVerts]; int totalTris = triCount0 + triCount1; int[] aTriangles = new int[totalTris]; //Debug.LogFormat ( "totalVerts = {0} + {1} = {2}, totalTris = {3} + {4} = {5}", vertCount0, vertCount1, totalVerts, triCount0, triCount1, totalTris ); for (int i0 = 0; i0 < vertCount0; i0++) { aVertices[i0] = vertices0[i0]; aNormals[i0] = normals0[i0]; aUVs[i0] = uv0[i0]; } for (int i0 = 0; i0 < triCount0; i0++) { aTriangles[i0] = triangles0[i0]; } for (int i1 = 0; i1 < vertCount1; i1++) { int mIndex = vertCount0 + i1; aVertices[mIndex] = vertices1[i1]; aNormals[mIndex] = normals1[i1]; aUVs[mIndex] = uv1[i1]; } for (int i1 = 0; i1 < triCount1; i1++) { int mIndex = triCount0 + i1; aTriangles[mIndex] = vertCount0 + triangles1[i1]; } if (cache != null) { cache.vertices = aVertices; cache.normals = aNormals; cache.uvs = aUVs; cache.triangles = aTriangles; } result.vertices = aVertices; result.normals = aNormals; result.uv = aUVs; result.triangles = aTriangles; result.UploadMeshData(false); }
public static bool Aggregate(Mesh result, Mesh mesh0, OMesh mesh1, int cacheID = -1, int maxVertices = 65535) { AggregateCache cache = null; if (cacheID != -1) { if (c_Cache.TryGetValue(cacheID, out cache) == false) { cache = new AggregateCache(mesh0.vertices, mesh0.normals, mesh0.uv, mesh0.triangles); c_Cache.Add(cacheID, cache); Debug.Log("New AggregateCache created " + cacheID); } } Vector3[] vertices0 = cacheID == -1 ? mesh0.vertices : cache.vertices; int[] triangles0 = cacheID == -1 ? mesh0.triangles : cache.triangles; int vertCount0 = vertices0.Length, triCount0 = triangles0.Length; int vertCount1 = mesh1.vertIndex, triCount1 = mesh1.triIndex; if (vertCount0 + vertCount1 > maxVertices) { return(false); } Vector3[] normals0 = cacheID == -1 ? mesh0.normals : cache.normals; Vector2[] uv0 = cacheID == -1 ? mesh0.uv : cache.uvs; Vector3[] vertices1 = mesh1.vertices; Vector3[] normals1 = mesh1.normals; Vector2[] uv1 = mesh1.uvs; int[] triangles1 = mesh1.triangles; MergeBuffers(result, cache, vertices0, normals0, uv0, triangles0, vertCount0, triCount0, vertices1, normals1, uv1, triangles1, vertCount1, triCount1 ); return(true); }