-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstance.h
116 lines (99 loc) · 2.85 KB
/
instance.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#ifndef _INSTANCE_H_
#define _INSTANCE_H_
#include <iostream>
#include <vector>
#include <unordered_map>
#include <cstdint>
#include <ctime>
#include <string.h>
#include <memory>
#include "libs/vector.h"
#include "generation/noises.h"
#include "generation/heightfield-generator.h"
#include "generation/instance-generator.h"
#include "polygonization/polygonizer.h"
#include "polygonization/mesh.h"
#include "task/task.h"
#include "task/promise.h"
#include "task/octree.h"
class ChunkResult
{
public:
uint8_t *terrainMeshBuffer;
uint8_t *waterMeshBuffer;
uint8_t *treeInstancesBuffer;
uint8_t *flowerInstancesBuffer;
uint8_t *bushInstancesBuffer;
uint8_t *rockInstancesBuffer;
uint8_t *stoneInstancesBuffer;
uint8_t *grassInstancesBuffer;
uint8_t *poiInstancesBuffer;
uint8_t *heightfieldsBuffer;
void free();
};
class RenderingInfo
{
public:
vm::vec3 worldPosition;
vm::vec3 cameraPosition;
Quat cameraQuaternion;
std::array<float, 16> projectionMatrix;
};
class PGInstance
{
public:
HeightfieldGenerator heightfieldGenerator;
VegetationGenerator vegetationGenerator;
MineralGenerator mineralGenerator;
PoiGenerator poiGenerator;
Polygonizer polygonizer;
RenderingInfo renderingInfo;
PGInstance(int seed, int chunkSize);
~PGInstance();
void setCamera(const vm::vec3 &worldPosition, const vm::vec3 &cameraPosition, const Quat &cameraQuaternion, const std::array<float, 16> &projectionMatrix);
OctreeContext getChunkSeedOctree(
const vm::ivec2 &worldPosition,
int minLod,
int maxLod,
int chunkSize);
uint8_t *createMobSplat(const vm::ivec2 &worldPositionXZ, const int lod);
void createChunkMesh(
ChunkResult *result,
const vm::ivec2 &worldPosition,
int lod,
const std::array<int, 2> &lodArray,
int generateFlags,
int numVegetationInstances,
int numRockInstances,
int numGrassInstances,
int numPoiInstances);
void createChunkMeshAsync(
uint32_t id,
const vm::ivec2 &worldPosition,
int lod,
const std::array<int, 2> &lodArray,
int generateFlags,
int numVegetationInstances,
int numRockInstances,
int numGrassInstances,
int numPoiInstances);
void createMobSplatAsync(uint32_t id, const vm::ivec2 &worldPositionXZ, const int lod, const int priority);
uint8_t *createBarrierMesh(
const vm::ivec2 &worldPosition,
int minLod,
int maxLod);
void createBarrierMeshAsync(
uint32_t id,
const vm::ivec2 &worldPosition,
int minLod,
int maxLod);
void trackerUpdateAsync(
uint32_t id,
Tracker *tracker,
const vm::vec3 &position,
int minLod,
int maxLod,
int lod1Range,
int priority);
};
#endif // _INSTANCE_H_