Skip to content

Commit

Permalink
Expose getNeighbor() as GetFrontNeighbor()
Browse files Browse the repository at this point in the history
  • Loading branch information
Majiir committed Sep 2, 2014
1 parent dce52c6 commit a3b694b
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions Plugin/GeodesicGrid/Cell.cs
Expand Up @@ -223,9 +223,9 @@ public IEnumerable<Triangle> GetChildren(int level)
var dir = this.getDirection();

yield return this;
yield return new Triangle(root.getNeighbor(ChildType.Straight, level), dir);
yield return new Triangle(root.GetFrontNeighbor(ChildType.Straight, level), dir);

var cell = root.getNeighbor(dir == FaceDirection.Down ? ChildType.Down : ChildType.Up, level);
var cell = root.GetFrontNeighbor(dir == FaceDirection.Down ? ChildType.Down : ChildType.Up, level);
yield return new Triangle(cell, FaceDirection.Down);
yield return new Triangle(cell, FaceDirection.Up);
}
Expand All @@ -239,13 +239,13 @@ public IEnumerable<Cell> GetVertices(int level)

if (this.getDirection() == FaceDirection.Up)
{
yield return root.getNeighbor(ChildType.Up, level);
yield return root.getNeighbor(ChildType.Straight, level);
yield return root.GetFrontNeighbor(ChildType.Up, level);
yield return root.GetFrontNeighbor(ChildType.Straight, level);
}
else
{
yield return root.getNeighbor(ChildType.Straight, level);
yield return root.getNeighbor(ChildType.Down, level);
yield return root.GetFrontNeighbor(ChildType.Straight, level);
yield return root.GetFrontNeighbor(ChildType.Down, level);
}
}

Expand Down Expand Up @@ -445,9 +445,9 @@ public IEnumerable<Cell> GetNeighbors(int level)
}
else
{
yield return this.getNeighbor(ChildType.Up, level);
yield return this.getNeighbor(ChildType.Straight, level);
yield return this.getNeighbor(ChildType.Down, level);
yield return this.GetFrontNeighbor(ChildType.Up, level);
yield return this.GetFrontNeighbor(ChildType.Straight, level);
yield return this.GetFrontNeighbor(ChildType.Down, level);

var root = IsPentagon;

Expand Down Expand Up @@ -497,7 +497,7 @@ public Cell GetParent()
private Cell getSecondParent()
{
if (Level == 0) { throw new InvalidOperationException("Cannot find parent of a top-level cell"); }
return GetParent().getNeighbor(this.direction, Level - 1);
return GetParent().GetFrontNeighbor(this.direction, Level - 1);
}

private Cell getChild(ChildType direction)
Expand Down Expand Up @@ -537,7 +537,7 @@ private static uint wrap(uint index)

private static readonly List<Cell[,]> neighborCache = new List<Cell[,]>();

private Cell getNeighbor(ChildType direction, int level)
public Cell GetFrontNeighbor(ChildType direction, int level)
{
var thisLevel = this.Level;
if (level < thisLevel) { throw new ArgumentException("Cannot find neighbor at a level index lower than this cell"); }
Expand Down Expand Up @@ -578,24 +578,24 @@ private Cell getNeighbor(ChildType direction, int level)
var first = cell.GetParent();
if (thisDir == dir)
{
cache[j, k] = first.getNeighbor(dir, cacheLevel - 1);
cache[j, k] = first.GetFrontNeighbor(dir, cacheLevel - 1);
}
else if (thisDir == dir.Flip())
{
cache[j, k] = first.getNeighbor(ChildType.Straight, cacheLevel);
cache[j, k] = first.GetFrontNeighbor(ChildType.Straight, cacheLevel);
}
else
{
if (dir == ChildType.Straight) { dir = thisDir; }

var other = first.getNeighbor(dir, cacheLevel - 1);
var other = first.GetFrontNeighbor(dir, cacheLevel - 1);
if (other.isPolarSeam() && (first.getRoot() != other.getRoot()))
{
cache[j, k] = first.getNeighbor(ChildType.Straight, cacheLevel - 1).getNeighbor(dir, cacheLevel);
cache[j, k] = first.GetFrontNeighbor(ChildType.Straight, cacheLevel - 1).GetFrontNeighbor(dir, cacheLevel);
}
else
{
cache[j, k] = other.getNeighbor(dir.Flip(), cacheLevel);
cache[j, k] = other.GetFrontNeighbor(dir.Flip(), cacheLevel);
}
}
}
Expand Down Expand Up @@ -662,7 +662,7 @@ private Cell getBackNeighbor(ChildType direction, int level)
}
else if (thisDir == ChildType.Straight)
{
return first.getNeighbor(direction, level);
return first.GetFrontNeighbor(direction, level);
}
else
{
Expand All @@ -681,11 +681,11 @@ private Cell getBackNeighbor(ChildType direction, int level)

if ((direction == ChildType.Straight) == seam)
{
return common.getNeighbor(ChildType.Straight, thisLevel).approach(seam ? thisDir : other, level - thisLevel);
return common.GetFrontNeighbor(ChildType.Straight, thisLevel).approach(seam ? thisDir : other, level - thisLevel);
}
else
{
return common.getNeighbor(seam ? thisDir : other, thisLevel).approach(ChildType.Straight, level - thisLevel);
return common.GetFrontNeighbor(seam ? thisDir : other, thisLevel).approach(ChildType.Straight, level - thisLevel);
}
}
}
Expand All @@ -702,7 +702,7 @@ private bool isPolarSeam()
if (cell.direction != dir) { return false; }
cell = cell.GetParent();
}
return cell.getNeighbor(dir, 0).isPolar;
return cell.GetFrontNeighbor(dir, 0).isPolar;
}

#endregion
Expand Down

0 comments on commit a3b694b

Please sign in to comment.