Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/wip5.8.0' into wip5.8.0webport
Browse files Browse the repository at this point in the history
  • Loading branch information
proller committed Aug 21, 2024
2 parents c9e19a6 + b0b29f0 commit 997e088
Show file tree
Hide file tree
Showing 44 changed files with 795 additions and 369 deletions.
2 changes: 1 addition & 1 deletion build_tools/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ DIST=${DIST=`cat /etc/issue /etc/issue.net | head -n1 | cut -d " " -f1`}
if [ -z "$NO_DEPS" ]; then
if [ "$DIST" = "Debian" ] || [ "$DIST" = "Ubuntu" ]; then
sudo apt install -y git subversion build-essential cmake ninja-build ccache libbz2-dev libzstd-dev libjpeg-dev libfreetype6-dev libxxf86vm-dev libxi-dev libsqlite3-dev libhiredis-dev libvorbis-dev libopenal-dev libcurl4-openssl-dev libssl-dev libluajit-5.1-dev libgettextpo0 libmsgpack-dev libboost-system-dev clang lld llvm libc++-dev libc++abi-dev
for PACKAGE in libpng12-dev libpng-dev libgles1-mesa-dev libgles2-mesa-dev libgl1-mesa-dev libunwind-dev ; do
for PACKAGE in libpng12-dev libpng-dev libgles1-mesa-dev libgles2-mesa-dev libgl1-mesa-dev ; do
sudo apt install -y $PACKAGE ||:
done
elif [ -e /etc/arch-release ]; then
Expand Down
46 changes: 46 additions & 0 deletions cmake-variants.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
buildType:
default: debug
choices:
RelWithDebInfo:
short: RelWithDebInfo
long: Fast and debugable
buildType: RelWithDebInfo
debug:
short: Debug
long: Emit debug information
buildType: Debug
release:
short: Release
long: Optimize generated code
buildType: Release

asan:
short: Asan
long: Instrument with Address Sanitizer
buildType: Debug
settings:
SANITIZE_ADDRESS: ON
tsan:
short: Tsan
long: Instrument with Thread Sanitizer
buildType: Debug
settings:
SANITIZE_THREAD: ON
msan:
short: Msan
long: Instrument with Memory Sanitizer
buildType: Debug
settings:
SANITIZE_MEMORY: ON
usan:
short: Ubsan
long: Instrument with UB Sanitizer
buildType: Debug
settings:
SANITIZE_UNDEFINED: ON
gperf:
short: Gperf
long: Gperf
buildType: Debug
settings:
ENABLE_GPERF: ON
2 changes: 1 addition & 1 deletion games/Repixture
Submodule Repixture updated from 34af64 to ee527c
26 changes: 23 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_CXX_STANDARD 20)

set(HAVE_SHARED_MUTEX 1)

set(CMAKE_POSITION_INDEPENDENT_CODE ON)

set(HAVE_THREAD_LOCAL 1)

set(THREADS_PREFER_PTHREAD_FLAG ON)
Expand Down Expand Up @@ -732,9 +729,30 @@ if(ENABLE_TIFF AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/external/libtiff/CMakeList
set(TIFF_LIRARY TIFF::tiff)
set(TIFF_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/external/libtiff/libtiff ${CMAKE_CURRENT_SOURCE_DIR}/external/libtiff/libtiff)
include_directories(BEFORE SYSTEM ${TIFF_INCLUDE_DIR})
message(STATUS "Using tiff: ${TIFF_INCLUDE_DIR} ${TIFF_LIRARY}")
set(USE_TIFF 1)
endif()

if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/external/libosmium/CMakeLists.txt)
set(BUILD_TESTING 0 CACHE INTERNAL "")
set(BUILD_DATA_TESTS 0 CACHE INTERNAL "")
set(BUILD_EXAMPLES 0 CACHE INTERNAL "")
set(BUILD_BENCHMARKS 0 CACHE INTERNAL "")
add_subdirectory(external/libosmium)
set(OSMIUM_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external/libosmium/include)
include_directories(BEFORE SYSTEM ${OSMIUM_INCLUDE_DIR})
find_package(BZip2)
if(BZIP2_FOUND)
set (OSMIUM_LIRARY ${OSMIUM_LIRARY} BZip2::BZip2)
endif()
find_package(EXPAT)
if(EXPAT_FOUND)
set (OSMIUM_LIRARY ${OSMIUM_LIRARY} EXPAT::EXPAT)
endif()
set(USE_OSMIUM 1)
message(STATUS "Using osmium: ${OSMIUM_INCLUDE_DIR} : ${OSMIUM_LIRARY}")
endif()

