-
Notifications
You must be signed in to change notification settings - Fork 0
/
TriangleChunk.h
40 lines (30 loc) · 946 Bytes
/
TriangleChunk.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
#pragma once
#include "Utility.h"
#include <map>
#include <vector>
#include "Mesh.h"
#include "FastNoiseLite.h"
#include "Common.h"
class TriangleChunk
{
public:
TriangleChunk(Vertex v1, Vertex v2, Vertex v3, float frequency, int octaves, FastNoiseLite* noise, ID3D12GraphicsCommandList* commandList);
~TriangleChunk() { delete mMesh; mMesh = nullptr; };
// Geometry
std::map<std::pair<int, int>, int> mVertexMap;
std::vector<Vertex> mVertices;
std::vector<uint32_t> mIndices;
Mesh* mMesh;
bool mCombine = false;
private:
// Subdivide mesh
bool Subdivide(Vertex v1, Vertex v2, Vertex v3, int level = 0);
// Get vertex for triangle edge
int GetVertexForEdge(int v1, int v2);
// Subdivide triangle
std::vector<Triangle> SubdivideTriangle(Triangle triangle);
// Apply noise
void ApplyNoise(float frequency, int octaves, FastNoiseLite* noise, std::vector<Vertex>& vertices);
int mMaxLOD = 6;
float mSphereOffset = 0.0;
};