diff options
author | Vitaliy <silverunicorn2011@yandex.ru> | 2018-03-22 22:59:49 +0300 |
---|---|---|
committer | Loïc Blot <nerzhul@users.noreply.github.com> | 2018-03-22 20:59:49 +0100 |
commit | 9fcc0c1217fcd3acabaa11239631de10032fa126 (patch) | |
tree | 7596bc17bd51f5b9d22ad918743d90fcfa0e2278 /src/client/meshgen/collector.h | |
parent | 8986a9e6053bed0002726bc000ee394a928b7f51 (diff) | |
download | minetest-9fcc0c1217fcd3acabaa11239631de10032fa126.tar.gz minetest-9fcc0c1217fcd3acabaa11239631de10032fa126.tar.bz2 minetest-9fcc0c1217fcd3acabaa11239631de10032fa126.zip |
Update mesh collector and move it to a separate file (#6904)
* Update MeshCollector
* Simplify MeshCollector
Diffstat (limited to 'src/client/meshgen/collector.h')
-rw-r--r-- | src/client/meshgen/collector.h | 65 |
1 files changed, 65 insertions, 0 deletions
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 <numzer0@yandex.ru> + +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 <array> +#include <vector> +#include "irrlichttypes.h" +#include <S3DVertex.h> +#include "client/tile.h" + +struct PreMeshBuffer +{ + TileLayer layer; + std::vector<u16> indices; + std::vector<video::S3DVertex> vertices; + + PreMeshBuffer() = default; + explicit PreMeshBuffer(const TileLayer &layer) : layer(layer) {} +}; + +struct MeshCollector +{ + std::array<std::vector<PreMeshBuffer>, 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); +}; |