Переглянути джерело

Various tweaks to the previous merge

BearishSun 9 роки тому
батько
коміт
9d73cc1da2
77 змінених файлів з 139 додано та 143 видалено
  1. BIN
      Data/Editor/GUISkin.asset
  2. BIN
      Data/Editor/Icons/Sprites/sprite_AnimationClipIcon.psd16.asset
  3. BIN
      Data/Editor/Icons/Sprites/sprite_AnimationClipIcon.psd32.asset
  4. BIN
      Data/Editor/Icons/Sprites/sprite_AnimationClipIcon.psd48.asset
  5. BIN
      Data/Editor/Icons/Sprites/sprite_AudioClipIcon.psd16.asset
  6. BIN
      Data/Editor/Icons/Sprites/sprite_AudioClipIcon.psd32.asset
  7. BIN
      Data/Editor/Icons/Sprites/sprite_AudioClipIcon.psd48.asset
  8. BIN
      Data/Editor/Icons/Sprites/sprite_CSharpIcon.psd16.asset
  9. BIN
      Data/Editor/Icons/Sprites/sprite_CSharpIcon.psd32.asset
  10. BIN
      Data/Editor/Icons/Sprites/sprite_CSharpIcon.psd48.asset
  11. BIN
      Data/Editor/Icons/Sprites/sprite_FolderIcon.psd16.asset
  12. BIN
      Data/Editor/Icons/Sprites/sprite_FolderIcon.psd32.asset
  13. BIN
      Data/Editor/Icons/Sprites/sprite_FolderIcon.psd48.asset
  14. BIN
      Data/Editor/Icons/Sprites/sprite_FontIcon.psd16.asset
  15. BIN
      Data/Editor/Icons/Sprites/sprite_FontIcon.psd32.asset
  16. BIN
      Data/Editor/Icons/Sprites/sprite_FontIcon.psd48.asset
  17. BIN
      Data/Editor/Icons/Sprites/sprite_GUISkinIcon.psd16.asset
  18. BIN
      Data/Editor/Icons/Sprites/sprite_GUISkinIcon.psd32.asset
  19. BIN
      Data/Editor/Icons/Sprites/sprite_GUISkinIcon.psd48.asset
  20. BIN
      Data/Editor/Icons/Sprites/sprite_MaterialIcon.psd16.asset
  21. BIN
      Data/Editor/Icons/Sprites/sprite_MaterialIcon.psd32.asset
  22. BIN
      Data/Editor/Icons/Sprites/sprite_MaterialIcon.psd48.asset
  23. BIN
      Data/Editor/Icons/Sprites/sprite_MeshIcon.psd16.asset
  24. BIN
      Data/Editor/Icons/Sprites/sprite_MeshIcon.psd32.asset
  25. BIN
      Data/Editor/Icons/Sprites/sprite_MeshIcon.psd48.asset
  26. BIN
      Data/Editor/Icons/Sprites/sprite_PhysicsMaterialIcon.psd16.asset
  27. BIN
      Data/Editor/Icons/Sprites/sprite_PhysicsMaterialIcon.psd32.asset
  28. BIN
      Data/Editor/Icons/Sprites/sprite_PhysicsMaterialIcon.psd48.asset
  29. BIN
      Data/Editor/Icons/Sprites/sprite_PhysicsMeshIcon.psd16.asset
  30. BIN
      Data/Editor/Icons/Sprites/sprite_PhysicsMeshIcon.psd32.asset
  31. BIN
      Data/Editor/Icons/Sprites/sprite_PhysicsMeshIcon.psd48.asset
  32. BIN
      Data/Editor/Icons/Sprites/sprite_PrefabIcon.psd16.asset
  33. BIN
      Data/Editor/Icons/Sprites/sprite_PrefabIcon.psd32.asset
  34. BIN
      Data/Editor/Icons/Sprites/sprite_PrefabIcon.psd48.asset
  35. BIN
      Data/Editor/Icons/Sprites/sprite_ShaderIcon.psd16.asset
  36. BIN
      Data/Editor/Icons/Sprites/sprite_ShaderIcon.psd32.asset
  37. BIN
      Data/Editor/Icons/Sprites/sprite_ShaderIcon.psd48.asset
  38. BIN
      Data/Editor/Icons/Sprites/sprite_ShaderIncludeIcon.psd16.asset
  39. BIN
      Data/Editor/Icons/Sprites/sprite_ShaderIncludeIcon.psd32.asset
  40. BIN
      Data/Editor/Icons/Sprites/sprite_ShaderIncludeIcon.psd48.asset
  41. BIN
      Data/Editor/Icons/Sprites/sprite_SpriteIcon.psd16.asset
  42. BIN
      Data/Editor/Icons/Sprites/sprite_SpriteIcon.psd32.asset
  43. BIN
      Data/Editor/Icons/Sprites/sprite_SpriteIcon.psd48.asset
  44. BIN
      Data/Editor/Icons/Sprites/sprite_TextIcon.psd16.asset
  45. BIN
      Data/Editor/Icons/Sprites/sprite_TextIcon.psd32.asset
  46. BIN
      Data/Editor/Icons/Sprites/sprite_TextIcon.psd48.asset
  47. BIN
      Data/Editor/Icons/Sprites/sprite_TextureIcon.psd16.asset
  48. BIN
      Data/Editor/Icons/Sprites/sprite_TextureIcon.psd32.asset
  49. BIN
      Data/Editor/Icons/Sprites/sprite_TextureIcon.psd48.asset
  50. BIN
      Data/Editor/Includes/PickingAlphaCull.bslinc.asset
  51. BIN
      Data/Editor/Includes/PickingCull.bslinc.asset
  52. BIN
      Data/Editor/ResourceManifest.asset
  53. BIN
      Data/Editor/Shaders/PickingAlphaCullCCW.bsl.asset
  54. BIN
      Data/Editor/Shaders/PickingAlphaCullCW.bsl.asset
  55. BIN
      Data/Editor/Shaders/PickingAlphaCullNone.bsl.asset
  56. BIN
      Data/Editor/Shaders/PickingCullCCW.bsl.asset
  57. BIN
      Data/Editor/Shaders/PickingCullCW.bsl.asset
  58. BIN
      Data/Editor/Shaders/PickingCullNone.bsl.asset
  59. BIN
      Data/Editor/Timestamp.asset
  60. BIN
      Data/Editor/arial.ttf.asset
  61. BIN
      Data/Editor/arialAA.ttf.asset
  62. 5 4
      Data/Raw/Editor/Includes/PickingAlphaCull.bslinc
  63. 5 5
      Data/Raw/Editor/Includes/PickingCull.bslinc
  64. 2 0
      Documentation/Manuals/Native/style.md
  65. 3 4
      Source/BansheeCore/Include/BsCamera.h
  66. 11 11
      Source/BansheeCore/Include/BsMultiRenderTexture.h
  67. 7 9
      Source/BansheeCore/Include/BsPixelData.h
  68. 1 1
      Source/BansheeCore/Include/BsPixelUtil.h
  69. 2 1
      Source/BansheeCore/Source/BsCamera.cpp
  70. 3 3
      Source/BansheeCore/Source/BsPixelData.cpp
  71. 23 19
      Source/BansheeEditor/Include/BsScenePicking.h
  72. 35 37
      Source/BansheeEditor/Source/BsScenePicking.cpp
  73. 9 6
      Source/MBansheeEditor/Windows/Scene/SceneSelection.cs
  74. 7 23
      Source/MBansheeEditor/Windows/Scene/SceneWindow.cs
  75. 10 10
      Source/RenderBeast/Include/BsRendererCamera.h
  76. 1 1
      Source/RenderBeast/Source/BsRendererCamera.cpp
  77. 15 9
      Source/SBansheeEditor/Source/BsScriptSceneSelection.cpp

