Browse Source

Deal with handle input more correctly
Use proper material when drawing handles

Marko Pintera 11 years ago
parent
commit
85c697cb7d

+ 2 - 1
BansheeEditor/Include/BsHandleManager.h

@@ -11,7 +11,8 @@ namespace BansheeEngine
 		HandleManager();
 		HandleManager();
 		virtual ~HandleManager();
 		virtual ~HandleManager();
 
 
-		void update(const Vector2I& inputPos, const Ray& inputRay, bool pressed);
+		void handleInput(const Vector2I& inputPos, const Ray& inputRay, bool pressed);
+		void update();
 
 
 		HandleSliderManager& getSliderManager() const { return *mSliderManager; }
 		HandleSliderManager& getSliderManager() const { return *mSliderManager; }
 		HandleDrawManager& getDrawManager() const { return *mDrawManager; }
 		HandleDrawManager& getDrawManager() const { return *mDrawManager; }

+ 1 - 0
BansheeEditor/Include/BsSceneEditorWidget.h

@@ -54,6 +54,7 @@ namespace BansheeEngine
 		HCamera mCamera;
 		HCamera mCamera;
 		GameObjectHandle<SceneCameraController> mCameraController;
 		GameObjectHandle<SceneCameraController> mCameraController;
 		SceneGrid* mSceneGrid;
 		SceneGrid* mSceneGrid;
+
 		bool mLeftButtonPressed;
 		bool mLeftButtonPressed;
 
 
 		HEvent mRenderCallback;
 		HEvent mRenderCallback;

+ 1 - 1
BansheeEditor/Source/BsHandleDrawManager.cpp

@@ -213,7 +213,7 @@ namespace BansheeEngine
 		{
 		{
 			if (currentType != proxyData.type)
 			if (currentType != proxyData.type)
 			{
 			{
-				if (currentType == MeshType::Solid)
+				if (proxyData.type == MeshType::Solid)
 					Renderer::setPass(*mSolidMaterial.proxy, 0);
 					Renderer::setPass(*mSolidMaterial.proxy, 0);
 				else
 				else
 					Renderer::setPass(*mWireMaterial.proxy, 0);
 					Renderer::setPass(*mWireMaterial.proxy, 0);

+ 13 - 7
BansheeEditor/Source/BsHandleManager.cpp

@@ -23,22 +23,28 @@ namespace BansheeEngine
 		return mSliderManager->isSliderActive();
 		return mSliderManager->isSliderActive();
 	}
 	}
 
 
-	void HandleManager::update(const Vector2I& inputPos, const Ray& inputRay, bool pressed)
+	void HandleManager::update()
 	{
 	{
 		SceneEditorWidget* sceneView = SceneViewLocator::instance();
 		SceneEditorWidget* sceneView = SceneViewLocator::instance();
 		if (sceneView != nullptr)
 		if (sceneView != nullptr)
 		{
 		{
 			HCamera sceneCamera = sceneView->getSceneCamera();
 			HCamera sceneCamera = sceneView->getSceneCamera();
 
 
-			refreshHandles();
+			queueDrawCommands();
+			mDrawManager->draw(sceneCamera);
+		}
+	}
 
 
-			mSliderManager->update(sceneCamera, inputPos, inputRay, pressed);
+	void HandleManager::handleInput(const Vector2I& inputPos, const Ray& inputRay, bool pressed)
+	{
+		SceneEditorWidget* sceneView = SceneViewLocator::instance();
+		if (sceneView != nullptr)
+		{
+			HCamera sceneCamera = sceneView->getSceneCamera();
 
 
+			refreshHandles();
+			mSliderManager->update(sceneCamera, inputPos, inputRay, pressed);
 			triggerHandles();
 			triggerHandles();
-
-			queueDrawCommands();
-
-			mDrawManager->draw(sceneCamera);
 		}
 		}
 	}
 	}
 }
 }

+ 3 - 3
BansheeEditor/Source/BsHandleSliderLine.cpp

@@ -8,8 +8,8 @@
 
 
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
-	const float HandleSliderLine::CAPSULE_RADIUS = 0.2f;
-	const float HandleSliderLine::SPHERE_RADIUS = 0.5f;
+	const float HandleSliderLine::CAPSULE_RADIUS = 0.1f;
+	const float HandleSliderLine::SPHERE_RADIUS = 0.25f;
 
 
 	HandleSliderLine::HandleSliderLine(const Vector3& direction, float length, float snapValue, bool fixedScale)
 	HandleSliderLine::HandleSliderLine(const Vector3& direction, float length, float snapValue, bool fixedScale)
 		:HandleSlider(fixedScale, snapValue), mLength(length), mDelta(0.0f)
 		:HandleSlider(fixedScale, snapValue), mLength(length), mDelta(0.0f)
@@ -19,7 +19,7 @@ namespace BansheeEngine
 		Vector3 start = Vector3::ZERO;
 		Vector3 start = Vector3::ZERO;
 		Vector3 end = start + mDirection * length;
 		Vector3 end = start + mDirection * length;
 
 
-		Vector3 sphereCenter = start + mDirection * std::max(0.0f, length - SPHERE_RADIUS * 2);
+		Vector3 sphereCenter = start + mDirection * std::max(0.0f, length - SPHERE_RADIUS);
 
 
 		mCapsuleCollider = Capsule(LineSegment3(start, end), CAPSULE_RADIUS);
 		mCapsuleCollider = Capsule(LineSegment3(start, end), CAPSULE_RADIUS);
 		mSphereCollider = Sphere(sphereCenter, SPHERE_RADIUS);
 		mSphereCollider = Sphere(sphereCenter, SPHERE_RADIUS);

