Exemple #1
0
        public static ChiselBlobBuilderArray <T> Construct <T>(this ChiselBlobBuilder builder, ref ChiselBlobArray <T> blobArray, T[] data, int length) where T : unmanaged
        {
            var blobBuilderArray = builder.Allocate(ref blobArray, length);

            for (int i = 0; i < length; i++)
            {
                blobBuilderArray[i] = data[i];
            }
            return(blobBuilderArray);
        }
Exemple #2
0
        public static ChiselBlobBuilderArray <T> Construct <T>(this ChiselBlobBuilder builder, ref ChiselBlobArray <T> blobArray, List <T> data) where T : unmanaged
        {
            var blobBuilderArray = builder.Allocate(ref blobArray, data.Count);

            for (int i = 0; i < data.Count; i++)
            {
                blobBuilderArray[i] = data[i];
            }
            return(blobBuilderArray);
        }
Exemple #3
0
        public static ChiselBlobBuilderArray <T> Construct <T>(this ChiselBlobBuilder builder, ref ChiselBlobArray <T> blobArray, NativeArray <T> data) where T : unmanaged
        {
            var blobBuilderArray = builder.Allocate(ref blobArray, data.Length);

            if (data.Length > 0)
            {
                UnsafeUtility.MemCpy(blobBuilderArray.GetUnsafePtr(), data.GetUnsafeReadOnlyPtr(), blobBuilderArray.Length * sizeof(T));
            }
            return(blobBuilderArray);
        }
Exemple #4
0
        public static ChiselBlobBuilderArray <T> Construct <T>(this ChiselBlobBuilder builder, ref ChiselBlobArray <T> blobArray, T *data, int length) where T : unmanaged
        {
            length = math.max(length, 0);
            var blobBuilderArray = builder.Allocate(ref blobArray, length);

            if (length > 0)
            {
                UnsafeUtility.MemCpy(blobBuilderArray.GetUnsafePtr(), data, blobBuilderArray.Length * sizeof(T));
            }
            return(blobBuilderArray);
        }
Exemple #5
0
        public static ChiselBlobBuilderArray <T> Construct <T>(this ChiselBlobBuilder builder, ref ChiselBlobArray <T> blobArray, NativeArray <T> data, int length) where T : unmanaged
        {
            length = math.max(length, 0);
            var blobBuilderArray = builder.Allocate(ref blobArray, length);

            if (length > 0)
            {
                var srcPtr = data.GetUnsafeReadOnlyPtr();
                var dstPtr = blobBuilderArray.GetUnsafePtr();
                UnsafeUtility.MemCpy(dstPtr, srcPtr, blobBuilderArray.Length * sizeof(T));
            }
            return(blobBuilderArray);
        }
Exemple #6
0
 public static ChiselBlobAssetReference <ChiselPathBlob> Convert(ChiselPath path, Allocator allocator)
 {
     path.UpgradeIfNecessary();
     using (var builder = new ChiselBlobBuilder(Allocator.Temp))
     {
         ref var root             = ref builder.ConstructRoot <ChiselPathBlob>();
         var     srcControlPoints = path.segments;
         var     dstControlPoints = builder.Allocate(ref root.segments, srcControlPoints.Length);
         for (int i = 0; i < srcControlPoints.Length; i++)
         {
             dstControlPoints[i] = Convert(srcControlPoints[i]);
         }
         return(builder.CreateBlobAssetReference <ChiselPathBlob>(allocator));
     }
Exemple #7
0
 public static ChiselBlobAssetReference <ChiselCurve2DBlob> Convert(Curve2D curve, Allocator allocator)
 {
     using (var builder = new ChiselBlobBuilder(Allocator.Temp))
     {
         ref var root = ref builder.ConstructRoot <ChiselCurve2DBlob>();
         root.closed = curve.closed;
         var srcControlPoints = curve.controlPoints;
         var dstControlPoints = builder.Allocate(ref root.controlPoints, srcControlPoints.Length);
         // TODO: just use fixed-array + memcpy
         for (int i = 0; i < srcControlPoints.Length; i++)
         {
             dstControlPoints[i] = Convert(srcControlPoints[i]);
         }
         return(builder.CreateBlobAssetReference <ChiselCurve2DBlob>(allocator));
     }