Commit Graph

139 Commits (ebef6080007defc6e6a6bfa56fbe5ddbbf8f148c)

Author SHA1 Message Date
EmaMaker ebef608000 blockpick: avoid blocks being placed diagonally 2023-10-12 21:47:00 +02:00
EmaMaker 0b294bb35b blockpick: cleanup blockpick place code 2023-10-09 21:55:31 +02:00
EmaMaker f3d8ffed54 blockpick: skip iteration if block has not changed 2023-10-04 23:37:04 +02:00
EmaMaker 0560fd43c6 print gpu in debug window 2023-10-04 20:58:06 +02:00
EmaMaker 62212a22ab main: do not terminate imgui, leads to crash 2023-10-04 14:59:31 +02:00
EmaMaker 357f67aac1 chunkmgr: debug info for chunkmgr 2023-10-04 14:59:17 +02:00
EmaMaker 1b4cef8958 Merge pull request 'Refactor Main/Update thread communication' (#14) from multithread-refactor into main
Reviewed-on: #14
2023-10-04 14:58:07 +02:00
EmaMaker e4c6eb50f3 Merge branch 'main' into multithread-refactor 2023-10-04 14:55:47 +02:00
EmaMaker 9b5939d256 renderer: do not send empty meshes to the gpu only at creation
I feel never sending empty meshes to the GPU is the cause of the bug causing floating quads near
chunk borders when a block is placed and then destroyed.
When destroying a block in a chunk, if nearby empty chunk meshes are not updated, the old mesh is
kept, which includes a quad at the border
2023-10-04 14:53:05 +02:00
EmaMaker 8401a3dca7 Merge branch 'main' into multithread-refactor 2023-10-04 14:51:56 +02:00
EmaMaker 255460892d blockpick control belongs to control, not chunkmgr 2023-10-04 14:41:44 +02:00
EmaMaker afdd622ec2 refactor message system between main and update threads
restores blockpicking with new multithread system
2023-10-04 14:35:29 +02:00
EmaMaker 93bc0e7066 renderer: do not send empty meshes to the gpu only at creation
I feel never sending empty meshes to the GPU is the cause of the bug causing floating quads near
chunk borders when a block is placed and then destroyed.
When destroying a block in a chunk, if nearby empty chunk meshes are not updated, the old mesh is
kept, which includes a quad at the border
2023-10-04 13:57:12 +02:00
EmaMaker 8544620899 Merge pull request 'Refactor Meshing/Rendering communication' (#13) from multithread-refactor into main
Reviewed-on: #13
2023-10-04 13:52:26 +02:00
EmaMaker a4f1e5fc1f Merge branch 'main' into multithread-refactor 2023-10-04 13:51:56 +02:00
EmaMaker 78b65894b7 chunkmesher: compiler flag to not show borders at world limit 2023-10-04 13:35:50 +02:00
EmaMaker 355da726f6 Merge pull request 'Refactor Secondary Threads' (#12) from multithread-refactor into main
Reviewed-on: #12
2023-10-04 13:32:23 +02:00
EmaMaker ba95db4678 renderer: also delete meshes of old chunks 2023-10-04 13:24:06 +02:00
EmaMaker 7c82a71dd0 chunk: vram buffers are managed by renderer now 2023-10-04 13:24:06 +02:00
EmaMaker 7786d4f04d renderer: use ChunkMeshData from rendering thread
This system decouples the Secondary threads from the Render thread. Once a chunk is meshed, only the mesh data is sent to the rendering thread, which does not use any direct reference to the chunk itself
2023-10-04 13:24:06 +02:00
EmaMaker 1822911845 chunkmesher: use goto for error handling 2023-10-04 13:24:06 +02:00
EmaMaker d0ddf2256f move chunkmeshdata into its own file
And let it be managed by chunkmesher instead of chunkmanager
2023-10-04 13:23:49 +02:00
EmaMaker 88abf21502 multithread: refactor update thread, communication between mesh/gen/upd threads
- Use parallel_for to iterate over all the stored chunks
- Only push a chunk to a queue if it is not already present, using chunk state bitfield (solves
	memory leak, continously adding new elements to a queue)
- Properly delete an element from chunks concurrent_hash_map using accessor, then free the memory
(solves memory leak: not being able to delete old elements and always adding new ones)

Breaks:

- Rendering (will be properly refactored in a future commit)
- Block picking (will be refactored in a future commit)
2023-10-04 13:10:05 +02:00
EmaMaker f4947d5f70 debugwindow: catch exception to avoid crash when missing parameters 2023-10-04 12:58:00 +02:00
EmaMaker 4e7fadd2b9 chunk: use chunk state to mark presence of chunk in thread communication queues 2023-10-04 12:57:57 +02:00
EmaMaker d1b151f92f chunk: typedef for chunk state 2023-10-04 12:57:57 +02:00
EmaMaker 44edf3e53a Merge pull request 'Misc fixes in preparation for multithreading refactor' (#10) from multithread-refactor into main
Reviewed-on: #10
2023-10-03 22:55:11 +02:00
EmaMaker 3adb061057 Merge branch 'main' into multithread-refactor 2023-10-03 22:53:42 +02:00
EmaMaker 1a50d1fb84 chunkmgr: span chunk indices in a cube around the player, not a sphere 2023-10-03 22:45:09 +02:00
EmaMaker 60bbc85682 chunk: store index in chunk itself 2023-10-03 22:45:09 +02:00
EmaMaker 490f207e39 chunk/mgr: calculate index belongs to chunk namespace 2023-10-03 22:45:09 +02:00
EmaMaker c6d00c4200 fix type mismatch in chunk index/coordinates
typedef an appropriate chunk_index_t and chunk_intcoord_t
2023-10-03 22:45:09 +02:00
EmaMaker 2a57796ed2 move input handling from main into dedicated file 2023-10-03 22:45:09 +02:00
EmaMaker ca043bac68 threads: allow for proper shutdown
using `if` instead of `while` avoids the need to wait for the queue to empty to shutdown the thread
2023-10-03 22:44:55 +02:00
EmaMaker f6f4057109 update player debug variables in main instead of chunkmgr 2023-10-03 22:09:03 +02:00
EmaMaker 353ef37186 renderer: perform frustum culling only if chunk has vertices 2023-10-03 22:08:40 +02:00
EmaMaker 880c634be0 camera: set atomic position at startup
this avoids the first few chunk update loops recognizing the camera as being positioned at (0,0,0), which in turns avoids wastefully generating chunks out of view at startup
2023-10-03 22:08:40 +02:00
EmaMaker 9ad0485a79 Merge pull request 'Adds HUD elements' (#9) from hud into main
Reviewed-on: #9
2023-09-20 12:43:59 +02:00
EmaMaker 50bc52a679 debug window: use wireframe from checkbox in rendering 2023-09-20 12:42:05 +02:00
EmaMaker 07068d740a debug window: use block type from slider in block picking 2023-09-20 12:42:05 +02:00
EmaMaker 52696f2dde debug window: use crosshair type from slider in shader 2023-09-20 12:42:05 +02:00
EmaMaker 9d2d0c8772 debug window: populate with data 2023-09-20 12:42:05 +02:00
EmaMaker f526e9b152 create debug window with imgui 2023-09-20 12:42:05 +02:00
EmaMaker e7c4b2d56b lib: add dearimgui lib 2023-09-20 12:42:05 +02:00
EmaMaker a6a419fdff hud: crosshair with fragment shader 2023-09-20 12:42:05 +02:00
EmaMaker 3f61a6a753 renderer: screenshot by saving render texture to file 2023-09-20 12:37:32 +02:00
EmaMaker 00a4b8e1e2 renderer: properly handle framebuffer resizing 2023-09-20 12:37:32 +02:00
EmaMaker 4b723d58fa libs: import stb_image_write 2023-09-20 12:37:32 +02:00
EmaMaker 1c0ee1315f renderer: render scene to a texture
And then render the texture onto a quad that fills the screen
The screen-filled quad upon which the texture is rendered must never be rendered in wireframe. Rendering in wireframe only makes sense when rendering the world on the texture
2023-09-20 12:37:32 +02:00
EmaMaker 6670f3b41c shader: make geometry shader not mandatory 2023-09-20 12:37:32 +02:00