+ 7 - 4
BansheeEditor/Source/BsSceneEditorWidget.cpp

@@ -39,7 +39,8 @@ namespace BansheeEngine
 	SceneEditorWidget* SceneEditorWidget::Instance = nullptr;
 	SceneEditorWidget* SceneEditorWidget::Instance = nullptr;
 
 
 	SceneEditorWidget::SceneEditorWidget(const ConstructPrivately& dummy, EditorWidgetContainer& parentContainer)
 	SceneEditorWidget::SceneEditorWidget(const ConstructPrivately& dummy, EditorWidgetContainer& parentContainer)
-		:EditorWidget<SceneEditorWidget>(HString(L"SceneEditorWidget"), parentContainer), mGUIRenderTexture(nullptr), mLeftButtonPressed(false)
+		:EditorWidget<SceneEditorWidget>(HString(L"SceneEditorWidget"), parentContainer), mGUIRenderTexture(nullptr), 
+		mLeftButtonPressed(false)
 	{
 	{
 		SceneViewLocator::_provide(this);
 		SceneViewLocator::_provide(this);
 
 
@@ -73,6 +74,8 @@ namespace BansheeEngine
 			mCameraController->update();
 			mCameraController->update();
 		}
 		}
 
 
+		HandleManager::instance().update();
+
 		//// DEBUG ONLY
 		//// DEBUG ONLY
 		//if (gTime().getCurrentFrameNumber() == 100)
 		//if (gTime().getCurrentFrameNumber() == 100)
 		//{
 		//{
@@ -116,7 +119,7 @@ namespace BansheeEngine
 		{
 		{
 			Ray inputRay = mCamera->screenPointToRay(scenePos);
 			Ray inputRay = mCamera->screenPointToRay(scenePos);
 
 
-			HandleManager::instance().update(scenePos, inputRay, mLeftButtonPressed);
+			HandleManager::instance().handleInput(scenePos, inputRay, mLeftButtonPressed);
 		}
 		}
 	}
 	}
 
 
@@ -132,7 +135,7 @@ namespace BansheeEngine
 		mLeftButtonPressed = false;
 		mLeftButtonPressed = false;
 		Ray inputRay = mCamera->screenPointToRay(scenePos);
 		Ray inputRay = mCamera->screenPointToRay(scenePos);
 
 
-		HandleManager::instance().update(scenePos, inputRay, mLeftButtonPressed);
+		HandleManager::instance().handleInput(scenePos, inputRay, mLeftButtonPressed);
 	}
 	}
 
 
 	void SceneEditorWidget::onPointerPressed(const PointerEvent& event)
 	void SceneEditorWidget::onPointerPressed(const PointerEvent& event)
@@ -147,7 +150,7 @@ namespace BansheeEngine
 		mLeftButtonPressed = true;
 		mLeftButtonPressed = true;
 		Ray inputRay = mCamera->screenPointToRay(scenePos);
 		Ray inputRay = mCamera->screenPointToRay(scenePos);
 
 
-		HandleManager::instance().update(scenePos, inputRay, mLeftButtonPressed);
+		HandleManager::instance().handleInput(scenePos, inputRay, mLeftButtonPressed);
 
 
 		// If we didn't hit a handle, perform normal selection
 		// If we didn't hit a handle, perform normal selection
 		if (!HandleManager::instance().isHandleActive())
 		if (!HandleManager::instance().isHandleActive())

+ 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();
 
 

+ 2 - 1
SBansheeEditor/Source/BsScriptHandleManager.cpp

@@ -122,7 +122,8 @@ namespace BansheeEngine
 
 
 	void ScriptHandleManager::queueDrawCommands()
 	void ScriptHandleManager::queueDrawCommands()
 	{
 	{
-		callDraw(mDefaultHandleManager);
+		if (mDefaultHandleManager != nullptr)
+			callDraw(mDefaultHandleManager);
 
 
 		for (auto& handle : mActiveHandleData.handles)
 		for (auto& handle : mActiveHandleData.handles)
 		{
 		{

+ 1 - 4
SceneView.txt

@@ -3,13 +3,10 @@
   - Make a C# wrapper for Camera and Renderable
   - Make a C# wrapper for Camera and Renderable
 
 
 REFACTOR material getParams* and related classes. Those params should update all gpu program params that share that variable, not just the first found
 REFACTOR material getParams* and related classes. Those params should update all gpu program params that share that variable, not just the first found
-Handles need to render in front of everything
- - But I still need to respect depth between overlapping handles
- - Just sort by distance?
 Clicking on empty space needs to deselect everything
 Clicking on empty space needs to deselect everything
 Dragging a slider doesn't move it properly (also need to fix colliders so not all handles overlap)
 Dragging a slider doesn't move it properly (also need to fix colliders so not all handles overlap)
 Need a way to drag and drop items from Scene tree view to Scene view
 Need a way to drag and drop items from Scene tree view to Scene view
-HandleManager::update is meant to be called every frame but it is called only when mouse input is received (and isn't even called on mouse movement it seems)
+Handle normals seem to break as the camera moves at a certain angle
 
 
 Test handles
 Test handles
  - Test basic move handle
  - Test basic move handle