Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/wip5.7.0' into mapgen_earth
Browse files Browse the repository at this point in the history
  • Loading branch information
proller committed Nov 6, 2023
2 parents f962134 + 09b8c75 commit c1220c1
Show file tree
Hide file tree
Showing 54 changed files with 1,167 additions and 504 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ Core: fast reliable network protocol, fast multi-threaded server, utf8 chat, bui

Changelog
======
### 5.7.0.0 (?)
* Tree growth
* Weather tuned


### 5.6.1.0 (?)
* auth_kv removed, use instead in world.mt:
auth_backend = leveldbfm
Expand Down
11 changes: 9 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,15 @@ endif()


MESSAGE(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
if (NOT NO_LTO AND (CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")) # AND NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten"
# include(CheckIPOSupported)

if(NOT NO_LTO AND NOT DEVELOPMENT_BUILD AND(CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo"))
option(USE_LTO "Use LTO" ON)
else()
option(USE_LTO "Use LTO" OFF)
endif()

if (USE_LTO)
# include(CheckIPOSupported)
# check_ipo_supported(RESULT supported OUTPUT error)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
message(STATUS "Using lto")
Expand Down
21 changes: 17 additions & 4 deletions build_tools/debian_ogles.sh → build_tools/build.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
#!/usr/bin/env bash
# script for fast installing on raspberry pi, odroid and other arm boards with debian

set -e
set -x

# There's no package available, you have to compile it from source.
# you can place this text to freeminer.sh file and run it

# or
# curl https://raw.githubusercontent.com/freeminer/freeminer/master/build_tools/debian_ogles.sh | sh
# curl https://raw.githubusercontent.com/freeminer/freeminer/master/build_tools/build.sh | sh

#1. To compile need to install packages:
sudo apt install -y git subversion build-essential cmake ninja-build ccache libbz2-dev libzstd-dev "libpng12-dev|libpng-dev" libjpeg-dev libfreetype6-dev libxxf86vm-dev libsqlite3-dev libvorbis-dev libopenal-dev libcurl4-openssl-dev libluajit-5.1-dev libleveldb-dev libsnappy-dev libgettextpo0 libmsgpack-dev libgl1-mesa-dev "libgles1-mesa-dev|libgles2-mesa-dev" libgles2-mesa-dev libboost-system-dev libunwind-dev libc++-dev libc++abi-dev
DIST=${DIST=`lsb_release --short --id`}
DIST=${DIST=`cat /etc/issue /etc/issue.net | head -n1 | cut -d " " -f1`}
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 libluajit-5.1-dev libleveldb-dev libsnappy-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
sudo apt install -y $PACKAGE ||:
done
else
echo Todo
fi



if [ -n "" ]; then
#2. get and compile irrlicht with oppengl es support:
Expand All @@ -29,10 +42,10 @@ fi
[ -s ../src/CMakeLists.txt ] && mkdir -p ../build && cd ../build

#update if second+ run
git pull
git pull --rebase

#compile
cmake .. -GNinja -DENABLE_GLES=1 # -DIRRLICHT_INCLUDE_DIR=../irrlicht/include -DIRRLICHT_LIBRARY=../irrlicht/lib/Linux/libIrrlicht.a
cmake .. -GNinja -DENABLE_GLES=1 -DCMAKE_C_COMPILER=`which clang` -DCMAKE_CXX_COMPILER=`which clang++` # -DIRRLICHT_INCLUDE_DIR=../irrlicht/include -DIRRLICHT_LIBRARY=../irrlicht/lib/Linux/libIrrlicht.a
nice cmake --build .

# link dir with /Shaders/
Expand Down
2 changes: 1 addition & 1 deletion builtin/mainmenu/tab_online.lua
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ local function main_button_handler(tabview, fields, name, tabdata)
if gamedata.address and gamedata.port then
core.settings:set("address", gamedata.address)
core.settings:set("remote_port", gamedata.port)
core.settings:set("remote_proto", gamedata.proto)
core.settings:set("remote_proto", gamedata.proto or "mt")
core.start()
end
return true
Expand Down
2 changes: 1 addition & 1 deletion games/default
Submodule default updated 52 files
+13 −7 .gitmodules
+4 −0 .luacheckrc
+21 −0 game_api.txt
+22 −17 mods/beds/functions.lua
+2 −2 mods/bucket/init.lua
+1 −0 mods/creative/locale/creative.de.tr
+1 −0 mods/creative/locale/creative.eo.tr
+2 −1 mods/creative/locale/creative.es.tr
+1 −0 mods/creative/locale/creative.fr.tr
+1 −0 mods/creative/locale/creative.id.tr
+1 −0 mods/creative/locale/creative.it.tr
+1 −0 mods/creative/locale/creative.ja.tr
+1 −0 mods/creative/locale/creative.jbo.tr
+1 −0 mods/creative/locale/creative.ms.tr
+1 −0 mods/creative/locale/creative.pl.tr
+1 −0 mods/creative/locale/creative.pt_BR.tr
+1 −0 mods/creative/locale/creative.ru.tr
+1 −0 mods/creative/locale/creative.sk.tr
+1 −0 mods/creative/locale/creative.sv.tr
+1 −0 mods/creative/locale/creative.uk.tr
+1 −0 mods/creative/locale/creative.zh_CN.tr
+1 −0 mods/creative/locale/creative.zh_TW.tr
+1 −0 mods/creative/locale/template.txt
+12 −5 mods/default/chests.lua
+1 −1 mods/default/init.lua
+2 −1 mods/default/license.txt
+1 −1 mods/default/locale/default.de.tr
+102 −18 mods/default/nodes.lua
+ mods/default/textures/default_river_water.png
+ mods/default/textures/default_river_water_flowing_animated.png
+ mods/default/textures/default_river_water_source_animated.png
+ mods/default/textures/default_water.png
+ mods/default/textures/default_water_flowing_animated.png
+ mods/default/textures/default_water_source_animated.png
+83 −85 mods/default/trees.lua
+17 −4 mods/doors/init.lua
+0 −1 mods/fire/locale/fire.fr.tr
+0 −1 mods/fire/locale/fire.it.tr
+0 −1 mods/fire/locale/fire.ms.tr
+0 −1 mods/fire/locale/fire.ru.tr
+1 −1 mods/mob_horse
+1 −1 mods/mobs_animal
+1 −1 mods/mobs_monster
+1 −1 mods/mobs_npc
+1 −1 mods/mobs_redo
+1 −0 mods/mobs_sky
+1 −0 mods/mobs_water
+1 −1 mods/pbj_pup
+1 −1 mods/protector
+36 −113 mods/stairs/init.lua
+18 −2 mods/weather/erosion.lua
+6 −4 mods/weather/weather.lua
2 changes: 1 addition & 1 deletion lib/irrlichtmt
1 change: 1 addition & 0 deletions src/client/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ Client::Client(

m_cache_save_interval = g_settings->getU16("server_map_save_interval");
m_mesh_grid = { g_settings->getU16("client_mesh_chunk") };
control.cell_size = m_mesh_grid.cell_size;
}

void Client::migrateModStorage()
Expand Down
74 changes: 63 additions & 11 deletions src/client/clientmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,6 @@ void ClientMap::updateDrawList(float dtime, unsigned int max_cycle_ms)
u32 blocks_in_range_with_mesh = 0;



{
for (auto & [block_coord, block] : m_blocks) {
//auto block = getBlockNoCreateNoEx(block_coord);
int mesh_step = getFarmeshStep(m_control, getNodeBlockPos(cam_pos_nodes), block_coord);
Expand Down Expand Up @@ -362,6 +360,7 @@ void ClientMap::updateDrawList(float dtime, unsigned int max_cycle_ms)
for (MapBlock *block : sectorblocks) {
MapBlockMesh *mesh = block->mesh;
*/
{

// Calculate the coordinates for range and frustum culling
v3f mesh_sphere_center;
Expand Down Expand Up @@ -740,6 +739,8 @@ void ClientMap::updateDrawListFm(float dtime, unsigned int max_cycle_ms)
if (!max_cycle_ms)
max_cycle_ms = 300/getControl().fps_wanted;

auto is_frustum_culled = m_client->getCamera()->getFrustumCuller();

//v3f camera_position = m_camera_position;
//f32 camera_fov = m_camera_fov;

Expand Down Expand Up @@ -827,7 +828,16 @@ void ClientMap::updateDrawListFm(float dtime, unsigned int max_cycle_ms)

const int maxq = 1000;

bool occlusion_culling_enabled = true;

// Number of blocks frustum culled
u32 blocks_frustum_culled = 0;

MeshGrid mesh_grid = m_client->getMeshGrid();
// No occlusion culling when free_move is on and camera is inside ground
// No occlusion culling for chunk sizes of 4 and above
// because the current occlusion culling test is highly inefficient at these sizes
bool occlusion_culling_enabled = mesh_grid.cell_size < 4;

if (m_control.allow_noclip) {
MapNode n = getNode(cam_pos_nodes);
if (n.getContent() == CONTENT_IGNORE || m_nodedef->get(n).solidness == 2)
Expand Down Expand Up @@ -860,7 +870,7 @@ void ClientMap::updateDrawListFm(float dtime, unsigned int max_cycle_ms)
*/

auto mesh = block->getMesh(mesh_step);

{
blocks_in_range++;

const int smesh_size = block->getMeshSize(mesh_step);
Expand All @@ -877,7 +887,7 @@ void ClientMap::updateDrawListFm(float dtime, unsigned int max_cycle_ms)
continue;
}
if(mesh_step == mesh->step && block->getTimestamp() <= mesh->timestamp && !smesh_size) {
blocks_in_range_without_mesh++;
++blocks_in_range_without_mesh;
continue;
}
}
Expand Down Expand Up @@ -929,13 +939,54 @@ void ClientMap::updateDrawListFm(float dtime, unsigned int max_cycle_ms)
continue;
}
*/
// Occlusion culling
if ((!m_control.range_all && d > m_control.wanted_range * BS) ||
(occlusion_culling_enabled && isBlockOccluded(block, cam_pos_nodes))) {
blocks_occlusion_culled++;
continue;
}

// Calculate the coordinates for range and frustum culling
v3opos_t mesh_sphere_center;
f32 mesh_sphere_radius;

v3pos_t block_pos_nodes = block->getPosRelative();

if (mesh) {
mesh_sphere_center = intToFloat(block_pos_nodes, BS)
+ mesh->getBoundingSphereCenter();
mesh_sphere_radius = mesh->getBoundingRadius();
} else {
mesh_sphere_center = intToFloat(block_pos_nodes, BS)
+ v3opos_t((MAP_BLOCKSIZE * 0.5f - 0.5f) * BS);
mesh_sphere_radius = 0.0f;
}

// First, perform a simple distance check.
if (!m_control.range_all &&
mesh_sphere_center.getDistanceFrom(m_camera_position) >
m_control.wanted_range * BS + mesh_sphere_radius)
continue; // Out of range, skip.

// Keep the block alive as long as it is in range.
block->resetUsageTimer();
blocks_in_range_with_mesh++;

/*
// Frustum culling
// Only do coarse culling here, to account for fast camera movement.
// This is needed because this function is not called every frame.
float frustum_cull_extra_radius = 300.0f;
if (is_frustum_culled(mesh_sphere_center,
mesh_sphere_radius + frustum_cull_extra_radius)) {
blocks_frustum_culled++;
continue;
}
*/

// Raytraced occlusion culling - send rays from the camera to the block's corners
if (!m_control.range_all && occlusion_culling_enabled && m_enable_raytraced_culling &&
mesh &&
isMeshOccluded(block, mesh_grid.cell_size, cam_pos_nodes)) {
blocks_occlusion_culled++;
continue;
}


// This block is in range. Reset usage timer.
Expand Down Expand Up @@ -979,6 +1030,7 @@ void ClientMap::updateDrawListFm(float dtime, unsigned int max_cycle_ms)
if (porting::getTimeMs() > end_ms) {
break;
}
}

}
m_drawlist_last = draw_nearest.size();
Expand Down
3 changes: 2 additions & 1 deletion src/client/clientmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ struct MapDrawControl
// freeminer:
float farmesh = 0;
int farmesh_step = 1;
int cell_size = 1;

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

Expand Down
2 changes: 1 addition & 1 deletion src/client/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3112,7 +3112,7 @@ static void pauseNodeAnimation(PausedNodesList &paused, scene::ISceneNode *node)
float speed = animated_node->getAnimationSpeed();
if (!speed)
return;
paused.push_back({grab(animated_node), speed});
paused.emplace_back(grab(animated_node), speed);
animated_node->setAnimationSpeed(0.0f);
}

Expand Down
37 changes: 23 additions & 14 deletions src/client/mapblock_mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,27 @@ along with Freeminer. If not, see <http://www.gnu.org/licenses/>.
#include <array>
#include <algorithm>

int getFarmeshStep(MapDrawControl& draw_control, const v3pos_t & playerblockpos, const v3pos_t & blockpos) {


return 1; // TODO FIX MESHMAKE


int getFarmeshStep(MapDrawControl &draw_control, const v3bpos_t &playerblockpos,
const v3bpos_t &blockpos)
{
int range = radius_box(playerblockpos, blockpos);
if (draw_control.farmesh) {
const pos_t nearest = 256/MAP_BLOCKSIZE;
if (range >= std::min<pos_t>(nearest*8, draw_control.farmesh+draw_control.farmesh_step*4)) return 16;
else if (range >= std::min<pos_t>(nearest*4, draw_control.farmesh+draw_control.farmesh_step*2)) return 8;
else if (range >= std::min<pos_t>(nearest*2, draw_control.farmesh+draw_control.farmesh_step)) return 4;
else if (range >= std::min<pos_t>(nearest, draw_control.farmesh)) return 2;

const pos_t nearest = std::max(draw_control.cell_size * 2, 256 / MAP_BLOCKSIZE);
// DUMP(draw_control.farmesh, range, nearest, draw_control.cell_size, draw_control.farmesh + draw_control.farmesh_step * 4, draw_control.farmesh + draw_control.farmesh_step * 2, draw_control.farmesh + draw_control.farmesh_step, draw_control.farmesh);
const auto farmesh_cells = std::max<int>(draw_control.cell_size * 2,
draw_control.farmesh / draw_control.cell_size);
if (range >= std::min<pos_t>(
nearest * 8, farmesh_cells + draw_control.farmesh_step * 4))
return 16;
else if (range >= std::min<pos_t>(nearest * 4,
farmesh_cells + draw_control.farmesh_step * 2))
return 8;
else if (range >=
std::min<pos_t>(nearest * 2, farmesh_cells + draw_control.farmesh_step))
return 4;
else if (range >= std::min<pos_t>(nearest, farmesh_cells))
return 2;
}
return 1;
};
Expand All @@ -63,6 +71,7 @@ MeshMakeData::MeshMakeData(Client *client, bool use_shaders, int step):
m_client(client),
m_use_shaders(use_shaders)

, side_length_data(MAP_BLOCKSIZE * m_mesh_grid.cell_size)
, step{step}
//, map{map_}, draw_control{draw_control_}
/*#if defined(MESH_ZEROCOPY)
Expand Down Expand Up @@ -149,7 +158,7 @@ void MeshMakeData::fillBlockDataBegin(const v3s16 &blockpos)

m_vmanip.clear();
VoxelArea voxel_area(blockpos_nodes - v3s16(1,1,1) * MAP_BLOCKSIZE,
blockpos_nodes + v3s16(1,1,1) * (side_length + MAP_BLOCKSIZE /* extra layer of blocks around the mesh */) - v3s16(1,1,1));
blockpos_nodes + v3s16(1,1,1) * (side_length_data + MAP_BLOCKSIZE /* extra layer of blocks around the mesh */) - v3s16(1,1,1));
m_vmanip.addArea(voxel_area);
}

Expand Down Expand Up @@ -1306,10 +1315,10 @@ void PartialMeshBuffer::afterDraw() const

MapBlockMesh::MapBlockMesh(MeshMakeData *data, v3s16 camera_offset):
step(data->step),
no_draw(data->no_draw),
//no_draw(data->no_draw),
m_tsrc(data->m_client->getTextureSource()),
m_shdrsrc(data->m_client->getShaderSource()),
m_bounding_sphere_center((data->side_length * 0.5f - 0.5f) * BS),
m_bounding_sphere_center((data->side_length_data * 0.5f - 0.5f) * BS),
m_animation_force_timer(0), // force initial animation
m_last_crack(-1),
m_last_daynight_ratio((u32) -1)
Expand Down
5 changes: 3 additions & 2 deletions src/client/mapblock_mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class IShaderSource;
Mesh making stuff
*/

int getFarmeshStep(MapDrawControl& draw_control, const v3pos_t & playerblockpos, const v3pos_t & block_pos);
int getFarmeshStep(MapDrawControl& draw_control, const v3bpos_t & playerblockpos, const v3bpos_t & block_pos);

class MapBlock;
struct MinimapMapblock;
Expand All @@ -66,6 +66,7 @@ struct MeshMakeData
bool m_use_shaders;

// fm:
u16 side_length_data;
int step = 1;
int range = 1;
bool no_draw = false;
Expand Down Expand Up @@ -260,7 +261,7 @@ class MapBlockMesh
}

int step = 1;
bool no_draw = 0;
//bool no_draw = 0;
unsigned int timestamp = 0;
u32 m_usage_timer = 0;
// ===
Expand Down
2 changes: 1 addition & 1 deletion src/client/mesh_generator_thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ void MeshUpdateWorkerThread::doUpdate()
sleep_ms(m_generation_interval);
ScopeProfiler sp(g_profiler, "Client: Mesh making (sum)");

MapBlock::mesh_type mesh_new {new MapBlockMesh(q->data, *m_camera_offset)};
MapBlock::mesh_type mesh_new = std::make_shared<MapBlockMesh>(q->data, *m_camera_offset);
MeshUpdateResult r;
r.p = q->p;
r.mesh = mesh_new;
Expand Down
3 changes: 3 additions & 0 deletions src/client/shadows/dynamicshadowsrender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ ShadowRenderer::~ShadowRenderer()
delete m_shadow_mix_cb;
m_shadow_node_array.clear();
m_light_list.clear();

if (m_screen_quad)
delete m_screen_quad;
}

void ShadowRenderer::disable()
Expand Down
3 changes: 1 addition & 2 deletions src/content_abm.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/*
content_abm.cpp
Copyright (C) 2013 celeron55, Perttu Ahola <[email protected]>
Copyright (C) 2013-2023 proller <[email protected]>
*/

/*
Expand Down
Loading

0 comments on commit c1220c1

Please sign in to comment.