BIN
Data/Editor/GUISkin.asset


BIN
Data/Editor/Icons/Sprites/sprite_AnimationClipIcon.psd16.asset


BIN
Data/Editor/Icons/Sprites/sprite_AnimationClipIcon.psd32.asset


BIN
Data/Editor/Icons/Sprites/sprite_AnimationClipIcon.psd48.asset


BIN
Data/Editor/Icons/Sprites/sprite_AudioClipIcon.psd16.asset


BIN
Data/Editor/Icons/Sprites/sprite_AudioClipIcon.psd32.asset


BIN
Data/Editor/Icons/Sprites/sprite_AudioClipIcon.psd48.asset


BIN
Data/Editor/Icons/Sprites/sprite_CSharpIcon.psd16.asset


BIN
Data/Editor/Icons/Sprites/sprite_CSharpIcon.psd32.asset


BIN
Data/Editor/Icons/Sprites/sprite_CSharpIcon.psd48.asset


BIN
Data/Editor/Icons/Sprites/sprite_FolderIcon.psd16.asset


BIN
Data/Editor/Icons/Sprites/sprite_FolderIcon.psd32.asset


BIN
Data/Editor/Icons/Sprites/sprite_FolderIcon.psd48.asset


BIN
Data/Editor/Icons/Sprites/sprite_FontIcon.psd16.asset


BIN
Data/Editor/Icons/Sprites/sprite_FontIcon.psd32.asset


BIN
Data/Editor/Icons/Sprites/sprite_FontIcon.psd48.asset


BIN
Data/Editor/Icons/Sprites/sprite_GUISkinIcon.psd16.asset


BIN
Data/Editor/Icons/Sprites/sprite_GUISkinIcon.psd32.asset


BIN
Data/Editor/Icons/Sprites/sprite_GUISkinIcon.psd48.asset


BIN
Data/Editor/Icons/Sprites/sprite_MaterialIcon.psd16.asset


BIN
Data/Editor/Icons/Sprites/sprite_MaterialIcon.psd32.asset


BIN
Data/Editor/Icons/Sprites/sprite_MaterialIcon.psd48.asset


BIN
Data/Editor/Icons/Sprites/sprite_MeshIcon.psd16.asset


BIN
Data/Editor/Icons/Sprites/sprite_MeshIcon.psd32.asset


BIN
Data/Editor/Icons/Sprites/sprite_MeshIcon.psd48.asset


BIN
Data/Editor/Icons/Sprites/sprite_PhysicsMaterialIcon.psd16.asset


BIN
Data/Editor/Icons/Sprites/sprite_PhysicsMaterialIcon.psd32.asset


BIN
Data/Editor/Icons/Sprites/sprite_PhysicsMaterialIcon.psd48.asset


BIN
Data/Editor/Icons/Sprites/sprite_PhysicsMeshIcon.psd16.asset


BIN
Data/Editor/Icons/Sprites/sprite_PhysicsMeshIcon.psd32.asset


BIN
Data/Editor/Icons/Sprites/sprite_PhysicsMeshIcon.psd48.asset


BIN
Data/Editor/Icons/Sprites/sprite_PrefabIcon.psd16.asset


BIN
Data/Editor/Icons/Sprites/sprite_PrefabIcon.psd32.asset


BIN
Data/Editor/Icons/Sprites/sprite_PrefabIcon.psd48.asset


BIN
Data/Editor/Icons/Sprites/sprite_ShaderIcon.psd16.asset


BIN
Data/Editor/Icons/Sprites/sprite_ShaderIcon.psd32.asset


BIN
Data/Editor/Icons/Sprites/sprite_ShaderIcon.psd48.asset


BIN
Data/Editor/Icons/Sprites/sprite_ShaderIncludeIcon.psd16.asset


BIN
Data/Editor/Icons/Sprites/sprite_ShaderIncludeIcon.psd32.asset


BIN
Data/Editor/Icons/Sprites/sprite_ShaderIncludeIcon.psd48.asset


BIN
Data/Editor/Icons/Sprites/sprite_SpriteIcon.psd16.asset


BIN
Data/Editor/Icons/Sprites/sprite_SpriteIcon.psd32.asset


BIN
Data/Editor/Icons/Sprites/sprite_SpriteIcon.psd48.asset


BIN
Data/Editor/Icons/Sprites/sprite_TextIcon.psd16.asset


BIN
Data/Editor/Icons/Sprites/sprite_TextIcon.psd32.asset


BIN
Data/Editor/Icons/Sprites/sprite_TextIcon.psd48.asset


BIN
Data/Editor/Icons/Sprites/sprite_TextureIcon.psd16.asset


BIN
Data/Editor/Icons/Sprites/sprite_TextureIcon.psd32.asset


BIN
Data/Editor/Icons/Sprites/sprite_TextureIcon.psd48.asset


BIN
Data/Editor/Includes/PickingAlphaCull.bslinc.asset


BIN
Data/Editor/Includes/PickingCull.bslinc.asset


BIN
Data/Editor/ResourceManifest.asset


BIN
Data/Editor/Shaders/PickingAlphaCullCCW.bsl.asset


BIN
Data/Editor/Shaders/PickingAlphaCullCW.bsl.asset


BIN
Data/Editor/Shaders/PickingAlphaCullNone.bsl.asset


BIN
Data/Editor/Shaders/PickingCullCCW.bsl.asset


BIN
Data/Editor/Shaders/PickingCullCW.bsl.asset


BIN
Data/Editor/Shaders/PickingCullNone.bsl.asset


BIN
Data/Editor/Timestamp.asset


BIN
Data/Editor/arial.ttf.asset


BIN
Data/Editor/arialAA.ttf.asset


+ 5 - 4
Data/Raw/Editor/Includes/PickingAlphaCull.bslinc

@@ -118,7 +118,7 @@ Technique : base("PickingAlphaCull") =
 			in vec3 bs_position;
 			in vec3 bs_position;
 			in vec2 bs_texcoord0;
 			in vec2 bs_texcoord0;
 			in vec3 bs_normal;
 			in vec3 bs_normal;
-			out vec4 bs_outNorm
+			out vec4 normal
 			out vec2 texcoord0;
 			out vec2 texcoord0;
 
 
 			out gl_PerVertex
 			out gl_PerVertex
@@ -130,7 +130,7 @@ Technique : base("PickingAlphaCull") =
 			{
 			{
 				gl_Position = matWorldViewProj * vec4(bs_position.xyz, 1);
 				gl_Position = matWorldViewProj * vec4(bs_position.xyz, 1);
 				texcoord0 = bs_texcoord0;
 				texcoord0 = bs_texcoord0;
-				bs_outNorm = vec4(bs_normal, 0);
+				normal = vec4(bs_normal, 0);
 			}
 			}
 		};
 		};
 		
 		
@@ -139,7 +139,7 @@ Technique : base("PickingAlphaCull") =
 			uniform sampler2D mainTexture;
 			uniform sampler2D mainTexture;
 			uniform vec4 colorIndex;
 			uniform vec4 colorIndex;
 			uniform float alphaCutoff;
 			uniform float alphaCutoff;
-			in vec4 bs_outNorm;
+			in vec4 normal;
 			in vec2 texcoord0;
 			in vec2 texcoord0;
 			out vec4 normalsColor;
 			out vec4 normalsColor;
 			out vec4 fragColor;
 			out vec4 fragColor;
