Browse Source

Added mesh drag and drop to scene view (WIP)
Added depth parameter to camera methods outputting world and view coordinates
Added default diffuse material
Bugfixes:
- Fixed ProjectLibrary.Load so it loads the proper resource
- Fixed Renderable and RenderableHandler so they properly check if they have a mesh before using it
- Fixed ProjectWindow so that scroll area doesn't keep expanding as the user draws the selection highlight
- Load resource manifest in ProjectLibrary before attempting a reimport due to a missing meta file
- Added default constructor for Mesh so it may be created from native code
- Fixed builtin-resource modification check so it properly detects files that were moved or deleted
- Fixed ScriptDragDropManager so user can retrieve dragged data before it is dropped
- Fixed Renderable so it properly initializes its layers field to a single bit value

Marko Pintera 10 years ago
parent
commit
d3e33e24e0

+ 10 - 10
BansheeEditor/Source/BsProjectLibrary.cpp

@@ -1001,6 +1001,16 @@ namespace BansheeEngine
 			mRootEntry->parent = nullptr;
 			mRootEntry->parent = nullptr;
 		}
 		}
 
 
+		// Load resource manifest
+		Path resourceManifestPath = mProjectFolder;
+		resourceManifestPath.append(INTERNAL_RESOURCES_DIR);
+		resourceManifestPath.append(RESOURCE_MANIFEST_FILENAME);
+
+		if (FileSystem::exists(resourceManifestPath))
+		{
+			mResourceManifest = ResourceManifest::load(resourceManifestPath, mProjectFolder);
+		}
+
 		// Load all meta files
 		// Load all meta files
 		Stack<DirectoryEntry*> todo;
 		Stack<DirectoryEntry*> todo;
 		todo.push(mRootEntry);
 		todo.push(mRootEntry);
@@ -1053,16 +1063,6 @@ namespace BansheeEngine
 				}
 				}
 			}
 			}
 		}
 		}
-
-		// Load resource manifest
-		Path resourceManifestPath = mProjectFolder;
-		resourceManifestPath.append(INTERNAL_RESOURCES_DIR);
-		resourceManifestPath.append(RESOURCE_MANIFEST_FILENAME);
-
-		if(FileSystem::exists(resourceManifestPath))
-		{
-			mResourceManifest = ResourceManifest::load(resourceManifestPath, mProjectFolder);
-		}
 	}
 	}
 
 
 	void ProjectLibrary::doOnEntryRemoved(const LibraryEntry* entry)
 	void ProjectLibrary::doOnEntryRemoved(const LibraryEntry* entry)

+ 12 - 0
BansheeEngine/Include/BsBuiltinResources.h

@@ -78,6 +78,16 @@ namespace BansheeEngine
 		 */
 		 */
 		const PixelData& getCursorMoveLeftRight(Vector2I& hotSpot);
 		const PixelData& getCursorMoveLeftRight(Vector2I& hotSpot);
 
 
+		/**
+		 * @brief	Returns a shader used for rendering only a diffuse texture.
+		 */
+		HShader getDiffuseShader() const { return mShaderDiffuse; }
+
+		/**
+		 * @brief	Returns a shader used as a replacement when no other is usable.
+		 */
+		HShader getDummyShader() const { return mShaderDummy; }
+
 		/**
 		/**
 		 * @brief	Creates material used for textual sprite rendering (e.g. text in GUI).
 		 * @brief	Creates material used for textual sprite rendering (e.g. text in GUI).
 		 */
 		 */
@@ -151,6 +161,7 @@ namespace BansheeEngine
 		HShader mShaderSpriteText;
 		HShader mShaderSpriteText;
 		HShader mShaderSpriteImage;
 		HShader mShaderSpriteImage;
 		HShader mShaderSpriteNonAlphaImage;
 		HShader mShaderSpriteNonAlphaImage;
+		HShader mShaderDiffuse;
 		HShader mShaderDummy;
 		HShader mShaderDummy;
 
 
 		ResourceManifestPtr mResourceManifest;
 		ResourceManifestPtr mResourceManifest;
@@ -261,6 +272,7 @@ namespace BansheeEngine
 		static const WString ShaderSpriteTextFile;
 		static const WString ShaderSpriteTextFile;
 		static const WString ShaderSpriteImageAlphaFile;
 		static const WString ShaderSpriteImageAlphaFile;
 		static const WString ShaderSpriteImageNoAlphaFile;
 		static const WString ShaderSpriteImageNoAlphaFile;
+		static const WString ShaderDiffuseFile;
 		static const WString ShaderDummyFile;
 		static const WString ShaderDummyFile;
 	};
 	};
 
 

+ 4 - 4
BansheeEngine/Include/BsCamera.h

@@ -223,12 +223,12 @@ namespace BansheeEngine
 		/**
 		/**
 		 * @copydoc	CameraHandler::screenToWorldPoint
 		 * @copydoc	CameraHandler::screenToWorldPoint
 		 */
 		 */
-		Vector3 screenToWorldPoint(const Vector2I& screenPoint) const { updateView(); return mInternal->screenToWorldPoint(screenPoint); }
+		Vector3 screenToWorldPoint(const Vector2I& screenPoint, float depth = 0.5f) const { updateView(); return mInternal->screenToWorldPoint(screenPoint, depth); }
 
 
 		/**
 		/**
 		 * @copydoc	CameraHandler::screenToViewPoint
 		 * @copydoc	CameraHandler::screenToViewPoint
 		 */
 		 */
-		Vector3 screenToViewPoint(const Vector2I& screenPoint) const { return mInternal->screenToViewPoint(screenPoint); }
+		Vector3 screenToViewPoint(const Vector2I& screenPoint, float depth = 0.5f) const { return mInternal->screenToViewPoint(screenPoint, depth); }
 
 
 		/**
 		/**
 		 * @copydoc	CameraHandler::screenToClipPoint
 		 * @copydoc	CameraHandler::screenToClipPoint
@@ -253,12 +253,12 @@ namespace BansheeEngine
 		/**
 		/**
 		 * @copydoc	CameraHandler::clipToWorldPoint
 		 * @copydoc	CameraHandler::clipToWorldPoint
 		 */
 		 */
-		Vector3 clipToWorldPoint(const Vector2& clipPoint) const { updateView(); return mInternal->clipToWorldPoint(clipPoint); }
+		Vector3 clipToWorldPoint(const Vector2& clipPoint, float depth = 0.5f) const { updateView(); return mInternal->clipToWorldPoint(clipPoint, depth); }
 
 
 		/**
 		/**
 		 * @copydoc	CameraHandler::clipToViewPoint
 		 * @copydoc	CameraHandler::clipToViewPoint
 		 */
 		 */
-		Vector3 clipToViewPoint(const Vector2& clipPoint) const { return mInternal->clipToViewPoint(clipPoint); }
+		Vector3 clipToViewPoint(const Vector2& clipPoint, float depth = 0.5f) const { return mInternal->clipToViewPoint(clipPoint, depth); }
 
 
 		/**
 		/**
 		 * @copydoc	CameraHandler::clipToScreenPoint
 		 * @copydoc	CameraHandler::clipToScreenPoint

+ 24 - 4
BansheeEngine/Include/BsCameraHandler.h

@@ -335,15 +335,25 @@ namespace BansheeEngine
 		/**
 		/**
 		 * @brief	Converts a point in screen space (pixels corresponding to
 		 * @brief	Converts a point in screen space (pixels corresponding to
 		 *			render target attached to the camera) to a point in world space.
 		 *			render target attached to the camera) to a point in world space.
+		 *
+		 * @param	screenPoint	Point to transform.
+		 * @param	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.
 		 */
 		 */
