mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-01 17:38:41 +00:00
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>
This commit is contained in:
parent
cded6a3945
commit
69fc206109
14 changed files with 266 additions and 118 deletions
|
@ -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;
|
||||
|
@ -54,12 +56,6 @@ struct MeshMakeData
|
|||
void fillBlockDataBegin(const v3s16 &blockpos);
|
||||
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
|
||||
*/
|
||||
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue