Esempio n. 1
0
 private static bool SubdivideSafe(NativeArray <float2> points, NativeArray <int2> edges, ref NativeArray <float2> outVertices, ref int outVertexCount, ref NativeArray <int> outIndices, ref int outIndexCount, ref NativeArray <int2> outEdges, ref int outEdgeCount, float areaFactor, float areaThreshold, int refineIterations, int smoothenIterations)
 {
     try
     {
         ModuleHandle.Subdivide(Allocator.Persistent, points, edges, ref outVertices, ref outVertexCount, ref outIndices, ref outIndexCount, ref outEdges, ref outEdgeCount, areaFactor, areaThreshold, refineIterations, smoothenIterations);
     }
     catch (Exception)
     {
         return(false);
     }
     return(true);
 }
Esempio n. 2
0
        private static unsafe void SubdivideBurst(Allocator allocator, float2 *points, int pointCount, int2 *edges, int edgeCount, float2 *outVertices, int *outIndices, int2 *outEdges, int arrayCount, float areaFactor, float areaThreshold, int refineIterations, int smoothenIterations, int3 *result)
        {
            NativeArray <int2> _edges = new NativeArray <int2>(edgeCount, allocator);

            for (int i = 0; i < _edges.Length; ++i)
            {
                _edges[i] = edges[i];
            }

            NativeArray <float2> _points = new NativeArray <float2>(pointCount, allocator);

            for (int i = 0; i < _points.Length; ++i)
            {
                _points[i] = points[i];
            }

            NativeArray <int>    _outIndices  = new NativeArray <int>(arrayCount, allocator);
            NativeArray <int2>   _outEdges    = new NativeArray <int2>(arrayCount, allocator);
            NativeArray <float2> _outVertices = new NativeArray <float2>(arrayCount, allocator);
            int outEdgeCount   = 0;
            int outIndexCount  = 0;
            int outVertexCount = 0;

            ModuleHandle.Subdivide(allocator, _points, _edges, ref _outVertices, ref outVertexCount, ref _outIndices, ref outIndexCount, ref _outEdges, ref outEdgeCount, areaFactor, areaThreshold, refineIterations, smoothenIterations);

            for (int i = 0; i < outEdgeCount; ++i)
            {
                outEdges[i] = _outEdges[i];
            }
            for (int i = 0; i < outIndexCount; ++i)
            {
                outIndices[i] = _outIndices[i];
            }
            for (int i = 0; i < outVertexCount; ++i)
            {
                outVertices[i] = _outVertices[i];
            }

            result->x = outVertexCount;
            result->y = outIndexCount;
            result->z = outEdgeCount;

            _outVertices.Dispose();
            _outEdges.Dispose();
            _outIndices.Dispose();
            _points.Dispose();
            _edges.Dispose();
        }