summaryrefslogtreecommitdiff
path: root/terrain.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'terrain.cpp')
-rw-r--r--terrain.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/terrain.cpp b/terrain.cpp
index 359cb84..35aef58 100644
--- a/terrain.cpp
+++ b/terrain.cpp
@@ -507,16 +507,17 @@ void Terrain::raise(float x, float z, float radius, float focus, float strength,
}
void Terrain::update(float x, float z) {
+ const int chunk_dist_threshold = chunk_size*4;
std::set<std::pair<int, int> > chunk_indices;
- int i = x - 100;
+ int i = x - chunk_dist_threshold;
i -= i % chunk_size;
- for(; i < x + 100; i += chunk_size) {
- int j = z - 100;
+ for(; i < x + chunk_dist_threshold; i += chunk_size) {
+ int j = z - chunk_dist_threshold;
j -= j % chunk_size;
- for(; j < z + 100; j += chunk_size) {
- float a = i - x;
- float b = j - z;
- if(sqrtf(a*a + b*b) < 100)
+ for(; j < z + chunk_dist_threshold; j += chunk_size) {
+ float a = i - x + chunk_size/2;
+ float b = j - z + chunk_size/2;
+ if(sqrtf(a*a + b*b) < chunk_dist_threshold)
chunk_indices.insert(std::pair<int, int>(i, j));
}
}
@@ -525,7 +526,7 @@ void Terrain::update(float x, float z) {
if(ind_it != chunk_indices.end()) {
chunk_indices.erase(ind_it);
}
- if((*it)->distance(x, z) > 100) {
+ if((*it)->distance(x, z) > chunk_dist_threshold) {
it = chunks.erase(it);
}
}