@@ -149,7 +149,8 @@ Technique : base("PickingAlphaCull") =
 				vec4 color = texture2D(mainTexture, texcoord0);
 				vec4 color = texture2D(mainTexture, texcoord0);
 				if(color.a < alphaCutoff)
 				if(color.a < alphaCutoff)
 					discard;
 					discard;
-				normalsColor = (bs_outNorm + vec4(1,1,1,0)) / 2;
+					
+				normalsColor = (normal + vec4(1,1,1,0)) / 2;
 				fragColor = colorIndex;
 				fragColor = colorIndex;
 			}
 			}
 		};
 		};

+ 5 - 5
Data/Raw/Editor/Includes/PickingCull.bslinc

@@ -89,8 +89,8 @@ Technique : base("PickingCull") =
 		{
 		{
 			uniform mat4 matWorldViewProj;
 			uniform mat4 matWorldViewProj;
 			in vec3 bs_position;
 			in vec3 bs_position;
-			in vec3 normal;
-			out vec4 outNorm;
+			in vec3 bs_normal;
+			out vec4 normal;
 			out gl_PerVertex
 			out gl_PerVertex
 			{
 			{
 				vec4 gl_Position;
 				vec4 gl_Position;
@@ -98,21 +98,21 @@ Technique : base("PickingCull") =
 			
 			
 			void main()
 			void main()
 			{
 			{
-				outNorm = vec4(normal,0);
+				normal = vec4(bs_normal,0);
 				gl_Position = matWorldViewProj * vec4(bs_position.xyz, 1);
 				gl_Position = matWorldViewProj * vec4(bs_position.xyz, 1);
 			}
 			}
 		};
 		};
 		
 		
 		Fragment =
 		Fragment =
 		{
 		{
-			in vec4 outNorm;
+			in vec4 normal;
 			uniform vec4 colorIndex;
 			uniform vec4 colorIndex;
 			out vec4 normalsColor;
 			out vec4 normalsColor;
 			out vec4 fragColor;
 			out vec4 fragColor;
 
 
 			void main()
 			void main()
 			{
 			{
-				normalsColor = (outNorm + vec4(1,1,1,0)) / 2;
+				normalsColor = (normal + vec4(1,1,1,0)) / 2;
 				fragColor = colorIndex;
 				fragColor = colorIndex;
 			}
 			}
 		};
 		};

+ 2 - 0
Documentation/Manuals/Native/style.md

@@ -40,6 +40,8 @@ Guidelines
   - Always put a space after a semicolon (e.g. for(int i = 0; i < 5; i++)).
   - Always put a space after a semicolon (e.g. for(int i = 0; i < 5; i++)).
   - Always put a space between operators (e.g. 5 + 2).
   - Always put a space between operators (e.g. 5 + 2).
   - Separate meaningful parts of the code in a method with empty lines
   - Separate meaningful parts of the code in a method with empty lines
+  - Always but a blank line after a block {}, and in general try to separate relevant pieces of code with "paragraphs" separated by blank lines
+  - No single line should be longer than column 124 (set up a guideline in your editor)
  - If method doesn't modify data, always mark it as const (getters especially)
  - If method doesn't modify data, always mark it as const (getters especially)
  - Always pass non-primitive parameters by reference unless `null` is a valid value in which case use a pointer
  - Always pass non-primitive parameters by reference unless `null` is a valid value in which case use a pointer
  - Reference/pointer parameters that won't be modified by a function should always be `const`
  - Reference/pointer parameters that won't be modified by a function should always be `const`

+ 3 - 4
Source/BansheeCore/Include/BsCamera.h

@@ -348,8 +348,8 @@ namespace BansheeEngine
 		 * world space.
 		 * world space.
 		 *
 		 *
 		 * @param[in]	screenPoint	Point to transform.
 		 * @param[in]	screenPoint	Point to transform.
-		 * @param[in]	depth		Depth to place the world point at. The depth is applied to the vector going from camera
-		 *							origin to the point on the near plane.
+		 * @param[in]	depth		Depth to place the world point at, in world coordinates. The depth is applied to the 
+		 *							vector going from camera origin to the point on the near plane.
 		 */
 		 */
 		Vector3 screenToWorldPoint(const Vector2I& screenPoint, float depth = 0.5f) const;
 		Vector3 screenToWorldPoint(const Vector2I& screenPoint, float depth = 0.5f) const;
 
 
@@ -358,8 +358,7 @@ namespace BansheeEngine
 		* world space.
 		* world space.
 		*
 		*
 		* @param[in]	screenPoint	Point to transform.
 		* @param[in]	screenPoint	Point to transform.
-		* @param[in]	deviceDepth	Device depth to place the world point at. The depth is applied to the vector going from camera
-		*							origin to the point on the near plane.
+		* @param[in]	deviceDepth	Depth to place the world point at, in normalized device coordinates.
 		*/
 		*/
 		Vector3 screenToWorldPointDeviceDepth(const Vector2I& screenPoint, float deviceDepth = 0.5f) const;
 		Vector3 screenToWorldPointDeviceDepth(const Vector2I& screenPoint, float deviceDepth = 0.5f) const;
 
 

+ 11 - 11
Source/BansheeCore/Include/BsMultiRenderTexture.h

@@ -91,7 +91,7 @@ namespace BansheeEngine
 		SPtr<CoreObjectCore> createCore() const override;
 		SPtr<CoreObjectCore> createCore() const override;
 
 
 		/** @copydoc CoreObjectCore::syncToCore */
 		/** @copydoc CoreObjectCore::syncToCore */
-		virtual CoreSyncData syncToCore(FrameAlloc* allocator) override;
+		CoreSyncData syncToCore(FrameAlloc* allocator) override;
 
 
 		MULTI_RENDER_TEXTURE_DESC mDesc;
 		MULTI_RENDER_TEXTURE_DESC mDesc;
 		Vector<HTexture> mBindableColorTex;
 		Vector<HTexture> mBindableColorTex;
@@ -116,23 +116,23 @@ namespace BansheeEngine
 		virtual ~MultiRenderTextureCore();
 		virtual ~MultiRenderTextureCore();
 
 
 		/** @copydoc CoreObjectCore::initialize */
 		/** @copydoc CoreObjectCore::initialize */
-		virtual void initialize() override;
+		void initialize() override;
 
 
 		/** Returns properties that describe the render texture. */
 		/** Returns properties that describe the render texture. */
 		const MultiRenderTextureProperties& getProperties() const;
 		const MultiRenderTextureProperties& getProperties() const;
 
 
 		/**
 		/**
-		* Returns a depth/stencil surface texture you may bind as an input to an GPU program.
-		*
-		* @note	Be aware that you cannot bind a render texture for reading and writing at the same time.
-		*/
+		 * Returns a depth/stencil surface texture you may bind as an input to an GPU program.
+		 *
+		 * @note	Be aware that you cannot bind a render texture for reading and writing at the same time.
+		 */
 		const SPtr<TextureView> getBindableDepthStencilTexture() const { return mDepthStencilSurface; }
 		const SPtr<TextureView> getBindableDepthStencilTexture() const { return mDepthStencilSurface; }
 
 
 		/**
 		/**
-		* Returns a color surface texture you may bind as an input to an GPU program.
-		*
-		* @note	Be aware that you cannot bind a render texture for reading and writing at the same time.
-		*/
+		 * Returns a color surface texture you may bind as an input to an GPU program.
+		 *
+		 * @note	Be aware that you cannot bind a render texture for reading and writing at the same time.
+		 */
 		const SPtr<TextureView>& getBindableColorTexture(UINT32 idx) const { return mColorSurfaces[idx]; }
 		const SPtr<TextureView>& getBindableColorTexture(UINT32 idx) const { return mColorSurfaces[idx]; }
 
 
 		/** @copydoc	TextureManager::createMultiRenderTexture(const MULTI_RENDER_TEXTURE_DESC&) */
 		/** @copydoc	TextureManager::createMultiRenderTexture(const MULTI_RENDER_TEXTURE_DESC&) */
@@ -142,7 +142,7 @@ namespace BansheeEngine
 		MultiRenderTextureCore(const MULTI_RENDER_TEXTURE_CORE_DESC& desc);
 		MultiRenderTextureCore(const MULTI_RENDER_TEXTURE_CORE_DESC& desc);
 
 
 		/** @copydoc CoreObjectCore::syncToCore */
 		/** @copydoc CoreObjectCore::syncToCore */
-		virtual void syncToCore(const CoreSyncData& data) override;
+		void syncToCore(const CoreSyncData& data) override;
 
 
 	private:
 	private:
 		/** Checks that all render surfaces and depth/stencil surface match. If they do not match an exception is thrown. */
 		/** Checks that all render surfaces and depth/stencil surface match. If they do not match an exception is thrown. */

+ 7 - 9
Source/BansheeCore/Include/BsPixelData.h

@@ -306,7 +306,7 @@ namespace BansheeEngine
 		Color getColorAt(UINT32 x, UINT32 y, UINT32 z = 0) const;
 		Color getColorAt(UINT32 x, UINT32 y, UINT32 z = 0) const;
 
 
 		/**	Sets the pixel color at the specified coordinates. */
 		/**	Sets the pixel color at the specified coordinates. */
-        void setColorAt(Color const &cv, UINT32 x, UINT32 y, UINT32 z = 0);
+        void setColorAt(const Color& color, UINT32 x, UINT32 y, UINT32 z = 0);
 
 
 		/**
 		/**
 		 * Converts all the internal data into an array of colors. Array is mapped as such: 
 		 * Converts all the internal data into an array of colors. Array is mapped as such: 
@@ -332,15 +332,13 @@ namespace BansheeEngine
 		 */
 		 */
 		float getDepthAt(UINT32 x, UINT32 y, UINT32 z = 0) const;
 		float getDepthAt(UINT32 x, UINT32 y, UINT32 z = 0) const;
 
 
-		/** 
-		 * Sets a depth value in range [0, 1] at the specified pixel coordinates.
-		 */
-		void setDepthAt(const float depth, UINT32 x, UINT32 y, UINT32 z = 0);
+		/** Sets a depth value in range [0, 1] at the specified pixel coordinates. */
+		void setDepthAt(float depth, UINT32 x, UINT32 y, UINT32 z = 0);
 
 
 		/**
 		/**
-		* Converts all the internal data into an array of float. Array is mapped as such:
-		* arrayIdx = x + y * width + z * width * height.
-		*/
+		 * Converts all the internal data into an array of float. Array is mapped as such:
+		 * arrayIdx = x + y * width + z * width * height.
+		 */
 		Vector<float> getDepths() const;
 		Vector<float> getDepths() const;
 
 
 		/**
 		/**
@@ -390,7 +388,7 @@ namespace BansheeEngine
 	public:
 	public:
 		friend class PixelDataRTTI;
 		friend class PixelDataRTTI;
 		static RTTITypeBase* getRTTIStatic();
 		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const override;
+		RTTITypeBase* getRTTI() const override;
     };
     };
 
 
 	/** @} */
 	/** @} */

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

@@ -190,7 +190,7 @@ namespace BansheeEngine
 		 */
 		 */
         static void unpackColor(float* r, float* g, float* b, float* a, PixelFormat format, const void* src); 
         static void unpackColor(float* r, float* g, float* b, float* a, PixelFormat format, const void* src); 
 
 
-		/** Writes a depth value to the provided memory location. Depth should be in [0,1]*/
+		/** Writes a depth value to the provided memory location. Depth should be in range [0, 1]. */
 		static void packDepth(float depth, const PixelFormat format, void* dest);
 		static void packDepth(float depth, const PixelFormat format, void* dest);
 
 
 		/** Reads the depth from the provided memory location. Value ranges in [0, 1]. */
 		/** Reads the depth from the provided memory location. Value ranges in [0, 1]. */

+ 2 - 1
Source/BansheeCore/Source/BsCamera.cpp

@@ -559,8 +559,8 @@ namespace BansheeEngine
 		Vector2 ndcPoint = screenToNdcPoint(screenPoint);
 		Vector2 ndcPoint = screenToNdcPoint(screenPoint);
 		Vector4 worldPoint(ndcPoint.x, ndcPoint.y, deviceDepth, 1.0f);
 		Vector4 worldPoint(ndcPoint.x, ndcPoint.y, deviceDepth, 1.0f);
 		worldPoint = getProjectionMatrixRS().inverse().multiply(worldPoint);
 		worldPoint = getProjectionMatrixRS().inverse().multiply(worldPoint);
-		Vector3 worldPoint3D;
 
 
+		Vector3 worldPoint3D;
 		if (Math::abs(worldPoint.w) > 1e-7f)
 		if (Math::abs(worldPoint.w) > 1e-7f)
 		{
 		{
 			float invW = 1.0f / worldPoint.w;
 			float invW = 1.0f / worldPoint.w;
@@ -569,6 +569,7 @@ namespace BansheeEngine
 			worldPoint3D.y = worldPoint.y * invW;
 			worldPoint3D.y = worldPoint.y * invW;
 			worldPoint3D.z = worldPoint.z * invW;
 			worldPoint3D.z = worldPoint.z * invW;
 		}
 		}
+
 		return viewToWorldPoint(worldPoint3D);
 		return viewToWorldPoint(worldPoint3D);
 	}
 	}
 
 

