--- a/src/proto2/Terrain.cc Sun Nov 30 17:22:57 2008 +0000
+++ b/src/proto2/Terrain.cc Sun Nov 30 19:20:11 2008 +0000
@@ -135,11 +135,23 @@
normal += DIRECTIONS[i];
}
}
- if (normal.length() == 0) normal = prevPoint - point;
+
+ // Special cases
+ Vector tmp = direction(direction(prevPoint-point) + direction(normal));
+ if (normal.length() == 0 || getType(tmp.x, tmp.y) != EMPTY)
+ normal = prevPoint - point; // Direct hit
+
+ if (getType(tmp.x,tmp.y) != EMPTY)
Engine::log(DEBUG, "Terrain.getNormal") << "Normal: " << normal;
return normal;
}
+Vector direction(const Vector &v) {
+ Vector tmp(v);
+ tmp /= tmp.length();
+ return Vector(round(tmp.x), round(tmp.y));
+}
+
// TODO: This could better :)
// TODO: And this need some cleaning :)
void Terrain::generateTerrain(int seed) {
@@ -196,3 +208,4 @@
std::vector<std::vector<TerrainType> > Terrain::getTerrain() const {
return terrain;
}
+
--- a/src/proto2/Terrain.hh Sun Nov 30 17:22:57 2008 +0000
+++ b/src/proto2/Terrain.hh Sun Nov 30 19:20:11 2008 +0000
@@ -162,4 +162,6 @@
std::vector<std::vector<TerrainType> > getTerrain() const;
};
+Vector direction(const Vector &v);
+
#endif