1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-31 18:31:04 +00:00

Client map: do frustum culling via planes (#12710)

This commit is contained in:
DS 2022-09-18 15:28:53 +02:00 committed by GitHub
parent a428a0cf37
commit c9ed059d91
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 113 additions and 42 deletions

View file

@ -45,9 +45,12 @@ void MeshCollector::append(const TileLayer &layer, const video::S3DVertex *verti
scale = 1.0f / layer.scale;
u32 vertex_count = p.vertices.size();
for (u32 i = 0; i < numVertices; i++)
for (u32 i = 0; i < numVertices; i++) {
p.vertices.emplace_back(vertices[i].Pos, 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());
}
for (u32 i = 0; i < numIndices; i++)
p.indices.push_back(indices[i] + vertex_count);
@ -81,8 +84,11 @@ void MeshCollector::append(const TileLayer &layer, const video::S3DVertex *verti
video::SColor color = c;
if (!light_source)
applyFacesShading(color, vertices[i].Normal);
p.vertices.emplace_back(vertices[i].Pos + pos, vertices[i].Normal, color,
auto vpos = vertices[i].Pos + pos;
p.vertices.emplace_back(vpos, vertices[i].Normal, color,
scale * vertices[i].TCoords);
m_bounding_radius_sq = std::max(m_bounding_radius_sq,
(vpos - m_center_pos).getLengthSQ());
}
for (u32 i = 0; i < numIndices; i++)

View file

@ -37,6 +37,12 @@ struct PreMeshBuffer
struct MeshCollector
{
std::array<std::vector<PreMeshBuffer>, MAX_TILE_LAYERS> prebuffers;
// bounding sphere radius and center
f32 m_bounding_radius_sq = 0.0f;
v3f m_center_pos;
// center_pos: pos to use for bounding-sphere, in BS-space
MeshCollector(const v3f center_pos) : m_center_pos(center_pos) {}
// clang-format off
void append(const TileSpec &material,