コード例 #1
0
 /// <summary>
 /// assumes both rectangles have the same transform
 /// </summary>
 /// <param name="that"></param>
 /// <returns></returns>
 public bool simpleIsTouching(GameRectangle that)
 {
     if (this.boundingBox.Left > that.boundingBox.Right || this.boundingBox.Top > that.boundingBox.Bottom ||
         this.boundingBox.Right < that.boundingBox.Left || this.boundingBox.Bottom < that.boundingBox.Top)
     {
         return(false);
     }
     return(true);
 }
コード例 #2
0
        public bool isTouching(GameRectangle that)
        {
            RawVector2[] theseCorners = this.getGlobalCorners();
            RawVector2[] thoseCorners = that.getGlobalCorners();

            RawVector2 thisMin = theseCorners[0];
            RawVector2 thatMin = thoseCorners[0];
            RawVector2 thisMax = theseCorners[0];
            RawVector2 thatMax = thoseCorners[0];

            for (int i = 1; i < 4; i++)
            {
                thisMin.X = Math.Min(thisMin.X, theseCorners[i].X);
                thisMin.Y = Math.Min(thisMin.Y, theseCorners[i].Y);
                thisMax.X = Math.Max(thisMax.X, theseCorners[i].X);
                thisMax.Y = Math.Max(thisMax.Y, theseCorners[i].Y);
                thatMin.X = Math.Min(thatMin.X, thoseCorners[i].X);
                thatMin.Y = Math.Min(thatMin.Y, thoseCorners[i].Y);
                thatMax.X = Math.Max(thatMax.X, thoseCorners[i].X);
                thatMax.Y = Math.Max(thatMax.Y, thoseCorners[i].Y);
            }
            if (thisMin.X > thatMax.X || thisMin.Y > thatMax.Y || thisMax.X < thatMin.X || thisMax.Y < thatMin.Y)
            {
                return(false);
            }

            for (int i = 0; i < 4; i++)
            {
                if (testSeparator(theseCorners[i], theseCorners[(i + 1) % 4], theseCorners[(i + 2) % 4], thoseCorners))
                {
                    return(false);
                }
            }
            for (int i = 0; i < 4; i++)
            {
                if (testSeparator(thoseCorners[i], thoseCorners[(i + 1) % 4], thoseCorners[(i + 2) % 4], theseCorners))
                {
                    return(false);
                }
            }
            return(true);
        }
コード例 #3
0
 public void addGameRectangle(GameRectangle bv)
 {
     grs.Add(bv);
 }