public unsafe static void Compute(List <Vertex> vertices, TriangleList[] triangleLists, RelevanceSphere[] aRelevanceSpheres, bool bUseEdgeLength, bool bUseCurvature, float fBorderCurvature, float fOriginalMeshSize, float[] costs, int[] collapses)
        {
            ComputeCostJob job = new ComputeCostJob();

            job.UseEdgeLength    = bUseEdgeLength;
            job.UseCurvature     = bUseCurvature;
            job.BorderCurvature  = fBorderCurvature;
            job.OriginalMeshSize = fOriginalMeshSize;
            List <StructTriangle> structTriangles = new List <StructTriangle>();
            int intAlignment = UnsafeUtility.SizeOf <int>();

            for (int n = 0; n < triangleLists.Length; n++)
            {
                List <Triangle> triangles = triangleLists[n].ListTriangles;
                for (int i = 0; i < triangles.Count; i++)
                {
                    Triangle       t  = triangles[i];
                    StructTriangle st = new StructTriangle()
                    {
                        Index   = t.Index,
                        Indices = (int *)UnsafeUtility.Malloc(t.Indices.Length * intAlignment, intAlignment, Allocator.TempJob),
                        Normal  = t.Normal,
                    };
                    for (int j = 0; j < t.Indices.Length; j++)
                    {
                        st.Indices[j] = t.Indices[j];
                    }
                    structTriangles.Add(st);
                }
            }
            job.Triangles = new NativeArray <StructTriangle>(structTriangles.ToArray(), Allocator.TempJob);
            job.Vertices  = new NativeArray <StructVertex>(vertices.Count, Allocator.TempJob);
            for (int i = 0; i < vertices.Count; i++)
            {
                Vertex       v  = vertices[i];
                StructVertex sv = new StructVertex()
                {
                    Position      = v.Position,
                    PositionWorld = v.PositionWorld,
                    ID            = v.ID,
                    Neighbors     = v.ListNeighbors.Count == 0 ? null : (int *)UnsafeUtility.Malloc(v.ListNeighbors.Count * intAlignment, intAlignment, Allocator.TempJob),
                    NeighborCount = v.ListNeighbors.Count,
                    Faces         = (int *)UnsafeUtility.Malloc(v.ListFaces.Count * intAlignment, intAlignment, Allocator.TempJob),
                    FaceCount     = v.ListFaces.Count,
                    IsBorder      = v.IsBorder() ? 1 : 0,
                };
                for (int j = 0; j < v.ListNeighbors.Count; j++)
                {
                    sv.Neighbors[j] = v.ListNeighbors[j].ID;
                }
                for (int j = 0; j < v.ListFaces.Count; j++)
                {
                    sv.Faces[j] = v.ListFaces[j].Index;
                }
                job.Vertices[i] = sv;
            }
            job.Spheres = new NativeArray <StructRelevanceSphere>(aRelevanceSpheres.Length, Allocator.TempJob);
            for (int i = 0; i < aRelevanceSpheres.Length; i++)
            {
                RelevanceSphere       rs  = aRelevanceSpheres[i];
                StructRelevanceSphere srs = new StructRelevanceSphere()
                {
                    Transformation = Matrix4x4.TRS(rs.Position, rs.Rotation, rs.Scale),
                    Relevance      = rs.Relevance,
                };
                job.Spheres[i] = srs;
            }
            job.Result   = new NativeArray <float>(costs, Allocator.TempJob);
            job.Collapse = new NativeArray <int>(collapses, Allocator.TempJob);
#if !JOB_DEBUG
            JobHandle handle = job.Schedule(costs.Length, 1);
            handle.Complete();
#else
            for (int i = 0; i < costs.Length; i++)
            {
                job.Execute(i);
            }
#endif
            job.Result.CopyTo(costs);
            job.Collapse.CopyTo(collapses);
            for (int i = 0; i < job.Triangles.Length; i++)
            {
                UnsafeUtility.Free(job.Triangles[i].Indices, Allocator.TempJob);
            }
            for (int i = 0; i < job.Vertices.Length; i++)
            {
                UnsafeUtility.Free(job.Vertices[i].Neighbors, Allocator.TempJob);
                UnsafeUtility.Free(job.Vertices[i].Faces, Allocator.TempJob);
            }
            job.Vertices.Dispose();
            job.Triangles.Dispose();
            job.Spheres.Dispose();
            job.Result.Dispose();
            job.Collapse.Dispose();
        }