equal
deleted
inserted
replaced
100 else |
100 else |
101 return TILE_XY(x, y); |
101 return TILE_XY(x, y); |
102 } |
102 } |
103 |
103 |
104 // Functions to calculate distances |
104 // Functions to calculate distances |
105 uint DistanceManhattan(TileIndex, TileIndex); // also known as L1-Norm |
105 uint DistanceManhattan(TileIndex, TileIndex); // also known as L1-Norm. Is the shortest distance one could go over diagonal tracks (or roads) |
106 uint DistanceSquare(TileIndex, TileIndex); // euclidian- or L2-Norm squared |
106 uint DistanceSquare(TileIndex, TileIndex); // euclidian- or L2-Norm squared |
107 uint DistanceMax(TileIndex, TileIndex); // also known as L-Infinity-Norm |
107 uint DistanceMax(TileIndex, TileIndex); // also known as L-Infinity-Norm |
108 uint DistanceMaxPlusManhattan(TileIndex, TileIndex); // Max + Manhattan |
108 uint DistanceMaxPlusManhattan(TileIndex, TileIndex); // Max + Manhattan |
|
109 uint DistanceTrack(TileIndex, TileIndex); // Returns the shortest distance one could go over tracks |
109 uint DistanceFromEdge(TileIndex); // shortest distance from any edge of the map |
110 uint DistanceFromEdge(TileIndex); // shortest distance from any edge of the map |
110 |
111 |
111 |
112 |
112 static inline TileIndexDiff TileOffsByDir(uint dir) |
113 static inline TileIndexDiff TileOffsByDir(uint dir) |
113 { |
114 { |
115 |
116 |
116 assert(dir < lengthof(_tileoffs_by_dir)); |
117 assert(dir < lengthof(_tileoffs_by_dir)); |
117 return ToTileIndexDiff(_tileoffs_by_dir[dir]); |
118 return ToTileIndexDiff(_tileoffs_by_dir[dir]); |
118 } |
119 } |
119 |
120 |
|
121 /* Approximation of the length of a straight track, relative to a diagonal |
|
122 * track (ie the size of a tile side). #defined instead of const so it can |
|
123 * stay integer. (no runtime float operations) Is this needed? |
|
124 * This value should be sqrt(2)/2 ~ 0.7071 */ |
|
125 #define STRAIGHT_TRACK_LENGTH (7071/10000) |
|
126 |
120 #endif |
127 #endif |