diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8bd80420c..537bf04ca 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,6 +19,8 @@ jobs: run: sudo apt update && sudo apt install freeglut3-dev libx11-dev clang-15 - name: Build run: ./make.sh + - name: Test + run: ./make.sh RunTests build-and-release-ubuntu-20: runs-on: ubuntu-20.04 @@ -30,6 +32,8 @@ jobs: run: sudo apt update && sudo apt install freeglut3-dev libx11-dev clang - name: Build run: ./make.sh + - name: Test + run: ./make.sh RunTests - name: Tar if: startsWith(github.ref, 'refs/tags/') run: ./make.sh BundleRelease @@ -57,6 +61,9 @@ jobs: - name: Build shell: bash run: ./make.sh + - name: Test + shell: bash + run: ./make.sh RunTests - name: Tar if: startsWith(github.ref, 'refs/tags/') shell: bash diff --git a/CHANGELOG.txt b/CHANGELOG.txt index a7873db2d..7fb6ef078 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,3 +1,45 @@ +* 1.6.1 + +- Change untextured_3d_geometry_buffer to have a `data_type Type` + This is a pretty major internal change. untextured_3d_geometry_buffers can + now switch between 32-bit float and 8-bit int. When loading a model from + disk, the size of the model is taken into account and the appropriate type + is chosen dynamically. + + This required a fair rewrite of the low-level vertex buffering routines to + be able to handle the permutations. This is still somewhat of a WIP; I + didn't finish all of them and the ones not done fall-back to the most + general routine, which is the slowest. I expect I'll rewrite/delete this + code again before performance in that code is the biggest problem I have. + +- Change world updates to happen in serial on a dedicated thread + Previous to this, multiple world updates could be in-flight at any given + time, which if overlapping would stomp on each other. Serializing updates + onto a single thread ensures that: + a) Updates are correct + b) Updates happen in the order they were issued + c) Chunks affected by multiple updates on a single frame only have their + mesh rebuilt once + + (c) is accomplished by completing all queued update jobs and then issuing + the chunk mesh rebuild jobs, one per unique chunk updated. + +- Add ability to create new assets from a world selection and serialize `.chunk` assets to disk + The selection region is saved out as a world_chunk + +- Add ability to load asset `.chunk`s from disk + +- Add abiltiy to render AssetType_WorldChunk + +- Fix layered brush previews crashing the program + +- Fix crash in AreEqual if null pointers were passed + +- Fixed failing tests, added test runs to CI/CD + + + + * 1.6.0 - Renderer now lives on its own thread. diff --git a/examples/tools/voxel_synthesis_rule_baker/game.cpp b/examples/tools/voxel_synthesis_rule_baker/game.cpp index 142dc844c..263b381e9 100644 --- a/examples/tools/voxel_synthesis_rule_baker/game.cpp +++ b/examples/tools/voxel_synthesis_rule_baker/game.cpp @@ -829,7 +829,7 @@ BONSAI_API_MAIN_THREAD_INIT_CALLBACK() Asset->LoadState = AssetLoadState_Loaded; model *Model = Allocate(model, Resources->GameMemory, 1); - untextured_3d_geometry_buffer *Mesh = AllocateTempMesh(Resources->GameMemory); + untextured_3d_geometry_buffer *Mesh = AllocateTempMesh(Resources->GameMemory, DataType_v3); AtomicReplaceMesh(&Model->Meshes, MeshBit_Lod0, Mesh, __rdtsc()); Asset->Models.Start = Model; @@ -849,12 +849,12 @@ BONSAI_API_MAIN_THREAD_INIT_CALLBACK() /* TempMemory, */ /* VoxData->Palette ); */ - BuildWorldChunkMeshFromMarkedVoxels_Greedy( ChunkData->Voxels, - ChunkData->Dim, - VoxOffset, VoxOffset+Global_TileDim, - Model->Meshes.E[0], - 0, - GetTranArena() ); + BuildWorldChunkMeshFromMarkedVoxels_Greedy_v3( ChunkData->Voxels, + ChunkData->Dim, + VoxOffset, VoxOffset+Global_TileDim, + Model->Meshes.E[0], + 0, + GetTranArena() ); /* BuildWorldChunkMesh_DebugVoxels( ChunkData->Voxels, */ diff --git a/examples/transparency/game.cpp b/examples/transparency/game.cpp index 7f71ac922..7b14a6fcb 100644 --- a/examples/transparency/game.cpp +++ b/examples/transparency/game.cpp @@ -69,14 +69,14 @@ SpawnFireEmitters(entity_block_array *Entities, b32 Colorful = False) } link_internal void -SpawnLineOfEntities(entity **EntityTable, entity_block_array *Storage, v3 BaseP, v3 Offset, s32 Count) +SpawnLineOfEntities(entity **EntityTable, entity_block_array *Storage, v3 BaseP, v3 Stride, s32 Count) { RangeIterator(Index, Count) { entity *E = TryGetFreeEntityPtr(EntityTable); Assert(E); - E->P.Offset = BaseP + (Offset*r32(Index)); + E->P.Offset = BaseP + (Stride*r32(Index)); SpawnEntity(E); Push(Storage, E); } @@ -101,7 +101,7 @@ BONSAI_API_MAIN_THREAD_INIT_CALLBACK() GameState = Allocate(game_state, Resources->GameMemory, 1); s32 EmitterCount = 6; - v3 xStride = V3(24, 0, 0); + v3 xStride = V3(32, 0, 0); { @@ -124,7 +124,7 @@ BONSAI_API_MAIN_THREAD_INIT_CALLBACK() { s32 yAt = 16; - SpawnLineOfEntities(EntityTable, &GameState->SplosionEmitters, V3(-32, yAt, 4), xStride, EmitterCount); + SpawnLineOfEntities(EntityTable, &GameState->SplosionEmitters, V3(-32, yAt, 6), xStride, EmitterCount); SpawnSplosionEmitters(&GameState->SplosionEmitters); } diff --git a/external/bonsai_stdlib b/external/bonsai_stdlib index 901e931dc..5663e381f 160000 --- a/external/bonsai_stdlib +++ b/external/bonsai_stdlib @@ -1 +1 @@ -Subproject commit 901e931dc6fedbd984a7de3eb948f17ee0e7c27c +Subproject commit 5663e381f7e44e68f154bfb2a5b1274e8f9224fc diff --git a/generated/anonymous_function_ui_render_command_RuTTrHiW.h b/generated/anonymous_function_ui_render_command_RuTTrHiW.h index 320044d46..f85debf26 100644 --- a/generated/anonymous_function_ui_render_command_RuTTrHiW.h +++ b/generated/anonymous_function_ui_render_command_RuTTrHiW.h @@ -1,4 +1,4 @@ -// external/bonsai_stdlib/src/ui/ui.cpp:2210:0 +// external/bonsai_stdlib/src/ui/ui.cpp:2260:0 case type_ui_render_command_window_start: { diff --git a/generated/anonymous_input_Lwen2qoF.h b/generated/anonymous_input_Lwen2qoF.h index bb291f77b..0da9181e4 100644 --- a/generated/anonymous_input_Lwen2qoF.h +++ b/generated/anonymous_input_Lwen2qoF.h @@ -1,4 +1,4 @@ -// external/bonsai_stdlib/src/ui/ui.cpp:3159:0 +// external/bonsai_stdlib/src/ui/ui.cpp:3228:0 if (Input->Dot.Clicked) { diff --git a/generated/anonymous_render_settings_0_wwLVyABc.h b/generated/anonymous_render_settings_0_wwLVyABc.h index 51e4f0b62..2e6db74b3 100644 --- a/generated/anonymous_render_settings_0_wwLVyABc.h +++ b/generated/anonymous_render_settings_0_wwLVyABc.h @@ -1,4 +1,4 @@ -// src/engine/serdes.cpp:387:0 +// src/engine/serdes.cpp:392:0 E1->UseSsao = E0->UseSsao; E1->UseShadowMapping = E0->UseShadowMapping; diff --git a/generated/anonymous_ui_render_command_nKuoMe2B.h b/generated/anonymous_ui_render_command_nKuoMe2B.h index e88d1ba8c..02bc1de0b 100644 --- a/generated/anonymous_ui_render_command_nKuoMe2B.h +++ b/generated/anonymous_ui_render_command_nKuoMe2B.h @@ -1,4 +1,4 @@ -// external/bonsai_stdlib/src/ui/ui.cpp:2163:0 +// external/bonsai_stdlib/src/ui/ui.cpp:2213:0 case type_ui_render_command_window_start: { diff --git a/generated/are_equal_bonsai_type_info.h b/generated/are_equal_bonsai_type_info.h index 63d8e9986..098253ffc 100644 --- a/generated/are_equal_bonsai_type_info.h +++ b/generated/are_equal_bonsai_type_info.h @@ -3,14 +3,21 @@ link_internal b32 AreEqual(bonsai_type_info *Thing1, bonsai_type_info *Thing2) { - b32 Result = True; - Result &= AreEqual(Thing1->Name, Thing2->Name); + if (Thing1 && Thing2) + { + b32 Result = True; + Result &= AreEqual(Thing1->Name, Thing2->Name); - Result &= AreEqual(Thing1->Version, Thing2->Version); + Result &= AreEqual(Thing1->Version, Thing2->Version); - Result &= AreEqual(Thing1->SizeOfInBytes, Thing2->SizeOfInBytes); + Result &= AreEqual(Thing1->SizeOfInBytes, Thing2->SizeOfInBytes); - return Result; + return Result; + } + else + { + return (Thing1 == Thing2); + } } link_internal b32 diff --git a/generated/are_equal_brush_settings.h b/generated/are_equal_brush_settings.h index 6fbddc1b0..d3b461b6a 100644 --- a/generated/are_equal_brush_settings.h +++ b/generated/are_equal_brush_settings.h @@ -1,11 +1,18 @@ -// src/engine/editor.h:887:0 +// src/engine/editor.h:891:0 link_internal b32 AreEqual(brush_settings *Thing1, brush_settings *Thing2) { - b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( brush_settings ) ); + if (Thing1 && Thing2) + { + b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( brush_settings ) ); - return Result; + return Result; + } + else + { + return (Thing1 == Thing2); + } } link_internal b32 diff --git a/generated/are_equal_debug_profile_scope.h b/generated/are_equal_debug_profile_scope.h index 60a5c9dfd..cf4e1985e 100644 --- a/generated/are_equal_debug_profile_scope.h +++ b/generated/are_equal_debug_profile_scope.h @@ -3,9 +3,16 @@ link_internal b32 AreEqual(debug_profile_scope *Thing1, debug_profile_scope *Thing2) { - b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( debug_profile_scope ) ); + if (Thing1 && Thing2) + { + b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( debug_profile_scope ) ); - return Result; + return Result; + } + else + { + return (Thing1 == Thing2); + } } link_internal b32 diff --git a/generated/are_equal_file_traversal_node.h b/generated/are_equal_file_traversal_node.h index ab39d020e..638c9ad59 100644 --- a/generated/are_equal_file_traversal_node.h +++ b/generated/are_equal_file_traversal_node.h @@ -3,14 +3,21 @@ link_internal b32 AreEqual(file_traversal_node *Thing1, file_traversal_node *Thing2) { - b32 Result = True; - Result &= AreEqual(Thing1->Type, Thing2->Type); + if (Thing1 && Thing2) + { + b32 Result = True; + Result &= AreEqual(Thing1->Type, Thing2->Type); - Result &= AreEqual(Thing1->Dir, Thing2->Dir); + Result &= AreEqual(Thing1->Dir, Thing2->Dir); - Result &= AreEqual(Thing1->Name, Thing2->Name); + Result &= AreEqual(Thing1->Name, Thing2->Name); - return Result; + return Result; + } + else + { + return (Thing1 == Thing2); + } } link_internal b32 diff --git a/generated/are_equal_memory_arena_stats.h b/generated/are_equal_memory_arena_stats.h index 4cf4b0e9c..76556089a 100644 --- a/generated/are_equal_memory_arena_stats.h +++ b/generated/are_equal_memory_arena_stats.h @@ -3,9 +3,16 @@ link_internal b32 AreEqual(memory_arena_stats *Thing1, memory_arena_stats *Thing2) { - b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( memory_arena_stats ) ); + if (Thing1 && Thing2) + { + b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( memory_arena_stats ) ); - return Result; + return Result; + } + else + { + return (Thing1 == Thing2); + } } link_internal b32 diff --git a/generated/are_equal_perlin_noise_params.h b/generated/are_equal_perlin_noise_params.h index 321284320..08090b018 100644 --- a/generated/are_equal_perlin_noise_params.h +++ b/generated/are_equal_perlin_noise_params.h @@ -1,11 +1,18 @@ -// src/engine/editor.h:653:0 +// src/engine/editor.h:657:0 link_internal b32 AreEqual(perlin_noise_params *Thing1, perlin_noise_params *Thing2) { - b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( perlin_noise_params ) ); + if (Thing1 && Thing2) + { + b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( perlin_noise_params ) ); - return Result; + return Result; + } + else + { + return (Thing1 == Thing2); + } } link_internal b32 diff --git a/generated/are_equal_rect3cp.h b/generated/are_equal_rect3cp.h index 1f9ba4205..352897f98 100644 --- a/generated/are_equal_rect3cp.h +++ b/generated/are_equal_rect3cp.h @@ -3,9 +3,16 @@ link_internal b32 AreEqual(rect3cp *Thing1, rect3cp *Thing2) { - b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( rect3cp ) ); + if (Thing1 && Thing2) + { + b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( rect3cp ) ); - return Result; + return Result; + } + else + { + return (Thing1 == Thing2); + } } link_internal b32 diff --git a/generated/are_equal_texture.h b/generated/are_equal_texture.h index 164f95876..1206bafbc 100644 --- a/generated/are_equal_texture.h +++ b/generated/are_equal_texture.h @@ -3,24 +3,31 @@ link_internal b32 AreEqual(texture *Thing1, texture *Thing2) { - b32 Result = True; - Result &= AreEqual(Thing1->ID, Thing2->ID); + if (Thing1 && Thing2) + { + b32 Result = True; + Result &= AreEqual(Thing1->ID, Thing2->ID); - Result &= AreEqual(Thing1->Dim, Thing2->Dim); + Result &= AreEqual(Thing1->Dim, Thing2->Dim); - Result &= AreEqual(Thing1->Slices, Thing2->Slices); + Result &= AreEqual(Thing1->Slices, Thing2->Slices); - Result &= AreEqual(Thing1->Channels, Thing2->Channels); + Result &= AreEqual(Thing1->Channels, Thing2->Channels); - Result &= AreEqual(Thing1->IsDepthTexture, Thing2->IsDepthTexture); + Result &= AreEqual(Thing1->IsDepthTexture, Thing2->IsDepthTexture); - Result &= AreEqual(Thing1->Format, Thing2->Format); + Result &= AreEqual(Thing1->Format, Thing2->Format); - Result &= AreEqual(Thing1->DebugName, Thing2->DebugName); + Result &= AreEqual(Thing1->DebugName, Thing2->DebugName); - Result &= AreEqual(Thing1->Queued, Thing2->Queued); + Result &= AreEqual(Thing1->Queued, Thing2->Queued); - return Result; + return Result; + } + else + { + return (Thing1 == Thing2); + } } link_internal b32 diff --git a/generated/are_equal_ui_toggle.h b/generated/are_equal_ui_toggle.h index 1db755d2c..426daf6b7 100644 --- a/generated/are_equal_ui_toggle.h +++ b/generated/are_equal_ui_toggle.h @@ -1,11 +1,18 @@ -// external/bonsai_stdlib/src/ui/ui.h:114:0 +// external/bonsai_stdlib/src/ui/ui.h:143:0 link_internal b32 AreEqual(ui_toggle *Thing1, ui_toggle *Thing2) { - b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( ui_toggle ) ); + if (Thing1 && Thing2) + { + b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( ui_toggle ) ); - return Result; + return Result; + } + else + { + return (Thing1 == Thing2); + } } link_internal b32 diff --git a/generated/are_equal_voxel_synthesis_change_propagation_info.h b/generated/are_equal_voxel_synthesis_change_propagation_info.h index 5ea293598..f00ef89c5 100644 --- a/generated/are_equal_voxel_synthesis_change_propagation_info.h +++ b/generated/are_equal_voxel_synthesis_change_propagation_info.h @@ -1,11 +1,18 @@ -// src/engine/voxel_synthesis.h:324:0 +// src/engine/voxel_synthesis.h:307:0 link_internal b32 AreEqual(voxel_synthesis_change_propagation_info *Thing1, voxel_synthesis_change_propagation_info *Thing2) { - b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( voxel_synthesis_change_propagation_info ) ); + if (Thing1 && Thing2) + { + b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( voxel_synthesis_change_propagation_info ) ); - return Result; + return Result; + } + else + { + return (Thing1 == Thing2); + } } link_internal b32 diff --git a/generated/are_equal_window_layout.h b/generated/are_equal_window_layout.h new file mode 100644 index 000000000..2c3536031 --- /dev/null +++ b/generated/are_equal_window_layout.h @@ -0,0 +1,95 @@ +// external/bonsai_stdlib/src/ui/ui.h:123:0 + +link_internal b32 +AreEqual(window_layout *Thing1, window_layout *Thing2) +{ + if (Thing1 && Thing2) + { + b32 Result = True; + Result &= AreEqual(Thing1->HashtableKey, Thing2->HashtableKey); + + Result &= AreEqual(Thing1->Title, Thing2->Title); + + Result &= AreEqual(Thing1->Minimized, Thing2->Minimized); + + Result &= AreEqual(Thing1->MinimizeIndex, Thing2->MinimizeIndex); + + Result &= AreEqual(Thing1->Flags, Thing2->Flags); + + Result &= AreEqual(Thing1->Basis, Thing2->Basis); + + Result &= AreEqual(Thing1->MaxClip, Thing2->MaxClip); + + Result &= AreEqual(Thing1->Scroll, Thing2->Scroll); + + Result &= AreEqual(Thing1->CachedFlags, Thing2->CachedFlags); + + Result &= AreEqual(Thing1->CachedBasis, Thing2->CachedBasis); + + Result &= AreEqual(Thing1->CachedMaxClip, Thing2->CachedMaxClip); + + Result &= AreEqual(Thing1->CachedScroll, Thing2->CachedScroll); + + Result &= AreEqual(Thing1->InteractionStackIndex, Thing2->InteractionStackIndex); + + Result &= AreEqual(Thing1->zBackground, Thing2->zBackground); + + Result &= AreEqual(Thing1->zText, Thing2->zText); + + Result &= AreEqual(Thing1->zBorder, Thing2->zBorder); + + Result &= AreEqual(Thing1->zTitleBar, Thing2->zTitleBar); + + Result &= AreEqual(Thing1->NextHotWindow, Thing2->NextHotWindow); + + return Result; + } + else + { + return (Thing1 == Thing2); + } +} + +link_internal b32 +AreEqual(window_layout Thing1, window_layout Thing2) +{ + b32 Result = True; + Result &= AreEqual(Thing1.HashtableKey, Thing2.HashtableKey); + + Result &= AreEqual(Thing1.Title, Thing2.Title); + + Result &= AreEqual(Thing1.Minimized, Thing2.Minimized); + + Result &= AreEqual(Thing1.MinimizeIndex, Thing2.MinimizeIndex); + + Result &= AreEqual(Thing1.Flags, Thing2.Flags); + + Result &= AreEqual(Thing1.Basis, Thing2.Basis); + + Result &= AreEqual(Thing1.MaxClip, Thing2.MaxClip); + + Result &= AreEqual(Thing1.Scroll, Thing2.Scroll); + + Result &= AreEqual(Thing1.CachedFlags, Thing2.CachedFlags); + + Result &= AreEqual(Thing1.CachedBasis, Thing2.CachedBasis); + + Result &= AreEqual(Thing1.CachedMaxClip, Thing2.CachedMaxClip); + + Result &= AreEqual(Thing1.CachedScroll, Thing2.CachedScroll); + + Result &= AreEqual(Thing1.InteractionStackIndex, Thing2.InteractionStackIndex); + + Result &= AreEqual(Thing1.zBackground, Thing2.zBackground); + + Result &= AreEqual(Thing1.zText, Thing2.zText); + + Result &= AreEqual(Thing1.zBorder, Thing2.zBorder); + + Result &= AreEqual(Thing1.zTitleBar, Thing2.zTitleBar); + + Result &= AreEqual(Thing1.NextHotWindow, Thing2.NextHotWindow); + + return Result; +} + diff --git a/generated/are_equal_xml_property.h b/generated/are_equal_xml_property.h index 340e5b481..f003bb9db 100644 --- a/generated/are_equal_xml_property.h +++ b/generated/are_equal_xml_property.h @@ -3,9 +3,16 @@ link_internal b32 AreEqual(xml_property *Thing1, xml_property *Thing2) { - b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( xml_property ) ); + if (Thing1 && Thing2) + { + b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( xml_property ) ); - return Result; + return Result; + } + else + { + return (Thing1 == Thing2); + } } link_internal b32 diff --git a/generated/are_equal_xml_tag.h b/generated/are_equal_xml_tag.h index 65a004b22..3fafca1fe 100644 --- a/generated/are_equal_xml_tag.h +++ b/generated/are_equal_xml_tag.h @@ -3,9 +3,16 @@ link_internal b32 AreEqual(xml_tag *Thing1, xml_tag *Thing2) { - b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( xml_tag ) ); + if (Thing1 && Thing2) + { + b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( xml_tag ) ); - return Result; + return Result; + } + else + { + return (Thing1 == Thing2); + } } link_internal b32 diff --git a/generated/are_equal_xml_token.h b/generated/are_equal_xml_token.h index 8451b8731..95f83c833 100644 --- a/generated/are_equal_xml_token.h +++ b/generated/are_equal_xml_token.h @@ -3,9 +3,16 @@ link_internal b32 AreEqual(xml_token *Thing1, xml_token *Thing2) { - b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( xml_token ) ); + if (Thing1 && Thing2) + { + b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( xml_token ) ); - return Result; + return Result; + } + else + { + return (Thing1 == Thing2); + } } link_internal b32 diff --git a/generated/asyncify_render_function_RenderToTexture_world_chunk.h b/generated/asyncify_render_function_RenderToTexture_world_chunk.h deleted file mode 100644 index 769bde1af..000000000 --- a/generated/asyncify_render_function_RenderToTexture_world_chunk.h +++ /dev/null @@ -1,31 +0,0 @@ -// src/engine/render.cpp:1236:0 - -struct render_to_texture_world_chunk_async_params poof(@async_function_params) -{ -engine_resources *Engine; -asset_thumbnail *Thumb; -world_chunk_lod_element_buffer *Meshes; -v3 Offset; -camera *Camera; -}; - -link_internal work_queue_entry -WorkQueueEntryAsyncFunction( struct_t.type *Params ) -{ - work_queue_entry Result = {}; - NotImplemented; - return Result; -} - -link_internal void -RenderToTexture_world_chunk_Async(work_queue *Queue,engine_resources *Engine ,asset_thumbnail *Thumb ,world_chunk_lod_element_buffer *Meshes ,v3 Offset ,camera *Camera ) -{ - render_to_texture_world_chunk_async_params Params = - { - Engine, Thumb, Meshes, Offset, Camera, - }; - - work_queue_entry Entry = WorkQueueEntryAsyncFunction(&Params); - PushWorkQueueEntry(Queue, &Entry); -} - diff --git a/generated/asyncify_render_function_RenderToTexture_world_chunk_world_chunk.h b/generated/asyncify_render_function_RenderToTexture_world_chunk_world_chunk.h deleted file mode 100644 index aea25b346..000000000 --- a/generated/asyncify_render_function_RenderToTexture_world_chunk_world_chunk.h +++ /dev/null @@ -1,11 +0,0 @@ -// src/engine/work_queue.h:239:0 - -struct render_to_texture_world_chunk_async_params poof(@async_function_params) -{ -engine_resources *Engine; -asset_thumbnail *Thumb; -world_chunk_lod_element_buffer *Meshes; -v3 Offset; -camera *Camera; -}; - diff --git a/generated/asyncify_render_function_c_DrawLod.h b/generated/asyncify_render_function_c_DrawLod.h index 924af6a1e..b1f8fce91 100644 --- a/generated/asyncify_render_function_c_DrawLod.h +++ b/generated/asyncify_render_function_c_DrawLod.h @@ -1,4 +1,4 @@ -// src/engine/work_queue.h:374:0 +// src/engine/work_queue.h:362:0 link_internal void DrawLod_Async(work_queue *Queue,engine_resources *Engine ,shader *Shader ,lod_element_buffer *Meshes ,r32 DistanceSquared ,v3 Basis ,Quaternion Rotation ,v3 Scale ) diff --git a/generated/asyncify_render_function_c_RenderToTexture.h b/generated/asyncify_render_function_c_RenderToTexture.h index 583df462c..d38878c51 100644 --- a/generated/asyncify_render_function_c_RenderToTexture.h +++ b/generated/asyncify_render_function_c_RenderToTexture.h @@ -1,4 +1,4 @@ -// src/engine/work_queue.h:371:0 +// src/engine/work_queue.h:359:0 link_internal void RenderToTexture_Async(work_queue *Queue,engine_resources *Engine ,asset_thumbnail *Thumb ,lod_element_buffer *Meshes ,v3 Offset ,camera *Camera ) diff --git a/generated/asyncify_render_function_c_RenderToTexture_world_chunk_world_chunk.h b/generated/asyncify_render_function_c_RenderToTexture_world_chunk_world_chunk.h deleted file mode 100644 index b5cc27a06..000000000 --- a/generated/asyncify_render_function_c_RenderToTexture_world_chunk_world_chunk.h +++ /dev/null @@ -1,20 +0,0 @@ -// src/engine/work_queue.h:368:0 - -link_internal void -RenderToTexture_world_chunk_Async(work_queue *Queue,engine_resources *Engine ,asset_thumbnail *Thumb ,world_chunk_lod_element_buffer *Meshes ,v3 Offset ,camera *Camera ) -{ - render_to_texture_world_chunk_async_params Params = - { - Engine, Thumb, Meshes, Offset, Camera, - }; - - work_queue_entry Entry = WorkQueueEntryAsyncFunction(&Params); - PushWorkQueueEntry(Queue, &Entry); -} - -link_internal void -DoJob(render_to_texture_world_chunk_async_params *Params) -{ - RenderToTexture_world_chunk( Params->Engine , Params->Thumb , Params->Meshes , Params->Offset , Params->Camera ); -} - diff --git a/generated/asyncify_render_function_h_DrawLod.h b/generated/asyncify_render_function_h_DrawLod.h index 2bdf8ec52..ee15b6b83 100644 --- a/generated/asyncify_render_function_h_DrawLod.h +++ b/generated/asyncify_render_function_h_DrawLod.h @@ -1,4 +1,4 @@ -// src/engine/work_queue.h:245:0 +// src/engine/work_queue.h:239:0 struct draw_lod_async_params poof(@async_function_params) { diff --git a/generated/asyncify_render_function_h_RenderToTexture.h b/generated/asyncify_render_function_h_RenderToTexture.h index 4fcc4b9be..148666f74 100644 --- a/generated/asyncify_render_function_h_RenderToTexture.h +++ b/generated/asyncify_render_function_h_RenderToTexture.h @@ -1,4 +1,4 @@ -// src/engine/work_queue.h:242:0 +// src/engine/work_queue.h:236:0 struct render_to_texture_async_params poof(@async_function_params) { diff --git a/generated/block_array_bitmap_688853862.h b/generated/block_array_bitmap_688853862.h index 84a8adc19..b931be9e8 100644 --- a/generated/block_array_bitmap_688853862.h +++ b/generated/block_array_bitmap_688853862.h @@ -143,6 +143,19 @@ GetPtr(bitmap_block_array *Arr, umm Index) return Result; } +link_internal bitmap * +TryGetPtr(bitmap_block_array *Arr, umm Index) +{ + umm BlockIndex = Index / 8; + umm ElementIndex = Index % 8; + + auto AtE = AtElements(Arr); + umm Total = GetIndex(&AtE); + bitmap *Result = {}; + if (Index < Total) { Result = GetPtr(Arr, Index); } + return Result; +} + link_internal u32 AtElements(bitmap_block *Block) { diff --git a/generated/block_array_c_asset_thumbnail_688856411.h b/generated/block_array_c_asset_thumbnail_688856411.h index 1dbaeb4cb..8b45d6e7f 100644 --- a/generated/block_array_c_asset_thumbnail_688856411.h +++ b/generated/block_array_c_asset_thumbnail_688856411.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:100:0 +// src/engine/editor.cpp:102:0 link_internal asset_thumbnail_block* diff --git a/generated/block_array_entity_688856407.h b/generated/block_array_entity_688856407.h index 79cadf822..0bcdcfedc 100644 --- a/generated/block_array_entity_688856407.h +++ b/generated/block_array_entity_688856407.h @@ -1,4 +1,4 @@ -// src/engine/serdes.cpp:339:0 +// src/engine/serdes.cpp:344:0 struct entity_block { @@ -143,6 +143,19 @@ GetPtr(entity_block_array *Arr, umm Index) return Result; } +link_internal entity * +TryGetPtr(entity_block_array *Arr, umm Index) +{ + umm BlockIndex = Index / 8; + umm ElementIndex = Index % 8; + + auto AtE = AtElements(Arr); + umm Total = GetIndex(&AtE); + entity *Result = {}; + if (Index < Total) { Result = GetPtr(Arr, Index); } + return Result; +} + link_internal u32 AtElements(entity_block *Block) { diff --git a/generated/block_array_entity_ptr_688856411.h b/generated/block_array_entity_ptr_688856411.h index e8ea0d06b..90f3be1cf 100644 --- a/generated/block_array_entity_ptr_688856411.h +++ b/generated/block_array_entity_ptr_688856411.h @@ -1,4 +1,4 @@ -// src/engine/world_chunk.h:325:0 +// src/engine/world_chunk.h:328:0 struct entity_ptr_block { @@ -143,6 +143,19 @@ GetPtr(entity_ptr_block_array *Arr, umm Index) return Result; } +link_internal entity_ptr * +TryGetPtr(entity_ptr_block_array *Arr, umm Index) +{ + umm BlockIndex = Index / 8; + umm ElementIndex = Index % 8; + + auto AtE = AtElements(Arr); + umm Total = GetIndex(&AtE); + entity_ptr *Result = {}; + if (Index < Total) { Result = GetPtr(Arr, Index); } + return Result; +} + link_internal u32 AtElements(entity_ptr_block *Block) { diff --git a/generated/block_array_file_traversal_node_688853862.h b/generated/block_array_file_traversal_node_688853862.h index 7ea77c3fb..d1276ec3d 100644 --- a/generated/block_array_file_traversal_node_688853862.h +++ b/generated/block_array_file_traversal_node_688853862.h @@ -143,6 +143,19 @@ GetPtr(file_traversal_node_block_array *Arr, umm Index) return Result; } +link_internal file_traversal_node * +TryGetPtr(file_traversal_node_block_array *Arr, umm Index) +{ + umm BlockIndex = Index / 8; + umm ElementIndex = Index % 8; + + auto AtE = AtElements(Arr); + umm Total = GetIndex(&AtE); + file_traversal_node *Result = {}; + if (Index < Total) { Result = GetPtr(Arr, Index); } + return Result; +} + link_internal u32 AtElements(file_traversal_node_block *Block) { diff --git a/generated/block_array_h_asset_thumbnail_688856411.h b/generated/block_array_h_asset_thumbnail_688856411.h index d5fc5941d..e1c5886c4 100644 --- a/generated/block_array_h_asset_thumbnail_688856411.h +++ b/generated/block_array_h_asset_thumbnail_688856411.h @@ -1,4 +1,4 @@ -// src/engine/editor.h:502:0 +// src/engine/editor.h:506:0 struct asset_thumbnail_block { @@ -143,6 +143,19 @@ GetPtr(asset_thumbnail_block_array *Arr, umm Index) return Result; } +link_internal asset_thumbnail * +TryGetPtr(asset_thumbnail_block_array *Arr, umm Index) +{ + umm BlockIndex = Index / 8; + umm ElementIndex = Index % 8; + + auto AtE = AtElements(Arr); + umm Total = GetIndex(&AtE); + asset_thumbnail *Result = {}; + if (Index < Total) { Result = GetPtr(Arr, Index); } + return Result; +} + link_internal u32 AtElements(asset_thumbnail_block *Block) { diff --git a/generated/block_array_h_texture_688856411.h b/generated/block_array_h_texture_688856411.h index 110ac1f22..a9bc114cf 100644 --- a/generated/block_array_h_texture_688856411.h +++ b/generated/block_array_h_texture_688856411.h @@ -143,6 +143,19 @@ GetPtr(texture_ptr_block_array *Arr, umm Index) return Result; } +link_internal texture_ptr * +TryGetPtr(texture_ptr_block_array *Arr, umm Index) +{ + umm BlockIndex = Index / 8; + umm ElementIndex = Index % 8; + + auto AtE = AtElements(Arr); + umm Total = GetIndex(&AtE); + texture_ptr *Result = {}; + if (Index < Total) { Result = GetPtr(Arr, Index); } + return Result; +} + link_internal u32 AtElements(texture_ptr_block *Block) { diff --git a/generated/block_array_h_texture_688856411_0.h b/generated/block_array_h_texture_688856411_0.h index f5debc592..00a07de11 100644 --- a/generated/block_array_h_texture_688856411_0.h +++ b/generated/block_array_h_texture_688856411_0.h @@ -143,6 +143,19 @@ GetPtr(texture_block_array *Arr, umm Index) return Result; } +link_internal texture * +TryGetPtr(texture_block_array *Arr, umm Index) +{ + umm BlockIndex = Index / 8; + umm ElementIndex = Index % 8; + + auto AtE = AtElements(Arr); + umm Total = GetIndex(&AtE); + texture *Result = {}; + if (Index < Total) { Result = GetPtr(Arr, Index); } + return Result; +} + link_internal u32 AtElements(texture_block *Block) { diff --git a/generated/block_array_h_u32_688856411.h b/generated/block_array_h_u32_688856411.h index d7ab97355..5f3d078d6 100644 --- a/generated/block_array_h_u32_688856411.h +++ b/generated/block_array_h_u32_688856411.h @@ -143,6 +143,19 @@ GetPtr(u32_block_array *Arr, umm Index) return Result; } +link_internal u32 * +TryGetPtr(u32_block_array *Arr, umm Index) +{ + umm BlockIndex = Index / 8; + umm ElementIndex = Index % 8; + + auto AtE = AtElements(Arr); + umm Total = GetIndex(&AtE); + u32 *Result = {}; + if (Index < Total) { Result = GetPtr(Arr, Index); } + return Result; +} + link_internal u32 AtElements(u32_block *Block) { diff --git a/generated/block_array_h_u8_cursor_688856411.h b/generated/block_array_h_u8_cursor_688856411.h index e0459f9ba..010baeb2f 100644 --- a/generated/block_array_h_u8_cursor_688856411.h +++ b/generated/block_array_h_u8_cursor_688856411.h @@ -143,6 +143,19 @@ GetPtr(u8_cursor_block_array *Arr, umm Index) return Result; } +link_internal u8_cursor * +TryGetPtr(u8_cursor_block_array *Arr, umm Index) +{ + umm BlockIndex = Index / 8; + umm ElementIndex = Index % 8; + + auto AtE = AtElements(Arr); + umm Total = GetIndex(&AtE); + u8_cursor *Result = {}; + if (Index < Total) { Result = GetPtr(Arr, Index); } + return Result; +} + link_internal u32 AtElements(u8_cursor_block *Block) { diff --git a/generated/block_array_h_world_chunk_ptr_688853862_0.h b/generated/block_array_h_world_chunk_ptr_688853862_0.h index aef53b967..6e5191c74 100644 --- a/generated/block_array_h_world_chunk_ptr_688853862_0.h +++ b/generated/block_array_h_world_chunk_ptr_688853862_0.h @@ -1,4 +1,4 @@ -// src/engine/world_chunk.h:416:0 +// src/engine/world_chunk.h:399:0 struct world_chunk_ptr_block { @@ -143,6 +143,19 @@ GetPtr(world_chunk_ptr_block_array *Arr, umm Index) return Result; } +link_internal world_chunk_ptr * +TryGetPtr(world_chunk_ptr_block_array *Arr, umm Index) +{ + umm BlockIndex = Index / 32; + umm ElementIndex = Index % 32; + + auto AtE = AtElements(Arr); + umm Total = GetIndex(&AtE); + world_chunk_ptr *Result = {}; + if (Index < Total) { Result = GetPtr(Arr, Index); } + return Result; +} + link_internal u32 AtElements(world_chunk_ptr_block *Block) { diff --git a/generated/block_array_member_info_688856411.h b/generated/block_array_member_info_688856411.h index 3870ae3ae..e22315a09 100644 --- a/generated/block_array_member_info_688856411.h +++ b/generated/block_array_member_info_688856411.h @@ -143,6 +143,19 @@ GetPtr(member_info_block_array *Arr, umm Index) return Result; } +link_internal member_info * +TryGetPtr(member_info_block_array *Arr, umm Index) +{ + umm BlockIndex = Index / 8; + umm ElementIndex = Index % 8; + + auto AtE = AtElements(Arr); + umm Total = GetIndex(&AtE); + member_info *Result = {}; + if (Index < Total) { Result = GetPtr(Arr, Index); } + return Result; +} + link_internal u32 AtElements(member_info_block *Block) { diff --git a/generated/block_array_model_688856411.h b/generated/block_array_model_688856411.h index 4f9230859..dda3b7ebc 100644 --- a/generated/block_array_model_688856411.h +++ b/generated/block_array_model_688856411.h @@ -1,4 +1,4 @@ -// src/engine/model.h:90:0 +// src/engine/model.h:91:0 struct model_block { @@ -143,6 +143,19 @@ GetPtr(model_block_array *Arr, umm Index) return Result; } +link_internal model * +TryGetPtr(model_block_array *Arr, umm Index) +{ + umm BlockIndex = Index / 8; + umm ElementIndex = Index % 8; + + auto AtE = AtElements(Arr); + umm Total = GetIndex(&AtE); + model *Result = {}; + if (Index < Total) { Result = GetPtr(Arr, Index); } + return Result; +} + link_internal u32 AtElements(model_block *Block) { diff --git a/generated/block_array_standing_spot_688853862.h b/generated/block_array_standing_spot_688853862.h index 75f34647b..723c7402c 100644 --- a/generated/block_array_standing_spot_688853862.h +++ b/generated/block_array_standing_spot_688853862.h @@ -1,4 +1,4 @@ -// src/engine/world_chunk.h:476:0 +// src/engine/world_chunk.h:462:0 struct standing_spot_block { @@ -143,6 +143,19 @@ GetPtr(standing_spot_block_array *Arr, umm Index) return Result; } +link_internal standing_spot * +TryGetPtr(standing_spot_block_array *Arr, umm Index) +{ + umm BlockIndex = Index / 8; + umm ElementIndex = Index % 8; + + auto AtE = AtElements(Arr); + umm Total = GetIndex(&AtE); + standing_spot *Result = {}; + if (Index < Total) { Result = GetPtr(Arr, Index); } + return Result; +} + link_internal u32 AtElements(standing_spot_block *Block) { diff --git a/generated/block_array_vox_data_688856411.h b/generated/block_array_vox_data_688856411.h index 277df2eaf..b4237c924 100644 --- a/generated/block_array_vox_data_688856411.h +++ b/generated/block_array_vox_data_688856411.h @@ -1,4 +1,4 @@ -// src/engine/model.h:84:0 +// src/engine/model.h:85:0 struct vox_data_block { @@ -143,6 +143,19 @@ GetPtr(vox_data_block_array *Arr, umm Index) return Result; } +link_internal vox_data * +TryGetPtr(vox_data_block_array *Arr, umm Index) +{ + umm BlockIndex = Index / 8; + umm ElementIndex = Index % 8; + + auto AtE = AtElements(Arr); + umm Total = GetIndex(&AtE); + vox_data *Result = {}; + if (Index < Total) { Result = GetPtr(Arr, Index); } + return Result; +} + link_internal u32 AtElements(vox_data_block *Block) { diff --git a/generated/block_array_voxel_stack_element_688853862.h b/generated/block_array_voxel_stack_element_688853862.h index 79280a67e..d3294351a 100644 --- a/generated/block_array_voxel_stack_element_688853862.h +++ b/generated/block_array_voxel_stack_element_688853862.h @@ -1,4 +1,4 @@ -// src/engine/world_chunk.cpp:4159:0 +// src/engine/world_update.h:35:0 struct voxel_stack_element_block { @@ -143,6 +143,19 @@ GetPtr(voxel_stack_element_block_array *Arr, umm Index) return Result; } +link_internal voxel_stack_element * +TryGetPtr(voxel_stack_element_block_array *Arr, umm Index) +{ + umm BlockIndex = Index / 8; + umm ElementIndex = Index % 8; + + auto AtE = AtElements(Arr); + umm Total = GetIndex(&AtE); + voxel_stack_element *Result = {}; + if (Index < Total) { Result = GetPtr(Arr, Index); } + return Result; +} + link_internal u32 AtElements(voxel_stack_element_block *Block) { diff --git a/generated/buffer_asset.h b/generated/buffer_asset.h index d7d6c7f7e..b268b5716 100644 --- a/generated/buffer_asset.h +++ b/generated/buffer_asset.h @@ -1,4 +1,4 @@ -// src/engine/asset.h:180:0 +// src/engine/asset.h:194:0 struct asset_buffer { diff --git a/generated/buffer_is_marked_for_growth_world_chunk_geometry_buffer.h b/generated/buffer_is_marked_for_growth_world_chunk_geometry_buffer.h deleted file mode 100644 index 36ebf0455..000000000 --- a/generated/buffer_is_marked_for_growth_world_chunk_geometry_buffer.h +++ /dev/null @@ -1,22 +0,0 @@ -// src/engine/mesh.h:89:0 - -link_internal b32 -BufferIsMarkedForGrowth(world_chunk_geometry_buffer *Dest) -{ - auto ToMark = Dest; - if (Dest->Parent) ToMark = Dest->Parent; - b32 Result = (ToMark->BufferNeedsToGrow > 0); - return Result; -} - -link_internal void -MarkBufferForGrowth(world_chunk_geometry_buffer *Dest, umm Grow) -{ - auto ToMark = Dest; - if (Dest->Parent) ToMark = Dest->Parent; - - // @single_parent_chain_link_untextured_3d - Assert(ToMark->Parent == 0); - ToMark->BufferNeedsToGrow += Grow; -} - diff --git a/generated/buffer_model.h b/generated/buffer_model.h index 59c57cb0d..bbd53b057 100644 --- a/generated/buffer_model.h +++ b/generated/buffer_model.h @@ -1,4 +1,4 @@ -// src/engine/model.h:87:0 +// src/engine/model.h:88:0 struct model_buffer { diff --git a/generated/buffer_standing_spot.h b/generated/buffer_standing_spot.h index 4c4febb16..22bc2f642 100644 --- a/generated/buffer_standing_spot.h +++ b/generated/buffer_standing_spot.h @@ -1,4 +1,4 @@ -// src/engine/world_chunk.h:519:0 +// src/engine/world_chunk.h:505:0 struct standing_spot_buffer { diff --git a/generated/buffer_tile_ruleset.h b/generated/buffer_tile_ruleset.h index 0e925ed33..13739dec7 100644 --- a/generated/buffer_tile_ruleset.h +++ b/generated/buffer_tile_ruleset.h @@ -1,4 +1,4 @@ -// src/engine/voxel_synthesis.h:82:0 +// src/engine/voxel_synthesis.h:65:0 struct tile_ruleset_buffer { diff --git a/generated/buffer_voxel_synth_tile.h b/generated/buffer_voxel_synth_tile.h index a46bdb000..283c551a0 100644 --- a/generated/buffer_voxel_synth_tile.h +++ b/generated/buffer_voxel_synth_tile.h @@ -1,4 +1,4 @@ -// src/engine/voxel_synthesis.h:102:0 +// src/engine/voxel_synthesis.h:85:0 struct voxel_synth_tile_buffer { diff --git a/generated/buffer_world_chunk_ptr.h b/generated/buffer_world_chunk_ptr.h index df0ae728b..127985865 100644 --- a/generated/buffer_world_chunk_ptr.h +++ b/generated/buffer_world_chunk_ptr.h @@ -1,4 +1,4 @@ -// src/engine/world_chunk.h:413:0 +// src/engine/world_chunk.h:396:0 struct world_chunk_ptr_buffer { diff --git a/generated/checked_vertex_buffering_functions_h_untextured_3d_geometry_buffer_v3.h b/generated/checked_vertex_buffering_functions_h_untextured_3d_geometry_buffer_v3.h new file mode 100644 index 000000000..82935ed23 --- /dev/null +++ b/generated/checked_vertex_buffering_functions_h_untextured_3d_geometry_buffer_v3.h @@ -0,0 +1,41 @@ +// src/engine/mesh.h:611:0 + +// +// Rotate, Scale and Offset +// + +inline void +BufferVertsChecked( + untextured_3d_geometry_buffer *Dest, + u32 NumVerts, + v3 *SrcVerts, v3 *SrcNormals, vertex_material *SrcMats, + v3 Offset, + v3 Scale, + Quaternion Rot +); + +// +// Scale and Offset +// + +inline void +BufferVertsChecked( + untextured_3d_geometry_buffer *Dest, + u32 NumVerts, + v3 *SrcVerts, v3 *SrcNormals, vertex_material *SrcMats, + v3 Offset, + v3 Scale +); + +// +// Untransformed +// + +inline void +BufferVertsChecked( + untextured_3d_geometry_buffer *Dest, + u32 NumVerts, + v3 *SrcVerts, v3 *SrcNormals, vertex_material *SrcMats +); + + diff --git a/generated/checked_vertex_buffering_functions_h_untextured_3d_geometry_buffer_v3_u8.h b/generated/checked_vertex_buffering_functions_h_untextured_3d_geometry_buffer_v3_u8.h new file mode 100644 index 000000000..f8f3aa9d0 --- /dev/null +++ b/generated/checked_vertex_buffering_functions_h_untextured_3d_geometry_buffer_v3_u8.h @@ -0,0 +1,41 @@ +// src/engine/mesh.h:613:0 + +// +// Rotate, Scale and Offset +// + +inline void +BufferVertsChecked( + untextured_3d_geometry_buffer *Dest, + u32 NumVerts, + v3_u8 *SrcVerts, v3_u8 *SrcNormals, vertex_material *SrcMats, + v3 Offset, + v3 Scale, + Quaternion Rot +); + +// +// Scale and Offset +// + +inline void +BufferVertsChecked( + untextured_3d_geometry_buffer *Dest, + u32 NumVerts, + v3_u8 *SrcVerts, v3_u8 *SrcNormals, vertex_material *SrcMats, + v3 Offset, + v3 Scale +); + +// +// Untransformed +// + +inline void +BufferVertsChecked( + untextured_3d_geometry_buffer *Dest, + u32 NumVerts, + v3_u8 *SrcVerts, v3_u8 *SrcNormals, vertex_material *SrcMats +); + + diff --git a/generated/checked_vertex_buffering_functions_untextured_3d_geometry_buffer_v3_f32.h b/generated/checked_vertex_buffering_functions_untextured_3d_geometry_buffer_v3_f32.h new file mode 100644 index 000000000..873bf5c64 --- /dev/null +++ b/generated/checked_vertex_buffering_functions_untextured_3d_geometry_buffer_v3_f32.h @@ -0,0 +1,154 @@ +// src/engine/mesh.h:625:0 + +// +// Rotate, Scale and Offset +// + +inline void +BufferVertsChecked( + untextured_3d_geometry_buffer *Dest, + u32 NumVerts, + v3 *SrcVerts, v3 *SrcNormals, vertex_material *SrcMats, + v3 Offset, + v3 Scale, + Quaternion Rot +) +{ + TIMED_FUNCTION(); + if (BufferHasRoomFor(Dest, NumVerts)) + { + switch (Dest->Type) + { + InvalidCase(DataType_Undefinded); + case DataType_v3_u8: + { + v3_u8 *DestVerts = Cast(v3_u8*, Dest->Verts) + Dest->At; + v3_u8 *DestNormals = Cast(v3_u8*, Dest->Normals) + Dest->At; + vertex_material *DestMats = Dest->Mat + Dest->At; + + CopyVertexBuffer(DestVerts, SrcVerts, NumVerts, Offset, Scale, Rot); + CopyNormalBuffer(DestNormals, SrcNormals, NumVerts, Rot); + CopyMaterialBuffer(DestMats, SrcMats, NumVerts); + } break; + + case DataType_v3: + { + v3 *DestVerts = Cast(v3*, Dest->Verts) + Dest->At; + v3 *DestNormals = Cast(v3*, Dest->Normals) + Dest->At; + vertex_material *DestMats = Dest->Mat + Dest->At; + + CopyVertexBuffer(DestVerts, SrcVerts, NumVerts, Offset, Scale, Rot); + CopyNormalBuffer(DestNormals, SrcNormals, NumVerts, Rot); + CopyMaterialBuffer(DestMats, SrcMats, NumVerts); + } break; + } + Dest->At += NumVerts; + } + else + { + // NOTE(Jesse): Supress spamming errors to the console after the first one. + if (BufferIsMarkedForGrowth(Dest) == False) { SoftError("Ran out of memory pushing %d Verts onto Mesh with %d/%d used", NumVerts, Dest->At, Dest->End-1); } + MarkBufferForGrowth(Dest, NumVerts); + } +} + +// +// Scale and Offset +// + +inline void +BufferVertsChecked( + untextured_3d_geometry_buffer *Dest, + u32 NumVerts, + v3 *SrcVerts, v3 *SrcNormals, vertex_material *SrcMats, + v3 Offset, + v3 Scale +) +{ + TIMED_FUNCTION(); + if (BufferHasRoomFor(Dest, NumVerts)) + { + switch (Dest->Type) + { + InvalidCase(DataType_Undefinded); + case DataType_v3_u8: + { + v3_u8 *DestVerts = Cast(v3_u8*, Dest->Verts) + Dest->At; + v3_u8 *DestNormals = Cast(v3_u8*, Dest->Normals) + Dest->At; + vertex_material *DestMats = Dest->Mat + Dest->At; + + CopyVertexBuffer(DestVerts, SrcVerts, NumVerts, Offset, Scale); + CopyNormalBuffer(DestNormals, SrcNormals, NumVerts); + CopyMaterialBuffer(DestMats, SrcMats, NumVerts); + } break; + + case DataType_v3: + { + v3 *DestVerts = Cast(v3*, Dest->Verts) + Dest->At; + v3 *DestNormals = Cast(v3*, Dest->Normals) + Dest->At; + vertex_material *DestMats = Dest->Mat + Dest->At; + + CopyVertexBuffer(DestVerts, SrcVerts, NumVerts, Offset, Scale); + CopyNormalBuffer(DestNormals, SrcNormals, NumVerts); + CopyMaterialBuffer(DestMats, SrcMats, NumVerts); + } break; + } + Dest->At += NumVerts; + } + else + { + if (BufferIsMarkedForGrowth(Dest) == False) { SoftError("Ran out of memory pushing %d Verts onto Mesh with %d/%d used", NumVerts, Dest->At, Dest->End-1); } + MarkBufferForGrowth(Dest, NumVerts); + } +} + + +// +// Untransformed +// + +inline void +BufferVertsChecked( + untextured_3d_geometry_buffer *Dest, + u32 NumVerts, + v3 *SrcVerts, v3 *SrcNormals, vertex_material *SrcMats +) +{ + TIMED_FUNCTION(); + if (BufferHasRoomFor(Dest, NumVerts)) + { + switch (Dest->Type) + { + InvalidCase(DataType_Undefinded); + case DataType_v3_u8: + { + v3_u8 *DestVerts = Cast(v3_u8*, Dest->Verts) + Dest->At; + v3_u8 *DestNormals = Cast(v3_u8*, Dest->Normals) + Dest->At; + vertex_material *DestMats = Dest->Mat + Dest->At; + + CopyVertexBuffer(DestVerts, SrcVerts, NumVerts); + CopyNormalBuffer(DestNormals, SrcNormals, NumVerts); + CopyMaterialBuffer(DestMats, SrcMats, NumVerts); + } break; + + case DataType_v3: + { + v3 *DestVerts = Cast(v3*, Dest->Verts) + Dest->At; + v3 *DestNormals = Cast(v3*, Dest->Normals) + Dest->At; + vertex_material *DestMats = Dest->Mat + Dest->At; + + CopyVertexBuffer(DestVerts, SrcVerts, NumVerts); + CopyNormalBuffer(DestNormals, SrcNormals, NumVerts); + CopyMaterialBuffer(DestMats, SrcMats, NumVerts); + } break; + } + Dest->At += NumVerts; + } + else + { + if (BufferIsMarkedForGrowth(Dest) == False) { SoftError("Ran out of memory pushing %d Verts onto Mesh with %d/%d used", NumVerts, Dest->At, Dest->End-1); } + MarkBufferForGrowth(Dest, NumVerts); + } +} + + diff --git a/generated/checked_vertex_buffering_functions_untextured_3d_geometry_buffer_v3_u8.h b/generated/checked_vertex_buffering_functions_untextured_3d_geometry_buffer_v3_u8.h new file mode 100644 index 000000000..6177fea27 --- /dev/null +++ b/generated/checked_vertex_buffering_functions_untextured_3d_geometry_buffer_v3_u8.h @@ -0,0 +1,154 @@ +// src/engine/mesh.h:627:0 + +// +// Rotate, Scale and Offset +// + +inline void +BufferVertsChecked( + untextured_3d_geometry_buffer *Dest, + u32 NumVerts, + v3_u8 *SrcVerts, v3_u8 *SrcNormals, vertex_material *SrcMats, + v3 Offset, + v3 Scale, + Quaternion Rot +) +{ + TIMED_FUNCTION(); + if (BufferHasRoomFor(Dest, NumVerts)) + { + switch (Dest->Type) + { + InvalidCase(DataType_Undefinded); + case DataType_v3_u8: + { + v3_u8 *DestVerts = Cast(v3_u8*, Dest->Verts) + Dest->At; + v3_u8 *DestNormals = Cast(v3_u8*, Dest->Normals) + Dest->At; + vertex_material *DestMats = Dest->Mat + Dest->At; + + CopyVertexBuffer(DestVerts, SrcVerts, NumVerts, Offset, Scale, Rot); + CopyNormalBuffer(DestNormals, SrcNormals, NumVerts, Rot); + CopyMaterialBuffer(DestMats, SrcMats, NumVerts); + } break; + + case DataType_v3: + { + v3 *DestVerts = Cast(v3*, Dest->Verts) + Dest->At; + v3 *DestNormals = Cast(v3*, Dest->Normals) + Dest->At; + vertex_material *DestMats = Dest->Mat + Dest->At; + + CopyVertexBuffer(DestVerts, SrcVerts, NumVerts, Offset, Scale, Rot); + CopyNormalBuffer(DestNormals, SrcNormals, NumVerts, Rot); + CopyMaterialBuffer(DestMats, SrcMats, NumVerts); + } break; + } + Dest->At += NumVerts; + } + else + { + // NOTE(Jesse): Supress spamming errors to the console after the first one. + if (BufferIsMarkedForGrowth(Dest) == False) { SoftError("Ran out of memory pushing %d Verts onto Mesh with %d/%d used", NumVerts, Dest->At, Dest->End-1); } + MarkBufferForGrowth(Dest, NumVerts); + } +} + +// +// Scale and Offset +// + +inline void +BufferVertsChecked( + untextured_3d_geometry_buffer *Dest, + u32 NumVerts, + v3_u8 *SrcVerts, v3_u8 *SrcNormals, vertex_material *SrcMats, + v3 Offset, + v3 Scale +) +{ + TIMED_FUNCTION(); + if (BufferHasRoomFor(Dest, NumVerts)) + { + switch (Dest->Type) + { + InvalidCase(DataType_Undefinded); + case DataType_v3_u8: + { + v3_u8 *DestVerts = Cast(v3_u8*, Dest->Verts) + Dest->At; + v3_u8 *DestNormals = Cast(v3_u8*, Dest->Normals) + Dest->At; + vertex_material *DestMats = Dest->Mat + Dest->At; + + CopyVertexBuffer(DestVerts, SrcVerts, NumVerts, Offset, Scale); + CopyNormalBuffer(DestNormals, SrcNormals, NumVerts); + CopyMaterialBuffer(DestMats, SrcMats, NumVerts); + } break; + + case DataType_v3: + { + v3 *DestVerts = Cast(v3*, Dest->Verts) + Dest->At; + v3 *DestNormals = Cast(v3*, Dest->Normals) + Dest->At; + vertex_material *DestMats = Dest->Mat + Dest->At; + + CopyVertexBuffer(DestVerts, SrcVerts, NumVerts, Offset, Scale); + CopyNormalBuffer(DestNormals, SrcNormals, NumVerts); + CopyMaterialBuffer(DestMats, SrcMats, NumVerts); + } break; + } + Dest->At += NumVerts; + } + else + { + if (BufferIsMarkedForGrowth(Dest) == False) { SoftError("Ran out of memory pushing %d Verts onto Mesh with %d/%d used", NumVerts, Dest->At, Dest->End-1); } + MarkBufferForGrowth(Dest, NumVerts); + } +} + + +// +// Untransformed +// + +inline void +BufferVertsChecked( + untextured_3d_geometry_buffer *Dest, + u32 NumVerts, + v3_u8 *SrcVerts, v3_u8 *SrcNormals, vertex_material *SrcMats +) +{ + TIMED_FUNCTION(); + if (BufferHasRoomFor(Dest, NumVerts)) + { + switch (Dest->Type) + { + InvalidCase(DataType_Undefinded); + case DataType_v3_u8: + { + v3_u8 *DestVerts = Cast(v3_u8*, Dest->Verts) + Dest->At; + v3_u8 *DestNormals = Cast(v3_u8*, Dest->Normals) + Dest->At; + vertex_material *DestMats = Dest->Mat + Dest->At; + + CopyVertexBuffer(DestVerts, SrcVerts, NumVerts); + CopyNormalBuffer(DestNormals, SrcNormals, NumVerts); + CopyMaterialBuffer(DestMats, SrcMats, NumVerts); + } break; + + case DataType_v3: + { + v3 *DestVerts = Cast(v3*, Dest->Verts) + Dest->At; + v3 *DestNormals = Cast(v3*, Dest->Normals) + Dest->At; + vertex_material *DestMats = Dest->Mat + Dest->At; + + CopyVertexBuffer(DestVerts, SrcVerts, NumVerts); + CopyNormalBuffer(DestNormals, SrcNormals, NumVerts); + CopyMaterialBuffer(DestMats, SrcMats, NumVerts); + } break; + } + Dest->At += NumVerts; + } + else + { + if (BufferIsMarkedForGrowth(Dest) == False) { SoftError("Ran out of memory pushing %d Verts onto Mesh with %d/%d used", NumVerts, Dest->At, Dest->End-1); } + MarkBufferForGrowth(Dest, NumVerts); + } +} + + diff --git a/generated/copy_normal_buffer_v3_u8_v3.h b/generated/copy_normal_buffer_v3_u8_v3.h new file mode 100644 index 000000000..ac245c5d7 --- /dev/null +++ b/generated/copy_normal_buffer_v3_u8_v3.h @@ -0,0 +1,42 @@ +// src/engine/mesh.h:326:0 + +link_inline void +CopyNormalBuffer( v3_u8 *Dest, v3 *Src, u32 NumVerts, Quaternion Rot) +{ + Assert(NumVerts % 3 == 0); + for ( u32 VertIndex = 0; + VertIndex < NumVerts; + VertIndex += 3 ) + { + { + auto N0 = Rotate(Src[VertIndex + 0], Rot); + auto N1 = Rotate(Src[VertIndex + 1], Rot); + auto N2 = Rotate(Src[VertIndex + 2], Rot); + PackAndStoreNormal(Dest+0, N0); + PackAndStoreNormal(Dest+1, N1); + PackAndStoreNormal(Dest+2, N2); + Dest += 3; + } + } +} + +link_inline void +CopyNormalBuffer( v3_u8 *Dest, v3 *Src, u32 NumVerts) +{ + Assert(NumVerts % 3 == 0); + for ( u32 VertIndex = 0; + VertIndex < NumVerts; + VertIndex += 3 ) + { + { + auto N0 = Src[VertIndex + 0]; + auto N1 = Src[VertIndex + 1]; + auto N2 = Src[VertIndex + 2]; + PackAndStoreNormal(Dest+0, N0); + PackAndStoreNormal(Dest+1, N1); + PackAndStoreNormal(Dest+2, N2); + Dest += 3; + } + } +} + diff --git a/generated/copy_normal_buffer_v3_u8_v3_u8.h b/generated/copy_normal_buffer_v3_u8_v3_u8.h new file mode 100644 index 000000000..b0a31ec6a --- /dev/null +++ b/generated/copy_normal_buffer_v3_u8_v3_u8.h @@ -0,0 +1,42 @@ +// src/engine/mesh.h:324:0 + +link_inline void +CopyNormalBuffer( v3_u8 *Dest, v3_u8 *Src, u32 NumVerts, Quaternion Rot) +{ + Assert(NumVerts % 3 == 0); + for ( u32 VertIndex = 0; + VertIndex < NumVerts; + VertIndex += 3 ) + { + { + auto N0 = Rotate(Src[VertIndex + 0], Rot); + auto N1 = Rotate(Src[VertIndex + 1], Rot); + auto N2 = Rotate(Src[VertIndex + 2], Rot); + PackAndStoreNormal(Dest+0, N0); + PackAndStoreNormal(Dest+1, N1); + PackAndStoreNormal(Dest+2, N2); + Dest += 3; + } + } +} + +link_inline void +CopyNormalBuffer( v3_u8 *Dest, v3_u8 *Src, u32 NumVerts) +{ + Assert(NumVerts % 3 == 0); + for ( u32 VertIndex = 0; + VertIndex < NumVerts; + VertIndex += 3 ) + { + { + auto N0 = Src[VertIndex + 0]; + auto N1 = Src[VertIndex + 1]; + auto N2 = Src[VertIndex + 2]; + PackAndStoreNormal(Dest+0, N0); + PackAndStoreNormal(Dest+1, N1); + PackAndStoreNormal(Dest+2, N2); + Dest += 3; + } + } +} + diff --git a/generated/copy_normal_buffer_v3_v3.h b/generated/copy_normal_buffer_v3_v3.h new file mode 100644 index 000000000..a52692eee --- /dev/null +++ b/generated/copy_normal_buffer_v3_v3.h @@ -0,0 +1,42 @@ +// src/engine/mesh.h:328:0 + +link_inline void +CopyNormalBuffer( v3 *Dest, v3 *Src, u32 NumVerts, Quaternion Rot) +{ + Assert(NumVerts % 3 == 0); + for ( u32 VertIndex = 0; + VertIndex < NumVerts; + VertIndex += 3 ) + { + { + auto N0 = Rotate(Src[VertIndex + 0], Rot); + auto N1 = Rotate(Src[VertIndex + 1], Rot); + auto N2 = Rotate(Src[VertIndex + 2], Rot); + PackAndStoreNormal(Dest+0, N0); + PackAndStoreNormal(Dest+1, N1); + PackAndStoreNormal(Dest+2, N2); + Dest += 3; + } + } +} + +link_inline void +CopyNormalBuffer( v3 *Dest, v3 *Src, u32 NumVerts) +{ + Assert(NumVerts % 3 == 0); + for ( u32 VertIndex = 0; + VertIndex < NumVerts; + VertIndex += 3 ) + { + { + auto N0 = Src[VertIndex + 0]; + auto N1 = Src[VertIndex + 1]; + auto N2 = Src[VertIndex + 2]; + PackAndStoreNormal(Dest+0, N0); + PackAndStoreNormal(Dest+1, N1); + PackAndStoreNormal(Dest+2, N2); + Dest += 3; + } + } +} + diff --git a/generated/copy_normal_buffer_v3_v3_u8.h b/generated/copy_normal_buffer_v3_v3_u8.h new file mode 100644 index 000000000..82c2b95fb --- /dev/null +++ b/generated/copy_normal_buffer_v3_v3_u8.h @@ -0,0 +1,42 @@ +// src/engine/mesh.h:330:0 + +link_inline void +CopyNormalBuffer( v3 *Dest, v3_u8 *Src, u32 NumVerts, Quaternion Rot) +{ + Assert(NumVerts % 3 == 0); + for ( u32 VertIndex = 0; + VertIndex < NumVerts; + VertIndex += 3 ) + { + { + auto N0 = Rotate(Src[VertIndex + 0], Rot); + auto N1 = Rotate(Src[VertIndex + 1], Rot); + auto N2 = Rotate(Src[VertIndex + 2], Rot); + PackAndStoreNormal(Dest+0, N0); + PackAndStoreNormal(Dest+1, N1); + PackAndStoreNormal(Dest+2, N2); + Dest += 3; + } + } +} + +link_inline void +CopyNormalBuffer( v3 *Dest, v3_u8 *Src, u32 NumVerts) +{ + Assert(NumVerts % 3 == 0); + for ( u32 VertIndex = 0; + VertIndex < NumVerts; + VertIndex += 3 ) + { + { + auto N0 = Src[VertIndex + 0]; + auto N1 = Src[VertIndex + 1]; + auto N2 = Src[VertIndex + 2]; + PackAndStoreNormal(Dest+0, N0); + PackAndStoreNormal(Dest+1, N1); + PackAndStoreNormal(Dest+2, N2); + Dest += 3; + } + } +} + diff --git a/generated/copy_vertex_buffer_v3_u8_v3.h b/generated/copy_vertex_buffer_v3_u8_v3.h new file mode 100644 index 000000000..e07572313 --- /dev/null +++ b/generated/copy_vertex_buffer_v3_u8_v3.h @@ -0,0 +1,113 @@ +// src/engine/mesh.h:317:0 + +// +// Offset, Scale, Rotate +// +// TODO(Jesse): Do we actually have to upscale to 32-bit float here for 8 bit types? +link_inline void +CopyVertexBuffer( v3_u8 *Dest, v3 *Src, u32 NumVerts, v3 Offset, v3 Scale, Quaternion Rot) +{ + Assert(NumVerts % 3 == 0); + + __m128 mmScale = _mm_set_ps(0, Scale.z, Scale.y, Scale.x); + __m128 mmOffset = _mm_set_ps(0, Offset.z, Offset.y, Offset.x); + + for ( u32 VertIndex = 0; + VertIndex < NumVerts; + VertIndex += 3 ) + { + auto Src0 = Rotate(Src[VertIndex + 0], Rot); + auto Src1 = Rotate(Src[VertIndex + 1], Rot); + auto Src2 = Rotate(Src[VertIndex + 2], Rot); + + f32_reg Vert0; + f32_reg Vert1; + f32_reg Vert2; + + Vert0.Sse = _mm_set_ps(0, Src0.z, Src0.y, Src0.x); + Vert1.Sse = _mm_set_ps(0, Src1.z, Src1.y, Src1.x); + Vert2.Sse = _mm_set_ps(0, Src2.z, Src2.y, Src2.x); + + Vert0.Sse = _mm_add_ps( _mm_mul_ps(Vert0.Sse, mmScale), mmOffset); + Vert1.Sse = _mm_add_ps( _mm_mul_ps(Vert1.Sse, mmScale), mmOffset); + Vert2.Sse = _mm_add_ps( _mm_mul_ps(Vert2.Sse, mmScale), mmOffset); + + v3_u8 Result0 = {{ u8(Vert0.F[0]), u8(Vert0.F[1]), u8(Vert0.F[2]) }}; + v3_u8 Result1 = {{ u8(Vert1.F[0]), u8(Vert1.F[1]), u8(Vert1.F[2]) }}; + v3_u8 Result2 = {{ u8(Vert2.F[0]), u8(Vert2.F[1]), u8(Vert2.F[2]) }}; + + Dest[0] = Result0; + Dest[1] = Result1; + Dest[2] = Result2; + + Dest += 3; + } +} + +// +// Offset, Scale +// +link_inline void +CopyVertexBuffer( v3_u8 *Dest, v3 *Src, u32 NumVerts, v3 Offset, v3 Scale ) +{ + Assert(NumVerts % 3 == 0); + + __m128 mmScale = _mm_set_ps(0, Scale.z, Scale.y, Scale.x); + __m128 mmOffset = _mm_set_ps(0, Offset.z, Offset.y, Offset.x); + + for ( u32 VertIndex = 0; + VertIndex < NumVerts; + VertIndex += 3 ) + { + auto Src0 = Src[VertIndex + 0]; + auto Src1 = Src[VertIndex + 1]; + auto Src2 = Src[VertIndex + 2]; + + f32_reg Vert0; + f32_reg Vert1; + f32_reg Vert2; + + Vert0.Sse = _mm_set_ps(0, Src0.z, Src0.y, Src0.x); + Vert1.Sse = _mm_set_ps(0, Src1.z, Src1.y, Src1.x); + Vert2.Sse = _mm_set_ps(0, Src2.z, Src2.y, Src2.x); + + Vert0.Sse = _mm_add_ps( _mm_mul_ps(Vert0.Sse, mmScale), mmOffset); + Vert1.Sse = _mm_add_ps( _mm_mul_ps(Vert1.Sse, mmScale), mmOffset); + Vert2.Sse = _mm_add_ps( _mm_mul_ps(Vert2.Sse, mmScale), mmOffset); + + v3_u8 Result0 = {{ u8(Vert0.F[0]), u8(Vert0.F[1]), u8(Vert0.F[2]) }}; + v3_u8 Result1 = {{ u8(Vert1.F[0]), u8(Vert1.F[1]), u8(Vert1.F[2]) }}; + v3_u8 Result2 = {{ u8(Vert2.F[0]), u8(Vert2.F[1]), u8(Vert2.F[2]) }}; + + Dest[0] = Result0; + Dest[1] = Result1; + Dest[2] = Result2; + + Dest += 3; + } +} + +link_inline void +CopyVertexBuffer( v3_u8 *Dest, v3 *Src, u32 NumVerts ) +{ + // TODO(Jesse): This conditional isn't working ..? + /* @are_equal(src_t, dest_t)? */ + { + /* MemCopy((u8*)Src, (u8*)Dest, sizeof(*Src)*NumVerts ); */ + } + { + for ( u32 VertIndex = 0; + VertIndex < NumVerts; + VertIndex += 3 ) + { + auto Src0 = Src[VertIndex + 0]; + auto Src1 = Src[VertIndex + 1]; + auto Src2 = Src[VertIndex + 2]; + + Dest[VertIndex + 0] = V3U8(Src0); + Dest[VertIndex + 1] = V3U8(Src1); + Dest[VertIndex + 2] = V3U8(Src2); + } + } +} + diff --git a/generated/copy_vertex_buffer_v3_u8_v3_u8.h b/generated/copy_vertex_buffer_v3_u8_v3_u8.h new file mode 100644 index 000000000..27c94ada2 --- /dev/null +++ b/generated/copy_vertex_buffer_v3_u8_v3_u8.h @@ -0,0 +1,113 @@ +// src/engine/mesh.h:315:0 + +// +// Offset, Scale, Rotate +// +// TODO(Jesse): Do we actually have to upscale to 32-bit float here for 8 bit types? +link_inline void +CopyVertexBuffer( v3_u8 *Dest, v3_u8 *Src, u32 NumVerts, v3 Offset, v3 Scale, Quaternion Rot) +{ + Assert(NumVerts % 3 == 0); + + __m128 mmScale = _mm_set_ps(0, Scale.z, Scale.y, Scale.x); + __m128 mmOffset = _mm_set_ps(0, Offset.z, Offset.y, Offset.x); + + for ( u32 VertIndex = 0; + VertIndex < NumVerts; + VertIndex += 3 ) + { + auto Src0 = Rotate(Src[VertIndex + 0], Rot); + auto Src1 = Rotate(Src[VertIndex + 1], Rot); + auto Src2 = Rotate(Src[VertIndex + 2], Rot); + + f32_reg Vert0; + f32_reg Vert1; + f32_reg Vert2; + + Vert0.Sse = _mm_set_ps(0, Src0.z, Src0.y, Src0.x); + Vert1.Sse = _mm_set_ps(0, Src1.z, Src1.y, Src1.x); + Vert2.Sse = _mm_set_ps(0, Src2.z, Src2.y, Src2.x); + + Vert0.Sse = _mm_add_ps( _mm_mul_ps(Vert0.Sse, mmScale), mmOffset); + Vert1.Sse = _mm_add_ps( _mm_mul_ps(Vert1.Sse, mmScale), mmOffset); + Vert2.Sse = _mm_add_ps( _mm_mul_ps(Vert2.Sse, mmScale), mmOffset); + + v3_u8 Result0 = {{ u8(Vert0.F[0]), u8(Vert0.F[1]), u8(Vert0.F[2]) }}; + v3_u8 Result1 = {{ u8(Vert1.F[0]), u8(Vert1.F[1]), u8(Vert1.F[2]) }}; + v3_u8 Result2 = {{ u8(Vert2.F[0]), u8(Vert2.F[1]), u8(Vert2.F[2]) }}; + + Dest[0] = Result0; + Dest[1] = Result1; + Dest[2] = Result2; + + Dest += 3; + } +} + +// +// Offset, Scale +// +link_inline void +CopyVertexBuffer( v3_u8 *Dest, v3_u8 *Src, u32 NumVerts, v3 Offset, v3 Scale ) +{ + Assert(NumVerts % 3 == 0); + + __m128 mmScale = _mm_set_ps(0, Scale.z, Scale.y, Scale.x); + __m128 mmOffset = _mm_set_ps(0, Offset.z, Offset.y, Offset.x); + + for ( u32 VertIndex = 0; + VertIndex < NumVerts; + VertIndex += 3 ) + { + auto Src0 = Src[VertIndex + 0]; + auto Src1 = Src[VertIndex + 1]; + auto Src2 = Src[VertIndex + 2]; + + f32_reg Vert0; + f32_reg Vert1; + f32_reg Vert2; + + Vert0.Sse = _mm_set_ps(0, Src0.z, Src0.y, Src0.x); + Vert1.Sse = _mm_set_ps(0, Src1.z, Src1.y, Src1.x); + Vert2.Sse = _mm_set_ps(0, Src2.z, Src2.y, Src2.x); + + Vert0.Sse = _mm_add_ps( _mm_mul_ps(Vert0.Sse, mmScale), mmOffset); + Vert1.Sse = _mm_add_ps( _mm_mul_ps(Vert1.Sse, mmScale), mmOffset); + Vert2.Sse = _mm_add_ps( _mm_mul_ps(Vert2.Sse, mmScale), mmOffset); + + v3_u8 Result0 = {{ u8(Vert0.F[0]), u8(Vert0.F[1]), u8(Vert0.F[2]) }}; + v3_u8 Result1 = {{ u8(Vert1.F[0]), u8(Vert1.F[1]), u8(Vert1.F[2]) }}; + v3_u8 Result2 = {{ u8(Vert2.F[0]), u8(Vert2.F[1]), u8(Vert2.F[2]) }}; + + Dest[0] = Result0; + Dest[1] = Result1; + Dest[2] = Result2; + + Dest += 3; + } +} + +link_inline void +CopyVertexBuffer( v3_u8 *Dest, v3_u8 *Src, u32 NumVerts ) +{ + // TODO(Jesse): This conditional isn't working ..? + /* @are_equal(src_t, dest_t)? */ + { + /* MemCopy((u8*)Src, (u8*)Dest, sizeof(*Src)*NumVerts ); */ + } + { + for ( u32 VertIndex = 0; + VertIndex < NumVerts; + VertIndex += 3 ) + { + auto Src0 = Src[VertIndex + 0]; + auto Src1 = Src[VertIndex + 1]; + auto Src2 = Src[VertIndex + 2]; + + Dest[VertIndex + 0] = V3U8(Src0); + Dest[VertIndex + 1] = V3U8(Src1); + Dest[VertIndex + 2] = V3U8(Src2); + } + } +} + diff --git a/generated/copy_vertex_buffer_v3_v3.h b/generated/copy_vertex_buffer_v3_v3.h new file mode 100644 index 000000000..793a09f2a --- /dev/null +++ b/generated/copy_vertex_buffer_v3_v3.h @@ -0,0 +1,113 @@ +// src/engine/mesh.h:319:0 + +// +// Offset, Scale, Rotate +// +// TODO(Jesse): Do we actually have to upscale to 32-bit float here for 8 bit types? +link_inline void +CopyVertexBuffer( v3 *Dest, v3 *Src, u32 NumVerts, v3 Offset, v3 Scale, Quaternion Rot) +{ + Assert(NumVerts % 3 == 0); + + __m128 mmScale = _mm_set_ps(0, Scale.z, Scale.y, Scale.x); + __m128 mmOffset = _mm_set_ps(0, Offset.z, Offset.y, Offset.x); + + for ( u32 VertIndex = 0; + VertIndex < NumVerts; + VertIndex += 3 ) + { + auto Src0 = Rotate(Src[VertIndex + 0], Rot); + auto Src1 = Rotate(Src[VertIndex + 1], Rot); + auto Src2 = Rotate(Src[VertIndex + 2], Rot); + + f32_reg Vert0; + f32_reg Vert1; + f32_reg Vert2; + + Vert0.Sse = _mm_set_ps(0, Src0.z, Src0.y, Src0.x); + Vert1.Sse = _mm_set_ps(0, Src1.z, Src1.y, Src1.x); + Vert2.Sse = _mm_set_ps(0, Src2.z, Src2.y, Src2.x); + + Vert0.Sse = _mm_add_ps( _mm_mul_ps(Vert0.Sse, mmScale), mmOffset); + Vert1.Sse = _mm_add_ps( _mm_mul_ps(Vert1.Sse, mmScale), mmOffset); + Vert2.Sse = _mm_add_ps( _mm_mul_ps(Vert2.Sse, mmScale), mmOffset); + + v3 Result0 = {{ f32(Vert0.F[0]), f32(Vert0.F[1]), f32(Vert0.F[2]) }}; + v3 Result1 = {{ f32(Vert1.F[0]), f32(Vert1.F[1]), f32(Vert1.F[2]) }}; + v3 Result2 = {{ f32(Vert2.F[0]), f32(Vert2.F[1]), f32(Vert2.F[2]) }}; + + Dest[0] = Result0; + Dest[1] = Result1; + Dest[2] = Result2; + + Dest += 3; + } +} + +// +// Offset, Scale +// +link_inline void +CopyVertexBuffer( v3 *Dest, v3 *Src, u32 NumVerts, v3 Offset, v3 Scale ) +{ + Assert(NumVerts % 3 == 0); + + __m128 mmScale = _mm_set_ps(0, Scale.z, Scale.y, Scale.x); + __m128 mmOffset = _mm_set_ps(0, Offset.z, Offset.y, Offset.x); + + for ( u32 VertIndex = 0; + VertIndex < NumVerts; + VertIndex += 3 ) + { + auto Src0 = Src[VertIndex + 0]; + auto Src1 = Src[VertIndex + 1]; + auto Src2 = Src[VertIndex + 2]; + + f32_reg Vert0; + f32_reg Vert1; + f32_reg Vert2; + + Vert0.Sse = _mm_set_ps(0, Src0.z, Src0.y, Src0.x); + Vert1.Sse = _mm_set_ps(0, Src1.z, Src1.y, Src1.x); + Vert2.Sse = _mm_set_ps(0, Src2.z, Src2.y, Src2.x); + + Vert0.Sse = _mm_add_ps( _mm_mul_ps(Vert0.Sse, mmScale), mmOffset); + Vert1.Sse = _mm_add_ps( _mm_mul_ps(Vert1.Sse, mmScale), mmOffset); + Vert2.Sse = _mm_add_ps( _mm_mul_ps(Vert2.Sse, mmScale), mmOffset); + + v3 Result0 = {{ f32(Vert0.F[0]), f32(Vert0.F[1]), f32(Vert0.F[2]) }}; + v3 Result1 = {{ f32(Vert1.F[0]), f32(Vert1.F[1]), f32(Vert1.F[2]) }}; + v3 Result2 = {{ f32(Vert2.F[0]), f32(Vert2.F[1]), f32(Vert2.F[2]) }}; + + Dest[0] = Result0; + Dest[1] = Result1; + Dest[2] = Result2; + + Dest += 3; + } +} + +link_inline void +CopyVertexBuffer( v3 *Dest, v3 *Src, u32 NumVerts ) +{ + // TODO(Jesse): This conditional isn't working ..? + /* @are_equal(src_t, dest_t)? */ + { + /* MemCopy((u8*)Src, (u8*)Dest, sizeof(*Src)*NumVerts ); */ + } + { + for ( u32 VertIndex = 0; + VertIndex < NumVerts; + VertIndex += 3 ) + { + auto Src0 = Src[VertIndex + 0]; + auto Src1 = Src[VertIndex + 1]; + auto Src2 = Src[VertIndex + 2]; + + Dest[VertIndex + 0] = V3(Src0); + Dest[VertIndex + 1] = V3(Src1); + Dest[VertIndex + 2] = V3(Src2); + } + } +} + diff --git a/generated/copy_vertex_buffer_v3_v3_u8_f32.h b/generated/copy_vertex_buffer_v3_v3_u8_f32.h new file mode 100644 index 000000000..f87937e0e --- /dev/null +++ b/generated/copy_vertex_buffer_v3_v3_u8_f32.h @@ -0,0 +1,113 @@ +// src/engine/mesh.h:321:0 + +// +// Offset, Scale, Rotate +// +// TODO(Jesse): Do we actually have to upscale to 32-bit float here for 8 bit types? +link_inline void +CopyVertexBuffer( v3 *Dest, v3_u8 *Src, u32 NumVerts, v3 Offset, v3 Scale, Quaternion Rot) +{ + Assert(NumVerts % 3 == 0); + + __m128 mmScale = _mm_set_ps(0, Scale.z, Scale.y, Scale.x); + __m128 mmOffset = _mm_set_ps(0, Offset.z, Offset.y, Offset.x); + + for ( u32 VertIndex = 0; + VertIndex < NumVerts; + VertIndex += 3 ) + { + auto Src0 = Rotate(Src[VertIndex + 0], Rot); + auto Src1 = Rotate(Src[VertIndex + 1], Rot); + auto Src2 = Rotate(Src[VertIndex + 2], Rot); + + f32_reg Vert0; + f32_reg Vert1; + f32_reg Vert2; + + Vert0.Sse = _mm_set_ps(0, Src0.z, Src0.y, Src0.x); + Vert1.Sse = _mm_set_ps(0, Src1.z, Src1.y, Src1.x); + Vert2.Sse = _mm_set_ps(0, Src2.z, Src2.y, Src2.x); + + Vert0.Sse = _mm_add_ps( _mm_mul_ps(Vert0.Sse, mmScale), mmOffset); + Vert1.Sse = _mm_add_ps( _mm_mul_ps(Vert1.Sse, mmScale), mmOffset); + Vert2.Sse = _mm_add_ps( _mm_mul_ps(Vert2.Sse, mmScale), mmOffset); + + v3 Result0 = {{ f32(Vert0.F[0]), f32(Vert0.F[1]), f32(Vert0.F[2]) }}; + v3 Result1 = {{ f32(Vert1.F[0]), f32(Vert1.F[1]), f32(Vert1.F[2]) }}; + v3 Result2 = {{ f32(Vert2.F[0]), f32(Vert2.F[1]), f32(Vert2.F[2]) }}; + + Dest[0] = Result0; + Dest[1] = Result1; + Dest[2] = Result2; + + Dest += 3; + } +} + +// +// Offset, Scale +// +link_inline void +CopyVertexBuffer( v3 *Dest, v3_u8 *Src, u32 NumVerts, v3 Offset, v3 Scale ) +{ + Assert(NumVerts % 3 == 0); + + __m128 mmScale = _mm_set_ps(0, Scale.z, Scale.y, Scale.x); + __m128 mmOffset = _mm_set_ps(0, Offset.z, Offset.y, Offset.x); + + for ( u32 VertIndex = 0; + VertIndex < NumVerts; + VertIndex += 3 ) + { + auto Src0 = Src[VertIndex + 0]; + auto Src1 = Src[VertIndex + 1]; + auto Src2 = Src[VertIndex + 2]; + + f32_reg Vert0; + f32_reg Vert1; + f32_reg Vert2; + + Vert0.Sse = _mm_set_ps(0, Src0.z, Src0.y, Src0.x); + Vert1.Sse = _mm_set_ps(0, Src1.z, Src1.y, Src1.x); + Vert2.Sse = _mm_set_ps(0, Src2.z, Src2.y, Src2.x); + + Vert0.Sse = _mm_add_ps( _mm_mul_ps(Vert0.Sse, mmScale), mmOffset); + Vert1.Sse = _mm_add_ps( _mm_mul_ps(Vert1.Sse, mmScale), mmOffset); + Vert2.Sse = _mm_add_ps( _mm_mul_ps(Vert2.Sse, mmScale), mmOffset); + + v3 Result0 = {{ f32(Vert0.F[0]), f32(Vert0.F[1]), f32(Vert0.F[2]) }}; + v3 Result1 = {{ f32(Vert1.F[0]), f32(Vert1.F[1]), f32(Vert1.F[2]) }}; + v3 Result2 = {{ f32(Vert2.F[0]), f32(Vert2.F[1]), f32(Vert2.F[2]) }}; + + Dest[0] = Result0; + Dest[1] = Result1; + Dest[2] = Result2; + + Dest += 3; + } +} + +link_inline void +CopyVertexBuffer( v3 *Dest, v3_u8 *Src, u32 NumVerts ) +{ + // TODO(Jesse): This conditional isn't working ..? + /* @are_equal(src_t, dest_t)? */ + { + /* MemCopy((u8*)Src, (u8*)Dest, sizeof(*Src)*NumVerts ); */ + } + { + for ( u32 VertIndex = 0; + VertIndex < NumVerts; + VertIndex += 3 ) + { + auto Src0 = Src[VertIndex + 0]; + auto Src1 = Src[VertIndex + 1]; + auto Src2 = Src[VertIndex + 2]; + + Dest[VertIndex + 0] = V3(Src0); + Dest[VertIndex + 1] = V3(Src1); + Dest[VertIndex + 2] = V3(Src2); + } + } +} + diff --git a/generated/d_union_all_constructors_work_queue_entry__bonsai_render_command.h b/generated/d_union_all_constructors_work_queue_entry__bonsai_render_command.h index 407579c2c..1911280a4 100644 --- a/generated/d_union_all_constructors_work_queue_entry__bonsai_render_command.h +++ b/generated/d_union_all_constructors_work_queue_entry__bonsai_render_command.h @@ -88,19 +88,6 @@ WorkQueueEntryBonsaiRenderCommand( bonsai_render_command_deallocate_world_chunk - }; - return Result; -} - -link_internal work_queue_entry__bonsai_render_command -WorkQueueEntryBonsaiRenderCommand( bonsai_render_command_reallocate_world_chunk_buffers A ) -{ - work_queue_entry__bonsai_render_command Result = { - .Type = type_bonsai_render_command_reallocate_world_chunk_buffers, - .bonsai_render_command_reallocate_world_chunk_buffers = A, - - - }; return Result; } @@ -326,19 +313,6 @@ BonsaiRenderCommandDeallocateWorldChunk( world_chunk* Chunk ) return Reuslt; } -link_internal bonsai_render_command_reallocate_world_chunk_buffers -BonsaiRenderCommandReallocateWorldChunkBuffers( gpu_element_buffer_handles* Handles , world_chunk_geometry_buffer* Mesh ) -{ - bonsai_render_command_reallocate_world_chunk_buffers Reuslt = { - .Handles = Handles -, - .Mesh = Mesh - }; - - - return Reuslt; -} - link_internal bonsai_render_command_do_stuff BonsaiRenderCommandDoStuff( u32 Ignored ) { diff --git a/generated/d_union_bonsai_render_command.h b/generated/d_union_bonsai_render_command.h index c72ad02aa..ffc4cd0f5 100644 --- a/generated/d_union_bonsai_render_command.h +++ b/generated/d_union_bonsai_render_command.h @@ -10,7 +10,6 @@ enum work_queue_entry__bonsai_render_command_type type_bonsai_render_command_reallocate_buffers, type_bonsai_render_command_deallocate_buffers, type_bonsai_render_command_deallocate_world_chunk, - type_bonsai_render_command_reallocate_world_chunk_buffers, type_bonsai_render_command_do_stuff, type_bonsai_render_command_setup_shader, type_bonsai_render_command_teardown_shader, @@ -36,7 +35,6 @@ struct work_queue_entry__bonsai_render_command struct bonsai_render_command_reallocate_buffers bonsai_render_command_reallocate_buffers; struct bonsai_render_command_deallocate_buffers bonsai_render_command_deallocate_buffers; struct bonsai_render_command_deallocate_world_chunk bonsai_render_command_deallocate_world_chunk; - struct bonsai_render_command_reallocate_world_chunk_buffers bonsai_render_command_reallocate_world_chunk_buffers; struct bonsai_render_command_do_stuff bonsai_render_command_do_stuff; struct bonsai_render_command_setup_shader bonsai_render_command_setup_shader; struct bonsai_render_command_teardown_shader bonsai_render_command_teardown_shader; diff --git a/generated/d_union_constructors_work_queue_entry.h b/generated/d_union_constructors_work_queue_entry.h index e9bbb9884..ace7a0118 100644 --- a/generated/d_union_constructors_work_queue_entry.h +++ b/generated/d_union_constructors_work_queue_entry.h @@ -1,4 +1,4 @@ -// src/engine/work_queue.h:330:0 +// src/engine/work_queue.h:324:0 link_internal work_queue_entry diff --git a/generated/d_union_ui_render_command.h b/generated/d_union_ui_render_command.h index f88aee7cd..3b289e345 100644 --- a/generated/d_union_ui_render_command.h +++ b/generated/d_union_ui_render_command.h @@ -1,4 +1,4 @@ -// external/bonsai_stdlib/src/ui/ui.h:774:0 +// external/bonsai_stdlib/src/ui/ui.h:807:0 enum ui_render_command_type { diff --git a/generated/d_union_work_queue_entry.h b/generated/d_union_work_queue_entry.h index ff9583787..0daf3c79a 100644 --- a/generated/d_union_work_queue_entry.h +++ b/generated/d_union_work_queue_entry.h @@ -1,4 +1,4 @@ -// src/engine/work_queue.h:302:0 +// src/engine/work_queue.h:296:0 enum work_queue_entry_type { diff --git a/generated/default_marshal_brush_settings_0.h b/generated/default_marshal_brush_settings_0.h index f72e77745..935c5add6 100644 --- a/generated/default_marshal_brush_settings_0.h +++ b/generated/default_marshal_brush_settings_0.h @@ -1,4 +1,4 @@ -// src/engine/editor.h:945:0 +// src/engine/editor.h:949:0 Live->Type = Stored->Type; diff --git a/generated/default_marshal_brush_settings_1.h b/generated/default_marshal_brush_settings_1.h index 2c49f4df1..6abfe2410 100644 --- a/generated/default_marshal_brush_settings_1.h +++ b/generated/default_marshal_brush_settings_1.h @@ -1,4 +1,4 @@ -// src/engine/editor.h:938:0 +// src/engine/editor.h:942:0 Live->Type = Stored->Type; diff --git a/generated/default_marshal_layered_brush_editor_0.h b/generated/default_marshal_layered_brush_editor_0.h index fee6c5424..048c27a31 100644 --- a/generated/default_marshal_layered_brush_editor_0.h +++ b/generated/default_marshal_layered_brush_editor_0.h @@ -1,4 +1,4 @@ -// src/engine/editor.h:1010:0 +// src/engine/editor.h:1015:0 Live->LayerCount = Stored->LayerCount; diff --git a/generated/default_marshal_layered_brush_editor_1.h b/generated/default_marshal_layered_brush_editor_1.h index e0d8d658d..b64efd566 100644 --- a/generated/default_marshal_layered_brush_editor_1.h +++ b/generated/default_marshal_layered_brush_editor_1.h @@ -1,4 +1,4 @@ -// src/engine/editor.h:1003:0 +// src/engine/editor.h:1008:0 RangeIterator(Index, (256)) { diff --git a/generated/default_marshal_noise_layer_0.h b/generated/default_marshal_noise_layer_0.h index 241ae4a4a..519a7a118 100644 --- a/generated/default_marshal_noise_layer_0.h +++ b/generated/default_marshal_noise_layer_0.h @@ -1,4 +1,4 @@ -// src/engine/editor.h:844:0 +// src/engine/editor.h:848:0 Live->Type = Stored->Type; diff --git a/generated/deserialize_struct_camera_0.h b/generated/deserialize_struct_camera_0.h index 47dae2c3e..bb6d1f6d4 100644 --- a/generated/deserialize_struct_camera_0.h +++ b/generated/deserialize_struct_camera_0.h @@ -1,4 +1,4 @@ -// src/engine/serdes.cpp:59:0 +// src/engine/serdes.cpp:62:0 link_internal b32 Deserialize(u8_cursor *Bytes, camera_0 *Element, memory_arena *Memory, umm Count = 1); diff --git a/generated/deserialize_struct_camera_1.h b/generated/deserialize_struct_camera_1.h index ea31cfdf0..79b3bd63f 100644 --- a/generated/deserialize_struct_camera_1.h +++ b/generated/deserialize_struct_camera_1.h @@ -1,4 +1,4 @@ -// src/engine/serdes.cpp:56:0 +// src/engine/serdes.cpp:59:0 link_internal b32 Deserialize(u8_cursor *Bytes, camera_1 *Element, memory_arena *Memory, umm Count = 1); diff --git a/generated/deserialize_struct_entity.h b/generated/deserialize_struct_entity.h index d702045c9..f787a8869 100644 --- a/generated/deserialize_struct_entity.h +++ b/generated/deserialize_struct_entity.h @@ -1,4 +1,4 @@ -// src/engine/serdes.cpp:331:0 +// src/engine/serdes.cpp:336:0 link_internal b32 Deserialize(u8_cursor *Bytes, entity *Element, memory_arena *Memory, umm Count = 1); diff --git a/generated/deserialize_struct_level_header.h b/generated/deserialize_struct_level_header.h index ff751cd3d..1df3d8ef2 100644 --- a/generated/deserialize_struct_level_header.h +++ b/generated/deserialize_struct_level_header.h @@ -1,4 +1,4 @@ -// src/engine/serdes.cpp:465:0 +// src/engine/serdes.cpp:470:0 link_internal b32 Deserialize(u8_cursor *Bytes, level_header *Element, memory_arena *Memory, umm Count = 1); diff --git a/generated/deserialize_struct_level_header_0.h b/generated/deserialize_struct_level_header_0.h index a51b54048..e4d85dd56 100644 --- a/generated/deserialize_struct_level_header_0.h +++ b/generated/deserialize_struct_level_header_0.h @@ -1,4 +1,4 @@ -// src/engine/serdes.cpp:456:0 +// src/engine/serdes.cpp:461:0 link_internal b32 Deserialize(u8_cursor *Bytes, level_header_0 *Element, memory_arena *Memory, umm Count = 1); diff --git a/generated/deserialize_struct_level_header_1.h b/generated/deserialize_struct_level_header_1.h index 6402fdd31..246a0f389 100644 --- a/generated/deserialize_struct_level_header_1.h +++ b/generated/deserialize_struct_level_header_1.h @@ -1,4 +1,4 @@ -// src/engine/serdes.cpp:459:0 +// src/engine/serdes.cpp:464:0 link_internal b32 Deserialize(u8_cursor *Bytes, level_header_1 *Element, memory_arena *Memory, umm Count = 1); diff --git a/generated/deserialize_struct_level_header_2.h b/generated/deserialize_struct_level_header_2.h index e5087098e..f6c7afd84 100644 --- a/generated/deserialize_struct_level_header_2.h +++ b/generated/deserialize_struct_level_header_2.h @@ -1,4 +1,4 @@ -// src/engine/serdes.cpp:462:0 +// src/engine/serdes.cpp:467:0 link_internal b32 Deserialize(u8_cursor *Bytes, level_header_2 *Element, memory_arena *Memory, umm Count = 1); diff --git a/generated/do_editor_ui_for_compound_type_animation.h b/generated/do_editor_ui_for_compound_type_animation.h index 6429ebbef..a4c59fde8 100644 --- a/generated/do_editor_ui_for_compound_type_animation.h +++ b/generated/do_editor_ui_for_compound_type_animation.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:232:0 +// src/engine/editor.cpp:235:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, animation *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_compound_type_asset.h b/generated/do_editor_ui_for_compound_type_asset.h index ece732b48..de4a45486 100644 --- a/generated/do_editor_ui_for_compound_type_asset.h +++ b/generated/do_editor_ui_for_compound_type_asset.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:302:0 +// src/engine/editor.cpp:332:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, asset *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) @@ -75,10 +75,19 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, asset *Element, cs Name, ui_r DoEditorUi(Ui, Window, // Cast to remove const/volatile keywords if they're there - Cast(model_buffer*,&Element->Models), - CSz("Models"), + Cast(asset_type*,&Element->Type), + CSz("Type"), Params ); + + + + + + + + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } PushTableEnd(Ui); } diff --git a/generated/do_editor_ui_for_compound_type_asset_id.h b/generated/do_editor_ui_for_compound_type_asset_id.h index db1d9fd4c..3c34d5fe1 100644 --- a/generated/do_editor_ui_for_compound_type_asset_id.h +++ b/generated/do_editor_ui_for_compound_type_asset_id.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:299:0 +// src/engine/editor.cpp:324:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, asset_id *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_compound_type_asset_thumbnail.h b/generated/do_editor_ui_for_compound_type_asset_thumbnail.h index 123d682c3..ee81035bc 100644 --- a/generated/do_editor_ui_for_compound_type_asset_thumbnail.h +++ b/generated/do_editor_ui_for_compound_type_asset_thumbnail.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:346:0 +// src/engine/editor.cpp:354:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, asset_thumbnail *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_compound_type_bonsai_futex.h b/generated/do_editor_ui_for_compound_type_bonsai_futex.h index dfdd95f72..be6441e0c 100644 --- a/generated/do_editor_ui_for_compound_type_bonsai_futex.h +++ b/generated/do_editor_ui_for_compound_type_bonsai_futex.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:238:0 +// src/engine/editor.cpp:241:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, bonsai_futex *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_compound_type_bonsai_stdlib.h b/generated/do_editor_ui_for_compound_type_bonsai_stdlib.h index 076962dc5..2bdf2990e 100644 --- a/generated/do_editor_ui_for_compound_type_bonsai_stdlib.h +++ b/generated/do_editor_ui_for_compound_type_bonsai_stdlib.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:169:0 +// src/engine/editor.cpp:172:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, bonsai_stdlib *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_compound_type_brush_layer.h b/generated/do_editor_ui_for_compound_type_brush_layer.h index 3fc0c4d03..1fbf06bd1 100644 --- a/generated/do_editor_ui_for_compound_type_brush_layer.h +++ b/generated/do_editor_ui_for_compound_type_brush_layer.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:355:0 +// src/engine/editor.cpp:363:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, brush_layer *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_compound_type_brush_settings.h b/generated/do_editor_ui_for_compound_type_brush_settings.h index 624946751..ef6bf470b 100644 --- a/generated/do_editor_ui_for_compound_type_brush_settings.h +++ b/generated/do_editor_ui_for_compound_type_brush_settings.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:124:0 +// src/engine/editor.cpp:127:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, brush_settings *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_compound_type_camera.h b/generated/do_editor_ui_for_compound_type_camera.h index 8e92b6a1e..09404cf6a 100644 --- a/generated/do_editor_ui_for_compound_type_camera.h +++ b/generated/do_editor_ui_for_compound_type_camera.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:340:0 +// src/engine/editor.cpp:348:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, camera *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_compound_type_chunk_data.h b/generated/do_editor_ui_for_compound_type_chunk_data.h index 4a1be4a79..da7dd7c53 100644 --- a/generated/do_editor_ui_for_compound_type_chunk_data.h +++ b/generated/do_editor_ui_for_compound_type_chunk_data.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:268:0 +// src/engine/editor.cpp:271:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, chunk_data *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_compound_type_chunk_thumbnail.h b/generated/do_editor_ui_for_compound_type_chunk_thumbnail.h index 074c85656..931e824f1 100644 --- a/generated/do_editor_ui_for_compound_type_chunk_thumbnail.h +++ b/generated/do_editor_ui_for_compound_type_chunk_thumbnail.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:349:0 +// src/engine/editor.cpp:357:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, chunk_thumbnail *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_compound_type_collision_event.h b/generated/do_editor_ui_for_compound_type_collision_event.h index 44cba9e11..37f2306d0 100644 --- a/generated/do_editor_ui_for_compound_type_collision_event.h +++ b/generated/do_editor_ui_for_compound_type_collision_event.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:305:0 +// src/engine/editor.cpp:335:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, collision_event *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_compound_type_debug_state.h b/generated/do_editor_ui_for_compound_type_debug_state.h index 3db15d504..9872015f1 100644 --- a/generated/do_editor_ui_for_compound_type_debug_state.h +++ b/generated/do_editor_ui_for_compound_type_debug_state.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:165:0 +// src/engine/editor.cpp:168:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, debug_state *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_compound_type_engine_debug.h b/generated/do_editor_ui_for_compound_type_engine_debug.h index 3ed264220..4bebe5582 100644 --- a/generated/do_editor_ui_for_compound_type_engine_debug.h +++ b/generated/do_editor_ui_for_compound_type_engine_debug.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:430:0 +// src/engine/editor.cpp:438:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, engine_debug *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_compound_type_engine_resources.h b/generated/do_editor_ui_for_compound_type_engine_resources.h index 1559c58ea..3351ed80e 100644 --- a/generated/do_editor_ui_for_compound_type_engine_resources.h +++ b/generated/do_editor_ui_for_compound_type_engine_resources.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:452:0 +// src/engine/editor.cpp:460:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, engine_resources *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_compound_type_engine_settings.h b/generated/do_editor_ui_for_compound_type_engine_settings.h index d7d63f334..eddfe89f4 100644 --- a/generated/do_editor_ui_for_compound_type_engine_settings.h +++ b/generated/do_editor_ui_for_compound_type_engine_settings.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:448:0 +// src/engine/editor.cpp:456:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, engine_settings *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_compound_type_entity.h b/generated/do_editor_ui_for_compound_type_entity.h index 210124489..4e98f2fba 100644 --- a/generated/do_editor_ui_for_compound_type_entity.h +++ b/generated/do_editor_ui_for_compound_type_entity.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:323:0 +// src/engine/editor.cpp:310:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, entity *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_compound_type_entity_aggregate_type.h b/generated/do_editor_ui_for_compound_type_entity_aggregate_type.h index 39843ad16..5ca04b7e6 100644 --- a/generated/do_editor_ui_for_compound_type_entity_aggregate_type.h +++ b/generated/do_editor_ui_for_compound_type_entity_aggregate_type.h @@ -1,17 +1,17 @@ // examples/turn_based/game_types.h:84:0 link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, entity_aggregate_type *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic) +DoEditorUi(renderer_2d *Ui, window_layout *Window, entity_aggregate_type *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) { if (Element) { - // NOTE(Jesse): This is wacky as fuck, but it's a pretty easy way to - // support not drawing the toggl-y thing if we just want to dump the members. + // NOTE(Jesse): This is wacky as fuck, but it's a pretty easy way to support + // not drawing the toggl-y thing if we just want to dump the members. b32 DrawChildren = True; b32 DidToggle = False; if (Name.Count) { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle entity_aggregate_type", Element), &DefaultUiRenderParams_Generic)) + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle entity_aggregate_type", Element), Params)) { DidToggle = True; PushNewRow(Ui); diff --git a/generated/do_editor_ui_for_compound_type_entity_game_data.h b/generated/do_editor_ui_for_compound_type_entity_game_data.h index 99fbf0f86..881f32d2f 100644 --- a/generated/do_editor_ui_for_compound_type_entity_game_data.h +++ b/generated/do_editor_ui_for_compound_type_entity_game_data.h @@ -1,17 +1,17 @@ // examples/turn_based/game_types.h:98:0 link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, entity_game_data *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic) +DoEditorUi(renderer_2d *Ui, window_layout *Window, entity_game_data *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) { if (Element) { - // NOTE(Jesse): This is wacky as fuck, but it's a pretty easy way to - // support not drawing the toggl-y thing if we just want to dump the members. + // NOTE(Jesse): This is wacky as fuck, but it's a pretty easy way to support + // not drawing the toggl-y thing if we just want to dump the members. b32 DrawChildren = True; b32 DidToggle = False; if (Name.Count) { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle entity_game_data", Element), &DefaultUiRenderParams_Generic)) + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle entity_game_data", Element), Params)) { DidToggle = True; PushNewRow(Ui); diff --git a/generated/do_editor_ui_for_compound_type_entity_id.h b/generated/do_editor_ui_for_compound_type_entity_id.h index 3a679ce28..c5842f4d1 100644 --- a/generated/do_editor_ui_for_compound_type_entity_id.h +++ b/generated/do_editor_ui_for_compound_type_entity_id.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:320:0 +// src/engine/editor.cpp:307:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, entity_id *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_compound_type_entity_position_info.h b/generated/do_editor_ui_for_compound_type_entity_position_info.h index 6c49cc534..bea7e09a4 100644 --- a/generated/do_editor_ui_for_compound_type_entity_position_info.h +++ b/generated/do_editor_ui_for_compound_type_entity_position_info.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:308:0 +// src/engine/editor.cpp:338:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, entity_position_info *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_compound_type_file_traversal_node.h b/generated/do_editor_ui_for_compound_type_file_traversal_node.h index 8e94c3767..45cd330bd 100644 --- a/generated/do_editor_ui_for_compound_type_file_traversal_node.h +++ b/generated/do_editor_ui_for_compound_type_file_traversal_node.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:292:0 +// src/engine/editor.cpp:295:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, file_traversal_node *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_compound_type_fireball_state.h b/generated/do_editor_ui_for_compound_type_fireball_state.h index 87f4bcd8a..bb78092de 100644 --- a/generated/do_editor_ui_for_compound_type_fireball_state.h +++ b/generated/do_editor_ui_for_compound_type_fireball_state.h @@ -1,17 +1,17 @@ // examples/turn_based/game_types.h:107:0 link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, fireball_state *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic) +DoEditorUi(renderer_2d *Ui, window_layout *Window, fireball_state *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) { if (Element) { - // NOTE(Jesse): This is wacky as fuck, but it's a pretty easy way to - // support not drawing the toggl-y thing if we just want to dump the members. + // NOTE(Jesse): This is wacky as fuck, but it's a pretty easy way to support + // not drawing the toggl-y thing if we just want to dump the members. b32 DrawChildren = True; b32 DidToggle = False; if (Name.Count) { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle fireball_state", Element), &DefaultUiRenderParams_Generic)) + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle fireball_state", Element), Params)) { DidToggle = True; PushNewRow(Ui); diff --git a/generated/do_editor_ui_for_compound_type_frustum.h b/generated/do_editor_ui_for_compound_type_frustum.h index bd2e6c367..6ec9e9fbe 100644 --- a/generated/do_editor_ui_for_compound_type_frustum.h +++ b/generated/do_editor_ui_for_compound_type_frustum.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:337:0 +// src/engine/editor.cpp:345:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, frustum *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_compound_type_g_buffer_render_group.h b/generated/do_editor_ui_for_compound_type_g_buffer_render_group.h index 7cb08d576..ac130d3c6 100644 --- a/generated/do_editor_ui_for_compound_type_g_buffer_render_group.h +++ b/generated/do_editor_ui_for_compound_type_g_buffer_render_group.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:418:0 +// src/engine/editor.cpp:426:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, g_buffer_render_group *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_compound_type_game_lights.h b/generated/do_editor_ui_for_compound_type_game_lights.h index 4fbc1d421..5614c7853 100644 --- a/generated/do_editor_ui_for_compound_type_game_lights.h +++ b/generated/do_editor_ui_for_compound_type_game_lights.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:412:0 +// src/engine/editor.cpp:420:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, game_lights *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_compound_type_gpu_element_buffer_handles.h b/generated/do_editor_ui_for_compound_type_gpu_element_buffer_handles.h index c0a07fad3..d61996e1e 100644 --- a/generated/do_editor_ui_for_compound_type_gpu_element_buffer_handles.h +++ b/generated/do_editor_ui_for_compound_type_gpu_element_buffer_handles.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:274:0 +// src/engine/editor.cpp:277:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, gpu_element_buffer_handles *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) @@ -90,6 +90,21 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, gpu_element_buffer_handles *E PushNewRow(Ui); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(data_type*,&Element->ElementType), + CSz("ElementType"), + Params + ); + + + + + + + + DoEditorUi(Ui, Window, // Cast to remove const/volatile keywords if they're there diff --git a/generated/do_editor_ui_for_compound_type_gpu_mapped_element_buffer.h b/generated/do_editor_ui_for_compound_type_gpu_mapped_element_buffer.h index 7185b61ae..b9bde3e6a 100644 --- a/generated/do_editor_ui_for_compound_type_gpu_mapped_element_buffer.h +++ b/generated/do_editor_ui_for_compound_type_gpu_mapped_element_buffer.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:277:0 +// src/engine/editor.cpp:280:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, gpu_mapped_element_buffer *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_compound_type_graphics.h b/generated/do_editor_ui_for_compound_type_graphics.h index dc1c08d16..1de894b60 100644 --- a/generated/do_editor_ui_for_compound_type_graphics.h +++ b/generated/do_editor_ui_for_compound_type_graphics.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:421:0 +// src/engine/editor.cpp:429:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, graphics *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_compound_type_graphics_settings.h b/generated/do_editor_ui_for_compound_type_graphics_settings.h index 9acdc8a49..67ef3ff2f 100644 --- a/generated/do_editor_ui_for_compound_type_graphics_settings.h +++ b/generated/do_editor_ui_for_compound_type_graphics_settings.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:445:0 +// src/engine/editor.cpp:453:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, graphics_settings *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_compound_type_input.h b/generated/do_editor_ui_for_compound_type_input.h index eb9505edd..51d476130 100644 --- a/generated/do_editor_ui_for_compound_type_input.h +++ b/generated/do_editor_ui_for_compound_type_input.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:158:0 +// src/engine/editor.cpp:161:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, input *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_compound_type_input_event.h b/generated/do_editor_ui_for_compound_type_input_event.h index 6881d88fe..6c5b040ec 100644 --- a/generated/do_editor_ui_for_compound_type_input_event.h +++ b/generated/do_editor_ui_for_compound_type_input_event.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:155:0 +// src/engine/editor.cpp:158:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, input_event *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_compound_type_keyframe.h b/generated/do_editor_ui_for_compound_type_keyframe.h index ced2a9edc..7f8d27edd 100644 --- a/generated/do_editor_ui_for_compound_type_keyframe.h +++ b/generated/do_editor_ui_for_compound_type_keyframe.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:229:0 +// src/engine/editor.cpp:232:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, keyframe *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_compound_type_layered_brush_editor.h b/generated/do_editor_ui_for_compound_type_layered_brush_editor.h index 4b568c530..9ad7a0925 100644 --- a/generated/do_editor_ui_for_compound_type_layered_brush_editor.h +++ b/generated/do_editor_ui_for_compound_type_layered_brush_editor.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:358:0 +// src/engine/editor.cpp:366:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, layered_brush_editor *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_compound_type_level_editor.h b/generated/do_editor_ui_for_compound_type_level_editor.h index e5c25e541..599ff6248 100644 --- a/generated/do_editor_ui_for_compound_type_level_editor.h +++ b/generated/do_editor_ui_for_compound_type_level_editor.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:436:0 +// src/engine/editor.cpp:444:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, level_editor *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) @@ -364,6 +364,43 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, level_editor *Element, cs Nam CSz("AssetThumbnails"), Params ); + + + + + + + + + DoEditorUi(Ui, + Window, + Cast(b8*,&Element->NewAssetFromSelection), + CSz("NewAssetFromSelection"), + &DefaultUiRenderParams_Checkbox + ); + + + + + + PushNewRow(Ui); + + if (ToggleButton(Ui, CSz("v NewAssetFromSelectionFilename[512]"), CSz("> NewAssetFromSelectionFilename[512]"), UiId(Window, "toggle level_editor char NewAssetFromSelectionFilename", Element->NewAssetFromSelectionFilename), Params )) + { + OPEN_INDENT_FOR_TOGGLEABLE_REGION(); + PushNewRow(Ui); + RangeIterator(ArrayIndex, 512) + { + DoEditorUi(Ui, Window, Element->NewAssetFromSelectionFilename+ArrayIndex, FSz("NewAssetFromSelectionFilename[%d]", ArrayIndex), Params); + PushNewRow(Ui); + } + CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); + } + PushNewRow(Ui); + + + + PushNewRow(Ui); if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } PushTableEnd(Ui); } diff --git a/generated/do_editor_ui_for_compound_type_lighting_render_group.h b/generated/do_editor_ui_for_compound_type_lighting_render_group.h index 8ce5bf56c..5b13452e4 100644 --- a/generated/do_editor_ui_for_compound_type_lighting_render_group.h +++ b/generated/do_editor_ui_for_compound_type_lighting_render_group.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:415:0 +// src/engine/editor.cpp:423:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, lighting_render_group *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_compound_type_lighting_settings.h b/generated/do_editor_ui_for_compound_type_lighting_settings.h index aea67e52d..0e942ba47 100644 --- a/generated/do_editor_ui_for_compound_type_lighting_settings.h +++ b/generated/do_editor_ui_for_compound_type_lighting_settings.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:208:0 +// src/engine/editor.cpp:211:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, lighting_settings *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_compound_type_lod_element_buffer.h b/generated/do_editor_ui_for_compound_type_lod_element_buffer.h index d0e769dac..4135fde4e 100644 --- a/generated/do_editor_ui_for_compound_type_lod_element_buffer.h +++ b/generated/do_editor_ui_for_compound_type_lod_element_buffer.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:280:0 +// src/engine/editor.cpp:283:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, lod_element_buffer *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_compound_type_model.h b/generated/do_editor_ui_for_compound_type_model.h index cfe417d2a..d91a210da 100644 --- a/generated/do_editor_ui_for_compound_type_model.h +++ b/generated/do_editor_ui_for_compound_type_model.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:283:0 +// src/engine/editor.cpp:286:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, model *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_compound_type_noise_layer.h b/generated/do_editor_ui_for_compound_type_noise_layer.h index 2ce3f5e72..d57a9a14b 100644 --- a/generated/do_editor_ui_for_compound_type_noise_layer.h +++ b/generated/do_editor_ui_for_compound_type_noise_layer.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:352:0 +// src/engine/editor.cpp:360:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, noise_layer *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_compound_type_particle.h b/generated/do_editor_ui_for_compound_type_particle.h index d768c082a..0930fb44b 100644 --- a/generated/do_editor_ui_for_compound_type_particle.h +++ b/generated/do_editor_ui_for_compound_type_particle.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:223:0 +// src/engine/editor.cpp:226:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, particle *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_compound_type_particle_system.h b/generated/do_editor_ui_for_compound_type_particle_system.h index a1ad68ea4..5f4cea964 100644 --- a/generated/do_editor_ui_for_compound_type_particle_system.h +++ b/generated/do_editor_ui_for_compound_type_particle_system.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:226:0 +// src/engine/editor.cpp:229:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, particle_system *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_compound_type_perlin_noise_params.h b/generated/do_editor_ui_for_compound_type_perlin_noise_params.h index cc28ffc0e..fc7664a03 100644 --- a/generated/do_editor_ui_for_compound_type_perlin_noise_params.h +++ b/generated/do_editor_ui_for_compound_type_perlin_noise_params.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:110:0 +// src/engine/editor.cpp:113:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, perlin_noise_params *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_compound_type_physics.h b/generated/do_editor_ui_for_compound_type_physics.h index f366219bf..97bbe744c 100644 --- a/generated/do_editor_ui_for_compound_type_physics.h +++ b/generated/do_editor_ui_for_compound_type_physics.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:214:0 +// src/engine/editor.cpp:217:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, physics *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_compound_type_plane.h b/generated/do_editor_ui_for_compound_type_plane.h index 4513cec78..f1016f68b 100644 --- a/generated/do_editor_ui_for_compound_type_plane.h +++ b/generated/do_editor_ui_for_compound_type_plane.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:334:0 +// src/engine/editor.cpp:342:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, plane *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_compound_type_platform.h b/generated/do_editor_ui_for_compound_type_platform.h index afc7d3353..2c2b66dc0 100644 --- a/generated/do_editor_ui_for_compound_type_platform.h +++ b/generated/do_editor_ui_for_compound_type_platform.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:161:0 +// src/engine/editor.cpp:164:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, platform *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) @@ -71,6 +71,21 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, platform *Element, cs Name, u + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(work_queue*,&Element->WorldUpdateQ), + CSz("WorldUpdateQ"), + Params + ); + + + + + + + + DoEditorUi(Ui, Window, // Cast to remove const/volatile keywords if they're there diff --git a/generated/do_editor_ui_for_compound_type_random_series.h b/generated/do_editor_ui_for_compound_type_random_series.h index bba30e3dc..2272a2447 100644 --- a/generated/do_editor_ui_for_compound_type_random_series.h +++ b/generated/do_editor_ui_for_compound_type_random_series.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:217:0 +// src/engine/editor.cpp:220:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, random_series *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_compound_type_rect3.h b/generated/do_editor_ui_for_compound_type_rect3.h index ee5dbc6fe..a4b472ba4 100644 --- a/generated/do_editor_ui_for_compound_type_rect3.h +++ b/generated/do_editor_ui_for_compound_type_rect3.h @@ -1,4 +1,4 @@ -// src/engine/editor.h:493:0 +// src/engine/editor.h:497:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, rect3 *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_compound_type_rect3cp.h b/generated/do_editor_ui_for_compound_type_rect3cp.h index a1ce28559..0e370f7f9 100644 --- a/generated/do_editor_ui_for_compound_type_rect3cp.h +++ b/generated/do_editor_ui_for_compound_type_rect3cp.h @@ -1,4 +1,4 @@ -// src/engine/editor.h:499:0 +// src/engine/editor.h:503:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, rect3cp *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_compound_type_rect3i.h b/generated/do_editor_ui_for_compound_type_rect3i.h index 322727314..7b66e0d65 100644 --- a/generated/do_editor_ui_for_compound_type_rect3i.h +++ b/generated/do_editor_ui_for_compound_type_rect3i.h @@ -1,4 +1,4 @@ -// src/engine/editor.h:496:0 +// src/engine/editor.h:500:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, rect3i *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_compound_type_render_buffers_2d.h b/generated/do_editor_ui_for_compound_type_render_buffers_2d.h index 50cfa3b6b..a082ba370 100644 --- a/generated/do_editor_ui_for_compound_type_render_buffers_2d.h +++ b/generated/do_editor_ui_for_compound_type_render_buffers_2d.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:406:0 +// src/engine/editor.cpp:414:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, render_buffers_2d *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_compound_type_render_debug.h b/generated/do_editor_ui_for_compound_type_render_debug.h index 743b85605..af357abe9 100644 --- a/generated/do_editor_ui_for_compound_type_render_debug.h +++ b/generated/do_editor_ui_for_compound_type_render_debug.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:424:0 +// src/engine/editor.cpp:432:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, render_debug *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_compound_type_render_settings.h b/generated/do_editor_ui_for_compound_type_render_settings.h index 78f7e5ebe..7293c5bb9 100644 --- a/generated/do_editor_ui_for_compound_type_render_settings.h +++ b/generated/do_editor_ui_for_compound_type_render_settings.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:211:0 +// src/engine/editor.cpp:214:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, render_settings *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_compound_type_renderer_2d.h b/generated/do_editor_ui_for_compound_type_renderer_2d.h index 33d5800c2..0b2a3d442 100644 --- a/generated/do_editor_ui_for_compound_type_renderer_2d.h +++ b/generated/do_editor_ui_for_compound_type_renderer_2d.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:409:0 +// src/engine/editor.cpp:417:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, renderer_2d *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) @@ -281,6 +281,21 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, renderer_2d *Element, cs Name + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(memory_arena*,&Element->WindowTableArena), + CSz("WindowTableArena"), + Params + ); + + + + + + + + if (ToggleButton(Ui, CSz("v DebugColors[128]"), CSz("> DebugColors[128]"), UiId(Window, "toggle renderer_2d v3 DebugColors", Element->DebugColors), Params )) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); diff --git a/generated/do_editor_ui_for_compound_type_shader.h b/generated/do_editor_ui_for_compound_type_shader.h index 18b180d86..3ab36a473 100644 --- a/generated/do_editor_ui_for_compound_type_shader.h +++ b/generated/do_editor_ui_for_compound_type_shader.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:403:0 +// src/engine/editor.cpp:411:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, shader *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_compound_type_shape_layer.h b/generated/do_editor_ui_for_compound_type_shape_layer.h index 2b911658b..144c77e10 100644 --- a/generated/do_editor_ui_for_compound_type_shape_layer.h +++ b/generated/do_editor_ui_for_compound_type_shape_layer.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:122:0 +// src/engine/editor.cpp:125:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, shape_layer *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_compound_type_texture.h b/generated/do_editor_ui_for_compound_type_texture.h index 615ae3fe0..f3bb0117b 100644 --- a/generated/do_editor_ui_for_compound_type_texture.h +++ b/generated/do_editor_ui_for_compound_type_texture.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:343:0 +// src/engine/editor.cpp:351:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, texture *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_compound_type_ui_debug.h b/generated/do_editor_ui_for_compound_type_ui_debug.h index 1975a270c..2f1eb0ac9 100644 --- a/generated/do_editor_ui_for_compound_type_ui_debug.h +++ b/generated/do_editor_ui_for_compound_type_ui_debug.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:427:0 +// src/engine/editor.cpp:435:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, ui_debug *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_compound_type_ui_id.h b/generated/do_editor_ui_for_compound_type_ui_id.h index a43bcf626..3f1646213 100644 --- a/generated/do_editor_ui_for_compound_type_ui_id.h +++ b/generated/do_editor_ui_for_compound_type_ui_id.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:131:0 +// src/engine/editor.cpp:134:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, ui_id *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_compound_type_ui_toggle.h b/generated/do_editor_ui_for_compound_type_ui_toggle.h index 6e855e05c..4c6a73d22 100644 --- a/generated/do_editor_ui_for_compound_type_ui_toggle.h +++ b/generated/do_editor_ui_for_compound_type_ui_toggle.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:134:0 +// src/engine/editor.cpp:137:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, ui_toggle *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_compound_type_untextured_3d_geometry_buffer.h b/generated/do_editor_ui_for_compound_type_untextured_3d_geometry_buffer.h index 719b409f5..fb9f429bc 100644 --- a/generated/do_editor_ui_for_compound_type_untextured_3d_geometry_buffer.h +++ b/generated/do_editor_ui_for_compound_type_untextured_3d_geometry_buffer.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:241:0 +// src/engine/editor.cpp:244:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, untextured_3d_geometry_buffer *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) @@ -26,8 +26,55 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, untextured_3d_geometry_buffer { PushTableStart(Ui); if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(data_type*,&Element->Type), + CSz("Type"), + Params + ); + + + + + + + + + PushNewRow(Ui); + + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(void *, Element->Verts), + CSz("Verts"), + Params + ); + + + + + + + + PushNewRow(Ui); + + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(void *, Element->Normals), + CSz("Normals"), + Params + ); + + + + + + + PushNewRow(Ui); DoEditorUi(Ui, diff --git a/generated/do_editor_ui_for_compound_type_vertex_material.h b/generated/do_editor_ui_for_compound_type_vertex_material.h index 6c2f88043..c4bfd610f 100644 --- a/generated/do_editor_ui_for_compound_type_vertex_material.h +++ b/generated/do_editor_ui_for_compound_type_vertex_material.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:235:0 +// src/engine/editor.cpp:238:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, vertex_material *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_compound_type_voronoi_noise_params.h b/generated/do_editor_ui_for_compound_type_voronoi_noise_params.h index 1fca509eb..f507086af 100644 --- a/generated/do_editor_ui_for_compound_type_voronoi_noise_params.h +++ b/generated/do_editor_ui_for_compound_type_voronoi_noise_params.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:113:0 +// src/engine/editor.cpp:116:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, voronoi_noise_params *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_compound_type_vox_data.h b/generated/do_editor_ui_for_compound_type_vox_data.h index 9d3a5cab8..879d37ccb 100644 --- a/generated/do_editor_ui_for_compound_type_vox_data.h +++ b/generated/do_editor_ui_for_compound_type_vox_data.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:271:0 +// src/engine/editor.cpp:274:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, vox_data *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_compound_type_voxel.h b/generated/do_editor_ui_for_compound_type_voxel.h index 18a4eb6e6..53da76de6 100644 --- a/generated/do_editor_ui_for_compound_type_voxel.h +++ b/generated/do_editor_ui_for_compound_type_voxel.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:262:0 +// src/engine/editor.cpp:265:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, voxel *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_compound_type_voxel_lighting.h b/generated/do_editor_ui_for_compound_type_voxel_lighting.h index 750f2d709..9fc78661e 100644 --- a/generated/do_editor_ui_for_compound_type_voxel_lighting.h +++ b/generated/do_editor_ui_for_compound_type_voxel_lighting.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:265:0 +// src/engine/editor.cpp:268:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, voxel_lighting *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_compound_type_work_queue.h b/generated/do_editor_ui_for_compound_type_work_queue.h index 44d21ec31..364d86d3a 100644 --- a/generated/do_editor_ui_for_compound_type_work_queue.h +++ b/generated/do_editor_ui_for_compound_type_work_queue.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:152:0 +// src/engine/editor.cpp:155:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, work_queue *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_compound_type_work_queue_entry.h b/generated/do_editor_ui_for_compound_type_work_queue_entry.h index 9e8a3dea5..92ce4f47d 100644 --- a/generated/do_editor_ui_for_compound_type_work_queue_entry.h +++ b/generated/do_editor_ui_for_compound_type_work_queue_entry.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:149:0 +// src/engine/editor.cpp:152:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, work_queue_entry *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_compound_type_world.h b/generated/do_editor_ui_for_compound_type_world.h index ca7ba8f3f..281e5677b 100644 --- a/generated/do_editor_ui_for_compound_type_world.h +++ b/generated/do_editor_ui_for_compound_type_world.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:205:0 +// src/engine/editor.cpp:208:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, world *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_compound_type_world_chunk.h b/generated/do_editor_ui_for_compound_type_world_chunk.h index 66f4bed5e..cbbdaa78f 100644 --- a/generated/do_editor_ui_for_compound_type_world_chunk.h +++ b/generated/do_editor_ui_for_compound_type_world_chunk.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:330:0 +// src/engine/editor.cpp:317:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, world_chunk *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) @@ -89,7 +89,7 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, world_chunk *Element, cs Name DoEditorUi(Ui, Window, // Cast to remove const/volatile keywords if they're there - Cast(world_chunk_lod_element_buffer*,&Element->Meshes), + Cast(lod_element_buffer*,&Element->Meshes), CSz("Meshes"), Params ); diff --git a/generated/do_editor_ui_for_compound_type_world_edit_brush.h b/generated/do_editor_ui_for_compound_type_world_edit_brush.h index 01f06aec1..71d2a9f81 100644 --- a/generated/do_editor_ui_for_compound_type_world_edit_brush.h +++ b/generated/do_editor_ui_for_compound_type_world_edit_brush.h @@ -1,4 +1,4 @@ -// src/engine/editor.h:781:0 +// src/engine/editor.h:785:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, world_edit_brush *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_compound_type_world_edit_params.h b/generated/do_editor_ui_for_compound_type_world_edit_params.h index 797750971..f013bc99e 100644 --- a/generated/do_editor_ui_for_compound_type_world_edit_params.h +++ b/generated/do_editor_ui_for_compound_type_world_edit_params.h @@ -1,4 +1,4 @@ -// src/engine/editor.h:696:0 +// src/engine/editor.h:700:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, world_edit_params *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_compound_type_world_update_op_shape_params_rect.h b/generated/do_editor_ui_for_compound_type_world_update_op_shape_params_rect.h index bc0df4a50..1f8fce601 100644 --- a/generated/do_editor_ui_for_compound_type_world_update_op_shape_params_rect.h +++ b/generated/do_editor_ui_for_compound_type_world_update_op_shape_params_rect.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:118:0 +// src/engine/editor.cpp:121:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, world_update_op_shape_params_rect *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_compound_type_world_update_op_shape_params_sphere.h b/generated/do_editor_ui_for_compound_type_world_update_op_shape_params_sphere.h index c72b3a2d8..47ea1067b 100644 --- a/generated/do_editor_ui_for_compound_type_world_update_op_shape_params_sphere.h +++ b/generated/do_editor_ui_for_compound_type_world_update_op_shape_params_sphere.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:116:0 +// src/engine/editor.cpp:119:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, world_update_op_shape_params_sphere *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) diff --git a/generated/do_editor_ui_for_container_entity_ptr_block_array.h b/generated/do_editor_ui_for_container_entity_ptr_block_array.h index 28c58f6bf..5fb77d46a 100644 --- a/generated/do_editor_ui_for_container_entity_ptr_block_array.h +++ b/generated/do_editor_ui_for_container_entity_ptr_block_array.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:327:0 +// src/engine/editor.cpp:314:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, entity_ptr_block_array *Container, cs Name, EDITOR_UI_FUNCTION_PROTO_DEFAULTS) diff --git a/generated/do_editor_ui_for_container_model_buffer.h b/generated/do_editor_ui_for_container_model_buffer.h index b38d3c7ce..fb9b51c99 100644 --- a/generated/do_editor_ui_for_container_model_buffer.h +++ b/generated/do_editor_ui_for_container_model_buffer.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:286:0 +// src/engine/editor.cpp:289:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, model_buffer *Container, cs Name, EDITOR_UI_FUNCTION_PROTO_DEFAULTS) diff --git a/generated/do_editor_ui_for_container_ui_toggle_hashtable.h b/generated/do_editor_ui_for_container_ui_toggle_hashtable.h index 3de37f277..b10b1b590 100644 --- a/generated/do_editor_ui_for_container_ui_toggle_hashtable.h +++ b/generated/do_editor_ui_for_container_ui_toggle_hashtable.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:143:0 +// src/engine/editor.cpp:146:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, ui_toggle_hashtable *Container, cs Name, EDITOR_UI_FUNCTION_PROTO_DEFAULTS) diff --git a/generated/do_editor_ui_for_container_v3_cursor.h b/generated/do_editor_ui_for_container_v3_cursor.h index 35dbd21c0..684eb74d4 100644 --- a/generated/do_editor_ui_for_container_v3_cursor.h +++ b/generated/do_editor_ui_for_container_v3_cursor.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:128:0 +// src/engine/editor.cpp:131:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, v3_cursor *Container, cs Name, EDITOR_UI_FUNCTION_PROTO_DEFAULTS) diff --git a/generated/do_editor_ui_for_enum_asset_type.h b/generated/do_editor_ui_for_enum_asset_type.h new file mode 100644 index 000000000..7f56343d5 --- /dev/null +++ b/generated/do_editor_ui_for_enum_asset_type.h @@ -0,0 +1,46 @@ +// src/engine/editor.cpp:329:0 + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, asset_type *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic) +{ + if (Name.Count) { PushColumn(Ui, CS(Name), &DefaultUiRenderParams_Column); } + + cs ElementName = ToStringPrefixless(*Element); + ui_id ToggleButtonId = UiId(Window, "enum value.type value.name", Element); + if (ToggleButton(Ui, ElementName, ElementName, ToggleButtonId, Params)) + { + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("Undefined"), UiId(Window, "enum AssetType_Undefined", Element), Params)) + { + *Element = AssetType_Undefined; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("Models"), UiId(Window, "enum AssetType_Models", Element), Params)) + { + *Element = AssetType_Models; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("WorldChunk"), UiId(Window, "enum AssetType_WorldChunk", Element), Params)) + { + *Element = AssetType_WorldChunk; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + } + else + { + PushNewRow(Ui); + } +} + diff --git a/generated/do_editor_ui_for_enum_chunk_flag.h b/generated/do_editor_ui_for_enum_chunk_flag.h index 0d6997e88..7c6e72a78 100644 --- a/generated/do_editor_ui_for_enum_chunk_flag.h +++ b/generated/do_editor_ui_for_enum_chunk_flag.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:259:0 +// src/engine/editor.cpp:262:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, chunk_flag *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic) diff --git a/generated/do_editor_ui_for_enum_data_type.h b/generated/do_editor_ui_for_enum_data_type.h new file mode 100644 index 000000000..872b8ff18 --- /dev/null +++ b/generated/do_editor_ui_for_enum_data_type.h @@ -0,0 +1,46 @@ +// src/engine/editor.h:494:0 + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, data_type *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic) +{ + if (Name.Count) { PushColumn(Ui, CS(Name), &DefaultUiRenderParams_Column); } + + cs ElementName = ToStringPrefixless(*Element); + ui_id ToggleButtonId = UiId(Window, "enum value.type value.name", Element); + if (ToggleButton(Ui, ElementName, ElementName, ToggleButtonId, Params)) + { + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("Undefinded"), UiId(Window, "enum DataType_Undefinded", Element), Params)) + { + *Element = DataType_Undefinded; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("v3"), UiId(Window, "enum DataType_v3", Element), Params)) + { + *Element = DataType_v3; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("u8"), UiId(Window, "enum DataType_v3_u8", Element), Params)) + { + *Element = DataType_v3_u8; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + } + else + { + PushNewRow(Ui); + } +} + diff --git a/generated/do_editor_ui_for_enum_engine_debug_view_mode.h b/generated/do_editor_ui_for_enum_engine_debug_view_mode.h index cfffa6722..5b522f3f0 100644 --- a/generated/do_editor_ui_for_enum_engine_debug_view_mode.h +++ b/generated/do_editor_ui_for_enum_engine_debug_view_mode.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:433:0 +// src/engine/editor.cpp:441:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, engine_debug_view_mode *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic) diff --git a/generated/do_editor_ui_for_enum_entity_behavior_flags.h b/generated/do_editor_ui_for_enum_entity_behavior_flags.h index ecf5d1d02..ff2e15c65 100644 --- a/generated/do_editor_ui_for_enum_entity_behavior_flags.h +++ b/generated/do_editor_ui_for_enum_entity_behavior_flags.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:197:0 +// src/engine/editor.cpp:200:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, entity_behavior_flags *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic) diff --git a/generated/do_editor_ui_for_enum_entity_state.h b/generated/do_editor_ui_for_enum_entity_state.h index 7b95e3694..b74d2170a 100644 --- a/generated/do_editor_ui_for_enum_entity_state.h +++ b/generated/do_editor_ui_for_enum_entity_state.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:194:0 +// src/engine/editor.cpp:197:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, entity_state *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic) diff --git a/generated/do_editor_ui_for_enum_file_traversal_type.h b/generated/do_editor_ui_for_enum_file_traversal_type.h index 6ab4d0f63..884f70e84 100644 --- a/generated/do_editor_ui_for_enum_file_traversal_type.h +++ b/generated/do_editor_ui_for_enum_file_traversal_type.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:289:0 +// src/engine/editor.cpp:292:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, file_traversal_type *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic) diff --git a/generated/do_editor_ui_for_enum_particle_spawn_type.h b/generated/do_editor_ui_for_enum_particle_spawn_type.h index 06681d8bb..cad2e517b 100644 --- a/generated/do_editor_ui_for_enum_particle_spawn_type.h +++ b/generated/do_editor_ui_for_enum_particle_spawn_type.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:220:0 +// src/engine/editor.cpp:223:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, particle_spawn_type *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic) diff --git a/generated/do_editor_ui_for_enum_resolution_setting.h b/generated/do_editor_ui_for_enum_resolution_setting.h index 077fe76f6..585324b80 100644 --- a/generated/do_editor_ui_for_enum_resolution_setting.h +++ b/generated/do_editor_ui_for_enum_resolution_setting.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:439:0 +// src/engine/editor.cpp:447:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, resolution_setting *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic) diff --git a/generated/do_editor_ui_for_enum_shader_language_setting.h b/generated/do_editor_ui_for_enum_shader_language_setting.h index 2a084f8a8..9fdcf000e 100644 --- a/generated/do_editor_ui_for_enum_shader_language_setting.h +++ b/generated/do_editor_ui_for_enum_shader_language_setting.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:442:0 +// src/engine/editor.cpp:450:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, shader_language_setting *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic) diff --git a/generated/do_editor_ui_for_enum_shape_type.h b/generated/do_editor_ui_for_enum_shape_type.h index 875018b42..f5621bc38 100644 --- a/generated/do_editor_ui_for_enum_shape_type.h +++ b/generated/do_editor_ui_for_enum_shape_type.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:120:0 +// src/engine/editor.cpp:123:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, shape_type *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic) diff --git a/generated/do_editor_ui_for_enum_tone_mapping_type.h b/generated/do_editor_ui_for_enum_tone_mapping_type.h index d15715a70..8d3c7ab35 100644 --- a/generated/do_editor_ui_for_enum_tone_mapping_type.h +++ b/generated/do_editor_ui_for_enum_tone_mapping_type.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:200:0 +// src/engine/editor.cpp:203:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, tone_mapping_type *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic) diff --git a/generated/do_editor_ui_for_enum_ui_noise_type.h b/generated/do_editor_ui_for_enum_ui_noise_type.h index 8fd8cc26c..aceaf5ab8 100644 --- a/generated/do_editor_ui_for_enum_ui_noise_type.h +++ b/generated/do_editor_ui_for_enum_ui_noise_type.h @@ -1,4 +1,4 @@ -// src/engine/editor.h:531:0 +// src/engine/editor.h:535:0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, ui_noise_type *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic) diff --git a/generated/do_editor_ui_for_radio_enum_asset_window_view_mode.h b/generated/do_editor_ui_for_radio_enum_asset_window_view_mode.h index 0a392a9cd..c8ec89173 100644 --- a/generated/do_editor_ui_for_radio_enum_asset_window_view_mode.h +++ b/generated/do_editor_ui_for_radio_enum_asset_window_view_mode.h @@ -1,4 +1,4 @@ -// src/engine/editor.h:679:0 +// src/engine/editor.h:683:0 link_internal void RadioSelect(ui_toggle_button_group *RadioGroup, asset_window_view_mode Selection) diff --git a/generated/do_editor_ui_for_radio_enum_brush_layer_type.h b/generated/do_editor_ui_for_radio_enum_brush_layer_type.h index cd49aada1..174a1e644 100644 --- a/generated/do_editor_ui_for_radio_enum_brush_layer_type.h +++ b/generated/do_editor_ui_for_radio_enum_brush_layer_type.h @@ -1,4 +1,4 @@ -// src/engine/editor.h:858:0 +// src/engine/editor.h:862:0 link_internal void RadioSelect(ui_toggle_button_group *RadioGroup, brush_layer_type Selection) diff --git a/generated/do_editor_ui_for_radio_enum_world_edit_brush_type.h b/generated/do_editor_ui_for_radio_enum_world_edit_brush_type.h index 303af972c..86a2395d6 100644 --- a/generated/do_editor_ui_for_radio_enum_world_edit_brush_type.h +++ b/generated/do_editor_ui_for_radio_enum_world_edit_brush_type.h @@ -1,4 +1,4 @@ -// src/engine/editor.h:693:0 +// src/engine/editor.h:697:0 link_internal void RadioSelect(ui_toggle_button_group *RadioGroup, world_edit_brush_type Selection) diff --git a/generated/do_editor_ui_for_radio_enum_world_edit_mode.h b/generated/do_editor_ui_for_radio_enum_world_edit_mode.h index e05b689da..fbee1fd67 100644 --- a/generated/do_editor_ui_for_radio_enum_world_edit_mode.h +++ b/generated/do_editor_ui_for_radio_enum_world_edit_mode.h @@ -1,4 +1,4 @@ -// src/engine/editor.h:687:0 +// src/engine/editor.h:691:0 link_internal void RadioSelect(ui_toggle_button_group *RadioGroup, world_edit_mode Selection) diff --git a/generated/do_editor_ui_for_radio_enum_world_edit_mode_modifier.h b/generated/do_editor_ui_for_radio_enum_world_edit_mode_modifier.h index b76524ccb..4022f3c97 100644 --- a/generated/do_editor_ui_for_radio_enum_world_edit_mode_modifier.h +++ b/generated/do_editor_ui_for_radio_enum_world_edit_mode_modifier.h @@ -1,4 +1,4 @@ -// src/engine/editor.h:666:0 +// src/engine/editor.h:670:0 link_internal void RadioSelect(ui_toggle_button_group *RadioGroup, world_edit_mode_modifier Selection) diff --git a/generated/do_editor_ui_for_radio_enum_world_edit_tool.h b/generated/do_editor_ui_for_radio_enum_world_edit_tool.h index cb7b67a47..7583cf80e 100644 --- a/generated/do_editor_ui_for_radio_enum_world_edit_tool.h +++ b/generated/do_editor_ui_for_radio_enum_world_edit_tool.h @@ -1,4 +1,4 @@ -// src/engine/editor.h:690:0 +// src/engine/editor.h:694:0 link_internal void RadioSelect(ui_toggle_button_group *RadioGroup, world_edit_tool Selection) diff --git a/generated/flood_fill_iteration_pattern_199741702_161749140_632272777.h b/generated/flood_fill_iteration_pattern_199741702_161749140_632272777.h index 2ac3de581..8b76e49d2 100644 --- a/generated/flood_fill_iteration_pattern_199741702_161749140_632272777.h +++ b/generated/flood_fill_iteration_pattern_199741702_161749140_632272777.h @@ -1,4 +1,4 @@ -// src/engine/world_chunk.cpp:4474:0 +// src/engine/world_update.cpp:619:0 random_series ColorEntropy = {4654376543246}; diff --git a/generated/flood_fill_iteration_pattern_275071431_101859599_0.h b/generated/flood_fill_iteration_pattern_275071431_101859599_0.h index 4b3631d7a..821fa6614 100644 --- a/generated/flood_fill_iteration_pattern_275071431_101859599_0.h +++ b/generated/flood_fill_iteration_pattern_275071431_101859599_0.h @@ -1,4 +1,4 @@ -// src/engine/world_chunk.cpp:4714:0 +// src/engine/world_update.cpp:859:0 random_series ColorEntropy = {4654376543246}; diff --git a/generated/flood_fill_iteration_pattern_275071431_785723886_0.h b/generated/flood_fill_iteration_pattern_275071431_785723886_0.h index 155dd597b..8bffb7436 100644 --- a/generated/flood_fill_iteration_pattern_275071431_785723886_0.h +++ b/generated/flood_fill_iteration_pattern_275071431_785723886_0.h @@ -1,4 +1,4 @@ -// src/engine/world_chunk.cpp:4698:0 +// src/engine/world_update.cpp:843:0 random_series ColorEntropy = {4654376543246}; diff --git a/generated/flood_fill_iteration_pattern_846291950_267608728_0.h b/generated/flood_fill_iteration_pattern_846291950_267608728_0.h index 8bdd6881b..a852aeb4c 100644 --- a/generated/flood_fill_iteration_pattern_846291950_267608728_0.h +++ b/generated/flood_fill_iteration_pattern_846291950_267608728_0.h @@ -1,4 +1,4 @@ -// src/engine/world_chunk.cpp:4578:0 +// src/engine/world_update.cpp:723:0 random_series ColorEntropy = {4654376543246}; diff --git a/generated/for_datatypes_0XxWqGSZ.h b/generated/for_datatypes_0XxWqGSZ.h index b42791eaa..703f07fe4 100644 --- a/generated/for_datatypes_0XxWqGSZ.h +++ b/generated/for_datatypes_0XxWqGSZ.h @@ -1,4 +1,10 @@ -// src/engine/work_queue.h:341:0 +// src/engine/work_queue.h:335:0 + + + + + + @@ -605,16 +611,27 @@ WorkQueueEntryAsyncFunction( render_to_texture_async_params *Params ) -struct render_to_texture_world_chunk_async_params; -link_internal work_queue_entry -WorkQueueEntryAsyncFunction( render_to_texture_world_chunk_async_params *Params ) -{ - work_queue_entry Result = {}; - Result.Type = type_work_queue_entry_async_function_call; - Result.work_queue_entry_async_function_call.Type = type_render_to_texture_world_chunk_async_params; - Result.work_queue_entry_async_function_call.render_to_texture_world_chunk_async_params = *Params; - return Result; -} + + + + + + + + + + + + + + + + + + + + + diff --git a/generated/for_datatypes_BBrLpuGA.h b/generated/for_datatypes_BBrLpuGA.h deleted file mode 100644 index 1972a3356..000000000 --- a/generated/for_datatypes_BBrLpuGA.h +++ /dev/null @@ -1,1941 +0,0 @@ -// src/engine/render.cpp:1216:0 - -u32_block_array - - -u32_block_array - - -u32_cursor - - -u8_cursor_block_array - - -u8_cursor_block_array - - -lighting_render_group - - -game_mode - - -render_debug - - -tagged_counted_string_stream - - -world_chunk_file_header_v3 - - -u8_cursor - - -ui_toggle - - -c_token_cursor_up - - -u8_cursor - - -bonsai_futex - - -engine_settings - - -rect3i_buffer - - -entropy_lists - - -rect3i_buffer - - -entropy_lists - - -bonsai_render_command_deallocate_buffers - - -parser_stream - - -parser_stream - - -world_chunk_file_header_v1 - - -texture - - -asset_thumbnail - - -ui_render_command_text - - -level_header - - -asset_thumbnail_block - - -asset_thumbnail_block - - -brush_settings_1 - - -native_file - - -debug_timed_function - - -bonsai_render_command_do_stuff - - -ui_render_command_buffer - - -maybe_file_traversal_node - - -maybe_file_traversal_node - - -vertex_material - - -white_noise_params - - -texture_block_array - - -texture_block_array - - -heap_allocator - - -xml_tag - - -v3i_iterator - - -v3i_iterator - - -world_update_op_shape_params_rect - - -platform - - -parser_stream_chunk - - -parser_stream_chunk - - -hotkeys - - -shadow_render_group - - -tile_rule_id - - -ui_render_command_column_start - - -maybe_standing_spot - - -entity_position_info - - -maybe_standing_spot - - -parser_linked_list_node - - -particle_system - - -parser_linked_list_node - - -engine_api - - -bonsai_render_command_gl_timer_read_value_and_histogram - - -sort_key - - -u8_cursor_block_array - - -u8_cursor_block_array - - -context_switch_event - - -voronoi_noise_params - - -ui_toggle_button_handle - - -bitmap_buffer - - -bitmap_buffer - - -work_queue_entry__bonsai_render_command - - -work_queue_entry__bonsai_render_command - - -interactable - - -u32_block - - -u32_block - - -c_token_buffer_stream - - -c_token_buffer_stream - - -texture_block_array - - -texture_block_array - - -ao_render_group - - -light - - -bonsai_render_command_gl_timer_init - - -linei - - -bitmap - - -voxel_synth_tile_linked_list_node - - -voxel_synth_tile_linked_list_node - - -u64_cursor - - -octave_buffer - - -u64_cursor - - -event_queue - - -unique_debug_profile_scope - - -maybe_ui_toggle - - -maybe_ui_toggle - - -u64_stream - - -u64_stream - - -brush_settings_0 - - -bonsai_type_info_hashtable_iterator - - -bonsai_type_info_hashtable_iterator - - -interactable_handle - - -heap_allocation_block - - -ui_id - - -u32_block_array - - -u32_block_array - - -find_command_result - - -noise_layer_0 - - -xml_parsing_at_indicators - - -ui_render_command_abs_border - - -memory_arena_stats - - -collision_event - - -bonsai_render_command_clear_all_framebuffers - - -camera - - -model_buffer - - -model_buffer - - -picked_world_chunk - - -picked_voxel - - -debug_state - - -renderer_2d - - -ray - - -parser_hashtable_iterator - - -parser_hashtable_iterator - - -ui_style - - -u64_stream_chunk - - -parser_hashtable - - -u64_stream_chunk - - -parser_hashtable - - -frustum - - -u64_buffer - - -u64_buffer - - -layout - - -ui_render_command_button_end - - -plane - - -counted_string_cursor - - -counted_string_cursor - - -entity_ptr_block_array - - -world_chunk - - -entity_ptr_block_array - - -texture - - -entity_block_array - - -world_chunk_ptr_block - - -world_chunk_ptr_block - - -parser - - -tagged_counted_string_stream_iterator - - -tagged_counted_string_stream_iterator - - -counted_string_stream_chunk - - -counted_string_stream_chunk - - -rect3 - - -world_update_op_shape_params_sphere - - -file_traversal_node - - -bonsai_render_command_gl_timer_start - - -fooooooo - - -graphics_settings - - -maybe_asset_ptr - - -maybe_asset_ptr - - -world_chunk_ptr_buffer - - -world_chunk_ptr_buffer - - -ui_render_command_table_end - - -graphics - - -table_info - - -perlin_noise_params - - -layered_brush_editor - - -font - - -tile_ruleset_buffer - - -tile_ruleset_buffer - - -ui_render_command - - -ui_render_command - - -asset_id - - -world_chunk_file_header_v3 - - -mutex - - -xml_tag_linked_list_node - - -xml_tag_linked_list_node - - -vertex_material - - -gpu_mapped_world_chunk_geometry_buffer - - -memory_record - - -noise_value_to_material_index - - -member_info_block - - -member_info_block - - -world_chunk_geometry_buffer - - -physics - - -asset - - -voxel_stack_element_block_array - - -voxel_stack_element_block_array - - -layered_brush_editor_0 - - -entity_ptr_block - - -entity_ptr_block - - -c_token_buffer_buffer - - -c_token_buffer_buffer - - -bonsai_render_command_gl_timer_end - - -debug_profile_scope_cursor - - -debug_profile_scope_cursor - - -s32_cursor - - -s32_cursor - - -counted_string_buffer - - -u32_cursor - - -counted_string_buffer - - -u32_cursor - - -asset_thumbnail_block_array_index - - -asset_thumbnail_block_array_index - - -temp_memory_handle - - -text_box_edit_state - - -r32_stream - - -s32_stream - - -s32_stream - - -u32_stream - - -u32_stream - - -lighting_settings_0 - - -bonsai_render_command_allocate_buffers - - -gpu_mapped_element_buffer - - -voxel_stack_element_block_array_index - - -voxel_stack_element_block_array_index - - -voxel - - -world_chunk_ptr_block_array - - -world_chunk_ptr_block_array - - -ui_render_command_text_at - - -freelist_entry - - -char_cursor - - -terminal_colors - - -bonsai_render_command_setup_shader - - -canonical_position - - -mutex_op_record - - -untextured_3d_geometry_buffer - - -debug_profile_scope - - -maybe_entity_ptr - - -maybe_entity_ptr - - -string_builder - - -standing_spot_iterator - - -standing_spot_iterator - - -maybe_ui_toggle_ptr - - -maybe_ui_toggle_ptr - - -bonsai_render_command_teardown_shader - - -tile_ruleset - - -layered_brush_editor_1 - - -vox_data_block_array - - -vox_data_block_array - - -texture_block_array_index - - -texture_block_array_index - - -work_queue_entry_init_asset - - -ui_render_command_window_start - - -bitmap_header - - -c_token_cursor - - -particle - - -s32_stream_chunk - - -s32_stream_chunk - - -peek_result - - -u32_stream_chunk - - -u32_stream_chunk - - -texture_ptr_block - - -texture_ptr_block - - -u32_buffer - - -u32_buffer - - -bonsai_render_command_draw_all_entities - - -ui_toggle_button_handle_buffer - - -ui_toggle_button_handle_buffer - - -render_state - - -tuple_cs_cs_buffer_builder - - -voxel_synth_tile_buffer - - -tuple_cs_cs_buffer_builder - - -voxel_synth_tile_buffer - - -u8_cursor_block_array_index - - -u8_cursor_block_array_index - - -debug_draw_call - - -counted_string_linked_list_node - - -counted_string_linked_list_node - - -input_event - - -voxel_stack_element_block - - -voxel_stack_element_block - - -frame_stats - - -string_from_parser - - -mutex_op_array - - -entity_list - - -work_queue_entry_sim_particle_system - - -counted_string - - -voxel_synthesis_gen_info - - -os - - -standing_spot_block - - -standing_spot_block - - -u32_block_array_index - - -asset - - -u32_block_array_index - - -standing_spot_block_array - - -standing_spot_block_array - - -sort_key_f - - -u64_iterator - - -u64_iterator - - -renderer_2d - - -ui_render_command_untextured_quad - - -debug_context_switch_event - - -parser_cursor - - -parser_cursor - - -ui_toggle_linked_list_node - - -ui_toggle_linked_list_node - - -u8_cursor_block - - -selected_arenas - - -u8_cursor_block - - -level_header_0 - - -bloom_upsample_shader - - -voxel_synth_tile - - -bonsai_type_info_linked_list_node - - -bonsai_type_info_linked_list_node - - -frame_event - - -rect2 - - -member_info_block_array - - -member_info_block_array - - -work_queue_entry_copy_buffer_set - - -v3i_buffer - - -textured_2d_geometry_buffer - - -level_header_1 - - -render_settings - - -point_buffer - - -window_layout - - -asset_buffer - - -asset_buffer - - -plane_computation - - -untextured_2d_geometry_buffer - - -apply_world_edit_params - - -macro_expansion - - -level_header_2 - - -m4 - - -ui_render_command_force_advance - - -bonsai_render_command_reallocate_buffers - - -shader_uniform - - -xml_token_stream - - -xml_tag_stream - - -chunk_data - - -maybe_v3 - - -thread_local_state - - -world_chunk_ptr_block_array_index - - -world_chunk_ptr_block_array_index - - -ui_element_reference - - -level_editor - - -entity_block_array_index - - -vox_data_block - - -vox_data_block - - -entity_block_array - - -maybe_model - - -world_chunk_file_header_v2 - - -model_block_array - - -model_block_array - - -standing_spot_block_array_index - - -standing_spot_block_array_index - - -tuple_cs_cs_iterator - - -world_chunk - - -tile_rule - - -tuple_cs_cs_iterator - - -brush_settings - - -clip_result - - -texture_cursor - - -texture_cursor - - -ui_toggle_button_group - - -ui_toggle_hashtable - - -ui_toggle_hashtable - - -world_edit_brush - - -game_lights - - -debug_thread_state - - -ui_render_command_table_start - - -untextured_3d_geometry_buffer - - -v3i_stream - - -gpu_mapped_element_buffer - - -rect3cp - - -bonsai_type_info - - -voxel_synth_tile_hashtable - - -voxel_synth_tile_hashtable - - -entity_id - - -bonsai_render_command_draw_world_chunk_draw_list - - -standing_spot - - -maybe_model_buffer - - -asset_thumbnail_block_array - - -maybe_model_buffer - - -asset_thumbnail_block_array - - -texture_ptr_block_array - - -texture_ptr_block_array - - -ui_render_command_column_end - - -entity - - -entity - - -ui_render_command_untextured_quad_at - - -member_info_block_array - - -member_info_block_array - - -entity_block - - -xml_token - - -vox_data_block_array - - -vox_data_block_array - - -memory_arena - - -sort_key_string - - -counted_string_buffer - - -render_settings_0 - - -file_traversal_node_block_array - - -file_traversal_node_block_array - - -standing_spot_block_array - - -standing_spot_block_array - - -render_buffers_2d - - -rect3i - - -world_update_op_shape_params_chunk_data - - -selected_memory_arena - - -m_nxn - - -input - - -d_list - - -composite_render_group - - -s32_iterator - - -s32_iterator - - -u32_iterator - - -u32_iterator - - -bonsai_stdlib - - -tuple_cs_cs_stream_chunk - - -tuple_cs_cs_stream_chunk - - -v3i_cursor - - -work_queue_entry__align_to_cache_line_helper - - -xml_tag_hashtable - - -xml_tag_hashtable - - -voxel_synthesis_result - - -chunk_thumbnail - - -mesh_metadata - - -bonsai_type_info_hashtable - - -bonsai_type_info_hashtable - - -rect3 - - -application_api - - -debug_context_switch_event_buffer_stream_block - - -member_info_block_array_index - - -member_info_block_array_index - - -c_token_buffer_iterator - - -c_token_buffer_iterator - - -parser_iterator - - -parser_iterator - - -work_queue_entry - - -work_queue_entry - - -keyframe - - -standing_spot_stream - - -standing_spot_stream - - -c_token_buffer - - -c_token_buffer - - -c_token_buffer_stream_chunk - - -c_token_buffer_stream_chunk - - -maybe_bonsai_type_info - - -maybe_bonsai_type_info - - -generic_noise_params - - -counted_string - - -filtered_file_traversal_helper_params - - -shader - - -counted_string_stream - - -thread_main_callback_type_buffer - - -bonsai_render_command_allocate_texture - - -counted_string_stream - - -thread_main_callback_type_buffer - - -tuple_cs_cs_stream - - -tuple_cs_cs_stream - - -registered_memory_arena - - -ui_relative_position_reference - - -debug_scope_tree - - -file_traversal_node_block - - -file_traversal_node_block - - -gaussian_render_group - - -called_function - - -bitmap_block_array - - -bitmap_block_array - - -line - - -world_edit_shape - - -vox_data_block_array_index - - -vox_data_block_array_index - - -maybe_asset_id - - -maybe_asset_id - - -ui_render_command_button_start - - -animation - - -octave - - -counted_string_hashtable_iterator - - -asset_system - - -counted_string_hashtable_iterator - - -shape_layer - - -bonsai_render_command_reallocate_world_chunk_buffers - - -work_queue_entry_init_world_chunk - - -untextured_3d_geometry_buffer - - -bitmap_block_array_index - - -triangle - - -bitmap_block_array_index - - -work_queue - - -bloom_render_group - - -bitmap_block_array - - -bitmap_block_array - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -bonsai_type_info_buffer - - -bonsai_type_info_buffer - - -v3i_cursor - - -v3i_cursor - - -bonsai_render_command_deallocate_texture - - -texture_ptr_block_array_index - - -camera_1 - - -texture_ptr_block_array_index - - -world_chunk_ptr_block_array - - -world_chunk_ptr_block_array - - -v3i_stream - - -v3i_stream - - -standing_spot_buffer - - -standing_spot_buffer - - -ui_toggle - - -world - - -model_block - - -model_block - - -model_block_array - - -model_block_array - - -selection_modification_state - - -entity_1 - - -engine_debug - - -bloom_downsample_shader - - -g_buffer_textures - - -render_entity_to_texture_group - - -work_queue_entry_copy_buffer_ref - - -loaded_collada_mesh - - -picked_world_chunk_static_buffer - - -voxel_synthesis_change_propagation_info - - -texture_block - - -texture_block - - -voxel_synth_tile_hashtable_iterator - - -voxel_synth_tile_hashtable_iterator - - -bitmap_block - - -bitmap_block - - -brush_layer - - -entity_ptr_block_array_index - - -entity_ptr_block_array_index - - -boundary_voxel - - -bonsai_debug_system - - -debug_histogram_function - - -ui_render_command_force_update_basis - - -v3i_stream_chunk - - -v3i_stream_chunk - - -opengl - - -cycle_range - - -v3i_buffer - - -v3i_buffer - - -ui_render_command_rel_border - - -ansi_stream - - -transparency_render_group - - -random_series - - -canonical_position - - -engine_resources - - -entity_ptr_block_array - - -entity_ptr_block_array - - -lod_element_buffer - - -tagged_counted_string_stream_stream - - -tagged_counted_string_stream_stream - - -sphere - - -render_buffers_2d - - -framebuffer - - -debug_context_switch_event_buffer_stream - - -boundary_voxels - - -xml_tag_hashtable_iterator - - -xml_tag_hashtable_iterator - - -world_update_op_shape_params_asset - - -current_triangles - - -counted_string_hashtable - - -counted_string_hashtable - - -member_info - - -ui_render_command_window_end - - -ui_render_params - - -v3_cursor - - -v3_cursor - - -file_traversal_node_buffer - - -file_traversal_node_buffer - - -tuple_cs_cs - - -tuple_cs_cs - - -thread_startup_params - - -voxel_stack_element_block_array - - -voxel_stack_element_block_array - - -tiered_mesh_freelist - - -tiered_mesh_freelist - - -bitmap_image_header - - -model - - -c_token - - -asset_thumbnail_block_array - - -asset_thumbnail_block_array - - -file_traversal_node_block_array - - -file_traversal_node_block_array - - -entity - - -ui_toggle_hashtable_iterator - - -ui_toggle_hashtable_iterator - - -g_buffer_render_group - - -voxel_synthesis_change_propagation_info_stack - - -voxel_synthesis_change_propagation_info_stack - - -voxel_stack_element_cursor - - -voxel_stack_element_cursor - - -camera_0 - - -mesh_freelist - - -counted_string_iterator - - -counted_string_iterator - - -u8_cursor - - -file_traversal_node_block_array_index - - -file_traversal_node_block_array_index - - -debug_context_switch_event_buffer - - -gpu_element_buffer_handles - - -button_interaction_result - - -texture_ptr_block_array - - -texture_ptr_block_array - - -tuple_cs_cs_buffer - - -tuple_cs_cs_buffer - - -window_sort_params - - -entity_0 - - -aabb_intersect_result - - -model_block_array_index - - -model_block_array_index - - -world_chunk_lod_element_buffer - - -find_button_start_result - - -ui_render_command_textured_quad - - -maybe_ray - - -maybe_picked_voxel - - -standing_spot_stream_chunk - - -standing_spot_stream_chunk - - -min_max_avg_dt - - -voxel_stack_element - - -noise_layer - - -voxel_lighting - - -render_to_texture_world_chunk_async_params - - -render_to_texture_world_chunk_async_params - - -entity_entity_collision_event - - -work_queue_entry_rebuild_mesh - - -tagged_counted_string_stream_stream_chunk - - -tagged_counted_string_stream_stream_chunk - - -lighting_settings - - -vox_data - - -edge - - -world_edit_params - - -xml_property - - -work_queue_entry_update_world_region - - -ui_debug - - - diff --git a/generated/for_datatypes_KJiGPAgq.h b/generated/for_datatypes_KJiGPAgq.h deleted file mode 100644 index bd5cb24e8..000000000 --- a/generated/for_datatypes_KJiGPAgq.h +++ /dev/null @@ -1,614 +0,0 @@ -// src/engine/work_queue.h:230:0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -struct render_to_texture_world_chunk_async_params; -link_internal work_queue_entry -WorkQueueEntryAsyncFunction( render_to_texture_world_chunk_async_params *Params ) -{ - work_queue_entry Result = {}; - NotImplemented; - return Result; -} - - - - - - - - - - - - - diff --git a/generated/for_datatypes_MqklaSV8.h b/generated/for_datatypes_MqklaSV8.h deleted file mode 100644 index de73ec5e7..000000000 --- a/generated/for_datatypes_MqklaSV8.h +++ /dev/null @@ -1,1938 +0,0 @@ -// src/engine/render.cpp:1215:0 - -u32_block_array - - -u32_block_array - - -u32_cursor - - -u8_cursor_block_array - - -u8_cursor_block_array - - -lighting_render_group - - -game_mode - - -render_debug - - -tagged_counted_string_stream - - -world_chunk_file_header_v3 - - -u8_cursor - - -ui_toggle - - -c_token_cursor_up - - -u8_cursor - - -bonsai_futex - - -engine_settings - - -rect3i_buffer - - -entropy_lists - - -rect3i_buffer - - -entropy_lists - - -bonsai_render_command_deallocate_buffers - - -parser_stream - - -parser_stream - - -world_chunk_file_header_v1 - - -texture - - -asset_thumbnail - - -ui_render_command_text - - -level_header - - -asset_thumbnail_block - - -asset_thumbnail_block - - -brush_settings_1 - - -native_file - - -debug_timed_function - - -bonsai_render_command_do_stuff - - -ui_render_command_buffer - - -maybe_file_traversal_node - - -maybe_file_traversal_node - - -vertex_material - - -white_noise_params - - -texture_block_array - - -texture_block_array - - -heap_allocator - - -xml_tag - - -v3i_iterator - - -v3i_iterator - - -world_update_op_shape_params_rect - - -platform - - -parser_stream_chunk - - -parser_stream_chunk - - -hotkeys - - -shadow_render_group - - -tile_rule_id - - -ui_render_command_column_start - - -maybe_standing_spot - - -entity_position_info - - -maybe_standing_spot - - -parser_linked_list_node - - -particle_system - - -parser_linked_list_node - - -engine_api - - -bonsai_render_command_gl_timer_read_value_and_histogram - - -sort_key - - -u8_cursor_block_array - - -u8_cursor_block_array - - -context_switch_event - - -voronoi_noise_params - - -ui_toggle_button_handle - - -bitmap_buffer - - -bitmap_buffer - - -work_queue_entry__bonsai_render_command - - -work_queue_entry__bonsai_render_command - - -interactable - - -u32_block - - -u32_block - - -c_token_buffer_stream - - -c_token_buffer_stream - - -texture_block_array - - -texture_block_array - - -ao_render_group - - -light - - -bonsai_render_command_gl_timer_init - - -linei - - -bitmap - - -voxel_synth_tile_linked_list_node - - -voxel_synth_tile_linked_list_node - - -u64_cursor - - -octave_buffer - - -u64_cursor - - -event_queue - - -unique_debug_profile_scope - - -maybe_ui_toggle - - -maybe_ui_toggle - - -u64_stream - - -u64_stream - - -brush_settings_0 - - -bonsai_type_info_hashtable_iterator - - -bonsai_type_info_hashtable_iterator - - -interactable_handle - - -heap_allocation_block - - -ui_id - - -u32_block_array - - -u32_block_array - - -find_command_result - - -noise_layer_0 - - -xml_parsing_at_indicators - - -ui_render_command_abs_border - - -memory_arena_stats - - -collision_event - - -bonsai_render_command_clear_all_framebuffers - - -camera - - -model_buffer - - -model_buffer - - -picked_world_chunk - - -picked_voxel - - -debug_state - - -renderer_2d - - -ray - - -parser_hashtable_iterator - - -parser_hashtable_iterator - - -ui_style - - -u64_stream_chunk - - -parser_hashtable - - -u64_stream_chunk - - -parser_hashtable - - -frustum - - -u64_buffer - - -u64_buffer - - -layout - - -ui_render_command_button_end - - -plane - - -counted_string_cursor - - -counted_string_cursor - - -entity_ptr_block_array - - -world_chunk - - -entity_ptr_block_array - - -texture - - -entity_block_array - - -world_chunk_ptr_block - - -world_chunk_ptr_block - - -parser - - -tagged_counted_string_stream_iterator - - -tagged_counted_string_stream_iterator - - -counted_string_stream_chunk - - -counted_string_stream_chunk - - -rect3 - - -world_update_op_shape_params_sphere - - -file_traversal_node - - -bonsai_render_command_gl_timer_start - - -fooooooo - - -graphics_settings - - -maybe_asset_ptr - - -maybe_asset_ptr - - -world_chunk_ptr_buffer - - -world_chunk_ptr_buffer - - -ui_render_command_table_end - - -graphics - - -table_info - - -perlin_noise_params - - -layered_brush_editor - - -font - - -tile_ruleset_buffer - - -tile_ruleset_buffer - - -ui_render_command - - -ui_render_command - - -asset_id - - -world_chunk_file_header_v3 - - -mutex - - -xml_tag_linked_list_node - - -xml_tag_linked_list_node - - -vertex_material - - -gpu_mapped_world_chunk_geometry_buffer - - -memory_record - - -noise_value_to_material_index - - -member_info_block - - -member_info_block - - -world_chunk_geometry_buffer - - -physics - - -asset - - -voxel_stack_element_block_array - - -voxel_stack_element_block_array - - -layered_brush_editor_0 - - -entity_ptr_block - - -entity_ptr_block - - -c_token_buffer_buffer - - -c_token_buffer_buffer - - -bonsai_render_command_gl_timer_end - - -debug_profile_scope_cursor - - -debug_profile_scope_cursor - - -s32_cursor - - -s32_cursor - - -counted_string_buffer - - -u32_cursor - - -counted_string_buffer - - -u32_cursor - - -asset_thumbnail_block_array_index - - -asset_thumbnail_block_array_index - - -temp_memory_handle - - -text_box_edit_state - - -r32_stream - - -s32_stream - - -s32_stream - - -u32_stream - - -u32_stream - - -lighting_settings_0 - - -bonsai_render_command_allocate_buffers - - -gpu_mapped_element_buffer - - -voxel_stack_element_block_array_index - - -voxel_stack_element_block_array_index - - -voxel - - -world_chunk_ptr_block_array - - -world_chunk_ptr_block_array - - -ui_render_command_text_at - - -freelist_entry - - -char_cursor - - -terminal_colors - - -bonsai_render_command_setup_shader - - -canonical_position - - -mutex_op_record - - -untextured_3d_geometry_buffer - - -debug_profile_scope - - -maybe_entity_ptr - - -maybe_entity_ptr - - -string_builder - - -standing_spot_iterator - - -standing_spot_iterator - - -maybe_ui_toggle_ptr - - -maybe_ui_toggle_ptr - - -bonsai_render_command_teardown_shader - - -tile_ruleset - - -layered_brush_editor_1 - - -vox_data_block_array - - -vox_data_block_array - - -texture_block_array_index - - -texture_block_array_index - - -work_queue_entry_init_asset - - -ui_render_command_window_start - - -bitmap_header - - -c_token_cursor - - -particle - - -s32_stream_chunk - - -s32_stream_chunk - - -peek_result - - -u32_stream_chunk - - -u32_stream_chunk - - -texture_ptr_block - - -texture_ptr_block - - -u32_buffer - - -u32_buffer - - -bonsai_render_command_draw_all_entities - - -ui_toggle_button_handle_buffer - - -ui_toggle_button_handle_buffer - - -render_state - - -tuple_cs_cs_buffer_builder - - -voxel_synth_tile_buffer - - -tuple_cs_cs_buffer_builder - - -voxel_synth_tile_buffer - - -u8_cursor_block_array_index - - -u8_cursor_block_array_index - - -debug_draw_call - - -counted_string_linked_list_node - - -counted_string_linked_list_node - - -input_event - - -voxel_stack_element_block - - -voxel_stack_element_block - - -frame_stats - - -string_from_parser - - -mutex_op_array - - -entity_list - - -work_queue_entry_sim_particle_system - - -counted_string - - -voxel_synthesis_gen_info - - -os - - -standing_spot_block - - -standing_spot_block - - -u32_block_array_index - - -asset - - -u32_block_array_index - - -standing_spot_block_array - - -standing_spot_block_array - - -sort_key_f - - -u64_iterator - - -u64_iterator - - -renderer_2d - - -ui_render_command_untextured_quad - - -debug_context_switch_event - - -parser_cursor - - -parser_cursor - - -ui_toggle_linked_list_node - - -ui_toggle_linked_list_node - - -u8_cursor_block - - -selected_arenas - - -u8_cursor_block - - -level_header_0 - - -bloom_upsample_shader - - -voxel_synth_tile - - -bonsai_type_info_linked_list_node - - -bonsai_type_info_linked_list_node - - -frame_event - - -rect2 - - -member_info_block_array - - -member_info_block_array - - -work_queue_entry_copy_buffer_set - - -v3i_buffer - - -textured_2d_geometry_buffer - - -level_header_1 - - -render_settings - - -point_buffer - - -window_layout - - -asset_buffer - - -asset_buffer - - -plane_computation - - -untextured_2d_geometry_buffer - - -apply_world_edit_params - - -macro_expansion - - -level_header_2 - - -m4 - - -ui_render_command_force_advance - - -bonsai_render_command_reallocate_buffers - - -shader_uniform - - -xml_token_stream - - -xml_tag_stream - - -chunk_data - - -maybe_v3 - - -thread_local_state - - -world_chunk_ptr_block_array_index - - -world_chunk_ptr_block_array_index - - -ui_element_reference - - -level_editor - - -entity_block_array_index - - -vox_data_block - - -vox_data_block - - -entity_block_array - - -maybe_model - - -world_chunk_file_header_v2 - - -model_block_array - - -model_block_array - - -standing_spot_block_array_index - - -standing_spot_block_array_index - - -tuple_cs_cs_iterator - - -world_chunk - - -tile_rule - - -tuple_cs_cs_iterator - - -brush_settings - - -clip_result - - -texture_cursor - - -texture_cursor - - -ui_toggle_button_group - - -ui_toggle_hashtable - - -ui_toggle_hashtable - - -world_edit_brush - - -game_lights - - -debug_thread_state - - -ui_render_command_table_start - - -untextured_3d_geometry_buffer - - -v3i_stream - - -gpu_mapped_element_buffer - - -rect3cp - - -bonsai_type_info - - -voxel_synth_tile_hashtable - - -voxel_synth_tile_hashtable - - -entity_id - - -bonsai_render_command_draw_world_chunk_draw_list - - -standing_spot - - -maybe_model_buffer - - -asset_thumbnail_block_array - - -maybe_model_buffer - - -asset_thumbnail_block_array - - -texture_ptr_block_array - - -texture_ptr_block_array - - -ui_render_command_column_end - - -entity - - -entity - - -ui_render_command_untextured_quad_at - - -member_info_block_array - - -member_info_block_array - - -entity_block - - -xml_token - - -vox_data_block_array - - -vox_data_block_array - - -memory_arena - - -sort_key_string - - -counted_string_buffer - - -render_settings_0 - - -file_traversal_node_block_array - - -file_traversal_node_block_array - - -standing_spot_block_array - - -standing_spot_block_array - - -render_buffers_2d - - -rect3i - - -world_update_op_shape_params_chunk_data - - -selected_memory_arena - - -m_nxn - - -input - - -d_list - - -composite_render_group - - -s32_iterator - - -s32_iterator - - -u32_iterator - - -u32_iterator - - -bonsai_stdlib - - -tuple_cs_cs_stream_chunk - - -tuple_cs_cs_stream_chunk - - -v3i_cursor - - -work_queue_entry__align_to_cache_line_helper - - -xml_tag_hashtable - - -xml_tag_hashtable - - -voxel_synthesis_result - - -chunk_thumbnail - - -mesh_metadata - - -bonsai_type_info_hashtable - - -bonsai_type_info_hashtable - - -rect3 - - -application_api - - -debug_context_switch_event_buffer_stream_block - - -member_info_block_array_index - - -member_info_block_array_index - - -c_token_buffer_iterator - - -c_token_buffer_iterator - - -parser_iterator - - -parser_iterator - - -work_queue_entry - - -work_queue_entry - - -keyframe - - -standing_spot_stream - - -standing_spot_stream - - -c_token_buffer - - -c_token_buffer - - -c_token_buffer_stream_chunk - - -c_token_buffer_stream_chunk - - -maybe_bonsai_type_info - - -maybe_bonsai_type_info - - -generic_noise_params - - -counted_string - - -filtered_file_traversal_helper_params - - -shader - - -counted_string_stream - - -thread_main_callback_type_buffer - - -bonsai_render_command_allocate_texture - - -counted_string_stream - - -thread_main_callback_type_buffer - - -tuple_cs_cs_stream - - -tuple_cs_cs_stream - - -registered_memory_arena - - -ui_relative_position_reference - - -debug_scope_tree - - -file_traversal_node_block - - -file_traversal_node_block - - -gaussian_render_group - - -called_function - - -bitmap_block_array - - -bitmap_block_array - - -line - - -world_edit_shape - - -vox_data_block_array_index - - -vox_data_block_array_index - - -maybe_asset_id - - -maybe_asset_id - - -ui_render_command_button_start - - -animation - - -octave - - -counted_string_hashtable_iterator - - -asset_system - - -counted_string_hashtable_iterator - - -shape_layer - - -bonsai_render_command_reallocate_world_chunk_buffers - - -work_queue_entry_init_world_chunk - - -untextured_3d_geometry_buffer - - -bitmap_block_array_index - - -triangle - - -bitmap_block_array_index - - -work_queue - - -bloom_render_group - - -bitmap_block_array - - -bitmap_block_array - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -bonsai_type_info_buffer - - -bonsai_type_info_buffer - - -v3i_cursor - - -v3i_cursor - - -bonsai_render_command_deallocate_texture - - -texture_ptr_block_array_index - - -camera_1 - - -texture_ptr_block_array_index - - -world_chunk_ptr_block_array - - -world_chunk_ptr_block_array - - -v3i_stream - - -v3i_stream - - -standing_spot_buffer - - -standing_spot_buffer - - -ui_toggle - - -world - - -model_block - - -model_block - - -model_block_array - - -model_block_array - - -selection_modification_state - - -entity_1 - - -engine_debug - - -bloom_downsample_shader - - -g_buffer_textures - - -render_entity_to_texture_group - - -work_queue_entry_copy_buffer_ref - - -loaded_collada_mesh - - -picked_world_chunk_static_buffer - - -voxel_synthesis_change_propagation_info - - -texture_block - - -texture_block - - -voxel_synth_tile_hashtable_iterator - - -voxel_synth_tile_hashtable_iterator - - -bitmap_block - - -bitmap_block - - -brush_layer - - -entity_ptr_block_array_index - - -entity_ptr_block_array_index - - -boundary_voxel - - -bonsai_debug_system - - -debug_histogram_function - - -ui_render_command_force_update_basis - - -v3i_stream_chunk - - -v3i_stream_chunk - - -opengl - - -cycle_range - - -v3i_buffer - - -v3i_buffer - - -ui_render_command_rel_border - - -ansi_stream - - -transparency_render_group - - -random_series - - -canonical_position - - -engine_resources - - -entity_ptr_block_array - - -entity_ptr_block_array - - -lod_element_buffer - - -tagged_counted_string_stream_stream - - -tagged_counted_string_stream_stream - - -sphere - - -render_buffers_2d - - -framebuffer - - -debug_context_switch_event_buffer_stream - - -boundary_voxels - - -xml_tag_hashtable_iterator - - -xml_tag_hashtable_iterator - - -world_update_op_shape_params_asset - - -current_triangles - - -counted_string_hashtable - - -counted_string_hashtable - - -member_info - - -ui_render_command_window_end - - -ui_render_params - - -v3_cursor - - -v3_cursor - - -file_traversal_node_buffer - - -file_traversal_node_buffer - - -tuple_cs_cs - - -tuple_cs_cs - - -thread_startup_params - - -voxel_stack_element_block_array - - -voxel_stack_element_block_array - - -tiered_mesh_freelist - - -tiered_mesh_freelist - - -bitmap_image_header - - -model - - -c_token - - -asset_thumbnail_block_array - - -asset_thumbnail_block_array - - -file_traversal_node_block_array - - -file_traversal_node_block_array - - -entity - - -ui_toggle_hashtable_iterator - - -ui_toggle_hashtable_iterator - - -g_buffer_render_group - - -voxel_synthesis_change_propagation_info_stack - - -voxel_synthesis_change_propagation_info_stack - - -voxel_stack_element_cursor - - -voxel_stack_element_cursor - - -camera_0 - - -mesh_freelist - - -counted_string_iterator - - -counted_string_iterator - - -u8_cursor - - -file_traversal_node_block_array_index - - -file_traversal_node_block_array_index - - -debug_context_switch_event_buffer - - -gpu_element_buffer_handles - - -button_interaction_result - - -texture_ptr_block_array - - -texture_ptr_block_array - - -tuple_cs_cs_buffer - - -tuple_cs_cs_buffer - - -window_sort_params - - -entity_0 - - -aabb_intersect_result - - -model_block_array_index - - -model_block_array_index - - -world_chunk_lod_element_buffer - - -find_button_start_result - - -ui_render_command_textured_quad - - -maybe_ray - - -maybe_picked_voxel - - -standing_spot_stream_chunk - - -standing_spot_stream_chunk - - -min_max_avg_dt - - -voxel_stack_element - - -noise_layer - - -voxel_lighting - - -render_to_texture_world_chunk_async_params - - -entity_entity_collision_event - - -work_queue_entry_rebuild_mesh - - -tagged_counted_string_stream_stream_chunk - - -tagged_counted_string_stream_stream_chunk - - -lighting_settings - - -vox_data - - -edge - - -world_edit_params - - -xml_property - - -work_queue_entry_update_world_region - - -ui_debug - - - diff --git a/generated/for_datatypes_Q8uOZAEQ.h b/generated/for_datatypes_Q8uOZAEQ.h deleted file mode 100644 index 15b45fa6c..000000000 --- a/generated/for_datatypes_Q8uOZAEQ.h +++ /dev/null @@ -1,623 +0,0 @@ -// src/engine/render.cpp:1216:0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -fooooooo fooooooo - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -render_to_texture_world_chunk_async_params render_to_texture_world_chunk_async_params - -render_to_texture_world_chunk_async_params render_to_texture_world_chunk_async_params - - - - - - - - - - - - - diff --git a/generated/for_datatypes_V2AOA3sH.h b/generated/for_datatypes_V2AOA3sH.h deleted file mode 100644 index bca590c62..000000000 --- a/generated/for_datatypes_V2AOA3sH.h +++ /dev/null @@ -1,608 +0,0 @@ -// src/engine/work_queue.h:198:0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -AsyncFunctionCall_render_to_texture_world_chunk_async_params, - - - - - - - - - - - - - diff --git a/generated/for_datatypes_bYsCP2bZ.h b/generated/for_datatypes_bYsCP2bZ.h deleted file mode 100644 index 2b1382e98..000000000 --- a/generated/for_datatypes_bYsCP2bZ.h +++ /dev/null @@ -1,151 +0,0 @@ -// src/engine/render.cpp:1216:0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/generated/for_datatypes_debug_print.h b/generated/for_datatypes_debug_print.h deleted file mode 100644 index 1972a3356..000000000 --- a/generated/for_datatypes_debug_print.h +++ /dev/null @@ -1,1941 +0,0 @@ -// src/engine/render.cpp:1216:0 - -u32_block_array - - -u32_block_array - - -u32_cursor - - -u8_cursor_block_array - - -u8_cursor_block_array - - -lighting_render_group - - -game_mode - - -render_debug - - -tagged_counted_string_stream - - -world_chunk_file_header_v3 - - -u8_cursor - - -ui_toggle - - -c_token_cursor_up - - -u8_cursor - - -bonsai_futex - - -engine_settings - - -rect3i_buffer - - -entropy_lists - - -rect3i_buffer - - -entropy_lists - - -bonsai_render_command_deallocate_buffers - - -parser_stream - - -parser_stream - - -world_chunk_file_header_v1 - - -texture - - -asset_thumbnail - - -ui_render_command_text - - -level_header - - -asset_thumbnail_block - - -asset_thumbnail_block - - -brush_settings_1 - - -native_file - - -debug_timed_function - - -bonsai_render_command_do_stuff - - -ui_render_command_buffer - - -maybe_file_traversal_node - - -maybe_file_traversal_node - - -vertex_material - - -white_noise_params - - -texture_block_array - - -texture_block_array - - -heap_allocator - - -xml_tag - - -v3i_iterator - - -v3i_iterator - - -world_update_op_shape_params_rect - - -platform - - -parser_stream_chunk - - -parser_stream_chunk - - -hotkeys - - -shadow_render_group - - -tile_rule_id - - -ui_render_command_column_start - - -maybe_standing_spot - - -entity_position_info - - -maybe_standing_spot - - -parser_linked_list_node - - -particle_system - - -parser_linked_list_node - - -engine_api - - -bonsai_render_command_gl_timer_read_value_and_histogram - - -sort_key - - -u8_cursor_block_array - - -u8_cursor_block_array - - -context_switch_event - - -voronoi_noise_params - - -ui_toggle_button_handle - - -bitmap_buffer - - -bitmap_buffer - - -work_queue_entry__bonsai_render_command - - -work_queue_entry__bonsai_render_command - - -interactable - - -u32_block - - -u32_block - - -c_token_buffer_stream - - -c_token_buffer_stream - - -texture_block_array - - -texture_block_array - - -ao_render_group - - -light - - -bonsai_render_command_gl_timer_init - - -linei - - -bitmap - - -voxel_synth_tile_linked_list_node - - -voxel_synth_tile_linked_list_node - - -u64_cursor - - -octave_buffer - - -u64_cursor - - -event_queue - - -unique_debug_profile_scope - - -maybe_ui_toggle - - -maybe_ui_toggle - - -u64_stream - - -u64_stream - - -brush_settings_0 - - -bonsai_type_info_hashtable_iterator - - -bonsai_type_info_hashtable_iterator - - -interactable_handle - - -heap_allocation_block - - -ui_id - - -u32_block_array - - -u32_block_array - - -find_command_result - - -noise_layer_0 - - -xml_parsing_at_indicators - - -ui_render_command_abs_border - - -memory_arena_stats - - -collision_event - - -bonsai_render_command_clear_all_framebuffers - - -camera - - -model_buffer - - -model_buffer - - -picked_world_chunk - - -picked_voxel - - -debug_state - - -renderer_2d - - -ray - - -parser_hashtable_iterator - - -parser_hashtable_iterator - - -ui_style - - -u64_stream_chunk - - -parser_hashtable - - -u64_stream_chunk - - -parser_hashtable - - -frustum - - -u64_buffer - - -u64_buffer - - -layout - - -ui_render_command_button_end - - -plane - - -counted_string_cursor - - -counted_string_cursor - - -entity_ptr_block_array - - -world_chunk - - -entity_ptr_block_array - - -texture - - -entity_block_array - - -world_chunk_ptr_block - - -world_chunk_ptr_block - - -parser - - -tagged_counted_string_stream_iterator - - -tagged_counted_string_stream_iterator - - -counted_string_stream_chunk - - -counted_string_stream_chunk - - -rect3 - - -world_update_op_shape_params_sphere - - -file_traversal_node - - -bonsai_render_command_gl_timer_start - - -fooooooo - - -graphics_settings - - -maybe_asset_ptr - - -maybe_asset_ptr - - -world_chunk_ptr_buffer - - -world_chunk_ptr_buffer - - -ui_render_command_table_end - - -graphics - - -table_info - - -perlin_noise_params - - -layered_brush_editor - - -font - - -tile_ruleset_buffer - - -tile_ruleset_buffer - - -ui_render_command - - -ui_render_command - - -asset_id - - -world_chunk_file_header_v3 - - -mutex - - -xml_tag_linked_list_node - - -xml_tag_linked_list_node - - -vertex_material - - -gpu_mapped_world_chunk_geometry_buffer - - -memory_record - - -noise_value_to_material_index - - -member_info_block - - -member_info_block - - -world_chunk_geometry_buffer - - -physics - - -asset - - -voxel_stack_element_block_array - - -voxel_stack_element_block_array - - -layered_brush_editor_0 - - -entity_ptr_block - - -entity_ptr_block - - -c_token_buffer_buffer - - -c_token_buffer_buffer - - -bonsai_render_command_gl_timer_end - - -debug_profile_scope_cursor - - -debug_profile_scope_cursor - - -s32_cursor - - -s32_cursor - - -counted_string_buffer - - -u32_cursor - - -counted_string_buffer - - -u32_cursor - - -asset_thumbnail_block_array_index - - -asset_thumbnail_block_array_index - - -temp_memory_handle - - -text_box_edit_state - - -r32_stream - - -s32_stream - - -s32_stream - - -u32_stream - - -u32_stream - - -lighting_settings_0 - - -bonsai_render_command_allocate_buffers - - -gpu_mapped_element_buffer - - -voxel_stack_element_block_array_index - - -voxel_stack_element_block_array_index - - -voxel - - -world_chunk_ptr_block_array - - -world_chunk_ptr_block_array - - -ui_render_command_text_at - - -freelist_entry - - -char_cursor - - -terminal_colors - - -bonsai_render_command_setup_shader - - -canonical_position - - -mutex_op_record - - -untextured_3d_geometry_buffer - - -debug_profile_scope - - -maybe_entity_ptr - - -maybe_entity_ptr - - -string_builder - - -standing_spot_iterator - - -standing_spot_iterator - - -maybe_ui_toggle_ptr - - -maybe_ui_toggle_ptr - - -bonsai_render_command_teardown_shader - - -tile_ruleset - - -layered_brush_editor_1 - - -vox_data_block_array - - -vox_data_block_array - - -texture_block_array_index - - -texture_block_array_index - - -work_queue_entry_init_asset - - -ui_render_command_window_start - - -bitmap_header - - -c_token_cursor - - -particle - - -s32_stream_chunk - - -s32_stream_chunk - - -peek_result - - -u32_stream_chunk - - -u32_stream_chunk - - -texture_ptr_block - - -texture_ptr_block - - -u32_buffer - - -u32_buffer - - -bonsai_render_command_draw_all_entities - - -ui_toggle_button_handle_buffer - - -ui_toggle_button_handle_buffer - - -render_state - - -tuple_cs_cs_buffer_builder - - -voxel_synth_tile_buffer - - -tuple_cs_cs_buffer_builder - - -voxel_synth_tile_buffer - - -u8_cursor_block_array_index - - -u8_cursor_block_array_index - - -debug_draw_call - - -counted_string_linked_list_node - - -counted_string_linked_list_node - - -input_event - - -voxel_stack_element_block - - -voxel_stack_element_block - - -frame_stats - - -string_from_parser - - -mutex_op_array - - -entity_list - - -work_queue_entry_sim_particle_system - - -counted_string - - -voxel_synthesis_gen_info - - -os - - -standing_spot_block - - -standing_spot_block - - -u32_block_array_index - - -asset - - -u32_block_array_index - - -standing_spot_block_array - - -standing_spot_block_array - - -sort_key_f - - -u64_iterator - - -u64_iterator - - -renderer_2d - - -ui_render_command_untextured_quad - - -debug_context_switch_event - - -parser_cursor - - -parser_cursor - - -ui_toggle_linked_list_node - - -ui_toggle_linked_list_node - - -u8_cursor_block - - -selected_arenas - - -u8_cursor_block - - -level_header_0 - - -bloom_upsample_shader - - -voxel_synth_tile - - -bonsai_type_info_linked_list_node - - -bonsai_type_info_linked_list_node - - -frame_event - - -rect2 - - -member_info_block_array - - -member_info_block_array - - -work_queue_entry_copy_buffer_set - - -v3i_buffer - - -textured_2d_geometry_buffer - - -level_header_1 - - -render_settings - - -point_buffer - - -window_layout - - -asset_buffer - - -asset_buffer - - -plane_computation - - -untextured_2d_geometry_buffer - - -apply_world_edit_params - - -macro_expansion - - -level_header_2 - - -m4 - - -ui_render_command_force_advance - - -bonsai_render_command_reallocate_buffers - - -shader_uniform - - -xml_token_stream - - -xml_tag_stream - - -chunk_data - - -maybe_v3 - - -thread_local_state - - -world_chunk_ptr_block_array_index - - -world_chunk_ptr_block_array_index - - -ui_element_reference - - -level_editor - - -entity_block_array_index - - -vox_data_block - - -vox_data_block - - -entity_block_array - - -maybe_model - - -world_chunk_file_header_v2 - - -model_block_array - - -model_block_array - - -standing_spot_block_array_index - - -standing_spot_block_array_index - - -tuple_cs_cs_iterator - - -world_chunk - - -tile_rule - - -tuple_cs_cs_iterator - - -brush_settings - - -clip_result - - -texture_cursor - - -texture_cursor - - -ui_toggle_button_group - - -ui_toggle_hashtable - - -ui_toggle_hashtable - - -world_edit_brush - - -game_lights - - -debug_thread_state - - -ui_render_command_table_start - - -untextured_3d_geometry_buffer - - -v3i_stream - - -gpu_mapped_element_buffer - - -rect3cp - - -bonsai_type_info - - -voxel_synth_tile_hashtable - - -voxel_synth_tile_hashtable - - -entity_id - - -bonsai_render_command_draw_world_chunk_draw_list - - -standing_spot - - -maybe_model_buffer - - -asset_thumbnail_block_array - - -maybe_model_buffer - - -asset_thumbnail_block_array - - -texture_ptr_block_array - - -texture_ptr_block_array - - -ui_render_command_column_end - - -entity - - -entity - - -ui_render_command_untextured_quad_at - - -member_info_block_array - - -member_info_block_array - - -entity_block - - -xml_token - - -vox_data_block_array - - -vox_data_block_array - - -memory_arena - - -sort_key_string - - -counted_string_buffer - - -render_settings_0 - - -file_traversal_node_block_array - - -file_traversal_node_block_array - - -standing_spot_block_array - - -standing_spot_block_array - - -render_buffers_2d - - -rect3i - - -world_update_op_shape_params_chunk_data - - -selected_memory_arena - - -m_nxn - - -input - - -d_list - - -composite_render_group - - -s32_iterator - - -s32_iterator - - -u32_iterator - - -u32_iterator - - -bonsai_stdlib - - -tuple_cs_cs_stream_chunk - - -tuple_cs_cs_stream_chunk - - -v3i_cursor - - -work_queue_entry__align_to_cache_line_helper - - -xml_tag_hashtable - - -xml_tag_hashtable - - -voxel_synthesis_result - - -chunk_thumbnail - - -mesh_metadata - - -bonsai_type_info_hashtable - - -bonsai_type_info_hashtable - - -rect3 - - -application_api - - -debug_context_switch_event_buffer_stream_block - - -member_info_block_array_index - - -member_info_block_array_index - - -c_token_buffer_iterator - - -c_token_buffer_iterator - - -parser_iterator - - -parser_iterator - - -work_queue_entry - - -work_queue_entry - - -keyframe - - -standing_spot_stream - - -standing_spot_stream - - -c_token_buffer - - -c_token_buffer - - -c_token_buffer_stream_chunk - - -c_token_buffer_stream_chunk - - -maybe_bonsai_type_info - - -maybe_bonsai_type_info - - -generic_noise_params - - -counted_string - - -filtered_file_traversal_helper_params - - -shader - - -counted_string_stream - - -thread_main_callback_type_buffer - - -bonsai_render_command_allocate_texture - - -counted_string_stream - - -thread_main_callback_type_buffer - - -tuple_cs_cs_stream - - -tuple_cs_cs_stream - - -registered_memory_arena - - -ui_relative_position_reference - - -debug_scope_tree - - -file_traversal_node_block - - -file_traversal_node_block - - -gaussian_render_group - - -called_function - - -bitmap_block_array - - -bitmap_block_array - - -line - - -world_edit_shape - - -vox_data_block_array_index - - -vox_data_block_array_index - - -maybe_asset_id - - -maybe_asset_id - - -ui_render_command_button_start - - -animation - - -octave - - -counted_string_hashtable_iterator - - -asset_system - - -counted_string_hashtable_iterator - - -shape_layer - - -bonsai_render_command_reallocate_world_chunk_buffers - - -work_queue_entry_init_world_chunk - - -untextured_3d_geometry_buffer - - -bitmap_block_array_index - - -triangle - - -bitmap_block_array_index - - -work_queue - - -bloom_render_group - - -bitmap_block_array - - -bitmap_block_array - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -(anonymous) - - -bonsai_type_info_buffer - - -bonsai_type_info_buffer - - -v3i_cursor - - -v3i_cursor - - -bonsai_render_command_deallocate_texture - - -texture_ptr_block_array_index - - -camera_1 - - -texture_ptr_block_array_index - - -world_chunk_ptr_block_array - - -world_chunk_ptr_block_array - - -v3i_stream - - -v3i_stream - - -standing_spot_buffer - - -standing_spot_buffer - - -ui_toggle - - -world - - -model_block - - -model_block - - -model_block_array - - -model_block_array - - -selection_modification_state - - -entity_1 - - -engine_debug - - -bloom_downsample_shader - - -g_buffer_textures - - -render_entity_to_texture_group - - -work_queue_entry_copy_buffer_ref - - -loaded_collada_mesh - - -picked_world_chunk_static_buffer - - -voxel_synthesis_change_propagation_info - - -texture_block - - -texture_block - - -voxel_synth_tile_hashtable_iterator - - -voxel_synth_tile_hashtable_iterator - - -bitmap_block - - -bitmap_block - - -brush_layer - - -entity_ptr_block_array_index - - -entity_ptr_block_array_index - - -boundary_voxel - - -bonsai_debug_system - - -debug_histogram_function - - -ui_render_command_force_update_basis - - -v3i_stream_chunk - - -v3i_stream_chunk - - -opengl - - -cycle_range - - -v3i_buffer - - -v3i_buffer - - -ui_render_command_rel_border - - -ansi_stream - - -transparency_render_group - - -random_series - - -canonical_position - - -engine_resources - - -entity_ptr_block_array - - -entity_ptr_block_array - - -lod_element_buffer - - -tagged_counted_string_stream_stream - - -tagged_counted_string_stream_stream - - -sphere - - -render_buffers_2d - - -framebuffer - - -debug_context_switch_event_buffer_stream - - -boundary_voxels - - -xml_tag_hashtable_iterator - - -xml_tag_hashtable_iterator - - -world_update_op_shape_params_asset - - -current_triangles - - -counted_string_hashtable - - -counted_string_hashtable - - -member_info - - -ui_render_command_window_end - - -ui_render_params - - -v3_cursor - - -v3_cursor - - -file_traversal_node_buffer - - -file_traversal_node_buffer - - -tuple_cs_cs - - -tuple_cs_cs - - -thread_startup_params - - -voxel_stack_element_block_array - - -voxel_stack_element_block_array - - -tiered_mesh_freelist - - -tiered_mesh_freelist - - -bitmap_image_header - - -model - - -c_token - - -asset_thumbnail_block_array - - -asset_thumbnail_block_array - - -file_traversal_node_block_array - - -file_traversal_node_block_array - - -entity - - -ui_toggle_hashtable_iterator - - -ui_toggle_hashtable_iterator - - -g_buffer_render_group - - -voxel_synthesis_change_propagation_info_stack - - -voxel_synthesis_change_propagation_info_stack - - -voxel_stack_element_cursor - - -voxel_stack_element_cursor - - -camera_0 - - -mesh_freelist - - -counted_string_iterator - - -counted_string_iterator - - -u8_cursor - - -file_traversal_node_block_array_index - - -file_traversal_node_block_array_index - - -debug_context_switch_event_buffer - - -gpu_element_buffer_handles - - -button_interaction_result - - -texture_ptr_block_array - - -texture_ptr_block_array - - -tuple_cs_cs_buffer - - -tuple_cs_cs_buffer - - -window_sort_params - - -entity_0 - - -aabb_intersect_result - - -model_block_array_index - - -model_block_array_index - - -world_chunk_lod_element_buffer - - -find_button_start_result - - -ui_render_command_textured_quad - - -maybe_ray - - -maybe_picked_voxel - - -standing_spot_stream_chunk - - -standing_spot_stream_chunk - - -min_max_avg_dt - - -voxel_stack_element - - -noise_layer - - -voxel_lighting - - -render_to_texture_world_chunk_async_params - - -render_to_texture_world_chunk_async_params - - -entity_entity_collision_event - - -work_queue_entry_rebuild_mesh - - -tagged_counted_string_stream_stream_chunk - - -tagged_counted_string_stream_stream_chunk - - -lighting_settings - - -vox_data - - -edge - - -world_edit_params - - -xml_property - - -work_queue_entry_update_world_region - - -ui_debug - - - diff --git a/generated/for_datatypes_fkubhsYl.h b/generated/for_datatypes_fkubhsYl.h index 67b5128a6..dd7077bab 100644 --- a/generated/for_datatypes_fkubhsYl.h +++ b/generated/for_datatypes_fkubhsYl.h @@ -1,4 +1,10 @@ -// src/engine/work_queue.h:285:0 +// src/engine/work_queue.h:279:0 + + + + + + @@ -595,7 +601,27 @@ render_to_texture_async_params render_to_texture_async_params; -render_to_texture_world_chunk_async_params render_to_texture_world_chunk_async_params; + + + + + + + + + + + + + + + + + + + + + diff --git a/generated/for_datatypes_kv3WBTai.h b/generated/for_datatypes_kv3WBTai.h index 63b59b60d..5ff83e53e 100644 --- a/generated/for_datatypes_kv3WBTai.h +++ b/generated/for_datatypes_kv3WBTai.h @@ -1,4 +1,10 @@ -// src/engine/work_queue.h:266:0 +// src/engine/work_queue.h:260:0 + + + + + + @@ -595,7 +601,27 @@ type_render_to_texture_async_params, -type_render_to_texture_world_chunk_async_params, + + + + + + + + + + + + + + + + + + + + + diff --git a/generated/gen_common_vector_v2.h b/generated/gen_common_vector_v2.h index 27a186f63..be156fa8d 100644 --- a/generated/gen_common_vector_v2.h +++ b/generated/gen_common_vector_v2.h @@ -1,4 +1,4 @@ -// external/bonsai_stdlib/src/vector.h:782:0 +// external/bonsai_stdlib/src/vector.h:787:0 inline r32 LengthSq( v2 Vec ) diff --git a/generated/gen_common_vector_v3.h b/generated/gen_common_vector_v3.h index 6d7e76e63..cecae9145 100644 --- a/generated/gen_common_vector_v3.h +++ b/generated/gen_common_vector_v3.h @@ -1,4 +1,4 @@ -// external/bonsai_stdlib/src/vector.h:785:0 +// external/bonsai_stdlib/src/vector.h:790:0 inline r32 LengthSq( v3 Vec ) diff --git a/generated/gen_common_vector_v3i.h b/generated/gen_common_vector_v3i.h index 17915d817..19bd61551 100644 --- a/generated/gen_common_vector_v3i.h +++ b/generated/gen_common_vector_v3i.h @@ -1,4 +1,4 @@ -// external/bonsai_stdlib/src/vector.h:788:0 +// external/bonsai_stdlib/src/vector.h:793:0 inline s32 LengthSq( v3i Vec ) diff --git a/generated/gen_constructor_voxel_stack_element.h b/generated/gen_constructor_voxel_stack_element.h index ae78918e0..fc8f4fbc6 100644 --- a/generated/gen_constructor_voxel_stack_element.h +++ b/generated/gen_constructor_voxel_stack_element.h @@ -1,4 +1,4 @@ -// src/engine/world_chunk.cpp:4156:0 +// src/engine/world_update.h:32:0 link_internal voxel_stack_element VoxelStackElement( v3i VoxSimP , voxel_rule_direction Dir ) diff --git a/generated/gen_constructor_voxel_synthesis_change_propagation_info.h b/generated/gen_constructor_voxel_synthesis_change_propagation_info.h index d72c0ad0c..07de319f4 100644 --- a/generated/gen_constructor_voxel_synthesis_change_propagation_info.h +++ b/generated/gen_constructor_voxel_synthesis_change_propagation_info.h @@ -1,4 +1,4 @@ -// src/engine/voxel_synthesis.h:321:0 +// src/engine/voxel_synthesis.h:304:0 link_internal voxel_synthesis_change_propagation_info VoxelSynthesisChangePropagationInfo( tile_rule PrevTileOptions , v3i PrevTileP , v3i DirOfTravel ) diff --git a/generated/gen_default_equality_operator_tile_rule_id.h b/generated/gen_default_equality_operator_tile_rule_id.h index b8a23b4ce..382ef129b 100644 --- a/generated/gen_default_equality_operator_tile_rule_id.h +++ b/generated/gen_default_equality_operator_tile_rule_id.h @@ -1,4 +1,4 @@ -// src/engine/voxel_synthesis.h:38:0 +// src/engine/voxel_synthesis.h:21:0 link_internal b32 operator==( tile_rule_id E1, tile_rule_id E2 ) diff --git a/generated/gen_default_equality_operator_ui_id.h b/generated/gen_default_equality_operator_ui_id.h index 139a22fa7..d5012f64b 100644 --- a/generated/gen_default_equality_operator_ui_id.h +++ b/generated/gen_default_equality_operator_ui_id.h @@ -1,4 +1,4 @@ -// external/bonsai_stdlib/src/ui/interactable.h:21:0 +// external/bonsai_stdlib/src/ui/interactable.h:29:0 link_internal b32 operator==( ui_id E1, ui_id E2 ) diff --git a/generated/gen_lerp_v2.h b/generated/gen_lerp_v2.h index ca87f8c48..18dca65f6 100644 --- a/generated/gen_lerp_v2.h +++ b/generated/gen_lerp_v2.h @@ -1,4 +1,4 @@ -// external/bonsai_stdlib/src/vector.h:765:0 +// external/bonsai_stdlib/src/vector.h:770:0 inline v2 Lerp(r32 t, v2 P1, v2 P2) diff --git a/generated/gen_lerp_v3.h b/generated/gen_lerp_v3.h index e6a43ddbd..860f6b952 100644 --- a/generated/gen_lerp_v3.h +++ b/generated/gen_lerp_v3.h @@ -1,4 +1,4 @@ -// external/bonsai_stdlib/src/vector.h:768:0 +// external/bonsai_stdlib/src/vector.h:773:0 inline v3 Lerp(r32 t, v3 P1, v3 P2) diff --git a/generated/gen_vector_area_v2.h b/generated/gen_vector_area_v2.h index 5a01ba207..995dc186e 100644 --- a/generated/gen_vector_area_v2.h +++ b/generated/gen_vector_area_v2.h @@ -1,4 +1,4 @@ -// external/bonsai_stdlib/src/vector.h:776:0 +// external/bonsai_stdlib/src/vector.h:781:0 inline r32 Area( v2 Vec ) diff --git a/generated/gen_vector_area_v2i.h b/generated/gen_vector_area_v2i.h index 57c0e4fce..2a2ec5f46 100644 --- a/generated/gen_vector_area_v2i.h +++ b/generated/gen_vector_area_v2i.h @@ -1,4 +1,4 @@ -// external/bonsai_stdlib/src/vector.h:779:0 +// external/bonsai_stdlib/src/vector.h:784:0 inline s32 Area( v2i Vec ) diff --git a/generated/gen_vector_infix_operator_v3i_688856393.h b/generated/gen_vector_infix_operator_v3i_688856393.h index 634e0f98e..ff94762e1 100644 --- a/generated/gen_vector_infix_operator_v3i_688856393.h +++ b/generated/gen_vector_infix_operator_v3i_688856393.h @@ -1,4 +1,4 @@ -// external/bonsai_stdlib/src/vector.h:762:0 +// external/bonsai_stdlib/src/vector.h:767:0 inline v3i operator&( v3i P1, v3i P2 ) diff --git a/generated/gen_vector_infix_operator_v3i_688856449.h b/generated/gen_vector_infix_operator_v3i_688856449.h index 6085bbf5c..63cda1295 100644 --- a/generated/gen_vector_infix_operator_v3i_688856449.h +++ b/generated/gen_vector_infix_operator_v3i_688856449.h @@ -1,4 +1,4 @@ -// external/bonsai_stdlib/src/vector.h:759:0 +// external/bonsai_stdlib/src/vector.h:764:0 inline v3i operator^( v3i P1, v3i P2 ) diff --git a/generated/gen_vector_normalize_funcs_v2.h b/generated/gen_vector_normalize_funcs_v2.h index 1a1d47f9b..5e3423b62 100644 --- a/generated/gen_vector_normalize_funcs_v2.h +++ b/generated/gen_vector_normalize_funcs_v2.h @@ -1,4 +1,4 @@ -// external/bonsai_stdlib/src/vector.h:791:0 +// external/bonsai_stdlib/src/vector.h:796:0 inline v2 Normalize( v2 Vec, r32 Length) diff --git a/generated/gen_vector_normalize_funcs_v3.h b/generated/gen_vector_normalize_funcs_v3.h index b8a5ca372..81c831297 100644 --- a/generated/gen_vector_normalize_funcs_v3.h +++ b/generated/gen_vector_normalize_funcs_v3.h @@ -1,4 +1,4 @@ -// external/bonsai_stdlib/src/vector.h:794:0 +// external/bonsai_stdlib/src/vector.h:799:0 inline v3 Normalize( v3 Vec, r32 Length) diff --git a/generated/generate_cursor_voxel_stack_element.h b/generated/generate_cursor_voxel_stack_element.h index 586ac3355..5471bc13f 100644 --- a/generated/generate_cursor_voxel_stack_element.h +++ b/generated/generate_cursor_voxel_stack_element.h @@ -1,4 +1,4 @@ -// src/engine/world_chunk.cpp:4162:0 +// src/engine/world_update.h:38:0 struct voxel_stack_element_cursor { diff --git a/generated/generate_stack_voxel_synthesis_change_propagation_info_803395170.h b/generated/generate_stack_voxel_synthesis_change_propagation_info_803395170.h index 2595ece0a..31a5ec0ca 100644 --- a/generated/generate_stack_voxel_synthesis_change_propagation_info_803395170.h +++ b/generated/generate_stack_voxel_synthesis_change_propagation_info_803395170.h @@ -1,4 +1,4 @@ -// src/engine/voxel_synthesis.h:327:0 +// src/engine/voxel_synthesis.h:310:0 struct voxel_synthesis_change_propagation_info_stack { diff --git a/generated/generate_stream_compact_standing_spot.h b/generated/generate_stream_compact_standing_spot.h index 01be67154..8a7d0ae69 100644 --- a/generated/generate_stream_compact_standing_spot.h +++ b/generated/generate_stream_compact_standing_spot.h @@ -1,4 +1,4 @@ -// src/engine/world_chunk.h:525:0 +// src/engine/world_chunk.h:511:0 link_internal standing_spot_buffer Compact(standing_spot_stream *Stream, memory_arena *PermMemory) diff --git a/generated/generate_stream_compact_v3i.h b/generated/generate_stream_compact_v3i.h index 49654dce7..0efcf1648 100644 --- a/generated/generate_stream_compact_v3i.h +++ b/generated/generate_stream_compact_v3i.h @@ -1,4 +1,4 @@ -// src/engine/world_chunk.cpp:3042:0 +// src/engine/world_chunk.cpp:3027:0 link_internal v3i_buffer Compact(v3i_stream *Stream, memory_arena *PermMemory) diff --git a/generated/generate_stream_standing_spot.h b/generated/generate_stream_standing_spot.h index 90e2b5b52..3e17a22d6 100644 --- a/generated/generate_stream_standing_spot.h +++ b/generated/generate_stream_standing_spot.h @@ -1,4 +1,4 @@ -// src/engine/world_chunk.h:522:0 +// src/engine/world_chunk.h:508:0 struct standing_spot_stream_chunk { diff --git a/generated/generate_string_table_asset_load_state.h b/generated/generate_string_table_asset_load_state.h index 4ea24a61e..9027206f6 100644 --- a/generated/generate_string_table_asset_load_state.h +++ b/generated/generate_string_table_asset_load_state.h @@ -1,4 +1,4 @@ -// src/engine/asset.h:140:0 +// src/engine/asset.h:141:0 link_internal counted_string ToStringPrefixless(asset_load_state Type) diff --git a/generated/generate_string_table_world_chunk_mesh_bitfield.h b/generated/generate_string_table_world_chunk_mesh_bitfield.h index a4259a6c2..e40848c71 100644 --- a/generated/generate_string_table_world_chunk_mesh_bitfield.h +++ b/generated/generate_string_table_world_chunk_mesh_bitfield.h @@ -1,4 +1,4 @@ -// src/engine/world_chunk.h:234:0 +// src/engine/world_chunk.h:237:0 link_internal counted_string ToStringPrefixless(world_chunk_mesh_bitfield Type) diff --git a/generated/generate_string_table_world_chunk_mesh_index.h b/generated/generate_string_table_world_chunk_mesh_index.h index 48ce8518c..3045b2d8d 100644 --- a/generated/generate_string_table_world_chunk_mesh_index.h +++ b/generated/generate_string_table_world_chunk_mesh_index.h @@ -1,4 +1,4 @@ -// src/engine/world_chunk.h:237:0 +// src/engine/world_chunk.h:240:0 link_internal counted_string ToStringPrefixless(world_chunk_mesh_index Type) diff --git a/generated/gpu_buffer_lod_element_buffer_untextured_3d_geometry_buffer.h b/generated/gpu_buffer_lod_element_buffer_untextured_3d_geometry_buffer.h index c026e887d..110f5cb1e 100644 --- a/generated/gpu_buffer_lod_element_buffer_untextured_3d_geometry_buffer.h +++ b/generated/gpu_buffer_lod_element_buffer_untextured_3d_geometry_buffer.h @@ -1,4 +1,4 @@ -// src/engine/render.cpp:1030:0 +// src/engine/render.cpp:1040:0 link_internal void @@ -42,10 +42,6 @@ SyncGpuBuffersAsync(engine_resources *Engine, lod_element_buffer *Meshes) PushReallocateBuffersCommand(&Engine->Stdlib.Plat.RenderQ, Handles, Mesh); Result = True; } - else - { - PushDeallocateBuffersCommand(&Engine->Stdlib.Plat.RenderQ, Handles); - } } } @@ -73,16 +69,8 @@ SyncGpuBuffersImmediate(engine_resources *Engine, lod_element_buffer *Meshes) { if (Mesh->At) { - // @duplicate_realloc_code - if (Handles->VertexHandle) - { - GL.DeleteBuffers(3, &Handles->VertexHandle); - Clear(Handles); - AssertNoGlErrors; - } - - AllocateGpuElementBuffer(Handles, Mesh->At); - CopyToGpuBuffer(Mesh, Handles); + Handles->Flags |= GpuHandles_UpdatePending; // NOTE(Jesse): Kinda dumb, but this has to be set at the moment.. + ReallocateAndSyncGpuBuffers(Handles, Mesh); Result = True; } else diff --git a/generated/gpu_buffer_world_chunk_lod_element_buffer_world_chunk_geometry_buffer.h b/generated/gpu_buffer_world_chunk_lod_element_buffer_world_chunk_geometry_buffer.h deleted file mode 100644 index 69dcd705f..000000000 --- a/generated/gpu_buffer_world_chunk_lod_element_buffer_world_chunk_geometry_buffer.h +++ /dev/null @@ -1,106 +0,0 @@ -// src/engine/render.cpp:1033:0 - - -link_internal void -CopyBufferIntoBuffer( world_chunk_geometry_buffer *Src, world_chunk_geometry_buffer *Dest) -{ - BufferVertsChecked(Src, Dest, {}, V3(1.0f)); -} - -link_internal void -CopyToGpuBuffer( world_chunk_geometry_buffer *Mesh, gpu_mapped_world_chunk_geometry_buffer *GpuBuffer) -{ - gpu_mapped_world_chunk_geometry_buffer Dest = MapGpuBuffer_world_chunk_geometry_buffer(&GpuBuffer->Handles); - CopyBufferIntoBuffer(Mesh, &Dest.Buffer); - FlushBuffersToCard(&Dest); -} - -link_internal void -CopyToGpuBuffer( world_chunk_geometry_buffer *Mesh, gpu_element_buffer_handles *Handles) -{ - gpu_mapped_world_chunk_geometry_buffer Dest = MapGpuBuffer_world_chunk_geometry_buffer(Handles); - CopyBufferIntoBuffer(Mesh, &Dest.Buffer); - FlushBuffersToCard(&Dest); -} - -link_internal b32 -SyncGpuBuffersAsync(engine_resources *Engine, world_chunk_lod_element_buffer *Meshes) -{ - b32 Result = False; - Assert(ThreadLocal_ThreadIndex != 1); - - RangeIterator(MeshIndex, MeshIndex_Count) - { - world_chunk_mesh_bitfield MeshBit = world_chunk_mesh_bitfield(1 << MeshIndex); - if (HasMesh(Meshes, MeshBit)) - { - gpu_element_buffer_handles *Handles = &Meshes->GpuBufferHandles[MeshIndex]; - - world_chunk_geometry_buffer *Mesh = AtomicReplaceMesh( Meshes, MeshBit, 0, u64_MAX ); - if (Mesh && Mesh->At) - { - PushReallocateBuffersCommand(&Engine->Stdlib.Plat.RenderQ, Handles, Mesh); - Result = True; - } - else - { - PushDeallocateBuffersCommand(&Engine->Stdlib.Plat.RenderQ, Handles); - } - } - } - - // TODO(Jesse): Is this actually a thing?? - FullBarrier; - - return Result; -} - -link_internal b32 -SyncGpuBuffersImmediate(engine_resources *Engine, world_chunk_lod_element_buffer *Meshes) -{ - b32 Result = False; - Assert(ThreadLocal_ThreadIndex == 1); - - RangeIterator(MeshIndex, MeshIndex_Count) - { - world_chunk_mesh_bitfield MeshBit = world_chunk_mesh_bitfield(1 << MeshIndex); - if (HasMesh(Meshes, MeshBit)) - { - gpu_element_buffer_handles *Handles = &Meshes->GpuBufferHandles[MeshIndex]; - - world_chunk_geometry_buffer *Mesh = AtomicReplaceMesh( Meshes, MeshBit, 0, u64_MAX ); - if (Mesh) - { - if (Mesh->At) - { - // @duplicate_realloc_code - if (Handles->VertexHandle) - { - GL.DeleteBuffers(3, &Handles->VertexHandle); - Clear(Handles); - AssertNoGlErrors; - } - - AllocateGpuElementBuffer(Handles, Mesh->At); - CopyToGpuBuffer(Mesh, Handles); - Result = True; - } - else - { - DeallocateGpuElementBuffer(Handles); - AssertNoGlErrors; - } - - DeallocateMesh(Engine, Mesh); - } - } - } - - AssertNoGlErrors; - - // TODO(Jesse): Is this actually a thing?? - FullBarrier; - - return Result; -} - diff --git a/generated/hashtable_get_ptr_window_layout_705671517_599498827.h b/generated/hashtable_get_ptr_window_layout_705671517_599498827.h new file mode 100644 index 000000000..0163d6e08 --- /dev/null +++ b/generated/hashtable_get_ptr_window_layout_705671517_599498827.h @@ -0,0 +1,31 @@ +// external/bonsai_stdlib/src/ui/ui.cpp:22:0 + +maybe_window_layout_ptr +GetPtrByHashtableKey( window_layout_hashtable *Table, ui_id HashtableKey ) +{ + /* ENSURE_OWNED_BY_THREAD(Table); */ + + maybe_window_layout_ptr Result = {}; + + auto *Bucket = GetHashBucket(umm(Hash(&HashtableKey)), Table); + while (Bucket) + { + auto E = &Bucket->Element; + + if (AreEqual(E->HashtableKey, HashtableKey)) + { + Result.Tag = Maybe_Yes; + Result.Value = E; + break; + } + else + { + Bucket = Bucket->Next; + } + } + + return Result; + + +} + diff --git a/generated/hashtable_get_window_layout_705671517_599498827.h b/generated/hashtable_get_window_layout_705671517_599498827.h new file mode 100644 index 000000000..d84e3e097 --- /dev/null +++ b/generated/hashtable_get_window_layout_705671517_599498827.h @@ -0,0 +1,29 @@ +// external/bonsai_stdlib/src/ui/ui.cpp:20:0 + +maybe_window_layout +GetByHashtableKey( window_layout_hashtable *Table, ui_id HashtableKey ) +{ + /* ENSURE_OWNED_BY_THREAD(Table); */ + + maybe_window_layout Result = {}; + + auto *Bucket = GetHashBucket(umm(Hash(&HashtableKey)), Table); + while (Bucket) + { + auto E = &Bucket->Element; + + if (AreEqual(E->HashtableKey, HashtableKey)) + { + Result.Tag = Maybe_Yes; + Result.Value = *E; + break; + } + else + { + Bucket = Bucket->Next; + } + } + + return Result; +} + diff --git a/generated/hashtable_impl_window_layout.h b/generated/hashtable_impl_window_layout.h new file mode 100644 index 000000000..cf8c7c936 --- /dev/null +++ b/generated/hashtable_impl_window_layout.h @@ -0,0 +1,154 @@ +// external/bonsai_stdlib/src/ui/ui.cpp:17:0 + +link_internal b32 AreEqual(window_layout_linked_list_node *Node1, window_layout_linked_list_node *Node2 ); + +link_internal window_layout_linked_list_node * +Allocate_window_layout_linked_list_node(memory_arena *Memory) +{ + window_layout_linked_list_node *Result = Allocate( window_layout_linked_list_node, Memory, 1); + return Result; +} + +link_internal window_layout_hashtable +Allocate_window_layout_hashtable(umm ElementCount, memory_arena *Memory) +{ + window_layout_hashtable Result = { + .Elements = Allocate( window_layout_linked_list_node*, Memory, ElementCount), + .Size = ElementCount, + /* OWNED_BY_THREAD_MEMBER_INIT() */ + }; + return Result; +} + +link_internal window_layout_linked_list_node * +GetHashBucket(umm HashValue, window_layout_hashtable *Table) +{ + /* ENSURE_OWNED_BY_THREAD(Table); */ + + Assert(Table->Size); + window_layout_linked_list_node *Result = Table->Elements[HashValue % Table->Size]; + return Result; +} + +link_internal window_layout * +GetFirstAtBucket(umm HashValue, window_layout_hashtable *Table) +{ + /* ENSURE_OWNED_BY_THREAD(Table); */ + + window_layout_linked_list_node *Bucket = GetHashBucket(HashValue, Table); + window_layout *Result = &Bucket->Element; + return Result; +} + +link_internal window_layout * +Insert(window_layout_linked_list_node *Node, window_layout_hashtable *Table) +{ + /* ENSURE_OWNED_BY_THREAD(Table); */ + + Assert(Table->Size); + umm HashValue = Hash(&Node->Element) % Table->Size; + window_layout_linked_list_node **Bucket = Table->Elements + HashValue; + while (*Bucket) + { + /* Assert(!AreEqual(*Bucket, Node)); */ + Bucket = &(*Bucket)->Next; + } + *Bucket = Node; + return &Bucket[0]->Element; +} + +link_internal window_layout* +Insert(window_layout Element, window_layout_hashtable *Table, memory_arena *Memory) +{ + /* ENSURE_OWNED_BY_THREAD(Table); */ + + window_layout_linked_list_node *Bucket = Allocate_window_layout_linked_list_node(Memory); + Bucket->Element = Element; + Insert(Bucket, Table); + return &Bucket->Element; +} + +link_internal window_layout* +Upsert(window_layout Element, window_layout_hashtable *Table, memory_arena *Memory) +{ + umm HashValue = Hash(&Element) % Table->Size; + window_layout_linked_list_node **Bucket = Table->Elements + HashValue; + while (*Bucket) + { + if (AreEqual(&Bucket[0]->Element, &Element)) { break; } + Bucket = &(*Bucket)->Next; + } + + if (*Bucket) + { + Bucket[0]->Element = Element; + } + else + { + Insert(Element, Table, Memory); + } + + return &Bucket[0]->Element; +} + +// +// Iterator impl. +// + +struct window_layout_hashtable_iterator +{ + umm HashIndex; + window_layout_hashtable *Table; + window_layout_linked_list_node *Node; +}; + +link_internal window_layout_hashtable_iterator +operator++( window_layout_hashtable_iterator &Iterator ) +{ + if (Iterator.Node) + { + Iterator.Node = Iterator.Node->Next; + } + else + { + Assert (Iterator.HashIndex < Iterator.Table->Size ); + Iterator.Node = Iterator.Table->Elements[++Iterator.HashIndex]; + } + + return Iterator; +} + +link_internal b32 +operator<( window_layout_hashtable_iterator I0, window_layout_hashtable_iterator I1) +{ + b32 Result = I0.HashIndex < I1.HashIndex; + return Result; +} + +link_inline window_layout_hashtable_iterator +ZerothIndex(window_layout_hashtable *Hashtable) +{ + window_layout_hashtable_iterator Iterator = {}; + Iterator.Table = Hashtable; + Iterator.Node = Hashtable->Elements[0]; + return Iterator; +} + +link_inline window_layout_hashtable_iterator +AtElements(window_layout_hashtable *Hashtable) +{ + window_layout_hashtable_iterator Result = { Hashtable->Size, 0, 0 }; + return Result; +} + +link_inline window_layout * +GetPtr(window_layout_hashtable *Hashtable, window_layout_hashtable_iterator Iterator) +{ + window_layout *Result = {}; + if (Iterator.Node) + { + Result = &Iterator.Node->Element; + } + return Result; +} + diff --git a/generated/hashtable_struct_ui_toggle.h b/generated/hashtable_struct_ui_toggle.h index 58a8200aa..7fde3db92 100644 --- a/generated/hashtable_struct_ui_toggle.h +++ b/generated/hashtable_struct_ui_toggle.h @@ -1,4 +1,4 @@ -// external/bonsai_stdlib/src/ui/ui.h:193:0 +// external/bonsai_stdlib/src/ui/ui.h:217:0 struct ui_toggle_linked_list_node { diff --git a/generated/hashtable_struct_window_layout.h b/generated/hashtable_struct_window_layout.h new file mode 100644 index 000000000..7d67898c1 --- /dev/null +++ b/generated/hashtable_struct_window_layout.h @@ -0,0 +1,15 @@ +// external/bonsai_stdlib/src/ui/ui.h:132:0 + +struct window_layout_linked_list_node +{ + window_layout Element; + window_layout_linked_list_node *Next; +}; + +struct window_layout_hashtable +{ + umm Size; + window_layout_linked_list_node **Elements; + /* OWNED_BY_THREAD_MEMBER() */ +}; + diff --git a/generated/hashtable_voxel_synth_tile.h b/generated/hashtable_voxel_synth_tile.h index 301ed2b98..7822c0c6c 100644 --- a/generated/hashtable_voxel_synth_tile.h +++ b/generated/hashtable_voxel_synth_tile.h @@ -1,4 +1,4 @@ -// src/engine/voxel_synthesis.h:175:0 +// src/engine/voxel_synthesis.h:158:0 struct voxel_synth_tile_linked_list_node { diff --git a/generated/maybe_asset_id.h b/generated/maybe_asset_id.h index 6a3413524..c76c8b422 100644 --- a/generated/maybe_asset_id.h +++ b/generated/maybe_asset_id.h @@ -1,4 +1,4 @@ -// src/engine/asset.h:152:0 +// src/engine/asset.h:153:0 struct maybe_asset_id { diff --git a/generated/maybe_asset_ptr.h b/generated/maybe_asset_ptr.h index 80e84007a..d20fdc8f2 100644 --- a/generated/maybe_asset_ptr.h +++ b/generated/maybe_asset_ptr.h @@ -1,4 +1,4 @@ -// src/engine/asset.h:183:0 +// src/engine/asset.h:197:0 struct maybe_asset_ptr { diff --git a/generated/maybe_chunk_data.h b/generated/maybe_chunk_data.h new file mode 100644 index 000000000..f8718b562 --- /dev/null +++ b/generated/maybe_chunk_data.h @@ -0,0 +1,8 @@ +// src/engine/world_chunk.h:201:0 + +struct maybe_chunk_data +{ + maybe_tag Tag; + chunk_data Value; +}; + diff --git a/generated/maybe_model_buffer.h b/generated/maybe_model_buffer.h index 88a454e32..6936193b4 100644 --- a/generated/maybe_model_buffer.h +++ b/generated/maybe_model_buffer.h @@ -1,4 +1,4 @@ -// src/engine/model.h:93:0 +// src/engine/model.h:94:0 struct maybe_model_buffer { diff --git a/generated/maybe_standing_spot.h b/generated/maybe_standing_spot.h index 2a685d51e..5c66e849b 100644 --- a/generated/maybe_standing_spot.h +++ b/generated/maybe_standing_spot.h @@ -1,4 +1,4 @@ -// src/engine/world_chunk.h:473:0 +// src/engine/world_chunk.h:459:0 struct maybe_standing_spot { diff --git a/generated/maybe_ui_toggle.h b/generated/maybe_ui_toggle.h index 06a31796b..ff5dd8c17 100644 --- a/generated/maybe_ui_toggle.h +++ b/generated/maybe_ui_toggle.h @@ -1,4 +1,4 @@ -// external/bonsai_stdlib/src/ui/ui.h:187:0 +// external/bonsai_stdlib/src/ui/ui.h:211:0 struct maybe_ui_toggle { diff --git a/generated/maybe_ui_toggle_ptr.h b/generated/maybe_ui_toggle_ptr.h index abab3b00e..b0f462dd8 100644 --- a/generated/maybe_ui_toggle_ptr.h +++ b/generated/maybe_ui_toggle_ptr.h @@ -1,4 +1,4 @@ -// external/bonsai_stdlib/src/ui/ui.h:190:0 +// external/bonsai_stdlib/src/ui/ui.h:214:0 struct maybe_ui_toggle_ptr { diff --git a/generated/maybe_v3.h b/generated/maybe_v3.h new file mode 100644 index 000000000..6cf67bf8c --- /dev/null +++ b/generated/maybe_v3.h @@ -0,0 +1,8 @@ +// external/bonsai_stdlib/src/vector.h:1117:0 + +struct maybe_v3 +{ + maybe_tag Tag; + v3 Value; +}; + diff --git a/generated/maybe_v3i.h b/generated/maybe_v3i.h new file mode 100644 index 000000000..4c5d0610f --- /dev/null +++ b/generated/maybe_v3i.h @@ -0,0 +1,8 @@ +// external/bonsai_stdlib/src/vector.h:1119:0 + +struct maybe_v3i +{ + maybe_tag Tag; + v3i Value; +}; + diff --git a/generated/maybe_window_layout.h b/generated/maybe_window_layout.h new file mode 100644 index 000000000..9b29b69e2 --- /dev/null +++ b/generated/maybe_window_layout.h @@ -0,0 +1,8 @@ +// external/bonsai_stdlib/src/ui/ui.h:126:0 + +struct maybe_window_layout +{ + maybe_tag Tag; + window_layout Value; +}; + diff --git a/generated/maybe_window_layout_ptr.h b/generated/maybe_window_layout_ptr.h new file mode 100644 index 000000000..47d9625ab --- /dev/null +++ b/generated/maybe_window_layout_ptr.h @@ -0,0 +1,8 @@ +// external/bonsai_stdlib/src/ui/ui.h:129:0 + +struct maybe_window_layout_ptr +{ + maybe_tag Tag; + window_layout_ptr Value; +}; + diff --git a/generated/mesh_allocator_untextured_3d_geometry_buffer_heap_allocator_190647831.h b/generated/mesh_allocator_untextured_3d_geometry_buffer_heap_allocator_190647831.h index 5c27b2da7..6dd4524b2 100644 --- a/generated/mesh_allocator_untextured_3d_geometry_buffer_heap_allocator_190647831.h +++ b/generated/mesh_allocator_untextured_3d_geometry_buffer_heap_allocator_190647831.h @@ -1,25 +1,37 @@ -// src/engine/mesh.cpp:35:0 +// src/engine/mesh.cpp:47:0 link_internal void -AllocateMesh( untextured_3d_geometry_buffer *Mesh, u32 NumVerts, heap_allocator *Memory) +AllocateMesh( untextured_3d_geometry_buffer *Mesh, data_type Type, u32 NumVerts, heap_allocator *Memory) { - Mesh->Verts = HeapAlloc(v3, Memory, NumVerts, CACHE_LINE_SIZE, False); - - Mesh->Normals = HeapAlloc(v3, Memory, NumVerts, CACHE_LINE_SIZE, False); - - Mesh->Mat = HeapAlloc(vertex_material, Memory, NumVerts, CACHE_LINE_SIZE, False); - - + switch (Type) + { + InvalidCase(DataType_Undefinded); + + case DataType_v3: + { + Mesh->Verts = HeapAlloc(v3, Memory, NumVerts, CACHE_LINE_SIZE, False); + Mesh->Normals = HeapAlloc(v3, Memory, NumVerts, CACHE_LINE_SIZE, False); + Mesh->Mat = HeapAlloc(matl, Memory, NumVerts, CACHE_LINE_SIZE, False); + } break; + + case DataType_v3_u8: + { + Mesh->Verts = HeapAlloc(v3_u8, Memory, NumVerts, CACHE_LINE_SIZE, False); + Mesh->Normals = HeapAlloc(v3_u8, Memory, NumVerts, CACHE_LINE_SIZE, False); + Mesh->Mat = HeapAlloc(matl, Memory, NumVerts, CACHE_LINE_SIZE, False); + } break; + } Mesh->End = NumVerts; Mesh->At = 0; + Mesh->Type = Type; } link_internal untextured_3d_geometry_buffer* -Allocate_untextured_3d_geometry_buffer( heap_allocator* Allocator, u32 NumVerts) +Allocate_untextured_3d_geometry_buffer( heap_allocator* Allocator, data_type Type, u32 NumVerts) { untextured_3d_geometry_buffer *Result = HeapAlloc(untextured_3d_geometry_buffer, Allocator, 1, CACHE_LINE_SIZE, False); - AllocateMesh(Result, NumVerts, Allocator); + AllocateMesh(Result, Type, NumVerts, Allocator); return Result; } diff --git a/generated/mesh_allocator_untextured_3d_geometry_buffer_memory_arena_372399955.h b/generated/mesh_allocator_untextured_3d_geometry_buffer_memory_arena_372399955.h index fcefef667..fa3fd557c 100644 --- a/generated/mesh_allocator_untextured_3d_geometry_buffer_memory_arena_372399955.h +++ b/generated/mesh_allocator_untextured_3d_geometry_buffer_memory_arena_372399955.h @@ -1,25 +1,37 @@ -// src/engine/mesh.cpp:32:0 +// src/engine/mesh.cpp:44:0 link_internal void -AllocateMesh( untextured_3d_geometry_buffer *Mesh, u32 NumVerts, memory_arena *Memory) +AllocateMesh( untextured_3d_geometry_buffer *Mesh, data_type Type, u32 NumVerts, memory_arena *Memory) { - Mesh->Verts = AllocateAlignedProtection(v3, Memory, NumVerts, CACHE_LINE_SIZE, False); - - Mesh->Normals = AllocateAlignedProtection(v3, Memory, NumVerts, CACHE_LINE_SIZE, False); - - Mesh->Mat = AllocateAlignedProtection(vertex_material, Memory, NumVerts, CACHE_LINE_SIZE, False); - - + switch (Type) + { + InvalidCase(DataType_Undefinded); + + case DataType_v3: + { + Mesh->Verts = AllocateAlignedProtection(v3, Memory, NumVerts, CACHE_LINE_SIZE, False); + Mesh->Normals = AllocateAlignedProtection(v3, Memory, NumVerts, CACHE_LINE_SIZE, False); + Mesh->Mat = AllocateAlignedProtection(matl, Memory, NumVerts, CACHE_LINE_SIZE, False); + } break; + + case DataType_v3_u8: + { + Mesh->Verts = AllocateAlignedProtection(v3_u8, Memory, NumVerts, CACHE_LINE_SIZE, False); + Mesh->Normals = AllocateAlignedProtection(v3_u8, Memory, NumVerts, CACHE_LINE_SIZE, False); + Mesh->Mat = AllocateAlignedProtection(matl, Memory, NumVerts, CACHE_LINE_SIZE, False); + } break; + } Mesh->End = NumVerts; Mesh->At = 0; + Mesh->Type = Type; } link_internal untextured_3d_geometry_buffer* -Allocate_untextured_3d_geometry_buffer( memory_arena* Allocator, u32 NumVerts) +Allocate_untextured_3d_geometry_buffer( memory_arena* Allocator, data_type Type, u32 NumVerts) { untextured_3d_geometry_buffer *Result = AllocateAlignedProtection(untextured_3d_geometry_buffer, Allocator, 1, CACHE_LINE_SIZE, False); - AllocateMesh(Result, NumVerts, Allocator); + AllocateMesh(Result, Type, NumVerts, Allocator); return Result; } diff --git a/generated/mesh_allocator_world_chunk_geometry_buffer_memory_arena_821677495.h b/generated/mesh_allocator_world_chunk_geometry_buffer_memory_arena_821677495.h deleted file mode 100644 index f9bcdaad8..000000000 --- a/generated/mesh_allocator_world_chunk_geometry_buffer_memory_arena_821677495.h +++ /dev/null @@ -1,26 +0,0 @@ -// src/engine/mesh.cpp:38:0 - -link_internal void -AllocateMesh( world_chunk_geometry_buffer *Mesh, u32 NumVerts, memory_arena *Memory) -{ - Mesh->Verts = AllocateAlignedProtection(v3_u8, Memory, NumVerts, CACHE_LINE_SIZE, False); - - Mesh->Normals = AllocateAlignedProtection(v3_u8, Memory, NumVerts, CACHE_LINE_SIZE, False); - - Mesh->Mat = AllocateAlignedProtection(vertex_material, Memory, NumVerts, CACHE_LINE_SIZE, False); - - - - Mesh->End = NumVerts; - Mesh->At = 0; -} - -link_internal world_chunk_geometry_buffer* -Allocate_world_chunk_geometry_buffer( memory_arena* Allocator, u32 NumVerts) -{ - world_chunk_geometry_buffer *Result = AllocateAlignedProtection(world_chunk_geometry_buffer, Allocator, 1, CACHE_LINE_SIZE, False); - AllocateMesh(Result, NumVerts, Allocator); - return Result; -} - - diff --git a/generated/mesh_buffering_functions_untextured_3d_geometry_buffer_v3.h b/generated/mesh_buffering_functions_untextured_3d_geometry_buffer_v3.h deleted file mode 100644 index 8989ee3ca..000000000 --- a/generated/mesh_buffering_functions_untextured_3d_geometry_buffer_v3.h +++ /dev/null @@ -1,307 +0,0 @@ -// src/engine/mesh.h:504:0 - - -// -// Rotate, Scale and Offset -// - -link_inline void -BufferVertsDirect( - v3 *DestVerts, v3 *DestNormals, vertex_material *DestMats, - u32 NumVerts, - v3 *SrcVerts, v3 *SrcNormals, vertex_material *SrcMats, - v3 Offset, - v3 Scale, - Quaternion Rot ) -{ - TIMED_FUNCTION(); - - __m128 mmScale = _mm_set_ps(0, Scale.z, Scale.y, Scale.x); - __m128 mmOffset = _mm_set_ps(0, Offset.z, Offset.y, Offset.x); - - Assert(NumVerts % 3 == 0); - - MemCopy((u8*)SrcMats, (u8*)DestMats, sizeof(*SrcMats)*NumVerts ); - - /* v3 HalfOffset = Offset*0.5f; */ - for ( u32 VertIndex = 0; - VertIndex < NumVerts; - VertIndex += 3 ) - { - { - auto N0 = Rotate(SrcNormals[VertIndex + 0], Rot); - auto N1 = Rotate(SrcNormals[VertIndex + 1], Rot); - auto N2 = Rotate(SrcNormals[VertIndex + 2], Rot); - - // NOTE(Jesse): This _hopefully_ gets inlined. Should figure out a - // way of asserting that it does, or forcing it to. The functions - // are overloads, but the compiler _should_ be able to figure out - // they can be inlined trivially.. - PackAndStoreNormal(DestNormals+0, N0); - PackAndStoreNormal(DestNormals+1, N1); - PackAndStoreNormal(DestNormals+2, N2); - - DestNormals += 3; - } - { - v3 VertSrc0 = Rotate(SrcVerts[VertIndex + 0], Rot); - v3 VertSrc1 = Rotate(SrcVerts[VertIndex + 1], Rot); - v3 VertSrc2 = Rotate(SrcVerts[VertIndex + 2], Rot); - - f32_reg Vert0; - f32_reg Vert1; - f32_reg Vert2; - - Vert0.Sse = _mm_set_ps(0, VertSrc0.z, VertSrc0.y, VertSrc0.x); - Vert1.Sse = _mm_set_ps(0, VertSrc1.z, VertSrc1.y, VertSrc1.x); - Vert2.Sse = _mm_set_ps(0, VertSrc2.z, VertSrc2.y, VertSrc2.x); - - Vert0.Sse = _mm_add_ps( _mm_mul_ps(Vert0.Sse, mmScale), mmOffset); - Vert1.Sse = _mm_add_ps( _mm_mul_ps(Vert1.Sse, mmScale), mmOffset); - Vert2.Sse = _mm_add_ps( _mm_mul_ps(Vert2.Sse, mmScale), mmOffset); - - v3 Result0 = {{ f32(Vert0.F[0]), f32(Vert0.F[1]), f32(Vert0.F[2])}}; - v3 Result1 = {{ f32(Vert1.F[0]), f32(Vert1.F[1]), f32(Vert1.F[2])}}; - v3 Result2 = {{ f32(Vert2.F[0]), f32(Vert2.F[1]), f32(Vert2.F[2])}}; - - DestVerts[0] = Result0; - DestVerts[1] = Result1; - DestVerts[2] = Result2; - - DestVerts += 3; - } - - } -} - -// -// Scale and Offset -// - -link_inline void -BufferVertsDirect( - v3 *DestVerts, v3 *DestNormals, vertex_material *DestMats, - u32 NumVerts, - v3 *SrcVerts, v3 *SrcNormals, vertex_material *SrcMats, - v3 Offset, - v3 Scale -) -{ - TIMED_FUNCTION(); - - __m128 mmScale = _mm_set_ps(0, Scale.z, Scale.y, Scale.x); - __m128 mmOffset = _mm_set_ps(0, Offset.z, Offset.y, Offset.x); - - Assert(NumVerts % 3 == 0); - - /* MemCopy((u8*)SrcNormals, (u8*)DestNormals, sizeof(*SrcNormals)*NumVerts ); */ - MemCopy((u8*)SrcMats, (u8*)DestMats, sizeof(*SrcMats)*NumVerts ); - - for ( u32 VertIndex = 0; - VertIndex < NumVerts; - VertIndex += 3 ) - { - { - auto N0 = SrcNormals[VertIndex + 0]; - auto N1 = SrcNormals[VertIndex + 1]; - auto N2 = SrcNormals[VertIndex + 2]; - PackAndStoreNormal(DestNormals+0, N0); - PackAndStoreNormal(DestNormals+1, N1); - PackAndStoreNormal(DestNormals+2, N2); - DestNormals += 3; - } - - v3 VertSrc0 = SrcVerts[VertIndex + 0]; - v3 VertSrc1 = SrcVerts[VertIndex + 1]; - v3 VertSrc2 = SrcVerts[VertIndex + 2]; - - f32_reg Vert0; - f32_reg Vert1; - f32_reg Vert2; - - Vert0.Sse = _mm_set_ps(0, VertSrc0.z, VertSrc0.y, VertSrc0.x); - Vert1.Sse = _mm_set_ps(0, VertSrc1.z, VertSrc1.y, VertSrc1.x); - Vert2.Sse = _mm_set_ps(0, VertSrc2.z, VertSrc2.y, VertSrc2.x); - - Vert0.Sse = _mm_add_ps( _mm_mul_ps(Vert0.Sse, mmScale), mmOffset); - Vert1.Sse = _mm_add_ps( _mm_mul_ps(Vert1.Sse, mmScale), mmOffset); - Vert2.Sse = _mm_add_ps( _mm_mul_ps(Vert2.Sse, mmScale), mmOffset); - - v3 Result0 = {{ f32(Vert0.F[0]), f32(Vert0.F[1]), f32(Vert0.F[2]) }}; - v3 Result1 = {{ f32(Vert1.F[0]), f32(Vert1.F[1]), f32(Vert1.F[2]) }}; - v3 Result2 = {{ f32(Vert2.F[0]), f32(Vert2.F[1]), f32(Vert2.F[2]) }}; - - DestVerts[0] = Result0; - DestVerts[1] = Result1; - DestVerts[2] = Result2; - - DestVerts += 3; - } -} - - -// -// Untransformed -// - -link_inline void -BufferVertsDirect( - v3 *DestVerts, v3 *DestNormals, vertex_material *DestMats, - u32 NumVerts, - v3 *Positions, v3 *Normals, vertex_material *Mats -) -{ - TIMED_FUNCTION(); - MemCopy((u8*)Positions, (u8*)DestVerts, sizeof(*Positions)*NumVerts ); - /* MemCopy((u8*)Normals, (u8*)DestNormals, sizeof(*Normals)*NumVerts ); */ - MemCopy((u8*)Mats, (u8*)DestMats, sizeof(*Mats)*NumVerts ); - - // NOTE(Jesse): Hopefully gets vectorized.. Can't do 4x because triangles - // are 3 elements.. Could do 12 with a cleanup pass.. but meh - for ( u32 VertIndex = 0; - VertIndex < NumVerts; - VertIndex += 3 ) - { - auto N0 = Normals[VertIndex + 0]; - auto N1 = Normals[VertIndex + 1]; - auto N2 = Normals[VertIndex + 2]; - PackAndStoreNormal(DestNormals+0, N0); - PackAndStoreNormal(DestNormals+1, N1); - PackAndStoreNormal(DestNormals+2, N2); - DestNormals += 3; - } -} - - - -// -// Rotate, Scale and Offset -// - -inline void -BufferVertsChecked( - untextured_3d_geometry_buffer *Dest, - u32 NumVerts, - v3 *VertsPositions, v3 *Normals, vertex_material *Mats, - v3 Offset, - v3 Scale, - Quaternion Rot -) -{ - TIMED_FUNCTION(); - if (BufferHasRoomFor(Dest, NumVerts)) - { - BufferVertsDirect(Dest->Verts + Dest->At, - Dest->Normals + Dest->At, - Dest->Mat + Dest->At, - NumVerts, - VertsPositions, Normals, Mats, - Offset, Scale, Rot); - - Dest->At += NumVerts; - } - else - { - // NOTE(Jesse): Supress spamming errors to the console after the first one. - if (BufferIsMarkedForGrowth(Dest) == False) { SoftError("Ran out of memory pushing %d Verts onto Mesh with %d/%d used", NumVerts, Dest->At, Dest->End-1); } - MarkBufferForGrowth(Dest, NumVerts); - } -} - -// -// Scale and Offset -// - -inline void -BufferVertsChecked( - untextured_3d_geometry_buffer *Dest, - u32 NumVerts, - v3 *VertsPositions, v3 *Normals, vertex_material *Mats, - v3 Offset, - v3 Scale -) -{ - TIMED_FUNCTION(); - if (BufferHasRoomFor(Dest, NumVerts)) - { - BufferVertsDirect(Dest->Verts + Dest->At, - Dest->Normals + Dest->At, - Dest->Mat + Dest->At, - NumVerts, - VertsPositions, Normals, Mats, - Offset, Scale); - - Dest->At += NumVerts; - } - else - { - if (BufferIsMarkedForGrowth(Dest) == False) { SoftError("Ran out of memory pushing %d Verts onto Mesh with %d/%d used", NumVerts, Dest->At, Dest->End-1); } - MarkBufferForGrowth(Dest, NumVerts); - } -} - -// -// Scale and Offset -// - -inline void -BufferVertsChecked( - untextured_3d_geometry_buffer* Src, - untextured_3d_geometry_buffer* Dest, - v3 Offset = V3(0), - v3 Scale = V3(1) -) -{ - TIMED_FUNCTION(); - - umm NumVerts = Src->End - Src->At; - if (Dest->At + Src->At <= Dest->End) - { - - BufferVertsDirect(Dest->Verts + Dest->At, - Dest->Normals + Dest->At, - Dest->Mat + Dest->At, - Src->At, - Src->Verts, Src->Normals, Src->Mat, - Offset, Scale); - - Dest->At += Src->At; - } - else - { - if (BufferIsMarkedForGrowth(Dest) == False) { SoftError("Ran out of memory pushing %d Verts onto Mesh with %d/%d used", NumVerts, Dest->At, Dest->End-1); } - MarkBufferForGrowth(Dest, Src->At); - } -} - - -// -// Untransformed -// - -inline void -BufferVertsChecked( - untextured_3d_geometry_buffer *Dest, - u32 NumVerts, - v3 *VertsPositions, v3 *Normals, vertex_material *Mats -) -{ - TIMED_FUNCTION(); - if (BufferHasRoomFor(Dest, NumVerts)) - { - BufferVertsDirect(Dest->Verts + Dest->At, - Dest->Normals + Dest->At, - Dest->Mat + Dest->At, - NumVerts, - VertsPositions, Normals, Mats); - - Dest->At += NumVerts; - } - else - { - if (BufferIsMarkedForGrowth(Dest) == False) { SoftError("Ran out of memory pushing %d Verts onto Mesh with %d/%d used", NumVerts, Dest->At, Dest->End-1); } - MarkBufferForGrowth(Dest, NumVerts); - } -} - - diff --git a/generated/mesh_buffering_functions_world_chunk_geometry_buffer_v3_u8.h b/generated/mesh_buffering_functions_world_chunk_geometry_buffer_v3_u8.h deleted file mode 100644 index d17cd2a07..000000000 --- a/generated/mesh_buffering_functions_world_chunk_geometry_buffer_v3_u8.h +++ /dev/null @@ -1,307 +0,0 @@ -// src/engine/mesh.h:507:0 - - -// -// Rotate, Scale and Offset -// - -link_inline void -BufferVertsDirect( - v3_u8 *DestVerts, v3_u8 *DestNormals, vertex_material *DestMats, - u32 NumVerts, - v3_u8 *SrcVerts, v3 *SrcNormals, vertex_material *SrcMats, - v3 Offset, - v3 Scale, - Quaternion Rot ) -{ - TIMED_FUNCTION(); - - __m128 mmScale = _mm_set_ps(0, Scale.z, Scale.y, Scale.x); - __m128 mmOffset = _mm_set_ps(0, Offset.z, Offset.y, Offset.x); - - Assert(NumVerts % 3 == 0); - - MemCopy((u8*)SrcMats, (u8*)DestMats, sizeof(*SrcMats)*NumVerts ); - - /* v3 HalfOffset = Offset*0.5f; */ - for ( u32 VertIndex = 0; - VertIndex < NumVerts; - VertIndex += 3 ) - { - { - auto N0 = Rotate(SrcNormals[VertIndex + 0], Rot); - auto N1 = Rotate(SrcNormals[VertIndex + 1], Rot); - auto N2 = Rotate(SrcNormals[VertIndex + 2], Rot); - - // NOTE(Jesse): This _hopefully_ gets inlined. Should figure out a - // way of asserting that it does, or forcing it to. The functions - // are overloads, but the compiler _should_ be able to figure out - // they can be inlined trivially.. - PackAndStoreNormal(DestNormals+0, N0); - PackAndStoreNormal(DestNormals+1, N1); - PackAndStoreNormal(DestNormals+2, N2); - - DestNormals += 3; - } - { - v3_u8 VertSrc0 = Rotate(SrcVerts[VertIndex + 0], Rot); - v3_u8 VertSrc1 = Rotate(SrcVerts[VertIndex + 1], Rot); - v3_u8 VertSrc2 = Rotate(SrcVerts[VertIndex + 2], Rot); - - f32_reg Vert0; - f32_reg Vert1; - f32_reg Vert2; - - Vert0.Sse = _mm_set_ps(0, VertSrc0.z, VertSrc0.y, VertSrc0.x); - Vert1.Sse = _mm_set_ps(0, VertSrc1.z, VertSrc1.y, VertSrc1.x); - Vert2.Sse = _mm_set_ps(0, VertSrc2.z, VertSrc2.y, VertSrc2.x); - - Vert0.Sse = _mm_add_ps( _mm_mul_ps(Vert0.Sse, mmScale), mmOffset); - Vert1.Sse = _mm_add_ps( _mm_mul_ps(Vert1.Sse, mmScale), mmOffset); - Vert2.Sse = _mm_add_ps( _mm_mul_ps(Vert2.Sse, mmScale), mmOffset); - - v3_u8 Result0 = {{ u8(Vert0.F[0]), u8(Vert0.F[1]), u8(Vert0.F[2])}}; - v3_u8 Result1 = {{ u8(Vert1.F[0]), u8(Vert1.F[1]), u8(Vert1.F[2])}}; - v3_u8 Result2 = {{ u8(Vert2.F[0]), u8(Vert2.F[1]), u8(Vert2.F[2])}}; - - DestVerts[0] = Result0; - DestVerts[1] = Result1; - DestVerts[2] = Result2; - - DestVerts += 3; - } - - } -} - -// -// Scale and Offset -// - -link_inline void -BufferVertsDirect( - v3_u8 *DestVerts, v3_u8 *DestNormals, vertex_material *DestMats, - u32 NumVerts, - v3_u8 *SrcVerts, v3 *SrcNormals, vertex_material *SrcMats, - v3 Offset, - v3 Scale -) -{ - TIMED_FUNCTION(); - - __m128 mmScale = _mm_set_ps(0, Scale.z, Scale.y, Scale.x); - __m128 mmOffset = _mm_set_ps(0, Offset.z, Offset.y, Offset.x); - - Assert(NumVerts % 3 == 0); - - /* MemCopy((u8*)SrcNormals, (u8*)DestNormals, sizeof(*SrcNormals)*NumVerts ); */ - MemCopy((u8*)SrcMats, (u8*)DestMats, sizeof(*SrcMats)*NumVerts ); - - for ( u32 VertIndex = 0; - VertIndex < NumVerts; - VertIndex += 3 ) - { - { - auto N0 = SrcNormals[VertIndex + 0]; - auto N1 = SrcNormals[VertIndex + 1]; - auto N2 = SrcNormals[VertIndex + 2]; - PackAndStoreNormal(DestNormals+0, N0); - PackAndStoreNormal(DestNormals+1, N1); - PackAndStoreNormal(DestNormals+2, N2); - DestNormals += 3; - } - - v3_u8 VertSrc0 = SrcVerts[VertIndex + 0]; - v3_u8 VertSrc1 = SrcVerts[VertIndex + 1]; - v3_u8 VertSrc2 = SrcVerts[VertIndex + 2]; - - f32_reg Vert0; - f32_reg Vert1; - f32_reg Vert2; - - Vert0.Sse = _mm_set_ps(0, VertSrc0.z, VertSrc0.y, VertSrc0.x); - Vert1.Sse = _mm_set_ps(0, VertSrc1.z, VertSrc1.y, VertSrc1.x); - Vert2.Sse = _mm_set_ps(0, VertSrc2.z, VertSrc2.y, VertSrc2.x); - - Vert0.Sse = _mm_add_ps( _mm_mul_ps(Vert0.Sse, mmScale), mmOffset); - Vert1.Sse = _mm_add_ps( _mm_mul_ps(Vert1.Sse, mmScale), mmOffset); - Vert2.Sse = _mm_add_ps( _mm_mul_ps(Vert2.Sse, mmScale), mmOffset); - - v3_u8 Result0 = {{ u8(Vert0.F[0]), u8(Vert0.F[1]), u8(Vert0.F[2]) }}; - v3_u8 Result1 = {{ u8(Vert1.F[0]), u8(Vert1.F[1]), u8(Vert1.F[2]) }}; - v3_u8 Result2 = {{ u8(Vert2.F[0]), u8(Vert2.F[1]), u8(Vert2.F[2]) }}; - - DestVerts[0] = Result0; - DestVerts[1] = Result1; - DestVerts[2] = Result2; - - DestVerts += 3; - } -} - - -// -// Untransformed -// - -link_inline void -BufferVertsDirect( - v3_u8 *DestVerts, v3_u8 *DestNormals, vertex_material *DestMats, - u32 NumVerts, - v3_u8 *Positions, v3 *Normals, vertex_material *Mats -) -{ - TIMED_FUNCTION(); - MemCopy((u8*)Positions, (u8*)DestVerts, sizeof(*Positions)*NumVerts ); - /* MemCopy((u8*)Normals, (u8*)DestNormals, sizeof(*Normals)*NumVerts ); */ - MemCopy((u8*)Mats, (u8*)DestMats, sizeof(*Mats)*NumVerts ); - - // NOTE(Jesse): Hopefully gets vectorized.. Can't do 4x because triangles - // are 3 elements.. Could do 12 with a cleanup pass.. but meh - for ( u32 VertIndex = 0; - VertIndex < NumVerts; - VertIndex += 3 ) - { - auto N0 = Normals[VertIndex + 0]; - auto N1 = Normals[VertIndex + 1]; - auto N2 = Normals[VertIndex + 2]; - PackAndStoreNormal(DestNormals+0, N0); - PackAndStoreNormal(DestNormals+1, N1); - PackAndStoreNormal(DestNormals+2, N2); - DestNormals += 3; - } -} - - - -// -// Rotate, Scale and Offset -// - -inline void -BufferVertsChecked( - world_chunk_geometry_buffer *Dest, - u32 NumVerts, - v3_u8 *VertsPositions, v3 *Normals, vertex_material *Mats, - v3 Offset, - v3 Scale, - Quaternion Rot -) -{ - TIMED_FUNCTION(); - if (BufferHasRoomFor(Dest, NumVerts)) - { - BufferVertsDirect(Dest->Verts + Dest->At, - Dest->Normals + Dest->At, - Dest->Mat + Dest->At, - NumVerts, - VertsPositions, Normals, Mats, - Offset, Scale, Rot); - - Dest->At += NumVerts; - } - else - { - // NOTE(Jesse): Supress spamming errors to the console after the first one. - if (BufferIsMarkedForGrowth(Dest) == False) { SoftError("Ran out of memory pushing %d Verts onto Mesh with %d/%d used", NumVerts, Dest->At, Dest->End-1); } - MarkBufferForGrowth(Dest, NumVerts); - } -} - -// -// Scale and Offset -// - -inline void -BufferVertsChecked( - world_chunk_geometry_buffer *Dest, - u32 NumVerts, - v3_u8 *VertsPositions, v3 *Normals, vertex_material *Mats, - v3 Offset, - v3 Scale -) -{ - TIMED_FUNCTION(); - if (BufferHasRoomFor(Dest, NumVerts)) - { - BufferVertsDirect(Dest->Verts + Dest->At, - Dest->Normals + Dest->At, - Dest->Mat + Dest->At, - NumVerts, - VertsPositions, Normals, Mats, - Offset, Scale); - - Dest->At += NumVerts; - } - else - { - if (BufferIsMarkedForGrowth(Dest) == False) { SoftError("Ran out of memory pushing %d Verts onto Mesh with %d/%d used", NumVerts, Dest->At, Dest->End-1); } - MarkBufferForGrowth(Dest, NumVerts); - } -} - -// -// Scale and Offset -// - -inline void -BufferVertsChecked( - world_chunk_geometry_buffer* Src, - world_chunk_geometry_buffer* Dest, - v3 Offset = V3(0), - v3 Scale = V3(1) -) -{ - TIMED_FUNCTION(); - - umm NumVerts = Src->End - Src->At; - if (Dest->At + Src->At <= Dest->End) - { - - BufferVertsDirect(Dest->Verts + Dest->At, - Dest->Normals + Dest->At, - Dest->Mat + Dest->At, - Src->At, - Src->Verts, Src->Normals, Src->Mat, - Offset, Scale); - - Dest->At += Src->At; - } - else - { - if (BufferIsMarkedForGrowth(Dest) == False) { SoftError("Ran out of memory pushing %d Verts onto Mesh with %d/%d used", NumVerts, Dest->At, Dest->End-1); } - MarkBufferForGrowth(Dest, Src->At); - } -} - - -// -// Untransformed -// - -inline void -BufferVertsChecked( - world_chunk_geometry_buffer *Dest, - u32 NumVerts, - v3_u8 *VertsPositions, v3 *Normals, vertex_material *Mats -) -{ - TIMED_FUNCTION(); - if (BufferHasRoomFor(Dest, NumVerts)) - { - BufferVertsDirect(Dest->Verts + Dest->At, - Dest->Normals + Dest->At, - Dest->Mat + Dest->At, - NumVerts, - VertsPositions, Normals, Mats); - - Dest->At += NumVerts; - } - else - { - if (BufferIsMarkedForGrowth(Dest) == False) { SoftError("Ran out of memory pushing %d Verts onto Mesh with %d/%d used", NumVerts, Dest->At, Dest->End-1); } - MarkBufferForGrowth(Dest, NumVerts); - } -} - - diff --git a/generated/push_render_command_work_queue_entry__bonsai_render_command.h b/generated/push_render_command_work_queue_entry__bonsai_render_command.h index 4d3865af4..ed3dd9e8a 100644 --- a/generated/push_render_command_work_queue_entry__bonsai_render_command.h +++ b/generated/push_render_command_work_queue_entry__bonsai_render_command.h @@ -78,17 +78,6 @@ PushBonsaiRenderCommandDeallocateWorldChunk( PushWorkQueueEntry(RenderQueue, &Work); } link_internal void -PushBonsaiRenderCommandReallocateWorldChunkBuffers( - work_queue *RenderQueue - , gpu_element_buffer_handles* Handles , world_chunk_geometry_buffer* Mesh -) -{ - work_queue_entry Work = WorkQueueEntry( - WorkQueueEntryBonsaiRenderCommand( BonsaiRenderCommandReallocateWorldChunkBuffers( Handles , Mesh ))); - - PushWorkQueueEntry(RenderQueue, &Work); -} -link_internal void PushBonsaiRenderCommandDoStuff( work_queue *RenderQueue , u32 Ignored = 0 diff --git a/generated/radio_button_group_for_bitfield_enum_level_editor_flags.h b/generated/radio_button_group_for_bitfield_enum_level_editor_flags.h index 640a0be1d..a5807a466 100644 --- a/generated/radio_button_group_for_bitfield_enum_level_editor_flags.h +++ b/generated/radio_button_group_for_bitfield_enum_level_editor_flags.h @@ -1,4 +1,4 @@ -// src/engine/editor.h:517:0 +// src/engine/editor.h:521:0 link_internal ui_toggle_button_group RadioButtonGroup_level_editor_flags( renderer_2d *Ui, diff --git a/generated/radio_button_group_for_bitfield_enum_ui_noise_type.h b/generated/radio_button_group_for_bitfield_enum_ui_noise_type.h index c02ae4c07..5e292c894 100644 --- a/generated/radio_button_group_for_bitfield_enum_ui_noise_type.h +++ b/generated/radio_button_group_for_bitfield_enum_ui_noise_type.h @@ -1,4 +1,4 @@ -// src/engine/editor.h:529:0 +// src/engine/editor.h:533:0 link_internal ui_toggle_button_group RadioButtonGroup_ui_noise_type( renderer_2d *Ui, diff --git a/generated/rectalinear_iteration_pattern_398799212.h b/generated/rectalinear_iteration_pattern_398799212.h index b3daef8a0..700a80a01 100644 --- a/generated/rectalinear_iteration_pattern_398799212.h +++ b/generated/rectalinear_iteration_pattern_398799212.h @@ -1,4 +1,4 @@ -// src/engine/world_chunk.cpp:4434:0 +// src/engine/world_update.cpp:579:0 DimIterator(x, y, z, UpdateDim) { diff --git a/generated/rectalinear_iteration_pattern_416827956.h b/generated/rectalinear_iteration_pattern_416827956.h index c53786b82..f2e09ff7c 100644 --- a/generated/rectalinear_iteration_pattern_416827956.h +++ b/generated/rectalinear_iteration_pattern_416827956.h @@ -1,4 +1,4 @@ -// src/engine/world_chunk.cpp:4605:0 +// src/engine/world_update.cpp:750:0 DimIterator(x, y, z, UpdateDim) { diff --git a/generated/rectalinear_iteration_pattern_428632106.h b/generated/rectalinear_iteration_pattern_428632106.h index caae7c61c..e2ec434c7 100644 --- a/generated/rectalinear_iteration_pattern_428632106.h +++ b/generated/rectalinear_iteration_pattern_428632106.h @@ -1,4 +1,4 @@ -// src/engine/world_chunk.cpp:4756:0 +// src/engine/world_update.cpp:901:0 DimIterator(x, y, z, UpdateDim) { diff --git a/generated/rectalinear_iteration_pattern_530902269.h b/generated/rectalinear_iteration_pattern_530902269.h index caf2b0f32..0f270c84c 100644 --- a/generated/rectalinear_iteration_pattern_530902269.h +++ b/generated/rectalinear_iteration_pattern_530902269.h @@ -1,4 +1,4 @@ -// src/engine/world_chunk.cpp:4553:0 +// src/engine/world_update.cpp:698:0 DimIterator(x, y, z, UpdateDim) { diff --git a/generated/rectalinear_iteration_pattern_583358156.h b/generated/rectalinear_iteration_pattern_583358156.h index a129a3fd6..22045c1b4 100644 --- a/generated/rectalinear_iteration_pattern_583358156.h +++ b/generated/rectalinear_iteration_pattern_583358156.h @@ -1,4 +1,4 @@ -// src/engine/world_chunk.cpp:4730:0 +// src/engine/world_update.cpp:875:0 DimIterator(x, y, z, UpdateDim) { diff --git a/generated/rectalinear_iteration_pattern_631222419.h b/generated/rectalinear_iteration_pattern_631222419.h index 337c6f005..ac9bd09c7 100644 --- a/generated/rectalinear_iteration_pattern_631222419.h +++ b/generated/rectalinear_iteration_pattern_631222419.h @@ -1,4 +1,4 @@ -// src/engine/world_chunk.cpp:4646:0 +// src/engine/world_update.cpp:791:0 DimIterator(x, y, z, UpdateDim) { diff --git a/generated/rectalinear_iteration_pattern_643608995.h b/generated/rectalinear_iteration_pattern_643608995.h index 10aee8406..b5116f47e 100644 --- a/generated/rectalinear_iteration_pattern_643608995.h +++ b/generated/rectalinear_iteration_pattern_643608995.h @@ -1,4 +1,4 @@ -// src/engine/world_chunk.cpp:4534:0 +// src/engine/world_update.cpp:679:0 DimIterator(x, y, z, UpdateDim) { diff --git a/generated/rectalinear_iteration_pattern_812652930.h b/generated/rectalinear_iteration_pattern_812652930.h index a33906543..20f932109 100644 --- a/generated/rectalinear_iteration_pattern_812652930.h +++ b/generated/rectalinear_iteration_pattern_812652930.h @@ -1,4 +1,4 @@ -// src/engine/world_chunk.cpp:4506:0 +// src/engine/world_update.cpp:651:0 DimIterator(x, y, z, UpdateDim) { diff --git a/generated/rectalinear_iteration_pattern_920026661.h b/generated/rectalinear_iteration_pattern_920026661.h index 535750144..9f53ecb65 100644 --- a/generated/rectalinear_iteration_pattern_920026661.h +++ b/generated/rectalinear_iteration_pattern_920026661.h @@ -1,4 +1,4 @@ -// src/engine/world_chunk.cpp:4454:0 +// src/engine/world_update.cpp:599:0 DimIterator(x, y, z, UpdateDim) { diff --git a/generated/rectalinear_iteration_pattern_992879728.h b/generated/rectalinear_iteration_pattern_992879728.h index 34dbadaf1..fdb50b66d 100644 --- a/generated/rectalinear_iteration_pattern_992879728.h +++ b/generated/rectalinear_iteration_pattern_992879728.h @@ -1,4 +1,4 @@ -// src/engine/world_chunk.cpp:4667:0 +// src/engine/world_update.cpp:812:0 DimIterator(x, y, z, UpdateDim) { diff --git a/generated/rectalinear_iteration_pattern_99934950.h b/generated/rectalinear_iteration_pattern_99934950.h index ae8647b8a..e985afe60 100644 --- a/generated/rectalinear_iteration_pattern_99934950.h +++ b/generated/rectalinear_iteration_pattern_99934950.h @@ -1,4 +1,4 @@ -// src/engine/world_chunk.cpp:4613:0 +// src/engine/world_update.cpp:758:0 DimIterator(x, y, z, UpdateDim) { diff --git a/generated/serdes_struct_bonsai_type_info.h b/generated/serdes_struct_bonsai_type_info.h index 4bfd5e8d6..855fa22ee 100644 --- a/generated/serdes_struct_bonsai_type_info.h +++ b/generated/serdes_struct_bonsai_type_info.h @@ -1,4 +1,4 @@ -// src/engine/serdes.cpp:407:0 +// src/engine/serdes.cpp:412:0 link_internal bonsai_type_info TypeInfo(bonsai_type_info *Ignored) diff --git a/generated/serdes_struct_bonsai_type_info_buffer.h b/generated/serdes_struct_bonsai_type_info_buffer.h index 53dfbb6ff..65206be25 100644 --- a/generated/serdes_struct_bonsai_type_info_buffer.h +++ b/generated/serdes_struct_bonsai_type_info_buffer.h @@ -1,4 +1,4 @@ -// src/engine/serdes.cpp:409:0 +// src/engine/serdes.cpp:414:0 link_internal bonsai_type_info TypeInfo(bonsai_type_info_buffer *Ignored) diff --git a/generated/serdes_struct_brush_layer.h b/generated/serdes_struct_brush_layer.h index 7ae00af71..cd71ac514 100644 --- a/generated/serdes_struct_brush_layer.h +++ b/generated/serdes_struct_brush_layer.h @@ -1,4 +1,4 @@ -// src/engine/serdes.cpp:512:0 +// src/engine/serdes.cpp:517:0 link_internal bonsai_type_info TypeInfo(brush_layer *Ignored) diff --git a/generated/serdes_struct_brush_settings.h b/generated/serdes_struct_brush_settings.h index 5361e2cc8..78e35c7af 100644 --- a/generated/serdes_struct_brush_settings.h +++ b/generated/serdes_struct_brush_settings.h @@ -1,4 +1,4 @@ -// src/engine/serdes.cpp:509:0 +// src/engine/serdes.cpp:514:0 link_internal bonsai_type_info TypeInfo(brush_settings *Ignored) diff --git a/generated/serdes_struct_brush_settings_0.h b/generated/serdes_struct_brush_settings_0.h index 01c80b856..a52f239eb 100644 --- a/generated/serdes_struct_brush_settings_0.h +++ b/generated/serdes_struct_brush_settings_0.h @@ -1,4 +1,4 @@ -// src/engine/serdes.cpp:505:0 +// src/engine/serdes.cpp:510:0 link_internal bonsai_type_info TypeInfo(brush_settings_0 *Ignored) diff --git a/generated/serdes_struct_brush_settings_1.h b/generated/serdes_struct_brush_settings_1.h index 3af103860..acbbe67bc 100644 --- a/generated/serdes_struct_brush_settings_1.h +++ b/generated/serdes_struct_brush_settings_1.h @@ -1,4 +1,4 @@ -// src/engine/serdes.cpp:507:0 +// src/engine/serdes.cpp:512:0 link_internal bonsai_type_info TypeInfo(brush_settings_1 *Ignored) diff --git a/generated/serdes_struct_camera.h b/generated/serdes_struct_camera.h index 0c6614e02..b8939210b 100644 --- a/generated/serdes_struct_camera.h +++ b/generated/serdes_struct_camera.h @@ -1,4 +1,4 @@ -// src/engine/serdes.cpp:115:0 +// src/engine/serdes.cpp:118:0 link_internal bonsai_type_info TypeInfo(camera *Ignored) diff --git a/generated/serdes_struct_entity_0.h b/generated/serdes_struct_entity_0.h index 236df757f..4777aa813 100644 --- a/generated/serdes_struct_entity_0.h +++ b/generated/serdes_struct_entity_0.h @@ -1,4 +1,4 @@ -// src/engine/serdes.cpp:328:0 +// src/engine/serdes.cpp:333:0 link_internal bonsai_type_info TypeInfo(entity_0 *Ignored) diff --git a/generated/serdes_struct_entity_1.h b/generated/serdes_struct_entity_1.h index a1bb89ab3..bad6dafa1 100644 --- a/generated/serdes_struct_entity_1.h +++ b/generated/serdes_struct_entity_1.h @@ -1,4 +1,4 @@ -// src/engine/serdes.cpp:325:0 +// src/engine/serdes.cpp:330:0 link_internal bonsai_type_info TypeInfo(entity_1 *Ignored) diff --git a/generated/serdes_struct_entity_game_data.h b/generated/serdes_struct_entity_game_data.h index 8a588fb99..b1315ee50 100644 --- a/generated/serdes_struct_entity_game_data.h +++ b/generated/serdes_struct_entity_game_data.h @@ -1,4 +1,4 @@ -// examples/turn_based/game.cpp:1120:0 +// examples/turn_based/game.cpp:1137:0 link_internal bonsai_type_info TypeInfo(entity_game_data *Ignored) diff --git a/generated/serdes_struct_entity_id.h b/generated/serdes_struct_entity_id.h index 5b16f3e7b..e5c12f260 100644 --- a/generated/serdes_struct_entity_id.h +++ b/generated/serdes_struct_entity_id.h @@ -1,4 +1,4 @@ -// src/engine/serdes.cpp:52:0 +// src/engine/serdes.cpp:55:0 link_internal bonsai_type_info TypeInfo(entity_id *Ignored) diff --git a/generated/serdes_struct_file_traversal_node.h b/generated/serdes_struct_file_traversal_node.h index 09451afe0..6e9cb863c 100644 --- a/generated/serdes_struct_file_traversal_node.h +++ b/generated/serdes_struct_file_traversal_node.h @@ -1,4 +1,4 @@ -// src/engine/serdes.cpp:272:0 +// src/engine/serdes.cpp:277:0 link_internal bonsai_type_info TypeInfo(file_traversal_node *Ignored) diff --git a/generated/serdes_struct_keyframe.h b/generated/serdes_struct_keyframe.h index 766daa6cf..f3165cc54 100644 --- a/generated/serdes_struct_keyframe.h +++ b/generated/serdes_struct_keyframe.h @@ -1,4 +1,4 @@ -// src/engine/serdes.cpp:245:0 +// src/engine/serdes.cpp:250:0 link_internal bonsai_type_info TypeInfo(keyframe *Ignored) diff --git a/generated/serdes_struct_layered_brush_editor.h b/generated/serdes_struct_layered_brush_editor.h index f726ed3f6..0533b20fa 100644 --- a/generated/serdes_struct_layered_brush_editor.h +++ b/generated/serdes_struct_layered_brush_editor.h @@ -1,4 +1,4 @@ -// src/engine/serdes.cpp:519:0 +// src/engine/serdes.cpp:524:0 link_internal bonsai_type_info TypeInfo(layered_brush_editor *Ignored) diff --git a/generated/serdes_struct_layered_brush_editor_0.h b/generated/serdes_struct_layered_brush_editor_0.h index 25fb1a205..5da30a27a 100644 --- a/generated/serdes_struct_layered_brush_editor_0.h +++ b/generated/serdes_struct_layered_brush_editor_0.h @@ -1,4 +1,4 @@ -// src/engine/serdes.cpp:515:0 +// src/engine/serdes.cpp:520:0 link_internal bonsai_type_info TypeInfo(layered_brush_editor_0 *Ignored) diff --git a/generated/serdes_struct_layered_brush_editor_1.h b/generated/serdes_struct_layered_brush_editor_1.h index cc9c78377..fb73a3450 100644 --- a/generated/serdes_struct_layered_brush_editor_1.h +++ b/generated/serdes_struct_layered_brush_editor_1.h @@ -1,4 +1,4 @@ -// src/engine/serdes.cpp:517:0 +// src/engine/serdes.cpp:522:0 link_internal bonsai_type_info TypeInfo(layered_brush_editor_1 *Ignored) diff --git a/generated/serdes_struct_lighting_settings.h b/generated/serdes_struct_lighting_settings.h index 83e876966..71f065b78 100644 --- a/generated/serdes_struct_lighting_settings.h +++ b/generated/serdes_struct_lighting_settings.h @@ -1,4 +1,4 @@ -// src/engine/serdes.cpp:376:0 +// src/engine/serdes.cpp:381:0 link_internal bonsai_type_info TypeInfo(lighting_settings *Ignored) diff --git a/generated/serdes_struct_lighting_settings_0.h b/generated/serdes_struct_lighting_settings_0.h index 30f15a533..1c477d99d 100644 --- a/generated/serdes_struct_lighting_settings_0.h +++ b/generated/serdes_struct_lighting_settings_0.h @@ -1,4 +1,4 @@ -// src/engine/serdes.cpp:373:0 +// src/engine/serdes.cpp:378:0 link_internal bonsai_type_info TypeInfo(lighting_settings_0 *Ignored) diff --git a/generated/serdes_struct_model.h b/generated/serdes_struct_model.h index 9abde768b..57592462f 100644 --- a/generated/serdes_struct_model.h +++ b/generated/serdes_struct_model.h @@ -1,4 +1,4 @@ -// src/engine/serdes.cpp:269:0 +// src/engine/serdes.cpp:274:0 link_internal bonsai_type_info TypeInfo(model *Ignored) diff --git a/generated/serdes_struct_noise_layer.h b/generated/serdes_struct_noise_layer.h index 42d16ae7f..f35c21255 100644 --- a/generated/serdes_struct_noise_layer.h +++ b/generated/serdes_struct_noise_layer.h @@ -1,4 +1,4 @@ -// src/engine/serdes.cpp:496:0 +// src/engine/serdes.cpp:501:0 link_internal bonsai_type_info TypeInfo(noise_layer *Ignored) diff --git a/generated/serdes_struct_noise_layer_0.h b/generated/serdes_struct_noise_layer_0.h index 926091f6d..d18ef2b27 100644 --- a/generated/serdes_struct_noise_layer_0.h +++ b/generated/serdes_struct_noise_layer_0.h @@ -1,4 +1,4 @@ -// src/engine/serdes.cpp:494:0 +// src/engine/serdes.cpp:499:0 link_internal bonsai_type_info TypeInfo(noise_layer_0 *Ignored) diff --git a/generated/serdes_struct_particle_system.h b/generated/serdes_struct_particle_system.h index d85918b77..90da78ff6 100644 --- a/generated/serdes_struct_particle_system.h +++ b/generated/serdes_struct_particle_system.h @@ -1,4 +1,4 @@ -// src/engine/serdes.cpp:260:0 +// src/engine/serdes.cpp:265:0 link_internal bonsai_type_info TypeInfo(particle_system *Ignored) diff --git a/generated/serdes_struct_perlin_noise_params.h b/generated/serdes_struct_perlin_noise_params.h index 034a842cc..1e444bfdc 100644 --- a/generated/serdes_struct_perlin_noise_params.h +++ b/generated/serdes_struct_perlin_noise_params.h @@ -1,4 +1,4 @@ -// src/engine/serdes.cpp:488:0 +// src/engine/serdes.cpp:493:0 link_internal bonsai_type_info TypeInfo(perlin_noise_params *Ignored) diff --git a/generated/serdes_struct_physics.h b/generated/serdes_struct_physics.h index d36c3cee3..b7ca341b0 100644 --- a/generated/serdes_struct_physics.h +++ b/generated/serdes_struct_physics.h @@ -1,4 +1,4 @@ -// src/engine/serdes.cpp:266:0 +// src/engine/serdes.cpp:271:0 link_internal bonsai_type_info TypeInfo(physics *Ignored) diff --git a/generated/serdes_struct_random_series.h b/generated/serdes_struct_random_series.h index c7bb2a3b4..3f8efeca3 100644 --- a/generated/serdes_struct_random_series.h +++ b/generated/serdes_struct_random_series.h @@ -1,4 +1,4 @@ -// src/engine/serdes.cpp:257:0 +// src/engine/serdes.cpp:262:0 link_internal bonsai_type_info TypeInfo(random_series *Ignored) diff --git a/generated/serdes_struct_rect3.h b/generated/serdes_struct_rect3.h index acc36a81d..20946e324 100644 --- a/generated/serdes_struct_rect3.h +++ b/generated/serdes_struct_rect3.h @@ -1,4 +1,4 @@ -// src/engine/serdes.cpp:251:0 +// src/engine/serdes.cpp:256:0 link_internal bonsai_type_info TypeInfo(rect3 *Ignored) diff --git a/generated/serdes_struct_rect3i.h b/generated/serdes_struct_rect3i.h index 995633a35..783da0486 100644 --- a/generated/serdes_struct_rect3i.h +++ b/generated/serdes_struct_rect3i.h @@ -1,4 +1,4 @@ -// src/engine/serdes.cpp:254:0 +// src/engine/serdes.cpp:259:0 link_internal bonsai_type_info TypeInfo(rect3i *Ignored) diff --git a/generated/serdes_struct_render_settings.h b/generated/serdes_struct_render_settings.h index 45a39b670..6df6d957e 100644 --- a/generated/serdes_struct_render_settings.h +++ b/generated/serdes_struct_render_settings.h @@ -1,4 +1,4 @@ -// src/engine/serdes.cpp:398:0 +// src/engine/serdes.cpp:403:0 link_internal bonsai_type_info TypeInfo(render_settings *Ignored) diff --git a/generated/serdes_struct_shape_layer.h b/generated/serdes_struct_shape_layer.h index b52044b66..0a693c02c 100644 --- a/generated/serdes_struct_shape_layer.h +++ b/generated/serdes_struct_shape_layer.h @@ -1,4 +1,4 @@ -// src/engine/serdes.cpp:502:0 +// src/engine/serdes.cpp:507:0 link_internal bonsai_type_info TypeInfo(shape_layer *Ignored) diff --git a/generated/serdes_struct_vertex_material.h b/generated/serdes_struct_vertex_material.h index 9b5c26830..2530010df 100644 --- a/generated/serdes_struct_vertex_material.h +++ b/generated/serdes_struct_vertex_material.h @@ -1,4 +1,4 @@ -// src/engine/serdes.cpp:121:0 +// src/engine/serdes.cpp:124:0 link_internal bonsai_type_info TypeInfo(vertex_material *Ignored) diff --git a/generated/serdes_struct_voronoi_noise_params.h b/generated/serdes_struct_voronoi_noise_params.h index c42cdacd7..f7bff92d2 100644 --- a/generated/serdes_struct_voronoi_noise_params.h +++ b/generated/serdes_struct_voronoi_noise_params.h @@ -1,4 +1,4 @@ -// src/engine/serdes.cpp:490:0 +// src/engine/serdes.cpp:495:0 link_internal bonsai_type_info TypeInfo(voronoi_noise_params *Ignored) diff --git a/generated/serdes_struct_vox_data.h b/generated/serdes_struct_vox_data.h index 7d26a5cf3..bbb1adbdf 100644 --- a/generated/serdes_struct_vox_data.h +++ b/generated/serdes_struct_vox_data.h @@ -1,4 +1,4 @@ -// src/engine/serdes.cpp:263:0 +// src/engine/serdes.cpp:268:0 link_internal bonsai_type_info TypeInfo(vox_data *Ignored) diff --git a/generated/serdes_struct_white_noise_params.h b/generated/serdes_struct_white_noise_params.h index 2d5a3cc68..fe9389713 100644 --- a/generated/serdes_struct_white_noise_params.h +++ b/generated/serdes_struct_white_noise_params.h @@ -1,4 +1,4 @@ -// src/engine/serdes.cpp:486:0 +// src/engine/serdes.cpp:491:0 link_internal bonsai_type_info TypeInfo(white_noise_params *Ignored) diff --git a/generated/serdes_struct_world_chunk.h b/generated/serdes_struct_world_chunk.h new file mode 100644 index 000000000..4984cac3f --- /dev/null +++ b/generated/serdes_struct_world_chunk.h @@ -0,0 +1,167 @@ +// src/engine/serdes.cpp:49:0 + +link_internal bonsai_type_info +TypeInfo(world_chunk *Ignored) +{ + bonsai_type_info Result = {}; + + Result.Name = CSz("world_chunk"); + Result.Version = 0 ; + + /* type.map(member) */ + /* { */ + /* { */ + /* member_info Member = {CSz("member.name"), CSz("member.name"), 0x(member.hash)}; */ + /* Push(&Result.Members, &Member); */ + /* } */ + /* } */ + + return Result; +} + +link_internal b32 +Serialize(u8_cursor_block_array *Bytes, world_chunk *BaseElement, umm Count = 1) +{ + Assert(Count > 0); + + u64 PointerTrue = True; + u64 PointerFalse = False; + + b32 Result = True; + + + + RangeIterator_t(umm, ElementIndex, Count) + { + world_chunk *Element = BaseElement + ElementIndex; + Result &= Serialize(Bytes, &Element->Dim); + + + + + + if (Element->Voxels) { Result &= Write(Bytes, Cast(u8*, &PointerTrue), sizeof(PointerTrue)); } + else { Result &= Write(Bytes, Cast(u8*, &PointerFalse), sizeof(PointerFalse)); } + + + + if (Element->VoxelLighting) { Result &= Write(Bytes, Cast(u8*, &PointerTrue), sizeof(PointerTrue)); } + else { Result &= Write(Bytes, Cast(u8*, &PointerFalse), sizeof(PointerFalse)); } + + + + Result &= Serialize(Bytes, &Element->WorldP); + + + + + + + + if (Element->Voxels) { Result &= Serialize(Bytes, Element->Voxels, Cast(umm, Volume(Element->Dim)) ); } + + + + if (Element->VoxelLighting) { Result &= Serialize(Bytes, Element->VoxelLighting, Cast(umm, Volume(Element->Dim)) ); } + + + + + + MAYBE_WRITE_DEBUG_OBJECT_DELIM(); + } + + return Result; +} + +link_internal b32 +Deserialize(u8_cursor *Bytes, world_chunk *Element, memory_arena *Memory, umm Count = 1); + +link_internal b32 +DeserializeCurrentVersion(u8_cursor *Bytes, world_chunk *Element, memory_arena *Memory); + + + + +link_internal b32 +DeserializeCurrentVersion(u8_cursor *Bytes, world_chunk *Element, memory_arena *Memory) +{ + b32 Result = True; + // NOTE(Jesse): Unfortunately we can't check for primitives because + // strings are considered primitive, but need memory to deserialize + Result &= Deserialize(Bytes, &Element->Dim, Memory); + + + + + + b64 HadVoxelsPointer = Read_u64(Bytes); + Assert(HadVoxelsPointer < 2); // Should be 0 or 1 + + + + b64 HadVoxelLightingPointer = Read_u64(Bytes); + Assert(HadVoxelLightingPointer < 2); // Should be 0 or 1 + + + + // NOTE(Jesse): Unfortunately we can't check for primitives because + // strings are considered primitive, but need memory to deserialize + Result &= Deserialize(Bytes, &Element->WorldP, Memory); + + + + + + + + if (HadVoxelsPointer) + { + umm Count = Cast(umm, Volume(Element->Dim)); + + + if (Element->Voxels == 0) + { + Element->Voxels = Allocate(voxel, Memory, Count); + } + + Result &= Deserialize(Bytes, Element->Voxels, Memory, Count); + } + + + if (HadVoxelLightingPointer) + { + umm Count = Cast(umm, Volume(Element->Dim)); + + + if (Element->VoxelLighting == 0) + { + Element->VoxelLighting = Allocate(voxel_lighting, Memory, Count); + } + + Result &= Deserialize(Bytes, Element->VoxelLighting, Memory, Count); + } + + + + + MAYBE_READ_DEBUG_OBJECT_DELIM(); + return Result; +} + +link_internal b32 +Deserialize(u8_cursor *Bytes, world_chunk *Element, memory_arena *Memory, umm Count) +{ + Assert(Count > 0); + + b32 Result = True; + RangeIterator_t(umm, ElementIndex, Count) + { + Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); + + } + + return Result; +} + + diff --git a/generated/serdes_struct_world_edit_params.h b/generated/serdes_struct_world_edit_params.h index e5ca46153..731fbfb3f 100644 --- a/generated/serdes_struct_world_edit_params.h +++ b/generated/serdes_struct_world_edit_params.h @@ -1,4 +1,4 @@ -// src/engine/serdes.cpp:492:0 +// src/engine/serdes.cpp:497:0 link_internal bonsai_type_info TypeInfo(world_edit_params *Ignored) diff --git a/generated/serdes_struct_world_update_op_shape_params_rect.h b/generated/serdes_struct_world_update_op_shape_params_rect.h index 37f1ff1db..4319eda18 100644 --- a/generated/serdes_struct_world_update_op_shape_params_rect.h +++ b/generated/serdes_struct_world_update_op_shape_params_rect.h @@ -1,4 +1,4 @@ -// src/engine/serdes.cpp:498:0 +// src/engine/serdes.cpp:503:0 link_internal bonsai_type_info TypeInfo(world_update_op_shape_params_rect *Ignored) diff --git a/generated/serdes_struct_world_update_op_shape_params_sphere.h b/generated/serdes_struct_world_update_op_shape_params_sphere.h index 17835b63a..03427306a 100644 --- a/generated/serdes_struct_world_update_op_shape_params_sphere.h +++ b/generated/serdes_struct_world_update_op_shape_params_sphere.h @@ -1,4 +1,4 @@ -// src/engine/serdes.cpp:500:0 +// src/engine/serdes.cpp:505:0 link_internal bonsai_type_info TypeInfo(world_update_op_shape_params_sphere *Ignored) diff --git a/generated/serdes_vector_Quaternion.h b/generated/serdes_vector_Quaternion.h index c474127bb..f2154e38e 100644 --- a/generated/serdes_vector_Quaternion.h +++ b/generated/serdes_vector_Quaternion.h @@ -1,4 +1,4 @@ -// src/engine/serdes.cpp:242:0 +// src/engine/serdes.cpp:247:0 link_internal b32 Serialize(u8_cursor_block_array *Bytes, Quaternion *Element, umm Count = 1) diff --git a/generated/serialize_struct_entity.h b/generated/serialize_struct_entity.h index d8983ebba..135a0c69d 100644 --- a/generated/serialize_struct_entity.h +++ b/generated/serialize_struct_entity.h @@ -1,4 +1,4 @@ -// src/engine/serdes.cpp:334:0 +// src/engine/serdes.cpp:339:0 link_internal bonsai_type_info TypeInfo(entity *Ignored) diff --git a/generated/serialize_struct_level_header.h b/generated/serialize_struct_level_header.h index 13af5389c..350c999ef 100644 --- a/generated/serialize_struct_level_header.h +++ b/generated/serialize_struct_level_header.h @@ -1,4 +1,4 @@ -// src/engine/serdes.cpp:468:0 +// src/engine/serdes.cpp:473:0 link_internal bonsai_type_info TypeInfo(level_header *Ignored) diff --git a/generated/serialize_struct_render_settings_0.h b/generated/serialize_struct_render_settings_0.h index e6dae9d7c..115a9da48 100644 --- a/generated/serialize_struct_render_settings_0.h +++ b/generated/serialize_struct_render_settings_0.h @@ -1,4 +1,4 @@ -// src/engine/serdes.cpp:395:0 +// src/engine/serdes.cpp:400:0 link_internal b32 Deserialize(u8_cursor *Bytes, render_settings_0 *Element, memory_arena *Memory, umm Count = 1); diff --git a/generated/staticbuffer_u32_cursor_ptr_961996651.h b/generated/staticbuffer_u32_cursor_ptr_961996651.h index a4327d740..28798f610 100644 --- a/generated/staticbuffer_u32_cursor_ptr_961996651.h +++ b/generated/staticbuffer_u32_cursor_ptr_961996651.h @@ -1,4 +1,4 @@ -// src/engine/voxel_synthesis.h:59:0 +// src/engine/voxel_synthesis.h:42:0 struct entropy_lists { diff --git a/generated/string_and_value_tables_asset_type.h b/generated/string_and_value_tables_asset_type.h new file mode 100644 index 000000000..cddc12537 --- /dev/null +++ b/generated/string_and_value_tables_asset_type.h @@ -0,0 +1,47 @@ +// src/engine/editor.cpp:327:0 + +link_internal counted_string +ToStringPrefixless(asset_type Type) +{ + counted_string Result = {}; + switch (Type) + { + case AssetType_Undefined: { Result = CSz("Undefined"); } break; + case AssetType_Models: { Result = CSz("Models"); } break; + case AssetType_WorldChunk: { Result = CSz("WorldChunk"); } break; + + + } + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + return Result; +} + +link_internal counted_string +ToString(asset_type Type) +{ + counted_string Result = {}; + switch (Type) + { + case AssetType_Undefined: { Result = CSz("AssetType_Undefined"); } break; + case AssetType_Models: { Result = CSz("AssetType_Models"); } break; + case AssetType_WorldChunk: { Result = CSz("AssetType_WorldChunk"); } break; + + + } + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + return Result; +} + +link_internal asset_type +AssetType(counted_string S) +{ + asset_type Result = {}; + + if (StringsMatch(S, CSz("AssetType_Undefined"))) { return AssetType_Undefined; } + if (StringsMatch(S, CSz("AssetType_Models"))) { return AssetType_Models; } + if (StringsMatch(S, CSz("AssetType_WorldChunk"))) { return AssetType_WorldChunk; } + + return Result; +} + + diff --git a/generated/string_and_value_tables_data_type.h b/generated/string_and_value_tables_data_type.h new file mode 100644 index 000000000..bf6349ff6 --- /dev/null +++ b/generated/string_and_value_tables_data_type.h @@ -0,0 +1,47 @@ +// src/engine/editor.h:492:0 + +link_internal counted_string +ToStringPrefixless(data_type Type) +{ + counted_string Result = {}; + switch (Type) + { + case DataType_Undefinded: { Result = CSz("Undefinded"); } break; + case DataType_v3: { Result = CSz("v3"); } break; + case DataType_v3_u8: { Result = CSz("u8"); } break; + + + } + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + return Result; +} + +link_internal counted_string +ToString(data_type Type) +{ + counted_string Result = {}; + switch (Type) + { + case DataType_Undefinded: { Result = CSz("DataType_Undefinded"); } break; + case DataType_v3: { Result = CSz("DataType_v3"); } break; + case DataType_v3_u8: { Result = CSz("DataType_v3_u8"); } break; + + + } + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + return Result; +} + +link_internal data_type +DataType(counted_string S) +{ + data_type Result = {}; + + if (StringsMatch(S, CSz("DataType_Undefinded"))) { return DataType_Undefinded; } + if (StringsMatch(S, CSz("DataType_v3"))) { return DataType_v3; } + if (StringsMatch(S, CSz("DataType_v3_u8"))) { return DataType_v3_u8; } + + return Result; +} + + diff --git a/generated/string_and_value_tables_engine_debug_view_mode.h b/generated/string_and_value_tables_engine_debug_view_mode.h index dc9ad63a4..35652e021 100644 --- a/generated/string_and_value_tables_engine_debug_view_mode.h +++ b/generated/string_and_value_tables_engine_debug_view_mode.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:190:0 +// src/engine/editor.cpp:193:0 link_internal counted_string ToStringPrefixless(engine_debug_view_mode Type) diff --git a/generated/string_and_value_tables_file_traversal_node.h b/generated/string_and_value_tables_file_traversal_node.h index 7a7c709e7..46e7463ca 100644 --- a/generated/string_and_value_tables_file_traversal_node.h +++ b/generated/string_and_value_tables_file_traversal_node.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:184:0 +// src/engine/editor.cpp:187:0 link_internal counted_string ToStringPrefixless(file_traversal_type Type) diff --git a/generated/string_and_value_tables_particle_spawn_type.h b/generated/string_and_value_tables_particle_spawn_type.h index d09dd60d5..c4e84e420 100644 --- a/generated/string_and_value_tables_particle_spawn_type.h +++ b/generated/string_and_value_tables_particle_spawn_type.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:181:0 +// src/engine/editor.cpp:184:0 link_internal counted_string ToStringPrefixless(particle_spawn_type Type) diff --git a/generated/string_and_value_tables_shape_type.h b/generated/string_and_value_tables_shape_type.h index 03478690d..ca5caf141 100644 --- a/generated/string_and_value_tables_shape_type.h +++ b/generated/string_and_value_tables_shape_type.h @@ -1,4 +1,4 @@ -// src/engine/editor.h:808:0 +// src/engine/editor.h:812:0 link_internal counted_string ToStringPrefixless(shape_type Type) diff --git a/generated/string_and_value_tables_tone_mapping_type.h b/generated/string_and_value_tables_tone_mapping_type.h index 0317c08cb..4cb4fe85a 100644 --- a/generated/string_and_value_tables_tone_mapping_type.h +++ b/generated/string_and_value_tables_tone_mapping_type.h @@ -1,4 +1,4 @@ -// src/engine/editor.cpp:187:0 +// src/engine/editor.cpp:190:0 link_internal counted_string ToStringPrefixless(tone_mapping_type Type) diff --git a/generated/string_and_value_tables_ui_noise_type.h b/generated/string_and_value_tables_ui_noise_type.h index 23750000b..74a650c5f 100644 --- a/generated/string_and_value_tables_ui_noise_type.h +++ b/generated/string_and_value_tables_ui_noise_type.h @@ -1,4 +1,4 @@ -// src/engine/editor.h:527:0 +// src/engine/editor.h:531:0 link_internal counted_string ToStringPrefixless(ui_noise_type Type) diff --git a/generated/string_and_value_tables_world_edit_mode.h b/generated/string_and_value_tables_world_edit_mode.h index 80d301e03..645da345d 100644 --- a/generated/string_and_value_tables_world_edit_mode.h +++ b/generated/string_and_value_tables_world_edit_mode.h @@ -1,4 +1,4 @@ -// src/engine/editor.h:682:0 +// src/engine/editor.h:686:0 link_internal counted_string ToStringPrefixless(world_edit_mode Type) diff --git a/generated/string_and_value_tables_world_edit_mode_modifier.h b/generated/string_and_value_tables_world_edit_mode_modifier.h index 988960239..0abe04583 100644 --- a/generated/string_and_value_tables_world_edit_mode_modifier.h +++ b/generated/string_and_value_tables_world_edit_mode_modifier.h @@ -1,4 +1,4 @@ -// src/engine/editor.h:669:0 +// src/engine/editor.h:673:0 link_internal counted_string ToStringPrefixless(world_edit_mode_modifier Type) diff --git a/generated/string_and_value_tables_world_edit_selection_mode.h b/generated/string_and_value_tables_world_edit_selection_mode.h index a39f2e6e3..80e0dfaee 100644 --- a/generated/string_and_value_tables_world_edit_selection_mode.h +++ b/generated/string_and_value_tables_world_edit_selection_mode.h @@ -1,4 +1,4 @@ -// src/engine/editor.h:561:0 +// src/engine/editor.h:565:0 link_internal counted_string ToStringPrefixless(world_edit_selection_mode Type) diff --git a/generated/string_and_value_tables_world_update_op_shape_type.h b/generated/string_and_value_tables_world_update_op_shape_type.h index 98b854605..a07783bd0 100644 --- a/generated/string_and_value_tables_world_update_op_shape_type.h +++ b/generated/string_and_value_tables_world_update_op_shape_type.h @@ -1,4 +1,4 @@ -// src/engine/editor.h:717:0 +// src/engine/editor.h:721:0 link_internal counted_string ToStringPrefixless(world_update_op_shape_type Type) diff --git a/generated/take_release_sync_lod_element_buffer.h b/generated/take_release_sync_lod_element_buffer.h index e05f7c9da..5da0d1378 100644 --- a/generated/take_release_sync_lod_element_buffer.h +++ b/generated/take_release_sync_lod_element_buffer.h @@ -1,4 +1,4 @@ -// src/engine/mesh.cpp:233:0 +// src/engine/mesh.cpp:247:0 link_internal untextured_3d_geometry_buffer * TakeOwnershipSync( lod_element_buffer *Buf, world_chunk_mesh_bitfield MeshBit) diff --git a/generated/threadsafe_mesh_container_world_chunk_lod_element_buffer.h b/generated/threadsafe_mesh_container_world_chunk_lod_element_buffer.h deleted file mode 100644 index 58c2b55c9..000000000 --- a/generated/threadsafe_mesh_container_world_chunk_lod_element_buffer.h +++ /dev/null @@ -1,116 +0,0 @@ -// src/engine/mesh.cpp:236:0 - -link_internal world_chunk_geometry_buffer * -TakeOwnershipSync( world_chunk_lod_element_buffer *Buf, world_chunk_mesh_bitfield MeshBit) -{ - AcquireFutex(&Buf->Locks[ToIndex(MeshBit)]); - world_chunk_geometry_buffer *Result = (world_chunk_geometry_buffer *)Buf->E[ToIndex(MeshBit)]; - return Result; -} - -link_internal void -ReleaseOwnership( world_chunk_lod_element_buffer *Src, world_chunk_mesh_bitfield MeshBit, world_chunk_geometry_buffer *Buf) -{ - /* if (Buf) { Assert(Src->MeshMask & MeshBit); } */ - ReleaseFutex(&Src->Locks[ToIndex(MeshBit)]); -} - -link_internal world_chunk_geometry_buffer * -ReplaceMesh( world_chunk_lod_element_buffer *Meshes, - world_chunk_mesh_bitfield MeshBit, - world_chunk_geometry_buffer *Buf, - u64 BufTimestamp ) -{ - Assert( Meshes->Locks[ToIndex(MeshBit)].SignalValue == (u32)ThreadLocal_ThreadIndex ); - /* if (Buf) { Assert(Buf->At); } */ - - world_chunk_geometry_buffer *Result = {}; - world_chunk_geometry_buffer *CurrentMesh = (world_chunk_geometry_buffer*)Meshes->E[ToIndex(MeshBit)]; - - if (CurrentMesh) - { - if (CurrentMesh->Timestamp < BufTimestamp) - { - Meshes->E[ToIndex(MeshBit)] = Buf; - Result = CurrentMesh; - } - else - { - // NOTE(Jesse): If we don't swap this in, we have to return it so it gets freed - Result = Buf; - } - } - else - { - Meshes->E[ToIndex(MeshBit)] = Buf; - } - - if (Meshes->E[ToIndex(MeshBit)]) { Meshes->MeshMask |= MeshBit; } - else { Meshes->MeshMask &= ~MeshBit; } - - return Result; -} - -link_internal world_chunk_geometry_buffer * -AtomicReplaceMesh( world_chunk_lod_element_buffer *Meshes, - world_chunk_mesh_bitfield MeshBit, - world_chunk_geometry_buffer *Buf, - u64 BufTimestamp ) -{ - TakeOwnershipSync(Meshes, MeshBit); - auto Replace = ReplaceMesh(Meshes, MeshBit, Buf, BufTimestamp); - ReleaseOwnership(Meshes, MeshBit, Buf); - return Replace; -} - -link_internal void -DeallocateMeshes(world_chunk_lod_element_buffer *Buf, tiered_mesh_freelist* MeshFreelist) -{ - if ( auto Mesh = AtomicReplaceMesh(Buf, MeshBit_Lod0, 0, __rdtsc()) ) { DeallocateMesh(Mesh, MeshFreelist); } - if ( auto Mesh = AtomicReplaceMesh(Buf, MeshBit_Lod1, 0, __rdtsc()) ) { DeallocateMesh(Mesh, MeshFreelist); } - if ( auto Mesh = AtomicReplaceMesh(Buf, MeshBit_Lod2, 0, __rdtsc()) ) { DeallocateMesh(Mesh, MeshFreelist); } - if ( auto Mesh = AtomicReplaceMesh(Buf, MeshBit_Lod3, 0, __rdtsc()) ) { DeallocateMesh(Mesh, MeshFreelist); } - if ( auto Mesh = AtomicReplaceMesh(Buf, MeshBit_Lod4, 0, __rdtsc()) ) { DeallocateMesh(Mesh, MeshFreelist); } - /* if ( auto Mesh = AtomicReplaceMesh(Buf, MeshBit_Debug, 0, __rdtsc()) ) { DeallocateMesh(Mesh, MeshFreelist); } */ - /* if ( auto Mesh = AtomicReplaceMesh(Buf, MeshBit_Transparency, 0, __rdtsc()) ) { DeallocateMesh(Mesh, MeshFreelist); } */ - - Buf->MeshMask = 0; -} - -link_internal b32 -HasGpuMesh(world_chunk_lod_element_buffer *Buf, world_chunk_mesh_bitfield MeshBit) -{ - b32 Result = (Buf->GpuBufferHandles[ToIndex(MeshBit)].VertexHandle != 0); - return Result; -} - - -link_internal b32 -HasGpuMesh(world_chunk_lod_element_buffer *Buf) -{ - b32 Result = False; - RangeIterator(MeshIndex, MeshIndex_Count) - { - Result |= (Buf->GpuBufferHandles[MeshIndex].VertexHandle != 0); - } - return Result; -} - -link_internal b32 -HasCpuMesh(world_chunk_lod_element_buffer *Buf) -{ - b32 Result = False; - RangeIterator(MeshIndex, MeshIndex_Count) - { - Result |= (Buf->E[MeshIndex] != 0); - } - return Result; -} - -link_internal b32 -HasMesh(world_chunk_lod_element_buffer *Buf, world_chunk_mesh_bitfield MeshBit) -{ - b32 Result = (Buf->E[ToIndex(MeshBit)] != 0); - return Result; -} - diff --git a/generated/toggle_button_group_for_enum_engine_debug_view_mode.h b/generated/toggle_button_group_for_enum_engine_debug_view_mode.h index 778b2597c..251e47eff 100644 --- a/generated/toggle_button_group_for_enum_engine_debug_view_mode.h +++ b/generated/toggle_button_group_for_enum_engine_debug_view_mode.h @@ -1,4 +1,4 @@ -// src/engine/editor.h:674:0 +// src/engine/editor.h:678:0 link_internal ui_toggle_button_group ToggleButtonGroup_engine_debug_view_mode( renderer_2d *Ui, diff --git a/generated/vertex_data_functions_v3.h b/generated/vertex_data_functions_v3.h index 9c7054fd6..4c821dfe5 100644 --- a/generated/vertex_data_functions_v3.h +++ b/generated/vertex_data_functions_v3.h @@ -1,4 +1,4 @@ -// src/engine/voxel_face.h:205:0 +// src/engine/voxel_face.h:212:0 inline void RightFaceVertexData( v3 MinP, v3 Diameter, v3 *Result) diff --git a/generated/vertex_data_functions_v3_u8.h b/generated/vertex_data_functions_v3_u8.h index a5a92d9bc..4309f5823 100644 --- a/generated/vertex_data_functions_v3_u8.h +++ b/generated/vertex_data_functions_v3_u8.h @@ -1,4 +1,4 @@ -// src/engine/voxel_face.h:208:0 +// src/engine/voxel_face.h:215:0 inline void RightFaceVertexData( v3_u8 MinP, v3 Diameter, v3_u8 *Result) diff --git a/generated/world_chunk_mesh_functions_untextured_3d_geometry_buffer.h b/generated/world_chunk_mesh_functions_untextured_3d_geometry_buffer_v3.h similarity index 94% rename from generated/world_chunk_mesh_functions_untextured_3d_geometry_buffer.h rename to generated/world_chunk_mesh_functions_untextured_3d_geometry_buffer_v3.h index 8eb0e23f3..58dfdbab7 100644 --- a/generated/world_chunk_mesh_functions_untextured_3d_geometry_buffer.h +++ b/generated/world_chunk_mesh_functions_untextured_3d_geometry_buffer_v3.h @@ -1,7 +1,7 @@ -// src/engine/world_chunk.cpp:2078:0 +// src/engine/world_chunk.cpp:2058:0 link_internal void -BuildWorldChunkMeshFromMarkedVoxels_Greedy( voxel *Voxels, +BuildWorldChunkMeshFromMarkedVoxels_Greedy_v3( voxel *Voxels, v3i SrcChunkDim, v3i SrcChunkMin, @@ -19,6 +19,7 @@ BuildWorldChunkMeshFromMarkedVoxels_Greedy( voxel *Voxels, /* HISTOGRAM_FUNCTION(); */ TIMED_FUNCTION(); + Assert(DestGeometry->Type == DataType_v3); v3 VertexData[VERTS_PER_FACE]; matl Materials[VERTS_PER_FACE]; @@ -81,38 +82,38 @@ BuildWorldChunkMeshFromMarkedVoxels_Greedy( voxel *Voxels, { v3 Dim = DoXStepping(TempVoxels, TmpDim, TmpVoxP, Voxel_RightFace, Voxel->Color, Voxel->Transparency); RightFaceVertexData( VertexOffset+TmpVoxP, Dim, VertexData); - BufferFaceData(Dest, VertexData, RightFaceNormalData, Materials); + BufferFaceData(Dest, VertexData, v3_RightFaceNormalData, Materials); } if (Voxel->Flags & Voxel_LeftFace) { v3 Dim = DoXStepping(TempVoxels, TmpDim, TmpVoxP, Voxel_LeftFace, Voxel->Color, Voxel->Transparency); LeftFaceVertexData( VertexOffset+TmpVoxP, Dim, VertexData); - BufferFaceData(Dest, VertexData, LeftFaceNormalData, Materials); + BufferFaceData(Dest, VertexData, v3_LeftFaceNormalData, Materials); } if (Voxel->Flags & Voxel_BottomFace) { v3 Dim = DoZStepping(TempVoxels, TmpDim, TmpVoxP, Voxel_BottomFace, Voxel->Color, Voxel->Transparency); BottomFaceVertexData( VertexOffset+TmpVoxP, Dim, VertexData); - BufferFaceData(Dest, VertexData, BottomFaceNormalData, Materials); + BufferFaceData(Dest, VertexData, v3_BottomFaceNormalData, Materials); } if (Voxel->Flags & Voxel_TopFace) { v3 Dim = DoZStepping(TempVoxels, TmpDim, TmpVoxP, Voxel_TopFace, Voxel->Color, Voxel->Transparency); TopFaceVertexData( VertexOffset+TmpVoxP, Dim, VertexData); - BufferFaceData(Dest, VertexData, TopFaceNormalData, Materials); + BufferFaceData(Dest, VertexData, v3_TopFaceNormalData, Materials); } if (Voxel->Flags & Voxel_FrontFace) { v3 Dim = DoYStepping(TempVoxels, TmpDim, TmpVoxP, Voxel_FrontFace, Voxel->Color, Voxel->Transparency); FrontFaceVertexData( VertexOffset+TmpVoxP, Dim, VertexData); - BufferFaceData(Dest, VertexData, FrontFaceNormalData, Materials); + BufferFaceData(Dest, VertexData, v3_FrontFaceNormalData, Materials); } if (Voxel->Flags & Voxel_BackFace) { v3 Dim = DoYStepping(TempVoxels, TmpDim, TmpVoxP, Voxel_BackFace, Voxel->Color, Voxel->Transparency); BackFaceVertexData( VertexOffset+TmpVoxP, Dim, VertexData); - BufferFaceData(Dest, VertexData, BackFaceNormalData, Materials); + BufferFaceData(Dest, VertexData, v3_BackFaceNormalData, Materials); } } @@ -126,23 +127,23 @@ BuildWorldChunkMeshFromMarkedVoxels_Greedy( voxel *Voxels, } link_internal void -BuildWorldChunkMeshFromMarkedVoxels_Greedy( vox_data *Vox, +BuildWorldChunkMeshFromMarkedVoxels_Greedy_v3( vox_data *Vox, untextured_3d_geometry_buffer *DestGeometry, untextured_3d_geometry_buffer *DestTransparentGeometry, memory_arena *TempMemory, - v3 VertexOffset = {}) + v3 VertexOffset = {}) { - BuildWorldChunkMeshFromMarkedVoxels_Greedy(Vox->ChunkData->Voxels, Vox->ChunkData->Dim, {}, Vox->ChunkData->Dim, DestGeometry, DestTransparentGeometry, TempMemory, VertexOffset); + BuildWorldChunkMeshFromMarkedVoxels_Greedy_v3(Vox->ChunkData->Voxels, Vox->ChunkData->Dim, {}, Vox->ChunkData->Dim, DestGeometry, DestTransparentGeometry, TempMemory, VertexOffset); } link_internal void -BuildMipMesh( voxel *Voxels, +BuildMipMesh_v3( voxel *Voxels, v3i VoxDim, v3i InnerMin, v3i InnerMax, - world_chunk_mesh_bitfield MeshBit, + world_chunk_mesh_bitfield MeshBit, untextured_3d_geometry_buffer *DestGeometry, memory_arena *TempMemory ) @@ -375,7 +376,7 @@ BuildMipMesh( voxel *Voxels, } link_internal void -BuildWorldChunkMeshFromMarkedVoxels_Naieve( voxel *Voxels, +BuildWorldChunkMeshFromMarkedVoxels_Naieve_v3( voxel *Voxels, chunk_dimension VoxDim, chunk_dimension SrcChunkMin, diff --git a/generated/world_chunk_mesh_functions_world_chunk_geometry_buffer.h b/generated/world_chunk_mesh_functions_untextured_3d_geometry_buffer_v3_u8.h similarity index 91% rename from generated/world_chunk_mesh_functions_world_chunk_geometry_buffer.h rename to generated/world_chunk_mesh_functions_untextured_3d_geometry_buffer_v3_u8.h index f7c464c12..58b3b0e85 100644 --- a/generated/world_chunk_mesh_functions_world_chunk_geometry_buffer.h +++ b/generated/world_chunk_mesh_functions_untextured_3d_geometry_buffer_v3_u8.h @@ -1,15 +1,15 @@ -// src/engine/world_chunk.cpp:2081:0 +// src/engine/world_chunk.cpp:2061:0 link_internal void -BuildWorldChunkMeshFromMarkedVoxels_Greedy( voxel *Voxels, +BuildWorldChunkMeshFromMarkedVoxels_Greedy_v3_u8( voxel *Voxels, v3i SrcChunkDim, v3i SrcChunkMin, v3i SrcChunkMax, // TODO(Jesse)(immediate, poof): removing the braces here causes poof to bail .. why? - world_chunk_geometry_buffer *DestGeometry, - world_chunk_geometry_buffer *DestTransparentGeometry, + untextured_3d_geometry_buffer *DestGeometry, + untextured_3d_geometry_buffer *DestTransparentGeometry, memory_arena *TempMemory, // NOTE(Jesse): This is so we can offset vertices such that we center @@ -19,6 +19,7 @@ BuildWorldChunkMeshFromMarkedVoxels_Greedy( voxel *Voxels, /* HISTOGRAM_FUNCTION(); */ TIMED_FUNCTION(); + Assert(DestGeometry->Type == DataType_v3_u8); v3_u8 VertexData[VERTS_PER_FACE]; matl Materials[VERTS_PER_FACE]; @@ -72,7 +73,7 @@ BuildWorldChunkMeshFromMarkedVoxels_Greedy( voxel *Voxels, FillArray(VertexMaterial(Voxel->Color, Voxel->Transparency, 0), Materials, VERTS_PER_FACE); - world_chunk_geometry_buffer *Dest = {}; + untextured_3d_geometry_buffer *Dest = {}; if (Voxel->Transparency) { Dest = DestTransparentGeometry; } else { Dest = DestGeometry; } if (Dest) @@ -81,38 +82,38 @@ BuildWorldChunkMeshFromMarkedVoxels_Greedy( voxel *Voxels, { v3 Dim = DoXStepping(TempVoxels, TmpDim, TmpVoxP, Voxel_RightFace, Voxel->Color, Voxel->Transparency); RightFaceVertexData( VertexOffset+TmpVoxP, Dim, VertexData); - BufferFaceData(Dest, VertexData, RightFaceNormalData, Materials); + BufferFaceData(Dest, VertexData, v3_u8_RightFaceNormalData, Materials); } if (Voxel->Flags & Voxel_LeftFace) { v3 Dim = DoXStepping(TempVoxels, TmpDim, TmpVoxP, Voxel_LeftFace, Voxel->Color, Voxel->Transparency); LeftFaceVertexData( VertexOffset+TmpVoxP, Dim, VertexData); - BufferFaceData(Dest, VertexData, LeftFaceNormalData, Materials); + BufferFaceData(Dest, VertexData, v3_u8_LeftFaceNormalData, Materials); } if (Voxel->Flags & Voxel_BottomFace) { v3 Dim = DoZStepping(TempVoxels, TmpDim, TmpVoxP, Voxel_BottomFace, Voxel->Color, Voxel->Transparency); BottomFaceVertexData( VertexOffset+TmpVoxP, Dim, VertexData); - BufferFaceData(Dest, VertexData, BottomFaceNormalData, Materials); + BufferFaceData(Dest, VertexData, v3_u8_BottomFaceNormalData, Materials); } if (Voxel->Flags & Voxel_TopFace) { v3 Dim = DoZStepping(TempVoxels, TmpDim, TmpVoxP, Voxel_TopFace, Voxel->Color, Voxel->Transparency); TopFaceVertexData( VertexOffset+TmpVoxP, Dim, VertexData); - BufferFaceData(Dest, VertexData, TopFaceNormalData, Materials); + BufferFaceData(Dest, VertexData, v3_u8_TopFaceNormalData, Materials); } if (Voxel->Flags & Voxel_FrontFace) { v3 Dim = DoYStepping(TempVoxels, TmpDim, TmpVoxP, Voxel_FrontFace, Voxel->Color, Voxel->Transparency); FrontFaceVertexData( VertexOffset+TmpVoxP, Dim, VertexData); - BufferFaceData(Dest, VertexData, FrontFaceNormalData, Materials); + BufferFaceData(Dest, VertexData, v3_u8_FrontFaceNormalData, Materials); } if (Voxel->Flags & Voxel_BackFace) { v3 Dim = DoYStepping(TempVoxels, TmpDim, TmpVoxP, Voxel_BackFace, Voxel->Color, Voxel->Transparency); BackFaceVertexData( VertexOffset+TmpVoxP, Dim, VertexData); - BufferFaceData(Dest, VertexData, BackFaceNormalData, Materials); + BufferFaceData(Dest, VertexData, v3_u8_BackFaceNormalData, Materials); } } @@ -126,25 +127,25 @@ BuildWorldChunkMeshFromMarkedVoxels_Greedy( voxel *Voxels, } link_internal void -BuildWorldChunkMeshFromMarkedVoxels_Greedy( vox_data *Vox, - world_chunk_geometry_buffer *DestGeometry, - world_chunk_geometry_buffer *DestTransparentGeometry, +BuildWorldChunkMeshFromMarkedVoxels_Greedy_v3_u8( vox_data *Vox, + untextured_3d_geometry_buffer *DestGeometry, + untextured_3d_geometry_buffer *DestTransparentGeometry, memory_arena *TempMemory, - v3_u8 VertexOffset = {}) + v3_u8 VertexOffset = {}) { - BuildWorldChunkMeshFromMarkedVoxels_Greedy(Vox->ChunkData->Voxels, Vox->ChunkData->Dim, {}, Vox->ChunkData->Dim, DestGeometry, DestTransparentGeometry, TempMemory, VertexOffset); + BuildWorldChunkMeshFromMarkedVoxels_Greedy_v3_u8(Vox->ChunkData->Voxels, Vox->ChunkData->Dim, {}, Vox->ChunkData->Dim, DestGeometry, DestTransparentGeometry, TempMemory, VertexOffset); } link_internal void -BuildMipMesh( voxel *Voxels, +BuildMipMesh_v3_u8( voxel *Voxels, v3i VoxDim, v3i InnerMin, v3i InnerMax, - world_chunk_mesh_bitfield MeshBit, + world_chunk_mesh_bitfield MeshBit, - world_chunk_geometry_buffer *DestGeometry, + untextured_3d_geometry_buffer *DestGeometry, memory_arena *TempMemory ) { /* TIMED_FUNCTION(); */ @@ -375,14 +376,14 @@ BuildMipMesh( voxel *Voxels, } link_internal void -BuildWorldChunkMeshFromMarkedVoxels_Naieve( voxel *Voxels, +BuildWorldChunkMeshFromMarkedVoxels_Naieve_v3_u8( voxel *Voxels, chunk_dimension VoxDim, chunk_dimension SrcChunkMin, chunk_dimension SrcChunkMax, - world_chunk_geometry_buffer *DestGeometry, - world_chunk_geometry_buffer *DestTransparentGeometry ) + untextured_3d_geometry_buffer *DestGeometry, + untextured_3d_geometry_buffer *DestTransparentGeometry ) { /* TIMED_FUNCTION(); */ diff --git a/jesse.bonsai.rdbg b/jesse.bonsai.rdbg index 03f842a05..3308eadee 100644 Binary files a/jesse.bonsai.rdbg and b/jesse.bonsai.rdbg differ diff --git a/jesse.make.sh b/jesse.make.sh index ebbdc05de..16ac71adb 100644 --- a/jesse.make.sh +++ b/jesse.make.sh @@ -7,10 +7,12 @@ ./make.sh $OPT BuildAll +# ./make.sh RunTests + # ./make.sh $OPT \ -# BuildExecutables \ + # BuildSingleExample examples/blank_project \ + # BuildExecutables \ # BuildSingleExample examples/tools/voxel_synthesis_rule_baker \ -# BuildSingleExample examples/blank_project \ # BuildSingleExample examples/turn_based \ # BuildSingleExample examples/project_and_level_picker \ # BuildSingleExample examples/terrain_gen \ @@ -20,23 +22,3 @@ # ./make.sh BundleRelease -# exit 0 - -# ./make.sh -O2 BuildSingleExample examples/blank_project -# ./make.sh -O2 BuildSingleExample examples/the_wanderer -# ./make.sh BuildSingleExample examples/the_wanderer - -# ./make.sh BuildTests - - - -# ./make.sh MakeDebugLibRelease - -# ./make.sh BuildTests -# ./make.sh BuildExecutables -# ./make.sh BuildBundledExamples - -# ./make.sh BuildAll -O0 -# ./make.sh BuildAll -O2 - -# ./make.sh BuildTests diff --git a/jesse.tests.rdbg b/jesse.tests.rdbg index 10197bab6..48cbb2bb6 100644 Binary files a/jesse.tests.rdbg and b/jesse.tests.rdbg differ diff --git a/make.sh b/make.sh index 9523fc824..c7d9370c7 100755 --- a/make.sh +++ b/make.sh @@ -261,16 +261,20 @@ function RunEntireBuild { if [ $RunPoof == 1 ]; then RunPoof + [ $? -ne 0 ] && exit 1 fi if [ $EMCC == 1 ]; then BuildWithEMCC + [ $? -ne 0 ] && exit 1 else BuildWithClang + [ $? -ne 0 ] && exit 1 fi if [ $RunTests == 1 ]; then $stdlib_build_scripts/run_tests.sh + [ $? -ne 0 ] && exit 1 fi } diff --git a/src/engine/api.cpp b/src/engine/api.cpp index 9eedf44fb..0c8add976 100644 --- a/src/engine/api.cpp +++ b/src/engine/api.cpp @@ -486,6 +486,8 @@ Bonsai_Render(engine_resources *Engine) PushBonsaiRenderCommandTeardownShader(&Plat->RenderQ, BonsaiRenderCommand_ShaderId_ShadowMap); + /* DoModalInteraction(Ui, RectMinDim(V2(0), *Ui->ScreenDim)); */ + { layout DefaultLayout = {}; @@ -513,11 +515,12 @@ WorkerThread_ApplicationDefaultImplementation(BONSAI_API_WORKER_THREAD_CALLBACK_ engine_resources *EngineResources = GetEngineResources(); world *World = EngineResources->World; - work_queue_entry_type Type = Entry->Type; - switch (Type) + work_queue_entry_type WorkType = Entry->Type; + switch (WorkType) { InvalidCase(type_work_queue_entry_noop); InvalidCase(type_work_queue_entry__align_to_cache_line_helper); + InvalidCase(type_work_queue_entry_update_world_region); // NOTE(Jesse): Render commands should never end up on a general purpose work queue InvalidCase(type_work_queue_entry__bonsai_render_command); @@ -532,12 +535,6 @@ WorkerThread_ApplicationDefaultImplementation(BONSAI_API_WORKER_THREAD_CALLBACK_ InitAsset(Job->Asset, Thread); } break; - case type_work_queue_entry_update_world_region: - { - work_queue_entry_update_world_region *Job = SafeAccess(work_queue_entry_update_world_region, Entry); - DoWorldUpdate(&EngineResources->Stdlib.Plat.LowPriority, World, Thread, Job); - } break; - case type_work_queue_entry_sim_particle_system: { work_queue_entry_sim_particle_system *Job = SafeAccess(work_queue_entry_sim_particle_system, Entry); @@ -549,7 +546,8 @@ WorkerThread_ApplicationDefaultImplementation(BONSAI_API_WORKER_THREAD_CALLBACK_ work_queue_entry_rebuild_mesh *Job = SafeAccess(work_queue_entry_rebuild_mesh, Entry); world_chunk *Chunk = Job->Chunk; - world_chunk_geometry_buffer *TempMesh = AllocateTempWorldChunkMesh(Thread->TempMemory); + data_type Type = GetMeshDatatypeForDimension(Chunk->Dim); + auto *TempMesh = AllocateTempMesh(Thread->TempMemory, Type); RebuildWorldChunkMesh(Thread, Chunk, {}, Chunk->Dim, MeshBit_Lod0, TempMesh, Thread->TempMemory); TempMesh->At = 0; diff --git a/src/engine/asset.cpp b/src/engine/asset.cpp index 678cbb7f1..3f7544ea7 100644 --- a/src/engine/asset.cpp +++ b/src/engine/asset.cpp @@ -231,6 +231,7 @@ DeserializeMesh(u8_cursor *File, world_chunk_file_header *Header, untextured_3d_ global_variable counted_string Global_AssetPrefixPath = CSz(""); + link_internal world_chunk_file_header_v3 ReadWorldChunkFileHeader_v3(u8_cursor *File) { @@ -242,12 +243,10 @@ ReadWorldChunkFileHeader_v3(u8_cursor *File) Assert( Result.Checksum == 0xdeadbeef ); Assert( Result.VertexElementSize == sizeof(v3) ); - /* Assert( Result.MaterialElementSize == sizeof(vertex_material) ); */ Assert( Result.NormalElementSize == sizeof(v3) ); Assert( Result.StandingSpotElementSize == sizeof(voxel_position) ); Assert( Result.VoxelElementSize == sizeof(voxel) ); - return Result; } @@ -297,7 +296,7 @@ ReadWorldChunkFileHeader(u8_stream *File) } link_internal u32 -ReadWorldChunkVersion(u8_stream *Cursor ) +ReadWorldChunkVersion(u8_stream *Cursor) { u32 WHNK = Read_u32(Cursor); Assert(WHNK == WorldChunkFileTag_WHNK); @@ -313,7 +312,7 @@ ReadWorldChunkVersion(u8_stream *Cursor ) } link_internal void -DeserializeChunk(u8_stream *FileBytes, world_chunk *Result, tiered_mesh_freelist *MeshFreelist, memory_arena *PermMemory) +DeserializeChunk(u8_stream *FileBytes, world_chunk *Result, memory_arena *PermMemory) { TIMED_FUNCTION(); @@ -405,10 +404,10 @@ SerializeChunk(world_chunk *Chunk, u8_cursor_block_array *Bytes) } link_internal b32 -SerializeChunk(world_chunk *Chunk, counted_string AssetPath) +SerializeChunk(world_chunk *Chunk, counted_string Filename) { auto WorldP = Chunk->WorldP; - counted_string Filename = GetAssetFilenameFor(AssetPath, WorldP, GetTranArena()); + /* counted_string Filename = GetAssetFilenameFor(AssetPath, WorldP, GetTranArena()); */ u8_cursor_block_array Bytes = {}; b32 Result = SerializeChunk(Chunk, &Bytes); @@ -432,7 +431,20 @@ FreeAsset(engine_resources *Engine, asset *Asset) Assert(Asset->LoadState == AssetLoadState_Loaded || Asset->LoadState == AssetLoadState_Error ); - FreeModelBuffer(&Engine->AssetSystem.AssetMemory, &Asset->Models); + switch (Asset->Type) + { + InvalidCase(AssetType_Undefined); + + case AssetType_Models: + { + FreeModelBuffer(&Engine->AssetSystem.AssetMemory, &Asset->Models); + } break; + + case AssetType_WorldChunk: + { + NotImplemented; + } break; + } HeapDeallocate(&Engine->AssetSystem.AssetMemory, Cast(void*, Asset->Id.FileNode.Dir.Start)); HeapDeallocate(&Engine->AssetSystem.AssetMemory, Cast(void*, Asset->Id.FileNode.Name.Start)); @@ -543,6 +555,7 @@ AllocateAsset(engine_resources *Engine, u64 FrameIndex = 0) return Result; } + link_internal void InitAsset(asset *Asset, thread_local_state *Thread) { @@ -567,6 +580,7 @@ InitAsset(asset *Asset, thread_local_state *Thread) if (Maybe.Tag == Maybe_Yes) { + Asset->Type = AssetType_Models; Asset->Models = Maybe.Value; FullBarrier; Asset->LoadState = AssetLoadState_Loaded; @@ -580,6 +594,33 @@ InitAsset(asset *Asset, thread_local_state *Thread) { Asset->LoadState = AssetLoadState_Error; } + else if ( AreEqual(Ext, CSz("chunk")) ) + { + u8_stream Bytes = U8_StreamFromFile(AssetFilepath, Thread->TempMemory); + + world_chunk _Chunk = {}; + world_chunk *Chunk = &_Chunk; + + // TODO(Jesse)(memory, leak): This leaks the chunk memory; we do not have a + // way of reclaiming it when it's loaded from disk. The chunk buffers for + // world chunks are just never freed, but the chunks are recycled. This + // chunk is a weird one as the buffers can be of arbitrary size. + Deserialize(&Bytes, Chunk, Thread->PermMemory, 1); + + MarkBoundaryVoxels_MakeExteriorFaces(Chunk->Voxels, Chunk->Dim, V3i(0), Chunk->Dim); + + FinalizeChunkInitialization(Chunk); + + data_type Type = GetMeshDatatypeForDimension(Chunk->Dim); + auto *TempMesh = AllocateTempMesh(Thread->TempMemory, Type); + + RebuildWorldChunkMesh(Thread, Chunk, V3i(0), Chunk->Dim, MeshBit_Lod0, TempMesh, Thread->TempMemory, Chunk->Dim/-2.f); + + Asset->Type = AssetType_WorldChunk; + Asset->Chunk = *Chunk; + + Asset->LoadState = AssetLoadState_Loaded; + } else { SoftError("Unsupported file format while initializing asset (%S).", AssetFilepath); @@ -741,6 +782,7 @@ GetAssetPtr(engine_resources *Engine, file_traversal_node *FileNode, u64 FrameIn link_internal model * GetModel(asset *Asset, asset_id *AID, u64 ModelIndex) { + Assert(Asset->Type == AssetType_Models); Assert(ModelIndex < Asset->Models.Count); Assert(AID->Index == Asset->Id.Index); Assert(AreEqual(&AID->FileNode, &Asset->Id.FileNode)); diff --git a/src/engine/asset.h b/src/engine/asset.h index 72aea4b35..c687e3851 100644 --- a/src/engine/asset.h +++ b/src/engine/asset.h @@ -122,6 +122,7 @@ struct world_chunk_file_header_v3 u8 VoxelElementSize; u8 pad[3]; }; + #pragma pack(pop) typedef world_chunk_file_header_v3 world_chunk_file_header; @@ -160,6 +161,14 @@ poof( ) #endif +enum asset_type +{ + AssetType_Undefined, + + AssetType_Models, + AssetType_WorldChunk, +}; + struct asset { volatile asset_load_state LoadState; @@ -169,7 +178,12 @@ struct asset // TODO(Jesse)(frame-index): Change to u32? At 120fps we get 9k hours (385 days) in a u32 u64 LRUFrameIndex; - model_buffer Models; + asset_type Type; + union + { + model_buffer Models; + world_chunk Chunk; + }; }; typedef asset* asset_ptr; @@ -198,3 +212,74 @@ GetAssetFilenameFor(counted_string AssetPath, world_position WorldP, memory_aren link_internal maybe_model_buffer LoadVoxModels(memory_arena *PermMemory, heap_allocator *Heap, char const *filepath, memory_arena *TempMemory); + +link_inline maybe_v3i +GetDimForAssetModel(asset *Asset, u32 ModelIndex) +{ + maybe_v3i Result = {}; + switch (Asset->Type) + { + InvalidCase(AssetType_Undefined); + + case AssetType_WorldChunk: + { + if (ModelIndex != 0) { Warn("Requested Dim for ModelIndex(%d) on an asset with Type(AssetType_WorldChunk), ignoring ModelIndex", ModelIndex); } + + Result.Tag = Maybe_Yes; + Result.Value = Asset->Chunk.Dim; + } break; + + case AssetType_Models: + { + if (model *Model = GetPtr(&Asset->Models, ModelIndex)) + { + Result.Tag = Maybe_Yes; + Result.Value = Model->Dim; + } + else + { + Warn("Asset did not have a ModelIndex(%d) model!", ModelIndex); + } + } break; + } + + return Result; +} + +link_inline maybe_chunk_data +GetChunkDataForAssetModel(asset *Asset, u32 ModelIndex) +{ + maybe_chunk_data Result = {}; + switch (Asset->Type) + { + InvalidCase(AssetType_Undefined); + + case AssetType_WorldChunk: + { + if (ModelIndex != 0) { Warn("Requested Dim for ModelIndex(%d) on an asset with Type(AssetType_WorldChunk), ignoring ModelIndex", ModelIndex); } + + Result.Tag = Maybe_Yes; + Result.Value = { + .Flags = Asset->Chunk.Flags, + .Dim = Asset->Chunk.Dim, + .Voxels = Asset->Chunk.Voxels, + .VoxelLighting = Asset->Chunk.VoxelLighting, + }; + } break; + + case AssetType_Models: + { + if (model *Model = GetPtr(&Asset->Models, ModelIndex)) + { + Result.Tag = Maybe_Yes; + Result.Value = *Model->Vox.ChunkData; + } + else + { + Warn("Asset did not have a ModelIndex(%d) model!", ModelIndex); + } + } break; + } + + return Result; +} diff --git a/src/engine/asset_loaders.cpp b/src/engine/asset_loaders.cpp index 6851aa940..b45c6336c 100644 --- a/src/engine/asset_loaders.cpp +++ b/src/engine/asset_loaders.cpp @@ -2,26 +2,3 @@ #include #include -#if 0 -link_internal world_chunk -DeserializeChunk(const char *zAssetPath, memory_arena *Memory, chunk_dimension WorldChunkDim) -{ - native_file AssetFile = OpenFile(zAssetPath, "r"); - world_chunk_file_header Header = ReadWorldChunkFileHeader(&AssetFile); - - world_chunk Result = {}; - AllocateWorldChunk(&Result, Memory, {}, WorldChunkDim); - Result.Mesh = AllocateMesh(Memory, (u32)Header.MeshElementCount); - - u32 Tag = Read_u32(&AssetFile); - Assert( Tag == WorldChunkFileTag_VOXD ); - umm VoxByteCount = Header.VoxelElementCount * Header.VoxelElementSize; - ReadBytesIntoBuffer(&AssetFile, VoxByteCount, (u8*)Result.Data->Voxels); - - BuildEntityMesh(Result.Data, Result.Mesh, DefaultPalette, WorldChunkDim); - - CloseFile(&AssetFile); - return Result; -} - -#endif diff --git a/src/engine/bonsai.h b/src/engine/bonsai.h index 1fba2bd45..a41025ac1 100644 --- a/src/engine/bonsai.h +++ b/src/engine/bonsai.h @@ -150,6 +150,7 @@ SetFlag( u8 *Flags, voxel_flag Flag ) inline void SetFlag( chunk_flag *Flags, chunk_flag Flag ) { + Assert( (*Flags & Flag) == 0); *Flags = (chunk_flag)(*Flags | Flag); return; } @@ -308,116 +309,7 @@ Unspawned(entity *Entity) return Result; } -#if 0 -typedef umm packed_voxel; -typedef umm unpacked_voxel; - -inline u8 -GetVoxelColor(packed_voxel *V) -{ - u8 Color = (V->Data >> (FINAL_POSITION_BIT) ) & ~( 0xFFFFFFFF << (COLOR_BIT_WIDTH)); - - Assert(Color < PALETTE_SIZE); - return Color; -} - -inline void -SetVoxelColor(packed_voxel *Voxel, int w) -{ - u32 flagMask = (0xFFFFFFFF << FINAL_COLOR_BIT); - u32 colorMask = ( flagMask | ~(0xFFFFFFFF << (FINAL_POSITION_BIT)) ); - - u32 currentFlags = Voxel->Data & colorMask; - - Voxel->Data = currentFlags; - Voxel->Data |= (w << (FINAL_POSITION_BIT)); - - u8 color = GetVoxelColor(Voxel); - Assert(color == w); -} - -inline voxel_position -GetVoxelP(packed_voxel *V) -{ - voxel_position P = Voxel_Position( - V->Data >> (POSITION_BIT_WIDTH * 0) & 0x000000FF >> (8 - POSITION_BIT_WIDTH), - V->Data >> (POSITION_BIT_WIDTH * 1) & 0x000000FF >> (8 - POSITION_BIT_WIDTH), - V->Data >> (POSITION_BIT_WIDTH * 2) & 0x000000FF >> (8 - POSITION_BIT_WIDTH) - ); - - return P; -} - -inline void -SetVoxelP(packed_voxel *Voxel, voxel_position P) -{ - Assert( P.x < Pow2(POSITION_BIT_WIDTH) ); - Assert( P.y < Pow2(POSITION_BIT_WIDTH) ); - Assert( P.z < Pow2(POSITION_BIT_WIDTH) ); - - int currentFlags = ( Voxel->Data & (0xFFFFFFFF << FINAL_POSITION_BIT)); - Voxel->Data = currentFlags; - - Voxel->Data |= P.x << (POSITION_BIT_WIDTH * 0); - Voxel->Data |= P.y << (POSITION_BIT_WIDTH * 1); - Voxel->Data |= P.z << (POSITION_BIT_WIDTH * 2); - - voxel_position SetP = GetVoxelP(Voxel); - Assert(SetP == P); - - return; -} -inline packed_voxel -PackVoxel(unpacked_voxel *V) -{ - packed_voxel Result = {}; - - Result.Data = V->Flags; // Must come first - - SetVoxelP(&Result, V->Offset); - SetVoxelColor(&Result, V->ColorIndex); - - Result.Data = SetFlag(Result.Data, Voxel_Filled); - - return Result; -} - -inline unpacked_voxel -GetUnpackedVoxel(int x, int y, int z, int w) -{ - unpacked_voxel V; - - V.Offset = Voxel_Position(x,y,z); - V.ColorIndex = w; - V.Flags = (voxel_flag)0; - - return V; -} - -inline packed_voxel -GetPackedVoxel(int x, int y, int z, int w) -{ - packed_voxel Result = {}; - voxel_position P = Voxel_Position(x,y,z); - - SetVoxelP(&Result, P ); - SetVoxelColor(&Result, w); - - Assert(GetVoxelP(&Result) == P); - Assert(GetVoxelColor(&Result) == w); - - return Result; -} - -#endif - -// TODO(Jesse): Delete this -link_internal void -ZeroMesh( untextured_3d_geometry_buffer *Mesh ) -{ - Mesh->At = 0; -} link_internal void ClearWorldChunk( world_chunk *Chunk ) diff --git a/src/engine/debug.cpp b/src/engine/debug.cpp index 9a10880d3..a0eb86b8a 100644 --- a/src/engine/debug.cpp +++ b/src/engine/debug.cpp @@ -130,7 +130,7 @@ DoLevelWindow(engine_resources *Engine) RangeIterator(ChunkIndex, ChunkCount) { world_chunk *Chunk = GetFreeWorldChunk(World); - DeserializeChunk(&LevelBytes, Chunk, &Engine->world_chunk_MeshFreelist, World->ChunkMemory); + DeserializeChunk(&LevelBytes, Chunk, World->ChunkMemory); if (IsInsideVisibleRegion(World, Chunk->WorldP)) { @@ -341,12 +341,116 @@ DoGraphicsDebugWindow(engine_resources *Engine) } link_internal b32 -FilterFilenamesByVoxExtension(file_traversal_node *Node) +FilterFilenamesByLoadableAssetExtensions(file_traversal_node *Node) { - b32 Result = EndsWith(Node->Name, CSz(".vox")); + b32 Result = EndsWith(Node->Name, CSz(".vox")); + Result |= EndsWith(Node->Name, CSz(".chunk")); return Result; } +link_internal void +FilenameModal(void *VoidEngine) +{ + engine_resources *Engine = Cast(engine_resources*, VoidEngine); + UNPACK_ENGINE_RESOURCES(Engine); + + Text(Ui, CSz("Callback")); +} + +link_internal asset_thumbnail* +AllocateAssetThumbnail(platform *Plat, asset_thumbnail_block_array *AssetThumbnails) +{ + v2i ThumbnailDim = V2i(256); + asset_thumbnail BlankThumb = {}; + asset_thumbnail *Thumb = Push(AssetThumbnails, &BlankThumb); + + MakeTexture_RGBA_Async(&Plat->RenderQ, &Thumb->Texture, ThumbnailDim, (u32*)0, CSz("Thumbnail")); + StandardCamera(&Thumb->Camera, 10000.0f, 100.0f, 0.f); + + return Thumb; +} + +link_internal interactable_handle +RenderMeshPreviewToTextureAndInteractWithThumb(engine_resources *Engine, window_layout *Window, asset_thumbnail *Thumb, lod_element_buffer *Meshes, v3 Dim, b32 Selected) +{ + UNPACK_ENGINE_RESOURCES(Engine); + + SyncGpuBuffersAsync(Engine, Meshes); + + texture *Texture = &Thumb->Texture; + camera *ThumbCamera = &Thumb->Camera; + + interactable_handle B = InteractWithThumbnailTexture(Engine, Ui, Window, "asset_texture_viewport", Thumb); + + if (Hover(Ui, &B)) + { + PushRelativeBorder(Ui, V2(Texture->Dim)*V2(-1.f, 1.f), UI_WINDOW_BEZEL_DEFAULT_COLOR, V4(8.f), zDepth_Background); + } + + if (Selected) + { + PushRelativeBorder(Ui, V2(Texture->Dim)*V2(-1.f, 1.f), UI_WINDOW_BEZEL_DEFAULT_COLOR*1.8f, V4(2.f)); + } + + PushForceAdvance(Ui, V2(8, 0)); + + if (Pressed(Ui, &B)) + { + RenderToTexture_Async(&Plat->RenderQ, Engine, Thumb, Meshes, {}, 0); + } + + if (EngineDebug->ResetAssetNodeView) + { + Window->Scroll = {}; + Window->CachedScroll = {}; + + v3 CenterpointOffset = Dim/-2.f; + f32 SmallObjectCorrectionFactor = 350.f/Length(CenterpointOffset); + Thumb->Camera.DistanceFromTarget = LengthSq(CenterpointOffset)*0.50f + SmallObjectCorrectionFactor; + UpdateGameCamera(World, {}, 0.f, {}, &Thumb->Camera, 0.f); + RenderToTexture_Async(&Plat->RenderQ, Engine, Thumb, Meshes, {}, 0); + } + + return B; +} + +link_internal void +RenderMeshPreviewIntoWorld(engine_resources *Engine, lod_element_buffer *Meshes, v3 Dim, b32 Selected) +{ + UNPACK_ENGINE_RESOURCES(Engine); + + if ( Engine->MousedOverVoxel.Tag ) + { + cp EntityOrigin = Canonical_Position(&Engine->MousedOverVoxel.Value); + EntityOrigin.Offset = Round(EntityOrigin.Offset); + + if ( !UiHoveredMouseInput(Ui) && Selected ) + { + // Draw model marking where the asset will go + // + { + // TODO(Jesse): Setting up and tearing down the shader here + // is highly questionable. We should probably keep a list + // of these guys that need this shader, then when we go + // to use it when drawing entities just draw them then.. + // + // That said .. this is just editor code.. so .. meh + // + /* SetupGBufferShader(Graphics, GetApplicationResolution(&Engine->Settings)); */ + + PushBonsaiRenderCommandSetupShader(RenderQ, BonsaiRenderCommand_ShaderId_gBuffer); + + v3 AssetHalfDim = Dim/2.f; + v3 Basis = GetRenderP(Engine, EntityOrigin) + V3(0.f, 0.f, AssetHalfDim.z); + DrawLod_Async(RenderQ, GetEngineResources(), &Graphics->gBuffer->gBufferShader, Meshes, 0.f, Basis, Quaternion(), V3(1)); + + PushBonsaiRenderCommandTeardownShader(RenderQ, BonsaiRenderCommand_ShaderId_gBuffer); + } + + } + } +} + link_internal void DoAssetWindow(engine_resources *Engine) { @@ -357,6 +461,59 @@ DoAssetWindow(engine_resources *Engine) PushWindowStart(Ui, &Window); +#if 0 + if (SelectionComplete(Editor->SelectionClicks)) + { + if (Button(Ui, CSz("New From Selection"), UiId(&Window, "NewFromSelectionButton", 0u))) + { + if (window_layout *Modal = ModalWindowStart(Ui, "New Asset", UiId(&Window, "NewAssetModal", 0u))) + { + char Buf[512]; + TextBox(Ui, CSz("Asset Name"), CS(Buf, 512), 512, UiId(Modal, "AssetNameButton", 0u)); + PushWindowEnd(Ui, Modal); + } + } + PushNewRow(Ui); + } +#endif + if (Button(Ui, CSz("New Asset From Selection"), UiId(&Window, "NewFromSelectionButton", 0u))) + { + Engine->Editor.NewAssetFromSelection = True; + } + + PushNewRow(Ui); + + if (Engine->Editor.NewAssetFromSelection) + { + TextBox(Ui, CSz("Asset Name"), CS(Engine->Editor.NewAssetFromSelectionFilename, 512), 512, UiId(&Window, "AssetNameButton", 0u)); + PushNewRow(Ui); + + if (Button(Ui, CSz("Save"), UiId(&Window, "Save Button", 0u))) + { + cs NewAssetFromSelectionFilename = CS(Engine->Editor.NewAssetFromSelectionFilename); + Engine->Editor.NewAssetFromSelection = False; + + world_chunk SaveChunk = GatherVoxelsOverlappingArea(Engine, Editor->SelectionRegion, GetTranArena()); + + cs SaveName = {}; + if (EndsWith(NewAssetFromSelectionFilename, CSz(".chunk"))) + { + SaveName = NewAssetFromSelectionFilename; + } + else + { + SaveName = Concat(NewAssetFromSelectionFilename, CSz(".chunk"), GetTranArena()); + } + + u8_cursor_block_array Bytes = {}; + + Serialize(&Bytes, &SaveChunk); + WriteToFile(Concat(CSz("models/"), SaveName, GetTranArena()), &Bytes); + /* SerializeChunk(&SaveChunk, Concat(CSz("models/"), SaveName, GetTranArena())); */ + } + } + PushNewRow(Ui); + DoEditorUi(Ui, &Window, &Engine->EngineDebug.AssetWindowViewMode, CSz("View"), &DefaultUiRenderParams_Generic); switch (Engine->EngineDebug.AssetWindowViewMode) @@ -364,7 +521,7 @@ DoAssetWindow(engine_resources *Engine) case AssetWindowViewMode_AssetFiles: { render_settings *Settings = &Graphics->Settings; - filtered_file_traversal_helper_params HelperParams = {&Window, FilterFilenamesByVoxExtension}; + filtered_file_traversal_helper_params HelperParams = {&Window, FilterFilenamesByLoadableAssetExtensions}; maybe_file_traversal_node ClickedFileNode = PlatformTraverseDirectoryTreeUnordered(CSz("models"), EngineDrawFileNodesFilteredHelper, u64(&HelperParams) ); if (ClickedFileNode.Tag) @@ -416,7 +573,6 @@ DoAssetWindow(engine_resources *Engine) WindowLayout("Asset View", window_layout_flags(WindowLayoutFlag_Align_Right)); PushWindowStart(Ui, &AssetViewWindow); - PushTableStart(Ui); if (EngineDebug->SelectedAsset.FileNode.Type) { @@ -440,94 +596,52 @@ DoAssetWindow(engine_resources *Engine) case AssetLoadState_Loaded: { - IterateOver(&Asset->Models, Model, ModelIndex) + switch (Asset->Type) { - SyncGpuBuffersAsync(Engine, &Model->Meshes); + InvalidCase(AssetType_Undefined); - render_entity_to_texture_group *RTTGroup = &Engine->RTTGroup; - if (ModelIndex >= TotalElements(&Editor->AssetThumbnails)) + case AssetType_WorldChunk: { - v2i ThumbnailDim = V2i(128); - asset_thumbnail BlankThumb = {}; - asset_thumbnail *Thumb = Push(&Editor->AssetThumbnails, &BlankThumb); - - MakeTexture_RGBA_Async(&Plat->RenderQ, &Thumb->Texture, ThumbnailDim, (u32*)0, CSz("Thumbnail")); - StandardCamera(&Thumb->Camera, 10000.0f, 100.0f, 0.f); - } - - asset_thumbnail *Thumb = GetPtr(&Editor->AssetThumbnails, ModelIndex); - texture *Texture = &Thumb->Texture; - camera *ThumbCamera = &Thumb->Camera; + render_entity_to_texture_group *RTTGroup = &Engine->RTTGroup; - if (EngineDebug->ResetAssetNodeView) - { - AssetViewWindow.Scroll = {}; - AssetViewWindow.CachedScroll = {}; - - v3 ModelCenterpointOffset = Model->Dim/-2.f; - f32 SmallObjectCorrectionFactor = 350.f/Length(ModelCenterpointOffset); - ThumbCamera->DistanceFromTarget = LengthSq(ModelCenterpointOffset)*0.50f + SmallObjectCorrectionFactor; - UpdateGameCamera(World, {}, 0.f, {}, ThumbCamera, 0.f); - RenderToTexture_Async(&Plat->RenderQ, Engine, Thumb, &Model->Meshes, {}, 0); - } + world_chunk *Chunk = &Asset->Chunk; - interactable_handle B = InteractWithThumbnailTexture(Engine, Ui, &AssetViewWindow, "asset_texture_viewport", Thumb); + asset_thumbnail *Thumb = TryGetPtr(&Editor->AssetThumbnails, 0); + if (Thumb == 0) { Thumb = AllocateAssetThumbnail(Plat, &Editor->AssetThumbnails); } - if (Hover(Ui, &B)) - { - PushRelativeBorder(Ui, V2(Texture->Dim)*V2(-1.f, 1.f), UI_WINDOW_BEZEL_DEFAULT_COLOR, V4(8.f), zDepth_Background); - } + b32 Selected = True; + interactable_handle B = RenderMeshPreviewToTextureAndInteractWithThumb(Engine, &AssetViewWindow, Thumb, &Chunk->Meshes, V3(Chunk->Dim), Selected); + RenderMeshPreviewIntoWorld(Engine, &Chunk->Meshes, V3(Chunk->Dim), Selected); - if (ModelIndex == EngineDebug->ModelIndex) - { - PushRelativeBorder(Ui, V2(Texture->Dim)*V2(-1.f, 1.f), UI_WINDOW_BEZEL_DEFAULT_COLOR*1.8f, V4(2.f)); - } - PushForceAdvance(Ui, V2(8, 0)); + } break; - if (Pressed(Ui, &B)) + case AssetType_Models: { - RenderToTexture_Async(&Plat->RenderQ, Engine, Thumb, &Model->Meshes, {}, 0); - EngineDebug->ModelIndex = ModelIndex; - } + IterateOver(&Asset->Models, Model, ModelIndex) + { + SyncGpuBuffersAsync(Engine, &Model->Meshes); - if ( Engine->MousedOverVoxel.Tag ) - { - cp EntityOrigin = Canonical_Position(&Engine->MousedOverVoxel.Value); - EntityOrigin.Offset = Round(EntityOrigin.Offset); + asset_thumbnail *Thumb = TryGetPtr(&Editor->AssetThumbnails, ModelIndex); + if (Thumb == 0) { Thumb = AllocateAssetThumbnail(Plat, &Editor->AssetThumbnails); } - if ( !UiHoveredMouseInput(Ui) && ModelIndex == EngineDebug->ModelIndex ) - { - v3 AssetHalfDim = V3(Model->Dim)/2.f; + b32 Selected = ModelIndex == EngineDebug->ModelIndex; - // Draw model marking where the asset will go - // + interactable_handle B = RenderMeshPreviewToTextureAndInteractWithThumb(Engine, &AssetViewWindow, Thumb, &Model->Meshes, V3(Model->Dim), Selected); + if (Pressed(Ui, &B)) { - // TODO(Jesse): Setting up and tearing down the shader here - // is highly questionable. We should probably keep a list - // of these guys that need this shader, then when we go - // to use it when drawing entities just draw them then.. - // - // That said .. this is just editor code.. so .. meh - // - /* SetupGBufferShader(Graphics, GetApplicationResolution(&Engine->Settings)); */ - - PushBonsaiRenderCommandSetupShader(RenderQ, BonsaiRenderCommand_ShaderId_gBuffer); + EngineDebug->ModelIndex = ModelIndex; + } - v3 Basis = GetRenderP(Engine, EntityOrigin) + V3(0.f, 0.f, AssetHalfDim.z); - DrawLod_Async(RenderQ, GetEngineResources(), &Graphics->gBuffer->gBufferShader, &Model->Meshes, 0.f, Basis, Quaternion(), V3(1)); + RenderMeshPreviewIntoWorld(Engine, &Model->Meshes, V3(Model->Dim), Selected); - PushBonsaiRenderCommandTeardownShader(RenderQ, BonsaiRenderCommand_ShaderId_gBuffer); + if ( (ModelIndex+1) % 4 == 0) + { + PushNewRow(Ui); + PushForceAdvance(Ui, V2(0, 8)); } - } - } - - if ( (ModelIndex+1) % 4 == 0) - { - PushNewRow(Ui); - PushForceAdvance(Ui, V2(0, 8)); - } + } break; } if (EngineDebug->ResetAssetNodeView) { EngineDebug->ResetAssetNodeView = False; } diff --git a/src/engine/editor.cpp b/src/engine/editor.cpp index 927e6c041..fcee242f1 100644 --- a/src/engine/editor.cpp +++ b/src/engine/editor.cpp @@ -54,8 +54,10 @@ InitEditor(level_editor *Editor) Editor->AssetThumbnails.Memory = Editor->Memory; - /* Editor->Shape.Settings.Type = BrushLayerType_Shape; */ - /* Editor->Noise.Settings.Type = BrushLayerType_Noise; */ + RangeIterator(LayerIndex, MAX_BRUSH_LAYERS) + { + Editor->LayeredBrushEditor.Layers[LayerIndex].Preview.Thumbnail.Texture.Dim = V2i(BRUSH_PREVIEW_TEXTURE_DIM); + } return Result; } @@ -107,6 +109,7 @@ GetUiDebug() return &Global_EngineResources->EngineDebug.UiDebug; } + poof(do_editor_ui_for_compound_type(perlin_noise_params)) #include @@ -292,22 +295,6 @@ poof(do_editor_ui_for_enum(file_traversal_type)) poof(do_editor_ui_for_compound_type(file_traversal_node)) #include -// NOTE(Jesse): Had to hack this slightly because the asset_load_state on Enitity is marked volatile -/* poof(do_editor_ui_for_enum(asset_load_state)) */ -#include - -poof(do_editor_ui_for_compound_type(asset_id)) -#include - -poof(do_editor_ui_for_compound_type(asset)) -#include - -poof(do_editor_ui_for_compound_type(collision_event)) -#include - -poof(do_editor_ui_for_compound_type(entity_position_info)) -#include - // @dirty_entity_P_format_hack // link_internal void @@ -330,6 +317,27 @@ poof(do_editor_ui_for_container(entity_ptr_block_array)) poof(do_editor_ui_for_compound_type(world_chunk)) #include +// NOTE(Jesse): Had to hack this slightly because the asset_load_state on Enitity is marked volatile +/* poof(do_editor_ui_for_enum(asset_load_state)) */ +#include + +poof(do_editor_ui_for_compound_type(asset_id)) +#include + +poof(string_and_value_tables(asset_type)) +#include +poof(do_editor_ui_for_enum(asset_type)) +#include + +poof(do_editor_ui_for_compound_type(asset)) +#include + +poof(do_editor_ui_for_compound_type(collision_event)) +#include + +poof(do_editor_ui_for_compound_type(entity_position_info)) +#include + poof(do_editor_ui_for_compound_type(plane)) #include @@ -1128,7 +1136,7 @@ CheckForChangesAndUpdate_ThenRenderToPreviewTexture(engine_resources *Engine, br if (Layer->Preview.Thumbnail.Texture.ID) // NOTE(Jesse): Avoid spamming a warning to console { - RenderToTexture_world_chunk_Async(&Plat->RenderQ, Engine, &Layer->Preview.Thumbnail, &Chunk->Meshes, V3(Chunk->Dim)/-2.f, 0); + RenderToTexture_Async(&Plat->RenderQ, Engine, &Layer->Preview.Thumbnail, &Chunk->Meshes, V3(Chunk->Dim)/-2.f, 0); } return UpdateVoxels; @@ -1724,7 +1732,10 @@ BrushSettingsForLayeredBrush(engine_resources *Engine, window_layout *BrushSetti { auto Thread = GetThreadLocalState(ThreadLocal_ThreadIndex); auto Chunk = Root_LayeredBrushPreview; - world_chunk_geometry_buffer *TempMesh = AllocateTempWorldChunkMesh(Thread->TempMemory); + + data_type Type = GetMeshDatatypeForDimension(Chunk->Dim); + auto *TempMesh = AllocateTempMesh(Thread->TempMemory, Type); + RebuildWorldChunkMesh(Thread, Chunk, {}, Chunk->Dim, MeshBit_Lod0, TempMesh, Thread->TempMemory); } @@ -2176,39 +2187,55 @@ DoWorldEditor(engine_resources *Engine) if (MaybeAsset.Tag) { asset *Asset = MaybeAsset.Value; - model *Model = GetPtr(&Asset->Models, EngineDebug->ModelIndex); - if (Model) + + switch (Asset->Type) { - v3 AssetHalfDim = V3(Model->Dim)/2.f; - world_update_op_shape_params_asset AssetUpdateShape = - { - EngineDebug->SelectedAsset, - EngineDebug->ModelIndex, - Canonicalize(World, EntityOrigin - V3(AssetHalfDim.xy, 0.f)) - }; + InvalidCase(AssetType_Undefined); - if (Editor->BrushType == WorldEdit_BrushType_Asset) + case AssetType_WorldChunk: + case AssetType_Models: { - world_edit_shape Shape = + maybe_v3i MaybeDim = GetDimForAssetModel(Asset, u32(EngineDebug->ModelIndex)); + if (MaybeDim.Tag) { - type_world_update_op_shape_params_asset, - .world_update_op_shape_params_asset = AssetUpdateShape, - }; - QueueWorldUpdateForRegion(Engine, WorldEdit_Mode_Attach, Editor->Params.Modifier, &Shape, {}, Engine->WorldUpdateMemory); - } - else if (Editor->BrushType == WorldEdit_BrushType_Entity) - { - entity *E = TryGetFreeEntityPtr(Engine->EntityTable); - if (E) + v3 AssetHalfDim = MaybeDim.Value / 2.f; + world_update_op_shape_params_asset AssetUpdateShape = + { + EngineDebug->SelectedAsset, + EngineDebug->ModelIndex, + Canonicalize(World, EntityOrigin - V3(AssetHalfDim.xy, 0.f)) + }; + + if (Editor->BrushType == WorldEdit_BrushType_Asset) + { + world_edit_shape Shape = + { + type_world_update_op_shape_params_asset, + .world_update_op_shape_params_asset = AssetUpdateShape, + }; + QueueWorldUpdateForRegion(Engine, WorldEdit_Mode_Attach, Editor->Params.Modifier, &Shape, {}, Engine->WorldUpdateMemory); + } + else if (Editor->BrushType == WorldEdit_BrushType_Entity) + { + entity *E = TryGetFreeEntityPtr(Engine->EntityTable); + if (E) + { + SpawnEntity(E, &EngineDebug->SelectedAsset, EngineDebug->ModelIndex, EntityBehaviorFlags_Default, 0, &AssetUpdateShape.Origin, AssetHalfDim); + } + } + else + { + InvalidCodePath(); + } + } + else { - SpawnEntity(E, &EngineDebug->SelectedAsset, EngineDebug->ModelIndex, EntityBehaviorFlags_Default, 0, &AssetUpdateShape.Origin, Model->Dim/2.f); + BUG("Somehow requested a ModelIndex from an Asset that did not have one!"); } - } - else - { - InvalidCodePath(); - } + } break; + } + } } } diff --git a/src/engine/editor.h b/src/engine/editor.h index 1ccf4e1ad..89c1aef0e 100644 --- a/src/engine/editor.h +++ b/src/engine/editor.h @@ -489,6 +489,10 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, cp *Value, cs Name, EDITOR_UI DoEditorUi(Ui, Window, &Value->Offset, CSz("Offset")); } +poof(string_and_value_tables(data_type)) +#include +poof(do_editor_ui_for_enum(data_type)) +#include poof(do_editor_ui_for_compound_type(rect3)) #include @@ -960,6 +964,7 @@ struct brush_layer #define NameBuf_Len (256) // TODO(Jesse): Make this dynamic .. probably .. #define MAX_BRUSH_LAYERS 16 +#define BRUSH_PREVIEW_TEXTURE_DIM 256 struct layered_brush_editor poof(@version(2)) { // NOTE(Jesse): This is so we can just copy the name of the brush in here and @@ -1060,6 +1065,9 @@ struct level_editor selection_modification_state Entity; asset_thumbnail_block_array AssetThumbnails; + + b32 NewAssetFromSelection; + char NewAssetFromSelectionFilename[512]; }; diff --git a/src/engine/engine.cpp b/src/engine/engine.cpp index 7ba0ff256..84765813e 100644 --- a/src/engine/engine.cpp +++ b/src/engine/engine.cpp @@ -31,6 +31,7 @@ #include // NOTE(Jesse): generated code for ser/des #include // NOTE(Jesse): Functions acting as basis for ser/des #include +#include #include #include #include diff --git a/src/engine/engine.h b/src/engine/engine.h index 6c4d79417..988f952e6 100644 --- a/src/engine/engine.h +++ b/src/engine/engine.h @@ -42,6 +42,7 @@ link_internal engine_resources *GetEngineResources(); #include #include +#include #include #include #include diff --git a/src/engine/gpu_mapped_buffer.cpp b/src/engine/gpu_mapped_buffer.cpp index 5d4d4c32e..29597c9a5 100644 --- a/src/engine/gpu_mapped_buffer.cpp +++ b/src/engine/gpu_mapped_buffer.cpp @@ -3,53 +3,7 @@ // (immediate geo buffer) we flush and draw immediately afterwards. // // Should probably move to using VAOs so we don't have to do this. -#if 0 -link_inline b32 -FlushBuffersToCard(gpu_element_buffer_handles* Handles) -{ - TIMED_FUNCTION(); - u32 BufferUnmapped = False; - NotImplemented; - - Assert(Handles->Mapped == True); - Handles->Mapped = False; - - AssertNoGlErrors; - - GL.EnableVertexAttribArray(VERTEX_POSITION_LAYOUT_LOCATION); - GL.EnableVertexAttribArray(VERTEX_NORMAL_LAYOUT_LOCATION); - GL.EnableVertexAttribArray(VERTEX_COLOR_LAYOUT_LOCATION); - GL.EnableVertexAttribArray(VERTEX_TRANS_EMISS_LAYOUT_LOCATION); - - AssertNoGlErrors; - - GL.BindBuffer(GL_ARRAY_BUFFER, Handles->VertexHandle); - GL.VertexAttribPointer(VERTEX_POSITION_LAYOUT_LOCATION, 3, GL_FLOAT, GL_FALSE, 0, (void*)0); - u32 BufferUnmapped = GL.UnmapBuffer(GL_ARRAY_BUFFER); - AssertNoGlErrors; - - GL.BindBuffer(GL_ARRAY_BUFFER, Handles->NormalHandle); - GL.VertexAttribPointer(VERTEX_NORMAL_LAYOUT_LOCATION, 3, GL_FLOAT, GL_FALSE, 0, (void*)0); - BufferUnmapped &= GL.UnmapBuffer(GL_ARRAY_BUFFER); - AssertNoGlErrors; - - - // NOTE(Jesse): This is just here to break when the size of these changes, - // serving as a reminder to update this code. - const u32 MtlFloatElements = sizeof(matl)/sizeof(u8); - CAssert(MtlFloatElements == 4); - - GL.BindBuffer(GL_ARRAY_BUFFER, Handles->MatHandle); - GL.VertexAttribIPointer(VERTEX_COLOR_LAYOUT_LOCATION, 1, GL_SHORT, sizeof(matl), Cast(void*, OffsetOf( ColorIndex, matl)) ); - GL.VertexAttribIPointer(VERTEX_TRANS_EMISS_LAYOUT_LOCATION, 2, GL_BYTE, sizeof(matl), Cast(void*, OffsetOf(Transparency, matl)) ); // @vertex_attrib_I_pointer_transparency_offsetof - BufferUnmapped &= GL.UnmapBuffer(GL_ARRAY_BUFFER); - AssertNoGlErrors; - - if (BufferUnmapped == False) { Error("glUnmapBuffer Failed"); } - return BufferUnmapped; -} -#endif - +// link_inline b32 FlushBuffersToCard(gpu_mapped_element_buffer *Buffer) { @@ -67,59 +21,38 @@ FlushBuffersToCard(gpu_mapped_element_buffer *Buffer) AssertNoGlErrors; - GL.BindBuffer(GL_ARRAY_BUFFER, Handles->VertexHandle); - GL.VertexAttribPointer(VERTEX_POSITION_LAYOUT_LOCATION, 3, GL_FLOAT, GL_FALSE, 0, (void*)0); - u32 BufferUnmapped = GL.UnmapBuffer(GL_ARRAY_BUFFER); - AssertNoGlErrors; - - GL.BindBuffer(GL_ARRAY_BUFFER, Handles->NormalHandle); - GL.VertexAttribPointer(VERTEX_NORMAL_LAYOUT_LOCATION, 3, GL_FLOAT, GL_FALSE, 0, (void*)0); - BufferUnmapped &= GL.UnmapBuffer(GL_ARRAY_BUFFER); - AssertNoGlErrors; - - - // NOTE(Jesse): This is just here to break when the size of these changes, - // serving as a reminder to update this code. - const u32 MtlFloatElements = sizeof(matl)/sizeof(u8); - CAssert(MtlFloatElements == 4); - - GL.BindBuffer(GL_ARRAY_BUFFER, Handles->MatHandle); - GL.VertexAttribIPointer(VERTEX_COLOR_LAYOUT_LOCATION, 1, GL_SHORT, sizeof(matl), Cast(void*, OffsetOf( ColorIndex, matl)) ); - GL.VertexAttribIPointer(VERTEX_TRANS_EMISS_LAYOUT_LOCATION, 2, GL_BYTE, sizeof(matl), Cast(void*, OffsetOf(Transparency, matl)) ); // @vertex_attrib_I_pointer_transparency_offsetof - BufferUnmapped &= GL.UnmapBuffer(GL_ARRAY_BUFFER); - AssertNoGlErrors; - - if (BufferUnmapped == False) { Error("glUnmapBuffer Failed"); } - return BufferUnmapped; -} - -link_inline b32 -FlushBuffersToCard(gpu_mapped_world_chunk_geometry_buffer *Buffer) -{ - TIMED_FUNCTION(); - gpu_element_buffer_handles* Handles = &Buffer->Handles; - Assert(Handles->Mapped == True); - Handles->Mapped = False; - - AssertNoGlErrors; - - GL.EnableVertexAttribArray(VERTEX_POSITION_LAYOUT_LOCATION); - GL.EnableVertexAttribArray(VERTEX_NORMAL_LAYOUT_LOCATION); - GL.EnableVertexAttribArray(VERTEX_COLOR_LAYOUT_LOCATION); - GL.EnableVertexAttribArray(VERTEX_TRANS_EMISS_LAYOUT_LOCATION); - - AssertNoGlErrors; - - GL.BindBuffer(GL_ARRAY_BUFFER, Handles->VertexHandle); - GL.VertexAttribIPointer(VERTEX_POSITION_LAYOUT_LOCATION, 3, GL_BYTE, 0, (void*)0); - u32 BufferUnmapped = GL.UnmapBuffer(GL_ARRAY_BUFFER); - AssertNoGlErrors; - - GL.BindBuffer(GL_ARRAY_BUFFER, Handles->NormalHandle); - GL.VertexAttribPointer(VERTEX_NORMAL_LAYOUT_LOCATION, 3, GL_BYTE, GL_TRUE, 0, (void*)0); - BufferUnmapped &= GL.UnmapBuffer(GL_ARRAY_BUFFER); - AssertNoGlErrors; - + u32 BufferUnmapped = 0; + switch (Handles->ElementType) + { + InvalidCase(DataType_Undefinded); + + case DataType_v3: + { + GL.BindBuffer(GL_ARRAY_BUFFER, Handles->VertexHandle); + GL.VertexAttribPointer(VERTEX_POSITION_LAYOUT_LOCATION, 3, GL_FLOAT, GL_FALSE, 0, (void*)0); + BufferUnmapped = GL.UnmapBuffer(GL_ARRAY_BUFFER); + AssertNoGlErrors; + + GL.BindBuffer(GL_ARRAY_BUFFER, Handles->NormalHandle); + GL.VertexAttribPointer(VERTEX_NORMAL_LAYOUT_LOCATION, 3, GL_FLOAT, GL_FALSE, 0, (void*)0); + BufferUnmapped &= GL.UnmapBuffer(GL_ARRAY_BUFFER); + AssertNoGlErrors; + } break; + + case DataType_v3_u8: + { + GL.BindBuffer(GL_ARRAY_BUFFER, Handles->VertexHandle); + GL.VertexAttribIPointer(VERTEX_POSITION_LAYOUT_LOCATION, 3, GL_BYTE, 0, (void*)0); + BufferUnmapped = GL.UnmapBuffer(GL_ARRAY_BUFFER); + AssertNoGlErrors; + + GL.BindBuffer(GL_ARRAY_BUFFER, Handles->NormalHandle); + GL.VertexAttribPointer(VERTEX_NORMAL_LAYOUT_LOCATION, 3, GL_BYTE, GL_TRUE, 0, (void*)0); + BufferUnmapped &= GL.UnmapBuffer(GL_ARRAY_BUFFER); + AssertNoGlErrors; + + } break; + } // NOTE(Jesse): This is just here to break when the size of these changes, // serving as a reminder to update this code. @@ -136,45 +69,75 @@ FlushBuffersToCard(gpu_mapped_world_chunk_geometry_buffer *Buffer) return BufferUnmapped; } - link_internal void -AllocateGpuElementBuffer(gpu_element_buffer_handles *Handles, u32 ElementCount) +AllocateGpuElementBuffer(gpu_element_buffer_handles *Handles, data_type Type, u32 ElementCount) { Assert(ElementCount); Assert(Handles->Mapped == False); + Assert(Handles->ElementType == DataType_Undefinded); - u32 v2Size = sizeof(v2)*ElementCount; - u32 v3Size = sizeof(v3)*ElementCount; u32 matlSize = sizeof(matl)*ElementCount; Assert(Handles->VertexHandle == 0); Assert(Handles->NormalHandle == 0); Assert(Handles->MatHandle == 0); - GL.GenBuffers(3, &Handles->VertexHandle); + Handles->ElementType = Type; Handles->ElementCount = ElementCount; - AssertNoGlErrors; - GL.BindBuffer(GL_ARRAY_BUFFER, Handles->VertexHandle); - GL.BufferData(GL_ARRAY_BUFFER, v3Size, 0, GL_STATIC_DRAW); - AssertNoGlErrors; + switch (Type) + { + InvalidCase(DataType_Undefinded); - GL.BindBuffer(GL_ARRAY_BUFFER, Handles->NormalHandle); - GL.BufferData(GL_ARRAY_BUFFER, v3Size, 0, GL_STATIC_DRAW); - AssertNoGlErrors; + case DataType_v3: + { + u32 v3Size = sizeof(v3)*ElementCount; + GL.GenBuffers(3, &Handles->VertexHandle); + AssertNoGlErrors; - GL.BindBuffer(GL_ARRAY_BUFFER, Handles->MatHandle); - GL.BufferData(GL_ARRAY_BUFFER, matlSize, 0, GL_STATIC_DRAW); - AssertNoGlErrors; + GL.BindBuffer(GL_ARRAY_BUFFER, Handles->VertexHandle); + GL.BufferData(GL_ARRAY_BUFFER, v3Size, 0, GL_STATIC_DRAW); + AssertNoGlErrors; + + GL.BindBuffer(GL_ARRAY_BUFFER, Handles->NormalHandle); + GL.BufferData(GL_ARRAY_BUFFER, v3Size, 0, GL_STATIC_DRAW); + AssertNoGlErrors; + + GL.BindBuffer(GL_ARRAY_BUFFER, Handles->MatHandle); + GL.BufferData(GL_ARRAY_BUFFER, matlSize, 0, GL_STATIC_DRAW); + AssertNoGlErrors; + + } break; + + case DataType_v3_u8: + { + u32 v3u8Size = sizeof(v3_u8)*ElementCount; + GL.GenBuffers(3, &Handles->VertexHandle); + AssertNoGlErrors; + + GL.BindBuffer(GL_ARRAY_BUFFER, Handles->VertexHandle); + GL.BufferData(GL_ARRAY_BUFFER, v3u8Size, 0, GL_STATIC_DRAW); + AssertNoGlErrors; + + GL.BindBuffer(GL_ARRAY_BUFFER, Handles->NormalHandle); + GL.BufferData(GL_ARRAY_BUFFER, v3u8Size, 0, GL_STATIC_DRAW); + AssertNoGlErrors; + + GL.BindBuffer(GL_ARRAY_BUFFER, Handles->MatHandle); + GL.BufferData(GL_ARRAY_BUFFER, matlSize, 0, GL_STATIC_DRAW); + AssertNoGlErrors; + + } break; + } GL.BindBuffer(GL_ARRAY_BUFFER, 0); AssertNoGlErrors; } link_internal void -AllocateGpuElementBuffer(gpu_mapped_element_buffer *GpuMap, u32 ElementCount) +AllocateGpuElementBuffer(gpu_mapped_element_buffer *GpuMap, data_type Type, u32 ElementCount) { - AllocateGpuElementBuffer(&GpuMap->Handles, ElementCount); + AllocateGpuElementBuffer(&GpuMap->Handles, Type, ElementCount); GpuMap->Buffer.End = ElementCount; } @@ -203,32 +166,65 @@ MapGpuBuffer_untextured_3d_geometry_buffer(gpu_element_buffer_handles *Handles) untextured_3d_geometry_buffer Buffer = {}; Buffer.End = Handles->ElementCount; + Buffer.Type = Handles->ElementType; - u32 v2Size = sizeof(v2)*Handles->ElementCount; - u32 v3Size = sizeof(v3)*Handles->ElementCount; - u32 matlSize = sizeof(matl)*Handles->ElementCount; + u32 MaterialBufferSize = sizeof(matl)*Handles->ElementCount; - GL.BindBuffer(GL_ARRAY_BUFFER, Handles->VertexHandle); - AssertNoGlErrors; - Buffer.Verts = (v3*)GL.MapBufferRange(GL_ARRAY_BUFFER, 0, v3Size, GL_MAP_WRITE_BIT); - AssertNoGlErrors; + switch (Handles->ElementType) + { + InvalidCase(DataType_Undefinded); - GL.BindBuffer(GL_ARRAY_BUFFER, Handles->NormalHandle); - AssertNoGlErrors; - Buffer.Normals = (v3*)GL.MapBufferRange(GL_ARRAY_BUFFER, 0, v3Size, GL_MAP_WRITE_BIT); - AssertNoGlErrors; + case DataType_v3: + { + u32 BufferSize = sizeof(v3)*Handles->ElementCount; - // Color data - GL.BindBuffer(GL_ARRAY_BUFFER, Handles->MatHandle); - AssertNoGlErrors; - Buffer.Mat = (matl*)GL.MapBufferRange(GL_ARRAY_BUFFER, 0, matlSize, GL_MAP_WRITE_BIT); - AssertNoGlErrors; + GL.BindBuffer(GL_ARRAY_BUFFER, Handles->VertexHandle); + AssertNoGlErrors; + Buffer.Verts = (v3*)GL.MapBufferRange(GL_ARRAY_BUFFER, 0, BufferSize, GL_MAP_WRITE_BIT); + AssertNoGlErrors; + + GL.BindBuffer(GL_ARRAY_BUFFER, Handles->NormalHandle); + AssertNoGlErrors; + Buffer.Normals = (v3*)GL.MapBufferRange(GL_ARRAY_BUFFER, 0, BufferSize, GL_MAP_WRITE_BIT); + AssertNoGlErrors; + + // Color data + GL.BindBuffer(GL_ARRAY_BUFFER, Handles->MatHandle); + AssertNoGlErrors; + Buffer.Mat = (matl*)GL.MapBufferRange(GL_ARRAY_BUFFER, 0, MaterialBufferSize, GL_MAP_WRITE_BIT); + AssertNoGlErrors; + + } break; + + case DataType_v3_u8: + { + u32 BufferSize = sizeof(v3_u8)*Handles->ElementCount; + + GL.BindBuffer(GL_ARRAY_BUFFER, Handles->VertexHandle); + AssertNoGlErrors; + Buffer.Verts = (v3_u8*)GL.MapBufferRange(GL_ARRAY_BUFFER, 0, BufferSize, GL_MAP_WRITE_BIT); + AssertNoGlErrors; + + GL.BindBuffer(GL_ARRAY_BUFFER, Handles->NormalHandle); + AssertNoGlErrors; + Buffer.Normals = (v3_u8*)GL.MapBufferRange(GL_ARRAY_BUFFER, 0, BufferSize, GL_MAP_WRITE_BIT); + AssertNoGlErrors; + + // Color data + GL.BindBuffer(GL_ARRAY_BUFFER, Handles->MatHandle); + AssertNoGlErrors; + Buffer.Mat = (matl*)GL.MapBufferRange(GL_ARRAY_BUFFER, 0, MaterialBufferSize, GL_MAP_WRITE_BIT); + AssertNoGlErrors; + + } break; + + } if (!Buffer.Verts) { Error("Allocating gpu_mapped_element_buffer::Verts"); } if (!Buffer.Normals) { Error("Allocating gpu_mapped_element_buffer::Normals"); } if (!Buffer.Mat) { Error("Allocating gpu_mapped_element_buffer::Mat"); } - GL.BindBuffer(GL_ARRAY_BUFFER, 0); +GL.BindBuffer(GL_ARRAY_BUFFER, 0); return {*Handles, Buffer}; } @@ -243,58 +239,9 @@ MapGpuBuffer_untextured_3d_geometry_buffer(gpu_mapped_element_buffer *GpuMap) { GpuMap->Buffer.End += GpuMap->Buffer.BufferNeedsToGrow; DeallocateGpuElementBuffer(GpuMap); - AllocateGpuElementBuffer(GpuMap, GpuMap->Buffer.End); + AllocateGpuElementBuffer(GpuMap, GpuMap->Handles.ElementType, GpuMap->Buffer.End); GpuMap->Buffer.BufferNeedsToGrow = 0; } GpuMap->Buffer = MapGpuBuffer_untextured_3d_geometry_buffer(&GpuMap->Handles).Buffer; } - - -link_internal gpu_mapped_world_chunk_geometry_buffer -MapGpuBuffer_world_chunk_geometry_buffer(gpu_element_buffer_handles *Handles) -{ - TIMED_FUNCTION(); - AssertNoGlErrors; - - Assert(Handles->Mapped == False); - Handles->Mapped = True; - - world_chunk_geometry_buffer Buffer = {}; - Buffer.End = Handles->ElementCount; - - u32 v3Size = sizeof(v3)*Handles->ElementCount; - u32 v3u8Size = sizeof(v3_u8)*Handles->ElementCount; - u32 matlSize = sizeof(matl)*Handles->ElementCount; - - GL.BindBuffer(GL_ARRAY_BUFFER, Handles->VertexHandle); - AssertNoGlErrors; - Buffer.Verts = (v3_u8*)GL.MapBufferRange(GL_ARRAY_BUFFER, 0, v3u8Size, GL_MAP_WRITE_BIT); - AssertNoGlErrors; - - GL.BindBuffer(GL_ARRAY_BUFFER, Handles->NormalHandle); - AssertNoGlErrors; - Buffer.Normals = (v3_u8*)GL.MapBufferRange(GL_ARRAY_BUFFER, 0, v3Size, GL_MAP_WRITE_BIT); - AssertNoGlErrors; - - // Color data - GL.BindBuffer(GL_ARRAY_BUFFER, Handles->MatHandle); - AssertNoGlErrors; - Buffer.Mat = (matl*)GL.MapBufferRange(GL_ARRAY_BUFFER, 0, matlSize, GL_MAP_WRITE_BIT); - AssertNoGlErrors; - - if (!Buffer.Verts) { Error("Allocating gpu_mapped_element_buffer::Verts"); } - if (!Buffer.Normals) { Error("Allocating gpu_mapped_element_buffer::Normals"); } - if (!Buffer.Mat) { Error("Allocating gpu_mapped_element_buffer::Mat"); } - - GL.BindBuffer(GL_ARRAY_BUFFER, 0); - - return {*Handles, Buffer}; -} - -link_internal world_chunk_geometry_buffer -MapGpuBuffer_world_chunk_geometry_buffer(gpu_mapped_world_chunk_geometry_buffer *Buffer) -{ - NotImplemented; - return {}; -} diff --git a/src/engine/loaders/collada.cpp b/src/engine/loaders/collada.cpp index 22a1bd8b6..1a1896993 100644 --- a/src/engine/loaders/collada.cpp +++ b/src/engine/loaders/collada.cpp @@ -47,7 +47,8 @@ LoadMeshData(xml_token_stream* XmlTokens, counted_string* GeometryId, memory_are counted_string VertexCountSelector = FormatCountedString(TempMemory, CSz("geometry%.*s polylist vcount"), GeometryId->Count, GeometryId->Start); ansi_stream Triangles = AnsiStream(GetFirstMatchingTag(XmlTokens, &VertexCountSelector)->Value); - untextured_3d_geometry_buffer *Mesh = Allocate_untextured_3d_geometry_buffer(Heap, TotalTriangleCount*3); + untextured_3d_geometry_buffer *Mesh = Allocate_untextured_3d_geometry_buffer(Heap, DataType_v3, TotalTriangleCount*3); + geometry_buffer_stub_v3 Stub = GetBufferStub_v3(Mesh); v3 MaxP = V3(f32_MIN); v3 MinP = V3(f32_MAX); @@ -71,11 +72,11 @@ LoadMeshData(xml_token_stream* XmlTokens, counted_string* GeometryId, memory_are Assert(NormalIndex < TotalElements(&Normals)); v3 P = Positions.Start[PositionIndex]; - Mesh->Verts[Mesh->At] = P; + Stub.Verts[Mesh->At] = P; MaxP = Max(P, MaxP); MinP = Min(P, MinP); - Mesh->Normals[Mesh->At] = Normalize(Normals.Start[NormalIndex]); + Stub.Normals[Mesh->At] = Normalize(Normals.Start[NormalIndex]); Mesh->At++; } diff --git a/src/engine/loaders/obj.cpp b/src/engine/loaders/obj.cpp index b472b2eaa..40b79eecb 100644 --- a/src/engine/loaders/obj.cpp +++ b/src/engine/loaders/obj.cpp @@ -145,15 +145,17 @@ LoadObj(memory_arena *PermMem, heap_allocator *Heap, const char * FilePath) Assert(Remaining(&VertIndicies) == 0 ); Assert(Remaining(&NormalIndicies) == 0 ); - untextured_3d_geometry_buffer *Mesh = Allocate_untextured_3d_geometry_buffer(Heap, Stats.FaceCount*3); + untextured_3d_geometry_buffer *Mesh = Allocate_untextured_3d_geometry_buffer(Heap, DataType_v3, Stats.FaceCount*3); v3 MinV = V3(f32_MAX); v3 MaxV = V3(f32_MIN); + geometry_buffer_stub_v3 Stub = GetBufferStub_v3(Mesh); + u32 VertCount = (u32)AtElements(&VertIndicies); for( u32 Index = 0; - Index < VertCount; - ++Index ) + Index < VertCount; + ++Index ) { u32 vIndex = VertIndicies.Start[Index]; u32 nIndex = NormalIndicies.Start[Index]; @@ -164,8 +166,8 @@ LoadObj(memory_arena *PermMem, heap_allocator *Heap, const char * FilePath) MinV = Min(Vertex, MinV); MaxV = Max(Vertex, MaxV); - Mesh->Verts[Mesh->At] = Vertex; - Mesh->Normals[Mesh->At] = Normal; + Stub.Verts[Mesh->At] = Vertex; + Stub.Normals[Mesh->At] = Normal; Mesh->At++; Assert(Mesh->At <= Mesh->End); diff --git a/src/engine/loaders/vox.cpp b/src/engine/loaders/vox.cpp index 319a1da05..63585a209 100644 --- a/src/engine/loaders/vox.cpp +++ b/src/engine/loaders/vox.cpp @@ -552,21 +552,18 @@ AllocateAndBuildMesh(vox_data *Vox, model *DestModel, memory_arena *TempMemory, chunk_data *ChunkData = Vox->ChunkData; DestModel->Dim = ChunkData->Dim; - geo_u3d *TempMesh0 = AllocateTempMesh(TempMemory); - geo_u3d *TempMesh1 = 0; - /* world_chunk_geometry_buffer *TempMesh1 = AllocateTempWorldChunkMesh(TempMemory); */ + data_type Type = GetMeshDatatypeForDimension(ChunkData->Dim); + geo_u3d *TempMesh = AllocateTempMesh(TempMemory, Type); - BuildWorldChunkMeshFromMarkedVoxels_Greedy(Vox, TempMesh0, TempMesh1, TempMemory, DestModel->Dim/-2.f); + BuildWorldChunkMeshFromMarkedVoxels_Greedy(Vox, TempMesh, 0, TempMemory, DestModel->Dim/-2.f); engine_resources *Engine = GetEngineResources(); - geo_u3d *FinalMesh0 = GetPermMeshForChunk(&Engine->geo_u3d_MeshFreelist, TempMesh0, PermMemory); - /* untextured_3d_geometry_buffer *FinalMesh1 = GetPermMeshForChunk(&Engine->MeshFreelist, TempMesh1, PermMemory); */ + geo_u3d *FinalMesh = GetPermMeshForChunk(&Engine->geo_u3d_MeshFreelist, TempMesh, PermMemory); - BuildWorldChunkMeshFromMarkedVoxels_Greedy(Vox, FinalMesh0, &DestModel->TransparentMesh, TempMemory, V3(DestModel->Dim)/-2.f); + DeepCopy(TempMesh, FinalMesh); - AtomicReplaceMesh(&DestModel->Meshes, MeshBit_Lod0, FinalMesh0, __rdtsc()); - /* AtomicReplaceMesh(&DestModel->TransMeshes, MeshBit_0, FinalMesh1, PermMemory); */ + AtomicReplaceMesh(&DestModel->Meshes, MeshBit_Lod0, FinalMesh, __rdtsc()); } link_internal maybe_model_buffer diff --git a/src/engine/mesh.cpp b/src/engine/mesh.cpp index fb5379eb3..daf885f17 100644 --- a/src/engine/mesh.cpp +++ b/src/engine/mesh.cpp @@ -3,25 +3,37 @@ poof( func mesh_allocator(mesh_t, allocator_t, type_poof_symbol allocate_proc) { link_internal void - AllocateMesh( mesh_t.name *Mesh, u32 NumVerts, allocator_t.name *Memory) + AllocateMesh( mesh_t.name *Mesh, data_type Type, u32 NumVerts, allocator_t.name *Memory) { - mesh_t.map(member) + switch (Type) { - member.has_tag(mesh_allocate)? + InvalidCase(DataType_Undefinded); + + case DataType_v3: { - Mesh->(member.name) = allocate_proc((member.type), Memory, NumVerts, CACHE_LINE_SIZE, False); - } + Mesh->Verts = allocate_proc(v3, Memory, NumVerts, CACHE_LINE_SIZE, False); + Mesh->Normals = allocate_proc(v3, Memory, NumVerts, CACHE_LINE_SIZE, False); + Mesh->Mat = allocate_proc(matl, Memory, NumVerts, CACHE_LINE_SIZE, False); + } break; + + case DataType_v3_u8: + { + Mesh->Verts = allocate_proc(v3_u8, Memory, NumVerts, CACHE_LINE_SIZE, False); + Mesh->Normals = allocate_proc(v3_u8, Memory, NumVerts, CACHE_LINE_SIZE, False); + Mesh->Mat = allocate_proc(matl, Memory, NumVerts, CACHE_LINE_SIZE, False); + } break; } Mesh->End = NumVerts; Mesh->At = 0; + Mesh->Type = Type; } link_internal mesh_t.name* - Allocate_(mesh_t.name)( (allocator_t.name)* Allocator, u32 NumVerts) + Allocate_(mesh_t.name)( (allocator_t.name)* Allocator, data_type Type, u32 NumVerts) { mesh_t.name *Result = allocate_proc((mesh_t.name), Allocator, 1, CACHE_LINE_SIZE, False); - AllocateMesh(Result, NumVerts, Allocator); + AllocateMesh(Result, Type, NumVerts, Allocator); return Result; } @@ -35,8 +47,8 @@ poof(mesh_allocator(untextured_3d_geometry_buffer, memory_arena, {AllocateAligne poof(mesh_allocator(untextured_3d_geometry_buffer, heap_allocator, {HeapAlloc})) #include -poof(mesh_allocator(world_chunk_geometry_buffer, memory_arena, {AllocateAlignedProtection})) -#include +/* poof(mesh_allocator(world_chunk_geometry_buffer, memory_arena, {AllocateAlignedProtection})) */ +/* #include */ link_internal void DeallocateMesh(untextured_3d_geometry_buffer* Mesh, mesh_freelist *MeshFreelist) @@ -72,7 +84,7 @@ DeallocateMesh(void *VoidMesh, tiered_mesh_freelist* MeshFreelist) // untextured_3d_geometry_buffer to work for both buffer types. // // TODO(Jesse): Really don't like relying on this .. should probably find a better way. - CAssert(OffsetOf(End, untextured_3d_geometry_buffer) == OffsetOf(End, world_chunk_geometry_buffer)); + /* CAssert(OffsetOf(End, untextured_3d_geometry_buffer) == OffsetOf(End, world_chunk_geometry_buffer)); */ untextured_3d_geometry_buffer *Mesh = Cast(untextured_3d_geometry_buffer*, VoidMesh); mesh_freelist *Freelist = TryGetTierForSize(MeshFreelist, Mesh->End); @@ -96,6 +108,7 @@ DeallocateMesh(engine_resources *Engine, untextured_3d_geometry_buffer* Mesh) } +#if 0 link_internal void DeallocateMesh(world_chunk_geometry_buffer* Mesh, mesh_freelist *MeshFreelist) { @@ -108,6 +121,7 @@ DeallocateMesh(engine_resources *Engine, world_chunk_geometry_buffer* Mesh) { DeallocateMesh(Mesh, &Engine->world_chunk_MeshFreelist); } +#endif @@ -233,7 +247,7 @@ poof( poof(threadsafe_mesh_container(lod_element_buffer, untextured_3d_geometry_buffer)) #include -poof(threadsafe_mesh_container(world_chunk_lod_element_buffer, world_chunk_geometry_buffer)) -#include +/* poof(threadsafe_mesh_container(world_chunk_lod_element_buffer, world_chunk_geometry_buffer)) */ +/* #include */ diff --git a/src/engine/mesh.h b/src/engine/mesh.h index 739a340a8..48b3a0516 100644 --- a/src/engine/mesh.h +++ b/src/engine/mesh.h @@ -86,8 +86,8 @@ poof( poof(grow_buffer(untextured_3d_geometry_buffer)) #include -poof(grow_buffer(world_chunk_geometry_buffer)) -#include +/* poof(grow_buffer(world_chunk_geometry_buffer)) */ +/* #include */ @@ -117,11 +117,19 @@ PackAndStoreNormal(v3 *Dest, v3 Src) *Dest = Src; } +link_inline void +PackAndStoreNormal(v3 *Dest, v3_u8 Src) +{ + *Dest = V3(Src)/127.f; +} + + // // Scale and Offset (homogeneous normals) // +#if 0 link_inline void BufferVertsDirect( v3_u8 *DestVerts, @@ -130,244 +138,272 @@ BufferVertsDirect( u32 NumVerts, - v3_u8 *SrcVerts, - v3_u8 *SrcNormals, + v3 *SrcVerts, + v3 *SrcNormals, vertex_material *SrcMats, v3 Offset, - v3 Scale + v3 Scale, + Quaternion Rot ) { - TIMED_FUNCTION(); - - __m128 mmScale = _mm_set_ps(0, Scale.z, Scale.y, Scale.x); - __m128 mmOffset = _mm_set_ps(0, Offset.z, Offset.y, Offset.x); - - Assert(NumVerts % 3 == 0); - - /* MemCopy((u8*)SrcNormals, (u8*)DestNormals, sizeof(*SrcNormals)*NumVerts ); */ - MemCopy((u8*)SrcMats, (u8*)DestMats, sizeof(*SrcMats)*NumVerts ); - - for ( u32 VertIndex = 0; - VertIndex < NumVerts; - VertIndex += 3 ) - { - { - auto N0 = SrcNormals[VertIndex + 0]; - auto N1 = SrcNormals[VertIndex + 1]; - auto N2 = SrcNormals[VertIndex + 2]; - PackAndStoreNormal(DestNormals+0, N0); - PackAndStoreNormal(DestNormals+1, N1); - PackAndStoreNormal(DestNormals+2, N2); - DestNormals += 3; - } - - v3_u8 VertSrc0 = SrcVerts[VertIndex + 0]; - v3_u8 VertSrc1 = SrcVerts[VertIndex + 1]; - v3_u8 VertSrc2 = SrcVerts[VertIndex + 2]; - - f32_reg Vert0; - f32_reg Vert1; - f32_reg Vert2; - - Vert0.Sse = _mm_set_ps(0, VertSrc0.z, VertSrc0.y, VertSrc0.x); - Vert1.Sse = _mm_set_ps(0, VertSrc1.z, VertSrc1.y, VertSrc1.x); - Vert2.Sse = _mm_set_ps(0, VertSrc2.z, VertSrc2.y, VertSrc2.x); - - Vert0.Sse = _mm_add_ps( _mm_mul_ps(Vert0.Sse, mmScale), mmOffset); - Vert1.Sse = _mm_add_ps( _mm_mul_ps(Vert1.Sse, mmScale), mmOffset); - Vert2.Sse = _mm_add_ps( _mm_mul_ps(Vert2.Sse, mmScale), mmOffset); - - v3_u8 Result0 = {{ u8(Vert0.F[0]), u8(Vert0.F[1]), u8(Vert0.F[2]) }}; - v3_u8 Result1 = {{ u8(Vert1.F[0]), u8(Vert1.F[1]), u8(Vert1.F[2]) }}; - v3_u8 Result2 = {{ u8(Vert2.F[0]), u8(Vert2.F[1]), u8(Vert2.F[2]) }}; - - DestVerts[0] = Result0; - DestVerts[1] = Result1; - DestVerts[2] = Result2; - - DestVerts += 3; - } + NotImplemented; } - +#endif poof( - func mesh_buffering_functions(mesh_t, vertex_t, element_t) + func copy_vertex_buffer(dest_t, src_t, result_primitive_t) { - // - // Rotate, Scale and Offset + // Offset, Scale, Rotate // - + // TODO(Jesse): Do we actually have to upscale to 32-bit float here for 8 bit types? link_inline void - BufferVertsDirect( - (vertex_t.name) *DestVerts, (vertex_t.name) *DestNormals, vertex_material *DestMats, - u32 NumVerts, - (vertex_t.name) *SrcVerts, v3 *SrcNormals, vertex_material *SrcMats, - v3 Offset, - v3 Scale, - Quaternion Rot ) + CopyVertexBuffer( dest_t.name *Dest, src_t.name *Src, u32 NumVerts, v3 Offset, v3 Scale, Quaternion Rot) { - TIMED_FUNCTION(); + Assert(NumVerts % 3 == 0); __m128 mmScale = _mm_set_ps(0, Scale.z, Scale.y, Scale.x); __m128 mmOffset = _mm_set_ps(0, Offset.z, Offset.y, Offset.x); - Assert(NumVerts % 3 == 0); - - MemCopy((u8*)SrcMats, (u8*)DestMats, sizeof(*SrcMats)*NumVerts ); - - /* v3 HalfOffset = Offset*0.5f; */ for ( u32 VertIndex = 0; VertIndex < NumVerts; VertIndex += 3 ) { - { - auto N0 = Rotate(SrcNormals[VertIndex + 0], Rot); - auto N1 = Rotate(SrcNormals[VertIndex + 1], Rot); - auto N2 = Rotate(SrcNormals[VertIndex + 2], Rot); - - // NOTE(Jesse): This _hopefully_ gets inlined. Should figure out a - // way of asserting that it does, or forcing it to. The functions - // are overloads, but the compiler _should_ be able to figure out - // they can be inlined trivially.. - PackAndStoreNormal(DestNormals+0, N0); - PackAndStoreNormal(DestNormals+1, N1); - PackAndStoreNormal(DestNormals+2, N2); - - DestNormals += 3; - } - { - vertex_t.name VertSrc0 = Rotate(SrcVerts[VertIndex + 0], Rot); - vertex_t.name VertSrc1 = Rotate(SrcVerts[VertIndex + 1], Rot); - vertex_t.name VertSrc2 = Rotate(SrcVerts[VertIndex + 2], Rot); - - f32_reg Vert0; - f32_reg Vert1; - f32_reg Vert2; + auto Src0 = Rotate(Src[VertIndex + 0], Rot); + auto Src1 = Rotate(Src[VertIndex + 1], Rot); + auto Src2 = Rotate(Src[VertIndex + 2], Rot); - Vert0.Sse = _mm_set_ps(0, VertSrc0.z, VertSrc0.y, VertSrc0.x); - Vert1.Sse = _mm_set_ps(0, VertSrc1.z, VertSrc1.y, VertSrc1.x); - Vert2.Sse = _mm_set_ps(0, VertSrc2.z, VertSrc2.y, VertSrc2.x); + f32_reg Vert0; + f32_reg Vert1; + f32_reg Vert2; - Vert0.Sse = _mm_add_ps( _mm_mul_ps(Vert0.Sse, mmScale), mmOffset); - Vert1.Sse = _mm_add_ps( _mm_mul_ps(Vert1.Sse, mmScale), mmOffset); - Vert2.Sse = _mm_add_ps( _mm_mul_ps(Vert2.Sse, mmScale), mmOffset); + Vert0.Sse = _mm_set_ps(0, Src0.z, Src0.y, Src0.x); + Vert1.Sse = _mm_set_ps(0, Src1.z, Src1.y, Src1.x); + Vert2.Sse = _mm_set_ps(0, Src2.z, Src2.y, Src2.x); - vertex_t.name Result0 = {{ element_t.name(Vert0.F[0]), element_t.name(Vert0.F[1]), element_t.name(Vert0.F[2])}}; - vertex_t.name Result1 = {{ element_t.name(Vert1.F[0]), element_t.name(Vert1.F[1]), element_t.name(Vert1.F[2])}}; - vertex_t.name Result2 = {{ element_t.name(Vert2.F[0]), element_t.name(Vert2.F[1]), element_t.name(Vert2.F[2])}}; + Vert0.Sse = _mm_add_ps( _mm_mul_ps(Vert0.Sse, mmScale), mmOffset); + Vert1.Sse = _mm_add_ps( _mm_mul_ps(Vert1.Sse, mmScale), mmOffset); + Vert2.Sse = _mm_add_ps( _mm_mul_ps(Vert2.Sse, mmScale), mmOffset); - DestVerts[0] = Result0; - DestVerts[1] = Result1; - DestVerts[2] = Result2; + dest_t.name Result0 = {{ result_primitive_t.name(Vert0.F[0]), result_primitive_t.name(Vert0.F[1]), result_primitive_t.name(Vert0.F[2]) }}; + dest_t.name Result1 = {{ result_primitive_t.name(Vert1.F[0]), result_primitive_t.name(Vert1.F[1]), result_primitive_t.name(Vert1.F[2]) }}; + dest_t.name Result2 = {{ result_primitive_t.name(Vert2.F[0]), result_primitive_t.name(Vert2.F[1]), result_primitive_t.name(Vert2.F[2]) }}; - DestVerts += 3; - } + Dest[0] = Result0; + Dest[1] = Result1; + Dest[2] = Result2; + Dest += 3; } } // - // Scale and Offset + // Offset, Scale // - link_inline void - BufferVertsDirect( - (vertex_t.name) *DestVerts, (vertex_t.name) *DestNormals, vertex_material *DestMats, - u32 NumVerts, - (vertex_t.name) *SrcVerts, v3 *SrcNormals, vertex_material *SrcMats, - v3 Offset, - v3 Scale - ) + CopyVertexBuffer( dest_t.name *Dest, src_t.name *Src, u32 NumVerts, v3 Offset, v3 Scale ) { - TIMED_FUNCTION(); + Assert(NumVerts % 3 == 0); __m128 mmScale = _mm_set_ps(0, Scale.z, Scale.y, Scale.x); __m128 mmOffset = _mm_set_ps(0, Offset.z, Offset.y, Offset.x); - Assert(NumVerts % 3 == 0); - - /* MemCopy((u8*)SrcNormals, (u8*)DestNormals, sizeof(*SrcNormals)*NumVerts ); */ - MemCopy((u8*)SrcMats, (u8*)DestMats, sizeof(*SrcMats)*NumVerts ); - for ( u32 VertIndex = 0; - VertIndex < NumVerts; - VertIndex += 3 ) + VertIndex < NumVerts; + VertIndex += 3 ) { - { - auto N0 = SrcNormals[VertIndex + 0]; - auto N1 = SrcNormals[VertIndex + 1]; - auto N2 = SrcNormals[VertIndex + 2]; - PackAndStoreNormal(DestNormals+0, N0); - PackAndStoreNormal(DestNormals+1, N1); - PackAndStoreNormal(DestNormals+2, N2); - DestNormals += 3; - } - - vertex_t.name VertSrc0 = SrcVerts[VertIndex + 0]; - vertex_t.name VertSrc1 = SrcVerts[VertIndex + 1]; - vertex_t.name VertSrc2 = SrcVerts[VertIndex + 2]; + auto Src0 = Src[VertIndex + 0]; + auto Src1 = Src[VertIndex + 1]; + auto Src2 = Src[VertIndex + 2]; f32_reg Vert0; f32_reg Vert1; f32_reg Vert2; - Vert0.Sse = _mm_set_ps(0, VertSrc0.z, VertSrc0.y, VertSrc0.x); - Vert1.Sse = _mm_set_ps(0, VertSrc1.z, VertSrc1.y, VertSrc1.x); - Vert2.Sse = _mm_set_ps(0, VertSrc2.z, VertSrc2.y, VertSrc2.x); + Vert0.Sse = _mm_set_ps(0, Src0.z, Src0.y, Src0.x); + Vert1.Sse = _mm_set_ps(0, Src1.z, Src1.y, Src1.x); + Vert2.Sse = _mm_set_ps(0, Src2.z, Src2.y, Src2.x); Vert0.Sse = _mm_add_ps( _mm_mul_ps(Vert0.Sse, mmScale), mmOffset); Vert1.Sse = _mm_add_ps( _mm_mul_ps(Vert1.Sse, mmScale), mmOffset); Vert2.Sse = _mm_add_ps( _mm_mul_ps(Vert2.Sse, mmScale), mmOffset); - vertex_t.name Result0 = {{ element_t.name(Vert0.F[0]), element_t.name(Vert0.F[1]), element_t.name(Vert0.F[2]) }}; - vertex_t.name Result1 = {{ element_t.name(Vert1.F[0]), element_t.name(Vert1.F[1]), element_t.name(Vert1.F[2]) }}; - vertex_t.name Result2 = {{ element_t.name(Vert2.F[0]), element_t.name(Vert2.F[1]), element_t.name(Vert2.F[2]) }}; + dest_t.name Result0 = {{ result_primitive_t.name(Vert0.F[0]), result_primitive_t.name(Vert0.F[1]), result_primitive_t.name(Vert0.F[2]) }}; + dest_t.name Result1 = {{ result_primitive_t.name(Vert1.F[0]), result_primitive_t.name(Vert1.F[1]), result_primitive_t.name(Vert1.F[2]) }}; + dest_t.name Result2 = {{ result_primitive_t.name(Vert2.F[0]), result_primitive_t.name(Vert2.F[1]), result_primitive_t.name(Vert2.F[2]) }}; - DestVerts[0] = Result0; - DestVerts[1] = Result1; - DestVerts[2] = Result2; + Dest[0] = Result0; + Dest[1] = Result1; + Dest[2] = Result2; - DestVerts += 3; + Dest += 3; } } + link_inline void + CopyVertexBuffer( dest_t.name *Dest, src_t.name *Src, u32 NumVerts ) + { + // TODO(Jesse): This conditional isn't working ..? + /* @are_equal(src_t, dest_t)? */ + { + /* MemCopy((u8*)Src, (u8*)Dest, sizeof(*Src)*NumVerts ); */ + } + { + for ( u32 VertIndex = 0; + VertIndex < NumVerts; + VertIndex += 3 ) + { + auto Src0 = Src[VertIndex + 0]; + auto Src1 = Src[VertIndex + 1]; + auto Src2 = Src[VertIndex + 2]; - // - // Untransformed - // + Dest[VertIndex + 0] = dest_t.name.to_capital_case(Src0); + Dest[VertIndex + 1] = dest_t.name.to_capital_case(Src1); + Dest[VertIndex + 2] = dest_t.name.to_capital_case(Src2); + } + } + } + } +) +poof( + func copy_normal_buffer(dest_t, src_t) + { link_inline void - BufferVertsDirect( - (vertex_t.name) *DestVerts, (vertex_t.name) *DestNormals, vertex_material *DestMats, - u32 NumVerts, - (vertex_t.name) *Positions, v3 *Normals, vertex_material *Mats - ) + CopyNormalBuffer( (dest_t.name) *Dest, (src_t.name) *Src, u32 NumVerts, Quaternion Rot) { - TIMED_FUNCTION(); - MemCopy((u8*)Positions, (u8*)DestVerts, sizeof(*Positions)*NumVerts ); - /* MemCopy((u8*)Normals, (u8*)DestNormals, sizeof(*Normals)*NumVerts ); */ - MemCopy((u8*)Mats, (u8*)DestMats, sizeof(*Mats)*NumVerts ); + Assert(NumVerts % 3 == 0); + for ( u32 VertIndex = 0; + VertIndex < NumVerts; + VertIndex += 3 ) + { + { + auto N0 = Rotate(Src[VertIndex + 0], Rot); + auto N1 = Rotate(Src[VertIndex + 1], Rot); + auto N2 = Rotate(Src[VertIndex + 2], Rot); + PackAndStoreNormal(Dest+0, N0); + PackAndStoreNormal(Dest+1, N1); + PackAndStoreNormal(Dest+2, N2); + Dest += 3; + } + } + } - // NOTE(Jesse): Hopefully gets vectorized.. Can't do 4x because triangles - // are 3 elements.. Could do 12 with a cleanup pass.. but meh + link_inline void + CopyNormalBuffer( (dest_t.name) *Dest, (src_t.name) *Src, u32 NumVerts) + { + Assert(NumVerts % 3 == 0); for ( u32 VertIndex = 0; - VertIndex < NumVerts; - VertIndex += 3 ) + VertIndex < NumVerts; + VertIndex += 3 ) { - auto N0 = Normals[VertIndex + 0]; - auto N1 = Normals[VertIndex + 1]; - auto N2 = Normals[VertIndex + 2]; - PackAndStoreNormal(DestNormals+0, N0); - PackAndStoreNormal(DestNormals+1, N1); - PackAndStoreNormal(DestNormals+2, N2); - DestNormals += 3; + { + auto N0 = Src[VertIndex + 0]; + auto N1 = Src[VertIndex + 1]; + auto N2 = Src[VertIndex + 2]; + PackAndStoreNormal(Dest+0, N0); + PackAndStoreNormal(Dest+1, N1); + PackAndStoreNormal(Dest+2, N2); + Dest += 3; + } } } + } +) + +poof(copy_vertex_buffer(v3_u8, v3_u8, u8)) +#include +poof(copy_vertex_buffer(v3_u8, v3, u8)) +#include +poof(copy_vertex_buffer(v3, v3, f32)) +#include +poof(copy_vertex_buffer(v3, v3_u8, f32)) +#include + +poof(copy_normal_buffer(v3_u8, v3_u8)) +#include +poof(copy_normal_buffer(v3_u8, v3)) +#include +poof(copy_normal_buffer(v3, v3)) +#include +poof(copy_normal_buffer(v3, v3_u8)) +#include + + +link_inline void +CopyMaterialBuffer(vertex_material *Dest, vertex_material *Src, u32 NumVerts) +{ + CAssert(sizeof(*Src) == sizeof(*Dest)); + Assert(NumVerts % 3 == 0); + + MemCopy((u8*)Src, (u8*)Dest, sizeof(*Src)*NumVerts ); +} + +link_inline data_type +GetMeshDatatypeForDimension(v3i MeshDim) +{ + Assert(LengthSq(MeshDim) > 0.f); // A negative dimension is nonsense.. + + data_type Result = DataType_v3; + + if (Abs(MeshDim.x) < 127 && Abs(MeshDim.y) < 127 && Abs(MeshDim.z) < 127) + { + Result = DataType_v3_u8; + } + return Result; +} +link_inline void * +GetVertexPointer(untextured_3d_geometry_buffer *Buffer, s32 Offset) +{ + Assert(Offset > 0); + void *Result = 0; + switch (Buffer->Type) + { + InvalidCase(DataType_Undefinded); + case DataType_v3_u8: + { + Result = Cast(v3_u8*, Buffer->Verts) + Offset; + } break; + + case DataType_v3: + { + Result = Cast(v3*, Buffer->Verts) + Offset; + } break; + } + + return Result; +} + +link_inline void * +GetNormalPointer(untextured_3d_geometry_buffer *Buffer, s32 Offset) +{ + Assert(Offset > 0); + + void *Result = 0; + switch (Buffer->Type) + { + InvalidCase(DataType_Undefinded); + case DataType_v3_u8: + { + Result = Cast(v3_u8*, Buffer->Normals) + Offset; + } break; + + case DataType_v3: + { + Result = Cast(v3*, Buffer->Normals) + Offset; + } break; + } + + return Result; +} + +poof( + func checked_vertex_buffering_functions(mesh_t, vertex_t) + { // // Rotate, Scale and Offset // @@ -376,7 +412,7 @@ poof( BufferVertsChecked( (mesh_t.name) *Dest, u32 NumVerts, - (vertex_t.name) *VertsPositions, v3 *Normals, vertex_material *Mats, + (vertex_t.name) *SrcVerts, (vertex_t.name) *SrcNormals, vertex_material *SrcMats, v3 Offset, v3 Scale, Quaternion Rot @@ -385,13 +421,31 @@ poof( TIMED_FUNCTION(); if (BufferHasRoomFor(Dest, NumVerts)) { - BufferVertsDirect(Dest->Verts + Dest->At, - Dest->Normals + Dest->At, - Dest->Mat + Dest->At, - NumVerts, - VertsPositions, Normals, Mats, - Offset, Scale, Rot); - + switch (Dest->Type) + { + InvalidCase(DataType_Undefinded); + case DataType_v3_u8: + { + v3_u8 *DestVerts = Cast(v3_u8*, Dest->Verts) + Dest->At; + v3_u8 *DestNormals = Cast(v3_u8*, Dest->Normals) + Dest->At; + vertex_material *DestMats = Dest->Mat + Dest->At; + + CopyVertexBuffer(DestVerts, SrcVerts, NumVerts, Offset, Scale, Rot); + CopyNormalBuffer(DestNormals, SrcNormals, NumVerts, Rot); + CopyMaterialBuffer(DestMats, SrcMats, NumVerts); + } break; + + case DataType_v3: + { + v3 *DestVerts = Cast(v3*, Dest->Verts) + Dest->At; + v3 *DestNormals = Cast(v3*, Dest->Normals) + Dest->At; + vertex_material *DestMats = Dest->Mat + Dest->At; + + CopyVertexBuffer(DestVerts, SrcVerts, NumVerts, Offset, Scale, Rot); + CopyNormalBuffer(DestNormals, SrcNormals, NumVerts, Rot); + CopyMaterialBuffer(DestMats, SrcMats, NumVerts); + } break; + } Dest->At += NumVerts; } else @@ -410,7 +464,7 @@ poof( BufferVertsChecked( (mesh_t.name) *Dest, u32 NumVerts, - (vertex_t.name) *VertsPositions, v3 *Normals, vertex_material *Mats, + (vertex_t.name) *SrcVerts, (vertex_t.name) *SrcNormals, vertex_material *SrcMats, v3 Offset, v3 Scale ) @@ -418,13 +472,31 @@ poof( TIMED_FUNCTION(); if (BufferHasRoomFor(Dest, NumVerts)) { - BufferVertsDirect(Dest->Verts + Dest->At, - Dest->Normals + Dest->At, - Dest->Mat + Dest->At, - NumVerts, - VertsPositions, Normals, Mats, - Offset, Scale); - + switch (Dest->Type) + { + InvalidCase(DataType_Undefinded); + case DataType_v3_u8: + { + v3_u8 *DestVerts = Cast(v3_u8*, Dest->Verts) + Dest->At; + v3_u8 *DestNormals = Cast(v3_u8*, Dest->Normals) + Dest->At; + vertex_material *DestMats = Dest->Mat + Dest->At; + + CopyVertexBuffer(DestVerts, SrcVerts, NumVerts, Offset, Scale); + CopyNormalBuffer(DestNormals, SrcNormals, NumVerts); + CopyMaterialBuffer(DestMats, SrcMats, NumVerts); + } break; + + case DataType_v3: + { + v3 *DestVerts = Cast(v3*, Dest->Verts) + Dest->At; + v3 *DestNormals = Cast(v3*, Dest->Normals) + Dest->At; + vertex_material *DestMats = Dest->Mat + Dest->At; + + CopyVertexBuffer(DestVerts, SrcVerts, NumVerts, Offset, Scale); + CopyNormalBuffer(DestNormals, SrcNormals, NumVerts); + CopyMaterialBuffer(DestMats, SrcMats, NumVerts); + } break; + } Dest->At += NumVerts; } else @@ -434,126 +506,195 @@ poof( } } + // - // Scale and Offset + // Untransformed // inline void BufferVertsChecked( - (mesh_t.name)* Src, - (mesh_t.name)* Dest, - v3 Offset = V3(0), - v3 Scale = V3(1) + (mesh_t.name) *Dest, + u32 NumVerts, + (vertex_t.name) *SrcVerts, (vertex_t.name) *SrcNormals, vertex_material *SrcMats ) { TIMED_FUNCTION(); - - umm NumVerts = Src->End - Src->At; - if (Dest->At + Src->At <= Dest->End) - { - - BufferVertsDirect(Dest->Verts + Dest->At, - Dest->Normals + Dest->At, - Dest->Mat + Dest->At, - Src->At, - Src->Verts, Src->Normals, Src->Mat, - Offset, Scale); - - Dest->At += Src->At; + if (BufferHasRoomFor(Dest, NumVerts)) + { + switch (Dest->Type) + { + InvalidCase(DataType_Undefinded); + case DataType_v3_u8: + { + v3_u8 *DestVerts = Cast(v3_u8*, Dest->Verts) + Dest->At; + v3_u8 *DestNormals = Cast(v3_u8*, Dest->Normals) + Dest->At; + vertex_material *DestMats = Dest->Mat + Dest->At; + + CopyVertexBuffer(DestVerts, SrcVerts, NumVerts); + CopyNormalBuffer(DestNormals, SrcNormals, NumVerts); + CopyMaterialBuffer(DestMats, SrcMats, NumVerts); + } break; + + case DataType_v3: + { + v3 *DestVerts = Cast(v3*, Dest->Verts) + Dest->At; + v3 *DestNormals = Cast(v3*, Dest->Normals) + Dest->At; + vertex_material *DestMats = Dest->Mat + Dest->At; + + CopyVertexBuffer(DestVerts, SrcVerts, NumVerts); + CopyNormalBuffer(DestNormals, SrcNormals, NumVerts); + CopyMaterialBuffer(DestMats, SrcMats, NumVerts); + } break; + } + Dest->At += NumVerts; } else { if (BufferIsMarkedForGrowth(Dest) == False) { SoftError("Ran out of memory pushing %d Verts onto Mesh with %d/%d used", NumVerts, Dest->At, Dest->End-1); } - MarkBufferForGrowth(Dest, Src->At); + MarkBufferForGrowth(Dest, NumVerts); } } + } +) +poof( + func checked_vertex_buffering_functions_h(mesh_t, vertex_t) + { // - // Untransformed + // Rotate, Scale and Offset // inline void BufferVertsChecked( (mesh_t.name) *Dest, u32 NumVerts, - (vertex_t.name) *VertsPositions, v3 *Normals, vertex_material *Mats - ) - { - TIMED_FUNCTION(); - if (BufferHasRoomFor(Dest, NumVerts)) - { - BufferVertsDirect(Dest->Verts + Dest->At, - Dest->Normals + Dest->At, - Dest->Mat + Dest->At, - NumVerts, - VertsPositions, Normals, Mats); + (vertex_t.name) *SrcVerts, (vertex_t.name) *SrcNormals, vertex_material *SrcMats, + v3 Offset, + v3 Scale, + Quaternion Rot + ); - Dest->At += NumVerts; - } - else - { - if (BufferIsMarkedForGrowth(Dest) == False) { SoftError("Ran out of memory pushing %d Verts onto Mesh with %d/%d used", NumVerts, Dest->At, Dest->End-1); } - MarkBufferForGrowth(Dest, NumVerts); - } - } + // + // Scale and Offset + // + + inline void + BufferVertsChecked( + (mesh_t.name) *Dest, + u32 NumVerts, + (vertex_t.name) *SrcVerts, (vertex_t.name) *SrcNormals, vertex_material *SrcMats, + v3 Offset, + v3 Scale + ); + + // + // Untransformed + // + + inline void + BufferVertsChecked( + (mesh_t.name) *Dest, + u32 NumVerts, + (vertex_t.name) *SrcVerts, (vertex_t.name) *SrcNormals, vertex_material *SrcMats + ); } ) -poof(mesh_buffering_functions(untextured_3d_geometry_buffer, v3, f32)) -#include +/* poof(direct_vertex_buffering_functions(untextured_3d_geometry_buffer, v3)) */ +/* #include */ -poof(mesh_buffering_functions(world_chunk_geometry_buffer, v3_u8, u8)) -#include +/* poof(direct_vertex_buffering_functions(untextured_3d_geometry_buffer, v3_u8)) */ +/* #include */ +poof(checked_vertex_buffering_functions_h(untextured_3d_geometry_buffer, v3)) +#include +poof(checked_vertex_buffering_functions_h(untextured_3d_geometry_buffer, v3_u8)) +#include -link_internal void -BufferFaceData( - world_chunk_geometry_buffer *Dest, - v3_u8 *Positions, v3 *Normals, vertex_material *Mats +inline void +BufferVertsChecked( + untextured_3d_geometry_buffer* Src, + untextured_3d_geometry_buffer* Dest, + v3 Offset = V3(0), // TODO(Jesse): Remove these defaults and make overloads? + v3 Scale = V3(1), + Quaternion Rot = Quaternion() + ); + +poof(checked_vertex_buffering_functions(untextured_3d_geometry_buffer, v3)) +#include +poof(checked_vertex_buffering_functions(untextured_3d_geometry_buffer, v3_u8)) +#include + +// +// Generic Scale and Offset +// + +inline void +BufferVertsChecked( + untextured_3d_geometry_buffer* Src, + untextured_3d_geometry_buffer* Dest, + v3 Offset, // = V3(0), // TODO(Jesse): Remove these defaults and make overloads? + v3 Scale, // = V3(1), + Quaternion Rot // = Quaternion() ) { - if (BufferHasRoomFor(Dest, 6)) + TIMED_FUNCTION(); + + if (BufferHasRoomFor(Dest, Src->At)) { - BufferVertsDirect( - Dest->Verts+Dest->At, Dest->Normals+Dest->At, Dest->Mat+Dest->At, - 6, - Positions, Normals, Mats); - /* MemCopy((u8*)TransEmiss, (u8*)&Dest->TransEmiss[Dest->At], sizeof(*TransEmiss)*NumVerts ); */ + switch (Src->Type) + { + InvalidCase(DataType_Undefinded); + case DataType_v3_u8: + { + v3_u8 *SrcVerts = Cast(v3_u8*, Src->Verts); + v3_u8 *SrcNormals = Cast(v3_u8*, Src->Normals); + vertex_material *SrcMats = Src->Mat; + BufferVertsChecked(Dest, Src->At, SrcVerts, SrcNormals, SrcMats, Offset, Scale, Rot); + } break; + + case DataType_v3: + { + v3 *SrcVerts = Cast(v3*, Src->Verts); + v3 *SrcNormals = Cast(v3*, Src->Normals); + vertex_material *SrcMats = Src->Mat; - Dest->At += 6; + BufferVertsChecked(Dest, Src->At, SrcVerts, SrcNormals, SrcMats, Offset, Scale, Rot); + } break; + } + + Dest->At += Src->At; } else { - // NOTE(Jesse): Supress spamming errors to the console after the first one. - if (BufferIsMarkedForGrowth(Dest) == False) { SoftError("Ran out of memory pushing %d Verts onto Mesh with %d/%d used", 6, Dest->At, Dest->End -1); } - MarkBufferForGrowth(Dest, 6); + if (BufferIsMarkedForGrowth(Dest) == False) { SoftError("Ran out of memory pushing %d Verts onto Mesh with %d/%d used", Src->At, Dest->At, Dest->End-1); } + MarkBufferForGrowth(Dest, Src->At); } } + +/* poof(mesh_buffering_functions(world_chunk_geometry_buffer, v3_u8, u8)) */ +/* #include */ + + +link_internal void +BufferFaceData( + untextured_3d_geometry_buffer *Dest, + v3_u8 *Positions, v3_u8 *Normals, vertex_material *Mats + ) +{ + BufferVertsChecked(Dest, 6, Positions, Normals, Mats); +} + link_internal void BufferFaceData( untextured_3d_geometry_buffer *Dest, v3 *Positions, v3 *Normals, vertex_material *Mats ) { - if (BufferHasRoomFor(Dest, 6)) - { - BufferVertsDirect( - Dest->Verts+Dest->At, Dest->Normals+Dest->At, Dest->Mat+Dest->At, - 6, - Positions, Normals, Mats); - /* MemCopy((u8*)TransEmiss, (u8*)&Dest->TransEmiss[Dest->At], sizeof(*TransEmiss)*NumVerts ); */ - - Dest->At += 6; - } - else - { - // NOTE(Jesse): Supress spamming errors to the console after the first one. - if (BufferIsMarkedForGrowth(Dest) == False) { SoftError("Ran out of memory pushing %d Verts onto Mesh with %d/%d used", 6, Dest->At, Dest->End -1); } - MarkBufferForGrowth(Dest, 6); - } + BufferVertsChecked(Dest, 6, Positions, Normals, Mats); } @@ -567,6 +708,7 @@ inline void DrawVoxel( untextured_3d_geometry_buffer *Mesh, v3 RenderP_VoxelCenter, u16 Color, v3 Diameter, v2 TransEmiss = V2(0.f, 0.f)) { /* TIMED_FUNCTION(); */ + Assert(Mesh->Type == DataType_v3); v3 VertexData[6]; @@ -580,22 +722,22 @@ DrawVoxel( untextured_3d_geometry_buffer *Mesh, v3 RenderP_VoxelCenter, u16 Colo v3 MinP = RenderP_VoxelCenter - (Diameter*0.5f); RightFaceVertexData( MinP, Diameter, VertexData); - BufferVertsChecked(Mesh, 6, VertexData, RightFaceNormalData, Materials); + BufferVertsChecked(Mesh, 6, VertexData, v3_RightFaceNormalData, Materials); LeftFaceVertexData( MinP, Diameter, VertexData); - BufferVertsChecked(Mesh, 6, VertexData, LeftFaceNormalData, Materials); + BufferVertsChecked(Mesh, 6, VertexData, v3_LeftFaceNormalData, Materials); BottomFaceVertexData( MinP, Diameter, VertexData); - BufferVertsChecked(Mesh, 6, VertexData, BottomFaceNormalData, Materials); + BufferVertsChecked(Mesh, 6, VertexData, v3_BottomFaceNormalData, Materials); TopFaceVertexData( MinP, Diameter, VertexData); - BufferVertsChecked(Mesh, 6, VertexData, TopFaceNormalData, Materials); + BufferVertsChecked(Mesh, 6, VertexData, v3_TopFaceNormalData, Materials); FrontFaceVertexData( MinP, Diameter, VertexData); - BufferVertsChecked(Mesh, 6, VertexData, FrontFaceNormalData, Materials); + BufferVertsChecked(Mesh, 6, VertexData, v3_FrontFaceNormalData, Materials); BackFaceVertexData( MinP, Diameter, VertexData); - BufferVertsChecked(Mesh, 6, VertexData, BackFaceNormalData, Materials); + BufferVertsChecked(Mesh, 6, VertexData, v3_BackFaceNormalData, Materials); } inline void diff --git a/src/engine/model.h b/src/engine/model.h index e66d2e57e..df939eaf9 100644 --- a/src/engine/model.h +++ b/src/engine/model.h @@ -56,6 +56,7 @@ poof(string_and_value_tables(model_index)) #include +// TODO(Jesse): Remove // Used when loading .vox files struct vox_data { diff --git a/src/engine/render.cpp b/src/engine/render.cpp index 8895f0183..e1e92cd2a 100644 --- a/src/engine/render.cpp +++ b/src/engine/render.cpp @@ -875,20 +875,38 @@ link_internal void SetupVertexAttribsFor_u3d_geo_element_buffer(gpu_element_buffer_handles *Handles) { AssertNoGlErrors; - GL.EnableVertexAttribArray(VERTEX_POSITION_LAYOUT_LOCATION); GL.EnableVertexAttribArray(VERTEX_NORMAL_LAYOUT_LOCATION); GL.EnableVertexAttribArray(VERTEX_COLOR_LAYOUT_LOCATION); GL.EnableVertexAttribArray(VERTEX_TRANS_EMISS_LAYOUT_LOCATION); AssertNoGlErrors; - GL.BindBuffer(GL_ARRAY_BUFFER, Handles->VertexHandle); - GL.VertexAttribPointer(VERTEX_POSITION_LAYOUT_LOCATION, 3, GL_FLOAT, GL_FALSE, 0, (void*)0); - AssertNoGlErrors; - GL.BindBuffer(GL_ARRAY_BUFFER, Handles->NormalHandle); - GL.VertexAttribPointer(VERTEX_NORMAL_LAYOUT_LOCATION, 3, GL_FLOAT, GL_FALSE, 0, (void*)0); - AssertNoGlErrors; + switch(Handles->ElementType) + { + InvalidCase(DataType_Undefinded); + case DataType_v3: + { + GL.BindBuffer(GL_ARRAY_BUFFER, Handles->VertexHandle); + GL.VertexAttribPointer(VERTEX_POSITION_LAYOUT_LOCATION, 3, GL_FLOAT, GL_FALSE, 0, (void*)0); + AssertNoGlErrors; + + GL.BindBuffer(GL_ARRAY_BUFFER, Handles->NormalHandle); + GL.VertexAttribPointer(VERTEX_NORMAL_LAYOUT_LOCATION, 3, GL_FLOAT, GL_FALSE, 0, (void*)0); + AssertNoGlErrors; + } break; + + case DataType_v3_u8: + { + GL.BindBuffer(GL_ARRAY_BUFFER, Handles->VertexHandle); + GL.VertexAttribPointer(VERTEX_POSITION_LAYOUT_LOCATION, 3, GL_BYTE, GL_FALSE, 0, (void*)0); + AssertNoGlErrors; + + GL.BindBuffer(GL_ARRAY_BUFFER, Handles->NormalHandle); + GL.VertexAttribPointer(VERTEX_NORMAL_LAYOUT_LOCATION, 3, GL_BYTE, GL_TRUE, 0, (void*)0); + AssertNoGlErrors; + } break; + } // NOTE(Jesse): This is just here to break when the size of these changes, @@ -903,6 +921,7 @@ SetupVertexAttribsFor_u3d_geo_element_buffer(gpu_element_buffer_handles *Handles AssertNoGlErrors; } + link_internal void DrawGpuBufferImmediate(gpu_element_buffer_handles *Handles) { @@ -963,10 +982,6 @@ poof( PushReallocateBuffersCommand(&Engine->Stdlib.Plat.RenderQ, Handles, Mesh); Result = True; } - else - { - PushDeallocateBuffersCommand(&Engine->Stdlib.Plat.RenderQ, Handles); - } } } @@ -994,16 +1009,8 @@ poof( { if (Mesh->At) { - // @duplicate_realloc_code - if (Handles->VertexHandle) - { - GL.DeleteBuffers(3, &Handles->VertexHandle); - Clear(Handles); - AssertNoGlErrors; - } - - AllocateGpuElementBuffer(Handles, Mesh->At); - CopyToGpuBuffer(Mesh, Handles); + Handles->Flags |= GpuHandles_UpdatePending; // NOTE(Jesse): Kinda dumb, but this has to be set at the moment.. + ReallocateAndSyncGpuBuffers(Handles, Mesh); Result = True; } else @@ -1027,11 +1034,30 @@ poof( } ) +link_internal void +ReallocateAndSyncGpuBuffers(gpu_element_buffer_handles *Handles, untextured_3d_geometry_buffer *Mesh); + poof(gpu_buffer(lod_element_buffer, untextured_3d_geometry_buffer)) #include -poof(gpu_buffer(world_chunk_lod_element_buffer, world_chunk_geometry_buffer)) -#include +link_internal void +ReallocateAndSyncGpuBuffers(gpu_element_buffer_handles *Handles, untextured_3d_geometry_buffer *Mesh) +{ + Assert(Handles->Flags & GpuHandles_UpdatePending); + + if (Handles->VertexHandle) + { + GL.DeleteBuffers(3, &Handles->VertexHandle); + } + UnsetBitfield(u16, Handles->Flags, GpuHandles_UpdatePending); + Clear(Handles); + + AllocateGpuElementBuffer(Handles, Mesh->Type, Mesh->At); + CopyToGpuBuffer(Mesh, Handles); +} + +/* poof(gpu_buffer(world_chunk_lod_element_buffer, world_chunk_geometry_buffer)) */ +/* #include */ link_internal m4 GetTransformMatrix(v3 Basis, v3 Scale, Quaternion Rotation) @@ -1048,6 +1074,7 @@ GetTransformMatrix(entity *Entity) return Result; } +#if 0 link_internal void DrawLod_world_chunk(engine_resources *Engine, shader *Shader, world_chunk_lod_element_buffer *Meshes, r32 DistanceSquared, v3 Basis, Quaternion Rotation = Quaternion(), v3 Scale = V3(1.f)) { @@ -1105,6 +1132,7 @@ DrawLod_world_chunk(engine_resources *Engine, shader *Shader, world_chunk_lod_el AssertNoGlErrors; } } +#endif link_internal void @@ -1165,6 +1193,7 @@ DrawLod(engine_resources *Engine, shader *Shader, lod_element_buffer *Meshes, r3 } } +#if 0 link_internal void RenderToTexture_world_chunk(engine_resources *Engine, asset_thumbnail *Thumb, world_chunk_lod_element_buffer *Meshes, v3 Offset, camera *Camera = 0) { @@ -1178,6 +1207,7 @@ RenderToTexture_world_chunk(engine_resources *Engine, asset_thumbnail *Thumb, wo Warn("Attempted to render to an unallocated texture."); } } +#endif /* link_internal void */ /* RenderToTexture_Async(engine_resources *Engine, asset_thumbnail *Thumb, world_chunk_lod_element_buffer *Meshes, v3 Offset, camera *Camera = 0) */ @@ -1462,15 +1492,20 @@ RenderDrawList(engine_resources *Engine, world_chunk_ptr_paged_list *DrawList, s IterateOver(DrawList, ChunkPtrPtr, ChunkIndex) { world_chunk *Chunk = *ChunkPtrPtr; - v3 CameraP = GetSimSpaceP(World, Camera->CurrentP); - v3 ChunkP = GetSimSpaceP(World, Chunk->WorldP); - /* SyncGpuBuffersImmediate(Engine, &Chunk->Meshes); */ - AssertNoGlErrors; + // In case gpu meshes got deallocated after the chunk was added to the draw list + if (HasGpuMesh(&Chunk->Meshes)) + { + v3 CameraP = GetSimSpaceP(World, Camera->CurrentP); + v3 ChunkP = GetSimSpaceP(World, Chunk->WorldP); - v3 Basis = GetRenderP(Engine, Chunk->WorldP); - DrawLod_world_chunk(Engine, Shader, &Chunk->Meshes, 0.f, Basis); - AssertNoGlErrors; + /* SyncGpuBuffersImmediate(Engine, &Chunk->Meshes); */ + AssertNoGlErrors; + + v3 Basis = GetRenderP(Engine, Chunk->WorldP); + DrawLod(Engine, Shader, &Chunk->Meshes, 0.f, Basis); + AssertNoGlErrors; + } } } @@ -1581,7 +1616,7 @@ DrawEditorPreview(engine_resources *Engine, shader *Shader) if (Chunk) { /* SyncGpuBuffersImmediate(Engine, &Chunk->Meshes); */ - DrawLod_world_chunk(Engine, Shader, &Chunk->Meshes, 0.f, Basis); + DrawLod(Engine, Shader, &Chunk->Meshes, 0.f, Basis); } } diff --git a/src/engine/render/render_init.cpp b/src/engine/render/render_init.cpp index ee9254801..7cbe34e58 100644 --- a/src/engine/render/render_init.cpp +++ b/src/engine/render/render_init.cpp @@ -503,7 +503,7 @@ link_internal void InitRenderToTextureGroup(render_entity_to_texture_group *Group, texture *ColorPalette, memory_arena *Memory) { // TODO(Jesse): Can this not re-use the immediate mode GpuMap from the 3D renderer? - AllocateGpuElementBuffer(&Group->GeoBuffer, (u32)Megabytes(1)); + AllocateGpuElementBuffer(&Group->GeoBuffer, DataType_v3, (u32)Megabytes(1)); Group->FBO = GenFramebuffer(); GL.BindFramebuffer(GL_FRAMEBUFFER, Group->FBO.ID); @@ -551,7 +551,7 @@ MakeTransparencyShader(v2 *ApplicationResolution, b32 *BravoilMyersOIT, b32 *Bra link_internal void InitTransparencyRenderGroup(render_settings *Settings, transparency_render_group *Group, v2i TextureSize, m4 *ViewProjection, texture *gBufferDepthTexture, texture *ColorPaletteTexture, memory_arena *Memory) { - AllocateGpuElementBuffer(&Group->GpuBuffer, (u32)Megabytes(1)); + AllocateGpuElementBuffer(&Group->GpuBuffer, DataType_v3, (u32)Megabytes(1)); Group->FBO = GenFramebuffer(); GL.BindFramebuffer(GL_FRAMEBUFFER, Group->FBO.ID); @@ -643,8 +643,8 @@ GraphicsInit(graphics *Result, engine_settings *EngineSettings, memory_arena *Gr Result->Camera = &Result->GameCamera; - AllocateGpuElementBuffer(Result->GpuBuffers + 0, (u32)Megabytes(1)); - AllocateGpuElementBuffer(Result->GpuBuffers + 1, (u32)Megabytes(1)); + AllocateGpuElementBuffer(Result->GpuBuffers + 0, DataType_v3, (u32)Megabytes(1)); + AllocateGpuElementBuffer(Result->GpuBuffers + 1, DataType_v3, (u32)Megabytes(1)); g_buffer_render_group *gBuffer = CreateGbuffer(GraphicsMemory); if (!InitGbufferRenderGroup(Result->Settings.iApplicationResolution, gBuffer)) diff --git a/src/engine/render_command.cpp b/src/engine/render_command.cpp index 00d7c6f5c..531129822 100644 --- a/src/engine/render_command.cpp +++ b/src/engine/render_command.cpp @@ -30,14 +30,16 @@ poof(push_render_command(work_queue_entry__bonsai_render_command)) link_internal void PushDeallocateBuffersCommand(work_queue *RenderQueue, gpu_element_buffer_handles *Handles) { - Handles->ElementCount = 0; - Handles->Mapped = 0; + /* Handles->ElementCount = 0; */ + /* Handles->Mapped = 0; */ /* Handles->Flags = GpuHandles_UpdatePending; */ // @vertex_handle_primal if (Handles->VertexHandle) { PushBonsaiRenderCommandDeallocateBuffers(RenderQueue, &Handles->VertexHandle, 3); } + Clear(Handles); } +#if 0 link_internal void PushReallocateBuffersCommand(work_queue *RenderQueue, gpu_element_buffer_handles *Handles, world_chunk_geometry_buffer *Mesh) { @@ -46,10 +48,12 @@ PushReallocateBuffersCommand(work_queue *RenderQueue, gpu_element_buffer_handles work_queue_entry Work = WorkQueueEntry(WorkQueueEntryBonsaiRenderCommand(BonsaiRenderCommandReallocateWorldChunkBuffers(Handles, Mesh))); PushWorkQueueEntry(RenderQueue, &Work); } +#endif link_internal void PushReallocateBuffersCommand(work_queue *RenderQueue, gpu_element_buffer_handles *Handles, untextured_3d_geometry_buffer *Mesh) { + Assert(Mesh->Type); Assert(Mesh->At); Handles->Flags = GpuHandles_UpdatePending; work_queue_entry Work = WorkQueueEntry(WorkQueueEntryBonsaiRenderCommand(BonsaiRenderCommandReallocateBuffers(Handles, Mesh))); diff --git a/src/engine/render_command.h b/src/engine/render_command.h index dac64dd39..df3c4913d 100644 --- a/src/engine/render_command.h +++ b/src/engine/render_command.h @@ -48,11 +48,11 @@ struct bonsai_render_command_reallocate_buffers untextured_3d_geometry_buffer *Mesh; }; -struct bonsai_render_command_reallocate_world_chunk_buffers -{ - gpu_element_buffer_handles *Handles; - world_chunk_geometry_buffer *Mesh; -}; +/* struct bonsai_render_command_reallocate_world_chunk_buffers */ +/* { */ +/* gpu_element_buffer_handles *Handles; */ +/* world_chunk_geometry_buffer *Mesh; */ +/* }; */ struct bonsai_render_command_clear_all_framebuffers @@ -138,7 +138,7 @@ poof( bonsai_render_command_deallocate_world_chunk - bonsai_render_command_reallocate_world_chunk_buffers + /* bonsai_render_command_reallocate_world_chunk_buffers */ bonsai_render_command_do_stuff diff --git a/src/engine/resources.cpp b/src/engine/resources.cpp index 895a2d23d..e0490617e 100644 --- a/src/engine/resources.cpp +++ b/src/engine/resources.cpp @@ -100,39 +100,12 @@ RenderLoop(thread_startup_params *ThreadParams, engine_resources *Engine) NotImplemented; } break; - - { tmatch(bonsai_render_command_reallocate_world_chunk_buffers, RC, Command) - auto *Handles = Command->Handles; - world_chunk_geometry_buffer *Mesh = Command->Mesh; - Assert(Handles->Flags&GpuHandles_UpdatePending); - - // @duplicate_realloc_code - if (Handles->VertexHandle) { GL.DeleteBuffers(3, &Handles->VertexHandle); } - Clear(Handles); - - AllocateGpuElementBuffer(Handles, Mesh->At); - CopyToGpuBuffer(Mesh, Handles); - - DeallocateMesh(Mesh, &Engine->world_chunk_MeshFreelist); - } break; - - { tmatch(bonsai_render_command_reallocate_buffers, RC, Command) auto *Handles = Command->Handles; - untextured_3d_geometry_buffer *Mesh = Command->Mesh; - - // @duplicate_realloc_code - if (Handles->VertexHandle) - { - GL.DeleteBuffers(3, &Handles->VertexHandle); - Clear(Handles); - } - - AllocateGpuElementBuffer(Handles, Mesh->At); - CopyToGpuBuffer(Mesh, Handles); + auto *Mesh = Command->Mesh; + ReallocateAndSyncGpuBuffers(Handles, Mesh); DeallocateMesh(Mesh, &Engine->geo_u3d_MeshFreelist); - UnsetBitfield(u16, Handles->Flags, GpuHandles_UpdatePending); } break; diff --git a/src/engine/resources.h b/src/engine/resources.h index d358bdf03..6a97866b7 100644 --- a/src/engine/resources.h +++ b/src/engine/resources.h @@ -150,17 +150,18 @@ GetCameraGhost(engine_resources *Engine) // TODO(Jesse): make this unpack DT // r32 dt = Plat->dt; -#define UNPACK_DATA_RESOURCES(Res) \ - platform *Plat = &(Res)->Stdlib.Plat; \ - world *World = Res->World; \ - game_state *GameState = Res->GameState; \ - heap_allocator *Heap = &Res->Heap; \ - entity **EntityTable = Res->EntityTable; \ - hotkeys *Hotkeys = &Res->Hotkeys; \ - engine_debug *EngineDebug = &Res->EngineDebug; \ - tiered_mesh_freelist *MeshFreelist = &Res->geo_u3d_MeshFreelist; \ - input *Input = &Res->Stdlib.Plat.Input; \ - level_editor *Editor = &Res->Editor; \ +#define UNPACK_DATA_RESOURCES(Res) \ + platform *Plat = &(Res)->Stdlib.Plat; \ + world *World = Res->World; \ + game_state *GameState = Res->GameState; \ + heap_allocator *Heap = &Res->Heap; \ + entity **EntityTable = Res->EntityTable; \ + hotkeys *Hotkeys = &Res->Hotkeys; \ + engine_debug *EngineDebug = &Res->EngineDebug; \ + tiered_mesh_freelist *MeshFreelist = &Res->geo_u3d_MeshFreelist; \ + input *Input = &Res->Stdlib.Plat.Input; \ + level_editor *Editor = &Res->Editor; \ + work_queue *WorldUpdateQ = &Plat->WorldUpdateQ; \ #define UNPACK_GRAPHICS_RESOURCES(Res) \ graphics *Graphics = &Res->Graphics; \ diff --git a/src/engine/serdes.cpp b/src/engine/serdes.cpp index 0b1704545..c40f27c08 100644 --- a/src/engine/serdes.cpp +++ b/src/engine/serdes.cpp @@ -46,6 +46,9 @@ poof(serdes_struct(voxel_lighting)) /* poof(serdes_array(voxel_lighting)) */ /* #include */ +poof(serdes_struct(world_chunk)) +#include + /* poof(serdes_array(v3)) */ /* #include */ @@ -192,9 +195,10 @@ Serialize(u8_cursor_block_array *Bytes, untextured_3d_geometry_buffer *Data) umm ElementCount = umm(Data->At); if (ElementCount) { - Result &= Serialize(Bytes, Data->Verts, ElementCount); - Result &= Serialize(Bytes, Data->Normals, ElementCount); - Result &= Serialize(Bytes, Data->Mat, ElementCount); + u32 ElementSize = DataTypeToElementSize[Data->Type]; + Result &= Serialize(Bytes, Cast(u8*, Data->Verts), ElementSize*ElementCount); + Result &= Serialize(Bytes, Cast(u8*, Data->Normals), ElementSize*ElementCount); + Result &= Serialize(Bytes, Data->Mat, ElementCount); } #endif @@ -216,9 +220,10 @@ Deserialize(u8_stream *Bytes, untextured_3d_geometry_buffer *Data, memory_arena if (ElementCount) { - Result &= Deserialize(Bytes, Data->Verts, Memory, ElementCount); - Result &= Deserialize(Bytes, Data->Normals, Memory, ElementCount); - Result &= Deserialize(Bytes, Data->Mat, Memory, ElementCount); + u32 ElementSize = DataTypeToElementSize[Data->Type]; + Result &= Deserialize(Bytes, Cast(u8*, Data->Verts), Memory, ElementSize*ElementCount); + Result &= Deserialize(Bytes, Cast(u8*, Data->Normals), Memory, ElementSize*ElementCount); + Result &= Deserialize(Bytes, Data->Mat, Memory, ElementCount); } #endif diff --git a/src/engine/serdes.h b/src/engine/serdes.h index 93b4fe6be..82d728294 100644 --- a/src/engine/serdes.h +++ b/src/engine/serdes.h @@ -477,3 +477,7 @@ Deserialize(u8_cursor *Bytes, cs *Element, memory_arena *Memory) poof(serdes_primitive({u8 s8 u16 s16 u32 s32 u64 s64 b8 r32 r64})) #include + +struct world_chunk; +link_internal b32 +Deserialize(u8_cursor *Bytes, world_chunk *Element, memory_arena *Memory, umm Count); diff --git a/src/engine/voxel_face.h b/src/engine/voxel_face.h index 2759b83ea..106b44300 100644 --- a/src/engine/voxel_face.h +++ b/src/engine/voxel_face.h @@ -32,12 +32,19 @@ global_variable v3 FrontPlane = {{ 1.f, 0.f, 1.f }}; global_variable v3 BackPlane = {{ 1.f, 0.f, 1.f }}; -global_variable v3 RightFaceNormalData[] = { {{1, 0, 0}}, {{1, 0, 0}}, {{1, 0, 0}}, {{1, 0, 0}}, {{1, 0, 0}}, {{1, 0, 0}} }; -global_variable v3 LeftFaceNormalData[] = { {{-1, 0, 0}}, {{-1, 0, 0}}, {{-1, 0, 0}}, {{-1, 0, 0}}, {{-1, 0, 0}}, {{-1, 0, 0}}, }; -global_variable v3 BackFaceNormalData[] = { {{0,-1, 0}}, {{0,-1, 0}}, {{0,-1, 0}}, {{0,-1, 0}}, {{0,-1, 0}}, {{0,-1, 0}}, }; -global_variable v3 FrontFaceNormalData[] = { {{0, 1, 0}}, {{0, 1, 0}}, {{0, 1, 0}}, {{0, 1, 0}}, {{0, 1, 0}}, {{0, 1, 0}}, }; -global_variable v3 TopFaceNormalData[] = { {{0, 0, 1}}, {{0, 0, 1}}, {{0, 0, 1}}, {{0, 0, 1}}, {{0, 0, 1}}, {{0, 0, 1}}, }; -global_variable v3 BottomFaceNormalData[] = { {{0, 0, -1}}, {{0, 0, -1}}, {{0, 0, -1}}, {{0, 0, -1}}, {{0, 0, -1}}, {{0, 0, -1}}, }; +global_variable v3 v3_RightFaceNormalData[] = { {{ 1, 0, 0}}, {{ 1, 0, 0}}, {{ 1, 0, 0}}, {{ 1, 0, 0}}, {{ 1, 0, 0}}, {{ 1, 0, 0}} }; +global_variable v3 v3_LeftFaceNormalData[] = { {{ -1, 0, 0}}, {{ -1, 0, 0}}, {{ -1, 0, 0}}, {{ -1, 0, 0}}, {{ -1, 0, 0}}, {{ -1, 0, 0}}, }; +global_variable v3 v3_BackFaceNormalData[] = { {{ 0, -1, 0}}, {{ 0, -1, 0}}, {{ 0, -1, 0}}, {{ 0, -1, 0}}, {{ 0, -1, 0}}, {{ 0, -1, 0}}, }; +global_variable v3 v3_FrontFaceNormalData[] = { {{ 0, 1, 0}}, {{ 0, 1, 0}}, {{ 0, 1, 0}}, {{ 0, 1, 0}}, {{ 0, 1, 0}}, {{ 0, 1, 0}}, }; +global_variable v3 v3_TopFaceNormalData[] = { {{ 0, 0, 1}}, {{ 0, 0, 1}}, {{ 0, 0, 1}}, {{ 0, 0, 1}}, {{ 0, 0, 1}}, {{ 0, 0, 1}}, }; +global_variable v3 v3_BottomFaceNormalData[] = { {{ 0, 0, -1}}, {{ 0, 0, -1}}, {{ 0, 0, -1}}, {{ 0, 0, -1}}, {{ 0, 0, -1}}, {{ 0, 0, -1}}, }; + +global_variable v3_u8 v3_u8_RightFaceNormalData[] = { {{ 127, 0, 0}}, {{ 127, 0, 0}}, {{ 127, 0, 0}}, {{ 127, 0, 0}}, {{ 127, 0, 0}}, {{ 127, 0, 0}} }; +global_variable v3_u8 v3_u8_LeftFaceNormalData[] = { {{ 255, 0, 0}}, {{ 255, 0, 0}}, {{ 255, 0, 0}}, {{ 255, 0, 0}}, {{ 255, 0, 0}}, {{ 255, 0, 0}}, }; +global_variable v3_u8 v3_u8_BackFaceNormalData[] = { {{ 0, 255, 0}}, {{ 0, 255, 0}}, {{ 0, 255, 0}}, {{ 0, 255, 0}}, {{ 0, 255, 0}}, {{ 0, 255, 0}}, }; +global_variable v3_u8 v3_u8_FrontFaceNormalData[] = { {{ 0, 127, 0}}, {{ 0, 127, 0}}, {{ 0, 127, 0}}, {{ 0, 127, 0}}, {{ 0, 127, 0}}, {{ 0, 127, 0}}, }; +global_variable v3_u8 v3_u8_TopFaceNormalData[] = { {{ 0, 0, 127}}, {{ 0, 0, 127}}, {{ 0, 0, 127}}, {{ 0, 0, 127}}, {{ 0, 0, 127}}, {{ 0, 0, 127}}, }; +global_variable v3_u8 v3_u8_BottomFaceNormalData[] = { {{ 0, 0, 255}}, {{ 0, 0, 255}}, {{ 0, 0, 255}}, {{ 0, 0, 255}}, {{ 0, 0, 255}}, {{ 0, 0, 255}}, }; diff --git a/src/engine/voxel_synthesis.cpp b/src/engine/voxel_synthesis.cpp index 1741ea290..0eb311904 100644 --- a/src/engine/voxel_synthesis.cpp +++ b/src/engine/voxel_synthesis.cpp @@ -55,9 +55,6 @@ BakeVoxelSynthesisRules(const char* InputVox) DEBUG_REGISTER_NAMED_ARENA(Memory, ThreadLocal_ThreadIndex, "VoxelSynthesisArena"); heap_allocator Heap = InitHeap(Gigabytes(2)); - /* Global_ThreadStates = Initialize_ThreadLocal_ThreadStates((s32)GetTotalThreadCount(), 0, Memory); */ - /* SetThreadLocal_ThreadIndex(0); */ - Info("Synthesizing rules for (%s)", InputVox); /* vox_data Vox = LoadVoxData(Memory, &Heap, InputVox, Global_TileDim*2, Global_TileDim*2); */ diff --git a/src/engine/voxel_synthesis.h b/src/engine/voxel_synthesis.h index 3dab29103..21926fccd 100644 --- a/src/engine/voxel_synthesis.h +++ b/src/engine/voxel_synthesis.h @@ -10,23 +10,6 @@ global_variable v3i AllDirections[] = { global_variable v3i Global_TileDim = V3i(8); -// NOTE(Jesse): This is more-or-less duplicated in the face_index enum. Coalesce them? -// @duplicate_face_index_enum -enum voxel_rule_direction -{ - VoxelRuleDir_PosX, - VoxelRuleDir_NegX, - - VoxelRuleDir_PosY, - VoxelRuleDir_NegY, - - VoxelRuleDir_PosZ, - VoxelRuleDir_NegZ, - - VoxelRuleDir_Count, -}; -CAssert(VoxelRuleDir_Count == 6); - struct tile_rule_id { u8 PageIndex; diff --git a/src/engine/work_queue.cpp b/src/engine/work_queue.cpp index 7582acbe1..ebf13cb94 100644 --- a/src/engine/work_queue.cpp +++ b/src/engine/work_queue.cpp @@ -64,50 +64,10 @@ CancelAllWorkQueueJobs(platform *Plat, work_queue *Queue) Assert(FutexIsSignaled(&Plat->WorkerThreadsSuspendFutex)); Assert(Plat->WorkerThreadsSuspendFutex.ThreadsWaiting == GetWorkerThreadCount()); - // TODO(Jesse)(critical, bug): Why does the following not work? We get - // assertions that we didn't clear a world chunk queued flag sometimes. - // nopush - // // TODO(Jesse): Might as well use memset? RangeIterator(EntryIndex, WORK_QUEUE_SIZE) - /* while (!QueueIsEmpty(Queue)) */ { - /* work_queue_entry *Entry = Cast(work_queue_entry*, Queue->Entries + Queue->DequeueIndex); */ work_queue_entry *Entry = Cast(work_queue_entry*, Queue->Entries + EntryIndex); - -#if 0 - work_queue_entry_type Type = Entry->Type; - switch (Type) - { - /* InvalidCase(type_work_queue_entry_noop); */ - InvalidCase(type_work_queue_entry__align_to_cache_line_helper); - - case type_work_queue_entry_noop: { } break; - - case type_work_queue_entry_copy_buffer_ref: - case type_work_queue_entry_copy_buffer_set: - case type_work_queue_entry_init_asset: - case type_work_queue_entry_update_world_region: - case type_work_queue_entry_sim_particle_system: - { - } break; - - case type_work_queue_entry_rebuild_mesh: - { - work_queue_entry_rebuild_mesh *Job = SafeAccess(work_queue_entry_rebuild_mesh, Entry); - world_chunk *Chunk = Job->Chunk; - Chunk->Flags = chunk_flag(Chunk->Flags & ~Chunk_Queued); - } break; - - case type_work_queue_entry_init_world_chunk: - { - work_queue_entry_init_world_chunk *Job = SafeAccess(work_queue_entry_init_world_chunk, Entry); - world_chunk *Chunk = Job->Chunk; - Chunk->Flags = chunk_flag(Chunk->Flags & ~Chunk_Queued); - } break; - } -#endif - *Entry = {}; } diff --git a/src/engine/work_queue.h b/src/engine/work_queue.h index 0e51055f9..7a6eec169 100644 --- a/src/engine/work_queue.h +++ b/src/engine/work_queue.h @@ -206,9 +206,6 @@ poof( } ) -link_internal void -RenderToTexture_world_chunk_Async(work_queue *Queue,engine_resources *Engine ,asset_thumbnail *Thumb ,world_chunk_lod_element_buffer *Meshes ,v3 Offset ,camera *Camera ); - link_internal void DrawLod(engine_resources *Engine, shader *Shader, lod_element_buffer *Meshes, r32 DistanceSquared, v3 Basis, Quaternion Rotation = Quaternion(), v3 Scale = V3(1.f)); @@ -236,9 +233,6 @@ poof( ) -poof(asyncify_render_function_h(RenderToTexture_world_chunk)) -#include - poof(asyncify_render_function_h(RenderToTexture)) #include @@ -359,15 +353,9 @@ poof( ) #include -link_internal void -RenderToTexture_world_chunk(engine_resources *Engine, asset_thumbnail *Thumb, world_chunk_lod_element_buffer *Meshes, v3 Offset, camera *Camera); - link_internal void RenderToTexture(engine_resources *Engine, asset_thumbnail *Thumb, lod_element_buffer *Meshes, v3 Offset, camera *Camera); -poof(asyncify_render_function_c(RenderToTexture_world_chunk)) -#include - poof(asyncify_render_function_c(RenderToTexture)) #include @@ -385,11 +373,6 @@ DispatchAsyncFunctionCall(work_queue_entry_async_function_call *Job) DoJob(RenderToTexture); } break; - { - tmatch(render_to_texture_world_chunk_async_params, Job, RenderToTexture); - DoJob(RenderToTexture); - } break; - { tmatch(draw_lod_async_params, Job, DrawLodParams); DoJob(DrawLodParams); diff --git a/src/engine/world_chunk.cpp b/src/engine/world_chunk.cpp index dbb52f077..2b3574c87 100644 --- a/src/engine/world_chunk.cpp +++ b/src/engine/world_chunk.cpp @@ -289,23 +289,6 @@ GetAndInsertFreeWorldChunk(world *World, world_position P) return Result; } -link_internal void -FreeGpuBuffers(world_chunk *Chunk) -{ - NotImplemented; - /* Assert(Chunk->Flags & Chunk_MeshUploadedToGpu); */ - /* { */ - /* RangeIterator(MeshIndex, MeshIndex_Count) */ - /* { */ - /* world_chunk_mesh_bitfield MeshBit = world_chunk_mesh_bitfield(1 << MeshIndex); */ - /* if (HasMesh(&Chunk->Meshes, MeshBit)) */ - /* { */ - /* DeallocateGpuElementBuffer(&Chunk->GpuBuffers[MeshIndex]); */ - /* } */ - /* } */ - /* } */ -} - link_internal void DeallocateGpuBuffers(work_queue *RenderQueue, world_chunk *Chunk ) { @@ -317,14 +300,6 @@ DeallocateGpuBuffers(work_queue *RenderQueue, world_chunk *Chunk ) } } -#if 0 -link_internal void -DeallocateWorldChunk(work_queue *RenderQueue, world_chunk *Chunk, tiered_mesh_freelist *MeshFreelist) -{ - PushBonsaiRenderCommandDeallocateWorldChunk( &Plat->RenderQ, Chunk); -} -#endif - link_internal void PushBonsaiRenderCommandDeallocateWorldChunk( work_queue *RenderQueue, world_chunk* Chunk); link_internal void @@ -1248,6 +1223,8 @@ DrawDebugVoxels( voxel *Voxels, { TIMED_FUNCTION(); + Assert(DestGeometry->Type == DataType_v3); + /* Assert(IsSet(SrcChunk, Chunk_VoxelsInitialized)); */ /* Assert(IsSet(DestChunk, Chunk_VoxelsInitialized)); */ @@ -1289,32 +1266,32 @@ DrawDebugVoxels( voxel *Voxels, if (Voxel->Flags & Voxel_RightFace) { RightFaceVertexData( V3(SrcP-SrcChunkMin), Diameter, VertexData); - BufferFaceData(DestGeometry, VertexData, RightFaceNormalData, Materials); + BufferFaceData(DestGeometry, VertexData, v3_RightFaceNormalData, Materials); } if (Voxel->Flags & Voxel_LeftFace) { LeftFaceVertexData( V3(SrcP-SrcChunkMin), Diameter, VertexData); - BufferFaceData(DestGeometry, VertexData, LeftFaceNormalData, Materials); + BufferFaceData(DestGeometry, VertexData, v3_LeftFaceNormalData, Materials); } if (Voxel->Flags & Voxel_BottomFace) { BottomFaceVertexData( V3(SrcP-SrcChunkMin), Diameter, VertexData); - BufferFaceData(DestGeometry, VertexData, BottomFaceNormalData, Materials); + BufferFaceData(DestGeometry, VertexData, v3_BottomFaceNormalData, Materials); } if (Voxel->Flags & Voxel_TopFace) { TopFaceVertexData( V3(SrcP-SrcChunkMin), Diameter, VertexData); - BufferFaceData(DestGeometry, VertexData, TopFaceNormalData, Materials); + BufferFaceData(DestGeometry, VertexData, v3_TopFaceNormalData, Materials); } if (Voxel->Flags & Voxel_FrontFace) { FrontFaceVertexData( V3(SrcP-SrcChunkMin), Diameter, VertexData); - BufferFaceData(DestGeometry, VertexData, FrontFaceNormalData, Materials); + BufferFaceData(DestGeometry, VertexData, v3_FrontFaceNormalData, Materials); } if (Voxel->Flags & Voxel_BackFace) { BackFaceVertexData( V3(SrcP-SrcChunkMin), Diameter, VertexData); - BufferFaceData(DestGeometry, VertexData, BackFaceNormalData, Materials); + BufferFaceData(DestGeometry, VertexData, v3_BackFaceNormalData, Materials); } } } @@ -1590,7 +1567,7 @@ poof( func world_chunk_mesh_functions(buffer_t, vert_t) { link_internal void - BuildWorldChunkMeshFromMarkedVoxels_Greedy( voxel *Voxels, + BuildWorldChunkMeshFromMarkedVoxels_Greedy_(vert_t.name)( voxel *Voxels, v3i SrcChunkDim, v3i SrcChunkMin, @@ -1608,6 +1585,7 @@ poof( /* HISTOGRAM_FUNCTION(); */ TIMED_FUNCTION(); + Assert(DestGeometry->Type == DataType_(vert_t.name)); vert_t.name VertexData[VERTS_PER_FACE]; matl Materials[VERTS_PER_FACE]; @@ -1670,38 +1648,38 @@ poof( { v3 Dim = DoXStepping(TempVoxels, TmpDim, TmpVoxP, Voxel_RightFace, Voxel->Color, Voxel->Transparency); RightFaceVertexData( VertexOffset+TmpVoxP, Dim, VertexData); - BufferFaceData(Dest, VertexData, RightFaceNormalData, Materials); + BufferFaceData(Dest, VertexData, (vert_t.name)_RightFaceNormalData, Materials); } if (Voxel->Flags & Voxel_LeftFace) { v3 Dim = DoXStepping(TempVoxels, TmpDim, TmpVoxP, Voxel_LeftFace, Voxel->Color, Voxel->Transparency); LeftFaceVertexData( VertexOffset+TmpVoxP, Dim, VertexData); - BufferFaceData(Dest, VertexData, LeftFaceNormalData, Materials); + BufferFaceData(Dest, VertexData, (vert_t.name)_LeftFaceNormalData, Materials); } if (Voxel->Flags & Voxel_BottomFace) { v3 Dim = DoZStepping(TempVoxels, TmpDim, TmpVoxP, Voxel_BottomFace, Voxel->Color, Voxel->Transparency); BottomFaceVertexData( VertexOffset+TmpVoxP, Dim, VertexData); - BufferFaceData(Dest, VertexData, BottomFaceNormalData, Materials); + BufferFaceData(Dest, VertexData, (vert_t.name)_BottomFaceNormalData, Materials); } if (Voxel->Flags & Voxel_TopFace) { v3 Dim = DoZStepping(TempVoxels, TmpDim, TmpVoxP, Voxel_TopFace, Voxel->Color, Voxel->Transparency); TopFaceVertexData( VertexOffset+TmpVoxP, Dim, VertexData); - BufferFaceData(Dest, VertexData, TopFaceNormalData, Materials); + BufferFaceData(Dest, VertexData, (vert_t.name)_TopFaceNormalData, Materials); } if (Voxel->Flags & Voxel_FrontFace) { v3 Dim = DoYStepping(TempVoxels, TmpDim, TmpVoxP, Voxel_FrontFace, Voxel->Color, Voxel->Transparency); FrontFaceVertexData( VertexOffset+TmpVoxP, Dim, VertexData); - BufferFaceData(Dest, VertexData, FrontFaceNormalData, Materials); + BufferFaceData(Dest, VertexData, (vert_t.name)_FrontFaceNormalData, Materials); } if (Voxel->Flags & Voxel_BackFace) { v3 Dim = DoYStepping(TempVoxels, TmpDim, TmpVoxP, Voxel_BackFace, Voxel->Color, Voxel->Transparency); BackFaceVertexData( VertexOffset+TmpVoxP, Dim, VertexData); - BufferFaceData(Dest, VertexData, BackFaceNormalData, Materials); + BufferFaceData(Dest, VertexData, (vert_t.name)_BackFaceNormalData, Materials); } } @@ -1715,26 +1693,26 @@ poof( } link_internal void - BuildWorldChunkMeshFromMarkedVoxels_Greedy( vox_data *Vox, - (buffer_t.name) *DestGeometry, - (buffer_t.name) *DestTransparentGeometry, - memory_arena *TempMemory, - vert_t.name VertexOffset = {}) + BuildWorldChunkMeshFromMarkedVoxels_Greedy_(vert_t.name)( vox_data *Vox, + (buffer_t.name) *DestGeometry, + (buffer_t.name) *DestTransparentGeometry, + memory_arena *TempMemory, + vert_t.name VertexOffset = {}) { - BuildWorldChunkMeshFromMarkedVoxels_Greedy(Vox->ChunkData->Voxels, Vox->ChunkData->Dim, {}, Vox->ChunkData->Dim, DestGeometry, DestTransparentGeometry, TempMemory, VertexOffset); + BuildWorldChunkMeshFromMarkedVoxels_Greedy_(vert_t.name)(Vox->ChunkData->Voxels, Vox->ChunkData->Dim, {}, Vox->ChunkData->Dim, DestGeometry, DestTransparentGeometry, TempMemory, VertexOffset); } link_internal void - BuildMipMesh( voxel *Voxels, - v3i VoxDim, + BuildMipMesh_(vert_t.name)( voxel *Voxels, + v3i VoxDim, - v3i InnerMin, - v3i InnerMax, + v3i InnerMin, + v3i InnerMax, - world_chunk_mesh_bitfield MeshBit, + world_chunk_mesh_bitfield MeshBit, - (buffer_t.name) *DestGeometry, - memory_arena *TempMemory ) + (buffer_t.name) *DestGeometry, + memory_arena *TempMemory ) { /* TIMED_FUNCTION(); */ @@ -1964,7 +1942,7 @@ poof( } link_internal void - BuildWorldChunkMeshFromMarkedVoxels_Naieve( voxel *Voxels, + BuildWorldChunkMeshFromMarkedVoxels_Naieve_(vert_t.name)( voxel *Voxels, chunk_dimension VoxDim, chunk_dimension SrcChunkMin, @@ -2076,10 +2054,10 @@ poof( ) poof(world_chunk_mesh_functions(untextured_3d_geometry_buffer, v3)) -#include +#include -poof(world_chunk_mesh_functions(world_chunk_geometry_buffer, v3_u8)) -#include +poof(world_chunk_mesh_functions(untextured_3d_geometry_buffer, v3_u8)) +#include #if 0 link_internal void @@ -2198,24 +2176,24 @@ BuildWorldChunkMesh_Direct( voxel *Voxels, } #endif -#if 1 +#if 0 link_internal world_chunk_geometry_buffer* AllocateTempWorldChunkMesh(memory_arena* TempMemory) { world_chunk_geometry_buffer* Result = Allocate_world_chunk_geometry_buffer(TempMemory, ELEMENTS_PER_TEMP_MESH); return Result; } +#endif link_internal untextured_3d_geometry_buffer* -AllocateTempMesh(memory_arena* TempMemory) +AllocateTempMesh(memory_arena* TempMemory, data_type Type) { - untextured_3d_geometry_buffer* Result = Allocate_untextured_3d_geometry_buffer(TempMemory, ELEMENTS_PER_TEMP_MESH); + untextured_3d_geometry_buffer* Result = Allocate_untextured_3d_geometry_buffer(TempMemory, Type, ELEMENTS_PER_TEMP_MESH); return Result; } -#endif link_internal untextured_3d_geometry_buffer* -GetPermMeshForChunk(mesh_freelist* Freelist, u32 Elements, memory_arena* PermMemory) +GetPermMeshForChunk(mesh_freelist* Freelist, data_type Type, u32 Elements, memory_arena* PermMemory) { Assert(Elements); #if BONSAI_INTERNAL @@ -2225,7 +2203,7 @@ GetPermMeshForChunk(mesh_freelist* Freelist, u32 Elements, memory_arena* PermMem untextured_3d_geometry_buffer* Result = Cast(untextured_3d_geometry_buffer*, Unlink_TS(&Freelist->FirstFreeMesh)); if (Result == 0) { - Result = Allocate_untextured_3d_geometry_buffer(PermMemory, Elements); + Result = Allocate_untextured_3d_geometry_buffer(PermMemory, Type, Elements); } #if BONSAI_INTERNAL @@ -2235,7 +2213,7 @@ GetPermMeshForChunk(mesh_freelist* Freelist, u32 Elements, memory_arena* PermMem } link_internal untextured_3d_geometry_buffer* -GetPermMeshForChunk(tiered_mesh_freelist *TieredFreelist, u32 Elements, memory_arena *PermMemory) +GetPermMeshForChunk(tiered_mesh_freelist *TieredFreelist, data_type Type, u32 Elements, memory_arena *PermMemory) { Assert(Elements); mesh_freelist *Freelist = TryGetTierForSize(TieredFreelist, Elements); @@ -2245,35 +2223,38 @@ GetPermMeshForChunk(tiered_mesh_freelist *TieredFreelist, u32 Elements, memory_a { u32 Tier = 1+ (Elements/WORLD_CHUNK_MESH_MIN_SIZE); u32 Size = Tier*WORLD_CHUNK_MESH_MIN_SIZE; - Result = GetPermMeshForChunk(Freelist, Size, PermMemory); + Result = GetPermMeshForChunk(Freelist, Type, Size, PermMemory); Assert(Result->End >= Elements); } else { - Result = Allocate_untextured_3d_geometry_buffer(PermMemory, Elements); + Result = Allocate_untextured_3d_geometry_buffer(PermMemory, Type, Elements); Assert(Result->End >= Elements); } return Result; } +#if 0 link_internal world_chunk_geometry_buffer * GetPermMeshForChunk(tiered_mesh_freelist *TieredFreelist, world_chunk_geometry_buffer *TempMesh, memory_arena *PermMemory) { world_chunk_geometry_buffer *Result = Cast(world_chunk_geometry_buffer*, GetPermMeshForChunk(TieredFreelist, TempMesh->At, PermMemory)); return Result; } +#endif link_internal untextured_3d_geometry_buffer* GetPermMeshForChunk(tiered_mesh_freelist* TieredFreelist, untextured_3d_geometry_buffer *TempMesh, memory_arena *PermMemory) { - untextured_3d_geometry_buffer *Result = GetPermMeshForChunk(TieredFreelist, TempMesh->At, PermMemory); + untextured_3d_geometry_buffer *Result = GetPermMeshForChunk(TieredFreelist, TempMesh->Type, TempMesh->At, PermMemory); return Result; } link_internal void ClipAndDisplaceToMinDim(untextured_3d_geometry_buffer* Buffer, v3 Min, v3 Dim) { +#if 0 v3 Max = Min+Dim; for (u32 VertIndex = 0; VertIndex < Buffer->At; @@ -2298,6 +2279,8 @@ ClipAndDisplaceToMinDim(untextured_3d_geometry_buffer* Buffer, v3 Min, v3 Dim) } } } +#endif + NotImplemented; } link_internal void @@ -3531,9 +3514,43 @@ QueueChunkForMeshRebuild(work_queue *Queue, world_chunk *Chunk, chunk_init_flags } link_internal void -RebuildWorldChunkMesh(thread_local_state *Thread, world_chunk *Chunk, v3i MinOffset, v3i MaxOffset, world_chunk_mesh_bitfield MeshBit, world_chunk_geometry_buffer *TempMesh, memory_arena *TempMem) +BuildWorldChunkMeshFromMarkedVoxels_Greedy( voxel *Voxels, v3i SrcChunkDim, v3i SrcChunkMin, v3i SrcChunkMax, untextured_3d_geometry_buffer *DestGeometry, untextured_3d_geometry_buffer *DestTransparentGeometry, memory_arena *TempMemory, v3 VertexOffset = {}) { - engine_resources *EngineResources = GetEngineResources(); + switch(DestGeometry->Type) + { + InvalidCase(DataType_Undefinded); + case DataType_v3: BuildWorldChunkMeshFromMarkedVoxels_Greedy_v3(Voxels, SrcChunkDim, SrcChunkMin, SrcChunkMax, DestGeometry, DestTransparentGeometry, TempMemory, VertexOffset); break; + case DataType_v3_u8: BuildWorldChunkMeshFromMarkedVoxels_Greedy_v3_u8(Voxels, SrcChunkDim, SrcChunkMin, SrcChunkMax, DestGeometry, DestTransparentGeometry, TempMemory, V3U8(VertexOffset)); break; + } +} + +link_internal void +BuildWorldChunkMeshFromMarkedVoxels_Greedy( vox_data *Vox, untextured_3d_geometry_buffer *DestGeometry, untextured_3d_geometry_buffer *DestTransparentGeometry, memory_arena *TempMemory, v3 VertexOffset = {}) +{ + switch(DestGeometry->Type) + { + InvalidCase(DataType_Undefinded); + case DataType_v3: BuildWorldChunkMeshFromMarkedVoxels_Greedy_v3(Vox, DestGeometry, DestTransparentGeometry, TempMemory, VertexOffset); break; + case DataType_v3_u8: BuildWorldChunkMeshFromMarkedVoxels_Greedy_v3_u8(Vox, DestGeometry, DestTransparentGeometry, TempMemory, V3U8(VertexOffset)); break; + } +} + + +link_internal void +BuildMipMesh( voxel *Voxels, v3i VoxDim, v3i InnerMin, v3i InnerMax, world_chunk_mesh_bitfield MeshBit, untextured_3d_geometry_buffer *DestGeometry, memory_arena *TempMemory ) +{ + switch(DestGeometry->Type) + { + InvalidCase(DataType_Undefinded); + case DataType_v3: BuildMipMesh_v3(Voxels, VoxDim, InnerMin, InnerMax, MeshBit, DestGeometry, TempMemory); break; + case DataType_v3_u8: BuildMipMesh_v3_u8(Voxels, VoxDim, InnerMin, InnerMax, MeshBit, DestGeometry, TempMemory); break; + } +} + +link_internal void +RebuildWorldChunkMesh(thread_local_state *Thread, world_chunk *Chunk, v3i MinOffset, v3i MaxOffset, world_chunk_mesh_bitfield MeshBit, geo_u3d *TempMesh, memory_arena *TempMem, v3 VertexOffset = {}) +{ + engine_resources *Engine = GetEngineResources(); Assert(Chunk->DEBUG_OwnedByThread == 0); Chunk->DEBUG_OwnedByThread = ThreadLocal_ThreadIndex; @@ -3545,7 +3562,7 @@ RebuildWorldChunkMesh(thread_local_state *Thread, world_chunk *Chunk, v3i MinOff #if VOXEL_DEBUG_COLOR BuildWorldChunkMeshFromMarkedVoxels_Naieve( Chunk->Voxels, Chunk->Dim, MinOffset, MaxOffset, TempMesh, 0); #else - BuildWorldChunkMeshFromMarkedVoxels_Greedy( Chunk->Voxels, Chunk->Dim, MinOffset, MaxOffset, TempMesh, 0, TempMem ); + BuildWorldChunkMeshFromMarkedVoxels_Greedy( Chunk->Voxels, Chunk->Dim, MinOffset, MaxOffset, TempMesh, 0, TempMem, VertexOffset); #endif } else @@ -3555,15 +3572,16 @@ RebuildWorldChunkMesh(thread_local_state *Thread, world_chunk *Chunk, v3i MinOff if (TempMesh->At) { - world_chunk_geometry_buffer *FinalMesh = GetPermMeshForChunk(&EngineResources->world_chunk_MeshFreelist, TempMesh, Thread->PermMemory); + geo_u3d *FinalMesh = GetPermMeshForChunk(&Engine->world_chunk_MeshFreelist, TempMesh, Thread->PermMemory); DeepCopy(TempMesh, FinalMesh); auto *Replaced = AtomicReplaceMesh(&Chunk->Meshes, MeshBit, FinalMesh, FinalMesh->Timestamp); - if (Replaced) { DeallocateMesh(Replaced, &EngineResources->world_chunk_MeshFreelist); } + if (Replaced) { DeallocateMesh(Replaced, &Engine->world_chunk_MeshFreelist); } } else { - // TODO(Jesse): Deallocate GPU buffers here. + PushDeallocateBuffersCommand(&Engine->Stdlib.Plat.RenderQ, &Chunk->Meshes.GpuBufferHandles[ToIndex(MeshBit)]); + /* DeallocateGpuBuffers(&Engine->Stdlib.Plat.RenderQ, Chunk); */ } Chunk->DEBUG_OwnedByThread = 0; @@ -3663,10 +3681,11 @@ InitializeChunkWithNoise( chunk_init_callback NoiseCallback, // NOTE(Jesse): You can use this for debug, but it doesn't work if you change it to NoExteriorFaces /* MarkBoundaryVoxels_MakeExteriorFaces(DestChunk->Voxels, DestChunk->Dim, {}, DestChunk->Dim); */ - FullBarrier; + /* FullBarrier; */ - SetFlag(DestChunk, Chunk_VoxelsInitialized); - SetFlag(SyntheticChunk, Chunk_VoxelsInitialized); + // NOTE(Jesse): The DestChunk is finalized at the end of the routine + /* SetFlag(DestChunk, Chunk_VoxelsInitialized); */ + FinalizeChunkInitialization(SyntheticChunk); if (Flags & ChunkInitFlag_ComputeStandingSpots) { @@ -3691,7 +3710,7 @@ InitializeChunkWithNoise( chunk_init_callback NoiseCallback, if (SyntheticChunkSum) { - world_chunk_geometry_buffer *TempMesh = AllocateTempWorldChunkMesh(Thread->TempMemory); + geo_u3d *TempMesh = AllocateTempMesh(Thread->TempMemory, DataType_v3_u8); RebuildWorldChunkMesh(Thread, SyntheticChunk, Global_ChunkApronMinDim, Global_ChunkApronMinDim+DestChunk->Dim, MeshBit_Lod0, TempMesh, Thread->TempMemory); TempMesh->At = 0; @@ -3916,1347 +3935,8 @@ DebugHighlightWorldChunkBasedOnState(graphics *Graphics, world_chunk *Chunk, unt -link_internal v3i -ChunkCountForDim(v3i Dim, v3i ChunkDim) -{ - v3i Fixup = Min(V3i(1), Dim % ChunkDim); - - v3i Result = (Dim/ChunkDim) + Fixup; - return Result; -} - -link_internal void -BlitAssetIntoWorld(engine_resources *Engine, asset *Asset, cp Origin) -{ - world *World = Engine->World; - - Assert(Asset->LoadState == AssetLoadState_Loaded); - - Assert(Asset->Models.Count > 0); - chunk_data *VoxData = Asset->Models.Start[0].Vox.ChunkData; - - chunk_dimension ModelDim = Asset->Models.Start[0].Dim; - - world_chunk SrcChunk = { - .Flags = VoxData->Flags, - .Dim = VoxData->Dim, - .Voxels = VoxData->Voxels, - }; - - // TODO(Jesse): Need to account for model offset in its chunk here. - chunk_dimension ChunkCounts = ChunkCountForDim(ModelDim + Origin.Offset, World->ChunkDim); - - DebugLine("%d %d %d", ChunkCounts.x, ChunkCounts.y, ChunkCounts.z); - - DimIterator(xChunk, yChunk, zChunk, ChunkCounts) - { - v3i SrcWorldP = V3i(xChunk, yChunk, zChunk); - - v3i DestWorldP = Origin.WorldP + SrcWorldP; - world_chunk *DestChunk = GetWorldChunkFromHashtable(World, DestWorldP); - if (DestChunk) - { - Assert(DestChunk->Flags & Chunk_VoxelsInitialized); - - v3i SrcVoxelsOffset = (SrcWorldP*World->ChunkDim) - V3i(Origin.Offset); - - MergeChunksOffset(&SrcChunk, DestChunk, SrcVoxelsOffset); - - // NOTE(Jesse): We have to either call MarkBoundaryVoxels_??? here or somehow infer - // what the face values are in the Merge routine - NotImplemented; - - QueueChunkForMeshRebuild(&Engine->Stdlib.Plat.LowPriority, DestChunk); - } - } -} - -link_internal void -QueueWorldUpdateForRegion( engine_resources *Engine, - world_edit_mode Mode, - world_edit_mode_modifier Modifier, - world_edit_shape *Shape, - u16 ColorIndex, - memory_arena *Memory ) -{ - TIMED_FUNCTION(); - - // TODO(Jesse): Should we just remove the paramter? Or do we sometimes not pass this? - Assert(Memory == Engine->WorldUpdateMemory); - - UNPACK_ENGINE_RESOURCES(Engine); - - cp MinPCoarse = {}; - cp MaxPCoarse = {}; - - // NOTE(Jesse): We have to expand by at least two in either direction because - // we need at least one additional voxel to tell if we have a solid face, and - // another one after that in case the last one on the exterior edge is - // transparent and the next one is solid - // - // I can't remember why the MaxPStroke has to be one more, and I actually - // think that it might not . - f32 MinPStroke = 2.f; - f32 MaxPStroke = 3.f; - - switch (Shape->Type) - { - InvalidCase(type_world_update_op_shape_params_noop); - InvalidCase(type_world_update_op_shape_params_count); - - case type_world_update_op_shape_params_sphere: - { - auto *ShapeSphere = SafeCast(world_update_op_shape_params_sphere, Shape); - cp P = ShapeSphere->Location; - - MinPCoarse = Canonicalize(World, P-V3(ShapeSphere->Radius+MinPStroke) - V3(Global_ChunkApronMinDim)); - MaxPCoarse = Canonicalize(World, P+V3(ShapeSphere->Radius+MaxPStroke) + V3(Global_ChunkApronMaxDim)); - } break; - - case type_world_update_op_shape_params_rect: - { - auto *ShapeRect = SafeCast(world_update_op_shape_params_rect, Shape); - -#if 0 - MinPCoarse = ShapeRect->Region.Min; - MaxPCoarse = ShapeRect->Region.Max; -#else - v3 MinP = Min(ShapeRect->Region.Min, ShapeRect->Region.Max); - v3 MaxP = Max(ShapeRect->Region.Min, ShapeRect->Region.Max); - - ShapeRect->Region.Min = MinP; - ShapeRect->Region.Max = MaxP; - - MinPCoarse = SimSpaceToCanonical(World, MinP - V3(MinPStroke) - V3(Global_ChunkApronMinDim)); - MaxPCoarse = SimSpaceToCanonical(World, MaxP + V3(MaxPStroke) + V3(Global_ChunkApronMaxDim)); -#endif - } break; - - case type_world_update_op_shape_params_chunk_data: - { - auto *ShapeChunk = SafeCast(world_update_op_shape_params_chunk_data, Shape); - - v3 MinSimP = ShapeChunk->SimSpaceOrigin; - v3 MaxSimP = MinSimP + ShapeChunk->Data.Dim; - - MinPCoarse = SimSpaceToCanonical(World, MinSimP-MinPStroke); - MaxPCoarse = SimSpaceToCanonical(World, MaxSimP+MaxPStroke); - } break; - - case type_world_update_op_shape_params_asset: - { - auto *ShapeAsset = SafeCast(world_update_op_shape_params_asset, Shape); - - v3 MinSimP = GetSimSpaceP(World, ShapeAsset->Origin); - - asset *Asset = GetAndLockAssetSync(GetEngineResources(), &ShapeAsset->AssetId); - model *Model = GetModel(Asset, &ShapeAsset->AssetId, ShapeAsset->ModelIndex); - v3 MaxSimP = MinSimP + Model->Dim; - - UnlockAsset(Engine, Asset); - - MinPCoarse = SimSpaceToCanonical(World, MinSimP-MinPStroke); - MaxPCoarse = SimSpaceToCanonical(World, MaxSimP+MaxPStroke); - } break; - } - - // These value align the min/max positions to StandingSpot boundaries in global space - auto MinPFixup = V3i(MinPCoarse.Offset) % V3i(Global_StandingSpotDim.xy, 1); - auto MaxPFixup = V3i(Global_StandingSpotDim.xy, 0) - V3i(MaxPCoarse.Offset) % V3i(Global_StandingSpotDim.xy, 1); - - Assert(MinPFixup.z == 0); - Assert(MaxPFixup.z == 0); - - auto MinP = Canonicalize(World, MinPCoarse - V3(MinPFixup)); - auto MaxP = Canonicalize(World, MaxPCoarse + V3(MaxPFixup)); - - MinP.Offset = Truncate(MinP.Offset); - MaxP.Offset = Truncate(MaxP.Offset); - - Assert(u32(MinP.Offset.x) % u32(Global_StandingSpotDim.x) == 0 ); - Assert(u32(MinP.Offset.y) % u32(Global_StandingSpotDim.y) == 0 ); - - Assert(u32(MaxP.Offset.x) % u32(Global_StandingSpotDim.x) == 0 ); - Assert(u32(MaxP.Offset.y) % u32(Global_StandingSpotDim.y) == 0 ); - - /* { */ - /* r32 Thickness = 0.15f; */ - /* DEBUG_HighlightVoxel(Engine, MinP, BLUE, Thickness); */ - /* DEBUG_HighlightVoxel(Engine, MaxP, RED, Thickness); */ - /* } */ - - /* world_position Delta = Max(MaxP.WorldP - MinP.WorldP, World_Position(1)); */ - v3i Delta = MaxP.WorldP - MinP.WorldP + 1; - u32 TotalChunkCount = Abs(Volume(Delta)); - - // TODO(Jesse)(leak): Each one of these gets leaked at the moment - world_chunk **Buffer = AllocateAligned(world_chunk*, Memory, TotalChunkCount, CACHE_LINE_SIZE); - - u32 ChunkIndex = 0; - for (s32 zChunk = MinP.WorldP.z; zChunk <= MaxP.WorldP.z; ++zChunk) - { - for (s32 yChunk = MinP.WorldP.y; yChunk <= MaxP.WorldP.y; ++yChunk) - { - for (s32 xChunk = MinP.WorldP.x; xChunk <= MaxP.WorldP.x; ++xChunk) - { - world_position ChunkP = World_Position(xChunk, yChunk, zChunk); - world_chunk *Chunk = GetWorldChunkFromHashtable(World, ChunkP); - if (Chunk && Chunk->Flags & Chunk_VoxelsInitialized) - { - Assert(Chunk->Flags != Chunk_Uninitialized); - Assert(ChunkIndex < TotalChunkCount); - Buffer[ChunkIndex++] = Chunk; - } - } - } - } - - // NOTE(Jesse): If none of the world chunks were in the hashtable yet we get ChunkCount == 0 - if (ChunkIndex > 0) - { - v3 SimFloodOrigin = GetHotVoxelForFlood(Engine, Mode, Modifier); - - work_queue_entry Entry = { - .Type = type_work_queue_entry_update_world_region, - .work_queue_entry_update_world_region = WorkQueueEntryUpdateWorldRegion(Mode, Modifier, SimFloodOrigin, Shape, ColorIndex, MinP, MaxP, Buffer, ChunkIndex), - }; - PushWorkQueueEntry(&Plat->LowPriority, &Entry); - } -} - -link_internal u32 -MapIntoQueryBox(v3i SimSpaceVoxP, v3i UpdateMinP, v3i UpdateDim) -{ - auto Rel = SimSpaceVoxP - UpdateMinP; - auto Result = GetIndex(Rel, UpdateDim); - return (u32)Result; -} - -link_internal u32 -MapIntoQueryBox(v3 SimSpaceVoxP, v3 UpdateMinP, v3i UpdateDim) -{ - v3 Rel = SimSpaceVoxP - UpdateMinP; - s32 Result = GetIndex(Rel, UpdateDim); - return (u32)Result; -} - -struct voxel_stack_element -{ - v3i VoxSimP; - voxel_rule_direction Dir; -}; - -link_internal b32 -AreEqual(voxel_stack_element E0, voxel_stack_element E1) -{ - NotImplemented; - return False; -} - -poof(gen_constructor(voxel_stack_element)) -#include - -poof(block_array(voxel_stack_element, {32})) -#include - -poof(generate_cursor(voxel_stack_element)) -#include - - - -link_internal void -DEBUG_AssertVoxelFloodStartsInEmptyVoxel(v3i SimSphereP, rect3i *SimSpaceUpdateBounds, voxel *CopiedVoxels) -{ -#if 1 -#if BONSAI_INTERNAL - v3i UpdateDim = GetDim(*SimSpaceUpdateBounds); - - { // NOTE(Jesse): Debug. Don't rely on the optimizer to remove this in release mode - // - // This asserts that we're not trying to flood starting at a voxel that's inside the world. - v3i RelVoxP = SimSphereP - SimSpaceUpdateBounds->Min; - s32 VoxelIndex = TryGetIndex(RelVoxP, UpdateDim); - if (VoxelIndex > -1) - { - voxel *OriginV = CopiedVoxels+VoxelIndex; - Assert( (OriginV->Flags&Voxel_Filled) == 0); - } - } -#endif -#endif -} - -// -// NOTE(Jesse): UserCode gets called when the first -poof( - func flood_fill_iteration_pattern(type_poof_symbol FloodPredicate, type_poof_symbol UserCode, type_poof_symbol UserCode2) @code_fragment - { - random_series ColorEntropy = {4654376543246}; - - voxel *V = {}; - // TODO(Jesse): Do we want to try and keep the amount of temp memory to a minimum here? - voxel_stack_element_cursor Stack = VoxelStackElementCursor(umm(TotalVoxels*6), Thread->TempMemory); - - // Unfortunately, can't #if this out in a poof function. Should probably - // put it on a #define switch to make sure it gets compiled out. - DEBUG_AssertVoxelFloodStartsInEmptyVoxel(FloodOrigin, &SimSpaceUpdateBounds, CopiedChunk->Voxels); - - Push(&Stack, VoxelStackElement(FloodOrigin, VoxelRuleDir_Count)); - while (AtElements(&Stack)) - { - b32 OverwriteVoxel = False; - - voxel_stack_element Element = Pop(&Stack); - v3i SimVoxP = Element.VoxSimP + AllDirections[Element.Dir]; - v3i RelVoxP = SimVoxP - SimSpaceUpdateBounds.Min; - - s32 VoxelIndex = TryGetIndex(RelVoxP, UpdateDim); - if (VoxelIndex > -1) - { - V = CopiedChunk->Voxels+VoxelIndex; - - v3i CenterToVoxP = SimVoxP - FloodOrigin; - - (FloodPredicate) - { - if ( (V->Flags & Voxel_MarkBit) == 0) - { - Push(&Stack, VoxelStackElement(SimVoxP, VoxelRuleDir_PosX)); - Push(&Stack, VoxelStackElement(SimVoxP, VoxelRuleDir_NegX)); - Push(&Stack, VoxelStackElement(SimVoxP, VoxelRuleDir_PosY)); - Push(&Stack, VoxelStackElement(SimVoxP, VoxelRuleDir_NegY)); - Push(&Stack, VoxelStackElement(SimVoxP, VoxelRuleDir_PosZ)); - Push(&Stack, VoxelStackElement(SimVoxP, VoxelRuleDir_NegZ)); - } - } - - (UserCode) - - V->Flags |= Voxel_MarkBit; - - if ( ((OverwriteVoxel == True) && (Invert == False)) || - ((OverwriteVoxel == False) && (Invert == True)) ) - { - if (Mode == WorldEdit_Mode_Paint) - { - V->Color = NewVoxelValue->Color; - } - else - { - *V = *NewVoxelValue; - } - } - } - } - - Push(&Stack, VoxelStackElement(FloodOrigin, VoxelRuleDir_Count)); - while (AtElements(&Stack)) - { - voxel_stack_element Element = Pop(&Stack); - v3i Dir = AllDirections[Element.Dir]; - { - v3i SimVoxP = Element.VoxSimP + Dir; - v3i RelVoxP = SimVoxP - SimSpaceUpdateBounds.Min; - - s32 VoxelIndex = TryGetIndex(RelVoxP, UpdateDim); - - if (VoxelIndex > -1) - { - V = CopiedChunk->Voxels+VoxelIndex; - - (UserCode2) - - if ( (V->Flags&Voxel_MarkBit)) - { - Push(&Stack, VoxelStackElement(SimVoxP, VoxelRuleDir_PosX)); - Push(&Stack, VoxelStackElement(SimVoxP, VoxelRuleDir_NegX)); - Push(&Stack, VoxelStackElement(SimVoxP, VoxelRuleDir_PosY)); - Push(&Stack, VoxelStackElement(SimVoxP, VoxelRuleDir_NegY)); - Push(&Stack, VoxelStackElement(SimVoxP, VoxelRuleDir_PosZ)); - Push(&Stack, VoxelStackElement(SimVoxP, VoxelRuleDir_NegZ)); - } - - V->Flags &= ~Voxel_MarkBit; - } - } - } - } -) - - -poof( - func rectalinear_iteration_pattern(type_poof_symbol UserCode) @code_fragment - { - DimIterator(x, y, z, UpdateDim) - { - b32 OverwriteVoxel = False; - - v3i VoxP = V3i(x,y,z); - v3i SimVoxP = VoxP + SimSpaceUpdateBounds.Min; - voxel *V = CopiedChunk->Voxels + GetIndex(VoxP, UpdateDim); - - if (Contains(SSRect, SimVoxP)) - { - UserCode - - if ( ((OverwriteVoxel == True ) && (Invert == False)) || - ((OverwriteVoxel == False) && (Invert == True )) ) - { - if (Mode == WorldEdit_Mode_Paint) - { - V->Color = NewVoxelValue->Color; - } - else - { - if (Mode == WorldEdit_Mode_Remove) { *V = {}; } - else { *V = *NewVoxelValue; } - } - - // Knock out face flags so the 'surface' algorithm doesn't "self-apply" - // We recompute these, so it's fine there. It's slower on non-surface - // paths, but .. when that's the bottleneck, we've won. - V->Flags = voxel_flag(V->Flags&~VoxelFaceMask); - } - } - } - - } -) - -// TODO(Jesse): Make this not a macro. -#define poof_check_for_unfilled_border() \ - { \ - if (voxel *Vn = TryGetVoxel(CopiedChunk, VoxP + V3(1,0,0))) \ - { \ - if ((Vn->Flags&VoxelFaceMask)) { IsUnfilledBorder = True; } \ - } \ - if (voxel *Vn = TryGetVoxel(CopiedChunk, VoxP + V3(-1,0,0))) \ - { \ - if ((Vn->Flags&VoxelFaceMask)) { IsUnfilledBorder = True; } \ - } \ - \ - if (voxel *Vn = TryGetVoxel(CopiedChunk, VoxP + V3(0,1,0))) \ - { \ - if ((Vn->Flags&VoxelFaceMask)) { IsUnfilledBorder = True; } \ - } \ - if (voxel *Vn = TryGetVoxel(CopiedChunk, VoxP + V3(0,-1,0))) \ - { \ - if ((Vn->Flags&VoxelFaceMask)) { IsUnfilledBorder = True; } \ - } \ - \ - if (voxel *Vn = TryGetVoxel(CopiedChunk, VoxP + V3(0,0,1))) \ - { \ - if ((Vn->Flags&VoxelFaceMask)) { IsUnfilledBorder = True; } \ - } \ - if (voxel *Vn = TryGetVoxel(CopiedChunk, VoxP + V3(0,0,-1))) \ - { \ - if ((Vn->Flags&VoxelFaceMask)) { IsUnfilledBorder = True; } \ - } \ - } \ -#if 0 -poof( - func poof_check_for_unfilled_border(ignored) - { - if (voxel *Vn = TryGetVoxel(CopiedChunk, VoxP + V3(1,0,0))) - { - if ((Vn->Flags&VoxelFaceMask)) { IsUnfilledBorder = True; } - } - if (voxel *Vn = TryGetVoxel(CopiedChunk, VoxP + V3(-1,0,0))) - { - if ((Vn->Flags&VoxelFaceMask)) { IsUnfilledBorder = True; } - } - - if (voxel *Vn = TryGetVoxel(CopiedChunk, VoxP + V3(0,1,0))) - { - if ((Vn->Flags&VoxelFaceMask)) { IsUnfilledBorder = True; } - } - if (voxel *Vn = TryGetVoxel(CopiedChunk, VoxP + V3(0,-1,0))) - { - if ((Vn->Flags&VoxelFaceMask)) { IsUnfilledBorder = True; } - } - if (voxel *Vn = TryGetVoxel(CopiedChunk, VoxP + V3(0,0,1))) - { - if ((Vn->Flags&VoxelFaceMask)) { IsUnfilledBorder = True; } - } - if (voxel *Vn = TryGetVoxel(CopiedChunk, VoxP + V3(0,0,-1))) - { - if ((Vn->Flags&VoxelFaceMask)) { IsUnfilledBorder = True; } - } - } -) -#endif - - - -struct apply_world_edit_params -{ - world_edit_mode Mode; - rect3i SSRect; - rect3i SimSpaceUpdateBounds; - world_chunk *CopiedChunk; - b32 Invert; - u16 Color; - u8 Transparency; -}; - -#define UNPACK_APPLY_WORLD_EDIT_PARAMS(P) \ - world_edit_mode Mode = P->Mode; \ - rect3i SSRect = P->SSRect; \ - rect3i SimSpaceUpdateBounds = P->SimSpaceUpdateBounds; \ - world_chunk *CopiedChunk = P->CopiedChunk; \ - v3i UpdateDim = GetDim(SimSpaceUpdateBounds); \ - b32 Invert = P->Invert - - - - - - -// -// -// shape_sphere -// -// - - -link_internal void -WorldEdit_shape_sphere_Surface(apply_world_edit_params *Params, r32 RadiusSquared, v3i EditCenterP, voxel *NewVoxelValue) -{ - UNPACK_APPLY_WORLD_EDIT_PARAMS(Params); - switch (Mode) - { - case WorldEdit_Mode_Disabled: {} break; - - case WorldEdit_Mode_Attach: - { - poof(rectalinear_iteration_pattern({ - - v3i CenterToVoxP = SimVoxP - EditCenterP; - if (LengthSq(CenterToVoxP) < RadiusSquared && (V->Flags&Voxel_Filled) == False) - { - b32 IsUnfilledBorder = False; - poof_check_for_unfilled_border() - Assert(NewVoxelValue->Flags & Voxel_Filled); - if (IsUnfilledBorder) - { - OverwriteVoxel = True; - } - } - })) -#include - } break; - - case WorldEdit_Mode_Paint: - case WorldEdit_Mode_Remove: - { - poof(rectalinear_iteration_pattern({ - v3i CenterToVoxP = SimVoxP - EditCenterP; - if (LengthSq(CenterToVoxP) < RadiusSquared && (V->Flags&VoxelFaceMask)) - { - OverwriteVoxel = True; - } - })) -#include - } break; - } -} - -link_internal void -WorldEdit_shape_sphere_Flood(apply_world_edit_params *Params, thread_local_state *Thread, r32 RadiusSquared, v3i EditCenterP, v3i FloodOrigin, voxel *NewVoxelValue) -{ - UNPACK_APPLY_WORLD_EDIT_PARAMS(Params); - s32 TotalVoxels = Volume(UpdateDim); - - Assert(Params->Mode == WorldEdit_Mode_Remove); - - poof(flood_fill_iteration_pattern( - { - if (LengthSq(CenterToVoxP) < RadiusSquared && (V->Flags&Voxel_Filled) == 0) - }, - { - if ( Length(CenterToVoxP) < SquareRoot(RadiusSquared)-1.f && (V->Flags&Voxel_Filled) ) - { V->Flags = Voxel_Empty; } - }, - { - v3i CenterToVoxP = SimVoxP - EditCenterP; - if (Length(CenterToVoxP) < SquareRoot(RadiusSquared)-1.f) - { - if (V->Flags & Voxel_Filled) - { - V->Color = SafeTruncateU8(RandomBetween((u32)GREY_5, &ColorEntropy, (u32)GREY_8+1)); - } - - } - else if (LengthSq(CenterToVoxP) < RadiusSquared) - { - V->Color = GREY_8; - } - } - )) -#include -} - -link_internal void -WorldEdit_shape_sphere_Default(apply_world_edit_params *Params, r32 RadiusSquared, v3i EditCenterP, voxel *NewVoxelValue) -{ - UNPACK_APPLY_WORLD_EDIT_PARAMS(Params); - - poof(rectalinear_iteration_pattern({ - v3i CenterToVoxP = SimVoxP - EditCenterP; - if (LengthSq(CenterToVoxP) < RadiusSquared) - { - OverwriteVoxel = True; - } - })) -#include -} - - -// -// -// shape_rect -// -// - -link_internal void -WorldEdit_shape_rect_Surface(apply_world_edit_params *Params, voxel *NewVoxelValue) -{ - UNPACK_APPLY_WORLD_EDIT_PARAMS(Params); - - switch (Mode) - { - case WorldEdit_Mode_Disabled: {} break; - - case WorldEdit_Mode_Attach: - { - poof(rectalinear_iteration_pattern({ - - if ((V->Flags&Voxel_Filled) == False) - { - b32 IsUnfilledBorder = False; - poof_check_for_unfilled_border() - Assert(NewVoxelValue->Flags & Voxel_Filled); - if (IsUnfilledBorder) - { - OverwriteVoxel = True; - } - } - })) -#include - } break; - - case WorldEdit_Mode_Paint: - case WorldEdit_Mode_Remove: - { - poof(rectalinear_iteration_pattern({ - if ( (V->Flags&VoxelFaceMask)) - { - OverwriteVoxel = True; - } - })) -#include - } break; - } -} - -link_internal void -WorldEdit_shape_rect_Flood( apply_world_edit_params *Params, thread_local_state *Thread, v3i FloodOrigin, voxel *NewVoxelValue) -{ - UNPACK_APPLY_WORLD_EDIT_PARAMS(Params); - s32 TotalVoxels = Volume(UpdateDim); - - switch (Mode) - { - case WorldEdit_Mode_Disabled: {} break; - - case WorldEdit_Mode_Paint: - case WorldEdit_Mode_Attach: - case WorldEdit_Mode_Remove: - { - poof(flood_fill_iteration_pattern( - { if ( (V->Flags&Voxel_Filled) == (Voxel_Filled*(Mode==WorldEdit_Mode_Attach)) ) }, - { - if ( Mode == WorldEdit_Mode_Attach && (V->Flags&Voxel_Filled) ) - { } - else - { - OverwriteVoxel = True; - } - }, - {} - )) -#include - } break; - } -} - -link_internal void -WorldEdit_shape_rect_Default(apply_world_edit_params *Params, voxel *NewVoxelValue) -{ - UNPACK_APPLY_WORLD_EDIT_PARAMS(Params); - switch (Mode) - { - case WorldEdit_Mode_Disabled: {} break; - case WorldEdit_Mode_Attach: - case WorldEdit_Mode_Remove: - { - poof(rectalinear_iteration_pattern({ - OverwriteVoxel = True; - })) -#include - } break; - - case WorldEdit_Mode_Paint: - { - poof(rectalinear_iteration_pattern({ - if (V->Flags & Voxel_Filled) - { - OverwriteVoxel = True; - } - })) -#include - } break; - } -} - - - - - - -// -// -// shape_chunk_data -// -// - -link_internal void -WorldEdit_shape_chunk_data_Surface(apply_world_edit_params *Params, v3 SimOrigin, chunk_data *Data) -{ - UNPACK_APPLY_WORLD_EDIT_PARAMS(Params); - - switch (Mode) - { - case WorldEdit_Mode_Disabled: {} break; - - case WorldEdit_Mode_Attach: - { - poof(rectalinear_iteration_pattern({ - - v3i OriginToCurrentVoxP = SimVoxP - SimOrigin; - voxel *NewVoxelValue = TryGetVoxel(Data, OriginToCurrentVoxP); - - if ((V->Flags&Voxel_Filled)==False) - { - b32 IsUnfilledBorder = False; - poof_check_for_unfilled_border() - if (IsUnfilledBorder) - { - OverwriteVoxel = True; - } - } - })) -#include - } break; - - case WorldEdit_Mode_Paint: - case WorldEdit_Mode_Remove: - { - poof(rectalinear_iteration_pattern({ - v3i OriginToCurrentVoxP = SimVoxP - SimOrigin; - voxel *NewVoxelValue = TryGetVoxel(Data, OriginToCurrentVoxP); - if (NewVoxelValue) - { - if ( (V->Flags&VoxelFaceMask) && (NewVoxelValue->Flags&Voxel_Filled) ) - { - OverwriteVoxel = True; - } - } - })) -#include - } break; - } -} - -link_internal void -WorldEdit_shape_chunk_data_Flood( - apply_world_edit_params *Params, - v3 SimOrigin, chunk_data *Data, - thread_local_state *Thread, v3i FloodOrigin - ) -{ - UNPACK_APPLY_WORLD_EDIT_PARAMS(Params); - - s32 TotalVoxels = Volume(UpdateDim); - switch (Mode) - { - case WorldEdit_Mode_Disabled: {} break; - case WorldEdit_Mode_Attach: - { - poof(flood_fill_iteration_pattern( - { - v3i OriginToCurrentVoxP = SimVoxP - SimOrigin; - voxel *NewVoxelValue = TryGetVoxel(Data, OriginToCurrentVoxP); - if ((V->Flags&Voxel_Filled)) - }, - { - if ( ((V->Flags&Voxel_Filled) == 0) && NewVoxelValue && (NewVoxelValue->Flags&Voxel_Filled)) { *V = *NewVoxelValue; } - }, - {} - )) -#include - } break; - - case WorldEdit_Mode_Remove: - { - poof(flood_fill_iteration_pattern( - { - v3i OriginToCurrentVoxP = SimVoxP - SimOrigin; - voxel *NewVoxelValue = TryGetVoxel(Data, OriginToCurrentVoxP); - if (Contains(SSRect, SimVoxP) && (V->Flags&Voxel_Filled) == 0) - }, - { - if (NewVoxelValue && (NewVoxelValue->Flags&Voxel_Filled)) { *V = {}; } - }, - {} - )) -#include - } break; - - case WorldEdit_Mode_Paint: - { - poof(rectalinear_iteration_pattern({ - v3i OriginToCurrentVoxP = SimVoxP - SimOrigin; - voxel *NewVoxelValue = TryGetVoxel(Data, OriginToCurrentVoxP); - if (NewVoxelValue && (NewVoxelValue->Flags&Voxel_Filled)) { V->Color = NewVoxelValue->Color; } - })) -#include - } break; - - } -} - -link_internal void -WorldEdit_shape_chunk_data_Default(apply_world_edit_params *Params, v3 SimOrigin, chunk_data *Data) -{ - UNPACK_APPLY_WORLD_EDIT_PARAMS(Params); - - voxel InvertV = { Voxel_Filled, Params->Transparency, Params->Color }; - - switch (Mode) - { - case WorldEdit_Mode_Disabled: {} break; - - case WorldEdit_Mode_Paint: - case WorldEdit_Mode_Attach: - case WorldEdit_Mode_Remove: - { - poof(rectalinear_iteration_pattern({ - v3i OriginToCurrentVoxP = SimVoxP - SimOrigin; - voxel *AssetV = TryGetVoxel(Data, OriginToCurrentVoxP); - voxel *NewVoxelValue = &InvertV; - if (AssetV && (AssetV->Flags&Voxel_Filled)) - { - NewVoxelValue = AssetV; - OverwriteVoxel = True; - } - })) -#include - } break; - } -} - - - - - - - -link_internal void -ApplyUpdateToRegion(thread_local_state *Thread, work_queue_entry_update_world_region *Job, rect3i SimSpaceUpdateBounds, world_chunk *CopiedChunk, b32 Invert = False) -{ - world *World = GetWorld(); - - random_series ColorEntropy = {4654376543246}; - - v3i UpdateDim = GetDim(SimSpaceUpdateBounds); - s32 TotalVoxels = Volume(UpdateDim); - - world_edit_mode Mode = Job->Brush.Mode; - world_edit_mode_modifier Modifier = Job->Brush.Modifier; - world_edit_shape Shape = Job->Brush.Shape; - /* v3i FloodOrigin = V3i(Job->Brush.SimFloodOrigin); */ - - u16 NewColor = Job->ColorIndex; - u8 NewTransparency = Job->Transparency; - - voxel _NewVoxelValue = {}; - voxel *NewVoxelValue = &_NewVoxelValue; - - if (Mode == WorldEdit_Mode_Attach || Mode == WorldEdit_Mode_Paint) - { -#if VOXEL_DEBUG_COLOR - _NewVoxelValue = { Voxel_Filled, NewTransparency, NewColor, {}, {}}; -#else - _NewVoxelValue = { Voxel_Filled, NewTransparency, NewColor}; -#endif - } - - switch (Shape.Type) - { - InvalidCase(type_world_update_op_shape_params_count); - InvalidCase(type_world_update_op_shape_params_noop); - - case type_world_update_op_shape_params_sphere: - { - world_update_op_shape_params_sphere *Sphere = SafeCast(world_update_op_shape_params_sphere, &Shape); - - v3i EditCenterP = V3i(Floor(GetSimSpaceP(World, Sphere->Location))); - r32 RadiusSquared = Square(Sphere->Radius); - rect3i SSRect = SimSpaceUpdateBounds; - - Assert(EditCenterP > SimSpaceUpdateBounds.Min); - Assert(EditCenterP < SimSpaceUpdateBounds.Max); - - /* rect3i SSRect = RectCenterRad(EditCenterP, V3i(Sphere->Radius)); */ - apply_world_edit_params Params = {Mode, SSRect, SimSpaceUpdateBounds, CopiedChunk, Invert, NewColor, NewTransparency}; - - switch(Modifier) - { - case WorldEdit_Modifier_Default: - { - WorldEdit_shape_sphere_Default(&Params, RadiusSquared, EditCenterP, NewVoxelValue); - } break; - - case WorldEdit_Modifier_Surface: - { - WorldEdit_shape_sphere_Surface(&Params, RadiusSquared, EditCenterP, NewVoxelValue); - } break; - - case WorldEdit_Modifier_Flood: - { - v3i FloodOrigin = EditCenterP; - WorldEdit_shape_sphere_Flood(&Params, Thread, RadiusSquared, EditCenterP, FloodOrigin, NewVoxelValue); - } break; - } - - } break; - - case type_world_update_op_shape_params_rect: - { - world_update_op_shape_params_rect *Rect = SafeCast(world_update_op_shape_params_rect, &Shape); - - // NOTE(Jesse): Outside world should have min/max'd these already - Assert(Rect->Region.Min <= Rect->Region.Max); - - // NOTE(Jesse): These are specifically meant to truncate, not floor - rect3i SSRect = {V3i(Rect->Region.Min), V3i(Rect->Region.Max)}; - v3i EditCenterP = V3i(Floor(Rect->Region.Min+(GetDim(SSRect)/2.f))); - - apply_world_edit_params Params = {Mode, SSRect, SimSpaceUpdateBounds, CopiedChunk, Invert, NewColor, NewTransparency}; - switch (Modifier) - { - case WorldEdit_Modifier_Surface: - { - WorldEdit_shape_rect_Surface(&Params, NewVoxelValue); - } break; - - case WorldEdit_Modifier_Flood: - { - v3i FloodOrigin = EditCenterP; - WorldEdit_shape_rect_Flood(&Params, Thread, FloodOrigin, NewVoxelValue); - } break; - - case WorldEdit_Modifier_Default: - { - WorldEdit_shape_rect_Default(&Params, NewVoxelValue); - } break; - } - } break; - - { - case type_world_update_op_shape_params_asset: - case type_world_update_op_shape_params_chunk_data: - { - asset *Asset = 0; - chunk_data *Data = 0; - v3 SimOrigin = {}; - - if (Shape.Type == type_world_update_op_shape_params_asset) - { - world_update_op_shape_params_asset *Casted = SafeCast(world_update_op_shape_params_asset, &Shape); - asset_id *AID = &Casted->AssetId; - Asset = GetAndLockAssetSync(GetEngineResources(), AID); - model *Model = GetModel(Asset, AID, Casted->ModelIndex); - Data = Model->Vox.ChunkData; - SimOrigin = GetSimSpaceP(World, Casted->Origin); - } - else if (Shape.Type == type_world_update_op_shape_params_chunk_data) - { - auto *Casted = SafeCast(world_update_op_shape_params_chunk_data, &Shape); - Data = &Casted->Data; - SimOrigin = Casted->SimSpaceOrigin; - } - else - { - InvalidCodePath(); - } - - rect3i SSRect = RectMinDim(V3i(SimOrigin), Data->Dim); - v3i EditCenterP = V3i(SimOrigin) + V3i(Data->Dim/2.f); - - apply_world_edit_params Params = {Mode, SSRect, SimSpaceUpdateBounds, CopiedChunk, Invert, NewColor, NewTransparency}; - switch (Modifier) - { - case WorldEdit_Modifier_Surface: - { - WorldEdit_shape_chunk_data_Surface(&Params, SimOrigin, Data); - } break; - - case WorldEdit_Modifier_Flood: - { - v3i FloodOrigin = EditCenterP; - WorldEdit_shape_chunk_data_Flood(&Params, SimOrigin, Data, Thread, FloodOrigin); - } break; - - case WorldEdit_Modifier_Default: - { - WorldEdit_shape_chunk_data_Default(&Params, SimOrigin, Data); - } break; - } - - if (Asset) { UnlockAsset(GetEngineResources(), Asset); Asset = 0; } - } break; - } - } - -} - -link_internal void -DoWorldUpdate(work_queue *Queue, world *World, thread_local_state *Thread, work_queue_entry_update_world_region *Job) -{ - TIMED_FUNCTION(); - - world_edit_mode Mode = Job->Brush.Mode; - world_edit_mode_modifier Modifier = Job->Brush.Modifier; - world_edit_shape Shape = Job->Brush.Shape; - /* v3i FloodOrigin = V3i(Job->Brush.SimFloodOrigin); */ - - u16 NewColor = Job->ColorIndex; - u8 NewTransparency = Job->Transparency; - cp MaxP = Job->MaxP; - cp MinP = Job->MinP; - world_chunk **DestChunkBuffer = Job->DestChunkBuffer; - u32 ChunkCount = Job->ChunkCount; - - v3 _P0 = GetSimSpaceP(World, MinP); - v3 _P1 = GetSimSpaceP(World, MaxP); - - // TODO(Jesse): Should these not just be assertions? Pretty sure the calling - // code makes sure these are already in 'sorted' order. - v3 P0 = Min(_P0, _P1); - v3 P1 = Max(_P0, _P1); - - // NOTE(Jesse): These are meant to truncate instead of floor - rect3i SimSpaceUpdateBounds = Rect3iMinMax( V3i(P0), V3i(P1) ); - - v3i UpdateDim = GetDim(SimSpaceUpdateBounds); - v3i UpdateMinP = SimSpaceUpdateBounds.Min; - - Assert(UpdateDim.x % Global_StandingSpotDim.x == 0); - Assert(UpdateDim.y % Global_StandingSpotDim.y == 0); - - /* s32 TotalVoxels_signed = Volume(SimSpaceUpdateBounds); */ - /* Assert(TotalVoxels_signed > 0); */ - - world_chunk CopiedChunk = {}; - - s32 TotalVoxels = Volume(UpdateDim); - CopiedChunk.Voxels = Allocate(voxel, Thread->PermMemory, TotalVoxels); - CopiedChunk.Dim = UpdateDim; - - for (s32 VoxelIndex = 0; VoxelIndex < TotalVoxels; ++VoxelIndex) { CopiedChunk.Voxels[VoxelIndex] = Global_UnsetVoxel; } - -#if 1 - for (u32 ChunkIndex = 0; ChunkIndex < ChunkCount; ++ChunkIndex) - { - world_chunk *Chunk = DestChunkBuffer[ChunkIndex]; - auto SimSpaceChunkRect = GetSimSpaceAABBi(World, Chunk); - auto SimSpaceIntersectionRect = Union(&SimSpaceChunkRect, &SimSpaceUpdateBounds); - - auto SimSpaceIntersectionMin = SimSpaceIntersectionRect.Min; - auto SimSpaceIntersectionMax = SimSpaceIntersectionRect.Max; - - auto SimSpaceChunkMin = SimSpaceChunkRect.Min; - auto SimSpaceChunkMax = SimSpaceChunkRect.Max; - - auto ChunkRelRectMin = SimSpaceIntersectionMin - SimSpaceChunkMin; - auto ChunkRelRectMax = SimSpaceIntersectionMax - SimSpaceChunkMin; - - for (s32 zVoxel = s32(ChunkRelRectMin.z); zVoxel < s32(ChunkRelRectMax.z); zVoxel += 1) - { - for (s32 yVoxel = s32(ChunkRelRectMin.y); yVoxel < s32(ChunkRelRectMax.y); yVoxel += 1) - { - for (s32 xVoxel = s32(ChunkRelRectMin.x); xVoxel < s32(ChunkRelRectMax.x); xVoxel += 1) - { - v3i RelVoxP = V3i(s32(xVoxel), s32(yVoxel), s32(zVoxel)); - voxel *V = GetVoxel(Chunk, RelVoxP); - Assert( (V->Flags & Voxel_MarkBit) == 0); - - v3i SimSpaceVoxPExact = V3i(xVoxel, yVoxel, zVoxel) + SimSpaceChunkMin; - - Assert(UpdateMinP <= SimSpaceVoxPExact); - u32 Index = MapIntoQueryBox(SimSpaceVoxPExact, UpdateMinP, UpdateDim); - Assert(s32(Index) < TotalVoxels); - Assert(CopiedChunk.Voxels[Index] == Global_UnsetVoxel); - CopiedChunk.Voxels[Index] = *V; - } - } - } - } -#endif - -#if 0 - world_update_callback Callback = Global_WorldUpdateCallbackTable[Mode][Modifier][Shape.Type]; - if (Callback) - { - Callback(Mode, Modifier, &Shape, DestChunkBuffer, ChunkCount, &SimSpaceUpdateBounds, CopiedChunk.Voxels); - } - else - { - Warn("Attempted to index into an un-implemented world update callback (%S)(%S)(%S).", ToString(Mode), ToString(Modifier), ToString(Shape.Type)); - } -#endif - - ApplyUpdateToRegion(Thread, Job, SimSpaceUpdateBounds, &CopiedChunk); - - - // NOTE(Jesse): We can actually do the entire dim here, but it's probably - // better (faster) to just do what we actually need to - - MarkBoundaryVoxels_NoExteriorFaces( CopiedChunk.Voxels, UpdateDim, {{1,1,1}}, UpdateDim-1); - /* MarkBoundaryVoxels_NoExteriorFaces( CopiedChunk.Voxels, UpdateDim, {}, UpdateDim); */ - /* MarkBoundaryVoxels_MakeExteriorFaces( CopiedChunk.Voxels, UpdateDim, {{1,1,1}}, UpdateDim-1); */ - /* MarkBoundaryVoxels_MakeExteriorFaces( CopiedChunk.Voxels, UpdateDim, {}, UpdateDim); */ - - -#if 1 - for (u32 ChunkIndex = 0; ChunkIndex < ChunkCount; ++ChunkIndex) - { - world_chunk *Chunk = DestChunkBuffer[ChunkIndex]; - auto SimSpaceChunkRect = GetSimSpaceAABBi(World, Chunk); - auto SimSpaceIntersectionRect = Union(&SimSpaceChunkRect, &SimSpaceUpdateBounds); - - auto SimSpaceIntersectionMin = SimSpaceIntersectionRect.Min; - auto SimSpaceIntersectionMax = SimSpaceIntersectionRect.Max; - - auto SimSpaceChunkMin = SimSpaceChunkRect.Min; - auto SimSpaceChunkMax = SimSpaceChunkRect.Max; - - auto ChunkRelRectMin = SimSpaceIntersectionMin - SimSpaceChunkMin; - auto ChunkRelRectMax = SimSpaceIntersectionMax - SimSpaceChunkMin; - - s32 StartedFilled = 0; - s32 EndedFilled = 0; - for (s32 zVoxel = s32(ChunkRelRectMin.z); zVoxel < s32(ChunkRelRectMax.z); zVoxel += 1) - { - for (s32 yVoxel = s32(ChunkRelRectMin.y); yVoxel < s32(ChunkRelRectMax.y); yVoxel += 1) - { - for (s32 xVoxel = s32(ChunkRelRectMin.x); xVoxel < s32(ChunkRelRectMax.x); xVoxel += 1) - { - voxel_position RelVoxP = Voxel_Position(s32(xVoxel), s32(yVoxel), s32(zVoxel)); - voxel *V = GetVoxel(Chunk, RelVoxP); - - v3i SimSpaceVoxPExact = V3i(xVoxel, yVoxel, zVoxel) + SimSpaceChunkMin; - - Assert(UpdateMinP <= SimSpaceVoxPExact); - u32 Index = MapIntoQueryBox(SimSpaceVoxPExact, UpdateMinP, UpdateDim); - Assert(s32(Index) < TotalVoxels); - Assert(CopiedChunk.Voxels[Index].Flags != Global_UnsetVoxel.Flags); - Assert(CopiedChunk.Voxels[Index].Transparency != Global_UnsetVoxel.Transparency); - Assert(CopiedChunk.Voxels[Index].Color != Global_UnsetVoxel.Color); - - Assert( (V->Flags & Voxel_MarkBit) == 0); - StartedFilled += (V->Flags&Voxel_Filled); -#if VOXEL_DEBUG_COLOR - V->Flags = CopiedChunk.Voxels[Index].Flags; - V->Color = CopiedChunk.Voxels[Index].Color; - V->Transparency = CopiedChunk.Voxels[Index].Transparency; -#else - *V = CopiedChunk.Voxels[Index]; -#endif - EndedFilled += (V->Flags&Voxel_Filled); - Assert( (V->Flags & Voxel_MarkBit) == 0); - } - } - } - - s32 DiffFilled = EndedFilled - StartedFilled; - Chunk->FilledCount += DiffFilled; - Assert(Chunk->FilledCount >= 0); - } -#endif - - - - // DEBUG CODE - // - -#define DEBUG_VIEW_WORLD_UPDATE 0 -#if DEBUG_VIEW_WORLD_UPDATE - untextured_3d_geometry_buffer *DebugMesh = &GetEngineDebug()->WorldEditDebugMesh; - // TODO(Jesse): Need to copy the voxels because the Greedy thing blows away - // the face flags as it does the traversal. - /* NotImplemented; */ - - chunk_data CD = { Chunk_VoxelsInitialized, UpdateDim, CopiedChunk.Voxels, 0 }; - vox_data Vox = {&CD}; -#if VOXEL_DEBUG_COLOR - BuildWorldChunkMeshFromMarkedVoxels_Naieve( CopiedChunk.Voxels, UpdateDim, {}, UpdateDim, DebugMesh ); -#else - BuildWorldChunkMeshFromMarkedVoxels_Greedy( &Vox, DebugMesh, 0, GetTranArena()); -#endif - - /* aabb QueryAABB = AABBMinMax( {}, V3i(7.f + Radius*2.f) ); */ - - DEBUG_DrawAABB(DebugMesh, AABBMinDim({}, V3(UpdateDim)), BLUE); - - DEBUG_DrawAABB(DebugMesh, AABBMinDim(V3(-1), V3(2)), PINK); - -/* world_chunk *TempChunk = AllocateWorldChunk(Thread->PermMemory, MinP.WorldP, UpdateDim); */ -/* picked_world_chunk *PickedChunk = Allocate(picked_world_chunk, Thread->PermMemory, 1); */ -/* PickedChunk->Chunk = TempChunk; */ - - /* v3 QueryRelLocation = V3(SimSphereP) - UpdateMinP; */ - /* DrawVoxel_MinDim(DebugMesh, QueryRelLocation, V4(1,0,0,1), V3(1.f)); */ -#endif - - voxel_position_cursor StandingSpots = V3iCursor(ChunkCount*WORLD_CHUNK_STANDING_SPOT_COUNT, Thread->TempMemory); - - /* if (GetLevelEditor()->Flags & LevelEditorFlags_StandingSpotsOnLevelLoad) */ -#if 0 - NotImplemented; -#else - { - ComputeStandingSpots( UpdateDim, CopiedChunk.Voxels, {}, - {}, - Global_StandingSpotDim, - UpdateDim, - 0, - &StandingSpots, Thread->TempMemory ); - } -#endif - - FullBarrier; - for (u32 ChunkIndex = 0; ChunkIndex < ChunkCount; ++ChunkIndex) - { - world_chunk *Chunk = DestChunkBuffer[ChunkIndex]; - - rect3i SimSpaceChunkAABB = GetSimSpaceAABBi(World, Chunk); - auto QueryRelChunkAABB = SimSpaceChunkAABB - UpdateMinP; -#if DEBUG_VIEW_WORLD_UPDATE - DEBUG_DrawAABB(DebugMesh, &QueryRelChunkAABB, RED); -#endif - - /* DebugLine("Start StandingSpotCount(%d)/(%d)", AtElements(&Chunk->StandingSpots), Count(&Chunk->StandingSpots)); */ - - auto SimSpaceChunkRect = GetSimSpaceAABBi(World, Chunk); - auto SimSpaceChunkMin = SimSpaceChunkRect.Min; - - // NOTE(Jesse): Cull old standing spots that are entirely inside the update AABB - u32 StandingSpotIndex = 0; - for (;;) - { - u32 LastIndex = (u32)AtElements(&Chunk->StandingSpots); - if (StandingSpotIndex >= LastIndex) { break; } - - voxel_position ChunkSpot = Chunk->StandingSpots.Start[StandingSpotIndex]; - voxel_position ChunkSimSpot = SimSpaceChunkMin + ChunkSpot; - rect3i SimSpotAABB = Rect3iMinDim(ChunkSimSpot, Global_StandingSpotDim); - - voxel_position QueryRelChunkSpot = ChunkSimSpot - UpdateMinP; - - { - /* DrawStandingSpot(Mesh, V3(QueryRelChunkSpot), V3(Global_StandingSpotDim), TEAL, DEFAULT_STANDING_SPOT_THICKNESS*1.5f); */ - } - - auto SimSpaceSpotUnion = Union(&SimSpotAABB, &SimSpaceUpdateBounds); - auto SimSpaceUnionDim = GetDim(SimSpaceSpotUnion); - if (Volume(SimSpaceSpotUnion) == Volume(Global_StandingSpotDim)) // Cull - { - voxel_position QueryRelUnion = SimSpaceSpotUnion.Min - UpdateMinP; - voxel_position SwapSpot = Pop(&Chunk->StandingSpots); - Chunk->StandingSpots.Start[StandingSpotIndex] = SwapSpot; - /* DebugLine("Dropping StandingSpot(%d,%d,%d)", ChunkSpot.x, ChunkSpot.y, ChunkSpot.z); */ - /* DrawVoxel_MinDim(Mesh, V3(QueryRelUnion), ORANGE, V3(SimSpaceUnionDim), DEFAULT_LINE_THICKNESS*2.f); */ -#if DEBUG_VIEW_WORLD_UPDATE - DrawStandingSpot(DebugMesh, V3(QueryRelChunkSpot), V3(Global_StandingSpotDim), RED, DEFAULT_STANDING_SPOT_THICKNESS*2.f); -#endif - } - else - { - /* DebugLine("Keeping StandingSpot(%d,%d,%d)", ChunkSpot.x, ChunkSpot.y, ChunkSpot.z); */ -#if DEBUG_VIEW_WORLD_UPDATE - DrawStandingSpot(DebugMesh, V3(QueryRelChunkSpot), V3(Global_StandingSpotDim), GREEN, DEFAULT_STANDING_SPOT_THICKNESS*2.f); -#endif - ++StandingSpotIndex; - } - } - - // Cull gen'd standing spots that overlap with any current standing spots - for (StandingSpotIndex = 0; StandingSpotIndex < AtElements(&StandingSpots); ++StandingSpotIndex) - { - voxel_position QueryRelSpot = StandingSpots.Start[StandingSpotIndex]; - voxel_position SimSpot = QueryRelSpot + UpdateMinP; - rect3i SimSpotAABB = Rect3iMinDim(SimSpot, Global_StandingSpotDim); - - // - // NOTE(Jesse): I'm not entirely sure this is working properly, but it seems to be - b32 Skip = false; - for (u32 ChunkStandingSpotIndex = 0; ChunkStandingSpotIndex < AtElements(&Chunk->StandingSpots); ++ChunkStandingSpotIndex) - { - voxel_position ChunkSpot = Chunk->StandingSpots.Start[ChunkStandingSpotIndex]; - voxel_position ChunkSimSpot = ChunkSpot + SimSpaceChunkMin; - rect3i ChunkSimSpotAABB = Rect3iMinDim(ChunkSimSpot, Global_StandingSpotDim); - if (Volume(Union(&SimSpotAABB, &ChunkSimSpotAABB))) - { - Skip = true; - break; - } - } - - if (!Skip) - { -#if DEBUG_VIEW_WORLD_UPDATE - DrawStandingSpot(DebugMesh, V3(QueryRelSpot), V3(Global_StandingSpotDim), TEAL, DEFAULT_STANDING_SPOT_THICKNESS*1.5f); -#endif - if ( Contains(SimSpaceChunkAABB, SimSpot) ) - { - voxel_position ChunkRelSpot = SimSpot - SimSpaceChunkAABB.Min; - Assert(Contains(World->ChunkDim, ChunkRelSpot)); - if (Remaining(&Chunk->StandingSpots)) - { - Push(ChunkRelSpot, &Chunk->StandingSpots); - } - else - { - Warn("Ran out of standing spots on world_chunk (%p)", Chunk); - break; - } - } - } - } - - /* DebugLine("End StandingSpotCount(%d)", AtElements(&Chunk->StandingSpots)); */ - - UnSetFlag(&Chunk->Flags, Chunk_Queued); - /* QueueChunkForInit(Queue, Chunk); */ - /* QueueChunkForMeshRebuild(Queue, Chunk); */ - QueueChunkForMeshRebuild(Queue, Chunk); - } -} link_internal maybe_standing_spot GetClosestToP(world *World, standing_spot_buffer *Spots, cp P) @@ -5744,15 +4424,13 @@ BufferChunkMesh( graphics *Graphics, auto CopyBuffer = ReserveBufferSpace( Dest, Src->At); if (Length(Rot.xyz) == 0.f) { - BufferVertsChecked(&CopyBuffer, Src->At, - Src->Verts, Src->Normals, Src->Mat, + BufferVertsChecked(&CopyBuffer, Src, ModelBasisP, V3(Scale)); } else { - BufferVertsChecked(&CopyBuffer, Src->At, - Src->Verts, Src->Normals, Src->Mat, + BufferVertsChecked(&CopyBuffer, Src, ModelBasisP, V3(Scale), Rot); } } diff --git a/src/engine/world_chunk.h b/src/engine/world_chunk.h index f3e1d2d50..bde0dd2c4 100644 --- a/src/engine/world_chunk.h +++ b/src/engine/world_chunk.h @@ -198,6 +198,9 @@ struct chunk_data voxel_lighting *VoxelLighting; }; +poof(maybe(chunk_data)) +#include + // NOTE(Jesse): These are literal indices and as such must start at 0 // TODO(Jesse): Rename this to something like mesh_lod_index enum world_chunk_mesh_index @@ -257,18 +260,18 @@ ToIndex(world_chunk_mesh_bitfield Bit) return MeshIndex_Count; } -// TODO(Jesse): Probably consolodate with lod_element_buffer ? -struct world_chunk_lod_element_buffer -{ - // TODO(Jesse): Remove this - volatile u32 MeshMask; +/* // TODO(Jesse): Probably consolodate with lod_element_buffer ? */ +/* struct world_chunk_lod_element_buffer */ +/* { */ +/* // TODO(Jesse): Remove this */ +/* volatile u32 MeshMask; */ - gpu_element_buffer_handles GpuBufferHandles[MeshIndex_Count]; +/* gpu_element_buffer_handles GpuBufferHandles[MeshIndex_Count]; */ - // Src meshes, read-only - world_chunk_geometry_buffer *E[MeshIndex_Count]; - bonsai_futex Locks[MeshIndex_Count]; -}; +/* // Src meshes, read-only */ +/* world_chunk_geometry_buffer *E[MeshIndex_Count]; */ +/* bonsai_futex Locks[MeshIndex_Count]; */ +/* }; */ struct lod_element_buffer { @@ -329,64 +332,43 @@ struct world_chunk { // NOTE(Jesse): Since we waste so much space with padding this thing out we // can afford to have a next pointer to keep the freelist - world_chunk *Next; - /* void *Next; // NOTE(Jesse): This gets cast to a "free_list_thing", so this just */ - // takes up the space where the pointer value gets saved .. - - /* poof( use_struct(chunk_data) ) */ - -/* union */ -/* { */ -/* chunk_data ChunkData; */ - /* struct */ - /* { */ - /* chunk_flag Flags; */ - /* v3i Dim; // TODO(Jesse): can be 3x u8 instead of 3x s32 */ - /* voxel *Voxels; */ - /* voxel_lighting *VoxelLighting; */ - /* }; */ - -/* }; */ + world_chunk *Next; poof(@no_serialize) - - chunk_flag Flags; - v3i Dim; // TODO(Jesse): can be 3x u8 instead of 3x s32 - voxel *Voxels; - voxel_lighting *VoxelLighting; + // chunk_data { + chunk_flag Flags; poof(@no_serialize) + v3i Dim; // could be compressed? + voxel *Voxels; poof(@array_length( Cast(umm, Volume(Element->Dim)))) + voxel_lighting *VoxelLighting; poof(@array_length( Cast(umm, Volume(Element->Dim)))) + // } // TODO(Jesse): This stores pointers that are completely ephemeral and as // such are wasted space. We could remove those to make this struct 24 bytes // smaller, which is probably pretty worth. - world_chunk_lod_element_buffer Meshes; + lod_element_buffer Meshes; poof(@no_serialize) /* threadsafe_geometry_buffer TransparentMeshes; */ /* gpu_mapped_element_buffer GpuBuffers[MeshIndex_Count]; */ - - voxel_position_cursor StandingSpots; + voxel_position_cursor StandingSpots; poof(@no_serialize) v3i WorldP; - s32 FilledCount; - b32 DrawBoundingVoxels; + s32 FilledCount; poof(@no_serialize) + b32 DrawBoundingVoxels; poof(@no_serialize) - s32 PointsToLeaveRemaining; - u32 TriCount; - s32 EdgeBoundaryVoxelCount; + s32 PointsToLeaveRemaining; poof(@no_serialize) + u32 TriCount; poof(@no_serialize) + s32 EdgeBoundaryVoxelCount; poof(@no_serialize) - u32 _Pad0; - /* u8 DimX; */ - /* u8 DimY; */ - /* u8 DimZ; */ - /* u8 _Pad0; */ + u32 _Pad0; poof(@no_serialize) // NOTE(Jesse): This is a list of all entities overlapping this chunk to be // considered for collision detection. - entity_ptr_block_array Entities; + entity_ptr_block_array Entities; poof(@no_serialize) // TODO(Jesse): Probably take this out? - s32 DEBUG_OwnedByThread; + s32 DEBUG_OwnedByThread; poof(@no_serialize) #if VOXEL_DEBUG_COLOR f32 *NoiseValues; poof(@no_serialize @array_length(Volume(Element->Dim))) @@ -409,6 +391,7 @@ CAssert(sizeof(voxel_position_cursor) == 24); /* CAssert(sizeof(world_chunk) % CACHE_LINE_SIZE == 0); */ typedef world_chunk* world_chunk_ptr; +typedef world_chunk** world_chunk_ptr_ptr; poof(buffer(world_chunk_ptr)) #include @@ -416,6 +399,7 @@ poof(buffer(world_chunk_ptr)) poof(block_array_h(world_chunk_ptr, {32}, {})) #include + struct octave { v3 Freq; @@ -745,3 +729,18 @@ TryGetVoxel(world *World, cp P) link_internal void DeallocateAndClearWorldChunk(engine_resources *Engine, world_chunk *Chunk); + +link_internal s32 +MarkBoundaryVoxels_MakeExteriorFaces( voxel *Voxels, chunk_dimension SrcChunkDim, chunk_dimension SrcChunkMin, chunk_dimension SrcChunkMax ); + +/* link_internal world_chunk_geometry_buffer* */ +/* AllocateTempWorldChunkMesh(memory_arena* TempMemory); */ + +link_internal void +RebuildWorldChunkMesh(thread_local_state *Thread, world_chunk *Chunk, v3i MinOffset, v3i MaxOffset, world_chunk_mesh_bitfield MeshBit, geo_u3d *TempMesh, memory_arena *TempMem, v3 VertexOffset); + +link_internal void +FinalizeChunkInitialization(world_chunk *Chunk); + +link_internal untextured_3d_geometry_buffer* +AllocateTempMesh(memory_arena* TempMemory, data_type Type); diff --git a/src/engine/world_update.cpp b/src/engine/world_update.cpp new file mode 100644 index 000000000..32bd89bdf --- /dev/null +++ b/src/engine/world_update.cpp @@ -0,0 +1,1394 @@ +link_export THREAD_MAIN_RETURN +WorldUpdateThread_Main(void *ThreadStartupParams) +{ + b32 InitResult = True; + thread_startup_params *ThreadParams = Cast(thread_startup_params*, ThreadStartupParams); + + engine_resources *Engine = Cast(engine_resources*, ThreadParams->EngineResources); + + SetThreadLocal_ThreadIndex(ThreadParams->ThreadIndex); + + thread_local_state *Thread = GetThreadLocalState(ThreadLocal_ThreadIndex); + + Assert(Global_EngineResources); + Assert(Global_ThreadStates); + + while ( FutexNotSignaled(ThreadParams->WorkerThreadsExitFutex) ) + { + UNPACK_ENGINE_RESOURCES(Engine); + + WORKER_THREAD_ADVANCE_DEBUG_SYSTEM(); + WorkerThread_BeforeJobStart(ThreadParams); + + world_chunk_ptr_block_array UpdatedChunks = {0, 0, Thread->TempMemory}; + + while (work_queue_entry *Entry = PopWorkQueueEntry(WorldUpdateQ)) + { + tswitch(Entry) + { + case type_work_queue_entry_noop: + case type_work_queue_entry_init_world_chunk: + case type_work_queue_entry_copy_buffer_set: + case type_work_queue_entry_copy_buffer_ref: + case type_work_queue_entry_init_asset: + case type_work_queue_entry_rebuild_mesh: + case type_work_queue_entry_sim_particle_system: + case type_work_queue_entry__align_to_cache_line_helper: + case type_work_queue_entry_async_function_call: + case type_work_queue_entry__bonsai_render_command: + { + InvalidCodePath(); + } break; + + case type_work_queue_entry_update_world_region: + { + work_queue_entry_update_world_region *Job = SafeAccess(work_queue_entry_update_world_region, Entry); + DoWorldUpdate(&Engine->Stdlib.Plat.LowPriority, World, Thread, Job); + + RangeIterator_t(u32, ChunkIndex, Job->ChunkCount) + { + world_chunk *Chunk = Job->DestChunkBuffer[ChunkIndex]; + // Only push each chunk to have it's mesh rebuilt once, even if it + // was updated multiple times. + if (Chunk->Flags & Chunk_Queued) + { + UnSetFlag(&Chunk->Flags, Chunk_Queued); + Push(&UpdatedChunks, &Chunk); + } + } + + + } break; + + } + + } + + IterateOver(&UpdatedChunks, Chunk, ChunkIndex) + { + QueueChunkForMeshRebuild(&Plat->LowPriority, *Chunk); + } + + // NOTE(Jesse): This is intentionally after all the updates have completed + // such that the UpdatedChunks block array persists between jobs and we + // clear it at the end. + RewindArena(GetTranArena()); + + SleepMs(1); + + if (FutexIsSignaled(ThreadParams->WorkerThreadsExitFutex)) break; + + if (FutexIsSignaled(ThreadParams->WorkerThreadsSuspendFutex)) { WaitOnFutex(ThreadParams->WorkerThreadsSuspendFutex); } + } + + + Info("Exiting WorldUpdate Thread (%d)", ThreadParams->ThreadIndex); + WaitOnFutex(ThreadParams->WorkerThreadsExitFutex); + + THREAD_MAIN_RETURN Result = ReinterpretCast(THREAD_MAIN_RETURN, InitResult); + return Result; +} + +link_internal void +BlitAssetIntoWorld(engine_resources *Engine, asset *Asset, cp Origin) +{ + world *World = Engine->World; + + Assert(Asset->LoadState == AssetLoadState_Loaded); + + world_chunk SrcChunk = {}; + chunk_dimension ModelDim = {}; + switch (Asset->Type) + { + InvalidCase(AssetType_Undefined); + + case AssetType_Models: + { + Assert(Asset->Models.Count > 0); + chunk_data *VoxData = Asset->Models.Start[0].Vox.ChunkData; + + ModelDim = Asset->Models.Start[0].Dim; + + SrcChunk = { + .Flags = VoxData->Flags, + .Dim = VoxData->Dim, + .Voxels = VoxData->Voxels, + }; + + } break; + + case AssetType_WorldChunk: + { + SrcChunk = Asset->Chunk; + ModelDim = Asset->Chunk.Dim; + } break; + } + + // TODO(Jesse): Need to account for model offset in its chunk here. + chunk_dimension ChunkCounts = ChunkCountForDim(ModelDim + Origin.Offset, World->ChunkDim); + + DebugLine("%d %d %d", ChunkCounts.x, ChunkCounts.y, ChunkCounts.z); + + DimIterator(xChunk, yChunk, zChunk, ChunkCounts) + { + v3i SrcWorldP = V3i(xChunk, yChunk, zChunk); + + v3i DestWorldP = Origin.WorldP + SrcWorldP; + world_chunk *DestChunk = GetWorldChunkFromHashtable(World, DestWorldP); + if (DestChunk) + { + Assert(DestChunk->Flags & Chunk_VoxelsInitialized); + + v3i SrcVoxelsOffset = (SrcWorldP*World->ChunkDim) - V3i(Origin.Offset); + + MergeChunksOffset(&SrcChunk, DestChunk, SrcVoxelsOffset); + + // NOTE(Jesse): We have to either call MarkBoundaryVoxels_??? here or somehow infer + // what the face values are in the Merge routine + NotImplemented; + + QueueChunkForMeshRebuild(&Engine->Stdlib.Plat.LowPriority, DestChunk); + } + } +} + +link_internal void +QueueWorldUpdateForRegion( engine_resources *Engine, + world_edit_mode Mode, + world_edit_mode_modifier Modifier, + world_edit_shape *Shape, + u16 ColorIndex, + memory_arena *Memory ) +{ + TIMED_FUNCTION(); + + // TODO(Jesse): Should we just remove the paramter? Or do we sometimes not pass this? + Assert(Memory == Engine->WorldUpdateMemory); + + UNPACK_ENGINE_RESOURCES(Engine); + + cp MinPCoarse = {}; + cp MaxPCoarse = {}; + + // NOTE(Jesse): We have to expand by at least two in either direction because + // we need at least one additional voxel to tell if we have a solid face, and + // another one after that in case the last one on the exterior edge is + // transparent and the next one is solid + // + // I can't remember why the MaxPStroke has to be one more, and I actually + // think that it might not . + f32 MinPStroke = 2.f; + f32 MaxPStroke = 3.f; + + switch (Shape->Type) + { + InvalidCase(type_world_update_op_shape_params_noop); + InvalidCase(type_world_update_op_shape_params_count); + + case type_world_update_op_shape_params_sphere: + { + auto *ShapeSphere = SafeCast(world_update_op_shape_params_sphere, Shape); + cp P = ShapeSphere->Location; + + MinPCoarse = Canonicalize(World, P-V3(ShapeSphere->Radius+MinPStroke) - V3(Global_ChunkApronMinDim)); + MaxPCoarse = Canonicalize(World, P+V3(ShapeSphere->Radius+MaxPStroke) + V3(Global_ChunkApronMaxDim)); + } break; + + case type_world_update_op_shape_params_rect: + { + auto *ShapeRect = SafeCast(world_update_op_shape_params_rect, Shape); + +#if 0 + MinPCoarse = ShapeRect->Region.Min; + MaxPCoarse = ShapeRect->Region.Max; +#else + v3 MinP = Min(ShapeRect->Region.Min, ShapeRect->Region.Max); + v3 MaxP = Max(ShapeRect->Region.Min, ShapeRect->Region.Max); + + ShapeRect->Region.Min = MinP; + ShapeRect->Region.Max = MaxP; + + MinPCoarse = SimSpaceToCanonical(World, MinP - V3(MinPStroke) - V3(Global_ChunkApronMinDim)); + MaxPCoarse = SimSpaceToCanonical(World, MaxP + V3(MaxPStroke) + V3(Global_ChunkApronMaxDim)); +#endif + } break; + + case type_world_update_op_shape_params_chunk_data: + { + auto *ShapeChunk = SafeCast(world_update_op_shape_params_chunk_data, Shape); + + v3 MinSimP = ShapeChunk->SimSpaceOrigin; + v3 MaxSimP = MinSimP + ShapeChunk->Data.Dim; + + MinPCoarse = SimSpaceToCanonical(World, MinSimP-MinPStroke); + MaxPCoarse = SimSpaceToCanonical(World, MaxSimP+MaxPStroke); + } break; + + case type_world_update_op_shape_params_asset: + { + auto *ShapeAsset = SafeCast(world_update_op_shape_params_asset, Shape); + + v3 MinSimP = GetSimSpaceP(World, ShapeAsset->Origin); + + asset *Asset = GetAndLockAssetSync(GetEngineResources(), &ShapeAsset->AssetId); + v3 MaxSimP = MinSimP + GetDimForAssetModel(Asset, u32(ShapeAsset->ModelIndex)).Value; + + UnlockAsset(Engine, Asset); + + MinPCoarse = SimSpaceToCanonical(World, MinSimP-MinPStroke); + MaxPCoarse = SimSpaceToCanonical(World, MaxSimP+MaxPStroke); + } break; + } + + // These value align the min/max positions to StandingSpot boundaries in global space + auto MinPFixup = V3i(MinPCoarse.Offset) % V3i(Global_StandingSpotDim.xy, 1); + auto MaxPFixup = V3i(Global_StandingSpotDim.xy, 0) - V3i(MaxPCoarse.Offset) % V3i(Global_StandingSpotDim.xy, 1); + + Assert(MinPFixup.z == 0); + Assert(MaxPFixup.z == 0); + + auto MinP = Canonicalize(World, MinPCoarse - V3(MinPFixup)); + auto MaxP = Canonicalize(World, MaxPCoarse + V3(MaxPFixup)); + + MinP.Offset = Truncate(MinP.Offset); + MaxP.Offset = Truncate(MaxP.Offset); + + Assert(u32(MinP.Offset.x) % u32(Global_StandingSpotDim.x) == 0 ); + Assert(u32(MinP.Offset.y) % u32(Global_StandingSpotDim.y) == 0 ); + + Assert(u32(MaxP.Offset.x) % u32(Global_StandingSpotDim.x) == 0 ); + Assert(u32(MaxP.Offset.y) % u32(Global_StandingSpotDim.y) == 0 ); + + /* { */ + /* r32 Thickness = 0.15f; */ + /* DEBUG_HighlightVoxel(Engine, MinP, BLUE, Thickness); */ + /* DEBUG_HighlightVoxel(Engine, MaxP, RED, Thickness); */ + /* } */ + + /* world_position Delta = Max(MaxP.WorldP - MinP.WorldP, World_Position(1)); */ + v3i Delta = MaxP.WorldP - MinP.WorldP + 1; + u32 TotalChunkCount = Abs(Volume(Delta)); + + // TODO(Jesse)(leak): Each one of these gets leaked at the moment + world_chunk **Buffer = AllocateAligned(world_chunk*, Memory, TotalChunkCount, CACHE_LINE_SIZE); + + u32 ChunkIndex = 0; + for (s32 zChunk = MinP.WorldP.z; zChunk <= MaxP.WorldP.z; ++zChunk) + { + for (s32 yChunk = MinP.WorldP.y; yChunk <= MaxP.WorldP.y; ++yChunk) + { + for (s32 xChunk = MinP.WorldP.x; xChunk <= MaxP.WorldP.x; ++xChunk) + { + world_position ChunkP = World_Position(xChunk, yChunk, zChunk); + world_chunk *Chunk = GetWorldChunkFromHashtable(World, ChunkP); + if (Chunk && Chunk->Flags & Chunk_VoxelsInitialized) + { + Assert(Chunk->Flags != Chunk_Uninitialized); + Assert(ChunkIndex < TotalChunkCount); + Buffer[ChunkIndex++] = Chunk; + SetFlag(Chunk, Chunk_Queued); + } + } + } + } + + // NOTE(Jesse): If none of the world chunks were in the hashtable yet we get ChunkCount == 0 + if (ChunkIndex > 0) + { + v3 SimFloodOrigin = GetHotVoxelForFlood(Engine, Mode, Modifier); + + work_queue_entry Entry = { + .Type = type_work_queue_entry_update_world_region, + .work_queue_entry_update_world_region = WorkQueueEntryUpdateWorldRegion(Mode, Modifier, SimFloodOrigin, Shape, ColorIndex, MinP, MaxP, Buffer, ChunkIndex), + }; + PushWorkQueueEntry(&Plat->WorldUpdateQ, &Entry); + } +} + +link_internal u32 +MapIntoQueryBox(v3i SimSpaceVoxP, v3i UpdateMinP, v3i UpdateDim) +{ + auto Rel = SimSpaceVoxP - UpdateMinP; + auto Result = GetIndex(Rel, UpdateDim); + return (u32)Result; +} + +link_internal u32 +MapIntoQueryBox(v3 SimSpaceVoxP, v3 UpdateMinP, v3i UpdateDim) +{ + v3 Rel = SimSpaceVoxP - UpdateMinP; + s32 Result = GetIndex(Rel, UpdateDim); + return (u32)Result; +} + + +link_internal void +DEBUG_AssertVoxelFloodStartsInEmptyVoxel(v3i SimSphereP, rect3i *SimSpaceUpdateBounds, voxel *CopiedVoxels) +{ +#if 1 +#if BONSAI_INTERNAL + v3i UpdateDim = GetDim(*SimSpaceUpdateBounds); + + { // NOTE(Jesse): Debug. Don't rely on the optimizer to remove this in release mode + // + // This asserts that we're not trying to flood starting at a voxel that's inside the world. + v3i RelVoxP = SimSphereP - SimSpaceUpdateBounds->Min; + s32 VoxelIndex = TryGetIndex(RelVoxP, UpdateDim); + if (VoxelIndex > -1) + { + voxel *OriginV = CopiedVoxels+VoxelIndex; + Assert( (OriginV->Flags&Voxel_Filled) == 0); + } + } +#endif +#endif +} + + + + + + + + +// +// NOTE(Jesse): UserCode gets called when the first +poof( + func flood_fill_iteration_pattern(type_poof_symbol FloodPredicate, type_poof_symbol UserCode, type_poof_symbol UserCode2) @code_fragment + { + random_series ColorEntropy = {4654376543246}; + + voxel *V = {}; + // TODO(Jesse): Do we want to try and keep the amount of temp memory to a minimum here? + voxel_stack_element_cursor Stack = VoxelStackElementCursor(umm(TotalVoxels*6), Thread->TempMemory); + + // Unfortunately, can't #if this out in a poof function. Should probably + // put it on a #define switch to make sure it gets compiled out. + DEBUG_AssertVoxelFloodStartsInEmptyVoxel(FloodOrigin, &SimSpaceUpdateBounds, CopiedChunk->Voxels); + + Push(&Stack, VoxelStackElement(FloodOrigin, VoxelRuleDir_Count)); + while (AtElements(&Stack)) + { + b32 OverwriteVoxel = False; + + voxel_stack_element Element = Pop(&Stack); + v3i SimVoxP = Element.VoxSimP + AllDirections[Element.Dir]; + v3i RelVoxP = SimVoxP - SimSpaceUpdateBounds.Min; + + s32 VoxelIndex = TryGetIndex(RelVoxP, UpdateDim); + if (VoxelIndex > -1) + { + V = CopiedChunk->Voxels+VoxelIndex; + + v3i CenterToVoxP = SimVoxP - FloodOrigin; + + (FloodPredicate) + { + if ( (V->Flags & Voxel_MarkBit) == 0) + { + Push(&Stack, VoxelStackElement(SimVoxP, VoxelRuleDir_PosX)); + Push(&Stack, VoxelStackElement(SimVoxP, VoxelRuleDir_NegX)); + Push(&Stack, VoxelStackElement(SimVoxP, VoxelRuleDir_PosY)); + Push(&Stack, VoxelStackElement(SimVoxP, VoxelRuleDir_NegY)); + Push(&Stack, VoxelStackElement(SimVoxP, VoxelRuleDir_PosZ)); + Push(&Stack, VoxelStackElement(SimVoxP, VoxelRuleDir_NegZ)); + } + } + + (UserCode) + + V->Flags |= Voxel_MarkBit; + + if ( ((OverwriteVoxel == True) && (Invert == False)) || + ((OverwriteVoxel == False) && (Invert == True)) ) + { + if (Mode == WorldEdit_Mode_Paint) + { + V->Color = NewVoxelValue->Color; + } + else + { + *V = *NewVoxelValue; + } + } + } + } + + Push(&Stack, VoxelStackElement(FloodOrigin, VoxelRuleDir_Count)); + while (AtElements(&Stack)) + { + voxel_stack_element Element = Pop(&Stack); + v3i Dir = AllDirections[Element.Dir]; + { + v3i SimVoxP = Element.VoxSimP + Dir; + v3i RelVoxP = SimVoxP - SimSpaceUpdateBounds.Min; + + s32 VoxelIndex = TryGetIndex(RelVoxP, UpdateDim); + + if (VoxelIndex > -1) + { + V = CopiedChunk->Voxels+VoxelIndex; + + (UserCode2) + + if ( (V->Flags&Voxel_MarkBit)) + { + Push(&Stack, VoxelStackElement(SimVoxP, VoxelRuleDir_PosX)); + Push(&Stack, VoxelStackElement(SimVoxP, VoxelRuleDir_NegX)); + Push(&Stack, VoxelStackElement(SimVoxP, VoxelRuleDir_PosY)); + Push(&Stack, VoxelStackElement(SimVoxP, VoxelRuleDir_NegY)); + Push(&Stack, VoxelStackElement(SimVoxP, VoxelRuleDir_PosZ)); + Push(&Stack, VoxelStackElement(SimVoxP, VoxelRuleDir_NegZ)); + } + + V->Flags &= ~Voxel_MarkBit; + } + } + } + } +) + + +poof( + func rectalinear_iteration_pattern(type_poof_symbol UserCode) @code_fragment + { + DimIterator(x, y, z, UpdateDim) + { + b32 OverwriteVoxel = False; + + v3i VoxP = V3i(x,y,z); + v3i SimVoxP = VoxP + SimSpaceUpdateBounds.Min; + voxel *V = CopiedChunk->Voxels + GetIndex(VoxP, UpdateDim); + + if (Contains(SSRect, SimVoxP)) + { + UserCode + + if ( ((OverwriteVoxel == True ) && (Invert == False)) || + ((OverwriteVoxel == False) && (Invert == True )) ) + { + if (Mode == WorldEdit_Mode_Paint) + { + V->Color = NewVoxelValue->Color; + } + else + { + if (Mode == WorldEdit_Mode_Remove) { *V = {}; } + else { *V = *NewVoxelValue; } + } + + // Knock out face flags so the 'surface' algorithm doesn't "self-apply" + // We recompute these, so it's fine there. It's slower on non-surface + // paths, but .. when that's the bottleneck, we've won. + V->Flags = voxel_flag(V->Flags&~VoxelFaceMask); + } + } + } + + } +) + +// TODO(Jesse): Make this not a macro. +#define poof_check_for_unfilled_border() \ + { \ + if (voxel *Vn = TryGetVoxel(CopiedChunk, VoxP + V3(1,0,0))) \ + { \ + if ((Vn->Flags&VoxelFaceMask)) { IsUnfilledBorder = True; } \ + } \ + if (voxel *Vn = TryGetVoxel(CopiedChunk, VoxP + V3(-1,0,0))) \ + { \ + if ((Vn->Flags&VoxelFaceMask)) { IsUnfilledBorder = True; } \ + } \ + \ + if (voxel *Vn = TryGetVoxel(CopiedChunk, VoxP + V3(0,1,0))) \ + { \ + if ((Vn->Flags&VoxelFaceMask)) { IsUnfilledBorder = True; } \ + } \ + if (voxel *Vn = TryGetVoxel(CopiedChunk, VoxP + V3(0,-1,0))) \ + { \ + if ((Vn->Flags&VoxelFaceMask)) { IsUnfilledBorder = True; } \ + } \ + \ + if (voxel *Vn = TryGetVoxel(CopiedChunk, VoxP + V3(0,0,1))) \ + { \ + if ((Vn->Flags&VoxelFaceMask)) { IsUnfilledBorder = True; } \ + } \ + if (voxel *Vn = TryGetVoxel(CopiedChunk, VoxP + V3(0,0,-1))) \ + { \ + if ((Vn->Flags&VoxelFaceMask)) { IsUnfilledBorder = True; } \ + } \ + } \ + +#if 0 +poof( + func poof_check_for_unfilled_border(ignored) + { + if (voxel *Vn = TryGetVoxel(CopiedChunk, VoxP + V3(1,0,0))) + { + if ((Vn->Flags&VoxelFaceMask)) { IsUnfilledBorder = True; } + } + if (voxel *Vn = TryGetVoxel(CopiedChunk, VoxP + V3(-1,0,0))) + { + if ((Vn->Flags&VoxelFaceMask)) { IsUnfilledBorder = True; } + } + + if (voxel *Vn = TryGetVoxel(CopiedChunk, VoxP + V3(0,1,0))) + { + if ((Vn->Flags&VoxelFaceMask)) { IsUnfilledBorder = True; } + } + if (voxel *Vn = TryGetVoxel(CopiedChunk, VoxP + V3(0,-1,0))) + { + if ((Vn->Flags&VoxelFaceMask)) { IsUnfilledBorder = True; } + } + + if (voxel *Vn = TryGetVoxel(CopiedChunk, VoxP + V3(0,0,1))) + { + if ((Vn->Flags&VoxelFaceMask)) { IsUnfilledBorder = True; } + } + if (voxel *Vn = TryGetVoxel(CopiedChunk, VoxP + V3(0,0,-1))) + { + if ((Vn->Flags&VoxelFaceMask)) { IsUnfilledBorder = True; } + } + } +) +#endif + + + + + + + +// +// +// shape_sphere +// +// + + +link_internal void +WorldEdit_shape_sphere_Surface(apply_world_edit_params *Params, r32 RadiusSquared, v3i EditCenterP, voxel *NewVoxelValue) +{ + UNPACK_APPLY_WORLD_EDIT_PARAMS(Params); + switch (Mode) + { + case WorldEdit_Mode_Disabled: {} break; + + case WorldEdit_Mode_Attach: + { + poof(rectalinear_iteration_pattern({ + + v3i CenterToVoxP = SimVoxP - EditCenterP; + if (LengthSq(CenterToVoxP) < RadiusSquared && (V->Flags&Voxel_Filled) == False) + { + b32 IsUnfilledBorder = False; + poof_check_for_unfilled_border() + Assert(NewVoxelValue->Flags & Voxel_Filled); + if (IsUnfilledBorder) + { + OverwriteVoxel = True; + } + } + })) +#include + } break; + + case WorldEdit_Mode_Paint: + case WorldEdit_Mode_Remove: + { + poof(rectalinear_iteration_pattern({ + v3i CenterToVoxP = SimVoxP - EditCenterP; + if (LengthSq(CenterToVoxP) < RadiusSquared && (V->Flags&VoxelFaceMask)) + { + OverwriteVoxel = True; + } + })) +#include + } break; + } +} + +link_internal void +WorldEdit_shape_sphere_Flood(apply_world_edit_params *Params, thread_local_state *Thread, r32 RadiusSquared, v3i EditCenterP, v3i FloodOrigin, voxel *NewVoxelValue) +{ + UNPACK_APPLY_WORLD_EDIT_PARAMS(Params); + s32 TotalVoxels = Volume(UpdateDim); + + Assert(Params->Mode == WorldEdit_Mode_Remove); + + poof(flood_fill_iteration_pattern( + { + if (LengthSq(CenterToVoxP) < RadiusSquared && (V->Flags&Voxel_Filled) == 0) + }, + { + if ( Length(CenterToVoxP) < SquareRoot(RadiusSquared)-1.f && (V->Flags&Voxel_Filled) ) + { V->Flags = Voxel_Empty; } + }, + { + v3i CenterToVoxP = SimVoxP - EditCenterP; + if (Length(CenterToVoxP) < SquareRoot(RadiusSquared)-1.f) + { + if (V->Flags & Voxel_Filled) + { + V->Color = SafeTruncateU8(RandomBetween((u32)GREY_5, &ColorEntropy, (u32)GREY_8+1)); + } + + } + else if (LengthSq(CenterToVoxP) < RadiusSquared) + { + V->Color = GREY_8; + } + } + )) +#include +} + +link_internal void +WorldEdit_shape_sphere_Default(apply_world_edit_params *Params, r32 RadiusSquared, v3i EditCenterP, voxel *NewVoxelValue) +{ + UNPACK_APPLY_WORLD_EDIT_PARAMS(Params); + + poof(rectalinear_iteration_pattern({ + v3i CenterToVoxP = SimVoxP - EditCenterP; + if (LengthSq(CenterToVoxP) < RadiusSquared) + { + OverwriteVoxel = True; + } + })) +#include +} + + +// +// +// shape_rect +// +// + +link_internal void +WorldEdit_shape_rect_Surface(apply_world_edit_params *Params, voxel *NewVoxelValue) +{ + UNPACK_APPLY_WORLD_EDIT_PARAMS(Params); + + switch (Mode) + { + case WorldEdit_Mode_Disabled: {} break; + + case WorldEdit_Mode_Attach: + { + poof(rectalinear_iteration_pattern({ + + if ((V->Flags&Voxel_Filled) == False) + { + b32 IsUnfilledBorder = False; + poof_check_for_unfilled_border() + Assert(NewVoxelValue->Flags & Voxel_Filled); + if (IsUnfilledBorder) + { + OverwriteVoxel = True; + } + } + })) +#include + } break; + + case WorldEdit_Mode_Paint: + case WorldEdit_Mode_Remove: + { + poof(rectalinear_iteration_pattern({ + if ( (V->Flags&VoxelFaceMask)) + { + OverwriteVoxel = True; + } + })) +#include + } break; + } +} + +link_internal void +WorldEdit_shape_rect_Flood( apply_world_edit_params *Params, thread_local_state *Thread, v3i FloodOrigin, voxel *NewVoxelValue) +{ + UNPACK_APPLY_WORLD_EDIT_PARAMS(Params); + s32 TotalVoxels = Volume(UpdateDim); + + switch (Mode) + { + case WorldEdit_Mode_Disabled: {} break; + + case WorldEdit_Mode_Paint: + case WorldEdit_Mode_Attach: + case WorldEdit_Mode_Remove: + { + poof(flood_fill_iteration_pattern( + { if ( (V->Flags&Voxel_Filled) == (Voxel_Filled*(Mode==WorldEdit_Mode_Attach)) ) }, + { + if ( Mode == WorldEdit_Mode_Attach && (V->Flags&Voxel_Filled) ) + { } + else + { + OverwriteVoxel = True; + } + }, + {} + )) +#include + } break; + } +} + +link_internal void +WorldEdit_shape_rect_Default(apply_world_edit_params *Params, voxel *NewVoxelValue) +{ + UNPACK_APPLY_WORLD_EDIT_PARAMS(Params); + switch (Mode) + { + case WorldEdit_Mode_Disabled: {} break; + case WorldEdit_Mode_Attach: + case WorldEdit_Mode_Remove: + { + poof(rectalinear_iteration_pattern({ + OverwriteVoxel = True; + })) +#include + } break; + + case WorldEdit_Mode_Paint: + { + poof(rectalinear_iteration_pattern({ + if (V->Flags & Voxel_Filled) + { + OverwriteVoxel = True; + } + })) +#include + } break; + } +} + + + + + + +// +// +// shape_chunk_data +// +// + +link_internal void +WorldEdit_shape_chunk_data_Surface(apply_world_edit_params *Params, v3 SimOrigin, chunk_data *Data) +{ + UNPACK_APPLY_WORLD_EDIT_PARAMS(Params); + + switch (Mode) + { + case WorldEdit_Mode_Disabled: {} break; + + case WorldEdit_Mode_Attach: + { + poof(rectalinear_iteration_pattern({ + + v3i OriginToCurrentVoxP = SimVoxP - SimOrigin; + voxel *NewVoxelValue = TryGetVoxel(Data, OriginToCurrentVoxP); + + if ((V->Flags&Voxel_Filled)==False) + { + b32 IsUnfilledBorder = False; + poof_check_for_unfilled_border() + if (IsUnfilledBorder) + { + OverwriteVoxel = True; + } + } + })) +#include + } break; + + case WorldEdit_Mode_Paint: + case WorldEdit_Mode_Remove: + { + poof(rectalinear_iteration_pattern({ + v3i OriginToCurrentVoxP = SimVoxP - SimOrigin; + voxel *NewVoxelValue = TryGetVoxel(Data, OriginToCurrentVoxP); + if (NewVoxelValue) + { + if ( (V->Flags&VoxelFaceMask) && (NewVoxelValue->Flags&Voxel_Filled) ) + { + OverwriteVoxel = True; + } + } + })) +#include + } break; + } +} + +link_internal void +WorldEdit_shape_chunk_data_Flood( + apply_world_edit_params *Params, + v3 SimOrigin, chunk_data *Data, + thread_local_state *Thread, v3i FloodOrigin + ) +{ + UNPACK_APPLY_WORLD_EDIT_PARAMS(Params); + + s32 TotalVoxels = Volume(UpdateDim); + switch (Mode) + { + case WorldEdit_Mode_Disabled: {} break; + case WorldEdit_Mode_Attach: + { + poof(flood_fill_iteration_pattern( + { + v3i OriginToCurrentVoxP = SimVoxP - SimOrigin; + voxel *NewVoxelValue = TryGetVoxel(Data, OriginToCurrentVoxP); + if ((V->Flags&Voxel_Filled)) + }, + { + if ( ((V->Flags&Voxel_Filled) == 0) && NewVoxelValue && (NewVoxelValue->Flags&Voxel_Filled)) { *V = *NewVoxelValue; } + }, + {} + )) +#include + } break; + + case WorldEdit_Mode_Remove: + { + poof(flood_fill_iteration_pattern( + { + v3i OriginToCurrentVoxP = SimVoxP - SimOrigin; + voxel *NewVoxelValue = TryGetVoxel(Data, OriginToCurrentVoxP); + if (Contains(SSRect, SimVoxP) && (V->Flags&Voxel_Filled) == 0) + }, + { + if (NewVoxelValue && (NewVoxelValue->Flags&Voxel_Filled)) { *V = {}; } + }, + {} + )) +#include + } break; + + case WorldEdit_Mode_Paint: + { + poof(rectalinear_iteration_pattern({ + v3i OriginToCurrentVoxP = SimVoxP - SimOrigin; + voxel *NewVoxelValue = TryGetVoxel(Data, OriginToCurrentVoxP); + if (NewVoxelValue && (NewVoxelValue->Flags&Voxel_Filled)) { V->Color = NewVoxelValue->Color; } + })) +#include + } break; + + } +} + +link_internal void +WorldEdit_shape_chunk_data_Default(apply_world_edit_params *Params, v3 SimOrigin, chunk_data *Data) +{ + UNPACK_APPLY_WORLD_EDIT_PARAMS(Params); + + voxel InvertV = { Voxel_Filled, Params->Transparency, Params->Color }; + + switch (Mode) + { + case WorldEdit_Mode_Disabled: {} break; + + case WorldEdit_Mode_Paint: + case WorldEdit_Mode_Attach: + case WorldEdit_Mode_Remove: + { + poof(rectalinear_iteration_pattern({ + v3i OriginToCurrentVoxP = SimVoxP - SimOrigin; + voxel *AssetV = TryGetVoxel(Data, OriginToCurrentVoxP); + voxel *NewVoxelValue = &InvertV; + if (AssetV && (AssetV->Flags&Voxel_Filled)) + { + NewVoxelValue = AssetV; + OverwriteVoxel = True; + } + })) +#include + } break; + } +} + + + + +link_internal void +ApplyUpdateToRegion(thread_local_state *Thread, work_queue_entry_update_world_region *Job, rect3i SimSpaceUpdateBounds, world_chunk *CopiedChunk, b32 Invert /* = False */) +{ + world *World = GetWorld(); + + random_series ColorEntropy = {4654376543246}; + + v3i UpdateDim = GetDim(SimSpaceUpdateBounds); + s32 TotalVoxels = Volume(UpdateDim); + + world_edit_mode Mode = Job->Brush.Mode; + world_edit_mode_modifier Modifier = Job->Brush.Modifier; + world_edit_shape Shape = Job->Brush.Shape; + /* v3i FloodOrigin = V3i(Job->Brush.SimFloodOrigin); */ + + u16 NewColor = Job->ColorIndex; + u8 NewTransparency = Job->Transparency; + + voxel _NewVoxelValue = {}; + voxel *NewVoxelValue = &_NewVoxelValue; + + if (Mode == WorldEdit_Mode_Attach || Mode == WorldEdit_Mode_Paint) + { +#if VOXEL_DEBUG_COLOR + _NewVoxelValue = { Voxel_Filled, NewTransparency, NewColor, {}, {}}; +#else + _NewVoxelValue = { Voxel_Filled, NewTransparency, NewColor}; +#endif + } + + switch (Shape.Type) + { + InvalidCase(type_world_update_op_shape_params_count); + InvalidCase(type_world_update_op_shape_params_noop); + + case type_world_update_op_shape_params_sphere: + { + world_update_op_shape_params_sphere *Sphere = SafeCast(world_update_op_shape_params_sphere, &Shape); + + v3i EditCenterP = V3i(Floor(GetSimSpaceP(World, Sphere->Location))); + r32 RadiusSquared = Square(Sphere->Radius); + rect3i SSRect = SimSpaceUpdateBounds; + + Assert(EditCenterP > SimSpaceUpdateBounds.Min); + Assert(EditCenterP < SimSpaceUpdateBounds.Max); + + /* rect3i SSRect = RectCenterRad(EditCenterP, V3i(Sphere->Radius)); */ + apply_world_edit_params Params = {Mode, SSRect, SimSpaceUpdateBounds, CopiedChunk, Invert, NewColor, NewTransparency}; + + switch(Modifier) + { + case WorldEdit_Modifier_Default: + { + WorldEdit_shape_sphere_Default(&Params, RadiusSquared, EditCenterP, NewVoxelValue); + } break; + + case WorldEdit_Modifier_Surface: + { + WorldEdit_shape_sphere_Surface(&Params, RadiusSquared, EditCenterP, NewVoxelValue); + } break; + + case WorldEdit_Modifier_Flood: + { + v3i FloodOrigin = EditCenterP; + WorldEdit_shape_sphere_Flood(&Params, Thread, RadiusSquared, EditCenterP, FloodOrigin, NewVoxelValue); + } break; + } + + } break; + + case type_world_update_op_shape_params_rect: + { + world_update_op_shape_params_rect *Rect = SafeCast(world_update_op_shape_params_rect, &Shape); + + // NOTE(Jesse): Outside world should have min/max'd these already + Assert(Rect->Region.Min <= Rect->Region.Max); + + // NOTE(Jesse): These are specifically meant to truncate, not floor + rect3i SSRect = {V3i(Rect->Region.Min), V3i(Rect->Region.Max)}; + v3i EditCenterP = V3i(Floor(Rect->Region.Min+(GetDim(SSRect)/2.f))); + + apply_world_edit_params Params = {Mode, SSRect, SimSpaceUpdateBounds, CopiedChunk, Invert, NewColor, NewTransparency}; + switch (Modifier) + { + case WorldEdit_Modifier_Surface: + { + WorldEdit_shape_rect_Surface(&Params, NewVoxelValue); + } break; + + case WorldEdit_Modifier_Flood: + { + v3i FloodOrigin = EditCenterP; + WorldEdit_shape_rect_Flood(&Params, Thread, FloodOrigin, NewVoxelValue); + } break; + + case WorldEdit_Modifier_Default: + { + WorldEdit_shape_rect_Default(&Params, NewVoxelValue); + } break; + } + } break; + + { + case type_world_update_op_shape_params_asset: + case type_world_update_op_shape_params_chunk_data: + { + asset *Asset = 0; + chunk_data Data = {}; + v3 SimOrigin = {}; + + if (Shape.Type == type_world_update_op_shape_params_asset) + { + world_update_op_shape_params_asset *Casted = SafeCast(world_update_op_shape_params_asset, &Shape); + asset_id *AID = &Casted->AssetId; + Asset = GetAndLockAssetSync(GetEngineResources(), AID); + Data = GetChunkDataForAssetModel(Asset, u32(Casted->ModelIndex)).Value; + SimOrigin = GetSimSpaceP(World, Casted->Origin); + } + else if (Shape.Type == type_world_update_op_shape_params_chunk_data) + { + auto *Casted = SafeCast(world_update_op_shape_params_chunk_data, &Shape); + Data = Casted->Data; + SimOrigin = Casted->SimSpaceOrigin; + } + else + { + InvalidCodePath(); + } + + rect3i SSRect = RectMinDim(V3i(SimOrigin), Data.Dim); + v3i EditCenterP = V3i(SimOrigin) + V3i(Data.Dim/2.f); + + apply_world_edit_params Params = {Mode, SSRect, SimSpaceUpdateBounds, CopiedChunk, Invert, NewColor, NewTransparency}; + switch (Modifier) + { + case WorldEdit_Modifier_Surface: + { + WorldEdit_shape_chunk_data_Surface(&Params, SimOrigin, &Data); + } break; + + case WorldEdit_Modifier_Flood: + { + v3i FloodOrigin = EditCenterP; + WorldEdit_shape_chunk_data_Flood(&Params, SimOrigin, &Data, Thread, FloodOrigin); + } break; + + case WorldEdit_Modifier_Default: + { + WorldEdit_shape_chunk_data_Default(&Params, SimOrigin, &Data); + } break; + } + + if (Asset) { UnlockAsset(GetEngineResources(), Asset); Asset = 0; } + } break; + } + } + +} + +link_internal void +DoWorldUpdate(work_queue *Queue, world *World, thread_local_state *Thread, work_queue_entry_update_world_region *Job) +{ + TIMED_FUNCTION(); + + world_edit_mode Mode = Job->Brush.Mode; + world_edit_mode_modifier Modifier = Job->Brush.Modifier; + world_edit_shape Shape = Job->Brush.Shape; + /* v3i FloodOrigin = V3i(Job->Brush.SimFloodOrigin); */ + + u16 NewColor = Job->ColorIndex; + u8 NewTransparency = Job->Transparency; + cp MaxP = Job->MaxP; + cp MinP = Job->MinP; + world_chunk **DestChunkBuffer = Job->DestChunkBuffer; + u32 ChunkCount = Job->ChunkCount; + + v3 _P0 = GetSimSpaceP(World, MinP); + v3 _P1 = GetSimSpaceP(World, MaxP); + + // TODO(Jesse): Should these not just be assertions? Pretty sure the calling + // code makes sure these are already in 'sorted' order. + v3 P0 = Min(_P0, _P1); + v3 P1 = Max(_P0, _P1); + + // NOTE(Jesse): These are meant to truncate instead of floor + rect3i SimSpaceUpdateBounds = Rect3iMinMax( V3i(P0), V3i(P1) ); + + v3i UpdateDim = GetDim(SimSpaceUpdateBounds); + v3i UpdateMinP = SimSpaceUpdateBounds.Min; + + Assert(UpdateDim.x % Global_StandingSpotDim.x == 0); + Assert(UpdateDim.y % Global_StandingSpotDim.y == 0); + + /* s32 TotalVoxels_signed = Volume(SimSpaceUpdateBounds); */ + /* Assert(TotalVoxels_signed > 0); */ + + world_chunk CopiedChunk = {}; + + s32 TotalVoxels = Volume(UpdateDim); + CopiedChunk.Voxels = Allocate(voxel, Thread->PermMemory, TotalVoxels); + CopiedChunk.Dim = UpdateDim; + + for (s32 VoxelIndex = 0; VoxelIndex < TotalVoxels; ++VoxelIndex) { CopiedChunk.Voxels[VoxelIndex] = Global_UnsetVoxel; } + +#if 1 + for (u32 ChunkIndex = 0; ChunkIndex < ChunkCount; ++ChunkIndex) + { + world_chunk *Chunk = DestChunkBuffer[ChunkIndex]; + auto SimSpaceChunkRect = GetSimSpaceAABBi(World, Chunk); + auto SimSpaceIntersectionRect = Union(&SimSpaceChunkRect, &SimSpaceUpdateBounds); + + auto SimSpaceIntersectionMin = SimSpaceIntersectionRect.Min; + auto SimSpaceIntersectionMax = SimSpaceIntersectionRect.Max; + + auto SimSpaceChunkMin = SimSpaceChunkRect.Min; + auto SimSpaceChunkMax = SimSpaceChunkRect.Max; + + auto ChunkRelRectMin = SimSpaceIntersectionMin - SimSpaceChunkMin; + auto ChunkRelRectMax = SimSpaceIntersectionMax - SimSpaceChunkMin; + + for (s32 zVoxel = s32(ChunkRelRectMin.z); zVoxel < s32(ChunkRelRectMax.z); zVoxel += 1) + { + for (s32 yVoxel = s32(ChunkRelRectMin.y); yVoxel < s32(ChunkRelRectMax.y); yVoxel += 1) + { + for (s32 xVoxel = s32(ChunkRelRectMin.x); xVoxel < s32(ChunkRelRectMax.x); xVoxel += 1) + { + v3i RelVoxP = V3i(s32(xVoxel), s32(yVoxel), s32(zVoxel)); + voxel *V = GetVoxel(Chunk, RelVoxP); + Assert( (V->Flags & Voxel_MarkBit) == 0); + + v3i SimSpaceVoxPExact = V3i(xVoxel, yVoxel, zVoxel) + SimSpaceChunkMin; + + Assert(UpdateMinP <= SimSpaceVoxPExact); + u32 Index = MapIntoQueryBox(SimSpaceVoxPExact, UpdateMinP, UpdateDim); + Assert(s32(Index) < TotalVoxels); + Assert(CopiedChunk.Voxels[Index] == Global_UnsetVoxel); + CopiedChunk.Voxels[Index] = *V; + } + } + } + } +#endif + +#if 0 + world_update_callback Callback = Global_WorldUpdateCallbackTable[Mode][Modifier][Shape.Type]; + if (Callback) + { + Callback(Mode, Modifier, &Shape, DestChunkBuffer, ChunkCount, &SimSpaceUpdateBounds, CopiedChunk.Voxels); + } + else + { + Warn("Attempted to index into an un-implemented world update callback (%S)(%S)(%S).", ToString(Mode), ToString(Modifier), ToString(Shape.Type)); + } +#endif + + ApplyUpdateToRegion(Thread, Job, SimSpaceUpdateBounds, &CopiedChunk); + + + // NOTE(Jesse): We can actually do the entire dim here, but it's probably + // better (faster) to just do what we actually need to + + MarkBoundaryVoxels_NoExteriorFaces( CopiedChunk.Voxels, UpdateDim, {{1,1,1}}, UpdateDim-1); + /* MarkBoundaryVoxels_NoExteriorFaces( CopiedChunk.Voxels, UpdateDim, {}, UpdateDim); */ + /* MarkBoundaryVoxels_MakeExteriorFaces( CopiedChunk.Voxels, UpdateDim, {{1,1,1}}, UpdateDim-1); */ + /* MarkBoundaryVoxels_MakeExteriorFaces( CopiedChunk.Voxels, UpdateDim, {}, UpdateDim); */ + + +#if 1 + for (u32 ChunkIndex = 0; ChunkIndex < ChunkCount; ++ChunkIndex) + { + world_chunk *Chunk = DestChunkBuffer[ChunkIndex]; + auto SimSpaceChunkRect = GetSimSpaceAABBi(World, Chunk); + auto SimSpaceIntersectionRect = Union(&SimSpaceChunkRect, &SimSpaceUpdateBounds); + + auto SimSpaceIntersectionMin = SimSpaceIntersectionRect.Min; + auto SimSpaceIntersectionMax = SimSpaceIntersectionRect.Max; + + auto SimSpaceChunkMin = SimSpaceChunkRect.Min; + auto SimSpaceChunkMax = SimSpaceChunkRect.Max; + + auto ChunkRelRectMin = SimSpaceIntersectionMin - SimSpaceChunkMin; + auto ChunkRelRectMax = SimSpaceIntersectionMax - SimSpaceChunkMin; + + s32 StartedFilled = 0; + s32 EndedFilled = 0; + for (s32 zVoxel = s32(ChunkRelRectMin.z); zVoxel < s32(ChunkRelRectMax.z); zVoxel += 1) + { + for (s32 yVoxel = s32(ChunkRelRectMin.y); yVoxel < s32(ChunkRelRectMax.y); yVoxel += 1) + { + for (s32 xVoxel = s32(ChunkRelRectMin.x); xVoxel < s32(ChunkRelRectMax.x); xVoxel += 1) + { + voxel_position RelVoxP = Voxel_Position(s32(xVoxel), s32(yVoxel), s32(zVoxel)); + voxel *V = GetVoxel(Chunk, RelVoxP); + + v3i SimSpaceVoxPExact = V3i(xVoxel, yVoxel, zVoxel) + SimSpaceChunkMin; + + Assert(UpdateMinP <= SimSpaceVoxPExact); + u32 Index = MapIntoQueryBox(SimSpaceVoxPExact, UpdateMinP, UpdateDim); + Assert(s32(Index) < TotalVoxels); + Assert(CopiedChunk.Voxels[Index].Flags != Global_UnsetVoxel.Flags); + Assert(CopiedChunk.Voxels[Index].Transparency != Global_UnsetVoxel.Transparency); + Assert(CopiedChunk.Voxels[Index].Color != Global_UnsetVoxel.Color); + + Assert( (V->Flags & Voxel_MarkBit) == 0); + StartedFilled += (V->Flags&Voxel_Filled); +#if VOXEL_DEBUG_COLOR + V->Flags = CopiedChunk.Voxels[Index].Flags; + V->Color = CopiedChunk.Voxels[Index].Color; + V->Transparency = CopiedChunk.Voxels[Index].Transparency; +#else + *V = CopiedChunk.Voxels[Index]; +#endif + EndedFilled += (V->Flags&Voxel_Filled); + Assert( (V->Flags & Voxel_MarkBit) == 0); + } + } + } + + s32 DiffFilled = EndedFilled - StartedFilled; + Chunk->FilledCount += DiffFilled; + Assert(Chunk->FilledCount >= 0); + } +#endif + + + + // DEBUG CODE + // + +#define DEBUG_VIEW_WORLD_UPDATE 0 +#if DEBUG_VIEW_WORLD_UPDATE + untextured_3d_geometry_buffer *DebugMesh = &GetEngineDebug()->WorldEditDebugMesh; + // TODO(Jesse): Need to copy the voxels because the Greedy thing blows away + // the face flags as it does the traversal. + /* NotImplemented; */ + + chunk_data CD = { Chunk_VoxelsInitialized, UpdateDim, CopiedChunk.Voxels, 0 }; + vox_data Vox = {&CD}; +#if VOXEL_DEBUG_COLOR + BuildWorldChunkMeshFromMarkedVoxels_Naieve( CopiedChunk.Voxels, UpdateDim, {}, UpdateDim, DebugMesh ); +#else + BuildWorldChunkMeshFromMarkedVoxels_Greedy( &Vox, DebugMesh, 0, GetTranArena()); +#endif + + /* aabb QueryAABB = AABBMinMax( {}, V3i(7.f + Radius*2.f) ); */ + + DEBUG_DrawAABB(DebugMesh, AABBMinDim({}, V3(UpdateDim)), BLUE); + + DEBUG_DrawAABB(DebugMesh, AABBMinDim(V3(-1), V3(2)), PINK); + +/* world_chunk *TempChunk = AllocateWorldChunk(Thread->PermMemory, MinP.WorldP, UpdateDim); */ +/* picked_world_chunk *PickedChunk = Allocate(picked_world_chunk, Thread->PermMemory, 1); */ +/* PickedChunk->Chunk = TempChunk; */ + + /* v3 QueryRelLocation = V3(SimSphereP) - UpdateMinP; */ + /* DrawVoxel_MinDim(DebugMesh, QueryRelLocation, V4(1,0,0,1), V3(1.f)); */ +#endif + + voxel_position_cursor StandingSpots = V3iCursor(ChunkCount*WORLD_CHUNK_STANDING_SPOT_COUNT, Thread->TempMemory); + + /* if (GetLevelEditor()->Flags & LevelEditorFlags_StandingSpotsOnLevelLoad) */ +#if 0 + NotImplemented; +#else + { + ComputeStandingSpots( UpdateDim, CopiedChunk.Voxels, {}, + {}, + Global_StandingSpotDim, + UpdateDim, + 0, + &StandingSpots, Thread->TempMemory ); + } +#endif + + FullBarrier; + for (u32 ChunkIndex = 0; ChunkIndex < ChunkCount; ++ChunkIndex) + { + world_chunk *Chunk = DestChunkBuffer[ChunkIndex]; + + rect3i SimSpaceChunkAABB = GetSimSpaceAABBi(World, Chunk); + auto QueryRelChunkAABB = SimSpaceChunkAABB - UpdateMinP; +#if DEBUG_VIEW_WORLD_UPDATE + DEBUG_DrawAABB(DebugMesh, &QueryRelChunkAABB, RED); +#endif + + /* DebugLine("Start StandingSpotCount(%d)/(%d)", AtElements(&Chunk->StandingSpots), Count(&Chunk->StandingSpots)); */ + + auto SimSpaceChunkRect = GetSimSpaceAABBi(World, Chunk); + auto SimSpaceChunkMin = SimSpaceChunkRect.Min; + + // NOTE(Jesse): Cull old standing spots that are entirely inside the update AABB + u32 StandingSpotIndex = 0; + for (;;) + { + u32 LastIndex = (u32)AtElements(&Chunk->StandingSpots); + if (StandingSpotIndex >= LastIndex) { break; } + + voxel_position ChunkSpot = Chunk->StandingSpots.Start[StandingSpotIndex]; + voxel_position ChunkSimSpot = SimSpaceChunkMin + ChunkSpot; + rect3i SimSpotAABB = Rect3iMinDim(ChunkSimSpot, Global_StandingSpotDim); + + voxel_position QueryRelChunkSpot = ChunkSimSpot - UpdateMinP; + + { + /* DrawStandingSpot(Mesh, V3(QueryRelChunkSpot), V3(Global_StandingSpotDim), TEAL, DEFAULT_STANDING_SPOT_THICKNESS*1.5f); */ + } + + auto SimSpaceSpotUnion = Union(&SimSpotAABB, &SimSpaceUpdateBounds); + auto SimSpaceUnionDim = GetDim(SimSpaceSpotUnion); + if (Volume(SimSpaceSpotUnion) == Volume(Global_StandingSpotDim)) // Cull + { + voxel_position QueryRelUnion = SimSpaceSpotUnion.Min - UpdateMinP; + voxel_position SwapSpot = Pop(&Chunk->StandingSpots); + Chunk->StandingSpots.Start[StandingSpotIndex] = SwapSpot; + /* DebugLine("Dropping StandingSpot(%d,%d,%d)", ChunkSpot.x, ChunkSpot.y, ChunkSpot.z); */ + /* DrawVoxel_MinDim(Mesh, V3(QueryRelUnion), ORANGE, V3(SimSpaceUnionDim), DEFAULT_LINE_THICKNESS*2.f); */ +#if DEBUG_VIEW_WORLD_UPDATE + DrawStandingSpot(DebugMesh, V3(QueryRelChunkSpot), V3(Global_StandingSpotDim), RED, DEFAULT_STANDING_SPOT_THICKNESS*2.f); +#endif + } + else + { + /* DebugLine("Keeping StandingSpot(%d,%d,%d)", ChunkSpot.x, ChunkSpot.y, ChunkSpot.z); */ +#if DEBUG_VIEW_WORLD_UPDATE + DrawStandingSpot(DebugMesh, V3(QueryRelChunkSpot), V3(Global_StandingSpotDim), GREEN, DEFAULT_STANDING_SPOT_THICKNESS*2.f); +#endif + ++StandingSpotIndex; + } + } + + // Cull gen'd standing spots that overlap with any current standing spots + for (StandingSpotIndex = 0; StandingSpotIndex < AtElements(&StandingSpots); ++StandingSpotIndex) + { + voxel_position QueryRelSpot = StandingSpots.Start[StandingSpotIndex]; + voxel_position SimSpot = QueryRelSpot + UpdateMinP; + rect3i SimSpotAABB = Rect3iMinDim(SimSpot, Global_StandingSpotDim); + + // + // NOTE(Jesse): I'm not entirely sure this is working properly, but it seems to be + b32 Skip = false; + for (u32 ChunkStandingSpotIndex = 0; ChunkStandingSpotIndex < AtElements(&Chunk->StandingSpots); ++ChunkStandingSpotIndex) + { + voxel_position ChunkSpot = Chunk->StandingSpots.Start[ChunkStandingSpotIndex]; + voxel_position ChunkSimSpot = ChunkSpot + SimSpaceChunkMin; + rect3i ChunkSimSpotAABB = Rect3iMinDim(ChunkSimSpot, Global_StandingSpotDim); + if (Volume(Union(&SimSpotAABB, &ChunkSimSpotAABB))) + { + Skip = true; + break; + } + } + + if (!Skip) + { +#if DEBUG_VIEW_WORLD_UPDATE + DrawStandingSpot(DebugMesh, V3(QueryRelSpot), V3(Global_StandingSpotDim), TEAL, DEFAULT_STANDING_SPOT_THICKNESS*1.5f); +#endif + if ( Contains(SimSpaceChunkAABB, SimSpot) ) + { + voxel_position ChunkRelSpot = SimSpot - SimSpaceChunkAABB.Min; + Assert(Contains(World->ChunkDim, ChunkRelSpot)); + if (Remaining(&Chunk->StandingSpots)) + { + Push(ChunkRelSpot, &Chunk->StandingSpots); + } + else + { + Warn("Ran out of standing spots on world_chunk (%p)", Chunk); + break; + } + } + } + } + } +} + diff --git a/src/engine/world_update.h b/src/engine/world_update.h new file mode 100644 index 000000000..302cf8e2e --- /dev/null +++ b/src/engine/world_update.h @@ -0,0 +1,86 @@ +// NOTE(Jesse): This is more-or-less duplicated in the face_index enum. Coalesce them? +// @duplicate_face_index_enum +enum voxel_rule_direction +{ + VoxelRuleDir_PosX, + VoxelRuleDir_NegX, + + VoxelRuleDir_PosY, + VoxelRuleDir_NegY, + + VoxelRuleDir_PosZ, + VoxelRuleDir_NegZ, + + VoxelRuleDir_Count, +}; +CAssert(VoxelRuleDir_Count == 6); + + +struct voxel_stack_element +{ + v3i VoxSimP; + voxel_rule_direction Dir; +}; + +link_internal b32 +AreEqual(voxel_stack_element E0, voxel_stack_element E1) +{ + NotImplemented; + return False; +} + +poof(gen_constructor(voxel_stack_element)) +#include + +poof(block_array(voxel_stack_element, {32})) +#include + +poof(generate_cursor(voxel_stack_element)) +#include + + +struct apply_world_edit_params +{ + world_edit_mode Mode; + rect3i SSRect; + rect3i SimSpaceUpdateBounds; + world_chunk *CopiedChunk; + b32 Invert; + u16 Color; + u8 Transparency; +}; + + +#define UNPACK_APPLY_WORLD_EDIT_PARAMS(P) \ + world_edit_mode Mode = P->Mode; \ + rect3i SSRect = P->SSRect; \ + rect3i SimSpaceUpdateBounds = P->SimSpaceUpdateBounds; \ + world_chunk *CopiedChunk = P->CopiedChunk; \ + v3i UpdateDim = GetDim(SimSpaceUpdateBounds); \ + b32 Invert = P->Invert + + + + +link_internal v3i +ChunkCountForDim(v3i Dim, v3i ChunkDim) +{ + v3i Fixup = Min(V3i(1), Dim % ChunkDim); + + v3i Result = (Dim/ChunkDim) + Fixup; + return Result; +} + + + + +struct work_queue_entry_update_world_region; + +link_internal void +QueueWorldUpdateForRegion( engine_resources *Engine, world_edit_mode Mode, world_edit_mode_modifier Modifier, world_edit_shape *Shape, u16 ColorIndex, memory_arena *Memory ); + +link_internal void +ApplyUpdateToRegion(thread_local_state *Thread, work_queue_entry_update_world_region *Job, rect3i SimSpaceUpdateBounds, world_chunk *CopiedChunk, b32 Invert = False); + +link_internal void +DoWorldUpdate(work_queue *Queue, world *World, thread_local_state *Thread, work_queue_entry_update_world_region *Job); diff --git a/src/game_loader.cpp b/src/game_loader.cpp index b129cfd02..33493cbe9 100644 --- a/src/game_loader.cpp +++ b/src/game_loader.cpp @@ -179,11 +179,10 @@ main( s32 ArgCount, const char ** Args ) EngineResources->Stdlib.Plat.ScreenDim = V2(SettingToValue(EngineResources->Settings.Graphics.WindowStartingSize)); - thread_main_callback_type Procs[1] = { RenderThread_Main }; - /* thread_main_callback_type Procs[1] = { EngineApi.RenderThread_Main }; */ + thread_main_callback_type Procs[2] = { RenderThread_Main, WorldUpdateThread_Main }; thread_main_callback_type_buffer CustomWorkerProcs = {}; - CustomWorkerProcs.Count = 1; CustomWorkerProcs.Start = Procs; + CustomWorkerProcs.Count = 2; Ensure( InitializeBonsaiStdlib( bonsai_init_flags(BonsaiInit_OpenWindow|BonsaiInit_LaunchThreadPool|BonsaiInit_InitDebugSystem), GameApi, @@ -210,7 +209,8 @@ main( s32 ArgCount, const char ** Args ) memory_arena *WorkQueueMemory = AllocateArena(); InitQueue(&Plat->HighPriority, WorkQueueMemory); InitQueue(&Plat->LowPriority, WorkQueueMemory); - InitQueue(&Plat->RenderQ, WorkQueueMemory); + InitQueue(&Plat->RenderQ, WorkQueueMemory); + InitQueue(&Plat->WorldUpdateQ, WorkQueueMemory); DEBUG_REGISTER_ARENA(GameMemory, 0); diff --git a/src/tests/callgraph.cpp b/src/tests/callgraph.cpp index 1dd203080..d91f2e9f0 100644 --- a/src/tests/callgraph.cpp +++ b/src/tests/callgraph.cpp @@ -29,10 +29,17 @@ main(s32 ArgCount, const char** Args) { TestSuiteBegin("callgraph", ArgCount, Args); - /* bonsai_debug_system DebugSystem = InitializeBonsaiDebug("./bin/lib_debug_system_loadable" PLATFORM_RUNTIME_LIB_EXTENSION, 0); */ + memory_arena BootstrapArena = {}; + engine_resources Engine = {}; + Global_EngineResources = &Engine; + Ensure( InitializeBonsaiStdlib( BonsaiInit_InitDebugSystem, + {}, + &Engine.Stdlib, + &BootstrapArena ) ); TIMED_FUNCTION(); + FunctionOne(); debug_scope_tree *Tree = GetDebugState()->GetWriteScopeTree(); diff --git a/src/tests/chunk.cpp b/src/tests/chunk.cpp index 741b67752..15e44bb23 100644 --- a/src/tests/chunk.cpp +++ b/src/tests/chunk.cpp @@ -8,11 +8,11 @@ TestChunkCopy(memory_arena *Memory) { thread_local_state MainThread = DefaultThreadLocalState(0); - chunk_dimension DestChunkDim = Chunk_Dimension(8); - world_position DestChunkP = World_Position(0); + v3i DestChunkDim = Chunk_Dimension(8); + v3i DestChunkP = World_Position(0); - chunk_dimension SynChunkDim = DestChunkDim+2; - world_position SynChunkP = World_Position(0); + v3i SynChunkDim = DestChunkDim+2; + v3i SynChunkP = World_Position(0); { // Ensure the flat noise initialization works correctly @@ -46,8 +46,8 @@ TestChunkCopy(memory_arena *Memory) } } } - } + // Not related to the chunk tests, but checks the temp_memory_handle is working // @ensure_temp_memory_handle_is_working TestThat(Memory->At == Memory->Start); @@ -85,8 +85,8 @@ TestChunkCopy(memory_arena *Memory) } } } - } + // @ensure_temp_memory_handle_is_working TestThat(Memory->At == Memory->Start); } @@ -96,8 +96,20 @@ main(s32 ArgCount, const char** Args) { TestSuiteBegin("Chunk", ArgCount, Args); + memory_arena BootstrapArena = {}; + engine_resources Engine = {}; + Global_EngineResources = &Engine; + Ensure( InitializeBonsaiStdlib( BonsaiInit_Default, + {}, + &Engine.Stdlib, + &BootstrapArena ) ); + + memory_arena *Memory = AllocateArena(Megabytes(32)); + Engine.World = Allocate(world, &BootstrapArena, 1); + AllocateWorld(Engine.World, {}, V3i(8), V3i(8)); + TestChunkCopy(Memory); TestSuiteEnd(); diff --git a/src/tests/colladaloader.cpp b/src/tests/colladaloader.cpp index 7f5dc58a7..b43de6a2e 100644 --- a/src/tests/colladaloader.cpp +++ b/src/tests/colladaloader.cpp @@ -448,6 +448,15 @@ main(s32 ArgCount, const char** Args) { TestSuiteBegin("Collada Loader", ArgCount, Args); + memory_arena BootstrapArena = {}; + engine_resources Engine = {}; + Global_EngineResources = &Engine; + Ensure( InitializeBonsaiStdlib( BonsaiInit_Default, + {}, + &Engine.Stdlib, + &BootstrapArena ) ); + + XmlTests(); TokenizingTest(); diff --git a/src/tests/containers/block_array.cpp b/src/tests/containers/block_array.cpp index edb5e0327..21314d2de 100644 --- a/src/tests/containers/block_array.cpp +++ b/src/tests/containers/block_array.cpp @@ -1,5 +1,4 @@ - #include #include #include diff --git a/src/tests/file.cpp b/src/tests/file.cpp index ecb803826..2665b18ca 100644 --- a/src/tests/file.cpp +++ b/src/tests/file.cpp @@ -13,6 +13,8 @@ main(s32 ArgCount, const char** Args) memory_arena _Memory = {}; memory_arena* Memory = &_Memory; + SetThreadLocal_ThreadIndex(0); + counted_string Contents = ReadEntireFileIntoString(CS(TEST_FIXTURES_PATH "/read_file_test"), Memory); DebugLine("%u", Contents.Count); TestThat(Contents.Count == 11); diff --git a/src/tests/sort.cpp b/src/tests/sort.cpp index 7e253f83c..f527209b2 100644 --- a/src/tests/sort.cpp +++ b/src/tests/sort.cpp @@ -1,5 +1,4 @@ - #include #include #include @@ -25,6 +24,8 @@ main(s32 ArgCount, const char** Args) { TestSuiteBegin("Sort", ArgCount, Args); + SetThreadLocal_ThreadIndex(0); + { u64 SortKeyIndex = 0; sort_key Keys[] = diff --git a/src/tests/test_bitmap.cpp b/src/tests/test_bitmap.cpp index 8d54008b9..b49c02ae4 100644 --- a/src/tests/test_bitmap.cpp +++ b/src/tests/test_bitmap.cpp @@ -40,6 +40,8 @@ main(s32 ArgCount, const char** Args) { TestSuiteBegin("Bitmap", ArgCount, Args); + SetThreadLocal_ThreadIndex(0); + memory_arena Arena = {}; v4 Red = V4(1,0,0,0); diff --git a/src/tests/ui_command_buffer.cpp b/src/tests/ui_command_buffer.cpp index b0751f258..619d29d6c 100644 --- a/src/tests/ui_command_buffer.cpp +++ b/src/tests/ui_command_buffer.cpp @@ -10,7 +10,7 @@ TestTable(renderer_2d* Group) Index < 2; ++Index) { - interactable_handle Interaction = PushButtonStart(Group, UiId(0, "TestButtonInteraction", Index)); + interactable_handle Interaction = PushButtonStart(Group, UiId(0, "TestButtonInteraction0", Index)); PushColumn(Group, CS("String1")); PushColumn(Group, CS("String2")); PushColumn(Group, CS("String3")); @@ -29,7 +29,7 @@ TestTable(renderer_2d* Group) PushTableEnd(Group); PushTableStart(Group); - PushButtonStart(Group, UiId(0,Cast(void*,0),Cast(void*,0))); + PushButtonStart(Group, UiId(0, "TestButtonInteraction1", 0u)); PushColumn(Group, CS("String1")); PushColumn(Group, CS("String2")); PushColumn(Group, CS("String3")); @@ -39,7 +39,7 @@ TestTable(renderer_2d* Group) PushTableEnd(Group); PushTableStart(Group); - PushButtonStart(Group, UiId(0,Cast(void*,0),Cast(void*,0))); + PushButtonStart(Group, UiId(0, "TestButtonInteraction2", 0u)); PushColumn(Group, CS("String1")); PushColumn(Group, CS("String2")); PushColumn(Group, CS("String3")); @@ -54,6 +54,8 @@ main(s32 ArgCount, const char** Args) { TestSuiteBegin("ui_command_buffer", ArgCount, Args); + SetThreadLocal_ThreadIndex(0); + // NOTE(Jesse): Sorry for this... engine_resources Engine = {}; Global_EngineResources = &Engine;