Ejemplo n.º 1
0
 public static bool Equals(RectInt32 rect1, RectInt32 rect2)
 {
     if (rect1.IsEmpty)
     {
         return rect2.IsEmpty;
     }
     return (((rect1.X.Equals(rect2.X) && rect1.Y.Equals(rect2.Y)) && rect1.Width.Equals(rect2.Width)) && rect1.Height.Equals(rect2.Height));
 }
Ejemplo n.º 2
0
 public bool Contains(RectInt32 rect)
 {
     if (this.IsEmpty || rect.IsEmpty)
     {
         return(false);
     }
     return(this.x <= rect.x && this.y <= rect.y && this.x + this.width >= rect.x + rect.width &&
            this.y + this.height >= rect.y + rect.height);
 }
Ejemplo n.º 3
0
 public static bool Equals(RectInt32 rect1, RectInt32 rect2)
 {
     if (rect1.IsEmpty)
     {
         return(rect2.IsEmpty);
     }
     return(rect1.X.Equals(rect2.X) && rect1.Y.Equals(rect2.Y) && rect1.Width.Equals(rect2.Width) &&
            rect1.Height.Equals(rect2.Height));
 }
Ejemplo n.º 4
0
 public bool Contains(RectInt32 rect)
 {
     if (IsEmpty || rect.IsEmpty)
     {
         return(false);
     }
     return((((x <= rect.x) && (y <= rect.y)) &&
             ((x + width) >= (rect.x + rect.width))) && ((y + height) >= (rect.y + rect.height)));
 }
Ejemplo n.º 5
0
 public bool IntersectsWith(RectInt32 rect)
 {
     if (this.IsEmpty || rect.IsEmpty)
     {
         return(false);
     }
     return(rect.Left <= this.Right && rect.Right >= this.Left && rect.Top <= this.Bottom &&
            rect.Bottom >= this.Top);
 }
Ejemplo n.º 6
0
 public bool Contains(RectInt32 rect)
 {
     if (IsEmpty || rect.IsEmpty)
     {
         return(false);
     }
     return(x <= rect.x && y <= rect.y && x + width >= rect.x + rect.width &&
            y + height >= rect.y + rect.height);
 }
Ejemplo n.º 7
0
 static RectInt32()
 {
     s_empty = new RectInt32
     {
         x      = 0,
         y      = 0,
         width  = 0,
         height = 0
     };
 }
Ejemplo n.º 8
0
 static RectInt32()
 {
     s_empty = new RectInt32
     {
         x = 0,
         y = 0,
         width = 0,
         height = 0
     };
 }
Ejemplo n.º 9
0
        public RectInt32 Intersect(RectInt32 rect)
        {
            if (!this.IntersectsWith(rect))
            {
                return(RectInt32.Empty);
            }
            int num1 = Math.Max(this.Left, rect.Left);
            int num2 = Math.Max(this.Top, rect.Top);

            return(new RectInt32()
            {
                width = Math.Max(Math.Min(this.Right, rect.Right) - num1, 0),
                height = Math.Max(Math.Min(this.Bottom, rect.Bottom) - num2, 0),
                x = num1,
                y = num2
            });
        }
Ejemplo n.º 10
0
 public RectInt32 Intersect(RectInt32 rect)
 {
     if (!IntersectsWith(rect))
     {
         return(Empty);
     }
     else
     {
         int num  = Math.Max(Left, rect.Left);
         int num2 = Math.Max(Top, rect.Top);
         return(new RectInt32()
         {
             width = Math.Max(Math.Min(Right, rect.Right) - num, 0),
             height = Math.Max(Math.Min(Bottom, rect.Bottom) - num2, 0),
             x = num,
             y = num2
         });
     }
 }
Ejemplo n.º 11
0
 public bool IntersectsWith(RectInt32 rect)
 {
     if (IsEmpty || rect.IsEmpty)
     {
         return false;
     }
     return ((((rect.Left <= Right) && (rect.Right >= Left)) && (rect.Top <= Bottom)) && (rect.Bottom >= Top));
 }
Ejemplo n.º 12
0
 public RectInt32 Intersect(RectInt32 rect)
 {
     if (!IntersectsWith(rect))
     {
         return Empty;
     }
     else
     {
         int num = Math.Max(Left, rect.Left);
         int num2 = Math.Max(Top, rect.Top);
         return new RectInt32() {
         width = Math.Max(Math.Min(Right, rect.Right) - num, 0),
         height = Math.Max(Math.Min(Bottom, rect.Bottom) - num2, 0),
         x = num,
         y = num2
         };
     }
 }
Ejemplo n.º 13
0
 public bool Equals(RectInt32 value)
 {
     return Equals(this, value);
 }
Ejemplo n.º 14
0
 public bool Contains(RectInt32 rect)
 {
     if (IsEmpty || rect.IsEmpty)
     {
         return false;
     }
     return ((((x <= rect.x) && (y <= rect.y)) &&
              ((x + width) >= (rect.x + rect.width))) && ((y + height) >= (rect.y + rect.height)));
 }
