Ver Fonte

Fixed scene axes handle offsets so picking is now handled correctly

BearishSun há 10 anos atrás
pai
commit
54c63e0fd5

+ 0 - 2
BansheeEditor/Source/BsHandleSliderLine.cpp

@@ -6,8 +6,6 @@
 #include "BsSphere.h"
 #include "BsRay.h"
 
-#include "BsDebug.h"
-
 namespace BansheeEngine
 {
 	const float HandleSliderLine::CAPSULE_RADIUS = 0.05f;

+ 4 - 1
MBansheeEditor/Scene/SceneAxesGUI.cs

@@ -57,7 +57,9 @@ namespace BansheeEditor
             renderTextureGUI = new GUIRenderTexture(renderTexture, true);
 
             GUILayoutY layout = panel.AddLayoutY();
-            layout.AddElement(renderTextureGUI);
+            GUILayoutX textureLayout = layout.AddLayoutX();
+            textureLayout.AddElement(renderTextureGUI);
+            textureLayout.AddFlexibleSpace();
 
             Rect2I bounds = new Rect2I(0, 0, width, height);
             sceneHandles = new SceneHandles(window, camera);
@@ -65,6 +67,7 @@ namespace BansheeEditor
 
             labelGUI = new GUILabel(projType.ToString(), EditorStyles.LabelCentered);
             layout.AddElement(labelGUI);
+            layout.AddFlexibleSpace();
 
             this.panel = panel;
             this.bounds = bounds;

+ 10 - 6
MBansheeEditor/Scene/SceneAxesHandle.cs

@@ -56,17 +56,21 @@ namespace BansheeEditor
             position = new Vector3(0, 0, -5.0f);
             rotation = cam.SceneObject.Rotation.Inverse;
 
-            xAxis.Position = position + new Vector3(BOX_EXTENT, 0.0f, 0.0f);
-            yAxis.Position = position + new Vector3(0.0f, BOX_EXTENT, 0.0f);
-            zAxis.Position = position + new Vector3(0.0f, 0.0f, BOX_EXTENT);
+            Vector3 xOffset = rotation.Rotate(new Vector3(BOX_EXTENT, 0.0f, 0.0f));
+            Vector3 yOffset = rotation.Rotate(new Vector3(0.0f, BOX_EXTENT, 0.0f));
+            Vector3 zOffset = rotation.Rotate(new Vector3(0.0f, 0.0f, BOX_EXTENT));
+
+            xAxis.Position = position + xOffset;
+            yAxis.Position = position + yOffset;
+            zAxis.Position = position + zOffset;
 
             xAxis.Rotation = rotation;
             yAxis.Rotation = rotation;
             zAxis.Rotation = rotation;
 
-            xNegAxis.Position = position - new Vector3(BOX_EXTENT, 0.0f, 0.0f);
-            yNegAxis.Position = position - new Vector3(0.0f, BOX_EXTENT, 0.0f);
-            zNegAxis.Position = position - new Vector3(0.0f, 0.0f, BOX_EXTENT);
+            xNegAxis.Position = position - xOffset;
+            yNegAxis.Position = position - yOffset;
+            zNegAxis.Position = position - zOffset;
 
             xNegAxis.Rotation = rotation;
             yNegAxis.Rotation = rotation;

+ 2 - 6
MBansheeEditor/Scene/SceneCamera.cs

@@ -208,12 +208,8 @@ namespace BansheeEditor
                     // Handle movement using movement keys
                     Vector3 direction = Vector3.Zero;
 
-                    if (!isOrtographic)
-                    {
-                        if (goingForward) direction += SceneObject.Forward;
-                        if (goingBack) direction -= SceneObject.Forward;
-                    }
-
+                    if (goingForward) direction += SceneObject.Forward;
+                    if (goingBack) direction -= SceneObject.Forward;
                     if (goingRight) direction += SceneObject.Right;
                     if (goingLeft) direction -= SceneObject.Right;
                     if (goingUp) direction += SceneObject.Up;

+ 5 - 4
MBansheeEditor/Scene/SceneWindow.cs

@@ -24,7 +24,8 @@ namespace BansheeEditor
         private static readonly Color ClearColor = new Color(83.0f/255.0f, 83.0f/255.0f, 83.0f/255.0f);
         private const string ProfilerOverlayActiveKey = "_Internal_ProfilerOverlayActive";
         private const int HandleAxesGUISize = 50;
-        private const int HandleAxesGUIPadding = 5;
+        private const int HandleAxesGUIPaddingX = 10;
+        private const int HandleAxesGUIPaddingY = 5;
 
         private Camera camera;
         private SceneCamera cameraController;
@@ -536,8 +537,8 @@ namespace BansheeEditor
                 {
                     if (Input.IsPointerButtonDown(PointerButton.Left))
                     {
-                        Rect2I sceneAxesGUIBounds = new Rect2I(Width - HandleAxesGUISize - HandleAxesGUIPadding, 
-                            HandleAxesGUIPadding, HandleAxesGUISize, HandleAxesGUISize);
+                        Rect2I sceneAxesGUIBounds = new Rect2I(Width - HandleAxesGUISize - HandleAxesGUIPaddingX, 
+                            HandleAxesGUIPaddingY, HandleAxesGUISize, HandleAxesGUISize);
 
                         if (sceneAxesGUIBounds.Contains(scenePos))
                             sceneAxesGUI.TrySelect(scenePos);
@@ -798,7 +799,7 @@ namespace BansheeEditor
             Rect2I rtBounds = new Rect2I(0, 0, width, height);
             renderTextureGUI.Bounds = rtBounds;
 
-            sceneAxesGUI.SetPosition(width - HandleAxesGUISize - HandleAxesGUIPadding, HandleAxesGUIPadding);
+            sceneAxesGUI.SetPosition(width - HandleAxesGUISize - HandleAxesGUIPaddingX, HandleAxesGUIPaddingY);
 
             // TODO - Consider only doing the resize once user stops resizing the widget in order to reduce constant
             // render target destroy/create cycle for every single pixel.