public override bool DragUpdated() { //Debug.Log("DragUpdated"); //InternalCSGModelManager.skipRefresh = true; try { DisableVisualObjects(); DragAndDrop.visualMode = DragAndDropVisualMode.Copy; var intersection = SceneQueryUtility.FindMeshIntersection(Event.current.mousePosition); var normal = intersection.plane.normal; hoverPosition = intersection.worldIntersection; hoverParent = SelectionUtility.FindParentToAssignTo(intersection); hoverBrushSurface = intersection.brush != null ? new SelectedBrushSurface(intersection.brush, intersection.surfaceIndex) : null; hoverRotation = SelectionUtility.FindDragOrientation(normal, sourceSurfaceAlignment, destinationSurfaceAlignment); haveNoParent = (hoverParent == null); hoverSiblingIndex = int.MaxValue; RealtimeCSG.Grid.SetForcedGrid(intersection.plane); var toggleSnapping = (Event.current.modifiers & EventModifiers.Control) == EventModifiers.Control; var doSnapping = RealtimeCSG.CSGSettings.SnapToGrid ^ toggleSnapping; if (doSnapping) { var localPoints = new Vector3[8]; var localPlane = intersection.plane; for (var i = 0; i < localPoints.Length; i++) { localPoints[i] = GeometryUtility.ProjectPointOnPlane(localPlane, (hoverRotation * projectedBounds[i]) + hoverPosition); } hoverPosition += RealtimeCSG.Grid.SnapDeltaToGrid(MathConstants.zeroVector3, localPoints); } hoverPosition = GeometryUtility.ProjectPointOnPlane(intersection.plane, hoverPosition) + (normal * 0.01f); EnableVisualObjects(); return(true); } finally { if (!SceneViewEventHandler.IsActive()) { SceneViewEventHandler.ResetUpdateRoutine(); } } }
public bool DragUpdated(SceneView sceneView) { try { DisableVisualObjects(); DragAndDrop.visualMode = DragAndDropVisualMode.Copy; var camera = sceneView.camera; var intersection = SceneQueryUtility.FindMeshIntersection(camera, Event.current.mousePosition); var normal = intersection.worldPlane.normal; hoverPosition = intersection.worldIntersection; hoverParent = SelectionUtility.FindParentToAssignTo(intersection); hoverBrushSurface = intersection.brush != null ? new SelectedBrushSurface(intersection.brush, intersection.surfaceIndex, intersection.worldPlane) : null; hoverRotation = SelectionUtility.FindDragOrientation(sceneView, normal, sourceSurfaceAlignment, destinationSurfaceAlignment); haveNoParent = (hoverParent == null); hoverSiblingIndex = int.MaxValue; RealtimeCSG.CSGGrid.SetForcedGrid(camera, intersection.worldPlane); // Since we're snapping points to grid and do not have a relative distance, relative snapping makes no sense var doGridSnapping = RealtimeCSG.CSGSettings.ActiveSnappingMode != SnapMode.None; if (doGridSnapping) { var localPoints = new Vector3[8]; var localPlane = intersection.worldPlane; for (var i = 0; i < localPoints.Length; i++) { localPoints[i] = GeometryUtility.ProjectPointOnPlane(localPlane, (hoverRotation * projectedBounds[i]) + hoverPosition); } hoverPosition += RealtimeCSG.CSGGrid.SnapDeltaToGrid(camera, MathConstants.zeroVector3, localPoints); } hoverPosition = GeometryUtility.ProjectPointOnPlane(intersection.worldPlane, hoverPosition); // + (normal * 0.01f); EnableVisualObjects(); return(true); } finally { if (!UpdateLoop.IsActive()) { UpdateLoop.ResetUpdateRoutine(); } } }