diff options
| author | x2048 <codeforsmile@gmail.com> | 2023-01-31 17:30:59 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-01-31 17:30:59 +0100 |
| commit | 69fc20610947610b7829f3bfad82e23ed705b764 (patch) | |
| tree | 775cb27a4875a071fccddee87b80730e39ed9b14 /src/client/mapblock_mesh.h | |
| parent | cded6a3945206e51c35adbd063f1aec3a47e310f (diff) | |
| download | minetest-69fc20610947610b7829f3bfad82e23ed705b764.tar.xz | |
8x block meshes (#13133)
Reduce the number of drawcalls by generating a mesh per 8 blocks (2x2x2). Only blocks with even coordinates (lowest bit set to 0) will get a mesh.
Note: This also removes the old 'loops' algorithm for building the draw list, because it produces visual artifacts and cannot be made compatible with the approach of having a mesh for every 8th block without hurting performance.
Co-authored-by: Jude Melton-Houghton <jwmhjwmh@gmail.com>
Co-authored-by: Lars <larsh@apache.org>
Co-authored-by: sfan5 <sfan5@live.de>
Diffstat (limited to 'src/client/mapblock_mesh.h')
| -rw-r--r-- | src/client/mapblock_mesh.h | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/src/client/mapblock_mesh.h b/src/client/mapblock_mesh.h index 7f6185c3a..82e9a0f22 100644 --- a/src/client/mapblock_mesh.h +++ b/src/client/mapblock_mesh.h @@ -24,6 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "voxel.h" #include <array> #include <map> +#include <unordered_map> class Client; class IShaderSource; @@ -42,6 +43,7 @@ struct MeshMakeData v3s16 m_blockpos = v3s16(-1337,-1337,-1337); v3s16 m_crack_pos_relative = v3s16(-1337,-1337,-1337); bool m_smooth_lighting = false; + u16 side_length = MAP_BLOCKSIZE; Client *m_client; bool m_use_shaders; @@ -55,12 +57,6 @@ struct MeshMakeData void fillBlockData(const v3s16 &block_offset, MapNode *data); /* - Copy central data directly from block, and other data from - parent of block. - */ - void fill(MapBlock *block); - - /* Set the (node) position of a crack */ void setCrack(int crack_level, v3s16 crack_pos); @@ -108,7 +104,7 @@ class MapBlockBspTree public: MapBlockBspTree() {} - void buildTree(const std::vector<MeshTriangle> *triangles); + void buildTree(const std::vector<MeshTriangle> *triangles, u16 side_lingth); void traverse(v3f viewpoint, std::vector<s32> &output) const { @@ -203,11 +199,11 @@ public: return m_mesh[layer]; } - MinimapMapblock *moveMinimapMapblock() + std::vector<MinimapMapblock*> moveMinimapMapblocks() { - MinimapMapblock *p = m_minimap_mapblock; - m_minimap_mapblock = NULL; - return p; + std::vector<MinimapMapblock*> minimap_mapblocks; + minimap_mapblocks.swap(m_minimap_mapblocks); + return minimap_mapblocks; } bool isAnimationForced() const @@ -245,7 +241,7 @@ private: }; scene::IMesh *m_mesh[MAX_TILE_LAYERS]; - MinimapMapblock *m_minimap_mapblock; + std::vector<MinimapMapblock*> m_minimap_mapblocks; ITextureSource *m_tsrc; IShaderSource *m_shdrsrc; @@ -344,4 +340,4 @@ void getNodeTile(MapNode mn, const v3s16 &p, const v3s16 &dir, MeshMakeData *dat /// Return bitset of the sides of the mapblock that consist of solid nodes only /// Bits: /// 0 0 -Z +Z -X +X -Y +Y -u8 get_solid_sides(MeshMakeData *data); +std::unordered_map<v3s16, u8> get_solid_sides(MeshMakeData *data); |