-		Vector3 screenToWorldPoint(const Vector2I& screenPoint) const;
+		Vector3 screenToWorldPoint(const Vector2I& screenPoint, float depth = 0.5f) const;
 
 
 		/**
 		/**
 		 * @brief	Converts a point in screen space (pixels corresponding to
 		 * @brief	Converts a point in screen space (pixels corresponding to
 		 *			render target attached to the camera) to a point relative to
 		 *			render target attached to the camera) to a point relative to
 		 *			camera's coordinate system (view space).
 		 *			camera's coordinate system (view space).
+		 *
+		 * @param	screenPoint	Point to transform.
+		 * @param	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.
 		 */
 		 */
-		Vector3 screenToViewPoint(const Vector2I& screenPoint) const;
+		Vector3 screenToViewPoint(const Vector2I& screenPoint, float depth = 0.5f) const;
 
 
 		/**
 		/**
 		 * @brief	Converts a point in screen space (pixels corresponding to
 		 * @brief	Converts a point in screen space (pixels corresponding to
@@ -374,14 +384,24 @@ namespace BansheeEngine
 		/**
 		/**
 		 * @brief	Converts a point in normalized clip coordinates ([0, 1] range) to
 		 * @brief	Converts a point in normalized clip coordinates ([0, 1] range) to
 		 *			a point in world space.
 		 *			a point in world space.
+		 *
+		 * @param	clipPoint	Point to transform.
+		 * @param	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.
 		 */
 		 */
-		Vector3 clipToWorldPoint(const Vector2& clipPoint) const;
+		Vector3 clipToWorldPoint(const Vector2& clipPoint, float depth = 0.5f) const;
 
 
 		/**
 		/**
 		 * @brief	Converts a point in normalized clip coordinates ([0, 1] range) to
 		 * @brief	Converts a point in normalized clip coordinates ([0, 1] range) to
 		 *			a point relative to camera's coordinate system (view space).
 		 *			a point relative to camera's coordinate system (view space).
+		 *
+		 * @param	clipPoint	Point to transform.
+		 * @param	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.
 		 */
 		 */
