private static void KillActiveAnimations(DPOverlayBase dpBase)
        {
            if (currentAnimations.Count <= 0)
            {
                return;
            }

            //Kill any existing animations
            DPAnimationState existingState = currentAnimations.Find(x => x.dpBase == dpBase);

            if (existingState != null)
            {
                currentAnimations.Remove(existingState);

                existingState.dpBase.KillTransitions();

                //Set the overlay to whatever final pos it had
                existingState.dpBase.transform.localPosition = existingState.finalPos;
                existingState.dpBase.SyncTransform();

                existingState.dpBase.overlay.SetWidthInMeters(existingState.finalWidth);

                if (existingState.data.changeVisibility)
                {
                    existingState.dpBase.overlay.SetVisible(existingState.data.show);
                }
            }
        }
Exemple #2
0
        public void EndCurrentDrag()
        {
            if (!isDragging)
            {
                return;
            }

            //Debug.Log("ending drag");


            if (draggingDP == null)
            {
                Debug.LogError("Dragging DP null");
                return;
            }

            draggingDP.onOverlayDragged?.Invoke(false);

            //If it was using a snap point in the past, clear it:
            draggingDP.ClearAllSnapData();

            //If we ended the drag on a new snap point
            if (isUsingSnapPoint)
            {
                draggingDP.TransitionOverlayPosition(activeSnapPoint.transform.localPosition, activeSnapPoint.transform.localEulerAngles, transitionSnapPointSpeed,
                                                     Ease.InOutCubic, false);

                //Remove any previous thing
                if (activeSnapPoint.dpApp != null)
                {
                    TheBarManager.I.MinimizeApp(activeSnapPoint.dpApp.appKey);
                }
                else if (activeSnapPoint.dpBase != null)
                {
                    DPUIManager.Animate(activeSnapPoint.dpBase, DPAnimation.FadeOut);
                    activeSnapPoint.ClearAllSnapData();
                }

                if (draggingDP.hasDPAppParent && draggingDP.dpAppParent.dpMain == draggingDP)
                {
                    activeSnapPoint.SetSnappedApp(draggingDP.dpAppParent);
                }
                else
                {
                    activeSnapPoint.SetSnappedDP(draggingDP);
                }
            }


            TheBarManager.I.ToggleSnapPointsVisible(false);

            isDragging = false;

            dummyDragChild.parent = null;

            draggingDP      = null;
            activeSnapPoint = null;

            draggingDPIsAutoCurving = false;
        }
 public static void RemoveAnchoredDP(DPOverlayBase dpBase)
 {
     dpBase.isAnchoredToTheBar = false;
     //dpBase.SetOverlayTrackedDevice(DPOverlayTrackedDevice.None);
     I.theBarDP.RemoveChildOverlay(dpBase);
     //dpBase.transform.SetParent(SteamVRManager.I.noAnchorTrans);
     //dpBase.SyncTransform(true);
 }
        public void AddDependentDP(DPOverlayBase dpBase)
        {
            if (dependingDPs.Contains(dpBase))
            {
                return;
            }

            dependingDPs.Add(dpBase);
        }
        public void RemoveDependentDP(DPOverlayBase dpBase)
        {
            if (!dependingDPs.Contains(dpBase))
            {
                return;
            }

            dependingDPs.Remove(dpBase);
        }
        private void HandleDPLookAway(DPOverlayBase dpBase)
        {
            if (lookedAtDPs.Contains(dpBase))
            {
                dpBase.isBeingLookedAt = false;

                lookedAtDPs.Remove(dpBase);
            }
        }
 public static void AddAnchoredDP(DPOverlayBase dpBase)
 {
     dpBase.isAnchoredToTheBar = true;
     //dpBase.SetOverlayTrackedDevice(DPOverlayTrackedDevice.None);
     dpBase.followParentOpacity = false;
     I.theBarDP.AddChildOverlay(dpBase, true);
     //dpBase.transform.SetParent(I.theBarDP.transform, true);
     //dpBase.SyncTransform(true);
 }
