aboutsummaryrefslogtreecommitdiff
path: root/src/client/meshgen
diff options
context:
space:
mode:
authorx2048 <codeforsmile@gmail.com>2023-01-31 17:30:59 +0100
committerGitHub <noreply@github.com>2023-01-31 17:30:59 +0100
commit69fc20610947610b7829f3bfad82e23ed705b764 (patch)
tree775cb27a4875a071fccddee87b80730e39ed9b14 /src/client/meshgen
parentcded6a3945206e51c35adbd063f1aec3a47e310f (diff)
downloadminetest-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/meshgen')
-rw-r--r--src/client/meshgen/collector.cpp4
-rw-r--r--src/client/meshgen/collector.h5
2 files changed, 6 insertions, 3 deletions
diff --git a/src/client/meshgen/collector.cpp b/src/client/meshgen/collector.cpp
index c5f4eb976..86c188c3f 100644
--- a/src/client/meshgen/collector.cpp
+++ b/src/client/meshgen/collector.cpp
@@ -46,7 +46,7 @@ void MeshCollector::append(const TileLayer &layer, const video::S3DVertex *verti
u32 vertex_count = p.vertices.size();
for (u32 i = 0; i < numVertices; i++) {
- p.vertices.emplace_back(vertices[i].Pos, vertices[i].Normal,
+ p.vertices.emplace_back(vertices[i].Pos + offset, vertices[i].Normal,
vertices[i].Color, scale * vertices[i].TCoords);
m_bounding_radius_sq = std::max(m_bounding_radius_sq,
(vertices[i].Pos - m_center_pos).getLengthSQ());
@@ -84,7 +84,7 @@ void MeshCollector::append(const TileLayer &layer, const video::S3DVertex *verti
video::SColor color = c;
if (!light_source)
applyFacesShading(color, vertices[i].Normal);
- auto vpos = vertices[i].Pos + pos;
+ auto vpos = vertices[i].Pos + pos + offset;
p.vertices.emplace_back(vpos, vertices[i].Normal, color,
scale * vertices[i].TCoords);
m_bounding_radius_sq = std::max(m_bounding_radius_sq,
diff --git a/src/client/meshgen/collector.h b/src/client/meshgen/collector.h
index c390c53e7..9b49ce72e 100644
--- a/src/client/meshgen/collector.h
+++ b/src/client/meshgen/collector.h
@@ -21,6 +21,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <array>
#include <vector>
#include "irrlichttypes.h"
+#include "irr_v3d.h"
#include <S3DVertex.h>
#include "client/tile.h"
@@ -40,9 +41,11 @@ struct MeshCollector
// bounding sphere radius and center
f32 m_bounding_radius_sq = 0.0f;
v3f m_center_pos;
+ v3f offset;
// center_pos: pos to use for bounding-sphere, in BS-space
- MeshCollector(const v3f center_pos) : m_center_pos(center_pos) {}
+ // offset: offset added to vertices
+ MeshCollector(const v3f center_pos, v3f offset = v3f()) : m_center_pos(center_pos), offset(offset) {}
// clang-format off
void append(const TileSpec &material,