Permalink
Browse files

Rename Center.edges to borders and Corner.edges to protrudes, to matc…

…h the terminology in my grid article.
  • Loading branch information...
1 parent 9729413 commit 311e786a6e5bab88bfff61fc302e918d4554bb15 @amitp committed Sep 4, 2010
Showing with 19 additions and 19 deletions.
  1. +11 −11 Map.as
  2. +1 −1 NoisyEdges.as
  3. +1 −1 Roads.as
  4. +1 −1 graph/Center.as
  5. +1 −1 graph/Corner.as
  6. +4 −4 mapgen2.as
View
22 Map.as
@@ -71,15 +71,15 @@ package {
for each (p in centers) {
p.neighbors.splice(0, p.neighbors.length);
p.corners.splice(0, p.corners.length);
- p.edges.splice(0, p.edges.length);
+ p.borders.splice(0, p.borders.length);
}
centers.splice(0, centers.length);
}
if (corners) {
for each (q in corners) {
q.adjacent.splice(0, q.adjacent.length);
q.touches.splice(0, q.touches.length);
- q.edges.splice(0, q.edges.length);
+ q.protrudes.splice(0, q.protrudes.length);
q.downslope = null;
q.watershed = null;
}
@@ -269,8 +269,8 @@ package {
p = new Center();
p.index = centers.length;
p.point = point;
- p.edges = new Vector.<Edge>();
p.neighbors = new Vector.<Center>();
+ p.borders = new Vector.<Edge>();
p.corners = new Vector.<Corner>();
centers.push(p);
centerLookup[point] = p;
@@ -308,9 +308,9 @@ package {
q.index = corners.length;
corners.push(q);
q.point = point;
- q.edges = new Vector.<Edge>();
- q.adjacent = new Vector.<Corner>();
q.touches = new Vector.<Center>();
+ q.protrudes = new Vector.<Edge>();
+ q.adjacent = new Vector.<Corner>();
_cornerMap[bucket].push(q);
return q;
}
@@ -333,10 +333,10 @@ package {
edge.d1 = centerLookup[dedge.p1];
// Centers point to edges. Corners point to edges.
- if (edge.d0 != null) { edge.d0.edges.push(edge); }
- if (edge.d1 != null) { edge.d1.edges.push(edge); }
- if (edge.v0 != null) { edge.v0.edges.push(edge); }
- if (edge.v1 != null) { edge.v1.edges.push(edge); }
+ if (edge.d0 != null) { edge.d0.borders.push(edge); }
+ if (edge.d1 != null) { edge.d1.borders.push(edge); }
+ if (edge.v0 != null) { edge.v0.protrudes.push(edge); }
+ if (edge.v1 != null) { edge.v1.protrudes.push(edge); }
function addToCornerList(v:Vector.<Corner>, x:Corner):void {
if (x != null && v.indexOf(x) < 0) { v.push(x); }
@@ -758,14 +758,14 @@ package {
// Look up a Voronoi Edge object given two adjacent Voronoi
// polygons, or two adjacent Voronoi corners
public function lookupEdgeFromCenter(p:Center, r:Center):Edge {
- for each (var edge:Edge in p.edges) {
+ for each (var edge:Edge in p.borders) {
if (edge.d0 == r || edge.d1 == r) return edge;
}
return null;
}
public function lookupEdgeFromCorner(q:Corner, s:Corner):Edge {
- for each (var edge:Edge in q.edges) {
+ for each (var edge:Edge in q.protrudes) {
if (edge.v0 == s || edge.v1 == s) return edge;
}
return null;
View
@@ -24,7 +24,7 @@ package {
public function buildNoisyEdges(map:Map, lava:Lava, random:PM_PRNG):void {
var p:Center, edge:Edge;
for each (p in map.centers) {
- for each (edge in p.edges) {
+ for each (edge in p.borders) {
if (edge.d0 && edge.d1 && edge.v0 && edge.v1 && !path0[edge.index]) {
var f:Number = NOISY_LINE_TRADEOFF;
var t:Point = Point.interpolate(edge.v0.point, edge.d0.point, f);
View
@@ -65,7 +65,7 @@ package {
// Roads go between polygons that have different contour levels
for each (p in map.centers) {
- for each (edge in p.edges) {
+ for each (edge in p.borders) {
if (edge.v0 && edge.v1
&& cornerContour[edge.v0.index] != cornerContour[edge.v1.index]) {
road[edge.index] = Math.min(cornerContour[edge.v0.index],
View
@@ -12,7 +12,7 @@ package graph {
public var biome:String;
public var elevation:Number;
public var moisture:Number;
- public var edges:Vector.<Edge>;
+ public var borders:Vector.<Edge>;
public var neighbors:Vector.<Center>;
public var corners:Vector.<Corner>;
};
View
@@ -11,7 +11,7 @@ package graph {
public var border:Boolean;
public var elevation:Number;
public var moisture:Number;
- public var edges:Vector.<Edge>;
+ public var protrudes:Vector.<Edge>;
public var adjacent:Vector.<Corner>;
public var touches:Vector.<Center>;
View
@@ -479,7 +479,7 @@ package {
graphicsData = new Vector.<IGraphicsData>();
for each (p in map.centers) {
if (p.ocean) continue;
- for each (edge in p.edges) {
+ for each (edge in p.borders) {
var color:int = colors[p.biome] || 0;
if (colorFunction != null) {
color = colorFunction(color, p, q, edge);
@@ -671,7 +671,7 @@ package {
if (roads.roadConnections[p.index]) {
if (roads.roadConnections[p.index].length == 2) {
// Regular road: draw a spline from one edge to the other.
- edges = p.edges;
+ edges = p.borders;
for (i = 0; i < edges.length; i++) {
edge1 = edges[i];
if (roads.road[edge1.index] > 0) {
@@ -702,7 +702,7 @@ package {
} else {
// Intersection or dead end: draw a road spline from
// each edge to the center
- for each (edge1 in p.edges) {
+ for each (edge1 in p.borders) {
if (roads.road[edge1.index] > 0) {
d = 0.25*edge1.midpoint.subtract(p.point).length;
A = normalTowards(edge1, p.point, d).add(edge1.midpoint);
@@ -781,7 +781,7 @@ package {
for each (p in map.centers) {
color = colors[p.biome] || (p.ocean? colors.OCEAN : p.water? colors.RIVER : 0xffffff);
graphics.beginFill(interpolateColor(color, 0xdddddd, 0.2));
- for each (edge in p.edges) {
+ for each (edge in p.borders) {
if (edge.v0 && edge.v1) {
graphics.moveTo(p.point.x, p.point.y);
graphics.lineTo(edge.v0.point.x, edge.v0.point.y);

0 comments on commit 311e786

Please sign in to comment.