示例#1
0
		public void AddSpan_First_Success()
		{
			var cell = new Cell(40);
			var span = new Span(10, 20);

			cell.AddSpan(span);

			Assert.AreEqual(span.Minimum, cell.Spans[0].Minimum);
			Assert.AreEqual(span.Maximum, cell.Spans[0].Maximum);
		}
示例#2
0
		public void AddSpan_Flipped_Success()
		{
			var cell = new Cell(40);
			var span = new Span(20, 10);

			cell.AddSpan(span);

			Assert.AreEqual(cell.Spans[0].Minimum, span.Maximum);
			Assert.AreEqual(cell.Spans[0].Maximum, span.Minimum);
		}
示例#3
0
		public void AddSpan_ContainedMerge_Success()
		{
			var cell = new Cell(40);
			var span = new Span(10, 20);
			var span2 = new Span(5, 25);

			cell.AddSpan(span);
			cell.AddSpan(span2);

			Assert.AreEqual(span2.Minimum, cell.Spans[0].Minimum);
			Assert.AreEqual(span2.Maximum, cell.Spans[0].Maximum);
		}
示例#4
0
		public void AddSpan_Above_Success()
		{
			var cell = new Cell(40);
			var span = new Span(10, 20);
			var span2 = new Span(21, 25);

			cell.AddSpan(span);
			cell.AddSpan(span2);

			Assert.AreEqual(span.Minimum, cell.Spans[0].Minimum);
			Assert.AreEqual(span.Maximum, cell.Spans[0].Maximum);
			Assert.AreEqual(span2.Minimum, cell.Spans[1].Minimum);
			Assert.AreEqual(span2.Maximum, cell.Spans[1].Maximum);
		}
示例#5
0
		public void Filter_LowHangingWalkable_Success()
		{
			var hf = new Heightfield(new BBox3(Vector3.Zero, Vector3.One), 0.5f, 0.02f);
			var span = new Span(10, 15, Area.Default);
			var span2 = new Span(16, 20, Area.Null);

			hf[0].AddSpan(span);
			hf[0].AddSpan(span2);

			hf.FilterLowHangingWalkableObstacles(20);

			Assert.AreEqual(hf[0].Spans[0].Area, hf[0].Spans[1].Area);
		}
示例#6
0
		public void Filter_WalkableLowHeight_Success()
		{
			var hf = new Heightfield(new BBox3(Vector3.Zero, Vector3.One), 0.5f, 0.02f);
			var span = new Span(10, 20, Area.Default);
			var span2 = new Span(25, 30, Area.Default);

			hf[0].AddSpan(span);
			hf[0].AddSpan(span2);

			//too low to walk through. there is only a gap of 5 units to walk through,
			//but at least 15 units is needed
			hf.FilterWalkableLowHeightSpans(15);

			//so one span is unwalkable and the other is fine
			Assert.AreEqual(hf[0].Spans[0].Area, Area.Null);
			Assert.AreEqual(hf[0].Spans[1].Area, Area.Default);
		}
示例#7
0
		public void Filter_LowHangingWalkable_Fail()
		{
			var hf = new Heightfield(new BBox3(Vector3.Zero, Vector3.One), 0.5f, 0.02f);
			var span = new Span(1, 2, Area.Default);
			var span2 = new Span(10, 20, Area.Null);

			hf[2].AddSpan(span);
			hf[2].AddSpan(span2);

			//walkable step cannot cover the gap (difference between span2 maximum and span 1 maximum) so fail
			hf.FilterLowHangingWalkableObstacles(10);
			Assert.AreNotEqual(hf[0, 1].Spans[0].Area, hf[0, 1].Spans[1].Area);
		}