-
Notifications
You must be signed in to change notification settings - Fork 0
/
World.h
57 lines (42 loc) · 1.13 KB
/
World.h
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
54
55
56
57
#pragma once
#include <vector>
#include "Terrain.h"
#include "ModelRenderer.h"
class World : public EngineObject
{
class Heightmap
{
public:
Heightmap(unsigned x, unsigned z);
explicit Heightmap(const Heightmap&);
explicit Heightmap(Heightmap&&);
Heightmap& operator=(const Heightmap&);
Heightmap& operator=(Heightmap&&);
float* get();
float* get( unsigned x, unsigned z);
float* operator[] (unsigned x);
private:
unique_ptr<float> _mem;
float* _pos0;
unsigned _x, _z;
};
public:
World(ThreadManager*, Camera*, unsigned x, unsigned z);
virtual void load(RessourceHandler& loader);
virtual void init(KeyMap& map);
virtual void update(ThreadManager&);
virtual void render(Shader&, RenderingEngine::RenderState);
static unsigned getMemPosForTerrain(int x, int z, bool invX, bool invZ);
~World();
private:
void TerrainForPos(vec2 pos, int xOff, int zOff);
void setPos(vec2 pos);
vec2 toWorldPos(vec3 pos) { return vec2(pos.x, pos.z); }
unsigned chunkX, chunkZ;
vector<Terrain> allocator;
Heightmap _heightmap;
Camera* player;
mutex safeguard;
Texture ground; //needs to become atlas
bool initialized;
};