reduce memory consumption
parent
4217f8f92f
commit
770e3bfce9
|
@ -1,30 +1,30 @@
|
||||||
The target system is: Emscripten - 1 - x86
|
The target system is: Emscripten - 1 - x86
|
||||||
The host system is: Linux - 6.1.0-5-amd64 - x86_64
|
The host system is: Linux - 6.1.0-5-amd64 - x86_64
|
||||||
Determining if the include file unistd.h exists passed with the following output:
|
Determining if the include file unistd.h exists passed with the following output:
|
||||||
Change Dir: /home/brett/Documents/Brock/CS 3P98/Final Project/cmake-build-emrelease/CMakeFiles/CMakeScratch/TryCompile-R1cnjV
|
Change Dir: /home/brett/Documents/Brock/CS 3P98/Final Project/cmake-build-emrelease/CMakeFiles/CMakeScratch/TryCompile-nkD9HZ
|
||||||
|
|
||||||
Run Build Command(s):/usr/bin/gmake -f Makefile cmTC_8162d/fast && /usr/bin/gmake -f CMakeFiles/cmTC_8162d.dir/build.make CMakeFiles/cmTC_8162d.dir/build
|
Run Build Command(s):/usr/bin/gmake -f Makefile cmTC_964c5/fast && /usr/bin/gmake -f CMakeFiles/cmTC_964c5.dir/build.make CMakeFiles/cmTC_964c5.dir/build
|
||||||
gmake[1]: Entering directory '/home/brett/Documents/Brock/CS 3P98/Final Project/cmake-build-emrelease/CMakeFiles/CMakeScratch/TryCompile-R1cnjV'
|
gmake[1]: Entering directory '/home/brett/Documents/Brock/CS 3P98/Final Project/cmake-build-emrelease/CMakeFiles/CMakeScratch/TryCompile-nkD9HZ'
|
||||||
Building C object CMakeFiles/cmTC_8162d.dir/CheckIncludeFile.c.o
|
Building C object CMakeFiles/cmTC_964c5.dir/CheckIncludeFile.c.o
|
||||||
/usr/bin/emcc -MD -MT CMakeFiles/cmTC_8162d.dir/CheckIncludeFile.c.o -MF CMakeFiles/cmTC_8162d.dir/CheckIncludeFile.c.o.d -o CMakeFiles/cmTC_8162d.dir/CheckIncludeFile.c.o -c "/home/brett/Documents/Brock/CS 3P98/Final Project/cmake-build-emrelease/CMakeFiles/CMakeScratch/TryCompile-R1cnjV/CheckIncludeFile.c"
|
/usr/bin/emcc -MD -MT CMakeFiles/cmTC_964c5.dir/CheckIncludeFile.c.o -MF CMakeFiles/cmTC_964c5.dir/CheckIncludeFile.c.o.d -o CMakeFiles/cmTC_964c5.dir/CheckIncludeFile.c.o -c "/home/brett/Documents/Brock/CS 3P98/Final Project/cmake-build-emrelease/CMakeFiles/CMakeScratch/TryCompile-nkD9HZ/CheckIncludeFile.c"
|
||||||
Linking C executable cmTC_8162d.js
|
Linking C executable cmTC_964c5.js
|
||||||
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_8162d.dir/link.txt --verbose=1
|
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_964c5.dir/link.txt --verbose=1
|
||||||
/usr/bin/emcc @CMakeFiles/cmTC_8162d.dir/objects1 -o cmTC_8162d.js
|
/usr/bin/emcc @CMakeFiles/cmTC_964c5.dir/objects1 -o cmTC_964c5.js
|
||||||
gmake[1]: Leaving directory '/home/brett/Documents/Brock/CS 3P98/Final Project/cmake-build-emrelease/CMakeFiles/CMakeScratch/TryCompile-R1cnjV'
|
gmake[1]: Leaving directory '/home/brett/Documents/Brock/CS 3P98/Final Project/cmake-build-emrelease/CMakeFiles/CMakeScratch/TryCompile-nkD9HZ'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Determining if the include file fcntl.h exists passed with the following output:
|
Determining if the include file fcntl.h exists passed with the following output:
|
||||||
Change Dir: /home/brett/Documents/Brock/CS 3P98/Final Project/cmake-build-emrelease/CMakeFiles/CMakeScratch/TryCompile-fztl4Q
|
Change Dir: /home/brett/Documents/Brock/CS 3P98/Final Project/cmake-build-emrelease/CMakeFiles/CMakeScratch/TryCompile-s1aY2P
|
||||||
|
|
||||||
Run Build Command(s):/usr/bin/gmake -f Makefile cmTC_3ae2a/fast && /usr/bin/gmake -f CMakeFiles/cmTC_3ae2a.dir/build.make CMakeFiles/cmTC_3ae2a.dir/build
|
Run Build Command(s):/usr/bin/gmake -f Makefile cmTC_90857/fast && /usr/bin/gmake -f CMakeFiles/cmTC_90857.dir/build.make CMakeFiles/cmTC_90857.dir/build
|
||||||
gmake[1]: Entering directory '/home/brett/Documents/Brock/CS 3P98/Final Project/cmake-build-emrelease/CMakeFiles/CMakeScratch/TryCompile-fztl4Q'
|
gmake[1]: Entering directory '/home/brett/Documents/Brock/CS 3P98/Final Project/cmake-build-emrelease/CMakeFiles/CMakeScratch/TryCompile-s1aY2P'
|
||||||
Building C object CMakeFiles/cmTC_3ae2a.dir/CheckIncludeFile.c.o
|
Building C object CMakeFiles/cmTC_90857.dir/CheckIncludeFile.c.o
|
||||||
/usr/bin/emcc -MD -MT CMakeFiles/cmTC_3ae2a.dir/CheckIncludeFile.c.o -MF CMakeFiles/cmTC_3ae2a.dir/CheckIncludeFile.c.o.d -o CMakeFiles/cmTC_3ae2a.dir/CheckIncludeFile.c.o -c "/home/brett/Documents/Brock/CS 3P98/Final Project/cmake-build-emrelease/CMakeFiles/CMakeScratch/TryCompile-fztl4Q/CheckIncludeFile.c"
|
/usr/bin/emcc -MD -MT CMakeFiles/cmTC_90857.dir/CheckIncludeFile.c.o -MF CMakeFiles/cmTC_90857.dir/CheckIncludeFile.c.o.d -o CMakeFiles/cmTC_90857.dir/CheckIncludeFile.c.o -c "/home/brett/Documents/Brock/CS 3P98/Final Project/cmake-build-emrelease/CMakeFiles/CMakeScratch/TryCompile-s1aY2P/CheckIncludeFile.c"
|
||||||
Linking C executable cmTC_3ae2a.js
|
Linking C executable cmTC_90857.js
|
||||||
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_3ae2a.dir/link.txt --verbose=1
|
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_90857.dir/link.txt --verbose=1
|
||||||
/usr/bin/emcc @CMakeFiles/cmTC_3ae2a.dir/objects1 -o cmTC_3ae2a.js
|
/usr/bin/emcc @CMakeFiles/cmTC_90857.dir/objects1 -o cmTC_90857.js
|
||||||
gmake[1]: Leaving directory '/home/brett/Documents/Brock/CS 3P98/Final Project/cmake-build-emrelease/CMakeFiles/CMakeScratch/TryCompile-fztl4Q'
|
gmake[1]: Leaving directory '/home/brett/Documents/Brock/CS 3P98/Final Project/cmake-build-emrelease/CMakeFiles/CMakeScratch/TryCompile-s1aY2P'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
-I"/home/brett/Documents/Brock/CS 3P98/Final Project/include" -I"/home/brett/Documents/Brock/CS 3P98/Final Project/libraries/BLT/include" -I"/home/brett/Documents/Brock/CS 3P98/Final Project/cmake-build-emrelease/libraries/BLT/config" -I"/home/brett/Documents/Brock/CS 3P98/Final Project/cmake-build-emrelease/libraries/freetype-2.13.0/include" -I"/home/brett/Documents/Brock/CS 3P98/Final Project/libraries/freetype-2.13.0/include"
|
-I"/home/brett/Documents/Brock/CS 3P98/Final Project/libraries/sparsepp/sparsepp" -I"/home/brett/Documents/Brock/CS 3P98/Final Project/libraries/parallel-hashmap/parallel_hashmap" -I"/home/brett/Documents/Brock/CS 3P98/Final Project/include" -I"/home/brett/Documents/Brock/CS 3P98/Final Project/libraries/BLT/include" -I"/home/brett/Documents/Brock/CS 3P98/Final Project/cmake-build-emrelease/libraries/BLT/config" -I"/home/brett/Documents/Brock/CS 3P98/Final Project/cmake-build-emrelease/libraries/freetype-2.13.0/include" -I"/home/brett/Documents/Brock/CS 3P98/Final Project/libraries/freetype-2.13.0/include"
|
||||||
|
|
|
@ -338,11 +338,28 @@ CMakeFiles/FinalProject.dir/src/main.cpp.o: \
|
||||||
/home/brett/Documents/Brock/CS\ 3P98/Final\ Project/include/render/camera.h \
|
/home/brett/Documents/Brock/CS\ 3P98/Final\ Project/include/render/camera.h \
|
||||||
/home/brett/Documents/Brock/CS\ 3P98/Final\ Project/include/world/chunk/world.h \
|
/home/brett/Documents/Brock/CS\ 3P98/Final\ Project/include/world/chunk/world.h \
|
||||||
/home/brett/Documents/Brock/CS\ 3P98/Final\ Project/include/world/chunk/storage.h \
|
/home/brett/Documents/Brock/CS\ 3P98/Final\ Project/include/world/chunk/storage.h \
|
||||||
|
/home/brett/Documents/Brock/CS\ 3P98/Final\ Project/libraries/BLT/include/blt/std/format.h \
|
||||||
/home/brett/Documents/Brock/CS\ 3P98/Final\ Project/include/world/chunk/typedefs.h \
|
/home/brett/Documents/Brock/CS\ 3P98/Final\ Project/include/world/chunk/typedefs.h \
|
||||||
/home/brett/Documents/Brock/CS\ 3P98/Final\ Project/include/world/registry.h \
|
/home/brett/Documents/Brock/CS\ 3P98/Final\ Project/include/world/registry.h \
|
||||||
/home/brett/Documents/Brock/CS\ 3P98/Final\ Project/include/render/textures.h \
|
/home/brett/Documents/Brock/CS\ 3P98/Final\ Project/include/render/textures.h \
|
||||||
/home/brett/Documents/Brock/CS\ 3P98/Final\ Project/include/stb/stb_image.h \
|
/home/brett/Documents/Brock/CS\ 3P98/Final\ Project/include/stb/stb_image.h \
|
||||||
/home/brett/Documents/Brock/CS\ 3P98/Final\ Project/include/util/settings.h \
|
/home/brett/Documents/Brock/CS\ 3P98/Final\ Project/include/util/settings.h \
|
||||||
/home/brett/Documents/Brock/CS\ 3P98/Final\ Project/include/stb/stb_image_resize.h \
|
/home/brett/Documents/Brock/CS\ 3P98/Final\ Project/include/stb/stb_image_resize.h \
|
||||||
|
/home/brett/Documents/Brock/CS\ 3P98/Final\ Project/libraries/parallel-hashmap/parallel_hashmap/phmap.h \
|
||||||
|
/usr/share/emscripten/cache/sysroot/include/c++/v1/array \
|
||||||
|
/usr/share/emscripten/cache/sysroot/include/c++/v1/cassert \
|
||||||
|
/usr/share/emscripten/cache/sysroot/include/assert.h \
|
||||||
|
/home/brett/Documents/Brock/CS\ 3P98/Final\ Project/libraries/parallel-hashmap/parallel_hashmap/phmap_fwd_decl.h \
|
||||||
|
/home/brett/Documents/Brock/CS\ 3P98/Final\ Project/libraries/parallel-hashmap/parallel_hashmap/phmap_utils.h \
|
||||||
|
/home/brett/Documents/Brock/CS\ 3P98/Final\ Project/libraries/parallel-hashmap/parallel_hashmap/phmap_bits.h \
|
||||||
|
/home/brett/Documents/Brock/CS\ 3P98/Final\ Project/libraries/parallel-hashmap/parallel_hashmap/phmap_config.h \
|
||||||
|
/usr/share/emscripten/cache/sysroot/include/c++/v1/any \
|
||||||
|
/home/brett/Documents/Brock/CS\ 3P98/Final\ Project/libraries/parallel-hashmap/parallel_hashmap/phmap_base.h \
|
||||||
|
/usr/share/emscripten/cache/sysroot/include/c++/v1/shared_mutex \
|
||||||
|
/home/brett/Documents/Brock/CS\ 3P98/Final\ Project/libraries/sparsepp/sparsepp/spp.h \
|
||||||
|
/home/brett/Documents/Brock/CS\ 3P98/Final\ Project/libraries/sparsepp/sparsepp/spp_stdint.h \
|
||||||
|
/home/brett/Documents/Brock/CS\ 3P98/Final\ Project/libraries/sparsepp/sparsepp/spp_config.h \
|
||||||
|
/home/brett/Documents/Brock/CS\ 3P98/Final\ Project/libraries/sparsepp/sparsepp/spp_traits.h \
|
||||||
|
/home/brett/Documents/Brock/CS\ 3P98/Final\ Project/libraries/sparsepp/sparsepp/spp_utils.h \
|
||||||
/home/brett/Documents/Brock/CS\ 3P98/Final\ Project/include/util/math.h \
|
/home/brett/Documents/Brock/CS\ 3P98/Final\ Project/include/util/math.h \
|
||||||
/home/brett/Documents/Brock/CS\ 3P98/Final\ Project/include/stb/stb_perlin.h
|
/home/brett/Documents/Brock/CS\ 3P98/Final\ Project/include/stb/stb_perlin.h
|
||||||
|
|
|
@ -116,8 +116,8 @@ libraries/freetype-2.13.0/clean: libraries/freetype-2.13.0/CMakeFiles/freetype.d
|
||||||
# Target rules for target CMakeFiles/FinalProject.dir
|
# Target rules for target CMakeFiles/FinalProject.dir
|
||||||
|
|
||||||
# All Build rule for target.
|
# All Build rule for target.
|
||||||
CMakeFiles/FinalProject.dir/all: libraries/freetype-2.13.0/CMakeFiles/freetype.dir/all
|
|
||||||
CMakeFiles/FinalProject.dir/all: libraries/BLT/CMakeFiles/BLT.dir/all
|
CMakeFiles/FinalProject.dir/all: libraries/BLT/CMakeFiles/BLT.dir/all
|
||||||
|
CMakeFiles/FinalProject.dir/all: libraries/freetype-2.13.0/CMakeFiles/freetype.dir/all
|
||||||
$(MAKE) $(MAKESILENT) -f CMakeFiles/FinalProject.dir/build.make CMakeFiles/FinalProject.dir/depend
|
$(MAKE) $(MAKESILENT) -f CMakeFiles/FinalProject.dir/build.make CMakeFiles/FinalProject.dir/depend
|
||||||
$(MAKE) $(MAKESILENT) -f CMakeFiles/FinalProject.dir/build.make CMakeFiles/FinalProject.dir/build
|
$(MAKE) $(MAKESILENT) -f CMakeFiles/FinalProject.dir/build.make CMakeFiles/FinalProject.dir/build
|
||||||
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --progress-dir="/home/brett/Documents/Brock/CS 3P98/Final Project/cmake-build-emrelease/CMakeFiles" --progress-num=10,11,12,13,14,15,16,17,18,19,20,21,22 "Built target FinalProject"
|
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --progress-dir="/home/brett/Documents/Brock/CS 3P98/Final Project/cmake-build-emrelease/CMakeFiles" --progress-num=10,11,12,13,14,15,16,17,18,19,20,21,22 "Built target FinalProject"
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
-I"/home/brett/Documents/Brock/CS 3P98/Final Project/include" -I"/home/brett/Documents/Brock/CS 3P98/Final Project/libraries/BLT/include" -I"/home/brett/Documents/Brock/CS 3P98/Final Project/cmake-build-emrelease/libraries/BLT/config"
|
-I"/home/brett/Documents/Brock/CS 3P98/Final Project/libraries/sparsepp/sparsepp" -I"/home/brett/Documents/Brock/CS 3P98/Final Project/libraries/parallel-hashmap/parallel_hashmap" -I"/home/brett/Documents/Brock/CS 3P98/Final Project/include" -I"/home/brett/Documents/Brock/CS 3P98/Final Project/libraries/BLT/include" -I"/home/brett/Documents/Brock/CS 3P98/Final Project/cmake-build-emrelease/libraries/BLT/config"
|
||||||
|
|
Binary file not shown.
|
@ -184,3 +184,16 @@
|
||||||
2 1220 1678080343755903154 CMakeFiles/FinalProject.dir/src/world/chunk/storage.cpp.o 19cb330422f1ead7
|
2 1220 1678080343755903154 CMakeFiles/FinalProject.dir/src/world/chunk/storage.cpp.o 19cb330422f1ead7
|
||||||
2 1521 1678080344055911519 CMakeFiles/FinalProject.dir/src/world/chunk/world.cpp.o 5a5f514ae327b7c6
|
2 1521 1678080344055911519 CMakeFiles/FinalProject.dir/src/world/chunk/world.cpp.o 5a5f514ae327b7c6
|
||||||
1521 1655 1678080344187915200 FinalProject 9e02455301d10951
|
1521 1655 1678080344187915200 FinalProject 9e02455301d10951
|
||||||
|
2 1191 1678115458859390863 CMakeFiles/FinalProject.dir/src/main.cpp.o 44f0aca089894d0f
|
||||||
|
2 1420 1678115459091397186 CMakeFiles/FinalProject.dir/src/world/chunk/storage.cpp.o 19cb330422f1ead7
|
||||||
|
2 1575 1678115459243401325 CMakeFiles/FinalProject.dir/src/world/chunk/world.cpp.o 5a5f514ae327b7c6
|
||||||
|
1575 1704 1678115459371404813 FinalProject 9e02455301d10951
|
||||||
|
2 1181 1678115586658870102 CMakeFiles/FinalProject.dir/src/main.cpp.o 44f0aca089894d0f
|
||||||
|
2 1332 1678115586806874126 CMakeFiles/FinalProject.dir/src/world/chunk/storage.cpp.o 19cb330422f1ead7
|
||||||
|
3 1557 1678115587030880222 CMakeFiles/FinalProject.dir/src/world/chunk/world.cpp.o 5a5f514ae327b7c6
|
||||||
|
1557 1693 1678115587166883922 FinalProject 9e02455301d10951
|
||||||
|
2 1071 1678115738963010170 CMakeFiles/FinalProject.dir/src/main.cpp.o 44f0aca089894d0f
|
||||||
|
2 1222 1678115739115014299 CMakeFiles/FinalProject.dir/src/world/chunk/storage.cpp.o 19cb330422f1ead7
|
||||||
|
2 1350 1678115739243017776 CMakeFiles/FinalProject.dir/src/world/registry.cpp.o 3e7542c3498b07ce
|
||||||
|
2 1467 1678115739359020927 CMakeFiles/FinalProject.dir/src/world/chunk/world.cpp.o 5a5f514ae327b7c6
|
||||||
|
1467 1599 1678115739491024515 FinalProject 9e02455301d10951
|
||||||
|
|
Binary file not shown.
|
@ -1,3 +1,3 @@
|
||||||
Start testing: Mar 06 00:25 EST
|
Start testing: Mar 06 10:15 EST
|
||||||
----------------------------------------------------------
|
----------------------------------------------------------
|
||||||
End testing: Mar 06 00:25 EST
|
End testing: Mar 06 10:15 EST
|
||||||
|
|
|
@ -40,10 +40,11 @@ namespace fp {
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] inline bool checkBlockVisibility(const block_pos& pos) const {
|
[[nodiscard]] inline bool checkBlockVisibility(const block_pos& pos) const {
|
||||||
|
// blocks outside the check are always not visible to us. This requires special logic
|
||||||
if (pos.x < 0 || pos.x >= CHUNK_SIZE || pos.y < 0 || pos.y >= CHUNK_SIZE || pos.z < 0 || pos.z >= CHUNK_SIZE) {
|
if (pos.x < 0 || pos.x >= CHUNK_SIZE || pos.y < 0 || pos.y >= CHUNK_SIZE || pos.z < 0 || pos.z >= CHUNK_SIZE) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return fp::registry::get(get(pos)).visibility <= fp::registry::TRANSPARENT_TEXTURE;
|
return fp::registry::get(get(pos)).visibility >= fp::registry::TRANSPARENT_TEXTURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void set(const block_pos& pos, block_type blockID) {
|
inline void set(const block_pos& pos, block_type blockID) {
|
||||||
|
|
|
@ -31,10 +31,8 @@ namespace fp {
|
||||||
OKAY = 0,
|
OKAY = 0,
|
||||||
// chunk needs its VAO updated with the newest mesh
|
// chunk needs its VAO updated with the newest mesh
|
||||||
REFRESH = 1,
|
REFRESH = 1,
|
||||||
// chunk needs its edges re-meshed because it was created with null neighbours
|
|
||||||
PARTIAL_MESH = 2,
|
|
||||||
// chunk needs a complete re-mesh.
|
// chunk needs a complete re-mesh.
|
||||||
FULL_MESH = 3
|
DIRTY = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
enum chunk_update_status {
|
enum chunk_update_status {
|
||||||
|
|
|
@ -92,34 +92,19 @@ namespace fp {
|
||||||
void updateChunkMesh();
|
void updateChunkMesh();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mark the chunk as completely dirty and in need of a full check refresh
|
* Mark the chunk as completely dirty and in need of a full chunk refresh
|
||||||
*/
|
*/
|
||||||
inline void markDirty() {
|
inline void markDirty() {
|
||||||
dirtiness = FULL_MESH;
|
dirtiness = DIRTY;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Partial mesh update has been completed, we are now waiting on the edge chunks to be
|
|
||||||
* generated before continuing to generate the chunk edge mesh
|
|
||||||
*/
|
|
||||||
inline void markPartialComplete() {
|
|
||||||
dirtiness = PARTIAL_MESH;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Full chunk mesh is now completely generated and waiting on uploading to the GPU
|
* Full chunk mesh is now completely generated and waiting on uploading to the GPU
|
||||||
*/
|
*/
|
||||||
inline void markComplete() {
|
inline void markRefresh() {
|
||||||
dirtiness = REFRESH;
|
dirtiness = REFRESH;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Mesh uploading complete, chunk meshing is now done and inactive
|
|
||||||
*/
|
|
||||||
inline void markDone() {
|
|
||||||
dirtiness = OKAY;
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] inline block_storage*& getBlockStorage() {
|
[[nodiscard]] inline block_storage*& getBlockStorage() {
|
||||||
return storage;
|
return storage;
|
||||||
}
|
}
|
||||||
|
@ -167,10 +152,6 @@ namespace fp {
|
||||||
private:
|
private:
|
||||||
std::unordered_map<chunk_pos, chunk*, _static::chunk_pos_hash, _static::chunk_pos_equality> chunk_storage;
|
std::unordered_map<chunk_pos, chunk*, _static::chunk_pos_hash, _static::chunk_pos_equality> chunk_storage;
|
||||||
protected:
|
protected:
|
||||||
static void generateFullMesh(mesh_storage* mesh, chunk* chunk);
|
|
||||||
|
|
||||||
void generateEdgeMesh(mesh_storage* mesh, chunk* chunk);
|
|
||||||
|
|
||||||
void generateChunkMesh(chunk* chunk);
|
void generateChunkMesh(chunk* chunk);
|
||||||
|
|
||||||
chunk* generateChunk(const chunk_pos& pos);
|
chunk* generateChunk(const chunk_pos& pos);
|
||||||
|
@ -234,8 +215,7 @@ namespace fp {
|
||||||
}
|
}
|
||||||
|
|
||||||
~world() {
|
~world() {
|
||||||
BLT_PRINT_PROFILE("Chunk Mesh", blt::logging::TRACE, true);
|
BLT_PRINT_PROFILE("Chunk", blt::logging::TRACE, true);
|
||||||
BLT_PRINT_PROFILE("Chunk Generate", blt::logging::TRACE, true);
|
|
||||||
for (auto& chunk : chunk_storage)
|
for (auto& chunk : chunk_storage)
|
||||||
delete (chunk.second);
|
delete (chunk.second);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,41 +11,6 @@
|
||||||
#include "stb/stb_perlin.h"
|
#include "stb/stb_perlin.h"
|
||||||
#include <blt/std/format.h>
|
#include <blt/std/format.h>
|
||||||
|
|
||||||
void fp::world::generateFullMesh(mesh_storage* mesh, fp::chunk* chunk) {
|
|
||||||
BLT_START_INTERVAL("Chunk Mesh", "Full Mesh");
|
|
||||||
|
|
||||||
for (int i = 0; i < CHUNK_SIZE; i++) {
|
|
||||||
for (int j = 0; j < CHUNK_SIZE; j++) {
|
|
||||||
for (int k = 0; k < CHUNK_SIZE; k++) {
|
|
||||||
auto*& storage = chunk->getBlockStorage();
|
|
||||||
|
|
||||||
auto& block = fp::registry::get(storage->get({i, j, k}));
|
|
||||||
|
|
||||||
auto texture_index = fp::registry::getTextureIndex(block.textureName);
|
|
||||||
|
|
||||||
// The main chunk mesh can handle opaque and transparent textures. (Transparency will be discarded)
|
|
||||||
if (block.visibility <= registry::TRANSPARENT_TEXTURE) {
|
|
||||||
if (!storage->checkBlockVisibility({i - 1, j, k}))
|
|
||||||
mesh->addFace(X_NEG, {i, j, k}, texture_index);
|
|
||||||
if (!storage->checkBlockVisibility({i + 1, j, k}))
|
|
||||||
mesh->addFace(X_POS, {i, j, k}, texture_index);
|
|
||||||
if (!storage->checkBlockVisibility({i, j - 1, k}))
|
|
||||||
mesh->addFace(Y_NEG, {i, j, k}, texture_index);
|
|
||||||
if (!storage->checkBlockVisibility({i, j + 1, k}))
|
|
||||||
mesh->addFace(Y_POS, {i, j, k}, texture_index);
|
|
||||||
if (!storage->checkBlockVisibility({i, j, k - 1}))
|
|
||||||
mesh->addFace(Z_NEG, {i, j, k}, texture_index);
|
|
||||||
if (!storage->checkBlockVisibility({i, j, k + 1}))
|
|
||||||
mesh->addFace(Z_POS, {i, j, k}, texture_index);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
chunk->markPartialComplete();
|
|
||||||
BLT_END_INTERVAL("Chunk Mesh", "Full Mesh");
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void checkEdgeFaces(
|
inline void checkEdgeFaces(
|
||||||
fp::mesh_storage* mesh, fp::chunk* chunk, fp::chunk* neighbour, fp::face face,
|
fp::mesh_storage* mesh, fp::chunk* chunk, fp::chunk* neighbour, fp::face face,
|
||||||
const fp::block_pos& pos, const fp::block_pos& neighbour_pos
|
const fp::block_pos& pos, const fp::block_pos& neighbour_pos
|
||||||
|
@ -60,22 +25,55 @@ inline void checkEdgeFaces(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void fp::world::generateEdgeMesh(mesh_storage* mesh, fp::chunk* chunk) {
|
void fp::world::generateChunkMesh(chunk* chunk) {
|
||||||
BLT_START_INTERVAL("Chunk Mesh", "Edge Mesh");
|
// don't re-mesh unless requested
|
||||||
// don't try to regen the chunk mesh unless there is a chance all neighbours are not null
|
if (chunk->getDirtiness() != DIRTY)
|
||||||
|
return;
|
||||||
|
// don't try to re-mesh the chunk unless there is a chance all neighbours are not null
|
||||||
if (chunk->getStatus() != chunk_update_status::NEIGHBOUR_CREATE)
|
if (chunk->getStatus() != chunk_update_status::NEIGHBOUR_CREATE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
chunk_neighbours neighbours{};
|
chunk_neighbours neighbours{};
|
||||||
getNeighbours(chunk->getPos(), neighbours);
|
getNeighbours(chunk->getPos(), neighbours);
|
||||||
|
|
||||||
|
|
||||||
// if none of the neighbours exist we cannot continue!
|
// if none of the neighbours exist we cannot continue!
|
||||||
for (auto* neighbour : neighbours.neighbours) {
|
for (auto* neighbour : neighbours.neighbours) {
|
||||||
if (!neighbour)
|
if (!neighbour)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto* mesh = new mesh_storage();
|
||||||
|
|
||||||
|
BLT_START_INTERVAL("Chunk", "Mesh");
|
||||||
|
|
||||||
|
auto*& block_storage = chunk->getBlockStorage();
|
||||||
|
|
||||||
|
for (int i = 0; i < CHUNK_SIZE; i++) {
|
||||||
|
for (int j = 0; j < CHUNK_SIZE; j++) {
|
||||||
|
for (int k = 0; k < CHUNK_SIZE; k++) {
|
||||||
|
auto& block = fp::registry::get(block_storage->get({i, j, k}));
|
||||||
|
|
||||||
|
auto texture_index = fp::registry::getTextureIndex(block.textureName);
|
||||||
|
|
||||||
|
// The main chunk mesh can handle opaque and transparent textures. (Transparency will be discarded)
|
||||||
|
if (block.visibility <= registry::TRANSPARENT_TEXTURE) {
|
||||||
|
if (block_storage->checkBlockVisibility({i - 1, j, k}))
|
||||||
|
mesh->addFace(X_NEG, {i, j, k}, texture_index);
|
||||||
|
if (block_storage->checkBlockVisibility({i + 1, j, k}))
|
||||||
|
mesh->addFace(X_POS, {i, j, k}, texture_index);
|
||||||
|
if (block_storage->checkBlockVisibility({i, j - 1, k}))
|
||||||
|
mesh->addFace(Y_NEG, {i, j, k}, texture_index);
|
||||||
|
if (block_storage->checkBlockVisibility({i, j + 1, k}))
|
||||||
|
mesh->addFace(Y_POS, {i, j, k}, texture_index);
|
||||||
|
if (block_storage->checkBlockVisibility({i, j, k - 1}))
|
||||||
|
mesh->addFace(Z_NEG, {i, j, k}, texture_index);
|
||||||
|
if (block_storage->checkBlockVisibility({i, j, k + 1}))
|
||||||
|
mesh->addFace(Z_POS, {i, j, k}, texture_index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < CHUNK_SIZE; i++) {
|
for (int i = 0; i < CHUNK_SIZE; i++) {
|
||||||
for (int j = 0; j < CHUNK_SIZE; j++) {
|
for (int j = 0; j < CHUNK_SIZE; j++) {
|
||||||
checkEdgeFaces(
|
checkEdgeFaces(
|
||||||
|
@ -101,21 +99,11 @@ void fp::world::generateEdgeMesh(mesh_storage* mesh, fp::chunk* chunk) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
chunk->getMeshStorage() = mesh;
|
||||||
chunk->getStatus() = NONE;
|
chunk->getStatus() = NONE;
|
||||||
chunk->markComplete();
|
chunk->markRefresh();
|
||||||
BLT_END_INTERVAL("Chunk Mesh", "Edge Mesh");
|
|
||||||
}
|
|
||||||
|
|
||||||
void fp::world::generateChunkMesh(fp::chunk* chunk) {
|
|
||||||
if (chunk->getMeshStorage() == nullptr)
|
|
||||||
chunk->getMeshStorage() = new mesh_storage();
|
|
||||||
|
|
||||||
if (chunk->getDirtiness() == FULL_MESH) { // full chunk mesh
|
BLT_END_INTERVAL("Chunk", "Mesh");
|
||||||
generateFullMesh(chunk->getMeshStorage(), chunk);
|
|
||||||
}
|
|
||||||
if (chunk->getDirtiness() == PARTIAL_MESH) { // partial chunk mesh (had null neighbours)
|
|
||||||
generateEdgeMesh(chunk->getMeshStorage(), chunk);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::queue<fp::chunk_pos> chunks_to_generate{};
|
std::queue<fp::chunk_pos> chunks_to_generate{};
|
||||||
|
@ -248,5 +236,5 @@ void fp::chunk::updateChunkMesh() {
|
||||||
// delete the local chunk mesh memory, since we no longer need to store it.
|
// delete the local chunk mesh memory, since we no longer need to store it.
|
||||||
delete (mesh);
|
delete (mesh);
|
||||||
mesh = nullptr;
|
mesh = nullptr;
|
||||||
markDone();
|
dirtiness = OKAY;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,13 +5,18 @@
|
||||||
*/
|
*/
|
||||||
#include <world/registry.h>
|
#include <world/registry.h>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
#include <phmap.h>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
#include <condition_variable>
|
#include <condition_variable>
|
||||||
|
|
||||||
|
#ifdef __EMSCRIPTEN__
|
||||||
std::unordered_map<fp::block_type, fp::registry::block_properties> blocks;
|
std::unordered_map<fp::block_type, fp::registry::block_properties> blocks;
|
||||||
|
#else
|
||||||
|
phmap::flat_hash_map<fp::block_type, fp::registry::block_properties> blocks;
|
||||||
|
#endif
|
||||||
|
|
||||||
fp::texture::palette* base_palette;
|
fp::texture::palette* base_palette;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue