@@ -167,8 +167,9 @@ namespace konstructs {
167167 Vector3i pos (p, q, k);
168168 int distance = (pos - player_chunk).norm ();
169169 int score;
170+ auto it = models.find (pos);
171+ bool is_updated = world.chunk_updated_since_requested (pos);
170172 if (chunk_visible (planes, pos)) {
171- auto it = models.find (pos);
172173 if (it != models.end ()) {
173174 /* Ok, found the model, let's render it!
174175 */
@@ -177,10 +178,18 @@ namespace konstructs {
177178 c.set (translation, m->translation );
178179 c.draw (m);
179180 faces += m->faces ;
180- /* We already have a model of the chunk,
181- * so we really don't need it.
182- */
183- score = NO_CHUNK_FOUND;
181+ if (is_updated) {
182+ /* We already have a model of the chunk,
183+ * but it's outdated, so it needs to be refreshed.
184+ */
185+ score = distance / 2 ;
186+ } else {
187+ /* We already have a model of the chunk,
188+ * it didn't change since last requested,
189+ * so we really don't need it.
190+ */
191+ score = NO_CHUNK_FOUND;
192+ }
184193 } else {
185194 /* We wanted to render the model,
186195 * but we didn't have it, so we really want this chunk!
@@ -192,7 +201,13 @@ namespace konstructs {
192201 * but if she turns around she might need this chunk
193202 * so let's fetch it, but not super urgent
194203 */
195- score = distance;
204+ if (it != models.end () && !is_updated) {
205+ /* We already have it and it's not updated */
206+ score = NO_CHUNK_FOUND;
207+ } else {
208+ /* We don't have it or it's update*/
209+ score = distance;
210+ }
196211 }
197212 if (score < best_chunk_score && world.chunk_not_requested (pos)) {
198213 best_chunk_score = score;
0 commit comments