Esempio n. 1
0
        public void PointerMove(MouseInputEvent mouseEvent)
        {
            if (!m_panButtonDown)
            {
                return;
            }

            Vector2 newPos = new Vector2(mouseEvent.x, mouseEvent.y);

            if (m_current == newPos)
            {
                return;
            }


            float anchorDeltaSqMag          = (m_anchor - newPos).sqrMagnitude;
            bool  exceededStartPanThreshold = (anchorDeltaSqMag > 4.0f); //m_panStartThresholdPixels);

            if (!m_panning && exceededStartPanThreshold)
            {
                m_panning = true;
                var pan = PopulatePanData();
                m_handler.Event_TouchPan_Start(pan);
            }

            if (m_panning)
            {
                m_current = newPos;
                var pan = PopulatePanData();

                m_handler.Event_TouchPan(pan);
            }
        }
Esempio n. 2
0
        public void PointerMove(TouchInputEvent touchEvent)
        {
            int   numTouches       = touchEvent.pointerEvents.Count;
            float dx               = 0;
            float dy               = 0;
            float totalX           = 0;
            float totalY           = 0;
            int   inputsToConsider = Math.Min(MaxPanInputs, numTouches);
            bool  somethingPanned  = false;

            for (int i = 0; i < inputsToConsider; ++i)
            {
                int pid = touchEvent.pointerEvents[i].pointerIdentity;

                //Wrld_TTY("PanGesture::PointerMove %d -- %f\n", pid, inputs[pid].LengthSq());
                if (inputs[pid].sqrMagnitude > InputActivityTolerance)
                {
                    //Wrld_TTY("POINTER %d CONSIDERED\n", pid);

                    float x = touchEvent.pointerEvents[i].x;
                    float y = touchEvent.pointerEvents[i].y;
                    totalX     += x;
                    totalY     += y;
                    dx         += x - inputs[pid].x;
                    dy         += y - inputs[pid].y;
                    inputs[pid] = new Vector2(x, y);

                    //var delta = new Vector2(dx, dy);
                    //if(delta.LengthSq() > MIN_PAN_MAG_DELTA_SQUARED_TOLERANCE) {
                    somethingPanned = true;
                    //}
                }
            }

            if (inputsToConsider > 0)
            {
                if (!panning && somethingPanned)
                {
                    totalX /= inputsToConsider;
                    totalY /= inputsToConsider;
                    panning = true;
                    panCenter.Set(totalX, totalY);

                    AppInterface.PanData pan;
                    Vector2 touchExtents = GetTouchExtents(touchEvent);
                    pan = PopulatePanData(inputsToConsider, touchExtents);

                    //Wrld_TTY("PAN START\n");
                    m_handler.Event_TouchPan_Start(pan);
                }

                if (panning)
                {
                    dx /= inputsToConsider;
                    dy /= inputsToConsider;
                    float newX = panCenter.x + dx;
                    float newY = panCenter.y + dy;

                    panCenter.Set(newX, newY);

                    AppInterface.PanData pan;
                    Vector2 touchExtents = GetTouchExtents(touchEvent);
                    pan = PopulatePanData(inputsToConsider, touchExtents);

                    m_handler.Event_TouchPan(pan);
                }
            }
        }