瀏覽代碼

PixelFormat, PixelData and PixelVolume types are now auto-generated in C#

BearishSun 8 年之前
父節點
當前提交
5fa245888c

+ 3 - 1
.gitignore

@@ -22,4 +22,6 @@ Build
 *.opendb
 BsEngineConfig.h
 BsFrameworkConfig.h
-Source/Experimental
+Source/Experimental
+Source/MBansheeEngine/Generated
+Source/MBansheeEditor/Generated

+ 39 - 34
Source/BansheeCore/Include/BsPixelData.h

@@ -14,85 +14,84 @@ namespace bs
 	 */
 
 	/** Pixel formats usable by images, textures and render surfaces. */
-    enum PixelFormat
+    enum BS_SCRIPT_EXPORT(n:PixelFormat) PixelFormat
     {
         /** Unknown pixel format. */
-        PF_UNKNOWN = 0,
+        PF_UNKNOWN				BS_SCRIPT_EXPORT(ex:true) = 0,
         /** 8-bit pixel format, all bits red. */
-        PF_R8 = 1,
+        PF_R8					BS_SCRIPT_EXPORT(n:R8) = 1,
 		/** 2 byte pixel format, 1 byte red, 1 byte green. */
-		PF_R8G8 = 2,
+		PF_R8G8					BS_SCRIPT_EXPORT(n:R8G8) = 2,
         /** 24-bit pixel format, 8 bits for red, green and blue. */
-        PF_R8G8B8 = 3,
+        PF_R8G8B8				BS_SCRIPT_EXPORT(n:R8G8B8) = 3,
         /** 24-bit pixel format, 8 bits for blue, green and red. */
-        PF_B8G8R8 = 4,
+        PF_B8G8R8				BS_SCRIPT_EXPORT(n:B8G8R8) = 4,
         /** 32-bit pixel format, 8 bits for blue, green, red and alpha. */
-        PF_B8G8R8A8 = 7,
+        PF_B8G8R8A8				BS_SCRIPT_EXPORT(n:B8G8R8A8) = 7,
 		/** 32-bit pixel format, 8 bits for red, green, blue and alpha. */
-		PF_R8G8B8A8 = 8, 
+		PF_R8G8B8A8				BS_SCRIPT_EXPORT(n:R8G8B8A8) = 8,
         /** DXT1/BC1 format containing opaque RGB or 1-bit alpha RGB. 4 bits per pixel. */
-        PF_BC1 = 13,
+        PF_BC1					BS_SCRIPT_EXPORT(n:BC1) = 13,
 		/** DXT3/BC2 format containing RGB with premultiplied alpha. 4 bits per pixel. */
-		PF_BC1a = 14,
+		PF_BC1a					BS_SCRIPT_EXPORT(ex:true) = 14,
         /** DXT3/BC2 format containing RGB with explicit alpha. 8 bits per pixel. */
-        PF_BC2 = 15,
+        PF_BC2					BS_SCRIPT_EXPORT(n:BC2) = 15,
         /** DXT5/BC2 format containing RGB with explicit alpha. 8 bits per pixel. Better alpha gradients than BC2. */
-        PF_BC3 = 16,
+        PF_BC3					BS_SCRIPT_EXPORT(n:BC3) = 16,
 		/** One channel compressed format. 4 bits per pixel. */
-		PF_BC4 = 17,
+		PF_BC4					BS_SCRIPT_EXPORT(n:BC4) = 17,
 		/** Two channel compressed format. 8 bits per pixel. */
-		PF_BC5 = 18,
+		PF_BC5					BS_SCRIPT_EXPORT(n:BC5) = 18,
 		/** Format storing RGB in half (16-bit) floating point format usable for HDR. 8 bits per pixel. */
-		PF_BC6H = 19,
+		PF_BC6H					BS_SCRIPT_EXPORT(n:BC6H) = 19,
 		/** 
 		 * Format storing RGB with optional alpha channel. Similar to BC1/BC2/BC3 formats but with higher quality and 
 		 * higher decompress overhead. 8 bits per pixel. 
 		 */
-		PF_BC7 = 20,
+		PF_BC7					BS_SCRIPT_EXPORT(n:BC7) = 20,
 		/** 16-bit pixel format, 16 bits (float) for red. */
-        PF_FLOAT16_R = 21,
+        PF_FLOAT16_R			BS_SCRIPT_EXPORT(n:Float16_R) = 21,
 		/** 32-bit, 2-channel s10e5 floating point pixel format, 16-bit red, 16-bit green. */
-		PF_FLOAT16_RG = 22,
+		PF_FLOAT16_RG			BS_SCRIPT_EXPORT(n:Float16_RG) = 22,
         /** 48-bit pixel format, 16 bits (float) for red, 16 bits (float) for green, 16 bits (float) for blue. */
-        PF_FLOAT16_RGB = 23,
+        PF_FLOAT16_RGB			BS_SCRIPT_EXPORT(n:Float16_RGB) = 23,
         /** 
 		 * 64-bit pixel format, 16 bits (float) for red, 16 bits (float) for green, 16 bits (float) for blue, 16 bits 
 		 * (float) for alpha. 
 		 */
-        PF_FLOAT16_RGBA = 24,
+        PF_FLOAT16_RGBA			BS_SCRIPT_EXPORT(n:Float16_RGBA) = 24,
 		/** 32-bit pixel format, 32 bits (float) for red. */
-        PF_FLOAT32_R = 25,
+        PF_FLOAT32_R			BS_SCRIPT_EXPORT(n:Float32_R) = 25,
 		/** 64-bit, 2-channel floating point pixel format, 32-bit red, 32-bit green. */
-		PF_FLOAT32_RG = 26,
+		PF_FLOAT32_RG			BS_SCRIPT_EXPORT(n:Float32_RG) = 26,
         /** 96-bit pixel format, 32 bits (float) for red, 32 bits (float) for green, 32 bits (float) for blue. */
-        PF_FLOAT32_RGB = 27,
+        PF_FLOAT32_RGB			BS_SCRIPT_EXPORT(n:Float32_RGB) = 27,
         /** 
 		 * 128-bit pixel format, 32 bits (float) for red, 32 bits (float) for green, 32 bits (float) for blue, 32 bits 
 		 * (float) for alpha. 
 		 */
-        PF_FLOAT32_RGBA = 28,
+        PF_FLOAT32_RGBA			BS_SCRIPT_EXPORT(n:Float32_RGBA) = 28,
 		/** Depth stencil format, 32bit depth, 8bit stencil + 24 unused. */
-		PF_D32_S8X24 = 29,
+		PF_D32_S8X24			BS_SCRIPT_EXPORT(n:D32_S8X24) = 29,
 		/** Depth stencil fomrat, 24bit depth + 8bit stencil. */
-		PF_D24S8 = 30,
+		PF_D24S8				BS_SCRIPT_EXPORT(n:D24S8) = 30,
 		/** Depth format, 32bits. */
-		PF_D32 = 31,
+		PF_D32					BS_SCRIPT_EXPORT(n:D32) = 31,
 		/** Depth format, 16bits. */
-		PF_D16 = 32,
+		PF_D16					BS_SCRIPT_EXPORT(n:D16) = 32,
 		/** 
 		 * 32-bit float format, 11 bits (float) for red, 11 bits (float) for green, 10 bits (float) for blue. Framebuffer 
 		 * only format, not for CPU use. 
 		 */
-		PF_FLOAT_R11G11B10 = 33,
+		PF_FLOAT_R11G11B10		BS_SCRIPT_EXPORT(ex:true) = 33,
 		/** 
 		 * 32-bit unsigned normalized format, 10 bits (float) for red, 10 bits (float) for green, 10 bits (float) for blue, 
 		 * and two bits for alpha. Framebuffer only format, not for CPU use.
 		 */
-		PF_UNORM_R10G10B10A2 = 34,
+		PF_UNORM_R10G10B10A2	BS_SCRIPT_EXPORT(ex:true) = 34,
 		/** Number of pixel formats currently defined. */
-        PF_COUNT = 35
+        PF_COUNT				BS_SCRIPT_EXPORT(ex:true) = 35
     };
