Terrain::getTangent and Terrain::getNormal must be implemented. Everything else should be there. Still: Not tested, not
used.
--- a/src/proto2/Terrain.cc Sun Nov 30 13:52:48 2008 +0000
+++ b/src/proto2/Terrain.cc Sun Nov 30 14:01:06 2008 +0000
@@ -104,12 +104,23 @@
return false; // No Collision
}
-void Terrain::removeGround(const Vector &pos, const float r) {
+void Terrain::removeGround(const Vector &pos, const float radius) {
// TODO: Implement. Some circle algoritmh should be usefull here,
// though the current impelementation doesn't seem too bad either.
- Vector midpoint = getPixelLocation(pos);
-
+ Vector mid = getPixelLocation(pos);
+ uint16_t r = scale(radius);
+ for (uint16_t i = mid.x-r; i < mid.x+r; i++) {
+ for (uint_16_t j = mid.y-r; j < mid.y+r; j++) {
+ if (getType(i, j) != ROCK) { // getType returns ROCK if
+ // out of bounds
+ if ((i-mid.x)*(i-mid.x)+(j-mid.y)*(j-mid.y) < r*r) {
+ terrain[i][j] = EMPTY;
+ terr.draw_pixel(i, j, COLOR_EMPTY);
+ }
+ }
+ }
+ }
}