Exemple #8
0
        // --- Cursor management ---

        private void ShowCursorsAtInteractionPoints(DPOverlayBase dpBase, List <Vector3> interactionPoints)
        {
            foreach (Vector3 point in interactionPoints)
            {
                //Un-offset to be centered again
                //Vector2 fixedPoint = new Vector2(point.x - dpBase.overlay.width / 2f, point.y - dpBase.overlayHeight / 2f);
                //Debug.Log(fixedPoint.x);

                if (_cursorsDPPool.Count <= _cursorPoolIndex)
                {
                    _cursorsDPPool.Add(Instantiate(cursorPF, SteamVRManager.I.noAnchorTrans).GetComponent <DPCursor>());
                    _cursorsDPPool[_cursorPoolIndex].cursorDP.PreInitialize();
                    _cursorsDPPool[_cursorPoolIndex].cursorDP.overlay.SetSortOrder(100);
                    _cursorsDPPool[_cursorPoolIndex].cursorDP.RequestRendering();
                    //Debug.Log("added cursor");
                }

                DPCameraOverlay cursorDP = _cursorsDPPool[_cursorPoolIndex].cursorDP;
                DPCursor        cursor   = _cursorsDPPool[_cursorPoolIndex];


                //Get the distance to the overlay
                float distance = Vector3.Distance(SteamVRManager.I.hmdTrans.position, point);

                distance /= 100f;
                cursorDP.overlay.SetWidthInMeters(0.001f + distance);

                //Set position, if new overlay, jump instantly

                if (cursor.targetDP != dpBase)
                {
                    cursorDP.transform.position = point;

                    cursor.targetDP = dpBase;
                }
                else
                {
                    cursorDP.transform.position = Vector3.Lerp(cursorDP.transform.position, point, Time.deltaTime * 30f);
                }


                cursorDP.transform.LookAt(2 * cursorDP.transform.position - SteamVRManager.I.hmdTrans.position);

                //cursor.transform.LookAt(SteamVRManager.I.hmdTrans);


                cursorDP.SetOverlayTransform(cursorDP.transform.position, cursorDP.transform.eulerAngles, false);

                if (!cursorDP.overlay.isVisible)
                {
                    cursorDP.overlay.SetVisible(true);
                }

                _cursorPoolIndex++;
            }
        }
        public void CloseDP(DPOverlayBase dpBase)
        {
            dpBase.ClearAllSnapData();

            if (DPToolbar.I.activeDP == dpBase)
            {
                DPToolbar.I.ResetToolbar();
            }

            Destroy(dpBase.gameObject);
        }
        public void Show(DPOverlayBase dpBase, Vector3 pos, string name, Texture2D icon)
        {
            //if (currentDP == dpBase) return;

            //Unsub from events:
            if (currentDP != null)
            {
                currentDP.onOverlayDragged -= dragAction;
            }


            currentDP = dpBase;

            //Sub to events
            dragAction = currentDP.onOverlayDragged += delegate(bool b) {
                if (!b)
                {
                    InitUI(currentDP);
                }
            };

            InitUI(dpBase);

            textCurrent.SetText(name);
            iconCurrent.texture = icon;


            /*transCalcHMDDir.position = SteamVRManager.I.hmdTrans.position;
             * transCalcHMDDir.LookAt(dpBase.transform);*/


            //windowSettingsDP.OrphanOverlay();

            windowSettingsTopDP.SetOverlayTransform(new Vector3(0f, 0.36f, 0f), new Vector3(0f, 0f, 15f), true, true, true);

            windowSettingsDP.KillTransitions();

            windowSettingsDP.transform.position = pos;
            windowSettingsDP.transform.LookAt(2 * windowSettingsDP.transform.position - SteamVRManager.I.hmdTrans.position);

            windowSettingsDP.SyncTransform();

            windowSettingsCurrentDP.SetOverlayTransform(new Vector3(0f, 0.36f, 0), Vector3.zero);

            //dpBase.AddChildOverlay(windowSettingsDP);


            DPUIManager.Animate(windowSettingsDP, DPAnimations.FadeIn);

            isActive = true;
        }
        private void HandleDPLookAt(DPOverlayBase dpBase)
        {
            dpBase.lookedAtCheck = true;

            if (lookedAtDPs.Contains(dpBase))
            {
                return;
            }

            dpBase.isBeingLookedAt = true;



            lookedAtDPs.Add(dpBase);
        }
