コード例 #1
0
 private void OnGUI()
 {
     _pipelineStage = GizmosEnginePipelineStage.GUI;
     foreach (var gizmo in _gizmos)
     {
         gizmo.OnGUI_SystemCall();
     }
     _pipelineStage = GizmosEnginePipelineStage.PostGUI;
 }
コード例 #2
0
        public void Render_SystemCall()
        {
            _pipelineStage = GizmosEnginePipelineStage.Render;
            Camera renderCamera = Camera.current;

            if (!IsSceneGizmoCamera(renderCamera) && !IsRenderCamera(renderCamera))
            {
                _pipelineStage = GizmosEnginePipelineStage.PostRender;
                return;
            }

            if (Settings.EnableGizmoSorting)
            {
                Vector3 camPos       = RenderStageCamera.transform.position;
                var     sortedGizmos = new List <Gizmo>(_gizmos);
                sortedGizmos.Sort(delegate(Gizmo g0, Gizmo g1)
                {
                    float d0 = (g0.Transform.Position3D - camPos).sqrMagnitude;
                    float d1 = (g1.Transform.Position3D - camPos).sqrMagnitude;

                    return(d1.CompareTo(d0));
                });

                var worldFrustumPlanes = CameraViewVolume.GetCameraWorldPlanes(renderCamera);
                foreach (var gizmo in sortedGizmos)
                {
                    gizmo.Render_SystemCall(renderCamera, worldFrustumPlanes);
                }
            }
            else
            {
                var worldFrustumPlanes = CameraViewVolume.GetCameraWorldPlanes(renderCamera);
                foreach (var gizmo in _gizmos)
                {
                    gizmo.Render_SystemCall(renderCamera, worldFrustumPlanes);
                }
            }

            _pipelineStage = GizmosEnginePipelineStage.PostRender;
        }
コード例 #3
0
        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;
        }
コード例 #4
0
        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)
            {
                // Note: We always reset the hovered info even if the UI is hovered. This is because
                //       we want to catch special cases where the mouse cursor moves from the gizmo
                //       over to the UI. In that case, if we don't reset the hovered info, the gizmo
                //       will be affected by mouse movements when interacting with the UI.
                _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;
        }