public Gizmo() { _handles = new GizmoHandleCollection(this); _hoverInfo.Reset(); _dragInfo.Reset(); }
public void Update_SystemCall() { foreach (var sceneGizmoCam in _sceneGizmoCameras) { sceneGizmoCam.Update_SystemCall(); } _pipelineStage = GizmosEnginePipelineStage.Update; IInputDevice inputDevice = RTInputDevice.Get.Device; bool deviceHasPointer = inputDevice.HasPointer(); Vector3 inputDevicePos = inputDevice.GetPositionYAxisUp(); bool isUIHovered = RTScene.Get.IsAnyUIElementHovered(); bool canUpdateHoverInfo = _draggedGizmo == null && !isUIHovered; if (canUpdateHoverInfo) { YesNoAnswer answer = new YesNoAnswer(); if (CanDoHoverUpdate != null) { CanDoHoverUpdate(answer); } if (answer.HasNo) { canUpdateHoverInfo = false; } } if (canUpdateHoverInfo) { _hoveredGizmo = null; _gizmoHoverInfo.Reset(); } bool isDeviceInsideFocusCamera = deviceHasPointer && RTFocusCamera.Get.IsViewportHoveredByDevice(); //RTFocusCamera.Get.TargetCamera.pixelRect.Contains(inputDevicePos); bool focusCameraCanRenderGizmos = IsRenderCamera(RTFocusCamera.Get.TargetCamera); var hoverDataCollection = new List <GizmoHandleHoverData>(10); foreach (var gizmo in _gizmos) { gizmo.OnUpdateBegin_SystemCall(); if (canUpdateHoverInfo && gizmo.IsEnabled && isDeviceInsideFocusCamera && deviceHasPointer && focusCameraCanRenderGizmos) { var handleHoverData = GetGizmoHandleHoverData(gizmo); if (handleHoverData != null) { hoverDataCollection.Add(handleHoverData); } } } GizmoHandleHoverData hoverData = null; if (canUpdateHoverInfo && hoverDataCollection.Count != 0) { SortHandleHoverDataCollection(hoverDataCollection, inputDevicePos); hoverData = hoverDataCollection[0]; _hoveredGizmo = hoverData.Gizmo; _gizmoHoverInfo.HandleId = hoverData.HandleId; _gizmoHoverInfo.HandleDimension = hoverData.HandleDimension; _gizmoHoverInfo.HoverPoint = hoverData.HoverPoint; _gizmoHoverInfo.IsHovered = true; } foreach (var gizmo in _gizmos) { _gizmoHoverInfo.IsHovered = (gizmo == _hoveredGizmo); gizmo.UpdateHandleHoverInfo_SystemCall(_gizmoHoverInfo); gizmo.HandleInputDeviceEvents_SystemCall(); gizmo.OnUpdateEnd_SystemCall(); } _pipelineStage = GizmosEnginePipelineStage.PostUpdate; }