Exemple #12
0
        /// <summary>
        /// If we're previewing what an app would look like here, cancel it, and restore the previous one.
        /// </summary>
        public void CancelPreviewAndRestore(bool fadeBackIn = true)
        {
            if (!isPreviewing)
            {
                return;
            }

            //Fade the actual overlay back in
            if (isOccupied && fadeBackIn)
            {
                dpBase.TransitionOverlayOpacity(dpBase.overlay.targetOpacity, transitionSnapPointSpeed, Ease.InOutCubic, false);
            }


            tempPreviewDP = null;
        }
Exemple #13
0
 /// <summary>
 /// Handles if a manually spawned DPApp should actually be visible or not
 /// </summary>
 /// <param name="state"></param>
 /// <param name="dpBase"></param>
 public static void SyncNewDPAppVisibility(DPAppSerialized state, DPOverlayBase dpBase, bool forceVisible = false)
 {
     //Show
     if (forceVisible || !state.isMinimized && (TheBarManager.isOpened || (!TheBarManager.isOpened && state.isPinned)))
     {
         TheBarManager.I.ToggleDPApp(dpBase.dpAppParent, true, true);
         dpBase.dpAppParent.OnTheBarToggled(true);
         dpBase.dpAppParent.OnOpen();
     }
     //Hide
     else
     {
         TheBarManager.I.ToggleDPApp(dpBase.dpAppParent, false, true);
         dpBase.dpAppParent.OnTheBarToggled(false);
         //dpBase.dpAppParent.OnMinimize();
     }
 }
Exemple #14
0
        public void ClearAllSnapData()
        {
            //if (!isOccupied) return;

            if (dpApp != null)
            {
                dpApp.snapPoint = null;
                dpApp           = null;
            }

            if (dpBase != null)
            {
                dpBase.snapPoint = null;
                dpBase           = null;
            }

            tempPreviewDP = null;
        }
Exemple #15
0
        private void ClearActiveSnapPoint(DPOverlayBase dpBase)
        {
            if (!isUsingSnapPoint)
            {
                return;
            }

            activeSnapPoint.CancelPreviewAndRestore();

            dpBase.KillTransitions();

            dpBase.TransitionOverlayWidth(dpBase.overlay.targetWidth, transitionSnapPointSpeed, false);
            dpBase.TransitionOverlayOpacity(dpBase.overlay.targetOpacity, transitionSnapPointSpeed, Ease.InOutCubic, false);
            //dpBase.TransitionOverlayCurvature(dpBase.overlay.targetCurvature, transitionSnapPointSpeed, false);

            activeSnapPoint.iconDP.TransitionOverlayWidth(activeSnapPoint.iconDP.overlay.targetWidth, transitionSnapPointSpeed, false);
            activeSnapPoint = null;
        }
Exemple #16
0
        private void FetchComponents()
        {
            if (dpMain == null)
            {
                dpMain = transform.Find("Main")?.Find("Overlay")?.GetComponent <DPOverlayBase>();
                if (dpMain == null)
                {
                    dpMain = transform.Find("Overlay").GetComponent <DPOverlayBase>();
                }
            }

            dpMain.dpAppParent = this;



            /*if (useTopBar && !dpTopBar) {
             *      dpTopBar = transform.Find("TopBar")?.Find("Overlay")?.GetComponent<DPOverlayBase>();
             * }
             * if (dpTopBar != null) {
             *      dpTopBar.dpAppParent = this;
             *      dpTopBar.showToolbar = false;
             *
             *      dpMain.AddChildOverlay(dpTopBar);
             *
             * }*/


            //Loop over the others and see if we need to add any more.
            Transform others = transform.Find("Others");

            if (others != null)
            {
                foreach (Transform t in others)
                {
                    DPOverlayBase test = t.Find("Overlay")?.GetComponent <DPOverlayBase>();
                    if (test != null)
                    {
                        otherDPs.Add(test);
                        test.dpAppParent = this;
                    }
                }
            }
        }
Exemple #17
0
        private void ResetPrevious()
        {
            if (activeDP == null)
            {
                return;
            }

            if (activeDP.overlay.trackedDevice == DPOverlayTrackedDevice.None && !activeDPHasBeenDragged)
            {
                Vector3 newPos = activeDP.transform.position + activeDP.transform.up * -0.1f;

                activeDP.TransitionOverlayPosition(newPos, activeDP.transform.eulerAngles, 0.5f);
            }

            //activeDP.onOverlayDragged -= OnActiveDragged;

            activeDP = null;

            activeDPHasBeenDragged = false;
        }
