# HG changeset patch # User saiam # Date 1228053666 0 # Node ID fc572ad7326aaa0021d0aaaddd689cb55d83b7fa # Parent d02f642625ec64a8c93703e64ba8aab40b33207d Terrain::getTangent and Terrain::getNormal must be implemented. Everything else should be there. Still: Not tested, not used. diff -r d02f642625ec -r fc572ad7326a src/proto2/Terrain.cc --- 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); + } + } + } + } }