예제 #1
0
 private static bool TessellateSafe(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)
 {
     try
     {
         ModuleHandle.Tessellate(Allocator.Persistent, points, edges, ref outVertices, ref outVertexCount, ref outIndices, ref outIndexCount, ref outEdges, ref outEdgeCount);
     }
     catch (Exception)
     {
         return(false);
     }
     return(true);
 }
예제 #2
0
        private static unsafe void TessellateBurst(Allocator allocator, float2 *points, int pointCount, int2 *edges, int edgeCount, float2 *outVertices, int *outIndices, int2 *outEdges, int arrayCount, 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.Tessellate(allocator, _points, _edges, ref _outVertices, ref outVertexCount, ref _outIndices, ref outIndexCount, ref _outEdges, ref outEdgeCount);

            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();
        }