Exemple #18
0
        public void ShowKeyboard(DPOverlayBase dpBase, bool child = true)
        {
            //if (activeDP == dpBase) return;

            if (dpBase == keyboardDP)
            {
                return;
            }


            activeDP = dpBase;

            //keyboardDP.OrphanOverlay();

            Vector3 goodPos;
            Vector3 goodRot;

            /*if (child) {
             *      activeDP.AddChildOverlay(keyboardDP);
             *
             *      keyboardDP.overlay.SetWidthInMeters(0.8f);
             *
             *      goodPos = new Vector3(0f, activeDP.overlayHeight / -1.9f, -0.21f);
             *
             *      goodRot = new Vector3(30f, 0f, 0f);
             * }
             * else {*/
            goodPos  = activeDP.transform.position + activeDP.transform.forward * -0.11f;
            goodPos += activeDP.transform.up * (activeDP.overlayHeight / 2f);

            goodRot   = SteamVRManager.I.hmdTrans.eulerAngles;
            goodRot.z = 0f;
            //}


            keyboardDP.SetOverlayTransform(goodPos, goodRot);


            TheBarManager.I.ToggleDPApp(dpBase.dpAppParent, true, true);
        }
Exemple #19
0
        /// <summary>
        /// Used to preview what a DP would look like if snapped in this spot
        /// </summary>
        public void PreviewSnappedDP(DPOverlayBase newDPBase, bool fadeOutCurrent = true)
        {
            if (isOccupied && dpBase == newDPBase)
            {
                return;
            }

            tempPreviewDP = newDPBase;


            if (isOccupied && fadeOutCurrent)
            {
                dpBase.TransitionOverlayOpacity(0.1f, transitionSnapPointSpeed, Ease.InOutCubic, false);
            }

            /*Vector3 inFrontPos = transform.position + transform.forward * -0.015f;
             *
             * tempPreviewDP.KillTransitions();
             *
             * if (animate) {
             *      if (isOccupied) dpBase.TransitionOverlayOpacity(0.1f, transitionSnapPointSpeed, Ease.InOutCubic, false);
             *
             *      tempPreviewDP.TransitionOverlayWidth(overlayWidth, transitionSnapPointSpeed, false);
             *      tempPreviewDP.TransitionOverlayCurvature(overlayCurvature, transitionSnapPointSpeed, false);
             *      tempPreviewDP.TransitionOverlayOpacity(overlayOpacity, transitionSnapPointSpeed, Ease.InOutCubic, false);
             *
             *      tempPreviewDP.TransitionOverlayPosition(inFrontPos, transform.eulerAngles, transitionSnapPointSpeed, Ease.InOutCubic, false);
             * }
             * else {
             *
             *      if (isOccupied) dpBase.overlay.SetOpacity(0.1f, false);
             *
             *      tempPreviewDP.overlay.SetWidthInMeters(overlayWidth, false);
             *      tempPreviewDP.overlay.SetCurvature(overlayCurvature, false);
             *      tempPreviewDP.overlay.SetOpacity(overlayOpacity, false);
             *
             *      tempPreviewDP.SetOverlayTransform(inFrontPos, transform.eulerAngles, true, false);
             * }*/
        }
        /// <summary>
        /// Handles any new overlays that need to be processed, adds them to the master overlay list, and calls pre-initialize if specified by the overlay.
        /// </summary>
        private void HandleNeedToProcess()
        {
            if (!SteamVRManager.isConnected)
            {
                return;
            }

            if (DPOverlayBase.needToProcess.Count <= 0)
            {
                if (!isInitialized)
                {
                    isInitialized = true;
                    onInitialized?.Invoke();
                }

                return;
            }

            for (int i = 0; i < DPOverlayBase.needToProcess.Count; i++)
            {
                DPOverlayBase dpBase = DPOverlayBase.needToProcess[i];
                if (dpBase == null)
                {
                    continue;
                }

                //Add to the main list of all overlays
                overlays.Add(dpBase);

                //Pre-initialize if requested
                if (dpBase.autoPreInitialize)
                {
                    dpBase.PreInitialize();
                }

                //Remove it so we don't process it again
                DPOverlayBase.needToProcess.Remove(dpBase);
            }
        }
        private void Start()
        {
            I = this;

            DPSettings.LoadConfigJson();
            //StartCoroutine(DPSettings.AutoSave());

            DPSettings.OnLoad(HandleMinimizeAtStartup);


            //	TemplateWindowItem.selectedEvent += delegate(UwcWindow window) { NewDPWindowOverlay(window); };
            WindowSelectListElement.onPressed += delegate(WindowSelectListElement element) {
                DPDesktopOverlay desktopDP;

                if (!element.isDesktop)
                {
                    desktopDP = NewDPWindowOverlay(element.window);
                }

                else
                {
                    desktopDP = NewDPMonitorOverlay(element.monitor);
                }

                TheBarManager.I.LaunchAppToMainSnap(desktopDP.dpAppParent.appKey);
            };


            //SteamVRManager.I.onSteamVRConnected.AddListener(LoadDefaultLayout);

            //StartCoroutine(HandleOverlayRendering());

            StartCoroutine(DPOverlayBase.HandleRendering());



            TouchInjector.InitializeTouchInjection();
        }
