From f70cbc0dade14cf07cad774ffc8f5c903b1a5ea8 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Wed, 12 Mar 2025 02:59:12 +0000 Subject: Split Terrain::generateMeshes into smaller functions Also removes incorrect optimisation that a tile's AABB could be assumed from tile base position; in fact some faces cross the boundaries and the AABB needs to account for this. --- game/terrain.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'game/terrain.h') diff --git a/game/terrain.h b/game/terrain.h index eaec01d..1a63296 100644 --- a/game/terrain.h +++ b/game/terrain.h @@ -41,9 +41,16 @@ private: struct SurfaceKey { const Surface * surface; GlobalPosition2D basePosition; - bool operator<(const SurfaceKey &) const; + inline bool operator<(const SurfaceKey &) const; }; + using SurfaceIndices = std::map>; + void copyVerticesToBuffer() const; + [[nodiscard]] SurfaceIndices mapSurfaceFacesToIndices() const; + void copyIndicesToBuffers(const SurfaceIndices &); + void pruneOrphanMeshes(const SurfaceIndices &); + [[nodiscard]] inline GlobalPosition2D getTile(const FaceHandle &) const; + glBuffer verticesBuffer; std::map meshes; Texture::Ptr grass = std::make_shared("grass.png"); -- cgit v1.2.3