if (CMAKE_BUILD_TYPE STREQUAL "Debug" AND ${CMAKE_VERSION} VERSION_GREATER "3.11.0")
set(USE_DEBUG_HELPERS ON CACHE BOOL "")
endif()
Expand Down Expand Up @@ -1000,6 +1018,7 @@ if(BUILD_CLIENT)
${SCTP_LIBRARY}
${WEBSOCKETPP_LIBRARY}
${TIFF_LIRARY}
${OSMIUM_LIRARY}

${LUA_BIT_LIBRARY}
${FREETYPE_LIBRARY}
Expand Down Expand Up @@ -1080,6 +1099,7 @@ if(BUILD_SERVER)
${SCTP_LIBRARY}
${WEBSOCKETPP_LIBRARY}
${TIFF_LIRARY}
${OSMIUM_LIRARY}

${LUA_LIBRARY}
${LUA_BIT_LIBRARY}
Expand Down
2 changes: 1 addition & 1 deletion src/activeobjectmgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,6 @@ class ActiveObjectMgr
// removeObject()!
//std::map<u16, std::unique_ptr<T>> m_active_objects;

concurrent_unordered_map<u16, TPtr> m_active_objects;
concurrent_shared_unordered_map<u16, TPtr> m_active_objects;
std::vector<TPtr> m_active_objects_deleted;
};
8 changes: 8 additions & 0 deletions src/client/activeobjectmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,18 @@ void ActiveObjectMgr::step(
std::vector<u16> ids = getAllIds();

for (u16 id : ids) {
auto it = getActiveObject(id);
if (!it) {
continue;
}
f(it);

/*
auto it = m_active_objects.find(id);
if (it == m_active_objects.end())
continue; // obj was removed
f(it->second);
*/
}

m_active_objects_deleted.clear();
Expand Down
19 changes: 10 additions & 9 deletions src/client/clientmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -901,14 +901,16 @@ void ClientMap::updateDrawListFm(float dtime, unsigned int max_cycle_ms)

auto bp = ir.first;
int range = ir.second;
const auto d = range;
//const auto d = range;
draw_nearest.pop_back();

//auto block = getBlockNoCreateNoEx(bp);
auto block = m_blocks.get(bp);
if (!block)
continue;

block->resetUsageTimer();

const auto mesh_step =
getLodStep(m_control, getNodeBlockPos(m_camera_position_node), bp);

Expand All @@ -930,7 +932,7 @@ void ClientMap::updateDrawListFm(float dtime, unsigned int max_cycle_ms)
{
if ((!mesh && smesh_size < 0) || mesh_step != mesh->lod_step) {
blocks_in_range_without_mesh++;
if (m_mesh_queued < maxq || range <= 1) {
if (m_mesh_queued < maxq || range <= 2) {
const auto bts = block->getTimestamp();
if (block->mesh_requested_timestamp < bts) {
block->mesh_requested_timestamp = bts;
Expand Down Expand Up @@ -1045,9 +1047,6 @@ void ClientMap::updateDrawListFm(float dtime, unsigned int max_cycle_ms)
}


// This block is in range. Reset usage timer.
block->resetUsageTimer();

// Limit block count in case of a sudden increase
blocks_in_range_with_mesh++;
/*
Expand All @@ -1064,9 +1063,9 @@ void ClientMap::updateDrawListFm(float dtime, unsigned int max_cycle_ms)
} else if (const auto bts = block->getTimestamp();
bts != BLOCK_TIMESTAMP_UNDEFINED &&
block->getTimestamp() > mesh->timestamp + (smesh_size ? 0
: range >= 1
: range >= 2
? 60
: 5) &&
: 0) &&
(m_mesh_queued < maxq * 1.5 || range <= 2)) {
if (mesh_step > 1)
m_client->addUpdateMeshTask(bp);
Expand All @@ -1081,7 +1080,7 @@ void ClientMap::updateDrawListFm(float dtime, unsigned int max_cycle_ms)
{
const auto fmesh_step = getFarStep(
m_control, getNodeBlockPos(m_far_blocks_last_cam_pos), bp);
blocks_skip_farmesh.insert(
blocks_skip_farmesh.emplace(
getFarActual(bp, getNodeBlockPos(m_far_blocks_last_cam_pos),
fmesh_step, m_control));
}
Expand Down Expand Up @@ -1129,7 +1128,9 @@ void ClientMap::updateDrawListFm(float dtime, unsigned int max_cycle_ms)
getNodeBlockPos(m_far_blocks_last_cam_pos),
it->first); // m_camera_position_node
if (mesh_step > 1 &&
!inFarGrid(it->first, getNodeBlockPos(m_far_blocks_last_cam_pos), mesh_step, m_control)) {
!inFarGrid(it->first,
getNodeBlockPos(m_far_blocks_last_cam_pos), mesh_step,
m_control)) {
} else {
const auto mesh = it->second->getFarMesh(mesh_step);
if (!mesh) {
Expand Down
2 changes: 1 addition & 1 deletion src/client/clientmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ class ClientMap : public Map, public scene::ISceneNode

// fm:
v3pos_t m_camera_position_node;
using drawlist_map = std::map<v3pos_t, MapBlockP, MapBlockComparer>;
using drawlist_map = std::map<v3bpos_t, MapBlockP, MapBlockComparer>;
drawlist_map m_drawlist_0, m_drawlist_1;
std::atomic<drawlist_map *> m_drawlist {&m_drawlist_0};
std::atomic_bool m_drawlist_current = 0;
Expand Down
26 changes: 13 additions & 13 deletions src/client/fm_farmesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ along with Freeminer. If not, see <http://www.gnu.org/licenses/>.
#include "util/directiontables.h"
#include "util/numeric.h"
#include "util/timetaker.h"

const v3opos_t g_6dirso[6] = {
// +right, +top, +back
v3opos_t(0, 0, 1), // back
Expand All @@ -45,27 +46,27 @@ const v3opos_t g_6dirso[6] = {
};

FarContainer::FarContainer(){};

const MapNode &FarContainer::getNodeRefUnsafe(const v3pos_t &p)
{
const auto &v = m_mg->visible_content(p);
if (v.getContent())
return v;
return m_mg->visible_transparent;
};

MapNode FarContainer::getNodeNoExNoEmerge(const v3pos_t &p)
{
return getNodeRefUnsafe(p);
};

MapNode FarContainer::getNodeNoEx(const v3pos_t &p)
{
return getNodeRefUnsafe(p);
};

void FarMesh::makeFarBlock(const v3bpos_t &blockpos)
void FarMesh::makeFarBlock(const v3bpos_t &blockpos, size_t step)
{
const auto step = getFarStep(m_client->getEnv().getClientMap().getControl(),
getNodeBlockPos(m_camera_pos_aligned), blockpos);

const auto blockpos_actual =
getFarActual(blockpos, getNodeBlockPos(m_camera_pos_aligned), step,
m_client->getEnv().getClientMap().getControl());
Expand Down Expand Up @@ -93,8 +94,9 @@ void FarMesh::makeFarBlock(const v3bpos_t &blockpos)

void FarMesh::makeFarBlock7(const v3bpos_t &blockpos, size_t step)
{
const auto step_width = pow(2, step);
for (const auto &dir : g_7dirs) {
makeFarBlock(blockpos + dir * step);
makeFarBlock(blockpos + dir * step_width, step);
}
}

Expand Down Expand Up @@ -232,8 +234,8 @@ int FarMesh::go_direction(const size_t dir_n)
const auto block_step =
getFarStep(draw_control, m_camera_pos_aligned / MAP_BLOCKSIZE,
floatToInt(pos_last, BS) / MAP_BLOCKSIZE);
const auto step_width =
MAP_BLOCKSIZE * pow(2, block_step - block_step_reduce);
const auto block_step_pow = pow(2, block_step - block_step_reduce);
const auto step_width = MAP_BLOCKSIZE * block_step_pow;
ray_cache.finished += step_width;
const unsigned int depth = ray_cache.finished;

Expand All @@ -246,12 +248,10 @@ int FarMesh::go_direction(const size_t dir_n)
pos_last = pos;

#if !USE_POS32
const auto block_step_real =
getFarStep(draw_control, m_camera_pos_aligned / MAP_BLOCKSIZE,
floatToInt(pos_last, BS) / MAP_BLOCKSIZE);

const auto step_width_real =
MAP_BLOCKSIZE *
pow(2, block_step_real + log(draw_control.cell_size) / log(2));
pow(2, block_step + log(draw_control.cell_size) / log(2));
#else
const auto step_width_real = step_width;
#endif
Expand Down Expand Up @@ -291,10 +291,10 @@ int FarMesh::go_direction(const size_t dir_n)
TimeTaker timer_step("makeFarBlock");
g_profiler->add("Client makeFarBlock", 1);
#if FARMESH_FAST
makeFarBlock(blockpos);
makeFarBlock(blockpos, block_step);
#else
// less holes, more unused meshes:
makeFarBlock7(blockpos, pow(2, block_step));
makeFarBlock7(blockpos, block_step);
#endif
break;
}
Expand Down
5 changes: 3 additions & 2 deletions src/client/fm_farmesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ along with Freeminer. If not, see <http://www.gnu.org/licenses/>.

#pragma once

#include <atomic>
#include "client/camera.h"
#include "fm_nodecontainer.h"
#include "irr_v3d.h"
Expand Down Expand Up @@ -58,7 +59,7 @@ class FarMesh
v3pos_t m_camera_offset,
//float brightness,
int render_range, float speed);
void makeFarBlock(const v3bpos_t &blockpos);
void makeFarBlock(const v3bpos_t &blockpos, size_t step);
void makeFarBlock7(const v3bpos_t &blockpos, size_t step);
//void makeFarBlocks(const v3bpos_t &blockpos);

Expand Down Expand Up @@ -110,7 +111,7 @@ class FarMesh
int processed = -1;
};
std::array<plane_cache, 6> plane_processed;
unsigned int last_distance_max = 0;
std::atomic_uint last_distance_max = 0;
int go_direction(const size_t dir_n);
std::array<async_step_runner, 6> async;
int timestamp_complete = 0;
Expand Down
8 changes: 4 additions & 4 deletions src/client/hud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -912,14 +912,14 @@ void Hud::drawBlockBounds()
if (m_block_bounds_mode == BLOCK_BOUNDS_FAR) {
v3f offset = intToFloat(client->getCamera()->getOffset(), BS);

s8 radius = m_block_bounds_mode == BLOCK_BOUNDS_NEAR ? 2 : 0;
//s8 radius = m_block_bounds_mode == BLOCK_BOUNDS_NEAR ? 2 : 0;

v3f halfNode = v3f(BS, BS, BS) / 2.0f;

auto lock = client->getEnv().getClientMap().m_far_blocks.try_lock_shared_rec();
auto & far_blocks = client->getEnv().getClientMap().m_far_blocks;
auto lock = far_blocks.try_lock_shared_rec();
if (lock->owns_lock()) {
for (const auto &[blockPos, block] :
client->getEnv().getClientMap().m_far_blocks) {
far_blocks) {
if (block->getTimestamp() <
client->getEnv().getClientMap().m_far_blocks_use_timestamp)
continue;
Expand Down
2 changes: 1 addition & 1 deletion src/clientiface.h
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ class RemoteClient
No MapBlock* is stored here because the blocks can get deleted.
*/
unsigned int m_nearest_unsent_reset_want = 0;
concurrent_shared_unordered_map<v3pos_t, unsigned int, v3posHash, v3posEqual> m_blocks_sent;
concurrent_shared_unordered_map<v3pos_t, double, v3posHash, v3posEqual> m_blocks_sent;

//std::unordered_set<v3s16> m_blocks_sent;

Expand Down
1 change: 1 addition & 0 deletions src/cmake_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#cmakedefine01 USE_IPV4_DEFAULT
#cmakedefine01 USE_MANDELBULBER
#cmakedefine01 USE_MULTI
#cmakedefine01 USE_OSMIUM
#cmakedefine01 USE_SCTP
#cmakedefine01 USE_SQLITE3
#cmakedefine01 USE_TIFF
Expand Down
Loading

0 comments on commit 997e088

Please sign in to comment.