Minetest 5.9.0-dev
 
Loading...
Searching...
No Matches
collector.h
Go to the documentation of this file.
1/*
2Minetest
3Copyright (C) 2018 numzero, Lobachevskiy Vitaliy <numzer0@yandex.ru>
4
5This program is free software; you can redistribute it and/or modify
6it under the terms of the GNU Lesser General Public License as published by
7the Free Software Foundation; either version 2.1 of the License, or
8(at your option) any later version.
9
10This program is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU Lesser General Public License for more details.
14
15You should have received a copy of the GNU Lesser General Public License along
16with this program; if not, write to the Free Software Foundation, Inc.,
1751 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18*/
19
20#pragma once
21#include <array>
22#include <vector>
23#include "irrlichttypes.h"
24#include "irr_v3d.h"
25#include <S3DVertex.h>
26#include "client/tile.h"
27
29{
31 std::vector<u16> indices;
32 std::vector<video::S3DVertex> vertices;
33
34 PreMeshBuffer() = default;
35 explicit PreMeshBuffer(const TileLayer &layer) : layer(layer) {}
36};
37
39{
40 std::array<std::vector<PreMeshBuffer>, MAX_TILE_LAYERS> prebuffers;
41 // bounding sphere radius and center
45
46 // center_pos: pos to use for bounding-sphere, in BS-space
47 // offset: offset added to vertices
48 MeshCollector(const v3f center_pos, v3f offset = v3f()) : m_center_pos(center_pos), offset(offset) {}
49
50 void append(const TileSpec &material,
51 const video::S3DVertex *vertices, u32 numVertices,
52 const u16 *indices, u32 numIndices);
53 void append(const TileSpec &material,
54 const video::S3DVertex *vertices, u32 numVertices,
55 const u16 *indices, u32 numIndices,
56 v3f pos, video::SColor c, u8 light_source);
57
58private:
59 void append(const TileLayer &material,
60 const video::S3DVertex *vertices, u32 numVertices,
61 const u16 *indices, u32 numIndices,
62 u8 layernum, bool use_scale = false);
63 void append(const TileLayer &material,
64 const video::S3DVertex *vertices, u32 numVertices,
65 const u16 *indices, u32 numIndices,
66 v3f pos, video::SColor c, u8 light_source,
67 u8 layernum, bool use_scale = false);
68
69 PreMeshBuffer &findBuffer(const TileLayer &layer, u8 layernum, u32 numVertices);
70};
core::vector3df v3f
Definition: irr_v3d.h:26
Definition: collector.h:39
void append(const TileSpec &material, const video::S3DVertex *vertices, u32 numVertices, const u16 *indices, u32 numIndices)
Definition: collector.cpp:25
MeshCollector(const v3f center_pos, v3f offset=v3f())
Definition: collector.h:48
v3f offset
Definition: collector.h:44
v3f m_center_pos
Definition: collector.h:43
std::array< std::vector< PreMeshBuffer >, MAX_TILE_LAYERS > prebuffers
Definition: collector.h:40
PreMeshBuffer & findBuffer(const TileLayer &layer, u8 layernum, u32 numVertices)
Definition: collector.cpp:98
f32 m_bounding_radius_sq
Definition: collector.h:42
Definition: collector.h:29
std::vector< video::S3DVertex > vertices
Definition: collector.h:32
TileLayer layer
Definition: collector.h:30
PreMeshBuffer(const TileLayer &layer)
Definition: collector.h:35
std::vector< u16 > indices
Definition: collector.h:31
PreMeshBuffer()=default
Defines a layer of a tile.
Definition: tile.h:73
Definition: tile.h:159
#define MAX_TILE_LAYERS
Definition: tile.h:69