Bläddra i källkod

Code conformity

MarcoROG 9 år sedan
förälder
incheckning
b4c8495274

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

@@ -12,7 +12,7 @@ namespace BansheeEditor
      */
 
     /// <summary>
-    /// Contains information regarding object snapping.
+    /// Contains Object containing the world position and normal of the surface under the snapping point.
     /// </summary>
     [StructLayout(LayoutKind.Sequential)]
     struct SnapData
@@ -23,7 +23,7 @@ namespace BansheeEditor
         public Vector3 normal;
 
         /// <summary>
-        /// The 3D position on the surface of the object
+        /// The 3D position on the surface of the object.
         /// </summary>
         public Vector3 position;
     }
@@ -55,7 +55,7 @@ namespace BansheeEditor
         /// </summary>
         /// <param name="pointerPos">Position of the pointer relative to the scene camera viewport.</param>
         /// <param name="controlHeld">Should this selection add to the existing selection, or replace it.</param>
-        /// <param name="ignoreSceneObjects">An array of renderables that should not be rendered during scene picking.</param>
+        /// <param name="ignoreSceneObjects">Optional set of objects to ignore during scene picking.</param>
         internal void PickObject(Vector2I pointerPos, bool controlHeld, SceneObject[] ignoreSceneObjects = null)
         {
             Internal_PickObject(mCachedPtr, ref pointerPos, controlHeld, ignoreSceneObjects);
@@ -67,18 +67,18 @@ namespace BansheeEditor
         /// <param name="pointerPos">Position of the pointer relative to the scene camera viewport.</param>
         /// <param name="area">The screen area in which objects will be selected.</param>
         /// <param name="controlHeld">Should this selection add to the existing selection, or replace it.</param>
-        /// <param name="ignoreSceneObjects">An array of renderables that should not be rendered during scene picking.</param>
+        /// <param name="ignoreSceneObjects">Optional set of objects to ignore during scene picking.</param>
         internal void PickObjects(Vector2I pointerPos, Vector2I area, bool controlHeld, SceneObject[] ignoreSceneObjects = null)
         {
             Internal_PickObjects(mCachedPtr, ref pointerPos, ref area, controlHeld, ignoreSceneObjects);
         }
 
         /// <summary>
-        /// Returns the 3D position of an object under the cursor, along with the surface normal in that point.
+        /// Object containing the world position and normal of the surface under the provided screen point.
         /// </summary>
         /// <param name="pointerPos">Position of the pointer relative to the scene camera viewport.</param>
         /// <param name="data">A struct containing the position on the object surface and the normal in that point.</param>
-        /// <param name="ignoreSceneObjects">An array of renderables that should not be rendered during scene picking.</param>
+        /// <param name="ignoreSceneObjects">Optional set of objects to ignore during scene picking.</param>
         /// <returns>The object the pointer is snapping to.</returns>
         internal SceneObject Snap(Vector2I pointerPos, out SnapData data, SceneObject[] ignoreSceneObjects = null)
         {

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

@@ -3,7 +3,6 @@
 using System;
 using System.Collections.Generic;
 using System.IO;
-using System.Runtime.Remoting.Messaging;
 using BansheeEngine;
 
 namespace BansheeEditor
@@ -598,7 +597,14 @@ namespace BansheeEditor
                             else
                             {
                                 Ray worldRay = camera.ViewportToWorldRay(scenePos);
-                                draggedSO.Position = worldRay * DefaultPlacementDepth - draggedSOOffset;
+                                Vector3 pos = worldRay*DefaultPlacementDepth - draggedSOOffset;
+                                float interval = EditorSettings.MoveHandleSnapAmount;
+                                if (EditorSettings.MoveHandleSnapActive)
+                                    draggedSO.Position = new Vector3(pos.x - (pos.x % interval), pos.y - (pos.y % interval),
+                                        pos.z - (pos.z % interval));
+                                else
+                                    draggedSO.Position = new Vector3(pos.x, pos.y - (pos.y % interval), pos.z);
+
                                 draggedSO.Rotation = Quaternion.LookRotation(Vector3.YAxis);
                             }
                         }
@@ -632,10 +638,6 @@ namespace BansheeEditor
 
                 if (inBounds && HasContentFocus)
                 {
-                    bool newHandle = false;
-                    SceneHandles.BeginInput();
-                    newHandle = sceneHandles.IsActive();
-                    SceneHandles.EndInput();  
                     if (Input.IsPointerButtonDown(PointerButton.Left))
                     {
                         Rect2I sceneAxesGUIBounds = new Rect2I(Width - HandleAxesGUISize - HandleAxesGUIPaddingX, 
@@ -646,7 +648,7 @@ namespace BansheeEditor
                         else
                             sceneHandles.TrySelect(scenePos);
                     }
-                    else if (Input.IsPointerButtonHeld(PointerButton.Left) && !newHandle && !dragActive &&
+                    else if (Input.IsPointerButtonHeld(PointerButton.Left) && !handleActive && !dragActive &&
                              draggedSO == null && scenePos != mouseDownPosition)
                     {
                         if (isDraggingSelection)

+ 4 - 2
Source/SBansheeEditor/Source/BsScriptSceneSelection.cpp

@@ -64,7 +64,7 @@ namespace BansheeEngine
 			}
 		}
 
-		HSceneObject pickedObject = ScenePicking::instance().pickClosestObject(thisPtr->mCamera, *inputPos, Vector2I(1, 1), ignoredSceneObjects); //TODO REMOVE DATA
+		HSceneObject pickedObject = ScenePicking::instance().pickClosestObject(thisPtr->mCamera, *inputPos, Vector2I(1, 1), ignoredSceneObjects);
 		if (pickedObject)
 		{
 			if (additive) // Append to existing selection
@@ -114,7 +114,8 @@ namespace BansheeEngine
 				ignoredSceneObjects.push_back(so);
 			}
 		}
-		Vector<HSceneObject> pickedObjects = ScenePicking::instance().pickObjects(thisPtr->mCamera, *inputPos, *area, ignoredSceneObjects); //TODO: REMOVE DATA
+
+		Vector<HSceneObject> pickedObjects = ScenePicking::instance().pickObjects(thisPtr->mCamera, *inputPos, *area, ignoredSceneObjects);
 
 		if (pickedObjects.size() != 0)
 		{
@@ -167,6 +168,7 @@ namespace BansheeEngine
 				ignoredSceneObjects.push_back(so);
 			}
 		}
+
 		HSceneObject instance = ScenePicking::instance().pickClosestObject(thisPtr->mCamera, *inputPos, Vector2I(1, 1), ignoredSceneObjects, data);
 		MonoObject* managedInstance = ScriptGameObjectManager::instance().getOrCreateScriptSceneObject(instance)->getManagedInstance();
 		if (instance == nullptr)