-		Vector3 clipToViewPoint(const Vector2& clipPoint) const;
+		Vector3 clipToViewPoint(const Vector2& clipPoint, float depth = 0.5f) const;
 
 
 		/**
 		/**
 		 * @brief	Converts a point in normalized clip coordinates ([0, 1] range) to
 		 * @brief	Converts a point in normalized clip coordinates ([0, 1] range) to

+ 3 - 1
BansheeEngine/Source/BsBuiltinResources.cpp

@@ -157,6 +157,7 @@ namespace BansheeEngine
 	const WString BuiltinResources::ShaderSpriteTextFile = L"SpriteText.bsl";
 	const WString BuiltinResources::ShaderSpriteTextFile = L"SpriteText.bsl";
 	const WString BuiltinResources::ShaderSpriteImageAlphaFile = L"SpriteImageAlpha.bsl";
 	const WString BuiltinResources::ShaderSpriteImageAlphaFile = L"SpriteImageAlpha.bsl";
 	const WString BuiltinResources::ShaderSpriteImageNoAlphaFile = L"SpriteImageNoAlpha.bsl";
 	const WString BuiltinResources::ShaderSpriteImageNoAlphaFile = L"SpriteImageNoAlpha.bsl";
+	const WString BuiltinResources::ShaderDiffuseFile = L"Diffuse.bsl";
 	const WString BuiltinResources::ShaderDummyFile = L"Dummy.bsl";
 	const WString BuiltinResources::ShaderDummyFile = L"Dummy.bsl";
 
 
 	BuiltinResources::~BuiltinResources()
 	BuiltinResources::~BuiltinResources()
@@ -202,6 +203,7 @@ namespace BansheeEngine
 		mShaderSpriteText = getShader(ShaderSpriteTextFile);
 		mShaderSpriteText = getShader(ShaderSpriteTextFile);
 		mShaderSpriteImage = getShader(ShaderSpriteImageAlphaFile);
 		mShaderSpriteImage = getShader(ShaderSpriteImageAlphaFile);
 		mShaderSpriteNonAlphaImage = getShader(ShaderSpriteImageNoAlphaFile);
 		mShaderSpriteNonAlphaImage = getShader(ShaderSpriteImageNoAlphaFile);
+		mShaderDiffuse = getShader(ShaderDiffuseFile);
 		mShaderDummy = getShader(ShaderDummyFile);
 		mShaderDummy = getShader(ShaderDummyFile);
 
 
 		mWhiteSpriteTexture = getSkinTexture(WhiteTex);
 		mWhiteSpriteTexture = getSkinTexture(WhiteTex);
@@ -941,7 +943,7 @@ namespace BansheeEngine
 			return true;
 			return true;
 		};
 		};
 
 
-		FileSystem::iterate(folder, checkUpToDate);
+		FileSystem::iterate(folder, checkUpToDate, checkUpToDate);
 
 
 		return !upToDate;
 		return !upToDate;
 	}
 	}

+ 8 - 8
BansheeEngine/Source/BsCameraHandler.cpp

@@ -539,16 +539,16 @@ namespace BansheeEngine
 		return getViewMatrix().multiplyAffine(worldPoint);
 		return getViewMatrix().multiplyAffine(worldPoint);
 	}
 	}
 
 
-	Vector3 CameraHandlerBase::screenToWorldPoint(const Vector2I& screenPoint) const
+	Vector3 CameraHandlerBase::screenToWorldPoint(const Vector2I& screenPoint, float depth) const
 	{
 	{
 		Vector2 clipPoint = screenToClipPoint(screenPoint);
 		Vector2 clipPoint = screenToClipPoint(screenPoint);
-		return clipToWorldPoint(clipPoint);
+		return clipToWorldPoint(clipPoint, depth);
 	}
 	}
 
 
-	Vector3 CameraHandlerBase::screenToViewPoint(const Vector2I& screenPoint) const
+	Vector3 CameraHandlerBase::screenToViewPoint(const Vector2I& screenPoint, float depth) const
 	{
 	{
 		Vector2 clipPoint = screenToClipPoint(screenPoint);
 		Vector2 clipPoint = screenToClipPoint(screenPoint);
-		return clipToViewPoint(clipPoint);
+		return clipToViewPoint(clipPoint, depth);
 	}
 	}
 
 
 	Vector2 CameraHandlerBase::screenToClipPoint(const Vector2I& screenPoint) const
 	Vector2 CameraHandlerBase::screenToClipPoint(const Vector2I& screenPoint) const
@@ -580,15 +580,15 @@ namespace BansheeEngine
 		return Vector2(projPoint.x, projPoint.y);
 		return Vector2(projPoint.x, projPoint.y);
 	}
 	}
 
 
-	Vector3 CameraHandlerBase::clipToWorldPoint(const Vector2& clipPoint) const
+	Vector3 CameraHandlerBase::clipToWorldPoint(const Vector2& clipPoint, float depth) const
 	{
 	{
-		Vector3 viewPoint = clipToViewPoint(clipPoint);
+		Vector3 viewPoint = clipToViewPoint(clipPoint, depth);
 		return viewToWorldPoint(viewPoint);
 		return viewToWorldPoint(viewPoint);
 	}
 	}
 
 
-	Vector3 CameraHandlerBase::clipToViewPoint(const Vector2& clipPoint) const
+	Vector3 CameraHandlerBase::clipToViewPoint(const Vector2& clipPoint, float depth) const
 	{
 	{
-		return unprojectPoint(Vector3(clipPoint.x, clipPoint.y, 0.5f));
+		return unprojectPoint(Vector3(clipPoint.x, clipPoint.y, depth));
 	}
 	}
 
 
 	Vector2I CameraHandlerBase::clipToScreenPoint(const Vector2& clipPoint) const
 	Vector2I CameraHandlerBase::clipToScreenPoint(const Vector2& clipPoint) const

+ 6 - 1
BansheeEngine/Source/BsRenderableHandler.cpp

@@ -29,7 +29,12 @@ namespace BansheeEngine
 	void TRenderableHandler<Core>::setMesh(const MeshType& mesh)
 	void TRenderableHandler<Core>::setMesh(const MeshType& mesh)
 	{
 	{
 		mMesh = mesh;
 		mMesh = mesh;
-		mMaterials.resize(mesh->getProperties().getNumSubMeshes());
+
+		int numSubMeshes = 0;
+		if (mesh != nullptr)
+			numSubMeshes = mesh->getProperties().getNumSubMeshes();
+
+		mMaterials.resize(numSubMeshes);
 
 
 		_markResourcesDirty();
 		_markResourcesDirty();
 		_markCoreDirty();
 		_markCoreDirty();

+ 4 - 1
License/Third Party/Bison.txt

@@ -1 +1,4 @@
-For convenience reasons Banshee is distributed with a unmodified binary executable of Bison. Bison is not integrated into Banshee in any way and is used as a tool during the build process. Bison is licensed under GPL which you must respect if you integrate it into your application or modify its source. You may download the Bison source and view the license terms on "https://www.gnu.org/software/bison". 
+For convenience reasons Banshee is distributed with a unmodified binary executable of Bison. 
+Bison is not integrated into Banshee in any way and is used as a tool during the build process. 
+Bison is licensed under GPL which you must respect if you integrate it into your application or 
+modify its source. You may download the Bison source and view the license terms on "https://www.gnu.org/software/bison". 

+ 8 - 8
MBansheeEditor/DbgGizmo.cs

@@ -20,15 +20,15 @@ namespace BansheeEditor
                 iconTexture = new SpriteTexture(iconTex);
                 iconTexture = new SpriteTexture(iconTex);
             }
             }
 
 
-            Gizmos.DrawCube(target.sceneObject.Position, new Vector3(1, 1, 1));
-            Gizmos.DrawSphere(target.sceneObject.Position + 2 * Vector3.xAxis, 1.0f);
-            Gizmos.DrawWireCube(target.sceneObject.Position + 4 * Vector3.xAxis, new Vector3(1, 1, 1));
-            Gizmos.DrawWireSphere(target.sceneObject.Position + 6 * Vector3.xAxis, 1.0f);
-            Gizmos.DrawLine(target.sceneObject.Position + 7.5f * Vector3.xAxis,
-                target.sceneObject.Position + 8.5f * Vector3.xAxis);
-            Gizmos.DrawFrustum(target.sceneObject.Position + 10 * Vector3.xAxis, 1920.0f / 1080.0f, 90, 1.0f, 1000.0f);
+            Gizmos.DrawCube(target.SceneObject.Position, new Vector3(1, 1, 1));
+            Gizmos.DrawSphere(target.SceneObject.Position + 2 * Vector3.xAxis, 1.0f);
+            Gizmos.DrawWireCube(target.SceneObject.Position + 4 * Vector3.xAxis, new Vector3(1, 1, 1));
+            Gizmos.DrawWireSphere(target.SceneObject.Position + 6 * Vector3.xAxis, 1.0f);
+            Gizmos.DrawLine(target.SceneObject.Position + 7.5f * Vector3.xAxis,
+                target.SceneObject.Position + 8.5f * Vector3.xAxis);
+            Gizmos.DrawFrustum(target.SceneObject.Position + 10 * Vector3.xAxis, 1920.0f / 1080.0f, 90, 1.0f, 1000.0f);
 
 
-            Gizmos.DrawIcon(target.sceneObject.Position + new Vector3(0, 10, 0), iconTexture, false);
+            Gizmos.DrawIcon(target.SceneObject.Position + new Vector3(0, 10, 0), iconTexture, false);
         }
         }
     }
     }
 }
 }

+ 3 - 3
MBansheeEditor/DebugCameraHandle.cs

@@ -18,7 +18,7 @@ namespace BansheeEditor
 
 
         protected override void PreInput()
         protected override void PreInput()
         {
         {
-            xAxis.Position = target.sceneObject.Position;
+            xAxis.Position = target.SceneObject.Position;
         }
         }
 
 
         protected override void PostInput()
         protected override void PostInput()
@@ -28,14 +28,14 @@ namespace BansheeEditor
 
 
         protected override void Draw()
         protected override void Draw()
         {
         {
-            Vector3 end = target.sceneObject.Position + Vector3.xAxis * 5;
+            Vector3 end = target.SceneObject.Position + Vector3.xAxis * 5;
 
 
             if (xAxis.State == HandleSlider.StateType.Active)
             if (xAxis.State == HandleSlider.StateType.Active)
                 HandleDrawing.SetColor(Color.White);
                 HandleDrawing.SetColor(Color.White);
             else
             else
                 HandleDrawing.SetColor(Color.Green);
                 HandleDrawing.SetColor(Color.Green);
 
 
-            HandleDrawing.DrawLine(target.sceneObject.Position, end);
+            HandleDrawing.DrawLine(target.SceneObject.Position, end);
         }
         }
     }
     }
 }
 }

+ 5 - 0
MBansheeEditor/ProjectWindow.cs

@@ -1186,6 +1186,11 @@ namespace BansheeEditor
                 selectionArea.height = dragSelectionStart.y - dragSelectionEnd.y;
                 selectionArea.height = dragSelectionStart.y - dragSelectionEnd.y;
             }
             }
 
 
+            Rect2I maxBounds = contentScrollArea.Layout.Bounds;
+            maxBounds.x = 0;
+            maxBounds.y = 0;
+            selectionArea.Clip(maxBounds);
+
             return selectionArea;
             return selectionArea;
         }
         }
 
 

+ 2 - 2
MBansheeEditor/Scene/Handles.cs

@@ -44,10 +44,10 @@ namespace BansheeEditor
 
 
         public static float GetHandleSize(Camera camera, Vector3 position)
         public static float GetHandleSize(Camera camera, Vector3 position)
         {
         {
-            Vector3 cameraPos = camera.sceneObject.Position;
+            Vector3 cameraPos = camera.SceneObject.Position;
 
 
 		    Vector3 diff = position - cameraPos;
 		    Vector3 diff = position - cameraPos;
-		    float distAlongViewDir = Math.Abs(Vector3.Dot(diff, camera.sceneObject.Rotation.Forward));
+		    float distAlongViewDir = Math.Abs(Vector3.Dot(diff, camera.SceneObject.Rotation.Forward));
 
 
             return distAlongViewDir * EditorSettings.DefaultHandleSize;
             return distAlongViewDir * EditorSettings.DefaultHandleSize;
         }
         }

+ 4 - 4
MBansheeEditor/Scene/RotateHandle.cs

@@ -112,7 +112,7 @@ namespace BansheeEditor
 
 
             // Draw free rotate handle
             // Draw free rotate handle
             //// Rotate it so it always faces the camera, and move it forward a bit to always render in front
             //// Rotate it so it always faces the camera, and move it forward a bit to always render in front
-            Vector3 freeHandleNormal = EditorApplication.SceneViewCamera.sceneObject.Rotation.Rotate(GetZDir());
+            Vector3 freeHandleNormal = EditorApplication.SceneViewCamera.SceneObject.Rotation.Rotate(GetZDir());
             Vector3 offset = freeHandleNormal*0.1f;
             Vector3 offset = freeHandleNormal*0.1f;
 
 
             HandleDrawing.DrawWireDisc(offset, freeHandleNormal, 1.0f, handleSize);
             HandleDrawing.DrawWireDisc(offset, freeHandleNormal, 1.0f, handleSize);
@@ -120,19 +120,19 @@ namespace BansheeEditor
 
 
         private Degree GetXStartAngle()
         private Degree GetXStartAngle()
         {
         {
-            Vector3 xStartDir = Vector3.Cross(EditorApplication.SceneViewCamera.sceneObject.Forward, GetXDir());
+            Vector3 xStartDir = Vector3.Cross(EditorApplication.SceneViewCamera.SceneObject.Forward, GetXDir());
             return PointOnCircleToAngle(GetXDir(), xStartDir);
             return PointOnCircleToAngle(GetXDir(), xStartDir);
         }
         }
 
 
         private Degree GetYStartAngle()
         private Degree GetYStartAngle()
         {
         {
-            Vector3 yStartDir = Vector3.Cross(EditorApplication.SceneViewCamera.sceneObject.Forward, GetYDir());
+            Vector3 yStartDir = Vector3.Cross(EditorApplication.SceneViewCamera.SceneObject.Forward, GetYDir());
             return PointOnCircleToAngle(GetYDir(), yStartDir);
             return PointOnCircleToAngle(GetYDir(), yStartDir);
         }
         }
 
 
         private Degree GetZStartAngle()
         private Degree GetZStartAngle()
         {
         {
-            Vector3 zStartDir = Vector3.Cross(EditorApplication.SceneViewCamera.sceneObject.Forward, GetZDir());
+            Vector3 zStartDir = Vector3.Cross(EditorApplication.SceneViewCamera.SceneObject.Forward, GetZDir());
             return PointOnCircleToAngle(GetZDir(), zStartDir);
             return PointOnCircleToAngle(GetZDir(), zStartDir);
         }
         }
 
 

+ 2 - 2
MBansheeEditor/Scene/ScaleHandle.cs

@@ -49,7 +49,7 @@ namespace BansheeEditor
 
 
             float handleSize = Handles.GetHandleSize(EditorApplication.SceneViewCamera, position);
             float handleSize = Handles.GetHandleSize(EditorApplication.SceneViewCamera, position);
             Vector3 freeAxisOffset = (Vector3.xAxis * -0.3f + Vector3.yAxis * -0.3f) * handleSize;
             Vector3 freeAxisOffset = (Vector3.xAxis * -0.3f + Vector3.yAxis * -0.3f) * handleSize;
-            freeAxis.Rotation = EditorApplication.SceneViewCamera.sceneObject.Rotation;
+            freeAxis.Rotation = EditorApplication.SceneViewCamera.SceneObject.Rotation;
             freeAxis.Position = position + freeAxis.Rotation.Rotate(freeAxisOffset);
             freeAxis.Position = position + freeAxis.Rotation.Rotate(freeAxisOffset);
         }
         }
 
 
@@ -126,7 +126,7 @@ namespace BansheeEditor
 
 
             Vector3 offset = Vector3.zAxis*0.1f;
             Vector3 offset = Vector3.zAxis*0.1f;
 
 
-            Quaternion cameraRot = EditorApplication.SceneViewCamera.sceneObject.Rotation;
+            Quaternion cameraRot = EditorApplication.SceneViewCamera.SceneObject.Rotation;
             bottomLeft = cameraRot.Rotate(bottomLeft + offset);
             bottomLeft = cameraRot.Rotate(bottomLeft + offset);
             topLeft = cameraRot.Rotate(topLeft + offset);
             topLeft = cameraRot.Rotate(topLeft + offset);
             topRight = cameraRot.Rotate(topRight + offset);
             topRight = cameraRot.Rotate(topRight + offset);

+ 6 - 6
MBansheeEditor/Scene/SceneCamera.cs

@@ -89,14 +89,14 @@ namespace BansheeEditor
                 Quaternion camRot = yRot * xRot;
                 Quaternion camRot = yRot * xRot;
                 camRot.Normalize();
                 camRot.Normalize();
 
 
-                sceneObject.Rotation = camRot;
+                SceneObject.Rotation = camRot;
 		    }
 		    }
 
 
             Vector3 direction = Vector3.zero;
             Vector3 direction = Vector3.zero;
-            if (goingForward) direction += sceneObject.Forward;
-            if (goingBack) direction -= sceneObject.Forward;
-            if (goingRight) direction += sceneObject.Right;
-            if (goingLeft) direction -= sceneObject.Right;
+            if (goingForward) direction += SceneObject.Forward;
+            if (goingBack) direction -= SceneObject.Forward;
+            if (goingRight) direction += SceneObject.Right;
+            if (goingLeft) direction -= SceneObject.Right;
 
 
             if (direction.SqrdMagnitude != 0)
             if (direction.SqrdMagnitude != 0)
             {
             {
@@ -118,7 +118,7 @@ namespace BansheeEditor
             if (currentSpeed > tooSmall)
             if (currentSpeed > tooSmall)
             {
             {
                 Vector3 velocity = direction * currentSpeed;
                 Vector3 velocity = direction * currentSpeed;
-                sceneObject.Move(velocity * frameDelta);
+                SceneObject.Move(velocity * frameDelta);
             }
             }
         }
         }
     }
     }

+ 95 - 3
MBansheeEditor/Scene/SceneWindow.cs

@@ -1,5 +1,6 @@
 using System;
 using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
+using System.IO;
 using System.Linq;
 using System.Linq;
 using System.Text;
 using System.Text;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
@@ -10,6 +11,7 @@ namespace BansheeEditor
     internal sealed class SceneWindow : EditorWindow
     internal sealed class SceneWindow : EditorWindow
     {
     {
         private const int HeaderHeight = 20;
         private const int HeaderHeight = 20;
+        private const float DefaultPlacementDepth = 5.0f;
 
 
         private Camera camera;
         private Camera camera;
         private SceneCamera cameraController;
         private SceneCamera cameraController;
@@ -38,6 +40,10 @@ namespace BansheeEditor
 
 
         private int editorSettingsHash = int.MaxValue;
         private int editorSettingsHash = int.MaxValue;
 
 
+        // Drag & drop
+        private bool dragActive;
+        private SceneObject draggedSO;
+
         public Camera GetCamera()
         public Camera GetCamera()
         {
         {
             return camera;
             return camera;
@@ -112,7 +118,7 @@ namespace BansheeEditor
         {
         {
             if (camera != null)
             if (camera != null)
             {
             {
-                camera.sceneObject.Destroy();
+                camera.SceneObject.Destroy();
             }
             }
         }
         }
 
 
@@ -156,11 +162,97 @@ namespace BansheeEditor
                 }
                 }
             }
             }
 
 
+            Vector2I scenePos;
+            bool inBounds = ScreenToScenePos(Input.PointerPosition, out scenePos);
+
+            bool draggedOver = DragDrop.DragInProgress || DragDrop.DropInProgress;
+            draggedOver &= inBounds && DragDrop.Type == DragDropType.Resource;
+
+            if (DragDrop.DropInProgress)
+            {
+                Debug.Log("DROP IN PROGRESS: " + draggedOver + " - " + inBounds + " - " + DragDrop.Type);
+            }
+
+            if (draggedOver)
+            {
+                if (DragDrop.DropInProgress)
+                {
+                    dragActive = false;
+                    draggedSO = null;
+
+                    Debug.Log("DROPPED DRAGON");
+                }
+                else
+                {
+                    if (!dragActive)
+                    {
+                        dragActive = true;
+
+                        ResourceDragDropData dragData = (ResourceDragDropData)DragDrop.Data;
+
+                        string draggedMeshPath = "";
+                        string[] draggedPaths = dragData.Paths;
+
+                        for (int i = 0; i < draggedPaths.Length; i++)
+                        {
+
+                            LibraryEntry entry = ProjectLibrary.GetEntry(draggedPaths[i]);
+                            if (entry != null && entry.Type == LibraryEntryType.File)
+                            {
+                                FileEntry fileEntry = (FileEntry) entry;
+                                if (fileEntry.ResType == ResourceType.Mesh)
+                                {
+                                    draggedMeshPath = draggedPaths[i];
+                                    break;
+                                }
+                            }
+                        }
+
+                        if (!string.IsNullOrEmpty(draggedMeshPath))
+                        {
+                            string meshName = Path.GetFileName(draggedMeshPath);
+
+                            draggedSO = new SceneObject(meshName);
+                            Mesh mesh = ProjectLibrary.Load<Mesh>(draggedMeshPath);
+                            Material material = new Material(Builtin.DiffuseShader);
+
+                            Renderable renderable = draggedSO.AddComponent<Renderable>();
+                            renderable.Mesh = mesh;
+                            renderable.SetMaterial(material);
+
+                            Debug.Log("CREATED DRAGON");
+                        }
+                    }
+
+                    if (draggedSO != null)
+                    {
+                        Ray worldRay = camera.ScreenToWorldRay(scenePos);
+                        draggedSO.Position = worldRay*DefaultPlacementDepth;
+                    }
+                }
+
+                return;
+            }
+            else
+            {
+                if (dragActive)
+                {
+                    dragActive = false;
+
+                    if (draggedSO != null)
+                    {
+                        Debug.Log("DESTROYED DRAGON");
+
+                        draggedSO.Destroy();
+                        draggedSO = null;
+                    }
+                }
+            }
+
             if (!HasFocus)
             if (!HasFocus)
                 return;
                 return;
 
 
-            Vector2I scenePos;
-            if (ScreenToScenePos(Input.PointerPosition, out scenePos))
+            if (inBounds)
             {
             {
                 if (Input.IsPointerButtonDown(PointerButton.Left))
                 if (Input.IsPointerButtonDown(PointerButton.Left))
                 {
                 {

+ 8 - 0
MBansheeEngine/Builtin.cs

@@ -9,7 +9,15 @@ namespace BansheeEngine
             get { return Internal_GetWhiteTexture(); }
             get { return Internal_GetWhiteTexture(); }
         }
         }
 
 
+        public static Shader DiffuseShader
+        {
+            get { return Internal_GetDiffuseShader(); }
+        }
+
         [MethodImpl(MethodImplOptions.InternalCall)]
         [MethodImpl(MethodImplOptions.InternalCall)]
         private static extern SpriteTexture Internal_GetWhiteTexture();
         private static extern SpriteTexture Internal_GetWhiteTexture();
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern Shader Internal_GetDiffuseShader();
     }
     }
 }
 }

+ 6 - 6
MBansheeEngine/Camera.cs

@@ -141,16 +141,16 @@ namespace BansheeEngine
         public Vector2 WorldToClip(Vector3 value) { return handler.WorldToClip(value); }
         public Vector2 WorldToClip(Vector3 value) { return handler.WorldToClip(value); }
         public Vector3 WorldToView(Vector3 value) { return handler.WorldToView(value); }
         public Vector3 WorldToView(Vector3 value) { return handler.WorldToView(value); }
 
 
-        public Vector3 ScreenToWorld(Vector2I value) { return handler.ScreenToWorld(value); }
-        public Vector3 ScreenToView(Vector2I value) { return handler.ScreenToView(value); }
+        public Vector3 ScreenToWorld(Vector2I value, float depth = 0.5f) { return handler.ScreenToWorld(value, depth); }
+        public Vector3 ScreenToView(Vector2I value, float depth = 0.5f) { return handler.ScreenToView(value, depth); }
         public Vector2 ScreenToClip(Vector2I value) { return handler.ScreenToClip(value); }
         public Vector2 ScreenToClip(Vector2I value) { return handler.ScreenToClip(value); }
 
 
         public Vector3 ViewToWorld(Vector3 value) { return handler.ViewToWorld(value); }
         public Vector3 ViewToWorld(Vector3 value) { return handler.ViewToWorld(value); }
         public Vector2I ViewToScreen(Vector3 value) { return handler.ViewToScreen(value); }
         public Vector2I ViewToScreen(Vector3 value) { return handler.ViewToScreen(value); }
         public Vector2 ViewToClip(Vector3 value) { return handler.ViewToClip(value); }
         public Vector2 ViewToClip(Vector3 value) { return handler.ViewToClip(value); }
 
 
-        public Vector3 ClipToWorld(Vector2 value) { return handler.ClipToWorld(value); }
-        public Vector3 ClipToView(Vector2 value) { return handler.ClipToView(value); }
+        public Vector3 ClipToWorld(Vector2 value, float depth = 0.5f) { return handler.ClipToWorld(value, depth); }
+        public Vector3 ClipToView(Vector2 value, float depth = 0.5f) { return handler.ClipToView(value, depth); }
         public Vector2I ClipToScreen(Vector2 value) { return handler.ClipToScreen(value); }
         public Vector2I ClipToScreen(Vector2 value) { return handler.ClipToScreen(value); }
 
 
         public Ray ScreenToWorldRay(Vector2I value) { return handler.ScreenToWorldRay(value); }
         public Ray ScreenToWorldRay(Vector2I value) { return handler.ScreenToWorldRay(value); }
@@ -176,7 +176,7 @@ namespace BansheeEngine
             if (handler != null)
             if (handler != null)
                 handler.OnDestroy();
                 handler.OnDestroy();
 
 
-            handler = new CameraHandler(sceneObject);
+            handler = new CameraHandler(SceneObject);
 
 
             // Restore saved values after reset
             // Restore saved values after reset
             handler.aspectRatio = serializableData.aspectRatio;
             handler.aspectRatio = serializableData.aspectRatio;
@@ -198,7 +198,7 @@ namespace BansheeEngine
 
 
         private void Update()
         private void Update()
         {
         {
-            handler.UpdateView(sceneObject);
+            handler.UpdateView(SceneObject);
         }
         }
 
 
         private void OnDestroy()
         private void OnDestroy()

+ 8 - 8
MBansheeEngine/CameraHandler.cs

@@ -156,16 +156,16 @@ namespace BansheeEngine
         internal Vector2 WorldToClip(Vector3 value) { return Internal_WorldToClip(mCachedPtr, value); }
         internal Vector2 WorldToClip(Vector3 value) { return Internal_WorldToClip(mCachedPtr, value); }
         internal Vector3 WorldToView(Vector3 value) { return Internal_WorldToView(mCachedPtr, value); }
         internal Vector3 WorldToView(Vector3 value) { return Internal_WorldToView(mCachedPtr, value); }
 
 
-        internal Vector3 ScreenToWorld(Vector2I value) { return Internal_ScreenToWorld(mCachedPtr, value); }
-        internal Vector3 ScreenToView(Vector2I value) { return Internal_ScreenToView(mCachedPtr, value); }
+        internal Vector3 ScreenToWorld(Vector2I value, float depth) { return Internal_ScreenToWorld(mCachedPtr, value, depth); }
+        internal Vector3 ScreenToView(Vector2I value, float depth) { return Internal_ScreenToView(mCachedPtr, value, depth); }
         internal Vector2 ScreenToClip(Vector2I value) { return Internal_ScreenToClip(mCachedPtr, value); }
         internal Vector2 ScreenToClip(Vector2I value) { return Internal_ScreenToClip(mCachedPtr, value); }
 
 
         internal Vector3 ViewToWorld(Vector3 value) { return Internal_ViewToWorld(mCachedPtr, value); }
         internal Vector3 ViewToWorld(Vector3 value) { return Internal_ViewToWorld(mCachedPtr, value); }
         internal Vector2I ViewToScreen(Vector3 value) { return Internal_ViewToScreen(mCachedPtr, value); }
         internal Vector2I ViewToScreen(Vector3 value) { return Internal_ViewToScreen(mCachedPtr, value); }
         internal Vector2 ViewToClip(Vector3 value) { return Internal_ViewToClip(mCachedPtr, value); }
         internal Vector2 ViewToClip(Vector3 value) { return Internal_ViewToClip(mCachedPtr, value); }
 
 
-        internal Vector3 ClipToWorld(Vector2 value) { return Internal_ClipToWorld(mCachedPtr, value); }
-        internal Vector3 ClipToView(Vector2 value) { return Internal_ClipToView(mCachedPtr, value); }
+        internal Vector3 ClipToWorld(Vector2 value, float depth) { return Internal_ClipToWorld(mCachedPtr, value, depth); }
+        internal Vector3 ClipToView(Vector2 value, float depth) { return Internal_ClipToView(mCachedPtr, value, depth); }
         internal Vector2I ClipToScreen(Vector2 value) { return Internal_ClipToScreen(mCachedPtr, value); }
         internal Vector2I ClipToScreen(Vector2 value) { return Internal_ClipToScreen(mCachedPtr, value); }
 
 
         internal Ray ScreenToWorldRay(Vector2I value) { return Internal_ScreenToWorldRay(mCachedPtr, value); }
         internal Ray ScreenToWorldRay(Vector2I value) { return Internal_ScreenToWorldRay(mCachedPtr, value); }
@@ -287,9 +287,9 @@ namespace BansheeEngine
         private static extern Vector3 Internal_WorldToView(IntPtr instance, Vector3 value);
         private static extern Vector3 Internal_WorldToView(IntPtr instance, Vector3 value);
 
 
         [MethodImpl(MethodImplOptions.InternalCall)]
         [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern Vector3 Internal_ScreenToWorld(IntPtr instance, Vector2I value);
+        private static extern Vector3 Internal_ScreenToWorld(IntPtr instance, Vector2I value, float depth);
         [MethodImpl(MethodImplOptions.InternalCall)]
         [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern Vector3 Internal_ScreenToView(IntPtr instance, Vector2I value);
+        private static extern Vector3 Internal_ScreenToView(IntPtr instance, Vector2I value, float depth);
         [MethodImpl(MethodImplOptions.InternalCall)]
         [MethodImpl(MethodImplOptions.InternalCall)]
         private static extern Vector2 Internal_ScreenToClip(IntPtr instance, Vector2I value);
         private static extern Vector2 Internal_ScreenToClip(IntPtr instance, Vector2I value);
 
 
@@ -301,9 +301,9 @@ namespace BansheeEngine
         private static extern Vector2 Internal_ViewToClip(IntPtr instance, Vector3 value);
         private static extern Vector2 Internal_ViewToClip(IntPtr instance, Vector3 value);
 
 
         [MethodImpl(MethodImplOptions.InternalCall)]
         [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern Vector3 Internal_ClipToWorld(IntPtr instance, Vector2 value);
+        private static extern Vector3 Internal_ClipToWorld(IntPtr instance, Vector2 value, float depth);
         [MethodImpl(MethodImplOptions.InternalCall)]
         [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern Vector3 Internal_ClipToView(IntPtr instance, Vector2 value);
+        private static extern Vector3 Internal_ClipToView(IntPtr instance, Vector2 value, float depth);
         [MethodImpl(MethodImplOptions.InternalCall)]
         [MethodImpl(MethodImplOptions.InternalCall)]
         private static extern Vector2I Internal_ClipToScreen(IntPtr instance, Vector2 value);
         private static extern Vector2I Internal_ClipToScreen(IntPtr instance, Vector2 value);
 
 

+ 1 - 1
MBansheeEngine/Component.cs

@@ -9,7 +9,7 @@ namespace BansheeEngine
         protected Component()
         protected Component()
         { }
         { }
 
 
-        public SceneObject sceneObject
+        public SceneObject SceneObject
         {
         {
             get { return Internal_GetSceneObject(mCachedPtr); }
             get { return Internal_GetSceneObject(mCachedPtr); }
         }
         }

+ 4 - 0
MBansheeEngine/Mesh.cs

@@ -6,6 +6,10 @@ namespace BansheeEngine
 {
 {
     public class Mesh : Resource
     public class Mesh : Resource
     {
     {
+        // For internal use by the runtime
+        private Mesh()
+        { }
+
         public Mesh(int numVertices, int numIndices, MeshTopology topology = MeshTopology.TriangleList,
         public Mesh(int numVertices, int numIndices, MeshTopology topology = MeshTopology.TriangleList,
             MeshUsage usage = MeshUsage.Default, VertexType vertex = VertexType.Position, 
             MeshUsage usage = MeshUsage.Default, VertexType vertex = VertexType.Position, 
             IndexType index = IndexType.Index32)
             IndexType index = IndexType.Index32)

+ 9 - 5
MBansheeEngine/Renderable.cs

@@ -22,7 +22,11 @@ namespace BansheeEngine
                 handler.Mesh = value; 
                 handler.Mesh = value; 
                 serializableData.mesh = value;
                 serializableData.mesh = value;
 
 
-                Material[] newMaterials = new Material[value.SubMeshCount];
+                int subMeshCount = 0;
+                if (value != null)
+                    subMeshCount = value.SubMeshCount;
+
+                Material[] newMaterials = new Material[subMeshCount];
                 int numToCopy = MathEx.Min(newMaterials.Length, serializableData.materials.Length);
                 int numToCopy = MathEx.Min(newMaterials.Length, serializableData.materials.Length);
                 Array.Copy(serializableData.materials, newMaterials, numToCopy);
                 Array.Copy(serializableData.materials, newMaterials, numToCopy);
                 serializableData.materials = newMaterials;
                 serializableData.materials = newMaterials;
@@ -55,13 +59,13 @@ namespace BansheeEngine
 
 
         public Bounds Bounds
         public Bounds Bounds
         {
         {
-            get { return handler.GetBounds(sceneObject); }
+            get { return handler.GetBounds(SceneObject); }
         }
         }
 
 
         private void OnInitialize()
         private void OnInitialize()
         {
         {
             serializableData.materials = new Material[0];
             serializableData.materials = new Material[0];
-            serializableData.layers = 0xFFFFFFFFFFFFFFFF;
+            serializableData.layers = 1;
         }
         }
 
 
         private void OnReset()
         private void OnReset()
@@ -69,7 +73,7 @@ namespace BansheeEngine
             if (handler != null)
             if (handler != null)
                 handler.OnDestroy();
                 handler.OnDestroy();
 
 
-            handler = new RenderableHandler(sceneObject);
+            handler = new RenderableHandler(SceneObject);
 
 
             // Restore saved values after reset
             // Restore saved values after reset
             handler.Mesh = serializableData.mesh;
             handler.Mesh = serializableData.mesh;
@@ -85,7 +89,7 @@ namespace BansheeEngine
 
 
         private void Update()
         private void Update()
         {
         {
-            handler.UpdateTransform(sceneObject);
+            handler.UpdateTransform(SceneObject);
         }
         }
 
 
         private void OnDestroy()
         private void OnDestroy()

+ 5 - 1
MBansheeEngine/RenderableHandler.cs

@@ -15,7 +15,11 @@ namespace BansheeEngine
             {
             {
                 mesh = value;
                 mesh = value;
 
 
-                Material[] newMaterials = new Material[mesh.SubMeshCount];
+                int subMeshCount = 0;
+                if (mesh != null)
+                    subMeshCount = mesh.SubMeshCount;
+
+                Material[] newMaterials = new Material[subMeshCount];
                 int numToCopy = MathEx.Min(newMaterials.Length, materials.Length);
                 int numToCopy = MathEx.Min(newMaterials.Length, materials.Length);
                 Array.Copy(materials, newMaterials, numToCopy);
                 Array.Copy(materials, newMaterials, numToCopy);
                 materials = newMaterials;
                 materials = newMaterials;

+ 28 - 4
SBansheeEditor/Source/BsScriptDragDropManager.cpp

@@ -225,10 +225,34 @@ namespace BansheeEngine
 
 
 	MonoObject* ScriptDragDropManager::getDropData() const
 	MonoObject* ScriptDragDropManager::getDropData() const
 	{
 	{
-		if (mDropType == ScriptDragDropType::SceneObject)
-			return ScriptSceneObjectDragDropData::create(mDroppedSceneObjects);
-		else if (mDropType == ScriptDragDropType::Resource)
-			return ScriptResourceDragDropData::create(mDroppedPaths);
+		if (DragAndDropManager::instance().isDragInProgress())
+		{
+			UINT32 nativeType = DragAndDropManager::instance().getDragTypeId();
+
+			if (nativeType == (UINT32)DragAndDropType::SceneObject)
+			{
+				DraggedSceneObjects* draggedData = reinterpret_cast<DraggedSceneObjects*>(DragAndDropManager::instance().getDragData());
+
+				Vector<HSceneObject> draggedSceneObjects;
+				for (UINT32 i = 0; i < draggedData->numObjects; i++)
+					draggedSceneObjects.push_back(draggedData->objects[i]);
+
+				return ScriptSceneObjectDragDropData::create(draggedSceneObjects);
+			}
+			else if (nativeType == (UINT32)DragAndDropType::Resources)
+			{
+				DraggedResources* draggedResources = reinterpret_cast<DraggedResources*>(DragAndDropManager::instance().getDragData());
+
+				return ScriptResourceDragDropData::create(draggedResources->resourcePaths);
+			}
+		}
+		else
+		{
+			if (mDropType == ScriptDragDropType::SceneObject)
+				return ScriptSceneObjectDragDropData::create(mDroppedSceneObjects);
+			else if (mDropType == ScriptDragDropType::Resource)
+				return ScriptResourceDragDropData::create(mDroppedPaths);
+		}
 
 
 		return nullptr;
 		return nullptr;
 	}
 	}

+ 9 - 1
SBansheeEditor/Source/BsScriptProjectLibrary.cpp

@@ -15,6 +15,7 @@
 #include "BsScriptFont.h"
 #include "BsScriptFont.h"
 #include "BsScriptImportOptions.h"
 #include "BsScriptImportOptions.h"
 #include "BsEditorApplication.h"
 #include "BsEditorApplication.h"
+#include "BsPath.h"
 
 
 using namespace std::placeholders;
 using namespace std::placeholders;
 
 
@@ -80,7 +81,14 @@ namespace BansheeEngine
 	{
 	{
 		Path resourcePath = MonoUtil::monoToWString(path);
 		Path resourcePath = MonoUtil::monoToWString(path);
 
 
-		HResource resource = Resources::instance().load(resourcePath);
+		HResource resource;
+		ProjectLibrary::LibraryEntry* entry = ProjectLibrary::instance().findEntry(resourcePath);
+		if (entry != nullptr && entry->type == ProjectLibrary::LibraryEntryType::File)
+		{
+			ProjectLibrary::ResourceEntry* resEntry = static_cast <ProjectLibrary::ResourceEntry*>(entry);
+			resource = Resources::instance().loadFromUUID(resEntry->meta->getUUID());
+		}
+		
 		if (!resource)
 		if (!resource)
 			return nullptr;
 			return nullptr;
 
 

+ 1 - 0
SBansheeEngine/Include/BsScriptBuiltin.h

@@ -12,6 +12,7 @@ namespace BansheeEngine
 
 
 	private:
 	private:
 		static MonoObject* internal_getWhiteTexture();
 		static MonoObject* internal_getWhiteTexture();
+		static MonoObject* internal_getDiffuseShader();
 		
 		
 		ScriptBuiltin(MonoObject* instance);
 		ScriptBuiltin(MonoObject* instance);
 	};
 	};

+ 4 - 4
SBansheeEngine/Include/BsScriptCameraHandler.h

@@ -81,16 +81,16 @@ namespace BansheeEngine
 		static Vector2 internal_WorldToClip(ScriptCameraHandler* instance, Vector3 value);
 		static Vector2 internal_WorldToClip(ScriptCameraHandler* instance, Vector3 value);
 		static Vector3 internal_WorldToView(ScriptCameraHandler* instance, Vector3 value);
 		static Vector3 internal_WorldToView(ScriptCameraHandler* instance, Vector3 value);
 
 
-		static Vector3 internal_ScreenToWorld(ScriptCameraHandler* instance, Vector2I value);
-		static Vector3 internal_ScreenToView(ScriptCameraHandler* instance, Vector2I value);
+		static Vector3 internal_ScreenToWorld(ScriptCameraHandler* instance, Vector2I value, float depth);
+		static Vector3 internal_ScreenToView(ScriptCameraHandler* instance, Vector2I value, float depth);
 		static Vector2 internal_ScreenToClip(ScriptCameraHandler* instance, Vector2I value);
 		static Vector2 internal_ScreenToClip(ScriptCameraHandler* instance, Vector2I value);
 
 
 		static Vector3 internal_ViewToWorld(ScriptCameraHandler* instance, Vector3 value);
 		static Vector3 internal_ViewToWorld(ScriptCameraHandler* instance, Vector3 value);
 		static Vector2I internal_ViewToScreen(ScriptCameraHandler* instance, Vector3 value);
 		static Vector2I internal_ViewToScreen(ScriptCameraHandler* instance, Vector3 value);
 		static Vector2 internal_ViewToClip(ScriptCameraHandler* instance, Vector3 value);
 		static Vector2 internal_ViewToClip(ScriptCameraHandler* instance, Vector3 value);
 
 
-		static Vector3 internal_ClipToWorld(ScriptCameraHandler* instance, Vector2 value);
-		static Vector3 internal_ClipToView(ScriptCameraHandler* instance, Vector2 value);
+		static Vector3 internal_ClipToWorld(ScriptCameraHandler* instance, Vector2 value, float depth);
+		static Vector3 internal_ClipToView(ScriptCameraHandler* instance, Vector2 value, float depth);
 		static Vector2I internal_ClipToScreen(ScriptCameraHandler* instance, Vector2 value);
 		static Vector2I internal_ClipToScreen(ScriptCameraHandler* instance, Vector2 value);
 
 
 		static Ray internal_ScreenToWorldRay(ScriptCameraHandler* instance, Vector2I value);
 		static Ray internal_ScreenToWorldRay(ScriptCameraHandler* instance, Vector2I value);

+ 13 - 0
SBansheeEngine/Source/BsScriptBuiltin.cpp

@@ -5,6 +5,7 @@
 #include "BsMonoUtil.h"
 #include "BsMonoUtil.h"
 #include "BsBuiltinResources.h"
 #include "BsBuiltinResources.h"
 #include "BsScriptSpriteTexture.h"
 #include "BsScriptSpriteTexture.h"
+#include "BsScriptShader.h"
 #include "BsScriptResourceManager.h"
 #include "BsScriptResourceManager.h"
 
 
 namespace BansheeEngine
 namespace BansheeEngine
@@ -16,6 +17,7 @@ namespace BansheeEngine
 	void ScriptBuiltin::initRuntimeData()
 	void ScriptBuiltin::initRuntimeData()
 	{
 	{
 		metaData.scriptClass->addInternalCall("Internal_GetWhiteTexture", &ScriptBuiltin::internal_getWhiteTexture);
 		metaData.scriptClass->addInternalCall("Internal_GetWhiteTexture", &ScriptBuiltin::internal_getWhiteTexture);
+		metaData.scriptClass->addInternalCall("Internal_GetDiffuseShader", &ScriptBuiltin::internal_getDiffuseShader);
 	}
 	}
 
 
 	MonoObject* ScriptBuiltin::internal_getWhiteTexture()
 	MonoObject* ScriptBuiltin::internal_getWhiteTexture()
@@ -28,4 +30,15 @@ namespace BansheeEngine
 
 
 		return scriptSpriteTex->getManagedInstance();
 		return scriptSpriteTex->getManagedInstance();
 	}
 	}
+
+	MonoObject* ScriptBuiltin::internal_getDiffuseShader()
+	{
+		HShader diffuseShader = BuiltinResources::instance().getDiffuseShader();
+
+		ScriptShader* scriptShader = ScriptResourceManager::instance().getScriptShader(diffuseShader);
+		if (scriptShader == nullptr)
+			scriptShader = ScriptResourceManager::instance().createScriptShader(diffuseShader);
+
+		return scriptShader->getManagedInstance();
+	}
 }
 }

+ 8 - 8
SBansheeEngine/Source/BsScriptCameraHandler.cpp

@@ -328,14 +328,14 @@ namespace BansheeEngine
 		return instance->mCameraHandler->worldToViewPoint(value);
 		return instance->mCameraHandler->worldToViewPoint(value);
 	}
 	}
 
 
-	Vector3 ScriptCameraHandler::internal_ScreenToWorld(ScriptCameraHandler* instance, Vector2I value)
+	Vector3 ScriptCameraHandler::internal_ScreenToWorld(ScriptCameraHandler* instance, Vector2I value, float depth)
 	{
 	{
-		return instance->mCameraHandler->screenToWorldPoint(value);
+		return instance->mCameraHandler->screenToWorldPoint(value, depth);
 	}
 	}
 
 
-	Vector3 ScriptCameraHandler::internal_ScreenToView(ScriptCameraHandler* instance, Vector2I value)
+	Vector3 ScriptCameraHandler::internal_ScreenToView(ScriptCameraHandler* instance, Vector2I value, float depth)
 	{
 	{
-		return instance->mCameraHandler->screenToViewPoint(value);
+		return instance->mCameraHandler->screenToViewPoint(value, depth);
 	}
 	}
 
 
 	Vector2 ScriptCameraHandler::internal_ScreenToClip(ScriptCameraHandler* instance, Vector2I value)
 	Vector2 ScriptCameraHandler::internal_ScreenToClip(ScriptCameraHandler* instance, Vector2I value)
@@ -358,14 +358,14 @@ namespace BansheeEngine
 		return instance->mCameraHandler->viewToClipPoint(value);
 		return instance->mCameraHandler->viewToClipPoint(value);
 	}
 	}
 
 
-	Vector3 ScriptCameraHandler::internal_ClipToWorld(ScriptCameraHandler* instance, Vector2 value)
+	Vector3 ScriptCameraHandler::internal_ClipToWorld(ScriptCameraHandler* instance, Vector2 value, float depth)
 	{
 	{
-		return instance->mCameraHandler->clipToWorldPoint(value);
+		return instance->mCameraHandler->clipToWorldPoint(value, depth);
 	}
 	}
 
 
-	Vector3 ScriptCameraHandler::internal_ClipToView(ScriptCameraHandler* instance, Vector2 value)
+	Vector3 ScriptCameraHandler::internal_ClipToView(ScriptCameraHandler* instance, Vector2 value, float depth)
 	{
 	{
-		return instance->mCameraHandler->clipToViewPoint(value);
+		return instance->mCameraHandler->clipToViewPoint(value, depth);
 	}
 	}
 
 
 	Vector2I ScriptCameraHandler::internal_ClipToScreen(ScriptCameraHandler* instance, Vector2 value)
 	Vector2I ScriptCameraHandler::internal_ClipToScreen(ScriptCameraHandler* instance, Vector2 value)

+ 7 - 0
SBansheeEngine/Source/BsScriptMaterial.cpp

@@ -9,6 +9,7 @@
 #include "BsScriptTexture2D.h"
 #include "BsScriptTexture2D.h"
 #include "BsScriptTexture3D.h"
 #include "BsScriptTexture3D.h"
 #include "BsScriptTextureCube.h"
 #include "BsScriptTextureCube.h"
+#include <BsBuiltinResources.h>
 
 
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
@@ -54,6 +55,9 @@ namespace BansheeEngine
 		if (shader != nullptr)
 		if (shader != nullptr)
 			nativeShader = shader->getShaderHandle();
 			nativeShader = shader->getShaderHandle();
 
 
+		if (nativeShader == nullptr)
+			nativeShader = BuiltinResources::instance().getDummyShader();
+
 		HMaterial material = Material::create(nativeShader);
 		HMaterial material = Material::create(nativeShader);
 		ScriptResourceManager::instance().createScriptMaterial(instance, material);
 		ScriptResourceManager::instance().createScriptMaterial(instance, material);
 	}
 	}
@@ -78,6 +82,9 @@ namespace BansheeEngine
 		if (shader != nullptr)
 		if (shader != nullptr)
 			nativeShader = shader->getShaderHandle();
 			nativeShader = shader->getShaderHandle();
 
 
+		if (nativeShader == nullptr)
+			nativeShader = BuiltinResources::instance().getDummyShader();
+
 		nativeInstance->getMaterialHandle()->setShader(nativeShader);
 		nativeInstance->getMaterialHandle()->setShader(nativeShader);
 	}
 	}
 
 

+ 8 - 8
TODO.txt

@@ -17,9 +17,7 @@ TODO - Setting Material array parameters isn't possible from C#
 GUIResourceField doesn't distinguish between tex2d, tex3d and texcube.
 GUIResourceField doesn't distinguish between tex2d, tex3d and texcube.
 
 
 ---------------------------------------------------------------------
 ---------------------------------------------------------------------
-
-When windows first open they show up as all black. This is problematic with progress bar window since it may appear for just one frame and it only shows up as black square during that time.
- - Later on after I fix this issue I should probably just make a special case and not open the progress bar if all import is done in one go
+ProjectLibrary import
 
 
 I'm not sure if queued dependencies are handled properly. They're handled on an internal ProjectLibrary loop but perhaps I should
 I'm not sure if queued dependencies are handled properly. They're handled on an internal ProjectLibrary loop but perhaps I should
 return them in checkForModifications?
 return them in checkForModifications?
@@ -27,8 +25,10 @@ return them in checkForModifications?
 ----------------------------------------------------------------------
 ----------------------------------------------------------------------
 Project window
 Project window
 
 
-Simple tasks:
- - Hook up scene view drag and drop instantiation
+Dropping doesn't work. endDrag in DragAndDropManager gets called before cursorReleased()
+Destroying Renderable objects doesn't seem to properly clear them from the renderer
+Dragging the selection area past the scroll area borders will expand the scroll area
+Add mesh scale to FBX importer (and default it to 0.01 or whatever makes the dragon look normal sized)
 
 
 Later:
 Later:
  - Hook up ping effect so it triggers when I select a resource or sceneobject
  - Hook up ping effect so it triggers when I select a resource or sceneobject
@@ -37,6 +37,8 @@ Later:
  - Save & restore scroll position when Refresh happens
  - Save & restore scroll position when Refresh happens
  - F2 and context menu for renaming assets (or when clicking on a solo selected asset)
  - F2 and context menu for renaming assets (or when clicking on a solo selected asset)
    - Also make sure the names contain only valid path characters
    - Also make sure the names contain only valid path characters
+ - Delete with a dialog box to confirm
+
 ----------------------------------------------------------------------
 ----------------------------------------------------------------------
 Resources
 Resources
  - Load/Unload/UnloadUnused
  - Load/Unload/UnloadUnused
@@ -104,9 +106,7 @@ AFTER I have scene widget in C#:
  - Test custom handles from C#
  - Test custom handles from C#
  - Test handle snapping
  - Test handle snapping
 
 
-Need a way to drag and drop items from Scene tree view to Scene view
- - When dragging a mesh it should by default create a SceneObject with a renderable
- - I might want a C# DragAndDrop class? It can contain Resource or SceneObject only for now, similar to Selection
+Make sure that camera controls only work when scene view is in focus
 
 
 ----------------------------------------------------------------------
 ----------------------------------------------------------------------
 Other
 Other