Browse Source

Added a debug model in Scene view
Various DockManager fixes

Marko Pintera 11 years ago
parent
commit
830c1f5fe8

+ 6 - 0
BansheeCore/Include/BsGpuParam.h

@@ -134,6 +134,9 @@ namespace BansheeEngine
 			UINT32 sizeBytes = std::min(elementSizeBytes, (UINT32)sizeof(T)); // Truncate if it doesn't fit within parameter size
 			UINT32 sizeBytes = std::min(elementSizeBytes, (UINT32)sizeof(T)); // Truncate if it doesn't fit within parameter size
 			GpuParamBlockPtr paramBlock = getParamBlock(mParamDesc->paramBlockSlot);
 			GpuParamBlockPtr paramBlock = getParamBlock(mParamDesc->paramBlockSlot);
 
 
+			if (paramBlock == nullptr)
+				return;
+
 			if (TransposePolicy<T>::transposeEnabled(getTransposeMatrices()))
 			if (TransposePolicy<T>::transposeEnabled(getTransposeMatrices()))
 			{
 			{
 				T transposed = TransposePolicy<T>::transpose(value);
 				T transposed = TransposePolicy<T>::transpose(value);
@@ -175,6 +178,9 @@ namespace BansheeEngine
 			UINT32 sizeBytes = std::min(elementSizeBytes, (UINT32)sizeof(T));
 			UINT32 sizeBytes = std::min(elementSizeBytes, (UINT32)sizeof(T));
 			GpuParamBlockPtr paramBlock = getParamBlock(mParamDesc->paramBlockSlot);
 			GpuParamBlockPtr paramBlock = getParamBlock(mParamDesc->paramBlockSlot);
 
 
+			if (paramBlock == nullptr)
+				return T();
+			
 			T value;
 			T value;
 			paramBlock->read((mParamDesc->cpuMemOffset + arrayIdx * mParamDesc->arrayElementStride) * sizeof(UINT32), &value, sizeBytes);
 			paramBlock->read((mParamDesc->cpuMemOffset + arrayIdx * mParamDesc->arrayElementStride) * sizeof(UINT32), &value, sizeBytes);
 
 

+ 0 - 2
BansheeEditor/BansheeEditor.vcxproj

@@ -314,7 +314,6 @@
     <ClInclude Include="Include\BsProjectResourceMeta.h" />
     <ClInclude Include="Include\BsProjectResourceMeta.h" />
     <ClInclude Include="Include\BsProjectResourceMetaRTTI.h" />
     <ClInclude Include="Include\BsProjectResourceMetaRTTI.h" />
     <ClInclude Include="Include\BsGUIVector2Field.h" />
     <ClInclude Include="Include\BsGUIVector2Field.h" />
-    <ClInclude Include="Include\BsDebugCamera.h" />
     <ClInclude Include="Include\BsResourceImporter.h" />
     <ClInclude Include="Include\BsResourceImporter.h" />
     <ClInclude Include="Include\BsSceneCameraController.h" />
     <ClInclude Include="Include\BsSceneCameraController.h" />
     <ClInclude Include="Include\BsSceneEditorWidget.h" />
     <ClInclude Include="Include\BsSceneEditorWidget.h" />
@@ -371,7 +370,6 @@
     <ClCompile Include="Source\BsSceneCameraController.cpp" />
     <ClCompile Include="Source\BsSceneCameraController.cpp" />
     <ClCompile Include="Source\BsSceneEditorWidget.cpp" />
     <ClCompile Include="Source\BsSceneEditorWidget.cpp" />
     <ClCompile Include="Source\BsUndoRedo.cpp" />
     <ClCompile Include="Source\BsUndoRedo.cpp" />
-    <ClCompile Include="Source\BsDebugCamera.cpp" />
     <ClCompile Include="Source\BsEditorApplication.cpp" />
     <ClCompile Include="Source\BsEditorApplication.cpp" />
     <ClCompile Include="Source\BsTestTextSprite.cpp" />
     <ClCompile Include="Source\BsTestTextSprite.cpp" />
     <ClCompile Include="Source\DbgEditorWidget1.cpp" />
     <ClCompile Include="Source\DbgEditorWidget1.cpp" />

+ 0 - 6
BansheeEditor/BansheeEditor.vcxproj.filters

@@ -180,9 +180,6 @@
     <ClInclude Include="Include\BsTestTextSprite.h">
     <ClInclude Include="Include\BsTestTextSprite.h">
       <Filter>Header Files</Filter>
       <Filter>Header Files</Filter>
     </ClInclude>
     </ClInclude>
-    <ClInclude Include="Include\BsDebugCamera.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
     <ClInclude Include="Include\BsProjectResourceMeta.h">
     <ClInclude Include="Include\BsProjectResourceMeta.h">
       <Filter>Header Files\Editor</Filter>
       <Filter>Header Files\Editor</Filter>
     </ClInclude>
     </ClInclude>
@@ -338,9 +335,6 @@
     <ClCompile Include="Source\BsGUIFieldBase.cpp">
     <ClCompile Include="Source\BsGUIFieldBase.cpp">
       <Filter>Source Files\Editor</Filter>
       <Filter>Source Files\Editor</Filter>
     </ClCompile>
     </ClCompile>
-    <ClCompile Include="Source\BsDebugCamera.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="Source\BsTestTextSprite.cpp">
     <ClCompile Include="Source\BsTestTextSprite.cpp">
       <Filter>Source Files</Filter>
       <Filter>Source Files</Filter>
     </ClCompile>
     </ClCompile>

+ 0 - 39
BansheeEditor/Include/BsDebugCamera.h

@@ -1,39 +0,0 @@
-#pragma once
-
-#include "BsPrerequisites.h"
-#include "BsComponent.h"
-#include "BsMath.h"
-
-namespace BansheeEngine
-{
-	class DebugCamera : public Component
-	{
-	private:
-		float mCurrentSpeed;
-
-		Degree mPitch;
-		Degree mYaw;
-		bool mLastButtonState;
-
-		HCamera mCamera;
-
-		static const float START_SPEED;
-		static const float TOP_SPEED;
-		static const float ACCELERATION;
-		static const float FAST_MODE_MULTIPLIER;
-		static const float ROTATION_SPEED; // Degrees/second
-
-		/************************************************************************/
-		/* 						COMPONENT OVERRIDES                      		*/
-		/************************************************************************/
-	protected:
-		friend class SceneObject;
-
-		/** Standard constructor.
-        */
-		DebugCamera(const HSceneObject& parent);
-
-	public:
-		virtual void update();
-	};
-}

+ 9 - 7
BansheeEditor/Include/BsDockManager.h

@@ -17,18 +17,19 @@ namespace BansheeEngine
 		class DockContainer
 		class DockContainer
 		{
 		{
 		public:
 		public:
-			DockContainer();
-			DockContainer(DockContainer* parent);
+			DockContainer(DockManager* manager);
+			DockContainer(DockManager* manager, DockContainer* parent);
 			~DockContainer();
 			~DockContainer();
 
 
 			void setArea(INT32 x, INT32 y, UINT32 width, UINT32 height);
 			void setArea(INT32 x, INT32 y, UINT32 width, UINT32 height);
 			void makeLeaf(GUIWidget* widgetParent, RenderWindow* parentWindow);
 			void makeLeaf(GUIWidget* widgetParent, RenderWindow* parentWindow);
 			void makeLeaf(EditorWidgetContainer* existingContainer);
 			void makeLeaf(EditorWidgetContainer* existingContainer);
-			void splitContainer(GUIWidget* widgetParent, RenderWindow* parentWindow, bool horizontal, bool newChildIsFirst, float splitPosition = 0.5f);
-			void addLeft(GUIWidget* widgetParent, RenderWindow* parentWindow, EditorWidgetBase* widget);
-			void addRight(GUIWidget* widgetParent, RenderWindow* parentWindow, EditorWidgetBase* widget);
-			void addTop(GUIWidget* widgetParent, RenderWindow* parentWindow, EditorWidgetBase* widget);
-			void addBottom(GUIWidget* widgetParent, RenderWindow* parentWindow, EditorWidgetBase* widget);
+			void splitContainer(bool horizontal, bool newChildIsFirst, float splitPosition = 0.5f);
+			void makeSplit(GUIWidget* widgetParent, DockManager::DockContainer* first, DockManager::DockContainer* second, bool horizontal, float splitPosition);
+			void addLeft(EditorWidgetBase* widget);
+			void addRight(EditorWidgetBase* widget);
+			void addTop(EditorWidgetBase* widget);
+			void addBottom(EditorWidgetBase* widget);
 
 
 			void addWidget(EditorWidgetBase* widget);
 			void addWidget(EditorWidgetBase* widget);
 			void addWidget(const String& name);
 			void addWidget(const String& name);
@@ -51,6 +52,7 @@ namespace BansheeEngine
 			bool mIsLeaf;
 			bool mIsLeaf;
 			DockContainer* mChildren[2];
 			DockContainer* mChildren[2];
 			DockContainer* mParent;
 			DockContainer* mParent;
+			DockManager* mManager;
 			EditorWidgetContainer* mWidgets;
 			EditorWidgetContainer* mWidgets;
 			GUIDockSlider* mSlider;
 			GUIDockSlider* mSlider;
 			RectI mArea;
 			RectI mArea;

+ 0 - 94
BansheeEditor/Source/BsDebugCamera.cpp

@@ -1,94 +0,0 @@
-#include "BsDebugCamera.h"
-#include "BsInput.h"
-#include "BsVector3.h"
-#include "BsTime.h"
-#include "BsMath.h"
-#include "BsSceneObject.h"
-#include "BsCamera.h"
-#include "BsPlatform.h"
-
-namespace BansheeEngine
-{
-	const float DebugCamera::START_SPEED = 40.0f;
-	const float DebugCamera::TOP_SPEED = 130.0f;
-	const float DebugCamera::ACCELERATION = 10.0f;
-	const float DebugCamera::FAST_MODE_MULTIPLIER = 2.0f;
-	const float DebugCamera::ROTATION_SPEED = 0.5f; // Degrees/pixel
-
-	DebugCamera::DebugCamera(const HSceneObject& parent)
-		:Component(parent), mPitch(0.0f), mYaw(0.0f), mLastButtonState(false)
-	{
-		setName("DebugCamera");
-
-		mCamera = sceneObject()->getComponent<Camera>();
-		mCamera->setNearClipDistance(5);
-
-		sceneObject()->setPosition(Vector3(0,0,0));
-		sceneObject()->lookAt(Vector3(0,0,-1));
-	}
-
-	void DebugCamera::update()
-	{
-		bool goingForward = gInput().isButtonHeld(BC_W) || gInput().isButtonHeld(BC_UP);
-		bool goingBack = gInput().isButtonHeld(BC_S) || gInput().isButtonHeld(BC_DOWN);
-		bool goingLeft = gInput().isButtonHeld(BC_A) || gInput().isButtonHeld(BC_LEFT);
-		bool goingRight = gInput().isButtonHeld(BC_D) || gInput().isButtonHeld(BC_RIGHT);
-		bool fastMove = gInput().isButtonHeld(BC_LSHIFT);
-		bool camRotating = gInput().isButtonHeld(BC_MOUSE_RIGHT);
-
-		if(camRotating != mLastButtonState)
-		{
-			if(camRotating)
-				Platform::hideCursor();
-			else
-				Platform::showCursor();
-
-			mLastButtonState = camRotating;
-		}
-
-		Vector3 direction = Vector3::ZERO;
-		if (goingForward) direction += SO()->getForward();
-		if (goingBack) direction -= SO()->getForward();
-		if (goingRight) direction += SO()->getRight();
-		if (goingLeft) direction -= SO()->getRight();
-
-		if (direction.squaredLength() != 0)
-		{
-			direction.normalize();
-
-			float multiplier = 1.0f;
-			if(fastMove)
-				multiplier = FAST_MODE_MULTIPLIER;
-
-			mCurrentSpeed = Math::clamp(mCurrentSpeed + ACCELERATION * gTime().getFrameDelta(), START_SPEED, TOP_SPEED);
-			mCurrentSpeed *= multiplier;
-		}
-		else
-		{
-			mCurrentSpeed = 0.0f;
-		}
-
-		float tooSmall = std::numeric_limits<float>::epsilon();
-		if(mCurrentSpeed > tooSmall)
-		{
-			Vector3 velocity = direction * mCurrentSpeed;
-			SO()->move(velocity * gTime().getFrameDelta());
-		}
-
-		if(camRotating)
-		{
-			mYaw += Degree(gInput().getAxisValue((UINT32)InputAxis::MouseX) * ROTATION_SPEED);
-			mPitch += Degree(gInput().getAxisValue((UINT32)InputAxis::MouseY) * ROTATION_SPEED);
-
-			Quaternion yRot;
-			yRot.fromAxisAngle(Vector3::UNIT_Y, Radian(mYaw));
-
-			Quaternion xRot;
-			xRot.fromAxisAngle(yRot.xAxis(), Radian(mPitch));
-
-			Quaternion camRot = xRot * yRot;
-
-			SO()->setRotation(camRot);
-		}
-	}
-}

+ 65 - 30
BansheeEditor/Source/BsDockManager.cpp

@@ -36,17 +36,17 @@ namespace BansheeEngine
 	const Color DockManager::TINT_COLOR = Color(0.44f, 0.44f, 0.44f, 0.22f);
 	const Color DockManager::TINT_COLOR = Color(0.44f, 0.44f, 0.44f, 0.22f);
 	const Color DockManager::HIGHLIGHT_COLOR = Color(0.44f, 0.44f, 0.44f, 0.42f);
 	const Color DockManager::HIGHLIGHT_COLOR = Color(0.44f, 0.44f, 0.44f, 0.42f);
 
 
-	DockManager::DockContainer::DockContainer()
+	DockManager::DockContainer::DockContainer(DockManager* manager)
 		:mIsLeaf(true), mWidgets(nullptr), mSplitPosition(0.5f),
 		:mIsLeaf(true), mWidgets(nullptr), mSplitPosition(0.5f),
-		mIsHorizontal(false), mParent(nullptr), mSlider(nullptr)
+		mIsHorizontal(false), mParent(nullptr), mSlider(nullptr), mManager(manager)
 	{
 	{
 		mChildren[0] = nullptr;
 		mChildren[0] = nullptr;
 		mChildren[1] = nullptr;
 		mChildren[1] = nullptr;
 	}
 	}
 
 
-	DockManager::DockContainer::DockContainer(DockContainer* parent)
+	DockManager::DockContainer::DockContainer(DockManager* manager, DockContainer* parent)
 		:mIsLeaf(false), mWidgets(nullptr), mSplitPosition(0.5f),
 		:mIsLeaf(false), mWidgets(nullptr), mSplitPosition(0.5f),
-		mIsHorizontal(false), mParent(parent), mSlider(nullptr)
+		mIsHorizontal(false), mParent(parent), mSlider(nullptr), mManager(manager)
 	{
 	{
 		mChildren[0] = nullptr;
 		mChildren[0] = nullptr;
 		mChildren[1] = nullptr;
 		mChildren[1] = nullptr;
@@ -166,57 +166,79 @@ namespace BansheeEngine
 		mWidgets->setSize(mArea.width, mArea.height);
 		mWidgets->setSize(mArea.width, mArea.height);
 	}
 	}
 
 
-	void DockManager::DockContainer::addLeft(GUIWidget* widgetParent, RenderWindow* parentWindow, EditorWidgetBase* widget)
+	void DockManager::DockContainer::addLeft(EditorWidgetBase* widget)
 	{
 	{
 		if(mIsLeaf)
 		if(mIsLeaf)
-			splitContainer(widgetParent, parentWindow, false, true);
+			splitContainer(false, true);
 
 
 		mChildren[0]->addWidget(widget);
 		mChildren[0]->addWidget(widget);
 	}
 	}
 
 
-	void DockManager::DockContainer::addRight(GUIWidget* widgetParent, RenderWindow* parentWindow, EditorWidgetBase* widget)
+	void DockManager::DockContainer::addRight(EditorWidgetBase* widget)
 	{
 	{
 		if(mIsLeaf)
 		if(mIsLeaf)
-			splitContainer(widgetParent, parentWindow, false, false);
+			splitContainer(false, false);
 
 
 		mChildren[1]->addWidget(widget);
 		mChildren[1]->addWidget(widget);
 	}
 	}
 
 
-	void DockManager::DockContainer::addTop(GUIWidget* widgetParent, RenderWindow* parentWindow, EditorWidgetBase* widget)
+	void DockManager::DockContainer::addTop(EditorWidgetBase* widget)
 	{
 	{
 		if(mIsLeaf)
 		if(mIsLeaf)
-			splitContainer(widgetParent, parentWindow, true, true);
+			splitContainer(true, true);
 
 
 		mChildren[0]->addWidget(widget);
 		mChildren[0]->addWidget(widget);
 	}
 	}
 
 
-	void DockManager::DockContainer::addBottom(GUIWidget* widgetParent, RenderWindow* parentWindow, EditorWidgetBase* widget)
+	void DockManager::DockContainer::addBottom(EditorWidgetBase* widget)
 	{
 	{
 		if(mIsLeaf)
 		if(mIsLeaf)
-			splitContainer(widgetParent, parentWindow, true, false);
+			splitContainer(true, false);
 
 
 		mChildren[1]->addWidget(widget);
 		mChildren[1]->addWidget(widget);
 	}
 	}
 
 
-	void DockManager::DockContainer::splitContainer(GUIWidget* widgetParent, RenderWindow* parentWindow, bool horizontal, bool newChildIsFirst, float splitPosition)
+	void DockManager::DockContainer::splitContainer(bool horizontal, bool newChildIsFirst, float splitPosition)
 	{
 	{
+		DockContainer* children[2];
+
 		UINT32 idxA = newChildIsFirst ? 0 : 1;
 		UINT32 idxA = newChildIsFirst ? 0 : 1;
 		UINT32 idxB = (idxA + 1) % 2;
 		UINT32 idxB = (idxA + 1) % 2;
 
 
-		mChildren[idxA] = bs_new<DockContainer>(this);
-		mChildren[idxB] = bs_new<DockContainer>(this);
+		children[idxA] = bs_new<DockContainer>(mManager, this);
+		children[idxB] = bs_new<DockContainer>(mManager, this);
 
 
 		mWidgets->onWidgetClosed.clear();
 		mWidgets->onWidgetClosed.clear();
+		
+		children[idxA]->makeLeaf(mManager->_getParentWidget(), mManager->mParentWindow);
+		children[idxB]->makeLeaf(mWidgets);
+
+		mWidgets = nullptr;
+		makeSplit(mManager->_getParentWidget(), children[0], children[1], horizontal, splitPosition);
+	}
 
 
-		mChildren[idxA]->makeLeaf(widgetParent, parentWindow);
-		mChildren[idxB]->makeLeaf(mWidgets);
+	void DockManager::DockContainer::makeSplit(GUIWidget* widgetParent, DockManager::DockContainer* first, DockManager::DockContainer* second, bool horizontal, float splitPosition)
+	{
+		mChildren[0] = first;
+		mChildren[1] = second;
 
 
 		mIsLeaf = false;
 		mIsLeaf = false;
 		mIsHorizontal = horizontal;
 		mIsHorizontal = horizontal;
-		mWidgets = nullptr;
 		mSplitPosition = splitPosition;
 		mSplitPosition = splitPosition;
 
 
-		if(horizontal)
+		if (mWidgets != nullptr)
+		{
+			bs_delete(mWidgets);
+			mWidgets = nullptr;
+		}
+
+		if (mSlider != nullptr)
+		{
+			GUIElement::destroy(mSlider);
+			mSlider = nullptr;
+		}
+
+		if (horizontal)
 		{
 		{
 			mSlider = GUIDockSlider::create(true, "DockSliderBtn");
 			mSlider = GUIDockSlider::create(true, "DockSliderBtn");
 			mSlider->_setWidgetDepth(widgetParent->getDepth());
 			mSlider->_setWidgetDepth(widgetParent->getDepth());
@@ -294,10 +316,23 @@ namespace BansheeEngine
 				else
 				else
 					sibling = mParent->mChildren[0];
 					sibling = mParent->mChildren[0];
 
 
-				sibling->mWidgets->onWidgetClosed.clear();
+				if (sibling->mIsLeaf)
+				{
+					sibling->mWidgets->onWidgetClosed.clear();
 
 
-				mParent->makeLeaf(sibling->mWidgets);
-				sibling->mWidgets = nullptr;
+					mParent->makeLeaf(sibling->mWidgets);
+					sibling->mWidgets = nullptr;
+				}
+				else
+				{
+					mParent->makeSplit(mManager->_getParentWidget(), sibling->mChildren[0], sibling->mChildren[1], sibling->mIsHorizontal, sibling->mSplitPosition);
+
+					sibling->mChildren[0]->mParent = mParent;
+					sibling->mChildren[1]->mParent = mParent;
+
+					sibling->mChildren[0] = nullptr;
+					sibling->mChildren[1] = nullptr;
+				}
 
 
 				bs_delete(sibling);
 				bs_delete(sibling);
 				bs_delete(this);
 				bs_delete(this);
@@ -374,7 +409,7 @@ namespace BansheeEngine
 
 
 	DockManager::DockManager(RenderWindow* parentWindow, const GUILayoutOptions& layoutOptions)
 	DockManager::DockManager(RenderWindow* parentWindow, const GUILayoutOptions& layoutOptions)
 		:GUIElementContainer(layoutOptions), mParentWindow(parentWindow), mMouseOverContainer(nullptr), mHighlightedDropLoc(DockLocation::None),
 		:GUIElementContainer(layoutOptions), mParentWindow(parentWindow), mMouseOverContainer(nullptr), mHighlightedDropLoc(DockLocation::None),
-		mShowOverlay(false), mAddedRenderCallback(false)
+		mShowOverlay(false), mAddedRenderCallback(false), mRootContainer(this)
 	{
 	{
 		mTopDropPolygon = bs_newN<Vector2>(4);
 		mTopDropPolygon = bs_newN<Vector2>(4);
 		mBotDropPolygon = bs_newN<Vector2>(4);
 		mBotDropPolygon = bs_newN<Vector2>(4);
@@ -464,16 +499,16 @@ namespace BansheeEngine
 			switch(location)
 			switch(location)
 			{
 			{
 			case DockLocation::Left:
 			case DockLocation::Left:
-				container->addLeft(_getParentWidget(), mParentWindow, widgetToInsert);
+				container->addLeft(widgetToInsert);
 				break;
 				break;
 			case DockLocation::Right:
 			case DockLocation::Right:
-				container->addRight(_getParentWidget(), mParentWindow, widgetToInsert);
+				container->addRight(widgetToInsert);
 				break;
 				break;
 			case DockLocation::Top:
 			case DockLocation::Top:
-				container->addTop(_getParentWidget(), mParentWindow, widgetToInsert);
+				container->addTop(widgetToInsert);
 				break;
 				break;
 			case DockLocation::Bottom:
 			case DockLocation::Bottom:
-				container->addBottom(_getParentWidget(), mParentWindow, widgetToInsert);
+				container->addBottom(widgetToInsert);
 				break;
 				break;
 			}
 			}
 		}
 		}
@@ -497,7 +532,7 @@ namespace BansheeEngine
 
 
 	void DockManager::closeAll()
 	void DockManager::closeAll()
 	{
 	{
-		mRootContainer = DockContainer();
+		mRootContainer = DockContainer(this);
 		mMouseOverContainer = nullptr;
 		mMouseOverContainer = nullptr;
 	}
 	}
 
 
@@ -616,7 +651,7 @@ namespace BansheeEngine
 			}
 			}
 		}
 		}
 
 
-		mRootContainer = DockContainer();
+		mRootContainer = DockContainer(this);
 
 
 		// Load layout
 		// Load layout
 		struct StackEntry
 		struct StackEntry
@@ -671,7 +706,7 @@ namespace BansheeEngine
 
 
 					leafEntry = GetLeafEntry(curEntry.layoutEntry->children[1], 0);
 					leafEntry = GetLeafEntry(curEntry.layoutEntry->children[1], 0);
 
 
-					curEntry.container->splitContainer(_getParentWidget(), mParentWindow, curEntry.layoutEntry->horizontalSplit, false, curEntry.layoutEntry->splitPosition);
+					curEntry.container->splitContainer(curEntry.layoutEntry->horizontalSplit, false, curEntry.layoutEntry->splitPosition);
 
 
 					DockContainer* otherChild = curEntry.container->mChildren[1];
 					DockContainer* otherChild = curEntry.container->mChildren[1];
 					OpenWidgets(otherChild, leafEntry->widgetNames);
 					OpenWidgets(otherChild, leafEntry->widgetNames);

+ 13 - 28
BansheeEditor/Source/BsEditorApplication.cpp

@@ -36,6 +36,7 @@
 #include "BsGUIButton.h"
 #include "BsGUIButton.h"
 #include "BsGUILayout.h"
 #include "BsGUILayout.h"
 #include "BsEvent.h"
 #include "BsEvent.h"
+#include "BsRenderer.h"
 
 
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
@@ -161,8 +162,8 @@ namespace BansheeEngine
 		{
 		{
 		case RenderSystemPlugin::DX11:
 		case RenderSystemPlugin::DX11:
 		{
 		{
-										 psLoc = L"C:\\Projects\\BansheeEngine\\Data\\hlsl11_ps.gpuprog";
-										 vsLoc = L"C:\\Projects\\BansheeEngine\\Data\\hlsl11_vs.gpuprog";
+										 psLoc = L"..\\..\\..\\..\\Data\\hlsl11_ps.gpuprog";
+										 vsLoc = L"..\\..\\..\\..\\Data\\hlsl11_vs.gpuprog";
 										 language = "hlsl";
 										 language = "hlsl";
 										 psProfile = GPP_PS_4_0;
 										 psProfile = GPP_PS_4_0;
 										 vsProfile = GPP_VS_4_0;
 										 vsProfile = GPP_VS_4_0;
@@ -172,8 +173,8 @@ namespace BansheeEngine
 		}
 		}
 		case RenderSystemPlugin::DX9:
 		case RenderSystemPlugin::DX9:
 		{
 		{
-										psLoc = L"C:\\Projects\\BansheeEngine\\Data\\hlsl9_ps.gpuprog";
-										vsLoc = L"C:\\Projects\\BansheeEngine\\Data\\hlsl9_vs.gpuprog";
+										psLoc = L"..\\..\\..\\..\\Data\\hlsl9_ps.gpuprog";
+										vsLoc = L"..\\..\\..\\..\\Data\\hlsl9_vs.gpuprog";
 										language = "hlsl";
 										language = "hlsl";
 										psProfile = GPP_PS_2_0;
 										psProfile = GPP_PS_2_0;
 										vsProfile = GPP_VS_2_0;
 										vsProfile = GPP_VS_2_0;
@@ -183,8 +184,8 @@ namespace BansheeEngine
 		}
 		}
 		case RenderSystemPlugin::OpenGL:
 		case RenderSystemPlugin::OpenGL:
 		{
 		{
-										   psLoc = L"C:\\Projects\\BansheeEngine\\Data\\glsl_ps.gpuprog";
-										   vsLoc = L"C:\\Projects\\BansheeEngine\\Data\\glsl_vs.gpuprog";
+										   psLoc = L"..\\..\\..\\..\\Data\\glsl_ps.gpuprog";
+										   vsLoc = L"..\\..\\..\\..\\Data\\glsl_vs.gpuprog";
 										   language = "glsl";
 										   language = "glsl";
 										   psProfile = GPP_PS_2_0;
 										   psProfile = GPP_PS_2_0;
 										   vsProfile = GPP_VS_2_0;
 										   vsProfile = GPP_VS_2_0;
@@ -229,13 +230,13 @@ namespace BansheeEngine
 		mFragProgRef = gResources().load(L"C:\\fragProgCg.vprog");
 		mFragProgRef = gResources().load(L"C:\\fragProgCg.vprog");
 
 
 		mTestShader = Shader::create("TestShader");
 		mTestShader = Shader::create("TestShader");
-		mTestShader->addParameter("matViewProjection", "matViewProjection", GPDT_MATRIX_4X4);
-
-		if (mActiveRSPlugin == RenderSystemPlugin::DX11)
-			mTestShader->addParameter("input", "input", GPDT_STRUCT, 0, 2, 8);
+		mTestShader->addParameter("matWorldViewProj", "matWorldViewProj", GPDT_MATRIX_4X4, RPS_WorldViewProjTfrm);
 
 
 		mTestShader->addParameter("samp", "samp", GPOT_SAMPLER2D);
 		mTestShader->addParameter("samp", "samp", GPOT_SAMPLER2D);
 		mTestShader->addParameter("tex", "tex", GPOT_TEXTURE2D);
 		mTestShader->addParameter("tex", "tex", GPOT_TEXTURE2D);
+
+		mTestShader->setParamBlockAttribs("PerObject", true, GPBU_DYNAMIC, RBS_PerObject);
+
 		mNewTechniqueGL = mTestShader->addTechnique("GLRenderSystem", "BansheeRenderer");
 		mNewTechniqueGL = mTestShader->addTechnique("GLRenderSystem", "BansheeRenderer");
 		mNewPassGL = mNewTechniqueGL->addPass();
 		mNewPassGL = mNewTechniqueGL->addPass();
 		mNewPassGL->setVertexProgram(mVertProgRef);
 		mNewPassGL->setVertexProgram(mVertProgRef);
@@ -257,24 +258,8 @@ namespace BansheeEngine
 		mTestMaterial = Material::create();
 		mTestMaterial = Material::create();
 		mTestMaterial->setShader(mTestShader);
 		mTestMaterial->setShader(mTestShader);
 
 
-		mTestMaterial->setMat4("matViewProjection", Matrix4::IDENTITY);
-
-		if (mActiveRSPlugin == RenderSystemPlugin::DX11)
-		{
-			float dbgMultipliers1[2];
-			dbgMultipliers1[0] = 0.0f;
-			dbgMultipliers1[1] = 0.0f;
-
-			float dbgMultipliers2[2];
-			dbgMultipliers2[0] = 1.0f;
-			dbgMultipliers2[1] = 1.0f;
-
-			mTestMaterial->setStructData("input", dbgMultipliers1, sizeof(dbgMultipliers1), 0);
-			mTestMaterial->setStructData("input", dbgMultipliers2, sizeof(dbgMultipliers2), 1);
-		}
-
-		mTestTexRef = static_resource_cast<Texture>(Importer::instance().import(L"C:\\ArenaTowerDFS.psd"));
-		mDbgMeshRef = static_resource_cast<Mesh>(Importer::instance().import(L"C:\\X_Arena_Tower.FBX"));
+		mTestTexRef = static_resource_cast<Texture>(Importer::instance().import(L"..\\..\\..\\..\\Data\\Examples\\Dragon.tga"));
+		mDbgMeshRef = static_resource_cast<Mesh>(Importer::instance().import(L"..\\..\\..\\..\\Data\\Examples\\Dragon.fbx"));
 
 
 		gResources().save(mTestTexRef, L"C:\\ExportTest.tex", true);
 		gResources().save(mTestTexRef, L"C:\\ExportTest.tex", true);
 		gResources().save(mDbgMeshRef, L"C:\\ExportMesh.mesh", true);
 		gResources().save(mDbgMeshRef, L"C:\\ExportMesh.mesh", true);

+ 0 - 1
BansheeEditor/Source/BsMainEditorWindow.cpp

@@ -16,7 +16,6 @@
 
 
 // DEBUG ONLY
 // DEBUG ONLY
 #include "BsTestTextSprite.h"
 #include "BsTestTextSprite.h"
-#include "BsDebugCamera.h"
 #include "BsDrawHelper2D.h"
 #include "BsDrawHelper2D.h"
 #include "BsDrawHelper3D.h"
 #include "BsDrawHelper3D.h"
 #include "BsRectF.h"
 #include "BsRectF.h"

+ 38 - 27
BansheeEditor/Source/BsSceneCameraController.cpp

@@ -7,6 +7,7 @@
 #include "BsCamera.h"
 #include "BsCamera.h"
 #include "BsPlatform.h"
 #include "BsPlatform.h"
 #include "BsEditorApplication.h"
 #include "BsEditorApplication.h"
+#include "BsCursor.h"
 
 
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
@@ -23,7 +24,18 @@ namespace BansheeEngine
 	const float SceneCameraController::TOP_SPEED = 130.0f;
 	const float SceneCameraController::TOP_SPEED = 130.0f;
 	const float SceneCameraController::ACCELERATION = 10.0f;
 	const float SceneCameraController::ACCELERATION = 10.0f;
 	const float SceneCameraController::FAST_MODE_MULTIPLIER = 2.0f;
 	const float SceneCameraController::FAST_MODE_MULTIPLIER = 2.0f;
-	const float SceneCameraController::ROTATION_SPEED = 0.5f; // Degrees/pixel
+	const float SceneCameraController::ROTATION_SPEED = 360.0f; // Degrees/second
+
+	Degree wrapAngle(Degree angle)
+	{
+		if (angle.valueDegrees() < -360.0f)
+			angle += Degree(360.0f);
+
+		if (angle.valueDegrees() > 360.0f)
+			angle -= Degree(360.0f);
+
+		return angle;
+	}
 
 
 	SceneCameraController::SceneCameraController(const HSceneObject& parent)
 	SceneCameraController::SceneCameraController(const HSceneObject& parent)
 		:Component(parent), mPitch(0.0f), mYaw(0.0f), mLastButtonState(false)
 		:Component(parent), mPitch(0.0f), mYaw(0.0f), mLastButtonState(false)
@@ -38,12 +50,6 @@ namespace BansheeEngine
 		mRotate = VirtualButton(ROTATE_BTN);
 		mRotate = VirtualButton(ROTATE_BTN);
 		mHorizontal = VirtualAxis(HORIZONTAL_AXIS);
 		mHorizontal = VirtualAxis(HORIZONTAL_AXIS);
 		mVertical = VirtualAxis(VERTICAL_AXIS);
 		mVertical = VirtualAxis(VERTICAL_AXIS);
-
-		mCamera = sceneObject()->getComponent<Camera>();
-		mCamera->setNearClipDistance(5);
-
-		sceneObject()->setPosition(Vector3(0, 0, 0));
-		sceneObject()->lookAt(Vector3(0, 0, -1));
 	}
 	}
 
 
 	void SceneCameraController::update()
 	void SceneCameraController::update()
@@ -61,13 +67,34 @@ namespace BansheeEngine
 		if (camRotating != mLastButtonState)
 		if (camRotating != mLastButtonState)
 		{
 		{
 			if (camRotating)
 			if (camRotating)
-				Platform::hideCursor();
+				Cursor::instance().hide();
 			else
 			else
-				Platform::showCursor();
+				Cursor::instance().show();
 
 
 			mLastButtonState = camRotating;
 			mLastButtonState = camRotating;
 		}
 		}
 
 
+		float frameDelta = gTime().getFrameDelta();
+		if (camRotating)
+		{
+			mYaw += Degree(gVirtualInput().getAxisValue(mHorizontal) * ROTATION_SPEED * frameDelta);
+			mPitch += Degree(gVirtualInput().getAxisValue(mVertical) * ROTATION_SPEED * frameDelta);
+
+			mYaw = wrapAngle(mYaw);
+			mPitch = wrapAngle(mPitch);
+
+			Quaternion yRot;
+			yRot.fromAxisAngle(Vector3::UNIT_Y, Radian(mYaw));
+
+			Quaternion xRot;
+			xRot.fromAxisAngle(Vector3::UNIT_X, Radian(mPitch));
+
+			Quaternion camRot = yRot * xRot;
+			camRot.normalize();
+
+			SO()->setRotation(camRot);
+		}
+
 		Vector3 direction = Vector3::ZERO;
 		Vector3 direction = Vector3::ZERO;
 		if (goingForward) direction += SO()->getForward();
 		if (goingForward) direction += SO()->getForward();
 		if (goingBack) direction -= SO()->getForward();
 		if (goingBack) direction -= SO()->getForward();
@@ -82,7 +109,7 @@ namespace BansheeEngine
 			if (fastMove)
 			if (fastMove)
 				multiplier = FAST_MODE_MULTIPLIER;
 				multiplier = FAST_MODE_MULTIPLIER;
 
 
-			mCurrentSpeed = Math::clamp(mCurrentSpeed + ACCELERATION * gTime().getFrameDelta(), START_SPEED, TOP_SPEED);
+			mCurrentSpeed = Math::clamp(mCurrentSpeed + ACCELERATION * frameDelta, START_SPEED, TOP_SPEED);
 			mCurrentSpeed *= multiplier;
 			mCurrentSpeed *= multiplier;
 		}
 		}
 		else
 		else
@@ -94,23 +121,7 @@ namespace BansheeEngine
 		if (mCurrentSpeed > tooSmall)
 		if (mCurrentSpeed > tooSmall)
 		{
 		{
 			Vector3 velocity = direction * mCurrentSpeed;
 			Vector3 velocity = direction * mCurrentSpeed;
-			SO()->move(velocity * gTime().getFrameDelta());
-		}
-
-		if (camRotating)
-		{
-			mYaw += Degree(gVirtualInput().getAxisValue(mHorizontal) * ROTATION_SPEED);
-			mPitch += Degree(gVirtualInput().getAxisValue(mVertical) * ROTATION_SPEED);
-
-			Quaternion yRot;
-			yRot.fromAxisAngle(Vector3::UNIT_Y, Radian(mYaw));
-
-			Quaternion xRot;
-			xRot.fromAxisAngle(yRot.xAxis(), Radian(mPitch));
-
-			Quaternion camRot = xRot * yRot;
-
-			SO()->setRotation(camRot);
+			SO()->move(velocity * frameDelta);
 		}
 		}
 	}
 	}
 }
 }

