├── .gitmodules
├── CudaVdGenerator
├── .gitignore
├── CudaVdGenerator.h
├── CudaVdGenerator.vcxproj
└── main.cu
├── LICENSE
├── README.md
├── UE4VoxelTerrain
├── .gitignore
├── Config
│ ├── DefaultEditor.ini
│ ├── DefaultEditorPerProjectUserSettings.ini
│ ├── DefaultEngine.ini
│ ├── DefaultGame.ini
│ └── DefaultInput.ini
├── Source
│ ├── UE4VoxelTerrain.Target.cs
│ ├── UE4VoxelTerrain
│ │ ├── BaseCharacter.cpp
│ │ ├── BaseCharacter.h
│ │ ├── CubeObject.cpp
│ │ ├── CubeObject.h
│ │ ├── CudaTerrainGeneratorComponent.cpp
│ │ ├── CudaTerrainGeneratorComponent.h
│ │ ├── LevelController.cpp
│ │ ├── LevelController.h
│ │ ├── MainHUD.cpp
│ │ ├── MainHUD.h
│ │ ├── MiningTool.cpp
│ │ ├── MiningTool.h
│ │ ├── PreparationHelperActor.cpp
│ │ ├── PreparationHelperActor.h
│ │ ├── Ramp.cpp
│ │ ├── Ramp.h
│ │ ├── SpawnHelper.hpp
│ │ ├── TerrainController.cpp
│ │ ├── TerrainController.h
│ │ ├── TerrainGenerator.cpp
│ │ ├── TerrainGenerator.h
│ │ ├── UE4VoxelTerrain.Build.cs
│ │ ├── UE4VoxelTerrain.cpp
│ │ ├── UE4VoxelTerrain.h
│ │ ├── UE4VoxelTerrainCharacter.cpp
│ │ ├── UE4VoxelTerrainCharacter.h
│ │ ├── UE4VoxelTerrainGameMode.cpp
│ │ ├── UE4VoxelTerrainGameMode.h
│ │ ├── UE4VoxelTerrainPlayerController.cpp
│ │ ├── UE4VoxelTerrainPlayerController.h
│ │ └── UI
│ │ │ ├── SystemInfoWidget.cpp
│ │ │ └── SystemInfoWidget.h
│ └── UE4VoxelTerrainEditor.Target.cs
└── UE4VoxelTerrain.uproject
├── cave.gif
├── controls.md
├── grass.gif
└── terrain.gif
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "UE4VoxelTerrain/Plugins/UnrealSandboxTerrain"]
2 | path = UE4VoxelTerrain/Plugins/UnrealSandboxTerrain
3 | url = https://github.com/bw2012/UnrealSandboxTerrain.git
4 | [submodule "UE4VoxelTerrain/Plugins/UnrealSandboxToolkit"]
5 | path = UE4VoxelTerrain/Plugins/UnrealSandboxToolkit
6 | url = https://github.com/bw2012/UnrealSandboxToolkit.git
7 |
--------------------------------------------------------------------------------
/CudaVdGenerator/.gitignore:
--------------------------------------------------------------------------------
1 | .vs
2 | x64
3 | CudaVdGenerator.vcxproj.user
4 |
5 |
--------------------------------------------------------------------------------
/CudaVdGenerator/CudaVdGenerator.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 |
4 | typedef struct TZoneData {
5 | float x;
6 | float y;
7 | float z;
8 |
9 | int c[10];
10 |
11 | } TZoneData;
12 |
13 | typedef struct TVdGenBlock {
14 | int size = 0;
15 |
16 | TZoneData* zoneData = nullptr;
17 | size_t zd_size = 0;
18 |
19 | TDensityVal* voxelData = nullptr;
20 | size_t vd_size = 0;
21 |
22 | TMaterialId* materialData = nullptr;
23 | size_t md_size = 0;
24 |
25 | int* cacheData = nullptr;
26 | size_t cd_size = 0;
27 |
28 | } TVdGenBlock;
--------------------------------------------------------------------------------
/CudaVdGenerator/CudaVdGenerator.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(VCTargetsPath)\BuildCustomizations
5 |
6 |
7 |
8 | Debug
9 | x64
10 |
11 |
12 | Release
13 | x64
14 |
15 |
16 |
17 | {E24383DD-55FD-4FDE-8263-21454C782763}
18 | vectorAdd_vs2019
19 | CudaVdGeneratorDll
20 |
21 |
22 |
23 |
24 | DynamicLibrary
25 | MultiByte
26 | v142
27 | 10.0
28 |
29 |
30 | true
31 |
32 |
33 | true
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 | $(Platform)/$(Configuration)/
45 | $(IncludePath)
46 | AllRules.ruleset
47 |
48 |
49 |
50 |
51 | d:/src/bin/win64/$(Configuration)/
52 |
53 |
54 |
55 | Level3
56 | WIN32;_MBCS;%(PreprocessorDefinitions)
57 | ./;$(CudaToolkitDir)/include;../../common/inc;
58 |
59 |
60 | Console
61 | cudart_static.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
62 | $(CudaToolkitLibDir);
63 | $(OutDir)/CudaVdGenerator.dll
64 |
65 |
66 | compute_35,sm_35;compute_37,sm_37;compute_50,sm_50;compute_52,sm_52;compute_60,sm_60;compute_61,sm_61;compute_70,sm_70;compute_75,sm_75;compute_80,sm_80;compute_86,sm_86;
67 | -Xcompiler "/wd 4819" %(AdditionalOptions)
68 | ./;../../common/inc
69 | WIN32
70 | --threads 0
71 |
72 |
73 |
74 |
75 | Disabled
76 | MultiThreadedDebug
77 |
78 |
79 | true
80 | Default
81 |
82 |
83 | MTd
84 | 64
85 |
86 |
87 |
88 |
89 | MaxSpeed
90 | MultiThreaded
91 |
92 |
93 | false
94 | UseLinkTimeCodeGeneration
95 |
96 |
97 | MT
98 | 64
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
--------------------------------------------------------------------------------
/CudaVdGenerator/main.cu:
--------------------------------------------------------------------------------
1 |
2 | #include
3 | #include
4 |
5 | // For the CUDA runtime routines (prefixed with "cuda_")
6 | #include
7 | //#include
8 |
9 |
10 | #define USBT_ZONE_SIZE 1000.f
11 | #define USBT_ZONE_DIMENSION 65
12 |
13 | typedef unsigned char TDensityVal;
14 | typedef unsigned short TMaterialId;
15 |
16 | #include "CudaVdGenerator.h"
17 |
18 | //====================================================================================
19 | // DLL declarations
20 | //====================================================================================
21 |
22 | extern "C" __declspec(dllexport) int CudaGetInfo(void);
23 | extern "C" __declspec(dllexport) int CudaGenerateVd(TVdGenBlock* vdGenBlock);
24 |
25 |
26 | //====================================================================================
27 | // cuda perlin noise
28 | //====================================================================================
29 |
30 | __device__ const int p[512] = { 151, 160, 137, 91, 90, 15, 131, 13, 201, 95, 96, 53, 194, 233, 7, 225, 140, 36, 103, 30, 69, 142, 8, 99, 37, 240, 21, 10, 23, 190, 6, 148, 247, 120, 234, 75, 0, 26, 197, 62, 94, 252, 219, 203, 117, 35, 11, 32, 57, 177, 33, 88, 237, 149, 56, 87, 174, 20, 125, 136, 171, 168, 68, 175, 74, 165, 71, 134, 139, 48, 27, 166, 77, 146, 158, 231, 83, 111, 229, 122, 60, 211, 133, 230, 220, 105, 92, 41, 55, 46, 245, 40, 244, 102, 143, 54, 65, 25, 63, 161, 1, 216, 80, 73, 209, 76, 132, 187, 208, 89, 18, 169, 200, 196, 135, 130, 116, 188, 159, 86, 164, 100, 109, 198, 173, 186, 3, 64, 52, 217, 226, 250, 124, 123, 5, 202, 38, 147, 118, 126, 255, 82, 85, 212, 207, 206, 59, 227, 47, 16, 58, 17, 182, 189, 28, 42, 223, 183, 170, 213, 119, 248, 152, 2, 44, 154, 163, 70, 221, 153, 101, 155, 167, 43, 172, 9, 129, 22, 39, 253, 19, 98, 108, 110, 79, 113, 224, 232, 178, 185, 112, 104, 218, 246, 97, 228, 251, 34, 242, 193, 238, 210, 144, 12, 191, 179, 162, 241, 81, 51, 145, 235, 249, 14, 239, 107, 49, 192, 214, 31, 181, 199, 106, 157, 184, 84, 204, 176, 115, 121, 50, 45, 127, 4, 150, 254, 138, 236, 205, 93, 222, 114, 67, 29, 24, 72, 243, 141, 128, 195, 78, 66, 215, 61, 156, 180, 151, 160, 137, 91, 90, 15, 131, 13, 201, 95, 96, 53, 194, 233, 7, 225, 140, 36, 103, 30, 69, 142, 8, 99, 37, 240, 21, 10, 23, 190, 6, 148, 247, 120, 234, 75, 0, 26, 197, 62, 94, 252, 219, 203, 117, 35, 11, 32, 57, 177, 33, 88, 237, 149, 56, 87, 174, 20, 125, 136, 171, 168, 68, 175, 74, 165, 71, 134, 139, 48, 27, 166, 77, 146, 158, 231, 83, 111, 229, 122, 60, 211, 133, 230, 220, 105, 92, 41, 55, 46, 245, 40, 244, 102, 143, 54, 65, 25, 63, 161, 1, 216, 80, 73, 209, 76, 132, 187, 208, 89, 18, 169, 200, 196, 135, 130, 116, 188, 159, 86, 164, 100, 109, 198, 173, 186, 3, 64, 52, 217, 226, 250, 124, 123, 5, 202, 38, 147, 118, 126, 255, 82, 85, 212, 207, 206, 59, 227, 47, 16, 58, 17, 182, 189, 28, 42, 223, 183, 170, 213, 119, 248, 152, 2, 44, 154, 163, 70, 221, 153, 101, 155, 167, 43, 172, 9, 129, 22, 39, 253, 19, 98, 108, 110, 79, 113, 224, 232, 178, 185, 112, 104, 218, 246, 97, 228, 251, 34, 242, 193, 238, 210, 144, 12, 191, 179, 162, 241, 81, 51, 145, 235, 249, 14, 239, 107, 49, 192, 214, 31, 181, 199, 106, 157, 184, 84, 204, 176, 115, 121, 50, 45, 127, 4, 150, 254, 138, 236, 205, 93, 222, 114, 67, 29, 24, 72, 243, 141, 128, 195, 78, 66, 215, 61, 156, 180 };
31 |
32 | __device__ float fade(float t) { return t * t * t * (t * (t * 6 - 15) + 10); }
33 |
34 | __device__ float lerp(float t, float a, float b) { return a + t * (b - a); }
35 |
36 | __device__ float grad(int hash, float x, float y, float z) {
37 | int h = hash & 15;
38 | float u = h < 8 ? x : y,
39 | v = h < 4 ? y : h == 12 || h == 14 ? x : z;
40 | return ((h & 1) == 0 ? u : -u) + ((h & 2) == 0 ? v : -v);
41 | }
42 | __device__ float noise(float x, float y, float z) {
43 | int X = (int)floor(x) & 255;
44 | int Y = (int)floor(y) & 255;
45 | int Z = (int)floor(z) & 255;
46 |
47 | x -= floor(x);
48 | y -= floor(y);
49 | z -= floor(z);
50 |
51 | float u = fade(x);
52 | float v = fade(y);
53 | float w = fade(z);
54 |
55 | int A = p[X] + Y, AA = p[A] + Z, AB = p[A + 1] + Z;
56 | int B = p[X + 1] + Y, BA = p[B] + Z, BB = p[B + 1] + Z;
57 |
58 | return lerp(w, lerp(v, lerp(u, grad(p[AA], x, y, z),
59 | grad(p[BA], x - 1, y, z)),
60 | lerp(u, grad(p[AB], x, y - 1, z),
61 | grad(p[BB], x - 1, y - 1, z))),
62 | lerp(v, lerp(u, grad(p[AA + 1], x, y, z - 1),
63 | grad(p[BA + 1], x - 1, y, z - 1)),
64 | lerp(u, grad(p[AB + 1], x, y - 1, z - 1),
65 | grad(p[BB + 1], x - 1, y - 1, z - 1))));
66 | }
67 |
68 | //====================================================================================
69 | //
70 | //====================================================================================
71 |
72 | __device__ float3 operator+(const float3& a, const float3& b) {
73 | return make_float3(a.x + b.x, a.y + b.y, a.z + b.z);
74 | }
75 |
76 | __device__ float3 voxelIndexToRelPos(const int x, const int y, const int z, int vd_num, float vd_size) {
77 | const float step = vd_size / (vd_num - 1);
78 | const float s = -vd_size / 2;
79 | float3 v = make_float3(s, s, s);
80 | float3 a = make_float3(x * step, y * step, z * step);
81 | v = v + a;
82 | return v;
83 | }
84 |
85 | __device__ float clcGroundLevel(float3 v, int vd_num, float vd_size) {
86 | const float scale1 = 0.001f; // small
87 | const float scale2 = 0.0004f; // medium
88 | const float scale3 = 0.00009f; // big
89 |
90 | const float noise_small = noise(v.x * scale1, v.y * scale1, 0) * 0.5f;
91 | const float noise_medium = noise(v.x * scale2, v.y * scale2, 0) * 5;
92 | const float noise_big = noise(v.x * scale3, v.y * scale3, 0) * 10;
93 | const float gl = ((noise_small + noise_medium + noise_big) * 100) + 205.f;
94 |
95 | return gl;
96 | }
97 |
98 | __device__ float clcDensityByGroundLevel(float3 v, float gl) {
99 | const float Z = v.z;
100 | const float D = Z - gl;
101 |
102 | if (D > 500) {
103 | return 0.f;
104 | }
105 |
106 | if (D < -500) {
107 | return 1.f;
108 | }
109 |
110 | const float density = 1 - (1 / (1 + exp(-(Z-gl) / 20)));
111 | return density;
112 | }
113 |
114 | __device__ int clcLinearIndex(int x, int y, int z, int n) {
115 | return x * n * n + y * n + z;
116 | };
117 |
118 |
119 | __global__ void cudaGenerateZoneVd(TZoneData* devZoneData, TDensityVal* devVd, TMaterialId* devMd, int vd_num, float vd_size, int totalZoneCount) {
120 | int idx = blockDim.x * blockIdx.x + threadIdx.x;
121 |
122 | if (idx >= totalZoneCount) {
123 | return;
124 | }
125 |
126 | TZoneData zd = devZoneData[idx];
127 | auto t = vd_num * vd_num * vd_num * idx;
128 |
129 | TDensityVal* vd = devVd + t;
130 | TMaterialId* md = devMd + t;
131 |
132 | const float3 zoneOrigin = make_float3(zd.x, zd.y, zd.z);
133 | const float step = vd_size / (vd_num - 1);
134 | const float s = -vd_size / 2;
135 |
136 | int i = 0;
137 | for (int x = 0; x < vd_num; x++) {
138 | for (int y = 0; y < vd_num; y++) {
139 | float3 v0 = voxelIndexToRelPos(x, y, 0, vd_num, vd_size);
140 | v0 = v0 + zoneOrigin;
141 | const float gl = clcGroundLevel(v0, vd_num, vd_size);
142 |
143 | for (int z = 0; z < vd_num; z++) {
144 | float3 v = voxelIndexToRelPos(x, y, z, vd_num, vd_size);
145 | v = v + zoneOrigin;
146 |
147 | float density = clcDensityByGroundLevel(v, gl);
148 | int d = 255 * density;
149 |
150 | vd[i] = d;
151 | md[i] = 1;
152 |
153 | i++;
154 | }
155 |
156 | }
157 | }
158 | }
159 |
160 | #define LOD_ARRAY_SIZE 7
161 |
162 | __global__ void cudaMakeCache(TZoneData* devZoneData, TDensityVal* devVd, int* devCd, int vd_num, float vd_size, int totalZoneCount) {
163 | int idx = blockDim.x * blockIdx.x + threadIdx.x;
164 |
165 | if (idx >= totalZoneCount) {
166 | return;
167 | }
168 |
169 | //TZoneData zd = devZoneData[idx];
170 | TZoneData* zd_p = &devZoneData[idx];
171 | auto t = vd_num * vd_num * vd_num * idx;
172 |
173 | TDensityVal* vd = devVd + t;
174 | int* cd = devCd + t;
175 |
176 | for (int lod = 0; lod < LOD_ARRAY_SIZE; lod++) {
177 | zd_p->c[lod] = 0;
178 | }
179 |
180 | for (int x = 0u; x < vd_num; x++) {
181 | for (int y = 0u; y < vd_num; y++) {
182 | for (int z = 0u; z < vd_num; z++) {
183 |
184 | int offset = 0;
185 |
186 | for (int lod = 0; lod < LOD_ARRAY_SIZE; lod++) {
187 | int s = 1 << lod;
188 |
189 | int n = (vd_num - 1) >> lod;
190 |
191 | if (x >= s && y >= s && z >= s) {
192 | if (x % s == 0 && y % s == 0 && z % s == 0) {
193 | int li[8];
194 | li[7] = clcLinearIndex(x, y - s, z, vd_num);
195 | li[6] = clcLinearIndex(x, y, z, vd_num);
196 | li[5] = clcLinearIndex(x - s, y - s, z, vd_num);
197 | li[4] = clcLinearIndex(x - s, y, z, vd_num);
198 | li[3] = clcLinearIndex(x, y - s, z - s, vd_num);
199 | li[2] = clcLinearIndex(x, y, z - s, vd_num);
200 | li[1] = clcLinearIndex(x - s, y - s, z - s, vd_num);
201 | li[0] = clcLinearIndex(x - s, y, z - s, vd_num);
202 |
203 |
204 | char corner[8];
205 | for (auto i = 0; i < 8; i++) {
206 | corner[i] = (vd[li[i]] <= 127) ? -127 : 0;
207 | }
208 |
209 | unsigned long caseCode = ((corner[0] >> 7) & 0x01)
210 | | ((corner[1] >> 6) & 0x02)
211 | | ((corner[2] >> 5) & 0x04)
212 | | ((corner[3] >> 4) & 0x08)
213 | | ((corner[4] >> 3) & 0x10)
214 | | ((corner[5] >> 2) & 0x20)
215 | | ((corner[6] >> 1) & 0x40)
216 | | (corner[7] & 0x80);
217 |
218 | if (caseCode != 0 && caseCode != 255) {
219 | cd[offset + zd_p->c[lod]] = li[1];
220 | zd_p->c[lod]++;
221 | }
222 | }
223 | }
224 |
225 | offset += n * n * n;
226 | }
227 |
228 |
229 | }
230 | }
231 | }
232 |
233 |
234 |
235 | }
236 |
237 | //====================================================================================
238 | //
239 | //====================================================================================
240 |
241 | typedef unsigned __int64 uint64;
242 |
243 | uint64 time_ms() {
244 | return std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count();
245 | }
246 |
247 | int CudaGetInfo(void) {
248 | return 0;
249 | }
250 |
251 | int CudaGenerateVd(TVdGenBlock* vdGenBlock) {
252 | cudaError_t err = cudaSuccess;
253 |
254 | if (vdGenBlock == nullptr) {
255 | return -1;
256 | }
257 |
258 | uint64 start0 = time_ms();
259 |
260 | int vd_num = USBT_ZONE_DIMENSION;
261 | float vd_size = USBT_ZONE_SIZE;
262 |
263 | printf("total_zone_count -> %d \n", vdGenBlock->size);
264 |
265 | auto start1 = time_ms();
266 |
267 | TDensityVal* d_vd = NULL;
268 | err = cudaMalloc((void**)&d_vd, vdGenBlock->vd_size);
269 | if (err != cudaSuccess) {
270 | fprintf(stderr, "Failed to allocate device TDensityVal (error code %s)!\n", cudaGetErrorString(err));
271 | return -1;
272 | }
273 |
274 | TMaterialId* d_md = NULL;
275 | err = cudaMalloc((void**)&d_md, vdGenBlock->md_size);
276 | if (err != cudaSuccess) {
277 | fprintf(stderr, "Failed to allocate device TMaterialId (error code %s)!\n", cudaGetErrorString(err));
278 | return -1;
279 | }
280 |
281 | TZoneData* d_zd = NULL;
282 | err = cudaMalloc((void**)&d_zd, vdGenBlock->zd_size);
283 | if (err != cudaSuccess) {
284 | fprintf(stderr, "Failed to allocate device TZoneData (error code %s)!\n", cudaGetErrorString(err));
285 | return -1;
286 | }
287 |
288 | int* d_cd = NULL;
289 | err = cudaMalloc((void**)&d_cd, vdGenBlock->cd_size);
290 | if (err != cudaSuccess) {
291 | fprintf(stderr, "Failed to allocate device cach data (error code %s)!\n", cudaGetErrorString(err));
292 | return -1;
293 | }
294 |
295 | printf("Copy input data from the host memory to the CUDA device\n");
296 | err = cudaMemcpy(d_zd, vdGenBlock->zoneData, vdGenBlock->zd_size, cudaMemcpyHostToDevice);
297 | if (err != cudaSuccess) {
298 | fprintf(stderr, "Failed to copy zone data from host to device (error code %s)!\n", cudaGetErrorString(err));
299 | return -1;
300 | }
301 |
302 | auto end1 = time_ms();
303 | printf("%d ms\n", (int)(end1 - start1));
304 |
305 | int threadsPerBlock = 256;
306 | int blocksPerGrid = (vdGenBlock->size + threadsPerBlock - 1) / threadsPerBlock;
307 |
308 | printf("CUDA kernel launch with %d blocks of %d threads\n", blocksPerGrid, threadsPerBlock);
309 |
310 | auto t1 = time_ms();
311 | cudaGenerateZoneVd << > > (d_zd, d_vd, d_md, vd_num, vd_size, vdGenBlock->size);
312 | err = cudaGetLastError();
313 | if (err != cudaSuccess) {
314 | fprintf(stderr, "Failed to launch cudaGenerateZoneVd kernel (error code %s)!\n", cudaGetErrorString(err));
315 | return -1;
316 | }
317 |
318 |
319 | cudaMakeCache << > > (d_zd, d_vd, d_cd, vd_num, vd_size, vdGenBlock->size);
320 | err = cudaGetLastError();
321 | if (err != cudaSuccess) {
322 | fprintf(stderr, "Failed to launch cudaMakeCache kernel (error code %s)!\n", cudaGetErrorString(err));
323 | return -1;
324 | }
325 |
326 | err = cudaDeviceSynchronize();
327 | auto t2 = time_ms();
328 | if (err != cudaSuccess) {
329 | fprintf(stderr, "Failed to cudaDeviceSynchronize: %s \n", cudaGetErrorString(err));
330 | return -1;
331 | } else {
332 | printf("%d ms\n", (int)(t2 - t1));
333 | }
334 |
335 | printf("Copy output data from the CUDA device to the host memory\n");
336 | printf("%d\n", vdGenBlock->vd_size);
337 |
338 | auto start2 = time_ms();
339 |
340 | err = cudaMemcpy(vdGenBlock->voxelData, d_vd, vdGenBlock->vd_size, cudaMemcpyDeviceToHost);
341 | if (err != cudaSuccess) {
342 | fprintf(stderr, "Failed to copy vector C from device to host (error code %s)!\n", cudaGetErrorString(err));
343 | return -1;
344 | }
345 |
346 | err = cudaMemcpy(vdGenBlock->materialData, d_md, vdGenBlock->md_size, cudaMemcpyDeviceToHost);
347 | if (err != cudaSuccess) {
348 | fprintf(stderr, "Failed to copy vector C from device to host (error code %s)!\n", cudaGetErrorString(err));
349 | return -1;
350 | }
351 |
352 | err = cudaMemcpy(vdGenBlock->zoneData, d_zd, vdGenBlock->zd_size, cudaMemcpyDeviceToHost);
353 | if (err != cudaSuccess) {
354 | fprintf(stderr, "Failed to copy zone data from device to host (error code %s)!\n", cudaGetErrorString(err));
355 | return -1;
356 | }
357 |
358 | err = cudaMemcpy(vdGenBlock->cacheData, d_cd, vdGenBlock->cd_size, cudaMemcpyDeviceToHost);
359 | if (err != cudaSuccess) {
360 | fprintf(stderr, "Failed to copy cache data from device to host (error code %s)!\n", cudaGetErrorString(err));
361 | return -1;
362 | }
363 |
364 | auto end2 = time_ms();
365 | printf("%d ms\n", (int)(end2 - start2));
366 |
367 | // Free device global memory
368 | err = cudaFree(d_vd);
369 | if (err != cudaSuccess)
370 | {
371 | fprintf(stderr, "Failed to free device vector A (error code %s)!\n", cudaGetErrorString(err));
372 | return -1;
373 | }
374 |
375 | err = cudaFree(d_md);
376 | if (err != cudaSuccess)
377 | {
378 | fprintf(stderr, "Failed to free device vector A (error code %s)!\n", cudaGetErrorString(err));
379 | return -1;
380 | }
381 |
382 | err = cudaFree(d_zd);
383 | if (err != cudaSuccess)
384 | {
385 | fprintf(stderr, "Failed to free device vector A (error code %s)!\n", cudaGetErrorString(err));
386 | return -1;
387 | }
388 |
389 | auto end0 = time_ms();
390 | printf("Finished: %d ms\n", (int)(end0 - start0));
391 |
392 | return 0;
393 | }
394 |
395 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # UE4VoxelTerrain
2 | Unreal Engine 4 procedural voxel terrian example (partially based on Transvoxel™ Algorithm by Eric Lengyel http://transvoxel.org/)
3 | This plugin provides tools to generate, visualize and in-game change volume terrain using voxels.
4 |
5 | 
6 |
7 | 
8 |
9 | 
10 |
11 | Master branch tested with Unreal Engine 4.27.1 [Windows 10]
12 |
13 | > [!WARNING]
14 | > This version is discontinued due to UE5 release. Please use UE5 version.
15 |
16 | # UE5 version source code
17 |
18 | https://github.com/bw2012/UE5VoxelTerrainDemo
19 |
20 | # Download playable demo
21 | UE5 version: [UE5VoxelTerrain-0.0.39.zip](https://mega.nz/file/mKoSQDTD#H9zhTK-HGyCfolQuhSGCJ-jOSXfA_IlOsWVU5xPTAgU)
22 |
23 | UE4 version: [UE4VoxelTerrain-0.0.23.zip](https://drive.google.com/file/d/1pg1EYWWtyAS4ZwLdQvE-DJOJOVZPjj8v/view)
24 |
25 | # Features
26 | * Runtime terrain modification
27 | * Procedural landscape/caves generation
28 | * Level of details (per chunk)
29 | * Foliage
30 | * Up to 65535 terrain materials
31 |
32 | # Usage
33 | 1. Install MS Visual Studio 2022
34 | 2. Clone repository properly ```git clone --recursive https://github.com/bw2012/UE4VoxelTerrain.git```
35 | 3. This project uses git submodules. Make sure that project are cloned properly and folder UE4VoxelTerrain/Plugins is not empty.
36 | 4. Open directory UE4VoxelTerrain
37 | 5. Download [Content.zip](https://drive.google.com/file/d/1lvWXYaOzaiHsp0OgZyLBL7G_NSyvf9sT/view?usp=sharing) (~1.2Gb) and unzip it to ```Content``` folder
38 | 6. Open project file with Unreal Engine 4.27
39 | 7. Wait for compile UE4 KiteDemo shaders (first run may take long time)
40 |
41 |
42 |
--------------------------------------------------------------------------------
/UE4VoxelTerrain/.gitignore:
--------------------------------------------------------------------------------
1 | Build
2 | Binaries
3 | DerivedDataCache
4 | Intermediate
5 | Saved
6 | *.opensdf
7 | *.sdf
8 | *.sln
9 | *.suo
10 | *.xcodeproj
11 | *.xcworkspace
12 | .codelite
13 | .kdev4
14 | .clang
15 | .vs
16 | *.db
17 | *.ipch
18 |
19 | UE4VoxelTerrain.VC.VC.opendb
20 | UE4VoxelTerrain.VC.db
21 |
22 | Content
23 |
24 | *.zip
25 |
26 |
--------------------------------------------------------------------------------
/UE4VoxelTerrain/Config/DefaultEditor.ini:
--------------------------------------------------------------------------------
1 | [UnrealEd.SimpleMap]
2 | SimpleMapName=/Game/TopDown/Maps/TopDownExampleMap
3 |
4 | [EditoronlyBP]
5 | bAllowClassAndBlueprintPinMatching=true
6 | bReplaceBlueprintWithClass= true
7 | bDontLoadBlueprintOutsideEditor= true
8 | bBlueprintIsNotBlueprintType= true
9 |
10 | [/Script/UnrealEd.AssetViewerSettings]
11 | -Profiles=(ProfileName="Default",DirectionalLightIntensity=2.620000,DirectionalLightColor=(R=0.990000,G=0.839850,B=0.732600,A=1.000000),SkyLightIntensity=0.880000,bRotateLightingRig=False,bShowEnvironment=True,bShowFloor=True,EnvironmentCubeMapPath="/Engine/EditorMaterials/AssetViewer/EpicQuadPanorama_CC+EV1.EpicQuadPanorama_CC+EV1",PostProcessingSettings=(bOverride_WhiteTemp=True,bOverride_WhiteTint=False,bOverride_ColorSaturation=True,bOverride_ColorContrast=True,bOverride_ColorGamma=True,bOverride_ColorGain=True,bOverride_ColorOffset=True,bOverride_FilmWhitePoint=False,bOverride_FilmSaturation=False,bOverride_FilmChannelMixerRed=False,bOverride_FilmChannelMixerGreen=False,bOverride_FilmChannelMixerBlue=False,bOverride_FilmContrast=False,bOverride_FilmDynamicRange=False,bOverride_FilmHealAmount=False,bOverride_FilmToeAmount=False,bOverride_FilmShadowTint=False,bOverride_FilmShadowTintBlend=False,bOverride_FilmShadowTintAmount=False,bOverride_FilmSlope=True,bOverride_FilmToe=True,bOverride_FilmShoulder=True,bOverride_FilmBlackClip=True,bOverride_FilmWhiteClip=True,bOverride_SceneColorTint=False,bOverride_SceneFringeIntensity=False,bOverride_AmbientCubemapTint=False,bOverride_AmbientCubemapIntensity=False,bOverride_BloomIntensity=True,bOverride_BloomThreshold=False,bOverride_Bloom1Tint=False,bOverride_Bloom1Size=False,bOverride_Bloom2Size=False,bOverride_Bloom2Tint=False,bOverride_Bloom3Tint=False,bOverride_Bloom3Size=False,bOverride_Bloom4Tint=False,bOverride_Bloom4Size=False,bOverride_Bloom5Tint=False,bOverride_Bloom5Size=False,bOverride_Bloom6Tint=False,bOverride_Bloom6Size=False,bOverride_BloomSizeScale=False,bOverride_BloomDirtMaskIntensity=False,bOverride_BloomDirtMaskTint=False,bOverride_BloomDirtMask=False,bOverride_AutoExposureMethod=True,bOverride_AutoExposureLowPercent=False,bOverride_AutoExposureHighPercent=False,bOverride_AutoExposureMinBrightness=True,bOverride_AutoExposureMaxBrightness=True,bOverride_AutoExposureSpeedUp=False,bOverride_AutoExposureSpeedDown=False,bOverride_AutoExposureBias=True,bOverride_HistogramLogMin=True,bOverride_HistogramLogMax=True,bOverride_LensFlareIntensity=False,bOverride_LensFlareTint=False,bOverride_LensFlareTints=False,bOverride_LensFlareBokehSize=False,bOverride_LensFlareBokehShape=False,bOverride_LensFlareThreshold=False,bOverride_VignetteIntensity=True,bOverride_GrainIntensity=False,bOverride_GrainJitter=False,bOverride_AmbientOcclusionIntensity=True,bOverride_AmbientOcclusionStaticFraction=True,bOverride_AmbientOcclusionRadius=True,bOverride_AmbientOcclusionFadeDistance=False,bOverride_AmbientOcclusionFadeRadius=False,bOverride_AmbientOcclusionDistance=False,bOverride_AmbientOcclusionRadiusInWS=False,bOverride_AmbientOcclusionPower=True,bOverride_AmbientOcclusionBias=True,bOverride_AmbientOcclusionQuality=True,bOverride_AmbientOcclusionMipBlend=True,bOverride_AmbientOcclusionMipScale=True,bOverride_AmbientOcclusionMipThreshold=True,bOverride_LPVIntensity=False,bOverride_LPVDirectionalOcclusionIntensity=False,bOverride_LPVDirectionalOcclusionRadius=False,bOverride_LPVDiffuseOcclusionExponent=False,bOverride_LPVSpecularOcclusionExponent=False,bOverride_LPVDiffuseOcclusionIntensity=False,bOverride_LPVSpecularOcclusionIntensity=False,bOverride_LPVSize=False,bOverride_LPVSecondaryOcclusionIntensity=False,bOverride_LPVSecondaryBounceIntensity=False,bOverride_LPVGeometryVolumeBias=False,bOverride_LPVVplInjectionBias=False,bOverride_LPVEmissiveInjectionIntensity=False,bOverride_IndirectLightingColor=False,bOverride_IndirectLightingIntensity=False,bOverride_ColorGradingIntensity=True,bOverride_ColorGradingLUT=True,bOverride_DepthOfFieldFocalDistance=False,bOverride_DepthOfFieldFstop=False,bOverride_DepthOfFieldSensorWidth=False,bOverride_DepthOfFieldDepthBlurRadius=False,bOverride_DepthOfFieldDepthBlurAmount=False,bOverride_DepthOfFieldFocalRegion=False,bOverride_DepthOfFieldNearTransitionRegion=False,bOverride_DepthOfFieldFarTransitionRegion=False,bOverride_DepthOfFieldScale=True,bOverride_DepthOfFieldMaxBokehSize=False,bOverride_DepthOfFieldNearBlurSize=False,bOverride_DepthOfFieldFarBlurSize=False,bOverride_DepthOfFieldMethod=True,bOverride_MobileHQGaussian=False,bOverride_DepthOfFieldBokehShape=False,bOverride_DepthOfFieldOcclusion=False,bOverride_DepthOfFieldColorThreshold=False,bOverride_DepthOfFieldSizeThreshold=False,bOverride_DepthOfFieldSkyFocusDistance=False,bOverride_DepthOfFieldVignetteSize=False,bOverride_MotionBlurAmount=False,bOverride_MotionBlurMax=False,bOverride_MotionBlurPerObjectSize=False,bOverride_ScreenPercentage=False,bOverride_ScreenSpaceReflectionIntensity=True,bOverride_ScreenSpaceReflectionQuality=True,bOverride_ScreenSpaceReflectionMaxRoughness=True,bOverride_ScreenSpaceReflectionRoughnessScale=False,WhiteTemp=6700.000000,WhiteTint=0.000000,ColorSaturation=(X=1.000000,Y=1.000000,Z=1.000000),ColorContrast=(X=1.000000,Y=1.000000,Z=1.000000),ColorGamma=(X=1.000000,Y=1.000000,Z=1.000000),ColorGain=(X=1.000000,Y=1.000000,Z=1.000000),ColorOffset=(X=0.005000,Y=0.005000,Z=0.005000),FilmWhitePoint=(R=1.000000,G=1.000000,B=1.000000,A=1.000000),FilmShadowTint=(R=1.000000,G=1.000000,B=1.000000,A=1.000000),FilmShadowTintBlend=0.500000,FilmShadowTintAmount=0.000000,FilmSaturation=1.000000,FilmChannelMixerRed=(R=1.000000,G=0.000000,B=0.000000,A=1.000000),FilmChannelMixerGreen=(R=0.000000,G=1.000000,B=0.000000,A=1.000000),FilmChannelMixerBlue=(R=0.000000,G=0.000000,B=1.000000,A=1.000000),FilmContrast=0.030000,FilmToeAmount=1.000000,FilmHealAmount=1.000000,FilmDynamicRange=4.000000,FilmSlope=0.880000,FilmToe=0.550000,FilmShoulder=0.260000,FilmBlackClip=0.000000,FilmWhiteClip=0.040000,SceneColorTint=(R=1.000000,G=1.000000,B=1.000000,A=1.000000),SceneFringeIntensity=0.000000,BloomIntensity=0.675000,BloomThreshold=-1.000000,BloomSizeScale=4.000000,Bloom1Size=0.300000,Bloom2Size=1.000000,Bloom3Size=2.000000,Bloom4Size=10.000000,Bloom5Size=30.000000,Bloom6Size=64.000000,Bloom1Tint=(R=0.346500,G=0.346500,B=0.346500,A=1.000000),Bloom2Tint=(R=0.138000,G=0.138000,B=0.138000,A=1.000000),Bloom3Tint=(R=0.117600,G=0.117600,B=0.117600,A=1.000000),Bloom4Tint=(R=0.066000,G=0.066000,B=0.066000,A=1.000000),Bloom5Tint=(R=0.066000,G=0.066000,B=0.066000,A=1.000000),Bloom6Tint=(R=0.061000,G=0.061000,B=0.061000,A=1.000000),BloomDirtMaskIntensity=0.000000,BloomDirtMaskTint=(R=0.500000,G=0.500000,B=0.500000,A=1.000000),BloomDirtMask=None,LPVIntensity=1.000000,LPVVplInjectionBias=0.640000,LPVSize=5312.000000,LPVSecondaryOcclusionIntensity=0.000000,LPVSecondaryBounceIntensity=0.000000,LPVGeometryVolumeBias=0.384000,LPVEmissiveInjectionIntensity=1.000000,LPVDirectionalOcclusionIntensity=0.000000,LPVDirectionalOcclusionRadius=8.000000,LPVDiffuseOcclusionExponent=1.000000,LPVSpecularOcclusionExponent=7.000000,LPVDiffuseOcclusionIntensity=1.000000,LPVSpecularOcclusionIntensity=1.000000,AmbientCubemapTint=(R=1.000000,G=1.000000,B=1.000000,A=1.000000),AmbientCubemapIntensity=1.000000,AmbientCubemap=None,AutoExposureMethod=AEM_Histogram,AutoExposureLowPercent=80.000000,AutoExposureHighPercent=98.300003,AutoExposureMinBrightness=1.000000,AutoExposureMaxBrightness=1.000000,AutoExposureSpeedUp=3.000000,AutoExposureSpeedDown=1.000000,AutoExposureBias=0.330000,HistogramLogMin=-8.000000,HistogramLogMax=4.000000,LensFlareIntensity=1.000000,LensFlareTint=(R=1.000000,G=1.000000,B=1.000000,A=1.000000),LensFlareBokehSize=3.000000,LensFlareThreshold=8.000000,LensFlareBokehShape=None,LensFlareTints[0]=(R=1.000000,G=0.800000,B=0.400000,A=0.600000),LensFlareTints[1]=(R=1.000000,G=1.000000,B=0.600000,A=0.530000),LensFlareTints[2]=(R=0.800000,G=0.800000,B=1.000000,A=0.460000),LensFlareTints[3]=(R=0.500000,G=1.000000,B=0.400000,A=0.390000),LensFlareTints[4]=(R=0.500000,G=0.800000,B=1.000000,A=0.310000),LensFlareTints[5]=(R=0.900000,G=1.000000,B=0.800000,A=0.270000),LensFlareTints[6]=(R=1.000000,G=0.800000,B=0.400000,A=0.220000),LensFlareTints[7]=(R=0.900000,G=0.700000,B=0.700000,A=0.150000),VignetteIntensity=0.161468,GrainJitter=0.000000,GrainIntensity=0.000000,AmbientOcclusionIntensity=1.000000,AmbientOcclusionStaticFraction=1.000000,AmbientOcclusionRadius=73.477997,AmbientOcclusionRadiusInWS=False,AmbientOcclusionFadeDistance=8000.000000,AmbientOcclusionFadeRadius=5000.000000,AmbientOcclusionDistance=80.000000,AmbientOcclusionPower=1.200000,AmbientOcclusionBias=3.000000,AmbientOcclusionQuality=100.000000,AmbientOcclusionMipBlend=0.600000,AmbientOcclusionMipScale=1.700000,AmbientOcclusionMipThreshold=0.010000,IndirectLightingColor=(R=1.000000,G=1.000000,B=1.000000,A=1.000000),IndirectLightingIntensity=1.000000,ColorGradingIntensity=0.000000,ColorGradingLUT=Texture2D'/Engine/EditorResources/RGBTable16x1_AssetViewer.RGBTable16x1_AssetViewer',DepthOfFieldMethod=DOFM_BokehDOF,bMobileHQGaussian=False,DepthOfFieldFstop=4.000000,DepthOfFieldSensorWidth=24.576000,DepthOfFieldFocalDistance=1000.000000,DepthOfFieldDepthBlurAmount=1.000000,DepthOfFieldDepthBlurRadius=0.000000,DepthOfFieldFocalRegion=0.000000,DepthOfFieldNearTransitionRegion=300.000000,DepthOfFieldFarTransitionRegion=500.000000,DepthOfFieldScale=0.000000,DepthOfFieldMaxBokehSize=15.000000,DepthOfFieldNearBlurSize=15.000000,DepthOfFieldFarBlurSize=15.000000,DepthOfFieldBokehShape=None,DepthOfFieldOcclusion=0.400000,DepthOfFieldColorThreshold=1.000000,DepthOfFieldSizeThreshold=0.080000,DepthOfFieldSkyFocusDistance=0.000000,DepthOfFieldVignetteSize=200.000000,MotionBlurAmount=0.500000,MotionBlurMax=5.000000,MotionBlurPerObjectSize=0.500000,ScreenPercentage=100.000000,ScreenSpaceReflectionIntensity=100.000000,ScreenSpaceReflectionQuality=100.000000,ScreenSpaceReflectionMaxRoughness=1.000000,WeightedBlendables=(Array=),Blendables=),bPostProcessingEnabled=True,LightingRigRotation=109.389069,RotationSpeed=2.000000,DirectionalLightRotation=(Pitch=-40.000000,Yaw=-67.500000,Roll=0.000000))
12 | +Profiles=(ProfileName="Default",DirectionalLightIntensity=2.620000,DirectionalLightColor=(R=0.990000,G=0.839850,B=0.732600,A=1.000000),SkyLightIntensity=0.880000,bRotateLightingRig=False,bShowEnvironment=True,bShowFloor=True,EnvironmentCubeMapPath="/Engine/EditorMaterials/AssetViewer/EpicQuadPanorama_CC+EV1.EpicQuadPanorama_CC+EV1",PostProcessingSettings=(bOverride_WhiteTemp=True,bOverride_WhiteTint=False,bOverride_ColorSaturation=True,bOverride_ColorContrast=True,bOverride_ColorGamma=True,bOverride_ColorGain=True,bOverride_ColorOffset=True,bOverride_ColorSaturationShadows=False,bOverride_ColorContrastShadows=False,bOverride_ColorGammaShadows=False,bOverride_ColorGainShadows=False,bOverride_ColorOffsetShadows=False,bOverride_ColorSaturationMidtones=False,bOverride_ColorContrastMidtones=False,bOverride_ColorGammaMidtones=False,bOverride_ColorGainMidtones=False,bOverride_ColorOffsetMidtones=False,bOverride_ColorSaturationHighlights=False,bOverride_ColorContrastHighlights=False,bOverride_ColorGammaHighlights=False,bOverride_ColorGainHighlights=False,bOverride_ColorOffsetHighlights=False,bOverride_ColorCorrectionShadowsMax=False,bOverride_ColorCorrectionHighlightsMin=False,bOverride_FilmWhitePoint=False,bOverride_FilmSaturation=False,bOverride_FilmChannelMixerRed=False,bOverride_FilmChannelMixerGreen=False,bOverride_FilmChannelMixerBlue=False,bOverride_FilmContrast=False,bOverride_FilmDynamicRange=False,bOverride_FilmHealAmount=False,bOverride_FilmToeAmount=False,bOverride_FilmShadowTint=False,bOverride_FilmShadowTintBlend=False,bOverride_FilmShadowTintAmount=False,bOverride_FilmSlope=True,bOverride_FilmToe=True,bOverride_FilmShoulder=True,bOverride_FilmBlackClip=True,bOverride_FilmWhiteClip=True,bOverride_SceneColorTint=False,bOverride_SceneFringeIntensity=False,bOverride_AmbientCubemapTint=False,bOverride_AmbientCubemapIntensity=False,bOverride_BloomIntensity=True,bOverride_BloomThreshold=False,bOverride_Bloom1Tint=False,bOverride_Bloom1Size=False,bOverride_Bloom2Size=False,bOverride_Bloom2Tint=False,bOverride_Bloom3Tint=False,bOverride_Bloom3Size=False,bOverride_Bloom4Tint=False,bOverride_Bloom4Size=False,bOverride_Bloom5Tint=False,bOverride_Bloom5Size=False,bOverride_Bloom6Tint=False,bOverride_Bloom6Size=False,bOverride_BloomSizeScale=False,bOverride_BloomDirtMaskIntensity=False,bOverride_BloomDirtMaskTint=False,bOverride_BloomDirtMask=False,bOverride_AutoExposureMethod=True,bOverride_AutoExposureLowPercent=False,bOverride_AutoExposureHighPercent=False,bOverride_AutoExposureMinBrightness=True,bOverride_AutoExposureMaxBrightness=True,bOverride_AutoExposureSpeedUp=False,bOverride_AutoExposureSpeedDown=False,bOverride_AutoExposureBias=True,bOverride_HistogramLogMin=True,bOverride_HistogramLogMax=True,bOverride_LensFlareIntensity=False,bOverride_LensFlareTint=False,bOverride_LensFlareTints=False,bOverride_LensFlareBokehSize=False,bOverride_LensFlareBokehShape=False,bOverride_LensFlareThreshold=False,bOverride_VignetteIntensity=True,bOverride_GrainIntensity=False,bOverride_GrainJitter=False,bOverride_AmbientOcclusionIntensity=True,bOverride_AmbientOcclusionStaticFraction=True,bOverride_AmbientOcclusionRadius=True,bOverride_AmbientOcclusionFadeDistance=False,bOverride_AmbientOcclusionFadeRadius=False,bOverride_AmbientOcclusionDistance=False,bOverride_AmbientOcclusionRadiusInWS=False,bOverride_AmbientOcclusionPower=True,bOverride_AmbientOcclusionBias=True,bOverride_AmbientOcclusionQuality=True,bOverride_AmbientOcclusionMipBlend=True,bOverride_AmbientOcclusionMipScale=True,bOverride_AmbientOcclusionMipThreshold=True,bOverride_LPVIntensity=False,bOverride_LPVDirectionalOcclusionIntensity=False,bOverride_LPVDirectionalOcclusionRadius=False,bOverride_LPVDiffuseOcclusionExponent=False,bOverride_LPVSpecularOcclusionExponent=False,bOverride_LPVDiffuseOcclusionIntensity=False,bOverride_LPVSpecularOcclusionIntensity=False,bOverride_LPVSize=False,bOverride_LPVSecondaryOcclusionIntensity=False,bOverride_LPVSecondaryBounceIntensity=False,bOverride_LPVGeometryVolumeBias=False,bOverride_LPVVplInjectionBias=False,bOverride_LPVEmissiveInjectionIntensity=False,bOverride_IndirectLightingColor=False,bOverride_IndirectLightingIntensity=False,bOverride_ColorGradingIntensity=True,bOverride_ColorGradingLUT=True,bOverride_DepthOfFieldFocalDistance=False,bOverride_DepthOfFieldFstop=False,bOverride_DepthOfFieldSensorWidth=False,bOverride_DepthOfFieldDepthBlurRadius=False,bOverride_DepthOfFieldDepthBlurAmount=False,bOverride_DepthOfFieldFocalRegion=False,bOverride_DepthOfFieldNearTransitionRegion=False,bOverride_DepthOfFieldFarTransitionRegion=False,bOverride_DepthOfFieldScale=True,bOverride_DepthOfFieldMaxBokehSize=False,bOverride_DepthOfFieldNearBlurSize=False,bOverride_DepthOfFieldFarBlurSize=False,bOverride_DepthOfFieldMethod=True,bOverride_MobileHQGaussian=False,bOverride_DepthOfFieldBokehShape=False,bOverride_DepthOfFieldOcclusion=False,bOverride_DepthOfFieldColorThreshold=False,bOverride_DepthOfFieldSizeThreshold=False,bOverride_DepthOfFieldSkyFocusDistance=False,bOverride_DepthOfFieldVignetteSize=False,bOverride_MotionBlurAmount=False,bOverride_MotionBlurMax=False,bOverride_MotionBlurPerObjectSize=False,bOverride_ScreenPercentage=False,bOverride_ScreenSpaceReflectionIntensity=True,bOverride_ScreenSpaceReflectionQuality=True,bOverride_ScreenSpaceReflectionMaxRoughness=True,bOverride_ScreenSpaceReflectionRoughnessScale=False,WhiteTemp=6700.000000,WhiteTint=0.000000,ColorSaturation=(X=1.000000,Y=1.000000,Z=1.000000,W=1.000000),ColorContrast=(X=1.000000,Y=1.000000,Z=1.000000,W=1.000000),ColorGamma=(X=1.000000,Y=1.000000,Z=1.000000,W=1.000000),ColorGain=(X=1.000000,Y=1.000000,Z=1.000000,W=1.000000),ColorOffset=(X=0.005000,Y=0.005000,Z=0.005000,W=0.000000),ColorSaturationShadows=(X=1.000000,Y=1.000000,Z=1.000000,W=1.000000),ColorContrastShadows=(X=1.000000,Y=1.000000,Z=1.000000,W=1.000000),ColorGammaShadows=(X=1.000000,Y=1.000000,Z=1.000000,W=1.000000),ColorGainShadows=(X=1.000000,Y=1.000000,Z=1.000000,W=1.000000),ColorOffsetShadows=(X=0.000000,Y=0.000000,Z=0.000000,W=0.000000),ColorCorrectionShadowsMax=0.090000,ColorSaturationMidtones=(X=1.000000,Y=1.000000,Z=1.000000,W=1.000000),ColorContrastMidtones=(X=1.000000,Y=1.000000,Z=1.000000,W=1.000000),ColorGammaMidtones=(X=1.000000,Y=1.000000,Z=1.000000,W=1.000000),ColorGainMidtones=(X=1.000000,Y=1.000000,Z=1.000000,W=1.000000),ColorOffsetMidtones=(X=0.000000,Y=0.000000,Z=0.000000,W=0.000000),ColorSaturationHighlights=(X=1.000000,Y=1.000000,Z=1.000000,W=1.000000),ColorContrastHighlights=(X=1.000000,Y=1.000000,Z=1.000000,W=1.000000),ColorGammaHighlights=(X=1.000000,Y=1.000000,Z=1.000000,W=1.000000),ColorGainHighlights=(X=1.000000,Y=1.000000,Z=1.000000,W=1.000000),ColorOffsetHighlights=(X=0.000000,Y=0.000000,Z=0.000000,W=0.000000),ColorCorrectionHighlightsMin=0.500000,FilmWhitePoint=(R=1.000000,G=1.000000,B=1.000000,A=1.000000),FilmShadowTint=(R=1.000000,G=1.000000,B=1.000000,A=1.000000),FilmShadowTintBlend=0.500000,FilmShadowTintAmount=0.000000,FilmSaturation=1.000000,FilmChannelMixerRed=(R=1.000000,G=0.000000,B=0.000000,A=1.000000),FilmChannelMixerGreen=(R=0.000000,G=1.000000,B=0.000000,A=1.000000),FilmChannelMixerBlue=(R=0.000000,G=0.000000,B=1.000000,A=1.000000),FilmContrast=0.030000,FilmToeAmount=1.000000,FilmHealAmount=1.000000,FilmDynamicRange=4.000000,FilmSlope=0.880000,FilmToe=0.550000,FilmShoulder=0.260000,FilmBlackClip=0.000000,FilmWhiteClip=0.040000,SceneColorTint=(R=1.000000,G=1.000000,B=1.000000,A=1.000000),SceneFringeIntensity=0.000000,BloomIntensity=0.675000,BloomThreshold=-1.000000,BloomSizeScale=4.000000,Bloom1Size=0.300000,Bloom2Size=1.000000,Bloom3Size=2.000000,Bloom4Size=10.000000,Bloom5Size=30.000000,Bloom6Size=64.000000,Bloom1Tint=(R=0.346500,G=0.346500,B=0.346500,A=1.000000),Bloom2Tint=(R=0.138000,G=0.138000,B=0.138000,A=1.000000),Bloom3Tint=(R=0.117600,G=0.117600,B=0.117600,A=1.000000),Bloom4Tint=(R=0.066000,G=0.066000,B=0.066000,A=1.000000),Bloom5Tint=(R=0.066000,G=0.066000,B=0.066000,A=1.000000),Bloom6Tint=(R=0.061000,G=0.061000,B=0.061000,A=1.000000),BloomDirtMaskIntensity=0.000000,BloomDirtMaskTint=(R=0.500000,G=0.500000,B=0.500000,A=1.000000),BloomDirtMask=None,AmbientCubemapTint=(R=1.000000,G=1.000000,B=1.000000,A=1.000000),AmbientCubemapIntensity=1.000000,AmbientCubemap=None,AutoExposureMethod=AEM_Histogram,AutoExposureLowPercent=80.000000,AutoExposureHighPercent=98.300003,AutoExposureMinBrightness=1.000000,AutoExposureMaxBrightness=1.000000,AutoExposureSpeedUp=3.000000,AutoExposureSpeedDown=1.000000,AutoExposureBias=0.330000,HistogramLogMin=-8.000000,HistogramLogMax=4.000000,LensFlareIntensity=1.000000,LensFlareTint=(R=1.000000,G=1.000000,B=1.000000,A=1.000000),LensFlareBokehSize=3.000000,LensFlareThreshold=8.000000,LensFlareBokehShape=None,LensFlareTints[0]=(R=1.000000,G=0.800000,B=0.400000,A=0.600000),LensFlareTints[1]=(R=1.000000,G=1.000000,B=0.600000,A=0.530000),LensFlareTints[2]=(R=0.800000,G=0.800000,B=1.000000,A=0.460000),LensFlareTints[3]=(R=0.500000,G=1.000000,B=0.400000,A=0.390000),LensFlareTints[4]=(R=0.500000,G=0.800000,B=1.000000,A=0.310000),LensFlareTints[5]=(R=0.900000,G=1.000000,B=0.800000,A=0.270000),LensFlareTints[6]=(R=1.000000,G=0.800000,B=0.400000,A=0.220000),LensFlareTints[7]=(R=0.900000,G=0.700000,B=0.700000,A=0.150000),VignetteIntensity=0.161468,GrainJitter=0.000000,GrainIntensity=0.000000,AmbientOcclusionIntensity=1.000000,AmbientOcclusionStaticFraction=1.000000,AmbientOcclusionRadius=73.477997,AmbientOcclusionRadiusInWS=False,AmbientOcclusionFadeDistance=8000.000000,AmbientOcclusionFadeRadius=5000.000000,AmbientOcclusionDistance=80.000000,AmbientOcclusionPower=1.200000,AmbientOcclusionBias=3.000000,AmbientOcclusionQuality=100.000000,AmbientOcclusionMipBlend=0.600000,AmbientOcclusionMipScale=1.700000,AmbientOcclusionMipThreshold=0.010000,IndirectLightingColor=(R=1.000000,G=1.000000,B=1.000000,A=1.000000),IndirectLightingIntensity=1.000000,ColorGradingIntensity=0.000000,ColorGradingLUT=Texture2D'/Engine/EditorResources/RGBTable16x1_AssetViewer.RGBTable16x1_AssetViewer',DepthOfFieldMethod=DOFM_BokehDOF,bMobileHQGaussian=False,DepthOfFieldFstop=4.000000,DepthOfFieldSensorWidth=24.576000,DepthOfFieldFocalDistance=1000.000000,DepthOfFieldDepthBlurAmount=1.000000,DepthOfFieldDepthBlurRadius=0.000000,DepthOfFieldFocalRegion=0.000000,DepthOfFieldNearTransitionRegion=300.000000,DepthOfFieldFarTransitionRegion=500.000000,DepthOfFieldScale=0.000000,DepthOfFieldMaxBokehSize=15.000000,DepthOfFieldNearBlurSize=15.000000,DepthOfFieldFarBlurSize=15.000000,DepthOfFieldBokehShape=None,DepthOfFieldOcclusion=0.400000,DepthOfFieldColorThreshold=1.000000,DepthOfFieldSizeThreshold=0.080000,DepthOfFieldSkyFocusDistance=0.000000,DepthOfFieldVignetteSize=200.000000,MotionBlurAmount=0.500000,MotionBlurMax=5.000000,MotionBlurPerObjectSize=0.500000,LPVIntensity=1.000000,LPVVplInjectionBias=0.640000,LPVSize=5312.000000,LPVSecondaryOcclusionIntensity=0.000000,LPVSecondaryBounceIntensity=0.000000,LPVGeometryVolumeBias=0.384000,LPVEmissiveInjectionIntensity=1.000000,LPVDirectionalOcclusionIntensity=0.000000,LPVDirectionalOcclusionRadius=8.000000,LPVDiffuseOcclusionExponent=1.000000,LPVSpecularOcclusionExponent=7.000000,LPVDiffuseOcclusionIntensity=1.000000,LPVSpecularOcclusionIntensity=1.000000,ScreenSpaceReflectionIntensity=100.000000,ScreenSpaceReflectionQuality=100.000000,ScreenSpaceReflectionMaxRoughness=1.000000,ScreenPercentage=100.000000,WeightedBlendables=(Array=),Blendables=),bPostProcessingEnabled=True,LightingRigRotation=109.389069,RotationSpeed=2.000000,DirectionalLightRotation=(Pitch=-39.999985,Yaw=-67.500015,Roll=0.000000))
13 | +Profiles=(ProfileName="Default",DirectionalLightIntensity=2.620000,DirectionalLightColor=(R=0.990000,G=0.839850,B=0.732600,A=1.000000),SkyLightIntensity=0.880000,bRotateLightingRig=False,bShowEnvironment=True,bShowFloor=True,EnvironmentCubeMapPath="/Engine/EditorMaterials/AssetViewer/EpicQuadPanorama_CC+EV1.EpicQuadPanorama_CC+EV1",PostProcessingSettings=(bOverride_WhiteTemp=True,bOverride_WhiteTint=False,bOverride_ColorSaturation=True,bOverride_ColorContrast=True,bOverride_ColorGamma=True,bOverride_ColorGain=True,bOverride_ColorOffset=True,bOverride_ColorSaturationShadows=False,bOverride_ColorContrastShadows=False,bOverride_ColorGammaShadows=False,bOverride_ColorGainShadows=False,bOverride_ColorOffsetShadows=False,bOverride_ColorSaturationMidtones=False,bOverride_ColorContrastMidtones=False,bOverride_ColorGammaMidtones=False,bOverride_ColorGainMidtones=False,bOverride_ColorOffsetMidtones=False,bOverride_ColorSaturationHighlights=False,bOverride_ColorContrastHighlights=False,bOverride_ColorGammaHighlights=False,bOverride_ColorGainHighlights=False,bOverride_ColorOffsetHighlights=False,bOverride_ColorCorrectionShadowsMax=False,bOverride_ColorCorrectionHighlightsMin=False,bOverride_FilmWhitePoint=False,bOverride_FilmSaturation=False,bOverride_FilmChannelMixerRed=False,bOverride_FilmChannelMixerGreen=False,bOverride_FilmChannelMixerBlue=False,bOverride_FilmContrast=False,bOverride_FilmDynamicRange=False,bOverride_FilmHealAmount=False,bOverride_FilmToeAmount=False,bOverride_FilmShadowTint=False,bOverride_FilmShadowTintBlend=False,bOverride_FilmShadowTintAmount=False,bOverride_FilmSlope=True,bOverride_FilmToe=True,bOverride_FilmShoulder=True,bOverride_FilmBlackClip=True,bOverride_FilmWhiteClip=True,bOverride_SceneColorTint=False,bOverride_SceneFringeIntensity=False,bOverride_AmbientCubemapTint=False,bOverride_AmbientCubemapIntensity=False,bOverride_BloomIntensity=True,bOverride_BloomThreshold=False,bOverride_Bloom1Tint=False,bOverride_Bloom1Size=False,bOverride_Bloom2Size=False,bOverride_Bloom2Tint=False,bOverride_Bloom3Tint=False,bOverride_Bloom3Size=False,bOverride_Bloom4Tint=False,bOverride_Bloom4Size=False,bOverride_Bloom5Tint=False,bOverride_Bloom5Size=False,bOverride_Bloom6Tint=False,bOverride_Bloom6Size=False,bOverride_BloomSizeScale=False,bOverride_BloomDirtMaskIntensity=False,bOverride_BloomDirtMaskTint=False,bOverride_BloomDirtMask=False,bOverride_AutoExposureMethod=True,bOverride_AutoExposureLowPercent=False,bOverride_AutoExposureHighPercent=False,bOverride_AutoExposureMinBrightness=True,bOverride_AutoExposureMaxBrightness=True,bOverride_AutoExposureSpeedUp=False,bOverride_AutoExposureSpeedDown=False,bOverride_AutoExposureBias=True,bOverride_HistogramLogMin=True,bOverride_HistogramLogMax=True,bOverride_LensFlareIntensity=False,bOverride_LensFlareTint=False,bOverride_LensFlareTints=False,bOverride_LensFlareBokehSize=False,bOverride_LensFlareBokehShape=False,bOverride_LensFlareThreshold=False,bOverride_VignetteIntensity=True,bOverride_GrainIntensity=False,bOverride_GrainJitter=False,bOverride_AmbientOcclusionIntensity=True,bOverride_AmbientOcclusionStaticFraction=True,bOverride_AmbientOcclusionRadius=True,bOverride_AmbientOcclusionFadeDistance=False,bOverride_AmbientOcclusionFadeRadius=False,bOverride_AmbientOcclusionDistance=False,bOverride_AmbientOcclusionRadiusInWS=False,bOverride_AmbientOcclusionPower=True,bOverride_AmbientOcclusionBias=True,bOverride_AmbientOcclusionQuality=True,bOverride_AmbientOcclusionMipBlend=True,bOverride_AmbientOcclusionMipScale=True,bOverride_AmbientOcclusionMipThreshold=True,bOverride_LPVIntensity=False,bOverride_LPVDirectionalOcclusionIntensity=False,bOverride_LPVDirectionalOcclusionRadius=False,bOverride_LPVDiffuseOcclusionExponent=False,bOverride_LPVSpecularOcclusionExponent=False,bOverride_LPVDiffuseOcclusionIntensity=False,bOverride_LPVSpecularOcclusionIntensity=False,bOverride_LPVSize=False,bOverride_LPVSecondaryOcclusionIntensity=False,bOverride_LPVSecondaryBounceIntensity=False,bOverride_LPVGeometryVolumeBias=False,bOverride_LPVVplInjectionBias=False,bOverride_LPVEmissiveInjectionIntensity=False,bOverride_IndirectLightingColor=False,bOverride_IndirectLightingIntensity=False,bOverride_ColorGradingIntensity=True,bOverride_ColorGradingLUT=True,bOverride_DepthOfFieldFocalDistance=False,bOverride_DepthOfFieldFstop=False,bOverride_DepthOfFieldSensorWidth=False,bOverride_DepthOfFieldDepthBlurRadius=False,bOverride_DepthOfFieldDepthBlurAmount=False,bOverride_DepthOfFieldFocalRegion=False,bOverride_DepthOfFieldNearTransitionRegion=False,bOverride_DepthOfFieldFarTransitionRegion=False,bOverride_DepthOfFieldScale=True,bOverride_DepthOfFieldMaxBokehSize=False,bOverride_DepthOfFieldNearBlurSize=False,bOverride_DepthOfFieldFarBlurSize=False,bOverride_DepthOfFieldMethod=True,bOverride_MobileHQGaussian=False,bOverride_DepthOfFieldBokehShape=False,bOverride_DepthOfFieldOcclusion=False,bOverride_DepthOfFieldColorThreshold=False,bOverride_DepthOfFieldSizeThreshold=False,bOverride_DepthOfFieldSkyFocusDistance=False,bOverride_DepthOfFieldVignetteSize=False,bOverride_MotionBlurAmount=False,bOverride_MotionBlurMax=False,bOverride_MotionBlurPerObjectSize=False,bOverride_ScreenPercentage=False,bOverride_ScreenSpaceReflectionIntensity=True,bOverride_ScreenSpaceReflectionQuality=True,bOverride_ScreenSpaceReflectionMaxRoughness=True,bOverride_ScreenSpaceReflectionRoughnessScale=False,WhiteTemp=6700.000000,WhiteTint=0.000000,ColorSaturation=(X=1.000000,Y=1.000000,Z=1.000000,W=1.000000),ColorContrast=(X=1.000000,Y=1.000000,Z=1.000000,W=1.000000),ColorGamma=(X=1.000000,Y=1.000000,Z=1.000000,W=1.000000),ColorGain=(X=1.000000,Y=1.000000,Z=1.000000,W=1.000000),ColorOffset=(X=0.005000,Y=0.005000,Z=0.005000,W=0.000000),ColorSaturationShadows=(X=1.000000,Y=1.000000,Z=1.000000,W=1.000000),ColorContrastShadows=(X=1.000000,Y=1.000000,Z=1.000000,W=1.000000),ColorGammaShadows=(X=1.000000,Y=1.000000,Z=1.000000,W=1.000000),ColorGainShadows=(X=1.000000,Y=1.000000,Z=1.000000,W=1.000000),ColorOffsetShadows=(X=0.000000,Y=0.000000,Z=0.000000,W=0.000000),ColorCorrectionShadowsMax=0.090000,ColorSaturationMidtones=(X=1.000000,Y=1.000000,Z=1.000000,W=1.000000),ColorContrastMidtones=(X=1.000000,Y=1.000000,Z=1.000000,W=1.000000),ColorGammaMidtones=(X=1.000000,Y=1.000000,Z=1.000000,W=1.000000),ColorGainMidtones=(X=1.000000,Y=1.000000,Z=1.000000,W=1.000000),ColorOffsetMidtones=(X=0.000000,Y=0.000000,Z=0.000000,W=0.000000),ColorSaturationHighlights=(X=1.000000,Y=1.000000,Z=1.000000,W=1.000000),ColorContrastHighlights=(X=1.000000,Y=1.000000,Z=1.000000,W=1.000000),ColorGammaHighlights=(X=1.000000,Y=1.000000,Z=1.000000,W=1.000000),ColorGainHighlights=(X=1.000000,Y=1.000000,Z=1.000000,W=1.000000),ColorOffsetHighlights=(X=0.000000,Y=0.000000,Z=0.000000,W=0.000000),ColorCorrectionHighlightsMin=0.500000,FilmWhitePoint=(R=1.000000,G=1.000000,B=1.000000,A=1.000000),FilmShadowTint=(R=1.000000,G=1.000000,B=1.000000,A=1.000000),FilmShadowTintBlend=0.500000,FilmShadowTintAmount=0.000000,FilmSaturation=1.000000,FilmChannelMixerRed=(R=1.000000,G=0.000000,B=0.000000,A=1.000000),FilmChannelMixerGreen=(R=0.000000,G=1.000000,B=0.000000,A=1.000000),FilmChannelMixerBlue=(R=0.000000,G=0.000000,B=1.000000,A=1.000000),FilmContrast=0.030000,FilmToeAmount=1.000000,FilmHealAmount=0.180000,FilmDynamicRange=4.000000,FilmSlope=0.880000,FilmToe=0.550000,FilmShoulder=0.260000,FilmBlackClip=0.000000,FilmWhiteClip=0.040000,SceneColorTint=(R=1.000000,G=1.000000,B=1.000000,A=1.000000),SceneFringeIntensity=0.000000,BloomIntensity=1.000000,BloomThreshold=1.000000,BloomSizeScale=4.000000,Bloom1Size=1.000000,Bloom2Size=4.000000,Bloom3Size=16.000000,Bloom4Size=32.000000,Bloom5Size=64.000000,Bloom6Size=64.000000,Bloom1Tint=(R=0.500000,G=0.500000,B=0.500000,A=1.000000),Bloom2Tint=(R=0.500000,G=0.500000,B=0.500000,A=1.000000),Bloom3Tint=(R=0.500000,G=0.500000,B=0.500000,A=1.000000),Bloom4Tint=(R=0.500000,G=0.500000,B=0.500000,A=1.000000),Bloom5Tint=(R=0.500000,G=0.500000,B=0.500000,A=1.000000),Bloom6Tint=(R=0.500000,G=0.500000,B=0.500000,A=1.000000),BloomDirtMaskIntensity=1.000000,BloomDirtMaskTint=(R=0.500000,G=0.500000,B=0.500000,A=1.000000),BloomDirtMask=None,AmbientCubemapTint=(R=1.000000,G=1.000000,B=1.000000,A=1.000000),AmbientCubemapIntensity=1.000000,AmbientCubemap=None,AutoExposureMethod=AEM_Histogram,AutoExposureLowPercent=80.000000,AutoExposureHighPercent=98.300003,AutoExposureMinBrightness=1.000000,AutoExposureMaxBrightness=1.000000,AutoExposureSpeedUp=3.000000,AutoExposureSpeedDown=1.000000,AutoExposureBias=0.330000,HistogramLogMin=-8.000000,HistogramLogMax=4.000000,LensFlareIntensity=1.000000,LensFlareTint=(R=1.000000,G=1.000000,B=1.000000,A=1.000000),LensFlareBokehSize=3.000000,LensFlareThreshold=8.000000,LensFlareBokehShape=None,LensFlareTints[0]=(R=1.000000,G=0.800000,B=0.400000,A=0.600000),LensFlareTints[1]=(R=1.000000,G=1.000000,B=0.600000,A=0.530000),LensFlareTints[2]=(R=0.800000,G=0.800000,B=1.000000,A=0.460000),LensFlareTints[3]=(R=0.500000,G=1.000000,B=0.400000,A=0.390000),LensFlareTints[4]=(R=0.500000,G=0.800000,B=1.000000,A=0.310000),LensFlareTints[5]=(R=0.900000,G=1.000000,B=0.800000,A=0.270000),LensFlareTints[6]=(R=1.000000,G=0.800000,B=0.400000,A=0.220000),LensFlareTints[7]=(R=0.900000,G=0.700000,B=0.700000,A=0.150000),VignetteIntensity=0.161468,GrainJitter=0.000000,GrainIntensity=0.000000,AmbientOcclusionIntensity=1.000000,AmbientOcclusionStaticFraction=1.000000,AmbientOcclusionRadius=73.477997,AmbientOcclusionRadiusInWS=False,AmbientOcclusionFadeDistance=8000.000000,AmbientOcclusionFadeRadius=5000.000000,AmbientOcclusionDistance=80.000000,AmbientOcclusionPower=1.200000,AmbientOcclusionBias=3.000000,AmbientOcclusionQuality=100.000000,AmbientOcclusionMipBlend=0.600000,AmbientOcclusionMipScale=1.700000,AmbientOcclusionMipThreshold=0.010000,IndirectLightingColor=(R=1.000000,G=1.000000,B=1.000000,A=1.000000),IndirectLightingIntensity=1.000000,ColorGradingIntensity=0.000000,ColorGradingLUT=Texture2D'/Engine/EditorResources/RGBTable16x1_AssetViewer.RGBTable16x1_AssetViewer',DepthOfFieldMethod=DOFM_BokehDOF,bMobileHQGaussian=False,DepthOfFieldFstop=4.000000,DepthOfFieldSensorWidth=24.576000,DepthOfFieldFocalDistance=1000.000000,DepthOfFieldDepthBlurAmount=1.000000,DepthOfFieldDepthBlurRadius=0.000000,DepthOfFieldFocalRegion=0.000000,DepthOfFieldNearTransitionRegion=300.000000,DepthOfFieldFarTransitionRegion=500.000000,DepthOfFieldScale=0.000000,DepthOfFieldMaxBokehSize=15.000000,DepthOfFieldNearBlurSize=15.000000,DepthOfFieldFarBlurSize=15.000000,DepthOfFieldBokehShape=None,DepthOfFieldOcclusion=0.400000,DepthOfFieldColorThreshold=1.000000,DepthOfFieldSizeThreshold=0.080000,DepthOfFieldSkyFocusDistance=0.000000,DepthOfFieldVignetteSize=200.000000,MotionBlurAmount=0.500000,MotionBlurMax=5.000000,MotionBlurPerObjectSize=0.500000,LPVIntensity=1.000000,LPVVplInjectionBias=0.640000,LPVSize=5312.000000,LPVSecondaryOcclusionIntensity=0.000000,LPVSecondaryBounceIntensity=0.000000,LPVGeometryVolumeBias=0.384000,LPVEmissiveInjectionIntensity=1.000000,LPVDirectionalOcclusionIntensity=0.000000,LPVDirectionalOcclusionRadius=8.000000,LPVDiffuseOcclusionExponent=1.000000,LPVSpecularOcclusionExponent=7.000000,LPVDiffuseOcclusionIntensity=1.000000,LPVSpecularOcclusionIntensity=1.000000,ScreenSpaceReflectionIntensity=100.000000,ScreenSpaceReflectionQuality=100.000000,ScreenSpaceReflectionMaxRoughness=1.000000,ScreenPercentage=100.000000,WeightedBlendables=(Array=),Blendables=),bPostProcessingEnabled=True,LightingRigRotation=109.389069,RotationSpeed=2.000000,DirectionalLightRotation=(Pitch=-39.999985,Yaw=-67.500015,Roll=0.000000))
14 | +Profiles=(ProfileName="Default",DirectionalLightIntensity=2.620000,DirectionalLightColor=(R=0.990000,G=0.839850,B=0.732600,A=1.000000),SkyLightIntensity=0.880000,bRotateLightingRig=False,bShowEnvironment=True,bShowFloor=True,EnvironmentCubeMapPath="",PostProcessingSettings=(bOverride_WhiteTemp=True,bOverride_WhiteTint=False,bOverride_ColorSaturation=True,bOverride_ColorContrast=True,bOverride_ColorGamma=True,bOverride_ColorGain=True,bOverride_ColorOffset=True,bOverride_ColorSaturationShadows=False,bOverride_ColorContrastShadows=False,bOverride_ColorGammaShadows=False,bOverride_ColorGainShadows=False,bOverride_ColorOffsetShadows=False,bOverride_ColorSaturationMidtones=False,bOverride_ColorContrastMidtones=False,bOverride_ColorGammaMidtones=False,bOverride_ColorGainMidtones=False,bOverride_ColorOffsetMidtones=False,bOverride_ColorSaturationHighlights=False,bOverride_ColorContrastHighlights=False,bOverride_ColorGammaHighlights=False,bOverride_ColorGainHighlights=False,bOverride_ColorOffsetHighlights=False,bOverride_ColorCorrectionShadowsMax=False,bOverride_ColorCorrectionHighlightsMin=False,bOverride_FilmWhitePoint=False,bOverride_FilmSaturation=False,bOverride_FilmChannelMixerRed=False,bOverride_FilmChannelMixerGreen=False,bOverride_FilmChannelMixerBlue=False,bOverride_FilmContrast=False,bOverride_FilmDynamicRange=False,bOverride_FilmHealAmount=False,bOverride_FilmToeAmount=False,bOverride_FilmShadowTint=False,bOverride_FilmShadowTintBlend=False,bOverride_FilmShadowTintAmount=False,bOverride_FilmSlope=True,bOverride_FilmToe=True,bOverride_FilmShoulder=True,bOverride_FilmBlackClip=True,bOverride_FilmWhiteClip=True,bOverride_SceneColorTint=False,bOverride_SceneFringeIntensity=False,bOverride_AmbientCubemapTint=False,bOverride_AmbientCubemapIntensity=False,bOverride_BloomIntensity=True,bOverride_BloomThreshold=False,bOverride_Bloom1Tint=False,bOverride_Bloom1Size=False,bOverride_Bloom2Size=False,bOverride_Bloom2Tint=False,bOverride_Bloom3Tint=False,bOverride_Bloom3Size=False,bOverride_Bloom4Tint=False,bOverride_Bloom4Size=False,bOverride_Bloom5Tint=False,bOverride_Bloom5Size=False,bOverride_Bloom6Tint=False,bOverride_Bloom6Size=False,bOverride_BloomSizeScale=False,bOverride_BloomDirtMaskIntensity=False,bOverride_BloomDirtMaskTint=False,bOverride_BloomDirtMask=False,bOverride_AutoExposureMethod=True,bOverride_AutoExposureLowPercent=False,bOverride_AutoExposureHighPercent=False,bOverride_AutoExposureMinBrightness=True,bOverride_AutoExposureMaxBrightness=True,bOverride_AutoExposureSpeedUp=False,bOverride_AutoExposureSpeedDown=False,bOverride_AutoExposureBias=True,bOverride_HistogramLogMin=True,bOverride_HistogramLogMax=True,bOverride_LensFlareIntensity=False,bOverride_LensFlareTint=False,bOverride_LensFlareTints=False,bOverride_LensFlareBokehSize=False,bOverride_LensFlareBokehShape=False,bOverride_LensFlareThreshold=False,bOverride_VignetteIntensity=True,bOverride_GrainIntensity=False,bOverride_GrainJitter=False,bOverride_AmbientOcclusionIntensity=True,bOverride_AmbientOcclusionStaticFraction=True,bOverride_AmbientOcclusionRadius=True,bOverride_AmbientOcclusionFadeDistance=False,bOverride_AmbientOcclusionFadeRadius=False,bOverride_AmbientOcclusionDistance=False,bOverride_AmbientOcclusionRadiusInWS=False,bOverride_AmbientOcclusionPower=True,bOverride_AmbientOcclusionBias=True,bOverride_AmbientOcclusionQuality=True,bOverride_AmbientOcclusionMipBlend=True,bOverride_AmbientOcclusionMipScale=True,bOverride_AmbientOcclusionMipThreshold=True,bOverride_LPVIntensity=False,bOverride_LPVDirectionalOcclusionIntensity=False,bOverride_LPVDirectionalOcclusionRadius=False,bOverride_LPVDiffuseOcclusionExponent=False,bOverride_LPVSpecularOcclusionExponent=False,bOverride_LPVDiffuseOcclusionIntensity=False,bOverride_LPVSpecularOcclusionIntensity=False,bOverride_LPVSize=False,bOverride_LPVSecondaryOcclusionIntensity=False,bOverride_LPVSecondaryBounceIntensity=False,bOverride_LPVGeometryVolumeBias=False,bOverride_LPVVplInjectionBias=False,bOverride_LPVEmissiveInjectionIntensity=False,bOverride_IndirectLightingColor=False,bOverride_IndirectLightingIntensity=False,bOverride_ColorGradingIntensity=True,bOverride_ColorGradingLUT=True,bOverride_DepthOfFieldFocalDistance=False,bOverride_DepthOfFieldFstop=False,bOverride_DepthOfFieldSensorWidth=False,bOverride_DepthOfFieldDepthBlurRadius=False,bOverride_DepthOfFieldDepthBlurAmount=False,bOverride_DepthOfFieldFocalRegion=False,bOverride_DepthOfFieldNearTransitionRegion=False,bOverride_DepthOfFieldFarTransitionRegion=False,bOverride_DepthOfFieldScale=True,bOverride_DepthOfFieldMaxBokehSize=False,bOverride_DepthOfFieldNearBlurSize=False,bOverride_DepthOfFieldFarBlurSize=False,bOverride_DepthOfFieldMethod=True,bOverride_MobileHQGaussian=False,bOverride_DepthOfFieldBokehShape=False,bOverride_DepthOfFieldOcclusion=False,bOverride_DepthOfFieldColorThreshold=False,bOverride_DepthOfFieldSizeThreshold=False,bOverride_DepthOfFieldSkyFocusDistance=False,bOverride_DepthOfFieldVignetteSize=False,bOverride_MotionBlurAmount=False,bOverride_MotionBlurMax=False,bOverride_MotionBlurPerObjectSize=False,bOverride_ScreenPercentage=False,bOverride_ScreenSpaceReflectionIntensity=True,bOverride_ScreenSpaceReflectionQuality=True,bOverride_ScreenSpaceReflectionMaxRoughness=True,bOverride_ScreenSpaceReflectionRoughnessScale=False,WhiteTemp=6700.000000,WhiteTint=0.000000,ColorSaturation=(X=1.000000,Y=1.000000,Z=1.000000,W=1.000000),ColorContrast=(X=1.000000,Y=1.000000,Z=1.000000,W=1.000000),ColorGamma=(X=1.000000,Y=1.000000,Z=1.000000,W=1.000000),ColorGain=(X=1.000000,Y=1.000000,Z=1.000000,W=1.000000),ColorOffset=(X=0.005000,Y=0.005000,Z=0.005000,W=0.000000),ColorSaturationShadows=(X=1.000000,Y=1.000000,Z=1.000000,W=1.000000),ColorContrastShadows=(X=1.000000,Y=1.000000,Z=1.000000,W=1.000000),ColorGammaShadows=(X=1.000000,Y=1.000000,Z=1.000000,W=1.000000),ColorGainShadows=(X=1.000000,Y=1.000000,Z=1.000000,W=1.000000),ColorOffsetShadows=(X=0.000000,Y=0.000000,Z=0.000000,W=0.000000),ColorCorrectionShadowsMax=0.090000,ColorSaturationMidtones=(X=1.000000,Y=1.000000,Z=1.000000,W=1.000000),ColorContrastMidtones=(X=1.000000,Y=1.000000,Z=1.000000,W=1.000000),ColorGammaMidtones=(X=1.000000,Y=1.000000,Z=1.000000,W=1.000000),ColorGainMidtones=(X=1.000000,Y=1.000000,Z=1.000000,W=1.000000),ColorOffsetMidtones=(X=0.000000,Y=0.000000,Z=0.000000,W=0.000000),ColorSaturationHighlights=(X=1.000000,Y=1.000000,Z=1.000000,W=1.000000),ColorContrastHighlights=(X=1.000000,Y=1.000000,Z=1.000000,W=1.000000),ColorGammaHighlights=(X=1.000000,Y=1.000000,Z=1.000000,W=1.000000),ColorGainHighlights=(X=1.000000,Y=1.000000,Z=1.000000,W=1.000000),ColorOffsetHighlights=(X=0.000000,Y=0.000000,Z=0.000000,W=0.000000),ColorCorrectionHighlightsMin=0.500000,FilmWhitePoint=(R=1.000000,G=1.000000,B=1.000000,A=1.000000),FilmShadowTint=(R=1.000000,G=1.000000,B=1.000000,A=1.000000),FilmShadowTintBlend=0.500000,FilmShadowTintAmount=0.000000,FilmSaturation=1.000000,FilmChannelMixerRed=(R=1.000000,G=0.000000,B=0.000000,A=1.000000),FilmChannelMixerGreen=(R=0.000000,G=1.000000,B=0.000000,A=1.000000),FilmChannelMixerBlue=(R=0.000000,G=0.000000,B=1.000000,A=1.000000),FilmContrast=0.030000,FilmToeAmount=1.000000,FilmHealAmount=0.180000,FilmDynamicRange=4.000000,FilmSlope=0.880000,FilmToe=0.550000,FilmShoulder=0.260000,FilmBlackClip=0.000000,FilmWhiteClip=0.040000,SceneColorTint=(R=1.000000,G=1.000000,B=1.000000,A=1.000000),SceneFringeIntensity=0.000000,BloomIntensity=1.000000,BloomThreshold=1.000000,BloomSizeScale=4.000000,Bloom1Size=1.000000,Bloom2Size=4.000000,Bloom3Size=16.000000,Bloom4Size=32.000000,Bloom5Size=64.000000,Bloom6Size=64.000000,Bloom1Tint=(R=0.500000,G=0.500000,B=0.500000,A=1.000000),Bloom2Tint=(R=0.500000,G=0.500000,B=0.500000,A=1.000000),Bloom3Tint=(R=0.500000,G=0.500000,B=0.500000,A=1.000000),Bloom4Tint=(R=0.500000,G=0.500000,B=0.500000,A=1.000000),Bloom5Tint=(R=0.500000,G=0.500000,B=0.500000,A=1.000000),Bloom6Tint=(R=0.500000,G=0.500000,B=0.500000,A=1.000000),BloomDirtMaskIntensity=1.000000,BloomDirtMaskTint=(R=0.500000,G=0.500000,B=0.500000,A=1.000000),BloomDirtMask=None,AmbientCubemapTint=(R=1.000000,G=1.000000,B=1.000000,A=1.000000),AmbientCubemapIntensity=1.000000,AmbientCubemap=None,AutoExposureMethod=AEM_Histogram,AutoExposureLowPercent=80.000000,AutoExposureHighPercent=98.300003,AutoExposureMinBrightness=1.000000,AutoExposureMaxBrightness=1.000000,AutoExposureSpeedUp=3.000000,AutoExposureSpeedDown=1.000000,AutoExposureBias=0.330000,HistogramLogMin=-8.000000,HistogramLogMax=4.000000,LensFlareIntensity=1.000000,LensFlareTint=(R=1.000000,G=1.000000,B=1.000000,A=1.000000),LensFlareBokehSize=3.000000,LensFlareThreshold=8.000000,LensFlareBokehShape=None,LensFlareTints[0]=(R=1.000000,G=0.800000,B=0.400000,A=0.600000),LensFlareTints[1]=(R=1.000000,G=1.000000,B=0.600000,A=0.530000),LensFlareTints[2]=(R=0.800000,G=0.800000,B=1.000000,A=0.460000),LensFlareTints[3]=(R=0.500000,G=1.000000,B=0.400000,A=0.390000),LensFlareTints[4]=(R=0.500000,G=0.800000,B=1.000000,A=0.310000),LensFlareTints[5]=(R=0.900000,G=1.000000,B=0.800000,A=0.270000),LensFlareTints[6]=(R=1.000000,G=0.800000,B=0.400000,A=0.220000),LensFlareTints[7]=(R=0.900000,G=0.700000,B=0.700000,A=0.150000),VignetteIntensity=0.161468,GrainJitter=0.000000,GrainIntensity=0.000000,AmbientOcclusionIntensity=1.000000,AmbientOcclusionStaticFraction=1.000000,AmbientOcclusionRadius=73.477997,AmbientOcclusionRadiusInWS=False,AmbientOcclusionFadeDistance=8000.000000,AmbientOcclusionFadeRadius=5000.000000,AmbientOcclusionDistance=80.000000,AmbientOcclusionPower=1.200000,AmbientOcclusionBias=3.000000,AmbientOcclusionQuality=100.000000,AmbientOcclusionMipBlend=0.600000,AmbientOcclusionMipScale=1.700000,AmbientOcclusionMipThreshold=0.010000,IndirectLightingColor=(R=1.000000,G=1.000000,B=1.000000,A=1.000000),IndirectLightingIntensity=1.000000,ColorGradingIntensity=0.000000,ColorGradingLUT=Texture2D'/Engine/EditorResources/RGBTable16x1_AssetViewer.RGBTable16x1_AssetViewer',DepthOfFieldMethod=DOFM_BokehDOF,bMobileHQGaussian=False,DepthOfFieldFstop=4.000000,DepthOfFieldSensorWidth=24.576000,DepthOfFieldFocalDistance=1000.000000,DepthOfFieldDepthBlurAmount=1.000000,DepthOfFieldDepthBlurRadius=0.000000,DepthOfFieldFocalRegion=0.000000,DepthOfFieldNearTransitionRegion=300.000000,DepthOfFieldFarTransitionRegion=500.000000,DepthOfFieldScale=0.000000,DepthOfFieldMaxBokehSize=15.000000,DepthOfFieldNearBlurSize=15.000000,DepthOfFieldFarBlurSize=15.000000,DepthOfFieldBokehShape=None,DepthOfFieldOcclusion=0.400000,DepthOfFieldColorThreshold=1.000000,DepthOfFieldSizeThreshold=0.080000,DepthOfFieldSkyFocusDistance=0.000000,DepthOfFieldVignetteSize=200.000000,MotionBlurAmount=0.500000,MotionBlurMax=5.000000,MotionBlurPerObjectSize=0.500000,LPVIntensity=1.000000,LPVVplInjectionBias=0.640000,LPVSize=5312.000000,LPVSecondaryOcclusionIntensity=0.000000,LPVSecondaryBounceIntensity=0.000000,LPVGeometryVolumeBias=0.384000,LPVEmissiveInjectionIntensity=1.000000,LPVDirectionalOcclusionIntensity=0.000000,LPVDirectionalOcclusionRadius=8.000000,LPVDiffuseOcclusionExponent=1.000000,LPVSpecularOcclusionExponent=7.000000,LPVDiffuseOcclusionIntensity=1.000000,LPVSpecularOcclusionIntensity=1.000000,ScreenSpaceReflectionIntensity=100.000000,ScreenSpaceReflectionQuality=100.000000,ScreenSpaceReflectionMaxRoughness=1.000000,ScreenPercentage=100.000000,WeightedBlendables=(Array=),Blendables=),bPostProcessingEnabled=True,LightingRigRotation=109.389069,RotationSpeed=2.000000,DirectionalLightRotation=(Pitch=-39.999985,Yaw=-67.500015,Roll=0.000000))
15 |
16 |
--------------------------------------------------------------------------------
/UE4VoxelTerrain/Config/DefaultEditorPerProjectUserSettings.ini:
--------------------------------------------------------------------------------
1 | [ContentBrowser]
2 | ContentBrowserTab1.SelectedPaths=/Game/TopDown
3 |
4 | [/Script/SourceCodeAccess.SourceCodeAccessSettings]
5 | PreferredAccessor=VisualStudio2017
6 |
7 |
--------------------------------------------------------------------------------
/UE4VoxelTerrain/Config/DefaultEngine.ini:
--------------------------------------------------------------------------------
1 | [/Script/EngineSettings.GameMapsSettings]
2 | GameDefaultMap=/Game/Sandbox/FirstMenuMap.FirstMenuMap
3 | EditorStartupMap=/Game/Sandbox/MainMap.MainMap
4 | GlobalDefaultGameMode="/Script/UE4VoxelTerrain.UE4VoxelTerrainGameMode"
5 |
6 |
7 | [/Script/Engine.Engine]
8 | +ActiveGameNameRedirects=(OldGameName="TP_TopDown",NewGameName="/Script/UE4VoxelTerrain")
9 | +ActiveGameNameRedirects=(OldGameName="/Script/TP_TopDown",NewGameName="/Script/UE4VoxelTerrain")
10 | +ActiveClassRedirects=(OldClassName="TP_TopDownPlayerController",NewClassName="UE4VoxelTerrainPlayerController")
11 | +ActiveClassRedirects=(OldClassName="TP_TopDownGameMode",NewClassName="UE4VoxelTerrainGameMode")
12 | +ActiveClassRedirects=(OldClassName="TP_TopDownCharacter",NewClassName="UE4VoxelTerrainCharacter")
13 |
14 | [/Script/HardwareTargeting.HardwareTargetingSettings]
15 | TargetedHardwareClass=Desktop
16 | AppliedTargetedHardwareClass=Desktop
17 | DefaultGraphicsPerformance=Maximum
18 | AppliedDefaultGraphicsPerformance=Maximum
19 |
20 | [/Script/Engine.RecastNavMesh]
21 | RuntimeGeneration=Dynamic
22 | bForceRebuildOnLoad=True
23 |
24 | [/Script/Engine.RendererSettings]
25 | r.AllowStaticLighting=False
26 | r.SupportSkyAtmosphereAffectsHeightFog=True
27 |
28 | [/Script/Engine.UserInterfaceSettings]
29 | RenderFocusRule=NavigationOnly
30 | DefaultCursor=None
31 | TextEditBeamCursor=None
32 | CrosshairsCursor=None
33 | GrabHandCursor=None
34 | GrabHandClosedCursor=None
35 | SlashedCircleCursor=None
36 | ApplicationScale=1.000000
37 | UIScaleRule=ShortestSide
38 | CustomScalingRuleClass=None
39 | UIScaleCurve=(EditorCurveData=(PreInfinityExtrap=RCCE_Constant,PostInfinityExtrap=RCCE_Constant,Keys=((Time=480.000000,Value=0.444000),(Time=720.000000,Value=0.666000),(Time=1080.000000,Value=1.000000),(Time=8640.000000,Value=8.000000)),DefaultValue=340282346638528859811704183484516925440.000000),ExternalCurve=None)
40 |
41 | [/Script/Engine.PhysicsSettings]
42 | DefaultGravityZ=-980.000000
43 | DefaultTerminalVelocity=4000.000000
44 | DefaultFluidFriction=0.300000
45 | SimulateScratchMemorySize=262144
46 | RagdollAggregateThreshold=4
47 | TriangleMeshTriangleMinAreaThreshold=5.000000
48 | bEnableAsyncScene=False
49 | bEnableShapeSharing=False
50 | bEnablePCM=False
51 | bEnableStabilization=False
52 | bWarnMissingLocks=True
53 | bEnable2DPhysics=False
54 | PhysicErrorCorrection=(PingExtrapolation=0.100000,ErrorPerLinearDifference=1.000000,ErrorPerAngularDifference=1.000000,MaxRestoredStateError=1.000000,PositionLerp=0.000000,AngleLerp=0.400000,LinearVelocityCoefficient=100.000000,AngularVelocityCoefficient=10.000000,ErrorAccumulationSeconds=0.500000,ErrorAccumulationDistanceSq=15.000000,ErrorAccumulationSimilarity=100.000000)
55 | LockedAxis=Invalid
56 | DefaultDegreesOfFreedom=Full3D
57 | BounceThresholdVelocity=200.000000
58 | FrictionCombineMode=Average
59 | RestitutionCombineMode=Average
60 | MaxAngularVelocity=3600.000000
61 | MaxDepenetrationVelocity=0.000000
62 | ContactOffsetMultiplier=0.010000
63 | MinContactOffset=0.000100
64 | MaxContactOffset=1.000000
65 | bSimulateSkeletalMeshOnDedicatedServer=True
66 | DefaultShapeComplexity=CTF_UseSimpleAndComplex
67 | bDefaultHasComplexCollision=True
68 | bSuppressFaceRemapTable=False
69 | bSupportUVFromHitResults=False
70 | bDisableActiveActors=False
71 | bDisableKinematicStaticPairs=False
72 | bDisableKinematicKinematicPairs=False
73 | bDisableCCD=False
74 | bEnableEnhancedDeterminism=False
75 | MaxPhysicsDeltaTime=0.033333
76 | bSubstepping=False
77 | bSubsteppingAsync=False
78 | MaxSubstepDeltaTime=0.016667
79 | MaxSubsteps=6
80 | SyncSceneSmoothingFactor=0.000000
81 | AsyncSceneSmoothingFactor=0.990000
82 | InitialAverageFrameRate=0.016667
83 | PhysXTreeRebuildRate=10
84 | DefaultBroadphaseSettings=(bUseMBPOnClient=False,bUseMBPOnServer=False,MBPBounds=(Min=(X=0.000000,Y=0.000000,Z=0.000000),Max=(X=0.000000,Y=0.000000,Z=0.000000),IsValid=0),MBPNumSubdivs=2)
85 |
86 | [/Script/NavigationSystem.RecastNavMesh]
87 | bForceRebuildOnLoad=True
88 | RuntimeGeneration=Dynamic
89 |
90 | [/Script/IOSRuntimeSettings.IOSRuntimeSettings]
91 | bSupportsPortraitOrientation=False
92 | bSupportsUpsideDownOrientation=False
93 | bSupportsLandscapeLeftOrientation=True
94 | PreferredLandscapeOrientation=LandscapeLeft
95 |
--------------------------------------------------------------------------------
/UE4VoxelTerrain/Config/DefaultGame.ini:
--------------------------------------------------------------------------------
1 | [/Script/EngineSettings.GeneralProjectSettings]
2 | ProjectID=52080CFB475264890A4492A6326CD414
3 | ProjectName=Voxel Terrain
4 |
5 | [/Script/UE4VoxelTerrain.UE4VoxelTerrainCharacter]
6 | FixedCameraPitch=-45.0
7 | FixedCameraDistance=1500.0
8 |
9 | [/Script/UnrealEd.ProjectPackagingSettings]
10 | IncludeDebugFiles=True
11 |
12 |
--------------------------------------------------------------------------------
/UE4VoxelTerrain/Config/DefaultInput.ini:
--------------------------------------------------------------------------------
1 |
2 |
3 | [/Script/Engine.InputSettings]
4 | -AxisConfig=(AxisKeyName="Gamepad_LeftX",AxisProperties=(DeadZone=0.25,Exponent=1.f,Sensitivity=1.f))
5 | -AxisConfig=(AxisKeyName="Gamepad_LeftY",AxisProperties=(DeadZone=0.25,Exponent=1.f,Sensitivity=1.f))
6 | -AxisConfig=(AxisKeyName="Gamepad_RightX",AxisProperties=(DeadZone=0.25,Exponent=1.f,Sensitivity=1.f))
7 | -AxisConfig=(AxisKeyName="Gamepad_RightY",AxisProperties=(DeadZone=0.25,Exponent=1.f,Sensitivity=1.f))
8 | -AxisConfig=(AxisKeyName="MouseX",AxisProperties=(DeadZone=0.f,Exponent=1.f,Sensitivity=0.07f))
9 | -AxisConfig=(AxisKeyName="MouseY",AxisProperties=(DeadZone=0.f,Exponent=1.f,Sensitivity=0.07f))
10 | -AxisConfig=(AxisKeyName="Mouse2D",AxisProperties=(DeadZone=0.f,Exponent=1.f,Sensitivity=0.07f))
11 | +AxisConfig=(AxisKeyName="Mouse2D",AxisProperties=(DeadZone=0.000000,Sensitivity=0.070000,Exponent=1.000000,bInvert=False))
12 | +AxisConfig=(AxisKeyName="MotionController_Right_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
13 | +AxisConfig=(AxisKeyName="MotionController_Right_TriggerAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
14 | +AxisConfig=(AxisKeyName="MotionController_Right_Grip1Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
15 | +AxisConfig=(AxisKeyName="MotionController_Right_Grip2Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
16 | +AxisConfig=(AxisKeyName="Gamepad_Special_Left_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
17 | +AxisConfig=(AxisKeyName="Gamepad_Special_Left_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
18 | +AxisConfig=(AxisKeyName="Gamepad_LeftX",AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
19 | +AxisConfig=(AxisKeyName="Gamepad_LeftY",AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
20 | +AxisConfig=(AxisKeyName="Gamepad_RightX",AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
21 | +AxisConfig=(AxisKeyName="Gamepad_RightY",AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
22 | +AxisConfig=(AxisKeyName="MouseX",AxisProperties=(DeadZone=0.000000,Sensitivity=0.070000,Exponent=1.000000,bInvert=False))
23 | +AxisConfig=(AxisKeyName="MouseY",AxisProperties=(DeadZone=0.000000,Sensitivity=0.070000,Exponent=1.000000,bInvert=False))
24 | +AxisConfig=(AxisKeyName="MouseWheelAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
25 | +AxisConfig=(AxisKeyName="Gamepad_LeftTriggerAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
26 | +AxisConfig=(AxisKeyName="Gamepad_RightTriggerAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
27 | +AxisConfig=(AxisKeyName="MotionController_Left_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
28 | +AxisConfig=(AxisKeyName="MotionController_Left_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
29 | +AxisConfig=(AxisKeyName="MotionController_Left_TriggerAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
30 | +AxisConfig=(AxisKeyName="MotionController_Left_Grip1Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
31 | +AxisConfig=(AxisKeyName="MotionController_Left_Grip2Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
32 | +AxisConfig=(AxisKeyName="MotionController_Right_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
33 | +AxisConfig=(AxisKeyName="Daydream_Left_Trackpad_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
34 | +AxisConfig=(AxisKeyName="Daydream_Left_Trackpad_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
35 | +AxisConfig=(AxisKeyName="Daydream_Right_Trackpad_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
36 | +AxisConfig=(AxisKeyName="Daydream_Right_Trackpad_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
37 | +AxisConfig=(AxisKeyName="Vive_Left_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
38 | +AxisConfig=(AxisKeyName="Vive_Left_Trackpad_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
39 | +AxisConfig=(AxisKeyName="Vive_Left_Trackpad_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
40 | +AxisConfig=(AxisKeyName="Vive_Right_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
41 | +AxisConfig=(AxisKeyName="Vive_Right_Trackpad_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
42 | +AxisConfig=(AxisKeyName="Vive_Right_Trackpad_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
43 | +AxisConfig=(AxisKeyName="MixedReality_Left_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
44 | +AxisConfig=(AxisKeyName="MixedReality_Left_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
45 | +AxisConfig=(AxisKeyName="MixedReality_Left_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
46 | +AxisConfig=(AxisKeyName="MixedReality_Left_Trackpad_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
47 | +AxisConfig=(AxisKeyName="MixedReality_Left_Trackpad_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
48 | +AxisConfig=(AxisKeyName="MixedReality_Right_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
49 | +AxisConfig=(AxisKeyName="MixedReality_Right_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
50 | +AxisConfig=(AxisKeyName="MixedReality_Right_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
51 | +AxisConfig=(AxisKeyName="MixedReality_Right_Trackpad_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
52 | +AxisConfig=(AxisKeyName="MixedReality_Right_Trackpad_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
53 | +AxisConfig=(AxisKeyName="OculusGo_Left_Trackpad_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
54 | +AxisConfig=(AxisKeyName="OculusGo_Left_Trackpad_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
55 | +AxisConfig=(AxisKeyName="OculusGo_Right_Trackpad_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
56 | +AxisConfig=(AxisKeyName="OculusGo_Right_Trackpad_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
57 | +AxisConfig=(AxisKeyName="OculusTouch_Left_Grip_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
58 | +AxisConfig=(AxisKeyName="OculusTouch_Left_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
59 | +AxisConfig=(AxisKeyName="OculusTouch_Left_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
60 | +AxisConfig=(AxisKeyName="OculusTouch_Left_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
61 | +AxisConfig=(AxisKeyName="OculusTouch_Right_Grip_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
62 | +AxisConfig=(AxisKeyName="OculusTouch_Right_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
63 | +AxisConfig=(AxisKeyName="OculusTouch_Right_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
64 | +AxisConfig=(AxisKeyName="OculusTouch_Right_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
65 | +AxisConfig=(AxisKeyName="ValveIndex_Left_Grip_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
66 | +AxisConfig=(AxisKeyName="ValveIndex_Left_Grip_Force",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
67 | +AxisConfig=(AxisKeyName="ValveIndex_Left_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
68 | +AxisConfig=(AxisKeyName="ValveIndex_Left_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
69 | +AxisConfig=(AxisKeyName="ValveIndex_Left_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
70 | +AxisConfig=(AxisKeyName="ValveIndex_Left_Trackpad_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
71 | +AxisConfig=(AxisKeyName="ValveIndex_Left_Trackpad_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
72 | +AxisConfig=(AxisKeyName="ValveIndex_Left_Trackpad_Force",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
73 | +AxisConfig=(AxisKeyName="ValveIndex_Left_Trackpad_Touch",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
74 | +AxisConfig=(AxisKeyName="ValveIndex_Right_Grip_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
75 | +AxisConfig=(AxisKeyName="ValveIndex_Right_Grip_Force",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
76 | +AxisConfig=(AxisKeyName="ValveIndex_Right_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
77 | +AxisConfig=(AxisKeyName="ValveIndex_Right_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
78 | +AxisConfig=(AxisKeyName="ValveIndex_Right_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
79 | +AxisConfig=(AxisKeyName="ValveIndex_Right_Trackpad_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
80 | +AxisConfig=(AxisKeyName="ValveIndex_Right_Trackpad_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
81 | +AxisConfig=(AxisKeyName="ValveIndex_Right_Trackpad_Force",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
82 | bAltEnterTogglesFullscreen=True
83 | bF11TogglesFullscreen=True
84 | bUseMouseForTouch=False
85 | bEnableMouseSmoothing=True
86 | bEnableFOVScaling=True
87 | bCaptureMouseOnLaunch=True
88 | bAlwaysShowTouchInterface=False
89 | bShowConsoleOnFourFingerTap=True
90 | bEnableGestureRecognizer=False
91 | bUseAutocorrect=False
92 | DefaultViewportMouseCaptureMode=CapturePermanently_IncludingInitialMouseDown
93 | DefaultViewportMouseLockMode=LockOnCapture
94 | FOVScale=0.011110
95 | DoubleClickTime=0.200000
96 | +ActionMappings=(ActionName="MainAction",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=LeftMouseButton)
97 | +ActionMappings=(ActionName="1",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=One)
98 | +ActionMappings=(ActionName="2",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=Two)
99 | +ActionMappings=(ActionName="ZoomIn",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=MouseScrollUp)
100 | +ActionMappings=(ActionName="ZoomOut",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=MouseScrollDown)
101 | +ActionMappings=(ActionName="Jump",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=SpaceBar)
102 | +ActionMappings=(ActionName="AltAction",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=RightMouseButton)
103 | +ActionMappings=(ActionName="Test",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=P)
104 | +ActionMappings=(ActionName="3",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=Three)
105 | +ActionMappings=(ActionName="0",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=Zero)
106 | +ActionMappings=(ActionName="4",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=Four)
107 | +ActionMappings=(ActionName="5",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=Five)
108 | +ActionMappings=(ActionName="6",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=Six)
109 | +ActionMappings=(ActionName="7",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=Seven)
110 | +AxisMappings=(AxisName="MoveForward",Scale=1.000000,Key=W)
111 | +AxisMappings=(AxisName="MoveForward",Scale=-1.000000,Key=S)
112 | +AxisMappings=(AxisName="MoveRight",Scale=1.000000,Key=D)
113 | +AxisMappings=(AxisName="MoveRight",Scale=-1.000000,Key=A)
114 | +AxisMappings=(AxisName="Turn",Scale=1.000000,Key=MouseX)
115 | +AxisMappings=(AxisName="LookUp",Scale=-1.000000,Key=MouseY)
116 | DefaultPlayerInputClass=/Script/Engine.PlayerInput
117 | DefaultInputComponentClass=/Script/Engine.InputComponent
118 | DefaultTouchInterface=None
119 | -ConsoleKeys=Tilde
120 | +ConsoleKeys=Tilde
121 |
122 |
--------------------------------------------------------------------------------
/UE4VoxelTerrain/Source/UE4VoxelTerrain.Target.cs:
--------------------------------------------------------------------------------
1 | // Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
2 |
3 | using UnrealBuildTool;
4 | using System.Collections.Generic;
5 |
6 | public class UE4VoxelTerrainTarget : TargetRules
7 | {
8 | public UE4VoxelTerrainTarget(TargetInfo Target) : base(Target)
9 | {
10 | Type = TargetType.Game;
11 | ExtraModuleNames.Add("UE4VoxelTerrain");
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/UE4VoxelTerrain/Source/UE4VoxelTerrain/BaseCharacter.cpp:
--------------------------------------------------------------------------------
1 | // Fill out your copyright notice in the Description page of Project Settings.
2 |
3 | #include "UE4VoxelTerrain.h"
4 | #include "BaseCharacter.h"
5 |
6 | // Sets default values
7 | ABaseCharacter::ABaseCharacter() {
8 | PrimaryActorTick.bCanEverTick = true;
9 |
10 | CursorMesh = CreateDefaultSubobject(TEXT("CursorMesh"));
11 | CursorMesh->SetRelativeLocation(FVector(400.0f, 0.f, 0.f));
12 | CursorMesh->SetCollisionEnabled(ECollisionEnabled::NoCollision);
13 | CursorMesh->SetCollisionProfileName(TEXT("NoCollision"));
14 | CursorMesh->SetCanEverAffectNavigation(false);
15 | CursorMesh->SetVisibleFlag(false);
16 | CursorMesh->AttachTo(FollowCamera);
17 | CursorMesh->SetWorldRotation(FRotator());
18 | }
19 |
20 | // Called when the game starts or when spawned
21 | void ABaseCharacter::BeginPlay() {
22 | Super::BeginPlay();
23 | }
24 |
25 | // Called every frame
26 | void ABaseCharacter::Tick(float DeltaTime) {
27 | Super::Tick(DeltaTime);
28 | }
29 |
30 | // Called to bind functionality to input
31 | void ABaseCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) {
32 | Super::SetupPlayerInputComponent(PlayerInputComponent);
33 | }
34 |
35 |
--------------------------------------------------------------------------------
/UE4VoxelTerrain/Source/UE4VoxelTerrain/BaseCharacter.h:
--------------------------------------------------------------------------------
1 | // Fill out your copyright notice in the Description page of Project Settings.
2 |
3 | #pragma once
4 |
5 | #include "CoreMinimal.h"
6 | #include "GameFramework/Character.h"
7 | #include "SandboxCharacter.h"
8 | #include "SandboxObjectMap.h"
9 | #include "BaseCharacter.generated.h"
10 |
11 | UCLASS()
12 | class UE4VOXELTERRAIN_API ABaseCharacter : public ASandboxCharacter {
13 | GENERATED_BODY()
14 |
15 | public:
16 | // Sets default values for this character's properties
17 | ABaseCharacter();
18 |
19 | protected:
20 | // Called when the game starts or when spawned
21 | virtual void BeginPlay() override;
22 |
23 | public:
24 |
25 | UPROPERTY(EditAnywhere, Category = "Sandbox")
26 | USandboxObjectMap* SandboxObjectMap;
27 |
28 | UPROPERTY(EditAnywhere, Category = "Sandbox")
29 | UBlueprint* TestObject;
30 |
31 | UPROPERTY(EditAnywhere, Category = "Sandbox")
32 | USoundCue* TestSound;
33 |
34 | UPROPERTY(EditAnywhere, Category = "Sandbox")
35 | UStaticMeshComponent* CursorMesh;
36 |
37 | // Called every frame
38 | virtual void Tick(float DeltaTime) override;
39 |
40 | // Called to bind functionality to input
41 | virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
42 |
43 | };
44 |
--------------------------------------------------------------------------------
/UE4VoxelTerrain/Source/UE4VoxelTerrain/CubeObject.cpp:
--------------------------------------------------------------------------------
1 | // Fill out your copyright notice in the Description page of Project Settings.
2 |
3 | #include "UE4VoxelTerrain.h"
4 | #include "CubeObject.h"
5 |
6 |
--------------------------------------------------------------------------------
/UE4VoxelTerrain/Source/UE4VoxelTerrain/CubeObject.h:
--------------------------------------------------------------------------------
1 | // Fill out your copyright notice in the Description page of Project Settings.
2 |
3 | #pragma once
4 |
5 | #include "CoreMinimal.h"
6 | #include "SandboxObject.h"
7 | #include "CubeObject.generated.h"
8 |
9 | /**
10 | *
11 | */
12 | UCLASS()
13 | class UE4VOXELTERRAIN_API ACubeObject : public ASandboxObject {
14 | GENERATED_BODY()
15 |
16 | public:
17 |
18 | };
19 |
--------------------------------------------------------------------------------
/UE4VoxelTerrain/Source/UE4VoxelTerrain/CudaTerrainGeneratorComponent.cpp:
--------------------------------------------------------------------------------
1 | // Fill out your copyright notice in the Description page of Project Settings.
2 |
3 | #include "UE4VoxelTerrain.h"
4 | #include "TerrainController.h"
5 | #include "UnrealSandboxTerrain.h"
6 | #include "CudaTerrainGeneratorComponent.h"
7 |
8 | typedef struct TZoneData {
9 | float x;
10 | float y;
11 | float z;
12 |
13 | int c[10];
14 |
15 | } TZoneData;
16 |
17 | typedef struct TVdGenBlock {
18 | int size = 0;
19 |
20 | TZoneData* zoneData = nullptr;
21 | size_t zd_size = 0;
22 |
23 | TDensityVal* voxelData = nullptr;
24 | size_t vd_size = 0;
25 |
26 | TMaterialId* materialData = nullptr;
27 | size_t md_size = 0;
28 |
29 | int* cacheData = nullptr;
30 | size_t cd_size = 0;
31 |
32 | } TVdGenBlock;
33 |
34 |
35 |
36 | #define TotalCacheSize 299593
37 |
38 | static const float CaveLayerZ = 7000.f;
39 |
40 |
41 | class TVdGenBlockCuda {
42 |
43 | public:
44 |
45 | TVdGenBlockCuda(int size) {
46 | vdGenBlk.size = size;
47 | const uint32 ZoneVoxelResolution = 65; //FIXME
48 |
49 | int vd_full_num = ZoneVoxelResolution * ZoneVoxelResolution * ZoneVoxelResolution;
50 |
51 | vdGenBlk.vd_size = vd_full_num * sizeof(TDensityVal) * size;
52 | vdGenBlk.md_size = vd_full_num * sizeof(TMaterialId) * size;
53 | vdGenBlk.zd_size = size * sizeof(TZoneData);
54 | vdGenBlk.cd_size = TotalCacheSize * sizeof(int) * size;
55 |
56 | vdGenBlk.voxelData = (TDensityVal*)malloc(vdGenBlk.vd_size);
57 | vdGenBlk.materialData = (TMaterialId*)malloc(vdGenBlk.md_size);
58 | vdGenBlk.zoneData = (TZoneData*)malloc(vdGenBlk.zd_size);
59 | vdGenBlk.cacheData = (int*)malloc(vdGenBlk.cd_size);
60 | }
61 |
62 | ~TVdGenBlockCuda() {
63 | free(vdGenBlk.voxelData);
64 | free(vdGenBlk.materialData);
65 | free(vdGenBlk.zoneData);
66 | free(vdGenBlk.cacheData);
67 | }
68 |
69 | TVdGenBlock* GetVdGenBlock() {
70 | return &vdGenBlk;
71 | }
72 |
73 | private:
74 |
75 | TVdGenBlock vdGenBlk;
76 |
77 | };
78 |
79 | void UCudaTerrainGeneratorComponent::BeginPlay() {
80 | Super::BeginPlay();
81 | UE_LOG(LogTemp, Warning, TEXT("UCudaTerrainGeneratorComponent::BeginPlay"));
82 | }
83 |
84 | //====================================================================================
85 | // Terrain density and material generator
86 | //====================================================================================
87 |
88 | bool IsCaveLayerZone(float Z) {
89 | static constexpr int const ZoneCaveLevel = -(CaveLayerZ / 1000);
90 | return Z <= ZoneCaveLevel + 1 && Z >= ZoneCaveLevel - 1;
91 | }
92 |
93 | void StructureHotizontalBoxTunnel(UCudaTerrainGeneratorComponent* Generator, const FBox TunnelBox) {
94 |
95 | }
96 |
97 | void StructureVerticalCylinderTunnel(UCudaTerrainGeneratorComponent* Generator, const FVector& Origin, const float Radius, const float Top, const float Bottom) {
98 |
99 |
100 | }
101 |
102 |
103 | void UCudaTerrainGeneratorComponent::PrepareMetaData() {
104 | UE_LOG(LogTemp, Warning, TEXT("UCudaTerrainGeneratorComponent::PrepareMetaData()"));
105 |
106 | const FVector O(0, 0, -3000);
107 | const float Len = (23 * 1000) - 200; //1400
108 | const float Width = 800;
109 | const float Height = 800;
110 | const FVector Min(O.X - Len / 2, O.Y - Width / 2, O.Z - Height / 2);
111 | const FVector Max(O.X + Len / 2, O.Y + Width / 2, O.Z + Height / 2);
112 | FBox Box(Min, Max);
113 |
114 | StructureHotizontalBoxTunnel(this, Box);
115 | StructureHotizontalBoxTunnel(this, Box.MoveTo(O + FVector(0.f, 5000.f, 0.f)));
116 | StructureHotizontalBoxTunnel(this, Box.MoveTo(O + FVector(0.f, -5000.f, 0.f)));
117 | StructureHotizontalBoxTunnel(this, Box.MoveTo(O + FVector(0.f, 10000.f, 0.f)));
118 | StructureHotizontalBoxTunnel(this, Box.MoveTo(O + FVector(0.f, -10000.f, 0.f)));
119 |
120 | const FVector Min2(O.X - Width / 2, O.Y - Len / 2, O.Z - Height / 2);
121 | const FVector Max2(O.X + Width / 2, O.Y + Len / 2, O.Z + Height / 2);
122 | FBox Box2(Min2, Max2);
123 | StructureHotizontalBoxTunnel(this, Box2);
124 | StructureHotizontalBoxTunnel(this, Box2.MoveTo(O + FVector(10000.f, 0.f, 0.f)));
125 | StructureHotizontalBoxTunnel(this, Box2.MoveTo(O + FVector(-10000.f, 0.f, 0.f)));
126 |
127 | StructureVerticalCylinderTunnel(this, FVector(1000, 0, 0), 300.f, 0.f, -3000.f);
128 | }
129 |
130 | bool UCudaTerrainGeneratorComponent::IsForcedComplexZone(const TVoxelIndex& ZoneIndex) {
131 | if (IsCaveLayerZone(ZoneIndex.Z)) {
132 | //return true;
133 | }
134 |
135 | if (ZoneIndex.X == 1 && ZoneIndex.Y == 0) {
136 | //return true;
137 | }
138 |
139 | return Super::IsForcedComplexZone(ZoneIndex);
140 | }
141 |
142 | float UCudaTerrainGeneratorComponent::FunctionMakeVerticalCylinder(const float InDensity, const FVector& V, const FVector& Origin, const float Radius, const float Top, const float Bottom) const {
143 | static const float E = 50;
144 | static const float NoisePositionScale = 0.007f;
145 | static const float NoiseValueScale = 0.1;
146 |
147 | if (InDensity > 0.5f) {
148 | if (V.Z < Top + E && V.Z > Bottom - E) {
149 | const FVector P = V - Origin;
150 | const float R = std::sqrt(P.X * P.X + P.Y * P.Y);
151 | if (R < Radius + E) {
152 | if (R < Radius - E) {
153 | return 0.f;
154 | } else {
155 | //AsyncTask(ENamedThreads::GameThread, [=]() { DrawDebugPoint(GetWorld(), V, 2.f, FColor(255, 255, 255, 0), true); });
156 |
157 | const float N = PerlinNoise(P, NoisePositionScale, NoiseValueScale);
158 | float Density = 1 / (1 + exp((Radius - R) / 100)) + N;
159 | if (Density < InDensity) {
160 | return Density;
161 | }
162 | }
163 | }
164 | }
165 | }
166 |
167 | return InDensity;
168 | };
169 |
170 | float UCudaTerrainGeneratorComponent::FunctionMakeBox(const float InDensity, const FVector& P, const FBox& InBox) const {
171 | const float ExtendXP = InBox.Max.X;
172 | const float ExtendYP = InBox.Max.Y;
173 | const float ExtendZP = InBox.Max.Z;
174 | const float ExtendXN = InBox.Min.X;
175 | const float ExtendYN = InBox.Min.Y;
176 | const float ExtendZN = InBox.Min.Z;
177 |
178 | static const float E = 50;
179 | FBox Box = InBox.ExpandBy(E);
180 |
181 | static float D = 100;
182 | static const float NoisePositionScale = 0.005f;
183 | static const float NoiseValueScale = 0.1;
184 | float R = InDensity;
185 |
186 | if (InDensity < 0.5f) {
187 | return InDensity;
188 | }
189 |
190 | if (FMath::PointBoxIntersection(P, Box)) {
191 | R = 0;
192 |
193 | if (FMath::Abs(P.X - ExtendXP) < 50 || FMath::Abs(-P.X + ExtendXN) < 50) {
194 | const float DensityXP = 1 / (1 + exp((ExtendXP - P.X) / D));
195 | const float DensityXN = 1 / (1 + exp((-ExtendXN + P.X) / D));
196 | const float DensityX = (DensityXP + DensityXN);
197 | const float N = PerlinNoise(P, NoisePositionScale, NoiseValueScale);
198 | R = DensityX + N;
199 | }
200 |
201 | if (FMath::Abs(P.Y - ExtendYP) < 50 || FMath::Abs(-P.Y + ExtendYN) < 50) {
202 | if (R < 0.5f) {
203 | const float DensityYP = 1 / (1 + exp((ExtendYP - P.Y) / D));
204 | const float DensityYN = 1 / (1 + exp((-ExtendYN + P.Y) / D));
205 | const float DensityY = (DensityYP + DensityYN);
206 | const float N = PerlinNoise(P, NoisePositionScale, NoiseValueScale);
207 | R = DensityY + N;
208 | }
209 | }
210 |
211 | if (FMath::Abs(P.Z - ExtendZP) < 50 || FMath::Abs(-P.Z + ExtendZN) < 50) {
212 | if (R < 0.5f) {
213 | const float DensityZP = 1 / (1 + exp((ExtendZP - P.Z) / D));
214 | const float DensityZN = 1 / (1 + exp((-ExtendZN + P.Z) / D));
215 | const float DensityZ = (DensityZP + DensityZN);
216 | const float N = PerlinNoise(P, NoisePositionScale, NoiseValueScale / 2);
217 | R = DensityZ + N;
218 |
219 | }
220 | }
221 | }
222 |
223 | if (R > 1) {
224 | R = 1;
225 | }
226 |
227 | if (R < 0) {
228 | R = 0;
229 | }
230 |
231 | return R;
232 | };
233 |
234 |
235 | float UCudaTerrainGeneratorComponent::FunctionMakeCaveLayer(float Density, const FVector& WorldPos) const {
236 | const float BaseCaveLevel = CaveLayerZ;
237 |
238 | float Result = Density;
239 |
240 | static const float scale0 = 0.005f; // small
241 | static const float scale1 = 0.001f; // small
242 | static const float scale2 = 0.0003f; // big
243 |
244 | const FVector v0(WorldPos.X * scale0, WorldPos.Y * scale0, WorldPos.Z * 0.0002); // Stalactite
245 | const FVector v1(WorldPos.X * scale1, WorldPos.Y * scale1, WorldPos.Z * scale1); // just noise
246 | //const FVector v2(WorldPos.X * scale2, WorldPos.Y *scale2, WorldPos.Z * scale2); // just noise big
247 | const float Noise0 = PerlinNoise(v0);
248 | const float Noise1 = PerlinNoise(v1);
249 | //const float Noise2 = PerlinNoise(v2);
250 | //const float Noise2 = PerlinNoise(v2);
251 |
252 | //const FVector v4(WorldPos.X * scale3, WorldPos.Y * scale3, 10); // extra cave level
253 | //const float Noise4 = PerlinNoise(v4);
254 |
255 | //float NormalizedPerlin = (NoiseMedium + 0.87) / 1.73;
256 | //float Z = WorldPos.Z + NoiseMedium * 100;
257 | //float DensityByGroundLevel = 1 - (1 / (1 + exp(-Z)));
258 |
259 | // cave height
260 | static const float scale3 = 0.001f;
261 | const FVector v3(WorldPos.X * scale3, WorldPos.Y * scale3, 0); // extra cave height
262 | const float Noise3 = PerlinNoise(v3);
263 | const float BaseCaveHeight = 400;
264 | const float ExtraCaveHeight = 490 * Noise3;
265 | float CaveHeight = BaseCaveHeight + ExtraCaveHeight;
266 | //float CaveHeight = BaseCaveHeight;
267 | if (CaveHeight < 0) {
268 | CaveHeight = 0; // protection if my calculation is failed
269 | }
270 |
271 | //cave level
272 | static const float scale4 = 0.00025f;
273 | const FVector v4(WorldPos.X * scale4, WorldPos.Y * scale4, 10); // extra cave height
274 | const float Noise4 = PerlinNoise(v4);
275 | const float ExtraCaveLevel = 1000 * Noise4;
276 | const float CaveLevel = BaseCaveLevel + ExtraCaveLevel;
277 |
278 | // cave layer function
279 | const float CaveHeightF = CaveHeight * 160; // 80000 -> 473
280 | float CaveLayer = 1 - exp(-pow((WorldPos.Z + CaveLevel), 2) / CaveHeightF); // 80000 -> 473 = 473 * 169.13
281 |
282 | if (WorldPos.Z < -(BaseCaveLevel - 1200) && WorldPos.Z > -(BaseCaveLevel + 1200)) {
283 | const float CaveLayerN = 1 - CaveLayer;
284 | //Result *= CaveLayer + CaveLayerN * Noise0 * 0.5 + Noise1 * 0.75 + Noise2 * 0.5;
285 | Result *= CaveLayer + CaveLayerN * Noise0 * 0.5 + Noise1 * 0.75;
286 | //Result *= CaveLayer;
287 | }
288 |
289 | //Result = Density * (NoiseMedium * 0.5 + t);
290 |
291 | if (Result < 0) {
292 | Result = 0;
293 | }
294 |
295 | if (Result > 1) {
296 | Result = 1;
297 | }
298 |
299 | return Result;
300 | }
301 |
302 | float UCudaTerrainGeneratorComponent::DensityFunctionExt(float Density, const TVoxelIndex& ZoneIndex, const FVector& WorldPos, const FVector& LocalPos) const {
303 |
304 | if (ZoneIndex.X == 0 && ZoneIndex.Y == 0 && ZoneIndex.Z == -1) {
305 | float Result = Density;
306 |
307 | FVector P = LocalPos;
308 | float r = std::sqrt(P.X * P.X + P.Y * P.Y + P.Z * P.Z);
309 | const float MaxR = 1000;
310 | float t = 1 - exp(-pow(r, 2) / (MaxR * 100));
311 |
312 | //float D = 1 / (1 + exp((r - MaxR) / 10));
313 | //Result *= t;
314 |
315 | return Result;
316 | }
317 |
318 | if (IsCaveLayerZone(ZoneIndex.Z)) {
319 | //return FunctionMakeCaveLayer(Density, WorldPos);
320 | }
321 |
322 | return Density;
323 | }
324 |
325 | //==========================================
326 | // Foliage (mushrooms)
327 | //==========================================
328 |
329 | FSandboxFoliage UCudaTerrainGeneratorComponent::FoliageExt(const int32 FoliageTypeId, const FSandboxFoliage& FoliageType, const TVoxelIndex& ZoneIndex, const FVector& WorldPos) {
330 | FSandboxFoliage Foliage = FoliageType;
331 |
332 | // tree
333 | if (FoliageTypeId >= 100 && FoliageTypeId <= 199) {
334 | const float R = std::sqrt(WorldPos.X * WorldPos.X + WorldPos.Y * WorldPos.Y + WorldPos.Z * WorldPos.Z);
335 |
336 | if (R < 3500) {
337 | Foliage.Probability *= 0.01;
338 | }
339 |
340 | if (R > 8000) {
341 | //forest
342 | Foliage.Probability *= 20;
343 | Foliage.SpawnStep *= 0.7;
344 | Foliage.OffsetRange *= 0.7;
345 | }
346 | }
347 |
348 | // grass
349 | if (FoliageTypeId == 1) {
350 | const float R = std::sqrt(WorldPos.X * WorldPos.X + WorldPos.Y * WorldPos.Y + WorldPos.Z * WorldPos.Z);
351 |
352 | if (R < 1000) {
353 | float T = R / 1000;
354 | if (T < 0.2) {
355 | T = 0.2;
356 | }
357 |
358 | //Foliage.ScaleMaxZ *= T;
359 | //Foliage.ScaleMinZ = 0.3;
360 | }
361 | }
362 |
363 | if (FoliageTypeId == 2) {
364 | const float R = std::sqrt(WorldPos.X * WorldPos.X + WorldPos.Y * WorldPos.Y + WorldPos.Z * WorldPos.Z);
365 |
366 | if (R < 500) {
367 | Foliage.Probability = 0;
368 | }
369 | }
370 |
371 | return Foliage;
372 | }
373 |
374 | void UCudaTerrainGeneratorComponent::BatchGenerateComplexVd(TArray& GenPass2List) {
375 | ATerrainController* Controller = (ATerrainController*)GetController();
376 | if (Controller->IsUseCuda()) {
377 |
378 | int TotalZoneCount = GenPass2List.Num();
379 | if (TotalZoneCount == 0) {
380 | return;
381 | }
382 |
383 | UE_LOG(LogTemp, Log, TEXT("Use CUDA: %d"), GenPass2List.Num());
384 |
385 | double Start = FPlatformTime::Seconds();
386 |
387 | TVdGenBlockCuda VdGenBlockCuda(TotalZoneCount);
388 | TVdGenBlock* vdGenBlk = VdGenBlockCuda.GetVdGenBlock();
389 |
390 | int i = 0;
391 | //const uint32 ZoneVoxelResolution = 65; //FIXME
392 | const static int s = ZoneVoxelResolution * ZoneVoxelResolution * ZoneVoxelResolution;
393 | for (const auto& P : GenPass2List) {
394 | FVector Pos = Controller->GetZonePos(P.ZoneIndex);
395 | vdGenBlk->zoneData[i].x = Pos.X;
396 | vdGenBlk->zoneData[i].y = Pos.Y;
397 | vdGenBlk->zoneData[i].z = Pos.Z;
398 | i++;
399 | }
400 |
401 | PCudaGenerateVd CudaGenerateVd = (PCudaGenerateVd)Controller->CudaGenVdPtr;
402 | int CudaResult = CudaGenerateVd(vdGenBlk);
403 |
404 | int idx = 0;
405 | for (auto& P : GenPass2List) {
406 | P.Vd->copyDataUnsafe(&vdGenBlk->voxelData[idx * s], &vdGenBlk->materialData[idx * s]);
407 | P.Vd->clearSubstanceCache();
408 | P.Vd->copyCacheUnsafe(&vdGenBlk->cacheData[idx * s], vdGenBlk->zoneData[idx].c);
409 | idx++;
410 | }
411 |
412 | double End = FPlatformTime::Seconds();
413 | double Time = (End - Start) * 1000;
414 | UE_LOG(LogTemp, Log, TEXT("CudaResult -> %d ----> %f ms"), CudaResult, Time);
415 |
416 | } else {
417 | UTerrainGeneratorComponent::BatchGenerateComplexVd(GenPass2List);
418 | }
419 | }
420 |
421 | void UCudaTerrainGeneratorComponent::OnBatchGenerationFinished() {
422 |
423 | }
--------------------------------------------------------------------------------
/UE4VoxelTerrain/Source/UE4VoxelTerrain/CudaTerrainGeneratorComponent.h:
--------------------------------------------------------------------------------
1 | // Fill out your copyright notice in the Description page of Project Settings.
2 |
3 | #pragma once
4 |
5 | #include "CoreMinimal.h"
6 | #include "TerrainGeneratorComponent.h"
7 | #include "CudaTerrainGeneratorComponent.generated.h"
8 |
9 | /**
10 | *
11 | */
12 | UCLASS()
13 | class UE4VOXELTERRAIN_API UCudaTerrainGeneratorComponent : public UTerrainGeneratorComponent {
14 | GENERATED_BODY()
15 |
16 | public:
17 |
18 | void BeginPlay() override;
19 |
20 | virtual float DensityFunctionExt(float Density, const TVoxelIndex& ZoneIndex, const FVector& WorldPos, const FVector& LocalPos) const override;
21 |
22 | virtual FSandboxFoliage FoliageExt(const int32 FoliageTypeId, const FSandboxFoliage & FoliageType, const TVoxelIndex & ZoneIndex, const FVector & WorldPos) override;
23 |
24 | protected:
25 |
26 | virtual void BatchGenerateComplexVd(TArray& GenPass2List) override;
27 |
28 | virtual void OnBatchGenerationFinished() override;
29 |
30 | virtual bool IsForcedComplexZone(const TVoxelIndex& ZoneIndex) override;
31 |
32 | void virtual PrepareMetaData() override;
33 |
34 |
35 | public:
36 |
37 | float FunctionMakeBox(const float InDensity, const FVector& P, const FBox& InBox) const;
38 |
39 | float FunctionMakeCaveLayer(float Density, const FVector& WorldPos) const;
40 |
41 | float FunctionMakeVerticalCylinder(const float InDensity, const FVector& V, const FVector& Origin, const float Radius, const float Top, const float Bottom) const;
42 |
43 | };
44 |
--------------------------------------------------------------------------------
/UE4VoxelTerrain/Source/UE4VoxelTerrain/LevelController.cpp:
--------------------------------------------------------------------------------
1 | // Fill out your copyright notice in the Description page of Project Settings.
2 |
3 | #include "UE4VoxelTerrain.h"
4 | #include "LevelController.h"
5 |
6 |
7 |
8 | TSubclassOf ALevelController::GetSandboxObjectByClassId(int32 ClassId) {
9 |
10 | if (ObjectMap->ObjectMap.Contains(ClassId)) {
11 | return ObjectMap->ObjectMap[ClassId];
12 | }
13 |
14 | return nullptr;
15 | }
--------------------------------------------------------------------------------
/UE4VoxelTerrain/Source/UE4VoxelTerrain/LevelController.h:
--------------------------------------------------------------------------------
1 | // Fill out your copyright notice in the Description page of Project Settings.
2 |
3 | #pragma once
4 |
5 | #include "CoreMinimal.h"
6 | #include "SandboxLevelController.h"
7 | #include "LevelController.generated.h"
8 |
9 | /**
10 | *
11 | */
12 | UCLASS()
13 | class UE4VOXELTERRAIN_API ALevelController : public ASandboxLevelController
14 | {
15 | GENERATED_BODY()
16 |
17 |
18 | public:
19 |
20 | TSubclassOf GetSandboxObjectByClassId(int32 ClassId);
21 |
22 | };
23 |
--------------------------------------------------------------------------------
/UE4VoxelTerrain/Source/UE4VoxelTerrain/MainHUD.cpp:
--------------------------------------------------------------------------------
1 | // Fill out your copyright notice in the Description page of Project Settings.
2 |
3 | #include "UE4VoxelTerrain.h"
4 | #include "MainHUD.h"
5 | #include "UI/SystemInfoWidget.h"
6 |
7 |
8 | void AMainHUD::BeginPlay() {
9 | openWidget(TEXT("/Game/Sandbox/UI/W_SystemInfo.W_SystemInfo_C"));
10 | }
11 |
12 |
13 | template
14 | T* AMainHUD::openWidget(FString widget_name) {
15 | FStringClassReference big_inventory_widget_ref(widget_name);
16 | if (UClass* w = big_inventory_widget_ref.TryLoadClass()) {
17 | T* widget = CreateWidget(GetWorld(), w);
18 | widget->AddToViewport();
19 | return widget;
20 | }
21 | else {
22 | UE_LOG(LogTemp, Error, TEXT("widget %s is not found"), *widget_name);
23 | return NULL;
24 | }
25 | }
26 |
27 |
--------------------------------------------------------------------------------
/UE4VoxelTerrain/Source/UE4VoxelTerrain/MainHUD.h:
--------------------------------------------------------------------------------
1 | // Fill out your copyright notice in the Description page of Project Settings.
2 |
3 | #pragma once
4 |
5 | #include "GameFramework/HUD.h"
6 | #include "MainHUD.generated.h"
7 |
8 | /**
9 | *
10 | */
11 | UCLASS()
12 | class UE4VOXELTERRAIN_API AMainHUD : public AHUD
13 | {
14 | GENERATED_BODY()
15 |
16 | public:
17 | void BeginPlay();
18 |
19 |
20 | private:
21 | template
22 | T* openWidget(FString widget_name);
23 |
24 |
25 | };
26 |
--------------------------------------------------------------------------------
/UE4VoxelTerrain/Source/UE4VoxelTerrain/MiningTool.cpp:
--------------------------------------------------------------------------------
1 | // Fill out your copyright notice in the Description page of Project Settings.
2 |
3 | #include "UE4VoxelTerrain.h"
4 | #include "MiningTool.h"
5 |
6 | //#include "SpawnHelper.hpp"
7 | #include "VoxelMeshComponent.h"
8 |
9 |
10 | #define Dig_Cube_Size 110 //60
11 | #define Dig_Snap_To_Grid 100 //50
12 |
13 | #define Dig_Cylinder_Length 100
14 | #define Dig_Cylinder_Radius 100
15 |
16 | //FIXME
17 | void CalculateTargetRotation(ABaseCharacter* Character, FRotator& Rotation);
18 |
19 |
20 | FVector SnapToGrid(const FVector& Location, const float GridRange) {
21 | FVector Tmp(Location);
22 | Tmp /= GridRange;
23 | Tmp.Set(std::round(Tmp.X), std::round(Tmp.Y), std::round(Tmp.Z));
24 | Tmp *= GridRange;
25 | return FVector((int)Tmp.X, (int)Tmp.Y, (int)Tmp.Z);
26 | }
27 |
28 | void HelpDigCylinder(ABaseCharacter* Character, const FVector& Location, const float Len, TUniqueFunction Function) {
29 | const FVector& Tmp = Location;
30 | FRotator Rotation;
31 | CalculateTargetRotation(Character, Rotation);
32 | //Rotation += FRotator(45, 0, 0);
33 | FVector LenV(0, 0, Len);
34 | LenV = Rotation.RotateVector(LenV);
35 |
36 | FVector LenMin = Tmp - LenV;
37 | FVector LenMax = Tmp + LenV;
38 |
39 | Function(Tmp, LenMin, LenMax, Rotation);
40 | }
41 |
42 |
43 |
44 | AMiningTool::AMiningTool() {
45 | DiggingToolMode = 0;
46 | }
47 |
48 |
49 | void AMiningTool::PlaySound(const FSandboxTerrainMaterial& MatInfo, const FVector& Location, UWorld* World) {
50 | if (this->DiggingRockSound && MatInfo.Type == FSandboxTerrainMaterialType::Rock) {
51 | UGameplayStatics::PlaySoundAtLocation(World, this->DiggingRockSound, Location, FRotator(0));
52 | }
53 |
54 | if (this->DiggingSoilSound && MatInfo.Type == FSandboxTerrainMaterialType::Soil) {
55 | UGameplayStatics::PlaySoundAtLocation(World, this->DiggingSoilSound, Location, FRotator(0));
56 | }
57 | }
58 |
59 |
60 | void AMiningTool::OnAltAction(const FHitResult& Hit, ABaseCharacter* Owner) {
61 | UWorld* World = Owner->GetWorld();
62 | ASandboxTerrainController* Terrain = Cast(Hit.Actor.Get());
63 | if (Terrain) {
64 | TVoxelIndex ZoneIndex = Terrain->GetZoneIndex(Hit.ImpactPoint);
65 | FVector ZoneIndexTmp(ZoneIndex.X, ZoneIndex.Y, ZoneIndex.Z);
66 |
67 | UVoxelMeshComponent* ZoneMesh = Cast(Hit.Component.Get());
68 | if (ZoneMesh) {
69 | uint16 MatId = ZoneMesh->GetMaterialIdFromCollisionFaceIndex(Hit.FaceIndex);
70 | //UE_LOG(LogSandboxTerrain, Log, TEXT("MatId -> %d"), MatId);
71 |
72 | if (MatId > 0) {
73 | FSandboxTerrainMaterial MatInfo;
74 | if (Terrain->GetTerrainMaterialInfoById(MatId, MatInfo)) {
75 | PlaySound(MatInfo, Hit.Location, World);
76 | }
77 | }
78 | }
79 |
80 | //UE_LOG(LogTemp, Log, TEXT("Test -> %f %f %f"), Hit.Location.X, Hit.Location.Y, Hit.Location.Z);
81 | UE_LOG(LogTemp, Log, TEXT("ZoneIndex -> %f %f %f"), ZoneIndexTmp.X, ZoneIndexTmp.Y, ZoneIndexTmp.Z);
82 |
83 | if (DiggingToolMode == 0) {
84 | Terrain->DigTerrainRoundHole(Hit.ImpactPoint, 80, true);
85 | if (Owner->GetSandboxPlayerView() == PlayerView::TOP_DOWN) {
86 | //GetWorld()->GetTimerManager().SetTimer(Timer, this, &AUE4VoxelTerrainPlayerController::PerformAction, 0.1, true);
87 | }
88 | }
89 |
90 | if (DiggingToolMode == 1) {
91 | FVector Location = SnapToGrid(Hit.Location, Dig_Snap_To_Grid);
92 | Terrain->DigTerrainCubeHole(Location, Dig_Cube_Size);
93 |
94 | //float test = 55;
95 | //FVector Min(-test);
96 | //FVector Max(test);
97 | //FBox Box(Min, Max);
98 | //Terrain->DigTerrainCubeHole(Location, Box, -45, FVector(0, 0, 1));
99 | //Terrain->DigTerrainCubeHole(Location, Box, 0, FVector(0, 0, 1));
100 | }
101 |
102 | if (DiggingToolMode == 2) {
103 | //Terrain->FillTerrainRound(Hit.ImpactPoint, 60, 3); //sand
104 | Terrain->FillTerrainRound(Hit.ImpactPoint, 60, 1); //dirt
105 | }
106 |
107 |
108 | if (DiggingToolMode == 3) {
109 | //const FVector Location = SnapToGrid(Hit.Location, Dig_Snap_To_Grid);
110 | const FVector Location = Hit.Location;
111 | const float Len = Dig_Cylinder_Length;
112 | HelpDigCylinder(Owner, Location, Len, [&](const FVector& Pos, const FVector& LenMin, const FVector& LenMax, const FRotator& Rotation) {
113 | Terrain->DigCylinder(Hit.ImpactPoint, Dig_Cylinder_Radius, Len, Rotation);
114 | });
115 |
116 | /*
117 | const FVector Location = SnapToGrid(Hit.Location, 100);
118 | FBox MyBox = FBox(FVector(0, -110, -105), FVector(200, 105, 400));
119 | Terrain->DigTerrainCubeHole(Location, MyBox, Dig_Cube_Size);
120 |
121 | if (LevelController) {
122 | // spawn ramp
123 | FVector RampPos = Location;
124 | RampPos.Z = Hit.Location.Z - 10.f;
125 | TSubclassOf RampObj = LevelController->GetSandboxObjectByClassId(110);
126 | FVector Scale = FVector(1, 1, 1);
127 | FRotator Rotation(-26.5f, 0, 0);
128 | FTransform Transform(Rotation, RampPos, Scale);
129 | GetWorld()->SpawnActor(RampObj->ClassDefaultObject->GetClass(), &Transform);
130 | }
131 | */
132 | }
133 | }
134 |
135 | /*
136 | if (DiggingToolMode == 3) {
137 | ASandboxObject* TargetObj = Cast(Hit.Actor.Get());
138 | if (TargetObj && TargetObj->GetSandboxTypeId() == 110) {
139 | FVector RampPos = TargetObj->GetActorLocation();
140 | FVector D(200, 0, -100);
141 | RampPos += D;
142 |
143 | FBox MyBox = FBox(FVector(0, -110, -105), FVector(200, 105, 250));
144 | TerrainController->DigTerrainCubeHole(RampPos, MyBox, Dig_Cube_Size);
145 | TSubclassOf RampObj = LevelController->GetSandboxObjectByClassId(110);
146 | FVector Scale = FVector(1, 1, 1);
147 | FRotator Rotation(-26.5f, 0, 0);
148 | FTransform Transform(Rotation, RampPos, Scale);
149 | GetWorld()->SpawnActor(RampObj->ClassDefaultObject->GetClass(), &Transform);
150 | }
151 | }
152 | */
153 |
154 |
155 | }
156 |
157 | void AMiningTool::OnTracePlayerActionPoint(const FHitResult& Res, ABaseCharacter* Owner) {
158 | UWorld* World = Owner->GetWorld();
159 | ASandboxTerrainController* TerrainController = Cast(Res.Actor.Get());
160 | if (TerrainController) {
161 | if (DiggingToolMode == 0) {
162 | DrawDebugSphere(World, Res.Location, 80, 24, FColor(255, 255, 255, 100));
163 | }
164 |
165 | if (DiggingToolMode == 1) {
166 | const FVector Location = SnapToGrid(Res.Location, Dig_Snap_To_Grid);
167 | DrawDebugBox(World, Location, FVector(Dig_Cube_Size), FColor(255, 255, 255, 100));
168 | }
169 |
170 | if (DiggingToolMode == 2) {
171 | DrawDebugSphere(World, Res.Location, 60, 24, FColor(100, 255, 0, 100));
172 | }
173 |
174 | if (DiggingToolMode == 3) {
175 | //const FVector Location = SnapToGrid(Hit.Location, Dig_Snap_To_Grid);
176 | const FVector Location = Res.Location;
177 | const float Len = Dig_Cylinder_Length;
178 | HelpDigCylinder(Owner, Location, Len, [&](const FVector& Pos, const FVector& LenMin, const FVector& LenMax, const FRotator& Rotation) {
179 | DrawDebugCylinder(World, LenMax, LenMin, Dig_Cylinder_Radius, 128, FColor(255, 255, 255, 128));
180 | });
181 | }
182 | }
183 |
184 |
185 | /*
186 | const FVector Location = SnapToGrid(Res.Location, Dig_Snap_To_Grid);
187 | const FRotator Rotation = GetControlRotation();
188 | HelpDigStairs(Location, Rotation, [&](const FVector& TmpPos) {
189 | DrawDebugBox(GetWorld(), TmpPos, FVector(Dig_Cube_Size), FColor(255, 255, 255, 100));
190 | });
191 | */
192 |
193 | /*
194 | const FVector Location = SnapToGrid(Res.Location, 100);
195 | FBox MyBox = FBox(FVector(0, -105, -105), FVector(200, 105, 200));
196 | FTransform Transform(Location);
197 | DrawDebugSolidBox(World, MyBox, FColor(255, 255, 255, 100), Transform, false);
198 | */
199 |
200 |
201 | /*
202 | if (DiggingToolMode == 3) {
203 | ASandboxObject* TargetObj = Cast(Res.Actor.Get());
204 | if (TargetObj && TargetObj->GetSandboxTypeId() == 110) {
205 | FVector Pos = TargetObj->GetActorLocation();
206 | FVector D(200, 0, -100);
207 | Pos += D;
208 |
209 | FBox MyBox = FBox(FVector(0, -105, -105), FVector(200, 105, 200));
210 | FTransform Transform(Pos);
211 | DrawDebugSolidBox(GetWorld(), MyBox, FColor(255, 255, 255, 100), Transform, false);
212 | }
213 | }
214 | */
215 | }
--------------------------------------------------------------------------------
/UE4VoxelTerrain/Source/UE4VoxelTerrain/MiningTool.h:
--------------------------------------------------------------------------------
1 | // Fill out your copyright notice in the Description page of Project Settings.
2 |
3 | #pragma once
4 |
5 | #include "CoreMinimal.h"
6 | #include "SandboxObject.h"
7 | #include "BaseCharacter.h"
8 | #include "SandboxTerrainController.h"
9 | #include "MiningTool.generated.h"
10 |
11 | /**
12 | *
13 | */
14 | UCLASS()
15 | class UE4VOXELTERRAIN_API AMiningTool : public ASandboxObject
16 | {
17 | GENERATED_BODY()
18 |
19 | public:
20 |
21 | AMiningTool();
22 |
23 | UPROPERTY(EditAnywhere, Category = "Sandbox")
24 | USoundCue* DiggingRockSound;
25 |
26 | UPROPERTY(EditAnywhere, Category = "Sandbox")
27 | USoundCue* DiggingSoilSound;
28 |
29 | void OnAltAction(const FHitResult& Hit, ABaseCharacter* Owner);
30 |
31 | void OnTracePlayerActionPoint(const FHitResult& Res, ABaseCharacter* Owner);
32 |
33 | void ToggleToolMode() { DiggingToolMode++; DiggingToolMode = DiggingToolMode % 4; };
34 |
35 | private:
36 |
37 | int DiggingToolMode = 0;
38 |
39 | void PlaySound(const FSandboxTerrainMaterial& MatInfo, const FVector& Location, UWorld* World);
40 |
41 | };
42 |
--------------------------------------------------------------------------------
/UE4VoxelTerrain/Source/UE4VoxelTerrain/PreparationHelperActor.cpp:
--------------------------------------------------------------------------------
1 | // Fill out your copyright notice in the Description page of Project Settings.
2 |
3 | #include "UE4VoxelTerrain.h"
4 | #include "PreparationHelperActor.h"
5 |
6 | // Sets default values
7 | APreparationHelperActor::APreparationHelperActor()
8 | {
9 | // Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
10 | PrimaryActorTick.bCanEverTick = true;
11 |
12 | }
13 |
14 | bool CheckSaveDirLocal(FString SaveDir) {
15 | UE_LOG(LogTemp, Log, TEXT("Check directory: %s"), *SaveDir);
16 | IPlatformFile& PlatformFile = FPlatformFileManager::Get().GetPlatformFile();
17 | if (!PlatformFile.DirectoryExists(*SaveDir)) {
18 | PlatformFile.CreateDirectory(*SaveDir);
19 | UE_LOG(LogTemp, Log, TEXT("Create directory: %s"), *SaveDir);
20 | if (!PlatformFile.DirectoryExists(*SaveDir)) {
21 | UE_LOG(LogTemp, Log, TEXT("Unable to create directory: %s"), *SaveDir);
22 | return false;
23 | }
24 | }
25 |
26 | return true;
27 | }
28 |
29 | // Called when the game starts or when spawned
30 | void APreparationHelperActor::BeginPlay()
31 | {
32 | Super::BeginPlay();
33 |
34 | // TODO finish
35 | FString MapName = TEXT("World 0");
36 | FString SavePath = FPaths::ProjectSavedDir();
37 | FString SaveDir = SavePath + TEXT("Map/");
38 |
39 | if (!CheckSaveDirLocal(SaveDir)) {
40 | // log error
41 | }
42 |
43 | FString SaveDirWorld0 = SaveDir + MapName + TEXT("/");
44 | if (!CheckSaveDirLocal(SaveDirWorld0)) {
45 | // log error
46 | }
47 | }
48 |
49 | // Called every frame
50 | void APreparationHelperActor::Tick(float DeltaTime)
51 | {
52 | Super::Tick(DeltaTime);
53 |
54 | }
55 |
56 |
--------------------------------------------------------------------------------
/UE4VoxelTerrain/Source/UE4VoxelTerrain/PreparationHelperActor.h:
--------------------------------------------------------------------------------
1 | // Fill out your copyright notice in the Description page of Project Settings.
2 |
3 | #pragma once
4 |
5 | #include "CoreMinimal.h"
6 | #include "GameFramework/Actor.h"
7 | #include "PreparationHelperActor.generated.h"
8 |
9 | UCLASS()
10 | class UE4VOXELTERRAIN_API APreparationHelperActor : public AActor
11 | {
12 | GENERATED_BODY()
13 |
14 | public:
15 | // Sets default values for this actor's properties
16 | APreparationHelperActor();
17 |
18 | protected:
19 | // Called when the game starts or when spawned
20 | virtual void BeginPlay() override;
21 |
22 | public:
23 | // Called every frame
24 | virtual void Tick(float DeltaTime) override;
25 |
26 | };
27 |
--------------------------------------------------------------------------------
/UE4VoxelTerrain/Source/UE4VoxelTerrain/Ramp.cpp:
--------------------------------------------------------------------------------
1 | // Fill out your copyright notice in the Description page of Project Settings.
2 |
3 | #include "UE4VoxelTerrain.h"
4 | #include "Ramp.h"
5 |
6 | uint64 ARamp::GetSandboxTypeId() {
7 | return 110;
8 | }
--------------------------------------------------------------------------------
/UE4VoxelTerrain/Source/UE4VoxelTerrain/Ramp.h:
--------------------------------------------------------------------------------
1 | // Fill out your copyright notice in the Description page of Project Settings.
2 |
3 | #pragma once
4 |
5 | #include "CoreMinimal.h"
6 | #include "SandboxObject.h"
7 | #include "Ramp.generated.h"
8 |
9 | /**
10 | *
11 | */
12 | UCLASS()
13 | class UE4VOXELTERRAIN_API ARamp : public ASandboxObject {
14 | GENERATED_BODY()
15 |
16 | public:
17 | virtual uint64 GetSandboxTypeId();
18 | };
19 |
--------------------------------------------------------------------------------
/UE4VoxelTerrain/Source/UE4VoxelTerrain/SpawnHelper.hpp:
--------------------------------------------------------------------------------
1 |
2 | #pragma once
3 | #include "UE4VoxelTerrain.h"
4 | #include "SandboxObject.h"
5 | #include "SandboxCharacter.h"
6 | #include "SandboxTerrainController.h"
7 | #include "BaseCharacter.h"
8 |
9 |
10 | bool IsCursorPositionValid(const FHitResult& Hit) {
11 | if (Hit.bBlockingHit) {
12 | ACharacter* Character = Cast(Hit.Actor);
13 | if (Character) {
14 | return false;
15 | }
16 |
17 | return true;
18 | }
19 |
20 | return false;
21 | }
22 |
23 | void TransformPos(ASandboxObject* NewObj, FVector& Pos, FRotator& Rotation, const FHitResult& TraceResult) {
24 | ASandboxObject* TargetObject = Cast(TraceResult.Actor);
25 |
26 | // cube
27 | if (NewObj->GetSandboxTypeId() == 10) {
28 | if (TargetObject && TargetObject->GetSandboxTypeId() == 10) {
29 | FVector TargetActorPos = TraceResult.Actor->GetActorLocation();
30 | Pos = TargetActorPos;
31 | Rotation = TraceResult.Actor->GetActorRotation();
32 |
33 | FVector Normal = TraceResult.ImpactNormal;
34 | Pos = Pos + (Normal * 60);
35 | } else {
36 | FVector Normal = TraceResult.ImpactNormal;
37 | Pos = Pos + (Normal * 30);
38 | }
39 |
40 | return;
41 | }
42 |
43 | }
44 |
45 | void CalculateTargetRotation(ABaseCharacter* Character, FRotator& Rotation) {
46 | if (Character->GetSandboxPlayerView() == PlayerView::TOP_DOWN) {
47 | Rotation = FRotator();
48 | }
49 |
50 | if (Character->GetSandboxPlayerView() == PlayerView::THIRD_PERSON) {
51 | FRotator Rot = Character->FollowCamera->GetComponentRotation();
52 | Rot.Pitch = 0;
53 | Rot.Roll = 0;
54 | Rotation = Rot;
55 | }
56 |
57 | if (Character->GetSandboxPlayerView() == PlayerView::FIRST_PERSON) {
58 | FRotator Rot = Character->GetCapsuleComponent()->GetComponentRotation();
59 | Rotation = Rot;
60 | }
61 | }
62 |
63 | void CalculateCursorPosition(ABaseCharacter* Character, const FHitResult& Res, FVector& Location, FRotator& Rotation, ASandboxObject* Obj) {
64 | Location = Res.Location;
65 | CalculateTargetRotation(Character, Rotation);
66 | TransformPos(Obj, Location, Rotation, Res);
67 | }
68 |
69 |
70 | void DigTerrainAround(ASandboxObject* Object, UWorld* World, const FVector& Pos, const FRotator& Rotator) {
71 | TArray Components;
72 | Object->GetComponents(Components);
73 | for (UStaticMeshComponent* StaticMeshComponent : Components) {
74 | FBoxSphereBounds BoxSphereBounds = StaticMeshComponent->CalcBounds(FTransform());
75 | TArray OverlapArray;
76 | World->OverlapMultiByChannel(OverlapArray, Pos, FQuat(), ECC_Visibility, FCollisionShape::MakeSphere(BoxSphereBounds.SphereRadius));
77 | for (auto& Overlap : OverlapArray) {
78 | ASandboxTerrainController* Terrain = Cast(Overlap.Actor.Get());
79 | if (Terrain) {
80 | Terrain->DigTerrainCubeHole(Pos, 30, Rotator);
81 | continue;
82 | }
83 | }
84 | }
85 | }
86 |
87 |
88 | FRotator SelectRotation() {
89 | const auto DirIndex = FMath::RandRange(0, 6);
90 | static const FRotator Direction[7] = { FRotator(0), FRotator(90, 0, 0), FRotator(-90, 0, 0), FRotator(0, 90, 0), FRotator(0, -90, 0), FRotator(0, 0, 90), FRotator(0, 0, -90) };
91 | const FRotator Rotation = Direction[DirIndex];
92 |
93 | return Rotation;
94 | }
95 |
96 |
97 | void SpawnSandboxObject(UWorld* World, ASandboxCharacter* Owner, const FVector& Location, const FRotator& Rotation, ASandboxObject* Object) {
98 | auto SpawnActorClass = Object->GetClass();
99 | if (SpawnActorClass) {
100 | FRotator RotationExt(0);
101 | if (Object->GetSandboxTypeId() == 10) {
102 | RotationExt = SelectRotation();
103 | }
104 |
105 | RotationExt += Rotation;
106 |
107 | if (Object->GetSandboxTypeId() == 10) {
108 | DigTerrainAround(Object, World, Location, RotationExt);
109 | }
110 |
111 | AActor* NewActor = World->SpawnActor(SpawnActorClass, &Location, &RotationExt);
112 | }
113 | };
114 |
115 | void DropSandboxObject(UWorld* World, ASandboxCharacter* Owner, ASandboxObject* Object) {
116 | auto SpawnActorClass = Object->GetClass();
117 | //const FRotator SpawnRotation = Owner->GetControlRotation();
118 | const FRotator SpawnRotation = Owner->GetActorRotation();
119 | const FVector SpawnLocation = Owner->GetActorLocation() + SpawnRotation.RotateVector(FVector(100, 0, 50));
120 |
121 | FActorSpawnParameters ActorSpawnParams;
122 | ActorSpawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AdjustIfPossibleButDontSpawnIfColliding;
123 |
124 | AActor* NewActor = World->SpawnActor(SpawnActorClass, &SpawnLocation, &SpawnRotation, ActorSpawnParams);
125 | if (NewActor) {
126 | UStaticMeshComponent* RootComponent = Cast(NewActor->GetRootComponent());
127 | if (RootComponent) {
128 | RootComponent->SetSimulatePhysics(true);
129 | //RootComponent->SetMassScale(NAME_None, 2);
130 | RootComponent->SetPhysicsLinearVelocity(SpawnRotation.RotateVector(FVector(500, 0, 0)));
131 | }
132 | }
133 |
134 | };
135 |
136 |
137 |
138 | void HelpDigStairs(const FVector& Location, const FRotator& PlayerRotation, TUniqueFunction Function) {
139 | FVector V = PlayerRotation.RotateVector(FVector(1, 0, 0));
140 | V.Z = 0;
141 | V.Normalize(0.001f);
142 | V.X = FMath::RoundHalfToZero(V.X);
143 | V.Y = FMath::RoundHalfToZero(V.Y);
144 | V.Normalize(0.001f);
145 |
146 | if (V.X == 0 && V.Y == 0) {
147 | return;
148 | }
149 |
150 | float Test = FMath::Abs(FMath::Abs(V.X) - FMath::Abs(V.Y));
151 |
152 | if (Test < 0.1f) {
153 | return;
154 | }
155 |
156 | float Step = 25;
157 | FVector Tmp(Location);
158 | Tmp.Z += 150;
159 | for (int i = 0; i < 5; i++) {
160 | Tmp += V * 25 * 2;
161 | Tmp.Z -= Step;
162 | //DrawDebugBox(GetWorld(), Tmp, FVector(DIG_CUBE_SIZE), FColor(255, 255, 255, 100));
163 | Function(Tmp);
164 | }
165 | }
166 |
--------------------------------------------------------------------------------
/UE4VoxelTerrain/Source/UE4VoxelTerrain/TerrainController.cpp:
--------------------------------------------------------------------------------
1 | // Fill out your copyright notice in the Description page of Project Settings.
2 |
3 | #include "UE4VoxelTerrain.h"
4 |
5 | #include "UnrealSandboxTerrain.h"
6 | #include "TerrainController.h"
7 |
8 | #include "SandboxObject.h"
9 | #include "DrawDebugHelpers.h"
10 |
11 | #include "CudaTerrainGeneratorComponent.h"
12 |
13 |
14 | //======================================================================================================================================================================
15 | // Terrain generator
16 | //======================================================================================================================================================================
17 |
18 |
19 | class UCuda2TerrainGeneratorComponent : public UTerrainGeneratorComponent {
20 |
21 | public:
22 |
23 | //UCudaTerrainGeneratorComponent::UCudaTerrainGeneratorComponent(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) {
24 | //UE_LOG(LogTemp, Warning, TEXT(" UCudaTerrainGeneratorComponent"));
25 | //}
26 |
27 |
28 | };
29 |
30 |
31 | UTerrainGeneratorComponent* ATerrainController::NewTerrainGenerator() {
32 | UCudaTerrainGeneratorComponent* CudaGenerator = NewObject(this, TEXT("TerrainGenerator"));
33 | UE_LOG(LogTemp, Warning, TEXT("TEST -> %s"), *CudaGenerator->GetClass()->GetName());
34 | return CudaGenerator;
35 | }
36 |
37 | bool ATerrainController::IsUseCuda() {
38 | if (CudaGenVdPtr && bUseCUDAGenerator) {
39 | return true;
40 | }
41 |
42 | return false;
43 | }
44 |
45 | void ATerrainController::BeginPlay() {
46 | if (bUseCUDAGenerator) {
47 | //FString filePath = *FPaths::GamePluginsDir() + folder + "/" + name;
48 | FString CudaGenDllFilePath = "D:\\src\\bin\\win64\\Debug\\CudaVdGenerator.dll";
49 | if (FPaths::FileExists(CudaGenDllFilePath)) {
50 | this->CudaGenDllHandle = FPlatformProcess::GetDllHandle(*CudaGenDllFilePath);
51 | if (this->CudaGenDllHandle) {
52 | UE_LOG(LogTemp, Log, TEXT("CudaVdGenerator.dll -> LOADED"));
53 |
54 | FString CudaGetInfoName = "CudaGetInfo";
55 | PCudaGetInfo CudaGetInfo = (PCudaGetInfo)FPlatformProcess::GetDllExport(this->CudaGenDllHandle, *CudaGetInfoName);
56 | if (CudaGetInfo) {
57 | UE_LOG(LogTemp, Log, TEXT("CudaGetInfo -> OK"));
58 | }
59 |
60 | FString CudaGenerateVdName = "CudaGenerateVd";
61 | PCudaGenerateVd CudaGenerateVd = (PCudaGenerateVd)FPlatformProcess::GetDllExport(this->CudaGenDllHandle, *CudaGenerateVdName);
62 | if (CudaGenerateVd) {
63 | UE_LOG(LogTemp, Log, TEXT("CudaGenerateVd -> OK"));
64 |
65 | CudaGenVdPtr = CudaGenerateVd;
66 | }
67 | }
68 | else {
69 | UE_LOG(LogTemp, Log, TEXT("Error loading CudaVdGenerator.dll"));
70 | }
71 | }
72 | else {
73 | UE_LOG(LogTemp, Log, TEXT("CudaVdGenerator.dll not found"));
74 | }
75 | }
76 |
77 |
78 | Super::BeginPlay();
79 | }
80 |
81 | void ATerrainController::EndPlay(const EEndPlayReason::Type EndPlayReason) {
82 | Super::EndPlay(EndPlayReason);
83 |
84 | if (this->CudaGenDllHandle) {
85 | UE_LOG(LogTemp, Log, TEXT("Free CudaVdGenerator.dll"));
86 | FPlatformProcess::FreeDllHandle(CudaGenDllHandle);
87 | }
88 |
89 | }
90 |
91 | void ATerrainController::ShutdownAndSaveMap() {
92 |
93 | }
--------------------------------------------------------------------------------
/UE4VoxelTerrain/Source/UE4VoxelTerrain/TerrainController.h:
--------------------------------------------------------------------------------
1 | // Fill out your copyright notice in the Description page of Project Settings.
2 |
3 | #pragma once
4 |
5 | #include "SandboxTerrainController.h"
6 | #include "LevelController.h"
7 | #include "TerrainController.generated.h"
8 |
9 |
10 | struct TVdGenBlock;
11 |
12 | typedef int(*PCudaGetInfo)();
13 | typedef int(*PCudaGenerateVd)(TVdGenBlock*);
14 |
15 | /**
16 | *
17 | */
18 | UCLASS()
19 | class UE4VOXELTERRAIN_API ATerrainController : public ASandboxTerrainController
20 | {
21 | GENERATED_BODY()
22 |
23 |
24 | public:
25 |
26 | UPROPERTY(EditAnywhere, Category = "UnrealSandbox Debug")
27 | bool bUseCUDAGenerator = false;
28 |
29 | UPROPERTY(EditAnywhere, Category = "UnrealSandbox Toolkit")
30 | ALevelController* LevelController;
31 |
32 | UFUNCTION(BlueprintImplementableEvent, meta = (DisplayName = "On Progress Save Voxel Terrain"))
33 | void OnProgressSaveTerrain(float Progress);
34 |
35 | UFUNCTION(BlueprintImplementableEvent, meta = (DisplayName = "On Finish Save Voxel Terrain"))
36 | void OnFinishSaveTerrain();
37 |
38 | UFUNCTION(BlueprintCallable, Category = "UnrealSandbox")
39 | void ShutdownAndSaveMap();
40 |
41 |
42 | public:
43 |
44 | virtual void BeginPlay() override;
45 |
46 | virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
47 |
48 | bool IsUseCuda();
49 |
50 | void* CudaGenVdPtr = nullptr; //FIXME
51 |
52 | protected:
53 |
54 | virtual UTerrainGeneratorComponent* NewTerrainGenerator() override;
55 |
56 | private:
57 |
58 | void* CudaGenDllHandle = nullptr;
59 |
60 | };
61 |
--------------------------------------------------------------------------------
/UE4VoxelTerrain/Source/UE4VoxelTerrain/TerrainGenerator.cpp:
--------------------------------------------------------------------------------
1 | // Fill out your copyright notice in the Description page of Project Settings.
2 |
3 | #include "UE4VoxelTerrain.h"
4 | #include "TerrainGenerator.h"
5 |
6 | #define MessageTime 10.0f
7 |
8 |
9 | class TBaseGenerator;
10 |
11 | void ATerrainGenerator::StartBuildingTerrain() {
12 | }
13 |
14 |
15 | void ATerrainGenerator::ProgressGenerationPipeline(uint32 Progress, uint32 Total) {
16 |
17 | }
18 |
19 | void ATerrainGenerator::FinishGenerationPipeline() {
20 |
21 | }
22 |
23 |
--------------------------------------------------------------------------------
/UE4VoxelTerrain/Source/UE4VoxelTerrain/TerrainGenerator.h:
--------------------------------------------------------------------------------
1 | // Fill out your copyright notice in the Description page of Project Settings.
2 |
3 | #pragma once
4 |
5 | #include "CoreMinimal.h"
6 | #include "TerrainController.h"
7 | #include "TerrainGenerator.generated.h"
8 |
9 | /**
10 | *
11 | */
12 | UCLASS()
13 | class UE4VOXELTERRAIN_API ATerrainGenerator : public ATerrainController {
14 | GENERATED_BODY()
15 |
16 | public:
17 |
18 |
19 | UPROPERTY(EditAnywhere, Category = "UnrealSandboxDebug")
20 | int BatchSize = 10;
21 |
22 | UPROPERTY(EditAnywhere, Category = "UnrealSandboxDebug")
23 | int AreaGenerationSize = 10;
24 |
25 |
26 | UFUNCTION(BlueprintCallable, Category = "UnrealSandbox")
27 | void StartBuildingTerrain();
28 |
29 | UFUNCTION(BlueprintImplementableEvent, meta = (DisplayName = "On Finish Build Sandbox Terrain"))
30 | void OnFinishBuildingTerrain();
31 |
32 | UFUNCTION(BlueprintImplementableEvent, meta = (DisplayName = "On Progress Build Sandbox Terrain"))
33 | void OnProgressBuildingTerrain(float Progress);
34 |
35 | protected:
36 |
37 |
38 | private:
39 |
40 | void FinishGenerationPipeline();
41 |
42 | void ProgressGenerationPipeline(uint32 Progress, uint32 Total);
43 |
44 | FCriticalSection GenerateTerrainMutex;
45 | bool bIsGenerationStarted;
46 | };
47 |
--------------------------------------------------------------------------------
/UE4VoxelTerrain/Source/UE4VoxelTerrain/UE4VoxelTerrain.Build.cs:
--------------------------------------------------------------------------------
1 | // Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
2 |
3 | using UnrealBuildTool;
4 |
5 | public class UE4VoxelTerrain : ModuleRules
6 | {
7 | public UE4VoxelTerrain(ReadOnlyTargetRules Target) : base(Target)
8 | {
9 | bUseRTTI = true;
10 | CppStandard = CppStandardVersion.Latest;
11 |
12 | PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "UnrealSandboxTerrain", "UnrealSandboxToolkit" });
13 | }
14 |
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/UE4VoxelTerrain/Source/UE4VoxelTerrain/UE4VoxelTerrain.cpp:
--------------------------------------------------------------------------------
1 | // Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
2 |
3 | #include "UE4VoxelTerrain.h"
4 |
5 |
6 | IMPLEMENT_PRIMARY_GAME_MODULE( FDefaultGameModuleImpl, UE4VoxelTerrain, "UE4VoxelTerrain" );
7 |
8 | DEFINE_LOG_CATEGORY(LogUE4VoxelTerrain)
9 |
--------------------------------------------------------------------------------
/UE4VoxelTerrain/Source/UE4VoxelTerrain/UE4VoxelTerrain.h:
--------------------------------------------------------------------------------
1 |
2 | // Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
3 |
4 | #ifndef __UE4VOXELTERRAIN_H__
5 | #define __UE4VOXELTERRAIN_H__
6 |
7 | #include "EngineMinimal.h"
8 |
9 | DECLARE_LOG_CATEGORY_EXTERN(LogUE4VoxelTerrain, Log, All);
10 |
11 |
12 | #endif
13 |
--------------------------------------------------------------------------------
/UE4VoxelTerrain/Source/UE4VoxelTerrain/UE4VoxelTerrainCharacter.cpp:
--------------------------------------------------------------------------------
1 | // Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
2 |
3 | #include "UE4VoxelTerrain.h"
4 | #include "UE4VoxelTerrainCharacter.h"
5 | #include "UE4VoxelTerrainPlayerController.h"
6 | #include "Runtime/CoreUObject/Public/UObject/ConstructorHelpers.h"
7 | #include "Runtime/Engine/Classes/Components/DecalComponent.h"
8 | #include "DrawDebugHelpers.h"
9 | #include "SandboxTerrainController.h"
10 | #include "UE4VoxelTerrainPlayerController.h"
11 |
12 | #include
13 |
14 | AUE4VoxelTerrainCharacter::AUE4VoxelTerrainCharacter() {
15 |
16 |
17 | }
18 |
19 | void AUE4VoxelTerrainCharacter::Tick(float DeltaSeconds) {
20 | Super::Tick(DeltaSeconds);
21 |
22 | //if (CursorToWorld != nullptr)
23 | /*
24 | {
25 | if (AUE4VoxelTerrainPlayerController* PC = Cast(GetController())) {
26 | FHitResult TraceHitResult = PC->TracePlayerActionPoint();
27 |
28 | if (!TraceHitResult.bBlockingHit) {
29 | return;
30 | }
31 |
32 | ASandboxTerrainController* TerrainController = Cast(TraceHitResult.Actor.Get());
33 |
34 | UVoxelDualContouringMeshComponent* DualContouringVoxelMesh = Cast(TraceHitResult.Component.Get());
35 | if (DualContouringVoxelMesh != nullptr) {
36 | AUE4VoxelTerrainPlayerController* controller = Cast(GetController());
37 | if (controller->tool_mode == 1) {
38 | DrawDebugSphere(GetWorld(), TraceHitResult.Location, 80, 24, FColor(255, 255, 255, 100));
39 | }
40 | }
41 |
42 | if (TerrainController != nullptr) {
43 | AUE4VoxelTerrainPlayerController* controller = Cast(GetController());
44 |
45 | if (controller->tool_mode == 1) {
46 | DrawDebugSphere(GetWorld(), TraceHitResult.Location, 80, 24, FColor(255, 255, 255, 100));
47 | }
48 |
49 | if (controller->tool_mode == 2) {
50 | DrawDebugBox(GetWorld(), TraceHitResult.Location, FVector(105), FColor(255, 255, 255, 100));
51 | //FVector Min(-110, -110, -110);
52 | //FVector Max(110, 110, 110);
53 | //FBox Box(Min, Max);
54 | //FTransform Transform(FQuat(FVector(1, 0, 0), -45), TraceHitResult.Location, FVector(1));
55 | //DrawDebugSolidBox(GetWorld(), Box, FColor(255, 255, 255, 100), Transform);
56 | }
57 |
58 | if (controller->tool_mode == 3) {
59 | static const float GridRange = 100;
60 | FVector Tmp(TraceHitResult.Location);
61 | Tmp /= GridRange;
62 | Tmp.Set(std::round(Tmp.X), std::round(Tmp.Y), std::round(Tmp.Z));
63 | Tmp *= GridRange;
64 | FVector Position((int)Tmp.X, (int)Tmp.Y, (int)Tmp.Z);
65 |
66 | FQuat Rotation;
67 | DrawDebugBox(GetWorld(), Position, FVector(100), Rotation, FColor(255, 255, 255, 100));
68 | }
69 |
70 | if (controller->tool_mode == 4) {
71 | DrawDebugSphere(GetWorld(), TraceHitResult.Location, 60, 24, FColor(100, 255, 255, 100));
72 | }
73 |
74 | if (controller->tool_mode == 5) {
75 | DrawDebugSphere(GetWorld(), TraceHitResult.Location, 60, 24, FColor(255, 255, 100, 100));
76 | }
77 |
78 | if (controller->tool_mode == 6) {
79 | DrawDebugSphere(GetWorld(), TraceHitResult.Location, 60, 24, FColor(255, 100, 255, 100));
80 | }
81 |
82 | if (controller->tool_mode == 7) {
83 | static const float GridRange = 100;
84 | FVector Tmp(TraceHitResult.Location);
85 | Tmp /= GridRange;
86 | Tmp.Set(std::round(Tmp.X), std::round(Tmp.Y), std::floor(Tmp.Z));
87 | Tmp *= GridRange;
88 | FVector Position((int)Tmp.X, (int)Tmp.Y, ((int)Tmp.Z) + GridRange);
89 |
90 | DrawDebugBox(GetWorld(), Position, FVector(50), FColor(100, 100, 100, 100));
91 | }
92 | }
93 | }
94 | }
95 | */
96 | }
97 |
98 |
--------------------------------------------------------------------------------
/UE4VoxelTerrain/Source/UE4VoxelTerrain/UE4VoxelTerrainCharacter.h:
--------------------------------------------------------------------------------
1 | // Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
2 | #pragma once
3 | #include "GameFramework/Character.h"
4 | #include "SandboxCharacter.h"
5 | #include "UE4VoxelTerrainCharacter.generated.h"
6 |
7 | UCLASS(Blueprintable)
8 | class AUE4VoxelTerrainCharacter : public ASandboxCharacter
9 | {
10 | GENERATED_BODY()
11 |
12 | public:
13 | AUE4VoxelTerrainCharacter();
14 |
15 | virtual void Tick(float DeltaSeconds) override;
16 |
17 | UPROPERTY(EditAnywhere, Category = "Sandbox")
18 | UBlueprint* TestObject;
19 |
20 |
21 | private:
22 |
23 |
24 | };
25 |
26 |
--------------------------------------------------------------------------------
/UE4VoxelTerrain/Source/UE4VoxelTerrain/UE4VoxelTerrainGameMode.cpp:
--------------------------------------------------------------------------------
1 | // Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
2 |
3 | #include "UE4VoxelTerrain.h"
4 | #include "UE4VoxelTerrainGameMode.h"
5 | #include "UE4VoxelTerrainPlayerController.h"
6 | #include "UE4VoxelTerrainCharacter.h"
7 | #include "MainHUD.h"
8 |
9 | AUE4VoxelTerrainGameMode::AUE4VoxelTerrainGameMode()
10 | {
11 | // use our custom PlayerController class
12 | PlayerControllerClass = AUE4VoxelTerrainPlayerController::StaticClass();
13 |
14 | // set default pawn class to our Blueprinted character
15 | static ConstructorHelpers::FClassFinder PlayerPawnBPClass(TEXT("/Game/Sandbox/BP_TestCharacter"));
16 | if (PlayerPawnBPClass.Class != NULL)
17 | {
18 | DefaultPawnClass = PlayerPawnBPClass.Class;
19 | }
20 |
21 | HUDClass = AMainHUD::StaticClass();
22 | }
--------------------------------------------------------------------------------
/UE4VoxelTerrain/Source/UE4VoxelTerrain/UE4VoxelTerrainGameMode.h:
--------------------------------------------------------------------------------
1 | // Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
2 | #pragma once
3 | #include "GameFramework/GameMode.h"
4 | #include "UE4VoxelTerrainGameMode.generated.h"
5 |
6 | UCLASS(minimalapi)
7 | class AUE4VoxelTerrainGameMode : public AGameMode
8 | {
9 | GENERATED_BODY()
10 |
11 | public:
12 | AUE4VoxelTerrainGameMode();
13 | };
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/UE4VoxelTerrain/Source/UE4VoxelTerrain/UE4VoxelTerrainPlayerController.cpp:
--------------------------------------------------------------------------------
1 | // Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
2 |
3 | #include "UE4VoxelTerrain.h"
4 | #include "UE4VoxelTerrainPlayerController.h"
5 | #include "SandboxTerrainController.h"
6 | #include "SandboxCharacter.h"
7 | #include "VoxelIndex.h"
8 |
9 | #include "SpawnHelper.hpp"
10 |
11 | // test only
12 | #include "SandboxObject.h"
13 | #include "BaseCharacter.h"
14 | #include "MiningTool.h"
15 | #include "DrawDebugHelpers.h"
16 |
17 |
18 | AUE4VoxelTerrainPlayerController::AUE4VoxelTerrainPlayerController() {
19 | bPlaceCurrentObjectToWorld = false;
20 | }
21 |
22 | void AUE4VoxelTerrainPlayerController::BeginPlay() {
23 | Super::BeginPlay();
24 |
25 | for (TActorIterator ActorItr(GetWorld()); ActorItr; ++ActorItr) {
26 | ASandboxEnvironment* Env = Cast(*ActorItr);
27 | if (Env) {
28 | UE_LOG(LogTemp, Log, TEXT("Found ASandboxEnvironment -> %s"), *Env->GetName());
29 | SandboxEnvironment = Env;
30 | break;
31 | }
32 | }
33 |
34 | for (TActorIterator ActorItr(GetWorld()); ActorItr; ++ActorItr) {
35 | ALevelController* LevelCtrl = Cast(*ActorItr);
36 | if (LevelCtrl) {
37 | UE_LOG(LogTemp, Log, TEXT("Found ALevelController -> %s"), *LevelCtrl->GetName());
38 | LevelController = LevelCtrl;
39 | break;
40 | }
41 | }
42 |
43 | for (TActorIterator ActorItr(GetWorld()); ActorItr; ++ActorItr) {
44 | ATerrainController* TerrainCtrl = Cast(*ActorItr);
45 | if (TerrainCtrl) {
46 | UE_LOG(LogTemp, Log, TEXT("Found ATerrainController -> %s"), *TerrainCtrl->GetName());
47 | TerrainController = TerrainCtrl;
48 | break;
49 | }
50 | }
51 | }
52 |
53 | void AUE4VoxelTerrainPlayerController::PlayerTick(float DeltaTime) {
54 | Super::PlayerTick(DeltaTime);
55 |
56 | ABaseCharacter* Character = Cast(GetCharacter());
57 | if (Character) {
58 | FVector Location = Character->GetActorLocation();
59 | const float Distance = FVector::Distance(Location, PrevLocation);
60 | if (Distance > 50) {
61 | PrevLocation = Location;
62 | // update player position
63 | SandboxEnvironment->UpdatePlayerPosition(Location);
64 | if (SandboxEnvironment) {
65 | if (Location.Z < -500) {
66 | SandboxEnvironment->SetCaveMode(true);
67 | } else {
68 | SandboxEnvironment->SetCaveMode(false);
69 | }
70 | }
71 | }
72 | }
73 | }
74 |
75 | void AUE4VoxelTerrainPlayerController::ToggleToolMode() {
76 | ABaseCharacter* BaseCharacter = Cast(GetCharacter());
77 | if (!BaseCharacter) {
78 | return;
79 | }
80 |
81 | if (BaseCharacter->IsDead()) {
82 | return;
83 | }
84 |
85 | ASandboxObject* Obj = GetCurrentInventoryObject();
86 | if (Obj) {
87 | if (Obj->GetSandboxTypeId() == 100) { // if shovel
88 | AMiningTool* MiningTool = Cast(Obj);
89 | if (MiningTool) {
90 | MiningTool->ToggleToolMode();
91 | }
92 | }
93 | }
94 | };
95 |
96 | void AUE4VoxelTerrainPlayerController::SetupInputComponent() {
97 | // set up gameplay key bindings
98 | Super::SetupInputComponent();
99 | }
100 |
101 | void AUE4VoxelTerrainPlayerController::OnMainActionPressed() {
102 | SetDestinationPressed();
103 | bPlaceCurrentObjectToWorld = false;
104 | }
105 |
106 | void AUE4VoxelTerrainPlayerController::OnMainActionReleased() {
107 | SetDestinationReleased();
108 | }
109 |
110 | ASandboxObject* AUE4VoxelTerrainPlayerController::GetCurrentInventoryObject() {
111 | UContainerComponent* Inventory = GetInventory();
112 | if (Inventory != nullptr) {
113 | FContainerStack* Stack = Inventory->GetSlot(CurrentInventorySlot);
114 | if (Stack != nullptr) {
115 | if (Stack->Amount > 0) {
116 | TSubclassOf ObjectClass = Stack->ObjectClass;
117 | if (ObjectClass != nullptr) {
118 | ASandboxObject* Actor = Cast(ObjectClass->ClassDefaultObject);
119 | return Actor;
120 | }
121 | }
122 | }
123 | }
124 |
125 | return nullptr;
126 | }
127 |
128 | void AUE4VoxelTerrainPlayerController::OnAltActionPressed() {
129 | ABaseCharacter* BaseCharacter = Cast(GetCharacter());
130 | if (!BaseCharacter) {
131 | return;
132 | }
133 |
134 | if (BaseCharacter->IsDead()) {
135 | return;
136 | }
137 |
138 | FHitResult Hit = TracePlayerActionPoint();
139 | if (Hit.bBlockingHit) {
140 | //UE_LOG(LogSandboxTerrain, Warning, TEXT("test point -> %f %f %f"), Hit.ImpactPoint.X, Hit.ImpactPoint.Y, Hit.ImpactPoint.Z);
141 |
142 | ASandboxObject* Obj = GetCurrentInventoryObject();
143 | if (Obj) {
144 | if (Obj->GetSandboxTypeId() == 100) { // if shovel
145 | AMiningTool* MiningTool = Cast(Obj);
146 | if (MiningTool) {
147 | MiningTool->OnAltAction(Hit, BaseCharacter);
148 | }
149 | return;
150 | }
151 |
152 | if (bPlaceCurrentObjectToWorld) {
153 | if (IsCursorPositionValid(Hit) && Obj) {
154 | FVector Location;
155 | FRotator Rotation;
156 |
157 | CalculateCursorPosition(BaseCharacter, Hit, Location, Rotation, Obj);
158 | SpawnSandboxObject(GetWorld(), BaseCharacter, Location, Rotation, Obj);
159 | //DropSandboxObject(GetWorld(), Character, Obj);
160 | return;
161 | }
162 | } else {
163 | bPlaceCurrentObjectToWorld = true;
164 | }
165 | }
166 | }
167 | }
168 |
169 | void AUE4VoxelTerrainPlayerController::OnAltActionReleased() {
170 | GetWorld()->GetTimerManager().ClearTimer(Timer);
171 | }
172 |
173 | void AUE4VoxelTerrainPlayerController::PerformAction() {
174 | ASandboxCharacter* Character = Cast(GetCharacter());
175 | if (Character->GetSandboxPlayerView() != PlayerView::TOP_DOWN) { return; }
176 |
177 | FHitResult Hit;
178 | GetHitResultUnderCursor(ECC_WorldStatic, false, Hit);
179 | if (Hit.bBlockingHit) {
180 | ASandboxTerrainController* Terrain = Cast(Hit.Actor.Get());
181 | if (Terrain) {
182 | //if (DiggingToolMode == 0) {
183 | //Terrain->DigTerrainRoundHole(Hit.ImpactPoint, 80, 5);
184 | //}
185 | }
186 | }
187 | }
188 |
189 | void AUE4VoxelTerrainPlayerController::OnTracePlayerActionPoint(const FHitResult& Res) {
190 | ABaseCharacter* BaseCharacter = Cast(GetCharacter());
191 | if (BaseCharacter) {
192 | if (BaseCharacter->IsDead()) {
193 | return;
194 | }
195 |
196 | ASandboxObject* Obj = GetCurrentInventoryObject();
197 | if (Obj) {
198 | if (Obj->GetSandboxTypeId() == 100) { //shovel
199 | AMiningTool* MiningTool = Cast(Obj);
200 | if (MiningTool) {
201 | MiningTool->OnTracePlayerActionPoint(Res, BaseCharacter);
202 | }
203 | }
204 | }
205 |
206 | if (bPlaceCurrentObjectToWorld && IsCursorPositionValid(Res) && Obj) {
207 | auto Mesh = Obj->SandboxRootMesh->GetStaticMesh();
208 | FVector Scale = Obj->GetRootComponent()->GetRelativeScale3D();
209 | //UE_LOG(LogSandboxTerrain, Warning, TEXT("Scale = %f %f %f"), Scale.X, Scale.Y, Scale.Z);
210 | BaseCharacter->CursorMesh->SetStaticMesh(Mesh);
211 | BaseCharacter->CursorMesh->SetVisibility(true, true);
212 | BaseCharacter->CursorMesh->SetRelativeScale3D(Scale);
213 |
214 | FVector Location;
215 | FRotator Rotation;
216 | CalculateCursorPosition(BaseCharacter, Res, Location, Rotation, Obj);
217 | BaseCharacter->CursorMesh->SetWorldLocationAndRotationNoPhysics(Location, Rotation);
218 | } else {
219 | BaseCharacter->CursorMesh->SetVisibility(false, true);
220 | BaseCharacter->CursorMesh->SetStaticMesh(nullptr);
221 | BaseCharacter->CursorMesh->SetRelativeScale3D(FVector(1));
222 | }
223 | }
224 | }
--------------------------------------------------------------------------------
/UE4VoxelTerrain/Source/UE4VoxelTerrain/UE4VoxelTerrainPlayerController.h:
--------------------------------------------------------------------------------
1 | // Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
2 | #pragma once
3 | #include "GameFramework/PlayerController.h"
4 | #include "SandboxPlayerController.h"
5 | #include "SandboxEnvironment.h"
6 | #include "LevelController.h"
7 | #include "TerrainController.h"
8 | #include "UE4VoxelTerrainPlayerController.generated.h"
9 |
10 |
11 | UCLASS()
12 | class AUE4VoxelTerrainPlayerController : public ASandboxPlayerController
13 | {
14 | GENERATED_BODY()
15 |
16 | public:
17 | AUE4VoxelTerrainPlayerController();
18 |
19 | UFUNCTION(BlueprintCallable, Category = "Sandbox")
20 | void ToggleToolMode();
21 |
22 | virtual void BeginPlay() override;
23 |
24 | protected:
25 |
26 | virtual void PlayerTick(float DeltaTime) override;
27 |
28 | virtual void SetupInputComponent() override;
29 |
30 | virtual void OnMainActionPressed();
31 |
32 | virtual void OnMainActionReleased();
33 |
34 | virtual void OnAltActionPressed();
35 |
36 | virtual void OnAltActionReleased();
37 |
38 | void PerformAction();
39 |
40 | virtual void OnTracePlayerActionPoint(const FHitResult& Res) override;
41 |
42 |
43 | private:
44 |
45 | UPROPERTY()
46 | ASandboxEnvironment* SandboxEnvironment;
47 |
48 | UPROPERTY()
49 | ALevelController* LevelController;
50 |
51 | UPROPERTY()
52 | ATerrainController* TerrainController;
53 |
54 |
55 | //bool bIsConstructionMode;
56 | bool bPlaceCurrentObjectToWorld;
57 |
58 | FTimerHandle Timer;
59 |
60 | ASandboxObject* GetCurrentInventoryObject();
61 |
62 | FVector PrevLocation;
63 | };
64 |
65 |
66 |
--------------------------------------------------------------------------------
/UE4VoxelTerrain/Source/UE4VoxelTerrain/UI/SystemInfoWidget.cpp:
--------------------------------------------------------------------------------
1 | // Fill out your copyright notice in the Description page of Project Settings.
2 |
3 | #include "UE4VoxelTerrain.h"
4 | #include "SystemInfoWidget.h"
5 | #include "TerrainController.h"
6 |
7 |
8 |
9 |
10 | FString USystemInfoWidget::SandboxVersionInfoText() {
11 | return TEXT("v0.0.15-pre-alpha");
12 | }
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/UE4VoxelTerrain/Source/UE4VoxelTerrain/UI/SystemInfoWidget.h:
--------------------------------------------------------------------------------
1 | // Fill out your copyright notice in the Description page of Project Settings.
2 |
3 | #pragma once
4 |
5 | #include "Runtime/UMG/Public/UMG.h"
6 | #include "Runtime/UMG/Public/UMGStyle.h"
7 | #include "Runtime/UMG/Public/Slate/SObjectWidget.h"
8 | #include "Runtime/UMG/Public/IUMGModule.h"
9 | #include "Runtime/UMG/Public/Blueprint/UserWidget.h"
10 |
11 | #include "TerrainController.h"
12 |
13 | #include "Blueprint/UserWidget.h"
14 | #include "SystemInfoWidget.generated.h"
15 |
16 | /**
17 | *
18 | */
19 | UCLASS()
20 | class UE4VOXELTERRAIN_API USystemInfoWidget : public UUserWidget
21 | {
22 | GENERATED_BODY()
23 |
24 | protected:
25 | UFUNCTION(BlueprintCallable, Category = "Sandbox System info")
26 | FString SandboxVersionInfoText();
27 |
28 | private:
29 |
30 |
31 | };
32 |
--------------------------------------------------------------------------------
/UE4VoxelTerrain/Source/UE4VoxelTerrainEditor.Target.cs:
--------------------------------------------------------------------------------
1 | // Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
2 |
3 | using UnrealBuildTool;
4 | using System.Collections.Generic;
5 |
6 | public class UE4VoxelTerrainEditorTarget : TargetRules
7 | {
8 | public UE4VoxelTerrainEditorTarget(TargetInfo Target) : base(Target)
9 | {
10 | Type = TargetType.Editor;
11 | ExtraModuleNames.Add("UE4VoxelTerrain");
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/UE4VoxelTerrain/UE4VoxelTerrain.uproject:
--------------------------------------------------------------------------------
1 | {
2 | "FileVersion": 3,
3 | "EngineAssociation": "4.27",
4 | "Category": "",
5 | "Description": "",
6 | "Modules": [
7 | {
8 | "Name": "UE4VoxelTerrain",
9 | "Type": "Runtime",
10 | "LoadingPhase": "Default",
11 | "AdditionalDependencies": [
12 | "UnrealSandboxTerrain",
13 | "Engine",
14 | "UMG",
15 | "UnrealSandboxToolkit"
16 | ]
17 | }
18 | ],
19 | "Plugins": [
20 |
21 | ]
22 | }
--------------------------------------------------------------------------------
/cave.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bw2012/UE4VoxelTerrain/a92853cd61d6fb1fe872600a1ec38521471eda29/cave.gif
--------------------------------------------------------------------------------
/controls.md:
--------------------------------------------------------------------------------
1 | # Controls
2 | ```V ``` - toggle view (top down / third person)
3 |
4 | **Top down view:**
5 |
6 | ```Left mouse button ``` - move character to selected point
7 |
8 | ```Right mouse button ``` - use tool
9 |
10 | ```1 ``` ... ```7 ``` - change tool
11 |
12 | **Third person view:**
13 |
14 | ```W ``` ```S ``` ```A ``` ```D ``` - move character
15 |
16 | ```Mouse ``` - camera look
--------------------------------------------------------------------------------
/grass.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bw2012/UE4VoxelTerrain/a92853cd61d6fb1fe872600a1ec38521471eda29/grass.gif
--------------------------------------------------------------------------------
/terrain.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bw2012/UE4VoxelTerrain/a92853cd61d6fb1fe872600a1ec38521471eda29/terrain.gif
--------------------------------------------------------------------------------