-	typedef Vector<PixelFormat> PixelFormatList;
 
 	/**	Flags defining some properties of pixel formats. */
     enum PixelFormatFlags {
@@ -156,7 +155,7 @@ namespace bs
 	 *
 	 * @see		GpuResourceData
 	 */
-    class BS_CORE_EXPORT PixelData : public GpuResourceData
+    class BS_CORE_EXPORT BS_SCRIPT_EXPORT(n:PixelData) PixelData : public GpuResourceData
 	{
     public:
 		PixelData();
@@ -181,12 +180,14 @@ namespace bs
 		 * Returns the number of pixels that offsets one row from another. This can be "width", but doesn't have to be as
 		 * some buffers require padding.
 		 */
+		BS_SCRIPT_EXPORT(n:RawRowPitch,pr:getter)
 		UINT32 getRowPitch() const { return mRowPitch; }
 
 		/**
 		 * Returns the number of pixels that offsets one depth slice from another. This can be "width * height", but 
 		 * doesn't have to be as some buffers require padding.
 		 */
+		BS_SCRIPT_EXPORT(n:RawSlicePitch,pr:getter)
 		UINT32 getSlicePitch() const { return mSlicePitch; }
 
 		/**
@@ -214,6 +215,7 @@ namespace bs
         UINT32 getSliceSkip() const { return mSlicePitch - (getHeight() * mRowPitch); }
 
 		/** Returns the pixel format used by the internal buffer for storing the pixels. */
+		BS_SCRIPT_EXPORT(n:Format,pr:getter)
 		PixelFormat getFormat() const { return mFormat; }
 
 		/**	Returns width of the buffer in pixels. */
@@ -262,11 +264,13 @@ namespace bs
 		UINT32 getBack() const { return mExtents.back; }
 
 		/** Returns extents of the pixel volume this object is capable of holding. */
+		BS_SCRIPT_EXPORT(n:Extents,pr:getter)
 		PixelVolume getExtents() const { return mExtents; }
 
 		/** 
 		 * Return whether this buffer is laid out consecutive in memory (meaning the pitches are equal to the dimensions). 
 		 */
+		BS_SCRIPT_EXPORT(n:RawIsConsecutive,pr:getter)
         bool isConsecutive() const 
 		{ 
 			return mRowPitch == getWidth() && mSlicePitch == getWidth()*getHeight(); 
@@ -276,6 +280,7 @@ namespace bs
       	UINT32 getConsecutiveSize() const;
 
 		/**	Return the size (in bytes) of the buffer this image requires. */
+		BS_SCRIPT_EXPORT(n:RawSize,pr:getter)
       	UINT32 getSize() const;
 
 		/**
@@ -334,7 +339,7 @@ namespace bs
 		 * Constructs a new object with an internal buffer capable of holding "extents" volume of pixels, where each pixel
 		 * is of the specified pixel format. Extent offsets are also stored, but are not used internally.
 		 */
-		static SPtr<PixelData> create(const PixelVolume &extents, PixelFormat pixelFormat);
+		static SPtr<PixelData> create(const PixelVolume& extents, PixelFormat pixelFormat);
 
 		/**
 		 * Constructs a new object with an internal buffer capable of holding volume of pixels described by provided width,

+ 1 - 1
Source/BansheeCore/Include/BsPixelVolume.h

@@ -11,7 +11,7 @@ namespace bs
 	 */
 
 	/**	Represents a 3D region of pixels used for referencing pixel data. */
-	struct BS_CORE_EXPORT PixelVolume
+	struct BS_CORE_EXPORT BS_SCRIPT_EXPORT(pl:true,n:PixelVolume) PixelVolume
 	{
 		UINT32 left, top, right, bottom, front, back;
 

+ 1 - 2
Source/MBansheeEngine/MBansheeEngine.csproj

@@ -165,7 +165,6 @@
     <Compile Include="Physics\SliderJoint.cs" />
     <Compile Include="Physics\SphereCollider.cs" />
     <Compile Include="Physics\SphericalJoint.cs" />
-    <Compile Include="Utility\PixelData.cs" />
     <Compile Include="Utility\PixelUtility.cs" />
     <Compile Include="Utility\PlainText.cs" />
     <Compile Include="Scene\Prefab.cs" />
@@ -213,7 +212,7 @@
     <Compile Include="Rendering\TextureCube.cs" />
     <Compile Include="Utility\Time.cs" />
     <Compile Include="Input\VirtualInput.cs" />
-	<Compile Include="Generated\*.cs"/>
+    <Compile Include="Generated\*.cs" />
   </ItemGroup>
   <ItemGroup />
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

+ 0 - 449
Source/MBansheeEngine/Utility/PixelData.cs

@@ -1,449 +0,0 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-using System;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-namespace BansheeEngine
-{
-    /** @addtogroup Utility
-     *  @{
-     */
-
-    /// <summary>
-    /// Pixel formats usable by images, textures and render surfaces.
-    /// </summary>
-    public enum PixelFormat // Note: Must match C++ enum PixelFormat
-    {
-        /// <summary>
-        /// 8-bit pixel format, all bits red.
-        /// </summary>
-        R8 = 1,
-        /// <summary>
-        /// 2 byte pixel format, 1 byte red, 1 byte green.
-        /// </summary>
-        R8G8 = 2,
-        /// <summary>
-        /// 24-bit pixel format, 8 bits for red, green and blue.
-        /// </summary>
-        R8G8B8 = 3,
-        /// <summary>
-        /// 32-bit pixel format, 8 bits for red, green, blue and alpha.
-        /// </summary>
-        R8G8B8A8 = 8,
-        /// <summary>
-        /// DXT1/BC1 format containing opaque RGB or 1-bit alpha RGB. 4 bits per pixel.
-        /// </summary>
-        BC1 = 13,
-        /// <summary>
-        /// DXT3/BC2 format containing RGB with premultiplied alpha. 4 bits per pixel.
-        /// </summary>
-        BC1a = 14,
-        /// <summary>
-        /// DXT3/BC2 format containing RGB with explicit alpha. 8 bits per pixel.
-        /// </summary>
-        BC2 = 15,
-        /// <summary>
-        /// DXT5/BC2 format containing RGB with explicit alpha. 8 bits per pixel. Better alpha gradients than BC2.
-        /// </summary>
-        BC3 = 16,
-        /// <summary>
-        /// One channel compressed format. 4 bits per pixel.
-        /// </summary>
-        BC4 = 17,
-        /// <summary>
-        /// Two channel compressed format. 8 bits per pixel.
-        /// </summary>
-        BC5 = 18,
-        /// <summary>
-        /// Format storing RGB in half (16-bit) floating point format usable for HDR. 8 bits per pixel.
-        /// </summary>
-        BC6H = 19,
-        /// <summary>
-        /// Format storing RGB with optional alpha channel. Similar to BC1/BC2/BC3 formats but with higher quality and 
-        /// higher decompress overhead. 8 bits per pixel.
-        /// </summary>
-        BC7 = 20,
-        /// <summary>
-        /// 16-bit 1-channel s10e5 floating point pixel format, 16 bits (float) for red.
-        /// </summary>
-        Float16_R = 21,
-        /// <summary>
-        /// 32-bit, 2-channel s10e5 floating point pixel format, 16-bits (float) for red, 16-bits (float) for green.
-        /// </summary>
-        Float16_RG = 22,
-        /// <summary>
-        /// 48-bit, 3-channel s10e5 floating point pixel format,, 16 bits (float) for red, 16 bits (float) for green, 
-        /// 16 bits (float) for blue.
-        /// </summary>
-        Float16_RGB = 23,
-        /// <summary>
-        /// 64-bit, 4-channel s10e5 floating point pixel format, 16 bits (float) for red, 16 bits (float) for green, 
-        /// 16 bits (float) for blue, 16 bits (float) for alpha.
-        /// </summary>
-        Float16_RGBA = 24,
-        /// <summary>
-        /// 32-bit pixel format, 32 bits (float) for red.
-        /// </summary>
-        Float32_R = 25,
-        /// <summary>
-        /// 64-bit, pixel format, 32-bits (float) for red, 32-bits (float) for green.
-        /// </summary>
-        Float32_RG = 26,
-        /// <summary>
-        /// 96-bit pixel format, 32 bits (float) for red, 32 bits (float) for green, 32 bits (float) for blue.
-        /// </summary>
-        Float32_RGB = 27,
-        /// <summary>
-        /// 128-bit pixel format, 32 bits (float) for red, 32 bits (float) for green, 32 bits (float) for blue, 
-        /// 32 bits (float) for alpha.
-        /// </summary>
-        Float32_RGBA = 28,
-        /// <summary>
-        /// Depth stencil format, 32bit depth, 8bit stencil + 24 unused.
-        /// </summary>
-        D32_S8X24 = 29,
-        /// <summary>
-        /// Depth stencil format, 24bit depth + 8bit stencil.
-        /// </summary>
-        D24S8 = 30,
-        /// <summary>
-        /// Depth format, 32bits.
-        /// </summary>
-        D32 = 31,
-        /// <summary>
-        /// Depth format, 16bits.
-        /// </summary>
-        D16 = 32
-    };
-
-    /// <summary>
-    /// A buffer describing a volume (3D), image (2D) or line (1D) of pixels in memory. Pixels are stored as a succession 
-    /// of "depth" slices, each containing "height" rows of "width" pixels.
-    /// </summary>
-    public sealed class PixelData : ScriptObject
-    {
-        /// <summary>
-        /// Width, height and depth of the pixels this object is capable of holding.
-        /// </summary>
-        public PixelVolume Extents
-        {
-            get
-            {
-                PixelVolume volume;
-                Internal_GetExtents(mCachedPtr, out volume);
-                return volume;
-            }
-        }
-
-        /// <summary>
-        /// Format of the pixels in the buffer.
-        /// </summary>
-        public PixelFormat Format
-        {
-            get
-            {
-                PixelFormat format;
-                Internal_GetFormat(mCachedPtr, out format);
-                return format;
-            }
-        }
-
-        /// <summary>
-        /// Returns number of bytes per a row of pixels.
-        /// </summary>
-        public int RawRowPitch
-        {
-            get
-            {
-                int rowPitch;
-                Internal_GetRowPitch(mCachedPtr, out rowPitch);
-                return rowPitch;
-            }
-        }
-
-        /// <summary>
-        /// Returns number of bytes per a 2D slice/plane of pixels.
-        /// </summary>
-        public int RawSlicePitch
-        {
-            get
-            {
-                int slicePitch;
-                Internal_GetSlicePitch(mCachedPtr, out slicePitch);
-                return slicePitch;
-            }
-        }
-
-        /// <summary>
-        /// Returns total number of bytes used by all the pixels.
-        /// </summary>
-        public int RawSize
-        {
-            get
-            {
-                int size;
-                Internal_GetSize(mCachedPtr, out size);
-                return size;
-            }
-        }
-
-        /// <summary>
-        /// Checks are the pixels in the buffer consecutive. If this is false then the buffer has padding and you should
-        /// check <see cref="RawRowPitch"/> and <see cref="RawSlicePitch"/> when accessing it directly.
-        /// </summary>
-        public bool RawIsConsecutive
-        {
-            get
-            {
-                bool isConsecutive;
-                Internal_GetIsConsecutive(mCachedPtr, out isConsecutive);
-                return isConsecutive;
-            }
-        }
-
-        /// <summary>
-        /// Constructor for internal use by the runtime.
-        /// </summary>
-        private PixelData()
-        { }
-
-        /// <summary>
-        /// Creates a new pixel data buffer capable of storing the specified amount of pixels.
-        /// </summary>
-        /// <param name="volume">Width, height and depth determining number of pixels to store.</param>
-        /// <param name="format">Format of individual pixels.</param>
-        public PixelData(PixelVolume volume, PixelFormat format = PixelFormat.R8G8B8A8)
-        {
-            Internal_CreateInstance(this, ref volume, format);
-        }
-
-        /// <summary>
-        /// Creates a new 2D pixel data buffer capable of storing the specified amount of pixels.
-        /// </summary>
-        /// <param name="width">Number of pixels in each row.</param>
-        /// <param name="height">Number of pixels in each column.</param>
-        /// <param name="format">Format of individual pixels.</param>
-        public PixelData(int width, int height, PixelFormat format = PixelFormat.R8G8B8A8)
-        {
-            PixelVolume volume = new PixelVolume(0, 0, width, height);
-
-            Internal_CreateInstance(this, ref volume, format);
-        }
-
-        /// <summary>
-        /// Creates a new 3D pixel data buffer capable of storing the specified amount of pixels.
-        /// </summary>
-        /// <param name="width">Number of pixels in each row.</param>
-        /// <param name="height">Number of pixels in each column.</param>
-        /// <param name="depth">Number of 2D slices.</param>
-        /// <param name="format">Format of individual pixels.</param>
-        public PixelData(int width, int height, int depth, PixelFormat format = PixelFormat.R8G8B8A8)
-        {
-            PixelVolume volume = new PixelVolume(0, 0, 0, width, height, depth);
-
-            Internal_CreateInstance(this, ref volume, format);
-        }
-
-        /// <summary>
-        /// Returns a pixel at the specified location in the buffer.
-        /// </summary>
-        /// <param name="x">X coordinate of the pixel.</param>
-        /// <param name="y">Y coordinate of the pixel.</param>
-        /// <param name="z">Z coordinate of the pixel.</param>
-        /// <returns>Value of the pixel, or undefined value if coordinates are out of range.</returns>
-        public Color GetPixel(int x, int y, int z = 0)
-        {
-            Color pixel;
-            Internal_GetPixel(mCachedPtr, x, y, z, out pixel);
-            return pixel;
-        }
-
-        /// <summary>
-        /// Sets a pixel at the specified location in the buffer.
-        /// </summary>
-        /// <param name="color">Color of the pixel to set.</param>
-        /// <param name="x">X coordinate of the pixel.</param>
-        /// <param name="y">Y coordinate of the pixel.</param>
-        /// <param name="z">Z coordinate of the pixel.</param>
-        public void SetPixel(Color color, int x, int y, int z = 0)
-        {
-            Internal_SetPixel(mCachedPtr, x, y, z, ref color);
-        }
-
-        /// <summary>
-        /// Returns values of all pixels. 
-        /// </summary>
-        /// <returns>All pixels in the buffer ordered consecutively. Pixels are stored as a succession of "depth" slices, 
-        ///          each containing "height" rows of "width" pixels.</returns>
-        public Color[] GetPixels()
-        {
-            Color[] pixels;
-            Internal_GetPixels(mCachedPtr, out pixels);
-            return pixels;
-        }
-
-        /// <summary>
-        /// Sets all pixels in the buffer. Caller must ensure that number of pixels match the extends of the buffer.
-        /// </summary>
-        /// <param name="pixels">All pixels to set ordered consecutively. Pixels are stored as a succession of "depth" 
-        ///                      slices, each containing "height" rows of "width" pixels.</param>
-        public void SetPixels(Color[] pixels)
-        {
-            Internal_SetPixels(mCachedPtr, pixels);
-        }
-
-        /// <summary>
-        /// Returns all pixels in the buffer as raw bytes.
-        /// </summary>
-        /// <returns>Raw pixel bytes. It is up to the caller to interpret the pixel format and account for potential 
-        ///          row and slice pitch values.</returns>
-        public byte[] GetRawPixels()
-        {
-            byte[] pixels;
-            Internal_GetRawPixels(mCachedPtr, out pixels);
-            return pixels;
-        }
-
-        /// <summary>
-        /// Sets all pixels in the buffer as raw bytes.
-        /// </summary>
-        /// <param name="pixels">Raw pixel bytes. It is up to the caller to set the proper pixel format and account for 
-        ///                      potential row and slice pitch values.</param>
-        public void SetRawPixels(byte[] pixels)
-        {
-            Internal_SetRawPixels(mCachedPtr, pixels);
-        }
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_CreateInstance(PixelData instance, ref PixelVolume volume, PixelFormat format);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_GetPixel(IntPtr thisPtr, int x, int y, int z, out Color value);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_SetPixel(IntPtr thisPtr, int x, int y, int z, ref Color value);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_GetPixels(IntPtr thisPtr, out Color[] value);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_SetPixels(IntPtr thisPtr, Color[] value);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_GetRawPixels(IntPtr thisPtr, out byte[] value);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_SetRawPixels(IntPtr thisPtr, byte[] value);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_GetExtents(IntPtr thisPtr, out PixelVolume value);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_GetFormat(IntPtr thisPtr, out PixelFormat value);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_GetRowPitch(IntPtr thisPtr, out int value);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_GetSlicePitch(IntPtr thisPtr, out int value);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_GetSize(IntPtr thisPtr, out int value);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_GetIsConsecutive(IntPtr thisPtr, out bool value);
-    }
-
-    /// <summary>
-    /// Represents a 3D region of pixels used for referencing pixel data.
-    /// </summary>
-    [StructLayout(LayoutKind.Sequential)]
-    public struct PixelVolume // Note: Must match C++ class PixelVolume
-    {
-        private int left, top, right, bottom, front, back;
-
-        /// <summary>
-        /// Returns the left border of the pixel region (minimal X).
-        /// </summary>
-        public int Left { get { return left; } }
-
-        /// <summary>
-        /// Returns the right border of the pixel region (maximal X).
-        /// </summary>
-        public int Right { get { return right; } }
-
-        /// <summary>
-        /// Returns the top border of the pixel region (minimal Y).
-        /// </summary>
-        public int Top { get { return top; } }
-
-        /// <summary>
-        /// Returns the bottom border of the pixel region (maximal Y).
-        /// </summary>
-        public int Bottom { get { return bottom; } }
-
-        /// <summary>
-        /// Returns the front border of the pixel region (minimal Z).
-        /// </summary>
-        public int Front { get { return front; } }
-
-        /// <summary>
-        /// Returns the back border of the pixel region (maximal Z).
-        /// </summary>
-        public int Back { get { return back; } }
-
-        /// <summary>
-        /// Returns the number of pixels between right and left borders of the volume.
-        /// </summary>
-        public int Width { get { return right - left; } }
-
-        /// <summary>
-        /// Returns the number of pixels between bottom and top borders of the volume.
-        /// </summary>
-        public int Height { get { return bottom - top; } }
-
-        /// <summary>
-        /// Returns the number of pixels between back and front borders of the volume.
-        /// </summary>
-        public int Depth { get { return back - front; } }
-
-        /// <summary>
-        /// Creates a new 2D region.
-        /// </summary>
-        /// <param name="left">Left border of the region.</param>
-        /// <param name="top">Top border of the region.</param>
-        /// <param name="right">Right border of the region. Must be larger than left border.</param>
-        /// <param name="bottom">Bottom border of the region. Must be larger than top border.</param>
-        public PixelVolume(int left, int top, int right, int bottom)
-        {
-            this.left = left;
-            this.right = right;
-            this.top = top;
-            this.bottom = bottom;
-            this.front = 0;
-            this.back = 1;
-        }
-
-        /// <summary>
-        /// Creates a new 3D region.
-        /// </summary>
-        /// <param name="left">Left border of the region.</param>
-        /// <param name="top">Top border of the region.</param>
-        /// <param name="front">Front border of the region.</param>
-        /// <param name="right">Right border of the region. Must be larger than left border.</param>
-        /// <param name="bottom">Bottom border of the region. Must be larger than top border.</param>
-        /// <param name="back">Back border of the region. Must be larger than back border.</param>
-        public PixelVolume(int left, int top, int front, int right, int bottom, int back)
-        {
-            this.left = left;
-            this.right = right;
-            this.top = top;
-            this.bottom = bottom;
-            this.front = front;
-            this.back = back;
-        }
-    };
-
-    /** @} */
-}

+ 12 - 2
Source/SBansheeEngine/CMakeSources.cmake

@@ -101,7 +101,6 @@ set(BS_SBANSHEEENGINE_INC_WRAPPERS
 	"Include/BsScriptMeshData.h"
 	"Include/BsScriptPhysicsMaterial.h"
 	"Include/BsScriptPhysicsMesh.h"
-	"Include/BsScriptPixelData.h"
 	"Include/BsScriptPixelUtility.h"
 	"Include/BsScriptPlainText.h"
 	"Include/BsScriptPrefab.h"
@@ -239,7 +238,6 @@ set(BS_SBANSHEEENGINE_SRC_WRAPPERS
 	"Source/BsScriptMeshData.cpp"
 	"Source/BsScriptPhysicsMaterial.cpp"
 	"Source/BsScriptPhysicsMesh.cpp"
-	"Source/BsScriptPixelData.cpp"
 	"Source/BsScriptPixelUtility.cpp"
 	"Source/BsScriptPlainText.cpp"
 	"Source/BsScriptPrefab.cpp"
@@ -323,6 +321,14 @@ set(BS_SBANSHEEENGINE_INC_RTTI
 	"Include/BsManagedResourceMetaDataRTTI.h"
 )
 
+set(BS_SBANSHEEENGINE_INC_EXTENSIONS
+	"Include/BsPixelDataEx.h"
+)
+
+set(BS_SBANSHEEENGINE_SRC_EXTENSIONS
+	"Source/BsPixelDataEx.cpp"
+)
+
 source_group("Header Files" FILES ${BS_SBANSHEEENGINE_INC_NOFILTER})
 source_group("Source Files\\Wrappers\\GUI" FILES ${BS_SBANSHEEENGINE_SRC_WRAPPERS_GUI})
 source_group("Header Files\\Serialization\\RTTI" FILES ${BS_SBANSHEEENGINE_INC_SERIALIZATION_RTTI})
@@ -335,6 +341,8 @@ source_group("Source Files\\Wrappers" FILES ${BS_SBANSHEEENGINE_SRC_WRAPPERS})
 source_group("Header Files\\Serialization" FILES ${BS_SBANSHEEENGINE_INC_SERIALIZATION})
 source_group("Source Files" FILES ${BS_SBANSHEEENGINE_SRC_NOFILTER})
 source_group("Header Files\\RTTI" FILES ${BS_SBANSHEEENGINE_INC_RTTI})
+source_group("Header Files\\Extensions" FILES ${BS_SBANSHEEENGINE_INC_EXTENSIONS})
+source_group("Source Files\\Extensions" FILES ${BS_SBANSHEEENGINE_SRC_EXTENSIONS})
 
 set(BS_SBANSHEEENGINE_SRC
 	${BS_SBANSHEEENGINE_INC_NOFILTER}
@@ -349,4 +357,6 @@ set(BS_SBANSHEEENGINE_SRC
 	${BS_SBANSHEEENGINE_INC_SERIALIZATION}
 	${BS_SBANSHEEENGINE_SRC_NOFILTER}
 	${BS_SBANSHEEENGINE_INC_RTTI}
+	${BS_SBANSHEEENGINE_INC_EXTENSIONS}
+	${BS_SBANSHEEENGINE_SRC_EXTENSIONS}
 )

+ 87 - 0
Source/SBansheeEngine/Include/BsPixelDataEx.h

@@ -0,0 +1,87 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsScriptEnginePrerequisites.h"
+#include "BsColor.h"
+#include "BsPixelData.h"
+
+namespace bs
+{
+	/** @addtogroup ScriptInteropEngine
+	 *  @{
+	 */
+
+	/** Extension class for PixelData, for adding additional functionality for the script version of PixelData. */
+	class BS_SCRIPT_EXPORT(e:PixelData) PixelDataEx
+	{
+	public:
+		BS_SCRIPT_EXPORT(ec:PixelData)
+		static SPtr<PixelData> create(const PixelVolume& volume, PixelFormat format = PF_B8G8R8A8);
+
+		BS_SCRIPT_EXPORT(ec:PixelData)
+		static SPtr<PixelData> create(UINT32 width, UINT32 height, UINT32 depth = 1, PixelFormat pixelFormat = PF_B8G8R8A8);
+
+		/**
+		 * Returns a pixel at the specified location in the buffer.
+		 * 
+		 * @param[in] x		X coordinate of the pixel.
+		 * @param[in] y		Y coordinate of the pixel.
+		 * @param[in] z		Z coordinate of the pixel.
+		 * @return			Value of the pixel, or undefined value if coordinates are out of range.
+		 */
+		BS_SCRIPT_EXPORT(e:PixelData,n:GetPixel)
+		static Color getPixel(const SPtr<PixelData>& thisPtr, int x, int y, int z = 0);
+		
+		/**
+		 * Sets a pixel at the specified location in the buffer.
+		 * 
+		 * @param[in] value		Color of the pixel to set.
+		 * @param[in] x			X coordinate of the pixel.
+		 * @param[in] y			Y coordinate of the pixel.
+		 * @param[in] z			Z coordinate of the pixel.
+		 */
+		BS_SCRIPT_EXPORT(e:PixelData,n:SetPixel)
+		static void setPixel(const SPtr<PixelData>& thisPtr, const Color& value, int x, int y, int z = 0);
+		
+		/**
+		 * Returns values of all pixels. 
+		 *
+		 * @return	All pixels in the buffer ordered consecutively. Pixels are stored as a succession of "depth" slices, 
+		 *			each containing "height" rows of "width" pixels.
+		 */
+		BS_SCRIPT_EXPORT(e:PixelData,n:GetPixels)
+		static Vector<Color> getPixels(const SPtr<PixelData>& thisPtr);
+		
+		/**
+		 * Sets all pixels in the buffer.Caller must ensure that number of pixels match the extends of the buffer.
+		 *
+		 * @param value	All pixels in the buffer ordered consecutively. Pixels are stored as a succession of "depth" slices, 
+		 *				each containing "height" rows of "width" pixels.
+		 */
+		BS_SCRIPT_EXPORT(e:PixelData,n:SetPixels)
+		static void setPixels(const SPtr<PixelData>& thisPtr, const Vector<Color>& value);
+		
+		/**
+		 * Returns all pixels in the buffer as raw bytes.
+		 *
+		 * @return	Raw pixel bytes. It is up to the caller to interpret the pixel format and account for potential 
+         *			row and slice pitch values.
+		 */
+		BS_SCRIPT_EXPORT(e:PixelData,n:GetRawPixels)
+		static Vector<char> getRawPixels(const SPtr<PixelData>& thisPtr);
+		
+		/**
+		 * Sets all pixels in the buffer as raw bytes.
+		 *
+		 * @param[in] value		Raw pixel bytes. It is up to the caller to interpret the pixel format and account for 
+		 *						potential row and slice pitch values.
+		 */
+		BS_SCRIPT_EXPORT(e:PixelData,n:SetRawPixels)
+		static void setRawPixels(const SPtr<PixelData>& thisPtr, const Vector<char>& value);
+
+		static bool checkIsLocked(const SPtr<PixelData>& thisPtr);
+	};
+
+	/** @} */
+}

+ 0 - 59
Source/SBansheeEngine/Include/BsScriptPixelData.h

@@ -1,59 +0,0 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsScriptEnginePrerequisites.h"
-#include "BsScriptObject.h"
-#include "BsPixelData.h"
-#include "BsColor.h"
-
-namespace bs
-{
-	/** @addtogroup ScriptInteropEngine
-	 *  @{
-	 */
-
-	/**	Interop class between C++ & CLR for PixelData. */
-	class BS_SCR_BE_EXPORT ScriptPixelData : public ScriptObject <ScriptPixelData>
-	{
-	public:
-		SCRIPT_OBJ(ENGINE_ASSEMBLY, "BansheeEngine", "PixelData")
-
-		/**	Returns the internal wrapped pixel data. */
-		SPtr<PixelData> getInternalValue() const { return mPixelData; }
-
-		/** Creates a new managed pixel data instance that wraps the provided native pixel data instance. */
-		static MonoObject* create(const SPtr<PixelData>& pixelData);
-
-	private:
-		ScriptPixelData(MonoObject* managedInstance);
-		~ScriptPixelData();
-
-		/**	Initializes the object. Must be called after construction and before use. */
-		void initialize(const SPtr<PixelData>& pixelData);
-
-		/** Checks is the underlying pixel data of the provided object locked. When locked pixel data cannot be accessed. */
-		static bool checkIsLocked(ScriptPixelData* thisPtr);
-
-		SPtr<PixelData> mPixelData;
-
-		/************************************************************************/
-		/* 								CLR HOOKS						   		*/
-		/************************************************************************/
-		static void internal_createInstance(MonoObject* instance, PixelVolume* volume, PixelFormat format);
-		static void internal_getPixel(ScriptPixelData* thisPtr, int x, int y, int z, Color* value);
-		static void internal_setPixel(ScriptPixelData* thisPtr, int x, int y, int z, Color* value);
-		static void internal_getPixels(ScriptPixelData* thisPtr, MonoArray** value);
-		static void internal_setPixels(ScriptPixelData* thisPtr, MonoArray* value);
-		static void internal_getRawPixels(ScriptPixelData* thisPtr, MonoArray** value);
-		static void internal_setRawPixels(ScriptPixelData* thisPtr, MonoArray* value);
-		static void internal_getExtents(ScriptPixelData* thisPtr, PixelVolume* value);
-		static void internal_getFormat(ScriptPixelData* thisPtr, PixelFormat* value);
-		static void internal_getRowPitch(ScriptPixelData* thisPtr, int* value);
-		static void internal_getSlicePitch(ScriptPixelData* thisPtr, int* value);
-		static void internal_getSize(ScriptPixelData* thisPtr, int* value);
-		static void internal_getIsConsecutive(ScriptPixelData* thisPtr, bool* value);
-	};
-
-	/** @} */
-}

+ 91 - 0
Source/SBansheeEngine/Source/BsPixelDataEx.cpp

@@ -0,0 +1,91 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#include "BsPixelDataEx.h"
+#include "BsScriptColor.h"
+
+namespace bs
+{
+	SPtr<PixelData> PixelDataEx::create(const PixelVolume& volume, PixelFormat format)
+	{
+		SPtr<PixelData> pixelData = bs_shared_ptr_new<PixelData>(volume, format);
+		pixelData->allocateInternalBuffer();
+
+		return pixelData;
+	}
+
+	SPtr<PixelData> PixelDataEx::create(UINT32 width, UINT32 height, UINT32 depth, PixelFormat format)
+	{
+		SPtr<PixelData> pixelData = bs_shared_ptr_new<PixelData>(width, height, depth, format);
+		pixelData->allocateInternalBuffer();
+
+		return pixelData;
+	}
+
+	Color PixelDataEx::getPixel(const SPtr<PixelData>& thisPtr, int x, int y, int z)
+	{
+		if (!checkIsLocked(thisPtr))
+			return thisPtr->getColorAt(x, y, z);
+		else
+			return Color();
+	}
+
+	void PixelDataEx::setPixel(const SPtr<PixelData>& thisPtr, const Color& value, int x, int y, int z)
+	{
+		if (!checkIsLocked(thisPtr))
+			thisPtr->setColorAt(value, x, y, z);
+	}
+
+	Vector<Color> PixelDataEx::getPixels(const SPtr<PixelData>& thisPtr)
+	{
+		if (!checkIsLocked(thisPtr))
+			return Vector<Color>();
+
+		return thisPtr->getColors();
+	}
+
+	void PixelDataEx::setPixels(const SPtr<PixelData>& thisPtr, const Vector<Color>& value)
+	{
+		if (!checkIsLocked(thisPtr))
+			return;
+
+		thisPtr->setColors(value);
+	}
+
+	Vector<char> PixelDataEx::getRawPixels(const SPtr<PixelData>& thisPtr)
+	{
+		if (!checkIsLocked(thisPtr))
+			return Vector<char>();
+
+		Vector<char> output(thisPtr->getSize());
+		memcpy(output.data(), thisPtr->getData(), thisPtr->getSize());
+
+		return output;
+	}
+
+	void PixelDataEx::setRawPixels(const SPtr<PixelData>& thisPtr, const Vector<char>& value)
+	{
+		if (!checkIsLocked(thisPtr))
+			return;
+
+		UINT32 arrayLen = (UINT32)value.size();
+		if (thisPtr->getSize() != arrayLen)
+		{
+			LOGERR("Unable to set colors, invalid array size.")
+				return;
+		}
+
+		UINT8* data = thisPtr->getData();
+		memcpy(data, value.data(), thisPtr->getSize());
+	}
+
+	bool PixelDataEx::checkIsLocked(const SPtr<PixelData>& thisPtr)
+	{
+		if (thisPtr->isLocked())
+		{
+			LOGWRN("Attempting to access a locked pixel data buffer.");
+			return true;
+		}
+
+		return false;
+	}
+}

+ 3 - 3
Source/SBansheeEngine/Source/BsScriptCursor.cpp

@@ -5,7 +5,7 @@
 #include "BsMonoClass.h"
 #include "BsMonoUtil.h"
 #include "BsCursor.h"
-#include "BsScriptPixelData.h"
+#include "BsScriptPixelData.generated.h"
 
 namespace bs
 {
@@ -78,7 +78,7 @@ namespace bs
 
 		if (scriptPixelData != nullptr)
 		{
-			SPtr<PixelData> pixelData = scriptPixelData->getInternalValue();
+			SPtr<PixelData> pixelData = scriptPixelData->getInternal();
 			Cursor::instance().setCursorIcon(nameStr, *pixelData, *hotspot);
 		}
 		else
@@ -91,7 +91,7 @@ namespace bs
 
 		if (scriptPixelData != nullptr)
 		{
-			SPtr<PixelData> pixelData = scriptPixelData->getInternalValue();
+			SPtr<PixelData> pixelData = scriptPixelData->getInternal();
 			Cursor::instance().setCursorIcon(cursor, *pixelData, *hotspot);
 		}
 		else

+ 0 - 315
Source/SBansheeEngine/Source/BsScriptPixelData.cpp

@@ -1,315 +0,0 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#include "BsScriptPixelData.h"
-#include "BsScriptMeta.h"
-#include "BsMonoField.h"
-#include "BsMonoClass.h"
-#include "BsMonoManager.h"
-#include "BsMonoUtil.h"
-#include "BsPixelUtil.h"
-#include "BsScriptColor.h"
-
-namespace bs
-{
-	ScriptPixelData::ScriptPixelData(MonoObject* managedInstance)
-		:ScriptObject(managedInstance)
-	{
-
-	}
-
-	ScriptPixelData::~ScriptPixelData()
-	{
-
-	}
-
-	void ScriptPixelData::initRuntimeData()
-	{
-		metaData.scriptClass->addInternalCall("Internal_CreateInstance", &ScriptPixelData::internal_createInstance);
-		metaData.scriptClass->addInternalCall("Internal_GetPixel", &ScriptPixelData::internal_getPixel);
-		metaData.scriptClass->addInternalCall("Internal_SetPixel", &ScriptPixelData::internal_setPixel);
-		metaData.scriptClass->addInternalCall("Internal_GetPixels", &ScriptPixelData::internal_getPixels);
-		metaData.scriptClass->addInternalCall("Internal_SetPixels", &ScriptPixelData::internal_setPixels);
-		metaData.scriptClass->addInternalCall("Internal_GetRawPixels", &ScriptPixelData::internal_getRawPixels);
-		metaData.scriptClass->addInternalCall("Internal_SetRawPixels", &ScriptPixelData::internal_setRawPixels);
-		metaData.scriptClass->addInternalCall("Internal_GetExtents", &ScriptPixelData::internal_getExtents);
-		metaData.scriptClass->addInternalCall("Internal_GetFormat", &ScriptPixelData::internal_getFormat);
-		metaData.scriptClass->addInternalCall("Internal_GetRowPitch", &ScriptPixelData::internal_getRowPitch);
-		metaData.scriptClass->addInternalCall("Internal_GetSlicePitch", &ScriptPixelData::internal_getSlicePitch);
-		metaData.scriptClass->addInternalCall("Internal_GetSize", &ScriptPixelData::internal_getSize);
-		metaData.scriptClass->addInternalCall("Internal_GetIsConsecutive", &ScriptPixelData::internal_getIsConsecutive);
-	}
-
-	void ScriptPixelData::initialize(const SPtr<PixelData>& pixelData)
-	{
-		mPixelData = pixelData;
-	}
-
-	MonoObject* ScriptPixelData::create(const SPtr<PixelData>& pixelData)
-	{
-		MonoObject* pixelDataObj = metaData.scriptClass->createInstance();
-
-		ScriptPixelData* scriptPixelData = ScriptPixelData::toNative(pixelDataObj);
-		scriptPixelData->initialize(pixelData);
-
-		return pixelDataObj;
-	}
-
-	void ScriptPixelData::internal_createInstance(MonoObject* instance, PixelVolume* volume, PixelFormat format)
-	{
-		SPtr<PixelData> pixelData = bs_shared_ptr_new<PixelData>(*volume, format);
-		pixelData->allocateInternalBuffer();
-
-		ScriptPixelData* scriptPixelData = new (bs_alloc<ScriptPixelData>()) ScriptPixelData(instance);
-		scriptPixelData->initialize(pixelData);
-	}
-
-	void ScriptPixelData::internal_getPixel(ScriptPixelData* thisPtr, int x, int y, int z, Color* value)
-	{
-		if (!checkIsLocked(thisPtr))
-			*value = thisPtr->mPixelData->getColorAt(x, y, z);
-		else
-			*value = Color();
-	}
-
-	void ScriptPixelData::internal_setPixel(ScriptPixelData* thisPtr, int x, int y, int z, Color* value)
-	{
-		if (!checkIsLocked(thisPtr))
-			thisPtr->mPixelData->setColorAt(*value, x, y, z);
-	}
-
-	void ScriptPixelData::internal_getPixels(ScriptPixelData* thisPtr, MonoArray** value)
-	{
-		if (!checkIsLocked(thisPtr))
-			return;
-
-		SPtr<PixelData> pixelData = thisPtr->mPixelData;
-		PixelVolume pixelVolume = pixelData->getExtents();
-		UINT32 depth = pixelVolume.getDepth();
-		UINT32 height = pixelVolume.getHeight();
-		UINT32 width = pixelVolume.getWidth();
-
-		::MonoClass* colorClass = ScriptColor::getMetaData()->scriptClass->_getInternalClass();
-		UINT32 totalNumElements = width * height * depth;
-
-		ScriptArray scriptArray(colorClass, totalNumElements);
-
-		PixelFormat format = pixelData->getFormat();
-		UINT32 pixelSize = PixelUtil::getNumElemBytes(format);
-		UINT8* data = pixelData->getData();
-
-		UINT32 rowPitch = pixelData->getRowPitch();
-		UINT32 slicePitch = pixelData->getSlicePitch();
-
-		// Note: Can I copy bytes more directly?
-		for (UINT32 z = 0; z < depth; z++)
-		{
-			UINT32 zArrayIdx = z * width * height;
-			UINT32 zDataIdx = z * slicePitch * pixelSize;
-
-			for (UINT32 y = 0; y < height; y++)
-			{
-				UINT32 yArrayIdx = y * width;
-				UINT32 yDataIdx = y * rowPitch * pixelSize;
-
-				for (UINT32 x = 0; x < width; x++)
-				{
-					UINT32 arrayIdx = x + yArrayIdx + zArrayIdx;
-					UINT32 dataIdx = x * pixelSize + yDataIdx + zDataIdx;
-
-					UINT8* dest = data + dataIdx;
-					scriptArray.set(arrayIdx, *(Color*)dest);
-				}
-			}
-		}
-
-		*value = scriptArray.getInternal();
-
-	}
-
-	void ScriptPixelData::internal_setPixels(ScriptPixelData* thisPtr, MonoArray* value)
-	{
-		if (!checkIsLocked(thisPtr))
-			return;
-
-		SPtr<PixelData> pixelData = thisPtr->mPixelData;
-		PixelVolume pixelVolume = pixelData->getExtents();
-		UINT32 depth = pixelVolume.getDepth();
-		UINT32 height = pixelVolume.getHeight();
-		UINT32 width = pixelVolume.getWidth();
-
-		ScriptArray scriptArray(value);
-
-		UINT32 arrayLen = scriptArray.size();
-		UINT32 totalNumElements = width * height * depth;
-		if (arrayLen != totalNumElements)
-		{
-			LOGERR("Unable to set colors, invalid array size.")
-			return;
-		}
-
-		PixelFormat format = pixelData->getFormat();
-		UINT32 pixelSize = PixelUtil::getNumElemBytes(format);
-		UINT8* data = pixelData->getData();
-
-		UINT32 rowPitch = pixelData->getRowPitch();
-		UINT32 slicePitch = pixelData->getSlicePitch();
-
-		for (UINT32 z = 0; z < depth; z++)
-		{
-			UINT32 zArrayIdx = z * width * height;
-			UINT32 zDataIdx = z * slicePitch * pixelSize;
-
-			for (UINT32 y = 0; y < height; y++)
-			{
-				UINT32 yArrayIdx = y * width;
-				UINT32 yDataIdx = y * rowPitch * pixelSize;
-
-				for (UINT32 x = 0; x < width; x++)
-				{
-					UINT32 arrayIdx = x + yArrayIdx + zArrayIdx;
-					UINT32 dataIdx = x * pixelSize + yDataIdx + zDataIdx;
-
-					UINT8* dest = data + dataIdx;
-
-					Color color = scriptArray.get<Color>(arrayIdx);
-					PixelUtil::packColor(color, format, dest);
-				}
-			}
-		}
-	}
-
-	void ScriptPixelData::internal_getRawPixels(ScriptPixelData* thisPtr, MonoArray** value)
-	{
-		if (!checkIsLocked(thisPtr))
-			return;
-
-		SPtr<PixelData> pixelData = thisPtr->mPixelData;
-		PixelVolume pixelVolume = pixelData->getExtents();
-		UINT32 depth = pixelVolume.getDepth();
-		UINT32 height = pixelVolume.getHeight();
-		UINT32 width = pixelVolume.getWidth();
-
-		ScriptArray scriptArray(MonoUtil::getByteClass(), pixelData->getSize());
-
-		PixelFormat format = pixelData->getFormat();
-		UINT32 pixelSize = PixelUtil::getNumElemBytes(format);
-		UINT8* data = pixelData->getData();
-
-		UINT32 rowPitch = pixelData->getRowPitch();
-		UINT32 slicePitch = pixelData->getSlicePitch();
-
-		// Note: Can I copy bytes more directly?
-		for (UINT32 z = 0; z < depth; z++)
-		{
-			UINT32 zArrayIdx = z * width * height;
-			UINT32 zDataIdx = z * slicePitch * pixelSize;
-
-			for (UINT32 y = 0; y < height; y++)
-			{
-				UINT32 yArrayIdx = y * width;
-				UINT32 yDataIdx = y * rowPitch * pixelSize;
-
-				for (UINT32 x = 0; x < width; x++)
-				{
-					UINT32 arrayIdx = x + yArrayIdx + zArrayIdx;
-					UINT32 dataIdx = x * pixelSize + yDataIdx + zDataIdx;
-
-					UINT8* dest = data + dataIdx;
-					scriptArray.set(arrayIdx, *dest);
-				}
-			}
-		}
-
-		*value = scriptArray.getInternal();
-	}
-
-	void ScriptPixelData::internal_setRawPixels(ScriptPixelData* thisPtr, MonoArray* value)
-	{
-		if (!checkIsLocked(thisPtr))
-			return;
-
-		SPtr<PixelData> pixelData = thisPtr->mPixelData;
-		PixelVolume pixelVolume = pixelData->getExtents();
-		UINT32 depth = pixelVolume.getDepth();
-		UINT32 height = pixelVolume.getHeight();
-		UINT32 width = pixelVolume.getWidth();
-
-		ScriptArray scriptArray(value);
-		UINT32 arrayLen = scriptArray.size();
-		if (pixelData->getSize() != arrayLen)
-		{
-			LOGERR("Unable to set colors, invalid array size.")
-			return;
-		}
-
-		PixelFormat format = pixelData->getFormat();
-		UINT32 pixelSize = PixelUtil::getNumElemBytes(format);
-		UINT8* data = pixelData->getData();
-
-		UINT32 rowPitch = pixelData->getRowPitch();
-		UINT32 slicePitch = pixelData->getSlicePitch();
-
-		// Note: Can I copy bytes more directly?
-		for (UINT32 z = 0; z < depth; z++)
-		{
-			UINT32 zArrayIdx = z * width * height;
-			UINT32 zDataIdx = z * slicePitch * pixelSize;
-
-			for (UINT32 y = 0; y < height; y++)
-			{
-				UINT32 yArrayIdx = y * width;
-				UINT32 yDataIdx = y * rowPitch * pixelSize;
-
-				for (UINT32 x = 0; x < width; x++)
-				{
-					UINT32 arrayIdx = x + yArrayIdx + zArrayIdx;
-					UINT32 dataIdx = x * pixelSize + yDataIdx + zDataIdx;
-
-					UINT8* dest = data + dataIdx;
-					*dest = scriptArray.get<char>(arrayIdx);
-				}
-			}
-		}
-	}
-
-	void ScriptPixelData::internal_getExtents(ScriptPixelData* thisPtr, PixelVolume* value)
-	{
-		*value = thisPtr->mPixelData->getExtents();
-	}
-
-	void ScriptPixelData::internal_getFormat(ScriptPixelData* thisPtr, PixelFormat* value)
-	{
-		*value = thisPtr->mPixelData->getFormat();
-	}
-
-	void ScriptPixelData::internal_getRowPitch(ScriptPixelData* thisPtr, int* value)
-	{
-		*value = thisPtr->mPixelData->getRowPitch();
-	}
-
-	void ScriptPixelData::internal_getSlicePitch(ScriptPixelData* thisPtr, int* value)
-	{
-		*value = thisPtr->mPixelData->getSlicePitch();
-	}
-
-	void ScriptPixelData::internal_getSize(ScriptPixelData* thisPtr, int* value)
-	{
-		*value = thisPtr->mPixelData->getSize();
-	}
-
-	void ScriptPixelData::internal_getIsConsecutive(ScriptPixelData* thisPtr, bool* value)
-	{
-		*value = thisPtr->mPixelData->isConsecutive();
-	}
-
-	bool ScriptPixelData::checkIsLocked(ScriptPixelData* thisPtr)
-	{
-		if (thisPtr->mPixelData->isLocked())
-		{
-			LOGWRN("Attempting to access a locked pixel data buffer.");
-			return true;
-		}
-
-		return false;
-	}
-}

+ 6 - 6
Source/SBansheeEngine/Source/BsScriptPixelUtility.cpp

@@ -5,7 +5,7 @@
 #include "BsMonoClass.h"
 #include "BsMonoUtil.h"
 #include "BsDebug.h"
-#include "BsScriptPixelData.h"
+#include "BsScriptPixelData.generated.h"
 
 namespace bs
 {
@@ -64,7 +64,7 @@ namespace bs
 		if (sourceScriptPixelData == nullptr)
 			return nullptr;
 
-		SPtr<PixelData> sourcePixelData = sourceScriptPixelData->getInternalValue();
+		SPtr<PixelData> sourcePixelData = sourceScriptPixelData->getInternal();
 		SPtr<PixelData> outputData = bs_shared_ptr_new<PixelData>(sourcePixelData->getWidth(), sourcePixelData->getHeight(), 
 			sourcePixelData->getDepth(), newFormat);
 		outputData->allocateInternalBuffer();
@@ -80,7 +80,7 @@ namespace bs
 		if (sourceScriptPixelData == nullptr)
 			return nullptr;
 
-		SPtr<PixelData> sourcePixelData = sourceScriptPixelData->getInternalValue();
+		SPtr<PixelData> sourcePixelData = sourceScriptPixelData->getInternal();
 		SPtr<PixelData> outputData = bs_shared_ptr_new<PixelData>(sourcePixelData->getWidth(), sourcePixelData->getHeight(), 
 			sourcePixelData->getDepth(), options->format);
 		outputData->allocateInternalBuffer();
@@ -96,7 +96,7 @@ namespace bs
 		if (sourceScriptPixelData == nullptr)
 			return nullptr;
 
-		SPtr<PixelData> sourcePixelData = sourceScriptPixelData->getInternalValue();
+		SPtr<PixelData> sourcePixelData = sourceScriptPixelData->getInternal();
 		Vector<SPtr<PixelData>> mipmaps = PixelUtil::genMipmaps(*sourcePixelData, *options);
 
 		UINT32 numElements = (UINT32)mipmaps.size();
@@ -117,7 +117,7 @@ namespace bs
 		if (sourceScriptPixelData == nullptr)
 			return nullptr;
 
-		SPtr<PixelData> sourcePixelData = sourceScriptPixelData->getInternalValue();
+		SPtr<PixelData> sourcePixelData = sourceScriptPixelData->getInternal();
 		SPtr<PixelData> outputData = bs_shared_ptr_new<PixelData>(newSize->getWidth(), newSize->getHeight(),
 			newSize->getDepth(), sourcePixelData->getFormat());
 		outputData->allocateInternalBuffer();
@@ -133,7 +133,7 @@ namespace bs
 		if (sourceScriptPixelData == nullptr)
 			return;
 
-		SPtr<PixelData> pixelData = sourceScriptPixelData->getInternalValue();
+		SPtr<PixelData> pixelData = sourceScriptPixelData->getInternal();
 		PixelUtil::applyGamma(pixelData->getData(), gamma, pixelData->getSize(), PixelUtil::getNumElemBits(pixelData->getFormat()));
 	}
 }

+ 3 - 2
Source/SBansheeEngine/Source/BsScriptTexture2D.cpp

@@ -9,10 +9,11 @@
 #include "BsTexture.h"
 #include "BsPixelUtil.h"
 #include "BsException.h"
-#include "BsScriptPixelData.h"
 #include "BsScriptAsyncOp.h"
 #include "BsCoreThread.h"
 
+#include "BsScriptPixelData.generated.h"
+
 using namespace std::placeholders;
 
 namespace bs
@@ -88,7 +89,7 @@ namespace bs
 		if (scriptPixelData != nullptr)
 		{
 			HTexture texture = thisPtr->getHandle();
-			texture->writeData(scriptPixelData->getInternalValue(), 0, mipLevel, false);
+			texture->writeData(scriptPixelData->getInternal(), 0, mipLevel, false);
 		}
 	}
 

+ 3 - 2
Source/SBansheeEngine/Source/BsScriptTexture3D.cpp

@@ -9,10 +9,11 @@
 #include "BsTexture.h"
 #include "BsPixelUtil.h"
 #include "BsException.h"
-#include "BsScriptPixelData.h"
 #include "BsScriptAsyncOp.h"
 #include "BsCoreThread.h"
 
+#include "BsScriptPixelData.generated.h"
+
 using namespace std::placeholders;
 
 namespace bs
@@ -88,7 +89,7 @@ namespace bs
 		{
 			HTexture texture = thisPtr->getHandle();
 
-			texture->writeData(scriptPixelData->getInternalValue(), 0, mipLevel, false);
+			texture->writeData(scriptPixelData->getInternal(), 0, mipLevel, false);
 		}
 	}
 

+ 3 - 3
Source/SBansheeEngine/Source/BsScriptTextureCube.cpp

@@ -8,11 +8,11 @@
 #include "BsMonoManager.h"
 #include "BsTexture.h"
 #include "BsPixelUtil.h"
-#include "BsException.h"
-#include "BsScriptPixelData.h"
 #include "BsScriptAsyncOp.h"
 #include "BsCoreThread.h"
 
+#include "BsScriptPixelData.generated.h"
+
 using namespace std::placeholders;
 
 namespace bs
@@ -87,7 +87,7 @@ namespace bs
 		if (scriptPixelData != nullptr)
 		{
 			HTexture texture = thisPtr->getHandle();
-			texture->writeData(scriptPixelData->getInternalValue(), face, mipLevel, false);
+			texture->writeData(scriptPixelData->getInternal(), face, mipLevel, false);
 		}
 	}