+ 14 - 7
BansheeEditor/Source/BsSceneEditorWidget.cpp

@@ -21,21 +21,28 @@ namespace BansheeEngine
 		:EditorWidget<SceneEditorWidget>(HString(L"SceneEditorWidget"), parentContainer)
 		:EditorWidget<SceneEditorWidget>(HString(L"SceneEditorWidget"), parentContainer)
 	{
 	{
 		GUILayout& layout = mContent->getLayout();
 		GUILayout& layout = mContent->getLayout();
+
+		UINT32 width = 200; // TODO - Use proper width/height once I have texture resize working. Have some mininum limit (e.g. 4x4)
+		UINT32 height = 200;
 		
 		
-		mSceneRenderTarget = RenderTexture::create(TEX_TYPE_2D, getWidth(), getHeight());
+		mSceneRenderTarget = RenderTexture::create(TEX_TYPE_2D, width, height);
 		mSceneRenderTarget->setPriority(1);
 		mSceneRenderTarget->setPriority(1);
 
 
-		HSceneObject sceneCameraGO = SceneObject::create("SceneCamera");
-		mCamera = sceneCameraGO->addComponent<Camera>(mSceneRenderTarget, 0.0f, 0.0f, 1.0f, 1.0f);
+		HSceneObject sceneCameraSO = SceneObject::create("SceneCamera");
+		mCamera = sceneCameraSO->addComponent<Camera>(mSceneRenderTarget, 0.0f, 0.0f, 1.0f, 1.0f);
+
+		sceneCameraSO->setPosition(Vector3(0, 0, 0));
+		sceneCameraSO->lookAt(Vector3(0, 0, -3));
 
 
-		sceneCameraGO->setPosition(Vector3(0, 0, 0));
-		sceneCameraGO->lookAt(Vector3(0, 0, -3));
+		// DEBUG ONLY
+		sceneCameraSO->setPosition(Vector3(-130.0f, 140.0f, 650.0f));
+		sceneCameraSO->lookAt(Vector3(0, 0, 0));
 
 
 		mCamera->setPriority(1);
 		mCamera->setPriority(1);
 		mCamera->setNearClipDistance(5);
 		mCamera->setNearClipDistance(5);
-		mCamera->setAspectRatio(getWidth() / (float)getHeight());
+		mCamera->setAspectRatio(width / (float)height);
 
 
-		sceneCameraGO->addComponent<SceneCameraController>();
+		sceneCameraSO->addComponent<SceneCameraController>();
 
 
 		layout.addElement(GUIRenderTexture::create(mSceneRenderTarget));
 		layout.addElement(GUIRenderTexture::create(mSceneRenderTarget));
 	}
 	}

