mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-01 17:38:41 +00:00
Split CVertexBuffer from CMeshBuffer
This commit is contained in:
parent
538b8b9b34
commit
5d6e15bc49
10 changed files with 246 additions and 78 deletions
|
@ -178,13 +178,14 @@ void Clouds::updateMesh()
|
|||
|
||||
|
||||
auto *mb = m_meshbuffer.get();
|
||||
auto &vertices = mb->Vertices->Data;
|
||||
{
|
||||
const u32 vertex_count = num_faces_to_draw * 16 * m_cloud_radius_i * m_cloud_radius_i;
|
||||
const u32 quad_count = vertex_count / 4;
|
||||
const u32 index_count = quad_count * 6;
|
||||
|
||||
// reserve memory
|
||||
mb->Vertices.reserve(vertex_count);
|
||||
vertices.reserve(vertex_count);
|
||||
mb->Indices.reserve(index_count);
|
||||
}
|
||||
|
||||
|
@ -192,7 +193,7 @@ void Clouds::updateMesh()
|
|||
#define INAREA(x, z, radius) \
|
||||
((x) >= -(radius) && (x) < (radius) && (z) >= -(radius) && (z) < (radius))
|
||||
|
||||
mb->Vertices.clear();
|
||||
vertices.clear();
|
||||
for (s16 zi0= -m_cloud_radius_i; zi0 < m_cloud_radius_i; zi0++)
|
||||
for (s16 xi0= -m_cloud_radius_i; xi0 < m_cloud_radius_i; xi0++)
|
||||
{
|
||||
|
@ -312,7 +313,7 @@ void Clouds::updateMesh()
|
|||
|
||||
for (video::S3DVertex &vertex : v) {
|
||||
vertex.Pos += pos;
|
||||
mb->Vertices.push_back(vertex);
|
||||
vertices.push_back(vertex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -134,16 +134,17 @@ Hud::Hud(Client *client, LocalPlayer *player,
|
|||
|
||||
// Prepare mesh for compass drawing
|
||||
auto &b = m_rotation_mesh_buffer;
|
||||
b.Vertices.resize(4);
|
||||
auto &vertices = b.Vertices->Data;
|
||||
vertices.resize(4);
|
||||
b.Indices.resize(6);
|
||||
|
||||
video::SColor white(255, 255, 255, 255);
|
||||
v3f normal(0.f, 0.f, 1.f);
|
||||
|
||||
b.Vertices[0] = video::S3DVertex(v3f(-1.f, -1.f, 0.f), normal, white, v2f(0.f, 1.f));
|
||||
b.Vertices[1] = video::S3DVertex(v3f(-1.f, 1.f, 0.f), normal, white, v2f(0.f, 0.f));
|
||||
b.Vertices[2] = video::S3DVertex(v3f( 1.f, 1.f, 0.f), normal, white, v2f(1.f, 0.f));
|
||||
b.Vertices[3] = video::S3DVertex(v3f( 1.f, -1.f, 0.f), normal, white, v2f(1.f, 1.f));
|
||||
vertices[0] = video::S3DVertex(v3f(-1.f, -1.f, 0.f), normal, white, v2f(0.f, 1.f));
|
||||
vertices[1] = video::S3DVertex(v3f(-1.f, 1.f, 0.f), normal, white, v2f(0.f, 0.f));
|
||||
vertices[2] = video::S3DVertex(v3f( 1.f, 1.f, 0.f), normal, white, v2f(1.f, 0.f));
|
||||
vertices[3] = video::S3DVertex(v3f( 1.f, -1.f, 0.f), normal, white, v2f(1.f, 1.f));
|
||||
|
||||
b.Indices[0] = 0;
|
||||
b.Indices[1] = 1;
|
||||
|
|
|
@ -555,14 +555,15 @@ v3f Minimap::getYawVec()
|
|||
scene::SMeshBuffer *Minimap::getMinimapMeshBuffer()
|
||||
{
|
||||
scene::SMeshBuffer *buf = new scene::SMeshBuffer();
|
||||
buf->Vertices.resize(4);
|
||||
auto &vertices = buf->Vertices->Data;
|
||||
vertices.resize(4);
|
||||
buf->Indices.resize(6);
|
||||
static const video::SColor c(255, 255, 255, 255);
|
||||
|
||||
buf->Vertices[0] = video::S3DVertex(-1, -1, 0, 0, 0, 1, c, 0, 1);
|
||||
buf->Vertices[1] = video::S3DVertex(-1, 1, 0, 0, 0, 1, c, 0, 0);
|
||||
buf->Vertices[2] = video::S3DVertex( 1, 1, 0, 0, 0, 1, c, 1, 0);
|
||||
buf->Vertices[3] = video::S3DVertex( 1, -1, 0, 0, 0, 1, c, 1, 1);
|
||||
vertices[0] = video::S3DVertex(-1, -1, 0, 0, 0, 1, c, 0, 1);
|
||||
vertices[1] = video::S3DVertex(-1, 1, 0, 0, 0, 1, c, 0, 0);
|
||||
vertices[2] = video::S3DVertex( 1, 1, 0, 0, 0, 1, c, 1, 0);
|
||||
vertices[3] = video::S3DVertex( 1, -1, 0, 0, 0, 1, c, 1, 1);
|
||||
|
||||
buf->Indices[0] = 0;
|
||||
buf->Indices[1] = 1;
|
||||
|
|
|
@ -830,7 +830,8 @@ void Sky::updateStars()
|
|||
warningstream << "Requested " << m_star_params.count << " stars but " << 0x4000 << " is the max\n";
|
||||
m_star_params.count = 0x4000;
|
||||
}
|
||||
m_stars->Vertices.reserve(4 * m_star_params.count);
|
||||
auto &vertices = m_stars->Vertices->Data;
|
||||
vertices.reserve(4 * m_star_params.count);
|
||||
m_stars->Indices.reserve(6 * m_star_params.count);
|
||||
|
||||
video::SColor fallback_color = m_star_params.starcolor; // used on GLES 2 “without shaders”
|
||||
|
@ -852,10 +853,10 @@ void Sky::updateStars()
|
|||
a.rotateVect(p1);
|
||||
a.rotateVect(p2);
|
||||
a.rotateVect(p3);
|
||||
m_stars->Vertices.push_back(video::S3DVertex(p, {}, fallback_color, {}));
|
||||
m_stars->Vertices.push_back(video::S3DVertex(p1, {}, fallback_color, {}));
|
||||
m_stars->Vertices.push_back(video::S3DVertex(p2, {}, fallback_color, {}));
|
||||
m_stars->Vertices.push_back(video::S3DVertex(p3, {}, fallback_color, {}));
|
||||
vertices.push_back(video::S3DVertex(p, {}, fallback_color, {}));
|
||||
vertices.push_back(video::S3DVertex(p1, {}, fallback_color, {}));
|
||||
vertices.push_back(video::S3DVertex(p2, {}, fallback_color, {}));
|
||||
vertices.push_back(video::S3DVertex(p3, {}, fallback_color, {}));
|
||||
}
|
||||
for (u16 i = 0; i < m_star_params.count; i++) {
|
||||
m_stars->Indices.push_back(i * 4 + 0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue