Beispiel #1
0
 public unsafe void LoadFrom(MutableSpan <float> source)
 {
     fixed(void *ptr = &this.V0L)
     {
         Marshal.Copy(source.Data, source.Offset, (IntPtr)ptr, ScalarCount);
     }
 }
Beispiel #2
0
 public unsafe void CopyTo(MutableSpan <float> dest)
 {
     fixed(void *ptr = &this.V0L)
     {
         Marshal.Copy((IntPtr)ptr, dest.Data, dest.Offset, ScalarCount);
     }
 }
Beispiel #3
0
 public static void LoadFrom(this MutableSpan <int> data, ref Vector4 v)
 {
     data[0] = (int)v.X;
     data[1] = (int)v.Y;
     data[2] = (int)v.Z;
     data[3] = (int)v.W;
 }
Beispiel #4
0
 public static void SaveTo(this MutableSpan <int> data, ref Vector4 v)
 {
     v.X = data[0];
     v.Y = data[1];
     v.Z = data[2];
     v.W = data[3];
 }
Beispiel #5
0
        public static unsafe void CopyTo(Block8x8F *blockPtr, MutableSpan <byte> dest)
        {
            float *fPtr = (float *)blockPtr;

            for (int i = 0; i < ScalarCount; i++)
            {
                dest[i] = (byte)*fPtr;
                fPtr++;
            }
        }
Beispiel #6
0
        /// <summary>
        /// Converts all int values of src to float
        /// </summary>
        /// <param name="src">Source</param>
        /// <returns>A new <see cref="MutableSpan{T}"/> with float values</returns>
        public static MutableSpan <float> ConvertToFloat32MutableSpan(this MutableSpan <int> src)
        {
            MutableSpan <float> result = new MutableSpan <float>(src.TotalCount);

            for (int i = 0; i < src.TotalCount; i++)
            {
                result[i] = (float)src[i];
            }

            return(result);
        }
Beispiel #7
0
        /// <summary>
        /// Copy all values in src to a new <see cref="MutableSpan{T}"/> instance
        /// </summary>
        /// <typeparam name="T">Element type</typeparam>
        /// <param name="src">The source</param>
        /// <returns>A new instance of <see cref="MutableSpan{T}"/></returns>
        public static MutableSpan <T> Copy <T>(this MutableSpan <T> src)
        {
            MutableSpan <T> result = new MutableSpan <T>(src.TotalCount);

            for (int i = 0; i < src.TotalCount; i++)
            {
                result[i] = src[i];
            }

            return(result);
        }
Beispiel #8
0
        /// <summary>
        /// Add a scalar to all values of src
        /// </summary>
        /// <param name="src">The source</param>
        /// <param name="scalar">The scalar value to add</param>
        /// <returns>A new instance of <see cref="MutableSpan{T}"/></returns>
        public static MutableSpan <int> AddScalarToAllValues(this MutableSpan <int> src, int scalar)
        {
            MutableSpan <int> result = new MutableSpan <int>(src.TotalCount);

            for (int i = 0; i < src.TotalCount; i++)
            {
                result[i] = src[i] + scalar;
            }

            return(result);
        }
Beispiel #9
0
        /// <summary>
        /// Copy raw 32bit floating point data to dest
        /// </summary>
        /// <param name="dest">Destination</param>
        public unsafe void CopyTo(MutableSpan <int> dest)
        {
            fixed(Vector4 *ptr = &this.V0L)
            {
                float *fp = (float *)ptr;

                for (int i = 0; i < ScalarCount; i++)
                {
                    dest[i] = (int)fp[i];
                }
            }
        }
Beispiel #10
0
        /// <summary>
        /// Load raw 32bit floating point data from source
        /// </summary>
        /// <param name="source">Source</param>
        public unsafe void LoadFrom(MutableSpan <int> source)
        {
            fixed(Vector4 *ptr = &this.V0L)
            {
                float *fp = (float *)ptr;

                for (int i = 0; i < ScalarCount; i++)
                {
                    fp[i] = source[i];
                }
            }
        }
Beispiel #11
0
        public unsafe void CopyColorsTo(MutableSpan <byte> buffer, int stride, Block8x8F *tempBlockPtr)
        {
            this.TransformByteConvetibleColorValuesInto(ref *tempBlockPtr);

            float *src = (float *)tempBlockPtr;

            for (int i = 0; i < 8; i++)
            {
                buffer[0] = (byte)src[0];
                buffer[1] = (byte)src[1];
                buffer[2] = (byte)src[2];
                buffer[3] = (byte)src[3];
                buffer[4] = (byte)src[4];
                buffer[5] = (byte)src[5];
                buffer[6] = (byte)src[6];
                buffer[7] = (byte)src[7];
                buffer.AddOffset(stride);
                src += 8;
            }
        }
Beispiel #12
0
 public static unsafe void CopyTo(Block8x8F *blockPtr, MutableSpan <float> dest)
 {
     Marshal.Copy((IntPtr)blockPtr, dest.Data, dest.Offset, ScalarCount);
 }
Beispiel #13
0
 public static unsafe void LoadFrom(Block8x8F *blockPtr, MutableSpan <float> source)
 {
     Marshal.Copy(source.Data, source.Offset, (IntPtr)blockPtr, ScalarCount);
 }