Пример #1
0
        //---------------------------------------------------------------------
        public bool Pick(int fromX, int fromY, int destX, int destY, float value, ref EbPixelNavigatePickData result)
        {
            int deltaX = destX - fromX;
            int deltaY = destY - fromY;

            if (deltaX == 0 && deltaY == 0)
            {
                return(false);
            }
            float absDeltaX = Math.Abs((float)deltaX);
            float absDeltaY = Math.Abs((float)deltaY);

            if (absDeltaX >= absDeltaY)
            {
                if (deltaX < 0)
                {
                    return(_pickXNegative(fromX, fromY, destX, destY, value, ref result));
                }
                else
                {
                    return(_pickXPositive(fromX, fromY, destX, destY, value, ref result));
                }
            }
            else
            {
                if (deltaY < 0)
                {
                    return(_pickYNegative(fromX, fromY, destX, destY, value, ref result));
                }
                else
                {
                    return(_pickYPositive(fromX, fromY, destX, destY, value, ref result));
                }
            }
        }
Пример #2
0
        //---------------------------------------------------------------------
        bool _pickXPositive(int fromX, int fromY, int destX, int destY, float value, ref EbPixelNavigatePickData result)
        {
            int deltaX = destX - fromX;
            int deltaY = destY - fromY;

            float fromCenterX = (float)fromX + 0.5f;
            float fromCenterY = (float)fromY + 0.5f;

            float fDeltaX = 1.0f;
            float fDeltaY = (float)deltaY / Math.Abs((float)deltaX);

            float pickX = fromCenterX;
            float pickY = fromCenterY;

            for (int idx = fromX; idx < destX; ++idx)
            {
                pickX += fDeltaX;
                pickY += fDeltaY;

                int newCellX = (int)pickX;
                int newCellY = (int)pickY;
                if (mListStep[newCellX + newCellY * mSizeX].Cost == value)
                {
                    result.blockX    = newCellX;
                    result.blockY    = newCellY;
                    result.lastFreeX = (int)(pickX - fDeltaX);
                    result.lastFreeY = (int)(pickY - fDeltaY);
                    return(true);
                }
            }
            if (mListStep[destX + destY * mSizeX].Cost == value)
            {
                result.blockX    = destX;
                result.blockY    = destY;
                result.lastFreeX = (int)(pickX);
                result.lastFreeY = (int)(pickY);
                return(true);
            }
            return(false);
        }
Пример #3
0
        //---------------------------------------------------------------------
        bool _pickYPositive(int fromX, int fromY, int destX, int destY, float value, ref EbPixelNavigatePickData result)
        {
            int deltaX = destX - fromX;
            int deltaY = destY - fromY;

            float fromCenterX = (float)fromX + 0.5f;
            float fromCenterY = (float)fromY + 0.5f;

            float fDeltaX = (float)deltaX / Math.Abs((float)deltaY);
            float fDeltaY = 1.0f;
            float pickX = fromCenterX;
            float pickY = fromCenterY;

            for (int idx = fromY; idx < destY; ++idx)
            {
                pickX += fDeltaX;
                pickY += fDeltaY;

                int newCellX = (int)pickX;
                int newCellY = (int)pickY;
                if (mListStep[newCellX + newCellY * mSizeX].Cost == value)
                {
                    result.blockX = newCellX;
                    result.blockY = newCellY;
                    result.lastFreeX = (int)(pickX - fDeltaX);
                    result.lastFreeY = (int)(pickY - fDeltaY);
                    return true;
                }
            }
            if (mListStep[destX + destY * mSizeX].Cost == value)
            {
                result.blockX = destX;
                result.blockY = destY;
                result.lastFreeX = (int)(pickX);
                result.lastFreeY = (int)(pickY);
                return true;
            }
            return false;
        }
Пример #4
0
 //---------------------------------------------------------------------
 public bool Pick(int fromX, int fromY, int destX, int destY, float value, ref EbPixelNavigatePickData result)
 {
     int deltaX = destX - fromX;
     int deltaY = destY - fromY;
     if (deltaX == 0 && deltaY == 0)
     {
         return false;
     }
     float absDeltaX = Math.Abs((float)deltaX);
     float absDeltaY = Math.Abs((float)deltaY);
     if (absDeltaX >= absDeltaY)
     {
         if (deltaX < 0)
         {
             return _pickXNegative(fromX, fromY, destX, destY, value, ref result);
         }
         else
         {
             return _pickXPositive(fromX, fromY, destX, destY, value, ref result);
         }
     }
     else
     {
         if (deltaY < 0)
         {
             return _pickYNegative(fromX, fromY, destX, destY, value, ref result);
         }
         else
         {
             return _pickYPositive(fromX, fromY, destX, destY, value, ref result);
         }
     }
 }
Пример #5
0
 //---------------------------------------------------------------------
 public bool pick(int fromX, int fromY, int destX, int destY)
 {
     EbPixelNavigatePickData data = new EbPixelNavigatePickData();
     return Pick(fromX, fromY, destX, destY, 1f, ref data);
 }
Пример #6
0
        //---------------------------------------------------------------------
        public bool pick(int fromX, int fromY, int destX, int destY)
        {
            EbPixelNavigatePickData data = new EbPixelNavigatePickData();

            return(Pick(fromX, fromY, destX, destY, 1f, ref data));
        }