From 9fcc0c1217fcd3acabaa11239631de10032fa126 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Thu, 22 Mar 2018 22:59:49 +0300 Subject: Update mesh collector and move it to a separate file (#6904) * Update MeshCollector * Simplify MeshCollector --- src/client/meshgen/collector.h | 65 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 src/client/meshgen/collector.h (limited to 'src/client/meshgen/collector.h') diff --git a/src/client/meshgen/collector.h b/src/client/meshgen/collector.h new file mode 100644 index 000000000..e4189088e --- /dev/null +++ b/src/client/meshgen/collector.h @@ -0,0 +1,65 @@ +/* +Minetest +Copyright (C) 2018 numzero, Lobachevskiy Vitaliy + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#pragma once +#include +#include +#include "irrlichttypes.h" +#include +#include "client/tile.h" + +struct PreMeshBuffer +{ + TileLayer layer; + std::vector indices; + std::vector vertices; + + PreMeshBuffer() = default; + explicit PreMeshBuffer(const TileLayer &layer) : layer(layer) {} +}; + +struct MeshCollector +{ + std::array, MAX_TILE_LAYERS> prebuffers; + + // clang-format off + void append(const TileSpec &material, + const video::S3DVertex *vertices, u32 numVertices, + const u16 *indices, u32 numIndices); + void append(const TileSpec &material, + const video::S3DVertex *vertices, u32 numVertices, + const u16 *indices, u32 numIndices, + v3f pos, video::SColor c, u8 light_source); + // clang-format on + +private: + // clang-format off + void append(const TileLayer &material, + const video::S3DVertex *vertices, u32 numVertices, + const u16 *indices, u32 numIndices, + u8 layernum, bool use_scale = false); + void append(const TileLayer &material, + const video::S3DVertex *vertices, u32 numVertices, + const u16 *indices, u32 numIndices, + v3f pos, video::SColor c, u8 light_source, + u8 layernum, bool use_scale = false); + // clang-format on + + PreMeshBuffer &findBuffer(const TileLayer &layer, u8 layernum, u32 numVertices); +}; -- cgit v1.2.3