+ 1 - 1
BansheeEditorExec/BsEditorExec.cpp

@@ -11,7 +11,7 @@ int CALLBACK WinMain(
 	_In_  int nCmdShow
 	_In_  int nCmdShow
 	)
 	)
 {
 {
-	EditorApplication::startUp(RenderSystemPlugin::DX9);
+	EditorApplication::startUp(RenderSystemPlugin::DX11);
 	EditorApplication::instance().runMainLoop();
 	EditorApplication::instance().runMainLoop();
 	EditorApplication::shutDown();
 	EditorApplication::shutDown();
 
 

+ 9 - 0
SceneView.txt

@@ -1,4 +1,13 @@
+I get an error when serializing a material
+ - I'm assuming its because one shader block is renderer manager and not created at the time of serialization
+
 Resizing SceneView requires a resize() method on RenderTexture
 Resizing SceneView requires a resize() method on RenderTexture
+ - Add resize() method to RenderTexture and normal Texture
+Add a basic 3D model so SceneView actually displays something
+
+Think about how gizmos will be rendered
+ - Both quad icon-like ones
+ - And ones for bounding boxes, camera frustum, etc.
 
 
 Picking
 Picking
  - Create core thread class that accepts a screen coordinate and a camera and it determines object at its position
  - Create core thread class that accepts a screen coordinate and a camera and it determines object at its position