+ 3 - 3
Source/BansheeCore/Source/BsPixelData.cpp

@@ -83,11 +83,11 @@ namespace BansheeEngine
 		return cv;
 		return cv;
 	}
 	}
 
 
-	void PixelData::setColorAt(Color const &cv, UINT32 x, UINT32 y, UINT32 z)
+	void PixelData::setColorAt(const Color& color, UINT32 x, UINT32 y, UINT32 z)
 	{
 	{
 		UINT32 pixelSize = PixelUtil::getNumElemBytes(mFormat);
 		UINT32 pixelSize = PixelUtil::getNumElemBytes(mFormat);
 		UINT32 pixelOffset = pixelSize * (z * mSlicePitch + y * mRowPitch + x);
 		UINT32 pixelOffset = pixelSize * (z * mSlicePitch + y * mRowPitch + x);
-		PixelUtil::packColor(cv, mFormat, (unsigned char *)getData() + pixelOffset);
+		PixelUtil::packColor(color, mFormat, (unsigned char *)getData() + pixelOffset);
 	}
 	}
 
 
 	Vector<Color> PixelData::getColors() const
 	Vector<Color> PixelData::getColors() const
@@ -183,7 +183,7 @@ namespace BansheeEngine
 		return PixelUtil::unpackDepth(mFormat, (unsigned char *)getData() + pixelOffset);;
 		return PixelUtil::unpackDepth(mFormat, (unsigned char *)getData() + pixelOffset);;
 	}
 	}
 
 
