aboutsummaryrefslogtreecommitdiff
path: root/src/client/world/block.hh
blob: 9dfe303c17f2296bd3a6171ea20747dec71e8dd2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#ifndef CLIENT_WORLD_BLOCK_HH_
#define CLIENT_WORLD_BLOCK_HH_

#include <algorithm>
#include <array>
#include <vector>

#include <glm/glm.hpp>
#include <glm/gtc/matrix_access.hpp>
#include <glm/gtc/matrix_transform.hpp>

#include "shared/world/block.hh"

namespace client {
namespace world {

// Doesn't add any data, just information for rendering.
class block : public shared::world::block {
public:
    struct glvert {
        glm::vec3 vertice;
        glm::vec3 texture;
    };
    using glface_t = std::array<glvert, 6>;  // array of verts (a face)
    using glfaces_t = std::vector<glface_t>; // vector of faces (a block)

    // Render types refer to how the block should be culled when making the vbo.
    enum class draw_type {
        block,  // face testing
        custom, // no testing
    };

public:
    static enum draw_type get_draw_type(const enum block::type& type) noexcept;
    static const glfaces_t& get_glfaces(const enum block::type& type) noexcept;

public:
    template <typename... Args>
    block(Args&&... args) noexcept : block(std::forward<Args>(args)...) {}

public:
    enum draw_type get_draw_type() const noexcept {
        return get_draw_type(this->type);
    }
    const glfaces_t& get_glfaces() const noexcept {
        return get_glfaces(this->type);
    }
};

} // namespace world
} // namespace client

#endif