Fix thread loops missing blocks

This commit is contained in:
Marc Gilleron 2018-09-27 00:31:09 +01:00
parent 7357060377
commit 4d6765130d
4 changed files with 10 additions and 4 deletions

View File

@ -3,6 +3,7 @@
#include <core/vector.h>
#include <core/dvector.h>
#include <core/ustring.h>
#include "vector3i.h"
// Takes elements starting from a given position and moves them at the beginning,
@ -40,4 +41,8 @@ void copy_to(PoolVector<T> &to, const Vector<T> &from) {
}
}
inline String ptr2s(const void *p) {
return String::num_uint64((uint64_t)p, 16);
}
#endif // HEADER_VOXEL_UTILITY_H

View File

@ -147,7 +147,7 @@ void VoxelMeshUpdater::thread_func() {
}
uint32_t time = OS::get_singleton()->get_ticks_msec();
if (time >= sync_time) {
if (time >= sync_time || _input.blocks.empty()) {
thread_sync(queue_index, stats);

View File

@ -40,7 +40,7 @@ void VoxelProviderThread::push(const InputData &input) {
{
MutexLock lock(_input_mutex);
// TODO If the same update is sent twice, keep only the latest one
// TODO If the same request is sent twice, keep only the latest one
_shared_input.blocks_to_emerge.append_array(input.blocks_to_emerge);
_shared_input.blocks_to_immerge.append_array(input.blocks_to_immerge);
@ -125,7 +125,7 @@ void VoxelProviderThread::thread_func() {
}
uint32_t time = OS::get_singleton()->get_ticks_msec();
if (time >= sync_time) {
if (time >= sync_time || _input.is_empty()) {
thread_sync(emerge_index, stats);

View File

@ -578,8 +578,9 @@ void VoxelTerrain::_process() {
// TODO What if the map is really composed of empty blocks?
if (_map->is_block_surrounded(npos)) {
if (state && *state == BLOCK_UPDATE_NOT_SENT || *state == BLOCK_UPDATE_SENT) {
if (state && *state == BLOCK_UPDATE_NOT_SENT) {
// Assuming it is scheduled to be updated already.
// In case of BLOCK_UPDATE_SENT, we'll have to resend it.
continue;
}