blob: 85cb736dc9deaa1415057cede8d75a998ae2982a (
plain) (
blame)
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
58
59
60
61
62
63
|
#pragma once
#include <map>
#include <vector>
#include <mutex>
#include <queue>
#include <memory>
#include <thread>
#include "RendererSection.hpp"
#include "RendererEntity.hpp"
#include "RendererSky.hpp"
#include "RendererSectionData.hpp"
class Frustum;
class GameState;
class Texture;
class Shader;
class EventListener;
class RenderState;
class RendererWorld {
struct SectionParsing {
SectionsData data;
RendererSectionData renderer;
bool parsing = false;
};
//General
std::unique_ptr<EventListener> listener;
size_t numOfWorkers;
size_t currentWorker = 0;
std::vector<std::thread> workers;
void WorkerFunction(size_t WorkerId);
bool isRunning = true;
const static size_t parsingBufferSize = 64;
SectionParsing parsing[parsingBufferSize];
std::queue<Vector> parseQueue;
bool parseQueueNeedRemoveUnnecessary = false;
void ParseQueueUpdate();
void ParseQeueueRemoveUnnecessary();
//Blocks
std::vector<Vector> renderList;
std::map<Vector, RendererSection> sections;
void UpdateAllSections(VectorF playerPos);
std::chrono::time_point<std::chrono::high_resolution_clock> globalTimeStart;
//Entities
std::vector<RendererEntity> entities;
//Sky
Texture *skyTexture;
RendererSky rendererSky;
public:
RendererWorld();
~RendererWorld();
void Render(RenderState& renderState);
void PrepareRender();
double MaxRenderingDistance;
void Update(double timeToUpdate);
};
|