Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
proller committed Oct 18, 2024
1 parent 63e009e commit a025a08
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 36 deletions.
48 changes: 23 additions & 25 deletions src/client/clientmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,32 +35,30 @@ along with Freeminer. If not, see <http://www.gnu.org/licenses/>.
struct MapDrawControl
{

// freeminer:
int32_t farmesh = 30000;
uint16_t farmesh_quality = 0;
bool farmesh_stable = false;
int32_t lodmesh = 4;
int cell_size = 1;
uint8_t cell_size_pow = 0;
uint8_t farmesh_quality_pow = 0;

float fps = 30;
float fps_avg = 30;
float fps_wanted = 30;
float drawtime_avg = 30;

float fov = 180;
float fov_add = 0;
float fov_want = 180; // smooth change

float farthest_drawn = 0;

//bool block_overflow;
// freeminer:
int32_t farmesh{30000};
uint16_t farmesh_quality{};
bool farmesh_stable{};
int32_t lodmesh{4};
int cell_size{1};
uint8_t cell_size_pow{};
uint8_t farmesh_quality_pow{};

float fps{30};
float fps_avg{30};
float fps_wanted{30};
float drawtime_avg{30};

float fov{180};
float fov_add{};
float fov_want{180}; // smooth change

float farthest_drawn{};

void fm_init();
MapDrawControl() {
fm_init();
}
// ==
MapDrawControl() { fm_init(); }
// ==


// Wanted drawing range
std::atomic_int32_t wanted_range = 0.0f;
Expand Down
21 changes: 13 additions & 8 deletions src/client/fm_farmesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ void FarMesh::makeFarBlock(
}
block->far_iteration = far_iteration_complete;
if (new_block) {
last_async = std::async(std::launch::async,
std::async(std::launch::async,
[this, block]() mutable { m_client->createFarMesh(block); });
}
return;
Expand Down Expand Up @@ -249,7 +249,6 @@ FarMesh::FarMesh(Client *client, Server *server, MapDrawControl *control) :

FarMesh::~FarMesh()
{
last_async.wait();
}

auto align_shift(auto pos, const auto amount)
Expand Down Expand Up @@ -431,8 +430,9 @@ uint8_t FarMesh::update(v3opos_t camera_pos,
//float brightness,
int render_range, float speed)
{
if (!mg)
if (!mg) {
return {};
}

m_speed = speed;

Expand All @@ -451,8 +451,9 @@ uint8_t FarMesh::update(v3opos_t camera_pos,
m_camera_pos_aligned.getDistanceFrom(camera_pos_aligned_int) > 1000);

const auto set_new_cam_pos = [&]() {
if (m_camera_pos_aligned == camera_pos_aligned_int)
if (m_camera_pos_aligned == camera_pos_aligned_int) {
return false;
}

++far_iteration_complete;

Expand All @@ -471,8 +472,9 @@ uint8_t FarMesh::update(v3opos_t camera_pos,
set_new_cam_pos();
}
clientMap.far_blocks_last_cam_pos = m_camera_pos_aligned;
if (!last_distance_max)
if (!last_distance_max) {
last_distance_max = distance_max;
}
}

if (complete_set) {
Expand All @@ -499,8 +501,9 @@ uint8_t FarMesh::update(v3opos_t camera_pos,
break;
}
#endif
if (!plane_processed[i].processed)
if (!plane_processed[i].processed) {
continue;
}
++planes_processed;
async[i].step([this, i = i]() {
//for (int depth = 0; depth < 100; ++depth) {
Expand All @@ -517,15 +520,17 @@ uint8_t FarMesh::update(v3opos_t camera_pos,
}

bool cam_pos_updated{};
if (far_fast || !planes_processed)
if (far_fast || !planes_processed) {
cam_pos_updated = set_new_cam_pos();
}
if (!cam_pos_updated) {
if (!planes_processed && !complete_set) {
clientMap.far_blocks_last_cam_pos = m_camera_pos_aligned;
clientMap.far_iteration_use = far_iteration_complete;

if (far_iteration_complete)
if (far_iteration_complete) {
clientMap.far_iteration_clean = far_iteration_complete - 1;
}
complete_set = true;
}
} else if (far_fast) {
Expand Down
2 changes: 0 additions & 2 deletions src/client/fm_farmesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,4 @@ class FarMesh
concurrent_shared_unordered_map<uint16_t, concurrent_unordered_set<v3bpos_t>>
far_blocks_list;
std::array<async_step_runner, 6> async;

std::future<void> last_async;
};
1 change: 0 additions & 1 deletion src/fm_world_merge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,6 @@ bool WorldMerger::merge_all()

bool WorldMerger::merge_changed()
{
DUMP("wantmerge", changed_blocks_for_merge.size());
if (!changed_blocks_for_merge.empty()) {
const auto res = merge_list(changed_blocks_for_merge);
changed_blocks_for_merge.clear();
Expand Down

0 comments on commit a025a08

Please sign in to comment.