Exemple #22
0
        private void Start()
        {
            TheBarManager.I.onBarOpened += b => {
                if (!b)
                {
                    Button_Close();
                }
            };

            DPOverlayBase.onClickedOn += dpBase => {
                activeDP = dpBase;
            };

            KButton.onButtonPress += HandleKeyPress;
            //KConstantButton.onButtonPress += HandleKeyPress;



            LoadLayout(_qwertyKeys);


            InitSym();
        }
Exemple #23
0
        public void StartDragDP(DPOverlayBase dpToDrag)
        {
            if (dpToDrag == null)
            {
                return;
            }

            if (!interactionEnabled)
            {
                return;
            }

            if (isDragging)
            {
                EndCurrentDrag();
            }

            dummyDragChild.SetParent(primaryLaser.pointer);
            dummyDragChild.position    = dpToDrag.transform.position;
            dummyDragChild.eulerAngles = dpToDrag.transform.eulerAngles;

            draggingDP = dpToDrag;

            dpToDrag.onOverlayDragged?.Invoke(true);

            if (draggingDP.canUseSnapPoints)
            {
                TheBarManager.I.ToggleSnapPointsVisible(true);
            }

            if (!DPSettings.config.autoCurveDragging)
            {
                draggingDP.overlay.SetCurvature(0f);
            }

            isDragging = true;
        }
Exemple #24
0
        public void Target(DPOverlayBase dpBase)
        {
            if (!dpBase.showToolbar)
            {
                return;
            }

            if (dpBase == activeDP)
            {
                return;
            }


            //Unsub from events
            if (activeDP != null)
            {
            }

            activeDP = dpBase;

            //Sub to events


            toolbarDP.alwaysInteract           = activeDP.alwaysInteract;
            toolbarDP.alwaysInteractBlockInput = activeDP.alwaysInteractBlockInput;

            pinIcon.SetActive(activeDP.showToolbarPin);
            settingsIcon.SetActive(activeDP.showToolbarSettings);


            toolbarDP.OrphanOverlay();
            activeDP.AddChildOverlay(toolbarDP);


            toolbarDP.RequestRendering(true);
        }
