From f9962b0db5072870864a1f758687106139f740dc Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Tue, 25 Feb 2025 00:23:11 +0000 Subject: Improve Terrain::generateMeshes performance Creates mesh per surface based on a single buffer of all vertices and a collection of per surfuce indices. Makes ColourBias a uniform instead of a vertex attribute. --- game/terrain.h | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'game/terrain.h') diff --git a/game/terrain.h b/game/terrain.h index f0f9621..095b4ef 100644 --- a/game/terrain.h +++ b/game/terrain.h @@ -1,11 +1,9 @@ #pragma once #include "chronology.h" -#include "collection.h" #include "config/types.h" #include "game/worldobject.h" #include "geoData.h" -#include "gfx/models/mesh.h" #include "gfx/models/texture.h" #include "gfx/renderable.h" @@ -26,14 +24,20 @@ public: struct Vertex { GlobalPosition3D pos; Normal3D normal; - RGB colourBias; }; + void generateMeshes(); + private: void afterChange() override; - void generateMeshes(); - Collection, false> meshes; + struct SurfaceArrayBuffer { + glVertexArray vertexArray; + glBuffer indicesBuffer; + GLsizei count; + }; + + glBuffer verticesBuffer; + std::multimap meshes; Texture::Ptr grass = std::make_shared("grass.png"); - size_t geoGeneration {}; }; -- cgit v1.2.3