-	void PixelData::setDepthAt(const float depth, UINT32 x, UINT32 y, UINT32 z)
+	void PixelData::setDepthAt(float depth, UINT32 x, UINT32 y, UINT32 z)
 	{
 	{
 		UINT32 pixelSize = PixelUtil::getNumElemBytes(mFormat);
 		UINT32 pixelSize = PixelUtil::getNumElemBytes(mFormat);
 		UINT32 pixelOffset = pixelSize * (z * mSlicePitch + y * mRowPitch + x);
 		UINT32 pixelOffset = pixelSize * (z * mSlicePitch + y * mRowPitch + x);

+ 23 - 19
Source/BansheeEditor/Include/BsScenePicking.h

@@ -13,7 +13,7 @@ namespace BansheeEngine
 	 *  @{
 	 *  @{
 	 */
 	 */
 
 
-	 /** Contains the data of a scene picking action. */
+	/** Contains the data of a scene picking action. */
 	struct SnapData
 	struct SnapData
 	{
 	{
 		Vector3 normal;
 		Vector3 normal;
@@ -24,7 +24,8 @@ namespace BansheeEngine
 	struct PickResults
 	struct PickResults
 	{
 	{
 		Vector<UINT32> objects;
 		Vector<UINT32> objects;
-		SnapData data;
+		Vector3 normal;
+		float depth;
 	};
 	};
 
 
 	class ScenePickingCore;
 	class ScenePickingCore;
@@ -50,29 +51,32 @@ namespace BansheeEngine
 		/**
 		/**
 		 * Attempts to find a single nearest scene object under the provided position and area.
 		 * Attempts to find a single nearest scene object under the provided position and area.
 		 *
 		 *
-		 * @param[in]	cam			Camera to perform the picking from.
-		 * @param[in]	position	Pointer position relative to the camera viewport, in pixels.
-		 * @param[in]	area		Width/height of the checked area in pixels. Use (1, 1) if you want the exact position
-		 *							under the pointer.
-		 * @param[in]	ignoreRenderables		A list of objects that should not be rendered during scene picking.
-		 * @param[out]	data		Picking data regarding position and normal.
-		 * @return					Nearest SceneObject under the provided area, or an empty handle if no object is found.
+		 * @param[in]	cam					Camera to perform the picking from.
+		 * @param[in]	position			Pointer position relative to the camera viewport, in pixels.
+		 * @param[in]	area				Width/height of the checked area in pixels. Use (1, 1) if you want the exact
+		 *									position under the pointer.
+		 * @param[in]	ignoreRenderables	A list of objects that should be ignored during scene picking.
+		 * @param[out]	data				Picking data regarding position and normal.
+		 * @return							Nearest SceneObject under the provided area, or an empty handle if no object is
+		 *									found.
 		 */
 		 */
-		HSceneObject pickClosestObject(const SPtr<Camera>& cam, const Vector2I& position, const Vector2I& area, Vector<HSceneObject>& ignoreRenderables, SnapData* data = nullptr);
+		HSceneObject pickClosestObject(const SPtr<Camera>& cam, const Vector2I& position, const Vector2I& area, 
+			Vector<HSceneObject>& ignoreRenderables, SnapData* data = nullptr);
 
 
 		/**
 		/**
 		 * Attempts to find all scene objects under the provided position and area. This does not mean objects occluded by
 		 * Attempts to find all scene objects under the provided position and area. This does not mean objects occluded by
 		 * other objects.
 		 * other objects.
 		 *
 		 *
-		 * @param[in]	cam			Camera to perform the picking from.
-		 * @param[in]	position	Pointer position relative to the camera viewport, in pixels.
-		 * @param[in]	area		Width/height of the checked area in pixels. Use (1, 1) if you want the exact position
-		 *							under the pointer.
-		 * @param[in]	ignoreRenderables		A list of objects that should not be rendered during scene picking.
-		 * @param[out]	data		Picking data regarding position and normal.
-		 * @return					A list of SceneObject%s under the provided area.
+		 * @param[in]	cam					Camera to perform the picking from.
+		 * @param[in]	position			Pointer position relative to the camera viewport, in pixels.
+		 * @param[in]	area				Width/height of the checked area in pixels. Use (1, 1) if you want the exact 
+		 *									position under the pointer.
+		 * @param[in]	ignoreRenderables	A list of objects that should be ignored during scene picking.
+		 * @param[out]	data				Picking data regarding position and normal.
+		 * @return							A list of SceneObject%s under the provided area.
 		 */
 		 */
-		Vector<HSceneObject> pickObjects(const SPtr<Camera>& cam, const Vector2I& position, const Vector2I& area, Vector<HSceneObject>& ignoreRenderables, SnapData* data = nullptr);
+		Vector<HSceneObject> pickObjects(const SPtr<Camera>& cam, const Vector2I& position, const Vector2I& area, 
+			Vector<HSceneObject>& ignoreRenderables, SnapData* data = nullptr);
 
 
 	private:
 	private:
 		friend class ScenePickingCore;
 		friend class ScenePickingCore;
@@ -141,7 +145,7 @@ namespace BansheeEngine
 		 * @param[in]	viewportArea	Normalized area of the render target we're rendering in.
 		 * @param[in]	viewportArea	Normalized area of the render target we're rendering in.
 		 * @param[in]	position		Position of the pointer where to pick objects, in pixels relative to viewport.
 		 * @param[in]	position		Position of the pointer where to pick objects, in pixels relative to viewport.
 		 * @param[in]	area			Width/height of the area to pick objects, in pixels.
 		 * @param[in]	area			Width/height of the area to pick objects, in pixels.
-		 * @param[in]	gatherSnapData	Whether it should gather normal and picking position information.
+		 * @param[in]	gatherSnapData	Determines whather normal & depth information will be recorded.
 		 * @param[out]	asyncOp			Async operation handle that when complete will contain the results of the picking
 		 * @param[out]	asyncOp			Async operation handle that when complete will contain the results of the picking
 		 *								operation in the form of Vector<SelectedObject>.
 		 *								operation in the form of Vector<SelectedObject>.
 		 */
 		 */

+ 35 - 37
Source/BansheeEditor/Source/BsScenePicking.cpp

@@ -54,7 +54,8 @@ namespace BansheeEngine
 		gCoreAccessor().queueCommand(std::bind(&ScenePickingCore::destroy, mCore));
 		gCoreAccessor().queueCommand(std::bind(&ScenePickingCore::destroy, mCore));
 	}
 	}
 
 
-	HSceneObject ScenePicking::pickClosestObject(const SPtr<Camera>& cam, const Vector2I& position, const Vector2I& area, Vector<HSceneObject>& ignoreRenderables, SnapData* data)
+	HSceneObject ScenePicking::pickClosestObject(const SPtr<Camera>& cam, const Vector2I& position, const Vector2I& area, 
+		Vector<HSceneObject>& ignoreRenderables, SnapData* data)
 	{
 	{
 		Vector<HSceneObject> selectedObjects = pickObjects(cam, position, area, ignoreRenderables, data);
 		Vector<HSceneObject> selectedObjects = pickObjects(cam, position, area, ignoreRenderables, data);
 		if (selectedObjects.size() == 0)
 		if (selectedObjects.size() == 0)
@@ -70,7 +71,8 @@ namespace BansheeEngine
 		return selectedObjects[0];
 		return selectedObjects[0];
 	}
 	}
 
 
-	Vector<HSceneObject> ScenePicking::pickObjects(const SPtr<Camera>& cam, const Vector2I& position, const Vector2I& area, Vector<HSceneObject>& ignoreRenderables, SnapData* data)
+	Vector<HSceneObject> ScenePicking::pickObjects(const SPtr<Camera>& cam, const Vector2I& position, const Vector2I& area, 
+		Vector<HSceneObject>& ignoreRenderables, SnapData* data)
 	{
 	{
 		auto comparePickElement = [&] (const ScenePicking::RenderablePickData& a, const ScenePicking::RenderablePickData& b)
 		auto comparePickElement = [&] (const ScenePicking::RenderablePickData& a, const ScenePicking::RenderablePickData& b)
 		{
 		{
@@ -189,16 +191,14 @@ namespace BansheeEngine
 
 
 		assert(op.hasCompleted());
 		assert(op.hasCompleted());
 
 
-		PickResults returnValue = op.getReturnValue<PickResults>();
-
+		PickResults pickResults = op.getReturnValue<PickResults>();
 		if (data != nullptr)
 		if (data != nullptr)
 		{
 		{
-			Vector3 pos = returnValue.data.pickPosition;
-			*data = returnValue.data;
-			data->pickPosition = cam->screenToWorldPointDeviceDepth(Vector2I(pos.x, pos.y), pos.z);
+			data->pickPosition = cam->screenToWorldPointDeviceDepth(position, pickResults.depth);
+			data->normal = pickResults.normal;
 		}
 		}
 
 
-		Vector<UINT32> selectedObjects = returnValue.objects;
+		Vector<UINT32> selectedObjects = pickResults.objects;
 		Vector<HSceneObject> results;
 		Vector<HSceneObject> results;
 
 
 		for (auto& selectedObjectIdx : selectedObjects)
 		for (auto& selectedObjectIdx : selectedObjects)
@@ -288,24 +288,25 @@ namespace BansheeEngine
 		RenderAPICore& rs = RenderAPICore::instance();
 		RenderAPICore& rs = RenderAPICore::instance();
 
 
 		SPtr<RenderTextureCore> rtt = std::static_pointer_cast<RenderTextureCore>(target);
 		SPtr<RenderTextureCore> rtt = std::static_pointer_cast<RenderTextureCore>(target);
+
 		SPtr<TextureCore> outputTexture = rtt->getBindableColorTexture();
 		SPtr<TextureCore> outputTexture = rtt->getBindableColorTexture();
 		TextureProperties outputTextureProperties = outputTexture->getProperties();
 		TextureProperties outputTextureProperties = outputTexture->getProperties();
+
+		SPtr<TextureCore> normalsTexture = TextureCore::create(TEX_TYPE_2D, outputTextureProperties.getWidth(),
+			outputTextureProperties.getHeight(), 0, PF_R8G8B8A8, TU_RENDERTARGET, false, 1);
 		SPtr<TextureCore> depthTexture = rtt->getBindableDepthStencilTexture();
 		SPtr<TextureCore> depthTexture = rtt->getBindableDepthStencilTexture();
 
 
-		MULTI_RENDER_TEXTURE_CORE_DESC multiTextureDescription;
-		multiTextureDescription.colorSurfaces.resize(2);
-		multiTextureDescription.colorSurfaces[0].face = 0;
-		multiTextureDescription.colorSurfaces[0].texture = outputTexture;
-		multiTextureDescription.colorSurfaces[1].face = 0;
-		SPtr<TextureCore> core = TextureCore::create(TextureType::TEX_TYPE_2D, outputTextureProperties.getWidth(),
-			outputTextureProperties.getHeight(), 0, PixelFormat::PF_R8G8B8A8, TU_RENDERTARGET, false, 1);
-		multiTextureDescription.colorSurfaces[1].texture = core;
-		RENDER_SURFACE_CORE_DESC depthStencilDescription;
-		depthStencilDescription.face = 0;
-		depthStencilDescription.texture = depthTexture;
-		multiTextureDescription.depthStencilSurface = depthStencilDescription;
+		MULTI_RENDER_TEXTURE_CORE_DESC pickingMRT;
+		pickingMRT.colorSurfaces.resize(2);
+		pickingMRT.colorSurfaces[0].face = 0;
+		pickingMRT.colorSurfaces[0].texture = outputTexture;
+		pickingMRT.colorSurfaces[1].face = 0;
+		pickingMRT.colorSurfaces[1].texture = normalsTexture;
+
+		pickingMRT.depthStencilSurface.face = 0;
+		pickingMRT.depthStencilSurface.texture = depthTexture;
 		
 		
-		mPickingTexture = MultiRenderTextureCore::create(multiTextureDescription);
+		mPickingTexture = MultiRenderTextureCore::create(pickingMRT);
 
 
 		rs.beginFrame();
 		rs.beginFrame();
 		rs.setRenderTarget(mPickingTexture);
 		rs.setRenderTarget(mPickingTexture);
@@ -380,6 +381,8 @@ namespace BansheeEngine
 		if (position.x < 0 || position.x >= (INT32)outputTexture->getProperties().getWidth() ||
 		if (position.x < 0 || position.x >= (INT32)outputTexture->getProperties().getWidth() ||
 			position.y < 0 || position.y >= (INT32)outputTexture->getProperties().getHeight())
 			position.y < 0 || position.y >= (INT32)outputTexture->getProperties().getHeight())
 		{
 		{
+			mPickingTexture = nullptr;
+
 			asyncOp._completeOperation(Vector<UINT32>());
 			asyncOp._completeOperation(Vector<UINT32>());
 			return;
 			return;
 		}
 		}
@@ -467,31 +470,26 @@ namespace BansheeEngine
 		{
 		{
 			depthTexture->readSubresource(0, *depthPixelData);
 			depthTexture->readSubresource(0, *depthPixelData);
 			normalsTexture->readSubresource(0, *normalsPixelData);
 			normalsTexture->readSubresource(0, *normalsPixelData);
-			float depth;
-			Color normal;
+
+			Vector2I samplePixel = position;
 			if (rtProps.requiresTextureFlipping())
 			if (rtProps.requiresTextureFlipping())
-			{
-				depth = depthPixelData->getDepthAt(position.x, depthPixelData->getHeight() - position.y);
-				normal = normalsPixelData->getColorAt(position.x, depthPixelData->getHeight() - position.y);
-			}
-			else
-			{
-				depth = depthPixelData->getDepthAt(position.x, position.y);
-				normal = normalsPixelData->getColorAt(position.x, position.y);
-			}
+				samplePixel.y = depthPixelData->getHeight() - samplePixel.y;
+
+			float depth = depthPixelData->getDepthAt(samplePixel.x, samplePixel.y);
+			Color normal = normalsPixelData->getColorAt(samplePixel.x, samplePixel.y);
 
 
-			SnapData data;
 			const RenderAPIInfo& rapiInfo = rs.getAPIInfo();
 			const RenderAPIInfo& rapiInfo = rs.getAPIInfo();
 			float max = rapiInfo.getMaximumDepthInputValue();
 			float max = rapiInfo.getMaximumDepthInputValue();
 			float min = rapiInfo.getMinimumDepthInputValue();
 			float min = rapiInfo.getMinimumDepthInputValue();
 			depth = depth * Math::abs(max - min) + min;
 			depth = depth * Math::abs(max - min) + min;
-			data.pickPosition = Vector3(position.x, position.y, depth);
-			data.normal = Vector3((normal.r * 2) - 1, (normal.g * 2) - 1, (normal.b * 2) - 1);
-			result.data = data;
+
+			result.depth = depth;
+			result.normal = Vector3((normal.r * 2) - 1, (normal.g * 2) - 1, (normal.b * 2) - 1);
 		}
 		}
+
+		mPickingTexture = nullptr;
 		
 		
 		result.objects = objects;
 		result.objects = objects;
 		asyncOp._completeOperation(result);
 		asyncOp._completeOperation(result);
-		mNormalsTexture = nullptr;
 	}
 	}
 }
 }

+ 9 - 6
Source/MBansheeEditor/Windows/Scene/SceneSelection.cs

@@ -12,7 +12,7 @@ namespace BansheeEditor
      */
      */
 
 
     /// <summary>
     /// <summary>
-    /// Contains Object containing the world position and normal of the surface under the snapping point.
+    /// Contains world position and normal of the surface of the object in a snap operation.
     /// </summary>
     /// </summary>
     [StructLayout(LayoutKind.Sequential)]
     [StructLayout(LayoutKind.Sequential)]
     struct SnapData
     struct SnapData
@@ -23,7 +23,7 @@ namespace BansheeEditor
         public Vector3 normal;
         public Vector3 normal;
 
 
         /// <summary>
         /// <summary>
-        /// The 3D position on the surface of the object.
+        /// The world position on the surface of the object.
         /// </summary>
         /// </summary>
         public Vector3 position;
         public Vector3 position;
     }
     }
@@ -65,19 +65,22 @@ namespace BansheeEditor
         /// Attempts to select a scene object in the specified area.
         /// Attempts to select a scene object in the specified area.
         /// </summary>
         /// </summary>
         /// <param name="pointerPos">Position of the pointer relative to the scene camera viewport.</param>
         /// <param name="pointerPos">Position of the pointer relative to the scene camera viewport.</param>
-        /// <param name="area">The screen area in which objects will be selected.</param>
+        /// <param name="area">Size of the in which objects will be selected, in pixels and relative to 
+        ///                    <paramref name="pointerPos"/>.</param>
         /// <param name="controlHeld">Should this selection add to the existing selection, or replace it.</param>
         /// <param name="controlHeld">Should this selection add to the existing selection, or replace it.</param>
         /// <param name="ignoreSceneObjects">Optional set of objects to ignore during scene picking.</param>
         /// <param name="ignoreSceneObjects">Optional set of objects to ignore during scene picking.</param>
-        internal void PickObjects(Vector2I pointerPos, Vector2I area, bool controlHeld, SceneObject[] ignoreSceneObjects = null)
+        internal void PickObjects(Vector2I pointerPos, Vector2I area, bool controlHeld, 
+            SceneObject[] ignoreSceneObjects = null)
         {
         {
             Internal_PickObjects(mCachedPtr, ref pointerPos, ref area, controlHeld, ignoreSceneObjects);
             Internal_PickObjects(mCachedPtr, ref pointerPos, ref area, controlHeld, ignoreSceneObjects);
         }
         }
 
 
         /// <summary>
         /// <summary>
-        /// Object containing the world position and normal of the surface under the provided screen point.
+        /// Attempts to find a scene object under the provided position, while also returning the world position and normal
+        /// of the point that was hit.
         /// </summary>
         /// </summary>
         /// <param name="pointerPos">Position of the pointer relative to the scene camera viewport.</param>
         /// <param name="pointerPos">Position of the pointer relative to the scene camera viewport.</param>
-        /// <param name="data">A struct containing the position on the object surface and the normal in that point.</param>
+        /// <param name="data">Position and normal on the object surface at the point that was hit.</param>
         /// <param name="ignoreSceneObjects">Optional set of objects to ignore during scene picking.</param>
         /// <param name="ignoreSceneObjects">Optional set of objects to ignore during scene picking.</param>
         /// <returns>The object the pointer is snapping to.</returns>
         /// <returns>The object the pointer is snapping to.</returns>
         internal SceneObject Snap(Vector2I pointerPos, out SnapData data, SceneObject[] ignoreSceneObjects = null)
         internal SceneObject Snap(Vector2I pointerPos, out SnapData data, SceneObject[] ignoreSceneObjects = null)

+ 7 - 23
Source/MBansheeEditor/Windows/Scene/SceneWindow.cs

@@ -23,8 +23,6 @@ namespace BansheeEditor
         internal const string ScaleToolBinding = "ScaleTool";
         internal const string ScaleToolBinding = "ScaleTool";
         internal const string FrameBinding = "SceneFrame";
         internal const string FrameBinding = "SceneFrame";
 
 
-        public SceneSelection sceneSelection;
-
         private const int HeaderHeight = 20;
         private const int HeaderHeight = 20;
         private const float DefaultPlacementDepth = 5.0f;
         private const float DefaultPlacementDepth = 5.0f;
         private static readonly Color ClearColor = new Color(83.0f/255.0f, 83.0f/255.0f, 83.0f/255.0f);
         private static readonly Color ClearColor = new Color(83.0f/255.0f, 83.0f/255.0f, 83.0f/255.0f);
@@ -42,6 +40,7 @@ namespace BansheeEditor
 
 
         private GUIRenderTexture renderTextureGUI;
         private GUIRenderTexture renderTextureGUI;
         private SceneGrid sceneGrid;
         private SceneGrid sceneGrid;
+        private SceneSelection sceneSelection;
         private SceneGizmos sceneGizmos;
         private SceneGizmos sceneGizmos;
         private SceneHandles sceneHandles;
         private SceneHandles sceneHandles;
 
 
@@ -436,7 +435,7 @@ namespace BansheeEditor
         /// <param name="screenPos">Coordinates relative to the screen.</param>
         /// <param name="screenPos">Coordinates relative to the screen.</param>
         /// <param name="scenePos">Output coordinates relative to the scene view texture.</param>
         /// <param name="scenePos">Output coordinates relative to the scene view texture.</param>
         /// <returns>True if the coordinates are within the scene view texture, false otherwise.</returns>
         /// <returns>True if the coordinates are within the scene view texture, false otherwise.</returns>
-        public bool ScreenToScenePos(Vector2I screenPos, out Vector2I scenePos)
+        private bool ScreenToScenePos(Vector2I screenPos, out Vector2I scenePos)
         {
         {
             scenePos = screenPos;
             scenePos = screenPos;
             Vector2I windowPos = ScreenToWindowPos(screenPos);
             Vector2I windowPos = ScreenToWindowPos(screenPos);
@@ -587,26 +586,11 @@ namespace BansheeEditor
                         if (Input.IsButtonHeld(ButtonCode.Space))
                         if (Input.IsButtonHeld(ButtonCode.Space))
                         {
                         {
                             SnapData snapData;
                             SnapData snapData;
-                            var snappedTo = sceneSelection.Snap(scenePos, out snapData, new SceneObject[] {draggedSO});
-                            if (snappedTo != null)
-                            {
-                                Quaternion q = Quaternion.FromToRotation(Vector3.YAxis, snapData.normal);
-                                draggedSO.Position = snapData.position;
-                                draggedSO.Rotation = q;
-                            }
-                            else
-                            {
-                                Ray worldRay = camera.ViewportToWorldRay(scenePos);
-                                Vector3 pos = worldRay*DefaultPlacementDepth - draggedSOOffset;
-                                float interval = EditorSettings.MoveHandleSnapAmount;
-                                if (EditorSettings.MoveHandleSnapActive)
-                                    draggedSO.Position = new Vector3(pos.x - (pos.x % interval), pos.y - (pos.y % interval),
-                                        pos.z - (pos.z % interval));
-                                else
-                                    draggedSO.Position = new Vector3(pos.x, pos.y - (pos.y % interval), pos.z);
-
-                                draggedSO.Rotation = Quaternion.LookRotation(Vector3.YAxis);
-                            }
+                            sceneSelection.Snap(scenePos, out snapData, new SceneObject[] {draggedSO});
+
+                            Quaternion q = Quaternion.FromToRotation(Vector3.YAxis, snapData.normal);
+                            draggedSO.Position = snapData.position;
+                            draggedSO.Rotation = q;
                         }
                         }
                         else
                         else
                         {
                         {

+ 10 - 10
Source/RenderBeast/Include/BsRendererCamera.h

@@ -68,16 +68,6 @@ namespace BansheeEngine
 		void determineVisible(Vector<RendererObject>& renderables, const Vector<Bounds>& renderableBounds, 
 		void determineVisible(Vector<RendererObject>& renderables, const Vector<Bounds>& renderableBounds, 
 			Vector<bool>& visibility);
 			Vector<bool>& visibility);
 
 
-		/**
-		* Extracts the necessary values from the projection matrix that allow you to transform device Z value into
-		* world Z value.
-		* 
-		* @param[in]	projMatrix	Projection matrix that was used to create the device Z value to transform.
-		* @return					Returns two values that can be used to transform device z to world z using this formula:
-		* 							z = (deviceZ + y) * x.
-		*/
-		Vector2 getDeviceZTransform(const Matrix4& projMatrix) const;
-
 		/** 
 		/** 
 		 * Returns a structure containing information about post-processing effects. This structure will be modified and
 		 * Returns a structure containing information about post-processing effects. This structure will be modified and
 		 * maintained by the post-processing system.
 		 * maintained by the post-processing system.
@@ -88,6 +78,16 @@ namespace BansheeEngine
 		CameraShaderData getShaderData();
 		CameraShaderData getShaderData();
 
 
 	private:
 	private:
+		/**
+		 * Extracts the necessary values from the projection matrix that allow you to transform device Z value into
+		 * world Z value.
+		 * 
+		 * @param[in]	projMatrix	Projection matrix that was used to create the device Z value to transform.
+		 * @return					Returns two values that can be used to transform device z to world z using this formula:
+		 * 							z = (deviceZ + y) * x.
+		 */
+		Vector2 getDeviceZTransform(const Matrix4& projMatrix) const;
+
 		const CameraCore* mCamera;
 		const CameraCore* mCamera;
 		SPtr<RenderQueue> mOpaqueQueue;
 		SPtr<RenderQueue> mOpaqueQueue;
 		SPtr<RenderQueue> mTransparentQueue;
 		SPtr<RenderQueue> mTransparentQueue;

+ 1 - 1
Source/RenderBeast/Source/BsRendererCamera.cpp

@@ -130,7 +130,7 @@ namespace BansheeEngine
 		mTransparentQueue->sort();
 		mTransparentQueue->sort();
 	}
 	}
 
 
-	Vector2 RendererCamera::getDeviceZTransform(const Matrix4& projMatrix)
+	Vector2 RendererCamera::getDeviceZTransform(const Matrix4& projMatrix) const
 	{
 	{
 		// Returns a set of values that will transform depth buffer values (e.g. [0, 1] in DX, [-1, 1] in GL) to a distance
 		// Returns a set of values that will transform depth buffer values (e.g. [0, 1] in DX, [-1, 1] in GL) to a distance
 		// in world space. This involes applying the inverse projection transform to the depth value. When you multiply
 		// in world space. This involes applying the inverse projection transform to the depth value. When you multiply

+ 15 - 9
Source/SBansheeEditor/Source/BsScriptSceneSelection.cpp

@@ -90,10 +90,10 @@ namespace BansheeEngine
 		{
 		{
 			Selection::instance().clearSceneSelection();
 			Selection::instance().clearSceneSelection();
 		}
 		}
-			
 	}
 	}
 
 
-	void ScriptSceneSelection::internal_PickObjects(ScriptSceneSelection* thisPtr, Vector2I* inputPos, Vector2I* area, bool additive, MonoArray* ignoreRenderables)
+	void ScriptSceneSelection::internal_PickObjects(ScriptSceneSelection* thisPtr, Vector2I* inputPos, Vector2I* area, 
+		bool additive, MonoArray* ignoreRenderables)
 	{
 	{
 		Vector<HSceneObject> ignoredSceneObjects;
 		Vector<HSceneObject> ignoredSceneObjects;
 
 
@@ -115,7 +115,8 @@ namespace BansheeEngine
 			}
 			}
 		}
 		}
 
 
-		Vector<HSceneObject> pickedObjects = ScenePicking::instance().pickObjects(thisPtr->mCamera, *inputPos, *area, ignoredSceneObjects);
+		Vector<HSceneObject> pickedObjects = ScenePicking::instance().pickObjects(thisPtr->mCamera, *inputPos, 
+			*area, ignoredSceneObjects);
 
 
 		if (pickedObjects.size() != 0)
 		if (pickedObjects.size() != 0)
 		{
 		{
@@ -123,7 +124,8 @@ namespace BansheeEngine
 			{
 			{
 				Vector<HSceneObject> selectedSOs = Selection::instance().getSceneObjects();
 				Vector<HSceneObject> selectedSOs = Selection::instance().getSceneObjects();
 
 
-				for (int i = 0; i < pickedObjects.size(); i++) {
+				for (int i = 0; i < pickedObjects.size(); i++) 
+				{
 					bool found = false;
 					bool found = false;
 					for (int j = 0; j < selectedSOs.size(); j++)
 					for (int j = 0; j < selectedSOs.size(); j++)
 					{
 					{
@@ -133,9 +135,11 @@ namespace BansheeEngine
 							break;
 							break;
 						}
 						}
 					}
 					}
+
 					if (!found)
 					if (!found)
 						selectedSOs.push_back(pickedObjects[i]);
 						selectedSOs.push_back(pickedObjects[i]);
 				}
 				}
+
 				Selection::instance().setSceneObjects(selectedSOs);
 				Selection::instance().setSceneObjects(selectedSOs);
 			}
 			}
 			else
 			else
@@ -147,7 +151,8 @@ namespace BansheeEngine
 		}
 		}
 	}
 	}
 
 
-	MonoObject* ScriptSceneSelection::internal_Snap(ScriptSceneSelection* thisPtr, Vector2I* inputPos, SnapData* data, MonoArray* ignoreRenderables)
+	MonoObject* ScriptSceneSelection::internal_Snap(ScriptSceneSelection* thisPtr, Vector2I* inputPos, SnapData* data, 
+		MonoArray* ignoreRenderables)
 	{
 	{
 		Vector<HSceneObject> ignoredSceneObjects;
 		Vector<HSceneObject> ignoredSceneObjects;
 
 
@@ -169,12 +174,13 @@ namespace BansheeEngine
 			}
 			}
 		}
 		}
 
 
-		HSceneObject instance = ScenePicking::instance().pickClosestObject(thisPtr->mCamera, *inputPos, Vector2I(1, 1), ignoredSceneObjects, data);
-		MonoObject* managedInstance = ScriptGameObjectManager::instance().getOrCreateScriptSceneObject(instance)->getManagedInstance();
+		HSceneObject instance = ScenePicking::instance().pickClosestObject(thisPtr->mCamera, *inputPos, Vector2I(1, 1), 
+			ignoredSceneObjects, data);
+
 		if (instance == nullptr)
 		if (instance == nullptr)
 			return nullptr;
 			return nullptr;
 
 
-		return  managedInstance;
+		ScriptSceneObject* scriptSO = ScriptGameObjectManager::instance().getOrCreateScriptSceneObject(instance);
+		return scriptSO->getManagedInstance();
 	}
 	}
-
 }
 }