Exemple #25
0
        /// <summary>
        /// Sets a new DPBase that is anchored on this snap point
        /// </summary>
        /// <param name="newDPBase"></param>
        public void SetSnappedDP(DPOverlayBase newDPBase)
        {
            dpBase           = newDPBase;
            dpBase.snapPoint = this;


            /*
             * if (setValues && animate) {
             *      dpBase.KillTransitions();
             *
             *      dpBase.TransitionOverlayWidth(overlayWidth, transitionSnapPointSpeed, false);
             *      dpBase.TransitionOverlayCurvature(overlayCurvature, transitionSnapPointSpeed, false);
             *      dpBase.TransitionOverlayOpacity(overlayOpacity, transitionSnapPointSpeed, Ease.InOutCubic, false);
             *
             *      dpBase.TransitionOverlayPosition(transform.position, transform.eulerAngles, transitionSnapPointSpeed, Ease.InOutCubic, false);
             *
             * }
             * else if (setValues && !animate) {
             *      dpBase.KillTransitions();
             *
             *      dpBase.overlay.SetWidthInMeters(overlayWidth, false);
             *      dpBase.overlay.SetCurvature(overlayCurvature, false);
             *      dpBase.overlay.SetOpacity(overlayOpacity, false);
             *
             *      dpBase.SetOverlayTransform(transform.position, transform.eulerAngles, true, false);
             * }
             */


            //Clear the state of any overlay that used to be snapped here and is now being replaced
            tempPreviewDP = null;


            //Activate the icon:
            //iconDP.TransitionOverlayWidth(0.07f, transitionSnapPointSpeed, false);
        }
        private IEnumerator HandleRays()
        {
            while (true)
            {
                //Set all the currently "looked at" overlays checker to be false
                for (int i = 0; i < lookedAtDPs.Count; i++)
                {
                    lookedAtDPs[i].lookedAtCheck = false;
                }


                while (!SteamVRManager.isConnected)
                {
                    yield return(null);
                }



                /*
                 * DPRenderWindowOverlay tempPrimary = null;
                 *
                 * //For the center point. For finding the primary overlay
                 * for (int i = OverlayManager.I.overlays.Count; i --> 0; ) {
                 *      DPOverlayBase dpBase = OverlayManager.I.overlays[i];
                 *
                 *      if (!dpBase.overlay.shouldRender) continue;
                 *
                 *      //We're looking for a Desktop Window overlay, so we skip any overlays that aren't like that.
                 *      if ((dpBase is DPRenderWindowOverlay) == false) continue;
                 *
                 *
                 *      //If it's being scrolled, it has to be the primary so mouse input is sent properly.
                 *      if (dpBase.isBeingScrolled) {
                 *              //Debug.Log("found scroller");
                 *              tempPrimary = dpBase as DPRenderWindowOverlay;
                 *              break;
                 *      }
                 *
                 *      //If not being scrolled, test for collisions:
                 *
                 *      //If it collides, we're looking at the DP.
                 *      if (TestComputeIntersection(dpBase.overlay.handle, centerTransform)) {
                 *              HandleDPLookAt(dpBase);
                 *
                 *              tempPrimary = dpBase as DPRenderWindowOverlay;
                 *
                 *              //Break since we found one:
                 *              break;
                 *      }
                 *
                 * }*/

                /*//If we found a primary, and it's not equal to the last one, trigger the events:
                 * if (tempPrimary != null && tempPrimary != primaryWindowDP) {
                 *
                 *      //Disable primary on the previous overlay.
                 *      if (primaryWindowDP != null) primaryWindowDP.isPrimary = false;
                 *
                 *      primaryWindowDP = tempPrimary;
                 *      primaryWindowDP.isPrimary = true;
                 *
                 * }*/



                //yield return null;



                foreach (Transform point in raycastPoints)
                {
                    for (int i = OverlayManager.I.overlays.Count; i-- > 0;)
                    {
                        DPOverlayBase dpBase = OverlayManager.I.overlays[i];

                        //Skip this if we've already confirmed that it's being looked at:
                        if (dpBase.lookedAtCheck == true)
                        {
                            continue;
                        }

                        if (!dpBase.overlay.isVisible)
                        {
                            continue;
                        }

                        //If it collides, we're looking at the DP.
                        if (TestComputeIntersection(dpBase.overlay.handle, point))
                        {
                            HandleDPLookAt(dpBase);
                        }
                    }


                    yield return(null);
                }


                //Sets any overlays that have the check still false, but are supposedly being looked at back to the og state

                for (int i = lookedAtDPs.Count - 1; i >= 0; i--)
                {
                    if (lookedAtDPs[i].isBeingLookedAt && lookedAtDPs[i].lookedAtCheck == false)
                    {
                        HandleDPLookAway(lookedAtDPs[i]);
                    }
                }

                //lookedAtDPs.Clear();

                yield return(null);
            }
        }
        private bool CalculateIntersection(DPOverlayBase dpBase, out IntersectionResults results)
        {
            results = new IntersectionResults();

            return(SteamVR_Utils.ComputeIntersection(dpBase.overlay.handle, pointer.position, pointer.forward, SteamVRManager.trackingSpace, ref results));
        }
        public override bool HandleInteractionDetection(out List <Vector3> cursorPositions)
        {
            cursorPositions = new List <Vector3>();


            //DPOverlayBase closestOverlay;

            List <DPLaserCollisionData> collisions = new List <DPLaserCollisionData>();

            //bool foundOverlay = false;

            //Foreach of the overlays
            for (int i = 0; i < OverlayManager.I.overlays.Count; i++)
            {
                DPOverlayBase dpToTest = OverlayManager.I.overlays[i];

                //Don't process invisible or non-interactable overlays
                if (!dpToTest.overlay.shouldRender || !dpToTest.isInteractable)
                {
                    continue;
                }

                //Ignore look/distance hiding overlays:
                if (dpToTest.lookHidingActive || dpToTest.distanceHidingActive)
                {
                    continue;
                }

                if (!isActivated && !dpToTest.alwaysInteract && !dpToTest.allowMultipuleInteractors)
                {
                    continue;
                }

                //If the laser isn't activated, global interaction isn't activated, and the overlay doesn't want interaction when the bar is closed, just skip it.
                //If the overlay supports multi-interact, it's possible we might want to enable this laser, so we don't skip this quite yet.
                // ^^ if (!isActivated && !OverlayInteractionManager.interactionEnabled && !dpToTest.usePointInteraction && !dpToTest.allowMultipuleInteractors) continue;

                //If the overlay anchor is the same as the interactor, skip
                if (dpToTest.overlay.trackedDevice != DPOverlayTrackedDevice.None && dpToTest.overlay.trackedDevice == trackedDevice)
                {
                    continue;
                }

                //If the laser intersects with the overlay
                if (CalculateIntersection(dpToTest, out IntersectionResults hitResults))
                {
                    //Add it to the list of possible intersections
                    collisions.Add(new DPLaserCollisionData()
                    {
                        results = hitResults, dpBase = dpToTest
                    });
                }
            }


            //Actually handle interaction stuff once we find the closest collided overlay
            if (collisions.Count >= 1)
            {
                //Find the closest collision data out of all the collisions
                DPLaserCollisionData closest = collisions[0];

                for (int j = 1; j < collisions.Count; j++)
                {
                    if (collisions[j].results.distance < closest.results.distance)
                    {
                        closest = collisions[j];
                    }
                }

                //We've found the closest one, and can now interact.

                mostRecentIntersection = closest.results;

                //If interaction is not globally enabled, but the overlay has a flag for pointing interaction, we enable this laser.
                if (!isActivated && !OverlayInteractionManager.interactionEnabled)
                {
                    if (closest.dpBase.alwaysInteract)
                    {
                        //OverlayInteractionManager.I.TempEnableInteraction(inputSource);

                        //tempMultiInteractActive = true;

                        Activate(true);
                        if (closest.dpBase.alwaysInteractBlockInput)
                        {
                            OverlayInteractionManager.BlockInput(true);
                        }
                        //OverlayInteractionManager.I.
                    }

                    //Else, if interaction is not globally enabled, we return.
                    else
                    {
                        return(false);
                    }
                }


                //If we were using multi-touch on the old overlay, Disable the laser again:
                if (targetDP != closest.dpBase && targetDP != null && OverlayInteractionManager.interactionEnabled && OverlayInteractionManager.I.primaryLaser != this)
                {
                    multiInteractActive = false;
                    Disable();
                }


                //Activate the laser if it's not on and this overlay uses multi-interact:
                if (OverlayInteractionManager.interactionEnabled && !isActivated && closest.dpBase.allowMultipuleInteractors)
                {
                    multiInteractActive = true;
                    Activate(true);
                }


                else if (!isActivated)
                {
                    return(false);
                }


                //HIT A NEW OVERLAY
                //If we hit another overlay, disable interaction on the old overlay.
                if (targetDP != closest.dpBase && targetDP != null)
                {
                    targetDP.isBeingInteracted = false;
                    activatedTempEatClick      = true;

                    //If interaction isn't globally enabled, we need to turn off this laser when we leave this overlay.
                    if (!OverlayInteractionManager.interactionEnabled && !TheBarManager.isOpened)
                    {
                        Disable();
                        if (OverlayInteractionManager.inputBlocked)
                        {
                            OverlayInteractionManager.BlockInput(false);
                        }
                    }
                }


                targetDP = closest.dpBase;
                targetDP.isBeingInteracted = true;

                isInteracting = true;

                //Show the window bottom:
                if (OverlayInteractionManager.I.primaryLaser == this)
                {
                    DPToolbar.I.Target(targetDP);
                }


                targetDP.HandleColliderInteracted(this, new List <Vector2>()
                {
                    closest.results.UVs
                });


                cursorPositions.Add(closest.results.point);


                //return since we found an overlay for interaction
                return(true);
            }

            //Else, we found no overlays to interact with, so reset the state:


            //If we were temporarially interacting with a multi-touch overlay, disable this laser again.
            if (OverlayInteractionManager.interactionEnabled && OverlayInteractionManager.I.primaryLaser != this)
            {
                multiInteractActive = false;
                Disable();
            }


            if (targetDP != null)
            {
                targetDP.isBeingInteracted = false;

                //If interaction isn't globally enabled, we need to turn off this laser when we leave this overlay.
                if (!OverlayInteractionManager.interactionEnabled && !TheBarManager.isOpened)
                {
                    Disable();

                    if (OverlayInteractionManager.inputBlocked)
                    {
                        OverlayInteractionManager.BlockInput(false);
                    }
                }
            }

            targetDP      = null;
            isInteracting = false;
            return(false);
        }
        private IEnumerator AnchorOverlayDelayed(DPOverlayBase dpBase)
        {
            yield return(new WaitForSeconds(2.5f));

            dpBase.SetOverlayTrackedDevice(dpBase.overlay.trackedDevice, 0, false);
        }