Ejemplo n.º 15
0
 public static RectInt32 Offset(RectInt32 rect, int offsetX, int offsetY)
 {
     rect.Offset(offsetX, offsetY);
     return rect;
 }
Ejemplo n.º 16
0
 public static RectInt32 Intersect(RectInt32 rect1, RectInt32 rect2)
 {
     rect1.Intersect(rect2);
     return rect1;
 }
Ejemplo n.º 17
0
 public bool Equals(RectInt32 value)
 {
     return(RectInt32.Equals(this, value));
 }
Ejemplo n.º 18
0
 public static RectInt32 Offset(RectInt32 rect, int offsetX, int offsetY)
 {
     rect.Offset(offsetX, offsetY);
     return(rect);
 }
Ejemplo n.º 19
0
 public static RectInt32 Intersect(RectInt32 rect1, RectInt32 rect2)
 {
     rect1.Intersect(rect2);
     return(rect1);
 }
Ejemplo n.º 20
0
		/// <summary>
		/// Adds the rendering liquid vertices to the provided list for the MapChunk given by:
		/// </summary>
		/// <param name="indexY">The y index of the map chunk.</param>
		/// <param name="indexX">The x index of the map chunk</param>
		/// <param name="vertices">The Collection to add the vertices to.</param>
		/// <returns>The number of vertices added.</returns>
		public override int GenerateLiquidVertices(int indexX, int indexY, ICollection<Vector3> vertices)
		{
			var count = 0;
			var chunk = Chunks[indexX, indexY];

			if (chunk == null) return count;
			if (!chunk.HasLiquid) return count;

			//var clr = Color.Green;

			//switch (mh2O.Header.Type)
			//{
			//    case FluidType.Water:
			//        clr = Color.Blue;
			//        break;
			//    case FluidType.Lava:
			//        clr = Color.Red;
			//        break;
			//    case FluidType.OceanWater:
			//        clr = Color.Coral;
			//        break;
			//}

			var mh2OHeightMap = chunk.LiquidHeights;
			var header = chunk.WaterInfo.Header;
			var bounds = new RectInt32(header.XOffset, header.YOffset, header.Width, header.Height);
			for (var xStep = 0; xStep <= TerrainConstants.UnitsPerChunkSide; xStep++)
			{
				for (var yStep = 0; yStep < 9; yStep++)
				{
					var xPos = TerrainConstants.CenterPoint - (TileX * TerrainConstants.TileSize) -
							   (indexX * TerrainConstants.ChunkSize) - (xStep * TerrainConstants.UnitSize);
					var yPos = TerrainConstants.CenterPoint - (TileY * TerrainConstants.TileSize) -
							   (indexY * TerrainConstants.ChunkSize) - (yStep * TerrainConstants.UnitSize);

					if (((xStep < bounds.X) || ((xStep - bounds.X) > bounds.Height)) ||
						((yStep < bounds.Y) || ((yStep - bounds.Y) > bounds.Width)))
					{
						continue;
					}

					var zPos = mh2OHeightMap[yStep - bounds.Y, xStep - bounds.X];

					var position = new Vector3(xPos, yPos, zPos);

					vertices.Add(position);
					count++;
				}
			}
			return count;
		}
Ejemplo n.º 21
0
		/// <summary>
		/// Adds the rendering liquid indices to the provided list for the MapChunk given by:
		/// </summary>
		/// <param name="indexY">The y index of the map chunk.</param>
		/// <param name="indexX">The x index of the map chunk</param>
		/// <param name="offset">The number to add to the indices so as to match the end of the Vertices list.</param>
		/// <param name="indices">The Collection to add the indices to.</param>
		public override void GenerateLiquidIndices(int indexX, int indexY, int offset, List<int> indices)
		{
			var chunk = Chunks[indexX, indexY];
			if (chunk == null) return;
			if (!chunk.HasLiquid) return;

			var renderMap = chunk.LiquidMap;
			var header = chunk.WaterInfo.Header;
			var bounds = new RectInt32(header.XOffset, header.YOffset, header.Width, header.Height);
			for (int r = bounds.X; r < (bounds.X + bounds.Height); r++)
			{
				for (int c = bounds.Y; c < (bounds.Y + bounds.Width); c++)
				{
					var row = r - bounds.X;
					var col = c - bounds.Y;

					if (!renderMap[col, row] && ((bounds.Height != 8) || (bounds.Width != 8))) continue;
					indices.Add(offset + ((row + 1) * (bounds.Width + 1) + col));
					indices.Add(offset + (row * (bounds.Width + 1) + col));
					indices.Add(offset + (row * (bounds.Width + 1) + col + 1));
					indices.Add(offset + ((row + 1) * (bounds.Width + 1) + col + 1));
					indices.Add(offset + ((row + 1) * (bounds.Width + 1) + col));
					indices.Add(offset + (row * (bounds.Width + 1) + col + 1));
				}
			}
		}