Exemple #30
0
        public static void ApplyState(DPOverlayBase dpBase, DPAppSerialized state)
        {
            dpBase.overlay.SetWidthInMeters(state.width);

            dpBase.overlay.SetCurvature(state.curvature);

            dpBase.useSmoothAnchoring      = state.useSmoothAnchoring;
            dpBase.smoothAnchoringStrength = state.smoothAnchoringStrength;

            dpBase.useSnapAnchoring      = state.useSnapAnchoring;
            dpBase.snapAnchoringDistance = state.snapAnchoringDistance;

            dpBase.SetOverlayTransform(state.pos, state.rot);

            if (state.isAnchoredToTheBar)
            {
                TheBarManager.AddAnchoredDP(dpBase);
                //Apply the position in case the bar hasn't been opened
                //if (!TheBarManager.hasBeenOpened) dpBase.SetOverlayTransform(state., state.theBarWorldRot, true, true, false);
                dpBase.SetOverlayTransform(state.pos, state.rot);
            }
            else if (state.useSmoothAnchoring)
            {
                dpBase.SetOverlayTrackedDevice(state.smoothAnchoringTrackedDevice);
            }
            else if (state.useSnapAnchoring)
            {
                dpBase.SetOverlayTrackedDevice(state.snapAnchoringTrackedDevice);
            }
            else
            {
                dpBase.SetOverlayTrackedDevice(state.trackedDevice);
            }

            dpBase.isPinned = state.isPinned;

            dpBase.fpsToCaptureAt            = state.captureFPS;
            dpBase.forceHighCaptureFramerate = state.forceCaptureRate;

            dpBase.SetOverlayOpacity(state.opacity);


            dpBase.useLookHiding      = state.useLookHiding;
            dpBase.lookHidingStrength = state.lookHidingStrength;
            dpBase.lookHidingOpacity  = state.lookHidingHideOpacity;

            dpBase.useDistanceHiding      = state.useDistanceHiding;
            dpBase.distanceHidingDistance = state.distanceHidingDistance;
            dpBase.distanceHidingOpacity  = state.distanceHidingOpacity;

            dpBase.useWindowCropping = state.useWindowCropping;

            dpBase.cropAmount = state.cropAmount;

            dpBase.overlay.SetSBS(state.useSBS, state.sbsCrossedMode);

            dpBase.useTouchInput = state.useTouchInput;

            dpBase.alwaysInteract           = state.alwaysInteract;
            dpBase.alwaysInteractBlockInput = state.alwaysInteractBlockInput;

            dpBase.isInteractable = state.disableInteraction;

            dpBase.isDraggable = state.disableDragging;


            dpBase.dpAppParent.isMinimized = state.isMinimized;
        }