diff --git a/.gitignore b/.gitignore index ab0656846..5fed10274 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,8 @@ levels/ brushes/_untitled.brush +runtime_settings/* + bin/ tmp/ diff --git a/assets/white.bmp b/assets/white.bmp new file mode 100644 index 000000000..8ae7e9965 Binary files /dev/null and b/assets/white.bmp differ diff --git a/brushes/black_castle_wall.brush b/brushes/black_castle_wall.brush deleted file mode 100644 index 4fb42bf2b..000000000 Binary files a/brushes/black_castle_wall.brush and /dev/null differ diff --git a/brushes/black_castle_wall_broken.brush b/brushes/black_castle_wall_broken.brush deleted file mode 100644 index ba8aaa0f4..000000000 Binary files a/brushes/black_castle_wall_broken.brush and /dev/null differ diff --git a/brushes/black_castle_wall_rough.brush b/brushes/black_castle_wall_rough.brush deleted file mode 100644 index 5e00467eb..000000000 Binary files a/brushes/black_castle_wall_rough.brush and /dev/null differ diff --git a/brushes/dirt_path.brush b/brushes/dirt_path.brush deleted file mode 100644 index cc2be09f6..000000000 Binary files a/brushes/dirt_path.brush and /dev/null differ diff --git a/brushes/eraser.brush b/brushes/eraser.brush deleted file mode 100644 index 080697f3d..000000000 Binary files a/brushes/eraser.brush and /dev/null differ diff --git a/brushes/foliage.brush b/brushes/foliage.brush deleted file mode 100644 index d4602f0e8..000000000 Binary files a/brushes/foliage.brush and /dev/null differ diff --git a/brushes/granite_wall.brush b/brushes/granite_wall.brush deleted file mode 100644 index 81d373fd0..000000000 Binary files a/brushes/granite_wall.brush and /dev/null differ diff --git a/brushes/granite_wall_paint.brush b/brushes/granite_wall_paint.brush deleted file mode 100644 index 55443cbad..000000000 Binary files a/brushes/granite_wall_paint.brush and /dev/null differ diff --git a/brushes/grass.brush b/brushes/grass.brush deleted file mode 100644 index bccbac5f3..000000000 Binary files a/brushes/grass.brush and /dev/null differ diff --git a/brushes/small_gravel.brush b/brushes/small_gravel.brush deleted file mode 100644 index 3a54757f7..000000000 Binary files a/brushes/small_gravel.brush and /dev/null differ diff --git a/brushes/spackled_base.1.brush b/brushes/spackled_base.1.brush deleted file mode 100644 index 142b6aa87..000000000 Binary files a/brushes/spackled_base.1.brush and /dev/null differ diff --git a/brushes/spackled_base.brush b/brushes/spackled_base.brush deleted file mode 100644 index 324a1ab6d..000000000 Binary files a/brushes/spackled_base.brush and /dev/null differ diff --git a/brushes/spackled_stone.1.brush b/brushes/spackled_stone.1.brush deleted file mode 100644 index caadc3122..000000000 Binary files a/brushes/spackled_stone.1.brush and /dev/null differ diff --git a/brushes/spackled_stone.brush b/brushes/spackled_stone.brush deleted file mode 100644 index 518905aa7..000000000 Binary files a/brushes/spackled_stone.brush and /dev/null differ diff --git a/brushes/spackled_stone_green.1.brush b/brushes/spackled_stone_green.1.brush deleted file mode 100644 index 757e75b1e..000000000 Binary files a/brushes/spackled_stone_green.1.brush and /dev/null differ diff --git a/brushes/spackled_stone_green.brush b/brushes/spackled_stone_green.brush deleted file mode 100644 index caadc3122..000000000 Binary files a/brushes/spackled_stone_green.brush and /dev/null differ diff --git a/brushes/spackled_stone_green2.brush b/brushes/spackled_stone_green2.brush deleted file mode 100644 index 82db8cdac..000000000 Binary files a/brushes/spackled_stone_green2.brush and /dev/null differ diff --git a/brushes/stone_path.brush b/brushes/stone_path.brush deleted file mode 100644 index 7c06944d3..000000000 Binary files a/brushes/stone_path.brush and /dev/null differ diff --git a/brushes/test.brush b/brushes/test.brush deleted file mode 100644 index 451df64e4..000000000 Binary files a/brushes/test.brush and /dev/null differ diff --git a/brushes/vines.brush b/brushes/vines.brush deleted file mode 100644 index 73d2b46a7..000000000 Binary files a/brushes/vines.brush and /dev/null differ diff --git a/brushes/wood_horizontal.brush b/brushes/wood_horizontal.brush deleted file mode 100644 index 64834fe02..000000000 Binary files a/brushes/wood_horizontal.brush and /dev/null differ diff --git a/brushes/wood_horizontal.brushdw.brush b/brushes/wood_horizontal.brushdw.brush deleted file mode 100644 index 64834fe02..000000000 Binary files a/brushes/wood_horizontal.brushdw.brush and /dev/null differ diff --git a/brushes/wood_vertical.1.brush b/brushes/wood_vertical.1.brush deleted file mode 100644 index fa534ab21..000000000 Binary files a/brushes/wood_vertical.1.brush and /dev/null differ diff --git a/brushes/wood_vertical.brush b/brushes/wood_vertical.brush deleted file mode 100644 index fa534ab21..000000000 Binary files a/brushes/wood_vertical.brush and /dev/null differ diff --git a/brushes/wooden_door.1.brush b/brushes/wooden_door.1.brush deleted file mode 100644 index fa534ab21..000000000 Binary files a/brushes/wooden_door.1.brush and /dev/null differ diff --git a/brushes/wooden_door.brush b/brushes/wooden_door.brush deleted file mode 100644 index 0ec8443e7..000000000 Binary files a/brushes/wooden_door.brush and /dev/null differ diff --git a/ctags.sh b/ctags.sh new file mode 100644 index 000000000..55389060e --- /dev/null +++ b/ctags.sh @@ -0,0 +1,4 @@ +#! /usr/bin/env bash + +# This tells ctags abouit the poof macro, which frequently confuses its parser +ctags -R -I poof+ . diff --git a/docs/00_getting_started.md b/docs/00_getting_started.md new file mode 100644 index 000000000..6482394db --- /dev/null +++ b/docs/00_getting_started.md @@ -0,0 +1,25 @@ + +# Getting Started + +## Prebuilt Binaries + +The fastest way to get started with Bonsai is to grab the prebuilt binaries from +the [Latest Releases](../../releases/latest) page. Windows and Linux are supported. + + +## Running an Example + +Bonsai ships with several pre-built example projects, under the `bin/game_libs` +folder. To run an example, simply launch `bin/game_loader.exe` and select the +example from the menu presented. Alternatively, you may specify which example +to run from a command line as an argument. For example, +`bin/game_loader.exe bin/game_libs/terrain_gen_loadable.dll` + +## Terrain Generation + +The terrain_gen example provides users with a convenient playground for +experimenting with terrain generation. Just fire up your favorite editor, +navigate to `shaders/terrain/shaping/default.fragmentshader`, and edit away! +Terrain shaders hot-reload, so you have a fast edit-compile-run loop for +experimentation. + diff --git a/docs/controls.md b/docs/controls.md new file mode 100644 index 000000000..77c278ee8 --- /dev/null +++ b/docs/controls.md @@ -0,0 +1,64 @@ +# Legend + +This is notation for the single keystroke 'a' +``` +a +``` + +This is notation for a single keystroke of any of 'w', 'a', 's', 'd', +``` +wasd +``` + +This is notation for the chord 'Ctrl + s' +``` + +``` + +This is notation for the chord 'Alt + Shift + s' +``` + +``` + + +# General + +`f1` : toggle debug menu + +`escape` : load "project\_and\_level\_picker", or quit + +# Camera Controls + +`wasd` : move camera on a horizontal plane + +`q` : move camera down + +`e` : move camera up + +hold `rmouse` : rotate camera + + +# Editor + +Select the 'World Edit' tab from the top menu + +`` : Begin area selection + +`lclick` : Finish area selection + +`` : Center camera on selection + +`` : Multi-select + +## With area selected + +`` : Scale along axis + +`` : Scale along axis; both sides + +`` : Scale along all axies + +`` : Translate along axis + diff --git a/docs/editor.md b/docs/editor.md new file mode 100644 index 000000000..bfe8d95e2 --- /dev/null +++ b/docs/editor.md @@ -0,0 +1,51 @@ +# Editor + +To enter world edit mode, select "World Edit" from the menu in the top-left corner +of the screen. + +## Brushes + +Brushes are the backbone of the world editing system. Brushes describe how a +world edit affects the selected area. + +### Creation + +To create a brush, select "New" from the "Brush Settings" window. + +### Brush Settings Window + +Here we'll detail each option in the "Brush Settings window, in order. + +* Brush Name + The name of the brush, on disk. + +* Layer Count + The number of layers the brush has + +* Affect World + Should the brush interact with voxels from world-gen, or strictly voxels from + edits. + +--- + +### ----- LAYERS ------ + +* Brush Type : Noise | Shape + Changes the type of the brush + +* Brush Type(Noise) + * Noise Type : Perlin | Voronoi | White + + +* Value Modifier + * ClampPos : max(0, sample), after applying ValueBias and Power + * ClampNeg : min(0, sample), after applying ValueBias and Power + * Threshold : Set sample to 0 if it does not pass threshold, before Power and ValueBias + * Discard : Set sample to 0 + +* Blend Mode + * Additive : output = sample + previous + * Subtractive : output = previous - sample + * Multiply : output = previous * sample + * Threshold : output = sample > threshold ? threshold : sample + * Disabled : output = output diff --git a/docs/world_gen.md b/docs/world_gen.md new file mode 100644 index 000000000..0a3238f25 --- /dev/null +++ b/docs/world_gen.md @@ -0,0 +1,40 @@ +# World Generation + +Terrain generation in Bonsai is composed of several stages, some of which are +user reconfigurable. The stages are as follows: + +1. Terrain Shaping +2. Terrain Normal Calculation +3. Terrain Decoration +5. World Edit applications +6. Meshing +7. Drawing + + +Stages (1) and (3) are easily configurable by users of the engine. There is an +example project named `terrain_gen` that makes it easy to switch between +different shaping and decoration shaders. + + +## Terrain Shaping + +The Terrain Shaping stage is typically responsible for the overall shape of the +terrain. Set the `NoiseValue` and `ColorValue` variables inside the block +marked ` -- user code -- ` to any values you like. A final value above zero is +solid, a value below zero is air. + +To add a new Terrain Shaping shader, copy `shaders/terrain/shaping/default.fragmentshader` +to a new file in the same directory. + + +## Terrain Decoration + +The Terrain Decoration stage has the `NoiseValue` and `ColorValue` passed through +from the previous Shaping stage, as well as an additional `NormalValue`, which +is the normal to the surface at that point. The Terrain Decoration stage is +typically used to apply small details, coloring, and texturing to the final terrain. + +To add a new Terrain Decoration shader, copy `shaders/terrain/decoration/default.fragmentshader` +to a new filename in the same directory. + + diff --git a/dottedboxguy.make.sh b/dottedboxguy.make.sh new file mode 100644 index 000000000..e7d2c6db9 --- /dev/null +++ b/dottedboxguy.make.sh @@ -0,0 +1,7 @@ +#! /usr/bin/env bash + +# OPT="-O2" + +./make.sh $OPT \ + BuildSingleExample examples/terrain_gen \ + BuildExecutables \ diff --git a/examples/blank_project/game.cpp b/examples/blank_project/game.cpp index 713bfcdf8..5e11cb849 100644 --- a/examples/blank_project/game.cpp +++ b/examples/blank_project/game.cpp @@ -2,8 +2,6 @@ #define BONSAI_DEBUG_SYSTEM_API 1 #include - -#include #include // NOTE(Jesse): This is an optional function that gets called for each worker @@ -32,8 +30,10 @@ BONSAI_API_WORKER_THREAD_CALLBACK() // NOTE(Jesse): Render commands should never end up on a general purpose work queue InvalidCase(type_work_queue_entry__bonsai_render_command); + case type_work_queue_entry_build_chunk_mesh: + case type_work_queue_entry_finalize_noise_values: case type_work_queue_entry_async_function_call: - case type_work_queue_entry_update_world_region: + /* case type_work_queue_entry_update_world_region: */ case type_work_queue_entry_rebuild_mesh: case type_work_queue_entry_init_asset: case type_work_queue_entry_init_world_chunk: @@ -68,9 +68,9 @@ BONSAI_API_MAIN_THREAD_INIT_CALLBACK() world_position WorldCenter = {}; canonical_position CameraTargetP = {}; - StandardCamera(Graphics->Camera, 10000.0f, 1000.0f); + StandardCamera(Graphics->Camera, 30000.0f, 1000.0f); - AllocateWorld(World, WorldCenter, WORLD_CHUNK_DIM, g_VisibleRegion); + AllocateWorld(World, WorldCenter, VisibleRegionSize_128); GameState = Allocate(game_state, Resources->GameMemory, 1); return GameState; diff --git a/examples/blank_project/game_constants.h b/examples/blank_project/game_constants.h deleted file mode 100644 index d83dba30a..000000000 --- a/examples/blank_project/game_constants.h +++ /dev/null @@ -1,15 +0,0 @@ - -#if 0 -global_variable chunk_dimension -g_VisibleRegion = Chunk_Dimension(32, 32, 8); - -global_variable chunk_dimension -WORLD_CHUNK_DIM = Chunk_Dimension(32, 32, 8); -#else -global_variable chunk_dimension -g_VisibleRegion = Chunk_Dimension(8, 8, 4); - -global_variable chunk_dimension -WORLD_CHUNK_DIM = Chunk_Dimension(64, 64, 64); - -#endif diff --git a/examples/project_and_level_picker/game.cpp b/examples/project_and_level_picker/game.cpp index 964031ec5..1e3df636c 100644 --- a/examples/project_and_level_picker/game.cpp +++ b/examples/project_and_level_picker/game.cpp @@ -1,6 +1,4 @@ #include - -#include #include BONSAI_API_WORKER_THREAD_CALLBACK() @@ -17,8 +15,10 @@ BONSAI_API_WORKER_THREAD_CALLBACK() Result = True; } break; + case type_work_queue_entry_build_chunk_mesh: + case type_work_queue_entry_finalize_noise_values: case type_work_queue_entry_async_function_call: - case type_work_queue_entry_update_world_region: + /* case type_work_queue_entry_update_world_region: */ case type_work_queue_entry_rebuild_mesh: case type_work_queue_entry_init_asset: case type_work_queue_entry_copy_buffer_ref: @@ -33,9 +33,9 @@ BONSAI_API_MAIN_THREAD_INIT_CALLBACK() { UNPACK_ENGINE_RESOURCES(Resources); - AllocateWorld(World, {}, WORLD_CHUNK_DIM, g_VisibleRegion); - + AllocateWorld(World, {}, VisibleRegionSize_128); GameState = Allocate(game_state, Resources->GameMemory, 1); + return GameState; } diff --git a/examples/project_and_level_picker/game_constants.h b/examples/project_and_level_picker/game_constants.h deleted file mode 100644 index ff8c73fa2..000000000 --- a/examples/project_and_level_picker/game_constants.h +++ /dev/null @@ -1,15 +0,0 @@ - -#if 0 -global_variable chunk_dimension -g_VisibleRegion = Chunk_Dimension(32, 32, 8); - -global_variable chunk_dimension -WORLD_CHUNK_DIM = Chunk_Dimension(32, 32, 8); -#else -global_variable chunk_dimension -g_VisibleRegion = Chunk_Dimension(16, 16, 4); - -global_variable chunk_dimension -WORLD_CHUNK_DIM = Chunk_Dimension(32, 32, 32); - -#endif diff --git a/examples/terrain_gen/game.cpp b/examples/terrain_gen/game.cpp index 018a58fa0..4ba17ac95 100644 --- a/examples/terrain_gen/game.cpp +++ b/examples/terrain_gen/game.cpp @@ -2,764 +2,151 @@ #include -#include "game_constants.h" -#include "game_types.h" - -link_internal u32 -Terrain_Checkerboard( world_chunk *Chunk, - v3i NoiseBasis, - void *NoiseParams, - void *UserData ) -{ - UNPACK_NOISE_PARAMS(NoiseParams); - - u32 Result = 0; - - auto AbsX = Abs(Chunk->WorldP.x); - auto AbsY = Abs(Chunk->WorldP.y); +#include "game.h" - if ( AbsX % 2 == 0 && AbsY % 2 == 1) { RGBColor = MagicaVoxelDefaultPaletteToRGB(MCV_RED); } - if ( AbsX % 2 == 1 && AbsY % 2 == 0) { RGBColor = MagicaVoxelDefaultPaletteToRGB(MCV_BLUE); } - - for ( s32 z = 0; z < Dim.z; ++ z) - { - s64 WorldZ = z - zMin - SrcToDest.z + (WorldChunkDim.z*Chunk->WorldP.z); - for ( s32 y = 0; y < Dim.y; ++ y) - { - for ( s32 x = 0; x < Dim.x; ++ x) - { - if (WorldZ < zMin) - { - s32 Index = GetIndex(Voxel_Position(x,y,z), Dim); - Chunk->Voxels[Index].Flags = Voxel_Filled; - Chunk->Voxels[Index].Color = RGBtoPackedHSV(RGBColor); - ++Result; - } - } - } - } - - return Result;; +BONSAI_API_WORKER_THREAD_INIT_CALLBACK() +{ + SetThreadLocal_ThreadIndex(Thread->Index); } -link_internal u32 -GrassyIslandTerrain( world_chunk *Chunk, - v3i NoiseBasis, - void *NoiseParams, - void *UserData ) +BONSAI_API_MAIN_THREAD_INIT_CALLBACK() { - TIMED_FUNCTION(); - UNPACK_NOISE_PARAMS(NoiseParams); - u32 ChunkSum = 0; - - s32 MinZ = Chunk->WorldP.z*WorldChunkDim.z; - s32 MaxZ = MinZ+WorldChunkDim.z ; - - octave_buffer *OctaveBuf = (octave_buffer*)UserData; - u32 OctaveCount = OctaveBuf->Count; - - for ( s32 z = 0; z < Dim.z; ++ z) - { - s64 WorldZ = z - SrcToDest.z + (WorldChunkDim.z*Chunk->WorldP.z); - s64 WorldZBiased = WorldZ - zMin; - for ( s32 y = 0; y < Dim.y; ++ y) - { - s64 WorldY = y - SrcToDest.y + (WorldChunkDim.y*Chunk->WorldP.y); - for ( s32 x = 0; x < Dim.x; ++ x) - { - s64 WorldX = x - SrcToDest.x + (WorldChunkDim.x*Chunk->WorldP.x); - s32 VoxIndex = GetIndex(Voxel_Position(x,y,z), Dim); - Chunk->Voxels[VoxIndex].Flags = Voxel_Empty; - Assert( NotSet(&Chunk->Voxels[VoxIndex], Voxel_Filled) ); - - r32 NoiseValue = 0.f; - for (u32 OctaveIndex = 0; OctaveIndex < OctaveCount; ++OctaveIndex) - { - octave *Octave = OctaveBuf->Octaves+OctaveIndex; - - f32 InX = SafeDivide0((x + SrcToDest.x + (WorldChunkDim.x*Chunk->WorldP.x)), Octave->Freq.x); - f32 InY = SafeDivide0((y + SrcToDest.y + (WorldChunkDim.y*Chunk->WorldP.y)), Octave->Freq.y); - f32 InZ = SafeDivide0((z + SrcToDest.z + (WorldChunkDim.z*Chunk->WorldP.z)), Octave->Freq.z); - - r32 Warp = PerlinNoise(InX, InY, InZ); - v3 WarpFactor = Warp*Octave->WarpStrength; + UNPACK_ENGINE_RESOURCES(Resources); - r32 N = PerlinNoise(InX+WarpFactor.x, InY+WarpFactor.y, InZ+WarpFactor.z); + Global_AssetPrefixPath = CSz("examples/terrain_gen/assets"); - Assert(N <= 1.05f); - Assert(N > -1.05f); + world_position WorldCenter = V3i(100, 100, 0); - NoiseValue += (N*Octave->Amp); - } + canonical_position CameraTargetP = {}; - b32 NoiseChoice = r64(NoiseValue) > r64(WorldZBiased); + /* auto VisibleRegionSize = VisibleRegionSize_128; */ + auto VisibleRegionSize = VisibleRegionSize_1k; + /* auto VisibleRegionSize = VisibleRegionSize_8192; */ + /* auto VisibleRegionSize = VisibleRegionSize_16k; */ + /* auto VisibleRegionSize = VisibleRegionSize_64k; */ + /* auto VisibleRegionSize = VisibleRegionSize_64k; */ + AllocateWorld(World, WorldCenter, VisibleRegionSize); - /* if (NoiseValue > WorldZBiased) */ - /* { */ - /* } */ - /* u16 StartColorMin = GREY_4; */ - /* u16 StartColorMax = GREY_6; */ - /* u16 ThisColor = SafeTruncateToU16(umm(RandomBetween(StartColorMin, &GenColorEntropy, StartColorMax))); */ - v3 ThisColor = RGB_GRASS_GREEN; + v3i VisibleRegion = V3i(VisibleRegionSize); + f32 DistanceFromTarget = 50000.f; + f32 FarClip = 5000000.f; + StandardCamera(Graphics->Camera, FarClip, DistanceFromTarget); - u8 ThisTransparency = 0; + GameState = Allocate(game_state, Resources->GameMemory, 1); + *GameState = {}; - s32 SnowThreshold = 100; - if (NoiseChoice == True && WorldZ > SnowThreshold) - { - ThisColor = RGB_WHITE; - } + Camera->GhostId = GetFreeEntity(EntityTable); + entity *CameraGhost = GetEntity(EntityTable, Camera->GhostId); - s32 SandThreshold = 3; - if (NoiseChoice == True && WorldZ < SandThreshold) - { - ThisColor = RGB_SAND; - } + CameraGhost->P.WorldP = VisibleRegion/2; + CameraGhost->P.WorldP.z = (10000/64) + 3; + /* CameraGhost->P.WorldP.z = 0; */ + CameraGhost->Behavior = entity_behavior_flags(CameraGhost->Behavior|EntityBehaviorFlags_DefatulCameraGhostBehavior|EntityBehaviorFlags_WorldCenter); + SpawnEntity(CameraGhost); - s32 GravelThreshold = 1; - if (NoiseChoice == True && WorldZ < GravelThreshold) - { - ThisColor = RGB_GRAVEL; - } - s32 WaterThreshold = 0; - if (NoiseChoice == False && WorldZ < WaterThreshold) - { - NoiseChoice = True; - ThisColor = RGB_BLUE; - ThisTransparency = 255; - } + GameState->VisibleRegionSize = &World->VisibleRegionSize; -#if 1 - GrowGrassPerlin( Chunk, V3i(x,y,z), NoiseValue, 1.f, SrcToDest, WorldChunkDim, WorldZBiased, &ThisColor, &NoiseChoice ); -#else - s32 Below = TryGetIndex(x, y, z-1, Dim); - s32 B0 = TryGetIndex(x+1, y, z-1, Dim); - s32 B1 = TryGetIndex(x-1, y, z-1, Dim); - s32 B2 = TryGetIndex(x, y+1, z-1, Dim); - s32 B3 = TryGetIndex(x, y-1, z-1, Dim); - - u32 CornersFilled = 0; - if (B0 > -1) { CornersFilled += (Chunk->Voxels[B0].Flags & Voxel_Filled); } - if (B1 > -1) { CornersFilled += (Chunk->Voxels[B1].Flags & Voxel_Filled); } - if (B2 > -1) { CornersFilled += (Chunk->Voxels[B2].Flags & Voxel_Filled); } - if (B3 > -1) { CornersFilled += (Chunk->Voxels[B3].Flags & Voxel_Filled); } - - if (NoiseChoice == False) - { - /* s32 Above = TryGetIndex(x, y, z+1, Dim); */ - if (Below > -1) - { - if ( CornersFilled > 3 && - Chunk->Voxels[Below].Flags & Voxel_Filled && - Chunk->Voxels[Below].Color >= StartColorMin && Chunk->Voxels[Below].Color <= StartColorMax ) - { - NoiseChoice = True; - ThisColor = DIRT; - } -#if 1 - if (Chunk->Voxels[Below].Flags&Voxel_Filled && - Chunk->Voxels[Below].Color == DIRT) - { - f32 InX = SafeDivide0((x + SrcToDest.x + ( WorldChunkDim.x*Chunk->WorldP.x)), 10.f); - f32 InY = SafeDivide0((y + SrcToDest.y + ( WorldChunkDim.y*Chunk->WorldP.y)), 10.f); - f32 InZ = SafeDivide0((z + SrcToDest.z + ( WorldChunkDim.z*Chunk->WorldP.z)), 10.f); - - u16 GrassColorMin = RGB_GRASS_GREEN; - u16 GrassColorMax = RGB_GRASS_GREEN+2; - ThisColor = SafeTruncateToU16(umm(RandomBetween(GrassColorMin, &GenColorEntropy, GrassColorMax))); - NoiseChoice = True; - - r32 GrassChance = PerlinNoise(InX, InY, InZ); - if (GrassChance > 0.45f) { ThisColor = RGB_GRASS_GREEN-1; } - } - - if (Chunk->Voxels[Below].Flags&Voxel_Filled && - Chunk->Voxels[Below].Color == RGB_GRASS_GREEN-1) - { - r32 GrassChance = RandomUnilateral(&GenColorEntropy); - if (GrassChance > 0.85f) - { - NoiseChoice = True; - ThisColor = RGB_GRASS_GREEN-1; - } - if (GrassChance > 0.997f) - { - ThisColor = RED; - } - if (GrassChance > 0.998f) - { - ThisColor = YELLOW; - } - if (GrassChance > 0.999f) - { - ThisColor = PINK; - } - } +#if 0 + easing_function *EasingFunction = &Graphics->TerrainShapingRC.ReshapeFunc; + GameState->EasingFunction = EasingFunction; + Push(&EasingFunction->Points, V2(0,0)); + Push(&EasingFunction->Points, V2(0.47f, 0.10f)); + Push(&EasingFunction->Points, V2(0.67f,0.78f)); + Push(&EasingFunction->Points, V2(0.87f,0.70f)); + Push(&EasingFunction->Points, V2(1,1)); + InitializeEasingFunctionVisualizerRenderPass_Async( + LoRenderQ, + &GameState->EasingFunctionVisRP, + EasingFunction, + 0 ); #endif - } - } - else // NoiseChoice == True - { - if (Below > -1) - { - if (ThisColor == StartColorMin && (Chunk->Voxels[Below].Flags&Voxel_Filled)==0 ) - { - r32 VineChance = RandomUnilateral(&GenColorEntropy); - if (CornersFilled <= 2 && VineChance > 0.9f) - { - ThisColor = RGB_GRASS_GREEN; - while (RandomUnilateral(&GenColorEntropy) > 0.95f) - { - } - } - } - } - } -#endif - - SetFlag(&Chunk->Voxels[VoxIndex], (voxel_flag)(Voxel_Filled*NoiseChoice)); - Chunk->Voxels[VoxIndex].Color = RGBtoPackedHSV(ThisColor)*u16(NoiseChoice); - Chunk->Voxels[VoxIndex].Transparency = ThisTransparency; - ChunkSum += NoiseChoice; - - - Assert( (Chunk->Voxels[VoxIndex].Flags&VoxelFaceMask) == 0); + return GameState; +} - if (NoiseChoice) - { - Assert( IsSet(&Chunk->Voxels[VoxIndex], Voxel_Filled) ); - } - else - { - Assert( NotSet(&Chunk->Voxels[VoxIndex], Voxel_Filled) ); - } - } - } - } - return ChunkSum; -} +poof(do_editor_ui_for_compound_type(game_state)) +#include -link_internal u32 -WarpedTerrain( world_chunk *Chunk, - v3i NoiseBasis, - void *NoiseParams, - void *UserData ) +BONSAI_API_MAIN_THREAD_CALLBACK() { - TIMED_FUNCTION(); - UNPACK_NOISE_PARAMS(NoiseParams); - - u32 ChunkSum = 0; + Assert(ThreadLocal_ThreadIndex == 0); - s32 MinZ = Chunk->WorldP.z*WorldChunkDim.z; - s32 MaxZ = MinZ+WorldChunkDim.z ; + TIMED_FUNCTION(); + UNPACK_ENGINE_RESOURCES(Resources); - octave_buffer *OctaveBuf = (octave_buffer*)UserData; - u32 OctaveCount = OctaveBuf->Count; + f32 dt = Plat->dt; + f32 Speed = 80.f; - for ( s32 z = 0; z < Dim.z; ++ z) { - s64 WorldZ = z - SrcToDest.z + (WorldChunkDim.z*Chunk->WorldP.z); - s64 WorldZBiased = WorldZ - zMin; - for ( s32 y = 0; y < Dim.y; ++ y) - { - s64 WorldY = y - SrcToDest.y + (WorldChunkDim.y*Chunk->WorldP.y); - for ( s32 x = 0; x < Dim.x; ++ x) - { - s64 WorldX = x - SrcToDest.x + (WorldChunkDim.x*Chunk->WorldP.x); - s32 VoxIndex = GetIndex(Voxel_Position(x,y,z), Dim); - Chunk->Voxels[VoxIndex].Flags = Voxel_Empty; - Assert( NotSet(&Chunk->Voxels[VoxIndex], Voxel_Filled) ); - - r32 NoiseValue = 0.f; - for (u32 OctaveIndex = 0; OctaveIndex < OctaveCount; ++OctaveIndex) - { - octave *Octave = OctaveBuf->Octaves+OctaveIndex; - - f32 InX = SafeDivide0((x + SrcToDest.x + ( WorldChunkDim.x*Chunk->WorldP.x)), Octave->Freq.x); - f32 InY = SafeDivide0((y + SrcToDest.y + ( WorldChunkDim.y*Chunk->WorldP.y)), Octave->Freq.y); - f32 InZ = SafeDivide0((z + SrcToDest.z + ( WorldChunkDim.z*Chunk->WorldP.z)), Octave->Freq.z); - - r32 Warp = PerlinNoise(InX, InY, InZ); - v3 WarpFactor = Warp*Octave->WarpStrength; - - r32 N = PerlinNoise(InX+WarpFactor.x, InY+WarpFactor.y, InZ+WarpFactor.z); - - Assert(N <= 1.05f); - Assert(N > -1.05f); - - NoiseValue += (N*Octave->Amp); - } - - b32 NoiseChoice = r64(NoiseValue) > r64(WorldZBiased); - - v3 ThisColor = RGBColor; - -#if 0 - s32 SnowThreshold = 100; - if (NoiseChoice == True && WorldZ > SnowThreshold) - { - ThisColor = WHITE; - } + window_layout *Window = GetOrCreateWindow(Ui, "GameState"); + PushWindowStart(Ui, Window); + DoEditorUi(Ui, Window, GameState, {}, u32(Hash(Window))); + PushWindowEnd(Ui, Window); + } - s32 SandThreshold = 3; - if (NoiseChoice == True && WorldZ < SandThreshold) - { - ThisColor = YELLOW; - } + /* { */ + /* window_layout *Window = GetOrCreateWindow(Ui, "Easing Window"); */ + /* PushWindowStart(Ui, Window); */ + /* PushUntexturedQuad(Ui, V2(0), V2(256), zDepth_Text, 0, {}, UiElementLayoutFlag_Default, UseRenderPass_easing_function_visualizer_render_pass, &GameState->EasingFunctionVisRP); */ + /* PushWindowEnd(Ui, Window); */ + /* } */ - s32 WaterThreshold = 0; - if (NoiseChoice == False && WorldZ < WaterThreshold) - { - NoiseChoice = True; - ThisColor = BLUE; - } -#endif - - SetFlag(&Chunk->Voxels[VoxIndex], (voxel_flag)(Voxel_Filled*NoiseChoice)); - Chunk->Voxels[VoxIndex].Color = RGBtoPackedHSV(ThisColor)*u16(NoiseChoice); - ChunkSum += NoiseChoice; + { + global_variable window_layout Window = WindowLayout("Terrain Shaping Shader", WindowLayoutFlag_Align_Right); + PushWindowStart(Ui, &Window); - Assert( (Chunk->Voxels[VoxIndex].Flags&VoxelFaceMask) == 0); + file_traversal_node_block_array Files = + GetLexicographicallySortedListOfFilesInDirectory( + CSz("shaders/terrain/shaping"), GetTranArena()); - if (NoiseChoice) - { - Assert( IsSet(&Chunk->Voxels[VoxIndex], Voxel_Filled) ); - } - else + u32 I = 0; + IterateOver(&Files, FileNode, FileNodeIndex) + { + if (FileNode->Type == FileTraversalType_File) { - Assert( NotSet(&Chunk->Voxels[VoxIndex], Voxel_Filled) ); + b32 Selected = Contains(Resources->Graphics.TerrainShapingRC.Program.FragSourceFilename, FileNode->Name); + if (Button(Ui, FileNode->Name, UiId(&Window, "shader file name", I++), Selected)) + { + // Force engine to reload new shader + Resources->Graphics.TerrainShapingRC.Program.FragSourceFilename = Concat(FileNode->Dir, CSz("/"), FileNode->Name, GetTranArena()); + Resources->Graphics.TerrainShapingRC.Program.FragmentTimeModifiedWhenLoaded = 0; + } + PushNewRow(Ui); } } - } + PushWindowEnd(Ui, &Window); } - return ChunkSum; -} - -BONSAI_API_WORKER_THREAD_INIT_CALLBACK() -{ - Global_ThreadStates = AllThreads; - SetThreadLocal_ThreadIndex(ThreadIndex); -} - -BONSAI_API_WORKER_THREAD_CALLBACK() -{ - if (ThreadLocal_ThreadIndex == INVALID_THREAD_LOCAL_THREAD_INDEX) { SetThreadLocal_ThreadIndex(Thread->Index); } - - b32 Result = True; - switch (Entry->Type) { - default: { Result = False; } break; + global_variable window_layout Window = WindowLayout("Terrain Decoration Shader", WindowLayoutFlag_Align_BottomRight); + PushWindowStart(Ui, &Window); + file_traversal_node_block_array Files = GetLexicographicallySortedListOfFilesInDirectory(CSz("shaders/terrain/decoration"), GetTranArena()); - // NOTE(Jesse): Here we're going to provide an implementation for - // initializing a world chunk. - case type_work_queue_entry_init_world_chunk: - { - volatile work_queue_entry_init_world_chunk *Job = SafeAccess(work_queue_entry_init_world_chunk, Entry); - world_chunk *Chunk = Job->Chunk; - - if (ChunkIsGarbage(Chunk)) - { - // NOTE(Jesse): This is an optimization; the engine marks chunks that - // have moved outside of the visible region as garbage. - Chunk->Flags = Chunk_Uninitialized; - } - else + u32 I = 0; + IterateOver(&Files, FileNode, FileNodeIndex) { - auto GenType = GetEngineResources()->GameState->TerrainGenType; - - auto Ignored = MeshBit_Lod0; - - /* Info("%S", ToString(GenType)); */ - switch (GenType) + if (FileNode->Type == FileTraversalType_File) { - case TerrainGenType_Flat: - { - // Flat Params - v3 Period = V3(100); - s32 Amplititude = 25; - s32 StartingZDepth = -1; - v3 Color = RGB_GRASS_GREEN; - InitializeChunkWithNoise( Terrain_Flat, Thread, Chunk, Chunk->Dim, 0, Period, Amplititude, StartingZDepth, Color, Ignored, ChunkInitFlag_Noop, 0); - } break; - - case TerrainGenType_SinCos: + b32 Selected = Contains(Resources->Graphics.TerrainDecorationRC.Program.FragSourceFilename, FileNode->Name); + if (Button(Ui, FileNode->Name, UiId(&Window, "shader file name", I++), Selected)) { - // Bumpy Sin(x)+Cos(y) noise. Useful for visualizing the polylines/splines mapping noise values to their final values. - v3 Period = V3(100); - s32 Amplititude = 250; - /* s32 Period = 100; */ - /* s32 Amplititude = 2500; */ - s32 StartingZDepth = -1; - chunk_init_flags InitFlags = ChunkInitFlag_Noop; - v3 Color = RGB_GRASS_GREEN; - InitializeChunkWithNoise( Terrain_SinCos, Thread, Chunk, Chunk->Dim, 0, Period, Amplititude, StartingZDepth, Color, Ignored, InitFlags, 0); - } break; - - case TerrainGenType_Voronoi: - { - // Voronoi noise .. looks like rocks. - v3 Period = V3(100); - s32 Amplititude = 50; - s32 StartingZDepth = -1; - chunk_init_flags InitFlags = ChunkInitFlag_Noop; - v3 Color = RGB_GRASS_GREEN; - InitializeChunkWithNoise( Terrain_Voronoi2D, Thread, Chunk, Chunk->Dim, 0, Period, Amplititude, StartingZDepth, Color, Ignored, InitFlags, 0); - } break; - - case TerrainGenType_Checkerboard: - { - // Custom flat noise function that produces a checkerboard - v3 Period = V3(0); - s32 Amplititude = 0; - s32 StartingZDepth = -1; - chunk_init_flags InitFlags = ChunkInitFlag_Noop; - /* chunk_init_flags InitFlags = ChunkInitFlag_GenMipMapLODs; */ - v3 Color = RGB_GRASS_GREEN; - InitializeChunkWithNoise( Terrain_Checkerboard, Thread, Chunk, Chunk->Dim, 0, Period, Amplititude, StartingZDepth, Color, Ignored, InitFlags, 0); - } break; - - case TerrainGenType_Perlin2D: - { - // Perlin 2D Params - v3 Period = V3(100); - s32 Amplititude = 5; - s32 StartingZDepth = 0; - v3 Color = RGB_GRASS_GREEN; - u32 Octaves = 1; - InitializeChunkWithNoise( Terrain_Perlin2D, Thread, Chunk, Chunk->Dim, 0, Period, Amplititude, StartingZDepth, Color, MeshBit_Lod0, ChunkInitFlag_Noop, &Octaves); - } break; - - case TerrainGenType_Perlin3D: - { - // Perlin 3D Params - v3 Period = V3(50); - s32 Amplititude = 8; - s32 StartingZDepth = 2; - v3 Color = RGB_GRASS_GREEN; - InitializeChunkWithNoise( Terrain_Perlin3D, Thread, Chunk, Chunk->Dim, 0, Period, Amplititude, StartingZDepth, Color, MeshBit_Lod0, ChunkInitFlag_Noop, 0); - } break; - - - case TerrainGenType_FBM2D: - { - // FBM params - v3 Period = V3(300); - s32 Amplititude = 220; - s32 StartingZDepth = -200; - u32 Octaves = 4; - /* chunk_init_flags InitFlags = ChunkInitFlag_ComputeStandingSpots; */ - chunk_init_flags InitFlags = ChunkInitFlag_Noop; - v3 Color = RGB_GRASS_GREEN; - InitializeChunkWithNoise( Terrain_FBM2D, Thread, Chunk, Chunk->Dim, 0, Period, Amplititude, StartingZDepth, Color, Ignored, InitFlags, (void*)&Octaves); - } break; - - case TerrainGenType_GrassyTerracedTerrain: - { - // Custom FBM noise example generating slightly-more-complex game-world-like terrain - v3 Period = V3(0); // Ignored - s32 Amplititude = 0; // Ignored - s32 StartingZDepth = -100; - u32 OctaveCount = 1; - - octave_buffer OctaveBuf = { OctaveCount, {} }; - OctaveBuf.Octaves = Allocate(octave, Thread->TempMemory, OctaveCount); - - OctaveBuf.Octaves[0] = {V3(400, 400, 200), 150, V3(1)}; - /* OctaveBuf.Octaves[1] = {V3(35, 35, 50), 6, V3(2.f)}; */ - /* OctaveBuf.Octaves[2] = {V3(500, 500, 20), 200, V3(2.f)}; */ - /* OctaveBuf.Octaves[2] = {75, 60, 1}; */ - /* OctaveBuf.Octaves[3] = {37, 30, 0}; */ - - - /* chunk_init_flags InitFlags = ChunkInitFlag_ComputeStandingSpots; */ - /* chunk_init_flags InitFlags = ChunkInitFlag_GenMipMapLODs; */ - chunk_init_flags InitFlags = ChunkInitFlag_Noop; - v3 Color = RGB_GRASS_GREEN; - InitializeChunkWithNoise( GrassyTerracedTerrain, Thread, Chunk, Chunk->Dim, 0, Period, Amplititude, StartingZDepth, Color, MeshBit_Lod0, InitFlags, (void*)&OctaveBuf); - } break; - - case TerrainGenType_GrassyTerracedTerrain2: - { - // Custom FBM noise example generating slightly-more-complex game-world-like terrain - v3 Period = V3(0); // Ignored - s32 Amplititude = 0; // Ignored - s32 StartingZDepth = -100; - u32 OctaveCount = 1; - - octave_buffer OctaveBuf = { OctaveCount, {} }; - OctaveBuf.Octaves = Allocate(octave, Thread->TempMemory, OctaveCount); - - OctaveBuf.Octaves[0] = {V3(400, 400, 200), 150, V3(1)}; - /* OctaveBuf.Octaves[1] = {V3(35, 35, 50), 60, V3(2.f)}; */ - /* OctaveBuf.Octaves[2] = {V3(500, 500, 20), 200, V3(2.f)}; */ - /* OctaveBuf.Octaves[2] = {75, 60, 1}; */ - /* OctaveBuf.Octaves[3] = {37, 30, 0}; */ - - - /* chunk_init_flags InitFlags = ChunkInitFlag_ComputeStandingSpots; */ - /* chunk_init_flags InitFlags = ChunkInitFlag_GenMipMapLODs; */ - chunk_init_flags InitFlags = ChunkInitFlag_Noop; - v3 Color = RGB_GRASS_GREEN; - InitializeChunkWithNoise( GrassyTerracedTerrain2, Thread, Chunk, Chunk->Dim, 0, Period, Amplititude, StartingZDepth, Color, MeshBit_Lod0, InitFlags, (void*)&OctaveBuf); - } break; - - - case TerrainGenType_GrassyTerracedTerrain3: - { - // Custom FBM noise example generating slightly-more-complex game-world-like terrain - v3 Period = V3(0); // Ignored - s32 Amplititude = 0; // Ignored - s32 StartingZDepth = -100; - u32 OctaveCount = 2; - - octave_buffer OctaveBuf = { OctaveCount, {} }; - OctaveBuf.Octaves = Allocate(octave, Thread->TempMemory, OctaveCount); - - OctaveBuf.Octaves[0] = {V3(1400, 1400, 800), 350, V3(1.f)}; - OctaveBuf.Octaves[1] = {V3(400, 400, 200), 150, V3(1.f)}; - /* OctaveBuf.Octaves[2] = {V3(35, 35, 50), 6, V3(2.f)}; */ - /* OctaveBuf.Octaves[2] = {V3(500, 500, 20), 200, V3(2.f)}; */ - /* OctaveBuf.Octaves[2] = {75, 60, 1}; */ - /* OctaveBuf.Octaves[3] = {37, 30, 0}; */ - - - /* chunk_init_flags InitFlags = ChunkInitFlag_ComputeStandingSpots; */ - /* chunk_init_flags InitFlags = ChunkInitFlag_GenMipMapLODs; */ - chunk_init_flags InitFlags = ChunkInitFlag_Noop; - v3 Color = RGB_GRASS_GREEN; - InitializeChunkWithNoise( GrassyTerracedTerrain3, Thread, Chunk, Chunk->Dim, 0, Period, Amplititude, StartingZDepth, Color, MeshBit_Lod0, InitFlags, (void*)&OctaveBuf); - } break; - - case TerrainGenType_GrassyTerracedTerrain4: - { - // Custom FBM noise example generating slightly-more-complex game-world-like terrain - v3 Period = V3(0); // Ignored - s32 Amplititude = 0; // Ignored - s32 StartingZDepth = -100; - u32 OctaveCount = 3; - - octave_buffer OctaveBuf = { OctaveCount, {} }; - OctaveBuf.Octaves = Allocate(octave, Thread->TempMemory, OctaveCount); - - OctaveBuf.Octaves[0] = {V3(800, 800, 1700), 350, V3(1.f)}; - OctaveBuf.Octaves[1] = {V3(400, 400, 200), 350, V3(1.f)}; - OctaveBuf.Octaves[2] = {V3(35, 35, 25), 6, V3(2.f)}; - - /* chunk_init_flags InitFlags = ChunkInitFlag_ComputeStandingSpots; */ - /* chunk_init_flags InitFlags = ChunkInitFlag_GenMipMapLODs; */ - chunk_init_flags InitFlags = ChunkInitFlag_Noop; - v3 Color = RGB_GRASS_GREEN; - InitializeChunkWithNoise( GrassyTerracedTerrain4, Thread, Chunk, Chunk->Dim, 0, Period, Amplititude, StartingZDepth, Color, MeshBit_Lod0, InitFlags, (void*)&OctaveBuf); - } break; - - - case TerrainGenType_TerracedTerrain: - { - // Custom FBM noise example generating slightly-more-complex game-world-like terrain - v3 Period = V3(0); // Ignored - s32 Amplititude = 0; // Ignored - s32 StartingZDepth = -100; - u32 OctaveCount = 1; - - octave_buffer OctaveBuf = { OctaveCount, {} }; - OctaveBuf.Octaves = Allocate(octave, Thread->TempMemory, OctaveCount); - - OctaveBuf.Octaves[0] = {V3(400, 400, 200), 150, V3(1)}; - /* OctaveBuf.Octaves[1] = {V3(35, 35, 50), 6, V3(2.f)}; */ - /* OctaveBuf.Octaves[2] = {V3(500, 500, 20), 200, V3(2.f)}; */ - /* OctaveBuf.Octaves[2] = {75, 60, 1}; */ - /* OctaveBuf.Octaves[3] = {37, 30, 0}; */ - - - /* chunk_init_flags InitFlags = ChunkInitFlag_ComputeStandingSpots; */ - /* chunk_init_flags InitFlags = ChunkInitFlag_GenMipMapLODs; */ - chunk_init_flags InitFlags = ChunkInitFlag_Noop; - v3 Color = RGB_GRASS_GREEN; - InitializeChunkWithNoise( TerracedTerrain, Thread, Chunk, Chunk->Dim, 0, Period, Amplititude, StartingZDepth, Color, MeshBit_Lod0, InitFlags, (void*)&OctaveBuf); - } break; - - case TerrainGenType_GrassyLargeTerracedTerrain: - { - // Custom FBM noise example generating slightly-more-complex game-world-like terrain - v3 Period = V3(0); // Ignored - s32 Amplititude = 0; // Ignored - s32 StartingZDepth = -140; - u32 OctaveCount = 4; - - octave_buffer OctaveBuf = { OctaveCount, {} }; - OctaveBuf.Octaves = Allocate(octave, Thread->TempMemory, OctaveCount); - - OctaveBuf.Octaves[0] = {V3(1200, 1200, 900), 500, V3(1)}; - OctaveBuf.Octaves[1] = {V3(1200, 1200, 900), 500, V3(1)}; - OctaveBuf.Octaves[2] = {V3(800, 800, 500), 125, V3(1)}; - OctaveBuf.Octaves[3] = {V3(35, 35, 25), 5, V3(2.f)}; - /* OctaveBuf.Octaves[2] = {V3(500, 500, 20), 200, V3(2.f)}; */ - /* OctaveBuf.Octaves[2] = {75, 60, 1}; */ - /* OctaveBuf.Octaves[3] = {37, 30, 0}; */ - - - /* chunk_init_flags InitFlags = ChunkInitFlag_ComputeStandingSpots; */ - chunk_init_flags InitFlags = ChunkInitFlag_GenLODs; - /* chunk_init_flags InitFlags = ChunkInitFlag_Noop; */ - v3 Color = RGB_GRASS_GREEN; - InitializeChunkWithNoise( GrassyLargeTerracedTerrain, Thread, Chunk, Chunk->Dim, 0, Period, Amplititude, StartingZDepth, Color, MeshBit_Lod0, InitFlags, (void*)&OctaveBuf); - } break; - - case TerrainGenType_GrassyIsland: - { - // Custom FBM noise example generating slightly-more-complex game-world-like terrain - v3 Period = V3(0); // Ignored - s32 Amplititude = 0; // Ignored - s32 StartingZDepth = -140; - u32 OctaveCount = 2; - - octave_buffer OctaveBuf = { OctaveCount, {} }; - OctaveBuf.Octaves = Allocate(octave, Thread->TempMemory, OctaveCount); - - OctaveBuf.Octaves[0] = {V3(800, 800, 300), 275, V3(1)}; - OctaveBuf.Octaves[1] = {V3(35, 35, 50), 25, V3(2.f)}; - /* OctaveBuf.Octaves[2] = {V3(500, 500, 20), 200, V3(2.f)}; */ - /* OctaveBuf.Octaves[2] = {75, 60, 1}; */ - /* OctaveBuf.Octaves[3] = {37, 30, 0}; */ - - - /* chunk_init_flags InitFlags = ChunkInitFlag_ComputeStandingSpots; */ - /* chunk_init_flags InitFlags = ChunkInitFlag_GenMipMapLODs; */ - chunk_init_flags InitFlags = ChunkInitFlag_Noop; - v3 Color = RGB_GRASS_GREEN; - InitializeChunkWithNoise( GrassyIslandTerrain, Thread, Chunk, Chunk->Dim, 0, Period, Amplititude, StartingZDepth, Color, MeshBit_Lod0, InitFlags, (void*)&OctaveBuf); - } break; - - case TerrainGenType_Hoodoo: - { - v3 Period = V3(300); - s32 Amplititude = 220; - s32 StartingZDepth = 70; - u32 OctaveCount = 2; - - octave_buffer OctaveBuf = { OctaveCount, {} }; - OctaveBuf.Octaves = Allocate(octave, Thread->TempMemory, OctaveCount); - - OctaveBuf.Octaves[0] = {V3(350, 150, 50), 25, V3(1.f)}; - OctaveBuf.Octaves[1] = {V3(120, 60, 35), 7.5, V3(1.f)}; - /* OctaveBuf.Octaves[1] = {V3(90, 60, 35), 25, V3(1.f)}; */ - - chunk_init_flags InitFlags = ChunkInitFlag_Noop; - /* chunk_init_flags InitFlags = ChunkInitFlag_GenMipMapLODs; */ - /* chunk_init_flags InitFlags = chunk_init_flags(ChunkInitFlag_ComputeStandingSpots | ChunkInitFlag_GenMipMapLODs); */ - v3 Color = RGB_GRASS_GREEN; - InitializeChunkWithNoise( HoodooTerrain, Thread, Chunk, Chunk->Dim, 0, Period, Amplititude, StartingZDepth, Color, MeshBit_Lod0, InitFlags, (void*)&OctaveBuf); - } break; - - case TerrainGenType_Warped: - { - // Custom FBM noise example generating highly domain-warped terrain - v3 Period = V3(0); // Ignored - s32 Amplititude = 0; // Ignored - s32 StartingZDepth = -200; - u32 OctaveCount = 2; - - octave_buffer OctaveBuf = { OctaveCount, {} }; - OctaveBuf.Octaves = Allocate(octave, Thread->TempMemory, OctaveCount); - - OctaveBuf.Octaves[0] = {V3(800, 800, 300), 350, V3(1)}; - OctaveBuf.Octaves[1] = {V3(35, 35, 50), 20, V3(3.f)}; - /* OctaveBuf.Octaves[2] = {V3(500, 500, 20), 200, V3(2.f)}; */ - /* OctaveBuf.Octaves[2] = {V3(500, 500, 20), 200, V3(2.f)}; */ - /* OctaveBuf.Octaves[2] = {75, 60, 1}; */ - /* OctaveBuf.Octaves[3] = {37, 30, 0}; */ - - - /* chunk_init_flags InitFlags = ChunkInitFlag_ComputeStandingSpots; */ - /* chunk_init_flags InitFlags = ChunkInitFlag_GenMipMapLODs; */ - chunk_init_flags InitFlags = ChunkInitFlag_Noop; - v3 Color = RGB_GRASS_GREEN; - InitializeChunkWithNoise( WarpedTerrain, Thread, Chunk, Chunk->Dim, 0, Period, Amplititude, StartingZDepth, Color, Ignored, InitFlags, (void*)&OctaveBuf); - } break; - - + // Force engine to reload new shader + Resources->Graphics.TerrainDecorationRC.Program.FragSourceFilename = Concat(FileNode->Dir, CSz("/"), FileNode->Name, GetTranArena()); + Resources->Graphics.TerrainDecorationRC.Program.FragmentTimeModifiedWhenLoaded = 0; + } + PushNewRow(Ui); } } - - FinalizeChunkInitialization(Chunk); - UnSetFlag(&Chunk->Flags, Chunk_Queued); - } break; + PushWindowEnd(Ui, &Window); } - return Result; -} - -BONSAI_API_MAIN_THREAD_INIT_CALLBACK() -{ - UNPACK_ENGINE_RESOURCES(Resources); - - Global_AssetPrefixPath = CSz("examples/terrain_gen/assets"); - - world_position WorldCenter = {}; - canonical_position CameraTargetP = {}; - - StandardCamera(Graphics->Camera, 10000.0f, 5000.0f); - - AllocateWorld(World, WorldCenter, WORLD_CHUNK_DIM, g_VisibleRegion); - - GameState = Allocate(game_state, Resources->GameMemory, 1); - - /* GameState->TerrainGenType = TerrainGenType_GrassyTerracedTerrain; */ - - GameState->TerrainGenType = TerrainGenType_SinCos; - /* GameState->TerrainGenType = TerrainGenType_GrassyTerracedTerrain4; */ - /* GameState->TerrainGenType = TerrainGenType_Voronoi; */ - /* World->Center = V3i(-22, 101, 1); */ - - Camera->GhostId = GetFreeEntity(EntityTable); - entity *CameraGhost = GetEntity(EntityTable, Camera->GhostId); - /* CameraGhost->P.WorldP = V3i(-53, -93, 2); */ - /* CameraGhost->P.WorldP = V3i(-25, -75, 2); */ - /* CameraGhost->P.WorldP = V3i(-5, -121, 2); */ - CameraGhost->P.WorldP = V3i(330, -87, 2); - /* CameraGhost->P.WorldP = V3i(33, -87, 2); */ - /* CameraGhost->P.WorldP = V3i(5, -73, 2); */ - CameraGhost->Behavior = entity_behavior_flags(CameraGhost->Behavior|EntityBehaviorFlags_DefatulCameraGhostBehavior|EntityBehaviorFlags_WorldCenter); - - SpawnEntity(CameraGhost); - - return GameState; -} - - -BONSAI_API_MAIN_THREAD_CALLBACK() -{ - Assert(ThreadLocal_ThreadIndex == 0); - - TIMED_FUNCTION(); - UNPACK_ENGINE_RESOURCES(Resources); - - f32 dt = Plat->dt; - f32 Speed = 80.f; - - global_variable window_layout Window = WindowLayout("Terrain Gen", WindowLayoutFlag_Align_Right); - - PushWindowStart(Ui, &Window); - ui_toggle_button_group TerrainGenTypeRadio = RadioButtonGroup_terrain_gen_type(Ui, &Window, CSz("Terrain Generators"), &GameState->TerrainGenType, &DefaultUiRenderParams_Generic, ToggleButtonGroupFlags_DrawVertical); - PushWindowEnd(Ui, &Window); - - /* Info("%S :: %d", ToString(GameState->TerrainGenType), GameState->TerrainGenType); */ - - if (TerrainGenTypeRadio.AnyElementClicked) - { - SignalAndWaitForWorkers(&Plat->WorkerThreadsSuspendFutex); - SoftResetEngine(Resources, HardResetFlag_NoResetCamera); - UnsignalFutex(&Plat->WorkerThreadsSuspendFutex); - } } diff --git a/examples/terrain_gen/game.h b/examples/terrain_gen/game.h new file mode 100644 index 000000000..f946733ca --- /dev/null +++ b/examples/terrain_gen/game.h @@ -0,0 +1,10 @@ + + +struct game_state +{ + easing_function *EasingFunction; + visible_region_size *VisibleRegionSize; + + easing_function_visualizer_render_pass EasingFunctionVisRP; poof(@ui_skip) +}; + diff --git a/examples/terrain_gen/game_constants.h b/examples/terrain_gen/game_constants.h deleted file mode 100644 index 9e2a3b117..000000000 --- a/examples/terrain_gen/game_constants.h +++ /dev/null @@ -1,50 +0,0 @@ - -#if 0 -global_variable chunk_dimension -g_VisibleRegion = Chunk_Dimension(32, 32, 8); - -global_variable chunk_dimension -WORLD_CHUNK_DIM = Chunk_Dimension(32, 32, 8); - -#else - -global_variable chunk_dimension -/* g_VisibleRegion = Chunk_Dimension(120, 120, 6); */ -/* g_VisibleRegion = Chunk_Dimension(64, 64, 16); */ -/* g_VisibleRegion = Chunk_Dimension(80, 80, 8); */ -/* g_VisibleRegion = Chunk_Dimension(64, 64, 8); */ -/* g_VisibleRegion = Chunk_Dimension(64, 64, 6); */ -/* g_VisibleRegion = Chunk_Dimension(32, 32, 16); */ -/* g_VisibleRegion = Chunk_Dimension(32, 32, 10); */ -/* g_VisibleRegion = Chunk_Dimension(32, 32, 8); */ -/* g_VisibleRegion = Chunk_Dimension(32, 32, 6); */ -/* g_VisibleRegion = Chunk_Dimension(32, 32, 4); */ -/* g_VisibleRegion = Chunk_Dimension(24, 24, 4); */ -/* g_VisibleRegion = Chunk_Dimension(24, 24, 6); */ -g_VisibleRegion = Chunk_Dimension(24, 24, 8); -/* g_VisibleRegion = Chunk_Dimension(16, 16, 8); */ -/* g_VisibleRegion = Chunk_Dimension(16, 16, 6); */ -/* g_VisibleRegion = Chunk_Dimension(10, 10, 10); */ -/* g_VisibleRegion = Chunk_Dimension(8, 8, 6); */ - - -/* global_variable chunk_dimension */ -/* WORLD_CHUNK_DIM = Chunk_Dimension(16, 16, 16); */ - -/* global_variable chunk_dimension */ -/* WORLD_CHUNK_DIM = Chunk_Dimension(16, 16, 16); */ - -/* global_variable chunk_dimension */ -/* WORLD_CHUNK_DIM = Chunk_Dimension(28, 28, 28); */ - -/* global_variable chunk_dimension */ -/* WORLD_CHUNK_DIM = Chunk_Dimension(32, 32, 32); */ - -/* global_variable chunk_dimension */ -/* WORLD_CHUNK_DIM = Chunk_Dimension(64, 64, 64); */ - - -global_variable chunk_dimension -WORLD_CHUNK_DIM = Chunk_Dimension(64, 64, 64); - -#endif diff --git a/examples/terrain_gen/game_types.h b/examples/terrain_gen/game_types.h deleted file mode 100644 index 0b44c0fea..000000000 --- a/examples/terrain_gen/game_types.h +++ /dev/null @@ -1,33 +0,0 @@ - -enum terrain_gen_type -{ - /* TerrainGenType_Undefined = (0), */ - TerrainGenType_Flat = (1 << 0), - TerrainGenType_Checkerboard = (1 << 1), - TerrainGenType_SinCos = (1 << 2), - TerrainGenType_Voronoi = (1 << 3), - TerrainGenType_Perlin2D = (1 << 4), - TerrainGenType_Perlin3D = (1 << 5), - TerrainGenType_FBM2D = (1 << 6), - TerrainGenType_TerracedTerrain = (1 << 7), - TerrainGenType_GrassyTerracedTerrain = (1 << 8), - TerrainGenType_GrassyLargeTerracedTerrain = (1 << 9), - TerrainGenType_GrassyTerracedTerrain2 = (1 << 10), - TerrainGenType_GrassyTerracedTerrain3 = (1 << 11), - TerrainGenType_GrassyTerracedTerrain4 = (1 << 12), - TerrainGenType_GrassyIsland = (1 << 13), - TerrainGenType_Hoodoo = (1 << 14), - TerrainGenType_Warped = (1 << 15), -}; - -poof(radio_button_group_for_bitfield_enum(terrain_gen_type)) -#include - -poof(string_and_value_tables(terrain_gen_type)) -#include - -struct game_state -{ - terrain_gen_type TerrainGenType; -}; - diff --git a/examples/the_wanderer/game.cpp b/examples/the_wanderer/game.cpp index 6d61308f5..28c0deae2 100644 --- a/examples/the_wanderer/game.cpp +++ b/examples/the_wanderer/game.cpp @@ -1,8 +1,6 @@ #define BONSAI_DEBUG_SYSTEM_API 1 #include - -#include #include @@ -99,10 +97,10 @@ BONSAI_API_MAIN_THREAD_INIT_CALLBACK() GameState = Allocate(game_state, Resources->GameMemory, 1); - GameState->Entropy.Seed = DEBUG_NOISE_SEED; + GameState->Entropy.Seed = 525634563; world_position WorldCenter = World_Position(0, 0, 0); - AllocateWorld(Resources->World, WorldCenter, WORLD_CHUNK_DIM, g_VisibleRegion); + AllocateWorld(Resources->World, {}, VisibleRegionSize_128); /* Resources->World->Flags = world_flag(Resources->World->Flags|WorldFlag_WorldCenterFollowsCameraTarget); */ GameState->Models = AllocateGameModels(GameState, Resources->GameMemory, Heap); diff --git a/examples/the_wanderer/game_constants.h b/examples/the_wanderer/game_constants.h deleted file mode 100644 index afa33ecb4..000000000 --- a/examples/the_wanderer/game_constants.h +++ /dev/null @@ -1,14 +0,0 @@ - -#if 0 -global_variable chunk_dimension -g_VisibleRegion = Chunk_Dimension(32, 32, 8); - -global_variable chunk_dimension -WORLD_CHUNK_DIM = Chunk_Dimension(32, 32, 8); -#else -global_variable chunk_dimension -g_VisibleRegion = Chunk_Dimension(16, 8, 8); - -global_variable chunk_dimension -WORLD_CHUNK_DIM = Chunk_Dimension(32, 32, 32); -#endif diff --git a/examples/tile_gen/game.cpp b/examples/tile_gen/game.cpp index c85cb5b2f..0bd2be3f0 100644 --- a/examples/tile_gen/game.cpp +++ b/examples/tile_gen/game.cpp @@ -1,13 +1,9 @@ #define BONSAI_DEBUG_SYSTEM_API 1 #include - -#include #include -/* global_variable debug_state *Global_DebugStatePointer; */ - model * AllocateGameModels(game_state *GameState, memory_arena *Memory, heap_allocator *Heap) { @@ -26,7 +22,7 @@ BONSAI_API_MAIN_THREAD_CALLBACK() UNPACK_ENGINE_RESOURCES(Resources); - /* GL.Disable(GL_CULL_FACE); */ + /* GetGL()->Disable(GL_CULL_FACE); */ entity *Player = GameState->Player; @@ -57,7 +53,7 @@ BONSAI_API_MAIN_THREAD_INIT_CALLBACK() GameState->Models = AllocateGameModels(GameState, Memory, Heap); world_position WorldCenter = World_Position(0, 0, 0); - AllocateAndInitWorld(Resources->World, WorldCenter, WORLD_CHUNK_DIM, g_VisibleRegion); + AllocateAndInitWorld(Resources->World, WorldCenter, WORLD_CHUNK_DIM, VisibleRegionSize_128); GameState->Player = GetFreeEntity(EntityTable); SpawnPlayer( Plat, diff --git a/examples/tile_gen/game_constants.h b/examples/tile_gen/game_constants.h deleted file mode 100644 index afa33ecb4..000000000 --- a/examples/tile_gen/game_constants.h +++ /dev/null @@ -1,14 +0,0 @@ - -#if 0 -global_variable chunk_dimension -g_VisibleRegion = Chunk_Dimension(32, 32, 8); - -global_variable chunk_dimension -WORLD_CHUNK_DIM = Chunk_Dimension(32, 32, 8); -#else -global_variable chunk_dimension -g_VisibleRegion = Chunk_Dimension(16, 8, 8); - -global_variable chunk_dimension -WORLD_CHUNK_DIM = Chunk_Dimension(32, 32, 32); -#endif diff --git a/examples/tools/voxel_synthesis_rule_baker/game.cpp b/examples/tools/voxel_synthesis_rule_baker/game.cpp index 28a828392..a5a13ffee 100644 --- a/examples/tools/voxel_synthesis_rule_baker/game.cpp +++ b/examples/tools/voxel_synthesis_rule_baker/game.cpp @@ -1,8 +1,6 @@ #define BONSAI_DEBUG_SYSTEM_API 1 #include - -#include "game_constants.h" #include "game_types.h" BONSAI_API_WORKER_THREAD_CALLBACK() @@ -722,7 +720,7 @@ BONSAI_API_MAIN_THREAD_INIT_CALLBACK() /* world_position WorldCenter = {{2,2,2}}; */ - world_position WorldCenter = g_VisibleRegion/2; + world_position WorldCenter = V3i(VisibleRegionSize_128)/2; /* world_position WorldCenter = {{}}; */ /* canonical_position CameraTargetP = Canonical_Position(V3(0), {{4,4,4}}); */ @@ -733,7 +731,7 @@ BONSAI_API_MAIN_THREAD_INIT_CALLBACK() GameState->Entropy.Seed = DEBUG_NOISE_SEED; - AllocateWorld(Resources->World, WorldCenter, WORLD_CHUNK_DIM, g_VisibleRegion); + AllocateWorld(Resources->World, WorldCenter, VisibleRegionSize_128); random_series WorldEntropy = {54930695483}; WaitForWorkerThreads(&Plat->HighPriorityWorkerCount); diff --git a/examples/tools/voxel_synthesis_rule_baker/game_constants.h b/examples/tools/voxel_synthesis_rule_baker/game_constants.h deleted file mode 100644 index 3723ecf5c..000000000 --- a/examples/tools/voxel_synthesis_rule_baker/game_constants.h +++ /dev/null @@ -1,22 +0,0 @@ - -#if 0 -global_variable chunk_dimension -g_VisibleRegion = Chunk_Dimension(32, 32, 8); - -global_variable chunk_dimension -WORLD_CHUNK_DIM = Chunk_Dimension(32, 32, 8); -#else - -/* global_variable chunk_dimension */ -/* g_VisibleRegion = Chunk_Dimension(16, 8, 4); */ - -global_variable chunk_dimension -g_VisibleRegion = Chunk_Dimension(4, 4, 4); - -/* global_variable chunk_dimension */ -/* g_VisibleRegion = Chunk_Dimension(8, 8, 4); */ - -global_variable chunk_dimension -WORLD_CHUNK_DIM = Chunk_Dimension(32, 32, 32); - -#endif diff --git a/examples/transparency/game.cpp b/examples/transparency/game.cpp index 7b14a6fcb..d1cfd4f76 100644 --- a/examples/transparency/game.cpp +++ b/examples/transparency/game.cpp @@ -2,33 +2,8 @@ #define BONSAI_DEBUG_SYSTEM_API 1 #include - -#include #include -BONSAI_API_WORKER_THREAD_CALLBACK() -{ - switch (Entry->Type) - { - InvalidCase(type_work_queue_entry_noop); - InvalidCase(type_work_queue_entry__align_to_cache_line_helper); - InvalidCase(type_work_queue_entry__bonsai_render_command); - - case type_work_queue_entry_async_function_call: - case type_work_queue_entry_update_world_region: - case type_work_queue_entry_rebuild_mesh: - case type_work_queue_entry_init_asset: - case type_work_queue_entry_init_world_chunk: - case type_work_queue_entry_copy_buffer_ref: - case type_work_queue_entry_copy_buffer_set: - case type_work_queue_entry_sim_particle_system: {} break; - } - - return False; -} - - - link_internal void SpawnSplosionEmitters(entity_block_array *Entities) { @@ -94,7 +69,7 @@ BONSAI_API_MAIN_THREAD_INIT_CALLBACK() StandardCamera(Graphics->Camera, 10000.0f, 1000.0f); - AllocateWorld(World, WorldCenter, WORLD_CHUNK_DIM, g_VisibleRegion); + AllocateWorld(World, WorldCenter, VisibleRegionSize_128); /* World->Flags = WorldFlag_WorldCenterFollowsCameraTarget; */ diff --git a/examples/transparency/game_constants.h b/examples/transparency/game_constants.h deleted file mode 100644 index ff8c73fa2..000000000 --- a/examples/transparency/game_constants.h +++ /dev/null @@ -1,15 +0,0 @@ - -#if 0 -global_variable chunk_dimension -g_VisibleRegion = Chunk_Dimension(32, 32, 8); - -global_variable chunk_dimension -WORLD_CHUNK_DIM = Chunk_Dimension(32, 32, 8); -#else -global_variable chunk_dimension -g_VisibleRegion = Chunk_Dimension(16, 16, 4); - -global_variable chunk_dimension -WORLD_CHUNK_DIM = Chunk_Dimension(32, 32, 32); - -#endif diff --git a/examples/transparency/remedy_repro.rdbg b/examples/transparency/remedy_repro.rdbg new file mode 100644 index 000000000..10b9ade07 Binary files /dev/null and b/examples/transparency/remedy_repro.rdbg differ diff --git a/examples/turn_based/game.cpp b/examples/turn_based/game.cpp index 0362252ea..1d1b514b0 100644 --- a/examples/turn_based/game.cpp +++ b/examples/turn_based/game.cpp @@ -1,8 +1,6 @@ #define BONSAI_DEBUG_SYSTEM_API 1 #include - -#include "game_constants.h" #include "game_types.h" global_variable v3 @@ -26,23 +24,23 @@ MoveToStandingSpot(world *World, canonical_position P) } link_weak void -EntityUserDataEditorUi(renderer_2d *Ui, window_layout *Window, u64 *UserType, u64 *UserData, cs Name, EDITOR_UI_FUNCTION_PROTO_ARGUMENTS) +EntityUserDataEditorUi(renderer_2d *Ui, window_layout *Window, u64 *UserType, u64 *UserData, cs Name, u32 ParentHash, EDITOR_UI_FUNCTION_PROTO_ARGUMENTS) { entity_aggregate_type *AType = UserTypeToAggregateTypePtr(UserType); - DoEditorUi(Ui, Window, AType, CSz("entity_aggregate_type UserType"), EDITOR_UI_FUNCTION_INSTANCE_NAMES); + DoEditorUi(Ui, Window, AType, CSz("entity_aggregate_type UserType"), ParentHash, EDITOR_UI_FUNCTION_INSTANCE_NAMES); switch (AType->Type) { case EntityType_Player: { entity_game_data *State = Cast(entity_game_data*, *UserData); - DoEditorUi(Ui, Window, State, CSz("entity_game_data UserData")); + DoEditorUi(Ui, Window, State, CSz("entity_game_data UserData"), 0); } break; case EntityType_Fireball: { fireball_state *State = Cast(fireball_state*, *UserData); - DoEditorUi(Ui, Window, State, CSz("fireball_state UserData")); + DoEditorUi(Ui, Window, State, CSz("fireball_state UserData"), 0); } break; case EntityType_Default: @@ -457,61 +455,11 @@ GameEntityUpdate(engine_resources *Engine, entity *Entity ) } -BONSAI_API_WORKER_THREAD_INIT_CALLBACK() -{ - Global_ThreadStates = AllThreads; - SetThreadLocal_ThreadIndex(ThreadIndex); -} - -BONSAI_API_WORKER_THREAD_CALLBACK() -{ - b32 Result = True; - switch (Entry->Type) - { - default: { Result = False; } break; - - // NOTE(Jesse): Here we're going to provide an implementation for - // initializing a world chunk. - case type_work_queue_entry_init_world_chunk: - { - volatile work_queue_entry_init_world_chunk *Job = SafeAccess(work_queue_entry_init_world_chunk, Entry); - world_chunk *Chunk = Job->Chunk; - - if (ChunkIsGarbage(Chunk)) - { - // NOTE(Jesse): This is an optimization; the engine marks chunks that - // have moved outside of the visible region as garbage. - Chunk->Flags = Chunk_Uninitialized; - } - else - { - s32 Period = 0; // Ignored - s32 Amplititude = 0; // Ignored - s32 StartingZDepth = -400; - u32 OctaveCount = 3; - - octave_buffer OctaveBuf = { OctaveCount, {} }; - OctaveBuf.Octaves = Allocate(octave, Thread->TempMemory, OctaveCount); - - - OctaveBuf.Octaves[0] = {V3(800, 800, 1700), 350, V3(1.f)}; - OctaveBuf.Octaves[1] = {V3(400, 400, 200), 350, V3(3.f)}; - OctaveBuf.Octaves[2] = {V3(35, 35, 25), 6, V3(2.f)}; - - /* OctaveBuf.Octaves[0] = {V3(1000, 1000, 700), 150, V3(1)}; */ - /* OctaveBuf.Octaves[1] = {V3(400, 400, 200), 150, V3(1,1,2)}; */ - /* /1* OctaveBuf.Octaves[2] = {V3(6, 6, 200), 150, V3(1,1,2)}; *1/ */ - - chunk_init_flags InitFlags = chunk_init_flags(ChunkInitFlag_ComputeStandingSpots|ChunkInitFlag_GenLODs); - /* chunk_init_flags InitFlags = chunk_init_flags(ChunkInitFlag_ComputeStandingSpots); */ - /* chunk_init_flags InitFlags = ChunkInitFlag_Noop; */ - InitializeChunkWithNoise( GrassyTerracedTerrain4, Thread, Chunk, Chunk->Dim, 0, V3(Period), Amplititude, StartingZDepth, HSV_GRASS_GREEN, MeshBit_Lod0, InitFlags, (void*)&OctaveBuf); - } - } - } - - return Result; -} +/* BONSAI_API_WORKER_THREAD_INIT_CALLBACK() */ +/* { */ +/* Global_ThreadStates = AllThreads; */ +/* SetThreadLocal_ThreadIndex(ThreadIndex); */ +/* } */ link_internal physics FireballPhysics() @@ -809,7 +757,8 @@ BONSAI_API_MAIN_THREAD_CALLBACK() } - b32 WorldEditMode = (Editor->EngineDebugViewModeToggleBits & (1<EngineDebugViewModeToggleBits & (1<TurnMode == TurnMode_Default && WorldEditMode == 0 ) { @@ -1196,9 +1145,9 @@ BONSAI_API_MAIN_THREAD_INIT_CALLBACK() StandardCamera(&Graphics->GameCamera, 10000.0f, 500.0f); - GameState->Entropy = {DEBUG_NOISE_SEED}; + GameState->Entropy = {53654734657}; - AllocateWorld(Resources->World, WorldCenter, WORLD_CHUNK_DIM, g_VisibleRegion); + AllocateWorld(Resources->World, WorldCenter, VisibleRegionSize_128); u32 PlayerModelIndex = ModelIndex_Player_old; GameState->PlayerId = GetFreeEntity(EntityTable); @@ -1215,7 +1164,7 @@ BONSAI_API_MAIN_THREAD_INIT_CALLBACK() Graphics->GameCamera.GhostId = Player->Id; u32 EnemyCount = 3; - v3i HalfVisibleRegion = g_VisibleRegion / 2; + v3i HalfVisibleRegion = V3i(VisibleRegionSize_128) / 2; HalfVisibleRegion.z = 0; for (u32 EnemyIndex = 0; EnemyIndex < EnemyCount; ++EnemyIndex) { diff --git a/examples/turn_based/game_constants.h b/examples/turn_based/game_constants.h deleted file mode 100644 index eeeb76a8b..000000000 --- a/examples/turn_based/game_constants.h +++ /dev/null @@ -1,35 +0,0 @@ - -#if 0 -global_variable chunk_dimension -g_VisibleRegion = Chunk_Dimension(32, 32, 8); - -global_variable chunk_dimension -WORLD_CHUNK_DIM = Chunk_Dimension(32, 32, 8); -#else - -/* global_variable chunk_dimension */ -/* g_VisibleRegion = Chunk_Dimension(8, 8, 8); */ - -global_variable chunk_dimension -g_VisibleRegion = Chunk_Dimension(12, 12, 8); - -/* global_variable chunk_dimension */ -/* g_VisibleRegion = Chunk_Dimension(24, 16, 6); */ - -/* global_variable chunk_dimension */ -/* g_VisibleRegion = Chunk_Dimension(20, 20, 6); */ - -/* global_variable chunk_dimension */ -/* g_VisibleRegion = Chunk_Dimension(24, 24, 8); */ - -/* global_variable chunk_dimension */ -/* g_VisibleRegion = Chunk_Dimension(32, 32, 8); */ - - -global_variable chunk_dimension -WORLD_CHUNK_DIM = Chunk_Dimension(32, 32, 32); - -/* global_variable chunk_dimension */ -/* WORLD_CHUNK_DIM = Chunk_Dimension(64, 64, 64); */ - -#endif diff --git a/examples/ui_test/game.cpp b/examples/ui_test/game.cpp new file mode 100644 index 000000000..4e6846d5b --- /dev/null +++ b/examples/ui_test/game.cpp @@ -0,0 +1,115 @@ +// NOTE(Jesse): This includes implementations for performace profiling and debug tracing +#define BONSAI_DEBUG_SYSTEM_API 1 + +#include + +#include + +BONSAI_API_MAIN_THREAD_INIT_CALLBACK() +{ + UNPACK_ENGINE_RESOURCES(Resources); + Global_AssetPrefixPath = CSz("examples/ui_test/assets"); + + world_position WorldCenter = {}; + canonical_position CameraTargetP = {}; + + StandardCamera(Graphics->Camera, 30000.0f, 1000.0f); + AllocateWorld(World, WorldCenter, VisibleRegionSize_128); + + GameState = Allocate(game_state, Resources->GameMemory, 1); + return GameState; +} + +enum test_enum +{ + TestEnum_Foo, + TestEnum_Bar, + TestEnum_Baz, +}; + +poof(string_and_value_tables(test_enum)) +#include +poof(do_editor_ui_for_enum(test_enum)) +#include + +enum radio_enum poof(@ui_display_radio) +{ + RadioEnum_Foo, + RadioEnum_Bar, + RadioEnum_Baz, +}; + +poof(string_and_value_tables(radio_enum)) +#include +poof(do_editor_ui_for_enum(radio_enum)) +#include + + +enum bitfield_enum poof(@bitfield) +{ + // Can put this in for testing the 0 path, or take it out to test the unset error path + /* BitfieldEnum_Unset = (0), */ + + BitfieldEnum_Foo = (1<<0), + BitfieldEnum_Bar = (1<<1), + BitfieldEnum_Baz = (1<<2), +}; + +poof(string_and_value_tables(bitfield_enum)) +#include +poof(do_editor_ui_for_enum(bitfield_enum)) +#include + + +struct nested_type +{ + s32 NestedFoo; + f32 NestedBar; + u32 Array[4]; +}; + +poof(do_editor_ui_for_compound_type(nested_type)) +#include + +struct test_type +{ + + u32 UnsignedNumber; + f32 FloatNumber; + s32 SignedNumber; + b32 Boolean; + + nested_type Nested; poof(@ui_display_name({})) + + test_enum BasicEnum; + bitfield_enum BitfieldEnum; + radio_enum RadioEnum; +}; + +poof(do_editor_ui_for_compound_type(test_type)) +#include + +BONSAI_API_MAIN_THREAD_CALLBACK() +{ + Assert(ThreadLocal_ThreadIndex == 0); + + TIMED_FUNCTION(); + UNPACK_ENGINE_RESOURCES(Resources); + + debug_global test_type Test = {}; + debug_global nested_type Nested = {}; + + window_layout *Window = GetOrCreateWindow(Ui, "Test Window"); + + PushWindowStart(Ui, Window); + DoEditorUi(Ui, Window, &Test, CSz("Test Thing"), 0); + + PushNewRow(Ui); + PushNewRow(Ui); + PushNewRow(Ui); + + DoEditorUi(Ui, Window, &Nested, CSz("Test Nested"), 0); + PushWindowEnd(Ui, Window); + + +} diff --git a/examples/ui_test/game_types.h b/examples/ui_test/game_types.h new file mode 100644 index 000000000..db1e8ec36 --- /dev/null +++ b/examples/ui_test/game_types.h @@ -0,0 +1,6 @@ + +// NOTE(Jesse): This is where you put data that's specific to your game +struct game_state +{ +}; + diff --git a/external/bonsai_debug b/external/bonsai_debug index 0468de9df..bd5e94daf 160000 --- a/external/bonsai_debug +++ b/external/bonsai_debug @@ -1 +1 @@ -Subproject commit 0468de9dffa78892c6777c0d36971c39f59cee59 +Subproject commit bd5e94daf42425ef132c7feb38454cd7f2ca32eb diff --git a/external/bonsai_stdlib b/external/bonsai_stdlib index 41ebc2a47..ba928090b 160000 --- a/external/bonsai_stdlib +++ b/external/bonsai_stdlib @@ -1 +1 @@ -Subproject commit 41ebc2a47c8a6d01ba4b6bb76a4fcf7f703280d2 +Subproject commit ba928090b272494cfad8746d8a15c7ca8d78dfcd diff --git a/generated/(builtin.for_datatypes)_RIx8WIj8.h b/generated/(builtin.for_datatypes)_RIx8WIj8.h new file mode 100644 index 000000000..ad295bdfb --- /dev/null +++ b/generated/(builtin.for_datatypes)_RIx8WIj8.h @@ -0,0 +1,715 @@ +// src/engine/editor.h:602:0 + + + + + +struct easing_function; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, easing_function *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; + +struct lighting_render_group; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, lighting_render_group *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; + + +struct render_debug; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, render_debug *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; + + + + + +struct ui_toggle; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, ui_toggle *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; + +struct bonsai_futex; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, bonsai_futex *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; +struct engine_settings; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, engine_settings *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; + + + + + + +struct texture; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, texture *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; +struct asset_thumbnail; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, asset_thumbnail *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; + +struct world_update_op_shape_params_cylinder; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, world_update_op_shape_params_cylinder *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; + + + + + + + + +struct vertex_material; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, vertex_material *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; +struct white_noise_params; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, white_noise_params *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; + + + + +struct world_update_op_shape_params_rect; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, world_update_op_shape_params_rect *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; +struct platform; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, platform *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; + +struct hotkeys; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, hotkeys *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; +struct shadow_render_group; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, shadow_render_group *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; + + + + + +struct particle_system; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, particle_system *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; + + + + + + + +struct voronoi_noise_params; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, voronoi_noise_params *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; + + + + + + + + + + + + + + + + + +struct terrain_decoration_render_context; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, terrain_decoration_render_context *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; + + + + + + + + + + + +struct terrain_finalize_render_context; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, terrain_finalize_render_context *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; + + + +struct ui_id; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, ui_id *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; + + + + + + + + + + + + +struct camera; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, camera *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; + + + + + + + + + +struct renderer_2d; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, renderer_2d *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; + + + + + + + + + +struct frustum; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, frustum *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; + + + +struct plane; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, plane *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; + + + + + + + + + +struct world_edit_render_context; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, world_edit_render_context *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; + + +struct shape_layer_advanced_params; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, shape_layer_advanced_params *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; + + + +struct world_update_op_shape_params_sphere; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, world_update_op_shape_params_sphere *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; + + + +struct graphics_settings; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, graphics_settings *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; + + + + +struct graphics; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, graphics *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; + +struct perlin_noise_params; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, perlin_noise_params *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; + + + + + + + + + + + + +struct physics; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, physics *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +struct world_edit; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, world_edit *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; + + + +struct particle; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, particle *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; + + + + + +struct easing_function_visualizer_render_pass; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, easing_function_visualizer_render_pass *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; + + + + + + + + +struct input_event; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, input_event *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; + + + + + + + + + +struct world_update_op_shape_params_plane; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, world_update_op_shape_params_plane *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; + + + + + + + + + + + + + + + + +struct selection_region; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, selection_region *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; + + + + + + + +struct shadow_map_shader; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, shadow_map_shader *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; +struct bloom_upsample_shader; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, bloom_upsample_shader *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; + + + + + + + +struct render_settings; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, render_settings *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; + + + + + + + + + + + + + + + + + + + +struct level_editor; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, level_editor *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; + + + + + + + + + + + + +struct brush_settings; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, brush_settings *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; + + + + + + +struct game_lights; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, game_lights *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; + + + + + + + + + + + + +struct octree_node_freelist; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, octree_node_freelist *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; + + + + + + + + +struct gen_chunk_freelist; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, gen_chunk_freelist *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; + + + + + + + +struct memory_arena; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, memory_arena *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; + + + + + +struct render_buffers_2d; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, render_buffers_2d *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; + + + + +struct input; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, input *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; + + + + + + + + + + +struct bonsai_stdlib; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, bonsai_stdlib *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; + + + + + + +struct chunk_thumbnail; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, chunk_thumbnail *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; + + + + + + + + + + + +struct keyframe; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, keyframe *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; + + + + + +struct world_update_op_shape_params_torus; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, world_update_op_shape_params_torus *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; + + +struct shader; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, shader *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; + + + + + + + + + + + + + + + + + +struct animation; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, animation *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; + + + + +struct shape_layer; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, shape_layer *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; + + +struct untextured_3d_geometry_buffer; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, untextured_3d_geometry_buffer *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; + + +struct work_queue; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, work_queue *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; +struct bloom_render_group; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, bloom_render_group *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; + + +struct terrain_derivs_render_context; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, terrain_derivs_render_context *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; + + + + + + + + + + + + + + + + +struct engine_debug; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, engine_debug *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; +struct bloom_downsample_shader; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, bloom_downsample_shader *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; + + + + + + + + + + + + +struct brush_layer; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, brush_layer *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; + + + + + + + + + + + + + + +struct random_series; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, random_series *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; + +struct engine_resources; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, engine_resources *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +struct g_buffer_render_group; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, g_buffer_render_group *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; + + + +struct terrain_shaping_render_context; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, terrain_shaping_render_context *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; + + + + + + + + + + + + + + + + + + + + + + + + + +struct v2_static_cursor_16; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, v2_static_cursor_16 *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; + + + +struct noise_layer; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, noise_layer *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; + + + + + + +struct lighting_settings; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, lighting_settings *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; + + + +struct ui_debug; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, ui_debug *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; + +struct world_chunk_freelist; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, world_chunk_freelist *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) +; + diff --git a/generated/anonymous_async_function_call_type_rQAZtEUA.h b/generated/anonymous_async_function_call_type_rQAZtEUA.h new file mode 100644 index 000000000..8a19ee945 --- /dev/null +++ b/generated/anonymous_async_function_call_type_rQAZtEUA.h @@ -0,0 +1,15 @@ +// src/engine/work_queue.h:293:0 +{ + tmatch( finalize_shit_and_fuckin_do_stuff_async_params, Task, Job ); + DoJob(Job); +} break; +{ + tmatch( initialize_easing_function_visualizer_render_pass_async_params, Task, Job ); + DoJob(Job); +} break; +{ + tmatch( compile_shader_pair_async_params, Task, Job ); + DoJob(Job); +} break; + + diff --git a/generated/anonymous_entity_position_info_ynGg9Dhj.h b/generated/anonymous_entity_position_info_ynGg9Dhj.h index dd4b6af7d..c25c3f14c 100644 --- a/generated/anonymous_entity_position_info_ynGg9Dhj.h +++ b/generated/anonymous_entity_position_info_ynGg9Dhj.h @@ -1,7 +1,7 @@ // src/engine/entity.h:217:0 - Entity->LastResolvedPosInfo.P = Entity->P; Entity->LastResolvedPosInfo._CollisionVolumeRadius = Entity->_CollisionVolumeRadius; Entity->LastResolvedPosInfo.Scale = Entity->Scale; Entity->LastResolvedPosInfo.EulerAngles = Entity->EulerAngles; + diff --git a/generated/anonymous_function_input_HLGbqwh0.h b/generated/anonymous_function_input_HLGbqwh0.h index 8e5bafb0d..3a6f4bc89 100644 --- a/generated/anonymous_function_input_HLGbqwh0.h +++ b/generated/anonymous_function_input_HLGbqwh0.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/input.h:162:0 - +// external/bonsai_stdlib/src/input.h:165:0 Input->Enter.Clicked = False; @@ -191,3 +190,4 @@ Input->MMB.Clicked = False; + diff --git a/generated/anonymous_function_ui_render_command_RuTTrHiW.h b/generated/anonymous_function_ui_render_command_RuTTrHiW.h index e317488fb..8d5b245a2 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:2311:0 +// external/bonsai_stdlib/src/ui/ui.cpp:2533:0 case type_ui_render_command_window_start: { @@ -6,24 +6,30 @@ case type_ui_render_command_window_start: Result.Min = Min(Result.Min, GetAbsoluteDrawBoundsMin(&Command->ui_render_command_window_start.Layout)); } break; + + + case type_ui_render_command_table_start: { Result.Max = Max(Result.Max, GetAbsoluteDrawBoundsMax(&Command->ui_render_command_table_start.Layout)); Result.Min = Min(Result.Min, GetAbsoluteDrawBoundsMin(&Command->ui_render_command_table_start.Layout)); } break; + case type_ui_render_command_column_start: { Result.Max = Max(Result.Max, GetAbsoluteDrawBoundsMax(&Command->ui_render_command_column_start.Layout)); Result.Min = Min(Result.Min, GetAbsoluteDrawBoundsMin(&Command->ui_render_command_column_start.Layout)); } break; + case type_ui_render_command_text: { Result.Max = Max(Result.Max, GetAbsoluteDrawBoundsMax(&Command->ui_render_command_text.Layout)); Result.Min = Min(Result.Min, GetAbsoluteDrawBoundsMin(&Command->ui_render_command_text.Layout)); } break; + case type_ui_render_command_textured_quad: { Result.Max = Max(Result.Max, GetAbsoluteDrawBoundsMax(&Command->ui_render_command_textured_quad.Layout)); @@ -42,3 +48,11 @@ case type_ui_render_command_untextured_quad_at: Result.Min = Min(Result.Min, GetAbsoluteDrawBoundsMin(&Command->ui_render_command_untextured_quad_at.Layout)); } break; + + + + + + + + diff --git a/generated/anonymous_input_5Nt8cwGP.h b/generated/anonymous_input_5Nt8cwGP.h index 8c01ef416..ce6cb33be 100644 --- a/generated/anonymous_input_5Nt8cwGP.h +++ b/generated/anonymous_input_5Nt8cwGP.h @@ -1,122 +1,126 @@ -// external/bonsai_stdlib/src/platform/win32/win32_platform.cpp:411:0 +// external/bonsai_stdlib/src/platform/win32/win32_platform.cpp:412:0 +BindKeyupToInput( VK_RETURN, Enter); -BindKeyupToInput(VK_RETURN, Enter); +BindKeyupToInput( VK_ESCAPE, Escape); -BindKeyupToInput(VK_ESCAPE, Escape); +BindKeyupToInput( VK_MENU, Alt); -BindKeyupToInput(VK_MENU, Alt); +BindKeyupToInput( VK_CONTROL, Ctrl); -BindKeyupToInput(VK_CONTROL, Ctrl); +BindKeyupToInput( VK_SHIFT, Shift); -BindKeyupToInput(VK_SHIFT, Shift); +BindKeyupToInput( VK_BACK, Backspace); -BindKeyupToInput(VK_BACK, Backspace); +BindKeyupToInput( VK_DELETE, Delete); -BindKeyupToInput(VK_DELETE, Delete); +BindKeyupToInput( VK_F12, F12); -BindKeyupToInput(VK_F12, F12); +BindKeyupToInput( VK_F11, F11); -BindKeyupToInput(VK_F11, F11); +BindKeyupToInput( VK_F10, F10); -BindKeyupToInput(VK_F10, F10); +BindKeyupToInput( VK_F9, F9); -BindKeyupToInput(VK_F9, F9); +BindKeyupToInput( VK_F8, F8); -BindKeyupToInput(VK_F8, F8); +BindKeyupToInput( VK_F7, F7); -BindKeyupToInput(VK_F7, F7); +BindKeyupToInput( VK_F6, F6); -BindKeyupToInput(VK_F6, F6); +BindKeyupToInput( VK_F5, F5); -BindKeyupToInput(VK_F5, F5); +BindKeyupToInput( VK_F4, F4); -BindKeyupToInput(VK_F4, F4); +BindKeyupToInput( VK_F3, F3); -BindKeyupToInput(VK_F3, F3); +BindKeyupToInput( VK_F2, F2); -BindKeyupToInput(VK_F2, F2); +BindKeyupToInput( VK_F1, F1); -BindKeyupToInput(VK_F1, F1); +BindKeyupToInput( VK_OEM_PERIOD, Dot); -BindKeyupToInput(VK_OEM_PERIOD, Dot); +BindKeyupToInput( VK_OEM_MINUS, Minus); -BindKeyupToInput(VK_OEM_MINUS, Minus); +BindKeyupToInput( VK_OEM_2, FSlash); -BindKeyupToInput(VK_OEM_2, FSlash); +BindKeyupToInput( VK_SPACE, Space); -BindKeyupToInput(VK_SPACE, Space); -BindKeyupToInput(0x30, N0); +BindKeyupToInput( 0x30, N0); -BindKeyupToInput(0x31, N1); +BindKeyupToInput( 0x31, N1); -BindKeyupToInput(0x32, N2); +BindKeyupToInput( 0x32, N2); -BindKeyupToInput(0x33, N3); +BindKeyupToInput( 0x33, N3); -BindKeyupToInput(0x34, N4); +BindKeyupToInput( 0x34, N4); -BindKeyupToInput(0x35, N5); +BindKeyupToInput( 0x35, N5); -BindKeyupToInput(0x36, N6); +BindKeyupToInput( 0x36, N6); -BindKeyupToInput(0x37, N7); +BindKeyupToInput( 0x37, N7); -BindKeyupToInput(0x38, N8); +BindKeyupToInput( 0x38, N8); -BindKeyupToInput(0x39, N9); +BindKeyupToInput( 0x39, N9); -BindKeyupToInput(0x41, A); +BindKeyupToInput( 0x41, A); -BindKeyupToInput(0x42, B); +BindKeyupToInput( 0x42, B); -BindKeyupToInput(0x43, C); +BindKeyupToInput( 0x43, C); -BindKeyupToInput(0x44, D); +BindKeyupToInput( 0x44, D); -BindKeyupToInput(0x45, E); +BindKeyupToInput( 0x45, E); -BindKeyupToInput(0x46, F); +BindKeyupToInput( 0x46, F); -BindKeyupToInput(0x47, G); +BindKeyupToInput( 0x47, G); -BindKeyupToInput(0x48, H); +BindKeyupToInput( 0x48, H); -BindKeyupToInput(0x49, I); +BindKeyupToInput( 0x49, I); -BindKeyupToInput(0x4A, J); +BindKeyupToInput( 0x4A, J); -BindKeyupToInput(0x4B, K); +BindKeyupToInput( 0x4B, K); -BindKeyupToInput(0x4C, L); +BindKeyupToInput( 0x4C, L); -BindKeyupToInput(0x4D, M); +BindKeyupToInput( 0x4D, M); -BindKeyupToInput(0x4E, N); +BindKeyupToInput( 0x4E, N); -BindKeyupToInput(0x4F, O); +BindKeyupToInput( 0x4F, O); -BindKeyupToInput(0x50, P); +BindKeyupToInput( 0x50, P); -BindKeyupToInput(0x51, Q); +BindKeyupToInput( 0x51, Q); -BindKeyupToInput(0x52, R); +BindKeyupToInput( 0x52, R); -BindKeyupToInput(0x53, S); +BindKeyupToInput( 0x53, S); -BindKeyupToInput(0x54, T); +BindKeyupToInput( 0x54, T); -BindKeyupToInput(0x55, U); +BindKeyupToInput( 0x55, U); -BindKeyupToInput(0x56, V); +BindKeyupToInput( 0x56, V); + +BindKeyupToInput( 0x57, W); + +BindKeyupToInput( 0x58, X); + +BindKeyupToInput( 0x59, Y); + +BindKeyupToInput( 0x5A, Z); -BindKeyupToInput(0x57, W); -BindKeyupToInput(0x58, X); -BindKeyupToInput(0x59, Y); -BindKeyupToInput(0x5A, Z); diff --git a/generated/anonymous_input_Lwen2qoF.h b/generated/anonymous_input_Lwen2qoF.h index 1fd4730c1..c1a97dd7b 100644 --- a/generated/anonymous_input_Lwen2qoF.h +++ b/generated/anonymous_input_Lwen2qoF.h @@ -1,4 +1,22 @@ -// external/bonsai_stdlib/src/ui/ui.cpp:3279:0 +// external/bonsai_stdlib/src/ui/ui.cpp:3665:0 + + + + + + + + + + + + + + + + + + if (Input->Dot.Clicked) { @@ -8,7 +26,7 @@ if (Input->Dot.Clicked) } else { - Cast(char*, Text.Start)[Text.Count] ='.'; + Cast(char*, Text.Start)[Text.Count] = '.'; } Text.Count++; } @@ -21,7 +39,7 @@ if (Input->Minus.Clicked) } else { - Cast(char*, Text.Start)[Text.Count] ='-'; + Cast(char*, Text.Start)[Text.Count] = '-'; } Text.Count++; } @@ -34,7 +52,7 @@ if (Input->FSlash.Clicked) } else { - Cast(char*, Text.Start)[Text.Count] ='/'; + Cast(char*, Text.Start)[Text.Count] = '/'; } Text.Count++; } @@ -47,7 +65,7 @@ if (Input->Space.Clicked) } else { - Cast(char*, Text.Start)[Text.Count] =' '; + Cast(char*, Text.Start)[Text.Count] = ' '; } Text.Count++; } @@ -60,7 +78,7 @@ if (Input->Underscore.Clicked) } else { - Cast(char*, Text.Start)[Text.Count] ='_'; + Cast(char*, Text.Start)[Text.Count] = '_'; } Text.Count++; } @@ -73,7 +91,7 @@ if (Input->N0.Clicked) } else { - Cast(char*, Text.Start)[Text.Count] ='0'; + Cast(char*, Text.Start)[Text.Count] = '0'; } Text.Count++; } @@ -86,7 +104,7 @@ if (Input->N1.Clicked) } else { - Cast(char*, Text.Start)[Text.Count] ='1'; + Cast(char*, Text.Start)[Text.Count] = '1'; } Text.Count++; } @@ -99,7 +117,7 @@ if (Input->N2.Clicked) } else { - Cast(char*, Text.Start)[Text.Count] ='2'; + Cast(char*, Text.Start)[Text.Count] = '2'; } Text.Count++; } @@ -112,7 +130,7 @@ if (Input->N3.Clicked) } else { - Cast(char*, Text.Start)[Text.Count] ='3'; + Cast(char*, Text.Start)[Text.Count] = '3'; } Text.Count++; } @@ -125,7 +143,7 @@ if (Input->N4.Clicked) } else { - Cast(char*, Text.Start)[Text.Count] ='4'; + Cast(char*, Text.Start)[Text.Count] = '4'; } Text.Count++; } @@ -138,7 +156,7 @@ if (Input->N5.Clicked) } else { - Cast(char*, Text.Start)[Text.Count] ='5'; + Cast(char*, Text.Start)[Text.Count] = '5'; } Text.Count++; } @@ -151,7 +169,7 @@ if (Input->N6.Clicked) } else { - Cast(char*, Text.Start)[Text.Count] ='6'; + Cast(char*, Text.Start)[Text.Count] = '6'; } Text.Count++; } @@ -164,7 +182,7 @@ if (Input->N7.Clicked) } else { - Cast(char*, Text.Start)[Text.Count] ='7'; + Cast(char*, Text.Start)[Text.Count] = '7'; } Text.Count++; } @@ -177,7 +195,7 @@ if (Input->N8.Clicked) } else { - Cast(char*, Text.Start)[Text.Count] ='8'; + Cast(char*, Text.Start)[Text.Count] = '8'; } Text.Count++; } @@ -190,7 +208,7 @@ if (Input->N9.Clicked) } else { - Cast(char*, Text.Start)[Text.Count] ='9'; + Cast(char*, Text.Start)[Text.Count] = '9'; } Text.Count++; } @@ -203,7 +221,7 @@ if (Input->A.Clicked) } else { - Cast(char*, Text.Start)[Text.Count] ='a'; + Cast(char*, Text.Start)[Text.Count] = 'a'; } Text.Count++; } @@ -216,7 +234,7 @@ if (Input->B.Clicked) } else { - Cast(char*, Text.Start)[Text.Count] ='b'; + Cast(char*, Text.Start)[Text.Count] = 'b'; } Text.Count++; } @@ -229,7 +247,7 @@ if (Input->C.Clicked) } else { - Cast(char*, Text.Start)[Text.Count] ='c'; + Cast(char*, Text.Start)[Text.Count] = 'c'; } Text.Count++; } @@ -242,7 +260,7 @@ if (Input->D.Clicked) } else { - Cast(char*, Text.Start)[Text.Count] ='d'; + Cast(char*, Text.Start)[Text.Count] = 'd'; } Text.Count++; } @@ -255,7 +273,7 @@ if (Input->E.Clicked) } else { - Cast(char*, Text.Start)[Text.Count] ='e'; + Cast(char*, Text.Start)[Text.Count] = 'e'; } Text.Count++; } @@ -268,7 +286,7 @@ if (Input->F.Clicked) } else { - Cast(char*, Text.Start)[Text.Count] ='f'; + Cast(char*, Text.Start)[Text.Count] = 'f'; } Text.Count++; } @@ -281,7 +299,7 @@ if (Input->G.Clicked) } else { - Cast(char*, Text.Start)[Text.Count] ='g'; + Cast(char*, Text.Start)[Text.Count] = 'g'; } Text.Count++; } @@ -294,7 +312,7 @@ if (Input->H.Clicked) } else { - Cast(char*, Text.Start)[Text.Count] ='h'; + Cast(char*, Text.Start)[Text.Count] = 'h'; } Text.Count++; } @@ -307,7 +325,7 @@ if (Input->I.Clicked) } else { - Cast(char*, Text.Start)[Text.Count] ='i'; + Cast(char*, Text.Start)[Text.Count] = 'i'; } Text.Count++; } @@ -320,7 +338,7 @@ if (Input->J.Clicked) } else { - Cast(char*, Text.Start)[Text.Count] ='j'; + Cast(char*, Text.Start)[Text.Count] = 'j'; } Text.Count++; } @@ -333,7 +351,7 @@ if (Input->K.Clicked) } else { - Cast(char*, Text.Start)[Text.Count] ='k'; + Cast(char*, Text.Start)[Text.Count] = 'k'; } Text.Count++; } @@ -346,7 +364,7 @@ if (Input->L.Clicked) } else { - Cast(char*, Text.Start)[Text.Count] ='l'; + Cast(char*, Text.Start)[Text.Count] = 'l'; } Text.Count++; } @@ -359,7 +377,7 @@ if (Input->M.Clicked) } else { - Cast(char*, Text.Start)[Text.Count] ='m'; + Cast(char*, Text.Start)[Text.Count] = 'm'; } Text.Count++; } @@ -372,7 +390,7 @@ if (Input->N.Clicked) } else { - Cast(char*, Text.Start)[Text.Count] ='n'; + Cast(char*, Text.Start)[Text.Count] = 'n'; } Text.Count++; } @@ -385,7 +403,7 @@ if (Input->O.Clicked) } else { - Cast(char*, Text.Start)[Text.Count] ='o'; + Cast(char*, Text.Start)[Text.Count] = 'o'; } Text.Count++; } @@ -398,7 +416,7 @@ if (Input->P.Clicked) } else { - Cast(char*, Text.Start)[Text.Count] ='p'; + Cast(char*, Text.Start)[Text.Count] = 'p'; } Text.Count++; } @@ -411,7 +429,7 @@ if (Input->Q.Clicked) } else { - Cast(char*, Text.Start)[Text.Count] ='q'; + Cast(char*, Text.Start)[Text.Count] = 'q'; } Text.Count++; } @@ -424,7 +442,7 @@ if (Input->R.Clicked) } else { - Cast(char*, Text.Start)[Text.Count] ='r'; + Cast(char*, Text.Start)[Text.Count] = 'r'; } Text.Count++; } @@ -437,7 +455,7 @@ if (Input->S.Clicked) } else { - Cast(char*, Text.Start)[Text.Count] ='s'; + Cast(char*, Text.Start)[Text.Count] = 's'; } Text.Count++; } @@ -450,7 +468,7 @@ if (Input->T.Clicked) } else { - Cast(char*, Text.Start)[Text.Count] ='t'; + Cast(char*, Text.Start)[Text.Count] = 't'; } Text.Count++; } @@ -463,7 +481,7 @@ if (Input->U.Clicked) } else { - Cast(char*, Text.Start)[Text.Count] ='u'; + Cast(char*, Text.Start)[Text.Count] = 'u'; } Text.Count++; } @@ -476,7 +494,7 @@ if (Input->V.Clicked) } else { - Cast(char*, Text.Start)[Text.Count] ='v'; + Cast(char*, Text.Start)[Text.Count] = 'v'; } Text.Count++; } @@ -489,7 +507,7 @@ if (Input->W.Clicked) } else { - Cast(char*, Text.Start)[Text.Count] ='w'; + Cast(char*, Text.Start)[Text.Count] = 'w'; } Text.Count++; } @@ -502,7 +520,7 @@ if (Input->X.Clicked) } else { - Cast(char*, Text.Start)[Text.Count] ='x'; + Cast(char*, Text.Start)[Text.Count] = 'x'; } Text.Count++; } @@ -515,7 +533,7 @@ if (Input->Y.Clicked) } else { - Cast(char*, Text.Start)[Text.Count] ='y'; + Cast(char*, Text.Start)[Text.Count] = 'y'; } Text.Count++; } @@ -528,10 +546,14 @@ if (Input->Z.Clicked) } else { - Cast(char*, Text.Start)[Text.Count] ='z'; + Cast(char*, Text.Start)[Text.Count] = 'z'; } Text.Count++; } + + + + diff --git a/generated/anonymous_input_nPw6miGy.h b/generated/anonymous_input_nPw6miGy.h index 70b7fef67..a264c418a 100644 --- a/generated/anonymous_input_nPw6miGy.h +++ b/generated/anonymous_input_nPw6miGy.h @@ -1,122 +1,126 @@ -// external/bonsai_stdlib/src/platform/win32/win32_platform.cpp:439:0 +// external/bonsai_stdlib/src/platform/win32/win32_platform.cpp:440:0 +BindKeydownToInput( VK_RETURN, Enter); -BindKeydownToInput(VK_RETURN, Enter); +BindKeydownToInput( VK_ESCAPE, Escape); -BindKeydownToInput(VK_ESCAPE, Escape); +BindKeydownToInput( VK_MENU, Alt); -BindKeydownToInput(VK_MENU, Alt); +BindKeydownToInput( VK_CONTROL, Ctrl); -BindKeydownToInput(VK_CONTROL, Ctrl); +BindKeydownToInput( VK_SHIFT, Shift); -BindKeydownToInput(VK_SHIFT, Shift); +BindKeydownToInput( VK_BACK, Backspace); -BindKeydownToInput(VK_BACK, Backspace); +BindKeydownToInput( VK_DELETE, Delete); -BindKeydownToInput(VK_DELETE, Delete); +BindKeydownToInput( VK_F12, F12); -BindKeydownToInput(VK_F12, F12); +BindKeydownToInput( VK_F11, F11); -BindKeydownToInput(VK_F11, F11); +BindKeydownToInput( VK_F10, F10); -BindKeydownToInput(VK_F10, F10); +BindKeydownToInput( VK_F9, F9); -BindKeydownToInput(VK_F9, F9); +BindKeydownToInput( VK_F8, F8); -BindKeydownToInput(VK_F8, F8); +BindKeydownToInput( VK_F7, F7); -BindKeydownToInput(VK_F7, F7); +BindKeydownToInput( VK_F6, F6); -BindKeydownToInput(VK_F6, F6); +BindKeydownToInput( VK_F5, F5); -BindKeydownToInput(VK_F5, F5); +BindKeydownToInput( VK_F4, F4); -BindKeydownToInput(VK_F4, F4); +BindKeydownToInput( VK_F3, F3); -BindKeydownToInput(VK_F3, F3); +BindKeydownToInput( VK_F2, F2); -BindKeydownToInput(VK_F2, F2); +BindKeydownToInput( VK_F1, F1); -BindKeydownToInput(VK_F1, F1); +BindKeydownToInput( VK_OEM_PERIOD, Dot); -BindKeydownToInput(VK_OEM_PERIOD, Dot); +BindKeydownToInput( VK_OEM_MINUS, Minus); -BindKeydownToInput(VK_OEM_MINUS, Minus); +BindKeydownToInput( VK_OEM_2, FSlash); -BindKeydownToInput(VK_OEM_2, FSlash); +BindKeydownToInput( VK_SPACE, Space); -BindKeydownToInput(VK_SPACE, Space); -BindKeydownToInput(0x30, N0); +BindKeydownToInput( 0x30, N0); -BindKeydownToInput(0x31, N1); +BindKeydownToInput( 0x31, N1); -BindKeydownToInput(0x32, N2); +BindKeydownToInput( 0x32, N2); -BindKeydownToInput(0x33, N3); +BindKeydownToInput( 0x33, N3); -BindKeydownToInput(0x34, N4); +BindKeydownToInput( 0x34, N4); -BindKeydownToInput(0x35, N5); +BindKeydownToInput( 0x35, N5); -BindKeydownToInput(0x36, N6); +BindKeydownToInput( 0x36, N6); -BindKeydownToInput(0x37, N7); +BindKeydownToInput( 0x37, N7); -BindKeydownToInput(0x38, N8); +BindKeydownToInput( 0x38, N8); -BindKeydownToInput(0x39, N9); +BindKeydownToInput( 0x39, N9); -BindKeydownToInput(0x41, A); +BindKeydownToInput( 0x41, A); -BindKeydownToInput(0x42, B); +BindKeydownToInput( 0x42, B); -BindKeydownToInput(0x43, C); +BindKeydownToInput( 0x43, C); -BindKeydownToInput(0x44, D); +BindKeydownToInput( 0x44, D); -BindKeydownToInput(0x45, E); +BindKeydownToInput( 0x45, E); -BindKeydownToInput(0x46, F); +BindKeydownToInput( 0x46, F); -BindKeydownToInput(0x47, G); +BindKeydownToInput( 0x47, G); -BindKeydownToInput(0x48, H); +BindKeydownToInput( 0x48, H); -BindKeydownToInput(0x49, I); +BindKeydownToInput( 0x49, I); -BindKeydownToInput(0x4A, J); +BindKeydownToInput( 0x4A, J); -BindKeydownToInput(0x4B, K); +BindKeydownToInput( 0x4B, K); -BindKeydownToInput(0x4C, L); +BindKeydownToInput( 0x4C, L); -BindKeydownToInput(0x4D, M); +BindKeydownToInput( 0x4D, M); -BindKeydownToInput(0x4E, N); +BindKeydownToInput( 0x4E, N); -BindKeydownToInput(0x4F, O); +BindKeydownToInput( 0x4F, O); -BindKeydownToInput(0x50, P); +BindKeydownToInput( 0x50, P); -BindKeydownToInput(0x51, Q); +BindKeydownToInput( 0x51, Q); -BindKeydownToInput(0x52, R); +BindKeydownToInput( 0x52, R); -BindKeydownToInput(0x53, S); +BindKeydownToInput( 0x53, S); -BindKeydownToInput(0x54, T); +BindKeydownToInput( 0x54, T); -BindKeydownToInput(0x55, U); +BindKeydownToInput( 0x55, U); -BindKeydownToInput(0x56, V); +BindKeydownToInput( 0x56, V); + +BindKeydownToInput( 0x57, W); + +BindKeydownToInput( 0x58, X); + +BindKeydownToInput( 0x59, Y); + +BindKeydownToInput( 0x5A, Z); -BindKeydownToInput(0x57, W); -BindKeydownToInput(0x58, X); -BindKeydownToInput(0x59, Y); -BindKeydownToInput(0x5A, Z); diff --git a/generated/anonymous_render_settings_0_wwLVyABc.h b/generated/anonymous_render_settings_0_wwLVyABc.h deleted file mode 100644 index eb4d94190..000000000 --- a/generated/anonymous_render_settings_0_wwLVyABc.h +++ /dev/null @@ -1,15 +0,0 @@ -// src/engine/serdes.cpp:414:0 - -E1->UseSsao = E0->UseSsao; -E1->UseShadowMapping = E0->UseShadowMapping; -E1->UseLightingBloom = E0->UseLightingBloom; -E1->BravoilMyersOIT = E0->BravoilMyersOIT; -E1->BravoilMcGuireOIT = E0->BravoilMcGuireOIT; -E1->DrawMajorGrid = E0->DrawMajorGrid; -E1->DrawMinorGrid = E0->DrawMinorGrid; -E1->MajorGridDim = E0->MajorGridDim; -E1->OffsetOfWorldCenterToGrid = E0->OffsetOfWorldCenterToGrid; -E1->Headless = E0->Headless; -E1->ToneMappingType = E0->ToneMappingType; -E1->Lighting = E0->Lighting; - diff --git a/generated/anonymous_ui_render_command_nKuoMe2B.h b/generated/anonymous_ui_render_command_nKuoMe2B.h index ac77fec0e..b811fa8f9 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:2264:0 +// external/bonsai_stdlib/src/ui/ui.cpp:2486:0 case type_ui_render_command_window_start: { @@ -6,24 +6,30 @@ case type_ui_render_command_window_start: Command->ui_render_command_window_start.Layout.DrawBounds = InvertedInfinityRectangle(); } break; + + + case type_ui_render_command_table_start: { Command->ui_render_command_table_start.Layout.At = {}; Command->ui_render_command_table_start.Layout.DrawBounds = InvertedInfinityRectangle(); } break; + case type_ui_render_command_column_start: { Command->ui_render_command_column_start.Layout.At = {}; Command->ui_render_command_column_start.Layout.DrawBounds = InvertedInfinityRectangle(); } break; + case type_ui_render_command_text: { Command->ui_render_command_text.Layout.At = {}; Command->ui_render_command_text.Layout.DrawBounds = InvertedInfinityRectangle(); } break; + case type_ui_render_command_textured_quad: { Command->ui_render_command_textured_quad.Layout.At = {}; @@ -42,3 +48,11 @@ case type_ui_render_command_untextured_quad_at: Command->ui_render_command_untextured_quad_at.Layout.DrawBounds = InvertedInfinityRectangle(); } break; + + + + + + + + diff --git a/generated/are_equal_bonsai_type_info.h b/generated/are_equal_bonsai_type_info.h index 098253ffc..e40b6b677 100644 --- a/generated/are_equal_bonsai_type_info.h +++ b/generated/are_equal_bonsai_type_info.h @@ -1,16 +1,17 @@ -// src/engine/bonsai_type_info.h:24:0 - +// external/bonsai_stdlib/src/poof_functions.h:626:0 link_internal b32 AreEqual(bonsai_type_info *Thing1, bonsai_type_info *Thing2) { if (Thing1 && Thing2) { - b32 Result = True; - Result &= AreEqual(Thing1->Name, Thing2->Name); + b32 Result = True; + Result &= AreEqual(Thing1->Name, Thing2->Name); + + Result &= AreEqual(Thing1->Version, Thing2->Version); + + Result &= AreEqual(Thing1->SizeOfInBytes, Thing2->SizeOfInBytes); - Result &= AreEqual(Thing1->Version, Thing2->Version); - Result &= AreEqual(Thing1->SizeOfInBytes, Thing2->SizeOfInBytes); return Result; } @@ -23,12 +24,14 @@ AreEqual(bonsai_type_info *Thing1, bonsai_type_info *Thing2) link_internal b32 AreEqual(bonsai_type_info Thing1, bonsai_type_info Thing2) { - b32 Result = True; - Result &= AreEqual(Thing1.Name, Thing2.Name); + b32 Result = True; + Result &= AreEqual(Thing1.Name, Thing2.Name); + + Result &= AreEqual(Thing1.Version, Thing2.Version); + + Result &= AreEqual(Thing1.SizeOfInBytes, Thing2.SizeOfInBytes); - Result &= AreEqual(Thing1.Version, Thing2.Version); - Result &= AreEqual(Thing1.SizeOfInBytes, Thing2.SizeOfInBytes); return Result; } diff --git a/generated/are_equal_debug_profile_scope.h b/generated/are_equal_debug_profile_scope.h index cf4e1985e..b5cfd24e1 100644 --- a/generated/are_equal_debug_profile_scope.h +++ b/generated/are_equal_debug_profile_scope.h @@ -1,11 +1,10 @@ -// external/bonsai_debug/src/api.h:115:0 - +// external/bonsai_stdlib/src/poof_functions.h:626:0 link_internal b32 AreEqual(debug_profile_scope *Thing1, debug_profile_scope *Thing2) { if (Thing1 && Thing2) { - b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( debug_profile_scope ) ); + b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( debug_profile_scope ) ); return Result; } @@ -18,7 +17,7 @@ AreEqual(debug_profile_scope *Thing1, debug_profile_scope *Thing2) link_internal b32 AreEqual(debug_profile_scope Thing1, debug_profile_scope Thing2) { - b32 Result = MemoryIsEqual((u8*)&Thing1, (u8*)&Thing2, sizeof( debug_profile_scope ) ); + b32 Result = MemoryIsEqual((u8*)&Thing1, (u8*)&Thing2, sizeof( debug_profile_scope ) ); return Result; } diff --git a/generated/are_equal_file_traversal_node.h b/generated/are_equal_file_traversal_node.h index 638c9ad59..63428edd0 100644 --- a/generated/are_equal_file_traversal_node.h +++ b/generated/are_equal_file_traversal_node.h @@ -1,16 +1,17 @@ -// external/bonsai_stdlib/src/file.h:57:0 - +// external/bonsai_stdlib/src/poof_functions.h:626:0 link_internal b32 AreEqual(file_traversal_node *Thing1, file_traversal_node *Thing2) { if (Thing1 && Thing2) { - b32 Result = True; - Result &= AreEqual(Thing1->Type, Thing2->Type); + b32 Result = True; + Result &= AreEqual(Thing1->Type, Thing2->Type); + + Result &= AreEqual(Thing1->Dir, Thing2->Dir); + + Result &= AreEqual(Thing1->Name, Thing2->Name); - Result &= AreEqual(Thing1->Dir, Thing2->Dir); - Result &= AreEqual(Thing1->Name, Thing2->Name); return Result; } @@ -23,12 +24,14 @@ AreEqual(file_traversal_node *Thing1, file_traversal_node *Thing2) link_internal b32 AreEqual(file_traversal_node Thing1, file_traversal_node Thing2) { - b32 Result = True; - Result &= AreEqual(Thing1.Type, Thing2.Type); + b32 Result = True; + Result &= AreEqual(Thing1.Type, Thing2.Type); + + Result &= AreEqual(Thing1.Dir, Thing2.Dir); + + Result &= AreEqual(Thing1.Name, Thing2.Name); - Result &= AreEqual(Thing1.Dir, Thing2.Dir); - Result &= AreEqual(Thing1.Name, Thing2.Name); return Result; } diff --git a/generated/are_equal_memory_arena_stats.h b/generated/are_equal_memory_arena_stats.h index 76556089a..02d9b0f70 100644 --- a/generated/are_equal_memory_arena_stats.h +++ b/generated/are_equal_memory_arena_stats.h @@ -1,11 +1,10 @@ -// external/bonsai_debug/debug.h:76:0 - +// external/bonsai_stdlib/src/poof_functions.h:626:0 link_internal b32 AreEqual(memory_arena_stats *Thing1, memory_arena_stats *Thing2) { if (Thing1 && Thing2) { - b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( memory_arena_stats ) ); + b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( memory_arena_stats ) ); return Result; } @@ -18,7 +17,7 @@ AreEqual(memory_arena_stats *Thing1, memory_arena_stats *Thing2) link_internal b32 AreEqual(memory_arena_stats Thing1, memory_arena_stats Thing2) { - b32 Result = MemoryIsEqual((u8*)&Thing1, (u8*)&Thing2, sizeof( memory_arena_stats ) ); + b32 Result = MemoryIsEqual((u8*)&Thing1, (u8*)&Thing2, sizeof( memory_arena_stats ) ); return Result; } diff --git a/generated/are_equal_octree_node.h b/generated/are_equal_octree_node.h new file mode 100644 index 000000000..bda190fa5 --- /dev/null +++ b/generated/are_equal_octree_node.h @@ -0,0 +1,24 @@ +// external/bonsai_stdlib/src/poof_functions.h:626:0 +link_internal b32 +AreEqual(octree_node *Thing1, octree_node *Thing2) +{ + if (Thing1 && Thing2) + { + b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( octree_node ) ); + + return Result; + } + else + { + return (Thing1 == Thing2); + } +} + +link_internal b32 +AreEqual(octree_node Thing1, octree_node Thing2) +{ + b32 Result = MemoryIsEqual((u8*)&Thing1, (u8*)&Thing2, sizeof( octree_node ) ); + + return Result; +} + diff --git a/generated/are_equal_perlin_noise_params.h b/generated/are_equal_perlin_noise_params.h index 08090b018..e5bab41c2 100644 --- a/generated/are_equal_perlin_noise_params.h +++ b/generated/are_equal_perlin_noise_params.h @@ -1,11 +1,10 @@ -// src/engine/editor.h:657:0 - +// external/bonsai_stdlib/src/poof_functions.h:626:0 link_internal b32 AreEqual(perlin_noise_params *Thing1, perlin_noise_params *Thing2) { if (Thing1 && Thing2) { - b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( perlin_noise_params ) ); + b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( perlin_noise_params ) ); return Result; } @@ -18,7 +17,7 @@ AreEqual(perlin_noise_params *Thing1, perlin_noise_params *Thing2) link_internal b32 AreEqual(perlin_noise_params Thing1, perlin_noise_params Thing2) { - b32 Result = MemoryIsEqual((u8*)&Thing1, (u8*)&Thing2, sizeof( perlin_noise_params ) ); + b32 Result = MemoryIsEqual((u8*)&Thing1, (u8*)&Thing2, sizeof( perlin_noise_params ) ); return Result; } diff --git a/generated/are_equal_rect3cp.h b/generated/are_equal_rect3cp.h index 352897f98..92d80d293 100644 --- a/generated/are_equal_rect3cp.h +++ b/generated/are_equal_rect3cp.h @@ -1,11 +1,10 @@ -// src/engine/canonical_position.h:239:0 - +// external/bonsai_stdlib/src/poof_functions.h:626:0 link_internal b32 AreEqual(rect3cp *Thing1, rect3cp *Thing2) { if (Thing1 && Thing2) { - b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( rect3cp ) ); + b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( rect3cp ) ); return Result; } @@ -18,7 +17,7 @@ AreEqual(rect3cp *Thing1, rect3cp *Thing2) link_internal b32 AreEqual(rect3cp Thing1, rect3cp Thing2) { - b32 Result = MemoryIsEqual((u8*)&Thing1, (u8*)&Thing2, sizeof( rect3cp ) ); + b32 Result = MemoryIsEqual((u8*)&Thing1, (u8*)&Thing2, sizeof( rect3cp ) ); return Result; } diff --git a/generated/are_equal_render_settings.h b/generated/are_equal_render_settings.h new file mode 100644 index 000000000..578e734e5 --- /dev/null +++ b/generated/are_equal_render_settings.h @@ -0,0 +1,24 @@ +// external/bonsai_stdlib/src/poof_functions.h:626:0 +link_internal b32 +AreEqual(render_settings *Thing1, render_settings *Thing2) +{ + if (Thing1 && Thing2) + { + b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( render_settings ) ); + + return Result; + } + else + { + return (Thing1 == Thing2); + } +} + +link_internal b32 +AreEqual(render_settings Thing1, render_settings Thing2) +{ + b32 Result = MemoryIsEqual((u8*)&Thing1, (u8*)&Thing2, sizeof( render_settings ) ); + + return Result; +} + diff --git a/generated/are_equal_brush_settings.h b/generated/are_equal_struct.h similarity index 54% rename from generated/are_equal_brush_settings.h rename to generated/are_equal_struct.h index 31e0b12f3..ceea8c08a 100644 --- a/generated/are_equal_brush_settings.h +++ b/generated/are_equal_struct.h @@ -1,11 +1,10 @@ -// src/engine/editor.h:912:0 - +// external/bonsai_stdlib/src/poof_functions.h:626:0 link_internal b32 AreEqual(brush_settings *Thing1, brush_settings *Thing2) { if (Thing1 && Thing2) { - b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( brush_settings ) ); + b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( brush_settings ) ); return Result; } @@ -18,7 +17,7 @@ AreEqual(brush_settings *Thing1, brush_settings *Thing2) link_internal b32 AreEqual(brush_settings Thing1, brush_settings Thing2) { - b32 Result = MemoryIsEqual((u8*)&Thing1, (u8*)&Thing2, sizeof( brush_settings ) ); + b32 Result = MemoryIsEqual((u8*)&Thing1, (u8*)&Thing2, sizeof( brush_settings ) ); return Result; } diff --git a/generated/are_equal_texture.h b/generated/are_equal_texture.h index 1206bafbc..4473975db 100644 --- a/generated/are_equal_texture.h +++ b/generated/are_equal_texture.h @@ -1,26 +1,27 @@ -// external/bonsai_stdlib/src/texture_cursor.cpp:1:0 - +// external/bonsai_stdlib/src/poof_functions.h:626:0 link_internal b32 AreEqual(texture *Thing1, texture *Thing2) { if (Thing1 && Thing2) { - b32 Result = True; - Result &= AreEqual(Thing1->ID, Thing2->ID); + b32 Result = True; + Result &= AreEqual(Thing1->ID, Thing2->ID); + + Result &= AreEqual(Thing1->Dim, Thing2->Dim); + + Result &= AreEqual(Thing1->Slices, Thing2->Slices); - Result &= AreEqual(Thing1->Dim, Thing2->Dim); + Result &= AreEqual(Thing1->Channels, Thing2->Channels); - Result &= AreEqual(Thing1->Slices, Thing2->Slices); + Result &= AreEqual(Thing1->IsDepthTexture, Thing2->IsDepthTexture); - Result &= AreEqual(Thing1->Channels, Thing2->Channels); + Result &= AreEqual(Thing1->Format, Thing2->Format); - Result &= AreEqual(Thing1->IsDepthTexture, Thing2->IsDepthTexture); + Result &= AreEqual(Thing1->DebugName, Thing2->DebugName); - Result &= AreEqual(Thing1->Format, Thing2->Format); + Result &= AreEqual(Thing1->Queued, Thing2->Queued); - Result &= AreEqual(Thing1->DebugName, Thing2->DebugName); - Result &= AreEqual(Thing1->Queued, Thing2->Queued); return Result; } @@ -33,22 +34,24 @@ AreEqual(texture *Thing1, texture *Thing2) link_internal b32 AreEqual(texture Thing1, texture Thing2) { - b32 Result = True; - Result &= AreEqual(Thing1.ID, Thing2.ID); + b32 Result = True; + Result &= AreEqual(Thing1.ID, Thing2.ID); + + Result &= AreEqual(Thing1.Dim, Thing2.Dim); + + Result &= AreEqual(Thing1.Slices, Thing2.Slices); - Result &= AreEqual(Thing1.Dim, Thing2.Dim); + Result &= AreEqual(Thing1.Channels, Thing2.Channels); - Result &= AreEqual(Thing1.Slices, Thing2.Slices); + Result &= AreEqual(Thing1.IsDepthTexture, Thing2.IsDepthTexture); - Result &= AreEqual(Thing1.Channels, Thing2.Channels); + Result &= AreEqual(Thing1.Format, Thing2.Format); - Result &= AreEqual(Thing1.IsDepthTexture, Thing2.IsDepthTexture); + Result &= AreEqual(Thing1.DebugName, Thing2.DebugName); - Result &= AreEqual(Thing1.Format, Thing2.Format); + Result &= AreEqual(Thing1.Queued, Thing2.Queued); - Result &= AreEqual(Thing1.DebugName, Thing2.DebugName); - Result &= AreEqual(Thing1.Queued, Thing2.Queued); return Result; } diff --git a/generated/are_equal_ui_toggle.h b/generated/are_equal_ui_toggle.h index 8bc906cdc..ed9d34054 100644 --- a/generated/are_equal_ui_toggle.h +++ b/generated/are_equal_ui_toggle.h @@ -1,11 +1,10 @@ -// external/bonsai_stdlib/src/ui/ui.h:144:0 - +// external/bonsai_stdlib/src/poof_functions.h:626:0 link_internal b32 AreEqual(ui_toggle *Thing1, ui_toggle *Thing2) { if (Thing1 && Thing2) { - b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( ui_toggle ) ); + b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( ui_toggle ) ); return Result; } @@ -18,7 +17,7 @@ AreEqual(ui_toggle *Thing1, ui_toggle *Thing2) link_internal b32 AreEqual(ui_toggle Thing1, ui_toggle Thing2) { - b32 Result = MemoryIsEqual((u8*)&Thing1, (u8*)&Thing2, sizeof( ui_toggle ) ); + b32 Result = MemoryIsEqual((u8*)&Thing1, (u8*)&Thing2, sizeof( ui_toggle ) ); return Result; } diff --git a/generated/are_equal_voxel_synthesis_change_propagation_info.h b/generated/are_equal_voxel_synthesis_change_propagation_info.h index f00ef89c5..49f9f8eb5 100644 --- a/generated/are_equal_voxel_synthesis_change_propagation_info.h +++ b/generated/are_equal_voxel_synthesis_change_propagation_info.h @@ -1,11 +1,10 @@ -// src/engine/voxel_synthesis.h:307:0 - +// external/bonsai_stdlib/src/poof_functions.h:626:0 link_internal b32 AreEqual(voxel_synthesis_change_propagation_info *Thing1, voxel_synthesis_change_propagation_info *Thing2) { if (Thing1 && Thing2) { - b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( voxel_synthesis_change_propagation_info ) ); + b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( voxel_synthesis_change_propagation_info ) ); return Result; } @@ -18,7 +17,7 @@ AreEqual(voxel_synthesis_change_propagation_info *Thing1, voxel_synthesis_change 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 ) ); + b32 Result = MemoryIsEqual((u8*)&Thing1, (u8*)&Thing2, sizeof( voxel_synthesis_change_propagation_info ) ); return Result; } diff --git a/generated/are_equal_window_layout.h b/generated/are_equal_window_layout.h deleted file mode 100644 index 5c8aad984..000000000 --- a/generated/are_equal_window_layout.h +++ /dev/null @@ -1,95 +0,0 @@ -// external/bonsai_stdlib/src/ui/ui.h:124: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_world_edit_brush.h b/generated/are_equal_world_edit_brush.h new file mode 100644 index 000000000..6db62aae7 --- /dev/null +++ b/generated/are_equal_world_edit_brush.h @@ -0,0 +1,24 @@ +// external/bonsai_stdlib/src/poof_functions.h:626:0 +link_internal b32 +AreEqual(world_edit_brush *Thing1, world_edit_brush *Thing2) +{ + if (Thing1 && Thing2) + { + b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( world_edit_brush ) ); + + return Result; + } + else + { + return (Thing1 == Thing2); + } +} + +link_internal b32 +AreEqual(world_edit_brush Thing1, world_edit_brush Thing2) +{ + b32 Result = MemoryIsEqual((u8*)&Thing1, (u8*)&Thing2, sizeof( world_edit_brush ) ); + + return Result; +} + diff --git a/generated/are_equal_xml_property.h b/generated/are_equal_xml_property.h index f003bb9db..c2611b3b8 100644 --- a/generated/are_equal_xml_property.h +++ b/generated/are_equal_xml_property.h @@ -1,11 +1,10 @@ -// external/bonsai_stdlib/src/xml.cpp:4:0 - +// external/bonsai_stdlib/src/poof_functions.h:626:0 link_internal b32 AreEqual(xml_property *Thing1, xml_property *Thing2) { if (Thing1 && Thing2) { - b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( xml_property ) ); + b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( xml_property ) ); return Result; } @@ -18,7 +17,7 @@ AreEqual(xml_property *Thing1, xml_property *Thing2) link_internal b32 AreEqual(xml_property Thing1, xml_property Thing2) { - b32 Result = MemoryIsEqual((u8*)&Thing1, (u8*)&Thing2, sizeof( xml_property ) ); + b32 Result = MemoryIsEqual((u8*)&Thing1, (u8*)&Thing2, sizeof( xml_property ) ); return Result; } diff --git a/generated/are_equal_xml_tag.h b/generated/are_equal_xml_tag.h index 3fafca1fe..269153283 100644 --- a/generated/are_equal_xml_tag.h +++ b/generated/are_equal_xml_tag.h @@ -1,11 +1,10 @@ -// external/bonsai_stdlib/src/xml.cpp:7:0 - +// external/bonsai_stdlib/src/poof_functions.h:626:0 link_internal b32 AreEqual(xml_tag *Thing1, xml_tag *Thing2) { if (Thing1 && Thing2) { - b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( xml_tag ) ); + b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( xml_tag ) ); return Result; } @@ -18,7 +17,7 @@ AreEqual(xml_tag *Thing1, xml_tag *Thing2) link_internal b32 AreEqual(xml_tag Thing1, xml_tag Thing2) { - b32 Result = MemoryIsEqual((u8*)&Thing1, (u8*)&Thing2, sizeof( xml_tag ) ); + b32 Result = MemoryIsEqual((u8*)&Thing1, (u8*)&Thing2, sizeof( xml_tag ) ); return Result; } diff --git a/generated/are_equal_xml_token.h b/generated/are_equal_xml_token.h index 95f83c833..0e9762877 100644 --- a/generated/are_equal_xml_token.h +++ b/generated/are_equal_xml_token.h @@ -1,11 +1,10 @@ -// external/bonsai_stdlib/src/xml.cpp:1:0 - +// external/bonsai_stdlib/src/poof_functions.h:626:0 link_internal b32 AreEqual(xml_token *Thing1, xml_token *Thing2) { if (Thing1 && Thing2) { - b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( xml_token ) ); + b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( xml_token ) ); return Result; } @@ -18,7 +17,7 @@ AreEqual(xml_token *Thing1, xml_token *Thing2) link_internal b32 AreEqual(xml_token Thing1, xml_token Thing2) { - b32 Result = MemoryIsEqual((u8*)&Thing1, (u8*)&Thing2, sizeof( xml_token ) ); + b32 Result = MemoryIsEqual((u8*)&Thing1, (u8*)&Thing2, sizeof( xml_token ) ); return Result; } diff --git a/generated/asyncify_render_function_c_DrawLod.h b/generated/asyncify_render_function_c_DrawLod.h deleted file mode 100644 index 43edcbabb..000000000 --- a/generated/asyncify_render_function_c_DrawLod.h +++ /dev/null @@ -1,20 +0,0 @@ -// src/engine/work_queue.h:363: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 ) -{ - draw_lod_async_params Params = - { - Engine, Shader, Meshes, DistanceSquared, Basis, Rotation, Scale, - }; - - work_queue_entry Entry = WorkQueueEntryAsyncFunction(&Params); - PushWorkQueueEntry(Queue, &Entry); -} - -link_internal void -DoJob(draw_lod_async_params *Params) -{ - DrawLod( Params->Engine , Params->Shader , Params->Meshes , Params->DistanceSquared , Params->Basis , Params->Rotation , Params->Scale ); -} - diff --git a/generated/asyncify_render_function_c_RenderToTexture.h b/generated/asyncify_render_function_c_RenderToTexture.h deleted file mode 100644 index 76f870909..000000000 --- a/generated/asyncify_render_function_c_RenderToTexture.h +++ /dev/null @@ -1,20 +0,0 @@ -// src/engine/work_queue.h:360:0 - -link_internal void -RenderToTexture_Async(work_queue *Queue,engine_resources *Engine ,asset_thumbnail *Thumb ,lod_element_buffer *Meshes ,v3 Offset ,camera *Camera ) -{ - render_to_texture_async_params Params = - { - Engine, Thumb, Meshes, Offset, Camera, - }; - - work_queue_entry Entry = WorkQueueEntryAsyncFunction(&Params); - PushWorkQueueEntry(Queue, &Entry); -} - -link_internal void -DoJob(render_to_texture_async_params *Params) -{ - RenderToTexture( 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 deleted file mode 100644 index 15ffc9807..000000000 --- a/generated/asyncify_render_function_h_DrawLod.h +++ /dev/null @@ -1,13 +0,0 @@ -// src/engine/work_queue.h:240:0 - -struct draw_lod_async_params poof(@async_function_params) -{ -engine_resources *Engine; -shader *Shader; -lod_element_buffer *Meshes; -r32 DistanceSquared; -v3 Basis; -Quaternion Rotation; -v3 Scale; -}; - diff --git a/generated/asyncify_render_function_h_RenderToTexture.h b/generated/asyncify_render_function_h_RenderToTexture.h deleted file mode 100644 index ea65b2322..000000000 --- a/generated/asyncify_render_function_h_RenderToTexture.h +++ /dev/null @@ -1,11 +0,0 @@ -// src/engine/work_queue.h:237:0 - -struct render_to_texture_async_params poof(@async_function_params) -{ -engine_resources *Engine; -asset_thumbnail *Thumb; -lod_element_buffer *Meshes; -v3 Offset; -camera *Camera; -}; - diff --git a/generated/block_array_bitmap_688853862.h b/generated/block_array_bitmap_688853862.h index b931be9e8..345a4c611 100644 --- a/generated/block_array_bitmap_688853862.h +++ b/generated/block_array_bitmap_688853862.h @@ -1,240 +1,363 @@ -// external/bonsai_stdlib/src/bitmap.cpp:182:0 +// external/bonsai_stdlib/src/poof_functions.h:2600:0 + + + struct bitmap_block { - u32 Index; - u32 At; - bitmap *Elements; - bitmap_block *Next; + /* u32 Index; */ + umm At; + bitmap Elements[8]; }; struct bitmap_block_array_index { - bitmap_block *Block; - u32 BlockIndex; - u32 ElementIndex; + umm Index; }; struct bitmap_block_array { - bitmap_block *First; - bitmap_block *Current; + bitmap_block **BlockPtrs; poof(@array_length(Element->BlockCount)) + u32 BlockCount; + u32 ElementCount; memory_arena *Memory; poof(@no_serialize) }; -typedef bitmap_block_array bitmap_paged_list; +link_internal bitmap_block_array +BitmapBlockArray(memory_arena *Memory) +{ + bitmap_block_array Result = {}; + Result.Memory = Memory; + return Result; +} -link_internal bitmap_block_array_index -operator++(bitmap_block_array_index &I0) +link_internal b32 +AreEqual(bitmap_block_array_index *Thing1, bitmap_block_array_index *Thing2) { - if (I0.Block) + if (Thing1 && Thing2) { - if (I0.ElementIndex == 8-1) - { - I0.ElementIndex = 0; - I0.BlockIndex++; - I0.Block = I0.Block->Next; - } - else - { - I0.ElementIndex++; - } + b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( bitmap_block_array_index ) ); + + return Result; } else { - I0.ElementIndex++; + return (Thing1 == Thing2); } +} + +link_internal b32 +AreEqual(bitmap_block_array_index Thing1, bitmap_block_array_index Thing2) +{ + b32 Result = MemoryIsEqual((u8*)&Thing1, (u8*)&Thing2, sizeof( bitmap_block_array_index ) ); + + return Result; +} + + +typedef bitmap_block_array bitmap_paged_list; + +link_internal bitmap_block_array_index +operator++( bitmap_block_array_index &I0 ) +{ + I0.Index++; return I0; } link_internal b32 -operator<(bitmap_block_array_index I0, bitmap_block_array_index I1) +operator<( bitmap_block_array_index I0, bitmap_block_array_index I1 ) { - b32 Result = I0.BlockIndex < I1.BlockIndex || (I0.BlockIndex == I1.BlockIndex & I0.ElementIndex < I1.ElementIndex); + b32 Result = I0.Index < I1.Index; + return Result; +} + +link_internal b32 +operator==( bitmap_block_array_index I0, bitmap_block_array_index I1 ) +{ + b32 Result = I0.Index == I1.Index; return Result; } link_inline umm -GetIndex(bitmap_block_array_index *Index) +GetIndex( bitmap_block_array_index *Index) { - umm Result = Index->ElementIndex + (Index->BlockIndex*8); + umm Result = Index->Index; return Result; } + link_internal bitmap_block_array_index -ZerothIndex(bitmap_block_array *Arr) +ZerothIndex( bitmap_block_array *Arr ) { - bitmap_block_array_index Result = {}; - Result.Block = Arr->First; - /* Assert(Result.Block->Index == 0); */ - return Result; + return {}; } -link_internal umm -TotalElements(bitmap_block_array *Arr) +link_internal bitmap_block_array_index +Capacity( bitmap_block_array *Arr ) { - umm Result = 0; - if (Arr->Current) - { - Result = (Arr->Current->Index * 8) + Arr->Current->At; - } + bitmap_block_array_index Result = {Arr->BlockCount * 8}; return Result; } link_internal bitmap_block_array_index -LastIndex(bitmap_block_array *Arr) +AtElements( bitmap_block_array *Arr ) { - bitmap_block_array_index Result = {}; - if (Arr->Current) - { - Result.Block = Arr->Current; - Result.BlockIndex = Arr->Current->Index; - Result.ElementIndex = Arr->Current->At; - Assert(Result.ElementIndex); - Result.ElementIndex--; - } + bitmap_block_array_index Result = {Arr->ElementCount}; return Result; } + +link_internal umm +TotalElements( bitmap_block_array *Arr ) +{ + umm Result = AtElements(Arr).Index; + return Result; +} + + link_internal bitmap_block_array_index -AtElements(bitmap_block_array *Arr) +LastIndex( bitmap_block_array *Arr ) { bitmap_block_array_index Result = {}; - if (Arr->Current) - { - Result.Block = Arr->Current; - Result.BlockIndex = Arr->Current->Index; - Result.ElementIndex = Arr->Current->At; - } + umm Count = AtElements(Arr).Index; + if (Count) Result.Index = Count-1; return Result; } -link_internal bitmap * -GetPtr(bitmap_block_array *Arr, bitmap_block_array_index Index) +link_internal umm +Count( bitmap_block_array *Arr ) { - bitmap *Result = {}; - if (Index.Block) { Result = Index.Block->Elements + Index.ElementIndex; } + auto Result = AtElements(Arr).Index; return Result; } +link_internal bitmap_block * +GetBlock( bitmap_block_array *Arr, bitmap_block_array_index Index ) +{ + umm BlockIndex = Index.Index / 8; + Assert(BlockIndex < Arr->BlockCount); + bitmap_block *Block = Arr->BlockPtrs[BlockIndex]; + return Block; +} + link_internal bitmap * -GetPtr(bitmap_block *Block, umm Index) +GetPtr( bitmap_block_array *Arr, bitmap_block_array_index Index ) { - bitmap *Result = 0; - if (Index < Block->At) { Result = Block->Elements + Index; } + Assert(Arr->BlockPtrs); + Assert(Index.Index < Capacity(Arr).Index); + + bitmap_block *Block = GetBlock(Arr, Index); + + umm ElementIndex = Index.Index % 8; + bitmap *Result = (Block->Elements + ElementIndex); return Result; } + link_internal bitmap * -GetPtr(bitmap_block_array *Arr, umm Index) +GetPtr( bitmap_block_array *Arr, umm Index ) { - umm BlockIndex = Index / 8; - umm ElementIndex = Index % 8; + bitmap_block_array_index I = {Index}; + return GetPtr(Arr, I); +} + - umm AtBlock = 0; - bitmap_block *Block = Arr->First; - while (AtBlock++ < BlockIndex) +link_internal bitmap * +TryGetPtr( bitmap_block_array *Arr, bitmap_block_array_index Index) +{ + bitmap * Result = {}; + if (Arr->BlockPtrs && Index < AtElements(Arr)) { - Block = Block->Next; + Result = GetPtr(Arr, Index); } - - bitmap *Result = Block->Elements+ElementIndex; return Result; } link_internal bitmap * -TryGetPtr(bitmap_block_array *Arr, umm Index) +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); } + auto Result = TryGetPtr(Arr, bitmap_block_array_index{Index}); return Result; } -link_internal u32 -AtElements(bitmap_block *Block) + + + + +link_internal cs +CS( bitmap_block_array_index Index ) { - return Block->At; + return FSz("(%u)", Index.Index); } - -link_internal bitmap_block* -Allocate_bitmap_block(memory_arena *Memory) +link_internal bitmap * +Set( bitmap_block_array *Arr, + bitmap *Element, + bitmap_block_array_index Index ) { - bitmap_block *Result = Allocate(bitmap_block, Memory, 1); - Result->Elements = Allocate(bitmap, Memory, 8); - return Result; + Assert(Arr->BlockPtrs); + Assert(Index.Index < Capacity(Arr).Index); + bitmap_block *Block = GetBlock(Arr, Index); + umm ElementIndex = Index.Index % 8; + auto Slot = Block->Elements+ElementIndex; + *Slot = *Element; + return Slot; } -link_internal cs -CS(bitmap_block_array_index Index) +link_internal void +NewBlock( bitmap_block_array *Arr ) { - return FSz("(%u)(%u)", Index.BlockIndex, Index.ElementIndex); + bitmap_block *NewBlock = Allocate( bitmap_block , Arr->Memory, 1); + bitmap_block **NewBlockPtrs = Allocate( bitmap_block*, Arr->Memory, Arr->BlockCount+1); + + RangeIterator_t(u32, BlockI, Arr->BlockCount) + { + NewBlockPtrs[BlockI] = Arr->BlockPtrs[BlockI]; + } + + NewBlockPtrs[Arr->BlockCount] = NewBlock; + + + + Arr->BlockPtrs = NewBlockPtrs; + Arr->BlockCount += 1; } link_internal void -RemoveUnordered(bitmap_block_array *Array, bitmap_block_array_index Index) +RemoveUnordered( bitmap_block_array *Array, bitmap_block_array_index Index) { - bitmap_block_array_index LastI = LastIndex(Array); + auto LastI = LastIndex(Array); + Assert(Index.Index <= LastI.Index); - bitmap *Element = GetPtr(Array, Index); - bitmap *LastElement = GetPtr(Array, LastI); + auto LastElement = GetPtr(Array, LastI); + Set(Array, LastElement, Index); + Array->ElementCount -= 1; +} - *Element = *LastElement; +link_internal void +RemoveOrdered( bitmap_block_array *Array, bitmap_block_array_index IndexToRemove) +{ + Assert(IndexToRemove.Index < Array->ElementCount); - Assert(Array->Current->At); - Array->Current->At -= 1; + bitmap *Prev = {}; - if (Array->Current->At == 0) + bitmap_block_array_index Max = AtElements(Array); + RangeIteratorRange_t(umm, Index, Max.Index, IndexToRemove.Index) { - // Walk the chain till we get to the second-last one - bitmap_block *Current = Array->First; - bitmap_block *LastB = LastI.Block; + bitmap *E = GetPtr(Array, Index); - while (Current->Next && Current->Next != LastB) + if (Prev) { - Current = Current->Next; + *Prev = *E; } - Assert(Current->Next == LastB || Current->Next == 0); - Array->Current = Current; + Prev = E; } + + Array->ElementCount -= 1; } -link_internal bitmap * -Push(bitmap_block_array *Array, bitmap *Element) +link_internal void +RemoveOrdered( bitmap_block_array *Array, bitmap *Element ) { - if (Array->Memory == 0) { Array->Memory = AllocateArena(); } - - if (Array->First == 0) { Array->First = Allocate_bitmap_block(Array->Memory); Array->Current = Array->First; } - - if (Array->Current->At == 8) + IterateOver(Array, E, I) { - if (Array->Current->Next) + if (E == Element) { - Array->Current = Array->Current->Next; - Assert(Array->Current->At == 0); + RemoveOrdered(Array, I); + break; } - else - { - bitmap_block *Next = Allocate_bitmap_block(Array->Memory); - Next->Index = Array->Current->Index + 1; + } +} - Array->Current->Next = Next; - Array->Current = Next; +link_internal bitmap_block_array_index +Find( bitmap_block_array *Array, bitmap *Query) +{ + bitmap_block_array_index Result = {INVALID_BLOCK_ARRAY_INDEX}; + IterateOver(Array, E, Index) + { + if ( E == Query ) + { + Result = Index; + break; } } + return Result; +} + + + +link_internal b32 +IsValid(bitmap_block_array_index *Index) +{ + bitmap_block_array_index Test = {INVALID_BLOCK_ARRAY_INDEX}; + b32 Result = (AreEqual(Index, &Test) == False); + return Result; +} + +link_internal bitmap * +Push( bitmap_block_array *Array, bitmap *Element) +{ + Assert(Array->Memory); + + if (AtElements(Array) == Capacity(Array)) + { + NewBlock(Array); + } - bitmap *Result = Array->Current->Elements + Array->Current->At; + bitmap *Result = Set(Array, Element, AtElements(Array)); - Array->Current->Elements[Array->Current->At++] = *Element; + Array->ElementCount += 1; return Result; } +link_internal bitmap * +Push( bitmap_block_array *Array ) +{ + bitmap Element = {}; + auto Result = Push(Array, &Element); + return Result; +} + +link_internal void +Insert( bitmap_block_array *Array, bitmap_block_array_index Index, bitmap *Element ) +{ + Assert(Index.Index <= LastIndex(Array).Index); + Assert(Array->Memory); + + // Alocate a new thingy + bitmap *Prev = Push(Array); + + auto Last = LastIndex(Array); + + RangeIteratorReverseRange(I, s32(Last.Index), s32(Index.Index)) + { + auto E = GetPtr(Array, umm(I)); + *Prev = *E; + Prev = E; + } + + *Prev = *Element; +} + +link_internal void +Insert( bitmap_block_array *Array, u32 Index, bitmap *Element ) +{ + Insert(Array, { .Index = Index }, Element); +} + +link_internal void +Shift( bitmap_block_array *Array, bitmap *Element ) +{ + Insert(Array, { .Index = 0 }, Element); +} + +/* element_t.has_tag(do_editor_ui)? */ +/* { */ +/* do_editor_ui_for_container( block_array_t ) */ +/* } */ + + diff --git a/generated/block_array_c_asset_thumbnail_688856411.h b/generated/block_array_c_asset_thumbnail_688856411.h index 335b72e02..d01d80c00 100644 --- a/generated/block_array_c_asset_thumbnail_688856411.h +++ b/generated/block_array_c_asset_thumbnail_688856411.h @@ -1,77 +1,180 @@ -// src/engine/editor.cpp:80:0 +// external/bonsai_stdlib/src/poof_functions.h:2378:0 -link_internal asset_thumbnail_block* -Allocate_asset_thumbnail_block(memory_arena *Memory) + + +link_internal cs +CS( asset_thumbnail_block_array_index Index ) { - asset_thumbnail_block *Result = Allocate(asset_thumbnail_block, Memory, 1); - Result->Elements = Allocate(asset_thumbnail, Memory, 8); - return Result; + return FSz("(%u)", Index.Index); } -link_internal cs -CS(asset_thumbnail_block_array_index Index) +link_internal asset_thumbnail * +Set( asset_thumbnail_block_array *Arr, + asset_thumbnail *Element, + asset_thumbnail_block_array_index Index ) { - return FSz("(%u)(%u)", Index.BlockIndex, Index.ElementIndex); + Assert(Arr->BlockPtrs); + Assert(Index.Index < Capacity(Arr).Index); + asset_thumbnail_block *Block = GetBlock(Arr, Index); + umm ElementIndex = Index.Index % 8; + auto Slot = Block->Elements+ElementIndex; + *Slot = *Element; + return Slot; } link_internal void -RemoveUnordered(asset_thumbnail_block_array *Array, asset_thumbnail_block_array_index Index) +NewBlock( asset_thumbnail_block_array *Arr ) { - asset_thumbnail_block_array_index LastI = LastIndex(Array); + asset_thumbnail_block *NewBlock = Allocate( asset_thumbnail_block , Arr->Memory, 1); + asset_thumbnail_block **NewBlockPtrs = Allocate( asset_thumbnail_block*, Arr->Memory, Arr->BlockCount+1); + + RangeIterator_t(u32, BlockI, Arr->BlockCount) + { + NewBlockPtrs[BlockI] = Arr->BlockPtrs[BlockI]; + } - asset_thumbnail *Element = GetPtr(Array, Index); - asset_thumbnail *LastElement = GetPtr(Array, LastI); + NewBlockPtrs[Arr->BlockCount] = NewBlock; - *Element = *LastElement; + + + Arr->BlockPtrs = NewBlockPtrs; + Arr->BlockCount += 1; +} + +link_internal void +RemoveUnordered( asset_thumbnail_block_array *Array, asset_thumbnail_block_array_index Index) +{ + auto LastI = LastIndex(Array); + Assert(Index.Index <= LastI.Index); + + auto LastElement = GetPtr(Array, LastI); + Set(Array, LastElement, Index); + Array->ElementCount -= 1; +} + +link_internal void +RemoveOrdered( asset_thumbnail_block_array *Array, asset_thumbnail_block_array_index IndexToRemove) +{ + Assert(IndexToRemove.Index < Array->ElementCount); - Assert(Array->Current->At); - Array->Current->At -= 1; + asset_thumbnail *Prev = {}; - if (Array->Current->At == 0) + asset_thumbnail_block_array_index Max = AtElements(Array); + RangeIteratorRange_t(umm, Index, Max.Index, IndexToRemove.Index) { - // Walk the chain till we get to the second-last one - asset_thumbnail_block *Current = Array->First; - asset_thumbnail_block *LastB = LastI.Block; + asset_thumbnail *E = GetPtr(Array, Index); - while (Current->Next && Current->Next != LastB) + if (Prev) { - Current = Current->Next; + *Prev = *E; } - Assert(Current->Next == LastB || Current->Next == 0); - Array->Current = Current; + Prev = E; } + + Array->ElementCount -= 1; } -link_internal asset_thumbnail * -Push(asset_thumbnail_block_array *Array, asset_thumbnail *Element) +link_internal void +RemoveOrdered( asset_thumbnail_block_array *Array, asset_thumbnail *Element ) { - if (Array->Memory == 0) { Array->Memory = AllocateArena(); } - - if (Array->First == 0) { Array->First = Allocate_asset_thumbnail_block(Array->Memory); Array->Current = Array->First; } - - if (Array->Current->At == 8) + IterateOver(Array, E, I) { - if (Array->Current->Next) + if (E == Element) { - Array->Current = Array->Current->Next; - Assert(Array->Current->At == 0); + RemoveOrdered(Array, I); + break; } - else - { - asset_thumbnail_block *Next = Allocate_asset_thumbnail_block(Array->Memory); - Next->Index = Array->Current->Index + 1; + } +} - Array->Current->Next = Next; - Array->Current = Next; +link_internal asset_thumbnail_block_array_index +Find( asset_thumbnail_block_array *Array, asset_thumbnail *Query) +{ + asset_thumbnail_block_array_index Result = {INVALID_BLOCK_ARRAY_INDEX}; + IterateOver(Array, E, Index) + { + if ( E == Query ) + { + Result = Index; + break; } } + return Result; +} + + + +link_internal b32 +IsValid(asset_thumbnail_block_array_index *Index) +{ + asset_thumbnail_block_array_index Test = {INVALID_BLOCK_ARRAY_INDEX}; + b32 Result = (AreEqual(Index, &Test) == False); + return Result; +} + +link_internal asset_thumbnail * +Push( asset_thumbnail_block_array *Array, asset_thumbnail *Element) +{ + Assert(Array->Memory); + + if (AtElements(Array) == Capacity(Array)) + { + NewBlock(Array); + } - asset_thumbnail *Result = Array->Current->Elements + Array->Current->At; + asset_thumbnail *Result = Set(Array, Element, AtElements(Array)); - Array->Current->Elements[Array->Current->At++] = *Element; + Array->ElementCount += 1; return Result; } +link_internal asset_thumbnail * +Push( asset_thumbnail_block_array *Array ) +{ + asset_thumbnail Element = {}; + auto Result = Push(Array, &Element); + return Result; +} + +link_internal void +Insert( asset_thumbnail_block_array *Array, asset_thumbnail_block_array_index Index, asset_thumbnail *Element ) +{ + Assert(Index.Index <= LastIndex(Array).Index); + Assert(Array->Memory); + + // Alocate a new thingy + asset_thumbnail *Prev = Push(Array); + + auto Last = LastIndex(Array); + + RangeIteratorReverseRange(I, s32(Last.Index), s32(Index.Index)) + { + auto E = GetPtr(Array, umm(I)); + *Prev = *E; + Prev = E; + } + + *Prev = *Element; +} + +link_internal void +Insert( asset_thumbnail_block_array *Array, u32 Index, asset_thumbnail *Element ) +{ + Insert(Array, { .Index = Index }, Element); +} + +link_internal void +Shift( asset_thumbnail_block_array *Array, asset_thumbnail *Element ) +{ + Insert(Array, { .Index = 0 }, Element); +} + +/* element_t.has_tag(do_editor_ui)? */ +/* { */ +/* do_editor_ui_for_container( block_array_t ) */ +/* } */ + + diff --git a/generated/block_array_c_counted_string_688853862_counted_string_block_array_counted_string_block_counted_string_block_array_index.h b/generated/block_array_c_counted_string_688853862_counted_string_block_array_counted_string_block_counted_string_block_array_index.h new file mode 100644 index 000000000..6c418ecbf --- /dev/null +++ b/generated/block_array_c_counted_string_688853862_counted_string_block_array_counted_string_block_counted_string_block_array_index.h @@ -0,0 +1,180 @@ +// external/bonsai_stdlib/src/poof_functions.h:2378:0 + + + + +link_internal cs +CS( counted_string_block_array_index Index ) +{ + return FSz("(%u)", Index.Index); +} + +link_internal counted_string * +Set( counted_string_block_array *Arr, + counted_string *Element, + counted_string_block_array_index Index ) +{ + Assert(Arr->BlockPtrs); + Assert(Index.Index < Capacity(Arr).Index); + counted_string_block *Block = GetBlock(Arr, Index); + umm ElementIndex = Index.Index % 32; + auto Slot = Block->Elements+ElementIndex; + *Slot = *Element; + return Slot; +} + +link_internal void +NewBlock( counted_string_block_array *Arr ) +{ + counted_string_block *NewBlock = Allocate( counted_string_block , Arr->Memory, 1); + counted_string_block **NewBlockPtrs = Allocate( counted_string_block*, Arr->Memory, Arr->BlockCount+1); + + RangeIterator_t(u32, BlockI, Arr->BlockCount) + { + NewBlockPtrs[BlockI] = Arr->BlockPtrs[BlockI]; + } + + NewBlockPtrs[Arr->BlockCount] = NewBlock; + + + + Arr->BlockPtrs = NewBlockPtrs; + Arr->BlockCount += 1; +} + +link_internal void +RemoveUnordered( counted_string_block_array *Array, counted_string_block_array_index Index) +{ + auto LastI = LastIndex(Array); + Assert(Index.Index <= LastI.Index); + + auto LastElement = GetPtr(Array, LastI); + Set(Array, LastElement, Index); + Array->ElementCount -= 1; +} + +link_internal void +RemoveOrdered( counted_string_block_array *Array, counted_string_block_array_index IndexToRemove) +{ + Assert(IndexToRemove.Index < Array->ElementCount); + + counted_string *Prev = {}; + + counted_string_block_array_index Max = AtElements(Array); + RangeIteratorRange_t(umm, Index, Max.Index, IndexToRemove.Index) + { + counted_string *E = GetPtr(Array, Index); + + if (Prev) + { + *Prev = *E; + } + + Prev = E; + } + + Array->ElementCount -= 1; +} + +link_internal void +RemoveOrdered( counted_string_block_array *Array, counted_string *Element ) +{ + IterateOver(Array, E, I) + { + if (E == Element) + { + RemoveOrdered(Array, I); + break; + } + } +} + +link_internal counted_string_block_array_index +Find( counted_string_block_array *Array, counted_string *Query) +{ + counted_string_block_array_index Result = {INVALID_BLOCK_ARRAY_INDEX}; + IterateOver(Array, E, Index) + { + if ( E == Query ) + { + Result = Index; + break; + } + } + return Result; +} + + + +link_internal b32 +IsValid(counted_string_block_array_index *Index) +{ + counted_string_block_array_index Test = {INVALID_BLOCK_ARRAY_INDEX}; + b32 Result = (AreEqual(Index, &Test) == False); + return Result; +} + +link_internal counted_string * +Push( counted_string_block_array *Array, counted_string *Element) +{ + Assert(Array->Memory); + + if (AtElements(Array) == Capacity(Array)) + { + NewBlock(Array); + } + + counted_string *Result = Set(Array, Element, AtElements(Array)); + + Array->ElementCount += 1; + + return Result; +} + +link_internal counted_string * +Push( counted_string_block_array *Array ) +{ + counted_string Element = {}; + auto Result = Push(Array, &Element); + return Result; +} + +link_internal void +Insert( counted_string_block_array *Array, counted_string_block_array_index Index, counted_string *Element ) +{ + Assert(Index.Index <= LastIndex(Array).Index); + Assert(Array->Memory); + + // Alocate a new thingy + counted_string *Prev = Push(Array); + + auto Last = LastIndex(Array); + + RangeIteratorReverseRange(I, s32(Last.Index), s32(Index.Index)) + { + auto E = GetPtr(Array, umm(I)); + *Prev = *E; + Prev = E; + } + + *Prev = *Element; +} + +link_internal void +Insert( counted_string_block_array *Array, u32 Index, counted_string *Element ) +{ + Insert(Array, { .Index = Index }, Element); +} + +link_internal void +Shift( counted_string_block_array *Array, counted_string *Element ) +{ + Insert(Array, { .Index = 0 }, Element); +} + +/* element_t.has_tag(do_editor_ui)? */ +/* { */ +/* do_editor_ui_for_container( block_array_t ) */ +/* } */ + + diff --git a/generated/block_array_c_entity_ptr_688856411_struct_struct_struct.h b/generated/block_array_c_entity_ptr_688856411_struct_struct_struct.h new file mode 100644 index 000000000..d3b195e2a --- /dev/null +++ b/generated/block_array_c_entity_ptr_688856411_struct_struct_struct.h @@ -0,0 +1,180 @@ +// external/bonsai_stdlib/src/poof_functions.h:2378:0 + + + + +link_internal cs +CS( entity_ptr_block_array_index Index ) +{ + return FSz("(%u)", Index.Index); +} + +link_internal entity_ptr +Set( entity_ptr_block_array *Arr, + entity_ptr Element, + entity_ptr_block_array_index Index ) +{ + Assert(Arr->BlockPtrs); + Assert(Index.Index < Capacity(Arr).Index); + entity_ptr_block *Block = GetBlock(Arr, Index); + umm ElementIndex = Index.Index % 8; + auto Slot = Block->Elements+ElementIndex; + *Slot = Element; + return *Slot; +} + +link_internal void +NewBlock( entity_ptr_block_array *Arr ) +{ + entity_ptr_block *NewBlock = Allocate( entity_ptr_block , Arr->Memory, 1); + entity_ptr_block **NewBlockPtrs = Allocate( entity_ptr_block*, Arr->Memory, Arr->BlockCount+1); + + RangeIterator_t(u32, BlockI, Arr->BlockCount) + { + NewBlockPtrs[BlockI] = Arr->BlockPtrs[BlockI]; + } + + NewBlockPtrs[Arr->BlockCount] = NewBlock; + + + + Arr->BlockPtrs = NewBlockPtrs; + Arr->BlockCount += 1; +} + +link_internal void +RemoveUnordered( entity_ptr_block_array *Array, entity_ptr_block_array_index Index) +{ + auto LastI = LastIndex(Array); + Assert(Index.Index <= LastI.Index); + + auto LastElement = GetPtr(Array, LastI); + Set(Array, LastElement, Index); + Array->ElementCount -= 1; +} + +link_internal void +RemoveOrdered( entity_ptr_block_array *Array, entity_ptr_block_array_index IndexToRemove) +{ + Assert(IndexToRemove.Index < Array->ElementCount); + + entity_ptr Prev = {}; + + entity_ptr_block_array_index Max = AtElements(Array); + RangeIteratorRange_t(umm, Index, Max.Index, IndexToRemove.Index) + { + entity_ptr E = GetPtr(Array, Index); + + if (Prev) + { + *Prev = *E; + } + + Prev = E; + } + + Array->ElementCount -= 1; +} + +link_internal void +RemoveOrdered( entity_ptr_block_array *Array, entity_ptr Element ) +{ + IterateOver(Array, E, I) + { + if (E == Element) + { + RemoveOrdered(Array, I); + break; + } + } +} + +link_internal entity_ptr_block_array_index +Find( entity_ptr_block_array *Array, entity_ptr Query) +{ + entity_ptr_block_array_index Result = {INVALID_BLOCK_ARRAY_INDEX}; + IterateOver(Array, E, Index) + { + if ( E == Query ) + { + Result = Index; + break; + } + } + return Result; +} + + + +link_internal b32 +IsValid(entity_ptr_block_array_index *Index) +{ + entity_ptr_block_array_index Test = {INVALID_BLOCK_ARRAY_INDEX}; + b32 Result = (AreEqual(Index, &Test) == False); + return Result; +} + +link_internal entity_ptr +Push( entity_ptr_block_array *Array, entity_ptr Element) +{ + Assert(Array->Memory); + + if (AtElements(Array) == Capacity(Array)) + { + NewBlock(Array); + } + + entity_ptr Result = Set(Array, Element, AtElements(Array)); + + Array->ElementCount += 1; + + return Result; +} + +link_internal entity_ptr +Push( entity_ptr_block_array *Array ) +{ + entity_ptr Element = {}; + auto Result = Push(Array, Element); + return Result; +} + +link_internal void +Insert( entity_ptr_block_array *Array, entity_ptr_block_array_index Index, entity_ptr Element ) +{ + Assert(Index.Index <= LastIndex(Array).Index); + Assert(Array->Memory); + + // Alocate a new thingy + entity_ptr Prev = Push(Array); + + auto Last = LastIndex(Array); + + RangeIteratorReverseRange(I, s32(Last.Index), s32(Index.Index)) + { + auto E = GetPtr(Array, umm(I)); + *Prev = *E; + Prev = E; + } + + *Prev = *Element; +} + +link_internal void +Insert( entity_ptr_block_array *Array, u32 Index, entity_ptr Element ) +{ + Insert(Array, { .Index = Index }, Element); +} + +link_internal void +Shift( entity_ptr_block_array *Array, entity_ptr Element ) +{ + Insert(Array, { .Index = 0 }, Element); +} + +/* element_t.has_tag(do_editor_ui)? */ +/* { */ +/* do_editor_ui_for_container( block_array_t ) */ +/* } */ + + diff --git a/generated/block_array_c_gpu_timer_688735882.h b/generated/block_array_c_gpu_timer_688735882.h new file mode 100644 index 000000000..ba7adec76 --- /dev/null +++ b/generated/block_array_c_gpu_timer_688735882.h @@ -0,0 +1,180 @@ +// external/bonsai_stdlib/src/poof_functions.h:2378:0 + + + + +link_internal cs +CS( gpu_timer_block_array_index Index ) +{ + return FSz("(%u)", Index.Index); +} + +link_internal gpu_timer * +Set( gpu_timer_block_array *Arr, + gpu_timer *Element, + gpu_timer_block_array_index Index ) +{ + Assert(Arr->BlockPtrs); + Assert(Index.Index < Capacity(Arr).Index); + gpu_timer_block *Block = GetBlock(Arr, Index); + umm ElementIndex = Index.Index % 128; + auto Slot = Block->Elements+ElementIndex; + *Slot = *Element; + return Slot; +} + +link_internal void +NewBlock( gpu_timer_block_array *Arr ) +{ + gpu_timer_block *NewBlock = Allocate( gpu_timer_block , Arr->Memory, 1); + gpu_timer_block **NewBlockPtrs = Allocate( gpu_timer_block*, Arr->Memory, Arr->BlockCount+1); + + RangeIterator_t(u32, BlockI, Arr->BlockCount) + { + NewBlockPtrs[BlockI] = Arr->BlockPtrs[BlockI]; + } + + NewBlockPtrs[Arr->BlockCount] = NewBlock; + + + + Arr->BlockPtrs = NewBlockPtrs; + Arr->BlockCount += 1; +} + +link_internal void +RemoveUnordered( gpu_timer_block_array *Array, gpu_timer_block_array_index Index) +{ + auto LastI = LastIndex(Array); + Assert(Index.Index <= LastI.Index); + + auto LastElement = GetPtr(Array, LastI); + Set(Array, LastElement, Index); + Array->ElementCount -= 1; +} + +link_internal void +RemoveOrdered( gpu_timer_block_array *Array, gpu_timer_block_array_index IndexToRemove) +{ + Assert(IndexToRemove.Index < Array->ElementCount); + + gpu_timer *Prev = {}; + + gpu_timer_block_array_index Max = AtElements(Array); + RangeIteratorRange_t(umm, Index, Max.Index, IndexToRemove.Index) + { + gpu_timer *E = GetPtr(Array, Index); + + if (Prev) + { + *Prev = *E; + } + + Prev = E; + } + + Array->ElementCount -= 1; +} + +link_internal void +RemoveOrdered( gpu_timer_block_array *Array, gpu_timer *Element ) +{ + IterateOver(Array, E, I) + { + if (E == Element) + { + RemoveOrdered(Array, I); + break; + } + } +} + +link_internal gpu_timer_block_array_index +Find( gpu_timer_block_array *Array, gpu_timer *Query) +{ + gpu_timer_block_array_index Result = {INVALID_BLOCK_ARRAY_INDEX}; + IterateOver(Array, E, Index) + { + if ( E == Query ) + { + Result = Index; + break; + } + } + return Result; +} + + + +link_internal b32 +IsValid(gpu_timer_block_array_index *Index) +{ + gpu_timer_block_array_index Test = {INVALID_BLOCK_ARRAY_INDEX}; + b32 Result = (AreEqual(Index, &Test) == False); + return Result; +} + +link_internal gpu_timer * +Push( gpu_timer_block_array *Array, gpu_timer *Element) +{ + Assert(Array->Memory); + + if (AtElements(Array) == Capacity(Array)) + { + NewBlock(Array); + } + + gpu_timer *Result = Set(Array, Element, AtElements(Array)); + + Array->ElementCount += 1; + + return Result; +} + +link_internal gpu_timer * +Push( gpu_timer_block_array *Array ) +{ + gpu_timer Element = {}; + auto Result = Push(Array, &Element); + return Result; +} + +link_internal void +Insert( gpu_timer_block_array *Array, gpu_timer_block_array_index Index, gpu_timer *Element ) +{ + Assert(Index.Index <= LastIndex(Array).Index); + Assert(Array->Memory); + + // Alocate a new thingy + gpu_timer *Prev = Push(Array); + + auto Last = LastIndex(Array); + + RangeIteratorReverseRange(I, s32(Last.Index), s32(Index.Index)) + { + auto E = GetPtr(Array, umm(I)); + *Prev = *E; + Prev = E; + } + + *Prev = *Element; +} + +link_internal void +Insert( gpu_timer_block_array *Array, u32 Index, gpu_timer *Element ) +{ + Insert(Array, { .Index = Index }, Element); +} + +link_internal void +Shift( gpu_timer_block_array *Array, gpu_timer *Element ) +{ + Insert(Array, { .Index = 0 }, Element); +} + +/* element_t.has_tag(do_editor_ui)? */ +/* { */ +/* do_editor_ui_for_container( block_array_t ) */ +/* } */ + + diff --git a/generated/block_array_c_shader_ptr_688853971.h b/generated/block_array_c_shader_ptr_688853971.h new file mode 100644 index 000000000..d2ad63862 --- /dev/null +++ b/generated/block_array_c_shader_ptr_688853971.h @@ -0,0 +1,180 @@ +// external/bonsai_stdlib/src/poof_functions.h:2378:0 + + + + +link_internal cs +CS( shader_ptr_block_array_index Index ) +{ + return FSz("(%u)", Index.Index); +} + +link_internal shader_ptr +Set( shader_ptr_block_array *Arr, + shader_ptr Element, + shader_ptr_block_array_index Index ) +{ + Assert(Arr->BlockPtrs); + Assert(Index.Index < Capacity(Arr).Index); + shader_ptr_block *Block = GetBlock(Arr, Index); + umm ElementIndex = Index.Index % 64; + auto Slot = Block->Elements+ElementIndex; + *Slot = Element; + return *Slot; +} + +link_internal void +NewBlock( shader_ptr_block_array *Arr ) +{ + shader_ptr_block *NewBlock = Allocate( shader_ptr_block , Arr->Memory, 1); + shader_ptr_block **NewBlockPtrs = Allocate( shader_ptr_block*, Arr->Memory, Arr->BlockCount+1); + + RangeIterator_t(u32, BlockI, Arr->BlockCount) + { + NewBlockPtrs[BlockI] = Arr->BlockPtrs[BlockI]; + } + + NewBlockPtrs[Arr->BlockCount] = NewBlock; + + + + Arr->BlockPtrs = NewBlockPtrs; + Arr->BlockCount += 1; +} + +link_internal void +RemoveUnordered( shader_ptr_block_array *Array, shader_ptr_block_array_index Index) +{ + auto LastI = LastIndex(Array); + Assert(Index.Index <= LastI.Index); + + auto LastElement = GetPtr(Array, LastI); + Set(Array, LastElement, Index); + Array->ElementCount -= 1; +} + +link_internal void +RemoveOrdered( shader_ptr_block_array *Array, shader_ptr_block_array_index IndexToRemove) +{ + Assert(IndexToRemove.Index < Array->ElementCount); + + shader_ptr Prev = {}; + + shader_ptr_block_array_index Max = AtElements(Array); + RangeIteratorRange_t(umm, Index, Max.Index, IndexToRemove.Index) + { + shader_ptr E = GetPtr(Array, Index); + + if (Prev) + { + *Prev = *E; + } + + Prev = E; + } + + Array->ElementCount -= 1; +} + +link_internal void +RemoveOrdered( shader_ptr_block_array *Array, shader_ptr Element ) +{ + IterateOver(Array, E, I) + { + if (E == Element) + { + RemoveOrdered(Array, I); + break; + } + } +} + +link_internal shader_ptr_block_array_index +Find( shader_ptr_block_array *Array, shader_ptr Query) +{ + shader_ptr_block_array_index Result = {INVALID_BLOCK_ARRAY_INDEX}; + IterateOver(Array, E, Index) + { + if ( E == Query ) + { + Result = Index; + break; + } + } + return Result; +} + + + +link_internal b32 +IsValid(shader_ptr_block_array_index *Index) +{ + shader_ptr_block_array_index Test = {INVALID_BLOCK_ARRAY_INDEX}; + b32 Result = (AreEqual(Index, &Test) == False); + return Result; +} + +link_internal shader_ptr +Push( shader_ptr_block_array *Array, shader_ptr Element) +{ + Assert(Array->Memory); + + if (AtElements(Array) == Capacity(Array)) + { + NewBlock(Array); + } + + shader_ptr Result = Set(Array, Element, AtElements(Array)); + + Array->ElementCount += 1; + + return Result; +} + +link_internal shader_ptr +Push( shader_ptr_block_array *Array ) +{ + shader_ptr Element = {}; + auto Result = Push(Array, Element); + return Result; +} + +link_internal void +Insert( shader_ptr_block_array *Array, shader_ptr_block_array_index Index, shader_ptr Element ) +{ + Assert(Index.Index <= LastIndex(Array).Index); + Assert(Array->Memory); + + // Alocate a new thingy + shader_ptr Prev = Push(Array); + + auto Last = LastIndex(Array); + + RangeIteratorReverseRange(I, s32(Last.Index), s32(Index.Index)) + { + auto E = GetPtr(Array, umm(I)); + *Prev = *E; + Prev = E; + } + + *Prev = *Element; +} + +link_internal void +Insert( shader_ptr_block_array *Array, u32 Index, shader_ptr Element ) +{ + Insert(Array, { .Index = Index }, Element); +} + +link_internal void +Shift( shader_ptr_block_array *Array, shader_ptr Element ) +{ + Insert(Array, { .Index = 0 }, Element); +} + +/* element_t.has_tag(do_editor_ui)? */ +/* { */ +/* do_editor_ui_for_container( block_array_t ) */ +/* } */ + + diff --git a/generated/block_array_c_texture_688856411.h b/generated/block_array_c_texture_688856411.h index 20b384414..01f6d5e27 100644 --- a/generated/block_array_c_texture_688856411.h +++ b/generated/block_array_c_texture_688856411.h @@ -1,77 +1,180 @@ -// external/bonsai_stdlib/src/texture.cpp:5:0 +// external/bonsai_stdlib/src/poof_functions.h:2378:0 -link_internal texture_block* -Allocate_texture_block(memory_arena *Memory) + + +link_internal cs +CS( texture_block_array_index Index ) { - texture_block *Result = Allocate(texture_block, Memory, 1); - Result->Elements = Allocate(texture, Memory, 8); - return Result; + return FSz("(%u)", Index.Index); } -link_internal cs -CS(texture_block_array_index Index) +link_internal texture * +Set( texture_block_array *Arr, + texture *Element, + texture_block_array_index Index ) { - return FSz("(%u)(%u)", Index.BlockIndex, Index.ElementIndex); + Assert(Arr->BlockPtrs); + Assert(Index.Index < Capacity(Arr).Index); + texture_block *Block = GetBlock(Arr, Index); + umm ElementIndex = Index.Index % 8; + auto Slot = Block->Elements+ElementIndex; + *Slot = *Element; + return Slot; } link_internal void -RemoveUnordered(texture_block_array *Array, texture_block_array_index Index) +NewBlock( texture_block_array *Arr ) { - texture_block_array_index LastI = LastIndex(Array); + texture_block *NewBlock = Allocate( texture_block , Arr->Memory, 1); + texture_block **NewBlockPtrs = Allocate( texture_block*, Arr->Memory, Arr->BlockCount+1); + + RangeIterator_t(u32, BlockI, Arr->BlockCount) + { + NewBlockPtrs[BlockI] = Arr->BlockPtrs[BlockI]; + } - texture *Element = GetPtr(Array, Index); - texture *LastElement = GetPtr(Array, LastI); + NewBlockPtrs[Arr->BlockCount] = NewBlock; - *Element = *LastElement; + + + Arr->BlockPtrs = NewBlockPtrs; + Arr->BlockCount += 1; +} + +link_internal void +RemoveUnordered( texture_block_array *Array, texture_block_array_index Index) +{ + auto LastI = LastIndex(Array); + Assert(Index.Index <= LastI.Index); + + auto LastElement = GetPtr(Array, LastI); + Set(Array, LastElement, Index); + Array->ElementCount -= 1; +} + +link_internal void +RemoveOrdered( texture_block_array *Array, texture_block_array_index IndexToRemove) +{ + Assert(IndexToRemove.Index < Array->ElementCount); - Assert(Array->Current->At); - Array->Current->At -= 1; + texture *Prev = {}; - if (Array->Current->At == 0) + texture_block_array_index Max = AtElements(Array); + RangeIteratorRange_t(umm, Index, Max.Index, IndexToRemove.Index) { - // Walk the chain till we get to the second-last one - texture_block *Current = Array->First; - texture_block *LastB = LastI.Block; + texture *E = GetPtr(Array, Index); - while (Current->Next && Current->Next != LastB) + if (Prev) { - Current = Current->Next; + *Prev = *E; } - Assert(Current->Next == LastB || Current->Next == 0); - Array->Current = Current; + Prev = E; } + + Array->ElementCount -= 1; } -link_internal texture * -Push(texture_block_array *Array, texture *Element) +link_internal void +RemoveOrdered( texture_block_array *Array, texture *Element ) { - if (Array->Memory == 0) { Array->Memory = AllocateArena(); } - - if (Array->First == 0) { Array->First = Allocate_texture_block(Array->Memory); Array->Current = Array->First; } - - if (Array->Current->At == 8) + IterateOver(Array, E, I) { - if (Array->Current->Next) + if (E == Element) { - Array->Current = Array->Current->Next; - Assert(Array->Current->At == 0); + RemoveOrdered(Array, I); + break; } - else - { - texture_block *Next = Allocate_texture_block(Array->Memory); - Next->Index = Array->Current->Index + 1; + } +} - Array->Current->Next = Next; - Array->Current = Next; +link_internal texture_block_array_index +Find( texture_block_array *Array, texture *Query) +{ + texture_block_array_index Result = {INVALID_BLOCK_ARRAY_INDEX}; + IterateOver(Array, E, Index) + { + if ( E == Query ) + { + Result = Index; + break; } } + return Result; +} + + + +link_internal b32 +IsValid(texture_block_array_index *Index) +{ + texture_block_array_index Test = {INVALID_BLOCK_ARRAY_INDEX}; + b32 Result = (AreEqual(Index, &Test) == False); + return Result; +} + +link_internal texture * +Push( texture_block_array *Array, texture *Element) +{ + Assert(Array->Memory); + + if (AtElements(Array) == Capacity(Array)) + { + NewBlock(Array); + } - texture *Result = Array->Current->Elements + Array->Current->At; + texture *Result = Set(Array, Element, AtElements(Array)); - Array->Current->Elements[Array->Current->At++] = *Element; + Array->ElementCount += 1; return Result; } +link_internal texture * +Push( texture_block_array *Array ) +{ + texture Element = {}; + auto Result = Push(Array, &Element); + return Result; +} + +link_internal void +Insert( texture_block_array *Array, texture_block_array_index Index, texture *Element ) +{ + Assert(Index.Index <= LastIndex(Array).Index); + Assert(Array->Memory); + + // Alocate a new thingy + texture *Prev = Push(Array); + + auto Last = LastIndex(Array); + + RangeIteratorReverseRange(I, s32(Last.Index), s32(Index.Index)) + { + auto E = GetPtr(Array, umm(I)); + *Prev = *E; + Prev = E; + } + + *Prev = *Element; +} + +link_internal void +Insert( texture_block_array *Array, u32 Index, texture *Element ) +{ + Insert(Array, { .Index = Index }, Element); +} + +link_internal void +Shift( texture_block_array *Array, texture *Element ) +{ + Insert(Array, { .Index = 0 }, Element); +} + +/* element_t.has_tag(do_editor_ui)? */ +/* { */ +/* do_editor_ui_for_container( block_array_t ) */ +/* } */ + + diff --git a/generated/block_array_c_u32_688856411.h b/generated/block_array_c_u32_688856411.h index 5d3d64539..4ca569ad7 100644 --- a/generated/block_array_c_u32_688856411.h +++ b/generated/block_array_c_u32_688856411.h @@ -1,77 +1,180 @@ -// external/bonsai_stdlib/src/primitive_containers.cpp:2:0 +// external/bonsai_stdlib/src/poof_functions.h:2378:0 -link_internal u32_block* -Allocate_u32_block(memory_arena *Memory) + + +link_internal cs +CS( u32_block_array_index Index ) { - u32_block *Result = Allocate(u32_block, Memory, 1); - Result->Elements = Allocate(u32, Memory, 8); - return Result; + return FSz("(%u)", Index.Index); } -link_internal cs -CS(u32_block_array_index Index) +link_internal u32 * +Set( u32_block_array *Arr, + u32 *Element, + u32_block_array_index Index ) { - return FSz("(%u)(%u)", Index.BlockIndex, Index.ElementIndex); + Assert(Arr->BlockPtrs); + Assert(Index.Index < Capacity(Arr).Index); + u32_block *Block = GetBlock(Arr, Index); + umm ElementIndex = Index.Index % 8; + auto Slot = Block->Elements+ElementIndex; + *Slot = *Element; + return Slot; } link_internal void -RemoveUnordered(u32_block_array *Array, u32_block_array_index Index) +NewBlock( u32_block_array *Arr ) { - u32_block_array_index LastI = LastIndex(Array); + u32_block *NewBlock = Allocate( u32_block , Arr->Memory, 1); + u32_block **NewBlockPtrs = Allocate( u32_block*, Arr->Memory, Arr->BlockCount+1); + + RangeIterator_t(u32, BlockI, Arr->BlockCount) + { + NewBlockPtrs[BlockI] = Arr->BlockPtrs[BlockI]; + } - u32 *Element = GetPtr(Array, Index); - u32 *LastElement = GetPtr(Array, LastI); + NewBlockPtrs[Arr->BlockCount] = NewBlock; - *Element = *LastElement; + + + Arr->BlockPtrs = NewBlockPtrs; + Arr->BlockCount += 1; +} + +link_internal void +RemoveUnordered( u32_block_array *Array, u32_block_array_index Index) +{ + auto LastI = LastIndex(Array); + Assert(Index.Index <= LastI.Index); + + auto LastElement = GetPtr(Array, LastI); + Set(Array, LastElement, Index); + Array->ElementCount -= 1; +} + +link_internal void +RemoveOrdered( u32_block_array *Array, u32_block_array_index IndexToRemove) +{ + Assert(IndexToRemove.Index < Array->ElementCount); - Assert(Array->Current->At); - Array->Current->At -= 1; + u32 *Prev = {}; - if (Array->Current->At == 0) + u32_block_array_index Max = AtElements(Array); + RangeIteratorRange_t(umm, Index, Max.Index, IndexToRemove.Index) { - // Walk the chain till we get to the second-last one - u32_block *Current = Array->First; - u32_block *LastB = LastI.Block; + u32 *E = GetPtr(Array, Index); - while (Current->Next && Current->Next != LastB) + if (Prev) { - Current = Current->Next; + *Prev = *E; } - Assert(Current->Next == LastB || Current->Next == 0); - Array->Current = Current; + Prev = E; } + + Array->ElementCount -= 1; } -link_internal u32 * -Push(u32_block_array *Array, u32 *Element) +link_internal void +RemoveOrdered( u32_block_array *Array, u32 *Element ) { - if (Array->Memory == 0) { Array->Memory = AllocateArena(); } - - if (Array->First == 0) { Array->First = Allocate_u32_block(Array->Memory); Array->Current = Array->First; } - - if (Array->Current->At == 8) + IterateOver(Array, E, I) { - if (Array->Current->Next) + if (E == Element) { - Array->Current = Array->Current->Next; - Assert(Array->Current->At == 0); + RemoveOrdered(Array, I); + break; } - else - { - u32_block *Next = Allocate_u32_block(Array->Memory); - Next->Index = Array->Current->Index + 1; + } +} - Array->Current->Next = Next; - Array->Current = Next; +link_internal u32_block_array_index +Find( u32_block_array *Array, u32 *Query) +{ + u32_block_array_index Result = {INVALID_BLOCK_ARRAY_INDEX}; + IterateOver(Array, E, Index) + { + if ( E == Query ) + { + Result = Index; + break; } } + return Result; +} + + + +link_internal b32 +IsValid(u32_block_array_index *Index) +{ + u32_block_array_index Test = {INVALID_BLOCK_ARRAY_INDEX}; + b32 Result = (AreEqual(Index, &Test) == False); + return Result; +} + +link_internal u32 * +Push( u32_block_array *Array, u32 *Element) +{ + Assert(Array->Memory); + + if (AtElements(Array) == Capacity(Array)) + { + NewBlock(Array); + } - u32 *Result = Array->Current->Elements + Array->Current->At; + u32 *Result = Set(Array, Element, AtElements(Array)); - Array->Current->Elements[Array->Current->At++] = *Element; + Array->ElementCount += 1; return Result; } +link_internal u32 * +Push( u32_block_array *Array ) +{ + u32 Element = {}; + auto Result = Push(Array, &Element); + return Result; +} + +link_internal void +Insert( u32_block_array *Array, u32_block_array_index Index, u32 *Element ) +{ + Assert(Index.Index <= LastIndex(Array).Index); + Assert(Array->Memory); + + // Alocate a new thingy + u32 *Prev = Push(Array); + + auto Last = LastIndex(Array); + + RangeIteratorReverseRange(I, s32(Last.Index), s32(Index.Index)) + { + auto E = GetPtr(Array, umm(I)); + *Prev = *E; + Prev = E; + } + + *Prev = *Element; +} + +link_internal void +Insert( u32_block_array *Array, u32 Index, u32 *Element ) +{ + Insert(Array, { .Index = Index }, Element); +} + +link_internal void +Shift( u32_block_array *Array, u32 *Element ) +{ + Insert(Array, { .Index = 0 }, Element); +} + +/* element_t.has_tag(do_editor_ui)? */ +/* { */ +/* do_editor_ui_for_container( block_array_t ) */ +/* } */ + + diff --git a/generated/block_array_c_u8_cursor_688856411.h b/generated/block_array_c_u8_cursor_688856411.h index 532bc11a6..fa980d32c 100644 --- a/generated/block_array_c_u8_cursor_688856411.h +++ b/generated/block_array_c_u8_cursor_688856411.h @@ -1,77 +1,180 @@ -// external/bonsai_stdlib/src/ansi_stream.cpp:3:0 +// external/bonsai_stdlib/src/poof_functions.h:2378:0 -link_internal u8_cursor_block* -Allocate_u8_cursor_block(memory_arena *Memory) + + +link_internal cs +CS( u8_cursor_block_array_index Index ) { - u8_cursor_block *Result = Allocate(u8_cursor_block, Memory, 1); - Result->Elements = Allocate(u8_cursor, Memory, 8); - return Result; + return FSz("(%u)", Index.Index); } -link_internal cs -CS(u8_cursor_block_array_index Index) +link_internal u8_cursor * +Set( u8_cursor_block_array *Arr, + u8_cursor *Element, + u8_cursor_block_array_index Index ) { - return FSz("(%u)(%u)", Index.BlockIndex, Index.ElementIndex); + Assert(Arr->BlockPtrs); + Assert(Index.Index < Capacity(Arr).Index); + u8_cursor_block *Block = GetBlock(Arr, Index); + umm ElementIndex = Index.Index % 8; + auto Slot = Block->Elements+ElementIndex; + *Slot = *Element; + return Slot; } link_internal void -RemoveUnordered(u8_cursor_block_array *Array, u8_cursor_block_array_index Index) +NewBlock( u8_cursor_block_array *Arr ) { - u8_cursor_block_array_index LastI = LastIndex(Array); + u8_cursor_block *NewBlock = Allocate( u8_cursor_block , Arr->Memory, 1); + u8_cursor_block **NewBlockPtrs = Allocate( u8_cursor_block*, Arr->Memory, Arr->BlockCount+1); + + RangeIterator_t(u32, BlockI, Arr->BlockCount) + { + NewBlockPtrs[BlockI] = Arr->BlockPtrs[BlockI]; + } - u8_cursor *Element = GetPtr(Array, Index); - u8_cursor *LastElement = GetPtr(Array, LastI); + NewBlockPtrs[Arr->BlockCount] = NewBlock; - *Element = *LastElement; + + + Arr->BlockPtrs = NewBlockPtrs; + Arr->BlockCount += 1; +} + +link_internal void +RemoveUnordered( u8_cursor_block_array *Array, u8_cursor_block_array_index Index) +{ + auto LastI = LastIndex(Array); + Assert(Index.Index <= LastI.Index); + + auto LastElement = GetPtr(Array, LastI); + Set(Array, LastElement, Index); + Array->ElementCount -= 1; +} + +link_internal void +RemoveOrdered( u8_cursor_block_array *Array, u8_cursor_block_array_index IndexToRemove) +{ + Assert(IndexToRemove.Index < Array->ElementCount); - Assert(Array->Current->At); - Array->Current->At -= 1; + u8_cursor *Prev = {}; - if (Array->Current->At == 0) + u8_cursor_block_array_index Max = AtElements(Array); + RangeIteratorRange_t(umm, Index, Max.Index, IndexToRemove.Index) { - // Walk the chain till we get to the second-last one - u8_cursor_block *Current = Array->First; - u8_cursor_block *LastB = LastI.Block; + u8_cursor *E = GetPtr(Array, Index); - while (Current->Next && Current->Next != LastB) + if (Prev) { - Current = Current->Next; + *Prev = *E; } - Assert(Current->Next == LastB || Current->Next == 0); - Array->Current = Current; + Prev = E; } + + Array->ElementCount -= 1; } -link_internal u8_cursor * -Push(u8_cursor_block_array *Array, u8_cursor *Element) +link_internal void +RemoveOrdered( u8_cursor_block_array *Array, u8_cursor *Element ) { - if (Array->Memory == 0) { Array->Memory = AllocateArena(); } - - if (Array->First == 0) { Array->First = Allocate_u8_cursor_block(Array->Memory); Array->Current = Array->First; } - - if (Array->Current->At == 8) + IterateOver(Array, E, I) { - if (Array->Current->Next) + if (E == Element) { - Array->Current = Array->Current->Next; - Assert(Array->Current->At == 0); + RemoveOrdered(Array, I); + break; } - else - { - u8_cursor_block *Next = Allocate_u8_cursor_block(Array->Memory); - Next->Index = Array->Current->Index + 1; + } +} - Array->Current->Next = Next; - Array->Current = Next; +link_internal u8_cursor_block_array_index +Find( u8_cursor_block_array *Array, u8_cursor *Query) +{ + u8_cursor_block_array_index Result = {INVALID_BLOCK_ARRAY_INDEX}; + IterateOver(Array, E, Index) + { + if ( E == Query ) + { + Result = Index; + break; } } + return Result; +} + + + +link_internal b32 +IsValid(u8_cursor_block_array_index *Index) +{ + u8_cursor_block_array_index Test = {INVALID_BLOCK_ARRAY_INDEX}; + b32 Result = (AreEqual(Index, &Test) == False); + return Result; +} + +link_internal u8_cursor * +Push( u8_cursor_block_array *Array, u8_cursor *Element) +{ + Assert(Array->Memory); + + if (AtElements(Array) == Capacity(Array)) + { + NewBlock(Array); + } - u8_cursor *Result = Array->Current->Elements + Array->Current->At; + u8_cursor *Result = Set(Array, Element, AtElements(Array)); - Array->Current->Elements[Array->Current->At++] = *Element; + Array->ElementCount += 1; return Result; } +link_internal u8_cursor * +Push( u8_cursor_block_array *Array ) +{ + u8_cursor Element = {}; + auto Result = Push(Array, &Element); + return Result; +} + +link_internal void +Insert( u8_cursor_block_array *Array, u8_cursor_block_array_index Index, u8_cursor *Element ) +{ + Assert(Index.Index <= LastIndex(Array).Index); + Assert(Array->Memory); + + // Alocate a new thingy + u8_cursor *Prev = Push(Array); + + auto Last = LastIndex(Array); + + RangeIteratorReverseRange(I, s32(Last.Index), s32(Index.Index)) + { + auto E = GetPtr(Array, umm(I)); + *Prev = *E; + Prev = E; + } + + *Prev = *Element; +} + +link_internal void +Insert( u8_cursor_block_array *Array, u32 Index, u8_cursor *Element ) +{ + Insert(Array, { .Index = Index }, Element); +} + +link_internal void +Shift( u8_cursor_block_array *Array, u8_cursor *Element ) +{ + Insert(Array, { .Index = 0 }, Element); +} + +/* element_t.has_tag(do_editor_ui)? */ +/* { */ +/* do_editor_ui_for_container( block_array_t ) */ +/* } */ + + diff --git a/generated/block_array_dummy_work_queue_entry_build_chunk_mesh_688853862.h b/generated/block_array_dummy_work_queue_entry_build_chunk_mesh_688853862.h new file mode 100644 index 000000000..9fe71a4f4 --- /dev/null +++ b/generated/block_array_dummy_work_queue_entry_build_chunk_mesh_688853862.h @@ -0,0 +1,363 @@ +// external/bonsai_stdlib/src/poof_functions.h:2600:0 + + + + +struct dummy_work_queue_entry_build_chunk_mesh_block +{ + /* u32 Index; */ + umm At; + dummy_work_queue_entry_build_chunk_mesh Elements[8]; +}; + +struct dummy_work_queue_entry_build_chunk_mesh_block_array_index +{ + umm Index; +}; + +struct dummy_work_queue_entry_build_chunk_mesh_block_array +{ + dummy_work_queue_entry_build_chunk_mesh_block **BlockPtrs; poof(@array_length(Element->BlockCount)) + u32 BlockCount; + u32 ElementCount; + memory_arena *Memory; poof(@no_serialize) + +}; + +link_internal dummy_work_queue_entry_build_chunk_mesh_block_array +DummyWorkQueueEntryBuildChunkMeshBlockArray(memory_arena *Memory) +{ + dummy_work_queue_entry_build_chunk_mesh_block_array Result = {}; + Result.Memory = Memory; + return Result; +} + +link_internal b32 +AreEqual(dummy_work_queue_entry_build_chunk_mesh_block_array_index *Thing1, dummy_work_queue_entry_build_chunk_mesh_block_array_index *Thing2) +{ + if (Thing1 && Thing2) + { + b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( dummy_work_queue_entry_build_chunk_mesh_block_array_index ) ); + + return Result; + } + else + { + return (Thing1 == Thing2); + } +} + +link_internal b32 +AreEqual(dummy_work_queue_entry_build_chunk_mesh_block_array_index Thing1, dummy_work_queue_entry_build_chunk_mesh_block_array_index Thing2) +{ + b32 Result = MemoryIsEqual((u8*)&Thing1, (u8*)&Thing2, sizeof( dummy_work_queue_entry_build_chunk_mesh_block_array_index ) ); + + return Result; +} + + +typedef dummy_work_queue_entry_build_chunk_mesh_block_array dummy_work_queue_entry_build_chunk_mesh_paged_list; + +link_internal dummy_work_queue_entry_build_chunk_mesh_block_array_index +operator++( dummy_work_queue_entry_build_chunk_mesh_block_array_index &I0 ) +{ + I0.Index++; + return I0; +} + +link_internal b32 +operator<( dummy_work_queue_entry_build_chunk_mesh_block_array_index I0, dummy_work_queue_entry_build_chunk_mesh_block_array_index I1 ) +{ + b32 Result = I0.Index < I1.Index; + return Result; +} + +link_internal b32 +operator==( dummy_work_queue_entry_build_chunk_mesh_block_array_index I0, dummy_work_queue_entry_build_chunk_mesh_block_array_index I1 ) +{ + b32 Result = I0.Index == I1.Index; + return Result; +} + +link_inline umm +GetIndex( dummy_work_queue_entry_build_chunk_mesh_block_array_index *Index) +{ + umm Result = Index->Index; + return Result; +} + + +link_internal dummy_work_queue_entry_build_chunk_mesh_block_array_index +ZerothIndex( dummy_work_queue_entry_build_chunk_mesh_block_array *Arr ) +{ + return {}; +} + +link_internal dummy_work_queue_entry_build_chunk_mesh_block_array_index +Capacity( dummy_work_queue_entry_build_chunk_mesh_block_array *Arr ) +{ + dummy_work_queue_entry_build_chunk_mesh_block_array_index Result = {Arr->BlockCount * 8}; + return Result; +} + +link_internal dummy_work_queue_entry_build_chunk_mesh_block_array_index +AtElements( dummy_work_queue_entry_build_chunk_mesh_block_array *Arr ) +{ + dummy_work_queue_entry_build_chunk_mesh_block_array_index Result = {Arr->ElementCount}; + return Result; +} + + +link_internal umm +TotalElements( dummy_work_queue_entry_build_chunk_mesh_block_array *Arr ) +{ + umm Result = AtElements(Arr).Index; + return Result; +} + + +link_internal dummy_work_queue_entry_build_chunk_mesh_block_array_index +LastIndex( dummy_work_queue_entry_build_chunk_mesh_block_array *Arr ) +{ + dummy_work_queue_entry_build_chunk_mesh_block_array_index Result = {}; + umm Count = AtElements(Arr).Index; + if (Count) Result.Index = Count-1; + return Result; +} + +link_internal umm +Count( dummy_work_queue_entry_build_chunk_mesh_block_array *Arr ) +{ + auto Result = AtElements(Arr).Index; + return Result; +} + +link_internal dummy_work_queue_entry_build_chunk_mesh_block * +GetBlock( dummy_work_queue_entry_build_chunk_mesh_block_array *Arr, dummy_work_queue_entry_build_chunk_mesh_block_array_index Index ) +{ + umm BlockIndex = Index.Index / 8; + Assert(BlockIndex < Arr->BlockCount); + dummy_work_queue_entry_build_chunk_mesh_block *Block = Arr->BlockPtrs[BlockIndex]; + return Block; +} + +link_internal dummy_work_queue_entry_build_chunk_mesh * +GetPtr( dummy_work_queue_entry_build_chunk_mesh_block_array *Arr, dummy_work_queue_entry_build_chunk_mesh_block_array_index Index ) +{ + Assert(Arr->BlockPtrs); + Assert(Index.Index < Capacity(Arr).Index); + + dummy_work_queue_entry_build_chunk_mesh_block *Block = GetBlock(Arr, Index); + + umm ElementIndex = Index.Index % 8; + dummy_work_queue_entry_build_chunk_mesh *Result = (Block->Elements + ElementIndex); + return Result; +} + + +link_internal dummy_work_queue_entry_build_chunk_mesh * +GetPtr( dummy_work_queue_entry_build_chunk_mesh_block_array *Arr, umm Index ) +{ + dummy_work_queue_entry_build_chunk_mesh_block_array_index I = {Index}; + return GetPtr(Arr, I); +} + + +link_internal dummy_work_queue_entry_build_chunk_mesh * +TryGetPtr( dummy_work_queue_entry_build_chunk_mesh_block_array *Arr, dummy_work_queue_entry_build_chunk_mesh_block_array_index Index) +{ + dummy_work_queue_entry_build_chunk_mesh * Result = {}; + if (Arr->BlockPtrs && Index < AtElements(Arr)) + { + Result = GetPtr(Arr, Index); + } + return Result; +} + +link_internal dummy_work_queue_entry_build_chunk_mesh * +TryGetPtr( dummy_work_queue_entry_build_chunk_mesh_block_array *Arr, umm Index) +{ + auto Result = TryGetPtr(Arr, dummy_work_queue_entry_build_chunk_mesh_block_array_index{Index}); + return Result; +} + + + + + +link_internal cs +CS( dummy_work_queue_entry_build_chunk_mesh_block_array_index Index ) +{ + return FSz("(%u)", Index.Index); +} + +link_internal dummy_work_queue_entry_build_chunk_mesh * +Set( dummy_work_queue_entry_build_chunk_mesh_block_array *Arr, + dummy_work_queue_entry_build_chunk_mesh *Element, + dummy_work_queue_entry_build_chunk_mesh_block_array_index Index ) +{ + Assert(Arr->BlockPtrs); + Assert(Index.Index < Capacity(Arr).Index); + dummy_work_queue_entry_build_chunk_mesh_block *Block = GetBlock(Arr, Index); + umm ElementIndex = Index.Index % 8; + auto Slot = Block->Elements+ElementIndex; + *Slot = *Element; + return Slot; +} + +link_internal void +NewBlock( dummy_work_queue_entry_build_chunk_mesh_block_array *Arr ) +{ + dummy_work_queue_entry_build_chunk_mesh_block *NewBlock = Allocate( dummy_work_queue_entry_build_chunk_mesh_block , Arr->Memory, 1); + dummy_work_queue_entry_build_chunk_mesh_block **NewBlockPtrs = Allocate( dummy_work_queue_entry_build_chunk_mesh_block*, Arr->Memory, Arr->BlockCount+1); + + RangeIterator_t(u32, BlockI, Arr->BlockCount) + { + NewBlockPtrs[BlockI] = Arr->BlockPtrs[BlockI]; + } + + NewBlockPtrs[Arr->BlockCount] = NewBlock; + + + + Arr->BlockPtrs = NewBlockPtrs; + Arr->BlockCount += 1; +} + +link_internal void +RemoveUnordered( dummy_work_queue_entry_build_chunk_mesh_block_array *Array, dummy_work_queue_entry_build_chunk_mesh_block_array_index Index) +{ + auto LastI = LastIndex(Array); + Assert(Index.Index <= LastI.Index); + + auto LastElement = GetPtr(Array, LastI); + Set(Array, LastElement, Index); + Array->ElementCount -= 1; +} + +link_internal void +RemoveOrdered( dummy_work_queue_entry_build_chunk_mesh_block_array *Array, dummy_work_queue_entry_build_chunk_mesh_block_array_index IndexToRemove) +{ + Assert(IndexToRemove.Index < Array->ElementCount); + + dummy_work_queue_entry_build_chunk_mesh *Prev = {}; + + dummy_work_queue_entry_build_chunk_mesh_block_array_index Max = AtElements(Array); + RangeIteratorRange_t(umm, Index, Max.Index, IndexToRemove.Index) + { + dummy_work_queue_entry_build_chunk_mesh *E = GetPtr(Array, Index); + + if (Prev) + { + *Prev = *E; + } + + Prev = E; + } + + Array->ElementCount -= 1; +} + +link_internal void +RemoveOrdered( dummy_work_queue_entry_build_chunk_mesh_block_array *Array, dummy_work_queue_entry_build_chunk_mesh *Element ) +{ + IterateOver(Array, E, I) + { + if (E == Element) + { + RemoveOrdered(Array, I); + break; + } + } +} + +link_internal dummy_work_queue_entry_build_chunk_mesh_block_array_index +Find( dummy_work_queue_entry_build_chunk_mesh_block_array *Array, dummy_work_queue_entry_build_chunk_mesh *Query) +{ + dummy_work_queue_entry_build_chunk_mesh_block_array_index Result = {INVALID_BLOCK_ARRAY_INDEX}; + IterateOver(Array, E, Index) + { + if ( E == Query ) + { + Result = Index; + break; + } + } + return Result; +} + + + +link_internal b32 +IsValid(dummy_work_queue_entry_build_chunk_mesh_block_array_index *Index) +{ + dummy_work_queue_entry_build_chunk_mesh_block_array_index Test = {INVALID_BLOCK_ARRAY_INDEX}; + b32 Result = (AreEqual(Index, &Test) == False); + return Result; +} + +link_internal dummy_work_queue_entry_build_chunk_mesh * +Push( dummy_work_queue_entry_build_chunk_mesh_block_array *Array, dummy_work_queue_entry_build_chunk_mesh *Element) +{ + Assert(Array->Memory); + + if (AtElements(Array) == Capacity(Array)) + { + NewBlock(Array); + } + + dummy_work_queue_entry_build_chunk_mesh *Result = Set(Array, Element, AtElements(Array)); + + Array->ElementCount += 1; + + return Result; +} + +link_internal dummy_work_queue_entry_build_chunk_mesh * +Push( dummy_work_queue_entry_build_chunk_mesh_block_array *Array ) +{ + dummy_work_queue_entry_build_chunk_mesh Element = {}; + auto Result = Push(Array, &Element); + return Result; +} + +link_internal void +Insert( dummy_work_queue_entry_build_chunk_mesh_block_array *Array, dummy_work_queue_entry_build_chunk_mesh_block_array_index Index, dummy_work_queue_entry_build_chunk_mesh *Element ) +{ + Assert(Index.Index <= LastIndex(Array).Index); + Assert(Array->Memory); + + // Alocate a new thingy + dummy_work_queue_entry_build_chunk_mesh *Prev = Push(Array); + + auto Last = LastIndex(Array); + + RangeIteratorReverseRange(I, s32(Last.Index), s32(Index.Index)) + { + auto E = GetPtr(Array, umm(I)); + *Prev = *E; + Prev = E; + } + + *Prev = *Element; +} + +link_internal void +Insert( dummy_work_queue_entry_build_chunk_mesh_block_array *Array, u32 Index, dummy_work_queue_entry_build_chunk_mesh *Element ) +{ + Insert(Array, { .Index = Index }, Element); +} + +link_internal void +Shift( dummy_work_queue_entry_build_chunk_mesh_block_array *Array, dummy_work_queue_entry_build_chunk_mesh *Element ) +{ + Insert(Array, { .Index = 0 }, Element); +} + +/* element_t.has_tag(do_editor_ui)? */ +/* { */ +/* do_editor_ui_for_container( block_array_t ) */ +/* } */ + + + diff --git a/generated/block_array_entity_688856407.h b/generated/block_array_entity_688856407.h index d81d4e12e..2354c4120 100644 --- a/generated/block_array_entity_688856407.h +++ b/generated/block_array_entity_688856407.h @@ -1,240 +1,363 @@ -// src/engine/serdes.cpp:366:0 +// external/bonsai_stdlib/src/poof_functions.h:2600:0 + + + struct entity_block { - u32 Index; - u32 At; - entity *Elements; - entity_block *Next; + /* u32 Index; */ + umm At; + entity Elements[8]; }; struct entity_block_array_index { - entity_block *Block; - u32 BlockIndex; - u32 ElementIndex; + umm Index; }; struct entity_block_array { - entity_block *First; - entity_block *Current; + entity_block **BlockPtrs; poof(@array_length(Element->BlockCount)) + u32 BlockCount; + u32 ElementCount; memory_arena *Memory; poof(@no_serialize) }; -typedef entity_block_array entity_paged_list; +link_internal entity_block_array +EntityBlockArray(memory_arena *Memory) +{ + entity_block_array Result = {}; + Result.Memory = Memory; + return Result; +} -link_internal entity_block_array_index -operator++(entity_block_array_index &I0) +link_internal b32 +AreEqual(entity_block_array_index *Thing1, entity_block_array_index *Thing2) { - if (I0.Block) + if (Thing1 && Thing2) { - if (I0.ElementIndex == 8-1) - { - I0.ElementIndex = 0; - I0.BlockIndex++; - I0.Block = I0.Block->Next; - } - else - { - I0.ElementIndex++; - } + b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( entity_block_array_index ) ); + + return Result; } else { - I0.ElementIndex++; + return (Thing1 == Thing2); } +} + +link_internal b32 +AreEqual(entity_block_array_index Thing1, entity_block_array_index Thing2) +{ + b32 Result = MemoryIsEqual((u8*)&Thing1, (u8*)&Thing2, sizeof( entity_block_array_index ) ); + + return Result; +} + + +typedef entity_block_array entity_paged_list; + +link_internal entity_block_array_index +operator++( entity_block_array_index &I0 ) +{ + I0.Index++; return I0; } link_internal b32 -operator<(entity_block_array_index I0, entity_block_array_index I1) +operator<( entity_block_array_index I0, entity_block_array_index I1 ) { - b32 Result = I0.BlockIndex < I1.BlockIndex || (I0.BlockIndex == I1.BlockIndex & I0.ElementIndex < I1.ElementIndex); + b32 Result = I0.Index < I1.Index; + return Result; +} + +link_internal b32 +operator==( entity_block_array_index I0, entity_block_array_index I1 ) +{ + b32 Result = I0.Index == I1.Index; return Result; } link_inline umm -GetIndex(entity_block_array_index *Index) +GetIndex( entity_block_array_index *Index) { - umm Result = Index->ElementIndex + (Index->BlockIndex*8); + umm Result = Index->Index; return Result; } + link_internal entity_block_array_index -ZerothIndex(entity_block_array *Arr) +ZerothIndex( entity_block_array *Arr ) { - entity_block_array_index Result = {}; - Result.Block = Arr->First; - /* Assert(Result.Block->Index == 0); */ - return Result; + return {}; } -link_internal umm -TotalElements(entity_block_array *Arr) +link_internal entity_block_array_index +Capacity( entity_block_array *Arr ) { - umm Result = 0; - if (Arr->Current) - { - Result = (Arr->Current->Index * 8) + Arr->Current->At; - } + entity_block_array_index Result = {Arr->BlockCount * 8}; return Result; } link_internal entity_block_array_index -LastIndex(entity_block_array *Arr) +AtElements( entity_block_array *Arr ) { - entity_block_array_index Result = {}; - if (Arr->Current) - { - Result.Block = Arr->Current; - Result.BlockIndex = Arr->Current->Index; - Result.ElementIndex = Arr->Current->At; - Assert(Result.ElementIndex); - Result.ElementIndex--; - } + entity_block_array_index Result = {Arr->ElementCount}; return Result; } + +link_internal umm +TotalElements( entity_block_array *Arr ) +{ + umm Result = AtElements(Arr).Index; + return Result; +} + + link_internal entity_block_array_index -AtElements(entity_block_array *Arr) +LastIndex( entity_block_array *Arr ) { entity_block_array_index Result = {}; - if (Arr->Current) - { - Result.Block = Arr->Current; - Result.BlockIndex = Arr->Current->Index; - Result.ElementIndex = Arr->Current->At; - } + umm Count = AtElements(Arr).Index; + if (Count) Result.Index = Count-1; return Result; } -link_internal entity * -GetPtr(entity_block_array *Arr, entity_block_array_index Index) +link_internal umm +Count( entity_block_array *Arr ) { - entity *Result = {}; - if (Index.Block) { Result = Index.Block->Elements + Index.ElementIndex; } + auto Result = AtElements(Arr).Index; return Result; } +link_internal entity_block * +GetBlock( entity_block_array *Arr, entity_block_array_index Index ) +{ + umm BlockIndex = Index.Index / 8; + Assert(BlockIndex < Arr->BlockCount); + entity_block *Block = Arr->BlockPtrs[BlockIndex]; + return Block; +} + link_internal entity * -GetPtr(entity_block *Block, umm Index) +GetPtr( entity_block_array *Arr, entity_block_array_index Index ) { - entity *Result = 0; - if (Index < Block->At) { Result = Block->Elements + Index; } + Assert(Arr->BlockPtrs); + Assert(Index.Index < Capacity(Arr).Index); + + entity_block *Block = GetBlock(Arr, Index); + + umm ElementIndex = Index.Index % 8; + entity *Result = (Block->Elements + ElementIndex); return Result; } + link_internal entity * -GetPtr(entity_block_array *Arr, umm Index) +GetPtr( entity_block_array *Arr, umm Index ) { - umm BlockIndex = Index / 8; - umm ElementIndex = Index % 8; + entity_block_array_index I = {Index}; + return GetPtr(Arr, I); +} + - umm AtBlock = 0; - entity_block *Block = Arr->First; - while (AtBlock++ < BlockIndex) +link_internal entity * +TryGetPtr( entity_block_array *Arr, entity_block_array_index Index) +{ + entity * Result = {}; + if (Arr->BlockPtrs && Index < AtElements(Arr)) { - Block = Block->Next; + Result = GetPtr(Arr, Index); } - - entity *Result = Block->Elements+ElementIndex; return Result; } link_internal entity * -TryGetPtr(entity_block_array *Arr, umm Index) +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); } + auto Result = TryGetPtr(Arr, entity_block_array_index{Index}); return Result; } -link_internal u32 -AtElements(entity_block *Block) + + + + +link_internal cs +CS( entity_block_array_index Index ) { - return Block->At; + return FSz("(%u)", Index.Index); } - -link_internal entity_block* -Allocate_entity_block(memory_arena *Memory) +link_internal entity * +Set( entity_block_array *Arr, + entity *Element, + entity_block_array_index Index ) { - entity_block *Result = Allocate(entity_block, Memory, 1); - Result->Elements = Allocate(entity, Memory, 8); - return Result; + Assert(Arr->BlockPtrs); + Assert(Index.Index < Capacity(Arr).Index); + entity_block *Block = GetBlock(Arr, Index); + umm ElementIndex = Index.Index % 8; + auto Slot = Block->Elements+ElementIndex; + *Slot = *Element; + return Slot; } -link_internal cs -CS(entity_block_array_index Index) +link_internal void +NewBlock( entity_block_array *Arr ) { - return FSz("(%u)(%u)", Index.BlockIndex, Index.ElementIndex); + entity_block *NewBlock = Allocate( entity_block , Arr->Memory, 1); + entity_block **NewBlockPtrs = Allocate( entity_block*, Arr->Memory, Arr->BlockCount+1); + + RangeIterator_t(u32, BlockI, Arr->BlockCount) + { + NewBlockPtrs[BlockI] = Arr->BlockPtrs[BlockI]; + } + + NewBlockPtrs[Arr->BlockCount] = NewBlock; + + + + Arr->BlockPtrs = NewBlockPtrs; + Arr->BlockCount += 1; } link_internal void -RemoveUnordered(entity_block_array *Array, entity_block_array_index Index) +RemoveUnordered( entity_block_array *Array, entity_block_array_index Index) { - entity_block_array_index LastI = LastIndex(Array); + auto LastI = LastIndex(Array); + Assert(Index.Index <= LastI.Index); - entity *Element = GetPtr(Array, Index); - entity *LastElement = GetPtr(Array, LastI); + auto LastElement = GetPtr(Array, LastI); + Set(Array, LastElement, Index); + Array->ElementCount -= 1; +} - *Element = *LastElement; +link_internal void +RemoveOrdered( entity_block_array *Array, entity_block_array_index IndexToRemove) +{ + Assert(IndexToRemove.Index < Array->ElementCount); - Assert(Array->Current->At); - Array->Current->At -= 1; + entity *Prev = {}; - if (Array->Current->At == 0) + entity_block_array_index Max = AtElements(Array); + RangeIteratorRange_t(umm, Index, Max.Index, IndexToRemove.Index) { - // Walk the chain till we get to the second-last one - entity_block *Current = Array->First; - entity_block *LastB = LastI.Block; + entity *E = GetPtr(Array, Index); - while (Current->Next && Current->Next != LastB) + if (Prev) { - Current = Current->Next; + *Prev = *E; } - Assert(Current->Next == LastB || Current->Next == 0); - Array->Current = Current; + Prev = E; } + + Array->ElementCount -= 1; } -link_internal entity * -Push(entity_block_array *Array, entity *Element) +link_internal void +RemoveOrdered( entity_block_array *Array, entity *Element ) { - if (Array->Memory == 0) { Array->Memory = AllocateArena(); } - - if (Array->First == 0) { Array->First = Allocate_entity_block(Array->Memory); Array->Current = Array->First; } - - if (Array->Current->At == 8) + IterateOver(Array, E, I) { - if (Array->Current->Next) + if (E == Element) { - Array->Current = Array->Current->Next; - Assert(Array->Current->At == 0); + RemoveOrdered(Array, I); + break; } - else - { - entity_block *Next = Allocate_entity_block(Array->Memory); - Next->Index = Array->Current->Index + 1; + } +} - Array->Current->Next = Next; - Array->Current = Next; +link_internal entity_block_array_index +Find( entity_block_array *Array, entity *Query) +{ + entity_block_array_index Result = {INVALID_BLOCK_ARRAY_INDEX}; + IterateOver(Array, E, Index) + { + if ( E == Query ) + { + Result = Index; + break; } } + return Result; +} + + + +link_internal b32 +IsValid(entity_block_array_index *Index) +{ + entity_block_array_index Test = {INVALID_BLOCK_ARRAY_INDEX}; + b32 Result = (AreEqual(Index, &Test) == False); + return Result; +} + +link_internal entity * +Push( entity_block_array *Array, entity *Element) +{ + Assert(Array->Memory); + + if (AtElements(Array) == Capacity(Array)) + { + NewBlock(Array); + } - entity *Result = Array->Current->Elements + Array->Current->At; + entity *Result = Set(Array, Element, AtElements(Array)); - Array->Current->Elements[Array->Current->At++] = *Element; + Array->ElementCount += 1; return Result; } +link_internal entity * +Push( entity_block_array *Array ) +{ + entity Element = {}; + auto Result = Push(Array, &Element); + return Result; +} + +link_internal void +Insert( entity_block_array *Array, entity_block_array_index Index, entity *Element ) +{ + Assert(Index.Index <= LastIndex(Array).Index); + Assert(Array->Memory); + + // Alocate a new thingy + entity *Prev = Push(Array); + + auto Last = LastIndex(Array); + + RangeIteratorReverseRange(I, s32(Last.Index), s32(Index.Index)) + { + auto E = GetPtr(Array, umm(I)); + *Prev = *E; + Prev = E; + } + + *Prev = *Element; +} + +link_internal void +Insert( entity_block_array *Array, u32 Index, entity *Element ) +{ + Insert(Array, { .Index = Index }, Element); +} + +link_internal void +Shift( entity_block_array *Array, entity *Element ) +{ + Insert(Array, { .Index = 0 }, Element); +} + +/* element_t.has_tag(do_editor_ui)? */ +/* { */ +/* do_editor_ui_for_container( block_array_t ) */ +/* } */ + + diff --git a/generated/block_array_entity_ptr_688856411.h b/generated/block_array_entity_ptr_688856411.h deleted file mode 100644 index 90f3be1cf..000000000 --- a/generated/block_array_entity_ptr_688856411.h +++ /dev/null @@ -1,240 +0,0 @@ -// src/engine/world_chunk.h:328:0 - -struct entity_ptr_block -{ - u32 Index; - u32 At; - entity_ptr *Elements; - entity_ptr_block *Next; -}; - -struct entity_ptr_block_array_index -{ - entity_ptr_block *Block; - u32 BlockIndex; - u32 ElementIndex; -}; - -struct entity_ptr_block_array -{ - entity_ptr_block *First; - entity_ptr_block *Current; - memory_arena *Memory; poof(@no_serialize) - -}; - -typedef entity_ptr_block_array entity_ptr_paged_list; - -link_internal entity_ptr_block_array_index -operator++(entity_ptr_block_array_index &I0) -{ - if (I0.Block) - { - if (I0.ElementIndex == 8-1) - { - I0.ElementIndex = 0; - I0.BlockIndex++; - I0.Block = I0.Block->Next; - } - else - { - I0.ElementIndex++; - } - } - else - { - I0.ElementIndex++; - } - return I0; -} - -link_internal b32 -operator<(entity_ptr_block_array_index I0, entity_ptr_block_array_index I1) -{ - b32 Result = I0.BlockIndex < I1.BlockIndex || (I0.BlockIndex == I1.BlockIndex & I0.ElementIndex < I1.ElementIndex); - return Result; -} - -link_inline umm -GetIndex(entity_ptr_block_array_index *Index) -{ - umm Result = Index->ElementIndex + (Index->BlockIndex*8); - return Result; -} - -link_internal entity_ptr_block_array_index -ZerothIndex(entity_ptr_block_array *Arr) -{ - entity_ptr_block_array_index Result = {}; - Result.Block = Arr->First; - /* Assert(Result.Block->Index == 0); */ - return Result; -} - -link_internal umm -TotalElements(entity_ptr_block_array *Arr) -{ - umm Result = 0; - if (Arr->Current) - { - Result = (Arr->Current->Index * 8) + Arr->Current->At; - } - return Result; -} - -link_internal entity_ptr_block_array_index -LastIndex(entity_ptr_block_array *Arr) -{ - entity_ptr_block_array_index Result = {}; - if (Arr->Current) - { - Result.Block = Arr->Current; - Result.BlockIndex = Arr->Current->Index; - Result.ElementIndex = Arr->Current->At; - Assert(Result.ElementIndex); - Result.ElementIndex--; - } - return Result; -} - -link_internal entity_ptr_block_array_index -AtElements(entity_ptr_block_array *Arr) -{ - entity_ptr_block_array_index Result = {}; - if (Arr->Current) - { - Result.Block = Arr->Current; - Result.BlockIndex = Arr->Current->Index; - Result.ElementIndex = Arr->Current->At; - } - return Result; -} - -link_internal entity_ptr * -GetPtr(entity_ptr_block_array *Arr, entity_ptr_block_array_index Index) -{ - entity_ptr *Result = {}; - if (Index.Block) { Result = Index.Block->Elements + Index.ElementIndex; } - return Result; -} - -link_internal entity_ptr * -GetPtr(entity_ptr_block *Block, umm Index) -{ - entity_ptr *Result = 0; - if (Index < Block->At) { Result = Block->Elements + Index; } - return Result; -} - -link_internal entity_ptr * -GetPtr(entity_ptr_block_array *Arr, umm Index) -{ - umm BlockIndex = Index / 8; - umm ElementIndex = Index % 8; - - umm AtBlock = 0; - entity_ptr_block *Block = Arr->First; - while (AtBlock++ < BlockIndex) - { - Block = Block->Next; - } - - entity_ptr *Result = Block->Elements+ElementIndex; - 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) -{ - return Block->At; -} - - -link_internal entity_ptr_block* -Allocate_entity_ptr_block(memory_arena *Memory) -{ - entity_ptr_block *Result = Allocate(entity_ptr_block, Memory, 1); - Result->Elements = Allocate(entity_ptr, Memory, 8); - return Result; -} - -link_internal cs -CS(entity_ptr_block_array_index Index) -{ - return FSz("(%u)(%u)", Index.BlockIndex, Index.ElementIndex); -} - -link_internal void -RemoveUnordered(entity_ptr_block_array *Array, entity_ptr_block_array_index Index) -{ - entity_ptr_block_array_index LastI = LastIndex(Array); - - entity_ptr *Element = GetPtr(Array, Index); - entity_ptr *LastElement = GetPtr(Array, LastI); - - *Element = *LastElement; - - Assert(Array->Current->At); - Array->Current->At -= 1; - - if (Array->Current->At == 0) - { - // Walk the chain till we get to the second-last one - entity_ptr_block *Current = Array->First; - entity_ptr_block *LastB = LastI.Block; - - while (Current->Next && Current->Next != LastB) - { - Current = Current->Next; - } - - Assert(Current->Next == LastB || Current->Next == 0); - Array->Current = Current; - } -} - -link_internal entity_ptr * -Push(entity_ptr_block_array *Array, entity_ptr *Element) -{ - if (Array->Memory == 0) { Array->Memory = AllocateArena(); } - - if (Array->First == 0) { Array->First = Allocate_entity_ptr_block(Array->Memory); Array->Current = Array->First; } - - if (Array->Current->At == 8) - { - if (Array->Current->Next) - { - Array->Current = Array->Current->Next; - Assert(Array->Current->At == 0); - } - else - { - entity_ptr_block *Next = Allocate_entity_ptr_block(Array->Memory); - Next->Index = Array->Current->Index + 1; - - Array->Current->Next = Next; - Array->Current = Next; - } - } - - entity_ptr *Result = Array->Current->Elements + Array->Current->At; - - Array->Current->Elements[Array->Current->At++] = *Element; - - return Result; -} - - diff --git a/generated/block_array_entity_ptr_688856411_h.h b/generated/block_array_entity_ptr_688856411_h.h new file mode 100644 index 000000000..8997d9e12 --- /dev/null +++ b/generated/block_array_entity_ptr_688856411_h.h @@ -0,0 +1,183 @@ +// external/bonsai_stdlib/src/poof_functions.h:2211:0 + + + + +struct entity_ptr_block +{ + /* u32 Index; */ + umm At; + entity_ptr Elements[8]; +}; + +struct entity_ptr_block_array_index +{ + umm Index; +}; + +struct entity_ptr_block_array +{ + entity_ptr_block **BlockPtrs; poof(@array_length(Element->BlockCount)) + u32 BlockCount; + u32 ElementCount; + memory_arena *Memory; poof(@no_serialize) + +}; + +link_internal entity_ptr_block_array +EntityPtrBlockArray(memory_arena *Memory) +{ + entity_ptr_block_array Result = {}; + Result.Memory = Memory; + return Result; +} + +link_internal b32 +AreEqual(entity_ptr_block_array_index *Thing1, entity_ptr_block_array_index *Thing2) +{ + if (Thing1 && Thing2) + { + b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( entity_ptr_block_array_index ) ); + + return Result; + } + else + { + return (Thing1 == Thing2); + } +} + +link_internal b32 +AreEqual(entity_ptr_block_array_index Thing1, entity_ptr_block_array_index Thing2) +{ + b32 Result = MemoryIsEqual((u8*)&Thing1, (u8*)&Thing2, sizeof( entity_ptr_block_array_index ) ); + + return Result; +} + + +typedef entity_ptr_block_array entity_ptr_paged_list; + +link_internal entity_ptr_block_array_index +operator++( entity_ptr_block_array_index &I0 ) +{ + I0.Index++; + return I0; +} + +link_internal b32 +operator<( entity_ptr_block_array_index I0, entity_ptr_block_array_index I1 ) +{ + b32 Result = I0.Index < I1.Index; + return Result; +} + +link_internal b32 +operator==( entity_ptr_block_array_index I0, entity_ptr_block_array_index I1 ) +{ + b32 Result = I0.Index == I1.Index; + return Result; +} + +link_inline umm +GetIndex( entity_ptr_block_array_index *Index) +{ + umm Result = Index->Index; + return Result; +} + + +link_internal entity_ptr_block_array_index +ZerothIndex( entity_ptr_block_array *Arr ) +{ + return {}; +} + +link_internal entity_ptr_block_array_index +Capacity( entity_ptr_block_array *Arr ) +{ + entity_ptr_block_array_index Result = {Arr->BlockCount * 8}; + return Result; +} + +link_internal entity_ptr_block_array_index +AtElements( entity_ptr_block_array *Arr ) +{ + entity_ptr_block_array_index Result = {Arr->ElementCount}; + return Result; +} + + +link_internal umm +TotalElements( entity_ptr_block_array *Arr ) +{ + umm Result = AtElements(Arr).Index; + return Result; +} + + +link_internal entity_ptr_block_array_index +LastIndex( entity_ptr_block_array *Arr ) +{ + entity_ptr_block_array_index Result = {}; + umm Count = AtElements(Arr).Index; + if (Count) Result.Index = Count-1; + return Result; +} + +link_internal umm +Count( entity_ptr_block_array *Arr ) +{ + auto Result = AtElements(Arr).Index; + return Result; +} + +link_internal entity_ptr_block * +GetBlock( entity_ptr_block_array *Arr, entity_ptr_block_array_index Index ) +{ + umm BlockIndex = Index.Index / 8; + Assert(BlockIndex < Arr->BlockCount); + entity_ptr_block *Block = Arr->BlockPtrs[BlockIndex]; + return Block; +} + +link_internal entity_ptr +GetPtr( entity_ptr_block_array *Arr, entity_ptr_block_array_index Index ) +{ + Assert(Arr->BlockPtrs); + Assert(Index.Index < Capacity(Arr).Index); + + entity_ptr_block *Block = GetBlock(Arr, Index); + + umm ElementIndex = Index.Index % 8; + entity_ptr Result = *(Block->Elements + ElementIndex); + return Result; +} + + +link_internal entity_ptr +GetPtr( entity_ptr_block_array *Arr, umm Index ) +{ + entity_ptr_block_array_index I = {Index}; + return GetPtr(Arr, I); +} + + +link_internal entity_ptr +TryGetPtr( entity_ptr_block_array *Arr, entity_ptr_block_array_index Index) +{ + entity_ptr Result = {}; + if (Arr->BlockPtrs && Index < AtElements(Arr)) + { + Result = GetPtr(Arr, Index); + } + return Result; +} + +link_internal entity_ptr +TryGetPtr( entity_ptr_block_array *Arr, umm Index) +{ + auto Result = TryGetPtr(Arr, entity_ptr_block_array_index{Index}); + return Result; +} + diff --git a/generated/block_array_file_traversal_node_688853862.h b/generated/block_array_file_traversal_node_688853862.h index d1276ec3d..2b6b2dd76 100644 --- a/generated/block_array_file_traversal_node_688853862.h +++ b/generated/block_array_file_traversal_node_688853862.h @@ -1,240 +1,363 @@ -// external/bonsai_stdlib/src/file.cpp:6:0 +// external/bonsai_stdlib/src/poof_functions.h:2600:0 + + + struct file_traversal_node_block { - u32 Index; - u32 At; - file_traversal_node *Elements; - file_traversal_node_block *Next; + /* u32 Index; */ + umm At; + file_traversal_node Elements[8]; }; struct file_traversal_node_block_array_index { - file_traversal_node_block *Block; - u32 BlockIndex; - u32 ElementIndex; + umm Index; }; struct file_traversal_node_block_array { - file_traversal_node_block *First; - file_traversal_node_block *Current; + file_traversal_node_block **BlockPtrs; poof(@array_length(Element->BlockCount)) + u32 BlockCount; + u32 ElementCount; memory_arena *Memory; poof(@no_serialize) }; -typedef file_traversal_node_block_array file_traversal_node_paged_list; +link_internal file_traversal_node_block_array +FileTraversalNodeBlockArray(memory_arena *Memory) +{ + file_traversal_node_block_array Result = {}; + Result.Memory = Memory; + return Result; +} -link_internal file_traversal_node_block_array_index -operator++(file_traversal_node_block_array_index &I0) +link_internal b32 +AreEqual(file_traversal_node_block_array_index *Thing1, file_traversal_node_block_array_index *Thing2) { - if (I0.Block) + if (Thing1 && Thing2) { - if (I0.ElementIndex == 8-1) - { - I0.ElementIndex = 0; - I0.BlockIndex++; - I0.Block = I0.Block->Next; - } - else - { - I0.ElementIndex++; - } + b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( file_traversal_node_block_array_index ) ); + + return Result; } else { - I0.ElementIndex++; + return (Thing1 == Thing2); } +} + +link_internal b32 +AreEqual(file_traversal_node_block_array_index Thing1, file_traversal_node_block_array_index Thing2) +{ + b32 Result = MemoryIsEqual((u8*)&Thing1, (u8*)&Thing2, sizeof( file_traversal_node_block_array_index ) ); + + return Result; +} + + +typedef file_traversal_node_block_array file_traversal_node_paged_list; + +link_internal file_traversal_node_block_array_index +operator++( file_traversal_node_block_array_index &I0 ) +{ + I0.Index++; return I0; } link_internal b32 -operator<(file_traversal_node_block_array_index I0, file_traversal_node_block_array_index I1) +operator<( file_traversal_node_block_array_index I0, file_traversal_node_block_array_index I1 ) { - b32 Result = I0.BlockIndex < I1.BlockIndex || (I0.BlockIndex == I1.BlockIndex & I0.ElementIndex < I1.ElementIndex); + b32 Result = I0.Index < I1.Index; + return Result; +} + +link_internal b32 +operator==( file_traversal_node_block_array_index I0, file_traversal_node_block_array_index I1 ) +{ + b32 Result = I0.Index == I1.Index; return Result; } link_inline umm -GetIndex(file_traversal_node_block_array_index *Index) +GetIndex( file_traversal_node_block_array_index *Index) { - umm Result = Index->ElementIndex + (Index->BlockIndex*8); + umm Result = Index->Index; return Result; } + link_internal file_traversal_node_block_array_index -ZerothIndex(file_traversal_node_block_array *Arr) +ZerothIndex( file_traversal_node_block_array *Arr ) { - file_traversal_node_block_array_index Result = {}; - Result.Block = Arr->First; - /* Assert(Result.Block->Index == 0); */ - return Result; + return {}; } -link_internal umm -TotalElements(file_traversal_node_block_array *Arr) +link_internal file_traversal_node_block_array_index +Capacity( file_traversal_node_block_array *Arr ) { - umm Result = 0; - if (Arr->Current) - { - Result = (Arr->Current->Index * 8) + Arr->Current->At; - } + file_traversal_node_block_array_index Result = {Arr->BlockCount * 8}; return Result; } link_internal file_traversal_node_block_array_index -LastIndex(file_traversal_node_block_array *Arr) +AtElements( file_traversal_node_block_array *Arr ) { - file_traversal_node_block_array_index Result = {}; - if (Arr->Current) - { - Result.Block = Arr->Current; - Result.BlockIndex = Arr->Current->Index; - Result.ElementIndex = Arr->Current->At; - Assert(Result.ElementIndex); - Result.ElementIndex--; - } + file_traversal_node_block_array_index Result = {Arr->ElementCount}; return Result; } + +link_internal umm +TotalElements( file_traversal_node_block_array *Arr ) +{ + umm Result = AtElements(Arr).Index; + return Result; +} + + link_internal file_traversal_node_block_array_index -AtElements(file_traversal_node_block_array *Arr) +LastIndex( file_traversal_node_block_array *Arr ) { file_traversal_node_block_array_index Result = {}; - if (Arr->Current) - { - Result.Block = Arr->Current; - Result.BlockIndex = Arr->Current->Index; - Result.ElementIndex = Arr->Current->At; - } + umm Count = AtElements(Arr).Index; + if (Count) Result.Index = Count-1; return Result; } -link_internal file_traversal_node * -GetPtr(file_traversal_node_block_array *Arr, file_traversal_node_block_array_index Index) +link_internal umm +Count( file_traversal_node_block_array *Arr ) { - file_traversal_node *Result = {}; - if (Index.Block) { Result = Index.Block->Elements + Index.ElementIndex; } + auto Result = AtElements(Arr).Index; return Result; } +link_internal file_traversal_node_block * +GetBlock( file_traversal_node_block_array *Arr, file_traversal_node_block_array_index Index ) +{ + umm BlockIndex = Index.Index / 8; + Assert(BlockIndex < Arr->BlockCount); + file_traversal_node_block *Block = Arr->BlockPtrs[BlockIndex]; + return Block; +} + link_internal file_traversal_node * -GetPtr(file_traversal_node_block *Block, umm Index) +GetPtr( file_traversal_node_block_array *Arr, file_traversal_node_block_array_index Index ) { - file_traversal_node *Result = 0; - if (Index < Block->At) { Result = Block->Elements + Index; } + Assert(Arr->BlockPtrs); + Assert(Index.Index < Capacity(Arr).Index); + + file_traversal_node_block *Block = GetBlock(Arr, Index); + + umm ElementIndex = Index.Index % 8; + file_traversal_node *Result = (Block->Elements + ElementIndex); return Result; } + link_internal file_traversal_node * -GetPtr(file_traversal_node_block_array *Arr, umm Index) +GetPtr( file_traversal_node_block_array *Arr, umm Index ) { - umm BlockIndex = Index / 8; - umm ElementIndex = Index % 8; + file_traversal_node_block_array_index I = {Index}; + return GetPtr(Arr, I); +} + - umm AtBlock = 0; - file_traversal_node_block *Block = Arr->First; - while (AtBlock++ < BlockIndex) +link_internal file_traversal_node * +TryGetPtr( file_traversal_node_block_array *Arr, file_traversal_node_block_array_index Index) +{ + file_traversal_node * Result = {}; + if (Arr->BlockPtrs && Index < AtElements(Arr)) { - Block = Block->Next; + Result = GetPtr(Arr, Index); } - - file_traversal_node *Result = Block->Elements+ElementIndex; return Result; } link_internal file_traversal_node * -TryGetPtr(file_traversal_node_block_array *Arr, umm Index) +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); } + auto Result = TryGetPtr(Arr, file_traversal_node_block_array_index{Index}); return Result; } -link_internal u32 -AtElements(file_traversal_node_block *Block) + + + + +link_internal cs +CS( file_traversal_node_block_array_index Index ) { - return Block->At; + return FSz("(%u)", Index.Index); } - -link_internal file_traversal_node_block* -Allocate_file_traversal_node_block(memory_arena *Memory) +link_internal file_traversal_node * +Set( file_traversal_node_block_array *Arr, + file_traversal_node *Element, + file_traversal_node_block_array_index Index ) { - file_traversal_node_block *Result = Allocate(file_traversal_node_block, Memory, 1); - Result->Elements = Allocate(file_traversal_node, Memory, 8); - return Result; + Assert(Arr->BlockPtrs); + Assert(Index.Index < Capacity(Arr).Index); + file_traversal_node_block *Block = GetBlock(Arr, Index); + umm ElementIndex = Index.Index % 8; + auto Slot = Block->Elements+ElementIndex; + *Slot = *Element; + return Slot; } -link_internal cs -CS(file_traversal_node_block_array_index Index) +link_internal void +NewBlock( file_traversal_node_block_array *Arr ) { - return FSz("(%u)(%u)", Index.BlockIndex, Index.ElementIndex); + file_traversal_node_block *NewBlock = Allocate( file_traversal_node_block , Arr->Memory, 1); + file_traversal_node_block **NewBlockPtrs = Allocate( file_traversal_node_block*, Arr->Memory, Arr->BlockCount+1); + + RangeIterator_t(u32, BlockI, Arr->BlockCount) + { + NewBlockPtrs[BlockI] = Arr->BlockPtrs[BlockI]; + } + + NewBlockPtrs[Arr->BlockCount] = NewBlock; + + + + Arr->BlockPtrs = NewBlockPtrs; + Arr->BlockCount += 1; } link_internal void -RemoveUnordered(file_traversal_node_block_array *Array, file_traversal_node_block_array_index Index) +RemoveUnordered( file_traversal_node_block_array *Array, file_traversal_node_block_array_index Index) { - file_traversal_node_block_array_index LastI = LastIndex(Array); + auto LastI = LastIndex(Array); + Assert(Index.Index <= LastI.Index); - file_traversal_node *Element = GetPtr(Array, Index); - file_traversal_node *LastElement = GetPtr(Array, LastI); + auto LastElement = GetPtr(Array, LastI); + Set(Array, LastElement, Index); + Array->ElementCount -= 1; +} - *Element = *LastElement; +link_internal void +RemoveOrdered( file_traversal_node_block_array *Array, file_traversal_node_block_array_index IndexToRemove) +{ + Assert(IndexToRemove.Index < Array->ElementCount); - Assert(Array->Current->At); - Array->Current->At -= 1; + file_traversal_node *Prev = {}; - if (Array->Current->At == 0) + file_traversal_node_block_array_index Max = AtElements(Array); + RangeIteratorRange_t(umm, Index, Max.Index, IndexToRemove.Index) { - // Walk the chain till we get to the second-last one - file_traversal_node_block *Current = Array->First; - file_traversal_node_block *LastB = LastI.Block; + file_traversal_node *E = GetPtr(Array, Index); - while (Current->Next && Current->Next != LastB) + if (Prev) { - Current = Current->Next; + *Prev = *E; } - Assert(Current->Next == LastB || Current->Next == 0); - Array->Current = Current; + Prev = E; } + + Array->ElementCount -= 1; } -link_internal file_traversal_node * -Push(file_traversal_node_block_array *Array, file_traversal_node *Element) +link_internal void +RemoveOrdered( file_traversal_node_block_array *Array, file_traversal_node *Element ) { - if (Array->Memory == 0) { Array->Memory = AllocateArena(); } - - if (Array->First == 0) { Array->First = Allocate_file_traversal_node_block(Array->Memory); Array->Current = Array->First; } - - if (Array->Current->At == 8) + IterateOver(Array, E, I) { - if (Array->Current->Next) + if (E == Element) { - Array->Current = Array->Current->Next; - Assert(Array->Current->At == 0); + RemoveOrdered(Array, I); + break; } - else - { - file_traversal_node_block *Next = Allocate_file_traversal_node_block(Array->Memory); - Next->Index = Array->Current->Index + 1; + } +} - Array->Current->Next = Next; - Array->Current = Next; +link_internal file_traversal_node_block_array_index +Find( file_traversal_node_block_array *Array, file_traversal_node *Query) +{ + file_traversal_node_block_array_index Result = {INVALID_BLOCK_ARRAY_INDEX}; + IterateOver(Array, E, Index) + { + if ( E == Query ) + { + Result = Index; + break; } } + return Result; +} + + + +link_internal b32 +IsValid(file_traversal_node_block_array_index *Index) +{ + file_traversal_node_block_array_index Test = {INVALID_BLOCK_ARRAY_INDEX}; + b32 Result = (AreEqual(Index, &Test) == False); + return Result; +} + +link_internal file_traversal_node * +Push( file_traversal_node_block_array *Array, file_traversal_node *Element) +{ + Assert(Array->Memory); + + if (AtElements(Array) == Capacity(Array)) + { + NewBlock(Array); + } - file_traversal_node *Result = Array->Current->Elements + Array->Current->At; + file_traversal_node *Result = Set(Array, Element, AtElements(Array)); - Array->Current->Elements[Array->Current->At++] = *Element; + Array->ElementCount += 1; return Result; } +link_internal file_traversal_node * +Push( file_traversal_node_block_array *Array ) +{ + file_traversal_node Element = {}; + auto Result = Push(Array, &Element); + return Result; +} + +link_internal void +Insert( file_traversal_node_block_array *Array, file_traversal_node_block_array_index Index, file_traversal_node *Element ) +{ + Assert(Index.Index <= LastIndex(Array).Index); + Assert(Array->Memory); + + // Alocate a new thingy + file_traversal_node *Prev = Push(Array); + + auto Last = LastIndex(Array); + + RangeIteratorReverseRange(I, s32(Last.Index), s32(Index.Index)) + { + auto E = GetPtr(Array, umm(I)); + *Prev = *E; + Prev = E; + } + + *Prev = *Element; +} + +link_internal void +Insert( file_traversal_node_block_array *Array, u32 Index, file_traversal_node *Element ) +{ + Insert(Array, { .Index = Index }, Element); +} + +link_internal void +Shift( file_traversal_node_block_array *Array, file_traversal_node *Element ) +{ + Insert(Array, { .Index = 0 }, Element); +} + +/* element_t.has_tag(do_editor_ui)? */ +/* { */ +/* do_editor_ui_for_container( block_array_t ) */ +/* } */ + + diff --git a/generated/block_array_gpu_readback_buffer_688853862.h b/generated/block_array_gpu_readback_buffer_688853862.h new file mode 100644 index 000000000..026aebb0d --- /dev/null +++ b/generated/block_array_gpu_readback_buffer_688853862.h @@ -0,0 +1,363 @@ +// external/bonsai_stdlib/src/poof_functions.h:2600:0 + + + + +struct gpu_readback_buffer_block +{ + /* u32 Index; */ + umm At; + gpu_readback_buffer Elements[8]; +}; + +struct gpu_readback_buffer_block_array_index +{ + umm Index; +}; + +struct gpu_readback_buffer_block_array +{ + gpu_readback_buffer_block **BlockPtrs; poof(@array_length(Element->BlockCount)) + u32 BlockCount; + u32 ElementCount; + memory_arena *Memory; poof(@no_serialize) + +}; + +link_internal gpu_readback_buffer_block_array +GpuReadbackBufferBlockArray(memory_arena *Memory) +{ + gpu_readback_buffer_block_array Result = {}; + Result.Memory = Memory; + return Result; +} + +link_internal b32 +AreEqual(gpu_readback_buffer_block_array_index *Thing1, gpu_readback_buffer_block_array_index *Thing2) +{ + if (Thing1 && Thing2) + { + b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( gpu_readback_buffer_block_array_index ) ); + + return Result; + } + else + { + return (Thing1 == Thing2); + } +} + +link_internal b32 +AreEqual(gpu_readback_buffer_block_array_index Thing1, gpu_readback_buffer_block_array_index Thing2) +{ + b32 Result = MemoryIsEqual((u8*)&Thing1, (u8*)&Thing2, sizeof( gpu_readback_buffer_block_array_index ) ); + + return Result; +} + + +typedef gpu_readback_buffer_block_array gpu_readback_buffer_paged_list; + +link_internal gpu_readback_buffer_block_array_index +operator++( gpu_readback_buffer_block_array_index &I0 ) +{ + I0.Index++; + return I0; +} + +link_internal b32 +operator<( gpu_readback_buffer_block_array_index I0, gpu_readback_buffer_block_array_index I1 ) +{ + b32 Result = I0.Index < I1.Index; + return Result; +} + +link_internal b32 +operator==( gpu_readback_buffer_block_array_index I0, gpu_readback_buffer_block_array_index I1 ) +{ + b32 Result = I0.Index == I1.Index; + return Result; +} + +link_inline umm +GetIndex( gpu_readback_buffer_block_array_index *Index) +{ + umm Result = Index->Index; + return Result; +} + + +link_internal gpu_readback_buffer_block_array_index +ZerothIndex( gpu_readback_buffer_block_array *Arr ) +{ + return {}; +} + +link_internal gpu_readback_buffer_block_array_index +Capacity( gpu_readback_buffer_block_array *Arr ) +{ + gpu_readback_buffer_block_array_index Result = {Arr->BlockCount * 8}; + return Result; +} + +link_internal gpu_readback_buffer_block_array_index +AtElements( gpu_readback_buffer_block_array *Arr ) +{ + gpu_readback_buffer_block_array_index Result = {Arr->ElementCount}; + return Result; +} + + +link_internal umm +TotalElements( gpu_readback_buffer_block_array *Arr ) +{ + umm Result = AtElements(Arr).Index; + return Result; +} + + +link_internal gpu_readback_buffer_block_array_index +LastIndex( gpu_readback_buffer_block_array *Arr ) +{ + gpu_readback_buffer_block_array_index Result = {}; + umm Count = AtElements(Arr).Index; + if (Count) Result.Index = Count-1; + return Result; +} + +link_internal umm +Count( gpu_readback_buffer_block_array *Arr ) +{ + auto Result = AtElements(Arr).Index; + return Result; +} + +link_internal gpu_readback_buffer_block * +GetBlock( gpu_readback_buffer_block_array *Arr, gpu_readback_buffer_block_array_index Index ) +{ + umm BlockIndex = Index.Index / 8; + Assert(BlockIndex < Arr->BlockCount); + gpu_readback_buffer_block *Block = Arr->BlockPtrs[BlockIndex]; + return Block; +} + +link_internal gpu_readback_buffer * +GetPtr( gpu_readback_buffer_block_array *Arr, gpu_readback_buffer_block_array_index Index ) +{ + Assert(Arr->BlockPtrs); + Assert(Index.Index < Capacity(Arr).Index); + + gpu_readback_buffer_block *Block = GetBlock(Arr, Index); + + umm ElementIndex = Index.Index % 8; + gpu_readback_buffer *Result = (Block->Elements + ElementIndex); + return Result; +} + + +link_internal gpu_readback_buffer * +GetPtr( gpu_readback_buffer_block_array *Arr, umm Index ) +{ + gpu_readback_buffer_block_array_index I = {Index}; + return GetPtr(Arr, I); +} + + +link_internal gpu_readback_buffer * +TryGetPtr( gpu_readback_buffer_block_array *Arr, gpu_readback_buffer_block_array_index Index) +{ + gpu_readback_buffer * Result = {}; + if (Arr->BlockPtrs && Index < AtElements(Arr)) + { + Result = GetPtr(Arr, Index); + } + return Result; +} + +link_internal gpu_readback_buffer * +TryGetPtr( gpu_readback_buffer_block_array *Arr, umm Index) +{ + auto Result = TryGetPtr(Arr, gpu_readback_buffer_block_array_index{Index}); + return Result; +} + + + + + +link_internal cs +CS( gpu_readback_buffer_block_array_index Index ) +{ + return FSz("(%u)", Index.Index); +} + +link_internal gpu_readback_buffer * +Set( gpu_readback_buffer_block_array *Arr, + gpu_readback_buffer *Element, + gpu_readback_buffer_block_array_index Index ) +{ + Assert(Arr->BlockPtrs); + Assert(Index.Index < Capacity(Arr).Index); + gpu_readback_buffer_block *Block = GetBlock(Arr, Index); + umm ElementIndex = Index.Index % 8; + auto Slot = Block->Elements+ElementIndex; + *Slot = *Element; + return Slot; +} + +link_internal void +NewBlock( gpu_readback_buffer_block_array *Arr ) +{ + gpu_readback_buffer_block *NewBlock = Allocate( gpu_readback_buffer_block , Arr->Memory, 1); + gpu_readback_buffer_block **NewBlockPtrs = Allocate( gpu_readback_buffer_block*, Arr->Memory, Arr->BlockCount+1); + + RangeIterator_t(u32, BlockI, Arr->BlockCount) + { + NewBlockPtrs[BlockI] = Arr->BlockPtrs[BlockI]; + } + + NewBlockPtrs[Arr->BlockCount] = NewBlock; + + + + Arr->BlockPtrs = NewBlockPtrs; + Arr->BlockCount += 1; +} + +link_internal void +RemoveUnordered( gpu_readback_buffer_block_array *Array, gpu_readback_buffer_block_array_index Index) +{ + auto LastI = LastIndex(Array); + Assert(Index.Index <= LastI.Index); + + auto LastElement = GetPtr(Array, LastI); + Set(Array, LastElement, Index); + Array->ElementCount -= 1; +} + +link_internal void +RemoveOrdered( gpu_readback_buffer_block_array *Array, gpu_readback_buffer_block_array_index IndexToRemove) +{ + Assert(IndexToRemove.Index < Array->ElementCount); + + gpu_readback_buffer *Prev = {}; + + gpu_readback_buffer_block_array_index Max = AtElements(Array); + RangeIteratorRange_t(umm, Index, Max.Index, IndexToRemove.Index) + { + gpu_readback_buffer *E = GetPtr(Array, Index); + + if (Prev) + { + *Prev = *E; + } + + Prev = E; + } + + Array->ElementCount -= 1; +} + +link_internal void +RemoveOrdered( gpu_readback_buffer_block_array *Array, gpu_readback_buffer *Element ) +{ + IterateOver(Array, E, I) + { + if (E == Element) + { + RemoveOrdered(Array, I); + break; + } + } +} + +link_internal gpu_readback_buffer_block_array_index +Find( gpu_readback_buffer_block_array *Array, gpu_readback_buffer *Query) +{ + gpu_readback_buffer_block_array_index Result = {INVALID_BLOCK_ARRAY_INDEX}; + IterateOver(Array, E, Index) + { + if ( E == Query ) + { + Result = Index; + break; + } + } + return Result; +} + + + +link_internal b32 +IsValid(gpu_readback_buffer_block_array_index *Index) +{ + gpu_readback_buffer_block_array_index Test = {INVALID_BLOCK_ARRAY_INDEX}; + b32 Result = (AreEqual(Index, &Test) == False); + return Result; +} + +link_internal gpu_readback_buffer * +Push( gpu_readback_buffer_block_array *Array, gpu_readback_buffer *Element) +{ + Assert(Array->Memory); + + if (AtElements(Array) == Capacity(Array)) + { + NewBlock(Array); + } + + gpu_readback_buffer *Result = Set(Array, Element, AtElements(Array)); + + Array->ElementCount += 1; + + return Result; +} + +link_internal gpu_readback_buffer * +Push( gpu_readback_buffer_block_array *Array ) +{ + gpu_readback_buffer Element = {}; + auto Result = Push(Array, &Element); + return Result; +} + +link_internal void +Insert( gpu_readback_buffer_block_array *Array, gpu_readback_buffer_block_array_index Index, gpu_readback_buffer *Element ) +{ + Assert(Index.Index <= LastIndex(Array).Index); + Assert(Array->Memory); + + // Alocate a new thingy + gpu_readback_buffer *Prev = Push(Array); + + auto Last = LastIndex(Array); + + RangeIteratorReverseRange(I, s32(Last.Index), s32(Index.Index)) + { + auto E = GetPtr(Array, umm(I)); + *Prev = *E; + Prev = E; + } + + *Prev = *Element; +} + +link_internal void +Insert( gpu_readback_buffer_block_array *Array, u32 Index, gpu_readback_buffer *Element ) +{ + Insert(Array, { .Index = Index }, Element); +} + +link_internal void +Shift( gpu_readback_buffer_block_array *Array, gpu_readback_buffer *Element ) +{ + Insert(Array, { .Index = 0 }, Element); +} + +/* element_t.has_tag(do_editor_ui)? */ +/* { */ +/* do_editor_ui_for_container( block_array_t ) */ +/* } */ + + + diff --git a/generated/block_array_h_asset_thumbnail_688856411.h b/generated/block_array_h_asset_thumbnail_688856411.h index 39241abdd..2db25f33a 100644 --- a/generated/block_array_h_asset_thumbnail_688856411.h +++ b/generated/block_array_h_asset_thumbnail_688856411.h @@ -1,164 +1,183 @@ -// src/engine/editor.h:518:0 +// external/bonsai_stdlib/src/poof_functions.h:2211:0 + + + struct asset_thumbnail_block { - u32 Index; - u32 At; - asset_thumbnail *Elements; - asset_thumbnail_block *Next; + /* u32 Index; */ + umm At; + asset_thumbnail Elements[8]; }; struct asset_thumbnail_block_array_index { - asset_thumbnail_block *Block; - u32 BlockIndex; - u32 ElementIndex; + umm Index; }; struct asset_thumbnail_block_array { - asset_thumbnail_block *First; - asset_thumbnail_block *Current; + asset_thumbnail_block **BlockPtrs; poof(@array_length(Element->BlockCount)) + u32 BlockCount; + u32 ElementCount; memory_arena *Memory; poof(@no_serialize) }; -typedef asset_thumbnail_block_array asset_thumbnail_paged_list; +link_internal asset_thumbnail_block_array +AssetThumbnailBlockArray(memory_arena *Memory) +{ + asset_thumbnail_block_array Result = {}; + Result.Memory = Memory; + return Result; +} -link_internal asset_thumbnail_block_array_index -operator++(asset_thumbnail_block_array_index &I0) +link_internal b32 +AreEqual(asset_thumbnail_block_array_index *Thing1, asset_thumbnail_block_array_index *Thing2) { - if (I0.Block) + if (Thing1 && Thing2) { - if (I0.ElementIndex == 8-1) - { - I0.ElementIndex = 0; - I0.BlockIndex++; - I0.Block = I0.Block->Next; - } - else - { - I0.ElementIndex++; - } + b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( asset_thumbnail_block_array_index ) ); + + return Result; } else { - I0.ElementIndex++; + return (Thing1 == Thing2); } +} + +link_internal b32 +AreEqual(asset_thumbnail_block_array_index Thing1, asset_thumbnail_block_array_index Thing2) +{ + b32 Result = MemoryIsEqual((u8*)&Thing1, (u8*)&Thing2, sizeof( asset_thumbnail_block_array_index ) ); + + return Result; +} + + +typedef asset_thumbnail_block_array asset_thumbnail_paged_list; + +link_internal asset_thumbnail_block_array_index +operator++( asset_thumbnail_block_array_index &I0 ) +{ + I0.Index++; return I0; } link_internal b32 -operator<(asset_thumbnail_block_array_index I0, asset_thumbnail_block_array_index I1) +operator<( asset_thumbnail_block_array_index I0, asset_thumbnail_block_array_index I1 ) { - b32 Result = I0.BlockIndex < I1.BlockIndex || (I0.BlockIndex == I1.BlockIndex & I0.ElementIndex < I1.ElementIndex); + b32 Result = I0.Index < I1.Index; + return Result; +} + +link_internal b32 +operator==( asset_thumbnail_block_array_index I0, asset_thumbnail_block_array_index I1 ) +{ + b32 Result = I0.Index == I1.Index; return Result; } link_inline umm -GetIndex(asset_thumbnail_block_array_index *Index) +GetIndex( asset_thumbnail_block_array_index *Index) { - umm Result = Index->ElementIndex + (Index->BlockIndex*8); + umm Result = Index->Index; return Result; } + link_internal asset_thumbnail_block_array_index -ZerothIndex(asset_thumbnail_block_array *Arr) +ZerothIndex( asset_thumbnail_block_array *Arr ) { - asset_thumbnail_block_array_index Result = {}; - Result.Block = Arr->First; - /* Assert(Result.Block->Index == 0); */ - return Result; + return {}; } -link_internal umm -TotalElements(asset_thumbnail_block_array *Arr) +link_internal asset_thumbnail_block_array_index +Capacity( asset_thumbnail_block_array *Arr ) { - umm Result = 0; - if (Arr->Current) - { - Result = (Arr->Current->Index * 8) + Arr->Current->At; - } + asset_thumbnail_block_array_index Result = {Arr->BlockCount * 8}; return Result; } link_internal asset_thumbnail_block_array_index -LastIndex(asset_thumbnail_block_array *Arr) +AtElements( asset_thumbnail_block_array *Arr ) { - asset_thumbnail_block_array_index Result = {}; - if (Arr->Current) - { - Result.Block = Arr->Current; - Result.BlockIndex = Arr->Current->Index; - Result.ElementIndex = Arr->Current->At; - Assert(Result.ElementIndex); - Result.ElementIndex--; - } + asset_thumbnail_block_array_index Result = {Arr->ElementCount}; + return Result; +} + + +link_internal umm +TotalElements( asset_thumbnail_block_array *Arr ) +{ + umm Result = AtElements(Arr).Index; return Result; } + link_internal asset_thumbnail_block_array_index -AtElements(asset_thumbnail_block_array *Arr) +LastIndex( asset_thumbnail_block_array *Arr ) { asset_thumbnail_block_array_index Result = {}; - if (Arr->Current) - { - Result.Block = Arr->Current; - Result.BlockIndex = Arr->Current->Index; - Result.ElementIndex = Arr->Current->At; - } + umm Count = AtElements(Arr).Index; + if (Count) Result.Index = Count-1; return Result; } -link_internal asset_thumbnail * -GetPtr(asset_thumbnail_block_array *Arr, asset_thumbnail_block_array_index Index) +link_internal umm +Count( asset_thumbnail_block_array *Arr ) { - asset_thumbnail *Result = {}; - if (Index.Block) { Result = Index.Block->Elements + Index.ElementIndex; } + auto Result = AtElements(Arr).Index; return Result; } -link_internal asset_thumbnail * -GetPtr(asset_thumbnail_block *Block, umm Index) +link_internal asset_thumbnail_block * +GetBlock( asset_thumbnail_block_array *Arr, asset_thumbnail_block_array_index Index ) { - asset_thumbnail *Result = 0; - if (Index < Block->At) { Result = Block->Elements + Index; } - return Result; + umm BlockIndex = Index.Index / 8; + Assert(BlockIndex < Arr->BlockCount); + asset_thumbnail_block *Block = Arr->BlockPtrs[BlockIndex]; + return Block; } link_internal asset_thumbnail * -GetPtr(asset_thumbnail_block_array *Arr, umm Index) +GetPtr( asset_thumbnail_block_array *Arr, asset_thumbnail_block_array_index Index ) { - umm BlockIndex = Index / 8; - umm ElementIndex = Index % 8; + Assert(Arr->BlockPtrs); + Assert(Index.Index < Capacity(Arr).Index); - umm AtBlock = 0; - asset_thumbnail_block *Block = Arr->First; - while (AtBlock++ < BlockIndex) - { - Block = Block->Next; - } + asset_thumbnail_block *Block = GetBlock(Arr, Index); - asset_thumbnail *Result = Block->Elements+ElementIndex; + umm ElementIndex = Index.Index % 8; + asset_thumbnail *Result = (Block->Elements + ElementIndex); return Result; } + link_internal asset_thumbnail * -TryGetPtr(asset_thumbnail_block_array *Arr, umm Index) +GetPtr( asset_thumbnail_block_array *Arr, umm Index ) { - umm BlockIndex = Index / 8; - umm ElementIndex = Index % 8; + asset_thumbnail_block_array_index I = {Index}; + return GetPtr(Arr, I); +} - auto AtE = AtElements(Arr); - umm Total = GetIndex(&AtE); - asset_thumbnail *Result = {}; - if (Index < Total) { Result = GetPtr(Arr, Index); } + +link_internal asset_thumbnail * +TryGetPtr( asset_thumbnail_block_array *Arr, asset_thumbnail_block_array_index Index) +{ + asset_thumbnail * Result = {}; + if (Arr->BlockPtrs && Index < AtElements(Arr)) + { + Result = GetPtr(Arr, Index); + } return Result; } -link_internal u32 -AtElements(asset_thumbnail_block *Block) +link_internal asset_thumbnail * +TryGetPtr( asset_thumbnail_block_array *Arr, umm Index) { - return Block->At; + auto Result = TryGetPtr(Arr, asset_thumbnail_block_array_index{Index}); + return Result; } diff --git a/generated/block_array_h_counted_string_688853862_0_889429130_894106509_562163350.h b/generated/block_array_h_counted_string_688853862_0_889429130_894106509_562163350.h new file mode 100644 index 000000000..650eb8f88 --- /dev/null +++ b/generated/block_array_h_counted_string_688853862_0_889429130_894106509_562163350.h @@ -0,0 +1,183 @@ +// external/bonsai_stdlib/src/poof_functions.h:2211:0 + + + + +struct counted_string_block +{ + /* u32 Index; */ + umm At; + counted_string Elements[32]; +}; + +struct counted_string_block_array_index +{ + umm Index; +}; + +struct counted_string_block_array +{ + counted_string_block **BlockPtrs; poof(@array_length(Element->BlockCount)) + u32 BlockCount; + u32 ElementCount; + memory_arena *Memory; poof(@no_serialize) + +}; + +link_internal counted_string_block_array +CountedStringBlockArray(memory_arena *Memory) +{ + counted_string_block_array Result = {}; + Result.Memory = Memory; + return Result; +} + +link_internal b32 +AreEqual(counted_string_block_array_index *Thing1, counted_string_block_array_index *Thing2) +{ + if (Thing1 && Thing2) + { + b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( counted_string_block_array_index ) ); + + return Result; + } + else + { + return (Thing1 == Thing2); + } +} + +link_internal b32 +AreEqual(counted_string_block_array_index Thing1, counted_string_block_array_index Thing2) +{ + b32 Result = MemoryIsEqual((u8*)&Thing1, (u8*)&Thing2, sizeof( counted_string_block_array_index ) ); + + return Result; +} + + +typedef counted_string_block_array counted_string_paged_list; + +link_internal counted_string_block_array_index +operator++( counted_string_block_array_index &I0 ) +{ + I0.Index++; + return I0; +} + +link_internal b32 +operator<( counted_string_block_array_index I0, counted_string_block_array_index I1 ) +{ + b32 Result = I0.Index < I1.Index; + return Result; +} + +link_internal b32 +operator==( counted_string_block_array_index I0, counted_string_block_array_index I1 ) +{ + b32 Result = I0.Index == I1.Index; + return Result; +} + +link_inline umm +GetIndex( counted_string_block_array_index *Index) +{ + umm Result = Index->Index; + return Result; +} + + +link_internal counted_string_block_array_index +ZerothIndex( counted_string_block_array *Arr ) +{ + return {}; +} + +link_internal counted_string_block_array_index +Capacity( counted_string_block_array *Arr ) +{ + counted_string_block_array_index Result = {Arr->BlockCount * 32}; + return Result; +} + +link_internal counted_string_block_array_index +AtElements( counted_string_block_array *Arr ) +{ + counted_string_block_array_index Result = {Arr->ElementCount}; + return Result; +} + + +link_internal umm +TotalElements( counted_string_block_array *Arr ) +{ + umm Result = AtElements(Arr).Index; + return Result; +} + + +link_internal counted_string_block_array_index +LastIndex( counted_string_block_array *Arr ) +{ + counted_string_block_array_index Result = {}; + umm Count = AtElements(Arr).Index; + if (Count) Result.Index = Count-1; + return Result; +} + +link_internal umm +Count( counted_string_block_array *Arr ) +{ + auto Result = AtElements(Arr).Index; + return Result; +} + +link_internal counted_string_block * +GetBlock( counted_string_block_array *Arr, counted_string_block_array_index Index ) +{ + umm BlockIndex = Index.Index / 32; + Assert(BlockIndex < Arr->BlockCount); + counted_string_block *Block = Arr->BlockPtrs[BlockIndex]; + return Block; +} + +link_internal counted_string * +GetPtr( counted_string_block_array *Arr, counted_string_block_array_index Index ) +{ + Assert(Arr->BlockPtrs); + Assert(Index.Index < Capacity(Arr).Index); + + counted_string_block *Block = GetBlock(Arr, Index); + + umm ElementIndex = Index.Index % 32; + counted_string *Result = (Block->Elements + ElementIndex); + return Result; +} + + +link_internal counted_string * +GetPtr( counted_string_block_array *Arr, umm Index ) +{ + counted_string_block_array_index I = {Index}; + return GetPtr(Arr, I); +} + + +link_internal counted_string * +TryGetPtr( counted_string_block_array *Arr, counted_string_block_array_index Index) +{ + counted_string * Result = {}; + if (Arr->BlockPtrs && Index < AtElements(Arr)) + { + Result = GetPtr(Arr, Index); + } + return Result; +} + +link_internal counted_string * +TryGetPtr( counted_string_block_array *Arr, umm Index) +{ + auto Result = TryGetPtr(Arr, counted_string_block_array_index{Index}); + return Result; +} + diff --git a/generated/block_array_h_gpu_timer_688735882_0.h b/generated/block_array_h_gpu_timer_688735882_0.h new file mode 100644 index 000000000..7c3f1bfe4 --- /dev/null +++ b/generated/block_array_h_gpu_timer_688735882_0.h @@ -0,0 +1,183 @@ +// external/bonsai_stdlib/src/poof_functions.h:2211:0 + + + + +struct gpu_timer_block +{ + /* u32 Index; */ + umm At; + gpu_timer Elements[128]; +}; + +struct gpu_timer_block_array_index +{ + umm Index; +}; + +struct gpu_timer_block_array +{ + gpu_timer_block **BlockPtrs; poof(@array_length(Element->BlockCount)) + u32 BlockCount; + u32 ElementCount; + memory_arena *Memory; poof(@no_serialize) + +}; + +link_internal gpu_timer_block_array +GpuTimerBlockArray(memory_arena *Memory) +{ + gpu_timer_block_array Result = {}; + Result.Memory = Memory; + return Result; +} + +link_internal b32 +AreEqual(gpu_timer_block_array_index *Thing1, gpu_timer_block_array_index *Thing2) +{ + if (Thing1 && Thing2) + { + b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( gpu_timer_block_array_index ) ); + + return Result; + } + else + { + return (Thing1 == Thing2); + } +} + +link_internal b32 +AreEqual(gpu_timer_block_array_index Thing1, gpu_timer_block_array_index Thing2) +{ + b32 Result = MemoryIsEqual((u8*)&Thing1, (u8*)&Thing2, sizeof( gpu_timer_block_array_index ) ); + + return Result; +} + + +typedef gpu_timer_block_array gpu_timer_paged_list; + +link_internal gpu_timer_block_array_index +operator++( gpu_timer_block_array_index &I0 ) +{ + I0.Index++; + return I0; +} + +link_internal b32 +operator<( gpu_timer_block_array_index I0, gpu_timer_block_array_index I1 ) +{ + b32 Result = I0.Index < I1.Index; + return Result; +} + +link_internal b32 +operator==( gpu_timer_block_array_index I0, gpu_timer_block_array_index I1 ) +{ + b32 Result = I0.Index == I1.Index; + return Result; +} + +link_inline umm +GetIndex( gpu_timer_block_array_index *Index) +{ + umm Result = Index->Index; + return Result; +} + + +link_internal gpu_timer_block_array_index +ZerothIndex( gpu_timer_block_array *Arr ) +{ + return {}; +} + +link_internal gpu_timer_block_array_index +Capacity( gpu_timer_block_array *Arr ) +{ + gpu_timer_block_array_index Result = {Arr->BlockCount * 128}; + return Result; +} + +link_internal gpu_timer_block_array_index +AtElements( gpu_timer_block_array *Arr ) +{ + gpu_timer_block_array_index Result = {Arr->ElementCount}; + return Result; +} + + +link_internal umm +TotalElements( gpu_timer_block_array *Arr ) +{ + umm Result = AtElements(Arr).Index; + return Result; +} + + +link_internal gpu_timer_block_array_index +LastIndex( gpu_timer_block_array *Arr ) +{ + gpu_timer_block_array_index Result = {}; + umm Count = AtElements(Arr).Index; + if (Count) Result.Index = Count-1; + return Result; +} + +link_internal umm +Count( gpu_timer_block_array *Arr ) +{ + auto Result = AtElements(Arr).Index; + return Result; +} + +link_internal gpu_timer_block * +GetBlock( gpu_timer_block_array *Arr, gpu_timer_block_array_index Index ) +{ + umm BlockIndex = Index.Index / 128; + Assert(BlockIndex < Arr->BlockCount); + gpu_timer_block *Block = Arr->BlockPtrs[BlockIndex]; + return Block; +} + +link_internal gpu_timer * +GetPtr( gpu_timer_block_array *Arr, gpu_timer_block_array_index Index ) +{ + Assert(Arr->BlockPtrs); + Assert(Index.Index < Capacity(Arr).Index); + + gpu_timer_block *Block = GetBlock(Arr, Index); + + umm ElementIndex = Index.Index % 128; + gpu_timer *Result = (Block->Elements + ElementIndex); + return Result; +} + + +link_internal gpu_timer * +GetPtr( gpu_timer_block_array *Arr, umm Index ) +{ + gpu_timer_block_array_index I = {Index}; + return GetPtr(Arr, I); +} + + +link_internal gpu_timer * +TryGetPtr( gpu_timer_block_array *Arr, gpu_timer_block_array_index Index) +{ + gpu_timer * Result = {}; + if (Arr->BlockPtrs && Index < AtElements(Arr)) + { + Result = GetPtr(Arr, Index); + } + return Result; +} + +link_internal gpu_timer * +TryGetPtr( gpu_timer_block_array *Arr, umm Index) +{ + auto Result = TryGetPtr(Arr, gpu_timer_block_array_index{Index}); + return Result; +} + diff --git a/generated/block_array_h_shader_ptr_688853972_0.h b/generated/block_array_h_shader_ptr_688853972_0.h new file mode 100644 index 000000000..8415a55c2 --- /dev/null +++ b/generated/block_array_h_shader_ptr_688853972_0.h @@ -0,0 +1,183 @@ +// external/bonsai_stdlib/src/poof_functions.h:2211:0 + + + + +struct shader_ptr_block +{ + /* u32 Index; */ + umm At; + shader_ptr Elements[64]; +}; + +struct shader_ptr_block_array_index +{ + umm Index; +}; + +struct shader_ptr_block_array +{ + shader_ptr_block **BlockPtrs; poof(@array_length(Element->BlockCount)) + u32 BlockCount; + u32 ElementCount; + memory_arena *Memory; poof(@no_serialize) + +}; + +link_internal shader_ptr_block_array +ShaderPtrBlockArray(memory_arena *Memory) +{ + shader_ptr_block_array Result = {}; + Result.Memory = Memory; + return Result; +} + +link_internal b32 +AreEqual(shader_ptr_block_array_index *Thing1, shader_ptr_block_array_index *Thing2) +{ + if (Thing1 && Thing2) + { + b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( shader_ptr_block_array_index ) ); + + return Result; + } + else + { + return (Thing1 == Thing2); + } +} + +link_internal b32 +AreEqual(shader_ptr_block_array_index Thing1, shader_ptr_block_array_index Thing2) +{ + b32 Result = MemoryIsEqual((u8*)&Thing1, (u8*)&Thing2, sizeof( shader_ptr_block_array_index ) ); + + return Result; +} + + +typedef shader_ptr_block_array shader_ptr_paged_list; + +link_internal shader_ptr_block_array_index +operator++( shader_ptr_block_array_index &I0 ) +{ + I0.Index++; + return I0; +} + +link_internal b32 +operator<( shader_ptr_block_array_index I0, shader_ptr_block_array_index I1 ) +{ + b32 Result = I0.Index < I1.Index; + return Result; +} + +link_internal b32 +operator==( shader_ptr_block_array_index I0, shader_ptr_block_array_index I1 ) +{ + b32 Result = I0.Index == I1.Index; + return Result; +} + +link_inline umm +GetIndex( shader_ptr_block_array_index *Index) +{ + umm Result = Index->Index; + return Result; +} + + +link_internal shader_ptr_block_array_index +ZerothIndex( shader_ptr_block_array *Arr ) +{ + return {}; +} + +link_internal shader_ptr_block_array_index +Capacity( shader_ptr_block_array *Arr ) +{ + shader_ptr_block_array_index Result = {Arr->BlockCount * 64}; + return Result; +} + +link_internal shader_ptr_block_array_index +AtElements( shader_ptr_block_array *Arr ) +{ + shader_ptr_block_array_index Result = {Arr->ElementCount}; + return Result; +} + + +link_internal umm +TotalElements( shader_ptr_block_array *Arr ) +{ + umm Result = AtElements(Arr).Index; + return Result; +} + + +link_internal shader_ptr_block_array_index +LastIndex( shader_ptr_block_array *Arr ) +{ + shader_ptr_block_array_index Result = {}; + umm Count = AtElements(Arr).Index; + if (Count) Result.Index = Count-1; + return Result; +} + +link_internal umm +Count( shader_ptr_block_array *Arr ) +{ + auto Result = AtElements(Arr).Index; + return Result; +} + +link_internal shader_ptr_block * +GetBlock( shader_ptr_block_array *Arr, shader_ptr_block_array_index Index ) +{ + umm BlockIndex = Index.Index / 64; + Assert(BlockIndex < Arr->BlockCount); + shader_ptr_block *Block = Arr->BlockPtrs[BlockIndex]; + return Block; +} + +link_internal shader_ptr +GetPtr( shader_ptr_block_array *Arr, shader_ptr_block_array_index Index ) +{ + Assert(Arr->BlockPtrs); + Assert(Index.Index < Capacity(Arr).Index); + + shader_ptr_block *Block = GetBlock(Arr, Index); + + umm ElementIndex = Index.Index % 64; + shader_ptr Result = *(Block->Elements + ElementIndex); + return Result; +} + + +link_internal shader_ptr +GetPtr( shader_ptr_block_array *Arr, umm Index ) +{ + shader_ptr_block_array_index I = {Index}; + return GetPtr(Arr, I); +} + + +link_internal shader_ptr +TryGetPtr( shader_ptr_block_array *Arr, shader_ptr_block_array_index Index) +{ + shader_ptr Result = {}; + if (Arr->BlockPtrs && Index < AtElements(Arr)) + { + Result = GetPtr(Arr, Index); + } + return Result; +} + +link_internal shader_ptr +TryGetPtr( shader_ptr_block_array *Arr, umm Index) +{ + auto Result = TryGetPtr(Arr, shader_ptr_block_array_index{Index}); + return Result; +} + diff --git a/generated/block_array_h_texture_688856411.h b/generated/block_array_h_texture_688856411.h index a9bc114cf..a12064c3c 100644 --- a/generated/block_array_h_texture_688856411.h +++ b/generated/block_array_h_texture_688856411.h @@ -1,164 +1,183 @@ -// external/bonsai_stdlib/src/texture.h:45:0 +// external/bonsai_stdlib/src/poof_functions.h:2211:0 + + + struct texture_ptr_block { - u32 Index; - u32 At; - texture_ptr *Elements; - texture_ptr_block *Next; + /* u32 Index; */ + umm At; + texture_ptr Elements[8]; }; struct texture_ptr_block_array_index { - texture_ptr_block *Block; - u32 BlockIndex; - u32 ElementIndex; + umm Index; }; struct texture_ptr_block_array { - texture_ptr_block *First; - texture_ptr_block *Current; + texture_ptr_block **BlockPtrs; poof(@array_length(Element->BlockCount)) + u32 BlockCount; + u32 ElementCount; memory_arena *Memory; poof(@no_serialize) }; -typedef texture_ptr_block_array texture_ptr_paged_list; +link_internal texture_ptr_block_array +TexturePtrBlockArray(memory_arena *Memory) +{ + texture_ptr_block_array Result = {}; + Result.Memory = Memory; + return Result; +} -link_internal texture_ptr_block_array_index -operator++(texture_ptr_block_array_index &I0) +link_internal b32 +AreEqual(texture_ptr_block_array_index *Thing1, texture_ptr_block_array_index *Thing2) { - if (I0.Block) + if (Thing1 && Thing2) { - if (I0.ElementIndex == 8-1) - { - I0.ElementIndex = 0; - I0.BlockIndex++; - I0.Block = I0.Block->Next; - } - else - { - I0.ElementIndex++; - } + b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( texture_ptr_block_array_index ) ); + + return Result; } else { - I0.ElementIndex++; + return (Thing1 == Thing2); } +} + +link_internal b32 +AreEqual(texture_ptr_block_array_index Thing1, texture_ptr_block_array_index Thing2) +{ + b32 Result = MemoryIsEqual((u8*)&Thing1, (u8*)&Thing2, sizeof( texture_ptr_block_array_index ) ); + + return Result; +} + + +typedef texture_ptr_block_array texture_ptr_paged_list; + +link_internal texture_ptr_block_array_index +operator++( texture_ptr_block_array_index &I0 ) +{ + I0.Index++; return I0; } link_internal b32 -operator<(texture_ptr_block_array_index I0, texture_ptr_block_array_index I1) +operator<( texture_ptr_block_array_index I0, texture_ptr_block_array_index I1 ) { - b32 Result = I0.BlockIndex < I1.BlockIndex || (I0.BlockIndex == I1.BlockIndex & I0.ElementIndex < I1.ElementIndex); + b32 Result = I0.Index < I1.Index; + return Result; +} + +link_internal b32 +operator==( texture_ptr_block_array_index I0, texture_ptr_block_array_index I1 ) +{ + b32 Result = I0.Index == I1.Index; return Result; } link_inline umm -GetIndex(texture_ptr_block_array_index *Index) +GetIndex( texture_ptr_block_array_index *Index) { - umm Result = Index->ElementIndex + (Index->BlockIndex*8); + umm Result = Index->Index; return Result; } + +link_internal texture_ptr_block_array_index +ZerothIndex( texture_ptr_block_array *Arr ) +{ + return {}; +} + link_internal texture_ptr_block_array_index -ZerothIndex(texture_ptr_block_array *Arr) +Capacity( texture_ptr_block_array *Arr ) { - texture_ptr_block_array_index Result = {}; - Result.Block = Arr->First; - /* Assert(Result.Block->Index == 0); */ + texture_ptr_block_array_index Result = {Arr->BlockCount * 8}; return Result; } -link_internal umm -TotalElements(texture_ptr_block_array *Arr) +link_internal texture_ptr_block_array_index +AtElements( texture_ptr_block_array *Arr ) { - umm Result = 0; - if (Arr->Current) - { - Result = (Arr->Current->Index * 8) + Arr->Current->At; - } + texture_ptr_block_array_index Result = {Arr->ElementCount}; return Result; } -link_internal texture_ptr_block_array_index -LastIndex(texture_ptr_block_array *Arr) + +link_internal umm +TotalElements( texture_ptr_block_array *Arr ) { - texture_ptr_block_array_index Result = {}; - if (Arr->Current) - { - Result.Block = Arr->Current; - Result.BlockIndex = Arr->Current->Index; - Result.ElementIndex = Arr->Current->At; - Assert(Result.ElementIndex); - Result.ElementIndex--; - } + umm Result = AtElements(Arr).Index; return Result; } + link_internal texture_ptr_block_array_index -AtElements(texture_ptr_block_array *Arr) +LastIndex( texture_ptr_block_array *Arr ) { texture_ptr_block_array_index Result = {}; - if (Arr->Current) - { - Result.Block = Arr->Current; - Result.BlockIndex = Arr->Current->Index; - Result.ElementIndex = Arr->Current->At; - } + umm Count = AtElements(Arr).Index; + if (Count) Result.Index = Count-1; return Result; } -link_internal texture_ptr * -GetPtr(texture_ptr_block_array *Arr, texture_ptr_block_array_index Index) +link_internal umm +Count( texture_ptr_block_array *Arr ) { - texture_ptr *Result = {}; - if (Index.Block) { Result = Index.Block->Elements + Index.ElementIndex; } + auto Result = AtElements(Arr).Index; return Result; } -link_internal texture_ptr * -GetPtr(texture_ptr_block *Block, umm Index) +link_internal texture_ptr_block * +GetBlock( texture_ptr_block_array *Arr, texture_ptr_block_array_index Index ) { - texture_ptr *Result = 0; - if (Index < Block->At) { Result = Block->Elements + Index; } - return Result; + umm BlockIndex = Index.Index / 8; + Assert(BlockIndex < Arr->BlockCount); + texture_ptr_block *Block = Arr->BlockPtrs[BlockIndex]; + return Block; } -link_internal texture_ptr * -GetPtr(texture_ptr_block_array *Arr, umm Index) +link_internal texture_ptr +GetPtr( texture_ptr_block_array *Arr, texture_ptr_block_array_index Index ) { - umm BlockIndex = Index / 8; - umm ElementIndex = Index % 8; + Assert(Arr->BlockPtrs); + Assert(Index.Index < Capacity(Arr).Index); - umm AtBlock = 0; - texture_ptr_block *Block = Arr->First; - while (AtBlock++ < BlockIndex) - { - Block = Block->Next; - } + texture_ptr_block *Block = GetBlock(Arr, Index); - texture_ptr *Result = Block->Elements+ElementIndex; + umm ElementIndex = Index.Index % 8; + texture_ptr Result = *(Block->Elements + ElementIndex); return Result; } -link_internal texture_ptr * -TryGetPtr(texture_ptr_block_array *Arr, umm Index) + +link_internal texture_ptr +GetPtr( texture_ptr_block_array *Arr, umm Index ) { - umm BlockIndex = Index / 8; - umm ElementIndex = Index % 8; + texture_ptr_block_array_index I = {Index}; + return GetPtr(Arr, I); +} - auto AtE = AtElements(Arr); - umm Total = GetIndex(&AtE); - texture_ptr *Result = {}; - if (Index < Total) { Result = GetPtr(Arr, Index); } + +link_internal texture_ptr +TryGetPtr( texture_ptr_block_array *Arr, texture_ptr_block_array_index Index) +{ + texture_ptr Result = {}; + if (Arr->BlockPtrs && Index < AtElements(Arr)) + { + Result = GetPtr(Arr, Index); + } return Result; } -link_internal u32 -AtElements(texture_ptr_block *Block) +link_internal texture_ptr +TryGetPtr( texture_ptr_block_array *Arr, umm Index) { - return Block->At; + auto Result = TryGetPtr(Arr, texture_ptr_block_array_index{Index}); + return Result; } diff --git a/generated/block_array_h_texture_688856411_0.h b/generated/block_array_h_texture_688856411_0.h index 00a07de11..7d1c1963d 100644 --- a/generated/block_array_h_texture_688856411_0.h +++ b/generated/block_array_h_texture_688856411_0.h @@ -1,164 +1,183 @@ -// external/bonsai_stdlib/src/texture.h:42:0 +// external/bonsai_stdlib/src/poof_functions.h:2211:0 + + + struct texture_block { - u32 Index; - u32 At; - texture *Elements; - texture_block *Next; + /* u32 Index; */ + umm At; + texture Elements[8]; }; struct texture_block_array_index { - texture_block *Block; - u32 BlockIndex; - u32 ElementIndex; + umm Index; }; struct texture_block_array { - texture_block *First; - texture_block *Current; + texture_block **BlockPtrs; poof(@array_length(Element->BlockCount)) + u32 BlockCount; + u32 ElementCount; memory_arena *Memory; poof(@no_serialize) }; -typedef texture_block_array texture_paged_list; +link_internal texture_block_array +TextureBlockArray(memory_arena *Memory) +{ + texture_block_array Result = {}; + Result.Memory = Memory; + return Result; +} -link_internal texture_block_array_index -operator++(texture_block_array_index &I0) +link_internal b32 +AreEqual(texture_block_array_index *Thing1, texture_block_array_index *Thing2) { - if (I0.Block) + if (Thing1 && Thing2) { - if (I0.ElementIndex == 8-1) - { - I0.ElementIndex = 0; - I0.BlockIndex++; - I0.Block = I0.Block->Next; - } - else - { - I0.ElementIndex++; - } + b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( texture_block_array_index ) ); + + return Result; } else { - I0.ElementIndex++; + return (Thing1 == Thing2); } +} + +link_internal b32 +AreEqual(texture_block_array_index Thing1, texture_block_array_index Thing2) +{ + b32 Result = MemoryIsEqual((u8*)&Thing1, (u8*)&Thing2, sizeof( texture_block_array_index ) ); + + return Result; +} + + +typedef texture_block_array texture_paged_list; + +link_internal texture_block_array_index +operator++( texture_block_array_index &I0 ) +{ + I0.Index++; return I0; } link_internal b32 -operator<(texture_block_array_index I0, texture_block_array_index I1) +operator<( texture_block_array_index I0, texture_block_array_index I1 ) { - b32 Result = I0.BlockIndex < I1.BlockIndex || (I0.BlockIndex == I1.BlockIndex & I0.ElementIndex < I1.ElementIndex); + b32 Result = I0.Index < I1.Index; + return Result; +} + +link_internal b32 +operator==( texture_block_array_index I0, texture_block_array_index I1 ) +{ + b32 Result = I0.Index == I1.Index; return Result; } link_inline umm -GetIndex(texture_block_array_index *Index) +GetIndex( texture_block_array_index *Index) { - umm Result = Index->ElementIndex + (Index->BlockIndex*8); + umm Result = Index->Index; return Result; } + link_internal texture_block_array_index -ZerothIndex(texture_block_array *Arr) +ZerothIndex( texture_block_array *Arr ) { - texture_block_array_index Result = {}; - Result.Block = Arr->First; - /* Assert(Result.Block->Index == 0); */ - return Result; + return {}; } -link_internal umm -TotalElements(texture_block_array *Arr) +link_internal texture_block_array_index +Capacity( texture_block_array *Arr ) { - umm Result = 0; - if (Arr->Current) - { - Result = (Arr->Current->Index * 8) + Arr->Current->At; - } + texture_block_array_index Result = {Arr->BlockCount * 8}; return Result; } link_internal texture_block_array_index -LastIndex(texture_block_array *Arr) +AtElements( texture_block_array *Arr ) { - texture_block_array_index Result = {}; - if (Arr->Current) - { - Result.Block = Arr->Current; - Result.BlockIndex = Arr->Current->Index; - Result.ElementIndex = Arr->Current->At; - Assert(Result.ElementIndex); - Result.ElementIndex--; - } + texture_block_array_index Result = {Arr->ElementCount}; + return Result; +} + + +link_internal umm +TotalElements( texture_block_array *Arr ) +{ + umm Result = AtElements(Arr).Index; return Result; } + link_internal texture_block_array_index -AtElements(texture_block_array *Arr) +LastIndex( texture_block_array *Arr ) { texture_block_array_index Result = {}; - if (Arr->Current) - { - Result.Block = Arr->Current; - Result.BlockIndex = Arr->Current->Index; - Result.ElementIndex = Arr->Current->At; - } + umm Count = AtElements(Arr).Index; + if (Count) Result.Index = Count-1; return Result; } -link_internal texture * -GetPtr(texture_block_array *Arr, texture_block_array_index Index) +link_internal umm +Count( texture_block_array *Arr ) { - texture *Result = {}; - if (Index.Block) { Result = Index.Block->Elements + Index.ElementIndex; } + auto Result = AtElements(Arr).Index; return Result; } -link_internal texture * -GetPtr(texture_block *Block, umm Index) +link_internal texture_block * +GetBlock( texture_block_array *Arr, texture_block_array_index Index ) { - texture *Result = 0; - if (Index < Block->At) { Result = Block->Elements + Index; } - return Result; + umm BlockIndex = Index.Index / 8; + Assert(BlockIndex < Arr->BlockCount); + texture_block *Block = Arr->BlockPtrs[BlockIndex]; + return Block; } link_internal texture * -GetPtr(texture_block_array *Arr, umm Index) +GetPtr( texture_block_array *Arr, texture_block_array_index Index ) { - umm BlockIndex = Index / 8; - umm ElementIndex = Index % 8; + Assert(Arr->BlockPtrs); + Assert(Index.Index < Capacity(Arr).Index); - umm AtBlock = 0; - texture_block *Block = Arr->First; - while (AtBlock++ < BlockIndex) - { - Block = Block->Next; - } + texture_block *Block = GetBlock(Arr, Index); - texture *Result = Block->Elements+ElementIndex; + umm ElementIndex = Index.Index % 8; + texture *Result = (Block->Elements + ElementIndex); return Result; } + link_internal texture * -TryGetPtr(texture_block_array *Arr, umm Index) +GetPtr( texture_block_array *Arr, umm Index ) { - umm BlockIndex = Index / 8; - umm ElementIndex = Index % 8; + texture_block_array_index I = {Index}; + return GetPtr(Arr, I); +} - auto AtE = AtElements(Arr); - umm Total = GetIndex(&AtE); - texture *Result = {}; - if (Index < Total) { Result = GetPtr(Arr, Index); } + +link_internal texture * +TryGetPtr( texture_block_array *Arr, texture_block_array_index Index) +{ + texture * Result = {}; + if (Arr->BlockPtrs && Index < AtElements(Arr)) + { + Result = GetPtr(Arr, Index); + } return Result; } -link_internal u32 -AtElements(texture_block *Block) +link_internal texture * +TryGetPtr( texture_block_array *Arr, umm Index) { - return Block->At; + auto Result = TryGetPtr(Arr, texture_block_array_index{Index}); + return Result; } diff --git a/generated/block_array_h_u32_688856411.h b/generated/block_array_h_u32_688856411.h index 5f3d078d6..87db87baa 100644 --- a/generated/block_array_h_u32_688856411.h +++ b/generated/block_array_h_u32_688856411.h @@ -1,164 +1,183 @@ -// external/bonsai_stdlib/src/primitive_containers.h:2:0 +// external/bonsai_stdlib/src/poof_functions.h:2211:0 + + + struct u32_block { - u32 Index; - u32 At; - u32 *Elements; - u32_block *Next; + /* u32 Index; */ + umm At; + u32 Elements[8]; }; struct u32_block_array_index { - u32_block *Block; - u32 BlockIndex; - u32 ElementIndex; + umm Index; }; struct u32_block_array { - u32_block *First; - u32_block *Current; + u32_block **BlockPtrs; poof(@array_length(Element->BlockCount)) + u32 BlockCount; + u32 ElementCount; memory_arena *Memory; poof(@no_serialize) }; -typedef u32_block_array u32_paged_list; +link_internal u32_block_array +U32BlockArray(memory_arena *Memory) +{ + u32_block_array Result = {}; + Result.Memory = Memory; + return Result; +} -link_internal u32_block_array_index -operator++(u32_block_array_index &I0) +link_internal b32 +AreEqual(u32_block_array_index *Thing1, u32_block_array_index *Thing2) { - if (I0.Block) + if (Thing1 && Thing2) { - if (I0.ElementIndex == 8-1) - { - I0.ElementIndex = 0; - I0.BlockIndex++; - I0.Block = I0.Block->Next; - } - else - { - I0.ElementIndex++; - } + b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( u32_block_array_index ) ); + + return Result; } else { - I0.ElementIndex++; + return (Thing1 == Thing2); } +} + +link_internal b32 +AreEqual(u32_block_array_index Thing1, u32_block_array_index Thing2) +{ + b32 Result = MemoryIsEqual((u8*)&Thing1, (u8*)&Thing2, sizeof( u32_block_array_index ) ); + + return Result; +} + + +typedef u32_block_array u32_paged_list; + +link_internal u32_block_array_index +operator++( u32_block_array_index &I0 ) +{ + I0.Index++; return I0; } link_internal b32 -operator<(u32_block_array_index I0, u32_block_array_index I1) +operator<( u32_block_array_index I0, u32_block_array_index I1 ) { - b32 Result = I0.BlockIndex < I1.BlockIndex || (I0.BlockIndex == I1.BlockIndex & I0.ElementIndex < I1.ElementIndex); + b32 Result = I0.Index < I1.Index; + return Result; +} + +link_internal b32 +operator==( u32_block_array_index I0, u32_block_array_index I1 ) +{ + b32 Result = I0.Index == I1.Index; return Result; } link_inline umm -GetIndex(u32_block_array_index *Index) +GetIndex( u32_block_array_index *Index) { - umm Result = Index->ElementIndex + (Index->BlockIndex*8); + umm Result = Index->Index; return Result; } + link_internal u32_block_array_index -ZerothIndex(u32_block_array *Arr) +ZerothIndex( u32_block_array *Arr ) { - u32_block_array_index Result = {}; - Result.Block = Arr->First; - /* Assert(Result.Block->Index == 0); */ - return Result; + return {}; } -link_internal umm -TotalElements(u32_block_array *Arr) +link_internal u32_block_array_index +Capacity( u32_block_array *Arr ) { - umm Result = 0; - if (Arr->Current) - { - Result = (Arr->Current->Index * 8) + Arr->Current->At; - } + u32_block_array_index Result = {Arr->BlockCount * 8}; return Result; } link_internal u32_block_array_index -LastIndex(u32_block_array *Arr) +AtElements( u32_block_array *Arr ) { - u32_block_array_index Result = {}; - if (Arr->Current) - { - Result.Block = Arr->Current; - Result.BlockIndex = Arr->Current->Index; - Result.ElementIndex = Arr->Current->At; - Assert(Result.ElementIndex); - Result.ElementIndex--; - } + u32_block_array_index Result = {Arr->ElementCount}; + return Result; +} + + +link_internal umm +TotalElements( u32_block_array *Arr ) +{ + umm Result = AtElements(Arr).Index; return Result; } + link_internal u32_block_array_index -AtElements(u32_block_array *Arr) +LastIndex( u32_block_array *Arr ) { u32_block_array_index Result = {}; - if (Arr->Current) - { - Result.Block = Arr->Current; - Result.BlockIndex = Arr->Current->Index; - Result.ElementIndex = Arr->Current->At; - } + umm Count = AtElements(Arr).Index; + if (Count) Result.Index = Count-1; return Result; } -link_internal u32 * -GetPtr(u32_block_array *Arr, u32_block_array_index Index) +link_internal umm +Count( u32_block_array *Arr ) { - u32 *Result = {}; - if (Index.Block) { Result = Index.Block->Elements + Index.ElementIndex; } + auto Result = AtElements(Arr).Index; return Result; } -link_internal u32 * -GetPtr(u32_block *Block, umm Index) +link_internal u32_block * +GetBlock( u32_block_array *Arr, u32_block_array_index Index ) { - u32 *Result = 0; - if (Index < Block->At) { Result = Block->Elements + Index; } - return Result; + umm BlockIndex = Index.Index / 8; + Assert(BlockIndex < Arr->BlockCount); + u32_block *Block = Arr->BlockPtrs[BlockIndex]; + return Block; } link_internal u32 * -GetPtr(u32_block_array *Arr, umm Index) +GetPtr( u32_block_array *Arr, u32_block_array_index Index ) { - umm BlockIndex = Index / 8; - umm ElementIndex = Index % 8; + Assert(Arr->BlockPtrs); + Assert(Index.Index < Capacity(Arr).Index); - umm AtBlock = 0; - u32_block *Block = Arr->First; - while (AtBlock++ < BlockIndex) - { - Block = Block->Next; - } + u32_block *Block = GetBlock(Arr, Index); - u32 *Result = Block->Elements+ElementIndex; + umm ElementIndex = Index.Index % 8; + u32 *Result = (Block->Elements + ElementIndex); return Result; } + link_internal u32 * -TryGetPtr(u32_block_array *Arr, umm Index) +GetPtr( u32_block_array *Arr, umm Index ) { - umm BlockIndex = Index / 8; - umm ElementIndex = Index % 8; + u32_block_array_index I = {Index}; + return GetPtr(Arr, I); +} - auto AtE = AtElements(Arr); - umm Total = GetIndex(&AtE); - u32 *Result = {}; - if (Index < Total) { Result = GetPtr(Arr, Index); } + +link_internal u32 * +TryGetPtr( u32_block_array *Arr, u32_block_array_index Index) +{ + u32 * Result = {}; + if (Arr->BlockPtrs && Index < AtElements(Arr)) + { + Result = GetPtr(Arr, Index); + } return Result; } -link_internal u32 -AtElements(u32_block *Block) +link_internal u32 * +TryGetPtr( u32_block_array *Arr, umm Index) { - return Block->At; + auto Result = TryGetPtr(Arr, u32_block_array_index{Index}); + return Result; } diff --git a/generated/block_array_h_u8_cursor_688856411.h b/generated/block_array_h_u8_cursor_688856411.h index 010baeb2f..c6d470046 100644 --- a/generated/block_array_h_u8_cursor_688856411.h +++ b/generated/block_array_h_u8_cursor_688856411.h @@ -1,164 +1,183 @@ -// external/bonsai_stdlib/src/ansi_stream.h:6:0 +// external/bonsai_stdlib/src/poof_functions.h:2211:0 + + + struct u8_cursor_block { - u32 Index; - u32 At; - u8_cursor *Elements; - u8_cursor_block *Next; + /* u32 Index; */ + umm At; + u8_cursor Elements[8]; }; struct u8_cursor_block_array_index { - u8_cursor_block *Block; - u32 BlockIndex; - u32 ElementIndex; + umm Index; }; struct u8_cursor_block_array { - u8_cursor_block *First; - u8_cursor_block *Current; + u8_cursor_block **BlockPtrs; poof(@array_length(Element->BlockCount)) + u32 BlockCount; + u32 ElementCount; memory_arena *Memory; poof(@no_serialize) u64 BlockSize; }; -typedef u8_cursor_block_array u8_cursor_paged_list; +link_internal u8_cursor_block_array +U8CursorBlockArray(memory_arena *Memory) +{ + u8_cursor_block_array Result = {}; + Result.Memory = Memory; + return Result; +} -link_internal u8_cursor_block_array_index -operator++(u8_cursor_block_array_index &I0) +link_internal b32 +AreEqual(u8_cursor_block_array_index *Thing1, u8_cursor_block_array_index *Thing2) { - if (I0.Block) + if (Thing1 && Thing2) { - if (I0.ElementIndex == 8-1) - { - I0.ElementIndex = 0; - I0.BlockIndex++; - I0.Block = I0.Block->Next; - } - else - { - I0.ElementIndex++; - } + b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( u8_cursor_block_array_index ) ); + + return Result; } else { - I0.ElementIndex++; + return (Thing1 == Thing2); } +} + +link_internal b32 +AreEqual(u8_cursor_block_array_index Thing1, u8_cursor_block_array_index Thing2) +{ + b32 Result = MemoryIsEqual((u8*)&Thing1, (u8*)&Thing2, sizeof( u8_cursor_block_array_index ) ); + + return Result; +} + + +typedef u8_cursor_block_array u8_cursor_paged_list; + +link_internal u8_cursor_block_array_index +operator++( u8_cursor_block_array_index &I0 ) +{ + I0.Index++; return I0; } link_internal b32 -operator<(u8_cursor_block_array_index I0, u8_cursor_block_array_index I1) +operator<( u8_cursor_block_array_index I0, u8_cursor_block_array_index I1 ) { - b32 Result = I0.BlockIndex < I1.BlockIndex || (I0.BlockIndex == I1.BlockIndex & I0.ElementIndex < I1.ElementIndex); + b32 Result = I0.Index < I1.Index; + return Result; +} + +link_internal b32 +operator==( u8_cursor_block_array_index I0, u8_cursor_block_array_index I1 ) +{ + b32 Result = I0.Index == I1.Index; return Result; } link_inline umm -GetIndex(u8_cursor_block_array_index *Index) +GetIndex( u8_cursor_block_array_index *Index) { - umm Result = Index->ElementIndex + (Index->BlockIndex*8); + umm Result = Index->Index; return Result; } + link_internal u8_cursor_block_array_index -ZerothIndex(u8_cursor_block_array *Arr) +ZerothIndex( u8_cursor_block_array *Arr ) { - u8_cursor_block_array_index Result = {}; - Result.Block = Arr->First; - /* Assert(Result.Block->Index == 0); */ - return Result; + return {}; } -link_internal umm -TotalElements(u8_cursor_block_array *Arr) +link_internal u8_cursor_block_array_index +Capacity( u8_cursor_block_array *Arr ) { - umm Result = 0; - if (Arr->Current) - { - Result = (Arr->Current->Index * 8) + Arr->Current->At; - } + u8_cursor_block_array_index Result = {Arr->BlockCount * 8}; return Result; } link_internal u8_cursor_block_array_index -LastIndex(u8_cursor_block_array *Arr) +AtElements( u8_cursor_block_array *Arr ) { - u8_cursor_block_array_index Result = {}; - if (Arr->Current) - { - Result.Block = Arr->Current; - Result.BlockIndex = Arr->Current->Index; - Result.ElementIndex = Arr->Current->At; - Assert(Result.ElementIndex); - Result.ElementIndex--; - } + u8_cursor_block_array_index Result = {Arr->ElementCount}; + return Result; +} + + +link_internal umm +TotalElements( u8_cursor_block_array *Arr ) +{ + umm Result = AtElements(Arr).Index; return Result; } + link_internal u8_cursor_block_array_index -AtElements(u8_cursor_block_array *Arr) +LastIndex( u8_cursor_block_array *Arr ) { u8_cursor_block_array_index Result = {}; - if (Arr->Current) - { - Result.Block = Arr->Current; - Result.BlockIndex = Arr->Current->Index; - Result.ElementIndex = Arr->Current->At; - } + umm Count = AtElements(Arr).Index; + if (Count) Result.Index = Count-1; return Result; } -link_internal u8_cursor * -GetPtr(u8_cursor_block_array *Arr, u8_cursor_block_array_index Index) +link_internal umm +Count( u8_cursor_block_array *Arr ) { - u8_cursor *Result = {}; - if (Index.Block) { Result = Index.Block->Elements + Index.ElementIndex; } + auto Result = AtElements(Arr).Index; return Result; } -link_internal u8_cursor * -GetPtr(u8_cursor_block *Block, umm Index) +link_internal u8_cursor_block * +GetBlock( u8_cursor_block_array *Arr, u8_cursor_block_array_index Index ) { - u8_cursor *Result = 0; - if (Index < Block->At) { Result = Block->Elements + Index; } - return Result; + umm BlockIndex = Index.Index / 8; + Assert(BlockIndex < Arr->BlockCount); + u8_cursor_block *Block = Arr->BlockPtrs[BlockIndex]; + return Block; } link_internal u8_cursor * -GetPtr(u8_cursor_block_array *Arr, umm Index) +GetPtr( u8_cursor_block_array *Arr, u8_cursor_block_array_index Index ) { - umm BlockIndex = Index / 8; - umm ElementIndex = Index % 8; + Assert(Arr->BlockPtrs); + Assert(Index.Index < Capacity(Arr).Index); - umm AtBlock = 0; - u8_cursor_block *Block = Arr->First; - while (AtBlock++ < BlockIndex) - { - Block = Block->Next; - } + u8_cursor_block *Block = GetBlock(Arr, Index); - u8_cursor *Result = Block->Elements+ElementIndex; + umm ElementIndex = Index.Index % 8; + u8_cursor *Result = (Block->Elements + ElementIndex); return Result; } + link_internal u8_cursor * -TryGetPtr(u8_cursor_block_array *Arr, umm Index) +GetPtr( u8_cursor_block_array *Arr, umm Index ) { - umm BlockIndex = Index / 8; - umm ElementIndex = Index % 8; + u8_cursor_block_array_index I = {Index}; + return GetPtr(Arr, I); +} - auto AtE = AtElements(Arr); - umm Total = GetIndex(&AtE); - u8_cursor *Result = {}; - if (Index < Total) { Result = GetPtr(Arr, Index); } + +link_internal u8_cursor * +TryGetPtr( u8_cursor_block_array *Arr, u8_cursor_block_array_index Index) +{ + u8_cursor * Result = {}; + if (Arr->BlockPtrs && Index < AtElements(Arr)) + { + Result = GetPtr(Arr, Index); + } return Result; } -link_internal u32 -AtElements(u8_cursor_block *Block) +link_internal u8_cursor * +TryGetPtr( u8_cursor_block_array *Arr, umm Index) { - return Block->At; + auto Result = TryGetPtr(Arr, u8_cursor_block_array_index{Index}); + return Result; } 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 7f0ffb9df..e8899c5fe 100644 --- a/generated/block_array_h_world_chunk_ptr_688853862_0.h +++ b/generated/block_array_h_world_chunk_ptr_688853862_0.h @@ -1,164 +1,183 @@ -// src/engine/world_chunk.h:462:0 +// external/bonsai_stdlib/src/poof_functions.h:2211:0 + + + struct world_chunk_ptr_block { - u32 Index; - u32 At; - world_chunk_ptr *Elements; - world_chunk_ptr_block *Next; + /* u32 Index; */ + umm At; + world_chunk_ptr Elements[32]; }; struct world_chunk_ptr_block_array_index { - world_chunk_ptr_block *Block; - u32 BlockIndex; - u32 ElementIndex; + umm Index; }; struct world_chunk_ptr_block_array { - world_chunk_ptr_block *First; - world_chunk_ptr_block *Current; + world_chunk_ptr_block **BlockPtrs; poof(@array_length(Element->BlockCount)) + u32 BlockCount; + u32 ElementCount; memory_arena *Memory; poof(@no_serialize) }; -typedef world_chunk_ptr_block_array world_chunk_ptr_paged_list; +link_internal world_chunk_ptr_block_array +WorldChunkPtrBlockArray(memory_arena *Memory) +{ + world_chunk_ptr_block_array Result = {}; + Result.Memory = Memory; + return Result; +} -link_internal world_chunk_ptr_block_array_index -operator++(world_chunk_ptr_block_array_index &I0) +link_internal b32 +AreEqual(world_chunk_ptr_block_array_index *Thing1, world_chunk_ptr_block_array_index *Thing2) { - if (I0.Block) + if (Thing1 && Thing2) { - if (I0.ElementIndex == 32-1) - { - I0.ElementIndex = 0; - I0.BlockIndex++; - I0.Block = I0.Block->Next; - } - else - { - I0.ElementIndex++; - } + b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( world_chunk_ptr_block_array_index ) ); + + return Result; } else { - I0.ElementIndex++; + return (Thing1 == Thing2); } +} + +link_internal b32 +AreEqual(world_chunk_ptr_block_array_index Thing1, world_chunk_ptr_block_array_index Thing2) +{ + b32 Result = MemoryIsEqual((u8*)&Thing1, (u8*)&Thing2, sizeof( world_chunk_ptr_block_array_index ) ); + + return Result; +} + + +typedef world_chunk_ptr_block_array world_chunk_ptr_paged_list; + +link_internal world_chunk_ptr_block_array_index +operator++( world_chunk_ptr_block_array_index &I0 ) +{ + I0.Index++; return I0; } link_internal b32 -operator<(world_chunk_ptr_block_array_index I0, world_chunk_ptr_block_array_index I1) +operator<( world_chunk_ptr_block_array_index I0, world_chunk_ptr_block_array_index I1 ) { - b32 Result = I0.BlockIndex < I1.BlockIndex || (I0.BlockIndex == I1.BlockIndex & I0.ElementIndex < I1.ElementIndex); + b32 Result = I0.Index < I1.Index; + return Result; +} + +link_internal b32 +operator==( world_chunk_ptr_block_array_index I0, world_chunk_ptr_block_array_index I1 ) +{ + b32 Result = I0.Index == I1.Index; return Result; } link_inline umm -GetIndex(world_chunk_ptr_block_array_index *Index) +GetIndex( world_chunk_ptr_block_array_index *Index) { - umm Result = Index->ElementIndex + (Index->BlockIndex*32); + umm Result = Index->Index; return Result; } + +link_internal world_chunk_ptr_block_array_index +ZerothIndex( world_chunk_ptr_block_array *Arr ) +{ + return {}; +} + link_internal world_chunk_ptr_block_array_index -ZerothIndex(world_chunk_ptr_block_array *Arr) +Capacity( world_chunk_ptr_block_array *Arr ) { - world_chunk_ptr_block_array_index Result = {}; - Result.Block = Arr->First; - /* Assert(Result.Block->Index == 0); */ + world_chunk_ptr_block_array_index Result = {Arr->BlockCount * 32}; return Result; } -link_internal umm -TotalElements(world_chunk_ptr_block_array *Arr) +link_internal world_chunk_ptr_block_array_index +AtElements( world_chunk_ptr_block_array *Arr ) { - umm Result = 0; - if (Arr->Current) - { - Result = (Arr->Current->Index * 32) + Arr->Current->At; - } + world_chunk_ptr_block_array_index Result = {Arr->ElementCount}; return Result; } -link_internal world_chunk_ptr_block_array_index -LastIndex(world_chunk_ptr_block_array *Arr) + +link_internal umm +TotalElements( world_chunk_ptr_block_array *Arr ) { - world_chunk_ptr_block_array_index Result = {}; - if (Arr->Current) - { - Result.Block = Arr->Current; - Result.BlockIndex = Arr->Current->Index; - Result.ElementIndex = Arr->Current->At; - Assert(Result.ElementIndex); - Result.ElementIndex--; - } + umm Result = AtElements(Arr).Index; return Result; } + link_internal world_chunk_ptr_block_array_index -AtElements(world_chunk_ptr_block_array *Arr) +LastIndex( world_chunk_ptr_block_array *Arr ) { world_chunk_ptr_block_array_index Result = {}; - if (Arr->Current) - { - Result.Block = Arr->Current; - Result.BlockIndex = Arr->Current->Index; - Result.ElementIndex = Arr->Current->At; - } + umm Count = AtElements(Arr).Index; + if (Count) Result.Index = Count-1; return Result; } -link_internal world_chunk_ptr * -GetPtr(world_chunk_ptr_block_array *Arr, world_chunk_ptr_block_array_index Index) +link_internal umm +Count( world_chunk_ptr_block_array *Arr ) { - world_chunk_ptr *Result = {}; - if (Index.Block) { Result = Index.Block->Elements + Index.ElementIndex; } + auto Result = AtElements(Arr).Index; return Result; } -link_internal world_chunk_ptr * -GetPtr(world_chunk_ptr_block *Block, umm Index) +link_internal world_chunk_ptr_block * +GetBlock( world_chunk_ptr_block_array *Arr, world_chunk_ptr_block_array_index Index ) { - world_chunk_ptr *Result = 0; - if (Index < Block->At) { Result = Block->Elements + Index; } - return Result; + umm BlockIndex = Index.Index / 32; + Assert(BlockIndex < Arr->BlockCount); + world_chunk_ptr_block *Block = Arr->BlockPtrs[BlockIndex]; + return Block; } -link_internal world_chunk_ptr * -GetPtr(world_chunk_ptr_block_array *Arr, umm Index) +link_internal world_chunk_ptr +GetPtr( world_chunk_ptr_block_array *Arr, world_chunk_ptr_block_array_index Index ) { - umm BlockIndex = Index / 32; - umm ElementIndex = Index % 32; + Assert(Arr->BlockPtrs); + Assert(Index.Index < Capacity(Arr).Index); - umm AtBlock = 0; - world_chunk_ptr_block *Block = Arr->First; - while (AtBlock++ < BlockIndex) - { - Block = Block->Next; - } + world_chunk_ptr_block *Block = GetBlock(Arr, Index); - world_chunk_ptr *Result = Block->Elements+ElementIndex; + umm ElementIndex = Index.Index % 32; + world_chunk_ptr Result = *(Block->Elements + ElementIndex); return Result; } -link_internal world_chunk_ptr * -TryGetPtr(world_chunk_ptr_block_array *Arr, umm Index) + +link_internal world_chunk_ptr +GetPtr( world_chunk_ptr_block_array *Arr, umm Index ) { - umm BlockIndex = Index / 32; - umm ElementIndex = Index % 32; + world_chunk_ptr_block_array_index I = {Index}; + return GetPtr(Arr, I); +} - auto AtE = AtElements(Arr); - umm Total = GetIndex(&AtE); - world_chunk_ptr *Result = {}; - if (Index < Total) { Result = GetPtr(Arr, Index); } + +link_internal world_chunk_ptr +TryGetPtr( world_chunk_ptr_block_array *Arr, world_chunk_ptr_block_array_index Index) +{ + world_chunk_ptr Result = {}; + if (Arr->BlockPtrs && Index < AtElements(Arr)) + { + Result = GetPtr(Arr, Index); + } return Result; } -link_internal u32 -AtElements(world_chunk_ptr_block *Block) +link_internal world_chunk_ptr +TryGetPtr( world_chunk_ptr_block_array *Arr, umm Index) { - return Block->At; + auto Result = TryGetPtr(Arr, world_chunk_ptr_block_array_index{Index}); + return Result; } diff --git a/generated/block_array_member_info_688856411.h b/generated/block_array_member_info_688856411.h index e22315a09..4f5e12d3c 100644 --- a/generated/block_array_member_info_688856411.h +++ b/generated/block_array_member_info_688856411.h @@ -1,240 +1,363 @@ -// src/engine/bonsai_type_info.h:11:0 +// external/bonsai_stdlib/src/poof_functions.h:2600:0 + + + struct member_info_block { - u32 Index; - u32 At; - member_info *Elements; - member_info_block *Next; + /* u32 Index; */ + umm At; + member_info Elements[8]; }; struct member_info_block_array_index { - member_info_block *Block; - u32 BlockIndex; - u32 ElementIndex; + umm Index; }; struct member_info_block_array { - member_info_block *First; - member_info_block *Current; + member_info_block **BlockPtrs; poof(@array_length(Element->BlockCount)) + u32 BlockCount; + u32 ElementCount; memory_arena *Memory; poof(@no_serialize) }; -typedef member_info_block_array member_info_paged_list; +link_internal member_info_block_array +MemberInfoBlockArray(memory_arena *Memory) +{ + member_info_block_array Result = {}; + Result.Memory = Memory; + return Result; +} -link_internal member_info_block_array_index -operator++(member_info_block_array_index &I0) +link_internal b32 +AreEqual(member_info_block_array_index *Thing1, member_info_block_array_index *Thing2) { - if (I0.Block) + if (Thing1 && Thing2) { - if (I0.ElementIndex == 8-1) - { - I0.ElementIndex = 0; - I0.BlockIndex++; - I0.Block = I0.Block->Next; - } - else - { - I0.ElementIndex++; - } + b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( member_info_block_array_index ) ); + + return Result; } else { - I0.ElementIndex++; + return (Thing1 == Thing2); } +} + +link_internal b32 +AreEqual(member_info_block_array_index Thing1, member_info_block_array_index Thing2) +{ + b32 Result = MemoryIsEqual((u8*)&Thing1, (u8*)&Thing2, sizeof( member_info_block_array_index ) ); + + return Result; +} + + +typedef member_info_block_array member_info_paged_list; + +link_internal member_info_block_array_index +operator++( member_info_block_array_index &I0 ) +{ + I0.Index++; return I0; } link_internal b32 -operator<(member_info_block_array_index I0, member_info_block_array_index I1) +operator<( member_info_block_array_index I0, member_info_block_array_index I1 ) { - b32 Result = I0.BlockIndex < I1.BlockIndex || (I0.BlockIndex == I1.BlockIndex & I0.ElementIndex < I1.ElementIndex); + b32 Result = I0.Index < I1.Index; + return Result; +} + +link_internal b32 +operator==( member_info_block_array_index I0, member_info_block_array_index I1 ) +{ + b32 Result = I0.Index == I1.Index; return Result; } link_inline umm -GetIndex(member_info_block_array_index *Index) +GetIndex( member_info_block_array_index *Index) { - umm Result = Index->ElementIndex + (Index->BlockIndex*8); + umm Result = Index->Index; return Result; } + link_internal member_info_block_array_index -ZerothIndex(member_info_block_array *Arr) +ZerothIndex( member_info_block_array *Arr ) { - member_info_block_array_index Result = {}; - Result.Block = Arr->First; - /* Assert(Result.Block->Index == 0); */ - return Result; + return {}; } -link_internal umm -TotalElements(member_info_block_array *Arr) +link_internal member_info_block_array_index +Capacity( member_info_block_array *Arr ) { - umm Result = 0; - if (Arr->Current) - { - Result = (Arr->Current->Index * 8) + Arr->Current->At; - } + member_info_block_array_index Result = {Arr->BlockCount * 8}; return Result; } link_internal member_info_block_array_index -LastIndex(member_info_block_array *Arr) +AtElements( member_info_block_array *Arr ) { - member_info_block_array_index Result = {}; - if (Arr->Current) - { - Result.Block = Arr->Current; - Result.BlockIndex = Arr->Current->Index; - Result.ElementIndex = Arr->Current->At; - Assert(Result.ElementIndex); - Result.ElementIndex--; - } + member_info_block_array_index Result = {Arr->ElementCount}; return Result; } + +link_internal umm +TotalElements( member_info_block_array *Arr ) +{ + umm Result = AtElements(Arr).Index; + return Result; +} + + link_internal member_info_block_array_index -AtElements(member_info_block_array *Arr) +LastIndex( member_info_block_array *Arr ) { member_info_block_array_index Result = {}; - if (Arr->Current) - { - Result.Block = Arr->Current; - Result.BlockIndex = Arr->Current->Index; - Result.ElementIndex = Arr->Current->At; - } + umm Count = AtElements(Arr).Index; + if (Count) Result.Index = Count-1; return Result; } -link_internal member_info * -GetPtr(member_info_block_array *Arr, member_info_block_array_index Index) +link_internal umm +Count( member_info_block_array *Arr ) { - member_info *Result = {}; - if (Index.Block) { Result = Index.Block->Elements + Index.ElementIndex; } + auto Result = AtElements(Arr).Index; return Result; } +link_internal member_info_block * +GetBlock( member_info_block_array *Arr, member_info_block_array_index Index ) +{ + umm BlockIndex = Index.Index / 8; + Assert(BlockIndex < Arr->BlockCount); + member_info_block *Block = Arr->BlockPtrs[BlockIndex]; + return Block; +} + link_internal member_info * -GetPtr(member_info_block *Block, umm Index) +GetPtr( member_info_block_array *Arr, member_info_block_array_index Index ) { - member_info *Result = 0; - if (Index < Block->At) { Result = Block->Elements + Index; } + Assert(Arr->BlockPtrs); + Assert(Index.Index < Capacity(Arr).Index); + + member_info_block *Block = GetBlock(Arr, Index); + + umm ElementIndex = Index.Index % 8; + member_info *Result = (Block->Elements + ElementIndex); return Result; } + link_internal member_info * -GetPtr(member_info_block_array *Arr, umm Index) +GetPtr( member_info_block_array *Arr, umm Index ) { - umm BlockIndex = Index / 8; - umm ElementIndex = Index % 8; + member_info_block_array_index I = {Index}; + return GetPtr(Arr, I); +} + - umm AtBlock = 0; - member_info_block *Block = Arr->First; - while (AtBlock++ < BlockIndex) +link_internal member_info * +TryGetPtr( member_info_block_array *Arr, member_info_block_array_index Index) +{ + member_info * Result = {}; + if (Arr->BlockPtrs && Index < AtElements(Arr)) { - Block = Block->Next; + Result = GetPtr(Arr, Index); } - - member_info *Result = Block->Elements+ElementIndex; return Result; } link_internal member_info * -TryGetPtr(member_info_block_array *Arr, umm Index) +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); } + auto Result = TryGetPtr(Arr, member_info_block_array_index{Index}); return Result; } -link_internal u32 -AtElements(member_info_block *Block) + + + + +link_internal cs +CS( member_info_block_array_index Index ) { - return Block->At; + return FSz("(%u)", Index.Index); } - -link_internal member_info_block* -Allocate_member_info_block(memory_arena *Memory) +link_internal member_info * +Set( member_info_block_array *Arr, + member_info *Element, + member_info_block_array_index Index ) { - member_info_block *Result = Allocate(member_info_block, Memory, 1); - Result->Elements = Allocate(member_info, Memory, 8); - return Result; + Assert(Arr->BlockPtrs); + Assert(Index.Index < Capacity(Arr).Index); + member_info_block *Block = GetBlock(Arr, Index); + umm ElementIndex = Index.Index % 8; + auto Slot = Block->Elements+ElementIndex; + *Slot = *Element; + return Slot; } -link_internal cs -CS(member_info_block_array_index Index) +link_internal void +NewBlock( member_info_block_array *Arr ) { - return FSz("(%u)(%u)", Index.BlockIndex, Index.ElementIndex); + member_info_block *NewBlock = Allocate( member_info_block , Arr->Memory, 1); + member_info_block **NewBlockPtrs = Allocate( member_info_block*, Arr->Memory, Arr->BlockCount+1); + + RangeIterator_t(u32, BlockI, Arr->BlockCount) + { + NewBlockPtrs[BlockI] = Arr->BlockPtrs[BlockI]; + } + + NewBlockPtrs[Arr->BlockCount] = NewBlock; + + + + Arr->BlockPtrs = NewBlockPtrs; + Arr->BlockCount += 1; } link_internal void -RemoveUnordered(member_info_block_array *Array, member_info_block_array_index Index) +RemoveUnordered( member_info_block_array *Array, member_info_block_array_index Index) { - member_info_block_array_index LastI = LastIndex(Array); + auto LastI = LastIndex(Array); + Assert(Index.Index <= LastI.Index); - member_info *Element = GetPtr(Array, Index); - member_info *LastElement = GetPtr(Array, LastI); + auto LastElement = GetPtr(Array, LastI); + Set(Array, LastElement, Index); + Array->ElementCount -= 1; +} - *Element = *LastElement; +link_internal void +RemoveOrdered( member_info_block_array *Array, member_info_block_array_index IndexToRemove) +{ + Assert(IndexToRemove.Index < Array->ElementCount); - Assert(Array->Current->At); - Array->Current->At -= 1; + member_info *Prev = {}; - if (Array->Current->At == 0) + member_info_block_array_index Max = AtElements(Array); + RangeIteratorRange_t(umm, Index, Max.Index, IndexToRemove.Index) { - // Walk the chain till we get to the second-last one - member_info_block *Current = Array->First; - member_info_block *LastB = LastI.Block; + member_info *E = GetPtr(Array, Index); - while (Current->Next && Current->Next != LastB) + if (Prev) { - Current = Current->Next; + *Prev = *E; } - Assert(Current->Next == LastB || Current->Next == 0); - Array->Current = Current; + Prev = E; } + + Array->ElementCount -= 1; } -link_internal member_info * -Push(member_info_block_array *Array, member_info *Element) +link_internal void +RemoveOrdered( member_info_block_array *Array, member_info *Element ) { - if (Array->Memory == 0) { Array->Memory = AllocateArena(); } - - if (Array->First == 0) { Array->First = Allocate_member_info_block(Array->Memory); Array->Current = Array->First; } - - if (Array->Current->At == 8) + IterateOver(Array, E, I) { - if (Array->Current->Next) + if (E == Element) { - Array->Current = Array->Current->Next; - Assert(Array->Current->At == 0); + RemoveOrdered(Array, I); + break; } - else - { - member_info_block *Next = Allocate_member_info_block(Array->Memory); - Next->Index = Array->Current->Index + 1; + } +} - Array->Current->Next = Next; - Array->Current = Next; +link_internal member_info_block_array_index +Find( member_info_block_array *Array, member_info *Query) +{ + member_info_block_array_index Result = {INVALID_BLOCK_ARRAY_INDEX}; + IterateOver(Array, E, Index) + { + if ( E == Query ) + { + Result = Index; + break; } } + return Result; +} + + + +link_internal b32 +IsValid(member_info_block_array_index *Index) +{ + member_info_block_array_index Test = {INVALID_BLOCK_ARRAY_INDEX}; + b32 Result = (AreEqual(Index, &Test) == False); + return Result; +} + +link_internal member_info * +Push( member_info_block_array *Array, member_info *Element) +{ + Assert(Array->Memory); + + if (AtElements(Array) == Capacity(Array)) + { + NewBlock(Array); + } - member_info *Result = Array->Current->Elements + Array->Current->At; + member_info *Result = Set(Array, Element, AtElements(Array)); - Array->Current->Elements[Array->Current->At++] = *Element; + Array->ElementCount += 1; return Result; } +link_internal member_info * +Push( member_info_block_array *Array ) +{ + member_info Element = {}; + auto Result = Push(Array, &Element); + return Result; +} + +link_internal void +Insert( member_info_block_array *Array, member_info_block_array_index Index, member_info *Element ) +{ + Assert(Index.Index <= LastIndex(Array).Index); + Assert(Array->Memory); + + // Alocate a new thingy + member_info *Prev = Push(Array); + + auto Last = LastIndex(Array); + + RangeIteratorReverseRange(I, s32(Last.Index), s32(Index.Index)) + { + auto E = GetPtr(Array, umm(I)); + *Prev = *E; + Prev = E; + } + + *Prev = *Element; +} + +link_internal void +Insert( member_info_block_array *Array, u32 Index, member_info *Element ) +{ + Insert(Array, { .Index = Index }, Element); +} + +link_internal void +Shift( member_info_block_array *Array, member_info *Element ) +{ + Insert(Array, { .Index = 0 }, Element); +} + +/* element_t.has_tag(do_editor_ui)? */ +/* { */ +/* do_editor_ui_for_container( block_array_t ) */ +/* } */ + + diff --git a/generated/block_array_model_688856411.h b/generated/block_array_model_688856411.h index dda3b7ebc..d97cfccea 100644 --- a/generated/block_array_model_688856411.h +++ b/generated/block_array_model_688856411.h @@ -1,240 +1,363 @@ -// src/engine/model.h:91:0 +// external/bonsai_stdlib/src/poof_functions.h:2600:0 + + + struct model_block { - u32 Index; - u32 At; - model *Elements; - model_block *Next; + /* u32 Index; */ + umm At; + model Elements[8]; }; struct model_block_array_index { - model_block *Block; - u32 BlockIndex; - u32 ElementIndex; + umm Index; }; struct model_block_array { - model_block *First; - model_block *Current; + model_block **BlockPtrs; poof(@array_length(Element->BlockCount)) + u32 BlockCount; + u32 ElementCount; memory_arena *Memory; poof(@no_serialize) }; -typedef model_block_array model_paged_list; +link_internal model_block_array +ModelBlockArray(memory_arena *Memory) +{ + model_block_array Result = {}; + Result.Memory = Memory; + return Result; +} -link_internal model_block_array_index -operator++(model_block_array_index &I0) +link_internal b32 +AreEqual(model_block_array_index *Thing1, model_block_array_index *Thing2) { - if (I0.Block) + if (Thing1 && Thing2) { - if (I0.ElementIndex == 8-1) - { - I0.ElementIndex = 0; - I0.BlockIndex++; - I0.Block = I0.Block->Next; - } - else - { - I0.ElementIndex++; - } + b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( model_block_array_index ) ); + + return Result; } else { - I0.ElementIndex++; + return (Thing1 == Thing2); } +} + +link_internal b32 +AreEqual(model_block_array_index Thing1, model_block_array_index Thing2) +{ + b32 Result = MemoryIsEqual((u8*)&Thing1, (u8*)&Thing2, sizeof( model_block_array_index ) ); + + return Result; +} + + +typedef model_block_array model_paged_list; + +link_internal model_block_array_index +operator++( model_block_array_index &I0 ) +{ + I0.Index++; return I0; } link_internal b32 -operator<(model_block_array_index I0, model_block_array_index I1) +operator<( model_block_array_index I0, model_block_array_index I1 ) { - b32 Result = I0.BlockIndex < I1.BlockIndex || (I0.BlockIndex == I1.BlockIndex & I0.ElementIndex < I1.ElementIndex); + b32 Result = I0.Index < I1.Index; + return Result; +} + +link_internal b32 +operator==( model_block_array_index I0, model_block_array_index I1 ) +{ + b32 Result = I0.Index == I1.Index; return Result; } link_inline umm -GetIndex(model_block_array_index *Index) +GetIndex( model_block_array_index *Index) { - umm Result = Index->ElementIndex + (Index->BlockIndex*8); + umm Result = Index->Index; return Result; } + link_internal model_block_array_index -ZerothIndex(model_block_array *Arr) +ZerothIndex( model_block_array *Arr ) { - model_block_array_index Result = {}; - Result.Block = Arr->First; - /* Assert(Result.Block->Index == 0); */ - return Result; + return {}; } -link_internal umm -TotalElements(model_block_array *Arr) +link_internal model_block_array_index +Capacity( model_block_array *Arr ) { - umm Result = 0; - if (Arr->Current) - { - Result = (Arr->Current->Index * 8) + Arr->Current->At; - } + model_block_array_index Result = {Arr->BlockCount * 8}; return Result; } link_internal model_block_array_index -LastIndex(model_block_array *Arr) +AtElements( model_block_array *Arr ) { - model_block_array_index Result = {}; - if (Arr->Current) - { - Result.Block = Arr->Current; - Result.BlockIndex = Arr->Current->Index; - Result.ElementIndex = Arr->Current->At; - Assert(Result.ElementIndex); - Result.ElementIndex--; - } + model_block_array_index Result = {Arr->ElementCount}; return Result; } + +link_internal umm +TotalElements( model_block_array *Arr ) +{ + umm Result = AtElements(Arr).Index; + return Result; +} + + link_internal model_block_array_index -AtElements(model_block_array *Arr) +LastIndex( model_block_array *Arr ) { model_block_array_index Result = {}; - if (Arr->Current) - { - Result.Block = Arr->Current; - Result.BlockIndex = Arr->Current->Index; - Result.ElementIndex = Arr->Current->At; - } + umm Count = AtElements(Arr).Index; + if (Count) Result.Index = Count-1; return Result; } -link_internal model * -GetPtr(model_block_array *Arr, model_block_array_index Index) +link_internal umm +Count( model_block_array *Arr ) { - model *Result = {}; - if (Index.Block) { Result = Index.Block->Elements + Index.ElementIndex; } + auto Result = AtElements(Arr).Index; return Result; } +link_internal model_block * +GetBlock( model_block_array *Arr, model_block_array_index Index ) +{ + umm BlockIndex = Index.Index / 8; + Assert(BlockIndex < Arr->BlockCount); + model_block *Block = Arr->BlockPtrs[BlockIndex]; + return Block; +} + link_internal model * -GetPtr(model_block *Block, umm Index) +GetPtr( model_block_array *Arr, model_block_array_index Index ) { - model *Result = 0; - if (Index < Block->At) { Result = Block->Elements + Index; } + Assert(Arr->BlockPtrs); + Assert(Index.Index < Capacity(Arr).Index); + + model_block *Block = GetBlock(Arr, Index); + + umm ElementIndex = Index.Index % 8; + model *Result = (Block->Elements + ElementIndex); return Result; } + link_internal model * -GetPtr(model_block_array *Arr, umm Index) +GetPtr( model_block_array *Arr, umm Index ) { - umm BlockIndex = Index / 8; - umm ElementIndex = Index % 8; + model_block_array_index I = {Index}; + return GetPtr(Arr, I); +} + - umm AtBlock = 0; - model_block *Block = Arr->First; - while (AtBlock++ < BlockIndex) +link_internal model * +TryGetPtr( model_block_array *Arr, model_block_array_index Index) +{ + model * Result = {}; + if (Arr->BlockPtrs && Index < AtElements(Arr)) { - Block = Block->Next; + Result = GetPtr(Arr, Index); } - - model *Result = Block->Elements+ElementIndex; return Result; } link_internal model * -TryGetPtr(model_block_array *Arr, umm Index) +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); } + auto Result = TryGetPtr(Arr, model_block_array_index{Index}); return Result; } -link_internal u32 -AtElements(model_block *Block) + + + + +link_internal cs +CS( model_block_array_index Index ) { - return Block->At; + return FSz("(%u)", Index.Index); } - -link_internal model_block* -Allocate_model_block(memory_arena *Memory) +link_internal model * +Set( model_block_array *Arr, + model *Element, + model_block_array_index Index ) { - model_block *Result = Allocate(model_block, Memory, 1); - Result->Elements = Allocate(model, Memory, 8); - return Result; + Assert(Arr->BlockPtrs); + Assert(Index.Index < Capacity(Arr).Index); + model_block *Block = GetBlock(Arr, Index); + umm ElementIndex = Index.Index % 8; + auto Slot = Block->Elements+ElementIndex; + *Slot = *Element; + return Slot; } -link_internal cs -CS(model_block_array_index Index) +link_internal void +NewBlock( model_block_array *Arr ) { - return FSz("(%u)(%u)", Index.BlockIndex, Index.ElementIndex); + model_block *NewBlock = Allocate( model_block , Arr->Memory, 1); + model_block **NewBlockPtrs = Allocate( model_block*, Arr->Memory, Arr->BlockCount+1); + + RangeIterator_t(u32, BlockI, Arr->BlockCount) + { + NewBlockPtrs[BlockI] = Arr->BlockPtrs[BlockI]; + } + + NewBlockPtrs[Arr->BlockCount] = NewBlock; + + + + Arr->BlockPtrs = NewBlockPtrs; + Arr->BlockCount += 1; } link_internal void -RemoveUnordered(model_block_array *Array, model_block_array_index Index) +RemoveUnordered( model_block_array *Array, model_block_array_index Index) { - model_block_array_index LastI = LastIndex(Array); + auto LastI = LastIndex(Array); + Assert(Index.Index <= LastI.Index); - model *Element = GetPtr(Array, Index); - model *LastElement = GetPtr(Array, LastI); + auto LastElement = GetPtr(Array, LastI); + Set(Array, LastElement, Index); + Array->ElementCount -= 1; +} - *Element = *LastElement; +link_internal void +RemoveOrdered( model_block_array *Array, model_block_array_index IndexToRemove) +{ + Assert(IndexToRemove.Index < Array->ElementCount); - Assert(Array->Current->At); - Array->Current->At -= 1; + model *Prev = {}; - if (Array->Current->At == 0) + model_block_array_index Max = AtElements(Array); + RangeIteratorRange_t(umm, Index, Max.Index, IndexToRemove.Index) { - // Walk the chain till we get to the second-last one - model_block *Current = Array->First; - model_block *LastB = LastI.Block; + model *E = GetPtr(Array, Index); - while (Current->Next && Current->Next != LastB) + if (Prev) { - Current = Current->Next; + *Prev = *E; } - Assert(Current->Next == LastB || Current->Next == 0); - Array->Current = Current; + Prev = E; } + + Array->ElementCount -= 1; } -link_internal model * -Push(model_block_array *Array, model *Element) +link_internal void +RemoveOrdered( model_block_array *Array, model *Element ) { - if (Array->Memory == 0) { Array->Memory = AllocateArena(); } - - if (Array->First == 0) { Array->First = Allocate_model_block(Array->Memory); Array->Current = Array->First; } - - if (Array->Current->At == 8) + IterateOver(Array, E, I) { - if (Array->Current->Next) + if (E == Element) { - Array->Current = Array->Current->Next; - Assert(Array->Current->At == 0); + RemoveOrdered(Array, I); + break; } - else - { - model_block *Next = Allocate_model_block(Array->Memory); - Next->Index = Array->Current->Index + 1; + } +} - Array->Current->Next = Next; - Array->Current = Next; +link_internal model_block_array_index +Find( model_block_array *Array, model *Query) +{ + model_block_array_index Result = {INVALID_BLOCK_ARRAY_INDEX}; + IterateOver(Array, E, Index) + { + if ( E == Query ) + { + Result = Index; + break; } } + return Result; +} + + + +link_internal b32 +IsValid(model_block_array_index *Index) +{ + model_block_array_index Test = {INVALID_BLOCK_ARRAY_INDEX}; + b32 Result = (AreEqual(Index, &Test) == False); + return Result; +} + +link_internal model * +Push( model_block_array *Array, model *Element) +{ + Assert(Array->Memory); + + if (AtElements(Array) == Capacity(Array)) + { + NewBlock(Array); + } - model *Result = Array->Current->Elements + Array->Current->At; + model *Result = Set(Array, Element, AtElements(Array)); - Array->Current->Elements[Array->Current->At++] = *Element; + Array->ElementCount += 1; return Result; } +link_internal model * +Push( model_block_array *Array ) +{ + model Element = {}; + auto Result = Push(Array, &Element); + return Result; +} + +link_internal void +Insert( model_block_array *Array, model_block_array_index Index, model *Element ) +{ + Assert(Index.Index <= LastIndex(Array).Index); + Assert(Array->Memory); + + // Alocate a new thingy + model *Prev = Push(Array); + + auto Last = LastIndex(Array); + + RangeIteratorReverseRange(I, s32(Last.Index), s32(Index.Index)) + { + auto E = GetPtr(Array, umm(I)); + *Prev = *E; + Prev = E; + } + + *Prev = *Element; +} + +link_internal void +Insert( model_block_array *Array, u32 Index, model *Element ) +{ + Insert(Array, { .Index = Index }, Element); +} + +link_internal void +Shift( model_block_array *Array, model *Element ) +{ + Insert(Array, { .Index = 0 }, Element); +} + +/* element_t.has_tag(do_editor_ui)? */ +/* { */ +/* do_editor_ui_for_container( block_array_t ) */ +/* } */ + + diff --git a/generated/block_array_octree_node_ptr_688853862.h b/generated/block_array_octree_node_ptr_688853862.h new file mode 100644 index 000000000..d8265b7d6 --- /dev/null +++ b/generated/block_array_octree_node_ptr_688853862.h @@ -0,0 +1,363 @@ +// external/bonsai_stdlib/src/poof_functions.h:2600:0 + + + + +struct octree_node_ptr_block +{ + /* u32 Index; */ + umm At; + octree_node_ptr Elements[8]; +}; + +struct octree_node_ptr_block_array_index +{ + umm Index; +}; + +struct octree_node_ptr_block_array +{ + octree_node_ptr_block **BlockPtrs; poof(@array_length(Element->BlockCount)) + u32 BlockCount; + u32 ElementCount; + memory_arena *Memory; poof(@no_serialize) + +}; + +link_internal octree_node_ptr_block_array +OctreeNodePtrBlockArray(memory_arena *Memory) +{ + octree_node_ptr_block_array Result = {}; + Result.Memory = Memory; + return Result; +} + +link_internal b32 +AreEqual(octree_node_ptr_block_array_index *Thing1, octree_node_ptr_block_array_index *Thing2) +{ + if (Thing1 && Thing2) + { + b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( octree_node_ptr_block_array_index ) ); + + return Result; + } + else + { + return (Thing1 == Thing2); + } +} + +link_internal b32 +AreEqual(octree_node_ptr_block_array_index Thing1, octree_node_ptr_block_array_index Thing2) +{ + b32 Result = MemoryIsEqual((u8*)&Thing1, (u8*)&Thing2, sizeof( octree_node_ptr_block_array_index ) ); + + return Result; +} + + +typedef octree_node_ptr_block_array octree_node_ptr_paged_list; + +link_internal octree_node_ptr_block_array_index +operator++( octree_node_ptr_block_array_index &I0 ) +{ + I0.Index++; + return I0; +} + +link_internal b32 +operator<( octree_node_ptr_block_array_index I0, octree_node_ptr_block_array_index I1 ) +{ + b32 Result = I0.Index < I1.Index; + return Result; +} + +link_internal b32 +operator==( octree_node_ptr_block_array_index I0, octree_node_ptr_block_array_index I1 ) +{ + b32 Result = I0.Index == I1.Index; + return Result; +} + +link_inline umm +GetIndex( octree_node_ptr_block_array_index *Index) +{ + umm Result = Index->Index; + return Result; +} + + +link_internal octree_node_ptr_block_array_index +ZerothIndex( octree_node_ptr_block_array *Arr ) +{ + return {}; +} + +link_internal octree_node_ptr_block_array_index +Capacity( octree_node_ptr_block_array *Arr ) +{ + octree_node_ptr_block_array_index Result = {Arr->BlockCount * 8}; + return Result; +} + +link_internal octree_node_ptr_block_array_index +AtElements( octree_node_ptr_block_array *Arr ) +{ + octree_node_ptr_block_array_index Result = {Arr->ElementCount}; + return Result; +} + + +link_internal umm +TotalElements( octree_node_ptr_block_array *Arr ) +{ + umm Result = AtElements(Arr).Index; + return Result; +} + + +link_internal octree_node_ptr_block_array_index +LastIndex( octree_node_ptr_block_array *Arr ) +{ + octree_node_ptr_block_array_index Result = {}; + umm Count = AtElements(Arr).Index; + if (Count) Result.Index = Count-1; + return Result; +} + +link_internal umm +Count( octree_node_ptr_block_array *Arr ) +{ + auto Result = AtElements(Arr).Index; + return Result; +} + +link_internal octree_node_ptr_block * +GetBlock( octree_node_ptr_block_array *Arr, octree_node_ptr_block_array_index Index ) +{ + umm BlockIndex = Index.Index / 8; + Assert(BlockIndex < Arr->BlockCount); + octree_node_ptr_block *Block = Arr->BlockPtrs[BlockIndex]; + return Block; +} + +link_internal octree_node_ptr +GetPtr( octree_node_ptr_block_array *Arr, octree_node_ptr_block_array_index Index ) +{ + Assert(Arr->BlockPtrs); + Assert(Index.Index < Capacity(Arr).Index); + + octree_node_ptr_block *Block = GetBlock(Arr, Index); + + umm ElementIndex = Index.Index % 8; + octree_node_ptr Result = *(Block->Elements + ElementIndex); + return Result; +} + + +link_internal octree_node_ptr +GetPtr( octree_node_ptr_block_array *Arr, umm Index ) +{ + octree_node_ptr_block_array_index I = {Index}; + return GetPtr(Arr, I); +} + + +link_internal octree_node_ptr +TryGetPtr( octree_node_ptr_block_array *Arr, octree_node_ptr_block_array_index Index) +{ + octree_node_ptr Result = {}; + if (Arr->BlockPtrs && Index < AtElements(Arr)) + { + Result = GetPtr(Arr, Index); + } + return Result; +} + +link_internal octree_node_ptr +TryGetPtr( octree_node_ptr_block_array *Arr, umm Index) +{ + auto Result = TryGetPtr(Arr, octree_node_ptr_block_array_index{Index}); + return Result; +} + + + + + +link_internal cs +CS( octree_node_ptr_block_array_index Index ) +{ + return FSz("(%u)", Index.Index); +} + +link_internal octree_node_ptr +Set( octree_node_ptr_block_array *Arr, + octree_node_ptr Element, + octree_node_ptr_block_array_index Index ) +{ + Assert(Arr->BlockPtrs); + Assert(Index.Index < Capacity(Arr).Index); + octree_node_ptr_block *Block = GetBlock(Arr, Index); + umm ElementIndex = Index.Index % 8; + auto Slot = Block->Elements+ElementIndex; + *Slot = Element; + return *Slot; +} + +link_internal void +NewBlock( octree_node_ptr_block_array *Arr ) +{ + octree_node_ptr_block *NewBlock = Allocate( octree_node_ptr_block , Arr->Memory, 1); + octree_node_ptr_block **NewBlockPtrs = Allocate( octree_node_ptr_block*, Arr->Memory, Arr->BlockCount+1); + + RangeIterator_t(u32, BlockI, Arr->BlockCount) + { + NewBlockPtrs[BlockI] = Arr->BlockPtrs[BlockI]; + } + + NewBlockPtrs[Arr->BlockCount] = NewBlock; + + + + Arr->BlockPtrs = NewBlockPtrs; + Arr->BlockCount += 1; +} + +link_internal void +RemoveUnordered( octree_node_ptr_block_array *Array, octree_node_ptr_block_array_index Index) +{ + auto LastI = LastIndex(Array); + Assert(Index.Index <= LastI.Index); + + auto LastElement = GetPtr(Array, LastI); + Set(Array, LastElement, Index); + Array->ElementCount -= 1; +} + +link_internal void +RemoveOrdered( octree_node_ptr_block_array *Array, octree_node_ptr_block_array_index IndexToRemove) +{ + Assert(IndexToRemove.Index < Array->ElementCount); + + octree_node_ptr Prev = {}; + + octree_node_ptr_block_array_index Max = AtElements(Array); + RangeIteratorRange_t(umm, Index, Max.Index, IndexToRemove.Index) + { + octree_node_ptr E = GetPtr(Array, Index); + + if (Prev) + { + *Prev = *E; + } + + Prev = E; + } + + Array->ElementCount -= 1; +} + +link_internal void +RemoveOrdered( octree_node_ptr_block_array *Array, octree_node_ptr Element ) +{ + IterateOver(Array, E, I) + { + if (E == Element) + { + RemoveOrdered(Array, I); + break; + } + } +} + +link_internal octree_node_ptr_block_array_index +Find( octree_node_ptr_block_array *Array, octree_node_ptr Query) +{ + octree_node_ptr_block_array_index Result = {INVALID_BLOCK_ARRAY_INDEX}; + IterateOver(Array, E, Index) + { + if ( E == Query ) + { + Result = Index; + break; + } + } + return Result; +} + + + +link_internal b32 +IsValid(octree_node_ptr_block_array_index *Index) +{ + octree_node_ptr_block_array_index Test = {INVALID_BLOCK_ARRAY_INDEX}; + b32 Result = (AreEqual(Index, &Test) == False); + return Result; +} + +link_internal octree_node_ptr +Push( octree_node_ptr_block_array *Array, octree_node_ptr Element) +{ + Assert(Array->Memory); + + if (AtElements(Array) == Capacity(Array)) + { + NewBlock(Array); + } + + octree_node_ptr Result = Set(Array, Element, AtElements(Array)); + + Array->ElementCount += 1; + + return Result; +} + +link_internal octree_node_ptr +Push( octree_node_ptr_block_array *Array ) +{ + octree_node_ptr Element = {}; + auto Result = Push(Array, Element); + return Result; +} + +link_internal void +Insert( octree_node_ptr_block_array *Array, octree_node_ptr_block_array_index Index, octree_node_ptr Element ) +{ + Assert(Index.Index <= LastIndex(Array).Index); + Assert(Array->Memory); + + // Alocate a new thingy + octree_node_ptr Prev = Push(Array); + + auto Last = LastIndex(Array); + + RangeIteratorReverseRange(I, s32(Last.Index), s32(Index.Index)) + { + auto E = GetPtr(Array, umm(I)); + *Prev = *E; + Prev = E; + } + + *Prev = *Element; +} + +link_internal void +Insert( octree_node_ptr_block_array *Array, u32 Index, octree_node_ptr Element ) +{ + Insert(Array, { .Index = Index }, Element); +} + +link_internal void +Shift( octree_node_ptr_block_array *Array, octree_node_ptr Element ) +{ + Insert(Array, { .Index = 0 }, Element); +} + +/* element_t.has_tag(do_editor_ui)? */ +/* { */ +/* do_editor_ui_for_container( block_array_t ) */ +/* } */ + + + diff --git a/generated/block_array_picked_octree_node_688853862.h b/generated/block_array_picked_octree_node_688853862.h new file mode 100644 index 000000000..322d9b745 --- /dev/null +++ b/generated/block_array_picked_octree_node_688853862.h @@ -0,0 +1,363 @@ +// external/bonsai_stdlib/src/poof_functions.h:2600:0 + + + + +struct picked_octree_node_block +{ + /* u32 Index; */ + umm At; + picked_octree_node Elements[8]; +}; + +struct picked_octree_node_block_array_index +{ + umm Index; +}; + +struct picked_octree_node_block_array +{ + picked_octree_node_block **BlockPtrs; poof(@array_length(Element->BlockCount)) + u32 BlockCount; + u32 ElementCount; + memory_arena *Memory; poof(@no_serialize) + +}; + +link_internal picked_octree_node_block_array +PickedOctreeNodeBlockArray(memory_arena *Memory) +{ + picked_octree_node_block_array Result = {}; + Result.Memory = Memory; + return Result; +} + +link_internal b32 +AreEqual(picked_octree_node_block_array_index *Thing1, picked_octree_node_block_array_index *Thing2) +{ + if (Thing1 && Thing2) + { + b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( picked_octree_node_block_array_index ) ); + + return Result; + } + else + { + return (Thing1 == Thing2); + } +} + +link_internal b32 +AreEqual(picked_octree_node_block_array_index Thing1, picked_octree_node_block_array_index Thing2) +{ + b32 Result = MemoryIsEqual((u8*)&Thing1, (u8*)&Thing2, sizeof( picked_octree_node_block_array_index ) ); + + return Result; +} + + +typedef picked_octree_node_block_array picked_octree_node_paged_list; + +link_internal picked_octree_node_block_array_index +operator++( picked_octree_node_block_array_index &I0 ) +{ + I0.Index++; + return I0; +} + +link_internal b32 +operator<( picked_octree_node_block_array_index I0, picked_octree_node_block_array_index I1 ) +{ + b32 Result = I0.Index < I1.Index; + return Result; +} + +link_internal b32 +operator==( picked_octree_node_block_array_index I0, picked_octree_node_block_array_index I1 ) +{ + b32 Result = I0.Index == I1.Index; + return Result; +} + +link_inline umm +GetIndex( picked_octree_node_block_array_index *Index) +{ + umm Result = Index->Index; + return Result; +} + + +link_internal picked_octree_node_block_array_index +ZerothIndex( picked_octree_node_block_array *Arr ) +{ + return {}; +} + +link_internal picked_octree_node_block_array_index +Capacity( picked_octree_node_block_array *Arr ) +{ + picked_octree_node_block_array_index Result = {Arr->BlockCount * 8}; + return Result; +} + +link_internal picked_octree_node_block_array_index +AtElements( picked_octree_node_block_array *Arr ) +{ + picked_octree_node_block_array_index Result = {Arr->ElementCount}; + return Result; +} + + +link_internal umm +TotalElements( picked_octree_node_block_array *Arr ) +{ + umm Result = AtElements(Arr).Index; + return Result; +} + + +link_internal picked_octree_node_block_array_index +LastIndex( picked_octree_node_block_array *Arr ) +{ + picked_octree_node_block_array_index Result = {}; + umm Count = AtElements(Arr).Index; + if (Count) Result.Index = Count-1; + return Result; +} + +link_internal umm +Count( picked_octree_node_block_array *Arr ) +{ + auto Result = AtElements(Arr).Index; + return Result; +} + +link_internal picked_octree_node_block * +GetBlock( picked_octree_node_block_array *Arr, picked_octree_node_block_array_index Index ) +{ + umm BlockIndex = Index.Index / 8; + Assert(BlockIndex < Arr->BlockCount); + picked_octree_node_block *Block = Arr->BlockPtrs[BlockIndex]; + return Block; +} + +link_internal picked_octree_node * +GetPtr( picked_octree_node_block_array *Arr, picked_octree_node_block_array_index Index ) +{ + Assert(Arr->BlockPtrs); + Assert(Index.Index < Capacity(Arr).Index); + + picked_octree_node_block *Block = GetBlock(Arr, Index); + + umm ElementIndex = Index.Index % 8; + picked_octree_node *Result = (Block->Elements + ElementIndex); + return Result; +} + + +link_internal picked_octree_node * +GetPtr( picked_octree_node_block_array *Arr, umm Index ) +{ + picked_octree_node_block_array_index I = {Index}; + return GetPtr(Arr, I); +} + + +link_internal picked_octree_node * +TryGetPtr( picked_octree_node_block_array *Arr, picked_octree_node_block_array_index Index) +{ + picked_octree_node * Result = {}; + if (Arr->BlockPtrs && Index < AtElements(Arr)) + { + Result = GetPtr(Arr, Index); + } + return Result; +} + +link_internal picked_octree_node * +TryGetPtr( picked_octree_node_block_array *Arr, umm Index) +{ + auto Result = TryGetPtr(Arr, picked_octree_node_block_array_index{Index}); + return Result; +} + + + + + +link_internal cs +CS( picked_octree_node_block_array_index Index ) +{ + return FSz("(%u)", Index.Index); +} + +link_internal picked_octree_node * +Set( picked_octree_node_block_array *Arr, + picked_octree_node *Element, + picked_octree_node_block_array_index Index ) +{ + Assert(Arr->BlockPtrs); + Assert(Index.Index < Capacity(Arr).Index); + picked_octree_node_block *Block = GetBlock(Arr, Index); + umm ElementIndex = Index.Index % 8; + auto Slot = Block->Elements+ElementIndex; + *Slot = *Element; + return Slot; +} + +link_internal void +NewBlock( picked_octree_node_block_array *Arr ) +{ + picked_octree_node_block *NewBlock = Allocate( picked_octree_node_block , Arr->Memory, 1); + picked_octree_node_block **NewBlockPtrs = Allocate( picked_octree_node_block*, Arr->Memory, Arr->BlockCount+1); + + RangeIterator_t(u32, BlockI, Arr->BlockCount) + { + NewBlockPtrs[BlockI] = Arr->BlockPtrs[BlockI]; + } + + NewBlockPtrs[Arr->BlockCount] = NewBlock; + + + + Arr->BlockPtrs = NewBlockPtrs; + Arr->BlockCount += 1; +} + +link_internal void +RemoveUnordered( picked_octree_node_block_array *Array, picked_octree_node_block_array_index Index) +{ + auto LastI = LastIndex(Array); + Assert(Index.Index <= LastI.Index); + + auto LastElement = GetPtr(Array, LastI); + Set(Array, LastElement, Index); + Array->ElementCount -= 1; +} + +link_internal void +RemoveOrdered( picked_octree_node_block_array *Array, picked_octree_node_block_array_index IndexToRemove) +{ + Assert(IndexToRemove.Index < Array->ElementCount); + + picked_octree_node *Prev = {}; + + picked_octree_node_block_array_index Max = AtElements(Array); + RangeIteratorRange_t(umm, Index, Max.Index, IndexToRemove.Index) + { + picked_octree_node *E = GetPtr(Array, Index); + + if (Prev) + { + *Prev = *E; + } + + Prev = E; + } + + Array->ElementCount -= 1; +} + +link_internal void +RemoveOrdered( picked_octree_node_block_array *Array, picked_octree_node *Element ) +{ + IterateOver(Array, E, I) + { + if (E == Element) + { + RemoveOrdered(Array, I); + break; + } + } +} + +link_internal picked_octree_node_block_array_index +Find( picked_octree_node_block_array *Array, picked_octree_node *Query) +{ + picked_octree_node_block_array_index Result = {INVALID_BLOCK_ARRAY_INDEX}; + IterateOver(Array, E, Index) + { + if ( E == Query ) + { + Result = Index; + break; + } + } + return Result; +} + + + +link_internal b32 +IsValid(picked_octree_node_block_array_index *Index) +{ + picked_octree_node_block_array_index Test = {INVALID_BLOCK_ARRAY_INDEX}; + b32 Result = (AreEqual(Index, &Test) == False); + return Result; +} + +link_internal picked_octree_node * +Push( picked_octree_node_block_array *Array, picked_octree_node *Element) +{ + Assert(Array->Memory); + + if (AtElements(Array) == Capacity(Array)) + { + NewBlock(Array); + } + + picked_octree_node *Result = Set(Array, Element, AtElements(Array)); + + Array->ElementCount += 1; + + return Result; +} + +link_internal picked_octree_node * +Push( picked_octree_node_block_array *Array ) +{ + picked_octree_node Element = {}; + auto Result = Push(Array, &Element); + return Result; +} + +link_internal void +Insert( picked_octree_node_block_array *Array, picked_octree_node_block_array_index Index, picked_octree_node *Element ) +{ + Assert(Index.Index <= LastIndex(Array).Index); + Assert(Array->Memory); + + // Alocate a new thingy + picked_octree_node *Prev = Push(Array); + + auto Last = LastIndex(Array); + + RangeIteratorReverseRange(I, s32(Last.Index), s32(Index.Index)) + { + auto E = GetPtr(Array, umm(I)); + *Prev = *E; + Prev = E; + } + + *Prev = *Element; +} + +link_internal void +Insert( picked_octree_node_block_array *Array, u32 Index, picked_octree_node *Element ) +{ + Insert(Array, { .Index = Index }, Element); +} + +link_internal void +Shift( picked_octree_node_block_array *Array, picked_octree_node *Element ) +{ + Insert(Array, { .Index = 0 }, Element); +} + +/* element_t.has_tag(do_editor_ui)? */ +/* { */ +/* do_editor_ui_for_container( block_array_t ) */ +/* } */ + + + diff --git a/generated/block_array_standing_spot_688853862.h b/generated/block_array_standing_spot_688853862.h index 20313c99f..eaceb4f8a 100644 --- a/generated/block_array_standing_spot_688853862.h +++ b/generated/block_array_standing_spot_688853862.h @@ -1,240 +1,363 @@ -// src/engine/world_chunk.h:523:0 +// external/bonsai_stdlib/src/poof_functions.h:2600:0 + + + struct standing_spot_block { - u32 Index; - u32 At; - standing_spot *Elements; - standing_spot_block *Next; + /* u32 Index; */ + umm At; + standing_spot Elements[8]; }; struct standing_spot_block_array_index { - standing_spot_block *Block; - u32 BlockIndex; - u32 ElementIndex; + umm Index; }; struct standing_spot_block_array { - standing_spot_block *First; - standing_spot_block *Current; + standing_spot_block **BlockPtrs; poof(@array_length(Element->BlockCount)) + u32 BlockCount; + u32 ElementCount; memory_arena *Memory; poof(@no_serialize) }; -typedef standing_spot_block_array standing_spot_paged_list; +link_internal standing_spot_block_array +StandingSpotBlockArray(memory_arena *Memory) +{ + standing_spot_block_array Result = {}; + Result.Memory = Memory; + return Result; +} -link_internal standing_spot_block_array_index -operator++(standing_spot_block_array_index &I0) +link_internal b32 +AreEqual(standing_spot_block_array_index *Thing1, standing_spot_block_array_index *Thing2) { - if (I0.Block) + if (Thing1 && Thing2) { - if (I0.ElementIndex == 8-1) - { - I0.ElementIndex = 0; - I0.BlockIndex++; - I0.Block = I0.Block->Next; - } - else - { - I0.ElementIndex++; - } + b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( standing_spot_block_array_index ) ); + + return Result; } else { - I0.ElementIndex++; + return (Thing1 == Thing2); } +} + +link_internal b32 +AreEqual(standing_spot_block_array_index Thing1, standing_spot_block_array_index Thing2) +{ + b32 Result = MemoryIsEqual((u8*)&Thing1, (u8*)&Thing2, sizeof( standing_spot_block_array_index ) ); + + return Result; +} + + +typedef standing_spot_block_array standing_spot_paged_list; + +link_internal standing_spot_block_array_index +operator++( standing_spot_block_array_index &I0 ) +{ + I0.Index++; return I0; } link_internal b32 -operator<(standing_spot_block_array_index I0, standing_spot_block_array_index I1) +operator<( standing_spot_block_array_index I0, standing_spot_block_array_index I1 ) { - b32 Result = I0.BlockIndex < I1.BlockIndex || (I0.BlockIndex == I1.BlockIndex & I0.ElementIndex < I1.ElementIndex); + b32 Result = I0.Index < I1.Index; + return Result; +} + +link_internal b32 +operator==( standing_spot_block_array_index I0, standing_spot_block_array_index I1 ) +{ + b32 Result = I0.Index == I1.Index; return Result; } link_inline umm -GetIndex(standing_spot_block_array_index *Index) +GetIndex( standing_spot_block_array_index *Index) { - umm Result = Index->ElementIndex + (Index->BlockIndex*8); + umm Result = Index->Index; return Result; } + link_internal standing_spot_block_array_index -ZerothIndex(standing_spot_block_array *Arr) +ZerothIndex( standing_spot_block_array *Arr ) { - standing_spot_block_array_index Result = {}; - Result.Block = Arr->First; - /* Assert(Result.Block->Index == 0); */ - return Result; + return {}; } -link_internal umm -TotalElements(standing_spot_block_array *Arr) +link_internal standing_spot_block_array_index +Capacity( standing_spot_block_array *Arr ) { - umm Result = 0; - if (Arr->Current) - { - Result = (Arr->Current->Index * 8) + Arr->Current->At; - } + standing_spot_block_array_index Result = {Arr->BlockCount * 8}; return Result; } link_internal standing_spot_block_array_index -LastIndex(standing_spot_block_array *Arr) +AtElements( standing_spot_block_array *Arr ) { - standing_spot_block_array_index Result = {}; - if (Arr->Current) - { - Result.Block = Arr->Current; - Result.BlockIndex = Arr->Current->Index; - Result.ElementIndex = Arr->Current->At; - Assert(Result.ElementIndex); - Result.ElementIndex--; - } + standing_spot_block_array_index Result = {Arr->ElementCount}; return Result; } + +link_internal umm +TotalElements( standing_spot_block_array *Arr ) +{ + umm Result = AtElements(Arr).Index; + return Result; +} + + link_internal standing_spot_block_array_index -AtElements(standing_spot_block_array *Arr) +LastIndex( standing_spot_block_array *Arr ) { standing_spot_block_array_index Result = {}; - if (Arr->Current) - { - Result.Block = Arr->Current; - Result.BlockIndex = Arr->Current->Index; - Result.ElementIndex = Arr->Current->At; - } + umm Count = AtElements(Arr).Index; + if (Count) Result.Index = Count-1; return Result; } -link_internal standing_spot * -GetPtr(standing_spot_block_array *Arr, standing_spot_block_array_index Index) +link_internal umm +Count( standing_spot_block_array *Arr ) { - standing_spot *Result = {}; - if (Index.Block) { Result = Index.Block->Elements + Index.ElementIndex; } + auto Result = AtElements(Arr).Index; return Result; } +link_internal standing_spot_block * +GetBlock( standing_spot_block_array *Arr, standing_spot_block_array_index Index ) +{ + umm BlockIndex = Index.Index / 8; + Assert(BlockIndex < Arr->BlockCount); + standing_spot_block *Block = Arr->BlockPtrs[BlockIndex]; + return Block; +} + link_internal standing_spot * -GetPtr(standing_spot_block *Block, umm Index) +GetPtr( standing_spot_block_array *Arr, standing_spot_block_array_index Index ) { - standing_spot *Result = 0; - if (Index < Block->At) { Result = Block->Elements + Index; } + Assert(Arr->BlockPtrs); + Assert(Index.Index < Capacity(Arr).Index); + + standing_spot_block *Block = GetBlock(Arr, Index); + + umm ElementIndex = Index.Index % 8; + standing_spot *Result = (Block->Elements + ElementIndex); return Result; } + link_internal standing_spot * -GetPtr(standing_spot_block_array *Arr, umm Index) +GetPtr( standing_spot_block_array *Arr, umm Index ) { - umm BlockIndex = Index / 8; - umm ElementIndex = Index % 8; + standing_spot_block_array_index I = {Index}; + return GetPtr(Arr, I); +} + - umm AtBlock = 0; - standing_spot_block *Block = Arr->First; - while (AtBlock++ < BlockIndex) +link_internal standing_spot * +TryGetPtr( standing_spot_block_array *Arr, standing_spot_block_array_index Index) +{ + standing_spot * Result = {}; + if (Arr->BlockPtrs && Index < AtElements(Arr)) { - Block = Block->Next; + Result = GetPtr(Arr, Index); } - - standing_spot *Result = Block->Elements+ElementIndex; return Result; } link_internal standing_spot * -TryGetPtr(standing_spot_block_array *Arr, umm Index) +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); } + auto Result = TryGetPtr(Arr, standing_spot_block_array_index{Index}); return Result; } -link_internal u32 -AtElements(standing_spot_block *Block) + + + + +link_internal cs +CS( standing_spot_block_array_index Index ) { - return Block->At; + return FSz("(%u)", Index.Index); } - -link_internal standing_spot_block* -Allocate_standing_spot_block(memory_arena *Memory) +link_internal standing_spot * +Set( standing_spot_block_array *Arr, + standing_spot *Element, + standing_spot_block_array_index Index ) { - standing_spot_block *Result = Allocate(standing_spot_block, Memory, 1); - Result->Elements = Allocate(standing_spot, Memory, 8); - return Result; + Assert(Arr->BlockPtrs); + Assert(Index.Index < Capacity(Arr).Index); + standing_spot_block *Block = GetBlock(Arr, Index); + umm ElementIndex = Index.Index % 8; + auto Slot = Block->Elements+ElementIndex; + *Slot = *Element; + return Slot; } -link_internal cs -CS(standing_spot_block_array_index Index) +link_internal void +NewBlock( standing_spot_block_array *Arr ) { - return FSz("(%u)(%u)", Index.BlockIndex, Index.ElementIndex); + standing_spot_block *NewBlock = Allocate( standing_spot_block , Arr->Memory, 1); + standing_spot_block **NewBlockPtrs = Allocate( standing_spot_block*, Arr->Memory, Arr->BlockCount+1); + + RangeIterator_t(u32, BlockI, Arr->BlockCount) + { + NewBlockPtrs[BlockI] = Arr->BlockPtrs[BlockI]; + } + + NewBlockPtrs[Arr->BlockCount] = NewBlock; + + + + Arr->BlockPtrs = NewBlockPtrs; + Arr->BlockCount += 1; } link_internal void -RemoveUnordered(standing_spot_block_array *Array, standing_spot_block_array_index Index) +RemoveUnordered( standing_spot_block_array *Array, standing_spot_block_array_index Index) { - standing_spot_block_array_index LastI = LastIndex(Array); + auto LastI = LastIndex(Array); + Assert(Index.Index <= LastI.Index); - standing_spot *Element = GetPtr(Array, Index); - standing_spot *LastElement = GetPtr(Array, LastI); + auto LastElement = GetPtr(Array, LastI); + Set(Array, LastElement, Index); + Array->ElementCount -= 1; +} - *Element = *LastElement; +link_internal void +RemoveOrdered( standing_spot_block_array *Array, standing_spot_block_array_index IndexToRemove) +{ + Assert(IndexToRemove.Index < Array->ElementCount); - Assert(Array->Current->At); - Array->Current->At -= 1; + standing_spot *Prev = {}; - if (Array->Current->At == 0) + standing_spot_block_array_index Max = AtElements(Array); + RangeIteratorRange_t(umm, Index, Max.Index, IndexToRemove.Index) { - // Walk the chain till we get to the second-last one - standing_spot_block *Current = Array->First; - standing_spot_block *LastB = LastI.Block; + standing_spot *E = GetPtr(Array, Index); - while (Current->Next && Current->Next != LastB) + if (Prev) { - Current = Current->Next; + *Prev = *E; } - Assert(Current->Next == LastB || Current->Next == 0); - Array->Current = Current; + Prev = E; } + + Array->ElementCount -= 1; } -link_internal standing_spot * -Push(standing_spot_block_array *Array, standing_spot *Element) +link_internal void +RemoveOrdered( standing_spot_block_array *Array, standing_spot *Element ) { - if (Array->Memory == 0) { Array->Memory = AllocateArena(); } - - if (Array->First == 0) { Array->First = Allocate_standing_spot_block(Array->Memory); Array->Current = Array->First; } - - if (Array->Current->At == 8) + IterateOver(Array, E, I) { - if (Array->Current->Next) + if (E == Element) { - Array->Current = Array->Current->Next; - Assert(Array->Current->At == 0); + RemoveOrdered(Array, I); + break; } - else - { - standing_spot_block *Next = Allocate_standing_spot_block(Array->Memory); - Next->Index = Array->Current->Index + 1; + } +} - Array->Current->Next = Next; - Array->Current = Next; +link_internal standing_spot_block_array_index +Find( standing_spot_block_array *Array, standing_spot *Query) +{ + standing_spot_block_array_index Result = {INVALID_BLOCK_ARRAY_INDEX}; + IterateOver(Array, E, Index) + { + if ( E == Query ) + { + Result = Index; + break; } } + return Result; +} + + + +link_internal b32 +IsValid(standing_spot_block_array_index *Index) +{ + standing_spot_block_array_index Test = {INVALID_BLOCK_ARRAY_INDEX}; + b32 Result = (AreEqual(Index, &Test) == False); + return Result; +} + +link_internal standing_spot * +Push( standing_spot_block_array *Array, standing_spot *Element) +{ + Assert(Array->Memory); + + if (AtElements(Array) == Capacity(Array)) + { + NewBlock(Array); + } - standing_spot *Result = Array->Current->Elements + Array->Current->At; + standing_spot *Result = Set(Array, Element, AtElements(Array)); - Array->Current->Elements[Array->Current->At++] = *Element; + Array->ElementCount += 1; return Result; } +link_internal standing_spot * +Push( standing_spot_block_array *Array ) +{ + standing_spot Element = {}; + auto Result = Push(Array, &Element); + return Result; +} + +link_internal void +Insert( standing_spot_block_array *Array, standing_spot_block_array_index Index, standing_spot *Element ) +{ + Assert(Index.Index <= LastIndex(Array).Index); + Assert(Array->Memory); + + // Alocate a new thingy + standing_spot *Prev = Push(Array); + + auto Last = LastIndex(Array); + + RangeIteratorReverseRange(I, s32(Last.Index), s32(Index.Index)) + { + auto E = GetPtr(Array, umm(I)); + *Prev = *E; + Prev = E; + } + + *Prev = *Element; +} + +link_internal void +Insert( standing_spot_block_array *Array, u32 Index, standing_spot *Element ) +{ + Insert(Array, { .Index = Index }, Element); +} + +link_internal void +Shift( standing_spot_block_array *Array, standing_spot *Element ) +{ + Insert(Array, { .Index = 0 }, Element); +} + +/* element_t.has_tag(do_editor_ui)? */ +/* { */ +/* do_editor_ui_for_container( block_array_t ) */ +/* } */ + + diff --git a/generated/block_array_texture_ptr_688856411.h b/generated/block_array_texture_ptr_688856411.h index c086eeca2..2089b65cd 100644 --- a/generated/block_array_texture_ptr_688856411.h +++ b/generated/block_array_texture_ptr_688856411.h @@ -1,77 +1,180 @@ -// external/bonsai_stdlib/src/texture.cpp:8:0 +// external/bonsai_stdlib/src/poof_functions.h:2378:0 -link_internal texture_ptr_block* -Allocate_texture_ptr_block(memory_arena *Memory) + + +link_internal cs +CS( texture_ptr_block_array_index Index ) { - texture_ptr_block *Result = Allocate(texture_ptr_block, Memory, 1); - Result->Elements = Allocate(texture_ptr, Memory, 8); - return Result; + return FSz("(%u)", Index.Index); } -link_internal cs -CS(texture_ptr_block_array_index Index) +link_internal texture_ptr +Set( texture_ptr_block_array *Arr, + texture_ptr Element, + texture_ptr_block_array_index Index ) +{ + Assert(Arr->BlockPtrs); + Assert(Index.Index < Capacity(Arr).Index); + texture_ptr_block *Block = GetBlock(Arr, Index); + umm ElementIndex = Index.Index % 8; + auto Slot = Block->Elements+ElementIndex; + *Slot = Element; + return *Slot; +} + +link_internal void +NewBlock( texture_ptr_block_array *Arr ) { - return FSz("(%u)(%u)", Index.BlockIndex, Index.ElementIndex); + texture_ptr_block *NewBlock = Allocate( texture_ptr_block , Arr->Memory, 1); + texture_ptr_block **NewBlockPtrs = Allocate( texture_ptr_block*, Arr->Memory, Arr->BlockCount+1); + + RangeIterator_t(u32, BlockI, Arr->BlockCount) + { + NewBlockPtrs[BlockI] = Arr->BlockPtrs[BlockI]; + } + + NewBlockPtrs[Arr->BlockCount] = NewBlock; + + + + Arr->BlockPtrs = NewBlockPtrs; + Arr->BlockCount += 1; } link_internal void -RemoveUnordered(texture_ptr_block_array *Array, texture_ptr_block_array_index Index) +RemoveUnordered( texture_ptr_block_array *Array, texture_ptr_block_array_index Index) { - texture_ptr_block_array_index LastI = LastIndex(Array); + auto LastI = LastIndex(Array); + Assert(Index.Index <= LastI.Index); - texture_ptr *Element = GetPtr(Array, Index); - texture_ptr *LastElement = GetPtr(Array, LastI); + auto LastElement = GetPtr(Array, LastI); + Set(Array, LastElement, Index); + Array->ElementCount -= 1; +} - *Element = *LastElement; +link_internal void +RemoveOrdered( texture_ptr_block_array *Array, texture_ptr_block_array_index IndexToRemove) +{ + Assert(IndexToRemove.Index < Array->ElementCount); - Assert(Array->Current->At); - Array->Current->At -= 1; + texture_ptr Prev = {}; - if (Array->Current->At == 0) + texture_ptr_block_array_index Max = AtElements(Array); + RangeIteratorRange_t(umm, Index, Max.Index, IndexToRemove.Index) { - // Walk the chain till we get to the second-last one - texture_ptr_block *Current = Array->First; - texture_ptr_block *LastB = LastI.Block; + texture_ptr E = GetPtr(Array, Index); - while (Current->Next && Current->Next != LastB) + if (Prev) { - Current = Current->Next; + *Prev = *E; } - Assert(Current->Next == LastB || Current->Next == 0); - Array->Current = Current; + Prev = E; } + + Array->ElementCount -= 1; } -link_internal texture_ptr * -Push(texture_ptr_block_array *Array, texture_ptr *Element) +link_internal void +RemoveOrdered( texture_ptr_block_array *Array, texture_ptr Element ) { - if (Array->Memory == 0) { Array->Memory = AllocateArena(); } - - if (Array->First == 0) { Array->First = Allocate_texture_ptr_block(Array->Memory); Array->Current = Array->First; } - - if (Array->Current->At == 8) + IterateOver(Array, E, I) { - if (Array->Current->Next) + if (E == Element) { - Array->Current = Array->Current->Next; - Assert(Array->Current->At == 0); + RemoveOrdered(Array, I); + break; } - else - { - texture_ptr_block *Next = Allocate_texture_ptr_block(Array->Memory); - Next->Index = Array->Current->Index + 1; + } +} - Array->Current->Next = Next; - Array->Current = Next; +link_internal texture_ptr_block_array_index +Find( texture_ptr_block_array *Array, texture_ptr Query) +{ + texture_ptr_block_array_index Result = {INVALID_BLOCK_ARRAY_INDEX}; + IterateOver(Array, E, Index) + { + if ( E == Query ) + { + Result = Index; + break; } } + return Result; +} + + + +link_internal b32 +IsValid(texture_ptr_block_array_index *Index) +{ + texture_ptr_block_array_index Test = {INVALID_BLOCK_ARRAY_INDEX}; + b32 Result = (AreEqual(Index, &Test) == False); + return Result; +} + +link_internal texture_ptr +Push( texture_ptr_block_array *Array, texture_ptr Element) +{ + Assert(Array->Memory); + + if (AtElements(Array) == Capacity(Array)) + { + NewBlock(Array); + } - texture_ptr *Result = Array->Current->Elements + Array->Current->At; + texture_ptr Result = Set(Array, Element, AtElements(Array)); - Array->Current->Elements[Array->Current->At++] = *Element; + Array->ElementCount += 1; return Result; } +link_internal texture_ptr +Push( texture_ptr_block_array *Array ) +{ + texture_ptr Element = {}; + auto Result = Push(Array, Element); + return Result; +} + +link_internal void +Insert( texture_ptr_block_array *Array, texture_ptr_block_array_index Index, texture_ptr Element ) +{ + Assert(Index.Index <= LastIndex(Array).Index); + Assert(Array->Memory); + + // Alocate a new thingy + texture_ptr Prev = Push(Array); + + auto Last = LastIndex(Array); + + RangeIteratorReverseRange(I, s32(Last.Index), s32(Index.Index)) + { + auto E = GetPtr(Array, umm(I)); + *Prev = *E; + Prev = E; + } + + *Prev = *Element; +} + +link_internal void +Insert( texture_ptr_block_array *Array, u32 Index, texture_ptr Element ) +{ + Insert(Array, { .Index = Index }, Element); +} + +link_internal void +Shift( texture_ptr_block_array *Array, texture_ptr Element ) +{ + Insert(Array, { .Index = 0 }, Element); +} + +/* element_t.has_tag(do_editor_ui)? */ +/* { */ +/* do_editor_ui_for_container( block_array_t ) */ +/* } */ + + diff --git a/generated/block_array_vox_data_688856411.h b/generated/block_array_vox_data_688856411.h index b4237c924..3fba42555 100644 --- a/generated/block_array_vox_data_688856411.h +++ b/generated/block_array_vox_data_688856411.h @@ -1,240 +1,363 @@ -// src/engine/model.h:85:0 +// external/bonsai_stdlib/src/poof_functions.h:2600:0 + + + struct vox_data_block { - u32 Index; - u32 At; - vox_data *Elements; - vox_data_block *Next; + /* u32 Index; */ + umm At; + vox_data Elements[8]; }; struct vox_data_block_array_index { - vox_data_block *Block; - u32 BlockIndex; - u32 ElementIndex; + umm Index; }; struct vox_data_block_array { - vox_data_block *First; - vox_data_block *Current; + vox_data_block **BlockPtrs; poof(@array_length(Element->BlockCount)) + u32 BlockCount; + u32 ElementCount; memory_arena *Memory; poof(@no_serialize) }; -typedef vox_data_block_array vox_data_paged_list; +link_internal vox_data_block_array +VoxDataBlockArray(memory_arena *Memory) +{ + vox_data_block_array Result = {}; + Result.Memory = Memory; + return Result; +} -link_internal vox_data_block_array_index -operator++(vox_data_block_array_index &I0) +link_internal b32 +AreEqual(vox_data_block_array_index *Thing1, vox_data_block_array_index *Thing2) { - if (I0.Block) + if (Thing1 && Thing2) { - if (I0.ElementIndex == 8-1) - { - I0.ElementIndex = 0; - I0.BlockIndex++; - I0.Block = I0.Block->Next; - } - else - { - I0.ElementIndex++; - } + b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( vox_data_block_array_index ) ); + + return Result; } else { - I0.ElementIndex++; + return (Thing1 == Thing2); } +} + +link_internal b32 +AreEqual(vox_data_block_array_index Thing1, vox_data_block_array_index Thing2) +{ + b32 Result = MemoryIsEqual((u8*)&Thing1, (u8*)&Thing2, sizeof( vox_data_block_array_index ) ); + + return Result; +} + + +typedef vox_data_block_array vox_data_paged_list; + +link_internal vox_data_block_array_index +operator++( vox_data_block_array_index &I0 ) +{ + I0.Index++; return I0; } link_internal b32 -operator<(vox_data_block_array_index I0, vox_data_block_array_index I1) +operator<( vox_data_block_array_index I0, vox_data_block_array_index I1 ) { - b32 Result = I0.BlockIndex < I1.BlockIndex || (I0.BlockIndex == I1.BlockIndex & I0.ElementIndex < I1.ElementIndex); + b32 Result = I0.Index < I1.Index; + return Result; +} + +link_internal b32 +operator==( vox_data_block_array_index I0, vox_data_block_array_index I1 ) +{ + b32 Result = I0.Index == I1.Index; return Result; } link_inline umm -GetIndex(vox_data_block_array_index *Index) +GetIndex( vox_data_block_array_index *Index) { - umm Result = Index->ElementIndex + (Index->BlockIndex*8); + umm Result = Index->Index; return Result; } + link_internal vox_data_block_array_index -ZerothIndex(vox_data_block_array *Arr) +ZerothIndex( vox_data_block_array *Arr ) { - vox_data_block_array_index Result = {}; - Result.Block = Arr->First; - /* Assert(Result.Block->Index == 0); */ - return Result; + return {}; } -link_internal umm -TotalElements(vox_data_block_array *Arr) +link_internal vox_data_block_array_index +Capacity( vox_data_block_array *Arr ) { - umm Result = 0; - if (Arr->Current) - { - Result = (Arr->Current->Index * 8) + Arr->Current->At; - } + vox_data_block_array_index Result = {Arr->BlockCount * 8}; return Result; } link_internal vox_data_block_array_index -LastIndex(vox_data_block_array *Arr) +AtElements( vox_data_block_array *Arr ) { - vox_data_block_array_index Result = {}; - if (Arr->Current) - { - Result.Block = Arr->Current; - Result.BlockIndex = Arr->Current->Index; - Result.ElementIndex = Arr->Current->At; - Assert(Result.ElementIndex); - Result.ElementIndex--; - } + vox_data_block_array_index Result = {Arr->ElementCount}; return Result; } + +link_internal umm +TotalElements( vox_data_block_array *Arr ) +{ + umm Result = AtElements(Arr).Index; + return Result; +} + + link_internal vox_data_block_array_index -AtElements(vox_data_block_array *Arr) +LastIndex( vox_data_block_array *Arr ) { vox_data_block_array_index Result = {}; - if (Arr->Current) - { - Result.Block = Arr->Current; - Result.BlockIndex = Arr->Current->Index; - Result.ElementIndex = Arr->Current->At; - } + umm Count = AtElements(Arr).Index; + if (Count) Result.Index = Count-1; return Result; } -link_internal vox_data * -GetPtr(vox_data_block_array *Arr, vox_data_block_array_index Index) +link_internal umm +Count( vox_data_block_array *Arr ) { - vox_data *Result = {}; - if (Index.Block) { Result = Index.Block->Elements + Index.ElementIndex; } + auto Result = AtElements(Arr).Index; return Result; } +link_internal vox_data_block * +GetBlock( vox_data_block_array *Arr, vox_data_block_array_index Index ) +{ + umm BlockIndex = Index.Index / 8; + Assert(BlockIndex < Arr->BlockCount); + vox_data_block *Block = Arr->BlockPtrs[BlockIndex]; + return Block; +} + link_internal vox_data * -GetPtr(vox_data_block *Block, umm Index) +GetPtr( vox_data_block_array *Arr, vox_data_block_array_index Index ) { - vox_data *Result = 0; - if (Index < Block->At) { Result = Block->Elements + Index; } + Assert(Arr->BlockPtrs); + Assert(Index.Index < Capacity(Arr).Index); + + vox_data_block *Block = GetBlock(Arr, Index); + + umm ElementIndex = Index.Index % 8; + vox_data *Result = (Block->Elements + ElementIndex); return Result; } + link_internal vox_data * -GetPtr(vox_data_block_array *Arr, umm Index) +GetPtr( vox_data_block_array *Arr, umm Index ) { - umm BlockIndex = Index / 8; - umm ElementIndex = Index % 8; + vox_data_block_array_index I = {Index}; + return GetPtr(Arr, I); +} + - umm AtBlock = 0; - vox_data_block *Block = Arr->First; - while (AtBlock++ < BlockIndex) +link_internal vox_data * +TryGetPtr( vox_data_block_array *Arr, vox_data_block_array_index Index) +{ + vox_data * Result = {}; + if (Arr->BlockPtrs && Index < AtElements(Arr)) { - Block = Block->Next; + Result = GetPtr(Arr, Index); } - - vox_data *Result = Block->Elements+ElementIndex; return Result; } link_internal vox_data * -TryGetPtr(vox_data_block_array *Arr, umm Index) +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); } + auto Result = TryGetPtr(Arr, vox_data_block_array_index{Index}); return Result; } -link_internal u32 -AtElements(vox_data_block *Block) + + + + +link_internal cs +CS( vox_data_block_array_index Index ) { - return Block->At; + return FSz("(%u)", Index.Index); } - -link_internal vox_data_block* -Allocate_vox_data_block(memory_arena *Memory) +link_internal vox_data * +Set( vox_data_block_array *Arr, + vox_data *Element, + vox_data_block_array_index Index ) { - vox_data_block *Result = Allocate(vox_data_block, Memory, 1); - Result->Elements = Allocate(vox_data, Memory, 8); - return Result; + Assert(Arr->BlockPtrs); + Assert(Index.Index < Capacity(Arr).Index); + vox_data_block *Block = GetBlock(Arr, Index); + umm ElementIndex = Index.Index % 8; + auto Slot = Block->Elements+ElementIndex; + *Slot = *Element; + return Slot; } -link_internal cs -CS(vox_data_block_array_index Index) +link_internal void +NewBlock( vox_data_block_array *Arr ) { - return FSz("(%u)(%u)", Index.BlockIndex, Index.ElementIndex); + vox_data_block *NewBlock = Allocate( vox_data_block , Arr->Memory, 1); + vox_data_block **NewBlockPtrs = Allocate( vox_data_block*, Arr->Memory, Arr->BlockCount+1); + + RangeIterator_t(u32, BlockI, Arr->BlockCount) + { + NewBlockPtrs[BlockI] = Arr->BlockPtrs[BlockI]; + } + + NewBlockPtrs[Arr->BlockCount] = NewBlock; + + + + Arr->BlockPtrs = NewBlockPtrs; + Arr->BlockCount += 1; } link_internal void -RemoveUnordered(vox_data_block_array *Array, vox_data_block_array_index Index) +RemoveUnordered( vox_data_block_array *Array, vox_data_block_array_index Index) { - vox_data_block_array_index LastI = LastIndex(Array); + auto LastI = LastIndex(Array); + Assert(Index.Index <= LastI.Index); - vox_data *Element = GetPtr(Array, Index); - vox_data *LastElement = GetPtr(Array, LastI); + auto LastElement = GetPtr(Array, LastI); + Set(Array, LastElement, Index); + Array->ElementCount -= 1; +} - *Element = *LastElement; +link_internal void +RemoveOrdered( vox_data_block_array *Array, vox_data_block_array_index IndexToRemove) +{ + Assert(IndexToRemove.Index < Array->ElementCount); - Assert(Array->Current->At); - Array->Current->At -= 1; + vox_data *Prev = {}; - if (Array->Current->At == 0) + vox_data_block_array_index Max = AtElements(Array); + RangeIteratorRange_t(umm, Index, Max.Index, IndexToRemove.Index) { - // Walk the chain till we get to the second-last one - vox_data_block *Current = Array->First; - vox_data_block *LastB = LastI.Block; + vox_data *E = GetPtr(Array, Index); - while (Current->Next && Current->Next != LastB) + if (Prev) { - Current = Current->Next; + *Prev = *E; } - Assert(Current->Next == LastB || Current->Next == 0); - Array->Current = Current; + Prev = E; } + + Array->ElementCount -= 1; } -link_internal vox_data * -Push(vox_data_block_array *Array, vox_data *Element) +link_internal void +RemoveOrdered( vox_data_block_array *Array, vox_data *Element ) { - if (Array->Memory == 0) { Array->Memory = AllocateArena(); } - - if (Array->First == 0) { Array->First = Allocate_vox_data_block(Array->Memory); Array->Current = Array->First; } - - if (Array->Current->At == 8) + IterateOver(Array, E, I) { - if (Array->Current->Next) + if (E == Element) { - Array->Current = Array->Current->Next; - Assert(Array->Current->At == 0); + RemoveOrdered(Array, I); + break; } - else - { - vox_data_block *Next = Allocate_vox_data_block(Array->Memory); - Next->Index = Array->Current->Index + 1; + } +} - Array->Current->Next = Next; - Array->Current = Next; +link_internal vox_data_block_array_index +Find( vox_data_block_array *Array, vox_data *Query) +{ + vox_data_block_array_index Result = {INVALID_BLOCK_ARRAY_INDEX}; + IterateOver(Array, E, Index) + { + if ( E == Query ) + { + Result = Index; + break; } } + return Result; +} + + + +link_internal b32 +IsValid(vox_data_block_array_index *Index) +{ + vox_data_block_array_index Test = {INVALID_BLOCK_ARRAY_INDEX}; + b32 Result = (AreEqual(Index, &Test) == False); + return Result; +} + +link_internal vox_data * +Push( vox_data_block_array *Array, vox_data *Element) +{ + Assert(Array->Memory); + + if (AtElements(Array) == Capacity(Array)) + { + NewBlock(Array); + } - vox_data *Result = Array->Current->Elements + Array->Current->At; + vox_data *Result = Set(Array, Element, AtElements(Array)); - Array->Current->Elements[Array->Current->At++] = *Element; + Array->ElementCount += 1; return Result; } +link_internal vox_data * +Push( vox_data_block_array *Array ) +{ + vox_data Element = {}; + auto Result = Push(Array, &Element); + return Result; +} + +link_internal void +Insert( vox_data_block_array *Array, vox_data_block_array_index Index, vox_data *Element ) +{ + Assert(Index.Index <= LastIndex(Array).Index); + Assert(Array->Memory); + + // Alocate a new thingy + vox_data *Prev = Push(Array); + + auto Last = LastIndex(Array); + + RangeIteratorReverseRange(I, s32(Last.Index), s32(Index.Index)) + { + auto E = GetPtr(Array, umm(I)); + *Prev = *E; + Prev = E; + } + + *Prev = *Element; +} + +link_internal void +Insert( vox_data_block_array *Array, u32 Index, vox_data *Element ) +{ + Insert(Array, { .Index = Index }, Element); +} + +link_internal void +Shift( vox_data_block_array *Array, vox_data *Element ) +{ + Insert(Array, { .Index = 0 }, Element); +} + +/* element_t.has_tag(do_editor_ui)? */ +/* { */ +/* do_editor_ui_for_container( block_array_t ) */ +/* } */ + + diff --git a/generated/block_array_voxel_stack_element_688853862.h b/generated/block_array_voxel_stack_element_688853862.h index d3294351a..34a32034a 100644 --- a/generated/block_array_voxel_stack_element_688853862.h +++ b/generated/block_array_voxel_stack_element_688853862.h @@ -1,240 +1,363 @@ -// src/engine/world_update.h:35:0 +// external/bonsai_stdlib/src/poof_functions.h:2600:0 + + + struct voxel_stack_element_block { - u32 Index; - u32 At; - voxel_stack_element *Elements; - voxel_stack_element_block *Next; + /* u32 Index; */ + umm At; + voxel_stack_element Elements[8]; }; struct voxel_stack_element_block_array_index { - voxel_stack_element_block *Block; - u32 BlockIndex; - u32 ElementIndex; + umm Index; }; struct voxel_stack_element_block_array { - voxel_stack_element_block *First; - voxel_stack_element_block *Current; + voxel_stack_element_block **BlockPtrs; poof(@array_length(Element->BlockCount)) + u32 BlockCount; + u32 ElementCount; memory_arena *Memory; poof(@no_serialize) }; -typedef voxel_stack_element_block_array voxel_stack_element_paged_list; +link_internal voxel_stack_element_block_array +VoxelStackElementBlockArray(memory_arena *Memory) +{ + voxel_stack_element_block_array Result = {}; + Result.Memory = Memory; + return Result; +} -link_internal voxel_stack_element_block_array_index -operator++(voxel_stack_element_block_array_index &I0) +link_internal b32 +AreEqual(voxel_stack_element_block_array_index *Thing1, voxel_stack_element_block_array_index *Thing2) { - if (I0.Block) + if (Thing1 && Thing2) { - if (I0.ElementIndex == 8-1) - { - I0.ElementIndex = 0; - I0.BlockIndex++; - I0.Block = I0.Block->Next; - } - else - { - I0.ElementIndex++; - } + b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( voxel_stack_element_block_array_index ) ); + + return Result; } else { - I0.ElementIndex++; + return (Thing1 == Thing2); } +} + +link_internal b32 +AreEqual(voxel_stack_element_block_array_index Thing1, voxel_stack_element_block_array_index Thing2) +{ + b32 Result = MemoryIsEqual((u8*)&Thing1, (u8*)&Thing2, sizeof( voxel_stack_element_block_array_index ) ); + + return Result; +} + + +typedef voxel_stack_element_block_array voxel_stack_element_paged_list; + +link_internal voxel_stack_element_block_array_index +operator++( voxel_stack_element_block_array_index &I0 ) +{ + I0.Index++; return I0; } link_internal b32 -operator<(voxel_stack_element_block_array_index I0, voxel_stack_element_block_array_index I1) +operator<( voxel_stack_element_block_array_index I0, voxel_stack_element_block_array_index I1 ) { - b32 Result = I0.BlockIndex < I1.BlockIndex || (I0.BlockIndex == I1.BlockIndex & I0.ElementIndex < I1.ElementIndex); + b32 Result = I0.Index < I1.Index; + return Result; +} + +link_internal b32 +operator==( voxel_stack_element_block_array_index I0, voxel_stack_element_block_array_index I1 ) +{ + b32 Result = I0.Index == I1.Index; return Result; } link_inline umm -GetIndex(voxel_stack_element_block_array_index *Index) +GetIndex( voxel_stack_element_block_array_index *Index) { - umm Result = Index->ElementIndex + (Index->BlockIndex*8); + umm Result = Index->Index; return Result; } + link_internal voxel_stack_element_block_array_index -ZerothIndex(voxel_stack_element_block_array *Arr) +ZerothIndex( voxel_stack_element_block_array *Arr ) { - voxel_stack_element_block_array_index Result = {}; - Result.Block = Arr->First; - /* Assert(Result.Block->Index == 0); */ - return Result; + return {}; } -link_internal umm -TotalElements(voxel_stack_element_block_array *Arr) +link_internal voxel_stack_element_block_array_index +Capacity( voxel_stack_element_block_array *Arr ) { - umm Result = 0; - if (Arr->Current) - { - Result = (Arr->Current->Index * 8) + Arr->Current->At; - } + voxel_stack_element_block_array_index Result = {Arr->BlockCount * 8}; return Result; } link_internal voxel_stack_element_block_array_index -LastIndex(voxel_stack_element_block_array *Arr) +AtElements( voxel_stack_element_block_array *Arr ) { - voxel_stack_element_block_array_index Result = {}; - if (Arr->Current) - { - Result.Block = Arr->Current; - Result.BlockIndex = Arr->Current->Index; - Result.ElementIndex = Arr->Current->At; - Assert(Result.ElementIndex); - Result.ElementIndex--; - } + voxel_stack_element_block_array_index Result = {Arr->ElementCount}; return Result; } + +link_internal umm +TotalElements( voxel_stack_element_block_array *Arr ) +{ + umm Result = AtElements(Arr).Index; + return Result; +} + + link_internal voxel_stack_element_block_array_index -AtElements(voxel_stack_element_block_array *Arr) +LastIndex( voxel_stack_element_block_array *Arr ) { voxel_stack_element_block_array_index Result = {}; - if (Arr->Current) - { - Result.Block = Arr->Current; - Result.BlockIndex = Arr->Current->Index; - Result.ElementIndex = Arr->Current->At; - } + umm Count = AtElements(Arr).Index; + if (Count) Result.Index = Count-1; return Result; } -link_internal voxel_stack_element * -GetPtr(voxel_stack_element_block_array *Arr, voxel_stack_element_block_array_index Index) +link_internal umm +Count( voxel_stack_element_block_array *Arr ) { - voxel_stack_element *Result = {}; - if (Index.Block) { Result = Index.Block->Elements + Index.ElementIndex; } + auto Result = AtElements(Arr).Index; return Result; } +link_internal voxel_stack_element_block * +GetBlock( voxel_stack_element_block_array *Arr, voxel_stack_element_block_array_index Index ) +{ + umm BlockIndex = Index.Index / 8; + Assert(BlockIndex < Arr->BlockCount); + voxel_stack_element_block *Block = Arr->BlockPtrs[BlockIndex]; + return Block; +} + link_internal voxel_stack_element * -GetPtr(voxel_stack_element_block *Block, umm Index) +GetPtr( voxel_stack_element_block_array *Arr, voxel_stack_element_block_array_index Index ) { - voxel_stack_element *Result = 0; - if (Index < Block->At) { Result = Block->Elements + Index; } + Assert(Arr->BlockPtrs); + Assert(Index.Index < Capacity(Arr).Index); + + voxel_stack_element_block *Block = GetBlock(Arr, Index); + + umm ElementIndex = Index.Index % 8; + voxel_stack_element *Result = (Block->Elements + ElementIndex); return Result; } + link_internal voxel_stack_element * -GetPtr(voxel_stack_element_block_array *Arr, umm Index) +GetPtr( voxel_stack_element_block_array *Arr, umm Index ) { - umm BlockIndex = Index / 8; - umm ElementIndex = Index % 8; + voxel_stack_element_block_array_index I = {Index}; + return GetPtr(Arr, I); +} + - umm AtBlock = 0; - voxel_stack_element_block *Block = Arr->First; - while (AtBlock++ < BlockIndex) +link_internal voxel_stack_element * +TryGetPtr( voxel_stack_element_block_array *Arr, voxel_stack_element_block_array_index Index) +{ + voxel_stack_element * Result = {}; + if (Arr->BlockPtrs && Index < AtElements(Arr)) { - Block = Block->Next; + Result = GetPtr(Arr, Index); } - - voxel_stack_element *Result = Block->Elements+ElementIndex; return Result; } link_internal voxel_stack_element * -TryGetPtr(voxel_stack_element_block_array *Arr, umm Index) +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); } + auto Result = TryGetPtr(Arr, voxel_stack_element_block_array_index{Index}); return Result; } -link_internal u32 -AtElements(voxel_stack_element_block *Block) + + + + +link_internal cs +CS( voxel_stack_element_block_array_index Index ) { - return Block->At; + return FSz("(%u)", Index.Index); } - -link_internal voxel_stack_element_block* -Allocate_voxel_stack_element_block(memory_arena *Memory) +link_internal voxel_stack_element * +Set( voxel_stack_element_block_array *Arr, + voxel_stack_element *Element, + voxel_stack_element_block_array_index Index ) { - voxel_stack_element_block *Result = Allocate(voxel_stack_element_block, Memory, 1); - Result->Elements = Allocate(voxel_stack_element, Memory, 8); - return Result; + Assert(Arr->BlockPtrs); + Assert(Index.Index < Capacity(Arr).Index); + voxel_stack_element_block *Block = GetBlock(Arr, Index); + umm ElementIndex = Index.Index % 8; + auto Slot = Block->Elements+ElementIndex; + *Slot = *Element; + return Slot; } -link_internal cs -CS(voxel_stack_element_block_array_index Index) +link_internal void +NewBlock( voxel_stack_element_block_array *Arr ) { - return FSz("(%u)(%u)", Index.BlockIndex, Index.ElementIndex); + voxel_stack_element_block *NewBlock = Allocate( voxel_stack_element_block , Arr->Memory, 1); + voxel_stack_element_block **NewBlockPtrs = Allocate( voxel_stack_element_block*, Arr->Memory, Arr->BlockCount+1); + + RangeIterator_t(u32, BlockI, Arr->BlockCount) + { + NewBlockPtrs[BlockI] = Arr->BlockPtrs[BlockI]; + } + + NewBlockPtrs[Arr->BlockCount] = NewBlock; + + + + Arr->BlockPtrs = NewBlockPtrs; + Arr->BlockCount += 1; } link_internal void -RemoveUnordered(voxel_stack_element_block_array *Array, voxel_stack_element_block_array_index Index) +RemoveUnordered( voxel_stack_element_block_array *Array, voxel_stack_element_block_array_index Index) { - voxel_stack_element_block_array_index LastI = LastIndex(Array); + auto LastI = LastIndex(Array); + Assert(Index.Index <= LastI.Index); - voxel_stack_element *Element = GetPtr(Array, Index); - voxel_stack_element *LastElement = GetPtr(Array, LastI); + auto LastElement = GetPtr(Array, LastI); + Set(Array, LastElement, Index); + Array->ElementCount -= 1; +} - *Element = *LastElement; +link_internal void +RemoveOrdered( voxel_stack_element_block_array *Array, voxel_stack_element_block_array_index IndexToRemove) +{ + Assert(IndexToRemove.Index < Array->ElementCount); - Assert(Array->Current->At); - Array->Current->At -= 1; + voxel_stack_element *Prev = {}; - if (Array->Current->At == 0) + voxel_stack_element_block_array_index Max = AtElements(Array); + RangeIteratorRange_t(umm, Index, Max.Index, IndexToRemove.Index) { - // Walk the chain till we get to the second-last one - voxel_stack_element_block *Current = Array->First; - voxel_stack_element_block *LastB = LastI.Block; + voxel_stack_element *E = GetPtr(Array, Index); - while (Current->Next && Current->Next != LastB) + if (Prev) { - Current = Current->Next; + *Prev = *E; } - Assert(Current->Next == LastB || Current->Next == 0); - Array->Current = Current; + Prev = E; } + + Array->ElementCount -= 1; } -link_internal voxel_stack_element * -Push(voxel_stack_element_block_array *Array, voxel_stack_element *Element) +link_internal void +RemoveOrdered( voxel_stack_element_block_array *Array, voxel_stack_element *Element ) { - if (Array->Memory == 0) { Array->Memory = AllocateArena(); } - - if (Array->First == 0) { Array->First = Allocate_voxel_stack_element_block(Array->Memory); Array->Current = Array->First; } - - if (Array->Current->At == 8) + IterateOver(Array, E, I) { - if (Array->Current->Next) + if (E == Element) { - Array->Current = Array->Current->Next; - Assert(Array->Current->At == 0); + RemoveOrdered(Array, I); + break; } - else - { - voxel_stack_element_block *Next = Allocate_voxel_stack_element_block(Array->Memory); - Next->Index = Array->Current->Index + 1; + } +} - Array->Current->Next = Next; - Array->Current = Next; +link_internal voxel_stack_element_block_array_index +Find( voxel_stack_element_block_array *Array, voxel_stack_element *Query) +{ + voxel_stack_element_block_array_index Result = {INVALID_BLOCK_ARRAY_INDEX}; + IterateOver(Array, E, Index) + { + if ( E == Query ) + { + Result = Index; + break; } } + return Result; +} + + + +link_internal b32 +IsValid(voxel_stack_element_block_array_index *Index) +{ + voxel_stack_element_block_array_index Test = {INVALID_BLOCK_ARRAY_INDEX}; + b32 Result = (AreEqual(Index, &Test) == False); + return Result; +} + +link_internal voxel_stack_element * +Push( voxel_stack_element_block_array *Array, voxel_stack_element *Element) +{ + Assert(Array->Memory); + + if (AtElements(Array) == Capacity(Array)) + { + NewBlock(Array); + } - voxel_stack_element *Result = Array->Current->Elements + Array->Current->At; + voxel_stack_element *Result = Set(Array, Element, AtElements(Array)); - Array->Current->Elements[Array->Current->At++] = *Element; + Array->ElementCount += 1; return Result; } +link_internal voxel_stack_element * +Push( voxel_stack_element_block_array *Array ) +{ + voxel_stack_element Element = {}; + auto Result = Push(Array, &Element); + return Result; +} + +link_internal void +Insert( voxel_stack_element_block_array *Array, voxel_stack_element_block_array_index Index, voxel_stack_element *Element ) +{ + Assert(Index.Index <= LastIndex(Array).Index); + Assert(Array->Memory); + + // Alocate a new thingy + voxel_stack_element *Prev = Push(Array); + + auto Last = LastIndex(Array); + + RangeIteratorReverseRange(I, s32(Last.Index), s32(Index.Index)) + { + auto E = GetPtr(Array, umm(I)); + *Prev = *E; + Prev = E; + } + + *Prev = *Element; +} + +link_internal void +Insert( voxel_stack_element_block_array *Array, u32 Index, voxel_stack_element *Element ) +{ + Insert(Array, { .Index = Index }, Element); +} + +link_internal void +Shift( voxel_stack_element_block_array *Array, voxel_stack_element *Element ) +{ + Insert(Array, { .Index = 0 }, Element); +} + +/* element_t.has_tag(do_editor_ui)? */ +/* { */ +/* do_editor_ui_for_container( block_array_t ) */ +/* } */ + + diff --git a/generated/block_array_world_chunk_ptr_688853862.h b/generated/block_array_world_chunk_ptr_688853862.h index 8a88bb4bd..af3956163 100644 --- a/generated/block_array_world_chunk_ptr_688853862.h +++ b/generated/block_array_world_chunk_ptr_688853862.h @@ -1,77 +1,180 @@ -// src/engine/world_chunk.cpp:2:0 +// external/bonsai_stdlib/src/poof_functions.h:2378:0 -link_internal world_chunk_ptr_block* -Allocate_world_chunk_ptr_block(memory_arena *Memory) + + +link_internal cs +CS( world_chunk_ptr_block_array_index Index ) { - world_chunk_ptr_block *Result = Allocate(world_chunk_ptr_block, Memory, 1); - Result->Elements = Allocate(world_chunk_ptr, Memory, 32); - return Result; + return FSz("(%u)", Index.Index); } -link_internal cs -CS(world_chunk_ptr_block_array_index Index) +link_internal world_chunk_ptr +Set( world_chunk_ptr_block_array *Arr, + world_chunk_ptr Element, + world_chunk_ptr_block_array_index Index ) +{ + Assert(Arr->BlockPtrs); + Assert(Index.Index < Capacity(Arr).Index); + world_chunk_ptr_block *Block = GetBlock(Arr, Index); + umm ElementIndex = Index.Index % 32; + auto Slot = Block->Elements+ElementIndex; + *Slot = Element; + return *Slot; +} + +link_internal void +NewBlock( world_chunk_ptr_block_array *Arr ) { - return FSz("(%u)(%u)", Index.BlockIndex, Index.ElementIndex); + world_chunk_ptr_block *NewBlock = Allocate( world_chunk_ptr_block , Arr->Memory, 1); + world_chunk_ptr_block **NewBlockPtrs = Allocate( world_chunk_ptr_block*, Arr->Memory, Arr->BlockCount+1); + + RangeIterator_t(u32, BlockI, Arr->BlockCount) + { + NewBlockPtrs[BlockI] = Arr->BlockPtrs[BlockI]; + } + + NewBlockPtrs[Arr->BlockCount] = NewBlock; + + + + Arr->BlockPtrs = NewBlockPtrs; + Arr->BlockCount += 1; } link_internal void -RemoveUnordered(world_chunk_ptr_block_array *Array, world_chunk_ptr_block_array_index Index) +RemoveUnordered( world_chunk_ptr_block_array *Array, world_chunk_ptr_block_array_index Index) { - world_chunk_ptr_block_array_index LastI = LastIndex(Array); + auto LastI = LastIndex(Array); + Assert(Index.Index <= LastI.Index); - world_chunk_ptr *Element = GetPtr(Array, Index); - world_chunk_ptr *LastElement = GetPtr(Array, LastI); + auto LastElement = GetPtr(Array, LastI); + Set(Array, LastElement, Index); + Array->ElementCount -= 1; +} - *Element = *LastElement; +link_internal void +RemoveOrdered( world_chunk_ptr_block_array *Array, world_chunk_ptr_block_array_index IndexToRemove) +{ + Assert(IndexToRemove.Index < Array->ElementCount); - Assert(Array->Current->At); - Array->Current->At -= 1; + world_chunk_ptr Prev = {}; - if (Array->Current->At == 0) + world_chunk_ptr_block_array_index Max = AtElements(Array); + RangeIteratorRange_t(umm, Index, Max.Index, IndexToRemove.Index) { - // Walk the chain till we get to the second-last one - world_chunk_ptr_block *Current = Array->First; - world_chunk_ptr_block *LastB = LastI.Block; + world_chunk_ptr E = GetPtr(Array, Index); - while (Current->Next && Current->Next != LastB) + if (Prev) { - Current = Current->Next; + *Prev = *E; } - Assert(Current->Next == LastB || Current->Next == 0); - Array->Current = Current; + Prev = E; } + + Array->ElementCount -= 1; } -link_internal world_chunk_ptr * -Push(world_chunk_ptr_block_array *Array, world_chunk_ptr *Element) +link_internal void +RemoveOrdered( world_chunk_ptr_block_array *Array, world_chunk_ptr Element ) { - if (Array->Memory == 0) { Array->Memory = AllocateArena(); } - - if (Array->First == 0) { Array->First = Allocate_world_chunk_ptr_block(Array->Memory); Array->Current = Array->First; } - - if (Array->Current->At == 32) + IterateOver(Array, E, I) { - if (Array->Current->Next) + if (E == Element) { - Array->Current = Array->Current->Next; - Assert(Array->Current->At == 0); + RemoveOrdered(Array, I); + break; } - else - { - world_chunk_ptr_block *Next = Allocate_world_chunk_ptr_block(Array->Memory); - Next->Index = Array->Current->Index + 1; + } +} - Array->Current->Next = Next; - Array->Current = Next; +link_internal world_chunk_ptr_block_array_index +Find( world_chunk_ptr_block_array *Array, world_chunk_ptr Query) +{ + world_chunk_ptr_block_array_index Result = {INVALID_BLOCK_ARRAY_INDEX}; + IterateOver(Array, E, Index) + { + if ( E == Query ) + { + Result = Index; + break; } } + return Result; +} + + + +link_internal b32 +IsValid(world_chunk_ptr_block_array_index *Index) +{ + world_chunk_ptr_block_array_index Test = {INVALID_BLOCK_ARRAY_INDEX}; + b32 Result = (AreEqual(Index, &Test) == False); + return Result; +} + +link_internal world_chunk_ptr +Push( world_chunk_ptr_block_array *Array, world_chunk_ptr Element) +{ + Assert(Array->Memory); + + if (AtElements(Array) == Capacity(Array)) + { + NewBlock(Array); + } - world_chunk_ptr *Result = Array->Current->Elements + Array->Current->At; + world_chunk_ptr Result = Set(Array, Element, AtElements(Array)); - Array->Current->Elements[Array->Current->At++] = *Element; + Array->ElementCount += 1; return Result; } +link_internal world_chunk_ptr +Push( world_chunk_ptr_block_array *Array ) +{ + world_chunk_ptr Element = {}; + auto Result = Push(Array, Element); + return Result; +} + +link_internal void +Insert( world_chunk_ptr_block_array *Array, world_chunk_ptr_block_array_index Index, world_chunk_ptr Element ) +{ + Assert(Index.Index <= LastIndex(Array).Index); + Assert(Array->Memory); + + // Alocate a new thingy + world_chunk_ptr Prev = Push(Array); + + auto Last = LastIndex(Array); + + RangeIteratorReverseRange(I, s32(Last.Index), s32(Index.Index)) + { + auto E = GetPtr(Array, umm(I)); + *Prev = *E; + Prev = E; + } + + *Prev = *Element; +} + +link_internal void +Insert( world_chunk_ptr_block_array *Array, u32 Index, world_chunk_ptr Element ) +{ + Insert(Array, { .Index = Index }, Element); +} + +link_internal void +Shift( world_chunk_ptr_block_array *Array, world_chunk_ptr Element ) +{ + Insert(Array, { .Index = 0 }, Element); +} + +/* element_t.has_tag(do_editor_ui)? */ +/* { */ +/* do_editor_ui_for_container( block_array_t ) */ +/* } */ + + diff --git a/generated/block_array_world_edit_688735882.h b/generated/block_array_world_edit_688735882.h new file mode 100644 index 000000000..674e118ed --- /dev/null +++ b/generated/block_array_world_edit_688735882.h @@ -0,0 +1,372 @@ +// src/engine/editor.h:1250:0 + + + + + +struct world_edit_block +{ + /* u32 Index; */ + umm At; + world_edit Elements[8]; +}; + +struct world_edit_block_array_index poof(@block_array_IndexOfValue) +{ + umm Index; +}; + +struct world_edit_block_array +{ + world_edit_block **BlockPtrs; poof(@array_length(Element->BlockCount)) + u32 BlockCount; + u32 ElementCount; + memory_arena *Memory; poof(@no_serialize) + +}; + +link_internal world_edit_block_array +WorldEditBlockArray(memory_arena *Memory) +{ + world_edit_block_array Result = {}; + Result.Memory = Memory; + return Result; +} + +link_internal b32 +AreEqual(world_edit_block_array_index *Thing1, world_edit_block_array_index *Thing2) +{ + if (Thing1 && Thing2) + { + b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( world_edit_block_array_index ) ); + + return Result; + } + else + { + return (Thing1 == Thing2); + } +} + +link_internal b32 +AreEqual(world_edit_block_array_index Thing1, world_edit_block_array_index Thing2) +{ + b32 Result = MemoryIsEqual((u8*)&Thing1, (u8*)&Thing2, sizeof( world_edit_block_array_index ) ); + + return Result; +} + + +typedef world_edit_block_array world_edit_paged_list; + +link_internal world_edit_block_array_index +operator++( world_edit_block_array_index &I0 ) +{ + I0.Index++; + return I0; +} + +link_internal b32 +operator<( world_edit_block_array_index I0, world_edit_block_array_index I1 ) +{ + b32 Result = I0.Index < I1.Index; + return Result; +} + +link_internal b32 +operator==( world_edit_block_array_index I0, world_edit_block_array_index I1 ) +{ + b32 Result = I0.Index == I1.Index; + return Result; +} + +link_inline umm +GetIndex( world_edit_block_array_index *Index) +{ + umm Result = Index->Index; + return Result; +} + + +link_internal world_edit_block_array_index +ZerothIndex( world_edit_block_array *Arr ) +{ + return {}; +} + +link_internal world_edit_block_array_index +Capacity( world_edit_block_array *Arr ) +{ + world_edit_block_array_index Result = {Arr->BlockCount * 8}; + return Result; +} + +link_internal world_edit_block_array_index +AtElements( world_edit_block_array *Arr ) +{ + world_edit_block_array_index Result = {Arr->ElementCount}; + return Result; +} + + +link_internal umm +TotalElements( world_edit_block_array *Arr ) +{ + umm Result = AtElements(Arr).Index; + return Result; +} + + +link_internal world_edit_block_array_index +LastIndex( world_edit_block_array *Arr ) +{ + world_edit_block_array_index Result = {}; + umm Count = AtElements(Arr).Index; + if (Count) Result.Index = Count-1; + return Result; +} + +link_internal umm +Count( world_edit_block_array *Arr ) +{ + auto Result = AtElements(Arr).Index; + return Result; +} + +link_internal world_edit_block * +GetBlock( world_edit_block_array *Arr, world_edit_block_array_index Index ) +{ + umm BlockIndex = Index.Index / 8; + Assert(BlockIndex < Arr->BlockCount); + world_edit_block *Block = Arr->BlockPtrs[BlockIndex]; + return Block; +} + +link_internal world_edit * +GetPtr( world_edit_block_array *Arr, world_edit_block_array_index Index ) +{ + Assert(Arr->BlockPtrs); + Assert(Index.Index < Capacity(Arr).Index); + + world_edit_block *Block = GetBlock(Arr, Index); + + umm ElementIndex = Index.Index % 8; + world_edit *Result = (Block->Elements + ElementIndex); + return Result; +} + + +link_internal world_edit * +GetPtr( world_edit_block_array *Arr, umm Index ) +{ + world_edit_block_array_index I = {Index}; + return GetPtr(Arr, I); +} + + +link_internal world_edit * +TryGetPtr( world_edit_block_array *Arr, world_edit_block_array_index Index) +{ + world_edit * Result = {}; + if (Arr->BlockPtrs && Index < AtElements(Arr)) + { + Result = GetPtr(Arr, Index); + } + return Result; +} + +link_internal world_edit * +TryGetPtr( world_edit_block_array *Arr, umm Index) +{ + auto Result = TryGetPtr(Arr, world_edit_block_array_index{Index}); + return Result; +} + + + + + +link_internal cs +CS( world_edit_block_array_index Index ) +{ + return FSz("(%u)", Index.Index); +} + +link_internal world_edit * +Set( world_edit_block_array *Arr, + world_edit *Element, + world_edit_block_array_index Index ) +{ + Assert(Arr->BlockPtrs); + Assert(Index.Index < Capacity(Arr).Index); + world_edit_block *Block = GetBlock(Arr, Index); + umm ElementIndex = Index.Index % 8; + auto Slot = Block->Elements+ElementIndex; + *Slot = *Element; + return Slot; +} + +link_internal void +NewBlock( world_edit_block_array *Arr ) +{ + world_edit_block *NewBlock = Allocate( world_edit_block , Arr->Memory, 1); + world_edit_block **NewBlockPtrs = Allocate( world_edit_block*, Arr->Memory, Arr->BlockCount+1); + + RangeIterator_t(u32, BlockI, Arr->BlockCount) + { + NewBlockPtrs[BlockI] = Arr->BlockPtrs[BlockI]; + } + + NewBlockPtrs[Arr->BlockCount] = NewBlock; + + + + Arr->BlockPtrs = NewBlockPtrs; + Arr->BlockCount += 1; +} + +link_internal void +RemoveUnordered( world_edit_block_array *Array, world_edit_block_array_index Index) +{ + auto LastI = LastIndex(Array); + Assert(Index.Index <= LastI.Index); + + auto LastElement = GetPtr(Array, LastI); + Set(Array, LastElement, Index); + Array->ElementCount -= 1; +} + +link_internal void +RemoveOrdered( world_edit_block_array *Array, world_edit_block_array_index IndexToRemove) +{ + Assert(IndexToRemove.Index < Array->ElementCount); + + world_edit *Prev = {}; + + world_edit_block_array_index Max = AtElements(Array); + RangeIteratorRange_t(umm, Index, Max.Index, IndexToRemove.Index) + { + world_edit *E = GetPtr(Array, Index); + + if (Prev) + { + *Prev = *E; + } + + Prev = E; + } + + Array->ElementCount -= 1; +} + +link_internal void +RemoveOrdered( world_edit_block_array *Array, world_edit *Element ) +{ + IterateOver(Array, E, I) + { + if (E == Element) + { + RemoveOrdered(Array, I); + break; + } + } +} + +link_internal world_edit_block_array_index +Find( world_edit_block_array *Array, world_edit *Query) +{ + world_edit_block_array_index Result = {INVALID_BLOCK_ARRAY_INDEX}; + IterateOver(Array, E, Index) + { + if ( E == Query ) + { + Result = Index; + break; + } + } + return Result; +} + + + +link_internal b32 +IsValid(world_edit_block_array_index *Index) +{ + world_edit_block_array_index Test = {INVALID_BLOCK_ARRAY_INDEX}; + b32 Result = (AreEqual(Index, &Test) == False); + return Result; +} + +link_internal world_edit * +Push( world_edit_block_array *Array, world_edit *Element) +{ + Assert(Array->Memory); + + if (AtElements(Array) == Capacity(Array)) + { + NewBlock(Array); + } + + world_edit *Result = Set(Array, Element, AtElements(Array)); + + Array->ElementCount += 1; + + return Result; +} + +link_internal world_edit * +Push( world_edit_block_array *Array ) +{ + world_edit Element = {}; + auto Result = Push(Array, &Element); + return Result; +} + +link_internal void +Shift( world_edit_block_array *Array, world_edit *Element ) +{ + Assert(Array->Memory); + world_edit *Prev = {}; + + // Alocate a new thingy + Push(Array); + + auto End = AtElements(Array); + RangeIteratorReverse(Index, s32(End.Index)) + { + auto E = GetPtr(Array, umm(Index)); + if (Prev) { *Prev = *E; } + Prev = E; + } + + *Prev = *Element; +} + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, world_edit_block_array *Container, cs Name, u32 ParentHash, EDITOR_UI_FUNCTION_PROTO_DEFAULTS) +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash); + if (Container) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, Name.Start, Container, ThisHash), EDITOR_UI_FUNCTION_INSTANCE_NAMES)) + { + PushNewRow(Ui); + IterateOver(Container, Element, ElementIndex) + { + DoEditorUi(Ui, Window, Element, CS(ElementIndex), ThisHash, EDITOR_UI_FUNCTION_INSTANCE_NAMES); + PushNewRow(Ui); + } + } + PushNewRow(Ui); + } + else + { + PushColumn(Ui, FSz("%S", Name), EDITOR_UI_FUNCTION_INSTANCE_NAMES); + PushColumn(Ui, CSz("(null)"), EDITOR_UI_FUNCTION_INSTANCE_NAMES); + PushNewRow(Ui); + } +} + + + + diff --git a/generated/block_array_world_edit_block_array_index_688735882.h b/generated/block_array_world_edit_block_array_index_688735882.h new file mode 100644 index 000000000..4df3d25e2 --- /dev/null +++ b/generated/block_array_world_edit_block_array_index_688735882.h @@ -0,0 +1,377 @@ +// external/bonsai_stdlib/src/poof_functions.h:2600:0 + + + + +struct world_edit_block_array_index_block +{ + /* u32 Index; */ + umm At; + world_edit_block_array_index Elements[8]; +}; + +struct world_edit_block_array_index_block_array_index +{ + umm Index; +}; + +struct world_edit_block_array_index_block_array +{ + world_edit_block_array_index_block **BlockPtrs; poof(@array_length(Element->BlockCount)) + u32 BlockCount; + u32 ElementCount; + memory_arena *Memory; poof(@no_serialize) + +}; + +link_internal world_edit_block_array_index_block_array +WorldEditBlockArrayIndexBlockArray(memory_arena *Memory) +{ + world_edit_block_array_index_block_array Result = {}; + Result.Memory = Memory; + return Result; +} + +link_internal b32 +AreEqual(world_edit_block_array_index_block_array_index *Thing1, world_edit_block_array_index_block_array_index *Thing2) +{ + if (Thing1 && Thing2) + { + b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( world_edit_block_array_index_block_array_index ) ); + + return Result; + } + else + { + return (Thing1 == Thing2); + } +} + +link_internal b32 +AreEqual(world_edit_block_array_index_block_array_index Thing1, world_edit_block_array_index_block_array_index Thing2) +{ + b32 Result = MemoryIsEqual((u8*)&Thing1, (u8*)&Thing2, sizeof( world_edit_block_array_index_block_array_index ) ); + + return Result; +} + + +typedef world_edit_block_array_index_block_array world_edit_block_array_index_paged_list; + +link_internal world_edit_block_array_index_block_array_index +operator++( world_edit_block_array_index_block_array_index &I0 ) +{ + I0.Index++; + return I0; +} + +link_internal b32 +operator<( world_edit_block_array_index_block_array_index I0, world_edit_block_array_index_block_array_index I1 ) +{ + b32 Result = I0.Index < I1.Index; + return Result; +} + +link_internal b32 +operator==( world_edit_block_array_index_block_array_index I0, world_edit_block_array_index_block_array_index I1 ) +{ + b32 Result = I0.Index == I1.Index; + return Result; +} + +link_inline umm +GetIndex( world_edit_block_array_index_block_array_index *Index) +{ + umm Result = Index->Index; + return Result; +} + + +link_internal world_edit_block_array_index_block_array_index +ZerothIndex( world_edit_block_array_index_block_array *Arr ) +{ + return {}; +} + +link_internal world_edit_block_array_index_block_array_index +Capacity( world_edit_block_array_index_block_array *Arr ) +{ + world_edit_block_array_index_block_array_index Result = {Arr->BlockCount * 8}; + return Result; +} + +link_internal world_edit_block_array_index_block_array_index +AtElements( world_edit_block_array_index_block_array *Arr ) +{ + world_edit_block_array_index_block_array_index Result = {Arr->ElementCount}; + return Result; +} + + +link_internal umm +TotalElements( world_edit_block_array_index_block_array *Arr ) +{ + umm Result = AtElements(Arr).Index; + return Result; +} + + +link_internal world_edit_block_array_index_block_array_index +LastIndex( world_edit_block_array_index_block_array *Arr ) +{ + world_edit_block_array_index_block_array_index Result = {}; + umm Count = AtElements(Arr).Index; + if (Count) Result.Index = Count-1; + return Result; +} + +link_internal umm +Count( world_edit_block_array_index_block_array *Arr ) +{ + auto Result = AtElements(Arr).Index; + return Result; +} + +link_internal world_edit_block_array_index_block * +GetBlock( world_edit_block_array_index_block_array *Arr, world_edit_block_array_index_block_array_index Index ) +{ + umm BlockIndex = Index.Index / 8; + Assert(BlockIndex < Arr->BlockCount); + world_edit_block_array_index_block *Block = Arr->BlockPtrs[BlockIndex]; + return Block; +} + +link_internal world_edit_block_array_index * +GetPtr( world_edit_block_array_index_block_array *Arr, world_edit_block_array_index_block_array_index Index ) +{ + Assert(Arr->BlockPtrs); + Assert(Index.Index < Capacity(Arr).Index); + + world_edit_block_array_index_block *Block = GetBlock(Arr, Index); + + umm ElementIndex = Index.Index % 8; + world_edit_block_array_index *Result = (Block->Elements + ElementIndex); + return Result; +} + + +link_internal world_edit_block_array_index * +GetPtr( world_edit_block_array_index_block_array *Arr, umm Index ) +{ + world_edit_block_array_index_block_array_index I = {Index}; + return GetPtr(Arr, I); +} + + +link_internal world_edit_block_array_index * +TryGetPtr( world_edit_block_array_index_block_array *Arr, world_edit_block_array_index_block_array_index Index) +{ + world_edit_block_array_index * Result = {}; + if (Arr->BlockPtrs && Index < AtElements(Arr)) + { + Result = GetPtr(Arr, Index); + } + return Result; +} + +link_internal world_edit_block_array_index * +TryGetPtr( world_edit_block_array_index_block_array *Arr, umm Index) +{ + auto Result = TryGetPtr(Arr, world_edit_block_array_index_block_array_index{Index}); + return Result; +} + + + + + +link_internal cs +CS( world_edit_block_array_index_block_array_index Index ) +{ + return FSz("(%u)", Index.Index); +} + +link_internal world_edit_block_array_index * +Set( world_edit_block_array_index_block_array *Arr, + world_edit_block_array_index *Element, + world_edit_block_array_index_block_array_index Index ) +{ + Assert(Arr->BlockPtrs); + Assert(Index.Index < Capacity(Arr).Index); + world_edit_block_array_index_block *Block = GetBlock(Arr, Index); + umm ElementIndex = Index.Index % 8; + auto Slot = Block->Elements+ElementIndex; + *Slot = *Element; + return Slot; +} + +link_internal void +NewBlock( world_edit_block_array_index_block_array *Arr ) +{ + world_edit_block_array_index_block *NewBlock = Allocate( world_edit_block_array_index_block , Arr->Memory, 1); + world_edit_block_array_index_block **NewBlockPtrs = Allocate( world_edit_block_array_index_block*, Arr->Memory, Arr->BlockCount+1); + + RangeIterator_t(u32, BlockI, Arr->BlockCount) + { + NewBlockPtrs[BlockI] = Arr->BlockPtrs[BlockI]; + } + + NewBlockPtrs[Arr->BlockCount] = NewBlock; + + + + Arr->BlockPtrs = NewBlockPtrs; + Arr->BlockCount += 1; +} + +link_internal void +RemoveUnordered( world_edit_block_array_index_block_array *Array, world_edit_block_array_index_block_array_index Index) +{ + auto LastI = LastIndex(Array); + Assert(Index.Index <= LastI.Index); + + auto LastElement = GetPtr(Array, LastI); + Set(Array, LastElement, Index); + Array->ElementCount -= 1; +} + +link_internal void +RemoveOrdered( world_edit_block_array_index_block_array *Array, world_edit_block_array_index_block_array_index IndexToRemove) +{ + Assert(IndexToRemove.Index < Array->ElementCount); + + world_edit_block_array_index *Prev = {}; + + world_edit_block_array_index_block_array_index Max = AtElements(Array); + RangeIteratorRange_t(umm, Index, Max.Index, IndexToRemove.Index) + { + world_edit_block_array_index *E = GetPtr(Array, Index); + + if (Prev) + { + *Prev = *E; + } + + Prev = E; + } + + Array->ElementCount -= 1; +} + +link_internal void +RemoveOrdered( world_edit_block_array_index_block_array *Array, world_edit_block_array_index *Element ) +{ + IterateOver(Array, E, I) + { + if (E == Element) + { + RemoveOrdered(Array, I); + break; + } + } +} + +link_internal world_edit_block_array_index_block_array_index +Find( world_edit_block_array_index_block_array *Array, world_edit_block_array_index *Query) +{ + world_edit_block_array_index_block_array_index Result = {INVALID_BLOCK_ARRAY_INDEX}; + IterateOver(Array, E, Index) + { + if ( E == Query ) + { + Result = Index; + break; + } + } + return Result; +} + +link_internal world_edit_block_array_index_block_array_index +IndexOfValue( world_edit_block_array_index_block_array *Array, world_edit_block_array_index *Query) +{ + world_edit_block_array_index_block_array_index Result = {INVALID_BLOCK_ARRAY_INDEX}; + IterateOver(Array, E, Index) + { + if (AreEqual(E, Query)) + { + Result = Index; + break; + } + } + return Result; +} + + +link_internal b32 +IsValid(world_edit_block_array_index_block_array_index *Index) +{ + world_edit_block_array_index_block_array_index Test = {INVALID_BLOCK_ARRAY_INDEX}; + b32 Result = (AreEqual(Index, &Test) == False); + return Result; +} + +link_internal world_edit_block_array_index * +Push( world_edit_block_array_index_block_array *Array, world_edit_block_array_index *Element) +{ + Assert(Array->Memory); + + if (AtElements(Array) == Capacity(Array)) + { + NewBlock(Array); + } + + world_edit_block_array_index *Result = Set(Array, Element, AtElements(Array)); + + Array->ElementCount += 1; + + return Result; +} + +link_internal world_edit_block_array_index * +Push( world_edit_block_array_index_block_array *Array ) +{ + world_edit_block_array_index Element = {}; + auto Result = Push(Array, &Element); + return Result; +} + +link_internal void +Insert( world_edit_block_array_index_block_array *Array, world_edit_block_array_index_block_array_index Index, world_edit_block_array_index *Element ) +{ + Assert(Index.Index <= LastIndex(Array).Index); + Assert(Array->Memory); + + // Alocate a new thingy + world_edit_block_array_index *Prev = Push(Array); + + auto Last = LastIndex(Array); + + RangeIteratorReverseRange(I, s32(Last.Index), s32(Index.Index)) + { + auto E = GetPtr(Array, umm(I)); + *Prev = *E; + Prev = E; + } + + *Prev = *Element; +} + +link_internal void +Insert( world_edit_block_array_index_block_array *Array, u32 Index, world_edit_block_array_index *Element ) +{ + Insert(Array, { .Index = Index }, Element); +} + +link_internal void +Shift( world_edit_block_array_index_block_array *Array, world_edit_block_array_index *Element ) +{ + Insert(Array, { .Index = 0 }, Element); +} + +/* element_t.has_tag(do_editor_ui)? */ +/* { */ +/* do_editor_ui_for_container( block_array_t ) */ +/* } */ + + + diff --git a/generated/block_array_world_edit_layer_688735882.h b/generated/block_array_world_edit_layer_688735882.h new file mode 100644 index 000000000..f92962703 --- /dev/null +++ b/generated/block_array_world_edit_layer_688735882.h @@ -0,0 +1,363 @@ +// external/bonsai_stdlib/src/poof_functions.h:2600:0 + + + + +struct world_edit_layer_block +{ + /* u32 Index; */ + umm At; + world_edit_layer Elements[8]; +}; + +struct world_edit_layer_block_array_index +{ + umm Index; +}; + +struct world_edit_layer_block_array +{ + world_edit_layer_block **BlockPtrs; poof(@array_length(Element->BlockCount)) + u32 BlockCount; + u32 ElementCount; + memory_arena *Memory; poof(@no_serialize) + +}; + +link_internal world_edit_layer_block_array +WorldEditLayerBlockArray(memory_arena *Memory) +{ + world_edit_layer_block_array Result = {}; + Result.Memory = Memory; + return Result; +} + +link_internal b32 +AreEqual(world_edit_layer_block_array_index *Thing1, world_edit_layer_block_array_index *Thing2) +{ + if (Thing1 && Thing2) + { + b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( world_edit_layer_block_array_index ) ); + + return Result; + } + else + { + return (Thing1 == Thing2); + } +} + +link_internal b32 +AreEqual(world_edit_layer_block_array_index Thing1, world_edit_layer_block_array_index Thing2) +{ + b32 Result = MemoryIsEqual((u8*)&Thing1, (u8*)&Thing2, sizeof( world_edit_layer_block_array_index ) ); + + return Result; +} + + +typedef world_edit_layer_block_array world_edit_layer_paged_list; + +link_internal world_edit_layer_block_array_index +operator++( world_edit_layer_block_array_index &I0 ) +{ + I0.Index++; + return I0; +} + +link_internal b32 +operator<( world_edit_layer_block_array_index I0, world_edit_layer_block_array_index I1 ) +{ + b32 Result = I0.Index < I1.Index; + return Result; +} + +link_internal b32 +operator==( world_edit_layer_block_array_index I0, world_edit_layer_block_array_index I1 ) +{ + b32 Result = I0.Index == I1.Index; + return Result; +} + +link_inline umm +GetIndex( world_edit_layer_block_array_index *Index) +{ + umm Result = Index->Index; + return Result; +} + + +link_internal world_edit_layer_block_array_index +ZerothIndex( world_edit_layer_block_array *Arr ) +{ + return {}; +} + +link_internal world_edit_layer_block_array_index +Capacity( world_edit_layer_block_array *Arr ) +{ + world_edit_layer_block_array_index Result = {Arr->BlockCount * 8}; + return Result; +} + +link_internal world_edit_layer_block_array_index +AtElements( world_edit_layer_block_array *Arr ) +{ + world_edit_layer_block_array_index Result = {Arr->ElementCount}; + return Result; +} + + +link_internal umm +TotalElements( world_edit_layer_block_array *Arr ) +{ + umm Result = AtElements(Arr).Index; + return Result; +} + + +link_internal world_edit_layer_block_array_index +LastIndex( world_edit_layer_block_array *Arr ) +{ + world_edit_layer_block_array_index Result = {}; + umm Count = AtElements(Arr).Index; + if (Count) Result.Index = Count-1; + return Result; +} + +link_internal umm +Count( world_edit_layer_block_array *Arr ) +{ + auto Result = AtElements(Arr).Index; + return Result; +} + +link_internal world_edit_layer_block * +GetBlock( world_edit_layer_block_array *Arr, world_edit_layer_block_array_index Index ) +{ + umm BlockIndex = Index.Index / 8; + Assert(BlockIndex < Arr->BlockCount); + world_edit_layer_block *Block = Arr->BlockPtrs[BlockIndex]; + return Block; +} + +link_internal world_edit_layer * +GetPtr( world_edit_layer_block_array *Arr, world_edit_layer_block_array_index Index ) +{ + Assert(Arr->BlockPtrs); + Assert(Index.Index < Capacity(Arr).Index); + + world_edit_layer_block *Block = GetBlock(Arr, Index); + + umm ElementIndex = Index.Index % 8; + world_edit_layer *Result = (Block->Elements + ElementIndex); + return Result; +} + + +link_internal world_edit_layer * +GetPtr( world_edit_layer_block_array *Arr, umm Index ) +{ + world_edit_layer_block_array_index I = {Index}; + return GetPtr(Arr, I); +} + + +link_internal world_edit_layer * +TryGetPtr( world_edit_layer_block_array *Arr, world_edit_layer_block_array_index Index) +{ + world_edit_layer * Result = {}; + if (Arr->BlockPtrs && Index < AtElements(Arr)) + { + Result = GetPtr(Arr, Index); + } + return Result; +} + +link_internal world_edit_layer * +TryGetPtr( world_edit_layer_block_array *Arr, umm Index) +{ + auto Result = TryGetPtr(Arr, world_edit_layer_block_array_index{Index}); + return Result; +} + + + + + +link_internal cs +CS( world_edit_layer_block_array_index Index ) +{ + return FSz("(%u)", Index.Index); +} + +link_internal world_edit_layer * +Set( world_edit_layer_block_array *Arr, + world_edit_layer *Element, + world_edit_layer_block_array_index Index ) +{ + Assert(Arr->BlockPtrs); + Assert(Index.Index < Capacity(Arr).Index); + world_edit_layer_block *Block = GetBlock(Arr, Index); + umm ElementIndex = Index.Index % 8; + auto Slot = Block->Elements+ElementIndex; + *Slot = *Element; + return Slot; +} + +link_internal void +NewBlock( world_edit_layer_block_array *Arr ) +{ + world_edit_layer_block *NewBlock = Allocate( world_edit_layer_block , Arr->Memory, 1); + world_edit_layer_block **NewBlockPtrs = Allocate( world_edit_layer_block*, Arr->Memory, Arr->BlockCount+1); + + RangeIterator_t(u32, BlockI, Arr->BlockCount) + { + NewBlockPtrs[BlockI] = Arr->BlockPtrs[BlockI]; + } + + NewBlockPtrs[Arr->BlockCount] = NewBlock; + + + + Arr->BlockPtrs = NewBlockPtrs; + Arr->BlockCount += 1; +} + +link_internal void +RemoveUnordered( world_edit_layer_block_array *Array, world_edit_layer_block_array_index Index) +{ + auto LastI = LastIndex(Array); + Assert(Index.Index <= LastI.Index); + + auto LastElement = GetPtr(Array, LastI); + Set(Array, LastElement, Index); + Array->ElementCount -= 1; +} + +link_internal void +RemoveOrdered( world_edit_layer_block_array *Array, world_edit_layer_block_array_index IndexToRemove) +{ + Assert(IndexToRemove.Index < Array->ElementCount); + + world_edit_layer *Prev = {}; + + world_edit_layer_block_array_index Max = AtElements(Array); + RangeIteratorRange_t(umm, Index, Max.Index, IndexToRemove.Index) + { + world_edit_layer *E = GetPtr(Array, Index); + + if (Prev) + { + *Prev = *E; + } + + Prev = E; + } + + Array->ElementCount -= 1; +} + +link_internal void +RemoveOrdered( world_edit_layer_block_array *Array, world_edit_layer *Element ) +{ + IterateOver(Array, E, I) + { + if (E == Element) + { + RemoveOrdered(Array, I); + break; + } + } +} + +link_internal world_edit_layer_block_array_index +Find( world_edit_layer_block_array *Array, world_edit_layer *Query) +{ + world_edit_layer_block_array_index Result = {INVALID_BLOCK_ARRAY_INDEX}; + IterateOver(Array, E, Index) + { + if ( E == Query ) + { + Result = Index; + break; + } + } + return Result; +} + + + +link_internal b32 +IsValid(world_edit_layer_block_array_index *Index) +{ + world_edit_layer_block_array_index Test = {INVALID_BLOCK_ARRAY_INDEX}; + b32 Result = (AreEqual(Index, &Test) == False); + return Result; +} + +link_internal world_edit_layer * +Push( world_edit_layer_block_array *Array, world_edit_layer *Element) +{ + Assert(Array->Memory); + + if (AtElements(Array) == Capacity(Array)) + { + NewBlock(Array); + } + + world_edit_layer *Result = Set(Array, Element, AtElements(Array)); + + Array->ElementCount += 1; + + return Result; +} + +link_internal world_edit_layer * +Push( world_edit_layer_block_array *Array ) +{ + world_edit_layer Element = {}; + auto Result = Push(Array, &Element); + return Result; +} + +link_internal void +Insert( world_edit_layer_block_array *Array, world_edit_layer_block_array_index Index, world_edit_layer *Element ) +{ + Assert(Index.Index <= LastIndex(Array).Index); + Assert(Array->Memory); + + // Alocate a new thingy + world_edit_layer *Prev = Push(Array); + + auto Last = LastIndex(Array); + + RangeIteratorReverseRange(I, s32(Last.Index), s32(Index.Index)) + { + auto E = GetPtr(Array, umm(I)); + *Prev = *E; + Prev = E; + } + + *Prev = *Element; +} + +link_internal void +Insert( world_edit_layer_block_array *Array, u32 Index, world_edit_layer *Element ) +{ + Insert(Array, { .Index = Index }, Element); +} + +link_internal void +Shift( world_edit_layer_block_array *Array, world_edit_layer *Element ) +{ + Insert(Array, { .Index = 0 }, Element); +} + +/* element_t.has_tag(do_editor_ui)? */ +/* { */ +/* do_editor_ui_for_container( block_array_t ) */ +/* } */ + + + diff --git a/generated/block_array_world_edit_ptr_688735882.h b/generated/block_array_world_edit_ptr_688735882.h new file mode 100644 index 000000000..7364af951 --- /dev/null +++ b/generated/block_array_world_edit_ptr_688735882.h @@ -0,0 +1,363 @@ +// external/bonsai_stdlib/src/poof_functions.h:2600:0 + + + + +struct world_edit_ptr_block +{ + /* u32 Index; */ + umm At; + world_edit_ptr Elements[8]; +}; + +struct world_edit_ptr_block_array_index +{ + umm Index; +}; + +struct world_edit_ptr_block_array +{ + world_edit_ptr_block **BlockPtrs; poof(@array_length(Element->BlockCount)) + u32 BlockCount; + u32 ElementCount; + memory_arena *Memory; poof(@no_serialize) + +}; + +link_internal world_edit_ptr_block_array +WorldEditPtrBlockArray(memory_arena *Memory) +{ + world_edit_ptr_block_array Result = {}; + Result.Memory = Memory; + return Result; +} + +link_internal b32 +AreEqual(world_edit_ptr_block_array_index *Thing1, world_edit_ptr_block_array_index *Thing2) +{ + if (Thing1 && Thing2) + { + b32 Result = MemoryIsEqual((u8*)Thing1, (u8*)Thing2, sizeof( world_edit_ptr_block_array_index ) ); + + return Result; + } + else + { + return (Thing1 == Thing2); + } +} + +link_internal b32 +AreEqual(world_edit_ptr_block_array_index Thing1, world_edit_ptr_block_array_index Thing2) +{ + b32 Result = MemoryIsEqual((u8*)&Thing1, (u8*)&Thing2, sizeof( world_edit_ptr_block_array_index ) ); + + return Result; +} + + +typedef world_edit_ptr_block_array world_edit_ptr_paged_list; + +link_internal world_edit_ptr_block_array_index +operator++( world_edit_ptr_block_array_index &I0 ) +{ + I0.Index++; + return I0; +} + +link_internal b32 +operator<( world_edit_ptr_block_array_index I0, world_edit_ptr_block_array_index I1 ) +{ + b32 Result = I0.Index < I1.Index; + return Result; +} + +link_internal b32 +operator==( world_edit_ptr_block_array_index I0, world_edit_ptr_block_array_index I1 ) +{ + b32 Result = I0.Index == I1.Index; + return Result; +} + +link_inline umm +GetIndex( world_edit_ptr_block_array_index *Index) +{ + umm Result = Index->Index; + return Result; +} + + +link_internal world_edit_ptr_block_array_index +ZerothIndex( world_edit_ptr_block_array *Arr ) +{ + return {}; +} + +link_internal world_edit_ptr_block_array_index +Capacity( world_edit_ptr_block_array *Arr ) +{ + world_edit_ptr_block_array_index Result = {Arr->BlockCount * 8}; + return Result; +} + +link_internal world_edit_ptr_block_array_index +AtElements( world_edit_ptr_block_array *Arr ) +{ + world_edit_ptr_block_array_index Result = {Arr->ElementCount}; + return Result; +} + + +link_internal umm +TotalElements( world_edit_ptr_block_array *Arr ) +{ + umm Result = AtElements(Arr).Index; + return Result; +} + + +link_internal world_edit_ptr_block_array_index +LastIndex( world_edit_ptr_block_array *Arr ) +{ + world_edit_ptr_block_array_index Result = {}; + umm Count = AtElements(Arr).Index; + if (Count) Result.Index = Count-1; + return Result; +} + +link_internal umm +Count( world_edit_ptr_block_array *Arr ) +{ + auto Result = AtElements(Arr).Index; + return Result; +} + +link_internal world_edit_ptr_block * +GetBlock( world_edit_ptr_block_array *Arr, world_edit_ptr_block_array_index Index ) +{ + umm BlockIndex = Index.Index / 8; + Assert(BlockIndex < Arr->BlockCount); + world_edit_ptr_block *Block = Arr->BlockPtrs[BlockIndex]; + return Block; +} + +link_internal world_edit_ptr +GetPtr( world_edit_ptr_block_array *Arr, world_edit_ptr_block_array_index Index ) +{ + Assert(Arr->BlockPtrs); + Assert(Index.Index < Capacity(Arr).Index); + + world_edit_ptr_block *Block = GetBlock(Arr, Index); + + umm ElementIndex = Index.Index % 8; + world_edit_ptr Result = *(Block->Elements + ElementIndex); + return Result; +} + + +link_internal world_edit_ptr +GetPtr( world_edit_ptr_block_array *Arr, umm Index ) +{ + world_edit_ptr_block_array_index I = {Index}; + return GetPtr(Arr, I); +} + + +link_internal world_edit_ptr +TryGetPtr( world_edit_ptr_block_array *Arr, world_edit_ptr_block_array_index Index) +{ + world_edit_ptr Result = {}; + if (Arr->BlockPtrs && Index < AtElements(Arr)) + { + Result = GetPtr(Arr, Index); + } + return Result; +} + +link_internal world_edit_ptr +TryGetPtr( world_edit_ptr_block_array *Arr, umm Index) +{ + auto Result = TryGetPtr(Arr, world_edit_ptr_block_array_index{Index}); + return Result; +} + + + + + +link_internal cs +CS( world_edit_ptr_block_array_index Index ) +{ + return FSz("(%u)", Index.Index); +} + +link_internal world_edit_ptr +Set( world_edit_ptr_block_array *Arr, + world_edit_ptr Element, + world_edit_ptr_block_array_index Index ) +{ + Assert(Arr->BlockPtrs); + Assert(Index.Index < Capacity(Arr).Index); + world_edit_ptr_block *Block = GetBlock(Arr, Index); + umm ElementIndex = Index.Index % 8; + auto Slot = Block->Elements+ElementIndex; + *Slot = Element; + return *Slot; +} + +link_internal void +NewBlock( world_edit_ptr_block_array *Arr ) +{ + world_edit_ptr_block *NewBlock = Allocate( world_edit_ptr_block , Arr->Memory, 1); + world_edit_ptr_block **NewBlockPtrs = Allocate( world_edit_ptr_block*, Arr->Memory, Arr->BlockCount+1); + + RangeIterator_t(u32, BlockI, Arr->BlockCount) + { + NewBlockPtrs[BlockI] = Arr->BlockPtrs[BlockI]; + } + + NewBlockPtrs[Arr->BlockCount] = NewBlock; + + + + Arr->BlockPtrs = NewBlockPtrs; + Arr->BlockCount += 1; +} + +link_internal void +RemoveUnordered( world_edit_ptr_block_array *Array, world_edit_ptr_block_array_index Index) +{ + auto LastI = LastIndex(Array); + Assert(Index.Index <= LastI.Index); + + auto LastElement = GetPtr(Array, LastI); + Set(Array, LastElement, Index); + Array->ElementCount -= 1; +} + +link_internal void +RemoveOrdered( world_edit_ptr_block_array *Array, world_edit_ptr_block_array_index IndexToRemove) +{ + Assert(IndexToRemove.Index < Array->ElementCount); + + world_edit_ptr Prev = {}; + + world_edit_ptr_block_array_index Max = AtElements(Array); + RangeIteratorRange_t(umm, Index, Max.Index, IndexToRemove.Index) + { + world_edit_ptr E = GetPtr(Array, Index); + + if (Prev) + { + *Prev = *E; + } + + Prev = E; + } + + Array->ElementCount -= 1; +} + +link_internal void +RemoveOrdered( world_edit_ptr_block_array *Array, world_edit_ptr Element ) +{ + IterateOver(Array, E, I) + { + if (E == Element) + { + RemoveOrdered(Array, I); + break; + } + } +} + +link_internal world_edit_ptr_block_array_index +Find( world_edit_ptr_block_array *Array, world_edit_ptr Query) +{ + world_edit_ptr_block_array_index Result = {INVALID_BLOCK_ARRAY_INDEX}; + IterateOver(Array, E, Index) + { + if ( E == Query ) + { + Result = Index; + break; + } + } + return Result; +} + + + +link_internal b32 +IsValid(world_edit_ptr_block_array_index *Index) +{ + world_edit_ptr_block_array_index Test = {INVALID_BLOCK_ARRAY_INDEX}; + b32 Result = (AreEqual(Index, &Test) == False); + return Result; +} + +link_internal world_edit_ptr +Push( world_edit_ptr_block_array *Array, world_edit_ptr Element) +{ + Assert(Array->Memory); + + if (AtElements(Array) == Capacity(Array)) + { + NewBlock(Array); + } + + world_edit_ptr Result = Set(Array, Element, AtElements(Array)); + + Array->ElementCount += 1; + + return Result; +} + +link_internal world_edit_ptr +Push( world_edit_ptr_block_array *Array ) +{ + world_edit_ptr Element = {}; + auto Result = Push(Array, Element); + return Result; +} + +link_internal void +Insert( world_edit_ptr_block_array *Array, world_edit_ptr_block_array_index Index, world_edit_ptr Element ) +{ + Assert(Index.Index <= LastIndex(Array).Index); + Assert(Array->Memory); + + // Alocate a new thingy + world_edit_ptr Prev = Push(Array); + + auto Last = LastIndex(Array); + + RangeIteratorReverseRange(I, s32(Last.Index), s32(Index.Index)) + { + auto E = GetPtr(Array, umm(I)); + *Prev = *E; + Prev = E; + } + + *Prev = *Element; +} + +link_internal void +Insert( world_edit_ptr_block_array *Array, u32 Index, world_edit_ptr Element ) +{ + Insert(Array, { .Index = Index }, Element); +} + +link_internal void +Shift( world_edit_ptr_block_array *Array, world_edit_ptr Element ) +{ + Insert(Array, { .Index = 0 }, Element); +} + +/* element_t.has_tag(do_editor_ui)? */ +/* { */ +/* do_editor_ui_for_container( block_array_t ) */ +/* } */ + + + diff --git a/generated/bubble_sort_686708022.h b/generated/bubble_sort_686708022.h index 21a0aae9e..7937ed39f 100644 --- a/generated/bubble_sort_686708022.h +++ b/generated/bubble_sort_686708022.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/sort.h:68:0 - +// external/bonsai_stdlib/src/sort.h:39:0 link_internal void BubbleSort(sort_key *Keys, u32 Count) { @@ -30,8 +29,39 @@ BubbleSort(sort_key *Keys, u32 Count) return; } + link_internal void -BubbleSort(sort_key_f *Keys, u32 Count) +BubbleSort_descending(sort_key *Keys, u32 Count) +{ + for (u32 Ignored = 0; + Ignored < Count; + ++Ignored) + { + b32 Sorted = True; + + for (u32 Inner = 0; + Inner < (Count-1); + ++Inner) + { + auto *KeyA = Keys+Inner; + auto *KeyB = Keys+Inner+1; + + if (*KeyA > *KeyB) + { + auto Temp = *KeyA; + *KeyA = *KeyB; + *KeyB = Temp; + Sorted = False; + } + } + + if (Sorted) break; + } + + return; +} +link_internal void +BubbleSort(sort_key_f64 *Keys, u32 Count) { for (u32 Ignored = 0; Ignored < Count; @@ -60,6 +90,98 @@ BubbleSort(sort_key_f *Keys, u32 Count) return; } + +link_internal void +BubbleSort_descending(sort_key_f64 *Keys, u32 Count) +{ + for (u32 Ignored = 0; + Ignored < Count; + ++Ignored) + { + b32 Sorted = True; + + for (u32 Inner = 0; + Inner < (Count-1); + ++Inner) + { + auto *KeyA = Keys+Inner; + auto *KeyB = Keys+Inner+1; + + if (*KeyA > *KeyB) + { + auto Temp = *KeyA; + *KeyA = *KeyB; + *KeyB = Temp; + Sorted = False; + } + } + + if (Sorted) break; + } + + return; +} +link_internal void +BubbleSort(sort_key_f32 *Keys, u32 Count) +{ + for (u32 Ignored = 0; + Ignored < Count; + ++Ignored) + { + b32 Sorted = True; + + for (u32 Inner = 0; + Inner < (Count-1); + ++Inner) + { + auto *KeyA = Keys+Inner; + auto *KeyB = Keys+Inner+1; + + if (*KeyA < *KeyB) + { + auto Temp = *KeyA; + *KeyA = *KeyB; + *KeyB = Temp; + Sorted = False; + } + } + + if (Sorted) break; + } + + return; +} + +link_internal void +BubbleSort_descending(sort_key_f32 *Keys, u32 Count) +{ + for (u32 Ignored = 0; + Ignored < Count; + ++Ignored) + { + b32 Sorted = True; + + for (u32 Inner = 0; + Inner < (Count-1); + ++Inner) + { + auto *KeyA = Keys+Inner; + auto *KeyB = Keys+Inner+1; + + if (*KeyA > *KeyB) + { + auto Temp = *KeyA; + *KeyA = *KeyB; + *KeyB = Temp; + Sorted = False; + } + } + + if (Sorted) break; + } + + return; +} link_internal void BubbleSort(sort_key_string *Keys, u32 Count) { @@ -91,3 +213,35 @@ BubbleSort(sort_key_string *Keys, u32 Count) return; } +link_internal void +BubbleSort_descending(sort_key_string *Keys, u32 Count) +{ + for (u32 Ignored = 0; + Ignored < Count; + ++Ignored) + { + b32 Sorted = True; + + for (u32 Inner = 0; + Inner < (Count-1); + ++Inner) + { + auto *KeyA = Keys+Inner; + auto *KeyB = Keys+Inner+1; + + if (*KeyA > *KeyB) + { + auto Temp = *KeyA; + *KeyA = *KeyB; + *KeyB = Temp; + Sorted = False; + } + } + + if (Sorted) break; + } + + return; +} + + diff --git a/generated/buffer_asset.h b/generated/buffer_asset.h index b268b5716..666096f38 100644 --- a/generated/buffer_asset.h +++ b/generated/buffer_asset.h @@ -1,5 +1,4 @@ -// src/engine/asset.h:194:0 - +// external/bonsai_stdlib/src/poof_functions.h:1435:0 struct asset_buffer { umm Count; @@ -7,20 +6,12 @@ struct asset_buffer }; link_internal asset_buffer -AssetBuffer( umm ElementCount, memory_arena* Memory) -{ - asset_buffer Result = {}; - - if (ElementCount) - { - Result.Start = Allocate( asset, Memory, ElementCount ); - Result.Count = ElementCount; - } - else - { - Warn("Attempted to allocate asset_buffer of 0 length."); - } +AssetBuffer( umm ElementCount, memory_arena* Memory); +link_internal asset_buffer +AssetBuffer( asset *Start, umm ElementCount) +{ + asset_buffer Result = {ElementCount, Start}; return Result; } @@ -67,6 +58,12 @@ GetPtr(asset_buffer *Buf, umm Index) return Result; } +link_inline asset * +TryGetPtr(asset_buffer *Buf, umm Index) +{ + return GetPtr(Buf, Index); +} + link_inline asset * Get(asset_buffer *Buf, umm Index) { @@ -74,4 +71,22 @@ Get(asset_buffer *Buf, umm Index) return Result; } +link_internal asset_buffer +AssetBuffer( umm ElementCount, memory_arena* Memory) +{ + asset_buffer Result = {}; + + if (ElementCount) + { + Result.Start = Allocate( asset, Memory, ElementCount ); + Result.Count = ElementCount; + } + else + { + Warn("Attempted to allocate asset_buffer of 0 length."); + } + + return Result; +} + diff --git a/generated/buffer_bitmap.h b/generated/buffer_bitmap.h index f6028d38a..cd01ccc8b 100644 --- a/generated/buffer_bitmap.h +++ b/generated/buffer_bitmap.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/bitmap.cpp:37:0 - +// external/bonsai_stdlib/src/poof_functions.h:1435:0 struct bitmap_buffer { umm Count; @@ -7,20 +6,12 @@ struct bitmap_buffer }; link_internal bitmap_buffer -BitmapBuffer( umm ElementCount, memory_arena* Memory) -{ - bitmap_buffer Result = {}; - - if (ElementCount) - { - Result.Start = Allocate( bitmap, Memory, ElementCount ); - Result.Count = ElementCount; - } - else - { - Warn("Attempted to allocate bitmap_buffer of 0 length."); - } +BitmapBuffer( umm ElementCount, memory_arena* Memory); +link_internal bitmap_buffer +BitmapBuffer( bitmap *Start, umm ElementCount) +{ + bitmap_buffer Result = {ElementCount, Start}; return Result; } @@ -67,6 +58,12 @@ GetPtr(bitmap_buffer *Buf, umm Index) return Result; } +link_inline bitmap * +TryGetPtr(bitmap_buffer *Buf, umm Index) +{ + return GetPtr(Buf, Index); +} + link_inline bitmap * Get(bitmap_buffer *Buf, umm Index) { @@ -74,4 +71,22 @@ Get(bitmap_buffer *Buf, umm Index) return Result; } +link_internal bitmap_buffer +BitmapBuffer( umm ElementCount, memory_arena* Memory) +{ + bitmap_buffer Result = {}; + + if (ElementCount) + { + Result.Start = Allocate( bitmap, Memory, ElementCount ); + Result.Count = ElementCount; + } + else + { + Warn("Attempted to allocate bitmap_buffer of 0 length."); + } + + return Result; +} + diff --git a/generated/buffer_bonsai_type_info.h b/generated/buffer_bonsai_type_info.h index a07edb7bb..c3fa2a2cd 100644 --- a/generated/buffer_bonsai_type_info.h +++ b/generated/buffer_bonsai_type_info.h @@ -1,5 +1,4 @@ -// src/engine/bonsai_type_info.h:34:0 - +// external/bonsai_stdlib/src/poof_functions.h:1435:0 struct bonsai_type_info_buffer { umm Count; @@ -7,20 +6,12 @@ struct bonsai_type_info_buffer }; link_internal bonsai_type_info_buffer -BonsaiTypeInfoBuffer( umm ElementCount, memory_arena* Memory) -{ - bonsai_type_info_buffer Result = {}; - - if (ElementCount) - { - Result.Start = Allocate( bonsai_type_info, Memory, ElementCount ); - Result.Count = ElementCount; - } - else - { - Warn("Attempted to allocate bonsai_type_info_buffer of 0 length."); - } +BonsaiTypeInfoBuffer( umm ElementCount, memory_arena* Memory); +link_internal bonsai_type_info_buffer +BonsaiTypeInfoBuffer( bonsai_type_info *Start, umm ElementCount) +{ + bonsai_type_info_buffer Result = {ElementCount, Start}; return Result; } @@ -67,6 +58,12 @@ GetPtr(bonsai_type_info_buffer *Buf, umm Index) return Result; } +link_inline bonsai_type_info * +TryGetPtr(bonsai_type_info_buffer *Buf, umm Index) +{ + return GetPtr(Buf, Index); +} + link_inline bonsai_type_info * Get(bonsai_type_info_buffer *Buf, umm Index) { @@ -74,4 +71,22 @@ Get(bonsai_type_info_buffer *Buf, umm Index) return Result; } +link_internal bonsai_type_info_buffer +BonsaiTypeInfoBuffer( umm ElementCount, memory_arena* Memory) +{ + bonsai_type_info_buffer Result = {}; + + if (ElementCount) + { + Result.Start = Allocate( bonsai_type_info, Memory, ElementCount ); + Result.Count = ElementCount; + } + else + { + Warn("Attempted to allocate bonsai_type_info_buffer of 0 length."); + } + + return Result; +} + diff --git a/generated/buffer_builder_tuple_cs_cs.h b/generated/buffer_builder_tuple_cs_cs.h index 186d047fb..fb8190b71 100644 --- a/generated/buffer_builder_tuple_cs_cs.h +++ b/generated/buffer_builder_tuple_cs_cs.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/counted_string.cpp:46:0 - +// external/bonsai_stdlib/src/poof_functions.h:714:0 struct tuple_cs_cs_buffer_builder { tuple_cs_cs_stream Chunks; diff --git a/generated/buffer_c_struct_u32.h b/generated/buffer_c_struct_u32.h new file mode 100644 index 000000000..f3774aef5 --- /dev/null +++ b/generated/buffer_c_struct_u32.h @@ -0,0 +1,19 @@ +// external/bonsai_stdlib/src/poof_functions.h:1404:0 +link_internal shader_uniform_buffer +ShaderUniformBuffer( u32 ElementCount, memory_arena* Memory) +{ + shader_uniform_buffer Result = {}; + + if (ElementCount) + { + Result.Start = Allocate( shader_uniform, Memory, ElementCount ); + Result.Count = ElementCount; + } + else + { + Warn("Attempted to allocate shader_uniform_buffer of 0 length."); + } + + return Result; +} + diff --git a/generated/buffer_c_struct_u64.h b/generated/buffer_c_struct_u64.h new file mode 100644 index 000000000..59b75d420 --- /dev/null +++ b/generated/buffer_c_struct_u64.h @@ -0,0 +1,19 @@ +// external/bonsai_stdlib/src/poof_functions.h:1404:0 +link_internal model_buffer +ModelBuffer( u64 ElementCount, memory_arena* Memory) +{ + model_buffer Result = {}; + + if (ElementCount) + { + Result.Start = Allocate( model, Memory, ElementCount ); + Result.Count = ElementCount; + } + else + { + Warn("Attempted to allocate model_buffer of 0 length."); + } + + return Result; +} + diff --git a/generated/buffer_c_token.h b/generated/buffer_c_token.h index d621a59d3..563853d48 100644 --- a/generated/buffer_c_token.h +++ b/generated/buffer_c_token.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/c_token.cpp:2:0 - +// external/bonsai_stdlib/src/poof_functions.h:1435:0 struct c_token_buffer { umm Count; @@ -7,20 +6,12 @@ struct c_token_buffer }; link_internal c_token_buffer -CTokenBuffer( umm ElementCount, memory_arena* Memory) -{ - c_token_buffer Result = {}; - - if (ElementCount) - { - Result.Start = Allocate( c_token, Memory, ElementCount ); - Result.Count = ElementCount; - } - else - { - Warn("Attempted to allocate c_token_buffer of 0 length."); - } +CTokenBuffer( umm ElementCount, memory_arena* Memory); +link_internal c_token_buffer +CTokenBuffer( c_token *Start, umm ElementCount) +{ + c_token_buffer Result = {ElementCount, Start}; return Result; } @@ -67,6 +58,12 @@ GetPtr(c_token_buffer *Buf, umm Index) return Result; } +link_inline c_token * +TryGetPtr(c_token_buffer *Buf, umm Index) +{ + return GetPtr(Buf, Index); +} + link_inline c_token * Get(c_token_buffer *Buf, umm Index) { @@ -74,4 +71,22 @@ Get(c_token_buffer *Buf, umm Index) return Result; } +link_internal c_token_buffer +CTokenBuffer( umm ElementCount, memory_arena* Memory) +{ + c_token_buffer Result = {}; + + if (ElementCount) + { + Result.Start = Allocate( c_token, Memory, ElementCount ); + Result.Count = ElementCount; + } + else + { + Warn("Attempted to allocate c_token_buffer of 0 length."); + } + + return Result; +} + diff --git a/generated/buffer_c_token_buffer.h b/generated/buffer_c_token_buffer.h index 451fb72dd..cfc5c0599 100644 --- a/generated/buffer_c_token_buffer.h +++ b/generated/buffer_c_token_buffer.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/c_token.cpp:5:0 - +// external/bonsai_stdlib/src/poof_functions.h:1435:0 struct c_token_buffer_buffer { umm Count; @@ -7,20 +6,12 @@ struct c_token_buffer_buffer }; link_internal c_token_buffer_buffer -CTokenBufferBuffer( umm ElementCount, memory_arena* Memory) -{ - c_token_buffer_buffer Result = {}; - - if (ElementCount) - { - Result.Start = Allocate( c_token_buffer, Memory, ElementCount ); - Result.Count = ElementCount; - } - else - { - Warn("Attempted to allocate c_token_buffer_buffer of 0 length."); - } +CTokenBufferBuffer( umm ElementCount, memory_arena* Memory); +link_internal c_token_buffer_buffer +CTokenBufferBuffer( c_token_buffer *Start, umm ElementCount) +{ + c_token_buffer_buffer Result = {ElementCount, Start}; return Result; } @@ -67,6 +58,12 @@ GetPtr(c_token_buffer_buffer *Buf, umm Index) return Result; } +link_inline c_token_buffer * +TryGetPtr(c_token_buffer_buffer *Buf, umm Index) +{ + return GetPtr(Buf, Index); +} + link_inline c_token_buffer * Get(c_token_buffer_buffer *Buf, umm Index) { @@ -74,4 +71,22 @@ Get(c_token_buffer_buffer *Buf, umm Index) return Result; } +link_internal c_token_buffer_buffer +CTokenBufferBuffer( umm ElementCount, memory_arena* Memory) +{ + c_token_buffer_buffer Result = {}; + + if (ElementCount) + { + Result.Start = Allocate( c_token_buffer, Memory, ElementCount ); + Result.Count = ElementCount; + } + else + { + Warn("Attempted to allocate c_token_buffer_buffer of 0 length."); + } + + return Result; +} + diff --git a/generated/buffer_counted_string.h b/generated/buffer_counted_string.h index 682f60305..23d78e61c 100644 --- a/generated/buffer_counted_string.h +++ b/generated/buffer_counted_string.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/counted_string.cpp:18:0 - +// external/bonsai_stdlib/src/poof_functions.h:1435:0 struct counted_string_buffer { umm Count; @@ -7,20 +6,12 @@ struct counted_string_buffer }; link_internal counted_string_buffer -CountedStringBuffer( umm ElementCount, memory_arena* Memory) -{ - counted_string_buffer Result = {}; - - if (ElementCount) - { - Result.Start = Allocate( counted_string, Memory, ElementCount ); - Result.Count = ElementCount; - } - else - { - Warn("Attempted to allocate counted_string_buffer of 0 length."); - } +CountedStringBuffer( umm ElementCount, memory_arena* Memory); +link_internal counted_string_buffer +CountedStringBuffer( counted_string *Start, umm ElementCount) +{ + counted_string_buffer Result = {ElementCount, Start}; return Result; } @@ -67,6 +58,12 @@ GetPtr(counted_string_buffer *Buf, umm Index) return Result; } +link_inline counted_string * +TryGetPtr(counted_string_buffer *Buf, umm Index) +{ + return GetPtr(Buf, Index); +} + link_inline counted_string * Get(counted_string_buffer *Buf, umm Index) { @@ -74,4 +71,22 @@ Get(counted_string_buffer *Buf, umm Index) return Result; } +link_internal counted_string_buffer +CountedStringBuffer( umm ElementCount, memory_arena* Memory) +{ + counted_string_buffer Result = {}; + + if (ElementCount) + { + Result.Start = Allocate( counted_string, Memory, ElementCount ); + Result.Count = ElementCount; + } + else + { + Warn("Attempted to allocate counted_string_buffer of 0 length."); + } + + return Result; +} + diff --git a/generated/buffer_file_traversal_node.h b/generated/buffer_file_traversal_node.h index e5c53a59b..94ea52184 100644 --- a/generated/buffer_file_traversal_node.h +++ b/generated/buffer_file_traversal_node.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/file.cpp:3:0 - +// external/bonsai_stdlib/src/poof_functions.h:1435:0 struct file_traversal_node_buffer { umm Count; @@ -7,20 +6,12 @@ struct file_traversal_node_buffer }; link_internal file_traversal_node_buffer -FileTraversalNodeBuffer( umm ElementCount, memory_arena* Memory) -{ - file_traversal_node_buffer Result = {}; - - if (ElementCount) - { - Result.Start = Allocate( file_traversal_node, Memory, ElementCount ); - Result.Count = ElementCount; - } - else - { - Warn("Attempted to allocate file_traversal_node_buffer of 0 length."); - } +FileTraversalNodeBuffer( umm ElementCount, memory_arena* Memory); +link_internal file_traversal_node_buffer +FileTraversalNodeBuffer( file_traversal_node *Start, umm ElementCount) +{ + file_traversal_node_buffer Result = {ElementCount, Start}; return Result; } @@ -67,6 +58,12 @@ GetPtr(file_traversal_node_buffer *Buf, umm Index) return Result; } +link_inline file_traversal_node * +TryGetPtr(file_traversal_node_buffer *Buf, umm Index) +{ + return GetPtr(Buf, Index); +} + link_inline file_traversal_node * Get(file_traversal_node_buffer *Buf, umm Index) { @@ -74,4 +71,22 @@ Get(file_traversal_node_buffer *Buf, umm Index) return Result; } +link_internal file_traversal_node_buffer +FileTraversalNodeBuffer( umm ElementCount, memory_arena* Memory) +{ + file_traversal_node_buffer Result = {}; + + if (ElementCount) + { + Result.Start = Allocate( file_traversal_node, Memory, ElementCount ); + Result.Count = ElementCount; + } + else + { + Warn("Attempted to allocate file_traversal_node_buffer of 0 length."); + } + + return Result; +} + diff --git a/generated/buffer_h_struct_u32.h b/generated/buffer_h_struct_u32.h new file mode 100644 index 000000000..9924c43c6 --- /dev/null +++ b/generated/buffer_h_struct_u32.h @@ -0,0 +1,73 @@ +// external/bonsai_stdlib/src/poof_functions.h:1328:0 +struct shader_uniform_buffer +{ + u32 Count; + shader_uniform *Start; poof(@array_length(Element->Count)) +}; + +link_internal shader_uniform_buffer +ShaderUniformBuffer( u32 ElementCount, memory_arena* Memory); + +link_internal shader_uniform_buffer +ShaderUniformBuffer( shader_uniform *Start, u32 ElementCount) +{ + shader_uniform_buffer Result = {ElementCount, Start}; + return Result; +} + +link_inline u32 +LastIndex(shader_uniform_buffer *Buf) +{ + u32 Result = Buf->Count > 0? Buf->Count-1 : 0; + return Result; +} + +link_inline u32 +ZerothIndex(shader_uniform_buffer *Buf) +{ + u32 Result = 0; + return Result; +} + +link_inline u32 +AtElements(shader_uniform_buffer *Buf) +{ + u32 Result = Buf->Count; + return Result; +} + +link_inline u32 +TotalElements(shader_uniform_buffer *Buf) +{ + u32 Result = Buf->Count; + return Result; +} + +link_inline u32 +CurrentCount(shader_uniform_buffer *Buf) +{ + u32 Result = Buf->Count; + return Result; +} + +link_inline shader_uniform * +GetPtr(shader_uniform_buffer *Buf, u32 Index) +{ + shader_uniform *Result = 0; + if (Index < Buf->Count) { Result = Buf->Start + Index; } + return Result; +} + +link_inline shader_uniform * +TryGetPtr(shader_uniform_buffer *Buf, u32 Index) +{ + return GetPtr(Buf, Index); +} + +link_inline shader_uniform * +Get(shader_uniform_buffer *Buf, u32 Index) +{ + shader_uniform *Result = GetPtr(Buf, Index); + return Result; +} + diff --git a/generated/buffer_is_marked_for_growth_untextured_3d_geometry_buffer.h b/generated/buffer_is_marked_for_growth_untextured_3d_geometry_buffer.h index 29665dca7..8f1f15494 100644 --- a/generated/buffer_is_marked_for_growth_untextured_3d_geometry_buffer.h +++ b/generated/buffer_is_marked_for_growth_untextured_3d_geometry_buffer.h @@ -1,5 +1,4 @@ -// src/engine/mesh.h:87:0 - +// src/engine/mesh.h:56:0 link_internal b32 BufferIsMarkedForGrowth(untextured_3d_geometry_buffer *Dest) { diff --git a/generated/buffer_model.h b/generated/buffer_model.h index bbd53b057..798f053ca 100644 --- a/generated/buffer_model.h +++ b/generated/buffer_model.h @@ -1,5 +1,4 @@ -// src/engine/model.h:88:0 - +// external/bonsai_stdlib/src/poof_functions.h:1428:0 struct model_buffer { u64 Count; @@ -7,20 +6,12 @@ struct model_buffer }; link_internal model_buffer -ModelBuffer( u64 ElementCount, memory_arena* Memory) -{ - model_buffer Result = {}; - - if (ElementCount) - { - Result.Start = Allocate( model, Memory, ElementCount ); - Result.Count = ElementCount; - } - else - { - Warn("Attempted to allocate model_buffer of 0 length."); - } +ModelBuffer( u64 ElementCount, memory_arena* Memory); +link_internal model_buffer +ModelBuffer( model *Start, u64 ElementCount) +{ + model_buffer Result = {ElementCount, Start}; return Result; } @@ -67,6 +58,12 @@ GetPtr(model_buffer *Buf, u64 Index) return Result; } +link_inline model * +TryGetPtr(model_buffer *Buf, u64 Index) +{ + return GetPtr(Buf, Index); +} + link_inline model * Get(model_buffer *Buf, u64 Index) { @@ -74,3 +71,4 @@ Get(model_buffer *Buf, u64 Index) return Result; } + diff --git a/generated/buffer_octree_node_ptr.h b/generated/buffer_octree_node_ptr.h new file mode 100644 index 000000000..21b04168a --- /dev/null +++ b/generated/buffer_octree_node_ptr.h @@ -0,0 +1,92 @@ +// external/bonsai_stdlib/src/poof_functions.h:1435:0 +struct octree_node_ptr_buffer +{ + umm Count; + octree_node_ptr *Start; poof(@array_length(Element->Count)) +}; + +link_internal octree_node_ptr_buffer +OctreeNodePtrBuffer( umm ElementCount, memory_arena* Memory); + +link_internal octree_node_ptr_buffer +OctreeNodePtrBuffer( octree_node_ptr *Start, umm ElementCount) +{ + octree_node_ptr_buffer Result = {ElementCount, Start}; + return Result; +} + +link_inline umm +LastIndex(octree_node_ptr_buffer *Buf) +{ + umm Result = Buf->Count > 0? Buf->Count-1 : 0; + return Result; +} + +link_inline umm +ZerothIndex(octree_node_ptr_buffer *Buf) +{ + umm Result = 0; + return Result; +} + +link_inline umm +AtElements(octree_node_ptr_buffer *Buf) +{ + umm Result = Buf->Count; + return Result; +} + +link_inline umm +TotalElements(octree_node_ptr_buffer *Buf) +{ + umm Result = Buf->Count; + return Result; +} + +link_inline umm +CurrentCount(octree_node_ptr_buffer *Buf) +{ + umm Result = Buf->Count; + return Result; +} + +link_inline octree_node_ptr * +GetPtr(octree_node_ptr_buffer *Buf, umm Index) +{ + octree_node_ptr *Result = 0; + if (Index < Buf->Count) { Result = Buf->Start + Index; } + return Result; +} + +link_inline octree_node_ptr * +TryGetPtr(octree_node_ptr_buffer *Buf, umm Index) +{ + return GetPtr(Buf, Index); +} + +link_inline octree_node_ptr * +Get(octree_node_ptr_buffer *Buf, umm Index) +{ + octree_node_ptr *Result = GetPtr(Buf, Index); + return Result; +} + +link_internal octree_node_ptr_buffer +OctreeNodePtrBuffer( umm ElementCount, memory_arena* Memory) +{ + octree_node_ptr_buffer Result = {}; + + if (ElementCount) + { + Result.Start = Allocate( octree_node_ptr, Memory, ElementCount ); + Result.Count = ElementCount; + } + else + { + Warn("Attempted to allocate octree_node_ptr_buffer of 0 length."); + } + + return Result; +} + + diff --git a/generated/buffer_rect3i.h b/generated/buffer_rect3i.h index 9e8296b3a..6b066377b 100644 --- a/generated/buffer_rect3i.h +++ b/generated/buffer_rect3i.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/rect.cpp:1:0 - +// external/bonsai_stdlib/src/poof_functions.h:1435:0 struct rect3i_buffer { umm Count; @@ -7,20 +6,12 @@ struct rect3i_buffer }; link_internal rect3i_buffer -Rect3iBuffer( umm ElementCount, memory_arena* Memory) -{ - rect3i_buffer Result = {}; - - if (ElementCount) - { - Result.Start = Allocate( rect3i, Memory, ElementCount ); - Result.Count = ElementCount; - } - else - { - Warn("Attempted to allocate rect3i_buffer of 0 length."); - } +Rect3iBuffer( umm ElementCount, memory_arena* Memory); +link_internal rect3i_buffer +Rect3iBuffer( rect3i *Start, umm ElementCount) +{ + rect3i_buffer Result = {ElementCount, Start}; return Result; } @@ -67,6 +58,12 @@ GetPtr(rect3i_buffer *Buf, umm Index) return Result; } +link_inline rect3i * +TryGetPtr(rect3i_buffer *Buf, umm Index) +{ + return GetPtr(Buf, Index); +} + link_inline rect3i * Get(rect3i_buffer *Buf, umm Index) { @@ -74,4 +71,22 @@ Get(rect3i_buffer *Buf, umm Index) return Result; } +link_internal rect3i_buffer +Rect3iBuffer( umm ElementCount, memory_arena* Memory) +{ + rect3i_buffer Result = {}; + + if (ElementCount) + { + Result.Start = Allocate( rect3i, Memory, ElementCount ); + Result.Count = ElementCount; + } + else + { + Warn("Attempted to allocate rect3i_buffer of 0 length."); + } + + return Result; +} + diff --git a/generated/buffer_sort_key.h b/generated/buffer_sort_key.h new file mode 100644 index 000000000..d70221fa3 --- /dev/null +++ b/generated/buffer_sort_key.h @@ -0,0 +1,92 @@ +// external/bonsai_stdlib/src/poof_functions.h:1435:0 +struct sort_key_buffer +{ + umm Count; + sort_key *Start; poof(@array_length(Element->Count)) +}; + +link_internal sort_key_buffer +SortKeyBuffer( umm ElementCount, memory_arena* Memory); + +link_internal sort_key_buffer +SortKeyBuffer( sort_key *Start, umm ElementCount) +{ + sort_key_buffer Result = {ElementCount, Start}; + return Result; +} + +link_inline umm +LastIndex(sort_key_buffer *Buf) +{ + umm Result = Buf->Count > 0? Buf->Count-1 : 0; + return Result; +} + +link_inline umm +ZerothIndex(sort_key_buffer *Buf) +{ + umm Result = 0; + return Result; +} + +link_inline umm +AtElements(sort_key_buffer *Buf) +{ + umm Result = Buf->Count; + return Result; +} + +link_inline umm +TotalElements(sort_key_buffer *Buf) +{ + umm Result = Buf->Count; + return Result; +} + +link_inline umm +CurrentCount(sort_key_buffer *Buf) +{ + umm Result = Buf->Count; + return Result; +} + +link_inline sort_key * +GetPtr(sort_key_buffer *Buf, umm Index) +{ + sort_key *Result = 0; + if (Index < Buf->Count) { Result = Buf->Start + Index; } + return Result; +} + +link_inline sort_key * +TryGetPtr(sort_key_buffer *Buf, umm Index) +{ + return GetPtr(Buf, Index); +} + +link_inline sort_key * +Get(sort_key_buffer *Buf, umm Index) +{ + sort_key *Result = GetPtr(Buf, Index); + return Result; +} + +link_internal sort_key_buffer +SortKeyBuffer( umm ElementCount, memory_arena* Memory) +{ + sort_key_buffer Result = {}; + + if (ElementCount) + { + Result.Start = Allocate( sort_key, Memory, ElementCount ); + Result.Count = ElementCount; + } + else + { + Warn("Attempted to allocate sort_key_buffer of 0 length."); + } + + return Result; +} + + diff --git a/generated/buffer_standing_spot.h b/generated/buffer_standing_spot.h index 9183be470..31b74057b 100644 --- a/generated/buffer_standing_spot.h +++ b/generated/buffer_standing_spot.h @@ -1,5 +1,4 @@ -// src/engine/world_chunk.h:566:0 - +// external/bonsai_stdlib/src/poof_functions.h:1435:0 struct standing_spot_buffer { umm Count; @@ -7,20 +6,12 @@ struct standing_spot_buffer }; link_internal standing_spot_buffer -StandingSpotBuffer( umm ElementCount, memory_arena* Memory) -{ - standing_spot_buffer Result = {}; - - if (ElementCount) - { - Result.Start = Allocate( standing_spot, Memory, ElementCount ); - Result.Count = ElementCount; - } - else - { - Warn("Attempted to allocate standing_spot_buffer of 0 length."); - } +StandingSpotBuffer( umm ElementCount, memory_arena* Memory); +link_internal standing_spot_buffer +StandingSpotBuffer( standing_spot *Start, umm ElementCount) +{ + standing_spot_buffer Result = {ElementCount, Start}; return Result; } @@ -67,6 +58,12 @@ GetPtr(standing_spot_buffer *Buf, umm Index) return Result; } +link_inline standing_spot * +TryGetPtr(standing_spot_buffer *Buf, umm Index) +{ + return GetPtr(Buf, Index); +} + link_inline standing_spot * Get(standing_spot_buffer *Buf, umm Index) { @@ -74,4 +71,22 @@ Get(standing_spot_buffer *Buf, umm Index) return Result; } +link_internal standing_spot_buffer +StandingSpotBuffer( umm ElementCount, memory_arena* Memory) +{ + standing_spot_buffer Result = {}; + + if (ElementCount) + { + Result.Start = Allocate( standing_spot, Memory, ElementCount ); + Result.Count = ElementCount; + } + else + { + Warn("Attempted to allocate standing_spot_buffer of 0 length."); + } + + return Result; +} + diff --git a/generated/buffer_thread_main_callback_type.h b/generated/buffer_thread_main_callback_type.h index c2df75b22..672c9660c 100644 --- a/generated/buffer_thread_main_callback_type.h +++ b/generated/buffer_thread_main_callback_type.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/thread.cpp:1:0 - +// external/bonsai_stdlib/src/poof_functions.h:1435:0 struct thread_main_callback_type_buffer { umm Count; @@ -7,20 +6,12 @@ struct thread_main_callback_type_buffer }; link_internal thread_main_callback_type_buffer -ThreadMainCallbackTypeBuffer( umm ElementCount, memory_arena* Memory) -{ - thread_main_callback_type_buffer Result = {}; - - if (ElementCount) - { - Result.Start = Allocate( thread_main_callback_type, Memory, ElementCount ); - Result.Count = ElementCount; - } - else - { - Warn("Attempted to allocate thread_main_callback_type_buffer of 0 length."); - } +ThreadMainCallbackTypeBuffer( umm ElementCount, memory_arena* Memory); +link_internal thread_main_callback_type_buffer +ThreadMainCallbackTypeBuffer( thread_main_callback_type *Start, umm ElementCount) +{ + thread_main_callback_type_buffer Result = {ElementCount, Start}; return Result; } @@ -67,6 +58,12 @@ GetPtr(thread_main_callback_type_buffer *Buf, umm Index) return Result; } +link_inline thread_main_callback_type * +TryGetPtr(thread_main_callback_type_buffer *Buf, umm Index) +{ + return GetPtr(Buf, Index); +} + link_inline thread_main_callback_type * Get(thread_main_callback_type_buffer *Buf, umm Index) { @@ -74,4 +71,22 @@ Get(thread_main_callback_type_buffer *Buf, umm Index) return Result; } +link_internal thread_main_callback_type_buffer +ThreadMainCallbackTypeBuffer( umm ElementCount, memory_arena* Memory) +{ + thread_main_callback_type_buffer Result = {}; + + if (ElementCount) + { + Result.Start = Allocate( thread_main_callback_type, Memory, ElementCount ); + Result.Count = ElementCount; + } + else + { + Warn("Attempted to allocate thread_main_callback_type_buffer of 0 length."); + } + + return Result; +} + diff --git a/generated/buffer_tile_ruleset.h b/generated/buffer_tile_ruleset.h index 13739dec7..c9c6ce0cd 100644 --- a/generated/buffer_tile_ruleset.h +++ b/generated/buffer_tile_ruleset.h @@ -1,5 +1,4 @@ -// src/engine/voxel_synthesis.h:65:0 - +// external/bonsai_stdlib/src/poof_functions.h:1435:0 struct tile_ruleset_buffer { umm Count; @@ -7,20 +6,12 @@ struct tile_ruleset_buffer }; link_internal tile_ruleset_buffer -TileRulesetBuffer( umm ElementCount, memory_arena* Memory) -{ - tile_ruleset_buffer Result = {}; - - if (ElementCount) - { - Result.Start = Allocate( tile_ruleset, Memory, ElementCount ); - Result.Count = ElementCount; - } - else - { - Warn("Attempted to allocate tile_ruleset_buffer of 0 length."); - } +TileRulesetBuffer( umm ElementCount, memory_arena* Memory); +link_internal tile_ruleset_buffer +TileRulesetBuffer( tile_ruleset *Start, umm ElementCount) +{ + tile_ruleset_buffer Result = {ElementCount, Start}; return Result; } @@ -67,6 +58,12 @@ GetPtr(tile_ruleset_buffer *Buf, umm Index) return Result; } +link_inline tile_ruleset * +TryGetPtr(tile_ruleset_buffer *Buf, umm Index) +{ + return GetPtr(Buf, Index); +} + link_inline tile_ruleset * Get(tile_ruleset_buffer *Buf, umm Index) { @@ -74,4 +71,22 @@ Get(tile_ruleset_buffer *Buf, umm Index) return Result; } +link_internal tile_ruleset_buffer +TileRulesetBuffer( umm ElementCount, memory_arena* Memory) +{ + tile_ruleset_buffer Result = {}; + + if (ElementCount) + { + Result.Start = Allocate( tile_ruleset, Memory, ElementCount ); + Result.Count = ElementCount; + } + else + { + Warn("Attempted to allocate tile_ruleset_buffer of 0 length."); + } + + return Result; +} + diff --git a/generated/buffer_u32.h b/generated/buffer_u32.h index 9038f870d..d9438e16c 100644 --- a/generated/buffer_u32.h +++ b/generated/buffer_u32.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/binary_parser.cpp:3:0 - +// external/bonsai_stdlib/src/poof_functions.h:1435:0 struct u32_buffer { umm Count; @@ -7,20 +6,12 @@ struct u32_buffer }; link_internal u32_buffer -U32Buffer( umm ElementCount, memory_arena* Memory) -{ - u32_buffer Result = {}; - - if (ElementCount) - { - Result.Start = Allocate( u32, Memory, ElementCount ); - Result.Count = ElementCount; - } - else - { - Warn("Attempted to allocate u32_buffer of 0 length."); - } +U32Buffer( umm ElementCount, memory_arena* Memory); +link_internal u32_buffer +U32Buffer( u32 *Start, umm ElementCount) +{ + u32_buffer Result = {ElementCount, Start}; return Result; } @@ -67,6 +58,12 @@ GetPtr(u32_buffer *Buf, umm Index) return Result; } +link_inline u32 * +TryGetPtr(u32_buffer *Buf, umm Index) +{ + return GetPtr(Buf, Index); +} + link_inline u32 * Get(u32_buffer *Buf, umm Index) { @@ -74,4 +71,22 @@ Get(u32_buffer *Buf, umm Index) return Result; } +link_internal u32_buffer +U32Buffer( umm ElementCount, memory_arena* Memory) +{ + u32_buffer Result = {}; + + if (ElementCount) + { + Result.Start = Allocate( u32, Memory, ElementCount ); + Result.Count = ElementCount; + } + else + { + Warn("Attempted to allocate u32_buffer of 0 length."); + } + + return Result; +} + diff --git a/generated/buffer_u64.h b/generated/buffer_u64.h index 926de5005..de905094d 100644 --- a/generated/buffer_u64.h +++ b/generated/buffer_u64.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/binary_parser.cpp:23:0 - +// external/bonsai_stdlib/src/poof_functions.h:1435:0 struct u64_buffer { umm Count; @@ -7,20 +6,12 @@ struct u64_buffer }; link_internal u64_buffer -U64Buffer( umm ElementCount, memory_arena* Memory) -{ - u64_buffer Result = {}; - - if (ElementCount) - { - Result.Start = Allocate( u64, Memory, ElementCount ); - Result.Count = ElementCount; - } - else - { - Warn("Attempted to allocate u64_buffer of 0 length."); - } +U64Buffer( umm ElementCount, memory_arena* Memory); +link_internal u64_buffer +U64Buffer( u64 *Start, umm ElementCount) +{ + u64_buffer Result = {ElementCount, Start}; return Result; } @@ -67,6 +58,12 @@ GetPtr(u64_buffer *Buf, umm Index) return Result; } +link_inline u64 * +TryGetPtr(u64_buffer *Buf, umm Index) +{ + return GetPtr(Buf, Index); +} + link_inline u64 * Get(u64_buffer *Buf, umm Index) { @@ -74,4 +71,22 @@ Get(u64_buffer *Buf, umm Index) return Result; } +link_internal u64_buffer +U64Buffer( umm ElementCount, memory_arena* Memory) +{ + u64_buffer Result = {}; + + if (ElementCount) + { + Result.Start = Allocate( u64, Memory, ElementCount ); + Result.Count = ElementCount; + } + else + { + Warn("Attempted to allocate u64_buffer of 0 length."); + } + + return Result; +} + diff --git a/generated/buffer_ui_toggle_button_handle.h b/generated/buffer_ui_toggle_button_handle.h index a8759e243..ebd0fc195 100644 --- a/generated/buffer_ui_toggle_button_handle.h +++ b/generated/buffer_ui_toggle_button_handle.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/ui/ui.cpp:4:0 - +// external/bonsai_stdlib/src/poof_functions.h:1435:0 struct ui_toggle_button_handle_buffer { umm Count; @@ -7,20 +6,12 @@ struct ui_toggle_button_handle_buffer }; link_internal ui_toggle_button_handle_buffer -UiToggleButtonHandleBuffer( umm ElementCount, memory_arena* Memory) -{ - ui_toggle_button_handle_buffer Result = {}; - - if (ElementCount) - { - Result.Start = Allocate( ui_toggle_button_handle, Memory, ElementCount ); - Result.Count = ElementCount; - } - else - { - Warn("Attempted to allocate ui_toggle_button_handle_buffer of 0 length."); - } +UiToggleButtonHandleBuffer( umm ElementCount, memory_arena* Memory); +link_internal ui_toggle_button_handle_buffer +UiToggleButtonHandleBuffer( ui_toggle_button_handle *Start, umm ElementCount) +{ + ui_toggle_button_handle_buffer Result = {ElementCount, Start}; return Result; } @@ -67,6 +58,12 @@ GetPtr(ui_toggle_button_handle_buffer *Buf, umm Index) return Result; } +link_inline ui_toggle_button_handle * +TryGetPtr(ui_toggle_button_handle_buffer *Buf, umm Index) +{ + return GetPtr(Buf, Index); +} + link_inline ui_toggle_button_handle * Get(ui_toggle_button_handle_buffer *Buf, umm Index) { @@ -74,4 +71,22 @@ Get(ui_toggle_button_handle_buffer *Buf, umm Index) return Result; } +link_internal ui_toggle_button_handle_buffer +UiToggleButtonHandleBuffer( umm ElementCount, memory_arena* Memory) +{ + ui_toggle_button_handle_buffer Result = {}; + + if (ElementCount) + { + Result.Start = Allocate( ui_toggle_button_handle, Memory, ElementCount ); + Result.Count = ElementCount; + } + else + { + Warn("Attempted to allocate ui_toggle_button_handle_buffer of 0 length."); + } + + return Result; +} + diff --git a/generated/buffer_v3i.h b/generated/buffer_v3i.h index e8ee9cb79..d78d0a5e9 100644 --- a/generated/buffer_v3i.h +++ b/generated/buffer_v3i.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/vector.cpp:2:0 - +// external/bonsai_stdlib/src/poof_functions.h:1435:0 struct v3i_buffer { umm Count; @@ -7,20 +6,12 @@ struct v3i_buffer }; link_internal v3i_buffer -V3iBuffer( umm ElementCount, memory_arena* Memory) -{ - v3i_buffer Result = {}; - - if (ElementCount) - { - Result.Start = Allocate( v3i, Memory, ElementCount ); - Result.Count = ElementCount; - } - else - { - Warn("Attempted to allocate v3i_buffer of 0 length."); - } +V3iBuffer( umm ElementCount, memory_arena* Memory); +link_internal v3i_buffer +V3iBuffer( v3i *Start, umm ElementCount) +{ + v3i_buffer Result = {ElementCount, Start}; return Result; } @@ -67,6 +58,12 @@ GetPtr(v3i_buffer *Buf, umm Index) return Result; } +link_inline v3i * +TryGetPtr(v3i_buffer *Buf, umm Index) +{ + return GetPtr(Buf, Index); +} + link_inline v3i * Get(v3i_buffer *Buf, umm Index) { @@ -74,4 +71,22 @@ Get(v3i_buffer *Buf, umm Index) return Result; } +link_internal v3i_buffer +V3iBuffer( umm ElementCount, memory_arena* Memory) +{ + v3i_buffer Result = {}; + + if (ElementCount) + { + Result.Start = Allocate( v3i, Memory, ElementCount ); + Result.Count = ElementCount; + } + else + { + Warn("Attempted to allocate v3i_buffer of 0 length."); + } + + return Result; +} + diff --git a/generated/buffer_voxel_synth_tile.h b/generated/buffer_voxel_synth_tile.h index 283c551a0..dce5c8860 100644 --- a/generated/buffer_voxel_synth_tile.h +++ b/generated/buffer_voxel_synth_tile.h @@ -1,5 +1,4 @@ -// src/engine/voxel_synthesis.h:85:0 - +// external/bonsai_stdlib/src/poof_functions.h:1435:0 struct voxel_synth_tile_buffer { umm Count; @@ -7,20 +6,12 @@ struct voxel_synth_tile_buffer }; link_internal voxel_synth_tile_buffer -VoxelSynthTileBuffer( umm ElementCount, memory_arena* Memory) -{ - voxel_synth_tile_buffer Result = {}; - - if (ElementCount) - { - Result.Start = Allocate( voxel_synth_tile, Memory, ElementCount ); - Result.Count = ElementCount; - } - else - { - Warn("Attempted to allocate voxel_synth_tile_buffer of 0 length."); - } +VoxelSynthTileBuffer( umm ElementCount, memory_arena* Memory); +link_internal voxel_synth_tile_buffer +VoxelSynthTileBuffer( voxel_synth_tile *Start, umm ElementCount) +{ + voxel_synth_tile_buffer Result = {ElementCount, Start}; return Result; } @@ -67,6 +58,12 @@ GetPtr(voxel_synth_tile_buffer *Buf, umm Index) return Result; } +link_inline voxel_synth_tile * +TryGetPtr(voxel_synth_tile_buffer *Buf, umm Index) +{ + return GetPtr(Buf, Index); +} + link_inline voxel_synth_tile * Get(voxel_synth_tile_buffer *Buf, umm Index) { @@ -74,4 +71,22 @@ Get(voxel_synth_tile_buffer *Buf, umm Index) return Result; } +link_internal voxel_synth_tile_buffer +VoxelSynthTileBuffer( umm ElementCount, memory_arena* Memory) +{ + voxel_synth_tile_buffer Result = {}; + + if (ElementCount) + { + Result.Start = Allocate( voxel_synth_tile, Memory, ElementCount ); + Result.Count = ElementCount; + } + else + { + Warn("Attempted to allocate voxel_synth_tile_buffer of 0 length."); + } + + return Result; +} + diff --git a/generated/buffer_world_chunk_ptr.h b/generated/buffer_world_chunk_ptr.h index 142c1de5d..ebb8971bc 100644 --- a/generated/buffer_world_chunk_ptr.h +++ b/generated/buffer_world_chunk_ptr.h @@ -1,5 +1,4 @@ -// src/engine/world_chunk.h:459:0 - +// external/bonsai_stdlib/src/poof_functions.h:1435:0 struct world_chunk_ptr_buffer { umm Count; @@ -7,20 +6,12 @@ struct world_chunk_ptr_buffer }; link_internal world_chunk_ptr_buffer -WorldChunkPtrBuffer( umm ElementCount, memory_arena* Memory) -{ - world_chunk_ptr_buffer Result = {}; - - if (ElementCount) - { - Result.Start = Allocate( world_chunk_ptr, Memory, ElementCount ); - Result.Count = ElementCount; - } - else - { - Warn("Attempted to allocate world_chunk_ptr_buffer of 0 length."); - } +WorldChunkPtrBuffer( umm ElementCount, memory_arena* Memory); +link_internal world_chunk_ptr_buffer +WorldChunkPtrBuffer( world_chunk_ptr *Start, umm ElementCount) +{ + world_chunk_ptr_buffer Result = {ElementCount, Start}; return Result; } @@ -67,6 +58,12 @@ GetPtr(world_chunk_ptr_buffer *Buf, umm Index) return Result; } +link_inline world_chunk_ptr * +TryGetPtr(world_chunk_ptr_buffer *Buf, umm Index) +{ + return GetPtr(Buf, Index); +} + link_inline world_chunk_ptr * Get(world_chunk_ptr_buffer *Buf, umm Index) { @@ -74,4 +71,22 @@ Get(world_chunk_ptr_buffer *Buf, umm Index) return Result; } +link_internal world_chunk_ptr_buffer +WorldChunkPtrBuffer( umm ElementCount, memory_arena* Memory) +{ + world_chunk_ptr_buffer Result = {}; + + if (ElementCount) + { + Result.Start = Allocate( world_chunk_ptr, Memory, ElementCount ); + Result.Count = ElementCount; + } + else + { + Warn("Attempted to allocate world_chunk_ptr_buffer of 0 length."); + } + + return Result; +} + 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 index 82935ed23..197c96aff 100644 --- 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 @@ -1,5 +1,4 @@ -// src/engine/mesh.h:611:0 - +// src/engine/mesh.h:555:0 // // Rotate, Scale and Offset // 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 index f8f3aa9d0..f907caf78 100644 --- 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 @@ -1,5 +1,4 @@ -// src/engine/mesh.h:613:0 - +// src/engine/mesh.h:555:0 // // Rotate, Scale and Offset // 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 index 873bf5c64..d58994418 100644 --- 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 @@ -1,5 +1,4 @@ -// src/engine/mesh.h:625:0 - +// src/engine/mesh.h:398:0 // // Rotate, Scale and Offset // 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 index 6177fea27..55394e13e 100644 --- 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 @@ -1,5 +1,4 @@ -// src/engine/mesh.h:627:0 - +// src/engine/mesh.h:398:0 // // Rotate, Scale and Offset // diff --git a/generated/copy_normal_buffer_v3_u8_v3.h b/generated/copy_normal_buffer_v3_u8_v3.h index ac245c5d7..7b04fa18a 100644 --- a/generated/copy_normal_buffer_v3_u8_v3.h +++ b/generated/copy_normal_buffer_v3_u8_v3.h @@ -1,5 +1,4 @@ -// src/engine/mesh.h:326:0 - +// src/engine/mesh.h:264:0 link_inline void CopyNormalBuffer( v3_u8 *Dest, v3 *Src, u32 NumVerts, Quaternion Rot) { diff --git a/generated/copy_normal_buffer_v3_u8_v3_u8.h b/generated/copy_normal_buffer_v3_u8_v3_u8.h index b0a31ec6a..ebcefc14e 100644 --- a/generated/copy_normal_buffer_v3_u8_v3_u8.h +++ b/generated/copy_normal_buffer_v3_u8_v3_u8.h @@ -1,5 +1,4 @@ -// src/engine/mesh.h:324:0 - +// src/engine/mesh.h:264:0 link_inline void CopyNormalBuffer( v3_u8 *Dest, v3_u8 *Src, u32 NumVerts, Quaternion Rot) { diff --git a/generated/copy_normal_buffer_v3_v3.h b/generated/copy_normal_buffer_v3_v3.h index a52692eee..00a4ba65d 100644 --- a/generated/copy_normal_buffer_v3_v3.h +++ b/generated/copy_normal_buffer_v3_v3.h @@ -1,5 +1,4 @@ -// src/engine/mesh.h:328:0 - +// src/engine/mesh.h:264:0 link_inline void CopyNormalBuffer( v3 *Dest, v3 *Src, u32 NumVerts, Quaternion Rot) { diff --git a/generated/copy_normal_buffer_v3_v3_u8.h b/generated/copy_normal_buffer_v3_v3_u8.h index 82c2b95fb..39bfc40da 100644 --- a/generated/copy_normal_buffer_v3_v3_u8.h +++ b/generated/copy_normal_buffer_v3_v3_u8.h @@ -1,5 +1,4 @@ -// src/engine/mesh.h:330:0 - +// src/engine/mesh.h:264:0 link_inline void CopyNormalBuffer( v3 *Dest, v3_u8 *Src, u32 NumVerts, Quaternion Rot) { diff --git a/generated/copy_vertex_buffer_v3_u8_v3.h b/generated/copy_vertex_buffer_v3_u8_v3.h index e07572313..d618fbb9a 100644 --- a/generated/copy_vertex_buffer_v3_u8_v3.h +++ b/generated/copy_vertex_buffer_v3_u8_v3.h @@ -1,5 +1,4 @@ -// src/engine/mesh.h:317:0 - +// src/engine/mesh.h:148:0 // // Offset, Scale, Rotate // @@ -20,9 +19,9 @@ CopyVertexBuffer( v3_u8 *Dest, v3 *Src, u32 NumVerts, v3 Offset, v3 Scale, Quate auto Src1 = Rotate(Src[VertIndex + 1], Rot); auto Src2 = Rotate(Src[VertIndex + 2], Rot); - f32_reg Vert0; - f32_reg Vert1; - f32_reg Vert2; + f32_4x Vert0; + f32_4x Vert1; + f32_4x 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); @@ -32,9 +31,9 @@ CopyVertexBuffer( v3_u8 *Dest, v3 *Src, u32 NumVerts, v3 Offset, v3 Scale, Quate 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]) }}; + v3_u8 Result0 = {{ u8(Vert0.E[0]), u8(Vert0.E[1]), u8(Vert0.E[2]) }}; + v3_u8 Result1 = {{ u8(Vert1.E[0]), u8(Vert1.E[1]), u8(Vert1.E[2]) }}; + v3_u8 Result2 = {{ u8(Vert2.E[0]), u8(Vert2.E[1]), u8(Vert2.E[2]) }}; Dest[0] = Result0; Dest[1] = Result1; @@ -63,9 +62,9 @@ CopyVertexBuffer( v3_u8 *Dest, v3 *Src, u32 NumVerts, v3 Offset, v3 Scale ) auto Src1 = Src[VertIndex + 1]; auto Src2 = Src[VertIndex + 2]; - f32_reg Vert0; - f32_reg Vert1; - f32_reg Vert2; + f32_4x Vert0; + f32_4x Vert1; + f32_4x 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); @@ -75,9 +74,9 @@ CopyVertexBuffer( v3_u8 *Dest, v3 *Src, u32 NumVerts, v3 Offset, v3 Scale ) 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]) }}; + v3_u8 Result0 = {{ u8(Vert0.E[0]), u8(Vert0.E[1]), u8(Vert0.E[2]) }}; + v3_u8 Result1 = {{ u8(Vert1.E[0]), u8(Vert1.E[1]), u8(Vert1.E[2]) }}; + v3_u8 Result2 = {{ u8(Vert2.E[0]), u8(Vert2.E[1]), u8(Vert2.E[2]) }}; Dest[0] = Result0; Dest[1] = Result1; diff --git a/generated/copy_vertex_buffer_v3_u8_v3_u8.h b/generated/copy_vertex_buffer_v3_u8_v3_u8.h index 27c94ada2..fb29e8b25 100644 --- a/generated/copy_vertex_buffer_v3_u8_v3_u8.h +++ b/generated/copy_vertex_buffer_v3_u8_v3_u8.h @@ -1,5 +1,4 @@ -// src/engine/mesh.h:315:0 - +// src/engine/mesh.h:148:0 // // Offset, Scale, Rotate // @@ -20,9 +19,9 @@ CopyVertexBuffer( v3_u8 *Dest, v3_u8 *Src, u32 NumVerts, v3 Offset, v3 Scale, Qu auto Src1 = Rotate(Src[VertIndex + 1], Rot); auto Src2 = Rotate(Src[VertIndex + 2], Rot); - f32_reg Vert0; - f32_reg Vert1; - f32_reg Vert2; + f32_4x Vert0; + f32_4x Vert1; + f32_4x 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); @@ -32,9 +31,9 @@ CopyVertexBuffer( v3_u8 *Dest, v3_u8 *Src, u32 NumVerts, v3 Offset, v3 Scale, Qu 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]) }}; + v3_u8 Result0 = {{ u8(Vert0.E[0]), u8(Vert0.E[1]), u8(Vert0.E[2]) }}; + v3_u8 Result1 = {{ u8(Vert1.E[0]), u8(Vert1.E[1]), u8(Vert1.E[2]) }}; + v3_u8 Result2 = {{ u8(Vert2.E[0]), u8(Vert2.E[1]), u8(Vert2.E[2]) }}; Dest[0] = Result0; Dest[1] = Result1; @@ -63,9 +62,9 @@ CopyVertexBuffer( v3_u8 *Dest, v3_u8 *Src, u32 NumVerts, v3 Offset, v3 Scale ) auto Src1 = Src[VertIndex + 1]; auto Src2 = Src[VertIndex + 2]; - f32_reg Vert0; - f32_reg Vert1; - f32_reg Vert2; + f32_4x Vert0; + f32_4x Vert1; + f32_4x 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); @@ -75,9 +74,9 @@ CopyVertexBuffer( v3_u8 *Dest, v3_u8 *Src, u32 NumVerts, v3 Offset, v3 Scale ) 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]) }}; + v3_u8 Result0 = {{ u8(Vert0.E[0]), u8(Vert0.E[1]), u8(Vert0.E[2]) }}; + v3_u8 Result1 = {{ u8(Vert1.E[0]), u8(Vert1.E[1]), u8(Vert1.E[2]) }}; + v3_u8 Result2 = {{ u8(Vert2.E[0]), u8(Vert2.E[1]), u8(Vert2.E[2]) }}; Dest[0] = Result0; Dest[1] = Result1; diff --git a/generated/copy_vertex_buffer_v3_v3.h b/generated/copy_vertex_buffer_v3_v3.h index 793a09f2a..385c71b1d 100644 --- a/generated/copy_vertex_buffer_v3_v3.h +++ b/generated/copy_vertex_buffer_v3_v3.h @@ -1,5 +1,4 @@ -// src/engine/mesh.h:319:0 - +// src/engine/mesh.h:148:0 // // Offset, Scale, Rotate // @@ -20,9 +19,9 @@ CopyVertexBuffer( v3 *Dest, v3 *Src, u32 NumVerts, v3 Offset, v3 Scale, Quaterni auto Src1 = Rotate(Src[VertIndex + 1], Rot); auto Src2 = Rotate(Src[VertIndex + 2], Rot); - f32_reg Vert0; - f32_reg Vert1; - f32_reg Vert2; + f32_4x Vert0; + f32_4x Vert1; + f32_4x 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); @@ -32,9 +31,9 @@ CopyVertexBuffer( v3 *Dest, v3 *Src, u32 NumVerts, v3 Offset, v3 Scale, Quaterni 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]) }}; + v3 Result0 = {{ f32(Vert0.E[0]), f32(Vert0.E[1]), f32(Vert0.E[2]) }}; + v3 Result1 = {{ f32(Vert1.E[0]), f32(Vert1.E[1]), f32(Vert1.E[2]) }}; + v3 Result2 = {{ f32(Vert2.E[0]), f32(Vert2.E[1]), f32(Vert2.E[2]) }}; Dest[0] = Result0; Dest[1] = Result1; @@ -63,9 +62,9 @@ CopyVertexBuffer( v3 *Dest, v3 *Src, u32 NumVerts, v3 Offset, v3 Scale ) auto Src1 = Src[VertIndex + 1]; auto Src2 = Src[VertIndex + 2]; - f32_reg Vert0; - f32_reg Vert1; - f32_reg Vert2; + f32_4x Vert0; + f32_4x Vert1; + f32_4x 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); @@ -75,9 +74,9 @@ CopyVertexBuffer( v3 *Dest, v3 *Src, u32 NumVerts, v3 Offset, v3 Scale ) 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]) }}; + v3 Result0 = {{ f32(Vert0.E[0]), f32(Vert0.E[1]), f32(Vert0.E[2]) }}; + v3 Result1 = {{ f32(Vert1.E[0]), f32(Vert1.E[1]), f32(Vert1.E[2]) }}; + v3 Result2 = {{ f32(Vert2.E[0]), f32(Vert2.E[1]), f32(Vert2.E[2]) }}; Dest[0] = Result0; Dest[1] = Result1; diff --git a/generated/copy_vertex_buffer_v3_v3_u8_f32.h b/generated/copy_vertex_buffer_v3_v3_u8_f32.h index f87937e0e..72ab94f86 100644 --- a/generated/copy_vertex_buffer_v3_v3_u8_f32.h +++ b/generated/copy_vertex_buffer_v3_v3_u8_f32.h @@ -1,5 +1,4 @@ -// src/engine/mesh.h:321:0 - +// src/engine/mesh.h:148:0 // // Offset, Scale, Rotate // @@ -20,9 +19,9 @@ CopyVertexBuffer( v3 *Dest, v3_u8 *Src, u32 NumVerts, v3 Offset, v3 Scale, Quate auto Src1 = Rotate(Src[VertIndex + 1], Rot); auto Src2 = Rotate(Src[VertIndex + 2], Rot); - f32_reg Vert0; - f32_reg Vert1; - f32_reg Vert2; + f32_4x Vert0; + f32_4x Vert1; + f32_4x 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); @@ -32,9 +31,9 @@ CopyVertexBuffer( v3 *Dest, v3_u8 *Src, u32 NumVerts, v3 Offset, v3 Scale, Quate 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]) }}; + v3 Result0 = {{ f32(Vert0.E[0]), f32(Vert0.E[1]), f32(Vert0.E[2]) }}; + v3 Result1 = {{ f32(Vert1.E[0]), f32(Vert1.E[1]), f32(Vert1.E[2]) }}; + v3 Result2 = {{ f32(Vert2.E[0]), f32(Vert2.E[1]), f32(Vert2.E[2]) }}; Dest[0] = Result0; Dest[1] = Result1; @@ -63,9 +62,9 @@ CopyVertexBuffer( v3 *Dest, v3_u8 *Src, u32 NumVerts, v3 Offset, v3 Scale ) auto Src1 = Src[VertIndex + 1]; auto Src2 = Src[VertIndex + 2]; - f32_reg Vert0; - f32_reg Vert1; - f32_reg Vert2; + f32_4x Vert0; + f32_4x Vert1; + f32_4x 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); @@ -75,9 +74,9 @@ CopyVertexBuffer( v3 *Dest, v3_u8 *Src, u32 NumVerts, v3 Offset, v3 Scale ) 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]) }}; + v3 Result0 = {{ f32(Vert0.E[0]), f32(Vert0.E[1]), f32(Vert0.E[2]) }}; + v3 Result1 = {{ f32(Vert1.E[0]), f32(Vert1.E[1]), f32(Vert1.E[2]) }}; + v3 Result2 = {{ f32(Vert2.E[0]), f32(Vert2.E[1]), f32(Vert2.E[2]) }}; Dest[0] = Result0; Dest[1] = Result1; diff --git a/generated/cursor_v3i.h b/generated/cursor_v3i.h index 4396c066b..b7e681888 100644 --- a/generated/cursor_v3i.h +++ b/generated/cursor_v3i.h @@ -1,12 +1,10 @@ -// external/bonsai_stdlib/src/vector.cpp:5:0 - +// external/bonsai_stdlib/src/poof_functions.h:1541:0 struct v3i_cursor { v3i *Start; // TODO(Jesse)(immediate): For the love of fucksakes change these to indices v3i *At; v3i *End; - /* OWNED_BY_THREAD_MEMBER(); */ }; @@ -15,12 +13,12 @@ link_internal v3i_cursor V3iCursor(umm ElementCount, memory_arena* Memory) { v3i *Start = (v3i*)PushStruct(Memory, sizeof(v3i)*ElementCount, 1, 0); - v3i_cursor Result = { - .Start = Start, - .End = Start+ElementCount, - .At = Start, - /* OWNED_BY_THREAD_MEMBER_INIT() */ - }; + v3i_cursor Result = {}; + + Result.Start = Start; + Result.End = Start+ElementCount; + Result.At = Start; + return Result; } @@ -34,6 +32,12 @@ GetPtr(v3i_cursor *Cursor, umm ElementIndex) return Result; } +link_internal v3i* +TryGetPtr(v3i_cursor *Cursor, umm ElementIndex) +{ + return GetPtr(Cursor, ElementIndex); +} + link_internal v3i* GetPtrUnsafe(v3i_cursor *Cursor, umm ElementIndex) { 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 1911280a4..a892c8dc5 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 @@ -1,431 +1,613 @@ -// src/engine/render_command.h:160:0 +// external/bonsai_stdlib/src/poof_functions.h:78:0 link_internal work_queue_entry__bonsai_render_command -WorkQueueEntryBonsaiRenderCommand( bonsai_render_command_clear_all_framebuffers A ) +WorkQueueEntryBonsaiRenderCommand( bonsai_render_command_initialize_noise_buffer A ) +{ + work_queue_entry__bonsai_render_command Result = { + .Type = type_bonsai_render_command_initialize_noise_buffer, + .bonsai_render_command_initialize_noise_buffer = A, + + + + }; + return Result; +} + +link_internal work_queue_entry__bonsai_render_command +WorkQueueEntryBonsaiRenderCommand( bonsai_render_command_clear_all_framebuffers A ) { work_queue_entry__bonsai_render_command Result = { .Type = type_bonsai_render_command_clear_all_framebuffers, .bonsai_render_command_clear_all_framebuffers = A, - + }; return Result; } link_internal work_queue_entry__bonsai_render_command -WorkQueueEntryBonsaiRenderCommand( bonsai_render_command_allocate_texture A ) +WorkQueueEntryBonsaiRenderCommand( bonsai_render_command_allocate_texture A ) { work_queue_entry__bonsai_render_command Result = { .Type = type_bonsai_render_command_allocate_texture, .bonsai_render_command_allocate_texture = A, - + }; return Result; } link_internal work_queue_entry__bonsai_render_command -WorkQueueEntryBonsaiRenderCommand( bonsai_render_command_deallocate_texture A ) +WorkQueueEntryBonsaiRenderCommand( bonsai_render_command_deallocate_texture A ) { work_queue_entry__bonsai_render_command Result = { .Type = type_bonsai_render_command_deallocate_texture, .bonsai_render_command_deallocate_texture = A, - + }; return Result; } link_internal work_queue_entry__bonsai_render_command -WorkQueueEntryBonsaiRenderCommand( bonsai_render_command_allocate_buffers A ) +WorkQueueEntryBonsaiRenderCommand( bonsai_render_command_allocate_handles A ) { work_queue_entry__bonsai_render_command Result = { - .Type = type_bonsai_render_command_allocate_buffers, - .bonsai_render_command_allocate_buffers = A, + .Type = type_bonsai_render_command_allocate_handles, + .bonsai_render_command_allocate_handles = A, - + }; return Result; } link_internal work_queue_entry__bonsai_render_command -WorkQueueEntryBonsaiRenderCommand( bonsai_render_command_reallocate_buffers A ) +WorkQueueEntryBonsaiRenderCommand( bonsai_render_command_deallocate_handles A ) { work_queue_entry__bonsai_render_command Result = { - .Type = type_bonsai_render_command_reallocate_buffers, - .bonsai_render_command_reallocate_buffers = A, + .Type = type_bonsai_render_command_deallocate_handles, + .bonsai_render_command_deallocate_handles = A, - + }; return Result; } link_internal work_queue_entry__bonsai_render_command -WorkQueueEntryBonsaiRenderCommand( bonsai_render_command_deallocate_buffers A ) +WorkQueueEntryBonsaiRenderCommand( bonsai_render_command_deallocate_world_chunk A ) { work_queue_entry__bonsai_render_command Result = { - .Type = type_bonsai_render_command_deallocate_buffers, - .bonsai_render_command_deallocate_buffers = A, + .Type = type_bonsai_render_command_deallocate_world_chunk, + .bonsai_render_command_deallocate_world_chunk = A, - + }; return Result; } link_internal work_queue_entry__bonsai_render_command -WorkQueueEntryBonsaiRenderCommand( bonsai_render_command_deallocate_world_chunk A ) +WorkQueueEntryBonsaiRenderCommand( bonsai_render_command_do_stuff A ) { work_queue_entry__bonsai_render_command Result = { - .Type = type_bonsai_render_command_deallocate_world_chunk, - .bonsai_render_command_deallocate_world_chunk = A, + .Type = type_bonsai_render_command_do_stuff, + .bonsai_render_command_do_stuff = A, - + }; return Result; } link_internal work_queue_entry__bonsai_render_command -WorkQueueEntryBonsaiRenderCommand( bonsai_render_command_do_stuff A ) +WorkQueueEntryBonsaiRenderCommand( bonsai_render_command_allocate_and_map_gpu_element_buffer A ) { work_queue_entry__bonsai_render_command Result = { - .Type = type_bonsai_render_command_do_stuff, - .bonsai_render_command_do_stuff = A, + .Type = type_bonsai_render_command_allocate_and_map_gpu_element_buffer, + .bonsai_render_command_allocate_and_map_gpu_element_buffer = A, - + + + }; + return Result; +} + +link_internal work_queue_entry__bonsai_render_command +WorkQueueEntryBonsaiRenderCommand( bonsai_render_command_unmap_gpu_element_buffer A ) +{ + work_queue_entry__bonsai_render_command Result = { + .Type = type_bonsai_render_command_unmap_gpu_element_buffer, + .bonsai_render_command_unmap_gpu_element_buffer = A, + + + + }; + return Result; +} + +link_internal work_queue_entry__bonsai_render_command +WorkQueueEntryBonsaiRenderCommand( bonsai_render_command_unmap_and_deallocate_pbo A ) +{ + work_queue_entry__bonsai_render_command Result = { + .Type = type_bonsai_render_command_unmap_and_deallocate_pbo, + .bonsai_render_command_unmap_and_deallocate_pbo = A, + + }; return Result; } link_internal work_queue_entry__bonsai_render_command -WorkQueueEntryBonsaiRenderCommand( bonsai_render_command_setup_shader A ) +WorkQueueEntryBonsaiRenderCommand( bonsai_render_command_setup_shader A ) { work_queue_entry__bonsai_render_command Result = { .Type = type_bonsai_render_command_setup_shader, .bonsai_render_command_setup_shader = A, - + }; return Result; } link_internal work_queue_entry__bonsai_render_command -WorkQueueEntryBonsaiRenderCommand( bonsai_render_command_teardown_shader A ) +WorkQueueEntryBonsaiRenderCommand( bonsai_render_command_teardown_shader A ) { work_queue_entry__bonsai_render_command Result = { .Type = type_bonsai_render_command_teardown_shader, .bonsai_render_command_teardown_shader = A, - + }; return Result; } link_internal work_queue_entry__bonsai_render_command -WorkQueueEntryBonsaiRenderCommand( bonsai_render_command_set_shader_uniform A ) +WorkQueueEntryBonsaiRenderCommand( bonsai_render_command_set_shader_uniform A ) { work_queue_entry__bonsai_render_command Result = { .Type = type_bonsai_render_command_set_shader_uniform, .bonsai_render_command_set_shader_uniform = A, - + }; return Result; } link_internal work_queue_entry__bonsai_render_command -WorkQueueEntryBonsaiRenderCommand( bonsai_render_command_draw_world_chunk_draw_list A ) +WorkQueueEntryBonsaiRenderCommand( bonsai_render_command_draw_world_chunk_draw_list A ) { work_queue_entry__bonsai_render_command Result = { .Type = type_bonsai_render_command_draw_world_chunk_draw_list, .bonsai_render_command_draw_world_chunk_draw_list = A, - + }; return Result; } link_internal work_queue_entry__bonsai_render_command -WorkQueueEntryBonsaiRenderCommand( bonsai_render_command_draw_all_entities A ) +WorkQueueEntryBonsaiRenderCommand( bonsai_render_command_draw_all_entities A ) { work_queue_entry__bonsai_render_command Result = { .Type = type_bonsai_render_command_draw_all_entities, .bonsai_render_command_draw_all_entities = A, - + }; return Result; } link_internal work_queue_entry__bonsai_render_command -WorkQueueEntryBonsaiRenderCommand( bonsai_render_command_gl_timer_init A ) +WorkQueueEntryBonsaiRenderCommand( bonsai_render_command_gl_timer_init A ) { work_queue_entry__bonsai_render_command Result = { .Type = type_bonsai_render_command_gl_timer_init, .bonsai_render_command_gl_timer_init = A, - + }; return Result; } link_internal work_queue_entry__bonsai_render_command -WorkQueueEntryBonsaiRenderCommand( bonsai_render_command_gl_timer_start A ) +WorkQueueEntryBonsaiRenderCommand( bonsai_render_command_gl_timer_start A ) { work_queue_entry__bonsai_render_command Result = { .Type = type_bonsai_render_command_gl_timer_start, .bonsai_render_command_gl_timer_start = A, - + }; return Result; } link_internal work_queue_entry__bonsai_render_command -WorkQueueEntryBonsaiRenderCommand( bonsai_render_command_gl_timer_end A ) +WorkQueueEntryBonsaiRenderCommand( bonsai_render_command_gl_timer_end A ) { work_queue_entry__bonsai_render_command Result = { .Type = type_bonsai_render_command_gl_timer_end, .bonsai_render_command_gl_timer_end = A, - + }; return Result; } link_internal work_queue_entry__bonsai_render_command -WorkQueueEntryBonsaiRenderCommand( bonsai_render_command_gl_timer_read_value_and_histogram A ) +WorkQueueEntryBonsaiRenderCommand( bonsai_render_command_gl_timer_read_value_and_histogram A ) { work_queue_entry__bonsai_render_command Result = { .Type = type_bonsai_render_command_gl_timer_read_value_and_histogram, .bonsai_render_command_gl_timer_read_value_and_histogram = A, - + }; return Result; } +link_internal work_queue_entry__bonsai_render_command +WorkQueueEntryBonsaiRenderCommand( bonsai_render_command_cancel_all_noise_readback_jobs A ) +{ + work_queue_entry__bonsai_render_command Result = { + .Type = type_bonsai_render_command_cancel_all_noise_readback_jobs, + .bonsai_render_command_cancel_all_noise_readback_jobs = A, + + + + }; + return Result; +} + + + + + + + +link_internal bonsai_render_command_initialize_noise_buffer +BonsaiRenderCommandInitializeNoiseBuffer( octree_node * DestNode ) +{ + bonsai_render_command_initialize_noise_buffer Reuslt = { + .DestNode = DestNode + + + }; + + + + return Reuslt; +} link_internal bonsai_render_command_clear_all_framebuffers -BonsaiRenderCommandClearAllFramebuffers( u32 Ignored ) +BonsaiRenderCommandClearAllFramebuffers( u32 Ignored ) { bonsai_render_command_clear_all_framebuffers Reuslt = { - .Ignored = Ignored + .Ignored = Ignored + + }; - + + return Reuslt; } link_internal bonsai_render_command_allocate_texture -BonsaiRenderCommandAllocateTexture( texture* Texture , void * Data ) +BonsaiRenderCommandAllocateTexture( texture * Texture , void * Data ) { bonsai_render_command_allocate_texture Reuslt = { - .Texture = Texture -, - .Data = Data + .Texture = Texture + +, .Data = Data + + }; + + return Reuslt; } link_internal bonsai_render_command_deallocate_texture -BonsaiRenderCommandDeallocateTexture( u32* Buffers , s32 Count ) +BonsaiRenderCommandDeallocateTexture( u32 * Buffers , s32 Count ) { bonsai_render_command_deallocate_texture Reuslt = { - .Buffers = Buffers -, - .Count = Count + .Buffers = Buffers + +, .Count = Count + + }; + + return Reuslt; } -link_internal bonsai_render_command_allocate_buffers -BonsaiRenderCommandAllocateBuffers( u32* Buffers , s32 Count ) +link_internal bonsai_render_command_allocate_handles +BonsaiRenderCommandAllocateHandles( gpu_element_buffer_handles * Handles , untextured_3d_geometry_buffer * Mesh ) { - bonsai_render_command_allocate_buffers Reuslt = { - .Buffers = Buffers -, - .Count = Count + bonsai_render_command_allocate_handles Reuslt = { + .Handles = Handles + +, .Mesh = Mesh + + }; + + return Reuslt; } -link_internal bonsai_render_command_reallocate_buffers -BonsaiRenderCommandReallocateBuffers( gpu_element_buffer_handles* Handles , untextured_3d_geometry_buffer* Mesh ) +link_internal bonsai_render_command_deallocate_handles +BonsaiRenderCommandDeallocateHandles( gpu_element_buffer_handles Handles ) { - bonsai_render_command_reallocate_buffers Reuslt = { - .Handles = Handles -, - .Mesh = Mesh + bonsai_render_command_deallocate_handles Reuslt = { + .Handles = Handles + + }; - + + return Reuslt; } -link_internal bonsai_render_command_deallocate_buffers -BonsaiRenderCommandDeallocateBuffers( u32* Buffers , s32 Count ) +link_internal bonsai_render_command_deallocate_world_chunk +BonsaiRenderCommandDeallocateWorldChunk( world_chunk * Chunk ) { - bonsai_render_command_deallocate_buffers Reuslt = { - .Count = Count + bonsai_render_command_deallocate_world_chunk Reuslt = { + .Chunk = Chunk + + }; - RangeIterator(Index, s32(Count)) - { - Reuslt.Buffers[Index] = Buffers[Index]; - } + + + return Reuslt; +} + +link_internal bonsai_render_command_do_stuff +BonsaiRenderCommandDoStuff( u32 Ignored ) +{ + bonsai_render_command_do_stuff Reuslt = { + .Ignored = Ignored + + + }; + return Reuslt; } -link_internal bonsai_render_command_deallocate_world_chunk -BonsaiRenderCommandDeallocateWorldChunk( world_chunk* Chunk ) +link_internal bonsai_render_command_allocate_and_map_gpu_element_buffer +BonsaiRenderCommandAllocateAndMapGpuElementBuffer( data_type Type , u32 ElementCount , gpu_mapped_element_buffer * Dest , gen_chunk * SynChunk , octree_node * DestNode ) { - bonsai_render_command_deallocate_world_chunk Reuslt = { - .Chunk = Chunk + bonsai_render_command_allocate_and_map_gpu_element_buffer Reuslt = { + .Type = Type + +, .ElementCount = ElementCount + +, .Dest = Dest + +, .SynChunk = SynChunk + +, .DestNode = DestNode + + }; + + + + + return Reuslt; } -link_internal bonsai_render_command_do_stuff -BonsaiRenderCommandDoStuff( u32 Ignored ) +link_internal bonsai_render_command_unmap_gpu_element_buffer +BonsaiRenderCommandUnmapGpuElementBuffer( gpu_element_buffer_handles * Handles , octree_node * DestNode ) { - bonsai_render_command_do_stuff Reuslt = { - .Ignored = Ignored + bonsai_render_command_unmap_gpu_element_buffer Reuslt = { + .Handles = Handles + +, .DestNode = DestNode + + }; + + + return Reuslt; +} + +link_internal bonsai_render_command_unmap_and_deallocate_pbo +BonsaiRenderCommandUnmapAndDeallocatePbo( gpu_readback_buffer PBOBuf ) +{ + bonsai_render_command_unmap_and_deallocate_pbo Reuslt = { + .PBOBuf = PBOBuf + + + }; + + + return Reuslt; } link_internal bonsai_render_command_setup_shader -BonsaiRenderCommandSetupShader( bonsai_render_command_shader_id ShaderId ) +BonsaiRenderCommandSetupShader( bonsai_render_command_shader_id ShaderId ) { bonsai_render_command_setup_shader Reuslt = { - .ShaderId = ShaderId + .ShaderId = ShaderId + + }; - + + return Reuslt; } link_internal bonsai_render_command_teardown_shader -BonsaiRenderCommandTeardownShader( bonsai_render_command_shader_id ShaderId ) +BonsaiRenderCommandTeardownShader( bonsai_render_command_shader_id ShaderId ) { bonsai_render_command_teardown_shader Reuslt = { - .ShaderId = ShaderId + .ShaderId = ShaderId + + }; - + + return Reuslt; } link_internal bonsai_render_command_set_shader_uniform -BonsaiRenderCommandSetShaderUniform( shader_uniform Uniform , shader* Shader , s32 TextureUnit ) +BonsaiRenderCommandSetShaderUniform( shader_uniform Uniform , shader * Shader , s32 TextureUnit ) { bonsai_render_command_set_shader_uniform Reuslt = { - .Uniform = Uniform -, - .Shader = Shader -, - .TextureUnit = TextureUnit + .Uniform = Uniform + +, .Shader = Shader + +, .TextureUnit = TextureUnit + + }; + + + return Reuslt; } link_internal bonsai_render_command_draw_world_chunk_draw_list -BonsaiRenderCommandDrawWorldChunkDrawList( world_chunk_ptr_paged_list* DrawList , shader* Shader ) +BonsaiRenderCommandDrawWorldChunkDrawList( octree_node_ptr_block_array * DrawList , shader * Shader , camera * Camera ) { bonsai_render_command_draw_world_chunk_draw_list Reuslt = { - .DrawList = DrawList -, - .Shader = Shader + .DrawList = DrawList + +, .Shader = Shader + +, .Camera = Camera + + }; + + + return Reuslt; } link_internal bonsai_render_command_draw_all_entities -BonsaiRenderCommandDrawAllEntities( shader* Shader ) +BonsaiRenderCommandDrawAllEntities( shader * Shader ) { bonsai_render_command_draw_all_entities Reuslt = { - .Shader = Shader + .Shader = Shader + + }; - + + return Reuslt; } link_internal bonsai_render_command_gl_timer_init -BonsaiRenderCommandGlTimerInit( u32* GlTimerObject ) +BonsaiRenderCommandGlTimerInit( u32 * GlTimerObject ) { bonsai_render_command_gl_timer_init Reuslt = { - .GlTimerObject = GlTimerObject + .GlTimerObject = GlTimerObject + + }; - + + return Reuslt; } link_internal bonsai_render_command_gl_timer_start -BonsaiRenderCommandGlTimerStart( u32 GlTimerObject ) +BonsaiRenderCommandGlTimerStart( u32 GlTimerObject ) { bonsai_render_command_gl_timer_start Reuslt = { - .GlTimerObject = GlTimerObject + .GlTimerObject = GlTimerObject + + }; - + + return Reuslt; } link_internal bonsai_render_command_gl_timer_end -BonsaiRenderCommandGlTimerEnd( u32 GlTimerObject ) +BonsaiRenderCommandGlTimerEnd( u32 GlTimerObject ) { bonsai_render_command_gl_timer_end Reuslt = { - .GlTimerObject = GlTimerObject + .GlTimerObject = GlTimerObject + + }; - + + return Reuslt; } link_internal bonsai_render_command_gl_timer_read_value_and_histogram -BonsaiRenderCommandGlTimerReadValueAndHistogram( u32 GlTimerObject ) +BonsaiRenderCommandGlTimerReadValueAndHistogram( u32 GlTimerObject ) { bonsai_render_command_gl_timer_read_value_and_histogram Reuslt = { - .GlTimerObject = GlTimerObject + .GlTimerObject = GlTimerObject + + + }; + + + + return Reuslt; +} + +link_internal bonsai_render_command_cancel_all_noise_readback_jobs +BonsaiRenderCommandCancelAllNoiseReadbackJobs( ) +{ + bonsai_render_command_cancel_all_noise_readback_jobs Reuslt = { + }; return Reuslt; } + + + + diff --git a/generated/d_union_constructors_work_queue_entry.h b/generated/d_union_constructors_work_queue_entry.h index 87f5ac584..d7f9c1013 100644 --- a/generated/d_union_constructors_work_queue_entry.h +++ b/generated/d_union_constructors_work_queue_entry.h @@ -1,133 +1,150 @@ -// src/engine/work_queue.h:325:0 +// external/bonsai_stdlib/src/poof_functions.h:51:0 link_internal work_queue_entry -WorkQueueEntry( work_queue_entry_init_world_chunk A ) +WorkQueueEntry( work_queue_entry_init_world_chunk A ) { work_queue_entry Result = { .Type = type_work_queue_entry_init_world_chunk, .work_queue_entry_init_world_chunk = A, - + }; return Result; } link_internal work_queue_entry -WorkQueueEntry( work_queue_entry_copy_buffer_set A ) +WorkQueueEntry( work_queue_entry_finalize_noise_values A ) { work_queue_entry Result = { - .Type = type_work_queue_entry_copy_buffer_set, - .work_queue_entry_copy_buffer_set = A, + .Type = type_work_queue_entry_finalize_noise_values, + .work_queue_entry_finalize_noise_values = A, - + }; return Result; } link_internal work_queue_entry -WorkQueueEntry( work_queue_entry_copy_buffer_ref A ) +WorkQueueEntry( work_queue_entry_build_chunk_mesh A ) { work_queue_entry Result = { - .Type = type_work_queue_entry_copy_buffer_ref, - .work_queue_entry_copy_buffer_ref = A, + .Type = type_work_queue_entry_build_chunk_mesh, + .work_queue_entry_build_chunk_mesh = A, - + }; return Result; } link_internal work_queue_entry -WorkQueueEntry( work_queue_entry_init_asset A ) +WorkQueueEntry( work_queue_entry_copy_buffer_set A ) { work_queue_entry Result = { - .Type = type_work_queue_entry_init_asset, - .work_queue_entry_init_asset = A, + .Type = type_work_queue_entry_copy_buffer_set, + .work_queue_entry_copy_buffer_set = A, - + }; return Result; } link_internal work_queue_entry -WorkQueueEntry( work_queue_entry_update_world_region A ) +WorkQueueEntry( work_queue_entry_copy_buffer_ref A ) { work_queue_entry Result = { - .Type = type_work_queue_entry_update_world_region, - .work_queue_entry_update_world_region = A, + .Type = type_work_queue_entry_copy_buffer_ref, + .work_queue_entry_copy_buffer_ref = A, - + }; return Result; } link_internal work_queue_entry -WorkQueueEntry( work_queue_entry_rebuild_mesh A ) +WorkQueueEntry( work_queue_entry_init_asset A ) +{ + work_queue_entry Result = { + .Type = type_work_queue_entry_init_asset, + .work_queue_entry_init_asset = A, + + + + }; + return Result; +} + +link_internal work_queue_entry +WorkQueueEntry( work_queue_entry_rebuild_mesh A ) { work_queue_entry Result = { .Type = type_work_queue_entry_rebuild_mesh, .work_queue_entry_rebuild_mesh = A, - + }; return Result; } link_internal work_queue_entry -WorkQueueEntry( work_queue_entry_sim_particle_system A ) +WorkQueueEntry( work_queue_entry_sim_particle_system A ) { work_queue_entry Result = { .Type = type_work_queue_entry_sim_particle_system, .work_queue_entry_sim_particle_system = A, - + }; return Result; } link_internal work_queue_entry -WorkQueueEntry( work_queue_entry__bonsai_render_command A ) +WorkQueueEntry( work_queue_entry__bonsai_render_command A ) { work_queue_entry Result = { .Type = type_work_queue_entry__bonsai_render_command, .work_queue_entry__bonsai_render_command = A, - + }; return Result; } link_internal work_queue_entry -WorkQueueEntry( work_queue_entry_async_function_call A ) +WorkQueueEntry( work_queue_entry_async_function_call A ) { work_queue_entry Result = { .Type = type_work_queue_entry_async_function_call, .work_queue_entry_async_function_call = A, - + }; return Result; } link_internal work_queue_entry -WorkQueueEntry( work_queue_entry__align_to_cache_line_helper A ) +WorkQueueEntry( work_queue_entry__align_to_cache_line_helper A ) { work_queue_entry Result = { .Type = type_work_queue_entry__align_to_cache_line_helper, .work_queue_entry__align_to_cache_line_helper = A, - + }; return Result; } + + + + diff --git a/generated/d_union_ui_render_command.h b/generated/d_union_ui_render_command.h index 144039931..865753833 100644 --- a/generated/d_union_ui_render_command.h +++ b/generated/d_union_ui_render_command.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/ui/ui.h:810:0 - +// external/bonsai_stdlib/src/ui/ui.h:900:0 enum ui_render_command_type { type_ui_render_command_noop, diff --git a/generated/d_union_work_queue_entry.h b/generated/d_union_work_queue_entry.h index fc568a4b5..bbaf13d21 100644 --- a/generated/d_union_work_queue_entry.h +++ b/generated/d_union_work_queue_entry.h @@ -1,13 +1,13 @@ -// src/engine/work_queue.h:297:0 - +// src/engine/work_queue.h:210:0 enum work_queue_entry_type { type_work_queue_entry_noop, type_work_queue_entry_init_world_chunk, + type_work_queue_entry_finalize_noise_values, + type_work_queue_entry_build_chunk_mesh, type_work_queue_entry_copy_buffer_set, type_work_queue_entry_copy_buffer_ref, type_work_queue_entry_init_asset, - type_work_queue_entry_update_world_region, type_work_queue_entry_rebuild_mesh, type_work_queue_entry_sim_particle_system, type_work_queue_entry__bonsai_render_command, @@ -22,10 +22,11 @@ struct work_queue_entry union { struct work_queue_entry_init_world_chunk work_queue_entry_init_world_chunk; + struct work_queue_entry_finalize_noise_values work_queue_entry_finalize_noise_values; + struct work_queue_entry_build_chunk_mesh work_queue_entry_build_chunk_mesh; struct work_queue_entry_copy_buffer_set work_queue_entry_copy_buffer_set; struct work_queue_entry_copy_buffer_ref work_queue_entry_copy_buffer_ref; struct work_queue_entry_init_asset work_queue_entry_init_asset; - struct work_queue_entry_update_world_region work_queue_entry_update_world_region; struct work_queue_entry_rebuild_mesh work_queue_entry_rebuild_mesh; struct work_queue_entry_sim_particle_system work_queue_entry_sim_particle_system; struct work_queue_entry__bonsai_render_command work_queue_entry__bonsai_render_command; diff --git a/generated/d_union_bonsai_render_command.h b/generated/d_union_work_queue_entry__bonsai_render_command.h similarity index 65% rename from generated/d_union_bonsai_render_command.h rename to generated/d_union_work_queue_entry__bonsai_render_command.h index ffc4cd0f5..1802f3209 100644 --- a/generated/d_union_bonsai_render_command.h +++ b/generated/d_union_work_queue_entry__bonsai_render_command.h @@ -1,16 +1,18 @@ -// src/engine/render_command.h:128:0 - +// src/engine/render_command.h:166:0 enum work_queue_entry__bonsai_render_command_type { type_work_queue_entry__bonsai_render_command_noop, + type_bonsai_render_command_initialize_noise_buffer, type_bonsai_render_command_clear_all_framebuffers, type_bonsai_render_command_allocate_texture, type_bonsai_render_command_deallocate_texture, - type_bonsai_render_command_allocate_buffers, - type_bonsai_render_command_reallocate_buffers, - type_bonsai_render_command_deallocate_buffers, + type_bonsai_render_command_allocate_handles, + type_bonsai_render_command_deallocate_handles, type_bonsai_render_command_deallocate_world_chunk, type_bonsai_render_command_do_stuff, + type_bonsai_render_command_allocate_and_map_gpu_element_buffer, + type_bonsai_render_command_unmap_gpu_element_buffer, + type_bonsai_render_command_unmap_and_deallocate_pbo, type_bonsai_render_command_setup_shader, type_bonsai_render_command_teardown_shader, type_bonsai_render_command_set_shader_uniform, @@ -20,6 +22,7 @@ enum work_queue_entry__bonsai_render_command_type type_bonsai_render_command_gl_timer_start, type_bonsai_render_command_gl_timer_end, type_bonsai_render_command_gl_timer_read_value_and_histogram, + type_bonsai_render_command_cancel_all_noise_readback_jobs, }; struct work_queue_entry__bonsai_render_command @@ -28,14 +31,17 @@ struct work_queue_entry__bonsai_render_command union { + struct bonsai_render_command_initialize_noise_buffer bonsai_render_command_initialize_noise_buffer; struct bonsai_render_command_clear_all_framebuffers bonsai_render_command_clear_all_framebuffers; struct bonsai_render_command_allocate_texture bonsai_render_command_allocate_texture; struct bonsai_render_command_deallocate_texture bonsai_render_command_deallocate_texture; - struct bonsai_render_command_allocate_buffers bonsai_render_command_allocate_buffers; - 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_allocate_handles bonsai_render_command_allocate_handles; + struct bonsai_render_command_deallocate_handles bonsai_render_command_deallocate_handles; struct bonsai_render_command_deallocate_world_chunk bonsai_render_command_deallocate_world_chunk; struct bonsai_render_command_do_stuff bonsai_render_command_do_stuff; + struct bonsai_render_command_allocate_and_map_gpu_element_buffer bonsai_render_command_allocate_and_map_gpu_element_buffer; + struct bonsai_render_command_unmap_gpu_element_buffer bonsai_render_command_unmap_gpu_element_buffer; + struct bonsai_render_command_unmap_and_deallocate_pbo bonsai_render_command_unmap_and_deallocate_pbo; struct bonsai_render_command_setup_shader bonsai_render_command_setup_shader; struct bonsai_render_command_teardown_shader bonsai_render_command_teardown_shader; struct bonsai_render_command_set_shader_uniform bonsai_render_command_set_shader_uniform; @@ -45,6 +51,7 @@ struct work_queue_entry__bonsai_render_command struct bonsai_render_command_gl_timer_start bonsai_render_command_gl_timer_start; struct bonsai_render_command_gl_timer_end bonsai_render_command_gl_timer_end; struct bonsai_render_command_gl_timer_read_value_and_histogram bonsai_render_command_gl_timer_read_value_and_histogram; + struct bonsai_render_command_cancel_all_noise_readback_jobs bonsai_render_command_cancel_all_noise_readback_jobs; }; }; diff --git a/generated/deep_copy_u32_stream.h b/generated/deep_copy_u32_stream.h index bcaabffde..63fc5e17e 100644 --- a/generated/deep_copy_u32_stream.h +++ b/generated/deep_copy_u32_stream.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/binary_parser.cpp:15:0 - +// external/bonsai_stdlib/src/poof_functions.h:1299:0 /* link_internal void */ /* DeepCopy( Type.name *Src, Type.name *Dest) */ /* { */ diff --git a/generated/default_marshal_brush_settings_0.h b/generated/default_marshal_brush_settings_0.h deleted file mode 100644 index a5558a52c..000000000 --- a/generated/default_marshal_brush_settings_0.h +++ /dev/null @@ -1,32 +0,0 @@ -// src/engine/editor.h:977:0 - -Live->Type = Stored->Type; - - - -Live->Noise = Stored->Noise; - - - -Live->Shape = Stored->Shape; - - - -Live->Mode = Stored->Mode; - - - -Live->Modifier = Stored->Modifier; - - - -Live->Iterations = Stored->Iterations; - - - -Live->Offset = Stored->Offset; - - - -Live->RGBColor = MagicaVoxelDefaultPaletteToRGB(Stored->Color); - diff --git a/generated/default_marshal_brush_settings_1.h b/generated/default_marshal_brush_settings_1.h deleted file mode 100644 index f5202671d..000000000 --- a/generated/default_marshal_brush_settings_1.h +++ /dev/null @@ -1,36 +0,0 @@ -// src/engine/editor.h:970:0 - -Live->Type = Stored->Type; - - - -Live->Noise = Stored->Noise; - - - -Live->Shape = Stored->Shape; - - - -Live->Mode = Stored->Mode; - - - -Live->Modifier = Stored->Modifier; - - - -Live->Iterations = Stored->Iterations; - - - -Live->Offset = Stored->Offset; - - - -Live->NoiseBasisOffset = Stored->NoiseBasisOffset; - - - -Live->RGBColor = MagicaVoxelDefaultPaletteToRGB(Stored->Color); - diff --git a/generated/default_marshal_brush_settings_2.h b/generated/default_marshal_brush_settings_2.h deleted file mode 100644 index 969e11d15..000000000 --- a/generated/default_marshal_brush_settings_2.h +++ /dev/null @@ -1,40 +0,0 @@ -// src/engine/editor.h:963:0 - -Live->Type = Stored->Type; - - - -Live->Noise = Stored->Noise; - - - -Live->Shape = Stored->Shape; - - - -Live->Mode = Stored->Mode; - - - -Live->Modifier = Stored->Modifier; - - - -Live->Iterations = Stored->Iterations; - - - -Live->Offset = Stored->Offset; - - - -Live->NoiseBasisOffset = Stored->NoiseBasisOffset; - - - -Live->RGBColor = MagicaVoxelDefaultPaletteToRGB(Stored->Color); - - - -Live->Invert = Stored->Invert; - diff --git a/generated/default_marshal_layered_brush_editor_0.h b/generated/default_marshal_layered_brush_editor_0.h deleted file mode 100644 index 2304c3b95..000000000 --- a/generated/default_marshal_layered_brush_editor_0.h +++ /dev/null @@ -1,15 +0,0 @@ -// src/engine/editor.h:1075:0 - -Live->LayerCount = Stored->LayerCount; - - - -RangeIterator(Index, 16) -{ - Live->Layers[Index] = Stored->Layers[Index]; - -} - - - - diff --git a/generated/default_marshal_layered_brush_editor_1.h b/generated/default_marshal_layered_brush_editor_1.h deleted file mode 100644 index 36562e431..000000000 --- a/generated/default_marshal_layered_brush_editor_1.h +++ /dev/null @@ -1,30 +0,0 @@ -// src/engine/editor.h:1068:0 - -RangeIterator(Index, (256)) -{ - Live->NameBuf[Index] = Stored->NameBuf[Index]; - -} - - -Live->LayerCount = Stored->LayerCount; - - - -RangeIterator(Index, 16) -{ - Live->Layers[Index] = Stored->Layers[Index]; - -} - - -Live->SeedBrushWithSelection = Stored->SeedBrushWithSelection; - - - -Live->BrushFollowsCursor = Stored->BrushFollowsCursor; - - - - - diff --git a/generated/default_marshal_layered_brush_editor_2.h b/generated/default_marshal_layered_brush_editor_2.h deleted file mode 100644 index b64633e9a..000000000 --- a/generated/default_marshal_layered_brush_editor_2.h +++ /dev/null @@ -1,23 +0,0 @@ -// src/engine/editor.h:1061:0 - -Live->LayerCount = Stored->LayerCount; - - - -RangeIterator(Index, 16) -{ - Live->Layers[Index] = Stored->Layers[Index]; - -} - - -Live->SeedBrushWithSelection = Stored->SeedBrushWithSelection; - - - -Live->BrushFollowsCursor = Stored->BrushFollowsCursor; - - - - - diff --git a/generated/default_marshal_level_header_3.h b/generated/default_marshal_level_header_3.h deleted file mode 100644 index 2415b35ef..000000000 --- a/generated/default_marshal_level_header_3.h +++ /dev/null @@ -1,28 +0,0 @@ -// src/engine/serdes.cpp:484:0 - -Live->ChunkCount = Stored->ChunkCount; - - - -Live->EntityCount = Stored->EntityCount; - - - -Live->WorldFlags = Stored->WorldFlags; - - - -Live->WorldCenter = Stored->WorldCenter; - - - -Live->VisibleRegion = Stored->VisibleRegion; - - - -Live->Camera = Stored->Camera; - - - -Live->RenderSettings = Stored->RenderSettings; - diff --git a/generated/default_marshal_noise_layer_0.h b/generated/default_marshal_noise_layer_0.h index 4ec612773..32a6bc463 100644 --- a/generated/default_marshal_noise_layer_0.h +++ b/generated/default_marshal_noise_layer_0.h @@ -1,5 +1,4 @@ -// src/engine/editor.h:842:0 - +// src/engine/serdes.h:15:0 Live->Type = Stored->Type; @@ -10,3 +9,7 @@ Live->Perlin = Stored->Perlin; Live->Voronoi = Stored->Voronoi; + + + + diff --git a/generated/default_marshal_particle_system_0.h b/generated/default_marshal_particle_system_0.h index 97bec78f6..926746e72 100644 --- a/generated/default_marshal_particle_system_0.h +++ b/generated/default_marshal_particle_system_0.h @@ -1,5 +1,4 @@ -// src/engine/serdes.cpp:280:0 - +// src/engine/serdes.h:15:0 Live->Entropy = Stored->Entropy; @@ -86,10 +85,11 @@ Live->ElapsedSinceLastEmission = Stored->ElapsedSinceLastEmission; RangeIterator(Index, 6) { - Live->PackedHSVColors[Index] = MagicaVoxelDefaultPaletteToPackedHSV(Stored->MCVColors[Index]); + Live->PackedHSVColors[Index] = MagicaVoxelDefaultPaletteToPackedHSV(Stored->MCVColors[Index]); } + diff --git a/generated/default_marshal_world_chunk_0.h b/generated/default_marshal_world_chunk_0.h deleted file mode 100644 index 5d13ff442..000000000 --- a/generated/default_marshal_world_chunk_0.h +++ /dev/null @@ -1,20 +0,0 @@ -// src/engine/serdes.cpp:55:0 - -Live->Dim = Stored->Dim; - - - -MarshalMagicaVoxelEncodedColors(Stored->Voxels, Live->Voxels, Stored->Dim); - - - -Live->VoxelLighting = Stored->VoxelLighting; - - - -Live->WorldP = Stored->WorldP; - - - - - diff --git a/generated/deserialize_struct_camera_0.h b/generated/deserialize_struct_camera_0.h index bafdc1abe..758912a79 100644 --- a/generated/deserialize_struct_camera_0.h +++ b/generated/deserialize_struct_camera_0.h @@ -1,5 +1,4 @@ -// src/engine/serdes.cpp:74:0 - +// src/engine/serdes.h:252:0 link_internal b32 Deserialize(u8_cursor *Bytes, camera_0 *Element, memory_arena *Memory, umm Count = 1); @@ -13,7 +12,7 @@ link_internal b32 DeserializeCurrentVersion(u8_cursor *Bytes, camera_0 *Element, memory_arena *Memory) { b32 Result = True; - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Frust, Memory); @@ -21,7 +20,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, camera_0 *Element, memory_arena *Mem - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->CurrentP, Memory); @@ -29,7 +28,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, camera_0 *Element, memory_arena *Mem - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->RenderSpacePosition, Memory); @@ -37,7 +36,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, camera_0 *Element, memory_arena *Mem - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Pitch, Memory); @@ -45,7 +44,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, camera_0 *Element, memory_arena *Mem - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Roll, Memory); @@ -53,7 +52,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, camera_0 *Element, memory_arena *Mem - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Yaw, Memory); @@ -61,7 +60,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, camera_0 *Element, memory_arena *Mem - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->DistanceFromTarget, Memory); @@ -69,7 +68,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, camera_0 *Element, memory_arena *Mem - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Front, Memory); @@ -77,7 +76,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, camera_0 *Element, memory_arena *Mem - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Right, Memory); @@ -85,7 +84,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, camera_0 *Element, memory_arena *Mem - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Up, Memory); @@ -93,11 +92,28 @@ DeserializeCurrentVersion(u8_cursor *Bytes, camera_0 *Element, memory_arena *Mem - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->GhostId, Memory); + + + + + + + + + + + + + + + + + MAYBE_READ_DEBUG_OBJECT_DELIM(); return Result; @@ -111,7 +127,7 @@ Deserialize(u8_cursor *Bytes, camera_0 *Element, memory_arena *Memory, umm Count b32 Result = True; RangeIterator_t(umm, ElementIndex, Count) { - Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); + Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); } diff --git a/generated/deserialize_struct_camera_1.h b/generated/deserialize_struct_camera_1.h index 938c62761..029cb414d 100644 --- a/generated/deserialize_struct_camera_1.h +++ b/generated/deserialize_struct_camera_1.h @@ -1,5 +1,4 @@ -// src/engine/serdes.cpp:71:0 - +// src/engine/serdes.h:252:0 link_internal b32 Deserialize(u8_cursor *Bytes, camera_1 *Element, memory_arena *Memory, umm Count = 1); @@ -13,7 +12,7 @@ link_internal b32 DeserializeCurrentVersion(u8_cursor *Bytes, camera_1 *Element, memory_arena *Memory) { b32 Result = True; - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Frust, Memory); @@ -21,7 +20,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, camera_1 *Element, memory_arena *Mem - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->CurrentP, Memory); @@ -29,7 +28,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, camera_1 *Element, memory_arena *Mem - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->RenderSpacePosition, Memory); @@ -37,7 +36,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, camera_1 *Element, memory_arena *Mem - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Pitch, Memory); @@ -45,7 +44,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, camera_1 *Element, memory_arena *Mem - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Roll, Memory); @@ -53,7 +52,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, camera_1 *Element, memory_arena *Mem - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Yaw, Memory); @@ -61,7 +60,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, camera_1 *Element, memory_arena *Mem - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->TargetPitch, Memory); @@ -69,7 +68,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, camera_1 *Element, memory_arena *Mem - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->TargetRoll, Memory); @@ -77,7 +76,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, camera_1 *Element, memory_arena *Mem - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->TargetYaw, Memory); @@ -85,7 +84,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, camera_1 *Element, memory_arena *Mem - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Blend, Memory); @@ -93,7 +92,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, camera_1 *Element, memory_arena *Mem - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->DistanceFromTarget, Memory); @@ -101,7 +100,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, camera_1 *Element, memory_arena *Mem - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Front, Memory); @@ -109,7 +108,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, camera_1 *Element, memory_arena *Mem - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Right, Memory); @@ -117,7 +116,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, camera_1 *Element, memory_arena *Mem - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Up, Memory); @@ -125,11 +124,32 @@ DeserializeCurrentVersion(u8_cursor *Bytes, camera_1 *Element, memory_arena *Mem - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->GhostId, Memory); + + + + + + + + + + + + + + + + + + + + + MAYBE_READ_DEBUG_OBJECT_DELIM(); return Result; @@ -143,7 +163,7 @@ Deserialize(u8_cursor *Bytes, camera_1 *Element, memory_arena *Memory, umm Count b32 Result = True; RangeIterator_t(umm, ElementIndex, Count) { - Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); + Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); } diff --git a/generated/deserialize_struct_entity.h b/generated/deserialize_struct_entity.h index 1b5a9cc95..828082599 100644 --- a/generated/deserialize_struct_entity.h +++ b/generated/deserialize_struct_entity.h @@ -1,5 +1,4 @@ -// src/engine/serdes.cpp:358:0 - +// src/engine/serdes.h:252:0 link_internal b32 Deserialize(u8_cursor *Bytes, entity *Element, memory_arena *Memory, umm Count = 1); @@ -10,11 +9,11 @@ DeserializeCurrentVersion(u8_cursor *Bytes, entity *Element, memory_arena *Memor link_internal b32 DeserializeVersioned(u8_cursor *Bytes, entity *Element, bonsai_type_info *TypeInfo, memory_arena *Memory) { - Assert(TypeInfo->Version <=2); + Assert(TypeInfo->Version <= 2); b32 Result = True; - if (TypeInfo->Version == 0) + if (TypeInfo->Version == 0) { entity_0 T0 = {}; Result &= Deserialize(Bytes, &T0, Memory); @@ -28,7 +27,7 @@ DeserializeVersioned(u8_cursor *Bytes, entity *Element, bonsai_type_info *TypeIn } - if (TypeInfo->Version ==2) + if (TypeInfo->Version == 2) { Result &= DeserializeCurrentVersion(Bytes, Element, Memory); } @@ -41,7 +40,7 @@ link_internal b32 DeserializeCurrentVersion(u8_cursor *Bytes, entity *Element, memory_arena *Memory) { b32 Result = True; - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Id, Memory); @@ -49,7 +48,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, entity *Element, memory_arena *Memor - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->P, Memory); @@ -57,7 +56,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, entity *Element, memory_arena *Memor - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->EulerAngles, Memory); @@ -65,7 +64,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, entity *Element, memory_arena *Memor - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Scale, Memory); @@ -73,7 +72,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, entity *Element, memory_arena *Memor - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->_CollisionVolumeRadius, Memory); @@ -81,7 +80,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, entity *Element, memory_arena *Memor - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Physics, Memory); @@ -89,7 +88,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, entity *Element, memory_arena *Memor - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->AssetId, Memory); @@ -97,7 +96,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, entity *Element, memory_arena *Memor - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->ModelIndex, Memory); @@ -105,22 +104,24 @@ DeserializeCurrentVersion(u8_cursor *Bytes, entity *Element, memory_arena *Memor - b64 HadEmitterPointer = Read_u64(Bytes); + + + b64 HadEmitterPointer = Read_u64(Bytes); Assert(HadEmitterPointer < 2); // Should be 0 or 1 - Element->State = Cast(entity_state, Read_u32(Bytes)); + Element->State = Cast(entity_state, Read_u32(Bytes)); - Element->Behavior = Cast(entity_behavior_flags, Read_u32(Bytes)); + Element->Behavior = Cast(entity_behavior_flags, Read_u32(Bytes)); - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Carrying, Memory); @@ -128,7 +129,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, entity *Element, memory_arena *Memor - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->UserType, Memory); @@ -136,11 +137,24 @@ DeserializeCurrentVersion(u8_cursor *Bytes, entity *Element, memory_arena *Memor -if (EntityUserDataDeserialize) {Result &= EntityUserDataDeserialize(Bytes, &Element->UserType, &Element->UserData, Memory);} + if (EntityUserDataDeserialize) {Result &= EntityUserDataDeserialize(Bytes, &Element->UserType, &Element->UserData, Memory);} + + + - if (HadEmitterPointer) + + + + + + + + + + + if (HadEmitterPointer) { - umm Count = 1; + umm Count = 1; if (Element->Emitter == 0) @@ -152,6 +166,11 @@ if (EntityUserDataDeserialize) {Result &= EntityUserDataDeserialize(Bytes, &Elem } + + + + + MAYBE_READ_DEBUG_OBJECT_DELIM(); @@ -166,7 +185,7 @@ Deserialize(u8_cursor *Bytes, entity *Element, memory_arena *Memory, umm Count) b32 Result = True; RangeIterator_t(umm, ElementIndex, Count) { - maybe_bonsai_type_info MaybeSerializedType = GetByName(&Global_SerializeTypeTable, CSz("entity")); + maybe_bonsai_type_info MaybeSerializedType = GetByName(&Global_SerializeTypeTable, CSz("entity")); if (MaybeSerializedType.Tag) { diff --git a/generated/deserialize_struct_level_header.h b/generated/deserialize_struct_level_header.h index 3d7d33c6a..856be64d3 100644 --- a/generated/deserialize_struct_level_header.h +++ b/generated/deserialize_struct_level_header.h @@ -1,5 +1,4 @@ -// src/engine/serdes.cpp:501:0 - +// src/engine/serdes.h:252:0 link_internal b32 Deserialize(u8_cursor *Bytes, level_header *Element, memory_arena *Memory, umm Count = 1); @@ -7,61 +6,29 @@ link_internal b32 DeserializeCurrentVersion(u8_cursor *Bytes, level_header *Element, memory_arena *Memory); + + link_internal b32 -DeserializeVersioned(u8_cursor *Bytes, level_header *Element, bonsai_type_info *TypeInfo, memory_arena *Memory) +DeserializeCurrentVersion(u8_cursor *Bytes, level_header *Element, memory_arena *Memory) { - Assert(TypeInfo->Version <=4); - b32 Result = True; - - if (TypeInfo->Version == 0) - { - level_header_0 T0 = {}; - Result &= Deserialize(Bytes, &T0, Memory); - Marshal(&T0, Element); - } - if (TypeInfo->Version == 1) - { - level_header_1 T1 = {}; - Result &= Deserialize(Bytes, &T1, Memory); - Marshal(&T1, Element); - } - if (TypeInfo->Version == 2) - { - level_header_2 T2 = {}; - Result &= Deserialize(Bytes, &T2, Memory); - Marshal(&T2, Element); - } - if (TypeInfo->Version == 3) - { - level_header_3 T3 = {}; - Result &= Deserialize(Bytes, &T3, Memory); - Marshal(&T3, Element); - } + // NOTE(Jesse): Unfortunately we can't check for primitives because + // strings are considered primitive, but need memory to deserialize + Result &= Deserialize(Bytes, &Element->LayerCount, Memory); - if (TypeInfo->Version ==4) - { - Result &= DeserializeCurrentVersion(Bytes, Element, Memory); - } - return Result; -} -link_internal b32 -DeserializeCurrentVersion(u8_cursor *Bytes, level_header *Element, memory_arena *Memory) -{ - b32 Result = True; - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->ChunkCount, Memory); + Result &= Deserialize(Bytes, &Element->EditCount, Memory); - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->EntityCount, Memory); @@ -69,15 +36,15 @@ DeserializeCurrentVersion(u8_cursor *Bytes, level_header *Element, memory_arena - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->WorldFlags, Memory); + Result &= Deserialize(Bytes, &Element->SelectedLayerIndex, Memory); - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->WorldCenter, Memory); @@ -85,15 +52,12 @@ DeserializeCurrentVersion(u8_cursor *Bytes, level_header *Element, memory_arena - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->VisibleRegion, Memory); - + Element->VisibleRegionSize = Cast(visible_region_size, Read_u32(Bytes)); - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Camera, Memory); @@ -101,11 +65,47 @@ DeserializeCurrentVersion(u8_cursor *Bytes, level_header *Element, memory_arena - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->RenderSettings, Memory); + + + + + { + umm Count = (256); + + Result &= Deserialize(Bytes, Element->TerrainShapingShader, Memory, Count); + } + + + + + + { + umm Count = (256); + + Result &= Deserialize(Bytes, Element->TerrainDecorationShader, Memory, Count); + } + + + + + + + + + + + + + + + + + MAYBE_READ_DEBUG_OBJECT_DELIM(); return Result; @@ -119,22 +119,7 @@ Deserialize(u8_cursor *Bytes, level_header *Element, memory_arena *Memory, umm C b32 Result = True; RangeIterator_t(umm, ElementIndex, Count) { - maybe_bonsai_type_info MaybeSerializedType = GetByName(&Global_SerializeTypeTable, CSz("level_header")); - - if (MaybeSerializedType.Tag) - { - u64 OldIgnoredVersionNumber; - if (MaybeSerializedType.Value.Version > 0) - { - Deserialize(Bytes, &OldIgnoredVersionNumber, Memory); - } - Result &= DeserializeVersioned(Bytes, Element+ElementIndex, &MaybeSerializedType.Value, Memory); - } - else - { - bonsai_type_info T0TypeInfo = {}; - Result &= DeserializeVersioned(Bytes, Element+ElementIndex, &T0TypeInfo, Memory); - } + Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); } diff --git a/generated/deserialize_struct_level_header_0.h b/generated/deserialize_struct_level_header_0.h deleted file mode 100644 index c8454395d..000000000 --- a/generated/deserialize_struct_level_header_0.h +++ /dev/null @@ -1,88 +0,0 @@ -// src/engine/serdes.cpp:489:0 - -link_internal b32 -Deserialize(u8_cursor *Bytes, level_header_0 *Element, memory_arena *Memory, umm Count = 1); - -link_internal b32 -DeserializeCurrentVersion(u8_cursor *Bytes, level_header_0 *Element, memory_arena *Memory); - - - - -link_internal b32 -DeserializeCurrentVersion(u8_cursor *Bytes, level_header_0 *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->ChunkCount, Memory); - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->EntityCount, Memory); - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->WorldFlags, Memory); - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->WorldCenter, Memory); - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->VisibleRegion, Memory); - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->Camera, Memory); - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->CameraTarget, Memory); - - - - MAYBE_READ_DEBUG_OBJECT_DELIM(); - return Result; -} - -link_internal b32 -Deserialize(u8_cursor *Bytes, level_header_0 *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/deserialize_struct_level_header_1.h b/generated/deserialize_struct_level_header_1.h deleted file mode 100644 index 7184226b2..000000000 --- a/generated/deserialize_struct_level_header_1.h +++ /dev/null @@ -1,88 +0,0 @@ -// src/engine/serdes.cpp:492:0 - -link_internal b32 -Deserialize(u8_cursor *Bytes, level_header_1 *Element, memory_arena *Memory, umm Count = 1); - -link_internal b32 -DeserializeCurrentVersion(u8_cursor *Bytes, level_header_1 *Element, memory_arena *Memory); - - - - -link_internal b32 -DeserializeCurrentVersion(u8_cursor *Bytes, level_header_1 *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->ChunkCount, Memory); - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->EntityCount, Memory); - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->WorldFlags, Memory); - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->WorldCenter, Memory); - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->VisibleRegion, Memory); - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->Camera, Memory); - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->CameraTarget, Memory); - - - - MAYBE_READ_DEBUG_OBJECT_DELIM(); - return Result; -} - -link_internal b32 -Deserialize(u8_cursor *Bytes, level_header_1 *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/deserialize_struct_level_header_2.h b/generated/deserialize_struct_level_header_2.h deleted file mode 100644 index 47b7198dc..000000000 --- a/generated/deserialize_struct_level_header_2.h +++ /dev/null @@ -1,88 +0,0 @@ -// src/engine/serdes.cpp:495:0 - -link_internal b32 -Deserialize(u8_cursor *Bytes, level_header_2 *Element, memory_arena *Memory, umm Count = 1); - -link_internal b32 -DeserializeCurrentVersion(u8_cursor *Bytes, level_header_2 *Element, memory_arena *Memory); - - - - -link_internal b32 -DeserializeCurrentVersion(u8_cursor *Bytes, level_header_2 *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->ChunkCount, Memory); - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->EntityCount, Memory); - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->WorldFlags, Memory); - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->WorldCenter, Memory); - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->VisibleRegion, Memory); - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->Camera, Memory); - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->CameraTarget, Memory); - - - - MAYBE_READ_DEBUG_OBJECT_DELIM(); - return Result; -} - -link_internal b32 -Deserialize(u8_cursor *Bytes, level_header_2 *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/deserialize_struct_level_header_3.h b/generated/deserialize_struct_level_header_3.h deleted file mode 100644 index 076c86cc1..000000000 --- a/generated/deserialize_struct_level_header_3.h +++ /dev/null @@ -1,88 +0,0 @@ -// src/engine/serdes.cpp:498:0 - -link_internal b32 -Deserialize(u8_cursor *Bytes, level_header_3 *Element, memory_arena *Memory, umm Count = 1); - -link_internal b32 -DeserializeCurrentVersion(u8_cursor *Bytes, level_header_3 *Element, memory_arena *Memory); - - - - -link_internal b32 -DeserializeCurrentVersion(u8_cursor *Bytes, level_header_3 *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->ChunkCount, Memory); - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->EntityCount, Memory); - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->WorldFlags, Memory); - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->WorldCenter, Memory); - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->VisibleRegion, Memory); - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->Camera, Memory); - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->RenderSettings, Memory); - - - - MAYBE_READ_DEBUG_OBJECT_DELIM(); - return Result; -} - -link_internal b32 -Deserialize(u8_cursor *Bytes, level_header_3 *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/do_editor_ui_for_compound_type_animation.h b/generated/do_editor_ui_for_compound_type_animation.h deleted file mode 100644 index ddfeee3a3..000000000 --- a/generated/do_editor_ui_for_compound_type_animation.h +++ /dev/null @@ -1,163 +0,0 @@ -// src/engine/editor.cpp:216:0 - -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, animation *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. - b32 DrawChildren = True; - b32 DidToggle = False; - if (Name.Count) - { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle animation", Element), Params)) - { - DidToggle = True; - PushNewRow(Ui); - } - else - { - DrawChildren = False; - } - } - - if (DrawChildren) - { - PushTableStart(Ui); - if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(r32*,&Element->t), - CSz("t"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(r32*,&Element->tEnd), - CSz("tEnd"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u32*,&Element->xKeyframeCount), - CSz("xKeyframeCount"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(keyframe*, Element->xKeyframes), - CSz("xKeyframes"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u32*,&Element->yKeyframeCount), - CSz("yKeyframeCount"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(keyframe*, Element->yKeyframes), - CSz("yKeyframes"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u32*,&Element->zKeyframeCount), - CSz("zKeyframeCount"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(keyframe*, Element->zKeyframes), - CSz("zKeyframes"), - Params - ); - if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); - } - else - { - PushNewRow(Ui); - } - - } - else - { - PushColumn(Ui, Name, Params); - PushColumn(Ui, CSz("(null)"), Params); - PushNewRow(Ui); - } - -} - diff --git a/generated/do_editor_ui_for_compound_type_asset.h b/generated/do_editor_ui_for_compound_type_asset.h index 333841fff..3889b1167 100644 --- a/generated/do_editor_ui_for_compound_type_asset.h +++ b/generated/do_editor_ui_for_compound_type_asset.h @@ -1,8 +1,11 @@ -// src/engine/editor.cpp:313:0 +// src/engine/editor.h:305:0 +struct asset; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, asset *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) + -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, asset *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) { + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x318DDBAB); + if (Element) { // NOTE(Jesse): This is wacky as fuck, but it's a pretty easy way to support @@ -11,7 +14,7 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, asset *Element, cs Name, ui_r b32 DidToggle = False; if (Name.Count) { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle asset", Element), Params)) + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle asset", Element, ThisHash), Params)) { DidToggle = True; PushNewRow(Ui); @@ -24,15 +27,24 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, asset *Element, cs Name, ui_r if (DrawChildren) { - PushTableStart(Ui); + if (Name.Count) { PushTableStart(Ui); } + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(asset_load_state*,&Element->LoadState), - CSz("LoadState"), - Params - ); + + + { + + + + cs MemberName = CSz("LoadState"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(asset_load_state*, &Element->LoadState), + MemberName, + ThisHash, + Params + ); @@ -40,14 +52,25 @@ 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(asset_id*,&Element->Id), - CSz("Id"), - Params - ); + + { + + + + cs MemberName = CSz("Id"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(asset_id*, &Element->Id), + MemberName, + ThisHash, + Params + ); @@ -55,41 +78,84 @@ 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(u64*,&Element->LRUFrameIndex), - CSz("LRUFrameIndex"), - Params - ); + { + + + + cs MemberName = CSz("LRUFrameIndex"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u64*, &Element->LRUFrameIndex), + MemberName, + ThisHash, + Params + ); - PushNewRow(Ui); - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(asset_type*,&Element->Type), - CSz("Type"), - Params - ); + PushNewRow(Ui); + } + + + { + + + + cs MemberName = CSz("Type"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(asset_type*, &Element->Type), + MemberName, + ThisHash, + Params + ); + + + + + + + } + { + + + + cs MemberName = CSz("(anonymous)"); + + + + + + + + + + + } + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); + if (Name.Count) { PushTableEnd(Ui); } } else { 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 029589c19..475473d41 100644 --- a/generated/do_editor_ui_for_compound_type_asset_id.h +++ b/generated/do_editor_ui_for_compound_type_asset_id.h @@ -1,8 +1,11 @@ -// src/engine/editor.cpp:305:0 +// src/engine/editor.h:305:0 +struct asset_id; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, asset_id *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) + -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, asset_id *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) { + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x31F98252); + if (Element) { // NOTE(Jesse): This is wacky as fuck, but it's a pretty easy way to support @@ -11,7 +14,7 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, asset_id *Element, cs Name, u b32 DidToggle = False; if (Name.Count) { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle asset_id", Element), Params)) + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle asset_id", Element, ThisHash), Params)) { DidToggle = True; PushNewRow(Ui); @@ -24,33 +27,65 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, asset_id *Element, cs Name, u if (DrawChildren) { - PushTableStart(Ui); + if (Name.Count) { PushTableStart(Ui); } + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u16*,&Element->Index), - CSz("Index"), - Params - ); + + { + + + + cs MemberName = CSz("Index"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u16*, &Element->Index), + MemberName, + ThisHash, + Params + ); - PushNewRow(Ui); - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(file_traversal_node*,&Element->FileNode), - CSz("FileNode"), - Params - ); + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("FileNode"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(file_traversal_node*, &Element->FileNode), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); + if (Name.Count) { PushTableEnd(Ui); } } else { diff --git a/generated/do_editor_ui_for_compound_type_asset_thumbnail.h b/generated/do_editor_ui_for_compound_type_asset_thumbnail.h deleted file mode 100644 index 44371d81e..000000000 --- a/generated/do_editor_ui_for_compound_type_asset_thumbnail.h +++ /dev/null @@ -1,68 +0,0 @@ -// src/engine/editor.cpp:335:0 - -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, asset_thumbnail *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. - b32 DrawChildren = True; - b32 DidToggle = False; - if (Name.Count) - { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle asset_thumbnail", Element), Params)) - { - DidToggle = True; - PushNewRow(Ui); - } - else - { - DrawChildren = False; - } - } - - if (DrawChildren) - { - PushTableStart(Ui); - if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(texture*,&Element->Texture), - CSz("Texture"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(camera*,&Element->Camera), - CSz("Camera"), - Params - ); - if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); - } - else - { - PushNewRow(Ui); - } - - } - else - { - PushColumn(Ui, Name, Params); - PushColumn(Ui, CSz("(null)"), Params); - PushNewRow(Ui); - } - -} - diff --git a/generated/do_editor_ui_for_compound_type_bonsai_futex.h b/generated/do_editor_ui_for_compound_type_bonsai_futex.h deleted file mode 100644 index 74eb8a5e6..000000000 --- a/generated/do_editor_ui_for_compound_type_bonsai_futex.h +++ /dev/null @@ -1,90 +0,0 @@ -// src/engine/editor.cpp:222:0 - -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, bonsai_futex *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. - b32 DrawChildren = True; - b32 DidToggle = False; - if (Name.Count) - { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle bonsai_futex", Element), Params)) - { - DidToggle = True; - PushNewRow(Ui); - } - else - { - DrawChildren = False; - } - } - - if (DrawChildren) - { - PushTableStart(Ui); - if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u32*,&Element->SignalValue), - CSz("SignalValue"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u32*,&Element->ThreadsWaiting), - CSz("ThreadsWaiting"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - Cast(b8*,&Element->Initialized), - CSz("Initialized"), - &DefaultUiRenderParams_Checkbox - ); - - - - - - PushNewRow(Ui); - if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); - } - else - { - PushNewRow(Ui); - } - - } - else - { - PushColumn(Ui, Name, Params); - PushColumn(Ui, CSz("(null)"), Params); - PushNewRow(Ui); - } - -} - diff --git a/generated/do_editor_ui_for_compound_type_bonsai_stdlib.h b/generated/do_editor_ui_for_compound_type_bonsai_stdlib.h deleted file mode 100644 index 9bb7e3baa..000000000 --- a/generated/do_editor_ui_for_compound_type_bonsai_stdlib.h +++ /dev/null @@ -1,113 +0,0 @@ -// src/engine/editor.cpp:153:0 - -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, bonsai_stdlib *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. - b32 DrawChildren = True; - b32 DidToggle = False; - if (Name.Count) - { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle bonsai_stdlib", Element), Params)) - { - DidToggle = True; - PushNewRow(Ui); - } - else - { - DrawChildren = False; - } - } - - if (DrawChildren) - { - PushTableStart(Ui); - if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(os*,&Element->Os), - CSz("Os"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(platform*,&Element->Plat), - CSz("Plat"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(thread_local_state*, Element->ThreadStates), - CSz("ThreadStates"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(texture_block_array*,&Element->AllTextures), - CSz("AllTextures"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(debug_state*,&Element->DebugState), - CSz("DebugState"), - Params - ); - if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); - } - else - { - PushNewRow(Ui); - } - - } - else - { - PushColumn(Ui, Name, Params); - PushColumn(Ui, CSz("(null)"), Params); - PushNewRow(Ui); - } - -} - 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 185d80401..c1bd9638b 100644 --- a/generated/do_editor_ui_for_compound_type_brush_layer.h +++ b/generated/do_editor_ui_for_compound_type_brush_layer.h @@ -1,8 +1,11 @@ -// src/engine/editor.cpp:344:0 +// src/engine/editor.h:303:0 +struct brush_layer; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, brush_layer *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) + -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, brush_layer *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) { + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x133E0EA1); + if (Element) { // NOTE(Jesse): This is wacky as fuck, but it's a pretty easy way to support @@ -11,7 +14,7 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, brush_layer *Element, cs Name b32 DidToggle = False; if (Name.Count) { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle brush_layer", Element), Params)) + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle brush_layer", Element, ThisHash), Params)) { DidToggle = True; PushNewRow(Ui); @@ -24,26 +27,48 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, brush_layer *Element, cs Name if (DrawChildren) { - PushTableStart(Ui); + if (Name.Count) { PushTableStart(Ui); } + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(brush_settings*,&Element->Settings), - CSz("Settings"), - Params - ); + + + { + + + + cs MemberName = {}; + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(brush_settings*, &Element->Settings), + MemberName, + ThisHash, + Params + ); + + + + } + { + + + + cs MemberName = CSz("PrevSettings"); + + + } + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); + if (Name.Count) { PushTableEnd(Ui); } } else { diff --git a/generated/do_editor_ui_for_compound_type_brush_settings.h b/generated/do_editor_ui_for_compound_type_brush_settings.h deleted file mode 100644 index ab108cc34..000000000 --- a/generated/do_editor_ui_for_compound_type_brush_settings.h +++ /dev/null @@ -1,197 +0,0 @@ -// src/engine/editor.cpp:108:0 - -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, brush_settings *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. - b32 DrawChildren = True; - b32 DidToggle = False; - if (Name.Count) - { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle brush_settings", Element), Params)) - { - DidToggle = True; - PushNewRow(Ui); - } - else - { - DrawChildren = False; - } - } - - if (DrawChildren) - { - PushTableStart(Ui); - if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(brush_layer_type*,&Element->Type), - CSz("Type"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(noise_layer*,&Element->Noise), - CSz("Noise"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(shape_layer*,&Element->Shape), - CSz("Shape"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(world_edit_mode*,&Element->Mode), - CSz("Mode"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(world_edit_mode_modifier*,&Element->Modifier), - CSz("Modifier"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(s32*,&Element->Iterations), - CSz("Iterations"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(rect3i*,&Element->Offset), - CSz("Offset"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(v3i*,&Element->NoiseBasisOffset), - CSz("NoiseBasisOffset"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(v3*,&Element->RGBColor), - CSz("RGBColor"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(b8*,&Element->Invert), - CSz("Invert"), - Params - ); - - - - - - - - PushNewRow(Ui); - if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); - } - else - { - PushNewRow(Ui); - } - - } - else - { - PushColumn(Ui, Name, Params); - PushColumn(Ui, CSz("(null)"), Params); - PushNewRow(Ui); - } - -} - diff --git a/generated/do_editor_ui_for_compound_type_camera.h b/generated/do_editor_ui_for_compound_type_camera.h deleted file mode 100644 index 9b462e349..000000000 --- a/generated/do_editor_ui_for_compound_type_camera.h +++ /dev/null @@ -1,287 +0,0 @@ -// src/engine/editor.cpp:329:0 - -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, camera *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. - b32 DrawChildren = True; - b32 DidToggle = False; - if (Name.Count) - { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle camera", Element), Params)) - { - DidToggle = True; - PushNewRow(Ui); - } - else - { - DrawChildren = False; - } - } - - if (DrawChildren) - { - PushTableStart(Ui); - if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(frustum*,&Element->Frust), - CSz("Frust"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(cp*,&Element->CurrentP), - CSz("CurrentP"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(v3*,&Element->RenderSpacePosition), - CSz("RenderSpacePosition"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(r32*,&Element->Pitch), - CSz("Pitch"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(r32*,&Element->Roll), - CSz("Roll"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(r32*,&Element->Yaw), - CSz("Yaw"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(r32*,&Element->DistanceFromTarget), - CSz("DistanceFromTarget"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(r32*,&Element->TargetPitch), - CSz("TargetPitch"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(r32*,&Element->TargetRoll), - CSz("TargetRoll"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(r32*,&Element->TargetYaw), - CSz("TargetYaw"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(r32*,&Element->TargetDistanceFromTarget), - CSz("TargetDistanceFromTarget"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(r32*,&Element->Blend), - CSz("Blend"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(v3*,&Element->Front), - CSz("Front"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(v3*,&Element->Right), - CSz("Right"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(v3*,&Element->Up), - CSz("Up"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(entity_id*,&Element->GhostId), - CSz("GhostId"), - Params - ); - if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); - } - else - { - PushNewRow(Ui); - } - - } - else - { - PushColumn(Ui, Name, Params); - PushColumn(Ui, CSz("(null)"), Params); - PushNewRow(Ui); - } - -} - 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 782ad1b9e..674823865 100644 --- a/generated/do_editor_ui_for_compound_type_chunk_data.h +++ b/generated/do_editor_ui_for_compound_type_chunk_data.h @@ -1,8 +1,11 @@ -// src/engine/editor.cpp:252:0 +// src/engine/editor.h:305:0 +struct chunk_data; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, chunk_data *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) + -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, chunk_data *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) { + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x27DCE418); + if (Element) { // NOTE(Jesse): This is wacky as fuck, but it's a pretty easy way to support @@ -11,7 +14,7 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, chunk_data *Element, cs Name, b32 DidToggle = False; if (Name.Count) { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle chunk_data", Element), Params)) + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle chunk_data", Element, ThisHash), Params)) { DidToggle = True; PushNewRow(Ui); @@ -24,15 +27,24 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, chunk_data *Element, cs Name, if (DrawChildren) { - PushTableStart(Ui); + if (Name.Count) { PushTableStart(Ui); } + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(chunk_flag*,&Element->Flags), - CSz("Flags"), - Params - ); + + + { + + + + cs MemberName = CSz("Dim"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v3i*, &Element->Dim), + MemberName, + ThisHash, + Params + ); @@ -40,14 +52,25 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, chunk_data *Element, cs Name, + + + + } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(v3i*,&Element->Dim), - CSz("Dim"), - Params - ); + + { + + + + cs MemberName = CSz("Occupancy"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u64*, Element->Occupancy), + MemberName, + ThisHash, + Params + ); @@ -55,31 +78,68 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, chunk_data *Element, cs Name, + PushNewRow(Ui); + + + + } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(voxel*, Element->Voxels), - CSz("Voxels"), - Params - ); + + { + + + + cs MemberName = CSz("xOccupancyBorder"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u64*, Element->xOccupancyBorder), + MemberName, + ThisHash, + Params + ); + + + PushNewRow(Ui); + + } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(voxel_lighting*, Element->VoxelLighting), - CSz("VoxelLighting"), - Params - ); + + { + + + + cs MemberName = CSz("FaceMasks"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u64*, Element->FaceMasks), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); + if (Name.Count) { PushTableEnd(Ui); } } else { diff --git a/generated/do_editor_ui_for_compound_type_chunk_thumbnail.h b/generated/do_editor_ui_for_compound_type_chunk_thumbnail.h deleted file mode 100644 index 982a1e3b5..000000000 --- a/generated/do_editor_ui_for_compound_type_chunk_thumbnail.h +++ /dev/null @@ -1,68 +0,0 @@ -// src/engine/editor.cpp:338:0 - -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, chunk_thumbnail *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. - b32 DrawChildren = True; - b32 DidToggle = False; - if (Name.Count) - { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle chunk_thumbnail", Element), Params)) - { - DidToggle = True; - PushNewRow(Ui); - } - else - { - DrawChildren = False; - } - } - - if (DrawChildren) - { - PushTableStart(Ui); - if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(world_chunk*,&Element->Chunk), - CSz("Chunk"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(asset_thumbnail*,&Element->Thumbnail), - CSz("Thumbnail"), - Params - ); - if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); - } - else - { - PushNewRow(Ui); - } - - } - else - { - PushColumn(Ui, Name, Params); - PushColumn(Ui, CSz("(null)"), Params); - PushNewRow(Ui); - } - -} - 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 dd2acd392..e36ddb1f4 100644 --- a/generated/do_editor_ui_for_compound_type_collision_event.h +++ b/generated/do_editor_ui_for_compound_type_collision_event.h @@ -1,8 +1,11 @@ -// src/engine/editor.cpp:316:0 +// src/engine/editor.h:305:0 +struct collision_event; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, collision_event *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) + -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, collision_event *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) { + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x29EED98A); + if (Element) { // NOTE(Jesse): This is wacky as fuck, but it's a pretty easy way to support @@ -11,7 +14,7 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, collision_event *Element, cs b32 DidToggle = False; if (Name.Count) { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle collision_event", Element), Params)) + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle collision_event", Element, ThisHash), Params)) { DidToggle = True; PushNewRow(Ui); @@ -24,47 +27,78 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, collision_event *Element, cs if (DrawChildren) { - PushTableStart(Ui); + if (Name.Count) { PushTableStart(Ui); } + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u32*,&Element->FrameIndex), - CSz("FrameIndex"), - Params - ); + + { + + + + cs MemberName = CSz("FrameIndex"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u32*, &Element->FrameIndex), + MemberName, + ThisHash, + Params + ); - PushNewRow(Ui); - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u32*,&Element->Count), - CSz("Count"), - Params - ); + PushNewRow(Ui); + } + + { + + + + cs MemberName = CSz("Count"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u32*, &Element->Count), + MemberName, + ThisHash, + Params + ); - PushNewRow(Ui); - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(cp*,&Element->MinP), - CSz("MinP"), - Params - ); + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("MinP"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(cp*, &Element->MinP), + MemberName, + ThisHash, + Params + ); @@ -72,16 +106,39 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, collision_event *Element, cs + + + + } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(cp*,&Element->MaxP), - CSz("MaxP"), - Params - ); + + { + + + + cs MemberName = CSz("MaxP"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(cp*, &Element->MaxP), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); + if (Name.Count) { PushTableEnd(Ui); } } else { 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 68351bedd..f750c1ae0 100644 --- a/generated/do_editor_ui_for_compound_type_debug_state.h +++ b/generated/do_editor_ui_for_compound_type_debug_state.h @@ -1,8 +1,11 @@ -// src/engine/editor.cpp:149:0 +// src/engine/editor.h:305:0 +struct debug_state; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, debug_state *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) + -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, debug_state *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) { + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x2186A9AB); + if (Element) { // NOTE(Jesse): This is wacky as fuck, but it's a pretty easy way to support @@ -11,7 +14,7 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, debug_state *Element, cs Name b32 DidToggle = False; if (Name.Count) { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle debug_state", Element), Params)) + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle debug_state", Element, ThisHash), Params)) { DidToggle = True; PushNewRow(Ui); @@ -24,387 +27,1219 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, debug_state *Element, cs Name if (DrawChildren) { - PushTableStart(Ui); + if (Name.Count) { PushTableStart(Ui); } + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - Cast(b8*,&Element->Initialized), - CSz("Initialized"), - &DefaultUiRenderParams_Checkbox - ); + + { + + + + cs MemberName = CSz("Initialized"); + DoEditorUi(Ui, + Window, + Cast(b8*, &Element->Initialized), + MemberName, + ThisHash, + &DefaultUiRenderParams_Checkbox + ); - PushNewRow(Ui); - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u32*,&Element->UIType), - CSz("UIType"), - Params - ); + PushNewRow(Ui); + } + + { + + + + cs MemberName = CSz("UIType"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u32*, &Element->UIType), + MemberName, + ThisHash, + Params + ); - PushNewRow(Ui); - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u64*,&Element->BytesBufferedToCard), - CSz("BytesBufferedToCard"), - Params - ); + PushNewRow(Ui); + } + - PushNewRow(Ui); + { + + + + cs MemberName = CSz("BytesBufferedToCard"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u64*, &Element->BytesBufferedToCard), + MemberName, + ThisHash, + Params + ); - DoEditorUi(Ui, - Window, - Cast(b8*,&Element->DebugDoScopeProfiling), - CSz("DebugDoScopeProfiling"), - &DefaultUiRenderParams_Checkbox - ); - PushNewRow(Ui); - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u64*,&Element->NumScopes), - CSz("NumScopes"), - Params - ); + PushNewRow(Ui); + } + + { + + + + cs MemberName = CSz("DebugDoScopeProfiling"); + DoEditorUi(Ui, + Window, + Cast(b8*, &Element->DebugDoScopeProfiling), + MemberName, + ThisHash, + &DefaultUiRenderParams_Checkbox + ); - PushNewRow(Ui); - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u32*,&Element->DrawCallCountLastFrame), - CSz("DrawCallCountLastFrame"), - Params - ); + PushNewRow(Ui); + } + + { + + + + cs MemberName = CSz("NumScopes"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u64*, &Element->NumScopes), + MemberName, + ThisHash, + Params + ); - PushNewRow(Ui); - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u32*,&Element->VertexCountLastFrame), - CSz("VertexCountLastFrame"), - Params - ); + PushNewRow(Ui); - PushNewRow(Ui); + } + + + { + + + + cs MemberName = CSz("DrawCallCountLastFrame"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u32*, &Element->DrawCallCountLastFrame), + MemberName, + ThisHash, + Params + ); + - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(picked_world_chunk*, Element->PickedChunk), - CSz("PickedChunk"), - Params - ); + PushNewRow(Ui); + + } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(picked_world_chunk*, Element->HoverChunk), - CSz("HoverChunk"), - Params - ); + + { + + + + cs MemberName = CSz("VertexCountLastFrame"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u32*, &Element->VertexCountLastFrame), + MemberName, + ThisHash, + Params + ); + + PushNewRow(Ui); + + + } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(debug_thread_state*, Element->ThreadStates), - CSz("ThreadStates"), - Params - ); + { + + + + cs MemberName = CSz("FrameEnd"); + + + + + } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(memory_arena*, Element->MetaTableNameStringsArena), - CSz("MetaTableNameStringsArena"), - Params - ); + + { + + + + cs MemberName = CSz("FrameBegin"); + + + + } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(renderer_2d*, Element->UiGroup), - CSz("UiGroup"), - Params - ); + + { + + + + cs MemberName = CSz("DebugRegisterArena"); + + + + } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(untextured_3d_geometry_buffer*,&Element->LineMesh), - CSz("LineMesh"), - Params - ); + + { + + + + cs MemberName = CSz("UnregisterArena"); + + + + } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(selected_arenas*, Element->SelectedArenas), - CSz("SelectedArenas"), - Params - ); + + { + + + + cs MemberName = CSz("WorkerThreadAdvanceDebugSystem"); + + + + } - DoEditorUi(Ui, - Window, - Cast(b8*,&Element->DisplayDebugMenu), - CSz("DisplayDebugMenu"), - &DefaultUiRenderParams_Checkbox - ); + { + + + + cs MemberName = CSz("MainThreadAdvanceDebugSystem"); + - PushNewRow(Ui); - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(debug_profile_scope*, Element->HotFunction), - CSz("HotFunction"), - Params - ); + + + + + } + + + { + + + + cs MemberName = CSz("MutexWait"); + + + + } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u64_cursor*,&Element->HistogramSamples), - CSz("HistogramSamples"), - Params - ); + + { + + + + cs MemberName = CSz("MutexAquired"); + + + + } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(debug_profile_scope*,&Element->FreeScopeSentinel), - CSz("FreeScopeSentinel"), - Params - ); + + { + + + + cs MemberName = CSz("MutexReleased"); + + + + } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(umm*,&Element->MinCycles), - CSz("MinCycles"), - Params - ); + { + + + + cs MemberName = CSz("GetProfileScope"); + - PushNewRow(Ui); + - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(umm*,&Element->MaxCycles), - CSz("MaxCycles"), - Params - ); + } + + { + + + + cs MemberName = CSz("Debug_Allocate"); + - PushNewRow(Ui); - if (ToggleButton(Ui, CSz("v Frames[(128)]"), CSz("> Frames[(128)]"), UiId(Window, "toggle debug_state frame_stats Frames", Element->Frames), Params )) - { - OPEN_INDENT_FOR_TOGGLEABLE_REGION(); - PushNewRow(Ui); - RangeIterator(ArrayIndex, (128)) - { - DoEditorUi(Ui, Window, Element->Frames+ArrayIndex, FSz("Frames[%d]", ArrayIndex), Params); - - } - CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); + + + } - PushNewRow(Ui); + + { + + + + cs MemberName = CSz("RegisterThread"); + + + + + + + + + } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u32*,&Element->ReadScopeIndex), - CSz("ReadScopeIndex"), - Params - ); + { + + + + cs MemberName = CSz("WriteMemoryRecord"); + - PushNewRow(Ui); + - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(s32*,&Element->FreeScopeCount), - CSz("FreeScopeCount"), - Params - ); + } + + { + + + + cs MemberName = CSz("ClearMemoryRecordsFor"); + - PushNewRow(Ui); - if (ToggleButton(Ui, CSz("v RegisteredMemoryArenas[(1024)]"), CSz("> RegisteredMemoryArenas[(1024)]"), UiId(Window, "toggle debug_state registered_memory_arena RegisteredMemoryArenas", Element->RegisteredMemoryArenas), Params )) - { - OPEN_INDENT_FOR_TOGGLEABLE_REGION(); - PushNewRow(Ui); - RangeIterator(ArrayIndex, (1024)) + + + + } + + + { + + + + cs MemberName = CSz("TrackDrawCall"); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("GetThreadLocalState"); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("DebugValue_r32"); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("DebugValue_u32"); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("DebugValue_u64"); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("DumpScopeTreeDataToConsole"); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("OpenAndInitializeDebugWindow"); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("ProcessInputAndRedrawWindow"); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("(anonymous)"); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("(anonymous)"); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("(anonymous)"); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("GetReadScopeTree"); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("GetWriteScopeTree"); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("PickedChunk"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(picked_world_chunk*, Element->PickedChunk), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("HoverChunk"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(picked_world_chunk*, Element->HoverChunk), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("ThreadStates"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(debug_thread_state*, Element->ThreadStates), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("MetaTableNameStringsArena"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(memory_arena*, Element->MetaTableNameStringsArena), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("UiGroup"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(renderer_2d*, Element->UiGroup), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("LineMesh"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(untextured_3d_geometry_buffer*, &Element->LineMesh), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("SelectedArenas"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(selected_arenas*, Element->SelectedArenas), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("DisplayDebugMenu"); + DoEditorUi(Ui, + Window, + Cast(b8*, &Element->DisplayDebugMenu), + MemberName, + ThisHash, + &DefaultUiRenderParams_Checkbox + ); + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("HotFunction"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(debug_profile_scope*, Element->HotFunction), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("HistogramSamples"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u64_cursor*, &Element->HistogramSamples), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("HistogramFutex"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(bonsai_futex*, &Element->HistogramFutex), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("FreeScopeSentinel"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(debug_profile_scope*, &Element->FreeScopeSentinel), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("MinCycles"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(umm*, &Element->MinCycles), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("MaxCycles"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(umm*, &Element->MaxCycles), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("Frames"); + + + if (ToggleButton(Ui, + CSz("v Frames[(128)]"), + CSz("> Frames[(128)]"), + UiId(Window, "toggle debug_state frame_stats Frames", Element->Frames, ThisHash), + Params )) { - DoEditorUi(Ui, Window, Element->RegisteredMemoryArenas+ArrayIndex, FSz("RegisteredMemoryArenas[%d]", ArrayIndex), Params); - + OPEN_INDENT_FOR_TOGGLEABLE_REGION(); + PushNewRow(Ui); + s32 End = (128); + + RangeIterator(ArrayIndex, End) + { + DoEditorUi(Ui, + Window, + Element->Frames+ArrayIndex, + FSz("Frames[%d]", ArrayIndex), + ThisHash, + Params); + + + } + CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); + PushNewRow(Ui); + + + + + + } - PushNewRow(Ui); + + { + + + + cs MemberName = CSz("ReadScopeIndex"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u32*, &Element->ReadScopeIndex), + MemberName, + ThisHash, + Params + ); + + + + + + PushNewRow(Ui); + + + + } - if (ToggleButton(Ui, CSz("v TrackedDrawCalls[(4096)]"), CSz("> TrackedDrawCalls[(4096)]"), UiId(Window, "toggle debug_state debug_draw_call TrackedDrawCalls", Element->TrackedDrawCalls), Params )) - { - OPEN_INDENT_FOR_TOGGLEABLE_REGION(); + + { + + + + cs MemberName = CSz("FreeScopeCount"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(s32*, &Element->FreeScopeCount), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("RegisteredMemoryArenas"); + + + if (ToggleButton(Ui, + CSz("v RegisteredMemoryArenas[(1024)]"), + CSz("> RegisteredMemoryArenas[(1024)]"), + UiId(Window, "toggle debug_state registered_memory_arena RegisteredMemoryArenas", Element->RegisteredMemoryArenas, ThisHash), + Params )) + { + OPEN_INDENT_FOR_TOGGLEABLE_REGION(); + PushNewRow(Ui); + s32 End = (1024); + + RangeIterator(ArrayIndex, End) + { + DoEditorUi(Ui, + Window, + Element->RegisteredMemoryArenas+ArrayIndex, + FSz("RegisteredMemoryArenas[%d]", ArrayIndex), + ThisHash, + Params); + + + } + CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); + } PushNewRow(Ui); - RangeIterator(ArrayIndex, (4096)) + + + + + + + } + + + { + + + + cs MemberName = CSz("TrackedDrawCalls"); + + + if (ToggleButton(Ui, + CSz("v TrackedDrawCalls[(4096)]"), + CSz("> TrackedDrawCalls[(4096)]"), + UiId(Window, "toggle debug_state debug_draw_call TrackedDrawCalls", Element->TrackedDrawCalls, ThisHash), + Params )) { - DoEditorUi(Ui, Window, Element->TrackedDrawCalls+ArrayIndex, FSz("TrackedDrawCalls[%d]", ArrayIndex), Params); - + OPEN_INDENT_FOR_TOGGLEABLE_REGION(); + PushNewRow(Ui); + s32 End = (4096); + + RangeIterator(ArrayIndex, End) + { + DoEditorUi(Ui, + Window, + Element->TrackedDrawCalls+ArrayIndex, + FSz("TrackedDrawCalls[%d]", ArrayIndex), + ThisHash, + Params); + + + } + CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); + PushNewRow(Ui); + + + + + + } - PushNewRow(Ui); + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); + if (Name.Count) { PushTableEnd(Ui); } } else { diff --git a/generated/do_editor_ui_for_compound_type_engine_debug.h b/generated/do_editor_ui_for_compound_type_engine_debug.h deleted file mode 100644 index bef647892..000000000 --- a/generated/do_editor_ui_for_compound_type_engine_debug.h +++ /dev/null @@ -1,284 +0,0 @@ -// src/engine/editor.cpp:419:0 - -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, engine_debug *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. - b32 DrawChildren = True; - b32 DidToggle = False; - if (Name.Count) - { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle engine_debug", Element), Params)) - { - DidToggle = True; - PushNewRow(Ui); - } - else - { - DrawChildren = False; - } - } - - if (DrawChildren) - { - PushTableStart(Ui); - if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(memory_arena*, Element->Memory), - CSz("Memory"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(engine_debug_view_mode*,&Element->ViewMode), - CSz("ViewMode"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(picked_world_chunk_static_buffer*,&Element->PickedChunks), - CSz("PickedChunks"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(texture_ptr_block_array*,&Element->Textures), - CSz("Textures"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(ui_debug*,&Element->UiDebug), - CSz("UiDebug"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(render_debug*,&Element->Render), - CSz("Render"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(b8*,&Element->DrawEntityCollisionVolumes), - CSz("DrawEntityCollisionVolumes"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(b8*,&Element->DrawWorldAxies), - CSz("DrawWorldAxies"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(b8*,&Element->TriggerRuntimeBreak), - CSz("TriggerRuntimeBreak"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(b8*,&Element->ResetAssetNodeView), - CSz("ResetAssetNodeView"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u8*,&Element->PickedChunkState), - CSz("PickedChunkState"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(world_chunk*, Element->PickedChunk), - CSz("PickedChunk"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(asset_window_view_mode*,&Element->AssetWindowViewMode), - CSz("AssetWindowViewMode"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(asset_id*,&Element->SelectedAsset), - CSz("SelectedAsset"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u64*,&Element->ModelIndex), - CSz("ModelIndex"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(entity_id*,&Element->SelectedEntity), - CSz("SelectedEntity"), - Params - ); - if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); - } - else - { - PushNewRow(Ui); - } - - } - else - { - PushColumn(Ui, Name, Params); - PushColumn(Ui, CSz("(null)"), Params); - PushNewRow(Ui); - } - -} - diff --git a/generated/do_editor_ui_for_compound_type_engine_resources.h b/generated/do_editor_ui_for_compound_type_engine_resources.h deleted file mode 100644 index b113db3bd..000000000 --- a/generated/do_editor_ui_for_compound_type_engine_resources.h +++ /dev/null @@ -1,429 +0,0 @@ -// src/engine/editor.cpp:441:0 - -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, engine_resources *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. - b32 DrawChildren = True; - b32 DidToggle = False; - if (Name.Count) - { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle engine_resources", Element), Params)) - { - DidToggle = True; - PushNewRow(Ui); - } - else - { - DrawChildren = False; - } - } - - if (DrawChildren) - { - PushTableStart(Ui); - if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(engine_settings*,&Element->Settings), - CSz("Settings"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(bonsai_stdlib*,&Element->Stdlib), - CSz("Stdlib"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(renderer_2d*,&Element->Ui), - CSz("Ui"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(application_api*,&Element->GameApi), - CSz("GameApi"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(hotkeys*,&Element->Hotkeys), - CSz("Hotkeys"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(maybe_ray*,&Element->MaybeMouseRay), - CSz("MaybeMouseRay"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(world*, Element->World), - CSz("World"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(game_state*, Element->GameState), - CSz("GameState"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(graphics*,&Element->Graphics), - CSz("Graphics"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(file_traversal_node*,&Element->RequestedGameLibReloadNode), - CSz("RequestedGameLibReloadNode"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(game_lib_reload_behavior*,&Element->RequestedGameLibReloadBehavior), - CSz("RequestedGameLibReloadBehavior"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(heap_allocator*,&Element->Heap), - CSz("Heap"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(memory_arena*, Element->GameMemory), - CSz("GameMemory"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(memory_arena*, Element->WorldUpdateMemory), - CSz("WorldUpdateMemory"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(entity*, Element->EntityTable), - CSz("EntityTable"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(asset_system*,&Element->AssetSystem), - CSz("AssetSystem"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u32*,&Element->FrameIndex), - CSz("FrameIndex"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(tiered_mesh_freelist*,&Element->geo_u3d_MeshFreelist), - CSz("geo_u3d_MeshFreelist"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(tiered_mesh_freelist*,&Element->world_chunk_MeshFreelist), - CSz("world_chunk_MeshFreelist"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(debug_state*, Element->DebugState), - CSz("DebugState"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(engine_debug*,&Element->EngineDebug), - CSz("EngineDebug"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(level_editor*,&Element->Editor), - CSz("Editor"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(maybe_picked_voxel*,&Element->MousedOverVoxel), - CSz("MousedOverVoxel"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(maybe_standing_spot*,&Element->ClosestStandingSpotToCursor), - CSz("ClosestStandingSpotToCursor"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(maybe_entity_ptr*,&Element->HoverEntity), - CSz("HoverEntity"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(render_entity_to_texture_group*,&Element->RTTGroup), - CSz("RTTGroup"), - Params - ); - if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); - } - else - { - PushNewRow(Ui); - } - - } - else - { - PushColumn(Ui, Name, Params); - PushColumn(Ui, CSz("(null)"), Params); - PushNewRow(Ui); - } - -} - diff --git a/generated/do_editor_ui_for_compound_type_engine_settings.h b/generated/do_editor_ui_for_compound_type_engine_settings.h deleted file mode 100644 index 1e7dafaf5..000000000 --- a/generated/do_editor_ui_for_compound_type_engine_settings.h +++ /dev/null @@ -1,53 +0,0 @@ -// src/engine/editor.cpp:437:0 - -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, engine_settings *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. - b32 DrawChildren = True; - b32 DidToggle = False; - if (Name.Count) - { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle engine_settings", Element), Params)) - { - DidToggle = True; - PushNewRow(Ui); - } - else - { - DrawChildren = False; - } - } - - if (DrawChildren) - { - PushTableStart(Ui); - if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(graphics_settings*,&Element->Graphics), - CSz("Graphics"), - Params - ); - if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); - } - else - { - PushNewRow(Ui); - } - - } - else - { - PushColumn(Ui, Name, Params); - PushColumn(Ui, CSz("(null)"), Params); - PushNewRow(Ui); - } - -} - diff --git a/generated/do_editor_ui_for_compound_type_entity.h b/generated/do_editor_ui_for_compound_type_entity.h index 2e7e69ca9..e17ea0e53 100644 --- a/generated/do_editor_ui_for_compound_type_entity.h +++ b/generated/do_editor_ui_for_compound_type_entity.h @@ -1,8 +1,11 @@ -// src/engine/editor.cpp:291:0 +// src/engine/editor.h:305:0 +struct entity; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, entity *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) + -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, entity *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) { + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x2D655F50); + if (Element) { // NOTE(Jesse): This is wacky as fuck, but it's a pretty easy way to support @@ -11,7 +14,7 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, entity *Element, cs Name, ui_ b32 DidToggle = False; if (Name.Count) { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle entity", Element), Params)) + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle entity", Element, ThisHash), Params)) { DidToggle = True; PushNewRow(Ui); @@ -24,230 +27,406 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, entity *Element, cs Name, ui_ if (DrawChildren) { - PushTableStart(Ui); + if (Name.Count) { PushTableStart(Ui); } + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(entity_id*,&Element->Id), - CSz("Id"), - Params - ); + + + { + + + + cs MemberName = CSz("Id"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(entity_id*, &Element->Id), + MemberName, + ThisHash, + Params + ); + + + + } -DoEditorUi_entity_P(Ui, Window, Element, CSz("cp P"), EDITOR_UI_FUNCTION_INSTANCE_NAMES); + + { + + + + cs MemberName = CSz("P"); + DoEditorUi_entity_P(Ui, Window, Element, CSz("cp P"), ThisHash, EDITOR_UI_FUNCTION_INSTANCE_NAMES); + + + + } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(v3*,&Element->EulerAngles), - CSz("EulerAngles"), - Params -,-PI32, PI32 ); + + { + + + + cs MemberName = CSz("EulerAngles"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v3*, &Element->EulerAngles), + MemberName, + ThisHash, + Params + , -PI32, PI32 ); + + + + } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(r32*,&Element->Scale), - CSz("Scale"), - Params - ); + { + + + + cs MemberName = CSz("Scale"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(r32*, &Element->Scale), + MemberName, + ThisHash, + Params + ); - PushNewRow(Ui); - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(v3*,&Element->_CollisionVolumeRadius), - CSz("_CollisionVolumeRadius"), - Params - ); + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("_CollisionVolumeRadius"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v3*, &Element->_CollisionVolumeRadius), + MemberName, + ThisHash, + Params + ); + + + + } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(physics*,&Element->Physics), - CSz("Physics"), - Params - ); + + { + + + + cs MemberName = CSz("Physics"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(physics*, &Element->Physics), + MemberName, + ThisHash, + Params + ); + + + + } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(asset_id*,&Element->AssetId), - CSz("AssetId"), - Params - ); + { + + + + cs MemberName = CSz("AssetId"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(asset_id*, &Element->AssetId), + MemberName, + ThisHash, + Params + ); + + + + + } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u64*,&Element->ModelIndex), - CSz("ModelIndex"), - Params - ); + { + + + + cs MemberName = CSz("ModelIndex"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u64*, &Element->ModelIndex), + MemberName, + ThisHash, + Params + ); - PushNewRow(Ui); - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(collision_event*,&Element->LastResolvedCollision), - CSz("LastResolvedCollision"), - Params - ); + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("LastResolvedCollision"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(collision_event*, &Element->LastResolvedCollision), + MemberName, + ThisHash, + Params + ); + + + + } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(entity_position_info*,&Element->LastResolvedPosInfo), - CSz("LastResolvedPosInfo"), - Params - ); + + { + + + + cs MemberName = CSz("LastResolvedPosInfo"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(entity_position_info*, &Element->LastResolvedPosInfo), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Emitter"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(particle_system*, Element->Emitter), + MemberName, + ThisHash, + Params + ); + + + + } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(particle_system*, Element->Emitter), - CSz("Emitter"), - Params - ); + + { + + + + cs MemberName = CSz("State"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(entity_state*, &Element->State), + MemberName, + ThisHash, + Params + ); + + + + } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(entity_state*,&Element->State), - CSz("State"), - Params - ); + + { + + + + cs MemberName = CSz("Behavior"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(entity_behavior_flags*, &Element->Behavior), + MemberName, + ThisHash, + Params + ); + + + + } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(entity_behavior_flags*,&Element->Behavior), - CSz("Behavior"), - Params - ); + { + + + + cs MemberName = CSz("Carrying"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(entity_id*, &Element->Carrying), + MemberName, + ThisHash, + Params + ); + + + + + } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(entity_id*,&Element->Carrying), - CSz("Carrying"), - Params - ); + + { + + + + cs MemberName = CSz("UserType"); + if (EntityUserDataEditorUi) {EntityUserDataEditorUi(Ui, Window, &Element->UserType, &Element->UserData, Name, ThisHash, EDITOR_UI_FUNCTION_INSTANCE_NAMES);} + else {DoEditorUi(Ui, Window, &Element->UserType, Name, ThisHash, EDITOR_UI_FUNCTION_INSTANCE_NAMES); } + ; + PushNewRow(Ui); + } - if (EntityUserDataEditorUi) {EntityUserDataEditorUi(Ui, Window, &Element->UserType, &Element->UserData, Name, EDITOR_UI_FUNCTION_INSTANCE_NAMES);} - else {DoEditorUi(Ui, Window, &Element->UserType, Name, EDITOR_UI_FUNCTION_INSTANCE_NAMES); } -; + { + + + + cs MemberName = CSz("UserData"); + if (EntityUserDataEditorUi) { /* User took control, skip this because it's intended */ } + else {DoEditorUi(Ui, Window, &Element->UserData, Name, ThisHash, EDITOR_UI_FUNCTION_INSTANCE_NAMES); } + ; - PushNewRow(Ui); - if (EntityUserDataEditorUi) { /* User took control, skip this because it's intended */ } - else {DoEditorUi(Ui, Window, &Element->UserData, Name, EDITOR_UI_FUNCTION_INSTANCE_NAMES); } -; + PushNewRow(Ui); + } - PushNewRow(Ui); if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); + if (Name.Count) { PushTableEnd(Ui); } } else { 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 5ca04b7e6..b0b6199e2 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,8 +1,11 @@ -// examples/turn_based/game_types.h:84:0 +// src/engine/editor.h:303:0 +struct entity_aggregate_type; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, entity_aggregate_type *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) + -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, entity_aggregate_type *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) { + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x22759A9E); + if (Element) { // NOTE(Jesse): This is wacky as fuck, but it's a pretty easy way to support @@ -11,7 +14,7 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, entity_aggregate_type *Elemen b32 DidToggle = False; if (Name.Count) { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle entity_aggregate_type", Element), Params)) + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle entity_aggregate_type", Element, ThisHash), Params)) { DidToggle = True; PushNewRow(Ui); @@ -24,32 +27,64 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, entity_aggregate_type *Elemen if (DrawChildren) { - PushTableStart(Ui); + if (Name.Count) { PushTableStart(Ui); } + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(entity_type*,&Element->Type), - CSz("Type"), - Params - ); + + + { + + + + cs MemberName = CSz("Type"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(entity_type*, &Element->Type), + MemberName, + ThisHash, + Params + ); + + + + } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(entity_status*,&Element->Status), - CSz("Status"), - Params - ); + + { + + + + cs MemberName = CSz("Status"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(entity_status*, &Element->Status), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); + if (Name.Count) { PushTableEnd(Ui); } } else { 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 881f32d2f..aec52f8c7 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,8 +1,11 @@ -// examples/turn_based/game_types.h:98:0 +// src/engine/editor.h:303:0 +struct entity_game_data; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, entity_game_data *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) + -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, entity_game_data *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) { + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x1ACA7D88); + if (Element) { // NOTE(Jesse): This is wacky as fuck, but it's a pretty easy way to support @@ -11,7 +14,7 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, entity_game_data *Element, cs b32 DidToggle = False; if (Name.Count) { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle entity_game_data", Element), Params)) + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle entity_game_data", Element, ThisHash), Params)) { DidToggle = True; PushNewRow(Ui); @@ -24,73 +27,120 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, entity_game_data *Element, cs if (DrawChildren) { - PushTableStart(Ui); + if (Name.Count) { PushTableStart(Ui); } + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u32*,&Element->FireballChargeLevel), - CSz("FireballChargeLevel"), - Params - ); + + { + + + + cs MemberName = CSz("FireballChargeLevel"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u32*, &Element->FireballChargeLevel), + MemberName, + ThisHash, + Params + ); - PushNewRow(Ui); - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u32*,&Element->FireballCharges), - CSz("FireballCharges"), - Params - ); + PushNewRow(Ui); + } + + { + + + + cs MemberName = CSz("FireballCharges"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u32*, &Element->FireballCharges), + MemberName, + ThisHash, + Params + ); - PushNewRow(Ui); - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u32*,&Element->IceBlockCharges), - CSz("IceBlockCharges"), - Params - ); + PushNewRow(Ui); + } + - PushNewRow(Ui); + { + + + + cs MemberName = CSz("IceBlockCharges"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u32*, &Element->IceBlockCharges), + MemberName, + ThisHash, + Params + ); - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u32*,&Element->HoldingItem), - CSz("HoldingItem"), - Params - ); + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("HoldingItem"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u32*, &Element->HoldingItem), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } - PushNewRow(Ui); if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); + if (Name.Count) { PushTableEnd(Ui); } } else { 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 c97bd6f61..086dac927 100644 --- a/generated/do_editor_ui_for_compound_type_entity_id.h +++ b/generated/do_editor_ui_for_compound_type_entity_id.h @@ -1,8 +1,11 @@ -// src/engine/editor.cpp:288:0 +// src/engine/editor.h:305:0 +struct entity_id; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, entity_id *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) + -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, entity_id *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) { + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x25522C9E); + if (Element) { // NOTE(Jesse): This is wacky as fuck, but it's a pretty easy way to support @@ -11,7 +14,7 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, entity_id *Element, cs Name, b32 DidToggle = False; if (Name.Count) { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle entity_id", Element), Params)) + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle entity_id", Element, ThisHash), Params)) { DidToggle = True; PushNewRow(Ui); @@ -24,41 +27,66 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, entity_id *Element, cs Name, if (DrawChildren) { - PushTableStart(Ui); + if (Name.Count) { PushTableStart(Ui); } + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u32*,&Element->Index), - CSz("Index"), - Params - ); + + { + + + + cs MemberName = CSz("Index"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u32*, &Element->Index), + MemberName, + ThisHash, + Params + ); - PushNewRow(Ui); - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u32*,&Element->Generation), - CSz("Generation"), - Params - ); + PushNewRow(Ui); + } + + { + + + + cs MemberName = CSz("Generation"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u32*, &Element->Generation), + MemberName, + ThisHash, + Params + ); - PushNewRow(Ui); + + + + + PushNewRow(Ui); + + + + } + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); + if (Name.Count) { PushTableEnd(Ui); } } else { 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 2cc0709bd..9c931d727 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,8 +1,11 @@ -// src/engine/editor.cpp:319:0 +// src/engine/editor.h:305:0 +struct entity_position_info; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, entity_position_info *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) + -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, entity_position_info *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) { + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x35BC40CA); + if (Element) { // NOTE(Jesse): This is wacky as fuck, but it's a pretty easy way to support @@ -11,7 +14,7 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, entity_position_info *Element b32 DidToggle = False; if (Name.Count) { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle entity_position_info", Element), Params)) + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle entity_position_info", Element, ThisHash), Params)) { DidToggle = True; PushNewRow(Ui); @@ -24,15 +27,24 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, entity_position_info *Element if (DrawChildren) { - PushTableStart(Ui); + if (Name.Count) { PushTableStart(Ui); } + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(cp*,&Element->P), - CSz("P"), - Params - ); + + + { + + + + cs MemberName = CSz("P"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(cp*, &Element->P), + MemberName, + ThisHash, + Params + ); @@ -40,14 +52,25 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, entity_position_info *Element + + + + } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(v3*,&Element->_CollisionVolumeRadius), - CSz("_CollisionVolumeRadius"), - Params - ); + + { + + + + cs MemberName = CSz("_CollisionVolumeRadius"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v3*, &Element->_CollisionVolumeRadius), + MemberName, + ThisHash, + Params + ); @@ -55,32 +78,66 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, entity_position_info *Element + + + + } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(r32*,&Element->Scale), - CSz("Scale"), - Params - ); + { + + + + cs MemberName = CSz("Scale"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(r32*, &Element->Scale), + MemberName, + ThisHash, + Params + ); - PushNewRow(Ui); - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(v3*,&Element->EulerAngles), - CSz("EulerAngles"), - Params - ); + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("EulerAngles"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v3*, &Element->EulerAngles), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); + if (Name.Count) { PushTableEnd(Ui); } } else { 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 561f92b11..5da4da868 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,8 +1,11 @@ -// src/engine/editor.cpp:276:0 +// src/engine/editor.h:305:0 +struct file_traversal_node; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, file_traversal_node *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) + -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, file_traversal_node *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) { + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x26008A1B); + if (Element) { // NOTE(Jesse): This is wacky as fuck, but it's a pretty easy way to support @@ -11,7 +14,7 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, file_traversal_node *Element, b32 DidToggle = False; if (Name.Count) { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle file_traversal_node", Element), Params)) + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle file_traversal_node", Element, ThisHash), Params)) { DidToggle = True; PushNewRow(Ui); @@ -24,56 +27,92 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, file_traversal_node *Element, if (DrawChildren) { - PushTableStart(Ui); + if (Name.Count) { PushTableStart(Ui); } + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(file_traversal_type*,&Element->Type), - CSz("Type"), - Params - ); + + + { + + + + cs MemberName = CSz("Type"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(file_traversal_type*, &Element->Type), + MemberName, + ThisHash, + Params + ); + + + + } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(cs*,&Element->Dir), - CSz("Dir"), - Params - ); + { + + + + cs MemberName = CSz("Dir"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(cs*, &Element->Dir), + MemberName, + ThisHash, + Params + ); - PushNewRow(Ui); - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(cs*,&Element->Name), - CSz("Name"), - Params - ); + PushNewRow(Ui); + + + } + + { + + + + cs MemberName = CSz("Name"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(cs*, &Element->Name), + MemberName, + ThisHash, + Params + ); - PushNewRow(Ui); + + + PushNewRow(Ui); + + + + } + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); + if (Name.Count) { PushTableEnd(Ui); } } else { 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 bb78092de..70669b22c 100644 --- a/generated/do_editor_ui_for_compound_type_fireball_state.h +++ b/generated/do_editor_ui_for_compound_type_fireball_state.h @@ -1,8 +1,11 @@ -// examples/turn_based/game_types.h:107:0 +// src/engine/editor.h:303:0 +struct fireball_state; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, fireball_state *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) + -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, fireball_state *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) { + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x11326A7F); + if (Element) { // NOTE(Jesse): This is wacky as fuck, but it's a pretty easy way to support @@ -11,7 +14,7 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, fireball_state *Element, cs N b32 DidToggle = False; if (Name.Count) { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle fireball_state", Element), Params)) + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle fireball_state", Element, ThisHash), Params)) { DidToggle = True; PushNewRow(Ui); @@ -24,33 +27,65 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, fireball_state *Element, cs N if (DrawChildren) { - PushTableStart(Ui); + if (Name.Count) { PushTableStart(Ui); } + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(r32*,&Element->ChargeLevel), - CSz("ChargeLevel"), - Params - ); + + { + + + + cs MemberName = CSz("ChargeLevel"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(r32*, &Element->ChargeLevel), + MemberName, + ThisHash, + Params + ); - PushNewRow(Ui); - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(cp*,&Element->TargetP), - CSz("TargetP"), - Params - ); + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("TargetP"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(cp*, &Element->TargetP), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); + if (Name.Count) { PushTableEnd(Ui); } } else { diff --git a/generated/do_editor_ui_for_compound_type_frustum.h b/generated/do_editor_ui_for_compound_type_frustum.h deleted file mode 100644 index 119d18605..000000000 --- a/generated/do_editor_ui_for_compound_type_frustum.h +++ /dev/null @@ -1,162 +0,0 @@ -// src/engine/editor.cpp:326:0 - -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, frustum *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. - b32 DrawChildren = True; - b32 DidToggle = False; - if (Name.Count) - { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle frustum", Element), Params)) - { - DidToggle = True; - PushNewRow(Ui); - } - else - { - DrawChildren = False; - } - } - - if (DrawChildren) - { - PushTableStart(Ui); - if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(f32*,&Element->farClip), - CSz("farClip"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(f32*,&Element->nearClip), - CSz("nearClip"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(f32*,&Element->width), - CSz("width"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(f32*,&Element->FOV), - CSz("FOV"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(plane*,&Element->Top), - CSz("Top"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(plane*,&Element->Bot), - CSz("Bot"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(plane*,&Element->Left), - CSz("Left"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(plane*,&Element->Right), - CSz("Right"), - Params - ); - if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); - } - else - { - PushNewRow(Ui); - } - - } - else - { - PushColumn(Ui, Name, Params); - PushColumn(Ui, CSz("(null)"), Params); - PushNewRow(Ui); - } - -} - 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 deleted file mode 100644 index 8c835dfcf..000000000 --- a/generated/do_editor_ui_for_compound_type_g_buffer_render_group.h +++ /dev/null @@ -1,151 +0,0 @@ -// src/engine/editor.cpp:407:0 - -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, g_buffer_render_group *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. - b32 DrawChildren = True; - b32 DidToggle = False; - if (Name.Count) - { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle g_buffer_render_group", Element), Params)) - { - DidToggle = True; - PushNewRow(Ui); - } - else - { - DrawChildren = False; - } - } - - if (DrawChildren) - { - PushTableStart(Ui); - if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(framebuffer*,&Element->FBO), - CSz("FBO"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(g_buffer_textures*,&Element->Textures), - CSz("Textures"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(shader*,&Element->gBufferShader), - CSz("gBufferShader"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(m4*,&Element->InverseViewMatrix), - CSz("InverseViewMatrix"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(m4*,&Element->InverseProjectionMatrix), - CSz("InverseProjectionMatrix"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(m4*,&Element->ViewProjection), - CSz("ViewProjection"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u32*,&Element->GlTimerObject), - CSz("GlTimerObject"), - Params - ); - - - - - - - - PushNewRow(Ui); - if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); - } - else - { - PushNewRow(Ui); - } - - } - else - { - PushColumn(Ui, Name, Params); - PushColumn(Ui, CSz("(null)"), Params); - PushNewRow(Ui); - } - -} - diff --git a/generated/do_editor_ui_for_compound_type_game_lights.h b/generated/do_editor_ui_for_compound_type_game_lights.h deleted file mode 100644 index fce7a6223..000000000 --- a/generated/do_editor_ui_for_compound_type_game_lights.h +++ /dev/null @@ -1,115 +0,0 @@ -// src/engine/editor.cpp:401:0 - -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, game_lights *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. - b32 DrawChildren = True; - b32 DidToggle = False; - if (Name.Count) - { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle game_lights", Element), Params)) - { - DidToggle = True; - PushNewRow(Ui); - } - else - { - DrawChildren = False; - } - } - - if (DrawChildren) - { - PushTableStart(Ui); - if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(texture*,&Element->ColorTex), - CSz("ColorTex"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(texture*,&Element->PositionTex), - CSz("PositionTex"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(r32*,&Element->IndexToUV), - CSz("IndexToUV"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(s32*,&Element->Count), - CSz("Count"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(light*, Element->Lights), - CSz("Lights"), - Params - ); - if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); - } - else - { - PushNewRow(Ui); - } - - } - else - { - PushColumn(Ui, Name, Params); - PushColumn(Ui, CSz("(null)"), Params); - PushNewRow(Ui); - } - -} - diff --git a/generated/do_editor_ui_for_compound_type_game_state.h b/generated/do_editor_ui_for_compound_type_game_state.h new file mode 100644 index 000000000..8848a28db --- /dev/null +++ b/generated/do_editor_ui_for_compound_type_game_state.h @@ -0,0 +1,113 @@ +// src/engine/editor.h:303:0 +struct game_state; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, game_state *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) + + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x7825EE2); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle game_state", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("EasingFunction"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(easing_function*, Element->EasingFunction), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("VisibleRegionSize"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(visible_region_size*, Element->VisibleRegionSize), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("EasingFunctionVisRP"); + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} + 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 356df9acc..f513e434d 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,8 +1,11 @@ -// src/engine/editor.cpp:258:0 +// src/engine/editor.h:305:0 +struct gpu_element_buffer_handles; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, gpu_element_buffer_handles *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) + -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, gpu_element_buffer_handles *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) { + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0xA286F82); + if (Element) { // NOTE(Jesse): This is wacky as fuck, but it's a pretty easy way to support @@ -11,7 +14,7 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, gpu_element_buffer_handles *E b32 DidToggle = False; if (Name.Count) { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle gpu_element_buffer_handles", Element), Params)) + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle gpu_element_buffer_handles", Element, ThisHash), Params)) { DidToggle = True; PushNewRow(Ui); @@ -24,136 +27,214 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, gpu_element_buffer_handles *E if (DrawChildren) { - PushTableStart(Ui); + if (Name.Count) { PushTableStart(Ui); } + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u32*,&Element->VertexHandle), - CSz("VertexHandle"), - Params - ); + + { + + + + cs MemberName = CSz("VAO"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u32*, &Element->VAO), + MemberName, + ThisHash, + Params + ); - PushNewRow(Ui); - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u32*,&Element->NormalHandle), - CSz("NormalHandle"), - Params - ); + PushNewRow(Ui); + } + + { + + + + cs MemberName = CSz("Handles"); + + + if (ToggleButton(Ui, + CSz("v Handles[3]"), + CSz("> Handles[3]"), + UiId(Window, "toggle gpu_element_buffer_handles u32 Handles", Element->Handles, ThisHash), + Params )) + { + OPEN_INDENT_FOR_TOGGLEABLE_REGION(); + PushNewRow(Ui); + s32 End = 3; + + RangeIterator(ArrayIndex, End) + { + DoEditorUi(Ui, + Window, + Element->Handles+ArrayIndex, + FSz("Handles[%d]", ArrayIndex), + ThisHash, + Params); + + PushNewRow(Ui); + } + CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); + } + PushNewRow(Ui); - PushNewRow(Ui); + PushNewRow(Ui); - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u32*,&Element->MatHandle), - CSz("MatHandle"), - Params - ); + } + + { + + + + cs MemberName = CSz("ElementCount"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u32*, &Element->ElementCount), + MemberName, + ThisHash, + Params + ); - PushNewRow(Ui); - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u32*,&Element->ElementCount), - CSz("ElementCount"), - Params - ); + PushNewRow(Ui); + } + + { + + + + cs MemberName = CSz("ElementType"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(data_type*, &Element->ElementType), + MemberName, + ThisHash, + Params + ); - 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 - Cast(b8*,&Element->Mapped), - CSz("Mapped"), - Params - ); + { + + + + cs MemberName = CSz("Mapped"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(b8*, &Element->Mapped), + MemberName, + ThisHash, + Params + ); - PushNewRow(Ui); - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(b8*,&Element->Pad), - CSz("Pad"), - Params - ); + PushNewRow(Ui); + + } + + { + + + + cs MemberName = CSz("Pad"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(b8*, &Element->Pad), + MemberName, + ThisHash, + Params + ); - PushNewRow(Ui); - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u16*,&Element->Flags), - CSz("Flags"), - Params - ); + PushNewRow(Ui); + } + + { + + + + cs MemberName = CSz("Flags"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u16*, &Element->Flags), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } - PushNewRow(Ui); if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); + if (Name.Count) { PushTableEnd(Ui); } } else { 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 e820ba9c6..0656b27f6 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,8 +1,11 @@ -// src/engine/editor.cpp:261:0 +// src/engine/editor.h:305:0 +struct gpu_mapped_element_buffer; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, gpu_mapped_element_buffer *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) + -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, gpu_mapped_element_buffer *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) { + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x1EA242B7); + if (Element) { // NOTE(Jesse): This is wacky as fuck, but it's a pretty easy way to support @@ -11,7 +14,7 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, gpu_mapped_element_buffer *El b32 DidToggle = False; if (Name.Count) { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle gpu_mapped_element_buffer", Element), Params)) + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle gpu_mapped_element_buffer", Element, ThisHash), Params)) { DidToggle = True; PushNewRow(Ui); @@ -24,32 +27,64 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, gpu_mapped_element_buffer *El if (DrawChildren) { - PushTableStart(Ui); + if (Name.Count) { PushTableStart(Ui); } + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(gpu_element_buffer_handles*,&Element->Handles), - CSz("Handles"), - Params - ); + + + { + + + + cs MemberName = CSz("Handles"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(gpu_element_buffer_handles*, &Element->Handles), + MemberName, + ThisHash, + Params + ); + + + + } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(untextured_3d_geometry_buffer*,&Element->Buffer), - CSz("Buffer"), - Params - ); + + { + + + + cs MemberName = CSz("Buffer"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(untextured_3d_geometry_buffer*, &Element->Buffer), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); + if (Name.Count) { PushTableEnd(Ui); } } else { diff --git a/generated/do_editor_ui_for_compound_type_graphics.h b/generated/do_editor_ui_for_compound_type_graphics.h deleted file mode 100644 index f036303c4..000000000 --- a/generated/do_editor_ui_for_compound_type_graphics.h +++ /dev/null @@ -1,413 +0,0 @@ -// src/engine/editor.cpp:410:0 - -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, graphics *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. - b32 DrawChildren = True; - b32 DidToggle = False; - if (Name.Count) - { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle graphics", Element), Params)) - { - DidToggle = True; - PushNewRow(Ui); - } - else - { - DrawChildren = False; - } - } - - if (DrawChildren) - { - PushTableStart(Ui); - if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - Cast(b8*,&Element->Initialized), - CSz("Initialized"), - &DefaultUiRenderParams_Checkbox - ); - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - Cast(b8*,&Element->RenderGate), - CSz("RenderGate"), - &DefaultUiRenderParams_Checkbox - ); - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(render_settings*,&Element->Settings), - CSz("Settings"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(v3*,&Element->SunBasis), - CSz("SunBasis"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(r32*,&Element->FogPower), - CSz("FogPower"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(v3*,&Element->FogColor), - CSz("FogColor"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(v3*,&Element->SkyColor), - CSz("SkyColor"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(camera*,&Element->GameCamera), - CSz("GameCamera"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(camera*,&Element->DebugCamera), - CSz("DebugCamera"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(r32*,&Element->Exposure), - CSz("Exposure"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(world_chunk_ptr_paged_list*,&Element->MainDrawList), - CSz("MainDrawList"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(world_chunk_ptr_paged_list*,&Element->ShadowMapDrawList), - CSz("ShadowMapDrawList"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(v3*,&Element->MinClipP_worldspace), - CSz("MinClipP_worldspace"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(v3*,&Element->MaxClipP_worldspace), - CSz("MaxClipP_worldspace"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(g_buffer_render_group*, Element->gBuffer), - CSz("gBuffer"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(ao_render_group*, Element->AoGroup), - CSz("AoGroup"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(shadow_render_group*, Element->SG), - CSz("SG"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(texture*,&Element->ColorPaletteTexture), - CSz("ColorPaletteTexture"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(transparency_render_group*,&Element->Transparency), - CSz("Transparency"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(lighting_render_group*,&Element->Lighting), - CSz("Lighting"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(gaussian_render_group*,&Element->Gaussian), - CSz("Gaussian"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(composite_render_group*,&Element->CompositeGroup), - CSz("CompositeGroup"), - Params - ); - - - - - - - - - if (ToggleButton(Ui, CSz("v GpuBuffers[2]"), CSz("> GpuBuffers[2]"), UiId(Window, "toggle graphics gpu_mapped_element_buffer GpuBuffers", Element->GpuBuffers), Params )) - { - OPEN_INDENT_FOR_TOGGLEABLE_REGION(); - PushNewRow(Ui); - RangeIterator(ArrayIndex, 2) - { - DoEditorUi(Ui, Window, Element->GpuBuffers+ArrayIndex, FSz("GpuBuffers[%d]", ArrayIndex), Params); - - } - CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); - } - PushNewRow(Ui); - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u32*,&Element->GpuBufferWriteIndex), - CSz("GpuBufferWriteIndex"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(memory_arena*, Element->Memory), - CSz("Memory"), - Params - ); - if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); - } - else - { - PushNewRow(Ui); - } - - } - else - { - PushColumn(Ui, Name, Params); - PushColumn(Ui, CSz("(null)"), Params); - PushNewRow(Ui); - } - -} - diff --git a/generated/do_editor_ui_for_compound_type_graphics_settings.h b/generated/do_editor_ui_for_compound_type_graphics_settings.h deleted file mode 100644 index 87fd3a714..000000000 --- a/generated/do_editor_ui_for_compound_type_graphics_settings.h +++ /dev/null @@ -1,113 +0,0 @@ -// src/engine/editor.cpp:434:0 - -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, graphics_settings *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. - b32 DrawChildren = True; - b32 DidToggle = False; - if (Name.Count) - { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle graphics_settings", Element), Params)) - { - DidToggle = True; - PushNewRow(Ui); - } - else - { - DrawChildren = False; - } - } - - if (DrawChildren) - { - PushTableStart(Ui); - if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(resolution_setting*,&Element->Resolution), - CSz("Resolution"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(shadow_quality_setting*,&Element->ShadowQuality), - CSz("ShadowQuality"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(lighting_quality_setting*,&Element->LightingQuality), - CSz("LightingQuality"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(shader_language_setting*,&Element->ShaderLanguage), - CSz("ShaderLanguage"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(resolution_setting*,&Element->WindowStartingSize), - CSz("WindowStartingSize"), - Params - ); - if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); - } - else - { - PushNewRow(Ui); - } - - } - else - { - PushColumn(Ui, Name, Params); - PushColumn(Ui, CSz("(null)"), Params); - PushNewRow(Ui); - } - -} - diff --git a/generated/do_editor_ui_for_compound_type_input.h b/generated/do_editor_ui_for_compound_type_input.h deleted file mode 100644 index 0207b7906..000000000 --- a/generated/do_editor_ui_for_compound_type_input.h +++ /dev/null @@ -1,1006 +0,0 @@ -// src/engine/editor.cpp:142:0 - -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, input *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. - b32 DrawChildren = True; - b32 DidToggle = False; - if (Name.Count) - { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle input", Element), Params)) - { - DidToggle = True; - PushNewRow(Ui); - } - else - { - DrawChildren = False; - } - } - - if (DrawChildren) - { - PushTableStart(Ui); - if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input_event*,&Element->Enter), - CSz("Enter"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input_event*,&Element->Escape), - CSz("Escape"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input_event*,&Element->Alt), - CSz("Alt"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input_event*,&Element->Ctrl), - CSz("Ctrl"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input_event*,&Element->Shift), - CSz("Shift"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input_event*,&Element->Backspace), - CSz("Backspace"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input_event*,&Element->Delete), - CSz("Delete"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input_event*,&Element->F12), - CSz("F12"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input_event*,&Element->F11), - CSz("F11"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input_event*,&Element->F10), - CSz("F10"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input_event*,&Element->F9), - CSz("F9"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input_event*,&Element->F8), - CSz("F8"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input_event*,&Element->F7), - CSz("F7"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input_event*,&Element->F6), - CSz("F6"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input_event*,&Element->F5), - CSz("F5"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input_event*,&Element->F4), - CSz("F4"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input_event*,&Element->F3), - CSz("F3"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input_event*,&Element->F2), - CSz("F2"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input_event*,&Element->F1), - CSz("F1"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input_event*,&Element->Dot), - CSz("Dot"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input_event*,&Element->Minus), - CSz("Minus"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input_event*,&Element->FSlash), - CSz("FSlash"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input_event*,&Element->Space), - CSz("Space"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input_event*,&Element->Underscore), - CSz("Underscore"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input_event*,&Element->N0), - CSz("N0"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input_event*,&Element->N1), - CSz("N1"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input_event*,&Element->N2), - CSz("N2"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input_event*,&Element->N3), - CSz("N3"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input_event*,&Element->N4), - CSz("N4"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input_event*,&Element->N5), - CSz("N5"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input_event*,&Element->N6), - CSz("N6"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input_event*,&Element->N7), - CSz("N7"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input_event*,&Element->N8), - CSz("N8"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input_event*,&Element->N9), - CSz("N9"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input_event*,&Element->A), - CSz("A"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input_event*,&Element->B), - CSz("B"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input_event*,&Element->C), - CSz("C"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input_event*,&Element->D), - CSz("D"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input_event*,&Element->E), - CSz("E"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input_event*,&Element->F), - CSz("F"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input_event*,&Element->G), - CSz("G"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input_event*,&Element->H), - CSz("H"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input_event*,&Element->I), - CSz("I"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input_event*,&Element->J), - CSz("J"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input_event*,&Element->K), - CSz("K"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input_event*,&Element->L), - CSz("L"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input_event*,&Element->M), - CSz("M"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input_event*,&Element->N), - CSz("N"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input_event*,&Element->O), - CSz("O"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input_event*,&Element->P), - CSz("P"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input_event*,&Element->Q), - CSz("Q"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input_event*,&Element->R), - CSz("R"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input_event*,&Element->S), - CSz("S"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input_event*,&Element->T), - CSz("T"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input_event*,&Element->U), - CSz("U"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input_event*,&Element->V), - CSz("V"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input_event*,&Element->W), - CSz("W"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input_event*,&Element->X), - CSz("X"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input_event*,&Element->Y), - CSz("Y"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input_event*,&Element->Z), - CSz("Z"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input_event*,&Element->RMB), - CSz("RMB"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input_event*,&Element->LMB), - CSz("LMB"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input_event*,&Element->MMB), - CSz("MMB"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(s32*,&Element->MouseWheelDelta), - CSz("MouseWheelDelta"), - Params - ); - - - - - - - - PushNewRow(Ui); - if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); - } - else - { - PushNewRow(Ui); - } - - } - else - { - PushColumn(Ui, Name, Params); - PushColumn(Ui, CSz("(null)"), Params); - PushNewRow(Ui); - } - -} - diff --git a/generated/do_editor_ui_for_compound_type_input_event.h b/generated/do_editor_ui_for_compound_type_input_event.h deleted file mode 100644 index 90c6d4130..000000000 --- a/generated/do_editor_ui_for_compound_type_input_event.h +++ /dev/null @@ -1,71 +0,0 @@ -// src/engine/editor.cpp:139:0 - -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, input_event *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. - b32 DrawChildren = True; - b32 DidToggle = False; - if (Name.Count) - { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle input_event", Element), Params)) - { - DidToggle = True; - PushNewRow(Ui); - } - else - { - DrawChildren = False; - } - } - - if (DrawChildren) - { - PushTableStart(Ui); - if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - Cast(b8*,&Element->Clicked), - CSz("Clicked"), - &DefaultUiRenderParams_Checkbox - ); - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - Cast(b8*,&Element->Pressed), - CSz("Pressed"), - &DefaultUiRenderParams_Checkbox - ); - - - - - - PushNewRow(Ui); - if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); - } - else - { - PushNewRow(Ui); - } - - } - else - { - PushColumn(Ui, Name, Params); - PushColumn(Ui, CSz("(null)"), Params); - PushNewRow(Ui); - } - -} - diff --git a/generated/do_editor_ui_for_compound_type_keyframe.h b/generated/do_editor_ui_for_compound_type_keyframe.h deleted file mode 100644 index 2e83aae56..000000000 --- a/generated/do_editor_ui_for_compound_type_keyframe.h +++ /dev/null @@ -1,77 +0,0 @@ -// src/engine/editor.cpp:213:0 - -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, keyframe *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. - b32 DrawChildren = True; - b32 DidToggle = False; - if (Name.Count) - { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle keyframe", Element), Params)) - { - DidToggle = True; - PushNewRow(Ui); - } - else - { - DrawChildren = False; - } - } - - if (DrawChildren) - { - PushTableStart(Ui); - if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(r32*,&Element->tEnd), - CSz("tEnd"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(r32*,&Element->Value), - CSz("Value"), - Params - ); - - - - - - - - PushNewRow(Ui); - if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); - } - else - { - PushNewRow(Ui); - } - - } - else - { - PushColumn(Ui, Name, Params); - PushColumn(Ui, CSz("(null)"), Params); - PushNewRow(Ui); - } - -} - diff --git a/generated/do_editor_ui_for_compound_type_layered_brush.h b/generated/do_editor_ui_for_compound_type_layered_brush.h new file mode 100644 index 000000000..b442cf4dc --- /dev/null +++ b/generated/do_editor_ui_for_compound_type_layered_brush.h @@ -0,0 +1,146 @@ +// src/engine/editor.h:305:0 +struct layered_brush; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, layered_brush *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) + + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x1F7B17CD); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle layered_brush", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("LayerCount"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(s32*, &Element->LayerCount), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("Layers"); + + + if (ToggleButton(Ui, + CSz("v Layers[16]"), + CSz("> Layers[16]"), + UiId(Window, "toggle layered_brush brush_layer Layers", Element->Layers, ThisHash), + Params )) + { + OPEN_INDENT_FOR_TOGGLEABLE_REGION(); + PushNewRow(Ui); + s32 End = s32(Element->LayerCount); + Assert( End < 16 ); + + RangeIterator(ArrayIndex, End) + { + DoEditorUi(Ui, + Window, + Element->Layers+ArrayIndex, + FSz("Layers[%d]", ArrayIndex), + ThisHash, + Params); + + + } + CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); + } + PushNewRow(Ui); + + + + + + + } + + + { + + + + cs MemberName = CSz("AffectExisting"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(b8*, &Element->AffectExisting), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} + 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 deleted file mode 100644 index cc75c5c69..000000000 --- a/generated/do_editor_ui_for_compound_type_layered_brush_editor.h +++ /dev/null @@ -1,195 +0,0 @@ -// src/engine/editor.cpp:347:0 - -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, layered_brush_editor *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. - b32 DrawChildren = True; - b32 DidToggle = False; - if (Name.Count) - { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle layered_brush_editor", Element), Params)) - { - DidToggle = True; - PushNewRow(Ui); - } - else - { - DrawChildren = False; - } - } - - if (DrawChildren) - { - PushTableStart(Ui); - if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - if (ToggleButton(Ui, CSz("v NameBuf[(256) + 1]"), CSz("> NameBuf[(256) + 1]"), UiId(Window, "toggle layered_brush_editor char NameBuf", Element->NameBuf), Params )) - { - OPEN_INDENT_FOR_TOGGLEABLE_REGION(); - PushNewRow(Ui); - RangeIterator(ArrayIndex, (256) + 1) - { - DoEditorUi(Ui, Window, Element->NameBuf+ArrayIndex, FSz("NameBuf[%d]", ArrayIndex), Params); - PushNewRow(Ui); - } - CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); - } - PushNewRow(Ui); - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(s32*,&Element->LayerCount), - CSz("LayerCount"), - Params - ); - - - - - - - - PushNewRow(Ui); - - if (ToggleButton(Ui, CSz("v Layers[16]"), CSz("> Layers[16]"), UiId(Window, "toggle layered_brush_editor brush_layer Layers", Element->Layers), Params )) - { - OPEN_INDENT_FOR_TOGGLEABLE_REGION(); - PushNewRow(Ui); - RangeIterator(ArrayIndex, 16) - { - DoEditorUi(Ui, Window, Element->Layers+ArrayIndex, FSz("Layers[%d]", ArrayIndex), Params); - - } - CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); - } - PushNewRow(Ui); - - - - - if (ToggleButton(Ui, CSz("v LayerPreviews[16]"), CSz("> LayerPreviews[16]"), UiId(Window, "toggle layered_brush_editor chunk_thumbnail LayerPreviews", Element->LayerPreviews), Params )) - { - OPEN_INDENT_FOR_TOGGLEABLE_REGION(); - PushNewRow(Ui); - RangeIterator(ArrayIndex, 16) - { - DoEditorUi(Ui, Window, Element->LayerPreviews+ArrayIndex, FSz("LayerPreviews[%d]", ArrayIndex), Params); - - } - CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); - } - PushNewRow(Ui); - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(chunk_thumbnail*,&Element->SeedLayer), - CSz("SeedLayer"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(b8*,&Element->SeedBrushWithSelection), - CSz("SeedBrushWithSelection"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(b8*,&Element->BrushFollowsCursor), - CSz("BrushFollowsCursor"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(world_edit_mode*,&Element->Mode), - CSz("Mode"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(world_edit_mode_modifier*,&Element->Modifier), - CSz("Modifier"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(chunk_thumbnail*,&Element->Preview), - CSz("Preview"), - Params - ); - if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); - } - else - { - PushNewRow(Ui); - } - - } - else - { - PushColumn(Ui, Name, Params); - PushColumn(Ui, CSz("(null)"), Params); - PushNewRow(Ui); - } - -} - diff --git a/generated/do_editor_ui_for_compound_type_level_editor.h b/generated/do_editor_ui_for_compound_type_level_editor.h deleted file mode 100644 index c704a619a..000000000 --- a/generated/do_editor_ui_for_compound_type_level_editor.h +++ /dev/null @@ -1,420 +0,0 @@ -// src/engine/editor.cpp:425:0 - -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, level_editor *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. - b32 DrawChildren = True; - b32 DidToggle = False; - if (Name.Count) - { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle level_editor", Element), Params)) - { - DidToggle = True; - PushNewRow(Ui); - } - else - { - DrawChildren = False; - } - } - - if (DrawChildren) - { - PushTableStart(Ui); - if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(memory_arena*, Element->Memory), - CSz("Memory"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(world_edit_tool*,&Element->Tool), - CSz("Tool"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(world_edit_tool*,&Element->PreviousTool), - CSz("PreviousTool"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(world_edit_brush_type*,&Element->BrushType), - CSz("BrushType"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(single_brush_settings*,&Element->SingleBrush), - CSz("SingleBrush"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(asset_brush_settings*,&Element->AssetBrush), - CSz("AssetBrush"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(layered_brush_editor*,&Element->LayeredBrushEditor), - CSz("LayeredBrushEditor"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(b8*,&Element->SelectionFollowsCursor), - CSz("SelectionFollowsCursor"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - Cast(b8*,&Element->RootChunkNeedsNewMesh), - CSz("RootChunkNeedsNewMesh"), - &DefaultUiRenderParams_Checkbox - ); - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(cp*,&Element->MostRecentSelectionRegionMin), - CSz("MostRecentSelectionRegionMin"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(cp*,&Element->NextSelectionRegionMin), - CSz("NextSelectionRegionMin"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(cp*,&Element->EditorPreviewRegionMin), - CSz("EditorPreviewRegionMin"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u64*,&Element->EngineDebugViewModeToggleBits), - CSz("EngineDebugViewModeToggleBits"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u16*,&Element->HoverColorIndex), - CSz("HoverColorIndex"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - Cast(b8*,&Element->SelectionChanged), - CSz("SelectionChanged"), - &DefaultUiRenderParams_Checkbox - ); - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u32*,&Element->SelectionClicks), - CSz("SelectionClicks"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(cp*,&Element->SelectionBase), - CSz("SelectionBase"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(rect3cp*,&Element->SelectionRegion), - CSz("SelectionRegion"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(rect3cp*,&Element->PrevSelectionRegion), - CSz("PrevSelectionRegion"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(rect3cp*,&Element->CopyRegion), - CSz("CopyRegion"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(selection_modification_state*,&Element->Selection), - CSz("Selection"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(selection_modification_state*,&Element->Entity), - CSz("Entity"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(asset_thumbnail_block_array*,&Element->AssetThumbnails), - 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); - } - else - { - PushNewRow(Ui); - } - - } - else - { - PushColumn(Ui, Name, Params); - PushColumn(Ui, CSz("(null)"), Params); - PushNewRow(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 deleted file mode 100644 index 93f7bf0b4..000000000 --- a/generated/do_editor_ui_for_compound_type_lighting_render_group.h +++ /dev/null @@ -1,113 +0,0 @@ -// src/engine/editor.cpp:404:0 - -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, lighting_render_group *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. - b32 DrawChildren = True; - b32 DidToggle = False; - if (Name.Count) - { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle lighting_render_group", Element), Params)) - { - DidToggle = True; - PushNewRow(Ui); - } - else - { - DrawChildren = False; - } - } - - if (DrawChildren) - { - PushTableStart(Ui); - if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(game_lights*,&Element->Lights), - CSz("Lights"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(framebuffer*,&Element->FBO), - CSz("FBO"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(texture*,&Element->LuminanceTex), - CSz("LuminanceTex"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(shader*,&Element->Shader), - CSz("Shader"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(bloom_render_group*,&Element->Bloom), - CSz("Bloom"), - Params - ); - if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); - } - else - { - PushNewRow(Ui); - } - - } - else - { - PushColumn(Ui, Name, Params); - PushColumn(Ui, CSz("(null)"), Params); - PushNewRow(Ui); - } - -} - diff --git a/generated/do_editor_ui_for_compound_type_lighting_settings.h b/generated/do_editor_ui_for_compound_type_lighting_settings.h deleted file mode 100644 index e179411fd..000000000 --- a/generated/do_editor_ui_for_compound_type_lighting_settings.h +++ /dev/null @@ -1,209 +0,0 @@ -// src/engine/editor.cpp:192:0 - -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, lighting_settings *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. - b32 DrawChildren = True; - b32 DidToggle = False; - if (Name.Count) - { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle lighting_settings", Element), Params)) - { - DidToggle = True; - PushNewRow(Ui); - } - else - { - DrawChildren = False; - } - } - - if (DrawChildren) - { - PushTableStart(Ui); - if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(b8*,&Element->AutoDayNightCycle), - CSz("AutoDayNightCycle"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(r32*,&Element->tDay), - CSz("tDay"), - Params -,-PI32, PI32 ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(f32*,&Element->DawnIntensity), - CSz("DawnIntensity"), - Params -,0.f, 3.f ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(v3*,&Element->DawnColor), - CSz("DawnColor"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(f32*,&Element->SunIntensity), - CSz("SunIntensity"), - Params -,0.f, 3.f ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(v3*,&Element->SunColor), - CSz("SunColor"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(f32*,&Element->DuskIntensity), - CSz("DuskIntensity"), - Params -,0.f, 3.f ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(v3*,&Element->DuskColor), - CSz("DuskColor"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(f32*,&Element->MoonIntensity), - CSz("MoonIntensity"), - Params -,0.f, 3.f ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(v3*,&Element->MoonColor), - CSz("MoonColor"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(v3*,&Element->CurrentSunColor), - CSz("CurrentSunColor"), - Params - ); - if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); - } - else - { - PushNewRow(Ui); - } - - } - else - { - PushColumn(Ui, Name, Params); - PushColumn(Ui, CSz("(null)"), Params); - PushNewRow(Ui); - } - -} - 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 48e1670ad..f59f6e5fe 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,8 +1,11 @@ -// src/engine/editor.cpp:264:0 +// src/engine/editor.h:305:0 +struct lod_element_buffer; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, lod_element_buffer *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) + -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, lod_element_buffer *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) { + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x229F06E8); + if (Element) { // NOTE(Jesse): This is wacky as fuck, but it's a pretty easy way to support @@ -11,7 +14,7 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, lod_element_buffer *Element, b32 DidToggle = False; if (Name.Count) { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle lod_element_buffer", Element), Params)) + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle lod_element_buffer", Element, ThisHash), Params)) { DidToggle = True; PushNewRow(Ui); @@ -24,70 +27,159 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, lod_element_buffer *Element, if (DrawChildren) { - PushTableStart(Ui); + if (Name.Count) { PushTableStart(Ui); } + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u32*,&Element->MeshMask), - CSz("MeshMask"), - Params - ); + + { + + + + cs MemberName = CSz("MeshMask"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u32*, &Element->MeshMask), + MemberName, + ThisHash, + Params + ); - PushNewRow(Ui); - if (ToggleButton(Ui, CSz("v GpuBufferHandles[MeshIndex_Count]"), CSz("> GpuBufferHandles[MeshIndex_Count]"), UiId(Window, "toggle lod_element_buffer gpu_element_buffer_handles GpuBufferHandles", Element->GpuBufferHandles), Params )) - { - OPEN_INDENT_FOR_TOGGLEABLE_REGION(); - PushNewRow(Ui); - RangeIterator(ArrayIndex, MeshIndex_Count) + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("GpuBufferHandles"); + + + if (ToggleButton(Ui, + CSz("v GpuBufferHandles[MeshIndex_Count]"), + CSz("> GpuBufferHandles[MeshIndex_Count]"), + UiId(Window, "toggle lod_element_buffer gpu_element_buffer_handles GpuBufferHandles", Element->GpuBufferHandles, ThisHash), + Params )) { - DoEditorUi(Ui, Window, Element->GpuBufferHandles+ArrayIndex, FSz("GpuBufferHandles[%d]", ArrayIndex), Params); - + OPEN_INDENT_FOR_TOGGLEABLE_REGION(); + PushNewRow(Ui); + s32 End = MeshIndex_Count; + + RangeIterator(ArrayIndex, End) + { + DoEditorUi(Ui, + Window, + Element->GpuBufferHandles+ArrayIndex, + FSz("GpuBufferHandles[%d]", ArrayIndex), + ThisHash, + Params); + + + } + CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); - } - PushNewRow(Ui); + PushNewRow(Ui); + + + + } - if (ToggleButton(Ui, CSz("v E[MeshIndex_Count]"), CSz("> E[MeshIndex_Count]"), UiId(Window, "toggle lod_element_buffer geo_u3d_ptr E", Element->E), Params )) - { - OPEN_INDENT_FOR_TOGGLEABLE_REGION(); - PushNewRow(Ui); - RangeIterator(ArrayIndex, MeshIndex_Count) + + { + + + + cs MemberName = CSz("E"); + + + if (ToggleButton(Ui, + CSz("v E[MeshIndex_Count]"), + CSz("> E[MeshIndex_Count]"), + UiId(Window, "toggle lod_element_buffer geo_u3d_ptr E", Element->E, ThisHash), + Params )) { - DoEditorUi(Ui, Window, Element->E+ArrayIndex, FSz("E[%d]", ArrayIndex), Params); - + OPEN_INDENT_FOR_TOGGLEABLE_REGION(); + PushNewRow(Ui); + s32 End = MeshIndex_Count; + + RangeIterator(ArrayIndex, End) + { + DoEditorUi(Ui, + Window, + Element->E+ArrayIndex, + FSz("E[%d]", ArrayIndex), + ThisHash, + Params); + + + } + CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); - } - PushNewRow(Ui); + PushNewRow(Ui); + + + + } - if (ToggleButton(Ui, CSz("v Locks[MeshIndex_Count]"), CSz("> Locks[MeshIndex_Count]"), UiId(Window, "toggle lod_element_buffer bonsai_futex Locks", Element->Locks), Params )) - { - OPEN_INDENT_FOR_TOGGLEABLE_REGION(); - PushNewRow(Ui); - RangeIterator(ArrayIndex, MeshIndex_Count) + + { + + + + cs MemberName = CSz("Locks"); + + + if (ToggleButton(Ui, + CSz("v Locks[MeshIndex_Count]"), + CSz("> Locks[MeshIndex_Count]"), + UiId(Window, "toggle lod_element_buffer bonsai_futex Locks", Element->Locks, ThisHash), + Params )) { - DoEditorUi(Ui, Window, Element->Locks+ArrayIndex, FSz("Locks[%d]", ArrayIndex), Params); - + OPEN_INDENT_FOR_TOGGLEABLE_REGION(); + PushNewRow(Ui); + s32 End = MeshIndex_Count; + + RangeIterator(ArrayIndex, End) + { + DoEditorUi(Ui, + Window, + Element->Locks+ArrayIndex, + FSz("Locks[%d]", ArrayIndex), + ThisHash, + Params); + + + } + CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); + PushNewRow(Ui); + + + + + + } - PushNewRow(Ui); + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); + if (Name.Count) { PushTableEnd(Ui); } } else { diff --git a/generated/do_editor_ui_for_compound_type_maybe_ray.h b/generated/do_editor_ui_for_compound_type_maybe_ray.h new file mode 100644 index 000000000..d86316fe2 --- /dev/null +++ b/generated/do_editor_ui_for_compound_type_maybe_ray.h @@ -0,0 +1,103 @@ +// src/engine/editor.h:305:0 +struct maybe_ray; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, maybe_ray *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) + + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x378E6FBD); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle maybe_ray", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("Tag"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(maybe_tag*, &Element->Tag), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Ray"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(ray*, &Element->Ray), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} + diff --git a/generated/do_editor_ui_for_compound_type_model.h b/generated/do_editor_ui_for_compound_type_model.h index 358f14709..828ad5ae8 100644 --- a/generated/do_editor_ui_for_compound_type_model.h +++ b/generated/do_editor_ui_for_compound_type_model.h @@ -1,8 +1,11 @@ -// src/engine/editor.cpp:267:0 +// src/engine/editor.h:305:0 +struct model; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, model *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) + -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, model *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) { + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x4BAE73F); + if (Element) { // NOTE(Jesse): This is wacky as fuck, but it's a pretty easy way to support @@ -11,7 +14,7 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, model *Element, cs Name, ui_r b32 DidToggle = False; if (Name.Count) { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle model", Element), Params)) + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle model", Element, ThisHash), Params)) { DidToggle = True; PushNewRow(Ui); @@ -24,77 +27,168 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, model *Element, cs Name, ui_r if (DrawChildren) { - PushTableStart(Ui); + if (Name.Count) { PushTableStart(Ui); } + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(vox_data*,&Element->Vox), - CSz("Vox"), - Params - ); + + + { + + + + cs MemberName = CSz("Vox"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(vox_data*, &Element->Vox), + MemberName, + ThisHash, + Params + ); + + + + } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(lod_element_buffer*,&Element->Meshes), - CSz("Meshes"), - Params - ); + + { + + + + cs MemberName = CSz("Meshes"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(lod_element_buffer*, &Element->Meshes), + MemberName, + ThisHash, + Params + ); + + + + } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(untextured_3d_geometry_buffer*,&Element->TransparentMesh), - CSz("TransparentMesh"), - Params - ); + { + + + + cs MemberName = CSz("Mesh"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(gpu_mapped_element_buffer*, &Element->Mesh), + MemberName, + ThisHash, + Params + ); + + + + + } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(animation*,&Element->Animation), - CSz("Animation"), - Params - ); + + { + + + + cs MemberName = CSz("TransparentMesh"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(untextured_3d_geometry_buffer*, &Element->TransparentMesh), + MemberName, + ThisHash, + Params + ); + + + + } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(v3i*,&Element->Dim), - CSz("Dim"), - Params - ); + + { + + + + cs MemberName = CSz("Animation"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(animation*, &Element->Animation), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Dim"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v3i*, &Element->Dim), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); + if (Name.Count) { PushTableEnd(Ui); } } else { diff --git a/generated/do_editor_ui_for_compound_type_nested_type.h b/generated/do_editor_ui_for_compound_type_nested_type.h new file mode 100644 index 000000000..83e28b826 --- /dev/null +++ b/generated/do_editor_ui_for_compound_type_nested_type.h @@ -0,0 +1,146 @@ +// src/engine/editor.h:305:0 +struct nested_type; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, nested_type *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) + + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x10BA4CBE); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle nested_type", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("NestedFoo"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(s32*, &Element->NestedFoo), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("NestedBar"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(f32*, &Element->NestedBar), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("Array"); + + + if (ToggleButton(Ui, + CSz("v Array[4]"), + CSz("> Array[4]"), + UiId(Window, "toggle nested_type u32 Array", Element->Array, ThisHash), + Params )) + { + OPEN_INDENT_FOR_TOGGLEABLE_REGION(); + PushNewRow(Ui); + s32 End = 4; + + RangeIterator(ArrayIndex, End) + { + DoEditorUi(Ui, + Window, + Element->Array+ArrayIndex, + FSz("Array[%d]", ArrayIndex), + ThisHash, + Params); + + PushNewRow(Ui); + } + CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); + } + PushNewRow(Ui); + + + + PushNewRow(Ui); + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} + diff --git a/generated/do_editor_ui_for_compound_type_noise_layer.h b/generated/do_editor_ui_for_compound_type_noise_layer.h deleted file mode 100644 index d33fa4754..000000000 --- a/generated/do_editor_ui_for_compound_type_noise_layer.h +++ /dev/null @@ -1,98 +0,0 @@ -// src/engine/editor.cpp:341:0 - -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, noise_layer *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. - b32 DrawChildren = True; - b32 DidToggle = False; - if (Name.Count) - { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle noise_layer", Element), Params)) - { - DidToggle = True; - PushNewRow(Ui); - } - else - { - DrawChildren = False; - } - } - - if (DrawChildren) - { - PushTableStart(Ui); - if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(ui_noise_type*,&Element->Type), - CSz("Type"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(white_noise_params*,&Element->White), - CSz("White"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(perlin_noise_params*,&Element->Perlin), - CSz("Perlin"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(voronoi_noise_params*,&Element->Voronoi), - CSz("Voronoi"), - Params - ); - if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); - } - else - { - PushNewRow(Ui); - } - - } - else - { - PushColumn(Ui, Name, Params); - PushColumn(Ui, CSz("(null)"), Params); - PushNewRow(Ui); - } - -} - diff --git a/generated/do_editor_ui_for_compound_type_octree_node.h b/generated/do_editor_ui_for_compound_type_octree_node.h new file mode 100644 index 000000000..26211f272 --- /dev/null +++ b/generated/do_editor_ui_for_compound_type_octree_node.h @@ -0,0 +1,318 @@ +// src/engine/editor.h:305:0 +struct octree_node; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, octree_node *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) + + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x1C6C60D9); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle octree_node", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("Flags"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(chunk_flag*, &Element->Flags), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Type"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(octree_node_type*, &Element->Type), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Dirty"); + DoEditorUi(Ui, + Window, + Cast(b8*, &Element->Dirty), + MemberName, + ThisHash, + &DefaultUiRenderParams_Checkbox + ); + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("WorldP"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v3i*, &Element->WorldP), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Resolution"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v3i*, &Element->Resolution), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Chunk"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(world_chunk*, Element->Chunk), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Children"); + + + if (ToggleButton(Ui, + CSz("v Children[8]"), + CSz("> Children[8]"), + UiId(Window, "toggle octree_node octree_node Children", Element->Children, ThisHash), + Params )) + { + OPEN_INDENT_FOR_TOGGLEABLE_REGION(); + PushNewRow(Ui); + s32 End = 8; + + RangeIterator(ArrayIndex, End) + { + if (Element->Children[ArrayIndex]) {DoEditorUi(Ui, Window, Element->Children[ArrayIndex], CSz("Child"), ThisHash, Params);}; + + + } + CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); + } + PushNewRow(Ui); + + + + + + + } + + + { + + + + cs MemberName = CSz("Next"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(octree_node*, Element->Next), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Edits"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(world_edit_ptr_block_array*, &Element->Edits), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Lock"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(bonsai_futex*, &Element->Lock), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} + diff --git a/generated/do_editor_ui_for_compound_type_particle.h b/generated/do_editor_ui_for_compound_type_particle.h deleted file mode 100644 index edfb30b39..000000000 --- a/generated/do_editor_ui_for_compound_type_particle.h +++ /dev/null @@ -1,123 +0,0 @@ -// src/engine/editor.cpp:207:0 - -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, particle *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. - b32 DrawChildren = True; - b32 DidToggle = False; - if (Name.Count) - { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle particle", Element), Params)) - { - DidToggle = True; - PushNewRow(Ui); - } - else - { - DrawChildren = False; - } - } - - if (DrawChildren) - { - PushTableStart(Ui); - if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(v3*,&Element->Velocity), - CSz("Velocity"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(v3*,&Element->Offset), - CSz("Offset"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u8*,&Element->Color), - CSz("Color"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(b8*,&Element->IsLight), - CSz("IsLight"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(r32*,&Element->RemainingLifespan), - CSz("RemainingLifespan"), - Params - ); - - - - - - - - PushNewRow(Ui); - if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); - } - else - { - PushNewRow(Ui); - } - - } - else - { - PushColumn(Ui, Name, Params); - PushColumn(Ui, CSz("(null)"), Params); - PushNewRow(Ui); - } - -} - diff --git a/generated/do_editor_ui_for_compound_type_particle_system.h b/generated/do_editor_ui_for_compound_type_particle_system.h deleted file mode 100644 index bbf437e30..000000000 --- a/generated/do_editor_ui_for_compound_type_particle_system.h +++ /dev/null @@ -1,405 +0,0 @@ -// src/engine/editor.cpp:210:0 - -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, particle_system *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. - b32 DrawChildren = True; - b32 DidToggle = False; - if (Name.Count) - { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle particle_system", Element), Params)) - { - DidToggle = True; - PushNewRow(Ui); - } - else - { - DrawChildren = False; - } - } - - if (DrawChildren) - { - PushTableStart(Ui); - if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(random_series*,&Element->Entropy), - CSz("Entropy"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(particle_spawn_type*,&Element->SpawnType), - CSz("SpawnType"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(r32*,&Element->Drag), - CSz("Drag"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(r32*,&Element->Lifetime), - CSz("Lifetime"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(r32*,&Element->EmissionDelay), - CSz("EmissionDelay"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(r32*,&Element->EmissionLifespan), - CSz("EmissionLifespan"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u32*,&Element->ActiveParticles), - CSz("ActiveParticles"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(r32*,&Element->LifespanMod), - CSz("LifespanMod"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(r32*,&Element->ParticleLifespan), - CSz("ParticleLifespan"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(r32*,&Element->ParticlesPerSecond), - CSz("ParticlesPerSecond"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(r32*,&Element->ParticleLightEmission), - CSz("ParticleLightEmission"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(r32*,&Element->ParticleLightEmissionChance), - CSz("ParticleLightEmissionChance"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(r32*,&Element->ParticleStartingTransparency), - CSz("ParticleStartingTransparency"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(r32*,&Element->ParticleEndingTransparency), - CSz("ParticleEndingTransparency"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(v3*,&Element->ParticleStartingDim), - CSz("ParticleStartingDim"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(f32*,&Element->ParticleEndingDim), - CSz("ParticleEndingDim"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(v3*,&Element->ParticleTurbMin), - CSz("ParticleTurbMin"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(v3*,&Element->ParticleTurbMax), - CSz("ParticleTurbMax"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(aabb*,&Element->SpawnRegion), - CSz("SpawnRegion"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(r32*,&Element->SystemMovementCoefficient), - CSz("SystemMovementCoefficient"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(r32*,&Element->ElapsedSinceLastEmission), - CSz("ElapsedSinceLastEmission"), - Params - ); - - - - - - - - PushNewRow(Ui); - - if (ToggleButton(Ui, CSz("v PackedHSVColors[6]"), CSz("> PackedHSVColors[6]"), UiId(Window, "toggle particle_system u16 PackedHSVColors", Element->PackedHSVColors), Params )) - { - OPEN_INDENT_FOR_TOGGLEABLE_REGION(); - PushNewRow(Ui); - RangeIterator(ArrayIndex, 6) - { - DoEditorUi(Ui, Window, Element->PackedHSVColors+ArrayIndex, FSz("PackedHSVColors[%d]", ArrayIndex), Params); - PushNewRow(Ui); - } - CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); - } - PushNewRow(Ui); - - - - PushNewRow(Ui); - - if (ToggleButton(Ui, CSz("v Particles[(4096)]"), CSz("> Particles[(4096)]"), UiId(Window, "toggle particle_system particle Particles", Element->Particles), Params )) - { - OPEN_INDENT_FOR_TOGGLEABLE_REGION(); - PushNewRow(Ui); - RangeIterator(ArrayIndex, (4096)) - { - DoEditorUi(Ui, Window, Element->Particles+ArrayIndex, FSz("Particles[%d]", ArrayIndex), Params); - - } - CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); - } - PushNewRow(Ui); - if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); - } - else - { - PushNewRow(Ui); - } - - } - else - { - PushColumn(Ui, Name, Params); - PushColumn(Ui, CSz("(null)"), Params); - PushNewRow(Ui); - } - -} - 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 deleted file mode 100644 index 33febf5b5..000000000 --- a/generated/do_editor_ui_for_compound_type_perlin_noise_params.h +++ /dev/null @@ -1,92 +0,0 @@ -// src/engine/editor.cpp:94:0 - -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, perlin_noise_params *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. - b32 DrawChildren = True; - b32 DidToggle = False; - if (Name.Count) - { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle perlin_noise_params", Element), Params)) - { - DidToggle = True; - PushNewRow(Ui); - } - else - { - DrawChildren = False; - } - } - - if (DrawChildren) - { - PushTableStart(Ui); - if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(r32*,&Element->Threshold), - CSz("Threshold"), - Params -,0.1f, 20.f ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(v3*,&Element->Period), - CSz("Period"), - Params -,0.1f, 20.f ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(r32*,&Element->Amplitude), - CSz("Amplitude"), - Params -,0.1f, 20.f ); - - - - - - - - PushNewRow(Ui); - if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); - } - else - { - PushNewRow(Ui); - } - - } - else - { - PushColumn(Ui, Name, Params); - PushColumn(Ui, CSz("(null)"), Params); - PushNewRow(Ui); - } - -} - diff --git a/generated/do_editor_ui_for_compound_type_physics.h b/generated/do_editor_ui_for_compound_type_physics.h deleted file mode 100644 index 2cc151ee9..000000000 --- a/generated/do_editor_ui_for_compound_type_physics.h +++ /dev/null @@ -1,122 +0,0 @@ -// src/engine/editor.cpp:198:0 - -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, physics *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. - b32 DrawChildren = True; - b32 DidToggle = False; - if (Name.Count) - { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle physics", Element), Params)) - { - DidToggle = True; - PushNewRow(Ui); - } - else - { - DrawChildren = False; - } - } - - if (DrawChildren) - { - PushTableStart(Ui); - if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(v3*,&Element->Velocity), - CSz("Velocity"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(v3*,&Element->Force), - CSz("Force"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(v3*,&Element->Delta), - CSz("Delta"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(r32*,&Element->Mass), - CSz("Mass"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(r32*,&Element->Speed), - CSz("Speed"), - Params - ); - - - - - - - - PushNewRow(Ui); - if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); - } - else - { - PushNewRow(Ui); - } - - } - else - { - PushColumn(Ui, Name, Params); - PushColumn(Ui, CSz("(null)"), Params); - PushNewRow(Ui); - } - -} - diff --git a/generated/do_editor_ui_for_compound_type_plane.h b/generated/do_editor_ui_for_compound_type_plane.h deleted file mode 100644 index 88ee35034..000000000 --- a/generated/do_editor_ui_for_compound_type_plane.h +++ /dev/null @@ -1,93 +0,0 @@ -// src/engine/editor.cpp:323:0 - -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, plane *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. - b32 DrawChildren = True; - b32 DidToggle = False; - if (Name.Count) - { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle plane", Element), Params)) - { - DidToggle = True; - PushNewRow(Ui); - } - else - { - DrawChildren = False; - } - } - - if (DrawChildren) - { - PushTableStart(Ui); - if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(v3*,&Element->P), - CSz("P"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(v3*,&Element->Normal), - CSz("Normal"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(r32*,&Element->d), - CSz("d"), - Params - ); - - - - - - - - PushNewRow(Ui); - - - if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); - } - else - { - PushNewRow(Ui); - } - - } - else - { - PushColumn(Ui, Name, Params); - PushColumn(Ui, CSz("(null)"), Params); - PushNewRow(Ui); - } - -} - diff --git a/generated/do_editor_ui_for_compound_type_platform.h b/generated/do_editor_ui_for_compound_type_platform.h deleted file mode 100644 index 38c895136..000000000 --- a/generated/do_editor_ui_for_compound_type_platform.h +++ /dev/null @@ -1,296 +0,0 @@ -// src/engine/editor.cpp:145:0 - -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, platform *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. - b32 DrawChildren = True; - b32 DidToggle = False; - if (Name.Count) - { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle platform", Element), Params)) - { - DidToggle = True; - PushNewRow(Ui); - } - else - { - DrawChildren = False; - } - } - - if (DrawChildren) - { - PushTableStart(Ui); - if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(work_queue*,&Element->LowPriority), - CSz("LowPriority"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(work_queue*,&Element->HighPriority), - CSz("HighPriority"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(work_queue*,&Element->RenderQ), - CSz("RenderQ"), - Params - ); - - - - - - - - - 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 - Cast(u32*,&Element->HighPriorityWorkerCount), - CSz("HighPriorityWorkerCount"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(bonsai_futex*,&Element->HighPriorityModeFutex), - CSz("HighPriorityModeFutex"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(bonsai_futex*,&Element->WorkerThreadsSuspendFutex), - CSz("WorkerThreadsSuspendFutex"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(bonsai_futex*,&Element->WorkerThreadsExitFutex), - CSz("WorkerThreadsExitFutex"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(thread_startup_params*, Element->Threads), - CSz("Threads"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(v2*,&Element->MouseP), - CSz("MouseP"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(v2*,&Element->MouseDP), - CSz("MouseDP"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(memory_arena*, Element->Memory), - CSz("Memory"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(r32*,&Element->GameTime), - CSz("GameTime"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(r32*,&Element->dt), - CSz("dt"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(v2*,&Element->ScreenDim), - CSz("ScreenDim"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input*,&Element->Input), - CSz("Input"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(server_state*, Element->ServerState), - CSz("ServerState"), - Params - ); - if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); - } - else - { - PushNewRow(Ui); - } - - } - else - { - PushColumn(Ui, Name, Params); - PushColumn(Ui, CSz("(null)"), Params); - PushNewRow(Ui); - } - -} - diff --git a/generated/do_editor_ui_for_compound_type_random_series.h b/generated/do_editor_ui_for_compound_type_random_series.h deleted file mode 100644 index d51491290..000000000 --- a/generated/do_editor_ui_for_compound_type_random_series.h +++ /dev/null @@ -1,61 +0,0 @@ -// src/engine/editor.cpp:201:0 - -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, random_series *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. - b32 DrawChildren = True; - b32 DidToggle = False; - if (Name.Count) - { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle random_series", Element), Params)) - { - DidToggle = True; - PushNewRow(Ui); - } - else - { - DrawChildren = False; - } - } - - if (DrawChildren) - { - PushTableStart(Ui); - if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u64*,&Element->Seed), - CSz("Seed"), - Params - ); - - - - - - - - PushNewRow(Ui); - if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); - } - else - { - PushNewRow(Ui); - } - - } - else - { - PushColumn(Ui, Name, Params); - PushColumn(Ui, CSz("(null)"), Params); - PushNewRow(Ui); - } - -} - diff --git a/generated/do_editor_ui_for_compound_type_ray.h b/generated/do_editor_ui_for_compound_type_ray.h new file mode 100644 index 000000000..d628f39a8 --- /dev/null +++ b/generated/do_editor_ui_for_compound_type_ray.h @@ -0,0 +1,103 @@ +// src/engine/editor.h:305:0 +struct ray; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, ray *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) + + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x291019BF); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle ray", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("Origin"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v3*, &Element->Origin), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Dir"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v3*, &Element->Dir), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} + diff --git a/generated/do_editor_ui_for_compound_type_rect3.h b/generated/do_editor_ui_for_compound_type_rect3.h index 45916a3df..669b1e088 100644 --- a/generated/do_editor_ui_for_compound_type_rect3.h +++ b/generated/do_editor_ui_for_compound_type_rect3.h @@ -1,8 +1,11 @@ -// src/engine/editor.h:509:0 +// src/engine/editor.h:305:0 +struct rect3; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, rect3 *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) + -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, rect3 *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) { + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x131D4A18); + if (Element) { // NOTE(Jesse): This is wacky as fuck, but it's a pretty easy way to support @@ -11,7 +14,7 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, rect3 *Element, cs Name, ui_r b32 DidToggle = False; if (Name.Count) { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle rect3", Element), Params)) + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle rect3", Element, ThisHash), Params)) { DidToggle = True; PushNewRow(Ui); @@ -24,32 +27,64 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, rect3 *Element, cs Name, ui_r if (DrawChildren) { - PushTableStart(Ui); + if (Name.Count) { PushTableStart(Ui); } + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(v3*,&Element->Min), - CSz("Min"), - Params - ); + + + { + + + + cs MemberName = CSz("Min"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v3*, &Element->Min), + MemberName, + ThisHash, + Params + ); + + + + } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(v3*,&Element->Max), - CSz("Max"), - Params - ); + + { + + + + cs MemberName = CSz("Max"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v3*, &Element->Max), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); + if (Name.Count) { PushTableEnd(Ui); } } else { diff --git a/generated/do_editor_ui_for_compound_type_rect3cp.h b/generated/do_editor_ui_for_compound_type_rect3cp.h index c1ff81ddd..3bc69133f 100644 --- a/generated/do_editor_ui_for_compound_type_rect3cp.h +++ b/generated/do_editor_ui_for_compound_type_rect3cp.h @@ -1,8 +1,11 @@ -// src/engine/editor.h:515:0 +// src/engine/editor.h:305:0 +struct rect3cp; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, rect3cp *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) + -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, rect3cp *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) { + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x2615C8C); + if (Element) { // NOTE(Jesse): This is wacky as fuck, but it's a pretty easy way to support @@ -11,7 +14,7 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, rect3cp *Element, cs Name, ui b32 DidToggle = False; if (Name.Count) { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle rect3cp", Element), Params)) + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle rect3cp", Element, ThisHash), Params)) { DidToggle = True; PushNewRow(Ui); @@ -24,32 +27,64 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, rect3cp *Element, cs Name, ui if (DrawChildren) { - PushTableStart(Ui); + if (Name.Count) { PushTableStart(Ui); } + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(cp*,&Element->Min), - CSz("Min"), - Params - ); + + + { + + + + cs MemberName = CSz("Min"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(cp*, &Element->Min), + MemberName, + ThisHash, + Params + ); + + + + } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(cp*,&Element->Max), - CSz("Max"), - Params - ); + + { + + + + cs MemberName = CSz("Max"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(cp*, &Element->Max), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); + if (Name.Count) { PushTableEnd(Ui); } } else { diff --git a/generated/do_editor_ui_for_compound_type_rect3i.h b/generated/do_editor_ui_for_compound_type_rect3i.h index 938458d43..11f2d7941 100644 --- a/generated/do_editor_ui_for_compound_type_rect3i.h +++ b/generated/do_editor_ui_for_compound_type_rect3i.h @@ -1,8 +1,11 @@ -// src/engine/editor.h:512:0 +// src/engine/editor.h:305:0 +struct rect3i; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, rect3i *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) + -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, rect3i *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) { + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0xEC90500); + if (Element) { // NOTE(Jesse): This is wacky as fuck, but it's a pretty easy way to support @@ -11,7 +14,7 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, rect3i *Element, cs Name, ui_ b32 DidToggle = False; if (Name.Count) { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle rect3i", Element), Params)) + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle rect3i", Element, ThisHash), Params)) { DidToggle = True; PushNewRow(Ui); @@ -24,32 +27,64 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, rect3i *Element, cs Name, ui_ if (DrawChildren) { - PushTableStart(Ui); + if (Name.Count) { PushTableStart(Ui); } + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(v3i*,&Element->Min), - CSz("Min"), - Params - ); + + + { + + + + cs MemberName = CSz("Min"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v3i*, &Element->Min), + MemberName, + ThisHash, + Params + ); + + + + } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(v3i*,&Element->Max), - CSz("Max"), - Params - ); + + { + + + + cs MemberName = CSz("Max"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v3i*, &Element->Max), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); + if (Name.Count) { PushTableEnd(Ui); } } else { 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 deleted file mode 100644 index 5d1a53bdc..000000000 --- a/generated/do_editor_ui_for_compound_type_render_buffers_2d.h +++ /dev/null @@ -1,162 +0,0 @@ -// src/engine/editor.cpp:395:0 - -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, render_buffers_2d *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. - b32 DrawChildren = True; - b32 DidToggle = False; - if (Name.Count) - { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle render_buffers_2d", Element), Params)) - { - DidToggle = True; - PushNewRow(Ui); - } - else - { - DrawChildren = False; - } - } - - if (DrawChildren) - { - PushTableStart(Ui); - if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u32*,&Element->SolidUIVertexBuffer), - CSz("SolidUIVertexBuffer"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u32*,&Element->SolidUIColorBuffer), - CSz("SolidUIColorBuffer"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u32*,&Element->SolidUIUVBuffer), - CSz("SolidUIUVBuffer"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(texture*,&Element->DebugTextureArray), - CSz("DebugTextureArray"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(s32*,&Element->TextTextureUniform), - CSz("TextTextureUniform"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(shader*,&Element->Text2DShader), - CSz("Text2DShader"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(shader*,&Element->SolidUIShader), - CSz("SolidUIShader"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(textured_2d_geometry_buffer*,&Element->Geo), - CSz("Geo"), - Params - ); - if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); - } - else - { - PushNewRow(Ui); - } - - } - else - { - PushColumn(Ui, Name, Params); - PushColumn(Ui, CSz("(null)"), Params); - PushNewRow(Ui); - } - -} - diff --git a/generated/do_editor_ui_for_compound_type_render_debug.h b/generated/do_editor_ui_for_compound_type_render_debug.h deleted file mode 100644 index 00c0a16dc..000000000 --- a/generated/do_editor_ui_for_compound_type_render_debug.h +++ /dev/null @@ -1,109 +0,0 @@ -// src/engine/editor.cpp:413:0 - -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, render_debug *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. - b32 DrawChildren = True; - b32 DidToggle = False; - if (Name.Count) - { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle render_debug", Element), Params)) - { - DidToggle = True; - PushNewRow(Ui); - } - else - { - DrawChildren = False; - } - } - - if (DrawChildren) - { - PushTableStart(Ui); - if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u32*,&Element->BytesSolidGeoLastFrame), - CSz("BytesSolidGeoLastFrame"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u32*,&Element->BytesTransGeoLastFrame), - CSz("BytesTransGeoLastFrame"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u32*,&Element->VertsDrawnLastFrame), - CSz("VertsDrawnLastFrame"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u32*,&Element->DrawCallsLastFrame), - CSz("DrawCallsLastFrame"), - Params - ); - - - - - - - - PushNewRow(Ui); - if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); - } - else - { - PushNewRow(Ui); - } - - } - else - { - PushColumn(Ui, Name, Params); - PushColumn(Ui, CSz("(null)"), Params); - PushNewRow(Ui); - } - -} - diff --git a/generated/do_editor_ui_for_compound_type_render_settings.h b/generated/do_editor_ui_for_compound_type_render_settings.h deleted file mode 100644 index ccd6643e7..000000000 --- a/generated/do_editor_ui_for_compound_type_render_settings.h +++ /dev/null @@ -1,269 +0,0 @@ -// src/engine/editor.cpp:195:0 - -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, render_settings *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. - b32 DrawChildren = True; - b32 DidToggle = False; - if (Name.Count) - { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle render_settings", Element), Params)) - { - DidToggle = True; - PushNewRow(Ui); - } - else - { - DrawChildren = False; - } - } - - if (DrawChildren) - { - PushTableStart(Ui); - if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - Cast(b8*,&Element->UseSsao), - CSz("UseSsao"), - &DefaultUiRenderParams_Checkbox - ); - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - Cast(b8*,&Element->UseShadowMapping), - CSz("UseShadowMapping"), - &DefaultUiRenderParams_Checkbox - ); - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - Cast(b8*,&Element->UseLightingBloom), - CSz("UseLightingBloom"), - &DefaultUiRenderParams_Checkbox - ); - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - Cast(b8*,&Element->BravoilMyersOIT), - CSz("BravoilMyersOIT"), - &DefaultUiRenderParams_Checkbox - ); - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - Cast(b8*,&Element->BravoilMcGuireOIT), - CSz("BravoilMcGuireOIT"), - &DefaultUiRenderParams_Checkbox - ); - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - Cast(b8*,&Element->DrawMajorGrid), - CSz("DrawMajorGrid"), - &DefaultUiRenderParams_Checkbox - ); - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - Cast(b8*,&Element->DrawMinorGrid), - CSz("DrawMinorGrid"), - &DefaultUiRenderParams_Checkbox - ); - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(r32*,&Element->MajorGridDim), - CSz("MajorGridDim"), - Params -,0, 32 ); - - - - - - - - PushNewRow(Ui); - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(tone_mapping_type*,&Element->ToneMappingType), - CSz("ToneMappingType"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(lighting_settings*,&Element->Lighting), - CSz("Lighting"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(v2*,&Element->ApplicationResolution), - CSz("ApplicationResolution"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(v2*,&Element->ShadowMapResolution), - CSz("ShadowMapResolution"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(v2*,&Element->LuminanceMapResolution), - CSz("LuminanceMapResolution"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(v2i*,&Element->iApplicationResolution), - CSz("iApplicationResolution"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(v2i*,&Element->iShadowMapResolution), - CSz("iShadowMapResolution"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(v2i*,&Element->iLuminanceMapResolution), - CSz("iLuminanceMapResolution"), - Params - ); - if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); - } - else - { - PushNewRow(Ui); - } - - } - else - { - PushColumn(Ui, Name, Params); - PushColumn(Ui, CSz("(null)"), Params); - PushNewRow(Ui); - } - -} - diff --git a/generated/do_editor_ui_for_compound_type_renderer_2d.h b/generated/do_editor_ui_for_compound_type_renderer_2d.h deleted file mode 100644 index 7228ebdea..000000000 --- a/generated/do_editor_ui_for_compound_type_renderer_2d.h +++ /dev/null @@ -1,431 +0,0 @@ -// src/engine/editor.cpp:398:0 - -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, renderer_2d *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. - b32 DrawChildren = True; - b32 DidToggle = False; - if (Name.Count) - { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle renderer_2d", Element), Params)) - { - DidToggle = True; - PushNewRow(Ui); - } - else - { - DrawChildren = False; - } - } - - if (DrawChildren) - { - PushTableStart(Ui); - if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(render_buffers_2d*, Element->TextGroup), - CSz("TextGroup"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(texture*,&Element->SpriteTextureArray), - CSz("SpriteTextureArray"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u64*,&Element->InteractionStackTop), - CSz("InteractionStackTop"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(v2*, Element->MouseP), - CSz("MouseP"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(v2*, Element->MouseDP), - CSz("MouseDP"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(v2*, Element->ScreenDim), - CSz("ScreenDim"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(input*, Element->Input), - CSz("Input"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(ui_toggle_hashtable*,&Element->ToggleTable), - CSz("ToggleTable"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(window_layout_hashtable*,&Element->WindowTable), - CSz("WindowTable"), - Params - ); - - - - - - - - - if (ToggleButton(Ui, CSz("v MinimizedWindowBuffer[64]"), CSz("> MinimizedWindowBuffer[64]"), UiId(Window, "toggle renderer_2d window_layout MinimizedWindowBuffer", Element->MinimizedWindowBuffer), Params )) - { - OPEN_INDENT_FOR_TOGGLEABLE_REGION(); - PushNewRow(Ui); - RangeIterator(ArrayIndex, 64) - { - DoEditorUi(Ui, Window, Element->MinimizedWindowBuffer+ArrayIndex, FSz("MinimizedWindowBuffer[%d]", ArrayIndex), Params); - - } - CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); - } - PushNewRow(Ui); - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(window_layout*, Element->HighestWindow), - CSz("HighestWindow"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(interactable*,&Element->Hover), - CSz("Hover"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(interactable*,&Element->Clicked), - CSz("Clicked"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(interactable*,&Element->Pressed), - CSz("Pressed"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - Cast(b8*,&Element->RequestedForceCapture), - CSz("RequestedForceCapture"), - &DefaultUiRenderParams_Checkbox - ); - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(text_box_edit_state*,&Element->TextEdit), - CSz("TextEdit"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(untextured_2d_geometry_buffer*,&Element->Geo), - CSz("Geo"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(shader*,&Element->TexturedQuadShader), - CSz("TexturedQuadShader"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(ui_render_command_buffer*, Element->CommandBuffer), - CSz("CommandBuffer"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(memory_arena*,&Element->RenderCommandArena), - CSz("RenderCommandArena"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(memory_arena*,&Element->UiToggleArena), - CSz("UiToggleArena"), - Params - ); - - - - - - - - - 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(); - PushNewRow(Ui); - RangeIterator(ArrayIndex, 128) - { - DoEditorUi(Ui, Window, Element->DebugColors+ArrayIndex, FSz("DebugColors[%d]", ArrayIndex), Params); - - } - CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); - } - PushNewRow(Ui); - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u32*,&Element->SolidGeoCountLastFrame), - CSz("SolidGeoCountLastFrame"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u32*,&Element->TextGeoCountLastFrame), - CSz("TextGeoCountLastFrame"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(v3_cursor*, Element->ColorPalette), - CSz("ColorPalette"), - Params - ); - if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); - } - else - { - PushNewRow(Ui); - } - - } - else - { - PushColumn(Ui, Name, Params); - PushColumn(Ui, CSz("(null)"), Params); - PushNewRow(Ui); - } - -} - diff --git a/generated/do_editor_ui_for_compound_type_shader.h b/generated/do_editor_ui_for_compound_type_shader.h deleted file mode 100644 index fca20aa40..000000000 --- a/generated/do_editor_ui_for_compound_type_shader.h +++ /dev/null @@ -1,108 +0,0 @@ -// src/engine/editor.cpp:392:0 - -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, shader *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. - b32 DrawChildren = True; - b32 DidToggle = False; - if (Name.Count) - { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle shader", Element), Params)) - { - DidToggle = True; - PushNewRow(Ui); - } - else - { - DrawChildren = False; - } - } - - if (DrawChildren) - { - PushTableStart(Ui); - if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u32*,&Element->ID), - CSz("ID"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(shader_uniform*, Element->FirstUniform), - CSz("FirstUniform"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(cs*,&Element->VertexSourceFilename), - CSz("VertexSourceFilename"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(cs*,&Element->FragSourceFilename), - CSz("FragSourceFilename"), - Params - ); - - - - - - - - PushNewRow(Ui); - if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); - } - else - { - PushNewRow(Ui); - } - - } - else - { - PushColumn(Ui, Name, Params); - PushColumn(Ui, CSz("(null)"), Params); - PushNewRow(Ui); - } - -} - diff --git a/generated/do_editor_ui_for_compound_type_shape_layer.h b/generated/do_editor_ui_for_compound_type_shape_layer.h deleted file mode 100644 index 51abf148d..000000000 --- a/generated/do_editor_ui_for_compound_type_shape_layer.h +++ /dev/null @@ -1,83 +0,0 @@ -// src/engine/editor.cpp:106:0 - -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, shape_layer *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. - b32 DrawChildren = True; - b32 DidToggle = False; - if (Name.Count) - { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle shape_layer", Element), Params)) - { - DidToggle = True; - PushNewRow(Ui); - } - else - { - DrawChildren = False; - } - } - - if (DrawChildren) - { - PushTableStart(Ui); - if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(shape_type*,&Element->Type), - CSz("Type"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(world_update_op_shape_params_sphere*,&Element->Sphere), - CSz("Sphere"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(world_update_op_shape_params_rect*,&Element->Rect), - CSz("Rect"), - Params - ); - if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); - } - else - { - PushNewRow(Ui); - } - - } - else - { - PushColumn(Ui, Name, Params); - PushColumn(Ui, CSz("(null)"), Params); - PushNewRow(Ui); - } - -} - diff --git a/generated/do_editor_ui_for_compound_type_struct_world_edit_brush.h b/generated/do_editor_ui_for_compound_type_struct_world_edit_brush.h new file mode 100644 index 000000000..4fe735dec --- /dev/null +++ b/generated/do_editor_ui_for_compound_type_struct_world_edit_brush.h @@ -0,0 +1,145 @@ +// src/engine/editor.h:305:0 +struct world_edit_brush; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, world_edit_brush *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) + + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x2083C45D); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle world_edit_brush", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("NameBuf"); + auto Value = CS(Element->NameBuf); + DoEditorUi(Ui, Window, &Value, MemberName, ThisHash, Params); + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("Mode"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(world_edit_blend_mode*, &Element->Mode), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Modifier"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(world_edit_blend_mode_modifier*, &Element->Modifier), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Layered"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(layered_brush*, &Element->Layered), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} + diff --git a/generated/do_editor_ui_for_compound_type_test_type.h b/generated/do_editor_ui_for_compound_type_test_type.h new file mode 100644 index 000000000..8e4645440 --- /dev/null +++ b/generated/do_editor_ui_for_compound_type_test_type.h @@ -0,0 +1,260 @@ +// src/engine/editor.h:305:0 +struct test_type; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, test_type *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) + + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x10B801); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle test_type", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("UnsignedNumber"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u32*, &Element->UnsignedNumber), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("FloatNumber"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(f32*, &Element->FloatNumber), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("SignedNumber"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(s32*, &Element->SignedNumber), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("Boolean"); + DoEditorUi(Ui, + Window, + Cast(b8*, &Element->Boolean), + MemberName, + ThisHash, + &DefaultUiRenderParams_Checkbox + ); + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = {}; + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(nested_type*, &Element->Nested), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("BasicEnum"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(test_enum*, &Element->BasicEnum), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("BitfieldEnum"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(bitfield_enum*, &Element->BitfieldEnum), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("RadioEnum"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(radio_enum*, &Element->RadioEnum), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} + diff --git a/generated/do_editor_ui_for_compound_type_texture.h b/generated/do_editor_ui_for_compound_type_texture.h deleted file mode 100644 index 135db4b0c..000000000 --- a/generated/do_editor_ui_for_compound_type_texture.h +++ /dev/null @@ -1,165 +0,0 @@ -// src/engine/editor.cpp:332:0 - -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, texture *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. - b32 DrawChildren = True; - b32 DidToggle = False; - if (Name.Count) - { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle texture", Element), Params)) - { - DidToggle = True; - PushNewRow(Ui); - } - else - { - DrawChildren = False; - } - } - - if (DrawChildren) - { - PushTableStart(Ui); - if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u32*,&Element->ID), - CSz("ID"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(v2i*,&Element->Dim), - CSz("Dim"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u32*,&Element->Slices), - CSz("Slices"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u32*,&Element->Channels), - CSz("Channels"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - Cast(b8*,&Element->IsDepthTexture), - CSz("IsDepthTexture"), - &DefaultUiRenderParams_Checkbox - ); - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(texture_storage_format*,&Element->Format), - CSz("Format"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(cs*,&Element->DebugName), - CSz("DebugName"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - Cast(b8*,&Element->Queued), - CSz("Queued"), - &DefaultUiRenderParams_Checkbox - ); - - - - - - PushNewRow(Ui); - if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); - } - else - { - PushNewRow(Ui); - } - - } - else - { - PushColumn(Ui, Name, Params); - PushColumn(Ui, CSz("(null)"), Params); - PushNewRow(Ui); - } - -} - diff --git a/generated/do_editor_ui_for_compound_type_ui_debug.h b/generated/do_editor_ui_for_compound_type_ui_debug.h deleted file mode 100644 index 1c71a3b1e..000000000 --- a/generated/do_editor_ui_for_compound_type_ui_debug.h +++ /dev/null @@ -1,141 +0,0 @@ -// src/engine/editor.cpp:416:0 - -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, ui_debug *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. - b32 DrawChildren = True; - b32 DidToggle = False; - if (Name.Count) - { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle ui_debug", Element), Params)) - { - DidToggle = True; - PushNewRow(Ui); - } - else - { - DrawChildren = False; - } - } - - if (DrawChildren) - { - PushTableStart(Ui); - if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(b8*,&Element->OutlineUiValues), - CSz("OutlineUiValues"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(b8*,&Element->OutlineUiButtons), - CSz("OutlineUiButtons"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(b8*,&Element->OutlineUiTables), - CSz("OutlineUiTables"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(b8*,&Element->OutlineUiTableColumns), - CSz("OutlineUiTableColumns"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(b8*,&Element->DebugBreakOnElementClick), - CSz("DebugBreakOnElementClick"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(b8*,&Element->DebugBreakUiCommand), - CSz("DebugBreakUiCommand"), - Params - ); - - - - - - - - PushNewRow(Ui); - if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); - } - else - { - PushNewRow(Ui); - } - - } - else - { - PushColumn(Ui, Name, Params); - PushColumn(Ui, CSz("(null)"), Params); - PushNewRow(Ui); - } - -} - diff --git a/generated/do_editor_ui_for_compound_type_ui_id.h b/generated/do_editor_ui_for_compound_type_ui_id.h deleted file mode 100644 index a9d61dd61..000000000 --- a/generated/do_editor_ui_for_compound_type_ui_id.h +++ /dev/null @@ -1,109 +0,0 @@ -// src/engine/editor.cpp:115:0 - -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, ui_id *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. - b32 DrawChildren = True; - b32 DidToggle = False; - if (Name.Count) - { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle ui_id", Element), Params)) - { - DidToggle = True; - PushNewRow(Ui); - } - else - { - DrawChildren = False; - } - } - - if (DrawChildren) - { - PushTableStart(Ui); - if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u32*,&Element->_Reserved), - CSz("_Reserved"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u32*,&Element->WindowBits), - CSz("WindowBits"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u32*,&Element->InteractionBits), - CSz("InteractionBits"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u32*,&Element->ElementBits), - CSz("ElementBits"), - Params - ); - - - - - - - - PushNewRow(Ui); - if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); - } - else - { - PushNewRow(Ui); - } - - } - else - { - PushColumn(Ui, Name, Params); - PushColumn(Ui, CSz("(null)"), Params); - PushNewRow(Ui); - } - -} - diff --git a/generated/do_editor_ui_for_compound_type_ui_toggle.h b/generated/do_editor_ui_for_compound_type_ui_toggle.h deleted file mode 100644 index 1d75ae5d0..000000000 --- a/generated/do_editor_ui_for_compound_type_ui_toggle.h +++ /dev/null @@ -1,73 +0,0 @@ -// src/engine/editor.cpp:118:0 - -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, ui_toggle *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. - b32 DrawChildren = True; - b32 DidToggle = False; - if (Name.Count) - { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle ui_toggle", Element), Params)) - { - DidToggle = True; - PushNewRow(Ui); - } - else - { - DrawChildren = False; - } - } - - if (DrawChildren) - { - PushTableStart(Ui); - if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(ui_id*,&Element->Id), - CSz("Id"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - Cast(b8*,&Element->ToggledOn), - CSz("ToggledOn"), - &DefaultUiRenderParams_Checkbox - ); - - - - - - PushNewRow(Ui); - if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); - } - else - { - PushNewRow(Ui); - } - - } - else - { - PushColumn(Ui, Name, Params); - PushColumn(Ui, CSz("(null)"), Params); - PushNewRow(Ui); - } - -} - 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 deleted file mode 100644 index 1455da6e2..000000000 --- a/generated/do_editor_ui_for_compound_type_untextured_3d_geometry_buffer.h +++ /dev/null @@ -1,190 +0,0 @@ -// src/engine/editor.cpp:225:0 - -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, untextured_3d_geometry_buffer *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. - b32 DrawChildren = True; - b32 DidToggle = False; - if (Name.Count) - { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle untextured_3d_geometry_buffer", Element), Params)) - { - DidToggle = True; - PushNewRow(Ui); - } - else - { - DrawChildren = False; - } - } - - if (DrawChildren) - { - 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, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(vertex_material*, Element->Mat), - CSz("Mat"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u32*,&Element->End), - CSz("End"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u32*,&Element->At), - CSz("At"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(untextured_3d_geometry_buffer*, Element->Parent), - CSz("Parent"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u32*,&Element->BufferNeedsToGrow), - CSz("BufferNeedsToGrow"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u64*,&Element->Timestamp), - CSz("Timestamp"), - Params - ); - - - - - - - - PushNewRow(Ui); - if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); - } - else - { - PushNewRow(Ui); - } - - } - else - { - PushColumn(Ui, Name, Params); - PushColumn(Ui, CSz("(null)"), Params); - PushNewRow(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 deleted file mode 100644 index 160f9a583..000000000 --- a/generated/do_editor_ui_for_compound_type_vertex_material.h +++ /dev/null @@ -1,93 +0,0 @@ -// src/engine/editor.cpp:219:0 - -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, vertex_material *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. - b32 DrawChildren = True; - b32 DidToggle = False; - if (Name.Count) - { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle vertex_material", Element), Params)) - { - DidToggle = True; - PushNewRow(Ui); - } - else - { - DrawChildren = False; - } - } - - if (DrawChildren) - { - PushTableStart(Ui); - if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u16*,&Element->ColorIndex), - CSz("ColorIndex"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u8*,&Element->Transparency), - CSz("Transparency"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u8*,&Element->Emission), - CSz("Emission"), - Params - ); - - - - - - - - PushNewRow(Ui); - if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); - } - else - { - PushNewRow(Ui); - } - - } - else - { - PushColumn(Ui, Name, Params); - PushColumn(Ui, CSz("(null)"), Params); - PushNewRow(Ui); - } - -} - 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 deleted file mode 100644 index 386ea0d09..000000000 --- a/generated/do_editor_ui_for_compound_type_voronoi_noise_params.h +++ /dev/null @@ -1,124 +0,0 @@ -// src/engine/editor.cpp:97:0 - -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, voronoi_noise_params *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. - b32 DrawChildren = True; - b32 DidToggle = False; - if (Name.Count) - { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle voronoi_noise_params", Element), Params)) - { - DidToggle = True; - PushNewRow(Ui); - } - else - { - DrawChildren = False; - } - } - - if (DrawChildren) - { - PushTableStart(Ui); - if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(r32*,&Element->Threshold), - CSz("Threshold"), - Params -,0.1f, 20.f ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(v3*,&Element->Period), - CSz("Period"), - Params -,0.1f, 20.f ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(r32*,&Element->Amplitude), - CSz("Amplitude"), - Params -,0.1f, 20.f ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(r32*,&Element->Squareness), - CSz("Squareness"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(r32*,&Element->MaskChance), - CSz("MaskChance"), - Params - ); - - - - - - - - PushNewRow(Ui); - if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); - } - else - { - PushNewRow(Ui); - } - - } - else - { - PushColumn(Ui, Name, Params); - PushColumn(Ui, CSz("(null)"), Params); - PushNewRow(Ui); - } - -} - 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 754827d0e..cd878dbae 100644 --- a/generated/do_editor_ui_for_compound_type_vox_data.h +++ b/generated/do_editor_ui_for_compound_type_vox_data.h @@ -1,8 +1,11 @@ -// src/engine/editor.cpp:255:0 +// src/engine/editor.h:305:0 +struct vox_data; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, vox_data *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) + -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, vox_data *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) { + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0xD3FBFEF); + if (Element) { // NOTE(Jesse): This is wacky as fuck, but it's a pretty easy way to support @@ -11,7 +14,7 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, vox_data *Element, cs Name, u b32 DidToggle = False; if (Name.Count) { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle vox_data", Element), Params)) + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle vox_data", Element, ThisHash), Params)) { DidToggle = True; PushNewRow(Ui); @@ -24,17 +27,38 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, vox_data *Element, cs Name, u if (DrawChildren) { - PushTableStart(Ui); + if (Name.Count) { PushTableStart(Ui); } + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(chunk_data*, Element->ChunkData), - CSz("ChunkData"), - Params - ); + + + { + + + + cs MemberName = CSz("ChunkData"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(chunk_data*, Element->ChunkData), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); + if (Name.Count) { PushTableEnd(Ui); } } else { diff --git a/generated/do_editor_ui_for_compound_type_voxel.h b/generated/do_editor_ui_for_compound_type_voxel.h index 3ab6c01ac..a09219244 100644 --- a/generated/do_editor_ui_for_compound_type_voxel.h +++ b/generated/do_editor_ui_for_compound_type_voxel.h @@ -1,8 +1,11 @@ -// src/engine/editor.cpp:246:0 +// src/engine/editor.h:305:0 +struct voxel; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, voxel *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) + -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, voxel *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) { + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x4BBC2BC); + if (Element) { // NOTE(Jesse): This is wacky as fuck, but it's a pretty easy way to support @@ -11,7 +14,7 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, voxel *Element, cs Name, ui_r b32 DidToggle = False; if (Name.Count) { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle voxel", Element), Params)) + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle voxel", Element, ThisHash), Params)) { DidToggle = True; PushNewRow(Ui); @@ -24,57 +27,30 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, voxel *Element, cs Name, ui_r if (DrawChildren) { - PushTableStart(Ui); - if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u8*,&Element->Flags), - CSz("Flags"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u8*,&Element->Transparency), - CSz("Transparency"), - Params - ); - - - - + if (Name.Count) { PushTableStart(Ui); } + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + { + + + + cs MemberName = CSz("(anonymous)"); + - PushNewRow(Ui); - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u16*,&Element->Color), - CSz("Color"), - Params - ); + + } - PushNewRow(Ui); if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); + if (Name.Count) { PushTableEnd(Ui); } } else { 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 6b115127a..e9a3d4d8e 100644 --- a/generated/do_editor_ui_for_compound_type_voxel_lighting.h +++ b/generated/do_editor_ui_for_compound_type_voxel_lighting.h @@ -1,8 +1,11 @@ -// src/engine/editor.cpp:249:0 +// src/engine/editor.h:305:0 +struct voxel_lighting; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, voxel_lighting *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) + -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, voxel_lighting *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) { + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x21DD9FD4); + if (Element) { // NOTE(Jesse): This is wacky as fuck, but it's a pretty easy way to support @@ -11,7 +14,7 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, voxel_lighting *Element, cs N b32 DidToggle = False; if (Name.Count) { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle voxel_lighting", Element), Params)) + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle voxel_lighting", Element, ThisHash), Params)) { DidToggle = True; PushNewRow(Ui); @@ -24,25 +27,39 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, voxel_lighting *Element, cs N if (DrawChildren) { - PushTableStart(Ui); + if (Name.Count) { PushTableStart(Ui); } + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u8*,&Element->Emission), - CSz("Emission"), - Params - ); + + { + + + + cs MemberName = CSz("Emission"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u8*, &Element->Emission), + MemberName, + ThisHash, + Params + ); - PushNewRow(Ui); + + PushNewRow(Ui); + + + + } + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); + if (Name.Count) { PushTableEnd(Ui); } } else { diff --git a/generated/do_editor_ui_for_compound_type_white_noise_params.h b/generated/do_editor_ui_for_compound_type_white_noise_params.h deleted file mode 100644 index 4d21555df..000000000 --- a/generated/do_editor_ui_for_compound_type_white_noise_params.h +++ /dev/null @@ -1,61 +0,0 @@ -// src/engine/editor.cpp:91:0 - -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, white_noise_params *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. - b32 DrawChildren = True; - b32 DidToggle = False; - if (Name.Count) - { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle white_noise_params", Element), Params)) - { - DidToggle = True; - PushNewRow(Ui); - } - else - { - DrawChildren = False; - } - } - - if (DrawChildren) - { - PushTableStart(Ui); - if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(r32*,&Element->Threshold), - CSz("Threshold"), - Params - ); - - - - - - - - PushNewRow(Ui); - if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); - } - else - { - PushNewRow(Ui); - } - - } - else - { - PushColumn(Ui, Name, Params); - PushColumn(Ui, CSz("(null)"), Params); - PushNewRow(Ui); - } - -} - diff --git a/generated/do_editor_ui_for_compound_type_work_queue.h b/generated/do_editor_ui_for_compound_type_work_queue.h deleted file mode 100644 index 06f28d9ca..000000000 --- a/generated/do_editor_ui_for_compound_type_work_queue.h +++ /dev/null @@ -1,100 +0,0 @@ -// src/engine/editor.cpp:136:0 - -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, work_queue *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. - b32 DrawChildren = True; - b32 DidToggle = False; - if (Name.Count) - { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle work_queue", Element), Params)) - { - DidToggle = True; - PushNewRow(Ui); - } - else - { - DrawChildren = False; - } - } - - if (DrawChildren) - { - PushTableStart(Ui); - if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(bonsai_futex*,&Element->EnqueueFutex), - CSz("EnqueueFutex"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u32*,&Element->EnqueueIndex), - CSz("EnqueueIndex"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u32*,&Element->DequeueIndex), - CSz("DequeueIndex"), - Params - ); - - - - - - - - PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(work_queue_entry*, Element->Entries), - CSz("Entries"), - Params - ); - if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); - } - else - { - PushNewRow(Ui); - } - - } - else - { - PushColumn(Ui, Name, Params); - PushColumn(Ui, CSz("(null)"), Params); - PushNewRow(Ui); - } - -} - 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 7dce80638..ab83ecbd2 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,8 +1,11 @@ -// src/engine/editor.cpp:133:0 +// src/engine/editor.h:305:0 +struct work_queue_entry; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, work_queue_entry *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) + -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, work_queue_entry *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) { + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x3A80B56C); + if (Element) { // NOTE(Jesse): This is wacky as fuck, but it's a pretty easy way to support @@ -11,7 +14,7 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, work_queue_entry *Element, cs b32 DidToggle = False; if (Name.Count) { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle work_queue_entry", Element), Params)) + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle work_queue_entry", Element, ThisHash), Params)) { DidToggle = True; PushNewRow(Ui); @@ -24,26 +27,56 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, work_queue_entry *Element, cs if (DrawChildren) { - PushTableStart(Ui); + if (Name.Count) { PushTableStart(Ui); } + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(work_queue_entry_type*,&Element->Type), - CSz("Type"), - Params - ); + + + { + + + + cs MemberName = CSz("Type"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(work_queue_entry_type*, &Element->Type), + MemberName, + ThisHash, + Params + ); + + + + } + { + + + + cs MemberName = CSz("(anonymous)"); + + + + + + + + + + + } + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); + if (Name.Count) { PushTableEnd(Ui); } } else { diff --git a/generated/do_editor_ui_for_compound_type_world.h b/generated/do_editor_ui_for_compound_type_world.h index a4b0db13d..f9c813a10 100644 --- a/generated/do_editor_ui_for_compound_type_world.h +++ b/generated/do_editor_ui_for_compound_type_world.h @@ -1,8 +1,11 @@ -// src/engine/editor.cpp:189:0 +// src/engine/editor.h:305:0 +struct world; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, world *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) + -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, world *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) { + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x108363A); + if (Element) { // NOTE(Jesse): This is wacky as fuck, but it's a pretty easy way to support @@ -11,7 +14,7 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, world *Element, cs Name, ui_r b32 DidToggle = False; if (Name.Count) { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle world", Element), Params)) + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle world", Element, ThisHash), Params)) { DidToggle = True; PushNewRow(Ui); @@ -24,15 +27,24 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, world *Element, cs Name, ui_r if (DrawChildren) { - PushTableStart(Ui); + if (Name.Count) { PushTableStart(Ui); } + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(v3i*,&Element->Center), - CSz("Center"), - Params - ); + + + { + + + + cs MemberName = CSz("Center"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v3i*, &Element->Center), + MemberName, + ThisHash, + Params + ); @@ -40,88 +52,318 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, world *Element, cs Name, ui_r + + + + } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(v3i*,&Element->VisibleRegion), - CSz("VisibleRegion"), - Params - ); + { + + + + cs MemberName = CSz("VisibleRegionSize"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(visible_region_size*, &Element->VisibleRegionSize), + MemberName, + ThisHash, + Params + ); + + + + + } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u32*,&Element->HashSlotsUsed), - CSz("HashSlotsUsed"), - Params - ); + { + + + + cs MemberName = CSz("Root"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(octree_node*, &Element->Root), + MemberName, + ThisHash, + Params + ); - PushNewRow(Ui); - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u32*,&Element->HashSize), - CSz("HashSize"), - Params - ); + + + + } + + { + + + + cs MemberName = CSz("OctreeMemory"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(memory_arena*, Element->OctreeMemory), + MemberName, + ThisHash, + Params + ); - PushNewRow(Ui); - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(world_chunk*, Element->ChunkHash), - CSz("ChunkHash"), - Params - ); + + + + } + + + { + + + + cs MemberName = CSz("OctreeNodeFreelist"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(octree_node_freelist*, &Element->OctreeNodeFreelist), + MemberName, + ThisHash, + Params + ); + + + + } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(s32*,&Element->FreeChunkCount), - CSz("FreeChunkCount"), - Params - ); + { + + + + cs MemberName = CSz("OctreeNodeDeferFreelist"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(octree_node_freelist*, &Element->OctreeNodeDeferFreelist), + MemberName, + ThisHash, + Params + ); - PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("MaxOctreeNodesToQueuePerFrame"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(s32*, &Element->MaxOctreeNodesToQueuePerFrame), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("ChunksPerResolutionStep"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(s32*, &Element->ChunksPerResolutionStep), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("ChunkFreelistFutex"); + + + } + + + { + + + + cs MemberName = CSz("ChunkFreelistSentinal"); + + + } + + + { + + + + cs MemberName = CSz("FreeChunkCount"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(s32*, &Element->FreeChunkCount), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("TotalChunksAllocated"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(s32*, &Element->TotalChunksAllocated), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("TotalGenChunksAllocated"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(s32*, &Element->TotalGenChunksAllocated), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("ChunkDim"); + + + } + + + { + + + + cs MemberName = CSz("ChunkMemory"); + + + } if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); + if (Name.Count) { PushTableEnd(Ui); } } else { 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 d0b599370..70d1126b7 100644 --- a/generated/do_editor_ui_for_compound_type_world_chunk.h +++ b/generated/do_editor_ui_for_compound_type_world_chunk.h @@ -1,8 +1,11 @@ -// src/engine/editor.cpp:298:0 +// src/engine/editor.h:305:0 +struct world_chunk; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, world_chunk *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) + -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, world_chunk *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) { + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x3331643E); + if (Element) { // NOTE(Jesse): This is wacky as fuck, but it's a pretty easy way to support @@ -11,7 +14,7 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, world_chunk *Element, cs Name b32 DidToggle = False; if (Name.Count) { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle world_chunk", Element), Params)) + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle world_chunk", Element, ThisHash), Params)) { DidToggle = True; PushNewRow(Ui); @@ -24,270 +27,326 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, world_chunk *Element, cs Name if (DrawChildren) { - PushTableStart(Ui); + if (Name.Count) { PushTableStart(Ui); } + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(world_chunk*, Element->Next), - CSz("Next"), - Params - ); + + + { + + + + cs MemberName = CSz("Next"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(world_chunk*, Element->Next), + MemberName, + ThisHash, + Params + ); + + + + } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(chunk_flag*,&Element->Flags), - CSz("Flags"), - Params - ); + { + + + + cs MemberName = CSz("Dim"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v3i*, &Element->Dim), + MemberName, + ThisHash, + Params + ); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(v3i*,&Element->Dim), - CSz("Dim"), - Params - ); + + } + + { + + + + cs MemberName = CSz("Occupancy"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u64*, Element->Occupancy), + MemberName, + ThisHash, + Params + ); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(voxel*, Element->Voxels), - CSz("Voxels"), - Params - ); + PushNewRow(Ui); + } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(voxel_lighting*, Element->VoxelLighting), - CSz("VoxelLighting"), - Params - ); + { + + + + cs MemberName = CSz("xOccupancyBorder"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u64*, Element->xOccupancyBorder), + MemberName, + ThisHash, + Params + ); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(lod_element_buffer*,&Element->Meshes), - CSz("Meshes"), - Params - ); + + PushNewRow(Ui); + } + + { + + + + cs MemberName = CSz("FaceMasks"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u64*, Element->FaceMasks), + MemberName, + ThisHash, + Params + ); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(voxel_position_cursor*,&Element->StandingSpots), - CSz("StandingSpots"), - Params - ); + PushNewRow(Ui); + } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(v3i*,&Element->WorldP), - CSz("WorldP"), - Params - ); + { + + + + cs MemberName = CSz("IsOnFreelist"); + DoEditorUi(Ui, + Window, + Cast(b8*, &Element->IsOnFreelist), + MemberName, + ThisHash, + &DefaultUiRenderParams_Checkbox + ); + PushNewRow(Ui); - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(s32*,&Element->FilledCount), - CSz("FilledCount"), - Params - ); + } + + { + + + + cs MemberName = CSz("Handles"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(gpu_element_buffer_handles*, &Element->Handles), + MemberName, + ThisHash, + Params + ); - PushNewRow(Ui); - DoEditorUi(Ui, - Window, - Cast(b8*,&Element->DrawBoundingVoxels), - CSz("DrawBoundingVoxels"), - &DefaultUiRenderParams_Checkbox - ); + + } + - PushNewRow(Ui); + { + + + + cs MemberName = CSz("StandingSpots"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(voxel_position_cursor*, &Element->StandingSpots), + MemberName, + ThisHash, + Params + ); - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(s32*,&Element->PointsToLeaveRemaining), - CSz("PointsToLeaveRemaining"), - Params - ); + - PushNewRow(Ui); - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u32*,&Element->TriCount), - CSz("TriCount"), - Params - ); + } + + { + + + + cs MemberName = CSz("DimInChunks"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v3i*, &Element->DimInChunks), + MemberName, + ThisHash, + Params + ); - PushNewRow(Ui); - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(s32*,&Element->EdgeBoundaryVoxelCount), - CSz("EdgeBoundaryVoxelCount"), - Params - ); + + } + + { + + + + cs MemberName = CSz("WorldP"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v3i*, &Element->WorldP), + MemberName, + ThisHash, + Params + ); - PushNewRow(Ui); - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(u32*,&Element->_Pad0), - CSz("_Pad0"), - Params - ); + + } + + { + + + + cs MemberName = CSz("FilledCount"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(s32*, &Element->FilledCount), + MemberName, + ThisHash, + Params + ); - PushNewRow(Ui); - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(entity_ptr_block_array*,&Element->Entities), - CSz("Entities"), - Params - ); + PushNewRow(Ui); + } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(s32*,&Element->DEBUG_OwnedByThread), - CSz("DEBUG_OwnedByThread"), - Params - ); + { + + + + cs MemberName = CSz("Entities"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(entity_ptr_block_array*, &Element->Entities), + MemberName, + ThisHash, + Params + ); - PushNewRow(Ui); - if (ToggleButton(Ui, CSz("v _Pad1[28]"), CSz("> _Pad1[28]"), UiId(Window, "toggle world_chunk u8 _Pad1", Element->_Pad1), Params )) - { - OPEN_INDENT_FOR_TOGGLEABLE_REGION(); - PushNewRow(Ui); - RangeIterator(ArrayIndex, 28) - { - DoEditorUi(Ui, Window, Element->_Pad1+ArrayIndex, FSz("_Pad1[%d]", ArrayIndex), Params); - PushNewRow(Ui); - } - CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); - } - PushNewRow(Ui); + + } - PushNewRow(Ui); if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); + if (Name.Count) { PushTableEnd(Ui); } } else { diff --git a/generated/do_editor_ui_for_compound_type_world_edit_block_array_index.h b/generated/do_editor_ui_for_compound_type_world_edit_block_array_index.h new file mode 100644 index 000000000..f035b8182 --- /dev/null +++ b/generated/do_editor_ui_for_compound_type_world_edit_block_array_index.h @@ -0,0 +1,78 @@ +// src/engine/editor.h:305:0 +struct world_edit_block_array_index; +link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, world_edit_block_array_index *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) + + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x24CF6D11); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle world_edit_block_array_index", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("Index"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(umm*, &Element->Index), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} + 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 deleted file mode 100644 index 5cac4793e..000000000 --- a/generated/do_editor_ui_for_compound_type_world_edit_brush.h +++ /dev/null @@ -1,83 +0,0 @@ -// src/engine/editor.h:779:0 - -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, world_edit_brush *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. - b32 DrawChildren = True; - b32 DidToggle = False; - if (Name.Count) - { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle world_edit_brush", Element), Params)) - { - DidToggle = True; - PushNewRow(Ui); - } - else - { - DrawChildren = False; - } - } - - if (DrawChildren) - { - PushTableStart(Ui); - if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(world_edit_shape*,&Element->Shape), - CSz("Shape"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(world_edit_mode*,&Element->Mode), - CSz("Mode"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(world_edit_mode_modifier*,&Element->Modifier), - CSz("Modifier"), - Params - ); - if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); - } - else - { - PushNewRow(Ui); - } - - } - else - { - PushColumn(Ui, Name, Params); - PushColumn(Ui, CSz("(null)"), Params); - PushNewRow(Ui); - } - -} - 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 deleted file mode 100644 index 101758980..000000000 --- a/generated/do_editor_ui_for_compound_type_world_edit_params.h +++ /dev/null @@ -1,91 +0,0 @@ -// src/engine/editor.h:710:0 - -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, world_edit_params *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. - b32 DrawChildren = True; - b32 DidToggle = False; - if (Name.Count) - { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle world_edit_params", Element), Params)) - { - DidToggle = True; - PushNewRow(Ui); - } - else - { - DrawChildren = False; - } - } - - if (DrawChildren) - { - PushTableStart(Ui); - if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(world_edit_mode*,&Element->Mode), - CSz("Mode"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(world_edit_mode_modifier*,&Element->Modifier), - CSz("Modifier"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(s32*,&Element->Iterations), - CSz("Iterations"), - Params - ); - - - - - - - - PushNewRow(Ui); - if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); - } - else - { - PushNewRow(Ui); - } - - } - else - { - PushColumn(Ui, Name, Params); - PushColumn(Ui, CSz("(null)"), Params); - PushNewRow(Ui); - } - -} - 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 deleted file mode 100644 index b34ccc13d..000000000 --- a/generated/do_editor_ui_for_compound_type_world_update_op_shape_params_rect.h +++ /dev/null @@ -1,53 +0,0 @@ -// src/engine/editor.cpp:102: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) -{ - 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. - b32 DrawChildren = True; - b32 DidToggle = False; - if (Name.Count) - { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle world_update_op_shape_params_rect", Element), Params)) - { - DidToggle = True; - PushNewRow(Ui); - } - else - { - DrawChildren = False; - } - } - - if (DrawChildren) - { - PushTableStart(Ui); - if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(rect3*,&Element->Region), - CSz("Region"), - Params - ); - if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); - } - else - { - PushNewRow(Ui); - } - - } - else - { - PushColumn(Ui, Name, Params); - PushColumn(Ui, CSz("(null)"), Params); - PushNewRow(Ui); - } - -} - 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 deleted file mode 100644 index 8f5e26cf8..000000000 --- a/generated/do_editor_ui_for_compound_type_world_update_op_shape_params_sphere.h +++ /dev/null @@ -1,76 +0,0 @@ -// src/engine/editor.cpp:100: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) -{ - 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. - b32 DrawChildren = True; - b32 DidToggle = False; - if (Name.Count) - { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle world_update_op_shape_params_sphere", Element), Params)) - { - DidToggle = True; - PushNewRow(Ui); - } - else - { - DrawChildren = False; - } - } - - if (DrawChildren) - { - PushTableStart(Ui); - if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(cp*,&Element->Location), - CSz("Location"), - Params - ); - - - - - - - - - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast(f32*,&Element->Radius), - CSz("Radius"), - Params - ); - - - - - - - - PushNewRow(Ui); - if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); - } - else - { - PushNewRow(Ui); - } - - } - else - { - PushColumn(Ui, Name, Params); - PushColumn(Ui, CSz("(null)"), Params); - PushNewRow(Ui); - } - -} - 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 c21a31bd0..8bc34af27 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,16 +1,17 @@ -// src/engine/editor.cpp:295:0 - +// src/engine/editor.h:545:0 link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, entity_ptr_block_array *Container, cs Name, EDITOR_UI_FUNCTION_PROTO_DEFAULTS) +DoEditorUi(renderer_2d *Ui, window_layout *Window, entity_ptr_block_array *Container, cs Name, u32 ParentHash, EDITOR_UI_FUNCTION_PROTO_DEFAULTS) { + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x10C521DD); + if (Container) { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, Name.Start, Container), EDITOR_UI_FUNCTION_INSTANCE_NAMES)) + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, Name.Start, Container, ThisHash), EDITOR_UI_FUNCTION_INSTANCE_NAMES)) { PushNewRow(Ui); IterateOver(Container, Element, ElementIndex) { - DoEditorUi(Ui, Window, Element, CS(ElementIndex), EDITOR_UI_FUNCTION_INSTANCE_NAMES); + DoEditorUi(Ui, Window, Element, CS(ElementIndex), ThisHash, EDITOR_UI_FUNCTION_INSTANCE_NAMES); PushNewRow(Ui); } } diff --git a/generated/do_editor_ui_for_container_model_buffer.h b/generated/do_editor_ui_for_container_model_buffer.h index 792661d54..657a860f6 100644 --- a/generated/do_editor_ui_for_container_model_buffer.h +++ b/generated/do_editor_ui_for_container_model_buffer.h @@ -1,16 +1,17 @@ -// src/engine/editor.cpp:270:0 - +// src/engine/editor.h:545:0 link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, model_buffer *Container, cs Name, EDITOR_UI_FUNCTION_PROTO_DEFAULTS) +DoEditorUi(renderer_2d *Ui, window_layout *Window, model_buffer *Container, cs Name, u32 ParentHash, EDITOR_UI_FUNCTION_PROTO_DEFAULTS) { + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x25099996); + if (Container) { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, Name.Start, Container), EDITOR_UI_FUNCTION_INSTANCE_NAMES)) + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, Name.Start, Container, ThisHash), EDITOR_UI_FUNCTION_INSTANCE_NAMES)) { PushNewRow(Ui); IterateOver(Container, Element, ElementIndex) { - DoEditorUi(Ui, Window, Element, CS(ElementIndex), EDITOR_UI_FUNCTION_INSTANCE_NAMES); + DoEditorUi(Ui, Window, Element, CS(ElementIndex), ThisHash, EDITOR_UI_FUNCTION_INSTANCE_NAMES); PushNewRow(Ui); } } diff --git a/generated/do_editor_ui_for_container_shader_ptr_block_array.h b/generated/do_editor_ui_for_container_shader_ptr_block_array.h new file mode 100644 index 000000000..faf155111 --- /dev/null +++ b/generated/do_editor_ui_for_container_shader_ptr_block_array.h @@ -0,0 +1,27 @@ +// src/engine/editor.h:545:0 +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, shader_ptr_block_array *Container, cs Name, u32 ParentHash, EDITOR_UI_FUNCTION_PROTO_DEFAULTS) +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x11F70127); + + if (Container) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, Name.Start, Container, ThisHash), EDITOR_UI_FUNCTION_INSTANCE_NAMES)) + { + PushNewRow(Ui); + IterateOver(Container, Element, ElementIndex) + { + DoEditorUi(Ui, Window, Element, CS(ElementIndex), ThisHash, EDITOR_UI_FUNCTION_INSTANCE_NAMES); + PushNewRow(Ui); + } + } + PushNewRow(Ui); + } + else + { + PushColumn(Ui, FSz("%S", Name), EDITOR_UI_FUNCTION_INSTANCE_NAMES); + PushColumn(Ui, CSz("(null)"), EDITOR_UI_FUNCTION_INSTANCE_NAMES); + PushNewRow(Ui); + } +} + diff --git a/generated/do_editor_ui_for_container_struct.h b/generated/do_editor_ui_for_container_struct.h new file mode 100644 index 000000000..0472c0fbe --- /dev/null +++ b/generated/do_editor_ui_for_container_struct.h @@ -0,0 +1,27 @@ +// src/engine/editor.h:545:0 +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, shader_uniform_buffer *Container, cs Name, u32 ParentHash, EDITOR_UI_FUNCTION_PROTO_DEFAULTS) +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x1E4DB918); + + if (Container) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, Name.Start, Container, ThisHash), EDITOR_UI_FUNCTION_INSTANCE_NAMES)) + { + PushNewRow(Ui); + IterateOver(Container, Element, ElementIndex) + { + DoEditorUi(Ui, Window, Element, CS(ElementIndex), ThisHash, EDITOR_UI_FUNCTION_INSTANCE_NAMES); + PushNewRow(Ui); + } + } + PushNewRow(Ui); + } + else + { + PushColumn(Ui, FSz("%S", Name), EDITOR_UI_FUNCTION_INSTANCE_NAMES); + PushColumn(Ui, CSz("(null)"), EDITOR_UI_FUNCTION_INSTANCE_NAMES); + PushNewRow(Ui); + } +} + 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 0704f5296..e29d48541 100644 --- a/generated/do_editor_ui_for_container_ui_toggle_hashtable.h +++ b/generated/do_editor_ui_for_container_ui_toggle_hashtable.h @@ -1,16 +1,17 @@ -// src/engine/editor.cpp:127:0 - +// src/engine/editor.h:545:0 link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, ui_toggle_hashtable *Container, cs Name, EDITOR_UI_FUNCTION_PROTO_DEFAULTS) +DoEditorUi(renderer_2d *Ui, window_layout *Window, ui_toggle_hashtable *Container, cs Name, u32 ParentHash, EDITOR_UI_FUNCTION_PROTO_DEFAULTS) { + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x11C9E45C); + if (Container) { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, Name.Start, Container), EDITOR_UI_FUNCTION_INSTANCE_NAMES)) + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, Name.Start, Container, ThisHash), EDITOR_UI_FUNCTION_INSTANCE_NAMES)) { PushNewRow(Ui); IterateOver(Container, Element, ElementIndex) { - DoEditorUi(Ui, Window, Element, CS(ElementIndex), EDITOR_UI_FUNCTION_INSTANCE_NAMES); + DoEditorUi(Ui, Window, Element, CS(ElementIndex), ThisHash, EDITOR_UI_FUNCTION_INSTANCE_NAMES); PushNewRow(Ui); } } diff --git a/generated/do_editor_ui_for_container_v3_cursor.h b/generated/do_editor_ui_for_container_v3_cursor.h index 17a3b0a23..f5b698339 100644 --- a/generated/do_editor_ui_for_container_v3_cursor.h +++ b/generated/do_editor_ui_for_container_v3_cursor.h @@ -1,16 +1,17 @@ -// src/engine/editor.cpp:112:0 - +// src/engine/editor.h:545:0 link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, v3_cursor *Container, cs Name, EDITOR_UI_FUNCTION_PROTO_DEFAULTS) +DoEditorUi(renderer_2d *Ui, window_layout *Window, v3_cursor *Container, cs Name, u32 ParentHash, EDITOR_UI_FUNCTION_PROTO_DEFAULTS) { + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x24260F23); + if (Container) { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, Name.Start, Container), EDITOR_UI_FUNCTION_INSTANCE_NAMES)) + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, Name.Start, Container, ThisHash), EDITOR_UI_FUNCTION_INSTANCE_NAMES)) { PushNewRow(Ui); IterateOver(Container, Element, ElementIndex) { - DoEditorUi(Ui, Window, Element, CS(ElementIndex), EDITOR_UI_FUNCTION_INSTANCE_NAMES); + DoEditorUi(Ui, Window, Element, CS(ElementIndex), ThisHash, EDITOR_UI_FUNCTION_INSTANCE_NAMES); PushNewRow(Ui); } } diff --git a/generated/do_editor_ui_for_container_world_edit_block_array_index_block_array.h b/generated/do_editor_ui_for_container_world_edit_block_array_index_block_array.h new file mode 100644 index 000000000..fa9f5809b --- /dev/null +++ b/generated/do_editor_ui_for_container_world_edit_block_array_index_block_array.h @@ -0,0 +1,27 @@ +// src/engine/editor.h:545:0 +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, world_edit_block_array_index_block_array *Container, cs Name, u32 ParentHash, EDITOR_UI_FUNCTION_PROTO_DEFAULTS) +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x1E05D30D); + + if (Container) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, Name.Start, Container, ThisHash), EDITOR_UI_FUNCTION_INSTANCE_NAMES)) + { + PushNewRow(Ui); + IterateOver(Container, Element, ElementIndex) + { + DoEditorUi(Ui, Window, Element, CS(ElementIndex), ThisHash, EDITOR_UI_FUNCTION_INSTANCE_NAMES); + PushNewRow(Ui); + } + } + PushNewRow(Ui); + } + else + { + PushColumn(Ui, FSz("%S", Name), EDITOR_UI_FUNCTION_INSTANCE_NAMES); + PushColumn(Ui, CSz("(null)"), EDITOR_UI_FUNCTION_INSTANCE_NAMES); + PushNewRow(Ui); + } +} + diff --git a/generated/do_editor_ui_for_enum_QKyV0TwP.h b/generated/do_editor_ui_for_enum_QKyV0TwP.h new file mode 100644 index 000000000..4820a93b7 --- /dev/null +++ b/generated/do_editor_ui_for_enum_QKyV0TwP.h @@ -0,0 +1,67 @@ +// src/engine/editor.h:484:0 +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, world_edit_blend_mode *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Generic) +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x1991C8B1); + + if (Name.Count) { PushColumn(Ui, CS(Name), &DefaultUiRenderParams_Column); } + + cs ElementName = ToStringPrefixless(*Element); + ui_id ToggleButtonId = UiId(Window, "toggle world_edit_blend_mode", Element, ThisHash); + if (ToggleButton(Ui, ElementName, ElementName, ToggleButtonId, Params)) + { + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("Additive"), UiId(Window, "enum WorldEdit_Mode_Additive", Element, ThisHash), Params)) + { + *Element = WorldEdit_Mode_Additive; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("Subtractive"), UiId(Window, "enum WorldEdit_Mode_Subtractive", Element, ThisHash), Params)) + { + *Element = WorldEdit_Mode_Subtractive; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("Multiply"), UiId(Window, "enum WorldEdit_Mode_Multiply", Element, ThisHash), Params)) + { + *Element = WorldEdit_Mode_Multiply; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("Threshold"), UiId(Window, "enum WorldEdit_Mode_Threshold", Element, ThisHash), Params)) + { + *Element = WorldEdit_Mode_Threshold; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("Disabled"), UiId(Window, "enum WorldEdit_Mode_Disabled", Element, ThisHash), Params)) + { + *Element = WorldEdit_Mode_Disabled; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + + } + else + { + PushNewRow(Ui); + } +} + + diff --git a/generated/do_editor_ui_for_enum_asset_type.h b/generated/do_editor_ui_for_enum_asset_type.h index 73eb0a4dc..9478c7608 100644 --- a/generated/do_editor_ui_for_enum_asset_type.h +++ b/generated/do_editor_ui_for_enum_asset_type.h @@ -1,42 +1,44 @@ -// src/engine/editor.cpp:310:0 - +// src/engine/editor.h:484:0 link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, asset_type *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic) +DoEditorUi(renderer_2d *Ui, window_layout *Window, asset_type *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Generic) { + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x37186BAC); + if (Name.Count) { PushColumn(Ui, CS(Name), &DefaultUiRenderParams_Column); } cs ElementName = ToStringPrefixless(*Element); - ui_id ToggleButtonId = UiId(Window, "enum value.type value.name", Element); + ui_id ToggleButtonId = UiId(Window, "toggle asset_type", Element, ThisHash); 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)) + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("Undefined"), UiId(Window, "enum AssetType_Undefined", Element, ThisHash), Params)) { - *Element = AssetType_Undefined; + *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)) + if (Button(Ui, CSz("Models"), UiId(Window, "enum AssetType_Models", Element, ThisHash), Params)) { - *Element = AssetType_Models; + *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)) + if (Button(Ui, CSz("WorldChunk"), UiId(Window, "enum AssetType_WorldChunk", Element, ThisHash), Params)) { - *Element = AssetType_WorldChunk; + *Element = AssetType_WorldChunk; SetToggleButton(Ui, ToggleButtonId, False); } PushNewRow(Ui); + } else { @@ -44,3 +46,4 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, asset_type *Element, cs Name, } } + diff --git a/generated/do_editor_ui_for_enum_bitfield_enum.h b/generated/do_editor_ui_for_enum_bitfield_enum.h new file mode 100644 index 000000000..92adb1eb3 --- /dev/null +++ b/generated/do_editor_ui_for_enum_bitfield_enum.h @@ -0,0 +1,91 @@ +// src/engine/editor.h:484:0 +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, bitfield_enum *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Generic) +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x23F6F95E); + + if (Name.Count) { PushColumn(Ui, CS(Name), &DefaultUiRenderParams_Column); } + + cs ElementName = ToStringPrefixless(*Element); + ui_id ToggleButtonId = UiId(Window, "toggle bitfield_enum", Element, ThisHash); + if (ToggleButton(Ui, ElementName, ElementName, ToggleButtonId, Params)) + { + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("Foo"), UiId(Window, "enum BitfieldEnum_Foo", Element, ThisHash), Params)) + { + if (BitfieldEnum_Foo == bitfield_enum(0)) + { + *Element = bitfield_enum(0); + } + else + { + if ((*Element & BitfieldEnum_Foo) == BitfieldEnum_Foo) + { + *Element = bitfield_enum(*Element&~BitfieldEnum_Foo); + } + else + { + *Element = bitfield_enum(*Element|BitfieldEnum_Foo); + } + } + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("Bar"), UiId(Window, "enum BitfieldEnum_Bar", Element, ThisHash), Params)) + { + if (BitfieldEnum_Bar == bitfield_enum(0)) + { + *Element = bitfield_enum(0); + } + else + { + if ((*Element & BitfieldEnum_Bar) == BitfieldEnum_Bar) + { + *Element = bitfield_enum(*Element&~BitfieldEnum_Bar); + } + else + { + *Element = bitfield_enum(*Element|BitfieldEnum_Bar); + } + } + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("Baz"), UiId(Window, "enum BitfieldEnum_Baz", Element, ThisHash), Params)) + { + if (BitfieldEnum_Baz == bitfield_enum(0)) + { + *Element = bitfield_enum(0); + } + else + { + if ((*Element & BitfieldEnum_Baz) == BitfieldEnum_Baz) + { + *Element = bitfield_enum(*Element&~BitfieldEnum_Baz); + } + else + { + *Element = bitfield_enum(*Element|BitfieldEnum_Baz); + } + } + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + + } + else + { + PushNewRow(Ui); + } +} + + diff --git a/generated/do_editor_ui_for_enum_brush_layer_type.h b/generated/do_editor_ui_for_enum_brush_layer_type.h new file mode 100644 index 000000000..6953ce261 --- /dev/null +++ b/generated/do_editor_ui_for_enum_brush_layer_type.h @@ -0,0 +1,40 @@ +// src/engine/editor.h:484:0 +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, brush_layer_type *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Generic) +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x136838E8); + + if (Name.Count) { PushColumn(Ui, CS(Name), &DefaultUiRenderParams_Column); } + + cs ElementName = ToStringPrefixless(*Element); + ui_id ToggleButtonId = UiId(Window, "toggle brush_layer_type", Element, ThisHash); + if (ToggleButton(Ui, ElementName, ElementName, ToggleButtonId, Params)) + { + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("Noise"), UiId(Window, "enum BrushLayerType_Noise", Element, ThisHash), Params)) + { + *Element = BrushLayerType_Noise; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("Shape"), UiId(Window, "enum BrushLayerType_Shape", Element, ThisHash), Params)) + { + *Element = BrushLayerType_Shape; + + + 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 3b202e76b..817b2ef59 100644 --- a/generated/do_editor_ui_for_enum_chunk_flag.h +++ b/generated/do_editor_ui_for_enum_chunk_flag.h @@ -1,19 +1,20 @@ -// src/engine/editor.cpp:243:0 - +// src/engine/editor.h:484:0 link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, chunk_flag *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic) +DoEditorUi(renderer_2d *Ui, window_layout *Window, chunk_flag *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Generic) { + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x516E95E); + if (Name.Count) { PushColumn(Ui, CS(Name), &DefaultUiRenderParams_Column); } cs ElementName = ToStringPrefixless(*Element); - ui_id ToggleButtonId = UiId(Window, "enum value.type value.name", Element); + ui_id ToggleButtonId = UiId(Window, "toggle chunk_flag", Element, ThisHash); if (ToggleButton(Ui, ElementName, ElementName, ToggleButtonId, Params)) { PushNewRow(Ui); - if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column - if (Button(Ui, CSz("Uninitialized"), UiId(Window, "enum Chunk_Uninitialized", Element), Params)) + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("Uninitialized"), UiId(Window, "enum Chunk_Uninitialized", Element, ThisHash), Params)) { - if (Chunk_Uninitialized == chunk_flag(0)) + if (Chunk_Uninitialized == chunk_flag(0)) { *Element = chunk_flag(0); } @@ -34,9 +35,9 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, chunk_flag *Element, cs Name, } PushNewRow(Ui); if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column - if (Button(Ui, CSz("Queued"), UiId(Window, "enum Chunk_Queued", Element), Params)) + if (Button(Ui, CSz("Queued"), UiId(Window, "enum Chunk_Queued", Element, ThisHash), Params)) { - if (Chunk_Queued == chunk_flag(0)) + if (Chunk_Queued == chunk_flag(0)) { *Element = chunk_flag(0); } @@ -57,9 +58,9 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, chunk_flag *Element, cs Name, } PushNewRow(Ui); if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column - if (Button(Ui, CSz("VoxelsInitialized"), UiId(Window, "enum Chunk_VoxelsInitialized", Element), Params)) + if (Button(Ui, CSz("VoxelsInitialized"), UiId(Window, "enum Chunk_VoxelsInitialized", Element, ThisHash), Params)) { - if (Chunk_VoxelsInitialized == chunk_flag(0)) + if (Chunk_VoxelsInitialized == chunk_flag(0)) { *Element = chunk_flag(0); } @@ -80,9 +81,9 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, chunk_flag *Element, cs Name, } PushNewRow(Ui); if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column - if (Button(Ui, CSz("Garbage"), UiId(Window, "enum Chunk_Garbage", Element), Params)) + if (Button(Ui, CSz("Garbage"), UiId(Window, "enum Chunk_Garbage", Element, ThisHash), Params)) { - if (Chunk_Garbage == chunk_flag(0)) + if (Chunk_Garbage == chunk_flag(0)) { *Element = chunk_flag(0); } @@ -103,9 +104,9 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, chunk_flag *Element, cs Name, } PushNewRow(Ui); if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column - if (Button(Ui, CSz("Deallocate"), UiId(Window, "enum Chunk_Deallocate", Element), Params)) + if (Button(Ui, CSz("Deallocate"), UiId(Window, "enum Chunk_Deallocate", Element, ThisHash), Params)) { - if (Chunk_Deallocate == chunk_flag(0)) + if (Chunk_Deallocate == chunk_flag(0)) { *Element = chunk_flag(0); } @@ -126,9 +127,9 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, chunk_flag *Element, cs Name, } PushNewRow(Ui); if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column - if (Button(Ui, CSz("Freelist"), UiId(Window, "enum Chunk_Freelist", Element), Params)) + if (Button(Ui, CSz("Freelist"), UiId(Window, "enum Chunk_Freelist", Element, ThisHash), Params)) { - if (Chunk_Freelist == chunk_flag(0)) + if (Chunk_Freelist == chunk_flag(0)) { *Element = chunk_flag(0); } @@ -148,6 +149,7 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, chunk_flag *Element, cs Name, SetToggleButton(Ui, ToggleButtonId, False); } PushNewRow(Ui); + } else { @@ -155,3 +157,4 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, chunk_flag *Element, cs Name, } } + diff --git a/generated/do_editor_ui_for_enum_data_type.h b/generated/do_editor_ui_for_enum_data_type.h index cf312dfa7..a08f112e6 100644 --- a/generated/do_editor_ui_for_enum_data_type.h +++ b/generated/do_editor_ui_for_enum_data_type.h @@ -1,42 +1,44 @@ -// src/engine/editor.h:506:0 - +// src/engine/editor.h:484:0 link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, data_type *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic) +DoEditorUi(renderer_2d *Ui, window_layout *Window, data_type *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Generic) { + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x3B8062A8); + if (Name.Count) { PushColumn(Ui, CS(Name), &DefaultUiRenderParams_Column); } cs ElementName = ToStringPrefixless(*Element); - ui_id ToggleButtonId = UiId(Window, "enum value.type value.name", Element); + ui_id ToggleButtonId = UiId(Window, "toggle data_type", Element, ThisHash); 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)) + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("Undefinded"), UiId(Window, "enum DataType_Undefinded", Element, ThisHash), Params)) { - *Element = DataType_Undefinded; + *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)) + if (Button(Ui, CSz("v3"), UiId(Window, "enum DataType_v3", Element, ThisHash), Params)) { - *Element = DataType_v3; + *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)) + if (Button(Ui, CSz("u8"), UiId(Window, "enum DataType_v3_u8", Element, ThisHash), Params)) { - *Element = DataType_v3_u8; + *Element = DataType_v3_u8; SetToggleButton(Ui, ToggleButtonId, False); } PushNewRow(Ui); + } else { @@ -44,3 +46,4 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, data_type *Element, cs Name, } } + 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 1a372facc..4e63f783a 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,19 +1,20 @@ -// src/engine/editor.cpp:422:0 - +// src/engine/editor.h:484:0 link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, engine_debug_view_mode *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic) +DoEditorUi(renderer_2d *Ui, window_layout *Window, engine_debug_view_mode *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Generic) { + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x2D5EDA); + if (Name.Count) { PushColumn(Ui, CS(Name), &DefaultUiRenderParams_Column); } cs ElementName = ToStringPrefixless(*Element); - ui_id ToggleButtonId = UiId(Window, "enum value.type value.name", Element); + ui_id ToggleButtonId = UiId(Window, "toggle engine_debug_view_mode", Element, ThisHash); if (ToggleButton(Ui, ElementName, ElementName, ToggleButtonId, Params)) { PushNewRow(Ui); - if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column - if (Button(Ui, CSz("Level"), UiId(Window, "enum EngineDebugViewMode_Level", Element), Params)) + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("Level"), UiId(Window, "enum EngineDebugViewMode_Level", Element, ThisHash), Params)) { - if (EngineDebugViewMode_Level == engine_debug_view_mode(0)) + if (EngineDebugViewMode_Level == engine_debug_view_mode(0)) { *Element = engine_debug_view_mode(0); } @@ -34,9 +35,9 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, engine_debug_view_mode *Eleme } PushNewRow(Ui); if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column - if (Button(Ui, CSz("WorldEdit"), UiId(Window, "enum EngineDebugViewMode_WorldEdit", Element), Params)) + if (Button(Ui, CSz("WorldEdit"), UiId(Window, "enum EngineDebugViewMode_WorldEdit", Element, ThisHash), Params)) { - if (EngineDebugViewMode_WorldEdit == engine_debug_view_mode(0)) + if (EngineDebugViewMode_WorldEdit == engine_debug_view_mode(0)) { *Element = engine_debug_view_mode(0); } @@ -57,9 +58,9 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, engine_debug_view_mode *Eleme } PushNewRow(Ui); if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column - if (Button(Ui, CSz("Entities"), UiId(Window, "enum EngineDebugViewMode_Entities", Element), Params)) + if (Button(Ui, CSz("Entities"), UiId(Window, "enum EngineDebugViewMode_Entities", Element, ThisHash), Params)) { - if (EngineDebugViewMode_Entities == engine_debug_view_mode(0)) + if (EngineDebugViewMode_Entities == engine_debug_view_mode(0)) { *Element = engine_debug_view_mode(0); } @@ -80,9 +81,9 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, engine_debug_view_mode *Eleme } PushNewRow(Ui); if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column - if (Button(Ui, CSz("Assets"), UiId(Window, "enum EngineDebugViewMode_Assets", Element), Params)) + if (Button(Ui, CSz("Assets"), UiId(Window, "enum EngineDebugViewMode_Assets", Element, ThisHash), Params)) { - if (EngineDebugViewMode_Assets == engine_debug_view_mode(0)) + if (EngineDebugViewMode_Assets == engine_debug_view_mode(0)) { *Element = engine_debug_view_mode(0); } @@ -103,9 +104,9 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, engine_debug_view_mode *Eleme } PushNewRow(Ui); if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column - if (Button(Ui, CSz("WorldChunks"), UiId(Window, "enum EngineDebugViewMode_WorldChunks", Element), Params)) + if (Button(Ui, CSz("WorldChunks"), UiId(Window, "enum EngineDebugViewMode_WorldChunks", Element, ThisHash), Params)) { - if (EngineDebugViewMode_WorldChunks == engine_debug_view_mode(0)) + if (EngineDebugViewMode_WorldChunks == engine_debug_view_mode(0)) { *Element = engine_debug_view_mode(0); } @@ -126,9 +127,9 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, engine_debug_view_mode *Eleme } PushNewRow(Ui); if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column - if (Button(Ui, CSz("Textures"), UiId(Window, "enum EngineDebugViewMode_Textures", Element), Params)) + if (Button(Ui, CSz("Textures"), UiId(Window, "enum EngineDebugViewMode_Textures", Element, ThisHash), Params)) { - if (EngineDebugViewMode_Textures == engine_debug_view_mode(0)) + if (EngineDebugViewMode_Textures == engine_debug_view_mode(0)) { *Element = engine_debug_view_mode(0); } @@ -149,9 +150,9 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, engine_debug_view_mode *Eleme } PushNewRow(Ui); if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column - if (Button(Ui, CSz("RenderSettings"), UiId(Window, "enum EngineDebugViewMode_RenderSettings", Element), Params)) + if (Button(Ui, CSz("RenderSettings"), UiId(Window, "enum EngineDebugViewMode_RenderSettings", Element, ThisHash), Params)) { - if (EngineDebugViewMode_RenderSettings == engine_debug_view_mode(0)) + if (EngineDebugViewMode_RenderSettings == engine_debug_view_mode(0)) { *Element = engine_debug_view_mode(0); } @@ -172,9 +173,9 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, engine_debug_view_mode *Eleme } PushNewRow(Ui); if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column - if (Button(Ui, CSz("EngineDebug"), UiId(Window, "enum EngineDebugViewMode_EngineDebug", Element), Params)) + if (Button(Ui, CSz("EngineDebug"), UiId(Window, "enum EngineDebugViewMode_EngineDebug", Element, ThisHash), Params)) { - if (EngineDebugViewMode_EngineDebug == engine_debug_view_mode(0)) + if (EngineDebugViewMode_EngineDebug == engine_debug_view_mode(0)) { *Element = engine_debug_view_mode(0); } @@ -194,6 +195,7 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, engine_debug_view_mode *Eleme SetToggleButton(Ui, ToggleButtonId, False); } PushNewRow(Ui); + } else { @@ -201,3 +203,4 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, engine_debug_view_mode *Eleme } } + 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 05094c13b..26c3edc2b 100644 --- a/generated/do_editor_ui_for_enum_entity_behavior_flags.h +++ b/generated/do_editor_ui_for_enum_entity_behavior_flags.h @@ -1,19 +1,20 @@ -// src/engine/editor.cpp:181:0 - +// src/engine/editor.h:484:0 link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, entity_behavior_flags *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic) +DoEditorUi(renderer_2d *Ui, window_layout *Window, entity_behavior_flags *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Generic) { + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x1CF5460C); + if (Name.Count) { PushColumn(Ui, CS(Name), &DefaultUiRenderParams_Column); } cs ElementName = ToStringPrefixless(*Element); - ui_id ToggleButtonId = UiId(Window, "enum value.type value.name", Element); + ui_id ToggleButtonId = UiId(Window, "toggle entity_behavior_flags", Element, ThisHash); if (ToggleButton(Ui, ElementName, ElementName, ToggleButtonId, Params)) { PushNewRow(Ui); - if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column - if (Button(Ui, CSz("None"), UiId(Window, "enum EntityBehaviorFlags_None", Element), Params)) + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("None"), UiId(Window, "enum EntityBehaviorFlags_None", Element, ThisHash), Params)) { - if (EntityBehaviorFlags_None == entity_behavior_flags(0)) + if (EntityBehaviorFlags_None == entity_behavior_flags(0)) { *Element = entity_behavior_flags(0); } @@ -34,9 +35,9 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, entity_behavior_flags *Elemen } PushNewRow(Ui); if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column - if (Button(Ui, CSz("Gravity"), UiId(Window, "enum EntityBehaviorFlags_Gravity", Element), Params)) + if (Button(Ui, CSz("Gravity"), UiId(Window, "enum EntityBehaviorFlags_Gravity", Element, ThisHash), Params)) { - if (EntityBehaviorFlags_Gravity == entity_behavior_flags(0)) + if (EntityBehaviorFlags_Gravity == entity_behavior_flags(0)) { *Element = entity_behavior_flags(0); } @@ -57,9 +58,9 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, entity_behavior_flags *Elemen } PushNewRow(Ui); if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column - if (Button(Ui, CSz("WorldCollision"), UiId(Window, "enum EntityBehaviorFlags_WorldCollision", Element), Params)) + if (Button(Ui, CSz("WorldCollision"), UiId(Window, "enum EntityBehaviorFlags_WorldCollision", Element, ThisHash), Params)) { - if (EntityBehaviorFlags_WorldCollision == entity_behavior_flags(0)) + if (EntityBehaviorFlags_WorldCollision == entity_behavior_flags(0)) { *Element = entity_behavior_flags(0); } @@ -80,9 +81,9 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, entity_behavior_flags *Elemen } PushNewRow(Ui); if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column - if (Button(Ui, CSz("EntityCollision"), UiId(Window, "enum EntityBehaviorFlags_EntityCollision", Element), Params)) + if (Button(Ui, CSz("EntityCollision"), UiId(Window, "enum EntityBehaviorFlags_EntityCollision", Element, ThisHash), Params)) { - if (EntityBehaviorFlags_EntityCollision == entity_behavior_flags(0)) + if (EntityBehaviorFlags_EntityCollision == entity_behavior_flags(0)) { *Element = entity_behavior_flags(0); } @@ -103,9 +104,9 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, entity_behavior_flags *Elemen } PushNewRow(Ui); if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column - if (Button(Ui, CSz("UnspawnOnParticleSystemTerminate"), UiId(Window, "enum EntityBehaviorFlags_UnspawnOnParticleSystemTerminate", Element), Params)) + if (Button(Ui, CSz("UnspawnOnParticleSystemTerminate"), UiId(Window, "enum EntityBehaviorFlags_UnspawnOnParticleSystemTerminate", Element, ThisHash), Params)) { - if (EntityBehaviorFlags_UnspawnOnParticleSystemTerminate == entity_behavior_flags(0)) + if (EntityBehaviorFlags_UnspawnOnParticleSystemTerminate == entity_behavior_flags(0)) { *Element = entity_behavior_flags(0); } @@ -126,9 +127,9 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, entity_behavior_flags *Elemen } PushNewRow(Ui); if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column - if (Button(Ui, CSz("FitCollisionVolumeToModel"), UiId(Window, "enum EntityBehaviorFlags_FitCollisionVolumeToModel", Element), Params)) + if (Button(Ui, CSz("FitCollisionVolumeToModel"), UiId(Window, "enum EntityBehaviorFlags_FitCollisionVolumeToModel", Element, ThisHash), Params)) { - if (EntityBehaviorFlags_FitCollisionVolumeToModel == entity_behavior_flags(0)) + if (EntityBehaviorFlags_FitCollisionVolumeToModel == entity_behavior_flags(0)) { *Element = entity_behavior_flags(0); } @@ -149,9 +150,9 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, entity_behavior_flags *Elemen } PushNewRow(Ui); if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column - if (Button(Ui, CSz("DefatulCameraGhostBehavior"), UiId(Window, "enum EntityBehaviorFlags_DefatulCameraGhostBehavior", Element), Params)) + if (Button(Ui, CSz("DefatulCameraGhostBehavior"), UiId(Window, "enum EntityBehaviorFlags_DefatulCameraGhostBehavior", Element, ThisHash), Params)) { - if (EntityBehaviorFlags_DefatulCameraGhostBehavior == entity_behavior_flags(0)) + if (EntityBehaviorFlags_DefatulCameraGhostBehavior == entity_behavior_flags(0)) { *Element = entity_behavior_flags(0); } @@ -172,9 +173,9 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, entity_behavior_flags *Elemen } PushNewRow(Ui); if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column - if (Button(Ui, CSz("WorldCenter"), UiId(Window, "enum EntityBehaviorFlags_WorldCenter", Element), Params)) + if (Button(Ui, CSz("WorldCenter"), UiId(Window, "enum EntityBehaviorFlags_WorldCenter", Element, ThisHash), Params)) { - if (EntityBehaviorFlags_WorldCenter == entity_behavior_flags(0)) + if (EntityBehaviorFlags_WorldCenter == entity_behavior_flags(0)) { *Element = entity_behavior_flags(0); } @@ -195,9 +196,9 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, entity_behavior_flags *Elemen } PushNewRow(Ui); if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column - if (Button(Ui, CSz("Default"), UiId(Window, "enum EntityBehaviorFlags_Default", Element), Params)) + if (Button(Ui, CSz("Default"), UiId(Window, "enum EntityBehaviorFlags_Default", Element, ThisHash), Params)) { - if (EntityBehaviorFlags_Default == entity_behavior_flags(0)) + if (EntityBehaviorFlags_Default == entity_behavior_flags(0)) { *Element = entity_behavior_flags(0); } @@ -217,6 +218,7 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, entity_behavior_flags *Elemen SetToggleButton(Ui, ToggleButtonId, False); } PushNewRow(Ui); + } else { @@ -224,3 +226,4 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, entity_behavior_flags *Elemen } } + diff --git a/generated/do_editor_ui_for_enum_entity_state.h b/generated/do_editor_ui_for_enum_entity_state.h index 7338e9643..3371143a8 100644 --- a/generated/do_editor_ui_for_enum_entity_state.h +++ b/generated/do_editor_ui_for_enum_entity_state.h @@ -1,51 +1,53 @@ -// src/engine/editor.cpp:178:0 - +// src/engine/editor.h:484:0 link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, entity_state *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic) +DoEditorUi(renderer_2d *Ui, window_layout *Window, entity_state *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Generic) { + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x12A84A89); + if (Name.Count) { PushColumn(Ui, CS(Name), &DefaultUiRenderParams_Column); } cs ElementName = ToStringPrefixless(*Element); - ui_id ToggleButtonId = UiId(Window, "enum value.type value.name", Element); + ui_id ToggleButtonId = UiId(Window, "toggle entity_state", Element, ThisHash); if (ToggleButton(Ui, ElementName, ElementName, ToggleButtonId, Params)) { PushNewRow(Ui); - if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column - if (Button(Ui, CSz("Free"), UiId(Window, "enum EntityState_Free", Element), Params)) + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("Free"), UiId(Window, "enum EntityState_Free", Element, ThisHash), Params)) { - *Element = EntityState_Free; + *Element = EntityState_Free; SetToggleButton(Ui, ToggleButtonId, False); } PushNewRow(Ui); if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column - if (Button(Ui, CSz("Spawned"), UiId(Window, "enum EntityState_Spawned", Element), Params)) + if (Button(Ui, CSz("Spawned"), UiId(Window, "enum EntityState_Spawned", Element, ThisHash), Params)) { - *Element = EntityState_Spawned; + *Element = EntityState_Spawned; SetToggleButton(Ui, ToggleButtonId, False); } PushNewRow(Ui); if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column - if (Button(Ui, CSz("Destroyed"), UiId(Window, "enum EntityState_Destroyed", Element), Params)) + if (Button(Ui, CSz("Destroyed"), UiId(Window, "enum EntityState_Destroyed", Element, ThisHash), Params)) { - *Element = EntityState_Destroyed; + *Element = EntityState_Destroyed; SetToggleButton(Ui, ToggleButtonId, False); } PushNewRow(Ui); if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column - if (Button(Ui, CSz("Reserved"), UiId(Window, "enum EntityState_Reserved", Element), Params)) + if (Button(Ui, CSz("Reserved"), UiId(Window, "enum EntityState_Reserved", Element, ThisHash), Params)) { - *Element = EntityState_Reserved; + *Element = EntityState_Reserved; SetToggleButton(Ui, ToggleButtonId, False); } PushNewRow(Ui); + } else { @@ -53,3 +55,4 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, entity_state *Element, cs Nam } } + diff --git a/generated/do_editor_ui_for_enum_entity_status.h b/generated/do_editor_ui_for_enum_entity_status.h index 34fb31080..e6a4d885f 100644 --- a/generated/do_editor_ui_for_enum_entity_status.h +++ b/generated/do_editor_ui_for_enum_entity_status.h @@ -1,42 +1,44 @@ -// examples/turn_based/game_types.h:81:0 - +// src/engine/editor.h:482:0 link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, entity_status *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic) +DoEditorUi(renderer_2d *Ui, window_layout *Window, entity_status *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Generic) { + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0xF7D67E1); + if (Name.Count) { PushColumn(Ui, CS(Name), &DefaultUiRenderParams_Column); } cs ElementName = ToStringPrefixless(*Element); - ui_id ToggleButtonId = UiId(Window, "enum value.type value.name", Element); + ui_id ToggleButtonId = UiId(Window, "toggle entity_status", Element, ThisHash); if (ToggleButton(Ui, ElementName, ElementName, ToggleButtonId, Params)) { PushNewRow(Ui); - if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column - if (Button(Ui, CSz("None"), UiId(Window, "enum EntityStatus_None", Element), Params)) + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("None"), UiId(Window, "enum EntityStatus_None", Element, ThisHash), Params)) { - *Element = EntityStatus_None; + *Element = EntityStatus_None; SetToggleButton(Ui, ToggleButtonId, False); } PushNewRow(Ui); if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column - if (Button(Ui, CSz("Carried"), UiId(Window, "enum EntityStatus_Carried", Element), Params)) + if (Button(Ui, CSz("Carried"), UiId(Window, "enum EntityStatus_Carried", Element, ThisHash), Params)) { - *Element = EntityStatus_Carried; + *Element = EntityStatus_Carried; SetToggleButton(Ui, ToggleButtonId, False); } PushNewRow(Ui); if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column - if (Button(Ui, CSz("Thrown"), UiId(Window, "enum EntityStatus_Thrown", Element), Params)) + if (Button(Ui, CSz("Thrown"), UiId(Window, "enum EntityStatus_Thrown", Element, ThisHash), Params)) { - *Element = EntityStatus_Thrown; + *Element = EntityStatus_Thrown; SetToggleButton(Ui, ToggleButtonId, False); } PushNewRow(Ui); + } else { @@ -44,3 +46,4 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, entity_status *Element, cs Na } } + diff --git a/generated/do_editor_ui_for_enum_entity_type.h b/generated/do_editor_ui_for_enum_entity_type.h index 5c2595dfe..959aa4e74 100644 --- a/generated/do_editor_ui_for_enum_entity_type.h +++ b/generated/do_editor_ui_for_enum_entity_type.h @@ -1,69 +1,71 @@ -// examples/turn_based/game_types.h:78:0 - +// src/engine/editor.h:482:0 link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, entity_type *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic) +DoEditorUi(renderer_2d *Ui, window_layout *Window, entity_type *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Generic) { + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0xAB28A13); + if (Name.Count) { PushColumn(Ui, CS(Name), &DefaultUiRenderParams_Column); } cs ElementName = ToStringPrefixless(*Element); - ui_id ToggleButtonId = UiId(Window, "enum value.type value.name", Element); + ui_id ToggleButtonId = UiId(Window, "toggle entity_type", Element, ThisHash); if (ToggleButton(Ui, ElementName, ElementName, ToggleButtonId, Params)) { PushNewRow(Ui); - if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column - if (Button(Ui, CSz("Default"), UiId(Window, "enum EntityType_Default", Element), Params)) + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("Default"), UiId(Window, "enum EntityType_Default", Element, ThisHash), Params)) { - *Element = EntityType_Default; + *Element = EntityType_Default; SetToggleButton(Ui, ToggleButtonId, False); } PushNewRow(Ui); if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column - if (Button(Ui, CSz("Enemy"), UiId(Window, "enum EntityType_Enemy", Element), Params)) + if (Button(Ui, CSz("Enemy"), UiId(Window, "enum EntityType_Enemy", Element, ThisHash), Params)) { - *Element = EntityType_Enemy; + *Element = EntityType_Enemy; SetToggleButton(Ui, ToggleButtonId, False); } PushNewRow(Ui); if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column - if (Button(Ui, CSz("Player"), UiId(Window, "enum EntityType_Player", Element), Params)) + if (Button(Ui, CSz("Player"), UiId(Window, "enum EntityType_Player", Element, ThisHash), Params)) { - *Element = EntityType_Player; + *Element = EntityType_Player; SetToggleButton(Ui, ToggleButtonId, False); } PushNewRow(Ui); if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column - if (Button(Ui, CSz("Fireball"), UiId(Window, "enum EntityType_Fireball", Element), Params)) + if (Button(Ui, CSz("Fireball"), UiId(Window, "enum EntityType_Fireball", Element, ThisHash), Params)) { - *Element = EntityType_Fireball; + *Element = EntityType_Fireball; SetToggleButton(Ui, ToggleButtonId, False); } PushNewRow(Ui); if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column - if (Button(Ui, CSz("Loot"), UiId(Window, "enum EntityType_Loot", Element), Params)) + if (Button(Ui, CSz("Loot"), UiId(Window, "enum EntityType_Loot", Element, ThisHash), Params)) { - *Element = EntityType_Loot; + *Element = EntityType_Loot; SetToggleButton(Ui, ToggleButtonId, False); } PushNewRow(Ui); if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column - if (Button(Ui, CSz("ItemSpawn"), UiId(Window, "enum EntityType_ItemSpawn", Element), Params)) + if (Button(Ui, CSz("ItemSpawn"), UiId(Window, "enum EntityType_ItemSpawn", Element, ThisHash), Params)) { - *Element = EntityType_ItemSpawn; + *Element = EntityType_ItemSpawn; SetToggleButton(Ui, ToggleButtonId, False); } PushNewRow(Ui); + } else { @@ -71,3 +73,4 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, entity_type *Element, cs Name } } + 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 730068ed6..b208ea148 100644 --- a/generated/do_editor_ui_for_enum_file_traversal_type.h +++ b/generated/do_editor_ui_for_enum_file_traversal_type.h @@ -1,42 +1,44 @@ -// src/engine/editor.cpp:273:0 - +// src/engine/editor.h:484:0 link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, file_traversal_type *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic) +DoEditorUi(renderer_2d *Ui, window_layout *Window, file_traversal_type *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Generic) { + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x8811EEF); + if (Name.Count) { PushColumn(Ui, CS(Name), &DefaultUiRenderParams_Column); } cs ElementName = ToStringPrefixless(*Element); - ui_id ToggleButtonId = UiId(Window, "enum value.type value.name", Element); + ui_id ToggleButtonId = UiId(Window, "toggle file_traversal_type", Element, ThisHash); if (ToggleButton(Ui, ElementName, ElementName, ToggleButtonId, Params)) { PushNewRow(Ui); - if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column - if (Button(Ui, CSz("None"), UiId(Window, "enum FileTraversalType_None", Element), Params)) + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("None"), UiId(Window, "enum FileTraversalType_None", Element, ThisHash), Params)) { - *Element = FileTraversalType_None; + *Element = FileTraversalType_None; SetToggleButton(Ui, ToggleButtonId, False); } PushNewRow(Ui); if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column - if (Button(Ui, CSz("Dir"), UiId(Window, "enum FileTraversalType_Dir", Element), Params)) + if (Button(Ui, CSz("Dir"), UiId(Window, "enum FileTraversalType_Dir", Element, ThisHash), Params)) { - *Element = FileTraversalType_Dir; + *Element = FileTraversalType_Dir; SetToggleButton(Ui, ToggleButtonId, False); } PushNewRow(Ui); if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column - if (Button(Ui, CSz("File"), UiId(Window, "enum FileTraversalType_File", Element), Params)) + if (Button(Ui, CSz("File"), UiId(Window, "enum FileTraversalType_File", Element, ThisHash), Params)) { - *Element = FileTraversalType_File; + *Element = FileTraversalType_File; SetToggleButton(Ui, ToggleButtonId, False); } PushNewRow(Ui); + } else { @@ -44,3 +46,4 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, file_traversal_type *Element, } } + diff --git a/generated/do_editor_ui_for_enum_maybe_tag.h b/generated/do_editor_ui_for_enum_maybe_tag.h new file mode 100644 index 000000000..4c9d37a27 --- /dev/null +++ b/generated/do_editor_ui_for_enum_maybe_tag.h @@ -0,0 +1,40 @@ +// src/engine/editor.h:484:0 +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, maybe_tag *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Generic) +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x1FBAE2DF); + + if (Name.Count) { PushColumn(Ui, CS(Name), &DefaultUiRenderParams_Column); } + + cs ElementName = ToStringPrefixless(*Element); + ui_id ToggleButtonId = UiId(Window, "toggle maybe_tag", Element, ThisHash); + if (ToggleButton(Ui, ElementName, ElementName, ToggleButtonId, Params)) + { + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("No"), UiId(Window, "enum Maybe_No", Element, ThisHash), Params)) + { + *Element = Maybe_No; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("Yes"), UiId(Window, "enum Maybe_Yes", Element, ThisHash), Params)) + { + *Element = Maybe_Yes; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + + } + else + { + PushNewRow(Ui); + } +} + + 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 18814311f..9ec28ae7d 100644 --- a/generated/do_editor_ui_for_enum_particle_spawn_type.h +++ b/generated/do_editor_ui_for_enum_particle_spawn_type.h @@ -1,51 +1,53 @@ -// src/engine/editor.cpp:204:0 - +// src/engine/editor.h:484:0 link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, particle_spawn_type *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic) +DoEditorUi(renderer_2d *Ui, window_layout *Window, particle_spawn_type *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Generic) { + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x14DBD6B7); + if (Name.Count) { PushColumn(Ui, CS(Name), &DefaultUiRenderParams_Column); } cs ElementName = ToStringPrefixless(*Element); - ui_id ToggleButtonId = UiId(Window, "enum value.type value.name", Element); + ui_id ToggleButtonId = UiId(Window, "toggle particle_spawn_type", Element, ThisHash); if (ToggleButton(Ui, ElementName, ElementName, ToggleButtonId, Params)) { PushNewRow(Ui); - if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column - if (Button(Ui, CSz("None"), UiId(Window, "enum ParticleSpawnType_None", Element), Params)) + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("None"), UiId(Window, "enum ParticleSpawnType_None", Element, ThisHash), Params)) { - *Element = ParticleSpawnType_None; + *Element = ParticleSpawnType_None; SetToggleButton(Ui, ToggleButtonId, False); } PushNewRow(Ui); if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column - if (Button(Ui, CSz("Random"), UiId(Window, "enum ParticleSpawnType_Random", Element), Params)) + if (Button(Ui, CSz("Random"), UiId(Window, "enum ParticleSpawnType_Random", Element, ThisHash), Params)) { - *Element = ParticleSpawnType_Random; + *Element = ParticleSpawnType_Random; SetToggleButton(Ui, ToggleButtonId, False); } PushNewRow(Ui); if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column - if (Button(Ui, CSz("Expanding"), UiId(Window, "enum ParticleSpawnType_Expanding", Element), Params)) + if (Button(Ui, CSz("Expanding"), UiId(Window, "enum ParticleSpawnType_Expanding", Element, ThisHash), Params)) { - *Element = ParticleSpawnType_Expanding; + *Element = ParticleSpawnType_Expanding; SetToggleButton(Ui, ToggleButtonId, False); } PushNewRow(Ui); if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column - if (Button(Ui, CSz("Contracting"), UiId(Window, "enum ParticleSpawnType_Contracting", Element), Params)) + if (Button(Ui, CSz("Contracting"), UiId(Window, "enum ParticleSpawnType_Contracting", Element, ThisHash), Params)) { - *Element = ParticleSpawnType_Contracting; + *Element = ParticleSpawnType_Contracting; SetToggleButton(Ui, ToggleButtonId, False); } PushNewRow(Ui); + } else { @@ -53,3 +55,4 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, particle_spawn_type *Element, } } + diff --git a/generated/do_editor_ui_for_radio_enum_world_edit_mode_modifier.h b/generated/do_editor_ui_for_enum_radio_enum.h similarity index 52% rename from generated/do_editor_ui_for_radio_enum_world_edit_mode_modifier.h rename to generated/do_editor_ui_for_enum_radio_enum.h index 4022f3c97..d7521636c 100644 --- a/generated/do_editor_ui_for_radio_enum_world_edit_mode_modifier.h +++ b/generated/do_editor_ui_for_enum_radio_enum.h @@ -1,7 +1,6 @@ -// src/engine/editor.h:670:0 - +// src/engine/editor.h:484:0 link_internal void -RadioSelect(ui_toggle_button_group *RadioGroup, world_edit_mode_modifier Selection) +RadioSelect(ui_toggle_button_group *RadioGroup, radio_enum Selection) { ui_toggle_button_handle *ToggleHandle = RadioGroup->Buttons.Start + Selection; SetRadioButton(RadioGroup, ToggleHandle, True); @@ -9,18 +8,19 @@ RadioSelect(ui_toggle_button_group *RadioGroup, world_edit_mode_modifier Selecti } link_internal ui_toggle_button_group -RadioButtonGroup_world_edit_mode_modifier( renderer_2d *Ui, +RadioButtonGroup_radio_enum( renderer_2d *Ui, window_layout *Window, cs GroupName, - world_edit_mode_modifier *Element, + radio_enum *Element, ui_render_params *Params = &DefaultUiRenderParams_Generic, ui_toggle_button_group_flags ExtraFlags = ToggleButtonGroupFlags_None) { ui_toggle_button_handle ButtonHandles[] = { - { CSz("Default"), UiId(Window, Cast(void*, Element), Cast(void*, "world_edit_mode_modifier WorldEdit_Modifier_Default")), WorldEdit_Modifier_Default }, - { CSz("Flood"), UiId(Window, Cast(void*, Element), Cast(void*, "world_edit_mode_modifier WorldEdit_Modifier_Flood")), WorldEdit_Modifier_Flood }, - { CSz("Surface"), UiId(Window, Cast(void*, Element), Cast(void*, "world_edit_mode_modifier WorldEdit_Modifier_Surface")), WorldEdit_Modifier_Surface }, + { CSz("Foo"), {}, UiId(Window, Cast(void*, Element), Cast(void*, "radio_enum RadioEnum_Foo")), RadioEnum_Foo }, + { CSz("Bar"), {}, UiId(Window, Cast(void*, Element), Cast(void*, "radio_enum RadioEnum_Bar")), RadioEnum_Bar }, + { CSz("Baz"), {}, UiId(Window, Cast(void*, Element), Cast(void*, "radio_enum RadioEnum_Baz")), RadioEnum_Baz }, + }; ui_toggle_button_handle_buffer ButtonBuffer = { @@ -28,7 +28,7 @@ RadioButtonGroup_world_edit_mode_modifier( renderer_2d *Ui, ButtonHandles }; - ui_toggle_button_group Result = DrawButtonGroupForEnum(Ui, &ButtonBuffer, GroupName, Cast(u32*, Element), Params, ui_toggle_button_group_flags(ExtraFlags|ToggleButtonGroupFlags_RadioButtons)); + ui_toggle_button_group Result = DrawButtonGroupForEnum(Ui, &ButtonBuffer, GroupName, Cast(u32*, Element), Params, ui_toggle_button_group_flags(ExtraFlags|ToggleButtonGroupFlags_TypeRadioButton)); return Result; } @@ -38,12 +38,15 @@ RadioButtonGroup_world_edit_mode_modifier( renderer_2d *Ui, link_internal ui_toggle_button_group DoEditorUi( renderer_2d *Ui, window_layout *Window, - world_edit_mode_modifier *Element, + radio_enum *Element, cs GroupName, + u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Generic, ui_toggle_button_group_flags ExtraFlags = ToggleButtonGroupFlags_None) { - ui_toggle_button_group RadioGroup = RadioButtonGroup_world_edit_mode_modifier(Ui, Window, GroupName, Element, Params, ExtraFlags); + ui_toggle_button_group RadioGroup = RadioButtonGroup_radio_enum(Ui, Window, GroupName, Element, Params, ExtraFlags); return RadioGroup; } + + diff --git a/generated/do_editor_ui_for_enum_resolution_setting.h b/generated/do_editor_ui_for_enum_resolution_setting.h index 0921cc19b..a92bde8a8 100644 --- a/generated/do_editor_ui_for_enum_resolution_setting.h +++ b/generated/do_editor_ui_for_enum_resolution_setting.h @@ -1,42 +1,44 @@ -// src/engine/editor.cpp:428:0 - +// src/engine/editor.h:484:0 link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, resolution_setting *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic) +DoEditorUi(renderer_2d *Ui, window_layout *Window, resolution_setting *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Generic) { + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x299CF761); + if (Name.Count) { PushColumn(Ui, CS(Name), &DefaultUiRenderParams_Column); } cs ElementName = ToStringPrefixless(*Element); - ui_id ToggleButtonId = UiId(Window, "enum value.type value.name", Element); + ui_id ToggleButtonId = UiId(Window, "toggle resolution_setting", Element, ThisHash); if (ToggleButton(Ui, ElementName, ElementName, ToggleButtonId, Params)) { PushNewRow(Ui); - if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column - if (Button(Ui, CSz("4096x2160"), UiId(Window, "enum ResolutionSetting_4096x2160", Element), Params)) + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("4096x2160"), UiId(Window, "enum ResolutionSetting_4096x2160", Element, ThisHash), Params)) { - *Element = ResolutionSetting_4096x2160; + *Element = ResolutionSetting_4096x2160; SetToggleButton(Ui, ToggleButtonId, False); } PushNewRow(Ui); if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column - if (Button(Ui, CSz("1920x1080"), UiId(Window, "enum ResolutionSetting_1920x1080", Element), Params)) + if (Button(Ui, CSz("1920x1080"), UiId(Window, "enum ResolutionSetting_1920x1080", Element, ThisHash), Params)) { - *Element = ResolutionSetting_1920x1080; + *Element = ResolutionSetting_1920x1080; SetToggleButton(Ui, ToggleButtonId, False); } PushNewRow(Ui); if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column - if (Button(Ui, CSz("1280x720"), UiId(Window, "enum ResolutionSetting_1280x720", Element), Params)) + if (Button(Ui, CSz("1280x720"), UiId(Window, "enum ResolutionSetting_1280x720", Element, ThisHash), Params)) { - *Element = ResolutionSetting_1280x720; + *Element = ResolutionSetting_1280x720; SetToggleButton(Ui, ToggleButtonId, False); } PushNewRow(Ui); + } else { @@ -44,3 +46,4 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, resolution_setting *Element, } } + 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 537b26061..89a9fcc0d 100644 --- a/generated/do_editor_ui_for_enum_shader_language_setting.h +++ b/generated/do_editor_ui_for_enum_shader_language_setting.h @@ -1,33 +1,35 @@ -// src/engine/editor.cpp:431:0 - +// src/engine/editor.h:484:0 link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, shader_language_setting *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic) +DoEditorUi(renderer_2d *Ui, window_layout *Window, shader_language_setting *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Generic) { + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x1C155A0B); + if (Name.Count) { PushColumn(Ui, CS(Name), &DefaultUiRenderParams_Column); } cs ElementName = ToStringPrefixless(*Element); - ui_id ToggleButtonId = UiId(Window, "enum value.type value.name", Element); + ui_id ToggleButtonId = UiId(Window, "toggle shader_language_setting", Element, ThisHash); if (ToggleButton(Ui, ElementName, ElementName, ToggleButtonId, Params)) { PushNewRow(Ui); - if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column - if (Button(Ui, CSz("330core"), UiId(Window, "enum ShaderLanguageSetting_330core", Element), Params)) + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("330core"), UiId(Window, "enum ShaderLanguageSetting_330core", Element, ThisHash), Params)) { - *Element = ShaderLanguageSetting_330core; + *Element = ShaderLanguageSetting_330core; SetToggleButton(Ui, ToggleButtonId, False); } PushNewRow(Ui); if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column - if (Button(Ui, CSz("310es"), UiId(Window, "enum ShaderLanguageSetting_310es", Element), Params)) + if (Button(Ui, CSz("310es"), UiId(Window, "enum ShaderLanguageSetting_310es", Element, ThisHash), Params)) { - *Element = ShaderLanguageSetting_310es; + *Element = ShaderLanguageSetting_310es; SetToggleButton(Ui, ToggleButtonId, False); } PushNewRow(Ui); + } else { @@ -35,3 +37,4 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, shader_language_setting *Elem } } + diff --git a/generated/do_editor_ui_for_enum_shape_axis.h b/generated/do_editor_ui_for_enum_shape_axis.h new file mode 100644 index 000000000..d39321445 --- /dev/null +++ b/generated/do_editor_ui_for_enum_shape_axis.h @@ -0,0 +1,94 @@ +// src/engine/editor.h:484:0 +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, shape_axis *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Generic) +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x29E6250C); + + if (Name.Count) { PushColumn(Ui, CS(Name), &DefaultUiRenderParams_Column); } + + cs ElementName = ToStringPrefixless(*Element); + ui_id ToggleButtonId = UiId(Window, "toggle shape_axis", Element, ThisHash); + if (ToggleButton(Ui, ElementName, ElementName, ToggleButtonId, Params)) + { + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("InferFromMajorAxis"), UiId(Window, "enum ShapeAxis_InferFromMajorAxis", Element, ThisHash), Params)) + { + *Element = ShapeAxis_InferFromMajorAxis; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("PosX"), UiId(Window, "enum ShapeAxis_PosX", Element, ThisHash), Params)) + { + *Element = ShapeAxis_PosX; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("NegX"), UiId(Window, "enum ShapeAxis_NegX", Element, ThisHash), Params)) + { + *Element = ShapeAxis_NegX; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("PosY"), UiId(Window, "enum ShapeAxis_PosY", Element, ThisHash), Params)) + { + *Element = ShapeAxis_PosY; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("NegY"), UiId(Window, "enum ShapeAxis_NegY", Element, ThisHash), Params)) + { + *Element = ShapeAxis_NegY; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("PosZ"), UiId(Window, "enum ShapeAxis_PosZ", Element, ThisHash), Params)) + { + *Element = ShapeAxis_PosZ; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("NegZ"), UiId(Window, "enum ShapeAxis_NegZ", Element, ThisHash), Params)) + { + *Element = ShapeAxis_NegZ; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("Count"), UiId(Window, "enum ShapeAxis_Count", Element, ThisHash), Params)) + { + *Element = ShapeAxis_Count; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + + } + else + { + PushNewRow(Ui); + } +} + + diff --git a/generated/do_editor_ui_for_enum_shape_type.h b/generated/do_editor_ui_for_enum_shape_type.h index 2dc4aeabf..8b219f1b8 100644 --- a/generated/do_editor_ui_for_enum_shape_type.h +++ b/generated/do_editor_ui_for_enum_shape_type.h @@ -1,42 +1,71 @@ -// src/engine/editor.cpp:104:0 - +// src/engine/editor.h:484:0 link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, shape_type *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic) +DoEditorUi(renderer_2d *Ui, window_layout *Window, shape_type *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Generic) { + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x3022A425); + if (Name.Count) { PushColumn(Ui, CS(Name), &DefaultUiRenderParams_Column); } cs ElementName = ToStringPrefixless(*Element); - ui_id ToggleButtonId = UiId(Window, "enum value.type value.name", Element); + ui_id ToggleButtonId = UiId(Window, "toggle shape_type", Element, ThisHash); if (ToggleButton(Ui, ElementName, ElementName, ToggleButtonId, Params)) { + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("Rect"), UiId(Window, "enum ShapeType_Rect", Element, ThisHash), Params)) + { + *Element = ShapeType_Rect; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("Sphere"), UiId(Window, "enum ShapeType_Sphere", Element, ThisHash), Params)) + { + *Element = ShapeType_Sphere; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("Line"), UiId(Window, "enum ShapeType_Line", Element, ThisHash), Params)) + { + *Element = ShapeType_Line; + + + SetToggleButton(Ui, ToggleButtonId, False); + } PushNewRow(Ui); if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column - if (Button(Ui, CSz("None"), UiId(Window, "enum ShapeType_None", Element), Params)) + if (Button(Ui, CSz("Cylinder"), UiId(Window, "enum ShapeType_Cylinder", Element, ThisHash), Params)) { - *Element = ShapeType_None; + *Element = ShapeType_Cylinder; SetToggleButton(Ui, ToggleButtonId, False); } PushNewRow(Ui); if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column - if (Button(Ui, CSz("Sphere"), UiId(Window, "enum ShapeType_Sphere", Element), Params)) + if (Button(Ui, CSz("Plane"), UiId(Window, "enum ShapeType_Plane", Element, ThisHash), Params)) { - *Element = ShapeType_Sphere; + *Element = ShapeType_Plane; SetToggleButton(Ui, ToggleButtonId, False); } PushNewRow(Ui); if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column - if (Button(Ui, CSz("Rect"), UiId(Window, "enum ShapeType_Rect", Element), Params)) + if (Button(Ui, CSz("Torus"), UiId(Window, "enum ShapeType_Torus", Element, ThisHash), Params)) { - *Element = ShapeType_Rect; + *Element = ShapeType_Torus; SetToggleButton(Ui, ToggleButtonId, False); } PushNewRow(Ui); + } else { @@ -44,3 +73,4 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, shape_type *Element, cs Name, } } + diff --git a/generated/do_editor_ui_for_enum_test_enum.h b/generated/do_editor_ui_for_enum_test_enum.h new file mode 100644 index 000000000..da88d307d --- /dev/null +++ b/generated/do_editor_ui_for_enum_test_enum.h @@ -0,0 +1,49 @@ +// src/engine/editor.h:484:0 +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, test_enum *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Generic) +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x3B491E58); + + if (Name.Count) { PushColumn(Ui, CS(Name), &DefaultUiRenderParams_Column); } + + cs ElementName = ToStringPrefixless(*Element); + ui_id ToggleButtonId = UiId(Window, "toggle test_enum", Element, ThisHash); + if (ToggleButton(Ui, ElementName, ElementName, ToggleButtonId, Params)) + { + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("Foo"), UiId(Window, "enum TestEnum_Foo", Element, ThisHash), Params)) + { + *Element = TestEnum_Foo; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("Bar"), UiId(Window, "enum TestEnum_Bar", Element, ThisHash), Params)) + { + *Element = TestEnum_Bar; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("Baz"), UiId(Window, "enum TestEnum_Baz", Element, ThisHash), Params)) + { + *Element = TestEnum_Baz; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + + } + else + { + PushNewRow(Ui); + } +} + + 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 de8a2d4d1..116315817 100644 --- a/generated/do_editor_ui_for_enum_tone_mapping_type.h +++ b/generated/do_editor_ui_for_enum_tone_mapping_type.h @@ -1,69 +1,71 @@ -// src/engine/editor.cpp:184:0 - +// src/engine/editor.h:484:0 link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, tone_mapping_type *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic) +DoEditorUi(renderer_2d *Ui, window_layout *Window, tone_mapping_type *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Generic) { + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0xD9E6A84); + if (Name.Count) { PushColumn(Ui, CS(Name), &DefaultUiRenderParams_Column); } cs ElementName = ToStringPrefixless(*Element); - ui_id ToggleButtonId = UiId(Window, "enum value.type value.name", Element); + ui_id ToggleButtonId = UiId(Window, "toggle tone_mapping_type", Element, ThisHash); if (ToggleButton(Ui, ElementName, ElementName, ToggleButtonId, Params)) { PushNewRow(Ui); - if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column - if (Button(Ui, CSz("None"), UiId(Window, "enum ToneMappingType_None", Element), Params)) + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("None"), UiId(Window, "enum ToneMappingType_None", Element, ThisHash), Params)) { - *Element = ToneMappingType_None; + *Element = ToneMappingType_None; SetToggleButton(Ui, ToggleButtonId, False); } PushNewRow(Ui); if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column - if (Button(Ui, CSz("Reinhard"), UiId(Window, "enum ToneMappingType_Reinhard", Element), Params)) + if (Button(Ui, CSz("Reinhard"), UiId(Window, "enum ToneMappingType_Reinhard", Element, ThisHash), Params)) { - *Element = ToneMappingType_Reinhard; + *Element = ToneMappingType_Reinhard; SetToggleButton(Ui, ToggleButtonId, False); } PushNewRow(Ui); if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column - if (Button(Ui, CSz("Exposure"), UiId(Window, "enum ToneMappingType_Exposure", Element), Params)) + if (Button(Ui, CSz("Exposure"), UiId(Window, "enum ToneMappingType_Exposure", Element, ThisHash), Params)) { - *Element = ToneMappingType_Exposure; + *Element = ToneMappingType_Exposure; SetToggleButton(Ui, ToggleButtonId, False); } PushNewRow(Ui); if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column - if (Button(Ui, CSz("AGX"), UiId(Window, "enum ToneMappingType_AGX", Element), Params)) + if (Button(Ui, CSz("AGX"), UiId(Window, "enum ToneMappingType_AGX", Element, ThisHash), Params)) { - *Element = ToneMappingType_AGX; + *Element = ToneMappingType_AGX; SetToggleButton(Ui, ToggleButtonId, False); } PushNewRow(Ui); if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column - if (Button(Ui, CSz("Sepia"), UiId(Window, "enum ToneMappingType_AGX_Sepia", Element), Params)) + if (Button(Ui, CSz("Sepia"), UiId(Window, "enum ToneMappingType_AGX_Sepia", Element, ThisHash), Params)) { - *Element = ToneMappingType_AGX_Sepia; + *Element = ToneMappingType_AGX_Sepia; SetToggleButton(Ui, ToggleButtonId, False); } PushNewRow(Ui); if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column - if (Button(Ui, CSz("Punchy"), UiId(Window, "enum ToneMappingType_AGX_Punchy", Element), Params)) + if (Button(Ui, CSz("Punchy"), UiId(Window, "enum ToneMappingType_AGX_Punchy", Element, ThisHash), Params)) { - *Element = ToneMappingType_AGX_Punchy; + *Element = ToneMappingType_AGX_Punchy; SetToggleButton(Ui, ToggleButtonId, False); } PushNewRow(Ui); + } else { @@ -71,3 +73,4 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, tone_mapping_type *Element, c } } + 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 4c25356f3..9a278177c 100644 --- a/generated/do_editor_ui_for_enum_ui_noise_type.h +++ b/generated/do_editor_ui_for_enum_ui_noise_type.h @@ -1,42 +1,44 @@ -// src/engine/editor.h:547:0 - +// src/engine/editor.h:484:0 link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, ui_noise_type *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic) +DoEditorUi(renderer_2d *Ui, window_layout *Window, ui_noise_type *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Generic) { + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x56825CE); + if (Name.Count) { PushColumn(Ui, CS(Name), &DefaultUiRenderParams_Column); } cs ElementName = ToStringPrefixless(*Element); - ui_id ToggleButtonId = UiId(Window, "enum value.type value.name", Element); + ui_id ToggleButtonId = UiId(Window, "toggle ui_noise_type", Element, ThisHash); if (ToggleButton(Ui, ElementName, ElementName, ToggleButtonId, Params)) { PushNewRow(Ui); - if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column - if (Button(Ui, CSz("Perlin"), UiId(Window, "enum NoiseType_Perlin", Element), Params)) + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("Perlin"), UiId(Window, "enum NoiseType_Perlin", Element, ThisHash), Params)) { - *Element = NoiseType_Perlin; + *Element = NoiseType_Perlin; SetToggleButton(Ui, ToggleButtonId, False); } PushNewRow(Ui); if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column - if (Button(Ui, CSz("Voronoi"), UiId(Window, "enum NoiseType_Voronoi", Element), Params)) + if (Button(Ui, CSz("Voronoi"), UiId(Window, "enum NoiseType_Voronoi", Element, ThisHash), Params)) { - *Element = NoiseType_Voronoi; + *Element = NoiseType_Voronoi; SetToggleButton(Ui, ToggleButtonId, False); } PushNewRow(Ui); if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column - if (Button(Ui, CSz("White"), UiId(Window, "enum NoiseType_White", Element), Params)) + if (Button(Ui, CSz("White"), UiId(Window, "enum NoiseType_White", Element, ThisHash), Params)) { - *Element = NoiseType_White; + *Element = NoiseType_White; SetToggleButton(Ui, ToggleButtonId, False); } PushNewRow(Ui); + } else { @@ -44,3 +46,4 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, ui_noise_type *Element, cs Na } } + diff --git a/generated/do_editor_ui_for_enum_visible_region_size.h b/generated/do_editor_ui_for_enum_visible_region_size.h new file mode 100644 index 000000000..262097aeb --- /dev/null +++ b/generated/do_editor_ui_for_enum_visible_region_size.h @@ -0,0 +1,247 @@ +// src/engine/editor.h:484:0 +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, visible_region_size *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Generic) +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x3B8559F7); + + if (Name.Count) { PushColumn(Ui, CS(Name), &DefaultUiRenderParams_Column); } + + cs ElementName = ToStringPrefixless(*Element); + ui_id ToggleButtonId = UiId(Window, "toggle visible_region_size", Element, ThisHash); + if (ToggleButton(Ui, ElementName, ElementName, ToggleButtonId, Params)) + { + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("1"), UiId(Window, "enum VisibleRegionSize_1", Element, ThisHash), Params)) + { + *Element = VisibleRegionSize_1; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("2"), UiId(Window, "enum VisibleRegionSize_2", Element, ThisHash), Params)) + { + *Element = VisibleRegionSize_2; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("4"), UiId(Window, "enum VisibleRegionSize_4", Element, ThisHash), Params)) + { + *Element = VisibleRegionSize_4; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("8"), UiId(Window, "enum VisibleRegionSize_8", Element, ThisHash), Params)) + { + *Element = VisibleRegionSize_8; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("16"), UiId(Window, "enum VisibleRegionSize_16", Element, ThisHash), Params)) + { + *Element = VisibleRegionSize_16; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("32"), UiId(Window, "enum VisibleRegionSize_32", Element, ThisHash), Params)) + { + *Element = VisibleRegionSize_32; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("64"), UiId(Window, "enum VisibleRegionSize_64", Element, ThisHash), Params)) + { + *Element = VisibleRegionSize_64; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("128"), UiId(Window, "enum VisibleRegionSize_128", Element, ThisHash), Params)) + { + *Element = VisibleRegionSize_128; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("256"), UiId(Window, "enum VisibleRegionSize_256", Element, ThisHash), Params)) + { + *Element = VisibleRegionSize_256; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("512"), UiId(Window, "enum VisibleRegionSize_512", Element, ThisHash), Params)) + { + *Element = VisibleRegionSize_512; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("1k"), UiId(Window, "enum VisibleRegionSize_1k", Element, ThisHash), Params)) + { + *Element = VisibleRegionSize_1k; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("2k"), UiId(Window, "enum VisibleRegionSize_2k", Element, ThisHash), Params)) + { + *Element = VisibleRegionSize_2k; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("4k"), UiId(Window, "enum VisibleRegionSize_4k", Element, ThisHash), Params)) + { + *Element = VisibleRegionSize_4k; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("8k"), UiId(Window, "enum VisibleRegionSize_8k", Element, ThisHash), Params)) + { + *Element = VisibleRegionSize_8k; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("16k"), UiId(Window, "enum VisibleRegionSize_16k", Element, ThisHash), Params)) + { + *Element = VisibleRegionSize_16k; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("32k"), UiId(Window, "enum VisibleRegionSize_32k", Element, ThisHash), Params)) + { + *Element = VisibleRegionSize_32k; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("64k"), UiId(Window, "enum VisibleRegionSize_64k", Element, ThisHash), Params)) + { + *Element = VisibleRegionSize_64k; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("128k"), UiId(Window, "enum VisibleRegionSize_128k", Element, ThisHash), Params)) + { + *Element = VisibleRegionSize_128k; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("256k"), UiId(Window, "enum VisibleRegionSize_256k", Element, ThisHash), Params)) + { + *Element = VisibleRegionSize_256k; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("512k"), UiId(Window, "enum VisibleRegionSize_512k", Element, ThisHash), Params)) + { + *Element = VisibleRegionSize_512k; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("1024k"), UiId(Window, "enum VisibleRegionSize_1024k", Element, ThisHash), Params)) + { + *Element = VisibleRegionSize_1024k; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("2048k"), UiId(Window, "enum VisibleRegionSize_2048k", Element, ThisHash), Params)) + { + *Element = VisibleRegionSize_2048k; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("4096k"), UiId(Window, "enum VisibleRegionSize_4096k", Element, ThisHash), Params)) + { + *Element = VisibleRegionSize_4096k; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("8192k"), UiId(Window, "enum VisibleRegionSize_8192k", Element, ThisHash), Params)) + { + *Element = VisibleRegionSize_8192k; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("16kk"), UiId(Window, "enum VisibleRegionSize_16kk", Element, ThisHash), Params)) + { + *Element = VisibleRegionSize_16kk; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + + } + else + { + PushNewRow(Ui); + } +} + + diff --git a/generated/do_editor_ui_for_enum_voxel_rule_direction.h b/generated/do_editor_ui_for_enum_voxel_rule_direction.h new file mode 100644 index 000000000..4436b3e04 --- /dev/null +++ b/generated/do_editor_ui_for_enum_voxel_rule_direction.h @@ -0,0 +1,85 @@ +// src/engine/editor.h:484:0 +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, voxel_rule_direction *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Generic) +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x77DD4C3); + + if (Name.Count) { PushColumn(Ui, CS(Name), &DefaultUiRenderParams_Column); } + + cs ElementName = ToStringPrefixless(*Element); + ui_id ToggleButtonId = UiId(Window, "toggle voxel_rule_direction", Element, ThisHash); + if (ToggleButton(Ui, ElementName, ElementName, ToggleButtonId, Params)) + { + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("PosX"), UiId(Window, "enum VoxelRuleDir_PosX", Element, ThisHash), Params)) + { + *Element = VoxelRuleDir_PosX; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("NegX"), UiId(Window, "enum VoxelRuleDir_NegX", Element, ThisHash), Params)) + { + *Element = VoxelRuleDir_NegX; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("PosY"), UiId(Window, "enum VoxelRuleDir_PosY", Element, ThisHash), Params)) + { + *Element = VoxelRuleDir_PosY; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("NegY"), UiId(Window, "enum VoxelRuleDir_NegY", Element, ThisHash), Params)) + { + *Element = VoxelRuleDir_NegY; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("PosZ"), UiId(Window, "enum VoxelRuleDir_PosZ", Element, ThisHash), Params)) + { + *Element = VoxelRuleDir_PosZ; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("NegZ"), UiId(Window, "enum VoxelRuleDir_NegZ", Element, ThisHash), Params)) + { + *Element = VoxelRuleDir_NegZ; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("Count"), UiId(Window, "enum VoxelRuleDir_Count", Element, ThisHash), Params)) + { + *Element = VoxelRuleDir_Count; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + + } + else + { + PushNewRow(Ui); + } +} + + 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 c8ec89173..173618885 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,5 +1,4 @@ -// src/engine/editor.h:683:0 - +// src/engine/editor.h:577:0 link_internal void RadioSelect(ui_toggle_button_group *RadioGroup, asset_window_view_mode Selection) { @@ -18,8 +17,9 @@ RadioButtonGroup_asset_window_view_mode( renderer_2d *Ui, { ui_toggle_button_handle ButtonHandles[] = { - { CSz("AssetFiles"), UiId(Window, Cast(void*, Element), Cast(void*, "asset_window_view_mode AssetWindowViewMode_AssetFiles")), AssetWindowViewMode_AssetFiles }, - { CSz("AssetTable"), UiId(Window, Cast(void*, Element), Cast(void*, "asset_window_view_mode AssetWindowViewMode_AssetTable")), AssetWindowViewMode_AssetTable }, + { CSz("AssetFiles"), {}, UiId(Window, Cast(void*, Element), Cast(void*, "asset_window_view_mode AssetWindowViewMode_AssetFiles")), AssetWindowViewMode_AssetFiles }, + { CSz("AssetTable"), {}, UiId(Window, Cast(void*, Element), Cast(void*, "asset_window_view_mode AssetWindowViewMode_AssetTable")), AssetWindowViewMode_AssetTable }, + }; ui_toggle_button_handle_buffer ButtonBuffer = { @@ -27,7 +27,7 @@ RadioButtonGroup_asset_window_view_mode( renderer_2d *Ui, ButtonHandles }; - ui_toggle_button_group Result = DrawButtonGroupForEnum(Ui, &ButtonBuffer, GroupName, Cast(u32*, Element), Params, ui_toggle_button_group_flags(ExtraFlags|ToggleButtonGroupFlags_RadioButtons)); + ui_toggle_button_group Result = DrawButtonGroupForEnum(Ui, &ButtonBuffer, GroupName, Cast(u32*, Element), Params, ui_toggle_button_group_flags(ExtraFlags|ToggleButtonGroupFlags_TypeRadioButton)); return Result; } @@ -39,6 +39,7 @@ DoEditorUi( renderer_2d *Ui, window_layout *Window, asset_window_view_mode *Element, cs GroupName, + u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Generic, ui_toggle_button_group_flags ExtraFlags = ToggleButtonGroupFlags_None) { 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 0c2468b3b..ea7cb06a8 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,5 +1,4 @@ -// src/engine/editor.h:856:0 - +// src/engine/editor.h:577:0 link_internal void RadioSelect(ui_toggle_button_group *RadioGroup, brush_layer_type Selection) { @@ -18,8 +17,9 @@ RadioButtonGroup_brush_layer_type( renderer_2d *Ui, { ui_toggle_button_handle ButtonHandles[] = { - { CSz("Noise"), UiId(Window, Cast(void*, Element), Cast(void*, "brush_layer_type BrushLayerType_Noise")), BrushLayerType_Noise }, - { CSz("Shape"), UiId(Window, Cast(void*, Element), Cast(void*, "brush_layer_type BrushLayerType_Shape")), BrushLayerType_Shape }, + { CSz("Noise"), {}, UiId(Window, Cast(void*, Element), Cast(void*, "brush_layer_type BrushLayerType_Noise")), BrushLayerType_Noise }, + { CSz("Shape"), {}, UiId(Window, Cast(void*, Element), Cast(void*, "brush_layer_type BrushLayerType_Shape")), BrushLayerType_Shape }, + }; ui_toggle_button_handle_buffer ButtonBuffer = { @@ -27,7 +27,7 @@ RadioButtonGroup_brush_layer_type( renderer_2d *Ui, ButtonHandles }; - ui_toggle_button_group Result = DrawButtonGroupForEnum(Ui, &ButtonBuffer, GroupName, Cast(u32*, Element), Params, ui_toggle_button_group_flags(ExtraFlags|ToggleButtonGroupFlags_RadioButtons)); + ui_toggle_button_group Result = DrawButtonGroupForEnum(Ui, &ButtonBuffer, GroupName, Cast(u32*, Element), Params, ui_toggle_button_group_flags(ExtraFlags|ToggleButtonGroupFlags_TypeRadioButton)); return Result; } @@ -39,6 +39,7 @@ DoEditorUi( renderer_2d *Ui, window_layout *Window, brush_layer_type *Element, cs GroupName, + u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Generic, ui_toggle_button_group_flags ExtraFlags = ToggleButtonGroupFlags_None) { diff --git a/generated/do_editor_ui_for_radio_enum_world_edit_blend_mode.h b/generated/do_editor_ui_for_radio_enum_world_edit_blend_mode.h new file mode 100644 index 000000000..0ca20128d --- /dev/null +++ b/generated/do_editor_ui_for_radio_enum_world_edit_blend_mode.h @@ -0,0 +1,52 @@ +// src/engine/editor.h:575:0 +link_internal void +RadioSelect(ui_toggle_button_group *RadioGroup, world_edit_blend_mode Selection) +{ + ui_toggle_button_handle *ToggleHandle = RadioGroup->Buttons.Start + Selection; + SetRadioButton(RadioGroup, ToggleHandle, True); + /* Ensure( ToggleRadioButton(RadioGroup, ToggleHandle) ); */ +} + +link_internal ui_toggle_button_group +RadioButtonGroup_world_edit_blend_mode( renderer_2d *Ui, + window_layout *Window, + cs GroupName, + world_edit_blend_mode *Element, + ui_render_params *Params = &DefaultUiRenderParams_Generic, + ui_toggle_button_group_flags ExtraFlags = ToggleButtonGroupFlags_None) +{ + ui_toggle_button_handle ButtonHandles[] = + { + { CSz("Additive"), {}, UiId(Window, Cast(void*, Element), Cast(void*, "world_edit_blend_mode WorldEdit_Mode_Additive")), WorldEdit_Mode_Additive }, + { CSz("Subtractive"), {}, UiId(Window, Cast(void*, Element), Cast(void*, "world_edit_blend_mode WorldEdit_Mode_Subtractive")), WorldEdit_Mode_Subtractive }, + { CSz("Multiply"), {}, UiId(Window, Cast(void*, Element), Cast(void*, "world_edit_blend_mode WorldEdit_Mode_Multiply")), WorldEdit_Mode_Multiply }, + { CSz("Threshold"), {}, UiId(Window, Cast(void*, Element), Cast(void*, "world_edit_blend_mode WorldEdit_Mode_Threshold")), WorldEdit_Mode_Threshold }, + { CSz("Disabled"), {}, UiId(Window, Cast(void*, Element), Cast(void*, "world_edit_blend_mode WorldEdit_Mode_Disabled")), WorldEdit_Mode_Disabled }, + + }; + + ui_toggle_button_handle_buffer ButtonBuffer = { + ArrayCount(ButtonHandles), + ButtonHandles + }; + + ui_toggle_button_group Result = DrawButtonGroupForEnum(Ui, &ButtonBuffer, GroupName, Cast(u32*, Element), Params, ui_toggle_button_group_flags(ExtraFlags|ToggleButtonGroupFlags_TypeRadioButton)); + return Result; +} + + + + +link_internal ui_toggle_button_group +DoEditorUi( renderer_2d *Ui, + window_layout *Window, + world_edit_blend_mode *Element, + cs GroupName, + u32 ParentHash, + ui_render_params *Params = &DefaultUiRenderParams_Generic, + ui_toggle_button_group_flags ExtraFlags = ToggleButtonGroupFlags_None) +{ + ui_toggle_button_group RadioGroup = RadioButtonGroup_world_edit_blend_mode(Ui, Window, GroupName, Element, Params, ExtraFlags); + return RadioGroup; +} + diff --git a/generated/do_editor_ui_for_radio_enum_world_edit_blend_mode_modifier.h b/generated/do_editor_ui_for_radio_enum_world_edit_blend_mode_modifier.h new file mode 100644 index 000000000..60df54d28 --- /dev/null +++ b/generated/do_editor_ui_for_radio_enum_world_edit_blend_mode_modifier.h @@ -0,0 +1,137 @@ +// src/engine/editor.h:484:0 +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, world_edit_blend_mode_modifier *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Generic) +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x1AAA4276); + + if (Name.Count) { PushColumn(Ui, CS(Name), &DefaultUiRenderParams_Column); } + + cs ElementName = ToStringPrefixless(*Element); + ui_id ToggleButtonId = UiId(Window, "toggle world_edit_blend_mode_modifier", Element, ThisHash); + if (ToggleButton(Ui, ElementName, ElementName, ToggleButtonId, Params)) + { + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("None"), UiId(Window, "enum WorldEdit_Modifier_None", Element, ThisHash), Params)) + { + if (WorldEdit_Modifier_None == world_edit_blend_mode_modifier(0)) + { + *Element = world_edit_blend_mode_modifier(0); + } + else + { + if ((*Element & WorldEdit_Modifier_None) == WorldEdit_Modifier_None) + { + *Element = world_edit_blend_mode_modifier(*Element&~WorldEdit_Modifier_None); + } + else + { + *Element = world_edit_blend_mode_modifier(*Element|WorldEdit_Modifier_None); + } + } + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("ClampPos"), UiId(Window, "enum WorldEdit_ValueModifier_ClampPos", Element, ThisHash), Params)) + { + if (WorldEdit_ValueModifier_ClampPos == world_edit_blend_mode_modifier(0)) + { + *Element = world_edit_blend_mode_modifier(0); + } + else + { + if ((*Element & WorldEdit_ValueModifier_ClampPos) == WorldEdit_ValueModifier_ClampPos) + { + *Element = world_edit_blend_mode_modifier(*Element&~WorldEdit_ValueModifier_ClampPos); + } + else + { + *Element = world_edit_blend_mode_modifier(*Element|WorldEdit_ValueModifier_ClampPos); + } + } + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("ClampNeg"), UiId(Window, "enum WorldEdit_ValueModifier_ClampNeg", Element, ThisHash), Params)) + { + if (WorldEdit_ValueModifier_ClampNeg == world_edit_blend_mode_modifier(0)) + { + *Element = world_edit_blend_mode_modifier(0); + } + else + { + if ((*Element & WorldEdit_ValueModifier_ClampNeg) == WorldEdit_ValueModifier_ClampNeg) + { + *Element = world_edit_blend_mode_modifier(*Element&~WorldEdit_ValueModifier_ClampNeg); + } + else + { + *Element = world_edit_blend_mode_modifier(*Element|WorldEdit_ValueModifier_ClampNeg); + } + } + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("Threshold"), UiId(Window, "enum WorldEdit_ValueModifier_Threshold", Element, ThisHash), Params)) + { + if (WorldEdit_ValueModifier_Threshold == world_edit_blend_mode_modifier(0)) + { + *Element = world_edit_blend_mode_modifier(0); + } + else + { + if ((*Element & WorldEdit_ValueModifier_Threshold) == WorldEdit_ValueModifier_Threshold) + { + *Element = world_edit_blend_mode_modifier(*Element&~WorldEdit_ValueModifier_Threshold); + } + else + { + *Element = world_edit_blend_mode_modifier(*Element|WorldEdit_ValueModifier_Threshold); + } + } + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("Discard"), UiId(Window, "enum WorldEdit_ColorModifier_Discard", Element, ThisHash), Params)) + { + if (WorldEdit_ColorModifier_Discard == world_edit_blend_mode_modifier(0)) + { + *Element = world_edit_blend_mode_modifier(0); + } + else + { + if ((*Element & WorldEdit_ColorModifier_Discard) == WorldEdit_ColorModifier_Discard) + { + *Element = world_edit_blend_mode_modifier(*Element&~WorldEdit_ColorModifier_Discard); + } + else + { + *Element = world_edit_blend_mode_modifier(*Element|WorldEdit_ColorModifier_Discard); + } + } + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + + } + else + { + PushNewRow(Ui); + } +} + + 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 4dd7b4b36..1889f0528 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,5 +1,4 @@ -// src/engine/editor.h:697:0 - +// src/engine/editor.h:577:0 link_internal void RadioSelect(ui_toggle_button_group *RadioGroup, world_edit_brush_type Selection) { @@ -18,11 +17,12 @@ RadioButtonGroup_world_edit_brush_type( renderer_2d *Ui, { ui_toggle_button_handle ButtonHandles[] = { - { CSz("Disabled"), UiId(Window, Cast(void*, Element), Cast(void*, "world_edit_brush_type WorldEdit_BrushType_Disabled")), WorldEdit_BrushType_Disabled }, - { CSz("Single"), UiId(Window, Cast(void*, Element), Cast(void*, "world_edit_brush_type WorldEdit_BrushType_Single")), WorldEdit_BrushType_Single }, - { CSz("Asset"), UiId(Window, Cast(void*, Element), Cast(void*, "world_edit_brush_type WorldEdit_BrushType_Asset")), WorldEdit_BrushType_Asset }, - { CSz("Entity"), UiId(Window, Cast(void*, Element), Cast(void*, "world_edit_brush_type WorldEdit_BrushType_Entity")), WorldEdit_BrushType_Entity }, - { CSz("Layered"), UiId(Window, Cast(void*, Element), Cast(void*, "world_edit_brush_type WorldEdit_BrushType_Layered")), WorldEdit_BrushType_Layered }, + { CSz("Disabled"), {}, UiId(Window, Cast(void*, Element), Cast(void*, "world_edit_brush_type WorldEdit_BrushType_Disabled")), WorldEdit_BrushType_Disabled }, + { CSz("Single"), {}, UiId(Window, Cast(void*, Element), Cast(void*, "world_edit_brush_type WorldEdit_BrushType_Single")), WorldEdit_BrushType_Single }, + { CSz("Asset"), {}, UiId(Window, Cast(void*, Element), Cast(void*, "world_edit_brush_type WorldEdit_BrushType_Asset")), WorldEdit_BrushType_Asset }, + { CSz("Entity"), {}, UiId(Window, Cast(void*, Element), Cast(void*, "world_edit_brush_type WorldEdit_BrushType_Entity")), WorldEdit_BrushType_Entity }, + { CSz("Layered"), {}, UiId(Window, Cast(void*, Element), Cast(void*, "world_edit_brush_type WorldEdit_BrushType_Layered")), WorldEdit_BrushType_Layered }, + }; ui_toggle_button_handle_buffer ButtonBuffer = { @@ -30,7 +30,7 @@ RadioButtonGroup_world_edit_brush_type( renderer_2d *Ui, ButtonHandles }; - ui_toggle_button_group Result = DrawButtonGroupForEnum(Ui, &ButtonBuffer, GroupName, Cast(u32*, Element), Params, ui_toggle_button_group_flags(ExtraFlags|ToggleButtonGroupFlags_RadioButtons)); + ui_toggle_button_group Result = DrawButtonGroupForEnum(Ui, &ButtonBuffer, GroupName, Cast(u32*, Element), Params, ui_toggle_button_group_flags(ExtraFlags|ToggleButtonGroupFlags_TypeRadioButton)); return Result; } @@ -42,6 +42,7 @@ DoEditorUi( renderer_2d *Ui, window_layout *Window, world_edit_brush_type *Element, cs GroupName, + u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Generic, ui_toggle_button_group_flags ExtraFlags = ToggleButtonGroupFlags_None) { diff --git a/generated/do_editor_ui_for_radio_enum_world_edit_color_blend_mode.h b/generated/do_editor_ui_for_radio_enum_world_edit_color_blend_mode.h new file mode 100644 index 000000000..a47711bbd --- /dev/null +++ b/generated/do_editor_ui_for_radio_enum_world_edit_color_blend_mode.h @@ -0,0 +1,58 @@ +// src/engine/editor.h:484:0 +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, world_edit_color_blend_mode *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Generic) +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x1E3E2BDD); + + if (Name.Count) { PushColumn(Ui, CS(Name), &DefaultUiRenderParams_Column); } + + cs ElementName = ToStringPrefixless(*Element); + ui_id ToggleButtonId = UiId(Window, "toggle world_edit_color_blend_mode", Element, ThisHash); + if (ToggleButton(Ui, ElementName, ElementName, ToggleButtonId, Params)) + { + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("ValuePositive"), UiId(Window, "enum WorldEdit_ColorBlendMode_ValuePositive", Element, ThisHash), Params)) + { + *Element = WorldEdit_ColorBlendMode_ValuePositive; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("ValueNegative"), UiId(Window, "enum WorldEdit_ColorBlendMode_ValueNegative", Element, ThisHash), Params)) + { + *Element = WorldEdit_ColorBlendMode_ValueNegative; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("Surface"), UiId(Window, "enum WorldEdit_ColorBlendMode_Surface", Element, ThisHash), Params)) + { + *Element = WorldEdit_ColorBlendMode_Surface; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("Disabled"), UiId(Window, "enum WorldEdit_ColorBlendMode_Disabled", Element, ThisHash), Params)) + { + *Element = WorldEdit_ColorBlendMode_Disabled; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + + } + else + { + PushNewRow(Ui); + } +} + + 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 deleted file mode 100644 index fbee1fd67..000000000 --- a/generated/do_editor_ui_for_radio_enum_world_edit_mode.h +++ /dev/null @@ -1,50 +0,0 @@ -// src/engine/editor.h:691:0 - -link_internal void -RadioSelect(ui_toggle_button_group *RadioGroup, world_edit_mode Selection) -{ - ui_toggle_button_handle *ToggleHandle = RadioGroup->Buttons.Start + Selection; - SetRadioButton(RadioGroup, ToggleHandle, True); - /* Ensure( ToggleRadioButton(RadioGroup, ToggleHandle) ); */ -} - -link_internal ui_toggle_button_group -RadioButtonGroup_world_edit_mode( renderer_2d *Ui, - window_layout *Window, - cs GroupName, - world_edit_mode *Element, - ui_render_params *Params = &DefaultUiRenderParams_Generic, - ui_toggle_button_group_flags ExtraFlags = ToggleButtonGroupFlags_None) -{ - ui_toggle_button_handle ButtonHandles[] = - { - { CSz("Attach"), UiId(Window, Cast(void*, Element), Cast(void*, "world_edit_mode WorldEdit_Mode_Attach")), WorldEdit_Mode_Attach }, - { CSz("Remove"), UiId(Window, Cast(void*, Element), Cast(void*, "world_edit_mode WorldEdit_Mode_Remove")), WorldEdit_Mode_Remove }, - { CSz("Paint"), UiId(Window, Cast(void*, Element), Cast(void*, "world_edit_mode WorldEdit_Mode_Paint")), WorldEdit_Mode_Paint }, - { CSz("Disabled"), UiId(Window, Cast(void*, Element), Cast(void*, "world_edit_mode WorldEdit_Mode_Disabled")), WorldEdit_Mode_Disabled }, - }; - - ui_toggle_button_handle_buffer ButtonBuffer = { - ArrayCount(ButtonHandles), - ButtonHandles - }; - - ui_toggle_button_group Result = DrawButtonGroupForEnum(Ui, &ButtonBuffer, GroupName, Cast(u32*, Element), Params, ui_toggle_button_group_flags(ExtraFlags|ToggleButtonGroupFlags_RadioButtons)); - return Result; -} - - - - -link_internal ui_toggle_button_group -DoEditorUi( renderer_2d *Ui, - window_layout *Window, - world_edit_mode *Element, - cs GroupName, - ui_render_params *Params = &DefaultUiRenderParams_Generic, - ui_toggle_button_group_flags ExtraFlags = ToggleButtonGroupFlags_None) -{ - ui_toggle_button_group RadioGroup = RadioButtonGroup_world_edit_mode(Ui, Window, GroupName, Element, Params, ExtraFlags); - return RadioGroup; -} - 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 7583cf80e..a9c9af7f6 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,5 +1,4 @@ -// src/engine/editor.h:694:0 - +// src/engine/editor.h:577:0 link_internal void RadioSelect(ui_toggle_button_group *RadioGroup, world_edit_tool Selection) { @@ -18,11 +17,11 @@ RadioButtonGroup_world_edit_tool( renderer_2d *Ui, { ui_toggle_button_handle ButtonHandles[] = { - { CSz("Disabled"), UiId(Window, Cast(void*, Element), Cast(void*, "world_edit_tool WorldEdit_Tool_Disabled")), WorldEdit_Tool_Disabled }, - { CSz("Select"), UiId(Window, Cast(void*, Element), Cast(void*, "world_edit_tool WorldEdit_Tool_Select")), WorldEdit_Tool_Select }, - { CSz("Brush"), UiId(Window, Cast(void*, Element), Cast(void*, "world_edit_tool WorldEdit_Tool_Brush")), WorldEdit_Tool_Brush }, - { CSz("Eyedropper"), UiId(Window, Cast(void*, Element), Cast(void*, "world_edit_tool WorldEdit_Tool_Eyedropper")), WorldEdit_Tool_Eyedropper }, - { CSz("BlitEntity"), UiId(Window, Cast(void*, Element), Cast(void*, "world_edit_tool WorldEdit_Tool_BlitEntity")), WorldEdit_Tool_BlitEntity }, + { CSz("Disabled"), {}, UiId(Window, Cast(void*, Element), Cast(void*, "world_edit_tool WorldEdit_Tool_Disabled")), WorldEdit_Tool_Disabled }, + { CSz("Select"), {}, UiId(Window, Cast(void*, Element), Cast(void*, "world_edit_tool WorldEdit_Tool_Select")), WorldEdit_Tool_Select }, + { CSz("Eyedropper"), {}, UiId(Window, Cast(void*, Element), Cast(void*, "world_edit_tool WorldEdit_Tool_Eyedropper")), WorldEdit_Tool_Eyedropper }, + { CSz("BlitEntity"), {}, UiId(Window, Cast(void*, Element), Cast(void*, "world_edit_tool WorldEdit_Tool_BlitEntity")), WorldEdit_Tool_BlitEntity }, + }; ui_toggle_button_handle_buffer ButtonBuffer = { @@ -30,7 +29,7 @@ RadioButtonGroup_world_edit_tool( renderer_2d *Ui, ButtonHandles }; - ui_toggle_button_group Result = DrawButtonGroupForEnum(Ui, &ButtonBuffer, GroupName, Cast(u32*, Element), Params, ui_toggle_button_group_flags(ExtraFlags|ToggleButtonGroupFlags_RadioButtons)); + ui_toggle_button_group Result = DrawButtonGroupForEnum(Ui, &ButtonBuffer, GroupName, Cast(u32*, Element), Params, ui_toggle_button_group_flags(ExtraFlags|ToggleButtonGroupFlags_TypeRadioButton)); return Result; } @@ -42,6 +41,7 @@ DoEditorUi( renderer_2d *Ui, window_layout *Window, world_edit_tool *Element, cs GroupName, + u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Generic, ui_toggle_button_group_flags ExtraFlags = ToggleButtonGroupFlags_None) { diff --git a/generated/do_editor_ui_for_scalar_type_688724926.h b/generated/do_editor_ui_for_scalar_type_688724926.h index a47eba4ec..4c9f03e45 100644 --- a/generated/do_editor_ui_for_scalar_type_688724926.h +++ b/generated/do_editor_ui_for_scalar_type_688724926.h @@ -1,8 +1,9 @@ -// src/engine/editor.h:381:0 - +// src/engine/editor.h:261:0 link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, s64 *Value, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic, EDITOR_UI_VALUE_RANGE_PROTO_DEFAULTS) +DoEditorUi(renderer_2d *Ui, window_layout *Window, s64 *Value, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Generic, EDITOR_UI_VALUE_RANGE_PROTO_DEFAULTS) { + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x290D1BBC); + Params = Params ? Params : &DefaultUiRenderParams_Blank; if (Name.Count) { PushColumn(Ui, Name, &DefaultUiRenderParams_Column); } @@ -11,9 +12,9 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, s64 *Value, cs Name, ui_rende { u32 Start = StartColumn(Ui, &DefaultUiRenderParams_Blank); PushTableStart(Ui); - if (Button(Ui, CSz("-"), UiId(Window, "decrement", Value), &DefaultUiRenderParams_Button)) { *Value = *Value - 1; } + if (Button(Ui, CSz("-"), UiId(Window, "decrement", Value, ThisHash), &DefaultUiRenderParams_Button)) { *Value = *Value - 1; } PushColumn(Ui, CS(*Value), &DefaultUiRenderParams_Generic); - if (Button(Ui, CSz("+"), UiId(Window, "increment", Value), &DefaultUiRenderParams_Button)) { *Value = *Value + 1; } + if (Button(Ui, CSz("+"), UiId(Window, "increment", Value, ThisHash), &DefaultUiRenderParams_Button)) { *Value = *Value + 1; } PushTableEnd(Ui); EndColumn(Ui, Start); } @@ -26,14 +27,10 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, s64 *Value, cs Name, ui_rende } link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, volatile s64 *Value, cs Name, ui_render_params *Params) +DoEditorUi(renderer_2d *Ui, window_layout *Window, u64 *Value, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Generic, EDITOR_UI_VALUE_RANGE_PROTO_DEFAULTS) { - DoEditorUi(Ui, Window, (s64*) Value, Name, Params); -} + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x290D1BBE); -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, u64 *Value, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic, EDITOR_UI_VALUE_RANGE_PROTO_DEFAULTS) -{ Params = Params ? Params : &DefaultUiRenderParams_Blank; if (Name.Count) { PushColumn(Ui, Name, &DefaultUiRenderParams_Column); } @@ -42,9 +39,9 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, u64 *Value, cs Name, ui_rende { u32 Start = StartColumn(Ui, &DefaultUiRenderParams_Blank); PushTableStart(Ui); - if (Button(Ui, CSz("-"), UiId(Window, "decrement", Value), &DefaultUiRenderParams_Button)) { *Value = *Value - 1; } + if (Button(Ui, CSz("-"), UiId(Window, "decrement", Value, ThisHash), &DefaultUiRenderParams_Button)) { *Value = *Value - 1; } PushColumn(Ui, CS(*Value), &DefaultUiRenderParams_Generic); - if (Button(Ui, CSz("+"), UiId(Window, "increment", Value), &DefaultUiRenderParams_Button)) { *Value = *Value + 1; } + if (Button(Ui, CSz("+"), UiId(Window, "increment", Value, ThisHash), &DefaultUiRenderParams_Button)) { *Value = *Value + 1; } PushTableEnd(Ui); EndColumn(Ui, Start); } @@ -57,14 +54,10 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, u64 *Value, cs Name, ui_rende } link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, volatile u64 *Value, cs Name, ui_render_params *Params) +DoEditorUi(renderer_2d *Ui, window_layout *Window, s32 *Value, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Generic, EDITOR_UI_VALUE_RANGE_PROTO_DEFAULTS) { - DoEditorUi(Ui, Window, (u64*) Value, Name, Params); -} + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x290D052B); -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, s32 *Value, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic, EDITOR_UI_VALUE_RANGE_PROTO_DEFAULTS) -{ Params = Params ? Params : &DefaultUiRenderParams_Blank; if (Name.Count) { PushColumn(Ui, Name, &DefaultUiRenderParams_Column); } @@ -73,9 +66,9 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, s32 *Value, cs Name, ui_rende { u32 Start = StartColumn(Ui, &DefaultUiRenderParams_Blank); PushTableStart(Ui); - if (Button(Ui, CSz("-"), UiId(Window, "decrement", Value), &DefaultUiRenderParams_Button)) { *Value = *Value - 1; } + if (Button(Ui, CSz("-"), UiId(Window, "decrement", Value, ThisHash), &DefaultUiRenderParams_Button)) { *Value = *Value - 1; } PushColumn(Ui, CS(*Value), &DefaultUiRenderParams_Generic); - if (Button(Ui, CSz("+"), UiId(Window, "increment", Value), &DefaultUiRenderParams_Button)) { *Value = *Value + 1; } + if (Button(Ui, CSz("+"), UiId(Window, "increment", Value, ThisHash), &DefaultUiRenderParams_Button)) { *Value = *Value + 1; } PushTableEnd(Ui); EndColumn(Ui, Start); } @@ -88,14 +81,10 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, s32 *Value, cs Name, ui_rende } link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, volatile s32 *Value, cs Name, ui_render_params *Params) +DoEditorUi(renderer_2d *Ui, window_layout *Window, u32 *Value, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Generic, EDITOR_UI_VALUE_RANGE_PROTO_DEFAULTS) { - DoEditorUi(Ui, Window, (s32*) Value, Name, Params); -} + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x290D052D); -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, u32 *Value, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic, EDITOR_UI_VALUE_RANGE_PROTO_DEFAULTS) -{ Params = Params ? Params : &DefaultUiRenderParams_Blank; if (Name.Count) { PushColumn(Ui, Name, &DefaultUiRenderParams_Column); } @@ -104,9 +93,9 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, u32 *Value, cs Name, ui_rende { u32 Start = StartColumn(Ui, &DefaultUiRenderParams_Blank); PushTableStart(Ui); - if (Button(Ui, CSz("-"), UiId(Window, "decrement", Value), &DefaultUiRenderParams_Button)) { *Value = *Value - 1; } + if (Button(Ui, CSz("-"), UiId(Window, "decrement", Value, ThisHash), &DefaultUiRenderParams_Button)) { *Value = *Value - 1; } PushColumn(Ui, CS(*Value), &DefaultUiRenderParams_Generic); - if (Button(Ui, CSz("+"), UiId(Window, "increment", Value), &DefaultUiRenderParams_Button)) { *Value = *Value + 1; } + if (Button(Ui, CSz("+"), UiId(Window, "increment", Value, ThisHash), &DefaultUiRenderParams_Button)) { *Value = *Value + 1; } PushTableEnd(Ui); EndColumn(Ui, Start); } @@ -119,14 +108,10 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, u32 *Value, cs Name, ui_rende } link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, volatile u32 *Value, cs Name, ui_render_params *Params) +DoEditorUi(renderer_2d *Ui, window_layout *Window, s16 *Value, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Generic, EDITOR_UI_VALUE_RANGE_PROTO_DEFAULTS) { - DoEditorUi(Ui, Window, (u32*) Value, Name, Params); -} + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x290D30A5); -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, s16 *Value, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic, EDITOR_UI_VALUE_RANGE_PROTO_DEFAULTS) -{ Params = Params ? Params : &DefaultUiRenderParams_Blank; if (Name.Count) { PushColumn(Ui, Name, &DefaultUiRenderParams_Column); } @@ -135,9 +120,9 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, s16 *Value, cs Name, ui_rende { u32 Start = StartColumn(Ui, &DefaultUiRenderParams_Blank); PushTableStart(Ui); - if (Button(Ui, CSz("-"), UiId(Window, "decrement", Value), &DefaultUiRenderParams_Button)) { *Value = *Value - 1; } + if (Button(Ui, CSz("-"), UiId(Window, "decrement", Value, ThisHash), &DefaultUiRenderParams_Button)) { *Value = *Value - 1; } PushColumn(Ui, CS(*Value), &DefaultUiRenderParams_Generic); - if (Button(Ui, CSz("+"), UiId(Window, "increment", Value), &DefaultUiRenderParams_Button)) { *Value = *Value + 1; } + if (Button(Ui, CSz("+"), UiId(Window, "increment", Value, ThisHash), &DefaultUiRenderParams_Button)) { *Value = *Value + 1; } PushTableEnd(Ui); EndColumn(Ui, Start); } @@ -150,14 +135,10 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, s16 *Value, cs Name, ui_rende } link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, volatile s16 *Value, cs Name, ui_render_params *Params) +DoEditorUi(renderer_2d *Ui, window_layout *Window, u16 *Value, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Generic, EDITOR_UI_VALUE_RANGE_PROTO_DEFAULTS) { - DoEditorUi(Ui, Window, (s16*) Value, Name, Params); -} + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x290D30A7); -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, u16 *Value, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic, EDITOR_UI_VALUE_RANGE_PROTO_DEFAULTS) -{ Params = Params ? Params : &DefaultUiRenderParams_Blank; if (Name.Count) { PushColumn(Ui, Name, &DefaultUiRenderParams_Column); } @@ -166,9 +147,9 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, u16 *Value, cs Name, ui_rende { u32 Start = StartColumn(Ui, &DefaultUiRenderParams_Blank); PushTableStart(Ui); - if (Button(Ui, CSz("-"), UiId(Window, "decrement", Value), &DefaultUiRenderParams_Button)) { *Value = *Value - 1; } + if (Button(Ui, CSz("-"), UiId(Window, "decrement", Value, ThisHash), &DefaultUiRenderParams_Button)) { *Value = *Value - 1; } PushColumn(Ui, CS(*Value), &DefaultUiRenderParams_Generic); - if (Button(Ui, CSz("+"), UiId(Window, "increment", Value), &DefaultUiRenderParams_Button)) { *Value = *Value + 1; } + if (Button(Ui, CSz("+"), UiId(Window, "increment", Value, ThisHash), &DefaultUiRenderParams_Button)) { *Value = *Value + 1; } PushTableEnd(Ui); EndColumn(Ui, Start); } @@ -181,14 +162,10 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, u16 *Value, cs Name, ui_rende } link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, volatile u16 *Value, cs Name, ui_render_params *Params) +DoEditorUi(renderer_2d *Ui, window_layout *Window, s8 *Value, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Generic, EDITOR_UI_VALUE_RANGE_PROTO_DEFAULTS) { - DoEditorUi(Ui, Window, (u16*) Value, Name, Params); -} + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x290F14E4); -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, s8 *Value, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic, EDITOR_UI_VALUE_RANGE_PROTO_DEFAULTS) -{ Params = Params ? Params : &DefaultUiRenderParams_Blank; if (Name.Count) { PushColumn(Ui, Name, &DefaultUiRenderParams_Column); } @@ -197,9 +174,9 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, s8 *Value, cs Name, ui_render { u32 Start = StartColumn(Ui, &DefaultUiRenderParams_Blank); PushTableStart(Ui); - if (Button(Ui, CSz("-"), UiId(Window, "decrement", Value), &DefaultUiRenderParams_Button)) { *Value = *Value - 1; } + if (Button(Ui, CSz("-"), UiId(Window, "decrement", Value, ThisHash), &DefaultUiRenderParams_Button)) { *Value = *Value - 1; } PushColumn(Ui, CS(*Value), &DefaultUiRenderParams_Generic); - if (Button(Ui, CSz("+"), UiId(Window, "increment", Value), &DefaultUiRenderParams_Button)) { *Value = *Value + 1; } + if (Button(Ui, CSz("+"), UiId(Window, "increment", Value, ThisHash), &DefaultUiRenderParams_Button)) { *Value = *Value + 1; } PushTableEnd(Ui); EndColumn(Ui, Start); } @@ -212,14 +189,10 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, s8 *Value, cs Name, ui_render } link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, volatile s8 *Value, cs Name, ui_render_params *Params) +DoEditorUi(renderer_2d *Ui, window_layout *Window, u8 *Value, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Generic, EDITOR_UI_VALUE_RANGE_PROTO_DEFAULTS) { - DoEditorUi(Ui, Window, (s8*) Value, Name, Params); -} + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x290F14E6); -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, u8 *Value, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic, EDITOR_UI_VALUE_RANGE_PROTO_DEFAULTS) -{ Params = Params ? Params : &DefaultUiRenderParams_Blank; if (Name.Count) { PushColumn(Ui, Name, &DefaultUiRenderParams_Column); } @@ -228,9 +201,9 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, u8 *Value, cs Name, ui_render { u32 Start = StartColumn(Ui, &DefaultUiRenderParams_Blank); PushTableStart(Ui); - if (Button(Ui, CSz("-"), UiId(Window, "decrement", Value), &DefaultUiRenderParams_Button)) { *Value = *Value - 1; } + if (Button(Ui, CSz("-"), UiId(Window, "decrement", Value, ThisHash), &DefaultUiRenderParams_Button)) { *Value = *Value - 1; } PushColumn(Ui, CS(*Value), &DefaultUiRenderParams_Generic); - if (Button(Ui, CSz("+"), UiId(Window, "increment", Value), &DefaultUiRenderParams_Button)) { *Value = *Value + 1; } + if (Button(Ui, CSz("+"), UiId(Window, "increment", Value, ThisHash), &DefaultUiRenderParams_Button)) { *Value = *Value + 1; } PushTableEnd(Ui); EndColumn(Ui, Start); } @@ -242,9 +215,5 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, u8 *Value, cs Name, ui_render } -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, volatile u8 *Value, cs Name, ui_render_params *Params) -{ - DoEditorUi(Ui, Window, (u8*) Value, Name, Params); -} + diff --git a/generated/do_editor_ui_for_vector_type_688873645.h b/generated/do_editor_ui_for_vector_type_688873645.h index 9a1ac3e8e..873e50a65 100644 --- a/generated/do_editor_ui_for_vector_type_688873645.h +++ b/generated/do_editor_ui_for_vector_type_688873645.h @@ -1,19 +1,21 @@ -// src/engine/editor.h:493:0 - +// src/engine/editor.h:226:0 link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, v4i *Value, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic, EDITOR_UI_VALUE_RANGE_PROTO_DEFAULTS) +DoEditorUi(renderer_2d *Ui, window_layout *Window, v4i *Value, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Generic, EDITOR_UI_VALUE_RANGE_PROTO_DEFAULTS) { - /* PushTableStart(Ui); */ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x290F60E2); + + /* PushTableStart(Ui); */ if (Name.Count) { PushColumn(Ui, CS(Name), &DefaultUiRenderParams_Blank); } if (Value) { u32 Start = StartColumn(Ui, &DefaultUiRenderParams_Blank); PushTableStart(Ui); - DoEditorUi(Ui, Window, &Value->E[0], {}, Params, EDITOR_UI_VALUE_RANGE_INSTANCE_NAMES ); - DoEditorUi(Ui, Window, &Value->E[1], {}, Params, EDITOR_UI_VALUE_RANGE_INSTANCE_NAMES ); - DoEditorUi(Ui, Window, &Value->E[2], {}, Params, EDITOR_UI_VALUE_RANGE_INSTANCE_NAMES ); - DoEditorUi(Ui, Window, &Value->E[3], {}, Params, EDITOR_UI_VALUE_RANGE_INSTANCE_NAMES ); + DoEditorUi(Ui, Window, &Value->E[0], {}, ThisHash, Params, EDITOR_UI_VALUE_RANGE_INSTANCE_NAMES ); + DoEditorUi(Ui, Window, &Value->E[1], {}, ThisHash, Params, EDITOR_UI_VALUE_RANGE_INSTANCE_NAMES ); + DoEditorUi(Ui, Window, &Value->E[2], {}, ThisHash, Params, EDITOR_UI_VALUE_RANGE_INSTANCE_NAMES ); + DoEditorUi(Ui, Window, &Value->E[3], {}, ThisHash, Params, EDITOR_UI_VALUE_RANGE_INSTANCE_NAMES ); + PushTableEnd(Ui); /* PushNewRow(Ui); */ EndColumn(Ui, Start); @@ -23,19 +25,22 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, v4i *Value, cs Name, ui_rende PushNewRow(Ui); } link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, v4 *Value, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic, EDITOR_UI_VALUE_RANGE_PROTO_DEFAULTS) +DoEditorUi(renderer_2d *Ui, window_layout *Window, v4 *Value, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Generic, EDITOR_UI_VALUE_RANGE_PROTO_DEFAULTS) { - /* PushTableStart(Ui); */ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x290F1413); + + /* PushTableStart(Ui); */ if (Name.Count) { PushColumn(Ui, CS(Name), &DefaultUiRenderParams_Blank); } if (Value) { u32 Start = StartColumn(Ui, &DefaultUiRenderParams_Blank); PushTableStart(Ui); - DoEditorUi(Ui, Window, &Value->E[0], {}, Params, EDITOR_UI_VALUE_RANGE_INSTANCE_NAMES ); - DoEditorUi(Ui, Window, &Value->E[1], {}, Params, EDITOR_UI_VALUE_RANGE_INSTANCE_NAMES ); - DoEditorUi(Ui, Window, &Value->E[2], {}, Params, EDITOR_UI_VALUE_RANGE_INSTANCE_NAMES ); - DoEditorUi(Ui, Window, &Value->E[3], {}, Params, EDITOR_UI_VALUE_RANGE_INSTANCE_NAMES ); + DoEditorUi(Ui, Window, &Value->E[0], {}, ThisHash, Params, EDITOR_UI_VALUE_RANGE_INSTANCE_NAMES ); + DoEditorUi(Ui, Window, &Value->E[1], {}, ThisHash, Params, EDITOR_UI_VALUE_RANGE_INSTANCE_NAMES ); + DoEditorUi(Ui, Window, &Value->E[2], {}, ThisHash, Params, EDITOR_UI_VALUE_RANGE_INSTANCE_NAMES ); + DoEditorUi(Ui, Window, &Value->E[3], {}, ThisHash, Params, EDITOR_UI_VALUE_RANGE_INSTANCE_NAMES ); + PushTableEnd(Ui); /* PushNewRow(Ui); */ EndColumn(Ui, Start); @@ -45,18 +50,21 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, v4 *Value, cs Name, ui_render PushNewRow(Ui); } link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, v3i *Value, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic, EDITOR_UI_VALUE_RANGE_PROTO_DEFAULTS) +DoEditorUi(renderer_2d *Ui, window_layout *Window, v3i *Value, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Generic, EDITOR_UI_VALUE_RANGE_PROTO_DEFAULTS) { - /* PushTableStart(Ui); */ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x290F60AD); + + /* PushTableStart(Ui); */ if (Name.Count) { PushColumn(Ui, CS(Name), &DefaultUiRenderParams_Blank); } if (Value) { u32 Start = StartColumn(Ui, &DefaultUiRenderParams_Blank); PushTableStart(Ui); - DoEditorUi(Ui, Window, &Value->E[0], {}, Params, EDITOR_UI_VALUE_RANGE_INSTANCE_NAMES ); - DoEditorUi(Ui, Window, &Value->E[1], {}, Params, EDITOR_UI_VALUE_RANGE_INSTANCE_NAMES ); - DoEditorUi(Ui, Window, &Value->E[2], {}, Params, EDITOR_UI_VALUE_RANGE_INSTANCE_NAMES ); + DoEditorUi(Ui, Window, &Value->E[0], {}, ThisHash, Params, EDITOR_UI_VALUE_RANGE_INSTANCE_NAMES ); + DoEditorUi(Ui, Window, &Value->E[1], {}, ThisHash, Params, EDITOR_UI_VALUE_RANGE_INSTANCE_NAMES ); + DoEditorUi(Ui, Window, &Value->E[2], {}, ThisHash, Params, EDITOR_UI_VALUE_RANGE_INSTANCE_NAMES ); + PushTableEnd(Ui); /* PushNewRow(Ui); */ EndColumn(Ui, Start); @@ -66,18 +74,21 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, v3i *Value, cs Name, ui_rende PushNewRow(Ui); } link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, v3 *Value, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic, EDITOR_UI_VALUE_RANGE_PROTO_DEFAULTS) +DoEditorUi(renderer_2d *Ui, window_layout *Window, v3 *Value, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Generic, EDITOR_UI_VALUE_RANGE_PROTO_DEFAULTS) { - /* PushTableStart(Ui); */ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x290F13DE); + + /* PushTableStart(Ui); */ if (Name.Count) { PushColumn(Ui, CS(Name), &DefaultUiRenderParams_Blank); } if (Value) { u32 Start = StartColumn(Ui, &DefaultUiRenderParams_Blank); PushTableStart(Ui); - DoEditorUi(Ui, Window, &Value->E[0], {}, Params, EDITOR_UI_VALUE_RANGE_INSTANCE_NAMES ); - DoEditorUi(Ui, Window, &Value->E[1], {}, Params, EDITOR_UI_VALUE_RANGE_INSTANCE_NAMES ); - DoEditorUi(Ui, Window, &Value->E[2], {}, Params, EDITOR_UI_VALUE_RANGE_INSTANCE_NAMES ); + DoEditorUi(Ui, Window, &Value->E[0], {}, ThisHash, Params, EDITOR_UI_VALUE_RANGE_INSTANCE_NAMES ); + DoEditorUi(Ui, Window, &Value->E[1], {}, ThisHash, Params, EDITOR_UI_VALUE_RANGE_INSTANCE_NAMES ); + DoEditorUi(Ui, Window, &Value->E[2], {}, ThisHash, Params, EDITOR_UI_VALUE_RANGE_INSTANCE_NAMES ); + PushTableEnd(Ui); /* PushNewRow(Ui); */ EndColumn(Ui, Start); @@ -87,17 +98,20 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, v3 *Value, cs Name, ui_render PushNewRow(Ui); } link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, v2i *Value, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic, EDITOR_UI_VALUE_RANGE_PROTO_DEFAULTS) +DoEditorUi(renderer_2d *Ui, window_layout *Window, v2i *Value, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Generic, EDITOR_UI_VALUE_RANGE_PROTO_DEFAULTS) { - /* PushTableStart(Ui); */ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x290F6078); + + /* PushTableStart(Ui); */ if (Name.Count) { PushColumn(Ui, CS(Name), &DefaultUiRenderParams_Blank); } if (Value) { u32 Start = StartColumn(Ui, &DefaultUiRenderParams_Blank); PushTableStart(Ui); - DoEditorUi(Ui, Window, &Value->E[0], {}, Params, EDITOR_UI_VALUE_RANGE_INSTANCE_NAMES ); - DoEditorUi(Ui, Window, &Value->E[1], {}, Params, EDITOR_UI_VALUE_RANGE_INSTANCE_NAMES ); + DoEditorUi(Ui, Window, &Value->E[0], {}, ThisHash, Params, EDITOR_UI_VALUE_RANGE_INSTANCE_NAMES ); + DoEditorUi(Ui, Window, &Value->E[1], {}, ThisHash, Params, EDITOR_UI_VALUE_RANGE_INSTANCE_NAMES ); + PushTableEnd(Ui); /* PushNewRow(Ui); */ EndColumn(Ui, Start); @@ -107,17 +121,20 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, v2i *Value, cs Name, ui_rende PushNewRow(Ui); } link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, v2 *Value, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic, EDITOR_UI_VALUE_RANGE_PROTO_DEFAULTS) +DoEditorUi(renderer_2d *Ui, window_layout *Window, v2 *Value, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Generic, EDITOR_UI_VALUE_RANGE_PROTO_DEFAULTS) { - /* PushTableStart(Ui); */ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x290F13A9); + + /* PushTableStart(Ui); */ if (Name.Count) { PushColumn(Ui, CS(Name), &DefaultUiRenderParams_Blank); } if (Value) { u32 Start = StartColumn(Ui, &DefaultUiRenderParams_Blank); PushTableStart(Ui); - DoEditorUi(Ui, Window, &Value->E[0], {}, Params, EDITOR_UI_VALUE_RANGE_INSTANCE_NAMES ); - DoEditorUi(Ui, Window, &Value->E[1], {}, Params, EDITOR_UI_VALUE_RANGE_INSTANCE_NAMES ); + DoEditorUi(Ui, Window, &Value->E[0], {}, ThisHash, Params, EDITOR_UI_VALUE_RANGE_INSTANCE_NAMES ); + DoEditorUi(Ui, Window, &Value->E[1], {}, ThisHash, Params, EDITOR_UI_VALUE_RANGE_INSTANCE_NAMES ); + PushTableEnd(Ui); /* PushNewRow(Ui); */ EndColumn(Ui, Start); @@ -127,19 +144,22 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, v2 *Value, cs Name, ui_render PushNewRow(Ui); } link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, Quaternion *Value, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic, EDITOR_UI_VALUE_RANGE_PROTO_DEFAULTS) +DoEditorUi(renderer_2d *Ui, window_layout *Window, Quaternion *Value, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Generic, EDITOR_UI_VALUE_RANGE_PROTO_DEFAULTS) { - /* PushTableStart(Ui); */ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x42A58E4); + + /* PushTableStart(Ui); */ if (Name.Count) { PushColumn(Ui, CS(Name), &DefaultUiRenderParams_Blank); } if (Value) { u32 Start = StartColumn(Ui, &DefaultUiRenderParams_Blank); PushTableStart(Ui); - DoEditorUi(Ui, Window, &Value->E[0], {}, Params, EDITOR_UI_VALUE_RANGE_INSTANCE_NAMES ); - DoEditorUi(Ui, Window, &Value->E[1], {}, Params, EDITOR_UI_VALUE_RANGE_INSTANCE_NAMES ); - DoEditorUi(Ui, Window, &Value->E[2], {}, Params, EDITOR_UI_VALUE_RANGE_INSTANCE_NAMES ); - DoEditorUi(Ui, Window, &Value->E[3], {}, Params, EDITOR_UI_VALUE_RANGE_INSTANCE_NAMES ); + DoEditorUi(Ui, Window, &Value->E[0], {}, ThisHash, Params, EDITOR_UI_VALUE_RANGE_INSTANCE_NAMES ); + DoEditorUi(Ui, Window, &Value->E[1], {}, ThisHash, Params, EDITOR_UI_VALUE_RANGE_INSTANCE_NAMES ); + DoEditorUi(Ui, Window, &Value->E[2], {}, ThisHash, Params, EDITOR_UI_VALUE_RANGE_INSTANCE_NAMES ); + DoEditorUi(Ui, Window, &Value->E[3], {}, ThisHash, Params, EDITOR_UI_VALUE_RANGE_INSTANCE_NAMES ); + PushTableEnd(Ui); /* PushNewRow(Ui); */ EndColumn(Ui, Start); @@ -149,19 +169,22 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, Quaternion *Value, cs Name, u PushNewRow(Ui); } link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, m4 *Value, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic, EDITOR_UI_VALUE_RANGE_PROTO_DEFAULTS) +DoEditorUi(renderer_2d *Ui, window_layout *Window, m4 *Value, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Generic, EDITOR_UI_VALUE_RANGE_PROTO_DEFAULTS) { - /* PushTableStart(Ui); */ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x290F140A); + + /* PushTableStart(Ui); */ if (Name.Count) { PushColumn(Ui, CS(Name), &DefaultUiRenderParams_Blank); } if (Value) { u32 Start = StartColumn(Ui, &DefaultUiRenderParams_Blank); PushTableStart(Ui); - DoEditorUi(Ui, Window, &Value->E[0], {}, Params, EDITOR_UI_VALUE_RANGE_INSTANCE_NAMES ); - DoEditorUi(Ui, Window, &Value->E[1], {}, Params, EDITOR_UI_VALUE_RANGE_INSTANCE_NAMES ); - DoEditorUi(Ui, Window, &Value->E[2], {}, Params, EDITOR_UI_VALUE_RANGE_INSTANCE_NAMES ); - DoEditorUi(Ui, Window, &Value->E[3], {}, Params, EDITOR_UI_VALUE_RANGE_INSTANCE_NAMES ); + DoEditorUi(Ui, Window, &Value->E[0], {}, ThisHash, Params, EDITOR_UI_VALUE_RANGE_INSTANCE_NAMES ); + DoEditorUi(Ui, Window, &Value->E[1], {}, ThisHash, Params, EDITOR_UI_VALUE_RANGE_INSTANCE_NAMES ); + DoEditorUi(Ui, Window, &Value->E[2], {}, ThisHash, Params, EDITOR_UI_VALUE_RANGE_INSTANCE_NAMES ); + DoEditorUi(Ui, Window, &Value->E[3], {}, ThisHash, Params, EDITOR_UI_VALUE_RANGE_INSTANCE_NAMES ); + PushTableEnd(Ui); /* PushNewRow(Ui); */ EndColumn(Ui, Start); @@ -171,3 +194,4 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, m4 *Value, cs Name, ui_render PushNewRow(Ui); } + diff --git a/generated/flatten_block_array_file_traversal_node.h b/generated/flatten_block_array_file_traversal_node.h index 933b131e0..777ff6fab 100644 --- a/generated/flatten_block_array_file_traversal_node.h +++ b/generated/flatten_block_array_file_traversal_node.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/file.cpp:9:0 - +// external/bonsai_stdlib/src/poof_functions.h:2578:0 link_internal file_traversal_node_buffer Flatten(file_traversal_node_block_array *Array, memory_arena *Memory) { diff --git a/generated/flood_fill_iteration_pattern_199741702_161749140_632272777.h b/generated/flood_fill_iteration_pattern_199741702_161749140_632272777.h index 7ff156aa7..901cf0c62 100644 --- a/generated/flood_fill_iteration_pattern_199741702_161749140_632272777.h +++ b/generated/flood_fill_iteration_pattern_199741702_161749140_632272777.h @@ -1,111 +1,97 @@ -// src/engine/world_update.cpp:620:0 - +// src/engine/world_update.cpp:208:0 random_series ColorEntropy = {4654376543246}; +NotImplemented; + 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; - - - if (LengthSq(CenterToVoxP) < RadiusSquared && (V->Flags&Voxel_Filled) == 0) - - { - 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)); - } - } - - - if ( Length(CenterToVoxP) < SquareRoot(RadiusSquared)-1.f && (V->Flags&Voxel_Filled) ) - { V->Flags = Voxel_Empty; } - - - 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; - - - v3i CenterToVoxP = SimVoxP - EditCenterP; - if (Length(CenterToVoxP) < SquareRoot(RadiusSquared)-1.f) - { - if (V->Flags & Voxel_Filled) - { - V->Color = MagicaVoxelDefaultPaletteToPackedHSV(SafeTruncateU8(RandomBetween((u32)MCV_GREY_5, &ColorEntropy, (u32)MCV_GREY_8+1))); - } - - } - else if (LengthSq(CenterToVoxP) < RadiusSquared) - { - V->Color = MagicaVoxelDefaultPaletteToPackedHSV(MCV_GREY_8); - } - - - 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; - } - } -} +/* // 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) */ +/* { */ +/* NotImplemented; */ +/* /1* if ( (V->Flags & Voxel_MarkBit) == 0) *1/ */ +/* { */ +/* 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) */ + +/* NotImplemented; */ +/* /1* V->Flags |= Voxel_MarkBit; *1/ */ + +/* if ( ((OverwriteVoxel == True) && (Invert == False)) || */ +/* ((OverwriteVoxel == False) && (Invert == True)) ) */ +/* { */ +/* /1* if (Mode == WorldEdit_Mode_Paint) *1/ */ +/* /1* { *1/ */ +/* /1* V->Color = NewVoxelValue->Color; *1/ */ +/* /1* } *1/ */ +/* /1* else *1/ */ +/* { */ +/* *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) */ + +/* NotImplemented; */ +/* /1* if ( (V->Flags&Voxel_MarkBit)) *1/ */ +/* { */ +/* 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)); */ +/* } */ + +/* NotImplemented; */ +/* /1* V->Flags &= ~Voxel_MarkBit; *1/ */ +/* } */ +/* } */ +/* } */ diff --git a/generated/flood_fill_iteration_pattern_275071431_101859599_0.h b/generated/flood_fill_iteration_pattern_275071431_101859599_0.h deleted file mode 100644 index c4650a042..000000000 --- a/generated/flood_fill_iteration_pattern_275071431_101859599_0.h +++ /dev/null @@ -1,98 +0,0 @@ -// src/engine/world_update.cpp:860:0 - -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; - - - v3i OriginToCurrentVoxP = SimVoxP - SimOrigin; - voxel *NewVoxelValue = TryGetVoxel(Data, OriginToCurrentVoxP); - if (Contains(SSRect, SimVoxP) && (V->Flags&Voxel_Filled) == 0) - - { - 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)); - } - } - - - if (NewVoxelValue && (NewVoxelValue->Flags&Voxel_Filled)) { *V = {}; } - - - 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; - - - - 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; - } - } -} - diff --git a/generated/flood_fill_iteration_pattern_275071431_785723886_0.h b/generated/flood_fill_iteration_pattern_275071431_785723886_0.h deleted file mode 100644 index 6d60505be..000000000 --- a/generated/flood_fill_iteration_pattern_275071431_785723886_0.h +++ /dev/null @@ -1,98 +0,0 @@ -// src/engine/world_update.cpp:844:0 - -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; - - - v3i OriginToCurrentVoxP = SimVoxP - SimOrigin; - voxel *NewVoxelValue = TryGetVoxel(Data, OriginToCurrentVoxP); - if ((V->Flags&Voxel_Filled)) - - { - 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)); - } - } - - - if ( ((V->Flags&Voxel_Filled) == 0) && NewVoxelValue && (NewVoxelValue->Flags&Voxel_Filled)) { *V = *NewVoxelValue; } - - - 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; - - - - 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; - } - } -} - diff --git a/generated/flood_fill_iteration_pattern_846291950_267608728_0.h b/generated/flood_fill_iteration_pattern_846291950_267608728_0.h deleted file mode 100644 index 2de880a70..000000000 --- a/generated/flood_fill_iteration_pattern_846291950_267608728_0.h +++ /dev/null @@ -1,99 +0,0 @@ -// src/engine/world_update.cpp:724:0 - -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; - - if ( (V->Flags&Voxel_Filled) == (Voxel_Filled*(Mode==WorldEdit_Mode_Attach)) ) - { - 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)); - } - } - - - if ( Mode == WorldEdit_Mode_Attach && (V->Flags&Voxel_Filled) ) - { } - else - { - OverwriteVoxel = True; - } - - - 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; - - - - 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; - } - } -} - diff --git a/generated/for_datatypes_0XxWqGSZ.h b/generated/for_datatypes_0XxWqGSZ.h index 8de192134..25d44ed33 100644 --- a/generated/for_datatypes_0XxWqGSZ.h +++ b/generated/for_datatypes_0XxWqGSZ.h @@ -1,4 +1,4 @@ -// src/engine/work_queue.h:336:0 +// src/engine/work_queue.h:250:0 @@ -146,54 +146,14 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -struct render_to_texture_async_params; +struct finalize_shit_and_fuckin_do_stuff_async_params; link_internal work_queue_entry -WorkQueueEntryAsyncFunction( render_to_texture_async_params *Params ) +WorkQueueEntryAsyncFunction( finalize_shit_and_fuckin_do_stuff_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_async_params; - Result.work_queue_entry_async_function_call.render_to_texture_async_params = *Params; + Result.work_queue_entry_async_function_call.Type = type_finalize_shit_and_fuckin_do_stuff_async_params; + Result.work_queue_entry_async_function_call.finalize_shit_and_fuckin_do_stuff_async_params = *Params; return Result; } @@ -224,6 +184,16 @@ WorkQueueEntryAsyncFunction( render_to_texture_async_params *Params ) +struct initialize_easing_function_visualizer_render_pass_async_params; +link_internal work_queue_entry +WorkQueueEntryAsyncFunction( initialize_easing_function_visualizer_render_pass_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_initialize_easing_function_visualizer_render_pass_async_params; + Result.work_queue_entry_async_function_call.initialize_easing_function_visualizer_render_pass_async_params = *Params; + return Result; +} @@ -561,6 +531,16 @@ WorkQueueEntryAsyncFunction( render_to_texture_async_params *Params ) +struct compile_shader_pair_async_params; +link_internal work_queue_entry +WorkQueueEntryAsyncFunction( compile_shader_pair_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_compile_shader_pair_async_params; + Result.work_queue_entry_async_function_call.compile_shader_pair_async_params = *Params; + return Result; +} @@ -615,40 +595,6 @@ WorkQueueEntryAsyncFunction( render_to_texture_async_params *Params ) - - - - - - - - - - - - - - - - - - - - - -struct draw_lod_async_params; -link_internal work_queue_entry -WorkQueueEntryAsyncFunction( draw_lod_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_draw_lod_async_params; - Result.work_queue_entry_async_function_call.draw_lod_async_params = *Params; - return Result; -} - - - diff --git a/generated/for_datatypes_Bxw4Q7AW.h b/generated/for_datatypes_Bxw4Q7AW.h new file mode 100644 index 000000000..330a538aa --- /dev/null +++ b/generated/for_datatypes_Bxw4Q7AW.h @@ -0,0 +1,19394 @@ +// src/engine/editor.cpp:488:0 + + + + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, easing_function *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x35BB500A); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle easing_function", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("Name"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(cs*, &Element->Name), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("Points"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v2_static_cursor_16*, &Element->Points), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, lighting_render_group *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x1933080D); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle lighting_render_group", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("Program"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(shader*, &Element->Program), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Uniforms"); + + + if (ToggleButton(Ui, + CSz("v Uniforms[26]"), + CSz("> Uniforms[26]"), + UiId(Window, "toggle lighting_render_group shader_uniform Uniforms", Element->Uniforms, ThisHash), + Params )) + { + OPEN_INDENT_FOR_TOGGLEABLE_REGION(); + PushNewRow(Ui); + s32 End = 26; + + RangeIterator(ArrayIndex, End) + { + DoEditorUi(Ui, + Window, + Element->Uniforms+ArrayIndex, + FSz("Uniforms[%d]", ArrayIndex), + ThisHash, + Params); + + + } + CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); + } + PushNewRow(Ui); + + + + + + + } + + + { + + + + cs MemberName = CSz("FBO"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(framebuffer*, &Element->FBO), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("gColor"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(texture*, Element->gColor), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("gNormal"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(texture*, Element->gNormal), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("gDepth"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(texture*, Element->gDepth), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("shadowMap"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(texture*, Element->shadowMap), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Ssao"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(texture*, Element->Ssao), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("TransparencyAccumTex"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(texture*, Element->TransparencyAccumTex), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("TransparencyCountTex"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(texture*, Element->TransparencyCountTex), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("BravoilMyersOIT"); + DoEditorUi(Ui, + Window, + Cast(b8*, Element->BravoilMyersOIT), + MemberName, + ThisHash, + &DefaultUiRenderParams_Checkbox + ); + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("BravoilMcGuireOIT"); + DoEditorUi(Ui, + Window, + Cast(b8*, Element->BravoilMcGuireOIT), + MemberName, + ThisHash, + &DefaultUiRenderParams_Checkbox + ); + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("InverseViewMatrix"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(m4*, Element->InverseViewMatrix), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("InverseProjectionMatrix"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(m4*, Element->InverseProjectionMatrix), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("ShadowMVP"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(m4*, Element->ShadowMVP), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("LightColors"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(texture*, Element->LightColors), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("LightPositions"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(texture*, Element->LightPositions), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("LightIndexToUV"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(f32*, Element->LightIndexToUV), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("LightCount"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(s32*, Element->LightCount), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("Camera"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(camera*, Element->Camera), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("SunPosition"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v3*, Element->SunPosition), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("SunColor"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v3*, Element->SunColor), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("FogColor"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v3*, Element->FogColor), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("FogPower"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(f32*, Element->FogPower), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("UseSsao"); + DoEditorUi(Ui, + Window, + Cast(b8*, Element->UseSsao), + MemberName, + ThisHash, + &DefaultUiRenderParams_Checkbox + ); + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("UseShadowMapping"); + DoEditorUi(Ui, + Window, + Cast(b8*, Element->UseShadowMapping), + MemberName, + ThisHash, + &DefaultUiRenderParams_Checkbox + ); + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("UseLightingBloom"); + DoEditorUi(Ui, + Window, + Cast(b8*, Element->UseLightingBloom), + MemberName, + ThisHash, + &DefaultUiRenderParams_Checkbox + ); + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("ApplicationResolution"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v2*, Element->ApplicationResolution), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("ShadowMapResolution"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v2*, Element->ShadowMapResolution), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("LuminanceTex"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(texture*, &Element->LuminanceTex), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Lights"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(game_lights*, &Element->Lights), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, render_debug *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x1E3B3011); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle render_debug", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("BytesSolidGeoLastFrame"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u32*, &Element->BytesSolidGeoLastFrame), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("BytesTransGeoLastFrame"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u32*, &Element->BytesTransGeoLastFrame), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("VertsDrawnLastFrame"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u32*, &Element->VertsDrawnLastFrame), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("DrawCallsLastFrame"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u32*, &Element->DrawCallsLastFrame), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + + + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, ui_toggle *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x34E9B82B); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle ui_toggle", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("Id"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(ui_id*, &Element->Id), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("ToggledOn"); + DoEditorUi(Ui, + Window, + Cast(b8*, &Element->ToggledOn), + MemberName, + ThisHash, + &DefaultUiRenderParams_Checkbox + ); + + + + + + PushNewRow(Ui); + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, bonsai_futex *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x1CACA02D); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle bonsai_futex", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("SignalValue"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u32*, &Element->SignalValue), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("ThreadsWaiting"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u32*, &Element->ThreadsWaiting), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, engine_settings *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x11FDB034); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle engine_settings", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("Graphics"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(graphics_settings*, &Element->Graphics), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + + + + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, texture *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x1414405E); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle texture", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("ID"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u32*, &Element->ID), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("Dim"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v2i*, &Element->Dim), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Slices"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u32*, &Element->Slices), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("Channels"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u32*, &Element->Channels), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("IsDepthTexture"); + DoEditorUi(Ui, + Window, + Cast(b8*, &Element->IsDepthTexture), + MemberName, + ThisHash, + &DefaultUiRenderParams_Checkbox + ); + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("Format"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(texture_storage_format*, &Element->Format), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("DebugName"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(cs*, &Element->DebugName), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("Queued"); + DoEditorUi(Ui, + Window, + Cast(b8*, &Element->Queued), + MemberName, + ThisHash, + &DefaultUiRenderParams_Checkbox + ); + + + + + + PushNewRow(Ui); + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, asset_thumbnail *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x26039060); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle asset_thumbnail", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("Texture"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(texture*, &Element->Texture), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Camera"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(camera*, &Element->Camera), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, world_update_op_shape_params_cylinder *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x21B74063); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle world_update_op_shape_params_cylinder", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("Radius"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(r32*, &Element->Radius), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("Height"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(r32*, &Element->Height), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + + + + + + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, vertex_material *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x25F8008E); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle vertex_material", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("ColorIndex"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u16*, &Element->ColorIndex), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("Transparency"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u8*, &Element->Transparency), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("Emission"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u8*, &Element->Emission), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, white_noise_params *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x1F5D090); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle white_noise_params", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, world_update_op_shape_params_rect *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x1D0F48B7); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle world_update_op_shape_params_rect", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("Dim"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v3*, &Element->Dim), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, platform *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x2477D8B8); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle platform", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("LowPriority"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(work_queue*, &Element->LowPriority), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("HighPriority"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(work_queue*, &Element->HighPriority), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("LoRenderQ"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(work_queue*, &Element->LoRenderQ), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("HiRenderQ"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(work_queue*, &Element->HiRenderQ), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("HighPriorityWorkerCount"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u32*, &Element->HighPriorityWorkerCount), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("HighPriorityModeFutex"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(bonsai_futex*, &Element->HighPriorityModeFutex), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("WorkerThreadsSuspendFutex"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(bonsai_futex*, &Element->WorkerThreadsSuspendFutex), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("WorkerThreadsExitFutex"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(bonsai_futex*, &Element->WorkerThreadsExitFutex), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("MouseP"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v2*, &Element->MouseP), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("MouseDP"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v2*, &Element->MouseDP), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Memory"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(memory_arena*, Element->Memory), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("GameTime"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(r32*, &Element->GameTime), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("dt"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(r32*, &Element->dt), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("ScreenDim"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v2*, &Element->ScreenDim), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Input"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input*, &Element->Input), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("ServerState"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(server_state*, Element->ServerState), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, hotkeys *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x1A16B0BB); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle hotkeys", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("Debug_ToggleMenu"); + DoEditorUi(Ui, + Window, + Cast(b8*, &Element->Debug_ToggleMenu), + MemberName, + ThisHash, + &DefaultUiRenderParams_Checkbox + ); + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("Debug_ToggleProfiling"); + DoEditorUi(Ui, + Window, + Cast(b8*, &Element->Debug_ToggleProfiling), + MemberName, + ThisHash, + &DefaultUiRenderParams_Checkbox + ); + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("Debug_TriangulateIncrement"); + DoEditorUi(Ui, + Window, + Cast(b8*, &Element->Debug_TriangulateIncrement), + MemberName, + ThisHash, + &DefaultUiRenderParams_Checkbox + ); + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("Debug_TriangulateDecrement"); + DoEditorUi(Ui, + Window, + Cast(b8*, &Element->Debug_TriangulateDecrement), + MemberName, + ThisHash, + &DefaultUiRenderParams_Checkbox + ); + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("Left"); + DoEditorUi(Ui, + Window, + Cast(b8*, &Element->Left), + MemberName, + ThisHash, + &DefaultUiRenderParams_Checkbox + ); + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("Right"); + DoEditorUi(Ui, + Window, + Cast(b8*, &Element->Right), + MemberName, + ThisHash, + &DefaultUiRenderParams_Checkbox + ); + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("Forward"); + DoEditorUi(Ui, + Window, + Cast(b8*, &Element->Forward), + MemberName, + ThisHash, + &DefaultUiRenderParams_Checkbox + ); + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("Backward"); + DoEditorUi(Ui, + Window, + Cast(b8*, &Element->Backward), + MemberName, + ThisHash, + &DefaultUiRenderParams_Checkbox + ); + + + + + + PushNewRow(Ui); + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, shadow_render_group *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x4F8F8BF); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle shadow_render_group", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("FramebufferName"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u32*, &Element->FramebufferName), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("ShadowMap"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(texture*, &Element->ShadowMap), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Shader"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(shadow_map_shader*, &Element->Shader), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + + + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, particle_system *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x137DC8CC); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle particle_system", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("Entropy"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(random_series*, &Element->Entropy), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("SpawnType"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(particle_spawn_type*, &Element->SpawnType), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Drag"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(r32*, &Element->Drag), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("Lifetime"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(r32*, &Element->Lifetime), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("EmissionDelay"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(r32*, &Element->EmissionDelay), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("EmissionLifespan"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(r32*, &Element->EmissionLifespan), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("ActiveParticles"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u32*, &Element->ActiveParticles), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("LifespanMod"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(r32*, &Element->LifespanMod), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("ParticleLifespan"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(r32*, &Element->ParticleLifespan), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("ParticlesPerSecond"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(r32*, &Element->ParticlesPerSecond), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("ParticleLightEmission"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(r32*, &Element->ParticleLightEmission), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("ParticleLightEmissionChance"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(r32*, &Element->ParticleLightEmissionChance), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("ParticleStartingTransparency"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(r32*, &Element->ParticleStartingTransparency), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("ParticleEndingTransparency"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(r32*, &Element->ParticleEndingTransparency), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("ParticleStartingDim"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v3*, &Element->ParticleStartingDim), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("ParticleEndingDim"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(f32*, &Element->ParticleEndingDim), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("ParticleTurbMin"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v3*, &Element->ParticleTurbMin), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("ParticleTurbMax"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v3*, &Element->ParticleTurbMax), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("SpawnRegion"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(aabb*, &Element->SpawnRegion), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("SystemMovementCoefficient"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(r32*, &Element->SystemMovementCoefficient), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("ElapsedSinceLastEmission"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(r32*, &Element->ElapsedSinceLastEmission), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("PackedHSVColors"); + + + if (ToggleButton(Ui, + CSz("v PackedHSVColors[6]"), + CSz("> PackedHSVColors[6]"), + UiId(Window, "toggle particle_system u16 PackedHSVColors", Element->PackedHSVColors, ThisHash), + Params )) + { + OPEN_INDENT_FOR_TOGGLEABLE_REGION(); + PushNewRow(Ui); + s32 End = 6; + + RangeIterator(ArrayIndex, End) + { + DoEditorUi(Ui, + Window, + Element->PackedHSVColors+ArrayIndex, + FSz("PackedHSVColors[%d]", ArrayIndex), + ThisHash, + Params); + + PushNewRow(Ui); + } + CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); + } + PushNewRow(Ui); + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("Particles"); + + + if (ToggleButton(Ui, + CSz("v Particles[(4096)]"), + CSz("> Particles[(4096)]"), + UiId(Window, "toggle particle_system particle Particles", Element->Particles, ThisHash), + Params )) + { + OPEN_INDENT_FOR_TOGGLEABLE_REGION(); + PushNewRow(Ui); + s32 End = (4096); + + RangeIterator(ArrayIndex, End) + { + DoEditorUi(Ui, + Window, + Element->Particles+ArrayIndex, + FSz("Particles[%d]", ArrayIndex), + ThisHash, + Params); + + + } + CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); + } + PushNewRow(Ui); + + + + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + + + + + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, voronoi_noise_params *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x38DB8E3); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle voronoi_noise_params", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("Period"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v3*, &Element->Period), + MemberName, + ThisHash, + Params + , 0.1f, 20.f ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Squareness"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(r32*, &Element->Squareness), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("MaskChance"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(r32*, &Element->MaskChance), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + + + + + + + + + + + + + + + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, terrain_decoration_render_context *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x231A7121); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle terrain_decoration_render_context", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("Program"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(shader*, &Element->Program), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Uniforms"); + + + if (ToggleButton(Ui, + CSz("v Uniforms[4]"), + CSz("> Uniforms[4]"), + UiId(Window, "toggle terrain_decoration_render_context shader_uniform Uniforms", Element->Uniforms, ThisHash), + Params )) + { + OPEN_INDENT_FOR_TOGGLEABLE_REGION(); + PushNewRow(Ui); + s32 End = 4; + + RangeIterator(ArrayIndex, End) + { + DoEditorUi(Ui, + Window, + Element->Uniforms+ArrayIndex, + FSz("Uniforms[%d]", ArrayIndex), + ThisHash, + Params); + + + } + CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); + } + PushNewRow(Ui); + + + + + + + } + + + { + + + + cs MemberName = CSz("DestTex"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(texture*, Element->DestTex), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("DestFBO"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(framebuffer*, Element->DestFBO), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("DerivsTex"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(texture*, Element->DerivsTex), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("ChunkDim"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v3*, &Element->ChunkDim), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("WorldspaceChunkBasis"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v3*, &Element->WorldspaceChunkBasis), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("ChunkResolution"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v3*, &Element->ChunkResolution), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + + + + + + + + + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, terrain_finalize_render_context *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x1AC2947); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle terrain_finalize_render_context", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("Program"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(shader*, &Element->Program), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Uniforms"); + + + if (ToggleButton(Ui, + CSz("v Uniforms[1]"), + CSz("> Uniforms[1]"), + UiId(Window, "toggle terrain_finalize_render_context shader_uniform Uniforms", Element->Uniforms, ThisHash), + Params )) + { + OPEN_INDENT_FOR_TOGGLEABLE_REGION(); + PushNewRow(Ui); + s32 End = 1; + + RangeIterator(ArrayIndex, End) + { + DoEditorUi(Ui, + Window, + Element->Uniforms+ArrayIndex, + FSz("Uniforms[%d]", ArrayIndex), + ThisHash, + Params); + + + } + CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); + } + PushNewRow(Ui); + + + + + + + } + + + { + + + + cs MemberName = CSz("DestTex"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(texture*, &Element->DestTex), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("FBO"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(framebuffer*, &Element->FBO), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Ignored"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u32*, &Element->Ignored), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, ui_id *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x2A0FB15D); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle ui_id", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("_Reserved"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u32*, &Element->_Reserved), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("WindowBits"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u32*, &Element->WindowBits), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("InteractionBits"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u32*, &Element->InteractionBits), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("ElementBits"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u32*, &Element->ElementBits), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + + + + + + + + + + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, camera *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x17AFA196); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle camera", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("Frust"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(frustum*, &Element->Frust), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("CurrentP"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(cp*, &Element->CurrentP), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("RenderSpacePosition"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v3*, &Element->RenderSpacePosition), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Pitch"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(r32*, &Element->Pitch), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("Roll"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(r32*, &Element->Roll), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("Yaw"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(r32*, &Element->Yaw), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("DistanceFromTarget"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(r32*, &Element->DistanceFromTarget), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("TargetPitch"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(r32*, &Element->TargetPitch), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("TargetRoll"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(r32*, &Element->TargetRoll), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("TargetYaw"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(r32*, &Element->TargetYaw), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("TargetDistanceFromTarget"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(r32*, &Element->TargetDistanceFromTarget), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("Blend"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(r32*, &Element->Blend), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("Speed"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(r32*, &Element->Speed), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("Front"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v3*, &Element->Front), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Right"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v3*, &Element->Right), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Up"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v3*, &Element->Up), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("GhostId"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(entity_id*, &Element->GhostId), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("ViewProjection"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(m4*, &Element->ViewProjection), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("InverseViewMatrix"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(m4*, &Element->InverseViewMatrix), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("InverseProjectionMatrix"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(m4*, &Element->InverseProjectionMatrix), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + + + + + + + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, renderer_2d *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x1D97D1BB); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle renderer_2d", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("TextGroup"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(render_buffers_2d*, Element->TextGroup), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("SolidQuadGeometryBuffer"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(triple_buffered_gpu_mapped_ui_buffer*, &Element->SolidQuadGeometryBuffer), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("TexturedQuadRenderPass"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(textured_quad_render_pass*, &Element->TexturedQuadRenderPass), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("CustomQuadGeometryBuffer"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(triple_buffered_gpu_mapped_ui_buffer*, &Element->CustomQuadGeometryBuffer), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("SpriteTextureArray"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(texture*, &Element->SpriteTextureArray), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("MouseP"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v2*, Element->MouseP), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("MouseDP"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v2*, Element->MouseDP), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("ScreenDim"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v2*, Element->ScreenDim), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Input"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input*, Element->Input), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("ToggleTable"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(ui_toggle_hashtable*, &Element->ToggleTable), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("WindowTable"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(window_layout_hashtable*, &Element->WindowTable), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("MinimizedWindowBuffer"); + + + if (ToggleButton(Ui, + CSz("v MinimizedWindowBuffer[64]"), + CSz("> MinimizedWindowBuffer[64]"), + UiId(Window, "toggle renderer_2d window_layout MinimizedWindowBuffer", Element->MinimizedWindowBuffer, ThisHash), + Params )) + { + OPEN_INDENT_FOR_TOGGLEABLE_REGION(); + PushNewRow(Ui); + s32 End = 64; + + RangeIterator(ArrayIndex, End) + { + DoEditorUi(Ui, + Window, + Element->MinimizedWindowBuffer+ArrayIndex, + FSz("MinimizedWindowBuffer[%d]", ArrayIndex), + ThisHash, + Params); + + + } + CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); + } + PushNewRow(Ui); + + + + + + + } + + + { + + + + cs MemberName = CSz("HighestWindow"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(window_layout*, Element->HighestWindow), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Hover"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(interactable*, &Element->Hover), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Clicked"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(interactable*, &Element->Clicked), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Pressed"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(interactable*, &Element->Pressed), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("RequestedForceCapture"); + DoEditorUi(Ui, + Window, + Cast(b8*, &Element->RequestedForceCapture), + MemberName, + ThisHash, + &DefaultUiRenderParams_Checkbox + ); + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("TextEdit"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(text_box_edit_state*, &Element->TextEdit), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("CommandBuffer"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(ui_render_command_buffer*, Element->CommandBuffer), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("RenderCommandArena"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(memory_arena*, &Element->RenderCommandArena), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("UiToggleArena"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(memory_arena*, &Element->UiToggleArena), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("WindowTableArena"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(memory_arena*, &Element->WindowTableArena), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("DebugColors"); + + + if (ToggleButton(Ui, + CSz("v DebugColors[128]"), + CSz("> DebugColors[128]"), + UiId(Window, "toggle renderer_2d v3 DebugColors", Element->DebugColors, ThisHash), + Params )) + { + OPEN_INDENT_FOR_TOGGLEABLE_REGION(); + PushNewRow(Ui); + s32 End = 128; + + RangeIterator(ArrayIndex, End) + { + DoEditorUi(Ui, + Window, + Element->DebugColors+ArrayIndex, + FSz("DebugColors[%d]", ArrayIndex), + ThisHash, + Params); + + + } + CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); + } + PushNewRow(Ui); + + + + + + + } + + + { + + + + cs MemberName = CSz("ColorPalette"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v3_cursor*, Element->ColorPalette), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + + + + + + + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, frustum *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x358AF1CD); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle frustum", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("farClip"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(f32*, &Element->farClip), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("nearClip"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(f32*, &Element->nearClip), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("FOV"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(f32*, &Element->FOV), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("Top"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(plane*, &Element->Top), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Bottom"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(plane*, &Element->Bottom), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Left"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(plane*, &Element->Left), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Right"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(plane*, &Element->Right), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, plane *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x2A9389DB); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle plane", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("Normal"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v3*, &Element->Normal), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("DistanceToOrigin"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(f32*, &Element->DistanceToOrigin), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + + + + + + + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, world_edit_render_context *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x21E7B9F7); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle world_edit_render_context", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("Program"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(shader*, &Element->Program), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Uniforms"); + + + if (ToggleButton(Ui, + CSz("v Uniforms[4]"), + CSz("> Uniforms[4]"), + UiId(Window, "toggle world_edit_render_context shader_uniform Uniforms", Element->Uniforms, ThisHash), + Params )) + { + OPEN_INDENT_FOR_TOGGLEABLE_REGION(); + PushNewRow(Ui); + s32 End = 4; + + RangeIterator(ArrayIndex, End) + { + DoEditorUi(Ui, + Window, + Element->Uniforms+ArrayIndex, + FSz("Uniforms[%d]", ArrayIndex), + ThisHash, + Params); + + + } + CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); + } + PushNewRow(Ui); + + + + + + + } + + + { + + + + cs MemberName = CSz("PingPongFBOs"); + + + if (ToggleButton(Ui, + CSz("v PingPongFBOs[3]"), + CSz("> PingPongFBOs[3]"), + UiId(Window, "toggle world_edit_render_context framebuffer PingPongFBOs", Element->PingPongFBOs, ThisHash), + Params )) + { + OPEN_INDENT_FOR_TOGGLEABLE_REGION(); + PushNewRow(Ui); + s32 End = 3; + + RangeIterator(ArrayIndex, End) + { + DoEditorUi(Ui, + Window, + Element->PingPongFBOs+ArrayIndex, + FSz("PingPongFBOs[%d]", ArrayIndex), + ThisHash, + Params); + + + } + CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); + } + PushNewRow(Ui); + + + + + + + } + + + { + + + + cs MemberName = CSz("PingPongTextures"); + + + if (ToggleButton(Ui, + CSz("v PingPongTextures[3]"), + CSz("> PingPongTextures[3]"), + UiId(Window, "toggle world_edit_render_context texture PingPongTextures", Element->PingPongTextures, ThisHash), + Params )) + { + OPEN_INDENT_FOR_TOGGLEABLE_REGION(); + PushNewRow(Ui); + s32 End = 3; + + RangeIterator(ArrayIndex, End) + { + DoEditorUi(Ui, + Window, + Element->PingPongTextures+ArrayIndex, + FSz("PingPongTextures[%d]", ArrayIndex), + ThisHash, + Params); + + + } + CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); + } + PushNewRow(Ui); + + + + + + + } + + + { + + + + cs MemberName = CSz("ChunkDim"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v3*, Element->ChunkDim), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("WorldspaceChunkBasis"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v3*, Element->WorldspaceChunkBasis), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("ChunkResolution"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v3*, Element->ChunkResolution), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Type"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(s32*, &Element->Type), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, shape_layer_advanced_params *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x31853A01); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle shape_layer_advanced_params", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("Rounding"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(r32*, &Element->Rounding), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("Stretch"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v3*, &Element->Stretch), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Repeat"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v3*, &Element->Repeat), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Axis"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v3*, &Element->Axis), + MemberName, + ThisHash, + Params + , -1.f, 1.f ); + + + + + + + + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, world_update_op_shape_params_sphere *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0xD209A19); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle world_update_op_shape_params_sphere", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("Location"); + + + } + + + { + + + + cs MemberName = CSz("Radius"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(f32*, &Element->Radius), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, graphics_settings *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x17D77224); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle graphics_settings", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("Resolution"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(resolution_setting*, &Element->Resolution), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("ShadowQuality"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(shadow_quality_setting*, &Element->ShadowQuality), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("LightingQuality"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(lighting_quality_setting*, &Element->LightingQuality), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("ShaderLanguage"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(shader_language_setting*, &Element->ShaderLanguage), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("WindowStartingSize"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(resolution_setting*, &Element->WindowStartingSize), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, graphics *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x36CA0243); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle graphics", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("Initialized"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(bonsai_futex*, &Element->Initialized), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("RenderGate"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(bonsai_futex*, &Element->RenderGate), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Settings"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(render_settings*, &Element->Settings), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("PrevSettings"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(render_settings*, &Element->PrevSettings), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("OffsetOfWorldCenterToGrid"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v3*, &Element->OffsetOfWorldCenterToGrid), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("SunBasis"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v3*, &Element->SunBasis), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("SkyColor"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v3*, &Element->SkyColor), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("GameCamera"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(camera*, &Element->GameCamera), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("DebugCamera"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(camera*, &Element->DebugCamera), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Camera"); + + + } + + + { + + + + cs MemberName = CSz("Exposure"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(r32*, &Element->Exposure), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("MainDrawList"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(octree_node_ptr_paged_list*, &Element->MainDrawList), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("ShadowMapDrawList"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(octree_node_ptr_paged_list*, &Element->ShadowMapDrawList), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("MinClipP_worldspace"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v3*, &Element->MinClipP_worldspace), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("MaxClipP_worldspace"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v3*, &Element->MaxClipP_worldspace), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("gBuffer"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(g_buffer_render_group*, Element->gBuffer), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("AoGroup"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(ao_render_group*, Element->AoGroup), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("SG"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(shadow_render_group*, Element->SG), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("ColorPalette"); + + + } + + + { + + + + cs MemberName = CSz("ColorPaletteTexture"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(texture*, &Element->ColorPaletteTexture), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Transparency"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(transparency_render_group*, &Element->Transparency), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Lighting"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(lighting_render_group*, &Element->Lighting), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Bloom"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(bloom_render_group*, &Element->Bloom), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Gaussian"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(gaussian_render_group*, &Element->Gaussian), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("CompositeGroup"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(composite_render_group*, &Element->CompositeGroup), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("TerrainShapingRC"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(terrain_shaping_render_context*, &Element->TerrainShapingRC), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("TerrainDecorationRC"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(terrain_decoration_render_context*, &Element->TerrainDecorationRC), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("TerrainDerivsRC"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(terrain_derivs_render_context*, &Element->TerrainDerivsRC), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("TerrainFinalizeRC"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(terrain_finalize_render_context*, &Element->TerrainFinalizeRC), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("WorldEditRC"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(world_edit_render_context*, &Element->WorldEditRC), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("NoiseFinalizeJobsPending"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u32*, &Element->NoiseFinalizeJobsPending), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("TotalChunkJobsActive"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u32*, &Element->TotalChunkJobsActive), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("NoiseReadbackJobs"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(dummy_work_queue_entry_build_chunk_mesh_block_array*, &Element->NoiseReadbackJobs), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("ImmediateGeometry"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(triple_buffered_gpu_mapped_element_buffer*, &Element->ImmediateGeometry), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("GpuTimers"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(gpu_timer_block_array*, &Element->GpuTimers), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Memory"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(memory_arena*, Element->Memory), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, perlin_noise_params *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x3926BA4A); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle perlin_noise_params", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("Period"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v3*, &Element->Period), + MemberName, + ThisHash, + Params + , 0.1f, 20.f ); + + + + + + + + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + + + + + + + + + + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, physics *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x101A527C); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle physics", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("Velocity"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v3*, &Element->Velocity), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Force"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v3*, &Element->Force), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Delta"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v3*, &Element->Delta), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Mass"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(r32*, &Element->Mass), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("Speed"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(r32*, &Element->Speed), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, world_edit *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x12B39B25); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle world_edit", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("Region"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(rect3cp*, &Element->Region), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Brush"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(world_edit_brush*, Element->Brush), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Tombstone"); + DoEditorUi(Ui, + Window, + Cast(b8*, &Element->Tombstone), + MemberName, + ThisHash, + &DefaultUiRenderParams_Checkbox + ); + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("Selected"); + DoEditorUi(Ui, + Window, + Cast(b8*, &Element->Selected), + MemberName, + ThisHash, + &DefaultUiRenderParams_Checkbox + ); + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("Ordinal"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u32*, &Element->Ordinal), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, particle *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x3825E333); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle particle", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("Velocity"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v3*, &Element->Velocity), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Offset"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v3*, &Element->Offset), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Color"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u8*, &Element->Color), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("IsLight"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(b8*, &Element->IsLight), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("RemainingLifespan"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(r32*, &Element->RemainingLifespan), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + + + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, easing_function_visualizer_render_pass *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x8D1934E); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle easing_function_visualizer_render_pass", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("Program"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(shader*, &Element->Program), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Uniforms"); + + + if (ToggleButton(Ui, + CSz("v Uniforms[2]"), + CSz("> Uniforms[2]"), + UiId(Window, "toggle easing_function_visualizer_render_pass shader_uniform Uniforms", Element->Uniforms, ThisHash), + Params )) + { + OPEN_INDENT_FOR_TOGGLEABLE_REGION(); + PushNewRow(Ui); + s32 End = 2; + + RangeIterator(ArrayIndex, End) + { + DoEditorUi(Ui, + Window, + Element->Uniforms+ArrayIndex, + FSz("Uniforms[%d]", ArrayIndex), + ThisHash, + Params); + + + } + CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); + } + PushNewRow(Ui); + + + + + + + } + + + { + + + + cs MemberName = CSz("Func"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(easing_function*, Element->Func), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + + + + + + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, input_event *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x1548FB6C); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle input_event", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("Clicked"); + DoEditorUi(Ui, + Window, + Cast(b8*, &Element->Clicked), + MemberName, + ThisHash, + &DefaultUiRenderParams_Checkbox + ); + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("Pressed"); + DoEditorUi(Ui, + Window, + Cast(b8*, &Element->Pressed), + MemberName, + ThisHash, + &DefaultUiRenderParams_Checkbox + ); + + + + + + PushNewRow(Ui); + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + + + + + + + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, world_update_op_shape_params_plane *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x2BB91B80); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle world_update_op_shape_params_plane", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("Orientation"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(shape_axis*, &Element->Orientation), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Thickness"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(f32*, &Element->Thickness), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + + + + + + + + + + + + + + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, selection_region *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0xBA6A3C1); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle selection_region", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("Clicks"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u32*, &Element->Clicks), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("Base"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(cp*, &Element->Base), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Region"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(rect3cp*, &Element->Region), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Diff"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v3*, &Element->Diff), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("InitialSelect"); + DoEditorUi(Ui, + Window, + Cast(b8*, &Element->InitialSelect), + MemberName, + ThisHash, + &DefaultUiRenderParams_Checkbox + ); + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("ModMode"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(selection_modification_mode*, &Element->ModMode), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("ModState"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(selection_modification_state*, &Element->ModState), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + + + + + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, shadow_map_shader *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x21B57BD7); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle shadow_map_shader", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("Program"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(shader*, &Element->Program), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Uniforms"); + + + if (ToggleButton(Ui, + CSz("v Uniforms[4]"), + CSz("> Uniforms[4]"), + UiId(Window, "toggle shadow_map_shader shader_uniform Uniforms", Element->Uniforms, ThisHash), + Params )) + { + OPEN_INDENT_FOR_TOGGLEABLE_REGION(); + PushNewRow(Ui); + s32 End = 4; + + RangeIterator(ArrayIndex, End) + { + DoEditorUi(Ui, + Window, + Element->Uniforms+ArrayIndex, + FSz("Uniforms[%d]", ArrayIndex), + ThisHash, + Params); + + + } + CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); + } + PushNewRow(Ui); + + + + + + + } + + + { + + + + cs MemberName = CSz("ModelMatrix"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(m4*, &Element->ModelMatrix), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("ViewProjection"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(m4*, &Element->ViewProjection), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("MinClipP_worldspace"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v3*, Element->MinClipP_worldspace), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("MaxClipP_worldspace"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v3*, Element->MaxClipP_worldspace), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, bloom_upsample_shader *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x35DFEBD8); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle bloom_upsample_shader", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("Program"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(shader*, &Element->Program), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Uniforms"); + + + if (ToggleButton(Ui, + CSz("v Uniforms[1]"), + CSz("> Uniforms[1]"), + UiId(Window, "toggle bloom_upsample_shader shader_uniform Uniforms", Element->Uniforms, ThisHash), + Params )) + { + OPEN_INDENT_FOR_TOGGLEABLE_REGION(); + PushNewRow(Ui); + s32 End = 1; + + RangeIterator(ArrayIndex, End) + { + DoEditorUi(Ui, + Window, + Element->Uniforms+ArrayIndex, + FSz("Uniforms[%d]", ArrayIndex), + ThisHash, + Params); + + + } + CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); + } + PushNewRow(Ui); + + + + + + + } + + + { + + + + cs MemberName = CSz("FilterRadius"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(f32*, Element->FilterRadius), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + + + + + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, render_settings *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x3A47CBF1); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle render_settings", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("UseSsao"); + DoEditorUi(Ui, + Window, + Cast(b8*, &Element->UseSsao), + MemberName, + ThisHash, + &DefaultUiRenderParams_Checkbox + ); + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("UseShadowMapping"); + DoEditorUi(Ui, + Window, + Cast(b8*, &Element->UseShadowMapping), + MemberName, + ThisHash, + &DefaultUiRenderParams_Checkbox + ); + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("UseLightingBloom"); + DoEditorUi(Ui, + Window, + Cast(b8*, &Element->UseLightingBloom), + MemberName, + ThisHash, + &DefaultUiRenderParams_Checkbox + ); + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("BravoilMyersOIT"); + DoEditorUi(Ui, + Window, + Cast(b8*, &Element->BravoilMyersOIT), + MemberName, + ThisHash, + &DefaultUiRenderParams_Checkbox + ); + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("BravoilMcGuireOIT"); + DoEditorUi(Ui, + Window, + Cast(b8*, &Element->BravoilMcGuireOIT), + MemberName, + ThisHash, + &DefaultUiRenderParams_Checkbox + ); + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("DrawMajorGrid"); + DoEditorUi(Ui, + Window, + Cast(b8*, &Element->DrawMajorGrid), + MemberName, + ThisHash, + &DefaultUiRenderParams_Checkbox + ); + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("DrawMinorGrid"); + DoEditorUi(Ui, + Window, + Cast(b8*, &Element->DrawMinorGrid), + MemberName, + ThisHash, + &DefaultUiRenderParams_Checkbox + ); + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("MajorGridDim"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(r32*, &Element->MajorGridDim), + MemberName, + ThisHash, + Params + , 0, 32 ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("DrawCameraGhost"); + DoEditorUi(Ui, + Window, + Cast(b8*, &Element->DrawCameraGhost), + MemberName, + ThisHash, + &DefaultUiRenderParams_Checkbox + ); + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("CameraGhostSize"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(r32*, &Element->CameraGhostSize), + MemberName, + ThisHash, + Params + , 1, 100 ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("Ignored"); + + + } + + + { + + + + cs MemberName = CSz("Headless"); + + + } + + + { + + + + cs MemberName = CSz("ToneMappingType"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(tone_mapping_type*, &Element->ToneMappingType), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("GameCameraFOV"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(f32*, &Element->GameCameraFOV), + MemberName, + ThisHash, + Params + , 5, 250 ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("Lighting"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(lighting_settings*, &Element->Lighting), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("ApplicationResolution"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v2*, &Element->ApplicationResolution), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("ShadowMapResolution"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v2*, &Element->ShadowMapResolution), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("LuminanceMapResolution"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v2*, &Element->LuminanceMapResolution), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("iApplicationResolution"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v2i*, &Element->iApplicationResolution), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("iShadowMapResolution"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v2i*, &Element->iShadowMapResolution), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("iLuminanceMapResolution"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v2i*, &Element->iLuminanceMapResolution), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + + + + + + + + + + + + + + + + + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, level_editor *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x346D8421); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle level_editor", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("Memory"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(memory_arena*, Element->Memory), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Selection"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(selection_region*, &Element->Selection), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("AssetThumbnails"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(asset_thumbnail_block_array*, &Element->AssetThumbnails), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("NextLayerIndex"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u32*, &Element->NextLayerIndex), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("Layers"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(world_edit_layer_block_array*, &Element->Layers), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("SelectedLayerIndex"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(world_edit_layer_block_array_index*, &Element->SelectedLayerIndex), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Edits"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(world_edit_block_array*, &Element->Edits), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("SelectedEditIndices"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(world_edit_block_array_index_block_array*, &Element->SelectedEditIndices), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("HotEdit"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(world_edit*, Element->HotEdit), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("HotEditIndex"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(world_edit_block_array_index*, &Element->HotEditIndex), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("LoadedBrushes"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(world_edit_brush_hashtable*, &Element->LoadedBrushes), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("CurrentBrush"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(world_edit_brush*, Element->CurrentBrush), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + + + + + + + + + + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, brush_settings *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x2B34AC41); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle brush_settings", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("Brush Type"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(brush_layer_type*, &Element->Type), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + if (Element->Type == BrushLayerType_Noise) + + { + + + + cs MemberName = {}; + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(noise_layer*, &Element->Noise), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + if (Element->Type == BrushLayerType_Shape) + + { + + + + cs MemberName = {}; + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(shape_layer*, &Element->Shape), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Power"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(f32*, &Element->Power), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("ValueBias"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(r32*, &Element->ValueBias), + MemberName, + ThisHash, + Params + , -1.f, 1.f ); + + + + + + + + PushNewRow(Ui); + + + + } + if (HasThresholdModifier(Element)) + + { + + + + cs MemberName = CSz("Threshold"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(f32*, &Element->Threshold), + MemberName, + ThisHash, + Params + , 0.f, 1.f ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("ValueModifier"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(world_edit_blend_mode_modifier*, &Element->ValueModifier), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("BlendMode"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(world_edit_blend_mode*, &Element->BlendMode), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("ColorMode"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(world_edit_color_blend_mode*, &Element->ColorMode), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Invert"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(b8*, &Element->Invert), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("Iterations"); + + + } + + + { + + + + cs MemberName = CSz("Offset"); + + + } + + + { + + + + cs MemberName = CSz("NoiseBasisOffset"); + + + } + + + { + + + + cs MemberName = CSz("HSVColor"); + PushColumn(Ui, CSz("HSVColor")); DoColorPickerToggle(Ui, Window, &Element->HSVColor, False, ThisHash); + + + + + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + + + + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, game_lights *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0xFE5B45E); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle game_lights", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("ColorTex"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(texture*, &Element->ColorTex), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("PositionTex"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(texture*, &Element->PositionTex), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("IndexToUV"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(r32*, &Element->IndexToUV), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("Count"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(s32*, &Element->Count), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("Lights"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(light*, Element->Lights), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + + + + + + + + + + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, octree_node_freelist *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x17DC2499); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle octree_node_freelist", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("First"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(octree_node*, Element->First), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Memory"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(memory_arena*, Element->Memory), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Lock"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(bonsai_futex*, &Element->Lock), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("ElementsAllocated"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u32*, &Element->ElementsAllocated), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + + + + + + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, gen_chunk_freelist *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x188A1CBB); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle gen_chunk_freelist", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("First"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(gen_chunk*, Element->First), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Memory"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(memory_arena*, Element->Memory), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Lock"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(bonsai_futex*, &Element->Lock), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("ElementsAllocated"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u32*, &Element->ElementsAllocated), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + + + + + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, memory_arena *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0xB6B4CD6); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle memory_arena", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("Start"); + + + } + + + { + + + + cs MemberName = CSz("At"); + auto Value = u64(Element->End-Element->At); (Element->At); + DoEditorUi(Ui, Window, &Value, MemberName, ThisHash, Params); + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("End"); + auto Value = u64(Element->End-Element->Start); (Element->End); + DoEditorUi(Ui, Window, &Value, MemberName, ThisHash, Params); + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("NextBlockSize"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(umm*, &Element->NextBlockSize), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("Prev"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(memory_arena*, Element->Prev), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("DebugFutex"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(bonsai_futex*, &Element->DebugFutex), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + + + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, render_buffers_2d *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x83E1CFD); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle render_buffers_2d", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("DebugTextureArray"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(texture*, &Element->DebugTextureArray), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("TextTextureUniform"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(s32*, &Element->TextTextureUniform), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("UiShader"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(shader*, &Element->UiShader), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Buf"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(triple_buffered_gpu_mapped_ui_buffer*, &Element->Buf), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, input *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x8A2F50A); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle input", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("Enter"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input_event*, &Element->Enter), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Escape"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input_event*, &Element->Escape), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Alt"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input_event*, &Element->Alt), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Ctrl"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input_event*, &Element->Ctrl), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Shift"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input_event*, &Element->Shift), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Backspace"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input_event*, &Element->Backspace), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Delete"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input_event*, &Element->Delete), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("F12"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input_event*, &Element->F12), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("F11"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input_event*, &Element->F11), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("F10"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input_event*, &Element->F10), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("F9"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input_event*, &Element->F9), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("F8"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input_event*, &Element->F8), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("F7"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input_event*, &Element->F7), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("F6"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input_event*, &Element->F6), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("F5"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input_event*, &Element->F5), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("F4"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input_event*, &Element->F4), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("F3"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input_event*, &Element->F3), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("F2"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input_event*, &Element->F2), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("F1"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input_event*, &Element->F1), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Dot"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input_event*, &Element->Dot), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Minus"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input_event*, &Element->Minus), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("FSlash"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input_event*, &Element->FSlash), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Space"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input_event*, &Element->Space), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Underscore"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input_event*, &Element->Underscore), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("N0"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input_event*, &Element->N0), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("N1"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input_event*, &Element->N1), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("N2"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input_event*, &Element->N2), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("N3"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input_event*, &Element->N3), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("N4"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input_event*, &Element->N4), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("N5"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input_event*, &Element->N5), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("N6"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input_event*, &Element->N6), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("N7"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input_event*, &Element->N7), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("N8"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input_event*, &Element->N8), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("N9"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input_event*, &Element->N9), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("A"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input_event*, &Element->A), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("B"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input_event*, &Element->B), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("C"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input_event*, &Element->C), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("D"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input_event*, &Element->D), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("E"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input_event*, &Element->E), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("F"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input_event*, &Element->F), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("G"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input_event*, &Element->G), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("H"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input_event*, &Element->H), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("I"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input_event*, &Element->I), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("J"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input_event*, &Element->J), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("K"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input_event*, &Element->K), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("L"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input_event*, &Element->L), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("M"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input_event*, &Element->M), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("N"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input_event*, &Element->N), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("O"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input_event*, &Element->O), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("P"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input_event*, &Element->P), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Q"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input_event*, &Element->Q), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("R"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input_event*, &Element->R), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("S"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input_event*, &Element->S), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("T"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input_event*, &Element->T), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("U"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input_event*, &Element->U), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("V"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input_event*, &Element->V), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("W"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input_event*, &Element->W), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("X"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input_event*, &Element->X), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Y"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input_event*, &Element->Y), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Z"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input_event*, &Element->Z), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("RMB"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input_event*, &Element->RMB), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("LMB"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input_event*, &Element->LMB), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("MMB"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(input_event*, &Element->MMB), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("MouseWheelDelta"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(s32*, &Element->MouseWheelDelta), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + + + + + + + + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, bonsai_stdlib *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x1311052E); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle bonsai_stdlib", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("Os"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(os*, &Element->Os), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Plat"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(platform*, &Element->Plat), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("AppApi"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(application_api*, &Element->AppApi), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("GL"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(opengl*, &Element->GL), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("ThreadStates"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(thread_local_state*, Element->ThreadStates), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("DefaultThreadState"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(thread_local_state*, &Element->DefaultThreadState), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("ShaderHeaderFile"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(hot_reloadable_file*, &Element->ShaderHeaderFile), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("ShaderHeaderCode"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(ansi_stream*, &Element->ShaderHeaderCode), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("AllTextures"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(texture_block_array*, &Element->AllTextures), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("AllShaders"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(shader_ptr_block_array*, &Element->AllShaders), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("DebugState"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(debug_state*, &Element->DebugState), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + + + + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, chunk_thumbnail *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0xB590D48); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle chunk_thumbnail", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("Chunk"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(world_chunk*, &Element->Chunk), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Thumbnail"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(asset_thumbnail*, &Element->Thumbnail), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + + + + + + + + + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, keyframe *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x14339D6D); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle keyframe", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("tEnd"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(r32*, &Element->tEnd), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("Value"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(r32*, &Element->Value), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + + + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, world_update_op_shape_params_torus *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x39AD558C); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle world_update_op_shape_params_torus", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("MajorRadius"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(f32*, &Element->MajorRadius), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("MinorRadius"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(f32*, &Element->MinorRadius), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, shader *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x1813CD99); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle shader", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("ID"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u32*, &Element->ID), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("Uniforms"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(shader_uniform_buffer*, &Element->Uniforms), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("VertexSourceFilename"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(cs*, &Element->VertexSourceFilename), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("FragSourceFilename"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(cs*, &Element->FragSourceFilename), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("VertexTimeModifiedWhenLoaded"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(s64*, &Element->VertexTimeModifiedWhenLoaded), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("FragmentTimeModifiedWhenLoaded"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(s64*, &Element->FragmentTimeModifiedWhenLoaded), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("HotReloaded"); + DoEditorUi(Ui, + Window, + Cast(b8*, &Element->HotReloaded), + MemberName, + ThisHash, + &DefaultUiRenderParams_Checkbox + ); + + + + + + PushNewRow(Ui); + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + + + + + + + + + + + + + + + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, animation *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x34AA15E5); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle animation", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("t"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(r32*, &Element->t), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("tEnd"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(r32*, &Element->tEnd), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("xKeyframeCount"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u32*, &Element->xKeyframeCount), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("xKeyframes"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(keyframe*, Element->xKeyframes), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("yKeyframeCount"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u32*, &Element->yKeyframeCount), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("yKeyframes"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(keyframe*, Element->yKeyframes), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("zKeyframeCount"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u32*, &Element->zKeyframeCount), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("zKeyframes"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(keyframe*, Element->zKeyframes), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, shape_layer *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x11CD2DF2); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle shape_layer", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("Shape Type"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(shape_type*, &Element->Type), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + if (Element->Type == ShapeType_Rect) + + { + + + + cs MemberName = {}; + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(world_update_op_shape_params_rect*, &Element->Rect), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + if (Element->Type == ShapeType_Sphere) + + { + + + + cs MemberName = {}; + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(world_update_op_shape_params_sphere*, &Element->Sphere), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + if (Element->Type == ShapeType_Line) + + { + + + + cs MemberName = {}; + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(world_update_op_shape_params_sphere*, &Element->Line), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + if (Element->Type == ShapeType_Cylinder) + + { + + + + cs MemberName = {}; + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(world_update_op_shape_params_cylinder*, &Element->Cylinder), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + if (Element->Type == ShapeType_Plane) + + { + + + + cs MemberName = {}; + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(world_update_op_shape_params_plane*, &Element->Plane), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + if (Element->Type == ShapeType_Torus) + + { + + + + cs MemberName = {}; + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(world_update_op_shape_params_torus*, &Element->Torus), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Advanced"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(shape_layer_advanced_params*, &Element->Advanced), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, untextured_3d_geometry_buffer *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x7A74DF9); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle untextured_3d_geometry_buffer", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("Type"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(data_type*, &Element->Type), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Next"); + + + } + + + { + + + + cs MemberName = CSz("Verts"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(void *, Element->Verts), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("Normals"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(void *, Element->Normals), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("Mat"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(vertex_material*, Element->Mat), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("End"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u32*, &Element->End), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("At"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u32*, &Element->At), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("Parent"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(untextured_3d_geometry_buffer*, Element->Parent), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("BufferNeedsToGrow"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u32*, &Element->BufferNeedsToGrow), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("Timestamp"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u64*, &Element->Timestamp), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, work_queue *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x3AF675FC); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle work_queue", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("EnqueueFutex"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(bonsai_futex*, &Element->EnqueueFutex), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("EnqueueIndex"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u32*, &Element->EnqueueIndex), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("DequeueIndex"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u32*, &Element->DequeueIndex), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("Entries"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(work_queue_entry*, Element->Entries), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, bloom_render_group *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x26D95603); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle bloom_render_group", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("BlurFBO"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(framebuffer*, &Element->BlurFBO), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Tex"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(texture*, &Element->Tex), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("MipChain"); + + + if (ToggleButton(Ui, + CSz("v MipChain[(3)]"), + CSz("> MipChain[(3)]"), + UiId(Window, "toggle bloom_render_group texture MipChain", Element->MipChain, ThisHash), + Params )) + { + OPEN_INDENT_FOR_TOGGLEABLE_REGION(); + PushNewRow(Ui); + s32 End = (3); + + RangeIterator(ArrayIndex, End) + { + DoEditorUi(Ui, + Window, + Element->MipChain+ArrayIndex, + FSz("MipChain[%d]", ArrayIndex), + ThisHash, + Params); + + + } + CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); + } + PushNewRow(Ui); + + + + + + + } + + + { + + + + cs MemberName = CSz("DownsampleShader"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(bloom_downsample_shader*, &Element->DownsampleShader), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("UpsampleShader"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(bloom_upsample_shader*, &Element->UpsampleShader), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, terrain_derivs_render_context *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x302E0E17); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle terrain_derivs_render_context", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("Program"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(shader*, &Element->Program), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Uniforms"); + + + if (ToggleButton(Ui, + CSz("v Uniforms[1]"), + CSz("> Uniforms[1]"), + UiId(Window, "toggle terrain_derivs_render_context shader_uniform Uniforms", Element->Uniforms, ThisHash), + Params )) + { + OPEN_INDENT_FOR_TOGGLEABLE_REGION(); + PushNewRow(Ui); + s32 End = 1; + + RangeIterator(ArrayIndex, End) + { + DoEditorUi(Ui, + Window, + Element->Uniforms+ArrayIndex, + FSz("Uniforms[%d]", ArrayIndex), + ThisHash, + Params); + + + } + CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); + } + PushNewRow(Ui); + + + + + + + } + + + { + + + + cs MemberName = CSz("DestTex"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(texture*, &Element->DestTex), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("DestFBO"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(framebuffer*, &Element->DestFBO), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Ignored"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v3*, &Element->Ignored), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + + + + + + + + + + + + + + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, engine_debug *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x318BDE5D); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle engine_debug", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("Memory"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(memory_arena*, Element->Memory), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("ViewMode"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(engine_debug_view_mode*, &Element->ViewMode), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("PickedChunks"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(picked_world_chunk_static_buffer*, &Element->PickedChunks), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Textures"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(texture_ptr_block_array*, &Element->Textures), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("UiDebug"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(ui_debug*, &Element->UiDebug), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Render"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(render_debug*, &Element->Render), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("DrawEntityCollisionVolumes"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(b8*, &Element->DrawEntityCollisionVolumes), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("DrawWorldAxies"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(b8*, &Element->DrawWorldAxies), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("TriggerRuntimeBreak"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(b8*, &Element->TriggerRuntimeBreak), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("ResetAssetNodeView"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(b8*, &Element->ResetAssetNodeView), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("DrawBranchNodesWithMeshes"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(b8*, &Element->DrawBranchNodesWithMeshes), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("DrawBranchNodes"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(b8*, &Element->DrawBranchNodes), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("DrawLeafNodes"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(b8*, &Element->DrawLeafNodes), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("DrawNodesWithChunks"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(b8*, &Element->DrawNodesWithChunks), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("DrawQueuedNodes"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(b8*, &Element->DrawQueuedNodes), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("MarkChunkBorderVoxels"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(b8*, &Element->MarkChunkBorderVoxels), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("DrawGameCameraLocation"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(b8*, &Element->DrawGameCameraLocation), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("ChunkGenTimeElapsedMS"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(r64*, &Element->ChunkGenTimeElapsedMS), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("CellsGenerated"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u64*, &Element->CellsGenerated), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("ChunkGenCyclesElapsed"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(r64*, &Element->ChunkGenCyclesElapsed), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("PickedChunkState"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u8*, &Element->PickedChunkState), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("PickedNode"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(octree_node*, Element->PickedNode), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("AssetWindowViewMode"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(asset_window_view_mode*, &Element->AssetWindowViewMode), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("SelectedAsset"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(asset_id*, &Element->SelectedAsset), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("ModelIndex"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u64*, &Element->ModelIndex), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("SelectedEntity"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(entity_id*, &Element->SelectedEntity), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("OctreeDrawDepth"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u32*, &Element->OctreeDrawDepth), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("SelectedNode"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(octree_node*, Element->SelectedNode), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, bloom_downsample_shader *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0xA55F66A); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle bloom_downsample_shader", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("Program"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(shader*, &Element->Program), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Uniforms"); + + + if (ToggleButton(Ui, + CSz("v Uniforms[1]"), + CSz("> Uniforms[1]"), + UiId(Window, "toggle bloom_downsample_shader shader_uniform Uniforms", Element->Uniforms, ThisHash), + Params )) + { + OPEN_INDENT_FOR_TOGGLEABLE_REGION(); + PushNewRow(Ui); + s32 End = 1; + + RangeIterator(ArrayIndex, End) + { + DoEditorUi(Ui, + Window, + Element->Uniforms+ArrayIndex, + FSz("Uniforms[%d]", ArrayIndex), + ThisHash, + Params); + + + } + CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); + } + PushNewRow(Ui); + + + + + + + } + + + { + + + + cs MemberName = CSz("SrcResolution"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v2*, Element->SrcResolution), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + + + + + + + + + + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, brush_layer *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x133E0EA1); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle brush_layer", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = {}; + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(brush_settings*, &Element->Settings), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("PrevSettings"); + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + + + + + + + + + + + + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, random_series *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x33A36ED5); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle random_series", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("Seed"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u64*, &Element->Seed), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, engine_resources *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x2FE376DA); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle engine_resources", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("ReadyToStartMainLoop"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(bonsai_futex*, &Element->ReadyToStartMainLoop), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Stdlib"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(bonsai_stdlib*, &Element->Stdlib), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("EngineApi"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(engine_api*, &Element->EngineApi), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Settings"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(engine_settings*, &Element->Settings), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Ui"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(renderer_2d*, &Element->Ui), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Hotkeys"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(hotkeys*, &Element->Hotkeys), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("MaybeMouseRay"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(maybe_ray*, &Element->MaybeMouseRay), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("World"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(world*, Element->World), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("GameState"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(game_state*, Element->GameState), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Graphics"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(graphics*, &Element->Graphics), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("RequestedGameLibReloadNode"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(file_traversal_node*, &Element->RequestedGameLibReloadNode), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("RequestedGameLibReloadBehavior"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(game_lib_reload_behavior*, &Element->RequestedGameLibReloadBehavior), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Heap"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(heap_allocator*, &Element->Heap), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("GameMemory"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(memory_arena*, Element->GameMemory), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("WorldUpdateMemory"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(memory_arena*, Element->WorldUpdateMemory), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("EntityTable"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(entity*, Element->EntityTable), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("AssetSystem"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(asset_system*, &Element->AssetSystem), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("FrameIndex"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u32*, &Element->FrameIndex), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("geo_u3d_MeshFreelist"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(tiered_mesh_freelist*, &Element->geo_u3d_MeshFreelist), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("world_chunk_MeshFreelist"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(tiered_mesh_freelist*, &Element->world_chunk_MeshFreelist), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("EngineDebug"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(engine_debug*, &Element->EngineDebug), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Editor"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(level_editor*, &Element->Editor), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("MousedOverVoxel"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(maybe_picked_voxel*, &Element->MousedOverVoxel), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("ClosestStandingSpotToCursor"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(maybe_standing_spot*, &Element->ClosestStandingSpotToCursor), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("HoverEntity"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(maybe_entity_ptr*, &Element->HoverEntity), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("RTTGroup"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(render_to_texture_group*, &Element->RTTGroup), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("GenChunkFreelist"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(gen_chunk_freelist*, &Element->GenChunkFreelist), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, g_buffer_render_group *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x576CF56); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle g_buffer_render_group", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("FBO"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(framebuffer*, &Element->FBO), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Textures"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(g_buffer_textures*, &Element->Textures), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("gBufferShader"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(shader*, &Element->gBufferShader), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("InverseViewMatrix"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(m4*, &Element->InverseViewMatrix), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("InverseProjectionMatrix"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(m4*, &Element->InverseProjectionMatrix), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("ViewProjection"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(m4*, &Element->ViewProjection), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("GlTimerObject"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u32*, &Element->GlTimerObject), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, terrain_shaping_render_context *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x1818B763); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle terrain_shaping_render_context", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("Program"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(shader*, &Element->Program), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Uniforms"); + + + if (ToggleButton(Ui, + CSz("v Uniforms[5]"), + CSz("> Uniforms[5]"), + UiId(Window, "toggle terrain_shaping_render_context shader_uniform Uniforms", Element->Uniforms, ThisHash), + Params )) + { + OPEN_INDENT_FOR_TOGGLEABLE_REGION(); + PushNewRow(Ui); + s32 End = 5; + + RangeIterator(ArrayIndex, End) + { + DoEditorUi(Ui, + Window, + Element->Uniforms+ArrayIndex, + FSz("Uniforms[%d]", ArrayIndex), + ThisHash, + Params); + + + } + CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); + } + PushNewRow(Ui); + + + + + + + } + + + { + + + + cs MemberName = CSz("DestTex"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(texture*, &Element->DestTex), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("DestFBO"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(framebuffer*, &Element->DestFBO), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("ChunkDim"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v3*, &Element->ChunkDim), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("WorldspaceChunkBasis"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v3*, &Element->WorldspaceChunkBasis), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("ChunkResolution"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v3*, &Element->ChunkResolution), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("ReshapeFunc"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(easing_function*, &Element->ReshapeFunc), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + + + + + + + + + + + + + + + + + + + + + + + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, v2_static_cursor_16 *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x1498EFCB); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle v2_static_cursor_16", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("Start"); + + + if (ToggleButton(Ui, + CSz("v Start[16]"), + CSz("> Start[16]"), + UiId(Window, "toggle v2_static_cursor_16 v2 Start", Element->Start, ThisHash), + Params )) + { + OPEN_INDENT_FOR_TOGGLEABLE_REGION(); + PushNewRow(Ui); + s32 End = s32(Element->At); + Assert( End < 16 ); + + RangeIterator(ArrayIndex, End) + { + DoEditorUi(Ui, + Window, + Element->Start+ArrayIndex, + FSz("Start[%d]", ArrayIndex), + ThisHash, + Params); + + + } + CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); + } + PushNewRow(Ui); + + + + + + + } + + + { + + + + cs MemberName = CSz("At"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u32*, &Element->At), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, noise_layer *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x11D457CF); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle noise_layer", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("Noise Type"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(ui_noise_type*, &Element->Type), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + if (Element->Type == NoiseType_White) + + { + + + + cs MemberName = {}; + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(white_noise_params*, &Element->White), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + if (Element->Type == NoiseType_Perlin) + + { + + + + cs MemberName = {}; + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(perlin_noise_params*, &Element->Perlin), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + if (Element->Type == NoiseType_Voronoi) + + { + + + + cs MemberName = {}; + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(voronoi_noise_params*, &Element->Voronoi), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + + + + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, lighting_settings *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x4B67FED); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle lighting_settings", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("AutoDayNightCycle"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(b8*, &Element->AutoDayNightCycle), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("tDaySpeed"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(r32*, &Element->tDaySpeed), + MemberName, + ThisHash, + Params + , 1.f, 30.f ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("tDay"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(r32*, &Element->tDay), + MemberName, + ThisHash, + Params + , -PI32, PI32 ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("SunP"); + + + } + + + { + + + + cs MemberName = CSz("FogPower"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(r32*, &Element->FogPower), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("FogColor"); + PushColumn(Ui, CSz("FogColor")); DoColorPickerToggle(Ui, Window, &Element->FogColor, False, ThisHash); + + + + + + + + } + + + { + + + + cs MemberName = CSz("DawnIntensity"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(f32*, &Element->DawnIntensity), + MemberName, + ThisHash, + Params + , 0.f, 3.f ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("DawnHSV"); + PushColumn(Ui, CSz("DawnColor")); DoColorPickerToggle(Ui, Window, &Element->DawnHSV, False, ThisHash); + + + + + + + + } + + + { + + + + cs MemberName = CSz("SunIntensity"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(f32*, &Element->SunIntensity), + MemberName, + ThisHash, + Params + , 0.f, 3.f ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("SunHSV"); + PushColumn(Ui, CSz("SunColor")); DoColorPickerToggle(Ui, Window, &Element->SunHSV, False, ThisHash); + + + + + + + + } + + + { + + + + cs MemberName = CSz("DuskIntensity"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(f32*, &Element->DuskIntensity), + MemberName, + ThisHash, + Params + , 0.f, 3.f ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("DuskColor"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v3*, &Element->DuskColor), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("DuskHSV"); + PushColumn(Ui, CSz("DuskColor")); DoColorPickerToggle(Ui, Window, &Element->DuskHSV, False, ThisHash); + + + + + + + + } + + + { + + + + cs MemberName = CSz("MoonIntensity"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(f32*, &Element->MoonIntensity), + MemberName, + ThisHash, + Params + , 0.f, 3.f ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("MoonHSV"); + PushColumn(Ui, CSz("MoonColor")); DoColorPickerToggle(Ui, Window, &Element->MoonHSV, False, ThisHash); + + + + + + + + } + + + { + + + + cs MemberName = CSz("CurrentSunColor"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(v3*, &Element->CurrentSunColor), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, ui_debug *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x175317FA); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle ui_debug", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("OutlineUiValues"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(b8*, &Element->OutlineUiValues), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("OutlineUiButtons"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(b8*, &Element->OutlineUiButtons), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("OutlineUiTables"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(b8*, &Element->OutlineUiTables), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("OutlineUiTableColumns"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(b8*, &Element->OutlineUiTableColumns), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("DebugBreakOnElementClick"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(b8*, &Element->DebugBreakOnElementClick), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("DebugBreakUiCommand"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(b8*, &Element->DebugBreakUiCommand), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + + { + + + + cs MemberName = CSz("LogClickEvents"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(b8*, &Element->LogClickEvents), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, world_chunk_freelist *Element, cs Name, u32 ParentHash, ui_render_params *Params) + +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x2EA127FE); + + 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. + b32 DrawChildren = True; + b32 DidToggle = False; + if (Name.Count) + { + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle world_chunk_freelist", Element, ThisHash), Params)) + { + DidToggle = True; + PushNewRow(Ui); + } + else + { + DrawChildren = False; + } + } + + if (DrawChildren) + { + if (Name.Count) { PushTableStart(Ui); } + + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } + + + { + + + + cs MemberName = CSz("First"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(world_chunk*, Element->First), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Memory"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(memory_arena*, Element->Memory), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("Lock"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(bonsai_futex*, &Element->Lock), + MemberName, + ThisHash, + Params + ); + + + + + + + + + + + } + + + { + + + + cs MemberName = CSz("ElementsAllocated"); + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast(u32*, &Element->ElementsAllocated), + MemberName, + ThisHash, + Params + ); + + + + + + + + PushNewRow(Ui); + + + + } + + if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } + if (Name.Count) { PushTableEnd(Ui); } + } + else + { + PushNewRow(Ui); + } + + } + else + { + PushColumn(Ui, Name, Params); + PushColumn(Ui, CSz("(null)"), Params); + PushNewRow(Ui); + } + +} +; + + diff --git a/generated/for_datatypes_IXWy6K9V.h b/generated/for_datatypes_IXWy6K9V.h new file mode 100644 index 000000000..e77aa1e4e --- /dev/null +++ b/generated/for_datatypes_IXWy6K9V.h @@ -0,0 +1,2682 @@ +// src/engine/graphics.h:120:0 + + + + + + + +link_internal b32 +poof() +InitializeLightingRenderGroup +( + lighting_render_group *Element + + + + , texture *gColor + , texture *gNormal + , texture *gDepth + , texture *shadowMap + , texture *Ssao + , texture *TransparencyAccumTex + , texture *TransparencyCountTex + , b32 *BravoilMyersOIT + , b32 *BravoilMcGuireOIT + , m4 *InverseViewMatrix + , m4 *InverseProjectionMatrix + , m4 *ShadowMVP + , texture *LightColors + , texture *LightPositions + , f32 *LightIndexToUV + , s32 *LightCount + , camera *Camera + , v3 *SunPosition + , v3 *SunColor + , v3 *FogColor + , f32 *FogPower + , b32 *UseSsao + , b32 *UseShadowMapping + , b32 *UseLightingBloom + , v2 *ApplicationResolution + , v2 *ShadowMapResolution + + + +) +{ + b32 Result = CompileShaderPair(&Element->Program, CSz(BONSAI_SHADER_PATH "Lighting.vertexshader"), CSz(BONSAI_SHADER_PATH "Lighting.fragmentshader")); + + if (Result) + { + Element->Program.Uniforms = ShaderUniformBuffer(Element->Uniforms, ArrayCount(Element->Uniforms)); + + u32 UniformIndex = 0; + + + + + Element->gColor = gColor; + InitShaderUniform( + &Element->Program, + UniformIndex++, + + + + Element->gColor, + "gColor" + + + ); + + + + Element->gNormal = gNormal; + InitShaderUniform( + &Element->Program, + UniformIndex++, + + + + Element->gNormal, + "gNormal" + + + ); + + + + Element->gDepth = gDepth; + InitShaderUniform( + &Element->Program, + UniformIndex++, + + + + Element->gDepth, + "gDepth" + + + ); + + + + Element->shadowMap = shadowMap; + InitShaderUniform( + &Element->Program, + UniformIndex++, + + + + Element->shadowMap, + "shadowMap" + + + ); + + + + Element->Ssao = Ssao; + InitShaderUniform( + &Element->Program, + UniformIndex++, + + + + Element->Ssao, + "Ssao" + + + ); + + + + Element->TransparencyAccumTex = TransparencyAccumTex; + InitShaderUniform( + &Element->Program, + UniformIndex++, + + + + Element->TransparencyAccumTex, + "TransparencyAccumTex" + + + ); + + + + Element->TransparencyCountTex = TransparencyCountTex; + InitShaderUniform( + &Element->Program, + UniformIndex++, + + + + Element->TransparencyCountTex, + "TransparencyCountTex" + + + ); + + + + Element->BravoilMyersOIT = BravoilMyersOIT; + InitShaderUniform( + &Element->Program, + UniformIndex++, + + + + Element->BravoilMyersOIT, + "BravoilMyersOIT" + + + ); + + + + Element->BravoilMcGuireOIT = BravoilMcGuireOIT; + InitShaderUniform( + &Element->Program, + UniformIndex++, + + + + Element->BravoilMcGuireOIT, + "BravoilMcGuireOIT" + + + ); + + + + Element->InverseViewMatrix = InverseViewMatrix; + InitShaderUniform( + &Element->Program, + UniformIndex++, + + + + Element->InverseViewMatrix, + "InverseViewMatrix" + + + ); + + + + Element->InverseProjectionMatrix = InverseProjectionMatrix; + InitShaderUniform( + &Element->Program, + UniformIndex++, + + + + Element->InverseProjectionMatrix, + "InverseProjectionMatrix" + + + ); + + + + Element->ShadowMVP = ShadowMVP; + InitShaderUniform( + &Element->Program, + UniformIndex++, + + + + Element->ShadowMVP, + "ShadowMVP" + + + ); + + + + Element->LightColors = LightColors; + InitShaderUniform( + &Element->Program, + UniformIndex++, + + + + Element->LightColors, + "LightColors" + + + ); + + + + Element->LightPositions = LightPositions; + InitShaderUniform( + &Element->Program, + UniformIndex++, + + + + Element->LightPositions, + "LightPositions" + + + ); + + + + Element->LightIndexToUV = LightIndexToUV; + InitShaderUniform( + &Element->Program, + UniformIndex++, + + + + Element->LightIndexToUV, + "LightIndexToUV" + + + ); + + + + Element->LightCount = LightCount; + InitShaderUniform( + &Element->Program, + UniformIndex++, + + + + Element->LightCount, + "LightCount" + + + ); + + + + Element->Camera = Camera; + InitShaderUniform( + &Element->Program, + UniformIndex++, + + + + Element->Camera, + "Camera" + + + ); + + + + Element->SunPosition = SunPosition; + InitShaderUniform( + &Element->Program, + UniformIndex++, + + + + Element->SunPosition, + "SunPosition" + + + ); + + + + Element->SunColor = SunColor; + InitShaderUniform( + &Element->Program, + UniformIndex++, + + + + Element->SunColor, + "SunColor" + + + ); + + + + Element->FogColor = FogColor; + InitShaderUniform( + &Element->Program, + UniformIndex++, + + + + Element->FogColor, + "FogColor" + + + ); + + + + Element->FogPower = FogPower; + InitShaderUniform( + &Element->Program, + UniformIndex++, + + + + Element->FogPower, + "FogPower" + + + ); + + + + Element->UseSsao = UseSsao; + InitShaderUniform( + &Element->Program, + UniformIndex++, + + + + Element->UseSsao, + "UseSsao" + + + ); + + + + Element->UseShadowMapping = UseShadowMapping; + InitShaderUniform( + &Element->Program, + UniformIndex++, + + + + Element->UseShadowMapping, + "UseShadowMapping" + + + ); + + + + Element->UseLightingBloom = UseLightingBloom; + InitShaderUniform( + &Element->Program, + UniformIndex++, + + + + Element->UseLightingBloom, + "UseLightingBloom" + + + ); + + + + Element->ApplicationResolution = ApplicationResolution; + InitShaderUniform( + &Element->Program, + UniformIndex++, + + + + Element->ApplicationResolution, + "ApplicationResolution" + + + ); + + + + Element->ShadowMapResolution = ShadowMapResolution; + InitShaderUniform( + &Element->Program, + UniformIndex++, + + + + Element->ShadowMapResolution, + "ShadowMapResolution" + + + ); + + + + + + + + u32 Expected = 26 ; + if (UniformIndex != Expected ) + { + Error("Shader (lighting_render_group) had an incorrect number of uniform slots! Expected (%d), Got (%d)", Expected, UniformIndex); + } + } + + + + AssertNoGlErrors; + return Result; +} + +link_internal void +UseRenderPass_lighting_render_group +( lighting_render_group *Element ) +{ + TIMED_FUNCTION(); + if (Element->Program.ID != INVALID_SHADER) + { + { + TIMED_NAMED_BLOCK(UseProgram); + GetGL()->UseProgram(Element->Program.ID); + } + + { + TIMED_NAMED_BLOCK(BindUniforms); + s32 TextureUnit = 0; + s32 UniformIndex = 0; + + + + { + shader_uniform *Uniform = Element->Uniforms+UniformIndex; + BindUniformById(Uniform, &TextureUnit); + ++UniformIndex; + AssertNoGlErrors; + } + + + { + shader_uniform *Uniform = Element->Uniforms+UniformIndex; + BindUniformById(Uniform, &TextureUnit); + ++UniformIndex; + AssertNoGlErrors; + } + + + { + shader_uniform *Uniform = Element->Uniforms+UniformIndex; + BindUniformById(Uniform, &TextureUnit); + ++UniformIndex; + AssertNoGlErrors; + } + + + { + shader_uniform *Uniform = Element->Uniforms+UniformIndex; + BindUniformById(Uniform, &TextureUnit); + ++UniformIndex; + AssertNoGlErrors; + } + + + { + shader_uniform *Uniform = Element->Uniforms+UniformIndex; + BindUniformById(Uniform, &TextureUnit); + ++UniformIndex; + AssertNoGlErrors; + } + + + { + shader_uniform *Uniform = Element->Uniforms+UniformIndex; + BindUniformById(Uniform, &TextureUnit); + ++UniformIndex; + AssertNoGlErrors; + } + + + { + shader_uniform *Uniform = Element->Uniforms+UniformIndex; + BindUniformById(Uniform, &TextureUnit); + ++UniformIndex; + AssertNoGlErrors; + } + + + { + shader_uniform *Uniform = Element->Uniforms+UniformIndex; + BindUniformById(Uniform, &TextureUnit); + ++UniformIndex; + AssertNoGlErrors; + } + + + { + shader_uniform *Uniform = Element->Uniforms+UniformIndex; + BindUniformById(Uniform, &TextureUnit); + ++UniformIndex; + AssertNoGlErrors; + } + + + { + shader_uniform *Uniform = Element->Uniforms+UniformIndex; + BindUniformById(Uniform, &TextureUnit); + ++UniformIndex; + AssertNoGlErrors; + } + + + { + shader_uniform *Uniform = Element->Uniforms+UniformIndex; + BindUniformById(Uniform, &TextureUnit); + ++UniformIndex; + AssertNoGlErrors; + } + + + { + shader_uniform *Uniform = Element->Uniforms+UniformIndex; + BindUniformById(Uniform, &TextureUnit); + ++UniformIndex; + AssertNoGlErrors; + } + + + { + shader_uniform *Uniform = Element->Uniforms+UniformIndex; + BindUniformById(Uniform, &TextureUnit); + ++UniformIndex; + AssertNoGlErrors; + } + + + { + shader_uniform *Uniform = Element->Uniforms+UniformIndex; + BindUniformById(Uniform, &TextureUnit); + ++UniformIndex; + AssertNoGlErrors; + } + + + { + shader_uniform *Uniform = Element->Uniforms+UniformIndex; + BindUniformById(Uniform, &TextureUnit); + ++UniformIndex; + AssertNoGlErrors; + } + + + { + shader_uniform *Uniform = Element->Uniforms+UniformIndex; + BindUniformById(Uniform, &TextureUnit); + ++UniformIndex; + AssertNoGlErrors; + } + + + { + shader_uniform *Uniform = Element->Uniforms+UniformIndex; + BindUniformById(Uniform, &TextureUnit); + ++UniformIndex; + AssertNoGlErrors; + } + + + { + shader_uniform *Uniform = Element->Uniforms+UniformIndex; + BindUniformById(Uniform, &TextureUnit); + ++UniformIndex; + AssertNoGlErrors; + } + + + { + shader_uniform *Uniform = Element->Uniforms+UniformIndex; + BindUniformById(Uniform, &TextureUnit); + ++UniformIndex; + AssertNoGlErrors; + } + + + { + shader_uniform *Uniform = Element->Uniforms+UniformIndex; + BindUniformById(Uniform, &TextureUnit); + ++UniformIndex; + AssertNoGlErrors; + } + + + { + shader_uniform *Uniform = Element->Uniforms+UniformIndex; + BindUniformById(Uniform, &TextureUnit); + ++UniformIndex; + AssertNoGlErrors; + } + + + { + shader_uniform *Uniform = Element->Uniforms+UniformIndex; + BindUniformById(Uniform, &TextureUnit); + ++UniformIndex; + AssertNoGlErrors; + } + + + { + shader_uniform *Uniform = Element->Uniforms+UniformIndex; + BindUniformById(Uniform, &TextureUnit); + ++UniformIndex; + AssertNoGlErrors; + } + + + { + shader_uniform *Uniform = Element->Uniforms+UniformIndex; + BindUniformById(Uniform, &TextureUnit); + ++UniformIndex; + AssertNoGlErrors; + } + + + { + shader_uniform *Uniform = Element->Uniforms+UniformIndex; + BindUniformById(Uniform, &TextureUnit); + ++UniformIndex; + AssertNoGlErrors; + } + + + { + shader_uniform *Uniform = Element->Uniforms+UniformIndex; + BindUniformById(Uniform, &TextureUnit); + ++UniformIndex; + AssertNoGlErrors; + } + + + + + + + if (UniformIndex != 26 ) + { + Error("Shader (lighting_render_group) had an incorrect number of uniform slots!"); + } + } + } + else + { + SoftError("Attempted to bind uncompiled Shader (BONSAI_SHADER_PATH \"Lighting.vertexshader\") | (BONSAI_SHADER_PATH \"Lighting.fragmentshader\")"); + } + + AssertNoGlErrors; +} + +// NOTE(Jesse): This is for binding when passing a custom RP through the UI +link_internal void +UseRenderPass_lighting_render_group( void *Element ) +{ + UseRenderPass_lighting_render_group( Cast(lighting_render_group *, Element) ); +} + +link_internal void +UseRenderPass( lighting_render_group *Element ) +{ + UseRenderPass_lighting_render_group(Element); +} + +// TODO(Jesse): Remove in favor of UseRenderPass +link_internal void +UseShader( lighting_render_group *Element ) +{ + UseRenderPass_lighting_render_group(Element); +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +link_internal b32 +poof() +InitializeTerrainDecorationRenderContext +( + terrain_decoration_render_context *Element + + + + + , texture *DerivsTex + , v3 ChunkDim + , v3 WorldspaceChunkBasis + , v3 ChunkResolution + +) +{ + b32 Result = CompileShaderPair(&Element->Program, CSz("external/bonsai_stdlib/shaders/Passthrough.vertexshader"), CSz("shaders/terrain/decoration/default.fragmentshader")); + + if (Result) + { + Element->Program.Uniforms = ShaderUniformBuffer(Element->Uniforms, ArrayCount(Element->Uniforms)); + + u32 UniformIndex = 0; + + + + + + Element->DerivsTex = DerivsTex; + InitShaderUniform( + &Element->Program, + UniformIndex++, + + + + Element->DerivsTex, + "DerivsTex" + + + ); + + + + Element->ChunkDim = ChunkDim; + InitShaderUniform( + &Element->Program, + UniformIndex++, + + + + &Element->ChunkDim, + "ChunkDim" + + + ); + + + + Element->WorldspaceChunkBasis = WorldspaceChunkBasis; + InitShaderUniform( + &Element->Program, + UniformIndex++, + + + + &Element->WorldspaceChunkBasis, + "WorldspaceChunkBasis" + + + ); + + + + Element->ChunkResolution = ChunkResolution; + InitShaderUniform( + &Element->Program, + UniformIndex++, + + + + &Element->ChunkResolution, + "ChunkResolution" + + + ); + + + + + + u32 Expected = 4 ; + if (UniformIndex != Expected ) + { + Error("Shader (terrain_decoration_render_context) had an incorrect number of uniform slots! Expected (%d), Got (%d)", Expected, UniformIndex); + } + } + + + + AssertNoGlErrors; + return Result; +} + +link_internal void +UseRenderPass_terrain_decoration_render_context +( terrain_decoration_render_context *Element ) +{ + TIMED_FUNCTION(); + if (Element->Program.ID != INVALID_SHADER) + { + { + TIMED_NAMED_BLOCK(UseProgram); + GetGL()->UseProgram(Element->Program.ID); + } + + { + TIMED_NAMED_BLOCK(BindUniforms); + s32 TextureUnit = 0; + s32 UniformIndex = 0; + + + + + { + shader_uniform *Uniform = Element->Uniforms+UniformIndex; + BindUniformById(Uniform, &TextureUnit); + ++UniformIndex; + AssertNoGlErrors; + } + + + { + shader_uniform *Uniform = Element->Uniforms+UniformIndex; + BindUniformById(Uniform, &TextureUnit); + ++UniformIndex; + AssertNoGlErrors; + } + + + { + shader_uniform *Uniform = Element->Uniforms+UniformIndex; + BindUniformById(Uniform, &TextureUnit); + ++UniformIndex; + AssertNoGlErrors; + } + + + { + shader_uniform *Uniform = Element->Uniforms+UniformIndex; + BindUniformById(Uniform, &TextureUnit); + ++UniformIndex; + AssertNoGlErrors; + } + + + + + if (UniformIndex != 4 ) + { + Error("Shader (terrain_decoration_render_context) had an incorrect number of uniform slots!"); + } + } + } + else + { + SoftError("Attempted to bind uncompiled Shader (\"external/bonsai_stdlib/shaders/Passthrough.vertexshader\") | (\"shaders/terrain/decoration/default.fragmentshader\")"); + } + + AssertNoGlErrors; +} + +// NOTE(Jesse): This is for binding when passing a custom RP through the UI +link_internal void +UseRenderPass_terrain_decoration_render_context( void *Element ) +{ + UseRenderPass_terrain_decoration_render_context( Cast(terrain_decoration_render_context *, Element) ); +} + +link_internal void +UseRenderPass( terrain_decoration_render_context *Element ) +{ + UseRenderPass_terrain_decoration_render_context(Element); +} + +// TODO(Jesse): Remove in favor of UseRenderPass +link_internal void +UseShader( terrain_decoration_render_context *Element ) +{ + UseRenderPass_terrain_decoration_render_context(Element); +} + + + + + + + + + + + + + + +link_internal b32 +poof() +InitializeTerrainFinalizeRenderContext +( + terrain_finalize_render_context *Element + + + + + , u32 Ignored + +) +{ + b32 Result = CompileShaderPair(&Element->Program, CSz("external/bonsai_stdlib/shaders/Passthrough.vertexshader"), CSz("shaders/terrain/TerrainFinalize.fragmentshader")); + + if (Result) + { + Element->Program.Uniforms = ShaderUniformBuffer(Element->Uniforms, ArrayCount(Element->Uniforms)); + + u32 UniformIndex = 0; + + + + + + Element->Ignored = Ignored; + InitShaderUniform( + &Element->Program, + UniformIndex++, + + + + &Element->Ignored, + "Ignored" + + + ); + + + + + + u32 Expected = 1 ; + if (UniformIndex != Expected ) + { + Error("Shader (terrain_finalize_render_context) had an incorrect number of uniform slots! Expected (%d), Got (%d)", Expected, UniformIndex); + } + } + + + + AssertNoGlErrors; + return Result; +} + +link_internal void +UseRenderPass_terrain_finalize_render_context +( terrain_finalize_render_context *Element ) +{ + TIMED_FUNCTION(); + if (Element->Program.ID != INVALID_SHADER) + { + { + TIMED_NAMED_BLOCK(UseProgram); + GetGL()->UseProgram(Element->Program.ID); + } + + { + TIMED_NAMED_BLOCK(BindUniforms); + s32 TextureUnit = 0; + s32 UniformIndex = 0; + + + + + { + shader_uniform *Uniform = Element->Uniforms+UniformIndex; + BindUniformById(Uniform, &TextureUnit); + ++UniformIndex; + AssertNoGlErrors; + } + + + + + if (UniformIndex != 1 ) + { + Error("Shader (terrain_finalize_render_context) had an incorrect number of uniform slots!"); + } + } + } + else + { + SoftError("Attempted to bind uncompiled Shader (\"external/bonsai_stdlib/shaders/Passthrough.vertexshader\") | (\"shaders/terrain/TerrainFinalize.fragmentshader\")"); + } + + AssertNoGlErrors; +} + +// NOTE(Jesse): This is for binding when passing a custom RP through the UI +link_internal void +UseRenderPass_terrain_finalize_render_context( void *Element ) +{ + UseRenderPass_terrain_finalize_render_context( Cast(terrain_finalize_render_context *, Element) ); +} + +link_internal void +UseRenderPass( terrain_finalize_render_context *Element ) +{ + UseRenderPass_terrain_finalize_render_context(Element); +} + +// TODO(Jesse): Remove in favor of UseRenderPass +link_internal void +UseShader( terrain_finalize_render_context *Element ) +{ + UseRenderPass_terrain_finalize_render_context(Element); +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +link_internal b32 +poof() +InitializeWorldEditRenderContext +( + world_edit_render_context *Element + + + + + , v3 *ChunkDim + , v3 *WorldspaceChunkBasis + , v3 *ChunkResolution + , s32 Type + +) +{ + b32 Result = CompileShaderPair(&Element->Program, CSz("external/bonsai_stdlib/shaders/Passthrough.vertexshader"), CSz("shaders/terrain/world_edit.fragmentshader")); + + if (Result) + { + Element->Program.Uniforms = ShaderUniformBuffer(Element->Uniforms, ArrayCount(Element->Uniforms)); + + u32 UniformIndex = 0; + + + + + + Element->ChunkDim = ChunkDim; + InitShaderUniform( + &Element->Program, + UniformIndex++, + + + + Element->ChunkDim, + "ChunkDim" + + + ); + + + + Element->WorldspaceChunkBasis = WorldspaceChunkBasis; + InitShaderUniform( + &Element->Program, + UniformIndex++, + + + + Element->WorldspaceChunkBasis, + "WorldspaceChunkBasis" + + + ); + + + + Element->ChunkResolution = ChunkResolution; + InitShaderUniform( + &Element->Program, + UniformIndex++, + + + + Element->ChunkResolution, + "ChunkResolution" + + + ); + + + + Element->Type = Type; + InitShaderUniform( + &Element->Program, + UniformIndex++, + + + + &Element->Type, + "Type" + + + ); + + + + + + u32 Expected = 4 ; + if (UniformIndex != Expected ) + { + Error("Shader (world_edit_render_context) had an incorrect number of uniform slots! Expected (%d), Got (%d)", Expected, UniformIndex); + } + } + + + + AssertNoGlErrors; + return Result; +} + +link_internal void +UseRenderPass_world_edit_render_context +( world_edit_render_context *Element ) +{ + TIMED_FUNCTION(); + if (Element->Program.ID != INVALID_SHADER) + { + { + TIMED_NAMED_BLOCK(UseProgram); + GetGL()->UseProgram(Element->Program.ID); + } + + { + TIMED_NAMED_BLOCK(BindUniforms); + s32 TextureUnit = 0; + s32 UniformIndex = 0; + + + + + { + shader_uniform *Uniform = Element->Uniforms+UniformIndex; + BindUniformById(Uniform, &TextureUnit); + ++UniformIndex; + AssertNoGlErrors; + } + + + { + shader_uniform *Uniform = Element->Uniforms+UniformIndex; + BindUniformById(Uniform, &TextureUnit); + ++UniformIndex; + AssertNoGlErrors; + } + + + { + shader_uniform *Uniform = Element->Uniforms+UniformIndex; + BindUniformById(Uniform, &TextureUnit); + ++UniformIndex; + AssertNoGlErrors; + } + + + { + shader_uniform *Uniform = Element->Uniforms+UniformIndex; + BindUniformById(Uniform, &TextureUnit); + ++UniformIndex; + AssertNoGlErrors; + } + + + + + if (UniformIndex != 4 ) + { + Error("Shader (world_edit_render_context) had an incorrect number of uniform slots!"); + } + } + } + else + { + SoftError("Attempted to bind uncompiled Shader (\"external/bonsai_stdlib/shaders/Passthrough.vertexshader\") | (\"shaders/terrain/world_edit.fragmentshader\")"); + } + + AssertNoGlErrors; +} + +// NOTE(Jesse): This is for binding when passing a custom RP through the UI +link_internal void +UseRenderPass_world_edit_render_context( void *Element ) +{ + UseRenderPass_world_edit_render_context( Cast(world_edit_render_context *, Element) ); +} + +link_internal void +UseRenderPass( world_edit_render_context *Element ) +{ + UseRenderPass_world_edit_render_context(Element); +} + +// TODO(Jesse): Remove in favor of UseRenderPass +link_internal void +UseShader( world_edit_render_context *Element ) +{ + UseRenderPass_world_edit_render_context(Element); +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +link_internal b32 +poof(@async @render) +InitializeEasingFunctionVisualizerRenderPass +( + easing_function_visualizer_render_pass *Element + + + , easing_function *Func + +) +{ + b32 Result = CompileShaderPair(&Element->Program, CSz(STDLIB_SHADER_PATH "FullPassthrough.vertexshader"), CSz(BONSAI_SHADER_PATH "curve_remap_visualizer.fragmentshader")); + + if (Result) + { + Element->Program.Uniforms = ShaderUniformBuffer(Element->Uniforms, ArrayCount(Element->Uniforms)); + + u32 UniformIndex = 0; + + + + Element->Func = Func; + InitShaderUniform( + &Element->Program, + UniformIndex++, + + + + Element->Func->Points.Start, + "Points", + &Element->Func->Points.At + + ); + + + Element->Func = Func; + InitShaderUniform( + &Element->Program, + UniformIndex++, + + + + &Element->Func->Points.At, + "Count", + 0 + + ); + + + + + + u32 Expected = 2 ; + if (UniformIndex != Expected ) + { + Error("Shader (easing_function_visualizer_render_pass) had an incorrect number of uniform slots! Expected (%d), Got (%d)", Expected, UniformIndex); + } + } + + + + AssertNoGlErrors; + return Result; +} + +link_internal void +UseRenderPass_easing_function_visualizer_render_pass +( easing_function_visualizer_render_pass *Element ) +{ + TIMED_FUNCTION(); + if (Element->Program.ID != INVALID_SHADER) + { + { + TIMED_NAMED_BLOCK(UseProgram); + GetGL()->UseProgram(Element->Program.ID); + } + + { + TIMED_NAMED_BLOCK(BindUniforms); + s32 TextureUnit = 0; + s32 UniformIndex = 0; + + + { + shader_uniform *Uniform = Element->Uniforms+UniformIndex; + BindUniformById(Uniform, &TextureUnit); + ++UniformIndex; + AssertNoGlErrors; + } + + { + shader_uniform *Uniform = Element->Uniforms+UniformIndex; + BindUniformById(Uniform, &TextureUnit); + ++UniformIndex; + AssertNoGlErrors; + } + + + + + if (UniformIndex != 2 ) + { + Error("Shader (easing_function_visualizer_render_pass) had an incorrect number of uniform slots!"); + } + } + } + else + { + SoftError("Attempted to bind uncompiled Shader (STDLIB_SHADER_PATH \"FullPassthrough.vertexshader\") | (BONSAI_SHADER_PATH \"curve_remap_visualizer.fragmentshader\")"); + } + + AssertNoGlErrors; +} + +// NOTE(Jesse): This is for binding when passing a custom RP through the UI +link_internal void +UseRenderPass_easing_function_visualizer_render_pass( void *Element ) +{ + UseRenderPass_easing_function_visualizer_render_pass( Cast(easing_function_visualizer_render_pass *, Element) ); +} + +link_internal void +UseRenderPass( easing_function_visualizer_render_pass *Element ) +{ + UseRenderPass_easing_function_visualizer_render_pass(Element); +} + +// TODO(Jesse): Remove in favor of UseRenderPass +link_internal void +UseShader( easing_function_visualizer_render_pass *Element ) +{ + UseRenderPass_easing_function_visualizer_render_pass(Element); +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +link_internal b32 +poof() +InitializeShadowMapShader +( + shadow_map_shader *Element + + + , m4 ModelMatrix + , m4 ViewProjection + , v3 *MinClipP_worldspace + , v3 *MaxClipP_worldspace + +) +{ + b32 Result = CompileShaderPair(&Element->Program, CSz("shaders/DepthRTT.vertexshader"), CSz("shaders/DepthRTT.fragmentshader")); + + if (Result) + { + Element->Program.Uniforms = ShaderUniformBuffer(Element->Uniforms, ArrayCount(Element->Uniforms)); + + u32 UniformIndex = 0; + + + + Element->ModelMatrix = ModelMatrix; + InitShaderUniform( + &Element->Program, + UniformIndex++, + + + + &Element->ModelMatrix, + "ModelMatrix" + + + ); + + + + Element->ViewProjection = ViewProjection; + InitShaderUniform( + &Element->Program, + UniformIndex++, + + + + &Element->ViewProjection, + "ViewProjection" + + + ); + + + + Element->MinClipP_worldspace = MinClipP_worldspace; + InitShaderUniform( + &Element->Program, + UniformIndex++, + + + + Element->MinClipP_worldspace, + "MinClipP_worldspace" + + + ); + + + + Element->MaxClipP_worldspace = MaxClipP_worldspace; + InitShaderUniform( + &Element->Program, + UniformIndex++, + + + + Element->MaxClipP_worldspace, + "MaxClipP_worldspace" + + + ); + + + + + + u32 Expected = 4 ; + if (UniformIndex != Expected ) + { + Error("Shader (shadow_map_shader) had an incorrect number of uniform slots! Expected (%d), Got (%d)", Expected, UniformIndex); + } + } + + + + AssertNoGlErrors; + return Result; +} + +link_internal void +UseRenderPass_shadow_map_shader +( shadow_map_shader *Element ) +{ + TIMED_FUNCTION(); + if (Element->Program.ID != INVALID_SHADER) + { + { + TIMED_NAMED_BLOCK(UseProgram); + GetGL()->UseProgram(Element->Program.ID); + } + + { + TIMED_NAMED_BLOCK(BindUniforms); + s32 TextureUnit = 0; + s32 UniformIndex = 0; + + + { + shader_uniform *Uniform = Element->Uniforms+UniformIndex; + BindUniformById(Uniform, &TextureUnit); + ++UniformIndex; + AssertNoGlErrors; + } + + + { + shader_uniform *Uniform = Element->Uniforms+UniformIndex; + BindUniformById(Uniform, &TextureUnit); + ++UniformIndex; + AssertNoGlErrors; + } + + + { + shader_uniform *Uniform = Element->Uniforms+UniformIndex; + BindUniformById(Uniform, &TextureUnit); + ++UniformIndex; + AssertNoGlErrors; + } + + + { + shader_uniform *Uniform = Element->Uniforms+UniformIndex; + BindUniformById(Uniform, &TextureUnit); + ++UniformIndex; + AssertNoGlErrors; + } + + + + + if (UniformIndex != 4 ) + { + Error("Shader (shadow_map_shader) had an incorrect number of uniform slots!"); + } + } + } + else + { + SoftError("Attempted to bind uncompiled Shader (\"shaders/DepthRTT.vertexshader\") | (\"shaders/DepthRTT.fragmentshader\")"); + } + + AssertNoGlErrors; +} + +// NOTE(Jesse): This is for binding when passing a custom RP through the UI +link_internal void +UseRenderPass_shadow_map_shader( void *Element ) +{ + UseRenderPass_shadow_map_shader( Cast(shadow_map_shader *, Element) ); +} + +link_internal void +UseRenderPass( shadow_map_shader *Element ) +{ + UseRenderPass_shadow_map_shader(Element); +} + +// TODO(Jesse): Remove in favor of UseRenderPass +link_internal void +UseShader( shadow_map_shader *Element ) +{ + UseRenderPass_shadow_map_shader(Element); +} + + + +link_internal b32 +poof() +InitializeBloomUpsampleShader +( + bloom_upsample_shader *Element + + + , f32 *FilterRadius + +) +{ + b32 Result = CompileShaderPair(&Element->Program, CSz("external/bonsai_stdlib/shaders/Passthrough.vertexshader"), CSz("shaders/bloom_upsample.fragmentshader")); + + if (Result) + { + Element->Program.Uniforms = ShaderUniformBuffer(Element->Uniforms, ArrayCount(Element->Uniforms)); + + u32 UniformIndex = 0; + + + + Element->FilterRadius = FilterRadius; + InitShaderUniform( + &Element->Program, + UniformIndex++, + + + + Element->FilterRadius, + "FilterRadius" + + + ); + + + + + + u32 Expected = 1 ; + if (UniformIndex != Expected ) + { + Error("Shader (bloom_upsample_shader) had an incorrect number of uniform slots! Expected (%d), Got (%d)", Expected, UniformIndex); + } + } + + + + AssertNoGlErrors; + return Result; +} + +link_internal void +UseRenderPass_bloom_upsample_shader +( bloom_upsample_shader *Element ) +{ + TIMED_FUNCTION(); + if (Element->Program.ID != INVALID_SHADER) + { + { + TIMED_NAMED_BLOCK(UseProgram); + GetGL()->UseProgram(Element->Program.ID); + } + + { + TIMED_NAMED_BLOCK(BindUniforms); + s32 TextureUnit = 0; + s32 UniformIndex = 0; + + + { + shader_uniform *Uniform = Element->Uniforms+UniformIndex; + BindUniformById(Uniform, &TextureUnit); + ++UniformIndex; + AssertNoGlErrors; + } + + + + + if (UniformIndex != 1 ) + { + Error("Shader (bloom_upsample_shader) had an incorrect number of uniform slots!"); + } + } + } + else + { + SoftError("Attempted to bind uncompiled Shader (\"external/bonsai_stdlib/shaders/Passthrough.vertexshader\") | (\"shaders/bloom_upsample.fragmentshader\")"); + } + + AssertNoGlErrors; +} + +// NOTE(Jesse): This is for binding when passing a custom RP through the UI +link_internal void +UseRenderPass_bloom_upsample_shader( void *Element ) +{ + UseRenderPass_bloom_upsample_shader( Cast(bloom_upsample_shader *, Element) ); +} + +link_internal void +UseRenderPass( bloom_upsample_shader *Element ) +{ + UseRenderPass_bloom_upsample_shader(Element); +} + +// TODO(Jesse): Remove in favor of UseRenderPass +link_internal void +UseShader( bloom_upsample_shader *Element ) +{ + UseRenderPass_bloom_upsample_shader(Element); +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +link_internal b32 +poof() +InitializeTerrainDerivsRenderContext +( + terrain_derivs_render_context *Element + + + + + , v3 Ignored + +) +{ + b32 Result = CompileShaderPair(&Element->Program, CSz("external/bonsai_stdlib/shaders/Passthrough.vertexshader"), CSz("shaders/terrain/derivs.fragmentshader")); + + if (Result) + { + Element->Program.Uniforms = ShaderUniformBuffer(Element->Uniforms, ArrayCount(Element->Uniforms)); + + u32 UniformIndex = 0; + + + + + + Element->Ignored = Ignored; + InitShaderUniform( + &Element->Program, + UniformIndex++, + + + + &Element->Ignored, + "Ignored" + + + ); + + + + + + u32 Expected = 1 ; + if (UniformIndex != Expected ) + { + Error("Shader (terrain_derivs_render_context) had an incorrect number of uniform slots! Expected (%d), Got (%d)", Expected, UniformIndex); + } + } + + + + AssertNoGlErrors; + return Result; +} + +link_internal void +UseRenderPass_terrain_derivs_render_context +( terrain_derivs_render_context *Element ) +{ + TIMED_FUNCTION(); + if (Element->Program.ID != INVALID_SHADER) + { + { + TIMED_NAMED_BLOCK(UseProgram); + GetGL()->UseProgram(Element->Program.ID); + } + + { + TIMED_NAMED_BLOCK(BindUniforms); + s32 TextureUnit = 0; + s32 UniformIndex = 0; + + + + + { + shader_uniform *Uniform = Element->Uniforms+UniformIndex; + BindUniformById(Uniform, &TextureUnit); + ++UniformIndex; + AssertNoGlErrors; + } + + + + + if (UniformIndex != 1 ) + { + Error("Shader (terrain_derivs_render_context) had an incorrect number of uniform slots!"); + } + } + } + else + { + SoftError("Attempted to bind uncompiled Shader (\"external/bonsai_stdlib/shaders/Passthrough.vertexshader\") | (\"shaders/terrain/derivs.fragmentshader\")"); + } + + AssertNoGlErrors; +} + +// NOTE(Jesse): This is for binding when passing a custom RP through the UI +link_internal void +UseRenderPass_terrain_derivs_render_context( void *Element ) +{ + UseRenderPass_terrain_derivs_render_context( Cast(terrain_derivs_render_context *, Element) ); +} + +link_internal void +UseRenderPass( terrain_derivs_render_context *Element ) +{ + UseRenderPass_terrain_derivs_render_context(Element); +} + +// TODO(Jesse): Remove in favor of UseRenderPass +link_internal void +UseShader( terrain_derivs_render_context *Element ) +{ + UseRenderPass_terrain_derivs_render_context(Element); +} + + + + + + + + + + + + + + + + + + + + +link_internal b32 +poof() +InitializeBloomDownsampleShader +( + bloom_downsample_shader *Element + + + , v2 *SrcResolution + +) +{ + b32 Result = CompileShaderPair(&Element->Program, CSz("external/bonsai_stdlib/shaders/Passthrough.vertexshader"), CSz("shaders/bloom_downsample.fragmentshader")); + + if (Result) + { + Element->Program.Uniforms = ShaderUniformBuffer(Element->Uniforms, ArrayCount(Element->Uniforms)); + + u32 UniformIndex = 0; + + + + Element->SrcResolution = SrcResolution; + InitShaderUniform( + &Element->Program, + UniformIndex++, + + + + Element->SrcResolution, + "SrcResolution" + + + ); + + + + + + u32 Expected = 1 ; + if (UniformIndex != Expected ) + { + Error("Shader (bloom_downsample_shader) had an incorrect number of uniform slots! Expected (%d), Got (%d)", Expected, UniformIndex); + } + } + + + + AssertNoGlErrors; + return Result; +} + +link_internal void +UseRenderPass_bloom_downsample_shader +( bloom_downsample_shader *Element ) +{ + TIMED_FUNCTION(); + if (Element->Program.ID != INVALID_SHADER) + { + { + TIMED_NAMED_BLOCK(UseProgram); + GetGL()->UseProgram(Element->Program.ID); + } + + { + TIMED_NAMED_BLOCK(BindUniforms); + s32 TextureUnit = 0; + s32 UniformIndex = 0; + + + { + shader_uniform *Uniform = Element->Uniforms+UniformIndex; + BindUniformById(Uniform, &TextureUnit); + ++UniformIndex; + AssertNoGlErrors; + } + + + + + if (UniformIndex != 1 ) + { + Error("Shader (bloom_downsample_shader) had an incorrect number of uniform slots!"); + } + } + } + else + { + SoftError("Attempted to bind uncompiled Shader (\"external/bonsai_stdlib/shaders/Passthrough.vertexshader\") | (\"shaders/bloom_downsample.fragmentshader\")"); + } + + AssertNoGlErrors; +} + +// NOTE(Jesse): This is for binding when passing a custom RP through the UI +link_internal void +UseRenderPass_bloom_downsample_shader( void *Element ) +{ + UseRenderPass_bloom_downsample_shader( Cast(bloom_downsample_shader *, Element) ); +} + +link_internal void +UseRenderPass( bloom_downsample_shader *Element ) +{ + UseRenderPass_bloom_downsample_shader(Element); +} + +// TODO(Jesse): Remove in favor of UseRenderPass +link_internal void +UseShader( bloom_downsample_shader *Element ) +{ + UseRenderPass_bloom_downsample_shader(Element); +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +link_internal b32 +poof() +InitializeTerrainShapingRenderContext +( + terrain_shaping_render_context *Element + + + + + , v3 ChunkDim + , v3 WorldspaceChunkBasis + , v3 ChunkResolution + , easing_function ReshapeFunc + +) +{ + b32 Result = CompileShaderPair(&Element->Program, CSz("external/bonsai_stdlib/shaders/Passthrough.vertexshader"), CSz("shaders/terrain/shaping/default.fragmentshader")); + + if (Result) + { + Element->Program.Uniforms = ShaderUniformBuffer(Element->Uniforms, ArrayCount(Element->Uniforms)); + + u32 UniformIndex = 0; + + + + + + Element->ChunkDim = ChunkDim; + InitShaderUniform( + &Element->Program, + UniformIndex++, + + + + &Element->ChunkDim, + "ChunkDim" + + + ); + + + + Element->WorldspaceChunkBasis = WorldspaceChunkBasis; + InitShaderUniform( + &Element->Program, + UniformIndex++, + + + + &Element->WorldspaceChunkBasis, + "WorldspaceChunkBasis" + + + ); + + + + Element->ChunkResolution = ChunkResolution; + InitShaderUniform( + &Element->Program, + UniformIndex++, + + + + &Element->ChunkResolution, + "ChunkResolution" + + + ); + + + + Element->ReshapeFunc = ReshapeFunc; + InitShaderUniform( + &Element->Program, + UniformIndex++, + + + + Element->ReshapeFunc.Points.Start, + "SampleRemapCurvePoints", + &Element->ReshapeFunc.Points.At + + ); + + + Element->ReshapeFunc = ReshapeFunc; + InitShaderUniform( + &Element->Program, + UniformIndex++, + + + + &Element->ReshapeFunc.Points.At, + "SampleRemapCurvePointCount", + 0 + + ); + + + + + + u32 Expected = 5 ; + if (UniformIndex != Expected ) + { + Error("Shader (terrain_shaping_render_context) had an incorrect number of uniform slots! Expected (%d), Got (%d)", Expected, UniformIndex); + } + } + + + + AssertNoGlErrors; + return Result; +} + +link_internal void +UseRenderPass_terrain_shaping_render_context +( terrain_shaping_render_context *Element ) +{ + TIMED_FUNCTION(); + if (Element->Program.ID != INVALID_SHADER) + { + { + TIMED_NAMED_BLOCK(UseProgram); + GetGL()->UseProgram(Element->Program.ID); + } + + { + TIMED_NAMED_BLOCK(BindUniforms); + s32 TextureUnit = 0; + s32 UniformIndex = 0; + + + + + { + shader_uniform *Uniform = Element->Uniforms+UniformIndex; + BindUniformById(Uniform, &TextureUnit); + ++UniformIndex; + AssertNoGlErrors; + } + + + { + shader_uniform *Uniform = Element->Uniforms+UniformIndex; + BindUniformById(Uniform, &TextureUnit); + ++UniformIndex; + AssertNoGlErrors; + } + + + { + shader_uniform *Uniform = Element->Uniforms+UniformIndex; + BindUniformById(Uniform, &TextureUnit); + ++UniformIndex; + AssertNoGlErrors; + } + + + { + shader_uniform *Uniform = Element->Uniforms+UniformIndex; + BindUniformById(Uniform, &TextureUnit); + ++UniformIndex; + AssertNoGlErrors; + } + + { + shader_uniform *Uniform = Element->Uniforms+UniformIndex; + BindUniformById(Uniform, &TextureUnit); + ++UniformIndex; + AssertNoGlErrors; + } + + + + + if (UniformIndex != 5 ) + { + Error("Shader (terrain_shaping_render_context) had an incorrect number of uniform slots!"); + } + } + } + else + { + SoftError("Attempted to bind uncompiled Shader (\"external/bonsai_stdlib/shaders/Passthrough.vertexshader\") | (\"shaders/terrain/shaping/default.fragmentshader\")"); + } + + AssertNoGlErrors; +} + +// NOTE(Jesse): This is for binding when passing a custom RP through the UI +link_internal void +UseRenderPass_terrain_shaping_render_context( void *Element ) +{ + UseRenderPass_terrain_shaping_render_context( Cast(terrain_shaping_render_context *, Element) ); +} + +link_internal void +UseRenderPass( terrain_shaping_render_context *Element ) +{ + UseRenderPass_terrain_shaping_render_context(Element); +} + +// TODO(Jesse): Remove in favor of UseRenderPass +link_internal void +UseShader( terrain_shaping_render_context *Element ) +{ + UseRenderPass_terrain_shaping_render_context(Element); +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/generated/for_datatypes_cx51CcgQ.h b/generated/for_datatypes_cx51CcgQ.h new file mode 100644 index 000000000..6b510d934 --- /dev/null +++ b/generated/for_datatypes_cx51CcgQ.h @@ -0,0 +1,2103 @@ +// src/engine/work_queue.h:273:0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +link_internal void +FinalizeShitAndFuckinDoStuff_Async(work_queue *Queue, gen_chunk *GenChunk , octree_node *DestNode ) +{ + // Make sure we don't accidentally pass something that's not the render queue + Assert(Queue == &GetStdlib()->Plat.LoRenderQ); + + finalize_shit_and_fuckin_do_stuff_async_params Params = + { + GenChunk, DestNode, + }; + + work_queue_entry Entry = WorkQueueEntryAsyncFunction(&Params); + PushWorkQueueEntry(Queue, &Entry); +} + +link_internal void +DoJob(finalize_shit_and_fuckin_do_stuff_async_params *Params) +{ + FinalizeShitAndFuckinDoStuff( Params->GenChunk , Params->DestNode ); + +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +link_internal void +CompileShaderPair_Async(work_queue *Queue, shader *Shader , cs VertShaderPath , cs FragShaderPath , b32 DumpErrors , b32 RegisterForHotReload , b32* Result ) +{ + // Make sure we don't accidentally pass something that's not the render queue + Assert(Queue == &GetStdlib()->Plat.LoRenderQ); + + compile_shader_pair_async_params Params = + { + Result, Shader, VertShaderPath, FragShaderPath, DumpErrors, RegisterForHotReload, + }; + + work_queue_entry Entry = WorkQueueEntryAsyncFunction(&Params); + PushWorkQueueEntry(Queue, &Entry); +} + +link_internal void +DoJob(compile_shader_pair_async_params *Params) +{ + auto Result = CompileShaderPair( Params->Shader , Params->VertShaderPath , Params->FragShaderPath , Params->DumpErrors , Params->RegisterForHotReload ); + if (Params->Result) { *Params->Result = Result; } +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +link_internal void +InitializeEasingFunctionVisualizerRenderPass_Async(work_queue *Queue, easing_function_visualizer_render_pass *Element , easing_function *Func , b32* Result ) +{ + // Make sure we don't accidentally pass something that's not the render queue + Assert(Queue == &GetStdlib()->Plat.LoRenderQ); + + initialize_easing_function_visualizer_render_pass_async_params Params = + { + Result, Element, Func, + }; + + work_queue_entry Entry = WorkQueueEntryAsyncFunction(&Params); + PushWorkQueueEntry(Queue, &Entry); +} + +link_internal void +DoJob(initialize_easing_function_visualizer_render_pass_async_params *Params) +{ + auto Result = InitializeEasingFunctionVisualizerRenderPass( Params->Element , Params->Func ); + if (Params->Result) { *Params->Result = Result; } +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/generated/for_datatypes_fkubhsYl.h b/generated/for_datatypes_fkubhsYl.h index 74609cd29..26630eb38 100644 --- a/generated/for_datatypes_fkubhsYl.h +++ b/generated/for_datatypes_fkubhsYl.h @@ -1,4 +1,4 @@ -// src/engine/work_queue.h:280:0 +// src/engine/work_queue.h:191:0 @@ -146,6 +146,7 @@ +finalize_shit_and_fuckin_do_stuff_async_params finalize_shit_and_fuckin_do_stuff_async_params; @@ -174,6 +175,7 @@ +initialize_easing_function_visualizer_render_pass_async_params initialize_easing_function_visualizer_render_pass_async_params; @@ -186,7 +188,6 @@ -render_to_texture_async_params render_to_texture_async_params; @@ -512,6 +513,7 @@ render_to_texture_async_params render_to_texture_async_params; +compile_shader_pair_async_params compile_shader_pair_async_params; @@ -572,67 +574,3 @@ render_to_texture_async_params render_to_texture_async_params; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -draw_lod_async_params draw_lod_async_params; - - - - - - - - - diff --git a/generated/for_datatypes_kh9dwrCf.h b/generated/for_datatypes_kh9dwrCf.h new file mode 100644 index 000000000..cc94a62a6 --- /dev/null +++ b/generated/for_datatypes_kh9dwrCf.h @@ -0,0 +1,1476 @@ +// src/engine/editor.cpp:352:0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +link_internal b32 +IsValid(ui_brush_layer_actions Value) +{ + b32 Result = False; + switch (Value) + { + case UiBrushLayerAction_NoAction: + case UiBrushLayerAction_MoveUp: + case UiBrushLayerAction_MoveDown: + case UiBrushLayerAction_Duplicate: + case UiBrushLayerAction_Delete: + + { + Result = True; + } + } + return Result; +} + + + +link_internal counted_string +ToStringPrefixless(ui_brush_layer_actions Type) +{ + Assert(IsValid(Type)); + counted_string Result = {}; + + switch (Type) + { + case UiBrushLayerAction_NoAction: { Result = CSz("NoAction"); } break; + case UiBrushLayerAction_MoveUp: { Result = CSz("MoveUp"); } break; + case UiBrushLayerAction_MoveDown: { Result = CSz("MoveDown"); } break; + case UiBrushLayerAction_Duplicate: { Result = CSz("Duplicate"); } break; + case UiBrushLayerAction_Delete: { Result = CSz("Delete"); } break; + + + + } + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ + return Result; +} + +link_internal counted_string +ToString(ui_brush_layer_actions Type) +{ + Assert(IsValid(Type)); + + counted_string Result = {}; + switch (Type) + { + case UiBrushLayerAction_NoAction: { Result = CSz("UiBrushLayerAction_NoAction"); } break; + case UiBrushLayerAction_MoveUp: { Result = CSz("UiBrushLayerAction_MoveUp"); } break; + case UiBrushLayerAction_MoveDown: { Result = CSz("UiBrushLayerAction_MoveDown"); } break; + case UiBrushLayerAction_Duplicate: { Result = CSz("UiBrushLayerAction_Duplicate"); } break; + case UiBrushLayerAction_Delete: { Result = CSz("UiBrushLayerAction_Delete"); } break; + + + + } + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ + return Result; +} + +link_internal ui_brush_layer_actions +UiBrushLayerActions(counted_string S) +{ + ui_brush_layer_actions Result = {}; + + if (StringsMatch(S, CSz("UiBrushLayerAction_NoAction"))) { return UiBrushLayerAction_NoAction; } + if (StringsMatch(S, CSz("UiBrushLayerAction_MoveUp"))) { return UiBrushLayerAction_MoveUp; } + if (StringsMatch(S, CSz("UiBrushLayerAction_MoveDown"))) { return UiBrushLayerAction_MoveDown; } + if (StringsMatch(S, CSz("UiBrushLayerAction_Duplicate"))) { return UiBrushLayerAction_Duplicate; } + if (StringsMatch(S, CSz("UiBrushLayerAction_Delete"))) { return UiBrushLayerAction_Delete; } + + + return Result; +} + + +link_internal void +RadioSelect(ui_toggle_button_group *RadioGroup, ui_brush_layer_actions Selection) +{ + ui_toggle_button_handle *ToggleHandle = RadioGroup->Buttons.Start + Selection; + SetRadioButton(RadioGroup, ToggleHandle, True); + /* Ensure( ToggleRadioButton(RadioGroup, ToggleHandle) ); */ +} + +link_internal ui_toggle_button_group +RadioButtonGroup_ui_brush_layer_actions( renderer_2d *Ui, + window_layout *Window, + cs GroupName, + ui_brush_layer_actions *Element, + ui_render_params *Params = &DefaultUiRenderParams_Generic, + ui_toggle_button_group_flags ExtraFlags = ToggleButtonGroupFlags_None) +{ + ui_toggle_button_handle ButtonHandles[] = + { + { CSz("NoAction"), {}, UiId(Window, Cast(void*, Element), Cast(void*, "ui_brush_layer_actions UiBrushLayerAction_NoAction")), UiBrushLayerAction_NoAction }, + { CSz("MoveUp"), {}, UiId(Window, Cast(void*, Element), Cast(void*, "ui_brush_layer_actions UiBrushLayerAction_MoveUp")), UiBrushLayerAction_MoveUp }, + { CSz("MoveDown"), {}, UiId(Window, Cast(void*, Element), Cast(void*, "ui_brush_layer_actions UiBrushLayerAction_MoveDown")), UiBrushLayerAction_MoveDown }, + { CSz("Duplicate"), {}, UiId(Window, Cast(void*, Element), Cast(void*, "ui_brush_layer_actions UiBrushLayerAction_Duplicate")), UiBrushLayerAction_Duplicate }, + { CSz("Delete"), {}, UiId(Window, Cast(void*, Element), Cast(void*, "ui_brush_layer_actions UiBrushLayerAction_Delete")), UiBrushLayerAction_Delete }, + + }; + + ui_toggle_button_handle_buffer ButtonBuffer = { + ArrayCount(ButtonHandles), + ButtonHandles + }; + + ui_toggle_button_group Result = DrawButtonGroupForEnum(Ui, &ButtonBuffer, GroupName, Cast(u32*, Element), Params, ui_toggle_button_group_flags(ExtraFlags|ToggleButtonGroupFlags_TypeRadioButton)); + return Result; +} + + + + +link_internal ui_toggle_button_group +PushToolbar( renderer_2d *Ui, + window_layout *Window, + cs GroupName, + ui_brush_layer_actions *Element, + u64 Index = 0, + ui_render_params *Params = &DefaultUiRenderParams_Toolbar, + ui_toggle_button_group_flags ExtraFlags = ToggleButtonGroupFlags_None) +{ + /* auto Result = RadioButtonGroup_(enum_t.name)(Ui, Window, GroupName, Element, Params, ExtraFlags); */ + + ui_toggle_button_handle ButtonHandles[] = + { + + { + CSz("MoveUp"), + {}, + UiId( + Cast(void*, Window), + Cast(void*, Element), + Cast(void*, "ui_brush_layer_actions UiBrushLayerAction_MoveUp"), + Cast(void*, Index) + ), + UiBrushLayerAction_MoveUp, + }, + + { + CSz("MoveDown"), + {}, + UiId( + Cast(void*, Window), + Cast(void*, Element), + Cast(void*, "ui_brush_layer_actions UiBrushLayerAction_MoveDown"), + Cast(void*, Index) + ), + UiBrushLayerAction_MoveDown, + }, + + { + CSz("Duplicate"), + {}, + UiId( + Cast(void*, Window), + Cast(void*, Element), + Cast(void*, "ui_brush_layer_actions UiBrushLayerAction_Duplicate"), + Cast(void*, Index) + ), + UiBrushLayerAction_Duplicate, + }, + + { + CSz("Delete"), + {}, + UiId( + Cast(void*, Window), + Cast(void*, Element), + Cast(void*, "ui_brush_layer_actions UiBrushLayerAction_Delete"), + Cast(void*, Index) + ), + UiBrushLayerAction_Delete, + }, + + + }; + + ui_toggle_button_handle_buffer ButtonBuffer = { + ArrayCount(ButtonHandles), + ButtonHandles + }; + + ui_toggle_button_group Result = {}; + Result.Ui = Ui; + Result.Flags = ui_toggle_button_group_flags(ToggleButtonGroupFlags_TypeClickButton | ExtraFlags); + Result.Buttons = ButtonBuffer; + Result.EnumStorage = Cast(u32*, Element); + + DrawButtonGroup(&Result, GroupName); + return Result; +} + + + + + + + + + + + + + +link_internal b32 +IsValid(selection_modification_mode Value) +{ + b32 Result = False; + switch (Value) + { + case SelectionModificationMode_None: + case SelectionModificationMode_Initialize: + case SelectionModificationMode_Modify: + + { + Result = True; + } + } + return Result; +} + + + +link_internal counted_string +ToStringPrefixless(selection_modification_mode Type) +{ + Assert(IsValid(Type)); + counted_string Result = {}; + + switch (Type) + { + case SelectionModificationMode_None: { Result = CSz("None"); } break; + case SelectionModificationMode_Initialize: { Result = CSz("Initialize"); } break; + case SelectionModificationMode_Modify: { Result = CSz("Modify"); } break; + + + + } + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ + return Result; +} + +link_internal counted_string +ToString(selection_modification_mode Type) +{ + Assert(IsValid(Type)); + + counted_string Result = {}; + switch (Type) + { + case SelectionModificationMode_None: { Result = CSz("SelectionModificationMode_None"); } break; + case SelectionModificationMode_Initialize: { Result = CSz("SelectionModificationMode_Initialize"); } break; + case SelectionModificationMode_Modify: { Result = CSz("SelectionModificationMode_Modify"); } break; + + + + } + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ + return Result; +} + +link_internal selection_modification_mode +SelectionModificationMode(counted_string S) +{ + selection_modification_mode Result = {}; + + if (StringsMatch(S, CSz("SelectionModificationMode_None"))) { return SelectionModificationMode_None; } + if (StringsMatch(S, CSz("SelectionModificationMode_Initialize"))) { return SelectionModificationMode_Initialize; } + if (StringsMatch(S, CSz("SelectionModificationMode_Modify"))) { return SelectionModificationMode_Modify; } + + + return Result; +} + + + + +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, selection_modification_mode *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Generic) +{ + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x48A2A15); + + if (Name.Count) { PushColumn(Ui, CS(Name), &DefaultUiRenderParams_Column); } + + cs ElementName = ToStringPrefixless(*Element); + ui_id ToggleButtonId = UiId(Window, "toggle selection_modification_mode", Element, ThisHash); + if (ToggleButton(Ui, ElementName, ElementName, ToggleButtonId, Params)) + { + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("None"), UiId(Window, "enum SelectionModificationMode_None", Element, ThisHash), Params)) + { + *Element = SelectionModificationMode_None; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("Initialize"), UiId(Window, "enum SelectionModificationMode_Initialize", Element, ThisHash), Params)) + { + *Element = SelectionModificationMode_Initialize; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("Modify"), UiId(Window, "enum SelectionModificationMode_Modify", Element, ThisHash), Params)) + { + *Element = SelectionModificationMode_Modify; + + + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); + + } + else + { + PushNewRow(Ui); + } +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + +link_internal b32 +IsValid(ui_layer_edit_actions Value) +{ + b32 Result = False; + switch (Value) + { + case UiLayerEditAction_NoAction: + case UiLayerEditAction_SetBrush: + case UiLayerEditAction_Duplicate: + case UiLayerEditAction_Delete: + + { + Result = True; + } + } + return Result; +} + + + +link_internal counted_string +ToStringPrefixless(ui_layer_edit_actions Type) +{ + Assert(IsValid(Type)); + counted_string Result = {}; + + switch (Type) + { + case UiLayerEditAction_NoAction: { Result = CSz("NoAction"); } break; + case UiLayerEditAction_SetBrush: { Result = CSz("SetBrush"); } break; + case UiLayerEditAction_Duplicate: { Result = CSz("Duplicate"); } break; + case UiLayerEditAction_Delete: { Result = CSz("Delete"); } break; + + + + } + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ + return Result; +} + +link_internal counted_string +ToString(ui_layer_edit_actions Type) +{ + Assert(IsValid(Type)); + + counted_string Result = {}; + switch (Type) + { + case UiLayerEditAction_NoAction: { Result = CSz("UiLayerEditAction_NoAction"); } break; + case UiLayerEditAction_SetBrush: { Result = CSz("UiLayerEditAction_SetBrush"); } break; + case UiLayerEditAction_Duplicate: { Result = CSz("UiLayerEditAction_Duplicate"); } break; + case UiLayerEditAction_Delete: { Result = CSz("UiLayerEditAction_Delete"); } break; + + + + } + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ + return Result; +} + +link_internal ui_layer_edit_actions +UiLayerEditActions(counted_string S) +{ + ui_layer_edit_actions Result = {}; + + if (StringsMatch(S, CSz("UiLayerEditAction_NoAction"))) { return UiLayerEditAction_NoAction; } + if (StringsMatch(S, CSz("UiLayerEditAction_SetBrush"))) { return UiLayerEditAction_SetBrush; } + if (StringsMatch(S, CSz("UiLayerEditAction_Duplicate"))) { return UiLayerEditAction_Duplicate; } + if (StringsMatch(S, CSz("UiLayerEditAction_Delete"))) { return UiLayerEditAction_Delete; } + + + return Result; +} + + +link_internal void +RadioSelect(ui_toggle_button_group *RadioGroup, ui_layer_edit_actions Selection) +{ + ui_toggle_button_handle *ToggleHandle = RadioGroup->Buttons.Start + Selection; + SetRadioButton(RadioGroup, ToggleHandle, True); + /* Ensure( ToggleRadioButton(RadioGroup, ToggleHandle) ); */ +} + +link_internal ui_toggle_button_group +RadioButtonGroup_ui_layer_edit_actions( renderer_2d *Ui, + window_layout *Window, + cs GroupName, + ui_layer_edit_actions *Element, + ui_render_params *Params = &DefaultUiRenderParams_Generic, + ui_toggle_button_group_flags ExtraFlags = ToggleButtonGroupFlags_None) +{ + ui_toggle_button_handle ButtonHandles[] = + { + { CSz("NoAction"), {}, UiId(Window, Cast(void*, Element), Cast(void*, "ui_layer_edit_actions UiLayerEditAction_NoAction")), UiLayerEditAction_NoAction }, + { CSz("SetBrush"), {}, UiId(Window, Cast(void*, Element), Cast(void*, "ui_layer_edit_actions UiLayerEditAction_SetBrush")), UiLayerEditAction_SetBrush }, + { CSz("Duplicate"), {}, UiId(Window, Cast(void*, Element), Cast(void*, "ui_layer_edit_actions UiLayerEditAction_Duplicate")), UiLayerEditAction_Duplicate }, + { CSz("Delete"), {}, UiId(Window, Cast(void*, Element), Cast(void*, "ui_layer_edit_actions UiLayerEditAction_Delete")), UiLayerEditAction_Delete }, + + }; + + ui_toggle_button_handle_buffer ButtonBuffer = { + ArrayCount(ButtonHandles), + ButtonHandles + }; + + ui_toggle_button_group Result = DrawButtonGroupForEnum(Ui, &ButtonBuffer, GroupName, Cast(u32*, Element), Params, ui_toggle_button_group_flags(ExtraFlags|ToggleButtonGroupFlags_TypeRadioButton)); + return Result; +} + + + + +link_internal ui_toggle_button_group +PushToolbar( renderer_2d *Ui, + window_layout *Window, + cs GroupName, + ui_layer_edit_actions *Element, + u64 Index = 0, + ui_render_params *Params = &DefaultUiRenderParams_Toolbar, + ui_toggle_button_group_flags ExtraFlags = ToggleButtonGroupFlags_None) +{ + /* auto Result = RadioButtonGroup_(enum_t.name)(Ui, Window, GroupName, Element, Params, ExtraFlags); */ + + ui_toggle_button_handle ButtonHandles[] = + { + + { + CSz("S"), + CSz("SetBrush"), + UiId( + Cast(void*, Window), + Cast(void*, Element), + Cast(void*, "ui_layer_edit_actions UiLayerEditAction_SetBrush"), + Cast(void*, Index) + ), + UiLayerEditAction_SetBrush, + }, + + { + CSz("D"), + CSz("Duplicate"), + UiId( + Cast(void*, Window), + Cast(void*, Element), + Cast(void*, "ui_layer_edit_actions UiLayerEditAction_Duplicate"), + Cast(void*, Index) + ), + UiLayerEditAction_Duplicate, + }, + + { + CSz("X"), + CSz("Delete"), + UiId( + Cast(void*, Window), + Cast(void*, Element), + Cast(void*, "ui_layer_edit_actions UiLayerEditAction_Delete"), + Cast(void*, Index) + ), + UiLayerEditAction_Delete, + }, + + + }; + + ui_toggle_button_handle_buffer ButtonBuffer = { + ArrayCount(ButtonHandles), + ButtonHandles + }; + + ui_toggle_button_group Result = {}; + Result.Ui = Ui; + Result.Flags = ui_toggle_button_group_flags(ToggleButtonGroupFlags_TypeClickButton | ExtraFlags); + Result.Buttons = ButtonBuffer; + Result.EnumStorage = Cast(u32*, Element); + + DrawButtonGroup(&Result, GroupName); + return Result; +} + + + + + + +link_internal b32 +IsValid(ui_reorder_action Value) +{ + b32 Result = False; + switch (Value) + { + case UiReorderAction_NoAction: + case UiReorderAction_ReorderUp: + case UiReorderAction_ReorderDown: + + { + Result = True; + } + } + return Result; +} + + + +link_internal counted_string +ToStringPrefixless(ui_reorder_action Type) +{ + Assert(IsValid(Type)); + counted_string Result = {}; + + switch (Type) + { + case UiReorderAction_NoAction: { Result = CSz("NoAction"); } break; + case UiReorderAction_ReorderUp: { Result = CSz("ReorderUp"); } break; + case UiReorderAction_ReorderDown: { Result = CSz("ReorderDown"); } break; + + + + } + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ + return Result; +} + +link_internal counted_string +ToString(ui_reorder_action Type) +{ + Assert(IsValid(Type)); + + counted_string Result = {}; + switch (Type) + { + case UiReorderAction_NoAction: { Result = CSz("UiReorderAction_NoAction"); } break; + case UiReorderAction_ReorderUp: { Result = CSz("UiReorderAction_ReorderUp"); } break; + case UiReorderAction_ReorderDown: { Result = CSz("UiReorderAction_ReorderDown"); } break; + + + + } + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ + return Result; +} + +link_internal ui_reorder_action +UiReorderAction(counted_string S) +{ + ui_reorder_action Result = {}; + + if (StringsMatch(S, CSz("UiReorderAction_NoAction"))) { return UiReorderAction_NoAction; } + if (StringsMatch(S, CSz("UiReorderAction_ReorderUp"))) { return UiReorderAction_ReorderUp; } + if (StringsMatch(S, CSz("UiReorderAction_ReorderDown"))) { return UiReorderAction_ReorderDown; } + + + return Result; +} + + +link_internal void +RadioSelect(ui_toggle_button_group *RadioGroup, ui_reorder_action Selection) +{ + ui_toggle_button_handle *ToggleHandle = RadioGroup->Buttons.Start + Selection; + SetRadioButton(RadioGroup, ToggleHandle, True); + /* Ensure( ToggleRadioButton(RadioGroup, ToggleHandle) ); */ +} + +link_internal ui_toggle_button_group +RadioButtonGroup_ui_reorder_action( renderer_2d *Ui, + window_layout *Window, + cs GroupName, + ui_reorder_action *Element, + ui_render_params *Params = &DefaultUiRenderParams_Generic, + ui_toggle_button_group_flags ExtraFlags = ToggleButtonGroupFlags_None) +{ + ui_toggle_button_handle ButtonHandles[] = + { + { CSz("NoAction"), {}, UiId(Window, Cast(void*, Element), Cast(void*, "ui_reorder_action UiReorderAction_NoAction")), UiReorderAction_NoAction }, + { CSz("ReorderUp"), {}, UiId(Window, Cast(void*, Element), Cast(void*, "ui_reorder_action UiReorderAction_ReorderUp")), UiReorderAction_ReorderUp }, + { CSz("ReorderDown"), {}, UiId(Window, Cast(void*, Element), Cast(void*, "ui_reorder_action UiReorderAction_ReorderDown")), UiReorderAction_ReorderDown }, + + }; + + ui_toggle_button_handle_buffer ButtonBuffer = { + ArrayCount(ButtonHandles), + ButtonHandles + }; + + ui_toggle_button_group Result = DrawButtonGroupForEnum(Ui, &ButtonBuffer, GroupName, Cast(u32*, Element), Params, ui_toggle_button_group_flags(ExtraFlags|ToggleButtonGroupFlags_TypeRadioButton)); + return Result; +} + + + + +link_internal ui_toggle_button_group +PushToolbar( renderer_2d *Ui, + window_layout *Window, + cs GroupName, + ui_reorder_action *Element, + u64 Index = 0, + ui_render_params *Params = &DefaultUiRenderParams_Toolbar, + ui_toggle_button_group_flags ExtraFlags = ToggleButtonGroupFlags_None) +{ + /* auto Result = RadioButtonGroup_(enum_t.name)(Ui, Window, GroupName, Element, Params, ExtraFlags); */ + + ui_toggle_button_handle ButtonHandles[] = + { + + { + CSz("^"), + CSz("ReorderUp"), + UiId( + Cast(void*, Window), + Cast(void*, Element), + Cast(void*, "ui_reorder_action UiReorderAction_ReorderUp"), + Cast(void*, Index) + ), + UiReorderAction_ReorderUp, + }, + + { + CSz("v"), + CSz("ReorderDown"), + UiId( + Cast(void*, Window), + Cast(void*, Element), + Cast(void*, "ui_reorder_action UiReorderAction_ReorderDown"), + Cast(void*, Index) + ), + UiReorderAction_ReorderDown, + }, + + + }; + + ui_toggle_button_handle_buffer ButtonBuffer = { + ArrayCount(ButtonHandles), + ButtonHandles + }; + + ui_toggle_button_group Result = {}; + Result.Ui = Ui; + Result.Flags = ui_toggle_button_group_flags(ToggleButtonGroupFlags_TypeClickButton | ExtraFlags); + Result.Buttons = ButtonBuffer; + Result.EnumStorage = Cast(u32*, Element); + + DrawButtonGroup(&Result, GroupName); + return Result; +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +link_internal b32 +IsValid(ui_brush_actions Value) +{ + b32 Result = False; + switch (Value) + { + case UiBrushAction_NoAction: + case UiBrushAction_New: + case UiBrushAction_Save: + case UiBrushAction_Duplicate: + + { + Result = True; + } + } + return Result; +} + + + +link_internal counted_string +ToStringPrefixless(ui_brush_actions Type) +{ + Assert(IsValid(Type)); + counted_string Result = {}; + + switch (Type) + { + case UiBrushAction_NoAction: { Result = CSz("NoAction"); } break; + case UiBrushAction_New: { Result = CSz("New"); } break; + case UiBrushAction_Save: { Result = CSz("Save"); } break; + case UiBrushAction_Duplicate: { Result = CSz("Duplicate"); } break; + + + + } + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ + return Result; +} + +link_internal counted_string +ToString(ui_brush_actions Type) +{ + Assert(IsValid(Type)); + + counted_string Result = {}; + switch (Type) + { + case UiBrushAction_NoAction: { Result = CSz("UiBrushAction_NoAction"); } break; + case UiBrushAction_New: { Result = CSz("UiBrushAction_New"); } break; + case UiBrushAction_Save: { Result = CSz("UiBrushAction_Save"); } break; + case UiBrushAction_Duplicate: { Result = CSz("UiBrushAction_Duplicate"); } break; + + + + } + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ + return Result; +} + +link_internal ui_brush_actions +UiBrushActions(counted_string S) +{ + ui_brush_actions Result = {}; + + if (StringsMatch(S, CSz("UiBrushAction_NoAction"))) { return UiBrushAction_NoAction; } + if (StringsMatch(S, CSz("UiBrushAction_New"))) { return UiBrushAction_New; } + if (StringsMatch(S, CSz("UiBrushAction_Save"))) { return UiBrushAction_Save; } + if (StringsMatch(S, CSz("UiBrushAction_Duplicate"))) { return UiBrushAction_Duplicate; } + + + return Result; +} + + +link_internal void +RadioSelect(ui_toggle_button_group *RadioGroup, ui_brush_actions Selection) +{ + ui_toggle_button_handle *ToggleHandle = RadioGroup->Buttons.Start + Selection; + SetRadioButton(RadioGroup, ToggleHandle, True); + /* Ensure( ToggleRadioButton(RadioGroup, ToggleHandle) ); */ +} + +link_internal ui_toggle_button_group +RadioButtonGroup_ui_brush_actions( renderer_2d *Ui, + window_layout *Window, + cs GroupName, + ui_brush_actions *Element, + ui_render_params *Params = &DefaultUiRenderParams_Generic, + ui_toggle_button_group_flags ExtraFlags = ToggleButtonGroupFlags_None) +{ + ui_toggle_button_handle ButtonHandles[] = + { + { CSz("NoAction"), {}, UiId(Window, Cast(void*, Element), Cast(void*, "ui_brush_actions UiBrushAction_NoAction")), UiBrushAction_NoAction }, + { CSz("New"), {}, UiId(Window, Cast(void*, Element), Cast(void*, "ui_brush_actions UiBrushAction_New")), UiBrushAction_New }, + { CSz("Save"), {}, UiId(Window, Cast(void*, Element), Cast(void*, "ui_brush_actions UiBrushAction_Save")), UiBrushAction_Save }, + { CSz("Duplicate"), {}, UiId(Window, Cast(void*, Element), Cast(void*, "ui_brush_actions UiBrushAction_Duplicate")), UiBrushAction_Duplicate }, + + }; + + ui_toggle_button_handle_buffer ButtonBuffer = { + ArrayCount(ButtonHandles), + ButtonHandles + }; + + ui_toggle_button_group Result = DrawButtonGroupForEnum(Ui, &ButtonBuffer, GroupName, Cast(u32*, Element), Params, ui_toggle_button_group_flags(ExtraFlags|ToggleButtonGroupFlags_TypeRadioButton)); + return Result; +} + + + + +link_internal ui_toggle_button_group +PushToolbar( renderer_2d *Ui, + window_layout *Window, + cs GroupName, + ui_brush_actions *Element, + u64 Index = 0, + ui_render_params *Params = &DefaultUiRenderParams_Toolbar, + ui_toggle_button_group_flags ExtraFlags = ToggleButtonGroupFlags_None) +{ + /* auto Result = RadioButtonGroup_(enum_t.name)(Ui, Window, GroupName, Element, Params, ExtraFlags); */ + + ui_toggle_button_handle ButtonHandles[] = + { + + { + CSz("New"), + {}, + UiId( + Cast(void*, Window), + Cast(void*, Element), + Cast(void*, "ui_brush_actions UiBrushAction_New"), + Cast(void*, Index) + ), + UiBrushAction_New, + }, + + { + CSz("Save"), + {}, + UiId( + Cast(void*, Window), + Cast(void*, Element), + Cast(void*, "ui_brush_actions UiBrushAction_Save"), + Cast(void*, Index) + ), + UiBrushAction_Save, + }, + + { + CSz("Duplicate"), + {}, + UiId( + Cast(void*, Window), + Cast(void*, Element), + Cast(void*, "ui_brush_actions UiBrushAction_Duplicate"), + Cast(void*, Index) + ), + UiBrushAction_Duplicate, + }, + + + }; + + ui_toggle_button_handle_buffer ButtonBuffer = { + ArrayCount(ButtonHandles), + ButtonHandles + }; + + ui_toggle_button_group Result = {}; + Result.Ui = Ui; + Result.Flags = ui_toggle_button_group_flags(ToggleButtonGroupFlags_TypeClickButton | ExtraFlags); + Result.Buttons = ButtonBuffer; + Result.EnumStorage = Cast(u32*, Element); + + DrawButtonGroup(&Result, GroupName); + return Result; +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +link_internal b32 +IsValid(ui_layer_toolbar_actions Value) +{ + b32 Result = False; + switch (Value) + { + case LayerToolbarActions_NoAction: + case LayerToolbarActions_Rename: + case LayerToolbarActions_Duplicate: + case LayerToolbarActions_Delete: + + { + Result = True; + } + } + return Result; +} + + + +link_internal counted_string +ToStringPrefixless(ui_layer_toolbar_actions Type) +{ + Assert(IsValid(Type)); + counted_string Result = {}; + + switch (Type) + { + case LayerToolbarActions_NoAction: { Result = CSz("NoAction"); } break; + case LayerToolbarActions_Rename: { Result = CSz("Rename"); } break; + case LayerToolbarActions_Duplicate: { Result = CSz("Duplicate"); } break; + case LayerToolbarActions_Delete: { Result = CSz("Delete"); } break; + + + + } + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ + return Result; +} + +link_internal counted_string +ToString(ui_layer_toolbar_actions Type) +{ + Assert(IsValid(Type)); + + counted_string Result = {}; + switch (Type) + { + case LayerToolbarActions_NoAction: { Result = CSz("LayerToolbarActions_NoAction"); } break; + case LayerToolbarActions_Rename: { Result = CSz("LayerToolbarActions_Rename"); } break; + case LayerToolbarActions_Duplicate: { Result = CSz("LayerToolbarActions_Duplicate"); } break; + case LayerToolbarActions_Delete: { Result = CSz("LayerToolbarActions_Delete"); } break; + + + + } + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ + return Result; +} + +link_internal ui_layer_toolbar_actions +UiLayerToolbarActions(counted_string S) +{ + ui_layer_toolbar_actions Result = {}; + + if (StringsMatch(S, CSz("LayerToolbarActions_NoAction"))) { return LayerToolbarActions_NoAction; } + if (StringsMatch(S, CSz("LayerToolbarActions_Rename"))) { return LayerToolbarActions_Rename; } + if (StringsMatch(S, CSz("LayerToolbarActions_Duplicate"))) { return LayerToolbarActions_Duplicate; } + if (StringsMatch(S, CSz("LayerToolbarActions_Delete"))) { return LayerToolbarActions_Delete; } + + + return Result; +} + + +link_internal void +RadioSelect(ui_toggle_button_group *RadioGroup, ui_layer_toolbar_actions Selection) +{ + ui_toggle_button_handle *ToggleHandle = RadioGroup->Buttons.Start + Selection; + SetRadioButton(RadioGroup, ToggleHandle, True); + /* Ensure( ToggleRadioButton(RadioGroup, ToggleHandle) ); */ +} + +link_internal ui_toggle_button_group +RadioButtonGroup_ui_layer_toolbar_actions( renderer_2d *Ui, + window_layout *Window, + cs GroupName, + ui_layer_toolbar_actions *Element, + ui_render_params *Params = &DefaultUiRenderParams_Generic, + ui_toggle_button_group_flags ExtraFlags = ToggleButtonGroupFlags_None) +{ + ui_toggle_button_handle ButtonHandles[] = + { + { CSz("NoAction"), {}, UiId(Window, Cast(void*, Element), Cast(void*, "ui_layer_toolbar_actions LayerToolbarActions_NoAction")), LayerToolbarActions_NoAction }, + { CSz("Rename"), {}, UiId(Window, Cast(void*, Element), Cast(void*, "ui_layer_toolbar_actions LayerToolbarActions_Rename")), LayerToolbarActions_Rename }, + { CSz("Duplicate"), {}, UiId(Window, Cast(void*, Element), Cast(void*, "ui_layer_toolbar_actions LayerToolbarActions_Duplicate")), LayerToolbarActions_Duplicate }, + { CSz("Delete"), {}, UiId(Window, Cast(void*, Element), Cast(void*, "ui_layer_toolbar_actions LayerToolbarActions_Delete")), LayerToolbarActions_Delete }, + + }; + + ui_toggle_button_handle_buffer ButtonBuffer = { + ArrayCount(ButtonHandles), + ButtonHandles + }; + + ui_toggle_button_group Result = DrawButtonGroupForEnum(Ui, &ButtonBuffer, GroupName, Cast(u32*, Element), Params, ui_toggle_button_group_flags(ExtraFlags|ToggleButtonGroupFlags_TypeRadioButton)); + return Result; +} + + + + +link_internal ui_toggle_button_group +PushToolbar( renderer_2d *Ui, + window_layout *Window, + cs GroupName, + ui_layer_toolbar_actions *Element, + u64 Index = 0, + ui_render_params *Params = &DefaultUiRenderParams_Toolbar, + ui_toggle_button_group_flags ExtraFlags = ToggleButtonGroupFlags_None) +{ + /* auto Result = RadioButtonGroup_(enum_t.name)(Ui, Window, GroupName, Element, Params, ExtraFlags); */ + + ui_toggle_button_handle ButtonHandles[] = + { + + { + CSz("R"), + CSz("Rename"), + UiId( + Cast(void*, Window), + Cast(void*, Element), + Cast(void*, "ui_layer_toolbar_actions LayerToolbarActions_Rename"), + Cast(void*, Index) + ), + LayerToolbarActions_Rename, + }, + + { + CSz("D"), + CSz("Duplicate"), + UiId( + Cast(void*, Window), + Cast(void*, Element), + Cast(void*, "ui_layer_toolbar_actions LayerToolbarActions_Duplicate"), + Cast(void*, Index) + ), + LayerToolbarActions_Duplicate, + }, + + { + CSz("X"), + CSz("Delete"), + UiId( + Cast(void*, Window), + Cast(void*, Element), + Cast(void*, "ui_layer_toolbar_actions LayerToolbarActions_Delete"), + Cast(void*, Index) + ), + LayerToolbarActions_Delete, + }, + + + }; + + ui_toggle_button_handle_buffer ButtonBuffer = { + ArrayCount(ButtonHandles), + ButtonHandles + }; + + ui_toggle_button_group Result = {}; + Result.Ui = Ui; + Result.Flags = ui_toggle_button_group_flags(ToggleButtonGroupFlags_TypeClickButton | ExtraFlags); + Result.Buttons = ButtonBuffer; + Result.EnumStorage = Cast(u32*, Element); + + DrawButtonGroup(&Result, GroupName); + return Result; +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/generated/for_datatypes_khY6kwEk.h b/generated/for_datatypes_khY6kwEk.h new file mode 100644 index 000000000..5ef220ef9 --- /dev/null +++ b/generated/for_datatypes_khY6kwEk.h @@ -0,0 +1,2064 @@ +// src/engine/work_queue.h:153:0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +struct finalize_shit_and_fuckin_do_stuff_async_params poof(@async_function_params) +{ + + gen_chunk *GenChunk; + octree_node *DestNode; + +}; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +struct compile_shader_pair_async_params poof(@async_function_params) +{ + b32* Result; + shader *Shader; + cs VertShaderPath; + cs FragShaderPath; + b32 DumpErrors; + b32 RegisterForHotReload; + +}; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +struct initialize_easing_function_visualizer_render_pass_async_params poof(@async_function_params) +{ + b32* Result; + easing_function_visualizer_render_pass *Element; + easing_function *Func; + +}; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/generated/for_datatypes_kv3WBTai.h b/generated/for_datatypes_kv3WBTai.h index c9bfbc533..4f616275d 100644 --- a/generated/for_datatypes_kv3WBTai.h +++ b/generated/for_datatypes_kv3WBTai.h @@ -1,4 +1,4 @@ -// src/engine/work_queue.h:261:0 +// src/engine/work_queue.h:173:0 @@ -146,6 +146,7 @@ +type_finalize_shit_and_fuckin_do_stuff_async_params, @@ -174,6 +175,7 @@ +type_initialize_easing_function_visualizer_render_pass_async_params, @@ -186,7 +188,6 @@ -type_render_to_texture_async_params, @@ -512,6 +513,7 @@ type_render_to_texture_async_params, +type_compile_shader_pair_async_params, @@ -572,67 +574,3 @@ type_render_to_texture_async_params, - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -type_draw_lod_async_params, - - - - - - - - - diff --git a/generated/freelist_allocator_lEJhaKNS.h b/generated/freelist_allocator_lEJhaKNS.h new file mode 100644 index 000000000..cf4aa0b78 --- /dev/null +++ b/generated/freelist_allocator_lEJhaKNS.h @@ -0,0 +1,41 @@ +// external/bonsai_stdlib/src/poof_functions.h:2651:0 +struct gen_chunk_freelist +poof(@do_editor_ui) +{ + gen_chunk *First; + memory_arena *Memory; + bonsai_futex Lock; + u32 ElementsAllocated; +}; + +link_internal gen_chunk * +GetOrAllocate(gen_chunk_freelist *Freelist) +{ + + + AcquireFutex(&Freelist->Lock); + gen_chunk *Result = Freelist->First; + + if (Result) + { + Freelist->First = Result->Next; + } + else + { + Result = Allocate( gen_chunk, Freelist->Memory, 1 ); + Freelist->ElementsAllocated++; + } + ReleaseFutex(&Freelist->Lock); + + return Result; +} + +link_internal void +Free(gen_chunk_freelist *Freelist, gen_chunk *Element) +{ + AcquireFutex(&Freelist->Lock); + Element->Next = Freelist->First; + Freelist->First = Element; + ReleaseFutex(&Freelist->Lock); +} + diff --git a/generated/freelist_allocator_octree_node.h b/generated/freelist_allocator_octree_node.h new file mode 100644 index 000000000..820627085 --- /dev/null +++ b/generated/freelist_allocator_octree_node.h @@ -0,0 +1,41 @@ +// external/bonsai_stdlib/src/poof_functions.h:2651:0 +struct octree_node_freelist +poof(@do_editor_ui) +{ + octree_node *First; + memory_arena *Memory; + bonsai_futex Lock; + u32 ElementsAllocated; +}; + +link_internal octree_node * +GetOrAllocate(octree_node_freelist *Freelist) +{ + + + AcquireFutex(&Freelist->Lock); + octree_node *Result = Freelist->First; + + if (Result) + { + Freelist->First = Result->Next; + } + else + { + Result = Allocate( octree_node, Freelist->Memory, 1 ); + Freelist->ElementsAllocated++; + } + ReleaseFutex(&Freelist->Lock); + + return Result; +} + +link_internal void +Free(octree_node_freelist *Freelist, octree_node *Element) +{ + AcquireFutex(&Freelist->Lock); + Element->Next = Freelist->First; + Freelist->First = Element; + ReleaseFutex(&Freelist->Lock); +} + diff --git a/generated/freelist_allocator_world_chunk.h b/generated/freelist_allocator_world_chunk.h new file mode 100644 index 000000000..8048b8d20 --- /dev/null +++ b/generated/freelist_allocator_world_chunk.h @@ -0,0 +1,41 @@ +// external/bonsai_stdlib/src/poof_functions.h:2651:0 +struct world_chunk_freelist +poof(@do_editor_ui) +{ + world_chunk *First; + memory_arena *Memory; + bonsai_futex Lock; + u32 ElementsAllocated; +}; + +link_internal world_chunk * +GetOrAllocate(world_chunk_freelist *Freelist) +{ + + + AcquireFutex(&Freelist->Lock); + world_chunk *Result = Freelist->First; + + if (Result) + { + Freelist->First = Result->Next; + } + else + { + Result = Allocate( world_chunk, Freelist->Memory, 1 ); + Freelist->ElementsAllocated++; + } + ReleaseFutex(&Freelist->Lock); + + return Result; +} + +link_internal void +Free(world_chunk_freelist *Freelist, world_chunk *Element) +{ + AcquireFutex(&Freelist->Lock); + Element->Next = Freelist->First; + Freelist->First = Element; + ReleaseFutex(&Freelist->Lock); +} + diff --git a/generated/gen_are_equal_665365505.h b/generated/gen_are_equal_665365505.h index cb11e3820..13e111197 100644 --- a/generated/gen_are_equal_665365505.h +++ b/generated/gen_are_equal_665365505.h @@ -1,59 +1,121 @@ -// external/bonsai_stdlib/src/primitives.h:226:0 - +// external/bonsai_stdlib/src/primitives.h:213:0 link_internal b32 AreEqual( s64 E1, s64 E2 ) { b32 Result = E1 == E2; return Result; } + +link_internal b32 +AreEqual( s64 *E1, s64 *E2 ) +{ + b32 Result = *E1 == *E2; + return Result; +} link_internal b32 AreEqual( u64 E1, u64 E2 ) { b32 Result = E1 == E2; return Result; } + +link_internal b32 +AreEqual( u64 *E1, u64 *E2 ) +{ + b32 Result = *E1 == *E2; + return Result; +} link_internal b32 AreEqual( r64 E1, r64 E2 ) { b32 Result = E1 == E2; return Result; } + +link_internal b32 +AreEqual( r64 *E1, r64 *E2 ) +{ + b32 Result = *E1 == *E2; + return Result; +} link_internal b32 AreEqual( s32 E1, s32 E2 ) { b32 Result = E1 == E2; return Result; } + +link_internal b32 +AreEqual( s32 *E1, s32 *E2 ) +{ + b32 Result = *E1 == *E2; + return Result; +} link_internal b32 AreEqual( u32 E1, u32 E2 ) { b32 Result = E1 == E2; return Result; } + +link_internal b32 +AreEqual( u32 *E1, u32 *E2 ) +{ + b32 Result = *E1 == *E2; + return Result; +} link_internal b32 AreEqual( r32 E1, r32 E2 ) { b32 Result = E1 == E2; return Result; } + +link_internal b32 +AreEqual( r32 *E1, r32 *E2 ) +{ + b32 Result = *E1 == *E2; + return Result; +} link_internal b32 AreEqual( s16 E1, s16 E2 ) { b32 Result = E1 == E2; return Result; } + +link_internal b32 +AreEqual( s16 *E1, s16 *E2 ) +{ + b32 Result = *E1 == *E2; + return Result; +} link_internal b32 AreEqual( u16 E1, u16 E2 ) { b32 Result = E1 == E2; return Result; } + +link_internal b32 +AreEqual( u16 *E1, u16 *E2 ) +{ + b32 Result = *E1 == *E2; + return Result; +} link_internal b32 AreEqual( s8 E1, s8 E2 ) { b32 Result = E1 == E2; return Result; } + +link_internal b32 +AreEqual( s8 *E1, s8 *E2 ) +{ + b32 Result = *E1 == *E2; + return Result; +} link_internal b32 AreEqual( u8 E1, u8 E2 ) { @@ -61,3 +123,11 @@ AreEqual( u8 E1, u8 E2 ) return Result; } +link_internal b32 +AreEqual( u8 *E1, u8 *E2 ) +{ + b32 Result = *E1 == *E2; + return Result; +} + + diff --git a/generated/gen_bit_operators_u32.h b/generated/gen_bit_operators_u32.h index 24d4e76f0..b24ac423b 100644 --- a/generated/gen_bit_operators_u32.h +++ b/generated/gen_bit_operators_u32.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/bit_tricks.h:67:0 - +// external/bonsai_stdlib/src/bit_tricks.h:4:0 link_internal u32 UnsetLeastSignificantSetBit(u32 *Input) { diff --git a/generated/gen_bit_operators_u64.h b/generated/gen_bit_operators_u64.h index dfa8e95fb..0660503a5 100644 --- a/generated/gen_bit_operators_u64.h +++ b/generated/gen_bit_operators_u64.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/bit_tricks.h:70:0 - +// external/bonsai_stdlib/src/bit_tricks.h:4:0 link_internal u64 UnsetLeastSignificantSetBit(u64 *Input) { diff --git a/generated/gen_common_vector_v2.h b/generated/gen_common_vector_v2.h index f40109615..eb575d969 100644 --- a/generated/gen_common_vector_v2.h +++ b/generated/gen_common_vector_v2.h @@ -1,9 +1,8 @@ -// external/bonsai_stdlib/src/vector.h:788:0 - +// external/bonsai_stdlib/src/poof_functions.h:452:0 inline r32 LengthSq( v2 Vec ) { - r32 Result = Vec.E[0]*Vec.E[0] + Vec.E[1]*Vec.E[1] ; + r32 Result = Vec.E[0]*Vec.E[0] + Vec.E[1]*Vec.E[1] ; return Result; } @@ -18,8 +17,9 @@ inline v2 Max( v2 A, v2 B ) { v2 Result; - Result.E[0] = Max( A.E[0], B.E[0] ); + Result.E[0] = Max( A.E[0], B.E[0] ); Result.E[1] = Max( A.E[1], B.E[1] ); + return Result; } @@ -27,8 +27,9 @@ inline v2 Min( v2 A, v2 B ) { v2 Result; - Result.E[0] = Min( A.E[0], B.E[0] ); + Result.E[0] = Min( A.E[0], B.E[0] ); Result.E[1] = Min( A.E[1], B.E[1] ); + return Result; } @@ -36,8 +37,9 @@ inline v2 Abs( v2 Vec ) { v2 Result; - Result.E[0] = (r32)Abs( Vec.E[0] ); + Result.E[0] = (r32)Abs( Vec.E[0] ); Result.E[1] = (r32)Abs( Vec.E[1] ); + return Result; } @@ -46,8 +48,9 @@ inline v2 GetSign( v2 Vec ) { v2 Result; - Result.E[0] = GetSign( Vec.E[0] ); + Result.E[0] = GetSign( Vec.E[0] ); Result.E[1] = GetSign( Vec.E[1] ); + return Result; } @@ -56,8 +59,9 @@ inline v2 Bilateral( v2 Vec ) { v2 Result; - Result.E[0] = Bilateral( Vec.E[0] ); + Result.E[0] = Bilateral( Vec.E[0] ); Result.E[1] = Bilateral( Vec.E[1] ); + return Result; } @@ -65,8 +69,9 @@ inline v2 ClampNegative( v2 V ) { v2 Result = V; - if ( V.E[0] > r32(0) ) Result.E[0] = r32(0); + if ( V.E[0] > r32(0) ) Result.E[0] = r32(0); if ( V.E[1] > r32(0) ) Result.E[1] = r32(0); + return Result; } @@ -74,8 +79,9 @@ inline v2 ClampPositive( v2 V ) { v2 Result = V; - if ( V.E[0] < r32(0) ) Result.E[0] = r32(0); + if ( V.E[0] < r32(0) ) Result.E[0] = r32(0); if ( V.E[1] < r32(0) ) Result.E[1] = r32(0); + return Result; } @@ -83,10 +89,11 @@ inline v2 Clamp01( v2 V ) { v2 Result = V; - if ( V.E[0] < r32(0) ) Result.E[0] = r32(0); + if ( V.E[0] < r32(0) ) Result.E[0] = r32(0); if ( V.E[0] > r32(1) ) Result.E[0] = r32(1); if ( V.E[1] < r32(0) ) Result.E[1] = r32(0); if ( V.E[1] > r32(1) ) Result.E[1] = r32(1); + return Result; } diff --git a/generated/gen_common_vector_v3.h b/generated/gen_common_vector_v3.h index 6d2b74eef..3e45db79a 100644 --- a/generated/gen_common_vector_v3.h +++ b/generated/gen_common_vector_v3.h @@ -1,9 +1,8 @@ -// external/bonsai_stdlib/src/vector.h:791:0 - +// external/bonsai_stdlib/src/poof_functions.h:452:0 inline r32 LengthSq( v3 Vec ) { - r32 Result = Vec.E[0]*Vec.E[0] + Vec.E[1]*Vec.E[1] + Vec.E[2]*Vec.E[2] ; + r32 Result = Vec.E[0]*Vec.E[0] + Vec.E[1]*Vec.E[1] + Vec.E[2]*Vec.E[2] ; return Result; } @@ -18,9 +17,10 @@ inline v3 Max( v3 A, v3 B ) { v3 Result; - Result.E[0] = Max( A.E[0], B.E[0] ); + Result.E[0] = Max( A.E[0], B.E[0] ); Result.E[1] = Max( A.E[1], B.E[1] ); Result.E[2] = Max( A.E[2], B.E[2] ); + return Result; } @@ -28,9 +28,10 @@ inline v3 Min( v3 A, v3 B ) { v3 Result; - Result.E[0] = Min( A.E[0], B.E[0] ); + Result.E[0] = Min( A.E[0], B.E[0] ); Result.E[1] = Min( A.E[1], B.E[1] ); Result.E[2] = Min( A.E[2], B.E[2] ); + return Result; } @@ -38,9 +39,10 @@ inline v3 Abs( v3 Vec ) { v3 Result; - Result.E[0] = (r32)Abs( Vec.E[0] ); + Result.E[0] = (r32)Abs( Vec.E[0] ); Result.E[1] = (r32)Abs( Vec.E[1] ); Result.E[2] = (r32)Abs( Vec.E[2] ); + return Result; } @@ -49,9 +51,10 @@ inline v3 GetSign( v3 Vec ) { v3 Result; - Result.E[0] = GetSign( Vec.E[0] ); + Result.E[0] = GetSign( Vec.E[0] ); Result.E[1] = GetSign( Vec.E[1] ); Result.E[2] = GetSign( Vec.E[2] ); + return Result; } @@ -60,9 +63,10 @@ inline v3 Bilateral( v3 Vec ) { v3 Result; - Result.E[0] = Bilateral( Vec.E[0] ); + Result.E[0] = Bilateral( Vec.E[0] ); Result.E[1] = Bilateral( Vec.E[1] ); Result.E[2] = Bilateral( Vec.E[2] ); + return Result; } @@ -70,9 +74,10 @@ inline v3 ClampNegative( v3 V ) { v3 Result = V; - if ( V.E[0] > r32(0) ) Result.E[0] = r32(0); + if ( V.E[0] > r32(0) ) Result.E[0] = r32(0); if ( V.E[1] > r32(0) ) Result.E[1] = r32(0); if ( V.E[2] > r32(0) ) Result.E[2] = r32(0); + return Result; } @@ -80,9 +85,10 @@ inline v3 ClampPositive( v3 V ) { v3 Result = V; - if ( V.E[0] < r32(0) ) Result.E[0] = r32(0); + if ( V.E[0] < r32(0) ) Result.E[0] = r32(0); if ( V.E[1] < r32(0) ) Result.E[1] = r32(0); if ( V.E[2] < r32(0) ) Result.E[2] = r32(0); + return Result; } @@ -90,12 +96,13 @@ inline v3 Clamp01( v3 V ) { v3 Result = V; - if ( V.E[0] < r32(0) ) Result.E[0] = r32(0); + if ( V.E[0] < r32(0) ) Result.E[0] = r32(0); if ( V.E[0] > r32(1) ) Result.E[0] = r32(1); if ( V.E[1] < r32(0) ) Result.E[1] = r32(0); if ( V.E[1] > r32(1) ) Result.E[1] = r32(1); if ( V.E[2] < r32(0) ) Result.E[2] = r32(0); if ( V.E[2] > r32(1) ) Result.E[2] = r32(1); + return Result; } diff --git a/generated/gen_common_vector_v3i.h b/generated/gen_common_vector_v3i.h index 10f478493..c4ea36291 100644 --- a/generated/gen_common_vector_v3i.h +++ b/generated/gen_common_vector_v3i.h @@ -1,9 +1,8 @@ -// external/bonsai_stdlib/src/vector.h:794:0 - +// external/bonsai_stdlib/src/poof_functions.h:452:0 inline s32 LengthSq( v3i Vec ) { - s32 Result = Vec.E[0]*Vec.E[0] + Vec.E[1]*Vec.E[1] + Vec.E[2]*Vec.E[2] ; + s32 Result = Vec.E[0]*Vec.E[0] + Vec.E[1]*Vec.E[1] + Vec.E[2]*Vec.E[2] ; return Result; } @@ -18,9 +17,10 @@ inline v3i Max( v3i A, v3i B ) { v3i Result; - Result.E[0] = Max( A.E[0], B.E[0] ); + Result.E[0] = Max( A.E[0], B.E[0] ); Result.E[1] = Max( A.E[1], B.E[1] ); Result.E[2] = Max( A.E[2], B.E[2] ); + return Result; } @@ -28,9 +28,10 @@ inline v3i Min( v3i A, v3i B ) { v3i Result; - Result.E[0] = Min( A.E[0], B.E[0] ); + Result.E[0] = Min( A.E[0], B.E[0] ); Result.E[1] = Min( A.E[1], B.E[1] ); Result.E[2] = Min( A.E[2], B.E[2] ); + return Result; } @@ -38,9 +39,10 @@ inline v3i Abs( v3i Vec ) { v3i Result; - Result.E[0] = (s32)Abs( Vec.E[0] ); + Result.E[0] = (s32)Abs( Vec.E[0] ); Result.E[1] = (s32)Abs( Vec.E[1] ); Result.E[2] = (s32)Abs( Vec.E[2] ); + return Result; } @@ -49,9 +51,10 @@ inline v3i GetSign( v3i Vec ) { v3i Result; - Result.E[0] = GetSign( Vec.E[0] ); + Result.E[0] = GetSign( Vec.E[0] ); Result.E[1] = GetSign( Vec.E[1] ); Result.E[2] = GetSign( Vec.E[2] ); + return Result; } @@ -60,9 +63,10 @@ inline v3i Bilateral( v3i Vec ) { v3i Result; - Result.E[0] = Bilateral( Vec.E[0] ); + Result.E[0] = Bilateral( Vec.E[0] ); Result.E[1] = Bilateral( Vec.E[1] ); Result.E[2] = Bilateral( Vec.E[2] ); + return Result; } @@ -70,9 +74,10 @@ inline v3i ClampNegative( v3i V ) { v3i Result = V; - if ( V.E[0] > s32(0) ) Result.E[0] = s32(0); + if ( V.E[0] > s32(0) ) Result.E[0] = s32(0); if ( V.E[1] > s32(0) ) Result.E[1] = s32(0); if ( V.E[2] > s32(0) ) Result.E[2] = s32(0); + return Result; } @@ -80,9 +85,10 @@ inline v3i ClampPositive( v3i V ) { v3i Result = V; - if ( V.E[0] < s32(0) ) Result.E[0] = s32(0); + if ( V.E[0] < s32(0) ) Result.E[0] = s32(0); if ( V.E[1] < s32(0) ) Result.E[1] = s32(0); if ( V.E[2] < s32(0) ) Result.E[2] = s32(0); + return Result; } @@ -90,12 +96,13 @@ inline v3i Clamp01( v3i V ) { v3i Result = V; - if ( V.E[0] < s32(0) ) Result.E[0] = s32(0); + if ( V.E[0] < s32(0) ) Result.E[0] = s32(0); if ( V.E[0] > s32(1) ) Result.E[0] = s32(1); if ( V.E[1] < s32(0) ) Result.E[1] = s32(0); if ( V.E[1] > s32(1) ) Result.E[1] = s32(1); if ( V.E[2] < s32(0) ) Result.E[2] = s32(0); if ( V.E[2] > s32(1) ) Result.E[2] = s32(1); + return Result; } diff --git a/generated/gen_constructor_gpu_readback_buffer.h b/generated/gen_constructor_gpu_readback_buffer.h new file mode 100644 index 000000000..4c0bf984d --- /dev/null +++ b/generated/gen_constructor_gpu_readback_buffer.h @@ -0,0 +1,18 @@ +// external/bonsai_stdlib/src/poof_functions.h:115:0 +link_internal gpu_readback_buffer +GpuReadbackBuffer( u32 PBO , GLsync Fence ) +{ + gpu_readback_buffer Reuslt = { + .PBO = PBO + +, .Fence = Fence + + + }; + + + + + return Reuslt; +} + diff --git a/generated/gen_constructor_perlin_params.h b/generated/gen_constructor_perlin_params.h new file mode 100644 index 000000000..342c4470f --- /dev/null +++ b/generated/gen_constructor_perlin_params.h @@ -0,0 +1,27 @@ +// external/bonsai_stdlib/src/poof_functions.h:115:0 +link_internal perlin_params +PerlinParams( u32_8x P0 , u32_8x P1 , f32_8x Fract0 , f32_8x Fract1 , f32_8x Fade ) +{ + perlin_params Reuslt = { + .P0 = P0 + +, .P1 = P1 + +, .Fract0 = Fract0 + +, .Fract1 = Fract1 + +, .Fade = Fade + + + }; + + + + + + + + return Reuslt; +} + diff --git a/generated/gen_constructor_vertex_material.h b/generated/gen_constructor_vertex_material.h index 188e60073..76e2f944a 100644 --- a/generated/gen_constructor_vertex_material.h +++ b/generated/gen_constructor_vertex_material.h @@ -1,17 +1,21 @@ -// external/bonsai_stdlib/src/mesh.h:35:0 - +// external/bonsai_stdlib/src/poof_functions.h:115:0 link_internal vertex_material -VertexMaterial( u16 ColorIndex , u8 Transparency , u8 Emission ) +VertexMaterial( u16 ColorIndex , u8 Transparency , u8 Emission ) { vertex_material Reuslt = { - .ColorIndex = ColorIndex -, - .Transparency = Transparency -, - .Emission = Emission + .ColorIndex = ColorIndex + +, .Transparency = Transparency + +, .Emission = Emission + + }; + + + return Reuslt; } diff --git a/generated/gen_constructor_voxel_lighting.h b/generated/gen_constructor_voxel_lighting.h index 240522733..9dfb90d8c 100644 --- a/generated/gen_constructor_voxel_lighting.h +++ b/generated/gen_constructor_voxel_lighting.h @@ -1,13 +1,15 @@ -// src/engine/world_chunk.h:135:0 - +// external/bonsai_stdlib/src/poof_functions.h:115:0 link_internal voxel_lighting -VoxelLighting( u8 Emission ) +VoxelLighting( u8 Emission ) { voxel_lighting Reuslt = { - .Emission = Emission + .Emission = Emission + + }; - + + return Reuslt; } diff --git a/generated/gen_constructor_voxel_stack_element.h b/generated/gen_constructor_voxel_stack_element.h index fc8f4fbc6..fe1805080 100644 --- a/generated/gen_constructor_voxel_stack_element.h +++ b/generated/gen_constructor_voxel_stack_element.h @@ -1,15 +1,18 @@ -// src/engine/world_update.h:32:0 - +// external/bonsai_stdlib/src/poof_functions.h:115:0 link_internal voxel_stack_element -VoxelStackElement( v3i VoxSimP , voxel_rule_direction Dir ) +VoxelStackElement( v3i VoxSimP , voxel_rule_direction Dir ) { voxel_stack_element Reuslt = { - .VoxSimP = VoxSimP -, - .Dir = Dir + .VoxSimP = VoxSimP + +, .Dir = Dir + + }; + + return Reuslt; } diff --git a/generated/gen_constructor_voxel_synthesis_change_propagation_info.h b/generated/gen_constructor_voxel_synthesis_change_propagation_info.h index 07de319f4..7a2feeccc 100644 --- a/generated/gen_constructor_voxel_synthesis_change_propagation_info.h +++ b/generated/gen_constructor_voxel_synthesis_change_propagation_info.h @@ -1,17 +1,21 @@ -// src/engine/voxel_synthesis.h:304:0 - +// external/bonsai_stdlib/src/poof_functions.h:115:0 link_internal voxel_synthesis_change_propagation_info -VoxelSynthesisChangePropagationInfo( tile_rule PrevTileOptions , v3i PrevTileP , v3i DirOfTravel ) +VoxelSynthesisChangePropagationInfo( tile_rule PrevTileOptions , v3i PrevTileP , v3i DirOfTravel ) { voxel_synthesis_change_propagation_info Reuslt = { - .PrevTileOptions = PrevTileOptions -, - .PrevTileP = PrevTileP -, - .DirOfTravel = DirOfTravel + .PrevTileOptions = PrevTileOptions + +, .PrevTileP = PrevTileP + +, .DirOfTravel = DirOfTravel + + }; + + + return Reuslt; } diff --git a/generated/gen_default_equality_operator_tile_rule_id.h b/generated/gen_default_equality_operator_tile_rule_id.h index 382ef129b..56318ec4b 100644 --- a/generated/gen_default_equality_operator_tile_rule_id.h +++ b/generated/gen_default_equality_operator_tile_rule_id.h @@ -1,9 +1,8 @@ -// src/engine/voxel_synthesis.h:21:0 - +// external/bonsai_stdlib/src/poof_functions.h:96:0 link_internal b32 operator==( tile_rule_id E1, tile_rule_id E2 ) { - b32 Reuslt = E1.PageIndex == E2.PageIndex && E1.Bit == E2.Bit ; + b32 Reuslt = E1.PageIndex == E2.PageIndex && E1.Bit == E2.Bit ; return Reuslt; } diff --git a/generated/gen_default_equality_operator_ui_id.h b/generated/gen_default_equality_operator_ui_id.h index d5012f64b..5178cf0af 100644 --- a/generated/gen_default_equality_operator_ui_id.h +++ b/generated/gen_default_equality_operator_ui_id.h @@ -1,9 +1,8 @@ -// external/bonsai_stdlib/src/ui/interactable.h:29:0 - +// external/bonsai_stdlib/src/poof_functions.h:96:0 link_internal b32 operator==( ui_id E1, ui_id E2 ) { - b32 Reuslt = E1._Reserved == E2._Reserved && E1.WindowBits == E2.WindowBits && E1.InteractionBits == E2.InteractionBits && E1.ElementBits == E2.ElementBits ; + b32 Reuslt = E1._Reserved == E2._Reserved && E1.WindowBits == E2.WindowBits && E1.InteractionBits == E2.InteractionBits && E1.ElementBits == E2.ElementBits ; return Reuslt; } diff --git a/generated/gen_hetero_vector_operators_v2_v2i.h b/generated/gen_hetero_vector_operators_v2_v2i.h index 49d98f943..db89dec20 100644 --- a/generated/gen_hetero_vector_operators_v2_v2i.h +++ b/generated/gen_hetero_vector_operators_v2_v2i.h @@ -1,11 +1,11 @@ -// external/bonsai_stdlib/src/vector.h:226:0 - +// external/bonsai_stdlib/src/poof_functions.h:355:0 inline v2 operator+( v2 P1, v2i P2 ) { v2 Result; - Result.E[0] = Cast(r32, P1.E[0] + Cast(r32, P2.E[0])); + Result.E[0] = Cast(r32, P1.E[0] + Cast(r32, P2.E[0])); Result.E[1] = Cast(r32, P1.E[1] + Cast(r32, P2.E[1])); + return Result; } @@ -15,8 +15,9 @@ inline v2 operator-( v2 P1, v2i P2 ) { v2 Result; - Result.E[0] = Cast(r32, P1.E[0] - Cast(r32, P2.E[0])); + Result.E[0] = Cast(r32, P1.E[0] - Cast(r32, P2.E[0])); Result.E[1] = Cast(r32, P1.E[1] - Cast(r32, P2.E[1])); + return Result; } @@ -26,8 +27,9 @@ inline v2 operator*( v2 P1, v2i P2 ) { v2 Result; - Result.E[0] = Cast(r32, P1.E[0] * Cast(r32, P2.E[0])); + Result.E[0] = Cast(r32, P1.E[0] * Cast(r32, P2.E[0])); Result.E[1] = Cast(r32, P1.E[1] * Cast(r32, P2.E[1])); + return Result; } @@ -37,8 +39,9 @@ inline v2 operator/( v2 P1, v2i P2 ) { v2 Result; - Result.E[0] = Cast(r32, P1.E[0] / Cast(r32, P2.E[0])); + Result.E[0] = Cast(r32, P1.E[0] / Cast(r32, P2.E[0])); Result.E[1] = Cast(r32, P1.E[1] / Cast(r32, P2.E[1])); + return Result; } diff --git a/generated/gen_hetero_vector_operators_v2i_v2.h b/generated/gen_hetero_vector_operators_v2i_v2.h index 775ef8e1c..95e6ada9c 100644 --- a/generated/gen_hetero_vector_operators_v2i_v2.h +++ b/generated/gen_hetero_vector_operators_v2i_v2.h @@ -1,11 +1,11 @@ -// external/bonsai_stdlib/src/vector.h:229:0 - +// external/bonsai_stdlib/src/poof_functions.h:355:0 inline v2i operator+( v2i P1, v2 P2 ) { v2i Result; - Result.E[0] = Cast(s32, P1.E[0] + Cast(s32, P2.E[0])); + Result.E[0] = Cast(s32, P1.E[0] + Cast(s32, P2.E[0])); Result.E[1] = Cast(s32, P1.E[1] + Cast(s32, P2.E[1])); + return Result; } @@ -15,8 +15,9 @@ inline v2i operator-( v2i P1, v2 P2 ) { v2i Result; - Result.E[0] = Cast(s32, P1.E[0] - Cast(s32, P2.E[0])); + Result.E[0] = Cast(s32, P1.E[0] - Cast(s32, P2.E[0])); Result.E[1] = Cast(s32, P1.E[1] - Cast(s32, P2.E[1])); + return Result; } @@ -26,8 +27,9 @@ inline v2i operator*( v2i P1, v2 P2 ) { v2i Result; - Result.E[0] = Cast(s32, P1.E[0] * Cast(s32, P2.E[0])); + Result.E[0] = Cast(s32, P1.E[0] * Cast(s32, P2.E[0])); Result.E[1] = Cast(s32, P1.E[1] * Cast(s32, P2.E[1])); + return Result; } @@ -37,8 +39,9 @@ inline v2i operator/( v2i P1, v2 P2 ) { v2i Result; - Result.E[0] = Cast(s32, P1.E[0] / Cast(s32, P2.E[0])); + Result.E[0] = Cast(s32, P1.E[0] / Cast(s32, P2.E[0])); Result.E[1] = Cast(s32, P1.E[1] / Cast(s32, P2.E[1])); + return Result; } diff --git a/generated/gen_hetero_vector_operators_v3_u8_v3.h b/generated/gen_hetero_vector_operators_v3_u8_v3.h index 761cf0591..912451aa0 100644 --- a/generated/gen_hetero_vector_operators_v3_u8_v3.h +++ b/generated/gen_hetero_vector_operators_v3_u8_v3.h @@ -1,12 +1,12 @@ -// external/bonsai_stdlib/src/vector.h:241:0 - +// external/bonsai_stdlib/src/poof_functions.h:355:0 inline v3_u8 operator+( v3_u8 P1, v3 P2 ) { v3_u8 Result; - Result.E[0] = Cast(u8, P1.E[0] + Cast(u8, P2.E[0])); + Result.E[0] = Cast(u8, P1.E[0] + Cast(u8, P2.E[0])); Result.E[1] = Cast(u8, P1.E[1] + Cast(u8, P2.E[1])); Result.E[2] = Cast(u8, P1.E[2] + Cast(u8, P2.E[2])); + return Result; } @@ -16,9 +16,10 @@ inline v3_u8 operator-( v3_u8 P1, v3 P2 ) { v3_u8 Result; - Result.E[0] = Cast(u8, P1.E[0] - Cast(u8, P2.E[0])); + Result.E[0] = Cast(u8, P1.E[0] - Cast(u8, P2.E[0])); Result.E[1] = Cast(u8, P1.E[1] - Cast(u8, P2.E[1])); Result.E[2] = Cast(u8, P1.E[2] - Cast(u8, P2.E[2])); + return Result; } @@ -28,9 +29,10 @@ inline v3_u8 operator*( v3_u8 P1, v3 P2 ) { v3_u8 Result; - Result.E[0] = Cast(u8, P1.E[0] * Cast(u8, P2.E[0])); + Result.E[0] = Cast(u8, P1.E[0] * Cast(u8, P2.E[0])); Result.E[1] = Cast(u8, P1.E[1] * Cast(u8, P2.E[1])); Result.E[2] = Cast(u8, P1.E[2] * Cast(u8, P2.E[2])); + return Result; } @@ -40,9 +42,10 @@ inline v3_u8 operator/( v3_u8 P1, v3 P2 ) { v3_u8 Result; - Result.E[0] = Cast(u8, P1.E[0] / Cast(u8, P2.E[0])); + Result.E[0] = Cast(u8, P1.E[0] / Cast(u8, P2.E[0])); Result.E[1] = Cast(u8, P1.E[1] / Cast(u8, P2.E[1])); Result.E[2] = Cast(u8, P1.E[2] / Cast(u8, P2.E[2])); + return Result; } diff --git a/generated/gen_hetero_vector_operators_v3_u8_v3i.h b/generated/gen_hetero_vector_operators_v3_u8_v3i.h index e5977a31b..395eec253 100644 --- a/generated/gen_hetero_vector_operators_v3_u8_v3i.h +++ b/generated/gen_hetero_vector_operators_v3_u8_v3i.h @@ -1,12 +1,12 @@ -// external/bonsai_stdlib/src/vector.h:238:0 - +// external/bonsai_stdlib/src/poof_functions.h:355:0 inline v3_u8 operator+( v3_u8 P1, v3i P2 ) { v3_u8 Result; - Result.E[0] = Cast(u8, P1.E[0] + Cast(u8, P2.E[0])); + Result.E[0] = Cast(u8, P1.E[0] + Cast(u8, P2.E[0])); Result.E[1] = Cast(u8, P1.E[1] + Cast(u8, P2.E[1])); Result.E[2] = Cast(u8, P1.E[2] + Cast(u8, P2.E[2])); + return Result; } @@ -16,9 +16,10 @@ inline v3_u8 operator-( v3_u8 P1, v3i P2 ) { v3_u8 Result; - Result.E[0] = Cast(u8, P1.E[0] - Cast(u8, P2.E[0])); + Result.E[0] = Cast(u8, P1.E[0] - Cast(u8, P2.E[0])); Result.E[1] = Cast(u8, P1.E[1] - Cast(u8, P2.E[1])); Result.E[2] = Cast(u8, P1.E[2] - Cast(u8, P2.E[2])); + return Result; } @@ -28,9 +29,10 @@ inline v3_u8 operator*( v3_u8 P1, v3i P2 ) { v3_u8 Result; - Result.E[0] = Cast(u8, P1.E[0] * Cast(u8, P2.E[0])); + Result.E[0] = Cast(u8, P1.E[0] * Cast(u8, P2.E[0])); Result.E[1] = Cast(u8, P1.E[1] * Cast(u8, P2.E[1])); Result.E[2] = Cast(u8, P1.E[2] * Cast(u8, P2.E[2])); + return Result; } @@ -40,9 +42,10 @@ inline v3_u8 operator/( v3_u8 P1, v3i P2 ) { v3_u8 Result; - Result.E[0] = Cast(u8, P1.E[0] / Cast(u8, P2.E[0])); + Result.E[0] = Cast(u8, P1.E[0] / Cast(u8, P2.E[0])); Result.E[1] = Cast(u8, P1.E[1] / Cast(u8, P2.E[1])); Result.E[2] = Cast(u8, P1.E[2] / Cast(u8, P2.E[2])); + return Result; } diff --git a/generated/gen_hetero_vector_operators_v3_v3i.h b/generated/gen_hetero_vector_operators_v3_v3i.h index fbd0644cc..a1214b70d 100644 --- a/generated/gen_hetero_vector_operators_v3_v3i.h +++ b/generated/gen_hetero_vector_operators_v3_v3i.h @@ -1,12 +1,12 @@ -// external/bonsai_stdlib/src/vector.h:232:0 - +// external/bonsai_stdlib/src/poof_functions.h:355:0 inline v3 operator+( v3 P1, v3i P2 ) { v3 Result; - Result.E[0] = Cast(r32, P1.E[0] + Cast(r32, P2.E[0])); + Result.E[0] = Cast(r32, P1.E[0] + Cast(r32, P2.E[0])); Result.E[1] = Cast(r32, P1.E[1] + Cast(r32, P2.E[1])); Result.E[2] = Cast(r32, P1.E[2] + Cast(r32, P2.E[2])); + return Result; } @@ -16,9 +16,10 @@ inline v3 operator-( v3 P1, v3i P2 ) { v3 Result; - Result.E[0] = Cast(r32, P1.E[0] - Cast(r32, P2.E[0])); + Result.E[0] = Cast(r32, P1.E[0] - Cast(r32, P2.E[0])); Result.E[1] = Cast(r32, P1.E[1] - Cast(r32, P2.E[1])); Result.E[2] = Cast(r32, P1.E[2] - Cast(r32, P2.E[2])); + return Result; } @@ -28,9 +29,10 @@ inline v3 operator*( v3 P1, v3i P2 ) { v3 Result; - Result.E[0] = Cast(r32, P1.E[0] * Cast(r32, P2.E[0])); + Result.E[0] = Cast(r32, P1.E[0] * Cast(r32, P2.E[0])); Result.E[1] = Cast(r32, P1.E[1] * Cast(r32, P2.E[1])); Result.E[2] = Cast(r32, P1.E[2] * Cast(r32, P2.E[2])); + return Result; } @@ -40,9 +42,10 @@ inline v3 operator/( v3 P1, v3i P2 ) { v3 Result; - Result.E[0] = Cast(r32, P1.E[0] / Cast(r32, P2.E[0])); + Result.E[0] = Cast(r32, P1.E[0] / Cast(r32, P2.E[0])); Result.E[1] = Cast(r32, P1.E[1] / Cast(r32, P2.E[1])); Result.E[2] = Cast(r32, P1.E[2] / Cast(r32, P2.E[2])); + return Result; } diff --git a/generated/gen_hetero_vector_operators_v3i_v3.h b/generated/gen_hetero_vector_operators_v3i_v3.h index 947fcbf96..252a785e3 100644 --- a/generated/gen_hetero_vector_operators_v3i_v3.h +++ b/generated/gen_hetero_vector_operators_v3i_v3.h @@ -1,12 +1,12 @@ -// external/bonsai_stdlib/src/vector.h:235:0 - +// external/bonsai_stdlib/src/poof_functions.h:355:0 inline v3i operator+( v3i P1, v3 P2 ) { v3i Result; - Result.E[0] = Cast(s32, P1.E[0] + Cast(s32, P2.E[0])); + Result.E[0] = Cast(s32, P1.E[0] + Cast(s32, P2.E[0])); Result.E[1] = Cast(s32, P1.E[1] + Cast(s32, P2.E[1])); Result.E[2] = Cast(s32, P1.E[2] + Cast(s32, P2.E[2])); + return Result; } @@ -16,9 +16,10 @@ inline v3i operator-( v3i P1, v3 P2 ) { v3i Result; - Result.E[0] = Cast(s32, P1.E[0] - Cast(s32, P2.E[0])); + Result.E[0] = Cast(s32, P1.E[0] - Cast(s32, P2.E[0])); Result.E[1] = Cast(s32, P1.E[1] - Cast(s32, P2.E[1])); Result.E[2] = Cast(s32, P1.E[2] - Cast(s32, P2.E[2])); + return Result; } @@ -28,9 +29,10 @@ inline v3i operator*( v3i P1, v3 P2 ) { v3i Result; - Result.E[0] = Cast(s32, P1.E[0] * Cast(s32, P2.E[0])); + Result.E[0] = Cast(s32, P1.E[0] * Cast(s32, P2.E[0])); Result.E[1] = Cast(s32, P1.E[1] * Cast(s32, P2.E[1])); Result.E[2] = Cast(s32, P1.E[2] * Cast(s32, P2.E[2])); + return Result; } @@ -40,9 +42,10 @@ inline v3i operator/( v3i P1, v3 P2 ) { v3i Result; - Result.E[0] = Cast(s32, P1.E[0] / Cast(s32, P2.E[0])); + Result.E[0] = Cast(s32, P1.E[0] / Cast(s32, P2.E[0])); Result.E[1] = Cast(s32, P1.E[1] / Cast(s32, P2.E[1])); Result.E[2] = Cast(s32, P1.E[2] / Cast(s32, P2.E[2])); + return Result; } diff --git a/generated/gen_lerp_f32.h b/generated/gen_lerp_f32.h index 38b06e1d6..c81c293b4 100644 --- a/generated/gen_lerp_f32.h +++ b/generated/gen_lerp_f32.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/maff.h:22:0 - +// external/bonsai_stdlib/src/poof_functions.h:374:0 inline f32 Lerp(r32 t, f32 P1, f32 P2) { diff --git a/generated/gen_lerp_v2.h b/generated/gen_lerp_v2.h index 801286d62..2a4429aa3 100644 --- a/generated/gen_lerp_v2.h +++ b/generated/gen_lerp_v2.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/vector.h:771:0 - +// external/bonsai_stdlib/src/poof_functions.h:374: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 c263fe0f8..3ea998243 100644 --- a/generated/gen_lerp_v3.h +++ b/generated/gen_lerp_v3.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/vector.h:774:0 - +// external/bonsai_stdlib/src/poof_functions.h:374:0 inline v3 Lerp(r32 t, v3 P1, v3 P2) { diff --git a/generated/gen_map_value_to_range_r32.h b/generated/gen_map_value_to_range_r32.h index 3ad870836..9036e1285 100644 --- a/generated/gen_map_value_to_range_r32.h +++ b/generated/gen_map_value_to_range_r32.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/random.h:203:0 - +// external/bonsai_stdlib/src/random.h:177:0 link_internal r32 MapValueToRange( r32 LowestPossibleValue, r32 Value, r32 HighestPossibleValue) { diff --git a/generated/gen_map_value_to_range_s32.h b/generated/gen_map_value_to_range_s32.h index 4f1f0a57a..d09270f9a 100644 --- a/generated/gen_map_value_to_range_s32.h +++ b/generated/gen_map_value_to_range_s32.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/random.h:209:0 - +// external/bonsai_stdlib/src/random.h:177:0 link_internal s32 MapValueToRange( s32 LowestPossibleValue, r32 Value, s32 HighestPossibleValue) { diff --git a/generated/gen_map_value_to_range_u32.h b/generated/gen_map_value_to_range_u32.h index 58d1a8629..95a5d8044 100644 --- a/generated/gen_map_value_to_range_u32.h +++ b/generated/gen_map_value_to_range_u32.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/random.h:206:0 - +// external/bonsai_stdlib/src/random.h:177:0 link_internal u32 MapValueToRange( u32 LowestPossibleValue, r32 Value, u32 HighestPossibleValue) { diff --git a/generated/gen_primitive_deep_copy_715421923.h b/generated/gen_primitive_deep_copy_715421923.h index e626cebd3..b34f9650c 100644 --- a/generated/gen_primitive_deep_copy_715421923.h +++ b/generated/gen_primitive_deep_copy_715421923.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/primitives.h:243:0 - +// external/bonsai_stdlib/src/primitives.h:238:0 link_internal void DeepCopy( s64 *Src, s64 *Dest ) { @@ -51,3 +50,4 @@ DeepCopy( u8 *Src, u8 *Dest ) *Dest = *Src; } + diff --git a/generated/gen_random_between_r32.h b/generated/gen_random_between_r32.h index 19fe39b41..ea73bbbcb 100644 --- a/generated/gen_random_between_r32.h +++ b/generated/gen_random_between_r32.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/random.h:229:0 - +// external/bonsai_stdlib/src/random.h:215:0 link_internal r32 RandomBetween( r32 LowestPossibleValue, random_series *Entropy, r32 HighestPossibleValue) { diff --git a/generated/gen_random_between_s32.h b/generated/gen_random_between_s32.h index 07badf979..56f1ae49f 100644 --- a/generated/gen_random_between_s32.h +++ b/generated/gen_random_between_s32.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/random.h:235:0 - +// external/bonsai_stdlib/src/random.h:215:0 link_internal s32 RandomBetween( s32 LowestPossibleValue, random_series *Entropy, s32 HighestPossibleValue) { diff --git a/generated/gen_random_between_u32.h b/generated/gen_random_between_u32.h index 899933b0b..6d2b7b8ba 100644 --- a/generated/gen_random_between_u32.h +++ b/generated/gen_random_between_u32.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/random.h:232:0 - +// external/bonsai_stdlib/src/random.h:215:0 link_internal u32 RandomBetween( u32 LowestPossibleValue, random_series *Entropy, u32 HighestPossibleValue) { diff --git a/generated/gen_read_primitive_from_native_file_803324607.h b/generated/gen_read_primitive_from_native_file_803324607.h index 8d2883a39..2f622b99a 100644 --- a/generated/gen_read_primitive_from_native_file_803324607.h +++ b/generated/gen_read_primitive_from_native_file_803324607.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/binary_parser.cpp:431:0 - +// external/bonsai_stdlib/src/binary_parser.cpp:426:0 link_internal s8 Read_s8(native_file *File) { @@ -57,3 +56,4 @@ Read_u64(native_file *File) return Result; } + diff --git a/generated/gen_read_primitive_from_u8_cursor_little_endian_851742148.h b/generated/gen_read_primitive_from_u8_cursor_little_endian_851742148.h index 52f45d8c6..83c26b2f5 100644 --- a/generated/gen_read_primitive_from_u8_cursor_little_endian_851742148.h +++ b/generated/gen_read_primitive_from_u8_cursor_little_endian_851742148.h @@ -1,20 +1,19 @@ -// external/bonsai_stdlib/src/binary_parser.cpp:503:0 - -inline s8 +// external/bonsai_stdlib/src/binary_parser.cpp:449:0 +link_internal s8 Read_s8(u8 *Source) { s8 Result = *(s8*)Source; return Result; } -inline s8 +link_internal s8 Read_s8(s8 *Source) { s8 Result = *Source; return Result; } -inline s8 +link_internal s8 Read_s8(u8_stream *Source) { s8 Result = Read_s8(Source->At); @@ -23,7 +22,7 @@ Read_s8(u8_stream *Source) return Result; } -inline s8* +link_internal s8* ReadArray_s8(u8_stream *Source, u32 Count) { s8 *Result = (s8*)Source->At; @@ -31,21 +30,21 @@ ReadArray_s8(u8_stream *Source, u32 Count) Assert(Source->At <= Source->End); return Result; } -inline s16 +link_internal s16 Read_s16(u8 *Source) { s16 Result = *(s16*)Source; return Result; } -inline s16 +link_internal s16 Read_s16(s16 *Source) { s16 Result = *Source; return Result; } -inline s16 +link_internal s16 Read_s16(u8_stream *Source) { s16 Result = Read_s16(Source->At); @@ -54,7 +53,7 @@ Read_s16(u8_stream *Source) return Result; } -inline s16* +link_internal s16* ReadArray_s16(u8_stream *Source, u32 Count) { s16 *Result = (s16*)Source->At; @@ -62,21 +61,21 @@ ReadArray_s16(u8_stream *Source, u32 Count) Assert(Source->At <= Source->End); return Result; } -inline u16 +link_internal u16 Read_u16(u8 *Source) { u16 Result = *(u16*)Source; return Result; } -inline u16 +link_internal u16 Read_u16(u16 *Source) { u16 Result = *Source; return Result; } -inline u16 +link_internal u16 Read_u16(u8_stream *Source) { u16 Result = Read_u16(Source->At); @@ -85,7 +84,7 @@ Read_u16(u8_stream *Source) return Result; } -inline u16* +link_internal u16* ReadArray_u16(u8_stream *Source, u32 Count) { u16 *Result = (u16*)Source->At; @@ -93,21 +92,21 @@ ReadArray_u16(u8_stream *Source, u32 Count) Assert(Source->At <= Source->End); return Result; } -inline s32 +link_internal s32 Read_s32(u8 *Source) { s32 Result = *(s32*)Source; return Result; } -inline s32 +link_internal s32 Read_s32(s32 *Source) { s32 Result = *Source; return Result; } -inline s32 +link_internal s32 Read_s32(u8_stream *Source) { s32 Result = Read_s32(Source->At); @@ -116,7 +115,7 @@ Read_s32(u8_stream *Source) return Result; } -inline s32* +link_internal s32* ReadArray_s32(u8_stream *Source, u32 Count) { s32 *Result = (s32*)Source->At; @@ -124,21 +123,21 @@ ReadArray_s32(u8_stream *Source, u32 Count) Assert(Source->At <= Source->End); return Result; } -inline u32 +link_internal u32 Read_u32(u8 *Source) { u32 Result = *(u32*)Source; return Result; } -inline u32 +link_internal u32 Read_u32(u32 *Source) { u32 Result = *Source; return Result; } -inline u32 +link_internal u32 Read_u32(u8_stream *Source) { u32 Result = Read_u32(Source->At); @@ -147,7 +146,7 @@ Read_u32(u8_stream *Source) return Result; } -inline u32* +link_internal u32* ReadArray_u32(u8_stream *Source, u32 Count) { u32 *Result = (u32*)Source->At; @@ -155,21 +154,21 @@ ReadArray_u32(u8_stream *Source, u32 Count) Assert(Source->At <= Source->End); return Result; } -inline s64 +link_internal s64 Read_s64(u8 *Source) { s64 Result = *(s64*)Source; return Result; } -inline s64 +link_internal s64 Read_s64(s64 *Source) { s64 Result = *Source; return Result; } -inline s64 +link_internal s64 Read_s64(u8_stream *Source) { s64 Result = Read_s64(Source->At); @@ -178,7 +177,7 @@ Read_s64(u8_stream *Source) return Result; } -inline s64* +link_internal s64* ReadArray_s64(u8_stream *Source, u32 Count) { s64 *Result = (s64*)Source->At; @@ -186,21 +185,21 @@ ReadArray_s64(u8_stream *Source, u32 Count) Assert(Source->At <= Source->End); return Result; } -inline u64 +link_internal u64 Read_u64(u8 *Source) { u64 Result = *(u64*)Source; return Result; } -inline u64 +link_internal u64 Read_u64(u64 *Source) { u64 Result = *Source; return Result; } -inline u64 +link_internal u64 Read_u64(u8_stream *Source) { u64 Result = Read_u64(Source->At); @@ -209,7 +208,7 @@ Read_u64(u8_stream *Source) return Result; } -inline u64* +link_internal u64* ReadArray_u64(u8_stream *Source, u32 Count) { u64 *Result = (u64*)Source->At; @@ -218,3 +217,4 @@ ReadArray_u64(u8_stream *Source, u32 Count) return Result; } + diff --git a/generated/gen_read_primitive_u32.h b/generated/gen_read_primitive_u32.h index 851e75fd8..576ae2cf5 100644 --- a/generated/gen_read_primitive_u32.h +++ b/generated/gen_read_primitive_u32.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/binary_parser.cpp:562:0 - +// external/bonsai_stdlib/src/binary_parser.cpp:555:0 link_internal bool Read_u32(u8_cursor *Cursor, u32 *Dest) { diff --git a/generated/gen_read_primitive_u64.h b/generated/gen_read_primitive_u64.h index 485d68bd1..65f2a9898 100644 --- a/generated/gen_read_primitive_u64.h +++ b/generated/gen_read_primitive_u64.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/binary_parser.cpp:565:0 - +// external/bonsai_stdlib/src/binary_parser.cpp:555:0 link_internal bool Read_u64(u8_cursor *Cursor, u64 *Dest) { diff --git a/generated/gen_rect_helpers_rect2_v2.h b/generated/gen_rect_helpers_rect2_v2.h index 0d2330f80..3467efa21 100644 --- a/generated/gen_rect_helpers_rect2_v2.h +++ b/generated/gen_rect_helpers_rect2_v2.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/rect.h:129:0 - +// external/bonsai_stdlib/src/rect.h:58:0 link_internal rect2 RectMinMax(v2 Min, v2 Max) { @@ -53,4 +52,12 @@ IsInside(v2 P, rect2 Rect) return Result; } +// TODO(Jesse)(duplicate): make Contains primal and get rid of IsInside ..? +link_internal b32 +Contains(rect2 Rect, v2 P) +{ + b32 Result = IsInside(P, Rect); + return Result; +} + diff --git a/generated/gen_rect_helpers_rect3_v3.h b/generated/gen_rect_helpers_rect3_v3.h index 8582f5106..1e2ae8b1f 100644 --- a/generated/gen_rect_helpers_rect3_v3.h +++ b/generated/gen_rect_helpers_rect3_v3.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/rect.h:133:0 - +// external/bonsai_stdlib/src/rect.h:58:0 link_internal rect3 RectMinMax(v3 Min, v3 Max) { @@ -53,4 +52,12 @@ IsInside(v3 P, rect3 Rect) return Result; } +// TODO(Jesse)(duplicate): make Contains primal and get rid of IsInside ..? +link_internal b32 +Contains(rect3 Rect, v3 P) +{ + b32 Result = IsInside(P, Rect); + return Result; +} + diff --git a/generated/gen_rect_helpers_rect3i_v3i.h b/generated/gen_rect_helpers_rect3i_v3i.h index 20d2de808..5619b612a 100644 --- a/generated/gen_rect_helpers_rect3i_v3i.h +++ b/generated/gen_rect_helpers_rect3i_v3i.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/rect.h:136:0 - +// external/bonsai_stdlib/src/rect.h:58:0 link_internal rect3i RectMinMax(v3i Min, v3i Max) { @@ -53,4 +52,12 @@ IsInside(v3i P, rect3i Rect) return Result; } +// TODO(Jesse)(duplicate): make Contains primal and get rid of IsInside ..? +link_internal b32 +Contains(rect3i Rect, v3i P) +{ + b32 Result = IsInside(P, Rect); + return Result; +} + diff --git a/generated/gen_shader_uniform_push_camera.h b/generated/gen_shader_uniform_push_camera.h index 2ac1f4dc2..59955653e 100644 --- a/generated/gen_shader_uniform_push_camera.h +++ b/generated/gen_shader_uniform_push_camera.h @@ -1,33 +1,28 @@ -// src/engine/shader.cpp:1:0 +// external/bonsai_stdlib/src/poof_functions.h:14:0 -shader_uniform * -PushShaderUniform( memory_arena *Mem, const char *Name, camera *Value) +b32 +InitShaderUniform(shader *Shader, u32 Index, camera *Value, const char *Name, u32 *Count) { - shader_uniform *Uniform = PushShaderUniform(Mem, Name); + /* Assert(Count); */ + Assert(Index < Shader->Uniforms.Count); + + shader_uniform *Uniform = Shader->Uniforms.Start + Index; + Uniform->Type = ShaderUniform_Camera; Uniform->Camera = Value; - return Uniform; -} + Uniform->Name = Name; + Uniform->Count = Count; -shader_uniform * -GetUniform(memory_arena *Mem, shader *Shader, camera *Value, const char *Name) -{ - shader_uniform *Uniform = PushShaderUniform(Mem, Name, Value); Uniform->ID = GetShaderUniform(Shader, Name); - return Uniform; + + return Uniform->ID != INVALID_SHADER_UNIFORM; } -shader_uniform -ShaderUniform(shader *Shader, camera *Value, const char *Name) +b32 +InitShaderUniform(shader *Shader, u32 Index, camera *Value, const char *Name) { - shader_uniform Uniform = {}; - - Uniform.Type = ShaderUniform_Camera; - Uniform.Camera = Value; - Uniform.Name = Name; - - Uniform.ID = GetShaderUniform(Shader, Name); - - return Uniform; + // Setting this to null implies a count of 1 + u32 *CountPtr = 0; + return InitShaderUniform(Shader, Index, Value, Name, CountPtr); } diff --git a/generated/gen_shader_uniform_push_light.h b/generated/gen_shader_uniform_push_light.h index 3f1e01a9b..f519c2c4c 100644 --- a/generated/gen_shader_uniform_push_light.h +++ b/generated/gen_shader_uniform_push_light.h @@ -1,33 +1,28 @@ -// src/engine/shader.cpp:4:0 +// external/bonsai_stdlib/src/poof_functions.h:14:0 -shader_uniform * -PushShaderUniform( memory_arena *Mem, const char *Name, light *Value) +b32 +InitShaderUniform(shader *Shader, u32 Index, light *Value, const char *Name, u32 *Count) { - shader_uniform *Uniform = PushShaderUniform(Mem, Name); + /* Assert(Count); */ + Assert(Index < Shader->Uniforms.Count); + + shader_uniform *Uniform = Shader->Uniforms.Start + Index; + Uniform->Type = ShaderUniform_Light; Uniform->Light = Value; - return Uniform; -} + Uniform->Name = Name; + Uniform->Count = Count; -shader_uniform * -GetUniform(memory_arena *Mem, shader *Shader, light *Value, const char *Name) -{ - shader_uniform *Uniform = PushShaderUniform(Mem, Name, Value); Uniform->ID = GetShaderUniform(Shader, Name); - return Uniform; + + return Uniform->ID != INVALID_SHADER_UNIFORM; } -shader_uniform -ShaderUniform(shader *Shader, light *Value, const char *Name) +b32 +InitShaderUniform(shader *Shader, u32 Index, light *Value, const char *Name) { - shader_uniform Uniform = {}; - - Uniform.Type = ShaderUniform_Light; - Uniform.Light = Value; - Uniform.Name = Name; - - Uniform.ID = GetShaderUniform(Shader, Name); - - return Uniform; + // Setting this to null implies a count of 1 + u32 *CountPtr = 0; + return InitShaderUniform(Shader, Index, Value, Name, CountPtr); } diff --git a/generated/gen_shader_uniform_push_m4.h b/generated/gen_shader_uniform_push_m4.h index 9ee3e70f9..be7894dd7 100644 --- a/generated/gen_shader_uniform_push_m4.h +++ b/generated/gen_shader_uniform_push_m4.h @@ -1,33 +1,28 @@ -// external/bonsai_stdlib/src/shader.cpp:178:0 +// external/bonsai_stdlib/src/poof_functions.h:14:0 -shader_uniform * -PushShaderUniform( memory_arena *Mem, const char *Name, m4 *Value) +b32 +InitShaderUniform(shader *Shader, u32 Index, m4 *Value, const char *Name, u32 *Count) { - shader_uniform *Uniform = PushShaderUniform(Mem, Name); + /* Assert(Count); */ + Assert(Index < Shader->Uniforms.Count); + + shader_uniform *Uniform = Shader->Uniforms.Start + Index; + Uniform->Type = ShaderUniform_M4; Uniform->M4 = Value; - return Uniform; -} + Uniform->Name = Name; + Uniform->Count = Count; -shader_uniform * -GetUniform(memory_arena *Mem, shader *Shader, m4 *Value, const char *Name) -{ - shader_uniform *Uniform = PushShaderUniform(Mem, Name, Value); Uniform->ID = GetShaderUniform(Shader, Name); - return Uniform; + + return Uniform->ID != INVALID_SHADER_UNIFORM; } -shader_uniform -ShaderUniform(shader *Shader, m4 *Value, const char *Name) +b32 +InitShaderUniform(shader *Shader, u32 Index, m4 *Value, const char *Name) { - shader_uniform Uniform = {}; - - Uniform.Type = ShaderUniform_M4; - Uniform.M4 = Value; - Uniform.Name = Name; - - Uniform.ID = GetShaderUniform(Shader, Name); - - return Uniform; + // Setting this to null implies a count of 1 + u32 *CountPtr = 0; + return InitShaderUniform(Shader, Index, Value, Name, CountPtr); } diff --git a/generated/gen_shader_uniform_push_r32.h b/generated/gen_shader_uniform_push_r32.h index 49142ad60..6b8efaa31 100644 --- a/generated/gen_shader_uniform_push_r32.h +++ b/generated/gen_shader_uniform_push_r32.h @@ -1,33 +1,28 @@ -// external/bonsai_stdlib/src/shader.cpp:193:0 +// external/bonsai_stdlib/src/poof_functions.h:14:0 -shader_uniform * -PushShaderUniform( memory_arena *Mem, const char *Name, r32 *Value) +b32 +InitShaderUniform(shader *Shader, u32 Index, r32 *Value, const char *Name, u32 *Count) { - shader_uniform *Uniform = PushShaderUniform(Mem, Name); + /* Assert(Count); */ + Assert(Index < Shader->Uniforms.Count); + + shader_uniform *Uniform = Shader->Uniforms.Start + Index; + Uniform->Type = ShaderUniform_R32; Uniform->R32 = Value; - return Uniform; -} + Uniform->Name = Name; + Uniform->Count = Count; -shader_uniform * -GetUniform(memory_arena *Mem, shader *Shader, r32 *Value, const char *Name) -{ - shader_uniform *Uniform = PushShaderUniform(Mem, Name, Value); Uniform->ID = GetShaderUniform(Shader, Name); - return Uniform; + + return Uniform->ID != INVALID_SHADER_UNIFORM; } -shader_uniform -ShaderUniform(shader *Shader, r32 *Value, const char *Name) +b32 +InitShaderUniform(shader *Shader, u32 Index, r32 *Value, const char *Name) { - shader_uniform Uniform = {}; - - Uniform.Type = ShaderUniform_R32; - Uniform.R32 = Value; - Uniform.Name = Name; - - Uniform.ID = GetShaderUniform(Shader, Name); - - return Uniform; + // Setting this to null implies a count of 1 + u32 *CountPtr = 0; + return InitShaderUniform(Shader, Index, Value, Name, CountPtr); } diff --git a/generated/gen_shader_uniform_push_s32.h b/generated/gen_shader_uniform_push_s32.h index 280319422..c4e59ce77 100644 --- a/generated/gen_shader_uniform_push_s32.h +++ b/generated/gen_shader_uniform_push_s32.h @@ -1,33 +1,28 @@ -// external/bonsai_stdlib/src/shader.cpp:190:0 +// external/bonsai_stdlib/src/poof_functions.h:14:0 -shader_uniform * -PushShaderUniform( memory_arena *Mem, const char *Name, s32 *Value) +b32 +InitShaderUniform(shader *Shader, u32 Index, s32 *Value, const char *Name, u32 *Count) { - shader_uniform *Uniform = PushShaderUniform(Mem, Name); + /* Assert(Count); */ + Assert(Index < Shader->Uniforms.Count); + + shader_uniform *Uniform = Shader->Uniforms.Start + Index; + Uniform->Type = ShaderUniform_S32; Uniform->S32 = Value; - return Uniform; -} + Uniform->Name = Name; + Uniform->Count = Count; -shader_uniform * -GetUniform(memory_arena *Mem, shader *Shader, s32 *Value, const char *Name) -{ - shader_uniform *Uniform = PushShaderUniform(Mem, Name, Value); Uniform->ID = GetShaderUniform(Shader, Name); - return Uniform; + + return Uniform->ID != INVALID_SHADER_UNIFORM; } -shader_uniform -ShaderUniform(shader *Shader, s32 *Value, const char *Name) +b32 +InitShaderUniform(shader *Shader, u32 Index, s32 *Value, const char *Name) { - shader_uniform Uniform = {}; - - Uniform.Type = ShaderUniform_S32; - Uniform.S32 = Value; - Uniform.Name = Name; - - Uniform.ID = GetShaderUniform(Shader, Name); - - return Uniform; + // Setting this to null implies a count of 1 + u32 *CountPtr = 0; + return InitShaderUniform(Shader, Index, Value, Name, CountPtr); } diff --git a/generated/gen_shader_uniform_push_texture.h b/generated/gen_shader_uniform_push_texture.h index 2cdcd0253..d89b57be2 100644 --- a/generated/gen_shader_uniform_push_texture.h +++ b/generated/gen_shader_uniform_push_texture.h @@ -1,33 +1,28 @@ -// external/bonsai_stdlib/src/shader.cpp:175:0 +// external/bonsai_stdlib/src/poof_functions.h:14:0 -shader_uniform * -PushShaderUniform( memory_arena *Mem, const char *Name, texture *Value) +b32 +InitShaderUniform(shader *Shader, u32 Index, texture *Value, const char *Name, u32 *Count) { - shader_uniform *Uniform = PushShaderUniform(Mem, Name); + /* Assert(Count); */ + Assert(Index < Shader->Uniforms.Count); + + shader_uniform *Uniform = Shader->Uniforms.Start + Index; + Uniform->Type = ShaderUniform_Texture; Uniform->Texture = Value; - return Uniform; -} + Uniform->Name = Name; + Uniform->Count = Count; -shader_uniform * -GetUniform(memory_arena *Mem, shader *Shader, texture *Value, const char *Name) -{ - shader_uniform *Uniform = PushShaderUniform(Mem, Name, Value); Uniform->ID = GetShaderUniform(Shader, Name); - return Uniform; + + return Uniform->ID != INVALID_SHADER_UNIFORM; } -shader_uniform -ShaderUniform(shader *Shader, texture *Value, const char *Name) +b32 +InitShaderUniform(shader *Shader, u32 Index, texture *Value, const char *Name) { - shader_uniform Uniform = {}; - - Uniform.Type = ShaderUniform_Texture; - Uniform.Texture = Value; - Uniform.Name = Name; - - Uniform.ID = GetShaderUniform(Shader, Name); - - return Uniform; + // Setting this to null implies a count of 1 + u32 *CountPtr = 0; + return InitShaderUniform(Shader, Index, Value, Name, CountPtr); } diff --git a/generated/gen_shader_uniform_push_u32.h b/generated/gen_shader_uniform_push_u32.h index 0afeef8fe..33486c0d2 100644 --- a/generated/gen_shader_uniform_push_u32.h +++ b/generated/gen_shader_uniform_push_u32.h @@ -1,33 +1,28 @@ -// external/bonsai_stdlib/src/shader.cpp:187:0 +// external/bonsai_stdlib/src/poof_functions.h:14:0 -shader_uniform * -PushShaderUniform( memory_arena *Mem, const char *Name, u32 *Value) +b32 +InitShaderUniform(shader *Shader, u32 Index, u32 *Value, const char *Name, u32 *Count) { - shader_uniform *Uniform = PushShaderUniform(Mem, Name); + /* Assert(Count); */ + Assert(Index < Shader->Uniforms.Count); + + shader_uniform *Uniform = Shader->Uniforms.Start + Index; + Uniform->Type = ShaderUniform_U32; Uniform->U32 = Value; - return Uniform; -} + Uniform->Name = Name; + Uniform->Count = Count; -shader_uniform * -GetUniform(memory_arena *Mem, shader *Shader, u32 *Value, const char *Name) -{ - shader_uniform *Uniform = PushShaderUniform(Mem, Name, Value); Uniform->ID = GetShaderUniform(Shader, Name); - return Uniform; + + return Uniform->ID != INVALID_SHADER_UNIFORM; } -shader_uniform -ShaderUniform(shader *Shader, u32 *Value, const char *Name) +b32 +InitShaderUniform(shader *Shader, u32 Index, u32 *Value, const char *Name) { - shader_uniform Uniform = {}; - - Uniform.Type = ShaderUniform_U32; - Uniform.U32 = Value; - Uniform.Name = Name; - - Uniform.ID = GetShaderUniform(Shader, Name); - - return Uniform; + // Setting this to null implies a count of 1 + u32 *CountPtr = 0; + return InitShaderUniform(Shader, Index, Value, Name, CountPtr); } diff --git a/generated/gen_shader_uniform_push_v2.h b/generated/gen_shader_uniform_push_v2.h index 3b5fad0ae..e4505f590 100644 --- a/generated/gen_shader_uniform_push_v2.h +++ b/generated/gen_shader_uniform_push_v2.h @@ -1,33 +1,28 @@ -// external/bonsai_stdlib/src/shader.cpp:181:0 +// external/bonsai_stdlib/src/poof_functions.h:14:0 -shader_uniform * -PushShaderUniform( memory_arena *Mem, const char *Name, v2 *Value) +b32 +InitShaderUniform(shader *Shader, u32 Index, v2 *Value, const char *Name, u32 *Count) { - shader_uniform *Uniform = PushShaderUniform(Mem, Name); + /* Assert(Count); */ + Assert(Index < Shader->Uniforms.Count); + + shader_uniform *Uniform = Shader->Uniforms.Start + Index; + Uniform->Type = ShaderUniform_V2; Uniform->V2 = Value; - return Uniform; -} + Uniform->Name = Name; + Uniform->Count = Count; -shader_uniform * -GetUniform(memory_arena *Mem, shader *Shader, v2 *Value, const char *Name) -{ - shader_uniform *Uniform = PushShaderUniform(Mem, Name, Value); Uniform->ID = GetShaderUniform(Shader, Name); - return Uniform; + + return Uniform->ID != INVALID_SHADER_UNIFORM; } -shader_uniform -ShaderUniform(shader *Shader, v2 *Value, const char *Name) +b32 +InitShaderUniform(shader *Shader, u32 Index, v2 *Value, const char *Name) { - shader_uniform Uniform = {}; - - Uniform.Type = ShaderUniform_V2; - Uniform.V2 = Value; - Uniform.Name = Name; - - Uniform.ID = GetShaderUniform(Shader, Name); - - return Uniform; + // Setting this to null implies a count of 1 + u32 *CountPtr = 0; + return InitShaderUniform(Shader, Index, Value, Name, CountPtr); } diff --git a/generated/gen_shader_uniform_push_v3.h b/generated/gen_shader_uniform_push_v3.h index b175ad62a..e8d2c10e7 100644 --- a/generated/gen_shader_uniform_push_v3.h +++ b/generated/gen_shader_uniform_push_v3.h @@ -1,33 +1,28 @@ -// external/bonsai_stdlib/src/shader.cpp:184:0 +// external/bonsai_stdlib/src/poof_functions.h:14:0 -shader_uniform * -PushShaderUniform( memory_arena *Mem, const char *Name, v3 *Value) +b32 +InitShaderUniform(shader *Shader, u32 Index, v3 *Value, const char *Name, u32 *Count) { - shader_uniform *Uniform = PushShaderUniform(Mem, Name); + /* Assert(Count); */ + Assert(Index < Shader->Uniforms.Count); + + shader_uniform *Uniform = Shader->Uniforms.Start + Index; + Uniform->Type = ShaderUniform_V3; Uniform->V3 = Value; - return Uniform; -} + Uniform->Name = Name; + Uniform->Count = Count; -shader_uniform * -GetUniform(memory_arena *Mem, shader *Shader, v3 *Value, const char *Name) -{ - shader_uniform *Uniform = PushShaderUniform(Mem, Name, Value); Uniform->ID = GetShaderUniform(Shader, Name); - return Uniform; + + return Uniform->ID != INVALID_SHADER_UNIFORM; } -shader_uniform -ShaderUniform(shader *Shader, v3 *Value, const char *Name) +b32 +InitShaderUniform(shader *Shader, u32 Index, v3 *Value, const char *Name) { - shader_uniform Uniform = {}; - - Uniform.Type = ShaderUniform_V3; - Uniform.V3 = Value; - Uniform.Name = Name; - - Uniform.ID = GetShaderUniform(Shader, Name); - - return Uniform; + // Setting this to null implies a count of 1 + u32 *CountPtr = 0; + return InitShaderUniform(Shader, Index, Value, Name, CountPtr); } diff --git a/generated/gen_vector_area_v2.h b/generated/gen_vector_area_v2.h index 2420e773b..e5e36cf2c 100644 --- a/generated/gen_vector_area_v2.h +++ b/generated/gen_vector_area_v2.h @@ -1,11 +1,10 @@ -// external/bonsai_stdlib/src/vector.h:782:0 - +// external/bonsai_stdlib/src/poof_functions.h:429:0 inline r32 Area( v2 Vec ) { Assert(Vec.x > 0); Assert(Vec.y > 0); - r32 Result = Vec.E[0] * Vec.E[1] ; + r32 Result = Vec.E[0] * Vec.E[1] ; return Result; } diff --git a/generated/gen_vector_area_v2i.h b/generated/gen_vector_area_v2i.h index adfa2b4f5..0377528df 100644 --- a/generated/gen_vector_area_v2i.h +++ b/generated/gen_vector_area_v2i.h @@ -1,11 +1,10 @@ -// external/bonsai_stdlib/src/vector.h:785:0 - +// external/bonsai_stdlib/src/poof_functions.h:429:0 inline s32 Area( v2i Vec ) { Assert(Vec.x > 0); Assert(Vec.y > 0); - s32 Result = Vec.E[0] * Vec.E[1] ; + s32 Result = Vec.E[0] * Vec.E[1] ; return Result; } diff --git a/generated/gen_vector_infix_operator_v3i_688856393.h b/generated/gen_vector_infix_operator_v3i_688856393.h index d00a795c6..5c57d9638 100644 --- a/generated/gen_vector_infix_operator_v3i_688856393.h +++ b/generated/gen_vector_infix_operator_v3i_688856393.h @@ -1,12 +1,12 @@ -// external/bonsai_stdlib/src/vector.h:768:0 - +// external/bonsai_stdlib/src/poof_functions.h:170:0 inline v3i operator&( v3i P1, v3i P2 ) { v3i Result = { - .E[0] = P1.E[0] & P2.E[0], + .E[0] = P1.E[0] & P2.E[0], .E[1] = P1.E[1] & P2.E[1], .E[2] = P1.E[2] & P2.E[2], + }; return Result; } diff --git a/generated/gen_vector_infix_operator_v3i_688856449.h b/generated/gen_vector_infix_operator_v3i_688856449.h index ccfd0b5c5..6d2269889 100644 --- a/generated/gen_vector_infix_operator_v3i_688856449.h +++ b/generated/gen_vector_infix_operator_v3i_688856449.h @@ -1,12 +1,12 @@ -// external/bonsai_stdlib/src/vector.h:765:0 - +// external/bonsai_stdlib/src/poof_functions.h:170:0 inline v3i operator^( v3i P1, v3i P2 ) { v3i Result = { - .E[0] = P1.E[0] ^ P2.E[0], + .E[0] = P1.E[0] ^ P2.E[0], .E[1] = P1.E[1] ^ P2.E[1], .E[2] = P1.E[2] ^ P2.E[2], + }; return Result; } diff --git a/generated/gen_vector_normalize_funcs_v2.h b/generated/gen_vector_normalize_funcs_v2.h index 7cfb74479..26fbda967 100644 --- a/generated/gen_vector_normalize_funcs_v2.h +++ b/generated/gen_vector_normalize_funcs_v2.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/vector.h:797:0 - +// external/bonsai_stdlib/src/poof_functions.h:573: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 597def2ce..22f55e988 100644 --- a/generated/gen_vector_normalize_funcs_v3.h +++ b/generated/gen_vector_normalize_funcs_v3.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/vector.h:800:0 - +// external/bonsai_stdlib/src/poof_functions.h:573:0 inline v3 Normalize( v3 Vec, r32 Length) { diff --git a/generated/gen_vector_operators_v2.h b/generated/gen_vector_operators_v2.h index 7b3cde9dc..d87b935bc 100644 --- a/generated/gen_vector_operators_v2.h +++ b/generated/gen_vector_operators_v2.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/vector.h:208:0 - +// external/bonsai_stdlib/src/poof_functions.h:270:0 link_internal void DeepCopy(v2 *Src, v2 *Dest) { @@ -9,7 +8,7 @@ DeepCopy(v2 *Src, v2 *Dest) inline b32 operator==( v2 P1, v2 P2 ) { - b32 Result = ( P1.E[0] == P2.E[0] && P1.E[1] == P2.E[1] ); + b32 Result = ( P1.E[0] == P2.E[0] && P1.E[1] == P2.E[1] ); return Result; } @@ -33,10 +32,29 @@ operator!=( v2 P1, v2 P2 ) return Result; } +inline r32 +Sum( v2 P1 ) +{ + r32 Result = ( P1.E[0] + P1.E[1] ); + return Result; +} + + + +inline r32 +MaxChannel( v2 P1 ) +{ + r32 Result = P1.E[0]; + Result = Cast(r32, Max(Result, P1.E[0])); + Result = Cast(r32, Max(Result, P1.E[1])); +; + return Result; +} + inline b32 operator<( v2 P1, v2 P2 ) { - b32 Result = ( P1.E[0] < P2.E[0] && P1.E[1] < P2.E[1] ); + b32 Result = ( P1.E[0] < P2.E[0] && P1.E[1] < P2.E[1] ); return Result; } @@ -44,7 +62,7 @@ operator<( v2 P1, v2 P2 ) inline b32 operator<=( v2 P1, v2 P2 ) { - b32 Result = ( P1.E[0] <= P2.E[0] && P1.E[1] <= P2.E[1] ); + b32 Result = ( P1.E[0] <= P2.E[0] && P1.E[1] <= P2.E[1] ); return Result; } @@ -52,7 +70,7 @@ operator<=( v2 P1, v2 P2 ) inline b32 operator>( v2 P1, v2 P2 ) { - b32 Result = ( P1.E[0] > P2.E[0] && P1.E[1] > P2.E[1] ); + b32 Result = ( P1.E[0] > P2.E[0] && P1.E[1] > P2.E[1] ); return Result; } @@ -60,7 +78,7 @@ operator>( v2 P1, v2 P2 ) inline b32 operator>=( v2 P1, v2 P2 ) { - b32 Result = ( P1.E[0] >= P2.E[0] && P1.E[1] >= P2.E[1] ); + b32 Result = ( P1.E[0] >= P2.E[0] && P1.E[1] >= P2.E[1] ); return Result; } @@ -69,8 +87,9 @@ inline v2 operator+( v2 P1, v2 P2 ) { v2 Result = {{ - Cast(r32, P1.E[0] + P2.E[0]), + Cast(r32, P1.E[0] + P2.E[0]), Cast(r32, P1.E[1] + P2.E[1]), + }}; return Result; } @@ -79,8 +98,9 @@ inline v2 operator+( v2 P1, r32 Scalar ) { v2 Result = {{ - Cast(r32, P1.E[0] + Scalar), + Cast(r32, P1.E[0] + Scalar), Cast(r32, P1.E[1] + Scalar), + }}; return Result; } @@ -89,8 +109,9 @@ inline v2 operator+( r32 Scalar, v2 P1 ) { v2 Result = {{ - Cast(r32, Scalar + P1.E[0]), + Cast(r32, Scalar + P1.E[0]), Cast(r32, Scalar + P1.E[1]), + }}; return Result; } @@ -101,8 +122,9 @@ inline v2 operator-( v2 P1, v2 P2 ) { v2 Result = {{ - Cast(r32, P1.E[0] - P2.E[0]), + Cast(r32, P1.E[0] - P2.E[0]), Cast(r32, P1.E[1] - P2.E[1]), + }}; return Result; } @@ -111,8 +133,9 @@ inline v2 operator-( v2 P1, r32 Scalar ) { v2 Result = {{ - Cast(r32, P1.E[0] - Scalar), + Cast(r32, P1.E[0] - Scalar), Cast(r32, P1.E[1] - Scalar), + }}; return Result; } @@ -121,8 +144,9 @@ inline v2 operator-( r32 Scalar, v2 P1 ) { v2 Result = {{ - Cast(r32, Scalar - P1.E[0]), + Cast(r32, Scalar - P1.E[0]), Cast(r32, Scalar - P1.E[1]), + }}; return Result; } @@ -133,8 +157,9 @@ inline v2 operator*( v2 P1, v2 P2 ) { v2 Result = {{ - Cast(r32, P1.E[0] * P2.E[0]), + Cast(r32, P1.E[0] * P2.E[0]), Cast(r32, P1.E[1] * P2.E[1]), + }}; return Result; } @@ -143,8 +168,9 @@ inline v2 operator*( v2 P1, r32 Scalar ) { v2 Result = {{ - Cast(r32, P1.E[0] * Scalar), + Cast(r32, P1.E[0] * Scalar), Cast(r32, P1.E[1] * Scalar), + }}; return Result; } @@ -153,8 +179,9 @@ inline v2 operator*( r32 Scalar, v2 P1 ) { v2 Result = {{ - Cast(r32, Scalar * P1.E[0]), + Cast(r32, Scalar * P1.E[0]), Cast(r32, Scalar * P1.E[1]), + }}; return Result; } @@ -165,8 +192,9 @@ inline v2 operator/( v2 P1, v2 P2 ) { v2 Result = {{ - Cast(r32, P1.E[0] / P2.E[0]), + Cast(r32, P1.E[0] / P2.E[0]), Cast(r32, P1.E[1] / P2.E[1]), + }}; return Result; } @@ -175,8 +203,9 @@ inline v2 operator/( v2 P1, r32 Scalar ) { v2 Result = {{ - Cast(r32, P1.E[0] / Scalar), + Cast(r32, P1.E[0] / Scalar), Cast(r32, P1.E[1] / Scalar), + }}; return Result; } @@ -185,8 +214,9 @@ inline v2 operator/( r32 Scalar, v2 P1 ) { v2 Result = {{ - Cast(r32, Scalar / P1.E[0]), + Cast(r32, Scalar / P1.E[0]), Cast(r32, Scalar / P1.E[1]), + }}; return Result; } @@ -196,16 +226,18 @@ operator/( r32 Scalar, v2 P1 ) inline v2 & operator+=( v2 &P1, v2 P2 ) { - P1.E[0] += P2.E[0]; + P1.E[0] += P2.E[0]; P1.E[1] += P2.E[1]; + return P1; } inline v2 & operator+=( v2 &P1, r32 Scalar ) { - P1.E[0] += Scalar; + P1.E[0] += Scalar; P1.E[1] += Scalar; + return P1; } @@ -213,16 +245,18 @@ operator+=( v2 &P1, r32 Scalar ) inline v2 & operator-=( v2 &P1, v2 P2 ) { - P1.E[0] -= P2.E[0]; + P1.E[0] -= P2.E[0]; P1.E[1] -= P2.E[1]; + return P1; } inline v2 & operator-=( v2 &P1, r32 Scalar ) { - P1.E[0] -= Scalar; + P1.E[0] -= Scalar; P1.E[1] -= Scalar; + return P1; } @@ -230,16 +264,18 @@ operator-=( v2 &P1, r32 Scalar ) inline v2 & operator*=( v2 &P1, v2 P2 ) { - P1.E[0] *= P2.E[0]; + P1.E[0] *= P2.E[0]; P1.E[1] *= P2.E[1]; + return P1; } inline v2 & operator*=( v2 &P1, r32 Scalar ) { - P1.E[0] *= Scalar; + P1.E[0] *= Scalar; P1.E[1] *= Scalar; + return P1; } @@ -247,16 +283,18 @@ operator*=( v2 &P1, r32 Scalar ) inline v2 & operator/=( v2 &P1, v2 P2 ) { - P1.E[0] /= P2.E[0]; + P1.E[0] /= P2.E[0]; P1.E[1] /= P2.E[1]; + return P1; } inline v2 & operator/=( v2 &P1, r32 Scalar ) { - P1.E[0] /= Scalar; + P1.E[0] /= Scalar; P1.E[1] /= Scalar; + return P1; } diff --git a/generated/gen_vector_operators_v2i.h b/generated/gen_vector_operators_v2i.h index 6ff5a96a7..9fefb7c1d 100644 --- a/generated/gen_vector_operators_v2i.h +++ b/generated/gen_vector_operators_v2i.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/vector.h:211:0 - +// external/bonsai_stdlib/src/poof_functions.h:270:0 link_internal void DeepCopy(v2i *Src, v2i *Dest) { @@ -9,7 +8,7 @@ DeepCopy(v2i *Src, v2i *Dest) inline b32 operator==( v2i P1, v2i P2 ) { - b32 Result = ( P1.E[0] == P2.E[0] && P1.E[1] == P2.E[1] ); + b32 Result = ( P1.E[0] == P2.E[0] && P1.E[1] == P2.E[1] ); return Result; } @@ -33,10 +32,29 @@ operator!=( v2i P1, v2i P2 ) return Result; } +inline s32 +Sum( v2i P1 ) +{ + s32 Result = ( P1.E[0] + P1.E[1] ); + return Result; +} + + + +inline s32 +MaxChannel( v2i P1 ) +{ + s32 Result = P1.E[0]; + Result = Cast(s32, Max(Result, P1.E[0])); + Result = Cast(s32, Max(Result, P1.E[1])); +; + return Result; +} + inline b32 operator<( v2i P1, v2i P2 ) { - b32 Result = ( P1.E[0] < P2.E[0] && P1.E[1] < P2.E[1] ); + b32 Result = ( P1.E[0] < P2.E[0] && P1.E[1] < P2.E[1] ); return Result; } @@ -44,7 +62,7 @@ operator<( v2i P1, v2i P2 ) inline b32 operator<=( v2i P1, v2i P2 ) { - b32 Result = ( P1.E[0] <= P2.E[0] && P1.E[1] <= P2.E[1] ); + b32 Result = ( P1.E[0] <= P2.E[0] && P1.E[1] <= P2.E[1] ); return Result; } @@ -52,7 +70,7 @@ operator<=( v2i P1, v2i P2 ) inline b32 operator>( v2i P1, v2i P2 ) { - b32 Result = ( P1.E[0] > P2.E[0] && P1.E[1] > P2.E[1] ); + b32 Result = ( P1.E[0] > P2.E[0] && P1.E[1] > P2.E[1] ); return Result; } @@ -60,7 +78,7 @@ operator>( v2i P1, v2i P2 ) inline b32 operator>=( v2i P1, v2i P2 ) { - b32 Result = ( P1.E[0] >= P2.E[0] && P1.E[1] >= P2.E[1] ); + b32 Result = ( P1.E[0] >= P2.E[0] && P1.E[1] >= P2.E[1] ); return Result; } @@ -69,8 +87,9 @@ inline v2i operator+( v2i P1, v2i P2 ) { v2i Result = {{ - Cast(s32, P1.E[0] + P2.E[0]), + Cast(s32, P1.E[0] + P2.E[0]), Cast(s32, P1.E[1] + P2.E[1]), + }}; return Result; } @@ -79,8 +98,9 @@ inline v2i operator+( v2i P1, s32 Scalar ) { v2i Result = {{ - Cast(s32, P1.E[0] + Scalar), + Cast(s32, P1.E[0] + Scalar), Cast(s32, P1.E[1] + Scalar), + }}; return Result; } @@ -89,8 +109,9 @@ inline v2i operator+( s32 Scalar, v2i P1 ) { v2i Result = {{ - Cast(s32, Scalar + P1.E[0]), + Cast(s32, Scalar + P1.E[0]), Cast(s32, Scalar + P1.E[1]), + }}; return Result; } @@ -101,8 +122,9 @@ inline v2i operator-( v2i P1, v2i P2 ) { v2i Result = {{ - Cast(s32, P1.E[0] - P2.E[0]), + Cast(s32, P1.E[0] - P2.E[0]), Cast(s32, P1.E[1] - P2.E[1]), + }}; return Result; } @@ -111,8 +133,9 @@ inline v2i operator-( v2i P1, s32 Scalar ) { v2i Result = {{ - Cast(s32, P1.E[0] - Scalar), + Cast(s32, P1.E[0] - Scalar), Cast(s32, P1.E[1] - Scalar), + }}; return Result; } @@ -121,8 +144,9 @@ inline v2i operator-( s32 Scalar, v2i P1 ) { v2i Result = {{ - Cast(s32, Scalar - P1.E[0]), + Cast(s32, Scalar - P1.E[0]), Cast(s32, Scalar - P1.E[1]), + }}; return Result; } @@ -133,8 +157,9 @@ inline v2i operator*( v2i P1, v2i P2 ) { v2i Result = {{ - Cast(s32, P1.E[0] * P2.E[0]), + Cast(s32, P1.E[0] * P2.E[0]), Cast(s32, P1.E[1] * P2.E[1]), + }}; return Result; } @@ -143,8 +168,9 @@ inline v2i operator*( v2i P1, s32 Scalar ) { v2i Result = {{ - Cast(s32, P1.E[0] * Scalar), + Cast(s32, P1.E[0] * Scalar), Cast(s32, P1.E[1] * Scalar), + }}; return Result; } @@ -153,8 +179,9 @@ inline v2i operator*( s32 Scalar, v2i P1 ) { v2i Result = {{ - Cast(s32, Scalar * P1.E[0]), + Cast(s32, Scalar * P1.E[0]), Cast(s32, Scalar * P1.E[1]), + }}; return Result; } @@ -165,8 +192,9 @@ inline v2i operator/( v2i P1, v2i P2 ) { v2i Result = {{ - Cast(s32, P1.E[0] / P2.E[0]), + Cast(s32, P1.E[0] / P2.E[0]), Cast(s32, P1.E[1] / P2.E[1]), + }}; return Result; } @@ -175,8 +203,9 @@ inline v2i operator/( v2i P1, s32 Scalar ) { v2i Result = {{ - Cast(s32, P1.E[0] / Scalar), + Cast(s32, P1.E[0] / Scalar), Cast(s32, P1.E[1] / Scalar), + }}; return Result; } @@ -185,8 +214,9 @@ inline v2i operator/( s32 Scalar, v2i P1 ) { v2i Result = {{ - Cast(s32, Scalar / P1.E[0]), + Cast(s32, Scalar / P1.E[0]), Cast(s32, Scalar / P1.E[1]), + }}; return Result; } @@ -196,16 +226,18 @@ operator/( s32 Scalar, v2i P1 ) inline v2i & operator+=( v2i &P1, v2i P2 ) { - P1.E[0] += P2.E[0]; + P1.E[0] += P2.E[0]; P1.E[1] += P2.E[1]; + return P1; } inline v2i & operator+=( v2i &P1, s32 Scalar ) { - P1.E[0] += Scalar; + P1.E[0] += Scalar; P1.E[1] += Scalar; + return P1; } @@ -213,16 +245,18 @@ operator+=( v2i &P1, s32 Scalar ) inline v2i & operator-=( v2i &P1, v2i P2 ) { - P1.E[0] -= P2.E[0]; + P1.E[0] -= P2.E[0]; P1.E[1] -= P2.E[1]; + return P1; } inline v2i & operator-=( v2i &P1, s32 Scalar ) { - P1.E[0] -= Scalar; + P1.E[0] -= Scalar; P1.E[1] -= Scalar; + return P1; } @@ -230,16 +264,18 @@ operator-=( v2i &P1, s32 Scalar ) inline v2i & operator*=( v2i &P1, v2i P2 ) { - P1.E[0] *= P2.E[0]; + P1.E[0] *= P2.E[0]; P1.E[1] *= P2.E[1]; + return P1; } inline v2i & operator*=( v2i &P1, s32 Scalar ) { - P1.E[0] *= Scalar; + P1.E[0] *= Scalar; P1.E[1] *= Scalar; + return P1; } @@ -247,16 +283,18 @@ operator*=( v2i &P1, s32 Scalar ) inline v2i & operator/=( v2i &P1, v2i P2 ) { - P1.E[0] /= P2.E[0]; + P1.E[0] /= P2.E[0]; P1.E[1] /= P2.E[1]; + return P1; } inline v2i & operator/=( v2i &P1, s32 Scalar ) { - P1.E[0] /= Scalar; + P1.E[0] /= Scalar; P1.E[1] /= Scalar; + return P1; } diff --git a/generated/gen_vector_operators_v3.h b/generated/gen_vector_operators_v3.h index e0271c9b5..c4295839a 100644 --- a/generated/gen_vector_operators_v3.h +++ b/generated/gen_vector_operators_v3.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/vector.h:214:0 - +// external/bonsai_stdlib/src/poof_functions.h:270:0 link_internal void DeepCopy(v3 *Src, v3 *Dest) { @@ -9,7 +8,7 @@ DeepCopy(v3 *Src, v3 *Dest) inline b32 operator==( v3 P1, v3 P2 ) { - b32 Result = ( P1.E[0] == P2.E[0] && P1.E[1] == P2.E[1] && P1.E[2] == P2.E[2] ); + b32 Result = ( P1.E[0] == P2.E[0] && P1.E[1] == P2.E[1] && P1.E[2] == P2.E[2] ); return Result; } @@ -33,10 +32,30 @@ operator!=( v3 P1, v3 P2 ) return Result; } +inline r32 +Sum( v3 P1 ) +{ + r32 Result = ( P1.E[0] + P1.E[1] + P1.E[2] ); + return Result; +} + + + +inline r32 +MaxChannel( v3 P1 ) +{ + r32 Result = P1.E[0]; + Result = Cast(r32, Max(Result, P1.E[0])); + Result = Cast(r32, Max(Result, P1.E[1])); + Result = Cast(r32, Max(Result, P1.E[2])); +; + return Result; +} + inline b32 operator<( v3 P1, v3 P2 ) { - b32 Result = ( P1.E[0] < P2.E[0] && P1.E[1] < P2.E[1] && P1.E[2] < P2.E[2] ); + b32 Result = ( P1.E[0] < P2.E[0] && P1.E[1] < P2.E[1] && P1.E[2] < P2.E[2] ); return Result; } @@ -44,7 +63,7 @@ operator<( v3 P1, v3 P2 ) inline b32 operator<=( v3 P1, v3 P2 ) { - b32 Result = ( P1.E[0] <= P2.E[0] && P1.E[1] <= P2.E[1] && P1.E[2] <= P2.E[2] ); + b32 Result = ( P1.E[0] <= P2.E[0] && P1.E[1] <= P2.E[1] && P1.E[2] <= P2.E[2] ); return Result; } @@ -52,7 +71,7 @@ operator<=( v3 P1, v3 P2 ) inline b32 operator>( v3 P1, v3 P2 ) { - b32 Result = ( P1.E[0] > P2.E[0] && P1.E[1] > P2.E[1] && P1.E[2] > P2.E[2] ); + b32 Result = ( P1.E[0] > P2.E[0] && P1.E[1] > P2.E[1] && P1.E[2] > P2.E[2] ); return Result; } @@ -60,7 +79,7 @@ operator>( v3 P1, v3 P2 ) inline b32 operator>=( v3 P1, v3 P2 ) { - b32 Result = ( P1.E[0] >= P2.E[0] && P1.E[1] >= P2.E[1] && P1.E[2] >= P2.E[2] ); + b32 Result = ( P1.E[0] >= P2.E[0] && P1.E[1] >= P2.E[1] && P1.E[2] >= P2.E[2] ); return Result; } @@ -69,9 +88,10 @@ inline v3 operator+( v3 P1, v3 P2 ) { v3 Result = {{ - Cast(r32, P1.E[0] + P2.E[0]), + Cast(r32, P1.E[0] + P2.E[0]), Cast(r32, P1.E[1] + P2.E[1]), Cast(r32, P1.E[2] + P2.E[2]), + }}; return Result; } @@ -80,9 +100,10 @@ inline v3 operator+( v3 P1, r32 Scalar ) { v3 Result = {{ - Cast(r32, P1.E[0] + Scalar), + Cast(r32, P1.E[0] + Scalar), Cast(r32, P1.E[1] + Scalar), Cast(r32, P1.E[2] + Scalar), + }}; return Result; } @@ -91,9 +112,10 @@ inline v3 operator+( r32 Scalar, v3 P1 ) { v3 Result = {{ - Cast(r32, Scalar + P1.E[0]), + Cast(r32, Scalar + P1.E[0]), Cast(r32, Scalar + P1.E[1]), Cast(r32, Scalar + P1.E[2]), + }}; return Result; } @@ -104,9 +126,10 @@ inline v3 operator-( v3 P1, v3 P2 ) { v3 Result = {{ - Cast(r32, P1.E[0] - P2.E[0]), + Cast(r32, P1.E[0] - P2.E[0]), Cast(r32, P1.E[1] - P2.E[1]), Cast(r32, P1.E[2] - P2.E[2]), + }}; return Result; } @@ -115,9 +138,10 @@ inline v3 operator-( v3 P1, r32 Scalar ) { v3 Result = {{ - Cast(r32, P1.E[0] - Scalar), + Cast(r32, P1.E[0] - Scalar), Cast(r32, P1.E[1] - Scalar), Cast(r32, P1.E[2] - Scalar), + }}; return Result; } @@ -126,9 +150,10 @@ inline v3 operator-( r32 Scalar, v3 P1 ) { v3 Result = {{ - Cast(r32, Scalar - P1.E[0]), + Cast(r32, Scalar - P1.E[0]), Cast(r32, Scalar - P1.E[1]), Cast(r32, Scalar - P1.E[2]), + }}; return Result; } @@ -139,9 +164,10 @@ inline v3 operator*( v3 P1, v3 P2 ) { v3 Result = {{ - Cast(r32, P1.E[0] * P2.E[0]), + Cast(r32, P1.E[0] * P2.E[0]), Cast(r32, P1.E[1] * P2.E[1]), Cast(r32, P1.E[2] * P2.E[2]), + }}; return Result; } @@ -150,9 +176,10 @@ inline v3 operator*( v3 P1, r32 Scalar ) { v3 Result = {{ - Cast(r32, P1.E[0] * Scalar), + Cast(r32, P1.E[0] * Scalar), Cast(r32, P1.E[1] * Scalar), Cast(r32, P1.E[2] * Scalar), + }}; return Result; } @@ -161,9 +188,10 @@ inline v3 operator*( r32 Scalar, v3 P1 ) { v3 Result = {{ - Cast(r32, Scalar * P1.E[0]), + Cast(r32, Scalar * P1.E[0]), Cast(r32, Scalar * P1.E[1]), Cast(r32, Scalar * P1.E[2]), + }}; return Result; } @@ -174,9 +202,10 @@ inline v3 operator/( v3 P1, v3 P2 ) { v3 Result = {{ - Cast(r32, P1.E[0] / P2.E[0]), + Cast(r32, P1.E[0] / P2.E[0]), Cast(r32, P1.E[1] / P2.E[1]), Cast(r32, P1.E[2] / P2.E[2]), + }}; return Result; } @@ -185,9 +214,10 @@ inline v3 operator/( v3 P1, r32 Scalar ) { v3 Result = {{ - Cast(r32, P1.E[0] / Scalar), + Cast(r32, P1.E[0] / Scalar), Cast(r32, P1.E[1] / Scalar), Cast(r32, P1.E[2] / Scalar), + }}; return Result; } @@ -196,9 +226,10 @@ inline v3 operator/( r32 Scalar, v3 P1 ) { v3 Result = {{ - Cast(r32, Scalar / P1.E[0]), + Cast(r32, Scalar / P1.E[0]), Cast(r32, Scalar / P1.E[1]), Cast(r32, Scalar / P1.E[2]), + }}; return Result; } @@ -208,18 +239,20 @@ operator/( r32 Scalar, v3 P1 ) inline v3 & operator+=( v3 &P1, v3 P2 ) { - P1.E[0] += P2.E[0]; + P1.E[0] += P2.E[0]; P1.E[1] += P2.E[1]; P1.E[2] += P2.E[2]; + return P1; } inline v3 & operator+=( v3 &P1, r32 Scalar ) { - P1.E[0] += Scalar; + P1.E[0] += Scalar; P1.E[1] += Scalar; P1.E[2] += Scalar; + return P1; } @@ -227,18 +260,20 @@ operator+=( v3 &P1, r32 Scalar ) inline v3 & operator-=( v3 &P1, v3 P2 ) { - P1.E[0] -= P2.E[0]; + P1.E[0] -= P2.E[0]; P1.E[1] -= P2.E[1]; P1.E[2] -= P2.E[2]; + return P1; } inline v3 & operator-=( v3 &P1, r32 Scalar ) { - P1.E[0] -= Scalar; + P1.E[0] -= Scalar; P1.E[1] -= Scalar; P1.E[2] -= Scalar; + return P1; } @@ -246,18 +281,20 @@ operator-=( v3 &P1, r32 Scalar ) inline v3 & operator*=( v3 &P1, v3 P2 ) { - P1.E[0] *= P2.E[0]; + P1.E[0] *= P2.E[0]; P1.E[1] *= P2.E[1]; P1.E[2] *= P2.E[2]; + return P1; } inline v3 & operator*=( v3 &P1, r32 Scalar ) { - P1.E[0] *= Scalar; + P1.E[0] *= Scalar; P1.E[1] *= Scalar; P1.E[2] *= Scalar; + return P1; } @@ -265,18 +302,20 @@ operator*=( v3 &P1, r32 Scalar ) inline v3 & operator/=( v3 &P1, v3 P2 ) { - P1.E[0] /= P2.E[0]; + P1.E[0] /= P2.E[0]; P1.E[1] /= P2.E[1]; P1.E[2] /= P2.E[2]; + return P1; } inline v3 & operator/=( v3 &P1, r32 Scalar ) { - P1.E[0] /= Scalar; + P1.E[0] /= Scalar; P1.E[1] /= Scalar; P1.E[2] /= Scalar; + return P1; } diff --git a/generated/gen_vector_operators_v3_u8.h b/generated/gen_vector_operators_v3_u8.h index 0c2d43420..7c173f1af 100644 --- a/generated/gen_vector_operators_v3_u8.h +++ b/generated/gen_vector_operators_v3_u8.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/vector.h:220:0 - +// external/bonsai_stdlib/src/poof_functions.h:270:0 link_internal void DeepCopy(v3_u8 *Src, v3_u8 *Dest) { @@ -9,7 +8,7 @@ DeepCopy(v3_u8 *Src, v3_u8 *Dest) inline b32 operator==( v3_u8 P1, v3_u8 P2 ) { - b32 Result = ( P1.E[0] == P2.E[0] && P1.E[1] == P2.E[1] && P1.E[2] == P2.E[2] ); + b32 Result = ( P1.E[0] == P2.E[0] && P1.E[1] == P2.E[1] && P1.E[2] == P2.E[2] ); return Result; } @@ -33,10 +32,30 @@ operator!=( v3_u8 P1, v3_u8 P2 ) return Result; } +inline u8 +Sum( v3_u8 P1 ) +{ + u8 Result = ( P1.E[0] + P1.E[1] + P1.E[2] ); + return Result; +} + + + +inline u8 +MaxChannel( v3_u8 P1 ) +{ + u8 Result = P1.E[0]; + Result = Cast(u8, Max(Result, P1.E[0])); + Result = Cast(u8, Max(Result, P1.E[1])); + Result = Cast(u8, Max(Result, P1.E[2])); +; + return Result; +} + inline b32 operator<( v3_u8 P1, v3_u8 P2 ) { - b32 Result = ( P1.E[0] < P2.E[0] && P1.E[1] < P2.E[1] && P1.E[2] < P2.E[2] ); + b32 Result = ( P1.E[0] < P2.E[0] && P1.E[1] < P2.E[1] && P1.E[2] < P2.E[2] ); return Result; } @@ -44,7 +63,7 @@ operator<( v3_u8 P1, v3_u8 P2 ) inline b32 operator<=( v3_u8 P1, v3_u8 P2 ) { - b32 Result = ( P1.E[0] <= P2.E[0] && P1.E[1] <= P2.E[1] && P1.E[2] <= P2.E[2] ); + b32 Result = ( P1.E[0] <= P2.E[0] && P1.E[1] <= P2.E[1] && P1.E[2] <= P2.E[2] ); return Result; } @@ -52,7 +71,7 @@ operator<=( v3_u8 P1, v3_u8 P2 ) inline b32 operator>( v3_u8 P1, v3_u8 P2 ) { - b32 Result = ( P1.E[0] > P2.E[0] && P1.E[1] > P2.E[1] && P1.E[2] > P2.E[2] ); + b32 Result = ( P1.E[0] > P2.E[0] && P1.E[1] > P2.E[1] && P1.E[2] > P2.E[2] ); return Result; } @@ -60,7 +79,7 @@ operator>( v3_u8 P1, v3_u8 P2 ) inline b32 operator>=( v3_u8 P1, v3_u8 P2 ) { - b32 Result = ( P1.E[0] >= P2.E[0] && P1.E[1] >= P2.E[1] && P1.E[2] >= P2.E[2] ); + b32 Result = ( P1.E[0] >= P2.E[0] && P1.E[1] >= P2.E[1] && P1.E[2] >= P2.E[2] ); return Result; } @@ -69,9 +88,10 @@ inline v3_u8 operator+( v3_u8 P1, v3_u8 P2 ) { v3_u8 Result = {{ - Cast(u8, P1.E[0] + P2.E[0]), + Cast(u8, P1.E[0] + P2.E[0]), Cast(u8, P1.E[1] + P2.E[1]), Cast(u8, P1.E[2] + P2.E[2]), + }}; return Result; } @@ -80,9 +100,10 @@ inline v3_u8 operator+( v3_u8 P1, u8 Scalar ) { v3_u8 Result = {{ - Cast(u8, P1.E[0] + Scalar), + Cast(u8, P1.E[0] + Scalar), Cast(u8, P1.E[1] + Scalar), Cast(u8, P1.E[2] + Scalar), + }}; return Result; } @@ -91,9 +112,10 @@ inline v3_u8 operator+( u8 Scalar, v3_u8 P1 ) { v3_u8 Result = {{ - Cast(u8, Scalar + P1.E[0]), + Cast(u8, Scalar + P1.E[0]), Cast(u8, Scalar + P1.E[1]), Cast(u8, Scalar + P1.E[2]), + }}; return Result; } @@ -104,9 +126,10 @@ inline v3_u8 operator-( v3_u8 P1, v3_u8 P2 ) { v3_u8 Result = {{ - Cast(u8, P1.E[0] - P2.E[0]), + Cast(u8, P1.E[0] - P2.E[0]), Cast(u8, P1.E[1] - P2.E[1]), Cast(u8, P1.E[2] - P2.E[2]), + }}; return Result; } @@ -115,9 +138,10 @@ inline v3_u8 operator-( v3_u8 P1, u8 Scalar ) { v3_u8 Result = {{ - Cast(u8, P1.E[0] - Scalar), + Cast(u8, P1.E[0] - Scalar), Cast(u8, P1.E[1] - Scalar), Cast(u8, P1.E[2] - Scalar), + }}; return Result; } @@ -126,9 +150,10 @@ inline v3_u8 operator-( u8 Scalar, v3_u8 P1 ) { v3_u8 Result = {{ - Cast(u8, Scalar - P1.E[0]), + Cast(u8, Scalar - P1.E[0]), Cast(u8, Scalar - P1.E[1]), Cast(u8, Scalar - P1.E[2]), + }}; return Result; } @@ -139,9 +164,10 @@ inline v3_u8 operator*( v3_u8 P1, v3_u8 P2 ) { v3_u8 Result = {{ - Cast(u8, P1.E[0] * P2.E[0]), + Cast(u8, P1.E[0] * P2.E[0]), Cast(u8, P1.E[1] * P2.E[1]), Cast(u8, P1.E[2] * P2.E[2]), + }}; return Result; } @@ -150,9 +176,10 @@ inline v3_u8 operator*( v3_u8 P1, u8 Scalar ) { v3_u8 Result = {{ - Cast(u8, P1.E[0] * Scalar), + Cast(u8, P1.E[0] * Scalar), Cast(u8, P1.E[1] * Scalar), Cast(u8, P1.E[2] * Scalar), + }}; return Result; } @@ -161,9 +188,10 @@ inline v3_u8 operator*( u8 Scalar, v3_u8 P1 ) { v3_u8 Result = {{ - Cast(u8, Scalar * P1.E[0]), + Cast(u8, Scalar * P1.E[0]), Cast(u8, Scalar * P1.E[1]), Cast(u8, Scalar * P1.E[2]), + }}; return Result; } @@ -174,9 +202,10 @@ inline v3_u8 operator/( v3_u8 P1, v3_u8 P2 ) { v3_u8 Result = {{ - Cast(u8, P1.E[0] / P2.E[0]), + Cast(u8, P1.E[0] / P2.E[0]), Cast(u8, P1.E[1] / P2.E[1]), Cast(u8, P1.E[2] / P2.E[2]), + }}; return Result; } @@ -185,9 +214,10 @@ inline v3_u8 operator/( v3_u8 P1, u8 Scalar ) { v3_u8 Result = {{ - Cast(u8, P1.E[0] / Scalar), + Cast(u8, P1.E[0] / Scalar), Cast(u8, P1.E[1] / Scalar), Cast(u8, P1.E[2] / Scalar), + }}; return Result; } @@ -196,9 +226,10 @@ inline v3_u8 operator/( u8 Scalar, v3_u8 P1 ) { v3_u8 Result = {{ - Cast(u8, Scalar / P1.E[0]), + Cast(u8, Scalar / P1.E[0]), Cast(u8, Scalar / P1.E[1]), Cast(u8, Scalar / P1.E[2]), + }}; return Result; } @@ -208,18 +239,20 @@ operator/( u8 Scalar, v3_u8 P1 ) inline v3_u8 & operator+=( v3_u8 &P1, v3_u8 P2 ) { - P1.E[0] += P2.E[0]; + P1.E[0] += P2.E[0]; P1.E[1] += P2.E[1]; P1.E[2] += P2.E[2]; + return P1; } inline v3_u8 & operator+=( v3_u8 &P1, u8 Scalar ) { - P1.E[0] += Scalar; + P1.E[0] += Scalar; P1.E[1] += Scalar; P1.E[2] += Scalar; + return P1; } @@ -227,18 +260,20 @@ operator+=( v3_u8 &P1, u8 Scalar ) inline v3_u8 & operator-=( v3_u8 &P1, v3_u8 P2 ) { - P1.E[0] -= P2.E[0]; + P1.E[0] -= P2.E[0]; P1.E[1] -= P2.E[1]; P1.E[2] -= P2.E[2]; + return P1; } inline v3_u8 & operator-=( v3_u8 &P1, u8 Scalar ) { - P1.E[0] -= Scalar; + P1.E[0] -= Scalar; P1.E[1] -= Scalar; P1.E[2] -= Scalar; + return P1; } @@ -246,18 +281,20 @@ operator-=( v3_u8 &P1, u8 Scalar ) inline v3_u8 & operator*=( v3_u8 &P1, v3_u8 P2 ) { - P1.E[0] *= P2.E[0]; + P1.E[0] *= P2.E[0]; P1.E[1] *= P2.E[1]; P1.E[2] *= P2.E[2]; + return P1; } inline v3_u8 & operator*=( v3_u8 &P1, u8 Scalar ) { - P1.E[0] *= Scalar; + P1.E[0] *= Scalar; P1.E[1] *= Scalar; P1.E[2] *= Scalar; + return P1; } @@ -265,18 +302,20 @@ operator*=( v3_u8 &P1, u8 Scalar ) inline v3_u8 & operator/=( v3_u8 &P1, v3_u8 P2 ) { - P1.E[0] /= P2.E[0]; + P1.E[0] /= P2.E[0]; P1.E[1] /= P2.E[1]; P1.E[2] /= P2.E[2]; + return P1; } inline v3_u8 & operator/=( v3_u8 &P1, u8 Scalar ) { - P1.E[0] /= Scalar; + P1.E[0] /= Scalar; P1.E[1] /= Scalar; P1.E[2] /= Scalar; + return P1; } diff --git a/generated/gen_vector_operators_v3i.h b/generated/gen_vector_operators_v3i.h index 840695722..5b1b86284 100644 --- a/generated/gen_vector_operators_v3i.h +++ b/generated/gen_vector_operators_v3i.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/vector.h:217:0 - +// external/bonsai_stdlib/src/poof_functions.h:270:0 link_internal void DeepCopy(v3i *Src, v3i *Dest) { @@ -9,7 +8,7 @@ DeepCopy(v3i *Src, v3i *Dest) inline b32 operator==( v3i P1, v3i P2 ) { - b32 Result = ( P1.E[0] == P2.E[0] && P1.E[1] == P2.E[1] && P1.E[2] == P2.E[2] ); + b32 Result = ( P1.E[0] == P2.E[0] && P1.E[1] == P2.E[1] && P1.E[2] == P2.E[2] ); return Result; } @@ -33,10 +32,30 @@ operator!=( v3i P1, v3i P2 ) return Result; } +inline s32 +Sum( v3i P1 ) +{ + s32 Result = ( P1.E[0] + P1.E[1] + P1.E[2] ); + return Result; +} + + + +inline s32 +MaxChannel( v3i P1 ) +{ + s32 Result = P1.E[0]; + Result = Cast(s32, Max(Result, P1.E[0])); + Result = Cast(s32, Max(Result, P1.E[1])); + Result = Cast(s32, Max(Result, P1.E[2])); +; + return Result; +} + inline b32 operator<( v3i P1, v3i P2 ) { - b32 Result = ( P1.E[0] < P2.E[0] && P1.E[1] < P2.E[1] && P1.E[2] < P2.E[2] ); + b32 Result = ( P1.E[0] < P2.E[0] && P1.E[1] < P2.E[1] && P1.E[2] < P2.E[2] ); return Result; } @@ -44,7 +63,7 @@ operator<( v3i P1, v3i P2 ) inline b32 operator<=( v3i P1, v3i P2 ) { - b32 Result = ( P1.E[0] <= P2.E[0] && P1.E[1] <= P2.E[1] && P1.E[2] <= P2.E[2] ); + b32 Result = ( P1.E[0] <= P2.E[0] && P1.E[1] <= P2.E[1] && P1.E[2] <= P2.E[2] ); return Result; } @@ -52,7 +71,7 @@ operator<=( v3i P1, v3i P2 ) inline b32 operator>( v3i P1, v3i P2 ) { - b32 Result = ( P1.E[0] > P2.E[0] && P1.E[1] > P2.E[1] && P1.E[2] > P2.E[2] ); + b32 Result = ( P1.E[0] > P2.E[0] && P1.E[1] > P2.E[1] && P1.E[2] > P2.E[2] ); return Result; } @@ -60,7 +79,7 @@ operator>( v3i P1, v3i P2 ) inline b32 operator>=( v3i P1, v3i P2 ) { - b32 Result = ( P1.E[0] >= P2.E[0] && P1.E[1] >= P2.E[1] && P1.E[2] >= P2.E[2] ); + b32 Result = ( P1.E[0] >= P2.E[0] && P1.E[1] >= P2.E[1] && P1.E[2] >= P2.E[2] ); return Result; } @@ -69,9 +88,10 @@ inline v3i operator+( v3i P1, v3i P2 ) { v3i Result = {{ - Cast(s32, P1.E[0] + P2.E[0]), + Cast(s32, P1.E[0] + P2.E[0]), Cast(s32, P1.E[1] + P2.E[1]), Cast(s32, P1.E[2] + P2.E[2]), + }}; return Result; } @@ -80,9 +100,10 @@ inline v3i operator+( v3i P1, s32 Scalar ) { v3i Result = {{ - Cast(s32, P1.E[0] + Scalar), + Cast(s32, P1.E[0] + Scalar), Cast(s32, P1.E[1] + Scalar), Cast(s32, P1.E[2] + Scalar), + }}; return Result; } @@ -91,9 +112,10 @@ inline v3i operator+( s32 Scalar, v3i P1 ) { v3i Result = {{ - Cast(s32, Scalar + P1.E[0]), + Cast(s32, Scalar + P1.E[0]), Cast(s32, Scalar + P1.E[1]), Cast(s32, Scalar + P1.E[2]), + }}; return Result; } @@ -104,9 +126,10 @@ inline v3i operator-( v3i P1, v3i P2 ) { v3i Result = {{ - Cast(s32, P1.E[0] - P2.E[0]), + Cast(s32, P1.E[0] - P2.E[0]), Cast(s32, P1.E[1] - P2.E[1]), Cast(s32, P1.E[2] - P2.E[2]), + }}; return Result; } @@ -115,9 +138,10 @@ inline v3i operator-( v3i P1, s32 Scalar ) { v3i Result = {{ - Cast(s32, P1.E[0] - Scalar), + Cast(s32, P1.E[0] - Scalar), Cast(s32, P1.E[1] - Scalar), Cast(s32, P1.E[2] - Scalar), + }}; return Result; } @@ -126,9 +150,10 @@ inline v3i operator-( s32 Scalar, v3i P1 ) { v3i Result = {{ - Cast(s32, Scalar - P1.E[0]), + Cast(s32, Scalar - P1.E[0]), Cast(s32, Scalar - P1.E[1]), Cast(s32, Scalar - P1.E[2]), + }}; return Result; } @@ -139,9 +164,10 @@ inline v3i operator*( v3i P1, v3i P2 ) { v3i Result = {{ - Cast(s32, P1.E[0] * P2.E[0]), + Cast(s32, P1.E[0] * P2.E[0]), Cast(s32, P1.E[1] * P2.E[1]), Cast(s32, P1.E[2] * P2.E[2]), + }}; return Result; } @@ -150,9 +176,10 @@ inline v3i operator*( v3i P1, s32 Scalar ) { v3i Result = {{ - Cast(s32, P1.E[0] * Scalar), + Cast(s32, P1.E[0] * Scalar), Cast(s32, P1.E[1] * Scalar), Cast(s32, P1.E[2] * Scalar), + }}; return Result; } @@ -161,9 +188,10 @@ inline v3i operator*( s32 Scalar, v3i P1 ) { v3i Result = {{ - Cast(s32, Scalar * P1.E[0]), + Cast(s32, Scalar * P1.E[0]), Cast(s32, Scalar * P1.E[1]), Cast(s32, Scalar * P1.E[2]), + }}; return Result; } @@ -174,9 +202,10 @@ inline v3i operator/( v3i P1, v3i P2 ) { v3i Result = {{ - Cast(s32, P1.E[0] / P2.E[0]), + Cast(s32, P1.E[0] / P2.E[0]), Cast(s32, P1.E[1] / P2.E[1]), Cast(s32, P1.E[2] / P2.E[2]), + }}; return Result; } @@ -185,9 +214,10 @@ inline v3i operator/( v3i P1, s32 Scalar ) { v3i Result = {{ - Cast(s32, P1.E[0] / Scalar), + Cast(s32, P1.E[0] / Scalar), Cast(s32, P1.E[1] / Scalar), Cast(s32, P1.E[2] / Scalar), + }}; return Result; } @@ -196,9 +226,10 @@ inline v3i operator/( s32 Scalar, v3i P1 ) { v3i Result = {{ - Cast(s32, Scalar / P1.E[0]), + Cast(s32, Scalar / P1.E[0]), Cast(s32, Scalar / P1.E[1]), Cast(s32, Scalar / P1.E[2]), + }}; return Result; } @@ -208,18 +239,20 @@ operator/( s32 Scalar, v3i P1 ) inline v3i & operator+=( v3i &P1, v3i P2 ) { - P1.E[0] += P2.E[0]; + P1.E[0] += P2.E[0]; P1.E[1] += P2.E[1]; P1.E[2] += P2.E[2]; + return P1; } inline v3i & operator+=( v3i &P1, s32 Scalar ) { - P1.E[0] += Scalar; + P1.E[0] += Scalar; P1.E[1] += Scalar; P1.E[2] += Scalar; + return P1; } @@ -227,18 +260,20 @@ operator+=( v3i &P1, s32 Scalar ) inline v3i & operator-=( v3i &P1, v3i P2 ) { - P1.E[0] -= P2.E[0]; + P1.E[0] -= P2.E[0]; P1.E[1] -= P2.E[1]; P1.E[2] -= P2.E[2]; + return P1; } inline v3i & operator-=( v3i &P1, s32 Scalar ) { - P1.E[0] -= Scalar; + P1.E[0] -= Scalar; P1.E[1] -= Scalar; P1.E[2] -= Scalar; + return P1; } @@ -246,18 +281,20 @@ operator-=( v3i &P1, s32 Scalar ) inline v3i & operator*=( v3i &P1, v3i P2 ) { - P1.E[0] *= P2.E[0]; + P1.E[0] *= P2.E[0]; P1.E[1] *= P2.E[1]; P1.E[2] *= P2.E[2]; + return P1; } inline v3i & operator*=( v3i &P1, s32 Scalar ) { - P1.E[0] *= Scalar; + P1.E[0] *= Scalar; P1.E[1] *= Scalar; P1.E[2] *= Scalar; + return P1; } @@ -265,18 +302,20 @@ operator*=( v3i &P1, s32 Scalar ) inline v3i & operator/=( v3i &P1, v3i P2 ) { - P1.E[0] /= P2.E[0]; + P1.E[0] /= P2.E[0]; P1.E[1] /= P2.E[1]; P1.E[2] /= P2.E[2]; + return P1; } inline v3i & operator/=( v3i &P1, s32 Scalar ) { - P1.E[0] /= Scalar; + P1.E[0] /= Scalar; P1.E[1] /= Scalar; P1.E[2] /= Scalar; + return P1; } diff --git a/generated/gen_vector_operators_v4.h b/generated/gen_vector_operators_v4.h index a258ec2e7..fd9b63d89 100644 --- a/generated/gen_vector_operators_v4.h +++ b/generated/gen_vector_operators_v4.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/vector.h:223:0 - +// external/bonsai_stdlib/src/poof_functions.h:270:0 link_internal void DeepCopy(v4 *Src, v4 *Dest) { @@ -9,7 +8,7 @@ DeepCopy(v4 *Src, v4 *Dest) inline b32 operator==( v4 P1, v4 P2 ) { - b32 Result = ( P1.E[0] == P2.E[0] && P1.E[1] == P2.E[1] && P1.E[2] == P2.E[2] && P1.E[3] == P2.E[3] ); + b32 Result = ( P1.E[0] == P2.E[0] && P1.E[1] == P2.E[1] && P1.E[2] == P2.E[2] && P1.E[3] == P2.E[3] ); return Result; } @@ -33,10 +32,31 @@ operator!=( v4 P1, v4 P2 ) return Result; } +inline r32 +Sum( v4 P1 ) +{ + r32 Result = ( P1.E[0] + P1.E[1] + P1.E[2] + P1.E[3] ); + return Result; +} + + + +inline r32 +MaxChannel( v4 P1 ) +{ + r32 Result = P1.E[0]; + Result = Cast(r32, Max(Result, P1.E[0])); + Result = Cast(r32, Max(Result, P1.E[1])); + Result = Cast(r32, Max(Result, P1.E[2])); + Result = Cast(r32, Max(Result, P1.E[3])); +; + return Result; +} + inline b32 operator<( v4 P1, v4 P2 ) { - b32 Result = ( P1.E[0] < P2.E[0] && P1.E[1] < P2.E[1] && P1.E[2] < P2.E[2] && P1.E[3] < P2.E[3] ); + b32 Result = ( P1.E[0] < P2.E[0] && P1.E[1] < P2.E[1] && P1.E[2] < P2.E[2] && P1.E[3] < P2.E[3] ); return Result; } @@ -44,7 +64,7 @@ operator<( v4 P1, v4 P2 ) inline b32 operator<=( v4 P1, v4 P2 ) { - b32 Result = ( P1.E[0] <= P2.E[0] && P1.E[1] <= P2.E[1] && P1.E[2] <= P2.E[2] && P1.E[3] <= P2.E[3] ); + b32 Result = ( P1.E[0] <= P2.E[0] && P1.E[1] <= P2.E[1] && P1.E[2] <= P2.E[2] && P1.E[3] <= P2.E[3] ); return Result; } @@ -52,7 +72,7 @@ operator<=( v4 P1, v4 P2 ) inline b32 operator>( v4 P1, v4 P2 ) { - b32 Result = ( P1.E[0] > P2.E[0] && P1.E[1] > P2.E[1] && P1.E[2] > P2.E[2] && P1.E[3] > P2.E[3] ); + b32 Result = ( P1.E[0] > P2.E[0] && P1.E[1] > P2.E[1] && P1.E[2] > P2.E[2] && P1.E[3] > P2.E[3] ); return Result; } @@ -60,7 +80,7 @@ operator>( v4 P1, v4 P2 ) inline b32 operator>=( v4 P1, v4 P2 ) { - b32 Result = ( P1.E[0] >= P2.E[0] && P1.E[1] >= P2.E[1] && P1.E[2] >= P2.E[2] && P1.E[3] >= P2.E[3] ); + b32 Result = ( P1.E[0] >= P2.E[0] && P1.E[1] >= P2.E[1] && P1.E[2] >= P2.E[2] && P1.E[3] >= P2.E[3] ); return Result; } @@ -69,10 +89,11 @@ inline v4 operator+( v4 P1, v4 P2 ) { v4 Result = {{ - Cast(r32, P1.E[0] + P2.E[0]), + Cast(r32, P1.E[0] + P2.E[0]), Cast(r32, P1.E[1] + P2.E[1]), Cast(r32, P1.E[2] + P2.E[2]), Cast(r32, P1.E[3] + P2.E[3]), + }}; return Result; } @@ -81,10 +102,11 @@ inline v4 operator+( v4 P1, r32 Scalar ) { v4 Result = {{ - Cast(r32, P1.E[0] + Scalar), + Cast(r32, P1.E[0] + Scalar), Cast(r32, P1.E[1] + Scalar), Cast(r32, P1.E[2] + Scalar), Cast(r32, P1.E[3] + Scalar), + }}; return Result; } @@ -93,10 +115,11 @@ inline v4 operator+( r32 Scalar, v4 P1 ) { v4 Result = {{ - Cast(r32, Scalar + P1.E[0]), + Cast(r32, Scalar + P1.E[0]), Cast(r32, Scalar + P1.E[1]), Cast(r32, Scalar + P1.E[2]), Cast(r32, Scalar + P1.E[3]), + }}; return Result; } @@ -107,10 +130,11 @@ inline v4 operator-( v4 P1, v4 P2 ) { v4 Result = {{ - Cast(r32, P1.E[0] - P2.E[0]), + Cast(r32, P1.E[0] - P2.E[0]), Cast(r32, P1.E[1] - P2.E[1]), Cast(r32, P1.E[2] - P2.E[2]), Cast(r32, P1.E[3] - P2.E[3]), + }}; return Result; } @@ -119,10 +143,11 @@ inline v4 operator-( v4 P1, r32 Scalar ) { v4 Result = {{ - Cast(r32, P1.E[0] - Scalar), + Cast(r32, P1.E[0] - Scalar), Cast(r32, P1.E[1] - Scalar), Cast(r32, P1.E[2] - Scalar), Cast(r32, P1.E[3] - Scalar), + }}; return Result; } @@ -131,10 +156,11 @@ inline v4 operator-( r32 Scalar, v4 P1 ) { v4 Result = {{ - Cast(r32, Scalar - P1.E[0]), + Cast(r32, Scalar - P1.E[0]), Cast(r32, Scalar - P1.E[1]), Cast(r32, Scalar - P1.E[2]), Cast(r32, Scalar - P1.E[3]), + }}; return Result; } @@ -145,10 +171,11 @@ inline v4 operator*( v4 P1, v4 P2 ) { v4 Result = {{ - Cast(r32, P1.E[0] * P2.E[0]), + Cast(r32, P1.E[0] * P2.E[0]), Cast(r32, P1.E[1] * P2.E[1]), Cast(r32, P1.E[2] * P2.E[2]), Cast(r32, P1.E[3] * P2.E[3]), + }}; return Result; } @@ -157,10 +184,11 @@ inline v4 operator*( v4 P1, r32 Scalar ) { v4 Result = {{ - Cast(r32, P1.E[0] * Scalar), + Cast(r32, P1.E[0] * Scalar), Cast(r32, P1.E[1] * Scalar), Cast(r32, P1.E[2] * Scalar), Cast(r32, P1.E[3] * Scalar), + }}; return Result; } @@ -169,10 +197,11 @@ inline v4 operator*( r32 Scalar, v4 P1 ) { v4 Result = {{ - Cast(r32, Scalar * P1.E[0]), + Cast(r32, Scalar * P1.E[0]), Cast(r32, Scalar * P1.E[1]), Cast(r32, Scalar * P1.E[2]), Cast(r32, Scalar * P1.E[3]), + }}; return Result; } @@ -183,10 +212,11 @@ inline v4 operator/( v4 P1, v4 P2 ) { v4 Result = {{ - Cast(r32, P1.E[0] / P2.E[0]), + Cast(r32, P1.E[0] / P2.E[0]), Cast(r32, P1.E[1] / P2.E[1]), Cast(r32, P1.E[2] / P2.E[2]), Cast(r32, P1.E[3] / P2.E[3]), + }}; return Result; } @@ -195,10 +225,11 @@ inline v4 operator/( v4 P1, r32 Scalar ) { v4 Result = {{ - Cast(r32, P1.E[0] / Scalar), + Cast(r32, P1.E[0] / Scalar), Cast(r32, P1.E[1] / Scalar), Cast(r32, P1.E[2] / Scalar), Cast(r32, P1.E[3] / Scalar), + }}; return Result; } @@ -207,10 +238,11 @@ inline v4 operator/( r32 Scalar, v4 P1 ) { v4 Result = {{ - Cast(r32, Scalar / P1.E[0]), + Cast(r32, Scalar / P1.E[0]), Cast(r32, Scalar / P1.E[1]), Cast(r32, Scalar / P1.E[2]), Cast(r32, Scalar / P1.E[3]), + }}; return Result; } @@ -220,20 +252,22 @@ operator/( r32 Scalar, v4 P1 ) inline v4 & operator+=( v4 &P1, v4 P2 ) { - P1.E[0] += P2.E[0]; + P1.E[0] += P2.E[0]; P1.E[1] += P2.E[1]; P1.E[2] += P2.E[2]; P1.E[3] += P2.E[3]; + return P1; } inline v4 & operator+=( v4 &P1, r32 Scalar ) { - P1.E[0] += Scalar; + P1.E[0] += Scalar; P1.E[1] += Scalar; P1.E[2] += Scalar; P1.E[3] += Scalar; + return P1; } @@ -241,20 +275,22 @@ operator+=( v4 &P1, r32 Scalar ) inline v4 & operator-=( v4 &P1, v4 P2 ) { - P1.E[0] -= P2.E[0]; + P1.E[0] -= P2.E[0]; P1.E[1] -= P2.E[1]; P1.E[2] -= P2.E[2]; P1.E[3] -= P2.E[3]; + return P1; } inline v4 & operator-=( v4 &P1, r32 Scalar ) { - P1.E[0] -= Scalar; + P1.E[0] -= Scalar; P1.E[1] -= Scalar; P1.E[2] -= Scalar; P1.E[3] -= Scalar; + return P1; } @@ -262,20 +298,22 @@ operator-=( v4 &P1, r32 Scalar ) inline v4 & operator*=( v4 &P1, v4 P2 ) { - P1.E[0] *= P2.E[0]; + P1.E[0] *= P2.E[0]; P1.E[1] *= P2.E[1]; P1.E[2] *= P2.E[2]; P1.E[3] *= P2.E[3]; + return P1; } inline v4 & operator*=( v4 &P1, r32 Scalar ) { - P1.E[0] *= Scalar; + P1.E[0] *= Scalar; P1.E[1] *= Scalar; P1.E[2] *= Scalar; P1.E[3] *= Scalar; + return P1; } @@ -283,20 +321,22 @@ operator*=( v4 &P1, r32 Scalar ) inline v4 & operator/=( v4 &P1, v4 P2 ) { - P1.E[0] /= P2.E[0]; + P1.E[0] /= P2.E[0]; P1.E[1] /= P2.E[1]; P1.E[2] /= P2.E[2]; P1.E[3] /= P2.E[3]; + return P1; } inline v4 & operator/=( v4 &P1, r32 Scalar ) { - P1.E[0] /= Scalar; + P1.E[0] /= Scalar; P1.E[1] /= Scalar; P1.E[2] /= Scalar; P1.E[3] /= Scalar; + return P1; } diff --git a/generated/gen_wide_vector_operator_688856397_31875099.h b/generated/gen_wide_vector_operator_688856397_31875099.h new file mode 100644 index 000000000..37522d97c --- /dev/null +++ b/generated/gen_wide_vector_operator_688856397_31875099.h @@ -0,0 +1,37 @@ +// external/bonsai_stdlib/src/simd_avx2.h:148:0 +link_inline f32_8x +operator*(f32_8x A, f32_8x B) +{ + f32_8x Result = {{ _mm256_mul_ps(A.Sse, B.Sse) }}; + return Result; +} + +link_inline f32_8x +operator*(f32_8x A, f32 B) +{ + f32_8x Result = {{ _mm256_mul_ps(A.Sse, F32_8X(B).Sse) }}; + return Result; +} + +link_inline f32_8x +operator*(f32 A, f32_8x B) +{ + f32_8x Result = {{ _mm256_mul_ps(F32_8X(A).Sse, B.Sse) }}; + return Result; +} + +link_inline f32_8x +operator*(f32_8x A, __m256 B) +{ + f32_8x Result = {{ _mm256_mul_ps(A.Sse, B) }}; + return Result; +} + +link_inline f32_8x +operator*(__m256 A, f32_8x B) +{ + f32_8x Result = {{ _mm256_mul_ps(A, B.Sse) }}; + return Result; +} + + diff --git a/generated/gen_wide_vector_operator_688856398_962878887.h b/generated/gen_wide_vector_operator_688856398_962878887.h new file mode 100644 index 000000000..7e621c511 --- /dev/null +++ b/generated/gen_wide_vector_operator_688856398_962878887.h @@ -0,0 +1,37 @@ +// external/bonsai_stdlib/src/simd_avx2.h:148:0 +link_inline f32_8x +operator+(f32_8x A, f32_8x B) +{ + f32_8x Result = {{ _mm256_add_ps(A.Sse, B.Sse) }}; + return Result; +} + +link_inline f32_8x +operator+(f32_8x A, f32 B) +{ + f32_8x Result = {{ _mm256_add_ps(A.Sse, F32_8X(B).Sse) }}; + return Result; +} + +link_inline f32_8x +operator+(f32 A, f32_8x B) +{ + f32_8x Result = {{ _mm256_add_ps(F32_8X(A).Sse, B.Sse) }}; + return Result; +} + +link_inline f32_8x +operator+(f32_8x A, __m256 B) +{ + f32_8x Result = {{ _mm256_add_ps(A.Sse, B) }}; + return Result; +} + +link_inline f32_8x +operator+(__m256 A, f32_8x B) +{ + f32_8x Result = {{ _mm256_add_ps(A, B.Sse) }}; + return Result; +} + + diff --git a/generated/gen_wide_vector_operator_688856400_677608083.h b/generated/gen_wide_vector_operator_688856400_677608083.h new file mode 100644 index 000000000..5ea070739 --- /dev/null +++ b/generated/gen_wide_vector_operator_688856400_677608083.h @@ -0,0 +1,37 @@ +// external/bonsai_stdlib/src/simd_avx2.h:148:0 +link_inline f32_8x +operator-(f32_8x A, f32_8x B) +{ + f32_8x Result = {{ _mm256_sub_ps(A.Sse, B.Sse) }}; + return Result; +} + +link_inline f32_8x +operator-(f32_8x A, f32 B) +{ + f32_8x Result = {{ _mm256_sub_ps(A.Sse, F32_8X(B).Sse) }}; + return Result; +} + +link_inline f32_8x +operator-(f32 A, f32_8x B) +{ + f32_8x Result = {{ _mm256_sub_ps(F32_8X(A).Sse, B.Sse) }}; + return Result; +} + +link_inline f32_8x +operator-(f32_8x A, __m256 B) +{ + f32_8x Result = {{ _mm256_sub_ps(A.Sse, B) }}; + return Result; +} + +link_inline f32_8x +operator-(__m256 A, f32_8x B) +{ + f32_8x Result = {{ _mm256_sub_ps(A, B.Sse) }}; + return Result; +} + + diff --git a/generated/gen_wide_vector_operator_688856402_974542050.h b/generated/gen_wide_vector_operator_688856402_974542050.h new file mode 100644 index 000000000..22e132328 --- /dev/null +++ b/generated/gen_wide_vector_operator_688856402_974542050.h @@ -0,0 +1,37 @@ +// external/bonsai_stdlib/src/simd_avx2.h:148:0 +link_inline f32_8x +operator/(f32_8x A, f32_8x B) +{ + f32_8x Result = {{ _mm256_div_ps(A.Sse, B.Sse) }}; + return Result; +} + +link_inline f32_8x +operator/(f32_8x A, f32 B) +{ + f32_8x Result = {{ _mm256_div_ps(A.Sse, F32_8X(B).Sse) }}; + return Result; +} + +link_inline f32_8x +operator/(f32 A, f32_8x B) +{ + f32_8x Result = {{ _mm256_div_ps(F32_8X(A).Sse, B.Sse) }}; + return Result; +} + +link_inline f32_8x +operator/(f32_8x A, __m256 B) +{ + f32_8x Result = {{ _mm256_div_ps(A.Sse, B) }}; + return Result; +} + +link_inline f32_8x +operator/(__m256 A, f32_8x B) +{ + f32_8x Result = {{ _mm256_div_ps(A, B.Sse) }}; + return Result; +} + + diff --git a/generated/gen_write_primitive_from_u8_stream_803324607.h b/generated/gen_write_primitive_from_u8_stream_803324607.h index 8115f20b1..61aa541e0 100644 --- a/generated/gen_write_primitive_from_u8_stream_803324607.h +++ b/generated/gen_write_primitive_from_u8_stream_803324607.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/binary_parser.cpp:654:0 - +// external/bonsai_stdlib/src/binary_parser.cpp:629:0 link_internal b32 Write(u8_stream *Dest, s8 *Src) { @@ -217,3 +216,4 @@ Write(u8_cursor_block_array *Dest, u64 Src) return Result; } + diff --git a/generated/generate_cursor_debug_profile_scope.h b/generated/generate_cursor_debug_profile_scope.h index 77cb3ffc8..3b64ecbb7 100644 --- a/generated/generate_cursor_debug_profile_scope.h +++ b/generated/generate_cursor_debug_profile_scope.h @@ -1,12 +1,10 @@ -// external/bonsai_debug/src/api.h:118:0 - +// external/bonsai_stdlib/src/poof_functions.h:1541:0 struct debug_profile_scope_cursor { debug_profile_scope *Start; // TODO(Jesse)(immediate): For the love of fucksakes change these to indices debug_profile_scope *At; debug_profile_scope *End; - /* OWNED_BY_THREAD_MEMBER(); */ }; @@ -15,12 +13,12 @@ link_internal debug_profile_scope_cursor DebugProfileScopeCursor(umm ElementCount, memory_arena* Memory) { debug_profile_scope *Start = (debug_profile_scope*)PushStruct(Memory, sizeof(debug_profile_scope)*ElementCount, 1, 0); - debug_profile_scope_cursor Result = { - .Start = Start, - .End = Start+ElementCount, - .At = Start, - /* OWNED_BY_THREAD_MEMBER_INIT() */ - }; + debug_profile_scope_cursor Result = {}; + + Result.Start = Start; + Result.End = Start+ElementCount; + Result.At = Start; + return Result; } @@ -34,6 +32,12 @@ GetPtr(debug_profile_scope_cursor *Cursor, umm ElementIndex) return Result; } +link_internal debug_profile_scope* +TryGetPtr(debug_profile_scope_cursor *Cursor, umm ElementIndex) +{ + return GetPtr(Cursor, ElementIndex); +} + link_internal debug_profile_scope* GetPtrUnsafe(debug_profile_scope_cursor *Cursor, umm ElementIndex) { diff --git a/generated/generate_cursor_functions_c_token_cursor.h b/generated/generate_cursor_functions_c_token_cursor.h index 8107f33e3..0e6fdb974 100644 --- a/generated/generate_cursor_functions_c_token_cursor.h +++ b/generated/generate_cursor_functions_c_token_cursor.h @@ -1,16 +1,15 @@ -// external/bonsai_stdlib/src/c_token.h:390:0 - +// external/bonsai_stdlib/src/poof_functions.h:1563:0 link_internal c_token_cursor CTokenCursor(umm ElementCount, memory_arena* Memory) { c_token *Start = (c_token*)PushStruct(Memory, sizeof(c_token)*ElementCount, 1, 0); - c_token_cursor Result = { - .Start = Start, - .End = Start+ElementCount, - .At = Start, - /* OWNED_BY_THREAD_MEMBER_INIT() */ - }; + c_token_cursor Result = {}; + + Result.Start = Start; + Result.End = Start+ElementCount; + Result.At = Start; + return Result; } @@ -24,6 +23,12 @@ GetPtr(c_token_cursor *Cursor, umm ElementIndex) return Result; } +link_internal c_token* +TryGetPtr(c_token_cursor *Cursor, umm ElementIndex) +{ + return GetPtr(Cursor, ElementIndex); +} + link_internal c_token* GetPtrUnsafe(c_token_cursor *Cursor, umm ElementIndex) { diff --git a/generated/generate_cursor_functions_u64.h b/generated/generate_cursor_functions_u64.h index 150fd8902..963e6b2d2 100644 --- a/generated/generate_cursor_functions_u64.h +++ b/generated/generate_cursor_functions_u64.h @@ -1,16 +1,15 @@ -// external/bonsai_stdlib/src/binary_parser.cpp:26:0 - +// external/bonsai_stdlib/src/poof_functions.h:1563:0 link_internal u64_cursor U64Cursor(umm ElementCount, memory_arena* Memory) { u64 *Start = (u64*)PushStruct(Memory, sizeof(u64)*ElementCount, 1, 0); - u64_cursor Result = { - .Start = Start, - .End = Start+ElementCount, - .At = Start, - /* OWNED_BY_THREAD_MEMBER_INIT() */ - }; + u64_cursor Result = {}; + + Result.Start = Start; + Result.End = Start+ElementCount; + Result.At = Start; + return Result; } @@ -24,6 +23,12 @@ GetPtr(u64_cursor *Cursor, umm ElementIndex) return Result; } +link_internal u64* +TryGetPtr(u64_cursor *Cursor, umm ElementIndex) +{ + return GetPtr(Cursor, ElementIndex); +} + link_internal u64* GetPtrUnsafe(u64_cursor *Cursor, umm ElementIndex) { diff --git a/generated/generate_cursor_octree_node.h b/generated/generate_cursor_octree_node.h new file mode 100644 index 000000000..18530a52b --- /dev/null +++ b/generated/generate_cursor_octree_node.h @@ -0,0 +1,187 @@ +// external/bonsai_stdlib/src/poof_functions.h:1541:0 +struct octree_node_ptr_cursor +{ + octree_node_ptr *Start; + // TODO(Jesse)(immediate): For the love of fucksakes change these to indices + octree_node_ptr *At; + octree_node_ptr *End; +}; + + + +link_internal octree_node_ptr_cursor +OctreeNodePtrCursor(umm ElementCount, memory_arena* Memory) +{ + octree_node_ptr *Start = (octree_node_ptr*)PushStruct(Memory, sizeof(octree_node_ptr)*ElementCount, 1, 0); + octree_node_ptr_cursor Result = {}; + + Result.Start = Start; + Result.End = Start+ElementCount; + Result.At = Start; + + return Result; +} + +link_internal octree_node_ptr* +GetPtr(octree_node_ptr_cursor *Cursor, umm ElementIndex) +{ + /* ENSURE_OWNED_BY_THREAD(Cursor); */ + + octree_node_ptr *Result = {}; + if (ElementIndex < AtElements(Cursor)) { Result = Cursor->Start+ElementIndex; } + return Result; +} + +link_internal octree_node_ptr* +TryGetPtr(octree_node_ptr_cursor *Cursor, umm ElementIndex) +{ + return GetPtr(Cursor, ElementIndex); +} + +link_internal octree_node_ptr* +GetPtrUnsafe(octree_node_ptr_cursor *Cursor, umm ElementIndex) +{ + /* ENSURE_OWNED_BY_THREAD(Cursor); */ + + octree_node_ptr *Result = {}; + if (ElementIndex < TotalElements(Cursor)) { Result = Cursor->Start+ElementIndex; } + return Result; +} + +link_internal octree_node_ptr +Get(octree_node_ptr_cursor *Cursor, umm ElementIndex) +{ + /* ENSURE_OWNED_BY_THREAD(Cursor); */ + + Assert(ElementIndex < CurrentCount(Cursor)); + octree_node_ptr Result = Cursor->Start[ElementIndex]; + return Result; +} + +link_internal void +Set(octree_node_ptr_cursor *Cursor, umm ElementIndex, octree_node_ptr Element) +{ + /* ENSURE_OWNED_BY_THREAD(Cursor); */ + + umm CurrentElementCount = CurrentCount(Cursor); + Assert (ElementIndex <= CurrentElementCount); + + Cursor->Start[ElementIndex] = Element; + if (ElementIndex == CurrentElementCount) + { + Cursor->At++; + } +} + +link_internal octree_node_ptr* +Advance(octree_node_ptr_cursor *Cursor) +{ + /* ENSURE_OWNED_BY_THREAD(Cursor); */ + + octree_node_ptr * Result = {}; + if ( Cursor->At < Cursor->End ) { Result = Cursor->At++; } + return Result; +} + +link_internal octree_node_ptr * +Push(octree_node_ptr_cursor *Cursor, octree_node_ptr Element) +{ + /* ENSURE_OWNED_BY_THREAD(Cursor); */ + + Assert( Cursor->At < Cursor->End ); + octree_node_ptr *Result = Cursor->At; + *Cursor->At++ = Element; + return Result; +} + +link_internal octree_node_ptr +Pop(octree_node_ptr_cursor *Cursor) +{ + /* ENSURE_OWNED_BY_THREAD(Cursor); */ + + Assert( Cursor->At > Cursor->Start ); + octree_node_ptr Result = Cursor->At[-1]; + Cursor->At--; + return Result; +} + +link_internal s32 +LastIndex(octree_node_ptr_cursor *Cursor) +{ + /* ENSURE_OWNED_BY_THREAD(Cursor); */ + + s32 Result = s32(CurrentCount(Cursor))-1; + return Result; +} + +link_internal octree_node_ptr* +LastElement(octree_node_ptr_cursor *Cursor) +{ + octree_node_ptr *Result = {}; + s32 I = LastIndex(Cursor); + if (I > -1) { Result = Cursor->Start + I; } + return Result; +} + +link_internal b32 +Remove(octree_node_ptr_cursor *Cursor, octree_node_ptr Query) +{ + /* ENSURE_OWNED_BY_THREAD(Cursor); */ + + b32 Result = False; + CursorIterator(ElementIndex, Cursor) + { + octree_node_ptr Element = Get(Cursor, ElementIndex); + if (AreEqual(Element, Query)) + { + b32 IsLastIndex = LastIndex(Cursor) == s32(ElementIndex); + octree_node_ptr Tmp = Pop(Cursor); + + if (IsLastIndex) { Assert(AreEqual(Tmp, Query)); } + else { Set(Cursor, ElementIndex, Tmp); } + Result = True; + } + } + return Result; +} + + +link_internal b32 +ResizeCursor(octree_node_ptr_cursor *Cursor, umm Count, memory_arena *Memory) +{ + /* ENSURE_OWNED_BY_THREAD(Cursor); */ + + umm CurrentSize = TotalSize(Cursor); + + TruncateToElementCount(Cursor, Count); + umm NewSize = TotalSize(Cursor); + + Assert(NewSize/sizeof(octree_node_ptr) == Count); + + /* Info("Attempting to reallocate CurrentSize(%u), NewSize(%u)", CurrentSize, NewSize); */ + Ensure(Reallocate((u8*)Cursor->Start, Memory, CurrentSize, NewSize)); + return 0; +} + +link_internal void +Unshift( octree_node_ptr_cursor *Cursor ) +{ + /* ENSURE_OWNED_BY_THREAD(Cursor); */ + umm Count = AtElements(Cursor); + if (Count) + { + for (umm Index = 1; Index < Count; ++Index) + { + Cursor->Start[Index-1] = Cursor->Start[Index]; + } + + // NOTE(Jesse): This is actually correct, even though it doesn't look + // like it at first glance. At is OnePastLast, so decrementing and + // then clearing overwrites the last value that was set. + Cursor->At--; + *Cursor->At = {}; + } +} + + + diff --git a/generated/generate_cursor_parser.h b/generated/generate_cursor_parser.h index 7b24b6b6d..f5c33bd95 100644 --- a/generated/generate_cursor_parser.h +++ b/generated/generate_cursor_parser.h @@ -1,12 +1,10 @@ -// external/bonsai_stdlib/src/c_parser.h:92:0 - +// external/bonsai_stdlib/src/poof_functions.h:1541:0 struct parser_cursor { parser *Start; // TODO(Jesse)(immediate): For the love of fucksakes change these to indices parser *At; parser *End; - /* OWNED_BY_THREAD_MEMBER(); */ }; @@ -15,12 +13,12 @@ link_internal parser_cursor ParserCursor(umm ElementCount, memory_arena* Memory) { parser *Start = (parser*)PushStruct(Memory, sizeof(parser)*ElementCount, 1, 0); - parser_cursor Result = { - .Start = Start, - .End = Start+ElementCount, - .At = Start, - /* OWNED_BY_THREAD_MEMBER_INIT() */ - }; + parser_cursor Result = {}; + + Result.Start = Start; + Result.End = Start+ElementCount; + Result.At = Start; + return Result; } @@ -34,6 +32,12 @@ GetPtr(parser_cursor *Cursor, umm ElementIndex) return Result; } +link_internal parser* +TryGetPtr(parser_cursor *Cursor, umm ElementIndex) +{ + return GetPtr(Cursor, ElementIndex); +} + link_internal parser* GetPtrUnsafe(parser_cursor *Cursor, umm ElementIndex) { diff --git a/generated/generate_cursor_struct_u64.h b/generated/generate_cursor_struct_u64.h index 209f82f55..4de7b9044 100644 --- a/generated/generate_cursor_struct_u64.h +++ b/generated/generate_cursor_struct_u64.h @@ -1,12 +1,10 @@ -// external/bonsai_stdlib/src/binary_parser.h:1:0 - +// external/bonsai_stdlib/src/poof_functions.h:1548:0 struct u64_cursor { u64 *Start; // TODO(Jesse)(immediate): For the love of fucksakes change these to indices u64 *At; u64 *End; - /* OWNED_BY_THREAD_MEMBER(); */ }; diff --git a/generated/generate_cursor_texture.h b/generated/generate_cursor_texture.h index f3f0727b7..0fe4aa28d 100644 --- a/generated/generate_cursor_texture.h +++ b/generated/generate_cursor_texture.h @@ -1,12 +1,10 @@ -// external/bonsai_stdlib/src/texture_cursor.cpp:10:0 - +// external/bonsai_stdlib/src/poof_functions.h:1541:0 struct texture_cursor { texture *Start; // TODO(Jesse)(immediate): For the love of fucksakes change these to indices texture *At; texture *End; - /* OWNED_BY_THREAD_MEMBER(); */ }; @@ -15,12 +13,12 @@ link_internal texture_cursor TextureCursor(umm ElementCount, memory_arena* Memory) { texture *Start = (texture*)PushStruct(Memory, sizeof(texture)*ElementCount, 1, 0); - texture_cursor Result = { - .Start = Start, - .End = Start+ElementCount, - .At = Start, - /* OWNED_BY_THREAD_MEMBER_INIT() */ - }; + texture_cursor Result = {}; + + Result.Start = Start; + Result.End = Start+ElementCount; + Result.At = Start; + return Result; } @@ -34,6 +32,12 @@ GetPtr(texture_cursor *Cursor, umm ElementIndex) return Result; } +link_internal texture* +TryGetPtr(texture_cursor *Cursor, umm ElementIndex) +{ + return GetPtr(Cursor, ElementIndex); +} + link_internal texture* GetPtrUnsafe(texture_cursor *Cursor, umm ElementIndex) { diff --git a/generated/generate_cursor_u8.h b/generated/generate_cursor_u8.h index e06d2fc2e..b3fd33ce9 100644 --- a/generated/generate_cursor_u8.h +++ b/generated/generate_cursor_u8.h @@ -1,12 +1,10 @@ -// external/bonsai_stdlib/src/ansi_stream.h:3:0 - +// external/bonsai_stdlib/src/poof_functions.h:1541:0 struct u8_cursor { u8 *Start; // TODO(Jesse)(immediate): For the love of fucksakes change these to indices u8 *At; u8 *End; - /* OWNED_BY_THREAD_MEMBER(); */ }; @@ -15,12 +13,12 @@ link_internal u8_cursor U8Cursor(umm ElementCount, memory_arena* Memory) { u8 *Start = (u8*)PushStruct(Memory, sizeof(u8)*ElementCount, 1, 0); - u8_cursor Result = { - .Start = Start, - .End = Start+ElementCount, - .At = Start, - /* OWNED_BY_THREAD_MEMBER_INIT() */ - }; + u8_cursor Result = {}; + + Result.Start = Start; + Result.End = Start+ElementCount; + Result.At = Start; + return Result; } @@ -34,6 +32,12 @@ GetPtr(u8_cursor *Cursor, umm ElementIndex) return Result; } +link_internal u8* +TryGetPtr(u8_cursor *Cursor, umm ElementIndex) +{ + return GetPtr(Cursor, ElementIndex); +} + link_internal u8* GetPtrUnsafe(u8_cursor *Cursor, umm ElementIndex) { diff --git a/generated/generate_cursor_v3.h b/generated/generate_cursor_v3.h index 3476dd807..62b5e4bc8 100644 --- a/generated/generate_cursor_v3.h +++ b/generated/generate_cursor_v3.h @@ -1,12 +1,10 @@ -// external/bonsai_stdlib/src/binary_parser.cpp:40:0 - +// external/bonsai_stdlib/src/poof_functions.h:1541:0 struct v3_cursor { v3 *Start; // TODO(Jesse)(immediate): For the love of fucksakes change these to indices v3 *At; v3 *End; - /* OWNED_BY_THREAD_MEMBER(); */ }; @@ -15,12 +13,12 @@ link_internal v3_cursor V3Cursor(umm ElementCount, memory_arena* Memory) { v3 *Start = (v3*)PushStruct(Memory, sizeof(v3)*ElementCount, 1, 0); - v3_cursor Result = { - .Start = Start, - .End = Start+ElementCount, - .At = Start, - /* OWNED_BY_THREAD_MEMBER_INIT() */ - }; + v3_cursor Result = {}; + + Result.Start = Start; + Result.End = Start+ElementCount; + Result.At = Start; + return Result; } @@ -34,6 +32,12 @@ GetPtr(v3_cursor *Cursor, umm ElementIndex) return Result; } +link_internal v3* +TryGetPtr(v3_cursor *Cursor, umm ElementIndex) +{ + return GetPtr(Cursor, ElementIndex); +} + link_internal v3* GetPtrUnsafe(v3_cursor *Cursor, umm ElementIndex) { diff --git a/generated/generate_cursor_voxel_stack_element.h b/generated/generate_cursor_voxel_stack_element.h index 5471bc13f..20165103f 100644 --- a/generated/generate_cursor_voxel_stack_element.h +++ b/generated/generate_cursor_voxel_stack_element.h @@ -1,12 +1,10 @@ -// src/engine/world_update.h:38:0 - +// external/bonsai_stdlib/src/poof_functions.h:1541:0 struct voxel_stack_element_cursor { voxel_stack_element *Start; // TODO(Jesse)(immediate): For the love of fucksakes change these to indices voxel_stack_element *At; voxel_stack_element *End; - /* OWNED_BY_THREAD_MEMBER(); */ }; @@ -15,12 +13,12 @@ link_internal voxel_stack_element_cursor VoxelStackElementCursor(umm ElementCount, memory_arena* Memory) { voxel_stack_element *Start = (voxel_stack_element*)PushStruct(Memory, sizeof(voxel_stack_element)*ElementCount, 1, 0); - voxel_stack_element_cursor Result = { - .Start = Start, - .End = Start+ElementCount, - .At = Start, - /* OWNED_BY_THREAD_MEMBER_INIT() */ - }; + voxel_stack_element_cursor Result = {}; + + Result.Start = Start; + Result.End = Start+ElementCount; + Result.At = Start; + return Result; } @@ -34,6 +32,12 @@ GetPtr(voxel_stack_element_cursor *Cursor, umm ElementIndex) return Result; } +link_internal voxel_stack_element* +TryGetPtr(voxel_stack_element_cursor *Cursor, umm ElementIndex) +{ + return GetPtr(Cursor, ElementIndex); +} + link_internal voxel_stack_element* GetPtrUnsafe(voxel_stack_element_cursor *Cursor, umm ElementIndex) { diff --git a/generated/generate_stack_octree_node_ptr_0.h b/generated/generate_stack_octree_node_ptr_0.h new file mode 100644 index 000000000..09e70e173 --- /dev/null +++ b/generated/generate_stack_octree_node_ptr_0.h @@ -0,0 +1,93 @@ +// external/bonsai_stdlib/src/poof_functions.h:1444:0 +struct octree_node_ptr_stack +{ + octree_node_ptr *Start; + umm At; + umm End; + +}; + +link_internal octree_node_ptr_stack +OctreeNodePtrStack(umm ElementCount, memory_arena* Memory) +{ + octree_node_ptr *Start = (octree_node_ptr*)PushStruct(Memory, sizeof(octree_node_ptr)*ElementCount, 1, 0); + octree_node_ptr_stack Result = {}; + Result.Start = Start; + Result.End = ElementCount; + Result.At = 0; + return Result; +} + +link_internal umm +CurrentCount(octree_node_ptr_stack *Cursor) +{ + umm Result = Cursor->At; + return Result; +} + +link_internal s32 +LastIndex(octree_node_ptr_stack *Cursor) +{ + s32 Result = s32(Cursor->At)-1; + return Result; +} + +link_internal octree_node_ptr +Get(octree_node_ptr_stack *Cursor, umm ElementIndex) +{ + Assert(ElementIndex < Cursor->At); + octree_node_ptr Result = Cursor->Start[ElementIndex]; + return Result; +} + +link_internal void +Set(octree_node_ptr_stack *Cursor, umm ElementIndex, octree_node_ptr Element) +{ + umm CurrentElementCount = Cursor->At; + Assert (ElementIndex <= CurrentElementCount); + + Cursor->Start[ElementIndex] = Element; + if (ElementIndex == CurrentElementCount) + { + Cursor->At++; + } +} + +link_internal octree_node_ptr * +Push(octree_node_ptr_stack *Cursor, octree_node_ptr Element) +{ + Assert( Cursor->At < Cursor->End ); + octree_node_ptr *Result = Cursor->Start+Cursor->At; + Cursor->Start[Cursor->At++] = Element; + return Result; +} + +link_internal octree_node_ptr +Pop(octree_node_ptr_stack *Cursor) +{ + Assert( Cursor->At > 0 ); + octree_node_ptr Result = Cursor->Start[LastIndex(Cursor)]; + Cursor->At--; + return Result; +} + +link_internal b32 +RemoveUnordered(octree_node_ptr_stack *Cursor, octree_node_ptr Query) +{ + b32 Result = False; + StackIterator(ElementIndex, Cursor) + { + octree_node_ptr Element = Get(Cursor, ElementIndex); + if (AreEqual(Element, Query)) + { + b32 IsLastIndex = LastIndex(Cursor) == s32(ElementIndex); + octree_node_ptr Tmp = Pop(Cursor); + + if (IsLastIndex) { Assert(AreEqual(Tmp, Query)); } + else { Set(Cursor, ElementIndex, Tmp); } + Result = True; + } + } + return Result; +} + 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 31a5ec0ca..0384acd38 100644 --- a/generated/generate_stack_voxel_synthesis_change_propagation_info_803395170.h +++ b/generated/generate_stack_voxel_synthesis_change_propagation_info_803395170.h @@ -1,5 +1,4 @@ -// src/engine/voxel_synthesis.h:310:0 - +// external/bonsai_stdlib/src/poof_functions.h:1444:0 struct voxel_synthesis_change_propagation_info_stack { voxel_synthesis_change_propagation_info *Start; @@ -12,11 +11,10 @@ link_internal voxel_synthesis_change_propagation_info_stack VoxelSynthesisChangePropagationInfoStack(umm ElementCount, memory_arena* Memory) { voxel_synthesis_change_propagation_info *Start = (voxel_synthesis_change_propagation_info*)PushStruct(Memory, sizeof(voxel_synthesis_change_propagation_info)*ElementCount, 1, 0); - voxel_synthesis_change_propagation_info_stack Result = { - .Start = Start, - .End = ElementCount, - .At = 0, - }; + voxel_synthesis_change_propagation_info_stack Result = {}; + Result.Start = Start; + Result.End = ElementCount; + Result.At = 0; return Result; } diff --git a/generated/generate_stream_c_token_buffer.h b/generated/generate_stream_c_token_buffer.h index d3d1f35ef..30f9e77e1 100644 --- a/generated/generate_stream_c_token_buffer.h +++ b/generated/generate_stream_c_token_buffer.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/c_token.cpp:8:0 - +// external/bonsai_stdlib/src/poof_functions.h:2037:0 struct c_token_buffer_stream_chunk { c_token_buffer Element; @@ -14,6 +13,14 @@ struct c_token_buffer_stream umm ChunkCount; }; +link_internal c_token_buffer_stream +CTokenBufferStream(memory_arena *Memory) +{ + c_token_buffer_stream Result = {}; + Result.Memory = Memory; + return Result; +} + link_internal void Deallocate(c_token_buffer_stream *Stream) { @@ -62,10 +69,7 @@ IsLastElement(c_token_buffer_iterator* Iter) link_internal c_token_buffer * Push(c_token_buffer_stream* Stream, c_token_buffer Element) { - if (Stream->Memory == 0) - { - Stream->Memory = AllocateArena(); - } + Assert(Stream->Memory); /* (Type.name)_stream_chunk* NextChunk = AllocateProtection((Type.name)_stream_chunk*), Stream->Memory, 1, False) */ c_token_buffer_stream_chunk* NextChunk = (c_token_buffer_stream_chunk*)PushStruct(Stream->Memory, sizeof(c_token_buffer_stream_chunk), 1, 0); diff --git a/generated/generate_stream_compact_standing_spot.h b/generated/generate_stream_compact_standing_spot.h index e0dd90723..9c11b0197 100644 --- a/generated/generate_stream_compact_standing_spot.h +++ b/generated/generate_stream_compact_standing_spot.h @@ -1,5 +1,4 @@ -// src/engine/world_chunk.h:572:0 - +// external/bonsai_stdlib/src/poof_functions.h:2007:0 link_internal standing_spot_buffer Compact(standing_spot_stream *Stream, memory_arena *PermMemory) { diff --git a/generated/generate_stream_compact_u32.h b/generated/generate_stream_compact_u32.h index ebbfc97a1..473ad5833 100644 --- a/generated/generate_stream_compact_u32.h +++ b/generated/generate_stream_compact_u32.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/binary_parser.cpp:18:0 - +// external/bonsai_stdlib/src/poof_functions.h:2007:0 link_internal u32_buffer Compact(u32_stream *Stream, memory_arena *PermMemory) { diff --git a/generated/generate_stream_compact_u64.h b/generated/generate_stream_compact_u64.h index e46895c8a..a2907d388 100644 --- a/generated/generate_stream_compact_u64.h +++ b/generated/generate_stream_compact_u64.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/binary_parser.cpp:32:0 - +// external/bonsai_stdlib/src/poof_functions.h:2007:0 link_internal u64_buffer Compact(u64_stream *Stream, memory_arena *PermMemory) { diff --git a/generated/generate_stream_compact_v3i.h b/generated/generate_stream_compact_v3i.h index 8dad50541..4bb625f28 100644 --- a/generated/generate_stream_compact_v3i.h +++ b/generated/generate_stream_compact_v3i.h @@ -1,5 +1,4 @@ -// src/engine/world_chunk.cpp:3026:0 - +// external/bonsai_stdlib/src/poof_functions.h:2007:0 link_internal v3i_buffer Compact(v3i_stream *Stream, memory_arena *PermMemory) { diff --git a/generated/generate_stream_parser.h b/generated/generate_stream_parser.h index 841246bb2..7b6f276aa 100644 --- a/generated/generate_stream_parser.h +++ b/generated/generate_stream_parser.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/c_parser.h:95:0 - +// external/bonsai_stdlib/src/poof_functions.h:2037:0 struct parser_stream_chunk { parser Element; @@ -14,6 +13,14 @@ struct parser_stream umm ChunkCount; }; +link_internal parser_stream +ParserStream(memory_arena *Memory) +{ + parser_stream Result = {}; + Result.Memory = Memory; + return Result; +} + link_internal void Deallocate(parser_stream *Stream) { @@ -62,10 +69,7 @@ IsLastElement(parser_iterator* Iter) link_internal parser * Push(parser_stream* Stream, parser Element) { - if (Stream->Memory == 0) - { - Stream->Memory = AllocateArena(); - } + Assert(Stream->Memory); /* (Type.name)_stream_chunk* NextChunk = AllocateProtection((Type.name)_stream_chunk*), Stream->Memory, 1, False) */ parser_stream_chunk* NextChunk = (parser_stream_chunk*)PushStruct(Stream->Memory, sizeof(parser_stream_chunk), 1, 0); diff --git a/generated/generate_stream_standing_spot.h b/generated/generate_stream_standing_spot.h index f193f5d93..c320179a1 100644 --- a/generated/generate_stream_standing_spot.h +++ b/generated/generate_stream_standing_spot.h @@ -1,5 +1,4 @@ -// src/engine/world_chunk.h:569:0 - +// external/bonsai_stdlib/src/poof_functions.h:2037:0 struct standing_spot_stream_chunk { standing_spot Element; @@ -14,6 +13,14 @@ struct standing_spot_stream umm ChunkCount; }; +link_internal standing_spot_stream +StandingSpotStream(memory_arena *Memory) +{ + standing_spot_stream Result = {}; + Result.Memory = Memory; + return Result; +} + link_internal void Deallocate(standing_spot_stream *Stream) { @@ -62,10 +69,7 @@ IsLastElement(standing_spot_iterator* Iter) link_internal standing_spot * Push(standing_spot_stream* Stream, standing_spot Element) { - if (Stream->Memory == 0) - { - Stream->Memory = AllocateArena(); - } + Assert(Stream->Memory); /* (Type.name)_stream_chunk* NextChunk = AllocateProtection((Type.name)_stream_chunk*), Stream->Memory, 1, False) */ standing_spot_stream_chunk* NextChunk = (standing_spot_stream_chunk*)PushStruct(Stream->Memory, sizeof(standing_spot_stream_chunk), 1, 0); diff --git a/generated/generate_stream_tagged_counted_string_stream.h b/generated/generate_stream_tagged_counted_string_stream.h index 4d7864a70..da0d4a29b 100644 --- a/generated/generate_stream_tagged_counted_string_stream.h +++ b/generated/generate_stream_tagged_counted_string_stream.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/counted_string.h:124:0 - +// external/bonsai_stdlib/src/poof_functions.h:2037:0 struct tagged_counted_string_stream_stream_chunk { tagged_counted_string_stream Element; @@ -14,6 +13,14 @@ struct tagged_counted_string_stream_stream umm ChunkCount; }; +link_internal tagged_counted_string_stream_stream +TaggedCountedStringStreamStream(memory_arena *Memory) +{ + tagged_counted_string_stream_stream Result = {}; + Result.Memory = Memory; + return Result; +} + link_internal void Deallocate(tagged_counted_string_stream_stream *Stream) { @@ -62,10 +69,7 @@ IsLastElement(tagged_counted_string_stream_iterator* Iter) link_internal tagged_counted_string_stream * Push(tagged_counted_string_stream_stream* Stream, tagged_counted_string_stream Element) { - if (Stream->Memory == 0) - { - Stream->Memory = AllocateArena(); - } + Assert(Stream->Memory); /* (Type.name)_stream_chunk* NextChunk = AllocateProtection((Type.name)_stream_chunk*), Stream->Memory, 1, False) */ tagged_counted_string_stream_stream_chunk* NextChunk = (tagged_counted_string_stream_stream_chunk*)PushStruct(Stream->Memory, sizeof(tagged_counted_string_stream_stream_chunk), 1, 0); diff --git a/generated/generate_stream_tuple_cs_cs.h b/generated/generate_stream_tuple_cs_cs.h index 0875886c9..560f36f21 100644 --- a/generated/generate_stream_tuple_cs_cs.h +++ b/generated/generate_stream_tuple_cs_cs.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/counted_string.cpp:32:0 - +// external/bonsai_stdlib/src/poof_functions.h:2037:0 struct tuple_cs_cs_stream_chunk { tuple_cs_cs Element; @@ -14,6 +13,14 @@ struct tuple_cs_cs_stream umm ChunkCount; }; +link_internal tuple_cs_cs_stream +TupleCsCsStream(memory_arena *Memory) +{ + tuple_cs_cs_stream Result = {}; + Result.Memory = Memory; + return Result; +} + link_internal void Deallocate(tuple_cs_cs_stream *Stream) { @@ -62,10 +69,7 @@ IsLastElement(tuple_cs_cs_iterator* Iter) link_internal tuple_cs_cs * Push(tuple_cs_cs_stream* Stream, tuple_cs_cs Element) { - if (Stream->Memory == 0) - { - Stream->Memory = AllocateArena(); - } + Assert(Stream->Memory); /* (Type.name)_stream_chunk* NextChunk = AllocateProtection((Type.name)_stream_chunk*), Stream->Memory, 1, False) */ tuple_cs_cs_stream_chunk* NextChunk = (tuple_cs_cs_stream_chunk*)PushStruct(Stream->Memory, sizeof(tuple_cs_cs_stream_chunk), 1, 0); diff --git a/generated/generate_stream_u64.h b/generated/generate_stream_u64.h index 9181e3859..e377427fa 100644 --- a/generated/generate_stream_u64.h +++ b/generated/generate_stream_u64.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/binary_parser.cpp:29:0 - +// external/bonsai_stdlib/src/poof_functions.h:2037:0 struct u64_stream_chunk { u64 Element; @@ -14,6 +13,14 @@ struct u64_stream umm ChunkCount; }; +link_internal u64_stream +U64Stream(memory_arena *Memory) +{ + u64_stream Result = {}; + Result.Memory = Memory; + return Result; +} + link_internal void Deallocate(u64_stream *Stream) { @@ -62,10 +69,7 @@ IsLastElement(u64_iterator* Iter) link_internal u64 * Push(u64_stream* Stream, u64 Element) { - if (Stream->Memory == 0) - { - Stream->Memory = AllocateArena(); - } + Assert(Stream->Memory); /* (Type.name)_stream_chunk* NextChunk = AllocateProtection((Type.name)_stream_chunk*), Stream->Memory, 1, False) */ u64_stream_chunk* NextChunk = (u64_stream_chunk*)PushStruct(Stream->Memory, sizeof(u64_stream_chunk), 1, 0); diff --git a/generated/generate_stream_v3i.h b/generated/generate_stream_v3i.h index 5296dc8a8..8f9be9785 100644 --- a/generated/generate_stream_v3i.h +++ b/generated/generate_stream_v3i.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/vector.cpp:8:0 - +// external/bonsai_stdlib/src/poof_functions.h:2037:0 struct v3i_stream_chunk { v3i Element; @@ -14,6 +13,14 @@ struct v3i_stream umm ChunkCount; }; +link_internal v3i_stream +V3iStream(memory_arena *Memory) +{ + v3i_stream Result = {}; + Result.Memory = Memory; + return Result; +} + link_internal void Deallocate(v3i_stream *Stream) { @@ -62,10 +69,7 @@ IsLastElement(v3i_iterator* Iter) link_internal v3i * Push(v3i_stream* Stream, v3i Element) { - if (Stream->Memory == 0) - { - Stream->Memory = AllocateArena(); - } + Assert(Stream->Memory); /* (Type.name)_stream_chunk* NextChunk = AllocateProtection((Type.name)_stream_chunk*), Stream->Memory, 1, False) */ v3i_stream_chunk* NextChunk = (v3i_stream_chunk*)PushStruct(Stream->Memory, sizeof(v3i_stream_chunk), 1, 0); diff --git a/generated/generate_string_table_Chunk_ID.h b/generated/generate_string_table_Chunk_ID.h index 7aee9d4e2..5ea3f908e 100644 --- a/generated/generate_string_table_Chunk_ID.h +++ b/generated/generate_string_table_Chunk_ID.h @@ -1,12 +1,45 @@ -// src/engine/loaders/vox.cpp:27:0 +// external/bonsai_stdlib/src/poof_functions.h:1744:0 +link_internal b32 +IsValid(Chunk_ID Value) +{ + b32 Result = False; + switch (Value) + { + case ID_NONE: + case ID_VOX: + case ID_MAIN: + case ID_PACK: + case ID_SIZE: + case ID_XYZI: + case ID_RGBA: + case ID_nTRN: + case ID_nGRP: + case ID_nSHP: + case ID_MATL: + case ID_LAYR: + case ID_rOBJ: + case ID_rCAM: + case ID_NOTE: + case ID_IMAP: + + { + Result = True; + } + } + return Result; +} + + link_internal counted_string ToStringPrefixless(Chunk_ID Type) { + Assert(IsValid(Type)); counted_string Result = {}; + switch (Type) { - case ID_NONE: { Result = CSz("NONE"); } break; + case ID_NONE: { Result = CSz("NONE"); } break; case ID_VOX: { Result = CSz("VOX"); } break; case ID_MAIN: { Result = CSz("MAIN"); } break; case ID_PACK: { Result = CSz("PACK"); } break; @@ -23,19 +56,22 @@ ToStringPrefixless(Chunk_ID Type) case ID_NOTE: { Result = CSz("NOTE"); } break; case ID_IMAP: { Result = CSz("IMAP"); } break; + } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } link_internal counted_string ToString(Chunk_ID Type) { + Assert(IsValid(Type)); + counted_string Result = {}; switch (Type) { - case ID_NONE: { Result = CSz("ID_NONE"); } break; + case ID_NONE: { Result = CSz("ID_NONE"); } break; case ID_VOX: { Result = CSz("ID_VOX"); } break; case ID_MAIN: { Result = CSz("ID_MAIN"); } break; case ID_PACK: { Result = CSz("ID_PACK"); } break; @@ -52,9 +88,10 @@ ToString(Chunk_ID Type) case ID_NOTE: { Result = CSz("ID_NOTE"); } break; case ID_IMAP: { Result = CSz("ID_IMAP"); } break; + } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } diff --git a/generated/generate_string_table_asset_load_state.h b/generated/generate_string_table_asset_load_state.h index 9027206f6..afe01d2ad 100644 --- a/generated/generate_string_table_asset_load_state.h +++ b/generated/generate_string_table_asset_load_state.h @@ -1,38 +1,64 @@ -// src/engine/asset.h:141:0 +// external/bonsai_stdlib/src/poof_functions.h:1744:0 +link_internal b32 +IsValid(asset_load_state Value) +{ + b32 Result = False; + switch (Value) + { + case AssetLoadState_Unloaded: + case AssetLoadState_Allocated: + case AssetLoadState_Queued: + case AssetLoadState_Loaded: + case AssetLoadState_Error: + + { + Result = True; + } + } + return Result; +} + + link_internal counted_string ToStringPrefixless(asset_load_state Type) { + Assert(IsValid(Type)); counted_string Result = {}; + switch (Type) { - case AssetLoadState_Unloaded: { Result = CSz("Unloaded"); } break; + case AssetLoadState_Unloaded: { Result = CSz("Unloaded"); } break; case AssetLoadState_Allocated: { Result = CSz("Allocated"); } break; case AssetLoadState_Queued: { Result = CSz("Queued"); } break; case AssetLoadState_Loaded: { Result = CSz("Loaded"); } break; case AssetLoadState_Error: { Result = CSz("Error"); } break; + } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } link_internal counted_string ToString(asset_load_state Type) { + Assert(IsValid(Type)); + counted_string Result = {}; switch (Type) { - case AssetLoadState_Unloaded: { Result = CSz("AssetLoadState_Unloaded"); } break; + case AssetLoadState_Unloaded: { Result = CSz("AssetLoadState_Unloaded"); } break; case AssetLoadState_Allocated: { Result = CSz("AssetLoadState_Allocated"); } break; case AssetLoadState_Queued: { Result = CSz("AssetLoadState_Queued"); } break; case AssetLoadState_Loaded: { Result = CSz("AssetLoadState_Loaded"); } break; case AssetLoadState_Error: { Result = CSz("AssetLoadState_Error"); } break; + } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } diff --git a/generated/generate_string_table_c_token_type.h b/generated/generate_string_table_c_token_type.h index 638ac107b..0fb305165 100644 --- a/generated/generate_string_table_c_token_type.h +++ b/generated/generate_string_table_c_token_type.h @@ -1,12 +1,202 @@ -// external/bonsai_stdlib/src/c_token.h:225:0 +// external/bonsai_stdlib/src/poof_functions.h:1744:0 +link_internal b32 +IsValid(c_token_type Value) +{ + b32 Result = False; + switch (Value) + { + case CTokenType_Unknown: + case CT_ControlChar_Start_of_Heading: + case CT_ControlChar_Start_of_Text: + case CT_ControlChar_End_of_Text: + case CT_ControlChar_End_of_Transmission: + case CT_ControlChar_Enquiry: + case CT_ControlChar_Acknowledgement: + case CT_ControlChar_Bell: + case CT_ControlChar_Backspace: + case CT_ControlChar_Vertical_Tab: + case CT_ControlChar_Form_Feed: + case CT_ControlChar_Shift_Out: + case CT_ControlChar_Shift_In: + case CT_ControlChar_Data_Link_Escape: + case CT_ControlChar_Device_Control_1: + case CT_ControlChar_Device_Control_2: + case CT_ControlChar_Device_Control_3: + case CT_ControlChar_Device_Control_4: + case CT_ControlChar_Negative_Acknowledgement: + case CT_ControlChar_Synchronous_Idle: + case CT_ControlChar_End_of_Transmission_Block: + case CT_ControlChar_Cancel: + case CT_ControlChar_End_of_Medium: + case CT_ControlChar_Substitute: + case CT_ControlChar_Escape: + case CT_ControlChar_File_Separator: + case CT_ControlChar_Group_Separator: + case CT_ControlChar_Record_Separator: + case CT_ControlChar_Unit_Separator: + case CT_ControlChar_Delete: + case CTokenType_OpenBracket: + case CTokenType_CloseBracket: + case CTokenType_OpenBrace: + case CTokenType_CloseBrace: + case CTokenType_OpenParen: + case CTokenType_CloseParen: + case CTokenType_Dot: + case CTokenType_Comma: + case CTokenType_Semicolon: + case CTokenType_Colon: + case CTokenType_Hash: + case CTokenType_At: + case CTokenType_Dollar: + case CTokenType_Space: + case CTokenType_Tab: + case CTokenType_Star: + case CTokenType_Ampersand: + case CTokenType_SingleQuote: + case CTokenType_DoubleQuote: + case CTokenType_Equals: + case CTokenType_LT: + case CTokenType_GT: + case CTokenType_Plus: + case CTokenType_Minus: + case CTokenType_Percent: + case CTokenType_Bang: + case CTokenType_Hat: + case CTokenType_Question: + case CTokenType_FSlash: + case CTokenType_BSlash: + case CTokenType_Tilde: + case CTokenType_Backtick: + case CTokenType_Pipe: + case CTokenType_Newline: + case CTokenType_CarrigeReturn: + case CTokenType_EOF: + case CTokenType_CommentSingleLine: + case CTokenType_CommentMultiLine: + case CTokenType_EscapedNewline: + case CTokenType_Identifier: + case CTokenType_StringLiteral: + case CTokenType_CharLiteral: + case CTokenType_IntLiteral: + case CTokenType_DoubleLiteral: + case CTokenType_FloatLiteral: + case CTokenType_Poof: + case CT_Keyword_Noreturn: + case CT_Keyword_Override: + case CT_Keyword_Virtual: + case CT_Keyword_Noexcept: + case CT_Keyword_Explicit: + case CT_Keyword_Constexpr: + case CT_Keyword_Namespace: + case CT_Keyword_Class: + case CTokenType_Struct: + case CTokenType_Enum: + case CTokenType_Union: + case CTokenType_Typedef: + case CTokenType_Using: + case CTokenType_ThreadLocal: + case CTokenType_Const: + case CTokenType_Static: + case CTokenType_Volatile: + case CTokenType_Long: + case CTokenType_Unsigned: + case CTokenType_Signed: + case CTokenType_Bool: + case CTokenType_Auto: + case CTokenType_Void: + case CTokenType_Double: + case CTokenType_Float: + case CTokenType_Char: + case CTokenType_Int: + case CTokenType_Short: + case CTokenType_Inline: + case CTokenType_TemplateKeyword: + case CTokenType_OperatorKeyword: + case CT_Keyword_Public: + case CT_Keyword_Private: + case CT_Keyword_Protected: + case CT_KeywordPragma: + case CT_KeywordAttribute: + case CT_StaticAssert: + case CTokenType_Extern: + case CTokenType_Asm: + case CTokenType_Goto: + case CTokenType_Ellipsis: + case CTokenType_If: + case CTokenType_Else: + case CTokenType_Break: + case CTokenType_Switch: + case CTokenType_Case: + case CT_Keyword_Delete: + case CTokenType_Default: + case CTokenType_For: + case CTokenType_While: + case CTokenType_Continue: + case CTokenType_Return: + case CTokenType_LeftShift: + case CTokenType_RightShift: + case CTokenType_LessEqual: + case CTokenType_GreaterEqual: + case CTokenType_AreEqual: + case CTokenType_NotEqual: + case CTokenType_PlusEquals: + case CTokenType_MinusEquals: + case CTokenType_TimesEquals: + case CTokenType_DivEquals: + case CTokenType_ModEquals: + case CTokenType_AndEquals: + case CTokenType_OrEquals: + case CTokenType_XorEquals: + case CTokenType_Increment: + case CTokenType_Decrement: + case CTokenType_LogicalAnd: + case CTokenType_LogicalOr: + case CTokenType_Arrow: + case CT_ScopeResolutionOperator: + case CT_NameQualifier: + case CT_MacroLiteral: + case CT_MacroLiteral_SelfRefExpansion: + case CT_PreprocessorHasInclude: + case CT_PreprocessorHasIncludeNext: + case CT_PreprocessorPaste: + case CT_PreprocessorPaste_InvalidToken: + case CT_PreprocessorInclude: + case CT_PreprocessorIncludeNext: + case CT_PreprocessorIf: + case CT_PreprocessorElse: + case CT_PreprocessorElif: + case CT_PreprocessorEndif: + case CT_PreprocessorIfDefined: + case CT_PreprocessorIfNotDefined: + case CT_PreprocessorDefine: + case CT_PreprocessorUndef: + case CT_PreprocessorPragma: + case CT_PreprocessorError: + case CT_PreprocessorWarning: + case CT_Preprocessor_VA_ARGS_: + case CT_Preprocessor_Nuked: + case CT_InsertedCode: + case CT_PoofInsertedCode: + case CT_PoofModifiedToken: + + { + Result = True; + } + } + return Result; +} + + link_internal counted_string ToStringPrefixless(c_token_type Type) { + Assert(IsValid(Type)); counted_string Result = {}; + switch (Type) { - case CTokenType_Unknown: { Result = CSz("Unknown"); } break; + case CTokenType_Unknown: { Result = CSz("Unknown"); } break; case CT_ControlChar_Start_of_Heading: { Result = CSz("Heading"); } break; case CT_ControlChar_Start_of_Text: { Result = CSz("Text"); } break; case CT_ControlChar_End_of_Text: { Result = CSz("Text"); } break; @@ -180,19 +370,22 @@ ToStringPrefixless(c_token_type Type) case CT_PoofInsertedCode: { Result = CSz("PoofInsertedCode"); } break; case CT_PoofModifiedToken: { Result = CSz("PoofModifiedToken"); } break; + } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } link_internal counted_string ToString(c_token_type Type) { + Assert(IsValid(Type)); + counted_string Result = {}; switch (Type) { - case CTokenType_Unknown: { Result = CSz("CTokenType_Unknown"); } break; + case CTokenType_Unknown: { Result = CSz("CTokenType_Unknown"); } break; case CT_ControlChar_Start_of_Heading: { Result = CSz("CT_ControlChar_Start_of_Heading"); } break; case CT_ControlChar_Start_of_Text: { Result = CSz("CT_ControlChar_Start_of_Text"); } break; case CT_ControlChar_End_of_Text: { Result = CSz("CT_ControlChar_End_of_Text"); } break; @@ -366,9 +559,10 @@ ToString(c_token_type Type) case CT_PoofInsertedCode: { Result = CSz("CT_PoofInsertedCode"); } break; case CT_PoofModifiedToken: { Result = CSz("CT_PoofModifiedToken"); } break; + } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } diff --git a/generated/generate_string_table_entity_behavior_flags.h b/generated/generate_string_table_entity_behavior_flags.h index 8bffafeae..d2572af2c 100644 --- a/generated/generate_string_table_entity_behavior_flags.h +++ b/generated/generate_string_table_entity_behavior_flags.h @@ -1,12 +1,38 @@ -// src/engine/entity.h:39:0 +// external/bonsai_stdlib/src/poof_functions.h:1744:0 +link_internal b32 +IsValid(entity_behavior_flags Value) +{ + b32 Result = False; + switch (Value) + { + case EntityBehaviorFlags_None: + case EntityBehaviorFlags_Gravity: + case EntityBehaviorFlags_WorldCollision: + case EntityBehaviorFlags_EntityCollision: + case EntityBehaviorFlags_UnspawnOnParticleSystemTerminate: + case EntityBehaviorFlags_FitCollisionVolumeToModel: + case EntityBehaviorFlags_DefatulCameraGhostBehavior: + case EntityBehaviorFlags_WorldCenter: + case EntityBehaviorFlags_Default: + + { + Result = True; + } + } + return Result; +} + + link_internal counted_string ToStringPrefixless(entity_behavior_flags Type) { + Assert(IsValid(Type)); counted_string Result = {}; + switch (Type) { - case EntityBehaviorFlags_None: { Result = CSz("None"); } break; + case EntityBehaviorFlags_None: { Result = CSz("None"); } break; case EntityBehaviorFlags_Gravity: { Result = CSz("Gravity"); } break; case EntityBehaviorFlags_WorldCollision: { Result = CSz("WorldCollision"); } break; case EntityBehaviorFlags_EntityCollision: { Result = CSz("EntityCollision"); } break; @@ -16,42 +42,51 @@ ToStringPrefixless(entity_behavior_flags Type) case EntityBehaviorFlags_WorldCenter: { Result = CSz("WorldCenter"); } break; case EntityBehaviorFlags_Default: { Result = CSz("Default"); } break; - // TODO(Jesse): This is pretty barf and we could do it in a single allocation, + + // TODO(Jesse): This is pretty barf and we could do it in a single allocation, // but the metaprogram might have to be a bit fancier.. default: { u32 CurrentFlags = u32(Type); - if (CountBitsSet_Kernighan(CurrentFlags) == 1) - { - Result = FSz("(invalid value for entity_behavior_flags (%d))", CurrentFlags); - } - else + u32 BitsSet = CountBitsSet_Kernighan(CurrentFlags); + switch(BitsSet) { - u32 FirstValue = UnsetLeastSignificantSetBit(&CurrentFlags); - Result = ToStringPrefixless(entity_behavior_flags(FirstValue)); + case 0: // We likely passed 0 into this function, and the enum didn't have a 0 value + case 1: // The value we passed in was outside the range of the valid enum values + { + Result = FSz("(invalid value (%d))", CurrentFlags); + } break; - while (CurrentFlags) + default: { - u32 Value = UnsetLeastSignificantSetBit(&CurrentFlags); - cs Next = ToStringPrefixless(entity_behavior_flags(Value)); - Result = FSz("%S | %S", Result, Next); - } + u32 FirstValue = UnsetLeastSignificantSetBit(&CurrentFlags); + Result = ToStringPrefixless(entity_behavior_flags(FirstValue)); + + while (CurrentFlags) + { + u32 Value = UnsetLeastSignificantSetBit(&CurrentFlags); + cs Next = ToStringPrefixless(entity_behavior_flags(Value)); + Result = FSz("%S | %S", Result, Next); + } + } break; } } break; } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } link_internal counted_string ToString(entity_behavior_flags Type) { + Assert(IsValid(Type)); + counted_string Result = {}; switch (Type) { - case EntityBehaviorFlags_None: { Result = CSz("EntityBehaviorFlags_None"); } break; + case EntityBehaviorFlags_None: { Result = CSz("EntityBehaviorFlags_None"); } break; case EntityBehaviorFlags_Gravity: { Result = CSz("EntityBehaviorFlags_Gravity"); } break; case EntityBehaviorFlags_WorldCollision: { Result = CSz("EntityBehaviorFlags_WorldCollision"); } break; case EntityBehaviorFlags_EntityCollision: { Result = CSz("EntityBehaviorFlags_EntityCollision"); } break; @@ -61,7 +96,8 @@ ToString(entity_behavior_flags Type) case EntityBehaviorFlags_WorldCenter: { Result = CSz("EntityBehaviorFlags_WorldCenter"); } break; case EntityBehaviorFlags_Default: { Result = CSz("EntityBehaviorFlags_Default"); } break; - // TODO(Jesse): This is pretty barf and we could do it in a single allocation, + + // TODO(Jesse): This is pretty barf and we could do it in a single allocation, // but the metaprogram might have to be a bit fancier.. default: { @@ -79,7 +115,7 @@ ToString(entity_behavior_flags Type) } break; } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } diff --git a/generated/generate_string_table_entity_state.h b/generated/generate_string_table_entity_state.h index a247a0fcd..bbbcfad02 100644 --- a/generated/generate_string_table_entity_state.h +++ b/generated/generate_string_table_entity_state.h @@ -1,36 +1,61 @@ -// src/engine/entity.h:36:0 +// external/bonsai_stdlib/src/poof_functions.h:1744:0 +link_internal b32 +IsValid(entity_state Value) +{ + b32 Result = False; + switch (Value) + { + case EntityState_Free: + case EntityState_Spawned: + case EntityState_Destroyed: + case EntityState_Reserved: + + { + Result = True; + } + } + return Result; +} + + link_internal counted_string ToStringPrefixless(entity_state Type) { + Assert(IsValid(Type)); counted_string Result = {}; + switch (Type) { - case EntityState_Free: { Result = CSz("Free"); } break; + case EntityState_Free: { Result = CSz("Free"); } break; case EntityState_Spawned: { Result = CSz("Spawned"); } break; case EntityState_Destroyed: { Result = CSz("Destroyed"); } break; case EntityState_Reserved: { Result = CSz("Reserved"); } break; + } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } link_internal counted_string ToString(entity_state Type) { + Assert(IsValid(Type)); + counted_string Result = {}; switch (Type) { - case EntityState_Free: { Result = CSz("EntityState_Free"); } break; + case EntityState_Free: { Result = CSz("EntityState_Free"); } break; case EntityState_Spawned: { Result = CSz("EntityState_Spawned"); } break; case EntityState_Destroyed: { Result = CSz("EntityState_Destroyed"); } break; case EntityState_Reserved: { Result = CSz("EntityState_Reserved"); } break; + } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } diff --git a/generated/generate_string_table_entity_status.h b/generated/generate_string_table_entity_status.h index 3db1c6fad..356082588 100644 --- a/generated/generate_string_table_entity_status.h +++ b/generated/generate_string_table_entity_status.h @@ -1,34 +1,58 @@ -// examples/turn_based/game_types.h:75:0 +// external/bonsai_stdlib/src/poof_functions.h:1744:0 +link_internal b32 +IsValid(entity_status Value) +{ + b32 Result = False; + switch (Value) + { + case EntityStatus_None: + case EntityStatus_Carried: + case EntityStatus_Thrown: + + { + Result = True; + } + } + return Result; +} + + link_internal counted_string ToStringPrefixless(entity_status Type) { + Assert(IsValid(Type)); counted_string Result = {}; + switch (Type) { - case EntityStatus_None: { Result = CSz("None"); } break; + case EntityStatus_None: { Result = CSz("None"); } break; case EntityStatus_Carried: { Result = CSz("Carried"); } break; case EntityStatus_Thrown: { Result = CSz("Thrown"); } break; + } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } link_internal counted_string ToString(entity_status Type) { + Assert(IsValid(Type)); + counted_string Result = {}; switch (Type) { - case EntityStatus_None: { Result = CSz("EntityStatus_None"); } break; + case EntityStatus_None: { Result = CSz("EntityStatus_None"); } break; case EntityStatus_Carried: { Result = CSz("EntityStatus_Carried"); } break; case EntityStatus_Thrown: { Result = CSz("EntityStatus_Thrown"); } break; + } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } diff --git a/generated/generate_string_table_entity_type.h b/generated/generate_string_table_entity_type.h index 907deeeea..145856600 100644 --- a/generated/generate_string_table_entity_type.h +++ b/generated/generate_string_table_entity_type.h @@ -1,40 +1,67 @@ -// examples/turn_based/game_types.h:72:0 +// external/bonsai_stdlib/src/poof_functions.h:1744:0 +link_internal b32 +IsValid(entity_type Value) +{ + b32 Result = False; + switch (Value) + { + case EntityType_Default: + case EntityType_Enemy: + case EntityType_Player: + case EntityType_Fireball: + case EntityType_Loot: + case EntityType_ItemSpawn: + + { + Result = True; + } + } + return Result; +} + + link_internal counted_string ToStringPrefixless(entity_type Type) { + Assert(IsValid(Type)); counted_string Result = {}; + switch (Type) { - case EntityType_Default: { Result = CSz("Default"); } break; + case EntityType_Default: { Result = CSz("Default"); } break; case EntityType_Enemy: { Result = CSz("Enemy"); } break; case EntityType_Player: { Result = CSz("Player"); } break; case EntityType_Fireball: { Result = CSz("Fireball"); } break; case EntityType_Loot: { Result = CSz("Loot"); } break; case EntityType_ItemSpawn: { Result = CSz("ItemSpawn"); } break; + } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } link_internal counted_string ToString(entity_type Type) { + Assert(IsValid(Type)); + counted_string Result = {}; switch (Type) { - case EntityType_Default: { Result = CSz("EntityType_Default"); } break; + case EntityType_Default: { Result = CSz("EntityType_Default"); } break; case EntityType_Enemy: { Result = CSz("EntityType_Enemy"); } break; case EntityType_Player: { Result = CSz("EntityType_Player"); } break; case EntityType_Fireball: { Result = CSz("EntityType_Fireball"); } break; case EntityType_Loot: { Result = CSz("EntityType_Loot"); } break; case EntityType_ItemSpawn: { Result = CSz("EntityType_ItemSpawn"); } break; + } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } diff --git a/generated/generate_string_table_parse_error_code.h b/generated/generate_string_table_parse_error_code.h index df0f3e225..6cb855982 100644 --- a/generated/generate_string_table_parse_error_code.h +++ b/generated/generate_string_table_parse_error_code.h @@ -1,12 +1,55 @@ -// external/bonsai_stdlib/src/c_parser.h:61:0 +// external/bonsai_stdlib/src/poof_functions.h:1744:0 +link_internal b32 +IsValid(parse_error_code Value) +{ + b32 Result = False; + switch (Value) + { + case ParseErrorCode_None: + case ParseErrorCode_ExpectedSemicolonOrEquals: + case ParseErrorCode_StreamEndedUnexpectedly: + case ParseErrorCode_RequireTokenFailed: + case ParseErrorCode_InvalidTokenGenerated: + case ParseErrorCode_MalformedType: + case ParseErrorCode_PoofUserlandError: + case ParseErrorCode_PoofTypeError: + case ParseErrorCode_DUnionParse: + case ParseErrorCode_UndefinedDatatype: + case ParseErrorCode_InvalidKeyword: + case ParseErrorCode_InvalidDirective: + case ParseErrorCode_InvalidOperator: + case ParseErrorCode_InvalidMetaTransformOp: + case ParseErrorCode_InvalidArgument: + case ParseErrorCode_InvalidArgumentType: + case ParseErrorCode_InvalidArgumentCount: + case ParseErrorCode_InvalidName: + case ParseErrorCode_InvalidTag: + case ParseErrorCode_InvalidFunction: + case ParseErrorCode_SyntaxError: + case ParseErrorCode_NotImplemented: + case ParseErrorCode_InputStreamNull: + case ParseErrorCode_InternalCompilerError: + case ParseErrorCode_StackOverflow: + case ParseErrorCode_Unknown: + + { + Result = True; + } + } + return Result; +} + + link_internal counted_string ToStringPrefixless(parse_error_code Type) { + Assert(IsValid(Type)); counted_string Result = {}; + switch (Type) { - case ParseErrorCode_None: { Result = CSz("None"); } break; + case ParseErrorCode_None: { Result = CSz("None"); } break; case ParseErrorCode_ExpectedSemicolonOrEquals: { Result = CSz("ExpectedSemicolonOrEquals"); } break; case ParseErrorCode_StreamEndedUnexpectedly: { Result = CSz("StreamEndedUnexpectedly"); } break; case ParseErrorCode_RequireTokenFailed: { Result = CSz("RequireTokenFailed"); } break; @@ -16,6 +59,7 @@ ToStringPrefixless(parse_error_code Type) case ParseErrorCode_PoofTypeError: { Result = CSz("PoofTypeError"); } break; case ParseErrorCode_DUnionParse: { Result = CSz("DUnionParse"); } break; case ParseErrorCode_UndefinedDatatype: { Result = CSz("UndefinedDatatype"); } break; + case ParseErrorCode_InvalidKeyword: { Result = CSz("InvalidKeyword"); } break; case ParseErrorCode_InvalidDirective: { Result = CSz("InvalidDirective"); } break; case ParseErrorCode_InvalidOperator: { Result = CSz("InvalidOperator"); } break; case ParseErrorCode_InvalidMetaTransformOp: { Result = CSz("InvalidMetaTransformOp"); } break; @@ -32,19 +76,22 @@ ToStringPrefixless(parse_error_code Type) case ParseErrorCode_StackOverflow: { Result = CSz("StackOverflow"); } break; case ParseErrorCode_Unknown: { Result = CSz("Unknown"); } break; + } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } link_internal counted_string ToString(parse_error_code Type) { + Assert(IsValid(Type)); + counted_string Result = {}; switch (Type) { - case ParseErrorCode_None: { Result = CSz("ParseErrorCode_None"); } break; + case ParseErrorCode_None: { Result = CSz("ParseErrorCode_None"); } break; case ParseErrorCode_ExpectedSemicolonOrEquals: { Result = CSz("ParseErrorCode_ExpectedSemicolonOrEquals"); } break; case ParseErrorCode_StreamEndedUnexpectedly: { Result = CSz("ParseErrorCode_StreamEndedUnexpectedly"); } break; case ParseErrorCode_RequireTokenFailed: { Result = CSz("ParseErrorCode_RequireTokenFailed"); } break; @@ -54,6 +101,7 @@ ToString(parse_error_code Type) case ParseErrorCode_PoofTypeError: { Result = CSz("ParseErrorCode_PoofTypeError"); } break; case ParseErrorCode_DUnionParse: { Result = CSz("ParseErrorCode_DUnionParse"); } break; case ParseErrorCode_UndefinedDatatype: { Result = CSz("ParseErrorCode_UndefinedDatatype"); } break; + case ParseErrorCode_InvalidKeyword: { Result = CSz("ParseErrorCode_InvalidKeyword"); } break; case ParseErrorCode_InvalidDirective: { Result = CSz("ParseErrorCode_InvalidDirective"); } break; case ParseErrorCode_InvalidOperator: { Result = CSz("ParseErrorCode_InvalidOperator"); } break; case ParseErrorCode_InvalidMetaTransformOp: { Result = CSz("ParseErrorCode_InvalidMetaTransformOp"); } break; @@ -70,9 +118,10 @@ ToString(parse_error_code Type) case ParseErrorCode_StackOverflow: { Result = CSz("ParseErrorCode_StackOverflow"); } break; case ParseErrorCode_Unknown: { Result = CSz("ParseErrorCode_Unknown"); } break; + } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } diff --git a/generated/generate_string_table_player_action.h b/generated/generate_string_table_player_action.h index e52da2ef3..c31e81359 100644 --- a/generated/generate_string_table_player_action.h +++ b/generated/generate_string_table_player_action.h @@ -1,12 +1,37 @@ -// examples/turn_based/game_types.h:141:0 +// external/bonsai_stdlib/src/poof_functions.h:1744:0 +link_internal b32 +IsValid(player_action Value) +{ + b32 Result = False; + switch (Value) + { + case PlayerAction_None: + case PlayerAction_Move: + case PlayerAction_Shovel: + case PlayerAction_Grab: + case PlayerAction_ChargeFireball: + case PlayerAction_IceBlock: + case PlayerAction_Throw: + case PlayerAction_Count: + + { + Result = True; + } + } + return Result; +} + + link_internal counted_string ToStringPrefixless(player_action Type) { + Assert(IsValid(Type)); counted_string Result = {}; + switch (Type) { - case PlayerAction_None: { Result = CSz("None"); } break; + case PlayerAction_None: { Result = CSz("None"); } break; case PlayerAction_Move: { Result = CSz("Move"); } break; case PlayerAction_Shovel: { Result = CSz("Shovel"); } break; case PlayerAction_Grab: { Result = CSz("Grab"); } break; @@ -15,19 +40,22 @@ ToStringPrefixless(player_action Type) case PlayerAction_Throw: { Result = CSz("Throw"); } break; case PlayerAction_Count: { Result = CSz("Count"); } break; + } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } link_internal counted_string ToString(player_action Type) { + Assert(IsValid(Type)); + counted_string Result = {}; switch (Type) { - case PlayerAction_None: { Result = CSz("PlayerAction_None"); } break; + case PlayerAction_None: { Result = CSz("PlayerAction_None"); } break; case PlayerAction_Move: { Result = CSz("PlayerAction_Move"); } break; case PlayerAction_Shovel: { Result = CSz("PlayerAction_Shovel"); } break; case PlayerAction_Grab: { Result = CSz("PlayerAction_Grab"); } break; @@ -36,9 +64,10 @@ ToString(player_action Type) case PlayerAction_Throw: { Result = CSz("PlayerAction_Throw"); } break; case PlayerAction_Count: { Result = CSz("PlayerAction_Count"); } break; + } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } diff --git a/generated/generate_string_table_text_encoding.h b/generated/generate_string_table_text_encoding.h index 82001217b..219aec7d0 100644 --- a/generated/generate_string_table_text_encoding.h +++ b/generated/generate_string_table_text_encoding.h @@ -1,12 +1,41 @@ -// external/bonsai_stdlib/src/ansi_stream.h:32:0 +// external/bonsai_stdlib/src/poof_functions.h:1744:0 +link_internal b32 +IsValid(text_encoding Value) +{ + b32 Result = False; + switch (Value) + { + case TextEncoding_ASCII: + case TextEncoding_UTF8: + case TextEncoding_UTF16LE: + case TextEncoding_UTF16BE: + case TextEncoding_UTF32LE: + case TextEncoding_UTF32BE: + case TextEncoding_UTF7: + case TextEncoding_UTF1: + case TextEncoding_EBCDIC: + case TextEncoding_CSCU: + case TextEncoding_BOCU: + case TextEncoding_GB18030: + + { + Result = True; + } + } + return Result; +} + + link_internal counted_string ToStringPrefixless(text_encoding Type) { + Assert(IsValid(Type)); counted_string Result = {}; + switch (Type) { - case TextEncoding_ASCII: { Result = CSz("ASCII"); } break; + case TextEncoding_ASCII: { Result = CSz("ASCII"); } break; case TextEncoding_UTF8: { Result = CSz("UTF8"); } break; case TextEncoding_UTF16LE: { Result = CSz("UTF16LE"); } break; case TextEncoding_UTF16BE: { Result = CSz("UTF16BE"); } break; @@ -19,19 +48,22 @@ ToStringPrefixless(text_encoding Type) case TextEncoding_BOCU: { Result = CSz("BOCU"); } break; case TextEncoding_GB18030: { Result = CSz("GB18030"); } break; + } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } link_internal counted_string ToString(text_encoding Type) { + Assert(IsValid(Type)); + counted_string Result = {}; switch (Type) { - case TextEncoding_ASCII: { Result = CSz("TextEncoding_ASCII"); } break; + case TextEncoding_ASCII: { Result = CSz("TextEncoding_ASCII"); } break; case TextEncoding_UTF8: { Result = CSz("TextEncoding_UTF8"); } break; case TextEncoding_UTF16LE: { Result = CSz("TextEncoding_UTF16LE"); } break; case TextEncoding_UTF16BE: { Result = CSz("TextEncoding_UTF16BE"); } break; @@ -44,9 +76,10 @@ ToString(text_encoding Type) case TextEncoding_BOCU: { Result = CSz("TextEncoding_BOCU"); } break; case TextEncoding_GB18030: { Result = CSz("TextEncoding_GB18030"); } break; + } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } diff --git a/generated/generate_string_table_token_cursor_source.h b/generated/generate_string_table_token_cursor_source.h index 32a3969ac..505439e4d 100644 --- a/generated/generate_string_table_token_cursor_source.h +++ b/generated/generate_string_table_token_cursor_source.h @@ -1,12 +1,40 @@ -// external/bonsai_stdlib/src/c_token.h:256:0 +// external/bonsai_stdlib/src/poof_functions.h:1744:0 +link_internal b32 +IsValid(token_cursor_source Value) +{ + b32 Result = False; + switch (Value) + { + case TokenCursorSource_Unknown: + case TokenCursorSource_RootFile: + case TokenCursorSource_Include: + case TokenCursorSource_MacroExpansion: + case TokenCursorSource_MetaprogrammingExpansion: + case TokenCursorSource_PoofSymbolIteration: + case TokenCursorSource_PasteOperator: + case TokenCursorSource_CommandLineOption: + case TokenCursorSource_BodyText: + case TokenCursorSource_IntermediateRepresentaton: + case TokenCursorSource_Count: + + { + Result = True; + } + } + return Result; +} + + link_internal counted_string ToStringPrefixless(token_cursor_source Type) { + Assert(IsValid(Type)); counted_string Result = {}; + switch (Type) { - case TokenCursorSource_Unknown: { Result = CSz("Unknown"); } break; + case TokenCursorSource_Unknown: { Result = CSz("Unknown"); } break; case TokenCursorSource_RootFile: { Result = CSz("RootFile"); } break; case TokenCursorSource_Include: { Result = CSz("Include"); } break; case TokenCursorSource_MacroExpansion: { Result = CSz("MacroExpansion"); } break; @@ -18,19 +46,22 @@ ToStringPrefixless(token_cursor_source Type) case TokenCursorSource_IntermediateRepresentaton: { Result = CSz("IntermediateRepresentaton"); } break; case TokenCursorSource_Count: { Result = CSz("Count"); } break; + } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } link_internal counted_string ToString(token_cursor_source Type) { + Assert(IsValid(Type)); + counted_string Result = {}; switch (Type) { - case TokenCursorSource_Unknown: { Result = CSz("TokenCursorSource_Unknown"); } break; + case TokenCursorSource_Unknown: { Result = CSz("TokenCursorSource_Unknown"); } break; case TokenCursorSource_RootFile: { Result = CSz("TokenCursorSource_RootFile"); } break; case TokenCursorSource_Include: { Result = CSz("TokenCursorSource_Include"); } break; case TokenCursorSource_MacroExpansion: { Result = CSz("TokenCursorSource_MacroExpansion"); } break; @@ -42,9 +73,10 @@ ToString(token_cursor_source Type) case TokenCursorSource_IntermediateRepresentaton: { Result = CSz("TokenCursorSource_IntermediateRepresentaton"); } break; case TokenCursorSource_Count: { Result = CSz("TokenCursorSource_Count"); } break; + } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } diff --git a/generated/generate_string_table_turn_mode.h b/generated/generate_string_table_turn_mode.h index b36ae3122..65541158c 100644 --- a/generated/generate_string_table_turn_mode.h +++ b/generated/generate_string_table_turn_mode.h @@ -1,32 +1,55 @@ -// examples/turn_based/game_types.h:151:0 +// external/bonsai_stdlib/src/poof_functions.h:1744:0 +link_internal b32 +IsValid(turn_mode Value) +{ + b32 Result = False; + switch (Value) + { + case TurnMode_Default: + case TurnMode_Transition: + + { + Result = True; + } + } + return Result; +} + + link_internal counted_string ToStringPrefixless(turn_mode Type) { + Assert(IsValid(Type)); counted_string Result = {}; + switch (Type) { - case TurnMode_Default: { Result = CSz("Default"); } break; + case TurnMode_Default: { Result = CSz("Default"); } break; case TurnMode_Transition: { Result = CSz("Transition"); } break; + } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } link_internal counted_string ToString(turn_mode Type) { + Assert(IsValid(Type)); + counted_string Result = {}; switch (Type) { - case TurnMode_Default: { Result = CSz("TurnMode_Default"); } break; + case TurnMode_Default: { Result = CSz("TurnMode_Default"); } break; case TurnMode_Transition: { Result = CSz("TurnMode_Transition"); } break; + } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } diff --git a/generated/generate_string_table_world_chunk_mesh_bitfield.h b/generated/generate_string_table_world_chunk_mesh_bitfield.h index e40848c71..412172997 100644 --- a/generated/generate_string_table_world_chunk_mesh_bitfield.h +++ b/generated/generate_string_table_world_chunk_mesh_bitfield.h @@ -1,12 +1,36 @@ -// src/engine/world_chunk.h:237:0 +// external/bonsai_stdlib/src/poof_functions.h:1744:0 +link_internal b32 +IsValid(world_chunk_mesh_bitfield Value) +{ + b32 Result = False; + switch (Value) + { + case MeshBit_None: + case MeshBit_Lod0: + case MeshBit_Lod1: + case MeshBit_Lod2: + case MeshBit_Lod3: + case MeshBit_Lod4: + case MeshBit_Count: + + { + Result = True; + } + } + return Result; +} + + link_internal counted_string ToStringPrefixless(world_chunk_mesh_bitfield Type) { + Assert(IsValid(Type)); counted_string Result = {}; + switch (Type) { - case MeshBit_None: { Result = CSz("None"); } break; + case MeshBit_None: { Result = CSz("None"); } break; case MeshBit_Lod0: { Result = CSz("Lod0"); } break; case MeshBit_Lod1: { Result = CSz("Lod1"); } break; case MeshBit_Lod2: { Result = CSz("Lod2"); } break; @@ -14,19 +38,22 @@ ToStringPrefixless(world_chunk_mesh_bitfield Type) case MeshBit_Lod4: { Result = CSz("Lod4"); } break; case MeshBit_Count: { Result = CSz("Count"); } break; + } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } link_internal counted_string ToString(world_chunk_mesh_bitfield Type) { + Assert(IsValid(Type)); + counted_string Result = {}; switch (Type) { - case MeshBit_None: { Result = CSz("MeshBit_None"); } break; + case MeshBit_None: { Result = CSz("MeshBit_None"); } break; case MeshBit_Lod0: { Result = CSz("MeshBit_Lod0"); } break; case MeshBit_Lod1: { Result = CSz("MeshBit_Lod1"); } break; case MeshBit_Lod2: { Result = CSz("MeshBit_Lod2"); } break; @@ -34,9 +61,10 @@ ToString(world_chunk_mesh_bitfield Type) case MeshBit_Lod4: { Result = CSz("MeshBit_Lod4"); } break; case MeshBit_Count: { Result = CSz("MeshBit_Count"); } break; + } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } diff --git a/generated/generate_string_table_world_chunk_mesh_index.h b/generated/generate_string_table_world_chunk_mesh_index.h index 3045b2d8d..4a4e7f551 100644 --- a/generated/generate_string_table_world_chunk_mesh_index.h +++ b/generated/generate_string_table_world_chunk_mesh_index.h @@ -1,40 +1,67 @@ -// src/engine/world_chunk.h:240:0 +// external/bonsai_stdlib/src/poof_functions.h:1744:0 +link_internal b32 +IsValid(world_chunk_mesh_index Value) +{ + b32 Result = False; + switch (Value) + { + case MeshIndex_Lod0: + case MeshIndex_Lod1: + case MeshIndex_Lod2: + case MeshIndex_Lod3: + case MeshIndex_Lod4: + case MeshIndex_Count: + + { + Result = True; + } + } + return Result; +} + + link_internal counted_string ToStringPrefixless(world_chunk_mesh_index Type) { + Assert(IsValid(Type)); counted_string Result = {}; + switch (Type) { - case MeshIndex_Lod0: { Result = CSz("Lod0"); } break; + case MeshIndex_Lod0: { Result = CSz("Lod0"); } break; case MeshIndex_Lod1: { Result = CSz("Lod1"); } break; case MeshIndex_Lod2: { Result = CSz("Lod2"); } break; case MeshIndex_Lod3: { Result = CSz("Lod3"); } break; case MeshIndex_Lod4: { Result = CSz("Lod4"); } break; case MeshIndex_Count: { Result = CSz("Count"); } break; + } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } link_internal counted_string ToString(world_chunk_mesh_index Type) { + Assert(IsValid(Type)); + counted_string Result = {}; switch (Type) { - case MeshIndex_Lod0: { Result = CSz("MeshIndex_Lod0"); } break; + case MeshIndex_Lod0: { Result = CSz("MeshIndex_Lod0"); } break; case MeshIndex_Lod1: { Result = CSz("MeshIndex_Lod1"); } break; case MeshIndex_Lod2: { Result = CSz("MeshIndex_Lod2"); } break; case MeshIndex_Lod3: { Result = CSz("MeshIndex_Lod3"); } break; case MeshIndex_Lod4: { Result = CSz("MeshIndex_Lod4"); } break; case MeshIndex_Count: { Result = CSz("MeshIndex_Count"); } break; + } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } 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 deleted file mode 100644 index 149231e39..000000000 --- a/generated/gpu_buffer_lod_element_buffer_untextured_3d_geometry_buffer.h +++ /dev/null @@ -1,93 +0,0 @@ -// src/engine/render.cpp:1040:0 - - -link_internal void -CopyBufferIntoBuffer( untextured_3d_geometry_buffer *Src, untextured_3d_geometry_buffer *Dest) -{ - BufferVertsChecked(Src, Dest, {}, V3(1.0f)); -} - -link_internal void -CopyToGpuBuffer( untextured_3d_geometry_buffer *Mesh, gpu_mapped_untextured_3d_geometry_buffer *GpuBuffer) -{ - gpu_mapped_untextured_3d_geometry_buffer Dest = MapGpuBuffer_untextured_3d_geometry_buffer(&GpuBuffer->Handles); - CopyBufferIntoBuffer(Mesh, &Dest.Buffer); - FlushBuffersToCard(&Dest); -} - -link_internal void -CopyToGpuBuffer( untextured_3d_geometry_buffer *Mesh, gpu_element_buffer_handles *Handles) -{ - gpu_mapped_untextured_3d_geometry_buffer Dest = MapGpuBuffer_untextured_3d_geometry_buffer(Handles); - CopyBufferIntoBuffer(Mesh, &Dest.Buffer); - FlushBuffersToCard(&Dest); -} - -link_internal b32 -SyncGpuBuffersAsync(engine_resources *Engine, 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]; - - untextured_3d_geometry_buffer *Mesh = AtomicReplaceMesh( Meshes, MeshBit, 0, u64_MAX ); - if (Mesh && Mesh->At) - { - PushReallocateBuffersCommand(&Engine->Stdlib.Plat.RenderQ, Handles, Mesh); - Result = True; - } - } - } - - // TODO(Jesse): Is this actually a thing?? - FullBarrier; - - return Result; -} - -link_internal b32 -SyncGpuBuffersImmediate(engine_resources *Engine, 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]; - - untextured_3d_geometry_buffer *Mesh = AtomicReplaceMesh( Meshes, MeshBit, 0, u64_MAX ); - if (Mesh) - { - if (Mesh->At) - { - ReallocateAndSyncGpuBuffers(Handles, Mesh); - 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_bonsai_type_info.h b/generated/hashtable_bonsai_type_info.h index ddb374649..9d65fb770 100644 --- a/generated/hashtable_bonsai_type_info.h +++ b/generated/hashtable_bonsai_type_info.h @@ -1,5 +1,4 @@ -// src/engine/bonsai_type_info.h:37:0 - +// external/bonsai_stdlib/src/poof_functions.h:777:0 struct bonsai_type_info_linked_list_node { b32 Tombstoned; @@ -14,6 +13,7 @@ struct bonsai_type_info_hashtable /* OWNED_BY_THREAD_MEMBER() */ }; link_internal b32 AreEqual(bonsai_type_info_linked_list_node *Node1, bonsai_type_info_linked_list_node *Node2 ); +link_internal b32 AreEqual(bonsai_type_info *Element1, bonsai_type_info *Element2 ); link_internal bonsai_type_info_linked_list_node * Allocate_bonsai_type_info_linked_list_node(memory_arena *Memory) @@ -76,7 +76,7 @@ Insert(bonsai_type_info_linked_list_node *Node, bonsai_type_info_hashtable *Tabl bonsai_type_info_linked_list_node **Bucket = Table->Elements + HashValue; while (*Bucket) { - /* Assert(!AreEqual(*Bucket, Node)); */ + /* Assert(!AreEqual(&Bucket[0]->Element, &Node->Element)); */ Bucket = &(*Bucket)->Next; } *Bucket = Node; @@ -178,4 +178,11 @@ GetPtr(bonsai_type_info_hashtable *Hashtable, bonsai_type_info_hashtable_iterato } return Result; } + +link_inline bonsai_type_info * +TryGetPtr(bonsai_type_info_hashtable *Hashtable, bonsai_type_info_hashtable_iterator Iterator) +{ + return GetPtr(Hashtable, Iterator); +} + diff --git a/generated/hashtable_counted_string.h b/generated/hashtable_counted_string.h index 9b98489ea..38422bace 100644 --- a/generated/hashtable_counted_string.h +++ b/generated/hashtable_counted_string.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/counted_string.cpp:26:0 - +// external/bonsai_stdlib/src/poof_functions.h:777:0 struct counted_string_linked_list_node { b32 Tombstoned; @@ -14,6 +13,7 @@ struct counted_string_hashtable /* OWNED_BY_THREAD_MEMBER() */ }; link_internal b32 AreEqual(counted_string_linked_list_node *Node1, counted_string_linked_list_node *Node2 ); +link_internal b32 AreEqual(counted_string *Element1, counted_string *Element2 ); link_internal counted_string_linked_list_node * Allocate_counted_string_linked_list_node(memory_arena *Memory) @@ -76,7 +76,7 @@ Insert(counted_string_linked_list_node *Node, counted_string_hashtable *Table) counted_string_linked_list_node **Bucket = Table->Elements + HashValue; while (*Bucket) { - /* Assert(!AreEqual(*Bucket, Node)); */ + /* Assert(!AreEqual(&Bucket[0]->Element, &Node->Element)); */ Bucket = &(*Bucket)->Next; } *Bucket = Node; @@ -178,4 +178,11 @@ GetPtr(counted_string_hashtable *Hashtable, counted_string_hashtable_iterator It } return Result; } + +link_inline counted_string * +TryGetPtr(counted_string_hashtable *Hashtable, counted_string_hashtable_iterator Iterator) +{ + return GetPtr(Hashtable, Iterator); +} + diff --git a/generated/hashtable_get_bonsai_type_info_902_689333910.h b/generated/hashtable_get_bonsai_type_info_902_689333910.h index 2eb72319c..dbdc19f97 100644 --- a/generated/hashtable_get_bonsai_type_info_902_689333910.h +++ b/generated/hashtable_get_bonsai_type_info_902_689333910.h @@ -1,18 +1,18 @@ -// src/engine/bonsai_type_info.h:46:0 - +// external/bonsai_stdlib/src/poof_functions.h:978:0 bonsai_type_info_linked_list_node* -GetBucketByName( bonsai_type_info_hashtable *Table, cs Name ) +GetBucketByName( bonsai_type_info_hashtable *Table, cs Query ) { /* ENSURE_OWNED_BY_THREAD(Table); */ bonsai_type_info_linked_list_node* Result = {}; - auto *Bucket = GetHashBucket(umm(Hash(&Name)), Table); + auto *Bucket = GetHashBucket(umm(Hash(&Query)), Table); while (Bucket) { auto E = &Bucket->Element; - if (Bucket->Tombstoned == False && AreEqual(E->Name, Name)) + if (Bucket->Tombstoned == False && AreEqual(E->Name, Query)) + { Result = Bucket; break; @@ -27,13 +27,13 @@ GetBucketByName( bonsai_type_info_hashtable *Table, cs Name ) } maybe_bonsai_type_info -GetByName( bonsai_type_info_hashtable *Table, cs Name ) +GetByName( bonsai_type_info_hashtable *Table, cs Query ) { /* ENSURE_OWNED_BY_THREAD(Table); */ maybe_bonsai_type_info Result = {}; - bonsai_type_info_linked_list_node *Bucket = GetBucketByName(Table, Name); + bonsai_type_info_linked_list_node *Bucket = GetBucketByName(Table, Query); if (Bucket) { Result.Tag = Maybe_Yes; @@ -43,6 +43,7 @@ GetByName( bonsai_type_info_hashtable *Table, cs Name ) return Result; } + link_internal b32 Tombstone(cs Key, bonsai_type_info_hashtable *Table, memory_arena *Memory) { @@ -57,3 +58,9 @@ Tombstone(cs Key, bonsai_type_info_hashtable *Table, memory_arena *Memory) return Result; } +link_internal b32 +Drop( bonsai_type_info_hashtable *Table, cs Key ) +{ + return Tombstone(Key, Table, 0); +} + diff --git a/generated/hashtable_get_ptr_ui_toggle_31501_688856534.h b/generated/hashtable_get_ptr_ui_toggle_31501_688856534.h index 1598bf745..25204aa2a 100644 --- a/generated/hashtable_get_ptr_ui_toggle_31501_688856534.h +++ b/generated/hashtable_get_ptr_ui_toggle_31501_688856534.h @@ -1,18 +1,17 @@ -// external/bonsai_stdlib/src/ui/ui.cpp:13:0 - +// external/bonsai_stdlib/src/poof_functions.h:1053:0 maybe_ui_toggle_ptr -GetPtrById( ui_toggle_hashtable *Table, ui_id Id ) +GetPtrById( ui_toggle_hashtable *Table, ui_id Query ) { /* ENSURE_OWNED_BY_THREAD(Table); */ maybe_ui_toggle_ptr Result = {}; - auto *Bucket = GetHashBucket(umm(Hash(&Id)), Table); + auto *Bucket = GetHashBucket(umm(Hash(&Query)), Table); while (Bucket) { auto E = &Bucket->Element; - if (Bucket->Tombstoned == False && AreEqual(E->Id, Id)) + if (Bucket->Tombstoned == False && AreEqual(E->Id, Query)) { Result.Tag = Maybe_Yes; Result.Value = E; diff --git a/generated/hashtable_get_ptr_window_layout_705671517_599498827.h b/generated/hashtable_get_ptr_window_layout_705671517_599498827.h index 341f383a6..9a1ca4f6a 100644 --- a/generated/hashtable_get_ptr_window_layout_705671517_599498827.h +++ b/generated/hashtable_get_ptr_window_layout_705671517_599498827.h @@ -1,18 +1,17 @@ -// external/bonsai_stdlib/src/ui/ui.cpp:22:0 - +// external/bonsai_stdlib/src/poof_functions.h:1053:0 maybe_window_layout_ptr -GetPtrByHashtableKey( window_layout_hashtable *Table, ui_id HashtableKey ) +GetPtrByHashtableKey( window_layout_hashtable *Table, ui_id Query ) { /* ENSURE_OWNED_BY_THREAD(Table); */ maybe_window_layout_ptr Result = {}; - auto *Bucket = GetHashBucket(umm(Hash(&HashtableKey)), Table); + auto *Bucket = GetHashBucket(umm(Hash(&Query)), Table); while (Bucket) { auto E = &Bucket->Element; - if (Bucket->Tombstoned == False && AreEqual(E->HashtableKey, HashtableKey)) + if (Bucket->Tombstoned == False && AreEqual(E->HashtableKey, Query)) { Result.Tag = Maybe_Yes; Result.Value = E; diff --git a/generated/hashtable_get_u32_hashtable_wrapper_688719149_688856424.h b/generated/hashtable_get_u32_hashtable_wrapper_688719149_688856424.h new file mode 100644 index 000000000..51f1e0577 --- /dev/null +++ b/generated/hashtable_get_u32_hashtable_wrapper_688719149_688856424.h @@ -0,0 +1,66 @@ +// external/bonsai_stdlib/src/poof_functions.h:978:0 +u32_linked_list_node* +GetBucketByValue( u32_hashtable *Table, u32 Query ) +{ + /* ENSURE_OWNED_BY_THREAD(Table); */ + + u32_linked_list_node* Result = {}; + + auto *Bucket = GetHashBucket(umm(Hash(&Query)), Table); + while (Bucket) + { + auto E = &Bucket->Element; + + if (Bucket->Tombstoned == False && AreEqual(*E, Query)) + + { + Result = Bucket; + break; + } + else + { + Bucket = Bucket->Next; + } + } + + return Result; +} + +maybe_u32 +GetByValue( u32_hashtable *Table, u32 Query ) +{ + /* ENSURE_OWNED_BY_THREAD(Table); */ + + maybe_u32 Result = {}; + + u32_linked_list_node *Bucket = GetBucketByValue(Table, Query); + if (Bucket) + { + Result.Tag = Maybe_Yes; + Result.Value = Bucket->Element; + } + + return Result; +} + + +link_internal b32 +Tombstone(u32 Key, u32_hashtable *Table, memory_arena *Memory) +{ + b32 Result = False; + u32_linked_list_node *Bucket = GetBucketByValue(Table, Key); + if (Bucket) + { + Assert(Bucket->Tombstoned == False); + Bucket->Tombstoned = True; + Result = True; + } + return Result; +} + +link_internal b32 +Drop( u32_hashtable *Table, u32 Key ) +{ + return Tombstone(Key, Table, 0); +} + diff --git a/generated/hashtable_get_ui_toggle_31501_688856534.h b/generated/hashtable_get_ui_toggle_31501_688856534.h index a67d09042..f9acaa3e7 100644 --- a/generated/hashtable_get_ui_toggle_31501_688856534.h +++ b/generated/hashtable_get_ui_toggle_31501_688856534.h @@ -1,18 +1,18 @@ -// external/bonsai_stdlib/src/ui/ui.cpp:10:0 - +// external/bonsai_stdlib/src/poof_functions.h:978:0 ui_toggle_linked_list_node* -GetBucketById( ui_toggle_hashtable *Table, ui_id Id ) +GetBucketById( ui_toggle_hashtable *Table, ui_id Query ) { /* ENSURE_OWNED_BY_THREAD(Table); */ ui_toggle_linked_list_node* Result = {}; - auto *Bucket = GetHashBucket(umm(Hash(&Id)), Table); + auto *Bucket = GetHashBucket(umm(Hash(&Query)), Table); while (Bucket) { auto E = &Bucket->Element; - if (Bucket->Tombstoned == False && AreEqual(E->Id, Id)) + if (Bucket->Tombstoned == False && AreEqual(E->Id, Query)) + { Result = Bucket; break; @@ -27,13 +27,13 @@ GetBucketById( ui_toggle_hashtable *Table, ui_id Id ) } maybe_ui_toggle -GetById( ui_toggle_hashtable *Table, ui_id Id ) +GetById( ui_toggle_hashtable *Table, ui_id Query ) { /* ENSURE_OWNED_BY_THREAD(Table); */ maybe_ui_toggle Result = {}; - ui_toggle_linked_list_node *Bucket = GetBucketById(Table, Id); + ui_toggle_linked_list_node *Bucket = GetBucketById(Table, Query); if (Bucket) { Result.Tag = Maybe_Yes; @@ -43,6 +43,7 @@ GetById( ui_toggle_hashtable *Table, ui_id Id ) return Result; } + link_internal b32 Tombstone(ui_id Key, ui_toggle_hashtable *Table, memory_arena *Memory) { @@ -57,3 +58,9 @@ Tombstone(ui_id Key, ui_toggle_hashtable *Table, memory_arena *Memory) return Result; } +link_internal b32 +Drop( ui_toggle_hashtable *Table, ui_id Key ) +{ + return Tombstone(Key, Table, 0); +} + diff --git a/generated/hashtable_get_window_layout_705671517_599498827.h b/generated/hashtable_get_window_layout_705671517_599498827.h index c087aaa46..1f4a6d572 100644 --- a/generated/hashtable_get_window_layout_705671517_599498827.h +++ b/generated/hashtable_get_window_layout_705671517_599498827.h @@ -1,18 +1,18 @@ -// external/bonsai_stdlib/src/ui/ui.cpp:20:0 - +// external/bonsai_stdlib/src/poof_functions.h:978:0 window_layout_linked_list_node* -GetBucketByHashtableKey( window_layout_hashtable *Table, ui_id HashtableKey ) +GetBucketByHashtableKey( window_layout_hashtable *Table, ui_id Query ) { /* ENSURE_OWNED_BY_THREAD(Table); */ window_layout_linked_list_node* Result = {}; - auto *Bucket = GetHashBucket(umm(Hash(&HashtableKey)), Table); + auto *Bucket = GetHashBucket(umm(Hash(&Query)), Table); while (Bucket) { auto E = &Bucket->Element; - if (Bucket->Tombstoned == False && AreEqual(E->HashtableKey, HashtableKey)) + if (Bucket->Tombstoned == False && AreEqual(E->HashtableKey, Query)) + { Result = Bucket; break; @@ -27,13 +27,13 @@ GetBucketByHashtableKey( window_layout_hashtable *Table, ui_id HashtableKey ) } maybe_window_layout -GetByHashtableKey( window_layout_hashtable *Table, ui_id HashtableKey ) +GetByHashtableKey( window_layout_hashtable *Table, ui_id Query ) { /* ENSURE_OWNED_BY_THREAD(Table); */ maybe_window_layout Result = {}; - window_layout_linked_list_node *Bucket = GetBucketByHashtableKey(Table, HashtableKey); + window_layout_linked_list_node *Bucket = GetBucketByHashtableKey(Table, Query); if (Bucket) { Result.Tag = Maybe_Yes; @@ -43,6 +43,7 @@ GetByHashtableKey( window_layout_hashtable *Table, ui_id HashtableKey ) return Result; } + link_internal b32 Tombstone(ui_id Key, window_layout_hashtable *Table, memory_arena *Memory) { @@ -57,3 +58,9 @@ Tombstone(ui_id Key, window_layout_hashtable *Table, memory_arena *Memory) return Result; } +link_internal b32 +Drop( window_layout_hashtable *Table, ui_id Key ) +{ + return Tombstone(Key, Table, 0); +} + diff --git a/generated/hashtable_impl_u32.h b/generated/hashtable_impl_u32.h new file mode 100644 index 000000000..eb6d3106a --- /dev/null +++ b/generated/hashtable_impl_u32.h @@ -0,0 +1,175 @@ +// external/bonsai_stdlib/src/poof_functions.h:799:0 +link_internal b32 AreEqual(u32_linked_list_node *Node1, u32_linked_list_node *Node2 ); +link_internal b32 AreEqual(u32 *Element1, u32 *Element2 ); + +link_internal u32_linked_list_node * +Allocate_u32_linked_list_node(memory_arena *Memory) +{ + u32_linked_list_node *Result = Allocate( u32_linked_list_node, Memory, 1); + return Result; +} + +link_internal u32_hashtable +Allocate_u32_hashtable(umm ElementCount, memory_arena *Memory) +{ + u32_hashtable Result = { + .Elements = Allocate( u32_linked_list_node*, Memory, ElementCount), + .Size = ElementCount, + /* OWNED_BY_THREAD_MEMBER_INIT() */ + }; + return Result; +} + +link_internal u32_linked_list_node * +GetHashBucket(umm HashValue, u32_hashtable *Table) +{ + /* ENSURE_OWNED_BY_THREAD(Table); */ + + Assert(Table->Size); + u32_linked_list_node *Result = Table->Elements[HashValue % Table->Size]; + return Result; +} + +link_internal u32 * +GetFirstAtBucket(umm HashValue, u32_hashtable *Table) +{ + /* ENSURE_OWNED_BY_THREAD(Table); */ + + u32_linked_list_node *Bucket = GetHashBucket(HashValue, Table); + u32 *Result = &Bucket->Element; + return Result; +} + +link_internal u32_linked_list_node** +GetMatchingBucket(u32 Element, u32_hashtable *Table, memory_arena *Memory) +{ + umm HashValue = Hash(&Element) % Table->Size; + u32_linked_list_node **Bucket = Table->Elements + HashValue; + while (*Bucket) + { + if (AreEqual(&Bucket[0]->Element, &Element)) { break; } + Bucket = &(*Bucket)->Next; + } + return Bucket; +} + +link_internal u32 * +Insert(u32_linked_list_node *Node, u32_hashtable *Table) +{ + /* ENSURE_OWNED_BY_THREAD(Table); */ + + Assert(Table->Size); + umm HashValue = Hash(&Node->Element) % Table->Size; + u32_linked_list_node **Bucket = Table->Elements + HashValue; + while (*Bucket) + { + /* Assert(!AreEqual(&Bucket[0]->Element, &Node->Element)); */ + Bucket = &(*Bucket)->Next; + } + *Bucket = Node; + return &Bucket[0]->Element; +} + +link_internal u32* +Insert(u32 Element, u32_hashtable *Table, memory_arena *Memory) +{ + /* ENSURE_OWNED_BY_THREAD(Table); */ + + u32_linked_list_node *Bucket = Allocate_u32_linked_list_node(Memory); + Bucket->Element = Element; + Insert(Bucket, Table); + return &Bucket->Element; +} + +link_internal u32* +Upsert(u32 Element, u32_hashtable *Table, memory_arena *Memory) +{ + umm HashValue = Hash(&Element) % Table->Size; + u32_linked_list_node **Bucket = Table->Elements + HashValue; + while (*Bucket) + { + if (AreEqual(&Bucket[0]->Element, &Element)) { break; } + Bucket = &(*Bucket)->Next; + } + + if (*Bucket && Bucket[0]->Tombstoned == False) + { + Bucket[0]->Element = Element; + } + else + { + Insert(Element, Table, Memory); + } + + return &Bucket[0]->Element; +} + + +// +// Iterator impl. +// + +struct u32_hashtable_iterator +{ + umm HashIndex; + u32_hashtable *Table; + u32_linked_list_node *Node; +}; + +link_internal u32_hashtable_iterator +operator++( u32_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<( u32_hashtable_iterator I0, u32_hashtable_iterator I1) +{ + b32 Result = I0.HashIndex < I1.HashIndex; + return Result; +} + +link_inline u32_hashtable_iterator +ZerothIndex(u32_hashtable *Hashtable) +{ + u32_hashtable_iterator Iterator = {}; + Iterator.Table = Hashtable; + Iterator.Node = Hashtable->Elements[0]; + return Iterator; +} + +link_inline u32_hashtable_iterator +AtElements(u32_hashtable *Hashtable) +{ + u32_hashtable_iterator Result = { Hashtable->Size, 0, 0 }; + return Result; +} + +link_inline u32 * +GetPtr(u32_hashtable *Hashtable, u32_hashtable_iterator Iterator) +{ + u32 *Result = {}; + if (Iterator.Node) + { + Result = &Iterator.Node->Element; + } + return Result; +} + +link_inline u32 * +TryGetPtr(u32_hashtable *Hashtable, u32_hashtable_iterator Iterator) +{ + return GetPtr(Hashtable, Iterator); +} + + diff --git a/generated/hashtable_impl_ui_toggle.h b/generated/hashtable_impl_ui_toggle.h index 8ae253571..1ea6d93d5 100644 --- a/generated/hashtable_impl_ui_toggle.h +++ b/generated/hashtable_impl_ui_toggle.h @@ -1,6 +1,6 @@ -// external/bonsai_stdlib/src/ui/ui.cpp:7:0 - +// external/bonsai_stdlib/src/poof_functions.h:799:0 link_internal b32 AreEqual(ui_toggle_linked_list_node *Node1, ui_toggle_linked_list_node *Node2 ); +link_internal b32 AreEqual(ui_toggle *Element1, ui_toggle *Element2 ); link_internal ui_toggle_linked_list_node * Allocate_ui_toggle_linked_list_node(memory_arena *Memory) @@ -63,7 +63,7 @@ Insert(ui_toggle_linked_list_node *Node, ui_toggle_hashtable *Table) ui_toggle_linked_list_node **Bucket = Table->Elements + HashValue; while (*Bucket) { - /* Assert(!AreEqual(*Bucket, Node)); */ + /* Assert(!AreEqual(&Bucket[0]->Element, &Node->Element)); */ Bucket = &(*Bucket)->Next; } *Bucket = Node; @@ -166,3 +166,10 @@ GetPtr(ui_toggle_hashtable *Hashtable, ui_toggle_hashtable_iterator Iterator) return Result; } +link_inline ui_toggle * +TryGetPtr(ui_toggle_hashtable *Hashtable, ui_toggle_hashtable_iterator Iterator) +{ + return GetPtr(Hashtable, Iterator); +} + + diff --git a/generated/hashtable_impl_window_layout.h b/generated/hashtable_impl_window_layout.h index 7b613fdc7..c10879c4a 100644 --- a/generated/hashtable_impl_window_layout.h +++ b/generated/hashtable_impl_window_layout.h @@ -1,6 +1,6 @@ -// external/bonsai_stdlib/src/ui/ui.cpp:17:0 - +// external/bonsai_stdlib/src/poof_functions.h:799:0 link_internal b32 AreEqual(window_layout_linked_list_node *Node1, window_layout_linked_list_node *Node2 ); +link_internal b32 AreEqual(window_layout *Element1, window_layout *Element2 ); link_internal window_layout_linked_list_node * Allocate_window_layout_linked_list_node(memory_arena *Memory) @@ -63,7 +63,7 @@ Insert(window_layout_linked_list_node *Node, window_layout_hashtable *Table) window_layout_linked_list_node **Bucket = Table->Elements + HashValue; while (*Bucket) { - /* Assert(!AreEqual(*Bucket, Node)); */ + /* Assert(!AreEqual(&Bucket[0]->Element, &Node->Element)); */ Bucket = &(*Bucket)->Next; } *Bucket = Node; @@ -166,3 +166,10 @@ GetPtr(window_layout_hashtable *Hashtable, window_layout_hashtable_iterator Iter return Result; } +link_inline window_layout * +TryGetPtr(window_layout_hashtable *Hashtable, window_layout_hashtable_iterator Iterator) +{ + return GetPtr(Hashtable, Iterator); +} + + diff --git a/generated/hashtable_impl_xml_tag.h b/generated/hashtable_impl_xml_tag.h index c66a062f6..0d4fe6c7f 100644 --- a/generated/hashtable_impl_xml_tag.h +++ b/generated/hashtable_impl_xml_tag.h @@ -1,6 +1,6 @@ -// external/bonsai_stdlib/src/xml.cpp:10:0 - +// external/bonsai_stdlib/src/poof_functions.h:799:0 link_internal b32 AreEqual(xml_tag_linked_list_node *Node1, xml_tag_linked_list_node *Node2 ); +link_internal b32 AreEqual(xml_tag *Element1, xml_tag *Element2 ); link_internal xml_tag_linked_list_node * Allocate_xml_tag_linked_list_node(memory_arena *Memory) @@ -63,7 +63,7 @@ Insert(xml_tag_linked_list_node *Node, xml_tag_hashtable *Table) xml_tag_linked_list_node **Bucket = Table->Elements + HashValue; while (*Bucket) { - /* Assert(!AreEqual(*Bucket, Node)); */ + /* Assert(!AreEqual(&Bucket[0]->Element, &Node->Element)); */ Bucket = &(*Bucket)->Next; } *Bucket = Node; @@ -166,3 +166,10 @@ GetPtr(xml_tag_hashtable *Hashtable, xml_tag_hashtable_iterator Iterator) return Result; } +link_inline xml_tag * +TryGetPtr(xml_tag_hashtable *Hashtable, xml_tag_hashtable_iterator Iterator) +{ + return GetPtr(Hashtable, Iterator); +} + + diff --git a/generated/hashtable_parser.h b/generated/hashtable_parser.h index 674b4884a..a33201017 100644 --- a/generated/hashtable_parser.h +++ b/generated/hashtable_parser.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/c_parser.cpp:1:0 - +// external/bonsai_stdlib/src/poof_functions.h:777:0 struct parser_linked_list_node { b32 Tombstoned; @@ -14,6 +13,7 @@ struct parser_hashtable /* OWNED_BY_THREAD_MEMBER() */ }; link_internal b32 AreEqual(parser_linked_list_node *Node1, parser_linked_list_node *Node2 ); +link_internal b32 AreEqual(parser *Element1, parser *Element2 ); link_internal parser_linked_list_node * Allocate_parser_linked_list_node(memory_arena *Memory) @@ -76,7 +76,7 @@ Insert(parser_linked_list_node *Node, parser_hashtable *Table) parser_linked_list_node **Bucket = Table->Elements + HashValue; while (*Bucket) { - /* Assert(!AreEqual(*Bucket, Node)); */ + /* Assert(!AreEqual(&Bucket[0]->Element, &Node->Element)); */ Bucket = &(*Bucket)->Next; } *Bucket = Node; @@ -178,4 +178,11 @@ GetPtr(parser_hashtable *Hashtable, parser_hashtable_iterator Iterator) } return Result; } + +link_inline parser * +TryGetPtr(parser_hashtable *Hashtable, parser_hashtable_iterator Iterator) +{ + return GetPtr(Hashtable, Iterator); +} + diff --git a/generated/hashtable_struct_u32.h b/generated/hashtable_struct_u32.h new file mode 100644 index 000000000..3f552f5ff --- /dev/null +++ b/generated/hashtable_struct_u32.h @@ -0,0 +1,15 @@ +// external/bonsai_stdlib/src/poof_functions.h:780:0 +struct u32_linked_list_node +{ + b32 Tombstoned; + u32 Element; + u32_linked_list_node *Next; +}; + +struct u32_hashtable +{ + umm Size; + u32_linked_list_node **Elements; + /* OWNED_BY_THREAD_MEMBER() */ +}; + diff --git a/generated/hashtable_struct_ui_toggle.h b/generated/hashtable_struct_ui_toggle.h index a079e3282..97f26a1f3 100644 --- a/generated/hashtable_struct_ui_toggle.h +++ b/generated/hashtable_struct_ui_toggle.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/ui/ui.h:218:0 - +// external/bonsai_stdlib/src/poof_functions.h:780:0 struct ui_toggle_linked_list_node { b32 Tombstoned; diff --git a/generated/hashtable_struct_window_layout.h b/generated/hashtable_struct_window_layout.h index 9bf794ec8..d2259b01c 100644 --- a/generated/hashtable_struct_window_layout.h +++ b/generated/hashtable_struct_window_layout.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/ui/ui.h:133:0 - +// external/bonsai_stdlib/src/poof_functions.h:780:0 struct window_layout_linked_list_node { b32 Tombstoned; diff --git a/generated/hashtable_struct_xml_tag.h b/generated/hashtable_struct_xml_tag.h index 8a13040e1..0723a5734 100644 --- a/generated/hashtable_struct_xml_tag.h +++ b/generated/hashtable_struct_xml_tag.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/xml.h:46:0 - +// external/bonsai_stdlib/src/poof_functions.h:780:0 struct xml_tag_linked_list_node { b32 Tombstoned; diff --git a/generated/hashtable_to_buffer_bonsai_type_info.h b/generated/hashtable_to_buffer_bonsai_type_info.h index 24f31e944..5a86bee7b 100644 --- a/generated/hashtable_to_buffer_bonsai_type_info.h +++ b/generated/hashtable_to_buffer_bonsai_type_info.h @@ -1,5 +1,4 @@ -// src/engine/bonsai_type_info.h:40:0 - +// external/bonsai_stdlib/src/poof_functions.h:1087:0 bonsai_type_info_buffer ToBuffer( bonsai_type_info_hashtable *Table, memory_arena *Memory ) { diff --git a/generated/hashtable_voxel_synth_tile.h b/generated/hashtable_voxel_synth_tile.h index 580f05c67..47d45e75c 100644 --- a/generated/hashtable_voxel_synth_tile.h +++ b/generated/hashtable_voxel_synth_tile.h @@ -1,5 +1,4 @@ -// src/engine/voxel_synthesis.h:158:0 - +// external/bonsai_stdlib/src/poof_functions.h:777:0 struct voxel_synth_tile_linked_list_node { b32 Tombstoned; @@ -14,6 +13,7 @@ struct voxel_synth_tile_hashtable /* OWNED_BY_THREAD_MEMBER() */ }; link_internal b32 AreEqual(voxel_synth_tile_linked_list_node *Node1, voxel_synth_tile_linked_list_node *Node2 ); +link_internal b32 AreEqual(voxel_synth_tile *Element1, voxel_synth_tile *Element2 ); link_internal voxel_synth_tile_linked_list_node * Allocate_voxel_synth_tile_linked_list_node(memory_arena *Memory) @@ -76,7 +76,7 @@ Insert(voxel_synth_tile_linked_list_node *Node, voxel_synth_tile_hashtable *Tabl voxel_synth_tile_linked_list_node **Bucket = Table->Elements + HashValue; while (*Bucket) { - /* Assert(!AreEqual(*Bucket, Node)); */ + /* Assert(!AreEqual(&Bucket[0]->Element, &Node->Element)); */ Bucket = &(*Bucket)->Next; } *Bucket = Node; @@ -178,4 +178,11 @@ GetPtr(voxel_synth_tile_hashtable *Hashtable, voxel_synth_tile_hashtable_iterato } return Result; } + +link_inline voxel_synth_tile * +TryGetPtr(voxel_synth_tile_hashtable *Hashtable, voxel_synth_tile_hashtable_iterator Iterator) +{ + return GetPtr(Hashtable, Iterator); +} + diff --git a/generated/hashtable_world_edit_brush.h b/generated/hashtable_world_edit_brush.h new file mode 100644 index 000000000..0f983797c --- /dev/null +++ b/generated/hashtable_world_edit_brush.h @@ -0,0 +1,188 @@ +// external/bonsai_stdlib/src/poof_functions.h:777:0 +struct world_edit_brush_linked_list_node +{ + b32 Tombstoned; + world_edit_brush Element; + world_edit_brush_linked_list_node *Next; +}; + +struct world_edit_brush_hashtable +{ + umm Size; + world_edit_brush_linked_list_node **Elements; + /* OWNED_BY_THREAD_MEMBER() */ +}; +link_internal b32 AreEqual(world_edit_brush_linked_list_node *Node1, world_edit_brush_linked_list_node *Node2 ); +link_internal b32 AreEqual(world_edit_brush *Element1, world_edit_brush *Element2 ); + +link_internal world_edit_brush_linked_list_node * +Allocate_world_edit_brush_linked_list_node(memory_arena *Memory) +{ + world_edit_brush_linked_list_node *Result = Allocate( world_edit_brush_linked_list_node, Memory, 1); + return Result; +} + +link_internal world_edit_brush_hashtable +Allocate_world_edit_brush_hashtable(umm ElementCount, memory_arena *Memory) +{ + world_edit_brush_hashtable Result = { + .Elements = Allocate( world_edit_brush_linked_list_node*, Memory, ElementCount), + .Size = ElementCount, + /* OWNED_BY_THREAD_MEMBER_INIT() */ + }; + return Result; +} + +link_internal world_edit_brush_linked_list_node * +GetHashBucket(umm HashValue, world_edit_brush_hashtable *Table) +{ + /* ENSURE_OWNED_BY_THREAD(Table); */ + + Assert(Table->Size); + world_edit_brush_linked_list_node *Result = Table->Elements[HashValue % Table->Size]; + return Result; +} + +link_internal world_edit_brush * +GetFirstAtBucket(umm HashValue, world_edit_brush_hashtable *Table) +{ + /* ENSURE_OWNED_BY_THREAD(Table); */ + + world_edit_brush_linked_list_node *Bucket = GetHashBucket(HashValue, Table); + world_edit_brush *Result = &Bucket->Element; + return Result; +} + +link_internal world_edit_brush_linked_list_node** +GetMatchingBucket(world_edit_brush Element, world_edit_brush_hashtable *Table, memory_arena *Memory) +{ + umm HashValue = Hash(&Element) % Table->Size; + world_edit_brush_linked_list_node **Bucket = Table->Elements + HashValue; + while (*Bucket) + { + if (AreEqual(&Bucket[0]->Element, &Element)) { break; } + Bucket = &(*Bucket)->Next; + } + return Bucket; +} + +link_internal world_edit_brush * +Insert(world_edit_brush_linked_list_node *Node, world_edit_brush_hashtable *Table) +{ + /* ENSURE_OWNED_BY_THREAD(Table); */ + + Assert(Table->Size); + umm HashValue = Hash(&Node->Element) % Table->Size; + world_edit_brush_linked_list_node **Bucket = Table->Elements + HashValue; + while (*Bucket) + { + /* Assert(!AreEqual(&Bucket[0]->Element, &Node->Element)); */ + Bucket = &(*Bucket)->Next; + } + *Bucket = Node; + return &Bucket[0]->Element; +} + +link_internal world_edit_brush* +Insert(world_edit_brush Element, world_edit_brush_hashtable *Table, memory_arena *Memory) +{ + /* ENSURE_OWNED_BY_THREAD(Table); */ + + world_edit_brush_linked_list_node *Bucket = Allocate_world_edit_brush_linked_list_node(Memory); + Bucket->Element = Element; + Insert(Bucket, Table); + return &Bucket->Element; +} + +link_internal world_edit_brush* +Upsert(world_edit_brush Element, world_edit_brush_hashtable *Table, memory_arena *Memory) +{ + umm HashValue = Hash(&Element) % Table->Size; + world_edit_brush_linked_list_node **Bucket = Table->Elements + HashValue; + while (*Bucket) + { + if (AreEqual(&Bucket[0]->Element, &Element)) { break; } + Bucket = &(*Bucket)->Next; + } + + if (*Bucket && Bucket[0]->Tombstoned == False) + { + Bucket[0]->Element = Element; + } + else + { + Insert(Element, Table, Memory); + } + + return &Bucket[0]->Element; +} + + +// +// Iterator impl. +// + +struct world_edit_brush_hashtable_iterator +{ + umm HashIndex; + world_edit_brush_hashtable *Table; + world_edit_brush_linked_list_node *Node; +}; + +link_internal world_edit_brush_hashtable_iterator +operator++( world_edit_brush_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<( world_edit_brush_hashtable_iterator I0, world_edit_brush_hashtable_iterator I1) +{ + b32 Result = I0.HashIndex < I1.HashIndex; + return Result; +} + +link_inline world_edit_brush_hashtable_iterator +ZerothIndex(world_edit_brush_hashtable *Hashtable) +{ + world_edit_brush_hashtable_iterator Iterator = {}; + Iterator.Table = Hashtable; + Iterator.Node = Hashtable->Elements[0]; + return Iterator; +} + +link_inline world_edit_brush_hashtable_iterator +AtElements(world_edit_brush_hashtable *Hashtable) +{ + world_edit_brush_hashtable_iterator Result = { Hashtable->Size, 0, 0 }; + return Result; +} + +link_inline world_edit_brush * +GetPtr(world_edit_brush_hashtable *Hashtable, world_edit_brush_hashtable_iterator Iterator) +{ + world_edit_brush *Result = {}; + if (Iterator.Node) + { + Result = &Iterator.Node->Element; + } + return Result; +} + +link_inline world_edit_brush * +TryGetPtr(world_edit_brush_hashtable *Hashtable, world_edit_brush_hashtable_iterator Iterator) +{ + return GetPtr(Hashtable, Iterator); +} + + diff --git a/generated/index_of_counted_string.h b/generated/index_of_counted_string.h index dbf00a0b5..fff02ac44 100644 --- a/generated/index_of_counted_string.h +++ b/generated/index_of_counted_string.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/counted_string.cpp:23:0 - +// external/bonsai_stdlib/src/poof_functions.h:602:0 link_internal umm IndexOf(counted_string_buffer *Buf, counted_string Element) { diff --git a/generated/is_valid_bX0vSE1r.h b/generated/is_valid_bX0vSE1r.h new file mode 100644 index 000000000..942533fc3 --- /dev/null +++ b/generated/is_valid_bX0vSE1r.h @@ -0,0 +1,26 @@ +// external/bonsai_stdlib/src/poof_functions.h:2623:0 +link_internal b32 +IsValid(window_layout_flags Value) +{ + b32 Result = False; + switch (Value) + { + case WindowLayoutFlag_None: + case WindowLayoutFlag_Size_Dynamic: + case WindowLayoutFlag_StartupSize_InferHeight: + case WindowLayoutFlag_StartupSize_InferWidth: + case WindowLayoutFlag_StartupSize_Infer: + case WindowLayoutFlag_Align_Right: + case WindowLayoutFlag_Align_Bottom: + case WindowLayoutFlag_Align_BottomRight: + case WindowLayoutFlag_Default: + case WindowLayoutFlag_DeferFree: + + { + Result = True; + } + } + return Result; +} + + diff --git a/generated/maybe_asset_id.h b/generated/maybe_asset_id.h index c76c8b422..19779c11e 100644 --- a/generated/maybe_asset_id.h +++ b/generated/maybe_asset_id.h @@ -1,5 +1,4 @@ -// src/engine/asset.h:153:0 - +// external/bonsai_stdlib/src/poof_functions.h:2199:0 struct maybe_asset_id { maybe_tag Tag; diff --git a/generated/maybe_asset_ptr.h b/generated/maybe_asset_ptr.h index d20fdc8f2..abf00b34f 100644 --- a/generated/maybe_asset_ptr.h +++ b/generated/maybe_asset_ptr.h @@ -1,5 +1,4 @@ -// src/engine/asset.h:197:0 - +// external/bonsai_stdlib/src/poof_functions.h:2199:0 struct maybe_asset_ptr { maybe_tag Tag; diff --git a/generated/maybe_bonsai_type_info.h b/generated/maybe_bonsai_type_info.h index 684bdcdeb..19f4cbb7a 100644 --- a/generated/maybe_bonsai_type_info.h +++ b/generated/maybe_bonsai_type_info.h @@ -1,5 +1,4 @@ -// src/engine/bonsai_type_info.h:43:0 - +// external/bonsai_stdlib/src/poof_functions.h:2199:0 struct maybe_bonsai_type_info { maybe_tag Tag; diff --git a/generated/maybe_chunk_data.h b/generated/maybe_chunk_data.h index f8718b562..d6d8bf740 100644 --- a/generated/maybe_chunk_data.h +++ b/generated/maybe_chunk_data.h @@ -1,5 +1,4 @@ -// src/engine/world_chunk.h:201:0 - +// external/bonsai_stdlib/src/poof_functions.h:2199:0 struct maybe_chunk_data { maybe_tag Tag; diff --git a/generated/maybe_entity_ptr.h b/generated/maybe_entity_ptr.h index 47bc689c0..4741e2426 100644 --- a/generated/maybe_entity_ptr.h +++ b/generated/maybe_entity_ptr.h @@ -1,5 +1,4 @@ -// src/engine/resources.h:10:0 - +// external/bonsai_stdlib/src/poof_functions.h:2199:0 struct maybe_entity_ptr { maybe_tag Tag; diff --git a/generated/maybe_file_traversal_node.h b/generated/maybe_file_traversal_node.h index 432f93e21..4721f8689 100644 --- a/generated/maybe_file_traversal_node.h +++ b/generated/maybe_file_traversal_node.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/file.h:60:0 - +// external/bonsai_stdlib/src/poof_functions.h:2199:0 struct maybe_file_traversal_node { maybe_tag Tag; diff --git a/generated/maybe_model_buffer.h b/generated/maybe_model_buffer.h index 6936193b4..2817bf243 100644 --- a/generated/maybe_model_buffer.h +++ b/generated/maybe_model_buffer.h @@ -1,5 +1,4 @@ -// src/engine/model.h:94:0 - +// external/bonsai_stdlib/src/poof_functions.h:2199:0 struct maybe_model_buffer { maybe_tag Tag; diff --git a/generated/maybe_standing_spot.h b/generated/maybe_standing_spot.h index 1fed2462e..ea08f5fb5 100644 --- a/generated/maybe_standing_spot.h +++ b/generated/maybe_standing_spot.h @@ -1,5 +1,4 @@ -// src/engine/world_chunk.h:520:0 - +// external/bonsai_stdlib/src/poof_functions.h:2199:0 struct maybe_standing_spot { maybe_tag Tag; diff --git a/generated/maybe_u32.h b/generated/maybe_u32.h new file mode 100644 index 000000000..3c1115b01 --- /dev/null +++ b/generated/maybe_u32.h @@ -0,0 +1,7 @@ +// external/bonsai_stdlib/src/poof_functions.h:2199:0 +struct maybe_u32 +{ + maybe_tag Tag; + u32 Value; +}; + diff --git a/generated/maybe_ui_toggle.h b/generated/maybe_ui_toggle.h index 086f3424e..e58794b4f 100644 --- a/generated/maybe_ui_toggle.h +++ b/generated/maybe_ui_toggle.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/ui/ui.h:212:0 - +// external/bonsai_stdlib/src/poof_functions.h:2199:0 struct maybe_ui_toggle { maybe_tag Tag; diff --git a/generated/maybe_ui_toggle_ptr.h b/generated/maybe_ui_toggle_ptr.h index bb96cf33f..579dd3fef 100644 --- a/generated/maybe_ui_toggle_ptr.h +++ b/generated/maybe_ui_toggle_ptr.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/ui/ui.h:215:0 - +// external/bonsai_stdlib/src/poof_functions.h:2199:0 struct maybe_ui_toggle_ptr { maybe_tag Tag; diff --git a/generated/maybe_v3.h b/generated/maybe_v3.h index 147ba5fa2..c26f535b3 100644 --- a/generated/maybe_v3.h +++ b/generated/maybe_v3.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/vector.h:1118:0 - +// external/bonsai_stdlib/src/poof_functions.h:2199:0 struct maybe_v3 { maybe_tag Tag; diff --git a/generated/maybe_v3i.h b/generated/maybe_v3i.h index d3a397631..2f05eeeec 100644 --- a/generated/maybe_v3i.h +++ b/generated/maybe_v3i.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/vector.h:1120:0 - +// external/bonsai_stdlib/src/poof_functions.h:2199:0 struct maybe_v3i { maybe_tag Tag; diff --git a/generated/maybe_window_layout.h b/generated/maybe_window_layout.h index 8ad8dc96c..0398e4270 100644 --- a/generated/maybe_window_layout.h +++ b/generated/maybe_window_layout.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/ui/ui.h:127:0 - +// external/bonsai_stdlib/src/poof_functions.h:2199:0 struct maybe_window_layout { maybe_tag Tag; diff --git a/generated/maybe_window_layout_ptr.h b/generated/maybe_window_layout_ptr.h index 56ce02a37..62901732d 100644 --- a/generated/maybe_window_layout_ptr.h +++ b/generated/maybe_window_layout_ptr.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/ui/ui.h:130:0 - +// external/bonsai_stdlib/src/poof_functions.h:2199:0 struct maybe_window_layout_ptr { maybe_tag Tag; 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 6dd4524b2..c1be95c48 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,5 +1,4 @@ -// src/engine/mesh.cpp:47:0 - +// src/engine/mesh.cpp:3:0 link_internal void AllocateMesh( untextured_3d_geometry_buffer *Mesh, data_type Type, u32 NumVerts, heap_allocator *Memory) { 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 fa3fd557c..093655792 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,5 +1,4 @@ -// src/engine/mesh.cpp:44:0 - +// src/engine/mesh.cpp:3:0 link_internal void AllocateMesh( untextured_3d_geometry_buffer *Mesh, data_type Type, u32 NumVerts, memory_arena *Memory) { diff --git a/generated/parse_integer_136174807.h b/generated/parse_integer_136174807.h index b13072c4d..0635c519f 100644 --- a/generated/parse_integer_136174807.h +++ b/generated/parse_integer_136174807.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/counted_string.h:854:0 - +// external/bonsai_stdlib/src/counted_string.h:847:0 link_internal b32 ParseInteger(cs String, u32 *Out) { @@ -85,3 +84,4 @@ ParseInteger(cs String, s64 *Out) return Result; } + 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 ed3dd9e8a..5be6d7a1e 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 @@ -1,192 +1,236 @@ -// src/engine/render_command.cpp:27:0 +// src/engine/render_command.cpp:3:0 +link_internal void +PushBonsaiRenderCommandInitializeNoiseBuffer( + work_queue *RenderQueue + , octree_node* DestNode +) +{ + work_queue_entry Work = WorkQueueEntry( + WorkQueueEntryBonsaiRenderCommand( BonsaiRenderCommandInitializeNoiseBuffer( DestNode ))); + PushWorkQueueEntry(RenderQueue, &Work); +} link_internal void PushBonsaiRenderCommandClearAllFramebuffers( work_queue *RenderQueue - , u32 Ignored = 0 + , u32 Ignored = 0 ) { work_queue_entry Work = WorkQueueEntry( - WorkQueueEntryBonsaiRenderCommand( BonsaiRenderCommandClearAllFramebuffers( Ignored ))); + WorkQueueEntryBonsaiRenderCommand( BonsaiRenderCommandClearAllFramebuffers( Ignored ))); PushWorkQueueEntry(RenderQueue, &Work); } link_internal void PushBonsaiRenderCommandAllocateTexture( work_queue *RenderQueue - , texture* Texture , void * Data + , texture* Texture , void * Data ) { work_queue_entry Work = WorkQueueEntry( - WorkQueueEntryBonsaiRenderCommand( BonsaiRenderCommandAllocateTexture( Texture , Data ))); + WorkQueueEntryBonsaiRenderCommand( BonsaiRenderCommandAllocateTexture( Texture , Data ))); PushWorkQueueEntry(RenderQueue, &Work); } link_internal void PushBonsaiRenderCommandDeallocateTexture( work_queue *RenderQueue - , u32* Buffers , s32 Count = 3 + , u32* Buffers , s32 Count = 3 ) { work_queue_entry Work = WorkQueueEntry( - WorkQueueEntryBonsaiRenderCommand( BonsaiRenderCommandDeallocateTexture( Buffers , Count ))); + WorkQueueEntryBonsaiRenderCommand( BonsaiRenderCommandDeallocateTexture( Buffers , Count ))); PushWorkQueueEntry(RenderQueue, &Work); } link_internal void -PushBonsaiRenderCommandAllocateBuffers( +PushBonsaiRenderCommandAllocateHandles( work_queue *RenderQueue - , u32* Buffers , s32 Count = 3 + , gpu_element_buffer_handles* Handles , untextured_3d_geometry_buffer* Mesh ) { work_queue_entry Work = WorkQueueEntry( - WorkQueueEntryBonsaiRenderCommand( BonsaiRenderCommandAllocateBuffers( Buffers , Count ))); + WorkQueueEntryBonsaiRenderCommand( BonsaiRenderCommandAllocateHandles( Handles , Mesh ))); PushWorkQueueEntry(RenderQueue, &Work); } link_internal void -PushBonsaiRenderCommandReallocateBuffers( +PushBonsaiRenderCommandDeallocateHandles( work_queue *RenderQueue - , gpu_element_buffer_handles* Handles , untextured_3d_geometry_buffer* Mesh + , gpu_element_buffer_handles Handles ) { work_queue_entry Work = WorkQueueEntry( - WorkQueueEntryBonsaiRenderCommand( BonsaiRenderCommandReallocateBuffers( Handles , Mesh ))); + WorkQueueEntryBonsaiRenderCommand( BonsaiRenderCommandDeallocateHandles( Handles ))); PushWorkQueueEntry(RenderQueue, &Work); } link_internal void -PushBonsaiRenderCommandDeallocateBuffers( +PushBonsaiRenderCommandDeallocateWorldChunk( work_queue *RenderQueue - , u32* Buffers , s32 Count + , world_chunk* Chunk ) { work_queue_entry Work = WorkQueueEntry( - WorkQueueEntryBonsaiRenderCommand( BonsaiRenderCommandDeallocateBuffers( Buffers , Count ))); + WorkQueueEntryBonsaiRenderCommand( BonsaiRenderCommandDeallocateWorldChunk( Chunk ))); PushWorkQueueEntry(RenderQueue, &Work); } link_internal void -PushBonsaiRenderCommandDeallocateWorldChunk( +PushBonsaiRenderCommandDoStuff( work_queue *RenderQueue - , world_chunk* Chunk + , u32 Ignored = 0 ) { work_queue_entry Work = WorkQueueEntry( - WorkQueueEntryBonsaiRenderCommand( BonsaiRenderCommandDeallocateWorldChunk( Chunk ))); + WorkQueueEntryBonsaiRenderCommand( BonsaiRenderCommandDoStuff( Ignored ))); PushWorkQueueEntry(RenderQueue, &Work); } link_internal void -PushBonsaiRenderCommandDoStuff( +PushBonsaiRenderCommandAllocateAndMapGpuElementBuffer( + work_queue *RenderQueue + , data_type Type , u32 ElementCount , gpu_mapped_element_buffer* Dest , gen_chunk* SynChunk , octree_node* DestNode +) +{ + work_queue_entry Work = WorkQueueEntry( + WorkQueueEntryBonsaiRenderCommand( BonsaiRenderCommandAllocateAndMapGpuElementBuffer( Type , ElementCount , Dest , SynChunk , DestNode ))); + + PushWorkQueueEntry(RenderQueue, &Work); +} +link_internal void +PushBonsaiRenderCommandUnmapGpuElementBuffer( + work_queue *RenderQueue + , gpu_element_buffer_handles* Handles , octree_node* DestNode +) +{ + work_queue_entry Work = WorkQueueEntry( + WorkQueueEntryBonsaiRenderCommand( BonsaiRenderCommandUnmapGpuElementBuffer( Handles , DestNode ))); + + PushWorkQueueEntry(RenderQueue, &Work); +} +link_internal void +PushBonsaiRenderCommandUnmapAndDeallocatePbo( work_queue *RenderQueue - , u32 Ignored = 0 + , gpu_readback_buffer PBOBuf ) { work_queue_entry Work = WorkQueueEntry( - WorkQueueEntryBonsaiRenderCommand( BonsaiRenderCommandDoStuff( Ignored ))); + WorkQueueEntryBonsaiRenderCommand( BonsaiRenderCommandUnmapAndDeallocatePbo( PBOBuf ))); PushWorkQueueEntry(RenderQueue, &Work); } link_internal void PushBonsaiRenderCommandSetupShader( work_queue *RenderQueue - , bonsai_render_command_shader_id ShaderId + , bonsai_render_command_shader_id ShaderId ) { work_queue_entry Work = WorkQueueEntry( - WorkQueueEntryBonsaiRenderCommand( BonsaiRenderCommandSetupShader( ShaderId ))); + WorkQueueEntryBonsaiRenderCommand( BonsaiRenderCommandSetupShader( ShaderId ))); PushWorkQueueEntry(RenderQueue, &Work); } link_internal void PushBonsaiRenderCommandTeardownShader( work_queue *RenderQueue - , bonsai_render_command_shader_id ShaderId + , bonsai_render_command_shader_id ShaderId ) { work_queue_entry Work = WorkQueueEntry( - WorkQueueEntryBonsaiRenderCommand( BonsaiRenderCommandTeardownShader( ShaderId ))); + WorkQueueEntryBonsaiRenderCommand( BonsaiRenderCommandTeardownShader( ShaderId ))); PushWorkQueueEntry(RenderQueue, &Work); } link_internal void PushBonsaiRenderCommandSetShaderUniform( work_queue *RenderQueue - , shader_uniform Uniform , shader* Shader , s32 TextureUnit + , shader_uniform Uniform , shader* Shader , s32 TextureUnit ) { work_queue_entry Work = WorkQueueEntry( - WorkQueueEntryBonsaiRenderCommand( BonsaiRenderCommandSetShaderUniform( Uniform , Shader , TextureUnit ))); + WorkQueueEntryBonsaiRenderCommand( BonsaiRenderCommandSetShaderUniform( Uniform , Shader , TextureUnit ))); PushWorkQueueEntry(RenderQueue, &Work); } link_internal void PushBonsaiRenderCommandDrawWorldChunkDrawList( work_queue *RenderQueue - , world_chunk_ptr_paged_list* DrawList , shader* Shader + , octree_node_ptr_block_array* DrawList , shader* Shader , camera* Camera ) { work_queue_entry Work = WorkQueueEntry( - WorkQueueEntryBonsaiRenderCommand( BonsaiRenderCommandDrawWorldChunkDrawList( DrawList , Shader ))); + WorkQueueEntryBonsaiRenderCommand( BonsaiRenderCommandDrawWorldChunkDrawList( DrawList , Shader , Camera ))); PushWorkQueueEntry(RenderQueue, &Work); } link_internal void PushBonsaiRenderCommandDrawAllEntities( work_queue *RenderQueue - , shader* Shader + , shader* Shader ) { work_queue_entry Work = WorkQueueEntry( - WorkQueueEntryBonsaiRenderCommand( BonsaiRenderCommandDrawAllEntities( Shader ))); + WorkQueueEntryBonsaiRenderCommand( BonsaiRenderCommandDrawAllEntities( Shader ))); PushWorkQueueEntry(RenderQueue, &Work); } link_internal void PushBonsaiRenderCommandGlTimerInit( work_queue *RenderQueue - , u32* GlTimerObject + , u32* GlTimerObject ) { work_queue_entry Work = WorkQueueEntry( - WorkQueueEntryBonsaiRenderCommand( BonsaiRenderCommandGlTimerInit( GlTimerObject ))); + WorkQueueEntryBonsaiRenderCommand( BonsaiRenderCommandGlTimerInit( GlTimerObject ))); PushWorkQueueEntry(RenderQueue, &Work); } link_internal void PushBonsaiRenderCommandGlTimerStart( work_queue *RenderQueue - , u32 GlTimerObject + , u32 GlTimerObject ) { work_queue_entry Work = WorkQueueEntry( - WorkQueueEntryBonsaiRenderCommand( BonsaiRenderCommandGlTimerStart( GlTimerObject ))); + WorkQueueEntryBonsaiRenderCommand( BonsaiRenderCommandGlTimerStart( GlTimerObject ))); PushWorkQueueEntry(RenderQueue, &Work); } link_internal void PushBonsaiRenderCommandGlTimerEnd( work_queue *RenderQueue - , u32 GlTimerObject + , u32 GlTimerObject ) { work_queue_entry Work = WorkQueueEntry( - WorkQueueEntryBonsaiRenderCommand( BonsaiRenderCommandGlTimerEnd( GlTimerObject ))); + WorkQueueEntryBonsaiRenderCommand( BonsaiRenderCommandGlTimerEnd( GlTimerObject ))); PushWorkQueueEntry(RenderQueue, &Work); } link_internal void PushBonsaiRenderCommandGlTimerReadValueAndHistogram( work_queue *RenderQueue - , u32 GlTimerObject + , u32 GlTimerObject ) { work_queue_entry Work = WorkQueueEntry( - WorkQueueEntryBonsaiRenderCommand( BonsaiRenderCommandGlTimerReadValueAndHistogram( GlTimerObject ))); + WorkQueueEntryBonsaiRenderCommand( BonsaiRenderCommandGlTimerReadValueAndHistogram( GlTimerObject ))); PushWorkQueueEntry(RenderQueue, &Work); } +link_internal void +PushBonsaiRenderCommandCancelAllNoiseReadbackJobs( + work_queue *RenderQueue + +) +{ + work_queue_entry Work = WorkQueueEntry( + WorkQueueEntryBonsaiRenderCommand( BonsaiRenderCommandCancelAllNoiseReadbackJobs( ))); + + PushWorkQueueEntry(RenderQueue, &Work); +} + 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 deleted file mode 100644 index 0af0d431a..000000000 --- a/generated/radio_button_group_for_bitfield_enum_level_editor_flags.h +++ /dev/null @@ -1,26 +0,0 @@ -// src/engine/editor.h:533:0 - -link_internal ui_toggle_button_group -RadioButtonGroup_level_editor_flags( renderer_2d *Ui, - window_layout *Window, - cs GroupName, - level_editor_flags *Element, - ui_render_params *Params = &DefaultUiRenderParams_Generic, - ui_toggle_button_group_flags ExtraFlags = ToggleButtonGroupFlags_None) -{ - ui_toggle_button_handle ButtonHandles[] = - { - { CSz("Noop"), UiId(Window, Cast(void*, Element), Cast(void*, "level_editor_flags LevelEditorFlags_Noop")), LevelEditorFlags_Noop }, - - }; - - ui_toggle_button_handle_buffer ButtonBuffer = { - ArrayCount(ButtonHandles), - ButtonHandles - }; - - ui_toggle_button_group Result = DrawButtonGroupForEnum(Ui, &ButtonBuffer, GroupName, Cast(u32*, Element), Params, ui_toggle_button_group_flags(ExtraFlags|ToggleButtonGroupFlags_RadioButtons)); - return Result; -} - - diff --git a/generated/radio_button_group_for_bitfield_enum_terrain_gen_type.h b/generated/radio_button_group_for_bitfield_enum_terrain_gen_type.h deleted file mode 100644 index 50c8db321..000000000 --- a/generated/radio_button_group_for_bitfield_enum_terrain_gen_type.h +++ /dev/null @@ -1,40 +0,0 @@ -// examples/terrain_gen/game_types.h:23:0 - -link_internal ui_toggle_button_group -RadioButtonGroup_terrain_gen_type( renderer_2d *Ui, - window_layout *Window, - cs GroupName, - terrain_gen_type *Element, - ui_render_params *Params = &DefaultUiRenderParams_Generic, - ui_toggle_button_group_flags ExtraFlags = ToggleButtonGroupFlags_None) -{ - ui_toggle_button_handle ButtonHandles[] = - { - { CSz("Flat"), UiId(Window, Cast(void*, Element), Cast(void*, "terrain_gen_type TerrainGenType_Flat")), TerrainGenType_Flat }, - { CSz("Checkerboard"), UiId(Window, Cast(void*, Element), Cast(void*, "terrain_gen_type TerrainGenType_Checkerboard")), TerrainGenType_Checkerboard }, - { CSz("SinCos"), UiId(Window, Cast(void*, Element), Cast(void*, "terrain_gen_type TerrainGenType_SinCos")), TerrainGenType_SinCos }, - { CSz("Voronoi"), UiId(Window, Cast(void*, Element), Cast(void*, "terrain_gen_type TerrainGenType_Voronoi")), TerrainGenType_Voronoi }, - { CSz("Perlin2D"), UiId(Window, Cast(void*, Element), Cast(void*, "terrain_gen_type TerrainGenType_Perlin2D")), TerrainGenType_Perlin2D }, - { CSz("Perlin3D"), UiId(Window, Cast(void*, Element), Cast(void*, "terrain_gen_type TerrainGenType_Perlin3D")), TerrainGenType_Perlin3D }, - { CSz("FBM2D"), UiId(Window, Cast(void*, Element), Cast(void*, "terrain_gen_type TerrainGenType_FBM2D")), TerrainGenType_FBM2D }, - { CSz("TerracedTerrain"), UiId(Window, Cast(void*, Element), Cast(void*, "terrain_gen_type TerrainGenType_TerracedTerrain")), TerrainGenType_TerracedTerrain }, - { CSz("GrassyTerracedTerrain"), UiId(Window, Cast(void*, Element), Cast(void*, "terrain_gen_type TerrainGenType_GrassyTerracedTerrain")), TerrainGenType_GrassyTerracedTerrain }, - { CSz("GrassyLargeTerracedTerrain"), UiId(Window, Cast(void*, Element), Cast(void*, "terrain_gen_type TerrainGenType_GrassyLargeTerracedTerrain")), TerrainGenType_GrassyLargeTerracedTerrain }, - { CSz("GrassyTerracedTerrain2"), UiId(Window, Cast(void*, Element), Cast(void*, "terrain_gen_type TerrainGenType_GrassyTerracedTerrain2")), TerrainGenType_GrassyTerracedTerrain2 }, - { CSz("GrassyTerracedTerrain3"), UiId(Window, Cast(void*, Element), Cast(void*, "terrain_gen_type TerrainGenType_GrassyTerracedTerrain3")), TerrainGenType_GrassyTerracedTerrain3 }, - { CSz("GrassyTerracedTerrain4"), UiId(Window, Cast(void*, Element), Cast(void*, "terrain_gen_type TerrainGenType_GrassyTerracedTerrain4")), TerrainGenType_GrassyTerracedTerrain4 }, - { CSz("GrassyIsland"), UiId(Window, Cast(void*, Element), Cast(void*, "terrain_gen_type TerrainGenType_GrassyIsland")), TerrainGenType_GrassyIsland }, - { CSz("Hoodoo"), UiId(Window, Cast(void*, Element), Cast(void*, "terrain_gen_type TerrainGenType_Hoodoo")), TerrainGenType_Hoodoo }, - { CSz("Warped"), UiId(Window, Cast(void*, Element), Cast(void*, "terrain_gen_type TerrainGenType_Warped")), TerrainGenType_Warped }, - }; - - ui_toggle_button_handle_buffer ButtonBuffer = { - ArrayCount(ButtonHandles), - ButtonHandles - }; - - ui_toggle_button_group Result = DrawButtonGroupForEnum(Ui, &ButtonBuffer, GroupName, Cast(u32*, Element), Params, ui_toggle_button_group_flags(ExtraFlags|ToggleButtonGroupFlags_RadioButtons)); - return Result; -} - - 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 7bf5b2f09..fd5b7b71f 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,11 @@ -// src/engine/editor.h:545:0 +// src/engine/editor.h:150:0 +link_internal void +RadioSelect(ui_toggle_button_group *RadioGroup, ui_noise_type Selection) +{ + ui_toggle_button_handle *ToggleHandle = RadioGroup->Buttons.Start + Selection; + SetRadioButton(RadioGroup, ToggleHandle, True); + /* Ensure( ToggleRadioButton(RadioGroup, ToggleHandle) ); */ +} link_internal ui_toggle_button_group RadioButtonGroup_ui_noise_type( renderer_2d *Ui, @@ -10,9 +17,10 @@ RadioButtonGroup_ui_noise_type( renderer_2d *Ui, { ui_toggle_button_handle ButtonHandles[] = { - { CSz("Perlin"), UiId(Window, Cast(void*, Element), Cast(void*, "ui_noise_type NoiseType_Perlin")), NoiseType_Perlin }, - { CSz("Voronoi"), UiId(Window, Cast(void*, Element), Cast(void*, "ui_noise_type NoiseType_Voronoi")), NoiseType_Voronoi }, - { CSz("White"), UiId(Window, Cast(void*, Element), Cast(void*, "ui_noise_type NoiseType_White")), NoiseType_White }, + { CSz("Perlin"), {}, UiId(Window, Cast(void*, Element), Cast(void*, "ui_noise_type NoiseType_Perlin")), NoiseType_Perlin }, + { CSz("Voronoi"), {}, UiId(Window, Cast(void*, Element), Cast(void*, "ui_noise_type NoiseType_Voronoi")), NoiseType_Voronoi }, + { CSz("White"), {}, UiId(Window, Cast(void*, Element), Cast(void*, "ui_noise_type NoiseType_White")), NoiseType_White }, + }; ui_toggle_button_handle_buffer ButtonBuffer = { @@ -20,8 +28,9 @@ RadioButtonGroup_ui_noise_type( renderer_2d *Ui, ButtonHandles }; - ui_toggle_button_group Result = DrawButtonGroupForEnum(Ui, &ButtonBuffer, GroupName, Cast(u32*, Element), Params, ui_toggle_button_group_flags(ExtraFlags|ToggleButtonGroupFlags_RadioButtons)); + ui_toggle_button_group Result = DrawButtonGroupForEnum(Ui, &ButtonBuffer, GroupName, Cast(u32*, Element), Params, ui_toggle_button_group_flags(ExtraFlags|ToggleButtonGroupFlags_TypeRadioButton)); return Result; } + diff --git a/generated/rectalinear_iteration_pattern_398799212.h b/generated/rectalinear_iteration_pattern_398799212.h deleted file mode 100644 index 7b3122148..000000000 --- a/generated/rectalinear_iteration_pattern_398799212.h +++ /dev/null @@ -1,49 +0,0 @@ -// src/engine/world_update.cpp:580:0 - -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)) - { - - - 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; - } - } - - - 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); - } - } -} - - diff --git a/generated/rectalinear_iteration_pattern_416827956.h b/generated/rectalinear_iteration_pattern_416827956.h deleted file mode 100644 index f209ab38d..000000000 --- a/generated/rectalinear_iteration_pattern_416827956.h +++ /dev/null @@ -1,38 +0,0 @@ -// src/engine/world_update.cpp:751:0 - -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)) - { - - OverwriteVoxel = True; - - - 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); - } - } -} - - diff --git a/generated/rectalinear_iteration_pattern_428632106.h b/generated/rectalinear_iteration_pattern_428632106.h deleted file mode 100644 index d87ba0cdf..000000000 --- a/generated/rectalinear_iteration_pattern_428632106.h +++ /dev/null @@ -1,45 +0,0 @@ -// src/engine/world_update.cpp:902:0 - -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)) - { - - v3i OriginToCurrentVoxP = SimVoxP - SimOrigin; - voxel *AssetV = TryGetVoxel(Data, OriginToCurrentVoxP); - voxel *NewVoxelValue = &InvertV; - if ( (AssetV && (AssetV->Flags&Voxel_Filled)) || Params->PersistWhitespace ) - { - NewVoxelValue = AssetV; - OverwriteVoxel = True; - } - - - 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); - } - } -} - - diff --git a/generated/rectalinear_iteration_pattern_530902269.h b/generated/rectalinear_iteration_pattern_530902269.h deleted file mode 100644 index 97e6de798..000000000 --- a/generated/rectalinear_iteration_pattern_530902269.h +++ /dev/null @@ -1,41 +0,0 @@ -// src/engine/world_update.cpp:699:0 - -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)) - { - - if ( (V->Flags&VoxelFaceMask)) - { - OverwriteVoxel = True; - } - - - 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); - } - } -} - - diff --git a/generated/rectalinear_iteration_pattern_583358156.h b/generated/rectalinear_iteration_pattern_583358156.h deleted file mode 100644 index fedc9869b..000000000 --- a/generated/rectalinear_iteration_pattern_583358156.h +++ /dev/null @@ -1,40 +0,0 @@ -// src/engine/world_update.cpp:876:0 - -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)) - { - - v3i OriginToCurrentVoxP = SimVoxP - SimOrigin; - voxel *NewVoxelValue = TryGetVoxel(Data, OriginToCurrentVoxP); - if (NewVoxelValue && (NewVoxelValue->Flags&Voxel_Filled)) { V->Color = NewVoxelValue->Color; } - - - 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); - } - } -} - - diff --git a/generated/rectalinear_iteration_pattern_631222419.h b/generated/rectalinear_iteration_pattern_631222419.h deleted file mode 100644 index 62f7a278f..000000000 --- a/generated/rectalinear_iteration_pattern_631222419.h +++ /dev/null @@ -1,50 +0,0 @@ -// src/engine/world_update.cpp:792:0 - -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)) - { - - - 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; - } - } - - - 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); - } - } -} - - diff --git a/generated/rectalinear_iteration_pattern_643608995.h b/generated/rectalinear_iteration_pattern_643608995.h deleted file mode 100644 index d99cbaea6..000000000 --- a/generated/rectalinear_iteration_pattern_643608995.h +++ /dev/null @@ -1,48 +0,0 @@ -// src/engine/world_update.cpp:680:0 - -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)) - { - - - if ((V->Flags&Voxel_Filled) == False) - { - b32 IsUnfilledBorder = False; - poof_check_for_unfilled_border() - Assert(NewVoxelValue->Flags & Voxel_Filled); - if (IsUnfilledBorder) - { - OverwriteVoxel = True; - } - } - - - 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); - } - } -} - - diff --git a/generated/rectalinear_iteration_pattern_812652930.h b/generated/rectalinear_iteration_pattern_812652930.h index 210867881..81fdc2fe0 100644 --- a/generated/rectalinear_iteration_pattern_812652930.h +++ b/generated/rectalinear_iteration_pattern_812652930.h @@ -1,42 +1,37 @@ -// src/engine/world_update.cpp:652:0 +// src/engine/world_update.cpp:310:0 +NotImplemented; +/* DimIterator(x, y, z, UpdateDim) */ +/* { */ +/* b32 OverwriteVoxel = False; */ -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); */ - v3i VoxP = V3i(x,y,z); - v3i SimVoxP = VoxP + SimSpaceUpdateBounds.Min; - voxel *V = CopiedChunk->Voxels + GetIndex(VoxP, UpdateDim); +/* if (Contains(SSRect, SimVoxP)) */ +/* { */ +/* UserCode */ - if (Contains(SSRect, SimVoxP)) - { - - v3i CenterToVoxP = SimVoxP - EditCenterP; - if (LengthSq(CenterToVoxP) < RadiusSquared) - { - OverwriteVoxel = True; - } - +/* if ( ((OverwriteVoxel == True ) && (Invert == False)) || */ +/* ((OverwriteVoxel == False) && (Invert == True )) ) */ +/* { */ +/* /1* if (Mode == WorldEdit_Mode_Paint) *1/ */ +/* /1* { *1/ */ +/* /1* V->Color = NewVoxelValue->Color; *1/ */ +/* /1* } *1/ */ +/* /1* else *1/ */ +/* { */ +/* if (Mode == WorldEdit_Mode_Subtractive) { *V = {}; } */ +/* else { *V = *NewVoxelValue; } */ +/* } */ - 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); - } - } -} +/* // 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. */ +/* NotImplemented; */ +/* /1* V->Flags = voxel_flag(V->Flags&~VoxelFaceMask); *1/ */ +/* } */ +/* } */ +/* } */ diff --git a/generated/rectalinear_iteration_pattern_920026661.h b/generated/rectalinear_iteration_pattern_920026661.h deleted file mode 100644 index f45e49756..000000000 --- a/generated/rectalinear_iteration_pattern_920026661.h +++ /dev/null @@ -1,42 +0,0 @@ -// src/engine/world_update.cpp:600:0 - -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)) - { - - v3i CenterToVoxP = SimVoxP - EditCenterP; - if (LengthSq(CenterToVoxP) < RadiusSquared && (V->Flags&VoxelFaceMask)) - { - OverwriteVoxel = True; - } - - - 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); - } - } -} - - diff --git a/generated/rectalinear_iteration_pattern_992879728.h b/generated/rectalinear_iteration_pattern_992879728.h deleted file mode 100644 index cfcfc5648..000000000 --- a/generated/rectalinear_iteration_pattern_992879728.h +++ /dev/null @@ -1,46 +0,0 @@ -// src/engine/world_update.cpp:813:0 - -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)) - { - - v3i OriginToCurrentVoxP = SimVoxP - SimOrigin; - voxel *NewVoxelValue = TryGetVoxel(Data, OriginToCurrentVoxP); - if (NewVoxelValue) - { - if ( (V->Flags&VoxelFaceMask) && (NewVoxelValue->Flags&Voxel_Filled) ) - { - OverwriteVoxel = True; - } - } - - - 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); - } - } -} - - diff --git a/generated/rectalinear_iteration_pattern_99934950.h b/generated/rectalinear_iteration_pattern_99934950.h deleted file mode 100644 index 3c702c01f..000000000 --- a/generated/rectalinear_iteration_pattern_99934950.h +++ /dev/null @@ -1,41 +0,0 @@ -// src/engine/world_update.cpp:759:0 - -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)) - { - - if (V->Flags & Voxel_Filled) - { - OverwriteVoxel = True; - } - - - 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); - } - } -} - - diff --git a/generated/scalar_math_fuctions_451039071.h b/generated/scalar_math_fuctions_451039071.h index e595d7de3..007f80d75 100644 --- a/generated/scalar_math_fuctions_451039071.h +++ b/generated/scalar_math_fuctions_451039071.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/maff.h:367:0 - +// external/bonsai_stdlib/src/maff.h:371:0 inline r32 Clamp( r32 Min, r32 Value, r32 Max ) { @@ -43,3 +42,4 @@ Clamp( s64 Min, s64 Value, s64 Max ) return Value; } + diff --git a/generated/serdes_collection_world_edit_block_array_index_block_array.h b/generated/serdes_collection_world_edit_block_array_index_block_array.h new file mode 100644 index 000000000..f3e5bd8b9 --- /dev/null +++ b/generated/serdes_collection_world_edit_block_array_index_block_array.h @@ -0,0 +1,37 @@ +// src/engine/serdes.h:454:0 + + +link_internal b32 +Serialize( u8_cursor_block_array *Bytes, world_edit_block_array_index_block_array *Collection) +{ + auto i = AtElements(Collection); + u64 ElementCount = u64(GetIndex(&i)); + b32 Result = Write(Bytes, ElementCount); + + IterateOver(Collection, Element, EIndex) + { + Result &= Serialize(Bytes, Element); + } + + MAYBE_WRITE_DEBUG_OBJECT_DELIM(); + return Result; +} + +link_internal b32 +Deserialize( u8_cursor *Bytes, world_edit_block_array_index_block_array *Collection, memory_arena *Memory) +{ + u64 ElementCount = Read_u64(Bytes); + Collection->Memory = Memory; + + b32 Result = True; + RangeIterator_t(u64, EIndex, ElementCount) + { + world_edit_block_array_index Element = {}; + Result &= Deserialize(Bytes, &Element, Memory); + Push(Collection, &Element); + } + + MAYBE_READ_DEBUG_OBJECT_DELIM(); + return Result; +} + diff --git a/generated/serdes_cursor_v3.h b/generated/serdes_cursor_v3.h index c273eab80..e5c31e6f0 100644 --- a/generated/serdes_cursor_v3.h +++ b/generated/serdes_cursor_v3.h @@ -1,5 +1,4 @@ -// src/engine/serdes.cpp:21:0 - +// src/engine/serdes.h:416:0 link_internal b32 Serialize(u8_cursor_block_array *Bytes, v3_cursor* Cursor) { diff --git a/generated/serdes_primitive_592771169.h b/generated/serdes_primitive_592771169.h index c2c1a2b5b..cefab50c2 100644 --- a/generated/serdes_primitive_592771169.h +++ b/generated/serdes_primitive_592771169.h @@ -1,5 +1,4 @@ -// src/engine/serdes.h:490:0 - +// src/engine/serdes.h:56:0 link_internal b32 Serialize(u8_cursor_block_array *Bytes, u8 *Element, umm Count = 1) { @@ -243,3 +242,4 @@ Deserialize(u8_cursor *Bytes, r64 *Element, memory_arena *Ignored = 0, umm Count /* serdes_array(type) */ + diff --git a/generated/serdes_primitive_85387614.h b/generated/serdes_primitive_85387614.h index ccd79d971..450f6f0f6 100644 --- a/generated/serdes_primitive_85387614.h +++ b/generated/serdes_primitive_85387614.h @@ -1,5 +1,4 @@ -// src/engine/serdes.cpp:18:0 - +// src/engine/serdes.h:56:0 link_internal b32 Serialize(u8_cursor_block_array *Bytes, chunk_flag *Element, umm Count = 1) { @@ -23,3 +22,4 @@ Deserialize(u8_cursor *Bytes, chunk_flag *Element, memory_arena *Ignored = 0, um /* serdes_array(type) */ + diff --git a/generated/serdes_struct_bonsai_type_info.h b/generated/serdes_struct_bonsai_type_info.h index 239c6236c..451ea1bb2 100644 --- a/generated/serdes_struct_bonsai_type_info.h +++ b/generated/serdes_struct_bonsai_type_info.h @@ -1,12 +1,11 @@ -// src/engine/serdes.cpp:434:0 - +// src/engine/serdes.h:495:0 link_internal bonsai_type_info TypeInfo(bonsai_type_info *Ignored) { bonsai_type_info Result = {}; Result.Name = CSz("bonsai_type_info"); - Result.Version = 0 ; + Result.Version = 0 ; /* type.map(member) */ /* { */ @@ -24,7 +23,7 @@ Serialize(u8_cursor_block_array *Bytes, bonsai_type_info *BaseElement, umm Count { Assert(Count > 0); - u64 PointerTrue = True; + u64 PointerTrue = True; u64 PointerFalse = False; b32 Result = True; @@ -34,21 +33,36 @@ Serialize(u8_cursor_block_array *Bytes, bonsai_type_info *BaseElement, umm Count RangeIterator_t(umm, ElementIndex, Count) { bonsai_type_info *Element = BaseElement + ElementIndex; - Result &= Serialize(Bytes, &Element->Name); + Result &= Serialize(Bytes, &Element->Name); // default - Result &= Serialize(Bytes, &Element->Version); + Result &= Serialize(Bytes, &Element->Version); // default - Result &= Serialize(Bytes, &Element->SizeOfInBytes); - + + Result &= Serialize(Bytes, &Element->SizeOfInBytes); // default + + + + + + + + + + + + + + + MAYBE_WRITE_DEBUG_OBJECT_DELIM(); } @@ -69,7 +83,7 @@ link_internal b32 DeserializeCurrentVersion(u8_cursor *Bytes, bonsai_type_info *Element, memory_arena *Memory) { b32 Result = True; - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Name, Memory); @@ -77,7 +91,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, bonsai_type_info *Element, memory_ar - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Version, Memory); @@ -85,12 +99,21 @@ DeserializeCurrentVersion(u8_cursor *Bytes, bonsai_type_info *Element, memory_ar - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->SizeOfInBytes, Memory); + + + + + + + + + MAYBE_READ_DEBUG_OBJECT_DELIM(); return Result; } @@ -103,7 +126,7 @@ Deserialize(u8_cursor *Bytes, bonsai_type_info *Element, memory_arena *Memory, u b32 Result = True; RangeIterator_t(umm, ElementIndex, Count) { - Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); + Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); } diff --git a/generated/serdes_struct_bonsai_type_info_buffer.h b/generated/serdes_struct_bonsai_type_info_buffer.h index 75372b42e..af5a72f45 100644 --- a/generated/serdes_struct_bonsai_type_info_buffer.h +++ b/generated/serdes_struct_bonsai_type_info_buffer.h @@ -1,12 +1,11 @@ -// src/engine/serdes.cpp:436:0 - +// src/engine/serdes.h:495:0 link_internal bonsai_type_info TypeInfo(bonsai_type_info_buffer *Ignored) { bonsai_type_info Result = {}; Result.Name = CSz("bonsai_type_info_buffer"); - Result.Version = 0 ; + Result.Version = 0 ; /* type.map(member) */ /* { */ @@ -24,7 +23,7 @@ Serialize(u8_cursor_block_array *Bytes, bonsai_type_info_buffer *BaseElement, um { Assert(Count > 0); - u64 PointerTrue = True; + u64 PointerTrue = True; u64 PointerFalse = False; b32 Result = True; @@ -34,16 +33,27 @@ Serialize(u8_cursor_block_array *Bytes, bonsai_type_info_buffer *BaseElement, um RangeIterator_t(umm, ElementIndex, Count) { bonsai_type_info_buffer *Element = BaseElement + ElementIndex; - Result &= Serialize(Bytes, &Element->Count); + Result &= Serialize(Bytes, &Element->Count); // default + - if (Element->Start) { Result &= Write(Bytes, Cast(u8*, &PointerTrue), sizeof(PointerTrue)); } + if (Element->Start) { Result &= Write(Bytes, Cast(u8*, &PointerTrue), sizeof(PointerTrue)); } else { Result &= Write(Bytes, Cast(u8*, &PointerFalse), sizeof(PointerFalse)); } - if (Element->Start) { Result &= Serialize(Bytes, Element->Start,Element->Count ); } + + + + + + + if (Element->Start) { Result &= Serialize(Bytes, Element->Start, Element->Count ); } + + + + MAYBE_WRITE_DEBUG_OBJECT_DELIM(); } @@ -64,7 +74,7 @@ link_internal b32 DeserializeCurrentVersion(u8_cursor *Bytes, bonsai_type_info_buffer *Element, memory_arena *Memory) { b32 Result = True; - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Count, Memory); @@ -72,12 +82,17 @@ DeserializeCurrentVersion(u8_cursor *Bytes, bonsai_type_info_buffer *Element, me - b64 HadStartPointer = Read_u64(Bytes); + b64 HadStartPointer = Read_u64(Bytes); Assert(HadStartPointer < 2); // Should be 0 or 1 - if (HadStartPointer) + + + + + + if (HadStartPointer) { - umm Count =Element->Count; + umm Count = Element->Count; if (Element->Start == 0) @@ -88,6 +103,9 @@ DeserializeCurrentVersion(u8_cursor *Bytes, bonsai_type_info_buffer *Element, me Result &= Deserialize(Bytes, Element->Start, Memory, Count); } + + + MAYBE_READ_DEBUG_OBJECT_DELIM(); return Result; } @@ -100,7 +118,7 @@ Deserialize(u8_cursor *Bytes, bonsai_type_info_buffer *Element, memory_arena *Me b32 Result = True; RangeIterator_t(umm, ElementIndex, Count) { - Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); + Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); } diff --git a/generated/serdes_struct_brush_layer.h b/generated/serdes_struct_brush_layer.h index 7411c3da9..7ea5c54ae 100644 --- a/generated/serdes_struct_brush_layer.h +++ b/generated/serdes_struct_brush_layer.h @@ -1,12 +1,11 @@ -// src/engine/serdes.cpp:548:0 - +// src/engine/serdes.h:495:0 link_internal bonsai_type_info TypeInfo(brush_layer *Ignored) { bonsai_type_info Result = {}; Result.Name = CSz("brush_layer"); - Result.Version = 0 ; + Result.Version = 0 ; /* type.map(member) */ /* { */ @@ -24,7 +23,7 @@ Serialize(u8_cursor_block_array *Bytes, brush_layer *BaseElement, umm Count = 1) { Assert(Count > 0); - u64 PointerTrue = True; + u64 PointerTrue = True; u64 PointerFalse = False; b32 Result = True; @@ -34,15 +33,20 @@ Serialize(u8_cursor_block_array *Bytes, brush_layer *BaseElement, umm Count = 1) RangeIterator_t(umm, ElementIndex, Count) { brush_layer *Element = BaseElement + ElementIndex; - Result &= Serialize(Bytes, &Element->Settings); + Result &= Serialize(Bytes, &Element->Settings); // default + + + + + + - MAYBE_WRITE_DEBUG_OBJECT_DELIM(); } @@ -63,7 +67,7 @@ link_internal b32 DeserializeCurrentVersion(u8_cursor *Bytes, brush_layer *Element, memory_arena *Memory) { b32 Result = True; - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Settings, Memory); @@ -71,10 +75,13 @@ DeserializeCurrentVersion(u8_cursor *Bytes, brush_layer *Element, memory_arena * + + + MAYBE_READ_DEBUG_OBJECT_DELIM(); return Result; } @@ -87,7 +94,7 @@ Deserialize(u8_cursor *Bytes, brush_layer *Element, memory_arena *Memory, umm Co b32 Result = True; RangeIterator_t(umm, ElementIndex, Count) { - Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); + Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); } diff --git a/generated/serdes_struct_brush_settings.h b/generated/serdes_struct_brush_settings.h index e364c6a8e..c3baa0990 100644 --- a/generated/serdes_struct_brush_settings.h +++ b/generated/serdes_struct_brush_settings.h @@ -1,12 +1,11 @@ -// src/engine/serdes.cpp:545:0 - +// src/engine/serdes.h:495:0 link_internal bonsai_type_info TypeInfo(brush_settings *Ignored) { bonsai_type_info Result = {}; Result.Name = CSz("brush_settings"); - Result.Version =3 ; + Result.Version = 0 ; /* type.map(member) */ /* { */ @@ -24,73 +23,137 @@ Serialize(u8_cursor_block_array *Bytes, brush_settings *BaseElement, umm Count = { Assert(Count > 0); - u64 PointerTrue = True; + u64 PointerTrue = True; u64 PointerFalse = False; b32 Result = True; - Upsert(TypeInfo(BaseElement), &Global_SerializeTypeTable, Global_SerializeTypeTableArena ); - u64 VersionNumber =3; - Serialize(Bytes, &VersionNumber); - + RangeIterator_t(umm, ElementIndex, Count) { brush_settings *Element = BaseElement + ElementIndex; - Result &= Serialize(Bytes, (u32*)&Element->Type); + Result &= Serialize(Bytes, (u32*)&Element->Type); // enum - Result &= Serialize(Bytes, &Element->Noise); + Result &= Serialize(Bytes, &Element->Noise); // default - Result &= Serialize(Bytes, &Element->Shape); + Result &= Serialize(Bytes, &Element->Shape); // default - Result &= Serialize(Bytes, (u32*)&Element->Mode); + Result &= Serialize(Bytes, &Element->Power); // default - Result &= Serialize(Bytes, (u32*)&Element->Modifier); - Result &= Serialize(Bytes, &Element->Iterations); + Result &= Serialize(Bytes, &Element->ValueBias); // default - Result &= Serialize(Bytes, &Element->Offset); + Result &= Serialize(Bytes, &Element->Threshold); // default - Result &= Serialize(Bytes, &Element->NoiseBasisOffset); + Result &= Serialize(Bytes, (u32*)&Element->ValueModifier); // enum - Result &= Serialize(Bytes, &Element->RGBColor); + Result &= Serialize(Bytes, (u32*)&Element->BlendMode); // enum - Result &= Serialize(Bytes, &Element->Invert); + Result &= Serialize(Bytes, (u32*)&Element->ColorMode); // enum + + + + + Result &= Serialize(Bytes, &Element->Invert); // default + + + + + + + Result &= Serialize(Bytes, &Element->Iterations); // default + + + + + + + Result &= Serialize(Bytes, &Element->Offset); // default + + + + + + + Result &= Serialize(Bytes, &Element->NoiseBasisOffset); // default + + + + + + + Result &= Serialize(Bytes, &Element->HSVColor); // default + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - MAYBE_WRITE_DEBUG_OBJECT_DELIM(); } @@ -105,78 +168,81 @@ link_internal b32 DeserializeCurrentVersion(u8_cursor *Bytes, brush_settings *Element, memory_arena *Memory); + + link_internal b32 -DeserializeVersioned(u8_cursor *Bytes, brush_settings *Element, bonsai_type_info *TypeInfo, memory_arena *Memory) +DeserializeCurrentVersion(u8_cursor *Bytes, brush_settings *Element, memory_arena *Memory) { - Assert(TypeInfo->Version <=3); - b32 Result = True; + Element->Type = Cast(brush_layer_type, Read_u32(Bytes)); - if (TypeInfo->Version == 0) - { - brush_settings_0 T0 = {}; - Result &= Deserialize(Bytes, &T0, Memory); - Marshal(&T0, Element); - } - if (TypeInfo->Version == 1) - { - brush_settings_1 T1 = {}; - Result &= Deserialize(Bytes, &T1, Memory); - Marshal(&T1, Element); - } - if (TypeInfo->Version == 2) - { - brush_settings_2 T2 = {}; - Result &= Deserialize(Bytes, &T2, Memory); - Marshal(&T2, Element); - } - if (TypeInfo->Version ==3) - { - Result &= DeserializeCurrentVersion(Bytes, Element, Memory); - } - return Result; -} + // NOTE(Jesse): Unfortunately we can't check for primitives because + // strings are considered primitive, but need memory to deserialize + Result &= Deserialize(Bytes, &Element->Noise, Memory); -link_internal b32 -DeserializeCurrentVersion(u8_cursor *Bytes, brush_settings *Element, memory_arena *Memory) -{ - b32 Result = True; - Element->Type = Cast(brush_layer_type, Read_u32(Bytes)); + + + + // NOTE(Jesse): Unfortunately we can't check for primitives because + // strings are considered primitive, but need memory to deserialize + Result &= Deserialize(Bytes, &Element->Shape, Memory); + - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->Noise, Memory); + Result &= Deserialize(Bytes, &Element->Power, Memory); - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->Shape, Memory); + Result &= Deserialize(Bytes, &Element->ValueBias, Memory); + + + + + + // NOTE(Jesse): Unfortunately we can't check for primitives because + // strings are considered primitive, but need memory to deserialize + Result &= Deserialize(Bytes, &Element->Threshold, Memory); + + + + Element->ValueModifier = Cast(world_edit_blend_mode_modifier, Read_u32(Bytes)); - Element->Mode = Cast(world_edit_mode, Read_u32(Bytes)); + Element->BlendMode = Cast(world_edit_blend_mode, Read_u32(Bytes)); - Element->Modifier = Cast(world_edit_mode_modifier, Read_u32(Bytes)); + Element->ColorMode = Cast(world_edit_color_blend_mode, Read_u32(Bytes)); - // NOTE(Jesse): Unfortunately we can't check for primitives because + + // NOTE(Jesse): Unfortunately we can't check for primitives because + // strings are considered primitive, but need memory to deserialize + Result &= Deserialize(Bytes, &Element->Invert, Memory); + + + + + + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Iterations, Memory); @@ -184,7 +250,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, brush_settings *Element, memory_aren - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Offset, Memory); @@ -192,7 +258,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, brush_settings *Element, memory_aren - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->NoiseBasisOffset, Memory); @@ -200,19 +266,31 @@ DeserializeCurrentVersion(u8_cursor *Bytes, brush_settings *Element, memory_aren - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->RGBColor, Memory); + Result &= Deserialize(Bytes, &Element->HSVColor, Memory); + - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->Invert, Memory); + + + + + + + + + + + + + + MAYBE_READ_DEBUG_OBJECT_DELIM(); return Result; @@ -226,22 +304,7 @@ Deserialize(u8_cursor *Bytes, brush_settings *Element, memory_arena *Memory, umm b32 Result = True; RangeIterator_t(umm, ElementIndex, Count) { - maybe_bonsai_type_info MaybeSerializedType = GetByName(&Global_SerializeTypeTable, CSz("brush_settings")); - - if (MaybeSerializedType.Tag) - { - u64 OldIgnoredVersionNumber; - if (MaybeSerializedType.Value.Version > 0) - { - Deserialize(Bytes, &OldIgnoredVersionNumber, Memory); - } - Result &= DeserializeVersioned(Bytes, Element+ElementIndex, &MaybeSerializedType.Value, Memory); - } - else - { - bonsai_type_info T0TypeInfo = {}; - Result &= DeserializeVersioned(Bytes, Element+ElementIndex, &T0TypeInfo, Memory); - } + Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); } diff --git a/generated/serdes_struct_brush_settings_0.h b/generated/serdes_struct_brush_settings_0.h deleted file mode 100644 index 1fd30ef5d..000000000 --- a/generated/serdes_struct_brush_settings_0.h +++ /dev/null @@ -1,171 +0,0 @@ -// src/engine/serdes.cpp:539:0 - -link_internal bonsai_type_info -TypeInfo(brush_settings_0 *Ignored) -{ - bonsai_type_info Result = {}; - - Result.Name = CSz("brush_settings_0"); - 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, brush_settings_0 *BaseElement, umm Count = 1) -{ - Assert(Count > 0); - - u64 PointerTrue = True; - u64 PointerFalse = False; - - b32 Result = True; - - - - RangeIterator_t(umm, ElementIndex, Count) - { - brush_settings_0 *Element = BaseElement + ElementIndex; - Result &= Serialize(Bytes, (u32*)&Element->Type); - - - - - Result &= Serialize(Bytes, &Element->Noise); - - - - - - Result &= Serialize(Bytes, &Element->Shape); - - - - - - Result &= Serialize(Bytes, (u32*)&Element->Mode); - - - - - Result &= Serialize(Bytes, (u32*)&Element->Modifier); - - - - - Result &= Serialize(Bytes, &Element->Iterations); - - - - - - Result &= Serialize(Bytes, &Element->Offset); - - - - - - Result &= Serialize(Bytes, &Element->Color); - - - - MAYBE_WRITE_DEBUG_OBJECT_DELIM(); - } - - return Result; -} - -link_internal b32 -Deserialize(u8_cursor *Bytes, brush_settings_0 *Element, memory_arena *Memory, umm Count = 1); - -link_internal b32 -DeserializeCurrentVersion(u8_cursor *Bytes, brush_settings_0 *Element, memory_arena *Memory); - - - - -link_internal b32 -DeserializeCurrentVersion(u8_cursor *Bytes, brush_settings_0 *Element, memory_arena *Memory) -{ - b32 Result = True; - Element->Type = Cast(brush_layer_type, Read_u32(Bytes)); - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->Noise, Memory); - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->Shape, Memory); - - - - - - Element->Mode = Cast(world_edit_mode, Read_u32(Bytes)); - - - - - Element->Modifier = Cast(world_edit_mode_modifier, Read_u32(Bytes)); - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->Iterations, Memory); - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->Offset, Memory); - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->Color, Memory); - - - - MAYBE_READ_DEBUG_OBJECT_DELIM(); - return Result; -} - -link_internal b32 -Deserialize(u8_cursor *Bytes, brush_settings_0 *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_brush_settings_1.h b/generated/serdes_struct_brush_settings_1.h deleted file mode 100644 index e79f829df..000000000 --- a/generated/serdes_struct_brush_settings_1.h +++ /dev/null @@ -1,185 +0,0 @@ -// src/engine/serdes.cpp:541:0 - -link_internal bonsai_type_info -TypeInfo(brush_settings_1 *Ignored) -{ - bonsai_type_info Result = {}; - - Result.Name = CSz("brush_settings_1"); - 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, brush_settings_1 *BaseElement, umm Count = 1) -{ - Assert(Count > 0); - - u64 PointerTrue = True; - u64 PointerFalse = False; - - b32 Result = True; - - - - RangeIterator_t(umm, ElementIndex, Count) - { - brush_settings_1 *Element = BaseElement + ElementIndex; - Result &= Serialize(Bytes, (u32*)&Element->Type); - - - - - Result &= Serialize(Bytes, &Element->Noise); - - - - - - Result &= Serialize(Bytes, &Element->Shape); - - - - - - Result &= Serialize(Bytes, (u32*)&Element->Mode); - - - - - Result &= Serialize(Bytes, (u32*)&Element->Modifier); - - - - - Result &= Serialize(Bytes, &Element->Iterations); - - - - - - Result &= Serialize(Bytes, &Element->Offset); - - - - - - Result &= Serialize(Bytes, &Element->NoiseBasisOffset); - - - - - - Result &= Serialize(Bytes, &Element->Color); - - - - MAYBE_WRITE_DEBUG_OBJECT_DELIM(); - } - - return Result; -} - -link_internal b32 -Deserialize(u8_cursor *Bytes, brush_settings_1 *Element, memory_arena *Memory, umm Count = 1); - -link_internal b32 -DeserializeCurrentVersion(u8_cursor *Bytes, brush_settings_1 *Element, memory_arena *Memory); - - - - -link_internal b32 -DeserializeCurrentVersion(u8_cursor *Bytes, brush_settings_1 *Element, memory_arena *Memory) -{ - b32 Result = True; - Element->Type = Cast(brush_layer_type, Read_u32(Bytes)); - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->Noise, Memory); - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->Shape, Memory); - - - - - - Element->Mode = Cast(world_edit_mode, Read_u32(Bytes)); - - - - - Element->Modifier = Cast(world_edit_mode_modifier, Read_u32(Bytes)); - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->Iterations, Memory); - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->Offset, Memory); - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->NoiseBasisOffset, Memory); - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->Color, Memory); - - - - MAYBE_READ_DEBUG_OBJECT_DELIM(); - return Result; -} - -link_internal b32 -Deserialize(u8_cursor *Bytes, brush_settings_1 *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_brush_settings_2.h b/generated/serdes_struct_brush_settings_2.h deleted file mode 100644 index e8bc30dca..000000000 --- a/generated/serdes_struct_brush_settings_2.h +++ /dev/null @@ -1,199 +0,0 @@ -// src/engine/serdes.cpp:543:0 - -link_internal bonsai_type_info -TypeInfo(brush_settings_2 *Ignored) -{ - bonsai_type_info Result = {}; - - Result.Name = CSz("brush_settings_2"); - 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, brush_settings_2 *BaseElement, umm Count = 1) -{ - Assert(Count > 0); - - u64 PointerTrue = True; - u64 PointerFalse = False; - - b32 Result = True; - - - - RangeIterator_t(umm, ElementIndex, Count) - { - brush_settings_2 *Element = BaseElement + ElementIndex; - Result &= Serialize(Bytes, (u32*)&Element->Type); - - - - - Result &= Serialize(Bytes, &Element->Noise); - - - - - - Result &= Serialize(Bytes, &Element->Shape); - - - - - - Result &= Serialize(Bytes, (u32*)&Element->Mode); - - - - - Result &= Serialize(Bytes, (u32*)&Element->Modifier); - - - - - Result &= Serialize(Bytes, &Element->Iterations); - - - - - - Result &= Serialize(Bytes, &Element->Offset); - - - - - - Result &= Serialize(Bytes, &Element->NoiseBasisOffset); - - - - - - Result &= Serialize(Bytes, &Element->Color); - - - - - - Result &= Serialize(Bytes, &Element->Invert); - - - - MAYBE_WRITE_DEBUG_OBJECT_DELIM(); - } - - return Result; -} - -link_internal b32 -Deserialize(u8_cursor *Bytes, brush_settings_2 *Element, memory_arena *Memory, umm Count = 1); - -link_internal b32 -DeserializeCurrentVersion(u8_cursor *Bytes, brush_settings_2 *Element, memory_arena *Memory); - - - - -link_internal b32 -DeserializeCurrentVersion(u8_cursor *Bytes, brush_settings_2 *Element, memory_arena *Memory) -{ - b32 Result = True; - Element->Type = Cast(brush_layer_type, Read_u32(Bytes)); - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->Noise, Memory); - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->Shape, Memory); - - - - - - Element->Mode = Cast(world_edit_mode, Read_u32(Bytes)); - - - - - Element->Modifier = Cast(world_edit_mode_modifier, Read_u32(Bytes)); - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->Iterations, Memory); - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->Offset, Memory); - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->NoiseBasisOffset, Memory); - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->Color, Memory); - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->Invert, Memory); - - - - MAYBE_READ_DEBUG_OBJECT_DELIM(); - return Result; -} - -link_internal b32 -Deserialize(u8_cursor *Bytes, brush_settings_2 *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_camera.h b/generated/serdes_struct_camera.h index 78dd023b5..6c4f23c3f 100644 --- a/generated/serdes_struct_camera.h +++ b/generated/serdes_struct_camera.h @@ -1,12 +1,11 @@ -// src/engine/serdes.cpp:130:0 - +// src/engine/serdes.h:495:0 link_internal bonsai_type_info TypeInfo(camera *Ignored) { bonsai_type_info Result = {}; Result.Name = CSz("camera"); - Result.Version =2 ; + Result.Version = 2 ; /* type.map(member) */ /* { */ @@ -24,88 +23,174 @@ Serialize(u8_cursor_block_array *Bytes, camera *BaseElement, umm Count = 1) { Assert(Count > 0); - u64 PointerTrue = True; + u64 PointerTrue = True; u64 PointerFalse = False; b32 Result = True; - Upsert(TypeInfo(BaseElement), &Global_SerializeTypeTable, Global_SerializeTypeTableArena ); - u64 VersionNumber =2; + Upsert(TypeInfo(BaseElement), &Global_SerializeTypeTable, Global_SerializeTypeTableArena ); + u64 VersionNumber = 2; Serialize(Bytes, &VersionNumber); RangeIterator_t(umm, ElementIndex, Count) { camera *Element = BaseElement + ElementIndex; - Result &= Serialize(Bytes, &Element->Frust); + Result &= Serialize(Bytes, &Element->Frust); // default - Result &= Serialize(Bytes, &Element->CurrentP); + Result &= Serialize(Bytes, &Element->CurrentP); // default - Result &= Serialize(Bytes, &Element->RenderSpacePosition); + Result &= Serialize(Bytes, &Element->RenderSpacePosition); // default - Result &= Serialize(Bytes, &Element->TargetPitch); + + + + + Result &= Serialize(Bytes, &Element->TargetPitch); // default - Result &= Serialize(Bytes, &Element->TargetRoll); + Result &= Serialize(Bytes, &Element->TargetRoll); // default - Result &= Serialize(Bytes, &Element->TargetYaw); - Result &= Serialize(Bytes, &Element->TargetDistanceFromTarget); + Result &= Serialize(Bytes, &Element->TargetYaw); // default - Result &= Serialize(Bytes, &Element->Blend); + Result &= Serialize(Bytes, &Element->TargetDistanceFromTarget); // default - Result &= Serialize(Bytes, &Element->Front); + Result &= Serialize(Bytes, &Element->Blend); // default - Result &= Serialize(Bytes, &Element->Right); + Result &= Serialize(Bytes, &Element->Speed); // default - Result &= Serialize(Bytes, &Element->Up); + Result &= Serialize(Bytes, &Element->Front); // default + + + + + + + Result &= Serialize(Bytes, &Element->Right); // default + + + + + + + Result &= Serialize(Bytes, &Element->Up); // default + + + + + + + Result &= Serialize(Bytes, &Element->GhostId); // default + + + + + + + Result &= Serialize(Bytes, &Element->ViewProjection); // default + + + + + + + Result &= Serialize(Bytes, &Element->InverseViewMatrix); // default + + + + + + + Result &= Serialize(Bytes, &Element->InverseProjectionMatrix); // default + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - Result &= Serialize(Bytes, &Element->GhostId); - MAYBE_WRITE_DEBUG_OBJECT_DELIM(); } @@ -123,11 +208,11 @@ DeserializeCurrentVersion(u8_cursor *Bytes, camera *Element, memory_arena *Memor link_internal b32 DeserializeVersioned(u8_cursor *Bytes, camera *Element, bonsai_type_info *TypeInfo, memory_arena *Memory) { - Assert(TypeInfo->Version <=2); + Assert(TypeInfo->Version <= 2); b32 Result = True; - if (TypeInfo->Version == 0) + if (TypeInfo->Version == 0) { camera_0 T0 = {}; Result &= Deserialize(Bytes, &T0, Memory); @@ -141,7 +226,7 @@ DeserializeVersioned(u8_cursor *Bytes, camera *Element, bonsai_type_info *TypeIn } - if (TypeInfo->Version ==2) + if (TypeInfo->Version == 2) { Result &= DeserializeCurrentVersion(Bytes, Element, Memory); } @@ -154,7 +239,7 @@ link_internal b32 DeserializeCurrentVersion(u8_cursor *Bytes, camera *Element, memory_arena *Memory) { b32 Result = True; - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Frust, Memory); @@ -162,7 +247,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, camera *Element, memory_arena *Memor - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->CurrentP, Memory); @@ -170,7 +255,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, camera *Element, memory_arena *Memor - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->RenderSpacePosition, Memory); @@ -178,7 +263,11 @@ DeserializeCurrentVersion(u8_cursor *Bytes, camera *Element, memory_arena *Memor - // NOTE(Jesse): Unfortunately we can't check for primitives because + + + + + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->TargetPitch, Memory); @@ -186,7 +275,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, camera *Element, memory_arena *Memor - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->TargetRoll, Memory); @@ -194,7 +283,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, camera *Element, memory_arena *Memor - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->TargetYaw, Memory); @@ -202,7 +291,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, camera *Element, memory_arena *Memor - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->TargetDistanceFromTarget, Memory); @@ -210,7 +299,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, camera *Element, memory_arena *Memor - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Blend, Memory); @@ -218,7 +307,15 @@ DeserializeCurrentVersion(u8_cursor *Bytes, camera *Element, memory_arena *Memor - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because + // strings are considered primitive, but need memory to deserialize + Result &= Deserialize(Bytes, &Element->Speed, Memory); + + + + + + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Front, Memory); @@ -226,7 +323,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, camera *Element, memory_arena *Memor - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Right, Memory); @@ -234,7 +331,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, camera *Element, memory_arena *Memor - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Up, Memory); @@ -242,11 +339,61 @@ DeserializeCurrentVersion(u8_cursor *Bytes, camera *Element, memory_arena *Memor - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->GhostId, Memory); + + + + + // NOTE(Jesse): Unfortunately we can't check for primitives because + // strings are considered primitive, but need memory to deserialize + Result &= Deserialize(Bytes, &Element->ViewProjection, Memory); + + + + + + // NOTE(Jesse): Unfortunately we can't check for primitives because + // strings are considered primitive, but need memory to deserialize + Result &= Deserialize(Bytes, &Element->InverseViewMatrix, Memory); + + + + + + // NOTE(Jesse): Unfortunately we can't check for primitives because + // strings are considered primitive, but need memory to deserialize + Result &= Deserialize(Bytes, &Element->InverseProjectionMatrix, Memory); + + + + + + + + + + + + + + + + + + + + + + + + + + + MAYBE_READ_DEBUG_OBJECT_DELIM(); return Result; @@ -260,7 +407,7 @@ Deserialize(u8_cursor *Bytes, camera *Element, memory_arena *Memory, umm Count) b32 Result = True; RangeIterator_t(umm, ElementIndex, Count) { - maybe_bonsai_type_info MaybeSerializedType = GetByName(&Global_SerializeTypeTable, CSz("camera")); + maybe_bonsai_type_info MaybeSerializedType = GetByName(&Global_SerializeTypeTable, CSz("camera")); if (MaybeSerializedType.Tag) { diff --git a/generated/serdes_struct_canonical_position.h b/generated/serdes_struct_canonical_position.h index a9743ae1d..a92c13f2c 100644 --- a/generated/serdes_struct_canonical_position.h +++ b/generated/serdes_struct_canonical_position.h @@ -1,12 +1,11 @@ -// src/engine/serdes.cpp:24:0 - +// src/engine/serdes.h:495:0 link_internal bonsai_type_info TypeInfo(canonical_position *Ignored) { bonsai_type_info Result = {}; Result.Name = CSz("canonical_position"); - Result.Version = 0 ; + Result.Version = 0 ; /* type.map(member) */ /* { */ @@ -24,7 +23,7 @@ Serialize(u8_cursor_block_array *Bytes, canonical_position *BaseElement, umm Cou { Assert(Count > 0); - u64 PointerTrue = True; + u64 PointerTrue = True; u64 PointerFalse = False; b32 Result = True; @@ -34,15 +33,27 @@ Serialize(u8_cursor_block_array *Bytes, canonical_position *BaseElement, umm Cou RangeIterator_t(umm, ElementIndex, Count) { canonical_position *Element = BaseElement + ElementIndex; - Result &= Serialize(Bytes, &Element->Offset); + Result &= Serialize(Bytes, &Element->Offset); // default - Result &= Serialize(Bytes, &Element->WorldP); - + Result &= Serialize(Bytes, &Element->WorldP); // default + + + + + + + + + + + + + MAYBE_WRITE_DEBUG_OBJECT_DELIM(); } @@ -63,7 +74,7 @@ link_internal b32 DeserializeCurrentVersion(u8_cursor *Bytes, canonical_position *Element, memory_arena *Memory) { b32 Result = True; - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Offset, Memory); @@ -71,12 +82,20 @@ DeserializeCurrentVersion(u8_cursor *Bytes, canonical_position *Element, memory_ - // NOTE(Jesse): Unfortunately we can't check for primitives because + // 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); + + + + + + + + MAYBE_READ_DEBUG_OBJECT_DELIM(); return Result; } @@ -89,7 +108,7 @@ Deserialize(u8_cursor *Bytes, canonical_position *Element, memory_arena *Memory, b32 Result = True; RangeIterator_t(umm, ElementIndex, Count) { - Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); + Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); } diff --git a/generated/serdes_struct_entity_0.h b/generated/serdes_struct_entity_0.h index 831cbaa25..603296d14 100644 --- a/generated/serdes_struct_entity_0.h +++ b/generated/serdes_struct_entity_0.h @@ -1,12 +1,11 @@ -// src/engine/serdes.cpp:355:0 - +// src/engine/serdes.h:495:0 link_internal bonsai_type_info TypeInfo(entity_0 *Ignored) { bonsai_type_info Result = {}; Result.Name = CSz("entity_0"); - Result.Version = 0 ; + Result.Version = 0 ; /* type.map(member) */ /* { */ @@ -24,7 +23,7 @@ Serialize(u8_cursor_block_array *Bytes, entity_0 *BaseElement, umm Count = 1) { Assert(Count > 0); - u64 PointerTrue = True; + u64 PointerTrue = True; u64 PointerFalse = False; b32 Result = True; @@ -34,81 +33,121 @@ Serialize(u8_cursor_block_array *Bytes, entity_0 *BaseElement, umm Count = 1) RangeIterator_t(umm, ElementIndex, Count) { entity_0 *Element = BaseElement + ElementIndex; - Result &= Serialize(Bytes, &Element->Id); + Result &= Serialize(Bytes, &Element->Id); // default + + + + + + Result &= Serialize(Bytes, &Element->P); // default - Result &= Serialize(Bytes, &Element->P); + Result &= Serialize(Bytes, &Element->EulerAngles); // default - Result &= Serialize(Bytes, &Element->EulerAngles); + Result &= Serialize(Bytes, &Element->Scale); // default - Result &= Serialize(Bytes, &Element->Scale); + Result &= Serialize(Bytes, &Element->_CollisionVolumeRadius); // default - Result &= Serialize(Bytes, &Element->_CollisionVolumeRadius); - Result &= Serialize(Bytes, &Element->Physics); + Result &= Serialize(Bytes, &Element->Physics); // default - Result &= Serialize(Bytes, &Element->AssetId); + Result &= Serialize(Bytes, &Element->AssetId); // default - Result &= Serialize(Bytes, &Element->ModelIndex); + Result &= Serialize(Bytes, &Element->ModelIndex); // default - if (Element->Emitter) { Result &= Write(Bytes, Cast(u8*, &PointerTrue), sizeof(PointerTrue)); } + + + + + + if (Element->Emitter) { Result &= Write(Bytes, Cast(u8*, &PointerTrue), sizeof(PointerTrue)); } else { Result &= Write(Bytes, Cast(u8*, &PointerFalse), sizeof(PointerFalse)); } - Result &= Serialize(Bytes, (u32*)&Element->State); + Result &= Serialize(Bytes, (u32*)&Element->State); // enum + + + + + Result &= Serialize(Bytes, (u32*)&Element->Behavior); // enum + + + + + Result &= Serialize(Bytes, &Element->UserType); // default + + + + + if (EntityUserDataSerialize) {Result &= EntityUserDataSerialize(Bytes, Element->UserType, Element->UserData);} - Result &= Serialize(Bytes, (u32*)&Element->Behavior); + + - Result &= Serialize(Bytes, &Element->UserType); + + + + + - if (EntityUserDataSerialize) {Result &= EntityUserDataSerialize(Bytes, Element->UserType, Element->UserData);} + - if (Element->Emitter) { Result &= Serialize(Bytes, Element->Emitter); } + + + if (Element->Emitter) { Result &= Serialize(Bytes, Element->Emitter); } + + + + + + + + MAYBE_WRITE_DEBUG_OBJECT_DELIM(); @@ -130,7 +169,7 @@ link_internal b32 DeserializeCurrentVersion(u8_cursor *Bytes, entity_0 *Element, memory_arena *Memory) { b32 Result = True; - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Id, Memory); @@ -138,7 +177,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, entity_0 *Element, memory_arena *Mem - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->P, Memory); @@ -146,7 +185,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, entity_0 *Element, memory_arena *Mem - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->EulerAngles, Memory); @@ -154,7 +193,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, entity_0 *Element, memory_arena *Mem - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Scale, Memory); @@ -162,7 +201,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, entity_0 *Element, memory_arena *Mem - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->_CollisionVolumeRadius, Memory); @@ -170,7 +209,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, entity_0 *Element, memory_arena *Mem - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Physics, Memory); @@ -178,7 +217,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, entity_0 *Element, memory_arena *Mem - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->AssetId, Memory); @@ -186,7 +225,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, entity_0 *Element, memory_arena *Mem - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->ModelIndex, Memory); @@ -194,22 +233,24 @@ DeserializeCurrentVersion(u8_cursor *Bytes, entity_0 *Element, memory_arena *Mem - b64 HadEmitterPointer = Read_u64(Bytes); + + + b64 HadEmitterPointer = Read_u64(Bytes); Assert(HadEmitterPointer < 2); // Should be 0 or 1 - Element->State = Cast(entity_state, Read_u32(Bytes)); + Element->State = Cast(entity_state, Read_u32(Bytes)); - Element->Behavior = Cast(entity_behavior_flags, Read_u32(Bytes)); + Element->Behavior = Cast(entity_behavior_flags, Read_u32(Bytes)); - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->UserType, Memory); @@ -217,11 +258,24 @@ DeserializeCurrentVersion(u8_cursor *Bytes, entity_0 *Element, memory_arena *Mem -if (EntityUserDataDeserialize) {Result &= EntityUserDataDeserialize(Bytes, &Element->UserType, &Element->UserData, Memory);} + if (EntityUserDataDeserialize) {Result &= EntityUserDataDeserialize(Bytes, &Element->UserType, &Element->UserData, Memory);} + - if (HadEmitterPointer) + + + + + + + + + + + + + if (HadEmitterPointer) { - umm Count = 1; + umm Count = 1; if (Element->Emitter == 0) @@ -233,6 +287,10 @@ if (EntityUserDataDeserialize) {Result &= EntityUserDataDeserialize(Bytes, &Elem } + + + + MAYBE_READ_DEBUG_OBJECT_DELIM(); @@ -247,7 +305,7 @@ Deserialize(u8_cursor *Bytes, entity_0 *Element, memory_arena *Memory, umm Count b32 Result = True; RangeIterator_t(umm, ElementIndex, Count) { - Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); + Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); } diff --git a/generated/serdes_struct_entity_1.h b/generated/serdes_struct_entity_1.h index 04f51b29c..03f1aad87 100644 --- a/generated/serdes_struct_entity_1.h +++ b/generated/serdes_struct_entity_1.h @@ -1,12 +1,11 @@ -// src/engine/serdes.cpp:352:0 - +// src/engine/serdes.h:495:0 link_internal bonsai_type_info TypeInfo(entity_1 *Ignored) { bonsai_type_info Result = {}; Result.Name = CSz("entity_1"); - Result.Version = 0 ; + Result.Version = 0 ; /* type.map(member) */ /* { */ @@ -24,7 +23,7 @@ Serialize(u8_cursor_block_array *Bytes, entity_1 *BaseElement, umm Count = 1) { Assert(Count > 0); - u64 PointerTrue = True; + u64 PointerTrue = True; u64 PointerFalse = False; b32 Result = True; @@ -34,87 +33,130 @@ Serialize(u8_cursor_block_array *Bytes, entity_1 *BaseElement, umm Count = 1) RangeIterator_t(umm, ElementIndex, Count) { entity_1 *Element = BaseElement + ElementIndex; - Result &= Serialize(Bytes, &Element->Id); + Result &= Serialize(Bytes, &Element->Id); // default + + + + + + Result &= Serialize(Bytes, &Element->P); // default - Result &= Serialize(Bytes, &Element->P); + Result &= Serialize(Bytes, &Element->EulerAngles); // default - Result &= Serialize(Bytes, &Element->EulerAngles); + Result &= Serialize(Bytes, &Element->Scale); // default - Result &= Serialize(Bytes, &Element->Scale); + Result &= Serialize(Bytes, &Element->_CollisionVolumeRadius); // default - Result &= Serialize(Bytes, &Element->_CollisionVolumeRadius); - Result &= Serialize(Bytes, &Element->Physics); + Result &= Serialize(Bytes, &Element->Physics); // default - Result &= Serialize(Bytes, &Element->AssetId); + Result &= Serialize(Bytes, &Element->AssetId); // default - Result &= Serialize(Bytes, &Element->ModelIndex); + Result &= Serialize(Bytes, &Element->ModelIndex); // default - if (Element->Emitter) { Result &= Write(Bytes, Cast(u8*, &PointerTrue), sizeof(PointerTrue)); } + + + + + + if (Element->Emitter) { Result &= Write(Bytes, Cast(u8*, &PointerTrue), sizeof(PointerTrue)); } else { Result &= Write(Bytes, Cast(u8*, &PointerFalse), sizeof(PointerFalse)); } - Result &= Serialize(Bytes, (u32*)&Element->State); + Result &= Serialize(Bytes, (u32*)&Element->State); // enum + + + + + Result &= Serialize(Bytes, (u32*)&Element->Behavior); // enum + + + + + Result &= Serialize(Bytes, &Element->Carrying); // default + + + + + + Result &= Serialize(Bytes, &Element->UserType); // default - Result &= Serialize(Bytes, (u32*)&Element->Behavior); + if (EntityUserDataSerialize) {Result &= EntityUserDataSerialize(Bytes, Element->UserType, Element->UserData);} - Result &= Serialize(Bytes, &Element->Carrying); + + - Result &= Serialize(Bytes, &Element->UserType); + + + + + - if (EntityUserDataSerialize) {Result &= EntityUserDataSerialize(Bytes, Element->UserType, Element->UserData);} + - if (Element->Emitter) { Result &= Serialize(Bytes, Element->Emitter); } + + + if (Element->Emitter) { Result &= Serialize(Bytes, Element->Emitter); } + + + + + + + + + + MAYBE_WRITE_DEBUG_OBJECT_DELIM(); @@ -136,7 +178,7 @@ link_internal b32 DeserializeCurrentVersion(u8_cursor *Bytes, entity_1 *Element, memory_arena *Memory) { b32 Result = True; - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Id, Memory); @@ -144,7 +186,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, entity_1 *Element, memory_arena *Mem - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->P, Memory); @@ -152,7 +194,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, entity_1 *Element, memory_arena *Mem - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->EulerAngles, Memory); @@ -160,7 +202,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, entity_1 *Element, memory_arena *Mem - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Scale, Memory); @@ -168,7 +210,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, entity_1 *Element, memory_arena *Mem - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->_CollisionVolumeRadius, Memory); @@ -176,7 +218,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, entity_1 *Element, memory_arena *Mem - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Physics, Memory); @@ -184,7 +226,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, entity_1 *Element, memory_arena *Mem - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->AssetId, Memory); @@ -192,7 +234,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, entity_1 *Element, memory_arena *Mem - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->ModelIndex, Memory); @@ -200,22 +242,24 @@ DeserializeCurrentVersion(u8_cursor *Bytes, entity_1 *Element, memory_arena *Mem - b64 HadEmitterPointer = Read_u64(Bytes); + + + b64 HadEmitterPointer = Read_u64(Bytes); Assert(HadEmitterPointer < 2); // Should be 0 or 1 - Element->State = Cast(entity_state, Read_u32(Bytes)); + Element->State = Cast(entity_state, Read_u32(Bytes)); - Element->Behavior = Cast(entity_behavior_flags, Read_u32(Bytes)); + Element->Behavior = Cast(entity_behavior_flags, Read_u32(Bytes)); - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Carrying, Memory); @@ -223,7 +267,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, entity_1 *Element, memory_arena *Mem - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->UserType, Memory); @@ -231,11 +275,24 @@ DeserializeCurrentVersion(u8_cursor *Bytes, entity_1 *Element, memory_arena *Mem -if (EntityUserDataDeserialize) {Result &= EntityUserDataDeserialize(Bytes, &Element->UserType, &Element->UserData, Memory);} + if (EntityUserDataDeserialize) {Result &= EntityUserDataDeserialize(Bytes, &Element->UserType, &Element->UserData, Memory);} + - if (HadEmitterPointer) + + + + + + + + + + + + + if (HadEmitterPointer) { - umm Count = 1; + umm Count = 1; if (Element->Emitter == 0) @@ -247,6 +304,11 @@ if (EntityUserDataDeserialize) {Result &= EntityUserDataDeserialize(Bytes, &Elem } + + + + + MAYBE_READ_DEBUG_OBJECT_DELIM(); @@ -261,7 +323,7 @@ Deserialize(u8_cursor *Bytes, entity_1 *Element, memory_arena *Memory, umm Count b32 Result = True; RangeIterator_t(umm, ElementIndex, Count) { - Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); + Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); } diff --git a/generated/serdes_struct_entity_game_data.h b/generated/serdes_struct_entity_game_data.h index b1315ee50..2dfb1e120 100644 --- a/generated/serdes_struct_entity_game_data.h +++ b/generated/serdes_struct_entity_game_data.h @@ -1,12 +1,11 @@ -// examples/turn_based/game.cpp:1137:0 - +// src/engine/serdes.h:495:0 link_internal bonsai_type_info TypeInfo(entity_game_data *Ignored) { bonsai_type_info Result = {}; Result.Name = CSz("entity_game_data"); - Result.Version = 0 ; + Result.Version = 0 ; /* type.map(member) */ /* { */ @@ -24,7 +23,7 @@ Serialize(u8_cursor_block_array *Bytes, entity_game_data *BaseElement, umm Count { Assert(Count > 0); - u64 PointerTrue = True; + u64 PointerTrue = True; u64 PointerFalse = False; b32 Result = True; @@ -34,27 +33,45 @@ Serialize(u8_cursor_block_array *Bytes, entity_game_data *BaseElement, umm Count RangeIterator_t(umm, ElementIndex, Count) { entity_game_data *Element = BaseElement + ElementIndex; - Result &= Serialize(Bytes, &Element->FireballChargeLevel); + Result &= Serialize(Bytes, &Element->FireballChargeLevel); // default - Result &= Serialize(Bytes, &Element->FireballCharges); + Result &= Serialize(Bytes, &Element->FireballCharges); // default - Result &= Serialize(Bytes, &Element->IceBlockCharges); + Result &= Serialize(Bytes, &Element->IceBlockCharges); // default - Result &= Serialize(Bytes, &Element->HoldingItem); - + + + Result &= Serialize(Bytes, &Element->HoldingItem); // default + + + + + + + + + + + + + + + + + MAYBE_WRITE_DEBUG_OBJECT_DELIM(); } @@ -75,7 +92,7 @@ link_internal b32 DeserializeCurrentVersion(u8_cursor *Bytes, entity_game_data *Element, memory_arena *Memory) { b32 Result = True; - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->FireballChargeLevel, Memory); @@ -83,7 +100,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, entity_game_data *Element, memory_ar - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->FireballCharges, Memory); @@ -91,7 +108,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, entity_game_data *Element, memory_ar - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->IceBlockCharges, Memory); @@ -99,11 +116,21 @@ DeserializeCurrentVersion(u8_cursor *Bytes, entity_game_data *Element, memory_ar - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->HoldingItem, Memory); + + + + + + + + + + MAYBE_READ_DEBUG_OBJECT_DELIM(); return Result; @@ -117,7 +144,7 @@ Deserialize(u8_cursor *Bytes, entity_game_data *Element, memory_arena *Memory, u b32 Result = True; RangeIterator_t(umm, ElementIndex, Count) { - Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); + Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); } diff --git a/generated/serdes_struct_entity_id.h b/generated/serdes_struct_entity_id.h index b2b3ba073..2a90f29d2 100644 --- a/generated/serdes_struct_entity_id.h +++ b/generated/serdes_struct_entity_id.h @@ -1,12 +1,11 @@ -// src/engine/serdes.cpp:67:0 - +// src/engine/serdes.h:495:0 link_internal bonsai_type_info TypeInfo(entity_id *Ignored) { bonsai_type_info Result = {}; Result.Name = CSz("entity_id"); - Result.Version = 0 ; + Result.Version = 0 ; /* type.map(member) */ /* { */ @@ -24,7 +23,7 @@ Serialize(u8_cursor_block_array *Bytes, entity_id *BaseElement, umm Count = 1) { Assert(Count > 0); - u64 PointerTrue = True; + u64 PointerTrue = True; u64 PointerFalse = False; b32 Result = True; @@ -34,15 +33,27 @@ Serialize(u8_cursor_block_array *Bytes, entity_id *BaseElement, umm Count = 1) RangeIterator_t(umm, ElementIndex, Count) { entity_id *Element = BaseElement + ElementIndex; - Result &= Serialize(Bytes, &Element->Index); + Result &= Serialize(Bytes, &Element->Index); // default - Result &= Serialize(Bytes, &Element->Generation); - + Result &= Serialize(Bytes, &Element->Generation); // default + + + + + + + + + + + + + MAYBE_WRITE_DEBUG_OBJECT_DELIM(); } @@ -63,7 +74,7 @@ link_internal b32 DeserializeCurrentVersion(u8_cursor *Bytes, entity_id *Element, memory_arena *Memory) { b32 Result = True; - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Index, Memory); @@ -71,12 +82,20 @@ DeserializeCurrentVersion(u8_cursor *Bytes, entity_id *Element, memory_arena *Me - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Generation, Memory); + + + + + + + + MAYBE_READ_DEBUG_OBJECT_DELIM(); return Result; } @@ -89,7 +108,7 @@ Deserialize(u8_cursor *Bytes, entity_id *Element, memory_arena *Memory, umm Coun b32 Result = True; RangeIterator_t(umm, ElementIndex, Count) { - Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); + Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); } diff --git a/generated/serdes_struct_file_traversal_node.h b/generated/serdes_struct_file_traversal_node.h index fcd39c40c..78456c919 100644 --- a/generated/serdes_struct_file_traversal_node.h +++ b/generated/serdes_struct_file_traversal_node.h @@ -1,12 +1,11 @@ -// src/engine/serdes.cpp:299:0 - +// src/engine/serdes.h:495:0 link_internal bonsai_type_info TypeInfo(file_traversal_node *Ignored) { bonsai_type_info Result = {}; Result.Name = CSz("file_traversal_node"); - Result.Version = 0 ; + Result.Version = 0 ; /* type.map(member) */ /* { */ @@ -24,7 +23,7 @@ Serialize(u8_cursor_block_array *Bytes, file_traversal_node *BaseElement, umm Co { Assert(Count > 0); - u64 PointerTrue = True; + u64 PointerTrue = True; u64 PointerFalse = False; b32 Result = True; @@ -34,20 +33,34 @@ Serialize(u8_cursor_block_array *Bytes, file_traversal_node *BaseElement, umm Co RangeIterator_t(umm, ElementIndex, Count) { file_traversal_node *Element = BaseElement + ElementIndex; - Result &= Serialize(Bytes, (u32*)&Element->Type); + Result &= Serialize(Bytes, (u32*)&Element->Type); // enum - Result &= Serialize(Bytes, &Element->Dir); + Result &= Serialize(Bytes, &Element->Dir); // default - Result &= Serialize(Bytes, &Element->Name); - + Result &= Serialize(Bytes, &Element->Name); // default + + + + + + + + + + + + + + + MAYBE_WRITE_DEBUG_OBJECT_DELIM(); } @@ -68,12 +81,12 @@ link_internal b32 DeserializeCurrentVersion(u8_cursor *Bytes, file_traversal_node *Element, memory_arena *Memory) { b32 Result = True; - Element->Type = Cast(file_traversal_type, Read_u32(Bytes)); + Element->Type = Cast(file_traversal_type, Read_u32(Bytes)); - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Dir, Memory); @@ -81,11 +94,20 @@ DeserializeCurrentVersion(u8_cursor *Bytes, file_traversal_node *Element, memory - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Name, Memory); + + + + + + + + + MAYBE_READ_DEBUG_OBJECT_DELIM(); return Result; @@ -99,7 +121,7 @@ Deserialize(u8_cursor *Bytes, file_traversal_node *Element, memory_arena *Memory b32 Result = True; RangeIterator_t(umm, ElementIndex, Count) { - Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); + Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); } diff --git a/generated/serdes_struct_frustum.h b/generated/serdes_struct_frustum.h index eea4dad88..126e654be 100644 --- a/generated/serdes_struct_frustum.h +++ b/generated/serdes_struct_frustum.h @@ -1,12 +1,11 @@ -// src/engine/serdes.cpp:30:0 - +// src/engine/serdes.h:495:0 link_internal bonsai_type_info TypeInfo(frustum *Ignored) { bonsai_type_info Result = {}; Result.Name = CSz("frustum"); - Result.Version = 0 ; + Result.Version = 0 ; /* type.map(member) */ /* { */ @@ -24,7 +23,7 @@ Serialize(u8_cursor_block_array *Bytes, frustum *BaseElement, umm Count = 1) { Assert(Count > 0); - u64 PointerTrue = True; + u64 PointerTrue = True; u64 PointerFalse = False; b32 Result = True; @@ -34,51 +33,72 @@ Serialize(u8_cursor_block_array *Bytes, frustum *BaseElement, umm Count = 1) RangeIterator_t(umm, ElementIndex, Count) { frustum *Element = BaseElement + ElementIndex; - Result &= Serialize(Bytes, &Element->farClip); + Result &= Serialize(Bytes, &Element->farClip); // default - Result &= Serialize(Bytes, &Element->nearClip); + Result &= Serialize(Bytes, &Element->nearClip); // default - Result &= Serialize(Bytes, &Element->width); + Result &= Serialize(Bytes, &Element->FOV); // default - Result &= Serialize(Bytes, &Element->FOV); + Result &= Serialize(Bytes, &Element->Top); // default - Result &= Serialize(Bytes, &Element->Top); + Result &= Serialize(Bytes, &Element->Bottom); // default - Result &= Serialize(Bytes, &Element->Bot); - Result &= Serialize(Bytes, &Element->Left); + Result &= Serialize(Bytes, &Element->Left); // default - Result &= Serialize(Bytes, &Element->Right); - + Result &= Serialize(Bytes, &Element->Right); // default + + + + + + + + + + + + + + + + + + + + + + + MAYBE_WRITE_DEBUG_OBJECT_DELIM(); } @@ -99,7 +119,7 @@ link_internal b32 DeserializeCurrentVersion(u8_cursor *Bytes, frustum *Element, memory_arena *Memory) { b32 Result = True; - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->farClip, Memory); @@ -107,7 +127,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, frustum *Element, memory_arena *Memo - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->nearClip, Memory); @@ -115,51 +135,56 @@ DeserializeCurrentVersion(u8_cursor *Bytes, frustum *Element, memory_arena *Memo - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->width, Memory); + Result &= Deserialize(Bytes, &Element->FOV, Memory); - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->FOV, Memory); + Result &= Deserialize(Bytes, &Element->Top, Memory); - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->Top, Memory); + Result &= Deserialize(Bytes, &Element->Bottom, Memory); - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->Bot, Memory); + Result &= Deserialize(Bytes, &Element->Left, Memory); - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->Left, Memory); + Result &= Deserialize(Bytes, &Element->Right, Memory); - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->Right, Memory); + + + + + + + + MAYBE_READ_DEBUG_OBJECT_DELIM(); return Result; @@ -173,7 +198,7 @@ Deserialize(u8_cursor *Bytes, frustum *Element, memory_arena *Memory, umm Count) b32 Result = True; RangeIterator_t(umm, ElementIndex, Count) { - Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); + Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); } diff --git a/generated/serdes_struct_keyframe.h b/generated/serdes_struct_keyframe.h index 2891300d6..a316988c4 100644 --- a/generated/serdes_struct_keyframe.h +++ b/generated/serdes_struct_keyframe.h @@ -1,12 +1,11 @@ -// src/engine/serdes.cpp:262:0 - +// src/engine/serdes.h:495:0 link_internal bonsai_type_info TypeInfo(keyframe *Ignored) { bonsai_type_info Result = {}; Result.Name = CSz("keyframe"); - Result.Version = 0 ; + Result.Version = 0 ; /* type.map(member) */ /* { */ @@ -24,7 +23,7 @@ Serialize(u8_cursor_block_array *Bytes, keyframe *BaseElement, umm Count = 1) { Assert(Count > 0); - u64 PointerTrue = True; + u64 PointerTrue = True; u64 PointerFalse = False; b32 Result = True; @@ -34,15 +33,27 @@ Serialize(u8_cursor_block_array *Bytes, keyframe *BaseElement, umm Count = 1) RangeIterator_t(umm, ElementIndex, Count) { keyframe *Element = BaseElement + ElementIndex; - Result &= Serialize(Bytes, &Element->tEnd); + Result &= Serialize(Bytes, &Element->tEnd); // default - Result &= Serialize(Bytes, &Element->Value); - + Result &= Serialize(Bytes, &Element->Value); // default + + + + + + + + + + + + + MAYBE_WRITE_DEBUG_OBJECT_DELIM(); } @@ -63,7 +74,7 @@ link_internal b32 DeserializeCurrentVersion(u8_cursor *Bytes, keyframe *Element, memory_arena *Memory) { b32 Result = True; - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->tEnd, Memory); @@ -71,12 +82,20 @@ DeserializeCurrentVersion(u8_cursor *Bytes, keyframe *Element, memory_arena *Mem - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Value, Memory); + + + + + + + + MAYBE_READ_DEBUG_OBJECT_DELIM(); return Result; } @@ -89,7 +108,7 @@ Deserialize(u8_cursor *Bytes, keyframe *Element, memory_arena *Memory, umm Count b32 Result = True; RangeIterator_t(umm, ElementIndex, Count) { - Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); + Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); } diff --git a/generated/serdes_struct_layered_brush.h b/generated/serdes_struct_layered_brush.h new file mode 100644 index 000000000..6bdcacef0 --- /dev/null +++ b/generated/serdes_struct_layered_brush.h @@ -0,0 +1,143 @@ +// src/engine/serdes.h:495:0 +link_internal bonsai_type_info +TypeInfo(layered_brush *Ignored) +{ + bonsai_type_info Result = {}; + + Result.Name = CSz("layered_brush"); + 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, layered_brush *BaseElement, umm Count = 1) +{ + Assert(Count > 0); + + u64 PointerTrue = True; + u64 PointerFalse = False; + + b32 Result = True; + + + + RangeIterator_t(umm, ElementIndex, Count) + { + layered_brush *Element = BaseElement + ElementIndex; + Result &= Serialize(Bytes, &Element->LayerCount); // default + + + + + + + { + // TODO(Jesse): Should this really be a safe cast? + umm ThisCount = umm(Element->LayerCount); + + Result &= Serialize(Bytes, Element->Layers, ThisCount); + } + + + + + + Result &= Serialize(Bytes, &Element->AffectExisting); // default + + + + + + + + + + + + + + + + + MAYBE_WRITE_DEBUG_OBJECT_DELIM(); + } + + return Result; +} + +link_internal b32 +Deserialize(u8_cursor *Bytes, layered_brush *Element, memory_arena *Memory, umm Count = 1); + +link_internal b32 +DeserializeCurrentVersion(u8_cursor *Bytes, layered_brush *Element, memory_arena *Memory); + + + + +link_internal b32 +DeserializeCurrentVersion(u8_cursor *Bytes, layered_brush *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->LayerCount, Memory); + + + + + + { + // TODO(Jesse): Should this really be a safe cast? + umm Count = umm(Element->LayerCount); + + Result &= Deserialize(Bytes, Element->Layers, Memory, Count); + } + + + + + + // NOTE(Jesse): Unfortunately we can't check for primitives because + // strings are considered primitive, but need memory to deserialize + Result &= Deserialize(Bytes, &Element->AffectExisting, Memory); + + + + + + + + + + + + + MAYBE_READ_DEBUG_OBJECT_DELIM(); + return Result; +} + +link_internal b32 +Deserialize(u8_cursor *Bytes, layered_brush *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_layered_brush_editor.h b/generated/serdes_struct_layered_brush_editor.h deleted file mode 100644 index 57037146e..000000000 --- a/generated/serdes_struct_layered_brush_editor.h +++ /dev/null @@ -1,219 +0,0 @@ -// src/engine/serdes.cpp:557:0 - -link_internal bonsai_type_info -TypeInfo(layered_brush_editor *Ignored) -{ - bonsai_type_info Result = {}; - - Result.Name = CSz("layered_brush_editor"); - Result.Version =3 ; - - /* 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, layered_brush_editor *BaseElement, umm Count = 1) -{ - Assert(Count > 0); - - u64 PointerTrue = True; - u64 PointerFalse = False; - - b32 Result = True; - - Upsert(TypeInfo(BaseElement), &Global_SerializeTypeTable, Global_SerializeTypeTableArena ); - u64 VersionNumber =3; - Serialize(Bytes, &VersionNumber); - - - RangeIterator_t(umm, ElementIndex, Count) - { - layered_brush_editor *Element = BaseElement + ElementIndex; - Result &= Serialize(Bytes, &Element->LayerCount); - - - - - - { - // TODO(Jesse): Should this really be a safe cast? - umm ThisCount = umm(Element->LayerCount); - - Result &= Serialize(Bytes, Element->Layers, ThisCount); - } - - - - - - Result &= Serialize(Bytes, &Element->SeedBrushWithSelection); - - - - - - Result &= Serialize(Bytes, &Element->BrushFollowsCursor); - - - - - - Result &= Serialize(Bytes, (u32*)&Element->Mode); - - - - - Result &= Serialize(Bytes, (u32*)&Element->Modifier); - - - - - - - - - MAYBE_WRITE_DEBUG_OBJECT_DELIM(); - } - - return Result; -} - -link_internal b32 -Deserialize(u8_cursor *Bytes, layered_brush_editor *Element, memory_arena *Memory, umm Count = 1); - -link_internal b32 -DeserializeCurrentVersion(u8_cursor *Bytes, layered_brush_editor *Element, memory_arena *Memory); - - -link_internal b32 -DeserializeVersioned(u8_cursor *Bytes, layered_brush_editor *Element, bonsai_type_info *TypeInfo, memory_arena *Memory) -{ - Assert(TypeInfo->Version <=3); - - b32 Result = True; - - if (TypeInfo->Version == 0) - { - layered_brush_editor_0 T0 = {}; - Result &= Deserialize(Bytes, &T0, Memory); - Marshal(&T0, Element); - } - if (TypeInfo->Version == 1) - { - layered_brush_editor_1 T1 = {}; - Result &= Deserialize(Bytes, &T1, Memory); - Marshal(&T1, Element); - } - if (TypeInfo->Version == 2) - { - layered_brush_editor_2 T2 = {}; - Result &= Deserialize(Bytes, &T2, Memory); - Marshal(&T2, Element); - } - - - if (TypeInfo->Version ==3) - { - Result &= DeserializeCurrentVersion(Bytes, Element, Memory); - } - - return Result; -} - - -link_internal b32 -DeserializeCurrentVersion(u8_cursor *Bytes, layered_brush_editor *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->LayerCount, Memory); - - - - - - { - // TODO(Jesse): Should this really be a safe cast? - umm Count = umm(Element->LayerCount); - - Result &= Deserialize(Bytes, Element->Layers, Memory, Count); - } - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->SeedBrushWithSelection, Memory); - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->BrushFollowsCursor, Memory); - - - - - - Element->Mode = Cast(world_edit_mode, Read_u32(Bytes)); - - - - - Element->Modifier = Cast(world_edit_mode_modifier, Read_u32(Bytes)); - - - - - - - - - MAYBE_READ_DEBUG_OBJECT_DELIM(); - return Result; -} - -link_internal b32 -Deserialize(u8_cursor *Bytes, layered_brush_editor *Element, memory_arena *Memory, umm Count) -{ - Assert(Count > 0); - - b32 Result = True; - RangeIterator_t(umm, ElementIndex, Count) - { - maybe_bonsai_type_info MaybeSerializedType = GetByName(&Global_SerializeTypeTable, CSz("layered_brush_editor")); - - if (MaybeSerializedType.Tag) - { - u64 OldIgnoredVersionNumber; - if (MaybeSerializedType.Value.Version > 0) - { - Deserialize(Bytes, &OldIgnoredVersionNumber, Memory); - } - Result &= DeserializeVersioned(Bytes, Element+ElementIndex, &MaybeSerializedType.Value, Memory); - } - else - { - bonsai_type_info T0TypeInfo = {}; - Result &= DeserializeVersioned(Bytes, Element+ElementIndex, &T0TypeInfo, Memory); - } - - } - - return Result; -} - - diff --git a/generated/serdes_struct_layered_brush_editor_0.h b/generated/serdes_struct_layered_brush_editor_0.h deleted file mode 100644 index e2f5b0115..000000000 --- a/generated/serdes_struct_layered_brush_editor_0.h +++ /dev/null @@ -1,119 +0,0 @@ -// src/engine/serdes.cpp:551:0 - -link_internal bonsai_type_info -TypeInfo(layered_brush_editor_0 *Ignored) -{ - bonsai_type_info Result = {}; - - Result.Name = CSz("layered_brush_editor_0"); - 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, layered_brush_editor_0 *BaseElement, umm Count = 1) -{ - Assert(Count > 0); - - u64 PointerTrue = True; - u64 PointerFalse = False; - - b32 Result = True; - - - - RangeIterator_t(umm, ElementIndex, Count) - { - layered_brush_editor_0 *Element = BaseElement + ElementIndex; - Result &= Serialize(Bytes, &Element->LayerCount); - - - - - - { - // TODO(Jesse): Should this really be a safe cast? - umm ThisCount = umm(Element->LayerCount); - - Result &= Serialize(Bytes, Element->Layers, ThisCount); - } - - - - - - - - - - MAYBE_WRITE_DEBUG_OBJECT_DELIM(); - } - - return Result; -} - -link_internal b32 -Deserialize(u8_cursor *Bytes, layered_brush_editor_0 *Element, memory_arena *Memory, umm Count = 1); - -link_internal b32 -DeserializeCurrentVersion(u8_cursor *Bytes, layered_brush_editor_0 *Element, memory_arena *Memory); - - - - -link_internal b32 -DeserializeCurrentVersion(u8_cursor *Bytes, layered_brush_editor_0 *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->LayerCount, Memory); - - - - - - { - // TODO(Jesse): Should this really be a safe cast? - umm Count = umm(Element->LayerCount); - - Result &= Deserialize(Bytes, Element->Layers, Memory, Count); - } - - - - - - - - - - MAYBE_READ_DEBUG_OBJECT_DELIM(); - return Result; -} - -link_internal b32 -Deserialize(u8_cursor *Bytes, layered_brush_editor_0 *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_layered_brush_editor_1.h b/generated/serdes_struct_layered_brush_editor_1.h deleted file mode 100644 index 5a6d57748..000000000 --- a/generated/serdes_struct_layered_brush_editor_1.h +++ /dev/null @@ -1,167 +0,0 @@ -// src/engine/serdes.cpp:553:0 - -link_internal bonsai_type_info -TypeInfo(layered_brush_editor_1 *Ignored) -{ - bonsai_type_info Result = {}; - - Result.Name = CSz("layered_brush_editor_1"); - 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, layered_brush_editor_1 *BaseElement, umm Count = 1) -{ - Assert(Count > 0); - - u64 PointerTrue = True; - u64 PointerFalse = False; - - b32 Result = True; - - - - RangeIterator_t(umm, ElementIndex, Count) - { - layered_brush_editor_1 *Element = BaseElement + ElementIndex; - { - umm ThisCount = (256); - - Result &= Serialize(Bytes, Element->NameBuf, ThisCount); - } - - - - - - Result &= Serialize(Bytes, &Element->LayerCount); - - - - - - { - // TODO(Jesse): Should this really be a safe cast? - umm ThisCount = umm(Element->LayerCount); - - Result &= Serialize(Bytes, Element->Layers, ThisCount); - } - - - - - - Result &= Serialize(Bytes, &Element->SeedBrushWithSelection); - - - - - - Result &= Serialize(Bytes, &Element->BrushFollowsCursor); - - - - - - - - - - MAYBE_WRITE_DEBUG_OBJECT_DELIM(); - } - - return Result; -} - -link_internal b32 -Deserialize(u8_cursor *Bytes, layered_brush_editor_1 *Element, memory_arena *Memory, umm Count = 1); - -link_internal b32 -DeserializeCurrentVersion(u8_cursor *Bytes, layered_brush_editor_1 *Element, memory_arena *Memory); - - - - -link_internal b32 -DeserializeCurrentVersion(u8_cursor *Bytes, layered_brush_editor_1 *Element, memory_arena *Memory) -{ - b32 Result = True; - { - umm Count = (256); - - Result &= Deserialize(Bytes, Element->NameBuf, Memory, Count); - } - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->LayerCount, Memory); - - - - - - { - // TODO(Jesse): Should this really be a safe cast? - umm Count = umm(Element->LayerCount); - - Result &= Deserialize(Bytes, Element->Layers, Memory, Count); - } - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->SeedBrushWithSelection, Memory); - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->BrushFollowsCursor, Memory); - - - - - - - - - - MAYBE_READ_DEBUG_OBJECT_DELIM(); - return Result; -} - -link_internal b32 -Deserialize(u8_cursor *Bytes, layered_brush_editor_1 *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_layered_brush_editor_2.h b/generated/serdes_struct_layered_brush_editor_2.h deleted file mode 100644 index e2a99a9ef..000000000 --- a/generated/serdes_struct_layered_brush_editor_2.h +++ /dev/null @@ -1,147 +0,0 @@ -// src/engine/serdes.cpp:555:0 - -link_internal bonsai_type_info -TypeInfo(layered_brush_editor_2 *Ignored) -{ - bonsai_type_info Result = {}; - - Result.Name = CSz("layered_brush_editor_2"); - 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, layered_brush_editor_2 *BaseElement, umm Count = 1) -{ - Assert(Count > 0); - - u64 PointerTrue = True; - u64 PointerFalse = False; - - b32 Result = True; - - - - RangeIterator_t(umm, ElementIndex, Count) - { - layered_brush_editor_2 *Element = BaseElement + ElementIndex; - Result &= Serialize(Bytes, &Element->LayerCount); - - - - - - { - // TODO(Jesse): Should this really be a safe cast? - umm ThisCount = umm(Element->LayerCount); - - Result &= Serialize(Bytes, Element->Layers, ThisCount); - } - - - - - - Result &= Serialize(Bytes, &Element->SeedBrushWithSelection); - - - - - - Result &= Serialize(Bytes, &Element->BrushFollowsCursor); - - - - - - - - - - MAYBE_WRITE_DEBUG_OBJECT_DELIM(); - } - - return Result; -} - -link_internal b32 -Deserialize(u8_cursor *Bytes, layered_brush_editor_2 *Element, memory_arena *Memory, umm Count = 1); - -link_internal b32 -DeserializeCurrentVersion(u8_cursor *Bytes, layered_brush_editor_2 *Element, memory_arena *Memory); - - - - -link_internal b32 -DeserializeCurrentVersion(u8_cursor *Bytes, layered_brush_editor_2 *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->LayerCount, Memory); - - - - - - { - // TODO(Jesse): Should this really be a safe cast? - umm Count = umm(Element->LayerCount); - - Result &= Deserialize(Bytes, Element->Layers, Memory, Count); - } - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->SeedBrushWithSelection, Memory); - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->BrushFollowsCursor, Memory); - - - - - - - - - - MAYBE_READ_DEBUG_OBJECT_DELIM(); - return Result; -} - -link_internal b32 -Deserialize(u8_cursor *Bytes, layered_brush_editor_2 *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_lighting_settings.h b/generated/serdes_struct_lighting_settings.h index 8a6029a80..8434baf56 100644 --- a/generated/serdes_struct_lighting_settings.h +++ b/generated/serdes_struct_lighting_settings.h @@ -1,12 +1,11 @@ -// src/engine/serdes.cpp:403:0 - +// src/engine/serdes.h:495:0 link_internal bonsai_type_info TypeInfo(lighting_settings *Ignored) { bonsai_type_info Result = {}; Result.Name = CSz("lighting_settings"); - Result.Version =1 ; + Result.Version = 0 ; /* type.map(member) */ /* { */ @@ -24,88 +23,163 @@ Serialize(u8_cursor_block_array *Bytes, lighting_settings *BaseElement, umm Coun { Assert(Count > 0); - u64 PointerTrue = True; + u64 PointerTrue = True; u64 PointerFalse = False; b32 Result = True; - Upsert(TypeInfo(BaseElement), &Global_SerializeTypeTable, Global_SerializeTypeTableArena ); - u64 VersionNumber =1; - Serialize(Bytes, &VersionNumber); - + RangeIterator_t(umm, ElementIndex, Count) { lighting_settings *Element = BaseElement + ElementIndex; - Result &= Serialize(Bytes, &Element->AutoDayNightCycle); + Result &= Serialize(Bytes, &Element->AutoDayNightCycle); // default - Result &= Serialize(Bytes, &Element->tDay); + Result &= Serialize(Bytes, &Element->tDaySpeed); // default - Result &= Serialize(Bytes, &Element->SunP); + Result &= Serialize(Bytes, &Element->tDay); // default - Result &= Serialize(Bytes, &Element->DawnIntensity); + Result &= Serialize(Bytes, &Element->SunP); // default - Result &= Serialize(Bytes, &Element->DawnColor); + Result &= Serialize(Bytes, &Element->FogPower); // default - Result &= Serialize(Bytes, &Element->SunIntensity); - Result &= Serialize(Bytes, &Element->SunColor); + Result &= Serialize(Bytes, &Element->FogColor); // default - Result &= Serialize(Bytes, &Element->DuskIntensity); + Result &= Serialize(Bytes, &Element->DawnIntensity); // default - Result &= Serialize(Bytes, &Element->DuskColor); + Result &= Serialize(Bytes, &Element->DawnHSV); // default - Result &= Serialize(Bytes, &Element->MoonIntensity); + Result &= Serialize(Bytes, &Element->SunIntensity); // default - Result &= Serialize(Bytes, &Element->MoonColor); + Result &= Serialize(Bytes, &Element->SunHSV); // default + + + + + + + Result &= Serialize(Bytes, &Element->DuskIntensity); // default + + + + + + + Result &= Serialize(Bytes, &Element->DuskColor); // default + + + + + + + Result &= Serialize(Bytes, &Element->DuskHSV); // default + + + + + + + Result &= Serialize(Bytes, &Element->MoonIntensity); // default + + + + + + + Result &= Serialize(Bytes, &Element->MoonHSV); // default + + + + + + + Result &= Serialize(Bytes, &Element->CurrentSunColor); // default + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - Result &= Serialize(Bytes, &Element->CurrentSunColor); - MAYBE_WRITE_DEBUG_OBJECT_DELIM(); } @@ -120,43 +194,29 @@ link_internal b32 DeserializeCurrentVersion(u8_cursor *Bytes, lighting_settings *Element, memory_arena *Memory); + + link_internal b32 -DeserializeVersioned(u8_cursor *Bytes, lighting_settings *Element, bonsai_type_info *TypeInfo, memory_arena *Memory) +DeserializeCurrentVersion(u8_cursor *Bytes, lighting_settings *Element, memory_arena *Memory) { - Assert(TypeInfo->Version <=1); - b32 Result = True; - - if (TypeInfo->Version == 0) - { - lighting_settings_0 T0 = {}; - Result &= Deserialize(Bytes, &T0, Memory); - Marshal(&T0, Element); - } + // NOTE(Jesse): Unfortunately we can't check for primitives because + // strings are considered primitive, but need memory to deserialize + Result &= Deserialize(Bytes, &Element->AutoDayNightCycle, Memory); - if (TypeInfo->Version ==1) - { - Result &= DeserializeCurrentVersion(Bytes, Element, Memory); - } - return Result; -} -link_internal b32 -DeserializeCurrentVersion(u8_cursor *Bytes, lighting_settings *Element, memory_arena *Memory) -{ - b32 Result = True; - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->AutoDayNightCycle, Memory); + Result &= Deserialize(Bytes, &Element->tDaySpeed, Memory); - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->tDay, Memory); @@ -164,7 +224,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, lighting_settings *Element, memory_a - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->SunP, Memory); @@ -172,7 +232,23 @@ DeserializeCurrentVersion(u8_cursor *Bytes, lighting_settings *Element, memory_a - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because + // strings are considered primitive, but need memory to deserialize + Result &= Deserialize(Bytes, &Element->FogPower, Memory); + + + + + + // NOTE(Jesse): Unfortunately we can't check for primitives because + // strings are considered primitive, but need memory to deserialize + Result &= Deserialize(Bytes, &Element->FogColor, Memory); + + + + + + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->DawnIntensity, Memory); @@ -180,15 +256,15 @@ DeserializeCurrentVersion(u8_cursor *Bytes, lighting_settings *Element, memory_a - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->DawnColor, Memory); + Result &= Deserialize(Bytes, &Element->DawnHSV, Memory); - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->SunIntensity, Memory); @@ -196,15 +272,15 @@ DeserializeCurrentVersion(u8_cursor *Bytes, lighting_settings *Element, memory_a - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->SunColor, Memory); + Result &= Deserialize(Bytes, &Element->SunHSV, Memory); - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->DuskIntensity, Memory); @@ -212,7 +288,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, lighting_settings *Element, memory_a - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->DuskColor, Memory); @@ -220,7 +296,15 @@ DeserializeCurrentVersion(u8_cursor *Bytes, lighting_settings *Element, memory_a - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because + // strings are considered primitive, but need memory to deserialize + Result &= Deserialize(Bytes, &Element->DuskHSV, Memory); + + + + + + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->MoonIntensity, Memory); @@ -228,19 +312,41 @@ DeserializeCurrentVersion(u8_cursor *Bytes, lighting_settings *Element, memory_a - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->MoonColor, Memory); + Result &= Deserialize(Bytes, &Element->MoonHSV, Memory); - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->CurrentSunColor, Memory); + + + + + + + + + + + + + + + + + + + + + + MAYBE_READ_DEBUG_OBJECT_DELIM(); return Result; @@ -254,22 +360,7 @@ Deserialize(u8_cursor *Bytes, lighting_settings *Element, memory_arena *Memory, b32 Result = True; RangeIterator_t(umm, ElementIndex, Count) { - maybe_bonsai_type_info MaybeSerializedType = GetByName(&Global_SerializeTypeTable, CSz("lighting_settings")); - - if (MaybeSerializedType.Tag) - { - u64 OldIgnoredVersionNumber; - if (MaybeSerializedType.Value.Version > 0) - { - Deserialize(Bytes, &OldIgnoredVersionNumber, Memory); - } - Result &= DeserializeVersioned(Bytes, Element+ElementIndex, &MaybeSerializedType.Value, Memory); - } - else - { - bonsai_type_info T0TypeInfo = {}; - Result &= DeserializeVersioned(Bytes, Element+ElementIndex, &T0TypeInfo, Memory); - } + Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); } diff --git a/generated/serdes_struct_lighting_settings_0.h b/generated/serdes_struct_lighting_settings_0.h deleted file mode 100644 index 70639a59c..000000000 --- a/generated/serdes_struct_lighting_settings_0.h +++ /dev/null @@ -1,239 +0,0 @@ -// src/engine/serdes.cpp:400:0 - -link_internal bonsai_type_info -TypeInfo(lighting_settings_0 *Ignored) -{ - bonsai_type_info Result = {}; - - Result.Name = CSz("lighting_settings_0"); - 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, lighting_settings_0 *BaseElement, umm Count = 1) -{ - Assert(Count > 0); - - u64 PointerTrue = True; - u64 PointerFalse = False; - - b32 Result = True; - - - - RangeIterator_t(umm, ElementIndex, Count) - { - lighting_settings_0 *Element = BaseElement + ElementIndex; - Result &= Serialize(Bytes, &Element->AutoDayNightCycle); - - - - - - Result &= Serialize(Bytes, &Element->tDay); - - - - - - Result &= Serialize(Bytes, &Element->SunP); - - - - - - Result &= Serialize(Bytes, &Element->DawnColor); - - - - - - Result &= Serialize(Bytes, &Element->SunColor); - - - - - - Result &= Serialize(Bytes, &Element->DuskColor); - - - - - - Result &= Serialize(Bytes, &Element->MoonColor); - - - - - - Result &= Serialize(Bytes, &Element->SunIntensity); - - - - - - Result &= Serialize(Bytes, &Element->MoonIntensity); - - - - - - Result &= Serialize(Bytes, &Element->DawnIntensity); - - - - - - Result &= Serialize(Bytes, &Element->DuskIntensity); - - - - - - Result &= Serialize(Bytes, &Element->CurrentSunColor); - - - - MAYBE_WRITE_DEBUG_OBJECT_DELIM(); - } - - return Result; -} - -link_internal b32 -Deserialize(u8_cursor *Bytes, lighting_settings_0 *Element, memory_arena *Memory, umm Count = 1); - -link_internal b32 -DeserializeCurrentVersion(u8_cursor *Bytes, lighting_settings_0 *Element, memory_arena *Memory); - - - - -link_internal b32 -DeserializeCurrentVersion(u8_cursor *Bytes, lighting_settings_0 *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->AutoDayNightCycle, Memory); - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->tDay, Memory); - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->SunP, Memory); - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->DawnColor, Memory); - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->SunColor, Memory); - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->DuskColor, Memory); - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->MoonColor, Memory); - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->SunIntensity, Memory); - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->MoonIntensity, Memory); - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->DawnIntensity, Memory); - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->DuskIntensity, Memory); - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->CurrentSunColor, Memory); - - - - MAYBE_READ_DEBUG_OBJECT_DELIM(); - return Result; -} - -link_internal b32 -Deserialize(u8_cursor *Bytes, lighting_settings_0 *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_model.h b/generated/serdes_struct_model.h index 8fce9f3ed..e2e1e0d63 100644 --- a/generated/serdes_struct_model.h +++ b/generated/serdes_struct_model.h @@ -1,12 +1,11 @@ -// src/engine/serdes.cpp:296:0 - +// src/engine/serdes.h:495:0 link_internal bonsai_type_info TypeInfo(model *Ignored) { bonsai_type_info Result = {}; Result.Name = CSz("model"); - Result.Version = 0 ; + Result.Version = 0 ; /* type.map(member) */ /* { */ @@ -24,7 +23,7 @@ Serialize(u8_cursor_block_array *Bytes, model *BaseElement, umm Count = 1) { Assert(Count > 0); - u64 PointerTrue = True; + u64 PointerTrue = True; u64 PointerFalse = False; b32 Result = True; @@ -34,27 +33,49 @@ Serialize(u8_cursor_block_array *Bytes, model *BaseElement, umm Count = 1) RangeIterator_t(umm, ElementIndex, Count) { model *Element = BaseElement + ElementIndex; - Result &= Serialize(Bytes, &Element->Vox); + Result &= Serialize(Bytes, &Element->Vox); // default - Result &= Serialize(Bytes, &Element->TransparentMesh); + + + Result &= Serialize(Bytes, &Element->TransparentMesh); // default - Result &= Serialize(Bytes, &Element->Animation); + Result &= Serialize(Bytes, &Element->Animation); // default - Result &= Serialize(Bytes, &Element->Dim); - + + + Result &= Serialize(Bytes, &Element->Dim); // default + + + + + + + + + + + + + + + + + + + MAYBE_WRITE_DEBUG_OBJECT_DELIM(); } @@ -75,7 +96,7 @@ link_internal b32 DeserializeCurrentVersion(u8_cursor *Bytes, model *Element, memory_arena *Memory) { b32 Result = True; - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Vox, Memory); @@ -83,7 +104,9 @@ DeserializeCurrentVersion(u8_cursor *Bytes, model *Element, memory_arena *Memory - // NOTE(Jesse): Unfortunately we can't check for primitives because + + + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->TransparentMesh, Memory); @@ -91,7 +114,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, model *Element, memory_arena *Memory - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Animation, Memory); @@ -99,11 +122,23 @@ DeserializeCurrentVersion(u8_cursor *Bytes, model *Element, memory_arena *Memory - // NOTE(Jesse): Unfortunately we can't check for primitives because + // 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); + + + + + + + + + + + + MAYBE_READ_DEBUG_OBJECT_DELIM(); return Result; @@ -117,7 +152,7 @@ Deserialize(u8_cursor *Bytes, model *Element, memory_arena *Memory, umm Count) b32 Result = True; RangeIterator_t(umm, ElementIndex, Count) { - Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); + Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); } diff --git a/generated/serdes_struct_noise_layer.h b/generated/serdes_struct_noise_layer.h index 5b204715c..d25864970 100644 --- a/generated/serdes_struct_noise_layer.h +++ b/generated/serdes_struct_noise_layer.h @@ -1,12 +1,11 @@ -// src/engine/serdes.cpp:530:0 - +// src/engine/serdes.h:495:0 link_internal bonsai_type_info TypeInfo(noise_layer *Ignored) { bonsai_type_info Result = {}; Result.Name = CSz("noise_layer"); - Result.Version =1 ; + Result.Version = 1 ; /* type.map(member) */ /* { */ @@ -24,39 +23,56 @@ Serialize(u8_cursor_block_array *Bytes, noise_layer *BaseElement, umm Count = 1) { Assert(Count > 0); - u64 PointerTrue = True; + u64 PointerTrue = True; u64 PointerFalse = False; b32 Result = True; - Upsert(TypeInfo(BaseElement), &Global_SerializeTypeTable, Global_SerializeTypeTableArena ); - u64 VersionNumber =1; + Upsert(TypeInfo(BaseElement), &Global_SerializeTypeTable, Global_SerializeTypeTableArena ); + u64 VersionNumber = 1; Serialize(Bytes, &VersionNumber); RangeIterator_t(umm, ElementIndex, Count) { noise_layer *Element = BaseElement + ElementIndex; - Result &= Serialize(Bytes, (u32*)&Element->Type); + Result &= Serialize(Bytes, (u32*)&Element->Type); // enum - Result &= Serialize(Bytes, &Element->White); + Result &= Serialize(Bytes, &Element->White); // default - Result &= Serialize(Bytes, &Element->Perlin); + Result &= Serialize(Bytes, &Element->Perlin); // default - Result &= Serialize(Bytes, &Element->Voronoi); - + + Result &= Serialize(Bytes, &Element->Voronoi); // default + + + + + + + + + + + + + + + + + MAYBE_WRITE_DEBUG_OBJECT_DELIM(); } @@ -74,11 +90,11 @@ DeserializeCurrentVersion(u8_cursor *Bytes, noise_layer *Element, memory_arena * link_internal b32 DeserializeVersioned(u8_cursor *Bytes, noise_layer *Element, bonsai_type_info *TypeInfo, memory_arena *Memory) { - Assert(TypeInfo->Version <=1); + Assert(TypeInfo->Version <= 1); b32 Result = True; - if (TypeInfo->Version == 0) + if (TypeInfo->Version == 0) { noise_layer_0 T0 = {}; Result &= Deserialize(Bytes, &T0, Memory); @@ -86,7 +102,7 @@ DeserializeVersioned(u8_cursor *Bytes, noise_layer *Element, bonsai_type_info *T } - if (TypeInfo->Version ==1) + if (TypeInfo->Version == 1) { Result &= DeserializeCurrentVersion(Bytes, Element, Memory); } @@ -99,12 +115,12 @@ link_internal b32 DeserializeCurrentVersion(u8_cursor *Bytes, noise_layer *Element, memory_arena *Memory) { b32 Result = True; - Element->Type = Cast(ui_noise_type, Read_u32(Bytes)); + Element->Type = Cast(ui_noise_type, Read_u32(Bytes)); - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->White, Memory); @@ -112,7 +128,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, noise_layer *Element, memory_arena * - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Perlin, Memory); @@ -120,11 +136,21 @@ DeserializeCurrentVersion(u8_cursor *Bytes, noise_layer *Element, memory_arena * - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Voronoi, Memory); + + + + + + + + + + MAYBE_READ_DEBUG_OBJECT_DELIM(); return Result; @@ -138,7 +164,7 @@ Deserialize(u8_cursor *Bytes, noise_layer *Element, memory_arena *Memory, umm Co b32 Result = True; RangeIterator_t(umm, ElementIndex, Count) { - maybe_bonsai_type_info MaybeSerializedType = GetByName(&Global_SerializeTypeTable, CSz("noise_layer")); + maybe_bonsai_type_info MaybeSerializedType = GetByName(&Global_SerializeTypeTable, CSz("noise_layer")); if (MaybeSerializedType.Tag) { diff --git a/generated/serdes_struct_noise_layer_0.h b/generated/serdes_struct_noise_layer_0.h index 99d5f420d..a113c8306 100644 --- a/generated/serdes_struct_noise_layer_0.h +++ b/generated/serdes_struct_noise_layer_0.h @@ -1,12 +1,11 @@ -// src/engine/serdes.cpp:528:0 - +// src/engine/serdes.h:495:0 link_internal bonsai_type_info TypeInfo(noise_layer_0 *Ignored) { bonsai_type_info Result = {}; Result.Name = CSz("noise_layer_0"); - Result.Version = 0 ; + Result.Version = 0 ; /* type.map(member) */ /* { */ @@ -24,7 +23,7 @@ Serialize(u8_cursor_block_array *Bytes, noise_layer_0 *BaseElement, umm Count = { Assert(Count > 0); - u64 PointerTrue = True; + u64 PointerTrue = True; u64 PointerFalse = False; b32 Result = True; @@ -34,20 +33,34 @@ Serialize(u8_cursor_block_array *Bytes, noise_layer_0 *BaseElement, umm Count = RangeIterator_t(umm, ElementIndex, Count) { noise_layer_0 *Element = BaseElement + ElementIndex; - Result &= Serialize(Bytes, (u32*)&Element->Type); + Result &= Serialize(Bytes, (u32*)&Element->Type); // enum - Result &= Serialize(Bytes, &Element->Perlin); + Result &= Serialize(Bytes, &Element->Perlin); // default - Result &= Serialize(Bytes, &Element->Voronoi); - + Result &= Serialize(Bytes, &Element->Voronoi); // default + + + + + + + + + + + + + + + MAYBE_WRITE_DEBUG_OBJECT_DELIM(); } @@ -68,12 +81,12 @@ link_internal b32 DeserializeCurrentVersion(u8_cursor *Bytes, noise_layer_0 *Element, memory_arena *Memory) { b32 Result = True; - Element->Type = Cast(ui_noise_type, Read_u32(Bytes)); + Element->Type = Cast(ui_noise_type, Read_u32(Bytes)); - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Perlin, Memory); @@ -81,11 +94,20 @@ DeserializeCurrentVersion(u8_cursor *Bytes, noise_layer_0 *Element, memory_arena - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Voronoi, Memory); + + + + + + + + + MAYBE_READ_DEBUG_OBJECT_DELIM(); return Result; @@ -99,7 +121,7 @@ Deserialize(u8_cursor *Bytes, noise_layer_0 *Element, memory_arena *Memory, umm b32 Result = True; RangeIterator_t(umm, ElementIndex, Count) { - Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); + Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); } diff --git a/generated/serdes_struct_particle_system.h b/generated/serdes_struct_particle_system.h index 4e39922e7..e09c1b457 100644 --- a/generated/serdes_struct_particle_system.h +++ b/generated/serdes_struct_particle_system.h @@ -1,12 +1,11 @@ -// src/engine/serdes.cpp:287:0 - +// src/engine/serdes.h:495:0 link_internal bonsai_type_info TypeInfo(particle_system *Ignored) { bonsai_type_info Result = {}; Result.Name = CSz("particle_system"); - Result.Version =1 ; + Result.Version = 1 ; /* type.map(member) */ /* { */ @@ -24,146 +23,166 @@ Serialize(u8_cursor_block_array *Bytes, particle_system *BaseElement, umm Count { Assert(Count > 0); - u64 PointerTrue = True; + u64 PointerTrue = True; u64 PointerFalse = False; b32 Result = True; - Upsert(TypeInfo(BaseElement), &Global_SerializeTypeTable, Global_SerializeTypeTableArena ); - u64 VersionNumber =1; + Upsert(TypeInfo(BaseElement), &Global_SerializeTypeTable, Global_SerializeTypeTableArena ); + u64 VersionNumber = 1; Serialize(Bytes, &VersionNumber); RangeIterator_t(umm, ElementIndex, Count) { particle_system *Element = BaseElement + ElementIndex; - Result &= Serialize(Bytes, &Element->Entropy); + Result &= Serialize(Bytes, &Element->Entropy); // default - Result &= Serialize(Bytes, (u32*)&Element->SpawnType); + Result &= Serialize(Bytes, (u32*)&Element->SpawnType); // enum - Result &= Serialize(Bytes, &Element->Drag); + Result &= Serialize(Bytes, &Element->Drag); // default - Result &= Serialize(Bytes, &Element->Lifetime); + Result &= Serialize(Bytes, &Element->Lifetime); // default - Result &= Serialize(Bytes, &Element->EmissionDelay); + Result &= Serialize(Bytes, &Element->EmissionDelay); // default - Result &= Serialize(Bytes, &Element->EmissionLifespan); + Result &= Serialize(Bytes, &Element->EmissionLifespan); // default - Result &= Serialize(Bytes, &Element->ActiveParticles); - Result &= Serialize(Bytes, &Element->LifespanMod); + Result &= Serialize(Bytes, &Element->ActiveParticles); // default - Result &= Serialize(Bytes, &Element->ParticleLifespan); + Result &= Serialize(Bytes, &Element->LifespanMod); // default - Result &= Serialize(Bytes, &Element->ParticlesPerSecond); + Result &= Serialize(Bytes, &Element->ParticleLifespan); // default - Result &= Serialize(Bytes, &Element->ParticleLightEmission); + Result &= Serialize(Bytes, &Element->ParticlesPerSecond); // default - Result &= Serialize(Bytes, &Element->ParticleLightEmissionChance); + Result &= Serialize(Bytes, &Element->ParticleLightEmission); // default - Result &= Serialize(Bytes, &Element->ParticleStartingTransparency); - Result &= Serialize(Bytes, &Element->ParticleEndingTransparency); + Result &= Serialize(Bytes, &Element->ParticleLightEmissionChance); // default - Result &= Serialize(Bytes, &Element->ParticleStartingDim); + Result &= Serialize(Bytes, &Element->ParticleStartingTransparency); // default - Result &= Serialize(Bytes, &Element->ParticleEndingDim); + Result &= Serialize(Bytes, &Element->ParticleEndingTransparency); // default - Result &= Serialize(Bytes, &Element->ParticleTurbMin); + Result &= Serialize(Bytes, &Element->ParticleStartingDim); // default - Result &= Serialize(Bytes, &Element->ParticleTurbMax); + Result &= Serialize(Bytes, &Element->ParticleEndingDim); // default - Result &= Serialize(Bytes, &Element->SpawnRegion); - Result &= Serialize(Bytes, &Element->SystemMovementCoefficient); + Result &= Serialize(Bytes, &Element->ParticleTurbMin); // default - Result &= Serialize(Bytes, &Element->ElapsedSinceLastEmission); + Result &= Serialize(Bytes, &Element->ParticleTurbMax); // default - { - umm ThisCount = 6; + + + Result &= Serialize(Bytes, &Element->SpawnRegion); // default + + + + + + + Result &= Serialize(Bytes, &Element->SystemMovementCoefficient); // default + + + + + + + Result &= Serialize(Bytes, &Element->ElapsedSinceLastEmission); // default + + + + + + + { + umm ThisCount = 6; Result &= Serialize(Bytes, Element->PackedHSVColors, ThisCount); } @@ -172,9 +191,55 @@ Serialize(u8_cursor_block_array *Bytes, particle_system *BaseElement, umm Count + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + MAYBE_WRITE_DEBUG_OBJECT_DELIM(); } @@ -192,11 +257,11 @@ DeserializeCurrentVersion(u8_cursor *Bytes, particle_system *Element, memory_are link_internal b32 DeserializeVersioned(u8_cursor *Bytes, particle_system *Element, bonsai_type_info *TypeInfo, memory_arena *Memory) { - Assert(TypeInfo->Version <=1); + Assert(TypeInfo->Version <= 1); b32 Result = True; - if (TypeInfo->Version == 0) + if (TypeInfo->Version == 0) { particle_system_0 T0 = {}; Result &= Deserialize(Bytes, &T0, Memory); @@ -204,7 +269,7 @@ DeserializeVersioned(u8_cursor *Bytes, particle_system *Element, bonsai_type_inf } - if (TypeInfo->Version ==1) + if (TypeInfo->Version == 1) { Result &= DeserializeCurrentVersion(Bytes, Element, Memory); } @@ -217,7 +282,7 @@ link_internal b32 DeserializeCurrentVersion(u8_cursor *Bytes, particle_system *Element, memory_arena *Memory) { b32 Result = True; - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Entropy, Memory); @@ -225,12 +290,12 @@ DeserializeCurrentVersion(u8_cursor *Bytes, particle_system *Element, memory_are - Element->SpawnType = Cast(particle_spawn_type, Read_u32(Bytes)); + Element->SpawnType = Cast(particle_spawn_type, Read_u32(Bytes)); - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Drag, Memory); @@ -238,7 +303,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, particle_system *Element, memory_are - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Lifetime, Memory); @@ -246,7 +311,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, particle_system *Element, memory_are - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->EmissionDelay, Memory); @@ -254,7 +319,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, particle_system *Element, memory_are - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->EmissionLifespan, Memory); @@ -262,7 +327,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, particle_system *Element, memory_are - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->ActiveParticles, Memory); @@ -270,7 +335,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, particle_system *Element, memory_are - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->LifespanMod, Memory); @@ -278,7 +343,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, particle_system *Element, memory_are - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->ParticleLifespan, Memory); @@ -286,7 +351,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, particle_system *Element, memory_are - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->ParticlesPerSecond, Memory); @@ -294,7 +359,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, particle_system *Element, memory_are - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->ParticleLightEmission, Memory); @@ -302,7 +367,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, particle_system *Element, memory_are - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->ParticleLightEmissionChance, Memory); @@ -310,7 +375,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, particle_system *Element, memory_are - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->ParticleStartingTransparency, Memory); @@ -318,7 +383,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, particle_system *Element, memory_are - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->ParticleEndingTransparency, Memory); @@ -326,7 +391,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, particle_system *Element, memory_are - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->ParticleStartingDim, Memory); @@ -334,7 +399,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, particle_system *Element, memory_are - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->ParticleEndingDim, Memory); @@ -342,7 +407,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, particle_system *Element, memory_are - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->ParticleTurbMin, Memory); @@ -350,7 +415,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, particle_system *Element, memory_are - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->ParticleTurbMax, Memory); @@ -358,7 +423,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, particle_system *Element, memory_are - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->SpawnRegion, Memory); @@ -366,7 +431,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, particle_system *Element, memory_are - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->SystemMovementCoefficient, Memory); @@ -374,7 +439,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, particle_system *Element, memory_are - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->ElapsedSinceLastEmission, Memory); @@ -382,8 +447,8 @@ DeserializeCurrentVersion(u8_cursor *Bytes, particle_system *Element, memory_are - { - umm Count = 6; + { + umm Count = 6; Result &= Deserialize(Bytes, Element->PackedHSVColors, Memory, Count); } @@ -392,9 +457,33 @@ DeserializeCurrentVersion(u8_cursor *Bytes, particle_system *Element, memory_are + + + + + + + + + + + + + + + + + + + + + + + + MAYBE_READ_DEBUG_OBJECT_DELIM(); return Result; @@ -408,7 +497,7 @@ Deserialize(u8_cursor *Bytes, particle_system *Element, memory_arena *Memory, um b32 Result = True; RangeIterator_t(umm, ElementIndex, Count) { - maybe_bonsai_type_info MaybeSerializedType = GetByName(&Global_SerializeTypeTable, CSz("particle_system")); + maybe_bonsai_type_info MaybeSerializedType = GetByName(&Global_SerializeTypeTable, CSz("particle_system")); if (MaybeSerializedType.Tag) { diff --git a/generated/serdes_struct_particle_system_0.h b/generated/serdes_struct_particle_system_0.h index 57bb243d1..106549b7e 100644 --- a/generated/serdes_struct_particle_system_0.h +++ b/generated/serdes_struct_particle_system_0.h @@ -1,12 +1,11 @@ -// src/engine/serdes.cpp:284:0 - +// src/engine/serdes.h:495:0 link_internal bonsai_type_info TypeInfo(particle_system_0 *Ignored) { bonsai_type_info Result = {}; Result.Name = CSz("particle_system_0"); - Result.Version = 0 ; + Result.Version = 0 ; /* type.map(member) */ /* { */ @@ -24,7 +23,7 @@ Serialize(u8_cursor_block_array *Bytes, particle_system_0 *BaseElement, umm Coun { Assert(Count > 0); - u64 PointerTrue = True; + u64 PointerTrue = True; u64 PointerFalse = False; b32 Result = True; @@ -34,133 +33,153 @@ Serialize(u8_cursor_block_array *Bytes, particle_system_0 *BaseElement, umm Coun RangeIterator_t(umm, ElementIndex, Count) { particle_system_0 *Element = BaseElement + ElementIndex; - Result &= Serialize(Bytes, &Element->Entropy); + Result &= Serialize(Bytes, &Element->Entropy); // default + + + + + + + Result &= Serialize(Bytes, (u32*)&Element->SpawnType); // enum + + + + + Result &= Serialize(Bytes, &Element->Drag); // default + + + + + + + Result &= Serialize(Bytes, &Element->Lifetime); // default + - Result &= Serialize(Bytes, (u32*)&Element->SpawnType); + Result &= Serialize(Bytes, &Element->EmissionDelay); // default - Result &= Serialize(Bytes, &Element->Drag); + Result &= Serialize(Bytes, &Element->EmissionLifespan); // default - Result &= Serialize(Bytes, &Element->Lifetime); + Result &= Serialize(Bytes, &Element->ActiveParticles); // default - Result &= Serialize(Bytes, &Element->EmissionDelay); + Result &= Serialize(Bytes, &Element->LifespanMod); // default - Result &= Serialize(Bytes, &Element->EmissionLifespan); - Result &= Serialize(Bytes, &Element->ActiveParticles); + Result &= Serialize(Bytes, &Element->ParticleLifespan); // default - Result &= Serialize(Bytes, &Element->LifespanMod); + Result &= Serialize(Bytes, &Element->ParticlesPerSecond); // default - Result &= Serialize(Bytes, &Element->ParticleLifespan); + Result &= Serialize(Bytes, &Element->ParticleLightEmission); // default - Result &= Serialize(Bytes, &Element->ParticlesPerSecond); + Result &= Serialize(Bytes, &Element->ParticleLightEmissionChance); // default - Result &= Serialize(Bytes, &Element->ParticleLightEmission); + Result &= Serialize(Bytes, &Element->ParticleStartingTransparency); // default - Result &= Serialize(Bytes, &Element->ParticleLightEmissionChance); - Result &= Serialize(Bytes, &Element->ParticleStartingTransparency); + Result &= Serialize(Bytes, &Element->ParticleEndingTransparency); // default - Result &= Serialize(Bytes, &Element->ParticleEndingTransparency); + Result &= Serialize(Bytes, &Element->ParticleStartingDim); // default - Result &= Serialize(Bytes, &Element->ParticleStartingDim); + Result &= Serialize(Bytes, &Element->ParticleEndingDim); // default - Result &= Serialize(Bytes, &Element->ParticleEndingDim); + Result &= Serialize(Bytes, &Element->ParticleTurbMin); // default - Result &= Serialize(Bytes, &Element->ParticleTurbMin); + Result &= Serialize(Bytes, &Element->ParticleTurbMax); // default - Result &= Serialize(Bytes, &Element->ParticleTurbMax); - Result &= Serialize(Bytes, &Element->SpawnRegion); + Result &= Serialize(Bytes, &Element->SpawnRegion); // default - Result &= Serialize(Bytes, &Element->SystemMovementCoefficient); + Result &= Serialize(Bytes, &Element->SystemMovementCoefficient); // default - Result &= Serialize(Bytes, &Element->ElapsedSinceLastEmission); + Result &= Serialize(Bytes, &Element->ElapsedSinceLastEmission); // default - { - umm ThisCount = 6; + + + + { + umm ThisCount = 6; Result &= Serialize(Bytes, Element->MCVColors, ThisCount); } @@ -169,9 +188,55 @@ Serialize(u8_cursor_block_array *Bytes, particle_system_0 *BaseElement, umm Coun + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + MAYBE_WRITE_DEBUG_OBJECT_DELIM(); } @@ -192,7 +257,7 @@ link_internal b32 DeserializeCurrentVersion(u8_cursor *Bytes, particle_system_0 *Element, memory_arena *Memory) { b32 Result = True; - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Entropy, Memory); @@ -200,12 +265,12 @@ DeserializeCurrentVersion(u8_cursor *Bytes, particle_system_0 *Element, memory_a - Element->SpawnType = Cast(particle_spawn_type, Read_u32(Bytes)); + Element->SpawnType = Cast(particle_spawn_type, Read_u32(Bytes)); - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Drag, Memory); @@ -213,7 +278,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, particle_system_0 *Element, memory_a - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Lifetime, Memory); @@ -221,7 +286,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, particle_system_0 *Element, memory_a - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->EmissionDelay, Memory); @@ -229,7 +294,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, particle_system_0 *Element, memory_a - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->EmissionLifespan, Memory); @@ -237,7 +302,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, particle_system_0 *Element, memory_a - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->ActiveParticles, Memory); @@ -245,7 +310,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, particle_system_0 *Element, memory_a - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->LifespanMod, Memory); @@ -253,7 +318,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, particle_system_0 *Element, memory_a - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->ParticleLifespan, Memory); @@ -261,7 +326,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, particle_system_0 *Element, memory_a - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->ParticlesPerSecond, Memory); @@ -269,7 +334,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, particle_system_0 *Element, memory_a - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->ParticleLightEmission, Memory); @@ -277,7 +342,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, particle_system_0 *Element, memory_a - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->ParticleLightEmissionChance, Memory); @@ -285,7 +350,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, particle_system_0 *Element, memory_a - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->ParticleStartingTransparency, Memory); @@ -293,7 +358,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, particle_system_0 *Element, memory_a - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->ParticleEndingTransparency, Memory); @@ -301,7 +366,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, particle_system_0 *Element, memory_a - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->ParticleStartingDim, Memory); @@ -309,7 +374,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, particle_system_0 *Element, memory_a - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->ParticleEndingDim, Memory); @@ -317,7 +382,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, particle_system_0 *Element, memory_a - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->ParticleTurbMin, Memory); @@ -325,7 +390,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, particle_system_0 *Element, memory_a - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->ParticleTurbMax, Memory); @@ -333,7 +398,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, particle_system_0 *Element, memory_a - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->SpawnRegion, Memory); @@ -341,7 +406,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, particle_system_0 *Element, memory_a - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->SystemMovementCoefficient, Memory); @@ -349,7 +414,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, particle_system_0 *Element, memory_a - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->ElapsedSinceLastEmission, Memory); @@ -357,8 +422,8 @@ DeserializeCurrentVersion(u8_cursor *Bytes, particle_system_0 *Element, memory_a - { - umm Count = 6; + { + umm Count = 6; Result &= Deserialize(Bytes, Element->MCVColors, Memory, Count); } @@ -367,9 +432,33 @@ DeserializeCurrentVersion(u8_cursor *Bytes, particle_system_0 *Element, memory_a + + + + + + + + + + + + + + + + + + + + + + + + MAYBE_READ_DEBUG_OBJECT_DELIM(); return Result; @@ -383,7 +472,7 @@ Deserialize(u8_cursor *Bytes, particle_system_0 *Element, memory_arena *Memory, b32 Result = True; RangeIterator_t(umm, ElementIndex, Count) { - Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); + Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); } diff --git a/generated/serdes_struct_perlin_noise_params.h b/generated/serdes_struct_perlin_noise_params.h index a2e7301a1..36eb74d9c 100644 --- a/generated/serdes_struct_perlin_noise_params.h +++ b/generated/serdes_struct_perlin_noise_params.h @@ -1,12 +1,11 @@ -// src/engine/serdes.cpp:524:0 - +// src/engine/serdes.h:495:0 link_internal bonsai_type_info TypeInfo(perlin_noise_params *Ignored) { bonsai_type_info Result = {}; Result.Name = CSz("perlin_noise_params"); - Result.Version = 0 ; + Result.Version = 0 ; /* type.map(member) */ /* { */ @@ -24,7 +23,7 @@ Serialize(u8_cursor_block_array *Bytes, perlin_noise_params *BaseElement, umm Co { Assert(Count > 0); - u64 PointerTrue = True; + u64 PointerTrue = True; u64 PointerFalse = False; b32 Result = True; @@ -34,21 +33,18 @@ Serialize(u8_cursor_block_array *Bytes, perlin_noise_params *BaseElement, umm Co RangeIterator_t(umm, ElementIndex, Count) { perlin_noise_params *Element = BaseElement + ElementIndex; - Result &= Serialize(Bytes, &Element->Threshold); - + Result &= Serialize(Bytes, &Element->Period); // default - Result &= Serialize(Bytes, &Element->Period); + - Result &= Serialize(Bytes, &Element->Amplitude); - MAYBE_WRITE_DEBUG_OBJECT_DELIM(); } @@ -69,27 +65,18 @@ link_internal b32 DeserializeCurrentVersion(u8_cursor *Bytes, perlin_noise_params *Element, memory_arena *Memory) { b32 Result = True; - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->Threshold, Memory); - - - + Result &= Deserialize(Bytes, &Element->Period, Memory); - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->Period, Memory); - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->Amplitude, Memory); + - MAYBE_READ_DEBUG_OBJECT_DELIM(); return Result; @@ -103,7 +90,7 @@ Deserialize(u8_cursor *Bytes, perlin_noise_params *Element, memory_arena *Memory b32 Result = True; RangeIterator_t(umm, ElementIndex, Count) { - Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); + Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); } diff --git a/generated/serdes_struct_physics.h b/generated/serdes_struct_physics.h index 151f27d65..60c0d0991 100644 --- a/generated/serdes_struct_physics.h +++ b/generated/serdes_struct_physics.h @@ -1,12 +1,11 @@ -// src/engine/serdes.cpp:293:0 - +// src/engine/serdes.h:495:0 link_internal bonsai_type_info TypeInfo(physics *Ignored) { bonsai_type_info Result = {}; Result.Name = CSz("physics"); - Result.Version = 0 ; + Result.Version = 0 ; /* type.map(member) */ /* { */ @@ -24,7 +23,7 @@ Serialize(u8_cursor_block_array *Bytes, physics *BaseElement, umm Count = 1) { Assert(Count > 0); - u64 PointerTrue = True; + u64 PointerTrue = True; u64 PointerFalse = False; b32 Result = True; @@ -34,33 +33,54 @@ Serialize(u8_cursor_block_array *Bytes, physics *BaseElement, umm Count = 1) RangeIterator_t(umm, ElementIndex, Count) { physics *Element = BaseElement + ElementIndex; - Result &= Serialize(Bytes, &Element->Velocity); + Result &= Serialize(Bytes, &Element->Velocity); // default - Result &= Serialize(Bytes, &Element->Force); + Result &= Serialize(Bytes, &Element->Force); // default - Result &= Serialize(Bytes, &Element->Delta); + Result &= Serialize(Bytes, &Element->Delta); // default - Result &= Serialize(Bytes, &Element->Mass); + Result &= Serialize(Bytes, &Element->Mass); // default - Result &= Serialize(Bytes, &Element->Speed); - + + + + Result &= Serialize(Bytes, &Element->Speed); // default + + + + + + + + + + + + + + + + + + + MAYBE_WRITE_DEBUG_OBJECT_DELIM(); } @@ -81,7 +101,7 @@ link_internal b32 DeserializeCurrentVersion(u8_cursor *Bytes, physics *Element, memory_arena *Memory) { b32 Result = True; - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Velocity, Memory); @@ -89,7 +109,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, physics *Element, memory_arena *Memo - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Force, Memory); @@ -97,7 +117,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, physics *Element, memory_arena *Memo - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Delta, Memory); @@ -105,7 +125,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, physics *Element, memory_arena *Memo - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Mass, Memory); @@ -113,11 +133,22 @@ DeserializeCurrentVersion(u8_cursor *Bytes, physics *Element, memory_arena *Memo - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Speed, Memory); + + + + + + + + + + + MAYBE_READ_DEBUG_OBJECT_DELIM(); return Result; @@ -131,7 +162,7 @@ Deserialize(u8_cursor *Bytes, physics *Element, memory_arena *Memory, umm Count) b32 Result = True; RangeIterator_t(umm, ElementIndex, Count) { - Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); + Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); } diff --git a/generated/serdes_struct_plane.h b/generated/serdes_struct_plane.h index 86a77017b..de1d78533 100644 --- a/generated/serdes_struct_plane.h +++ b/generated/serdes_struct_plane.h @@ -1,12 +1,11 @@ -// src/engine/serdes.cpp:27:0 - +// src/engine/serdes.h:495:0 link_internal bonsai_type_info TypeInfo(plane *Ignored) { bonsai_type_info Result = {}; Result.Name = CSz("plane"); - Result.Version = 0 ; + Result.Version = 0 ; /* type.map(member) */ /* { */ @@ -24,7 +23,7 @@ Serialize(u8_cursor_block_array *Bytes, plane *BaseElement, umm Count = 1) { Assert(Count > 0); - u64 PointerTrue = True; + u64 PointerTrue = True; u64 PointerFalse = False; b32 Result = True; @@ -34,27 +33,27 @@ Serialize(u8_cursor_block_array *Bytes, plane *BaseElement, umm Count = 1) RangeIterator_t(umm, ElementIndex, Count) { plane *Element = BaseElement + ElementIndex; - Result &= Serialize(Bytes, &Element->P); + Result &= Serialize(Bytes, &Element->Normal); // default - Result &= Serialize(Bytes, &Element->Normal); + Result &= Serialize(Bytes, &Element->DistanceToOrigin); // default - Result &= Serialize(Bytes, &Element->d); + + - MAYBE_WRITE_DEBUG_OBJECT_DELIM(); } @@ -75,15 +74,7 @@ link_internal b32 DeserializeCurrentVersion(u8_cursor *Bytes, plane *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->P, Memory); - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Normal, Memory); @@ -91,9 +82,9 @@ DeserializeCurrentVersion(u8_cursor *Bytes, plane *Element, memory_arena *Memory - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->d, Memory); + Result &= Deserialize(Bytes, &Element->DistanceToOrigin, Memory); @@ -101,8 +92,10 @@ DeserializeCurrentVersion(u8_cursor *Bytes, plane *Element, memory_arena *Memory + + MAYBE_READ_DEBUG_OBJECT_DELIM(); return Result; } @@ -115,7 +108,7 @@ Deserialize(u8_cursor *Bytes, plane *Element, memory_arena *Memory, umm Count) b32 Result = True; RangeIterator_t(umm, ElementIndex, Count) { - Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); + Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); } diff --git a/generated/serdes_struct_random_series.h b/generated/serdes_struct_random_series.h index 8069cdc99..cee282868 100644 --- a/generated/serdes_struct_random_series.h +++ b/generated/serdes_struct_random_series.h @@ -1,12 +1,11 @@ -// src/engine/serdes.cpp:274:0 - +// src/engine/serdes.h:495:0 link_internal bonsai_type_info TypeInfo(random_series *Ignored) { bonsai_type_info Result = {}; Result.Name = CSz("random_series"); - Result.Version = 0 ; + Result.Version = 0 ; /* type.map(member) */ /* { */ @@ -24,7 +23,7 @@ Serialize(u8_cursor_block_array *Bytes, random_series *BaseElement, umm Count = { Assert(Count > 0); - u64 PointerTrue = True; + u64 PointerTrue = True; u64 PointerFalse = False; b32 Result = True; @@ -34,9 +33,18 @@ Serialize(u8_cursor_block_array *Bytes, random_series *BaseElement, umm Count = RangeIterator_t(umm, ElementIndex, Count) { random_series *Element = BaseElement + ElementIndex; - Result &= Serialize(Bytes, &Element->Seed); + Result &= Serialize(Bytes, &Element->Seed); // default + + + + + + + + + + - MAYBE_WRITE_DEBUG_OBJECT_DELIM(); } @@ -57,11 +65,18 @@ link_internal b32 DeserializeCurrentVersion(u8_cursor *Bytes, random_series *Element, memory_arena *Memory) { b32 Result = True; - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Seed, Memory); - + + + + + + + + MAYBE_READ_DEBUG_OBJECT_DELIM(); return Result; @@ -75,7 +90,7 @@ Deserialize(u8_cursor *Bytes, random_series *Element, memory_arena *Memory, umm b32 Result = True; RangeIterator_t(umm, ElementIndex, Count) { - Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); + Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); } diff --git a/generated/serdes_struct_rect3.h b/generated/serdes_struct_rect3.h index 9f3a25825..fb3b05a4a 100644 --- a/generated/serdes_struct_rect3.h +++ b/generated/serdes_struct_rect3.h @@ -1,12 +1,11 @@ -// src/engine/serdes.cpp:268:0 - +// src/engine/serdes.h:495:0 link_internal bonsai_type_info TypeInfo(rect3 *Ignored) { bonsai_type_info Result = {}; Result.Name = CSz("rect3"); - Result.Version = 0 ; + Result.Version = 0 ; /* type.map(member) */ /* { */ @@ -24,7 +23,7 @@ Serialize(u8_cursor_block_array *Bytes, rect3 *BaseElement, umm Count = 1) { Assert(Count > 0); - u64 PointerTrue = True; + u64 PointerTrue = True; u64 PointerFalse = False; b32 Result = True; @@ -34,15 +33,27 @@ Serialize(u8_cursor_block_array *Bytes, rect3 *BaseElement, umm Count = 1) RangeIterator_t(umm, ElementIndex, Count) { rect3 *Element = BaseElement + ElementIndex; - Result &= Serialize(Bytes, &Element->Min); + Result &= Serialize(Bytes, &Element->Min); // default - Result &= Serialize(Bytes, &Element->Max); - + Result &= Serialize(Bytes, &Element->Max); // default + + + + + + + + + + + + + MAYBE_WRITE_DEBUG_OBJECT_DELIM(); } @@ -63,7 +74,7 @@ link_internal b32 DeserializeCurrentVersion(u8_cursor *Bytes, rect3 *Element, memory_arena *Memory) { b32 Result = True; - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Min, Memory); @@ -71,12 +82,20 @@ DeserializeCurrentVersion(u8_cursor *Bytes, rect3 *Element, memory_arena *Memory - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Max, Memory); + + + + + + + + MAYBE_READ_DEBUG_OBJECT_DELIM(); return Result; } @@ -89,7 +108,7 @@ Deserialize(u8_cursor *Bytes, rect3 *Element, memory_arena *Memory, umm Count) b32 Result = True; RangeIterator_t(umm, ElementIndex, Count) { - Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); + Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); } diff --git a/generated/serdes_struct_rect3cp.h b/generated/serdes_struct_rect3cp.h new file mode 100644 index 000000000..790f81982 --- /dev/null +++ b/generated/serdes_struct_rect3cp.h @@ -0,0 +1,118 @@ +// src/engine/serdes.h:495:0 +link_internal bonsai_type_info +TypeInfo(rect3cp *Ignored) +{ + bonsai_type_info Result = {}; + + Result.Name = CSz("rect3cp"); + 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, rect3cp *BaseElement, umm Count = 1) +{ + Assert(Count > 0); + + u64 PointerTrue = True; + u64 PointerFalse = False; + + b32 Result = True; + + + + RangeIterator_t(umm, ElementIndex, Count) + { + rect3cp *Element = BaseElement + ElementIndex; + Result &= Serialize(Bytes, &Element->Min); // default + + + + + + + Result &= Serialize(Bytes, &Element->Max); // default + + + + + + + + + + + + + + + MAYBE_WRITE_DEBUG_OBJECT_DELIM(); + } + + return Result; +} + +link_internal b32 +Deserialize(u8_cursor *Bytes, rect3cp *Element, memory_arena *Memory, umm Count = 1); + +link_internal b32 +DeserializeCurrentVersion(u8_cursor *Bytes, rect3cp *Element, memory_arena *Memory); + + + + +link_internal b32 +DeserializeCurrentVersion(u8_cursor *Bytes, rect3cp *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->Min, Memory); + + + + + + // NOTE(Jesse): Unfortunately we can't check for primitives because + // strings are considered primitive, but need memory to deserialize + Result &= Deserialize(Bytes, &Element->Max, Memory); + + + + + + + + + + + + MAYBE_READ_DEBUG_OBJECT_DELIM(); + return Result; +} + +link_internal b32 +Deserialize(u8_cursor *Bytes, rect3cp *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_rect3i.h b/generated/serdes_struct_rect3i.h index ac7841fbf..31737e22d 100644 --- a/generated/serdes_struct_rect3i.h +++ b/generated/serdes_struct_rect3i.h @@ -1,12 +1,11 @@ -// src/engine/serdes.cpp:271:0 - +// src/engine/serdes.h:495:0 link_internal bonsai_type_info TypeInfo(rect3i *Ignored) { bonsai_type_info Result = {}; Result.Name = CSz("rect3i"); - Result.Version = 0 ; + Result.Version = 0 ; /* type.map(member) */ /* { */ @@ -24,7 +23,7 @@ Serialize(u8_cursor_block_array *Bytes, rect3i *BaseElement, umm Count = 1) { Assert(Count > 0); - u64 PointerTrue = True; + u64 PointerTrue = True; u64 PointerFalse = False; b32 Result = True; @@ -34,15 +33,27 @@ Serialize(u8_cursor_block_array *Bytes, rect3i *BaseElement, umm Count = 1) RangeIterator_t(umm, ElementIndex, Count) { rect3i *Element = BaseElement + ElementIndex; - Result &= Serialize(Bytes, &Element->Min); + Result &= Serialize(Bytes, &Element->Min); // default - Result &= Serialize(Bytes, &Element->Max); - + Result &= Serialize(Bytes, &Element->Max); // default + + + + + + + + + + + + + MAYBE_WRITE_DEBUG_OBJECT_DELIM(); } @@ -63,7 +74,7 @@ link_internal b32 DeserializeCurrentVersion(u8_cursor *Bytes, rect3i *Element, memory_arena *Memory) { b32 Result = True; - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Min, Memory); @@ -71,12 +82,20 @@ DeserializeCurrentVersion(u8_cursor *Bytes, rect3i *Element, memory_arena *Memor - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Max, Memory); + + + + + + + + MAYBE_READ_DEBUG_OBJECT_DELIM(); return Result; } @@ -89,7 +108,7 @@ Deserialize(u8_cursor *Bytes, rect3i *Element, memory_arena *Memory, umm Count) b32 Result = True; RangeIterator_t(umm, ElementIndex, Count) { - Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); + Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); } diff --git a/generated/serdes_struct_render_settings.h b/generated/serdes_struct_render_settings.h index 25107fe95..e7ad7a14b 100644 --- a/generated/serdes_struct_render_settings.h +++ b/generated/serdes_struct_render_settings.h @@ -1,12 +1,11 @@ -// src/engine/serdes.cpp:425:0 - +// src/engine/serdes.h:495:0 link_internal bonsai_type_info TypeInfo(render_settings *Ignored) { bonsai_type_info Result = {}; Result.Name = CSz("render_settings"); - Result.Version =1 ; + Result.Version = 0 ; /* type.map(member) */ /* { */ @@ -24,166 +23,227 @@ Serialize(u8_cursor_block_array *Bytes, render_settings *BaseElement, umm Count { Assert(Count > 0); - u64 PointerTrue = True; + u64 PointerTrue = True; u64 PointerFalse = False; b32 Result = True; - Upsert(TypeInfo(BaseElement), &Global_SerializeTypeTable, Global_SerializeTypeTableArena ); - u64 VersionNumber =1; - Serialize(Bytes, &VersionNumber); - + RangeIterator_t(umm, ElementIndex, Count) { render_settings *Element = BaseElement + ElementIndex; - Result &= Serialize(Bytes, &Element->UseSsao); + Result &= Serialize(Bytes, &Element->UseSsao); // default - Result &= Serialize(Bytes, &Element->UseShadowMapping); + Result &= Serialize(Bytes, &Element->UseShadowMapping); // default - Result &= Serialize(Bytes, &Element->UseLightingBloom); + Result &= Serialize(Bytes, &Element->UseLightingBloom); // default - Result &= Serialize(Bytes, &Element->BravoilMyersOIT); + Result &= Serialize(Bytes, &Element->BravoilMyersOIT); // default - Result &= Serialize(Bytes, &Element->BravoilMcGuireOIT); + Result &= Serialize(Bytes, &Element->BravoilMcGuireOIT); // default - Result &= Serialize(Bytes, &Element->DrawMajorGrid); - Result &= Serialize(Bytes, &Element->DrawMinorGrid); + Result &= Serialize(Bytes, &Element->DrawMajorGrid); // default - Result &= Serialize(Bytes, &Element->MajorGridDim); + Result &= Serialize(Bytes, &Element->DrawMinorGrid); // default - Result &= Serialize(Bytes, &Element->OffsetOfWorldCenterToGrid); + Result &= Serialize(Bytes, &Element->MajorGridDim); // default - Result &= Serialize(Bytes, &Element->Headless); + Result &= Serialize(Bytes, &Element->DrawCameraGhost); // default - Result &= Serialize(Bytes, (u32*)&Element->ToneMappingType); - Result &= Serialize(Bytes, &Element->Lighting); + Result &= Serialize(Bytes, &Element->CameraGhostSize); // default - Result &= Serialize(Bytes, &Element->ApplicationResolution); + Result &= Serialize(Bytes, &Element->Ignored); // default - Result &= Serialize(Bytes, &Element->ShadowMapResolution); + Result &= Serialize(Bytes, &Element->Headless); // default - Result &= Serialize(Bytes, &Element->LuminanceMapResolution); + Result &= Serialize(Bytes, (u32*)&Element->ToneMappingType); // enum - Result &= Serialize(Bytes, &Element->iApplicationResolution); + Result &= Serialize(Bytes, &Element->GameCameraFOV); // default - Result &= Serialize(Bytes, &Element->iShadowMapResolution); + Result &= Serialize(Bytes, &Element->Lighting); // default - Result &= Serialize(Bytes, &Element->iLuminanceMapResolution); - - MAYBE_WRITE_DEBUG_OBJECT_DELIM(); - } - return Result; -} -link_internal b32 -Deserialize(u8_cursor *Bytes, render_settings *Element, memory_arena *Memory, umm Count = 1); + Result &= Serialize(Bytes, &Element->ApplicationResolution); // default -link_internal b32 -DeserializeCurrentVersion(u8_cursor *Bytes, render_settings *Element, memory_arena *Memory); -link_internal b32 -DeserializeVersioned(u8_cursor *Bytes, render_settings *Element, bonsai_type_info *TypeInfo, memory_arena *Memory) -{ - Assert(TypeInfo->Version <=1); - b32 Result = True; - if (TypeInfo->Version == 0) - { - render_settings_0 T0 = {}; - Result &= Deserialize(Bytes, &T0, Memory); - Marshal(&T0, Element); - } + Result &= Serialize(Bytes, &Element->ShadowMapResolution); // default - if (TypeInfo->Version ==1) - { - Result &= DeserializeCurrentVersion(Bytes, Element, Memory); + + + + + + Result &= Serialize(Bytes, &Element->LuminanceMapResolution); // default + + + + + + + Result &= Serialize(Bytes, &Element->iApplicationResolution); // default + + + + + + + Result &= Serialize(Bytes, &Element->iShadowMapResolution); // default + + + + + + + Result &= Serialize(Bytes, &Element->iLuminanceMapResolution); // default + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + MAYBE_WRITE_DEBUG_OBJECT_DELIM(); } return Result; } +link_internal b32 +Deserialize(u8_cursor *Bytes, render_settings *Element, memory_arena *Memory, umm Count = 1); + +link_internal b32 +DeserializeCurrentVersion(u8_cursor *Bytes, render_settings *Element, memory_arena *Memory); + + + link_internal b32 DeserializeCurrentVersion(u8_cursor *Bytes, render_settings *Element, memory_arena *Memory) { b32 Result = True; - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->UseSsao, Memory); @@ -191,7 +251,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, render_settings *Element, memory_are - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->UseShadowMapping, Memory); @@ -199,7 +259,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, render_settings *Element, memory_are - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->UseLightingBloom, Memory); @@ -207,7 +267,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, render_settings *Element, memory_are - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->BravoilMyersOIT, Memory); @@ -215,7 +275,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, render_settings *Element, memory_are - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->BravoilMcGuireOIT, Memory); @@ -223,7 +283,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, render_settings *Element, memory_are - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->DrawMajorGrid, Memory); @@ -231,7 +291,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, render_settings *Element, memory_are - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->DrawMinorGrid, Memory); @@ -239,7 +299,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, render_settings *Element, memory_are - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->MajorGridDim, Memory); @@ -247,15 +307,31 @@ DeserializeCurrentVersion(u8_cursor *Bytes, render_settings *Element, memory_are - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because + // strings are considered primitive, but need memory to deserialize + Result &= Deserialize(Bytes, &Element->DrawCameraGhost, Memory); + + + + + + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->OffsetOfWorldCenterToGrid, Memory); + Result &= Deserialize(Bytes, &Element->CameraGhostSize, Memory); - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because + // strings are considered primitive, but need memory to deserialize + Result &= Deserialize(Bytes, &Element->Ignored, Memory); + + + + + + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Headless, Memory); @@ -263,12 +339,20 @@ DeserializeCurrentVersion(u8_cursor *Bytes, render_settings *Element, memory_are - Element->ToneMappingType = Cast(tone_mapping_type, Read_u32(Bytes)); + Element->ToneMappingType = Cast(tone_mapping_type, Read_u32(Bytes)); - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because + // strings are considered primitive, but need memory to deserialize + Result &= Deserialize(Bytes, &Element->GameCameraFOV, Memory); + + + + + + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Lighting, Memory); @@ -276,7 +360,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, render_settings *Element, memory_are - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->ApplicationResolution, Memory); @@ -284,7 +368,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, render_settings *Element, memory_are - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->ShadowMapResolution, Memory); @@ -292,7 +376,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, render_settings *Element, memory_are - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->LuminanceMapResolution, Memory); @@ -300,7 +384,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, render_settings *Element, memory_are - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->iApplicationResolution, Memory); @@ -308,7 +392,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, render_settings *Element, memory_are - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->iShadowMapResolution, Memory); @@ -316,11 +400,38 @@ DeserializeCurrentVersion(u8_cursor *Bytes, render_settings *Element, memory_are - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->iLuminanceMapResolution, Memory); + + + + + + + + + + + + + + + + + + + + + + + + + + + MAYBE_READ_DEBUG_OBJECT_DELIM(); return Result; @@ -334,22 +445,7 @@ Deserialize(u8_cursor *Bytes, render_settings *Element, memory_arena *Memory, um b32 Result = True; RangeIterator_t(umm, ElementIndex, Count) { - maybe_bonsai_type_info MaybeSerializedType = GetByName(&Global_SerializeTypeTable, CSz("render_settings")); - - if (MaybeSerializedType.Tag) - { - u64 OldIgnoredVersionNumber; - if (MaybeSerializedType.Value.Version > 0) - { - Deserialize(Bytes, &OldIgnoredVersionNumber, Memory); - } - Result &= DeserializeVersioned(Bytes, Element+ElementIndex, &MaybeSerializedType.Value, Memory); - } - else - { - bonsai_type_info T0TypeInfo = {}; - Result &= DeserializeVersioned(Bytes, Element+ElementIndex, &T0TypeInfo, Memory); - } + Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); } diff --git a/generated/serdes_struct_shape_layer.h b/generated/serdes_struct_shape_layer.h index 40aa47c62..e3126148b 100644 --- a/generated/serdes_struct_shape_layer.h +++ b/generated/serdes_struct_shape_layer.h @@ -1,12 +1,11 @@ -// src/engine/serdes.cpp:536:0 - +// src/engine/serdes.h:495:0 link_internal bonsai_type_info TypeInfo(shape_layer *Ignored) { bonsai_type_info Result = {}; Result.Name = CSz("shape_layer"); - Result.Version = 0 ; + Result.Version = 0 ; /* type.map(member) */ /* { */ @@ -24,7 +23,7 @@ Serialize(u8_cursor_block_array *Bytes, shape_layer *BaseElement, umm Count = 1) { Assert(Count > 0); - u64 PointerTrue = True; + u64 PointerTrue = True; u64 PointerFalse = False; b32 Result = True; @@ -34,20 +33,79 @@ Serialize(u8_cursor_block_array *Bytes, shape_layer *BaseElement, umm Count = 1) RangeIterator_t(umm, ElementIndex, Count) { shape_layer *Element = BaseElement + ElementIndex; - Result &= Serialize(Bytes, (u32*)&Element->Type); + Result &= Serialize(Bytes, (u32*)&Element->Type); // enum - Result &= Serialize(Bytes, &Element->Sphere); + Result &= Serialize(Bytes, &Element->Rect); // default - Result &= Serialize(Bytes, &Element->Rect); - + Result &= Serialize(Bytes, &Element->Sphere); // default + + + + + + + Result &= Serialize(Bytes, &Element->Line); // default + + + + + + + Result &= Serialize(Bytes, &Element->Cylinder); // default + + + + + + + Result &= Serialize(Bytes, &Element->Plane); // default + + + + + + + Result &= Serialize(Bytes, &Element->Torus); // default + + + + + + + Result &= Serialize(Bytes, &Element->Advanced); // default + + + + + + + + + + + + + + + + + + + + + + + + + MAYBE_WRITE_DEBUG_OBJECT_DELIM(); } @@ -68,12 +126,20 @@ link_internal b32 DeserializeCurrentVersion(u8_cursor *Bytes, shape_layer *Element, memory_arena *Memory) { b32 Result = True; - Element->Type = Cast(shape_type, Read_u32(Bytes)); + Element->Type = Cast(shape_type, Read_u32(Bytes)); + + + + + // NOTE(Jesse): Unfortunately we can't check for primitives because + // strings are considered primitive, but need memory to deserialize + Result &= Deserialize(Bytes, &Element->Rect, Memory); + - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Sphere, Memory); @@ -81,11 +147,57 @@ DeserializeCurrentVersion(u8_cursor *Bytes, shape_layer *Element, memory_arena * - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->Rect, Memory); + Result &= Deserialize(Bytes, &Element->Line, Memory); + + + + + + // NOTE(Jesse): Unfortunately we can't check for primitives because + // strings are considered primitive, but need memory to deserialize + Result &= Deserialize(Bytes, &Element->Cylinder, Memory); + + + + + + // NOTE(Jesse): Unfortunately we can't check for primitives because + // strings are considered primitive, but need memory to deserialize + Result &= Deserialize(Bytes, &Element->Plane, Memory); + + + + + // NOTE(Jesse): Unfortunately we can't check for primitives because + // strings are considered primitive, but need memory to deserialize + Result &= Deserialize(Bytes, &Element->Torus, Memory); + + + + + + // NOTE(Jesse): Unfortunately we can't check for primitives because + // strings are considered primitive, but need memory to deserialize + Result &= Deserialize(Bytes, &Element->Advanced, Memory); + + + + + + + + + + + + + + + MAYBE_READ_DEBUG_OBJECT_DELIM(); return Result; @@ -99,7 +211,7 @@ Deserialize(u8_cursor *Bytes, shape_layer *Element, memory_arena *Memory, umm Co b32 Result = True; RangeIterator_t(umm, ElementIndex, Count) { - Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); + Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); } diff --git a/generated/serdes_struct_shape_layer_advanced_params.h b/generated/serdes_struct_shape_layer_advanced_params.h new file mode 100644 index 000000000..35eeaa7c1 --- /dev/null +++ b/generated/serdes_struct_shape_layer_advanced_params.h @@ -0,0 +1,154 @@ +// src/engine/serdes.h:495:0 +link_internal bonsai_type_info +TypeInfo(shape_layer_advanced_params *Ignored) +{ + bonsai_type_info Result = {}; + + Result.Name = CSz("shape_layer_advanced_params"); + 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, shape_layer_advanced_params *BaseElement, umm Count = 1) +{ + Assert(Count > 0); + + u64 PointerTrue = True; + u64 PointerFalse = False; + + b32 Result = True; + + + + RangeIterator_t(umm, ElementIndex, Count) + { + shape_layer_advanced_params *Element = BaseElement + ElementIndex; + Result &= Serialize(Bytes, &Element->Rounding); // default + + + + + + + Result &= Serialize(Bytes, &Element->Stretch); // default + + + + + + + Result &= Serialize(Bytes, &Element->Repeat); // default + + + + + + + Result &= Serialize(Bytes, &Element->Axis); // default + + + + + + + + + + + + + + + + + + + MAYBE_WRITE_DEBUG_OBJECT_DELIM(); + } + + return Result; +} + +link_internal b32 +Deserialize(u8_cursor *Bytes, shape_layer_advanced_params *Element, memory_arena *Memory, umm Count = 1); + +link_internal b32 +DeserializeCurrentVersion(u8_cursor *Bytes, shape_layer_advanced_params *Element, memory_arena *Memory); + + + + +link_internal b32 +DeserializeCurrentVersion(u8_cursor *Bytes, shape_layer_advanced_params *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->Rounding, Memory); + + + + + + // NOTE(Jesse): Unfortunately we can't check for primitives because + // strings are considered primitive, but need memory to deserialize + Result &= Deserialize(Bytes, &Element->Stretch, Memory); + + + + + + // NOTE(Jesse): Unfortunately we can't check for primitives because + // strings are considered primitive, but need memory to deserialize + Result &= Deserialize(Bytes, &Element->Repeat, Memory); + + + + + + // NOTE(Jesse): Unfortunately we can't check for primitives because + // strings are considered primitive, but need memory to deserialize + Result &= Deserialize(Bytes, &Element->Axis, Memory); + + + + + + + + + + + + + + MAYBE_READ_DEBUG_OBJECT_DELIM(); + return Result; +} + +link_internal b32 +Deserialize(u8_cursor *Bytes, shape_layer_advanced_params *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_v1bB0O62.h b/generated/serdes_struct_v1bB0O62.h new file mode 100644 index 000000000..c0ace4be4 --- /dev/null +++ b/generated/serdes_struct_v1bB0O62.h @@ -0,0 +1,105 @@ +// src/engine/serdes.h:495:0 +link_internal bonsai_type_info +TypeInfo(m4 *Ignored) +{ + bonsai_type_info Result = {}; + + Result.Name = CSz("m4"); + 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, m4 *BaseElement, umm Count = 1) +{ + Assert(Count > 0); + + u64 PointerTrue = True; + u64 PointerFalse = False; + + b32 Result = True; + + + + RangeIterator_t(umm, ElementIndex, Count) + { + m4 *Element = BaseElement + ElementIndex; + { + umm ThisCount = 4; + + Result &= Serialize(Bytes, Element->E, ThisCount); + } + + + + + + + + + + + + MAYBE_WRITE_DEBUG_OBJECT_DELIM(); + } + + return Result; +} + +link_internal b32 +Deserialize(u8_cursor *Bytes, m4 *Element, memory_arena *Memory, umm Count = 1); + +link_internal b32 +DeserializeCurrentVersion(u8_cursor *Bytes, m4 *Element, memory_arena *Memory); + + + + +link_internal b32 +DeserializeCurrentVersion(u8_cursor *Bytes, m4 *Element, memory_arena *Memory) +{ + b32 Result = True; + { + umm Count = 4; + + Result &= Deserialize(Bytes, Element->E, Memory, Count); + } + + + + + + + + + + + MAYBE_READ_DEBUG_OBJECT_DELIM(); + return Result; +} + +link_internal b32 +Deserialize(u8_cursor *Bytes, m4 *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_vertex_material.h b/generated/serdes_struct_vertex_material.h index 17c97050e..ad9590c9b 100644 --- a/generated/serdes_struct_vertex_material.h +++ b/generated/serdes_struct_vertex_material.h @@ -1,12 +1,11 @@ -// src/engine/serdes.cpp:136:0 - +// src/engine/serdes.h:495:0 link_internal bonsai_type_info TypeInfo(vertex_material *Ignored) { bonsai_type_info Result = {}; Result.Name = CSz("vertex_material"); - Result.Version = 0 ; + Result.Version = 0 ; /* type.map(member) */ /* { */ @@ -24,7 +23,7 @@ Serialize(u8_cursor_block_array *Bytes, vertex_material *BaseElement, umm Count { Assert(Count > 0); - u64 PointerTrue = True; + u64 PointerTrue = True; u64 PointerFalse = False; b32 Result = True; @@ -34,21 +33,36 @@ Serialize(u8_cursor_block_array *Bytes, vertex_material *BaseElement, umm Count RangeIterator_t(umm, ElementIndex, Count) { vertex_material *Element = BaseElement + ElementIndex; - Result &= Serialize(Bytes, &Element->ColorIndex); + Result &= Serialize(Bytes, &Element->ColorIndex); // default - Result &= Serialize(Bytes, &Element->Transparency); + Result &= Serialize(Bytes, &Element->Transparency); // default - Result &= Serialize(Bytes, &Element->Emission); - + + Result &= Serialize(Bytes, &Element->Emission); // default + + + + + + + + + + + + + + + MAYBE_WRITE_DEBUG_OBJECT_DELIM(); } @@ -69,7 +83,7 @@ link_internal b32 DeserializeCurrentVersion(u8_cursor *Bytes, vertex_material *Element, memory_arena *Memory) { b32 Result = True; - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->ColorIndex, Memory); @@ -77,7 +91,7 @@ DeserializeCurrentVersion(u8_cursor *Bytes, vertex_material *Element, memory_are - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Transparency, Memory); @@ -85,12 +99,21 @@ DeserializeCurrentVersion(u8_cursor *Bytes, vertex_material *Element, memory_are - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Emission, Memory); + + + + + + + + + MAYBE_READ_DEBUG_OBJECT_DELIM(); return Result; } @@ -103,7 +126,7 @@ Deserialize(u8_cursor *Bytes, vertex_material *Element, memory_arena *Memory, um b32 Result = True; RangeIterator_t(umm, ElementIndex, Count) { - Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); + Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); } diff --git a/generated/serdes_struct_voronoi_noise_params.h b/generated/serdes_struct_voronoi_noise_params.h index 113e0de35..2950726d8 100644 --- a/generated/serdes_struct_voronoi_noise_params.h +++ b/generated/serdes_struct_voronoi_noise_params.h @@ -1,12 +1,11 @@ -// src/engine/serdes.cpp:526:0 - +// src/engine/serdes.h:495:0 link_internal bonsai_type_info TypeInfo(voronoi_noise_params *Ignored) { bonsai_type_info Result = {}; Result.Name = CSz("voronoi_noise_params"); - Result.Version = 0 ; + Result.Version = 0 ; /* type.map(member) */ /* { */ @@ -24,7 +23,7 @@ Serialize(u8_cursor_block_array *Bytes, voronoi_noise_params *BaseElement, umm C { Assert(Count > 0); - u64 PointerTrue = True; + u64 PointerTrue = True; u64 PointerFalse = False; b32 Result = True; @@ -34,33 +33,36 @@ Serialize(u8_cursor_block_array *Bytes, voronoi_noise_params *BaseElement, umm C RangeIterator_t(umm, ElementIndex, Count) { voronoi_noise_params *Element = BaseElement + ElementIndex; - Result &= Serialize(Bytes, &Element->Threshold); + Result &= Serialize(Bytes, &Element->Period); // default - Result &= Serialize(Bytes, &Element->Period); + Result &= Serialize(Bytes, &Element->Squareness); // default - Result &= Serialize(Bytes, &Element->Amplitude); + Result &= Serialize(Bytes, &Element->MaskChance); // default - Result &= Serialize(Bytes, &Element->Squareness); - Result &= Serialize(Bytes, &Element->MaskChance); + + + + + + - MAYBE_WRITE_DEBUG_OBJECT_DELIM(); } @@ -81,15 +83,7 @@ link_internal b32 DeserializeCurrentVersion(u8_cursor *Bytes, voronoi_noise_params *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->Threshold, Memory); - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Period, Memory); @@ -97,27 +91,28 @@ DeserializeCurrentVersion(u8_cursor *Bytes, voronoi_noise_params *Element, memor - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->Amplitude, Memory); + Result &= Deserialize(Bytes, &Element->Squareness, Memory); - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->Squareness, Memory); + Result &= Deserialize(Bytes, &Element->MaskChance, Memory); + - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->MaskChance, Memory); + + + MAYBE_READ_DEBUG_OBJECT_DELIM(); return Result; @@ -131,7 +126,7 @@ Deserialize(u8_cursor *Bytes, voronoi_noise_params *Element, memory_arena *Memor b32 Result = True; RangeIterator_t(umm, ElementIndex, Count) { - Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); + Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); } diff --git a/generated/serdes_struct_vox_data.h b/generated/serdes_struct_vox_data.h index 8b68075e5..de9d8dde3 100644 --- a/generated/serdes_struct_vox_data.h +++ b/generated/serdes_struct_vox_data.h @@ -1,12 +1,11 @@ -// src/engine/serdes.cpp:290:0 - +// src/engine/serdes.h:495:0 link_internal bonsai_type_info TypeInfo(vox_data *Ignored) { bonsai_type_info Result = {}; Result.Name = CSz("vox_data"); - Result.Version = 0 ; + Result.Version = 0 ; /* type.map(member) */ /* { */ @@ -24,7 +23,7 @@ Serialize(u8_cursor_block_array *Bytes, vox_data *BaseElement, umm Count = 1) { Assert(Count > 0); - u64 PointerTrue = True; + u64 PointerTrue = True; u64 PointerFalse = False; b32 Result = True; @@ -34,10 +33,18 @@ Serialize(u8_cursor_block_array *Bytes, vox_data *BaseElement, umm Count = 1) RangeIterator_t(umm, ElementIndex, Count) { vox_data *Element = BaseElement + ElementIndex; - if (Element->ChunkData) { Result &= Write(Bytes, Cast(u8*, &PointerTrue), sizeof(PointerTrue)); } + if (Element->ChunkData) { Result &= Write(Bytes, Cast(u8*, &PointerTrue), sizeof(PointerTrue)); } else { Result &= Write(Bytes, Cast(u8*, &PointerFalse), sizeof(PointerFalse)); } - if (Element->ChunkData) { Result &= Serialize(Bytes, Element->ChunkData); } + + + + + if (Element->ChunkData) { Result &= Serialize(Bytes, Element->ChunkData); } + + + + MAYBE_WRITE_DEBUG_OBJECT_DELIM(); } @@ -58,12 +65,16 @@ link_internal b32 DeserializeCurrentVersion(u8_cursor *Bytes, vox_data *Element, memory_arena *Memory) { b32 Result = True; - b64 HadChunkDataPointer = Read_u64(Bytes); + b64 HadChunkDataPointer = Read_u64(Bytes); Assert(HadChunkDataPointer < 2); // Should be 0 or 1 - if (HadChunkDataPointer) + + + + + if (HadChunkDataPointer) { - umm Count = 1; + umm Count = 1; if (Element->ChunkData == 0) @@ -74,6 +85,9 @@ DeserializeCurrentVersion(u8_cursor *Bytes, vox_data *Element, memory_arena *Mem Result &= Deserialize(Bytes, Element->ChunkData, Memory, Count); } + + + MAYBE_READ_DEBUG_OBJECT_DELIM(); return Result; } @@ -86,7 +100,7 @@ Deserialize(u8_cursor *Bytes, vox_data *Element, memory_arena *Memory, umm Count b32 Result = True; RangeIterator_t(umm, ElementIndex, Count) { - Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); + Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); } diff --git a/generated/serdes_struct_voxel.h b/generated/serdes_struct_voxel.h index dd3001f1b..c7d40b4cd 100644 --- a/generated/serdes_struct_voxel.h +++ b/generated/serdes_struct_voxel.h @@ -1,12 +1,11 @@ -// src/engine/serdes.cpp:38:0 - +// src/engine/serdes.h:495:0 link_internal bonsai_type_info TypeInfo(voxel *Ignored) { bonsai_type_info Result = {}; Result.Name = CSz("voxel"); - Result.Version = 0 ; + Result.Version = 0 ; /* type.map(member) */ /* { */ @@ -24,7 +23,7 @@ Serialize(u8_cursor_block_array *Bytes, voxel *BaseElement, umm Count = 1) { Assert(Count > 0); - u64 PointerTrue = True; + u64 PointerTrue = True; u64 PointerFalse = False; b32 Result = True; @@ -34,22 +33,12 @@ Serialize(u8_cursor_block_array *Bytes, voxel *BaseElement, umm Count = 1) RangeIterator_t(umm, ElementIndex, Count) { voxel *Element = BaseElement + ElementIndex; - Result &= Serialize(Bytes, &Element->Flags); - - - - + - Result &= Serialize(Bytes, &Element->Transparency); + - - - Result &= Serialize(Bytes, &Element->Color); - - - MAYBE_WRITE_DEBUG_OBJECT_DELIM(); } @@ -69,28 +58,12 @@ link_internal b32 DeserializeCurrentVersion(u8_cursor *Bytes, voxel *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->Flags, Memory); + + - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->Transparency, Memory); - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->Color, Memory); - - - MAYBE_READ_DEBUG_OBJECT_DELIM(); return Result; } @@ -103,7 +76,7 @@ Deserialize(u8_cursor *Bytes, voxel *Element, memory_arena *Memory, umm Count) b32 Result = True; RangeIterator_t(umm, ElementIndex, Count) { - Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); + Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); } diff --git a/generated/serdes_struct_voxel_lighting.h b/generated/serdes_struct_voxel_lighting.h index 6a96cf2b2..7b972fd24 100644 --- a/generated/serdes_struct_voxel_lighting.h +++ b/generated/serdes_struct_voxel_lighting.h @@ -1,12 +1,11 @@ -// src/engine/serdes.cpp:44:0 - +// src/engine/serdes.h:495:0 link_internal bonsai_type_info TypeInfo(voxel_lighting *Ignored) { bonsai_type_info Result = {}; Result.Name = CSz("voxel_lighting"); - Result.Version = 0 ; + Result.Version = 0 ; /* type.map(member) */ /* { */ @@ -24,7 +23,7 @@ Serialize(u8_cursor_block_array *Bytes, voxel_lighting *BaseElement, umm Count = { Assert(Count > 0); - u64 PointerTrue = True; + u64 PointerTrue = True; u64 PointerFalse = False; b32 Result = True; @@ -34,9 +33,18 @@ Serialize(u8_cursor_block_array *Bytes, voxel_lighting *BaseElement, umm Count = RangeIterator_t(umm, ElementIndex, Count) { voxel_lighting *Element = BaseElement + ElementIndex; - Result &= Serialize(Bytes, &Element->Emission); + Result &= Serialize(Bytes, &Element->Emission); // default + + + + + + + + + + - MAYBE_WRITE_DEBUG_OBJECT_DELIM(); } @@ -57,11 +65,18 @@ link_internal b32 DeserializeCurrentVersion(u8_cursor *Bytes, voxel_lighting *Element, memory_arena *Memory) { b32 Result = True; - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Emission, Memory); - + + + + + + + + MAYBE_READ_DEBUG_OBJECT_DELIM(); return Result; @@ -75,7 +90,7 @@ Deserialize(u8_cursor *Bytes, voxel_lighting *Element, memory_arena *Memory, umm b32 Result = True; RangeIterator_t(umm, ElementIndex, Count) { - Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); + Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); } diff --git a/generated/serdes_struct_white_noise_params.h b/generated/serdes_struct_white_noise_params.h index 546665ad3..f0b69c18d 100644 --- a/generated/serdes_struct_white_noise_params.h +++ b/generated/serdes_struct_white_noise_params.h @@ -1,12 +1,11 @@ -// src/engine/serdes.cpp:522:0 - +// src/engine/serdes.h:495:0 link_internal bonsai_type_info TypeInfo(white_noise_params *Ignored) { bonsai_type_info Result = {}; Result.Name = CSz("white_noise_params"); - Result.Version = 0 ; + Result.Version = 0 ; /* type.map(member) */ /* { */ @@ -24,7 +23,7 @@ Serialize(u8_cursor_block_array *Bytes, white_noise_params *BaseElement, umm Cou { Assert(Count > 0); - u64 PointerTrue = True; + u64 PointerTrue = True; u64 PointerFalse = False; b32 Result = True; @@ -34,7 +33,7 @@ Serialize(u8_cursor_block_array *Bytes, white_noise_params *BaseElement, umm Cou RangeIterator_t(umm, ElementIndex, Count) { white_noise_params *Element = BaseElement + ElementIndex; - Result &= Serialize(Bytes, &Element->Threshold); + @@ -57,9 +56,7 @@ link_internal b32 DeserializeCurrentVersion(u8_cursor *Bytes, white_noise_params *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->Threshold, Memory); + @@ -75,7 +72,7 @@ Deserialize(u8_cursor *Bytes, white_noise_params *Element, memory_arena *Memory, b32 Result = True; RangeIterator_t(umm, ElementIndex, Count) { - Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); + Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); } diff --git a/generated/serdes_struct_world_chunk.h b/generated/serdes_struct_world_chunk.h index 50a07eea7..31c121f1a 100644 --- a/generated/serdes_struct_world_chunk.h +++ b/generated/serdes_struct_world_chunk.h @@ -1,12 +1,11 @@ -// src/engine/serdes.cpp:60:0 - +// src/engine/serdes.h:495:0 link_internal bonsai_type_info TypeInfo(world_chunk *Ignored) { bonsai_type_info Result = {}; Result.Name = CSz("world_chunk"); - Result.Version =1 ; + Result.Version = 1 ; /* type.map(member) */ /* { */ @@ -24,51 +23,94 @@ Serialize(u8_cursor_block_array *Bytes, world_chunk *BaseElement, umm Count = 1) { Assert(Count > 0); - u64 PointerTrue = True; + u64 PointerTrue = True; u64 PointerFalse = False; b32 Result = True; - Upsert(TypeInfo(BaseElement), &Global_SerializeTypeTable, Global_SerializeTypeTableArena ); - u64 VersionNumber =1; + Upsert(TypeInfo(BaseElement), &Global_SerializeTypeTable, Global_SerializeTypeTableArena ); + u64 VersionNumber = 1; Serialize(Bytes, &VersionNumber); RangeIterator_t(umm, ElementIndex, Count) { world_chunk *Element = BaseElement + ElementIndex; - Result &= Serialize(Bytes, &Element->Dim); + + Result &= Serialize(Bytes, &Element->Dim); // default + - if (Element->Voxels) { Result &= Write(Bytes, Cast(u8*, &PointerTrue), sizeof(PointerTrue)); } + if (Element->Occupancy) { 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)); } + if (Element->xOccupancyBorder) { Result &= Write(Bytes, Cast(u8*, &PointerTrue), sizeof(PointerTrue)); } else { Result &= Write(Bytes, Cast(u8*, &PointerFalse), sizeof(PointerFalse)); } - Result &= Serialize(Bytes, &Element->WorldP); + if (Element->FaceMasks) { Result &= Write(Bytes, Cast(u8*, &PointerTrue), sizeof(PointerTrue)); } + else { Result &= Write(Bytes, Cast(u8*, &PointerFalse), sizeof(PointerFalse)); } + + + + Result &= Serialize(Bytes, &Element->IsOnFreelist); // default + + + + + + + + + Result &= Serialize(Bytes, &Element->DimInChunks); // default + + + + + + + Result &= Serialize(Bytes, &Element->WorldP); // default + + + + + + + + + + + + + if (Element->Occupancy) { Result &= Serialize(Bytes, Element->Occupancy); } + if (Element->xOccupancyBorder) { Result &= Serialize(Bytes, Element->xOccupancyBorder); } - if (Element->Voxels) { Result &= Serialize(Bytes, Element->Voxels, Cast(umm, Volume(Element->Dim)) ); } + if (Element->FaceMasks) { Result &= Serialize(Bytes, Element->FaceMasks); } - if (Element->VoxelLighting) { Result &= Serialize(Bytes, Element->VoxelLighting, Cast(umm, Volume(Element->Dim)) ); } + + + + + + + MAYBE_WRITE_DEBUG_OBJECT_DELIM(); @@ -87,11 +129,11 @@ DeserializeCurrentVersion(u8_cursor *Bytes, world_chunk *Element, memory_arena * link_internal b32 DeserializeVersioned(u8_cursor *Bytes, world_chunk *Element, bonsai_type_info *TypeInfo, memory_arena *Memory) { - Assert(TypeInfo->Version <=1); + Assert(TypeInfo->Version <= 1); b32 Result = True; - if (TypeInfo->Version == 0) + if (TypeInfo->Version == 0) { world_chunk_0 T0 = {}; Result &= Deserialize(Bytes, &T0, Memory); @@ -99,7 +141,7 @@ DeserializeVersioned(u8_cursor *Bytes, world_chunk *Element, bonsai_type_info *T } - if (TypeInfo->Version ==1) + if (TypeInfo->Version == 1) { Result &= DeserializeCurrentVersion(Bytes, Element, Memory); } @@ -112,7 +154,8 @@ 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 + + // 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); @@ -120,17 +163,40 @@ DeserializeCurrentVersion(u8_cursor *Bytes, world_chunk *Element, memory_arena * - b64 HadVoxelsPointer = Read_u64(Bytes); - Assert(HadVoxelsPointer < 2); // Should be 0 or 1 + b64 HadOccupancyPointer = Read_u64(Bytes); + Assert(HadOccupancyPointer < 2); // Should be 0 or 1 - b64 HadVoxelLightingPointer = Read_u64(Bytes); - Assert(HadVoxelLightingPointer < 2); // Should be 0 or 1 + b64 HadxOccupancyBorderPointer = Read_u64(Bytes); + Assert(HadxOccupancyBorderPointer < 2); // Should be 0 or 1 - // NOTE(Jesse): Unfortunately we can't check for primitives because + b64 HadFaceMasksPointer = Read_u64(Bytes); + Assert(HadFaceMasksPointer < 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->IsOnFreelist, Memory); + + + + + + + + // NOTE(Jesse): Unfortunately we can't check for primitives because + // strings are considered primitive, but need memory to deserialize + Result &= Deserialize(Bytes, &Element->DimInChunks, Memory); + + + + + + // 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); @@ -138,36 +204,62 @@ DeserializeCurrentVersion(u8_cursor *Bytes, world_chunk *Element, memory_arena * + + + + + + + + if (HadOccupancyPointer) + { + umm Count = 1; + + + if (Element->Occupancy == 0) + { + Element->Occupancy = Allocate(u64, Memory, Count); + } + + Result &= Deserialize(Bytes, Element->Occupancy, Memory, Count); + } - if (HadVoxelsPointer) + if (HadxOccupancyBorderPointer) { - umm Count = Cast(umm, Volume(Element->Dim)); + umm Count = 1; - if (Element->Voxels == 0) + if (Element->xOccupancyBorder == 0) { - Element->Voxels = Allocate(voxel, Memory, Count); + Element->xOccupancyBorder = Allocate(u64, Memory, Count); } - Result &= Deserialize(Bytes, Element->Voxels, Memory, Count); + Result &= Deserialize(Bytes, Element->xOccupancyBorder, Memory, Count); } - if (HadVoxelLightingPointer) + if (HadFaceMasksPointer) { - umm Count = Cast(umm, Volume(Element->Dim)); + umm Count = 1; - if (Element->VoxelLighting == 0) + if (Element->FaceMasks == 0) { - Element->VoxelLighting = Allocate(voxel_lighting, Memory, Count); + Element->FaceMasks = Allocate(u64, Memory, Count); } - Result &= Deserialize(Bytes, Element->VoxelLighting, Memory, Count); + Result &= Deserialize(Bytes, Element->FaceMasks, Memory, Count); } + + + + + + + MAYBE_READ_DEBUG_OBJECT_DELIM(); @@ -182,7 +274,7 @@ Deserialize(u8_cursor *Bytes, world_chunk *Element, memory_arena *Memory, umm Co b32 Result = True; RangeIterator_t(umm, ElementIndex, Count) { - maybe_bonsai_type_info MaybeSerializedType = GetByName(&Global_SerializeTypeTable, CSz("world_chunk")); + maybe_bonsai_type_info MaybeSerializedType = GetByName(&Global_SerializeTypeTable, CSz("world_chunk")); if (MaybeSerializedType.Tag) { diff --git a/generated/serdes_struct_world_chunk_0.h b/generated/serdes_struct_world_chunk_0.h index db65acef1..82cddb2f5 100644 --- a/generated/serdes_struct_world_chunk_0.h +++ b/generated/serdes_struct_world_chunk_0.h @@ -1,12 +1,11 @@ -// src/engine/serdes.cpp:49:0 - +// src/engine/serdes.h:495:0 link_internal bonsai_type_info TypeInfo(world_chunk_0 *Ignored) { bonsai_type_info Result = {}; Result.Name = CSz("world_chunk_0"); - Result.Version = 0 ; + Result.Version = 0 ; /* type.map(member) */ /* { */ @@ -24,7 +23,7 @@ Serialize(u8_cursor_block_array *Bytes, world_chunk_0 *BaseElement, umm Count = { Assert(Count > 0); - u64 PointerTrue = True; + u64 PointerTrue = True; u64 PointerFalse = False; b32 Result = True; @@ -34,38 +33,68 @@ Serialize(u8_cursor_block_array *Bytes, world_chunk_0 *BaseElement, umm Count = RangeIterator_t(umm, ElementIndex, Count) { world_chunk_0 *Element = BaseElement + ElementIndex; - Result &= Serialize(Bytes, &Element->Dim); + + Result &= Serialize(Bytes, &Element->Dim); // default + - if (Element->Voxels) { Result &= Write(Bytes, Cast(u8*, &PointerTrue), sizeof(PointerTrue)); } + 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)); } + 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); + + + Result &= Serialize(Bytes, &Element->WorldP); // default + + + + + + + + + + + + + + + if (Element->Voxels) { Result &= Serialize(Bytes, Element->Voxels, Cast(umm, Volume(Element->Dim)) ); } - 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)) ); } - if (Element->VoxelLighting) { Result &= Serialize(Bytes, Element->VoxelLighting, Cast(umm, Volume(Element->Dim)) ); } + + + + + + + + + + + + MAYBE_WRITE_DEBUG_OBJECT_DELIM(); @@ -87,7 +116,8 @@ link_internal b32 DeserializeCurrentVersion(u8_cursor *Bytes, world_chunk_0 *Element, memory_arena *Memory) { b32 Result = True; - // NOTE(Jesse): Unfortunately we can't check for primitives because + + // 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); @@ -95,17 +125,19 @@ DeserializeCurrentVersion(u8_cursor *Bytes, world_chunk_0 *Element, memory_arena - b64 HadVoxelsPointer = Read_u64(Bytes); + b64 HadVoxelsPointer = Read_u64(Bytes); Assert(HadVoxelsPointer < 2); // Should be 0 or 1 - b64 HadVoxelLightingPointer = Read_u64(Bytes); + b64 HadVoxelLightingPointer = Read_u64(Bytes); Assert(HadVoxelLightingPointer < 2); // Should be 0 or 1 - // NOTE(Jesse): Unfortunately we can't check for primitives because + + + // 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); @@ -113,11 +145,23 @@ DeserializeCurrentVersion(u8_cursor *Bytes, world_chunk_0 *Element, memory_arena + + + + + + + + + - if (HadVoxelsPointer) + + + + if (HadVoxelsPointer) { - umm Count = Cast(umm, Volume(Element->Dim)); + umm Count = Cast(umm, Volume(Element->Dim)); if (Element->Voxels == 0) @@ -129,9 +173,9 @@ DeserializeCurrentVersion(u8_cursor *Bytes, world_chunk_0 *Element, memory_arena } - if (HadVoxelLightingPointer) + if (HadVoxelLightingPointer) { - umm Count = Cast(umm, Volume(Element->Dim)); + umm Count = Cast(umm, Volume(Element->Dim)); if (Element->VoxelLighting == 0) @@ -143,6 +187,18 @@ DeserializeCurrentVersion(u8_cursor *Bytes, world_chunk_0 *Element, memory_arena } + + + + + + + + + + + + MAYBE_READ_DEBUG_OBJECT_DELIM(); @@ -157,7 +213,7 @@ Deserialize(u8_cursor *Bytes, world_chunk_0 *Element, memory_arena *Memory, umm b32 Result = True; RangeIterator_t(umm, ElementIndex, Count) { - Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); + Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); } diff --git a/generated/serdes_struct_world_edit.h b/generated/serdes_struct_world_edit.h new file mode 100644 index 000000000..6ee2b624b --- /dev/null +++ b/generated/serdes_struct_world_edit.h @@ -0,0 +1,182 @@ +// src/engine/serdes.h:495:0 +link_internal bonsai_type_info +TypeInfo(world_edit *Ignored) +{ + bonsai_type_info Result = {}; + + Result.Name = CSz("world_edit"); + 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_edit *BaseElement, umm Count = 1) +{ + Assert(Count > 0); + + u64 PointerTrue = True; + u64 PointerFalse = False; + + b32 Result = True; + + + + RangeIterator_t(umm, ElementIndex, Count) + { + world_edit *Element = BaseElement + ElementIndex; + Result &= Serialize(Bytes, &Element->Region); // default + + + + + + + if (Element->Brush) { Result &= Write(Bytes, Cast(u8*, &PointerTrue), sizeof(PointerTrue)); } + else { Result &= Write(Bytes, Cast(u8*, &PointerFalse), sizeof(PointerFalse)); } + + + + Result &= Serialize(Bytes, &Element->Tombstone); // default + + + + + + + Result &= Serialize(Bytes, &Element->Selected); // default + + + + + + + Result &= Serialize(Bytes, &Element->Ordinal); // default + + + + + + + + + + + if (Element->Brush) { Result &= Serialize(Bytes, Element->Brush); } + + + + + + + + + + + + MAYBE_WRITE_DEBUG_OBJECT_DELIM(); + } + + return Result; +} + +link_internal b32 +Deserialize(u8_cursor *Bytes, world_edit *Element, memory_arena *Memory, umm Count = 1); + +link_internal b32 +DeserializeCurrentVersion(u8_cursor *Bytes, world_edit *Element, memory_arena *Memory); + + + + +link_internal b32 +DeserializeCurrentVersion(u8_cursor *Bytes, world_edit *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->Region, Memory); + + + + + + b64 HadBrushPointer = Read_u64(Bytes); + Assert(HadBrushPointer < 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->Tombstone, Memory); + + + + + + // NOTE(Jesse): Unfortunately we can't check for primitives because + // strings are considered primitive, but need memory to deserialize + Result &= Deserialize(Bytes, &Element->Selected, Memory); + + + + + + // NOTE(Jesse): Unfortunately we can't check for primitives because + // strings are considered primitive, but need memory to deserialize + Result &= Deserialize(Bytes, &Element->Ordinal, Memory); + + + + + + + + + if (HadBrushPointer) + { + umm Count = 1; + + + if (Element->Brush == 0) + { + Element->Brush = Allocate(world_edit_brush, Memory, Count); + } + + Result &= Deserialize(Bytes, Element->Brush, Memory, Count); + } + + + + + + + + MAYBE_READ_DEBUG_OBJECT_DELIM(); + return Result; +} + +link_internal b32 +Deserialize(u8_cursor *Bytes, world_edit *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_block_array_index.h b/generated/serdes_struct_world_edit_block_array_index.h new file mode 100644 index 000000000..5a80da6f0 --- /dev/null +++ b/generated/serdes_struct_world_edit_block_array_index.h @@ -0,0 +1,100 @@ +// src/engine/serdes.h:495:0 +link_internal bonsai_type_info +TypeInfo(world_edit_block_array_index *Ignored) +{ + bonsai_type_info Result = {}; + + Result.Name = CSz("world_edit_block_array_index"); + 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_edit_block_array_index *BaseElement, umm Count = 1) +{ + Assert(Count > 0); + + u64 PointerTrue = True; + u64 PointerFalse = False; + + b32 Result = True; + + + + RangeIterator_t(umm, ElementIndex, Count) + { + world_edit_block_array_index *Element = BaseElement + ElementIndex; + Result &= Serialize(Bytes, &Element->Index); // default + + + + + + + + + + + + + MAYBE_WRITE_DEBUG_OBJECT_DELIM(); + } + + return Result; +} + +link_internal b32 +Deserialize(u8_cursor *Bytes, world_edit_block_array_index *Element, memory_arena *Memory, umm Count = 1); + +link_internal b32 +DeserializeCurrentVersion(u8_cursor *Bytes, world_edit_block_array_index *Element, memory_arena *Memory); + + + + +link_internal b32 +DeserializeCurrentVersion(u8_cursor *Bytes, world_edit_block_array_index *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->Index, Memory); + + + + + + + + + + + MAYBE_READ_DEBUG_OBJECT_DELIM(); + return Result; +} + +link_internal b32 +Deserialize(u8_cursor *Bytes, world_edit_block_array_index *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_brush.h b/generated/serdes_struct_world_edit_brush.h new file mode 100644 index 000000000..b7ea9dd27 --- /dev/null +++ b/generated/serdes_struct_world_edit_brush.h @@ -0,0 +1,149 @@ +// src/engine/serdes.h:495:0 +link_internal bonsai_type_info +TypeInfo(world_edit_brush *Ignored) +{ + bonsai_type_info Result = {}; + + Result.Name = CSz("world_edit_brush"); + 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_edit_brush *BaseElement, umm Count = 1) +{ + Assert(Count > 0); + + u64 PointerTrue = True; + u64 PointerFalse = False; + + b32 Result = True; + + + + RangeIterator_t(umm, ElementIndex, Count) + { + world_edit_brush *Element = BaseElement + ElementIndex; + { + umm ThisCount = (256) + 1; + + Result &= Serialize(Bytes, Element->NameBuf, ThisCount); + } + + + + + + Result &= Serialize(Bytes, (u32*)&Element->Mode); // enum + + + + + Result &= Serialize(Bytes, (u32*)&Element->Modifier); // enum + + + + + Result &= Serialize(Bytes, &Element->Layered); // default + + + + + + + + + + + + + + + + + + + MAYBE_WRITE_DEBUG_OBJECT_DELIM(); + } + + return Result; +} + +link_internal b32 +Deserialize(u8_cursor *Bytes, world_edit_brush *Element, memory_arena *Memory, umm Count = 1); + +link_internal b32 +DeserializeCurrentVersion(u8_cursor *Bytes, world_edit_brush *Element, memory_arena *Memory); + + + + +link_internal b32 +DeserializeCurrentVersion(u8_cursor *Bytes, world_edit_brush *Element, memory_arena *Memory) +{ + b32 Result = True; + { + umm Count = (256) + 1; + + Result &= Deserialize(Bytes, Element->NameBuf, Memory, Count); + } + + + + + + Element->Mode = Cast(world_edit_blend_mode, Read_u32(Bytes)); + + + + + Element->Modifier = Cast(world_edit_blend_mode_modifier, Read_u32(Bytes)); + + + + + // NOTE(Jesse): Unfortunately we can't check for primitives because + // strings are considered primitive, but need memory to deserialize + Result &= Deserialize(Bytes, &Element->Layered, Memory); + + + + + + + + + + + + + + MAYBE_READ_DEBUG_OBJECT_DELIM(); + return Result; +} + +link_internal b32 +Deserialize(u8_cursor *Bytes, world_edit_brush *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_layer.h b/generated/serdes_struct_world_edit_layer.h new file mode 100644 index 000000000..a09c91e09 --- /dev/null +++ b/generated/serdes_struct_world_edit_layer.h @@ -0,0 +1,123 @@ +// src/engine/serdes.h:495:0 +link_internal bonsai_type_info +TypeInfo(world_edit_layer *Ignored) +{ + bonsai_type_info Result = {}; + + Result.Name = CSz("world_edit_layer"); + 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_edit_layer *BaseElement, umm Count = 1) +{ + Assert(Count > 0); + + u64 PointerTrue = True; + u64 PointerFalse = False; + + b32 Result = True; + + + + RangeIterator_t(umm, ElementIndex, Count) + { + world_edit_layer *Element = BaseElement + ElementIndex; + { + umm ThisCount = (256) + 1; + + Result &= Serialize(Bytes, Element->NameBuf, ThisCount); + } + + + + + + Result &= Serialize(Bytes, &Element->EditIndices); // default + + + + + + + + + + + + + + + MAYBE_WRITE_DEBUG_OBJECT_DELIM(); + } + + return Result; +} + +link_internal b32 +Deserialize(u8_cursor *Bytes, world_edit_layer *Element, memory_arena *Memory, umm Count = 1); + +link_internal b32 +DeserializeCurrentVersion(u8_cursor *Bytes, world_edit_layer *Element, memory_arena *Memory); + + + + +link_internal b32 +DeserializeCurrentVersion(u8_cursor *Bytes, world_edit_layer *Element, memory_arena *Memory) +{ + b32 Result = True; + { + umm Count = (256) + 1; + + Result &= Deserialize(Bytes, Element->NameBuf, Memory, Count); + } + + + + + + // NOTE(Jesse): Unfortunately we can't check for primitives because + // strings are considered primitive, but need memory to deserialize + Result &= Deserialize(Bytes, &Element->EditIndices, Memory); + + + + + + + + + + + + MAYBE_READ_DEBUG_OBJECT_DELIM(); + return Result; +} + +link_internal b32 +Deserialize(u8_cursor *Bytes, world_edit_layer *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 deleted file mode 100644 index 731fbfb3f..000000000 --- a/generated/serdes_struct_world_edit_params.h +++ /dev/null @@ -1,105 +0,0 @@ -// src/engine/serdes.cpp:497:0 - -link_internal bonsai_type_info -TypeInfo(world_edit_params *Ignored) -{ - bonsai_type_info Result = {}; - - Result.Name = CSz("world_edit_params"); - 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_edit_params *BaseElement, umm Count = 1) -{ - Assert(Count > 0); - - u64 PointerTrue = True; - u64 PointerFalse = False; - - b32 Result = True; - - - - RangeIterator_t(umm, ElementIndex, Count) - { - world_edit_params *Element = BaseElement + ElementIndex; - Result &= Serialize(Bytes, (u32*)&Element->Mode); - - - - - Result &= Serialize(Bytes, (u32*)&Element->Modifier); - - - - - Result &= Serialize(Bytes, &Element->Iterations); - - - - MAYBE_WRITE_DEBUG_OBJECT_DELIM(); - } - - return Result; -} - -link_internal b32 -Deserialize(u8_cursor *Bytes, world_edit_params *Element, memory_arena *Memory, umm Count = 1); - -link_internal b32 -DeserializeCurrentVersion(u8_cursor *Bytes, world_edit_params *Element, memory_arena *Memory); - - - - -link_internal b32 -DeserializeCurrentVersion(u8_cursor *Bytes, world_edit_params *Element, memory_arena *Memory) -{ - b32 Result = True; - Element->Mode = Cast(world_edit_mode, Read_u32(Bytes)); - - - - - Element->Modifier = Cast(world_edit_mode_modifier, Read_u32(Bytes)); - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->Iterations, Memory); - - - - MAYBE_READ_DEBUG_OBJECT_DELIM(); - return Result; -} - -link_internal b32 -Deserialize(u8_cursor *Bytes, world_edit_params *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_update_op_shape_params_asset.h b/generated/serdes_struct_world_update_op_shape_params_asset.h new file mode 100644 index 000000000..3f06c1438 --- /dev/null +++ b/generated/serdes_struct_world_update_op_shape_params_asset.h @@ -0,0 +1,136 @@ +// src/engine/serdes.h:495:0 +link_internal bonsai_type_info +TypeInfo(world_update_op_shape_params_asset *Ignored) +{ + bonsai_type_info Result = {}; + + Result.Name = CSz("world_update_op_shape_params_asset"); + 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_update_op_shape_params_asset *BaseElement, umm Count = 1) +{ + Assert(Count > 0); + + u64 PointerTrue = True; + u64 PointerFalse = False; + + b32 Result = True; + + + + RangeIterator_t(umm, ElementIndex, Count) + { + world_update_op_shape_params_asset *Element = BaseElement + ElementIndex; + Result &= Serialize(Bytes, &Element->AssetId); // default + + + + + + + Result &= Serialize(Bytes, &Element->ModelIndex); // default + + + + + + + Result &= Serialize(Bytes, &Element->Origin); // default + + + + + + + + + + + + + + + + + MAYBE_WRITE_DEBUG_OBJECT_DELIM(); + } + + return Result; +} + +link_internal b32 +Deserialize(u8_cursor *Bytes, world_update_op_shape_params_asset *Element, memory_arena *Memory, umm Count = 1); + +link_internal b32 +DeserializeCurrentVersion(u8_cursor *Bytes, world_update_op_shape_params_asset *Element, memory_arena *Memory); + + + + +link_internal b32 +DeserializeCurrentVersion(u8_cursor *Bytes, world_update_op_shape_params_asset *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->AssetId, Memory); + + + + + + // NOTE(Jesse): Unfortunately we can't check for primitives because + // strings are considered primitive, but need memory to deserialize + Result &= Deserialize(Bytes, &Element->ModelIndex, Memory); + + + + + + // NOTE(Jesse): Unfortunately we can't check for primitives because + // strings are considered primitive, but need memory to deserialize + Result &= Deserialize(Bytes, &Element->Origin, Memory); + + + + + + + + + + + + + MAYBE_READ_DEBUG_OBJECT_DELIM(); + return Result; +} + +link_internal b32 +Deserialize(u8_cursor *Bytes, world_update_op_shape_params_asset *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_update_op_shape_params_chunk_data.h b/generated/serdes_struct_world_update_op_shape_params_chunk_data.h new file mode 100644 index 000000000..31d9e5dbc --- /dev/null +++ b/generated/serdes_struct_world_update_op_shape_params_chunk_data.h @@ -0,0 +1,118 @@ +// src/engine/serdes.h:495:0 +link_internal bonsai_type_info +TypeInfo(world_update_op_shape_params_chunk_data *Ignored) +{ + bonsai_type_info Result = {}; + + Result.Name = CSz("world_update_op_shape_params_chunk_data"); + 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_update_op_shape_params_chunk_data *BaseElement, umm Count = 1) +{ + Assert(Count > 0); + + u64 PointerTrue = True; + u64 PointerFalse = False; + + b32 Result = True; + + + + RangeIterator_t(umm, ElementIndex, Count) + { + world_update_op_shape_params_chunk_data *Element = BaseElement + ElementIndex; + Result &= Serialize(Bytes, &Element->Data); // default + + + + + + + Result &= Serialize(Bytes, &Element->SimSpaceOrigin); // default + + + + + + + + + + + + + + + MAYBE_WRITE_DEBUG_OBJECT_DELIM(); + } + + return Result; +} + +link_internal b32 +Deserialize(u8_cursor *Bytes, world_update_op_shape_params_chunk_data *Element, memory_arena *Memory, umm Count = 1); + +link_internal b32 +DeserializeCurrentVersion(u8_cursor *Bytes, world_update_op_shape_params_chunk_data *Element, memory_arena *Memory); + + + + +link_internal b32 +DeserializeCurrentVersion(u8_cursor *Bytes, world_update_op_shape_params_chunk_data *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->Data, Memory); + + + + + + // NOTE(Jesse): Unfortunately we can't check for primitives because + // strings are considered primitive, but need memory to deserialize + Result &= Deserialize(Bytes, &Element->SimSpaceOrigin, Memory); + + + + + + + + + + + + MAYBE_READ_DEBUG_OBJECT_DELIM(); + return Result; +} + +link_internal b32 +Deserialize(u8_cursor *Bytes, world_update_op_shape_params_chunk_data *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_update_op_shape_params_cylinder.h b/generated/serdes_struct_world_update_op_shape_params_cylinder.h new file mode 100644 index 000000000..852654843 --- /dev/null +++ b/generated/serdes_struct_world_update_op_shape_params_cylinder.h @@ -0,0 +1,118 @@ +// src/engine/serdes.h:495:0 +link_internal bonsai_type_info +TypeInfo(world_update_op_shape_params_cylinder *Ignored) +{ + bonsai_type_info Result = {}; + + Result.Name = CSz("world_update_op_shape_params_cylinder"); + 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_update_op_shape_params_cylinder *BaseElement, umm Count = 1) +{ + Assert(Count > 0); + + u64 PointerTrue = True; + u64 PointerFalse = False; + + b32 Result = True; + + + + RangeIterator_t(umm, ElementIndex, Count) + { + world_update_op_shape_params_cylinder *Element = BaseElement + ElementIndex; + Result &= Serialize(Bytes, &Element->Radius); // default + + + + + + + Result &= Serialize(Bytes, &Element->Height); // default + + + + + + + + + + + + + + + MAYBE_WRITE_DEBUG_OBJECT_DELIM(); + } + + return Result; +} + +link_internal b32 +Deserialize(u8_cursor *Bytes, world_update_op_shape_params_cylinder *Element, memory_arena *Memory, umm Count = 1); + +link_internal b32 +DeserializeCurrentVersion(u8_cursor *Bytes, world_update_op_shape_params_cylinder *Element, memory_arena *Memory); + + + + +link_internal b32 +DeserializeCurrentVersion(u8_cursor *Bytes, world_update_op_shape_params_cylinder *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->Radius, Memory); + + + + + + // NOTE(Jesse): Unfortunately we can't check for primitives because + // strings are considered primitive, but need memory to deserialize + Result &= Deserialize(Bytes, &Element->Height, Memory); + + + + + + + + + + + + MAYBE_READ_DEBUG_OBJECT_DELIM(); + return Result; +} + +link_internal b32 +Deserialize(u8_cursor *Bytes, world_update_op_shape_params_cylinder *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_update_op_shape_params_line.h b/generated/serdes_struct_world_update_op_shape_params_line.h new file mode 100644 index 000000000..60f7e35cd --- /dev/null +++ b/generated/serdes_struct_world_update_op_shape_params_line.h @@ -0,0 +1,136 @@ +// src/engine/serdes.h:495:0 +link_internal bonsai_type_info +TypeInfo(world_update_op_shape_params_line *Ignored) +{ + bonsai_type_info Result = {}; + + Result.Name = CSz("world_update_op_shape_params_line"); + 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_update_op_shape_params_line *BaseElement, umm Count = 1) +{ + Assert(Count > 0); + + u64 PointerTrue = True; + u64 PointerFalse = False; + + b32 Result = True; + + + + RangeIterator_t(umm, ElementIndex, Count) + { + world_update_op_shape_params_line *Element = BaseElement + ElementIndex; + Result &= Serialize(Bytes, &Element->P0); // default + + + + + + + Result &= Serialize(Bytes, &Element->P1); // default + + + + + + + Result &= Serialize(Bytes, &Element->Radius); // default + + + + + + + + + + + + + + + + + MAYBE_WRITE_DEBUG_OBJECT_DELIM(); + } + + return Result; +} + +link_internal b32 +Deserialize(u8_cursor *Bytes, world_update_op_shape_params_line *Element, memory_arena *Memory, umm Count = 1); + +link_internal b32 +DeserializeCurrentVersion(u8_cursor *Bytes, world_update_op_shape_params_line *Element, memory_arena *Memory); + + + + +link_internal b32 +DeserializeCurrentVersion(u8_cursor *Bytes, world_update_op_shape_params_line *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->P0, Memory); + + + + + + // NOTE(Jesse): Unfortunately we can't check for primitives because + // strings are considered primitive, but need memory to deserialize + Result &= Deserialize(Bytes, &Element->P1, Memory); + + + + + + // NOTE(Jesse): Unfortunately we can't check for primitives because + // strings are considered primitive, but need memory to deserialize + Result &= Deserialize(Bytes, &Element->Radius, Memory); + + + + + + + + + + + + + MAYBE_READ_DEBUG_OBJECT_DELIM(); + return Result; +} + +link_internal b32 +Deserialize(u8_cursor *Bytes, world_update_op_shape_params_line *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_update_op_shape_params_plane.h b/generated/serdes_struct_world_update_op_shape_params_plane.h new file mode 100644 index 000000000..95507167a --- /dev/null +++ b/generated/serdes_struct_world_update_op_shape_params_plane.h @@ -0,0 +1,113 @@ +// src/engine/serdes.h:495:0 +link_internal bonsai_type_info +TypeInfo(world_update_op_shape_params_plane *Ignored) +{ + bonsai_type_info Result = {}; + + Result.Name = CSz("world_update_op_shape_params_plane"); + 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_update_op_shape_params_plane *BaseElement, umm Count = 1) +{ + Assert(Count > 0); + + u64 PointerTrue = True; + u64 PointerFalse = False; + + b32 Result = True; + + + + RangeIterator_t(umm, ElementIndex, Count) + { + world_update_op_shape_params_plane *Element = BaseElement + ElementIndex; + Result &= Serialize(Bytes, (u32*)&Element->Orientation); // enum + + + + + Result &= Serialize(Bytes, &Element->Thickness); // default + + + + + + + + + + + + + + + MAYBE_WRITE_DEBUG_OBJECT_DELIM(); + } + + return Result; +} + +link_internal b32 +Deserialize(u8_cursor *Bytes, world_update_op_shape_params_plane *Element, memory_arena *Memory, umm Count = 1); + +link_internal b32 +DeserializeCurrentVersion(u8_cursor *Bytes, world_update_op_shape_params_plane *Element, memory_arena *Memory); + + + + +link_internal b32 +DeserializeCurrentVersion(u8_cursor *Bytes, world_update_op_shape_params_plane *Element, memory_arena *Memory) +{ + b32 Result = True; + Element->Orientation = Cast(shape_axis, Read_u32(Bytes)); + + + + + // NOTE(Jesse): Unfortunately we can't check for primitives because + // strings are considered primitive, but need memory to deserialize + Result &= Deserialize(Bytes, &Element->Thickness, Memory); + + + + + + + + + + + + MAYBE_READ_DEBUG_OBJECT_DELIM(); + return Result; +} + +link_internal b32 +Deserialize(u8_cursor *Bytes, world_update_op_shape_params_plane *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_update_op_shape_params_rect.h b/generated/serdes_struct_world_update_op_shape_params_rect.h index 456aeb124..b386a8d0e 100644 --- a/generated/serdes_struct_world_update_op_shape_params_rect.h +++ b/generated/serdes_struct_world_update_op_shape_params_rect.h @@ -1,12 +1,11 @@ -// src/engine/serdes.cpp:532:0 - +// src/engine/serdes.h:495:0 link_internal bonsai_type_info TypeInfo(world_update_op_shape_params_rect *Ignored) { bonsai_type_info Result = {}; Result.Name = CSz("world_update_op_shape_params_rect"); - Result.Version = 0 ; + Result.Version = 0 ; /* type.map(member) */ /* { */ @@ -24,7 +23,7 @@ Serialize(u8_cursor_block_array *Bytes, world_update_op_shape_params_rect *BaseE { Assert(Count > 0); - u64 PointerTrue = True; + u64 PointerTrue = True; u64 PointerFalse = False; b32 Result = True; @@ -34,9 +33,18 @@ Serialize(u8_cursor_block_array *Bytes, world_update_op_shape_params_rect *BaseE RangeIterator_t(umm, ElementIndex, Count) { world_update_op_shape_params_rect *Element = BaseElement + ElementIndex; - Result &= Serialize(Bytes, &Element->Region); + Result &= Serialize(Bytes, &Element->Dim); // default + + + + + + + + + + - MAYBE_WRITE_DEBUG_OBJECT_DELIM(); } @@ -57,11 +65,18 @@ link_internal b32 DeserializeCurrentVersion(u8_cursor *Bytes, world_update_op_shape_params_rect *Element, memory_arena *Memory) { b32 Result = True; - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->Region, Memory); + Result &= Deserialize(Bytes, &Element->Dim, Memory); + + + + + + + + - MAYBE_READ_DEBUG_OBJECT_DELIM(); return Result; @@ -75,7 +90,7 @@ Deserialize(u8_cursor *Bytes, world_update_op_shape_params_rect *Element, memory b32 Result = True; RangeIterator_t(umm, ElementIndex, Count) { - Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); + Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); } 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 7c32e6096..4f2734fac 100644 --- a/generated/serdes_struct_world_update_op_shape_params_sphere.h +++ b/generated/serdes_struct_world_update_op_shape_params_sphere.h @@ -1,12 +1,11 @@ -// src/engine/serdes.cpp:534:0 - +// src/engine/serdes.h:495:0 link_internal bonsai_type_info TypeInfo(world_update_op_shape_params_sphere *Ignored) { bonsai_type_info Result = {}; Result.Name = CSz("world_update_op_shape_params_sphere"); - Result.Version = 0 ; + Result.Version = 0 ; /* type.map(member) */ /* { */ @@ -24,7 +23,7 @@ Serialize(u8_cursor_block_array *Bytes, world_update_op_shape_params_sphere *Bas { Assert(Count > 0); - u64 PointerTrue = True; + u64 PointerTrue = True; u64 PointerFalse = False; b32 Result = True; @@ -34,15 +33,27 @@ Serialize(u8_cursor_block_array *Bytes, world_update_op_shape_params_sphere *Bas RangeIterator_t(umm, ElementIndex, Count) { world_update_op_shape_params_sphere *Element = BaseElement + ElementIndex; - Result &= Serialize(Bytes, &Element->Location); + Result &= Serialize(Bytes, &Element->Location); // default - Result &= Serialize(Bytes, &Element->Radius); - + Result &= Serialize(Bytes, &Element->Radius); // default + + + + + + + + + + + + + MAYBE_WRITE_DEBUG_OBJECT_DELIM(); } @@ -63,7 +74,7 @@ link_internal b32 DeserializeCurrentVersion(u8_cursor *Bytes, world_update_op_shape_params_sphere *Element, memory_arena *Memory) { b32 Result = True; - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Location, Memory); @@ -71,12 +82,20 @@ DeserializeCurrentVersion(u8_cursor *Bytes, world_update_op_shape_params_sphere - // NOTE(Jesse): Unfortunately we can't check for primitives because + // NOTE(Jesse): Unfortunately we can't check for primitives because // strings are considered primitive, but need memory to deserialize Result &= Deserialize(Bytes, &Element->Radius, Memory); + + + + + + + + MAYBE_READ_DEBUG_OBJECT_DELIM(); return Result; } @@ -89,7 +108,7 @@ Deserialize(u8_cursor *Bytes, world_update_op_shape_params_sphere *Element, memo b32 Result = True; RangeIterator_t(umm, ElementIndex, Count) { - Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); + Result &= DeserializeCurrentVersion(Bytes, Element+ElementIndex, Memory); } diff --git a/generated/serdes_struct_world_update_op_shape_params_torus.h b/generated/serdes_struct_world_update_op_shape_params_torus.h new file mode 100644 index 000000000..0a4b4733c --- /dev/null +++ b/generated/serdes_struct_world_update_op_shape_params_torus.h @@ -0,0 +1,118 @@ +// src/engine/serdes.h:495:0 +link_internal bonsai_type_info +TypeInfo(world_update_op_shape_params_torus *Ignored) +{ + bonsai_type_info Result = {}; + + Result.Name = CSz("world_update_op_shape_params_torus"); + 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_update_op_shape_params_torus *BaseElement, umm Count = 1) +{ + Assert(Count > 0); + + u64 PointerTrue = True; + u64 PointerFalse = False; + + b32 Result = True; + + + + RangeIterator_t(umm, ElementIndex, Count) + { + world_update_op_shape_params_torus *Element = BaseElement + ElementIndex; + Result &= Serialize(Bytes, &Element->MajorRadius); // default + + + + + + + Result &= Serialize(Bytes, &Element->MinorRadius); // default + + + + + + + + + + + + + + + MAYBE_WRITE_DEBUG_OBJECT_DELIM(); + } + + return Result; +} + +link_internal b32 +Deserialize(u8_cursor *Bytes, world_update_op_shape_params_torus *Element, memory_arena *Memory, umm Count = 1); + +link_internal b32 +DeserializeCurrentVersion(u8_cursor *Bytes, world_update_op_shape_params_torus *Element, memory_arena *Memory); + + + + +link_internal b32 +DeserializeCurrentVersion(u8_cursor *Bytes, world_update_op_shape_params_torus *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->MajorRadius, Memory); + + + + + + // NOTE(Jesse): Unfortunately we can't check for primitives because + // strings are considered primitive, but need memory to deserialize + Result &= Deserialize(Bytes, &Element->MinorRadius, Memory); + + + + + + + + + + + + MAYBE_READ_DEBUG_OBJECT_DELIM(); + return Result; +} + +link_internal b32 +Deserialize(u8_cursor *Bytes, world_update_op_shape_params_torus *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_vector_Quaternion.h b/generated/serdes_vector_Quaternion.h index 871a9bc88..9a22a7b32 100644 --- a/generated/serdes_vector_Quaternion.h +++ b/generated/serdes_vector_Quaternion.h @@ -1,5 +1,4 @@ -// src/engine/serdes.cpp:259:0 - +// src/engine/serdes.h:503:0 link_internal b32 Serialize(u8_cursor_block_array *Bytes, Quaternion *Element, umm Count = 1) { diff --git a/generated/serdes_vector_v2.h b/generated/serdes_vector_v2.h index d99274dc3..5df988c6d 100644 --- a/generated/serdes_vector_v2.h +++ b/generated/serdes_vector_v2.h @@ -1,5 +1,4 @@ -// src/engine/serdes.cpp:3:0 - +// src/engine/serdes.h:503:0 link_internal b32 Serialize(u8_cursor_block_array *Bytes, v2 *Element, umm Count = 1) { diff --git a/generated/serdes_vector_v2i.h b/generated/serdes_vector_v2i.h index b2ad225f8..9f53b47e3 100644 --- a/generated/serdes_vector_v2i.h +++ b/generated/serdes_vector_v2i.h @@ -1,5 +1,4 @@ -// src/engine/serdes.cpp:12:0 - +// src/engine/serdes.h:503:0 link_internal b32 Serialize(u8_cursor_block_array *Bytes, v2i *Element, umm Count = 1) { diff --git a/generated/serdes_vector_v3.h b/generated/serdes_vector_v3.h index d51fe84f2..715a229b0 100644 --- a/generated/serdes_vector_v3.h +++ b/generated/serdes_vector_v3.h @@ -1,5 +1,4 @@ -// src/engine/serdes.cpp:6:0 - +// src/engine/serdes.h:503:0 link_internal b32 Serialize(u8_cursor_block_array *Bytes, v3 *Element, umm Count = 1) { diff --git a/generated/serdes_vector_v3i.h b/generated/serdes_vector_v3i.h index 3aafd6d34..e2f6404bd 100644 --- a/generated/serdes_vector_v3i.h +++ b/generated/serdes_vector_v3i.h @@ -1,5 +1,4 @@ -// src/engine/serdes.cpp:15:0 - +// src/engine/serdes.h:503:0 link_internal b32 Serialize(u8_cursor_block_array *Bytes, v3i *Element, umm Count = 1) { diff --git a/generated/serdes_vector_v4.h b/generated/serdes_vector_v4.h index 73e2be987..702b3f8bf 100644 --- a/generated/serdes_vector_v4.h +++ b/generated/serdes_vector_v4.h @@ -1,5 +1,4 @@ -// src/engine/serdes.cpp:9:0 - +// src/engine/serdes.h:503:0 link_internal b32 Serialize(u8_cursor_block_array *Bytes, v4 *Element, umm Count = 1) { diff --git a/generated/serialize_struct_entity.h b/generated/serialize_struct_entity.h index cfa7ae79c..20d803013 100644 --- a/generated/serialize_struct_entity.h +++ b/generated/serialize_struct_entity.h @@ -1,12 +1,11 @@ -// src/engine/serdes.cpp:361:0 - +// src/engine/serdes.h:132:0 link_internal bonsai_type_info TypeInfo(entity *Ignored) { bonsai_type_info Result = {}; Result.Name = CSz("entity"); - Result.Version =2 ; + Result.Version = 2 ; /* type.map(member) */ /* { */ @@ -24,99 +23,142 @@ Serialize(u8_cursor_block_array *Bytes, entity *BaseElement, umm Count = 1) { Assert(Count > 0); - u64 PointerTrue = True; + u64 PointerTrue = True; u64 PointerFalse = False; b32 Result = True; - Upsert(TypeInfo(BaseElement), &Global_SerializeTypeTable, Global_SerializeTypeTableArena ); - u64 VersionNumber =2; + Upsert(TypeInfo(BaseElement), &Global_SerializeTypeTable, Global_SerializeTypeTableArena ); + u64 VersionNumber = 2; Serialize(Bytes, &VersionNumber); RangeIterator_t(umm, ElementIndex, Count) { entity *Element = BaseElement + ElementIndex; - Result &= Serialize(Bytes, &Element->Id); + Result &= Serialize(Bytes, &Element->Id); // default + + + + + + + Result &= Serialize(Bytes, &Element->P); // default - Result &= Serialize(Bytes, &Element->P); + Result &= Serialize(Bytes, &Element->EulerAngles); // default - Result &= Serialize(Bytes, &Element->EulerAngles); + Result &= Serialize(Bytes, &Element->Scale); // default - Result &= Serialize(Bytes, &Element->Scale); + Result &= Serialize(Bytes, &Element->_CollisionVolumeRadius); // default - Result &= Serialize(Bytes, &Element->_CollisionVolumeRadius); + Result &= Serialize(Bytes, &Element->Physics); // default - Result &= Serialize(Bytes, &Element->Physics); - Result &= Serialize(Bytes, &Element->AssetId); + Result &= Serialize(Bytes, &Element->AssetId); // default - Result &= Serialize(Bytes, &Element->ModelIndex); + Result &= Serialize(Bytes, &Element->ModelIndex); // default - if (Element->Emitter) { Result &= Write(Bytes, Cast(u8*, &PointerTrue), sizeof(PointerTrue)); } + + + + + if (Element->Emitter) { Result &= Write(Bytes, Cast(u8*, &PointerTrue), sizeof(PointerTrue)); } else { Result &= Write(Bytes, Cast(u8*, &PointerFalse), sizeof(PointerFalse)); } - Result &= Serialize(Bytes, (u32*)&Element->State); + Result &= Serialize(Bytes, (u32*)&Element->State); // enum + + + + + Result &= Serialize(Bytes, (u32*)&Element->Behavior); // enum + + + + + Result &= Serialize(Bytes, &Element->Carrying); // default + + + + + + + Result &= Serialize(Bytes, &Element->UserType); // default + + + + + if (EntityUserDataSerialize) {Result &= EntityUserDataSerialize(Bytes, Element->UserType, Element->UserData);} - Result &= Serialize(Bytes, (u32*)&Element->Behavior); + + - Result &= Serialize(Bytes, &Element->Carrying); + + + + + - Result &= Serialize(Bytes, &Element->UserType); + + + + if (Element->Emitter) { Result &= Serialize(Bytes, Element->Emitter); } + - if (EntityUserDataSerialize) {Result &= EntityUserDataSerialize(Bytes, Element->UserType, Element->UserData);} + - if (Element->Emitter) { Result &= Serialize(Bytes, Element->Emitter); } + + + diff --git a/generated/serialize_struct_level_header.h b/generated/serialize_struct_level_header.h index 0ee6ae028..11338307d 100644 --- a/generated/serialize_struct_level_header.h +++ b/generated/serialize_struct_level_header.h @@ -1,12 +1,11 @@ -// src/engine/serdes.cpp:504:0 - +// src/engine/serdes.h:132:0 link_internal bonsai_type_info TypeInfo(level_header *Ignored) { bonsai_type_info Result = {}; Result.Name = CSz("level_header"); - Result.Version =4 ; + Result.Version = 0 ; /* type.map(member) */ /* { */ @@ -24,58 +23,113 @@ Serialize(u8_cursor_block_array *Bytes, level_header *BaseElement, umm Count = 1 { Assert(Count > 0); - u64 PointerTrue = True; + u64 PointerTrue = True; u64 PointerFalse = False; b32 Result = True; - Upsert(TypeInfo(BaseElement), &Global_SerializeTypeTable, Global_SerializeTypeTableArena ); - u64 VersionNumber =4; - Serialize(Bytes, &VersionNumber); - + RangeIterator_t(umm, ElementIndex, Count) { level_header *Element = BaseElement + ElementIndex; - Result &= Serialize(Bytes, &Element->ChunkCount); + Result &= Serialize(Bytes, &Element->LayerCount); // default + + + + + + + Result &= Serialize(Bytes, &Element->EditCount); // default + + + + + + + Result &= Serialize(Bytes, &Element->EntityCount); // default + + + + + + + Result &= Serialize(Bytes, &Element->SelectedLayerIndex); // default + + + + + + + Result &= Serialize(Bytes, &Element->WorldCenter); // default + + + + + + + Result &= Serialize(Bytes, (u32*)&Element->VisibleRegionSize); // enum + + + + + Result &= Serialize(Bytes, &Element->Camera); // default + + + + + + + Result &= Serialize(Bytes, &Element->RenderSettings); // default - Result &= Serialize(Bytes, &Element->EntityCount); + { + umm ThisCount = (256); + Result &= Serialize(Bytes, Element->TerrainShapingShader, ThisCount); + } - Result &= Serialize(Bytes, &Element->WorldFlags); + { + umm ThisCount = (256); + Result &= Serialize(Bytes, Element->TerrainDecorationShader, ThisCount); + } - Result &= Serialize(Bytes, &Element->WorldCenter); - Result &= Serialize(Bytes, &Element->VisibleRegion); + + + + + - Result &= Serialize(Bytes, &Element->Camera); + + + + + - Result &= Serialize(Bytes, &Element->RenderSettings); - MAYBE_WRITE_DEBUG_OBJECT_DELIM(); } diff --git a/generated/serialize_struct_render_settings_0.h b/generated/serialize_struct_render_settings_0.h deleted file mode 100644 index 3883d1356..000000000 --- a/generated/serialize_struct_render_settings_0.h +++ /dev/null @@ -1,125 +0,0 @@ -// src/engine/serdes.cpp:422:0 - -link_internal b32 -Deserialize(u8_cursor *Bytes, render_settings_0 *Element, memory_arena *Memory, umm Count = 1); - -link_internal b32 -DeserializeCurrentVersion(u8_cursor *Bytes, render_settings_0 *Element, memory_arena *Memory); - - - - -link_internal b32 -DeserializeCurrentVersion(u8_cursor *Bytes, render_settings_0 *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->UseSsao, Memory); - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->UseShadowMapping, Memory); - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->UseLightingBloom, Memory); - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->BravoilMyersOIT, Memory); - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->BravoilMcGuireOIT, Memory); - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->DrawMajorGrid, Memory); - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->DrawMinorGrid, Memory); - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->MajorGridDim, Memory); - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->OffsetOfWorldCenterToGrid, Memory); - - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->Headless, Memory); - - - - - - Element->ToneMappingType = Cast(tone_mapping_type, Read_u32(Bytes)); - - - - - // NOTE(Jesse): Unfortunately we can't check for primitives because - // strings are considered primitive, but need memory to deserialize - Result &= Deserialize(Bytes, &Element->Lighting, Memory); - - - - MAYBE_READ_DEBUG_OBJECT_DELIM(); - return Result; -} - -link_internal b32 -Deserialize(u8_cursor *Bytes, render_settings_0 *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/shader_magic_bloom_downsample_shader.h b/generated/shader_magic_bloom_downsample_shader.h deleted file mode 100644 index 619bb0a26..000000000 --- a/generated/shader_magic_bloom_downsample_shader.h +++ /dev/null @@ -1,38 +0,0 @@ -// src/engine/bloom.h:11:0 - -link_internal void -InitializeBloomDownsampleShader( bloom_downsample_shader *Struct , v2*SrcResolution ) -{ - Struct->Program = LoadShaders(CSz("external/bonsai_stdlib/shaders/Passthrough.vertexshader"), CSz("shaders/bloom_downsample.fragmentshader")); - - u32 UniformIndex = 0; - - Struct->SrcResolution = SrcResolution; - - Struct->Uniforms[UniformIndex] = ShaderUniform(&Struct->Program, Struct->SrcResolution, "SrcResolution"); - ++UniformIndex; - - if (UniformIndex != 1 ) - { - Error("Shader (bloom_downsample_shader) had an incorrect number of uniform slots!"); - } - - -} - -link_internal void -UseShader( bloom_downsample_shader *Struct ) -{ - GL.UseProgram(Struct->Program.ID); - - s32 TextureUnit = 0; - s32 UniformIndex = 0; - BindUnifromById(Struct->Uniforms+UniformIndex, &TextureUnit); - ++UniformIndex; - - if (UniformIndex != 1 ) - { - Error("Shader (bloom_downsample_shader) had an incorrect number of uniform slots!"); - } -} - diff --git a/generated/shader_magic_bloom_upsample_shader.h b/generated/shader_magic_bloom_upsample_shader.h deleted file mode 100644 index e50d96165..000000000 --- a/generated/shader_magic_bloom_upsample_shader.h +++ /dev/null @@ -1,38 +0,0 @@ -// src/engine/bloom.h:25:0 - -link_internal void -InitializeBloomUpsampleShader( bloom_upsample_shader *Struct , f32*FilterRadius ) -{ - Struct->Program = LoadShaders(CSz("external/bonsai_stdlib/shaders/Passthrough.vertexshader"), CSz("shaders/bloom_upsample.fragmentshader")); - - u32 UniformIndex = 0; - - Struct->FilterRadius = FilterRadius; - - Struct->Uniforms[UniformIndex] = ShaderUniform(&Struct->Program, Struct->FilterRadius, "FilterRadius"); - ++UniformIndex; - - if (UniformIndex != 1 ) - { - Error("Shader (bloom_upsample_shader) had an incorrect number of uniform slots!"); - } - - -} - -link_internal void -UseShader( bloom_upsample_shader *Struct ) -{ - GL.UseProgram(Struct->Program.ID); - - s32 TextureUnit = 0; - s32 UniformIndex = 0; - BindUnifromById(Struct->Uniforms+UniformIndex, &TextureUnit); - ++UniformIndex; - - if (UniformIndex != 1 ) - { - Error("Shader (bloom_upsample_shader) had an incorrect number of uniform slots!"); - } -} - diff --git a/generated/shader_magic_shadow_map_shader.h b/generated/shader_magic_shadow_map_shader.h deleted file mode 100644 index 1de332f42..000000000 --- a/generated/shader_magic_shadow_map_shader.h +++ /dev/null @@ -1,60 +0,0 @@ -// src/engine/render/shadow_map.h:21:0 - -link_internal void -InitializeShadowMapShader( shadow_map_shader *Struct , m4 MVP , m4 ModelMatrix , v3*MinClipP_worldspace , v3*MaxClipP_worldspace ) -{ - Struct->Program = LoadShaders(CSz("shaders/DepthRTT.vertexshader"), CSz("shaders/DepthRTT.fragmentshader")); - - u32 UniformIndex = 0; - - - Struct->Uniforms[UniformIndex] = ShaderUniform(&Struct->Program,&Struct->MVP, "MVP"); - ++UniformIndex; - - - Struct->Uniforms[UniformIndex] = ShaderUniform(&Struct->Program,&Struct->ModelMatrix, "ModelMatrix"); - ++UniformIndex; - - Struct->MinClipP_worldspace = MinClipP_worldspace; - - Struct->Uniforms[UniformIndex] = ShaderUniform(&Struct->Program, Struct->MinClipP_worldspace, "MinClipP_worldspace"); - ++UniformIndex; - - Struct->MaxClipP_worldspace = MaxClipP_worldspace; - - Struct->Uniforms[UniformIndex] = ShaderUniform(&Struct->Program, Struct->MaxClipP_worldspace, "MaxClipP_worldspace"); - ++UniformIndex; - - if (UniformIndex != 4 ) - { - Error("Shader (shadow_map_shader) had an incorrect number of uniform slots!"); - } - - -} - -link_internal void -UseShader( shadow_map_shader *Struct ) -{ - GL.UseProgram(Struct->Program.ID); - - s32 TextureUnit = 0; - s32 UniformIndex = 0; - BindUnifromById(Struct->Uniforms+UniformIndex, &TextureUnit); - ++UniformIndex; - - BindUnifromById(Struct->Uniforms+UniformIndex, &TextureUnit); - ++UniformIndex; - - BindUnifromById(Struct->Uniforms+UniformIndex, &TextureUnit); - ++UniformIndex; - - BindUnifromById(Struct->Uniforms+UniformIndex, &TextureUnit); - ++UniformIndex; - - if (UniformIndex != 4 ) - { - Error("Shader (shadow_map_shader) had an incorrect number of uniform slots!"); - } -} - diff --git a/generated/shader_magic_textured_quad_render_pass.h b/generated/shader_magic_textured_quad_render_pass.h new file mode 100644 index 000000000..7e4fcaaff --- /dev/null +++ b/generated/shader_magic_textured_quad_render_pass.h @@ -0,0 +1,186 @@ +// external/bonsai_stdlib/src/shader.h:6:0 +link_internal b32 +poof() +InitializeTexturedQuadRenderPass +( + textured_quad_render_pass *Element + + + , b32 IsDepthTexture + , b32 HasAlphaChannel + , s32 TextureSlice + , v3 Tint + +) +{ + b32 Result = CompileShaderPair(&Element->Program, CSz(STDLIB_SHADER_PATH "FullPassthrough.vertexshader"), CSz(STDLIB_SHADER_PATH "SimpleTexture.fragmentshader")); + + if (Result) + { + Element->Program.Uniforms = ShaderUniformBuffer(Element->Uniforms, ArrayCount(Element->Uniforms)); + + u32 UniformIndex = 0; + + + + Element->IsDepthTexture = IsDepthTexture; + InitShaderUniform( + &Element->Program, + UniformIndex++, + + + + &Element->IsDepthTexture, + "IsDepthTexture" + + + ); + + + + Element->HasAlphaChannel = HasAlphaChannel; + InitShaderUniform( + &Element->Program, + UniformIndex++, + + + + &Element->HasAlphaChannel, + "HasAlphaChannel" + + + ); + + + + Element->TextureSlice = TextureSlice; + InitShaderUniform( + &Element->Program, + UniformIndex++, + + + + &Element->TextureSlice, + "TextureSlice" + + + ); + + + + Element->Tint = Tint; + InitShaderUniform( + &Element->Program, + UniformIndex++, + + + + &Element->Tint, + "Tint" + + + ); + + + + + + u32 Expected = 4 ; + if (UniformIndex != Expected ) + { + Error("Shader (textured_quad_render_pass) had an incorrect number of uniform slots! Expected (%d), Got (%d)", Expected, UniformIndex); + } + } + + + + AssertNoGlErrors; + return Result; +} + +link_internal void +UseRenderPass_textured_quad_render_pass +( textured_quad_render_pass *Element ) +{ + TIMED_FUNCTION(); + if (Element->Program.ID != INVALID_SHADER) + { + { + TIMED_NAMED_BLOCK(UseProgram); + GetGL()->UseProgram(Element->Program.ID); + } + + { + TIMED_NAMED_BLOCK(BindUniforms); + s32 TextureUnit = 0; + s32 UniformIndex = 0; + + + { + shader_uniform *Uniform = Element->Uniforms+UniformIndex; + BindUniformById(Uniform, &TextureUnit); + ++UniformIndex; + AssertNoGlErrors; + } + + + { + shader_uniform *Uniform = Element->Uniforms+UniformIndex; + BindUniformById(Uniform, &TextureUnit); + ++UniformIndex; + AssertNoGlErrors; + } + + + { + shader_uniform *Uniform = Element->Uniforms+UniformIndex; + BindUniformById(Uniform, &TextureUnit); + ++UniformIndex; + AssertNoGlErrors; + } + + + { + shader_uniform *Uniform = Element->Uniforms+UniformIndex; + BindUniformById(Uniform, &TextureUnit); + ++UniformIndex; + AssertNoGlErrors; + } + + + + + if (UniformIndex != 4 ) + { + Error("Shader (textured_quad_render_pass) had an incorrect number of uniform slots!"); + } + } + } + else + { + SoftError("Attempted to bind uncompiled Shader (STDLIB_SHADER_PATH \"FullPassthrough.vertexshader\") | (STDLIB_SHADER_PATH \"SimpleTexture.fragmentshader\")"); + } + + AssertNoGlErrors; +} + +// NOTE(Jesse): This is for binding when passing a custom RP through the UI +link_internal void +UseRenderPass_textured_quad_render_pass( void *Element ) +{ + UseRenderPass_textured_quad_render_pass( Cast(textured_quad_render_pass *, Element) ); +} + +link_internal void +UseRenderPass( textured_quad_render_pass *Element ) +{ + UseRenderPass_textured_quad_render_pass(Element); +} + +// TODO(Jesse): Remove in favor of UseRenderPass +link_internal void +UseShader( textured_quad_render_pass *Element ) +{ + UseRenderPass_textured_quad_render_pass(Element); +} + diff --git a/generated/static_cursor_v2_0_986190493.h b/generated/static_cursor_v2_0_986190493.h new file mode 100644 index 000000000..f55ff77b9 --- /dev/null +++ b/generated/static_cursor_v2_0_986190493.h @@ -0,0 +1,61 @@ +// external/bonsai_stdlib/src/poof_functions.h:1235:0 + +struct v2_static_cursor_16 +poof(@do_editor_ui) +{ + v2 Start[16]; poof(@array_length(Element->At)) + u32 At; +}; + +link_inline v2* +GetPtr( v2_static_cursor_16 *Buf, umm Index) +{ + v2 *Result = {}; + if ( Index < umm(16) ) + { + Result = Buf->Start+Index; + } + return Result; +} + +link_inline v2* +TryGetPtr( v2_static_cursor_16 *Buf, umm Index) +{ + return GetPtr(Buf, Index); +} + +link_inline v2 +Get( v2_static_cursor_16 *Buf, umm Index) +{ + Assert(Index < umm(16)); + Assert(Index < umm((Buf->At))); + v2 Result = Buf->Start[Index]; + return Result; +} + +link_internal umm +AtElements( v2_static_cursor_16 *Buf) +{ + return Buf->At; +} + +link_internal umm +TotalElements( v2_static_cursor_16 *Buf) +{ + return 16; +} + +link_inline void +Push( v2_static_cursor_16 *Buf, v2 *E ) +{ + Assert(AtElements(Buf) < TotalElements(Buf)); + Buf->Start[Buf->At++] = *E; +} + +link_inline void +Push( v2_static_cursor_16 *Buf, v2 E ) +{ + Assert(AtElements(Buf) < TotalElements(Buf)); + Buf->Start[Buf->At++] = E; +} + diff --git a/generated/staticbuffer_u32_cursor_ptr_961996651.h b/generated/staticbuffer_u32_cursor_ptr_961996651.h index 28798f610..e63fe0ce5 100644 --- a/generated/staticbuffer_u32_cursor_ptr_961996651.h +++ b/generated/staticbuffer_u32_cursor_ptr_961996651.h @@ -1,5 +1,4 @@ -// src/engine/voxel_synthesis.h:42:0 - +// external/bonsai_stdlib/src/poof_functions.h:1185:0 struct entropy_lists { u32_cursor Start[TILE_RULESETS_COUNT]; @@ -16,6 +15,12 @@ GetPtr( entropy_lists *Buf, umm Index) return Result; } +link_inline u32_cursor* +TryGetPtr( entropy_lists *Buf, umm Index) +{ + return GetPtr(Buf, Index); +} + link_inline u32_cursor Get( entropy_lists *Buf, umm Index) { diff --git a/generated/stream_and_cursor_counted_string.h b/generated/stream_and_cursor_counted_string.h index 2ef9d5ec7..baa974f60 100644 --- a/generated/stream_and_cursor_counted_string.h +++ b/generated/stream_and_cursor_counted_string.h @@ -1,12 +1,10 @@ -// external/bonsai_stdlib/src/counted_string.h:116:0 - +// external/bonsai_stdlib/src/poof_functions.h:2057:0 struct counted_string_cursor { counted_string *Start; // TODO(Jesse)(immediate): For the love of fucksakes change these to indices counted_string *At; counted_string *End; - /* OWNED_BY_THREAD_MEMBER(); */ }; @@ -15,12 +13,12 @@ link_internal counted_string_cursor CountedStringCursor(umm ElementCount, memory_arena* Memory) { counted_string *Start = (counted_string*)PushStruct(Memory, sizeof(counted_string)*ElementCount, 1, 0); - counted_string_cursor Result = { - .Start = Start, - .End = Start+ElementCount, - .At = Start, - /* OWNED_BY_THREAD_MEMBER_INIT() */ - }; + counted_string_cursor Result = {}; + + Result.Start = Start; + Result.End = Start+ElementCount; + Result.At = Start; + return Result; } @@ -34,6 +32,12 @@ GetPtr(counted_string_cursor *Cursor, umm ElementIndex) return Result; } +link_internal counted_string* +TryGetPtr(counted_string_cursor *Cursor, umm ElementIndex) +{ + return GetPtr(Cursor, ElementIndex); +} + link_internal counted_string* GetPtrUnsafe(counted_string_cursor *Cursor, umm ElementIndex) { @@ -194,6 +198,14 @@ struct counted_string_stream umm ChunkCount; }; +link_internal counted_string_stream +CountedStringStream(memory_arena *Memory) +{ + counted_string_stream Result = {}; + Result.Memory = Memory; + return Result; +} + link_internal void Deallocate(counted_string_stream *Stream) { @@ -242,10 +254,7 @@ IsLastElement(counted_string_iterator* Iter) link_internal counted_string * Push(counted_string_stream* Stream, counted_string Element) { - if (Stream->Memory == 0) - { - Stream->Memory = AllocateArena(); - } + Assert(Stream->Memory); /* (Type.name)_stream_chunk* NextChunk = AllocateProtection((Type.name)_stream_chunk*), Stream->Memory, 1, False) */ counted_string_stream_chunk* NextChunk = (counted_string_stream_chunk*)PushStruct(Stream->Memory, sizeof(counted_string_stream_chunk), 1, 0); diff --git a/generated/stream_and_cursor_s32.h b/generated/stream_and_cursor_s32.h index 010b70c98..fbc010afe 100644 --- a/generated/stream_and_cursor_s32.h +++ b/generated/stream_and_cursor_s32.h @@ -1,12 +1,10 @@ -// external/bonsai_stdlib/src/binary_parser.cpp:36:0 - +// external/bonsai_stdlib/src/poof_functions.h:2057:0 struct s32_cursor { s32 *Start; // TODO(Jesse)(immediate): For the love of fucksakes change these to indices s32 *At; s32 *End; - /* OWNED_BY_THREAD_MEMBER(); */ }; @@ -15,12 +13,12 @@ link_internal s32_cursor S32Cursor(umm ElementCount, memory_arena* Memory) { s32 *Start = (s32*)PushStruct(Memory, sizeof(s32)*ElementCount, 1, 0); - s32_cursor Result = { - .Start = Start, - .End = Start+ElementCount, - .At = Start, - /* OWNED_BY_THREAD_MEMBER_INIT() */ - }; + s32_cursor Result = {}; + + Result.Start = Start; + Result.End = Start+ElementCount; + Result.At = Start; + return Result; } @@ -34,6 +32,12 @@ GetPtr(s32_cursor *Cursor, umm ElementIndex) return Result; } +link_internal s32* +TryGetPtr(s32_cursor *Cursor, umm ElementIndex) +{ + return GetPtr(Cursor, ElementIndex); +} + link_internal s32* GetPtrUnsafe(s32_cursor *Cursor, umm ElementIndex) { @@ -194,6 +198,14 @@ struct s32_stream umm ChunkCount; }; +link_internal s32_stream +S32Stream(memory_arena *Memory) +{ + s32_stream Result = {}; + Result.Memory = Memory; + return Result; +} + link_internal void Deallocate(s32_stream *Stream) { @@ -242,10 +254,7 @@ IsLastElement(s32_iterator* Iter) link_internal s32 * Push(s32_stream* Stream, s32 Element) { - if (Stream->Memory == 0) - { - Stream->Memory = AllocateArena(); - } + Assert(Stream->Memory); /* (Type.name)_stream_chunk* NextChunk = AllocateProtection((Type.name)_stream_chunk*), Stream->Memory, 1, False) */ s32_stream_chunk* NextChunk = (s32_stream_chunk*)PushStruct(Stream->Memory, sizeof(s32_stream_chunk), 1, 0); diff --git a/generated/stream_and_cursor_u32.h b/generated/stream_and_cursor_u32.h index c0fe40b6e..66aeb546d 100644 --- a/generated/stream_and_cursor_u32.h +++ b/generated/stream_and_cursor_u32.h @@ -1,12 +1,10 @@ -// external/bonsai_stdlib/src/binary_parser.cpp:9:0 - +// external/bonsai_stdlib/src/poof_functions.h:2057:0 struct u32_cursor { u32 *Start; // TODO(Jesse)(immediate): For the love of fucksakes change these to indices u32 *At; u32 *End; - /* OWNED_BY_THREAD_MEMBER(); */ }; @@ -15,12 +13,12 @@ link_internal u32_cursor U32Cursor(umm ElementCount, memory_arena* Memory) { u32 *Start = (u32*)PushStruct(Memory, sizeof(u32)*ElementCount, 1, 0); - u32_cursor Result = { - .Start = Start, - .End = Start+ElementCount, - .At = Start, - /* OWNED_BY_THREAD_MEMBER_INIT() */ - }; + u32_cursor Result = {}; + + Result.Start = Start; + Result.End = Start+ElementCount; + Result.At = Start; + return Result; } @@ -34,6 +32,12 @@ GetPtr(u32_cursor *Cursor, umm ElementIndex) return Result; } +link_internal u32* +TryGetPtr(u32_cursor *Cursor, umm ElementIndex) +{ + return GetPtr(Cursor, ElementIndex); +} + link_internal u32* GetPtrUnsafe(u32_cursor *Cursor, umm ElementIndex) { @@ -194,6 +198,14 @@ struct u32_stream umm ChunkCount; }; +link_internal u32_stream +U32Stream(memory_arena *Memory) +{ + u32_stream Result = {}; + Result.Memory = Memory; + return Result; +} + link_internal void Deallocate(u32_stream *Stream) { @@ -242,10 +254,7 @@ IsLastElement(u32_iterator* Iter) link_internal u32 * Push(u32_stream* Stream, u32 Element) { - if (Stream->Memory == 0) - { - Stream->Memory = AllocateArena(); - } + Assert(Stream->Memory); /* (Type.name)_stream_chunk* NextChunk = AllocateProtection((Type.name)_stream_chunk*), Stream->Memory, 1, False) */ u32_stream_chunk* NextChunk = (u32_stream_chunk*)PushStruct(Stream->Memory, sizeof(u32_stream_chunk), 1, 0); diff --git a/generated/string_and_value_tables_ZQctkgyx.h b/generated/string_and_value_tables_ZQctkgyx.h new file mode 100644 index 000000000..ef3088fc7 --- /dev/null +++ b/generated/string_and_value_tables_ZQctkgyx.h @@ -0,0 +1,108 @@ +// external/bonsai_stdlib/src/poof_functions.h:2049:0 +link_internal b32 +IsValid(work_queue_entry_type Value) +{ + b32 Result = False; + switch (Value) + { + case type_work_queue_entry_noop: + case type_work_queue_entry_init_world_chunk: + case type_work_queue_entry_finalize_noise_values: + case type_work_queue_entry_build_chunk_mesh: + 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__bonsai_render_command: + case type_work_queue_entry_async_function_call: + case type_work_queue_entry__align_to_cache_line_helper: + + { + Result = True; + } + } + return Result; +} + + + +link_internal counted_string +ToStringPrefixless(work_queue_entry_type Type) +{ + Assert(IsValid(Type)); + counted_string Result = {}; + + switch (Type) + { + case type_work_queue_entry_noop: { Result = CSz("noop"); } break; + case type_work_queue_entry_init_world_chunk: { Result = CSz("chunk"); } break; + case type_work_queue_entry_finalize_noise_values: { Result = CSz("values"); } break; + case type_work_queue_entry_build_chunk_mesh: { Result = CSz("mesh"); } break; + case type_work_queue_entry_copy_buffer_set: { Result = CSz("set"); } break; + case type_work_queue_entry_copy_buffer_ref: { Result = CSz("ref"); } break; + case type_work_queue_entry_init_asset: { Result = CSz("asset"); } break; + case type_work_queue_entry_rebuild_mesh: { Result = CSz("mesh"); } break; + case type_work_queue_entry_sim_particle_system: { Result = CSz("system"); } break; + case type_work_queue_entry__bonsai_render_command: { Result = CSz("bonsai_render_command"); } break; + case type_work_queue_entry_async_function_call: { Result = CSz("call"); } break; + case type_work_queue_entry__align_to_cache_line_helper: { Result = CSz("align_to_cache_line_helper"); } break; + + + + } + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ + return Result; +} + +link_internal counted_string +ToString(work_queue_entry_type Type) +{ + Assert(IsValid(Type)); + + counted_string Result = {}; + switch (Type) + { + case type_work_queue_entry_noop: { Result = CSz("type_work_queue_entry_noop"); } break; + case type_work_queue_entry_init_world_chunk: { Result = CSz("type_work_queue_entry_init_world_chunk"); } break; + case type_work_queue_entry_finalize_noise_values: { Result = CSz("type_work_queue_entry_finalize_noise_values"); } break; + case type_work_queue_entry_build_chunk_mesh: { Result = CSz("type_work_queue_entry_build_chunk_mesh"); } break; + case type_work_queue_entry_copy_buffer_set: { Result = CSz("type_work_queue_entry_copy_buffer_set"); } break; + case type_work_queue_entry_copy_buffer_ref: { Result = CSz("type_work_queue_entry_copy_buffer_ref"); } break; + case type_work_queue_entry_init_asset: { Result = CSz("type_work_queue_entry_init_asset"); } break; + case type_work_queue_entry_rebuild_mesh: { Result = CSz("type_work_queue_entry_rebuild_mesh"); } break; + case type_work_queue_entry_sim_particle_system: { Result = CSz("type_work_queue_entry_sim_particle_system"); } break; + case type_work_queue_entry__bonsai_render_command: { Result = CSz("type_work_queue_entry__bonsai_render_command"); } break; + case type_work_queue_entry_async_function_call: { Result = CSz("type_work_queue_entry_async_function_call"); } break; + case type_work_queue_entry__align_to_cache_line_helper: { Result = CSz("type_work_queue_entry__align_to_cache_line_helper"); } break; + + + + } + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ + return Result; +} + +link_internal work_queue_entry_type +WorkQueueEntryType(counted_string S) +{ + work_queue_entry_type Result = {}; + + if (StringsMatch(S, CSz("type_work_queue_entry_noop"))) { return type_work_queue_entry_noop; } + if (StringsMatch(S, CSz("type_work_queue_entry_init_world_chunk"))) { return type_work_queue_entry_init_world_chunk; } + if (StringsMatch(S, CSz("type_work_queue_entry_finalize_noise_values"))) { return type_work_queue_entry_finalize_noise_values; } + if (StringsMatch(S, CSz("type_work_queue_entry_build_chunk_mesh"))) { return type_work_queue_entry_build_chunk_mesh; } + if (StringsMatch(S, CSz("type_work_queue_entry_copy_buffer_set"))) { return type_work_queue_entry_copy_buffer_set; } + if (StringsMatch(S, CSz("type_work_queue_entry_copy_buffer_ref"))) { return type_work_queue_entry_copy_buffer_ref; } + if (StringsMatch(S, CSz("type_work_queue_entry_init_asset"))) { return type_work_queue_entry_init_asset; } + if (StringsMatch(S, CSz("type_work_queue_entry_rebuild_mesh"))) { return type_work_queue_entry_rebuild_mesh; } + if (StringsMatch(S, CSz("type_work_queue_entry_sim_particle_system"))) { return type_work_queue_entry_sim_particle_system; } + if (StringsMatch(S, CSz("type_work_queue_entry__bonsai_render_command"))) { return type_work_queue_entry__bonsai_render_command; } + if (StringsMatch(S, CSz("type_work_queue_entry_async_function_call"))) { return type_work_queue_entry_async_function_call; } + if (StringsMatch(S, CSz("type_work_queue_entry__align_to_cache_line_helper"))) { return type_work_queue_entry__align_to_cache_line_helper; } + + + return Result; +} + + diff --git a/generated/string_and_value_tables_asset_type.h b/generated/string_and_value_tables_asset_type.h index 18ac5d62e..29645f445 100644 --- a/generated/string_and_value_tables_asset_type.h +++ b/generated/string_and_value_tables_asset_type.h @@ -1,34 +1,58 @@ -// src/engine/editor.cpp:308:0 +// external/bonsai_stdlib/src/poof_functions.h:2049:0 +link_internal b32 +IsValid(asset_type Value) +{ + b32 Result = False; + switch (Value) + { + case AssetType_Undefined: + case AssetType_Models: + case AssetType_WorldChunk: + + { + Result = True; + } + } + return Result; +} + + link_internal counted_string ToStringPrefixless(asset_type Type) { + Assert(IsValid(Type)); counted_string Result = {}; + switch (Type) { - case AssetType_Undefined: { Result = CSz("Undefined"); } break; + 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); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } link_internal counted_string ToString(asset_type Type) { + Assert(IsValid(Type)); + counted_string Result = {}; switch (Type) { - case AssetType_Undefined: { Result = CSz("AssetType_Undefined"); } break; + 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); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } @@ -37,10 +61,11 @@ AssetType(counted_string S) { asset_type Result = {}; - if (StringsMatch(S, CSz("AssetType_Undefined"))) { return AssetType_Undefined; } + 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_bitfield_enum.h b/generated/string_and_value_tables_bitfield_enum.h new file mode 100644 index 000000000..d24530fbe --- /dev/null +++ b/generated/string_and_value_tables_bitfield_enum.h @@ -0,0 +1,117 @@ +// external/bonsai_stdlib/src/poof_functions.h:2049:0 +link_internal b32 +IsValid(bitfield_enum Value) +{ + b32 Result = False; + switch (Value) + { + case BitfieldEnum_Foo: + case BitfieldEnum_Bar: + case BitfieldEnum_Baz: + + { + Result = True; + } + } + return Result; +} + + + +link_internal counted_string +ToStringPrefixless(bitfield_enum Type) +{ + Assert(IsValid(Type)); + counted_string Result = {}; + + switch (Type) + { + case BitfieldEnum_Foo: { Result = CSz("Foo"); } break; + case BitfieldEnum_Bar: { Result = CSz("Bar"); } break; + case BitfieldEnum_Baz: { Result = CSz("Baz"); } break; + + + // TODO(Jesse): This is pretty barf and we could do it in a single allocation, + // but the metaprogram might have to be a bit fancier.. + default: + { + u32 CurrentFlags = u32(Type); + + u32 BitsSet = CountBitsSet_Kernighan(CurrentFlags); + switch(BitsSet) + { + case 0: // We likely passed 0 into this function, and the enum didn't have a 0 value + case 1: // The value we passed in was outside the range of the valid enum values + { + Result = FSz("(invalid value (%d))", CurrentFlags); + } break; + + default: + { + u32 FirstValue = UnsetLeastSignificantSetBit(&CurrentFlags); + Result = ToStringPrefixless(bitfield_enum(FirstValue)); + + while (CurrentFlags) + { + u32 Value = UnsetLeastSignificantSetBit(&CurrentFlags); + cs Next = ToStringPrefixless(bitfield_enum(Value)); + Result = FSz("%S | %S", Result, Next); + } + } break; + } + } break; + + } + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ + return Result; +} + +link_internal counted_string +ToString(bitfield_enum Type) +{ + Assert(IsValid(Type)); + + counted_string Result = {}; + switch (Type) + { + case BitfieldEnum_Foo: { Result = CSz("BitfieldEnum_Foo"); } break; + case BitfieldEnum_Bar: { Result = CSz("BitfieldEnum_Bar"); } break; + case BitfieldEnum_Baz: { Result = CSz("BitfieldEnum_Baz"); } break; + + + // TODO(Jesse): This is pretty barf and we could do it in a single allocation, + // but the metaprogram might have to be a bit fancier.. + default: + { + u32 CurrentFlags = u32(Type); + + u32 FirstValue = UnsetLeastSignificantSetBit(&CurrentFlags); + Result = ToString(bitfield_enum(FirstValue)); + + while (CurrentFlags) + { + u32 Value = UnsetLeastSignificantSetBit(&CurrentFlags); + cs Next = ToString(bitfield_enum(Value)); + Result = FSz("%S | %S", Result, Next); + } + } break; + + } + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ + return Result; +} + +link_internal bitfield_enum +BitfieldEnum(counted_string S) +{ + bitfield_enum Result = {}; + + if (StringsMatch(S, CSz("BitfieldEnum_Foo"))) { return BitfieldEnum_Foo; } + if (StringsMatch(S, CSz("BitfieldEnum_Bar"))) { return BitfieldEnum_Bar; } + if (StringsMatch(S, CSz("BitfieldEnum_Baz"))) { return BitfieldEnum_Baz; } + + + return Result; +} + + diff --git a/generated/string_and_value_tables_bitmap_compression_type.h b/generated/string_and_value_tables_bitmap_compression_type.h index f6baed806..a3a8c5358 100644 --- a/generated/string_and_value_tables_bitmap_compression_type.h +++ b/generated/string_and_value_tables_bitmap_compression_type.h @@ -1,12 +1,39 @@ -// external/bonsai_stdlib/src/bitmap.cpp:76:0 +// external/bonsai_stdlib/src/poof_functions.h:2049:0 +link_internal b32 +IsValid(bitmap_compression_type Value) +{ + b32 Result = False; + switch (Value) + { + case BitmapCompressionType_RGB: + case BitmapCompressionType_RLE8: + case BitmapCompressionType_RLE4: + case BitmapCompressionType_BITFIELDS: + case BitmapCompressionType_JPEG: + case BitmapCompressionType_PNG: + case BitmapCompressionType_ALPHABITFIELDS: + case BitmapCompressionType_CMYK: + case BitmapCompressionType_CMYKRLE8: + case BitmapCompressionType_CMYKRLE4: + + { + Result = True; + } + } + return Result; +} + + link_internal counted_string ToStringPrefixless(bitmap_compression_type Type) { + Assert(IsValid(Type)); counted_string Result = {}; + switch (Type) { - case BitmapCompressionType_RGB: { Result = CSz("RGB"); } break; + case BitmapCompressionType_RGB: { Result = CSz("RGB"); } break; case BitmapCompressionType_RLE8: { Result = CSz("RLE8"); } break; case BitmapCompressionType_RLE4: { Result = CSz("RLE4"); } break; case BitmapCompressionType_BITFIELDS: { Result = CSz("BITFIELDS"); } break; @@ -17,19 +44,22 @@ ToStringPrefixless(bitmap_compression_type Type) case BitmapCompressionType_CMYKRLE8: { Result = CSz("CMYKRLE8"); } break; case BitmapCompressionType_CMYKRLE4: { Result = CSz("CMYKRLE4"); } break; + } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } link_internal counted_string ToString(bitmap_compression_type Type) { + Assert(IsValid(Type)); + counted_string Result = {}; switch (Type) { - case BitmapCompressionType_RGB: { Result = CSz("BitmapCompressionType_RGB"); } break; + case BitmapCompressionType_RGB: { Result = CSz("BitmapCompressionType_RGB"); } break; case BitmapCompressionType_RLE8: { Result = CSz("BitmapCompressionType_RLE8"); } break; case BitmapCompressionType_RLE4: { Result = CSz("BitmapCompressionType_RLE4"); } break; case BitmapCompressionType_BITFIELDS: { Result = CSz("BitmapCompressionType_BITFIELDS"); } break; @@ -40,9 +70,10 @@ ToString(bitmap_compression_type Type) case BitmapCompressionType_CMYKRLE8: { Result = CSz("BitmapCompressionType_CMYKRLE8"); } break; case BitmapCompressionType_CMYKRLE4: { Result = CSz("BitmapCompressionType_CMYKRLE4"); } break; + } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } @@ -51,7 +82,7 @@ BitmapCompressionType(counted_string S) { bitmap_compression_type Result = {}; - if (StringsMatch(S, CSz("BitmapCompressionType_RGB"))) { return BitmapCompressionType_RGB; } + if (StringsMatch(S, CSz("BitmapCompressionType_RGB"))) { return BitmapCompressionType_RGB; } if (StringsMatch(S, CSz("BitmapCompressionType_RLE8"))) { return BitmapCompressionType_RLE8; } if (StringsMatch(S, CSz("BitmapCompressionType_RLE4"))) { return BitmapCompressionType_RLE4; } if (StringsMatch(S, CSz("BitmapCompressionType_BITFIELDS"))) { return BitmapCompressionType_BITFIELDS; } @@ -62,6 +93,7 @@ BitmapCompressionType(counted_string S) if (StringsMatch(S, CSz("BitmapCompressionType_CMYKRLE8"))) { return BitmapCompressionType_CMYKRLE8; } if (StringsMatch(S, CSz("BitmapCompressionType_CMYKRLE4"))) { return BitmapCompressionType_CMYKRLE4; } + return Result; } diff --git a/generated/string_and_value_tables_chunk_flag.h b/generated/string_and_value_tables_chunk_flag.h index eb56e1f0e..fda52e7bd 100644 --- a/generated/string_and_value_tables_chunk_flag.h +++ b/generated/string_and_value_tables_chunk_flag.h @@ -1,61 +1,94 @@ -// src/engine/world_chunk.h:85:0 +// external/bonsai_stdlib/src/poof_functions.h:2049:0 +link_internal b32 +IsValid(chunk_flag Value) +{ + b32 Result = False; + switch (Value) + { + case Chunk_Uninitialized: + case Chunk_Queued: + case Chunk_VoxelsInitialized: + case Chunk_Garbage: + case Chunk_Deallocate: + case Chunk_Freelist: + + { + Result = True; + } + } + return Result; +} + + link_internal counted_string ToStringPrefixless(chunk_flag Type) { + Assert(IsValid(Type)); counted_string Result = {}; + switch (Type) { - case Chunk_Uninitialized: { Result = CSz("Uninitialized"); } break; + case Chunk_Uninitialized: { Result = CSz("Uninitialized"); } break; case Chunk_Queued: { Result = CSz("Queued"); } break; case Chunk_VoxelsInitialized: { Result = CSz("VoxelsInitialized"); } break; case Chunk_Garbage: { Result = CSz("Garbage"); } break; case Chunk_Deallocate: { Result = CSz("Deallocate"); } break; case Chunk_Freelist: { Result = CSz("Freelist"); } break; - // TODO(Jesse): This is pretty barf and we could do it in a single allocation, + + // TODO(Jesse): This is pretty barf and we could do it in a single allocation, // but the metaprogram might have to be a bit fancier.. default: { u32 CurrentFlags = u32(Type); - if (CountBitsSet_Kernighan(CurrentFlags) == 1) + u32 BitsSet = CountBitsSet_Kernighan(CurrentFlags); + switch(BitsSet) { - Result = FSz("(invalid value for chunk_flag (%d))", CurrentFlags); - } - else - { - u32 FirstValue = UnsetLeastSignificantSetBit(&CurrentFlags); - Result = ToStringPrefixless(chunk_flag(FirstValue)); + case 0: // We likely passed 0 into this function, and the enum didn't have a 0 value + case 1: // The value we passed in was outside the range of the valid enum values + { + Result = FSz("(invalid value (%d))", CurrentFlags); + } break; - while (CurrentFlags) + default: { - u32 Value = UnsetLeastSignificantSetBit(&CurrentFlags); - cs Next = ToStringPrefixless(chunk_flag(Value)); - Result = FSz("%S | %S", Result, Next); - } + u32 FirstValue = UnsetLeastSignificantSetBit(&CurrentFlags); + Result = ToStringPrefixless(chunk_flag(FirstValue)); + + while (CurrentFlags) + { + u32 Value = UnsetLeastSignificantSetBit(&CurrentFlags); + cs Next = ToStringPrefixless(chunk_flag(Value)); + Result = FSz("%S | %S", Result, Next); + } + } break; } } break; } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } link_internal counted_string ToString(chunk_flag Type) { + Assert(IsValid(Type)); + counted_string Result = {}; switch (Type) { - case Chunk_Uninitialized: { Result = CSz("Chunk_Uninitialized"); } break; + case Chunk_Uninitialized: { Result = CSz("Chunk_Uninitialized"); } break; case Chunk_Queued: { Result = CSz("Chunk_Queued"); } break; case Chunk_VoxelsInitialized: { Result = CSz("Chunk_VoxelsInitialized"); } break; case Chunk_Garbage: { Result = CSz("Chunk_Garbage"); } break; case Chunk_Deallocate: { Result = CSz("Chunk_Deallocate"); } break; case Chunk_Freelist: { Result = CSz("Chunk_Freelist"); } break; - // TODO(Jesse): This is pretty barf and we could do it in a single allocation, + + // TODO(Jesse): This is pretty barf and we could do it in a single allocation, // but the metaprogram might have to be a bit fancier.. default: { @@ -73,7 +106,7 @@ ToString(chunk_flag Type) } break; } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } @@ -82,13 +115,14 @@ ChunkFlag(counted_string S) { chunk_flag Result = {}; - if (StringsMatch(S, CSz("Chunk_Uninitialized"))) { return Chunk_Uninitialized; } + if (StringsMatch(S, CSz("Chunk_Uninitialized"))) { return Chunk_Uninitialized; } if (StringsMatch(S, CSz("Chunk_Queued"))) { return Chunk_Queued; } if (StringsMatch(S, CSz("Chunk_VoxelsInitialized"))) { return Chunk_VoxelsInitialized; } if (StringsMatch(S, CSz("Chunk_Garbage"))) { return Chunk_Garbage; } if (StringsMatch(S, CSz("Chunk_Deallocate"))) { return Chunk_Deallocate; } if (StringsMatch(S, CSz("Chunk_Freelist"))) { return Chunk_Freelist; } + return Result; } diff --git a/generated/string_and_value_tables_data_type.h b/generated/string_and_value_tables_data_type.h index 6cce13062..3dd482e13 100644 --- a/generated/string_and_value_tables_data_type.h +++ b/generated/string_and_value_tables_data_type.h @@ -1,34 +1,58 @@ -// src/engine/editor.h:504:0 +// external/bonsai_stdlib/src/poof_functions.h:2049:0 +link_internal b32 +IsValid(data_type Value) +{ + b32 Result = False; + switch (Value) + { + case DataType_Undefinded: + case DataType_v3: + case DataType_v3_u8: + + { + Result = True; + } + } + return Result; +} + + link_internal counted_string ToStringPrefixless(data_type Type) { + Assert(IsValid(Type)); counted_string Result = {}; + switch (Type) { - case DataType_Undefinded: { Result = CSz("Undefinded"); } break; + 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); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } link_internal counted_string ToString(data_type Type) { + Assert(IsValid(Type)); + counted_string Result = {}; switch (Type) { - case DataType_Undefinded: { Result = CSz("DataType_Undefinded"); } break; + 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); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } @@ -37,10 +61,11 @@ DataType(counted_string S) { data_type Result = {}; - if (StringsMatch(S, CSz("DataType_Undefinded"))) { return DataType_Undefinded; } + 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 64a9f3206..27f806d4a 100644 --- a/generated/string_and_value_tables_engine_debug_view_mode.h +++ b/generated/string_and_value_tables_engine_debug_view_mode.h @@ -1,12 +1,37 @@ -// src/engine/editor.cpp:174:0 +// external/bonsai_stdlib/src/poof_functions.h:2049:0 +link_internal b32 +IsValid(engine_debug_view_mode Value) +{ + b32 Result = False; + switch (Value) + { + case EngineDebugViewMode_Level: + case EngineDebugViewMode_WorldEdit: + case EngineDebugViewMode_Entities: + case EngineDebugViewMode_Assets: + case EngineDebugViewMode_WorldChunks: + case EngineDebugViewMode_Textures: + case EngineDebugViewMode_RenderSettings: + case EngineDebugViewMode_EngineDebug: + + { + Result = True; + } + } + return Result; +} + + link_internal counted_string ToStringPrefixless(engine_debug_view_mode Type) { + Assert(IsValid(Type)); counted_string Result = {}; + switch (Type) { - case EngineDebugViewMode_Level: { Result = CSz("Level"); } break; + case EngineDebugViewMode_Level: { Result = CSz("Level"); } break; case EngineDebugViewMode_WorldEdit: { Result = CSz("WorldEdit"); } break; case EngineDebugViewMode_Entities: { Result = CSz("Entities"); } break; case EngineDebugViewMode_Assets: { Result = CSz("Assets"); } break; @@ -15,42 +40,51 @@ ToStringPrefixless(engine_debug_view_mode Type) case EngineDebugViewMode_RenderSettings: { Result = CSz("RenderSettings"); } break; case EngineDebugViewMode_EngineDebug: { Result = CSz("EngineDebug"); } break; - // TODO(Jesse): This is pretty barf and we could do it in a single allocation, + + // TODO(Jesse): This is pretty barf and we could do it in a single allocation, // but the metaprogram might have to be a bit fancier.. default: { u32 CurrentFlags = u32(Type); - if (CountBitsSet_Kernighan(CurrentFlags) == 1) + u32 BitsSet = CountBitsSet_Kernighan(CurrentFlags); + switch(BitsSet) { - Result = FSz("(invalid value for engine_debug_view_mode (%d))", CurrentFlags); - } - else - { - u32 FirstValue = UnsetLeastSignificantSetBit(&CurrentFlags); - Result = ToStringPrefixless(engine_debug_view_mode(FirstValue)); + case 0: // We likely passed 0 into this function, and the enum didn't have a 0 value + case 1: // The value we passed in was outside the range of the valid enum values + { + Result = FSz("(invalid value (%d))", CurrentFlags); + } break; - while (CurrentFlags) + default: { - u32 Value = UnsetLeastSignificantSetBit(&CurrentFlags); - cs Next = ToStringPrefixless(engine_debug_view_mode(Value)); - Result = FSz("%S | %S", Result, Next); - } + u32 FirstValue = UnsetLeastSignificantSetBit(&CurrentFlags); + Result = ToStringPrefixless(engine_debug_view_mode(FirstValue)); + + while (CurrentFlags) + { + u32 Value = UnsetLeastSignificantSetBit(&CurrentFlags); + cs Next = ToStringPrefixless(engine_debug_view_mode(Value)); + Result = FSz("%S | %S", Result, Next); + } + } break; } } break; } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } link_internal counted_string ToString(engine_debug_view_mode Type) { + Assert(IsValid(Type)); + counted_string Result = {}; switch (Type) { - case EngineDebugViewMode_Level: { Result = CSz("EngineDebugViewMode_Level"); } break; + case EngineDebugViewMode_Level: { Result = CSz("EngineDebugViewMode_Level"); } break; case EngineDebugViewMode_WorldEdit: { Result = CSz("EngineDebugViewMode_WorldEdit"); } break; case EngineDebugViewMode_Entities: { Result = CSz("EngineDebugViewMode_Entities"); } break; case EngineDebugViewMode_Assets: { Result = CSz("EngineDebugViewMode_Assets"); } break; @@ -59,7 +93,8 @@ ToString(engine_debug_view_mode Type) case EngineDebugViewMode_RenderSettings: { Result = CSz("EngineDebugViewMode_RenderSettings"); } break; case EngineDebugViewMode_EngineDebug: { Result = CSz("EngineDebugViewMode_EngineDebug"); } break; - // TODO(Jesse): This is pretty barf and we could do it in a single allocation, + + // TODO(Jesse): This is pretty barf and we could do it in a single allocation, // but the metaprogram might have to be a bit fancier.. default: { @@ -77,7 +112,7 @@ ToString(engine_debug_view_mode Type) } break; } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } @@ -86,7 +121,7 @@ EngineDebugViewMode(counted_string S) { engine_debug_view_mode Result = {}; - if (StringsMatch(S, CSz("EngineDebugViewMode_Level"))) { return EngineDebugViewMode_Level; } + if (StringsMatch(S, CSz("EngineDebugViewMode_Level"))) { return EngineDebugViewMode_Level; } if (StringsMatch(S, CSz("EngineDebugViewMode_WorldEdit"))) { return EngineDebugViewMode_WorldEdit; } if (StringsMatch(S, CSz("EngineDebugViewMode_Entities"))) { return EngineDebugViewMode_Entities; } if (StringsMatch(S, CSz("EngineDebugViewMode_Assets"))) { return EngineDebugViewMode_Assets; } @@ -95,6 +130,7 @@ EngineDebugViewMode(counted_string S) if (StringsMatch(S, CSz("EngineDebugViewMode_RenderSettings"))) { return EngineDebugViewMode_RenderSettings; } if (StringsMatch(S, CSz("EngineDebugViewMode_EngineDebug"))) { return EngineDebugViewMode_EngineDebug; } + return Result; } diff --git a/generated/string_and_value_tables_enum_brush_layer_type.h b/generated/string_and_value_tables_enum_brush_layer_type.h new file mode 100644 index 000000000..7b79483d8 --- /dev/null +++ b/generated/string_and_value_tables_enum_brush_layer_type.h @@ -0,0 +1,68 @@ +// external/bonsai_stdlib/src/poof_functions.h:2049:0 +link_internal b32 +IsValid(brush_layer_type Value) +{ + b32 Result = False; + switch (Value) + { + case BrushLayerType_Noise: + case BrushLayerType_Shape: + + { + Result = True; + } + } + return Result; +} + + + +link_internal counted_string +ToStringPrefixless(brush_layer_type Type) +{ + Assert(IsValid(Type)); + counted_string Result = {}; + + switch (Type) + { + case BrushLayerType_Noise: { Result = CSz("Noise"); } break; + case BrushLayerType_Shape: { Result = CSz("Shape"); } break; + + + + } + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ + return Result; +} + +link_internal counted_string +ToString(brush_layer_type Type) +{ + Assert(IsValid(Type)); + + counted_string Result = {}; + switch (Type) + { + case BrushLayerType_Noise: { Result = CSz("BrushLayerType_Noise"); } break; + case BrushLayerType_Shape: { Result = CSz("BrushLayerType_Shape"); } break; + + + + } + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ + return Result; +} + +link_internal brush_layer_type +BrushLayerType(counted_string S) +{ + brush_layer_type Result = {}; + + if (StringsMatch(S, CSz("BrushLayerType_Noise"))) { return BrushLayerType_Noise; } + if (StringsMatch(S, CSz("BrushLayerType_Shape"))) { return BrushLayerType_Shape; } + + + return Result; +} + + diff --git a/generated/string_and_value_tables_file_traversal_node.h b/generated/string_and_value_tables_file_traversal_node.h index c83a61396..d3923926c 100644 --- a/generated/string_and_value_tables_file_traversal_node.h +++ b/generated/string_and_value_tables_file_traversal_node.h @@ -1,34 +1,58 @@ -// src/engine/editor.cpp:168:0 +// external/bonsai_stdlib/src/poof_functions.h:2049:0 +link_internal b32 +IsValid(file_traversal_type Value) +{ + b32 Result = False; + switch (Value) + { + case FileTraversalType_None: + case FileTraversalType_Dir: + case FileTraversalType_File: + + { + Result = True; + } + } + return Result; +} + + link_internal counted_string ToStringPrefixless(file_traversal_type Type) { + Assert(IsValid(Type)); counted_string Result = {}; + switch (Type) { - case FileTraversalType_None: { Result = CSz("None"); } break; + case FileTraversalType_None: { Result = CSz("None"); } break; case FileTraversalType_Dir: { Result = CSz("Dir"); } break; case FileTraversalType_File: { Result = CSz("File"); } break; + } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } link_internal counted_string ToString(file_traversal_type Type) { + Assert(IsValid(Type)); + counted_string Result = {}; switch (Type) { - case FileTraversalType_None: { Result = CSz("FileTraversalType_None"); } break; + case FileTraversalType_None: { Result = CSz("FileTraversalType_None"); } break; case FileTraversalType_Dir: { Result = CSz("FileTraversalType_Dir"); } break; case FileTraversalType_File: { Result = CSz("FileTraversalType_File"); } break; + } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } @@ -37,10 +61,11 @@ FileTraversalType(counted_string S) { file_traversal_type Result = {}; - if (StringsMatch(S, CSz("FileTraversalType_None"))) { return FileTraversalType_None; } + if (StringsMatch(S, CSz("FileTraversalType_None"))) { return FileTraversalType_None; } if (StringsMatch(S, CSz("FileTraversalType_Dir"))) { return FileTraversalType_Dir; } if (StringsMatch(S, CSz("FileTraversalType_File"))) { return FileTraversalType_File; } + return Result; } diff --git a/generated/string_and_value_tables_lJfyCh3Y.h b/generated/string_and_value_tables_lJfyCh3Y.h new file mode 100644 index 000000000..a3a4b3b6a --- /dev/null +++ b/generated/string_and_value_tables_lJfyCh3Y.h @@ -0,0 +1,72 @@ +// external/bonsai_stdlib/src/poof_functions.h:2049:0 +link_internal b32 +IsValid(async_function_call_type Value) +{ + b32 Result = False; + switch (Value) + { + case type_finalize_shit_and_fuckin_do_stuff_async_params: + case type_initialize_easing_function_visualizer_render_pass_async_params: + case type_compile_shader_pair_async_params: + + { + Result = True; + } + } + return Result; +} + + + +link_internal counted_string +ToStringPrefixless(async_function_call_type Type) +{ + Assert(IsValid(Type)); + counted_string Result = {}; + + switch (Type) + { + case type_finalize_shit_and_fuckin_do_stuff_async_params: { Result = CSz("params"); } break; + case type_initialize_easing_function_visualizer_render_pass_async_params: { Result = CSz("params"); } break; + case type_compile_shader_pair_async_params: { Result = CSz("params"); } break; + + + + } + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ + return Result; +} + +link_internal counted_string +ToString(async_function_call_type Type) +{ + Assert(IsValid(Type)); + + counted_string Result = {}; + switch (Type) + { + case type_finalize_shit_and_fuckin_do_stuff_async_params: { Result = CSz("type_finalize_shit_and_fuckin_do_stuff_async_params"); } break; + case type_initialize_easing_function_visualizer_render_pass_async_params: { Result = CSz("type_initialize_easing_function_visualizer_render_pass_async_params"); } break; + case type_compile_shader_pair_async_params: { Result = CSz("type_compile_shader_pair_async_params"); } break; + + + + } + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ + return Result; +} + +link_internal async_function_call_type +AsyncFunctionCallType(counted_string S) +{ + async_function_call_type Result = {}; + + if (StringsMatch(S, CSz("type_finalize_shit_and_fuckin_do_stuff_async_params"))) { return type_finalize_shit_and_fuckin_do_stuff_async_params; } + if (StringsMatch(S, CSz("type_initialize_easing_function_visualizer_render_pass_async_params"))) { return type_initialize_easing_function_visualizer_render_pass_async_params; } + if (StringsMatch(S, CSz("type_compile_shader_pair_async_params"))) { return type_compile_shader_pair_async_params; } + + + return Result; +} + + diff --git a/generated/string_and_value_tables_lighting_quality_setting.h b/generated/string_and_value_tables_lighting_quality_setting.h index 601362569..dbe41f5b2 100644 --- a/generated/string_and_value_tables_lighting_quality_setting.h +++ b/generated/string_and_value_tables_lighting_quality_setting.h @@ -1,36 +1,61 @@ -// src/engine/settings.h:30:0 +// external/bonsai_stdlib/src/poof_functions.h:2049:0 +link_internal b32 +IsValid(lighting_quality_setting Value) +{ + b32 Result = False; + switch (Value) + { + case LightingQualitySetting_High: + case LightingQualitySetting_Med: + case LightingQualitySetting_Low: + case LightingQualitySetting_Off: + + { + Result = True; + } + } + return Result; +} + + link_internal counted_string ToStringPrefixless(lighting_quality_setting Type) { + Assert(IsValid(Type)); counted_string Result = {}; + switch (Type) { - case LightingQualitySetting_High: { Result = CSz("High"); } break; + case LightingQualitySetting_High: { Result = CSz("High"); } break; case LightingQualitySetting_Med: { Result = CSz("Med"); } break; case LightingQualitySetting_Low: { Result = CSz("Low"); } break; case LightingQualitySetting_Off: { Result = CSz("Off"); } break; + } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } link_internal counted_string ToString(lighting_quality_setting Type) { + Assert(IsValid(Type)); + counted_string Result = {}; switch (Type) { - case LightingQualitySetting_High: { Result = CSz("LightingQualitySetting_High"); } break; + case LightingQualitySetting_High: { Result = CSz("LightingQualitySetting_High"); } break; case LightingQualitySetting_Med: { Result = CSz("LightingQualitySetting_Med"); } break; case LightingQualitySetting_Low: { Result = CSz("LightingQualitySetting_Low"); } break; case LightingQualitySetting_Off: { Result = CSz("LightingQualitySetting_Off"); } break; + } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } @@ -39,11 +64,12 @@ LightingQualitySetting(counted_string S) { lighting_quality_setting Result = {}; - if (StringsMatch(S, CSz("LightingQualitySetting_High"))) { return LightingQualitySetting_High; } + if (StringsMatch(S, CSz("LightingQualitySetting_High"))) { return LightingQualitySetting_High; } if (StringsMatch(S, CSz("LightingQualitySetting_Med"))) { return LightingQualitySetting_Med; } if (StringsMatch(S, CSz("LightingQualitySetting_Low"))) { return LightingQualitySetting_Low; } if (StringsMatch(S, CSz("LightingQualitySetting_Off"))) { return LightingQualitySetting_Off; } + return Result; } diff --git a/generated/string_and_value_tables_log_level.h b/generated/string_and_value_tables_log_level.h index 65cc10100..8756ed424 100644 --- a/generated/string_and_value_tables_log_level.h +++ b/generated/string_and_value_tables_log_level.h @@ -1,40 +1,67 @@ -// external/bonsai_stdlib/src/console_io.h:13:0 +// external/bonsai_stdlib/src/poof_functions.h:2049:0 +link_internal b32 +IsValid(log_level Value) +{ + b32 Result = False; + switch (Value) + { + case LogLevel_Undefined: + case LogLevel_Verbose: + case LogLevel_Debug: + case LogLevel_Info: + case LogLevel_Error: + case LogLevel_Shush: + + { + Result = True; + } + } + return Result; +} + + link_internal counted_string ToStringPrefixless(log_level Type) { + Assert(IsValid(Type)); counted_string Result = {}; + switch (Type) { - case LogLevel_Undefined: { Result = CSz("Undefined"); } break; + case LogLevel_Undefined: { Result = CSz("Undefined"); } break; case LogLevel_Verbose: { Result = CSz("Verbose"); } break; case LogLevel_Debug: { Result = CSz("Debug"); } break; case LogLevel_Info: { Result = CSz("Info"); } break; case LogLevel_Error: { Result = CSz("Error"); } break; case LogLevel_Shush: { Result = CSz("Shush"); } break; + } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } link_internal counted_string ToString(log_level Type) { + Assert(IsValid(Type)); + counted_string Result = {}; switch (Type) { - case LogLevel_Undefined: { Result = CSz("LogLevel_Undefined"); } break; + case LogLevel_Undefined: { Result = CSz("LogLevel_Undefined"); } break; case LogLevel_Verbose: { Result = CSz("LogLevel_Verbose"); } break; case LogLevel_Debug: { Result = CSz("LogLevel_Debug"); } break; case LogLevel_Info: { Result = CSz("LogLevel_Info"); } break; case LogLevel_Error: { Result = CSz("LogLevel_Error"); } break; case LogLevel_Shush: { Result = CSz("LogLevel_Shush"); } break; + } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } @@ -43,13 +70,14 @@ LogLevel(counted_string S) { log_level Result = {}; - if (StringsMatch(S, CSz("LogLevel_Undefined"))) { return LogLevel_Undefined; } + if (StringsMatch(S, CSz("LogLevel_Undefined"))) { return LogLevel_Undefined; } if (StringsMatch(S, CSz("LogLevel_Verbose"))) { return LogLevel_Verbose; } if (StringsMatch(S, CSz("LogLevel_Debug"))) { return LogLevel_Debug; } if (StringsMatch(S, CSz("LogLevel_Info"))) { return LogLevel_Info; } if (StringsMatch(S, CSz("LogLevel_Error"))) { return LogLevel_Error; } if (StringsMatch(S, CSz("LogLevel_Shush"))) { return LogLevel_Shush; } + return Result; } diff --git a/generated/string_and_value_tables_maybe_tag.h b/generated/string_and_value_tables_maybe_tag.h new file mode 100644 index 000000000..403323a4e --- /dev/null +++ b/generated/string_and_value_tables_maybe_tag.h @@ -0,0 +1,68 @@ +// external/bonsai_stdlib/src/poof_functions.h:2049:0 +link_internal b32 +IsValid(maybe_tag Value) +{ + b32 Result = False; + switch (Value) + { + case Maybe_No: + case Maybe_Yes: + + { + Result = True; + } + } + return Result; +} + + + +link_internal counted_string +ToStringPrefixless(maybe_tag Type) +{ + Assert(IsValid(Type)); + counted_string Result = {}; + + switch (Type) + { + case Maybe_No: { Result = CSz("No"); } break; + case Maybe_Yes: { Result = CSz("Yes"); } break; + + + + } + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ + return Result; +} + +link_internal counted_string +ToString(maybe_tag Type) +{ + Assert(IsValid(Type)); + + counted_string Result = {}; + switch (Type) + { + case Maybe_No: { Result = CSz("Maybe_No"); } break; + case Maybe_Yes: { Result = CSz("Maybe_Yes"); } break; + + + + } + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ + return Result; +} + +link_internal maybe_tag +MaybeTag(counted_string S) +{ + maybe_tag Result = {}; + + if (StringsMatch(S, CSz("Maybe_No"))) { return Maybe_No; } + if (StringsMatch(S, CSz("Maybe_Yes"))) { return Maybe_Yes; } + + + return Result; +} + + diff --git a/generated/string_and_value_tables_model_index.h b/generated/string_and_value_tables_model_index.h index 1227f5666..67b31943a 100644 --- a/generated/string_and_value_tables_model_index.h +++ b/generated/string_and_value_tables_model_index.h @@ -1,12 +1,68 @@ -// src/engine/model.h:55:0 +// external/bonsai_stdlib/src/poof_functions.h:2049:0 +link_internal b32 +IsValid(model_index Value) +{ + b32 Result = False; + switch (Value) + { + case ModelIndex_None: + case ModelIndex_Enemy_Skeleton_Axe: + case ModelIndex_Enemy_Skeleton_Sword: + case ModelIndex_Enemy_Skeleton_Lasher: + case ModelIndex_Enemy_Skeleton_Archer: + case ModelIndex_Enemy_Skeleton_Spear: + case ModelIndex_Enemy_Skeleton_AxeArmor: + case ModelIndex_Enemy_Skeleton_Hounds: + case ModelIndex_Enemy_Skeleton_Horserider: + case ModelIndex_Enemy_Skeleton_Horsebanner: + case ModelIndex_Enemy_Skeleton_Shaman: + case ModelIndex_Enemy_Skeleton_Champion: + case ModelIndex_Enemy_Skeleton_ChampionChampion: + case ModelIndex_Enemy_Skeleton_Concubiner: + case ModelIndex_Enemy_Skeleton_King: + case ModelIndex_Player_jp: + case ModelIndex_Player_bow: + case ModelIndex_Player_cat: + case ModelIndex_Player_fox: + case ModelIndex_Player_gumi: + case ModelIndex_Player_knight: + case ModelIndex_Player_man: + case ModelIndex_Player_mom: + case ModelIndex_Player_old: + case ModelIndex_Player_poem: + case ModelIndex_Player_rain: + case ModelIndex_Player_sasami: + case ModelIndex_Player_sol: + case ModelIndex_Player_sword: + case ModelIndex_Player_tale: + case ModelIndex_Player_tama: + case ModelIndex_Player_tsurugi: + case ModelIndex_Loot: + case ModelIndex_Projectile: + case ModelIndex_Proton: + case ModelIndex_Bitty0: + case ModelIndex_Bitty1: + case ModelIndex_Level: + case ModelIndex_Count: + + { + Result = True; + } + } + return Result; +} + + link_internal counted_string ToStringPrefixless(model_index Type) { + Assert(IsValid(Type)); counted_string Result = {}; + switch (Type) { - case ModelIndex_None: { Result = CSz("None"); } break; + case ModelIndex_None: { Result = CSz("None"); } break; case ModelIndex_Enemy_Skeleton_Axe: { Result = CSz("Axe"); } break; case ModelIndex_Enemy_Skeleton_Sword: { Result = CSz("Sword"); } break; case ModelIndex_Enemy_Skeleton_Lasher: { Result = CSz("Lasher"); } break; @@ -46,19 +102,22 @@ ToStringPrefixless(model_index Type) case ModelIndex_Level: { Result = CSz("Level"); } break; case ModelIndex_Count: { Result = CSz("Count"); } break; + } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } link_internal counted_string ToString(model_index Type) { + Assert(IsValid(Type)); + counted_string Result = {}; switch (Type) { - case ModelIndex_None: { Result = CSz("ModelIndex_None"); } break; + case ModelIndex_None: { Result = CSz("ModelIndex_None"); } break; case ModelIndex_Enemy_Skeleton_Axe: { Result = CSz("ModelIndex_Enemy_Skeleton_Axe"); } break; case ModelIndex_Enemy_Skeleton_Sword: { Result = CSz("ModelIndex_Enemy_Skeleton_Sword"); } break; case ModelIndex_Enemy_Skeleton_Lasher: { Result = CSz("ModelIndex_Enemy_Skeleton_Lasher"); } break; @@ -98,9 +157,10 @@ ToString(model_index Type) case ModelIndex_Level: { Result = CSz("ModelIndex_Level"); } break; case ModelIndex_Count: { Result = CSz("ModelIndex_Count"); } break; + } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } @@ -109,7 +169,7 @@ ModelIndex(counted_string S) { model_index Result = {}; - if (StringsMatch(S, CSz("ModelIndex_None"))) { return ModelIndex_None; } + if (StringsMatch(S, CSz("ModelIndex_None"))) { return ModelIndex_None; } if (StringsMatch(S, CSz("ModelIndex_Enemy_Skeleton_Axe"))) { return ModelIndex_Enemy_Skeleton_Axe; } if (StringsMatch(S, CSz("ModelIndex_Enemy_Skeleton_Sword"))) { return ModelIndex_Enemy_Skeleton_Sword; } if (StringsMatch(S, CSz("ModelIndex_Enemy_Skeleton_Lasher"))) { return ModelIndex_Enemy_Skeleton_Lasher; } @@ -149,6 +209,7 @@ ModelIndex(counted_string S) if (StringsMatch(S, CSz("ModelIndex_Level"))) { return ModelIndex_Level; } if (StringsMatch(S, CSz("ModelIndex_Count"))) { return ModelIndex_Count; } + return Result; } diff --git a/generated/string_and_value_tables_oeasGVdN.h b/generated/string_and_value_tables_oeasGVdN.h new file mode 100644 index 000000000..9cd39f48d --- /dev/null +++ b/generated/string_and_value_tables_oeasGVdN.h @@ -0,0 +1,148 @@ +// external/bonsai_stdlib/src/poof_functions.h:2049:0 +link_internal b32 +IsValid(work_queue_entry__bonsai_render_command_type Value) +{ + b32 Result = False; + switch (Value) + { + case type_work_queue_entry__bonsai_render_command_noop: + case type_bonsai_render_command_initialize_noise_buffer: + case type_bonsai_render_command_clear_all_framebuffers: + case type_bonsai_render_command_allocate_texture: + case type_bonsai_render_command_deallocate_texture: + case type_bonsai_render_command_allocate_handles: + case type_bonsai_render_command_deallocate_handles: + case type_bonsai_render_command_deallocate_world_chunk: + case type_bonsai_render_command_do_stuff: + case type_bonsai_render_command_allocate_and_map_gpu_element_buffer: + case type_bonsai_render_command_unmap_gpu_element_buffer: + case type_bonsai_render_command_unmap_and_deallocate_pbo: + case type_bonsai_render_command_setup_shader: + case type_bonsai_render_command_teardown_shader: + case type_bonsai_render_command_set_shader_uniform: + case type_bonsai_render_command_draw_world_chunk_draw_list: + case type_bonsai_render_command_draw_all_entities: + case type_bonsai_render_command_gl_timer_init: + case type_bonsai_render_command_gl_timer_start: + case type_bonsai_render_command_gl_timer_end: + case type_bonsai_render_command_gl_timer_read_value_and_histogram: + case type_bonsai_render_command_cancel_all_noise_readback_jobs: + + { + Result = True; + } + } + return Result; +} + + + +link_internal counted_string +ToStringPrefixless(work_queue_entry__bonsai_render_command_type Type) +{ + Assert(IsValid(Type)); + counted_string Result = {}; + + switch (Type) + { + case type_work_queue_entry__bonsai_render_command_noop: { Result = CSz("bonsai_render_command_noop"); } break; + case type_bonsai_render_command_initialize_noise_buffer: { Result = CSz("buffer"); } break; + case type_bonsai_render_command_clear_all_framebuffers: { Result = CSz("framebuffers"); } break; + case type_bonsai_render_command_allocate_texture: { Result = CSz("texture"); } break; + case type_bonsai_render_command_deallocate_texture: { Result = CSz("texture"); } break; + case type_bonsai_render_command_allocate_handles: { Result = CSz("handles"); } break; + case type_bonsai_render_command_deallocate_handles: { Result = CSz("handles"); } break; + case type_bonsai_render_command_deallocate_world_chunk: { Result = CSz("chunk"); } break; + case type_bonsai_render_command_do_stuff: { Result = CSz("stuff"); } break; + case type_bonsai_render_command_allocate_and_map_gpu_element_buffer: { Result = CSz("buffer"); } break; + case type_bonsai_render_command_unmap_gpu_element_buffer: { Result = CSz("buffer"); } break; + case type_bonsai_render_command_unmap_and_deallocate_pbo: { Result = CSz("pbo"); } break; + case type_bonsai_render_command_setup_shader: { Result = CSz("shader"); } break; + case type_bonsai_render_command_teardown_shader: { Result = CSz("shader"); } break; + case type_bonsai_render_command_set_shader_uniform: { Result = CSz("uniform"); } break; + case type_bonsai_render_command_draw_world_chunk_draw_list: { Result = CSz("list"); } break; + case type_bonsai_render_command_draw_all_entities: { Result = CSz("entities"); } break; + case type_bonsai_render_command_gl_timer_init: { Result = CSz("init"); } break; + case type_bonsai_render_command_gl_timer_start: { Result = CSz("start"); } break; + case type_bonsai_render_command_gl_timer_end: { Result = CSz("end"); } break; + case type_bonsai_render_command_gl_timer_read_value_and_histogram: { Result = CSz("histogram"); } break; + case type_bonsai_render_command_cancel_all_noise_readback_jobs: { Result = CSz("jobs"); } break; + + + + } + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ + return Result; +} + +link_internal counted_string +ToString(work_queue_entry__bonsai_render_command_type Type) +{ + Assert(IsValid(Type)); + + counted_string Result = {}; + switch (Type) + { + case type_work_queue_entry__bonsai_render_command_noop: { Result = CSz("type_work_queue_entry__bonsai_render_command_noop"); } break; + case type_bonsai_render_command_initialize_noise_buffer: { Result = CSz("type_bonsai_render_command_initialize_noise_buffer"); } break; + case type_bonsai_render_command_clear_all_framebuffers: { Result = CSz("type_bonsai_render_command_clear_all_framebuffers"); } break; + case type_bonsai_render_command_allocate_texture: { Result = CSz("type_bonsai_render_command_allocate_texture"); } break; + case type_bonsai_render_command_deallocate_texture: { Result = CSz("type_bonsai_render_command_deallocate_texture"); } break; + case type_bonsai_render_command_allocate_handles: { Result = CSz("type_bonsai_render_command_allocate_handles"); } break; + case type_bonsai_render_command_deallocate_handles: { Result = CSz("type_bonsai_render_command_deallocate_handles"); } break; + case type_bonsai_render_command_deallocate_world_chunk: { Result = CSz("type_bonsai_render_command_deallocate_world_chunk"); } break; + case type_bonsai_render_command_do_stuff: { Result = CSz("type_bonsai_render_command_do_stuff"); } break; + case type_bonsai_render_command_allocate_and_map_gpu_element_buffer: { Result = CSz("type_bonsai_render_command_allocate_and_map_gpu_element_buffer"); } break; + case type_bonsai_render_command_unmap_gpu_element_buffer: { Result = CSz("type_bonsai_render_command_unmap_gpu_element_buffer"); } break; + case type_bonsai_render_command_unmap_and_deallocate_pbo: { Result = CSz("type_bonsai_render_command_unmap_and_deallocate_pbo"); } break; + case type_bonsai_render_command_setup_shader: { Result = CSz("type_bonsai_render_command_setup_shader"); } break; + case type_bonsai_render_command_teardown_shader: { Result = CSz("type_bonsai_render_command_teardown_shader"); } break; + case type_bonsai_render_command_set_shader_uniform: { Result = CSz("type_bonsai_render_command_set_shader_uniform"); } break; + case type_bonsai_render_command_draw_world_chunk_draw_list: { Result = CSz("type_bonsai_render_command_draw_world_chunk_draw_list"); } break; + case type_bonsai_render_command_draw_all_entities: { Result = CSz("type_bonsai_render_command_draw_all_entities"); } break; + case type_bonsai_render_command_gl_timer_init: { Result = CSz("type_bonsai_render_command_gl_timer_init"); } break; + case type_bonsai_render_command_gl_timer_start: { Result = CSz("type_bonsai_render_command_gl_timer_start"); } break; + case type_bonsai_render_command_gl_timer_end: { Result = CSz("type_bonsai_render_command_gl_timer_end"); } break; + case type_bonsai_render_command_gl_timer_read_value_and_histogram: { Result = CSz("type_bonsai_render_command_gl_timer_read_value_and_histogram"); } break; + case type_bonsai_render_command_cancel_all_noise_readback_jobs: { Result = CSz("type_bonsai_render_command_cancel_all_noise_readback_jobs"); } break; + + + + } + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ + return Result; +} + +link_internal work_queue_entry__bonsai_render_command_type +WorkQueueEntryBonsaiRenderCommandType(counted_string S) +{ + work_queue_entry__bonsai_render_command_type Result = {}; + + if (StringsMatch(S, CSz("type_work_queue_entry__bonsai_render_command_noop"))) { return type_work_queue_entry__bonsai_render_command_noop; } + if (StringsMatch(S, CSz("type_bonsai_render_command_initialize_noise_buffer"))) { return type_bonsai_render_command_initialize_noise_buffer; } + if (StringsMatch(S, CSz("type_bonsai_render_command_clear_all_framebuffers"))) { return type_bonsai_render_command_clear_all_framebuffers; } + if (StringsMatch(S, CSz("type_bonsai_render_command_allocate_texture"))) { return type_bonsai_render_command_allocate_texture; } + if (StringsMatch(S, CSz("type_bonsai_render_command_deallocate_texture"))) { return type_bonsai_render_command_deallocate_texture; } + if (StringsMatch(S, CSz("type_bonsai_render_command_allocate_handles"))) { return type_bonsai_render_command_allocate_handles; } + if (StringsMatch(S, CSz("type_bonsai_render_command_deallocate_handles"))) { return type_bonsai_render_command_deallocate_handles; } + if (StringsMatch(S, CSz("type_bonsai_render_command_deallocate_world_chunk"))) { return type_bonsai_render_command_deallocate_world_chunk; } + if (StringsMatch(S, CSz("type_bonsai_render_command_do_stuff"))) { return type_bonsai_render_command_do_stuff; } + if (StringsMatch(S, CSz("type_bonsai_render_command_allocate_and_map_gpu_element_buffer"))) { return type_bonsai_render_command_allocate_and_map_gpu_element_buffer; } + if (StringsMatch(S, CSz("type_bonsai_render_command_unmap_gpu_element_buffer"))) { return type_bonsai_render_command_unmap_gpu_element_buffer; } + if (StringsMatch(S, CSz("type_bonsai_render_command_unmap_and_deallocate_pbo"))) { return type_bonsai_render_command_unmap_and_deallocate_pbo; } + if (StringsMatch(S, CSz("type_bonsai_render_command_setup_shader"))) { return type_bonsai_render_command_setup_shader; } + if (StringsMatch(S, CSz("type_bonsai_render_command_teardown_shader"))) { return type_bonsai_render_command_teardown_shader; } + if (StringsMatch(S, CSz("type_bonsai_render_command_set_shader_uniform"))) { return type_bonsai_render_command_set_shader_uniform; } + if (StringsMatch(S, CSz("type_bonsai_render_command_draw_world_chunk_draw_list"))) { return type_bonsai_render_command_draw_world_chunk_draw_list; } + if (StringsMatch(S, CSz("type_bonsai_render_command_draw_all_entities"))) { return type_bonsai_render_command_draw_all_entities; } + if (StringsMatch(S, CSz("type_bonsai_render_command_gl_timer_init"))) { return type_bonsai_render_command_gl_timer_init; } + if (StringsMatch(S, CSz("type_bonsai_render_command_gl_timer_start"))) { return type_bonsai_render_command_gl_timer_start; } + if (StringsMatch(S, CSz("type_bonsai_render_command_gl_timer_end"))) { return type_bonsai_render_command_gl_timer_end; } + if (StringsMatch(S, CSz("type_bonsai_render_command_gl_timer_read_value_and_histogram"))) { return type_bonsai_render_command_gl_timer_read_value_and_histogram; } + if (StringsMatch(S, CSz("type_bonsai_render_command_cancel_all_noise_readback_jobs"))) { return type_bonsai_render_command_cancel_all_noise_readback_jobs; } + + + return Result; +} + + diff --git a/generated/string_and_value_tables_particle_spawn_type.h b/generated/string_and_value_tables_particle_spawn_type.h index 75f2be226..34c34b2e7 100644 --- a/generated/string_and_value_tables_particle_spawn_type.h +++ b/generated/string_and_value_tables_particle_spawn_type.h @@ -1,36 +1,61 @@ -// src/engine/editor.cpp:165:0 +// external/bonsai_stdlib/src/poof_functions.h:2049:0 +link_internal b32 +IsValid(particle_spawn_type Value) +{ + b32 Result = False; + switch (Value) + { + case ParticleSpawnType_None: + case ParticleSpawnType_Random: + case ParticleSpawnType_Expanding: + case ParticleSpawnType_Contracting: + + { + Result = True; + } + } + return Result; +} + + link_internal counted_string ToStringPrefixless(particle_spawn_type Type) { + Assert(IsValid(Type)); counted_string Result = {}; + switch (Type) { - case ParticleSpawnType_None: { Result = CSz("None"); } break; + case ParticleSpawnType_None: { Result = CSz("None"); } break; case ParticleSpawnType_Random: { Result = CSz("Random"); } break; case ParticleSpawnType_Expanding: { Result = CSz("Expanding"); } break; case ParticleSpawnType_Contracting: { Result = CSz("Contracting"); } break; + } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } link_internal counted_string ToString(particle_spawn_type Type) { + Assert(IsValid(Type)); + counted_string Result = {}; switch (Type) { - case ParticleSpawnType_None: { Result = CSz("ParticleSpawnType_None"); } break; + case ParticleSpawnType_None: { Result = CSz("ParticleSpawnType_None"); } break; case ParticleSpawnType_Random: { Result = CSz("ParticleSpawnType_Random"); } break; case ParticleSpawnType_Expanding: { Result = CSz("ParticleSpawnType_Expanding"); } break; case ParticleSpawnType_Contracting: { Result = CSz("ParticleSpawnType_Contracting"); } break; + } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } @@ -39,11 +64,12 @@ ParticleSpawnType(counted_string S) { particle_spawn_type Result = {}; - if (StringsMatch(S, CSz("ParticleSpawnType_None"))) { return ParticleSpawnType_None; } + if (StringsMatch(S, CSz("ParticleSpawnType_None"))) { return ParticleSpawnType_None; } if (StringsMatch(S, CSz("ParticleSpawnType_Random"))) { return ParticleSpawnType_Random; } if (StringsMatch(S, CSz("ParticleSpawnType_Expanding"))) { return ParticleSpawnType_Expanding; } if (StringsMatch(S, CSz("ParticleSpawnType_Contracting"))) { return ParticleSpawnType_Contracting; } + return Result; } diff --git a/generated/string_and_value_tables_radio_enum.h b/generated/string_and_value_tables_radio_enum.h new file mode 100644 index 000000000..470245131 --- /dev/null +++ b/generated/string_and_value_tables_radio_enum.h @@ -0,0 +1,72 @@ +// external/bonsai_stdlib/src/poof_functions.h:2049:0 +link_internal b32 +IsValid(radio_enum Value) +{ + b32 Result = False; + switch (Value) + { + case RadioEnum_Foo: + case RadioEnum_Bar: + case RadioEnum_Baz: + + { + Result = True; + } + } + return Result; +} + + + +link_internal counted_string +ToStringPrefixless(radio_enum Type) +{ + Assert(IsValid(Type)); + counted_string Result = {}; + + switch (Type) + { + case RadioEnum_Foo: { Result = CSz("Foo"); } break; + case RadioEnum_Bar: { Result = CSz("Bar"); } break; + case RadioEnum_Baz: { Result = CSz("Baz"); } break; + + + + } + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ + return Result; +} + +link_internal counted_string +ToString(radio_enum Type) +{ + Assert(IsValid(Type)); + + counted_string Result = {}; + switch (Type) + { + case RadioEnum_Foo: { Result = CSz("RadioEnum_Foo"); } break; + case RadioEnum_Bar: { Result = CSz("RadioEnum_Bar"); } break; + case RadioEnum_Baz: { Result = CSz("RadioEnum_Baz"); } break; + + + + } + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ + return Result; +} + +link_internal radio_enum +RadioEnum(counted_string S) +{ + radio_enum Result = {}; + + if (StringsMatch(S, CSz("RadioEnum_Foo"))) { return RadioEnum_Foo; } + if (StringsMatch(S, CSz("RadioEnum_Bar"))) { return RadioEnum_Bar; } + if (StringsMatch(S, CSz("RadioEnum_Baz"))) { return RadioEnum_Baz; } + + + return Result; +} + + diff --git a/generated/string_and_value_tables_resolution_setting.h b/generated/string_and_value_tables_resolution_setting.h index 55420c3b4..11777be30 100644 --- a/generated/string_and_value_tables_resolution_setting.h +++ b/generated/string_and_value_tables_resolution_setting.h @@ -1,34 +1,58 @@ -// src/engine/settings.h:26:0 +// external/bonsai_stdlib/src/poof_functions.h:2049:0 +link_internal b32 +IsValid(resolution_setting Value) +{ + b32 Result = False; + switch (Value) + { + case ResolutionSetting_4096x2160: + case ResolutionSetting_1920x1080: + case ResolutionSetting_1280x720: + + { + Result = True; + } + } + return Result; +} + + link_internal counted_string ToStringPrefixless(resolution_setting Type) { + Assert(IsValid(Type)); counted_string Result = {}; + switch (Type) { - case ResolutionSetting_4096x2160: { Result = CSz("4096x2160"); } break; + case ResolutionSetting_4096x2160: { Result = CSz("4096x2160"); } break; case ResolutionSetting_1920x1080: { Result = CSz("1920x1080"); } break; case ResolutionSetting_1280x720: { Result = CSz("1280x720"); } break; + } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } link_internal counted_string ToString(resolution_setting Type) { + Assert(IsValid(Type)); + counted_string Result = {}; switch (Type) { - case ResolutionSetting_4096x2160: { Result = CSz("ResolutionSetting_4096x2160"); } break; + case ResolutionSetting_4096x2160: { Result = CSz("ResolutionSetting_4096x2160"); } break; case ResolutionSetting_1920x1080: { Result = CSz("ResolutionSetting_1920x1080"); } break; case ResolutionSetting_1280x720: { Result = CSz("ResolutionSetting_1280x720"); } break; + } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } @@ -37,10 +61,11 @@ ResolutionSetting(counted_string S) { resolution_setting Result = {}; - if (StringsMatch(S, CSz("ResolutionSetting_4096x2160"))) { return ResolutionSetting_4096x2160; } + if (StringsMatch(S, CSz("ResolutionSetting_4096x2160"))) { return ResolutionSetting_4096x2160; } if (StringsMatch(S, CSz("ResolutionSetting_1920x1080"))) { return ResolutionSetting_1920x1080; } if (StringsMatch(S, CSz("ResolutionSetting_1280x720"))) { return ResolutionSetting_1280x720; } + return Result; } diff --git a/generated/string_and_value_tables_shader_language_setting.h b/generated/string_and_value_tables_shader_language_setting.h index f80569ca1..e17adbd59 100644 --- a/generated/string_and_value_tables_shader_language_setting.h +++ b/generated/string_and_value_tables_shader_language_setting.h @@ -1,32 +1,55 @@ -// src/engine/settings.h:32:0 +// external/bonsai_stdlib/src/poof_functions.h:2049:0 +link_internal b32 +IsValid(shader_language_setting Value) +{ + b32 Result = False; + switch (Value) + { + case ShaderLanguageSetting_330core: + case ShaderLanguageSetting_310es: + + { + Result = True; + } + } + return Result; +} + + link_internal counted_string ToStringPrefixless(shader_language_setting Type) { + Assert(IsValid(Type)); counted_string Result = {}; + switch (Type) { - case ShaderLanguageSetting_330core: { Result = CSz("330core"); } break; + case ShaderLanguageSetting_330core: { Result = CSz("330core"); } break; case ShaderLanguageSetting_310es: { Result = CSz("310es"); } break; + } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } link_internal counted_string ToString(shader_language_setting Type) { + Assert(IsValid(Type)); + counted_string Result = {}; switch (Type) { - case ShaderLanguageSetting_330core: { Result = CSz("ShaderLanguageSetting_330core"); } break; + case ShaderLanguageSetting_330core: { Result = CSz("ShaderLanguageSetting_330core"); } break; case ShaderLanguageSetting_310es: { Result = CSz("ShaderLanguageSetting_310es"); } break; + } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } @@ -35,9 +58,10 @@ ShaderLanguageSetting(counted_string S) { shader_language_setting Result = {}; - if (StringsMatch(S, CSz("ShaderLanguageSetting_330core"))) { return ShaderLanguageSetting_330core; } + if (StringsMatch(S, CSz("ShaderLanguageSetting_330core"))) { return ShaderLanguageSetting_330core; } if (StringsMatch(S, CSz("ShaderLanguageSetting_310es"))) { return ShaderLanguageSetting_310es; } + return Result; } diff --git a/generated/string_and_value_tables_shadow_quality_setting.h b/generated/string_and_value_tables_shadow_quality_setting.h index d14934fba..661a6aafb 100644 --- a/generated/string_and_value_tables_shadow_quality_setting.h +++ b/generated/string_and_value_tables_shadow_quality_setting.h @@ -1,36 +1,61 @@ -// src/engine/settings.h:28:0 +// external/bonsai_stdlib/src/poof_functions.h:2049:0 +link_internal b32 +IsValid(shadow_quality_setting Value) +{ + b32 Result = False; + switch (Value) + { + case ShadowQualitySetting_High: + case ShadowQualitySetting_Med: + case ShadowQualitySetting_Low: + case ShadowQualitySetting_Off: + + { + Result = True; + } + } + return Result; +} + + link_internal counted_string ToStringPrefixless(shadow_quality_setting Type) { + Assert(IsValid(Type)); counted_string Result = {}; + switch (Type) { - case ShadowQualitySetting_High: { Result = CSz("High"); } break; + case ShadowQualitySetting_High: { Result = CSz("High"); } break; case ShadowQualitySetting_Med: { Result = CSz("Med"); } break; case ShadowQualitySetting_Low: { Result = CSz("Low"); } break; case ShadowQualitySetting_Off: { Result = CSz("Off"); } break; + } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } link_internal counted_string ToString(shadow_quality_setting Type) { + Assert(IsValid(Type)); + counted_string Result = {}; switch (Type) { - case ShadowQualitySetting_High: { Result = CSz("ShadowQualitySetting_High"); } break; + case ShadowQualitySetting_High: { Result = CSz("ShadowQualitySetting_High"); } break; case ShadowQualitySetting_Med: { Result = CSz("ShadowQualitySetting_Med"); } break; case ShadowQualitySetting_Low: { Result = CSz("ShadowQualitySetting_Low"); } break; case ShadowQualitySetting_Off: { Result = CSz("ShadowQualitySetting_Off"); } break; + } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } @@ -39,11 +64,12 @@ ShadowQualitySetting(counted_string S) { shadow_quality_setting Result = {}; - if (StringsMatch(S, CSz("ShadowQualitySetting_High"))) { return ShadowQualitySetting_High; } + if (StringsMatch(S, CSz("ShadowQualitySetting_High"))) { return ShadowQualitySetting_High; } if (StringsMatch(S, CSz("ShadowQualitySetting_Med"))) { return ShadowQualitySetting_Med; } if (StringsMatch(S, CSz("ShadowQualitySetting_Low"))) { return ShadowQualitySetting_Low; } if (StringsMatch(S, CSz("ShadowQualitySetting_Off"))) { return ShadowQualitySetting_Off; } + return Result; } diff --git a/generated/string_and_value_tables_shape_axis.h b/generated/string_and_value_tables_shape_axis.h new file mode 100644 index 000000000..8ac6ffc9d --- /dev/null +++ b/generated/string_and_value_tables_shape_axis.h @@ -0,0 +1,92 @@ +// external/bonsai_stdlib/src/poof_functions.h:2049:0 +link_internal b32 +IsValid(shape_axis Value) +{ + b32 Result = False; + switch (Value) + { + case ShapeAxis_InferFromMajorAxis: + case ShapeAxis_PosX: + case ShapeAxis_NegX: + case ShapeAxis_PosY: + case ShapeAxis_NegY: + case ShapeAxis_PosZ: + case ShapeAxis_NegZ: + case ShapeAxis_Count: + + { + Result = True; + } + } + return Result; +} + + + +link_internal counted_string +ToStringPrefixless(shape_axis Type) +{ + Assert(IsValid(Type)); + counted_string Result = {}; + + switch (Type) + { + case ShapeAxis_InferFromMajorAxis: { Result = CSz("InferFromMajorAxis"); } break; + case ShapeAxis_PosX: { Result = CSz("PosX"); } break; + case ShapeAxis_NegX: { Result = CSz("NegX"); } break; + case ShapeAxis_PosY: { Result = CSz("PosY"); } break; + case ShapeAxis_NegY: { Result = CSz("NegY"); } break; + case ShapeAxis_PosZ: { Result = CSz("PosZ"); } break; + case ShapeAxis_NegZ: { Result = CSz("NegZ"); } break; + case ShapeAxis_Count: { Result = CSz("Count"); } break; + + + + } + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ + return Result; +} + +link_internal counted_string +ToString(shape_axis Type) +{ + Assert(IsValid(Type)); + + counted_string Result = {}; + switch (Type) + { + case ShapeAxis_InferFromMajorAxis: { Result = CSz("ShapeAxis_InferFromMajorAxis"); } break; + case ShapeAxis_PosX: { Result = CSz("ShapeAxis_PosX"); } break; + case ShapeAxis_NegX: { Result = CSz("ShapeAxis_NegX"); } break; + case ShapeAxis_PosY: { Result = CSz("ShapeAxis_PosY"); } break; + case ShapeAxis_NegY: { Result = CSz("ShapeAxis_NegY"); } break; + case ShapeAxis_PosZ: { Result = CSz("ShapeAxis_PosZ"); } break; + case ShapeAxis_NegZ: { Result = CSz("ShapeAxis_NegZ"); } break; + case ShapeAxis_Count: { Result = CSz("ShapeAxis_Count"); } break; + + + + } + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ + return Result; +} + +link_internal shape_axis +ShapeAxis(counted_string S) +{ + shape_axis Result = {}; + + if (StringsMatch(S, CSz("ShapeAxis_InferFromMajorAxis"))) { return ShapeAxis_InferFromMajorAxis; } + if (StringsMatch(S, CSz("ShapeAxis_PosX"))) { return ShapeAxis_PosX; } + if (StringsMatch(S, CSz("ShapeAxis_NegX"))) { return ShapeAxis_NegX; } + if (StringsMatch(S, CSz("ShapeAxis_PosY"))) { return ShapeAxis_PosY; } + if (StringsMatch(S, CSz("ShapeAxis_NegY"))) { return ShapeAxis_NegY; } + if (StringsMatch(S, CSz("ShapeAxis_PosZ"))) { return ShapeAxis_PosZ; } + if (StringsMatch(S, CSz("ShapeAxis_NegZ"))) { return ShapeAxis_NegZ; } + if (StringsMatch(S, CSz("ShapeAxis_Count"))) { return ShapeAxis_Count; } + + + return Result; +} + + diff --git a/generated/string_and_value_tables_shape_type.h b/generated/string_and_value_tables_shape_type.h index 60087d8c5..4b039a948 100644 --- a/generated/string_and_value_tables_shape_type.h +++ b/generated/string_and_value_tables_shape_type.h @@ -1,34 +1,67 @@ -// src/engine/editor.h:806:0 +// external/bonsai_stdlib/src/poof_functions.h:2049:0 +link_internal b32 +IsValid(shape_type Value) +{ + b32 Result = False; + switch (Value) + { + case ShapeType_Rect: + case ShapeType_Sphere: + case ShapeType_Line: + case ShapeType_Cylinder: + case ShapeType_Plane: + case ShapeType_Torus: + + { + Result = True; + } + } + return Result; +} + + link_internal counted_string ToStringPrefixless(shape_type Type) { + Assert(IsValid(Type)); counted_string Result = {}; + switch (Type) { - case ShapeType_None: { Result = CSz("None"); } break; + case ShapeType_Rect: { Result = CSz("Rect"); } break; case ShapeType_Sphere: { Result = CSz("Sphere"); } break; - case ShapeType_Rect: { Result = CSz("Rect"); } break; + case ShapeType_Line: { Result = CSz("Line"); } break; + case ShapeType_Cylinder: { Result = CSz("Cylinder"); } break; + case ShapeType_Plane: { Result = CSz("Plane"); } break; + case ShapeType_Torus: { Result = CSz("Torus"); } break; + } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } link_internal counted_string ToString(shape_type Type) { + Assert(IsValid(Type)); + counted_string Result = {}; switch (Type) { - case ShapeType_None: { Result = CSz("ShapeType_None"); } break; + case ShapeType_Rect: { Result = CSz("ShapeType_Rect"); } break; case ShapeType_Sphere: { Result = CSz("ShapeType_Sphere"); } break; - case ShapeType_Rect: { Result = CSz("ShapeType_Rect"); } break; + case ShapeType_Line: { Result = CSz("ShapeType_Line"); } break; + case ShapeType_Cylinder: { Result = CSz("ShapeType_Cylinder"); } break; + case ShapeType_Plane: { Result = CSz("ShapeType_Plane"); } break; + case ShapeType_Torus: { Result = CSz("ShapeType_Torus"); } break; + } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } @@ -37,9 +70,13 @@ ShapeType(counted_string S) { shape_type Result = {}; - if (StringsMatch(S, CSz("ShapeType_None"))) { return ShapeType_None; } + if (StringsMatch(S, CSz("ShapeType_Rect"))) { return ShapeType_Rect; } if (StringsMatch(S, CSz("ShapeType_Sphere"))) { return ShapeType_Sphere; } - if (StringsMatch(S, CSz("ShapeType_Rect"))) { return ShapeType_Rect; } + if (StringsMatch(S, CSz("ShapeType_Line"))) { return ShapeType_Line; } + if (StringsMatch(S, CSz("ShapeType_Cylinder"))) { return ShapeType_Cylinder; } + if (StringsMatch(S, CSz("ShapeType_Plane"))) { return ShapeType_Plane; } + if (StringsMatch(S, CSz("ShapeType_Torus"))) { return ShapeType_Torus; } + return Result; } diff --git a/generated/string_and_value_tables_terrain_gen_type.h b/generated/string_and_value_tables_terrain_gen_type.h deleted file mode 100644 index 6a5222023..000000000 --- a/generated/string_and_value_tables_terrain_gen_type.h +++ /dev/null @@ -1,86 +0,0 @@ -// examples/terrain_gen/game_types.h:26:0 - -link_internal counted_string -ToStringPrefixless(terrain_gen_type Type) -{ - counted_string Result = {}; - switch (Type) - { - case TerrainGenType_Flat: { Result = CSz("Flat"); } break; - case TerrainGenType_Checkerboard: { Result = CSz("Checkerboard"); } break; - case TerrainGenType_SinCos: { Result = CSz("SinCos"); } break; - case TerrainGenType_Voronoi: { Result = CSz("Voronoi"); } break; - case TerrainGenType_Perlin2D: { Result = CSz("Perlin2D"); } break; - case TerrainGenType_Perlin3D: { Result = CSz("Perlin3D"); } break; - case TerrainGenType_FBM2D: { Result = CSz("FBM2D"); } break; - case TerrainGenType_TerracedTerrain: { Result = CSz("TerracedTerrain"); } break; - case TerrainGenType_GrassyTerracedTerrain: { Result = CSz("GrassyTerracedTerrain"); } break; - case TerrainGenType_GrassyLargeTerracedTerrain: { Result = CSz("GrassyLargeTerracedTerrain"); } break; - case TerrainGenType_GrassyTerracedTerrain2: { Result = CSz("GrassyTerracedTerrain2"); } break; - case TerrainGenType_GrassyTerracedTerrain3: { Result = CSz("GrassyTerracedTerrain3"); } break; - case TerrainGenType_GrassyTerracedTerrain4: { Result = CSz("GrassyTerracedTerrain4"); } break; - case TerrainGenType_GrassyIsland: { Result = CSz("GrassyIsland"); } break; - case TerrainGenType_Hoodoo: { Result = CSz("Hoodoo"); } break; - case TerrainGenType_Warped: { Result = CSz("Warped"); } break; - - - } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ - return Result; -} - -link_internal counted_string -ToString(terrain_gen_type Type) -{ - counted_string Result = {}; - switch (Type) - { - case TerrainGenType_Flat: { Result = CSz("TerrainGenType_Flat"); } break; - case TerrainGenType_Checkerboard: { Result = CSz("TerrainGenType_Checkerboard"); } break; - case TerrainGenType_SinCos: { Result = CSz("TerrainGenType_SinCos"); } break; - case TerrainGenType_Voronoi: { Result = CSz("TerrainGenType_Voronoi"); } break; - case TerrainGenType_Perlin2D: { Result = CSz("TerrainGenType_Perlin2D"); } break; - case TerrainGenType_Perlin3D: { Result = CSz("TerrainGenType_Perlin3D"); } break; - case TerrainGenType_FBM2D: { Result = CSz("TerrainGenType_FBM2D"); } break; - case TerrainGenType_TerracedTerrain: { Result = CSz("TerrainGenType_TerracedTerrain"); } break; - case TerrainGenType_GrassyTerracedTerrain: { Result = CSz("TerrainGenType_GrassyTerracedTerrain"); } break; - case TerrainGenType_GrassyLargeTerracedTerrain: { Result = CSz("TerrainGenType_GrassyLargeTerracedTerrain"); } break; - case TerrainGenType_GrassyTerracedTerrain2: { Result = CSz("TerrainGenType_GrassyTerracedTerrain2"); } break; - case TerrainGenType_GrassyTerracedTerrain3: { Result = CSz("TerrainGenType_GrassyTerracedTerrain3"); } break; - case TerrainGenType_GrassyTerracedTerrain4: { Result = CSz("TerrainGenType_GrassyTerracedTerrain4"); } break; - case TerrainGenType_GrassyIsland: { Result = CSz("TerrainGenType_GrassyIsland"); } break; - case TerrainGenType_Hoodoo: { Result = CSz("TerrainGenType_Hoodoo"); } break; - case TerrainGenType_Warped: { Result = CSz("TerrainGenType_Warped"); } break; - - - } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ - return Result; -} - -link_internal terrain_gen_type -TerrainGenType(counted_string S) -{ - terrain_gen_type Result = {}; - - if (StringsMatch(S, CSz("TerrainGenType_Flat"))) { return TerrainGenType_Flat; } - if (StringsMatch(S, CSz("TerrainGenType_Checkerboard"))) { return TerrainGenType_Checkerboard; } - if (StringsMatch(S, CSz("TerrainGenType_SinCos"))) { return TerrainGenType_SinCos; } - if (StringsMatch(S, CSz("TerrainGenType_Voronoi"))) { return TerrainGenType_Voronoi; } - if (StringsMatch(S, CSz("TerrainGenType_Perlin2D"))) { return TerrainGenType_Perlin2D; } - if (StringsMatch(S, CSz("TerrainGenType_Perlin3D"))) { return TerrainGenType_Perlin3D; } - if (StringsMatch(S, CSz("TerrainGenType_FBM2D"))) { return TerrainGenType_FBM2D; } - if (StringsMatch(S, CSz("TerrainGenType_TerracedTerrain"))) { return TerrainGenType_TerracedTerrain; } - if (StringsMatch(S, CSz("TerrainGenType_GrassyTerracedTerrain"))) { return TerrainGenType_GrassyTerracedTerrain; } - if (StringsMatch(S, CSz("TerrainGenType_GrassyLargeTerracedTerrain"))) { return TerrainGenType_GrassyLargeTerracedTerrain; } - if (StringsMatch(S, CSz("TerrainGenType_GrassyTerracedTerrain2"))) { return TerrainGenType_GrassyTerracedTerrain2; } - if (StringsMatch(S, CSz("TerrainGenType_GrassyTerracedTerrain3"))) { return TerrainGenType_GrassyTerracedTerrain3; } - if (StringsMatch(S, CSz("TerrainGenType_GrassyTerracedTerrain4"))) { return TerrainGenType_GrassyTerracedTerrain4; } - if (StringsMatch(S, CSz("TerrainGenType_GrassyIsland"))) { return TerrainGenType_GrassyIsland; } - if (StringsMatch(S, CSz("TerrainGenType_Hoodoo"))) { return TerrainGenType_Hoodoo; } - if (StringsMatch(S, CSz("TerrainGenType_Warped"))) { return TerrainGenType_Warped; } - - return Result; -} - - diff --git a/generated/string_and_value_tables_test_enum.h b/generated/string_and_value_tables_test_enum.h new file mode 100644 index 000000000..4859a09d7 --- /dev/null +++ b/generated/string_and_value_tables_test_enum.h @@ -0,0 +1,72 @@ +// external/bonsai_stdlib/src/poof_functions.h:2049:0 +link_internal b32 +IsValid(test_enum Value) +{ + b32 Result = False; + switch (Value) + { + case TestEnum_Foo: + case TestEnum_Bar: + case TestEnum_Baz: + + { + Result = True; + } + } + return Result; +} + + + +link_internal counted_string +ToStringPrefixless(test_enum Type) +{ + Assert(IsValid(Type)); + counted_string Result = {}; + + switch (Type) + { + case TestEnum_Foo: { Result = CSz("Foo"); } break; + case TestEnum_Bar: { Result = CSz("Bar"); } break; + case TestEnum_Baz: { Result = CSz("Baz"); } break; + + + + } + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ + return Result; +} + +link_internal counted_string +ToString(test_enum Type) +{ + Assert(IsValid(Type)); + + counted_string Result = {}; + switch (Type) + { + case TestEnum_Foo: { Result = CSz("TestEnum_Foo"); } break; + case TestEnum_Bar: { Result = CSz("TestEnum_Bar"); } break; + case TestEnum_Baz: { Result = CSz("TestEnum_Baz"); } break; + + + + } + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ + return Result; +} + +link_internal test_enum +TestEnum(counted_string S) +{ + test_enum Result = {}; + + if (StringsMatch(S, CSz("TestEnum_Foo"))) { return TestEnum_Foo; } + if (StringsMatch(S, CSz("TestEnum_Bar"))) { return TestEnum_Bar; } + if (StringsMatch(S, CSz("TestEnum_Baz"))) { return TestEnum_Baz; } + + + return Result; +} + + diff --git a/generated/string_and_value_tables_texture_storage_format.h b/generated/string_and_value_tables_texture_storage_format.h index fd9624526..750e3efd0 100644 --- a/generated/string_and_value_tables_texture_storage_format.h +++ b/generated/string_and_value_tables_texture_storage_format.h @@ -1,13 +1,47 @@ -// external/bonsai_stdlib/src/to_string.cpp:62:0 +// external/bonsai_stdlib/src/poof_functions.h:2049:0 +link_internal b32 +IsValid(texture_storage_format Value) +{ + b32 Result = False; + switch (Value) + { + case TextureStorageFormat_Undefined: + case TextureStorageFormat_R16I: + case TextureStorageFormat_R16F: + case TextureStorageFormat_R32I: + case TextureStorageFormat_R32UI: + case TextureStorageFormat_R32F: + case TextureStorageFormat_RG16F: + case TextureStorageFormat_RG32F: + case TextureStorageFormat_RGB16F: + case TextureStorageFormat_RGB32F: + case TextureStorageFormat_RGBA8: + case TextureStorageFormat_RGBA16F: + case TextureStorageFormat_RGBA32F: + case TextureStorageFormat_Depth32: + + { + Result = True; + } + } + return Result; +} + + link_internal counted_string ToStringPrefixless(texture_storage_format Type) { + Assert(IsValid(Type)); counted_string Result = {}; + switch (Type) { - case TextureStorageFormat_Undefined: { Result = CSz("Undefined"); } break; + case TextureStorageFormat_Undefined: { Result = CSz("Undefined"); } break; + case TextureStorageFormat_R16I: { Result = CSz("R16I"); } break; case TextureStorageFormat_R16F: { Result = CSz("R16F"); } break; + case TextureStorageFormat_R32I: { Result = CSz("R32I"); } break; + case TextureStorageFormat_R32UI: { Result = CSz("R32UI"); } break; case TextureStorageFormat_R32F: { Result = CSz("R32F"); } break; case TextureStorageFormat_RG16F: { Result = CSz("RG16F"); } break; case TextureStorageFormat_RG32F: { Result = CSz("RG32F"); } break; @@ -18,20 +52,26 @@ ToStringPrefixless(texture_storage_format Type) case TextureStorageFormat_RGBA32F: { Result = CSz("RGBA32F"); } break; case TextureStorageFormat_Depth32: { Result = CSz("Depth32"); } break; + } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } link_internal counted_string ToString(texture_storage_format Type) { + Assert(IsValid(Type)); + counted_string Result = {}; switch (Type) { - case TextureStorageFormat_Undefined: { Result = CSz("TextureStorageFormat_Undefined"); } break; + case TextureStorageFormat_Undefined: { Result = CSz("TextureStorageFormat_Undefined"); } break; + case TextureStorageFormat_R16I: { Result = CSz("TextureStorageFormat_R16I"); } break; case TextureStorageFormat_R16F: { Result = CSz("TextureStorageFormat_R16F"); } break; + case TextureStorageFormat_R32I: { Result = CSz("TextureStorageFormat_R32I"); } break; + case TextureStorageFormat_R32UI: { Result = CSz("TextureStorageFormat_R32UI"); } break; case TextureStorageFormat_R32F: { Result = CSz("TextureStorageFormat_R32F"); } break; case TextureStorageFormat_RG16F: { Result = CSz("TextureStorageFormat_RG16F"); } break; case TextureStorageFormat_RG32F: { Result = CSz("TextureStorageFormat_RG32F"); } break; @@ -42,9 +82,10 @@ ToString(texture_storage_format Type) case TextureStorageFormat_RGBA32F: { Result = CSz("TextureStorageFormat_RGBA32F"); } break; case TextureStorageFormat_Depth32: { Result = CSz("TextureStorageFormat_Depth32"); } break; + } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } @@ -53,8 +94,11 @@ TextureStorageFormat(counted_string S) { texture_storage_format Result = {}; - if (StringsMatch(S, CSz("TextureStorageFormat_Undefined"))) { return TextureStorageFormat_Undefined; } + if (StringsMatch(S, CSz("TextureStorageFormat_Undefined"))) { return TextureStorageFormat_Undefined; } + if (StringsMatch(S, CSz("TextureStorageFormat_R16I"))) { return TextureStorageFormat_R16I; } if (StringsMatch(S, CSz("TextureStorageFormat_R16F"))) { return TextureStorageFormat_R16F; } + if (StringsMatch(S, CSz("TextureStorageFormat_R32I"))) { return TextureStorageFormat_R32I; } + if (StringsMatch(S, CSz("TextureStorageFormat_R32UI"))) { return TextureStorageFormat_R32UI; } if (StringsMatch(S, CSz("TextureStorageFormat_R32F"))) { return TextureStorageFormat_R32F; } if (StringsMatch(S, CSz("TextureStorageFormat_RG16F"))) { return TextureStorageFormat_RG16F; } if (StringsMatch(S, CSz("TextureStorageFormat_RG32F"))) { return TextureStorageFormat_RG32F; } @@ -65,6 +109,7 @@ TextureStorageFormat(counted_string S) if (StringsMatch(S, CSz("TextureStorageFormat_RGBA32F"))) { return TextureStorageFormat_RGBA32F; } if (StringsMatch(S, CSz("TextureStorageFormat_Depth32"))) { return TextureStorageFormat_Depth32; } + return Result; } diff --git a/generated/string_and_value_tables_tone_mapping_type.h b/generated/string_and_value_tables_tone_mapping_type.h index 054e90bc2..f3fd12590 100644 --- a/generated/string_and_value_tables_tone_mapping_type.h +++ b/generated/string_and_value_tables_tone_mapping_type.h @@ -1,40 +1,67 @@ -// src/engine/editor.cpp:171:0 +// external/bonsai_stdlib/src/poof_functions.h:2049:0 +link_internal b32 +IsValid(tone_mapping_type Value) +{ + b32 Result = False; + switch (Value) + { + case ToneMappingType_None: + case ToneMappingType_Reinhard: + case ToneMappingType_Exposure: + case ToneMappingType_AGX: + case ToneMappingType_AGX_Sepia: + case ToneMappingType_AGX_Punchy: + + { + Result = True; + } + } + return Result; +} + + link_internal counted_string ToStringPrefixless(tone_mapping_type Type) { + Assert(IsValid(Type)); counted_string Result = {}; + switch (Type) { - case ToneMappingType_None: { Result = CSz("None"); } break; + case ToneMappingType_None: { Result = CSz("None"); } break; case ToneMappingType_Reinhard: { Result = CSz("Reinhard"); } break; case ToneMappingType_Exposure: { Result = CSz("Exposure"); } break; case ToneMappingType_AGX: { Result = CSz("AGX"); } break; case ToneMappingType_AGX_Sepia: { Result = CSz("Sepia"); } break; case ToneMappingType_AGX_Punchy: { Result = CSz("Punchy"); } break; + } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } link_internal counted_string ToString(tone_mapping_type Type) { + Assert(IsValid(Type)); + counted_string Result = {}; switch (Type) { - case ToneMappingType_None: { Result = CSz("ToneMappingType_None"); } break; + case ToneMappingType_None: { Result = CSz("ToneMappingType_None"); } break; case ToneMappingType_Reinhard: { Result = CSz("ToneMappingType_Reinhard"); } break; case ToneMappingType_Exposure: { Result = CSz("ToneMappingType_Exposure"); } break; case ToneMappingType_AGX: { Result = CSz("ToneMappingType_AGX"); } break; case ToneMappingType_AGX_Sepia: { Result = CSz("ToneMappingType_AGX_Sepia"); } break; case ToneMappingType_AGX_Punchy: { Result = CSz("ToneMappingType_AGX_Punchy"); } break; + } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } @@ -43,13 +70,14 @@ ToneMappingType(counted_string S) { tone_mapping_type Result = {}; - if (StringsMatch(S, CSz("ToneMappingType_None"))) { return ToneMappingType_None; } + if (StringsMatch(S, CSz("ToneMappingType_None"))) { return ToneMappingType_None; } if (StringsMatch(S, CSz("ToneMappingType_Reinhard"))) { return ToneMappingType_Reinhard; } if (StringsMatch(S, CSz("ToneMappingType_Exposure"))) { return ToneMappingType_Exposure; } if (StringsMatch(S, CSz("ToneMappingType_AGX"))) { return ToneMappingType_AGX; } if (StringsMatch(S, CSz("ToneMappingType_AGX_Sepia"))) { return ToneMappingType_AGX_Sepia; } if (StringsMatch(S, CSz("ToneMappingType_AGX_Punchy"))) { return ToneMappingType_AGX_Punchy; } + return Result; } diff --git a/generated/string_and_value_tables_ui_noise_type.h b/generated/string_and_value_tables_ui_noise_type.h index 8bdd8a66b..1bfe7ed2b 100644 --- a/generated/string_and_value_tables_ui_noise_type.h +++ b/generated/string_and_value_tables_ui_noise_type.h @@ -1,34 +1,58 @@ -// src/engine/editor.h:543:0 +// external/bonsai_stdlib/src/poof_functions.h:2049:0 +link_internal b32 +IsValid(ui_noise_type Value) +{ + b32 Result = False; + switch (Value) + { + case NoiseType_Perlin: + case NoiseType_Voronoi: + case NoiseType_White: + + { + Result = True; + } + } + return Result; +} + + link_internal counted_string ToStringPrefixless(ui_noise_type Type) { + Assert(IsValid(Type)); counted_string Result = {}; + switch (Type) { - case NoiseType_Perlin: { Result = CSz("Perlin"); } break; + case NoiseType_Perlin: { Result = CSz("Perlin"); } break; case NoiseType_Voronoi: { Result = CSz("Voronoi"); } break; case NoiseType_White: { Result = CSz("White"); } break; + } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } link_internal counted_string ToString(ui_noise_type Type) { + Assert(IsValid(Type)); + counted_string Result = {}; switch (Type) { - case NoiseType_Perlin: { Result = CSz("NoiseType_Perlin"); } break; + case NoiseType_Perlin: { Result = CSz("NoiseType_Perlin"); } break; case NoiseType_Voronoi: { Result = CSz("NoiseType_Voronoi"); } break; case NoiseType_White: { Result = CSz("NoiseType_White"); } break; + } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } @@ -37,10 +61,11 @@ UiNoiseType(counted_string S) { ui_noise_type Result = {}; - if (StringsMatch(S, CSz("NoiseType_Perlin"))) { return NoiseType_Perlin; } + if (StringsMatch(S, CSz("NoiseType_Perlin"))) { return NoiseType_Perlin; } if (StringsMatch(S, CSz("NoiseType_Voronoi"))) { return NoiseType_Voronoi; } if (StringsMatch(S, CSz("NoiseType_White"))) { return NoiseType_White; } + return Result; } diff --git a/generated/string_and_value_tables_visible_region_size.h b/generated/string_and_value_tables_visible_region_size.h new file mode 100644 index 000000000..13b390097 --- /dev/null +++ b/generated/string_and_value_tables_visible_region_size.h @@ -0,0 +1,160 @@ +// external/bonsai_stdlib/src/poof_functions.h:2049:0 +link_internal b32 +IsValid(visible_region_size Value) +{ + b32 Result = False; + switch (Value) + { + case VisibleRegionSize_1: + case VisibleRegionSize_2: + case VisibleRegionSize_4: + case VisibleRegionSize_8: + case VisibleRegionSize_16: + case VisibleRegionSize_32: + case VisibleRegionSize_64: + case VisibleRegionSize_128: + case VisibleRegionSize_256: + case VisibleRegionSize_512: + case VisibleRegionSize_1k: + case VisibleRegionSize_2k: + case VisibleRegionSize_4k: + case VisibleRegionSize_8k: + case VisibleRegionSize_16k: + case VisibleRegionSize_32k: + case VisibleRegionSize_64k: + case VisibleRegionSize_128k: + case VisibleRegionSize_256k: + case VisibleRegionSize_512k: + case VisibleRegionSize_1024k: + case VisibleRegionSize_2048k: + case VisibleRegionSize_4096k: + case VisibleRegionSize_8192k: + case VisibleRegionSize_16kk: + + { + Result = True; + } + } + return Result; +} + + + +link_internal counted_string +ToStringPrefixless(visible_region_size Type) +{ + Assert(IsValid(Type)); + counted_string Result = {}; + + switch (Type) + { + case VisibleRegionSize_1: { Result = CSz("1"); } break; + case VisibleRegionSize_2: { Result = CSz("2"); } break; + case VisibleRegionSize_4: { Result = CSz("4"); } break; + case VisibleRegionSize_8: { Result = CSz("8"); } break; + case VisibleRegionSize_16: { Result = CSz("16"); } break; + case VisibleRegionSize_32: { Result = CSz("32"); } break; + case VisibleRegionSize_64: { Result = CSz("64"); } break; + case VisibleRegionSize_128: { Result = CSz("128"); } break; + case VisibleRegionSize_256: { Result = CSz("256"); } break; + case VisibleRegionSize_512: { Result = CSz("512"); } break; + case VisibleRegionSize_1k: { Result = CSz("1k"); } break; + case VisibleRegionSize_2k: { Result = CSz("2k"); } break; + case VisibleRegionSize_4k: { Result = CSz("4k"); } break; + case VisibleRegionSize_8k: { Result = CSz("8k"); } break; + case VisibleRegionSize_16k: { Result = CSz("16k"); } break; + case VisibleRegionSize_32k: { Result = CSz("32k"); } break; + case VisibleRegionSize_64k: { Result = CSz("64k"); } break; + case VisibleRegionSize_128k: { Result = CSz("128k"); } break; + case VisibleRegionSize_256k: { Result = CSz("256k"); } break; + case VisibleRegionSize_512k: { Result = CSz("512k"); } break; + case VisibleRegionSize_1024k: { Result = CSz("1024k"); } break; + case VisibleRegionSize_2048k: { Result = CSz("2048k"); } break; + case VisibleRegionSize_4096k: { Result = CSz("4096k"); } break; + case VisibleRegionSize_8192k: { Result = CSz("8192k"); } break; + case VisibleRegionSize_16kk: { Result = CSz("16kk"); } break; + + + + } + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ + return Result; +} + +link_internal counted_string +ToString(visible_region_size Type) +{ + Assert(IsValid(Type)); + + counted_string Result = {}; + switch (Type) + { + case VisibleRegionSize_1: { Result = CSz("VisibleRegionSize_1"); } break; + case VisibleRegionSize_2: { Result = CSz("VisibleRegionSize_2"); } break; + case VisibleRegionSize_4: { Result = CSz("VisibleRegionSize_4"); } break; + case VisibleRegionSize_8: { Result = CSz("VisibleRegionSize_8"); } break; + case VisibleRegionSize_16: { Result = CSz("VisibleRegionSize_16"); } break; + case VisibleRegionSize_32: { Result = CSz("VisibleRegionSize_32"); } break; + case VisibleRegionSize_64: { Result = CSz("VisibleRegionSize_64"); } break; + case VisibleRegionSize_128: { Result = CSz("VisibleRegionSize_128"); } break; + case VisibleRegionSize_256: { Result = CSz("VisibleRegionSize_256"); } break; + case VisibleRegionSize_512: { Result = CSz("VisibleRegionSize_512"); } break; + case VisibleRegionSize_1k: { Result = CSz("VisibleRegionSize_1k"); } break; + case VisibleRegionSize_2k: { Result = CSz("VisibleRegionSize_2k"); } break; + case VisibleRegionSize_4k: { Result = CSz("VisibleRegionSize_4k"); } break; + case VisibleRegionSize_8k: { Result = CSz("VisibleRegionSize_8k"); } break; + case VisibleRegionSize_16k: { Result = CSz("VisibleRegionSize_16k"); } break; + case VisibleRegionSize_32k: { Result = CSz("VisibleRegionSize_32k"); } break; + case VisibleRegionSize_64k: { Result = CSz("VisibleRegionSize_64k"); } break; + case VisibleRegionSize_128k: { Result = CSz("VisibleRegionSize_128k"); } break; + case VisibleRegionSize_256k: { Result = CSz("VisibleRegionSize_256k"); } break; + case VisibleRegionSize_512k: { Result = CSz("VisibleRegionSize_512k"); } break; + case VisibleRegionSize_1024k: { Result = CSz("VisibleRegionSize_1024k"); } break; + case VisibleRegionSize_2048k: { Result = CSz("VisibleRegionSize_2048k"); } break; + case VisibleRegionSize_4096k: { Result = CSz("VisibleRegionSize_4096k"); } break; + case VisibleRegionSize_8192k: { Result = CSz("VisibleRegionSize_8192k"); } break; + case VisibleRegionSize_16kk: { Result = CSz("VisibleRegionSize_16kk"); } break; + + + + } + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ + return Result; +} + +link_internal visible_region_size +VisibleRegionSize(counted_string S) +{ + visible_region_size Result = {}; + + if (StringsMatch(S, CSz("VisibleRegionSize_1"))) { return VisibleRegionSize_1; } + if (StringsMatch(S, CSz("VisibleRegionSize_2"))) { return VisibleRegionSize_2; } + if (StringsMatch(S, CSz("VisibleRegionSize_4"))) { return VisibleRegionSize_4; } + if (StringsMatch(S, CSz("VisibleRegionSize_8"))) { return VisibleRegionSize_8; } + if (StringsMatch(S, CSz("VisibleRegionSize_16"))) { return VisibleRegionSize_16; } + if (StringsMatch(S, CSz("VisibleRegionSize_32"))) { return VisibleRegionSize_32; } + if (StringsMatch(S, CSz("VisibleRegionSize_64"))) { return VisibleRegionSize_64; } + if (StringsMatch(S, CSz("VisibleRegionSize_128"))) { return VisibleRegionSize_128; } + if (StringsMatch(S, CSz("VisibleRegionSize_256"))) { return VisibleRegionSize_256; } + if (StringsMatch(S, CSz("VisibleRegionSize_512"))) { return VisibleRegionSize_512; } + if (StringsMatch(S, CSz("VisibleRegionSize_1k"))) { return VisibleRegionSize_1k; } + if (StringsMatch(S, CSz("VisibleRegionSize_2k"))) { return VisibleRegionSize_2k; } + if (StringsMatch(S, CSz("VisibleRegionSize_4k"))) { return VisibleRegionSize_4k; } + if (StringsMatch(S, CSz("VisibleRegionSize_8k"))) { return VisibleRegionSize_8k; } + if (StringsMatch(S, CSz("VisibleRegionSize_16k"))) { return VisibleRegionSize_16k; } + if (StringsMatch(S, CSz("VisibleRegionSize_32k"))) { return VisibleRegionSize_32k; } + if (StringsMatch(S, CSz("VisibleRegionSize_64k"))) { return VisibleRegionSize_64k; } + if (StringsMatch(S, CSz("VisibleRegionSize_128k"))) { return VisibleRegionSize_128k; } + if (StringsMatch(S, CSz("VisibleRegionSize_256k"))) { return VisibleRegionSize_256k; } + if (StringsMatch(S, CSz("VisibleRegionSize_512k"))) { return VisibleRegionSize_512k; } + if (StringsMatch(S, CSz("VisibleRegionSize_1024k"))) { return VisibleRegionSize_1024k; } + if (StringsMatch(S, CSz("VisibleRegionSize_2048k"))) { return VisibleRegionSize_2048k; } + if (StringsMatch(S, CSz("VisibleRegionSize_4096k"))) { return VisibleRegionSize_4096k; } + if (StringsMatch(S, CSz("VisibleRegionSize_8192k"))) { return VisibleRegionSize_8192k; } + if (StringsMatch(S, CSz("VisibleRegionSize_16kk"))) { return VisibleRegionSize_16kk; } + + + return Result; +} + + diff --git a/generated/string_and_value_tables_voxel_rule_direction.h b/generated/string_and_value_tables_voxel_rule_direction.h new file mode 100644 index 000000000..0b5defb47 --- /dev/null +++ b/generated/string_and_value_tables_voxel_rule_direction.h @@ -0,0 +1,88 @@ +// external/bonsai_stdlib/src/poof_functions.h:2049:0 +link_internal b32 +IsValid(voxel_rule_direction Value) +{ + b32 Result = False; + switch (Value) + { + case VoxelRuleDir_PosX: + case VoxelRuleDir_NegX: + case VoxelRuleDir_PosY: + case VoxelRuleDir_NegY: + case VoxelRuleDir_PosZ: + case VoxelRuleDir_NegZ: + case VoxelRuleDir_Count: + + { + Result = True; + } + } + return Result; +} + + + +link_internal counted_string +ToStringPrefixless(voxel_rule_direction Type) +{ + Assert(IsValid(Type)); + counted_string Result = {}; + + switch (Type) + { + case VoxelRuleDir_PosX: { Result = CSz("PosX"); } break; + case VoxelRuleDir_NegX: { Result = CSz("NegX"); } break; + case VoxelRuleDir_PosY: { Result = CSz("PosY"); } break; + case VoxelRuleDir_NegY: { Result = CSz("NegY"); } break; + case VoxelRuleDir_PosZ: { Result = CSz("PosZ"); } break; + case VoxelRuleDir_NegZ: { Result = CSz("NegZ"); } break; + case VoxelRuleDir_Count: { Result = CSz("Count"); } break; + + + + } + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ + return Result; +} + +link_internal counted_string +ToString(voxel_rule_direction Type) +{ + Assert(IsValid(Type)); + + counted_string Result = {}; + switch (Type) + { + case VoxelRuleDir_PosX: { Result = CSz("VoxelRuleDir_PosX"); } break; + case VoxelRuleDir_NegX: { Result = CSz("VoxelRuleDir_NegX"); } break; + case VoxelRuleDir_PosY: { Result = CSz("VoxelRuleDir_PosY"); } break; + case VoxelRuleDir_NegY: { Result = CSz("VoxelRuleDir_NegY"); } break; + case VoxelRuleDir_PosZ: { Result = CSz("VoxelRuleDir_PosZ"); } break; + case VoxelRuleDir_NegZ: { Result = CSz("VoxelRuleDir_NegZ"); } break; + case VoxelRuleDir_Count: { Result = CSz("VoxelRuleDir_Count"); } break; + + + + } + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ + return Result; +} + +link_internal voxel_rule_direction +VoxelRuleDirection(counted_string S) +{ + voxel_rule_direction Result = {}; + + if (StringsMatch(S, CSz("VoxelRuleDir_PosX"))) { return VoxelRuleDir_PosX; } + if (StringsMatch(S, CSz("VoxelRuleDir_NegX"))) { return VoxelRuleDir_NegX; } + if (StringsMatch(S, CSz("VoxelRuleDir_PosY"))) { return VoxelRuleDir_PosY; } + if (StringsMatch(S, CSz("VoxelRuleDir_NegY"))) { return VoxelRuleDir_NegY; } + if (StringsMatch(S, CSz("VoxelRuleDir_PosZ"))) { return VoxelRuleDir_PosZ; } + if (StringsMatch(S, CSz("VoxelRuleDir_NegZ"))) { return VoxelRuleDir_NegZ; } + if (StringsMatch(S, CSz("VoxelRuleDir_Count"))) { return VoxelRuleDir_Count; } + + + return Result; +} + + diff --git a/generated/string_and_value_tables_world_edit_blend_mode.h b/generated/string_and_value_tables_world_edit_blend_mode.h new file mode 100644 index 000000000..76fd044ef --- /dev/null +++ b/generated/string_and_value_tables_world_edit_blend_mode.h @@ -0,0 +1,80 @@ +// external/bonsai_stdlib/src/poof_functions.h:2049:0 +link_internal b32 +IsValid(world_edit_blend_mode Value) +{ + b32 Result = False; + switch (Value) + { + case WorldEdit_Mode_Additive: + case WorldEdit_Mode_Subtractive: + case WorldEdit_Mode_Multiply: + case WorldEdit_Mode_Threshold: + case WorldEdit_Mode_Disabled: + + { + Result = True; + } + } + return Result; +} + + + +link_internal counted_string +ToStringPrefixless(world_edit_blend_mode Type) +{ + Assert(IsValid(Type)); + counted_string Result = {}; + + switch (Type) + { + case WorldEdit_Mode_Additive: { Result = CSz("Additive"); } break; + case WorldEdit_Mode_Subtractive: { Result = CSz("Subtractive"); } break; + case WorldEdit_Mode_Multiply: { Result = CSz("Multiply"); } break; + case WorldEdit_Mode_Threshold: { Result = CSz("Threshold"); } break; + case WorldEdit_Mode_Disabled: { Result = CSz("Disabled"); } break; + + + + } + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ + return Result; +} + +link_internal counted_string +ToString(world_edit_blend_mode Type) +{ + Assert(IsValid(Type)); + + counted_string Result = {}; + switch (Type) + { + case WorldEdit_Mode_Additive: { Result = CSz("WorldEdit_Mode_Additive"); } break; + case WorldEdit_Mode_Subtractive: { Result = CSz("WorldEdit_Mode_Subtractive"); } break; + case WorldEdit_Mode_Multiply: { Result = CSz("WorldEdit_Mode_Multiply"); } break; + case WorldEdit_Mode_Threshold: { Result = CSz("WorldEdit_Mode_Threshold"); } break; + case WorldEdit_Mode_Disabled: { Result = CSz("WorldEdit_Mode_Disabled"); } break; + + + + } + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ + return Result; +} + +link_internal world_edit_blend_mode +WorldEditBlendMode(counted_string S) +{ + world_edit_blend_mode Result = {}; + + if (StringsMatch(S, CSz("WorldEdit_Mode_Additive"))) { return WorldEdit_Mode_Additive; } + if (StringsMatch(S, CSz("WorldEdit_Mode_Subtractive"))) { return WorldEdit_Mode_Subtractive; } + if (StringsMatch(S, CSz("WorldEdit_Mode_Multiply"))) { return WorldEdit_Mode_Multiply; } + if (StringsMatch(S, CSz("WorldEdit_Mode_Threshold"))) { return WorldEdit_Mode_Threshold; } + if (StringsMatch(S, CSz("WorldEdit_Mode_Disabled"))) { return WorldEdit_Mode_Disabled; } + + + return Result; +} + + diff --git a/generated/string_and_value_tables_world_edit_blend_mode_modifier.h b/generated/string_and_value_tables_world_edit_blend_mode_modifier.h new file mode 100644 index 000000000..aaaba2d25 --- /dev/null +++ b/generated/string_and_value_tables_world_edit_blend_mode_modifier.h @@ -0,0 +1,125 @@ +// external/bonsai_stdlib/src/poof_functions.h:2049:0 +link_internal b32 +IsValid(world_edit_blend_mode_modifier Value) +{ + b32 Result = False; + switch (Value) + { + case WorldEdit_Modifier_None: + case WorldEdit_ValueModifier_ClampPos: + case WorldEdit_ValueModifier_ClampNeg: + case WorldEdit_ValueModifier_Threshold: + case WorldEdit_ColorModifier_Discard: + + { + Result = True; + } + } + return Result; +} + + + +link_internal counted_string +ToStringPrefixless(world_edit_blend_mode_modifier Type) +{ + Assert(IsValid(Type)); + counted_string Result = {}; + + switch (Type) + { + case WorldEdit_Modifier_None: { Result = CSz("None"); } break; + case WorldEdit_ValueModifier_ClampPos: { Result = CSz("ClampPos"); } break; + case WorldEdit_ValueModifier_ClampNeg: { Result = CSz("ClampNeg"); } break; + case WorldEdit_ValueModifier_Threshold: { Result = CSz("Threshold"); } break; + case WorldEdit_ColorModifier_Discard: { Result = CSz("Discard"); } break; + + + // TODO(Jesse): This is pretty barf and we could do it in a single allocation, + // but the metaprogram might have to be a bit fancier.. + default: + { + u32 CurrentFlags = u32(Type); + + u32 BitsSet = CountBitsSet_Kernighan(CurrentFlags); + switch(BitsSet) + { + case 0: // We likely passed 0 into this function, and the enum didn't have a 0 value + case 1: // The value we passed in was outside the range of the valid enum values + { + Result = FSz("(invalid value (%d))", CurrentFlags); + } break; + + default: + { + u32 FirstValue = UnsetLeastSignificantSetBit(&CurrentFlags); + Result = ToStringPrefixless(world_edit_blend_mode_modifier(FirstValue)); + + while (CurrentFlags) + { + u32 Value = UnsetLeastSignificantSetBit(&CurrentFlags); + cs Next = ToStringPrefixless(world_edit_blend_mode_modifier(Value)); + Result = FSz("%S | %S", Result, Next); + } + } break; + } + } break; + + } + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ + return Result; +} + +link_internal counted_string +ToString(world_edit_blend_mode_modifier Type) +{ + Assert(IsValid(Type)); + + counted_string Result = {}; + switch (Type) + { + case WorldEdit_Modifier_None: { Result = CSz("WorldEdit_Modifier_None"); } break; + case WorldEdit_ValueModifier_ClampPos: { Result = CSz("WorldEdit_ValueModifier_ClampPos"); } break; + case WorldEdit_ValueModifier_ClampNeg: { Result = CSz("WorldEdit_ValueModifier_ClampNeg"); } break; + case WorldEdit_ValueModifier_Threshold: { Result = CSz("WorldEdit_ValueModifier_Threshold"); } break; + case WorldEdit_ColorModifier_Discard: { Result = CSz("WorldEdit_ColorModifier_Discard"); } break; + + + // TODO(Jesse): This is pretty barf and we could do it in a single allocation, + // but the metaprogram might have to be a bit fancier.. + default: + { + u32 CurrentFlags = u32(Type); + + u32 FirstValue = UnsetLeastSignificantSetBit(&CurrentFlags); + Result = ToString(world_edit_blend_mode_modifier(FirstValue)); + + while (CurrentFlags) + { + u32 Value = UnsetLeastSignificantSetBit(&CurrentFlags); + cs Next = ToString(world_edit_blend_mode_modifier(Value)); + Result = FSz("%S | %S", Result, Next); + } + } break; + + } + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ + return Result; +} + +link_internal world_edit_blend_mode_modifier +WorldEditBlendModeModifier(counted_string S) +{ + world_edit_blend_mode_modifier Result = {}; + + if (StringsMatch(S, CSz("WorldEdit_Modifier_None"))) { return WorldEdit_Modifier_None; } + if (StringsMatch(S, CSz("WorldEdit_ValueModifier_ClampPos"))) { return WorldEdit_ValueModifier_ClampPos; } + if (StringsMatch(S, CSz("WorldEdit_ValueModifier_ClampNeg"))) { return WorldEdit_ValueModifier_ClampNeg; } + if (StringsMatch(S, CSz("WorldEdit_ValueModifier_Threshold"))) { return WorldEdit_ValueModifier_Threshold; } + if (StringsMatch(S, CSz("WorldEdit_ColorModifier_Discard"))) { return WorldEdit_ColorModifier_Discard; } + + + return Result; +} + + diff --git a/generated/string_and_value_tables_world_edit_color_blend_mode.h b/generated/string_and_value_tables_world_edit_color_blend_mode.h new file mode 100644 index 000000000..f5aed7de2 --- /dev/null +++ b/generated/string_and_value_tables_world_edit_color_blend_mode.h @@ -0,0 +1,76 @@ +// external/bonsai_stdlib/src/poof_functions.h:2049:0 +link_internal b32 +IsValid(world_edit_color_blend_mode Value) +{ + b32 Result = False; + switch (Value) + { + case WorldEdit_ColorBlendMode_ValuePositive: + case WorldEdit_ColorBlendMode_ValueNegative: + case WorldEdit_ColorBlendMode_Surface: + case WorldEdit_ColorBlendMode_Disabled: + + { + Result = True; + } + } + return Result; +} + + + +link_internal counted_string +ToStringPrefixless(world_edit_color_blend_mode Type) +{ + Assert(IsValid(Type)); + counted_string Result = {}; + + switch (Type) + { + case WorldEdit_ColorBlendMode_ValuePositive: { Result = CSz("ValuePositive"); } break; + case WorldEdit_ColorBlendMode_ValueNegative: { Result = CSz("ValueNegative"); } break; + case WorldEdit_ColorBlendMode_Surface: { Result = CSz("Surface"); } break; + case WorldEdit_ColorBlendMode_Disabled: { Result = CSz("Disabled"); } break; + + + + } + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ + return Result; +} + +link_internal counted_string +ToString(world_edit_color_blend_mode Type) +{ + Assert(IsValid(Type)); + + counted_string Result = {}; + switch (Type) + { + case WorldEdit_ColorBlendMode_ValuePositive: { Result = CSz("WorldEdit_ColorBlendMode_ValuePositive"); } break; + case WorldEdit_ColorBlendMode_ValueNegative: { Result = CSz("WorldEdit_ColorBlendMode_ValueNegative"); } break; + case WorldEdit_ColorBlendMode_Surface: { Result = CSz("WorldEdit_ColorBlendMode_Surface"); } break; + case WorldEdit_ColorBlendMode_Disabled: { Result = CSz("WorldEdit_ColorBlendMode_Disabled"); } break; + + + + } + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ + return Result; +} + +link_internal world_edit_color_blend_mode +WorldEditColorBlendMode(counted_string S) +{ + world_edit_color_blend_mode Result = {}; + + if (StringsMatch(S, CSz("WorldEdit_ColorBlendMode_ValuePositive"))) { return WorldEdit_ColorBlendMode_ValuePositive; } + if (StringsMatch(S, CSz("WorldEdit_ColorBlendMode_ValueNegative"))) { return WorldEdit_ColorBlendMode_ValueNegative; } + if (StringsMatch(S, CSz("WorldEdit_ColorBlendMode_Surface"))) { return WorldEdit_ColorBlendMode_Surface; } + if (StringsMatch(S, CSz("WorldEdit_ColorBlendMode_Disabled"))) { return WorldEdit_ColorBlendMode_Disabled; } + + + return Result; +} + + diff --git a/generated/string_and_value_tables_world_edit_mode.h b/generated/string_and_value_tables_world_edit_mode.h deleted file mode 100644 index 645da345d..000000000 --- a/generated/string_and_value_tables_world_edit_mode.h +++ /dev/null @@ -1,50 +0,0 @@ -// src/engine/editor.h:686:0 - -link_internal counted_string -ToStringPrefixless(world_edit_mode Type) -{ - counted_string Result = {}; - switch (Type) - { - case WorldEdit_Mode_Attach: { Result = CSz("Attach"); } break; - case WorldEdit_Mode_Remove: { Result = CSz("Remove"); } break; - case WorldEdit_Mode_Paint: { Result = CSz("Paint"); } break; - case WorldEdit_Mode_Disabled: { Result = CSz("Disabled"); } break; - - - } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ - return Result; -} - -link_internal counted_string -ToString(world_edit_mode Type) -{ - counted_string Result = {}; - switch (Type) - { - case WorldEdit_Mode_Attach: { Result = CSz("WorldEdit_Mode_Attach"); } break; - case WorldEdit_Mode_Remove: { Result = CSz("WorldEdit_Mode_Remove"); } break; - case WorldEdit_Mode_Paint: { Result = CSz("WorldEdit_Mode_Paint"); } break; - case WorldEdit_Mode_Disabled: { Result = CSz("WorldEdit_Mode_Disabled"); } break; - - - } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ - return Result; -} - -link_internal world_edit_mode -WorldEditMode(counted_string S) -{ - world_edit_mode Result = {}; - - if (StringsMatch(S, CSz("WorldEdit_Mode_Attach"))) { return WorldEdit_Mode_Attach; } - if (StringsMatch(S, CSz("WorldEdit_Mode_Remove"))) { return WorldEdit_Mode_Remove; } - if (StringsMatch(S, CSz("WorldEdit_Mode_Paint"))) { return WorldEdit_Mode_Paint; } - if (StringsMatch(S, CSz("WorldEdit_Mode_Disabled"))) { return WorldEdit_Mode_Disabled; } - - return Result; -} - - diff --git a/generated/string_and_value_tables_world_edit_mode_modifier.h b/generated/string_and_value_tables_world_edit_mode_modifier.h deleted file mode 100644 index 0abe04583..000000000 --- a/generated/string_and_value_tables_world_edit_mode_modifier.h +++ /dev/null @@ -1,47 +0,0 @@ -// src/engine/editor.h:673:0 - -link_internal counted_string -ToStringPrefixless(world_edit_mode_modifier Type) -{ - counted_string Result = {}; - switch (Type) - { - case WorldEdit_Modifier_Default: { Result = CSz("Default"); } break; - case WorldEdit_Modifier_Flood: { Result = CSz("Flood"); } break; - case WorldEdit_Modifier_Surface: { Result = CSz("Surface"); } break; - - - } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ - return Result; -} - -link_internal counted_string -ToString(world_edit_mode_modifier Type) -{ - counted_string Result = {}; - switch (Type) - { - case WorldEdit_Modifier_Default: { Result = CSz("WorldEdit_Modifier_Default"); } break; - case WorldEdit_Modifier_Flood: { Result = CSz("WorldEdit_Modifier_Flood"); } break; - case WorldEdit_Modifier_Surface: { Result = CSz("WorldEdit_Modifier_Surface"); } break; - - - } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ - return Result; -} - -link_internal world_edit_mode_modifier -WorldEditModeModifier(counted_string S) -{ - world_edit_mode_modifier Result = {}; - - if (StringsMatch(S, CSz("WorldEdit_Modifier_Default"))) { return WorldEdit_Modifier_Default; } - if (StringsMatch(S, CSz("WorldEdit_Modifier_Flood"))) { return WorldEdit_Modifier_Flood; } - if (StringsMatch(S, CSz("WorldEdit_Modifier_Surface"))) { return WorldEdit_Modifier_Surface; } - - return Result; -} - - 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 3afffdf56..2cf6a9427 100644 --- a/generated/string_and_value_tables_world_edit_selection_mode.h +++ b/generated/string_and_value_tables_world_edit_selection_mode.h @@ -1,40 +1,67 @@ -// src/engine/editor.h:577:0 +// external/bonsai_stdlib/src/poof_functions.h:2049:0 +link_internal b32 +IsValid(world_edit_selection_mode Value) +{ + b32 Result = False; + switch (Value) + { + case SelectionMode_Noop: + case SelectionMode_ResizeSingleLinearAxis: + case SelectionMode_ResizeBothLinearAxies: + case SelectionMode_ResizeAllAxies: + case SelectionMode_TranslateLinear: + case SelectionMode_TranslatePlanar: + + { + Result = True; + } + } + return Result; +} + + link_internal counted_string ToStringPrefixless(world_edit_selection_mode Type) { + Assert(IsValid(Type)); counted_string Result = {}; + switch (Type) { - case SelectionMode_Noop: { Result = CSz("Noop"); } break; + case SelectionMode_Noop: { Result = CSz("Noop"); } break; case SelectionMode_ResizeSingleLinearAxis: { Result = CSz("ResizeSingleLinearAxis"); } break; case SelectionMode_ResizeBothLinearAxies: { Result = CSz("ResizeBothLinearAxies"); } break; case SelectionMode_ResizeAllAxies: { Result = CSz("ResizeAllAxies"); } break; case SelectionMode_TranslateLinear: { Result = CSz("TranslateLinear"); } break; case SelectionMode_TranslatePlanar: { Result = CSz("TranslatePlanar"); } break; + } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } link_internal counted_string ToString(world_edit_selection_mode Type) { + Assert(IsValid(Type)); + counted_string Result = {}; switch (Type) { - case SelectionMode_Noop: { Result = CSz("SelectionMode_Noop"); } break; + case SelectionMode_Noop: { Result = CSz("SelectionMode_Noop"); } break; case SelectionMode_ResizeSingleLinearAxis: { Result = CSz("SelectionMode_ResizeSingleLinearAxis"); } break; case SelectionMode_ResizeBothLinearAxies: { Result = CSz("SelectionMode_ResizeBothLinearAxies"); } break; case SelectionMode_ResizeAllAxies: { Result = CSz("SelectionMode_ResizeAllAxies"); } break; case SelectionMode_TranslateLinear: { Result = CSz("SelectionMode_TranslateLinear"); } break; case SelectionMode_TranslatePlanar: { Result = CSz("SelectionMode_TranslatePlanar"); } break; + } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ + /* if (Result.Start == 0) { Info("Could not convert value(%d) to (enum_t.name)", Type); } */ return Result; } @@ -43,13 +70,14 @@ WorldEditSelectionMode(counted_string S) { world_edit_selection_mode Result = {}; - if (StringsMatch(S, CSz("SelectionMode_Noop"))) { return SelectionMode_Noop; } + if (StringsMatch(S, CSz("SelectionMode_Noop"))) { return SelectionMode_Noop; } if (StringsMatch(S, CSz("SelectionMode_ResizeSingleLinearAxis"))) { return SelectionMode_ResizeSingleLinearAxis; } if (StringsMatch(S, CSz("SelectionMode_ResizeBothLinearAxies"))) { return SelectionMode_ResizeBothLinearAxies; } if (StringsMatch(S, CSz("SelectionMode_ResizeAllAxies"))) { return SelectionMode_ResizeAllAxies; } if (StringsMatch(S, CSz("SelectionMode_TranslateLinear"))) { return SelectionMode_TranslateLinear; } if (StringsMatch(S, CSz("SelectionMode_TranslatePlanar"))) { return SelectionMode_TranslatePlanar; } + return Result; } 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 deleted file mode 100644 index b9f821e48..000000000 --- a/generated/string_and_value_tables_world_update_op_shape_type.h +++ /dev/null @@ -1,56 +0,0 @@ -// src/engine/editor.h:719:0 - -link_internal counted_string -ToStringPrefixless(world_update_op_shape_type Type) -{ - counted_string Result = {}; - switch (Type) - { - case type_world_update_op_shape_params_noop: { Result = CSz("noop"); } break; - case type_world_update_op_shape_params_sphere: { Result = CSz("sphere"); } break; - case type_world_update_op_shape_params_rect: { Result = CSz("rect"); } break; - case type_world_update_op_shape_params_asset: { Result = CSz("asset"); } break; - case type_world_update_op_shape_params_chunk_data: { Result = CSz("data"); } break; - case type_world_update_op_shape_params_count: { Result = CSz("count"); } break; - - - } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ - return Result; -} - -link_internal counted_string -ToString(world_update_op_shape_type Type) -{ - counted_string Result = {}; - switch (Type) - { - case type_world_update_op_shape_params_noop: { Result = CSz("type_world_update_op_shape_params_noop"); } break; - case type_world_update_op_shape_params_sphere: { Result = CSz("type_world_update_op_shape_params_sphere"); } break; - case type_world_update_op_shape_params_rect: { Result = CSz("type_world_update_op_shape_params_rect"); } break; - case type_world_update_op_shape_params_asset: { Result = CSz("type_world_update_op_shape_params_asset"); } break; - case type_world_update_op_shape_params_chunk_data: { Result = CSz("type_world_update_op_shape_params_chunk_data"); } break; - case type_world_update_op_shape_params_count: { Result = CSz("type_world_update_op_shape_params_count"); } break; - - - } - /* if (Result.Start == 0) { Info("Could not convert value(%d) to (EnumType.name)", Type); } */ - return Result; -} - -link_internal world_update_op_shape_type -WorldUpdateOpShapeType(counted_string S) -{ - world_update_op_shape_type Result = {}; - - if (StringsMatch(S, CSz("type_world_update_op_shape_params_noop"))) { return type_world_update_op_shape_params_noop; } - if (StringsMatch(S, CSz("type_world_update_op_shape_params_sphere"))) { return type_world_update_op_shape_params_sphere; } - if (StringsMatch(S, CSz("type_world_update_op_shape_params_rect"))) { return type_world_update_op_shape_params_rect; } - if (StringsMatch(S, CSz("type_world_update_op_shape_params_asset"))) { return type_world_update_op_shape_params_asset; } - if (StringsMatch(S, CSz("type_world_update_op_shape_params_chunk_data"))) { return type_world_update_op_shape_params_chunk_data; } - if (StringsMatch(S, CSz("type_world_update_op_shape_params_count"))) { return type_world_update_op_shape_params_count; } - - return Result; -} - - diff --git a/generated/string_concat_10.h b/generated/string_concat_10.h index ce271acab..362762381 100644 --- a/generated/string_concat_10.h +++ b/generated/string_concat_10.h @@ -1,16 +1,15 @@ -// external/bonsai_stdlib/src/counted_string.cpp:186:0 - +// external/bonsai_stdlib/src/counted_string.cpp:158:0 link_internal counted_string -Concat(cs S0, cs S1, cs S2, cs S3, cs S4, cs S5, cs S6, cs S7, cs S8, cs S9, memory_arena* Memory, umm ExtraChars = 0) +Concat( cs S0, cs S1, cs S2, cs S3, cs S4, cs S5, cs S6, cs S7, cs S8, cs S9, memory_arena* Memory, umm ExtraChars = 0) { - umm TotalLength = S0.Count + S1.Count + S2.Count + S3.Count + S4.Count + S5.Count + S6.Count + S7.Count + S8.Count + S9.Count + 0; + umm TotalLength = S0.Count + S1.Count + S2.Count + S3.Count + S4.Count + S5.Count + S6.Count + S7.Count + S8.Count + S9.Count + 0; counted_string Result = { .Count = TotalLength + ExtraChars, .Start = AllocateProtection(char, Memory, TotalLength, False), }; u64 At = 0; - MemCopy((u8*)S0.Start, (u8*)Result.Start+At, S0.Count); + MemCopy((u8*)S0.Start, (u8*)Result.Start+At, S0.Count); At += S0.Count; MemCopy((u8*)S1.Start, (u8*)Result.Start+At, S1.Count); At += S1.Count; diff --git a/generated/string_concat_2.h b/generated/string_concat_2.h index 9e0b2d413..02a7d0d3a 100644 --- a/generated/string_concat_2.h +++ b/generated/string_concat_2.h @@ -1,16 +1,15 @@ -// external/bonsai_stdlib/src/counted_string.cpp:170:0 - +// external/bonsai_stdlib/src/counted_string.cpp:158:0 link_internal counted_string -Concat(cs S0, cs S1, memory_arena* Memory, umm ExtraChars = 0) +Concat( cs S0, cs S1, memory_arena* Memory, umm ExtraChars = 0) { - umm TotalLength = S0.Count + S1.Count + 0; + umm TotalLength = S0.Count + S1.Count + 0; counted_string Result = { .Count = TotalLength + ExtraChars, .Start = AllocateProtection(char, Memory, TotalLength, False), }; u64 At = 0; - MemCopy((u8*)S0.Start, (u8*)Result.Start+At, S0.Count); + MemCopy((u8*)S0.Start, (u8*)Result.Start+At, S0.Count); At += S0.Count; MemCopy((u8*)S1.Start, (u8*)Result.Start+At, S1.Count); At += S1.Count; diff --git a/generated/string_concat_3.h b/generated/string_concat_3.h index 3e4cabe56..64e09c922 100644 --- a/generated/string_concat_3.h +++ b/generated/string_concat_3.h @@ -1,16 +1,15 @@ -// external/bonsai_stdlib/src/counted_string.cpp:172:0 - +// external/bonsai_stdlib/src/counted_string.cpp:158:0 link_internal counted_string -Concat(cs S0, cs S1, cs S2, memory_arena* Memory, umm ExtraChars = 0) +Concat( cs S0, cs S1, cs S2, memory_arena* Memory, umm ExtraChars = 0) { - umm TotalLength = S0.Count + S1.Count + S2.Count + 0; + umm TotalLength = S0.Count + S1.Count + S2.Count + 0; counted_string Result = { .Count = TotalLength + ExtraChars, .Start = AllocateProtection(char, Memory, TotalLength, False), }; u64 At = 0; - MemCopy((u8*)S0.Start, (u8*)Result.Start+At, S0.Count); + MemCopy((u8*)S0.Start, (u8*)Result.Start+At, S0.Count); At += S0.Count; MemCopy((u8*)S1.Start, (u8*)Result.Start+At, S1.Count); At += S1.Count; diff --git a/generated/string_concat_4.h b/generated/string_concat_4.h index 96c0ff5c6..9c363c870 100644 --- a/generated/string_concat_4.h +++ b/generated/string_concat_4.h @@ -1,16 +1,15 @@ -// external/bonsai_stdlib/src/counted_string.cpp:174:0 - +// external/bonsai_stdlib/src/counted_string.cpp:158:0 link_internal counted_string -Concat(cs S0, cs S1, cs S2, cs S3, memory_arena* Memory, umm ExtraChars = 0) +Concat( cs S0, cs S1, cs S2, cs S3, memory_arena* Memory, umm ExtraChars = 0) { - umm TotalLength = S0.Count + S1.Count + S2.Count + S3.Count + 0; + umm TotalLength = S0.Count + S1.Count + S2.Count + S3.Count + 0; counted_string Result = { .Count = TotalLength + ExtraChars, .Start = AllocateProtection(char, Memory, TotalLength, False), }; u64 At = 0; - MemCopy((u8*)S0.Start, (u8*)Result.Start+At, S0.Count); + MemCopy((u8*)S0.Start, (u8*)Result.Start+At, S0.Count); At += S0.Count; MemCopy((u8*)S1.Start, (u8*)Result.Start+At, S1.Count); At += S1.Count; diff --git a/generated/string_concat_5.h b/generated/string_concat_5.h index de4ed546a..603c5cb35 100644 --- a/generated/string_concat_5.h +++ b/generated/string_concat_5.h @@ -1,16 +1,15 @@ -// external/bonsai_stdlib/src/counted_string.cpp:176:0 - +// external/bonsai_stdlib/src/counted_string.cpp:158:0 link_internal counted_string -Concat(cs S0, cs S1, cs S2, cs S3, cs S4, memory_arena* Memory, umm ExtraChars = 0) +Concat( cs S0, cs S1, cs S2, cs S3, cs S4, memory_arena* Memory, umm ExtraChars = 0) { - umm TotalLength = S0.Count + S1.Count + S2.Count + S3.Count + S4.Count + 0; + umm TotalLength = S0.Count + S1.Count + S2.Count + S3.Count + S4.Count + 0; counted_string Result = { .Count = TotalLength + ExtraChars, .Start = AllocateProtection(char, Memory, TotalLength, False), }; u64 At = 0; - MemCopy((u8*)S0.Start, (u8*)Result.Start+At, S0.Count); + MemCopy((u8*)S0.Start, (u8*)Result.Start+At, S0.Count); At += S0.Count; MemCopy((u8*)S1.Start, (u8*)Result.Start+At, S1.Count); At += S1.Count; diff --git a/generated/string_concat_6.h b/generated/string_concat_6.h index 5d185b604..12bfad8c1 100644 --- a/generated/string_concat_6.h +++ b/generated/string_concat_6.h @@ -1,16 +1,15 @@ -// external/bonsai_stdlib/src/counted_string.cpp:178:0 - +// external/bonsai_stdlib/src/counted_string.cpp:158:0 link_internal counted_string -Concat(cs S0, cs S1, cs S2, cs S3, cs S4, cs S5, memory_arena* Memory, umm ExtraChars = 0) +Concat( cs S0, cs S1, cs S2, cs S3, cs S4, cs S5, memory_arena* Memory, umm ExtraChars = 0) { - umm TotalLength = S0.Count + S1.Count + S2.Count + S3.Count + S4.Count + S5.Count + 0; + umm TotalLength = S0.Count + S1.Count + S2.Count + S3.Count + S4.Count + S5.Count + 0; counted_string Result = { .Count = TotalLength + ExtraChars, .Start = AllocateProtection(char, Memory, TotalLength, False), }; u64 At = 0; - MemCopy((u8*)S0.Start, (u8*)Result.Start+At, S0.Count); + MemCopy((u8*)S0.Start, (u8*)Result.Start+At, S0.Count); At += S0.Count; MemCopy((u8*)S1.Start, (u8*)Result.Start+At, S1.Count); At += S1.Count; diff --git a/generated/string_concat_7.h b/generated/string_concat_7.h index 08820a67a..e9a8565d4 100644 --- a/generated/string_concat_7.h +++ b/generated/string_concat_7.h @@ -1,16 +1,15 @@ -// external/bonsai_stdlib/src/counted_string.cpp:180:0 - +// external/bonsai_stdlib/src/counted_string.cpp:158:0 link_internal counted_string -Concat(cs S0, cs S1, cs S2, cs S3, cs S4, cs S5, cs S6, memory_arena* Memory, umm ExtraChars = 0) +Concat( cs S0, cs S1, cs S2, cs S3, cs S4, cs S5, cs S6, memory_arena* Memory, umm ExtraChars = 0) { - umm TotalLength = S0.Count + S1.Count + S2.Count + S3.Count + S4.Count + S5.Count + S6.Count + 0; + umm TotalLength = S0.Count + S1.Count + S2.Count + S3.Count + S4.Count + S5.Count + S6.Count + 0; counted_string Result = { .Count = TotalLength + ExtraChars, .Start = AllocateProtection(char, Memory, TotalLength, False), }; u64 At = 0; - MemCopy((u8*)S0.Start, (u8*)Result.Start+At, S0.Count); + MemCopy((u8*)S0.Start, (u8*)Result.Start+At, S0.Count); At += S0.Count; MemCopy((u8*)S1.Start, (u8*)Result.Start+At, S1.Count); At += S1.Count; diff --git a/generated/string_concat_8.h b/generated/string_concat_8.h index bd0acc864..c9b588e3c 100644 --- a/generated/string_concat_8.h +++ b/generated/string_concat_8.h @@ -1,16 +1,15 @@ -// external/bonsai_stdlib/src/counted_string.cpp:182:0 - +// external/bonsai_stdlib/src/counted_string.cpp:158:0 link_internal counted_string -Concat(cs S0, cs S1, cs S2, cs S3, cs S4, cs S5, cs S6, cs S7, memory_arena* Memory, umm ExtraChars = 0) +Concat( cs S0, cs S1, cs S2, cs S3, cs S4, cs S5, cs S6, cs S7, memory_arena* Memory, umm ExtraChars = 0) { - umm TotalLength = S0.Count + S1.Count + S2.Count + S3.Count + S4.Count + S5.Count + S6.Count + S7.Count + 0; + umm TotalLength = S0.Count + S1.Count + S2.Count + S3.Count + S4.Count + S5.Count + S6.Count + S7.Count + 0; counted_string Result = { .Count = TotalLength + ExtraChars, .Start = AllocateProtection(char, Memory, TotalLength, False), }; u64 At = 0; - MemCopy((u8*)S0.Start, (u8*)Result.Start+At, S0.Count); + MemCopy((u8*)S0.Start, (u8*)Result.Start+At, S0.Count); At += S0.Count; MemCopy((u8*)S1.Start, (u8*)Result.Start+At, S1.Count); At += S1.Count; diff --git a/generated/string_concat_9.h b/generated/string_concat_9.h index b47e9751b..ad3174e63 100644 --- a/generated/string_concat_9.h +++ b/generated/string_concat_9.h @@ -1,16 +1,15 @@ -// external/bonsai_stdlib/src/counted_string.cpp:184:0 - +// external/bonsai_stdlib/src/counted_string.cpp:158:0 link_internal counted_string -Concat(cs S0, cs S1, cs S2, cs S3, cs S4, cs S5, cs S6, cs S7, cs S8, memory_arena* Memory, umm ExtraChars = 0) +Concat( cs S0, cs S1, cs S2, cs S3, cs S4, cs S5, cs S6, cs S7, cs S8, memory_arena* Memory, umm ExtraChars = 0) { - umm TotalLength = S0.Count + S1.Count + S2.Count + S3.Count + S4.Count + S5.Count + S6.Count + S7.Count + S8.Count + 0; + umm TotalLength = S0.Count + S1.Count + S2.Count + S3.Count + S4.Count + S5.Count + S6.Count + S7.Count + S8.Count + 0; counted_string Result = { .Count = TotalLength + ExtraChars, .Start = AllocateProtection(char, Memory, TotalLength, False), }; u64 At = 0; - MemCopy((u8*)S0.Start, (u8*)Result.Start+At, S0.Count); + MemCopy((u8*)S0.Start, (u8*)Result.Start+At, S0.Count); At += S0.Count; MemCopy((u8*)S1.Start, (u8*)Result.Start+At, S1.Count); At += S1.Count; diff --git a/generated/take_release_sync_lod_element_buffer.h b/generated/take_release_sync_lod_element_buffer.h index 5da0d1378..fa744b46d 100644 --- a/generated/take_release_sync_lod_element_buffer.h +++ b/generated/take_release_sync_lod_element_buffer.h @@ -1,5 +1,4 @@ -// src/engine/mesh.cpp:247:0 - +// src/engine/mesh.cpp:121:0 link_internal untextured_3d_geometry_buffer * TakeOwnershipSync( lod_element_buffer *Buf, world_chunk_mesh_bitfield MeshBit) { @@ -80,7 +79,7 @@ DeallocateMeshes(lod_element_buffer *Buf, tiered_mesh_freelist* MeshFreelist) link_internal b32 HasGpuMesh(lod_element_buffer *Buf, world_chunk_mesh_bitfield MeshBit) { - b32 Result = (Buf->GpuBufferHandles[ToIndex(MeshBit)].VertexHandle != 0); + b32 Result = (Buf->GpuBufferHandles[ToIndex(MeshBit)].Handles[mesh_VertexHandle] != 0); return Result; } @@ -91,7 +90,7 @@ HasGpuMesh(lod_element_buffer *Buf) b32 Result = False; RangeIterator(MeshIndex, MeshIndex_Count) { - Result |= (Buf->GpuBufferHandles[MeshIndex].VertexHandle != 0); + Result |= (Buf->GpuBufferHandles[MeshIndex].Handles[mesh_VertexHandle] != 0); } return Result; } @@ -110,7 +109,7 @@ HasCpuMesh(lod_element_buffer *Buf) link_internal b32 HasMesh(lod_element_buffer *Buf, world_chunk_mesh_bitfield MeshBit) { - b32 Result = (Buf->E[ToIndex(MeshBit)] != 0); + b32 Result = (Buf->GpuBufferHandles[ToIndex(MeshBit)].Handles[0] != 0); return Result; } diff --git a/generated/tiered_mesh_freelist.h b/generated/tiered_mesh_freelist.h index 817241870..f1d04c3db 100644 --- a/generated/tiered_mesh_freelist.h +++ b/generated/tiered_mesh_freelist.h @@ -1,5 +1,4 @@ -// src/engine/mesh.h:26:0 - +// external/bonsai_stdlib/src/poof_functions.h:1185:0 struct tiered_mesh_freelist { mesh_freelist Start[TIERED_MESH_FREELIST_MAX_ELEMENTS]; @@ -16,6 +15,12 @@ GetPtr( tiered_mesh_freelist *Buf, umm Index) return Result; } +link_inline mesh_freelist* +TryGetPtr( tiered_mesh_freelist *Buf, umm Index) +{ + return GetPtr(Buf, Index); +} + link_inline mesh_freelist Get( tiered_mesh_freelist *Buf, umm Index) { diff --git a/generated/to_hex_64_272205387.h b/generated/to_hex_64_272205387.h index ca340352f..de9046443 100644 --- a/generated/to_hex_64_272205387.h +++ b/generated/to_hex_64_272205387.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/counted_string.cpp:822:0 - +// external/bonsai_stdlib/src/counted_string.cpp:823:0 link_internal cs ToHex( s64 Value ) { @@ -19,3 +18,4 @@ ToHex( r64 Value ) return Result; } + diff --git a/generated/to_string_primitive_803324607.h b/generated/to_string_primitive_803324607.h index acb1e8c7e..2c67cebe0 100644 --- a/generated/to_string_primitive_803324607.h +++ b/generated/to_string_primitive_803324607.h @@ -1,5 +1,4 @@ -// external/bonsai_stdlib/src/to_string.cpp:56:0 - +// external/bonsai_stdlib/src/to_string.cpp:3:0 link_internal cs ToString(s8 *Element) { @@ -61,3 +60,4 @@ ToString(f64 *Element) return Result; } + diff --git a/generated/to_string_texture.h b/generated/to_string_texture.h index 758025131..d7e468c7d 100644 --- a/generated/to_string_texture.h +++ b/generated/to_string_texture.h @@ -1,16 +1,16 @@ -// external/bonsai_stdlib/src/to_string.cpp:65:0 - +// external/bonsai_stdlib/src/to_string.cpp:36:0 link_internal cs ToString(texture *Element) { - cs Result = FSz("ID(%S) Dim(%S) Slices(%S) Channels(%S) IsDepthTexture(%S) Format(%S) DebugName(%S) Queued(%S) ", ToString(& Element->ID), - ToString(& Element->Dim), - ToString(& Element->Slices), - ToString(& Element->Channels), - ToString(& Element->IsDepthTexture), - ToString( Element->Format), - ToString(& Element->DebugName), - ToString(& Element->Queued)); + cs Result = FSz("ID(%S) Dim(%S) Slices(%S) Channels(%S) IsDepthTexture(%S) Format(%S) DebugName(%S) Queued(%S) ", ToString( & Element->ID) +, ToString( & Element->Dim) +, ToString( & Element->Slices) +, ToString( & Element->Channels) +, ToString( & Element->IsDepthTexture) +, ToString( Element->Format) +, ToString( & Element->DebugName) +, ToString( & Element->Queued) +); return Result; } diff --git a/generated/to_string_vector_240271411.h b/generated/to_string_vector_240271411.h index 561ded450..160e9978c 100644 --- a/generated/to_string_vector_240271411.h +++ b/generated/to_string_vector_240271411.h @@ -1,17 +1,17 @@ -// external/bonsai_stdlib/src/to_string.cpp:59:0 - +// external/bonsai_stdlib/src/to_string.cpp:18:0 link_internal cs ToString(v2 *Element) { - cs Result = FSz("%S %S ", ToString(&Element->E[0]) , ToString(&Element->E[1]) ); + cs Result = FSz("%S %S ", ToString(&Element->E[0]) , ToString(&Element->E[1]) ); return Result; } link_internal cs ToString(v2i *Element) { - cs Result = FSz("%S %S ", ToString(&Element->E[0]) , ToString(&Element->E[1]) ); + cs Result = FSz("%S %S ", ToString(&Element->E[0]) , ToString(&Element->E[1]) ); 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 251e47eff..7d209c6dd 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,5 +1,4 @@ -// src/engine/editor.h:678:0 - +// src/engine/editor.h:135:0 link_internal ui_toggle_button_group ToggleButtonGroup_engine_debug_view_mode( renderer_2d *Ui, window_layout *Window, @@ -10,14 +9,15 @@ ToggleButtonGroup_engine_debug_view_mode( renderer_2d *Ui, { ui_toggle_button_handle ButtonHandles[] = { - { CSz("Level"), UiId(Window, Cast(void*, Element), Cast(void*, "engine_debug_view_mode EngineDebugViewMode_Level")), EngineDebugViewMode_Level }, - { CSz("WorldEdit"), UiId(Window, Cast(void*, Element), Cast(void*, "engine_debug_view_mode EngineDebugViewMode_WorldEdit")), EngineDebugViewMode_WorldEdit }, - { CSz("Entities"), UiId(Window, Cast(void*, Element), Cast(void*, "engine_debug_view_mode EngineDebugViewMode_Entities")), EngineDebugViewMode_Entities }, - { CSz("Assets"), UiId(Window, Cast(void*, Element), Cast(void*, "engine_debug_view_mode EngineDebugViewMode_Assets")), EngineDebugViewMode_Assets }, - { CSz("WorldChunks"), UiId(Window, Cast(void*, Element), Cast(void*, "engine_debug_view_mode EngineDebugViewMode_WorldChunks")), EngineDebugViewMode_WorldChunks }, - { CSz("Textures"), UiId(Window, Cast(void*, Element), Cast(void*, "engine_debug_view_mode EngineDebugViewMode_Textures")), EngineDebugViewMode_Textures }, - { CSz("RenderSettings"), UiId(Window, Cast(void*, Element), Cast(void*, "engine_debug_view_mode EngineDebugViewMode_RenderSettings")), EngineDebugViewMode_RenderSettings }, - { CSz("EngineDebug"), UiId(Window, Cast(void*, Element), Cast(void*, "engine_debug_view_mode EngineDebugViewMode_EngineDebug")), EngineDebugViewMode_EngineDebug }, + { CSz("Level"), {}, UiId(Window, Cast(void*, Element), Cast(void*, "engine_debug_view_mode EngineDebugViewMode_Level")), EngineDebugViewMode_Level }, + { CSz("WorldEdit"), {}, UiId(Window, Cast(void*, Element), Cast(void*, "engine_debug_view_mode EngineDebugViewMode_WorldEdit")), EngineDebugViewMode_WorldEdit }, + { CSz("Entities"), {}, UiId(Window, Cast(void*, Element), Cast(void*, "engine_debug_view_mode EngineDebugViewMode_Entities")), EngineDebugViewMode_Entities }, + { CSz("Assets"), {}, UiId(Window, Cast(void*, Element), Cast(void*, "engine_debug_view_mode EngineDebugViewMode_Assets")), EngineDebugViewMode_Assets }, + { CSz("WorldChunks"), {}, UiId(Window, Cast(void*, Element), Cast(void*, "engine_debug_view_mode EngineDebugViewMode_WorldChunks")), EngineDebugViewMode_WorldChunks }, + { CSz("Textures"), {}, UiId(Window, Cast(void*, Element), Cast(void*, "engine_debug_view_mode EngineDebugViewMode_Textures")), EngineDebugViewMode_Textures }, + { CSz("RenderSettings"), {}, UiId(Window, Cast(void*, Element), Cast(void*, "engine_debug_view_mode EngineDebugViewMode_RenderSettings")), EngineDebugViewMode_RenderSettings }, + { CSz("EngineDebug"), {}, UiId(Window, Cast(void*, Element), Cast(void*, "engine_debug_view_mode EngineDebugViewMode_EngineDebug")), EngineDebugViewMode_EngineDebug }, + }; ui_toggle_button_handle_buffer ButtonBuffer = { @@ -25,7 +25,7 @@ ToggleButtonGroup_engine_debug_view_mode( renderer_2d *Ui, ButtonHandles }; - ui_toggle_button_group Result = DrawButtonGroupForEnum(Ui, &ButtonBuffer, GroupName, Cast(u32*, Element), Params, ui_toggle_button_group_flags(ExtraFlags|ToggleButtonGroupFlags_MultiSelectButtons)); + ui_toggle_button_group Result = DrawButtonGroupForEnum(Ui, &ButtonBuffer, GroupName, Cast(u32*, Element), Params, ui_toggle_button_group_flags(ExtraFlags|ToggleButtonGroupFlags_TypeMultiSelectButton)); return Result; } diff --git a/generated/triple_buffered_HQIb5E82.h b/generated/triple_buffered_HQIb5E82.h new file mode 100644 index 000000000..f930a68ba --- /dev/null +++ b/generated/triple_buffered_HQIb5E82.h @@ -0,0 +1,49 @@ +// external/bonsai_stdlib/src/gpu_mapped_buffer.h:2:0 + + +struct triple_buffered_gpu_mapped_element_buffer +{ + u32 CurrentIndex; + gpu_element_buffer_handles Handles[3]; + untextured_3d_geometry_buffer Buffer; +}; + +link_internal gpu_element_buffer_handles * +CurrentHandles( triple_buffered_gpu_mapped_element_buffer *Buf ) +{ + Assert(Buf->CurrentIndex < 3); + gpu_element_buffer_handles *Result = Buf->Handles + Buf->CurrentIndex; + return Result; +} + +link_internal void +MapGpuBuffer( triple_buffered_gpu_mapped_element_buffer *Buf ) +{ + Buf->CurrentIndex = (Buf->CurrentIndex + 1) % 3; + Buf->Buffer = MapGpuBuffer_gpu_mapped_element_buffer(CurrentHandles(Buf)).Buffer; +} + +link_internal void +DrawBuffer( triple_buffered_gpu_mapped_element_buffer *Buf, v2 *ScreenDim ) +{ + auto Handles = CurrentHandles(Buf); + // TODO(Jesse): Probably smooth this out .. + gpu_mapped_element_buffer SyntheticBuffer = { + *Handles, + Buf->Buffer, + }; + + DrawBuffer(&SyntheticBuffer, ScreenDim); + + *Handles = SyntheticBuffer.Handles; +} + +link_internal void +AllocateGpuBuffer( triple_buffered_gpu_mapped_element_buffer *Buf, data_type Type, u32 ElementCount ) +{ + AllocateGpuBuffer_gpu_mapped_element_buffer(Buf->Handles+0, Type, ElementCount); + AllocateGpuBuffer_gpu_mapped_element_buffer(Buf->Handles+1, Type, ElementCount); + AllocateGpuBuffer_gpu_mapped_element_buffer(Buf->Handles+2, Type, ElementCount); + Buf->Buffer.End = ElementCount; +} + diff --git a/generated/triple_buffered_iGeuhioE.h b/generated/triple_buffered_iGeuhioE.h new file mode 100644 index 000000000..6df75d82a --- /dev/null +++ b/generated/triple_buffered_iGeuhioE.h @@ -0,0 +1,49 @@ +// external/bonsai_stdlib/src/gpu_mapped_buffer.h:2:0 + + +struct triple_buffered_gpu_mapped_ui_buffer +{ + u32 CurrentIndex; + gpu_element_buffer_handles Handles[3]; + ui_geometry_buffer Buffer; +}; + +link_internal gpu_element_buffer_handles * +CurrentHandles( triple_buffered_gpu_mapped_ui_buffer *Buf ) +{ + Assert(Buf->CurrentIndex < 3); + gpu_element_buffer_handles *Result = Buf->Handles + Buf->CurrentIndex; + return Result; +} + +link_internal void +MapGpuBuffer( triple_buffered_gpu_mapped_ui_buffer *Buf ) +{ + Buf->CurrentIndex = (Buf->CurrentIndex + 1) % 3; + Buf->Buffer = MapGpuBuffer_gpu_mapped_ui_buffer(CurrentHandles(Buf)).Buffer; +} + +link_internal void +DrawBuffer( triple_buffered_gpu_mapped_ui_buffer *Buf, v2 *ScreenDim ) +{ + auto Handles = CurrentHandles(Buf); + // TODO(Jesse): Probably smooth this out .. + gpu_mapped_ui_buffer SyntheticBuffer = { + *Handles, + Buf->Buffer, + }; + + DrawBuffer(&SyntheticBuffer, ScreenDim); + + *Handles = SyntheticBuffer.Handles; +} + +link_internal void +AllocateGpuBuffer( triple_buffered_gpu_mapped_ui_buffer *Buf, data_type Type, u32 ElementCount ) +{ + AllocateGpuBuffer_gpu_mapped_ui_buffer(Buf->Handles+0, Type, ElementCount); + AllocateGpuBuffer_gpu_mapped_ui_buffer(Buf->Handles+1, Type, ElementCount); + AllocateGpuBuffer_gpu_mapped_ui_buffer(Buf->Handles+2, Type, ElementCount); + Buf->Buffer.End = ElementCount; +} + diff --git a/generated/tuple_822959015.h b/generated/tuple_822959015.h index 58cb3eb40..b9129c574 100644 --- a/generated/tuple_822959015.h +++ b/generated/tuple_822959015.h @@ -1,22 +1,23 @@ -// external/bonsai_stdlib/src/counted_string.cpp:29:0 - +// external/bonsai_stdlib/src/poof_functions.h:682:0 struct tuple_cs_cs { - cs E0; + cs E0; cs E1; + }; /* poof_bind( TupleType <- { tuple_(Types.map.sep(_) (T) {(T.name)} } )*/ /* gen_constructor(TupleType) */ link_internal tuple_cs_cs -Tuple( cs E0, cs E1 ) +Tuple( cs E0, cs E1 ) { /* TupleType Result = */ tuple_cs_cs Result = { - .E0 = E0, + .E0 = E0, .E1 = E1, + }; return Result; } diff --git a/generated/vertex_data_functions_v3.h b/generated/vertex_data_functions_v3.h index 0672cb020..193dcd646 100644 --- a/generated/vertex_data_functions_v3.h +++ b/generated/vertex_data_functions_v3.h @@ -1,5 +1,4 @@ -// src/engine/voxel_face.h:215:0 - +// src/engine/voxel_face.h:72:0 inline void RightFaceVertexData( v3 MinP, v3 Diameter, v3 *Result) { @@ -19,8 +18,6 @@ RightFaceVertexData( v3 MinP, v3 Diameter, v3 *Result) v3 Temp[] = { P2, P1, P0, P2, P3, P1 }; MemCopy((u8*)Temp, (u8*)Result, sizeof(Temp)); - - return; } inline void diff --git a/generated/vertex_data_functions_v3_u8.h b/generated/vertex_data_functions_v3_u8.h index 898cb365c..d0f7a2ac1 100644 --- a/generated/vertex_data_functions_v3_u8.h +++ b/generated/vertex_data_functions_v3_u8.h @@ -1,5 +1,4 @@ -// src/engine/voxel_face.h:218:0 - +// src/engine/voxel_face.h:72:0 inline void RightFaceVertexData( v3_u8 MinP, v3 Diameter, v3_u8 *Result) { @@ -19,8 +18,6 @@ RightFaceVertexData( v3_u8 MinP, v3 Diameter, v3_u8 *Result) v3_u8 Temp[] = { P2, P1, P0, P2, P3, P1 }; MemCopy((u8*)Temp, (u8*)Result, sizeof(Temp)); - - return; } inline void diff --git a/generated/world_chunk_mesh_functions_untextured_3d_geometry_buffer_v3.h b/generated/world_chunk_mesh_functions_untextured_3d_geometry_buffer_v3.h index b6191b752..3b876b512 100644 --- a/generated/world_chunk_mesh_functions_untextured_3d_geometry_buffer_v3.h +++ b/generated/world_chunk_mesh_functions_untextured_3d_geometry_buffer_v3.h @@ -1,129 +1,325 @@ -// src/engine/world_chunk.cpp:2057:0 - +// src/engine/world_chunk.cpp:1485:0 link_internal void -BuildWorldChunkMeshFromMarkedVoxels_Greedy_v3( voxel *Voxels, - v3i SrcChunkDim, +BuildWorldChunkMeshFromMarkedVoxels_Naieve_v3( voxel *Voxels, + u64 *FaceMasks, + v3i SrcChunkDim, - v3i SrcChunkMin, - v3i SrcChunkMax, + v3i SrcChunkMin, + v3i SrcChunkMax, - // TODO(Jesse)(immediate, poof): removing the braces here causes poof to bail .. why? - untextured_3d_geometry_buffer *DestGeometry, - untextured_3d_geometry_buffer *DestTransparentGeometry, - memory_arena *TempMemory, + // TODO(Jesse)(immediate, poof): @poof_parens_bug + untextured_3d_geometry_buffer *Dest, + untextured_3d_geometry_buffer *Unused, // NOTE(Jesse): This is so we can offset vertices such that we center // entity models about 0 and rotation works properly. - v3 VertexOffset = {}) + v3 VertexOffset = {}) { /* HISTOGRAM_FUNCTION(); */ TIMED_FUNCTION(); - Assert(DestGeometry->Type == DataType_v3); + Assert(SrcChunkMin == V3i(0)); + Assert(SrcChunkMax == V3i(0)); + Assert(SrcChunkDim == V3i(64, 66, 66)); v3 VertexData[VERTS_PER_FACE]; + v3 NormalData[VERTS_PER_FACE]; matl Materials[VERTS_PER_FACE]; - auto SrcMinP = SrcChunkMin; - auto MaxDim = Min(SrcChunkDim, SrcChunkMax); - - auto TmpDim = MaxDim-SrcMinP; - - u32 TmpVol = u32(Volume(TmpDim)); - auto TempVoxels = Allocate(voxel, TempMemory, TmpVol); - - // NOTE(Jesse): It's necessary to copy the voxel data because the meshing - // algorithm unsets the face flags for the voxels instead of marking them - // as being processed. When complete, there should be no face-flags left on - // this data. (This is not asserted, but maybe should be?) - // - // TODO(Jesse): Assert there are no face flags left in this copy at the end of - // this process? - // - // TODO(Jesse): Copy data into here as the algorithm proceedes instead of in - // one shot at the start? - // - u32 TmpIndex = 0; - for ( s32 zIndex = 0; zIndex < TmpDim.z ; ++zIndex ) + for ( s32 zBlock = 1; zBlock < SrcChunkDim.z-1; ++zBlock ) { - for ( s32 yIndex = 0; yIndex < TmpDim.y ; ++yIndex ) + s32 z = zBlock-1; + for ( s32 yBlock = 1; yBlock < SrcChunkDim.y-1; ++yBlock ) { - for ( s32 xIndex = 0; xIndex < TmpDim.x ; ++xIndex ) + s32 y = yBlock-1; + s32 OccupancyIndex = GetIndex(yBlock, zBlock, SrcChunkDim.yz); + + u64 LeftFaces = FaceMasks[(OccupancyIndex*6)+0]; + u64 RightFaces = FaceMasks[(OccupancyIndex*6)+1]; + u64 FrontFaces = FaceMasks[(OccupancyIndex*6)+2]; + u64 BackFaces = FaceMasks[(OccupancyIndex*6)+3]; + u64 TopFaces = FaceMasks[(OccupancyIndex*6)+4]; + u64 BotFaces = FaceMasks[(OccupancyIndex*6)+5]; + + v3 Dim = V3(1.f, 1.f, 1.f); + + f32 BendStrength = 8.f; + f32 NormalFactor = 1.f/BendStrength; + + u64 BaseVoxelOffset = u64(GetIndex(0, yBlock, zBlock, SrcChunkDim)); + while (LeftFaces) { - voxel_position SrcP = SrcMinP + Voxel_Position(xIndex, yIndex, zIndex); - s32 SrcIndex = GetIndex(SrcP, SrcChunkDim); - /* Assert(TmpIndex < TmpVol); */ - TempVoxels[TmpIndex] = Voxels[SrcIndex]; - TmpIndex++; + u64 This = UnsetLeastSignificantSetBit(&LeftFaces); + u64 xOffset = GetIndexOfSingleSetBit(This); + v3 P = V3(s32(xOffset), y, z); + + u16 RGB = Voxels[BaseVoxelOffset+xOffset].RGBColor; + + u16 PNormal = Voxels[BaseVoxelOffset+xOffset].Normal; + v3 Normal = Normalize((UnpackV3_15b(PNormal)) + (V3(-1,0,0) * NormalFactor)); + /* Assert(Length(Normal) > 0.f); */ + + Assert(BufferHasRoomFor(Dest, VERTS_PER_FACE)); + + v3 *DestVerts = Cast( v3*, Dest->Verts) + Dest->At; + v3 *DestNormals = Cast( v3*, Dest->Normals) + Dest->At; + vertex_material *DestMats = Dest->Mat + Dest->At; + + LeftFaceVertexData( VertexOffset+P, Dim, DestVerts); + FillArray(Normal, DestNormals, VERTS_PER_FACE); + FillArray(VertexMaterial(RGB, 0.f, 0.f), DestMats, VERTS_PER_FACE); + Dest->At += VERTS_PER_FACE; } - } - } - Assert(TmpIndex == TmpVol); + while (RightFaces) + { + u64 This = UnsetLeastSignificantSetBit(&RightFaces); + u64 xOffset = GetIndexOfSingleSetBit(This); + v3 P = V3(s32(xOffset), y, z); + u16 RGB = Voxels[BaseVoxelOffset+xOffset].RGBColor; - s32 Index = 0; - for ( s32 z = 0; z < TmpDim.z ; ++z ) - { - for ( s32 y = 0; y < TmpDim.y ; ++y ) - { - for ( s32 x = 0; x < TmpDim.x ; ++x ) + u16 PNormal = Voxels[BaseVoxelOffset+xOffset].Normal; + v3 Normal = Normalize((UnpackV3_15b(PNormal)) + (V3(1,0,0) * NormalFactor)); + /* Assert(Length(Normal) > 0.f); */ + + Assert(BufferHasRoomFor(Dest, VERTS_PER_FACE)); + + v3 *DestVerts = Cast( v3*, Dest->Verts) + Dest->At; + v3 *DestNormals = Cast( v3*, Dest->Normals) + Dest->At; + vertex_material *DestMats = Dest->Mat + Dest->At; + + RightFaceVertexData( VertexOffset+P, Dim, DestVerts); + FillArray(Normal, DestNormals, VERTS_PER_FACE); + FillArray(VertexMaterial(RGB, 0.f, 0.f), DestMats, VERTS_PER_FACE); + Dest->At += VERTS_PER_FACE; + } + + while (FrontFaces) + { + u64 This = UnsetLeastSignificantSetBit(&FrontFaces); + u64 xOffset = GetIndexOfSingleSetBit(This); + v3 P = V3(s32(xOffset), y, z); + u16 RGB = Voxels[BaseVoxelOffset+xOffset].RGBColor; + + u16 PNormal = Voxels[BaseVoxelOffset+xOffset].Normal; + v3 Normal = Normalize((UnpackV3_15b(PNormal)) + (V3(0,1,0) * NormalFactor)); + /* Assert(Length(Normal) > 0.f); */ + + Assert(BufferHasRoomFor(Dest, VERTS_PER_FACE)); + + v3 *DestVerts = Cast( v3*, Dest->Verts) + Dest->At; + v3 *DestNormals = Cast( v3*, Dest->Normals) + Dest->At; + vertex_material *DestMats = Dest->Mat + Dest->At; + + FrontFaceVertexData( VertexOffset+P, Dim, DestVerts); + FillArray(Normal, DestNormals, VERTS_PER_FACE); + FillArray(VertexMaterial(RGB, 0.f, 0.f), DestMats, VERTS_PER_FACE); + Dest->At += VERTS_PER_FACE; + } + + while (BackFaces) + { + u64 This = UnsetLeastSignificantSetBit(&BackFaces); + u64 xOffset = GetIndexOfSingleSetBit(This); + v3 P = V3(s32(xOffset), y, z); + u16 RGB = Voxels[BaseVoxelOffset+xOffset].RGBColor; + + u16 PNormal = Voxels[BaseVoxelOffset+xOffset].Normal; + v3 Normal = Normalize((UnpackV3_15b(PNormal)) + (V3(0,-1,0) * NormalFactor)); + /* Assert(Length(Normal) > 0.f); */ + + Assert(BufferHasRoomFor(Dest, VERTS_PER_FACE)); + + v3 *DestVerts = Cast( v3*, Dest->Verts) + Dest->At; + v3 *DestNormals = Cast( v3*, Dest->Normals) + Dest->At; + vertex_material *DestMats = Dest->Mat + Dest->At; + + BackFaceVertexData( VertexOffset+P, Dim, DestVerts); + FillArray(Normal, DestNormals, VERTS_PER_FACE); + FillArray(VertexMaterial(RGB, 0.f, 0.f), DestMats, VERTS_PER_FACE); + Dest->At += VERTS_PER_FACE; + } + + while (TopFaces) { - v3i TmpVoxP = V3i(x,y,z); - voxel *Voxel = TempVoxels + Index; - - FillArray(VertexMaterial(Voxel->Color, Voxel->Transparency, 0), Materials, VERTS_PER_FACE); - - untextured_3d_geometry_buffer *Dest = {}; - if (Voxel->Transparency) { Dest = DestTransparentGeometry; } else { Dest = DestGeometry; } - - if (Dest) - { - if (Voxel->Flags & Voxel_RightFace) - { - v3 Dim = DoXStepping(TempVoxels, TmpDim, TmpVoxP, Voxel_RightFace, Voxel->Color, Voxel->Transparency); - RightFaceVertexData( VertexOffset+TmpVoxP, Dim, VertexData); - 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, 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, 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, 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, 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, v3_BackFaceNormalData, Materials); - } - } - - ++Index; + u64 This = UnsetLeastSignificantSetBit(&TopFaces); + u64 xOffset = GetIndexOfSingleSetBit(This); + v3 P = V3(s32(xOffset), y, z); + u16 RGB = Voxels[BaseVoxelOffset+xOffset].RGBColor; + + u16 PNormal = Voxels[BaseVoxelOffset+xOffset].Normal; + v3 Normal = Normalize((UnpackV3_15b(PNormal)) + (V3(0,0,1) * NormalFactor)); + /* Assert(Length(Normal) > 0.f); */ + + Assert(BufferHasRoomFor(Dest, VERTS_PER_FACE)); + + v3 *DestVerts = Cast( v3*, Dest->Verts) + Dest->At; + v3 *DestNormals = Cast( v3*, Dest->Normals) + Dest->At; + vertex_material *DestMats = Dest->Mat + Dest->At; + + TopFaceVertexData( VertexOffset+P, Dim, DestVerts); + FillArray(Normal, DestNormals, VERTS_PER_FACE); + FillArray(VertexMaterial(RGB, 0.f, 0.f), DestMats, VERTS_PER_FACE); + Dest->At += VERTS_PER_FACE; } + + while (BotFaces) + { + u64 This = UnsetLeastSignificantSetBit(&BotFaces); + u32 xOffset = GetIndexOfSingleSetBit(This); + v3 P = V3(s32(xOffset), y, z); + u16 RGB = Voxels[BaseVoxelOffset+xOffset].RGBColor; + + u16 PNormal = Voxels[BaseVoxelOffset+xOffset].Normal; + v3 Normal = Normalize((UnpackV3_15b(PNormal)) + (V3(0,0,-1) * NormalFactor)); + /* Assert(Length(Normal) > 0.f); */ + + Assert(BufferHasRoomFor(Dest, VERTS_PER_FACE)); + + v3 *DestVerts = Cast( v3*, Dest->Verts) + Dest->At; + v3 *DestNormals = Cast( v3*, Dest->Normals) + Dest->At; + vertex_material *DestMats = Dest->Mat + Dest->At; + + BottomFaceVertexData( VertexOffset+P, Dim, DestVerts); + FillArray(Normal, DestNormals, VERTS_PER_FACE); + FillArray(VertexMaterial(RGB, 0.f, 0.f), DestMats, VERTS_PER_FACE); + Dest->At += VERTS_PER_FACE; + } + + + } + } +} + + +link_internal void +BuildWorldChunkMeshFromMarkedVoxels_Greedy_v3( voxel *Voxels, + v3i SrcChunkDim, + + v3i SrcChunkMin, + v3i SrcChunkMax, + + // TODO(Jesse)(immediate, poof, @poof_parens_bug): removing the parens here causes poof to bail .. why? + 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 + // entity models about 0 and rotation works properly. + v3 VertexOffset = {}) +{ + /* HISTOGRAM_FUNCTION(); */ + TIMED_FUNCTION(); + + NotImplemented; +/* Assert(DestGeometry->Type == DataType_(vert_t.name)); */ + +/* vert_t.name VertexData[VERTS_PER_FACE]; */ +/* matl Materials[VERTS_PER_FACE]; */ + +/* auto SrcMinP = SrcChunkMin; */ +/* auto MaxDim = Min(SrcChunkDim, SrcChunkMax); */ + +/* auto TmpDim = MaxDim-SrcMinP; */ + +/* u32 TmpVol = u32(Volume(TmpDim)); */ +/* auto TempVoxels = Allocate(voxel, TempMemory, TmpVol); */ + +/* // NOTE(Jesse): It's necessary to copy the voxel data because the meshing */ +/* // algorithm unsets the face flags for the voxels instead of marking them */ +/* // as being processed. When complete, there should be no face-flags left on */ +/* // this data. (This is not asserted, but maybe should be?) */ +/* // */ +/* // TODO(Jesse): Assert there are no face flags left in this copy at the end of */ +/* // this process? */ +/* // */ +/* // TODO(Jesse): Copy data into here as the algorithm proceedes instead of in */ +/* // one shot at the start? */ +/* // */ +/* u32 TmpIndex = 0; */ +/* for ( s32 zIndex = 0; zIndex < TmpDim.z ; ++zIndex ) */ +/* { */ +/* for ( s32 yIndex = 0; yIndex < TmpDim.y ; ++yIndex ) */ +/* { */ +/* for ( s32 xIndex = 0; xIndex < TmpDim.x ; ++xIndex ) */ +/* { */ +/* voxel_position SrcP = SrcMinP + Voxel_Position(xIndex, yIndex, zIndex); */ +/* s32 SrcIndex = GetIndex(SrcP, SrcChunkDim); */ +/* /1* Assert(TmpIndex < TmpVol); *1/ */ +/* TempVoxels[TmpIndex] = Voxels[SrcIndex]; */ +/* TmpIndex++; */ +/* } */ +/* } */ +/* } */ + +/* Assert(TmpIndex == TmpVol); */ + +/* s32 Index = 0; */ +/* for ( s32 z = 0; z < TmpDim.z ; ++z ) */ +/* { */ +/* for ( s32 y = 0; y < TmpDim.y ; ++y ) */ +/* { */ +/* for ( s32 x = 0; x < TmpDim.x ; ++x ) */ +/* { */ +/* v3i TmpVoxP = V3i(x,y,z); */ +/* voxel *Voxel = TempVoxels + Index; */ + +/* FillArray(VertexMaterial(Voxel->Color, Voxel->Transparency, 0), Materials, VERTS_PER_FACE); */ + +/* (buffer_t.name) *Dest = {}; */ +/* if (Voxel->Transparency) { Dest = DestTransparentGeometry; } else { Dest = DestGeometry; } */ + +/* if (Dest) */ +/* { */ +/* if (Voxel->Flags & Voxel_RightFace) */ +/* { */ +/* v3 Dim = DoXStepping(TempVoxels, TmpDim, TmpVoxP, Voxel_RightFace, Voxel->Color, Voxel->Transparency); */ +/* RightFaceVertexData( VertexOffset+TmpVoxP, Dim, VertexData); */ +/* 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, (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, (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, (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, (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, (vert_t.name)_BackFaceNormalData, Materials); */ +/* } */ +/* } */ + +/* ++Index; */ +/* } */ +/* } */ +/* } */ + +/* if (DestGeometry) DestGeometry->Timestamp = __rdtsc(); */ +/* if (DestTransparentGeometry) DestTransparentGeometry->Timestamp = __rdtsc(); */ - if (DestGeometry) DestGeometry->Timestamp = __rdtsc(); - if (DestTransparentGeometry) DestTransparentGeometry->Timestamp = __rdtsc(); } link_internal void @@ -133,7 +329,8 @@ BuildWorldChunkMeshFromMarkedVoxels_Greedy_v3( vox_data *Vox, memory_arena *TempMemory, v3 VertexOffset = {}) { - BuildWorldChunkMeshFromMarkedVoxels_Greedy_v3(Vox->ChunkData->Voxels, Vox->ChunkData->Dim, {}, Vox->ChunkData->Dim, DestGeometry, DestTransparentGeometry, TempMemory, VertexOffset); + NotImplemented; + /* BuildWorldChunkMeshFromMarkedVoxels_Greedy_(vert_t.name)(Vox->ChunkData->Voxels, Vox->ChunkData->Dim, {}, Vox->ChunkData->Dim, DestGeometry, DestTransparentGeometry, TempMemory, VertexOffset); */ } link_internal void @@ -431,11 +628,7 @@ BuildWorldChunkMeshFromMarkedVoxels_Naieve_v3( voxel *Voxels, /* // TODO(Jesse): This copy could be avoided in multiple ways, and should be. */ /* /1* FillColorArray(Voxel->Color, FaceColors, ColorPallette, VERTS_PER_FACE); *1/ */ -/* /1* #if VOXEL_DEBUG_COLOR *1/ */ - /* /1* v3 Color = Abs(Voxel->DebugColor); *1/ */ -/* /1* #else *1/ */ /* /1* v3 Color = GetColorData(Voxel->Color); *1/ */ -/* /1* #endif *1/ */ /* f32 Trans = (f32)Voxel->Transparency / 255.f; */ /* FillArray(VertexMaterial(Voxel->Color, Trans, 0.f), Materials, VERTS_PER_FACE); */ diff --git a/generated/world_chunk_mesh_functions_untextured_3d_geometry_buffer_v3_u8.h b/generated/world_chunk_mesh_functions_untextured_3d_geometry_buffer_v3_u8.h index 1c1b64267..a87281aea 100644 --- a/generated/world_chunk_mesh_functions_untextured_3d_geometry_buffer_v3_u8.h +++ b/generated/world_chunk_mesh_functions_untextured_3d_geometry_buffer_v3_u8.h @@ -1,129 +1,325 @@ -// src/engine/world_chunk.cpp:2060:0 - +// src/engine/world_chunk.cpp:1485:0 link_internal void -BuildWorldChunkMeshFromMarkedVoxels_Greedy_v3_u8( voxel *Voxels, - v3i SrcChunkDim, +BuildWorldChunkMeshFromMarkedVoxels_Naieve_v3_u8( voxel *Voxels, + u64 *FaceMasks, + v3i SrcChunkDim, - v3i SrcChunkMin, - v3i SrcChunkMax, + v3i SrcChunkMin, + v3i SrcChunkMax, - // TODO(Jesse)(immediate, poof): removing the braces here causes poof to bail .. why? - untextured_3d_geometry_buffer *DestGeometry, - untextured_3d_geometry_buffer *DestTransparentGeometry, - memory_arena *TempMemory, + // TODO(Jesse)(immediate, poof): @poof_parens_bug + untextured_3d_geometry_buffer *Dest, + untextured_3d_geometry_buffer *Unused, // NOTE(Jesse): This is so we can offset vertices such that we center // entity models about 0 and rotation works properly. - v3_u8 VertexOffset = {}) + v3_u8 VertexOffset = {}) { /* HISTOGRAM_FUNCTION(); */ TIMED_FUNCTION(); - Assert(DestGeometry->Type == DataType_v3_u8); + Assert(SrcChunkMin == V3i(0)); + Assert(SrcChunkMax == V3i(0)); + Assert(SrcChunkDim == V3i(64, 66, 66)); v3_u8 VertexData[VERTS_PER_FACE]; + v3_u8 NormalData[VERTS_PER_FACE]; matl Materials[VERTS_PER_FACE]; - auto SrcMinP = SrcChunkMin; - auto MaxDim = Min(SrcChunkDim, SrcChunkMax); - - auto TmpDim = MaxDim-SrcMinP; - - u32 TmpVol = u32(Volume(TmpDim)); - auto TempVoxels = Allocate(voxel, TempMemory, TmpVol); - - // NOTE(Jesse): It's necessary to copy the voxel data because the meshing - // algorithm unsets the face flags for the voxels instead of marking them - // as being processed. When complete, there should be no face-flags left on - // this data. (This is not asserted, but maybe should be?) - // - // TODO(Jesse): Assert there are no face flags left in this copy at the end of - // this process? - // - // TODO(Jesse): Copy data into here as the algorithm proceedes instead of in - // one shot at the start? - // - u32 TmpIndex = 0; - for ( s32 zIndex = 0; zIndex < TmpDim.z ; ++zIndex ) + for ( s32 zBlock = 1; zBlock < SrcChunkDim.z-1; ++zBlock ) { - for ( s32 yIndex = 0; yIndex < TmpDim.y ; ++yIndex ) + s32 z = zBlock-1; + for ( s32 yBlock = 1; yBlock < SrcChunkDim.y-1; ++yBlock ) { - for ( s32 xIndex = 0; xIndex < TmpDim.x ; ++xIndex ) + s32 y = yBlock-1; + s32 OccupancyIndex = GetIndex(yBlock, zBlock, SrcChunkDim.yz); + + u64 LeftFaces = FaceMasks[(OccupancyIndex*6)+0]; + u64 RightFaces = FaceMasks[(OccupancyIndex*6)+1]; + u64 FrontFaces = FaceMasks[(OccupancyIndex*6)+2]; + u64 BackFaces = FaceMasks[(OccupancyIndex*6)+3]; + u64 TopFaces = FaceMasks[(OccupancyIndex*6)+4]; + u64 BotFaces = FaceMasks[(OccupancyIndex*6)+5]; + + v3 Dim = V3(1.f, 1.f, 1.f); + + f32 BendStrength = 8.f; + f32 NormalFactor = 1.f/BendStrength; + + u64 BaseVoxelOffset = u64(GetIndex(0, yBlock, zBlock, SrcChunkDim)); + while (LeftFaces) { - voxel_position SrcP = SrcMinP + Voxel_Position(xIndex, yIndex, zIndex); - s32 SrcIndex = GetIndex(SrcP, SrcChunkDim); - /* Assert(TmpIndex < TmpVol); */ - TempVoxels[TmpIndex] = Voxels[SrcIndex]; - TmpIndex++; + u64 This = UnsetLeastSignificantSetBit(&LeftFaces); + u64 xOffset = GetIndexOfSingleSetBit(This); + v3 P = V3(s32(xOffset), y, z); + + u16 RGB = Voxels[BaseVoxelOffset+xOffset].RGBColor; + + u16 PNormal = Voxels[BaseVoxelOffset+xOffset].Normal; + v3 Normal = Normalize((UnpackV3_15b(PNormal)) + (V3(-1,0,0) * NormalFactor)); + /* Assert(Length(Normal) > 0.f); */ + + Assert(BufferHasRoomFor(Dest, VERTS_PER_FACE)); + + 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; + + LeftFaceVertexData( VertexOffset+P, Dim, DestVerts); + FillArray(Normal, DestNormals, VERTS_PER_FACE); + FillArray(VertexMaterial(RGB, 0.f, 0.f), DestMats, VERTS_PER_FACE); + Dest->At += VERTS_PER_FACE; } - } - } - Assert(TmpIndex == TmpVol); + while (RightFaces) + { + u64 This = UnsetLeastSignificantSetBit(&RightFaces); + u64 xOffset = GetIndexOfSingleSetBit(This); + v3 P = V3(s32(xOffset), y, z); + u16 RGB = Voxels[BaseVoxelOffset+xOffset].RGBColor; - s32 Index = 0; - for ( s32 z = 0; z < TmpDim.z ; ++z ) - { - for ( s32 y = 0; y < TmpDim.y ; ++y ) - { - for ( s32 x = 0; x < TmpDim.x ; ++x ) + u16 PNormal = Voxels[BaseVoxelOffset+xOffset].Normal; + v3 Normal = Normalize((UnpackV3_15b(PNormal)) + (V3(1,0,0) * NormalFactor)); + /* Assert(Length(Normal) > 0.f); */ + + Assert(BufferHasRoomFor(Dest, VERTS_PER_FACE)); + + 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; + + RightFaceVertexData( VertexOffset+P, Dim, DestVerts); + FillArray(Normal, DestNormals, VERTS_PER_FACE); + FillArray(VertexMaterial(RGB, 0.f, 0.f), DestMats, VERTS_PER_FACE); + Dest->At += VERTS_PER_FACE; + } + + while (FrontFaces) + { + u64 This = UnsetLeastSignificantSetBit(&FrontFaces); + u64 xOffset = GetIndexOfSingleSetBit(This); + v3 P = V3(s32(xOffset), y, z); + u16 RGB = Voxels[BaseVoxelOffset+xOffset].RGBColor; + + u16 PNormal = Voxels[BaseVoxelOffset+xOffset].Normal; + v3 Normal = Normalize((UnpackV3_15b(PNormal)) + (V3(0,1,0) * NormalFactor)); + /* Assert(Length(Normal) > 0.f); */ + + Assert(BufferHasRoomFor(Dest, VERTS_PER_FACE)); + + 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; + + FrontFaceVertexData( VertexOffset+P, Dim, DestVerts); + FillArray(Normal, DestNormals, VERTS_PER_FACE); + FillArray(VertexMaterial(RGB, 0.f, 0.f), DestMats, VERTS_PER_FACE); + Dest->At += VERTS_PER_FACE; + } + + while (BackFaces) + { + u64 This = UnsetLeastSignificantSetBit(&BackFaces); + u64 xOffset = GetIndexOfSingleSetBit(This); + v3 P = V3(s32(xOffset), y, z); + u16 RGB = Voxels[BaseVoxelOffset+xOffset].RGBColor; + + u16 PNormal = Voxels[BaseVoxelOffset+xOffset].Normal; + v3 Normal = Normalize((UnpackV3_15b(PNormal)) + (V3(0,-1,0) * NormalFactor)); + /* Assert(Length(Normal) > 0.f); */ + + Assert(BufferHasRoomFor(Dest, VERTS_PER_FACE)); + + 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; + + BackFaceVertexData( VertexOffset+P, Dim, DestVerts); + FillArray(Normal, DestNormals, VERTS_PER_FACE); + FillArray(VertexMaterial(RGB, 0.f, 0.f), DestMats, VERTS_PER_FACE); + Dest->At += VERTS_PER_FACE; + } + + while (TopFaces) { - v3i TmpVoxP = V3i(x,y,z); - voxel *Voxel = TempVoxels + Index; - - FillArray(VertexMaterial(Voxel->Color, Voxel->Transparency, 0), Materials, VERTS_PER_FACE); - - untextured_3d_geometry_buffer *Dest = {}; - if (Voxel->Transparency) { Dest = DestTransparentGeometry; } else { Dest = DestGeometry; } - - if (Dest) - { - if (Voxel->Flags & Voxel_RightFace) - { - v3 Dim = DoXStepping(TempVoxels, TmpDim, TmpVoxP, Voxel_RightFace, Voxel->Color, Voxel->Transparency); - RightFaceVertexData( VertexOffset+TmpVoxP, Dim, VertexData); - 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, 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, 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, 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, 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, v3_u8_BackFaceNormalData, Materials); - } - } - - ++Index; + u64 This = UnsetLeastSignificantSetBit(&TopFaces); + u64 xOffset = GetIndexOfSingleSetBit(This); + v3 P = V3(s32(xOffset), y, z); + u16 RGB = Voxels[BaseVoxelOffset+xOffset].RGBColor; + + u16 PNormal = Voxels[BaseVoxelOffset+xOffset].Normal; + v3 Normal = Normalize((UnpackV3_15b(PNormal)) + (V3(0,0,1) * NormalFactor)); + /* Assert(Length(Normal) > 0.f); */ + + Assert(BufferHasRoomFor(Dest, VERTS_PER_FACE)); + + 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; + + TopFaceVertexData( VertexOffset+P, Dim, DestVerts); + FillArray(Normal, DestNormals, VERTS_PER_FACE); + FillArray(VertexMaterial(RGB, 0.f, 0.f), DestMats, VERTS_PER_FACE); + Dest->At += VERTS_PER_FACE; } + + while (BotFaces) + { + u64 This = UnsetLeastSignificantSetBit(&BotFaces); + u32 xOffset = GetIndexOfSingleSetBit(This); + v3 P = V3(s32(xOffset), y, z); + u16 RGB = Voxels[BaseVoxelOffset+xOffset].RGBColor; + + u16 PNormal = Voxels[BaseVoxelOffset+xOffset].Normal; + v3 Normal = Normalize((UnpackV3_15b(PNormal)) + (V3(0,0,-1) * NormalFactor)); + /* Assert(Length(Normal) > 0.f); */ + + Assert(BufferHasRoomFor(Dest, VERTS_PER_FACE)); + + 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; + + BottomFaceVertexData( VertexOffset+P, Dim, DestVerts); + FillArray(Normal, DestNormals, VERTS_PER_FACE); + FillArray(VertexMaterial(RGB, 0.f, 0.f), DestMats, VERTS_PER_FACE); + Dest->At += VERTS_PER_FACE; + } + + + } + } +} + + +link_internal void +BuildWorldChunkMeshFromMarkedVoxels_Greedy_v3_u8( voxel *Voxels, + v3i SrcChunkDim, + + v3i SrcChunkMin, + v3i SrcChunkMax, + + // TODO(Jesse)(immediate, poof, @poof_parens_bug): removing the parens here causes poof to bail .. why? + 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 + // entity models about 0 and rotation works properly. + v3_u8 VertexOffset = {}) +{ + /* HISTOGRAM_FUNCTION(); */ + TIMED_FUNCTION(); + + NotImplemented; +/* Assert(DestGeometry->Type == DataType_(vert_t.name)); */ + +/* vert_t.name VertexData[VERTS_PER_FACE]; */ +/* matl Materials[VERTS_PER_FACE]; */ + +/* auto SrcMinP = SrcChunkMin; */ +/* auto MaxDim = Min(SrcChunkDim, SrcChunkMax); */ + +/* auto TmpDim = MaxDim-SrcMinP; */ + +/* u32 TmpVol = u32(Volume(TmpDim)); */ +/* auto TempVoxels = Allocate(voxel, TempMemory, TmpVol); */ + +/* // NOTE(Jesse): It's necessary to copy the voxel data because the meshing */ +/* // algorithm unsets the face flags for the voxels instead of marking them */ +/* // as being processed. When complete, there should be no face-flags left on */ +/* // this data. (This is not asserted, but maybe should be?) */ +/* // */ +/* // TODO(Jesse): Assert there are no face flags left in this copy at the end of */ +/* // this process? */ +/* // */ +/* // TODO(Jesse): Copy data into here as the algorithm proceedes instead of in */ +/* // one shot at the start? */ +/* // */ +/* u32 TmpIndex = 0; */ +/* for ( s32 zIndex = 0; zIndex < TmpDim.z ; ++zIndex ) */ +/* { */ +/* for ( s32 yIndex = 0; yIndex < TmpDim.y ; ++yIndex ) */ +/* { */ +/* for ( s32 xIndex = 0; xIndex < TmpDim.x ; ++xIndex ) */ +/* { */ +/* voxel_position SrcP = SrcMinP + Voxel_Position(xIndex, yIndex, zIndex); */ +/* s32 SrcIndex = GetIndex(SrcP, SrcChunkDim); */ +/* /1* Assert(TmpIndex < TmpVol); *1/ */ +/* TempVoxels[TmpIndex] = Voxels[SrcIndex]; */ +/* TmpIndex++; */ +/* } */ +/* } */ +/* } */ + +/* Assert(TmpIndex == TmpVol); */ + +/* s32 Index = 0; */ +/* for ( s32 z = 0; z < TmpDim.z ; ++z ) */ +/* { */ +/* for ( s32 y = 0; y < TmpDim.y ; ++y ) */ +/* { */ +/* for ( s32 x = 0; x < TmpDim.x ; ++x ) */ +/* { */ +/* v3i TmpVoxP = V3i(x,y,z); */ +/* voxel *Voxel = TempVoxels + Index; */ + +/* FillArray(VertexMaterial(Voxel->Color, Voxel->Transparency, 0), Materials, VERTS_PER_FACE); */ + +/* (buffer_t.name) *Dest = {}; */ +/* if (Voxel->Transparency) { Dest = DestTransparentGeometry; } else { Dest = DestGeometry; } */ + +/* if (Dest) */ +/* { */ +/* if (Voxel->Flags & Voxel_RightFace) */ +/* { */ +/* v3 Dim = DoXStepping(TempVoxels, TmpDim, TmpVoxP, Voxel_RightFace, Voxel->Color, Voxel->Transparency); */ +/* RightFaceVertexData( VertexOffset+TmpVoxP, Dim, VertexData); */ +/* 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, (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, (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, (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, (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, (vert_t.name)_BackFaceNormalData, Materials); */ +/* } */ +/* } */ + +/* ++Index; */ +/* } */ +/* } */ +/* } */ + +/* if (DestGeometry) DestGeometry->Timestamp = __rdtsc(); */ +/* if (DestTransparentGeometry) DestTransparentGeometry->Timestamp = __rdtsc(); */ - if (DestGeometry) DestGeometry->Timestamp = __rdtsc(); - if (DestTransparentGeometry) DestTransparentGeometry->Timestamp = __rdtsc(); } link_internal void @@ -133,7 +329,8 @@ BuildWorldChunkMeshFromMarkedVoxels_Greedy_v3_u8( vox_data *Vox, memory_arena *TempMemory, v3_u8 VertexOffset = {}) { - BuildWorldChunkMeshFromMarkedVoxels_Greedy_v3_u8(Vox->ChunkData->Voxels, Vox->ChunkData->Dim, {}, Vox->ChunkData->Dim, DestGeometry, DestTransparentGeometry, TempMemory, VertexOffset); + NotImplemented; + /* BuildWorldChunkMeshFromMarkedVoxels_Greedy_(vert_t.name)(Vox->ChunkData->Voxels, Vox->ChunkData->Dim, {}, Vox->ChunkData->Dim, DestGeometry, DestTransparentGeometry, TempMemory, VertexOffset); */ } link_internal void @@ -431,11 +628,7 @@ BuildWorldChunkMeshFromMarkedVoxels_Naieve_v3_u8( voxel *Voxels, /* // TODO(Jesse): This copy could be avoided in multiple ways, and should be. */ /* /1* FillColorArray(Voxel->Color, FaceColors, ColorPallette, VERTS_PER_FACE); *1/ */ -/* /1* #if VOXEL_DEBUG_COLOR *1/ */ - /* /1* v3 Color = Abs(Voxel->DebugColor); *1/ */ -/* /1* #else *1/ */ /* /1* v3 Color = GetColorData(Voxel->Color); *1/ */ -/* /1* #endif *1/ */ /* f32 Trans = (f32)Voxel->Transparency / 255.f; */ /* FillArray(VertexMaterial(Voxel->Color, Trans, 0.f), Materials, VERTS_PER_FACE); */ diff --git a/jesse.bonsai.rdbg b/jesse.bonsai.rdbg index cb9adbf12..19bf055bf 100644 Binary files a/jesse.bonsai.rdbg and b/jesse.bonsai.rdbg differ diff --git a/jesse.make.sh b/jesse.make.sh index 66df8c0b6..e3247b193 100644 --- a/jesse.make.sh +++ b/jesse.make.sh @@ -1,24 +1,27 @@ -#!/usr/bin/env bash +#! /usr/bin/env bash -# OPT="-O2" +OPT="-O2" -./make.sh RunPoof -[ $? -ne 0 ] && exit 1 +# ./make.sh RunPoof +# [ $? -ne 0 ] && exit 1 # ./make.sh $OPT BuildAll # ./make.sh RunTests ./make.sh $OPT \ + BuildSingleExample examples/terrain_gen \ BuildExecutables \ - BuildSingleExample examples/transparency \ BuildSingleExample examples/project_and_level_picker \ - BuildSingleExample examples/blank_project \ -# BuildSingleExample examples/tools/voxel_synthesis_rule_baker \ -# BuildSingleExample examples/turn_based \ -# BuildSingleExample examples/terrain_gen \ -# BuildSingleExample examples/the_wanderer \ -# BuildTests \ + # BuildTests \ + # BuildSingleExample examples/ui_test \ + # BuildSingleExample examples/blank_project \ + # BuildSingleExample examples/transparency \ + # BuildSingleExample examples/turn_based \ + # BuildSingleExample examples/the_wanderer + # BuildSingleExample examples/tools/voxel_synthesis_rule_baker \ + +# ./make.sh BuildAll BundleRelease # ./make.sh BundleRelease diff --git a/jesse.tests.rdbg b/jesse.tests.rdbg index 48cbb2bb6..670433854 100644 Binary files a/jesse.tests.rdbg and b/jesse.tests.rdbg differ diff --git a/make.sh b/make.sh index c7d9370c7..87ef57773 100755 --- a/make.sh +++ b/make.sh @@ -6,6 +6,7 @@ # SANITIZER="-fsanitize=undefined" # SANITIZER="-fsanitize=address" +# SANITIZER="-fsanitize=thread" BUILD_EVERYTHING=0 @@ -40,6 +41,7 @@ BIN_TEST="$BIN/tests" BIN_GAME_LIBS="$BIN/game_libs" BONSAI_INTERNAL='-D BONSAI_INTERNAL=1' +# BONSAI_INTERNAL='' # $EXAMPLES/tile_gen @@ -51,9 +53,9 @@ BUNDLED_EXAMPLES=" $EXAMPLES/the_wanderer $EXAMPLES/terrain_gen $EXAMPLES/transparency - $EXAMPLES/tools/voxel_synthesis_rule_baker $EXAMPLES/project_and_level_picker " + # $EXAMPLES/tools/voxel_synthesis_rule_baker EXECUTABLES_TO_BUILD=" $SRC/game_loader.cpp @@ -69,6 +71,9 @@ DEBUG_TESTS_TO_BUILD=" $TESTS/allocation.cpp " +# COMPILER="clang++-19" +COMPILER="clang++" + function BuildExecutables { echo "" @@ -76,7 +81,7 @@ function BuildExecutables for executable in $EXECUTABLES_TO_BUILD; do SetOutputBinaryPathBasename "$executable" "$BIN" echo -e "$Building $executable" - clang++ \ + $COMPILER \ $SANITIZER \ $OPTIMIZATION_LEVEL \ $CXX_OPTIONS \ @@ -103,7 +108,7 @@ function BuildDebugOnlyTests for executable in $DEBUG_TESTS_TO_BUILD; do SetOutputBinaryPathBasename "$executable" "$BIN_TEST" echo -e "$Building $executable" - clang++ \ + $COMPILER \ $CXX_OPTIONS \ $BONSAI_INTERNAL \ $PLATFORM_CXX_OPTIONS \ @@ -128,7 +133,7 @@ function BuildTests for executable in $TESTS_TO_BUILD; do SetOutputBinaryPathBasename "$executable" "$BIN_TEST" echo -e "$Building $executable" - clang++ \ + $COMPILER \ $OPTIMIZATION_LEVEL \ $CXX_OPTIONS \ $BONSAI_INTERNAL \ @@ -152,7 +157,7 @@ function BuildExamples for executable in $EXAMPLES_TO_BUILD; do echo -e "$Building $executable" SetOutputBinaryPathBasename "$executable" "$BIN_GAME_LIBS" - clang++ \ + $COMPILER \ $SANITIZER \ -D BONSAI_DEBUG_SYSTEM_API=1 \ $OPTIMIZATION_LEVEL \ @@ -176,8 +181,8 @@ function BuildExamples function BuildWithClang { - which clang++ > /dev/null - [ $? -ne 0 ] && echo -e "Please install clang++" && exit 1 + which $COMPILER > /dev/null + [ $? -ne 0 ] && echo -e "Please install $COMPILER" && exit 1 echo -e "" echo -e "$Delimeter" @@ -297,20 +302,18 @@ function RunPoofHelper { # -I "C:/Program Files (x86)/Windows Kits/10/include/10.0.18362.0/um" \ # -I "C:/Program Files (x86)/Windows Kits/10/include/10.0.18362.0/winrt" \ + which poof > /dev/null 2>&1 + if [ $? -eq 0 ]; then + + cmd="poof $COLOR_FLAG -D POOF_PREPROCESSOR -D BONSAI_PREPROCESSOR -I src/ -I external/ $PLATFORM_DEFINES $BONSAI_INTERNAL $@" + echo "$cmd" + $cmd + else + echo "poof not found, skipping." + fi - # --log-level LogLevel_Debug \ - poof \ - $COLOR_FLAG \ - -D POOF_PREPROCESSOR \ - -D BONSAI_PREPROCESSOR \ - -I src/ \ - -I external/ \ - $PLATFORM_DEFINES \ - $BONSAI_INTERNAL \ - -o generated \ - $1 } @@ -325,22 +328,28 @@ function RunPoof # [ -d src/generated ] && rm -Rf src/generated # [ -d generated ] && rm -Rf generated - RunPoofHelper src/game_loader.cpp && echo -e "$Success poofed src/game_loader.cpp" & + # RunPoofHelper -o ./ src/poof_ctags_stub.cpp && echo -e "$Success poofed src/poof_ctags_stub.cpp" & + # TrackPid "" $! + + RunPoofHelper -o generated examples/ui_test/game.cpp && echo -e "$Success poofed examples/ui_test/game.cpp" & TrackPid "" $! - # RunPoofHelper examples/turn_based/game.cpp && echo -e "$Success poofed examples/turn_based/game.cpp" & + # RunPoofHelper -o generated src/game_loader.cpp && echo -e "$Success poofed src/game_loader.cpp" & + # TrackPid "" $! + + # RunPoofHelper -o generated examples/turn_based/game.cpp && echo -e "$Success poofed examples/turn_based/game.cpp" & # TrackPid "" $! - # RunPoofHelper examples/terrain_gen/game.cpp && echo -e "$Success poofed examples/terrain_gen/game.cpp" & + # RunPoofHelper -o generated examples/terrain_gen/game.cpp && echo -e "$Success poofed examples/terrain_gen/game.cpp" & # TrackPid "" $! - # RunPoofHelper examples/the_wanderer/game.cpp && echo -e "$Success poofed examples/the_wanderer/game.cpp" & + # RunPoofHelper -o generated examples/the_wanderer/game.cpp && echo -e "$Success poofed examples/the_wanderer/game.cpp" & # TrackPid "" $! - # RunPoofHelper examples/tools/voxel_synthesis_rule_baker/game.cpp && echo -e "$Success poofed examples/tools/voxel_synthesis_rule_baker/game.cpp" & + # RunPoofHelper -o generated examples/tools/voxel_synthesis_rule_baker/game.cpp && echo -e "$Success poofed examples/tools/voxel_synthesis_rule_baker/game.cpp" & # TrackPid "" $! - # RunPoofHelper src/tools/asset_packer.cpp && echo -e "$Success poofed src/tools/asset_packer.cpp" & + # RunPoofHelper -o generated src/tools/asset_packer.cpp && echo -e "$Success poofed src/tools/asset_packer.cpp" & # TrackPid "" $! WaitForTrackedPids @@ -350,23 +359,24 @@ function RunPoof } + # $TESTS/chunk.cpp + # $TESTS/ui_command_buffer.cpp + # $TESTS/m4.cpp + # $TESTS/colladaloader.cpp + # $TESTS/test_bitmap.cpp + # $TESTS/bonsai_string.cpp + # $TESTS/objloader.cpp + # $TESTS/callgraph.cpp + # $TESTS/heap_allocation.cpp + # $TESTS/rng.cpp + # $TESTS/file.cpp + # $TESTS/sort.cpp + # $TESTS/perlin_perf.cpp TESTS_TO_BUILD=" - $TESTS/chunk.cpp - $TESTS/ui_command_buffer.cpp - $TESTS/m4.cpp - $TESTS/colladaloader.cpp - $TESTS/test_bitmap.cpp - $TESTS/bonsai_string.cpp - $TESTS/objloader.cpp - $TESTS/callgraph.cpp - $TESTS/heap_allocation.cpp - $TESTS/rng.cpp - $TESTS/file.cpp - $TESTS/sort.cpp $TESTS/containers/block_array.cpp " -BuildAll() { +SetBuildAllFlags() { BuildExamples=1 BuildExecutables=1 @@ -385,7 +395,7 @@ BuildAll() { if [ $# -eq 0 ]; then OPTIMIZATION_LEVEL="-O2" - BuildAll + SetBuildAllFlags fi BundleRelease=0 @@ -396,7 +406,7 @@ while (( "$#" )); do case $CliArg in "BuildAll") - BuildAll + SetBuildAllFlags ;; "BuildExecutables") @@ -444,7 +454,6 @@ while (( "$#" )); do BundleRelease=1 OPTIMIZATION_LEVEL="-O2" BONSAI_INTERNAL="-D BONSAI_INTERNAL=0" - # BuildAll ;; "-Od") @@ -479,28 +488,35 @@ done time RunEntireBuild if [ $BundleRelease -eq 1 ]; then + echo -e "" echo -e "$Delimeter" echo -e "" ColorizeTitle "Bundling" + # bin/game_libs/turn_based_loadable$PLATFORM_LIB_EXTENSION \ + # bin/game_libs/the_wanderer_loadable$PLATFORM_LIB_EXTENSION \ + # bin/game_libs/transparency_loadable$PLATFORM_LIB_EXTENSION \ + tar -cz \ bin/game_loader$PLATFORM_EXE_EXTENSION \ bin/game_libs/blank_project_loadable$PLATFORM_LIB_EXTENSION \ - bin/game_libs/turn_based_loadable$PLATFORM_LIB_EXTENSION \ - bin/game_libs/the_wanderer_loadable$PLATFORM_LIB_EXTENSION \ bin/game_libs/terrain_gen_loadable$PLATFORM_LIB_EXTENSION \ - bin/game_libs/transparency_loadable$PLATFORM_LIB_EXTENSION \ bin/game_libs/project_and_level_picker_loadable$PLATFORM_LIB_EXTENSION \ - \ + \ shaders/* \ external/bonsai_stdlib/shaders/* \ assets/* \ models/* \ brushes/* \ - \ + \ .root_marker \ settings.init \ + white.bmp \ texture_atlas_0.bmp > "$Platform""_x86_64_release.tar.gz" + + [ $? -ne 0 ] && echo "$Failed $Platform""_x86_64_release.tar.gz" && exit 1 + + echo "$Success $Platform""_x86_64_release.tar.gz" fi diff --git a/models/boxes/treasure_0.vox b/models/boxes/treasure_0.vox new file mode 100644 index 000000000..ee4748ac1 Binary files /dev/null and b/models/boxes/treasure_0.vox differ diff --git a/models/boxes/treasure_1.vox b/models/boxes/treasure_1.vox new file mode 100644 index 000000000..7ed4b4431 Binary files /dev/null and b/models/boxes/treasure_1.vox differ diff --git a/models/grass_block.vox b/models/grass_block.vox new file mode 100644 index 000000000..56af7deda Binary files /dev/null and b/models/grass_block.vox differ diff --git a/models/grass_block_16.vox b/models/grass_block_16.vox new file mode 100644 index 000000000..517fe2b41 Binary files /dev/null and b/models/grass_block_16.vox differ diff --git a/models/red_power_barrell.vox b/models/red_power_barrell.vox new file mode 100644 index 000000000..5908ecb9f Binary files /dev/null and b/models/red_power_barrell.vox differ diff --git a/readme.md b/readme.md index 220b6b3d1..49efa687a 100644 --- a/readme.md +++ b/readme.md @@ -1,31 +1,65 @@ -![hero_banner](screenshots/two_doors.png) +

+ +

# Welcome to Bonsai! -Bonsai is a 3D voxel-based engine built with the intention of writing both -fast-paced arcade games and tile/turn-based RPGs +Bonsai is a voxel engine in a pot. It's been tended to with love and +care over the years. It started out as a learning excercise, and has taught me +the value of simplicity. -Bonsai, and nearly all it's dependencies, are written completely from scratch. -One external dependency is the C runtime library for startup, and a small -handful of trig functions (sin, cos, atan2). I have a back-burner task to -remove the CRT entirely, though it's unclear when/if I'll get around to it. +Bonsai supports massive worlds. The current version supports a maximum world +size of ~1 billion blocks, cubed. At one block per meter, that's the distance +from earth to the moon, 2600 times, in every direction. The view distance is +the entire world, all the time. Yes, you read that right. In Bonsai, you can +see in a straight line from Jupiter to the sun. -The only requirements to build and run Bonsai are an OpenGL 3.3+ driver, C++ -compiler, and a few appropriate system headers. +Bonsai terrain generation is fully procedural, and user configurable. Terrain +is generated on the GPU using regular glsl shaders. Anything you can do in a +shader, you can do in a Bonsai terrain generator. -![banner](screenshots/orks.png) +### 2.0.0-prealpha Note + +The current version is 2.0.0-prealpha-rc0, which can be found by joining the +Server](https://discord.gg/kmRpgXBh75). This version is a large rewrite of +several core systems, including the world generation, editor and parts of the +renderer. + +In its current state, the engine is effectively a terrain generator and editor. +For details on remaing work, see [Roadmap to v2.0.0](https://github.com/scallyw4g/bonsai/issues/82). + +![banner](screenshots/two_doors.png) + +# Getting Started -# Quickstart +Bonsai, and nearly all it's dependencies, are written completely from scratch. +One external dependency is the C runtime library for program startup. There is +a back-burner task to remove the CRT entirely, athough it's unclear when/if +anyone will ever get around to it. + +The only external requirements to build Bonsai are clang++ (>= version 18.1) +and a few appropriate system headers. + +## Quickstart Grab pre-built binaries & assets from the [Latest Releases](../../releases/latest) -for your platform of choice (as long as it's Windows or Linux ;) +for your platform of your choice (as long as your platform of choice is Windows or Linux) ;) -## Build from Source +### [Getting Started](docs/00_getting_started.md) -See the docs on the [build process](docs/01_build_process.md). +### [Build From Source](docs/01_build_process.md) -## Renderer Features +### [Controls](docs/controls.md) + +### [Discord Server](https://discord.gg/kmRpgXBh75) + + +![banner](screenshots/orks.png) + +# Feature Sets + +## Renderer * Deferred Shading * HDR Lighting @@ -36,28 +70,53 @@ See the docs on the [build process](docs/01_build_process.md). ![banner](screenshots/abandoned_workshop.png) -## Engine Features +## Engine -* Hot Code Reloading -* MT Job System +* Hot Shader & Game-code Reloading +* Async Job System * Entities * Collision * Transparent & Emissive Particles * UI Framework * Asset Loaders -* Terrain Generators * Primitive Physics -![banner](screenshots/profiler.png) -## Performance Profiler Features +![banner]( screenshots/mountain.png) + +## Terrain Generation + +* Fully programmable GPU-based terrain generation +* Batteries-included library of pre-built terrain shaders +* 1D, 2D and 3D noise library +* Terrain derivitives available in second-stage terrain "decoration" + +![banner](screenshots/ridgeline.png) + +## Editing + +* CSG-like SDF world editing +* Library of primitive shapes (rect, sphere, line, cylinder .. etc) +* SDF brush-based texturing of primitives + +![banner](screenshots/ork_aerial.png) + +## SDF Brushes + +* Layer-based brush GUI +* (coming soon) glsl brush shaders + +![banner](screenshots/brush.png) + +## Performance Profiler * Manual Instrumentation -* Memory allocation tracing -* Per frame call-graph tracing +* Memory allocation tracking +* Multithreaded callgraph tracing * Context Switches (windows only) * Physical Core (windows only) +![banner](screenshots/profiler.png) # Gallery @@ -67,15 +126,13 @@ See the docs on the [build process](docs/01_build_process.md). ![banner](screenshots/8_skele.png) -![banner](screenshots/dusk_defence.png) - -![banner](screenshots/5_skele.png) - # Wishlist ------------------------------------------------------------------------------- ## Renderer +[ ] HRC : https://github.com/entropylost/amitabha + [ ] SSR : https://lettier.github.io/3d-game-shaders-for-beginners/screen-space-reflection.html [ ] Screen-space lines : https://mattdesl.svbtle.com/drawing-lines-is-hard @@ -98,6 +155,8 @@ See the docs on the [build process](docs/01_build_process.md). [ ] Lumen-style GI screen-space radiance caching : https://www.youtube.com/watch?v=2GYXuM10riw +![banner]( screenshots/platapus.png) + ------------------------------------------------------------------------------- ## Terrain @@ -114,6 +173,8 @@ See the docs on the [build process](docs/01_build_process.md). * https://graphics.stanford.edu/courses/cs164-10-spring/Handouts/isotropic.pdf * https://inria.hal.science/inria-00071612/document +![banner](screenshots/pillar.png) + ------------------------------------------------------------------------------- ## Assets @@ -122,6 +183,9 @@ See the docs on the [build process](docs/01_build_process.md). [ ] Sound : mp3, ogg, ..? decompresser + +![banner](screenshots/5_skele.png) + ------------------------------------------------------------------------------- ## Datastructures @@ -143,9 +207,21 @@ See the docs on the [build process](docs/01_build_process.md). [ ] More interpolation goodies : https://paulbourke.net/miscellaneous/interpolation/ + +![banner](screenshots/dusk_defence.png) + +## Goodies + +[ ] Better (faster) Sin/Cos ? https://www.shadertoy.com/view/432yWW + +[ ] Look into using this Intel tooling for dual CPU/GPU world-gen? + https://www.intel.com/content/dam/develop/external/us/en/documents/spir-vtointe-ispcgpu-compute-on-the-cpu.pdf + https://ispc.github.io/ + ------------------------------------------------------------------------------- ## Profiler [ ] Improve the ETW layer : https://github.com/bombomby/optick/blob/master/src/optick_core.win.h [ ] GPU Profiling : https://www.khronos.org/opengl/wiki/Query_Object + diff --git a/screenshots/brush.png b/screenshots/brush.png new file mode 100644 index 000000000..3c8bcc4db Binary files /dev/null and b/screenshots/brush.png differ diff --git a/screenshots/logo_256.png b/screenshots/logo_256.png new file mode 100644 index 000000000..627633449 Binary files /dev/null and b/screenshots/logo_256.png differ diff --git a/screenshots/mountain.png b/screenshots/mountain.png new file mode 100644 index 000000000..0768db09f Binary files /dev/null and b/screenshots/mountain.png differ diff --git a/screenshots/ork_aerial.png b/screenshots/ork_aerial.png new file mode 100644 index 000000000..8a3bf847e Binary files /dev/null and b/screenshots/ork_aerial.png differ diff --git a/screenshots/pillar.png b/screenshots/pillar.png new file mode 100644 index 000000000..d6d9fc3b2 Binary files /dev/null and b/screenshots/pillar.png differ diff --git a/screenshots/platapus.png b/screenshots/platapus.png new file mode 100644 index 000000000..b6825bbfc Binary files /dev/null and b/screenshots/platapus.png differ diff --git a/screenshots/profiler.png b/screenshots/profiler.png index 3c4e0b688..7ecc35b75 100644 Binary files a/screenshots/profiler.png and b/screenshots/profiler.png differ diff --git a/screenshots/ridgeline.png b/screenshots/ridgeline.png new file mode 100644 index 000000000..1ee24cea2 Binary files /dev/null and b/screenshots/ridgeline.png differ diff --git a/settings.init b/settings.init index bcc472832..143b2d4d1 100644 --- a/settings.init +++ b/settings.init @@ -3,9 +3,9 @@ // NOTE(Jesse): Resolution of the back-buffers the renderer allocates // - resolution = ResolutionSetting_4096x2160 -// resolution = ResolutionSetting_1920x1080 -// resolution = ResolutionSetting_1280x720 +// resolution = ResolutionSetting_4096x2160 +// resolution = ResolutionSetting_1920x1080 + resolution = ResolutionSetting_1280x720 @@ -15,9 +15,9 @@ // // shadow_quality = ShadowQualitySetting_High - shadow_quality = ShadowQualitySetting_Med +// shadow_quality = ShadowQualitySetting_Med // shadow_quality = ShadowQualitySetting_Low -// shadow_quality = ShadowQualitySetting_Off + shadow_quality = ShadowQualitySetting_Off @@ -25,10 +25,10 @@ // NOTE(Jesse)(lighting_setting): Currently does nothing // - lighting_quality = LightingQualitySetting_High +// lighting_quality = LightingQualitySetting_High // lighting_quality = LightingQualitySetting_Med // lighting_quality = LightingQualitySetting_Low -// lighting_quality = LightingQualitySetting_Off + lighting_quality = LightingQualitySetting_Off diff --git a/shaders/9_ersion.fragmentshader b/shaders/9_ersion.fragmentshader new file mode 100644 index 000000000..d028b6d2d --- /dev/null +++ b/shaders/9_ersion.fragmentshader @@ -0,0 +1,418 @@ + +in vec2 gBufferUV; +layout (location = 0) out vec4 out_LightColor; +/* layout (location = 1) out vec3 BloomColor; */ + +uniform sampler2D gColor; +uniform sampler2D gPosition; +uniform sampler2D gNormal; +uniform sampler2D gDepth; +uniform sampler2D shadowMap; +uniform sampler2D Ssao; + +uniform s32 LightCount; +uniform r32 LightIndexToUV; +uniform sampler2D LightColors; +uniform sampler2D LightPositions; + +uniform sampler2D TransparencyAccumTex; +uniform sampler2D TransparencyCountTex; +uniform bool BravoilMyersOIT; +uniform bool BravoilMcGuireOIT; + +uniform mat4 InverseViewMatrix; +uniform mat4 InverseProjectionMatrix; +uniform mat4 ShadowMVP; + +uniform vec3 SunPosition; +uniform vec3 SunColor; +uniform vec3 Camera; + +uniform r32 FogPower; +uniform vec3 FogColor; + + +uniform bool UseSsao; +uniform bool UseShadowMapping; +uniform bool UseLightingBloom; + +uniform v2 ApplicationResolution; +uniform v2 ShadowMapResolution; + +int AoBlurSize = 4; // size of AO noise texture +float BlurredAO = 0.0f; + +/* fda */ + +// NOTE(Jesse): Better shader noise function for when I need it : https://www.shadertoy.com/view/4djSRW + +// NOTE(Jesse): These are done, leaving here for posterity for a bit. +// DONE(Jesse): Tune the sun color & ambient light color to be orange/teal +// DONE(Jesse): Tune the sun color & ambient light intensities to be 10:1 +// DONE(Jesse): Add back-lighting, which is a light from the opposite direciton of the sun. +// DONE(Jesse): Don't modulate key-light by SSAO +// +// https://www.youtube.com/watch?v=-pdSjBPH3zM +// + +// SunIntensity : 1.00f Full Sun +// SunIntensity : 0.05f Dusk +// SunIntensity : 0.005f Moonlight + +/* float SunIntensity = 0.0005f; +/* float SunIntensity = 0.005f; */ +/* float SunIntensity = 0.05f; */ +float SunIntensity = 0.5f; +/* float SunIntensity = 1.0f; */ + +// Tuning + float gamma = 2.2f; + float materialShininess = 2.0f; +// + + +vec3 SpecLightingCalc(float AttenuationFactor, vec3 DiffuseColor, vec3 FragToLight, vec3 FragWorldP, vec3 FragNormal, vec3 CameraP) +{ + vec3 reflectionVector = reflect(FragToLight, FragNormal); + vec3 FragToCamera = normalize(FragWorldP - CameraP); + float cosAngle = max(0.0, dot(FragToCamera, reflectionVector)); + float SpecularPower = pow(cosAngle, materialShininess); + vec3 SpecularLight = DiffuseColor * SpecularPower; + + return SpecularLight; +} + +vec3 LightingCalc(float AttenuationFactor, vec3 LightColor, vec3 FragToLight, vec3 FragNormal, vec3 CameraP) +{ + float LightCosTheta = clamp( dot( FragNormal, FragToLight), 0.0f, 1.0f); + vec3 DirectLight = LightColor * LightCosTheta * AttenuationFactor; + return DirectLight; +} + + +void main() +{ + vec2 gBufferTextureDim = ApplicationResolution; + ivec2 texelCoord = ivec2(gBufferUV*gBufferTextureDim); + + /* vec4 FragWorldP = texelFetch(gPosition, texelCoord, 0); */ + + /* f32 Depth = texelFetch(gDepth, texelCoord, 0).r; */ + f32 Depth = texture(gDepth, gBufferUV).r; // NOTE(Jesse): Nonlinear + +#if 0 + /* f32 DepthNonlinear = Linearize(DepthNonlinear, 5000.f, 0.1f); // 1.f at far clip plane, 0.f at near clip */ + + f32 ClipZ = (Depth*2.f) - 1.f; + v2 ClipXY = (gBufferUV*2.f)-1.f; + + v4 ClipP = V4(ClipXY.x, ClipXY.y, ClipZ, 1.f); // Correct + v4 ViewP = InverseProjectionMatrix * ClipP; + + ViewP /= ViewP.w; + + v4 WorldP = InverseViewMatrix * ViewP; + v4 FragPosition = WorldP; +#endif + + v3 FragWorldP = WorldPositionFromNonlinearDepth(Depth, gBufferUV, InverseProjectionMatrix, InverseViewMatrix); + + /* out_LightColor.r = Depth; */ + /* out_LightColor.r = abs(ClipZ); */ + /* out_LightColor.xy = abs(ClipXY); */ + /* out_LightColor = abs(ClipP); */ + + /* out_LightColor = abs(InverseProjectionMatrix[0]); */ + /* out_LightColor = abs(InverseProjectionMatrix[1]); */ + /* out_LightColor = abs(ViewP); */ + /* out_LightColor = abs(WorldP); */ + /* out_LightColor = FragWorldP; */ + /* out_LightColor.a = 1.f; */ + /* return; */ + + + vec4 TransAccum = texture(TransparencyAccumTex, gBufferUV); + float TransAccumCount = texture(TransparencyCountTex, gBufferUV).r; + float TransAccumEmission = texture(TransparencyCountTex, gBufferUV).g; + + vec3 AmbientLightContrib = SunColor*0.06f; + vec3 KeyLightContrib = V3(0.f); + vec3 BackLightContrib = V3(0.f); + vec3 PointLightsContrib = V3(0.f); + + vec3 CameraToFrag = normalize(FragWorldP - Camera); // TODO(Jesse): Pass this to the lighting calc that needs it + + vec4 gColorTexel = texelFetch(gColor, texelCoord, 0); + + vec3 Diffuse = gColorTexel.rgb; + /* float Emission = gColorTexel.a; */ + + /* Diffuse *= Emission; */ + + /* vec3 FragNormal = gColorTexel.rgb; */ + vec3 FragNormal = texelFetch(gNormal, texelCoord, 0).rgb; + + vec3 ShadowVisibility = vec3(1.0f); + + vec3 TotalLight = vec3(0.f); + /* r32 DiscardThresh = f32_MAX; */ + /* if (FragWorldP.x == DiscardThresh) */ + /* { */ + /* TotalLight = vec3(1.f); */ + /* } */ + /* else */ + { + + /* out_LightColor = FragWorldP; */ + /* return; */ + + + /* float Emission = clamp(0.f, 1.f, texelFetch(gColor, texelCoord, 0).a); */ + + { + vec3 FragToLight = normalize(SunPosition); + vec3 LightToFrag = -FragToLight; + + float LightAtt = SunIntensity; + KeyLightContrib = LightingCalc(LightAtt, SunColor, FragToLight, FragNormal, Camera); + /* KeyLightContrib += SpecLightingCalc(LightAtt, Diffuse, FragToLight, FragWorldP, FragNormal, Camera); */ + + BackLightContrib = LightingCalc(LightAtt, 0.15f*SunColor, LightToFrag, FragNormal, Camera); + } + + + + for ( s32 LightIndex = 0; LightIndex < LightCount; ++LightIndex ) + { + ivec2 LightUV = ivec2(LightIndex, 0); + + vec3 LightPosition = texelFetch(LightPositions, LightUV, 0).rgb; + vec3 LightColor = texelFetch(LightColors, LightUV, 0).rgb; + + vec3 FragToLight = normalize(LightPosition - FragWorldP); + + float LightCosTheta = clamp( dot( FragNormal, FragToLight), 0.0f, 1.0f); + + float Distance = distance(FragWorldP, LightPosition); + + float LightAtt = 0.f; + if (Distance > 0) { LightAtt = 1.0f/(Distance*Distance); } + + vec3 reflectionVector = reflect(FragToLight, FragNormal); + vec3 CameraToFrag = normalize(FragWorldP - Camera); + float cosAngle = max(0.f, dot(CameraToFrag, reflectionVector)); + float SpecularPower = pow(cosAngle, materialShininess); + + vec3 DirectLight = Diffuse * LightColor * LightCosTheta * LightAtt; + vec3 SpecularLight = vec3(0.f); + + if (LightCosTheta > 0.f) SpecularLight = LightColor * SpecularPower * LightAtt; + + PointLightsContrib += DirectLight + SpecularLight; + PointLightsContrib += SpecularLight; + } + + if (UseSsao) + { + vec2 texelSize = 1.0 / vec2(textureSize(Ssao, 0)); + float AccumAO = 0.0; + + vec2 hlim = vec2(float(-AoBlurSize) * 0.5 + 0.5); + + for (int i = 0; i < AoBlurSize; ++i) { + for (int j = 0; j < AoBlurSize; ++j) { + vec2 TexOffset = (hlim + vec2(float(i), float(j))) * texelSize; + AccumAO += texture(Ssao, gBufferUV + TexOffset).r; + } + } + + BlurredAO = AccumAO / float(AoBlurSize * AoBlurSize); + } + else + { + BlurredAO = 1.0f; + } + + + vec3 sampleVis = vec3(1.0f/5.f); + /* vec3 sampleVis = vec3(1.f/7.f); */ + + if (UseShadowMapping) + { + /* + * Shadow Mapping + */ + f32 LinearDepth = Linearize(Depth, 5000.f, 0.1f); + float acneBias = 0.045f * LinearDepth; // Fix acne + + v4 FragPShadowSpace = ShadowMVP * vec4(FragWorldP, 1.f); + f32 FragDepth = FragPShadowSpace.z - acneBias; + /* out_LightColor = vec4(FragDepth, FragDepth, FragDepth, 1.f); */ + /* out_LightColor = abs(FragPShadowSpace); */ + /* return; */ + + float ShadowSampleDepth = texture(shadowMap, FragPShadowSpace.xy ).x; // + acneBias; + if ( FragDepth > ShadowSampleDepth ) { ShadowVisibility -= vec3(1.f); } + + /* out_LightColor = vec4(ShadowSampleDepth, ShadowSampleDepth, ShadowSampleDepth, 1.f); */ + /* return; */ + + + // NOTE(Jesse): This is misguided. The correct thing to do is to write + // shadow information to a buffer, then sample that buffer using a box filter + // (or some other blur function). The reason to do it that way instead of + // directly here is that for each sample you take here, you'd have to + // recompute the actual shadow map value at the sample pos, which would be + // much too expensive even at small sample rates. + // + // I'm going to leave this here, but it causes flashing when the sun rotates + // such that the number of samples this hits true branches for change for the + // whole scene. + // + // Might be fine if the sun location was a fixed point, but that seems lame. + // +#if 0 + v2 ShadowMapUVStep = vec2(1.f)/ShadowMapResolution; + + // TODO(Jesse): Does this produce better results using texelFetch? + vec2 Mapped = vec2(FragPShadowSpace.xy + vec2(ShadowMapUVStep.x, 0.f)); + ShadowSampleDepth = texture(shadowMap, Mapped).x + acneBias; + if ( FragDepth > ShadowSampleDepth ) { ShadowVisibility -= sampleVis; } + + Mapped = vec2(FragPShadowSpace.xy + vec2(-ShadowMapUVStep.x, 0.f)); + ShadowSampleDepth = texture(shadowMap, Mapped).x + acneBias; + if ( FragDepth > ShadowSampleDepth ) { ShadowVisibility -= sampleVis; } + + Mapped = vec2(FragPShadowSpace.xy + vec2(0.f, ShadowMapUVStep.y)); + ShadowSampleDepth = texture(shadowMap, Mapped).x + acneBias; + if ( FragDepth > ShadowSampleDepth ) { ShadowVisibility -= sampleVis; } + + Mapped = vec2(FragPShadowSpace.xy + vec2(0.f, -ShadowMapUVStep.y)); + ShadowSampleDepth = texture(shadowMap, Mapped).x + acneBias; + if ( FragDepth > ShadowSampleDepth ) { ShadowVisibility -= sampleVis; } +#endif + + /* out_LightColor = vec4(vec3(FragDepth < ShadowSampleDepth ), 1.f); */ + /* return; */ + + } + + /* ShadowVisibility = max(ShadowVisibility, vec3(SunIntensity)); */ + /* out_LightColor = vec4(ShadowVisibility, 1.f); */ + /* return; */ + +#if 1 + /* + * Fog + */ + // TODO(Jesse): Can do squared? + float DistanceToFrag = distance(Camera, FragWorldP); + float MaxFogDist = 200.f; + + float FogContrib = clamp( DistanceToFrag / MaxFogDist, 0.f, 1.f); + FogContrib *= FogContrib*1.2; + v3 Fog = FogContrib * FogColor * FogPower; +#else + v3 Fog = V3(0); +#endif + + /* + * Tone-mapping && gamma correction + */ + + TotalLight = (Diffuse*KeyLightContrib*ShadowVisibility) + + (Diffuse*AmbientLightContrib*BlurredAO) + + (Diffuse*BackLightContrib*BlurredAO) + + (PointLightsContrib*BlurredAO) + + Fog; + /* Emission * Diffuse + */ + + /* if (Emission > 1.f) */ + /* { */ + /* TotalLight += Emission*Diffuse; */ + /* } */ + + /* vec3 TotalLight = (KeyLightContrib) + */ + /* (PointLightsContrib) + */ + /* (BlurredAO*BackLightContrib) + */ + /* Fog; */ + + } + + float Shine = 0.f; + /* Shine = clamp(pow(dot(SunPosition, CameraToFrag), 2.f), 0.f, 1.f); */ + + + /* out_LightColor = vec4(Diffuse, 1.f); */ + /* out_LightColor = vec4(abs(FragNormal), 1.f); */ + /* out_LightColor = vec4(KeyLightContrib*10.f, 1.f); */ + + /* out_LightColor = vec4( (KeyLightContrib*ShadowVisibility*100.f), 1.f); */ + /* out_LightColor = vec4( (ShadowVisibility), 1.f); */ + /* out_LightColor = vec4(FogContrib, FogContrib, FogContrib, 1.f) * vec4(FogColor, 1.f); */ + /* out_LightColor = vec4(out_LightColor, 1.f); */ + /* out_LightColor = vec4(1.f, 0.f, 0.f, 1.f); */ + /* out_LightColor = vec4(0.f); */ + v3 TransparencyContrib = v3(0.f, 0.f, 0.f); + + if (BravoilMyersOIT) + { + /* TransparencyContrib = BravoilMyersWeightedAverage(TransAccum, TransAccumCount); */ + + float Count = max(1.f, TransAccumCount); + + // Have to clamp because this is > 1.f for emissive surfaces, which breaks the following equation + float Alpha = clamp(TransAccum.a, 0.f, 1.f); + + v3 ColorResult = TransAccum.rgb/max(TransAccum.a, 0.00001f); + float AlphaResult = pow(max(0.0, 1.0-(Alpha/Count)), Count); + + TransparencyContrib = v3(ColorResult * AlphaResult); + /* out_LightColor = vec4(TotalLight+TransparencyContrib.rgb, 1.f); */ + /* out_LightColor = v4(TotalLight, 1.f); */ + } + + if (BravoilMcGuireOIT) + { + float Coverage = clamp(TransAccumCount, 0.f, 1.f); + /* float Coverage = Revealage; */ + TransparencyContrib = (TransAccum.rgb / clamp(TransAccum.a, 1e-4, 5e4)); + /* TransparencyContrib = (TransAccum.rgb / clamp(TransAccum.a, 1e-4, 5e4)) * Coverage; */ + + float LightTransmission = length(KeyLightContrib + BackLightContrib + PointLightsContrib + AmbientLightContrib); + float LightEmission = TransAccumEmission; + + /* out_LightColor = V4(TransAccumEmission, 0.f, 0.f, 1.f); */ + /* out_LightColor = V4(LightTransmission, 0.f, 0.f, 1.f); */ + /* out_LightColor = V4(LightEmission, 0.f, 0.f, 1.f); */ + /* out_LightColor = V4(max(LightTransmission, LightEmission), 0.f, 0.f, 1.f); */ + /* return; */ + + TransparencyContrib *= V3(LightTransmission + LightEmission); + /* TransparencyContrib *= LightEmission; */ + + /* out_LightColor = vec4( TotalLight + TransparencyContrib*LightTransmission, 1.f); */ + /* out_LightColor = vec4(Revealage, 0.f, 0.f, 1.f); */ + /* out_LightColor = vec4( TotalLight + ColorResult*Coverage, 1.f); */ + /* out_LightColor = vec4( TotalLight + ColorResult*Coverage, 1.f); */ + } + + out_LightColor = V4(TotalLight + TransparencyContrib, 1.f); + + /* out_LightColor = V4(FragNormal, 1.f); */ + + /* out_LightColor = V4(Emission, 0.f, 0.f, 1.f); */ + /* return; */ + + + /* if (UseLightingBloom) { BloomColor = TotalLight + TransparencyContrib.rgb; } */ + + /* else { BloomColor = vec3(0.0f, 0.0f, 0.0f); } */ + + /* if (UseLightingBloom) out_LightColor.r = 1.f; */ + /* if (UseShadowMapping) out_LightColor.b = 1.f; */ + /* if (UseSsao) out_LightColor.g = 1.f; */ + + /* out_LightColor = vec4(Emission, Emission, Emission, 1.f);; */ + /* BloomColor = vec3(Emission, Emission, Emission); */ +} diff --git a/shaders/DepthRTT.vertexshader b/shaders/DepthRTT.vertexshader index 9728cf8be..f3c8f8909 100644 --- a/shaders/DepthRTT.vertexshader +++ b/shaders/DepthRTT.vertexshader @@ -1,7 +1,9 @@ layout(location = 0) in vec3 vertexPosition_modelspace; -// NOTE(Jesse): Camera transform -uniform mat4 MVP; +// NOTE(Jesse): It's not just an MVP because of a deficiency on the C++ side; +// we don't have the facilities in the DrawLOD to differentiate between +// this shader and the gBuffer shader, which needs them as two matrices. +uniform mat4 ViewProjection; uniform mat4 ModelMatrix; out vec3 vertexP_worldspace; @@ -9,6 +11,6 @@ out vec3 vertexP_worldspace; void main() { vertexP_worldspace = (ModelMatrix * vec4(vertexPosition_modelspace, 1)).xyz; // ?? - gl_Position = MVP * V4(vertexP_worldspace, 1); + gl_Position = ViewProjection * V4(vertexP_worldspace, 1); } diff --git a/shaders/Lighting.fragmentshader b/shaders/Lighting.fragmentshader index 0f6d3d7b4..dd620bb49 100644 --- a/shaders/Lighting.fragmentshader +++ b/shaders/Lighting.fragmentshader @@ -15,8 +15,8 @@ uniform r32 LightIndexToUV; uniform sampler2D LightColors; uniform sampler2D LightPositions; -uniform sampler2D TransparencyAccum; -uniform sampler2D TransparencyCount; +uniform sampler2D TransparencyAccumTex; +uniform sampler2D TransparencyCountTex; uniform bool BravoilMyersOIT; uniform bool BravoilMcGuireOIT; @@ -26,7 +26,7 @@ uniform mat4 ShadowMVP; uniform vec3 SunPosition; uniform vec3 SunColor; -uniform vec3 CameraP; +uniform vec3 Camera; uniform r32 FogPower; uniform vec3 FogColor; @@ -42,6 +42,7 @@ uniform v2 ShadowMapResolution; int AoBlurSize = 4; // size of AO noise texture float BlurredAO = 0.0f; +/* fda */ // NOTE(Jesse): Better shader noise function for when I need it : https://www.shadertoy.com/view/4djSRW @@ -130,16 +131,16 @@ void main() /* return; */ - vec4 TransAccum = texture(TransparencyAccum, gBufferUV); - float TransAccumCount = texture(TransparencyCount, gBufferUV).r; - float TransAccumEmission = texture(TransparencyCount, gBufferUV).g; + vec4 TransAccum = texture(TransparencyAccumTex, gBufferUV); + float TransAccumCount = texture(TransparencyCountTex, gBufferUV).r; + float TransAccumEmission = texture(TransparencyCountTex, gBufferUV).g; vec3 AmbientLightContrib = SunColor*0.06f; vec3 KeyLightContrib = V3(0.f); vec3 BackLightContrib = V3(0.f); vec3 PointLightsContrib = V3(0.f); - vec3 CameraToFrag = normalize(FragWorldP - CameraP); // TODO(Jesse): Pass this to the lighting calc that needs it + vec3 CameraToFrag = normalize(FragWorldP - Camera); // TODO(Jesse): Pass this to the lighting calc that needs it vec4 gColorTexel = texelFetch(gColor, texelCoord, 0); @@ -148,8 +149,8 @@ void main() /* Diffuse *= Emission; */ + /* vec3 FragNormal = gColorTexel.rgb; */ vec3 FragNormal = texelFetch(gNormal, texelCoord, 0).rgb; - /* vec3 FragNormal = texture(gNormal, gBufferUV).rgb; */ vec3 ShadowVisibility = vec3(1.0f); @@ -173,10 +174,10 @@ void main() vec3 LightToFrag = -FragToLight; float LightAtt = SunIntensity; - KeyLightContrib = LightingCalc(LightAtt, SunColor, FragToLight, FragNormal, CameraP); - /* KeyLightContrib += SpecLightingCalc(LightAtt, Diffuse, FragToLight, FragWorldP, FragNormal, CameraP); */ + KeyLightContrib = LightingCalc(LightAtt, SunColor, FragToLight, FragNormal, Camera); + /* KeyLightContrib += SpecLightingCalc(LightAtt, Diffuse, FragToLight, FragWorldP, FragNormal, Camera); */ - BackLightContrib = LightingCalc(LightAtt, 0.15f*SunColor, LightToFrag, FragNormal, CameraP); + BackLightContrib = LightingCalc(LightAtt, 0.15f*SunColor, LightToFrag, FragNormal, Camera); } @@ -198,7 +199,7 @@ void main() if (Distance > 0) { LightAtt = 1.0f/(Distance*Distance); } vec3 reflectionVector = reflect(FragToLight, FragNormal); - vec3 CameraToFrag = normalize(FragWorldP - CameraP); + vec3 CameraToFrag = normalize(FragWorldP - Camera); float cosAngle = max(0.f, dot(CameraToFrag, reflectionVector)); float SpecularPower = pow(cosAngle, materialShininess); @@ -244,17 +245,18 @@ void main() f32 LinearDepth = Linearize(Depth, 5000.f, 0.1f); float acneBias = 0.045f * LinearDepth; // Fix acne - vec4 FragPShadowSpace = ShadowMVP * vec4(FragWorldP, 1.f); - float FragDepth = FragPShadowSpace.z - acneBias; + v4 FragPShadowSpace = ShadowMVP * vec4(FragWorldP, 1.f); + f32 FragDepth = FragPShadowSpace.z - acneBias; /* out_LightColor = vec4(FragDepth, FragDepth, FragDepth, 1.f); */ - /* out_LightColor = FragPShadowSpace; */ + /* out_LightColor = abs(FragPShadowSpace); */ /* return; */ + float ShadowSampleDepth = texture(shadowMap, FragPShadowSpace.xy ).x; // + acneBias; + if ( FragDepth > ShadowSampleDepth ) { ShadowVisibility -= vec3(1.f); } - v2 ShadowMapUVStep = vec2(1.f)/ShadowMapResolution; + /* out_LightColor = vec4(ShadowSampleDepth, ShadowSampleDepth, ShadowSampleDepth, 1.f); */ + /* return; */ - float ShadowSampleDepth = texture(shadowMap, FragPShadowSpace.xy ).x + acneBias; - if ( FragDepth > ShadowSampleDepth ) { ShadowVisibility -= vec3(1.f); } // NOTE(Jesse): This is misguided. The correct thing to do is to write // shadow information to a buffer, then sample that buffer using a box filter @@ -270,6 +272,8 @@ void main() // Might be fine if the sun location was a fixed point, but that seems lame. // #if 0 + v2 ShadowMapUVStep = vec2(1.f)/ShadowMapResolution; + // TODO(Jesse): Does this produce better results using texelFetch? vec2 Mapped = vec2(FragPShadowSpace.xy + vec2(ShadowMapUVStep.x, 0.f)); ShadowSampleDepth = texture(shadowMap, Mapped).x + acneBias; @@ -302,10 +306,12 @@ void main() * Fog */ // TODO(Jesse): Can do squared? - float DistanceToFrag = distance(CameraP, FragWorldP); - float MaxFogDist = 20000.f; + float DistanceToFrag = distance(Camera, FragWorldP); + float MaxFogDist = 7000.f; float FogContrib = clamp( DistanceToFrag / MaxFogDist, 0.f, 1.f); + FogContrib *= FogContrib*1.2; + /* FogContrib = pow(FogContrib,1); */ v3 Fog = FogContrib * FogColor * FogPower; #else v3 Fog = V3(0); @@ -393,6 +399,9 @@ void main() } out_LightColor = V4(TotalLight + TransparencyContrib, 1.f); + + /* out_LightColor = V4(FragNormal, 1.f); */ + /* out_LightColor = V4(Emission, 0.f, 0.f, 1.f); */ /* return; */ diff --git a/shaders/composite.fragmentshader b/shaders/composite.fragmentshader index 50741a7bf..686994734 100644 --- a/shaders/composite.fragmentshader +++ b/shaders/composite.fragmentshader @@ -106,6 +106,7 @@ vec3 agxLook(vec3 val) { vec3 power = vec3(1.0); float sat = 1.0; +#if 1 switch (ToneMappingType) { case 3: {} break; @@ -121,11 +122,14 @@ vec3 agxLook(vec3 val) { case 5: { // Punchy - slope = vec3(1.0); - power = vec3(1.15, 1.15, 1.15); - sat = 1.4; + f32 p = 1.25; + slope = vec3(1.f); + power = vec3(p); + /* power = vec3(1.15, 1.15, 1.15); */ + sat = 1.25; } break; } +#endif // ASC CDL val = pow(val * slope + offset, power); @@ -202,7 +206,7 @@ void main() vec3 TotalLight = Lighting + TransparencyContrib.rgb; - if (UseLightingBloom) { TotalLight += 0.25f*Bloom; } + if (UseLightingBloom) { TotalLight += 0.05f*Bloom; } /* vec3 TotalLight = Lighting + 0.15f*Bloom + (TransparencyContrib.rgb * TransparencyContrib.a); */ /* vec3 TotalLight = (Diffuse * Lighting) * 2.f; */ @@ -233,7 +237,7 @@ void main() // AGX tone mapping // // This supposedly closely emulates the actual color that gets recorded by - // .. some .. film on ahlhlhl + // .. some .. film on // https://github.com/EaryChow/AgX // https://www.shadertoy.com/view/cd3XWr // diff --git a/shaders/curve_remap_visualizer.fragmentshader b/shaders/curve_remap_visualizer.fragmentshader new file mode 100644 index 000000000..59f1b5f0d --- /dev/null +++ b/shaders/curve_remap_visualizer.fragmentshader @@ -0,0 +1,49 @@ +/* #extension GL_NV_shader_buffer_load : enable */ + +uniform v2 Points[16]; +uniform u32 Count; + +in vec2 UV; +out v4 Output; + + +b32 +WithinTolerance(f32 Epsilon, f32 A, f32 B) +{ + b32 Result = (A+Epsilon > B && A-Epsilon < B); + return Result; +} + + + +void main() +{ + Output = V4(1,1,1,1); + + + f32 Mapped = RemapSample(UV.x, Points, Count); + + if (Mapped == -1.f) + { + Output.rgb = v3(1.0f, 0.f, 1.0f); + } + else + { + r32 ThicknessInUVCoordinates = 0.01f; +#if 0 + if (Mapped > UV.y) + { + Output.rgb = V3(0.2); + } +#else + if (WithinTolerance(0.01f, Mapped, UV.y)) + { + r32 Dist = abs(UV.y - Mapped); + + r32 t = Dist/ThicknessInUVCoordinates; + Output.rgb = mix(v3(0), V3(1), t); + } +#endif + } + +} diff --git a/shaders/gBuffer.fragmentshader b/shaders/gBuffer.fragmentshader index 990cce3cd..135648d1f 100644 --- a/shaders/gBuffer.fragmentshader +++ b/shaders/gBuffer.fragmentshader @@ -152,5 +152,6 @@ void main() /* FinalColor.xyz = vec3(abs(CorrectedPos.w)); */ #endif + /* gColor = v4(abs(vertexN_worldspace),1.f); */ gColor = FinalColor; } diff --git a/shaders/gBuffer.vertexshader b/shaders/gBuffer.vertexshader index 30eb81b3f..546879bfe 100644 --- a/shaders/gBuffer.vertexshader +++ b/shaders/gBuffer.vertexshader @@ -35,7 +35,7 @@ void main() int Emission = in_TransEmiss.y; /* MaterialColor = texelFetch(ColorPalette, ivec2(ColorIndex, 0), 0).rgb; */ - MaterialColor = UnpackHSVColorToRGB(s32(ColorIndex)); + MaterialColor = UnpackV3_15b(int(ColorIndex)); /* MaterialColor = texelFetch(ColorPalette, ivec2(5, 0), 0).rgb; */ /* MaterialColor = V3(1,0,1); */ TransEmiss = V2(float(Transparency)/255.f, float(Emission)/(255.f/RENDERER_MAX_LIGHT_EMISSION_VALUE)); @@ -44,7 +44,10 @@ void main() v4 WorldVertex = ModelMatrix*vec4(vertexPosition_modelspace, 1); vertexP_worldspace = WorldVertex.xyz; - vertexN_worldspace = mat3(NormalMatrix) * V3(vertexNormal_modelspace); + + // NOTE(Jesse): We have to normalize because a scale factor in the NormalMatrix will grow/shrink the normal! + // TODO(Jesse): Is there some way of avoiding this? I guess hlhl + vertexN_worldspace = normalize(mat3(NormalMatrix) * V3(vertexNormal_modelspace)); gl_Position = ViewProjection * WorldVertex; } diff --git a/shaders/terrain/TerrainFinalize.fragmentshader b/shaders/terrain/TerrainFinalize.fragmentshader new file mode 100644 index 000000000..5e318ac15 --- /dev/null +++ b/shaders/terrain/TerrainFinalize.fragmentshader @@ -0,0 +1,29 @@ +uniform sampler2D InputTex; +uniform v3 ChunkResolution; + +in vec2 UV; +out uint Output; + + +void main() +{ + v4 TexLookup = texelFetch(InputTex, ivec2(gl_FragCoord.xy), 0); + + f32 NoiseValue = TexLookup.a; + v3 ColorValue = TexLookup.rgb; + + uint SolidBit = NoiseValue > 0.f ? 1u : 0u; + + ivec2 InputTexDim = ivec2(66); + ivec2 OutputTexDim = ivec2(66); + + v3 Normal = ComputeNormal(InputTex, gl_FragCoord.xy, InputTexDim, OutputTexDim, 1.f); + /* v3 Normal = Normalize(V3(1,1,0)); */ + + /* uint PackedNormal = PackRGB(Normalize(V3(1,1,1))); */ + uint PackedNormal = PackRGB(Normal); + uint PackedColor = PackRGB(ColorValue); + /* uint PackedColor = PackedNormal; */ + + Output = (SolidBit << 31) | (PackedNormal << 16) | PackedColor; +} diff --git a/shaders/terrain/decoration/billow.fragmentshader b/shaders/terrain/decoration/billow.fragmentshader new file mode 100644 index 000000000..1a06de3e9 --- /dev/null +++ b/shaders/terrain/decoration/billow.fragmentshader @@ -0,0 +1,48 @@ +uniform v2 SampleRemapCurvePoints[16]; +uniform u32 SampleRemapCurvePointCount; + +uniform v3 WorldspaceChunkBasis; +uniform v3 ChunkResolution; + +uniform sampler2D DerivsTex; +uniform sampler2D InputTex; + +in vec2 UV; +out v4 Output; + +void main() +{ + f32 x = floor(gl_FragCoord.x); + f32 z = floor(gl_FragCoord.y / 66); + f32 y = floor(gl_FragCoord.y - (z*66)); + + + v3 Offset = V3(0); + v3 Basis = Offset + WorldspaceChunkBasis + (v3(x,y,z)*ChunkResolution); + + ivec2 InputTexCoord = ivec2(gl_FragCoord.x + 1, (y + 1) + (z * 68) + 68 ); + v4 TexLookup = texelFetch(InputTex, InputTexCoord, 0); + v3 NormalValue = texelFetch(DerivsTex, ivec2(gl_FragCoord.xy) + ivec2(0, 0), 0).xyz; + + // NOTE(Jesse): Set these in the -- user code -- section + vec3 ColorValue = TexLookup.rgb; + f32 NoiseValue = TexLookup.a; + // + // -- user code -- + // + + { + v3 xyz = Basis/50.f; + f32 Billow = billow_noise(xyz, 5)*40.f; + NoiseValue += 10000.f; + } + + // + // -- end user code -- + // + + Output.rgb = ColorValue; + Output.a = NoiseValue; + + /* Output = (SolidBit << 15) | PackedColor; */ +} diff --git a/shaders/terrain/decoration/cliffy_hills.fragmentshader b/shaders/terrain/decoration/cliffy_hills.fragmentshader new file mode 100644 index 000000000..2d9a5751c --- /dev/null +++ b/shaders/terrain/decoration/cliffy_hills.fragmentshader @@ -0,0 +1,109 @@ +uniform v3 WorldspaceChunkBasis; +uniform v3 ChunkResolution; + +uniform sampler2D DerivsTex; +uniform sampler2D InputTex; + +in vec2 UV; +out v4 Output; + +v4 DoCliffs(v3 Basis, v3 Deriv, v3 InputColor) +{ + v3 Up = V3(0, 0, 1); + v3 Down = V3(0, 0, -1); + + f32 Cliffness = Clamp01(-dot(Up, Deriv) + 0.6f); + f32 Grassness = Clamp01(.15f-Cliffness); + + v3 BaseCliffColor = V3(0.08f); + v3 CliffColor = BaseCliffColor; + f32 CliffValue = 0.f; + + { + v3 v = voronoi_noise(Basis/v3(800,800,500)); + CliffValue += (v.x*2500)*Cliffness; + } + { + v3 v = voronoi_noise(Basis/v3(200,200,1800)); + CliffValue += (v.y*50)*Cliffness; + CliffValue += (v.x*100)*Cliffness; + } + { + v3 v = voronoi_noise(Basis/v3(50,50,100)); + CliffValue += (v.x*100)*Cliffness; + } + + + CliffColor = V3(abs(Cliffness)); + CliffColor = Cliffness > 0.15f ? BaseCliffColor : InputColor; + f32 FullColorThresh = 0.25f; + if (Cliffness > 0.f) + { + if (Cliffness > FullColorThresh) + { + CliffColor = BaseCliffColor; + } + else + { + f32 white = FullColorThresh*white_noise(Basis); + if (white < Cliffness) + { + CliffColor = BaseCliffColor; + } + else + { + CliffColor = InputColor; + } + } + } + + + return V4(CliffColor, CliffValue); +} + +void main() +{ + f32 x = floor(gl_FragCoord.x); + f32 z = floor(gl_FragCoord.y / 66); + f32 y = floor(gl_FragCoord.y - (z*66)); + + + v3 Offset = V3(0); + v3 Basis = Offset + WorldspaceChunkBasis + (v3(x,y,z)*ChunkResolution); + + ivec2 InputTexCoord = ivec2(gl_FragCoord.x + 1, (y + 1) + (z * 68) + 68 ); + v4 TexLookup = texelFetch(InputTex, InputTexCoord, 0); + v3 NormalValue = texelFetch(DerivsTex, ivec2(gl_FragCoord.xy) + ivec2(0, 0), 0).xyz; + + // NOTE(Jesse): Set these in the -- user code -- section + vec3 ColorValue = TexLookup.rgb; + f32 NoiseValue = TexLookup.a; + // + // -- user code -- + // + + { + + // Put random junk here + f32 CosTheta = Dot(NormalValue, Normalize(V3(0,0,1))); + + v4 Cliffs = DoCliffs(Basis, NormalValue, ColorValue); + ColorValue = Cliffs.rgb; + + f32 CliffContrib = exp((-Basis.z)/1300.f); + NoiseValue += Cliffs.w * CliffContrib; + } + + // + // -- end user code -- + // + + Output.rgb = ColorValue; + Output.a = NoiseValue; + + /* uint SolidBit = NoiseValue > 0.f ? 1u : 0u; */ + /* uint PackedColor = PackRGB(ColorValue); */ + /* /1* uint PackedColor = 3543u; *1/ */ + + /* Output = (SolidBit << 15) | PackedColor; */ +} diff --git a/shaders/terrain/decoration/default.fragmentshader b/shaders/terrain/decoration/default.fragmentshader new file mode 100644 index 000000000..94f649303 --- /dev/null +++ b/shaders/terrain/decoration/default.fragmentshader @@ -0,0 +1,45 @@ +uniform v3 WorldspaceChunkBasis; +uniform v3 ChunkResolution; + +uniform sampler2D DerivsTex; +uniform sampler2D InputTex; + +in vec2 UV; +out v4 Output; + +void main() +{ + f32 x = floor(gl_FragCoord.x); + f32 z = floor(gl_FragCoord.y / 66); + f32 y = floor(gl_FragCoord.y - (z*66)); + + + v3 Offset = V3(0); + v3 Basis = Offset + WorldspaceChunkBasis + (v3(x,y,z)*ChunkResolution); + + ivec2 InputTexCoord = ivec2(gl_FragCoord.x + 1, (y + 1) + (z * 68) + 68 ); + v4 TexLookup = texelFetch(InputTex, InputTexCoord, 0); + v3 NormalValue = texelFetch(DerivsTex, ivec2(gl_FragCoord.xy) + ivec2(0, 0), 0).xyz; + + // NOTE(Jesse): Set these in the -- user code -- section + vec3 ColorValue = TexLookup.rgb; + f32 NoiseValue = TexLookup.a; + + // + // -- user code -- + // + + { + if (length(ColorValue) < 0.01f) + { + ColorValue = V3(0.1f, 0.8f, 0.1f); + } + } + + // + // -- end user code -- + // + + Output.rgb = ColorValue; + Output.a = NoiseValue; +} diff --git a/shaders/terrain/decoration/derivs.fragmentshader b/shaders/terrain/decoration/derivs.fragmentshader new file mode 100644 index 000000000..1ee7af9b5 --- /dev/null +++ b/shaders/terrain/decoration/derivs.fragmentshader @@ -0,0 +1,42 @@ +uniform v3 WorldspaceChunkBasis; +uniform v3 ChunkResolution; + +uniform sampler2D DerivsTex; +uniform sampler2D InputTex; + +in vec2 UV; +out v4 Output; + +void main() +{ + f32 x = floor(gl_FragCoord.x); + f32 z = floor(gl_FragCoord.y / 66); + f32 y = floor(gl_FragCoord.y - (z*66)); + + + v3 Offset = V3(0); + v3 Basis = Offset + WorldspaceChunkBasis + (v3(x,y,z)*ChunkResolution); + + ivec2 InputTexCoord = ivec2(gl_FragCoord.x + 1, (y + 1) + (z * 68) + 68 ); + v4 TexLookup = texelFetch(InputTex, InputTexCoord, 0); + v3 NormalValue = texelFetch(DerivsTex, ivec2(gl_FragCoord.xy) + ivec2(0, 0), 0).xyz; + + // NOTE(Jesse): Set these in the -- user code -- section + vec3 ColorValue = TexLookup.rgb; + f32 NoiseValue = TexLookup.a; + + // + // -- user code -- + // + + { + ColorValue = abs(NormalValue); + } + + // + // -- end user code -- + // + + Output.rgb = ColorValue; + Output.a = NoiseValue; +} diff --git a/shaders/terrain/derivs.fragmentshader b/shaders/terrain/derivs.fragmentshader new file mode 100644 index 000000000..fe6849573 --- /dev/null +++ b/shaders/terrain/derivs.fragmentshader @@ -0,0 +1,15 @@ +uniform v3 ChunkResolution; + +uniform sampler2D InputTex; + +in vec2 UV; +out vec3 Output; + + +void main() +{ + ivec2 InputTexDim = ivec2(68); + ivec2 OutputTexDim = ivec2(66); + + Output = ComputeNormal(InputTex, gl_FragCoord.xy, InputTexDim, OutputTexDim, ChunkResolution.z); +} diff --git a/shaders/terrain/shaping/0_gradient.fragmentshader b/shaders/terrain/shaping/0_gradient.fragmentshader new file mode 100644 index 000000000..258476052 --- /dev/null +++ b/shaders/terrain/shaping/0_gradient.fragmentshader @@ -0,0 +1,58 @@ +uniform v3 WorldspaceChunkBasis; +uniform v3 ChunkResolution; + +in vec2 UV; +out v4 Output; + +void main() +{ + f32 x = floor(gl_FragCoord.x); + f32 z = floor(gl_FragCoord.y / 68); + f32 y = floor(gl_FragCoord.y - (z*68)); + + v3 Offset = V3(-1, -1, -1); + v3 Basis = Offset + WorldspaceChunkBasis + (v3(x,y,z)*ChunkResolution); + + // NOTE(Jesse): Set these in the -- user code -- section + v3 ColorValue = V3(0.f); + f32 NoiseValue = 0.f; + + // + // -- user code -- + // + { + v3 Period = V3(100.f); + float Amplitude = 200.f; + f32 StartingZDepth = DEFAULT_FLOOR_HEIGHT; + s32 Octaves = 1; + + NoiseValue = StartingZDepth; + + v3 deriv = v3(0.f); + f32 warp = 0.f; + + for (s32 Octave = 1; Octave <= Octaves; ++Octave) + { + v3 xyz = Basis / (Period/Octave); + + v4 gn = gradient_noise_derivs(xyz+warp); + deriv += gn.yzw; + + NoiseValue = NoiseValue + (gn.x * (Amplitude/Octave)); + } + + deriv = normalize(deriv); + ColorValue = abs(deriv); + + // Bias noise value to lower values as we get higher in z. + // This creates a "plane" of terrain + NoiseValue = NoiseValue - Basis.z; + } + + // + // -- end user code -- + // + + Output.rgb = ColorValue; + Output.a = NoiseValue; +} diff --git a/shaders/terrain/shaping/1_FBM_large.fragmentshader b/shaders/terrain/shaping/1_FBM_large.fragmentshader new file mode 100644 index 000000000..c0c0d4293 --- /dev/null +++ b/shaders/terrain/shaping/1_FBM_large.fragmentshader @@ -0,0 +1,51 @@ +uniform v3 WorldspaceChunkBasis; +uniform v3 ChunkResolution; + +in vec2 UV; +out v4 Output; + + +void main() +{ + f32 x = floor(gl_FragCoord.x); + f32 z = floor(gl_FragCoord.y / 68); + f32 y = floor(gl_FragCoord.y - (z*68)); + + v3 Basis = WorldspaceChunkBasis + (v3(x,y,z)*ChunkResolution); + + // NOTE(Jesse): Set these in the -- user code -- section + v3 ColorValue = V3(0.f); + f32 NoiseValue = 0.f; + + // + // -- user code -- + // + { + + v3 Period = V3(1800.f); + float Amplitude = 1000.f; + f32 StartingZDepth = DEFAULT_FLOOR_HEIGHT; + s32 Octaves = 3; + NoiseValue = StartingZDepth; + + f32 warp = 0.f; + + for (s32 Octave = 1; Octave <= Octaves; ++Octave) + { + v3 xyz = Basis / (Period/Octave); + + f32 gn = gradient_noise_derivs(xyz+warp).x; + NoiseValue += gn*(Amplitude/Octave); + } + + NoiseValue -= Basis.z; + ColorValue = V3(0.2f, 0.8f, 0.15f); + } + + // + // -- end user code -- + // + + Output.rgb = ColorValue; + Output.a = NoiseValue; +} diff --git a/shaders/terrain/shaping/1_FBM_small.fragmentshader b/shaders/terrain/shaping/1_FBM_small.fragmentshader new file mode 100644 index 000000000..34d5ed69d --- /dev/null +++ b/shaders/terrain/shaping/1_FBM_small.fragmentshader @@ -0,0 +1,51 @@ +uniform v3 WorldspaceChunkBasis; +uniform v3 ChunkResolution; + +in vec2 UV; +out v4 Output; + + +void main() +{ + f32 x = floor(gl_FragCoord.x); + f32 z = floor(gl_FragCoord.y / 68); + f32 y = floor(gl_FragCoord.y - (z*68)); + + v3 Basis = WorldspaceChunkBasis + (v3(x,y,z)*ChunkResolution); + + // NOTE(Jesse): Set these in the -- user code -- section + v3 ColorValue = V3(0.f); + f32 NoiseValue = 0.f; + + // + // -- user code -- + // + { + + v3 Period = V3(500.f); + float Amplitude = 150.f; + f32 StartingZDepth = DEFAULT_FLOOR_HEIGHT; + s32 Octaves = 5; + NoiseValue = StartingZDepth; + + f32 warp = 0.f; + + for (s32 Octave = 1; Octave <= Octaves; ++Octave) + { + v3 xyz = Basis / (Period/Octave); + + f32 gn = gradient_noise_derivs(xyz+warp).x; + NoiseValue += gn*(Amplitude/Octave); + } + + NoiseValue -= Basis.z; + ColorValue = V3(0.2f, 0.8f, 0.15f); + } + + // + // -- end user code -- + // + + Output.rgb = ColorValue; + Output.a = NoiseValue; +} diff --git a/shaders/terrain/shaping/2_voronoi.fragmentshader b/shaders/terrain/shaping/2_voronoi.fragmentshader new file mode 100644 index 000000000..efbb4f57b --- /dev/null +++ b/shaders/terrain/shaping/2_voronoi.fragmentshader @@ -0,0 +1,111 @@ + +uniform v3 WorldspaceChunkBasis; +uniform v3 ChunkResolution; + +in vec2 UV; +out vec4 Output; + +vec3 vhash(vec3 UV, vec3 offset) +{ + mat3 m = mat3(127.1,311.7, 74.7,269.5,183.3,246.1,113.5,271.9,124.6); + UV = fract(sin(UV* m) * 46839.32); + return vec3(sin(UV.z * +offset.x) * 0.5 + 0.5, cos(UV.x* offset.y) * 0.5 + 0.5,tan(UV.y * offset.z) * 0.5 + 0.5); +} + +#if 1 +vec4 voronoi_noise(vec3 p, vec3 AngleOffset, vec3 CellDensity) +{ + vec3 g = floor(p * CellDensity); + vec3 f = fract(p * CellDensity); + float res = 8.0; + float md=8.0; + vec3 mr; + vec4 Out; + for( int z=-1; z<=1; z++ ) + for( int y=-1; y<=1; y++ ) + for( int x=-1; x<=1; x++ ) + { + vec3 lattice = vec3(x,y,z); + vec3 offset=vhash(lattice + g ,AngleOffset); + vec3 r = lattice +offset -f; + float d = dot( r, r ); + if (d < res) + { + res=d; + mr=r; + } + } + + res = 8.0; + for( int z=-1; z<=1; z++ ) + for( int y=-1; y<=1; y++ ) + for( int x=-1; x<=1; x++ ) + { + vec3 lattice = vec3(x,y,z); + vec3 offset=vhash(lattice + g ,AngleOffset); + vec3 r = lattice +offset -f; + float d = dot( r, r ); + if( d < res ) + { + res = d; + Out.x= offset.x; + Out.y = d; + } + if( dot(mr-r,mr-r)>0.00001) + { + md = min( md, dot( 0.5*(mr+r), normalize(r-mr) ) ); + } + } + Out.z = mix(1.0, 0.0, smoothstep( 0.0, 0.1, md )); + Out.w = 1.0-smoothstep( 0.0, 0.1, res); + return Out; +} +#endif + +void main() +{ + + f32 x = floor(gl_FragCoord.x); + f32 z = floor(gl_FragCoord.y / 68); + f32 y = floor(gl_FragCoord.y - (z*68)); + + v3 Offset = V3(-2); + v3 Basis = Offset + WorldspaceChunkBasis + (v3(x,y,z)*ChunkResolution); + + // NOTE(Jesse): Set these in the -- user code -- section + v3 ColorValue = V3(0.f); + f32 NoiseValue = 0.f; + + // + // -- user code -- + // + { + v3 Period = V3(100.f); + float Amplitude = 200.f; + f32 StartingZDepth = DEFAULT_FLOOR_HEIGHT; + s32 Octaves = 1; + + NoiseValue = StartingZDepth; + + f32 warp = 0.f; + + for (s32 Octave = 1; Octave <= Octaves; ++Octave) + { + v3 xyz = Basis / (Period/Octave); + v4 gn = voronoi_noise(xyz+warp, V3(1.f), V3(1.f)); + ColorValue += gn.yzw; + NoiseValue = NoiseValue + (gn.x * (Amplitude/Octave)); + } + + ColorValue = abs(normalize(ColorValue)); + + NoiseValue = NoiseValue - Basis.z; + } + + // + // -- end user code -- + // + + Output.rgb = ColorValue; + Output.a = NoiseValue; +} diff --git a/shaders/terrain/shaping/3_cliffy_hills.fragmentshader b/shaders/terrain/shaping/3_cliffy_hills.fragmentshader new file mode 100644 index 000000000..3698c286b --- /dev/null +++ b/shaders/terrain/shaping/3_cliffy_hills.fragmentshader @@ -0,0 +1,280 @@ +uniform v3 WorldspaceChunkBasis; +uniform v3 ChunkResolution; + +in vec2 UV; +out v4 Output; + + + + +f32 +RoundToNearestMultiple(f32 NumToRound, f32 Multiple) +{ + f32 Remainder = mod(NumToRound, Multiple); + if (Remainder == 0) + return NumToRound; + + return NumToRound + Multiple - Remainder; +} + +void main() +{ + f32 x = floor(gl_FragCoord.x); + f32 z = floor(gl_FragCoord.y / 68); + f32 y = floor(gl_FragCoord.y - (z*68)); + + /* v3 Offset = V3(-1, -1, -1); */ + v3 Offset = V3(0); + v3 Basis = Offset + WorldspaceChunkBasis + (v3(x,y,z)*ChunkResolution); + +#if 0 + { + v3 TileCoord = trunc(Basis/16.f); + TileCoord.z = 0.f; + f32 TileNoise = white_noise(TileCoord); + + f32 zMod = mod(Basis.z, 16.f)/16.f; + + f32 Soften = clamp(zMod-0.4f, 0.f, 1.f)*16.f; + + Basis.z = Basis.z - zMod + Soften; //+ TileNoise; + } +#endif + +#if 0 + Basis.z = RoundToNearestMultiple(Basis.z, 16.f); +#endif + + // NOTE(Jesse): Set these in the -- user code -- section + v3 ColorValue = V3(0.f); + f32 NoiseValue = 0.f; + + // + // -- user code -- + // + { + v3 Period = V3(1500.f); + float Amplitude = 100.f; + f32 StartingZDepth = DEFAULT_FLOOR_HEIGHT; + /* f32 StartingZDepth = 0; */ + s32 Octaves = 6; + NoiseValue = StartingZDepth; + +#if 1 + { + f32 Start = 8000; + f32 End = 10000; + f32 Width = End-Start; + f32 Rad = Width/2.f; + /* f32 Power = 2000.f; */ + /* f32 Power = 0.001f; */ + f32 Power = 1000.f; + + f32 CircleOrigin = Start + Rad; + + /* if (Basis.x > Start && Basis.y > Start && */ + /* Basis.x < End && Basis.y < End) */ + { + v2 OriginRelativeBasis = 0.30f*((Basis.xy-CircleOrigin)/Rad); + /* v2 t = sin(PI32*(0.5f+(OriginRelativeBasis/Width))); */ + /* f32 t = sin(PI32*max(0.f, Rad - length(OriginRelativeBasis))); */ + f32 t = sin( Rad - length(OriginRelativeBasis)); + /* NoiseValue += min(t.x*Power, t.y*Power); */ + NoiseValue += t*Power; + } + } +#endif + + v3 Deriv = v3(0.f); + f32 warp = 0.f; + + for (s32 Octave = 1; Octave <= Octaves; ++Octave) + { + v3 xyz = Basis / (Period/Octave); + + v4 gn = gradient_noise_derivs(xyz+warp); + NoiseValue += gn.x*(Amplitude/Octave); + Deriv += gn.yzw; + } + + v3 Up = V3(0, 0, 1); + + /* NoiseValue = 100.f+RempaSample(NoiseValue); */ + + Deriv = normalize(Deriv); + /* Deriv.xy = abs(Deriv.xy); */ + f32 Cliffness = clamp(dot(Deriv, Up), 0.f, 1.f); + f32 Grassness = clamp(.15f-Cliffness, 0.f, 1.f); + + ColorValue = mix(v3(.1,.8,.2), v3(.3), Cliffness); + /* ColorValue = mix(v3(.1,.8,.2), v3(.3), pow(Cliffness, .2)); */ + /* ColorValue = Cliffness > 0.15f ? V3(0.3f) : v3(.1,.8,.2); */ + + // Grassy ripples + { + v4 gWobble = gradient_noise_derivs(Basis/v3(30, 30, 80)); + NoiseValue += gWobble.x*Grassness*50; + ColorValue += V3(0.f, 1.f, 0.f)*gWobble.x*Grassness*1.5f; + } + + +#if 1 + f32 rng2d = white_noise(Basis.xy); + f32 rng3d = white_noise(Basis); + + v3 BaseCliffColor = V3(0.08f); + v3 CliffColor = BaseCliffColor; + f32 CliffValue = 0.f; + // Main cliffs + { + v3 v = voronoi_noise(Basis/v3(200,200,1800)); + CliffValue += (v.x*200)*Cliffness; + CliffValue += (v.y*25)*Cliffness; + CliffColor = mix(CliffColor, BaseCliffColor, clamp(10*Cliffness*v.x,0,1)); + } + { + v3 v = voronoi_noise(Basis/v3(100,100,600)); + v.x += 0.5f; + v.x = v.x*v.x; + + if (v.x > 0.28f) + { + CliffValue += (v.x*25)*Cliffness; + /* CliffValue += (v.y*10)*Cliffness; */ + CliffColor = mix(CliffColor, v3(.7), Cliffness*v.x); + } + } + { + v3 v = voronoi_noise(Basis/v3(50,50,200)); + v.x += 0.50f; + v.x = v.x * v.x; + + if (v.x > 0.30) + { + /* CliffValue += (v.x)*Cliffness; */ + CliffValue += (v.x*10)*pow(Cliffness,3); + CliffColor = mix(CliffColor, v3(.9), Cliffness*v.x*v.x); + } + } + { + CliffValue += rng3d * 0.1f; + CliffColor = mix(CliffColor, v3(1.f), rng3d*Cliffness*.2); + } + + if (CliffValue > 12.f) + { + NoiseValue += CliffValue; + ColorValue = CliffColor; + } + + + f32 gravel_patch_stregth = value_noise_derivs(150+(Basis/300)).x; + gravel_patch_stregth += value_noise_derivs(150+(Basis/160)).x; + gravel_patch_stregth += value_noise_derivs(150+(Basis/80)).x; + gravel_patch_stregth += value_noise_derivs(150+(Basis/40)).x; + gravel_patch_stregth += value_noise_derivs(150+(Basis/20)).x; + gravel_patch_stregth += value_noise_derivs(150+(Basis/8)).x; + gravel_patch_stregth = max(gravel_patch_stregth, 0.f); + + + // Grass & Flowers + { + f32 n = clamp(rng2d-0.7f, 0.f, 1.f); + + f32 GrassValue = 90*n*Grassness; + + f32 tFlower = Basis.z - (GrassValue + NoiseValue); + tFlower = max(tFlower, 0); + + + f32 grass_patch_stregth = value_noise_derivs(Basis/80).x; + grass_patch_stregth += value_noise_derivs(Basis/40).x; + grass_patch_stregth += value_noise_derivs(Basis/20).x; + grass_patch_stregth += value_noise_derivs(Basis/8).x; + grass_patch_stregth = max(grass_patch_stregth-gravel_patch_stregth, 0.f); + + NoiseValue += GrassValue*grass_patch_stregth; + + f32 tColor = (grass_patch_stregth / 2.f)*Grassness; + ColorValue = mix(ColorValue, V3(.6f, .8f, .1f), tColor); + + if (rng2d > 0.99f) + { + ColorValue = mix(ColorValue, V3(.5f, .5f, .5f), tFlower); + } + if (rng2d > 0.995f) + { + ColorValue = mix(ColorValue, V3(.5f, .2f, .5f), tFlower); + } + + + /* ColorValue *= tFlower; */ + + /* ColorValue = V3(tFlower); */ + /* ColorValue = V3(GrassValue/1.f); */ + } + + // Rocky edges + { + f32 MinDotValue = 0.6f; + v3 v = voronoi_noise(Basis/v3(20,20,20)); + f32 Power = 100*gravel_patch_stregth*Cliffness*abs(clamp(Cliffness-MinDotValue, -MinDotValue, 0)); + if (v.x*Power > 3.f) + { + NoiseValue += v.x*Power; + ColorValue = v3(1.0); + } + } + /* { */ + /* f32 MinDotValue = 0.4f; */ + /* v3 v = voronoi_noise(Basis/v3(10,10,10)); */ + /* f32 Power = 400*gravel_patch_stregth*Cliffness*abs(clamp(Cliffness-MinDotValue, -MinDotValue, 0)); */ + /* NoiseValue += v.x*Power; */ + /* /1* NoiseValue -= ((1.f/v.x)*2)*Power; *1/ */ + /* ColorValue = mix(ColorValue, v3(1.0), Power/3*v.x); */ + /* } */ + + + /* ColorValue = V3(Grassness, Cliffness, 0.f); */ + /* ColorValue = V3(Cliffness); */ + + // Bias noise value to lower values as we get higher in z. + // This creates a "plane" of terrain + /* NoiseValue = NoiseValue - Basis.z + sin(Basis.x/500.f)*1000.f; */ + /* NoiseValue = NoiseValue - Basis.z + sin(Basis.x/500.f)*300.f - cos(Basis.y/800.f)*200.f;; */ + NoiseValue -= Basis.z; + +#if 0 + if (NoiseValue <= 0) + { + v3 TileCoord = trunc(Basis/16.f); + TileCoord.z = 0.f; + + f32 TileNoise = white_noise(TileCoord)*14.f; + + f32 NoiseToTile = TileNoise - NoiseValue; + NoiseToTile = clamp(NoiseToTile, -1, 1); + + NoiseValue += NoiseToTile; + } +#endif +#endif + + /* NoiseValue = StartingZDepth; */ + + } + + // + // -- end user code -- + // + + Output.rgb = ColorValue; + Output.a = NoiseValue; + + /* uint SolidBit = NoiseValue > 0.f ? 1u : 0u; */ + /* ColorValue = min(ColorValue, v3(1.f)); */ + /* uint PackedColor = PackRGB(ColorValue); */ + /* /1* uint PackedColor = 3543u; *1/ */ + + /* Output = (SolidBit << 15) | PackedColor; */ +} diff --git a/shaders/terrain/shaping/4_dottedboxguy_arch.fragmentshader b/shaders/terrain/shaping/4_dottedboxguy_arch.fragmentshader new file mode 100644 index 000000000..026d5648e --- /dev/null +++ b/shaders/terrain/shaping/4_dottedboxguy_arch.fragmentshader @@ -0,0 +1,136 @@ +uniform v3 WorldspaceChunkBasis; +uniform v3 ChunkResolution; + +in vec2 UV; +out vec4 Output; + +float sstep(float init_x){ + float x = clamp(init_x,-1.,1.); + x = abs(x); + return sign(init_x)*(x*(2.-x)); +} +#define PI 3.14159265359 +#define PI_INV 0.31830988618 + +float dot2( in vec2 v ) { return dot(v,v); } + +//trapezoid SDF from IQ +float sdTrapezoid( in vec2 p, in float r1, float r2, float he ){ + p = vec2(p.y, -p.x); + vec2 k1 = vec2(r2,he); + vec2 k2 = vec2(r2-r1,2.0*he); + p.x = abs(p.x); + vec2 ca = vec2(p.x-min(p.x,(p.y<0.0)?r1:r2), abs(p.y)-he); + vec2 cb = p - k1 + k2*clamp( dot(k1-p,k2)/dot2(k2), 0.0, 1.0 ); + float s = (cb.x<0.0 && ca.y<0.0) ? -1.0 : 1.0; + return s*sqrt( min(dot2(ca),dot2(cb)) ); +} + +float brick_size(float id, float n, float r){ + return (cos(mod(round(id)+.4, 2.)*PI)*.5+.5)*.5*r; +} + +float sdBrickCircle(vec2 p, float r, float n, float padding, float rotation){ + + float inv_n = 1./n; + rotation *= n; + + vec2 point = normalize(p); + float angle = atan(point.y, point.x); // angle from the x axis + float neighbor = 0.; + + //quantization of the normal's angle. you must normalize the angle before doing quantization + angle *= n*PI_INV; + + angle += rotation; + + angle = floor(angle); + + vec2 ids = vec2(angle); + + angle -= rotation; + + ids.y += 1.; + + neighbor = angle + 1.; + + angle *= inv_n; + angle *= PI; + neighbor *=PI*inv_n; + + //recunstructing the normals + vec2 right = vec2(cos(angle), sin(angle)); + vec2 left = vec2(cos(neighbor), sin(neighbor)); + + vec2 sizes = vec2(brick_size(ids.x, n, r), brick_size(ids.y, n, r)); + + //note : you can make the brick size not depend on the radius by removing r here + vec4 radii = vec4((1.-cos(inv_n*PI))/sin(inv_n*PI)); + radii *= r + vec4(sizes.x, -sizes.x, sizes.y, -sizes.y); + radii-=padding; + + vec3 brick0 = vec3(sizes.x, radii.x, radii.y); + vec3 brick1 = vec3(sizes.y, radii.z, radii.w); + + vec2 p_right = vec2(p.x*right.x + p.y*right.y, p.x*right.y - p.y*right.x); + p_right.x-=r; + + float d = sdTrapezoid(p_right, brick0.y, brick0.z, brick0.x); + + vec2 p_left = vec2(p.x*left.x + p.y*left.y, p.x*left.y - p.y*left.x); + p_left.x-=r; + + d = min(d, sdTrapezoid(p_left, brick1.y, brick1.z, brick1.x)); + + return d; +} + +void main() +{ + f32 x = floor(gl_FragCoord.x); + f32 z = floor(gl_FragCoord.y / 68); + f32 y = floor(gl_FragCoord.y - (z*68)); + + v3 Offset = V3(-1, -1, -1); + v3 Basis = Offset + WorldspaceChunkBasis + (v3(x,y,z)*ChunkResolution); + Basis *= .2; + + // NOTE(Jesse): Set these in the -- user code -- section + v3 ColorValue = V3(0.f); + f32 NoiseValue = 0.f; + + // + // -- user code -- + // + { + vec3 p = Basis; + float size = 200; + + f32 d = sdBrickCircle(p.xz-size, size*.5, 10., 1., 0.); + + vec3 col = (d>0.0) ? vec3(0.9,0.6,0.3) : vec3(0.65,0.85,1.0); + col *= 1.0 - exp(-9.0*abs(d)); + col *= 0.8 + 0.2*cos(1.0*d); + col = mix( col, vec3(1.0), 1.0-smoothstep(0.0,1.,abs(d))); + + vec2 w = vec2( d, abs(p.y-80.) - 40. ); + d = min(max(w.x,w.y),0.0) + length(max(w,0.0)); + + ColorValue = col; + + NoiseValue = d ; + } + + // + // -- end user code -- + // + + + Output.rgb = ColorValue; + Output.a = NoiseValue; + /* uint SolidBit = NoiseValue > 0.0f ? 1u : 0u; */ + /* uint PackedColor = PackRGB(ColorValue); */ + /* uint PackedColor = 3543u; */ + + /* Output = (SolidBit << 15) | PackedColor; */ +} diff --git a/shaders/terrain/shaping/5_mandlebulb.fragmentshader b/shaders/terrain/shaping/5_mandlebulb.fragmentshader new file mode 100644 index 000000000..8cc82ba32 --- /dev/null +++ b/shaders/terrain/shaping/5_mandlebulb.fragmentshader @@ -0,0 +1,86 @@ +uniform v3 WorldspaceChunkBasis; +uniform v3 ChunkResolution; + +in vec2 UV; +out vec4 Output; + +vec4 mandlebulb(vec3 p) +{ + p.xyz = p.xzy; + vec3 z = p; + vec3 dz=vec3(0.0); + float power = 6.; + float r, theta, phi; + float dr = 1.2; + + float t0 = 1.0; + for(int i = 0; i < 7; ++i) { + r = length(z); + if(r > 2.0) continue; + theta = atan(z.y / z.x); + #ifdef phase_shift_on + phi = asin(z.z / r) + iTime*0.1; + #else + phi = asin(z.z / r); + #endif + + dr = pow(r, power - 1.0) * dr * power + 1.0; + + r = pow(r, power); + theta = theta * power; + phi = phi * power; + + z = r * vec3(cos(theta)*cos(phi), sin(theta)*cos(phi), sin(phi)) + p; + + t0 = min(t0, r); + } + + f32 Thing = t0; + Thing = pow(clamp(Thing, 0.0, 1.0), 0.55); + vec3 tc0 = 0.5 + 0.5 * sin(3.0 + 4.2 * Thing + vec3(0.0, 0.5, 1.0)); + + vec4 Result = vec4(t0, tc0); + return Result; +} + + +void main() +{ + f32 x = floor(gl_FragCoord.x); + f32 z = floor(gl_FragCoord.y / 68); + f32 y = floor(gl_FragCoord.y - (z*68)); + + v3 Offset = V3(-1, -1, -1); + v3 Basis = Offset + WorldspaceChunkBasis + (v3(x,y,z)*ChunkResolution); + + // NOTE(Jesse): Set these in the -- user code -- section + v3 ColorValue = V3(0.f); + f32 NoiseValue = 0.f; + + // + // -- user code -- + // + + { + v3 Period = V3(100.f); + float Amplitude = 200.f; + f32 StartingZDepth = DEFAULT_FLOOR_HEIGHT; + s32 Octaves = 1; + + NoiseValue = StartingZDepth; + + v3 xyz = Basis / (Period); + v4 gn = mandlebulb((xyz/8.f)-1.4f)*v4(100.f, 1, 3, 18); + ColorValue += abs(normalize(gn.yzw)); + + NoiseValue = NoiseValue + (gn.x * (Amplitude)); + NoiseValue = NoiseValue - Basis.z; + } + + // + // -- end user code -- + // + + Output.rgb = ColorValue; + Output.a = NoiseValue; +} diff --git a/shaders/terrain/shaping/6_trunchet.fragmentshader b/shaders/terrain/shaping/6_trunchet.fragmentshader new file mode 100644 index 000000000..8f42368cf --- /dev/null +++ b/shaders/terrain/shaping/6_trunchet.fragmentshader @@ -0,0 +1,77 @@ +uniform v3 WorldspaceChunkBasis; +uniform v3 ChunkResolution; + +in vec2 UV; +out vec4 Output; + +// https://www.shadertoy.com/view/4td3zj +float heightMap(in vec2 p) { + + p *= 3.; + + // Hexagonal coordinates. + vec2 h = vec2(p.x + p.y*.57735, p.y*1.1547); + + // Closest hexagon center. + vec2 fh = floor(h); + vec2 f = h - fh; h = fh; + float c = fract((h.x + h.y)/3.); + h = c<.666 ? c<.333 ? h : h + 1. : h + step(f.yx, f); + + p -= vec2(h.x - h.y*.5, h.y*.8660254); + + // Rotate (flip, in this case) random hexagons. Otherwise, you'd have a bunch of circles only. + // Note that "h" is unique to each hexagon, so we can use it as the random ID. + c = fract(cos(dot(h, vec2(41, 289)))*43758.5453); // Reusing "c." + p -= p*step(c, .5)*2.; // Equivalent to: if (c<.5) p *= -1.; + + // Minimum squared distance to neighbors. Taking the square root after comparing, for speed. + // Three partitions need to be checked due to the flipping process. + p -= vec2(-1, 0); + c = dot(p, p); // Reusing "c" again. + p -= vec2(1.5, .8660254); + c = min(c, dot(p, p)); + p -= vec2(0, -1.73205); + c = min(c, dot(p, p)); + + return sqrt(c); + + // Wrapping the values - or folding the values over (abs(c-.5)*2., cos(c*6.283*1.), etc) - to produce + // the nicely lined-up, wavy patterns. I"m perfoming this step in the "map" function. It has to do + // with coloring and so forth. + //c = sqrt(c); + //c = cos(c*6.283*1.) + cos(c*6.283*2.); + //return (clamp(c*.6+.5, 0., 1.)); + +} + +void main() +{ + f32 x = floor(gl_FragCoord.x); + f32 z = floor(gl_FragCoord.y / 68); + f32 y = floor(gl_FragCoord.y - (z*68)); + + v3 Offset = V3(-1, -1, -1); + v3 Basis = Offset + WorldspaceChunkBasis + (v3(x,y,z)*ChunkResolution); + Basis *= .2; + + // NOTE(Jesse): Set these in the -- user code -- section + v3 ColorValue = V3(0.f); + f32 StartingZDepth = DEFAULT_FLOOR_HEIGHT; + f32 NoiseValue = StartingZDepth; + + // + // -- user code -- + // + { + f32 H = heightMap(Basis.xy/100.f); + NoiseValue = Basis.z - 10.f + H; + ColorValue = V3(H); + } + + // + // -- end user code -- + // + + Output.rgb = ColorValue; Output.a = NoiseValue; +} diff --git a/shaders/terrain/shaping/7_archway.fragmentshader b/shaders/terrain/shaping/7_archway.fragmentshader new file mode 100644 index 000000000..56811ef78 --- /dev/null +++ b/shaders/terrain/shaping/7_archway.fragmentshader @@ -0,0 +1,117 @@ +uniform v2 SampleRemapCurvePoints[16]; +uniform u32 SampleRemapCurvePointCount; + +uniform v3 WorldspaceChunkBasis; +uniform v3 ChunkResolution; + +in vec2 UV; +out v4 Output; + +void main() +{ + f32 x = floor(gl_FragCoord.x); + f32 z = floor(gl_FragCoord.y / 68); + f32 y = floor(gl_FragCoord.y - (z*68)); + + v3 Offset = V3(0); + v3 Basis = Offset + WorldspaceChunkBasis + (v3(x,y,z)*ChunkResolution); + + // NOTE(Jesse): Set these in the -- user code -- section + v3 ColorValue = V3(0.2f, 0.8f, 0.2f); + f32 NoiseValue = 0.f; + + // + // -- user code -- + // + { + v3 Period = V3(800.f); + float Amplitude = 800.f; + /* f32 StartingZDepth = 10000; */ + f32 StartingZDepth = DEFAULT_FLOOR_HEIGHT; + /* f32 StartingZDepth = 0; */ + NoiseValue = StartingZDepth; + + v3 Deriv = v3(0.f); + /* f32 warp = 0.f; */ + + /* v3 warp = v3(gradient_noise_derivs(Basis).x); */ + v3 warp = v3(0.f); + + f32 Mask; + { + f32 XOff = 700000.f; + v3 xyz = Basis / V3(XOff, XOff, 2000000.f); + Mask = (1.f+gradient_noise_derivs(xyz+warp).x)/2.f; + /* Mask = ridge_noise(xyz); */ + Mask = Smoothstep(Mask); + /* Mask = RemapSample(Mask, SampleRemapCurvePoints, SampleRemapCurvePointCount ); */ + Mask = Mask*1.6; + } + + s32 Octaves = s32(Mask*10); + while (Octaves > 0) + { + v3 xyz = Basis / V3(18000.f, 18000.f, 50000.f) / Octaves; + f32 N = Mask * (1.f+gradient_noise_derivs(xyz+warp).x)/2.f; + NoiseValue += N*N*N*N * (20000.f*Octaves); + + --Octaves; + } + + + // Scrub + { + v3 xyz = Basis / V3(50000.f, 50000.f, 10000.f); + f32 Perturb = 30000.f*(1.f+gradient_noise_derivs(xyz+warp).x)/2.f; + + if ( (NoiseValue+Perturb) > 1030000.f) + { + ColorValue = V3(0.3f, 0.7f, 0.2f); + } + + } + + // Scrub + { + v3 xyz = Basis / V3(50000.f, 50000.f, 10000.f); + f32 Perturb = 30000.f*(1.f+gradient_noise_derivs(xyz+warp).x)/2.f; + + if ( (NoiseValue+Perturb) > 1140000.f) + { + ColorValue = V3(0.4f, 0.6f, 0.3f); + } + + } + + + // Snow + { + /* v3 xyz = Basis / V3(7000.f, 7000.f, 170000.f); */ + /* f32 Perturb = 10000.f*(1.f+gradient_noise_derivs(xyz+warp).x)/2.f; */ + v3 xyz = Basis / V3(50000.f, 50000.f, 100000.f); + f32 Perturb = 30000.f*(1.f+gradient_noise_derivs(xyz+warp).x)/2.f; + + if ( (NoiseValue+Perturb) > 1150000.f) + { + ColorValue = V3(1.f); + } + } + + r32 white = white_noise(Basis); + ColorValue *= Clamp01(1.6f+white); + + + NoiseValue -= Basis.z; + /* NoiseValue = StartingZDepth; */ + + } + + // + // -- end user code -- + // + + Output.rgb = ColorValue; + Output.a = NoiseValue; + + /* Output = (SolidBit << 15) | PackedColor; */ +} diff --git a/shaders/terrain/shaping/7_steep_pillars.fragmentshader b/shaders/terrain/shaping/7_steep_pillars.fragmentshader new file mode 100644 index 000000000..c6961de60 --- /dev/null +++ b/shaders/terrain/shaping/7_steep_pillars.fragmentshader @@ -0,0 +1,78 @@ +uniform v2 SampleRemapCurvePoints[16]; +uniform u32 SampleRemapCurvePointCount; + +uniform v3 WorldspaceChunkBasis; +uniform v3 ChunkResolution; + +in vec2 UV; +out v4 Output; + +void main() +{ + f32 x = floor(gl_FragCoord.x); + f32 z = floor(gl_FragCoord.y / 68); + f32 y = floor(gl_FragCoord.y - (z*68)); + + v3 Offset = V3(0); + v3 Basis = Offset + WorldspaceChunkBasis + (v3(x,y,z)*ChunkResolution); + + // NOTE(Jesse): Set these in the -- user code -- section + v3 ColorValue = V3(0.1f, 0.7f, 0.1f); + f32 NoiseValue = 0.f; + + // + // -- user code -- + // + { + v3 Period = V3(800.f); + float Amplitude = 800.f; + f32 StartingZDepth = DEFAULT_FLOOR_HEIGHT; + NoiseValue = StartingZDepth; + + v3 Deriv = v3(0.f); + /* f32 warp = 0.f; */ + + /* v3 warp = v3(gradient_noise_derivs(Basis).x); */ + v3 warp = v3(0.f); + + f32 Mask; + { + v3 xyz = Basis / V3(100000.f, 100000.f, 1000000.f); + Mask = (1.f+gradient_noise_derivs(xyz+warp).x)/2.f; + } + + Mask = Mask*Mask*Mask * 3.f; +#if 0 + NoiseValue += Mask; +#else + s32 Octaves = 9; + while (Octaves > 0) + { + v3 xyz = Basis / V3(18000.f, 18000.f, 50000.f) / Octaves; + /* v3 N = voronoi_noise(xyz+warp); */ + /* f32 Mask = (gradient_noise_derivs(Basis/20000.f).x+1.f)/2.f; */ + /* Mask = RemapSample(Mask, SampleRemapCurvePoints, SampleRemapCurvePointCount ); */ + f32 N = Mask * (1.f+gradient_noise_derivs(xyz+warp).x)/2.f; + /* f32 Remapped = RemapSample(N, SampleRemapCurvePoints, SampleRemapCurvePointCount ); */ + /* NoiseValue += RemapSample(N, SampleRemapCurvePoints, SampleRemapCurvePointCount ) * 10000.f; */ + /* NoiseValue += Remapped*Remapped * 20000.f; */ + NoiseValue += N*N*N*N * (25000.f*Octaves); + + --Octaves; + } +#endif + + NoiseValue -= Basis.z; + /* NoiseValue = StartingZDepth; */ + + } + + // + // -- end user code -- + // + + Output.rgb = ColorValue; + Output.a = NoiseValue; + + /* Output = (SolidBit << 15) | PackedColor; */ +} diff --git a/shaders/terrain/shaping/7_steep_ravines.fragmentshader b/shaders/terrain/shaping/7_steep_ravines.fragmentshader new file mode 100644 index 000000000..f670dbdf0 --- /dev/null +++ b/shaders/terrain/shaping/7_steep_ravines.fragmentshader @@ -0,0 +1,90 @@ +uniform v2 SampleRemapCurvePoints[16]; +uniform u32 SampleRemapCurvePointCount; + +uniform v3 WorldspaceChunkBasis; +uniform v3 ChunkResolution; + +in vec2 UV; +out v4 Output; + +void main() +{ + f32 x = floor(gl_FragCoord.x); + f32 z = floor(gl_FragCoord.y / 68); + f32 y = floor(gl_FragCoord.y - (z*68)); + + v3 Offset = V3(0); + v3 Basis = Offset + WorldspaceChunkBasis + (v3(x,y,z)*ChunkResolution); + + // NOTE(Jesse): Set these in the -- user code -- section + v3 ColorValue = V3(0.1f, 0.7f, 0.1f); + f32 NoiseValue = 0.f; + + // + // -- user code -- + // + { + v3 Period = V3(800.f); + float Amplitude = 800.f; + /* f32 StartingZDepth = 10000; */ + f32 StartingZDepth = DEFAULT_FLOOR_HEIGHT; + /* f32 StartingZDepth = 0; */ + NoiseValue = StartingZDepth; + + v3 Deriv = v3(0.f); + /* f32 warp = 0.f; */ + + /* v3 warp = v3(gradient_noise_derivs(Basis).x); */ + v3 warp = v3(0.f); + + { + v3 xyz = Basis / (12000.f); + /* v3 N = voronoi_noise(xyz+warp); */ + f32 Mask = (gradient_noise_derivs(Basis/20000.f).x+1.f)/2.f; + /* Mask = RemapSample(Mask, SampleRemapCurvePoints, SampleRemapCurvePointCount ); */ + f32 N = ridge_noise(xyz+warp)*Mask; + /* NoiseValue += RemapSample((N+1.f)/2.f, SampleRemapCurvePoints, SampleRemapCurvePointCount ) * 10000.f; */ + NoiseValue += N * 20000.f; + } + + /* { */ + /* v3 xyz = Basis / (15000.f); */ + /* /1* v3 N = voronoi_noise(xyz+warp); *1/ */ + /* v4 N = gradient_noise_derivs(xyz+warp); */ + /* NoiseValue += RemapSample((N.x+1.f)/2.f, SampleRemapCurvePoints, SampleRemapCurvePointCount ) * 10000.f; */ + /* /1* NoiseValue += N.x * 20000.f; *1/ */ + /* } */ + + /* { */ + /* v3 xyz = Basis / (Period); */ + /* v4 N = gradient_noise_derivs(xyz+warp); */ + /* NoiseValue += RemapSample((N.x+1.f)/2.f, SampleRemapCurvePoints, SampleRemapCurvePointCount ) * Amplitude; */ + /* } */ + + /* s32 Octaves = 4; */ + /* f32 B = 0.f; */ + /* for (s32 Octave = 1; Octave <= Octaves; ++Octave) */ + /* { */ + /* v3 xyz = Basis / (Period/Octave); */ + /* f32 N = billow_noise(xyz+warp); */ + /* B = max(N, B); */ + /* /1* NoiseValue += RemapSample((N.x+1.f)/2.f, SampleRemapCurvePoints, SampleRemapCurvePointCount )*(Amplitude/Octave); *1/ */ + /* } */ + /* NoiseValue += B * Amplitude; */ + + v3 Up = V3(0, 0, 1); + + NoiseValue -= Basis.z; + /* NoiseValue = StartingZDepth; */ + + } + + // + // -- end user code -- + // + + Output.rgb = ColorValue; + Output.a = NoiseValue; + + /* Output = (SolidBit << 15) | PackedColor; */ +} diff --git a/shaders/terrain/shaping/8_shaped_voronoi_0.fragmentshader b/shaders/terrain/shaping/8_shaped_voronoi_0.fragmentshader new file mode 100644 index 000000000..41f5214e9 --- /dev/null +++ b/shaders/terrain/shaping/8_shaped_voronoi_0.fragmentshader @@ -0,0 +1,194 @@ +uniform v2 SampleRemapCurvePoints[16]; +uniform u32 SampleRemapCurvePointCount; + +uniform v3 WorldspaceChunkBasis; +uniform v3 ChunkResolution; + +in vec2 UV; +out v4 Output; + + + + + + + + +uvec3 murmurHash33(uvec3 src) { + const uint M = 0x5bd1e995u; + uvec3 h = uvec3(1190494759u, 2147483647u, 3559788179u); + src *= M; src ^= src>>24u; src *= M; + h *= M; h ^= src.x; h *= M; h ^= src.y; h *= M; h ^= src.z; + h ^= h>>13u; h *= M; h ^= h>>15u; + return h; +} + +vec3 hash(vec3 src) { + uvec3 h = murmurHash33(floatBitsToUint(src)); + return uintBitsToFloat(h & 0x007fffffu | 0x3f800000u) - 1.0; +} + +float sdLpDistance(in vec2 p, in float r, in float p_norm) { + // (|x|^p + |y|^p)^(1/p) + vec2 q = abs(p); + float d = pow(pow(q.x, p_norm) + pow(q.y, p_norm), 1.0 / p_norm); + return d - r; +} + +vec2 get_point(vec2 pos) { + ivec2 p = ivec2(floor(pos - 1.)) * 3; + vec3 rng = hash(vec3(float(p.x), float(p.y), float(p.x + p.y))); + return rng.xy; +} + +const vec2 offsets[24] = vec2[24]( + vec2(-2, -2), vec2(-1, -2), vec2(0, -2), vec2(1, -2), vec2(2, -2), + vec2(-2, -1), vec2(-1, -1), vec2(0, -1), vec2(1, -1), vec2(2, -1), + vec2(-2, 0), vec2(-1, 0), vec2(1, 0), vec2(2, 0), + vec2(-2, 1), vec2(-1, 1), vec2(0, 1), vec2(1, 1), vec2(2, 1), + vec2(-2, 2), vec2(-1, 2), vec2(0, 2), vec2(1, 2), vec2(2, 2) +); + +float sdShape(vec2 pos) { + float p_norm = 3.25f; + return sdLpDistance(pos, 0.9, p_norm); +} + +float sdVoronoi(vec2 pos) { + pos -= 0.5; + vec2 p = fract(pos); + + vec2 nearest = get_point(pos); + vec2 lastnearest = vec2(100.); + vec2 current = vec2(0.); + + vec3 dists = vec3( + sdShape(p - nearest), + sdShape(p - lastnearest), + sdShape(p - current) + ); + + for (int i = 0; i < 24; i++) { + current = offsets[i]; + current += get_point(pos + offsets[i]); + dists.z = sdShape(p - current); + if (dists.z < dists.y) { + dists.yz = dists.zy; + lastnearest = current; + } + if (dists.y < dists.x) { + dists.xy = dists.yx; + lastnearest = nearest; + nearest = current; + } + } + + float d = sdShape(p - lastnearest); + return d; +} + +float scene(vec2 p) { + float d = sdVoronoi(p); + return d; +} + +/* vec4 noise( vec2 uv ) { */ +/* vec2 m = vec2(0,0); */ +/* float d = scene(uv); */ + +/* vec3 col = (d>0.0) ? vec3(0.9,0.6,0.3) : vec3(0.65,0.85,1.0); */ +/* col *= 2.0 - exp(-6.0*abs(d)); */ +/* col *= 0.8 + 0.2*cos(150.0*d); */ +/* col = mix( col, vec3(1.0), 1.0-smoothstep(0.0,0.01,abs(d))); */ + +/* if(uv.x<0.)col = vec3(smoothstep(-1., 1., d)); */ + +/* if (d<0.01 && d>0.){col = vec3(0.);} */ + +/* v4 Result = vec4(col,d); */ +/* return Result; */ +/* } */ + + +v4 noise(vec2 uv) +{ + + float d = scene(uv); + v2 m = v2(0); + + + vec3 col = (d > 0.0) ? vec3(0.9, 0.6, 0.3) : vec3(0.65, 0.85, 1.0); + col *= 1.0 - exp(-6.0 * abs(d)); + col *= 0.8 + 0.2 * cos(150.0 * d); + col = mix(col, vec3(1.0), 1.0 - smoothstep(0.0, 0.01, abs(d))); + + if (uv.x < 0.) col = vec3(smoothstep(-1., 1., d)); + + /* d = length(uv - m) - abs(scene(m)); */ + + if (d < 0.01 && d > 0.) col = vec3(0.); + + v4 Result = vec4(col, d); + return Result; +} + + +f32 ClampPositive(f32 Value) +{ + return Value < 0.f ? 0.f : Value; +} + + + + +void main() +{ + f32 x = floor(gl_FragCoord.x); + f32 z = floor(gl_FragCoord.y / 68); + f32 y = floor(gl_FragCoord.y - (z*68)); + + + vec3 Offset = vec3(0); + vec3 Basis = Offset + WorldspaceChunkBasis + (vec3(x,y,z)*ChunkResolution); + + + // NOTE(Jesse): Set these in the -- user code -- section + vec3 ColorValue = vec3(0.f); + f32 NoiseValue = 0.f; + + // + // -- user code -- + // + { + f32 StartingZDepth = DEFAULT_FLOOR_HEIGHT; + NoiseValue += StartingZDepth - Basis.z; + + f32 CliffMask = 1.f; + { + vec3 Period = vec3(250.f); + /* vec3 Period = vec3(10.f); */ + float Amplitude = 500.f; + + vec3 xyz = Basis / Period; + v4 N = noise(xyz.xy); + + /* N.w *= -1.f; */ + /* N.w = ClampPositive(N.w); */ + + N.w = (N.w/2.f)+0.5f; + + N.w = RemapSample(N.w, SampleRemapCurvePoints, SampleRemapCurvePointCount); + + NoiseValue += ClampPositive(N.w * Amplitude); + ColorValue = N.rgb; + } + + } + + // + // -- end user code -- + // + + Output.rgb = ColorValue; + Output.a = NoiseValue; +} diff --git a/shaders/terrain/shaping/8_shaped_voronoi_1.fragmentshader b/shaders/terrain/shaping/8_shaped_voronoi_1.fragmentshader new file mode 100644 index 000000000..745b67a21 --- /dev/null +++ b/shaders/terrain/shaping/8_shaped_voronoi_1.fragmentshader @@ -0,0 +1,239 @@ +uniform v2 SampleRemapCurvePoints[16]; +uniform u32 SampleRemapCurvePointCount; + +uniform v3 WorldspaceChunkBasis; +uniform v3 ChunkResolution; + +in vec2 UV; +out v4 Output; + +#define PI 3.14159265358 + +uvec3 murmurHash33(uvec3 src) { + const uint M = 0x5bd1e995u; + uvec3 h = uvec3(1190494759u, 2147483647u, 3559788179u); + src *= M; src ^= src>>24u; src *= M; + h *= M; h ^= src.x; h *= M; h ^= src.y; h *= M; h ^= src.z; + h ^= h>>13u; h *= M; h ^= h>>15u; + return h; +} + +// 3 outputs, 3 inputs +vec3 hash(vec3 src) { + uvec3 h = murmurHash33(floatBitsToUint(src)); + return uintBitsToFloat(h & 0x007fffffu | 0x3f800000u) - 1.0; +} + +float sdBox( in vec2 p, in vec2 b, in vec4 r ) +{ + r.xy = (p.x>0.0)?r.xy : r.zw; + r.x = (p.y>0.0)?r.x : r.y; + vec2 q = abs(p)-b+r.x; + return min(max(q.x,q.y),0.0) + length(max(q,0.0)) - r.x; +} + +float sdPentagram(in vec2 p, in float r ) +{ + const float k1x = 0.809016994; // cos(¿/ 5) = ¼(¿5+1) + const float k2x = 0.309016994; // sin(¿/10) = ¼(¿5-1) + const float k1y = 0.587785252; // sin(¿/ 5) = ¼¿(10-2¿5) + const float k2y = 0.951056516; // cos(¿/10) = ¼¿(10+2¿5) + const float k1z = 0.726542528; // tan(¿/ 5) = ¿(5-2¿5) + const vec2 ve1 = vec2( k1x,-k1y); + const vec2 ve2 = vec2(-k1x,-k1y); + const vec2 ve3 = vec2( k2x,-k2y); + + p.x = abs(p.x); + p -= 2.0*max(dot(ve1,p),0.0)*ve1; + p -= 2.0*max(dot(ve2,p),0.0)*ve2; + p.x = abs(p.x); + p.y -= r; + return length(p-ve3*clamp(dot(p,ve3),0.0,k1z*r)) + * sign(p.y*ve3.x-p.x*ve3.y); +} + +float sdOrientedBox( in vec2 p, in vec2 a, in vec2 b, float th ) +{ + float l = length(b-a); + vec2 d = (b-a)/l; + vec2 q = p-(a+b)*0.5; + q = mat2(d.x,-d.y,d.y,d.x)*q; + q = abs(q)-vec2(l*0.5,th); + return length(max(q,0.0)) + min(max(q.x,q.y),0.0); +} + +// returns offset to the center of the cell in the current tile +vec3 get_point(vec2 pos){ + ivec2 p = (ivec2(pos) - 1) * 3; + vec3 rng = hash(vec3(float(p.x), float(p.y), float(p.x + p.y))); + return rng.xyz; +} + +const vec2 offsets[24] = vec2[24]( + vec2(-2, -2), + vec2(-1, -2), + vec2(0, -2), + vec2(1, -2), + vec2(2, -2), + vec2(-2, -1), + vec2(-1, -1), + vec2(0, -1), + vec2(1, -1), + vec2(2, -1), + vec2(-2, 0), + vec2(-1, 0), + vec2(1, 0), + vec2(2, 0), + vec2(-2, 1), + vec2(-1, 1), + vec2(0, 1), + vec2(1, 1), + vec2(2, 1), + vec2(-2, 2), + vec2(-1, 2), + vec2(0, 2), + vec2(1, 2), + vec2(2, 2) + +); + +float sdShape(vec2 pos, float rand){ + //return sdBox(pos, vec2(.8), vec4(0.)); + //return sdPentagram(pos, .9); + float r = .7; + rand*=PI*2.; + vec2 v = vec2(sin(rand), cos(rand)); + float d = abs(sdOrientedBox(pos, v, -v, .2))-.2; + return d; +} + +float sdVoronoi(vec2 pos){ + pos-=.5; + vec2 p = fract(pos); + + //nearest is initialized to the center cell because of potential future optimizations to reduce iteration count + vec3 rng = get_point(pos); + vec2 nearest = rng.xy; + vec2 lastnearest = vec2(100.); + vec2 current = vec2(0.); + + vec2 lastrng = vec2(rng.z); + + vec3 dists = vec3( + sdShape(p-nearest, rng.z), + sdShape(p-lastnearest, rng.z), + sdShape(p-current, rng.z)); + + //finding the two nearest points to the sampling point + for (int i = 0; i<24; i++){ + current = offsets[i]; + rng = get_point(pos+offsets[i]); + current += rng.xy; + + dists.z = sdShape(p-current, rng.z); + + if (dists.z0.0) ? vec3(0.9,0.6,0.3) : vec3(0.65,0.85,1.0); + col *= 1.0 - exp(-6.0*abs(d)); + col *= 0.8 + 0.2*cos(150.0*d); + col = mix( col, vec3(1.0), 1.0-smoothstep(0.0,0.01,abs(d))); + + if(uv.x<0.)col = vec3(smoothstep(-1., 1., d)); + + if (d<0.01 && d>0.){col = vec3(0.);} + // Output to screen + v4 fragColor = vec4(col, d); + return fragColor; +} + + + + +f32 ClampPositive(f32 Value) +{ + return Value < 0.f ? 0.f : Value; +} + + + + +void main() +{ + f32 x = floor(gl_FragCoord.x); + f32 z = floor(gl_FragCoord.y / 68); + f32 y = floor(gl_FragCoord.y - (z*68)); + + + vec3 Offset = vec3(0); + vec3 Basis = Offset + WorldspaceChunkBasis + (vec3(x,y,z)*ChunkResolution); + + + // NOTE(Jesse): Set these in the -- user code -- section + vec3 ColorValue = vec3(0.f); + f32 NoiseValue = 0.f; + + // + // -- user code -- + // + { + f32 StartingZDepth = DEFAULT_FLOOR_HEIGHT; + NoiseValue += StartingZDepth - Basis.z; + + f32 CliffMask = 1.f; + { + vec3 Period = vec3(150.f); + /* vec3 Period = vec3(10.f); */ + float Amplitude = 300.f; + + vec3 xyz = Basis / Period; + v4 N = noise(xyz.xy); + + N.w *= -1.f; + /* N.w = ClampPositive(N.w); */ + + N.w = (N.w/2.f)+0.5f; + + N.w = RemapSample(N.w, SampleRemapCurvePoints, SampleRemapCurvePointCount ); + + NoiseValue += N.w * Amplitude; + ColorValue = N.rgb; + } + + } + + // + // -- end user code -- + // + + Output.rgb = ColorValue; + Output.a = NoiseValue; +} diff --git a/shaders/terrain/shaping/8_shaped_voronoi_2.fragmentshader b/shaders/terrain/shaping/8_shaped_voronoi_2.fragmentshader new file mode 100644 index 000000000..1496387d1 --- /dev/null +++ b/shaders/terrain/shaping/8_shaped_voronoi_2.fragmentshader @@ -0,0 +1,220 @@ +uniform v2 SampleRemapCurvePoints[16]; +uniform u32 SampleRemapCurvePointCount; + +uniform v3 WorldspaceChunkBasis; +uniform v3 ChunkResolution; + +in vec2 UV; +out v4 Output; + + + + + + + + + +uvec3 murmurHash33(uvec3 src) { + const uint M = 0x5bd1e995u; + uvec3 h = uvec3(1190494759u, 2147483647u, 3559788179u); + src *= M; src ^= src>>24u; src *= M; + h *= M; h ^= src.x; h *= M; h ^= src.y; h *= M; h ^= src.z; + h ^= h>>13u; h *= M; h ^= h>>15u; + return h; +} + +// 3 outputs, 3 inputs +vec3 hash(vec3 src) { + uvec3 h = murmurHash33(floatBitsToUint(src)); + return uintBitsToFloat(h & 0x007fffffu | 0x3f800000u) - 1.0; +} + +float sdBox( in vec2 p, in vec2 b, in vec4 r ) +{ + r.xy = (p.x>0.0)?r.xy : r.zw; + r.x = (p.y>0.0)?r.x : r.y; + vec2 q = abs(p)-b+r.x; + return min(max(q.x,q.y),0.0) + length(max(q,0.0)) - r.x; +} + +float sdPentagram(in vec2 p, in float r ) +{ + float k1x = 0.809016994f; + float k2x = 0.309016994f; + float k1y = 0.587785252f; + float k2y = 0.951056516f; + float k1z = 0.726542528f; + vec2 ve1 = vec2( k1x,-k1y); + vec2 ve2 = vec2(-k1x,-k1y); + vec2 ve3 = vec2( k2x,-k2y); + + p.x = abs(p.x); + p -= 2.0*max(dot(ve1,p),0.0)*ve1; + p -= 2.0*max(dot(ve2,p),0.0)*ve2; + p.x = abs(p.x); + p.y -= r; + return length(p-ve3*clamp(dot(p,ve3),0.0,k1z*r)) + * sign(p.y*ve3.x-p.x*ve3.y); +} + +// returns offset to the center of the cell in the current tile +vec2 get_point(vec2 pos){ + ivec2 p = ivec2(floor(pos - 1.)) * 3; + vec3 rng = hash(vec3(float(p.x), float(p.y), float(p.x + p.y))); + return rng.xy; +} + +const vec2 offsets[24] = vec2[24]( + vec2(-2, -2), + vec2(-1, -2), + vec2(0, -2), + vec2(1, -2), + vec2(2, -2), + vec2(-2, -1), + vec2(-1, -1), + vec2(0, -1), + vec2(1, -1), + vec2(2, -1), + vec2(-2, 0), + vec2(-1, 0), + vec2(1, 0), + vec2(2, 0), + vec2(-2, 1), + vec2(-1, 1), + vec2(0, 1), + vec2(1, 1), + vec2(2, 1), + vec2(-2, 2), + vec2(-1, 2), + vec2(0, 2), + vec2(1, 2), + vec2(2, 2) + +); + +float sdShape(vec2 pos){ + //return sdBox(pos, vec2(.8), vec4(0.)); + return sdPentagram(pos, .9); +} + +float sdVoronoi(vec2 pos){ + pos-=.5; + vec2 p = fract(pos); + + //nearest is initialized to the center cell because of potential future optimizations to reduce iteration count + vec2 nearest = get_point(pos); + vec2 lastnearest = vec2(100.); + vec2 current = vec2(0.); + + vec3 dists = vec3( + sdShape(p-nearest), + sdShape(p-lastnearest), + sdShape(p-current)); + + //finding the two nearest points to the sampling point + for (int i = 0; i<24; i++){ + current = offsets[i]; + current += get_point(pos+offsets[i]); + dists.z = sdShape(p-current); + if (dists.z0.0) ? vec3(0.9,0.6,0.3) : vec3(0.65,0.85,1.0); + col *= 2.0 - exp(-6.0*abs(d)); + col *= 0.8 + 0.2*cos(150.0*d); + col = mix( col, vec3(1.0), 1.0-smoothstep(0.0,0.01,abs(d))); + + if(uv.x<0.)col = vec3(smoothstep(-1., 1., d)); + + if (d<0.01 && d>0.){col = vec3(0.);} + + v4 Result = vec4(col,d); + return Result; +} + + + + +f32 ClampPositive(f32 Value) +{ + return Value < 0.f ? 0.f : Value; +} + + + + +void main() +{ + f32 x = floor(gl_FragCoord.x); + f32 z = floor(gl_FragCoord.y / 68); + f32 y = floor(gl_FragCoord.y - (z*68)); + + + vec3 Offset = vec3(0); + vec3 Basis = Offset + WorldspaceChunkBasis + (vec3(x,y,z)*ChunkResolution); + + + // NOTE(Jesse): Set these in the -- user code -- section + vec3 ColorValue = vec3(0.f); + f32 NoiseValue = 0.f; + + // + // -- user code -- + // + { + f32 StartingZDepth = DEFAULT_FLOOR_HEIGHT; + NoiseValue += StartingZDepth - Basis.z; + + f32 CliffMask = 1.f; + { + vec3 Period = vec3(250.f); + /* vec3 Period = vec3(10.f); */ + float Amplitude = 800.f; + + vec3 xyz = Basis / Period; + v4 N = noise(xyz.xy); + N.w *= -1.f; + N.w = ClampPositive(N.w); + + N.w = (N.w/2.f)+0.5f; + + N.w = RemapSample(N.w, SampleRemapCurvePoints, SampleRemapCurvePointCount ); + + NoiseValue += ClampPositive(N.w * Amplitude); + ColorValue = N.rgb; + } + + } + + // + // -- end user code -- + // + + Output.rgb = ColorValue; + Output.a = NoiseValue; +} diff --git a/shaders/terrain/shaping/default.fragmentshader b/shaders/terrain/shaping/default.fragmentshader new file mode 100644 index 000000000..bbb7750fe --- /dev/null +++ b/shaders/terrain/shaping/default.fragmentshader @@ -0,0 +1,55 @@ +uniform v2 SampleRemapCurvePoints[16]; +uniform u32 SampleRemapCurvePointCount; + +uniform v3 WorldspaceChunkBasis; +uniform v3 ChunkResolution; + +in vec2 UV; +out v4 Output; + +void main() +{ + f32 x = floor(gl_FragCoord.x); + f32 z = floor(gl_FragCoord.y / 68); + f32 y = floor(gl_FragCoord.y - (z*68)); + + + v3 Offset = V3(0); + v3 Basis = Offset + WorldspaceChunkBasis + (v3(x,y,z)*ChunkResolution); + + + // NOTE(Jesse): Set these in the -- user code -- section + v3 ColorValue = V3(0.1f, 0.8f, 0.1f); + f32 NoiseValue = 0.f; + + // + // -- user code -- + // + { + f32 White = white_noise(v3(x,y,z)); + ColorValue -= 0.05f*White; + + NoiseValue += DEFAULT_FLOOR_HEIGHT; + + { + v3 Period = V3(1800.f); + float Amplitude = 200.f; + + v3 xyz = Basis / Period; + v4 gn = gradient_noise_derivs(xyz); + + NoiseValue += gn.x * Amplitude; + } + + // NOTE(Jesse): We subtract the Z value of the current voxel so we get + // lower values as we go higher in Z. This produces a flat-ish plane. + NoiseValue = NoiseValue - Basis.z; + } + + // + // -- end user code -- + // + + Output.rgb = ColorValue; + Output.a = NoiseValue; +} diff --git a/shaders/terrain/world_edit.fragmentshader b/shaders/terrain/world_edit.fragmentshader new file mode 100644 index 000000000..a3657b937 --- /dev/null +++ b/shaders/terrain/world_edit.fragmentshader @@ -0,0 +1,522 @@ +uniform v3 WorldspaceChunkBasis; +uniform v3 ChunkResolution; // TODO(Jesse): Make this a scalar? + +uniform int BrushType; +uniform int BlendMode; +uniform int ColorMode; +uniform int ValueModifiers; + +uniform int GenerateNormals; + +uniform f32 Power; +uniform f32 ValueBias; + +uniform v3 Axis; + +// +// Clipping params +// +uniform v3 ChunkRelEditMin; +uniform v3 ChunkRelEditMax; + + +// +// Shape params +// +uniform s32 ShapeType; // shape_type +uniform mat4 RotTransform; +uniform f32 Rounding; +uniform v3 Stretch; +uniform v3 Repeat; + +// +// Rect Params +// + +uniform v3 RectDim; + +// +// Sphere Params +// +uniform v3 EditRelativeSphereCenter; +uniform f32 Radius; + +// +// Cylinder Params +// + +uniform r32 Height; + +// +// Plane Params +// +uniform v3 PlaneNormal; +uniform f32 Planed; +uniform f32 PlaneRadius; + +// +// Torus Params +// + +uniform f32 MinorRadius; + + + + +// +// Noise params +// +uniform int NoiseType; +uniform v3 RGBColor; +uniform v3 Period; +uniform f32 Threshold; +uniform bool Invert; + +// +// Voronoi Params +// +uniform f32 Squareness; // 0 == not square, 1 == square + + + +uniform int SampleInputTex; +uniform sampler2D InputTex; + +uniform int SampleBlendTex; +uniform sampler2D BlendTex; + +in vec2 UV; +out vec4 Output; + +r32 DistanceToPlane(v3 PlaneNormal, f32 Planed, v3 P) +{ + r32 a = PlaneNormal.x; + r32 b = PlaneNormal.y; + r32 c = PlaneNormal.z; + + r32 d = Planed; + + r32 Distance = a*P.x + b*P.y + c*P.z + d; + return Distance; +} + +f32 iq_sdSphere(v3 p, f32 r) +{ + return length(p) - r; +} + +// p == sample point +// b == box dimension +// +f32 iq_sdBox(vec3 p, vec3 b) +{ + vec3 q = abs(p) - b; + return length(max(q,0.0)) + min(max(q.x,max(q.y,q.z)),0.0); +} + +// p == sample point +// h == height +// r == radius +// +float iq_sdCappedCylinder( vec3 p, float h, float r ) +{ + vec2 d = abs(vec2(length(p.xz),p.y)) - vec2(r,h); + return min(max(d.x,d.y),0.0) + length(max(d,0.0)); +} + +float iq_sdCylinder( vec3 p, vec3 c ) +{ + return length(p.xz-c.xy)-c.z; +} + +// p == sample point +// a == start point +// b == end point +// r == radius +float iq_sdRoundedLine( vec3 p, vec3 a, vec3 b, float r ) +{ + vec3 pa = p - a, ba = b - a; + float h = clamp( dot(pa,ba)/dot(ba,ba), 0.0, 1.0 ); + return length( pa - ba*h ) - r; +} + +// p == sample point +// t.x == major radius +// t.y == minor radius +// +float iq_sdTorus( vec3 p, vec2 t ) +{ + vec2 q = vec2(length(p.xz)-t.x,p.y); + return length(q)-t.y; +} + + +// p == sample point +// h == stretch vector +vec4 iq_opElongate( vec3 p, vec3 h ) +{ + // faster, but produces zero in the interior elongated box + /* return vec4( p-clamp(p,-h,h), 0.0 ); */ + + /* return vec4(0); */ + + vec3 q = abs(p)-h; + return vec4( max(q,0.0), min(max(q.x,max(q.y,q.z)),0.0) ); +} + +// p == sample point +// p == spacing between instances +// +v3 iq_opRepetition( v3 p, v3 s ) +{ + vec3 q = p - s*round(p/s); + return q; +} + +v4 DoInputTransforms(v3 p, mat3 Transform, v3 Stretch, v3 Repeat) +{ + p *= Transform; + if (length(Repeat) > 0.f) + { + p = iq_opRepetition(p, Repeat); + } + v4 w = iq_opElongate(p, Stretch); + return w; +} + +#if 1 +f32 IQSampleToBonsaiSample(f32 IQSample, f32 Rad) +{ + return (1.f-IQSample)/Rad; +} +#else +f32 IQSampleToBonsaiSample(f32 IQSample, f32 Rad) +{ + return (1.f-IQSample); +} +#endif + +void main() +{ + v4 TexLookup = vec4(0); + if (SampleInputTex > 0) + { + TexLookup = texelFetch(InputTex, ivec2(gl_FragCoord.xy), 0); + } + + // NOTE(Jesse): Set these in the -- user code -- section + vec3 ColorValue = TexLookup.rgb; + + f32 InitialAccumulator = TexLookup.a; + f32 Accumulator = TexLookup.a; + + f32 x = floor(gl_FragCoord.x); + f32 z = floor(gl_FragCoord.y / 66); + f32 y = floor(gl_FragCoord.y - (z*66)); + v3 xyz = V3(x,y,z) * ChunkResolution; + + mat3 RotMatrix = mat3(RotTransform); + + // TODO(Jesse): I have no idea why this works out to > Min and <= Max. I + // think it should be >= Min and < Max .. but I'm just going to leave it for now.. + if ( + xyz.x > ChunkRelEditMin.x && + xyz.y > ChunkRelEditMin.y && + xyz.z > ChunkRelEditMin.z && + + xyz.x <= ChunkRelEditMax.x && + xyz.y <= ChunkRelEditMax.y && + xyz.z <= ChunkRelEditMax.z ) + { + v3 Basis = WorldspaceChunkBasis + xyz; + v3 EditRelxyz = xyz - ChunkRelEditMin; + v3 EditDim = ChunkRelEditMax-ChunkRelEditMin; + v3 EditRad = EditDim/2.f; + + + { + v3 ColorSample = RGBColor; + f32 InitialSample = 0.f; + + s32 Octaves = 1; + switch (BrushType) + { + case 0: // BrushLayerType_Noise + { + v3 NoiseBasis = Basis / Period; + switch (NoiseType) + { + case 0: // NoiseType_Perlin: + { + InitialSample = value_noise_derivs(NoiseBasis).x; + } break; + + case 1: // NoiseType_Voronoi: + { + InitialSample = voronoi_noise(NoiseBasis, Squareness).x; + } break; + + case 2: // NoiseType_White: + { + InitialSample = white_noise(NoiseBasis); + } break; + } + + break; + } + + case 1: // BrushLayerType_Shape + { + switch (ShapeType) + { + // ShapeType_Rect + case 0: + { + /* v3 BoxR = EditDim/4.f; */ + /* v3 BoxR = v3(20.f); */ + /* v3 BoxR = v3(200.f); */ + v3 BoxR = RectDim/2.f; + if (length(BoxR) > 0.f) + { + } + else + { + BoxR = EditDim; + } + + v3 Center = EditDim/2.f; + v3 p = (EditRelxyz - Center); + v4 w = DoInputTransforms(p, RotMatrix, Stretch, Repeat); + f32 IQSample = w.w+iq_sdBox(w.xyz, BoxR); + InitialSample = -IQSample; + + } break; + + // ShapeType_Sphere + case 1: + { + v3 p = (EditRelxyz - EditRelativeSphereCenter); + v4 w = DoInputTransforms(p, RotMatrix, Stretch, Repeat); + f32 IQSample = w.w+iq_sdSphere(w.xyz, Radius); + InitialSample = -IQSample; + } break; + + // ShapeType_Line + case 2: + { + v3 p = EditRelxyz; + v3 start = v3(Radius); + v3 end = EditDim-v3(Radius); + + v4 w = DoInputTransforms(p, RotMatrix, Stretch, Repeat); + f32 IQSample = w.w+iq_sdRoundedLine(w.xyz, start, end, Radius); + InitialSample = -IQSample; + } break; + + // ShapeType_Cylinder + case 3: + { + v3 p = (EditRelxyz - EditRad); + v3 c = Axis; + + f32 r = 4.f; + f32 h = 102.f; + + v4 w = DoInputTransforms(p, RotMatrix, Stretch, Repeat); + + f32 IQSample = w.w+iq_sdCappedCylinder(w.xyz, Height, Radius); + InitialSample = -IQSample; + } break; + + // ShapeType_Plane + case 4: + { + f32 Dist = DistanceToPlane(PlaneNormal, Planed, EditRelxyz); + if (abs(Dist) < PlaneRadius*ChunkResolution.x) + { + InitialSample = 1.f; + } + } break; + + // ShapeType_Torus + case 5: + { + v2 t = v2(Radius, MinorRadius); + v3 p = EditRelxyz; + + v3 BoxR = EditDim/2.f; + p = EditRelxyz; + p -= BoxR; + + v4 w = DoInputTransforms(p, RotMatrix, Stretch, Repeat); + + f32 n = w.w+iq_sdTorus( w.xyz, t ); + + InitialSample = -n; + + } break; + + // @sdf_shape_step(7): Add more cases and implementations here + // for shape types added in Step 1 + // + } + + InitialSample += Rounding; + } break; + + default: {ColorValue = V3(1.f, 0.f, 1.f); Accumulator = 1.f;} break; + } + + /* InitialSample = Clamp01(InitialSample); */ + + f32 ThisSample = (InitialSample + ValueBias) * Power; + if (Invert) + { + ThisSample = ThisSample * -1.f; + } + + + + + + + + + + if ( (ValueModifiers & (1<<1)) > 0) // WorldEdit_ValueModifier_ClampPos + { + ThisSample = max(0.f, ThisSample); + } + + if ( (ValueModifiers & (1<<2)) > 0) // WorldEdit_ValueModifier_ClampNeg + { + ThisSample = min(0.f, ThisSample); + } + + if ( (ValueModifiers & (1<<3)) > 0) // WorldEdit_ValueModifier_Threshold + { + if (abs(InitialSample) < Threshold) { ThisSample = 0.f; } + } + + if ( (ValueModifiers & (1<<4)) > 0) // WorldEdit_ValueModifier_Discard + { + ThisSample = 0.f; + } + + + + + + + + + + + // Blend Value + // + switch (BlendMode) + { + case 0: // WorldEdit_Mode_Additive + { + if (ThisSample > 0.f) + { + Accumulator = Accumulator + ThisSample; + } + } break; + + case 1: // WorldEdit_Mode_Subtractive + { + if (ThisSample > 0.f) + { + Accumulator = Accumulator - ThisSample; + } + } break; + + case 2: // WorldEdit_Mode_Multiply + { + // Don't wanna check this because we want to use this to mask values out + /* if (ThisSample > 0.f) */ + { + Accumulator = Accumulator * ThisSample; + } + } break; + + case 3: // WorldEdit_Mode_Threshold + { + f32 AbsSampleValue = abs(ThisSample); + { + if(ThisSample >= Threshold) + { + Accumulator = Threshold; + } + } + + } break; + + case 4: // WorldEdit_Mode_Disabled + { ThisSample = 0.f; } break; + } + + + // Blend Color + // + switch (ColorMode) + { + case 0: // WorldEdit_ColorBlendMode_ValuePositive + { if (ThisSample > 0.f) { ColorValue = ColorSample; } } break; + + case 1: // WorldEdit_ColorBlendMode_ValueNegative + { if (ThisSample < 0.f) { ColorValue = ColorSample; } } break; + + case 2: // WorldEdit_ColorBlendMode_Surface + { + if (InitialAccumulator <= 0.f) + { + if (Accumulator > 0.f) + { + ColorValue = ColorSample; + /* ColorValue = ColorSample * (InitialSample); */ + } + } + } break; + /* { ColorValue = ColorValue + ColorSample; } break; */ + +#if 0 + case 3: // Subtractive + { ColorValue = ColorValue - ColorSample; } break; + + case 4: // Multiply + { ColorValue = ColorValue * ColorSample; } break; + + case 5: // Divide + { ColorValue = SafeDivide0(ColorValue, ColorSample); } break; + + case 6: // Average + { f32 StartingIntensity = length(ColorValue);Threshold : Set sample to 0 if it does not pass threshold, before Power and ValueBias + ColorValue = (ColorValue + ColorSample)/StartingIntensity; } break; +#endif + } + + } + + } + + if (SampleBlendTex > 0) + { + v4 TexLookup = texelFetch(BlendTex, ivec2(gl_FragCoord.xy), 0); + + if (Accumulator <= 0.f) + /* if (TexLookup.a > 0.f) */ + { + // Take Max of Accumulator or current world value + if (Accumulator < TexLookup.a) + { + Accumulator = TexLookup.a; + ColorValue = TexLookup.rgb; + } + } + } + + Output.rgb = ColorValue; + Output.a = Accumulator; +} diff --git a/src/engine/animation.h b/src/engine/animation.h index 190bfdcac..307d8b773 100644 --- a/src/engine/animation.h +++ b/src/engine/animation.h @@ -1,11 +1,13 @@ struct keyframe +poof(@do_editor_ui) { r32 tEnd; r32 Value; }; struct animation +poof(@do_editor_ui) { r32 t; r32 tEnd; diff --git a/src/engine/api.cpp b/src/engine/api.cpp index c0c1f47a7..cff26dcd4 100644 --- a/src/engine/api.cpp +++ b/src/engine/api.cpp @@ -1,4 +1,3 @@ - link_export b32 Bonsai_OnLibraryLoad(engine_resources *Resources) { @@ -7,12 +6,8 @@ Bonsai_OnLibraryLoad(engine_resources *Resources) if (ThreadLocal_ThreadIndex == -1) { SetThreadLocal_ThreadIndex(0); } else { Assert(ThreadLocal_ThreadIndex == 0); } - Global_ThreadStates = Resources->Stdlib.ThreadStates; - Global_EngineResources = Resources; - - /* Initialize_Global_UpdateWorldCallbackTable(); */ - - /* b32 Result = InitializeOpenglFunctions(); */ + Global_Stdlib = &Resources->Stdlib; + Assert(Resources->Stdlib.ThreadStates); return True; } @@ -27,8 +22,6 @@ Bonsai_Init(engine_resources *Resources) Result &= InitEditor(&Resources->Editor); Result &= InitEngineResources(Resources); - /* Initialize_Global_UpdateWorldCallbackTable(); */ - return Result; } @@ -39,10 +32,10 @@ SimulateCameraGhost_AndSet_OffsetWorldCenterToGrid(engine_resources *Engine) if (entity *CameraGhost = GetEntity(EntityTable, Camera->GhostId)) { - SimulateEntity(Engine, CameraGhost, Plat->dt, World->VisibleRegion, &GpuMap->Buffer, &Graphics->Transparency.GpuBuffer.Buffer, &Plat->HighPriority); + SimulateEntity(Engine, CameraGhost, Plat->dt, V3i(World->VisibleRegionSize), &GpuMap->Buffer, &Graphics->Transparency.GpuBuffer.Buffer, &Plat->HighPriority); v3 CameraTargetSimP = GetSimSpaceP(World, CameraGhost); - Graphics->Settings.OffsetOfWorldCenterToGrid = (CameraTargetSimP % V3(Graphics->Settings.MajorGridDim)); + Graphics->OffsetOfWorldCenterToGrid = (CameraTargetSimP % V3(Graphics->Settings.MajorGridDim)); } } @@ -67,18 +60,18 @@ Bonsai_FrameBegin(engine_resources *Resources) { TIMED_FUNCTION(); - PushBonsaiRenderCommandClearAllFramebuffers(&Resources->Stdlib.Plat.RenderQ); + PushBonsaiRenderCommandClearAllFramebuffers(&Resources->Stdlib.Plat.HiRenderQ); // NOTE(Jesse): This gets cleared before CollectUnusedChunks because that's // the thing that is populating the next hashtable - Resources->World->HashSlotsUsed = 0; + /* Resources->World->HashSlotsUsed = 0; */ /* DEBUG_AssertWorldChunkHashtableIsEmpty(Resources, NextWorldHashtable(Resources)); */ // NOTE(Jesse): Must come before we update the frame index becaues // CollectUnusedChunks picks the hashtable based on the frame index. // - CollectUnusedChunksAndClearCurrentTable(Resources, Resources->World->VisibleRegion); + /* CollectUnusedChunksAndClearCurrentTable(Resources, Resources->World->VisibleRegion); */ /* DEBUG_AssertWorldChunkHashtableIsEmpty(Resources, CurrentWorldHashtable(Resources)); */ @@ -86,11 +79,119 @@ Bonsai_FrameBegin(engine_resources *Resources) // sim pulls chunks out of the hashtable. // Resources->FrameIndex += 1; - Resources->World->ChunkHash = CurrentWorldHashtable(Resources); + + + b32 VRChanged = False; + DETECT_CHANGES_ON(Resources->World->VisibleRegionSize, PrevValue, + { + Info("Changed From (%S) to (%S)", ToString(PrevValue), ToString(Resources->World->VisibleRegionSize)); + VRChanged = True; + }); + + + if ( VRChanged || + Resources->Graphics.WorldEditRC.Program.HotReloaded || + Resources->Graphics.TerrainShapingRC.Program.HotReloaded || + Resources->Graphics.TerrainDecorationRC.Program.HotReloaded || + Resources->Graphics.TerrainDerivsRC.Program.HotReloaded || + Resources->Graphics.TerrainFinalizeRC.Program.HotReloaded ) + { + auto Plat = &Resources->Stdlib.Plat; + + // Must free before the render thread flushes + FreeOctreeChildren(Resources, &Resources->World->Root); + + SignalAndWaitForWorkers(&Plat->WorkerThreadsSuspendFutex); + CancelAllWorkQueueJobs(Resources); + Assert(Count(&Resources->Graphics.NoiseReadbackJobs) == 0); + + world *World = Resources->World; + v3i Center = World->Center; + auto VisibleRegionSize = World->VisibleRegionSize; + + HardResetWorld(Resources); + AllocateWorld(World, Center, VisibleRegionSize); + + ApplyEditBufferToOctree(Resources, &Resources->Editor.Edits); + /* HardResetEditor(&Resources->Editor); */ + + + UnsignalFutex(&Plat->WorkerThreadsSuspendFutex); + } + + + // Must come before UNPACK_ENGINE_RESOURCES such that we unpack the correct GpuMap + /* Resources->Graphics.GpuBufferWriteIndex = 0; */ + /* Resources->Graphics.GpuBufferWriteIndex = (Resources->FrameIndex) % 2; */ + + + UNPACK_ENGINE_RESOURCES(Resources); + + + // NOTE(Jesse): Has to come after the UI happens such that we don't get a + // frame of camera-jank if the UI captures mouse input + // + // The specific case here is that if the camera updates, then the UI draws, + // and we're in paint-single mode (which captures the input) there's a frame + // where the camera updates, then freezes, which feels ultra-janky. Updating + // the UI, then the camera, avoids this order-of-operations issue. + // + // @camera-update-ui-update-frame-jank + // + // Unfortunately, this actually re-introduces another order-of-operations issue + // which I've fixed in the past, which is that the immediate geometry is a + // frame late. + // + // @immediate-geometry-is-a-frame-late + // + // NOTE(Jesse): This has to come before we draw any of the game geometry. + // Specifically, if it comes after we draw bounding boxes for anything + // the bounding box lines shift when we move the camera because they're + // then a frame late. + // + // @immediate-geometry-is-a-frame-late + // + // UPDATE(Jesse): This bug has been reintroduced because of @camera-update-ui-update-frame-jank + // More info and a solution documented at : https://github.com/scallyw4g/bonsai/issues/30 + // + // UPDATE(Jesse): I fixed this again because the @camera-update-ui-update-frame-jank bug is + // gone. Got rid of paint-single mode in the way it was being done, and the new way shouldn't + // have that problem, when I get around to implementing it. + // + // { + + cp CameraTargetP = {}; + + entity *CameraGhost = GetEntity(EntityTable, Camera->GhostId); + if (CameraGhost == 0) + { + // Allocate default camera ghost + Camera->GhostId = GetFreeEntity(EntityTable); + CameraGhost = GetEntity(EntityTable, Camera->GhostId); + CameraGhost->Behavior = entity_behavior_flags(CameraGhost->Behavior | EntityBehaviorFlags_DefatulCameraGhostBehavior); + SpawnEntity(CameraGhost); + } + + if (CameraGhost) { CameraTargetP = CameraGhost->P; } + + b32 DoPositionDelta = (!UiCapturedMouseInput(Ui) && UiInteractionWasViewport(Ui)); + + // NOTE(Jesse): Don't remember what bug I fixed by changing this to DoPositionDelta, + // but it broke scrolling on laptop trackpads (where nothing is clicked). Going to + // remove it until I remember what the bug was .. + /* b32 DoZoomDelta = DoPositionDelta; */ + b32 DoZoomDelta = UiHoveredMouseInput(Ui) == False; + + v2 MouseDelta = GetMouseDelta(Plat); + UpdateGameCamera(World, MouseDelta, &Plat->Input, CameraTargetP, Camera, Plat->dt, DoPositionDelta, DoZoomDelta); + // } + + + /* Resources->World->ChunkHash = CurrentWorldHashtable(Resources); */ /* DEBUG_AssertWorldChunkHashtableIsEmpty(Resources, NextWorldHashtable(Resources)); */ - ComputeDrawListsAndQueueUnallocatedChunks(Resources); + /* ComputeDrawListsAndQueueUnallocatedChunks(Resources); */ /* DEBUG_AssertWorldChunkHashtableIsEmpty(Resources, NextWorldHashtable(Resources)); */ @@ -103,13 +204,8 @@ Bonsai_FrameBegin(engine_resources *Resources) // SimulateCameraGhost_AndSet_OffsetWorldCenterToGrid(Resources); - // Must come before UNPACK_ENGINE_RESOURCES such that we unpack the correct GpuMap - /* Resources->Graphics.GpuBufferWriteIndex = 0; */ - /* Resources->Graphics.GpuBufferWriteIndex = (Resources->FrameIndex) % 2; */ - - - UNPACK_ENGINE_RESOURCES(Resources); - + /* SplitAndQueueOctreeNodesForInit(Resources); */ + DispatchOctreeDrawJobs(Resources); if (GetEngineDebug()->DrawWorldAxies) { @@ -119,6 +215,15 @@ Bonsai_FrameBegin(engine_resources *Resources) DEBUG_DrawLine_Aligned(&CopyDest, V3(0,0,0), V3(0, 0, 10000), RGB_BLUE, 0.35f ); } + /* if (GetEngineDebug()->DrawGameCameraLocation) */ + { + if (Resources->Graphics.Camera == &Resources->Graphics.DebugCamera) + { + /* DEBUG_HighlightVoxel(Engine, Camera->ViewingTarget, RED); */ + DEBUG_HighlightVoxel(Resources, Graphics->GameCamera.CurrentP, RGB_PINK, 10.f); + } + } + Graphics->Lighting.Lights.Count = 0; @@ -128,20 +233,69 @@ Bonsai_FrameBegin(engine_resources *Resources) // // @camera-update-ui-update-frame-jank // + // + f32 LineWidth = 3.f; + LineWidth = .1f; if (UiHoveredMouseInput(Ui)) { - Resources->MaybeMouseRay = {}; - Resources->MousedOverVoxel = {}; - Resources->HoverEntity = {}; + // We want to preserve these when we swap to the debug camera + if (Camera == &Graphics->GameCamera) + { + Resources->MaybeMouseRay = {}; + Resources->MousedOverVoxel = {}; + Resources->HoverEntity = {}; + } } else { - Resources->MaybeMouseRay = ComputeRayFromCursor(Resources, &gBuffer->ViewProjection, Camera, World->ChunkDim); - Resources->MousedOverVoxel = MousePickVoxel(Resources); + if (Camera == &Graphics->GameCamera) + { + Resources->MaybeMouseRay = ComputeCameraSpaceRayFromCursor(Resources, Camera, World->ChunkDim); + + ray *Ray = &Resources->MaybeMouseRay.Ray; + v3 GameCameraSimSpaceP = GetSimSpaceP(World, Graphics->GameCamera.CurrentP); + Ray->Origin = GameCameraSimSpaceP; + } + + ray *Ray = &Resources->MaybeMouseRay.Ray; + + /* DEBUG_VALUE_r32(Ray->Origin.x); */ + /* DEBUG_VALUE_r32(Ray->Origin.y); */ + /* DEBUG_VALUE_r32(Ray->Origin.z); */ + + /* DEBUG_VALUE_r32(Ray->Dir.x); */ + /* DEBUG_VALUE_r32(Ray->Dir.y); */ + /* DEBUG_VALUE_r32(Ray->Dir.z); */ + + Resources->MousedOverVoxel = MousePickVoxel(Resources, Ray); Resources->HoverEntity = GetClosestEntityIntersectingRay(World, EntityTable, &Resources->MaybeMouseRay.Ray); } +#if 0 + { + ray *Ray = &Resources->MaybeMouseRay.Ray; + + { + untextured_3d_geometry_buffer Mesh = ReserveBufferSpace(&GpuMap->Buffer, VERTS_PER_LINE); + DEBUG_DrawLine(&Mesh, V3(0.,0.,LineWidth) + Ray->Origin, Ray->Origin + Ray->Dir*50000.f, RGB_PINK, LineWidth ); + } + + picked_octree_node_block_array NodeList = GetOctreeLeafNodesIntersectingRay(World, Ray, GetTranArena()); + IterateOver(&NodeList, PickedNode, NodeIndex) + { + random_series Entropy = {Cast(u64, PickedNode->Node)}; + v3 Color = RandomV3Unilateral(&Entropy); + aabb AABB = GetSimSpaceAABB(World, PickedNode->Node); + DEBUG_DrawSimSpaceAABB(Resources, &AABB, Color, 3.f); + + v3 IntersectionPoint = Ray->Origin + Ray->Dir*PickedNode->t; + DEBUG_HighlightVoxel(Resources, IntersectionPoint, Color, 3); + + } + } +#endif + // Find closest standing spot to cursor { Resources->ClosestStandingSpotToCursor = {}; @@ -263,9 +417,23 @@ Bonsai_FrameBegin(engine_resources *Resources) } link_export b32 -Bonsai_FrameEnd(engine_resources *Resources) +Bonsai_FrameEnd(engine_resources *Engine) { + UNPACK_ENGINE_RESOURCES(Engine); + b32 Result = True; + + if (!AreEqual(&Graphics->Settings, &Graphics->PrevSettings)) + { + u8_cursor_block_array Bytes = BeginSerialization(); + Serialize(&Bytes, &Graphics->Settings); + FinalizeSerialization(&Bytes, RUNTIME_SETTINGS__GRAPHICS_SETTINGS_PATH); + } + + Graphics->GameCamera.Frust.FOV = Graphics->Settings.GameCameraFOV; + + Graphics->PrevSettings = Graphics->Settings; + return Result; } @@ -278,7 +446,7 @@ Bonsai_Simulate(engine_resources *Resources) UNPACK_ENGINE_RESOURCES(Resources); - SimulateEntities(Resources, Plat->dt, World->VisibleRegion, &GpuMap->Buffer, &Graphics->Transparency.GpuBuffer.Buffer, &Plat->HighPriority); + SimulateEntities(Resources, Plat->dt, V3i(World->VisibleRegionSize), &GpuMap->Buffer, &Graphics->Transparency.GpuBuffer.Buffer, &Plat->HighPriority); /* DispatchSimulateParticleSystemJobs(&Plat->HighPriority, EntityTable, World->ChunkDim, &GpuMap->Buffer, Graphics, Plat->dt); */ UnsignalFutex(&Resources->Stdlib.Plat.HighPriorityModeFutex); @@ -287,6 +455,10 @@ Bonsai_Simulate(engine_resources *Resources) { if (Graphics->Camera == &Graphics->GameCamera) { + /* entity_id Prev = Graphics->DebugCamera.GhostId; */ + /* Graphics->DebugCamera = Graphics->GameCamera; */ + /* Graphics->DebugCamera.GhostId = Prev; */ + Graphics->Camera = &Graphics->DebugCamera; } else @@ -296,151 +468,46 @@ Bonsai_Simulate(engine_resources *Resources) Camera = Graphics->Camera; } - // NOTE(Jesse): Has to come after the UI happens such that we don't get a - // frame of camera-jank if the UI captures mouse input - // - // The specific case here is that if the camera updates, then the UI draws, - // and we're in paint-single mode (which captures the input) there's a frame - // where the camera updates, then freezes, which feels ultra-janky. Updating - // the UI, then the camera, avoids this order-of-operations issue. - // - // @camera-update-ui-update-frame-jank - // - // Unfortunately, this actually re-introduces another order-of-operations issue - // which I've fixed in the past, which is that the immediate geometry is a - // frame late. - // - // @immediate-geometry-is-a-frame-late - // - // NOTE(Jesse): This has to come before we draw any of the game geometry. - // Specifically, if it comes after we draw bounding boxes for anything - // the bounding box lines shift when we move the camera because they're - // then a frame late. - // - // @immediate-geometry-is-a-frame-late - // - // UPDATE(Jesse): This bug has been reintroduced because of @camera-update-ui-update-frame-jank - // More info and a solution documented at : https://github.com/scallyw4g/bonsai/issues/30 - // - - cp CameraTargetP = {}; - input *InputForCamera = &Plat->Input; - - entity *CameraGhost = GetEntity(EntityTable, Camera->GhostId); - if (CameraGhost == 0) - { - // Allocate default camera ghost - Camera->GhostId = GetFreeEntity(EntityTable); - CameraGhost = GetEntity(EntityTable, Camera->GhostId); - CameraGhost->Behavior = entity_behavior_flags(CameraGhost->Behavior | EntityBehaviorFlags_DefatulCameraGhostBehavior); - SpawnEntity(CameraGhost); - } - - if (CameraGhost) { CameraTargetP = CameraGhost->P; } - - b32 DoPositionDelta = (!UiCapturedMouseInput(Ui) && UiInteractionWasViewport(Ui)); - - // NOTE(Jesse): Don't remember what bug I fixed by changing this to DoPositionDelta, - // but it broke scrolling on laptop trackpads (where nothing is clicked). Going to - // remove it until I remember what the bug was .. - /* b32 DoZoomDelta = DoPositionDelta; */ - b32 DoZoomDelta = UiHoveredMouseInput(Ui) == False; - - v2 MouseDelta = GetMouseDelta(Plat); - UpdateGameCamera(World, MouseDelta, InputForCamera, CameraTargetP, Camera, Plat->dt, DoPositionDelta, DoZoomDelta); - - // TODO(Jesse)(correctness, nopush): This should actually be passing the back-buffer resolution?? - + /* m4 *ViewMat = ViewMatrix(World->ChunkDim, Camera); */ + /* m4 *ProjMat = ProjectionMatrix(Camera, Plat->ScreenDim); */ - m4 ViewMat = ViewMatrix(World->ChunkDim, Camera); - m4 ProjMat = ProjectionMatrix(Camera, Plat->ScreenDim); - - Resources->Graphics.gBuffer->InverseViewMatrix = Inverse(ViewMat); - Resources->Graphics.gBuffer->InverseProjectionMatrix = Inverse(ProjMat); - Resources->Graphics.gBuffer->ViewProjection = ProjMat * ViewMat; + Resources->Graphics.gBuffer->ViewProjection = Camera->ViewProjection; + Resources->Graphics.gBuffer->InverseViewMatrix = Camera->InverseViewMatrix; + Resources->Graphics.gBuffer->InverseProjectionMatrix = Camera->InverseProjectionMatrix; #if BONSAI_DEBUG_SYSTEM_API Debug_DoWorldChunkPicking(Resources); #endif + { // Update tDay and key-light such that we can start drawing + if (Graphics->Settings.Lighting.AutoDayNightCycle) + { + Graphics->Settings.Lighting.tDay += SafeDivide0(Plat->dt, Graphics->Settings.Lighting.tDaySpeed); + } - // Draw terrain - PushBonsaiRenderCommandGlTimerStart(&Plat->RenderQ, Graphics->gBuffer->GlTimerObject); - - PushBonsaiRenderCommandSetupShader(&Plat->RenderQ, BonsaiRenderCommand_ShaderId_gBuffer); - PushBonsaiRenderCommandDrawWorldChunkDrawList(&Plat->RenderQ, &Graphics->MainDrawList, &Graphics->gBuffer->gBufferShader); - PushBonsaiRenderCommandTeardownShader(&Plat->RenderQ, BonsaiRenderCommand_ShaderId_gBuffer); - - PushBonsaiRenderCommandSetupShader(&Plat->RenderQ, BonsaiRenderCommand_ShaderId_ShadowMap); - PushBonsaiRenderCommandDrawWorldChunkDrawList(&Plat->RenderQ, &Graphics->ShadowMapDrawList, &Graphics->SG->Shader.Program); - PushBonsaiRenderCommandTeardownShader(&Plat->RenderQ, BonsaiRenderCommand_ShaderId_ShadowMap); - - PushBonsaiRenderCommandGlTimerEnd(&Plat->RenderQ, Graphics->gBuffer->GlTimerObject); + UpdateKeyLight(Graphics, Graphics->Settings.Lighting.tDay); + Graphics->SG->Shader.ViewProjection = GetShadowMapMVP(World, &Graphics->GameCamera, Graphics->Settings.Lighting.SunP); + } - b32 Result = True; - return Result; -} -link_internal void -UpdateKeyLightColor(graphics *Graphics, r32 tDay) -{ - auto SG = Graphics->SG; - r32 tDaytime = Cos(tDay); - r32 tPostApex = Sin(tDay); + // Draw terrain + /* PushBonsaiRenderCommandGlTimerStart(&Plat->HiRenderQ, Graphics->gBuffer->GlTimerObject); */ - lighting_settings *Lighting = &Graphics->Settings.Lighting; + PushBonsaiRenderCommandSetupShader(&Plat->HiRenderQ, BonsaiRenderCommand_ShaderId_gBuffer); + PushBonsaiRenderCommandDrawWorldChunkDrawList(&Plat->HiRenderQ, &Graphics->MainDrawList, &Graphics->gBuffer->gBufferShader, &Graphics->GameCamera); + PushBonsaiRenderCommandTeardownShader(&Plat->HiRenderQ, BonsaiRenderCommand_ShaderId_gBuffer); - v3 DawnColor = Normalize(Lighting->DawnColor) * Lighting->DawnIntensity; - v3 SunColor = Normalize(Lighting->SunColor ) * Lighting->SunIntensity; - v3 DuskColor = Normalize(Lighting->DuskColor) * Lighting->DuskIntensity; - v3 MoonColor = Normalize(Lighting->MoonColor) * Lighting->MoonIntensity; + PushBonsaiRenderCommandSetupShader(&Plat->HiRenderQ, BonsaiRenderCommand_ShaderId_ShadowMap); + PushBonsaiRenderCommandDrawWorldChunkDrawList(&Plat->HiRenderQ, &Graphics->ShadowMapDrawList, &Graphics->SG->Shader.Program, 0); + PushBonsaiRenderCommandTeardownShader(&Plat->HiRenderQ, BonsaiRenderCommand_ShaderId_ShadowMap); - Lighting->SunP.x = Sin(((Graphics->SunBasis.x*PI32)) + tDay); - Lighting->SunP.y = Cos(((Graphics->SunBasis.y*PI32))+ tDay); - Lighting->SunP.z = (1.3f+Cos(((Graphics->SunBasis.z*PI32)) + tDay))/2.f; + /* PushBonsaiRenderCommandGlTimerEnd(&Plat->HiRenderQ, Graphics->gBuffer->GlTimerObject); */ - if (tDaytime > 0.f) - { - if (tPostApex > 0.f) - { - Lighting->CurrentSunColor = Lerp(tDaytime, DuskColor, SunColor); - } - else - { - Lighting->CurrentSunColor = Lerp(tDaytime, DawnColor, SunColor); - } - } - else - { - if (tPostApex > 0.f) - { - Lighting->CurrentSunColor = Lerp(Abs(tDaytime), DuskColor, MoonColor); - } - else - { - Lighting->CurrentSunColor = Lerp(Abs(tDaytime), DawnColor, MoonColor); - } - } - switch (Graphics->Settings.ToneMappingType) - { - case ToneMappingType_None: - case ToneMappingType_Reinhard: - case ToneMappingType_Exposure: - { } break; - - case ToneMappingType_AGX: - case ToneMappingType_AGX_Sepia: - case ToneMappingType_AGX_Punchy: - { - if (LengthSq(Lighting->CurrentSunColor) > 1.f) - { - Lighting->CurrentSunColor = Normalize(Lighting->CurrentSunColor); - } - } break; - } + b32 Result = True; + return Result; } link_export b32 @@ -449,12 +516,7 @@ Bonsai_Render(engine_resources *Engine) TIMED_FUNCTION(); UNPACK_ENGINE_RESOURCES(Engine); - if (Graphics->Settings.Lighting.AutoDayNightCycle) - { - Graphics->Settings.Lighting.tDay += Plat->dt/18.0f; - } - UpdateKeyLightColor(Graphics, Graphics->Settings.Lighting.tDay); - + SignalFutex(&Engine->Graphics.RenderGate); /* BindUniformByName(Shader, "DrawMinorGrid", False); */ shader_uniform MinorGridUniform = @@ -462,7 +524,8 @@ Bonsai_Render(engine_resources *Engine) .Type = ShaderUniform_U32, .U32 = &Global_False, .ID = INVALID_SHADER_UNIFORM, - .Name = "DrawMinorGrid" + .Name = "DrawMinorGrid", + .Count = 0, }; shader_uniform MajorGridUniform = @@ -470,20 +533,29 @@ Bonsai_Render(engine_resources *Engine) .Type = ShaderUniform_U32, .U32 = &Global_False, .ID = INVALID_SHADER_UNIFORM, - .Name = "DrawMajorGrid" + .Name = "DrawMajorGrid", + .Count = 0, }; - PushBonsaiRenderCommandSetupShader(&Plat->RenderQ, BonsaiRenderCommand_ShaderId_gBuffer); - PushBonsaiRenderCommandSetShaderUniform(&Plat->RenderQ, MinorGridUniform, &Graphics->gBuffer->gBufferShader, -1); - PushBonsaiRenderCommandSetShaderUniform(&Plat->RenderQ, MajorGridUniform, &Graphics->gBuffer->gBufferShader, -1); - PushBonsaiRenderCommandDrawAllEntities(&Plat->RenderQ, &Graphics->gBuffer->gBufferShader); - PushBonsaiRenderCommandTeardownShader(&Plat->RenderQ, BonsaiRenderCommand_ShaderId_gBuffer); + /* { */ + /* auto SunP = Graphics->Settings.Lighting.SunP; */ + /* auto Target = GetRenderP(World->ChunkDim, ComputeTarget(&Graphics->GameCamera), &Graphics->GameCamera); */ + /* DEBUG_VALUE(&SunP); */ + /* DEBUG_VALUE(&Target); */ + /* } */ + + + PushBonsaiRenderCommandSetupShader(&Plat->HiRenderQ, BonsaiRenderCommand_ShaderId_gBuffer); + PushBonsaiRenderCommandSetShaderUniform(&Plat->HiRenderQ, MinorGridUniform, &Graphics->gBuffer->gBufferShader, -1); + PushBonsaiRenderCommandSetShaderUniform(&Plat->HiRenderQ, MajorGridUniform, &Graphics->gBuffer->gBufferShader, -1); + PushBonsaiRenderCommandDrawAllEntities(&Plat->HiRenderQ, &Graphics->gBuffer->gBufferShader); + PushBonsaiRenderCommandTeardownShader(&Plat->HiRenderQ, BonsaiRenderCommand_ShaderId_gBuffer); - PushBonsaiRenderCommandSetupShader(&Plat->RenderQ, BonsaiRenderCommand_ShaderId_ShadowMap); - PushBonsaiRenderCommandDrawAllEntities(&Plat->RenderQ, &Graphics->SG->Shader.Program); - PushBonsaiRenderCommandTeardownShader(&Plat->RenderQ, BonsaiRenderCommand_ShaderId_ShadowMap); + PushBonsaiRenderCommandSetupShader(&Plat->HiRenderQ, BonsaiRenderCommand_ShaderId_ShadowMap); + PushBonsaiRenderCommandDrawAllEntities(&Plat->HiRenderQ, &Graphics->SG->Shader.Program); + PushBonsaiRenderCommandTeardownShader(&Plat->HiRenderQ, BonsaiRenderCommand_ShaderId_ShadowMap); /* DoModalInteraction(Ui, RectMinDim(V2(0), *Ui->ScreenDim)); */ @@ -491,36 +563,89 @@ Bonsai_Render(engine_resources *Engine) { layout DefaultLayout = {}; - DefaultLayout.DrawBounds = InvertedInfinityRectangle(); - render_state RenderState = { .Layout = &DefaultLayout, .ClipRect = DISABLE_CLIPPING }; + render_state RenderState = {}; + RenderState.Layout = &DefaultLayout; + SetWindowZDepths(Ui->CommandBuffer); FlushCommandBuffer(Ui, &RenderState, Ui->CommandBuffer, &DefaultLayout); } - PushBonsaiRenderCommandDoStuff(&Plat->RenderQ); + PushBonsaiRenderCommandDoStuff(&Plat->HiRenderQ); - PushBonsaiRenderCommandGlTimerReadValueAndHistogram(&Plat->RenderQ, Graphics->gBuffer->GlTimerObject); + /* PushBonsaiRenderCommandGlTimerReadValueAndHistogram(&Plat->HiRenderQ, Graphics->gBuffer->GlTimerObject); */ - Engine->Graphics.RenderGate = True; - while (Engine->Graphics.RenderGate == True) { SleepMs(1); } + while (FutexIsSignaled(&Engine->Graphics.RenderGate)) { SleepMs(1); } b32 Result = True; return Result; } +struct bonsai_thread_user_data +{ + u64 Magic0 = 0x69; + /* gen_chunk_freelist GenChunkFreelist; */ + u64 Magic1 = 0x420; +}; + +link_internal void +FreeWorldChunk(gen_chunk_freelist *Freelist, gen_chunk *Chunk) +{ + Free(Freelist, Chunk); +} + +link_internal void +FreeWorldChunk(world_chunk_freelist *Freelist, world_chunk *Chunk) +{ + Free(Freelist, Chunk); +} + +link_internal world_chunk * +GetOrAllocate(world_chunk_freelist *Freelist, v3i WorldP, v3i Dim, v3i DimInChunks, memory_arena *Memory) +{ + Freelist->Memory = Memory; + world_chunk *Result = GetOrAllocate(Freelist); + + if (Result->Occupancy == 0) + { + AllocateWorldChunk(Result, WorldP, Dim, DimInChunks, Memory); + } + + return Result; +} + +link_internal gen_chunk * +GetOrAllocate(gen_chunk_freelist *Freelist, v3i WorldP, v3i Dim, v3i DimInChunks, memory_arena *Memory) +{ + Freelist->Memory = Memory; + gen_chunk *Result = GetOrAllocate(Freelist); + + if (Result->Chunk.Occupancy == 0) + { + AllocateWorldChunk(&Result->Chunk, WorldP, Dim, DimInChunks, Memory); + Result->Voxels = AllocateAlignedProtection( voxel, Memory , Volume(Dim), CACHE_LINE_SIZE, false); + } + + Assert(HasGpuMesh(&Result->Mesh) == False); + Assert(HasGpuMesh(&Result->Chunk) == False); + + return Result; +} + link_weak void WorkerThread_ApplicationDefaultImplementation(BONSAI_API_WORKER_THREAD_CALLBACK_PARAMS) { engine_resources *EngineResources = GetEngineResources(); - world *World = EngineResources->World; + world *World = EngineResources->World; - work_queue_entry_type WorkType = Entry->Type; - switch (WorkType) + auto LoRenderQ = &EngineResources->Stdlib.Plat.LoRenderQ; + auto HiRenderQ = &EngineResources->Stdlib.Plat.HiRenderQ; + + tswitch (Entry) { InvalidCase(type_work_queue_entry_noop); InvalidCase(type_work_queue_entry__align_to_cache_line_helper); - InvalidCase(type_work_queue_entry_update_world_region); + /* 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); @@ -529,61 +654,162 @@ WorkerThread_ApplicationDefaultImplementation(BONSAI_API_WORKER_THREAD_CALLBACK_ DispatchAsyncFunctionCall(Job); } break; - case type_work_queue_entry_init_asset: - { - work_queue_entry_init_asset *Job = SafeAccess(work_queue_entry_init_asset, Entry); + { tmatch(work_queue_entry_init_asset, Entry, Job) InitAsset(Job->Asset, Thread); } break; - case type_work_queue_entry_sim_particle_system: - { - work_queue_entry_sim_particle_system *Job = SafeAccess(work_queue_entry_sim_particle_system, Entry); + { tmatch(work_queue_entry_sim_particle_system, Entry, Job) SimulateParticleSystem(Job); } 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; + { tmatch(work_queue_entry_finalize_noise_values, Entry, Job) + octree_node *Node = Job->DestNode; + auto Chunk = Node->Chunk; + + u32 *NoiseValues = Job->NoiseData; + v3i NoiseDim = Job->NoiseDim; + Assert(NoiseValues); + Assert(Chunk); + + world_chunk *DestChunk = Node->Chunk; + + // NOTE(Jesse): This is valid when we resubmit a chunk because we change the edits + // We need to keep these intact so that we don't flicker and hence have to wait + // till the very end to reallocate + // @dest_chunk_can_have_mesh + /* Assert(HasGpuMesh(&DestChunk->Handles) == False); */ + + gen_chunk *GenChunk = GetOrAllocate(&EngineResources->GenChunkFreelist, {}, Chunk->Dim + V3i(0, 2, 2), Chunk->DimInChunks, Thread->PermMemory); + world_chunk *SynChunk = &GenChunk->Chunk; + + Assert(HasGpuMesh(&GenChunk->Mesh) == False); + Assert(HasGpuMesh(SynChunk) == False); + + voxel *Voxels = GenChunk->Voxels; + + Assert(NoiseDim == V3i(66, 66, 66)); + Assert(SynChunk->Dim == V3i(64, 66, 66)); + + v3i WorldBasis = {}; + v3i SrcToDest = {}; + s64 zMin = 0; + + u32 ChunkSum = FinalizeOccupancyMasksFromNoiseValues(SynChunk, Voxels, WorldBasis, NoiseDim, NoiseValues, SrcToDest, zMin); + + b32 Continued = False; + if (ChunkSum && ChunkSum < u32(Volume(SynChunk->Dim))) + { + MakeFaceMasks_NoExteriorFaces(SynChunk->Occupancy, + SynChunk->xOccupancyBorder, + SynChunk->FaceMasks, + Voxels, + SynChunk->Dim, + {}, + SynChunk->Dim); + + Assert(SynChunk->Dim.x == 64); + Assert(SynChunk->Dim.y == 66); + Assert(SynChunk->Dim.z == 66); + + Assert(DestChunk->FilledCount == 0); + Assert(DestChunk->Dim.x == 64); + Assert(DestChunk->Dim.y == 64); + Assert(DestChunk->Dim.z == 64); + RangeIterator(z, 64) + RangeIterator(y, 64) + { + u64 Occ = SynChunk->Occupancy[(y+1) + ((z+1)*66)]; + DestChunk->Occupancy[y + (z*64)] = Occ; + DestChunk->FilledCount += CountBitsSet_Kernighan(Occ); + } + + Assert(DestChunk->FilledCount <= s32(Volume(DestChunk->Dim))); + + /* FinalizeChunkInitialization(SynChunk); */ + + s32 FacesRequired = CountRequiredFacesForMesh_Naieve(SynChunk->FaceMasks, SynChunk->Dim); + if (FacesRequired) + { + Continued = True; + /* Info("Chunk had faces (%d)", FacesRequired); */ + Assert(Node->Flags & Chunk_Queued); + PushBonsaiRenderCommandAllocateAndMapGpuElementBuffer( + LoRenderQ, DataType_v3_u8, u32(FacesRequired*VERTS_PER_FACE), &GenChunk->Mesh, + GenChunk, Node); // NOTE(Jesse): These should go away once we can specify the next job here.. + } + } + + Assert(Node->Flags & Chunk_Queued); - 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; - RebuildWorldChunkMesh(Thread, Chunk, {}, Chunk->Dim, MeshBit_Lod1, TempMesh, Thread->TempMemory); - TempMesh->At = 0; - RebuildWorldChunkMesh(Thread, Chunk, {}, Chunk->Dim, MeshBit_Lod2, TempMesh, Thread->TempMemory); - TempMesh->At = 0; - RebuildWorldChunkMesh(Thread, Chunk, {}, Chunk->Dim, MeshBit_Lod3, TempMesh, Thread->TempMemory); - TempMesh->At = 0; - RebuildWorldChunkMesh(Thread, Chunk, {}, Chunk->Dim, MeshBit_Lod4, TempMesh, Thread->TempMemory); - TempMesh->At = 0; - - if (Job->Flags & ChunkInitFlag_ComputeStandingSpots) + // If we didn't continue, we're done, free the resources + // + if (Continued == False) { - ComputeStandingSpots( Chunk->Dim, - Chunk->Voxels, - {}, - - {}, - Global_TileDim, - - Chunk->Dim, - 0, - &Chunk->StandingSpots, - /* memory_arena *PermMemory, */ - Thread->TempMemory ); + Assert(HasGpuMesh(&GenChunk->Mesh) == False); + /* DeallocateHandles(LoRenderQ, &GenChunk->Mesh.Handles); */ + + Free(&GetEngineResources()->GenChunkFreelist, GenChunk); + FinalizeNodeInitializaion(Node); + + // Deallocate the stale mesh if the new chunk didn't have a mesh + if (Node->Chunk && HasGpuMesh(Node->Chunk) ) + { + DeallocateHandles(LoRenderQ, &Node->Chunk->Handles); + } } - /* UnsetBitfield(chunk_flag, Chunk->Flags, Chunk_Queued); */ - Chunk->Flags = chunk_flag(Chunk->Flags & ~Chunk_Queued); - /* Chunk->Flags = chunk_flag(Chunk->Flags & ~Chunk_MeshUploadedToGpu); */ + + auto Graphics = &EngineResources->Graphics; + + // NOTE(Jesse): The CPU initializer obviously doesn't need to deallocate + // a PBO, so it sets the PBO handle to -1 + Assert(Job->PBOBuf.PBO != INVALID_PBO_HANDLE); + PushBonsaiRenderCommandUnmapAndDeallocatePbo(LoRenderQ, Job->PBOBuf); + + Assert(Graphics->NoiseFinalizeJobsPending); + AtomicDecrement(&Graphics->NoiseFinalizeJobsPending); + AtomicDecrement(&Graphics->TotalChunkJobsActive); + } break; - case type_work_queue_entry_init_world_chunk: - { - work_queue_entry_init_world_chunk *Job = SafeAccess(work_queue_entry_init_world_chunk, Entry); + { tmatch(work_queue_entry_build_chunk_mesh, Entry, Job) + gen_chunk *GenChunk = Job->GenChunk; + world_chunk *SynChunk = &GenChunk->Chunk; + + Assert(HasGpuMesh(&GenChunk->Mesh) == True); + Assert(HasGpuMesh( SynChunk) == False); + + + octree_node *DestNode = Job->DestNode; + world_chunk *DestChunk = DestNode->Chunk; + + Assert(DestNode->Flags & Chunk_Queued); + + // @dest_chunk_can_have_mesh + /* Assert(HasGpuMesh(DestChunk) == False); */ + + /* Info("Buidling Chunk Mesh"); */ + + BuildWorldChunkMeshFromMarkedVoxels_Naieve( GenChunk->Voxels, SynChunk->FaceMasks, SynChunk->Dim, {}, {}, &GenChunk->Mesh.Buffer, 0); + + Assert(HasGpuMesh(&GenChunk->Mesh) == True); + Assert(HasGpuMesh( SynChunk) == False); + + // @dest_chunk_can_have_mesh + /* Assert(HasGpuMesh(DestChunk) == False); */ + + FinalizeShitAndFuckinDoStuff_Async(LoRenderQ, GenChunk, DestNode); + } break; + + { tmatch(work_queue_entry_rebuild_mesh, Entry, Job) + NotImplemented; + } break; + + { tmatch(work_queue_entry_init_world_chunk, Entry, Job) + +#if 1 + NotImplemented; +#else world_chunk *Chunk = Job->Chunk; counted_string AssetFilename = GetAssetFilenameFor(Global_AssetPrefixPath, Chunk->WorldP, Thread->TempMemory); @@ -591,31 +817,30 @@ WorkerThread_ApplicationDefaultImplementation(BONSAI_API_WORKER_THREAD_CALLBACK_ if (ChunkIsGarbage(Chunk)) { - // NOTE(Jesse): This is an optimization; the engine marks chunks that // have moved outside of the visible region as garbage. + // NOTE(Jesse): This is an optimization; the engine marks chunks that + // have moved outside of the visible region as garbage. Chunk->Flags = Chunk_Uninitialized; } else { s32 Period = 150; s32 Amplititude = 10; - s32 StartingZDepth = 0; - v3 Color = HSV_GRASS_GREEN; + s32 StartingZDepth = 120; + v3 Color = RGB_GRASS_GREEN; Assert(Chunk->Dim == World->ChunkDim); u32 Octaves = 1; - InitializeChunkWithNoise( Terrain_Perlin2D, Thread, Chunk, Chunk->Dim, &AssetFile, V3(Period), Amplititude, StartingZDepth, Color, MeshBit_Lod0, ChunkInitFlag_ComputeStandingSpots, &Octaves); + /* InitializeChunkWithNoise( Terrain_Perlin2D, Thread, Chunk, Chunk->Dim, &AssetFile, V3(Period), Amplititude, StartingZDepth, Color, MeshBit_Lod0, ChunkInitFlag_ComputeStandingSpots, &Octaves); */ } +#endif } break; - case type_work_queue_entry_copy_buffer_ref: - { - work_queue_entry_copy_buffer_ref *CopyJob = SafeAccess(work_queue_entry_copy_buffer_ref, Entry); - DoCopyJob(CopyJob, &EngineResources->geo_u3d_MeshFreelist, Thread->PermMemory); + { tmatch(work_queue_entry_copy_buffer_ref, Entry, Job) + DoCopyJob(Job, &EngineResources->geo_u3d_MeshFreelist, Thread->PermMemory); } break; - case type_work_queue_entry_copy_buffer_set: - { + { tmatch(work_queue_entry_copy_buffer_set, Entry, Job) TIMED_BLOCK("Copy Set"); volatile work_queue_entry_copy_buffer_set *CopySet = SafeAccess(work_queue_entry_copy_buffer_set, Entry); for (u32 CopyIndex = 0; CopyIndex < CopySet->Count; ++CopyIndex) diff --git a/src/engine/api.h b/src/engine/api.h index 8115f8de0..df3e11559 100644 --- a/src/engine/api.h +++ b/src/engine/api.h @@ -7,11 +7,15 @@ struct engine_api bonsai_engine_callback FrameBegin; bonsai_engine_callback Simulate; bonsai_engine_callback FrameEnd; - bonsai_engine_callback Render; // NOTE(Jesse): This gets loaded such that the render thread shares the same // globals as the game lib. thread_main_callback_type RenderThread_Main; + + bonsai_engine_callback DrainHiRenderQueue; + bonsai_engine_callback DrainLoRenderQueue; + + bonsai_engine_callback Render; }; link_internal b32 @@ -23,23 +27,34 @@ InitializeEngineApi(engine_api *EngineApi, shared_lib GameLib) EngineApi->Simulate = (bonsai_engine_callback)GetProcFromLib(GameLib, STRINGIZE(Bonsai_Simulate) ); EngineApi->FrameBegin = (bonsai_engine_callback)GetProcFromLib(GameLib, STRINGIZE(Bonsai_FrameBegin) ); EngineApi->FrameEnd = (bonsai_engine_callback)GetProcFromLib(GameLib, STRINGIZE(Bonsai_FrameEnd) ); - EngineApi->Render = (bonsai_engine_callback)GetProcFromLib(GameLib, STRINGIZE(Bonsai_Render) ); + EngineApi->Render = (bonsai_engine_callback) GetProcFromLib(GameLib, STRINGIZE(Bonsai_Render) ); EngineApi->RenderThread_Main = (thread_main_callback_type)GetProcFromLib(GameLib, STRINGIZE(RenderThread_Main) ); + EngineApi->DrainLoRenderQueue = (bonsai_engine_callback) GetProcFromLib(GameLib, STRINGIZE(DrainLoRenderQueue) ); + EngineApi->DrainHiRenderQueue = (bonsai_engine_callback) GetProcFromLib(GameLib, STRINGIZE(DrainHiRenderQueue) ); + + b32 Result = EngineApi->Simulate && + EngineApi->OnLibraryLoad && + EngineApi->Init && + EngineApi->FrameBegin && + EngineApi->FrameEnd && + EngineApi->Render && + EngineApi->RenderThread_Main && + EngineApi->DrainHiRenderQueue && + EngineApi->DrainLoRenderQueue; - b32 Result = EngineApi->Simulate && EngineApi->OnLibraryLoad && EngineApi->Init && EngineApi->FrameBegin && EngineApi->FrameEnd && EngineApi->Render && EngineApi->RenderThread_Main; return Result; } link_internal b32 InitializeGameApi(application_api *GameApi, shared_lib GameLib) { - GameApi->GameInit = (bonsai_main_thread_init_callback) GetProcFromLib(GameLib, STRINGIZE(BONSAI_API_MAIN_THREAD_INIT_CALLBACK_NAME)); - GameApi->GameMain = (bonsai_main_thread_callback) GetProcFromLib(GameLib, STRINGIZE(BONSAI_API_MAIN_THREAD_CALLBACK_NAME)); - GameApi->WorkerInit = (bonsai_worker_thread_init_callback)GetProcFromLib(GameLib, STRINGIZE(BONSAI_API_WORKER_THREAD_INIT_CALLBACK_NAME)); - GameApi->WorkerMain = (bonsai_worker_thread_callback) GetProcFromLib(GameLib, STRINGIZE(BONSAI_API_WORKER_THREAD_CALLBACK_NAME) ); + GameApi->GameInit = (bonsai_main_thread_init_callback) GetProcFromLib(GameLib, STRINGIZE(BONSAI_API_MAIN_THREAD_INIT_CALLBACK_NAME)); + GameApi->GameMain = (bonsai_main_thread_callback) GetProcFromLib(GameLib, STRINGIZE(BONSAI_API_MAIN_THREAD_CALLBACK_NAME)); + GameApi->WorkerInit = (bonsai_worker_thread_init_callback) GetProcFromLib(GameLib, STRINGIZE(BONSAI_API_WORKER_THREAD_INIT_CALLBACK_NAME)); + GameApi->WorkerMain = (bonsai_worker_thread_callback) GetProcFromLib(GameLib, STRINGIZE(BONSAI_API_WORKER_THREAD_CALLBACK_NAME) ); GameApi->WorkerBeforeJob = (bonsai_worker_thread_before_job_callback)GetProcFromLib(GameLib, STRINGIZE(BONSAI_API_WORKER_THREAD_BEFORE_JOB_CALLBACK_NAME)); - GameApi->OnLibraryLoad = (bonsai_main_thread_callback) GetProcFromLib(GameLib, STRINGIZE(BONSAI_API_ON_GAME_LIB_LOAD_CALLBACK_NAME) ); + GameApi->OnLibraryLoad = (bonsai_main_thread_callback) GetProcFromLib(GameLib, STRINGIZE(BONSAI_API_ON_GAME_LIB_LOAD_CALLBACK_NAME) ); b32 Result = GameApi->GameMain != 0; return Result; diff --git a/src/engine/asset.cpp b/src/engine/asset.cpp index 3f7544ea7..6c004de31 100644 --- a/src/engine/asset.cpp +++ b/src/engine/asset.cpp @@ -15,7 +15,7 @@ MakeWorldChunkFileHeader_v2(world_chunk *Chunk) NotImplemented; /* if (HasMesh(&Chunk->Meshes, MeshBit_Lod0)) */ { - Result.MeshElementCount = Chunk->Meshes.E[MeshIndex_Lod0]->At; + /* Result.MeshElementCount = Chunk->Meshes.E[MeshIndex_Lod0]->At; */ } Result.VertexElementSize = (u32)sizeof(v3); @@ -69,7 +69,7 @@ MakeWorldChunkFileHeader_v1(world_chunk *Chunk) NotImplemented; /* if (HasMesh(&Chunk->Meshes, MeshBit_Lod0)) */ { - Result.MeshElementCount = Chunk->Meshes.E[MeshIndex_Lod0]->At; + /* Result.MeshElementCount = Chunk->Meshes.E[MeshIndex_Lod0]->At; */ } @@ -327,10 +327,10 @@ DeserializeChunk(u8_stream *FileBytes, world_chunk *Result, memory_arena *PermMe Assert(Header.VoxelElementCount == Volume(Result)); - u32 Tag = Read_u32(FileBytes); - Assert( Tag == WorldChunkFileTag_VOXD ); - umm VoxByteCount = Header.VoxelElementCount * Header.VoxelElementSize; - ReadBytesIntoBuffer(FileBytes, (u8*)Result->Voxels, VoxByteCount); + /* u32 Tag = Read_u32(FileBytes); */ + /* Assert( Tag == WorldChunkFileTag_VOXD ); */ + /* umm VoxByteCount = Header.VoxelElementCount * Header.VoxelElementSize; */ + /* ReadBytesIntoBuffer(FileBytes, (u8*)Result->Voxels, VoxByteCount); */ Result->FilledCount = s32(Header.VoxelElementCount); @@ -347,7 +347,7 @@ DeserializeChunk(u8_stream *FileBytes, world_chunk *Result, memory_arena *PermMe // // SPOT data // - Tag = Read_u32(FileBytes); + u32 Tag = Read_u32(FileBytes); Assert(Tag == WorldChunkFileTag_SPOT); umm ByteCount = SpotElementSize*TotalElements; @@ -358,7 +358,7 @@ DeserializeChunk(u8_stream *FileBytes, world_chunk *Result, memory_arena *PermMe /* Tag = Read_u32(FileBytes); */ /* Assert(Tag == WorldChunkFileTag_END); */ - Result->Flags = Chunk_VoxelsInitialized; + /* Result->Flags = Chunk_VoxelsInitialized; */ /* DebugLine("Loaded Chunk : P (%d,%d,%d) Standing Spots (%d)", Result->WorldP.x, Result->WorldP.y, Result->WorldP.z, Header.StandingSpotElementCount); */ } @@ -373,11 +373,10 @@ SerializeChunk(world_chunk *Chunk, u8_cursor_block_array *Bytes) Result &= Write(Bytes, (u8*)&FileHeader, sizeof(FileHeader)); { - u64 VoxByteCount = FileHeader.VoxelElementCount * FileHeader.VoxelElementSize; - - u32 Tag = WorldChunkFileTag_VOXD; - Result &= Write(Bytes, Tag); - Result &= Write(Bytes, (u8*)Chunk->Voxels, VoxByteCount); + /* u64 VoxByteCount = FileHeader.VoxelElementCount * FileHeader.VoxelElementSize; */ + /* u32 Tag = WorldChunkFileTag_VOXD; */ + /* Result &= Write(Bytes, Tag); */ + /* Result &= Write(Bytes, (u8*)Chunk->Voxels, VoxByteCount); */ } #if 0 @@ -607,14 +606,17 @@ InitAsset(asset *Asset, thread_local_state *Thread) // 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); + NotImplemented; + voxel *VoxelBuffer = 0; + MarkBoundaryVoxels_MakeExteriorFaces(Chunk->Occupancy, VoxelBuffer, Chunk->Dim, V3i(0), Chunk->Dim); - FinalizeChunkInitialization(Chunk); + /* 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); + NotImplemented; + /* RebuildWorldChunkMesh(Thread, Chunk, V3i(0), Chunk->Dim, MeshBit_Lod0, TempMesh, Thread->TempMemory, Chunk->Dim/-2.f); */ Asset->Type = AssetType_WorldChunk; Asset->Chunk = *Chunk; diff --git a/src/engine/asset.h b/src/engine/asset.h index c687e3851..c838251ed 100644 --- a/src/engine/asset.h +++ b/src/engine/asset.h @@ -258,12 +258,18 @@ GetChunkDataForAssetModel(asset *Asset, u32 ModelIndex) { if (ModelIndex != 0) { Warn("Requested Dim for ModelIndex(%d) on an asset with Type(AssetType_WorldChunk), ignoring ModelIndex", ModelIndex); } + // NOTE(Jesse): Removed Flags from chunk_data .. does that matter here? + NotImplemented; + Result.Tag = Maybe_Yes; Result.Value = { - .Flags = Asset->Chunk.Flags, .Dim = Asset->Chunk.Dim, - .Voxels = Asset->Chunk.Voxels, - .VoxelLighting = Asset->Chunk.VoxelLighting, + .Occupancy = Asset->Chunk.Occupancy, + .xOccupancyBorder = Asset->Chunk.xOccupancyBorder, + .FaceMasks = Asset->Chunk.FaceMasks, + /* .Flags = Asset->Chunk.Flags, */ + /* .Voxels = Asset->Chunk.Voxels, */ + /* .VoxelLighting = Asset->Chunk.VoxelLighting, */ }; } break; diff --git a/src/engine/asset_loaders.cpp b/src/engine/asset_loaders.cpp index b45c6336c..e69de29bb 100644 --- a/src/engine/asset_loaders.cpp +++ b/src/engine/asset_loaders.cpp @@ -1,4 +0,0 @@ -#include -#include -#include - diff --git a/src/engine/bloom.cpp b/src/engine/bloom.cpp index aa49f0ae0..1ef29bd52 100644 --- a/src/engine/bloom.cpp +++ b/src/engine/bloom.cpp @@ -21,8 +21,8 @@ InitBloomRenderGroup(bloom_render_group *Group, render_settings *Settings, memor // Bloom FBO { Group->BlurFBO = GenFramebuffer(); - GL.BindFramebuffer(GL_FRAMEBUFFER, Group->BlurFBO.ID); - GL.BindTexture(GL_TEXTURE_2D, Group->Tex.ID); + GetGL()->BindFramebuffer(GL_FRAMEBUFFER, Group->BlurFBO.ID); + GetGL()->BindTexture(GL_TEXTURE_2D, Group->Tex.ID); FramebufferTexture(&Group->BlurFBO, &Group->Tex); SetDrawBuffers(&Group->BlurFBO); if (CheckAndClearFramebuffer() == False) { Error("Initializing Bloom FBO"); } @@ -38,16 +38,16 @@ InitBloomRenderGroup(bloom_render_group *Group, render_settings *Settings, memor link_internal void RunBloomRenderPass(graphics *Graphics) { - bloom_render_group *Group = &Graphics->Lighting.Bloom; + bloom_render_group *Group = &Graphics->Bloom; - GL.BindFramebuffer(GL_FRAMEBUFFER, Group->BlurFBO.ID); + GetGL()->BindFramebuffer(GL_FRAMEBUFFER, Group->BlurFBO.ID); - // Setup VBO for fullscreen quad - Assert(Global_QuadVertexBuffer); - GL.EnableVertexAttribArray(0); - GL.BindBuffer(GL_ARRAY_BUFFER, Global_QuadVertexBuffer); - GL.VertexAttribPointer( 0, 3, GL_FLOAT, GL_FALSE, 0, (void*)0); - AssertNoGlErrors; + /* // Setup VBO for fullscreen quad */ + /* Assert(Global_QuadVertexBuffer); */ + /* GetGL()->EnableVertexAttribArray(0); */ + /* GetGL()->BindBuffer(GL_ARRAY_BUFFER, Global_QuadVertexBuffer); */ + /* GetGL()->VertexAttribPointer( 0, 3, GL_FLOAT, GL_FALSE, 0, (void*)0); */ + /* AssertNoGlErrors; */ // // Downsample @@ -56,10 +56,10 @@ RunBloomRenderPass(graphics *Graphics) UseShader(&Group->DownsampleShader); // Activate the 0th texture unit - GL.ActiveTexture(GL_TEXTURE0); + GetGL()->ActiveTexture(GL_TEXTURE0); // LuminanceTex is the source for the bloom, start with it as the source tex - GL.BindTexture(GL_TEXTURE_2D, Graphics->Lighting.LuminanceTex.ID); + GetGL()->BindTexture(GL_TEXTURE_2D, Graphics->Lighting.LuminanceTex.ID); v2 SrcDim = V2(Graphics->Lighting.LuminanceTex.Dim); RangeIterator(MipIndex, BLOOM_MIP_CHAIN_COUNT) @@ -69,10 +69,10 @@ RunBloomRenderPass(graphics *Graphics) BindUniformByName(&Group->DownsampleShader.Program, "SrcDim", &SrcDim); - GL.FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, MipTex->ID, 0); - Draw(6); + GetGL()->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, MipTex->ID, 0); + RenderQuad(); - GL.BindTexture(GL_TEXTURE_2D, MipTex->ID); // Make current mip the source for next iteration + GetGL()->BindTexture(GL_TEXTURE_2D, MipTex->ID); // Make current mip the source for next iteration SrcDim = V2(MipTex->Dim); } @@ -89,22 +89,22 @@ RunBloomRenderPass(graphics *Graphics) texture *MipTex = Group->MipChain + MipIndex; SetViewport(MipTex->Dim); - GL.FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, MipTex->ID, 0); - Draw(6); + GetGL()->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, MipTex->ID, 0); + RenderQuad(); - GL.BindTexture(GL_TEXTURE_2D, MipTex->ID); // Make current mip the source for next iteration + GetGL()->BindTexture(GL_TEXTURE_2D, MipTex->ID); // Make current mip the source for next iteration SrcDim = V2(MipTex->Dim); } // Final upsample into full-res texture SetViewport(Group->Tex.Dim); - GL.FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, Group->Tex.ID, 0); - Draw(6); + GetGL()->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, Group->Tex.ID, 0); + RenderQuad(); // Teardown VBO - GL.BindBuffer(GL_ARRAY_BUFFER, 0); - GL.DisableVertexAttribArray(0); + GetGL()->BindBuffer(GL_ARRAY_BUFFER, 0); + GetGL()->DisableVertexAttribArray(0); } diff --git a/src/engine/bloom.h b/src/engine/bloom.h index 61f508e88..96cc0b732 100644 --- a/src/engine/bloom.h +++ b/src/engine/bloom.h @@ -1,6 +1,8 @@ struct bloom_downsample_shader -poof( @vert_source_file("external/bonsai_stdlib/shaders/Passthrough.vertexshader") +poof( @render_pass + @do_editor_ui + @vert_source_file("external/bonsai_stdlib/shaders/Passthrough.vertexshader") @frag_source_file("shaders/bloom_downsample.fragmentshader") ) { shader Program; @@ -8,11 +10,11 @@ poof( @vert_source_file("external/bonsai_stdlib/shaders/Passthrough.vertexshader v2 *SrcResolution; poof(@uniform) }; -poof(shader_magic(bloom_downsample_shader)) -#include struct bloom_upsample_shader -poof( @vert_source_file("external/bonsai_stdlib/shaders/Passthrough.vertexshader") +poof( @render_pass + @do_editor_ui + @vert_source_file("external/bonsai_stdlib/shaders/Passthrough.vertexshader") @frag_source_file("shaders/bloom_upsample.fragmentshader") ) { shader Program; @@ -22,12 +24,11 @@ poof( @vert_source_file("external/bonsai_stdlib/shaders/Passthrough.vertexshader }; -poof(shader_magic(bloom_upsample_shader)) -#include #define BLOOM_MIP_CHAIN_COUNT (3) struct bloom_render_group +poof(@do_editor_ui) { framebuffer BlurFBO; // For doing the blur diff --git a/src/engine/bonsai.h b/src/engine/bonsai.h index 906187e4e..1a7754c8f 100644 --- a/src/engine/bonsai.h +++ b/src/engine/bonsai.h @@ -111,13 +111,6 @@ struct entity_entity_collision_event entity *Entity; }; -inline void -UnSetFlag( voxel_flag *Flags, voxel_flag Flag ) -{ - *Flags = (voxel_flag)(*Flags & ~Flag); - return; -} - inline void UnSetFlag( chunk_flag *Flags, chunk_flag Flag ) { @@ -126,9 +119,9 @@ UnSetFlag( chunk_flag *Flags, chunk_flag Flag ) } inline void -UnSetFlag( world_chunk *Chunk, chunk_flag Flag ) +UnSetFlag( octree_node *Node, chunk_flag Flag ) { - UnSetFlag(&Chunk->Flags, Flag); + UnSetFlag(&Node->Flags, Flag); return; } @@ -139,14 +132,6 @@ UnSetFlag( world_chunk *Chunk, chunk_flag Flag ) /* return; */ /* } */ -inline void -SetFlag( u8 *Flags, voxel_flag Flag ) -{ - /* Assert(Flag < u8_MAX); */ - *Flags = (u8)(*Flags | Flag); - return; -} - inline void SetFlag( chunk_flag *Flags, chunk_flag Flag ) { @@ -163,33 +148,12 @@ SetFlag( chunk_flag *Flags, chunk_flag Flag ) /* } */ inline void -SetFlag( world_chunk *Chunk, chunk_flag Flag ) +SetFlag( octree_node *Node, chunk_flag Flag ) { - Chunk->Flags = (chunk_flag)(Chunk->Flags | Flag); - return; -} - -inline void -SetFlag(voxel *Voxel, voxel_flag Flag ) -{ - SetFlag(&Voxel->Flags, Flag); - return; -} - -inline void -SetFlag(boundary_voxel *Voxel, voxel_flag Flag ) -{ - SetFlag(&Voxel->V.Flags, Flag); + Node->Flags = (chunk_flag)(Node->Flags | Flag); return; } -inline b32 -IsSet( u8 Flags, voxel_flag Flag ) -{ - b32 Result = ( (Flags & Flag) != 0 ); - return Result; -} - inline b32 IsSet( chunk_flag Flags, chunk_flag Flag ) { @@ -205,33 +169,12 @@ IsSet( chunk_flag Flags, chunk_flag Flag ) /* } */ inline b32 -IsSet( world_chunk *Chunk, chunk_flag Flag ) +IsSet( octree_node *Chunk, chunk_flag Flag ) { b32 Result = IsSet(Chunk->Flags, Flag); return Result; } -inline b32 -IsSet( voxel *V, voxel_flag Flag ) -{ - b32 Result = IsSet(V->Flags, Flag); - return Result; -} - -inline b32 -IsSet( boundary_voxel *V, voxel_flag Flag ) -{ - b32 Result = IsSet(&V->V, Flag); - return Result; -} - -inline b32 -NotSet( voxel_flag Flags, voxel_flag Flag ) -{ - b32 Result = !(IsSet(Flags, Flag)); - return Result; -} - inline b32 NotSet( chunk_flag Flags, chunk_flag Flag ) { @@ -247,19 +190,12 @@ NotSet( chunk_flag Flags, chunk_flag Flag ) /* } */ inline b32 -NotSet( world_chunk *Chunk, chunk_flag Flag ) +NotSet( octree_node *Chunk, chunk_flag Flag ) { b32 Result = !(IsSet(Chunk, Flag)); return Result; } -inline b32 -NotSet( voxel *Voxel, voxel_flag Flag ) -{ - b32 Result = !(IsSet(Voxel, Flag)); - return Result; -} - inline b32 Spawned(entity *Entity) { @@ -314,54 +250,24 @@ Unspawned(entity *Entity) link_internal void ClearWorldChunk( world_chunk *Chunk ) { + Assert(HasGpuMesh(Chunk) == False); +#if 0 + *Chunk = {}; +#else Chunk->WorldP = INVALID_WORLD_CHUNK_POSITION; Chunk->FilledCount = {}; - Chunk->DrawBoundingVoxels = {}; - Chunk->PointsToLeaveRemaining = {}; - Chunk->TriCount = {}; - Chunk->EdgeBoundaryVoxelCount = {}; + /* Chunk->DrawBoundingVoxels = {}; */ + /* Chunk->PointsToLeaveRemaining = {}; */ + /* Chunk->TriCount = {}; */ + /* Chunk->EdgeBoundaryVoxelCount = {}; */ Chunk->StandingSpots.At = Chunk->StandingSpots.Start; Chunk->Entities = {}; Chunk->Next = {}; - Chunk->DEBUG_OwnedByThread = {}; - - Clear(&Chunk->Meshes); - - Chunk->Flags = {}; -} - -inline b32 -IsFilled(voxel *Voxel) -{ - b32 Result = (Voxel->Flags & Voxel_Filled) == Voxel_Filled; + Chunk->Handles = {}; -#if BONSAI_INTERNAL - if (!Result) Assert( (Voxel->Flags&VoxelFaceMask) == 0); + Chunk->DimInChunks = {}; #endif - return Result; -} - -inline b32 -NotFilled(voxel *Voxel) -{ - b32 Result = !IsFilled(Voxel); - return Result; -} - -inline b32 -IsFilled( voxel *Voxels, voxel_position VoxelP, chunk_dimension Dim) -{ - s32 VoxelIndex = GetIndex(VoxelP, Dim); - b32 isFilled = IsSet(Voxels + VoxelIndex, Voxel_Filled); - return isFilled; -} - -inline b32 -NotFilled(voxel *Voxels, voxel_position VoxelP, chunk_dimension Dim) -{ - b32 Result = !IsFilled(Voxels, VoxelP, Dim); - return Result; } inline world_position diff --git a/src/engine/camera.cpp b/src/engine/camera.cpp index e09a51487..ca4ef2484 100644 --- a/src/engine/camera.cpp +++ b/src/engine/camera.cpp @@ -1,9 +1,56 @@ link_internal void UpdateCameraP(world *World, cp TargetViewP, camera *Camera) +{ +} + +link_inline v2 +GetMouseDelta(platform *Plat) +{ + r32 DPToWorldModifier = -0.001f; + v2 Result = Plat->MouseDP * DPToWorldModifier; + return Result; +} + +link_internal void +UpdateGameCamera( world *World, + v2 ScreenDim, + v2 MouseDelta, + r32 CameraZoomDelta, + cp TargetViewP, + camera *Camera, + r32 Dt ) { TIMED_FUNCTION(); + + // TODO(Jesse): Make these vary by DistanceFromTarget, such that the mouse feels the same amount of sensitive zoomed in as out. + Camera->TargetYaw += MouseDelta.x; + Camera->TargetPitch += MouseDelta.y; + Camera->TargetPitch = ClampBetween(0.0, Camera->TargetPitch, PI32); + + r32 t = 1.f; + if (Camera->Blend > 0.f && Dt > 0.f) + { + t = Min(1.f, Camera->Blend*Dt); + } + + Camera->Yaw = Lerp(t, Camera->Yaw, Camera->TargetYaw); + Camera->Pitch = Lerp(t, Camera->Pitch, Camera->TargetPitch); + + /* Camera->DistanceFromTarget += MouseDelta.y*Camera->DistanceFromTarget; */ + Camera->TargetDistanceFromTarget += CameraZoomDelta * Camera->DistanceFromTarget; + + Camera->DistanceFromTarget = Lerp(t, Camera->DistanceFromTarget, Camera->TargetDistanceFromTarget); + + Camera->DistanceFromTarget = ClampMin(Camera->DistanceFromTarget, Camera->Frust.nearClip); + Camera->DistanceFromTarget = ClampMax(Camera->DistanceFromTarget, Camera->Frust.farClip); + + Camera->TargetDistanceFromTarget = ClampMin(Camera->TargetDistanceFromTarget, Camera->Frust.nearClip); + Camera->TargetDistanceFromTarget = ClampMax(Camera->TargetDistanceFromTarget, Camera->Frust.farClip); + + // TODO(Jesse): Remove? if (Camera->DistanceFromTarget < 0.1f) { Camera->DistanceFromTarget = 0.1f; } + if (Camera->TargetDistanceFromTarget < 0.1f) { Camera->TargetDistanceFromTarget = 0.1f; } r32 Px = Sin(Camera->Yaw); r32 Py = Cos(Camera->Yaw); @@ -20,19 +67,31 @@ UpdateCameraP(world *World, cp TargetViewP, camera *Camera) Camera->RenderSpacePosition = GetRenderP(World->ChunkDim, Camera->CurrentP, Camera); + m4 View = ViewMatrix(World->ChunkDim, Camera); + m4 Proj = ProjectionMatrix(Camera, ScreenDim); + + Camera->ViewProjection = Proj * View; + Camera->InverseViewMatrix = Inverse(View); + Camera->InverseProjectionMatrix = Inverse(Proj); + + + + #if 1 // // Frustum computation // - v3 FrustLength = V3(0.0f, 0.0f, Camera->Frust.farClip); - v3 FarHeight = ( V3( 0.0f, ((Camera->Frust.farClip - Camera->Frust.nearClip)/Cos(Camera->Frust.FOV/2.0f)) * Sin(Camera->Frust.FOV/2.0f), 0.0f)); - v3 FarWidth = V3( FarHeight.y, 0.0f, 0.0f); + /* v3 FrustLength = V3(0.0f, 0.0f, Camera->Frust.farClip); */ + /* v3 FarHeight = ( V3( 0.0f, */ + /* ((Camera->Frust.farClip - Camera->Frust.nearClip)/Cos(Camera->Frust.FOV/2.0f)) * Sin(Camera->Frust.FOV/2.0f), */ + /* 0.0f)); */ + /* v3 FarWidth = V3( FarHeight.y, 0.0f, 0.0f); */ - v3 MaxMax = Normalize(FrustLength + FarHeight + FarWidth); - v3 MaxMin = Normalize(FrustLength + FarHeight - FarWidth); - v3 MinMax = Normalize(FrustLength - FarHeight + FarWidth); - v3 MinMin = Normalize(FrustLength - FarHeight - FarWidth); + /* v3 MaxMax = Normalize(FrustLength + FarHeight + FarWidth); */ + /* v3 MaxMin = Normalize(FrustLength + FarHeight - FarWidth); */ + /* v3 MinMax = Normalize(FrustLength - FarHeight + FarWidth); */ + /* v3 MinMin = Normalize(FrustLength - FarHeight - FarWidth); */ v3 Front = V3(0,0,1); v3 Target = Camera->Front; @@ -52,10 +111,10 @@ UpdateCameraP(world *World, cp TargetViewP, camera *Camera) /* MinMin = Normalize(Rotate(MinMin, GrossRotation)); */ /* MinMax = Normalize(Rotate(MinMax, GrossRotation)); */ - MaxMin = Normalize(Rotate(MaxMin, FinalRotation)); - MaxMax = Normalize(Rotate(MaxMax, FinalRotation)); - MinMin = Normalize(Rotate(MinMin, FinalRotation)); - MinMax = Normalize(Rotate(MinMax, FinalRotation)); + /* MaxMin = Normalize(Rotate(MaxMin, FinalRotation)); */ + /* MaxMax = Normalize(Rotate(MaxMax, FinalRotation)); */ + /* MinMin = Normalize(Rotate(MinMin, FinalRotation)); */ + /* MinMax = Normalize(Rotate(MinMax, FinalRotation)); */ #if DEBUG_DRAW_FRUSTUM_AT_ORIGIN { @@ -71,15 +130,35 @@ UpdateCameraP(world *World, cp TargetViewP, camera *Camera) v3 CameraSimP = GetSimSpaceP(World, Camera->CurrentP); - plane Top(CameraSimP, Normalize(Cross(MaxMax, MaxMin))); - plane Bot(CameraSimP, Normalize(Cross(MinMin, MinMax))); - plane Left(CameraSimP, Normalize(Cross(MinMax, MaxMax))); - plane Right(CameraSimP, Normalize(Cross(MaxMin, MinMin))); +#if 0 + plane Top = Plane(CameraSimP, Normalize(Cross(MaxMax, MaxMin))); + plane Bot = Plane(CameraSimP, Normalize(Cross(MinMin, MinMax))); + plane Left = Plane(CameraSimP, Normalize(Cross(MinMax, MaxMax))); + plane Right = Plane(CameraSimP, Normalize(Cross(MaxMin, MinMin))); Camera->Frust.Top = Top; Camera->Frust.Bot = Bot; Camera->Frust.Left = Left; Camera->Frust.Right = Right; +#else + auto zNear = Camera->Frust.nearClip; + auto zFar = Camera->Frust.farClip; + auto fovY = Camera->Frust.FOV; + auto aspect = ScreenDim.x/ScreenDim.y; + + f32 halfVSide = zFar * Tan(Rads(fovY*0.5f)); + f32 halfHSide = halfVSide * aspect; + v3 frontMultFar = zFar * Camera->Front; + + auto SimP = GetSimSpaceP(World, Camera->CurrentP); + + /* Camera->Frust.Near = Plane( Camera->RenderSpacePosition + zNear * Camera->Front, Camera->Front ); */ + /* Camera->Frust.Far = Plane( Camera->RenderSpacePosition + frontMultFar, -1.f*Camera->Front ); */ + Camera->Frust.Right = Plane( SimP, Normalize(Cross(frontMultFar - Camera->Right * halfHSide, Camera->Up)) ); + Camera->Frust.Left = Plane( SimP, Normalize(Cross(Camera->Up,frontMultFar + Camera->Right * halfHSide)) ); + Camera->Frust.Top = Plane( SimP, Normalize(Cross(Camera->Right, frontMultFar - Camera->Up * halfVSide)) ); + Camera->Frust.Bottom = Plane( SimP, Normalize(Cross(frontMultFar + Camera->Up * halfVSide, Camera->Right)) ); +#endif #endif @@ -91,52 +170,13 @@ UpdateCameraP(world *World, cp TargetViewP, camera *Camera) return; } -link_inline v2 -GetMouseDelta(platform *Plat) -{ - r32 DPToWorldModifier = -0.001f; - v2 Result = Plat->MouseDP * DPToWorldModifier; - return Result; -} - -link_internal void -UpdateGameCamera( world *World, - v2 MouseDelta, - r32 CameraZoomDelta, - cp TargetViewP, - camera *Camera, - r32 Dt ) -{ - // TODO(Jesse): Make these vary by DistanceFromTarget, such that the mouse feels the same amount of sensitive zoomed in as out. - Camera->TargetYaw += MouseDelta.x; - Camera->TargetPitch += MouseDelta.y; - Camera->TargetPitch = ClampBetween(0.0, Camera->TargetPitch, PI32); - - r32 t = 1.f; - if (Camera->Blend > 0.f && Dt > 0.f) - { - t = Min(1.f, Camera->Blend*Dt); - } - - Camera->Yaw = Lerp(t, Camera->Yaw, Camera->TargetYaw); - Camera->Pitch = Lerp(t, Camera->Pitch, Camera->TargetPitch); - - /* Camera->DistanceFromTarget += MouseDelta.y*Camera->DistanceFromTarget; */ - Camera->TargetDistanceFromTarget += CameraZoomDelta * Camera->DistanceFromTarget; - - Camera->DistanceFromTarget = Lerp(t, Camera->DistanceFromTarget, Camera->TargetDistanceFromTarget); - Camera->DistanceFromTarget = ClampMin(Camera->DistanceFromTarget, Camera->Frust.nearClip); - Camera->DistanceFromTarget = ClampMax(Camera->DistanceFromTarget, Camera->Frust.farClip); - - UpdateCameraP(World, TargetViewP, Camera); -} - link_internal void SetCameraTarget(v3 Target, camera *Camera) { - world *World = GetWorld(); - UpdateGameCamera(World, {}, {}, Canonical_Position(World->ChunkDim, Target, {}), Camera, 0.33f); + engine_resources *Engine = GetEngineResources(); + world *World = Engine->World; + UpdateGameCamera(World, Engine->Stdlib.Plat.ScreenDim, {}, {}, Canonical_Position(World->ChunkDim, Target, {}), Camera, 0.33f); } link_internal void @@ -149,43 +189,49 @@ UpdateGameCamera( world *World, b32 DoPositionDelta, b32 DoZoomDelta ) { + engine_resources *Engine = GetEngineResources(); + v2 UpdateMouseDelta = {}; f32 CameraZoomDelta = {}; if (Input) // TODO(Jesse): Assert here ..? { if (DoPositionDelta) { - UpdateMouseDelta = Input->LMB.Pressed ? MouseDelta : V2(0); + UpdateMouseDelta = Input->RMB.Pressed ? MouseDelta : V2(0); } if (DoZoomDelta) { CameraZoomDelta = -1.f*Input->MouseWheelDelta/500.f; - if (Input->RMB.Pressed) { CameraZoomDelta += MouseDelta.y; } + /* if (Input->RMB.Pressed) { CameraZoomDelta += MouseDelta.y; } */ } } - UpdateGameCamera(World, UpdateMouseDelta, CameraZoomDelta, NewTarget, Camera, Dt); + UpdateGameCamera(World, Engine->Stdlib.Plat.ScreenDim, UpdateMouseDelta, CameraZoomDelta, NewTarget, Camera, Dt); } link_internal void StandardCamera(camera* Camera, f32 FarClip, f32 DistanceFromTarget, f32 Blend) { - Clear(Camera); + *Camera = {}; Camera->Blend = Blend; Camera->Frust.farClip = FarClip; - Camera->Frust.nearClip = 1.0f; - Camera->Frust.width = 30.0f; - Camera->Frust.FOV = 45.0f; + Camera->Frust.nearClip = 0.05f; + + // Someone already set FOV .. probably when deserializing stored runtime settings. + if (Camera->Frust.FOV == 0.f) + { + Camera->Frust.FOV = 150.0f; + } Camera->Up = WORLD_Z; Camera->Right = WORLD_X; Camera->TargetPitch = PI32 - (PI32*0.25f); - Camera->TargetYaw = -PI32*0.15f; + Camera->TargetYaw = PI32*0.125f; Camera->TargetDistanceFromTarget = DistanceFromTarget; @@ -201,30 +247,47 @@ IsInFrustum(world *World, camera *Camera, canonical_position P) v3 TestP = GetSimSpaceP(World, P); - // This says if we're on the back-side of the plane by more than the dim of a - // world chunk, we're outside the frustum - /* Result &= (DistanceToPlane(&Camera->Frust.Top, TestP) < -1*World->ChunkDim.y); */ - /* Result &= (DistanceToPlane(&Camera->Frust.Bot, TestP) < -1*World->ChunkDim.y); */ - /* Result &= (DistanceToPlane(&Camera->Frust.Left, TestP) < -1*World->ChunkDim.x); */ - /* Result &= (DistanceToPlane(&Camera->Frust.Right, TestP) < -1*World->ChunkDim.x); */ + Result &= (DistanceToPlane(&Camera->Frust.Top, TestP) > 0.f); + Result &= (DistanceToPlane(&Camera->Frust.Bottom, TestP) > 0.f); + Result &= (DistanceToPlane(&Camera->Frust.Left, TestP) > 0.f); + Result &= (DistanceToPlane(&Camera->Frust.Right, TestP) > 0.f); - Result &= (DistanceToPlane(&Camera->Frust.Top, TestP) > 0); - Result &= (DistanceToPlane(&Camera->Frust.Bot, TestP) > 0); - Result &= (DistanceToPlane(&Camera->Frust.Left, TestP) > 0); - Result &= (DistanceToPlane(&Camera->Frust.Right, TestP) > 0); + return Result; +} +link_internal f32 +SignedDistanceToFrustum( camera *Camera, v3 P) +{ + f32 Result = (DistanceToPlane(&Camera->Frust.Top, P)); + Result = Max(Result, DistanceToPlane(&Camera->Frust.Bottom, P)); + Result = Max(Result, DistanceToPlane(&Camera->Frust.Left, P)); + Result = Max(Result, DistanceToPlane(&Camera->Frust.Right, P)); return Result; } link_internal bool IsInFrustum( world *World, camera *Camera, world_chunk *Chunk ) { - v3 ChunkMid = World->ChunkDim/2.0f; - canonical_position P1 = Canonical_Position(ChunkMid, Chunk->WorldP ); - bool Result = IsInFrustum(World, Camera, P1); + Assert(Chunk->Dim == V3i(64)); + v3 Dim = V3(Chunk->Dim)*V3(Chunk->DimInChunks); + r32 Radius = Length(Dim)/2.f; + v3 Center = GetSimSpaceP(World, Chunk) + Radius; + b32 Result = SignedDistanceToFrustum(Camera, Center) < (1.2f*Radius); + /* b32 Result = True; */ return Result; } +link_internal bool +IsInFrustum( world *World, camera *Camera, octree_node *Node ) +{ + r32 Radius = Length(V3(64)*V3(Node->Resolution))/2.f; + v3 Center = GetSimSpaceP(World, Node->WorldP) + Radius; + /* b32 Result = SignedDistanceToFrustum(Camera, Center) < Radius; */ + b32 Result = SignedDistanceToFrustum(Camera, Center) < (1.2f*Radius); + return Result; +} + + link_internal v3 Unproject(v2 ScreenP, r32 ClipZDepth, v2 ScreenDim, m4 *InvViewProj) { @@ -246,33 +309,34 @@ Unproject(v2 ScreenP, r32 ClipZDepth, v2 ScreenDim, m4 *InvViewProj) // // NOTE(Jesse): Returns a sim-space ray link_internal maybe_ray -ComputeRayFromCursor(engine_resources *Engine, m4* ViewProjection, camera *Camera, v3i WorldChunkDim) +ComputeCameraSpaceRayFromCursor(engine_resources *Engine, camera *Camera, v3i WorldChunkDim) { platform *Plat = &Engine->Stdlib.Plat; world *World = Engine->World; maybe_ray Result = {}; - m4 InverseViewProjection = {}; - b32 Inverted = Inverse((r32*)ViewProjection, (r32*)&InverseViewProjection); - if (Inverted) + m4 InverseViewProjection; + if (Inverse(&Camera->ViewProjection.E[0][0], &InverseViewProjection.E[0][0])) { v3 MouseMinWorldP = Unproject( Plat->MouseP, - 0.0f, + 0.1f, Plat->ScreenDim, - &InverseViewProjection); + &InverseViewProjection); v3 MouseMaxWorldP = Unproject( Plat->MouseP, - 1.0f, + 0.5f, Plat->ScreenDim, - &InverseViewProjection); + &InverseViewProjection); v3 RayDirection = Normalize(MouseMaxWorldP - MouseMinWorldP); /* DEBUG_HighlightVoxel(Engine, Camera->ViewingTarget, RED); */ /* v3 CameraOffset = Camera->ViewingTarget.Offset + V3(Camera->ViewingTarget.WorldP * WorldChunkDim); */ - v3 CameraOffset = GetSimSpaceP(World, ComputeTarget(Camera)); - /* v3 CameraOffset = V3(0); */ + /* v3 CameraOffset = GetSimSpaceP(World, ComputeTarget(Camera)); */ + /* v3 CameraOffset = GetSimSpaceP(World, Camera->CurrentP); */ + /* v3 CameraOffset = Camera->RenderSpacePosition; */ + v3 CameraOffset = V3(0); Result.Ray = { .Origin = MouseMinWorldP + CameraOffset, .Dir = RayDirection }; Result.Tag = Maybe_Yes; } diff --git a/src/engine/camera.h b/src/engine/camera.h index 24c211e6d..808c6f305 100644 --- a/src/engine/camera.h +++ b/src/engine/camera.h @@ -1,38 +1,37 @@ struct plane +poof(@do_editor_ui) { - v3 P; v3 Normal; - r32 d; - - plane( v3 P_in, v3 Normal_in ) - { - this->P = P_in; - this->Normal = Normal_in; - - this->d = -1.0f * (Normal.x*P.x + Normal.y*P.y + Normal.z*P.z); - - Assert(Normal.x*P.x + Normal.y*P.y + Normal.z*P.z + this->d == 0); - } - - plane() {} + f32 DistanceToOrigin; }; +link_internal plane +Plane( v3 Point, v3 Normal ) +{ + plane Reuslt = { Normal, Dot(Normal, Point) }; + return Reuslt; +} + struct frustum +poof(@do_editor_ui) { f32 farClip; f32 nearClip; - f32 width; f32 FOV; plane Top; - plane Bot; + plane Bottom; plane Left; plane Right; }; struct entity; -struct camera poof(@version(2)) +struct camera +poof( + @version(2) + @do_editor_ui + ) { frustum Frust; @@ -51,12 +50,17 @@ struct camera poof(@version(2)) r32 TargetDistanceFromTarget; r32 Blend; // How fast the camera interpolates. 0 is instant, 0.1f is verrry slow + r32 Speed = 8.0f; // How fast the camera ghost moves v3 Front; v3 Right; v3 Up; entity_id GhostId; + + m4 ViewProjection; + m4 InverseViewMatrix; + m4 InverseProjectionMatrix; }; struct camera_1 @@ -136,6 +140,9 @@ GetCameraRelativeInput(hotkeys *Hotkeys, camera *Camera) inline r32 DistanceToPlane(plane *Plane, v3 P) { + // https://learnopengl.com/Guest-Articles/2021/Scene/Frustum-Culling + r32 Result = Dot(Plane->Normal, P) - Plane->DistanceToOrigin; +#if 0 r32 x = Plane->P.x; r32 y = Plane->P.y; r32 z = Plane->P.z; @@ -147,8 +154,9 @@ DistanceToPlane(plane *Plane, v3 P) r32 d = Plane->d; Assert(a*x + b*y + c*z + d == 0); - r32 Distance = a*P.x + b*P.y + c*P.z + d; - return Distance; + r32 Result = a*P.x + b*P.y + c*P.z + d; +#endif + return Result; } link_internal v3 diff --git a/src/engine/canonical_position.cpp b/src/engine/canonical_position.cpp index 986bd14ed..b01d58abe 100644 --- a/src/engine/canonical_position.cpp +++ b/src/engine/canonical_position.cpp @@ -33,6 +33,33 @@ Canonicalize( world *World, canonical_position *P) *P = Canonicalize(World->ChunkDim, P->Offset, P->WorldP); } +// Canonical add +link_internal cp +CAdd(world *World, cp P1, cp P2) +{ + cp Result = { + P1.Offset + P2.Offset, + P1.WorldP + P2.WorldP + }; + + Canonicalize(World, &Result); + return Result; +} + +// Canonical add +link_internal cp +CSub(world *World, cp P1, cp P2) +{ + cp Result = { + P1.Offset - P2.Offset, + P1.WorldP - P2.WorldP + }; + + Canonicalize(World, &Result); + return Result; +} + + link_internal cp SimSpaceToCanonical(world *World, v3 P) { @@ -40,6 +67,15 @@ SimSpaceToCanonical(world *World, v3 P) return Result; } +link_internal rect3cp +SimSpaceToCanonical(world *World, rect3 *Rect) +{ + rect3cp Result = {}; + Result.Min = SimSpaceToCanonical(World, Rect->Min); + Result.Max = SimSpaceToCanonical(World, Rect->Max); + return Result; +} + link_internal rect3cp SimSpaceToCanonical(world *World, rect3i *Rect) { @@ -49,3 +85,10 @@ SimSpaceToCanonical(world *World, rect3i *Rect) return Result; } +link_internal cp +GetCenter(world *World, rect3cp *Rect) +{ + cp Rad = GetRadius(Rect); + cp Result = CAdd(World, Rect->Min, Rad); + return Result; +} diff --git a/src/engine/canonical_position.h b/src/engine/canonical_position.h index 0523dd716..8bc4391e5 100644 --- a/src/engine/canonical_position.h +++ b/src/engine/canonical_position.h @@ -1,3 +1,4 @@ +struct world; struct canonical_position { @@ -144,10 +145,10 @@ Min(canonical_position P1, canonical_position P2) } #endif -inline canonical_position -operator-(canonical_position A, v3 B) +inline cp +operator-(cp A, v3 B) { - canonical_position Result = A; + cp Result = A; Result.Offset.x = A.Offset.x - B.x; Result.Offset.y = A.Offset.y - B.y; @@ -156,10 +157,10 @@ operator-(canonical_position A, v3 B) return Result; } -inline canonical_position -operator+(canonical_position A, v3 B) +inline cp +operator+(cp A, v3 B) { - canonical_position Result = A; + cp Result = A; Result.Offset.x = A.Offset.x + B.x; Result.Offset.y = A.Offset.y + B.y; @@ -168,32 +169,51 @@ operator+(canonical_position A, v3 B) return Result; } -inline canonical_position& -operator+=(canonical_position& A, float B) +inline cp +operator/(cp A, s32 Int) +{ + cp Result = A; + Result.Offset /= f32(Int); + Result.WorldP /= Int; + return Result; +} + + +inline cp& +operator+=(cp& A, float B) { A.Offset += B; return(A); } -inline canonical_position& -operator+=(canonical_position& A, v3 B) +inline cp& +operator+=(cp& A, v3 B) { A.Offset += B; return(A); } -inline canonical_position& -operator+=(canonical_position& A, canonical_position B) +inline cp& +operator+=(cp& A, cp B) { A.Offset += B.Offset; A.WorldP += B.WorldP; return(A); } -inline canonical_position -operator-(canonical_position P1, canonical_position P2) +inline cp +operator+(cp P1, cp P2) { - canonical_position Result; + cp Result; + Result.Offset = P1.Offset + P2.Offset; + Result.WorldP = P1.WorldP + P2.WorldP; + return Result; +} + +inline cp +operator-(cp P1, cp P2) +{ + cp Result; Result.Offset = P1.Offset - P2.Offset; Result.WorldP = P1.WorldP - P2.WorldP; return Result; @@ -202,34 +222,39 @@ operator-(canonical_position P1, canonical_position P2) inline b32 operator>(cp P1, cp P2) { - b32 Result = (P1.WorldP > P2.WorldP) && (P1.Offset > P2.Offset); + b32 Result = (P1.WorldP > P2.WorldP) || + (P1.WorldP == P2.WorldP && (P1.Offset > P2.Offset)); return Result; } inline b32 operator<(cp P1, cp P2) { - b32 Result = (P1.WorldP < P2.WorldP) && (P1.Offset < P2.Offset); + b32 Result = (P1.WorldP < P2.WorldP) || + (P1.WorldP == P2.WorldP && (P1.Offset < P2.Offset)); return Result; } inline b32 operator>=(cp P1, cp P2) { - b32 Result = (P1.WorldP >= P2.WorldP) && (P1.Offset >= P2.Offset); + b32 Result = (P1.WorldP >= P2.WorldP) || + (P1.WorldP == P2.WorldP && (P1.Offset >= P2.Offset)); return Result; } inline b32 operator<=(cp P1, cp P2) { - b32 Result = (P1.WorldP <= P2.WorldP) && (P1.Offset <= P2.Offset); + b32 Result = (P1.WorldP <= P2.WorldP) || + (P1.WorldP == P2.WorldP && (P1.Offset <= P2.Offset)); return Result; } + struct rect3cp { cp Min; @@ -255,6 +280,29 @@ Rect3CP(rect3 *Rect) return Result; } +link_internal rect3cp +InvertedInfinityRectangle_rect3cp() +{ + rect3cp Result = { + .Min = Canonical_Position(V3( 1024.f), V3i(s32_MAX)), + .Max = Canonical_Position(V3(-1024.f), V3i(s32_MIN)), + }; + return Result; +} + + +/* poof(gen_rect_helpers(rect3cp, cp)) */ +/* #include */ + +link_internal cp +GetRadius(rect3cp *Rect) +{ + cp Dim = Rect->Max - Rect->Min; + cp Result = Dim/2; + return Result; +} + + link_internal rect3cp RectMinMax(cp Min, cp Max) { @@ -269,9 +317,11 @@ RectMinDim(v3i WorldChunkDim, cp Min, v3 Dim) return Result; } -struct world; +link_internal cp +GetCenter(world *World, rect3cp *Rect); + link_internal v3 -GetSimSpaceP(world *World, canonical_position P); +GetSimSpaceP(world *World, cp P); link_internal v3 GetDim(world *World, rect3cp Rect) @@ -289,6 +339,14 @@ IsInside(cp P, rect3cp Rect) return Result; } +link_internal b32 +Contains(rect3cp Rect, cp P) +{ + b32 Result = (P >= Rect.Min && P < Rect.Max); + return Result; +} + + link_internal cp Max(cp P0, cp P1) { @@ -350,13 +408,20 @@ GetSimSpaceRect(world *World, rect3cp Rect) } link_internal rect3 -GetSimSpaceAABB(world *World, rect3cp Rect) +GetSimSpaceAABB(world *World, rect3cp *Rect) { - v3 Min = GetSimSpaceP(World, Rect.Min); - v3 Max = GetSimSpaceP(World, Rect.Max); + v3 Min = GetSimSpaceP(World, Rect->Min); + v3 Max = GetSimSpaceP(World, Rect->Max); rect3 Result = RectMinMax(Min, Max); return Result; } +link_internal rect3 +GetSimSpaceAABB(world *World, rect3cp Rect) +{ + rect3 Result = GetSimSpaceAABB(World, &Rect); + return Result; +} + link_internal cp SimSpaceToCanonical( world *World, v3 P ); diff --git a/src/engine/chunk.cpp b/src/engine/chunk.cpp index 78956e000..db1e84255 100644 --- a/src/engine/chunk.cpp +++ b/src/engine/chunk.cpp @@ -6,22 +6,15 @@ AllocateChunkData(memory_arena *Storage, chunk_dimension Dim) // because multiple threads go to town on these memory blocks chunk_data *Result = AllocateAlignedProtection(chunk_data, Storage, 1, CACHE_LINE_SIZE, false); - s32 Vol = Volume(Dim); - if (Vol) { Result->Voxels = AllocateAlignedProtection(voxel, Storage , Vol, CACHE_LINE_SIZE, false); } - if (Vol) { Result->VoxelLighting = AllocateAlignedProtection(voxel_lighting, Storage , Vol, CACHE_LINE_SIZE, false); } - - /* ZeroChunk(Result); */ - - return Result; -} - -voxel * -AllocateVoxels(memory_arena *Storage, chunk_dimension Dim) -{ - voxel *Result = {}; - - s32 Vol = Volume(Dim); - if (Vol) { Result = AllocateAlignedProtection(voxel, Storage , Vol, CACHE_LINE_SIZE, false); } + s32 VoxCount = Volume(Dim); + if (VoxCount) + { + s32 OccupancyCount = (VoxCount+63) / 64; // Add seven so we round up when we divide if there's an extra one (or several) + Result->Occupancy = AllocateAlignedProtection( u64, Storage , OccupancyCount, CACHE_LINE_SIZE, false); + Result->FaceMasks = AllocateAlignedProtection( u64, Storage , 6*OccupancyCount, CACHE_LINE_SIZE, false); + /* Result->Voxels = AllocateAlignedProtection( voxel, Storage , VoxCount, CACHE_LINE_SIZE, false); */ + /* Result->VoxelLighting = AllocateAlignedProtection(voxel_lighting, Storage , VoxCount, CACHE_LINE_SIZE, false); */ + } return Result; } @@ -31,19 +24,33 @@ IsFilledInChunk( world_chunk *Chunk, voxel_position VoxelP, chunk_dimension Dim) { b32 isFilled = True; - if (Chunk && ( IsSet(Chunk, Chunk_VoxelsInitialized) )) + if (Chunk) { s32 i = GetIndex(VoxelP, Dim); Assert(i > -1); Assert(i < Volume(Dim)); - isFilled = IsSet(&Chunk->Voxels[i], Voxel_Filled); + isFilled = b32(GetOccupancyBit(Chunk, i)); } return isFilled; } +inline b32 +NotFilled(u64 *Occupancy, s32 Index) +{ + b32 Result = b32(GetOccupancyBit(Occupancy, Index)) == 0; + return Result; +} + +inline b32 +NotFilled(u64 *Occupancy, v3i P, v3i Dim) +{ + b32 Result = b32(GetOccupancyBit(Occupancy, GetIndex(P, Dim))) == 0; + return Result; +} + inline b32 NotFilledInChunk( world_chunk *Chunk, voxel_position VoxelP, chunk_dimension Dim) { @@ -52,19 +59,23 @@ NotFilledInChunk( world_chunk *Chunk, voxel_position VoxelP, chunk_dimension Dim } inline b32 -NotFilledInChunk( world_chunk *Chunk, s32 Index) +NotFilledInChunk(world_chunk *Chunk, s32 Index) { Assert(Chunk); b32 NotFilled = False; + NotImplemented; +#if 0 if (Index > -1) { NotFilled = !IsSet(&Chunk->Voxels[Index], Voxel_Filled); } +#endif return NotFilled; } +#if 0 void FillChunk(world_chunk *Chunk, chunk_dimension Dim, u8 ColorIndex = MCV_BLACK) { @@ -87,3 +98,4 @@ FillChunk(world_chunk *Chunk, chunk_dimension Dim, u8 ColorIndex = MCV_BLACK) SetFlag(Chunk, Chunk_VoxelsInitialized); } +#endif diff --git a/src/engine/color.h b/src/engine/color.h index 455b53666..d9fccf2f5 100644 --- a/src/engine/color.h +++ b/src/engine/color.h @@ -288,6 +288,6 @@ link_internal u16 MagicaVoxelDefaultPaletteToPackedHSV(u16 MagicaVoxelIndex) { v3 HSV = MagicaVoxelDefaultPaletteToHSV(MagicaVoxelIndex); - u16 Result = PackHSVColor(HSV); + u16 Result = PackV3_16b(HSV); return Result; } diff --git a/src/engine/debug.cpp b/src/engine/debug.cpp index c0425f7f8..b16568038 100644 --- a/src/engine/debug.cpp +++ b/src/engine/debug.cpp @@ -1,226 +1,4 @@ -link_internal void -DoLevelWindow(engine_resources *Engine) -{ - UNPACK_ENGINE_RESOURCES(Engine); - - local_persist window_layout Window = WindowLayout("Level"); - - thread_local_state *Thread = GetThreadLocalState(ThreadLocal_ThreadIndex); - - PushWindowStart(Ui, &Window); - PushTableStart(Ui); - if (Button(Ui, CSz("Export Level"), UiId(&Window, "export_level_button", 0ull))) - { - u8_cursor_block_array OutputStream = BeginSerialization(); - - u32 ChunkCount = 0; - RangeIterator(HashIndex, s32(World->HashSize)) - { - if (World->ChunkHash[HashIndex]) - { - ++ChunkCount; - } - } - - level_header Header = {}; - Header.ChunkCount = ChunkCount; - - Header.WorldFlags = Cast(u32, World->Flags); - Header.WorldCenter = World->Center; - Header.VisibleRegion = World->VisibleRegion; - Header.Camera = *Camera; - - Header.RenderSettings = Graphics->Settings; - - u32 EntityCount = 0; - RangeIterator(EntityIndex, TOTAL_ENTITY_COUNT) - { - entity *E = EntityTable[EntityIndex]; - if (Spawned(E)) { ++EntityCount; } - } - Header.EntityCount = EntityCount; - - - Serialize(&OutputStream, &Header); - - u64 Delimeter = LEVEL_FILE_DEBUG_OBJECT_DELIM; - RangeIterator(HashIndex, s32(World->HashSize)) - { - if (world_chunk *Chunk = World->ChunkHash[HashIndex]) - { - SerializeChunk(Chunk, &OutputStream); - } - } - - Ensure(Serialize(&OutputStream, &Delimeter)); - - RangeIterator(EntityIndex, TOTAL_ENTITY_COUNT) - { - entity *E = EntityTable[EntityIndex]; - if (Spawned(E)) - { - Serialize(&OutputStream, E); - } - } - - v3_cursor *Palette = GetColorPalette(); - Serialize(&OutputStream, Palette); - - const char *Filename = "../bonsai_levels/test.level"; - if (FinalizeSerialization(&OutputStream, Filename) == False) - { - SoftError("Could not serialize (%s).", Filename); - } - } - PushTableEnd(Ui); - PushNewRow(Ui); - - PushTableStart(Ui); - maybe_file_traversal_node ClickedNode = PlatformTraverseDirectoryTreeUnordered(CSz("../bonsai_levels"), EngineDrawFileNodesHelper, Cast(u64, &Window)); - PushTableEnd(Ui); - PushNewRow(Ui); - - // Import - if (ClickedNode.Tag) - { - cs Filename = Concat(ClickedNode.Value.Dir, CSz("/"), ClickedNode.Value.Name, GetTranArena()); - - u8_cursor LevelBytes = BeginDeserialization(Filename, GetTranArena()); - if (LevelBytes.Start) - { - level_header LevelHeader = {}; - - - if (Deserialize(&LevelBytes, &LevelHeader, Thread->PermMemory)) - { - { - engine_settings *EngineSettings = &GetEngineResources()->Settings; - LevelHeader.RenderSettings.ApplicationResolution = V2(GetApplicationResolution(EngineSettings)); - LevelHeader.RenderSettings.ShadowMapResolution = V2(GetShadowMapResolution(EngineSettings)); - LevelHeader.RenderSettings.LuminanceMapResolution = V2(GetLuminanceMapResolution(EngineSettings)); - - LevelHeader.RenderSettings.iApplicationResolution = GetApplicationResolution(EngineSettings); - LevelHeader.RenderSettings.iShadowMapResolution = GetShadowMapResolution(EngineSettings); - LevelHeader.RenderSettings.iLuminanceMapResolution = GetLuminanceMapResolution(EngineSettings); - } - - SignalAndWaitForWorkers(&Plat->WorkerThreadsSuspendFutex); - - SoftResetEngine(Engine); - - /* World->Flags = Cast(world_flag, LevelHeader.WorldFlags); */ - World->Center = LevelHeader.WorldCenter; - - maybe_bonsai_type_info MaybeLevelHeaderTypeInfo = GetByName(&Global_SerializeTypeTable, CSz("level_header")); - if (MaybeLevelHeaderTypeInfo.Tag) - { - if (MaybeLevelHeaderTypeInfo.Value.Version > 2) - { - Graphics->Settings = LevelHeader.RenderSettings; - } - } - - *Graphics->Camera = LevelHeader.Camera; - /* World->VisibleRegion = LevelHeader.VisibleRegion; */ - - s32 ChunkCount = Cast(s32, LevelHeader.ChunkCount); - /* Info("ChunksFreed (%u) ChunksLoaded (%u)", ChunksFreed, ChunkCount); */ - - RangeIterator(ChunkIndex, ChunkCount) - { - world_chunk *Chunk = GetFreeWorldChunk(World); - DeserializeChunk(&LevelBytes, Chunk, World->ChunkMemory); - - if (IsInsideVisibleRegion(World, Chunk->WorldP)) - { -#if 0 - if (Editor->Flags & LevelEditorFlags_RecomputeStandingSpotsOnLevelLoad) - { - Chunk->StandingSpots.At = Chunk->StandingSpots.Start; - Flags = ChunkInitFlag_ComputeStandingSpots; - } -#endif - - InsertChunkIntoWorld(World, Chunk); - } - } - - u64 Delimeter = LEVEL_FILE_DEBUG_OBJECT_DELIM; - Ensure(Read_u64(&LevelBytes) == Delimeter); - -#if 1 - - b32 Error = False; - u32 EntityCount = LevelHeader.EntityCount; - RangeIterator_t(u32, EntityIndex, EntityCount) - { - entity *E = EntityTable[EntityIndex]; - if (Deserialize(&LevelBytes, E, Thread->PermMemory) == False) - { - SoftError("Could not deserialize entity (%d), bailing.", EntityIndex); - Error = True; - break; - } - E->Id.Index = EntityIndex; // NOTE(Jesse): Hack.. entities got saved out with 0 indexes.. - } - - if (Error == False) - { - v3_cursor *Palette = GetColorPalette(); - Palette->At = Palette->Start; - Deserialize(&LevelBytes, Palette, Thread->PermMemory); - Assert(LevelBytes.At == LevelBytes.End); - - b32 NormalizePalette = False; - RangeIterator_t(umm, ColorIndex, (umm)(Palette->At-Palette->Start)) - { - v3 *C = Palette->Start+ColorIndex; - - // If any components are > 1.f we must have loaded a palette with values in the 0-255 range - if (C->E[0] > 1.f || C->E[1] > 1.f || C->E[2] > 1.f) { NormalizePalette = True; break; } - } - - if (NormalizePalette) - { - RangeIterator_t(umm, ColorIndex, (umm)(Palette->At-Palette->Start)) - { - v3 *C = Palette->Start+ColorIndex; - *C /= 255.f; - Assert (C->E[0] <= 1.f && C->E[1] <= 1.f && C->E[2] <= 1.f); - } - } - } - - - RangeIterator_t(u32, ChunkIndex, World->HashSize) - { - if (world_chunk *Chunk = World->ChunkHash[ChunkIndex]) - { - if (MaybeLevelHeaderTypeInfo.Value.Version < 4) - { - MarshalMagicaVoxelEncodedColors(Chunk->Voxels, Chunk->Voxels, Chunk->Dim); - } - - chunk_init_flags Flags = ChunkInitFlag_Noop; - QueueChunkForMeshRebuild(&GetEngineResources()->Stdlib.Plat.LowPriority, Chunk, Flags); - } - } - -#endif - - Assert(ThreadLocal_ThreadIndex == 0); - if (Engine->GameApi.OnLibraryLoad) { Engine->GameApi.OnLibraryLoad(Engine, GetThreadLocalState(ThreadLocal_ThreadIndex)); } - - UnsignalFutex(&Plat->WorkerThreadsSuspendFutex); - } - } - FinalizeDeserialization(&LevelBytes); - - } - PushWindowEnd(Ui, &Window); -} - link_internal void DoEntityWindow(engine_resources *Engine) { @@ -228,19 +6,20 @@ DoEntityWindow(engine_resources *Engine) #if 1 { - local_persist window_layout EntityWindow = WindowLayout("All Entities"); + window_layout *EntityWindow = GetOrCreateWindow(Ui, "All Entities"); - PushWindowStart(Ui, &EntityWindow); + PushWindowStart(Ui, EntityWindow); PushTableStart(Ui); RangeIterator(EntityIndex, TOTAL_ENTITY_COUNT) { entity *Entity = EntityTable[EntityIndex]; - DoEditorUi(Ui, &EntityWindow, Entity, FSz("(%d) (%S) (%S)", EntityIndex, ToString(Entity->State), Entity->AssetId.FileNode.Name) ); + cs Label = FSz("(%d) (%S) (%S)", EntityIndex, ToString(Entity->State), Entity->AssetId.FileNode.Name); + DoEditorUi(Ui, EntityWindow, Entity, Label, u32(Hash(EntityWindow)) ); } PushTableEnd(Ui); - PushWindowEnd(Ui, &EntityWindow); + PushWindowEnd(Ui, EntityWindow); } #endif @@ -268,16 +47,17 @@ DoEntityWindow(engine_resources *Engine) { DrawEntityCollisionVolume(SelectedEntity, &GpuMap->Buffer, Graphics, World->ChunkDim, RGB_WHITE); - local_persist window_layout EntityWindow = WindowLayout("Entity", WindowLayoutFlag_Align_Right); + window_layout *EntityWindow = GetOrCreateWindow(Ui, "Entity Details", WindowLayoutFlag_Align_Right); - PushWindowStart(Ui, &EntityWindow); + PushWindowStart(Ui, EntityWindow); PushTableStart(Ui); - DoEditorUi(Ui, &EntityWindow, SelectedEntity, FSz("SelectedEntity (%d)", SelectedEntity->Id.Index)); + DoEditorUi(Ui, EntityWindow, SelectedEntity, FSz("SelectedEntity (%d)", SelectedEntity->Id.Index), u32(Hash(EntityWindow)) ); PushNewRow(Ui); PushTableEnd(Ui); - PushWindowEnd(Ui, &EntityWindow); + PushWindowEnd(Ui, EntityWindow); +#if 0 aabb EntityAABB = GetSimSpaceAABB(World, SelectedEntity); if (Engine->MaybeMouseRay.Tag) @@ -326,6 +106,7 @@ DoEntityWindow(engine_resources *Engine) } } +#endif } if (Input->Delete.Clicked && Engine->HoverEntity.Tag) { Unspawn(Engine->HoverEntity.Value); } @@ -375,18 +156,24 @@ AllocateAssetThumbnail(platform *Plat, asset_thumbnail_block_array *AssetThumbna asset_thumbnail BlankThumb = {}; asset_thumbnail *Thumb = Push(AssetThumbnails, &BlankThumb); - MakeTexture_RGBA_Async(&Plat->RenderQ, &Thumb->Texture, ThumbnailDim, (u32*)0, CSz("Thumbnail")); + MakeTexture_RGBA_Async(&Plat->LoRenderQ, &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) +RenderMeshPreviewToTextureAndInteractWithThumb(engine_resources *Engine, window_layout *Window, asset_thumbnail *Thumb, gpu_mapped_element_buffer *Mesh, v3 Dim, b32 Selected) { UNPACK_ENGINE_RESOURCES(Engine); - SyncGpuBuffersAsync(Engine, Meshes); +#if 1 + NotImplemented; + return {}; +#else + // TODO(Jesse): Do we still do this here? + NotImplemented; + /* SyncGpuBuffersAsync(Engine, Mesh); */ texture *Texture = &Thumb->Texture; camera *ThumbCamera = &Thumb->Camera; @@ -407,7 +194,7 @@ RenderMeshPreviewToTextureAndInteractWithThumb(engine_resources *Engine, window_ if (Pressed(Ui, &B)) { - RenderToTexture_Async(&Plat->RenderQ, Engine, Thumb, Meshes, {}, 0); + RenderToTexture_Async(&Plat->RenderQ, Engine, Thumb, Mesh, {}, 0); } if (EngineDebug->ResetAssetNodeView) @@ -419,14 +206,16 @@ RenderMeshPreviewToTextureAndInteractWithThumb(engine_resources *Engine, window_ 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); + RenderToTexture_Async(&Plat->RenderQ, Engine, Thumb, Mesh, {}, 0); } return B; + +#endif } link_internal void -RenderMeshPreviewIntoWorld(engine_resources *Engine, lod_element_buffer *Meshes, v3 Dim, b32 Selected) +RenderMeshPreviewIntoWorld(engine_resources *Engine, gpu_mapped_element_buffer *Mesh, v3 Dim, b32 Selected) { UNPACK_ENGINE_RESOURCES(Engine); @@ -449,13 +238,14 @@ RenderMeshPreviewIntoWorld(engine_resources *Engine, lod_element_buffer *Meshes, // /* SetupGBufferShader(Graphics, GetApplicationResolution(&Engine->Settings)); */ - PushBonsaiRenderCommandSetupShader(RenderQ, BonsaiRenderCommand_ShaderId_gBuffer); + PushBonsaiRenderCommandSetupShader(HiRenderQ, 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)); + NotImplemented; + /* DrawLod_Async(HiRenderQ, GetEngineResources(), &Graphics->gBuffer->gBufferShader, Mesh, Basis, Quaternion(), V3(1)); */ - PushBonsaiRenderCommandTeardownShader(RenderQ, BonsaiRenderCommand_ShaderId_gBuffer); + PushBonsaiRenderCommandTeardownShader(HiRenderQ, BonsaiRenderCommand_ShaderId_gBuffer); } } @@ -466,7 +256,9 @@ link_internal void DoAssetWindow(engine_resources *Engine) { UNPACK_ENGINE_RESOURCES(Engine); + NotImplemented; +#if 0 { local_persist window_layout Window = WindowLayout("Assets"); @@ -487,6 +279,8 @@ DoAssetWindow(engine_resources *Engine) PushNewRow(Ui); } #endif + +#if 0 if (Button(Ui, CSz("New Asset From Selection"), UiId(&Window, "NewFromSelectionButton", 0u))) { Engine->Editor.NewAssetFromSelection = True; @@ -504,7 +298,7 @@ DoAssetWindow(engine_resources *Engine) cs NewAssetFromSelectionFilename = CS(Engine->Editor.NewAssetFromSelectionFilename); Engine->Editor.NewAssetFromSelection = False; - world_chunk SaveChunk = GatherVoxelsOverlappingArea(Engine, Editor->SelectionRegion, GetTranArena()); + world_chunk SaveChunk = GatherVoxelsOverlappingArea(Engine, Editor->Selection.Region, GetTranArena()); cs SaveName = {}; if (EndsWith(NewAssetFromSelectionFilename, CSz(".chunk"))) @@ -523,6 +317,7 @@ DoAssetWindow(engine_resources *Engine) /* SerializeChunk(&SaveChunk, Concat(CSz("models/"), SaveName, GetTranArena())); */ } } +#endif PushNewRow(Ui); DoEditorUi(Ui, &Window, &Engine->EngineDebug.AssetWindowViewMode, CSz("View"), &DefaultUiRenderParams_Generic); @@ -613,7 +408,7 @@ DoAssetWindow(engine_resources *Engine) case AssetType_WorldChunk: { - render_entity_to_texture_group *RTTGroup = &Engine->RTTGroup; + render_to_texture_group *RTTGroup = &Engine->RTTGroup; world_chunk *Chunk = &Asset->Chunk; @@ -621,8 +416,8 @@ DoAssetWindow(engine_resources *Engine) if (Thumb == 0) { Thumb = AllocateAssetThumbnail(Plat, &Editor->AssetThumbnails); } b32 Selected = True; - interactable_handle B = RenderMeshPreviewToTextureAndInteractWithThumb(Engine, &AssetViewWindow, Thumb, &Chunk->Meshes, V3(Chunk->Dim), Selected); - RenderMeshPreviewIntoWorld(Engine, &Chunk->Meshes, V3(Chunk->Dim), Selected); + interactable_handle B = RenderMeshPreviewToTextureAndInteractWithThumb(Engine, &AssetViewWindow, Thumb, &Chunk->Mesh, V3(Chunk->Dim), Selected); + RenderMeshPreviewIntoWorld(Engine, &Chunk->Mesh, V3(Chunk->Dim), Selected); } break; @@ -631,20 +426,22 @@ DoAssetWindow(engine_resources *Engine) { IterateOver(&Asset->Models, Model, ModelIndex) { - SyncGpuBuffersAsync(Engine, &Model->Meshes); + // TODO(Jesse): Do we still do this here? + NotImplemented; + /* SyncGpuBuffersAsync(Engine, &Model->Mesh); */ asset_thumbnail *Thumb = TryGetPtr(&Editor->AssetThumbnails, ModelIndex); if (Thumb == 0) { Thumb = AllocateAssetThumbnail(Plat, &Editor->AssetThumbnails); } b32 Selected = ModelIndex == EngineDebug->ModelIndex; - interactable_handle B = RenderMeshPreviewToTextureAndInteractWithThumb(Engine, &AssetViewWindow, Thumb, &Model->Meshes, V3(Model->Dim), Selected); + interactable_handle B = RenderMeshPreviewToTextureAndInteractWithThumb(Engine, &AssetViewWindow, Thumb, &Model->Mesh, V3(Model->Dim), Selected); if (Pressed(Ui, &B)) { EngineDebug->ModelIndex = ModelIndex; } - RenderMeshPreviewIntoWorld(Engine, &Model->Meshes, V3(Model->Dim), Selected); + RenderMeshPreviewIntoWorld(Engine, &Model->Mesh, V3(Model->Dim), Selected); if ( (ModelIndex+1) % 4 == 0) { @@ -667,6 +464,7 @@ DoAssetWindow(engine_resources *Engine) PushWindowEnd(Ui, &AssetViewWindow); } +#endif } #if 0 @@ -696,6 +494,7 @@ DoWorldEditDebugWindow(engine_resources *Engine) link_internal void DoEngineDebug(engine_resources *Engine) { + TIMED_FUNCTION(); UNPACK_ENGINE_RESOURCES(Engine); @@ -703,15 +502,30 @@ DoEngineDebug(engine_resources *Engine) ui_toggle_button_group EditorButtonGroup = ToggleButtonGroup_engine_debug_view_mode(Ui, 0, CS(""), &Engine->EngineDebug.ViewMode, &DefaultUiRenderParams_Column); + u64 CellsGenerated = EngineDebug->CellsGenerated; + + if (CellsGenerated) + { + r64 CyclesPerCell = EngineDebug->ChunkGenCyclesElapsed / CellsGenerated; + Text(Ui, CSz("CyclesPerCell : ")); + Text(Ui, CS(CyclesPerCell)); + PushNewRow(Ui); + } + + r64 ChunkGenSeconds = EngineDebug->ChunkGenTimeElapsedMS / 1000.0; + if (ChunkGenSeconds != 0.0) + { + r64 CellsPerSecond = (CellsGenerated/ChunkGenSeconds); + + Text(Ui, CSz("CellsPerSecond : ")); + Text(Ui, CS(CellsPerSecond)); + PushNewRow(Ui); + } + engine_debug_view_mode ViewMode = Engine->EngineDebug.ViewMode; /* Editor->EngineDebugViewModeToggleBits = EditorButtonGroup.ToggleBits; */ - // NOTE(Jesse): Do the world editor first so the SelectionChanged flag gets - // set before the rest of the UI code runs. This is not strictly necessary - // for correctness, but avoids a frame of lag. - // @selection_changed_flag - // if (ViewMode & EngineDebugViewMode_WorldEdit) { DoWorldEditor(Engine); @@ -729,43 +543,44 @@ DoEngineDebug(engine_resources *Engine) if (ViewMode & EngineDebugViewMode_WorldChunks) { - local_persist window_layout WorldChunkWindow = WindowLayout("World Chunks"); - WorldChunkWindow.Title = EngineDebug->PickedChunk ? - FSz("World Chunk : (%p)", EngineDebug->PickedChunk) : + window_layout *WorldChunkWindow = GetOrCreateWindow(Ui, "World Chunks"); + auto *PickedNode = EngineDebug->PickedNode; + auto *PickedChunk = PickedNode ? PickedNode->Chunk : 0; + + WorldChunkWindow->Title = PickedChunk ? + FSz("World Chunk : (%p)", PickedChunk) : CSz("World Chunk"); - PushWindowStart(Ui, &WorldChunkWindow); + PushWindowStart(Ui, WorldChunkWindow); if ( Clicked(&EditorButtonGroup, CSz("WorldChunks")) || - Button(Ui, CSz("PickNewChunk"), UiId(&WorldChunkWindow, "PickWorldChunkButton", 0ull) ) ) + Button(Ui, CSz("PickNewChunk"), UiId(WorldChunkWindow, "PickWorldChunkButton", 0ull) ) ) { EngineDebug->PickedChunkState = PickedChunkState_Hover; } - if (Button(Ui, CSz("RebuildMesh"), UiId(&WorldChunkWindow, "RebuildMesh WorldChunkWindow", 0ull)) ) - { - world_chunk *PickedChunk = EngineDebug->PickedChunk; - /* MarkBoundaryVoxels_Debug(PickedChunk->Voxels, PickedChunk->Dim); */ - MarkBoundaryVoxels_NoExteriorFaces(PickedChunk->Voxels, PickedChunk->Dim, {}, PickedChunk->Dim); - QueueChunkForMeshRebuild(&Plat->LowPriority, PickedChunk); - } - PushNewRow(Ui); + /* if (Button(Ui, CSz("RebuildMesh"), UiId(WorldChunkWindow, "RebuildMesh WorldChunkWindow", 0ull)) ) */ + /* { */ + /* MakeFaceMasks_NoExteriorFaces(PickedChunk->Occupancy, PickedChunk->xOccupancyBorder, PickedChunk->FaceMasks, PickedChunk->Voxels, PickedChunk->Dim, {}, PickedChunk->Dim); */ + /* QueueChunkForMeshRebuild(&Plat->LowPriority, PickedChunk); */ + /* } */ + /* PushNewRow(Ui); */ if (EngineDebug->PickedChunkState == PickedChunkState_Hover) { if (Engine->MousedOverVoxel.Tag) { - EngineDebug->PickedChunk = Engine->MousedOverVoxel.Value.Chunks[PickedVoxel_FirstFilled].Chunk; + EngineDebug->PickedNode = Engine->MousedOverVoxel.Value.Chunks[PickedVoxel_FirstFilled].Node; if (Input->LMB.Clicked) { EngineDebug->PickedChunkState = PickedChunkState_None; } } } - if (EngineDebug->PickedChunk) + if (EngineDebug->PickedNode) { - DoEditorUi(Ui, &WorldChunkWindow, EngineDebug->PickedChunk, CSz("PickedChunk")); + DoEditorUi(Ui, WorldChunkWindow, EngineDebug->PickedNode, {}, u32(Hash(WorldChunkWindow))); } - PushWindowEnd(Ui, &WorldChunkWindow); + PushWindowEnd(Ui, WorldChunkWindow); } #if 1 @@ -785,7 +600,11 @@ DoEngineDebug(engine_resources *Engine) PushTableStart(Ui); + auto Button = ToggleButtonStart(Ui, UiId(&TexturesWindow, u64(Texture), u64(0))); PushColumn(Ui, FSz("(%u) %S (%dx%d) Slices(%u) Channels(%u) IsDepthTexture(%b)", Texture->ID, Texture->DebugName, Texture->Dim.x, Texture->Dim.y, Texture->Slices, Texture->Channels, Texture->IsDepthTexture), UiElementAlignmentFlag_LeftAlign); PushNewRow(Ui); + ToggleButtonEnd(Ui); + + if (ToggledOn(Ui, &Button)) { Dim = V2(Texture->Dim) * 8.f; } u32 StartOuter = StartColumn(Ui); PushTableStart(Ui); @@ -793,12 +612,10 @@ DoEngineDebug(engine_resources *Engine) { RangeIterator_t(u32, SliceIndex, Texture->Slices) { - interactable_handle Button = PushButtonStart(Ui, UiId(&TexturesWindow, u64(Texture), u64(SliceIndex))); u32 Start = StartColumn(Ui); PushTexturedQuad(Ui, Texture, s32(SliceIndex), Dim, zDepth_Text); PushForceAdvance(Ui, V2(xAdvance, 0)); EndColumn(Ui, Start); - PushButtonEnd(Ui); if ( (SliceIndex+1) % 8 == 0) { @@ -846,12 +663,12 @@ DoEngineDebug(engine_resources *Engine) if (ViewMode & EngineDebugViewMode_RenderSettings) { v2 WindowDim = {{1200.f, 250.f}}; - local_persist window_layout RenderSettingsWindow = WindowLayout("Graphics Settings", WindowLayoutFlag_Align_Right); + window_layout *RenderSettingsWindow = GetOrCreateWindow(Ui, "Graphics Settings", window_layout_flags(WindowLayoutFlag_Default | WindowLayoutFlag_Align_Right)); render_settings *Settings = &Graphics->Settings; - PushWindowStart(Ui, &RenderSettingsWindow); - DoEditorUi(Ui, &RenderSettingsWindow, Settings, {}); - PushWindowEnd(Ui, &RenderSettingsWindow); + PushWindowStart(Ui, RenderSettingsWindow); + DoEditorUi(Ui, RenderSettingsWindow, Settings, {}, u32(Hash(RenderSettingsWindow))); + PushWindowEnd(Ui, RenderSettingsWindow); } if (ViewMode & EngineDebugViewMode_EngineDebug) @@ -859,16 +676,16 @@ DoEngineDebug(engine_resources *Engine) v2 WindowDim = {{1200.f, 250.f}}; { - local_persist window_layout Window = WindowLayout("Engine Debug", WindowLayoutFlag_Align_Right); - PushWindowStart(Ui, &Window); - DoEditorUi(Ui, &Window, EngineDebug, {}); - PushWindowEnd(Ui, &Window); + window_layout *Window = GetOrCreateWindow(Ui, "Engine Debug", WindowLayoutFlag_Align_Right); + PushWindowStart(Ui, Window); + DoEditorUi(Ui, Window, EngineDebug, {}, u32(Hash(Window)) ); + PushWindowEnd(Ui, Window); } { - local_persist window_layout Window = WindowLayout("Engine"); - PushWindowStart(Ui, &Window); - DoEditorUi(Ui, &Window, Engine, {}); - PushWindowEnd(Ui, &Window); + window_layout *Window = GetOrCreateWindow(Ui, "Engine"); + PushWindowStart(Ui, Window); + DoEditorUi(Ui, Window, Engine, {}, u32(Hash(Window))); + PushWindowEnd(Ui, Window); } DoGraphicsDebugWindow(Engine); diff --git a/src/engine/debug.h b/src/engine/debug.h index 38a309cfd..9c0d827ff 100644 --- a/src/engine/debug.h +++ b/src/engine/debug.h @@ -1,5 +1,6 @@ // TODO(Jesse): rename this to just thumbnail and move to renderer.. ? struct asset_thumbnail +poof(@do_editor_ui) { texture Texture; camera Camera; @@ -7,6 +8,7 @@ struct asset_thumbnail // TODO(Jesse): Move to renderer? struct chunk_thumbnail +poof(@do_editor_ui) { world_chunk Chunk; asset_thumbnail Thumbnail; @@ -14,6 +16,7 @@ struct chunk_thumbnail struct render_debug +poof(@do_editor_ui) { u32 BytesSolidGeoLastFrame; u32 BytesTransGeoLastFrame; @@ -40,7 +43,10 @@ enum engine_debug_view_mode poof(@bitfield) EngineDebugViewMode_EngineDebug = (1 << 7), }; +struct octree_node; + struct engine_debug +poof(@do_editor_ui) { memory_arena *Memory; @@ -58,8 +64,22 @@ struct engine_debug b8 TriggerRuntimeBreak; b8 ResetAssetNodeView; + b8 DrawBranchNodesWithMeshes; + b8 DrawBranchNodes; + b8 DrawLeafNodes; + b8 DrawNodesWithChunks; + b8 DrawQueuedNodes; + + b8 MarkChunkBorderVoxels; + + b8 DrawGameCameraLocation; + + r64 ChunkGenTimeElapsedMS; + u64 CellsGenerated; + r64 ChunkGenCyclesElapsed; + u8 PickedChunkState; - world_chunk *PickedChunk; + octree_node *PickedNode; asset_window_view_mode AssetWindowViewMode; @@ -68,6 +88,10 @@ struct engine_debug entity_id SelectedEntity; + u32 OctreeDrawDepth = 0xFFFFFFFF; + + octree_node *SelectedNode; + // World Edit debug // /* untextured_3d_geometry_buffer WorldEditDebugMesh; */ diff --git a/src/engine/debug_draw.cpp b/src/engine/debug_draw.cpp index 95f40af1e..5a3d1bc66 100644 --- a/src/engine/debug_draw.cpp +++ b/src/engine/debug_draw.cpp @@ -22,8 +22,19 @@ DEBUG_DrawLine( untextured_3d_geometry_buffer *Mesh, v3 P1, v3 P2, v3 RGBColor, /* v3 Color = GetColorData(Color); */ vertex_material Materials[VERTS_PER_FACE]; +#if 1 FillArray(VertexMaterial(RGBtoPackedHSV(RGBColor), 0.f, 0.f), Materials, VERTS_PER_FACE); - /* FillColorArray(Color, Materials, Global_ColorPalette, VERTS_PER_FACE); */ +#else + + Materials[0] = VertexMaterial(RGBtoPackedHSV(RGBColor), 0.f, 0.f); + Materials[1] = {}; + Materials[2] = VertexMaterial(RGBtoPackedHSV(RGBColor), 0.f, 0.f); + + Materials[3] = VertexMaterial(RGBtoPackedHSV(RGBColor), 0.f, 0.f); + Materials[5] = {}; + Materials[4] = {}; + +#endif v2 TransEmiss[VERTS_PER_FACE] = {}; @@ -141,14 +152,14 @@ DEBUG_DrawAABB(untextured_3d_geometry_buffer *Mesh, v3 MinP, v3 MaxP, v3 RGBColo /* v3 MaxP = HalfDim; */ // Compute verticies - v3 TopRL = V3(MinP.x, MaxP.y, MinP.z); - v3 TopRR = V3(MaxP.x, MaxP.y, MinP.z); - v3 TopFL = V3(MinP.x, MaxP.y, MaxP.z); - v3 TopFR = V3(MaxP.x, MaxP.y, MaxP.z); - v3 BotRL = V3(MinP.x, MinP.y, MinP.z); - v3 BotRR = V3(MaxP.x, MinP.y, MinP.z); - v3 BotFL = V3(MinP.x, MinP.y, MaxP.z); - v3 BotFR = V3(MaxP.x, MinP.y, MaxP.z); + v3 TopRL = V3(MinP.x, MaxP.y, MinP.z) * GLOBAL_RENDER_SCALE_FACTOR; + v3 TopRR = V3(MaxP.x, MaxP.y, MinP.z) * GLOBAL_RENDER_SCALE_FACTOR; + v3 TopFL = V3(MinP.x, MaxP.y, MaxP.z) * GLOBAL_RENDER_SCALE_FACTOR; + v3 TopFR = V3(MaxP.x, MaxP.y, MaxP.z) * GLOBAL_RENDER_SCALE_FACTOR; + v3 BotRL = V3(MinP.x, MinP.y, MinP.z) * GLOBAL_RENDER_SCALE_FACTOR; + v3 BotRR = V3(MaxP.x, MinP.y, MinP.z) * GLOBAL_RENDER_SCALE_FACTOR; + v3 BotFL = V3(MinP.x, MinP.y, MaxP.z) * GLOBAL_RENDER_SCALE_FACTOR; + v3 BotFR = V3(MaxP.x, MinP.y, MaxP.z) * GLOBAL_RENDER_SCALE_FACTOR; /* // Apply rotation to verts */ /* TopRL = ((Rotation * Quaternion(TopRL, 1)) * Conjugate(Rotation)).xyz; */ @@ -185,24 +196,45 @@ DEBUG_DrawAABB(untextured_3d_geometry_buffer *Mesh, v3 MinP, v3 MaxP, v3 RGBColo // Top #define LINES_PER_AABB (12) #define VERTS_PER_AABB (VERTS_PER_VOXEL*LINES_PER_AABB) - DEBUG_DrawLine_Aligned(Mesh, TopRL, TopRR, RGBColor, Thickness); - DEBUG_DrawLine_Aligned(Mesh, TopFL, TopFR, RGBColor, Thickness); - DEBUG_DrawLine_Aligned(Mesh, TopFL, TopRL, RGBColor, Thickness); - DEBUG_DrawLine_Aligned(Mesh, TopFR, TopRR, RGBColor, Thickness); +#if 1 + DEBUG_DrawLine_Aligned(Mesh, TopRL, TopRR, RGBColor, Thickness * GLOBAL_RENDER_SCALE_FACTOR); + DEBUG_DrawLine_Aligned(Mesh, TopFL, TopFR, RGBColor, Thickness * GLOBAL_RENDER_SCALE_FACTOR); + DEBUG_DrawLine_Aligned(Mesh, TopFL, TopRL, RGBColor, Thickness * GLOBAL_RENDER_SCALE_FACTOR); + DEBUG_DrawLine_Aligned(Mesh, TopFR, TopRR, RGBColor, Thickness * GLOBAL_RENDER_SCALE_FACTOR); + + // Right + DEBUG_DrawLine_Aligned(Mesh, TopFR, BotFR, RGBColor, Thickness * GLOBAL_RENDER_SCALE_FACTOR); + DEBUG_DrawLine_Aligned(Mesh, TopRR, BotRR, RGBColor, Thickness * GLOBAL_RENDER_SCALE_FACTOR); + + // Left + DEBUG_DrawLine_Aligned(Mesh, TopFL, BotFL, RGBColor, Thickness * GLOBAL_RENDER_SCALE_FACTOR); + DEBUG_DrawLine_Aligned(Mesh, TopRL, BotRL, RGBColor, Thickness * GLOBAL_RENDER_SCALE_FACTOR); + + // Bottom + DEBUG_DrawLine_Aligned(Mesh, BotRL, BotRR, RGBColor, Thickness * GLOBAL_RENDER_SCALE_FACTOR); + DEBUG_DrawLine_Aligned(Mesh, BotFL, BotFR, RGBColor, Thickness * GLOBAL_RENDER_SCALE_FACTOR); + DEBUG_DrawLine_Aligned(Mesh, BotFL, BotRL, RGBColor, Thickness * GLOBAL_RENDER_SCALE_FACTOR); + DEBUG_DrawLine_Aligned(Mesh, BotFR, BotRR, RGBColor, Thickness * GLOBAL_RENDER_SCALE_FACTOR); +#else + DEBUG_DrawLine(Mesh, TopRL, TopRR, RGBColor, Thickness * GLOBAL_RENDER_SCALE_FACTOR); + DEBUG_DrawLine(Mesh, TopFL, TopFR, RGBColor, Thickness * GLOBAL_RENDER_SCALE_FACTOR); + DEBUG_DrawLine(Mesh, TopFL, TopRL, RGBColor, Thickness * GLOBAL_RENDER_SCALE_FACTOR); + DEBUG_DrawLine(Mesh, TopFR, TopRR, RGBColor, Thickness * GLOBAL_RENDER_SCALE_FACTOR); // Right - DEBUG_DrawLine_Aligned(Mesh, TopFR, BotFR, RGBColor, Thickness); - DEBUG_DrawLine_Aligned(Mesh, TopRR, BotRR, RGBColor, Thickness); + DEBUG_DrawLine(Mesh, TopFR, BotFR, RGBColor, Thickness * GLOBAL_RENDER_SCALE_FACTOR); + DEBUG_DrawLine(Mesh, TopRR, BotRR, RGBColor, Thickness * GLOBAL_RENDER_SCALE_FACTOR); // Left - DEBUG_DrawLine_Aligned(Mesh, TopFL, BotFL, RGBColor, Thickness); - DEBUG_DrawLine_Aligned(Mesh, TopRL, BotRL, RGBColor, Thickness); + DEBUG_DrawLine(Mesh, TopFL, BotFL, RGBColor, Thickness * GLOBAL_RENDER_SCALE_FACTOR); + DEBUG_DrawLine(Mesh, TopRL, BotRL, RGBColor, Thickness * GLOBAL_RENDER_SCALE_FACTOR); // Bottom - DEBUG_DrawLine_Aligned(Mesh, BotRL, BotRR, RGBColor, Thickness); - DEBUG_DrawLine_Aligned(Mesh, BotFL, BotFR, RGBColor, Thickness); - DEBUG_DrawLine_Aligned(Mesh, BotFL, BotRL, RGBColor, Thickness); - DEBUG_DrawLine_Aligned(Mesh, BotFR, BotRR, RGBColor, Thickness); + DEBUG_DrawLine(Mesh, BotRL, BotRR, RGBColor, Thickness * GLOBAL_RENDER_SCALE_FACTOR); + DEBUG_DrawLine(Mesh, BotFL, BotFR, RGBColor, Thickness * GLOBAL_RENDER_SCALE_FACTOR); + DEBUG_DrawLine(Mesh, BotFL, BotRL, RGBColor, Thickness * GLOBAL_RENDER_SCALE_FACTOR); + DEBUG_DrawLine(Mesh, BotFR, BotRR, RGBColor, Thickness * GLOBAL_RENDER_SCALE_FACTOR); +#endif } link_internal void @@ -294,7 +326,18 @@ DEBUG_DrawChunkAABB( untextured_3d_geometry_buffer *Mesh, graphics *Graphics, wo chunk_dimension WorldChunkDim, v3 RGBColor, r32 Thickness = DEFAULT_LINE_THICKNESS) { v3 MinP = GetRenderP(WorldChunkDim, Canonical_Position(V3(0,0,0), Chunk->WorldP), Graphics->Camera); - v3 MaxP = GetRenderP(WorldChunkDim, Canonical_Position(WorldChunkDim, Chunk->WorldP), Graphics->Camera); + v3 MaxP = GetRenderP(WorldChunkDim, Canonical_Position(WorldChunkDim*Chunk->DimInChunks, Chunk->WorldP), Graphics->Camera); + + + DEBUG_DrawAABB(Mesh, MinP, MaxP, RGBColor, Thickness); +} + +link_internal void +DEBUG_DrawChunkAABB( untextured_3d_geometry_buffer *Mesh, graphics *Graphics, octree_node *Node, + chunk_dimension WorldChunkDim, v3 RGBColor, r32 Thickness = DEFAULT_LINE_THICKNESS) +{ + v3 MinP = GetRenderP(WorldChunkDim, Canonical_Position(V3(0,0,0), Node->WorldP), Graphics->Camera); + v3 MaxP = GetRenderP(WorldChunkDim, Canonical_Position(WorldChunkDim*Node->Resolution, Node->WorldP), Graphics->Camera); DEBUG_DrawAABB(Mesh, MinP, MaxP, RGBColor, Thickness); diff --git a/src/engine/editor.cpp b/src/engine/editor.cpp index 863ff0fb3..9e1ace8e7 100644 --- a/src/engine/editor.cpp +++ b/src/engine/editor.cpp @@ -1,41 +1,110 @@ -// TODO(Jesse): Should these live somewhere else? @engine_draw_file_nodes_helpers -link_internal maybe_file_traversal_node -EngineDrawFileNodesFilteredHelper(file_traversal_node Node, u64 Params) + +link_internal void +LoadBrushFromFile(level_editor *Editor, file_traversal_node *FileNode, memory_arena *TempMemory) +{ + Assert(FileNode->Type == FileTraversalType_File); + cs Filename = Concat(FileNode->Dir, CSz("/"), FileNode->Name, TempMemory); + + u8_cursor Bytes = BeginDeserialization(Filename, TempMemory); + + if (Bytes.Start) + { + world_edit_brush B = {}; + CopyString( FileNode->Name.Start, B.NameBuf, Min(umm(FileNode->Name.Count), umm(NameBuf_Len))); + Editor->CurrentBrush = Upsert(B, &Editor->LoadedBrushes, &Global_PermMemory); + + if (Deserialize(&Bytes, Editor->CurrentBrush, TempMemory) == False) + { + SoftError("While deserializing brush (%S).", Filename); + *Editor->CurrentBrush = {}; + } + } + + FinalizeDeserialization(&Bytes); +} + +link_internal world_edit * +NewEdit(level_editor *Editor, world_edit_layer *Layer, world_edit_block_array_index *IndexOut = 0) { - engine_resources *Engine = GetEngineResources(); - filtered_file_traversal_helper_params *HelperParams = ReinterpretCast(filtered_file_traversal_helper_params*, Params); - maybe_file_traversal_node Result = DrawFileNodes(&Engine->Ui, Node, HelperParams); + world_edit_block_array_index Index = {}; + world_edit *Result = {}; + IterateOver(&Editor->Edits, Edit, EditIndex) + { + if (Edit->Tombstone) + { + Edit->Tombstone = False; + Result = Edit; + Index = EditIndex; + } + } + + if (Result == 0) + { + Result = Push(&Editor->Edits); + Index = LastIndex(&Editor->Edits); + } + + Push(&Layer->EditIndices, &Index); + + if (IndexOut) + *IndexOut = Index; + return Result; } -// @engine_draw_file_nodes_helpers -link_internal b32 DefaultFileFilter(file_traversal_node *Node) { return True; } +link_internal world_edit * +DuplicateEdit(level_editor *Editor, world_edit_layer *Layer, world_edit *Edit, world_edit_block_array_index *IndexOut) +{ + world_edit_block_array_index DupIndex = {}; + auto *Duplicated = NewEdit(Editor, Layer, &DupIndex); + *Duplicated = *Edit; + Duplicated->Selected = False; + + *IndexOut = DupIndex; + + return Duplicated; +} + -// @engine_draw_file_nodes_helpers -link_internal maybe_file_traversal_node -EngineDrawFileNodesHelper(file_traversal_node Node, u64 Window) +link_internal world_edit_layer * +NewLayer(level_editor *Editor) { - engine_resources *Engine = GetEngineResources(); - filtered_file_traversal_helper_params HelperParams = {(window_layout*)Window, DefaultFileFilter}; - maybe_file_traversal_node Result = DrawFileNodes(&Engine->Ui, Node, &HelperParams); + auto ResultIndex = AtElements(&Editor->Layers); + auto Result = Push(&Editor->Layers); + Result->EditIndices = WorldEditBlockArrayIndexBlockArray(Editor->Memory); + + cs DefaultName = FSz("layer_%d", Editor->NextLayerIndex++); + CopyString(DefaultName.Start, Result->NameBuf, DefaultName.Count); + + Editor->SelectedLayerIndex = ResultIndex; return Result; } - link_internal b32 InitEditor(level_editor *Editor) { b32 Result = True; Editor->Memory = AllocateArena(); - Editor->AssetThumbnails.Memory = Editor->Memory; + Editor->Layers = WorldEditLayerBlockArray(Editor->Memory); + Assert(Editor->NextLayerIndex == 0); - RangeIterator(LayerIndex, MAX_BRUSH_LAYERS) + Editor->AssetThumbnails = AssetThumbnailBlockArray(Editor->Memory); + + Editor->LoadedBrushes = Allocate_world_edit_brush_hashtable(128, Editor->Memory); + + file_traversal_node_block_array Nodes = GetLexicographicallySortedListOfFilesInDirectory(CSz("brushes"), GetTranArena()); + + IterateOver(&Nodes, Node, NodeIndex) { - Editor->LayeredBrushEditor.LayerPreviews[LayerIndex].Thumbnail.Texture.Dim = V2i(BRUSH_PREVIEW_TEXTURE_DIM); + if (Node->Type == FileTraversalType_File) + { + LoadBrushFromFile(Editor, Node, GetTranArena()); + } } - Editor->LayeredBrushEditor.SeedLayer.Thumbnail.Texture.Dim = V2i(BRUSH_PREVIEW_TEXTURE_DIM); - Editor->LayeredBrushEditor.Preview.Thumbnail.Texture.Dim = V2i(BRUSH_PREVIEW_TEXTURE_DIM); + + Editor->Edits.Memory = Editor->Memory; + Editor->SelectedEditIndices.Memory = Editor->Memory; return Result; } @@ -43,35 +112,16 @@ InitEditor(level_editor *Editor) link_internal b32 HardResetEditor(level_editor *Editor) { - // TODO(Jesse)(leak): Delete textures allocated to visualize layered noise brushes? - // @hard_reset_texture_memory - - /* if (Editor->Shape.Preview.Thumbnail.Texture.ID) */ - /* { */ - /* DeleteTexture(&Editor->Shape.Preview.Thumbnail.Texture); */ - /* } */ - - /* if (Editor->Noise.Preview.Thumbnail.Texture.ID) */ - /* { */ - /* DeleteTexture(&Editor->Noise.Preview.Thumbnail.Texture); */ - /* } */ - IterateOver(&Editor->AssetThumbnails, Thumb, Index) { DeleteTexture(&Thumb->Texture); } - // @editor_chunk_memory_question - // - // I guess here we can actually just not worry about clearing it because - // it'll get realloc'd in the update path ..? Seems fine.. - /* DeallocateWorldChunk(&Editor->Noise.Chunk, &GetEngineResources()->MeshFreelist); */ - VaporizeArena(Editor->Memory); // NOTE(Jesse): There are some default values in noise params that we want to reset to - *Editor = {}; /* Clear(Editor); */ + *Editor = {}; b32 Result = InitEditor(Editor); return Result; @@ -83,41 +133,20 @@ poof(block_array_c(asset_thumbnail, {8})) link_weak ui_debug * GetUiDebug() { - Assert(Global_EngineResources); - return &Global_EngineResources->EngineDebug.UiDebug; + return &GetEngineResources()->EngineDebug.UiDebug; } +poof(string_and_value_tables(visible_region_size)) +#include +poof(do_editor_ui_for_enum(visible_region_size)) +#include -poof(do_editor_ui_for_compound_type(white_noise_params)) -#include - -poof(do_editor_ui_for_compound_type(perlin_noise_params)) -#include - -poof(do_editor_ui_for_compound_type(voronoi_noise_params)) -#include - -poof(do_editor_ui_for_compound_type(world_update_op_shape_params_sphere)) -#include -poof(do_editor_ui_for_compound_type(world_update_op_shape_params_rect)) -#include poof(do_editor_ui_for_enum(shape_type)) #include -poof(do_editor_ui_for_compound_type(shape_layer)) -#include -poof(do_editor_ui_for_compound_type(brush_settings)) -#include - poof(do_editor_ui_for_container(v3_cursor)) #include -poof(do_editor_ui_for_compound_type(ui_id)) -#include - -poof(do_editor_ui_for_compound_type(ui_toggle)) -#include - link_internal cs CS(ui_toggle_hashtable_iterator &Iter) { @@ -129,29 +158,87 @@ poof(do_editor_ui_for_container(ui_toggle_hashtable)) +link_internal void +DoEditorUi(renderer_2d *Ui, window_layout *Window, shader_uniform *Element, cs Name, u32 ParentHash, EDITOR_UI_FUNCTION_PROTO_DEFAULTS) +{ +#if 0 + if (Element) + { + if (ToggleButton(Ui, FSz("v %s", Element->Name), FSz("> %s", Element->Name), UiId(Window, "toggle shader_uniform", Element), EDITOR_UI_FUNCTION_INSTANCE_NAMES)) + { + PushNewRow(Ui); + + PushTableStart(Ui); + DoEditorUi(Ui, Window, &Element->Type, CSz("shader_uniform_type Type"), EDITOR_UI_FUNCTION_INSTANCE_NAMES); + switch (Element->Type) + { + InvalidCase(ShaderUniform_Undefined); + + case ShaderUniform_M4: { DoEditorUi(Ui, Window, Element->M4, CSz("M4"), EDITOR_UI_FUNCTION_INSTANCE_NAMES); } break; + case ShaderUniform_V2: { DoEditorUi(Ui, Window, Element->V2, CSz("V2"), EDITOR_UI_FUNCTION_INSTANCE_NAMES); } break; + case ShaderUniform_V3: { DoEditorUi(Ui, Window, Element->V3, CSz("V3"), EDITOR_UI_FUNCTION_INSTANCE_NAMES); } break; + case ShaderUniform_S32: { DoEditorUi(Ui, Window, Element->S32, CSz("S32"), EDITOR_UI_FUNCTION_INSTANCE_NAMES); PushNewRow(Ui); } break; + case ShaderUniform_U32: { DoEditorUi(Ui, Window, Element->U32, CSz("U32"), EDITOR_UI_FUNCTION_INSTANCE_NAMES); PushNewRow(Ui); } break; + case ShaderUniform_R32: { DoEditorUi(Ui, Window, Element->R32, CSz("R32"), EDITOR_UI_FUNCTION_INSTANCE_NAMES); PushNewRow(Ui); } break; + case ShaderUniform_Texture: { DoEditorUi(Ui, Window, Element->Texture, CSz("Texture"), EDITOR_UI_FUNCTION_INSTANCE_NAMES); } break; + case ShaderUniform_Light: { DoEditorUi(Ui, Window, Element->Light, CSz("Light"), EDITOR_UI_FUNCTION_INSTANCE_NAMES); } break; + case ShaderUniform_Camera: { DoEditorUi(Ui, Window, Element->Camera, CSz("Camera"), EDITOR_UI_FUNCTION_INSTANCE_NAMES); } break; + } + + DoEditorUi(Ui, Window, &Element->ID, CSz("s32 ID"), EDITOR_UI_FUNCTION_INSTANCE_NAMES); + PushNewRow(Ui); + DoEditorUi(Ui, Window, &Element->Count, CSz("u32 Count"), EDITOR_UI_FUNCTION_INSTANCE_NAMES); + PushNewRow(Ui); + + PushTableEnd(Ui); + /* DoEditorUi(Ui, Window, Element->Next, CSz("shader_uniform Next"), EDITOR_UI_FUNCTION_INSTANCE_NAMES); */ + } + + } + else + { + PushColumn(Ui, Name, EDITOR_UI_FUNCTION_INSTANCE_NAMES); + PushColumn(Ui, CSz("(null)"), EDITOR_UI_FUNCTION_INSTANCE_NAMES); + } + + PushNewRow(Ui); +#else + NotImplemented; +#endif +} +poof(do_editor_ui_for_container(shader_uniform_buffer)) +#include + +/* poof(do_editor_ui_for_compound_type(shader)) */ +/* #include */ + +poof(do_editor_ui_for_container(shader_ptr_block_array)) +#include + + poof(do_editor_ui_for_compound_type(work_queue_entry)) #include -poof(do_editor_ui_for_compound_type(work_queue)) -#include +/* poof(do_editor_ui_for_compound_type(work_queue)) */ +/* #include */ -poof(do_editor_ui_for_compound_type(input_event)) -#include +/* poof(do_editor_ui_for_compound_type(input_event)) */ +/* #include */ -poof(do_editor_ui_for_compound_type(input)) -#include +/* poof(do_editor_ui_for_compound_type(input)) */ +/* #include */ -poof(do_editor_ui_for_compound_type(platform)) -#include +/* poof(do_editor_ui_for_compound_type(platform)) */ +/* #include */ #if BONSAI_DEBUG_SYSTEM_API poof(do_editor_ui_for_compound_type(debug_state)) #include #endif -poof(do_editor_ui_for_compound_type(bonsai_stdlib)) -#include +/* poof(do_editor_ui_for_compound_type(bonsai_stdlib)) */ +/* #include */ @@ -186,45 +273,44 @@ poof(do_editor_ui_for_enum(tone_mapping_type)) -poof(do_editor_ui_for_compound_type(world)) -#include -poof(do_editor_ui_for_compound_type(lighting_settings)) -#include +/* poof(do_editor_ui_for_compound_type(lighting_settings)) */ +/* #include */ -poof(do_editor_ui_for_compound_type(render_settings)) -#include +/* poof(do_editor_ui_for_compound_type(render_settings)) */ +/* #include */ -poof(do_editor_ui_for_compound_type(physics)) -#include +/* poof(do_editor_ui_for_compound_type(physics)) */ +/* #include */ -poof(do_editor_ui_for_compound_type(random_series)) -#include +/* poof(do_editor_ui_for_compound_type(random_series)) */ +/* #include */ poof(do_editor_ui_for_enum(particle_spawn_type)) #include -poof(do_editor_ui_for_compound_type(particle)) -#include +/* poof(do_editor_ui_for_compound_type(particle)) */ +/* #include */ -poof(do_editor_ui_for_compound_type(particle_system)) -#include +/* poof(do_editor_ui_for_compound_type(particle_system)) */ +/* #include */ -poof(do_editor_ui_for_compound_type(keyframe)) -#include +/* poof(do_editor_ui_for_compound_type(keyframe)) */ +/* #include */ -poof(do_editor_ui_for_compound_type(animation)) -#include +/* poof(do_editor_ui_for_compound_type(animation)) */ +/* #include */ -poof(do_editor_ui_for_compound_type(vertex_material)) -#include +/* poof(do_editor_ui_for_compound_type(vertex_material)) */ +/* #include */ -poof(do_editor_ui_for_compound_type(bonsai_futex)) -#include +/* poof(do_editor_ui_for_compound_type(bonsai_futex)) */ +/* #include */ -poof(do_editor_ui_for_compound_type(untextured_3d_geometry_buffer)) -#include +/* poof(do_editor_ui_for_compound_type(untextured_3d_geometry_buffer)) */ +/* #include */ +#if 0 link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, geo_u3d **ElementP, cs Name, EDITOR_UI_FUNCTION_PROTO_DEFAULTS) { @@ -239,6 +325,75 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, geo_u3d **ElementP, cs Name, PushNewRow(Ui); } } +#endif + +/* poof(do_editor_ui_for_compound_type(plane)) */ +/* #include */ + +/* poof(do_editor_ui_for_compound_type(frustum)) */ +/* #include */ + +/* poof(do_editor_ui_for_compound_type(camera)) */ +/* #include */ + +/* poof(do_editor_ui_for_compound_type(texture)) */ +/* #include */ + +/* poof(do_editor_ui_for_compound_type(asset_thumbnail)) */ +/* #include */ + +/* poof(do_editor_ui_for_compound_type(chunk_thumbnail)) */ +/* #include */ + + + + +poof( + for_datatypes(enum) + func (enum_t) + { + enum_t.has_tag(gen_ui_toolbar)? + { + string_and_value_tables(enum_t) + toolbar_for_enum(enum_t) + } + + enum_t.has_tag(gen_string_and_value_tables)? + { + string_and_value_tables(enum_t) + } + + enum_t.has_tag(do_editor_ui)? + { + do_editor_ui_for_enum(enum_t) + } + } +) +#include + + + + +/* poof(do_editor_ui_for_compound_type(brush_layer)) */ +/* #include */ + +poof(do_editor_ui_for_compound_type(layered_brush)) +#include + +poof(do_editor_ui_for_compound_type(world_edit_brush)) +#include + +/* poof(do_editor_ui_for_compound_type(world_edit)) */ +/* #include */ + +/* poof(do_editor_ui_for_container(world_edit_ptr_block_array)) */ +/* #include */ + +poof(do_editor_ui_for_compound_type(world_edit_block_array_index)) +#include + +poof(do_editor_ui_for_container(world_edit_block_array_index_block_array)) +#include poof(do_editor_ui_for_enum(chunk_flag)) #include @@ -279,10 +434,10 @@ poof(do_editor_ui_for_compound_type(file_traversal_node)) // @dirty_entity_P_format_hack // link_internal void -DoEditorUi_entity_P(renderer_2d *Ui, window_layout *Window, entity *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Column) +DoEditorUi_entity_P(renderer_2d *Ui, window_layout *Window, entity *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Column) { - DoEditorUi(Ui, Window, &Element->P.WorldP, CSz("WorldP"), Params); - DoEditorUi(Ui, Window, &Element->P.Offset, CSz("Offset"), Params, 0.f, 32.f); + DoEditorUi(Ui, Window, &Element->P.WorldP, CSz("WorldP"), ParentHash, Params); + DoEditorUi(Ui, Window, &Element->P.Offset, CSz("Offset"), ParentHash, Params, 0.f, 32.f); } poof(do_editor_ui_for_compound_type(entity_id)) @@ -298,6 +453,12 @@ poof(do_editor_ui_for_container(entity_ptr_block_array)) poof(do_editor_ui_for_compound_type(world_chunk)) #include +poof(do_editor_ui_for_compound_type(octree_node)) +#include + +poof(do_editor_ui_for_compound_type(world)) +#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 @@ -320,127 +481,32 @@ poof(do_editor_ui_for_compound_type(entity_position_info)) #include -poof(do_editor_ui_for_compound_type(plane)) -#include - -poof(do_editor_ui_for_compound_type(frustum)) -#include - -poof(do_editor_ui_for_compound_type(camera)) -#include -poof(do_editor_ui_for_compound_type(texture)) -#include -poof(do_editor_ui_for_compound_type(asset_thumbnail)) -#include -poof(do_editor_ui_for_compound_type(chunk_thumbnail)) -#include - -poof(do_editor_ui_for_compound_type(noise_layer)) -#include - -poof(do_editor_ui_for_compound_type(brush_layer)) -#include - -poof(do_editor_ui_for_compound_type(layered_brush_editor)) -#include - - -link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, shader_uniform *Element, cs Name, EDITOR_UI_FUNCTION_PROTO_DEFAULTS) -{ - if (Element) +poof( + for_datatypes(struct) + func (struct_t) { - if (ToggleButton(Ui, FSz("v %s", Element->Name), FSz("> %s", Element->Name), UiId(Window, "toggle shader_uniform", Element), EDITOR_UI_FUNCTION_INSTANCE_NAMES)) + struct_t.has_tag(do_editor_ui)? { - PushNewRow(Ui); - - PushTableStart(Ui); - DoEditorUi(Ui, Window, &Element->Type, CSz("shader_uniform_type Type"), EDITOR_UI_FUNCTION_INSTANCE_NAMES); - switch (Element->Type) - { - InvalidCase(ShaderUniform_Undefined); - - case ShaderUniform_M4: { DoEditorUi(Ui, Window, Element->M4, CSz("M4"), EDITOR_UI_FUNCTION_INSTANCE_NAMES); } break; - case ShaderUniform_V2: { DoEditorUi(Ui, Window, Element->V2, CSz("V2"), EDITOR_UI_FUNCTION_INSTANCE_NAMES); } break; - case ShaderUniform_V3: { DoEditorUi(Ui, Window, Element->V3, CSz("V3"), EDITOR_UI_FUNCTION_INSTANCE_NAMES); } break; - case ShaderUniform_S32: { DoEditorUi(Ui, Window, Element->S32, CSz("S32"), EDITOR_UI_FUNCTION_INSTANCE_NAMES); } break; - case ShaderUniform_U32: { DoEditorUi(Ui, Window, Element->U32, CSz("U32"), EDITOR_UI_FUNCTION_INSTANCE_NAMES); } break; - case ShaderUniform_R32: { DoEditorUi(Ui, Window, Element->R32, CSz("R32"), EDITOR_UI_FUNCTION_INSTANCE_NAMES); } break; - case ShaderUniform_Texture: { DoEditorUi(Ui, Window, Element->Texture, CSz("Texture"), EDITOR_UI_FUNCTION_INSTANCE_NAMES); } break; - case ShaderUniform_Light: { DoEditorUi(Ui, Window, Element->Light, CSz("Light"), EDITOR_UI_FUNCTION_INSTANCE_NAMES); } break; - case ShaderUniform_Camera: { DoEditorUi(Ui, Window, Element->Camera, CSz("Camera"), EDITOR_UI_FUNCTION_INSTANCE_NAMES); } break; - } - - DoEditorUi(Ui, Window, &Element->ID, CSz("s32 ID"), EDITOR_UI_FUNCTION_INSTANCE_NAMES); - PushTableEnd(Ui); - PushNewRow(Ui); - - DoEditorUi(Ui, Window, Element->Next, CSz("shader_uniform Next"), EDITOR_UI_FUNCTION_INSTANCE_NAMES); + do_editor_ui_for_compound_type(struct_t); } } - else - { - PushColumn(Ui, Name, EDITOR_UI_FUNCTION_INSTANCE_NAMES); - PushColumn(Ui, CSz("(null)"), EDITOR_UI_FUNCTION_INSTANCE_NAMES); - PushNewRow(Ui); - } -} - -poof(do_editor_ui_for_compound_type(shader)) -#include - -poof(do_editor_ui_for_compound_type(render_buffers_2d)) -#include - -poof(do_editor_ui_for_compound_type(renderer_2d)) -#include - -poof(do_editor_ui_for_compound_type(game_lights)) -#include +) +#include -poof(do_editor_ui_for_compound_type(lighting_render_group)) -#include -poof(do_editor_ui_for_compound_type(g_buffer_render_group)) -#include - -poof(do_editor_ui_for_compound_type(graphics)) -#include - -poof(do_editor_ui_for_compound_type(render_debug)) -#include - -poof(do_editor_ui_for_compound_type(ui_debug)) -#include - -poof(do_editor_ui_for_compound_type(engine_debug)) -#include poof(do_editor_ui_for_enum(engine_debug_view_mode)) #include -poof(do_editor_ui_for_compound_type(level_editor)) -#include - poof(do_editor_ui_for_enum(resolution_setting)) #include poof(do_editor_ui_for_enum(shader_language_setting)) #include -poof(do_editor_ui_for_compound_type(graphics_settings)) -#include - -poof(do_editor_ui_for_compound_type(engine_settings)) -#include - - -poof(do_editor_ui_for_compound_type(engine_resources)) -#include - link_internal rect3i ModifySelectionAABB(rect3 *SelectionRegion, v3i UpdateVector, face_index Face, world_edit_selection_mode Mode) @@ -516,18 +582,6 @@ GetMax(v3 *SelectionRegion) return Result; } -link_internal void -ApplyEditToRegion(engine_resources *Engine, rect3 *SelectionAABB, v3 HSVColor, b32 PersistWhitespace, world_edit_mode WorldEditMode, world_edit_mode_modifier Modifier) -{ - world_edit_shape Shape = { - .Type = type_world_update_op_shape_params_rect, - .world_update_op_shape_params_rect.Region = *SelectionAABB - }; - - QueueWorldUpdateForRegion(Engine, WorldEditMode, Modifier, &Shape, HSVColor, PersistWhitespace, Engine->WorldUpdateMemory); -} - - link_internal v3 ConstrainUpdateVector(v3 UpdateVector, face_index Face, world_edit_selection_mode SelectionMode) { @@ -627,36 +681,31 @@ HighlightFace(engine_resources *Engine, face_index Face, aabb SelectionAABB, r32 } } -link_internal rect3i -DoSelectonModification( engine_resources *Engine, - ray *MouseRay, - world_edit_selection_mode SelectionMode, - selection_modification_state *SelectionState, - aabb SelectionAABB ) +link_internal void +UpdateSelectionStateForFrame( ray *MouseRay, + camera *Camera, + input *Input, + world_edit_selection_mode SelectionMode, + selection_modification_state *SelectionState) { - UNPACK_ENGINE_RESOURCES(Engine); - rect3i Result = Rect3i(SelectionAABB); - - v3 Normal = {}; + v3 Normal = NormalForFace(SelectionState->ClickedFace); v3 PlaneN = {}; switch (SelectionMode) { - case SelectionMode_Noop: { return Result; } + case SelectionMode_Noop: { return; } case SelectionMode_TranslateLinear: case SelectionMode_ResizeSingleLinearAxis: case SelectionMode_ResizeBothLinearAxies: case SelectionMode_ResizeAllAxies: { - Normal = NormalForFace(SelectionState->ClickedFace); v3 PerpN = Cross(Normal, Camera->Front); PlaneN = Cross(Normal, PerpN); } break; case SelectionMode_TranslatePlanar: { - Normal = NormalForFace(SelectionState->ClickedFace); PlaneN = Normal; } break; } @@ -671,2013 +720,1872 @@ DoSelectonModification( engine_resources *Engine, SelectionState->ClickedP[1] = PlaneIntersect; } } +} +link_internal rect3i +DoSelectonModification( engine_resources *Engine, + ray *MouseRay, + world_edit_selection_mode SelectionMode, + selection_modification_state *SelectionState, + aabb SelectionAABB, + v3 *Diff = 0) +{ + UNPACK_ENGINE_RESOURCES(Engine); v3 RoughUpdateVector = (SelectionState->ClickedP[1] - SelectionState->ClickedP[0]); v3 UpdateVector = ConstrainUpdateVector(RoughUpdateVector, SelectionState->ClickedFace, SelectionMode); - Result = ModifySelectionAABB(&SelectionAABB, V3i(UpdateVector), SelectionState->ClickedFace, SelectionMode); + rect3i Result = ModifySelectionAABB(&SelectionAABB, V3i(UpdateVector), SelectionState->ClickedFace, SelectionMode); + if (Diff) { - /* DEBUG_HighlightVoxel(Engine, SelectionState->ClickedP[0], RED); */ - /* DEBUG_HighlightVoxel(Engine, SelectionState->ClickedP[1], BLUE); */ - DEBUG_DrawSimSpaceVectorAt(Engine, SelectionState->ClickedP[0], UpdateVector, RGB_GREEN); + *Diff = UpdateVector; } - // Draw selection modification region - // - rect3 Draw = Rect3(&Result); - DEBUG_DrawSimSpaceAABB(Engine, &Draw, RGB_GREEN, 0.1f); - Assert(Result.Min <= Result.Max); - return Result; } -link_internal void -DoSelectedVoxelDebugWindow(engine_resources *Engine, cp VoxelCP) +#if 1 +link_internal interactable_handle +InteractWithThumbnailTexture(engine_resources *Engine, renderer_2d *Ui, window_layout *Window, const char* InteractionString, asset_thumbnail *Thumb) { - UNPACK_ENGINE_RESOURCES(Engine); - - voxel *V = TryGetVoxelPointer(World, VoxelCP); - + texture *Texture = &Thumb->Texture; + camera *ThumbCamera = &Thumb->Camera; - v3 SimP = Floor(GetSimSpaceP(World, VoxelCP)); -#if VOXEL_DEBUG_COLOR - if (V) + // TODO(Jesse)(leak): How do we deallocate these on hard reset? + // @hard_reset_texture_memory + if (Texture->ID == 0 && Texture->Queued == False) { - DEBUG_DrawSimSpaceVectorAt(Engine, SimP, Normalize(V->DebugColor)* 40.f, GREEN, 0.25f); - DEBUG_DrawSimSpaceVectorAt(Engine, SimP, Normalize(V->DebugColor)*-40.f, YELLOW, 0.25f); - DEBUG_HighlightVoxel(Engine, SimP, YELLOW, DEFAULT_LINE_THICKNESS*2.f); + Assert(Texture->Dim > V2i(0)); + Texture->Queued = True; + /* PushBonsaiRenderCommandAllocateTexture(&Engine->Plat->RenderQ, Texture); */ + MakeTexture_RGB_Async(&Engine->Stdlib.Plat.LoRenderQ, Texture, Texture->Dim, 0, CSz("NoisePreviewTexture")); + /* *Texture = MakeTexture_RGB(V2i(256), 0, CSz("NoisePreviewTexture")); */ + StandardCamera(ThumbCamera, 10000.f, 500.f, 30.f); } -#endif + interactable_handle B = PushButtonStart(Ui, UiId(Window, InteractionString, Cast(void*, Thumb))); + u32 Index = StartColumn(Ui, &DefaultUiRenderParams_Blank); + PushTexturedQuad(Ui, Texture, V2(Texture->Dim), zDepth_Text); + EndColumn(Ui, Index); + PushButtonEnd(Ui); + v2 MouseDP = {}; + r32 CameraZDelta = {}; + if (Pressed(Ui, &B)) { - local_persist window_layout Window = WindowLayout("Voxel Debug Window", V2(150.f, 150.f)); - PushWindowStart(Ui, &Window); - - if (V) - { - DoEditorUi(Ui, &Window, &V->Flags, CSz("Voxel Flags")); - PushNewRow(Ui); - - DoEditorUi(Ui, &Window, &VoxelCP, CSz("CP")); + Ui->RequestedForceCapture = True; + v2 MouseDelta = GetMouseDelta(&GetEngineResources()->Stdlib.Plat); + if (Ui->Input->LMB.Pressed) { MouseDP = MouseDelta*2.f; } + if (Ui->Input->RMB.Pressed) { CameraZDelta += MouseDelta.y*2.f; } + } + UpdateGameCamera(GetWorld(), Engine->Stdlib.Plat.ScreenDim, MouseDP, CameraZDelta, {}, ThumbCamera, 0.f); -#if VOXEL_DEBUG_COLOR - DoEditorUi(Ui, &Window, &V->DebugNoiseValue, CSz("Noise Value")); - PushNewRow(Ui); + /* if (Ui->Input->LMB.Pressed == False && Hover(Ui, &B)) { PushTooltip(Ui, ToString(Texture)); } */ - DoEditorUi(Ui, &Window, &V->DebugColor, CSz("DebugColor")); + return B; +} +#endif - r32 DotP = Dot(V->DebugColor, V3(0,0,1)); - DoEditorUi(Ui, &Window, &DotP, CSz("Dot against V3(0,0,1)")); - PushNewRow(Ui); - PushNewRow(Ui); +link_internal v3 +GetHotVoxelForEditMode(engine_resources *Engine, world_edit_blend_mode WorldEditMode) +{ + v3 Result = Floor(GetSimSpaceP(Engine->World, &Engine->MousedOverVoxel.Value, PickedVoxel_FirstFilled)); + return Result; +} - world_chunk *ThisChunk = GetWorldChunkFromHashtable(World, VoxelCP.WorldP); - - PushTableStart(Ui); - PushNewRow(Ui); - PushColumn(Ui, CSz("Contributed")); - PushColumn(Ui, CSz(" ")); - PushColumn(Ui, CSz(" ")); - PushColumn(Ui, CSz("Expected")); - PushNewRow(Ui); +#if 0 +link_internal void +BrushSettingsForNoiseBrush(engine_resources *Engine, window_layout *Window, noise_layer *Layer) +{ + UNPACK_ENGINE_RESOURCES(Engine); - PushColumn(Ui, CSz("To Normal")); - PushColumn(Ui, CSz("Offset")); - PushColumn(Ui, CSz("NoiseValue")); - PushColumn(Ui, CSz("NoiseValue")); - PushColumn(Ui, CSz("")); - PushNewRow(Ui); - v3i Dim = V3i(3,3,3); - for (s32 dz = -1; dz < 2; ++dz) + PushTableStart(Ui); + if (SelectionComplete(Editor->Selection.Clicks)) + { + DoEditorUi(Ui, Window, &Layer->Type, CSz("NoiseType"), &DefaultUiRenderParams_Generic); + PushTableStart(Ui); // TODO(Jesse): Necessary? + switch (Layer->Type) { - for (s32 dy = -1; dy < 2; ++dy) + case NoiseType_White: { - for (s32 dx = -1; dx < 2; ++dx) - { - /* if (dz == 0 && dy == 0 && dx == 0) continue; // ? */ - - s32 NormalIndex = GetIndex(VoxelCP.Offset+V3(dx,dy,dz)+1, ThisChunk->Dim+2); - s32 NoiseIndex = GetIndex(VoxelCP.Offset+V3(dx,dy,dz)+2, ThisChunk->Dim+4); - v3 ExpectedNormalValue = V3(f32_MAX); - r32 ExpectedNoiseValue = f32_MAX; - if (ThisChunk->NoiseValues) { ExpectedNoiseValue = ThisChunk->NoiseValues[NoiseIndex]; } - if (ThisChunk->NormalValues) { ExpectedNormalValue = ThisChunk->NormalValues[NormalIndex]; } - - voxel *dV = TryGetVoxelPointer(World, Canonicalize(World, VoxelCP + V3(dx,dy,dz))); - - ui_style *Style = &DefaultStyle; - - b32 ValueContributedToNormal = False; - if (dV && dV->DebugNoiseValue-dz > Truncate(V->DebugNoiseValue)) - { - Style = &DefaultSelectedStyle; - ValueContributedToNormal = True; - } - - { - if (ValueContributedToNormal) - { - PushColumn(Ui, CSz("+")); - } - else - { - PushColumn(Ui, CSz(" ")); - } - - PushColumn(Ui, FSz("(%d %d %d)", dx, dy, dz), Style); - if (dV) { PushColumn(Ui, CS(dV->DebugNoiseValue)); } - else { PushColumn(Ui, CSz("(INVALID NOISE INDEX)")); } - - if (dV && ExpectedNoiseValue != dV->DebugNoiseValue) { Style = &Global_DefaultErrorStyle; DEBUG_HighlightVoxel(Engine, SimP+V3(dx,dy,dz), RED); } - else { Style = &DefaultStyle; } - - if (ExpectedNoiseValue < f32_MAX) { PushColumn(Ui, FSz("(%.2f)", r64(ExpectedNoiseValue)), Style); } - else { PushColumn(Ui, FSz("(THIS CHUNK (%p) DID NOT HAVE VALID NOISE VALUE POINTER)", ThisChunk)); } - - if (dV && ExpectedNormalValue != dV->DebugColor) { Style = &Global_DefaultErrorStyle; DEBUG_HighlightVoxel(Engine, SimP+V3(dx,dy,dz), PINK); } - else { Style = &DefaultStyle; } - - if (ExpectedNormalValue.x < f32_MAX) { PushColumn(Ui, FSz("(%.2f,%.2f,%.2f)", r64(ExpectedNormalValue.x), r64(ExpectedNormalValue.y), r64(ExpectedNormalValue.z) ), Style); } - else { PushColumn(Ui, FSz("(THIS CHUNK (%p) DID NOT HAVE VALID NORMAL VALUE POINTER)", ThisChunk)); } + DoEditorUi(Ui, Window, &Layer->White, CSz("")); + } break; + case NoiseType_Perlin: + { + DoEditorUi(Ui, Window, &Layer->Perlin, CSz("")); + } break; - PushNewRow(Ui); - } - } - PushNewRow(Ui); - } - PushNewRow(Ui); + case NoiseType_Voronoi: + { + DoEditorUi(Ui, Window, &Layer->Voronoi, CSz("")); + } break; } PushTableEnd(Ui); -#endif - } else { - PushColumn(Ui, CSz("(null)")); + PushColumn(Ui, CSz("Make a selection to use Noise Brush")); + PushNewRow(Ui); } - PushWindowEnd(Ui, &Window); - } + PushTableEnd(Ui); } +#endif -#if 1 -link_internal interactable_handle -InteractWithThumbnailTexture(engine_resources *Engine, renderer_2d *Ui, window_layout *Window, const char* InteractionString, asset_thumbnail *Thumb) +link_internal cs +GetFilenameForBrush(cs Name, s32 Version = 0) { - texture *Texture = &Thumb->Texture; - camera *ThumbCamera = &Thumb->Camera; + cs Result; - // TODO(Jesse)(leak): How do we deallocate these on hard reset? - // @hard_reset_texture_memory - if (Texture->ID == 0 && Texture->Queued == False) + if (EndsWith(Name, CSz(".brush"))) { Name.Count -= 6; } + + if (Version) { - Assert(Texture->Dim > V2i(0)); - Texture->Queued = True; - /* PushBonsaiRenderCommandAllocateTexture(&Engine->Plat->RenderQ, Texture); */ - MakeTexture_RGB_Async(&Engine->Stdlib.Plat.RenderQ, Texture, Texture->Dim, 0, CSz("NoisePreviewTexture")); - /* *Texture = MakeTexture_RGB(V2i(256), 0, CSz("NoisePreviewTexture")); */ - StandardCamera(ThumbCamera, 10000.f, 500.f, 30.f); + Result = FCS(CSz("brushes/%S.%d.brush\0"), Name, Version); } - - interactable_handle B = PushButtonStart(Ui, UiId(Window, InteractionString, Cast(void*, Thumb))); - u32 Index = StartColumn(Ui, &DefaultUiRenderParams_Blank); - PushTexturedQuad(Ui, Texture, V2(Texture->Dim), zDepth_Text); - EndColumn(Ui, Index); - PushButtonEnd(Ui); - - v2 MouseDP = {}; - r32 CameraZDelta = {}; - if (Pressed(Ui, &B)) + else { - Ui->RequestedForceCapture = True; - v2 MouseDelta = GetMouseDelta(&GetEngineResources()->Stdlib.Plat); - if (Ui->Input->LMB.Pressed) { MouseDP = MouseDelta*2.f; } - if (Ui->Input->RMB.Pressed) { CameraZDelta += MouseDelta.y*2.f; } + Result = FCS(CSz("brushes/%S.brush\0"), Name); } - UpdateGameCamera(GetWorld(), MouseDP, CameraZDelta, {}, ThumbCamera, 0.f); - - /* if (Ui->Input->LMB.Pressed == False && Hover(Ui, &B)) { PushTooltip(Ui, ToString(Texture)); } */ - return B; + return Result; } -#endif - -link_internal v3 -GetHotVoxelForEditMode(engine_resources *Engine, world_edit_mode WorldEditMode) +link_internal void +SaveBrush(world_edit_brush *Brush, const char *FilenameZ) { - picked_voxel_position Pos = PickedVoxel_FirstFilled; + ZeroMemory(Brush->NameBuf, NameBuf_Len); + cs BrushNameBuf = CS(Brush->NameBuf, NameBuf_Len); - switch (WorldEditMode) - { - case WorldEdit_Mode_Disabled: {} break; - case WorldEdit_Mode_Attach: - { - Pos = PickedVoxel_LastEmpty; - } break; + cs BrushBasename = Basename(CS(FilenameZ)); + CopyString(&BrushBasename, &BrushNameBuf); - case WorldEdit_Mode_Paint: - case WorldEdit_Mode_Remove: - { - Pos = PickedVoxel_FirstFilled; - } break; - } + u8_cursor_block_array OutputStream = BeginSerialization(); + Serialize(&OutputStream, Brush); - v3 Result = Floor(GetSimSpaceP(Engine->World, &Engine->MousedOverVoxel.Value, Pos)); - return Result; + if (FinalizeSerialization(&OutputStream, FilenameZ) == False) + { + SoftError("Unable to serialize brush (%s) to file (%s).", Brush->NameBuf, FilenameZ); + } } -link_internal v3 -GetHotVoxelForFlood(engine_resources *Engine, world_edit_mode WorldEditMode, world_edit_mode_modifier Modifier) + +link_internal void +NewBrush(world_edit_brush *Brush) { - v3 Result = {}; - picked_voxel_position Pos = {}; + cs BrushNameBuf = CS(Brush->NameBuf, NameBuf_Len); - if (Modifier == WorldEdit_Modifier_Flood) - { - switch (WorldEditMode) - { - case WorldEdit_Mode_Disabled: {} break; - case WorldEdit_Mode_Attach: - { - Pos = PickedVoxel_FirstFilled; - } break; + ZeroMemory(Brush->NameBuf, NameBuf_Len); - case WorldEdit_Mode_Paint: - case WorldEdit_Mode_Remove: - { - Pos = PickedVoxel_LastEmpty; - } break; - } + cs Src = CSz("_untitled.brush"); + CopyString(&Src, &BrushNameBuf); - Result = Floor(GetSimSpaceP(Engine->World, &Engine->MousedOverVoxel.Value, Pos)); + brush_layer *Layers = Brush->Layered.Layers; + RangeIterator(LayerIndex, MAX_BRUSH_LAYERS) + { + brush_layer *Layer = Layers + LayerIndex; + Layer->Settings = {}; } - return Result; + Brush->Layered.LayerCount = 1; + + // Initialize PrevSettings so we don't fire a changed event straight away.. + // @prevent_change_event + CheckSettingsChanged(&Brush->Layered); } -link_internal v3i -GetShapeDim(shape_layer *Layer) +link_internal world_edit_brush +NewBrush() { - v3i Result = {}; - switch (Layer->Type) - { - case ShapeType_None: { } break; - case ShapeType_Sphere: - { - // NOTE(Jesse): This can't have a +1 because that dialates it outside the selection region. - Result = V3i(Layer->Sphere.Radius*2.f); - } break; - - case ShapeType_Rect: - { - Result = V3i(GetDim(Layer->Rect.Region)); - } break; - } - - return Result; + world_edit_brush Brush = {}; + NewBrush(&Brush); + return Brush; } -link_internal v3i -GetRequiredDimForLayer(v3i SelectionDim, brush_layer *Layer) +link_internal cs +GetLayerUiText(brush_layer *Layer, memory_arena *TempMem) { - v3i Request = GetDim(Layer->Settings.Offset); + cs LayerType = ToStringPrefixless(Layer->Settings.Type); + cs SubType = {}; switch (Layer->Settings.Type) { - case BrushLayerType_Noise: - { - Request += SelectionDim; - } break; - - case BrushLayerType_Shape: - { - - shape_layer *Shape = &Layer->Settings.Shape; - switch (Shape->Type) - { - case ShapeType_None: { } break; - case ShapeType_Sphere: - { - Request += V3i(Shape->Sphere.Radius*2.f); - } break; - - case ShapeType_Rect: - { - Request += SelectionDim; - } break; - } - } break; + case BrushLayerType_Noise: { SubType = ToStringPrefixless(Layer->Settings.Noise.Type); } break; + case BrushLayerType_Shape: { SubType = ToStringPrefixless(Layer->Settings.Shape.Type); } break; } - v3i Result = Max(V3i(0), Request); - return Result; + return FSz("%S(%S)", LayerType, SubType); } -// NOTE(Jesse): This is a little wacky, and I actually don't quite know why the -// preview chunk dimension is primal for noise layers, but .. there you go. -link_internal v3i -GetLayerDim(brush_layer *Layer) +link_internal void +DoColorSwatch(renderer_2d *Ui, v2 QuadDim, v3 RGB) { - v3i Result = GetDim(Layer->Settings.Offset); - switch (Layer->Settings.Type) - { - case BrushLayerType_Shape: - { - Result += GetShapeDim(&Layer->Settings.Shape); - } break; - - case BrushLayerType_Noise: - { - Result += GetSelectionDim(GetWorld(), GetLevelEditor()); //Preview->Chunk.Dim; - } break; - } - return Result; + ui_style Style = FlatUiStyle(RGB); + PushUntexturedQuad(Ui, {}, QuadDim, zDepth_Text, &Style, {} ); + PushNewRow(Ui); } -link_internal b32 -CheckForChangesAndUpdate_ThenRenderToPreviewTexture(engine_resources *Engine, brush_layer *Layer, chunk_thumbnail *Preview) +link_internal void +DoBrushSettingsWindow(engine_resources *Engine, world_edit_brush *Brush, window_layout *BrushSettingsWindow) { UNPACK_ENGINE_RESOURCES(Engine); - brush_settings *Settings = &Layer->Settings; - brush_settings *PrevSettings = &Layer->PrevSettings; - - v3i SelectionDim = GetSelectionDim(World, Editor); - v3i RequiredLayerDim = GetRequiredDimForLayer(SelectionDim, Layer); - - b32 ReallocChunk = Editor->SelectionChanged || Preview->Chunk.Dim != RequiredLayerDim; - b32 SettingsChanged = !AreEqual(Settings, PrevSettings); - b32 UpdateVoxels = ReallocChunk || SettingsChanged; - - *PrevSettings = *Settings; - - + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(u32(u64(BrushSettingsWindow))); - world_chunk *Chunk = &Preview->Chunk; - if (ReallocChunk) + PushWindowStart(Ui, BrushSettingsWindow); + Assert(Brush); { - // TODO(Jesse)(leak): Figure out exactly how this works. We can't allocate from the Editor - // memory pool because the goemetry buffers get freed to a freelist, and the editor memory - // pool gets cleared on game reload + b32 IsNewBrush = False; + layered_brush *LayeredBrush = &Brush->Layered; + { + b32 BrushUninitialized = Brush->NameBuf[0] == 0 && Brush->Layered.LayerCount == 0; + if (BrushUninitialized) + { + NewBrush(Brush); + IsNewBrush = True; + } + } + // - // @editor_chunk_memory_question + // Brush toolbar buttons // - /* DeallocateWorldChunk(Chunk, MeshFreelist); */ - DeallocateGpuBuffers(RenderQ, Chunk); - AllocateWorldChunk(Chunk, {}, RequiredLayerDim, Editor->Memory); - } - - if (UpdateVoxels) - { - /* Info("Detected changes to settings, updating voxels. ReallocChunk(%b) SettingsChanged(%b)", ReallocChunk, SettingsChanged); */ - - switch (Settings->Type) { - case BrushLayerType_Shape: + memory_arena *Tran = GetTranArena(); + + if (LayeredBrush->LayerCount) { - shape_layer *Shape = &Settings->Shape; - switch (Shape->Type) + ui_brush_actions BrushAction = {}; + ui_toggle_button_group Toolbar = PushToolbar(Ui, BrushSettingsWindow, CSz(""), &BrushAction); + switch (BrushAction) { - case ShapeType_None: {} break; + case UiBrushAction_NoAction: {} break; + + case UiBrushAction_New: + { + world_edit_brush ThisBrush = NewBrush(); + Editor->CurrentBrush = Insert(ThisBrush, &Editor->LoadedBrushes, Editor->Memory); + } break; + + case UiBrushAction_Save: + { + cs BrushFilepath = GetFilenameForBrush(CS(Brush->NameBuf)); + SaveBrush(Brush, BrushFilepath.Start); + } break; - case ShapeType_Rect: + case UiBrushAction_Duplicate: { - rect3 Region = RectMinDim({}, V3(SelectionDim)); + world_edit_brush Duplicated = *Brush; - Region.Min += V3(Settings->Offset.Min); - Region.Max += V3(Settings->Offset.Max); + cs_buffer Pieces = Split( CS(Duplicated.NameBuf), '.', Tran); - Sanitize(&Region); + if (Pieces.Count > 2) + { + cs BrushNameString = Pieces.Start[0]; + cs VersionString = Pieces.Start[Pieces.Count-2]; - Shape->Rect.Region.Min = Min(Region.Min, Region.Max); - Shape->Rect.Region.Max = Max(Region.Min, Region.Max); + s32 VersionNumber; + if ( ParseInteger(VersionString, &VersionNumber) ) + { + cs BrushFilepath = GetFilenameForBrush(BrushNameString, VersionNumber); + while (FileExists(BrushFilepath.Start)) + { + ++VersionNumber; + BrushFilepath = GetFilenameForBrush(BrushNameString, VersionNumber); + } - Assert(GetDim(Shape->Rect.Region) == V3(RequiredLayerDim)); - Assert(Chunk->Dim == RequiredLayerDim); + SaveBrush(&Duplicated, BrushFilepath.Start); + } + } + else + { + cs BrushFilepath = GetFilenameForBrush(CS(Duplicated.NameBuf), 1); + SaveBrush(&Duplicated, BrushFilepath.Start); + } + Editor->CurrentBrush = Insert(Duplicated, &Editor->LoadedBrushes, Editor->Memory); } break; - case ShapeType_Sphere: +#if 0 + case UiBrushAction_Import: { - // NOTE(Jesse): Constrain maximum sphere radius to minimum selection dimension - r32 MaxSphereRadius = Min(Min(SelectionDim.x, SelectionDim.y), SelectionDim.z)/2.f; - Shape->Sphere.Radius = MaxSphereRadius; - Shape->Sphere.Location = Canonical_Position(V3(MaxSphereRadius), {}); + ui_id ImportToggleId = UiId(BrushSettingsWindow, "brush import", 0u); + if (ToggleButton(Ui, CSz("Import"), CSz("Import"), ImportToggleId)) + { + PushNewRow(Ui); + + filtered_file_traversal_helper_params HelperParams = {BrushSettingsWindow, 0}; + maybe_file_traversal_node ClickedFileNode = PlatformTraverseDirectoryTreeUnordered(CSz("brushes"), EngineDrawFileNodesFilteredHelper, u64(&HelperParams) ); + if (ClickedFileNode.Tag) + { + LoadBrushFromFile(Editor, &ClickedFileNode.Value, Tran); + SetToggleButton(Ui, ImportToggleId, False); + } + } } break; - } +#endif - if (LengthSq(GetShapeDim(Shape)) > 0) - { - ApplyBrushLayer(Engine, Layer, Preview, Chunk, Settings->Offset.Min); - FinalizeChunkInitialization(Chunk); - QueueChunkForMeshRebuild(&Plat->LowPriority, Chunk); } + } - } break; - - case BrushLayerType_Noise: { - noise_layer *Noise = &Settings->Noise; - chunk_init_callback NoiseFunc = {}; - generic_noise_params NoiseParams = {}; - void *UserData = {}; - - NoiseParams.RGBColor = Settings->RGBColor; - switch (Noise->Type) + if (LayeredBrush->LayerCount) { - case NoiseType_White: + PushNewRow(Ui); + PushNewRow(Ui); + { - NoiseFunc = Terrain_WhiteNoise; - NoiseParams.Threshold = Noise->White.Threshold; - } break; + ui_id TextBoxId = UiId(BrushSettingsWindow, "name_buf_textbox", Brush->NameBuf); + cs NameBuf = CS(Brush->NameBuf); + TextBox(Ui, CSz("BrushName"), NameBuf, NameBuf_Len, TextBoxId); + PushNewRow(Ui); + + DoEditorUi(Ui, BrushSettingsWindow, &LayeredBrush->LayerCount, CSz("Layer Count"), ThisHash, &DefaultUiRenderParams_Generic); + // Clamp LayerCount to (1,MAX_BRUSH_LAYERS) once it's set + LayeredBrush->LayerCount = Max(LayeredBrush->LayerCount, 1); + LayeredBrush->LayerCount = Min(LayeredBrush->LayerCount, MAX_BRUSH_LAYERS); + PushNewRow(Ui); + PushNewRow(Ui); + } - case NoiseType_Perlin: { - NoiseFunc = Terrain_Perlin3D; - NoiseParams.Threshold = Noise->Perlin.Threshold; - NoiseParams.Period = Noise->Perlin.Period; - NoiseParams.Amplitude = Noise->Perlin.Amplitude; - } break; + /* DoEditorUi(Ui, BrushSettingsWindow, &LayeredBrush->Mode, CSz("Mode"), &DefaultUiRenderParams_Generic); */ + /* DoEditorUi(Ui, BrushSettingsWindow, &LayeredBrush->Modifier, CSz("Modifier"), &DefaultUiRenderParams_Generic); */ + /* PushNewRow(Ui); */ + } - case NoiseType_Voronoi: { - NoiseFunc = Terrain_Voronoi3D; - NoiseParams.Threshold = Noise->Voronoi.Threshold; - NoiseParams.Period = Noise->Voronoi.Period; - NoiseParams.Amplitude = Noise->Voronoi.Amplitude; - UserData = Cast(void*, &Noise->Voronoi); - } break; - } + DoEditorUi(Ui, BrushSettingsWindow, &LayeredBrush->AffectExisting, CSz("Affect World"), ThisHash, &DefaultUiRenderParams_Checkbox); + PushNewRow(Ui); + PushNewRow(Ui); - Assert(NoiseFunc); + PushColumn(Ui, CSz(" ----- LAYERS -----")); + PushNewRow(Ui); + PushNewRow(Ui); - Chunk->Flags = Chunk_Queued; + /* DoEditorUi(Ui, BrushSettingsWindow, &LayeredBrush->BrushFollowsCursor, CSz("BrushFollowsCursor"), &DefaultUiRenderParams_Checkbox); */ + /* PushNewRow(Ui); */ + /* PushNewRow(Ui); */ + } - InitializeChunkWithNoise( NoiseFunc, - GetThreadLocalState(ThreadLocal_ThreadIndex), - Chunk, - Cast(void*, &NoiseParams), - ChunkInitFlag_Noop, - UserData, - True, - Settings->NoiseBasisOffset + V3i(GetAbsoluteP(Editor->SelectionRegion.Min, GetWorldChunkDim()))); - } break; - } + } - SyncGpuBuffersAsync(Engine, &Chunk->Meshes); - } + { + s32 EditLayerIndex = 0; + ui_brush_layer_actions BrushLayerAction = {}; - if (Preview->Thumbnail.Texture.ID) // NOTE(Jesse): Avoid spamming a warning to console - { - RenderToTexture_Async(&Plat->RenderQ, Engine, &Preview->Thumbnail, &Chunk->Meshes, V3(Chunk->Dim)/-2.f, 0); - } + PushTableStart(Ui); - return UpdateVoxels; -} + brush_layer *BrushLayers = Brush->Layered.Layers; + RangeIterator(LayerIndex, LayeredBrush->LayerCount) + { + brush_layer *BrushLayer = BrushLayers + LayerIndex; -link_internal void -BrushSettingsForShapeBrush(engine_resources *Engine, window_layout *Window, shape_layer *Layer) -{ - UNPACK_ENGINE_RESOURCES(Engine); + ui_id ToggleId = UiId(BrushSettingsWindow, "brush_layer toggle interaction", u32(LayerIndex), ThisHash); + cs LayerDetails = GetLayerUiText(BrushLayer, GetTranArena()); - DoEditorUi(Ui, Window, &Layer->Type, CSz("ShapeType")); + if (ToggleButton(Ui, FSz("v %d %S", LayerIndex, LayerDetails), FSz("> %d %S", LayerIndex, LayerDetails), ToggleId)) + { + PushNewRow(Ui); - v3 SelectionDim = GetDim(GetSelectionRect(World, Editor)); - switch (Layer->Type) - { - case ShapeType_None: { } break; - case ShapeType_Rect: - { - DoEditorUi(Ui, Window, &Layer->Rect, CSz("")); - } break; + auto ActionsToolbarRef = PushTableStart(Ui); + ui_toggle_button_group Toolbar = PushToolbar(Ui, BrushSettingsWindow, CSz(""), &BrushLayerAction, u64(LayerIndex), &DefaultUiRenderParams_Toolbar, ToggleButtonGroupFlags_DrawVertical); + if (Toolbar.AnyElementClicked) + { + EditLayerIndex = LayerIndex; - case ShapeType_Sphere: - { - DoEditorUi(Ui, Window, &Layer->Sphere, CSz("")); - } break; - } + if (BrushLayerAction == UiBrushLayerAction_Delete) { SetToggleButton(Ui, ToggleId, False); } -} + b32 ThisState = GetToggleState(Ui, ToggleId); -link_internal void -BrushSettingsForNoiseBrush(engine_resources *Engine, window_layout *Window, noise_layer *Layer, chunk_thumbnail *Preview) -{ - UNPACK_ENGINE_RESOURCES(Engine); + if (BrushLayerAction == UiBrushLayerAction_MoveUp) + { + ui_id NextId = ToggleId; + NextId.ElementBits -= 1; + b32 NextState = GetToggleState(Ui, NextId); - PushTableStart(Ui); - if (SelectionComplete(Editor->SelectionClicks)) - { - DoEditorUi(Ui, Window, &Layer->Type, CSz("NoiseType"), &DefaultUiRenderParams_Generic); - PushTableStart(Ui); // TODO(Jesse): Necessary? - switch (Layer->Type) - { - case NoiseType_White: + SetToggleButton(Ui, ToggleId, NextState); + SetToggleButton(Ui, NextId, ThisState); + } + + if (BrushLayerAction == UiBrushLayerAction_MoveDown) + { + ui_id NextId = ToggleId; + NextId.ElementBits += 1; + b32 NextState = GetToggleState(Ui, NextId); + + SetToggleButton(Ui, ToggleId, NextState); + SetToggleButton(Ui, NextId, ThisState); + } + + } + PushTableEnd(Ui); + + PushTableStart(Ui, Position_RightOf, ActionsToolbarRef); + OPEN_INDENT_FOR_TOGGLEABLE_REGION(); + DoEditorUi(Ui, BrushSettingsWindow, BrushLayer, {}, ThisHash); + CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); + PushTableEnd(Ui); + } + else + { + DoColorSwatch(Ui, V2(20), HSVtoRGB(BrushLayer->Settings.HSVColor)); + } + + if (IsNewBrush && LayerIndex == 0) + { + SetToggleButton(Ui, ToggleId, True); + } + + PushNewRow(Ui); + } + PushTableEnd(Ui); + + if (BrushLayerAction == UiBrushLayerAction_MoveUp) { - DoEditorUi(Ui, Window, &Layer->White, CSz("")); - } break; + if (EditLayerIndex > 0) + { + brush_layer *BrushLayer = BrushLayers + EditLayerIndex; + brush_layer Tmp = BrushLayers[EditLayerIndex-1]; + BrushLayers[EditLayerIndex-1].Settings = BrushLayer->Settings; + BrushLayer->Settings = Tmp.Settings; + } + } - case NoiseType_Perlin: + if (BrushLayerAction == UiBrushLayerAction_MoveDown) { - DoEditorUi(Ui, Window, &Layer->Perlin, CSz("")); - } break; + if (LayeredBrush->LayerCount) + { + if (EditLayerIndex < LayeredBrush->LayerCount-1) + { + brush_layer *BrushLayer = BrushLayers + EditLayerIndex; + brush_layer Tmp = BrushLayers[EditLayerIndex+1]; + BrushLayers[EditLayerIndex+1].Settings = BrushLayer->Settings; + BrushLayer->Settings = Tmp.Settings; + } + } + } - case NoiseType_Voronoi: + if (BrushLayerAction == UiBrushLayerAction_Duplicate) { - DoEditorUi(Ui, Window, &Layer->Voronoi, CSz("")); - } break; + if (LayeredBrush->LayerCount < MAX_BRUSH_LAYERS) + { + LayeredBrush->LayerCount += 1; + + // Shuffle layers forward. This conveniently duplicates the EditLayerIndex + RangeIteratorReverseRange(LayerIndex, MAX_BRUSH_LAYERS, EditLayerIndex+1) + { + BrushLayers[LayerIndex].Settings = BrushLayers[LayerIndex-1].Settings; + } + } + } + + if (BrushLayerAction == UiBrushLayerAction_Delete) + { + // NOTE(Jesse): Not an `if` because we shouldn't be able to ask to + // delete a layer if there aren't any to delete! + Assert(LayeredBrush->LayerCount > 0); + + // Shuffle layers backwards, overwriting EditLayerIndex + RangeIteratorRange(LayerIndex, MAX_BRUSH_LAYERS, EditLayerIndex+1) + { + Assert(LayerIndex >= 0 && LayerIndex < MAX_BRUSH_LAYERS); + BrushLayers[LayerIndex-1].Settings = BrushLayers[LayerIndex].Settings; + } + + LayeredBrush->LayerCount -= 1; + } } - PushTableEnd(Ui); - } - else - { - PushColumn(Ui, CSz("Make a selection to use Noise Brush")); - PushNewRow(Ui); + } + } - PushTableEnd(Ui); + } + PushWindowEnd(Ui, BrushSettingsWindow); } -link_internal void -DoSettingsForBrushLayer(engine_resources *Engine, brush_layer *Layer, chunk_thumbnail *Preview, window_layout *Window) +link_internal aabb_intersect_result +EditWorldSelection(engine_resources *Engine) { UNPACK_ENGINE_RESOURCES(Engine); - brush_settings *Settings = &Layer->Settings; + auto PrevRegion = Editor->Selection.Region; - OPEN_INDENT_FOR_TOGGLEABLE_REGION(); - - PushNewRow(Ui); - DoEditorUi(Ui, Window, &Settings->Type, CSz("Type"), &DefaultUiRenderParams_Generic); + aabb_intersect_result AABBTest = {}; + Editor->Selection.InitialSelect = False; + Editor->Selection.Diff = {}; - switch (Layer->Settings.Type) + aabb TotalEditAreas = InvertedInfinityRectangle_rect3(); + // NOTE(Jesse): We can't predicate this because when we deselect everything + // we want this to automagically resize + /* if (AtElements(&Editor->SelectedEditIndices).Index) */ { - case BrushLayerType_Noise: - { - BrushSettingsForNoiseBrush(Engine, Window, &Settings->Noise, Preview); - } break; - - case BrushLayerType_Shape: + IterateOver(&Editor->SelectedEditIndices, EditIndex, EditIndexIndex) { - BrushSettingsForShapeBrush(Engine, Window, &Settings->Shape); - } break; + world_edit *Edit = GetPtr(&Editor->Edits, *EditIndex); + aabb EditAABB = GetSimSpaceRect(World, Edit->Region); + TotalEditAreas = Union(&TotalEditAreas, &EditAABB); + } + Editor->Selection.Region = SimSpaceToCanonical(World, &TotalEditAreas); } - // TODO(Jesse): do enum selector for Mode/Modifier/iterations - DoEditorUi(Ui, Window, &Settings->Mode, CSz("Mode")); - DoEditorUi(Ui, Window, &Settings->Modifier, CSz("Modifier")); - if (Settings->Modifier == WorldEdit_Modifier_Surface || Settings->Modifier == WorldEdit_Modifier_Flood) + if (Count(&Editor->SelectedEditIndices) == 0) { - DoEditorUi(Ui, Window, &Settings->Iterations, CSz("Iterations")); - PushNewRow(Ui); // Primitives require a new row.. I forget why, but there's a good reason. + Editor->Selection.ModMode = SelectionModificationMode_None; } - DoEditorUi(Ui, Window, &Settings->Offset, CSz("Dilation")); - DoEditorUi(Ui, Window, &Settings->NoiseBasisOffset, CSz("Basis"), &DefaultUiRenderParams_Generic); - DoEditorUi(Ui, Window, &Settings->Invert, CSz("Invert"), &DefaultUiRenderParams_Generic); - PushNewRow(Ui); + switch (Editor->Selection.ModMode) + { + case SelectionModificationMode_None: + { + Assert(Count(&Editor->SelectedEditIndices) == 0); + } break; - // NOTE(Jesse): These are only stricly necessary if Modifier is Flood or Surface .. do we care? - /* Settings->Offset.Min = Min(V3i(-Settings->Iterations), Settings->Offset.Min); */ - /* Settings->Offset.Max = Max(V3i( Settings->Iterations), Settings->Offset.Max); */ + case SelectionModificationMode_Initialize: + { + Assert(SelectionIncomplete(Editor->Selection.Clicks)); + Assert(Count(&Editor->SelectedEditIndices) == 1); - { - ui_style Style = UiStyleFromLightestColor(Settings->RGBColor); - PushUntexturedQuad(Ui, {}, V2(Global_Font.Size.y), zDepth_Text, &Style, DefaultGenericPadding); + // Hot update selection region before we click the second point + // Must come first or we get a frame of lag. + // + if (Engine->MousedOverVoxel.Tag) + { + auto MouseP = Canonical_Position(&Engine->MousedOverVoxel.Value); + MouseP.Offset = Floor(MouseP.Offset); + cp MinP = Min(Editor->Selection.Base, MouseP); + cp MaxP = Max(Editor->Selection.Base, MouseP) + V3(1.f); + /* Assert(MinP <= MaxP); */ + Editor->Selection.Region = RectMinMax(MinP, MaxP); + } - ui_id ColorPickerModalId = UiId(Window, "color modal interaction", Cast(void*, Settings)); + // Update Clicks and initial position + // + if (Input->LMB.Clicked) + { + switch (Editor->Selection.Clicks) + { + case 0: + { + if (Engine->MousedOverVoxel.Tag) + { + Editor->Selection.Clicks += 1; + auto MouseP = Canonical_Position(&Engine->MousedOverVoxel.Value); + MouseP.Offset = Floor(MouseP.Offset); + Editor->Selection.Base = MouseP; + } + } break; - if (Button(Ui, CSz("Set Color"), UiId(Window, "set color interaction", Cast(void*, Settings)))) + case 1: + { + Editor->Selection.Clicks += 1; + Editor->Selection.InitialSelect = True; + Editor->Selection.ModMode = SelectionModificationMode_Modify; + } break; + + InvalidDefaultCase; + } + } + } break; + + case SelectionModificationMode_Modify: { - ToggleModal(Ui, "Color Picker", ColorPickerModalId); - } - PushNewRow(Ui); + Assert(SelectionComplete(Editor->Selection.Clicks)); + Assert(Count(&Editor->SelectedEditIndices) > 0); + // Edit the selection region + // + rect3i ModifiedSelection = {}; + { + // If we're hovering a face and click, set ClickedFace, which is the + // source of truth that signals we're editing the selection region + // + if (Engine->MaybeMouseRay.Tag == Maybe_Yes) + { + ray Ray = Engine->MaybeMouseRay.Ray; - ColorPickerModal(Engine, ColorPickerModalId, &Settings->RGBColor, False); + aabb SelectionAABB = GetSimSpaceRect(World, Editor->Selection.Region); + AABBTest = Intersect(&SelectionAABB, &Ray); + face_index Face = AABBTest.Face; + if (Face) + { + if ( Input->LMB.Clicked && (Input->Shift.Pressed || Input->Alt.Pressed) ) + { + v3 PlaneBaseP = Ray.Origin + (AABBTest.t*Ray.Dir); + Editor->Selection.ModState.ClickedFace = Face; + Editor->Selection.ModState.ClickedP[0] = PlaneBaseP; + } + } - PushNewRow(Ui); - } + // If we're editing the selection region, Compute the proposed modification + // and make it permanent when we release the LMB + // + if (Editor->Selection.ModState.ClickedFace) + { + world_edit_selection_mode SelectionMode = ComputeSelectionMode(Input); + if (SelectionMode) // We could have started a selection edit and released the accelerator key + { + UpdateSelectionStateForFrame( &Ray, Camera, Input, SelectionMode, &Editor->Selection.ModState ); + v3 UpdateVector = {}; + ModifiedSelection = DoSelectonModification(Engine, &Ray, SelectionMode, &Editor->Selection.ModState, SelectionAABB, &UpdateVector); + if (Input->LMB.Pressed == False) + { + // If we actually changed the selection region + rect3cp ProposedSelection = SimSpaceToCanonical(World, &ModifiedSelection); - PushTableStart(Ui); - InteractWithThumbnailTexture(Engine, Ui, Window, "noise preview interaction", &Preview->Thumbnail); - PushNewRow(Ui); - PushTableEnd(Ui); - CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); -} + // Make ModifiedSelection permanent + Editor->Selection.Region = ProposedSelection; + Editor->Selection.Diff = UpdateVector; + } -link_internal void -ApplyBrushLayer(engine_resources *Engine, brush_layer *Layer, chunk_thumbnail *Preview, world_chunk *DestChunk, v3i SmallestMinOffset) -{ - UNPACK_ENGINE_RESOURCES(Engine); + // Draw proposed modification region + // + rect3 ModifiedAABB = Rect3(&ModifiedSelection); + v3 CameraSimP = GetSimSpaceP(World, Camera->CurrentP); + r32 BaseThicc = GetSelectionThicknessForDistance( Distance(CameraSimP, GetCenter(&ModifiedAABB)) ); + DEBUG_DrawSimSpaceAABB(Engine, &ModifiedAABB, RGB_GREEN, BaseThicc*0.75f); + } + } + } - if (LengthSq(DestChunk->Dim) > 0) - { - brush_settings *Settings = &Layer->Settings; + } + } break; + } - world_edit_mode Mode = Settings->Mode; - world_edit_mode_modifier Modifier = Settings->Modifier; + if (Editor->Selection.InitialSelect) { Info("InitialSelect"); } + return AABBTest; +} - rect3i UpdateBounds = {{}, DestChunk->Dim}; +link_internal cp +GetSelectionCenterP(world *World, level_editor *Editor) +{ + v3i Dim = GetSelectionDim(World, Editor); + cp Result = Canonicalize(World, Editor->Selection.Region.Min + V3(Dim/2)); + return Result; +} - world_edit_shape Shape = {}; - switch (Settings->Type) - { - case BrushLayerType_Shape: - { - Shape.Type = world_update_op_shape_type(Settings->Shape.Type); +link_internal v3 +ColorIndexToV3(u16 ColorIndex) +{ + u32 FiveBits = 0b0000000000011111; + u32 SixBits = 0b0000000000111111; - switch (Settings->Shape.Type) - { - case ShapeType_None: { } break; + f32 R = f32((ColorIndex >> 11) & FiveBits) / f32(FiveBits); + f32 G = f32((ColorIndex >> 6) & FiveBits) / f32(FiveBits); + f32 B = f32((ColorIndex >> 0) & SixBits) / f32(SixBits); - case ShapeType_Sphere: - { - Shape.world_update_op_shape_params_sphere = Settings->Shape.Sphere; - Shape.world_update_op_shape_params_sphere.Location.Offset = ((DestChunk->Dim/2.f) - V3(SmallestMinOffset)); - } break; + v3 Result = V3(R,G,B); + return Result; +} - case ShapeType_Rect: - { - Shape.world_update_op_shape_params_rect = Settings->Shape.Rect; - Shape.world_update_op_shape_params_rect.Region.Min -= V3(SmallestMinOffset); - Shape.world_update_op_shape_params_rect.Region.Max -= V3(SmallestMinOffset); - } break; - } +link_internal void +DoColorPickerSection(renderer_2d *Ui, window_layout *Window, u32 ThisHash, v3 *HSVDest, u32 HSVElementIndex, u32 Slices, v2 WidgetDim) +{ + v2 QuadDim = V2(WidgetDim.x/r32(Slices), WidgetDim.y); + v4 Padding = V4(0); + v3 HSV = *HSVDest; - } break; + r32 CurrentValue = HSVDest->E[HSVElementIndex]; - case BrushLayerType_Noise: - { - noise_layer *Noise = &Settings->Noise; - world_chunk *SrcChunk = &Preview->Chunk; - v3i SrcOffsetMin = Settings->Offset.Min; + ui_element_reference SaturationTable = PushTableStart(Ui); + RangeIterator_t(u8, ColorIndex, Slices) + { + r32 Value = r32(ColorIndex)/r32(Slices); - v3i DestRelativeMinCorner = (-1*SmallestMinOffset) + SrcOffsetMin; + HSV.E[HSVElementIndex] = Value; + v3 RGB = HSVtoRGB(HSV); - chunk_data D = {SrcChunk->Flags, SrcChunk->Dim, SrcChunk->Voxels, SrcChunk->VoxelLighting}; - world_update_op_shape_params_chunk_data ChunkDataShape = { D, V3(DestRelativeMinCorner) }; + b32 Selected = Value == CurrentValue; + ui_style Style = FlatUiStyle(RGB); + ui_id Id = UiId( Window, "ColorPicker value button", u32(u64(HSVDest)), ThisHash ^ u32(u64(Cast(void*, u64(ColorIndex) | u64(HSVElementIndex<<16)))) ); - Assert(SrcChunk->Dim <= DestChunk->Dim); + interactable_handle ColorPickerButton = PushButtonStart(Ui, Id); + PushUntexturedQuad(Ui, {}, QuadDim, zDepth_Text, &Style, Padding ); + PushButtonEnd(Ui); - Shape.Type = type_world_update_op_shape_params_chunk_data; - Shape.world_update_op_shape_params_chunk_data = ChunkDataShape; - } break; + b32 ButtonHover = Hover(Ui, &ColorPickerButton); + if (Selected || ButtonHover) + { + f32 BorderDim = 1.f; + v3 BorderColor = V3(1.0f); + PushRelativeBorder(Ui, V2(-1.f,1.f)*QuadDim, BorderColor, V4(BorderDim)); } - v3 SimFloodOrigin = V3(0); + if (ButtonHover) + { + PushTooltip(Ui, FSz("%d %.2V3", ColorIndex, &RGB)); + } - s32 Iterations = Settings->Iterations; - if (Iterations > 1) { Info("%d", Iterations); } - RangeIterator(IterIndex, Iterations) + if (Clicked(Ui, &ColorPickerButton)) { - work_queue_entry_update_world_region Job = WorkQueueEntryUpdateWorldRegion(Mode, Modifier, SimFloodOrigin, &Shape, Layer->Settings.RGBColor, {}, {}, {}, {}, 0); - ApplyUpdateToRegion(GetThreadLocalState(ThreadLocal_ThreadIndex), &Job, UpdateBounds, DestChunk, Layer->Settings.Invert); - DestChunk->FilledCount = MarkBoundaryVoxels_MakeExteriorFaces( DestChunk->Voxels, DestChunk->Dim, {{}}, DestChunk->Dim ); + HSVDest->E[HSVElementIndex] = Value; } } - + PushTableEnd(Ui); + PushNewRow(Ui); } -link_internal v3i -GetSmallestMinOffset(layered_brush_editor *LayeredBrush, v3i *LargestLayerDim) +link_internal void +DoColorPicker(renderer_2d *Ui, window_layout *Window, v3 *HSVDest, b32 ShowColorSwatch, u32 ParentHash) { - v3i SmallestMinOffset = V3i(s32_MAX); - - brush_layer *Layers = LayeredBrush->Layers; - RangeIterator(LayerIndex, LayeredBrush->LayerCount) - { - brush_layer *Layer = Layers + LayerIndex; + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ u32(u64(HSVDest))); - if (LargestLayerDim) { v3i LayerDim = GetLayerDim(Layer); *LargestLayerDim = Max(LayerDim, *LargestLayerDim); } - SmallestMinOffset = Min(Layer->Settings.Offset.Min, SmallestMinOffset); - } + u8 FiveBits = 0b11111; + u8 SixBits = 0b111111; - return SmallestMinOffset; -} + u16 HueSlices = SixBits; + u16 SaturationSlices = FiveBits; + u16 ValueSlices = FiveBits; + v2 ColorPickerSectionDim = V2(256, 30); -link_internal cs -GetFilenameForBrush(cs Name, s32 Version = 0) -{ - cs Result; + DoColorPickerSection(Ui, Window, ThisHash, HSVDest, 0, HueSlices, ColorPickerSectionDim); + DoColorPickerSection(Ui, Window, ThisHash, HSVDest, 1, SaturationSlices, ColorPickerSectionDim); + DoColorPickerSection(Ui, Window, ThisHash, HSVDest, 2, ValueSlices, ColorPickerSectionDim); - if (EndsWith(Name, CSz(".brush"))) { Name.Count -= 6; } + PushNewRow(Ui); - if (Version) - { - Result = FCS(CSz("brushes/%S.%d.brush\0"), Name, Version); - } - else + v3 RGB = HSVtoRGB(*HSVDest); + if (ShowColorSwatch) { - Result = FCS(CSz("brushes/%S.brush\0"), Name); + v2 QuadDim = V2(ColorPickerSectionDim.x, ColorPickerSectionDim.x); + DoColorSwatch(Ui, QuadDim, RGB); } - return Result; + cs HSVColorString = FSz("HSV (%.2V3)", HSVDest); + cs RGBColorString = FSz("RGB (%.2V3)", &RGB); + + PushColumn(Ui, HSVColorString ); + PushNewRow(Ui); + + PushColumn(Ui, RGBColorString ); + PushNewRow(Ui); } link_internal void -SaveBrush(layered_brush_editor *LayeredBrush, const char *FilenameZ) +DoColorPickerToggle(renderer_2d *Ui, window_layout *Window, v3 *HSVDest, b32 ShowColorSwatch, u32 ParentHash) { - u8_cursor_block_array OutputStream = BeginSerialization(); - Serialize(&OutputStream, LayeredBrush); + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ u32(u64(HSVDest))); - if (FinalizeSerialization(&OutputStream, FilenameZ) == False) - { - SoftError("Unable to serialize brush (%s) to file (%s).", LayeredBrush->NameBuf, FilenameZ); - } - else - { - ZeroMemory(LayeredBrush->NameBuf, NameBuf_Len); - cs BrushNameBuf = CS(LayeredBrush->NameBuf, NameBuf_Len); + ui_id InteractionId = UiId(Window, "ColorPicker toggle button", HSVDest, ThisHash); - cs BrushBasename = Basename(CS(FilenameZ)); - CopyString(&BrushBasename, &BrushNameBuf); - } -} + u32 ColumnIndex = StartColumn(Ui); + if (ToggledOn(Ui, InteractionId)) + { + // NOTE(Jesse): Gotta use a discrete button id for this + if (Button(Ui, CSz("Done"), UiId(Window, "ColorPicker toggle close", HSVDest, ThisHash))) { SetToggleButton(Ui, InteractionId, False); } + PushNewRow(Ui); + DoColorPicker(Ui, Window, HSVDest, ShowColorSwatch, ParentHash); + } + else + { + ui_style BStyle = UiStyleFromLightestColor(HSVtoRGB(*HSVDest)); + ToggleButtonStart(Ui, InteractionId, &BStyle); //, Padding, AlignFlags); + v2 Dim = V2(25); + PushUntexturedQuad(Ui, V2(0), Dim, zDepth_Text, &BStyle); + ToggleButtonEnd(Ui); + } + EndColumn(Ui, ColumnIndex); + PushNewRow(Ui); +} -link_internal void -NewBrush(layered_brush_editor *LayeredBrush) +link_internal b32 +CheckSettingsChanged(layered_brush *Brush) { - cs BrushNameBuf = CS(LayeredBrush->NameBuf, NameBuf_Len); - brush_layer *Layers = LayeredBrush->Layers; - - ZeroMemory(LayeredBrush->NameBuf, NameBuf_Len); - - cs Src = CSz("_untitled.brush"); - CopyString(&Src, &BrushNameBuf); + b32 Result = False; + RangeIterator(LayerIndex, Brush->LayerCount) + { + brush_layer *Layer = Brush->Layers + LayerIndex; + Result |= !AreEqual(&Layer->Settings, &Layer->PrevSettings); + Layer->PrevSettings = Layer->Settings; + } + return Result; +} - LayeredBrush->LayerCount = 1; - RangeIterator(LayerIndex, MAX_BRUSH_LAYERS) +link_internal b32 +CheckSettingsChanged(world_edit *Edit) +{ + b32 Result = False; + if (Edit->Brush) { - brush_layer *Layer = Layers + LayerIndex; - Layer->Settings = {}; + Result = CheckSettingsChanged(&Edit->Brush->Layered); } + return Result; } link_internal void -BrushSettingsForLayeredBrush(engine_resources *Engine, window_layout *BrushSettingsWindow) +ApplyEditToOctree(engine_resources *Engine, world_edit *Edit, memory_arena *TempMemory) { UNPACK_ENGINE_RESOURCES(Engine); + Assert(Edit->Tombstone == False); - layered_brush_editor *LayeredBrush = &Editor->LayeredBrushEditor; - brush_layer *Layers = LayeredBrush->Layers; - chunk_thumbnail *Previews = LayeredBrush->LayerPreviews; + Info("Applying Edit(%p) to Octree", Edit); - cs BrushNameBuf = CS(LayeredBrush->NameBuf, NameBuf_Len); + // Gather newly overlapping nodes and add the edit - b32 IsNewBrush = False; - if (LayeredBrush->NameBuf[0] == 0 && LayeredBrush->LayerCount == 0) { - NewBrush(LayeredBrush); - IsNewBrush = True; - } + octree_node_ptr_block_array Nodes = OctreeNodePtrBlockArray(TempMemory); - { - PushWindowStart(Ui, BrushSettingsWindow); - memory_arena *Tran = GetTranArena(); + rect3cp QueryRegion = Edit->Region; - if (LayeredBrush->LayerCount) - { - if (Button(Ui, CSz("Save"), UiId(BrushSettingsWindow, "brush save", 0u))) - { - cs BrushFilepath = GetFilenameForBrush(CS(LayeredBrush->NameBuf)); - SaveBrush(LayeredBrush, BrushFilepath.Start); - } - - if (Button(Ui, CSz("Duplicate"), UiId(BrushSettingsWindow, "brush dup", 0u))) - { - cs_buffer Pieces = Split( CS(LayeredBrush->NameBuf), '.', Tran); - if (Pieces.Count > 2) - { - cs BrushNameString = Pieces.Start[0]; - cs VersionString = Pieces.Start[Pieces.Count-2]; - - s32 VersionNumber; - if ( ParseInteger(VersionString, &VersionNumber) ) - { - cs BrushFilepath = GetFilenameForBrush(BrushNameString, VersionNumber); - while (FileExists(BrushFilepath.Start)) - { - ++VersionNumber; - BrushFilepath = GetFilenameForBrush(BrushNameString, VersionNumber); - } + // NOTE(Jesse): +#if 0 + { + QueryRegion.Min.Offset -= 1.f; + QueryRegion.Max.Offset += 1.f; - SaveBrush(LayeredBrush, BrushFilepath.Start); - } - } - else - { - cs BrushFilepath = GetFilenameForBrush(CS(LayeredBrush->NameBuf), 1); - SaveBrush(LayeredBrush, BrushFilepath.Start); - } - } + Canonicalize(World, &QueryRegion.Min); + Canonicalize(World, &QueryRegion.Max); } +#endif + GatherOctreeNodesOverlapping_Recursive(World, &World->Root, &QueryRegion, &Nodes); - ui_id ImportToggleId = UiId(BrushSettingsWindow, "brush import", 0u); - if (ToggleButton(Ui, CSz("Import"), CSz("Import"), ImportToggleId)) + IterateOver(&Nodes, Node, NodeIndex) { - PushNewRow(Ui); + AcquireFutex(&Node->Lock); - filtered_file_traversal_helper_params HelperParams = {BrushSettingsWindow, 0}; - maybe_file_traversal_node ClickedFileNode = PlatformTraverseDirectoryTreeUnordered(CSz("brushes"), EngineDrawFileNodesFilteredHelper, u64(&HelperParams) ); + /* auto EditAABB = GetSimSpaceAABB(World, Node); */ + /* random_series S = {u64(Node)}; */ + /* v3 BaseColor = RandomV3Unilateral(&S); */ + /* DEBUG_DrawSimSpaceAABB(Engine, &EditAABB, BaseColor, 1.f); */ - if (ClickedFileNode.Tag) { - cs Filename = Concat(ClickedFileNode.Value.Dir, CSz("/"), ClickedFileNode.Value.Name, Tran); - u8_cursor Bytes = BeginDeserialization(Filename, Tran); - if (Deserialize(&Bytes, &Editor->LayeredBrushEditor, Tran) == False) - { - SoftError("While deserializing brush (%S).", Filename); - Editor->LayeredBrushEditor = {}; - } - FinalizeDeserialization(&Bytes); - - // NOTE(Jesse): This has to happen after deserialization cause some - // brushes got saved out with a name, which gets read back in.. - ZeroMemory(LayeredBrush->NameBuf, NameBuf_Len); - CopyString(&ClickedFileNode.Value.Name, &BrushNameBuf); - - SetToggleButton(Ui, ImportToggleId, False); + // Shouldn't have this edit already attached .. + world_edit_ptr_block_array_index Index = Find(&Node->Edits, Edit); + Assert( IsValid(&Index) == False ); } - } - else - { - if (Button(Ui, CSz("New"), UiId(BrushSettingsWindow, "brush new", 0u))) + if (Node->Edits.Memory == 0) { - NewBrush(LayeredBrush); - IsNewBrush = True; + Node->Edits = WorldEditPtrBlockArray(Editor->Memory); } - if (LayeredBrush->LayerCount) - { - PushNewRow(Ui); - PushNewRow(Ui); - - { - ui_id TextBoxId = UiId(BrushSettingsWindow, "name_buf_textbox", LayeredBrush->NameBuf); - cs NameBuf = CS(LayeredBrush->NameBuf); - TextBox(Ui, CSz("BrushName"), NameBuf, NameBuf_Len, TextBoxId); - PushNewRow(Ui); - - DoEditorUi(Ui, BrushSettingsWindow, &LayeredBrush->LayerCount, CSz("Layer Count"), &DefaultUiRenderParams_Generic); - // Clamp LayerCount to (1,MAX_BRUSH_LAYERS) once it's set - LayeredBrush->LayerCount = Max(LayeredBrush->LayerCount, 1); - LayeredBrush->LayerCount = Min(LayeredBrush->LayerCount, MAX_BRUSH_LAYERS); - PushNewRow(Ui); - PushNewRow(Ui); - } - - { - DoEditorUi(Ui, BrushSettingsWindow, &LayeredBrush->Mode, CSz("Mode"), &DefaultUiRenderParams_Generic); - DoEditorUi(Ui, BrushSettingsWindow, &LayeredBrush->Modifier, CSz("Modifier"), &DefaultUiRenderParams_Generic); - PushNewRow(Ui); - } - - { - DoEditorUi(Ui, BrushSettingsWindow, &LayeredBrush->SeedBrushWithSelection, CSz("SeedBrushWithSelection"), &DefaultUiRenderParams_Checkbox); - PushNewRow(Ui); - - DoEditorUi(Ui, BrushSettingsWindow, &LayeredBrush->BrushFollowsCursor, CSz("BrushFollowsCursor"), &DefaultUiRenderParams_Checkbox); - PushNewRow(Ui); - PushNewRow(Ui); - } + Push(&Node->Edits, Edit); - } + Node->Dirty = True; + ReleaseFutex(&Node->Lock); } } +} +#if BONSAI_INTERNAL +link_internal void +SanityCheckOctreeDoesNotContainEdit_Recursive(world *World, octree_node *Current, world_edit *Edit) +{ + Assert(Current); - if (SelectionComplete(Editor->SelectionClicks)) + IterateOver(&Current->Edits, TestEdit, EditIndex) { - b32 AnyChanges = False; - RangeIterator(LayerIndex, LayeredBrush->LayerCount) - { - brush_layer *Layer = Layers + LayerIndex; - chunk_thumbnail *Preview = Previews + LayerIndex; - AnyChanges |= CheckForChangesAndUpdate_ThenRenderToPreviewTexture(Engine, Layer, Preview); - } - - if (AnyChanges) - { - Editor->RootChunkNeedsNewMesh = True; - Editor->MostRecentSelectionRegionMin = Editor->SelectionRegion.Min; - } + Assert(Edit != TestEdit); } - - - + switch(Current->Type) { - /* local_persist window_layout LayersWindow = WindowLayout("Layers", WindowLayoutFlag_Align_Right); */ - /* PushWindowStart(Ui, BrushSettingsWindow); */ + InvalidCase(OctreeNodeType_Undefined); - // NOTE(Jesse): Debug -#if 0 - if (LayeredBrush->SeedBrushWithSelection) + case OctreeNodeType_Leaf: { - PushTableStart(Ui); - world_chunk *SeedChunk = &LayeredBrush->SeedLayer.Chunk; - chunk_thumbnail *SeedPreview = &LayeredBrush->SeedLayer; - if (SeedPreview->Thumbnail.Texture.ID) { RenderToTexture_Async(&Plat->RenderQ, Engine, &SeedPreview->Thumbnail, &SeedChunk->Meshes, V3(SeedChunk->Dim)/-2.f, 0); } - InteractWithThumbnailTexture(Engine, Ui, BrushSettingsWindow, "seed preview interaction", &Editor->LayeredBrushEditor.SeedLayer.Thumbnail); - PushNewRow(Ui); - PushTableEnd(Ui); - - PushTableStart(Ui); - world_chunk *Root_LayeredBrushPreview = &LayeredBrush->Preview.Chunk; - if (SeedPreview->Thumbnail.Texture.ID) { RenderToTexture_Async(&Plat->RenderQ, Engine, &LayeredBrush->Preview.Thumbnail, &Root_LayeredBrushPreview->Meshes, V3(Root_LayeredBrushPreview->Dim)/-2.f, 0); } - InteractWithThumbnailTexture(Engine, Ui, BrushSettingsWindow, "root preview interaction", &Editor->LayeredBrushEditor.Preview.Thumbnail); - PushNewRow(Ui); - PushTableEnd(Ui); - } -#endif + } break; + case OctreeNodeType_Branch: { + SanityCheckOctreeDoesNotContainEdit_Recursive(World, Current->Children[0], Edit); + SanityCheckOctreeDoesNotContainEdit_Recursive(World, Current->Children[1], Edit); + SanityCheckOctreeDoesNotContainEdit_Recursive(World, Current->Children[2], Edit); + SanityCheckOctreeDoesNotContainEdit_Recursive(World, Current->Children[3], Edit); + SanityCheckOctreeDoesNotContainEdit_Recursive(World, Current->Children[4], Edit); + SanityCheckOctreeDoesNotContainEdit_Recursive(World, Current->Children[5], Edit); + SanityCheckOctreeDoesNotContainEdit_Recursive(World, Current->Children[6], Edit); + SanityCheckOctreeDoesNotContainEdit_Recursive(World, Current->Children[7], Edit); + } break; + } +} +#endif - { - b32 ReorderUp = False; - b32 ReorderDown = False; - b32 Duplicate = False; - b32 Delete = False; - s32 EditLayerIndex = 0; - PushTableStart(Ui); - RangeIterator(LayerIndex, LayeredBrush->LayerCount) - { - brush_layer *Layer = Layers + LayerIndex; - chunk_thumbnail *Preview = Previews + LayerIndex; - - ui_id ToggleId = UiId(BrushSettingsWindow, "brush_layer toggle interaction", Layer); - if (ToggleButton(Ui, FSz("v Layer %d", LayerIndex), FSz("> Layer %d", LayerIndex), ToggleId)) - { - if (Button(Ui, CSz("Up"), UiId(BrushSettingsWindow, "layer_reorder_up", Layer))) - { - ReorderUp = True; - EditLayerIndex = LayerIndex; - } +link_internal void +DropEditFromOctree(engine_resources *Engine, world_edit *Edit, memory_arena *TempMemory) +{ + UNPACK_ENGINE_RESOURCES(Engine); + Assert(Edit->Tombstone == False); - if (Button(Ui, CSz("Down"), UiId(BrushSettingsWindow, "layer_reorder_down", Layer))) - { - ReorderDown = True; - EditLayerIndex = LayerIndex; - } + octree_node_ptr_block_array Nodes = OctreeNodePtrBlockArray(TempMemory); - if (Button(Ui, CSz("Dup"), UiId(BrushSettingsWindow, "layer_duplicate", Layer))) - { - Duplicate = True; - EditLayerIndex = LayerIndex; - } + rect3cp QueryRegion = Edit->Region; - if (Button(Ui, CSz("Del"), UiId(BrushSettingsWindow, "layer_delete", Layer))) - { - Delete = True; - EditLayerIndex = LayerIndex; - } - DoSettingsForBrushLayer(Engine, Layer, Preview, BrushSettingsWindow); - } + // NOTE(Jesse): +#if 0 + { + QueryRegion.Min.Offset -= 1.f; + QueryRegion.Max.Offset += 1.f; - if (IsNewBrush && LayerIndex == 0) - { - SetToggleButton(Ui, ToggleId, True); - } + Canonicalize(World, &QueryRegion.Min); + Canonicalize(World, &QueryRegion.Max); + } +#endif - PushNewRow(Ui); - } - PushTableEnd(Ui); + GatherOctreeNodesOverlapping_Recursive(World, &World->Root, &QueryRegion, &Nodes); - if (ReorderUp) - { - if (EditLayerIndex > 0) - { - brush_layer *Layer = Layers + EditLayerIndex; - brush_layer Tmp = Layers[EditLayerIndex-1]; - Layers[EditLayerIndex-1].Settings = Layer->Settings; - Layer->Settings = Tmp.Settings; - } - } - if (ReorderDown) - { - if (LayeredBrush->LayerCount) - { - if (EditLayerIndex < LayeredBrush->LayerCount-1) - { - brush_layer *Layer = Layers + EditLayerIndex; - brush_layer Tmp = Layers[EditLayerIndex+1]; - Layers[EditLayerIndex+1].Settings = Layer->Settings; - Layer->Settings = Tmp.Settings; - } - } - } + IterateOver(&Nodes, Node, NodeIndex) + { + AcquireFutex(&Node->Lock); + auto Index = Find(&Node->Edits, Edit); + Assert(IsValid(&Index)); // There shouldn't be a node that doesn't contain the edit + RemoveUnordered(&Node->Edits, Index); + + // Need to reinitialize chunks that no longer have the edit so that it + // doesn't stay intact in chunks that lose it entirely + Node->Dirty = True; + ReleaseFutex(&Node->Lock); + } - if (Duplicate) - { - if (LayeredBrush->LayerCount < MAX_BRUSH_LAYERS) - { - LayeredBrush->LayerCount += 1; +#if BONSAI_INTERNAL + SanityCheckOctreeDoesNotContainEdit_Recursive(World, &World->Root, Edit); +#endif +} - // Shuffle layers forward. This conveniently duplicates the EditLayerIndex - RangeIteratorReverseRange(LayerIndex, MAX_BRUSH_LAYERS, EditLayerIndex+1) - { - Layers[LayerIndex].Settings = Layers[LayerIndex-1].Settings; - } - } - } +link_internal void +UpdateWorldEditBounds(engine_resources *Engine, world_edit *Edit, rect3cp Region, memory_arena *TempMemory) +{ + Assert(Edit->Tombstone == False); - if (Delete) - { - if (LayeredBrush->LayerCount < MAX_BRUSH_LAYERS) - { - // Shuffle layers backwards, overwriting EditLayerIndex - RangeIteratorRange(LayerIndex, MAX_BRUSH_LAYERS, EditLayerIndex+1) - { - Layers[LayerIndex-1].Settings = Layers[LayerIndex].Settings; - } + DropEditFromOctree(Engine, Edit, TempMemory); + Edit->Region = Region; + ApplyEditToOctree(Engine, Edit, TempMemory); +} - LayeredBrush->LayerCount -= 1; - } - } - } +link_internal void +ReapplyEditToOctree(engine_resources *Engine, world_edit *Edit, memory_arena *TempMemory) +{ + // TODO(Jesse): Is there a better way to do this, or do we even care? + UpdateWorldEditBounds(Engine, Edit, Edit->Region, TempMemory); +} - { - world_chunk *Root_LayeredBrushPreview = &LayeredBrush->Preview.Chunk; - Assert( (Root_LayeredBrushPreview->Flags&Chunk_Queued) == False ); +#if 0 - // - // TODO(Jesse)(async, speed): It would be kinda nice if this ran async.. - if ( Editor->RootChunkNeedsNewMesh ) - { - // TODO(Jesse): Shouldn't the LargestLayerDim take into account the largest Offset too..? - v3i LargestLayerDim = GetSelectionDim(World, Editor) + 2; - v3i SmallestMinOffset = GetSmallestMinOffset(LayeredBrush, &LargestLayerDim); - /* if (SmallestMinOffset == V3i(0)) */ - /* {SmallestMinOffset = V3i(1);} */ - - // Clear the voxels if the size didn't change, otherwise realloc - if (Root_LayeredBrushPreview->Dim == LargestLayerDim) - { - // TODO(Jesse): Actually necessary?? I think maybe not - ClearChunkVoxels(Root_LayeredBrushPreview->Voxels, Root_LayeredBrushPreview->Dim); - } - else - { - // @editor_chunk_memory_question - AllocateWorldChunk(Root_LayeredBrushPreview, {}, LargestLayerDim, Editor->Memory); - } +link_internal void +IncrementAllEditOrdinalsAbove(world_edit_block_array *Edits, u32 Ordinal) +{ + IterateOver(Edits, Edit, EditIndex) + { + if (Edit->Ordinal >= Ordinal) + { + if (Edit->Ordinal == EDIT_ORDINAL_TOMBSTONE) { continue; } + ++Edit->Ordinal; + } + } +} - world_chunk *SeedChunk = &LayeredBrush->SeedLayer.Chunk; - if (SeedChunk->Dim == LargestLayerDim) - { - ClearChunkVoxels(SeedChunk->Voxels, SeedChunk->Dim); - } - else - { - AllocateWorldChunk(SeedChunk, {}, LargestLayerDim, Editor->Memory); - } +// NOTE(Jesse): @duplicated_edit_ordinal_sort_code +link_internal sort_key_buffer +GetEditsSortedByOrdianl(world_edit_block_array *Edits, memory_arena *TempMem) +{ + umm EditCount = TotalElements(Edits); + sort_key *Keys = Allocate(sort_key, TempMem, EditCount); + IterateOver(Edits, Edit, EditIndex) + { + u32 KeyIndex = u32(GetIndex(&EditIndex)); + Keys[KeyIndex] = {u64(Edit), u64(Edit->Ordinal)}; + } + BubbleSort_descending(Keys, u32(EditCount)); -#if 1 - auto Thread = GetThreadLocalState(ThreadLocal_ThreadIndex); - if (LayeredBrush->SeedBrushWithSelection) - { - if (SelectionComplete(Editor->SelectionClicks)) - { - rect3cp GatherRegion = Editor->SelectionRegion; - GatherRegion.Min.Offset -= V3(1); - GatherRegion.Max.Offset += V3(1); - Canonicalize(World, &GatherRegion.Min); - Canonicalize(World, &GatherRegion.Max); - - world_chunk Seed = GatherVoxelsOverlappingArea(Engine, GatherRegion, GetTranArena()); - /* CopyChunkOffset(&Seed, Seed.Dim, Root_LayeredBrushPreview, Root_LayeredBrushPreview->Dim, -1*SmallestMinOffset); */ - CopyChunkOffset(&Seed, Seed.Dim, SeedChunk, SeedChunk->Dim, {}); - - /* // NOTE(Jesse): Zero out everything on the exterior edge */ - /* RangeIterator (z, SeedChunk->Dim.z) */ - /* RangeIterator (y, SeedChunk->Dim.y) */ - /* RangeIterator (x, SeedChunk->Dim.x) */ - /* { */ - /* if (z == 0 || y == 0 || x == 0 || */ - /* z == (SeedChunk->Dim.z-1) || y == (SeedChunk->Dim.y-1) || x == (SeedChunk->Dim.x-1)) */ - /* /1* if (z == 0 || y == 0 || x == 0) *1/ */ - /* { */ - /* s32 Index = GetIndex(x,y,z, SeedChunk->Dim); */ - /* SeedChunk->Voxels[Index] = {}; */ - /* } */ - /* } */ - - MarkBoundaryVoxels_MakeExteriorFaces(SeedChunk->Voxels, SeedChunk->Dim, {}, SeedChunk->Dim); - - FinalizeChunkInitialization(SeedChunk); - - data_type Type = GetMeshDatatypeForDimension(SeedChunk->Dim); - auto *TempMesh = AllocateTempMesh(Thread->TempMemory, Type); - RebuildWorldChunkMesh(Thread, SeedChunk, {}, SeedChunk->Dim, MeshBit_Lod0, TempMesh, Thread->TempMemory); - SyncGpuBuffersAsync(Engine, &SeedChunk->Meshes); - - CopyChunkOffset(SeedChunk, SeedChunk->Dim, Root_LayeredBrushPreview, Root_LayeredBrushPreview->Dim, {}); - } - } + return {EditCount, Keys}; +} #endif - RangeIterator(LayerIndex, LayeredBrush->LayerCount) - { - brush_layer *Layer = Layers + LayerIndex; - chunk_thumbnail *Preview = Previews + LayerIndex; - ApplyBrushLayer(Engine, Layer, Preview, Root_LayeredBrushPreview, SmallestMinOffset+V3i(-1)); - } - - FinalizeChunkInitialization(Root_LayeredBrushPreview); - { - auto Chunk = Root_LayeredBrushPreview; - - data_type Type = GetMeshDatatypeForDimension(Chunk->Dim); - auto *TempMesh = AllocateTempMesh(Thread->TempMemory, Type); +link_internal void +ApplyDiffToEditBuffer(engine_resources *Engine, v3 Diff, world_edit_block_array_index_block_array *Edits, world_edit_selection_mode SelectionMode) +{ + UNPACK_ENGINE_RESOURCES(Engine); - MarkBoundaryVoxels_MakeExteriorFaces(Root_LayeredBrushPreview->Voxels, Root_LayeredBrushPreview->Dim, {}, Root_LayeredBrushPreview->Dim-V3i(2)); + IterateOver(Edits, EditI, EditII) + { + world_edit *Edit = GetPtr(&Editor->Edits, *EditI); - RebuildWorldChunkMesh(Thread, Chunk, {}, Chunk->Dim, MeshBit_Lod0, TempMesh, Thread->TempMemory); - } + Assert(Engine->MaybeMouseRay.Tag == Maybe_Yes); + ray *Ray = &Engine->MaybeMouseRay.Ray; + aabb SelectionAABB = GetSimSpaceAABB(World, &Edit->Region); + rect3i ModifiedSelection = DoSelectonModification(Engine, Ray, SelectionMode, &Editor->Selection.ModState, SelectionAABB); - Editor->RootChunkNeedsNewMesh = False; - Editor->NextSelectionRegionMin = Editor->MostRecentSelectionRegionMin; + rect3cp NewRegion = SimSpaceToCanonical(World, &ModifiedSelection); + UpdateWorldEditBounds(Engine, Edit, NewRegion, GetTranArena()); + } +} - if (SyncGpuBuffersAsync(Engine, &Root_LayeredBrushPreview->Meshes)) - { - Editor->EditorPreviewRegionMin = Editor->NextSelectionRegionMin; - } - } +link_internal void +DeleteEdit(engine_resources *Engine, world_edit *Edit, world_edit_block_array_index *EditIndex, world_edit_layer *Layer = 0) +{ + Assert(Edit->Tombstone == False); + level_editor *Editor = &Engine->Editor; + DropEditFromOctree(Engine, Edit, GetTranArena()); - } - } + umm SelIndex = IndexOfValue(&Editor->SelectedEditIndices, EditIndex).Index; + if (SelIndex != INVALID_BLOCK_ARRAY_INDEX) + { + RemoveUnordered(&Editor->SelectedEditIndices, {SelIndex}); + } - PushWindowEnd(Ui, BrushSettingsWindow); + if (Layer) + { + RemoveOrdered(&Layer->EditIndices, EditIndex); } + + *Edit = {}; + Edit->Tombstone = True; } -link_internal void -DoBrushSettingsWindow(engine_resources *Engine, world_edit_tool WorldEditTool, world_edit_brush_type WorldEditBrushType) +link_internal world_edit * +GetClosestEditIntersectingRay(world *World, world_edit_block_array *Edits, ray *Ray, world_edit_block_array_index *ResultIndex = 0) { - UNPACK_ENGINE_RESOURCES(Engine); + world_edit *Result = {}; + world_edit_block_array_index Index = {INVALID_BLOCK_ARRAY_INDEX}; - local_persist window_layout Window = WindowLayout("Brush Settings", WindowLayoutFlag_Align_Right); - switch (WorldEditTool) + r32 tMin = f32_MAX; + IterateOver(Edits, Edit, EditIndex) { - case WorldEdit_Tool_Disabled: - case WorldEdit_Tool_Select: - case WorldEdit_Tool_Eyedropper: - case WorldEdit_Tool_BlitEntity: + aabb Box = GetSimSpaceAABB(World, Edit->Region); + aabb_intersect_result I = Intersect(Box, Ray); + if (I.t < tMin) { - } break; + tMin = I.t; + Result = Edit; + Index = EditIndex; + } + } - case WorldEdit_Tool_Brush: - { - switch (WorldEditBrushType) - { - case WorldEdit_BrushType_Disabled: {} break; - case WorldEdit_BrushType_Single: {} break; - case WorldEdit_BrushType_Entity: {} break; - case WorldEdit_BrushType_Asset: {} break; + if (ResultIndex) + *ResultIndex = Index; - case WorldEdit_BrushType_Layered: - { - BrushSettingsForLayeredBrush(Engine, &Window); - } break; + return Result; +} - } - } break; +link_internal void +DeselectAllEdits(level_editor *Editor) +{ + IterateOver(&Editor->SelectedEditIndices, EI, EII) + { + auto SelEdit = GetPtr(&Editor->Edits, *EI); + SelEdit->Selected = False; } + Editor->SelectedEditIndices.ElementCount = 0; } -link_internal b32 -CurrentToolIs(level_editor *Editor, world_edit_tool Tool, world_edit_brush_type BrushType) +link_internal void +SelectEdit(level_editor *Editor, world_edit *Edit, world_edit_block_array_index EditIndex, b32 MultiSelect = False) { - b32 Result = False; - if (Editor->Tool == Tool) + world_edit_block_array_index_block_array *SelectedEditIndices = &Editor->SelectedEditIndices; + Assert(Edit); + Assert(EditIndex.Index != INVALID_BLOCK_ARRAY_INDEX); + + if (MultiSelect) { - Result = True; - if (Editor->Tool == WorldEdit_Tool_Brush) + if (Edit->Selected) + { + Assert(Edit->Selected == True); + Edit->Selected = False; + + auto I = IndexOfValue(SelectedEditIndices, &EditIndex); + Assert(I.Index != INVALID_BLOCK_ARRAY_INDEX); + RemoveUnordered(SelectedEditIndices, I); + } + else { - Result = (Editor->BrushType == BrushType); + Assert(Edit->Selected == False); + Edit->Selected = True; + Push(SelectedEditIndices, &EditIndex); } } - return Result; + else + { + DeselectAllEdits(Editor); + Push(SelectedEditIndices, &EditIndex); + Edit->Selected = True; + } + + Editor->Selection.Clicks = 2; + Editor->Selection.ModMode = SelectionModificationMode_Modify; } -link_internal aabb_intersect_result -EditWorldSelection(engine_resources *Engine) +link_internal void +DoWorldEditor(engine_resources *Engine) { UNPACK_ENGINE_RESOURCES(Engine); - aabb_intersect_result AABBTest = {}; + Editor->HotEdit = 0; + Editor->HotEditIndex = {INVALID_BLOCK_ARRAY_INDEX}; + + if (Editor->CurrentBrush == 0) + { + world_edit_brush ThisBrush = NewBrush(); + Editor->CurrentBrush = Insert(ThisBrush, &Editor->LoadedBrushes, Editor->Memory); + } - if (Editor->SelectionClicks) + aabb_intersect_result AABBTest = EditWorldSelection(Engine); + + if (Engine->MaybeMouseRay.Tag == Maybe_Yes) { - r32 Thickness = 0.10f; + ray *Ray = &Engine->MaybeMouseRay.Ray; + Editor->HotEdit = GetClosestEditIntersectingRay(World, &Editor->Edits, Ray, &Editor->HotEditIndex); + } + + + + // + // + // Hotkeys + // + // + - if (SelectionIncomplete(Editor->SelectionClicks)) + if (Input->Shift.Pressed || Input->Alt.Pressed) { Ui->RequestedForceCapture = True; } + + if (Input->Ctrl.Pressed && Input->G.Clicked) + { + if (AtElements(&Editor->SelectedEditIndices).Index) { - if (Engine->MousedOverVoxel.Tag) + if (entity *Ghost = GetCameraGhost(Engine)) { - auto MouseP = Canonical_Position(&Engine->MousedOverVoxel.Value); - MouseP.Offset = Floor(MouseP.Offset); - - cp MinP = Min(Editor->SelectionBase, MouseP); - cp MaxP = Max(Editor->SelectionBase, MouseP) + V3(1.f); - /* Assert(MinP <= MaxP); */ - Editor->SelectionRegion = RectMinMax(MinP, MaxP); + Ghost->P = GetSelectionCenterP(World, Editor); } } - else - { - Thickness = 0.20f; - } + } - if (CurrentToolIs(Editor, WorldEdit_Tool_Brush, WorldEdit_BrushType_Layered)) - { - layered_brush_editor *Brush = &Editor->LayeredBrushEditor; - if (Brush->BrushFollowsCursor) - { - if (Engine->MousedOverVoxel.Tag) - { - cp MouseP = Canonical_Position(&Engine->MousedOverVoxel.Value, PickedVoxel_LastEmpty); + if (Input->Ctrl.Pressed && Input->S.Clicked) + { + world_edit_layer *Layer = TryGetSelectedLayer(Editor); + if (Layer == 0) { Layer = NewLayer(Editor); } + + world_edit_block_array_index Index = {}; + auto E = NewEdit(Editor, Layer, &Index); + E->Brush = Editor->CurrentBrush; - v3 SelectionDim = GetDim(GetSimSpaceRect(World, Editor->SelectionRegion)); - v3 SelectionRad = SelectionDim / 2.f; + SelectEdit(Editor, E, Index); + + // NOTE(Jesse): Must come after SelectEdit because it sets the ModMode to Modify + ResetSelection(Editor); + Editor->Selection.ModMode = SelectionModificationMode_Initialize; + } - Editor->SelectionRegion.Min = MouseP - SelectionRad; - Editor->SelectionRegion.Max = MouseP + SelectionRad; - Canonicalize(World, &Editor->SelectionRegion.Min); - Canonicalize(World, &Editor->SelectionRegion.Max); + { // All Brushes Window + local_persist window_layout AllBrushesWindow = WindowLayout("All Brushes", WindowLayoutFlag_Align_BottomRight); + PushWindowStart(Ui, &AllBrushesWindow); - Truncate(&Editor->SelectionRegion.Min.Offset); - Truncate(&Editor->SelectionRegion.Max.Offset); + IterateOver(&Editor->LoadedBrushes, Brush, BrushIndex) + { + if (Brush) + { + ui_style *Style = &DefaultStyle; + if (Brush == Editor->CurrentBrush) + { + Style = &DefaultSelectedStyle; + } + if (Button(Ui, CS(Brush->NameBuf), UiId(&AllBrushesWindow, "brush select", Brush), Style)) + { + Editor->CurrentBrush = Brush; + CheckSettingsChanged(&Brush->Layered); // Prevent firing a change event @prevent_change_event } + PushNewRow(Ui); } } + PushWindowEnd(Ui, &AllBrushesWindow); - aabb SelectionAABB = GetSimSpaceRect(World, Editor->SelectionRegion); + window_layout *BrushSettingsWindow = GetOrCreateWindow(Ui, "Brush Settings", WindowLayoutFlag_Align_Right | WindowLayoutFlag_Default); + DoBrushSettingsWindow(Engine, Editor->CurrentBrush, BrushSettingsWindow); + + // NOTE(Jesse): Must come after the settings window draws because the + // settings window detects and initializes new brushes + if (SelectionComplete(Editor->Selection.Clicks) && Editor->CurrentBrush) { - if (Engine->MaybeMouseRay.Tag == Maybe_Yes) + if (Editor->Selection.InitialSelect) { - ray Ray = Engine->MaybeMouseRay.Ray; + Info("Setting Initial edit state"); + Assert(AtElements(&Editor->SelectedEditIndices).Index == 1); + Assert(LengthSq(Editor->Selection.Diff) == 0.f); - /* Ray.Origin = GetSimSpaceP(World, Canonical_Position(World->ChunkDim, Ray.Origin, {})); */ - AABBTest = Intersect(&SelectionAABB, &Ray); + auto EditIndex = GetPtr(&Editor->SelectedEditIndices, {}); + world_edit *Edit = GetPtr(&Editor->Edits, *EditIndex); + UpdateWorldEditBounds(Engine, Edit, Editor->Selection.Region, GetTranArena()); + } - face_index Face = AABBTest.Face; - /* PushColumn(Ui, CS(Face)); */ - /* PushNewRow(Ui); */ + if (LengthSq(Editor->Selection.Diff) > 0.f) + { + Info("Applying diff to edit buffer"); + world_edit_selection_mode SelectionMode = ComputeSelectionMode(Input); + Assert(SelectionMode); + ApplyDiffToEditBuffer(Engine, Editor->Selection.Diff, &Editor->SelectedEditIndices, SelectionMode); + Editor->Selection.ModState.ClickedFace = FaceIndex_None; + } - if (Face) + b32 SettingsChanged = CheckSettingsChanged(&Editor->CurrentBrush->Layered); + if (SettingsChanged) + { + IterateOver(&Editor->Edits, Edit, EditIndex) { - /* r32 InsetWidth = 0.25f; */ - r32 InsetWidth = 0.f; - v3 HiColor = RGB_GREEN; - r32 HiThickness = Thickness*1.2f; - - HighlightFace(Engine, Face, SelectionAABB, InsetWidth, HiColor, HiThickness); + if (Edit->Tombstone) { continue; } - if ( Input->LMB.Clicked && (Input->Ctrl.Pressed || Input->Shift.Pressed || Input->Alt.Pressed) ) + if (Edit->Brush == Editor->CurrentBrush) { - v3 PlaneBaseP = Ray.Origin + (AABBTest.t*Ray.Dir); - Editor->Selection.ClickedFace = Face; - Editor->Selection.ClickedP[0] = PlaneBaseP; + ReapplyEditToOctree(Engine, Edit, GetTranArena()); } } + } + } + } - if (Editor->Selection.ClickedFace) - { - world_edit_selection_mode SelectionMode = {}; + { + local_persist window_layout LayersWindow = WindowLayout("Layers", WindowLayoutFlag_Align_Bottom); + PushWindowStart(Ui, &LayersWindow); - // Intentionally an el-if chain from most specific, to least. What's the alternative? - // - // Shift is resize - // Ctrl is move - // - if (Input->Shift.Pressed && Input->Ctrl.Pressed && Input->Alt.Pressed) - { - SelectionMode = SelectionMode_ResizeAllAxies; - } - else if (Input->Shift.Pressed && Input->Alt.Pressed) - { - SelectionMode = SelectionMode_ResizeBothLinearAxies; - } - else if (Input->Ctrl.Pressed && Input->Alt.Pressed) - { - SelectionMode = SelectionMode_TranslateLinear; - } - else if (Input->Shift.Pressed) - { - SelectionMode = SelectionMode_ResizeSingleLinearAxis; - } - else if (Input->Ctrl.Pressed) - { - SelectionMode = SelectionMode_TranslatePlanar; - } + if (Button(Ui, CSz("New Layer"), UiId(&LayersWindow, "new layer", 0ull))) + { + NewLayer(Editor); + } + + PushNewRow(Ui); + PushNewRow(Ui); - /* Info("%S", ToString(SelectionMode)); */ - /* if (SelectionMode) { Ui->RequestedForceCapture = True; } */ + PushTableStart(Ui); - rect3i ModifiedSelection = DoSelectonModification(Engine, &Ray, SelectionMode, &Editor->Selection, SelectionAABB); + world_edit_layer *PrevLayer = {}; - if (!Input->LMB.Pressed) - { - // If we actually changed the selection region - rect3cp ProposedSelection = SimSpaceToCanonical(World, &ModifiedSelection); + IterateOver(&Editor->Layers, Layer, LayerIndex) + { + cs Name = CS(Layer->NameBuf); + b32 LayerSelected = Editor->SelectedLayerIndex == LayerIndex; + + PushTableStart(Ui); + { + ui_style *Style = LayerSelected ? &DefaultSelectedStyle : &DefaultStyle; + if (Button(Ui, Name, UiId(&LayersWindow, Layer, Layer), Style)) + { + Editor->SelectedLayerIndex = LayerIndex; - // Make ModifiedSelection permanent - Editor->SelectionRegion = ProposedSelection; - Editor->Selection.ClickedFace = FaceIndex_None; + // NOTE(Jesse): Clear the list if we didn't have ctrl pressed + b32 MultiSelect = Input->Ctrl.Pressed; + IterateOver(&Layer->EditIndices, EditIndex, EII) + { + auto Edit = GetPtr(&Editor->Edits, *EditIndex); + SelectEdit(Editor, Edit, *EditIndex, MultiSelect); + MultiSelect = True; } } - } - } - // Draw selection box - // - - v3 BaseColor = RGB_WHITE; - DEBUG_DrawSimSpaceAABB(Engine, &SelectionAABB, BaseColor, Thickness); - } + ui_layer_toolbar_actions LayerToolbarAction = {}; + ui_toggle_button_group Toolbar = PushToolbar(Ui, &LayersWindow, {}, &LayerToolbarAction, u64(Layer)); + if (Toolbar.AnyElementClicked) + { + switch (LayerToolbarAction) + { + case LayerToolbarActions_NoAction: {} break; + case LayerToolbarActions_Rename: + { + } break; - // Don't fire selection changed event when dragging selection with selection edit tool - if (Editor->SelectionClicks != 1) - { - if (AreEqual(Editor->SelectionRegion, Editor->PrevSelectionRegion)) - { - Editor->SelectionChanged = False; - } - else - { - Editor->SelectionChanged = True; - } - Editor->PrevSelectionRegion = Editor->SelectionRegion; - } + case LayerToolbarActions_Duplicate: + { + auto SrcLayer = Layer; + auto DstLayer = NewLayer(Editor); - return AABBTest; -} + b32 MultiSelect = Input->Ctrl.Pressed; + IterateOver(&SrcLayer->EditIndices, EditIndex, EditIndexIndex) + { + world_edit *Edit = GetPtr(&Editor->Edits, *EditIndex); + world_edit_block_array_index DupIndex = {}; + auto *Duplicated = DuplicateEdit(Editor, DstLayer, Edit, &DupIndex); -link_internal cp -GetSelectionCenterP(world *World, level_editor *Editor) -{ - v3i Dim = GetSelectionDim(World, Editor); - cp Result = Canonicalize(World, Editor->SelectionRegion.Min + V3(Dim/2)); - return Result; -} + SelectEdit(Editor, Duplicated, DupIndex, MultiSelect); -link_internal b32 -InputStateIsValidToApplyEdit(input *Input) -{ - b32 Result = Input->LMB.Clicked && !Input->Shift.Pressed && !Input->Ctrl.Pressed && !Input->Alt.Pressed; - return Result; -} + ApplyEditToOctree(Engine, Duplicated, GetTranArena()); + MultiSelect = True; + } + } break; -link_internal world_edit_mode -GetEditModeForSelectedTool(level_editor *Editor) -{ - // Default is attach for tools/brushes that don't have a mode in their settings - world_edit_mode Result = WorldEdit_Mode_Attach; + case LayerToolbarActions_Delete: + { + IterateOver(&Layer->EditIndices, EditIndex, EditIndexIndex) + { + world_edit *Edit = GetPtr(&Editor->Edits, *EditIndex); + // NOTE(Jesse): We're deleting the layer here so we don't need + // to remove the edits one-by-one .. we'll clear the whole thing. + DeleteEdit(Engine, Edit, EditIndex); + } - switch(Editor->Tool) - { - case WorldEdit_Tool_Disabled: {} break; - case WorldEdit_Tool_Select: {} break; - case WorldEdit_Tool_Eyedropper: {} break; - case WorldEdit_Tool_BlitEntity: {} break; + Layer->EditIndices.ElementCount = 0; - case WorldEdit_Tool_Brush: - { - switch(Editor->BrushType) - { - case WorldEdit_BrushType_Disabled: {} break; - case WorldEdit_BrushType_Entity: {} break; - case WorldEdit_BrushType_Single: { Result = Editor->SingleBrush.Mode; } break; - case WorldEdit_BrushType_Asset: { Result = Editor->AssetBrush.Mode; } break; - case WorldEdit_BrushType_Layered: { Result = Editor->LayeredBrushEditor.Mode;} break; - } - } break; - } + RemoveOrdered(&Editor->Layers, Layer); + Layer = 0; - return Result; -} + Editor->SelectedLayerIndex = {INVALID_BLOCK_ARRAY_INDEX}; + LayerIndex = AtElements(&Editor->Layers); + } break; + } + } -link_internal v3 -ColorIndexToV3(u16 ColorIndex) -{ - u32 FiveBits = 0b0000000000011111; - u32 SixBits = 0b0000000000111111; + } + PushTableEnd(Ui); - f32 R = f32((ColorIndex >> 11) & FiveBits) / f32(FiveBits); - f32 G = f32((ColorIndex >> 6) & FiveBits) / f32(FiveBits); - f32 B = f32((ColorIndex >> 0) & SixBits) / f32(SixBits); + if (Layer) + { + PushTableStart(Ui); + if (AtElements(&Layer->EditIndices).Index == 0) + { + PushColumn(Ui, CSz("--- no edits ---")); + PushNewRow(Ui); + } + else + { + { + world_edit_block_array_index *PrevEditIndex = {}; + IterateOver(&Layer->EditIndices, EditIndex, EditIndexIndex) + { + world_edit *Edit = GetPtr(&Editor->Edits, *EditIndex); + Assert(Edit->Tombstone == False); - v3 Result = V3(R,G,B); - return Result; -} + const char *NameBuf = Edit->Brush ? Edit->Brush->NameBuf : "no brush"; + ui_reorder_action EditReorderAction = {}; + PushToolbar(Ui, &LayersWindow, {}, &EditReorderAction, u64(Edit)^u64(Layer), &DefaultUiRenderParams_Toolbar, ToggleButtonGroupFlags_NoNewRow); -link_internal void -DoColorPickerSection(engine_resources *Engine, window_layout *Window, v3 *HSVDest, u32 ElementIndex, u32 Slices, v2 WidgetDim, r32 CurrentValue) -{ - UNPACK_ENGINE_RESOURCES(Engine); + switch(EditReorderAction) + { + case UiReorderAction_NoAction: break; - ui_element_reference SaturationTable = PushTableStart(Ui); - RangeIterator_t(u8, ColorIndex, Slices) - { - /* v3 Color = GetColorData(u32(ColorIndex)); */ + case UiReorderAction_ReorderUp: + { + if (PrevEditIndex) + { + world_edit *PrevEdit = GetPtr(&Editor->Edits, *PrevEditIndex); + Assert(Edit != PrevEdit); + ReapplyEditToOctree(Engine, Edit, GetTranArena()); + ReapplyEditToOctree(Engine, PrevEdit, GetTranArena()); + + auto Tmp = *PrevEditIndex; + *PrevEditIndex = *EditIndex; + *EditIndex = Tmp; + } + else if (PrevLayer) + { + Push(&PrevLayer->EditIndices, EditIndex); + RemoveOrdered(&Layer->EditIndices, EditIndex); - v2 QuadDim = V2(WidgetDim.x/r32(Slices), WidgetDim.y); - v4 Padding = V4(0); - v3 BorderColor = V3(1.0f); + // NOTE(Jesse): No need to reapply because we didn't change + // the ordering, just shifted up a layer + /* ReapplyEditToOctree(Engine, Edit, GetTranArena()); */ + } - r32 Value = r32(ColorIndex)/r32(Slices); + } break; - v3 HSV = *HSVDest; - HSV.E[ElementIndex] = Value; - v3 RGB = HSVtoRGB(HSV); + case UiReorderAction_ReorderDown: + { + auto NextEditIndexIndex = EditIndexIndex; + ++NextEditIndexIndex; - b32 Selected = Value == CurrentValue; - ui_style Style = FlatUiStyle(RGB); - interactable_handle ColorPickerButton = PushButtonStart(Ui, UiId(Window, "ColorPicker value button", Cast(void*, u64(ColorIndex) | u64(ElementIndex<<16))) ); - PushUntexturedQuad(Ui, {}, QuadDim, zDepth_Text, &Style, Padding ); - PushButtonEnd(Ui); + if (auto NextEditIndex = TryGetPtr(&Layer->EditIndices, NextEditIndexIndex)) + { + world_edit *NextEdit = GetPtr(&Editor->Edits, *NextEditIndex); + Assert(Edit != NextEdit); + ReapplyEditToOctree(Engine, Edit, GetTranArena()); + ReapplyEditToOctree(Engine, NextEdit, GetTranArena()); - b32 ButtonHover = Hover(Ui, &ColorPickerButton); - if (Selected || ButtonHover) - { - f32 BorderDim = 1.f; - PushRelativeBorder(Ui, V2(-1.f,1.f)*QuadDim, BorderColor, V4(BorderDim)); - } + auto Tmp = *NextEditIndex; + *NextEditIndex = *EditIndex; + *EditIndex = Tmp; - if (ButtonHover) - { - PushTooltip(Ui, FSz("%d %.2V3", ColorIndex, &RGB)); - } + EditIndexIndex = AtElements(&Layer->EditIndices); + } + else + { + auto NextLayerIndex = LayerIndex; + ++NextLayerIndex; - if (ButtonHover && Input->LMB.Pressed) - { - HSVDest->E[ElementIndex] = Value; - } - } - PushTableEnd(Ui); - PushNewRow(Ui); -} + if (auto NextLayer = TryGetPtr(&Editor->Layers, GetIndex(&NextLayerIndex))) + { + RemoveOrdered(&Layer->EditIndices, EditIndex); + Shift(&NextLayer->EditIndices, EditIndex); -link_internal void -DoColorPicker(engine_resources *Engine, window_layout *Window, v3 *RGBDest, b32 ShowColorSwatch) -{ - UNPACK_ENGINE_RESOURCES(Engine); + // NOTE(Jesse): No need to reapply because we didn't change + // the ordering, just shifted up a layer + /* ReapplyEditToOctree(Engine, Edit, GetTranArena()); */ + } - /* u8 FourBits = 0b1111; */ - u8 FiveBits = 0b11111; - u8 SixBits = 0b111111; - /* u8 EightBits = 0b11111111; */ + EditIndexIndex = AtElements(&Layer->EditIndices); + } + } - u16 HueSlices = SixBits; - u16 SaturationSlices = FiveBits; - u16 ValueSlices = FiveBits; + break; + } - v2 ColorPickerSectionDim = V2(256, 30); - v3 HSV = RGBtoHSV(*RGBDest); + ui_render_params ButtonParams = DefaultUiRenderParams_Button; - DoColorPickerSection(Engine, Window, &HSV, 0, HueSlices, ColorPickerSectionDim, RGBDest->h); - DoColorPickerSection(Engine, Window, &HSV, 1, SaturationSlices, ColorPickerSectionDim, RGBDest->s); - DoColorPickerSection(Engine, Window, &HSV, 2, ValueSlices, ColorPickerSectionDim, RGBDest->v); + b32 EditIsSelected = Edit->Selected; + if (EditIsSelected) + { + ButtonParams.FStyle = &DefaultSelectedStyle; + } - PushNewRow(Ui); + auto EditSelectButton = PushSimpleButton(Ui, FSz("(%s)", NameBuf), UiId(&LayersWindow, "edit select", Edit), &ButtonParams); + if (Clicked(Ui, &EditSelectButton)) + { + // NOTE(Jesse): We do SelectEdit on the HotEdit later + /* b32 MultiSelect = Input->Ctrl.Pressed; */ + /* SelectEdit(Editor, Edit, *EditIndex, MultiSelect); */ - *RGBDest = HSVtoRGB(HSV); + Editor->SelectedLayerIndex = LayerIndex; + if (Edit->Brush) + { + Editor->CurrentBrush = Edit->Brush; + CheckSettingsChanged(&Edit->Brush->Layered); // Prevent firing a change event @prevent_change_event + } + } - if (ShowColorSwatch) - { - v2 QuadDim = V2(ColorPickerSectionDim.x, ColorPickerSectionDim.x); - ui_style Style = FlatUiStyle(*RGBDest); - PushUntexturedQuad(Ui, {}, QuadDim, zDepth_Text, &Style, {} ); - PushNewRow(Ui); - } + if (Hover(Ui, &EditSelectButton)) + { + Editor->HotEdit = Edit; + Editor->HotEditIndex = *EditIndex; + } - cs HSVColorString = FSz("HSV (%.2V3)", &HSV); - cs RGBColorString = FSz("RGB (%.2V3)", RGBDest); + ui_layer_edit_actions LayerEditAction = {}; + PushToolbar( Ui, &LayersWindow, {}, &LayerEditAction, u64(Edit)); + switch (LayerEditAction) + { + case UiLayerEditAction_NoAction: {} break; - PushColumn(Ui, HSVColorString ); - PushNewRow(Ui); + case UiLayerEditAction_SetBrush: + { + Assert(Editor->CurrentBrush); + Edit->Brush = Editor->CurrentBrush; + ReapplyEditToOctree(Engine, Edit, GetTranArena()); + } break; - PushColumn(Ui, RGBColorString ); - PushNewRow(Ui); + case UiLayerEditAction_Duplicate: + { + world_edit_block_array_index DupIndex = {}; + auto *Duplicated = DuplicateEdit(Editor, Layer, Edit, &DupIndex); - /* DoEditorUi(Ui, &Window, &Editor->HSVColorSelection, CSz("HSV Color") ); */ -} + b32 MultiSelect = Input->Ctrl.Pressed; + SelectEdit(Editor, Duplicated, DupIndex, MultiSelect); -link_internal void -ColorPickerModal(engine_resources *Engine, ui_id ModalId, v3 *RGBDest, b32 ShowColorSwatch /* = True */) -{ - UNPACK_ENGINE_RESOURCES(Engine); + ApplyEditToOctree(Engine, Duplicated, GetTranArena()); + } break; - if (window_layout *Window = ModalIsActive(Ui, ModalId)) - { - DoColorPicker(Engine, Window, RGBDest, ShowColorSwatch); + case UiLayerEditAction_Delete: + { + DeleteEdit(Engine, Edit, EditIndex, Layer); + } break; + } - PushNewRow(Ui); + PrevEditIndex = EditIndex; + } + } + } + PushTableEnd(Ui); + PushNewRow(Ui); - if (Button(Ui, CSz("Close"), UiId(Window, "modal close button", 0u))) - { - CompleteModal(Ui, ModalId); + PrevLayer = Layer; + } } PushNewRow(Ui); + PushTableEnd(Ui); + PushWindowEnd(Ui, &LayersWindow); } -} -link_internal void -DoWorldEditor(engine_resources *Engine) -{ - UNPACK_ENGINE_RESOURCES(Engine); - // @selection_changed_flag // - aabb_intersect_result AABBTest = EditWorldSelection(Engine); - aabb SelectionAABB = GetSimSpaceRect(World, Editor->SelectionRegion); - - ui_toggle_button_group WorldEditToolButtonGroup = {}; - ui_toggle_button_group WorldEditModeButtonGroup = {}; - ui_toggle_button_group WorldEditBrushTypeButtonGroup = {}; - ui_toggle_button_group WorldEditModifierButtonGroup = {}; + // + // Draw + // + // { - local_persist window_layout Window = WindowLayout("World Edit"); - PushWindowStart(Ui, &Window); - - PushTableStart(Ui); - ui_render_params Params = DefaultUiRenderParams_Button; - Params.Padding = V4(6, 3, 6, 3); - ui_element_reference CurrentRef = {}; + v3 CameraSimP = GetSimSpaceP(World, Camera->CurrentP); - { - WorldEditToolButtonGroup = DoEditorUi(Ui, &Window, &Editor->Tool, CSz("Tool"), &Params, ToggleButtonGroupFlags_DrawVertical); - CurrentRef = WorldEditToolButtonGroup.UiRef; - } + auto Face = Editor->Selection.ModState.ClickedFace; + if (Face == FaceIndex_None) { Face = AABBTest.Face; } - if (Editor->Tool == WorldEdit_Tool_Brush) - { - Params.RelativePosition.Position = Position_RightOf; - Params.RelativePosition.RelativeTo = CurrentRef; - WorldEditBrushTypeButtonGroup = DoEditorUi(Ui, &Window, &Editor->BrushType, CSz("Brush Type"), &Params, ToggleButtonGroupFlags_DrawVertical); - CurrentRef = WorldEditBrushTypeButtonGroup.UiRef; - } + f32 HiThicknessMod = 1.5f; + f32 SelectionThicknessMod = 3.0f; - PushTableEnd(Ui); - /* DoColorPicker(Engine, &Window, &Editor->HSVColorSelection); */ + b32 ShiftOrAltPressed = Input->Shift.Pressed | Input->Alt.Pressed; - PushWindowEnd(Ui, &Window); - } + // Selection region + // + if (Editor->Selection.ModMode && Editor->Selection.Clicks > 0) + { + aabb FinalSelectionAABB = GetSimSpaceRect(World, Editor->Selection.Region); + r32 BaseThicc = GetSelectionThicknessForDistance( Distance(CameraSimP, GetCenter(&FinalSelectionAABB)) ); + if (Face && ShiftOrAltPressed) + { + /* r32 InsetWidth = 0.25f; */ + r32 InsetWidth = 0.f; + v3 HiColor = RGB_RED; + HighlightFace(Engine, Face, FinalSelectionAABB, InsetWidth, HiColor, BaseThicc*SelectionThicknessMod*HiThicknessMod); + } + DEBUG_DrawSimSpaceAABB(Engine, &FinalSelectionAABB, RGB_GREEN, BaseThicc*SelectionThicknessMod); + } + // Highlight moused over voxel + // + if (Engine->MousedOverVoxel.Tag) + { + v3 HotVoxel = GetHotVoxelForEditMode(Engine, WorldEdit_Mode_Subtractive ); + DEBUG_HighlightVoxel( Engine, HotVoxel, RGB_RED, 0.075f); + } + // Highlight edits in the current layer + // + { + if ( world_edit_layer *Layer = TryGetSelectedLayer(Editor) ) + { + IterateOver(&Layer->EditIndices, EditIndex, EditIndexIndex) + { + world_edit *Edit = GetPtr(&Editor->Edits, *EditIndex); + Assert(Edit->Tombstone == False); + if (Edit == Editor->HotEdit) continue; + if (Edit->Selected) continue; + auto EditAABB = GetSimSpaceAABB(World, Edit->Region); + random_series S = {u64(Edit)}; + v3 BaseColor = RandomV3Unilateral(&S); - // - // - // Do tool selection actions (what happens when we change a tool selection) - // - // + r32 BaseThicc = GetSelectionThicknessForDistance( Distance(CameraSimP, GetCenter(&EditAABB)) ); + DEBUG_DrawSimSpaceAABB(Engine, &EditAABB, BaseColor, BaseThicc); + } + } + } - if (WorldEditToolButtonGroup.AnyElementClicked) - { - switch (Editor->Tool) + // Highlight currently selected edits + // { - case WorldEdit_Tool_Disabled: - case WorldEdit_Tool_Brush: - case WorldEdit_Tool_Eyedropper: - case WorldEdit_Tool_BlitEntity: - /* case WorldEdit_Tool_StandingSpots: */ - { } break; - - case WorldEdit_Tool_Select: + IterateOver(&Editor->SelectedEditIndices, EditIndex, EditIndexIndex) { - ResetSelection(Editor); - } break; - } - } + world_edit *Edit = GetPtr(&Editor->Edits, *EditIndex); + Assert(Edit->Tombstone == False); - // - // - // Edit tool interactions in the world - // - // - if ( UiCapturedMouseInput(Ui) == False && - UiHoveredMouseInput(Ui) == False ) - { - switch (Editor->Tool) - { - case WorldEdit_Tool_Disabled: + auto EditAABB = GetSimSpaceAABB(World, Edit->Region); + random_series S = {u64(Edit)}; + v3 BaseColor = RandomV3Unilateral(&S); - case WorldEdit_Tool_Brush: - { - switch (Editor->BrushType) + r32 BaseThicc = GetSelectionThicknessForDistance( Distance(CameraSimP, GetCenter(&EditAABB)) ); + if (Face && ShiftOrAltPressed) { - case WorldEdit_BrushType_Disabled: - {} break; + /* r32 InsetWidth = 0.25f; */ + r32 InsetWidth = 0.f; + v3 HiColor = RGB_RED; - case WorldEdit_BrushType_Entity: - case WorldEdit_BrushType_Asset: - { - if (Input->LMB.Clicked) - { - if (EngineDebug->SelectedAsset.FileNode.Type) - { - cp EntityOrigin = Canonical_Position(&Engine->MousedOverVoxel.Value); - EntityOrigin.Offset = Round(EntityOrigin.Offset); + HighlightFace(Engine, Face, EditAABB, InsetWidth, HiColor, BaseThicc*HiThicknessMod); + } - maybe_asset_ptr MaybeAsset = GetAssetPtr(Engine, &EngineDebug->SelectedAsset); - if (MaybeAsset.Tag) - { - asset *Asset = MaybeAsset.Value; + // NOTE(Jesse): This is intentionally after the HighlightFace call; we + // always wanna highlight that no matter if we're hovering or not + if (Edit == Editor->HotEdit) continue; - switch (Asset->Type) - { - InvalidCase(AssetType_Undefined); + DEBUG_DrawSimSpaceAABB(Engine, &EditAABB, RGB_YELLOW, BaseThicc); + } + } - case AssetType_WorldChunk: - case AssetType_Models: - { - // TODO(Jesse): There should be an unsafe version of this function, and rename this one to TryGetDimForAssetModel ..? - maybe_v3i MaybeDim = GetDimForAssetModel(Asset, u32(EngineDebug->ModelIndex)); - if (MaybeDim.Tag) - { - 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, Editor->AssetBrush.Mode, Editor->AssetBrush.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(); // NOTE(Jesse): This is redundant because we already checked it's one of these, - // but I'm going to keep it here in case we ever move this code.. or the checks. - } - } - else - { - BUG("Somehow requested a ModelIndex from an Asset that did not have one!"); - } - } break; + // Highlight the hot edit + // + if (Editor->HotEdit) + { + if ( Input->Shift.Pressed == False && + Input->Alt.Pressed == False && + Editor->Selection.ModMode != SelectionModificationMode_Initialize ) + { + if (Input->LMB.Clicked) + { + b32 MultiSelect = Input->Ctrl.Pressed; + SelectEdit(Editor, Editor->HotEdit, Editor->HotEditIndex, MultiSelect); + } + } - } + auto EditAABB = GetSimSpaceAABB(World, Editor->HotEdit->Region); + r32 BaseThicc = GetSelectionThicknessForDistance( Distance(CameraSimP, GetCenter(&EditAABB)) ); + DEBUG_DrawSimSpaceAABB(Engine, &EditAABB, RGB_PINK, BaseThicc); + } - } - } - } - } break; + } - case WorldEdit_BrushType_Single: - { - // NOTE(Jesse): This is kind of an optimization to jump directly to - // rebuilding the chunk mesh instead of doing all the hoop-jumping - // related to editing. I'm not really sure if it's worth the extra - // complexity here, and/or the slight bit of jank it introduces. I - // expect that once I serialize the world edits this should go away - // and we can just collapse world edits automatically in the edit thread. - // - // When my laptop is unplugged running on battery power, this is _much_ faster. - NotImplemented; -#if 0 - if (Editor->Params.Mode == WorldEdit_Mode_Paint) - { - b32 DoPaint = Input->LMB.Pressed; - if (DoPaint) - { - Ui->RequestedForceCapture = True;; - if (Engine->MousedOverVoxel.Tag) - { - if (voxel *V = GetVoxelPointer(&Engine->MousedOverVoxel.Value, PickedVoxel_FirstFilled)) - { - V->Color = Engine->Editor.SelectedColorIndex; - QueueChunkForMeshRebuild(&Plat->LowPriority, Engine->MousedOverVoxel.Value.Chunks[PickedVoxel_FirstFilled].Chunk); - } - } - } - } - else - { - b32 DoPaint = Input->LMB.Clicked; - if (DoPaint) - { - Ui->RequestedForceCapture = True; - if (Engine->MousedOverVoxel.Tag) - { - v3 P0 = GetHotVoxelForEditMode(Engine, Editor->Params.Mode); - rect3 AABB = RectMinMax(P0, P0+1.f); - ApplyEditToRegion(Engine, &AABB, Engine->Editor.SelectedColorIndex, {}, Editor->Params.Mode, Editor->Params.Modifier); - } - } - } +#if BONSAI_INTERNAL + // NOTE(Jesse): Sanity check we keep the selected flag in sync with the array + IterateOver(&Editor->Edits, Edit, EI) + { + auto SelectedEditIndex = IndexOfValue(&Editor->SelectedEditIndices, &EI); + if (SelectedEditIndex.Index == INVALID_BLOCK_ARRAY_INDEX) + { + Assert(Edit->Selected == False); + } + else + { + Assert(Edit->Selected == True); + } + } #endif - } break; - case WorldEdit_BrushType_Layered: - { - if (AABBTest.Face && InputStateIsValidToApplyEdit(Input)) - { - v3i Offset = V3i(s32_MAX); - world_chunk *Chunk = &Editor->LayeredBrushEditor.Preview.Chunk; - // TODO(Jesse): Call GetSmallestMinOffset here - RangeIterator(LayerIndex, Editor->LayeredBrushEditor.LayerCount) - { - brush_layer *Layer = Editor->LayeredBrushEditor.Layers + LayerIndex; - Offset = Min(Layer->Settings.Offset.Min, Offset); - } + u32 Ordinal = 0; + IterateOver(&Editor->Layers, Layer, LayerIndex) + { + IterateOver(&Layer->EditIndices, EditIndex, EII) + { + world_edit *Edit = GetPtr(&Editor->Edits, *EditIndex); + Edit->Ordinal = Ordinal++; + } + } - chunk_data D = {Chunk->Flags, Chunk->Dim, Chunk->Voxels, Chunk->VoxelLighting}; - world_update_op_shape_params_chunk_data ChunkDataShape = { D, V3(Offset) + GetSimSpaceP(World, Editor->SelectionRegion.Min) - V3i(1) }; +} - world_edit_shape Shape = - { - type_world_update_op_shape_params_chunk_data, - .world_update_op_shape_params_chunk_data = ChunkDataShape, - }; - QueueWorldUpdateForRegion(Engine, Editor->LayeredBrushEditor.Mode, Editor->LayeredBrushEditor.Modifier, &Shape, DEFAULT_HSV_COLOR, Editor->LayeredBrushEditor.SeedBrushWithSelection, Engine->WorldUpdateMemory); - } - } break; +link_internal void +DrawLod(engine_resources *Engine, shader *Shader, gpu_mapped_element_buffer *Mesh, r32 DistanceSquared, v3 Basis, Quaternion Rotation, v3 Scale ); - } - } break; +link_internal void +ApplyEditBufferToOctree(engine_resources *Engine, world_edit_paged_list *Edits) +{ + IterateOver(Edits, Edit, EditIndex) + { + if (Edit->Tombstone) { continue; } + ApplyEditToOctree(Engine, Edit, GetTranArena()); + } +} - case WorldEdit_Tool_Select: - { - if (Input->LMB.Clicked) - { switch (Editor->SelectionClicks) - { - case 0: - { - if (Engine->MousedOverVoxel.Tag) - { - Editor->SelectionClicks += 1; - auto MouseP = Canonical_Position(&Engine->MousedOverVoxel.Value); - MouseP.Offset = Floor(MouseP.Offset); - Editor->SelectionBase = MouseP; - } - } break; +link_internal void +DoLevelWindow(engine_resources *Engine) +{ + UNPACK_ENGINE_RESOURCES(Engine); - case 1: - { - Editor->SelectionClicks += 1; + local_persist window_layout Window = WindowLayout("Level"); - if (Editor->PreviousTool) - { - Editor->Tool = Editor->PreviousTool; - Editor->PreviousTool = {}; - } - } break; + thread_local_state *Thread = GetThreadLocalState(ThreadLocal_ThreadIndex); - } - } - } break; + // + // Level Export + // + PushWindowStart(Ui, &Window); + PushTableStart(Ui); + if (Button(Ui, CSz("Export Level"), UiId(&Window, "export_level_button", 0ull))) + { + u8_cursor_block_array OutputStream = BeginSerialization(); - case WorldEdit_Tool_Eyedropper: + u32 EntityCount = 0; + RangeIterator(EntityIndex, TOTAL_ENTITY_COUNT) { - if (Engine->MousedOverVoxel.Tag) - { - auto MouseP = Canonical_Position(&Engine->MousedOverVoxel.Value); - voxel *V = GetVoxelPointer(&Engine->MousedOverVoxel.Value, PickedVoxel_FirstFilled); + entity *E = EntityTable[EntityIndex]; + if (Spawned(E)) { ++EntityCount; } + } - Engine->Editor.HoverColorIndex = V->Color; + level_header Header = {}; - if (Input->LMB.Clicked) - { - /* Info("Selecting Color (%S)", CS(V->Color)); */ - /* Engine->Editor.HSVColorSelection = UnpackHSVColor(V->Color); */ + Header.WorldCenter = World->Center; + Header.VisibleRegionSize = World->VisibleRegionSize; + Header.Camera = *Camera; + Header.RenderSettings = Graphics->Settings; + Header.EntityCount = EntityCount; + Header.SelectedLayerIndex = u32(Editor->SelectedLayerIndex.Index); + Header.LayerCount = u32(AtElements(&Editor->Layers).Index); + Header.EditCount = u32(AtElements(&Editor->Edits).Index); - if (Editor->PreviousTool) - { - Editor->Tool = Editor->PreviousTool; - Editor->PreviousTool = {}; - } - } - } - else - { - Engine->Editor.HoverColorIndex = INVALID_COLOR_INDEX; - } - } break; + { + cs Filename = Engine->Graphics.TerrainShapingRC.Program.FragSourceFilename; + cs Dest = CS(Header.TerrainShapingShader, NameBuf_Len); + CopyString(&Filename, &Dest); + } + { + cs Filename = Engine->Graphics.TerrainDecorationRC.Program.FragSourceFilename; + cs Dest = CS(Header.TerrainDecorationShader, NameBuf_Len); + CopyString(&Filename, &Dest); + } + + Serialize(&OutputStream, &Header); + + u64 Delimeter = LEVEL_FILE_DEBUG_OBJECT_DELIM; + Ensure(Serialize(&OutputStream, &Delimeter)); - case WorldEdit_Tool_BlitEntity: + IterateOver(&Editor->Layers, Layer, LI) { - entity *SelectedEntity = GetEntity(EntityTable, EngineDebug->SelectedEntity); - if (SelectedEntity) - { - aabb EntityAABB = GetSimSpaceAABB(World, SelectedEntity); - if (Engine->MaybeMouseRay.Tag) - { - ray *Ray = &Engine->MaybeMouseRay.Ray; - aabb_intersect_result IntersectionResult = Intersect(EntityAABB, Ray); - if (Input->LMB.Clicked && IntersectionResult.Face) - { -#if 1 - world_update_op_shape_params_asset AssetUpdateShape = - { - SelectedEntity->AssetId, - SelectedEntity->ModelIndex, - SelectedEntity->P, - }; + Serialize(&OutputStream, Layer); + } + Ensure(Serialize(&OutputStream, &Delimeter)); - world_edit_shape Shape = - { - type_world_update_op_shape_params_asset, - .world_update_op_shape_params_asset = AssetUpdateShape, - }; - QueueWorldUpdateForRegion(Engine, WorldEdit_Mode_Attach, WorldEdit_Modifier_Default, &Shape, {}, {}, Engine->WorldUpdateMemory); -#endif - } - } - } - } break; + IterateOver(&Editor->Edits, Edit, EI) + { + Serialize(&OutputStream, Edit); + } + Ensure(Serialize(&OutputStream, &Delimeter)); -#if 0 - case WorldEdit_Tool_StandingSpots: + RangeIterator(EntityIndex, TOTAL_ENTITY_COUNT) { - NotImplemented; - if (Input->LMB.Clicked && AABBTest.Face && !Input->Shift.Pressed && !Input->Ctrl.Pressed) + entity *E = EntityTable[EntityIndex]; + if (Spawned(E)) { - world_edit_shape Shape = { - .Type = type_world_update_op_shape_params_rect, - .world_update_op_shape_params_rect.P0 = SelectionAABB.Min, - .world_update_op_shape_params_rect.P1 = SelectionAABB.Max, - }; - QueueWorldUpdateForRegion(Engine, WorldUpdateOperationMode_StandingSpots, &Shape, Editor->SelectedColorIndex, Engine->WorldUpdateMemory); + Serialize(&OutputStream, E); } - } break; -#endif - - } - } - + } - // NOTE(Jesse): This has to come after the tool interactions because of a trivial - // but important interaction. If there's a previous tool to pop back to, we - // need to do that pop back before the brush settings get updated and the - // brush preview gets drawn or else when we pop back the settings window thinks - // the Select tool is active, doesn't update any of the brush stuff, then - // the preview gets drawn because we pop back to the Layered brush tool and - // there's a frame of lag. - DoBrushSettingsWindow(Engine, Editor->Tool, Editor->BrushType); + Ensure(Serialize(&OutputStream, &Delimeter)); + const char *Filename = "../bonsai_levels/test.level"; + if (FinalizeSerialization(&OutputStream, Filename) == False) + { + SoftError("Could not serialize (%s).", Filename); + } + } + PushTableEnd(Ui); + PushNewRow(Ui); + PushTableStart(Ui); + maybe_file_traversal_node ClickedNode = PlatformTraverseDirectoryTreeUnordered(CSz("../bonsai_levels"), EngineDrawFileNodesHelper, Cast(u64, &Window)); + PushTableEnd(Ui); + PushNewRow(Ui); // + // Level Import // - // Hotkeys - // - // + if (ClickedNode.Tag) + { + cs Filename = Concat(ClickedNode.Value.Dir, CSz("/"), ClickedNode.Value.Name, GetTranArena()); + u8_cursor LevelBytes = BeginDeserialization(Filename, GetTranArena()); + if (LevelBytes.Start) + { + level_header LevelHeader = {}; - if (Input->Ctrl.Pressed || Input->Shift.Pressed || Input->Alt.Pressed) { Ui->RequestedForceCapture = True; } + Leak("Leaking level_header because we need to hold the level_header::TerrainGenShader such that we can reload the shader next frame .."); + if (Deserialize(&LevelBytes, &LevelHeader, Thread->PermMemory)) + { + u64 Delimeter = LEVEL_FILE_DEBUG_OBJECT_DELIM; + Ensure(Read_u64(&LevelBytes) == Delimeter); - if (Input->Ctrl.Pressed && Input->S.Clicked) { Editor->PreviousTool = Editor->Tool; Editor->Tool = WorldEdit_Tool_Select; ResetSelection(Editor); } + { + engine_settings *EngineSettings = &GetEngineResources()->Settings; + LevelHeader.RenderSettings.ApplicationResolution = V2(GetApplicationResolution(EngineSettings)); + LevelHeader.RenderSettings.ShadowMapResolution = V2(GetShadowMapResolution(EngineSettings)); + LevelHeader.RenderSettings.LuminanceMapResolution = V2(GetLuminanceMapResolution(EngineSettings)); + + LevelHeader.RenderSettings.iApplicationResolution = GetApplicationResolution(EngineSettings); + LevelHeader.RenderSettings.iShadowMapResolution = GetShadowMapResolution(EngineSettings); + LevelHeader.RenderSettings.iLuminanceMapResolution = GetLuminanceMapResolution(EngineSettings); + } - if (Input->Ctrl.Pressed && Input->E.Clicked) { Editor->PreviousTool = Editor->Tool; Editor->Tool = WorldEdit_Tool_Eyedropper; ResetSelectionIfIncomplete(Editor); } + FreeOctreeChildren(Engine, &World->Root); + SignalAndWaitForWorkers(&Plat->WorkerThreadsSuspendFutex); - if (Input->Ctrl.Pressed && Input->G.Clicked) { if (entity *Ghost = GetCameraGhost(Engine)) { Ghost->P = GetSelectionCenterP(World, Editor); } } - if (Editor->SelectionClicks == 2) - { - if (Input->Ctrl.Pressed && Input->D.Clicked) { ApplyEditToRegion(Engine, &SelectionAABB, {}, {}, WorldEdit_Mode_Remove, WorldEdit_Modifier_Default); } + Graphics->Settings = LevelHeader.RenderSettings; + *Graphics->Camera = LevelHeader.Camera; + World->VisibleRegionSize = LevelHeader.VisibleRegionSize; + World->Center = LevelHeader.WorldCenter; - if (Input->Ctrl.Pressed && Input->C.Clicked) { Editor->CopyRegion = Editor->SelectionRegion; } + /* Global_ProjectSwitcherGameLibName = LevelHeader.TerrainGenShader; */ - if (Input->Ctrl.Pressed && Input->V.Clicked) - { - v3 CopyDim = GetDim(World, Editor->CopyRegion); - s32 VoxelCount = s32(Volume(CopyDim)); - Leak("voxel *V = Allocate(voxel, Engine->Memory, VoxelCount)"); - voxel *V = Allocate(voxel, Engine->WorldUpdateMemory, VoxelCount); + Engine->Graphics.TerrainShapingRC.Program.FragSourceFilename = CopyString(LevelHeader.TerrainShapingShader, Thread->PermMemory); + Engine->Graphics.TerrainDecorationRC.Program.FragSourceFilename = CopyString(LevelHeader.TerrainDecorationShader, Thread->PermMemory); - Leak(""); - world_chunk_ptr_buffer Chunks = GatherChunksOverlappingArea(World, Editor->CopyRegion, Engine->WorldUpdateMemory); - GatherVoxelsOverlappingArea(World, GetSimSpaceRect3i(World, Editor->CopyRegion), &Chunks, V, VoxelCount); + // Must come after we fill out the VisibleRegion so the root octree node + // gets initialized to the correct size + // + // + // HACK(Jesse): This is a maaaajor hack and should be dealt with in a better way + bonsai_type_info_hashtable Tmp = Global_SerializeTypeTable; + Global_SerializeTypeTable = {}; + HardResetEngine(Engine); + Global_SerializeTypeTable = Tmp; - chunk_data D = {}; - D.Dim = V3i(CopyDim); - D.Voxels = V; + Engine->Editor.SelectedLayerIndex = {LevelHeader.SelectedLayerIndex}; - world_update_op_shape_params_chunk_data ChunkDataShape = { D, GetSimSpaceP(World, Editor->SelectionRegion.Min) }; - world_edit_shape Shape = - { - type_world_update_op_shape_params_chunk_data, - .world_update_op_shape_params_chunk_data = ChunkDataShape, - }; - QueueWorldUpdateForRegion(Engine, WorldEdit_Mode_Attach, WorldEdit_Modifier_Default, &Shape, {}, {}, Engine->WorldUpdateMemory); - } - } + /* s32 ChunkCount = Cast(s32, LevelHeader.ChunkCount); */ + s32 ChunkCount = 0; + /* Info("ChunksFreed (%u) ChunksLoaded (%u)", ChunksFreed, ChunkCount); */ -#if VOXEL_DEBUG_COLOR - { - cp DebugVoxel = {}; - if (Editor->SelectionClicks > 0) - { - DebugVoxel = Editor->SelectionRegion.Min; - } - else if (Engine->MousedOverVoxel.Tag) - { - DebugVoxel = Canonical_Position(&Engine->MousedOverVoxel.Value, PickedVoxel_FirstFilled); - } + RangeIterator_t(u32, LayerIndex, LevelHeader.LayerCount) + { + world_edit_layer DeserLayer = {}; + Deserialize(&LevelBytes, &DeserLayer, Editor->Memory); + world_edit_layer *FinalLayer = Push(&Editor->Layers, &DeserLayer); + FinalLayer->EditIndices.Memory = Editor->Memory; + } + Ensure(Read_u64(&LevelBytes) == Delimeter); - DoSelectedVoxelDebugWindow(Engine, DebugVoxel); - } -#endif + RangeIterator_t(u32, EditIndex, LevelHeader.EditCount) + { + world_edit DeserEdit = {}; // TODO(Jesse): Do we actually have to clear this? + Deserialize(&LevelBytes, &DeserEdit, Editor->Memory); - if (Engine->MousedOverVoxel.Tag) - { - v3 HotVoxel = GetHotVoxelForEditMode(Engine, GetEditModeForSelectedTool(Editor) ); - DEBUG_HighlightVoxel( Engine, HotVoxel, RGB_RED, 0.075f); - } -} + world_edit *FinalEdit = Push(&Editor->Edits, &DeserEdit); + if (FinalEdit->Tombstone == False) + { + if (FinalEdit->Brush) + { + FinalEdit->Brush = Upsert(*FinalEdit->Brush, &Editor->LoadedBrushes, Editor->Memory); + } -link_internal void -DrawEditorPreview(engine_resources *Engine, shader *Shader) -{ - UNPACK_ENGINE_RESOURCES(Engine); + if (FinalEdit->Selected) + { + FinalEdit->Selected = False; // Minor hack so SelectEdit doesn't assert + SelectEdit(Editor, FinalEdit, {EditIndex}, True); + Editor->Selection.ModMode == SelectionModificationMode_Modify; + } - world_chunk *Chunk = {}; - v3 Basis = {}; + ApplyEditToOctree(Engine, FinalEdit, GetTranArena()); + } + } + Ensure(Read_u64(&LevelBytes) == Delimeter); - switch (Editor->Tool) - { - case WorldEdit_Tool_Brush: - { - switch (Editor->BrushType) - { - case WorldEdit_BrushType_Layered: + b32 Error = False; + u32 EntityCount = LevelHeader.EntityCount; + RangeIterator_t(u32, EntityIndex, EntityCount) { - layered_brush_editor *LayeredBrushEditor = &Editor->LayeredBrushEditor; - v3i SmallestMinOffset = GetSmallestMinOffset(LayeredBrushEditor); - Chunk = &LayeredBrushEditor->Preview.Chunk; - Basis = V3(SmallestMinOffset) + GetRenderP(Engine, Editor->EditorPreviewRegionMin) - V3i(1); - } break; + entity *E = EntityTable[EntityIndex]; + if (Deserialize(&LevelBytes, E, Thread->PermMemory) == False) + { + SoftError("Could not deserialize entity (%d), bailing.", EntityIndex); + Error = True; + break; + } + E->Id.Index = EntityIndex; // NOTE(Jesse): Hack.. entities got saved out with 0 indexes.. + } - default: {} break; - } - } break; + Ensure(Read_u64(&LevelBytes) == Delimeter); - default: {} break; - } + Assert(ThreadLocal_ThreadIndex == 0); + if (Engine->Stdlib.AppApi.OnLibraryLoad) { Engine->Stdlib.AppApi.OnLibraryLoad(Engine, GetThreadLocalState(ThreadLocal_ThreadIndex)); } + + UnsignalFutex(&Plat->WorkerThreadsSuspendFutex); + } + } + FinalizeDeserialization(&LevelBytes); - if (Chunk) - { - DrawLod(Engine, Shader, &Chunk->Meshes, 0.f, Basis); } + PushWindowEnd(Ui, &Window); } diff --git a/src/engine/editor.h b/src/engine/editor.h index 541915e45..4c963bded 100644 --- a/src/engine/editor.h +++ b/src/engine/editor.h @@ -1,3 +1,101 @@ +/* #define EDITOR_DEFAULT_SELECTION_THICKNESS (0.15f) */ + +enum ui_layer_toolbar_actions +poof(@gen_ui_toolbar) +{ + LayerToolbarActions_NoAction poof(@ui_skip), + + LayerToolbarActions_Rename poof(@ui_display_name(CSz("R"))), + LayerToolbarActions_Duplicate poof(@ui_display_name(CSz("D"))), + LayerToolbarActions_Delete poof(@ui_display_name(CSz("X"))), + // + // .. ? +}; + +enum ui_brush_actions +poof(@gen_ui_toolbar) +{ + UiBrushAction_NoAction poof(@ui_skip), + + UiBrushAction_New, + UiBrushAction_Save, + UiBrushAction_Duplicate, +}; + +enum ui_reorder_action +poof(@gen_ui_toolbar) +{ + UiReorderAction_NoAction poof(@ui_skip), + UiReorderAction_ReorderUp poof(@ui_display_name(CSz("^"))), + UiReorderAction_ReorderDown poof(@ui_display_name(CSz("v"))), +}; + +enum ui_layer_edit_actions +poof(@gen_ui_toolbar) +{ + UiLayerEditAction_NoAction poof(@ui_skip), + + UiLayerEditAction_SetBrush poof(@ui_display_name(CSz("S"))), + UiLayerEditAction_Duplicate poof(@ui_display_name(CSz("D"))), + UiLayerEditAction_Delete poof(@ui_display_name(CSz("X"))), +}; + +enum ui_brush_layer_actions +poof(@gen_ui_toolbar) +{ + UiBrushLayerAction_NoAction poof(@ui_skip), + + UiBrushLayerAction_MoveUp, + UiBrushLayerAction_MoveDown, + UiBrushLayerAction_Duplicate, + UiBrushLayerAction_Delete, +}; + +// +// NOTE(Jesse): This is more-or-less duplicated in the face_index enum. Coalesce them? +// @duplicate_face_index_enum +// +// TODO(Jesse): Rename this to `axis_dir` or something.. +enum voxel_rule_direction +{ + VoxelRuleDir_PosX, + VoxelRuleDir_NegX, + + VoxelRuleDir_PosY, + VoxelRuleDir_NegY, + + VoxelRuleDir_PosZ, + VoxelRuleDir_NegZ, + + VoxelRuleDir_Count poof(@ui_skip), +}; +CAssert(VoxelRuleDir_Count == 6); + +poof(string_and_value_tables(voxel_rule_direction)) +#include + + +enum shape_axis +{ + ShapeAxis_InferFromMajorAxis, + + ShapeAxis_PosX, + ShapeAxis_NegX, + + ShapeAxis_PosY, + ShapeAxis_NegY, + + ShapeAxis_PosZ, + ShapeAxis_NegZ, + + ShapeAxis_Count poof(@ui_skip), +}; + +poof(string_and_value_tables(shape_axis)) +#include + +struct world; + #define EDITOR_UI_VALUE_RANGE_PROTO_DEFAULTS r32 MinValue = 0.f, r32 MaxValue = 1.f #define EDITOR_UI_VALUE_RANGE_INSTANCE_NAMES MinValue, MaxValue @@ -16,7 +114,7 @@ poof( { enum_t.map(enum_v) { - { CSz("enum_v.name.strip_all_prefix"), UiId(Window, Cast(void*, Element), Cast(void*, "enum_t.name enum_v.name")), enum_v.name }, + { CSz("enum_v.name.strip_all_prefix"), {}, UiId(Window, Cast(void*, Element), Cast(void*, "enum_t.name enum_v.name")), enum_v.name }, } }; @@ -32,12 +130,13 @@ poof( ) // multi-select group +// poof( func toggle_button_group_for_enum(enum_t) { enum_t.has_tag(bitfield)? { - generic_button_group_for_enum(enum_t, {Toggle}, {|ToggleButtonGroupFlags_MultiSelectButtons}) + generic_button_group_for_enum(enum_t, {Toggle}, {|ToggleButtonGroupFlags_TypeMultiSelectButton}) } { poof_error { Enum without @bitfield tag (enum_t.name) cannot create a multi-select button group. } @@ -45,6 +144,8 @@ poof( } ) +// radio group +// poof( func radio_button_group_for_enum(enum_t) { @@ -61,20 +162,64 @@ poof( /* Ensure( ToggleRadioButton(RadioGroup, ToggleHandle) ); */ } - generic_button_group_for_enum(enum_t, {Radio}, {|ToggleButtonGroupFlags_RadioButtons}) + generic_button_group_for_enum(enum_t, {Radio}, {|ToggleButtonGroupFlags_TypeRadioButton}) } } ) -// TODO(Jesse) This is now the same as the radio button path, remove it poof( - func radio_button_group_for_bitfield_enum(enum_t) + func toolbar_for_enum(enum_t) { - generic_button_group_for_enum(enum_t, {Radio}, {|ToggleButtonGroupFlags_RadioButtons}) - } -) + radio_button_group_for_enum(enum_t) + link_internal ui_toggle_button_group + PushToolbar( renderer_2d *Ui, + window_layout *Window, + cs GroupName, + enum_t.name *Element, + u64 Index = 0, + ui_render_params *Params = &DefaultUiRenderParams_Toolbar, + ui_toggle_button_group_flags ExtraFlags = ToggleButtonGroupFlags_None) + { + /* auto Result = RadioButtonGroup_(enum_t.name)(Ui, Window, GroupName, Element, Params, ExtraFlags); */ + ui_toggle_button_handle ButtonHandles[] = + { + enum_t.map(enum_v) + { + enum_v.has_tag(ui_skip)?{} + { + { + enum_v.has_tag(ui_display_name)? {enum_v.tag_value(ui_display_name)} {CSz("enum_v.name.strip_all_prefix")}, + enum_v.has_tag(ui_display_name)? {CSz("enum_v.name.strip_all_prefix")} {{}}, + UiId( + Cast(void*, Window), + Cast(void*, Element), + Cast(void*, "enum_t.name enum_v.name"), + Cast(void*, Index) + ), + enum_v.name, + }, + } + } + }; + + ui_toggle_button_handle_buffer ButtonBuffer = { + ArrayCount(ButtonHandles), + ButtonHandles + }; + + ui_toggle_button_group Result = {}; + Result.Ui = Ui; + Result.Flags = ui_toggle_button_group_flags(ToggleButtonGroupFlags_TypeClickButton | ExtraFlags); + Result.Buttons = ButtonBuffer; + Result.EnumStorage = Cast(u32*, Element); + + DrawButtonGroup(&Result, GroupName); + return Result; + } + } +) poof( @@ -83,8 +228,10 @@ poof( type_list.map(type) { link_internal void - DoEditorUi(renderer_2d *Ui, window_layout *Window, type.name *Value, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic, EDITOR_UI_VALUE_RANGE_PROTO_DEFAULTS) + DoEditorUi(renderer_2d *Ui, window_layout *Window, type.name *Value, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Generic, EDITOR_UI_VALUE_RANGE_PROTO_DEFAULTS) { + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x(type.hash)); + type.member(0, (E) { /* PushTableStart(Ui); */ @@ -96,7 +243,7 @@ poof( PushTableStart(Ui); E.map_array(e_index) { - DoEditorUi(Ui, Window, &Value->(E.name)[e_index], {}, Params, EDITOR_UI_VALUE_RANGE_INSTANCE_NAMES ); + DoEditorUi(Ui, Window, &Value->(E.name)[e_index], {}, ThisHash, Params, EDITOR_UI_VALUE_RANGE_INSTANCE_NAMES ); } PushTableEnd(Ui); /* PushNewRow(Ui); */ @@ -116,8 +263,10 @@ poof( type_list.map(type) { link_internal void - DoEditorUi(renderer_2d *Ui, window_layout *Window, type.name *Value, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic, EDITOR_UI_VALUE_RANGE_PROTO_DEFAULTS) + DoEditorUi(renderer_2d *Ui, window_layout *Window, type.name *Value, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Generic, EDITOR_UI_VALUE_RANGE_PROTO_DEFAULTS) { + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x(type.hash)); + Params = Params ? Params : &DefaultUiRenderParams_Blank; if (Name.Count) { PushColumn(Ui, Name, &DefaultUiRenderParams_Column); } @@ -126,9 +275,9 @@ poof( { u32 Start = StartColumn(Ui, &DefaultUiRenderParams_Blank); PushTableStart(Ui); - if (Button(Ui, CSz("-"), UiId(Window, "decrement", Value), &DefaultUiRenderParams_Button)) { *Value = *Value - 1; } + if (Button(Ui, CSz("-"), UiId(Window, "decrement", Value, ThisHash), &DefaultUiRenderParams_Button)) { *Value = *Value - 1; } PushColumn(Ui, CS(*Value), &DefaultUiRenderParams_Generic); - if (Button(Ui, CSz("+"), UiId(Window, "increment", Value), &DefaultUiRenderParams_Button)) { *Value = *Value + 1; } + if (Button(Ui, CSz("+"), UiId(Window, "increment", Value, ThisHash), &DefaultUiRenderParams_Button)) { *Value = *Value + 1; } PushTableEnd(Ui); EndColumn(Ui, Start); } @@ -140,22 +289,34 @@ poof( } - link_internal void - DoEditorUi(renderer_2d *Ui, window_layout *Window, volatile type.name *Value, cs Name, ui_render_params *Params) - { - DoEditorUi(Ui, Window, ((type.name)*) Value, Name, Params); - } - } } ) +poof( + func do_editor_ui_for_compound_type_decl(type) @code_fragment + { + struct type; + link_internal void DoEditorUi(renderer_2d *Ui, window_layout *Window, type.name *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Button) + } +) + poof( func do_editor_ui_for_compound_type(type) { - link_internal void - DoEditorUi(renderer_2d *Ui, window_layout *Window, type.name *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Button) + type.has_tag(do_editor_ui)? + { + /// NOTE(Jesse): I would really like to call do_editor_ui_for_compound_type_decl + /// here, but C++ is a fucking garbage fire and doesn't let you redeclare default parameters. + link_internal void + DoEditorUi(renderer_2d *Ui, window_layout *Window, type.name *Element, cs Name, u32 ParentHash, ui_render_params *Params) + } { + do_editor_ui_for_compound_type_decl(type) + } + { + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x(type.hash)); + if (Element) { // NOTE(Jesse): This is wacky as fuck, but it's a pretty easy way to support @@ -164,7 +325,7 @@ poof( b32 DidToggle = False; if (Name.Count) { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle type.name", Element), Params)) + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, "toggle type.name", Element, ThisHash), Params)) { DidToggle = True; PushNewRow(Ui); @@ -177,86 +338,130 @@ poof( if (DrawChildren) { - PushTableStart(Ui); + if (Name.Count) { PushTableStart(Ui); } + if (DidToggle) { OPEN_INDENT_FOR_TOGGLEABLE_REGION(); } type.map(member) { - member.has_tag(ui_skip)? - { - } - { - member.is_array? + member.has_tag(ui_display_condition)? { if ((member.tag_value(ui_display_condition))) }{} + + { /// NOTE(Jesse): this scope is here for the ui_display_condition if above.. + /// Yes, it's pretty janky, but it's the best I could come up with in a few minutes. + /// + /// It also hides the MemberName local, which .. is fine .. + cs MemberName = member.has_tag(ui_display_name)? {member.tag_value(ui_display_name)}{CSz("member.name")}; + member.has_tag(ui_skip)? { - if (ToggleButton(Ui, CSz("v member.name[member.array]"), CSz("> member.name[member.array]"), UiId(Window, "toggle type.name member.type member.name", Element->(member.name)), Params )) - { - OPEN_INDENT_FOR_TOGGLEABLE_REGION(); - PushNewRow(Ui); - RangeIterator(ArrayIndex, member.array) - { - DoEditorUi(Ui, Window, Element->(member.name)+ArrayIndex, FSz("member.name[%d]", ArrayIndex), Params); - member.is_primitive? { PushNewRow(Ui); } - } - CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); - } - PushNewRow(Ui); } { - member.has_tag(custom_ui)? + member.has_tag(ui_construct_as)? { - member.tag_value(custom_ui); + auto Value = member.tag_value(ui_construct_as)(Element->member.name); + DoEditorUi(Ui, Window, &Value, MemberName, ThisHash, Params); } { - member.is_type(b32)? + member.is_array? { - DoEditorUi(Ui, - Window, - Cast(b8*, member.is_pointer?{}{&}Element->(member.name)), - CSz("member.name"), - &DefaultUiRenderParams_Checkbox - member.has_tag(ui_value_range)?{, member.tag_value(ui_value_range) }); + member.has_tag(ui_display_name)? {poof_error(ui_display_name tag is incompatible with array members )} + + if (ToggleButton(Ui, + CSz("v member.name[member.array]"), + CSz("> member.name[member.array]"), + UiId(Window, "toggle type.name member.type member.name", Element->(member.name), ThisHash), + Params )) + { + OPEN_INDENT_FOR_TOGGLEABLE_REGION(); + PushNewRow(Ui); + member.has_tag(array_length)? + { + s32 End = s32((member.tag_value(array_length))); + Assert( End < member.array ); + }{ + s32 End = member.array; + } + RangeIterator(ArrayIndex, End) + { + member.has_tag(custom_ui)? + { + member.tag_value(custom_ui); + } + { + DoEditorUi(Ui, + Window, + Element->(member.name)+ArrayIndex, + FSz("member.name[%d]", ArrayIndex), + ThisHash, + Params); + } + member.is_primitive? { PushNewRow(Ui); } + } + CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); + } + PushNewRow(Ui); } { - member.is_union? + member.has_tag(custom_ui)? { - member.name? - { - DoEditorUi(Ui, - Window, - // Cast to remove const/volatile keywords if they're there - Cast((member.type)*, member.is_pointer?{}{&}Element->(member.name)), - CSz("member.name"), - Params - member.has_tag(ui_value_range)?{, member.tag_value(ui_value_range) }); - } - { - } + member.tag_value(custom_ui); } { - member.is_function? - { - } + member.is_type(b32)? { DoEditorUi(Ui, Window, - // Cast to remove const/volatile keywords if they're there - Cast((member.type)*, member.is_pointer?{}{&}Element->(member.name)), - CSz("member.name"), - Params + Cast(b8*, member.is_pointer?{}{&}Element->(member.name)), + MemberName, + ThisHash, + &DefaultUiRenderParams_Checkbox member.has_tag(ui_value_range)?{, member.tag_value(ui_value_range) }); } + { + member.is_union? + { + member.name? + { + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast((member.type)*, member.is_pointer?{}{&}Element->(member.name)), + MemberName, + ThisHash, + Params + member.has_tag(ui_value_range)?{, member.tag_value(ui_value_range) }); + } + { + } + } + { + member.is_function? + { + } + { + DoEditorUi(Ui, + Window, + // Cast to remove const/volatile keywords if they're there + Cast((member.type)*, member.is_pointer?{}{&}Element->(member.name)), + MemberName, + ThisHash, + Params + member.has_tag(ui_value_range)?{, member.tag_value(ui_value_range) }); + } + } + } } } } + + member.is_primitive? + { + PushNewRow(Ui); + } } - } - member.is_primitive? - { - PushNewRow(Ui); } } if (DidToggle) { CLOSE_INDENT_FOR_TOGGLEABLE_REGION(); } - PushTableEnd(Ui); + if (Name.Count) { PushTableEnd(Ui); } } else { @@ -278,52 +483,60 @@ poof( poof( func do_editor_ui_for_enum(enum_t) { - link_internal void - DoEditorUi(renderer_2d *Ui, window_layout *Window, enum_t.name *Element, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic) + enum_t.has_tag(ui_display_radio)? { - 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)) + do_editor_ui_for_radio_enum(enum_t) + } + { + link_internal void + DoEditorUi(renderer_2d *Ui, window_layout *Window, enum_t.name *Element, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Generic) { - PushNewRow(Ui); - enum_t.map(value) + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x(enum_t.hash)); + + if (Name.Count) { PushColumn(Ui, CS(Name), &DefaultUiRenderParams_Column); } + + cs ElementName = ToStringPrefixless(*Element); + ui_id ToggleButtonId = UiId(Window, "toggle enum_t.name", Element, ThisHash); + if (ToggleButton(Ui, ElementName, ElementName, ToggleButtonId, Params)) { - if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column - if (Button(Ui, CSz("value.name.strip_all_prefix"), UiId(Window, "enum value.name", Element), Params)) + PushNewRow(Ui); + enum_t.map(value) { - enum_t.has_tag(bitfield)? + if (Name.Count) { PushColumn(Ui, CSz("|")); } // Skip the first Name column + if (Button(Ui, CSz("value.name.strip_all_prefix"), UiId(Window, "enum value.name", Element, ThisHash), Params)) { - if ((value.name) == enum_t.name(0)) + enum_t.has_tag(bitfield)? { - *Element = enum_t.name(0); - } - else - { - if ((*Element & value.name) == value.name) + if ((value.name) == enum_t.name(0)) { - *Element = enum_t.name(*Element&~value.name); + *Element = enum_t.name(0); } else { - *Element = enum_t.name(*Element|value.name); + if ((*Element & value.name) == value.name) + { + *Element = enum_t.name(*Element&~value.name); + } + else + { + *Element = enum_t.name(*Element|value.name); + } } } - } - { - *Element = value.name; - } + { + *Element = value.name; + } - SetToggleButton(Ui, ToggleButtonId, False); + SetToggleButton(Ui, ToggleButtonId, False); + } + PushNewRow(Ui); } + } + else + { PushNewRow(Ui); } } - else - { - PushNewRow(Ui); - } } } ) @@ -332,16 +545,18 @@ poof( func do_editor_ui_for_container(type) { link_internal void - DoEditorUi(renderer_2d *Ui, window_layout *Window, type.name *Container, cs Name, EDITOR_UI_FUNCTION_PROTO_DEFAULTS) + DoEditorUi(renderer_2d *Ui, window_layout *Window, type.name *Container, cs Name, u32 ParentHash, EDITOR_UI_FUNCTION_PROTO_DEFAULTS) { + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ 0x(type.hash)); + if (Container) { - if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, Name.Start, Container), EDITOR_UI_FUNCTION_INSTANCE_NAMES)) + if (ToggleButton(Ui, FSz("v %S", Name), FSz("> %S", Name), UiId(Window, Name.Start, Container, ThisHash), EDITOR_UI_FUNCTION_INSTANCE_NAMES)) { PushNewRow(Ui); IterateOver(Container, Element, ElementIndex) { - DoEditorUi(Ui, Window, Element, CS(ElementIndex), EDITOR_UI_FUNCTION_INSTANCE_NAMES); + DoEditorUi(Ui, Window, Element, CS(ElementIndex), ThisHash, EDITOR_UI_FUNCTION_INSTANCE_NAMES); PushNewRow(Ui); } } @@ -368,6 +583,7 @@ poof( window_layout *Window, enum_t.name *Element, cs GroupName, + u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Generic, ui_toggle_button_group_flags ExtraFlags = ToggleButtonGroupFlags_None) { @@ -381,6 +597,17 @@ poof( poof(do_editor_ui_for_primitive_type({s64 u64 s32 u32 s16 u16 s8 u8})); #include + +poof( + for_datatypes(struct) + func (struct_t) + { + struct_t.has_tag(do_editor_ui)? { do_editor_ui_for_compound_type_decl(struct_t); } + } +) +#include + + link_internal void DebugSlider(renderer_2d *Ui, window_layout *Window, r32 *Value, cs Name, r32 Min, r32 Max, ui_render_params *Params = &DefaultUiRenderParams_Generic) { @@ -391,7 +618,7 @@ DebugSlider(renderer_2d *Ui, window_layout *Window, r32 *Value, cs Name, r32 Min auto Range = Max-Min; r32 PercFilled = ((*Value)-Min)/Range; - r32 Width = 100.f; + r32 Width = 50.f; if (Value) { @@ -419,17 +646,19 @@ DebugSlider(renderer_2d *Ui, window_layout *Window, r32 *Value, cs Name, r32 Min } link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, r32 *Value, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Generic, EDITOR_UI_VALUE_RANGE_PROTO_DEFAULTS) +DoEditorUi(renderer_2d *Ui, window_layout *Window, r32 *Value, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Generic, EDITOR_UI_VALUE_RANGE_PROTO_DEFAULTS) { + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ u32(u64(Name.Start))); + if (Name.Count) { PushColumn(Ui, Name, &DefaultUiRenderParams_Blank); } u32 Start = StartColumn(Ui, &DefaultUiRenderParams_Blank); PushTableStart(Ui); if (Value) { - if (Button(Ui, CSz("-"), UiId(Window, "decrement", Value))) { *Value = *Value - 1.f; } + if (Button(Ui, CSz("-"), UiId(Window, "decrement", Value, ThisHash))) { *Value = *Value - 1.f; } DebugSlider(Ui, Window, Value, {}, MinValue, MaxValue); - if (Button(Ui, CSz("+"), UiId(Window, "increment", Value))) { *Value = *Value + 1.f; } + if (Button(Ui, CSz("+"), UiId(Window, "increment", Value, ThisHash))) { *Value = *Value + 1.f; } } else { @@ -440,11 +669,13 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, r32 *Value, cs Name, ui_rende } link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, b8 *Value, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Checkbox) +DoEditorUi(renderer_2d *Ui, window_layout *Window, b8 *Value, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Checkbox) { UNPACK_UI_RENDER_PARAMS(Params); - interactable_handle ButtonHandle = PushButtonStart(Ui, UiId(Window, "toggle", Value), BStyle); + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ u32(u64(Name.Start))); + + interactable_handle ButtonHandle = PushButtonStart(Ui, UiId(Window, "toggle", Value, ThisHash), BStyle); PushColumn(Ui, CS(Name), &DefaultUiRenderParams_Generic); @@ -471,7 +702,7 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, b8 *Value, cs Name, ui_render } link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, cs *Value, cs Name, EDITOR_UI_FUNCTION_PROTO_DEFAULTS) +DoEditorUi(renderer_2d *Ui, window_layout *Window, cs *Value, cs Name, u32 ParentHash, EDITOR_UI_FUNCTION_PROTO_DEFAULTS) { PushColumn(Ui, CS(Name), EDITOR_UI_FUNCTION_INSTANCE_NAMES); Value ? @@ -480,8 +711,9 @@ DoEditorUi(renderer_2d *Ui, window_layout *Window, cs *Value, cs Name, EDITOR_UI } link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, void *Value, cs Name, ui_render_params *Params = &DefaultUiRenderParams_Column) +DoEditorUi(renderer_2d *Ui, window_layout *Window, void *Value, cs Name, u32 ParentHash, ui_render_params *Params = &DefaultUiRenderParams_Column) { + /* u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ u32(Name.Start)); */ if (Name.Count) { PushColumn(Ui, CS(Name), Params); } Value ? PushColumn(Ui, FSz("0x%x",umm(Value)), &DefaultUiRenderParams_Column) : @@ -495,17 +727,30 @@ poof(do_editor_ui_for_vector_type({v4i v4 v3i v3 v2i v2 Quaternion m4})); link_internal void -DoEditorUi(renderer_2d *Ui, window_layout *Window, cp *Value, cs Name, EDITOR_UI_FUNCTION_PROTO_DEFAULTS) +DoEditorUi(renderer_2d *Ui, window_layout *Window, cp *Value, cs Name, u32 ParentHash, EDITOR_UI_FUNCTION_PROTO_DEFAULTS) { - DoEditorUi(Ui, Window, &Value->WorldP, CSz("WorldP")); - DoEditorUi(Ui, Window, &Value->Offset, CSz("Offset")); + u32 ThisHash = ChrisWellonsIntegerHash_lowbias32(ParentHash ^ u32(u64(Name.Start))); + + DoEditorUi(Ui, Window, &Value->WorldP, CSz("WorldP"), ThisHash, Params); + DoEditorUi(Ui, Window, &Value->Offset, CSz("Offset"), ThisHash, Params); } +poof(string_and_value_tables(maybe_tag)) +#include +poof(do_editor_ui_for_enum(maybe_tag)) +#include + poof(string_and_value_tables(data_type)) #include poof(do_editor_ui_for_enum(data_type)) #include +poof(do_editor_ui_for_enum(shape_axis)) +#include + +poof(do_editor_ui_for_enum(voxel_rule_direction)) +#include + poof(do_editor_ui_for_compound_type(rect3)) #include @@ -518,21 +763,26 @@ poof(do_editor_ui_for_compound_type(rect3cp)) poof(block_array_h(asset_thumbnail, {8}, {})) #include -struct selection_modification_state +poof(do_editor_ui_for_compound_type(ray)) +#include + +poof(do_editor_ui_for_compound_type(maybe_ray)) +#include + +enum selection_modification_mode poof(@gen_string_and_value_tables @do_editor_ui) { - face_index ClickedFace; - v3 ClickedP[2]; + SelectionModificationMode_None, // Not modifying the selection + SelectionModificationMode_Initialize, // Initializing a new selection area + SelectionModificationMode_Modify, // Modifying the current selection area }; -enum level_editor_flags +struct selection_modification_state { - LevelEditorFlags_Noop = (1 << 0), - /* LevelEditorFlags_RecomputeStandingSpotsOnLevelLoad = (1 << 1), */ + // NOTE(Jesse): This is the source of truth for if we're modifying the selection + face_index ClickedFace; + v3 ClickedP[2]; }; -poof(radio_button_group_for_bitfield_enum(level_editor_flags)); -#include - enum ui_noise_type { NoiseType_Perlin, @@ -542,7 +792,7 @@ enum ui_noise_type poof(string_and_value_tables(ui_noise_type)) #include -poof(radio_button_group_for_bitfield_enum(ui_noise_type)); +poof(radio_button_group_for_enum(ui_noise_type)); #include poof(do_editor_ui_for_enum(ui_noise_type)) #include @@ -581,7 +831,7 @@ enum world_edit_tool { WorldEdit_Tool_Disabled, // poof(@ui_skip) WorldEdit_Tool_Select, // world_edit_selection_mode - WorldEdit_Tool_Brush, // world_edit_brush_type + /* WorldEdit_Tool_Brush, // world_edit_brush_type */ WorldEdit_Tool_Eyedropper, WorldEdit_Tool_BlitEntity, /* WorldEdit_Tool_StandingSpots, // Recomputes standing spots for an area */ @@ -596,21 +846,44 @@ enum world_edit_brush_type WorldEdit_BrushType_Layered, }; -// TODO(Jesse): Rename to .. something something behavior ? -enum world_edit_mode +enum world_edit_blend_mode { - WorldEdit_Mode_Attach, - WorldEdit_Mode_Remove, - WorldEdit_Mode_Paint, - WorldEdit_Mode_Disabled, // Useful for turning the layer off + WorldEdit_Mode_Additive, // Adds layer value to noise value + WorldEdit_Mode_Subtractive, // Subtracts layer value from noise value + WorldEdit_Mode_Multiply, + WorldEdit_Mode_Threshold, // Sets CurrentSample = SampleValue + WorldEdit_Mode_Disabled, // Useful for turning the layer off }; -// TODO(Jesse): Rename to reflect that it's the iteration pattern ..? -enum world_edit_mode_modifier +enum world_edit_color_blend_mode { - WorldEdit_Modifier_Default = 0, - WorldEdit_Modifier_Flood = (1<<0), - WorldEdit_Modifier_Surface = (1<<1), + WorldEdit_ColorBlendMode_ValuePositive, + WorldEdit_ColorBlendMode_ValueNegative, + + WorldEdit_ColorBlendMode_Surface, + + // TODO(Jesse): Put back in? + /* WorldEdit_ColorBlendMode_Additive, */ + /* WorldEdit_ColorBlendMode_Subtractive, */ + /* WorldEdit_ColorBlendMode_Multiply, */ + /* WorldEdit_ColorBlendMode_Divide, */ + + WorldEdit_ColorBlendMode_Disabled, // Useful for turning the layer off +}; + +enum world_edit_blend_mode_modifier poof(@bitfield) +{ + WorldEdit_Modifier_None = 0, + + /* WorldEdit_ValueModifier_Surface = (1<<0), */ + WorldEdit_ValueModifier_ClampPos = (1<<1), + WorldEdit_ValueModifier_ClampNeg = (1<<2), + WorldEdit_ValueModifier_Threshold = (1<<3), + + WorldEdit_ColorModifier_Discard = (1<<4), + + // NOTE(Jesse): Unsupported for now, unclear if it will be again .. + // WorldEdit_Modifier_Flood = xxxx, }; @@ -631,47 +904,47 @@ struct generic_noise_params }; // TODO(Jesse): Get rid of zMin -#define UNPACK_NOISE_PARAMS(P) \ - v3i WorldChunkDim = GetWorldChunkDim(); \ - v3i Dim = Chunk->Dim; \ - r32 Thresh = Cast(generic_noise_params*, (P))->Threshold; \ - s64 zMin = s64(Cast(generic_noise_params*, (P))->Threshold); \ - v3 Period = Cast(generic_noise_params*, (P))->Period; \ - s32 Amplitude = s32(Cast(generic_noise_params*, (P))->Amplitude); \ - v3 RGBColor = Cast(generic_noise_params*, (P))->RGBColor; \ - v3i SrcToDest = {-1*Global_ChunkApronMinDim}; +#define UNPACK_NOISE_PARAMS(P) \ + v3i WorldChunkDim = GetWorldChunkDim(); \ + v3i Dim = Chunk->Dim; \ + r32 Thresh = Cast(generic_noise_params*, (P))->Threshold; \ + s64 zMin = s64(Cast(generic_noise_params*, (P))->Threshold); \ + v3 Period = Cast(generic_noise_params*, (P))->Period; \ + s32 Amplitude = s32(Cast(generic_noise_params*, (P))->Amplitude); \ + v3 RGBColor = Cast(generic_noise_params*, (P))->RGBColor; \ + v3i SrcToDest = {} struct white_noise_params +poof(@do_editor_ui) { - r32 Threshold = 0.5f; }; + struct perlin_noise_params +poof(@do_editor_ui) { - r32 Threshold = 3.f; poof(@ui_value_range(0.1f, 20.f)) - v3 Period = {{8.f, 8.f, 8.f}}; poof(@ui_value_range(0.1f, 20.f)) - r32 Amplitude = 8.f; poof(@ui_value_range(0.1f, 20.f)) + v3 Period = {{8.f, 8.f, 8.f}}; poof(@ui_value_range(0.1f, 20.f)) }; poof(are_equal(perlin_noise_params)) #include struct voronoi_noise_params +poof(@do_editor_ui) { - r32 Threshold = 1.5f; poof(@ui_value_range(0.1f, 20.f)) v3 Period = {{10.f, 10.f, 10.f}}; poof(@ui_value_range(0.1f, 20.f)) - r32 Amplitude = 8.f; poof(@ui_value_range(0.1f, 20.f)) - r32 Squareness; r32 MaskChance; }; -poof(do_editor_ui_for_radio_enum(world_edit_mode_modifier)) -#include -poof(string_and_value_tables(world_edit_mode_modifier)) -#include +poof(string_and_value_tables(world_edit_blend_mode_modifier)) +#include + +poof(do_editor_ui_for_enum(world_edit_blend_mode_modifier)) +#include + @@ -683,13 +956,17 @@ poof(toggle_button_group_for_enum(engine_debug_view_mode)) poof(do_editor_ui_for_radio_enum(asset_window_view_mode)) #include -poof(string_and_value_tables(world_edit_mode)) -#include -/* poof(radio_button_group_for_bitfield_enum(world_edit_mode)); */ -/* #include */ +poof(string_and_value_tables(world_edit_blend_mode)) +#include + +poof(do_editor_ui_for_enum(world_edit_blend_mode)) +#include + +poof(string_and_value_tables(world_edit_color_blend_mode)) +#include +poof(do_editor_ui_for_enum(world_edit_color_blend_mode)) +#include -poof(do_editor_ui_for_radio_enum(world_edit_mode)) -#include poof(do_editor_ui_for_radio_enum(world_edit_tool)) #include @@ -704,27 +981,22 @@ poof(do_editor_ui_for_radio_enum(world_edit_brush_type)) -enum world_update_op_shape_type -{ - type_world_update_op_shape_params_noop, +/* enum world_update_op_shape_type */ +/* { */ +/* type_world_update_op_shape_params_noop, */ - type_world_update_op_shape_params_sphere, - type_world_update_op_shape_params_rect, - type_world_update_op_shape_params_asset, - type_world_update_op_shape_params_chunk_data, +/* type_world_update_op_shape_params_sphere, */ +/* type_world_update_op_shape_params_rect, */ +/* type_world_update_op_shape_params_cylinder, */ +/* type_world_update_op_shape_params_asset, */ +/* type_world_update_op_shape_params_chunk_data, */ - type_world_update_op_shape_params_count, -}; - -poof(string_and_value_tables(world_update_op_shape_type)) -#include +/* type_world_update_op_shape_params_count, */ +/* }; */ +/* poof(string_and_value_tables(world_update_op_shape_type)) */ +/* #include */ -struct world_update_op_shape_params_rect -{ - // Sim-space positions - rect3 Region; poof(@ui_disable) -}; struct asset; struct world_update_op_shape_params_asset @@ -740,17 +1012,58 @@ struct world_update_op_shape_params_chunk_data v3 SimSpaceOrigin; }; +struct world_update_op_shape_params_rect +poof(@do_editor_ui) +{ + v3 Dim; +}; + struct world_update_op_shape_params_sphere +poof(@do_editor_ui) { - cp Location; poof(@ui_disable) - f32 Radius = 10.f; poof(@ui_disable) + cp Location; poof(@ui_skip) + f32 Radius = 10.f; }; + +struct world_update_op_shape_params_line +{ + cp P0; poof(@ui_skip) + cp P1; poof(@ui_skip) + r32 Radius = 10.f; +}; + +struct world_update_op_shape_params_cylinder +poof(@do_editor_ui) +{ + r32 Radius = 4.f; + r32 Height = 25.f; +}; + +struct world_update_op_shape_params_plane +poof(@do_editor_ui) +{ + shape_axis Orientation; + f32 Thickness = 2.f; +}; + +struct world_update_op_shape_params_torus +poof(@do_editor_ui) +{ + f32 MajorRadius = 20.f; + f32 MinorRadius = 3.f; +}; + + +// @sdf_shape_step(2): Add new asset struct here +// + +#if 0 struct world_edit_shape { world_update_op_shape_type Type; - - union { + union poof(@d_union_type_target) + { world_update_op_shape_params_sphere world_update_op_shape_params_sphere; world_update_op_shape_params_rect world_update_op_shape_params_rect; world_update_op_shape_params_asset world_update_op_shape_params_asset; @@ -758,12 +1071,12 @@ struct world_edit_shape }; }; -struct world_edit_brush +struct world_edit_brush_constraints { world_edit_shape Shape; - world_edit_mode Mode; - world_edit_mode_modifier Modifier; + world_edit_blend_mode Mode; + world_edit_blend_mode_modifier Modifier; // NOTE(Jesse): If Modifier is Flood, this is set to where the flood should start // @@ -776,9 +1089,9 @@ struct world_edit_brush /* v3 SimFloodOrigin; */ }; -poof(do_editor_ui_for_compound_type(world_edit_brush)) +poof(do_editor_ui_for_compound_type(world_edit_brush_constraints)) #include - +#endif @@ -789,42 +1102,62 @@ poof(do_editor_ui_for_compound_type(world_edit_brush)) enum shape_type { - // NOTE(Jesse): Having this none value is kinda janky; I'd prefer to not for - // this enum, but since we have to overlap with type_world_update_op_shape_params - // we kinda have to have it (so that the none value draws if we accidentally set it to 0. - // - // type_world_update_op_shape_params doesn't strictly require a 0 value, - // but it's really nice to have the assertion in DoWorldUpdate + ShapeType_Rect = 0, + ShapeType_Sphere = 1, + ShapeType_Line = 2, + ShapeType_Cylinder = 3, + ShapeType_Plane = 4, + ShapeType_Torus = 5, + + // @sdf_shape_step(1): Add shape types here // - // Once this code matures a bit we can probably take this _None value - // out. It's strictly so we get a visual trigger in the UI. - // - ShapeType_None = type_world_update_op_shape_params_noop, - ShapeType_Sphere = type_world_update_op_shape_params_sphere, - ShapeType_Rect = type_world_update_op_shape_params_rect, }; poof(string_and_value_tables(shape_type)) #include +struct shape_layer_advanced_params +poof(@do_editor_ui) +{ + r32 Rounding; + v3 Stretch; + v3 Repeat; + v3 Axis; poof(@ui_value_range(-1.f, 1.f)) +}; + struct shape_layer +poof(@do_editor_ui) { - shape_type Type = ShapeType_Sphere; + shape_type Type; poof(@ui_display_name(CSz("Shape Type"))) // NOTE(Jesse): Intentionally not a d-union such that you can toggle between // them and your parameter selections stay intact. - world_update_op_shape_params_sphere Sphere; - world_update_op_shape_params_rect Rect; + world_update_op_shape_params_rect Rect; poof(@ui_display_name({}) @ui_display_condition(Element->Type == ShapeType_Rect)) + world_update_op_shape_params_sphere Sphere; poof(@ui_display_name({}) @ui_display_condition(Element->Type == ShapeType_Sphere)) + world_update_op_shape_params_sphere Line; poof(@ui_display_name({}) @ui_display_condition(Element->Type == ShapeType_Line)) + world_update_op_shape_params_cylinder Cylinder; poof(@ui_display_name({}) @ui_display_condition(Element->Type == ShapeType_Cylinder)) + world_update_op_shape_params_plane Plane; poof(@ui_display_name({}) @ui_display_condition(Element->Type == ShapeType_Plane)) + world_update_op_shape_params_torus Torus; poof(@ui_display_name({}) @ui_display_condition(Element->Type == ShapeType_Torus)) + // @sdf_shape_step(6): Add an instance of the new shape here + // + + + // NOTE(Jesse): Just in another struct for the UI + shape_layer_advanced_params Advanced; }; // NOTE(Jesse): This is intentionally not a d_union such that you can flip // between different noise selections and your parameters stay intact. -struct noise_layer poof(@version(1)) +struct noise_layer +poof( + @do_editor_ui + @version(1) + ) { - ui_noise_type Type; + ui_noise_type Type; poof(@ui_display_name(CSz("Noise Type"))) - white_noise_params White; - perlin_noise_params Perlin; - voronoi_noise_params Voronoi; + white_noise_params White; poof(@ui_display_name({}) @ui_display_condition(Element->Type == NoiseType_White)) + perlin_noise_params Perlin; poof(@ui_display_name({}) @ui_display_condition(Element->Type == NoiseType_Perlin)) + voronoi_noise_params Voronoi; poof(@ui_display_name({}) @ui_display_condition(Element->Type == NoiseType_Voronoi)) }; struct noise_layer_0 @@ -853,298 +1186,243 @@ enum brush_layer_type BrushLayerType_Shape, }; -poof(do_editor_ui_for_radio_enum(brush_layer_type)) -#include +poof(string_and_value_tables(brush_layer_type)) +#include + +poof(do_editor_ui_for_enum(brush_layer_type)) +#include -struct brush_settings poof(@version(3)) +struct brush_settings +poof(@do_editor_ui) { - brush_layer_type Type; + brush_layer_type Type; poof(@ui_display_name(CSz("Brush Type"))) - noise_layer Noise; - shape_layer Shape; + noise_layer Noise; poof(@ui_display_name({}) @ui_display_condition(Element->Type == BrushLayerType_Noise)) + shape_layer Shape; poof(@ui_display_name({}) @ui_display_condition(Element->Type == BrushLayerType_Shape)) // // Common across brush types // - world_edit_mode Mode; - world_edit_mode_modifier Modifier; - s32 Iterations = 1; // NOTE(Jesse): How many times to do the filter. - // NOTE(Jesse): This is the relative offset from the base selection. - // Used to inflate or contract the area affected by the brush. - // - // TODO(Jesse): Rename to dilation - rect3i Offset; + f32 Power = 10.f; // poof(@ui_value_range( 0.f, 25.f) @ui_display_condition(HasThresholdModifier(Element))) + r32 ValueBias = 0.f; poof(@ui_value_range(-1.f, 1.f)) + f32 Threshold = 0.f; poof(@ui_value_range( 0.f, 1.f) @ui_display_condition(HasThresholdModifier(Element))) - v3i NoiseBasisOffset; + world_edit_blend_mode_modifier ValueModifier; + world_edit_blend_mode BlendMode; + world_edit_color_blend_mode ColorMode; - /* v3 HSVColor = DEFAULT_HSV_COLOR; */ - v3 RGBColor = DEFAULT_RGB_COLOR; b8 Invert; -}; - -// TODO(Jesse): Rename to `brush` ..? -struct brush_settings_2 -{ - brush_layer_type Type; - noise_layer Noise; - shape_layer Shape; - // - // Common across brush types - // - world_edit_mode Mode; - world_edit_mode_modifier Modifier; - s32 Iterations = 1; // NOTE(Jesse): How many times to do the filter. - // NOTE(Jesse): This is the relative offset from the base selection. - // Used to inflate or contract the area affected by the brush. - // - // TODO(Jesse): Rename to dilation - rect3i Offset; - v3i NoiseBasisOffset; - u16 Color = 1; poof(@custom_marshal(Live->RGBColor = MagicaVoxelDefaultPaletteToRGB(Stored->Color);)) // Default to white - b8 Invert; -}; -poof(are_equal(brush_settings)) -#include - -struct brush_settings_1 -{ - brush_layer_type Type; - - noise_layer Noise; - shape_layer Shape; - - // - // Common across brush types - // - world_edit_mode Mode; - world_edit_mode_modifier Modifier; - s32 Iterations = 1; // NOTE(Jesse): How many times to do the filter. + s32 Iterations = 1; poof(@ui_skip) // NOTE(Jesse): This is the relative offset from the base selection. // Used to inflate or contract the area affected by the brush. - rect3i Offset; - - v3i NoiseBasisOffset; - - u16 Color = 1; poof(@custom_marshal(Live->RGBColor = MagicaVoxelDefaultPaletteToRGB(Stored->Color);)) // Default to white -}; - -struct brush_settings_0 -{ - brush_layer_type Type; - - noise_layer Noise; - shape_layer Shape; - - // - // Common across brush types // - world_edit_mode Mode; - world_edit_mode_modifier Modifier; - s32 Iterations = 1; // NOTE(Jesse): How many times to do the filter. + // TODO(Jesse): Rename to dilation + rect3i Offset; poof(@ui_skip) - // NOTE(Jesse): This is the relative offset from the base selection. - // Used to inflate or contract the area affected by the brush. - rect3i Offset; + v3i NoiseBasisOffset; poof(@ui_skip) - u16 Color = 1; poof(@custom_marshal(Live->RGBColor = MagicaVoxelDefaultPaletteToRGB(Stored->Color);)) // Default to white + // NOTE(Jesse): The color picker operates in HSV, so we need this to be HSV for now + v3 HSVColor = DEFAULT_HSV_COLOR; poof(@custom_ui(PushColumn(Ui, CSz("HSVColor")); DoColorPickerToggle(Ui, Window, &Element->HSVColor, False, ThisHash))) }; -link_internal void -Marshal(brush_settings_2 *Stored, brush_settings *Live) -{ - poof(default_marshal(brush_settings_2)) -#include -} - -link_internal void -Marshal(brush_settings_1 *Stored, brush_settings *Live) -{ - poof(default_marshal(brush_settings_1)) -#include -} - -link_internal void -Marshal(brush_settings_0 *Stored, brush_settings *Live) -{ - poof(default_marshal(brush_settings_0)) -#include -} - +poof(are_equal(brush_settings)) +#include struct brush_layer +poof(@do_editor_ui) { - brush_settings Settings; + brush_settings Settings; poof(@ui_display_name({})) brush_settings PrevSettings; poof(@no_serialize @ui_skip) // Change detection }; -#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(3)) +struct layered_brush { - // NOTE(Jesse): This is so we can just copy the name of the brush in here and - // not fuck around with allocating a single string when we load these in. - char NameBuf[NameBuf_Len+1]; poof(@no_serialize @ui_text_box) - // NOTE(Jesse): The layer previews have to be seperate from the brush_layer // because the deserialization code isn't smart enough to not stomp on the // texture handles when it marshals old types to the current one. s32 LayerCount; - brush_layer Layers[MAX_BRUSH_LAYERS]; poof(@array_length(LayerCount)) - chunk_thumbnail LayerPreviews[MAX_BRUSH_LAYERS]; poof(@array_length(LayerCount) @no_serialize) + brush_layer Layers [MAX_BRUSH_LAYERS]; poof(@array_length(Element->LayerCount)) - chunk_thumbnail SeedLayer; poof(@no_serialize) // NOTE(Jesse): Special layer that acts as the seed value + /* chunk_thumbnail LayerPreviews[MAX_BRUSH_LAYERS]; poof(@array_length(LayerCount) @no_serialize) */ + /* chunk_thumbnail SeedLayer; poof(@no_serialize) // NOTE(Jesse): Special layer that acts as the seed value */ - b8 SeedBrushWithSelection; - b8 BrushFollowsCursor; + b8 AffectExisting = True; + /* b8 BrushFollowsCursor; */ // NOTE(Jesse): These are the global settings for the brush when it gets applied to the world. - world_edit_mode Mode; - world_edit_mode_modifier Modifier; + /* world_edit_blend_mode Mode; */ + /* world_edit_blend_mode_modifier Modifier; */ // NOTE(Jesse): This is actually just using the chunk .. should probably change it - chunk_thumbnail Preview; poof(@no_serialize) + /* chunk_thumbnail Preview; poof(@no_serialize) */ }; -struct layered_brush_editor_2 -{ - // NOTE(Jesse): This is so we can just copy the name of the brush in here and - // not fuck around with allocating a single string when we load these in. - char NameBuf[NameBuf_Len+1]; poof(@no_serialize @ui_text_box) - s32 LayerCount; - brush_layer Layers[MAX_BRUSH_LAYERS]; poof(@array_length(LayerCount)) - b8 SeedBrushWithSelection; - b8 BrushFollowsCursor; - chunk_thumbnail Preview; poof(@no_serialize) + + +struct single_brush +{ + world_edit_blend_mode Mode; }; -struct layered_brush_editor_1 +struct asset_brush { - char NameBuf[NameBuf_Len]; + world_edit_blend_mode Mode; + world_edit_blend_mode_modifier Modifier; +}; - s32 LayerCount = 1; - brush_layer Layers[MAX_BRUSH_LAYERS]; poof(@array_length(LayerCount)) - b8 SeedBrushWithSelection; - b8 BrushFollowsCursor; - chunk_thumbnail Preview; poof(@no_serialize) -}; -struct layered_brush_editor_0 -{ - s32 LayerCount = 1; - brush_layer Layers[MAX_BRUSH_LAYERS]; poof(@array_length(LayerCount)) - chunk_thumbnail Preview; poof(@no_serialize) - b8 SeedBrushWithSelection; poof(@no_serialize) -}; -link_internal void -Marshal(layered_brush_editor_2 *Stored, layered_brush_editor *Live) -{ - poof(default_marshal(layered_brush_editor_2)) -#include -} -link_internal void -Marshal(layered_brush_editor_1 *Stored, layered_brush_editor *Live) +struct world_edit_brush { - poof(default_marshal(layered_brush_editor_1)) -#include -} + // NOTE(Jesse): This is so we can just copy the name of the brush in here and + // not fuck around with allocating a single string when we load these in. +#define NameBuf_Len (256) + char NameBuf[NameBuf_Len+1]; poof(@ui_text_box @ui_construct_as(CS)) + + /* world_edit_shape Shape; */ + world_edit_blend_mode Mode; + world_edit_blend_mode_modifier Modifier; + + /* world_edit_brush_type Type; */ + /* union */ + /* { */ + /* single_brush Single; */ + /* asset_brush Asset; */ + layered_brush Layered; + /* }; */ +}; -link_internal void -Marshal(layered_brush_editor_0 *Stored, layered_brush_editor *Live) +link_internal umm +Hash(world_edit_brush *Brush) { - poof(default_marshal(layered_brush_editor_0)) -#include + umm Result = Hash(CS(Brush->NameBuf)); + return Result; } +poof(are_equal(world_edit_brush)) +#include +poof(hashtable(world_edit_brush)) +#include - - -struct single_brush_settings +struct world_edit poof(@do_editor_ui) { - world_edit_mode Mode; + // TODO(Jesse): Rename to Bounds? + rect3cp Region = InvertedInfinityRectangle_rect3cp(); + world_edit_brush *Brush; + + // TODO(Jese): Pack these into a Flags field + // { + b32 Tombstone; + + // NOTE(Jesse): Need this so we don't have to do an n^2 loop when doing + // SelectEdit such that we can also makes + // + // Not my favorite, but it's also not the end of the world. + b32 Selected; + // } + u32 Ordinal; }; +typedef world_edit* world_edit_ptr; -struct asset_brush_settings -{ - world_edit_mode Mode; - world_edit_mode_modifier Modifier; -}; - +// TODO(Jesse): Add `add_tag` to poof so we can reinstate this +// +/* poof(block_array(world_edit, {128})) */ +#include +poof(block_array(world_edit_ptr, {128})) +#include +/* poof(add_tag(world_edit_block_array_index, block_array_IndexOfValue)) */ +poof(block_array(world_edit_block_array_index, {128})) +#include +struct world_edit_layer +{ + char NameBuf[NameBuf_Len+1]; + // NOTE(Jesse): type name is confusing here .. this is an array of indices into + // the world_edit block array + world_edit_block_array_index_block_array EditIndices; +}; +poof(block_array(world_edit_layer, {128})) +#include -struct level_editor +// NOTE(Jesse): This isn't really meant to be used outside the the level_editor +// I just packed all the things together such that it's a bit more obvious +// they're all for doing the selection +struct selection_region poof(@do_editor_ui) { - memory_arena *Memory; - - world_edit_tool Tool; - world_edit_tool PreviousTool; // So we can 'pop' back to the last tool on select/eyedropper - - world_edit_brush_type BrushType; + u32 Clicks; - single_brush_settings SingleBrush; - asset_brush_settings AssetBrush; - layered_brush_editor LayeredBrushEditor; + // NOTE(Jesse): We need to save the first point we clicked such that we can + // synthetically construct the region and construct it while we're clicking + // on a second point. The problem without this Base point is that we don't + // know if the point we clicked is the min or the max of the current box. + // There's probably a way to get around having this Base point, but it's not + // really a big deal. + cp Base; - b8 SelectionFollowsCursor; + rect3cp Region = InvertedInfinityRectangle_rect3cp(); - b32 RootChunkNeedsNewMesh; + v3 Diff; // When Changed is set, this should be nonzero. + b32 InitialSelect; // Set when we go from a partial selection state -> fully selected - cp MostRecentSelectionRegionMin; - cp NextSelectionRegionMin; - cp EditorPreviewRegionMin; + selection_modification_mode ModMode; + selection_modification_state ModState; +}; - u64 EngineDebugViewModeToggleBits; +struct level_editor +poof(@do_editor_ui) +{ + memory_arena *Memory; - /* u16 SelectedColorIndex; */ - u16 HoverColorIndex; + selection_region Selection; - b32 SelectionChanged; - u32 SelectionClicks; - cp SelectionBase; + asset_thumbnail_block_array AssetThumbnails; - rect3cp SelectionRegion; - rect3cp PrevSelectionRegion; // Change detection - // - rect3cp CopyRegion; + // Used for naming layers during NewLayer + u32 NextLayerIndex; - // Recorded when accel-clicking on the selection to manipulate it - selection_modification_state Selection; - selection_modification_state Entity; + world_edit_layer_block_array Layers; + world_edit_layer_block_array_index SelectedLayerIndex = {INVALID_BLOCK_ARRAY_INDEX}; - asset_thumbnail_block_array AssetThumbnails; + world_edit_block_array Edits; + world_edit_block_array_index_block_array SelectedEditIndices; - b32 NewAssetFromSelection; - char NewAssetFromSelectionFilename[512]; + world_edit *HotEdit; // Hovered + world_edit_block_array_index HotEditIndex; - /* v3 HSVColorSelection = {{0.f, 0.8f, 0.5f}}; */ + // TODO(Jesse): This is a stupid form of stoarge. We don't ever look anything + // up, we just keep pointers into it. Change to a paged-array and store the + // indices such that we save space when doing serialize/deserialize; + world_edit_brush_hashtable LoadedBrushes; + world_edit_brush *CurrentBrush; }; @@ -1167,22 +1445,20 @@ SelectionIncomplete(u32 SelectionClicks) link_internal void ResetSelection(level_editor *Editor) { - Editor->SelectionClicks = 0; - Editor->SelectionBase = {}; - Editor->SelectionRegion = {}; + Editor->Selection = {}; } link_internal void ResetSelectionIfIncomplete(level_editor *Editor) { - if (SelectionIncomplete(Editor->SelectionClicks)) { ResetSelection(Editor); } + if (SelectionIncomplete(Editor->Selection.Clicks)) { ResetSelection(Editor); } } link_internal rect3 GetSelectionRect(world *World, level_editor *Editor) { - v3 SelectionMinP = GetSimSpaceP(World, Editor->SelectionRegion.Min); - v3 SelectionMaxP = GetSimSpaceP(World, Editor->SelectionRegion.Max); + v3 SelectionMinP = GetSimSpaceP(World, Editor->Selection.Region.Min); + v3 SelectionMaxP = GetSimSpaceP(World, Editor->Selection.Region.Max); rect3 Result = RectMinMax(SelectionMinP, SelectionMaxP); return Result; @@ -1191,30 +1467,161 @@ GetSelectionRect(world *World, level_editor *Editor) link_internal v3i GetSelectionDim(world *World, level_editor *Editor) { - v3 SelectionMinP = GetSimSpaceP(World, Editor->SelectionRegion.Min); - v3 SelectionMaxP = GetSimSpaceP(World, Editor->SelectionRegion.Max); + v3 SelectionMinP = GetSimSpaceP(World, Editor->Selection.Region.Min); + v3 SelectionMaxP = GetSimSpaceP(World, Editor->Selection.Region.Max); v3i Result = V3i(SelectionMaxP - SelectionMinP); return Result; } +link_internal shape_axis +ComputeShapeAxisFromEditDim(v3 Dim) +{ + shape_axis Result = ShapeAxis_Count; + + f32 MaxAxisValue = Max(Max(Dim.x, Dim.y), Dim.z); + if (MaxAxisValue == Dim.x) { Result = ShapeAxis_PosX; } + if (MaxAxisValue == Dim.y) { Result = ShapeAxis_PosY; } + if (MaxAxisValue == Dim.z) { Result = ShapeAxis_PosZ; } + + Assert(Result != ShapeAxis_Count); + + return Result; +} + +link_internal world_edit_selection_mode +ComputeSelectionMode(input *Input) +{ + world_edit_selection_mode SelectionMode = {}; + + // Intentionally an el-if chain from most specific, to least. What's the alternative? + // + // Alt is move + // Shift is resize + // + if (Input->Shift.Pressed && Input->Ctrl.Pressed && Input->Alt.Pressed) + { + SelectionMode = SelectionMode_ResizeAllAxies; + } + else if (Input->Shift.Pressed && Input->Ctrl.Pressed) + { + SelectionMode = SelectionMode_ResizeBothLinearAxies; + } + else if (Input->Alt.Pressed && Input->Ctrl.Pressed) + { + SelectionMode = SelectionMode_TranslateLinear; + } + else if (Input->Shift.Pressed) + { + SelectionMode = SelectionMode_ResizeSingleLinearAxis; + } + else if (Input->Alt.Pressed) + { + SelectionMode = SelectionMode_TranslatePlanar; + } + + return SelectionMode; +} + +link_internal f32 +GetSelectionThicknessForDistance(f32 Distance) +{ + f32 Result = Clamp(0.25f, Distance / 3000.f, 12.f); + return Result; +} + +link_internal world_edit_layer * +TryGetSelectedLayer(level_editor *Editor) +{ + world_edit_layer *Result = TryGetPtr(&Editor->Layers, Editor->SelectedLayerIndex); + return Result; +} + +link_internal b32 +HasThresholdModifier(brush_settings *Element) +{ + b32 Result = (Element->ValueModifier&WorldEdit_ValueModifier_Threshold || Element->BlendMode&WorldEdit_Mode_Threshold); + return Result; +} + +link_internal r32 +GetPowerFor(world *World, world_edit *Edit, brush_settings *Settings) +{ + r32 Result = 0.f; + switch (Settings->Type) + { + case BrushLayerType_Noise: + { + Result = Settings->Power; + } break; + + case BrushLayerType_Shape: + { + switch (Settings->Shape.Type) + { + case ShapeType_Rect: + { + aabb Rect = GetSimSpaceRect(World, Edit->Region); + v3 Dim = GetDim(Rect); + Result = MaxChannel(Dim)/4.f; + } break; + + case ShapeType_Sphere: + { + Result = Settings->Shape.Sphere.Radius; + } break; + + case ShapeType_Line: + case ShapeType_Cylinder: + case ShapeType_Plane: + { + NotImplemented; + Result = 0.f; + } break; + + case ShapeType_Torus: + { + Result = Settings->Shape.Torus.MajorRadius; + } break; + } + } break; + } + + return Result; +} + + +link_internal b32 +CheckSettingsChanged(layered_brush *); + +link_internal b32 +CheckSettingsChanged(world_edit *); link_internal b32 HardResetEditor(level_editor *Editor); link_internal v3 -GetHotVoxelForEditMode(engine_resources *Engine, world_edit_mode WorldEditMode); +GetHotVoxelForEditMode(engine_resources *Engine, world_edit_blend_mode WorldEditMode); link_internal v3 -GetHotVoxelForFlood(engine_resources *Engine, world_edit_mode WorldEditMode, world_edit_mode_modifier Modifier); +GetHotVoxelForFlood(engine_resources *Engine, world_edit_blend_mode WorldEditMode, world_edit_blend_mode_modifier Modifier); -link_internal void -ApplyBrushLayer(engine_resources *Engine, brush_layer *Layer, chunk_thumbnail *Preview, world_chunk *DestChunk, v3i SmallestMinOffset); +/* link_internal void */ +/* ApplyBrushLayer(engine_resources *Engine, brush_layer *Layer, chunk_thumbnail *Preview, world_chunk *DestChunk, v3i SmallestMinOffset); */ link_internal v3i -GetSmallestMinOffset(layered_brush_editor *LayeredBrush, v3i *LargestLayerDim = 0); +GetSmallestMinOffset(layered_brush *LayeredBrush, v3i *LargestLayerDim = 0); -link_internal void -DrawEditorPreview(engine_resources *Engine, shader *Shader); +/* link_internal void */ +/* DrawEditorPreview(engine_resources *Engine, shader *Shader); */ link_internal void ColorPickerModal(engine_resources *Engine, ui_id ModalId, v3 *HSVDest, b32 ShowColorSwatch = True); + +link_internal void +DoColorPicker(renderer_2d *Ui, window_layout *Window, v3 *HSVDest, b32 ShowColorSwatch, u32 ParentHash); + +link_internal void +DoColorPickerToggle(renderer_2d *Ui, window_layout *Window, v3 *HSVDest, b32 ShowColorSwatch, u32 ParentHash); + +link_internal sort_key_buffer +GetEditsSortedByOrdianl(world_edit_block_array *Edits, memory_arena *TempMem); diff --git a/src/engine/engine.cpp b/src/engine/engine.cpp index 84765813e..ca036cf9b 100644 --- a/src/engine/engine.cpp +++ b/src/engine/engine.cpp @@ -1,8 +1,13 @@ +#include + +#include + #include #include #include +#include #include #include #include @@ -12,24 +17,32 @@ #include #include #include -#include #include + +#include #include -#include -#include + +#include +#include +#include + +#include // NOTE(Jesse): generated code for ser/des +#include // NOTE(Jesse): Functions acting as basis for ser/des #include -#include #include +#include #include #include #include #include // TODO(Jesse): Probably time to split this up? #include +#include +#include #include -#include // NOTE(Jesse): generated code for ser/des -#include // NOTE(Jesse): Functions acting as basis for ser/des +#include + #include #include #include @@ -39,6 +52,6 @@ #include #include -#include +/* #include */ #include diff --git a/src/engine/engine.h b/src/engine/engine.h index 59529ba12..db4c4ad70 100644 --- a/src/engine/engine.h +++ b/src/engine/engine.h @@ -4,6 +4,7 @@ #include #include + #include #include #include @@ -18,11 +19,14 @@ struct engine_resources; link_internal engine_resources *GetEngineResources(); #include +#include #include #include #include #include +#include +#include #include #include #include @@ -30,22 +34,22 @@ link_internal engine_resources *GetEngineResources(); #include #include +#include #include #include #include #include +#include +#include #include -#include #include -#include -#include #include #include -#include #include +#include #include #include @@ -59,3 +63,4 @@ link_internal engine_resources *GetEngineResources(); #include #include +#include diff --git a/src/engine/entity.cpp b/src/engine/entity.cpp index 7f39d9c92..d568f89be 100644 --- a/src/engine/entity.cpp +++ b/src/engine/entity.cpp @@ -7,7 +7,21 @@ Deactivate(particle_system *System) link_internal void Destroy(entity *Entity) { - DropEntityFromPreviouslyOccupiedChunks(GetEngineResources()->World, Entity, GetTranArena()); + // nopush + // nopush + // nopush + // nopush + // nopush + // nopush + // nopush + // nopush + // nopush + // nopush + // nopush + // nopush + // nopush + // nopush + /* DropEntityFromPreviouslyOccupiedChunks(GetEngineResources()->World, Entity, GetTranArena()); */ Assert( Spawned(Entity) ); Entity->State = EntityState_Destroyed; @@ -18,7 +32,21 @@ Destroy(entity *Entity) link_internal void Unspawn(entity *Entity) { - DropEntityFromPreviouslyOccupiedChunks(GetEngineResources()->World, Entity, GetTranArena()); + // nopush + // nopush + // nopush + // nopush + // nopush + // nopush + // nopush + // nopush + // nopush + // nopush + // nopush + // nopush + // nopush + // nopush + /* DropEntityFromPreviouslyOccupiedChunks(GetEngineResources()->World, Entity, GetTranArena()); */ Entity->State = EntityState_Free; Assert(Entity->Emitter); @@ -67,9 +95,9 @@ GetCollision_Entities( world *World, entity *ThisEntity, cp TestP, v3 CollisionD { IterateOver(&(*Chunk)->Entities, Entity, EntityIndex) { - if (*Entity == ThisEntity) continue; + if (Entity == ThisEntity) continue; - Hit = GetCollision(World, *Entity, AABBMinDim(SimP, CollisionDim)); + Hit = GetCollision(World, Entity, AABBMinDim(SimP, CollisionDim)); if (Hit) break; } if (Hit) break; @@ -185,7 +213,9 @@ GetCollision( world *World, aabb SimSpaceCollisionDim ) { v3i Offset = V3i(x,y,z); s32 Index = GetIndex(Offset, Chunk->Dim); - if (Chunk->Voxels[Index].Flags & Voxel_Filled) + s32 vOccupancy = GetOccupancyBit(Chunk->Occupancy, Index); + + if (vOccupancy) { cp Hit = {V3(Offset), Chunk->WorldP}; /* Assert(Hit > Result.MaxP); */ @@ -263,6 +293,8 @@ GetCollision(world *World, entity *Entity, v3 Offset = V3(0,0,0) ) link_internal entity * GetEntity(entity **EntityTable, entity_id Id) { + TIMED_FUNCTION(); + entity *Result = {}; // NOTE(Jesse): A Generation of 0 means the entity has never been allocated @@ -415,21 +447,44 @@ SpawnEntity(entity *Entity) { /* canonical_position CP = Canonicalize(World->ChunkDim, V3(x, y, z), InitialP->WorldP); */ cp CP = Canonical_Position(V3(0), V3i(x,y,z)); - world_chunk *Chunk = GetWorldChunkFromHashtable( World, CP.WorldP ); - if (Chunk == 0) + /* world_chunk *Chunk = GetWorldChunkFromHashtable( World, CP.WorldP ); */ + /* octree_node *Node = GetWorldChunkFromOctree( World, CP.WorldP ); */ + /* if (Node == 0) */ { - Chunk = AllocateAndInsertChunk(World, CP.WorldP); - if (Chunk) - { - QueueChunkForInit(&GetEngineResources()->Stdlib.Plat.HighPriority, Chunk, MeshBit_Lod0); - } + //nopush + //do we care? + /* NotImplemented; */ + /* Chunk = AllocateAndInsertChunk(World, CP.WorldP); */ + /* if (Chunk) */ + /* { */ + /* QueueChunkForInit(&GetEngineResources()->Stdlib.Plat.HighPriority, Chunk, MeshBit_Lod0); */ + /* } */ } } } } } - InsertEntityIntoChunks(World, Entity, GetTranArena()); + // nopush + // nopush + // nopush + // nopush + // nopush + // nopush + // nopush + // nopush + // nopush + // nopush + // nopush + // nopush + // nopush + // nopush + // nopush + // nopush + // nopush + // nopush + // nopush + /* InsertEntityIntoChunks(World, Entity, GetTranArena()); */ Entity->State = EntityState_Spawned; } @@ -1314,6 +1369,16 @@ Intersect(world *World, entity *First, aabb *Second) return Result; } +// TODO(Jesse): There's probably a better way to do this .. +inline b32 +Intersect(world *World, rect3cp *First, rect3cp *Second) +{ + rect3 R0 = GetSimSpaceAABB(World, First); + rect3 R1 = GetSimSpaceAABB(World, Second); + b32 Result = Intersect(&R0, &R1); + return Result; +} + inline b32 Intersect(world *World, aabb *First, entity *Second) { @@ -1448,7 +1513,7 @@ SimulateEntity(engine_resources *Resources, entity *Entity, r32 dt, v3i VisibleR { if (UiCapturedMouseInput(Ui) == False) { - f32 CameraSpeed = Camera->DistanceFromTarget * Camera->Blend/100.f; + f32 CameraSpeed = Camera->Speed * (Camera->DistanceFromTarget * Camera->Blend/100.f); v3 Offset = GetCameraRelativeInput(Hotkeys, Camera); Offset.z = 0; // Constrain to XY plane @@ -1456,7 +1521,7 @@ SimulateEntity(engine_resources *Resources, entity *Entity, r32 dt, v3i VisibleR if (Input->Q.Pressed) { Offset.z -= 1.f; } Offset = Normalize(Offset); - Entity->P.Offset += Offset * Plat->dt * CameraSpeed; + Entity->P.Offset += Offset * Plat->dt * (CameraSpeed); } } @@ -1503,9 +1568,43 @@ SimulateEntity(engine_resources *Resources, entity *Entity, r32 dt, v3i VisibleR } - DropEntityFromPreviouslyOccupiedChunks(World, Entity, GetTranArena()); + // nopush + // nopush + // nopush + // nopush + // nopush + // nopush + // nopush + // nopush + // nopush + // nopush + // nopush + // nopush + // nopush + // nopush + /* DropEntityFromPreviouslyOccupiedChunks(World, Entity, GetTranArena()); */ FinalizeEntityUpdate(Entity); - InsertEntityIntoChunks(World, Entity, GetTranArena()); + // + // nopush + // nopush + // nopush + // nopush + // nopush + // nopush + // nopush + // nopush + // nopush + // nopush + // nopush + // nopush + // nopush + // nopush + // nopush + // nopush + // nopush + // nopush + // nopush + /* InsertEntityIntoChunks(World, Entity, GetTranArena()); */ } link_internal void @@ -1561,3 +1660,71 @@ AStarPathfind(world *World, standing_spot_buffer *Spots, cp CurrentP, cp TargetP } +link_internal void +DropEntityFromPreviouslyOccupiedChunks(world *World, entity *Entity, memory_arena *TempMemory) +{ + // nocheckin + /* Assert(Entity->Behavior & EntityBehaviorFlags_EntityCollision); */ + + Assert(ThreadLocal_ThreadIndex == 0); + + rect3cp EntityArea = RectMinMax(Entity->LastResolvedPosInfo.P, Canonicalize(World->ChunkDim, Entity->LastResolvedPosInfo.P + Entity->LastResolvedPosInfo._CollisionVolumeRadius*2.f)); + world_chunk_ptr_buffer Chunks = GatherChunksOverlappingArea(World, EntityArea, TempMemory); + + if (Chunks.Count) + { + /* Info("Attempting to drop Entity(%p) from (%d) Chunks", Entity, Chunks.Count); */ + RangeIterator_t(umm, ChunkIndex, Chunks.Count) + { + world_chunk *Chunk = Chunks.Start[ChunkIndex]; + /* Info("Attempting to drop Entity(%p) from Chunk(%p)", Entity, Chunk); */ + + b32 Got = False; + IterateOver(&Chunk->Entities, TestEntity, TestEntityIndex) + { + if (TestEntity == Entity) + { + RemoveUnordered(&Chunk->Entities, TestEntityIndex); + Got = True; + break; + } + } + // NOTE(Jesse): This is a bit sketch. For it to work 100% correctly we + // cannot ever have entities that overlap uninitialized bits of the world. + // + // Currently it cannot be in, because an entity can be spawned outside + // the world just fine, then when the visible region moves to enclose the + // entity chunks will get initialized, but the entity will never have + // been added to the freshly minted chunks. + // + // We'd have to do some nonsense like check every entity for every chunk + // if it overlaps when we insert, which is not a thing. + /* Assert(Got); */ + } + } +} + +link_internal void +InsertEntityIntoChunks(world *World, entity *Entity, memory_arena *TempMemory) +{ + // nocheckin + /* Assert(Entity->Behavior & EntityBehaviorFlags_EntityCollision); */ + + auto MinP = Entity->LastResolvedPosInfo.P; + auto MaxP = Canonicalize(World->ChunkDim, Entity->LastResolvedPosInfo.P + Entity->LastResolvedPosInfo._CollisionVolumeRadius*2.f); + + rect3cp EntityArea = RectMinMax(MinP, MaxP); + world_chunk_ptr_buffer Chunks = GatherChunksOverlappingArea(World, EntityArea, TempMemory); + if (Chunks.Count) + { + /* Info("Attempting to insert Entity(%p) into (%d) Chunks", Entity, Chunks.Count); */ + RangeIterator_t(umm, ChunkIndex, Chunks.Count) + { + world_chunk *Chunk = Chunks.Start[ChunkIndex]; + /* Info("Attempting to insert Entity(%p) into Chunk(%p)", Entity, Chunk); */ + + Push(&Chunk->Entities, Entity); + } + } +} + diff --git a/src/engine/entity.h b/src/engine/entity.h index 6c3c633a5..9f8798e70 100644 --- a/src/engine/entity.h +++ b/src/engine/entity.h @@ -59,7 +59,7 @@ struct entity_position_info link_weak b32 EntityUserDataSerialize(u8_cursor_block_array *, u64 UserType, u64 UserData); link_weak b32 EntityUserDataDeserialize(u8_cursor *, u64 *UserType, u64 *UserData, memory_arena*); -link_weak void EntityUserDataEditorUi(renderer_2d *Ui, window_layout *Window, u64 *UserType, u64 *UserData, cs Name, EDITOR_UI_FUNCTION_PROTO_DEFAULTS); +link_weak void EntityUserDataEditorUi(renderer_2d *Ui, window_layout *Window, u64 *UserType, u64 *UserData, cs Name, u32 ParentHash, EDITOR_UI_FUNCTION_PROTO_DEFAULTS); struct entity poof(@version(2)) { @@ -74,7 +74,7 @@ struct entity poof(@version(2)) // // @dirty_entity_P_format_hack // - cp P; poof(@custom_ui(DoEditorUi_entity_P(Ui, Window, Element, CSz("cp P"), EDITOR_UI_FUNCTION_INSTANCE_NAMES))) + cp P; poof(@custom_ui(DoEditorUi_entity_P(Ui, Window, Element, CSz("cp P"), ThisHash, EDITOR_UI_FUNCTION_INSTANCE_NAMES))) v3 EulerAngles; poof(@ui_value_range(-PI32, PI32)) r32 Scale; @@ -103,8 +103,8 @@ struct entity poof(@version(2)) u64 UserType; poof( - @custom_ui( if (EntityUserDataEditorUi) {EntityUserDataEditorUi(Ui, Window, &Element->UserType, &Element->UserData, Name, EDITOR_UI_FUNCTION_INSTANCE_NAMES);} - else {DoEditorUi(Ui, Window, &Element->UserType, Name, EDITOR_UI_FUNCTION_INSTANCE_NAMES); } + @custom_ui( if (EntityUserDataEditorUi) {EntityUserDataEditorUi(Ui, Window, &Element->UserType, &Element->UserData, Name, ThisHash, EDITOR_UI_FUNCTION_INSTANCE_NAMES);} + else {DoEditorUi(Ui, Window, &Element->UserType, Name, ThisHash, EDITOR_UI_FUNCTION_INSTANCE_NAMES); } ) ) @@ -114,7 +114,7 @@ struct entity poof(@version(2)) @custom_deserialize(if (EntityUserDataDeserialize) {Result &= EntityUserDataDeserialize(Bytes, &Element->UserType, &Element->UserData, Memory);}) @custom_ui( if (EntityUserDataEditorUi) { /* User took control, skip this because it's intended */ } - else {DoEditorUi(Ui, Window, &Element->UserData, Name, EDITOR_UI_FUNCTION_INSTANCE_NAMES); } + else {DoEditorUi(Ui, Window, &Element->UserData, Name, ThisHash, EDITOR_UI_FUNCTION_INSTANCE_NAMES); } ) ) }; @@ -132,7 +132,7 @@ struct entity_1 // // @dirty_entity_P_format_hack // - cp P; poof(@custom_ui(DoEditorUi_entity_P(Ui, Window, Element, CSz("cp P"), EDITOR_UI_FUNCTION_INSTANCE_NAMES))) + cp P; poof(@custom_ui(DoEditorUi_entity_P(Ui, Window, Element, CSz("cp P"), ThisHash, EDITOR_UI_FUNCTION_INSTANCE_NAMES))) v3 EulerAngles; poof(@ui_value_range(-180.f, 180.f)) r32 Scale; @@ -179,7 +179,7 @@ struct entity_0 // // @dirty_entity_P_format_hack // - cp P; poof(@custom_ui(DoEditorUi_entity_P(Ui, Window, Element, CSz("cp P"), EDITOR_UI_FUNCTION_INSTANCE_NAMES))) + cp P; poof(@custom_ui(DoEditorUi_entity_P(Ui, Window, Element, CSz("cp P"), ThisHash, EDITOR_UI_FUNCTION_INSTANCE_NAMES))) v3 EulerAngles; poof(@ui_value_range(-180.f, 180.f)) r32 Scale; @@ -214,7 +214,7 @@ link_internal void FinalizeEntityUpdate(entity *Entity) { Assert(IsCanonical(GetWorld(), Entity->P)); - poof( func (entity_position_info Info) + poof( func (entity_position_info Info) @code_fragment { Info.map(member) { @@ -224,73 +224,6 @@ FinalizeEntityUpdate(entity *Entity) #include } -link_internal void -DropEntityFromPreviouslyOccupiedChunks(world *World, entity *Entity, memory_arena *TempMemory) -{ - // nocheckin - /* Assert(Entity->Behavior & EntityBehaviorFlags_EntityCollision); */ - - Assert(ThreadLocal_ThreadIndex == 0); - - rect3cp EntityArea = RectMinMax(Entity->LastResolvedPosInfo.P, Canonicalize(World->ChunkDim, Entity->LastResolvedPosInfo.P + Entity->LastResolvedPosInfo._CollisionVolumeRadius*2.f)); - world_chunk_ptr_buffer Chunks = GatherChunksOverlappingArea(World, EntityArea, TempMemory); - - if (Chunks.Count) - { - /* Info("Attempting to drop Entity(%p) from (%d) Chunks", Entity, Chunks.Count); */ - RangeIterator_t(umm, ChunkIndex, Chunks.Count) - { - world_chunk *Chunk = Chunks.Start[ChunkIndex]; - /* Info("Attempting to drop Entity(%p) from Chunk(%p)", Entity, Chunk); */ - - b32 Got = False; - IterateOver(&Chunk->Entities, TestEntity, TestEntityIndex) - { - if (*TestEntity == Entity) - { - RemoveUnordered(&Chunk->Entities, TestEntityIndex); - Got = True; - break; - } - } - // NOTE(Jesse): This is a bit sketch. For it to work 100% correctly we - // cannot ever have entities that overlap uninitialized bits of the world. - // - // Currently it cannot be in, because an entity can be spawned outside - // the world just fine, then when the visible region moves to enclose the - // entity chunks will get initialized, but the entity will never have - // been added to the freshly minted chunks. - // - // We'd have to do some nonsense like check every entity for every chunk - // if it overlaps when we insert, which is not a thing. - /* Assert(Got); */ - } - } -} - -link_internal void -InsertEntityIntoChunks(world *World, entity *Entity, memory_arena *TempMemory) -{ - // nocheckin - /* Assert(Entity->Behavior & EntityBehaviorFlags_EntityCollision); */ - - auto MinP = Entity->LastResolvedPosInfo.P; - auto MaxP = Canonicalize(World->ChunkDim, Entity->LastResolvedPosInfo.P + Entity->LastResolvedPosInfo._CollisionVolumeRadius*2.f); - - rect3cp EntityArea = RectMinMax(MinP, MaxP); - world_chunk_ptr_buffer Chunks = GatherChunksOverlappingArea(World, EntityArea, TempMemory); - if (Chunks.Count) - { - /* Info("Attempting to insert Entity(%p) into (%d) Chunks", Entity, Chunks.Count); */ - RangeIterator_t(umm, ChunkIndex, Chunks.Count) - { - world_chunk *Chunk = Chunks.Start[ChunkIndex]; - /* Info("Attempting to insert Entity(%p) into Chunk(%p)", Entity, Chunk); */ - - Push(&Chunk->Entities, &Entity); - } - } -} link_internal void UpdateCollisionVolumeRadius(world *World, entity *Entity, v3 NewRadius, memory_arena *TempMemory) @@ -326,3 +259,9 @@ GetEntityCenterP(world *World, entity *Entity) link_internal entity * GetEntity(entity **EntityTable, entity_id Id); + +link_internal void +DropEntityFromPreviouslyOccupiedChunks(world *World, entity *Entity, memory_arena *TempMemory); + +link_internal void +InsertEntityIntoChunks(world *World, entity *Entity, memory_arena *TempMemory); diff --git a/src/engine/game_effects.cpp b/src/engine/game_effects.cpp index cb4aa7bd3..f9b8f4cc7 100644 --- a/src/engine/game_effects.cpp +++ b/src/engine/game_effects.cpp @@ -295,11 +295,14 @@ DoDig( engine_resources *Resources, canonical_position PickCP, f32 Radius, f32 D v3 MinP = SimSpaceMinCenterP - V3(Radius, Radius, Depth); v3 MaxP = SimSpaceMinCenterP + V3(Radius, Radius, Depth); +#if 0 world_edit_shape Shape = { .Type = type_world_update_op_shape_params_rect, .world_update_op_shape_params_rect.Region = RectMinMax(MinP,MaxP), }; QueueWorldUpdateForRegion(Resources, WorldEdit_Mode_Remove, WorldEdit_Modifier_Default, &Shape, {}, {}, Resources->WorldUpdateMemory); +#endif + NotImplemented; } link_internal void @@ -310,11 +313,14 @@ DoIceBlock( engine_resources *Resources, canonical_position PickCP, f32 Radius, v3 MinP = SimSpaceMinCenterP - V3(Radius, Radius, 0.f); v3 MaxP = SimSpaceMinCenterP + V3(Radius, Radius, 3.f*Radius); +#if 0 world_edit_shape Shape = { .Type = type_world_update_op_shape_params_rect, .world_update_op_shape_params_rect.Region = RectMinMax(MinP,MaxP), }; QueueWorldUpdateForRegion(Resources, WorldEdit_Mode_Attach, WorldEdit_Modifier_Default, &Shape, HSV_ICE_BLUE, {}, Resources->WorldUpdateMemory); +#endif + NotImplemented; } link_internal void @@ -322,12 +328,13 @@ DoSplotion( engine_resources *Resources, cp PickCP, f32 Radius, random_series *E { UNPACK_ENGINE_RESOURCES(Resources); - world_edit_shape Shape = { - .Type = type_world_update_op_shape_params_sphere, - .world_update_op_shape_params_sphere.Radius = Radius, - .world_update_op_shape_params_sphere.Location = PickCP, - }; - QueueWorldUpdateForRegion(Resources, WorldEdit_Mode_Remove, WorldEdit_Modifier_Flood, &Shape, HSV_DARK_GREY, {}, Resources->WorldUpdateMemory); + /* world_edit_shape Shape = { */ + /* .Type = type_world_update_op_shape_params_sphere, */ + /* .world_update_op_shape_params_sphere.Radius = Radius, */ + /* .world_update_op_shape_params_sphere.Location = PickCP, */ + /* }; */ + NotImplemented; + /* QueueWorldUpdateForRegion(Resources, WorldEdit_Mode_Remove, WorldEdit_Modifier_Flood, &Shape, HSV_DARK_GREY, {}, Resources->WorldUpdateMemory); */ /* QueueWorldUpdateForRegion(Resources, WorldEdit_Mode_Remove, WorldUpdateModeModifier_None, &Shape, DARK_GREY, Resources->WorldUpdateMemory); */ /* QueueWorldUpdateForRegion(Resources, WorldEdit_Mode_Attach, WorldUpdateModeModifier_None, &Shape, DARK_GREY, Resources->WorldUpdateMemory); */ /* QueueWorldUpdateForRegion(Resources, WorldEdit_Mode_Attach, WorldUpdatenModeModifier_Flood, &Shape, DARK_GREY, Resources->WorldUpdateMemory); */ diff --git a/src/engine/gpu_mapped_buffer.cpp b/src/engine/gpu_mapped_buffer.cpp deleted file mode 100644 index 29597c9a5..000000000 --- a/src/engine/gpu_mapped_buffer.cpp +++ /dev/null @@ -1,247 +0,0 @@ - -// NOTE(Jesse): This hooks up the vertex attribs because in some cases -// (immediate geo buffer) we flush and draw immediately afterwards. -// -// Should probably move to using VAOs so we don't have to do this. -// -link_inline b32 -FlushBuffersToCard(gpu_mapped_element_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; - - 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. - 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_internal void -AllocateGpuElementBuffer(gpu_element_buffer_handles *Handles, data_type Type, u32 ElementCount) -{ - Assert(ElementCount); - Assert(Handles->Mapped == False); - Assert(Handles->ElementType == DataType_Undefinded); - - u32 matlSize = sizeof(matl)*ElementCount; - - Assert(Handles->VertexHandle == 0); - Assert(Handles->NormalHandle == 0); - Assert(Handles->MatHandle == 0); - - Handles->ElementType = Type; - Handles->ElementCount = ElementCount; - - switch (Type) - { - InvalidCase(DataType_Undefinded); - - case DataType_v3: - { - u32 v3Size = sizeof(v3)*ElementCount; - GL.GenBuffers(3, &Handles->VertexHandle); - 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, data_type Type, u32 ElementCount) -{ - AllocateGpuElementBuffer(&GpuMap->Handles, Type, ElementCount); - GpuMap->Buffer.End = ElementCount; -} - -link_internal void -DeallocateGpuElementBuffer(gpu_element_buffer_handles *Handles) -{ - GL.DeleteBuffers(3, &Handles->VertexHandle); - Clear(Handles); -} - -link_internal void -DeallocateGpuElementBuffer(gpu_mapped_element_buffer *Buf) -{ - DeallocateGpuElementBuffer(&Buf->Handles); - Clear(&Buf->Buffer); -} - -link_internal gpu_mapped_untextured_3d_geometry_buffer -MapGpuBuffer_untextured_3d_geometry_buffer(gpu_element_buffer_handles *Handles) -{ - TIMED_FUNCTION(); - AssertNoGlErrors; - - Assert(Handles->Mapped == False); - Handles->Mapped = True; - - untextured_3d_geometry_buffer Buffer = {}; - Buffer.End = Handles->ElementCount; - Buffer.Type = Handles->ElementType; - - u32 MaterialBufferSize = sizeof(matl)*Handles->ElementCount; - - switch (Handles->ElementType) - { - InvalidCase(DataType_Undefinded); - - case DataType_v3: - { - u32 BufferSize = sizeof(v3)*Handles->ElementCount; - - 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); - - return {*Handles, Buffer}; -} - -link_internal void -MapGpuBuffer_untextured_3d_geometry_buffer(gpu_mapped_element_buffer *GpuMap) -{ - TIMED_FUNCTION(); - - Assert(GpuMap->Buffer.Parent == False); - if (GpuMap->Buffer.BufferNeedsToGrow) - { - GpuMap->Buffer.End += GpuMap->Buffer.BufferNeedsToGrow; - DeallocateGpuElementBuffer(GpuMap); - AllocateGpuElementBuffer(GpuMap, GpuMap->Handles.ElementType, GpuMap->Buffer.End); - GpuMap->Buffer.BufferNeedsToGrow = 0; - } - - GpuMap->Buffer = MapGpuBuffer_untextured_3d_geometry_buffer(&GpuMap->Handles).Buffer; -} diff --git a/src/engine/graphics.h b/src/engine/graphics.h index 846dc1345..39c997800 100644 --- a/src/engine/graphics.h +++ b/src/engine/graphics.h @@ -1,3 +1,139 @@ +struct easing_function +poof(@do_editor_ui) +{ + cs Name; + v2_static_cursor_16 Points; +}; + +struct terrain_shaping_render_context +poof( @render_pass + @do_editor_ui + @vert_source_file("external/bonsai_stdlib/shaders/Passthrough.vertexshader") + @frag_source_file("shaders/terrain/shaping/default.fragmentshader") ) +{ + shader Program; + shader_uniform Uniforms[5]; + texture DestTex; + framebuffer DestFBO; + + v3 ChunkDim; poof(@uniform) + v3 WorldspaceChunkBasis; poof(@uniform) + v3 ChunkResolution; poof(@uniform) + + easing_function ReshapeFunc; + poof( + @uniform("SampleRemapCurvePoints", Element->ReshapeFunc.Points.Start, &Element->ReshapeFunc.Points.At) + @uniform("SampleRemapCurvePointCount", &Element->ReshapeFunc.Points.At, 0) + ) + +}; + +struct terrain_derivs_render_context +poof( @render_pass + @do_editor_ui + @vert_source_file("external/bonsai_stdlib/shaders/Passthrough.vertexshader") + @frag_source_file("shaders/terrain/derivs.fragmentshader") ) +{ + shader Program; + shader_uniform Uniforms[1]; + texture DestTex; + framebuffer DestFBO; + + v3 Ignored; poof(@uniform) +}; + +struct terrain_decoration_render_context +poof( @render_pass + @do_editor_ui + @vert_source_file("external/bonsai_stdlib/shaders/Passthrough.vertexshader") + @frag_source_file("shaders/terrain/decoration/default.fragmentshader") ) +{ + shader Program; + shader_uniform Uniforms[4]; + texture *DestTex; + framebuffer *DestFBO; + + texture *DerivsTex; poof(@uniform) + v3 ChunkDim; poof(@uniform) + v3 WorldspaceChunkBasis; poof(@uniform) + v3 ChunkResolution; poof(@uniform) +}; + + + +struct world_edit_render_context +poof( @render_pass + @do_editor_ui + @vert_source_file("external/bonsai_stdlib/shaders/Passthrough.vertexshader") + @frag_source_file("shaders/terrain/world_edit.fragmentshader") ) +{ + shader Program; + shader_uniform Uniforms[4]; + framebuffer PingPongFBOs[3]; + texture PingPongTextures[3]; + + v3 *ChunkDim; poof(@uniform) + v3 *WorldspaceChunkBasis; poof(@uniform) + v3 *ChunkResolution; poof(@uniform) + + s32 Type; poof(@uniform) +}; + +struct terrain_finalize_render_context +poof( @render_pass + @do_editor_ui + @vert_source_file("external/bonsai_stdlib/shaders/Passthrough.vertexshader") + @frag_source_file("shaders/terrain/TerrainFinalize.fragmentshader") ) +{ + shader Program; + shader_uniform Uniforms[1]; + texture DestTex; + framebuffer FBO; + + u32 Ignored; poof(@uniform) + /* texture *InputTex; poof(@uniform) */ +}; + + +struct easing_function_visualizer_render_pass +poof( + @render_pass + @async + @do_editor_ui + @vert_source_file(STDLIB_SHADER_PATH "FullPassthrough.vertexshader") + @frag_source_file(BONSAI_SHADER_PATH "curve_remap_visualizer.fragmentshader") + ) +{ + shader Program; + shader_uniform Uniforms[2]; + + easing_function *Func; + poof( + @uniform("Points", Element->Func->Points.Start, &Element->Func->Points.At) + @uniform("Count", &Element->Func->Points.At, 0) + ) +}; + + + +poof( + for_datatypes(struct) @code_fragment + func (struct_t) + { + struct_t.has_tag(render_pass)? + { + struct_t.has_tag(async)? + { + shader_magic(struct_t, {@async @render}) + } + { + shader_magic(struct_t, {}) + } + } + } +) +#include + struct composite_render_group { shader Shader; @@ -14,6 +150,7 @@ struct gaussian_render_group struct transparency_render_group { gpu_mapped_element_buffer GpuBuffer; + framebuffer FBO; shader Shader; texture AccumTex; @@ -24,18 +161,36 @@ struct transparency_render_group struct shadow_render_group; -struct graphics +poof(gen_constructor(gpu_readback_buffer)) +#include + +poof(block_array(gpu_readback_buffer, {32})) +#include + + +struct dummy_work_queue_entry_build_chunk_mesh { - b32 Initialized; + gpu_readback_buffer PBOBuf; + v3i NoiseDim; + octree_node *DestNode; +}; - volatile b32 RenderGate; +poof(block_array(dummy_work_queue_entry_build_chunk_mesh, {32})) +#include + +struct graphics +poof(@do_editor_ui) +{ + bonsai_futex Initialized; + bonsai_futex RenderGate; render_settings Settings; + render_settings PrevSettings; + + v3 OffsetOfWorldCenterToGrid; v3 SunBasis; - r32 FogPower; - v3 FogColor; v3 SkyColor; // Default cameras, game code can do it's own thing if it wants to. @@ -47,8 +202,8 @@ struct graphics r32 Exposure; - world_chunk_ptr_paged_list MainDrawList; - world_chunk_ptr_paged_list ShadowMapDrawList; + octree_node_ptr_paged_list MainDrawList; + octree_node_ptr_paged_list ShadowMapDrawList; // NOTE(Jesse): This is a stencil region for cutting out the selection region // such that we can reneder an appropriate temporary mesh in the case that @@ -57,9 +212,9 @@ struct graphics v3 MaxClipP_worldspace; // TODO(Jesse): None of these need to be pointers.. - g_buffer_render_group *gBuffer; - ao_render_group *AoGroup; - shadow_render_group *SG; + g_buffer_render_group *gBuffer; + ao_render_group *AoGroup; + shadow_render_group *SG; // NOTE(Jesse): This is the CPU-side color palette. It is the source of truth. @@ -75,11 +230,32 @@ struct graphics transparency_render_group Transparency; lighting_render_group Lighting; + bloom_render_group Bloom; gaussian_render_group Gaussian; composite_render_group CompositeGroup; - gpu_mapped_element_buffer GpuBuffers[2]; - u32 GpuBufferWriteIndex; + terrain_shaping_render_context TerrainShapingRC; + terrain_decoration_render_context TerrainDecorationRC; + terrain_derivs_render_context TerrainDerivsRC; + terrain_finalize_render_context TerrainFinalizeRC; + + world_edit_render_context WorldEditRC; + + // NOTE(Jesse): The array NoiseReadbackJobs stores the PBOs, but there's a 3 + // step process going on. First, the job is dispatched (copy values into PBO) + // then the job is complete (values copied, not used by app yet), then the + // NoiseFinalize is done, and the job is completed. NoiseFinalizeJobsPending + // tracks this third stage. + // + volatile u32 NoiseFinalizeJobsPending; + volatile u32 TotalChunkJobsActive; + dummy_work_queue_entry_build_chunk_mesh_block_array NoiseReadbackJobs = DummyWorkQueueEntryBuildChunkMeshBlockArray(&Global_PermMemory); + + triple_buffered_gpu_mapped_element_buffer ImmediateGeometry; + /* gpu_mapped_element_buffer GpuBuffers[2]; */ + /* u32 GpuBufferWriteIndex; */ + + gpu_timer_block_array GpuTimers = GpuTimerBlockArray(&Global_PermMemory); memory_arena *Memory; }; diff --git a/src/engine/level.h b/src/engine/level.h index 1298dced4..a86b3da0d 100644 --- a/src/engine/level.h +++ b/src/engine/level.h @@ -1,82 +1,23 @@ #define LEVEL_FILE_FORMAT_VERSION_NUMBER (1) -struct level_header poof(@version(4)) +struct level_header { - u32 ChunkCount; + u32 LayerCount; + u32 EditCount; u32 EntityCount; - // World Params - u32 WorldFlags; // world_flag - v3i WorldCenter; - v3i VisibleRegion; - - camera Camera; - - render_settings RenderSettings; -}; - -// NOTE(Jesse): This version and previous versions had chunks with magicavoxel encoded colors. -struct level_header_3 -{ - u32 ChunkCount; - u32 EntityCount; + // Editor Params + // + u32 SelectedLayerIndex; // World Params - u32 WorldFlags; // world_flag - v3i WorldCenter; - v3i VisibleRegion; + // + v3i WorldCenter; // in world chunks ..? + visible_region_size VisibleRegionSize; camera Camera; - render_settings RenderSettings; -}; - -struct level_header_2 -{ - bonsai_type_info_hashtable TypeInfoHashtable; poof(@no_serialize) - - u32 ChunkCount; - u32 EntityCount; - // World Params - u32 WorldFlags; // world_flag - v3i WorldCenter; - v3i VisibleRegion; - - camera Camera; - cp CameraTarget; -}; - - -struct level_header_1 -{ - /* u64 Version; */ - bonsai_type_info_hashtable TypeInfoHashtable; poof(@no_serialize) - - u32 ChunkCount; - u32 EntityCount; - - // World Params - u32 WorldFlags; // world_flag - v3i WorldCenter; - v3i VisibleRegion; - - camera Camera; - cp CameraTarget; -}; - - -struct level_header_0 -{ - /* u64 Version; */ - u32 ChunkCount; - u32 EntityCount; - - // World Params - u32 WorldFlags; // world_flag - v3i WorldCenter; - v3i VisibleRegion; - - camera Camera; - cp CameraTarget; + char TerrainShapingShader[NameBuf_Len]; + char TerrainDecorationShader[NameBuf_Len]; }; diff --git a/src/engine/light.h b/src/engine/light.h index d9b7dca89..cf227e250 100644 --- a/src/engine/light.h +++ b/src/engine/light.h @@ -5,6 +5,7 @@ struct light }; struct game_lights +poof(@do_editor_ui) { texture ColorTex; texture PositionTex; @@ -18,16 +19,60 @@ struct game_lights }; - struct lighting_render_group +poof( + @do_editor_ui + @render_pass + @vert_source_file(BONSAI_SHADER_PATH "Lighting.vertexshader") + @frag_source_file(BONSAI_SHADER_PATH "Lighting.fragmentshader") + ) { - game_lights Lights; + shader Program; + shader_uniform Uniforms[26]; framebuffer FBO; - texture LuminanceTex; - shader Shader; - bloom_render_group Bloom; + texture *gColor; poof (@uniform) + texture *gNormal; poof (@uniform) + texture *gDepth; poof (@uniform) + texture *shadowMap; poof (@uniform) + texture *Ssao; poof (@uniform) + + texture *TransparencyAccumTex; poof (@uniform) + texture *TransparencyCountTex; poof (@uniform) + + b32 *BravoilMyersOIT; poof (@uniform) + b32 *BravoilMcGuireOIT; poof (@uniform) + + m4 *InverseViewMatrix; poof (@uniform) + m4 *InverseProjectionMatrix; poof (@uniform) + m4 *ShadowMVP; poof (@uniform) + + // from struct game_lights { + texture *LightColors; poof (@uniform) + texture *LightPositions; poof (@uniform) + f32 *LightIndexToUV; poof (@uniform) + s32 *LightCount; poof (@uniform) + // } + + camera *Camera; poof (@uniform) + + v3 *SunPosition; poof (@uniform) + v3 *SunColor; poof (@uniform) + v3 *FogColor; poof (@uniform) + f32 *FogPower; poof (@uniform) + + b32 *UseSsao; poof (@uniform) + + b32 *UseShadowMapping; poof (@uniform) + b32 *UseLightingBloom; poof (@uniform) + + v2 *ApplicationResolution; poof (@uniform) + v2 *ShadowMapResolution; poof (@uniform) + + + texture LuminanceTex; + game_lights Lights; }; link_internal void @@ -56,10 +101,10 @@ DoLight(game_lights *Lights, v3 RenderPosition, v3 Color) /* #define SHADOW_MAP_RESOLUTION_X (2*1024) */ /* #define SHADOW_MAP_RESOLUTION_Y (2*1024) */ -#define SHADOW_MAP_X 512 -#define SHADOW_MAP_Y 512 -#define SHADOW_MAP_Z_MIN -512 -#define SHADOW_MAP_Z_MAX 512 +#define SHADOW_MAP_X 1024*4 +#define SHADOW_MAP_Y 1024*4 +#define SHADOW_MAP_Z_MIN -1024*4 +#define SHADOW_MAP_Z_MAX 1024*4 /* #define SHADOW_MAP_X 512 */ /* #define SHADOW_MAP_Y 512 */ diff --git a/src/engine/loaders/vox.cpp b/src/engine/loaders/vox.cpp index 7c0d111f2..3f52c3395 100644 --- a/src/engine/loaders/vox.cpp +++ b/src/engine/loaders/vox.cpp @@ -192,13 +192,13 @@ global_variable random_series TMP = {54235432543}; link_internal vox_data_block_array LoadVoxData(v3_cursor *ColorPalette, memory_arena *TempMemory, memory_arena *PermMemory, heap_allocator *Heap, const char *filepath, vox_loader_clip_behavior ClipBehavior, v3i HalfApronMin = {}, v3i HalfApronMax = {}, v3i ModDim = {}) { - vox_data_block_array Result = { {}, {}, TempMemory }; + vox_data_block_array Result = VoxDataBlockArray(TempMemory); v3i ReportedDim = {}; b32 HadPaletteData = False; - v3 TempHSVPalette[256] = {}; + v3 TempRGBPalette[256] = {}; @@ -248,8 +248,8 @@ LoadVoxData(v3_cursor *ColorPalette, memory_arena *TempMemory, memory_arena *Per u8 B = ReadChar(ModelFile, &bytesRemaining); u8 A = ReadChar(ModelFile, &bytesRemaining); - v3 ThisColor = RGBtoHSV(V3(R,G,B)/255.f); - TempHSVPalette[PaletteIndex] = ThisColor; + /* v3 ThisColor = RGBtoHSV(V3(R,G,B)/255.f); */ + TempRGBPalette[PaletteIndex] = V3(R,G,B)/255.f; /* v3 ThisColor = V3(R,G,B); */ #if 1 #else @@ -387,7 +387,7 @@ LoadVoxData(v3_cursor *ColorPalette, memory_arena *TempMemory, memory_arena *Per minZ = Min(TestP.z, minZ); LocalVoxelCache[VoxelCacheIndex] = boundary_voxel(TestP.x, TestP.y, TestP.z, Color); - SetFlag(&LocalVoxelCache[VoxelCacheIndex], Voxel_Filled); + /* SetFlag(&LocalVoxelCache[VoxelCacheIndex], Voxel_Filled); */ } else { @@ -436,34 +436,19 @@ LoadVoxData(v3_cursor *ColorPalette, memory_arena *TempMemory, memory_arena *Per { boundary_voxel *Voxel = &LocalVoxelCache[VoxelCacheIndex]; Voxel->Offset = Voxel->Offset - Min + HalfApronMin; - s32 Index = GetIndex(Voxel->Offset, ModelDim); - - if (Voxel->V.Flags & Voxel_Filled) - /* if (Voxel->V.Flags & Voxel_Filled && VoxelCacheIndex == 16) */ - { - /* if (RandomUnilateral(&TMP) > 0.25f) { Voxel->V.Transparency = 255; } */ - /* Current.ChunkData->Voxels[Index].Transparency = 128; */ - /* Voxel->V.Transparency = 255; */ - } - else - { - /* Voxel->V.Transparency = 0; */ - Assert(Voxel->V.Transparency == 0); - Voxel->V.Transparency = 128; - /* Voxel->V.Emission = 128; */ - } - /* Voxel->V.Transparency = 0; */ - Current.ChunkData->Voxels[Index] = Voxel->V; + s32 Index = GetIndex(Voxel->Offset, ModelDim); + NotImplemented; + /* Current.ChunkData->Voxels[Index] = Voxel->V; */ /* Result.ChunkData->VoxelLighting[Index] = VoxelLighting(0xff); */ } FullBarrier; - Current.ChunkData->Flags = Chunk_VoxelsInitialized; + /* Current.ChunkData->Flags = Chunk_VoxelsInitialized; */ - /* MarkBoundaryVoxels_NoExteriorFaces( Current.ChunkData->Voxels, Current.ChunkData->Dim, {}, Current.ChunkData->Dim); */ - MarkBoundaryVoxels_MakeExteriorFaces( Current.ChunkData->Voxels, Current.ChunkData->Dim, {}, Current.ChunkData->Dim); + NotImplemented; + /* MarkBoundaryVoxels_MakeExteriorFaces( Current.ChunkData->Occupancy, Current.ChunkData->Voxels, Current.ChunkData->Dim, {}, Current.ChunkData->Dim); */ Push(&Result, &Current); } break; @@ -523,11 +508,12 @@ LoadVoxData(v3_cursor *ColorPalette, memory_arena *TempMemory, memory_arena *Per DimIterator(x, y, z, Chunk->Dim) { s32 Index = GetIndex(x, y, z, Chunk->Dim); - u16 PaletteIndex = Chunk->Voxels[Index].Color; - if (HadPaletteData) - { Chunk->Voxels[Index].Color = PackHSVColor(TempHSVPalette[PaletteIndex]); } - else - { Chunk->Voxels[Index].Color = PackHSVColor(MagicaVoxelDefaultPaletteToHSV(PaletteIndex)); } + NotImplemented; + /* u16 PaletteIndex = Chunk->Voxels[Index].RGBColor; */ + /* if (HadPaletteData) */ + /* { Chunk->Voxels[Index].RGBColor = PackV3_16b(TempRGBPalette[PaletteIndex]); } */ + /* else */ + /* { Chunk->Voxels[Index].RGBColor = PackV3_16b(MagicaVoxelDefaultPaletteToRGB(PaletteIndex)); } */ } } } diff --git a/src/engine/loaders/vox.h b/src/engine/loaders/vox.h new file mode 100644 index 000000000..e2a107472 --- /dev/null +++ b/src/engine/loaders/vox.h @@ -0,0 +1,34 @@ +// Used when loading .vox files +// + +struct vox_voxel +{ + voxel V; + v3i Offset; + + vox_voxel(s32 x, s32 y, s32 z, u8 w) + { + this->Offset.x = x; + this->Offset.y = y; + this->Offset.z = z; + + this->V.Color = w; + + /* this->V.Flags = Voxel_Empty; */ + this->V.Transparency = 0; + } + + vox_voxel(voxel *V_in, voxel_position Offset_in) + { + this->V = *V_in; + this->Offset = Offset_in; + } +}; + +struct vox_loader_buffer +{ + chunk_data *ChunkData[4*4*4]; +}; + +poof(block_array(vox_loader_buffer, {8})) +#include diff --git a/src/engine/mesh.cpp b/src/engine/mesh.cpp index daf885f17..c3a904a6d 100644 --- a/src/engine/mesh.cpp +++ b/src/engine/mesh.cpp @@ -54,17 +54,9 @@ link_internal void DeallocateMesh(untextured_3d_geometry_buffer* Mesh, mesh_freelist *MeshFreelist) { Assert(Mesh); + Assert(Mesh->End <= MeshFreelist->MeshSize); #if BONSAI_INTERNAL - if (MeshFreelist->MeshSize == 0) - { - MeshFreelist->MeshSize = Mesh->End; - } - else - { - Assert(MeshFreelist->MeshSize == Mesh->End); - } - AcquireFutex(&MeshFreelist->DebugFutex); #endif @@ -80,12 +72,6 @@ DeallocateMesh(untextured_3d_geometry_buffer* Mesh, mesh_freelist *MeshFreelist) link_internal void DeallocateMesh(void *VoidMesh, tiered_mesh_freelist* MeshFreelist) { - // NOTE(Jesse): The End offsets must be the same for the cast to - // 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)); */ - untextured_3d_geometry_buffer *Mesh = Cast(untextured_3d_geometry_buffer*, VoidMesh); mesh_freelist *Freelist = TryGetTierForSize(MeshFreelist, Mesh->End); if (Freelist) @@ -93,6 +79,12 @@ DeallocateMesh(void *VoidMesh, tiered_mesh_freelist* MeshFreelist) u32 Tier = 1+ (Mesh->End/WORLD_CHUNK_MESH_MIN_SIZE); u32 Size = Tier*WORLD_CHUNK_MESH_MIN_SIZE; + if (Freelist->MeshSize == 0) + { + Freelist->MeshSize = Size; + } + + Assert(Freelist->MeshSize >= Mesh->End); DeallocateMesh(Mesh, Freelist); } else @@ -208,7 +200,7 @@ poof( link_internal b32 HasGpuMesh((container_t.name) *Buf, world_chunk_mesh_bitfield MeshBit) { - b32 Result = (Buf->GpuBufferHandles[ToIndex(MeshBit)].VertexHandle != 0); + b32 Result = (Buf->GpuBufferHandles[ToIndex(MeshBit)].Handles[mesh_VertexHandle] != 0); return Result; } @@ -219,7 +211,7 @@ poof( b32 Result = False; RangeIterator(MeshIndex, MeshIndex_Count) { - Result |= (Buf->GpuBufferHandles[MeshIndex].VertexHandle != 0); + Result |= (Buf->GpuBufferHandles[MeshIndex].Handles[mesh_VertexHandle] != 0); } return Result; } @@ -238,7 +230,7 @@ poof( link_internal b32 HasMesh((container_t.name) *Buf, world_chunk_mesh_bitfield MeshBit) { - b32 Result = (Buf->E[ToIndex(MeshBit)] != 0); + b32 Result = (Buf->GpuBufferHandles[ToIndex(MeshBit)].Handles[0] != 0); return Result; } } @@ -251,3 +243,10 @@ poof(threadsafe_mesh_container(lod_element_buffer, untextured_3d_geometry_buffer /* #include */ +link_internal b32 +HasGpuMesh(gpu_mapped_element_buffer *Buf) +{ + b32 Result = (Buf->Handles.Handles[0] != 0); + return Result; +} + diff --git a/src/engine/mesh.h b/src/engine/mesh.h index 372017ba8..e1f2ce23a 100644 --- a/src/engine/mesh.h +++ b/src/engine/mesh.h @@ -13,9 +13,9 @@ struct mesh_freelist { #if BONSAI_INTERNAL bonsai_futex DebugFutex; - u32 MeshSize; #endif + u32 MeshSize; volatile freelist_entry *FirstFreeMesh; }; @@ -40,7 +40,7 @@ TryGetTierForSize(tiered_mesh_freelist *TieredFreelist, u32 Size) // NOTE(Jesse): So we include the 1*minsize in the 0th bucket, 2*minsize in 1th bucket, etc if (Size % WORLD_CHUNK_MESH_MIN_SIZE == 0) { Size = Size-1; } - u32 Index = Size/WORLD_CHUNK_MESH_MIN_SIZE; + u32 Index = (Size)/WORLD_CHUNK_MESH_MIN_SIZE; if (Index < TIERED_MESH_FREELIST_MAX_ELEMENTS) { Result = TieredFreelist->Start + Index; @@ -52,13 +52,6 @@ TryGetTierForSize(tiered_mesh_freelist *TieredFreelist, u32 Size) return Result; } -link_internal void -MarkBufferForGrowth(untextured_2d_geometry_buffer *Dest, umm Grow) -{ - NotImplemented; -} - - poof( func grow_buffer(buffer_t) { @@ -174,9 +167,9 @@ poof( auto Src1 = Rotate(Src[VertIndex + 1], Rot); auto Src2 = Rotate(Src[VertIndex + 2], Rot); - f32_reg Vert0; - f32_reg Vert1; - f32_reg Vert2; + f32_4x Vert0; + f32_4x Vert1; + f32_4x 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); @@ -186,9 +179,9 @@ poof( Vert1.Sse = _mm_add_ps( _mm_mul_ps(Vert1.Sse, mmScale), mmOffset); Vert2.Sse = _mm_add_ps( _mm_mul_ps(Vert2.Sse, mmScale), mmOffset); - 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]) }}; + dest_t.name Result0 = {{ result_primitive_t.name(Vert0.E[0]), result_primitive_t.name(Vert0.E[1]), result_primitive_t.name(Vert0.E[2]) }}; + dest_t.name Result1 = {{ result_primitive_t.name(Vert1.E[0]), result_primitive_t.name(Vert1.E[1]), result_primitive_t.name(Vert1.E[2]) }}; + dest_t.name Result2 = {{ result_primitive_t.name(Vert2.E[0]), result_primitive_t.name(Vert2.E[1]), result_primitive_t.name(Vert2.E[2]) }}; Dest[0] = Result0; Dest[1] = Result1; @@ -217,9 +210,9 @@ poof( auto Src1 = Src[VertIndex + 1]; auto Src2 = Src[VertIndex + 2]; - f32_reg Vert0; - f32_reg Vert1; - f32_reg Vert2; + f32_4x Vert0; + f32_4x Vert1; + f32_4x 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); @@ -229,9 +222,9 @@ poof( Vert1.Sse = _mm_add_ps( _mm_mul_ps(Vert1.Sse, mmScale), mmOffset); Vert2.Sse = _mm_add_ps( _mm_mul_ps(Vert2.Sse, mmScale), mmOffset); - 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]) }}; + dest_t.name Result0 = {{ result_primitive_t.name(Vert0.E[0]), result_primitive_t.name(Vert0.E[1]), result_primitive_t.name(Vert0.E[2]) }}; + dest_t.name Result1 = {{ result_primitive_t.name(Vert1.E[0]), result_primitive_t.name(Vert1.E[1]), result_primitive_t.name(Vert1.E[2]) }}; + dest_t.name Result2 = {{ result_primitive_t.name(Vert2.E[0]), result_primitive_t.name(Vert2.E[1]), result_primitive_t.name(Vert2.E[2]) }}; Dest[0] = Result0; Dest[1] = Result1; @@ -739,9 +732,9 @@ DrawVoxel( untextured_3d_geometry_buffer *Mesh, v3 RenderP_VoxelCenter, u16 Pack } inline void -DrawVoxel( untextured_3d_geometry_buffer *Mesh, v3 RenderP_VoxelCenter, v3 HSVColor, v3 Diameter, v2 TransEmiss = V2(0.f, 0.f)) +DrawVoxel( untextured_3d_geometry_buffer *Mesh, v3 RenderP_VoxelCenter, v3 RGBColor, v3 Diameter, v2 TransEmiss = V2(0.f, 0.f)) { - DrawVoxel(Mesh, RenderP_VoxelCenter, PackHSVColor(HSVColor), Diameter, TransEmiss); + DrawVoxel(Mesh, RenderP_VoxelCenter, RGBtoPackedHSV(RGBColor), Diameter, TransEmiss); } inline void diff --git a/src/engine/model.cpp b/src/engine/model.cpp new file mode 100644 index 000000000..d6ac94c99 --- /dev/null +++ b/src/engine/model.cpp @@ -0,0 +1,2 @@ +poof(buffer_c(model, u64)) +#include diff --git a/src/engine/model.h b/src/engine/model.h index df939eaf9..5c5e0fa01 100644 --- a/src/engine/model.h +++ b/src/engine/model.h @@ -67,8 +67,11 @@ struct model { vox_data Vox; + // TODO(Jesse): Delete lod_element_buffer Meshes; poof(@no_serialize) + gpu_mapped_element_buffer Mesh; poof(@no_serialize) + /* untextured_3d_geometry_buffer Mesh; */ untextured_3d_geometry_buffer TransparentMesh; animation Animation; @@ -95,6 +98,7 @@ poof(maybe(model_buffer)) #include +#if 0 link_internal voxel * TryGetVoxel(chunk_data *ChunkData, v3i P) { @@ -103,6 +107,7 @@ TryGetVoxel(chunk_data *ChunkData, v3i P) if (Index > -1) { Result = ChunkData->Voxels + Index; } return Result; } +#endif struct maybe_model { diff --git a/src/engine/particle.h b/src/engine/particle.h index c91b1acd4..178a0d0b2 100644 --- a/src/engine/particle.h +++ b/src/engine/particle.h @@ -1,6 +1,7 @@ // TODO(Jesse): Remove this? #define PARTICLE_SYSTEM_EMIT_FOREVER (f32_MAX) struct particle +poof(@do_editor_ui) { // TODO(Jesse, id: 85, tags: robustness, memory_consumption): Compress to 16 bit float? v3 Velocity; @@ -22,7 +23,11 @@ enum particle_spawn_type #define PARTICLE_SYSTEM_COLOR_COUNT 6 #define PARTICLES_PER_SYSTEM (4096) -struct particle_system poof(@version(1)) +struct particle_system +poof( + @version(1) + @do_editor_ui + ) { random_series Entropy; diff --git a/src/engine/physics.h b/src/engine/physics.h index e0af78ef9..5b496d64d 100644 --- a/src/engine/physics.h +++ b/src/engine/physics.h @@ -1,4 +1,5 @@ struct physics +poof(@do_editor_ui) { v3 Velocity; v3 Force; diff --git a/src/engine/ray.h b/src/engine/ray.h index 728d22ea4..ddcabcae1 100644 --- a/src/engine/ray.h +++ b/src/engine/ray.h @@ -18,7 +18,6 @@ struct maybe_ray ray Ray; }; - struct aabb_intersect_result { face_index Face; @@ -104,6 +103,23 @@ Intersect(aabb AABB, ray *Ray) return Intersect(&AABB, Ray); } +link_internal b32 +Intersect(aabb *AABB, ray *Ray, r32 *t) +{ + b32 Result = False; + aabb_intersect_result IRes = Intersect(AABB, Ray); + + if (IRes.Face != FaceIndex_None) + { + Assert(IRes.t != f32_MAX); + *t = IRes.t; + Result = True; + } + return Result; +} + + + // https://www.scratchapixel.com/lessons/3d-basic-rendering/minimal-ray-tracer-rendering-simple-shapes/ray-plane-and-ray-disk-intersection.html link_internal b32 diff --git a/src/engine/render.cpp b/src/engine/render.cpp index 66b9f80b4..09defd9d1 100644 --- a/src/engine/render.cpp +++ b/src/engine/render.cpp @@ -2,12 +2,12 @@ void RenderAoTexture(v2i ApplicationResolution, ao_render_group *AoGroup) { - GL.BindFramebuffer(GL_FRAMEBUFFER, AoGroup->FBO.ID); + GetGL()->BindFramebuffer(GL_FRAMEBUFFER, AoGroup->FBO.ID); SetViewport(ApplicationResolution/2); - GL.UseProgram(AoGroup->Shader.ID); + GetGL()->UseProgram(AoGroup->Shader.ID); - GL.Uniform3fv(AoGroup->SsaoKernelUniform, SSAO_KERNEL_SIZE, (r32*)AoGroup->SsaoKernel); + GetGL()->Uniform3fv(AoGroup->SsaoKernelUniform, SSAO_KERNEL_SIZE, (r32*)AoGroup->SsaoKernel); BindShaderUniforms(&AoGroup->Shader); @@ -35,14 +35,14 @@ UpdateLightingTextures(game_lights *Lights) u32 Type = GL_TEXTURE_2D; - GL.BindTexture(Type, Lights->PositionTex.ID); - GL.TexImage2D( Type, 0, GL_RGB32F, + GetGL()->BindTexture(Type, Lights->PositionTex.ID); + GetGL()->TexImage2D( Type, 0, GL_RGB32F, Lights->PositionTex.Dim.x, Lights->PositionTex.Dim.y, 0, GL_RGB, GL_FLOAT, PosData); AssertNoGlErrors; - GL.BindTexture(Type, Lights->ColorTex.ID); - GL.TexImage2D( Type, 0, GL_RGB32F, + GetGL()->BindTexture(Type, Lights->ColorTex.ID); + GetGL()->TexImage2D( Type, 0, GL_RGB32F, Lights->ColorTex.Dim.x, Lights->ColorTex.Dim.y, 0, GL_RGB, GL_FLOAT, ColorData); AssertNoGlErrors; @@ -54,10 +54,10 @@ UpdateLightingTextures(game_lights *Lights) link_internal void Debug_DrawTextureToDebugQuad( shader *DebugShader ) { - GL.BindFramebuffer(GL_FRAMEBUFFER, 0); + GetGL()->BindFramebuffer(GL_FRAMEBUFFER, 0); SetViewport(V2(256)); - GL.UseProgram(DebugShader->ID); + GetGL()->UseProgram(DebugShader->ID); BindShaderUniforms(DebugShader); RenderQuad(); @@ -69,72 +69,64 @@ Debug_DrawTextureToDebugQuad( shader *DebugShader ) #endif inline m4 -GetShadowMapMVP(v3 SunP, v3 FrustumCenter) +GetShadowMapMVP(world *World, camera *Camera, v3 SunP) { - // Compute the MVP matrix from the light's point of view - /* v3 Translate = GetRenderP(Camera->Target, Camera); */ m4 depthProjectionMatrix = Orthographic(SHADOW_MAP_X, SHADOW_MAP_Y, SHADOW_MAP_Z_MIN, SHADOW_MAP_Z_MAX); - v3 Front = Normalize(SunP); - v3 Right = Cross(Front, V3(0,1,0)); - v3 Up = Cross(Right, Front); - - v3 Target = FrustumCenter; + v3 Target = {}; + v3 Up = V3(0.f, 1.f, 0.f); m4 depthViewMatrix = LookAt(SunP, Target, Up); return depthProjectionMatrix * depthViewMatrix; } link_internal void -RenderImmediateGeometryToShadowMap(gpu_mapped_element_buffer *GpuMap, graphics *Graphics) +RenderImmediateGeometryToShadowMap(world *World, graphics *Graphics, gpu_mapped_element_buffer *GpuMap) { TIMED_FUNCTION(); shadow_render_group *SG = Graphics->SG; - GL.BindFramebuffer(GL_FRAMEBUFFER, SG->FramebufferName); + GetGL()->BindFramebuffer(GL_FRAMEBUFFER, SG->FramebufferName); SetViewport(GetShadowMapResolution(&GetEngineResources()->Settings)); - - // @duplicate_shadow_map_MVP_calculation - v3 FrustCenter = GetFrustumCenter(Graphics->Camera); - SG->Shader.MVP = GetShadowMapMVP(Graphics->Settings.Lighting.SunP, FrustCenter); - - /* GL.UniformMatrix4fv(SG->MVP_ID, 1, GL_FALSE, &SG->MVP.E[0].E[0]); */ - UseShader(&SG->Shader); - /* BindUniformByName(&SG->DepthShader, "ModelMatrix", &IdentityMatrix); */ - Draw(GpuMap->Buffer.At); - GL.BindFramebuffer(GL_FRAMEBUFFER, 0); + GetGL()->BindFramebuffer(GL_FRAMEBUFFER, 0); return; } link_internal void -RenderImmediateGeometryToGBuffer(v2i ApplicationResolution, gpu_mapped_element_buffer *GpuMap, graphics *Graphics) +RenderImmediateGeometryToGBuffer(v2i ApplicationResolution, triple_buffered_gpu_mapped_element_buffer *ImmediateGeometry, graphics *Graphics) { TIMED_FUNCTION(); + + auto Handles = CurrentHandles(ImmediateGeometry); + Assert(Handles->Mapped == False); + auto GBufferRenderGroup = Graphics->gBuffer; - GL.BindFramebuffer(GL_FRAMEBUFFER, GBufferRenderGroup->FBO.ID); - GL.UseProgram(GBufferRenderGroup->gBufferShader.ID); + GetGL()->BindFramebuffer(GL_FRAMEBUFFER, GBufferRenderGroup->FBO.ID); + GetGL()->UseProgram(GBufferRenderGroup->gBufferShader.ID); SetViewport(ApplicationResolution); BindShaderUniforms(&GBufferRenderGroup->gBufferShader); // TODO(Jesse): Hoist this check out of here - GL.Disable(GL_CULL_FACE); - Draw(GpuMap->Buffer.At); - /* DrawGpuBufferImmediate(GpuMap->Handles); */ - GL.Enable(GL_CULL_FACE); + GetGL()->Disable(GL_CULL_FACE); + + /* Draw(GpuMap->Buffer.At); */ + + DrawGpuBufferImmediate(Handles, ImmediateGeometry->Buffer.At); + GetGL()->Enable(GL_CULL_FACE); CleanupTextureBindings(&GBufferRenderGroup->gBufferShader); @@ -144,15 +136,15 @@ RenderImmediateGeometryToGBuffer(v2i ApplicationResolution, gpu_mapped_element_b link_internal void CompositeGameTexturesAndDisplay( platform *Plat, graphics *Graphics ) { - GL.BindFramebuffer(GL_FRAMEBUFFER, 0); + GetGL()->BindFramebuffer(GL_FRAMEBUFFER, 0); SetViewport(Plat->ScreenDim); - GL.Enable(GL_BLEND); - GL.BlendFunc(GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA); + GetGL()->Enable(GL_BLEND); + GetGL()->BlendFunc(GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA); UseShader(&Graphics->CompositeGroup.Shader); - GL.Disable(GL_BLEND); + GetGL()->Disable(GL_BLEND); RenderQuad(); @@ -163,24 +155,24 @@ CompositeGameTexturesAndDisplay( platform *Plat, graphics *Graphics ) // Does lighting on gBuffer textures. Also composites transparent surfaces link_internal void -RenderLuminanceTexture(v2i ApplicationResolution, gpu_mapped_element_buffer *GpuMap, lighting_render_group *Lighting, graphics *Graphics) +RenderLuminanceTexture(v2i ApplicationResolution, lighting_render_group *Lighting, graphics *Graphics) { SetViewport(ApplicationResolution); UpdateLightingTextures(&Graphics->Lighting.Lights); // TODO(Jesse): Explain this. - Graphics->SG->Shader.MVP = NdcToScreenSpace * Graphics->SG->Shader.MVP; + Graphics->SG->Shader.ViewProjection = NdcToScreenSpace * Graphics->SG->Shader.ViewProjection; - /* GL.Enable(GL_BLEND); */ - /* GL.BlendFunc(GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA); */ + /* GetGL()->Enable(GL_BLEND); */ + /* GetGL()->BlendFunc(GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA); */ - GL.BindFramebuffer(GL_FRAMEBUFFER, Lighting->FBO.ID); + GetGL()->BindFramebuffer(GL_FRAMEBUFFER, Lighting->FBO.ID); -/* GL.Disable(GL_BLEND); */ +/* GetGL()->Disable(GL_BLEND); */ { - UseShader(&Lighting->Shader); + UseShader(&Lighting->Program); RenderQuad(); } @@ -212,11 +204,11 @@ GaussianBlurTexture(gaussian_render_group *Group, texture *TexIn, framebuffer *D if (last_iteration) { - GL.BindFramebuffer(GL_FRAMEBUFFER, DestFBO->ID); + GetGL()->BindFramebuffer(GL_FRAMEBUFFER, DestFBO->ID); } else { - GL.BindFramebuffer(GL_FRAMEBUFFER, Group->FBOs[horizontal].ID); + GetGL()->BindFramebuffer(GL_FRAMEBUFFER, Group->FBOs[horizontal].ID); } AssertNoGlErrors; @@ -232,7 +224,7 @@ GaussianBlurTexture(gaussian_render_group *Group, texture *TexIn, framebuffer *D Tex = &Group->Textures[!horizontal]; } - /* GL.BindTexture( GL_TEXTURE_2D, Tex->ID ); */ + /* GetGL()->BindTexture( GL_TEXTURE_2D, Tex->ID ); */ BindUniformByName(&Group->Shader, "SrcImage", Tex, 0); AssertNoGlErrors; @@ -242,22 +234,22 @@ GaussianBlurTexture(gaussian_render_group *Group, texture *TexIn, framebuffer *D if (first_iteration) first_iteration = false; } - GL.BindFramebuffer(GL_FRAMEBUFFER, 0); + GetGL()->BindFramebuffer(GL_FRAMEBUFFER, 0); } -link_internal gpu_mapped_element_buffer * -GetNextGpuMap(graphics *Graphics) -{ - gpu_mapped_element_buffer* GpuMap = Graphics->GpuBuffers + ((Graphics->GpuBufferWriteIndex+1)%2); - return GpuMap; -} +/* link_internal gpu_mapped_element_buffer * */ +/* GetNextGpuMap(graphics *Graphics) */ +/* { */ +/* gpu_mapped_element_buffer* GpuMap = Graphics->GpuBuffers + ((Graphics->GpuBufferWriteIndex+1)%2); */ +/* return GpuMap; */ +/* } */ -link_internal gpu_mapped_element_buffer * -GetCurrentGpuMap(graphics *Graphics) -{ - gpu_mapped_element_buffer* GpuMap = Graphics->GpuBuffers + Graphics->GpuBufferWriteIndex; - return GpuMap; -} +/* link_internal gpu_mapped_element_buffer * */ +/* GetCurrentGpuMap(graphics *Graphics) */ +/* { */ +/* gpu_mapped_element_buffer* GpuMap = Graphics->GpuBuffers + Graphics->GpuBufferWriteIndex; */ +/* return GpuMap; */ +/* } */ #if 0 void @@ -339,24 +331,24 @@ BuildExteriorBoundaryVoxels( world_chunk *chunk, chunk_dimension Dim, world_chun #endif inline void -ClearFramebuffers(graphics *Graphics, render_entity_to_texture_group *RTTGroup) +ClearFramebuffers(graphics *Graphics, render_to_texture_group *RTTGroup) { TIMED_FUNCTION(); - GL.ClearColor(Graphics->SkyColor.r, Graphics->SkyColor.g, Graphics->SkyColor.b, 1.f); - GL.BindFramebuffer(GL_FRAMEBUFFER, Graphics->gBuffer->FBO.ID); - GL.Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + GetGL()->ClearColor(Graphics->SkyColor.r, Graphics->SkyColor.g, Graphics->SkyColor.b, 1.f); + GetGL()->BindFramebuffer(GL_FRAMEBUFFER, Graphics->gBuffer->FBO.ID); + GetGL()->Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); SetDefaultFramebufferClearColors(); - /* GL.BindFramebuffer(GL_FRAMEBUFFER, RTTGroup->FBO.ID); */ - /* GL.Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); */ + /* GetGL()->BindFramebuffer(GL_FRAMEBUFFER, RTTGroup->FBO.ID); */ + /* GetGL()->Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); */ - GL.BindFramebuffer(GL_FRAMEBUFFER, Graphics->SG->FramebufferName); - GL.Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + GetGL()->BindFramebuffer(GL_FRAMEBUFFER, Graphics->SG->FramebufferName); + GetGL()->Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - GL.BindFramebuffer(GL_FRAMEBUFFER, Graphics->Lighting.FBO.ID); - GL.Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + GetGL()->BindFramebuffer(GL_FRAMEBUFFER, Graphics->Lighting.FBO.ID); + GetGL()->Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // TODO(Jesse): Why exactly would this not be necessary? /* glBindFramebuffer(GL_FRAMEBUFFER, Graphics->SG->FramebufferName); */ @@ -364,32 +356,32 @@ ClearFramebuffers(graphics *Graphics, render_entity_to_texture_group *RTTGroup) for (s32 Index = 0; Index < 2; ++Index) { - GL.BindFramebuffer(GL_FRAMEBUFFER, Graphics->Gaussian.FBOs[Index].ID); - GL.Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + GetGL()->BindFramebuffer(GL_FRAMEBUFFER, Graphics->Gaussian.FBOs[Index].ID); + GetGL()->Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); } - GL.BindFramebuffer(GL_FRAMEBUFFER, 0); - GL.Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + GetGL()->BindFramebuffer(GL_FRAMEBUFFER, 0); + GetGL()->Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); if (Graphics->Settings.BravoilMcGuireOIT) { - GL.BindFramebuffer(GL_FRAMEBUFFER, Graphics->Transparency.FBO.ID); + GetGL()->BindFramebuffer(GL_FRAMEBUFFER, Graphics->Transparency.FBO.ID); #if 1 - GL.Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + GetGL()->Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); #else { u32 Attachments = GL_COLOR_ATTACHMENT0; - GL.DrawBuffers(1, &Attachments); - GL.Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + GetGL()->DrawBuffers(1, &Attachments); + GetGL()->Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); } { u32 Attachments = GL_COLOR_ATTACHMENT0 + 1; - GL.DrawBuffers(1, &Attachments); - GL.ClearColor(1.f, 1.f, 1.f, 1.f); - GL.Clear(GL_COLOR_BUFFER_BIT); + GetGL()->DrawBuffers(1, &Attachments); + GetGL()->ClearColor(1.f, 1.f, 1.f, 1.f); + GetGL()->Clear(GL_COLOR_BUFFER_BIT); } { @@ -400,8 +392,8 @@ ClearFramebuffers(graphics *Graphics, render_entity_to_texture_group *RTTGroup) } else { - GL.BindFramebuffer(GL_FRAMEBUFFER, Graphics->Transparency.FBO.ID); - GL.Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + GetGL()->BindFramebuffer(GL_FRAMEBUFFER, Graphics->Transparency.FBO.ID); + GetGL()->Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); } @@ -608,16 +600,20 @@ Triangulate(untextured_3d_geometry_buffer* Dest, world_chunk* Chunk, chunk_dimen inline b32 IsBoundaryVoxel(world_chunk *Chunk, voxel_position Offset, chunk_dimension Dim) { + b32 Result = False; + + NotImplemented; +#if 0 s32 VoxelIndex = GetIndex(Offset, Dim); voxel *V = &Chunk->Voxels[VoxelIndex]; - b32 Result = False; Result |= IsSet( V, Voxel_BackFace); Result |= IsSet( V, Voxel_FrontFace); Result |= IsSet( V, Voxel_TopFace); Result |= IsSet( V, Voxel_BottomFace); Result |= IsSet( V, Voxel_LeftFace); Result |= IsSet( V, Voxel_RightFace); +#endif return Result; } @@ -743,64 +739,65 @@ HighlightEntity(engine_resources *Engine, entity *Entity) link_internal void DrawFrustum(world *World, graphics *Graphics, camera *Camera) { - auto *GpuBuffer = &GetCurrentGpuMap(Graphics)->Buffer; - auto Dest = ReserveBufferSpace(GpuBuffer, VERTS_PER_LINE*4); - - v3 SimSpaceP = GetSimSpaceP(World, Camera->CurrentP); - DEBUG_DrawLine(&Dest, line(SimSpaceP+Camera->Front*200.f, Camera->Frust.Top.Normal*5.f), RGB_RED, 0.2f ); - DEBUG_DrawLine(&Dest, line(SimSpaceP+Camera->Front*200.f, Camera->Frust.Bot.Normal*5.f), RGB_BLUE, 0.2f ); - DEBUG_DrawLine(&Dest, line(SimSpaceP+Camera->Front*200.f, Camera->Frust.Left.Normal*5.f), RGB_GREEN, 0.2f ); - DEBUG_DrawLine(&Dest, line(SimSpaceP+Camera->Front*200.f, Camera->Frust.Right.Normal*5.f), RGB_YELLOW, 0.2f ); + NotImplemented; + /* auto *GpuBuffer = &Graphics->ImmediateGeometry; */ + /* auto Dest = ReserveBufferSpace(GpuBuffer, VERTS_PER_LINE*4); */ + + /* v3 SimSpaceP = GetSimSpaceP(World, Camera->CurrentP); */ + /* DEBUG_DrawLine(&Dest, line(SimSpaceP+Camera->Front*200.f, Camera->Frust.Top.Normal*5.f), RGB_RED, 0.2f ); */ + /* DEBUG_DrawLine(&Dest, line(SimSpaceP+Camera->Front*200.f, Camera->Frust.Bottom.Normal*5.f), RGB_BLUE, 0.2f ); */ + /* DEBUG_DrawLine(&Dest, line(SimSpaceP+Camera->Front*200.f, Camera->Frust.Left.Normal*5.f), RGB_GREEN, 0.2f ); */ + /* DEBUG_DrawLine(&Dest, line(SimSpaceP+Camera->Front*200.f, Camera->Frust.Right.Normal*5.f), RGB_YELLOW, 0.2f ); */ } link_internal void RenderTransparencyBuffers(v2i ApplicationResolution, render_settings *Settings, transparency_render_group *Group) { - FlushBuffersToCard(&Group->GpuBuffer); + FlushBuffersToCard_gpu_mapped_element_buffer(&Group->GpuBuffer.Handles); if (Group->GpuBuffer.Buffer.At) { - GL.BindFramebuffer(GL_FRAMEBUFFER, Group->FBO.ID); + GetGL()->BindFramebuffer(GL_FRAMEBUFFER, Group->FBO.ID); UseShader(&Group->Shader); if (Settings->BravoilMcGuireOIT) { SetViewport(ApplicationResolution); - GL.Disable(GL_CULL_FACE); + GetGL()->Disable(GL_CULL_FACE); - GL.Enable(GL_BLEND); - /* GL.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); */ + GetGL()->Enable(GL_BLEND); + /* GetGL()->BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); */ // TODO(Jesse): The portable version requires changing the shader a bit - /* GL.BlendFuncSeparate(GL_ONE, GL_ONE, GL_ZERO, GL_ONE_MINUS_SRC_ALPHA); */ + /* GetGL()->BlendFuncSeparate(GL_ONE, GL_ONE, GL_ZERO, GL_ONE_MINUS_SRC_ALPHA); */ - GL.BlendFunci(0, GL_ONE, GL_ONE); - GL.BlendFunci(1, GL_ONE, GL_ONE); - /* GL.BlendFunci(1, GL_ZERO, GL_ONE_MINUS_SRC_ALPHA); */ - /* GL.BlendFunci(1, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); */ + GetGL()->BlendFunci(0, GL_ONE, GL_ONE); + GetGL()->BlendFunci(1, GL_ONE, GL_ONE); + /* GetGL()->BlendFunci(1, GL_ZERO, GL_ONE_MINUS_SRC_ALPHA); */ + /* GetGL()->BlendFunci(1, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); */ Draw(Group->GpuBuffer.Buffer.At); - GL.Disable(GL_BLEND); + GetGL()->Disable(GL_BLEND); - GL.Enable(GL_CULL_FACE); + GetGL()->Enable(GL_CULL_FACE); } else { - GL.Enable(GL_BLEND); - GL.BlendFunc(GL_ONE, GL_ONE); - GL.Disable(GL_CULL_FACE); - /* GL.DepthFunc(GL_LEQUAL); */ - /* GL.DepthFunc(GL_ALWAYS); */ + GetGL()->Enable(GL_BLEND); + GetGL()->BlendFunc(GL_ONE, GL_ONE); + GetGL()->Disable(GL_CULL_FACE); + /* GetGL()->DepthFunc(GL_LEQUAL); */ + /* GetGL()->DepthFunc(GL_ALWAYS); */ SetViewport(ApplicationResolution); Draw(Group->GpuBuffer.Buffer.At); - GL.Disable(GL_BLEND); - GL.Enable(GL_CULL_FACE); - /* GL.DepthFunc(GL_LEQUAL); */ + GetGL()->Disable(GL_BLEND); + GetGL()->Enable(GL_CULL_FACE); + /* GetGL()->DepthFunc(GL_LEQUAL); */ } Group->GpuBuffer.Buffer.At = 0; @@ -817,8 +814,8 @@ SetupRenderToTextureShader(engine_resources *Engine, texture *Texture, camera *C // GL stuff { - GL.BindFramebuffer(GL_FRAMEBUFFER, RTTGroup->FBO.ID); - GL.BindTexture(GL_TEXTURE_2D, Texture->ID); + GetGL()->BindFramebuffer(GL_FRAMEBUFFER, RTTGroup->FBO.ID); + GetGL()->BindTexture(GL_TEXTURE_2D, Texture->ID); RTTGroup->FBO.Attachments = 0; FramebufferTexture(&RTTGroup->FBO, Texture); @@ -833,8 +830,8 @@ SetupRenderToTextureShader(engine_resources *Engine, texture *Texture, camera *C SetViewport(V2(Texture->Dim)); - GL.Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - GL.Enable(GL_DEPTH_TEST); + GetGL()->Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + GetGL()->Enable(GL_DEPTH_TEST); } } return Result; @@ -845,18 +842,18 @@ SetupVertexAttribsFor_world_chunk_element_buffer(gpu_element_buffer_handles *Han { 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); + GetGL()->EnableVertexAttribArray(VERTEX_POSITION_LAYOUT_LOCATION); + GetGL()->EnableVertexAttribArray(VERTEX_NORMAL_LAYOUT_LOCATION); + GetGL()->EnableVertexAttribArray(VERTEX_COLOR_LAYOUT_LOCATION); + GetGL()->EnableVertexAttribArray(VERTEX_TRANS_EMISS_LAYOUT_LOCATION); AssertNoGlErrors; - GL.BindBuffer(GL_ARRAY_BUFFER, Handles->VertexHandle); - GL.VertexAttribPointer(VERTEX_POSITION_LAYOUT_LOCATION, 3, GL_BYTE, GL_FALSE, 0, (void*)0); + GetGL()->BindBuffer(GL_ARRAY_BUFFER, Handles->Handles[mesh_VertexHandle]); + GetGL()->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); + GetGL()->BindBuffer(GL_ARRAY_BUFFER, Handles->Handles[mesh_NormalHandle]); + GetGL()->VertexAttribPointer(VERTEX_NORMAL_LAYOUT_LOCATION, 3, GL_BYTE, GL_TRUE, 0, (void*)0); AssertNoGlErrors; @@ -865,77 +862,34 @@ SetupVertexAttribsFor_world_chunk_element_buffer(gpu_element_buffer_handles *Han 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_UNSIGNED_INT, 0, 0); */ - 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 + GetGL()->BindBuffer(GL_ARRAY_BUFFER, Handles->Handles[mesh_MatHandle]); + /* GetGL()->VertexAttribIPointer(VERTEX_COLOR_LAYOUT_LOCATION, 1, GL_UNSIGNED_INT, 0, 0); */ + GetGL()->VertexAttribIPointer(VERTEX_COLOR_LAYOUT_LOCATION, 1, GL_SHORT, sizeof(matl), Cast(void*, OffsetOf(ColorIndex, matl))); + GetGL()->VertexAttribIPointer(VERTEX_TRANS_EMISS_LAYOUT_LOCATION, 2, GL_BYTE, sizeof(matl), Cast(void*, OffsetOf(Transparency, matl)) ); // @vertex_attrib_I_pointer_transparency_offsetof AssertNoGlErrors; } + link_internal void -SetupVertexAttribsFor_u3d_geo_element_buffer(gpu_element_buffer_handles *Handles) +DrawGpuBufferImmediate(gpu_element_buffer_handles *Handles, u32 Count) { 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; - - - 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; + Assert(Handles->Mapped == False); + Assert(Handles->ElementCount); + Assert(Handles->VAO); - 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; + auto GL = GetGL(); - 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, - // 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_UNSIGNED_INT, 0, 0); */ - 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 - AssertNoGlErrors; + GL->BindVertexArray(Handles->VAO); + /* SetupVertexAttribsFor_u3d_geo_element_buffer(Handles); */ + Draw(Count); + GL->BindBuffer(GL_ARRAY_BUFFER, 0); } - link_internal void DrawGpuBufferImmediate(gpu_element_buffer_handles *Handles) { - AssertNoGlErrors; - - Draw(Handles->ElementCount); - - GL.BindBuffer(GL_ARRAY_BUFFER, 0); - - GL.DisableVertexAttribArray(VERTEX_POSITION_LAYOUT_LOCATION); - GL.DisableVertexAttribArray(VERTEX_NORMAL_LAYOUT_LOCATION); - GL.DisableVertexAttribArray(VERTEX_COLOR_LAYOUT_LOCATION); - GL.DisableVertexAttribArray(VERTEX_TRANS_EMISS_LAYOUT_LOCATION); + DrawGpuBufferImmediate(Handles, Handles->ElementCount); } poof( @@ -951,7 +905,7 @@ poof( link_internal void CopyToGpuBuffer( (buffer_t.name) *Mesh, gpu_mapped_(buffer_t.name) *GpuBuffer) { - gpu_mapped_(buffer_t.name) Dest = MapGpuBuffer_(buffer_t.name)(&GpuBuffer->Handles); + gpu_mapped_(buffer_t.name) Dest = MapGpuBuffer_(container_t.name)(&GpuBuffer->Handles); CopyBufferIntoBuffer(Mesh, &Dest.Buffer); FlushBuffersToCard(&Dest); } @@ -959,7 +913,7 @@ poof( link_internal void CopyToGpuBuffer( (buffer_t.name) *Mesh, gpu_element_buffer_handles *Handles) { - gpu_mapped_(buffer_t.name) Dest = MapGpuBuffer_(buffer_t.name)(Handles); + gpu_mapped_(buffer_t.name) Dest = MapGpuBuffer_(container_t.name)(Handles); CopyBufferIntoBuffer(Mesh, &Dest.Buffer); FlushBuffersToCard(&Dest); } @@ -1015,7 +969,7 @@ poof( } else { - DeallocateGpuElementBuffer(Handles); + DeallocateGpuBuffer(Handles); AssertNoGlErrors; } @@ -1037,20 +991,49 @@ 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(lod_element_buffer, untextured_3d_geometry_buffer)) */ +/* #include */ link_internal void -ReallocateAndSyncGpuBuffers(gpu_element_buffer_handles *Handles, untextured_3d_geometry_buffer *Mesh) +DeleteGpuBuffer(gpu_element_buffer_handles *Handles) { - if (Handles->VertexHandle) + Assert(Handles->VAO); + Assert(Handles->Handles[0]); + Assert(Handles->Handles[1]); + Assert(Handles->Handles[2]); + GetGL()->DeleteVertexArrays(1, &Handles->VAO); + GetGL()->DeleteBuffers(3, &Handles->Handles[mesh_VertexHandle]); +} + +link_internal void +ReallocateGpuBuffers(gpu_element_buffer_handles *Handles, data_type Type, u32 ElementCount) +{ + Assert(False); + Assert(Handles->Mapped == False); + if (Handles->VAO) { - GL.DeleteBuffers(3, &Handles->VertexHandle); + DeleteGpuBuffer(Handles); } Clear(Handles); - AllocateGpuElementBuffer(Handles, Mesh->Type, Mesh->At); - CopyToGpuBuffer(Mesh, Handles); + AllocateGpuBuffer_gpu_mapped_element_buffer(Handles, Type, ElementCount); +} + +link_internal void +ReallocateAndSyncGpuBuffers(gpu_element_buffer_handles *Handles, untextured_3d_geometry_buffer *Mesh) +{ + ReallocateGpuBuffers(Handles, Mesh->Type, Mesh->At); + /* CopyToGpuBuffer(Mesh, Handles); */ + NotImplemented; +} + +link_internal gpu_mapped_element_buffer +AllocateAndMapGpuBuffer(data_type Type, u32 ElementCount) +{ + gpu_mapped_element_buffer Buf = {}; + AllocateGpuBuffer(&Buf, Type, ElementCount); + MapGpuBuffer(&Buf); + return Buf; } /* poof(gpu_buffer(world_chunk_lod_element_buffer, world_chunk_geometry_buffer)) */ @@ -1131,43 +1114,50 @@ DrawLod_world_chunk(engine_resources *Engine, shader *Shader, world_chunk_lod_el } #endif - +#if 1 link_internal void -DrawLod(engine_resources *Engine, shader *Shader, lod_element_buffer *Meshes, r32 DistanceSquared, v3 Basis, Quaternion Rotation, v3 Scale ) +poof(@async @render) +DrawLod( engine_resources *Engine, + shader *Shader, + gpu_element_buffer_handles *Handles, + v3 Basis, + Quaternion Rotation, + v3 Scale ) { + TIMED_FUNCTION(); + UNPACK_ENGINE_RESOURCES(Engine); AssertNoGlErrors; - auto MeshBit = MeshBit_None; + Assert(Handles->Mapped == False); - if (DistanceSquared > Square(400*32)) - { - if (HasGpuMesh(Meshes, MeshBit_Lod4)) { MeshBit = MeshBit_Lod4; } - } - else if (DistanceSquared > Square(250*32)) + if (HasGpuMesh(Handles)) { - if (HasGpuMesh(Meshes, MeshBit_Lod3)) { MeshBit = MeshBit_Lod3; } - } - else if (DistanceSquared > Square(150*32)) - { - if (HasGpuMesh(Meshes, MeshBit_Lod2)) { MeshBit = MeshBit_Lod2; } - } - else if (DistanceSquared > Square(70*32)) - { - if (HasGpuMesh(Meshes, MeshBit_Lod1)) { MeshBit = MeshBit_Lod1; } - } - else - { - if (HasGpuMesh(Meshes, MeshBit_Lod0)) { MeshBit = MeshBit_Lod0; } - } + m4 ModelMatrix = GetTransformMatrix(Basis*GLOBAL_RENDER_SCALE_FACTOR, Scale*GLOBAL_RENDER_SCALE_FACTOR, Rotation); + TryBindUniform(Shader, "ModelMatrix", &ModelMatrix); - if (MeshBit != MeshBit_None) - { - m4 LocalTransform = GetTransformMatrix(Basis, Scale, Rotation); + m4 NormalMatrix = Transpose(Inverse(ModelMatrix)); + TryBindUniform(Shader, "NormalMatrix", &NormalMatrix); // NOTE(Jesse): Not all shaders that use this path draw normals (namely, DepthRTT) + + DrawGpuBufferImmediate(Handles); AssertNoGlErrors; + } +} +#endif + +#if 0 +link_internal void +DrawLod(engine_resources *Engine, shader *Shader, lod_element_buffer *Meshes, r32 DistanceSquared, v3 Basis, Quaternion Rotation, v3 Scale ) +{ + UNPACK_ENGINE_RESOURCES(Engine); + AssertNoGlErrors; + auto MeshBit = MeshBit_None; + + if (HasGpuMesh(Meshes, MeshBit_Lod0)) + { + m4 LocalTransform = GetTransformMatrix(Basis*GLOBAL_RENDER_SCALE_FACTOR, Scale*GLOBAL_RENDER_SCALE_FACTOR, Rotation); m4 NormalMatrix = Transpose(Inverse(LocalTransform)); - AssertNoGlErrors; // @janky_model_matrix_bs Ensure(TryBindUniform(Shader, "ModelMatrix", &LocalTransform)); @@ -1175,13 +1165,14 @@ DrawLod(engine_resources *Engine, shader *Shader, lod_element_buffer *Meshes, r3 TryBindUniform(Shader, "NormalMatrix", &NormalMatrix); // NOTE(Jesse): Not all shaders that use this path draw normals (namely, DepthRTT) AssertNoGlErrors; - auto Handles = &Meshes->GpuBufferHandles[ToIndex(MeshBit)]; + auto Handles = &Meshes->GpuBufferHandles[ToIndex(MeshBit_Lod0)]; SetupVertexAttribsFor_u3d_geo_element_buffer(Handles); DrawGpuBufferImmediate(Handles); AssertNoGlErrors; } } +#endif #if 0 link_internal void @@ -1206,12 +1197,12 @@ RenderToTexture_world_chunk(engine_resources *Engine, asset_thumbnail *Thumb, wo /* } */ link_internal void -RenderToTexture(engine_resources *Engine, asset_thumbnail *Thumb, lod_element_buffer *Meshes, v3 Offset, camera *Camera = 0) +RenderToTexture(engine_resources *Engine, asset_thumbnail *Thumb, gpu_mapped_element_buffer *Mesh, v3 Offset, camera *Camera = 0) { if (Camera == 0) { Camera = &Thumb->Camera; } if (SetupRenderToTextureShader(Engine, &Thumb->Texture, Camera)) { - DrawLod(Engine, &Engine->RTTGroup.Shader, Meshes, 0.f, Offset); + DrawLod(Engine, &Engine->RTTGroup.Shader, &Mesh->Handles, Offset); } else { @@ -1222,7 +1213,7 @@ RenderToTexture(engine_resources *Engine, asset_thumbnail *Thumb, lod_element_bu link_internal void RenderToTexture(engine_resources *Engine, asset_thumbnail *Thumb, model *Model, v3 Offset, camera *Camera = 0) { - RenderToTexture(Engine, Thumb, &Model->Meshes, Offset, Camera); + RenderToTexture(Engine, Thumb, &Model->Mesh, Offset, Camera); } link_internal void @@ -1235,14 +1226,14 @@ RenderToTexture(engine_resources *Engine, asset_thumbnail *Thumb, untextured_3d_ // Geometry stuff { - MapGpuBuffer_untextured_3d_geometry_buffer(&RTTGroup->GeoBuffer); + MapGpuBuffer(&RTTGroup->GeoBuffer); untextured_3d_geometry_buffer* Dest = &RTTGroup->GeoBuffer.Buffer; BufferVertsChecked(Src, Dest, Offset, V3(1.0f)); - FlushBuffersToCard(&RTTGroup->GeoBuffer); + FlushBuffersToCard_gpu_mapped_element_buffer(&RTTGroup->GeoBuffer.Handles); } - GL.Enable(GL_DEPTH_TEST); + GetGL()->Enable(GL_DEPTH_TEST); Draw(RTTGroup->GeoBuffer.Buffer.At); RTTGroup->GeoBuffer.Buffer.At = 0; } @@ -1302,14 +1293,16 @@ DrawEntity( shader *Shader, Entity->_CollisionVolumeRadius = Model->Dim/2.f; } - SyncGpuBuffersImmediate(GetEngineResources(), &Model->Meshes); + // TODO(Jesse): Do we still do this here? + NotImplemented; + /* SyncGpuBuffersImmediate(GetEngineResources(), &Model->Mesh); */ AssertNoGlErrors; v3 Offset = AnimationOffset + Entity->Scale*(V3(Model->Dim)/2.f); v3 Basis = GetRenderP(GetEngineResources(), Entity->P) + Offset; AssertNoGlErrors; - DrawLod(GetEngineResources(), Shader, &Model->Meshes, 0.f, Basis, FromEuler(Entity->EulerAngles), V3(Entity->Scale)); + DrawLod(GetEngineResources(), Shader, &Model->Mesh.Handles, Basis, FromEuler(Entity->EulerAngles), V3(Entity->Scale)); } } } @@ -1322,7 +1315,7 @@ SetupGBufferShader(graphics *Graphics, v2i ApplicationResolution, b32 DoSelectio if (DoSelectionMasking) { - auto SelectionRegion = GetLevelEditor()->SelectionRegion; + auto SelectionRegion = GetLevelEditor()->Selection.Region; SelectionRegion.Min.Offset += V3(0.0001f); SelectionRegion.Max.Offset -= V3(0.0001f); Graphics->MinClipP_worldspace = GetRenderP(GetEngineResources(), SelectionRegion.Min); @@ -1334,14 +1327,14 @@ SetupGBufferShader(graphics *Graphics, v2i ApplicationResolution, b32 DoSelectio Graphics->MaxClipP_worldspace = {}; } - GL.BindFramebuffer(GL_FRAMEBUFFER, GBufferRenderGroup->FBO.ID); - GL.UseProgram(GBufferRenderGroup->gBufferShader.ID); + GetGL()->BindFramebuffer(GL_FRAMEBUFFER, GBufferRenderGroup->FBO.ID); + GetGL()->UseProgram(GBufferRenderGroup->gBufferShader.ID); SetViewport(ApplicationResolution); BindShaderUniforms(&GBufferRenderGroup->gBufferShader); - GL.Disable(GL_CULL_FACE); + GetGL()->Disable(GL_CULL_FACE); AssertNoGlErrors; } @@ -1351,20 +1344,20 @@ TeardownGBufferShader(graphics *Graphics) { auto GBufferRenderGroup = Graphics->gBuffer; CleanupTextureBindings(&GBufferRenderGroup->gBufferShader); - GL.Enable(GL_CULL_FACE); + GetGL()->Enable(GL_CULL_FACE); } link_internal void -SetupShadowMapShader(graphics *Graphics, v2i ShadowMapResolution, b32 DoSelectionMasking) +SetupShadowMapShader(world *World, graphics *Graphics, v2i ShadowMapResolution, b32 DoSelectionMasking) { shadow_render_group *SG = Graphics->SG; if (DoSelectionMasking) { - auto SelectionRegion = GetLevelEditor()->SelectionRegion; + auto SelectionRegion = GetLevelEditor()->Selection.Region; SelectionRegion.Min.Offset += V3(0.0001f); SelectionRegion.Max.Offset -= V3(0.0001f); Graphics->MinClipP_worldspace = GetRenderP(GetEngineResources(), SelectionRegion.Min); @@ -1376,20 +1369,13 @@ SetupShadowMapShader(graphics *Graphics, v2i ShadowMapResolution, b32 DoSelectio Graphics->MaxClipP_worldspace = {}; } - GL.BindFramebuffer(GL_FRAMEBUFFER, SG->FramebufferName); + GetGL()->BindFramebuffer(GL_FRAMEBUFFER, SG->FramebufferName); SetViewport(ShadowMapResolution); - // TODO(Jesse): Duplicate MVP calculation - // @duplicate_shadow_map_MVP_calculation - v3 FrustCenter = GetFrustumCenter(Graphics->Camera); - SG->Shader.MVP = GetShadowMapMVP(Graphics->Settings.Lighting.SunP, FrustCenter); - UseShader(&SG->Shader); - /* GL.UniformMatrix4fv(SG->MVP_ID, 1, GL_FALSE, &SG->MVP.E[0].E[0]); */ - - GL.Disable(GL_CULL_FACE); + GetGL()->Disable(GL_CULL_FACE); AssertNoGlErrors; } @@ -1397,7 +1383,7 @@ SetupShadowMapShader(graphics *Graphics, v2i ShadowMapResolution, b32 DoSelectio link_internal void TeardownShadowMapShader(graphics *Graphics) { - GL.Enable(GL_CULL_FACE); + GetGL()->Enable(GL_CULL_FACE); AssertNoGlErrors; } @@ -1450,6 +1436,8 @@ DrawEntitiesToGBuffer( v2i ApplicationResolution, link_internal void ComputeDrawListsAndQueueUnallocatedChunks(engine_resources *Engine) { + NotImplemented; +#if 0 TIMED_FUNCTION(); UNPACK_ENGINE_RESOURCES(Engine); @@ -1504,27 +1492,61 @@ ComputeDrawListsAndQueueUnallocatedChunks(engine_resources *Engine) { InvalidCodePath(); } } } +#endif } link_internal void -RenderDrawList(engine_resources *Engine, world_chunk_ptr_paged_list *DrawList, shader *Shader) +RenderDrawList(engine_resources *Engine, octree_node_ptr_paged_list *DrawList, shader *Shader, camera *Camera) { - UNPACK_ENGINE_RESOURCES(Engine); - IterateOver(DrawList, ChunkPtrPtr, ChunkIndex) + world *World = Engine->World;; + + IterateOver(DrawList, Node, NodeIndex) { - world_chunk *Chunk = *ChunkPtrPtr; + auto Chunk = Node->Chunk; + Assert(Chunk); // In case gpu meshes got deallocated after the chunk was added to the draw list - if (HasGpuMesh(&Chunk->Meshes)) + if (HasGpuMesh(Chunk)) { - v3 CameraP = GetSimSpaceP(World, Camera->CurrentP); - v3 ChunkP = GetSimSpaceP(World, Chunk->WorldP); - - /* SyncGpuBuffersImmediate(Engine, &Chunk->Meshes); */ + v3 Offset = V3(Node->Resolution); + /* v3 Offset = V3(Node->Resolution*0.5f); */ + /* v3 Offset = -1.f*V3(Node->Resolution*0.5f); */ + /* v3 Offset = {}; */ + v3 Basis = Offset; + if (Camera) + { + Basis += GetRenderP(World->ChunkDim, Chunk->WorldP, Camera); + } + else + { + Basis += GetSimSpaceP(World, Chunk->WorldP); + } + DrawLod(Engine, Shader, &Chunk->Handles, Basis, Quaternion(), V3(Chunk->DimInChunks)); AssertNoGlErrors; + } + } +} - v3 Basis = GetRenderP(Engine, Chunk->WorldP); - DrawLod(Engine, Shader, &Chunk->Meshes, 0.f, Basis); +link_internal void +RenderDrawList(engine_resources *Engine, world_chunk_ptr_paged_list *DrawList, shader *Shader, camera *Camera) +{ + world *World = Engine->World;; + + IterateOver(DrawList, Chunk, ChunkIndex) + { + // In case gpu meshes got deallocated after the chunk was added to the draw list + if (HasGpuMesh(Chunk)) + { + v3 Basis; + if (Camera) + { + Basis = GetRenderP(World->ChunkDim, Chunk->WorldP, Camera); + } + else + { + Basis = GetSimSpaceP(World, Chunk->WorldP); + } + DrawLod(Engine, Shader, &Chunk->Handles, Basis, Quaternion(), V3(Chunk->DimInChunks)); AssertNoGlErrors; } } @@ -1588,13 +1610,14 @@ DrawWorldAndEntitiesToShadowMap(v2i ShadowMapResolution, engine_resources *Engin UNPACK_ENGINE_RESOURCES(Engine); - v3i Radius = World->VisibleRegion/2; + v3i Radius = V3i(World->VisibleRegionSize/2); v3i Min = World->Center - Radius; v3i Max = World->Center + Radius; shadow_render_group *SG = Graphics->SG; - SetupShadowMapShader(Graphics, ShadowMapResolution, Editor->LayeredBrushEditor.SeedBrushWithSelection); + b32 MaskSelection = False; + SetupShadowMapShader(World, Graphics, ShadowMapResolution, MaskSelection); // NOTE(Jesse): So there's a visual distinction between preview and instantiated /* DrawEditorPreview(Engine, &SG->DepthShader); */ @@ -1607,3 +1630,94 @@ DrawWorldAndEntitiesToShadowMap(v2i ShadowMapResolution, engine_resources *Engin TeardownShadowMapShader(Graphics); } + +link_internal void +UpdateKeyLight(graphics *Graphics, r32 tDay) +{ + auto SG = Graphics->SG; + r32 tDaytime = Cos(tDay); + r32 tPostApex = Sin(tDay); + + lighting_settings *Lighting = &Graphics->Settings.Lighting; + + v3 DawnColor = HSVtoRGB(Lighting->DawnHSV) * Lighting->DawnIntensity; + v3 SunColor = HSVtoRGB(Lighting->SunHSV ) * Lighting->SunIntensity; + v3 DuskColor = HSVtoRGB(Lighting->DuskHSV) * Lighting->DuskIntensity; + v3 MoonColor = HSVtoRGB(Lighting->MoonHSV) * Lighting->MoonIntensity; + + Lighting->SunP.x = Sin(((Graphics->SunBasis.x*PI32)) + tDay); + Lighting->SunP.y = Cos(((Graphics->SunBasis.y*PI32))+ tDay); + Lighting->SunP.z = (1.3f+Cos(((Graphics->SunBasis.z*PI32)) + tDay))/2.f; + + if (tDaytime > 0.f) + { + if (tPostApex > 0.f) + { + Lighting->CurrentSunColor = Lerp(tDaytime, DuskColor, SunColor); + } + else + { + Lighting->CurrentSunColor = Lerp(tDaytime, DawnColor, SunColor); + } + } + else + { + if (tPostApex > 0.f) + { + Lighting->CurrentSunColor = Lerp(Abs(tDaytime), DuskColor, MoonColor); + } + else + { + Lighting->CurrentSunColor = Lerp(Abs(tDaytime), DawnColor, MoonColor); + } + } + + switch (Graphics->Settings.ToneMappingType) + { + case ToneMappingType_None: + case ToneMappingType_Reinhard: + case ToneMappingType_Exposure: + { } break; + + case ToneMappingType_AGX: + case ToneMappingType_AGX_Sepia: + case ToneMappingType_AGX_Punchy: + { + if (LengthSq(Lighting->CurrentSunColor) > 1.f) + { + Lighting->CurrentSunColor = Normalize(Lighting->CurrentSunColor); + } + } break; + } +} + + +link_internal void +poof(@async @render) +FinalizeShitAndFuckinDoStuff(gen_chunk *GenChunk, octree_node *DestNode) +{ + world_chunk *DestChunk = DestNode->Chunk; + world_chunk *SynChunk = &GenChunk->Chunk; + Assert(HasGpuMesh(&GenChunk->Mesh) == True); + Assert(HasGpuMesh( SynChunk) == False); + + // @dest_chunk_can_have_mesh + /* Assert(HasGpuMesh(DestChunk) == False); */ + + FlushBuffersToCard_gpu_mapped_element_buffer(&GenChunk->Mesh.Handles); + + auto DestHandles = DestChunk->Handles; + + DestChunk->Handles = GenChunk->Mesh.Handles; + + if (HasGpuMesh(&DestHandles)) + { + DeleteGpuBuffer(&DestHandles); + } + + GenChunk->Mesh = {}; + Free(&GetEngineResources()->GenChunkFreelist, GenChunk); + + FinalizeNodeInitializaion(DestNode); +} + diff --git a/src/engine/render.h b/src/engine/render.h index 971ddd7a3..b133dbe3e 100644 --- a/src/engine/render.h +++ b/src/engine/render.h @@ -1,14 +1,10 @@ struct world_chunk; -// NOTE(Jesse): Must match defines in header.glsl -#define VERTEX_POSITION_LAYOUT_LOCATION 0 -#define VERTEX_NORMAL_LAYOUT_LOCATION 1 -#define VERTEX_COLOR_LAYOUT_LOCATION 2 -#define VERTEX_TRANS_EMISS_LAYOUT_LOCATION 3 +#define GLOBAL_RENDER_SCALE_FACTOR (0.001f) -#define DEFAULT_LINE_THICKNESS (0.1f) +#define DEFAULT_LINE_THICKNESS (0.3f) #define SSAO_KERNEL_SIZE 32 struct ao_render_group @@ -35,6 +31,7 @@ struct g_buffer_textures }; struct g_buffer_render_group +poof(@do_editor_ui) { framebuffer FBO; g_buffer_textures Textures; @@ -45,7 +42,6 @@ struct g_buffer_render_group m4 InverseViewMatrix; m4 InverseProjectionMatrix; - m4 ViewProjection; u32 GlTimerObject; @@ -75,18 +71,61 @@ Orthographic( r32 X, r32 Y, r32 Zmin, r32 Zmax) r32 f = Zmax; r32 n = Zmin; +#if 1 + // TODO(Jesse): Pretty sure this should use floats .. m4 Result = { V4(2/(r-l), 0 , 0 , -1*((r+l)/(r-l)) ), V4(0 , 2/(t-b), 0 , -1*((t+b)/(t-b)) ), V4(0 , 0 , -2/(f-n), -1*((f+n)/(f-n)) ), V4(0 , 0 , 0 , 1) }; +#else + m4 Result = { + V4(2.f/(r-l), 0.f , 0.f , -1.f*((r+l)/(r-l)) ), + V4(0.f , 2.f/(t-b), 0.f , -1.f*((t+b)/(t-b)) ), + V4(0.f , 0.f , -2.f/(f-n), -1.f*((f+n)/(f-n)) ), + V4(0.f , 0.f , 0.f , 1.f) + }; +#endif return Result; } inline m4 -Perspective(radians FOV, v2 WindowDim, r32 NearClip, r32 FarClip) +Perspective_infinite(radians FOV, v2 WindowDim, r32 NearClip, r32 FarClip) +{ + +#if 0 +// https://chaosinmotion.com/2010/09/06/goodbye-far-clipping-plane/ +// +// Projection +// +// a 0 0 0 +// 0 b 0 0 +// 0 0 0 d +// 0 0 e 0 +// +#endif + + r32 FocalLength = Tan(FOV/2.f); + r32 Aspect = WindowDim.x/WindowDim.y; + + r32 a = FOV/Aspect; + r32 b = FOV; + r32 d = -NearClip; + r32 e = -1.f; + + m4 Result = { + V4(a, 0, 0, 0), + V4(0, b, 0, 0), + V4(0, 0, 0, d), + V4(0, 0, e, 0), + }; + + return Result; +} +inline m4 +Perspective_clipped(radians FOV, v2 WindowDim, r32 NearClip, r32 FarClip) { #if 0 @@ -145,10 +184,20 @@ Rads(degrees Degrees) inline m4 ProjectionMatrix(camera *Camera, v2 ScreenDim) { - m4 Result = Perspective( Rads(Camera->Frust.FOV), - ScreenDim, - Camera->Frust.nearClip, - Camera->Frust.farClip); + /* m4 Result = Perspective_infinite( Camera->Frust.FOV, */ + /* ScreenDim, */ + /* Camera->Frust.nearClip, */ + /* Camera->Frust.farClip); */ + + /* m4 Result = Perspective_infinite( Rads(Camera->Frust.FOV), */ + /* ScreenDim, */ + /* Camera->Frust.nearClip, */ + /* Camera->Frust.farClip); */ + + m4 Result = Perspective_clipped( Rads(Camera->Frust.FOV), + ScreenDim, + Camera->Frust.nearClip, + Camera->Frust.farClip); return Result; } @@ -164,8 +213,8 @@ ProjectionMatrix(camera *Camera, v2 ScreenDim) untextured_3d_geometry_buffer ReserveBufferSpace(untextured_3d_geometry_buffer* Reservation, u32 ElementsToReserve); -link_internal gpu_mapped_element_buffer * -GetCurrentGpuMap(graphics *Graphics); +/* link_internal gpu_mapped_element_buffer * */ +/* GetCurrentGpuMap(graphics *Graphics); */ link_internal void DrawTerrainImmediate(graphics *Graphics, gpu_mapped_element_buffer *GpuBuffer, world_chunk *Chunk); @@ -176,3 +225,20 @@ CopyToGpuBuffer(untextured_3d_geometry_buffer *Mesh, gpu_mapped_element_buffer * link_internal void DeallocateGpuElementBuffer(gpu_mapped_element_buffer *Buf); +link_internal b32 +SyncGpuBuffersAsync(engine_resources *Engine, lod_element_buffer *Meshes); + +link_internal void +DrawLod(engine_resources *Engine, shader *Shader, gpu_element_buffer_handles *Handles, v3 Basis, Quaternion Rotation = Quaternion(), v3 Scale = V3(1.f)); + +link_internal void +SetupVertexAttribsFor_u3d_geo_element_buffer(gpu_element_buffer_handles *Handles); + +link_internal void +DrawGpuBufferImmediate(gpu_element_buffer_handles *Handles); + +link_internal void +DrawGpuBufferImmediate(gpu_element_buffer_handles *Handles, u32 Count); + +link_internal void +FinalizeShitAndFuckinDoStuff(gen_chunk *GenChunk, octree_node *DestNode); diff --git a/src/engine/render/gpu_timer.cpp b/src/engine/render/gpu_timer.cpp new file mode 100644 index 000000000..57a3b730b --- /dev/null +++ b/src/engine/render/gpu_timer.cpp @@ -0,0 +1,3 @@ +poof(block_array_c(gpu_timer, {128})) +#include + diff --git a/src/engine/render/gpu_timer.h b/src/engine/render/gpu_timer.h new file mode 100644 index 000000000..f3b46a36a --- /dev/null +++ b/src/engine/render/gpu_timer.h @@ -0,0 +1,54 @@ +#define INVALID_GPU_TIMER_HANDLE (0xFFFFFFFF) + +struct gpu_timer +{ + u32 Handle = INVALID_GPU_TIMER_HANDLE; + u64 Ns; +}; + +poof(block_array_h(gpu_timer, {128}, {})) +#include + +// TODO(Jesse, globals_cleanup) +global_variable b32 Global_ActiveGPUTimer; + +link_internal gpu_timer +StartGpuTimer(void) +{ + Assert(Global_ActiveGPUTimer == False); + Global_ActiveGPUTimer = True; + + gpu_timer Result = {}; + GetGL()->GenQueries(1, &Result.Handle); + Assert(Result.Handle != INVALID_GPU_TIMER_HANDLE); + + GetGL()->BeginQuery(GL_TIME_ELAPSED, Result.Handle); + return Result; +} + +link_internal void +EndGpuTimer(gpu_timer *Timer) +{ + GetGL()->EndQuery(GL_TIME_ELAPSED); + Assert(Global_ActiveGPUTimer == True); + Global_ActiveGPUTimer = False; +} + +link_internal s32 +QueryGpuTimer(gpu_timer *Timer) +{ + TIMED_FUNCTION(); + + Assert(Timer->Handle != INVALID_GPU_TIMER_HANDLE); + s32 Available = False; + GetGL()->GetQueryObjectiv(Timer->Handle, GL_QUERY_RESULT_AVAILABLE, &Available); + + if (Available) + { + GetGL()->GetQueryObjectui64v(Timer->Handle, GL_QUERY_RESULT, &Timer->Ns); + GetGL()->DeleteQueries(1, &Timer->Handle); + Timer->Handle = INVALID_GPU_TIMER_HANDLE; + } + + return Available; +} diff --git a/src/engine/render/render_init.cpp b/src/engine/render/render_init.cpp index 8036082c6..01d88e41a 100644 --- a/src/engine/render/render_init.cpp +++ b/src/engine/render/render_init.cpp @@ -8,7 +8,7 @@ SetDrawBuffers(framebuffer *FBO) Attachments[AttIndex] = GL_COLOR_ATTACHMENT0 + AttIndex; } - GL.DrawBuffers((s32)FBO->Attachments, Attachments); + GetGL()->DrawBuffers((s32)FBO->Attachments, Attachments); } void @@ -49,15 +49,10 @@ AllocateAndInitSsaoNoise(v2i ApplicationResolution, ao_render_group *AoGroup, me return SsaoNoiseTexture; } -link_internal lighting_render_group -MakeLightingRenderGroup() -{ - lighting_render_group Result = {}; - return Result; -} - -shader -MakeCompositeShader( memory_arena *GraphicsMemory, +link_internal b32 +MakeCompositeShader( + shader *Shader, + memory_arena *GraphicsMemory, v2 *ApplicationResolution, g_buffer_textures *gTextures, texture *ShadowMap, @@ -78,69 +73,48 @@ MakeCompositeShader( memory_arena *GraphicsMemory, tone_mapping_type *ToneMappingType ) { - shader Shader = LoadShaders( CSz(BONSAI_SHADER_PATH "composite.vertexshader"), CSz(BONSAI_SHADER_PATH "composite.fragmentshader") ); - - shader_uniform **Current = &Shader.FirstUniform; - - /* *Current = GetUniform(GraphicsMemory, &Shader, &gTextures->Color, "gColor"); */ - /* Current = &(*Current)->Next; */ - - *Current = GetUniform(GraphicsMemory, &Shader, &gTextures->Normal, "gNormal"); - Current = &(*Current)->Next; - - /* *Current = GetUniform(GraphicsMemory, &Shader, &gTextures->Position, "gPosition"); */ - /* Current = &(*Current)->Next; */ - - /* *Current = GetUniform(GraphicsMemory, &Shader, ShadowMap, "shadowMap"); */ - /* Current = &(*Current)->Next; */ - - /* *Current = GetUniform(GraphicsMemory, &Shader, Ssao, "Ssao"); */ - /* Current = &(*Current)->Next; */ - - *Current = GetUniform(GraphicsMemory, &Shader, BloomTex, "BloomTex"); - Current = &(*Current)->Next; - - *Current = GetUniform(GraphicsMemory, &Shader, TransparencyAccum, "TransparencyAccum"); - Current = &(*Current)->Next; - - *Current = GetUniform(GraphicsMemory, &Shader, TransparencyCount, "TransparencyCount"); - Current = &(*Current)->Next; - - *Current = GetUniform(GraphicsMemory, &Shader, (u32*)UseLightingBloom, "UseLightingBloom"); - Current = &(*Current)->Next; - - *Current = GetUniform(GraphicsMemory, &Shader, (u32*)BravoilMyersOIT, "BravoilMyersOIT"); - Current = &(*Current)->Next; + b32 Result = CompileShaderPair( Shader, CSz(BONSAI_SHADER_PATH "composite.vertexshader"), CSz(BONSAI_SHADER_PATH "composite.fragmentshader") ); + if (Result) + { + Shader->Uniforms = ShaderUniformBuffer(11, GraphicsMemory); - *Current = GetUniform(GraphicsMemory, &Shader, (u32*)BravoilMcGuireOIT, "BravoilMcGuireOIT"); - Current = &(*Current)->Next; + /* *Current = GetUniform(GraphicsMemory, &Shader, &gTextures->Color, "gColor"); */ + /* Current = &(*Current)->Next; */ - *Current = GetUniform(GraphicsMemory, &Shader, LuminanceTex, "LuminanceTex"); - Current = &(*Current)->Next; + /* *Current = GetUniform(GraphicsMemory, &Shader, &gTextures->Position, "gPosition"); */ + /* Current = &(*Current)->Next; */ - /* *Current = GetUniform(GraphicsMemory, &Shader, ShadowMVP, "ShadowMVP"); */ - /* Current = &(*Current)->Next; */ + /* *Current = GetUniform(GraphicsMemory, &Shader, ShadowMap, "shadowMap"); */ + /* Current = &(*Current)->Next; */ - /* *Current = GetUniform(GraphicsMemory, &Shader, Camera, "CameraP"); */ - /* Current = &(*Current)->Next; */ + /* *Current = GetUniform(GraphicsMemory, &Shader, Ssao, "Ssao"); */ + /* Current = &(*Current)->Next; */ - *Current = GetUniform(GraphicsMemory, &Shader, Exposure, "Exposure"); - Current = &(*Current)->Next; + /* InitShaderUniform(&Shader, 8, ShadowMVP, "ShadowMVP"); *1/ */ - *Current = GetUniform(GraphicsMemory, &Shader, (int*)ToneMappingType, "ToneMappingType"); - Current = &(*Current)->Next; + /* InitShaderUniform(&Shader, 9, Camera, "CameraP"); *1/ */ - *Current = GetUniform(GraphicsMemory, &Shader, ApplicationResolution, "ApplicationResolution"); - Current = &(*Current)->Next; + InitShaderUniform(Shader, 0, &gTextures->Normal, "gNormal"); + InitShaderUniform(Shader, 1, BloomTex, "BloomTex"); + InitShaderUniform(Shader, 2, TransparencyAccum, "TransparencyAccum"); + InitShaderUniform(Shader, 3, TransparencyCount, "TransparencyCount"); + InitShaderUniform(Shader, 4, (u32*)UseLightingBloom, "UseLightingBloom"); + InitShaderUniform(Shader, 5, (u32*)BravoilMyersOIT, "BravoilMyersOIT"); + InitShaderUniform(Shader, 6, (u32*)BravoilMcGuireOIT, "BravoilMcGuireOIT"); + InitShaderUniform(Shader, 7, LuminanceTex, "LuminanceTex"); + InitShaderUniform(Shader, 8, Exposure, "Exposure"); + InitShaderUniform(Shader, 9, (int*)ToneMappingType, "ToneMappingType"); + InitShaderUniform(Shader, 10, ApplicationResolution, "ApplicationResolution"); + } AssertNoGlErrors; - return Shader; + return Result; } -shader -MakeLightingShader( memory_arena *GraphicsMemory, +link_internal void +MakeLightingShader( lighting_render_group *Group, v2 *ApplicationResolution, g_buffer_textures *gTextures, @@ -172,112 +146,69 @@ MakeLightingShader( memory_arena *GraphicsMemory, b32 *UseLightingBloom ) { - shader Shader = LoadShaders( CSz(BONSAI_SHADER_PATH "Lighting.vertexshader"), CSz(BONSAI_SHADER_PATH "Lighting.fragmentshader") ); - - shader_uniform **Current = &Shader.FirstUniform; - *Current = GetUniform(GraphicsMemory, &Shader, &gTextures->Color, "gColor"); - Current = &(*Current)->Next; + InitializeLightingRenderGroup( Group, - *Current = GetUniform(GraphicsMemory, &Shader, &gTextures->Normal, "gNormal"); - Current = &(*Current)->Next; + &gTextures->Color, -/* *Current = GetUniform(GraphicsMemory, &Shader, &gTextures->Position, "gPosition"); */ - /* Current = &(*Current)->Next; */ + &gTextures->Normal, - *Current = GetUniform(GraphicsMemory, &Shader, &gTextures->Depth, "gDepth"); - Current = &(*Current)->Next; + &gTextures->Depth, - *Current = GetUniform(GraphicsMemory, &Shader, ShadowMap, "shadowMap"); - Current = &(*Current)->Next; + ShadowMap, - *Current = GetUniform(GraphicsMemory, &Shader, Ssao, "Ssao"); - Current = &(*Current)->Next; + Ssao, - *Current = GetUniform(GraphicsMemory, &Shader, AccumTex, "TransparencyAccum"); - Current = &(*Current)->Next; + AccumTex, - *Current = GetUniform(GraphicsMemory, &Shader, CountTex, "TransparencyCount"); - Current = &(*Current)->Next; + CountTex, - *Current = GetUniform(GraphicsMemory, &Shader, BravoilMyersOIT, "BravoilMyersOIT"); - Current = &(*Current)->Next; + BravoilMyersOIT, - *Current = GetUniform(GraphicsMemory, &Shader, BravoilMcGuireOIT, "BravoilMcGuireOIT"); - Current = &(*Current)->Next; + BravoilMcGuireOIT, - *Current = GetUniform(GraphicsMemory, &Shader, InverseViewMatrix, "InverseViewMatrix"); - Current = &(*Current)->Next; + InverseViewMatrix, - *Current = GetUniform(GraphicsMemory, &Shader, InverseProjectionMatrix, "InverseProjectionMatrix"); - Current = &(*Current)->Next; + InverseProjectionMatrix, - *Current = GetUniform(GraphicsMemory, &Shader, ShadowMVP, "ShadowMVP"); - Current = &(*Current)->Next; + ShadowMVP, - *Current = GetUniform(GraphicsMemory, &Shader, &Lights->ColorTex, "LightColors"); - Current = &(*Current)->Next; + &Lights->ColorTex, - *Current = GetUniform(GraphicsMemory, &Shader, &Lights->PositionTex, "LightPositions"); - Current = &(*Current)->Next; + &Lights->PositionTex, - *Current = GetUniform(GraphicsMemory, &Shader, &Lights->IndexToUV, "LightIndexToUV"); - Current = &(*Current)->Next; + &Lights->IndexToUV, - *Current = GetUniform(GraphicsMemory, &Shader, &Lights->Count, "LightCount"); - Current = &(*Current)->Next; + &Lights->Count, - *Current = GetUniform(GraphicsMemory, &Shader, Camera, "CameraP"); - Current = &(*Current)->Next; + Camera, - *Current = GetUniform(GraphicsMemory, &Shader, SunPosition, "SunPosition"); - Current = &(*Current)->Next; + SunPosition, - *Current = GetUniform(GraphicsMemory, &Shader, SunColor, "SunColor"); - Current = &(*Current)->Next; + SunColor, - *Current = GetUniform(GraphicsMemory, &Shader, FogColor, "FogColor"); - Current = &(*Current)->Next; + FogColor, - *Current = GetUniform(GraphicsMemory, &Shader, FogPower, "FogPower"); - Current = &(*Current)->Next; + FogPower, - *Current = GetUniform(GraphicsMemory, &Shader, (u32*)UseSsao, "UseSsao"); - Current = &(*Current)->Next; + (u32*)UseSsao, - *Current = GetUniform(GraphicsMemory, &Shader, (u32*)UseShadowMapping, "UseShadowMapping"); - Current = &(*Current)->Next; + (u32*)UseShadowMapping, - *Current = GetUniform(GraphicsMemory, &Shader, (u32*)UseLightingBloom, "UseLightingBloom"); - Current = &(*Current)->Next; + (u32*)UseLightingBloom, - *Current = GetUniform(GraphicsMemory, &Shader, ApplicationResolution, "ApplicationResolution"); - Current = &(*Current)->Next; + ApplicationResolution, - *Current = GetUniform(GraphicsMemory, &Shader, ShadowMapResolution, "ShadowMapResolution"); - Current = &(*Current)->Next; + ShadowMapResolution + ); - AssertNoGlErrors; - -#if 0 - if (Lights) - { - *Current = GetUniform(GraphicsMemory, &Shader, Lights->Lights, "Lights"); - Current = &(*Current)->Next; - - *Current = GetUniform(GraphicsMemory, &Shader, &Lights->Count, "LightCount"); - Current = &(*Current)->Next; - } -#endif - - return Shader; } framebuffer GenFramebuffer() { framebuffer Framebuffer = {}; - GL.GenFramebuffers(1, &Framebuffer.ID); + GetGL()->GenFramebuffers(1, &Framebuffer.ID); return Framebuffer; } @@ -291,42 +222,41 @@ CreateAoRenderGroup(memory_arena *Mem) return Result; } -link_internal gaussian_render_group -MakeGaussianBlurRenderGroup(v2 *ApplicationResolution, memory_arena *GraphicsMemory) +link_internal void +InitGaussianBlurRenderGroup(gaussian_render_group *Result, v2 *ApplicationResolution, memory_arena *GraphicsMemory) { - gaussian_render_group Result = {}; - - Result.Shader = LoadShaders(CSz(STDLIB_SHADER_PATH "Passthrough.vertexshader"), CSz(BONSAI_SHADER_PATH "Gaussian.fragmentshader")); + Ensure(CompileShaderPair(&Result->Shader, CSz(STDLIB_SHADER_PATH "Passthrough.vertexshader"), CSz(BONSAI_SHADER_PATH "Gaussian.fragmentshader"))); { - shader_uniform **Current = &Result.Shader.FirstUniform; - - *Current = GetUniform(GraphicsMemory, &Result.Shader, ApplicationResolution, "ApplicationResolution"); - Current = &(*Current)->Next; + Result->Shader.Uniforms = ShaderUniformBuffer(1, GraphicsMemory); + InitShaderUniform(&Result->Shader, 0, ApplicationResolution, "ApplicationResolution"); } - Result.FBOs[0] = GenFramebuffer(); - Result.FBOs[1] = GenFramebuffer(); + Result->FBOs[0] = GenFramebuffer(); + Result->FBOs[1] = GenFramebuffer(); // TODO(Jesse)(make_texture_rgba): Can we use MakeTexture_RGBA for (s32 Index = 0; Index < 2; ++Index) { - GL.BindFramebuffer(GL_FRAMEBUFFER, Result.FBOs[Index].ID); + GetGL()->BindFramebuffer(GL_FRAMEBUFFER, Result->FBOs[Index].ID); + AssertNoGlErrors; u32 Channels = 4; u32 Slices = 1; texture_storage_format StorageFormat = TextureStorageFormat_RGBA32F; - Result.Textures[Index] = GenTexture(V2i(*ApplicationResolution), CSz("GaussianBlur"), StorageFormat, Channels, Slices); - GL.TexImage2D( GL_TEXTURE_2D, 0, GL_RGBA32F, s32(ApplicationResolution->x), s32(ApplicationResolution->y), 0, GL_RGBA, GL_FLOAT, 0); + Result->Textures[Index] = GenTexture(V2i(*ApplicationResolution), CSz("GaussianBlur"), StorageFormat, Channels, Slices); + GetGL()->TexImage2D( GL_TEXTURE_2D, 0, GL_RGBA32F, s32(ApplicationResolution->x), s32(ApplicationResolution->y), 0, GL_RGBA, GL_FLOAT, 0); - FramebufferTexture(&Result.FBOs[Index], Result.Textures+Index); - SetDrawBuffers(&Result.FBOs[Index]); + AssertNoGlErrors; + + FramebufferTexture(&Result->FBOs[Index], Result->Textures+Index); + AssertNoGlErrors; + SetDrawBuffers(&Result->FBOs[Index]); + AssertNoGlErrors; Ensure(CheckAndClearFramebuffer()); } - - return Result; } g_buffer_render_group * @@ -338,105 +268,78 @@ CreateGbuffer(memory_arena *Memory) } -shader -CreateGbufferShader(graphics *Graphics, memory_arena *GraphicsMemory, v3 *MinClipP_worldspace, v3 *MaxClipP_worldspace, m4 *ViewProjection, camera *Camera, texture *ColorPaletteTexture) +link_internal b32 +CreateGbufferShader(shader *Shader, graphics *Graphics, memory_arena *GraphicsMemory, v3 *MinClipP_worldspace, v3 *MaxClipP_worldspace, m4 *ViewProjection, camera *Camera, texture *ColorPaletteTexture) { - shader Shader = LoadShaders( CSz(BONSAI_SHADER_PATH "gBuffer.vertexshader"), CSz(BONSAI_SHADER_PATH "gBuffer.fragmentshader") ); - - shader_uniform **Current = &Shader.FirstUniform; - - *Current = GetUniform(GraphicsMemory, &Shader, MinClipP_worldspace, "MinClipP_worldspace"); - Current = &(*Current)->Next; - - *Current = GetUniform(GraphicsMemory, &Shader, MaxClipP_worldspace, "MaxClipP_worldspace"); - Current = &(*Current)->Next; + b32 Result = CompileShaderPair(Shader, CSz(BONSAI_SHADER_PATH "gBuffer.vertexshader"), CSz(BONSAI_SHADER_PATH "gBuffer.fragmentshader") ); - *Current = GetUniform(GraphicsMemory, &Shader, ViewProjection, "ViewProjection"); - Current = &(*Current)->Next; + Shader->Uniforms = ShaderUniformBuffer(12, GraphicsMemory); + InitShaderUniform(Shader, 0, MinClipP_worldspace, "MinClipP_worldspace"); + InitShaderUniform(Shader, 1, MaxClipP_worldspace, "MaxClipP_worldspace"); + InitShaderUniform(Shader, 2, ViewProjection, "ViewProjection"); // @janky_model_matrix_bs - *Current = GetUniform(GraphicsMemory, &Shader, &IdentityMatrix, "ModelMatrix"); - Current = &(*Current)->Next; + InitShaderUniform(Shader, 3, &IdentityMatrix, "ModelMatrix"); + InitShaderUniform(Shader, 4, ColorPaletteTexture, "ColorPalette"); + InitShaderUniform(Shader, 5, &Camera->Frust.farClip, "FarClip"); + InitShaderUniform(Shader, 6, &Camera->Frust.nearClip, "NearClip"); + InitShaderUniform(Shader, 7, &Camera->RenderSpacePosition, "CameraToWorld"); + InitShaderUniform(Shader, 8, &Graphics->OffsetOfWorldCenterToGrid, "OffsetOfWorldCenterToGrid"); + InitShaderUniform(Shader, 9, &Graphics->Settings.MajorGridDim, "MajorGridDim"); + InitShaderUniform(Shader, 10, &Graphics->Settings.DrawMajorGrid, "DrawMajorGrid"); + InitShaderUniform(Shader, 11, &Graphics->Settings.DrawMinorGrid, "DrawMinorGrid"); - *Current = GetUniform(GraphicsMemory, &Shader, ColorPaletteTexture, "ColorPalette"); - Current = &(*Current)->Next; - - *Current = GetUniform(GraphicsMemory, &Shader, &Camera->Frust.farClip, "FarClip"); - Current = &(*Current)->Next; - - *Current = GetUniform(GraphicsMemory, &Shader, &Camera->Frust.nearClip, "NearClip"); - Current = &(*Current)->Next; - - *Current = GetUniform(GraphicsMemory, &Shader, &Camera->RenderSpacePosition, "CameraToWorld"); - Current = &(*Current)->Next; - - *Current = GetUniform(GraphicsMemory, &Shader, &Graphics->Settings.OffsetOfWorldCenterToGrid, "OffsetOfWorldCenterToGrid"); - Current = &(*Current)->Next; - - *Current = GetUniform(GraphicsMemory, &Shader, &Graphics->Settings.MajorGridDim, "MajorGridDim"); - Current = &(*Current)->Next; - - *Current = GetUniform(GraphicsMemory, &Shader, &Graphics->Settings.DrawMajorGrid, "DrawMajorGrid"); - Current = &(*Current)->Next; - - *Current = GetUniform(GraphicsMemory, &Shader, &Graphics->Settings.DrawMinorGrid, "DrawMinorGrid"); - Current = &(*Current)->Next; - - return Shader; + return Result; } -shader -MakeSsaoShader( memory_arena *GraphicsMemory, - g_buffer_textures *gTextures, - texture *SsaoNoiseTexture, - v3 *SsaoNoiseTile, - m4 *InverseViewMatrix, - m4 *InverseProjectionMatrix, - m4 *ViewProjection ) +link_internal b32 +MakeSsaoShader( shader *Shader, + memory_arena *GraphicsMemory, + g_buffer_textures *gTextures, + texture *SsaoNoiseTexture, + v3 *SsaoNoiseTile, + m4 *InverseViewMatrix, + m4 *InverseProjectionMatrix, + m4 *ViewProjection ) { - shader Shader = LoadShaders( CSz(STDLIB_SHADER_PATH "Passthrough.vertexshader"), CSz(BONSAI_SHADER_PATH "Ao.fragmentshader") ); - - shader_uniform **Current = &Shader.FirstUniform; - - /* *Current = GetUniform(GraphicsMemory, &Shader, &gTextures->Color, "gColor"); */ - /* Current = &(*Current)->Next; */ - - /* *Current = GetUniform(GraphicsMemory, &Shader, &gTextures->Position, "gPosition"); */ - /* Current = &(*Current)->Next; */ - - *Current = GetUniform(GraphicsMemory, &Shader, &gTextures->Normal, "gNormal"); - Current = &(*Current)->Next; + b32 Result = CompileShaderPair(Shader, CSz(STDLIB_SHADER_PATH "Passthrough.vertexshader"), CSz(BONSAI_SHADER_PATH "Ao.fragmentshader") ); - *Current = GetUniform(GraphicsMemory, &Shader, &gTextures->Depth, "gDepth"); - Current = &(*Current)->Next; - - *Current = GetUniform(GraphicsMemory, &Shader, SsaoNoiseTexture, "SsaoNoiseTexture"); - Current = &(*Current)->Next; - - *Current = GetUniform(GraphicsMemory, &Shader, SsaoNoiseTile, "SsaoNoiseTile"); - Current = &(*Current)->Next; + if (Result) + { + Shader->Uniforms = ShaderUniformBuffer(7, GraphicsMemory); - *Current = GetUniform(GraphicsMemory, &Shader, InverseViewMatrix, "InverseViewMatrix"); - Current = &(*Current)->Next; + /* *Current = GetUniform(GraphicsMemory, &Shader, &gTextures->Color, "gColor"); */ + /* Current = &(*Current)->Next; */ - *Current = GetUniform(GraphicsMemory, &Shader, InverseProjectionMatrix, "InverseProjectionMatrix"); - Current = &(*Current)->Next; + /* *Current = GetUniform(GraphicsMemory, &Shader, &gTextures->Position, "gPosition"); */ + /* Current = &(*Current)->Next; */ - *Current = GetUniform(GraphicsMemory, &Shader, ViewProjection, "ViewProjection"); - Current = &(*Current)->Next; + InitShaderUniform(Shader, 0, &gTextures->Normal, "gNormal"); + InitShaderUniform(Shader, 1, &gTextures->Depth, "gDepth"); + InitShaderUniform(Shader, 2, SsaoNoiseTexture, "SsaoNoiseTexture"); + InitShaderUniform(Shader, 3, SsaoNoiseTile, "SsaoNoiseTile"); + InitShaderUniform(Shader, 4, InverseViewMatrix, "InverseViewMatrix"); + InitShaderUniform(Shader, 5, InverseProjectionMatrix, "InverseProjectionMatrix"); + InitShaderUniform(Shader, 6, ViewProjection, "ViewProjection"); + } AssertNoGlErrors; - return Shader; + return Result; } link_internal bool InitAoRenderGroup(v2i ApplicationResolution, ao_render_group *AoGroup) { - GL.BindFramebuffer(GL_FRAMEBUFFER, AoGroup->FBO.ID); + GetGL()->BindFramebuffer(GL_FRAMEBUFFER, AoGroup->FBO.ID); b32 IsDepthTexture = False; - AoGroup->Texture = MakeTexture_SingleChannel( ApplicationResolution/2, CSz("AoTexture"), IsDepthTexture, TextureStorageFormat_R16F); + AoGroup->Texture = MakeTexture_SingleChannel( + ApplicationResolution/2, + 0, + CSz("AoTexture"), + IsDepthTexture, + TextureStorageFormat_R16F ); FramebufferTexture(&AoGroup->FBO, &AoGroup->Texture); SetDrawBuffers(&AoGroup->FBO); @@ -453,9 +356,9 @@ InitAoRenderGroup(v2i ApplicationResolution, ao_render_group *AoGroup) bool InitGbufferRenderGroup(v2i ApplicationResolution, g_buffer_render_group *gBuffer) { - GL.GenQueries(1, &gBuffer->GlTimerObject); + GetGL()->GenQueries(1, &gBuffer->GlTimerObject); - GL.BindFramebuffer(GL_FRAMEBUFFER, gBuffer->FBO.ID); + GetGL()->BindFramebuffer(GL_FRAMEBUFFER, gBuffer->FBO.ID); gBuffer->Textures.Color = MakeTexture_RGBA(ApplicationResolution, (v4*)0, CSz("gBufferColor"), 1, TextureStorageFormat_RGBA16F); gBuffer->Textures.Normal = MakeTexture_RGB( ApplicationResolution, (v3*)0, CSz("gBufferNormal"), 1, TextureStorageFormat_RGBA16F); @@ -476,62 +379,49 @@ InitGbufferRenderGroup(v2i ApplicationResolution, g_buffer_render_group *gBuffer } link_internal void -InitRenderToTextureGroup(render_entity_to_texture_group *Group, texture *ColorPalette, memory_arena *Memory) +InitRenderToTextureGroup(render_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, DataType_v3, (u32)Megabytes(1)); + AllocateGpuBuffer(&Group->GeoBuffer, DataType_v3, (u32)Megabytes(1)); Group->FBO = GenFramebuffer(); - GL.BindFramebuffer(GL_FRAMEBUFFER, Group->FBO.ID); + GetGL()->BindFramebuffer(GL_FRAMEBUFFER, Group->FBO.ID); // TODO(Jesse): Should we not hard-code the depth texture size here? texture DepthTexture = MakeDepthTexture( V2i(1024), CSz("RenderToTexture Depth")); FramebufferDepthTexture(&DepthTexture); - Group->Shader = MakeRenderToTextureShader(Memory, &Group->ViewProjection, ColorPalette); + Ensure( MakeRenderToTextureShader(&Group->Shader, Memory, &Group->ViewProjection, ColorPalette) ); Ensure(CheckAndClearFramebuffer()); } -link_internal shader -MakeTransparencyShader(v2 *ApplicationResolution, b32 *BravoilMyersOIT, b32 *BravoilMcGuireOIT, m4 *ViewProjection, texture *gBufferDepthTexture, texture *ColorPaletteTexture, memory_arena *Memory) +link_internal b32 +MakeTransparencyShader(shader *Shader, v2 *ApplicationResolution, b32 *BravoilMyersOIT, b32 *BravoilMcGuireOIT, m4 *ViewProjection, texture *gBufferDepthTexture, texture *ColorPaletteTexture, memory_arena *Memory) { - shader Shader = LoadShaders( CSz(BONSAI_SHADER_PATH "gBuffer.vertexshader"), CSz(BONSAI_SHADER_PATH "3DTransparency.fragmentshader") ); - - shader_uniform **Current = &Shader.FirstUniform; + b32 Result = CompileShaderPair(Shader, CSz(BONSAI_SHADER_PATH "gBuffer.vertexshader"), CSz(BONSAI_SHADER_PATH "3DTransparency.fragmentshader") ); - *Current = GetUniform(Memory, &Shader, ViewProjection, "ViewProjection"); - Current = &(*Current)->Next; + Shader->Uniforms = ShaderUniformBuffer(7, Memory); + InitShaderUniform(Shader, 0, ViewProjection, "ViewProjection"); // @janky_model_matrix_bs - *Current = GetUniform(Memory, &Shader, &IdentityMatrix, "ModelMatrix"); - Current = &(*Current)->Next; - - *Current = GetUniform(Memory, &Shader, gBufferDepthTexture, "gBufferDepthTexture"); - Current = &(*Current)->Next; - - *Current = GetUniform(Memory, &Shader, BravoilMyersOIT, "BravoilMyersOIT"); - Current = &(*Current)->Next; - - *Current = GetUniform(Memory, &Shader, BravoilMcGuireOIT, "BravoilMcGuireOIT"); - Current = &(*Current)->Next; + InitShaderUniform(Shader, 1, &IdentityMatrix, "ModelMatrix"); + InitShaderUniform(Shader, 2, gBufferDepthTexture, "gBufferDepthTexture"); + InitShaderUniform(Shader, 3, BravoilMyersOIT, "BravoilMyersOIT"); + InitShaderUniform(Shader, 4, BravoilMcGuireOIT, "BravoilMcGuireOIT"); + InitShaderUniform(Shader, 5, ApplicationResolution, "ApplicationResolution"); + InitShaderUniform(Shader, 6, ColorPaletteTexture, "ColorPalette"); - *Current = GetUniform(Memory, &Shader, ApplicationResolution, "ApplicationResolution"); - Current = &(*Current)->Next; - - *Current = GetUniform(Memory, &Shader, ColorPaletteTexture, "ColorPalette"); - Current = &(*Current)->Next; - - return Shader; + return Result; } 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, DataType_v3, (u32)Megabytes(1)); + AllocateGpuBuffer(&Group->GpuBuffer, DataType_v3, (u32)Megabytes(1)); Group->FBO = GenFramebuffer(); - GL.BindFramebuffer(GL_FRAMEBUFFER, Group->FBO.ID); + GetGL()->BindFramebuffer(GL_FRAMEBUFFER, Group->FBO.ID); // TODO(Jesse)(make_texture_rgba) : ? { @@ -539,7 +429,7 @@ InitTransparencyRenderGroup(render_settings *Settings, transparency_render_group u32 Slices = 1; texture_storage_format StorageFormat = TextureStorageFormat_RGBA16F; Group->AccumTex = GenTexture(TextureSize, CSz("Transparency Accum"), StorageFormat, Channels, Slices); - GL.TexImage2D( GL_TEXTURE_2D, 0, StorageFormat, TextureSize.x, TextureSize.y, 0, GL_RGBA, GL_FLOAT, 0); + GetGL()->TexImage2D( GL_TEXTURE_2D, 0, StorageFormat, TextureSize.x, TextureSize.y, 0, GL_RGBA, GL_FLOAT, 0); } { @@ -547,7 +437,7 @@ InitTransparencyRenderGroup(render_settings *Settings, transparency_render_group u32 Slices = 1; texture_storage_format StorageFormat = TextureStorageFormat_RG16F; Group->RevealTex = GenTexture(TextureSize, CSz("Transparency Reveal"), StorageFormat, Channels, Slices); - GL.TexImage2D( GL_TEXTURE_2D, 0, StorageFormat, TextureSize.x, TextureSize.y, 0, GL_RG, GL_FLOAT, 0); + GetGL()->TexImage2D( GL_TEXTURE_2D, 0, StorageFormat, TextureSize.x, TextureSize.y, 0, GL_RG, GL_FLOAT, 0); } // NOTE(Jesse): These have to be bound in this order because they're cleared @@ -556,72 +446,109 @@ InitTransparencyRenderGroup(render_settings *Settings, transparency_render_group FramebufferTexture(&Group->FBO, &Group->RevealTex); SetDrawBuffers(&Group->FBO); - Group->Shader = MakeTransparencyShader(&Settings->ApplicationResolution, &Settings->BravoilMyersOIT, &Settings->BravoilMcGuireOIT, ViewProjection, gBufferDepthTexture, ColorPaletteTexture, Memory); + MakeTransparencyShader(&Group->Shader, &Settings->ApplicationResolution, &Settings->BravoilMyersOIT, &Settings->BravoilMcGuireOIT, ViewProjection, gBufferDepthTexture, ColorPaletteTexture, Memory); Ensure( CheckAndClearFramebuffer() ); } -link_internal b32 -GraphicsInit(graphics *Result, engine_settings *EngineSettings, memory_arena *GraphicsMemory) + +#define RUNTIME_SETTINGS__GRAPHICS_SETTINGS_PATH "runtime_settings/graphics_settings.bin" + +link_internal void +DefaultRenderSettings(render_settings *Settings, engine_settings *EngineSettings, r32 GameCameraFOV) { - Init_Global_QuadVertexBuffer(); + Settings->ToneMappingType = ToneMappingType_Exposure; - Result->Memory = GraphicsMemory; + Settings->UseSsao = True; - Result->Settings.ToneMappingType = ToneMappingType_Exposure; + Settings->BravoilMyersOIT = True; + Settings->BravoilMcGuireOIT = True; - Result->Settings.UseSsao = True; + /* Settings->UseShadowMapping = True; */ + Settings->UseLightingBloom = True; - Result->Settings.BravoilMyersOIT = True; - Result->Settings.BravoilMcGuireOIT = True; + /* Settings->DrawMajorGrid = True; */ + /* Settings->DrawMinorGrid = True; */ + Settings->MajorGridDim = 16.f; - Result->Settings.UseShadowMapping = True; - Result->Settings.UseLightingBloom = True; + Settings->ApplicationResolution = V2(GetApplicationResolution(EngineSettings)); + Settings->ShadowMapResolution = V2(GetShadowMapResolution(EngineSettings)); + Settings->LuminanceMapResolution = V2(GetLuminanceMapResolution(EngineSettings)); - Result->Settings.DrawMajorGrid = True; - Result->Settings.DrawMinorGrid = True; - Result->Settings.MajorGridDim = 8.f; + Settings->iApplicationResolution = GetApplicationResolution(EngineSettings); + Settings->iShadowMapResolution = GetShadowMapResolution(EngineSettings); + Settings->iLuminanceMapResolution = GetLuminanceMapResolution(EngineSettings); - Result->Exposure = 1.5f; + Settings->GameCameraFOV = GameCameraFOV; - Result->Settings.ApplicationResolution = V2(GetApplicationResolution(EngineSettings)); - Result->Settings.ShadowMapResolution = V2(GetShadowMapResolution(EngineSettings)); - Result->Settings.LuminanceMapResolution = V2(GetLuminanceMapResolution(EngineSettings)); + { + lighting_settings *Lighting = &Settings->Lighting; - Result->Settings.iApplicationResolution = GetApplicationResolution(EngineSettings); - Result->Settings.iShadowMapResolution = GetShadowMapResolution(EngineSettings); - Result->Settings.iLuminanceMapResolution = GetLuminanceMapResolution(EngineSettings); + Lighting->tDay = -1.5f; - Result->FogPower = 2.f; + Lighting->SunP = V3(-1.f, -1.f, 0.35f); - Result->FogColor = V3(0.01f, 0.04f, 0.25f); - Result->SkyColor = V3(0.001f, 0.001f, 0.35f); + Lighting->DawnHSV = V3(0.11f, 0.48f, 0.87f); + Lighting->SunHSV = V3(0.00f, 0.00f, 0.00f); + Lighting->DuskHSV = V3(0.74f, 0.35f, 0.38f); + Lighting->MoonHSV = V3(0.63f, 0.15f, 0.22f); + Lighting->DawnIntensity = 0.78f; + Lighting->SunIntensity = 1.10f; + Lighting->DuskIntensity = 0.66f; + Lighting->MoonIntensity = 0.18f; + } +} + +link_internal b32 +GraphicsInit(graphics *Result, engine_settings *EngineSettings, memory_arena *GraphicsMemory) +{ + Assert(FutexIsSignaled(&Result->Initialized) == False); + + + shadow_render_group *SG = Allocate(shadow_render_group, GraphicsMemory, 1); { - lighting_settings *Lighting = &Result->Settings.Lighting; + v2i SR = V2i(1024*2); + if (!InitializeShadowRenderGroup(Result, SG, SR)) + { + SoftError("Initializing Shadow Buffer");// return False; + } + } - Lighting->tDay = 0.75f; - Lighting->SunP = V3(-1.f, -1.f, 0.35f); + Init_Global_QuadVertexBuffer(); - Lighting->DawnColor = V3(0.37f, 0.11f, 0.10f); - Lighting->SunColor = V3(0.17f, 0.13f, 0.17f); - Lighting->DuskColor = V3(0.13f, 0.12f, 0.14f); - Lighting->MoonColor = V3(0.04f, 0.07f, 0.18f); + Result->Memory = GraphicsMemory; + + StandardCamera(&Result->GameCamera, 100000.f, 500.f); + StandardCamera(&Result->DebugCamera, 100000.f, 500.f); + Result->Camera = &Result->GameCamera; - Lighting->SunIntensity = 1.10f; - Lighting->MoonIntensity = 0.10f; - Lighting->DawnIntensity = 0.70f; - Lighting->DuskIntensity = 0.50f; + if (FileExists(RUNTIME_SETTINGS__GRAPHICS_SETTINGS_PATH)) + { + u8_cursor Bytes = BeginDeserialization(CSz(RUNTIME_SETTINGS__GRAPHICS_SETTINGS_PATH), GetTranArena()); + if (Deserialize(&Bytes, &Result->Settings, GetTranArena()) == False) + { + Result->Settings = {}; + Remove(CSz(RUNTIME_SETTINGS__GRAPHICS_SETTINGS_PATH)); + DefaultRenderSettings(&Result->Settings, EngineSettings, Result->Camera->Frust.FOV); + } + FinalizeDeserialization(&Bytes); + } + else + { + DefaultRenderSettings(&Result->Settings, EngineSettings, Result->Camera->Frust.FOV); } - StandardCamera(&Result->GameCamera, 10000.f, 500.f); - StandardCamera(&Result->DebugCamera, 10000.f, 500.f); + Result->PrevSettings = Result->Settings; - Result->Camera = &Result->GameCamera; + Result->Exposure = 1.5f; - AllocateGpuElementBuffer(Result->GpuBuffers + 0, DataType_v3, (u32)Megabytes(1)); - AllocateGpuElementBuffer(Result->GpuBuffers + 1, DataType_v3, (u32)Megabytes(1)); + + Result->SkyColor = V3(0.001f, 0.001f, 0.35f); + + AllocateGpuBuffer(&Result->ImmediateGeometry, DataType_v3, (u32)Megabytes(1)); + /* AllocateGpuBuffer(Result->GpuBuffers + 1, DataType_v3, (u32)Megabytes(1)); */ g_buffer_render_group *gBuffer = CreateGbuffer(GraphicsMemory); if (!InitGbufferRenderGroup(Result->Settings.iApplicationResolution, gBuffer)) @@ -629,19 +556,19 @@ GraphicsInit(graphics *Result, engine_settings *EngineSettings, memory_arena *Gr Error("Initializing g_buffer_render_group"); return False; } - shadow_render_group *SG = Allocate(shadow_render_group, GraphicsMemory, 1); - if (!InitializeShadowRenderGroup(Result, SG, Result->Settings.iShadowMapResolution)) - { - SoftError("Initializing Shadow Buffer");// return False; - } - ao_render_group *AoGroup = CreateAoRenderGroup(GraphicsMemory); if (!InitAoRenderGroup(Result->Settings.iApplicationResolution, AoGroup)) { Error("Initializing ao_render_group"); return False; } - InitTransparencyRenderGroup(&Result->Settings, &Result->Transparency, Result->Settings.iApplicationResolution, &gBuffer->ViewProjection, &gBuffer->Textures.Depth, &Result->ColorPaletteTexture, GraphicsMemory); + InitTransparencyRenderGroup( &Result->Settings, + &Result->Transparency, + Result->Settings.iApplicationResolution, + &gBuffer->ViewProjection, + &gBuffer->Textures.Depth, + &Result->ColorPaletteTexture, + GraphicsMemory); // Initialize the lighting group { @@ -657,38 +584,36 @@ GraphicsInit(graphics *Result, engine_settings *EngineSettings, memory_arena *Gr Lights->IndexToUV = 1.0f / MAX_LIGHTS; - Lighting->Shader = - MakeLightingShader( GraphicsMemory, + MakeLightingShader( Lighting, - &Result->Settings.ApplicationResolution, - &gBuffer->Textures, + &Result->Settings.ApplicationResolution, + &gBuffer->Textures, - &Result->Settings.ShadowMapResolution, - &SG->ShadowMap, + &Result->Settings.ShadowMapResolution, + &SG->ShadowMap, - &AoGroup->Texture, + &AoGroup->Texture, - &Result->Transparency.AccumTex, - &Result->Transparency.RevealTex, - &Result->Settings.BravoilMyersOIT, - &Result->Settings.BravoilMcGuireOIT, + &Result->Transparency.AccumTex, + &Result->Transparency.RevealTex, + &Result->Settings.BravoilMyersOIT, + &Result->Settings.BravoilMcGuireOIT, - &gBuffer->InverseViewMatrix, - &gBuffer->InverseProjectionMatrix, - &SG->Shader.MVP, + &gBuffer->InverseViewMatrix, + &gBuffer->InverseProjectionMatrix, + &SG->Shader.ViewProjection, - &Lighting->Lights, + &Lighting->Lights, Result->Camera, - &Result->Settings.Lighting.SunP, - &Result->Settings.Lighting.CurrentSunColor, + &Result->Settings.Lighting.SunP, + &Result->Settings.Lighting.CurrentSunColor, - &Result->FogColor, - &Result->FogPower, + &Result->Settings.Lighting.FogColor, + &Result->Settings.Lighting.FogPower, - &Result->Settings.UseSsao, - &Result->Settings.UseShadowMapping, - &Result->Settings.UseLightingBloom - ); + &Result->Settings.UseSsao, + &Result->Settings.UseShadowMapping, + &Result->Settings.UseLightingBloom ); // Luminance FBO { @@ -696,7 +621,7 @@ GraphicsInit(graphics *Result, engine_settings *EngineSettings, memory_arena *Gr Lighting->FBO = GenFramebuffer(); - GL.BindFramebuffer(GL_FRAMEBUFFER, Lighting->FBO.ID); + GetGL()->BindFramebuffer(GL_FRAMEBUFFER, Lighting->FBO.ID); FramebufferTexture(&Lighting->FBO, &Lighting->LuminanceTex); /* FramebufferTexture(&Lighting->FBO, &Lighting->Bloom.Tex); */ SetDrawBuffers(&Lighting->FBO); @@ -704,7 +629,7 @@ GraphicsInit(graphics *Result, engine_settings *EngineSettings, memory_arena *Gr } - InitBloomRenderGroup(&Lighting->Bloom, &Result->Settings, GraphicsMemory); + InitBloomRenderGroup(&Result->Bloom, &Result->Settings, GraphicsMemory); } engine_resources *Resources = GetEngineResources(); @@ -712,7 +637,7 @@ GraphicsInit(graphics *Result, engine_settings *EngineSettings, memory_arena *Gr // TODO(Jesse): Move RTTGroup onto graphics? InitRenderToTextureGroup(&Resources->RTTGroup, &Result->ColorPaletteTexture, GraphicsMemory); - Result->Gaussian = MakeGaussianBlurRenderGroup(&Result->Settings.ApplicationResolution, GraphicsMemory); + InitGaussianBlurRenderGroup(&Result->Gaussian, &Result->Settings.ApplicationResolution, GraphicsMemory); AoGroup->NoiseTexture = AllocateAndInitSsaoNoise(Result->Settings.iApplicationResolution, AoGroup, GraphicsMemory); @@ -723,42 +648,167 @@ GraphicsInit(graphics *Result, engine_settings *EngineSettings, memory_arena *Gr Push(&Result->ColorPalette, MAGICAVOXEL_DEFAULT_PALETTE[ColorIndex]/255.f); } - gBuffer->gBufferShader = - CreateGbufferShader(Result, GraphicsMemory, &Result->MinClipP_worldspace, &Result->MaxClipP_worldspace, &gBuffer->ViewProjection, Result->Camera, &Result->ColorPaletteTexture); - AoGroup->Shader = MakeSsaoShader( GraphicsMemory, - &gBuffer->Textures, - &AoGroup->NoiseTexture, - &AoGroup->NoiseTile, - &gBuffer->InverseViewMatrix, - &gBuffer->InverseProjectionMatrix, - &gBuffer->ViewProjection ); + Ensure( + CreateGbufferShader(&gBuffer->gBufferShader, + Result, + GraphicsMemory, + &Result->MinClipP_worldspace, + &Result->MaxClipP_worldspace, + &gBuffer->ViewProjection, + Result->Camera, + &Result->ColorPaletteTexture)); + + MakeSsaoShader(&AoGroup->Shader, + GraphicsMemory, + &gBuffer->Textures, + &AoGroup->NoiseTexture, + &AoGroup->NoiseTile, + &gBuffer->InverseViewMatrix, + &gBuffer->InverseProjectionMatrix, + &gBuffer->ViewProjection ); AoGroup->SsaoKernelUniform = GetShaderUniform(&AoGroup->Shader, "SsaoKernel"); // Initialize the composite group { - Result->CompositeGroup.Shader = MakeCompositeShader( GraphicsMemory, - &Result->Settings.ApplicationResolution, - &gBuffer->Textures, - &SG->ShadowMap, - &AoGroup->Texture, - &Result->Lighting.LuminanceTex, - &Result->Lighting.Bloom.Tex, - &Result->Transparency.AccumTex, - &Result->Transparency.RevealTex, - &SG->Shader.MVP, - Result->Camera, - &Result->Exposure, - &Result->Settings.UseLightingBloom, - &Result->Settings.BravoilMyersOIT, - &Result->Settings.BravoilMcGuireOIT, - &Result->Settings.ToneMappingType - ); + Ensure(MakeCompositeShader(&Result->CompositeGroup.Shader, + GraphicsMemory, + &Result->Settings.ApplicationResolution, + &gBuffer->Textures, + &SG->ShadowMap, + &AoGroup->Texture, + &Result->Lighting.LuminanceTex, + &Result->Bloom.Tex, + &Result->Transparency.AccumTex, + &Result->Transparency.RevealTex, + &SG->Shader.ViewProjection, + Result->Camera, + &Result->Exposure, + &Result->Settings.UseLightingBloom, + &Result->Settings.BravoilMyersOIT, + &Result->Settings.BravoilMcGuireOIT, + &Result->Settings.ToneMappingType + )); + } + + + // + // World Edit RC + // + world_edit_render_context *WorldEditRC = &Result->WorldEditRC; + + v3 ChunkDim = V3(66, 66, 66); + v2i TextureDim = V2i(u32(ChunkDim.x), u32(ChunkDim.y*ChunkDim.z)); + + { + { + terrain_shaping_render_context *TerrainShapingRC = &Result->TerrainShapingRC; + InitializeWorldEditRenderContext(WorldEditRC, &TerrainShapingRC->ChunkDim, &TerrainShapingRC->WorldspaceChunkBasis, &TerrainShapingRC->ChunkResolution, {}); + } + + RangeIterator(Index, 3) + { + WorldEditRC->PingPongFBOs[Index] = GenFramebuffer(); + GetGL()->BindFramebuffer(GL_FRAMEBUFFER, WorldEditRC->PingPongFBOs[Index].ID); + + WorldEditRC->PingPongTextures[Index] = MakeTexture_RGBA(TextureDim, Cast(v4*, 0), CSz("PingPongTexture"), 1, TextureStorageFormat_RGBA32F); + + FramebufferTexture(&WorldEditRC->PingPongFBOs[Index], &WorldEditRC->PingPongTextures[Index]); + SetDrawBuffers(&WorldEditRC->PingPongFBOs[Index]); + + Ensure(CheckAndClearFramebuffer()); + } + } + + // + // Terrain Shaping + // + + { + terrain_shaping_render_context *RC = &Result->TerrainShapingRC; + InitializeTerrainShapingRenderContext(RC, ChunkDim, {}, {}, RC->ReshapeFunc); + + RC->DestFBO = GenFramebuffer(); + RC->DestTex = MakeTexture_RGBA(V2i(68, 68*68), Cast(v4*, 0), CSz("TerrainShaping"), 1, TextureStorageFormat_RGBA32F); + + GetGL()->BindFramebuffer(GL_FRAMEBUFFER, RC->DestFBO.ID); + + FramebufferTexture(&RC->DestFBO, &RC->DestTex); + SetDrawBuffers(&RC->DestFBO); + + Ensure(CheckAndClearFramebuffer()); + } + + // + // Terrain Derivs + // + + { + terrain_derivs_render_context *RC = &Result->TerrainDerivsRC; + InitializeTerrainDerivsRenderContext(RC, {}); + + RC->DestFBO = GenFramebuffer(); + RC->DestTex = MakeTexture_RGB(TextureDim, Cast(v3*, 0), CSz("TerrainDerivs"), 1, TextureStorageFormat_RGB32F); + + GetGL()->BindFramebuffer(GL_FRAMEBUFFER, RC->DestFBO.ID); + + FramebufferTexture(&RC->DestFBO, &RC->DestTex); + SetDrawBuffers(&RC->DestFBO); + + Ensure(CheckAndClearFramebuffer()); + } + + // + // Terrain Decoration + // + + { + terrain_decoration_render_context *TerrainDecorationRC = &Result->TerrainDecorationRC; + InitializeTerrainDecorationRenderContext(TerrainDecorationRC, &Result->TerrainDerivsRC.DestTex, ChunkDim, {}, {}); + + TerrainDecorationRC->DestFBO = &WorldEditRC->PingPongFBOs[0]; + TerrainDecorationRC->DestTex = &WorldEditRC->PingPongTextures[0]; + + GetGL()->BindFramebuffer(GL_FRAMEBUFFER, TerrainDecorationRC->DestFBO->ID); + + FramebufferTexture(TerrainDecorationRC->DestFBO, TerrainDecorationRC->DestTex); + SetDrawBuffers(TerrainDecorationRC->DestFBO); + + Ensure(CheckAndClearFramebuffer()); + } + + + + + // + // Terrain Finalize RC + // + { + terrain_finalize_render_context *TerrainFinalizeRC = &Result->TerrainFinalizeRC; + Result->TerrainFinalizeRC.FBO = GenFramebuffer(); + GetGL()->BindFramebuffer(GL_FRAMEBUFFER, Result->TerrainFinalizeRC.FBO.ID); + + { + u32 Channels = 1; + u32 Slices = 1; + // @shared_terrain_texture + TerrainFinalizeRC->DestTex = GenTexture(TextureDim, CSz("TerrainFinalizeTexture"), TextureStorageFormat_R32UI, Channels, Slices, False); + GetGL()->TexImage2D(GL_TEXTURE_2D, 0, GL_R32UI, TextureDim.x, TextureDim.y, 0, GL_RED_INTEGER, GL_UNSIGNED_INT, 0); + AssertNoGlErrors; + GetGL()->BindTexture(GL_TEXTURE_2D, 0); + } + FramebufferTexture(&Result->TerrainFinalizeRC.FBO, &TerrainFinalizeRC->DestTex); + SetDrawBuffers(&Result->TerrainFinalizeRC.FBO); + + + /* InitializeTerrainFinalizeRenderContext(TerrainFinalizeRC, &Result->TerrainShapingRC.DestTex); */ + InitializeTerrainFinalizeRenderContext(TerrainFinalizeRC, 0); + Ensure(CheckAndClearFramebuffer()); } - GL.Enable(GL_CULL_FACE); - GL.CullFace(GL_BACK); + GetGL()->Enable(GL_CULL_FACE); + GetGL()->CullFace(GL_BACK); AssertNoGlErrors; diff --git a/src/engine/render/shadow_map.cpp b/src/engine/render/shadow_map.cpp new file mode 100644 index 000000000..e2fbc58c2 --- /dev/null +++ b/src/engine/render/shadow_map.cpp @@ -0,0 +1,34 @@ +link_internal b32 +InitializeShadowRenderGroup(graphics *Graphics, shadow_render_group *SG, v2i ShadowMapResolution) +{ + // The framebuffer, which regroups 0, 1, or more textures, and 0 or 1 depth buffer. + GetGL()->GenFramebuffers(1, &SG->FramebufferName); + Assert(SG->FramebufferName); + GetGL()->BindFramebuffer(GL_FRAMEBUFFER, SG->FramebufferName); + + + SG->ShadowMap = MakeDepthTexture(ShadowMapResolution, CSz("ShadowDepth")); + FramebufferDepthTexture(&SG->ShadowMap); + + // TODO(Jesse, id: 119, tags: opengl, es2): Not present on ES2 .. should we use them? + // No color output in the bound framebuffer, only depth. + /* glDrawBuffer(GL_NONE); */ + /* glReadBuffer(GL_NONE); */ + + /* SG->DepthShader = LoadShaders( CSz(BONSAI_SHADER_PATH "DepthRTT.vertexshader"), CSz(BONSAI_SHADER_PATH "DepthRTT.fragmentshader") ); */ + /* SG->MVP_ID = GetShaderUniform(&SG->DepthShader, "depthMVP"); */ + + AssertNoGlErrors; + + + if( GetGL()->CheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) + return false; + + GetGL()->Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + GetGL()->BindFramebuffer(GL_FRAMEBUFFER, 0); + + Ensure(InitializeShadowMapShader( &SG->Shader , IdentityMatrix, IdentityMatrix, &Graphics->MinClipP_worldspace, &Graphics->MaxClipP_worldspace )); + + AssertNoGlErrors; + return true; +} diff --git a/src/engine/render/shadow_map.h b/src/engine/render/shadow_map.h index 1e24f7da7..5257d24b1 100644 --- a/src/engine/render/shadow_map.h +++ b/src/engine/render/shadow_map.h @@ -1,27 +1,26 @@ struct shadow_map_shader -poof( @vert_source_file("shaders/DepthRTT.vertexshader") +poof( @render_pass + @do_editor_ui + @vert_source_file("shaders/DepthRTT.vertexshader") @frag_source_file("shaders/DepthRTT.fragmentshader") ) { shader Program; shader_uniform Uniforms[4]; - // TODO(Jesse)(rename): Should be ViewProjection - m4 MVP; poof(@uniform) - // NOTE(Jesse): This never gets read from; it's strictly a placeholder/hack // to tell shader_magic there's a uniform called ModelMatrix, which gets set // at the time the model gets drawn. // // @janky_model_matrix_bs - m4 ModelMatrix; poof(@uniform) + m4 ModelMatrix; poof(@uniform) + m4 ViewProjection; poof(@uniform) v3 *MinClipP_worldspace; poof(@uniform) v3 *MaxClipP_worldspace; poof(@uniform) }; -poof(shader_magic(shadow_map_shader)) -#include struct shadow_render_group +poof(@do_editor_ui) { u32 FramebufferName; @@ -29,35 +28,3 @@ struct shadow_render_group shadow_map_shader Shader; }; -link_internal b32 -InitializeShadowRenderGroup(graphics *Graphics, shadow_render_group *SG, v2i ShadowMapResolution) -{ - // The framebuffer, which regroups 0, 1, or more textures, and 0 or 1 depth buffer. - GL.GenFramebuffers(1, &SG->FramebufferName); - Assert(SG->FramebufferName); - GL.BindFramebuffer(GL_FRAMEBUFFER, SG->FramebufferName); - - - SG->ShadowMap = MakeDepthTexture(ShadowMapResolution, CSz("ShadowDepth")); - FramebufferDepthTexture(&SG->ShadowMap); - - // TODO(Jesse, id: 119, tags: opengl, es2): Not present on ES2 .. should we use them? - // No color output in the bound framebuffer, only depth. - /* glDrawBuffer(GL_NONE); */ - /* glReadBuffer(GL_NONE); */ - - /* SG->DepthShader = LoadShaders( CSz(BONSAI_SHADER_PATH "DepthRTT.vertexshader"), CSz(BONSAI_SHADER_PATH "DepthRTT.fragmentshader") ); */ - /* SG->MVP_ID = GetShaderUniform(&SG->DepthShader, "depthMVP"); */ - - AssertNoGlErrors; - - if(GL.CheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) - return false; - - GL.Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - GL.BindFramebuffer(GL_FRAMEBUFFER, 0); - - InitializeShadowMapShader( &SG->Shader , IdentityMatrix, IdentityMatrix, &Graphics->MinClipP_worldspace, &Graphics->MaxClipP_worldspace ); - - return true; -} diff --git a/src/engine/render_command.cpp b/src/engine/render_command.cpp index f7af231bd..ac74a23dd 100644 --- a/src/engine/render_command.cpp +++ b/src/engine/render_command.cpp @@ -28,21 +28,20 @@ poof(push_render_command(work_queue_entry__bonsai_render_command)) #include link_internal void -PushDeallocateBuffersCommand(work_queue *RenderQueue, gpu_element_buffer_handles *Handles) +DeallocateHandles(work_queue *RenderQueue, gpu_element_buffer_handles *Handles) { - // @vertex_handle_primal - if (Handles->VertexHandle) { PushBonsaiRenderCommandDeallocateBuffers(RenderQueue, &Handles->VertexHandle, 3); } + PushBonsaiRenderCommandDeallocateHandles(RenderQueue, *Handles); Clear(Handles); } -link_internal void -PushReallocateBuffersCommand(work_queue *RenderQueue, gpu_element_buffer_handles *Handles, untextured_3d_geometry_buffer *Mesh) -{ - Assert(Mesh->Type); - Assert(Mesh->At); - work_queue_entry Work = WorkQueueEntry(WorkQueueEntryBonsaiRenderCommand(BonsaiRenderCommandReallocateBuffers(Handles, Mesh))); - PushWorkQueueEntry(RenderQueue, &Work); -} +/* link_internal void */ +/* PushReallocateBuffersCommand(work_queue *RenderQueue, gpu_element_buffer_handles *Handles, untextured_3d_geometry_buffer *Mesh) */ +/* { */ +/* Assert(Mesh->Type); */ +/* Assert(Mesh->At); */ +/* work_queue_entry Work = WorkQueueEntry(WorkQueueEntryBonsaiRenderCommand(BonsaiRenderCommandReallocateBuffers(Handles, Mesh))); */ +/* PushWorkQueueEntry(RenderQueue, &Work); */ +/* } */ link_internal void PushClearAllFramebuffersCommand(work_queue *RenderQueue) @@ -75,9 +74,9 @@ PushSetupShaderCommand(work_queue *RenderQueue, bonsai_render_command_shader_id } link_internal void -PushDrawWorldChunkDrawListCommand(work_queue *RenderQueue, world_chunk_ptr_paged_list *DrawList, shader *Shader) +PushDrawWorldChunkDrawListCommand(work_queue *RenderQueue, octree_node_ptr_paged_list *DrawList, shader *Shader, camera *Camera) { - work_queue_entry Work = WorkQueueEntry(WorkQueueEntryBonsaiRenderCommand(BonsaiRenderCommandDrawWorldChunkDrawList(DrawList, Shader))); + work_queue_entry Work = WorkQueueEntry(WorkQueueEntryBonsaiRenderCommand(BonsaiRenderCommandDrawWorldChunkDrawList(DrawList, Shader, Camera))); PushWorkQueueEntry(RenderQueue, &Work); } diff --git a/src/engine/render_command.h b/src/engine/render_command.h index df3c4913d..05daa6c10 100644 --- a/src/engine/render_command.h +++ b/src/engine/render_command.h @@ -1,3 +1,10 @@ +#define INVALID_PBO_HANDLE (0xFFFFFFFF) +struct gpu_readback_buffer +{ + u32 PBO = INVALID_PBO_HANDLE; + GLsync Fence; +}; + // // Renderer commands @@ -15,16 +22,9 @@ struct bonsai_render_command_deallocate_texture s32 Count = 3; }; -struct bonsai_render_command_allocate_buffers +struct bonsai_render_command_deallocate_handles { - u32 *Buffers; - s32 Count = 3; -}; - -struct bonsai_render_command_deallocate_buffers -{ - u32 Buffers[16]; poof(@array_length(Count)) - s32 Count; + gpu_element_buffer_handles Handles; }; // NOTE(Jesse): This is kind of a fucky workaround for the following situation: @@ -42,19 +42,12 @@ struct bonsai_render_command_deallocate_world_chunk world_chunk *Chunk; }; -struct bonsai_render_command_reallocate_buffers +struct bonsai_render_command_allocate_handles { gpu_element_buffer_handles *Handles; 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_clear_all_framebuffers { u32 Ignored = 0; // NOTE(Jesse): Only here because poof only gens functions if we @@ -91,10 +84,12 @@ struct bonsai_render_command_draw_all_entities shader *Shader; }; +struct octree_node_ptr_block_array; struct bonsai_render_command_draw_world_chunk_draw_list { - world_chunk_ptr_paged_list *DrawList; + octree_node_ptr_block_array *DrawList; shader *Shader; + camera *Camera; }; // NOTE(Jesse): Temporary @@ -103,6 +98,12 @@ struct bonsai_render_command_do_stuff u32 Ignored = 0; }; +struct octree_node; +struct bonsai_render_command_initialize_noise_buffer +{ + octree_node *DestNode; +}; + struct bonsai_render_command_gl_timer_init { u32 *GlTimerObject; @@ -123,18 +124,57 @@ struct bonsai_render_command_gl_timer_read_value_and_histogram u32 GlTimerObject; }; +struct bonsai_render_command_allocate_and_map_gpu_element_buffer +{ + data_type Type; + u32 ElementCount; + + gpu_mapped_element_buffer *Dest; + + // TODO(Jesse): This is a crutch for not being able to define the next job + // remove. + // + // nopush + gen_chunk *SynChunk; + octree_node *DestNode; +}; + +struct bonsai_render_command_unmap_gpu_element_buffer +{ + gpu_element_buffer_handles *Handles; + + // TODO(Jesse): This is a crutch for not being able to define the next job + // remove. + // + // nopush + octree_node *DestNode; +}; + +struct bonsai_render_command_unmap_and_deallocate_pbo +{ + gpu_readback_buffer PBOBuf; +}; + +struct bonsai_render_command_cancel_all_noise_readback_jobs +{ + // NOTE(Jesse): The thing that generates constructors and push functions + // doesn't know about enum_only .. so we have to create a dummy struct for this. +}; + poof( d_union work_queue_entry__bonsai_render_command { + bonsai_render_command_initialize_noise_buffer + + bonsai_render_command_clear_all_framebuffers bonsai_render_command_allocate_texture bonsai_render_command_deallocate_texture - bonsai_render_command_allocate_buffers - bonsai_render_command_reallocate_buffers - bonsai_render_command_deallocate_buffers + bonsai_render_command_allocate_handles + bonsai_render_command_deallocate_handles bonsai_render_command_deallocate_world_chunk @@ -142,6 +182,10 @@ poof( bonsai_render_command_do_stuff + bonsai_render_command_allocate_and_map_gpu_element_buffer + bonsai_render_command_unmap_gpu_element_buffer + bonsai_render_command_unmap_and_deallocate_pbo + bonsai_render_command_setup_shader bonsai_render_command_teardown_shader bonsai_render_command_set_shader_uniform @@ -153,9 +197,14 @@ poof( bonsai_render_command_gl_timer_start bonsai_render_command_gl_timer_end bonsai_render_command_gl_timer_read_value_and_histogram + + bonsai_render_command_cancel_all_noise_readback_jobs } ) -#include +#include + +poof(string_and_value_tables(work_queue_entry__bonsai_render_command_type)) +#include poof(d_union_all_constructors(work_queue_entry__bonsai_render_command)) #include @@ -185,3 +234,6 @@ PushDoStuffCommand(work_queue *RenderQueue); link_internal void PushBonsaiRenderCommandAllocateTexture(work_queue *, texture *, void *); + +link_internal void +PushBonsaiRenderCommandInitializeNoiseBuffer( work_queue *, octree_node *); diff --git a/src/engine/render_loop.cpp b/src/engine/render_loop.cpp new file mode 100644 index 000000000..5c55d61ee --- /dev/null +++ b/src/engine/render_loop.cpp @@ -0,0 +1,1160 @@ +link_export void +DrainHiRenderQueue(engine_resources *Engine) +{ + /* TIMED_FUNCTION(); */ + + Assert(RENDER_THREAD_ThreadLocal_ThreadIndex == ThreadLocal_ThreadIndex); + + UNPACK_ENGINE_RESOURCES(Engine); + Assert(EntityTable); + + /* RenderInfo("DrainRenderQueue"); */ + + AssertNoGlErrors; + while (work_queue_entry *Job = PopWorkQueueEntry(HiRenderQ)) + { + /* RenderInfo("%S", ToString(Job->Type)); */ + /* TIMED_NAMED_BLOCK(RENDER_LOOP); */ + tswitch(Job) + { + 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_update_world_region: */ + case type_work_queue_entry_rebuild_mesh: + case type_work_queue_entry_finalize_noise_values: + case type_work_queue_entry_build_chunk_mesh: + case type_work_queue_entry_sim_particle_system: + case type_work_queue_entry__align_to_cache_line_helper: + { + InvalidCodePath(); + } break; + + + { tmatch(work_queue_entry_async_function_call, Job, RPC) + /* RenderInfo("%S", ToString(RPC->Type)); */ + TIMED_NAMED_BLOCK(work_queue_entry_async_function_call); + DispatchAsyncFunctionCall(RPC); + } break; + + { tmatch(work_queue_entry__bonsai_render_command, Job, RenderCommand) + /* RenderInfo("%S", ToString(RenderCommand->Type)); */ + tswitch(RenderCommand) + { + InvalidCase(type_work_queue_entry__bonsai_render_command_noop); + + { case type_bonsai_render_command_cancel_all_noise_readback_jobs: + InvalidCodePath(); + } break; + + { tmatch(bonsai_render_command_allocate_and_map_gpu_element_buffer, RenderCommand, Command) + InvalidCodePath(); + } break; + + { tmatch(bonsai_render_command_unmap_gpu_element_buffer, RenderCommand, Command) + InvalidCodePath(); + } break; + + { tmatch(bonsai_render_command_unmap_and_deallocate_pbo, RenderCommand, Command) + InvalidCodePath(); + } break; + + { tmatch(bonsai_render_command_allocate_texture, RenderCommand, Command) + InvalidCodePath(); + } break; + + { tmatch(bonsai_render_command_deallocate_texture, RenderCommand, Command) + NotImplemented; + } break; + + + { tmatch(bonsai_render_command_allocate_handles, RenderCommand, Command) + NotImplemented; + } break; + + { tmatch(bonsai_render_command_deallocate_handles, RenderCommand, Command) + NotImplemented; + } break; + + { tmatch(bonsai_render_command_deallocate_world_chunk, RenderCommand, Command) + InvalidCodePath(); + } break; + + + { tmatch(bonsai_render_command_clear_all_framebuffers, RenderCommand, Command) + TIMED_NAMED_BLOCK(bonsai_render_command_clear_all_framebuffers); + ClearFramebuffers(Graphics, &Engine->RTTGroup); + } break; + + + { tmatch(bonsai_render_command_setup_shader, RenderCommand, Command) + TIMED_NAMED_BLOCK(bonsai_render_command_setup_shader); + + switch (Command->ShaderId) + { + InvalidCase(BonsaiRenderCommand_ShaderId_noop); + + case BonsaiRenderCommand_ShaderId_gBuffer: + { + SetupGBufferShader(Graphics, GetApplicationResolution(&Engine->Settings), False); + } break; + + case BonsaiRenderCommand_ShaderId_ShadowMap: + { + SetupShadowMapShader(World, Graphics, GetShadowMapResolution(&Engine->Settings), False); + } break; + } + } break; + + { tmatch(bonsai_render_command_teardown_shader, RenderCommand, Command) + TIMED_NAMED_BLOCK(bonsai_render_command_teardown_shader); + switch (Command->ShaderId) + { + InvalidCase(BonsaiRenderCommand_ShaderId_noop); + + case BonsaiRenderCommand_ShaderId_gBuffer: + { + TeardownGBufferShader(Graphics); + } break; + + case BonsaiRenderCommand_ShaderId_ShadowMap: + { + TeardownShadowMapShader(Graphics); + } break; + } + } break; + + { tmatch(bonsai_render_command_set_shader_uniform, RenderCommand, Command) + TIMED_NAMED_BLOCK(bonsai_render_command_set_shader_uniform); + shader *Shader = Command->Shader; + shader_uniform *Uniform = &Command->Uniform; + if (Uniform->ID >= 0) + { + BindUniformById(Uniform, &Command->TextureUnit); + } + else + { + BindUniformByName(Shader, Uniform, &Command->TextureUnit); + } + } break; + + { tmatch(bonsai_render_command_draw_world_chunk_draw_list, RenderCommand, Command) + TIMED_NAMED_BLOCK(bonsai_render_command_draw_world_chunk_draw_list); + Assert(FutexIsSignaled(&Graphics->RenderGate)); + RenderDrawList(Engine, Command->DrawList, Command->Shader, Command->Camera); + } break; + + { tmatch(bonsai_render_command_draw_all_entities, RenderCommand, Command) + TIMED_NAMED_BLOCK(bonsai_render_command_draw_all_entities); + DrawEntities(Command->Shader, EntityTable, &GpuMap->Buffer, 0, Graphics, World, Plat->dt); + } break; + + + { tmatch(bonsai_render_command_initialize_noise_buffer, RenderCommand, _Command) + InvalidCodePath(); + } break; + + + { tmatch(bonsai_render_command_do_stuff, RenderCommand, Command) + TIMED_NAMED_BLOCK(bonsai_render_command_do_stuff); + + // + // Render begin + // + + ao_render_group *AoGroup = Graphics->AoGroup; + +#if 0 + EngineDebug->Render.BytesSolidGeoLastFrame = GpuMap->Buffer.At; + EngineDebug->Render.BytesTransGeoLastFrame = Graphics->Transparency.GpuBuffer.Buffer.At; + + // TODO(Jesse): Make a render frame begin event to stuff this kinda thing onto? + // + // Update color texture, if necessary + // + s32 ColorCount = s32(AtElements(&Graphics->ColorPalette)); + if (ColorCount != Graphics->ColorPaletteTexture.Dim.x) + { + if (Graphics->ColorPaletteTexture.ID) { DeleteTexture(&Graphics->ColorPaletteTexture); } + Graphics->ColorPaletteTexture = + MakeTexture_RGB( V2i(ColorCount, 1), Graphics->ColorPalette.Start, CSz("ColorPalette")); + } +#endif + +#if 0 + // + // Editor preview + /* DrawStuffToGBufferTextures(Engine, GetApplicationResolution(&Engine->Settings)); */ + { + shadow_render_group *SG = Graphics->SG; + v3i Radius = World->VisibleRegion/2; + v3i Min = World->Center - Radius; + v3i Max = World->Center + Radius; + + SetupGBufferShader(Graphics, GetApplicationResolution(&Engine->Settings), False); + shader *Shader = &Graphics->gBuffer->gBufferShader; + DrawEditorPreview(Engine, Shader); + TeardownGBufferShader(Graphics); + + SetupShadowMapShader(Graphics, GetShadowMapResolution(&Engine->Settings), False); + Shader = &Graphics->SG->Shader.Program; + DrawEditorPreview(Engine, Shader); + TeardownShadowMapShader(Graphics); + } +#endif + + /* DrawWorldAndEntitiesToShadowMap(GetShadowMapResolution(&Engine->Settings), Engine); */ + + // TODO(Jesse): Move into engine debug + world_chunk *C = EngineDebug->PickedNode ? EngineDebug->PickedNode->Chunk : 0; + DebugHighlightWorldChunkBasedOnState(Graphics, C, &GpuMap->Buffer); + + AssertNoGlErrors; + + if (Graphics->Settings.DrawCameraGhost) + { + untextured_3d_geometry_buffer Mesh = ReserveBufferSpace(&GpuMap->Buffer, VERTS_PER_VOXEL); + DrawVoxel(&Mesh, {}, V3(0.7f), V3(1)*(Graphics->GameCamera.DistanceFromTarget/1000.f*Graphics->Settings.CameraGhostSize)); + } + + Ensure( FlushBuffersToCard_gpu_mapped_element_buffer(CurrentHandles(GpuMap)) ); // Unmaps buffer + + if (GpuMap->Buffer.At) + { + RenderImmediateGeometryToGBuffer(GetApplicationResolution(&Engine->Settings), GpuMap, Graphics); + /* RenderImmediateGeometryToShadowMap(World, Graphics, GpuMap); */ + } + Clear(&GpuMap->Buffer); + + /* DrawBuffer(GpuMap, &Plat->ScreenDim); */ + + + // NOTE(Jesse): I observed the AO lagging a frame behind if this is re-ordered + // after the transparency/luminance textures. I have literally 0 ideas as to + // why that would be, but here we are. + if (Graphics->Settings.UseSsao) { RenderAoTexture(GetApplicationResolution(&Engine->Settings), AoGroup); } + + + { + /* RenderTransparencyBuffers(GetApplicationResolution(&Engine->Settings), &Graphics->Settings, &Graphics->Transparency); */ + RenderLuminanceTexture(GetApplicationResolution(&Engine->Settings), Lighting, Graphics); + } + + if (Graphics->Settings.UseLightingBloom) { RunBloomRenderPass(Graphics); } + /* if (Graphics->Settings.UseLightingBloom) { GaussianBlurTexture(&Graphics->Gaussian, &Graphics->Lighting.BloomTex, &Graphics->Lighting.BloomFBO); } */ + + CompositeGameTexturesAndDisplay(Plat, Graphics); + + + UiFrameEnd(&Engine->Ui); + + MapGpuBuffer(&Ui->SolidQuadGeometryBuffer); + MapGpuBuffer(&Ui->TextGroup->Buf); + + BonsaiSwapBuffers(&Engine->Stdlib.Os); + + + HotReloadShaders(GetStdlib()); + + + /* GpuMap = GetNextGpuMap(Graphics); */ + + // Map GPU buffers for next frame + MapGpuBuffer(GpuMap); + /* MapGpuBuffer(&Graphics->Transparency.GpuBuffer); */ + Assert(GpuMap->Buffer.At == 0); + + UnsignalFutex(&Graphics->RenderGate, MAIN_THREAD_ThreadLocal_ThreadIndex); + + IterateOver(&Graphics->GpuTimers, Timer, TimerIndex) + { + if (Timer->Ns == 0) + { + if (QueryGpuTimer(Timer)) + { +#if BONSAI_DEBUG_SYSTEM_API + GetDebugState()->PushHistogramDataPoint(Timer->Ns); + // NOTE(Jesse): This skips the next timer, but it'll get + // hit on the next frame, so no worries .. + RemoveUnordered(&Graphics->GpuTimers, TimerIndex); +#endif + } + } + } + } break; + + { tmatch(bonsai_render_command_gl_timer_init, RenderCommand, Command) + InvalidCodePath(); + } break; + + { tmatch(bonsai_render_command_gl_timer_start, RenderCommand, Command) + InvalidCodePath(); + } break; + + { tmatch(bonsai_render_command_gl_timer_end, RenderCommand, Command) + InvalidCodePath(); + } break; + + { tmatch(bonsai_render_command_gl_timer_read_value_and_histogram, RenderCommand, Command) + InvalidCodePath(); + } break; + + } + } break; + } + + RewindArena(GetTranArena()); + } +} + +link_export void +DrainLoRenderQueue(engine_resources *Engine) +{ + /* TIMED_FUNCTION(); */ + + UNPACK_ENGINE_RESOURCES(Engine); + Assert(EntityTable); + + /* RenderInfo("DrainRenderQueue"); */ + + if (FutexIsSignaled(&Engine->Graphics.RenderGate)) return; + + AssertNoGlErrors; + while (work_queue_entry *Job = PopWorkQueueEntry(LoRenderQ)) + { + /* RenderInfo("%S", ToString(Job->Type)); */ + /* TIMED_NAMED_BLOCK(RENDER_LOOP); */ + tswitch(Job) + { + 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_update_world_region: */ + case type_work_queue_entry_rebuild_mesh: + case type_work_queue_entry_finalize_noise_values: + case type_work_queue_entry_build_chunk_mesh: + case type_work_queue_entry_sim_particle_system: + case type_work_queue_entry__align_to_cache_line_helper: + { + InvalidCodePath(); + } break; + + + { tmatch(work_queue_entry_async_function_call, Job, RPC) + /* RenderInfo("%S", ToString(RPC->Type)); */ + TIMED_NAMED_BLOCK(work_queue_entry_async_function_call); + DispatchAsyncFunctionCall(RPC); + } break; + + { tmatch(work_queue_entry__bonsai_render_command, Job, RenderCommand) + /* RenderInfo("%S", ToString(RenderCommand->Type)); */ + tswitch(RenderCommand) + { + InvalidCase(type_work_queue_entry__bonsai_render_command_noop); + + { case type_bonsai_render_command_cancel_all_noise_readback_jobs: + TIMED_NAMED_BLOCK(CancelReadbackJobs); + + IterateOver(&Graphics->NoiseReadbackJobs, PBOJob, JobIndex) + { + b32 Done = False; + while (!Done) + { + u32 SyncStatus = GetGL()->ClientWaitSync(PBOJob->PBOBuf.Fence, GL_SYNC_FLUSH_COMMANDS_BIT, 0); + switch(SyncStatus) + { + + case GL_ALREADY_SIGNALED: + case GL_CONDITION_SATISFIED: + { + AtomicDecrement(&Graphics->NoiseFinalizeJobsPending); + TIMED_NAMED_BLOCK(MapBuffer); + AssertNoGlErrors; + GetGL()->DeleteBuffers(1, &PBOJob->PBOBuf.PBO); + GetGL()->DeleteSync(PBOJob->PBOBuf.Fence); + AssertNoGlErrors; + /* RemoveUnordered(&Graphics->NoiseReadbackJobs, JobIndex); */ + Done = True; + } break; + + case GL_WAIT_FAILED: + { + /* RemoveUnordered(&Graphics->NoiseReadbackJobs, JobIndex); */ + SoftError("Error waiting on gl sync object"); + } break; + + case GL_TIMEOUT_EXPIRED: + { + SleepMs(1); + } break; + } + } + AssertNoGlErrors; + } + + // Clear the jobs + umm C = Count(&Graphics->NoiseReadbackJobs); + auto Z = ZerothIndex(&Graphics->NoiseReadbackJobs); + RangeIterator_t(umm, Index, C) { RemoveUnordered(&Graphics->NoiseReadbackJobs, Z); } + Assert(Count(&Graphics->NoiseReadbackJobs) == 0); + + /* Assert(Graphics->NoiseFinalizeJobsPending == 0); */ + } break; + + { tmatch(bonsai_render_command_allocate_and_map_gpu_element_buffer, RenderCommand, Command) + TIMED_NAMED_BLOCK(bonsai_render_command_allocate_and_map_gpu_element_buffer); + + AllocateGpuBuffer_gpu_mapped_element_buffer(&Command->Dest->Handles, Command->Type, Command->ElementCount); + MapGpuBuffer(Command->Dest); + Assert(HasGpuMesh(Command->Dest)); + + Assert(Command->DestNode->Flags & Chunk_Queued); + + auto LowPriorityQ = &Engine->Stdlib.Plat.LowPriority; + auto Next = WorkQueueEntry(WorkQueueEntryBuildWorldChunkMesh(Command->SynChunk, Command->DestNode)); + PushWorkQueueEntry(LowPriorityQ, &Next); + } break; + + { tmatch(bonsai_render_command_unmap_gpu_element_buffer, RenderCommand, Command) + TIMED_NAMED_BLOCK(bonsai_render_command_unmap_gpu_element_buffer); + + // Supersceded by FinalizeShitAndFuckinDoStuff + // + NotImplemented; + + +/* gpu_element_buffer_handles *Handles = Command->Handles; */ +/* FlushBuffersToCard_gpu_mapped_element_buffer(Handles); */ +/* Assert(Handles->Mapped == False); */ + + +/* Info("FlushBuffersToCard_gpu_mapped_element_buffer(%d)", Handles->ElementCount); */ + +/* octree_node *Node = Command->DestNode; */ +/* Assert(&Node->Chunk->Handles == Handles); */ +/* Assert(HasGpuMesh(Node->Chunk)); */ +/* Assert(Node->Chunk->Handles.VAO == Handles->VAO); */ +/* Assert(Node->Chunk->Handles.Handles[0] == Handles->Handles[0]); */ +/* Assert(Node->Chunk->Handles.Handles[1] == Handles->Handles[1]); */ +/* Assert(Node->Chunk->Handles.Handles[2] == Handles->Handles[2]); */ + + /* FinalizeNodeInitializaion(Cast(octree_node*, Cast(void*, Command->DestNode))); */ + } break; + + { tmatch(bonsai_render_command_unmap_and_deallocate_pbo, RenderCommand, Command) + TIMED_NAMED_BLOCK(bonsai_render_command_unmap_and_deallocate_pbo); + + gpu_readback_buffer PBOBuf = Command->PBOBuf; + + /* Info("(%d) Binding and Deallocating PBO (%u)", ThreadLocal_ThreadIndex, PBOBuf.PBO); */ + GetGL()->BindBuffer(GL_PIXEL_PACK_BUFFER, PBOBuf.PBO); + AssertNoGlErrors; + GetGL()->UnmapBuffer(GL_PIXEL_PACK_BUFFER); + AssertNoGlErrors; + GetGL()->DeleteBuffers(1, &PBOBuf.PBO); + AssertNoGlErrors; + GetGL()->DeleteSync(PBOBuf.Fence); + AssertNoGlErrors; + + } break; + + { tmatch(bonsai_render_command_allocate_texture, RenderCommand, Command) + TIMED_NAMED_BLOCK(bonsai_render_command_allocate_texture); + + texture *Texture = Command->Texture; + switch (Texture->Channels) + { + case 3: + { + *Texture = MakeTexture_RGB(Texture->Dim, (const v3*)Command->Data, Texture->DebugName, Texture->Slices, Texture->Format); + } break; + + case 4: + { + *Texture = MakeTexture_RGBA(Texture->Dim, Cast(u32*, Command->Data), Texture->DebugName, Texture->Slices, Texture->Format); + } break; + + InvalidDefaultCase; + } + + } break; + + + { tmatch(bonsai_render_command_deallocate_texture, RenderCommand, Command) + NotImplemented; + } break; + + + { tmatch(bonsai_render_command_allocate_handles, RenderCommand, Command) + TIMED_NAMED_BLOCK(bonsai_render_command_allocate_handles); + NotImplemented; + /* auto *Handles = Command->Handles; */ + /* auto *Mesh = Command->Mesh; */ + + /* ReallocateAndSyncGpuBuffers(Handles, Mesh); */ + /* DeallocateMesh(Mesh, &Engine->geo_u3d_MeshFreelist); */ + } break; + + + { tmatch(bonsai_render_command_deallocate_handles, RenderCommand, Command) + TIMED_NAMED_BLOCK(bonsai_render_command_deallocate_handles); + DeleteGpuBuffer(&Command->Handles); + } break; + + + { tmatch(bonsai_render_command_deallocate_world_chunk, RenderCommand, Command) + TIMED_NAMED_BLOCK(bonsai_render_command_deallocate_world_chunk); + world_chunk *Chunk = Command->Chunk; + FreeWorldChunk(Engine, Chunk); + } break; + + + { tmatch(bonsai_render_command_clear_all_framebuffers, RenderCommand, Command) + InvalidCodePath(); + } break; + + + + + { tmatch(bonsai_render_command_setup_shader, RenderCommand, Command) + InvalidCodePath(); + } break; + + { tmatch(bonsai_render_command_teardown_shader, RenderCommand, Command) + InvalidCodePath(); + } break; + + { tmatch(bonsai_render_command_set_shader_uniform, RenderCommand, Command) + InvalidCodePath(); + } break; + + { tmatch(bonsai_render_command_draw_world_chunk_draw_list, RenderCommand, Command) + InvalidCodePath(); + } break; + + { tmatch(bonsai_render_command_draw_all_entities, RenderCommand, Command) + InvalidCodePath(); + } break; + + + { tmatch(bonsai_render_command_initialize_noise_buffer, RenderCommand, _Command) + TIMED_NAMED_BLOCK(bonsai_render_command_initialize_noise_buffer); + /* Command = 0; */ + + AtomicIncrement(&Graphics->NoiseFinalizeJobsPending); + + bonsai_render_command_initialize_noise_buffer C = RenderCommand->bonsai_render_command_initialize_noise_buffer; + + octree_node *Node = C.DestNode; + world_chunk **Chunk2 = &C.DestNode->Chunk; + world_chunk *Chunk1 = C.DestNode->Chunk; + world_chunk *Chunk = Chunk1; + + Assert(s64(Chunk) == s64(Chunk1)); + + DispatchTerrainShaders(Graphics, Chunk); + + s32 CurrentAccumulationTextureIndex = 0; + + // + // Apply edits + // + + + auto WorldEditRC = &Graphics->WorldEditRC; + { + AcquireFutex(&Node->Lock); + if (TotalElements(&Node->Edits)) + { + AssertNoGlErrors; + + UseShader(WorldEditRC); + AssertNoGlErrors; + + + // NOTE(Jesse): @duplicated_edit_ordinal_sort_code + // Was too lazy to make a templated overload for the sort + // function.. so here we are. Hopefully I don't pay for this + // in the future. + // { +#if 1 + s32 EditCount = s32(TotalElements(&Node->Edits)); + sort_key *Keys = Allocate(sort_key, GetTranArena(), EditCount); + + + IterateOver(&Node->Edits, Edit, EditIndex) + { + u32 KeyIndex = u32(GetIndex(&EditIndex)); + Keys[KeyIndex] = {u64(Edit), u64(Edit->Ordinal)}; + } + + BubbleSort_descending(Keys, u32(EditCount)); +#endif + // } + + +#define AdvanceIndex(i) i = ((i+1) % 3) +#define Swap(a, b) do { auto tmp = b; b = a; a = tmp; } while (false) + + RangeIterator(KeyIndex, EditCount) + /* IterateOver(&Node->Edits, Edit, EditIndex) */ + { + TIMED_NAMED_BLOCK(WorldEditDrawCall); + + /* world_edit *Edit = GetPtr(&Editor->Edits, *Edit); */ + + world_edit *Edit = Cast(world_edit*, Keys[KeyIndex].Index); + if (Edit->Brush) // NOTE(Jesse): Don't necessarily have to have a brush if we created the edit before we created a brush. + { + layered_brush *Brush = &Edit->Brush->Layered; + + + b32 BindInputTexture = Brush->AffectExisting; + + s32 CurrentWriteTextureIndex = CurrentAccumulationTextureIndex; + s32 CurrentReadTextureIndex = CurrentAccumulationTextureIndex; + + AdvanceIndex(CurrentWriteTextureIndex); + + // If we're not trying to seed the brush with the current + // accumulator texture, set to the empty one + if (BindInputTexture == False) + { + AdvanceIndex(CurrentReadTextureIndex); + AdvanceIndex(CurrentReadTextureIndex); + } + + RangeIterator(LayerIndex, Brush->LayerCount) + { + GetGL()->BindFramebuffer(GL_FRAMEBUFFER, WorldEditRC->PingPongFBOs[CurrentWriteTextureIndex].ID); + + BindUniformByName(&WorldEditRC->Program, "SampleInputTex", BindInputTexture); + if (BindInputTexture) + { + texture *InputTex = &WorldEditRC->PingPongTextures[CurrentReadTextureIndex]; + // @derivs_texture_binding_to_shader_unit_0 + BindUniformByName(&WorldEditRC->Program, "InputTex", InputTex, 1); + } + BindInputTexture = True; + + b32 LastLayer = LayerIndex == Brush->LayerCount-1; + b32 BindBlendTex = (Brush->AffectExisting == False) && LastLayer; + BindUniformByName(&WorldEditRC->Program, "SampleBlendTex", BindBlendTex); + if (BindBlendTex) + { + texture *BlendTex = &WorldEditRC->PingPongTextures[CurrentAccumulationTextureIndex]; + BindUniformByName(&WorldEditRC->Program, "BlendTex", BlendTex, 2); + } + + brush_layer *Layer = Brush->Layers + LayerIndex; + + { + v3 RGBColor = HSVtoRGB(Layer->Settings.HSVColor); + BindUniformByName(&WorldEditRC->Program, "RGBColor", &RGBColor); + } + + BindUniformByName(&WorldEditRC->Program, "ValueBias", Layer->Settings.ValueBias); + BindUniformByName(&WorldEditRC->Program, "BrushType", Layer->Settings.Type); + BindUniformByName(&WorldEditRC->Program, "BlendMode", Layer->Settings.BlendMode); + BindUniformByName(&WorldEditRC->Program, "ValueModifiers", Layer->Settings.ValueModifier); + BindUniformByName(&WorldEditRC->Program, "ColorMode", Layer->Settings.ColorMode); + BindUniformByName(&WorldEditRC->Program, "Invert", Layer->Settings.Invert); + BindUniformByName(&WorldEditRC->Program, "Threshold", Layer->Settings.Threshold); + BindUniformByName(&WorldEditRC->Program, "Power", Layer->Settings.Power); + + + rect3 SimEditRect = GetSimSpaceRect(World, Edit->Region); + v3 SimChunkMin = GetSimSpaceP(World, Chunk->WorldP); + v3 EditRectRad = GetRadius(&SimEditRect); + + // NOTE(Jesse): Must call bind explicitly because the + // driver doesn't cache these values otherwise .. it + // just reads them whenever it wants through the pointer.. + v3 ChunkRelEditMin = SimEditRect.Min - SimChunkMin; + BindUniformByName(&WorldEditRC->Program, "ChunkRelEditMin", &ChunkRelEditMin); + AssertNoGlErrors; + + v3 ChunkRelEditMax = SimEditRect.Max - SimChunkMin; + BindUniformByName(&WorldEditRC->Program, "ChunkRelEditMax", &ChunkRelEditMax); + AssertNoGlErrors; + + v3 EditDim = ChunkRelEditMax - ChunkRelEditMin; + + switch (Layer->Settings.Type) + { + case BrushLayerType_Noise: + { + noise_layer *Noise = &Layer->Settings.Noise; + BindUniformByName(&WorldEditRC->Program, "NoiseType", Noise->Type); + + switch (Noise->Type) + { + case NoiseType_Perlin: + { + auto *Perlin = &Noise->Perlin; + BindUniformByName(&WorldEditRC->Program, "Period", &Perlin->Period); + } break; + + case NoiseType_Voronoi: + { + auto *Voronoi = &Noise->Voronoi; + BindUniformByName(&WorldEditRC->Program, "Squareness", Voronoi->Squareness); + BindUniformByName(&WorldEditRC->Program, "Period", &Voronoi->Period); + } break; + + case NoiseType_White: + {} break; + } + + } break; + + case BrushLayerType_Shape: + { + shape_layer *Shape = &Layer->Settings.Shape; + BindUniformByName(&WorldEditRC->Program, "ShapeType", Shape->Type); + + BindUniformByName(&WorldEditRC->Program, "Rounding", Shape->Advanced.Rounding); + BindUniformByName(&WorldEditRC->Program, "Stretch", &Shape->Advanced.Stretch); + BindUniformByName(&WorldEditRC->Program, "Repeat", &Shape->Advanced.Repeat); + + m4 Rot = RotateTransform(Shape->Advanced.Axis*PI32); + BindUniformByName(&WorldEditRC->Program, "RotTransform", &Rot); + + switch(Shape->Type) + { + case ShapeType_Rect: + { + auto Rect = &Shape->Rect; + BindUniformByName(&WorldEditRC->Program, "RectDim", &Rect->Dim); + } break; + + case ShapeType_Sphere: + { + auto Sphere = &Shape->Sphere; + + v3 SimSphereOrigin = GetSimSpaceP(World, Edit->Region.Min + EditRectRad); + v3 EditRelativeSphereCenter = SimSphereOrigin - SimEditRect.Min; + + BindUniformByName(&WorldEditRC->Program, "EditRelativeSphereCenter", &EditRelativeSphereCenter); + BindUniformByName(&WorldEditRC->Program, "Radius", Sphere->Radius); + } break; + + case ShapeType_Line: + { + auto Line = &Shape->Line; + BindUniformByName(&WorldEditRC->Program, "Radius", Line->Radius); + } break; + + case ShapeType_Cylinder: + { + auto Cylinder = &Shape->Cylinder; + BindUniformByName(&WorldEditRC->Program, "Radius", Cylinder->Radius); + BindUniformByName(&WorldEditRC->Program, "Height", Cylinder->Height); + } break; + + case ShapeType_Plane: + { + auto Plane = &Shape->Plane; + auto Orientation = Plane->Orientation; + + v3 xAxis = V3(1,0,0); + v3 yAxis = V3(0,1,0); + v3 zAxis = V3(0,0,1); + + switch (Orientation) + { + InvalidCase(ShapeAxis_Count); + + case ShapeAxis_InferFromMajorAxis: + {} break; + + // Traverses the X axis and ascends + case ShapeAxis_PosX: + { + xAxis = Normalize(V3(EditRectRad.x, 0.f, EditRectRad.z)); + yAxis = Normalize(V3(0.f, EditRectRad.y, 0.f)); + zAxis = Normalize(Cross(xAxis, yAxis)); + } break; + // Traverses the X axis and descends + case ShapeAxis_NegX: + { + xAxis = Normalize(V3(EditRectRad.x, 0.f, -EditRectRad.z)); + yAxis = Normalize(V3(0.f, EditRectRad.y, 0.f)); + zAxis = Normalize(Cross(xAxis, yAxis)); + } break; + + + case ShapeAxis_PosY: + { + xAxis = Normalize(V3(0.f, EditRectRad.y, EditRectRad.z)); + yAxis = Normalize(V3(EditRectRad.x, 0.f, 0.f)); + zAxis = Normalize(Cross(xAxis, yAxis)); + } break; + case ShapeAxis_NegY: + { + xAxis = Normalize(V3(0.f, EditRectRad.y, -EditRectRad.z)); + yAxis = Normalize(V3(EditRectRad.x, 0.f, 0.f)); + zAxis = Normalize(Cross(xAxis, yAxis)); + } break; + + + case ShapeAxis_PosZ: + { + xAxis = Normalize(V3(0.f, 0.f, EditRectRad.z)); + yAxis = Normalize(V3(EditRectRad.x, EditRectRad.y, 0.f)); + zAxis = Normalize(Cross(xAxis, yAxis)); + } break; + + case ShapeAxis_NegZ: + { + xAxis = Normalize(V3(0.f, 0.f, EditRectRad.z)); + yAxis = Normalize(V3(-EditRectRad.x, EditRectRad.y, 0.f)); + zAxis = Normalize(Cross(xAxis, yAxis)); + } break; + } + + v3 Plane_SimShapeOrigin = EditRectRad; + v3 PlaneNormal = zAxis; + + auto PlaneRadius = Plane->Thickness/2.f; + auto Planed = -1.0f * ( PlaneNormal.x*Plane_SimShapeOrigin.x + + PlaneNormal.y*Plane_SimShapeOrigin.y + + PlaneNormal.z*Plane_SimShapeOrigin.z ); + + auto PlanePos = Plane_SimShapeOrigin; + + BindUniformByName(&WorldEditRC->Program, "PlaneNormal", &PlaneNormal); + BindUniformByName(&WorldEditRC->Program, "Planed", Planed); + BindUniformByName(&WorldEditRC->Program, "PlaneRadius", PlaneRadius); + + } break; + + case ShapeType_Torus: + { + auto Torus = &Shape->Torus; + + BindUniformByName(&WorldEditRC->Program, "Radius", Torus->MajorRadius); + BindUniformByName(&WorldEditRC->Program, "MinorRadius", Torus->MinorRadius); + + } break; + + // @sdf_shape_step(5): Calculate values and bind uniform variables for the new shape + // + } + } break; + } + + + /* gpu_timer Timer = StartGpuTimer(); */ + RenderQuad(); + /* EndGpuTimer(&Timer); */ + /* Push(&Graphics->GpuTimers, &Timer); */ + + Swap(CurrentWriteTextureIndex, CurrentReadTextureIndex); + } + + CurrentAccumulationTextureIndex = CurrentReadTextureIndex; + } + + AssertNoGlErrors; + } + } + ReleaseFutex(&Node->Lock); + } + + /* DEBUG_DrawSimSpaceVectorAt(Engine, SimEditRect.Min + EditRectRad, xAxis*200.f, RGB_RED, DEFAULT_LINE_THICKNESS*4.f ); */ + /* DEBUG_DrawSimSpaceVectorAt(Engine, SimEditRect.Min + EditRectRad, yAxis*200.f, RGB_GREEN, DEFAULT_LINE_THICKNESS*4.f ); */ + /* DEBUG_DrawSimSpaceVectorAt(Engine, SimEditRect.Min + EditRectRad, zAxis*200.f, RGB_BLUE, DEFAULT_LINE_THICKNESS*4.f ); */ + /* DEBUG_DrawSimSpaceVectorAt(Engine, SimEditRect.Min + EditRectRad, PlaneNormal*400.f, RGB_PINK, DEFAULT_LINE_THICKNESS*2.f ); */ + + texture *CurrentAccumulationTexture = &WorldEditRC->PingPongTextures[CurrentAccumulationTextureIndex]; + + // + // Terrain Finalize + // + { + TIMED_NAMED_BLOCK(TerrainFinalizeDrawCall); + GetGL()->BindFramebuffer(GL_FRAMEBUFFER, Graphics->TerrainFinalizeRC.FBO.ID); + + UseShader(&Graphics->TerrainFinalizeRC); + + // NOTE(Jesse): The other inputtex calls bind to texture unit 1 .. it is correct that + // this bind to unit 0 because there's no derivs texture being bound here. + // + // @derivs_texture_binding_to_shader_unit_0 + BindUniformByName(&Graphics->TerrainFinalizeRC.Program, "InputTex", CurrentAccumulationTexture, 0); + + /* gpu_timer Timer = StartGpuTimer(); */ + RenderQuad(); + /* EndGpuTimer(&Timer); */ + /* Push(&Graphics->GpuTimers, &Timer); */ + + AssertNoGlErrors; + } + + /* Assert(Chunk1->Dim == V3i(64)); */ + /* Assert(NoiseDim == V3(66)); */ + v3i NoiseDim = V3i(66); + + s32 NoiseElementCount = s32(Volume(CurrentAccumulationTexture->Dim)); + s32 NoiseByteCount = NoiseElementCount*s32(sizeof(u32)); + + { + TIMED_NAMED_BLOCK(GenPboAndInitTransfer); + u32 PBO; + GetGL()->GenBuffers(1, &PBO); + AssertNoGlErrors; + + /* Info("(%d) Allocated PBO (%u)", ThreadLocal_ThreadIndex, PBO); */ + GetGL()->BindBuffer(GL_PIXEL_PACK_BUFFER, PBO); + GetGL()->BufferData(GL_PIXEL_PACK_BUFFER, NoiseByteCount, 0, GL_STREAM_READ); + AssertNoGlErrors; + GetGL()->ReadPixels(0, 0, CurrentAccumulationTexture->Dim.x, CurrentAccumulationTexture->Dim.y, GL_RED_INTEGER, GL_UNSIGNED_INT, 0); + AssertNoGlErrors; + GetGL()->BindBuffer(GL_PIXEL_PACK_BUFFER, 0); + + gl_fence Fence = GetGL()->FenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); + + dummy_work_queue_entry_build_chunk_mesh Readback = { {PBO,Fence}, NoiseDim, Node}; + Push(&Graphics->NoiseReadbackJobs, &Readback); + } + } break; + + + { tmatch(bonsai_render_command_do_stuff, RenderCommand, Command) + InvalidCodePath(); + } break; + + { tmatch(bonsai_render_command_gl_timer_init, RenderCommand, Command) + TIMED_NAMED_BLOCK(bonsai_render_command_gl_timer_init); + AssertNoGlErrors; + GetGL()->GenQueries(1, Command->GlTimerObject); + AssertNoGlErrors; + } break; + + { tmatch(bonsai_render_command_gl_timer_start, RenderCommand, Command) + TIMED_NAMED_BLOCK(bonsai_render_command_gl_timer_start); + AssertNoGlErrors; + GetGL()->BeginQuery(GL_TIME_ELAPSED, Command->GlTimerObject); + AssertNoGlErrors; + } break; + + { tmatch(bonsai_render_command_gl_timer_end, RenderCommand, Command) + TIMED_NAMED_BLOCK(bonsai_render_command_gl_timer_end); + AssertNoGlErrors; + GetGL()->EndQuery(GL_TIME_ELAPSED); + AssertNoGlErrors; + } break; + + { tmatch(bonsai_render_command_gl_timer_read_value_and_histogram, RenderCommand, Command) + TIMED_NAMED_BLOCK(bonsai_render_command_gl_timer_read_value_and_histogram); +#if 0 + AssertNoGlErrors; + u64 TimerNs = 0; + + s32 Available = False; + while (!Available) + { + GetGL()->GetQueryObjectiv(Command->GlTimerObject, GL_QUERY_RESULT_AVAILABLE, &Available); + /* if (Available == False) { Info("Waiting for query object to become available"); } */ + } + + + GetGL()->GetQueryObjectui64v(Command->GlTimerObject, GL_QUERY_RESULT, &TimerNs); + /* Info("GL reported time of (%.2f)ms", f64(TimerNs)/1000000.0); */ + /* GetDebugState()->PushHistogramDataPoint(TimerNs); */ + AssertNoGlErrors; +#endif + } break; + + } + } break; + } + + RewindArena(GetTranArena()); + + if (FutexIsSignaled(&Engine->Graphics.RenderGate)) return; + } + + { + TIMED_NAMED_BLOCK(CheckReadbackJobs); + IterateOver(&Graphics->NoiseReadbackJobs, PBOJob, JobIndex) + { + TIMED_NAMED_BLOCK(CheckJob); + Assert(PBOJob); + + /* Info("PBOJob(0x%x) JobIndex(%u)", PBOJob, JobIndex.Index); */ + /* Info("0x%x 0x%x", PBOJob->PBOBuf.PBO, PBOJob->PBOBuf.Fence); */ + + u32 SyncStatus = GetGL()->ClientWaitSync(PBOJob->PBOBuf.Fence, GL_SYNC_FLUSH_COMMANDS_BIT, 0); + AssertNoGlErrors; + switch(SyncStatus) + { + case GL_ALREADY_SIGNALED: + case GL_CONDITION_SATISFIED: + { + TIMED_NAMED_BLOCK(MapBuffer); + + AssertNoGlErrors; + /* umm JobCount = AtElements(&Graphics->NoiseReadbackJobs).Index; */ + /* Info("(%d) Binding and Mapping PBOJob(0x%x) PBO(%u) JobCount(%d) JobIndex(%u)", ThreadLocal_ThreadIndex, PBOJob, PBOJob->PBOBuf.PBO, JobCount, JobIndex.Index); */ + GetGL()->BindBuffer(GL_PIXEL_PACK_BUFFER, PBOJob->PBOBuf.PBO); + AssertNoGlErrors; + u32 *NoiseValues = Cast(u32*, GetGL()->MapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY)); + AssertNoGlErrors; + + auto BuildMeshJob = WorkQueueEntry(WorkQueueEntryFinalizeNoiseValues(PBOJob->PBOBuf, NoiseValues, PBOJob->NoiseDim, PBOJob->DestNode)); + PushWorkQueueEntry(&Plat->LowPriority, &BuildMeshJob); + + // TODO(Jesse): This actually makes the loop skip a job because we + // shorten the array, but never update the index we're looking at. + // + // It doesn't matter in this case because this runs every frame, so + // the skipped job is just a frame late. But, it would be nice if + // this was better. + // + // NOTE(Jesse): Must happen after we read the PBOJob values for the work queue entry + RemoveUnordered(&Graphics->NoiseReadbackJobs, JobIndex); + } break; + + case GL_TIMEOUT_EXPIRED: + { + } break; + + case GL_WAIT_FAILED: + { + SoftError("Error waiting on gl sync object"); + } break; + } + + if (FutexIsSignaled(&Engine->Graphics.RenderGate)) return; + } + } +} + +#define MillisecondsToNanoseconds(ms) (ms*1000.0) + +link_internal void +SpinlockNs(s32 Nanoseconds) +{ + TIMED_FUNCTION(); + + r64 StartMs = GetHighPrecisionClock(); + + for (;;) + { + r64 CurrentMs = GetHighPrecisionClock(); + r64 Elapsed = CurrentMs - StartMs; + + s32 ElapsedNs = s32(MillisecondsToNanoseconds(Elapsed)); + if (ElapsedNs > Nanoseconds) + { + break; + } + } +} + +link_export THREAD_MAIN_RETURN +RenderThread_Main(void *ThreadStartupParams) +{ + thread_local_state *Thread = Cast(thread_local_state*, ThreadStartupParams); + WorkerThread_BeforeJobStart(Thread); + + Assert(GetStdlib()->ThreadStates); + + /* Assert(Thread->ThreadIndex > 0); */ + /* SetThreadLocal_ThreadIndex(Thread->ThreadIndex); */ + + engine_resources *Engine = GetEngineResources(); + application_api *AppApi = &Thread->Stdlib->AppApi; + os *Os = &Engine->Stdlib.Os; + platform *Plat = &Engine->Stdlib.Plat; + engine_api *EngineApi = &Engine->EngineApi; + + PlatformMakeRenderContextCurrent(Os); + + b32 InitResult = GraphicsInit(&Engine->Graphics, &Engine->Settings, AllocateArena()); + + memory_arena *UiMemory = AllocateArena(); + if (InitResult) + { + InitRenderer2D(&Engine->Ui, &Engine->Heap, UiMemory, &Plat->MouseP, &Plat->MouseDP, &Plat->ScreenDim, &Plat->Input); + + bitmap_block_array Bitmaps = BitmapBlockArray(GetTranArena()); + LoadBitmapsFromFolderOrdered(CSz("assets/mystic_rpg_icon_pack/Sprites/300%/64x64_sprites"), &Bitmaps, GetTranArena(), GetTranArena()); + LoadBitmapsFromFolderOrdered(CSz("assets/mystic_rpg_icon_pack/Sprites/300%/44x44_sprites"), &Bitmaps, GetTranArena(), GetTranArena()); + Engine->Ui.SpriteTextureArray = CreateTextureArrayFromBitmapBlockArray(&Bitmaps, V2i(64,64)); + } + + // Map immediate GPU buffers for first frame + MapGpuBuffer(&Engine->Graphics.ImmediateGeometry); + MapGpuBuffer(&Engine->Graphics.Transparency.GpuBuffer); + + auto Ui = &Engine->Ui; + MapGpuBuffer(&Ui->SolidQuadGeometryBuffer); + MapGpuBuffer(&Ui->TextGroup->Buf); + + FullBarrier; + SignalFutex(&Engine->Graphics.Initialized); + + if (InitResult) + { + // Wait for main thread to complete initialization + while (FutexIsSignaled(&Engine->ReadyToStartMainLoop) == False) { SleepMs(1); }; + + bonsai_futex *WorkerThreadsExitFutex = &Plat->WorkerThreadsExitFutex; + while ( FutexNotSignaled(WorkerThreadsExitFutex) ) + { + WORKER_THREAD_ADVANCE_DEBUG_SYSTEM(); + + AppApi->WorkerBeforeJob(Thread); + + EngineApi->DrainHiRenderQueue(Engine); + EngineApi->DrainLoRenderQueue(Engine); + + if (FutexIsSignaled(&Plat->WorkerThreadsSuspendFutex)) + { + // Have to wait for all the worker threads to suspend cause they push + // entries onto the render queues + while (Plat->WorkerThreadsSuspendFutex.ThreadsWaiting != GetWorkerThreadCount()-1) + { + SleepMs(1); + } + + // Even though we just called these we have to make sure they're actually + // flushed; the main thread could have pushed stuff onto the Hi + // queue while we were draining the Lo queue, for example. Once we're + // in this if we know the main thread is waiting for us + EngineApi->DrainHiRenderQueue(Engine); + EngineApi->DrainLoRenderQueue(Engine); + Assert(QueueIsEmpty(&Engine->Stdlib.Plat.HiRenderQ)); + Assert(QueueIsEmpty(&Engine->Stdlib.Plat.LoRenderQ)); + + SleepMs(3); + + Assert(QueueIsEmpty(&Engine->Stdlib.Plat.HiRenderQ)); + Assert(QueueIsEmpty(&Engine->Stdlib.Plat.LoRenderQ)); + + WaitOnFutex(&Plat->WorkerThreadsSuspendFutex); + } + + SpinlockNs(100); + + /* SleepMs(1); */ + } + + Info("Exiting Render Thread (%d)", Thread->ThreadIndex); + WaitOnFutex(WorkerThreadsExitFutex); + } + else + { + Error("Render thread initiailization failed."); + } + + THREAD_MAIN_RETURN Result = ReinterpretCast(THREAD_MAIN_RETURN, InitResult); + return Result; +} diff --git a/src/engine/render_position.h b/src/engine/render_position.h index 3063c89bf..a35da2cfa 100644 --- a/src/engine/render_position.h +++ b/src/engine/render_position.h @@ -1,8 +1,3 @@ -// -// TODO(Jesse)(high-priority, getrenderp): This is complete garbage and needs to be removed asap. -// -#if 1 - link_internal cp ComputeTarget(camera *Camera) { @@ -11,25 +6,24 @@ ComputeTarget(camera *Camera) } inline v3 -GetRenderP(canonical_position P, camera *Camera, world_position WorldChunkDim) +GetRenderP(cp P, camera *Camera, v3i WorldChunkDim) { - cp ViewingTarget = ComputeTarget(Camera); - v3 CameraOffset = ViewingTarget.Offset + (ViewingTarget.WorldP * WorldChunkDim); - v3 Result = P.Offset + (P.WorldP * WorldChunkDim) - CameraOffset; + cp CameraRelative = P-Camera->CurrentP; + v3 Result = CameraRelative.Offset + (V3(CameraRelative.WorldP) * WorldChunkDim); return Result; } inline v3 -GetRenderP( chunk_dimension WorldChunkDim, canonical_position P, camera *Camera) +GetRenderP( v3i WorldChunkDim, cp P, camera *Camera) { v3 Result = GetRenderP(P, Camera, WorldChunkDim); return Result; } inline v3 -GetRenderP( chunk_dimension WorldChunkDim, v3 Offset, camera *Camera) +GetRenderP( v3i WorldChunkDim, v3 Offset, camera *Camera) { - v3 Result = GetRenderP(WorldChunkDim, Canonical_Position(Offset, World_Position(0)), Camera); + v3 Result = GetRenderP(WorldChunkDim, Canonical_Position(Offset, {}), Camera); return Result; } @@ -55,28 +49,28 @@ GetRenderP( engine_resources *Engine, v3 Offset ) } inline v3 -GetRenderP( chunk_dimension WorldChunkDim, world_position WorldP, camera *Camera) +GetRenderP( v3i WorldChunkDim, v3i WorldP, camera *Camera) { v3 Result = GetRenderP(WorldChunkDim, Canonical_Position(V3(0,0,0), WorldP), Camera); return Result; } inline v3 -GetRenderP( chunk_dimension WorldChunkDim, standing_spot *Spot, camera *Camera) +GetRenderP( v3i WorldChunkDim, standing_spot *Spot, camera *Camera) { v3 Result = Spot->P.Offset + GetRenderP(WorldChunkDim, Spot->P.WorldP, Camera); return Result; } inline v3 -GetRenderP( chunk_dimension WorldChunkDim, entity *entity, camera *Camera) +GetRenderP( v3i WorldChunkDim, entity *entity, camera *Camera) { v3 Result = GetRenderP(WorldChunkDim, entity->P, Camera); return Result; } inline aabb -GetRenderSpaceAABB(chunk_dimension WorldChunkDim, entity *Entity, camera *Camera) +GetRenderSpaceAABB(v3i WorldChunkDim, entity *Entity, camera *Camera) { v3 Radius = Entity->_CollisionVolumeRadius; v3 Center = GetRenderP(WorldChunkDim, Entity->P, Camera) + Radius; @@ -84,7 +78,6 @@ GetRenderSpaceAABB(chunk_dimension WorldChunkDim, entity *Entity, camera *Camera aabb Result = RectCenterRad(Center, Radius); return Result; } -#endif inline m4 LookAt(v3 P, v3 Target, v3 Up) @@ -107,7 +100,7 @@ LookAt(v3 P, v3 Target, v3 Up) } inline m4 -ViewMatrix(chunk_dimension WorldChunkDim, camera *Camera) +ViewMatrix(v3i WorldChunkDim, camera *Camera) { m4 Result = LookAt( GetRenderP(WorldChunkDim, Camera->CurrentP, Camera), diff --git a/src/engine/render_settings.h b/src/engine/render_settings.h index ae01f4034..214dda674 100644 --- a/src/engine/render_settings.h +++ b/src/engine/render_settings.h @@ -8,53 +8,38 @@ enum tone_mapping_type ToneMappingType_AGX_Punchy, }; -struct lighting_settings poof(@version(1)) +struct lighting_settings +poof(@do_editor_ui) { b8 AutoDayNightCycle; + r32 tDaySpeed = 10.f; poof(@ui_value_range(1.f, 30.f)) r32 tDay; poof(@ui_value_range(-PI32, PI32)) v3 SunP; poof(@ui_skip) + r32 FogPower; + v3 FogColor; poof(@custom_ui(PushColumn(Ui, CSz("FogColor")); DoColorPickerToggle(Ui, Window, &Element->FogColor, False, ThisHash))) + f32 DawnIntensity; poof(@ui_value_range(0.f, 3.f)) - v3 DawnColor; + v3 DawnHSV; poof(@custom_ui(PushColumn(Ui, CSz("DawnColor")); DoColorPickerToggle(Ui, Window, &Element->DawnHSV, False, ThisHash))) f32 SunIntensity; poof(@ui_value_range(0.f, 3.f)) - v3 SunColor; + v3 SunHSV; poof(@custom_ui(PushColumn(Ui, CSz("SunColor")); DoColorPickerToggle(Ui, Window, &Element->SunHSV, False, ThisHash))) f32 DuskIntensity; poof(@ui_value_range(0.f, 3.f)) v3 DuskColor; + v3 DuskHSV; poof(@custom_ui(PushColumn(Ui, CSz("DuskColor")); DoColorPickerToggle(Ui, Window, &Element->DuskHSV, False, ThisHash))) f32 MoonIntensity; poof(@ui_value_range(0.f, 3.f)) - v3 MoonColor; + v3 MoonHSV; poof(@custom_ui(PushColumn(Ui, CSz("MoonColor")); DoColorPickerToggle(Ui, Window, &Element->MoonHSV, False, ThisHash))) // Computed from the above parameters and passed to the shader v3 CurrentSunColor; }; -struct lighting_settings_0 -{ - b8 AutoDayNightCycle; - - r32 tDay; poof(@ui_value_range(-PI32, PI32)) - - v3 SunP; poof(@ui_value_range(-1.f, 1.f)) - - v3 DawnColor; - v3 SunColor; - v3 DuskColor; - v3 MoonColor; - - f32 SunIntensity; poof(@ui_value_range(0.f, 3.f)) - f32 MoonIntensity; poof(@ui_value_range(0.f, 3.f)) - f32 DawnIntensity; poof(@ui_value_range(0.f, 3.f)) - f32 DuskIntensity; poof(@ui_value_range(0.f, 3.f)) - - // Computed from the above parameters and passed to the shader - v3 CurrentSunColor; -}; - -struct render_settings poof(@version(1)) +struct render_settings +poof(@do_editor_ui) { // NOTE(Jesse): These have to be 32bit because they get passed to shaders // and the shader system is too dumb to handle 8-bit or 1-bit values @@ -67,14 +52,19 @@ struct render_settings poof(@version(1)) b32 DrawMajorGrid; b32 DrawMinorGrid; - r32 MajorGridDim; poof(@ui_value_range(0, 32)) + r32 MajorGridDim; poof(@ui_value_range(0, 32)) - v3 OffsetOfWorldCenterToGrid; poof(@ui_skip) - b32 Headless; poof(@ui_skip) + b32 DrawCameraGhost; + r32 CameraGhostSize = 1.f; poof(@ui_value_range(1, 100)) + // Moved OffsetOfWorldCenterToGrid to graphics + v3 Ignored; poof(@ui_skip) + b32 Headless; poof(@ui_skip) tone_mapping_type ToneMappingType; + f32 GameCameraFOV; poof(@ui_value_range(5, 250)) + lighting_settings Lighting; v2 ApplicationResolution; @@ -86,25 +76,5 @@ struct render_settings poof(@version(1)) v2i iLuminanceMapResolution; }; -struct render_settings_0 -{ - // NOTE(Jesse): These have to be 32bit because they get passed to shaders - // and the shader system is too dumb to handle 8-bit or 1-bit values - b32 UseSsao; - b32 UseShadowMapping; - b32 UseLightingBloom; - - b32 BravoilMyersOIT; - b32 BravoilMcGuireOIT; - - b32 DrawMajorGrid; - b32 DrawMinorGrid; - r32 MajorGridDim; poof(@ui_value_range(0, 32)) - - v3 OffsetOfWorldCenterToGrid; poof(@ui_skip) - b32 Headless; poof(@ui_skip) - - tone_mapping_type ToneMappingType; - - lighting_settings Lighting; -}; +poof(are_equal(render_settings)) +#include diff --git a/src/engine/resources.cpp b/src/engine/resources.cpp index 6ac047d3a..df395a37c 100644 --- a/src/engine/resources.cpp +++ b/src/engine/resources.cpp @@ -2,393 +2,25 @@ link_internal void DeallocateAndClearWorldChunk(engine_resources *Engine, world_chunk *Chunk) { UNPACK_ENGINE_RESOURCES(Engine); - Assert(Chunk->DEBUG_OwnedByThread == 0); - Chunk->DEBUG_OwnedByThread = ThreadLocal_ThreadIndex; - Assert(Chunk->Flags & Chunk_Deallocate|Chunk_VoxelsInitialized); + Assert(Chunk->IsOnFreelist == False); - DeallocateMeshes(&Chunk->Meshes, MeshFreelist); + /* Assert( (Chunk->Flags & Chunk_Queued) == 0); */ + /* Assert( Chunk->Flags & (Chunk_Deallocate|Chunk_VoxelsInitialized)); */ - /* DeallocateGpuBuffers(RenderQueue, Chunk); */ - RangeIterator(MeshIndex, MeshIndex_Count) + if (HasGpuMesh(Chunk)) { - auto Handles = Chunk->Meshes.GpuBufferHandles+MeshIndex; - // @vertex_handle_primal - // - /* if (Handles->VertexHandle) { GL.DeleteBuffers(3, &Handles->VertexHandle); } */ - PushDeallocateBuffersCommand(RenderQ, Handles); + DeallocateHandles(LoRenderQ, &Chunk->Handles); } ClearWorldChunk(Chunk); - Assert(Chunk->DEBUG_OwnedByThread == 0); - Assert(Chunk->Flags == 0); + /* Assert(Chunk->Flags == 0); */ Assert(Chunk->Next == 0); FullBarrier; } -link_internal void -RenderLoop(thread_startup_params *ThreadParams, engine_resources *Engine) -{ - // Map immediate GPU buffers for first frame - MapGpuBuffer_untextured_3d_geometry_buffer(&Engine->Graphics.GpuBuffers[0]); - MapGpuBuffer_untextured_3d_geometry_buffer(&Engine->Graphics.Transparency.GpuBuffer); - - os *Os = &Engine->Stdlib.Os; - /* platform *Plat = &Engine->Stdlib.Plat; */ - while ( FutexNotSignaled(ThreadParams->WorkerThreadsExitFutex) ) - { - UNPACK_ENGINE_RESOURCES(Engine); - - WORKER_THREAD_ADVANCE_DEBUG_SYSTEM(); - WorkerThread_BeforeJobStart(ThreadParams); - - while (work_queue_entry *Job = PopWorkQueueEntry(RenderQ)) - { - /* TIMED_NAMED_BLOCK(RENDER_LOOP); */ - tswitch(Job) - { - 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_update_world_region: - 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: - { - InvalidCodePath(); - } break; - - - { tmatch(work_queue_entry_async_function_call, Job, RPC) - DispatchAsyncFunctionCall(RPC); - } break; - - { tmatch(work_queue_entry__bonsai_render_command, Job, RC) - tswitch(RC) - { - InvalidCase(type_work_queue_entry__bonsai_render_command_noop); - - { tmatch(bonsai_render_command_allocate_texture, RC, Command) - - texture *Texture = Command->Texture; - switch (Texture->Channels) - { - case 3: - { - *Texture = MakeTexture_RGB(Texture->Dim, (const v3*)Command->Data, Texture->DebugName, Texture->Slices, Texture->Format); - } break; - - case 4: - { - *Texture = MakeTexture_RGBA(Texture->Dim, Cast(u32*, Command->Data), Texture->DebugName, Texture->Slices, Texture->Format); - } break; - - InvalidDefaultCase; - } - - } break; - - - { tmatch(bonsai_render_command_deallocate_texture, RC, Command) - NotImplemented; - } break; - - - { tmatch(bonsai_render_command_allocate_buffers, RC, Command) - NotImplemented; - } break; - - { tmatch(bonsai_render_command_reallocate_buffers, RC, Command) - auto *Handles = Command->Handles; - auto *Mesh = Command->Mesh; - - ReallocateAndSyncGpuBuffers(Handles, Mesh); - DeallocateMesh(Mesh, &Engine->geo_u3d_MeshFreelist); - } break; - - - { tmatch(bonsai_render_command_deallocate_buffers, RC, Command) - if (*Command->Buffers) { GL.DeleteBuffers(Command->Count, Command->Buffers); } - RangeIterator(Index, Command->Count) { Command->Buffers[Index] = 0; } - } break; - - - { tmatch(bonsai_render_command_deallocate_world_chunk, RC, Command) - TIMED_NAMED_BLOCK(bonsai_render_command_deallocate_world_chunk); - world_chunk *Chunk = Command->Chunk; - FreeWorldChunk(Engine, Chunk); - } break; - - - { tmatch(bonsai_render_command_clear_all_framebuffers, RC, Command) - ClearFramebuffers(Graphics, &Engine->RTTGroup); - } break; - - - - - { tmatch(bonsai_render_command_setup_shader, RC, Command) - switch (Command->ShaderId) - { - InvalidCase(BonsaiRenderCommand_ShaderId_noop); - - case BonsaiRenderCommand_ShaderId_gBuffer: - { - SetupGBufferShader(Graphics, GetApplicationResolution(&Engine->Settings), Editor->LayeredBrushEditor.SeedBrushWithSelection); - } break; - - case BonsaiRenderCommand_ShaderId_ShadowMap: - { - SetupShadowMapShader(Graphics, GetShadowMapResolution(&Engine->Settings), Editor->LayeredBrushEditor.SeedBrushWithSelection); - } break; - } - } break; - - { tmatch(bonsai_render_command_teardown_shader, RC, Command) - switch (Command->ShaderId) - { - InvalidCase(BonsaiRenderCommand_ShaderId_noop); - - case BonsaiRenderCommand_ShaderId_gBuffer: - { - TeardownGBufferShader(Graphics); - } break; - - case BonsaiRenderCommand_ShaderId_ShadowMap: - { - TeardownShadowMapShader(Graphics); - } break; - } - } break; - - { tmatch(bonsai_render_command_set_shader_uniform, RC, Command) - shader *Shader = Command->Shader; - shader_uniform *Uniform = &Command->Uniform; - if (Uniform->ID >= 0) - { - BindUnifromById(Uniform, &Command->TextureUnit); - } - else - { - BindUniformByName(Shader, Uniform, &Command->TextureUnit); - } - } break; - - { tmatch(bonsai_render_command_draw_world_chunk_draw_list, RC, Command) - RenderDrawList(Engine, Command->DrawList, Command->Shader); - } break; - - { tmatch(bonsai_render_command_draw_all_entities, RC, Command) - DrawEntities(Command->Shader, EntityTable, &GpuMap->Buffer, 0, Graphics, World, Plat->dt); - } break; - - - - { tmatch(bonsai_render_command_do_stuff, RC, Command) - - // - // Render begin - // - - ao_render_group *AoGroup = Graphics->AoGroup; - shadow_render_group *SG = Graphics->SG; - - EngineDebug->Render.BytesSolidGeoLastFrame = GpuMap->Buffer.At; - EngineDebug->Render.BytesTransGeoLastFrame = Graphics->Transparency.GpuBuffer.Buffer.At; - - // TODO(Jesse): Make a render frame begin event to stuff this kinda thing onto? - // - // Update color texture, if necessary - // - s32 ColorCount = s32(AtElements(&Graphics->ColorPalette)); - if (ColorCount != Graphics->ColorPaletteTexture.Dim.x) - { - if (Graphics->ColorPaletteTexture.ID) { DeleteTexture(&Graphics->ColorPaletteTexture); } - Graphics->ColorPaletteTexture = - MakeTexture_RGB( V2i(ColorCount, 1), Graphics->ColorPalette.Start, CSz("ColorPalette")); - } - - // Editor preview - /* DrawStuffToGBufferTextures(Engine, GetApplicationResolution(&Engine->Settings)); */ - { - v3i Radius = World->VisibleRegion/2; - v3i Min = World->Center - Radius; - v3i Max = World->Center + Radius; - - SetupGBufferShader(Graphics, GetApplicationResolution(&Engine->Settings), False); - shader *Shader = &Graphics->gBuffer->gBufferShader; - DrawEditorPreview(Engine, Shader); - TeardownGBufferShader(Graphics); - - SetupShadowMapShader(Graphics, GetShadowMapResolution(&Engine->Settings), False); - Shader = &Graphics->SG->Shader.Program; - DrawEditorPreview(Engine, Shader); - TeardownShadowMapShader(Graphics); - } - - /* DrawWorldAndEntitiesToShadowMap(GetShadowMapResolution(&Engine->Settings), Engine); */ - - // TODO(Jesse): Move into engine debug - DebugHighlightWorldChunkBasedOnState(Graphics, EngineDebug->PickedChunk, &GpuMap->Buffer); - - AssertNoGlErrors; - - Ensure( FlushBuffersToCard(GpuMap) ); // Unmaps buffer - if (GpuMap->Buffer.At) - { - RenderImmediateGeometryToGBuffer(GetApplicationResolution(&Engine->Settings), GpuMap, Graphics); - RenderImmediateGeometryToShadowMap(GpuMap, Graphics); - } - Clear(&GpuMap->Buffer); - - // NOTE(Jesse): I observed the AO lagging a frame behind if this is re-ordered - // after the transparency/luminance textures. I have literally 0 ideas as to - // why that would be, but here we are. - if (Graphics->Settings.UseSsao) { RenderAoTexture(GetApplicationResolution(&Engine->Settings), AoGroup); } - - { - RenderTransparencyBuffers(GetApplicationResolution(&Engine->Settings), &Graphics->Settings, &Graphics->Transparency); - RenderLuminanceTexture(GetApplicationResolution(&Engine->Settings), GpuMap, Lighting, Graphics); - } - - if (Graphics->Settings.UseLightingBloom) { RunBloomRenderPass(Graphics); } - /* if (Graphics->Settings.UseLightingBloom) { GaussianBlurTexture(&Graphics->Gaussian, &Graphics->Lighting.BloomTex, &Graphics->Lighting.BloomFBO); } */ - - - CompositeGameTexturesAndDisplay(Plat, Graphics); - - UiFrameEnd(&Engine->Ui); - - BonsaiSwapBuffers(&Engine->Stdlib.Os); - - - - /* GpuMap = GetNextGpuMap(Graphics); */ - - // Map immediate GPU buffers for next frame - MapGpuBuffer_untextured_3d_geometry_buffer(GpuMap); - MapGpuBuffer_untextured_3d_geometry_buffer(&Graphics->Transparency.GpuBuffer); - Assert(GpuMap->Buffer.At == 0); - - Graphics->RenderGate = False; - - } break; - - { tmatch(bonsai_render_command_gl_timer_init, RC, Command) - AssertNoGlErrors; - GL.GenQueries(1, Command->GlTimerObject); - AssertNoGlErrors; - } break; - - { tmatch(bonsai_render_command_gl_timer_start, RC, Command) - AssertNoGlErrors; - GL.BeginQuery(GL_TIME_ELAPSED, Command->GlTimerObject); - AssertNoGlErrors; - } break; - - { tmatch(bonsai_render_command_gl_timer_end, RC, Command) - AssertNoGlErrors; - GL.EndQuery(GL_TIME_ELAPSED); - AssertNoGlErrors; - } break; - - { tmatch(bonsai_render_command_gl_timer_read_value_and_histogram, RC, Command) - AssertNoGlErrors; - u64 TimerNs = 0; - - s32 Available = False; - while (!Available) - { - GL.GetQueryObjectiv(Command->GlTimerObject, GL_QUERY_RESULT_AVAILABLE, &Available); - /* if (Available == False) { Info("Waiting for query object to become available"); } */ - } - - - GL.GetQueryObjectui64v(Command->GlTimerObject, GL_QUERY_RESULT, &TimerNs); - /* Info("GL reported time of (%.2f)ms", f64(TimerNs)/1000000.0); */ - /* GetDebugState()->PushHistogramDataPoint(TimerNs); */ - AssertNoGlErrors; - } break; - - } - } break; - } - - RewindArena(GetTranArena()); - } - - SleepMs(1); - - if (FutexIsSignaled(ThreadParams->WorkerThreadsExitFutex)) break; - - if (FutexIsSignaled(ThreadParams->WorkerThreadsSuspendFutex)) { WaitOnFutex(ThreadParams->WorkerThreadsSuspendFutex); } - } - - Info("Exiting Render Thread (%d)", ThreadParams->ThreadIndex); - WaitOnFutex(ThreadParams->WorkerThreadsExitFutex); -} - -link_export THREAD_MAIN_RETURN -RenderThread_Main(void *ThreadStartupParams) -{ - b32 InitResult = True; - thread_startup_params *ThreadParams = Cast(thread_startup_params*, ThreadStartupParams); - - Global_EngineResources = (engine_resources*)ThreadParams->EngineResources; - Global_ThreadStates = Global_EngineResources->Stdlib.ThreadStates; - Assert(Global_EngineResources); - Assert(Global_ThreadStates); - - WorkerThread_BeforeJobStart(ThreadParams); - - /* Assert(ThreadParams->ThreadIndex > 0); */ - /* SetThreadLocal_ThreadIndex(ThreadParams->ThreadIndex); */ - - engine_resources *Engine = GetEngineResources(); - os *Os = &Engine->Stdlib.Os; - platform *Plat = &Engine->Stdlib.Plat; - - PlatformMakeRenderContextCurrent(Os); - - /* s32 VSyncFrames = 0; */ - /* InitResult &= OpenAndInitializeWindow(Os, Plat, VSyncFrames); */ - - if (InitResult) { InitResult &= InitializeOpenglFunctions(); } - - if (InitResult) { InitResult &= GraphicsInit(&Engine->Graphics, &Engine->Settings, AllocateArena()); } - - if (InitResult) - { - memory_arena *UiMemory = AllocateArena(); - InitRenderer2D(&Engine->Ui, &Engine->Heap, UiMemory, &Plat->MouseP, &Plat->MouseDP, &Plat->ScreenDim, &Plat->Input); - - bitmap_block_array Bitmaps = { .Memory = GetTranArena() }; - LoadBitmapsFromFolderOrdered(CSz("assets/mystic_rpg_icon_pack/Sprites/300%/64x64_sprites"), &Bitmaps, GetTranArena(), GetTranArena()); - LoadBitmapsFromFolderOrdered(CSz("assets/mystic_rpg_icon_pack/Sprites/300%/44x44_sprites"), &Bitmaps, GetTranArena(), GetTranArena()); - Engine->Ui.SpriteTextureArray = CreateTextureArrayFromBitmapBlockArray(&Bitmaps, V2i(64,64)); - } - - FullBarrier; - - Engine->Graphics.Initialized = True; - - if (InitResult) - { - RenderLoop(ThreadParams, Engine); - } - else - { - SoftError("Render thread initiailization failed."); - } - - THREAD_MAIN_RETURN Result = ReinterpretCast(THREAD_MAIN_RETURN, InitResult); - return Result; -} - link_internal b32 InitEngineResources(engine_resources *Engine) { @@ -461,7 +93,32 @@ CancelAllWorkQueueJobs(engine_resources *Engine) CancelAllWorkQueueJobs(Plat, &Plat->HighPriority); CancelAllWorkQueueJobs(Plat, &Plat->LowPriority); - CancelAllWorkQueueJobs(Plat, &Plat->RenderQ); + /* CancelAllWorkQueueJobs(Plat, &Plat->WorldUpdateQ); */ + + // NOTE(Jesse): The RendeQ flushes before it suspends, and at the time of + // this writing the application depends on this behavior. Some render queue + // jobs have knowledge of who to call next (because we don't have a way of + // specifying the next next job when we submit one). This makes it difficult + // to free resources that are only known to the jobs.. + // + // We just call CancelAllWorkQueueJobs to reset the queues. + // + Assert(QueueIsEmpty(&Plat->HiRenderQ)); + Assert(QueueIsEmpty(&Plat->LoRenderQ)); + CancelAllWorkQueueJobs(Plat, &Plat->HiRenderQ); + CancelAllWorkQueueJobs(Plat, &Plat->LoRenderQ); + + Assert(QueueIsEmpty(&Plat->HighPriority)); + Assert(QueueIsEmpty(&Plat->LowPriority)); + + PushBonsaiRenderCommandCancelAllNoiseReadbackJobs(&Plat->LoRenderQ); + + UnsignalFutex(&Plat->WorkerThreadsSuspendFutex); + + while (!QueueIsEmpty(&Plat->HiRenderQ)) { SleepMs(1); } + while (!QueueIsEmpty(&Plat->LoRenderQ)) { SleepMs(1); } + + SignalAndWaitForWorkers(&Plat->WorkerThreadsSuspendFutex); } link_internal void @@ -479,6 +136,7 @@ HardResetAssets(engine_resources *Engine) // NOTE(Jesse): This function soft-resets the engine to a state similar to that // at which it was when the game init routine was called. This is useful when // resetting the game state. For a more invasive +#if 0 link_internal void SoftResetEngine(engine_resources *Engine, hard_reset_flags Flags = HardResetFlag_None) { @@ -486,17 +144,9 @@ SoftResetEngine(engine_resources *Engine, hard_reset_flags Flags = HardResetFlag CancelAllWorkQueueJobs(Engine); - u32 ChunksFreed = 0; - RangeIterator(HashIndex, s32(World->HashSize)) - { - if (world_chunk *Chunk = World->ChunkHash[HashIndex]) - { - Chunk->Flags = Chunk_VoxelsInitialized; - FreeWorldChunk(Engine, Chunk); - World->ChunkHash[HashIndex] = 0; - ++ChunksFreed; - } - } + FreeOctreeChildren(Engine, &World->Root); + if (World->Root.Chunk) { FreeWorldChunk(Engine, World->Root.Chunk); } + InitOctreeNode(World, &World->Root, {}, World->VisibleRegion, {}); RangeIterator_t(u32, EntityIndex, TOTAL_ENTITY_COUNT) { @@ -506,31 +156,113 @@ SoftResetEngine(engine_resources *Engine, hard_reset_flags Flags = HardResetFlag HardResetAssets(Engine); } +#endif + + + +/* link_internal void */ +/* SoftResetWorld(engine_resources *Engine) */ +/* { */ +/* world *World = Engine->World; */ + +/* MergeOctreeChildren(Engine, &World->Root); */ + +/* if (World->Root.Chunk) */ +/* { */ +/* FreeWorldChunk(Engine, World->Root.Chunk); */ +/* } */ +/* World->Root = {}; */ + +/* InitOctreeNode(World, &World->Root, {}, World->VisibleRegion); */ +/* World->Root.Chunk = AllocateWorldChunk( {}, World->ChunkDim, World->VisibleRegion, World->ChunkMemory); */ + +/* } */ + +link_internal void +HardResetWorld(engine_resources *Engine) +{ + world *World = Engine->World; + + // NOTE(Jesse): We have to walk the octree to free all the GPU buffers :/ + // We also can't do it from in here because the render thread is stopped and + // we run the risk of filling the render queue before we've freed the entire + // world. Instead, we're going to assert here and put the onus on the caller + // to free the octree before the render thread has stopped. + /* FreeOctreeChildren(Engine, &World->Root); */ + Assert(World->Root.Type == OctreeNodeType_Leaf); + Assert(World->Root.Children[0] == 0); + Assert(World->Root.Children[1] == 0); + Assert(World->Root.Children[2] == 0); + Assert(World->Root.Children[3] == 0); + Assert(World->Root.Children[4] == 0); + Assert(World->Root.Children[5] == 0); + Assert(World->Root.Children[6] == 0); + Assert(World->Root.Children[7] == 0); + + Engine->Graphics.NoiseFinalizeJobsPending = 0; + Engine->Graphics.TotalChunkJobsActive = 0; + + VaporizeArena(World->ChunkMemory); + VaporizeArena(World->OctreeMemory); + + *World = {}; + + // The game init function is responsible for allocating the world .. we just + // clear it here. + /* v3i Center = World->Center; */ + /* auto VisibleRegionSize = World->VisibleRegionSize; */ + /* AllocateWorld(World, Center, ChunkDim, VisibleRegionSize); */ +} link_internal void -HardResetEngine(engine_resources *Engine) +SoftResetGraphics(graphics *Graphics) +{ + Graphics->MainDrawList.ElementCount = 0;; + Graphics->ShadowMapDrawList.ElementCount = 0; + + Graphics->TerrainShapingRC.ReshapeFunc = {}; +} + +link_internal void +HardResetEngine(engine_resources *Engine, hard_reset_flags Flags = HardResetFlag_None) { UNPACK_ENGINE_RESOURCES(Engine); + + Info("Hard Reset Begin"); + CancelAllWorkQueueJobs(Engine); RangeIterator_t(u32, EntityIndex, TOTAL_ENTITY_COUNT) { + if ( (Flags&HardResetFlag_NoResetCamera) && Graphics->GameCamera.GhostId.Index == EntityIndex ) { continue; } Unspawn(EntityTable[EntityIndex]); } VaporizeArena(Engine->GameMemory); Engine->GameMemory = AllocateArena(); - VaporizeArena(Engine->World->ChunkMemory); - Engine->World->ChunkMemory = AllocateArena(); - HardResetEditor(&Engine->Editor); + HardResetWorld(Engine); + + SoftResetGraphics(Graphics); + // TODO(Jesse)(leak): This leaks the texture handles; make a HardResetEngineDebug() + Leak("?"); VaporizeArena(Engine->EngineDebug.Memory); Engine->EngineDebug = {}; Engine->EngineDebug.Memory = AllocateArena(); HardResetAssets(Engine); + + Assert(ThreadLocal_ThreadIndex == 0); + thread_local_state *MainThread = GetThreadLocalState(ThreadLocal_ThreadIndex); + auto GameApi = &Engine->Stdlib.AppApi; + if (GameApi->GameInit) + { + Engine->GameState = GameApi->GameInit(Engine, MainThread); + } + + Info("Hard Reset End"); } diff --git a/src/engine/resources.h b/src/engine/resources.h index 6a97866b7..9b7f31789 100644 --- a/src/engine/resources.h +++ b/src/engine/resources.h @@ -34,16 +34,18 @@ struct asset_system }; struct engine_resources +poof(@do_editor_ui) { - engine_settings Settings; + bonsai_futex ReadyToStartMainLoop; bonsai_stdlib Stdlib; + engine_api EngineApi; + + engine_settings Settings; // TODO(Jesse): Should this go in stdlib? renderer_2d Ui; - application_api GameApi; - // Engine hotkeys Hotkeys; maybe_ray MaybeMouseRay; @@ -62,6 +64,8 @@ struct engine_resources asset_system AssetSystem; + // TODO(Jesse): Rename this to FrameNumber because it's incremented at the + // beginning of the frame, meaning we never see (FrameIndex == 0) u32 FrameIndex; // At 120fps we get 9k hours (385 days) of frames in 32bits tiered_mesh_freelist geo_u3d_MeshFreelist; @@ -71,8 +75,6 @@ struct engine_resources // NOTE(Jesse): This is kinda-sorta all debug stuff // - debug_state *DebugState; - engine_debug EngineDebug; level_editor Editor; @@ -81,32 +83,43 @@ struct engine_resources maybe_entity_ptr HoverEntity; - render_entity_to_texture_group RTTGroup; + render_to_texture_group RTTGroup; + + gen_chunk_freelist GenChunkFreelist; }; -// TODO(Jesse): Should this actually be a thing? -global_variable engine_resources *Global_EngineResources; +link_internal engine_resources * +TryGetEngineResources() +{ + engine_resources *Result = 0; + if (ThreadLocal_ThreadIndex != INVALID_THREAD_LOCAL_THREAD_INDEX) + { + thread_local_state *Thread = GetThreadLocalState(ThreadLocal_ThreadIndex); + Result = Cast(engine_resources*, Thread->UserData); + } + return Result; +} link_internal engine_resources * GetEngineResources() { - Assert(Global_EngineResources); - return Global_EngineResources; + thread_local_state *Thread = GetThreadLocalState(ThreadLocal_ThreadIndex); + return Cast(engine_resources*, Thread->UserData); } link_internal engine_debug * GetEngineDebug() { - Assert(Global_EngineResources); - return &Global_EngineResources->EngineDebug; + auto Result = &GetEngineResources()->EngineDebug; + return Result; } link_internal world * GetWorld() { - Assert(Global_EngineResources); - return Global_EngineResources->World; + auto Result = GetEngineResources()->World; + return Result; } link_internal v3i @@ -115,26 +128,12 @@ GetWorldChunkDim() return GetWorld()->ChunkDim; } -link_weak bonsai_stdlib * -GetStdlib() -{ - /* Assert(Global_EngineResources); */ - if (Global_EngineResources) - { - return &Global_EngineResources->Stdlib; - } - else - { - return 0; - } -} - link_internal level_editor * GetLevelEditor() { - Assert(Global_EngineResources); - return &Global_EngineResources->Editor; + auto Result = &GetEngineResources()->Editor; + return Result; } link_internal entity * @@ -160,15 +159,16 @@ GetCameraGhost(engine_resources *Engine) 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; \ - lighting_render_group *Lighting = &Graphics->Lighting; \ - renderer_2d *Ui = &Res->Ui; \ - gpu_mapped_element_buffer *GpuMap = GetCurrentGpuMap(Graphics); \ - g_buffer_render_group *gBuffer = Graphics->gBuffer; \ - camera *Camera = Graphics->Camera; \ - work_queue *RenderQ = &Plat->RenderQ + level_editor *Editor = &Res->Editor; + +#define UNPACK_GRAPHICS_RESOURCES(Res) \ + graphics *Graphics = &Res->Graphics; \ + lighting_render_group *Lighting = &Graphics->Lighting; \ + renderer_2d *Ui = &Res->Ui; \ + g_buffer_render_group *gBuffer = Graphics->gBuffer; \ + camera *Camera = Graphics->Camera; \ + camera *GameCamera = &Graphics->GameCamera; \ + work_queue *HiRenderQ = &Plat->HiRenderQ; \ + work_queue *LoRenderQ = &Plat->LoRenderQ; \ + triple_buffered_gpu_mapped_element_buffer *GpuMap = &Graphics->ImmediateGeometry diff --git a/src/engine/serdes.cpp b/src/engine/serdes.cpp index 958244a4e..4e2a79ad2 100644 --- a/src/engine/serdes.cpp +++ b/src/engine/serdes.cpp @@ -24,6 +24,9 @@ poof(serdes_cursor(v3)) poof(serdes_struct(canonical_position)) #include +poof(serdes_struct(m4)) +#include + poof(serdes_struct(plane)) #include @@ -52,8 +55,8 @@ poof(serdes_struct(world_chunk_0)) link_internal void Marshal(world_chunk_0 *Stored, world_chunk *Live) { -poof(default_marshal(world_chunk_0)) -#include +/* poof(default_marshal(world_chunk_0)) */ +/* #include */ } @@ -152,8 +155,9 @@ Serialize(u8_cursor_block_array *Bytes, chunk_data *Data, umm Count = 1) if (ElementCount) { - Serialize(Bytes, Data->Voxels, ElementCount); - Serialize(Bytes, Data->VoxelLighting, ElementCount); + NotImplemented; + /* Serialize(Bytes, Data->Voxels, ElementCount); */ + /* Serialize(Bytes, Data->VoxelLighting, ElementCount); */ } #endif @@ -170,13 +174,14 @@ Deserialize(u8_stream *Bytes, chunk_data *Data, memory_arena *Memory, umm Count Result &= ReadBytesIntoBuffer(Bytes, Cast(u8*, Data), sizeof(chunk_data)); umm ElementCount = umm(Volume(Data->Dim)); - Data->Voxels = 0; - Data->VoxelLighting = 0; + /* Data->Voxels = 0; */ + /* Data->VoxelLighting = 0; */ if (ElementCount) { - Result &= Deserialize(Bytes, Data->Voxels, Memory, ElementCount); - Result &= Deserialize(Bytes, Data->VoxelLighting, Memory, ElementCount); + NotImplemented; + /* Result &= Deserialize(Bytes, Data->Voxels, Memory, ElementCount); */ + /* Result &= Deserialize(Bytes, Data->VoxelLighting, Memory, ElementCount); */ } #endif @@ -271,6 +276,9 @@ poof(serdes_struct(rect3)) poof(serdes_struct(rect3i)) #include +poof(serdes_struct(rect3cp)) +#include + poof(serdes_struct(random_series)) #include @@ -366,138 +374,17 @@ poof(serialize_struct(entity)) poof( block_array(entity, {4}) ) #include - - - -#if 0 -link_internal void -Marshal(entity_1 *E0, entity_2 *E1) -{ - E1->Id = E0->Id; - E1->P = E0->P; - E1->EulerAngles = E0->EulerAngles.xyz; - E1->Scale = E0->Scale; - E1->_CollisionVolumeRadius = E0->_CollisionVolumeRadius; - E1->Physics = E0->Physics; - - E1->AssetId = E0->AssetId; - E1->AssetId.Index = INVALID_ASSET_INDEX; - - E1->Emitter = E0->Emitter; - E1->State = E0->State; - E1->Behavior = E0->Behavior; - E1->UserType = E0->UserType; - E1->UserData = E0->UserData; -} -#endif - -link_internal void -Marshal(lighting_settings_0 *E0, lighting_settings *E1) -{ - NotImplemented; -} - -poof(serdes_struct(lighting_settings_0)) -#include - poof(serdes_struct(lighting_settings)) #include - - - - - -link_internal void -Marshal(render_settings_0 *E0, render_settings *E1) -{ - poof(func (render_settings_0 settings_t) { - settings_t.map(member) { - E1->(member.name) = E0->(member.name); - } - }) -#include -} - -poof(deserialize_struct(render_settings_0)) -#include - poof(serdes_struct(render_settings)) #include -/* poof(serdes_struct(member_info)) */ -/* #include */ -/* poof(serdes_struct(member_info_block)) */ -/* #include */ -/* poof(serdes_struct(member_info_block_array)) */ -/* #include */ poof(serdes_struct(bonsai_type_info)) #include poof(serdes_struct(bonsai_type_info_buffer)) #include -/* poof(serdes_struct(bonsai_type_info_linked_list_node)) */ -/* #include */ -/* poof(serdes_struct(bonsai_type_info_hashtable)) */ -/* #include */ - -/* poof(serdes_struct(level_header)) */ -/* #include */ - - -link_internal void -Marshal(level_header_0 *E0, level_header *E1) -{ - E1->ChunkCount = E0->ChunkCount; - E1->EntityCount = E0->EntityCount; - E1->WorldFlags = E0->WorldFlags; - E1->WorldCenter = E0->WorldCenter; - E1->VisibleRegion = E0->VisibleRegion; - E1->Camera = E0->Camera; -} - -link_internal void -Marshal(level_header_1 *E0, level_header *E1) -{ - E1->ChunkCount = E0->ChunkCount; - E1->EntityCount = E0->EntityCount; - E1->WorldFlags = E0->WorldFlags; - E1->WorldCenter = E0->WorldCenter; - E1->VisibleRegion = E0->VisibleRegion; - E1->Camera = E0->Camera; -} - -link_internal void -Marshal(level_header_2 *E0, level_header *E1) -{ - E1->ChunkCount = E0->ChunkCount; - E1->EntityCount = E0->EntityCount; - E1->WorldFlags = E0->WorldFlags; - E1->WorldCenter = E0->WorldCenter; - E1->VisibleRegion = E0->VisibleRegion; - E1->Camera = E0->Camera; -} - -link_internal void -Marshal(level_header_3 *Stored, level_header *Live) -{ - poof(default_marshal(level_header_3)) -#include -} - - -poof(deserialize_struct(level_header_0)) -#include - -poof(deserialize_struct(level_header_1)) -#include - -poof(deserialize_struct(level_header_2)) -#include - -poof(deserialize_struct(level_header_3)) -#include - poof(deserialize_struct(level_header)) #include @@ -529,30 +416,57 @@ poof(serdes_struct(noise_layer_0)) #include poof(serdes_struct(noise_layer)) #include + +poof(serdes_struct(world_update_op_shape_params_asset)) +#include +poof(serdes_struct(world_update_op_shape_params_chunk_data)) +#include + poof(serdes_struct(world_update_op_shape_params_rect)) #include poof(serdes_struct(world_update_op_shape_params_sphere)) #include +poof(serdes_struct(world_update_op_shape_params_line)) +#include +poof(serdes_struct(world_update_op_shape_params_cylinder)) +#include +poof(serdes_struct(world_update_op_shape_params_plane)) +#include +poof(serdes_struct(world_update_op_shape_params_torus)) +#include +// @sdf_shape_step(3): Add new asset struct here to generate serialization code +// + +poof(serdes_struct(shape_layer_advanced_params)) +#include + poof(serdes_struct(shape_layer)) #include -poof(serdes_struct(brush_settings_0)) -#include -poof(serdes_struct(brush_settings_1)) -#include -poof(serdes_struct(brush_settings_2)) -#include + poof(serdes_struct(brush_settings)) #include poof(serdes_struct(brush_layer)) #include -poof(serdes_struct(layered_brush_editor_0)) -#include -poof(serdes_struct(layered_brush_editor_1)) -#include -poof(serdes_struct(layered_brush_editor_2)) -#include -poof(serdes_struct(layered_brush_editor)) -#include +/* poof(serdes_dunion(world_edit_shape)) */ +/* #include */ + +poof(serdes_struct(layered_brush)) +#include + +poof(serdes_struct(world_edit_brush)) +#include + +poof(serdes_struct(world_edit)) +#include + +poof(serdes_struct(world_edit_block_array_index)) +#include + +poof(serdes_collection(world_edit_block_array_index, {block_array})) +#include + +poof(serdes_struct(world_edit_layer)) +#include diff --git a/src/engine/serdes.h b/src/engine/serdes.h index bde7aefe9..8b3117609 100644 --- a/src/engine/serdes.h +++ b/src/engine/serdes.h @@ -155,7 +155,7 @@ poof( { Assert(Count > 0); - u64 PointerTrue = True; + u64 PointerTrue = True; u64 PointerFalse = False; b32 Result = True; @@ -189,7 +189,7 @@ poof( { member.is_enum? { - Result &= Serialize(Bytes, (u32*)&Element->(member.name)); + Result &= Serialize(Bytes, (u32*)&Element->(member.name)); // enum } { member.is_array? @@ -198,7 +198,7 @@ poof( member.has_tag(array_length)? { // TODO(Jesse): Should this really be a safe cast? - umm ThisCount = umm(Element->member.tag_value(array_length)); + umm ThisCount = umm((member.tag_value(array_length))); } { umm ThisCount = member.array; @@ -207,7 +207,13 @@ poof( } } { - Result &= Serialize(Bytes, &Element->(member.name)); + member.name? + { + Result &= Serialize(Bytes, &Element->(member.name)); // default + } + { + /// NOTE(Jesse): This path is here because of a bug in poof, issue #19 + } } } } @@ -312,7 +318,7 @@ poof( member.has_tag(array_length)? { // TODO(Jesse): Should this really be a safe cast? - umm Count = umm(Element->member.tag_value(array_length)); + umm Count = umm((member.tag_value(array_length))); } { umm Count = member.array; @@ -444,6 +450,47 @@ poof( } ) +poof( + func serdes_collection(element_type, type_poof_symbol collection_name ) + { + @var collection_type (element_type.name)_(collection_name) + + link_internal b32 + Serialize( u8_cursor_block_array *Bytes, collection_type *Collection) + { + auto i = AtElements(Collection); + u64 ElementCount = u64(GetIndex(&i)); + b32 Result = Write(Bytes, ElementCount); + + IterateOver(Collection, Element, EIndex) + { + Result &= Serialize(Bytes, Element); + } + + MAYBE_WRITE_DEBUG_OBJECT_DELIM(); + return Result; + } + + link_internal b32 + Deserialize( u8_cursor *Bytes, collection_type *Collection, memory_arena *Memory) + { + u64 ElementCount = Read_u64(Bytes); + Collection->Memory = Memory; + + b32 Result = True; + RangeIterator_t(u64, EIndex, ElementCount) + { + element_type.name Element = {}; + Result &= Deserialize(Bytes, &Element, Memory); + Push(Collection, &Element); + } + + MAYBE_READ_DEBUG_OBJECT_DELIM(); + return Result; + } + } +) + poof( func serdes_struct(type) { @@ -460,6 +507,43 @@ poof( } ) +poof( + func serdes_dunion(type) + { + link_internal b32 + Serialize(u8_cursor_block_array *Bytes, (type.name) *BaseElement, umm Count = 1) + { + switch (BaseElement->Type) + { + type.map_members(union_member) + { + union_member.has_tag(d_union_type_target)? + { + union_member.map(variant) + { + case type_(variant.name): + { + Serialize(Bytes, &BaseElement->(variant.name)); + } break; + } + } + } + + InvalidDefaultCase; + } + + return False; + } + + link_internal b32 + Deserialize(u8_cursor *Bytes, (type.name) *Element, memory_arena *Memory, umm Count = 1) + { + NotImplemented; + return False; + } + } +) + // TODO(Jesse): Do this in terms of poof tag @array_length link_internal b32 diff --git a/src/engine/serialize.cpp b/src/engine/serialize.cpp index d452bc341..51bfbaf7f 100644 --- a/src/engine/serialize.cpp +++ b/src/engine/serialize.cpp @@ -3,10 +3,12 @@ link_internal u8_cursor_block_array BeginSerialization() { + Assert(Global_SerializeTypeTableArena == 0); + Global_SerializeTypeTableArena = AllocateArena(); Global_SerializeTypeTable = Allocate_bonsai_type_info_hashtable(64, Global_SerializeTypeTableArena); - u8_cursor_block_array Blocks = {}; + u8_cursor_block_array Blocks = U8CursorBlockArray(Global_SerializeTypeTableArena); { Blocks.BlockSize = Megabytes(32); u8_cursor First = U8Cursor(Blocks.BlockSize, Global_SerializeTypeTableArena); @@ -19,7 +21,7 @@ BeginSerialization() link_internal b32 FinalizeSerialization(u8_cursor_block_array *Blocks, const char *Filename) { - u8_cursor_block_array TypeBufferOutputStream = {}; + u8_cursor_block_array TypeBufferOutputStream = U8CursorBlockArray(Global_SerializeTypeTableArena); { TypeBufferOutputStream.BlockSize = Megabytes(32); @@ -68,6 +70,8 @@ BeginDeserialization(cs Filename, memory_arena *TempMemory) // TODO(Jesse): Audit .level savefiles and remove this.. it's hella legacy case 0: { + Assert(Global_SerializeTypeTable.Size == 0); + Assert(Global_SerializeTypeTable.Elements == 0); Global_SerializeTypeTable = Allocate_bonsai_type_info_hashtable(64, Global_SerializeTypeTableArena); { @@ -96,6 +100,9 @@ BeginDeserialization(cs Filename, memory_arena *TempMemory) { bonsai_type_info_buffer TypeInfoBuffer = {}; Deserialize(&LevelBytes, &TypeInfoBuffer, Global_SerializeTypeTableArena); + + Assert(Global_SerializeTypeTable.Size == 0); + Assert(Global_SerializeTypeTable.Elements == 0); Global_SerializeTypeTable = Allocate_bonsai_type_info_hashtable(NextPowerOfTwo(TypeInfoBuffer.Count), Global_SerializeTypeTableArena); IterateOver(&TypeInfoBuffer, TypeInfo, TypeInfoIndex) @@ -104,7 +111,7 @@ BeginDeserialization(cs Filename, memory_arena *TempMemory) } } break; - default: { SoftError("Could not load level file claiming version (%lu), bailing.", LevelHeaderVersion); } + default: { SoftError("Could not load level file claiming version (%lu), bailing.", LevelHeaderVersion); LevelBytes = {}; } } } return LevelBytes; diff --git a/src/engine/settings.h b/src/engine/settings.h index f155724c9..d8441dd7a 100644 --- a/src/engine/settings.h +++ b/src/engine/settings.h @@ -33,6 +33,7 @@ poof(string_and_value_tables(shader_language_setting)); #include struct graphics_settings +poof(@do_editor_ui) { resolution_setting Resolution; shadow_quality_setting ShadowQuality; @@ -42,6 +43,7 @@ struct graphics_settings }; struct engine_settings +poof(@do_editor_ui) { graphics_settings Graphics; }; diff --git a/src/engine/shader.cpp b/src/engine/shader.cpp index 3f60fb054..0df4e9cf3 100644 --- a/src/engine/shader.cpp +++ b/src/engine/shader.cpp @@ -1,7 +1,7 @@ -poof(gen_shader_uniform_push(camera)); +poof(set_shader_uniform(camera)); #include -poof(gen_shader_uniform_push(light)); +poof(set_shader_uniform(light)); #include @@ -12,19 +12,23 @@ BindEngineUniform(shader_uniform *Uniform) { TIMED_FUNCTION(); + s32 Count = Uniform->Count ? s32(*Uniform->Count) : 1; + switch(Uniform->Type) { case ShaderUniform_Light: { TIMED_BLOCK("ShaderUniform_Light"); - GL.Uniform3fv(Uniform->ID, 1, &Uniform->Light->Position.E[0]); + Assert(Count); + GetGL()->Uniform3fv(Uniform->ID, Count, &Uniform->Light->Position.E[0]); END_BLOCK(); } break; case ShaderUniform_Camera: { TIMED_BLOCK("ShaderUniform_Camera"); - GL.Uniform3fv(Uniform->ID, 1, &Uniform->Camera->RenderSpacePosition.E[0]); + Assert(Count); + GetGL()->Uniform3fv(Uniform->ID, Count, &Uniform->Camera->RenderSpacePosition.E[0]); END_BLOCK(); } break; diff --git a/src/engine/shader.h b/src/engine/shader.h new file mode 100644 index 000000000..7587cb0e1 --- /dev/null +++ b/src/engine/shader.h @@ -0,0 +1,2 @@ +b32 InitShaderUniform(shader *Shader, u32 Index, camera *Value, const char *Name); +b32 InitShaderUniform(shader *Shader, u32 Index, camera *Value, const char *Name, u16 Count); diff --git a/src/engine/terrain.cpp b/src/engine/terrain.cpp index 7c9985fae..460311272 100644 --- a/src/engine/terrain.cpp +++ b/src/engine/terrain.cpp @@ -1,3 +1,591 @@ +link_internal u32 +Terrain_Flat( world_chunk *Chunk, + v3i NoiseBasis, + void *NoiseParams, + void *UserData ) +{ + UNPACK_NOISE_PARAMS(NoiseParams); + + u32 Result = 0; + for ( s32 z = 0; z < Chunk->Dim.z; ++ z) + { + /* s64 WorldZ = s64(z - zMin + NoiseBasis.z + (GetWorldChunkDim().z*Chunk->WorldP.z)); */ + for ( s32 y = 0; y < Chunk->Dim.y; ++ y) + { + for ( s32 x = 0; x < Chunk->Dim.x; ++ x) + { + if ((z + NoiseBasis.z) < Thresh) + { + s32 Index = GetIndex(Voxel_Position(x,y,z), Chunk->Dim); + SetOccupancyBit(Chunk, Index, VoxelOccupancy_Filled); + /* Chunk->Voxels[Index].Flags = Voxel_Filled; */ + Chunk->Voxels[Index].Color = RGBtoPackedHSV(RGBColor); + ++Result; + } + } + } + } + + return Result;; +} + + +global_variable random_series DEBUG_ENTROPY = {653765435432}; + +// 27.0m cycles | f32 ComputePerlinParameters +// +// 30.0m cycles | u32 ComputePerlinParameters +// 28.7m cycles | u32 ComputePerlinParameters +// 27.6m cycles | u32 ComputePerlinParameters +// 24.3m cycles | u32 ComputePerlinParameters +// 19.3m cycles | u32 ComputePerlinParameters +// +#if 0 +// NOTE(Jesse): I broke the non-upsampling path when I added upsampling.. +link_internal u32 +Terrain_FBM2D_upsample_broken( world_chunk *Chunk, + v3i NoiseBasis, + void *NoiseParams, + void *OctaveCount ) +{ + /* TIMED_FUNCTION(); */ + HISTOGRAM_FUNCTION(); + + UNPACK_NOISE_PARAMS(NoiseParams); + + + random_series GenColorEntropy = {12653763234231}; + + Period = Max(Period, V3(1.f)); + + auto PrimeX = U32_8X(501125321); + auto PrimeY = 1136930381u; + auto PrimeZ = 1720413743u; + + u16 PackedHSVColorValue = RGBtoPackedHSV(RGBColor); + + + s32 Octaves = *(s32*)OctaveCount; + +#if 0 + s32 MinZ = Chunk->WorldP.z*WorldChunkDim.z; + s32 MaxZ = MinZ+WorldChunkDim.z ; + + if (MaxZ < -Amplitude) + { + s32 MaxIndex = Volume(Dim); + for ( s32 VoxIndex = 0; VoxIndex < MaxIndex; ++VoxIndex) + { + Chunk->Voxels[VoxIndex].Flags = Voxel_Filled; + Chunk->Voxels[VoxIndex].Color = RGBtoPackedHSV(RGBColor); + } + return (u32)MaxIndex; + } + + if (MinZ > Amplitude) + return ChunkSum; +#endif + + memory_arena *TempArena = GetTranArena(); + + s32 NoiseUpsampleFactor = 1; + /* s32 NoiseUpsampleFactor = 4; */ + + v3i NoiseDim = RoundUp((Chunk->Dim+V3i(2,0,0)), V3i(8*NoiseUpsampleFactor, 1, 1)); + v3i NormalsDim = RoundUp((Chunk->Dim-V3i(0,2,2)), V3i(8*NoiseUpsampleFactor, 1, 1)); + + /* v3i NoiseDim = RoundUp((Chunk->Dim+V3i(2,0,0)), V3i(8, 1, 1)); */ + /* v3i NormalsDim = RoundUp((Chunk->Dim-V3i(0,2,2)), V3i(8, 1, 1)); */ + + Assert(Chunk->Dim == V3i(64, 66, 66)); + Assert(NormalsDim == V3i(64)); + + // NOTE(Jesse): This must hold true for using any Noise_8x func + Assert(NoiseDim.x % 8 == 0); + + s32 NoiseValuesCount = Volume(NoiseDim); + s32 NormalValuesCount = Volume(NormalsDim); + + // + r32 *NoiseValues = AllocateAligned(r32, TempArena, NoiseValuesCount, 32); + v3 *Normals = AllocateAligned( v3, TempArena, NormalValuesCount, 32); + // NOTE(Jesse): Must be true to use _mm256_store_ps, which we do in the 16x version of perlin + Assert(u64(NoiseValues) % 32 == 0); + + /* u32 Offset = 200'000'000; */ + /* v3i WorldBasis = V3i(Offset, Offset, 0) + NoiseBasis + (Chunk->WorldP*GetWorldChunkDim()); */ + v3i WorldBasis = NoiseBasis + (Chunk->WorldP*GetWorldChunkDim()); + + { + u32_8x xChunkResolution = U32_8X(u32(Chunk->DimInChunks.x)); + u32 yChunkResolution = u32(Chunk->DimInChunks.y); + u32 zChunkResolution = u32(Chunk->DimInChunks.z); + + u32 *zPeriods = Allocate(u32, TempArena, Octaves); + u32 *yPeriods = Allocate(u32, TempArena, Octaves); + avx_divisor *xPeriods = AllocateAligned(avx_divisor, TempArena, Octaves, 32); + + perlin_params *xParams = AllocateAligned(perlin_params, TempArena, NoiseDim.x*Octaves*2, 32); + perlin_params *yParams = AllocateAligned(perlin_params, TempArena, NoiseDim.y*Octaves*2, 32); + perlin_params *zParams = AllocateAligned(perlin_params, TempArena, NoiseDim.z*Octaves*2, 32); + + + + + v3i InteriorPeriod = V3i(Period); + RangeIterator(OctaveIndex, Octaves) + { + zPeriods[OctaveIndex] = u32(InteriorPeriod.z); + yPeriods[OctaveIndex] = u32(InteriorPeriod.y); + xPeriods[OctaveIndex] = AvxDivisor(u32(InteriorPeriod.x)); + InteriorPeriod = Max(V3i(1), InteriorPeriod/2); + } + + u64 StartingCycles = __rdtsc(); + { + TIMED_NAMED_BLOCK(precalculate_parameters); + + for ( s32 zNoise = 0; zNoise < NoiseDim.z; ++ zNoise) + { + RangeIterator(OctaveIndex, Octaves) + { + s32 i = OctaveIndex+(zNoise*Octaves); + zParams[i] = ComputePerlinParameters_scalar(u32(WorldBasis.z), u32(zNoise), zChunkResolution, zPeriods[OctaveIndex], PrimeZ); + } + } + + for ( s32 yNoise = 0; yNoise < NoiseDim.y; ++ yNoise) + { + RangeIterator(OctaveIndex, Octaves) + { + s32 i = OctaveIndex+(yNoise*Octaves); + yParams[i] = ComputePerlinParameters_scalar(u32(WorldBasis.y), u32(yNoise), yChunkResolution, yPeriods[OctaveIndex], PrimeY); + } + } + + s32 _xCoordsCount = NoiseDim.x*NoiseUpsampleFactor; + u32 *_xCoords = AllocateAligned(u32, TempArena, _xCoordsCount, 32); + for ( s32 xNoise = 0; xNoise < _xCoordsCount; ++ xNoise ) + { + /* _xCoords[xNoise] = u32(xNoise); */ + _xCoords[xNoise] = u32(xNoise) - 1; + } + + for ( s32 xNoise = 0; xNoise < NoiseDim.x; xNoise += 8 ) + { + /* auto _x = U32_8X(_xCoords+xNoise); */ + auto _x = U32_8X( + _xCoords[xNoise+(0*NoiseUpsampleFactor)], + _xCoords[xNoise+(1*NoiseUpsampleFactor)], + _xCoords[xNoise+(2*NoiseUpsampleFactor)], + _xCoords[xNoise+(3*NoiseUpsampleFactor)], + _xCoords[xNoise+(4*NoiseUpsampleFactor)], + _xCoords[xNoise+(5*NoiseUpsampleFactor)], + _xCoords[xNoise+(6*NoiseUpsampleFactor)], + _xCoords[xNoise+(7*NoiseUpsampleFactor)] ); + + RangeIterator(OctaveIndex, Octaves) + { + s32 i = OctaveIndex+(xNoise*Octaves); + xParams[i] = ComputePerlinParameters_vector(U32_8X(WorldBasis.x), _x, xChunkResolution, xPeriods[OctaveIndex], PrimeX); + } + } + } + + f32 OctaveAmplitudeMax = {}; + + { + r32 InteriorAmp = r32(Amplitude); + RangeIterator(OctaveIndex, Octaves) + { + OctaveAmplitudeMax += InteriorAmp; + InteriorAmp = Max(1.f, InteriorAmp/2.f); + } + } + + { + TIMED_NAMED_BLOCK(octaves); + for ( s32 zNoise = 0; zNoise < NoiseDim.z; ++ zNoise) + { + for ( s32 yNoise = 0; yNoise < NoiseDim.y; ++ yNoise) + { + for ( s32 xNoise = 0; xNoise < NoiseDim.x; xNoise += 8*NoiseUpsampleFactor ) + { + s32 NoiseIndex = GetIndex(xNoise, yNoise, zNoise, NoiseDim); + + const s32 SampleCount = 8; + alignas(32) f32_8x Samples = {}; + + r32 InteriorAmp = r32(Amplitude); + RangeIterator(OctaveIndex, Octaves) + { + auto zParam = zParams+OctaveIndex+(zNoise*Octaves); + auto yParam = yParams+OctaveIndex+(yNoise*Octaves); + auto xParam = xParams+OctaveIndex+(xNoise*Octaves); + + /* PerlinNoise_8x_avx2(xParam, yParam, zParam, NoiseValues+NoiseIndex, InteriorAmp); */ + PerlinNoise_8x_avx2(xParam, yParam, zParam, Samples.E, InteriorAmp); + InteriorAmp = Max(1.f, InteriorAmp/2.f); + } + + f32_8x OffsetSamples = StaticShuffle_avx(Samples, 1, 2, 3, 4, 5, 6, 7, 7); + f32_8x BlendedSamples = Lerp8x(F32_8X(0.5f), Samples, OffsetSamples); + + RangeIterator(SampleIndex, SampleCount) + { + /* RangeIterator(UpsampleIndex, NoiseUpsampleFactor) */ + { + s32 UpsampleIndex = 0; + NoiseValues[NoiseIndex+(SampleIndex*NoiseUpsampleFactor)+UpsampleIndex] += Samples.E[SampleIndex]; + UpsampleIndex = 1; + NoiseValues[NoiseIndex+(SampleIndex*NoiseUpsampleFactor)+UpsampleIndex] += BlendedSamples.E[SampleIndex]; + } + } + + } + } + } + } + + u64 EndingCycles = __rdtsc(); + u64 ElapsedCycles = EndingCycles - StartingCycles; + GetEngineDebug()->ChunkGenCyclesElapsed += ElapsedCycles; + GetEngineDebug()->CellsGenerated += u64(Volume(NoiseDim))*u64(Octaves)*u64(NoiseUpsampleFactor); + + + ComputeNormalsForChunkFromNoiseValues_avx( NoiseValues, NoiseDim, Normals, NormalsDim); + /* ComputeNormalsForChunkFromNoiseValues( NoiseValues, NoiseDim, Normals, NormalsDim); */ + + } + +#if 1 + u32 ChunkSum = FinalizeOccupancyMasksFromNoiseValues(Chunk, WorldBasis, NoiseDim, NoiseValues, SrcToDest, zMin, PackedHSVColorValue); +#else + + if (ChunkSum) + { + auto BuildMeshJob = WorkQueueEntry(WorkQueueEntryBuildChunkMesh({INVALID_PBO_HANDLE,0}, NoiseValues, NoiseDim, Chunk)); + thread_local_state *Thread = GetThreadLocalState(ThreadLocal_ThreadIndex); + HandleJob(&BuildMeshJob, Thread, &GetEngineResources()->GameApi); + } + u32 ChunkSum = Chunk->FilledCount; +#endif + return ChunkSum; +} +#endif + +link_internal u32 +Terrain_FBM2D( world_chunk *Chunk, + v3i NoiseBasis, + void *NoiseParams, + void *OctaveCount ) +{ +#if 0 + /* TIMED_FUNCTION(); */ + HISTOGRAM_FUNCTION(); + + UNPACK_NOISE_PARAMS(NoiseParams); + + u32 ChunkSum = 0; + + random_series GenColorEntropy = {12653763234231}; + + Period = Max(Period, V3(1.f)); + + auto PrimeX = U32_8X(501125321); + auto PrimeY = 1136930381u; + auto PrimeZ = 1720413743u; + + u16 PackedHSVColorValue = RGBtoPackedHSV(RGBColor); + + + s32 Octaves = *(s32*)OctaveCount; + +#if 0 + s32 MinZ = Chunk->WorldP.z*WorldChunkDim.z; + s32 MaxZ = MinZ+WorldChunkDim.z ; + + if (MaxZ < -Amplitude) + { + s32 MaxIndex = Volume(Dim); + for ( s32 VoxIndex = 0; VoxIndex < MaxIndex; ++VoxIndex) + { + Chunk->Voxels[VoxIndex].Flags = Voxel_Filled; + Chunk->Voxels[VoxIndex].Color = RGBtoPackedHSV(RGBColor); + } + return (u32)MaxIndex; + } + + if (MinZ > Amplitude) + return ChunkSum; +#endif + + memory_arena *TempArena = GetTranArena(); + + s32 NoiseUpsampleFactor = 1; + + /* v3i NoiseDim = RoundUp(Chunk->Dim/2, V3i(8)); */ + /* v3i NoiseDim = RoundUp((Chunk->Dim+2)/NoiseUpsampleFactor, V3i(8, 1, 1)); */ + v3i NoiseDim = RoundUp((Chunk->Dim+V3i(2,0,0))/NoiseUpsampleFactor, V3i(8, 1, 1)); + v3i NormalsDim = RoundUp((Chunk->Dim-V3i(0,2,2))/NoiseUpsampleFactor, V3i(8, 1, 1)); + + Assert(Chunk->Dim == V3i(64, 66, 66)); + Assert(NormalsDim == V3i(64)); + + /* v3i NoiseDim = Chunk->Dim; */ + // NOTE(Jesse): This must hold true for using any Noise_16x func + Assert(NoiseDim.x % 8 == 0); + + + /* v3i NoiseDim = Chunk->Dim + 2; */ + s32 NoiseValuesCount = Volume(NoiseDim); + s32 NormalValuesCount = Volume(NormalsDim); + // + // NOTE(Jesse): Have to add 1 to compute the normals because on the last + // iteration we go +1 in the x direction. This is super garbage/sketchy and + // I hate it, but I don't have a better solution for now. + r32 *NoiseValues = AllocateAligned(r32, TempArena, NoiseValuesCount+1, 32); + v3 *Normals = AllocateAligned( v3, TempArena, NormalValuesCount , 32); + // NOTE(Jesse): Must be true to use _mm256_store_ps, which we do in the 16x version of perlin + Assert(u64(NoiseValues) % 32 == 0); + + v3i WorldBasis = NoiseBasis + (Chunk->WorldP*GetWorldChunkDim()); + { + u32_8x xChunkResolution = U32_8X(u32(Chunk->DimInChunks.x)); + u32 yChunkResolution = u32(Chunk->DimInChunks.y); + u32 zChunkResolution = u32(Chunk->DimInChunks.z); + + u32 *zPeriods = Allocate(u32, TempArena, Octaves); + u32 *yPeriods = Allocate(u32, TempArena, Octaves); + avx_divisor *xPeriods = AllocateAligned(avx_divisor, TempArena, Octaves, 32); + + perlin_params *xParams = AllocateAligned(perlin_params, TempArena, NoiseDim.x*Octaves*2, 32); + perlin_params *yParams = AllocateAligned(perlin_params, TempArena, NoiseDim.y*Octaves*2, 32); + perlin_params *zParams = AllocateAligned(perlin_params, TempArena, NoiseDim.z*Octaves*2, 32); + + /* u32 Offset = 200'000'000; */ + /* v3i WorldBasis = V3i(Offset, Offset, 0) + NoiseBasis + (Chunk->WorldP*GetWorldChunkDim()); */ + + + + v3i InteriorPeriod = V3i(Period); + RangeIterator(OctaveIndex, Octaves) + { + zPeriods[OctaveIndex] = u32(InteriorPeriod.z); + yPeriods[OctaveIndex] = u32(InteriorPeriod.y); + xPeriods[OctaveIndex] = AvxDivisor(u32(InteriorPeriod.x)); + InteriorPeriod = Max(V3i(1), InteriorPeriod/2); + } + + u64 StartingCycles = __rdtsc(); + { + TIMED_NAMED_BLOCK(precalculate_parameters); + + for ( s32 zNoise = 0; zNoise < NoiseDim.z; ++ zNoise) + { + RangeIterator(OctaveIndex, Octaves) + { + s32 i = OctaveIndex+(zNoise*Octaves); + zParams[i] = ComputePerlinParameters_scalar(u32(WorldBasis.z), u32(zNoise), zChunkResolution, zPeriods[OctaveIndex], PrimeZ); + } + } + + for ( s32 yNoise = 0; yNoise < NoiseDim.y; ++ yNoise) + { + RangeIterator(OctaveIndex, Octaves) + { + s32 i = OctaveIndex+(yNoise*Octaves); + yParams[i] = ComputePerlinParameters_scalar(u32(WorldBasis.y), u32(yNoise), yChunkResolution, yPeriods[OctaveIndex], PrimeY); + } + } + + u32 *_xCoords = AllocateAligned(u32, TempArena, NoiseDim.x, 32); + for ( s32 xNoise = 0; xNoise < NoiseDim.x; ++ xNoise ) + { + _xCoords[xNoise] = u32(xNoise-1); + } + + for ( s32 xNoise = 0; xNoise < NoiseDim.x; xNoise += 8 ) + { + auto _x = U32_8X(_xCoords+xNoise); + RangeIterator(OctaveIndex, Octaves) + { + s32 i = OctaveIndex+(xNoise*Octaves); + xParams[i] = ComputePerlinParameters_vector(U32_8X(WorldBasis.x), _x, xChunkResolution, xPeriods[OctaveIndex], PrimeX); + } + } + } + + f32 OctaveAmplitudeMax = {}; + + { + r32 InteriorAmp = r32(Amplitude); + RangeIterator(OctaveIndex, Octaves) + { + OctaveAmplitudeMax += InteriorAmp; + InteriorAmp = Max(1.f, InteriorAmp/2.f); + } + } + + { + TIMED_NAMED_BLOCK(octaves); + for ( s32 zNoise = 0; zNoise < NoiseDim.z; ++ zNoise) + { + for ( s32 yNoise = 0; yNoise < NoiseDim.y; ++ yNoise) + { + for ( s32 xNoise = 0; xNoise < NoiseDim.x; xNoise += 8 ) + { + s32 NoiseIndex = GetIndex(xNoise, yNoise, zNoise, NoiseDim); + + r32 InteriorAmp = r32(Amplitude); + RangeIterator(OctaveIndex, Octaves) + { + auto zParam = zParams+OctaveIndex+(zNoise*Octaves); + auto yParam = yParams+OctaveIndex+(yNoise*Octaves); + auto xParam = xParams+OctaveIndex+(xNoise*Octaves); + PerlinNoise_8x_avx2(xParam, yParam, zParam, NoiseValues+NoiseIndex, InteriorAmp); + InteriorAmp = Max(1.f, InteriorAmp/2.f); + } + } + } + } + } + + u64 EndingCycles = __rdtsc(); + u64 ElapsedCycles = EndingCycles - StartingCycles; + GetEngineDebug()->ChunkGenCyclesElapsed += ElapsedCycles; + GetEngineDebug()->CellsGenerated += u64(Volume(NoiseDim))*u64(Octaves); + } + + ComputeNormalsForChunkFromNoiseValues_avx( NoiseValues, NoiseDim, Normals, NormalsDim); + ChunkSum = FinalizeOccupancyMasksFromNoiseValues(Chunk, WorldBasis, NoiseDim, NoiseValues, SrcToDest, zMin, PackedHSVColorValue); + + return ChunkSum; +#else + return 0; +#endif +} + +link_internal u32 +Terrain_Perlin2D( world_chunk *Chunk, + v3i NoiseBasis, + void *NoiseParams, + void *UserData ) +{ + TIMED_FUNCTION(); + u32 SyntheticChunkSum = Terrain_FBM2D( Chunk, NoiseBasis, NoiseParams, UserData ); + return SyntheticChunkSum; +} + +link_internal u32 +Terrain_Perlin3D( world_chunk *Chunk, + v3i NoiseBasis, + void *NoiseParams, + void *UserData ) +{ + TIMED_FUNCTION(); + + UNPACK_NOISE_PARAMS(NoiseParams); + + u32 Result = 0; + + Assert(Chunk); + + for ( s32 z = 0; z < Dim.z; ++ z) + { + for ( s32 y = 0; y < Dim.y; ++ y) + { + for ( s32 x = 0; x < Dim.x; ++ x) + { + s32 i = GetIndex(Voxel_Position(x,y,z), Dim); + NotImplemented; + /* Chunk->Voxels[i].Flags = Voxel_Empty; */ + + /* Assert( NotSet(&Chunk->Voxels[i], Voxel_Filled) ); */ + + v3 NoiseInput = MapWorldPositionToNoiseInputValue(V3(NoiseBasis), V3(x,y,z), Period); + r32 NoiseValue = PerlinNoise(NoiseInput); + + s32 NoiseChoice = NoiseValue*Amplitude > Thresh; + Assert(NoiseChoice == 0 || NoiseChoice == 1); + + + SetOccupancyBit(Chunk, i, NoiseChoice); + /* SetFlag(&Chunk->Voxels[i], (voxel_flag)(NoiseChoice * Voxel_Filled)); */ + + if (NoiseChoice) + { + Chunk->Voxels[i].Color = RGBtoPackedHSV(RGBColor); + /* Assert( IsSet(&Chunk->Voxels[i], Voxel_Filled) ); */ + ++Result; + } + else + { + /* Assert( NotSet(&Chunk->Voxels[i], Voxel_Filled) ); */ + } + + } + } + } + + return Result; +} + +link_internal u32 +Terrain_WhiteNoise( world_chunk *Chunk, + v3i NoiseBasis, + void *NoiseParams, + void *UserData ) +{ + TIMED_FUNCTION(); + + UNPACK_NOISE_PARAMS(NoiseParams); + + u32 Result = 0; + + Assert(Chunk); + + for ( s32 z = 0; z < Dim.z; ++ z) + { + for ( s32 y = 0; y < Dim.y; ++ y) + { + for ( s32 x = 0; x < Dim.x; ++ x) + { + s32 i = GetIndex(Voxel_Position(x,y,z), Dim); + NotImplemented; + /* Chunk->Voxels[i].Flags = Voxel_Empty; */ + + /* Assert( NotSet(&Chunk->Voxels[i], Voxel_Filled) ); */ + + v3 NoiseInput = MapWorldPositionToNoiseInputValue(V3(NoiseBasis), V3(x,y,z), Period); + random_series Entropy = RandomSeriesFromV3(NoiseInput); + + r32 NoiseValue = RandomUnilateral(&Entropy); + + s32 NoiseChoice = NoiseValue > Thresh; + Assert(NoiseChoice == 0 || NoiseChoice == 1); + + SetOccupancyBit(Chunk, i, NoiseChoice); + /* SetFlag(&Chunk->Voxels[i], (voxel_flag)(NoiseChoice * Voxel_Filled)); */ + + if (NoiseChoice) + { + Chunk->Voxels[i].Color = RGBtoPackedHSV(RGBColor); + /* Assert( IsSet(&Chunk->Voxels[i], Voxel_Filled) ); */ + ++Result; + } + else + { + /* Assert( NotSet(&Chunk->Voxels[i], Voxel_Filled) ); */ + } + + } + } + } + + return Result; +} + link_internal void GrowGrassPerlin( world_chunk *Chunk, v3i P, r32 NoiseValue, r32 MaskValue, v3i SrcToDest, v3i WorldChunkDim, r32 WorldZSubZMin, v3 *ThisColor, b32 *IsFilled ) { @@ -393,7 +981,7 @@ ComputeNormalsForChunkFromFilledFlag(world_chunk *Chunk, v3i WorldChunkDim, v3 * { s32 VoxIndex = GetIndex(V3i(x,y,z), ChunkDim); - if ( Chunk->Voxels[VoxIndex].Flags & Voxel_Filled ) + if ( GetOccupancyBit(Chunk, VoxIndex) ) { v3 Normal = {}; for ( s32 dz = -1; dz < 2; ++ dz) @@ -407,7 +995,7 @@ ComputeNormalsForChunkFromFilledFlag(world_chunk *Chunk, v3i WorldChunkDim, v3 * s32 dP = TryGetIndex(V3i(x+dx,y+dy,z+dz), ChunkDim); if (dP > -1) { - if ( Chunk->Voxels[dP].Flags & Voxel_Filled ) + if ( GetOccupancyBit(Chunk, dP) ) { Normal += V3(dx,dy,dz); } @@ -528,10 +1116,14 @@ ComputeNormalsForChunkFromNoiseValues_Opt(v3i Dim, r32 ChunkWorldZ, r32 *NoiseVa #endif link_internal void -ComputeNormalsForChunkFromNoiseValues( r32 ChunkWorldZ, r32 *NoiseValues, v3i NoiseDim, v3 *Normals, v3i NormalsDim) +ComputeNormalsForChunkFromNoiseValues( r32 *NoiseValues, v3i NoiseDim, v3 *Normals, v3i NormalsDim) { TIMED_FUNCTION(); + // NOTE(Jesse): For this function to work the noise has to be one voxel larger + // than the normal data + Assert(NoiseDim >= NormalsDim+2); + #if 1 for ( s32 z = 0; z < NormalsDim.z; ++ z) { @@ -565,10 +1157,250 @@ ComputeNormalsForChunkFromNoiseValues( r32 ChunkWorldZ, r32 *NoiseValues, v3i No } s32 NormalIndex = GetIndex(V3i(x,y,z), NormalsDim); + v3 Result = V3(x/64.f, y/64.f, z/64.f); + /* v3 Result = Normalize(Normal) * -1.f; */ + Normals[NormalIndex] = Result; + } + } + } +#else + for ( s32 z = 1; z < NoiseDim.z-1; ++ z) + { + for ( s32 y = 1; y < NoiseDim.y-1; ++ y) + { + for ( s32 x = 1; x < NoiseDim.x-1; ++ x) + { + s32 NormalIndex = GetIndex(V3i(x,y,z)-1, NormalsDim); + s32 NoiseIndex = GetIndex(V3i(x,y,z), NoiseDim); + r32 CurrentNoiseValue = NoiseValues[NoiseIndex]; + + v3 Normal = {}; + for ( s32 dz = -1; dz < 2; ++ dz) + { + for ( s32 dy = -1; dy < 2; ++ dy) + { + for ( s32 dx = -1; dx < 2; ++ dx) + { + if (dz == 0 && dy == 0 && dx == 0) continue; // Skip the middle-most voxel + + s32 dPIndex = GetIndex(V3i(x+dx,y+dy,z+dz), NoiseDim); + { + r32 Diff = NoiseValues[dPIndex]-dz - Truncate(CurrentNoiseValue); + if ( Diff > 0.f ) + { + // TODO(Jesse): Recompute with a small random variance to the weight if this is 0? + Normal += V3(dx,dy,dz)*Diff; + } + } + } + } + } Normals[NormalIndex] = Normalize(Normal) * -1.f; } } } +#endif +} + +typedef __m256 f256; +typedef __m256i i256; + +#define set8i _mm256_setr_epi32 + +inline f256 permute8f(const f256 a, const i256 choice) { + return _mm256_permutevar8x32_ps(a, choice); +} + +template +inline f256 select8f(const f256 tr, const f256 fr) + { return _mm256_blend_ps(fr, tr, (c7 << 7) | (c6 << 6) | (c5 << 5) | (c4 << 4) | (c3 << 3) | (c2 << 2) | (c1 << 1) | c0); } + +void vec3_soa_to_aos(f256& A, f256& B, f256& C, + const f256 x, const f256 y, const f256 z) +{ + // indices so we can permute into something sane. + const i256 PX = set8i(0, 3, 6, 1, 4, 7, 2, 5); + const i256 PY = set8i(5, 0, 3, 6, 1, 4, 7, 2); + const i256 PZ = set8i(2, 5, 0, 3, 6, 1, 4, 7); + + // re-arrange so we can select correct elements. + const f256 X = permute8f(x, PX); // 0.0f 3.0f 6.0f 1.0f 4.0f 7.0f 2.0f 5.0f + const f256 Y = permute8f(y, PY); // 5.1f 0.1f 3.1f 6.1f 1.1f 4.1f 7.1f 2.1f + const f256 Z = permute8f(z, PZ); // 2.2f 5.2f 0.2f 3.2f 6.2f 1.2f 4.2f 7.2f + + // perform our two stage selection + const f256 A0 = select8f<1, 0, 0, 1, 0, 0, 1, 0>(X, Y); // 0.0f 0.1f whatever 1.0f 1.1f whatever 2.0f 2.1f + const f256 B0 = select8f<1, 0, 0, 1, 0, 0, 1, 0>(Z, X); // 2.2f 3.0f whatever 3.2f 4.0f whatever 4.2f 5.0f + const f256 C0 = select8f<1, 0, 0, 1, 0, 0, 1, 0>(Y, Z); // 5.1f 5.2f whatever 6.1f 6.2f whatever 7.1f 7.2f + A = select8f<0, 0, 1, 0, 0, 1, 0, 0>(Z, A0); // 0.0f 0.1f 0.2f 1.0f 1.1f 1.2f 2.0f 2.1f + B = select8f<0, 0, 1, 0, 0, 1, 0, 0>(Y, B0); // 2.2f 3.0f 3.1f 3.2f 4.0f 4.1f 4.2f 5.0f + C = select8f<0, 0, 1, 0, 0, 1, 0, 0>(X, C0); // 5.1f 5.2f 6.0f 6.1f 6.2f 7.0f 7.1f 7.2f +} + +// for completeness.... +inline void vec3_aos_to_soa( + const f256 A, const f256 B, const f256 C, + f256& x, f256& y, f256& z) +{ + const f256 X0 = select8f<1, 0, 0, 1, 0, 0, 1, 0>(A, B); + const f256 Y0 = select8f<1, 0, 0, 1, 0, 0, 1, 0>(C, A); + const f256 Z0 = select8f<1, 0, 0, 1, 0, 0, 1, 0>(B, C); + + const f256 X = select8f<0, 0, 1, 0, 0, 1, 0, 0>(C, X0); + const f256 Y = select8f<0, 0, 1, 0, 0, 1, 0, 0>(B, Y0); + const f256 Z = select8f<0, 0, 1, 0, 0, 1, 0, 0>(A, Z0); + + const i256 PX = set8i(0, 3, 6, 1, 4, 7, 2, 5); + const i256 PY = set8i(1, 4, 7, 2, 5, 0, 3, 6); + const i256 PZ = set8i(2, 5, 0, 3, 6, 1, 4, 7); + + // rearrange and output + x = permute8f(X, PX); + y = permute8f(Y, PY); + z = permute8f(Z, PZ); +} + +/* __m256 x = _mm256_set_ps(7.0f, 6.0f, 5.0f, 4.0f, 3.0f, 2.0f, 1.0f, 0.0f); */ +/* __m256 y = _mm256_set_ps(7.1f, 6.1f, 5.1f, 4.1f, 3.1f, 2.1f, 1.1f, 0.1f); */ +/* __m256 z = _mm256_set_ps(7.2f, 6.2f, 5.2f, 4.2f, 3.2f, 2.2f, 1.2f, 0.2f); */ + +/* vec3_soa_to_aos(x, y, z, x, y, z); */ + + +/* std::vector result; */ +/* result.resize(24); */ +/* _mm256_storeu_ps(result.data(), x); */ +/* _mm256_storeu_ps(result.data() + 8, y); */ +/* _mm256_storeu_ps(result.data() + 16, z); */ + +link_internal void +Interleave( f32_8x X, f32_8x Y, f32_8x Z) +{ + vec3_soa_to_aos(X.Sse, Y.Sse, Z.Sse, X.Sse, Y.Sse, Z.Sse); +} + +link_internal void +Interleave(v3_8x In, v3 *Result) +{ + Result[0] = V3(In.E.x[0], In.E.y[0], In.E.z[0]); + Result[1] = V3(In.E.x[1], In.E.y[1], In.E.z[1]); + Result[2] = V3(In.E.x[2], In.E.y[2], In.E.z[2]); + Result[3] = V3(In.E.x[3], In.E.y[3], In.E.z[3]); + Result[4] = V3(In.E.x[4], In.E.y[4], In.E.z[4]); + Result[5] = V3(In.E.x[5], In.E.y[5], In.E.z[5]); + Result[6] = V3(In.E.x[6], In.E.y[6], In.E.z[6]); + Result[7] = V3(In.E.x[7], In.E.y[7], In.E.z[7]); +} + +// 3.55M +// 2.53M +// 2.51M +// +link_internal void +ComputeNormalsForChunkFromNoiseValues_avx( r32 *NoiseValues, v3i NoiseDim, v3 *Normals, v3i NormalsDim) +{ + /* HISTOGRAM_FUNCTION(); */ + TIMED_FUNCTION(); + + // NOTE(Jesse): The Normal values are undefined on the edges + // + // NOTE(Jesse): For this function to work the buffers have to be the same size + // and bounded by a multiple of 8, cause AVX. + // + Assert(NormalsDim.x % 8 == 0); + /* Assert(NoiseDim.x % 8 == 0); */ + + Assert(NormalsDim == V3i(64)); + + Assert(NoiseDim >= NormalsDim+V3i(2,2,2)); + +#if 0 + for ( s32 z = 0; z < NormalsDim.z; ++ z) + { + for ( s32 y = 0; y < NormalsDim.y; ++ y) + { + for ( s32 x = 0; x < NormalsDim.x; x += 1) + { + s32 NormalIndex = GetIndex(V3i(x,y,z), NormalsDim); + Normals[NormalIndex] = V3(1,0,1); + } + } + } +#endif + + +#if 1 + for ( s32 z = 0; z < NormalsDim.z; ++ z) + { + for ( s32 y = 0; y < NormalsDim.y; ++ y) + { + for ( s32 x = 0; x < NormalsDim.x; x += 8) + { + s32 NoiseBaseIndex = GetIndex(V3i(x,y,z), NoiseDim); + f32_8x CurrentNoiseValue = F32_8X(NoiseValues+NoiseBaseIndex); + + v3_8x Normal = {}; +#pragma unroll(3) + for ( s32 dz = -1; dz < 2; ++ dz) + { + auto _dz = F32_8X(dz); +#pragma unroll(3) + for ( s32 dy = -1; dy < 2; ++ dy) + { +#pragma unroll(3) + for ( s32 dx = -1; dx < 2; ++ dx) + { + if (dz == 0 && dy == 0 && dx == 0) continue; // Skip the middle-most voxel + + s32 dNoiseIndex = GetIndex(V3i(x+dx,y+dy,z+dz)+1, NoiseDim); + { + f32_8x OffsetNoiseValue = F32_8X_unaligned(NoiseValues + dNoiseIndex); + f32_8x Diff = OffsetNoiseValue - _dz - Truncate(CurrentNoiseValue); + + u32_8x AddMask = Diff > 0.f; + + v3_8x AddVal = Select(AddMask, V3_8X(dx,dy,dz)*Diff, V3_8X(0.f)); + + Normal.avx.x = Normal.avx.x + AddVal.avx.x; + Normal.avx.y = Normal.avx.y + AddVal.avx.y; + Normal.avx.z = Normal.avx.z + AddVal.avx.z; + + /* if ( Diff > 0.f ) */ + /* { */ + /* // TODO(Jesse): Recompute with a small random variance to the weight if this is 0? */ + /* Normal += V3_8X(dx,dy,dz)*Diff; */ + /* } */ + } + } + } + } + + v3_8x Result = Normalize(Normal) * F32_8X(-1.f); + /* v3_8x Result = V3_8X(x/64.f, y/64.f, z/64.f); */ + + + s32 NormalIndex = GetIndex(V3i(x,y,z), NormalsDim); + f32 *Basis = Cast(f32*, Normals+NormalIndex); + + // TODO(Jesse): The second interleave (from SO) is wrong, but it makes + // the function 25% faster ... +#if 1 + alignas(32) f32 Swizzled[8*3]; + Interleave(Result, (v3*)Swizzled); + + __m256 *A = (__m256*)Swizzled; + _mm256_storeu_ps( Basis+ 0, A[0]); + _mm256_storeu_ps( Basis+ 8, A[1]); + _mm256_storeu_ps( Basis+16, A[2]); +#else + Interleave(Result.avx.x, Result.avx.y, Result.avx.z); + _mm256_storeu_ps( Basis+ 0, Result.avx.x.Sse); + _mm256_storeu_ps( Basis+ 8, Result.avx.y.Sse); + _mm256_storeu_ps( Basis+16, Result.avx.z.Sse); +#endif + } + } + } #else for ( s32 z = 1; z < NoiseDim.z-1; ++ z) { @@ -638,8 +1470,9 @@ HoodooTerrain( world_chunk *Chunk, s64 WorldX = x + SrcToDest.x + (WorldChunkDim.x*Chunk->WorldP.x); r32 NoiseValue = 0.f; s32 VoxIndex = GetIndex(V3i(x,y,z), Dim); - Chunk->Voxels[VoxIndex].Flags = Voxel_Empty; - Assert( NotSet(&Chunk->Voxels[VoxIndex], Voxel_Filled) ); + NotImplemented; + /* Chunk->Voxels[VoxIndex].Flags = Voxel_Empty; */ + /* Assert( NotSet(&Chunk->Voxels[VoxIndex], Voxel_Filled) ); */ /* s32 Amp2 = Amplitude*2; */ r32 HighestNoise = 0.f; @@ -766,20 +1599,13 @@ HoodooTerrain( world_chunk *Chunk, /* ThisColor = BLUE; */ /* } */ - SetFlag(&Chunk->Voxels[VoxIndex], (voxel_flag)(Voxel_Filled*IsFilled)); + /* SetFlag(&Chunk->Voxels[VoxIndex], (voxel_flag)(Voxel_Filled*IsFilled)); */ + SetOccupancyBit(Chunk, VoxIndex, s32(IsFilled)); Chunk->Voxels[VoxIndex].Color = RGBtoPackedHSV(ThisColor)*u16(IsFilled); ChunkSum += IsFilled; - Assert( (Chunk->Voxels[VoxIndex].Flags&VoxelFaceMask) == 0); - - if (IsFilled) - { - Assert( IsSet(&Chunk->Voxels[VoxIndex], Voxel_Filled) ); - } - else - { - Assert( NotSet(&Chunk->Voxels[VoxIndex], Voxel_Filled) ); - } + NotImplemented; + /* Assert( (Chunk->Voxels[VoxIndex].Flags&VoxelFaceMask) == 0); */ } } } @@ -815,7 +1641,8 @@ TerracedTerrain( world_chunk *Chunk, { /* s64 WorldX = x + SrcToDest.x + (WorldChunkDim.x*Chunk->WorldP.x); */ s32 VoxIndex = GetIndex(V3i(x,y,z), Dim); - Chunk->Voxels[VoxIndex].Flags = Voxel_Empty; + NotImplemented; + /* Chunk->Voxels[VoxIndex].Flags = Voxel_Empty; */ /* Assert( NotSet(&Chunk->Voxels[VoxIndex], Voxel_Filled) ); */ r32 NoiseValue = 0.f; @@ -990,23 +1817,17 @@ TerracedTerrain( world_chunk *Chunk, } #endif - SetFlag(&Chunk->Voxels[VoxIndex], (voxel_flag)(Voxel_Filled*IsFilled)); + /* SetFlag(&Chunk->Voxels[VoxIndex], (voxel_flag)(Voxel_Filled*IsFilled)); */ + SetOccupancyBit(Chunk, VoxIndex, s32(IsFilled)); Chunk->Voxels[VoxIndex].Color = RGBtoPackedHSV(ThisColor)*u16(IsFilled); Chunk->Voxels[VoxIndex].Transparency = ThisTransparency; ChunkSum += IsFilled; - Assert( (Chunk->Voxels[VoxIndex].Flags&VoxelFaceMask) == 0); - - if (IsFilled) - { - Assert( IsSet(&Chunk->Voxels[VoxIndex], Voxel_Filled) ); - } - else - { - Assert( NotSet(&Chunk->Voxels[VoxIndex], Voxel_Filled) ); - } + NotImplemented; + /* Assert( (Chunk->Voxels[VoxIndex].Flags&VoxelFaceMask) == 0); */ + SetOccupancyBit(Chunk, VoxIndex, s32(IsFilled)); } } } @@ -1091,7 +1912,8 @@ GrassyTerracedTerrain2( world_chunk *Chunk, /* s64 WorldX = x + SrcToDest.x + (WorldChunkDim.x*Chunk->WorldP.x); */ s32 VoxIndex = GetIndex(V3i(x,y,z), Dim); - Chunk->Voxels[VoxIndex].Flags = Voxel_Empty; + NotImplemented; + /* Chunk->Voxels[VoxIndex].Flags = Voxel_Empty; */ /* Assert( NotSet(&Chunk->Voxels[VoxIndex], Voxel_Filled) ); */ r32 NoiseValue = 0.f; @@ -1169,23 +1991,15 @@ GrassyTerracedTerrain2( world_chunk *Chunk, GrowGrassPerlin( Chunk, V3i(x,y,z), NoiseValue, 1.f-TerraceMask, SrcToDest, WorldChunkDim, WorldZSubZMin, &ThisColor, &IsFilled ); - SetFlag(&Chunk->Voxels[VoxIndex], (voxel_flag)(Voxel_Filled*IsFilled)); + /* SetFlag(&Chunk->Voxels[VoxIndex], (voxel_flag)(Voxel_Filled*IsFilled)); */ + SetOccupancyBit(Chunk, VoxIndex, s32(IsFilled)); + Chunk->Voxels[VoxIndex].Color = RGBtoPackedHSV(ThisColor)*u8(IsFilled); Chunk->Voxels[VoxIndex].Transparency = ThisTransparency; ChunkSum += IsFilled; - - - Assert( (Chunk->Voxels[VoxIndex].Flags&VoxelFaceMask) == 0); - - if (IsFilled) - { - Assert( IsSet(&Chunk->Voxels[VoxIndex], Voxel_Filled) ); - } - else - { - Assert( NotSet(&Chunk->Voxels[VoxIndex], Voxel_Filled) ); - } + NotImplemented; + /* Assert( (Chunk->Voxels[VoxIndex].Flags&VoxelFaceMask) == 0); */ } } } @@ -1262,7 +2076,8 @@ GrassyTerracedTerrain3( world_chunk *Chunk, s64 WorldX = x + SrcToDest.x + (WorldChunkDim.x*Chunk->WorldP.x); s32 VoxIndex = GetIndex(V3i(x,y,z), Dim); - Chunk->Voxels[VoxIndex].Flags = Voxel_Empty; + NotImplemented; + /* Chunk->Voxels[VoxIndex].Flags = Voxel_Empty; */ /* Assert( NotSet(&Chunk->Voxels[VoxIndex], Voxel_Filled) ); */ r32 NoiseValue = 0.f; @@ -1325,23 +2140,14 @@ GrassyTerracedTerrain3( world_chunk *Chunk, GrowGrassPerlin( Chunk, V3i(x,y,z), NoiseValue, 1.f-TerraceMask, SrcToDest, WorldChunkDim, WorldZSubZMin, &ThisColor, &IsFilled ); - SetFlag(&Chunk->Voxels[VoxIndex], (voxel_flag)(Voxel_Filled*IsFilled)); + /* SetFlag(&Chunk->Voxels[VoxIndex], (voxel_flag)(Voxel_Filled*IsFilled)); */ + SetOccupancyBit(Chunk, VoxIndex, s32(IsFilled)); Chunk->Voxels[VoxIndex].Color = RGBtoPackedHSV(ThisColor)*u16(IsFilled); Chunk->Voxels[VoxIndex].Transparency = ThisTransparency; ChunkSum += IsFilled; - - - Assert( (Chunk->Voxels[VoxIndex].Flags&VoxelFaceMask) == 0); - - if (IsFilled) - { - Assert( IsSet(&Chunk->Voxels[VoxIndex], Voxel_Filled) ); - } - else - { - Assert( NotSet(&Chunk->Voxels[VoxIndex], Voxel_Filled) ); - } + NotImplemented; + /* Assert( (Chunk->Voxels[VoxIndex].Flags&VoxelFaceMask) == 0); */ } } } @@ -1546,6 +2352,7 @@ MakeCliffs_8x(world_chunk *Chunk, s32 NormalsIndex, s32 WorldX, s32 WorldY, s32 #endif } +#if 0 link_internal u32 GrassyTerracedTerrain4( world_chunk *Chunk, v3i NoiseBasis, @@ -1575,22 +2382,13 @@ GrassyTerracedTerrain4( world_chunk *Chunk, /* b32 *NoiseHit = Allocate(b32, GetTranArena(), Volume(NoiseDim)); */ /* b32 *NormalsHit = Allocate(b32, GetTranArena(), Volume(NormalDim)); */ -#if VOXEL_DEBUG_COLOR memory_arena *TempArena = GetThreadLocalState(ThreadLocal_ThreadIndex)->PermMemory; -#else - memory_arena *TempArena = GetTranArena(); -#endif r32 *NoiseValues = Allocate(r32, TempArena, Volume(NoiseDim)); v3 *Normals = Allocate( v3, TempArena, Volume(NormalDim)); -#if VOXEL_DEBUG_COLOR - Chunk->NoiseValues = NoiseValues; - Chunk->NormalValues = Normals; -#endif - // NOTE(Jesse): Perlin_8x needs a multiple of 8 here. - /* Assert(Dim.x % 8 == 0); */ + Assert(Dim.x % 8 == 0); s32 xNoiseBlockCount = NoiseDim.x / 8; { @@ -1633,7 +2431,7 @@ GrassyTerracedTerrain4( world_chunk *Chunk, }; f32 TmpPerlinResults[8]; - PerlinNoise_8x(xCoords, InY, InZ, TmpPerlinResults); + PerlinNoise_8x_avx2(xCoords, InY, InZ, TmpPerlinResults); RangeIterator(Index, 8) { @@ -1772,24 +2570,12 @@ GrassyTerracedTerrain4( world_chunk *Chunk, /* NormalsHit[NormalIndex+Index] = 1; */ b32 IsFilled = NoiseValues[NoiseIndex+Index] > r32(z+ChunkWorldZThresh); - SetFlag(&Chunk->Voxels[NormalIndex+Index], (voxel_flag)(Voxel_Filled*IsFilled)); + /* SetFlag(&Chunk->Voxels[NormalIndex+Index], (voxel_flag)(Voxel_Filled*IsFilled)); */ + SetOccupancyBit(Chunk, NormalIndex+Index, s32(IsFilled)); Chunk->Voxels[NormalIndex+Index].Color = RGBtoPackedHSV(ThisColor[Index])*u16(IsFilled); /* Chunk->Voxels[NormalIndex].Transparency = ThisTransparency; */ ChunkSum += IsFilled; } - -#if 0 - Assert( (Chunk->Voxels[NormalIndex].Flags&VoxelFaceMask) == 0); - - if (IsFilled) - { - Assert( IsSet(&Chunk->Voxels[NormalIndex], Voxel_Filled) ); - } - else - { - Assert( NotSet(&Chunk->Voxels[NormalIndex], Voxel_Filled) ); - } -#endif } s32 xFixupBase = (xShapingBlockCount * 8); @@ -1810,7 +2596,8 @@ GrassyTerracedTerrain4( world_chunk *Chunk, GrowGrassVoronoi( Chunk, V3i(x,y,z), NoiseValue, Normal, SrcToDest, WorldChunkDim, WorldZSubZMin, &ThisColor); b32 IsFilled = NoiseValues[NoiseIndex] > r32(z+ChunkWorldZThresh); - SetFlag(&Chunk->Voxels[NormalIndex], (voxel_flag)(Voxel_Filled*IsFilled)); + /* SetFlag(&Chunk->Voxels[NormalIndex], (voxel_flag)(Voxel_Filled*IsFilled)); */ + SetOccupancyBit(Chunk, NormalIndex, s32(IsFilled)); Chunk->Voxels[NormalIndex].Color = RGBtoPackedHSV(ThisColor)*u8(IsFilled); /* Chunk->Voxels[NormalIndex].Transparency = ThisTransparency; */ ChunkSum += IsFilled; @@ -1871,27 +2658,9 @@ GrassyTerracedTerrain4( world_chunk *Chunk, ComputeNormalsForChunkFromFilledFlag(Chunk, WorldChunkDim, Normals); #endif -#if VOXEL_DEBUG_COLOR -#if 0 - for ( s32 z = 0; z < Chunk->Dim.z; ++ z) - { - for ( s32 y = 0; y < Chunk->Dim.y; ++ y) - { - for ( s32 x = 0; x < Chunk->Dim.x; ++ x) - { - /* s32 Index = GetIndex(V3i(x,y,z), NormalDim); */ - s32 NormalIndex = GetIndex(V3i(x,y,z), NormalDim); - s32 NoiseIndex = GetIndex(V3i(x,y,z)+1, NoiseDim); - Chunk->Voxels[NormalIndex].DebugColor = Normals[NormalIndex]; - Chunk->Voxels[NormalIndex].DebugNoiseValue = NoiseValues[NoiseIndex]; - } - } - } -#endif -#endif - return ChunkSum; } +#endif link_internal u32 GrassyTerracedTerrain( world_chunk *Chunk, @@ -1922,7 +2691,8 @@ GrassyTerracedTerrain( world_chunk *Chunk, { /* s64 WorldX = x + SrcToDest.x + (WorldChunkDim.x*Chunk->WorldP.x); */ s32 VoxIndex = GetIndex(V3i(x,y,z), Dim); - Chunk->Voxels[VoxIndex].Flags = Voxel_Empty; + NotImplemented; + /* Chunk->Voxels[VoxIndex].Flags = Voxel_Empty; */ /* Assert( NotSet(&Chunk->Voxels[VoxIndex], Voxel_Filled) ); */ r32 NoiseValue = 0.f; @@ -2022,23 +2792,14 @@ GrassyTerracedTerrain( world_chunk *Chunk, GrowGrassPerlin( Chunk, V3i(x,y,z), NoiseValue, 1.f, SrcToDest, WorldChunkDim, WorldZSubZMin, &ThisColor, &IsFilled ); - SetFlag(&Chunk->Voxels[VoxIndex], (voxel_flag)(Voxel_Filled*IsFilled)); + /* SetFlag(&Chunk->Voxels[VoxIndex], (voxel_flag)(Voxel_Filled*IsFilled)); */ + SetOccupancyBit(Chunk, VoxIndex, s32(IsFilled)); Chunk->Voxels[VoxIndex].Color = RGBtoPackedHSV(ThisColor)*u8(IsFilled); Chunk->Voxels[VoxIndex].Transparency = ThisTransparency; ChunkSum += IsFilled; - - - Assert( (Chunk->Voxels[VoxIndex].Flags&VoxelFaceMask) == 0); - - if (IsFilled) - { - Assert( IsSet(&Chunk->Voxels[VoxIndex], Voxel_Filled) ); - } - else - { - Assert( NotSet(&Chunk->Voxels[VoxIndex], Voxel_Filled) ); - } + NotImplemented; + /* Assert( (Chunk->Voxels[VoxIndex].Flags&VoxelFaceMask) == 0); */ } } } @@ -2112,7 +2873,8 @@ GrassyLargeTerracedTerrain( world_chunk *Chunk, /* s64 WorldX = x + SrcToDest.x + (WorldChunkDim.x*Chunk->WorldP.x); */ s32 VoxIndex = GetIndex(V3i(x,y,z), Dim); - Chunk->Voxels[VoxIndex].Flags = Voxel_Empty; + NotImplemented; + /* Chunk->Voxels[VoxIndex].Flags = Voxel_Empty; */ /* Assert( NotSet(&Chunk->Voxels[VoxIndex], Voxel_Filled) ); */ r32 NoiseValue = 0.f; @@ -2181,23 +2943,14 @@ GrassyLargeTerracedTerrain( world_chunk *Chunk, GrowGrassPerlin( Chunk, V3i(x,y,z), NoiseValue, 1.f-Clamp01(TerraceMask), SrcToDest, WorldChunkDim, WorldZSubZMin, &ThisColor, &IsFilled ); /* GrowGrassPerlin( Chunk, V3i(x,y,z), NoiseValue, Clamp01(TerraceMask), SrcToDest, WorldChunkDim, WorldZSubZMin, &ThisColor, &IsFilled ); */ - SetFlag(&Chunk->Voxels[VoxIndex], (voxel_flag)(Voxel_Filled*IsFilled)); + /* SetFlag(&Chunk->Voxels[VoxIndex], (voxel_flag)(Voxel_Filled*IsFilled)); */ + SetOccupancyBit(Chunk, VoxIndex, s32(IsFilled)); Chunk->Voxels[VoxIndex].Color = RGBtoPackedHSV(ThisColor)*u8(IsFilled); Chunk->Voxels[VoxIndex].Transparency = ThisTransparency; ChunkSum += IsFilled; - - - Assert( (Chunk->Voxels[VoxIndex].Flags&VoxelFaceMask) == 0); - - if (IsFilled) - { - Assert( IsSet(&Chunk->Voxels[VoxIndex], Voxel_Filled) ); - } - else - { - Assert( NotSet(&Chunk->Voxels[VoxIndex], Voxel_Filled) ); - } + NotImplemented; + /* Assert( (Chunk->Voxels[VoxIndex].Flags&VoxelFaceMask) == 0); */ } } } @@ -2238,19 +2991,16 @@ Terrain_SinCos( world_chunk *Chunk, u32 ChunkSum = 0; - s32 MinZ = Chunk->WorldP.z*WorldChunkDim.z; - s32 MaxZ = MinZ+WorldChunkDim.z ; - for ( s32 z = 0; z < Dim.z; ++ z) { - s64 WorldZ = z + SrcToDest.z + (WorldChunkDim.z*Chunk->WorldP.z); + s64 WorldZ = (Chunk->DimInChunks.z/2) + (z*Chunk->DimInChunks.z) + (Chunk->WorldP.z*WorldChunkDim.z) + SrcToDest.z ; s64 WorldZSubZMin = WorldZ - zMin; for ( s32 y = 0; y < Dim.y; ++ y) { - s64 WorldY = y + SrcToDest.y + (WorldChunkDim.y*Chunk->WorldP.y); + s64 WorldY = (Chunk->DimInChunks.y/2) + (y*Chunk->DimInChunks.y) + SrcToDest.y + (WorldChunkDim.y*Chunk->WorldP.y); for ( s32 x = 0; x < Dim.x; ++ x) { - s64 WorldX = x + SrcToDest.x + (WorldChunkDim.x*Chunk->WorldP.x); + s64 WorldX = (Chunk->DimInChunks.x/2) + (x*Chunk->DimInChunks.x) + SrcToDest.x + (WorldChunkDim.x*Chunk->WorldP.x); s32 VoxIndex = GetIndex(V3i(x,y,z), Dim); r32 NoiseValue = ((Sin(r32(WorldX)/Period.x)+1.f)/2.f) + ((Cos(r32(WorldY)/Period.y)+1.f)/4.f); @@ -2262,21 +3012,17 @@ Terrain_SinCos( world_chunk *Chunk, } } -/* s64 ChunkWorldZThresh = SrcToDest.z + (WorldChunkDim.z*Chunk->WorldP.z) - zMin; */ -/* NotImplemented; */ -/* /1* ComputeNormalsForChunkFromNoiseValues(ChunkWorldZThresh, NoiseValues, Normals); *1/ */ - for ( s32 z = 0; z < Dim.z; ++ z) { - s64 WorldZ = z + SrcToDest.z + (WorldChunkDim.z*Chunk->WorldP.z); + s64 WorldZ = (Chunk->DimInChunks.z/2) + (z*Chunk->DimInChunks.z) + (Chunk->WorldP.z*WorldChunkDim.z) + SrcToDest.z ; s64 WorldZSubZMin = WorldZ - zMin; for ( s32 y = 0; y < Dim.y; ++ y) { - s64 WorldY = y + SrcToDest.y + (WorldChunkDim.y*Chunk->WorldP.y); + s64 WorldY = (Chunk->DimInChunks.y/2) + (y*Chunk->DimInChunks.y) + SrcToDest.y + (WorldChunkDim.y*Chunk->WorldP.y); for ( s32 x = 0; x < Dim.x; ++ x) { - s64 WorldX = x + SrcToDest.x + (WorldChunkDim.x*Chunk->WorldP.x); + s64 WorldX = (Chunk->DimInChunks.x/2) + (x*Chunk->DimInChunks.x) + SrcToDest.x + (WorldChunkDim.x*Chunk->WorldP.x); s32 VoxIndex = GetIndex(V3i(x,y,z), Dim); r32 *NoiseValue = NoiseValues+VoxIndex; @@ -2287,7 +3033,8 @@ Terrain_SinCos( world_chunk *Chunk, b32 IsFilled = r32(*NoiseValue) > r32(WorldZSubZMin); - SetFlag(&Chunk->Voxels[VoxIndex], (voxel_flag)(Voxel_Filled*IsFilled)); + /* SetFlag(&Chunk->Voxels[VoxIndex], (voxel_flag)(Voxel_Filled*IsFilled)); */ + SetOccupancyBit(Chunk, VoxIndex, s32(IsFilled)); Chunk->Voxels[VoxIndex].Color = RGBtoPackedHSV(ThisColor); ChunkSum += IsFilled; } @@ -2324,7 +3071,8 @@ Terrain_Voronoi3D( world_chunk *Chunk, for ( s32 x = 0; x < Dim.x; ++ x) { s32 VoxIndex = GetIndex(V3i(x,y,z), Dim); - Chunk->Voxels[VoxIndex].Flags = Voxel_Empty; + NotImplemented; + /* Chunk->Voxels[VoxIndex].Flags = Voxel_Empty; */ v3 RepeatBasisInCells = V3(8); v3 NoiseInput = NoiseMod((V3(x,y,z) + NoiseBasis)/Period, RepeatBasisInCells); @@ -2335,8 +3083,9 @@ Terrain_Voronoi3D( world_chunk *Chunk, b32 IsFilled = r32(NoiseValue) > r32(zMin) ; - SetFlag(&Chunk->Voxels[VoxIndex], (voxel_flag)(Voxel_Filled*IsFilled)); - Chunk->Voxels[VoxIndex].Color = PackHSVColor(RGBColor)*u8(IsFilled); + /* SetFlag(&Chunk->Voxels[VoxIndex], (voxel_flag)(Voxel_Filled*IsFilled)); */ + SetOccupancyBit(Chunk, VoxIndex, s32(IsFilled)); + Chunk->Voxels[VoxIndex].Color = PackV3_16b(RGBColor)*u8(IsFilled); ChunkSum += IsFilled; } } @@ -2375,7 +3124,8 @@ Terrain_Voronoi2D( world_chunk *Chunk, { s64 WorldX = x + SrcToDest.x + (WorldChunkDim.x*Chunk->WorldP.x); s32 VoxIndex = GetIndex(V3i(x,y,z), Dim); - Chunk->Voxels[VoxIndex].Flags = Voxel_Empty; + NotImplemented; + /* Chunk->Voxels[VoxIndex].Flags = Voxel_Empty; */ r32 NoiseValue = VoronoiNoise3D(V3(f32(WorldX), f32(WorldY), f32(WorldZ)) / Period, Squareness, MaskChance); /* r32 NoiseValue = VoronoiNoise3D(V3(s32(WorldX), s32(WorldY), s32(WorldZ)) * 0.04f) * 25.f; */ @@ -2385,7 +3135,8 @@ Terrain_Voronoi2D( world_chunk *Chunk, b32 IsFilled = r32(NoiseValue) > r32(WorldZSubZMin) ; - SetFlag(&Chunk->Voxels[VoxIndex], (voxel_flag)(Voxel_Filled*IsFilled)); + /* SetFlag(&Chunk->Voxels[VoxIndex], (voxel_flag)(Voxel_Filled*IsFilled)); */ + SetOccupancyBit(Chunk, VoxIndex, s32(IsFilled)); Chunk->Voxels[VoxIndex].Color = RGBtoPackedHSV(RGBColor)*u16(IsFilled); ChunkSum += IsFilled; } diff --git a/src/engine/terrain.h b/src/engine/terrain.h index 58daf436b..9a1ad038e 100644 --- a/src/engine/terrain.h +++ b/src/engine/terrain.h @@ -1,4 +1,145 @@ +#define MIN_TERRAIN_NOISE_WIDTH (64) + +#define COMPUTE_NOISE_INPUT(channel_name, offset, chunk) (chunk->DimInChunks.channel_name/2.f) + ((f32(offset)+channel_name)*chunk->DimInChunks.channel_name) + (chunk->WorldP.channel_name*WorldChunkDim.channel_name) + + +poof( + func terrain_iteration_pattern( type_poof_symbol noise_input_name, + type_poof_symbol noise_value_name, + type_poof_symbol packed_HSV_color_value_name, + type_poof_symbol user_code) + @code_fragment + { + Period = Max(Period, V3(1.f)); + + for ( s32 z = 0; z < Dim.z; ++ z) + { + s64 WorldZ = s64(COMPUTE_NOISE_INPUT(z, 0, Chunk)); + s64 WorldZBiased = WorldZ - zMin; + for ( s32 y = 0; y < Dim.y; ++ y) + { + for ( s32 x = 0; x < Dim.x; ++ x) + { + s32 VoxIndex = GetIndex(Voxel_Position(x,y,z), Dim); + Chunk->Voxels[VoxIndex].Flags = Voxel_Empty; + + v3 noise_input_name = V3( + COMPUTE_NOISE_INPUT(x, 0, Chunk), + COMPUTE_NOISE_INPUT(y, 0, Chunk), + COMPUTE_NOISE_INPUT(z, 0, Chunk) + ); + + + r32 noise_value_name = 0.f; + + user_code + + s32 NoiseChoice = r64((noise_value_name)) > r64(WorldZBiased); + + SetOccupancyBit(Chunk, VoxIndex, NoiseChoice); + /* SetOccupancyByte(Chunk, VoxIndex, OccupancyByte); */ + Chunk->Voxels[VoxIndex].Color = packed_HSV_color_value_name*u16(NoiseChoice); + ChunkSum += u32(NoiseChoice); + + Assert( (Chunk->Voxels[VoxIndex].Flags&VoxelFaceMask) == 0); + } + } + } + } +) + + + +poof( + func terrain_iteration_pattern_8x( type_poof_symbol noise_input_name, + type_poof_symbol noise_value_name, + type_poof_symbol packed_HSV_color_value_name, + type_poof_symbol user_code) + @code_fragment + { + // NOTE(Jesse): This must hold true for using any Noise_8x func + Assert(Chunk->Dim % V3i(8) == V3i(0)); + + Period = Max(Period, V3(1.f)); + + for ( s32 z = 0; z < Dim.z; ++ z) + { + f32 zCoord = COMPUTE_NOISE_INPUT(z, 0, Chunk); + f32 WorldZBiased = zCoord - zMin; + for ( s32 y = 0; y < Dim.y; ++ y) + { + f32 yCoord = COMPUTE_NOISE_INPUT(y, 0, Chunk); + for ( s32 x = 0; x < Dim.x; x += 8 ) + { + s32 VoxIndex = GetIndex(Voxel_Position(x,y,z), Dim); + + user_code + + u8 OccupancyByte = 0; + RangeIterator(ValueIndex, 8) + { + s32 ThisIndex = VoxIndex+ValueIndex; + s32 NoiseChoice = NoiseValues[ThisIndex] > WorldZBiased; + ChunkSum += u32(NoiseChoice); + + OccupancyByte |= (NoiseChoice << ValueIndex); + Chunk->Voxels[ThisIndex].Color = packed_HSV_color_value_name*u16(NoiseChoice); + } + + SetOccupancyByte(Chunk, VoxIndex, OccupancyByte); + } + } + } + } +) + +poof( + func terrain_iteration_pattern_16x( type_poof_symbol noise_input_name, + type_poof_symbol noise_value_name, + type_poof_symbol packed_HSV_color_value_name, + type_poof_symbol user_code) + @code_fragment + { + // NOTE(Jesse): This must hold true for using any Noise_16x func + Assert(Chunk->Dim % V3i(16) == V3i(0)); + + Period = Max(Period, V3(1.f)); + + for ( s32 z = 0; z < Dim.z; ++ z) + { + f32 zCoord = COMPUTE_NOISE_INPUT(z, 0, Chunk); + f32 WorldZBiased = zCoord - zMin; + for ( s32 y = 0; y < Dim.y; ++ y) + { + f32 yCoord = COMPUTE_NOISE_INPUT(y, 0, Chunk); + for ( s32 x = 0; x < Dim.x; x += 16 ) + { + s32 VoxIndex = GetIndex(Voxel_Position(x,y,z), Dim); + + user_code + + u16 OccupancyByte = 0; + RangeIterator(ValueIndex, 16) + { + s32 ThisIndex = VoxIndex+ValueIndex; + s32 NoiseChoice = NoiseValues[ThisIndex] > WorldZBiased; + ChunkSum += u32(NoiseChoice); + + OccupancyByte |= (NoiseChoice << ValueIndex); + Chunk->Voxels[ThisIndex].Color = packed_HSV_color_value_name*u16(NoiseChoice); + } + SetOccupancyByte(Chunk, VoxIndex, u8(OccupancyByte)); + SetOccupancyByte(Chunk, VoxIndex+8, u8(OccupancyByte>>8)); + } + } + } + } +) + + + + struct noise_value_to_material_index { f32 NoiseValue; @@ -45,6 +186,7 @@ MapNoiseValueToFinal(f32 Value) /* Assert(Value >= 0.f); */ // NOTE(Jesse): Descending order so we can scan from the front and find the interval we care about + /* v2 Points[] = */ /* { */ /* {{1.0f, 1.0f }}, */ @@ -66,26 +208,27 @@ MapNoiseValueToFinal(f32 Value) /* }; */ // Pretty nice -/* v2 Points[] = */ -/* { */ -/* {{1.0f, 1.0f }}, */ -/* {{0.7f, 0.7f }}, */ -/* {{0.65f, 0.43f }}, */ -/* {{0.6f, 0.4f }}, */ -/* {{0.5f, 0.1f }}, */ -/* {{0.0f, 0.0f }}, */ -/* }; */ - // Pillar-y v2 Points[] = { - {{1.0f, 0.5f }}, - {{0.6f, 0.3f }}, - {{0.1f, 0.2f }}, - {{0.05f, 0.45f }}, - {{0.0f , 0.5f }}, + {{1.0f, 1.0f }}, + {{0.7f, 0.7f }}, + {{0.65f, 0.43f }}, + {{0.6f, 0.4f }}, + {{0.5f, 0.1f }}, + {{-1.0f, -1.0f }}, }; + // Pillar-y + /* v2 Points[] = */ + /* { */ + /* {{1.0f, 0.5f }}, */ + /* {{0.6f, 0.3f }}, */ + /* {{0.1f, 0.2f }}, */ + /* {{0.05f, 0.45f }}, */ + /* {{0.0f , 0.5f }}, */ + /* }; */ + /* v2 Points[] = */ /* { */ /* {{1.0f, 0.0f }}, */ @@ -137,12 +280,28 @@ MapNoiseValueToFinal(f32 Value) } -link_internal void -ComputeNormalsForChunkFromNoiseValues( r32 ChunkWorldZ, r32 *NoiseValues, v3i NoiseDim, v3 *Normals, v3i NormalsDim); +/* link_internal void */ +/* ComputeNormalsForChunkFromNoiseValues( r32 *NoiseValues, v3i NoiseDim, v3 *Normals, v3i NormalsDim); */ + +/* link_internal void */ +/* ComputeNormalsForChunkFromNoiseValues_avx( r32 *NoiseValues, v3i NoiseDim, v3 *Normals, v3i NormalsDim); */ + + +/* link_internal u32 */ +/* Terrain_WhiteNoise( world_chunk *Chunk, v3i NoiseBasis, void *NoiseParams, void *UserData ); */ + +/* link_internal u32 */ +/* Terrain_Perlin3D( world_chunk *Chunk, v3i NoiseBasis, void *NoiseParams, void *UserData ); */ + +/* link_internal u32 */ +/* Terrain_Perlin2D( world_chunk *Chunk, v3i NoiseBasis, void *NoiseParams, void *UserData ); */ + +/* link_internal u32 */ +/* Terrain_Voronoi3D( world_chunk *Chunk, v3i NoiseBasis, void *NoiseParams, void *UserData ); */ /* link_internal u32 */ -/* Terrain_Voronoi2D( world_chunk *, v3i, v3i, v3i, u16, s32, s32, s64, v3i, void *); */ +/* Terrain_Voronoi2D( world_chunk *Chunk, v3i NoiseBasis, void *NoiseParams, void *UserData ); */ link_internal u32 -Terrain_Voronoi3D( world_chunk *, v3i, void *, void * ); +FinalizeOccupancyMasksFromNoiseValues(world_chunk *Chunk, v3i WorldBasis, v3i NoiseDim, u16 *NoiseValues, v3i SrcToDest, s64 zMin); diff --git a/src/engine/terrain_render.cpp b/src/engine/terrain_render.cpp new file mode 100644 index 000000000..9464f8738 --- /dev/null +++ b/src/engine/terrain_render.cpp @@ -0,0 +1,80 @@ + + +link_internal texture * +DispatchTerrainShaders(graphics *Graphics, world_chunk *Chunk) +{ + texture *InputTex = 0; + // + // Launch terrain shaping shader + // + { + auto *RC = &Graphics->TerrainShapingRC; + + RC->WorldspaceChunkBasis = V3(Chunk->WorldP) * V3(64); + RC->ChunkResolution = V3(Chunk->DimInChunks); + + TIMED_NAMED_BLOCK(TerrainShaping); + + GetGL()->BindFramebuffer(GL_FRAMEBUFFER, RC->DestFBO.ID); + UseShader(RC); + + v2i DestTextureDim = RC->DestTex.Dim; + SetViewport(DestTextureDim); + Assert(DestTextureDim == V2i(68, 68*68)); + + RenderQuad(); + + AssertNoGlErrors; + InputTex = &RC->DestTex; + } + + + // + // Calculate derivs of terrain shaping step + // + { + auto *RC = &Graphics->TerrainDerivsRC; + + TIMED_NAMED_BLOCK(TerrainDerivs); + GetGL()->BindFramebuffer(GL_FRAMEBUFFER, RC->DestFBO.ID); + UseShader(RC); + + // @derivs_texture_binding_to_shader_unit_0 + BindUniformByName(&RC->Program, "InputTex", InputTex, 0); + + v2i DestTextureDim = RC->DestTex.Dim; + Assert(DestTextureDim == V2i(66, 66*66)); + SetViewport(DestTextureDim); + + RenderQuad(); + + AssertNoGlErrors; + + /* InputTex = &RC->DestTex; */ + } + + // + // Launch terrain decoration shader + // + { + auto *RC = &Graphics->TerrainDecorationRC; + + RC->WorldspaceChunkBasis = V3(Chunk->WorldP) * V3(64); + RC->ChunkResolution = V3(Chunk->DimInChunks); + + TIMED_NAMED_BLOCK(TerrainDecoration); + GetGL()->BindFramebuffer(GL_FRAMEBUFFER, RC->DestFBO->ID); + UseShader(RC); + // Using texture unit 1 because the DerivsTex is automatically bound in UseShader to unit 0 + // @derivs_texture_binding_to_shader_unit_0 + BindUniformByName(&RC->Program, "InputTex", InputTex, 1); + + RenderQuad(); + + AssertNoGlErrors; + + InputTex = RC->DestTex; + } + + return InputTex; +} diff --git a/src/engine/util.h b/src/engine/util.h new file mode 100644 index 000000000..9ec52bd2c --- /dev/null +++ b/src/engine/util.h @@ -0,0 +1,22 @@ + + +link_internal maybe_file_traversal_node +EngineDrawFileNodesFilteredHelper(file_traversal_node Node, u64 Params) +{ + engine_resources *Engine = GetEngineResources(); + filtered_file_traversal_helper_params *HelperParams = ReinterpretCast(filtered_file_traversal_helper_params*, Params); + maybe_file_traversal_node Result = DrawFileNodes(&Engine->Ui, Node, HelperParams); + return Result; +} + +link_internal b32 DefaultFileFilter(file_traversal_node *Node) { return True; } + +link_internal maybe_file_traversal_node +EngineDrawFileNodesHelper(file_traversal_node Node, u64 Window) +{ + engine_resources *Engine = GetEngineResources(); + filtered_file_traversal_helper_params HelperParams = {(window_layout*)Window, DefaultFileFilter}; + maybe_file_traversal_node Result = DrawFileNodes(&Engine->Ui, Node, &HelperParams); + return Result; +} + diff --git a/src/engine/voxel.cpp b/src/engine/voxel.cpp new file mode 100644 index 000000000..192457964 --- /dev/null +++ b/src/engine/voxel.cpp @@ -0,0 +1,27 @@ +link_internal s32 +GetOccupancyBit(world_chunk *Chunk, s32 Index) +{ + /* Assert(Index < Volume(Chunk->Dim)); */ + s32 Result = GetOccupancyBit(Chunk->Occupancy, Index); + return Result; +} + +link_internal void +SetOccupancyBit(world_chunk *Chunk, s32 Index, s32 BitValue) +{ + s32 ByteIndex = Index/64; + s32 BitIndex = Index%64; + + Chunk->Occupancy[ByteIndex] &= ~(u64(1) << BitIndex); // Unconditionally knock out the bit + Chunk->Occupancy[ByteIndex] |= (u64(BitValue) << BitIndex); // Set new value.. 0 just does nothing + + /* s32 Test = GetOccupancyBit(Chunk, Index); */ + /* Assert(Test == BitValue); */ +} + +link_internal void +SetOccupancyMask(world_chunk *Chunk, s32 Index, u64 MaskValue) +{ + /* s32 MaskIndex = Index/64; */ + Chunk->Occupancy[Index] = MaskValue; +} diff --git a/src/engine/voxel.h b/src/engine/voxel.h new file mode 100644 index 000000000..c367230fc --- /dev/null +++ b/src/engine/voxel.h @@ -0,0 +1,23 @@ + +enum voxel_occupancy +{ + VoxelOccupancy_Empty = 0, + VoxelOccupancy_Filled = 1, +}; + + +link_internal s32 +GetOccupancyBit(u64 *Occupancy, s32 Index) +{ + s32 MaskIndex = Index/64; + s32 BitIndex = Index%64; + s32 Result = (Occupancy[MaskIndex] >> BitIndex) & 1; + return Result; +} + + +link_internal void +SetOccupancyBit(world_chunk *Chunk, s32 Index, s32 BitValue); + +link_internal s32 +GetOccupancyBit(world_chunk *Chunk, s32 Index); diff --git a/src/engine/voxel_face.h b/src/engine/voxel_face.h index c21c53c48..daaad89ae 100644 --- a/src/engine/voxel_face.h +++ b/src/engine/voxel_face.h @@ -22,14 +22,14 @@ /* global_variable f32 ShimmerStrength = 0.f; */ /* global_variable v3 ShimmerFix = {{ShimmerStrength, ShimmerStrength, ShimmerStrength}}; */ -global_variable v3 TopPlane = {{ 1.f, 1.f, 0.f }}; -global_variable v3 BotPlane = {{ 1.f, 1.f, 0.f }}; +/* global_variable v3 TopPlane = {{ 1.f, 1.f, 0.f }}; */ +/* global_variable v3 BotPlane = {{ 1.f, 1.f, 0.f }}; */ -global_variable v3 LeftPlane = {{ 0.f, 1.f, 1.f }}; -global_variable v3 RightPlane = {{ 0.f, 1.f, 1.f }}; +/* global_variable v3 LeftPlane = {{ 0.f, 1.f, 1.f }}; */ +/* global_variable v3 RightPlane = {{ 0.f, 1.f, 1.f }}; */ -global_variable v3 FrontPlane = {{ 1.f, 0.f, 1.f }}; -global_variable v3 BackPlane = {{ 1.f, 0.f, 1.f }}; +/* global_variable v3 FrontPlane = {{ 1.f, 0.f, 1.f }}; */ +/* global_variable v3 BackPlane = {{ 1.f, 0.f, 1.f }}; */ global_variable v3 v3_RightFaceNormalData[] = { {{ 1, 0, 0}}, {{ 1, 0, 0}}, {{ 1, 0, 0}}, {{ 1, 0, 0}}, {{ 1, 0, 0}}, {{ 1, 0, 0}} }; @@ -90,8 +90,6 @@ poof( vector_t.name Temp[] = { P2, P1, P0, P2, P3, P1 }; MemCopy((u8*)Temp, (u8*)Result, sizeof(Temp)); - - return; } inline void diff --git a/src/engine/voxel_synthesis.cpp b/src/engine/voxel_synthesis.cpp index 9cd557bde..3f10aa7a9 100644 --- a/src/engine/voxel_synthesis.cpp +++ b/src/engine/voxel_synthesis.cpp @@ -71,11 +71,13 @@ BakeVoxelSynthesisRules(const char* InputVox) DimIterator(xIndex, yIndex, zIndex, FillDim) { s32 VIndex = GetIndex(xIndex, yIndex, zIndex, ModelDim); - Vox.ChunkData->Voxels[VIndex].Flags = Voxel_Filled; - Vox.ChunkData->Voxels[VIndex].Color = RGBtoPackedHSV(RGB_GRASS_GREEN); + NotImplemented; + /* Vox.ChunkData->Voxels[VIndex].Flags = {}; */ + /* Vox.ChunkData->Voxels[VIndex].RGBColor = PackV3_16b(RGB_GRASS_GREEN); */ } - MarkBoundaryVoxels_NoExteriorFaces(Vox.ChunkData->Voxels, Vox.ChunkData->Dim, {}, Vox.ChunkData->Dim); + NotImplemented; + MakeFaceMasks_NoExteriorFaces( Vox.ChunkData->Occupancy, Vox.ChunkData->xOccupancyBorder, Vox.ChunkData->FaceMasks, 0, Vox.ChunkData->Dim, {}, Vox.ChunkData->Dim); Assert(Vox.ChunkData->Dim.x % Global_TileDim.x == 0); Assert(Vox.ChunkData->Dim.y % Global_TileDim.y == 0); @@ -116,7 +118,9 @@ BakeVoxelSynthesisRules(const char* InputVox) s32 ChunkVoxIndex = TryGetIndex( ChunkVoxP, Vox.ChunkData->Dim); if (ChunkVoxIndex > -1) { - voxel *V = Vox.ChunkData->Voxels + ChunkVoxIndex; + NotImplemented; + voxel *V = 0; + /* voxel *V = Vox.ChunkData->Voxels + ChunkVoxIndex; */ TileHash += Hash(V, TileVoxP); TempVoxels[TmpVoxelsIndex] = *V; } @@ -219,10 +223,12 @@ BakeVoxelSynthesisRules(const char* InputVox) voxel_synthesis_result Result = { + .Errors = {}, .VoxData = Vox, .Tiles = AllTiles, .Rules = Rules, .MaxTileEntropy = MaxTileEntropy, + .TileSuperpositionsDim = {}, }; #if 1 diff --git a/src/engine/voxel_synthesis.h b/src/engine/voxel_synthesis.h index 21926fccd..955fb90b6 100644 --- a/src/engine/voxel_synthesis.h +++ b/src/engine/voxel_synthesis.h @@ -104,10 +104,10 @@ VoxelSynthTile( tile_rule_id RuleId, u32 VoxelIndex, u64 HashValue, chunk_data * } -link_internal u64 +link_internal b32 AreEqual(voxel_synth_tile *T0, voxel_synth_tile *T1) { - u64 Result = T0->HashValue == T1->HashValue; + b32 Result = T0->HashValue == T1->HashValue; if (Result) { /* umm TempVoxelsSizeInBytes = sizeof(voxel)*umm(Volume(Global_TileDim)); */ @@ -115,13 +115,16 @@ AreEqual(voxel_synth_tile *T0, voxel_synth_tile *T1) { auto i = GetIndex(xIndex, yIndex, zIndex, Global_TileDim); + // Need to use the occupancy mask here + NotImplemented; + Result &= #if VOXEL_FACE_FLAGS_CONTRIBUTE_TO_HASH (T0->Voxels[i].Flags) == (T1->Voxels[i].Flags) && #else - (T0->Voxels[i].Flags&Voxel_Filled) == (T1->Voxels[i].Flags&Voxel_Filled) && + /* (T0->Voxels[i].Flags&Voxel_Filled) == (T1->Voxels[i].Flags&Voxel_Filled) && */ #endif - (T0->Voxels[i].Color) == (T1->Voxels[i].Color); + (T0->Voxels[i].RGBColor) == (T1->Voxels[i].RGBColor); if (!Result) break; } @@ -144,10 +147,12 @@ Hash(voxel *V, v3i P) { // Air voxels don't contribute to the hash, which is why we do the multiply // + u64 Result = 0; + NotImplemented; #if VOXEL_FACE_FLAGS_CONTRIBUTE_TO_HASH - u64 Result = u64(P.x + P.y + P.z + V->Flags + V->Color) * (V->Flags & Voxel_Filled); + /* u64 Result = u64(P.x + P.y + P.z + V->Flags + V->Color) * (V->Flags & Voxel_Filled); */ #else - u64 Result = u64(P.x + P.y + P.z + V->Color) * (V->Flags & Voxel_Filled); + /* u64 Result = u64(P.x + P.y + P.z + V->Color) * (V->Flags & Voxel_Filled); */ #endif /* u64 Result = u64(V->Flags + V->Color); */ diff --git a/src/engine/work_queue.h b/src/engine/work_queue.h index f448e4c13..22cbb0188 100644 --- a/src/engine/work_queue.h +++ b/src/engine/work_queue.h @@ -58,36 +58,34 @@ struct world_chunk; struct work_queue_entry_init_world_chunk { world_chunk *Chunk; - /* world_chunk_mesh_bitfield MeshBit; */ }; -struct work_queue_entry_rebuild_mesh +struct work_queue_entry_finalize_noise_values { - world_chunk *Chunk; - chunk_init_flags Flags; - /* world_chunk_mesh_bitfield MeshBit; */ -}; + gpu_readback_buffer PBOBuf; + u32 *NoiseData; + v3i NoiseDim; + octree_node *DestNode; +}; +struct work_queue_entry_build_chunk_mesh +{ + gen_chunk *GenChunk; + octree_node *DestNode; +}; +struct work_queue_entry_rebuild_mesh +{ + world_chunk *Chunk; + chunk_init_flags Flags; +}; -struct work_queue_entry_update_world_region -{ - world_edit_brush Brush; - // TODO(Jesse): These feel like part of the brush? - v3 HSVColor; - u8 Transparency; - b32 PersistWhitespace; - cp MinP; - cp MaxP; - world_chunk **DestChunkBuffer; - u32 ChunkCount; -}; struct asset; struct work_queue_entry_init_asset @@ -109,96 +107,12 @@ CAssert( (sizeof(work_queue_entry__align_to_cache_line_helper)+8) % CACHE_LINE_S - -#if VOXEL_DEBUG_COLOR -global_variable voxel Global_UnsetVoxel = { 0xff, 0xff, 0xffff, {}, {}}; -#else -global_variable voxel Global_UnsetVoxel = { 0xff, 0xff, 0xffff }; -#endif - - -#if 0 poof( - func rectilinear_world_update_inplace(type_poof_symbol MetaMode, - type_poof_symbol MetaModifier, - type_poof_symbol MetaShapeType, - type_poof_symbol UserCode) - { - link_internal void - RectilinearWorldUpdate_(MetaMode)_(MetaModifier)_(MetaShapeType) - ( world_edit_mode Mode, - world_edit_mode_modifier Modifier, - world_update_op_shape *Shape, - world_chunk **ChunkBuffer, - u32 ChunkCount, - rect3i *SimSpaceQueryAABB, - voxel *CopiedVoxels ) - { - - Assert(Mode == MetaMode); - Assert(Modifier == MetaModifier); - Assert(Shape->Type == MetaShapeType); - - /* v3i SimSpaceQueryMinP = V3i(SimSpaceQueryAABB->Min); */ - v3i SimSpaceQueryDim = GetDim(*SimSpaceQueryAABB); - Assert(SimSpaceQueryDim.x % Global_StandingSpotDim.x == 0); - Assert(SimSpaceQueryDim.y % Global_StandingSpotDim.y == 0); - - DimIterator(x, y, z, SimSpaceQueryDim) - { - v3i SimRelVoxP = V3i(x,y,z); - /* v3i SimVoxP = SimRelVoxP + SimSpaceQueryAABB.Min; */ - voxel *V = CopiedVoxels + GetIndex(SimRelVoxP, SimSpaceQueryDim); - - UserCode - } - } - - // Unfortunately, the C compiler is too stupid to do this. I'm leaving - // this here such that when adding a new callback you can manually paste - // this line into Initialize_Global_UpdateWorldCallbackTable() - // - static const char* lolwut_StringHack_(MetaMode)_(MetaModifier)_(MetaShapeType) = "Global_WorldUpdateCallbackTable[MetaMode][MetaModifier][MetaShapeType] = RectilinearWorldUpdate_(MetaMode)_(MetaModifier)_(MetaShapeType);"; - } -) - - -typedef void(*world_update_callback)(world_edit_mode, world_edit_mode_modifier, world_update_op_shape *, world_chunk **, u32, rect3i *, voxel *); - -global_variable world_update_callback -Global_WorldUpdateCallbackTable[WorldEdit_Mode_Count][WorldEdit_Modifier_Count][type_world_update_op_shape_params_count]; - - -poof(rectilinear_world_update_inplace( {WorldEdit_Mode_Attach}, - {WorldEdit_Modifier_None}, - {type_world_update_op_shape_params_rect}, - { - world_update_op_shape_params_rect *Rect = SafeCast(world_update_op_shape_params_rect, Shape); - rect3i SSRect = {V3i(Rect->P0), V3i(Rect->P1)}; - - /* voxel NewVoxelValue = { Voxel_Filled, NewTransparency, NewColor}; */ - /* if (Contains(SSRect, SimVoxP)) { *V = NewVoxelValue; } */ - } -)) -#include - -link_internal void -Initialize_Global_UpdateWorldCallbackTable() -{ - Global_WorldUpdateCallbackTable[WorldEdit_Mode_Attach][WorldEdit_Modifier_None][type_world_update_op_shape_params_rect] = RectilinearWorldUpdate_WorldEdit_Mode_Attach_WorldEdit_Modifier_None_type_world_update_op_shape_params_rect; -} -#endif - - - - - - -poof( - func asyncify_render_function_h(func_t) @code_fragment + func asyncify_render_function_h(func_t) { struct (func_t.name.to_snake_case)_async_params poof(@async_function_params) { + func_t.value ? { func_t.value* Result; } func_t.map(arg) { arg; @@ -207,18 +121,19 @@ poof( } ) -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)); poof( func asyncify_render_function_c(func_t) { link_internal void - (func_t.name)_Async(work_queue *Queue, func_t.map(arg).sep(,) { arg }) + (func_t.name)_Async(work_queue *Queue, func_t.map(arg).sep(,) { arg } func_t.value? { , func_t.value* Result }) { + // Make sure we don't accidentally pass something that's not the render queue + Assert(Queue == &GetStdlib()->Plat.LoRenderQ); + (func_t.name.to_snake_case)_async_params Params = { - func_t.map(arg) { arg.name, } + func_t.value? { Result, } func_t.map(arg) { arg.name, } }; work_queue_entry Entry = WorkQueueEntryAsyncFunction(&Params); @@ -228,37 +143,34 @@ poof( link_internal void DoJob((func_t.name.to_snake_case)_async_params *Params) { - func_t.name((func_t.map(arg).sep(,) { Params->(arg.name) })); + func_t.value? { auto Result = } func_t.name((func_t.map(arg).sep(,) { Params->(arg.name) })); + func_t.value? { if (Params->Result) { *Params->Result = Result; } } } } ) - -poof(asyncify_render_function_h(RenderToTexture)) -#include - -poof(asyncify_render_function_h(DrawLod)) -#include - - - - - - - - - - - - - +poof( + for_datatypes(func) + func (func_t) + { + func_t.has_tag(async)? + { + func_t.has_tag(render)? + { + asyncify_render_function_h(func_t) + } + } + } +) +#include +// Genereate tagged_union for async functions enum async_function_call_type { poof( - for_datatypes(all) @code_fragment + for_datatypes(struct) @code_fragment func (struct_t) { struct_t.has_tag(async_function_params)? @@ -266,7 +178,6 @@ enum async_function_call_type type_(struct_t.name), } } - func (enum_t) {} ) #include }; @@ -277,7 +188,7 @@ struct work_queue_entry_async_function_call union { poof( - for_datatypes(all) @code_fragment + for_datatypes(struct) @code_fragment func (struct_t) { struct_t.has_tag(async_function_params)? @@ -285,26 +196,31 @@ struct work_queue_entry_async_function_call struct_t.name struct_t.name; } } - func (enum_t) {} ) #include }; }; +poof(string_and_value_tables(async_function_call_type)) +#include + poof( d_union work_queue_entry { work_queue_entry_init_world_chunk + work_queue_entry_finalize_noise_values + work_queue_entry_build_chunk_mesh /* work_queue_entry_copy_buffer */ work_queue_entry_copy_buffer_set work_queue_entry_copy_buffer_ref work_queue_entry_init_asset - work_queue_entry_update_world_region + /* work_queue_entry_update_world_region */ work_queue_entry_rebuild_mesh work_queue_entry_sim_particle_system + // NOTE(Jesse): This is kind of a hack to put render commands onto the work // queue so I don't have to invent a whole generic system for having queues // with seperate work entry types. I should probably do this sometime in @@ -318,66 +234,74 @@ poof( ) #include +poof(string_and_value_tables(work_queue_entry_type)) +#include + // nocheckin // TODO(Jesse): Turn this on -CAssert(sizeof(work_queue_entry) % CACHE_LINE_SIZE == 0); +/* CAssert(sizeof(work_queue_entry) % CACHE_LINE_SIZE == 0); */ poof(d_union_constructors(work_queue_entry)) #include - - - - - poof( - for_datatypes(all) @code_fragment + for_datatypes(struct) @code_fragment func (struct_t) { struct_t.has_tag(async_function_params)? { struct struct_t.name; link_internal work_queue_entry - WorkQueueEntryAsyncFunction( (struct_t.type) *Params ) + WorkQueueEntryAsyncFunction( (struct_t.name) *Params ) { work_queue_entry Result = {}; Result.Type = type_work_queue_entry_async_function_call; - Result.work_queue_entry_async_function_call.Type = type_(struct_t.type); - Result.work_queue_entry_async_function_call.(struct_t.type) = *Params; + Result.work_queue_entry_async_function_call.Type = type_(struct_t.name); + Result.work_queue_entry_async_function_call.(struct_t.name) = *Params; return Result; } } } - func (enum_t) {} ) #include -link_internal void -RenderToTexture(engine_resources *Engine, asset_thumbnail *Thumb, lod_element_buffer *Meshes, v3 Offset, camera *Camera); - -poof(asyncify_render_function_c(RenderToTexture)) -#include -poof(asyncify_render_function_c(DrawLod)) -#include +poof( + for_datatypes(func) @code_fragment + func (func_t) + { + func_t.has_tag(async)? + { + func_t.has_tag(render)? + { + asyncify_render_function_c(func_t) + } + } + } +) +#include link_internal void -DispatchAsyncFunctionCall(work_queue_entry_async_function_call *Job) +DispatchAsyncFunctionCall(work_queue_entry_async_function_call *Task) { - tswitch(Job) + tswitch(Task) { - { - tmatch(render_to_texture_async_params, Job, RenderToTexture); - DoJob(RenderToTexture); - } break; - - { - tmatch(draw_lod_async_params, Job, DrawLodParams); - DoJob(DrawLodParams); - } break; + poof( + func (async_function_call_type tag_t) @code_fragment + { + tag_t.map(tag_v) + { + { + tmatch( tag_v.name.strip_single_prefix, Task, Job ); + DoJob(Job); + } break; + } + } + ) +#include } } @@ -390,6 +314,30 @@ DispatchAsyncFunctionCall(work_queue_entry_async_function_call *Job) + + + +link_internal s32 +EventsCurrentlyInQueue(work_queue *Queue) +{ + u32 Enqueue = Queue->EnqueueIndex; + u32 Dequeue = Queue->DequeueIndex; + + s32 Result = 0; + if (Dequeue < Enqueue) + { + Result = s32(Enqueue - Dequeue); + } + + if (Enqueue < Dequeue) + { + Result = s32((WORK_QUEUE_SIZE - Dequeue) + Enqueue); + } + + Assert(Result >= 0); + return Result; +} + // TODO(Jesse): Gen this from the constructors generator link_internal work_queue_entry WorkQueueEntry( particle_system *System, v3 EntityDelta, v3 RenderSpaceP, r32 dt) @@ -401,7 +349,7 @@ WorkQueueEntry( particle_system *System, v3 EntityDelta, v3 RenderSpaceP, r32 dt link_internal void -HandleJob(volatile work_queue_entry *Entry, thread_local_state *Thread, application_api *GameApi) +HandleJob(work_queue_entry *Entry, thread_local_state *Thread, application_api *GameApi) { if ( GameApi->WorkerMain && GameApi->WorkerMain(Entry, Thread)) @@ -415,20 +363,9 @@ HandleJob(volatile work_queue_entry *Entry, thread_local_state *Thread, applicat } -/* link_internal untextured_3d_geometry_buffer * */ -/* GetMeshFor(threadsafe_geometry_buffer *Buf, world_chunk_mesh_bitfield MeshBit); */ - -/* link_internal untextured_3d_geometry_buffer * */ -/* TakeOwnershipSync(threadsafe_geometry_buffer *Buf, world_chunk_mesh_bitfield MeshBit); */ - -/* link_internal void */ -/* ReleaseOwnership(threadsafe_geometry_buffer *Src, world_chunk_mesh_bitfield MeshBit, untextured_3d_geometry_buffer *Buf); */ - link_internal untextured_3d_geometry_buffer * TakeOwnershipSync(lod_element_buffer *Buf, world_chunk_mesh_bitfield MeshBit); link_internal void ReleaseOwnership(lod_element_buffer *Src, world_chunk_mesh_bitfield MeshBit, untextured_3d_geometry_buffer *Buf); - - diff --git a/src/engine/world.cpp b/src/engine/world.cpp index f60b20e1e..ce381fbd6 100644 --- a/src/engine/world.cpp +++ b/src/engine/world.cpp @@ -1,33 +1,72 @@ + +debug_global u32 DeferrFreedNodes; +debug_global u32 FreedNodes; + link_internal world * -AllocateWorld(world* World, world_position Center, voxel_position WorldChunkDim, chunk_dimension VisibleRegion) +AllocateWorld(world *World, v3i Center, visible_region_size VisibleRegionSize) { - Clear(World); + *World = {}; + Assert(World->ChunkDim == V3i(64)); memory_arena *WorldChunkMemory = AllocateArena(Gigabytes(2)); World->ChunkMemory = WorldChunkMemory; DEBUG_REGISTER_ARENA(World->ChunkMemory, 0); - World->HashSize = (u32)(Volume(VisibleRegion)*4); + memory_arena *OctreeMemory = AllocateArena(Megabytes(8)); + World->OctreeMemory = OctreeMemory; + DEBUG_REGISTER_ARENA(World->OctreeMemory, 0); + + /* World->HashSize = (u32)(Volume(VisibleRegion)*4); */ /* World->HashSize = WorldHashSize; */ - World->ChunkHashMemory[0] = Allocate(world_chunk*, WorldChunkMemory, World->HashSize ); - World->ChunkHashMemory[1] = Allocate(world_chunk*, WorldChunkMemory, World->HashSize ); + /* World->ChunkHashMemory[0] = Allocate(world_chunk*, WorldChunkMemory, World->HashSize ); */ + /* World->ChunkHashMemory[1] = Allocate(world_chunk*, WorldChunkMemory, World->HashSize ); */ - World->ChunkHash = World->ChunkHashMemory[0]; + /* World->ChunkHash = World->ChunkHashMemory[0]; */ /* World->FreeChunks = Allocate(world_chunk*, WorldChunkMemory, FREELIST_SIZE ); */ - World->ChunkDim = WorldChunkDim; - World->VisibleRegion = VisibleRegion; + + World->OctreeNodeFreelist.Memory = World->OctreeMemory; + + World->VisibleRegionSize = VisibleRegionSize; World->Center = Center; + // NOTE(Jesse): Has to come after World->ChunkDim is set + v3i VisibleRegion = V3i(VisibleRegionSize); + InitOctreeNode(World, &World->Root, {}, VisibleRegion, {}); + World->Root.Chunk = AllocateWorldChunk( {}, World->ChunkDim, VisibleRegion, World->ChunkMemory); + return World; } +link_internal void +ReinitializeOctreeNode(engine_resources *Engine, octree_node *Node, octree_node *Parent, octree_node_priority_queue *Queue, octree_stats *Stats) +{ + UNPACK_ENGINE_RESOURCES(Engine); + Assert(!FutexIsSignaled(&Node->Lock)); + + Assert(NotSet(Node->Flags, Chunk_Queued)); + { + AcquireFutex(&Node->Lock); + + if (Node->Chunk == 0) { Node->Chunk = GetFreeWorldChunk(Engine->World); } + + WorldChunk(Node->Chunk, Node->WorldP, Engine->World->ChunkDim, Node->Resolution); + PushOctreeNodeToPriorityQueue(World, GameCamera, Queue, Node, Parent); + + ReleaseFutex(&Node->Lock); + } +} + // TODO(Jesse): rect3cp should probably be a pointer..? // +#if 1 link_internal world_chunk_ptr_buffer GatherChunksOverlappingArea(world *World, rect3cp Region, memory_arena *Memory) { + NotImplemented; + return {}; +#if 0 auto MinP = Region.Min; auto MaxP = Region.Max; @@ -58,9 +97,55 @@ GatherChunksOverlappingArea(world *World, rect3cp Region, memory_arena *Memory) } } + Result.Count = ChunkIndex; + return Result; +#endif +} +#else +link_internal octree_node_ptr_buffer +GatherChunksOverlappingArea(world *World, rect3cp Region, memory_arena *Memory) +{ + auto MinP = Region.Min; + auto MaxP = Region.Max; + + Assert(MaxP.WorldP >= MinP.WorldP); + v3i Delta = MaxP.WorldP - MinP.WorldP + 1; + u32 TotalChunkCount = Abs(Volume(Delta)); + + world_chunk_ptr_buffer Result = {}; + + // NOTE(Jesse): These need to be aligned to the cache line size, so don't use the constructor fn + Result.Start = 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); + if (octree_node *Node = GetWorldChunkFromOctree( World, P )) + { + b32 AlreadyAddedToSet = False; + for (u32 TestIndex = 0; TestIndex < ChunkIndex; ++TestIndex) + { + if (Result.Start[TestIndex] == Node) { AlreadyAddedToSet = True; break; } + } + Assert(ChunkIndex < TotalChunkCount); + if (AlreadyAddedToSet == False) + { + Result.Start[ChunkIndex++] = Chunk; + } + } + } + } + } + Result.Count = ChunkIndex; return Result; } +#endif link_internal void @@ -75,7 +160,7 @@ GatherRangesOverlapping(world *World, rect3i SimSpaceAABB, world_chunk_ptr_buffe { world_chunk *Chunk = ChunkBuffer->Start[ChunkIndex]; auto SimSpaceChunkRect = GetSimSpaceAABBi(World, Chunk); - auto SimSpaceIntersectionRect = Union(&SimSpaceChunkRect, &SimSpaceAABB); + auto SimSpaceIntersectionRect = Intersection(&SimSpaceChunkRect, &SimSpaceAABB); auto SimSpaceIntersectionMin = SimSpaceIntersectionRect.Min; auto SimSpaceIntersectionMax = SimSpaceIntersectionRect.Max; @@ -95,6 +180,8 @@ GatherRangesOverlapping(world *World, rect3i SimSpaceAABB, world_chunk_ptr_buffe link_internal void GatherVoxelsOverlappingArea(world *World, rect3i SimSpaceAABB, world_chunk_ptr_buffer *ChunkBuffer, voxel *Voxels, s32 VoxelCount) { + NotImplemented; +#if 0 Assert(Volume(SimSpaceAABB) == VoxelCount); v3i SimSpaceQueryDim = GetDim(SimSpaceAABB); @@ -104,12 +191,7 @@ GatherVoxelsOverlappingArea(world *World, rect3i SimSpaceAABB, world_chunk_ptr_b u32 TotalVoxels = (u32)TotalVoxels_signed; - // TODO(Jesse): Put this behind a debug/internal flag ? -#if VOXEL_DEBUG_COLOR - voxel UnsetVoxel = { 0xff, 0xff, 0xffff, {}, {} }; -#else - voxel UnsetVoxel = { 0xff, 0xff, 0xffff }; -#endif + voxel UnsetVoxel = { 0xff, 0xffff, 0xffff }; for (u32 VoxelIndex = 0; VoxelIndex < TotalVoxels; ++VoxelIndex) { Voxels[VoxelIndex] = UnsetVoxel; } v3i SimSpaceQueryMinP = SimSpaceAABB.Min; @@ -118,7 +200,7 @@ GatherVoxelsOverlappingArea(world *World, rect3i SimSpaceAABB, world_chunk_ptr_b { world_chunk *Chunk = ChunkBuffer->Start[ChunkIndex]; auto SimSpaceChunkRect = GetSimSpaceAABBi(World, Chunk); - auto SimSpaceIntersectionRect = Union(&SimSpaceChunkRect, &SimSpaceAABB); + auto SimSpaceIntersectionRect = Intersection(&SimSpaceChunkRect, &SimSpaceAABB); auto SimSpaceIntersectionMin = SimSpaceIntersectionRect.Min; auto SimSpaceIntersectionMax = SimSpaceIntersectionRect.Max; @@ -137,7 +219,8 @@ GatherVoxelsOverlappingArea(world *World, rect3i SimSpaceAABB, world_chunk_ptr_b { voxel_position RelVoxP = Voxel_Position(s32(xVoxel), s32(yVoxel), s32(zVoxel)); voxel *V = GetVoxel(Chunk, RelVoxP); - Assert( (V->Flags & Voxel_MarkBit) == 0); + NotImplemented; + /* Assert( (V->Flags & Voxel_MarkBit) == 0); */ v3i SimSpaceVoxPExact = V3i(xVoxel, yVoxel, zVoxel) + SimSpaceChunkMin; @@ -150,6 +233,7 @@ GatherVoxelsOverlappingArea(world *World, rect3i SimSpaceAABB, world_chunk_ptr_b } } } +#endif } link_internal world_chunk @@ -165,8 +249,1010 @@ GatherVoxelsOverlappingArea(engine_resources *Engine, rect3cp Rect, memory_arena GatherVoxelsOverlappingArea(World, GetSimSpaceRect3i(World, Rect), &Chunks, V, VoxelCount); world_chunk Result = {}; + NotImplemented; +#if 0 Result.Voxels = V; Result.Dim = V3i(CopyDim); +#endif + + return Result; +} + + + + + + + + + + + + + +// +// Octree implementation +// + +link_internal rect3cp +GetBoundingBox(world *World, octree_node *Node) +{ + cp Min = Canonical_Position(V3(0), Node->WorldP); + cp Max = Canonicalize(World, Canonical_Position(V3(0), Node->WorldP+Node->Resolution)); + + rect3cp Rect = RectMinMax(Min, Max); + return Rect; +} + +link_internal rect3 +GetSimSpaceAABB(world *World, octree_node *Node) +{ + rect3cp CPRect = GetBoundingBox(World, Node); + rect3 Result = GetSimSpaceAABB(World, CPRect); + return Result; +} + +link_internal cp +GetCenter(world *World, octree_node *Node) +{ + cp Min = Canonical_Position(V3(0), Node->WorldP); + cp Max = Canonicalize(World, Canonical_Position(V3(0), Node->WorldP+Node->Resolution)); + + cp Rad = (Max-Min)/2; + + cp Center = CAdd(World, Min, Rad); + return Center; +} + +link_internal b32 +ContainsCameraGhost(world *World, entity **EntityTable, octree_node *Node, camera *Camera) +{ + rect3cp Rect = GetBoundingBox(World, Node); + + b32 Result = {}; + if (entity *Ghost = GetEntity(EntityTable, Camera->GhostId)) + { + Result = Contains(Rect, Ghost->P); + } + return Result; +} + +/* link_internal b32 */ +/* OctreeNodeNeedsToSplit(world *World, octree_node *Node, camera *Camera) */ +/* { */ +/* Assert(Node->Chunk->Dim == World->ChunkDim); */ +/* Assert(Node->Type); */ +/* Assert(Node->DimInChunks >= V3i(1)); */ + +/* b32 Result = Node->DimInChunks > V3i(1); */ +/* Result &= (Node->Chunk->Flags & Chunk_Queued) == 0; */ +/* Result &= ContainsCamera(World, Node, Camera); */ + +/* return Result; */ +/* } */ + +/* link_internal b32 */ +/* OctreeChildrenNeedToMerge(world *World, octree_node *Node, camera *Camera) */ +/* { */ +/* Assert(Node->Chunk->Dim % World->ChunkDim == V3i(0)); */ + +/* b32 Result = Node->Type == OctreeNodeType_Transit; */ +/* Result &= ContainsCamera(World, Node, Camera) == False; */ +/* return Result; */ +/* } */ + + +link_internal void +InitOctreeNode(world *World, octree_node *Node, v3i WorldP, v3i DimInChunks, world_edit_ptr_block_array *PotentialEdits) +{ + TIMED_FUNCTION(); + + // TODO(Jesse): Should there be a pointer to the editor on the World? + // Or should this just take the editor too..? + level_editor *Editor = &GetEngineResources()->Editor; + + *Node = {}; + Node->Type = OctreeNodeType_Leaf; + Node->WorldP = WorldP; + Node->Resolution = DimInChunks; + + rect3cp NodeBounds = GetBoundingBox(World, Node); + + if (PotentialEdits) + { + Node->Edits.Memory = PotentialEdits->Memory; + IterateOver(PotentialEdits, Edit, EditIndexIndex) + { + /* auto Edit = GetPtr(&Editor->Edits, *Edit); */ + /* Assert(Edit); */ + + if (Intersect(World, &NodeBounds, &Edit->Region)) + { + Push(&Node->Edits, Edit); + } + } + } + + Assert(DimInChunks > V3i(0)); +} + +link_internal octree_node * +GetParentNodeFor(world *World, octree_node *QueryNode) +{ + rect3cp QueryBox = GetBoundingBox(World, QueryNode); + + v3i NodeWorldMidpoint = QueryBox.Min.WorldP + ((QueryBox.Max.WorldP - QueryBox.Min.WorldP)/2); + cp NodeMidpoint = Canonical_Position(V3(0.f), NodeWorldMidpoint); + + octree_node *Result = {}; + octree_node *Parent = {}; + octree_node *Current = &World->Root; + + b32 Done = False; + while (Done == False) + { + + { + rect3cp CurrentBox = GetBoundingBox(World, Current); + Assert (Contains(CurrentBox, NodeMidpoint)); + } + { + v3i CurrentToQuery = NodeMidpoint.WorldP - Current->Chunk->WorldP; + v3i Cell = CurrentToQuery / (Current->Chunk->DimInChunks/2); + Assert(Cell < V3i(2)); + + s32 Index = GetIndex(Cell, V3i(2)); Assert(Index < 8); + + switch(Current->Type) + { + InvalidCase(OctreeNodeType_Undefined); + + case OctreeNodeType_Leaf: + { + Assert(Current == &World->Root); + Done = True; + } break; + + case OctreeNodeType_Branch: + { + if ( Current->Children[Index] == QueryNode ) + { + Result = Current; + Done = True; + } + else + { + Current = Current->Children[Index]; + { + rect3cp CurrentBox = GetBoundingBox(World, Current); + Assert (Contains(CurrentBox, NodeMidpoint)); + } + } + + } break; + } + } + /* else */ + { + /* Done = True; */ + } + + } + + if (QueryNode != &World->Root) + { + Assert(Result); + } + return Result; +} + + +typedef void (*octree_traversal_callback)(octree_node *); + +link_internal void +RecursiveOctreeTraversal( engine_resources *Engine, octree_node *Node, octree_traversal_callback Callback) +{ + UNPACK_ENGINE_RESOURCES(Engine); + + Callback(Node); + + switch(Node->Type) + { + InvalidCase(OctreeNodeType_Undefined); + + case OctreeNodeType_Branch: + { + RecursiveOctreeTraversal(Engine, Node->Children[0], Callback); + RecursiveOctreeTraversal(Engine, Node->Children[1], Callback); + RecursiveOctreeTraversal(Engine, Node->Children[2], Callback); + RecursiveOctreeTraversal(Engine, Node->Children[3], Callback); + RecursiveOctreeTraversal(Engine, Node->Children[4], Callback); + RecursiveOctreeTraversal(Engine, Node->Children[5], Callback); + RecursiveOctreeTraversal(Engine, Node->Children[6], Callback); + RecursiveOctreeTraversal(Engine, Node->Children[7], Callback); + } break; + + case OctreeNodeType_Leaf: + { + } break; + + } +} + +link_internal void +DEBUG_OctreeTraversal( engine_resources *Engine, octree_node *Node, octree_stats *Stats) +{ + UNPACK_ENGINE_RESOURCES(Engine); + + world_chunk *Chunk = Node->Chunk; + f32 AABBLineDim = Max(1.f, Node->Resolution.x/12.f); + + switch(Node->Type) + { + InvalidCase(OctreeNodeType_Undefined); + + case OctreeNodeType_Branch: + { + if (Chunk) + { + if (EngineDebug->DrawBranchNodes) + { + DEBUG_DrawChunkAABB(&GpuMap->Buffer, Graphics, Chunk, World->ChunkDim, RGB_ORANGE, AABBLineDim); + } + + if (HasGpuMesh(&Node->Chunk->Handles) && EngineDebug->DrawBranchNodesWithMeshes) + { + DEBUG_DrawChunkAABB(&GpuMap->Buffer, Graphics, Chunk, World->ChunkDim, RGB_ORANGE, AABBLineDim); + } + } + + DEBUG_OctreeTraversal(Engine, Node->Children[0], Stats); + DEBUG_OctreeTraversal(Engine, Node->Children[1], Stats); + DEBUG_OctreeTraversal(Engine, Node->Children[2], Stats); + DEBUG_OctreeTraversal(Engine, Node->Children[3], Stats); + DEBUG_OctreeTraversal(Engine, Node->Children[4], Stats); + DEBUG_OctreeTraversal(Engine, Node->Children[5], Stats); + DEBUG_OctreeTraversal(Engine, Node->Children[6], Stats); + DEBUG_OctreeTraversal(Engine, Node->Children[7], Stats); + + ++Stats->TotalBranches; + } break; + + case OctreeNodeType_Leaf: + { + if (Chunk && EngineDebug->DrawLeafNodes) + { + DEBUG_DrawChunkAABB(&GpuMap->Buffer, Graphics, Node->Chunk, World->ChunkDim, RGB_GREEN, AABBLineDim); + } + + ++Stats->TotalLeaves; + } break; + + } + + if (Chunk && Node->Flags & Chunk_Queued) + { + if (EngineDebug->DrawQueuedNodes) + { + DEBUG_DrawChunkAABB(&GpuMap->Buffer, Graphics, Node->Chunk, World->ChunkDim, RGB_RED, AABBLineDim*2.f); + } + ++Stats->TotalQueued; + } +} + +link_internal v3i +ComputeNodeDesiredResolution(engine_resources *Engine, octree_node *Node) +{ + UNPACK_ENGINE_RESOURCES(Engine); + + rect3 NodeRect = GetSimSpaceAABB(World, Node); + v3 CameraP = GetSimSpaceP(World, GameCamera->CurrentP); + r32 Distance = DistanceToBox(CameraP, NodeRect); + s32 DistanceInChunks = s32(Distance) / s32(World->ChunkDim.x); + + v3i Result = Max(V3i(1), V3i(DistanceInChunks / Engine->World->ChunksPerResolutionStep)); + return Result; +} +link_internal b32 +OctreeBranchShouldCollapse(engine_resources *Engine, octree_node *Node) +{ + UNPACK_ENGINE_RESOURCES(Engine); + Assert(Node->Type == OctreeNodeType_Branch); + + b32 Result = False; + + if (world_chunk *Chunk = Node->Chunk) + { + Assert(Node->Resolution == Chunk->DimInChunks); + Assert(Node->WorldP == Chunk->WorldP); + if (Node->Flags & Chunk_Queued) return Result; + } + + v3i Res = ComputeNodeDesiredResolution(Engine, Node); + if (Res > Node->Resolution) + { + Result = True; + } + return Result; +} + +link_internal b32 +OctreeLeafShouldSplit(engine_resources *Engine, octree_node *Node) +{ + UNPACK_ENGINE_RESOURCES(Engine); + Assert(Node->Type == OctreeNodeType_Leaf); + + if (world_chunk *Chunk = Node->Chunk) + { + Assert(Node->Resolution == Chunk->DimInChunks); + Assert(Node->WorldP == Chunk->WorldP); + } + + b32 Result = False; + if (Node->Resolution > V3i(1)) + { + v3i Res = ComputeNodeDesiredResolution(Engine, Node); + if (Res < Node->Resolution) + { + Result = True; + } + } + + return Result; +} + +#define RatioToListIndex(i) (OCTREE_PRIORITY_QUEUE_LIST_COUNT-1) - Min(s32(OCTREE_PRIORITY_QUEUE_LIST_COUNT-1), s32(i)); + + +// 0 is highest priority, OCTREE_PRIORITY_QUEUE_LIST_COUNT is lowest +// +link_internal s32 +ComputePriorityIndex(world *World, octree_node *Node, octree_node *Parent, camera *GameCamera) +{ + /* s32 IdealListIndex = RatioToListIndex(Node->Resolution.x/World->ChunksPerResolutionStep); */ + /* s32 IdealListIndex = Min(Node->Resolution.x*32, OCTREE_PRIORITY_QUEUE_LIST_COUNT-1); */ + /* s32 IdealListIndex = Min(Node->Resolution.x, OCTREE_PRIORITY_QUEUE_LIST_COUNT-1); */ + s32 IdealListIndex = Min(Node->Resolution.x, OCTREE_PRIORITY_QUEUE_LIST_COUNT-1); + + + // Prefer large nodes close to the camera + { + v3 CamSimP = GetSimSpaceP(World, GameCamera->CurrentP); + aabb Box = GetSimSpaceAABB(World, Node); + + r32 D = DistanceToBox(CamSimP, Box); + // DRatio is small when a large box is close to the camera + r32 DRatio = D / Node->Resolution.x; + s32 Offset = s32((1.f/DRatio) * 32.f); + IdealListIndex = Max(OCTREE_PRIORITY_QUEUE_LIST_COUNT-1, IdealListIndex-Offset); + } + + // Prefer nodes who intersect the camera ray +#if 0 + auto Engine = GetEngineResources(); + /* if (Engine->MaybeMouseRay.Tag) */ + { + v3 CamSimP = GetSimSpaceP(World, GameCamera->CurrentP); + ray Ray = {CamSimP, GameCamera->Front}; + aabb Box = GetSimSpaceAABB(World, Node); + r32 t; + if (Intersect(&Box, &Ray, &t)) + { + IdealListIndex = Max(OCTREE_PRIORITY_QUEUE_LIST_COUNT-1, IdealListIndex-100); + } + } +#endif + +#if 1 + // Penalize nodes who are not in the frustum + if (IsInFrustum(World, GameCamera, Node) == False) + { + /* IdealListIndex = OCTREE_PRIORITY_QUEUE_LIST_COUNT-1; */ + IdealListIndex = Min(OCTREE_PRIORITY_QUEUE_LIST_COUNT-1, IdealListIndex+128); + } +#endif + +#if 0 + // Penalize nodes who's parent is not in the frustum + if (Parent) + { + if (IsInFrustum(World, GameCamera, Parent) == False) + { + /* IdealListIndex = OCTREE_PRIORITY_QUEUE_LIST_COUNT-1; */ + IdealListIndex = Min(OCTREE_PRIORITY_QUEUE_LIST_COUNT-1, IdealListIndex+128); + } + } +#endif + + // Prefer chunks who have a higher chance of having geometry + if (Parent && Parent->Chunk && HasGpuMesh(&Parent->Chunk->Handles)) + { + IdealListIndex = Max(0, IdealListIndex-30); + } + + // Prefer chunks who have been edited + if (Count(&Node->Edits)) + { + IdealListIndex = Max(0, IdealListIndex-100); + } + + // Prefer chunks who are dirty + if (Node->Dirty) + { + IdealListIndex = Max(0, IdealListIndex-100); + } + + Assert(IdealListIndex >= 0 && IdealListIndex < OCTREE_PRIORITY_QUEUE_LIST_COUNT); + return IdealListIndex; +} + +link_internal b32 +PushOctreeNodeToPriorityQueue(world *World, camera *GameCamera, octree_node_priority_queue *Queue, octree_node *Node, octree_node *Parent) +{ + Assert(NotSet(Node, Chunk_Queued)); + + b32 Result = False; + + s32 IdealListIndex = ComputePriorityIndex(World, Node, Parent, GameCamera); + if (Remaining(&Queue->Lists[IdealListIndex])) + { + Push(&Queue->Lists[IdealListIndex], Node); + Result = True; + } + + return Result; +} + + +link_internal void +FreeOctreeNode(engine_resources *Engine, octree_node **Bucket) +{ + octree_node *Node = *Bucket; + *Bucket = 0; + + switch(Node->Type) + { + InvalidCase(OctreeNodeType_Undefined); + + case OctreeNodeType_Leaf: + { + } break; + + case OctreeNodeType_Branch: + { + FreeOctreeChildren(Engine, Node); + } break; + + } + + + if (world_chunk *Chunk = Node->Chunk) + { + if (Node->Flags & Chunk_Queued) + { + if ( (Node->Flags & Chunk_Deallocate) == 0) + { + { // debug + octree_node *TestNode = Engine->World->OctreeNodeDeferFreelist.First; + while (TestNode) { Assert(TestNode != Node); TestNode = TestNode->Next; } + } + + // TODO(Jesse, bug): This is a bug waiting to happen. Pretty sure this could + // accidentally persist the Chunk_Queued flag after the worker thread had + // un-set it and therefore jam up the DeferFreelist (forever waiting on + // a "Queued" chunk that's not actually queued). + Node->Flags = chunk_flag(Node->Flags|Chunk_Deallocate); + Free(&Engine->World->OctreeNodeDeferFreelist, Node); + ++DeferrFreedNodes; + } + } + else + { + Assert(Node->Flags & Chunk_VoxelsInitialized); + Assert( (Node->Flags & Chunk_Queued) == False); + FreeWorldChunk(Engine, Chunk); + + Clear(Node); + Free(&Engine->World->OctreeNodeFreelist, Node); + ++FreedNodes; + } + } + else + { + Clear(Node); + Free(&Engine->World->OctreeNodeFreelist, Node); + ++FreedNodes; + } + +} + +#if 1 +link_internal u32 +FreeOctreeChildren(engine_resources *Engine, octree_node *Node) +{ + UNPACK_ENGINE_RESOURCES(Engine); + if (Node->Chunk) { Assert(Node->Chunk->Dim % World->ChunkDim == V3i(0)); } + + if (Node->Type == OctreeNodeType_Branch) + { + Node->Type = OctreeNodeType_Leaf; + FreeOctreeNode(Engine, Node->Children+0); + FreeOctreeNode(Engine, Node->Children+1); + FreeOctreeNode(Engine, Node->Children+2); + FreeOctreeNode(Engine, Node->Children+3); + FreeOctreeNode(Engine, Node->Children+4); + FreeOctreeNode(Engine, Node->Children+5); + FreeOctreeNode(Engine, Node->Children+6); + FreeOctreeNode(Engine, Node->Children+7); + } + else + { + Assert(Node->Type == OctreeNodeType_Leaf); + Assert(Node->Children[0] == 0); + Assert(Node->Children[1] == 0); + Assert(Node->Children[2] == 0); + Assert(Node->Children[3] == 0); + Assert(Node->Children[4] == 0); + Assert(Node->Children[5] == 0); + Assert(Node->Children[6] == 0); + Assert(Node->Children[7] == 0); + } + + u32 Result = 1; + return Result; +} +#endif + + + +link_internal void +SplitOctreeNode_Recursive( engine_resources *Engine, + octree_node_priority_queue *Queue, + octree_node *NodeToSplit, + octree_node *Parent, + memory_arena *Memory ) +{ + UNPACK_ENGINE_RESOURCES(Engine); + + world_chunk *Chunk = NodeToSplit->Chunk; + + b32 Initialized = IsSet(NodeToSplit->Flags, Chunk_VoxelsInitialized); + b32 Queued = IsSet(NodeToSplit->Flags, Chunk_Queued); + b32 Dirty = NodeToSplit->Dirty; + + if (!Queued) + { + if (Initialized) + { + if (Chunk) { if (HasGpuMesh(&Chunk->Handles) == False) { NodeToSplit->Chunk = 0; FreeWorldChunk(Engine, Chunk); Chunk = 0; /* Info("%d", ComputePriorityIndex(World, NodeToSplit, Parent, GameCamera)); */ }} + if (Dirty) { PushOctreeNodeToPriorityQueue(World, GameCamera, Queue, NodeToSplit, Parent); } + } + else + { + PushOctreeNodeToPriorityQueue(World, GameCamera, Queue, NodeToSplit, Parent); + } + } + + Assert (NodeToSplit); + { + switch(NodeToSplit->Type) + { + InvalidCase(OctreeNodeType_Undefined); + + case OctreeNodeType_Branch: + { + if (OctreeBranchShouldCollapse(Engine, NodeToSplit)) + { + FreeOctreeChildren(Engine, NodeToSplit); + } + else + { + /* if (IsInitialized(NodeToSplit)) */ + /* if (AllChildrenAreInitialized(NodeToSplit)) */ + { + local_persist random_series TraversalRng = {43125437654765}; + u32 Mask = 7u; + u32 StartingIndex = RandomU32(&TraversalRng) & Mask; + Assert(StartingIndex < 8); + + SplitOctreeNode_Recursive(Engine, Queue, NodeToSplit->Children[(StartingIndex+0)&Mask], NodeToSplit, Memory); + SplitOctreeNode_Recursive(Engine, Queue, NodeToSplit->Children[(StartingIndex+1)&Mask], NodeToSplit, Memory); + SplitOctreeNode_Recursive(Engine, Queue, NodeToSplit->Children[(StartingIndex+2)&Mask], NodeToSplit, Memory); + SplitOctreeNode_Recursive(Engine, Queue, NodeToSplit->Children[(StartingIndex+3)&Mask], NodeToSplit, Memory); + SplitOctreeNode_Recursive(Engine, Queue, NodeToSplit->Children[(StartingIndex+4)&Mask], NodeToSplit, Memory); + SplitOctreeNode_Recursive(Engine, Queue, NodeToSplit->Children[(StartingIndex+5)&Mask], NodeToSplit, Memory); + SplitOctreeNode_Recursive(Engine, Queue, NodeToSplit->Children[(StartingIndex+6)&Mask], NodeToSplit, Memory); + SplitOctreeNode_Recursive(Engine, Queue, NodeToSplit->Children[(StartingIndex+7)&Mask], NodeToSplit, Memory); + } + } + } break; + + case OctreeNodeType_Leaf: + { + if (IsInitialized(NodeToSplit)) + { + b32 DoSplit = Parent == 0 || AllChildrenAreInitialized(Parent); + if (OctreeLeafShouldSplit(Engine, NodeToSplit)) + { + NodeToSplit->Type = OctreeNodeType_Branch; + + v3i ChildDimInChunks = NodeToSplit->Resolution / 2; + Assert(ChildDimInChunks >= V3i(1)); + + RangeIterator(Index, s32(ArrayCount(NodeToSplit->Children))) + { + Assert(NodeToSplit->Children[Index] == 0); + + // NOTE(Jesse): This is used as a mask so we can drop out + // dimensions that are on the min edge when computing RelWorldP + v3i P = PositionFromIndex(Index, V3i(2)); + Assert(P < V3i(2)); + v3i RelWorldP = P * ChildDimInChunks; + + octree_node *Child = GetOrAllocate(&World->OctreeNodeFreelist); + NodeToSplit->Children[Index] = Child; + + InitOctreeNode(World, Child, NodeToSplit->WorldP + RelWorldP, ChildDimInChunks, &NodeToSplit->Edits); + } + } + } + + } break; + + } + } +} + +link_internal b32 +IsInitialized(octree_node *Node) +{ + b32 Result = (Node->Flags & Chunk_VoxelsInitialized); return Result; } +link_internal b32 +AllChildrenAreInitialized(octree_node *Node) +{ + b32 Result = IsInitialized(Node->Children[0]); + Result &= IsInitialized(Node->Children[1]); + Result &= IsInitialized(Node->Children[2]); + Result &= IsInitialized(Node->Children[3]); + Result &= IsInitialized(Node->Children[4]); + Result &= IsInitialized(Node->Children[5]); + Result &= IsInitialized(Node->Children[6]); + Result &= IsInitialized(Node->Children[7]); + + return Result; +} + +link_internal void +DrawOctreeRecursive( engine_resources *Engine, + octree_node *Node, + octree_node *Parent, + octree_node_ptr_paged_list *MainDrawList, + octree_node_ptr_paged_list *ShadowMapDrawList, + octree_stats *Stats, + u32 Depth = 0 ) +{ + UNPACK_ENGINE_RESOURCES(Engine); + Assert (Node); + + world_chunk *Chunk = Node->Chunk; + if (Chunk) { Assert(Node->Chunk->Dim % World->ChunkDim == V3i(0)); } + + f32 AABBLineDim = Max(1.f, Node->Resolution.x/12.f); + switch(Node->Type) + { + InvalidCase(OctreeNodeType_Undefined); + + case OctreeNodeType_Branch: + { + if (Chunk && EngineDebug->DrawBranchNodes) + { + DEBUG_DrawChunkAABB(&GpuMap->Buffer, Graphics, Chunk, World->ChunkDim, RGB_ORANGE, AABBLineDim); + } + + if (Chunk && HasGpuMesh(&Chunk->Handles) && EngineDebug->DrawBranchNodesWithMeshes) + { + DEBUG_DrawChunkAABB(&GpuMap->Buffer, Graphics, Chunk, World->ChunkDim, RGB_ORANGE, AABBLineDim); + } + + if (AllChildrenAreInitialized(Node)) + { + DrawOctreeRecursive(Engine, Node->Children[0], Node, MainDrawList, ShadowMapDrawList, Stats, Depth+1); + DrawOctreeRecursive(Engine, Node->Children[1], Node, MainDrawList, ShadowMapDrawList, Stats, Depth+1); + DrawOctreeRecursive(Engine, Node->Children[2], Node, MainDrawList, ShadowMapDrawList, Stats, Depth+1); + DrawOctreeRecursive(Engine, Node->Children[3], Node, MainDrawList, ShadowMapDrawList, Stats, Depth+1); + DrawOctreeRecursive(Engine, Node->Children[4], Node, MainDrawList, ShadowMapDrawList, Stats, Depth+1); + DrawOctreeRecursive(Engine, Node->Children[5], Node, MainDrawList, ShadowMapDrawList, Stats, Depth+1); + DrawOctreeRecursive(Engine, Node->Children[6], Node, MainDrawList, ShadowMapDrawList, Stats, Depth+1); + DrawOctreeRecursive(Engine, Node->Children[7], Node, MainDrawList, ShadowMapDrawList, Stats, Depth+1); + } + else + { // Draw ourselves while we wait for children to initialize + + if (Depth == EngineDebug->OctreeDrawDepth || EngineDebug->OctreeDrawDepth == 0xFFFFFFFF) + { + if (Chunk) + { + if (ContainsCameraGhost(World, EntityTable, Node, GameCamera)) + { + EngineDebug->SelectedNode = Node; + } + + if (EngineDebug->DrawNodesWithChunks) + { + DEBUG_DrawChunkAABB(&GpuMap->Buffer, Graphics, Chunk, World->ChunkDim, RGB_GREEN, AABBLineDim); + } + + if (HasGpuMesh(&Chunk->Handles)) + { + if (IsInFrustum( World, Camera, Chunk )) + { + Push(MainDrawList, Node); + Push(ShadowMapDrawList, Node); + } + } + } + } + } + } break; + + case OctreeNodeType_Leaf: + { + if (Chunk) + { + if (EngineDebug->DrawLeafNodes) + { + DEBUG_DrawChunkAABB(&GpuMap->Buffer, Graphics, Chunk, World->ChunkDim, RGB_GREEN, AABBLineDim); + } + + if (Depth == EngineDebug->OctreeDrawDepth || EngineDebug->OctreeDrawDepth == 0xFFFFFFFF) + { + if (EngineDebug->DrawNodesWithChunks) + { + DEBUG_DrawChunkAABB(&GpuMap->Buffer, Graphics, Chunk, World->ChunkDim, RGB_GREEN, AABBLineDim); + } + + if (HasGpuMesh(&Chunk->Handles)) + { + if (IsInFrustum( World, Camera, Chunk )) + { + Push(MainDrawList, Node); + Push(ShadowMapDrawList, Node); + } + } + } + } + + } break; + + } +} + + + +link_internal void +SplitAndQueueOctreeNodesForInit(engine_resources *Engine) +{ + TIMED_FUNCTION(); + + UNPACK_ENGINE_RESOURCES(Engine); + + + Assert(EntityTable); + + b32 Continue = True; + u32 ChunksQueued = 0; + +#if 1 + // Free deferred chunks that are complete + { + while (World->OctreeNodeDeferFreelist.First) + { + octree_node *Node = World->OctreeNodeDeferFreelist.First; + octree_node *Next = Node->Next; + + if (Node->Flags & Chunk_Queued) + { + break; + } + else + { + Assert(Node->Flags & Chunk_VoxelsInitialized); + Assert( (Node->Flags & Chunk_Queued) == False); + + FreeWorldChunk(Engine, Node->Chunk); + + Clear(Node); + Free(&World->OctreeNodeFreelist, Node); + + ++FreedNodes;; + } + + Node = Next; + World->OctreeNodeDeferFreelist.First = Node; + } + } +#endif + + + octree_stats Stats = {}; + + { + s32 ChunksCurrentlyQueued = s32(Graphics->TotalChunkJobsActive); + s32 Headroom = MAX_OCTREE_NODES_QUEUED_TOTAL - ChunksCurrentlyQueued; + s32 MaxToQueueThisFrame = Max(0, Headroom); + octree_node_priority_queue Queue = {}; + RangeIterator(ListIndex, OCTREE_PRIORITY_QUEUE_LIST_COUNT) + { + Queue.Lists[ListIndex] = OctreeNodePtrCursor(OCTREE_PRIORITY_QUEUE_LIST_LENGTH, GetTranArena()); + } + + TIMED_NAMED_BLOCK(SplitOctreeNode_Recursive); + SplitOctreeNode_Recursive(Engine, &Queue, &World->Root, 0, World->OctreeMemory); + + { + TIMED_NAMED_BLOCK(QueueChunks); + s32 NumQueuedThisFrame = 0; + if (MaxToQueueThisFrame) + { + RangeIterator(ListIndex, OCTREE_PRIORITY_QUEUE_LIST_COUNT) + /* IterateOver(Queue.Lists, List, ListIndex) */ + { + octree_node_ptr_cursor List = Queue.Lists[ListIndex]; + IterateOver(&List, NodeP, NPIndex) + { + if (NodeP) + { + octree_node *Node = *NodeP; + + // Even though we should check this before pushing nodes onto the + // priority queue, we could have pushed the node multiple times if we + // did an edit and it overlapped with an uninitialized part of the world. + if (NotSet(Node->Flags, Chunk_Queued)) + { + if (Node->Chunk) + { + Assert(IsAllocated(Node->Chunk)); + } + else + { + Node->Chunk = GetFreeWorldChunk(World); + WorldChunk(Node->Chunk, Node->WorldP, GetWorldChunkDim(), Node->Resolution); + } + + Node->Dirty = False; + Node->Chunk->FilledCount = 0; + QueueChunkForInit(&Plat->LoRenderQ, Node, MeshBit_Lod0); + ++Stats.NewQueues; + if (++NumQueuedThisFrame == MaxToQueueThisFrame) goto done_queueing_nodes; + } + } + else + { + break; + } + } + } + } + } + + } + +done_queueing_nodes: + + return; +} + +link_internal void +DispatchOctreeDrawJobs(engine_resources *Engine) +{ + TIMED_FUNCTION(); + + UNPACK_ENGINE_RESOURCES(Engine); + + + Assert(EntityTable); + + auto *MainDrawList = &Graphics->MainDrawList; + auto *ShadowMapDrawList = &Graphics->ShadowMapDrawList; + + // Reset draw lists + { + Clear(MainDrawList); + Clear(ShadowMapDrawList); + + MainDrawList->Memory = GetTranArena(); + ShadowMapDrawList->Memory = GetTranArena(); + } + + octree_stats Stats = {}; + + { + TIMED_NAMED_BLOCK(DrawOctreeRecursive); + DrawOctreeRecursive(Engine, &World->Root, 0, MainDrawList, ShadowMapDrawList, &Stats); + } + + return; +} + + +link_internal octree_node * +GetWorldChunkFromOctree(world *World, v3i WorldP) +{ + octree_node *Result = {}; + octree_node *Current = &World->Root; + + b32 Done = False; + while (Done == False) + { + rect3cp Box = GetBoundingBox(World, Current); + if (Contains(Box, Canonical_Position(V3(0), WorldP))) + { + v3i CurrentToQuery = WorldP - Current->Chunk->WorldP; + v3i Cell = CurrentToQuery / Current->Chunk->DimInChunks; + Assert(Cell < V3i(2)); + + s32 Index = GetIndex(Cell, V3i(2)); Assert(Index < 8); + + switch(Current->Type) + { + InvalidCase(OctreeNodeType_Undefined); + + case OctreeNodeType_Leaf: + { + Assert (Current->Type == OctreeNodeType_Leaf); + Result = Current; + Done = True; + } break; + + case OctreeNodeType_Branch: + { + Current = Current->Children[Index]; + } break; + } + } + else + { + Done = True; + } + + } + + return Result; +} + +link_internal void +GatherOctreeNodesOverlapping_Recursive(world *World, octree_node *Current, rect3cp *Region, octree_node_ptr_block_array *Result) +{ + Assert(Current); + + rect3cp Box = GetBoundingBox(World, Current); + if (Intersect(World, &Box, Region)) + { + Push(Result, Current); + + switch(Current->Type) + { + InvalidCase(OctreeNodeType_Undefined); + + case OctreeNodeType_Leaf: + { + } break; + + case OctreeNodeType_Branch: + { + GatherOctreeNodesOverlapping_Recursive(World, Current->Children[0], Region, Result); + GatherOctreeNodesOverlapping_Recursive(World, Current->Children[1], Region, Result); + GatherOctreeNodesOverlapping_Recursive(World, Current->Children[2], Region, Result); + GatherOctreeNodesOverlapping_Recursive(World, Current->Children[3], Region, Result); + GatherOctreeNodesOverlapping_Recursive(World, Current->Children[4], Region, Result); + GatherOctreeNodesOverlapping_Recursive(World, Current->Children[5], Region, Result); + GatherOctreeNodesOverlapping_Recursive(World, Current->Children[6], Region, Result); + GatherOctreeNodesOverlapping_Recursive(World, Current->Children[7], Region, Result); + } break; + } + } +} + diff --git a/src/engine/world.h b/src/engine/world.h index fda311707..95d564f50 100644 --- a/src/engine/world.h +++ b/src/engine/world.h @@ -1,6 +1,315 @@ +global_variable chunk_dimension +WORLD_CHUNK_DIM = Chunk_Dimension(64, 64, 64); + +enum visible_region_size +{ + VisibleRegionSize_1 = (1 << 0), + VisibleRegionSize_2 = (1 << 1), + VisibleRegionSize_4 = (1 << 2), + VisibleRegionSize_8 = (1 << 3), + VisibleRegionSize_16 = (1 << 4), // (1k^3) + VisibleRegionSize_32 = (1 << 5), + VisibleRegionSize_64 = (1 << 6), + VisibleRegionSize_128 = (1 << 7), + VisibleRegionSize_256 = (1 << 8), + VisibleRegionSize_512 = (1 << 9), // 3.3 km + VisibleRegionSize_1k = (1 << 10), // 6.6 km + VisibleRegionSize_2k = (1 << 11), // 13.1 km + VisibleRegionSize_4k = (1 << 12), // 26.2 km + VisibleRegionSize_8k = (1 << 13), // 52.4 km + VisibleRegionSize_16k = (1 << 14), // 104.8 km (1m^3) + VisibleRegionSize_32k = (1 << 15), // 209.6 km + VisibleRegionSize_64k = (1 << 16), // 419.2 km + VisibleRegionSize_128k = (1 << 17), // 838.4 km + VisibleRegionSize_256k = (1 << 18), // big + VisibleRegionSize_512k = (1 << 19), // big + VisibleRegionSize_1024k = (1 << 20), // big + VisibleRegionSize_2048k = (1 << 21), // really big + VisibleRegionSize_4096k = (1 << 22), // really big + VisibleRegionSize_8192k = (1 << 23), // really big + VisibleRegionSize_16kk = (1 << 24), // dumb (1b^3) +}; + +enum octree_node_type +{ + OctreeNodeType_Undefined, + + OctreeNodeType_Branch, // Interior edge + /* OctreeNodeType_Twig, // Edge directly connected to leaf */ + OctreeNodeType_Leaf, // .. leaf +}; + +struct octree_node +{ + chunk_flag Flags; + octree_node_type Type; + + // TODO(Jesse): Pack into flags + b32 Dirty; + + v3i WorldP; + v3i Resolution; // in world-chunk space. Resolution of V3i(2) means the chunk occupies 2x2x2 chunks in world-space + + // NOTE(Jesse): This is a pointer such that we can cull chunks that are empty, or completely full. + world_chunk *Chunk; + + // NOTE(Jesse): Took the union out because the UI doesn't know how to deal.. + /* union { */ + octree_node *Children[8]; poof(@custom_ui(if (Element->Children[ArrayIndex]) {DoEditorUi(Ui, Window, Element->Children[ArrayIndex], CSz("Child"), ThisHash, Params);})) + octree_node *Next; // NOTE(Jesse): Freelist Next + /* }; */ + + world_edit_ptr_block_array Edits; + + bonsai_futex Lock; +}; + +typedef octree_node* octree_node_ptr; + +poof(buffer(octree_node_ptr)) +#include + +struct picked_octree_node +{ + octree_node *Node; + r32 t; +}; + +poof(are_equal(octree_node)) +#include +poof(generate_stack(octree_node_ptr, {})) +#include + +poof(freelist_allocator(octree_node)) +#include + +poof(freelist_allocator(world_chunk)) +#include + +poof(freelist_allocator(gen_chunk)) +#include + +poof(generate_cursor(octree_node_ptr)) +#include + +poof(block_array(octree_node_ptr, {32})) +#include + +poof(block_array(picked_octree_node, {32})) +#include + +struct world +{ + v3i Center; // the world chunk position of the center of the visible region + visible_region_size VisibleRegionSize; // The number of chunks in xyz we're going to update and render + + octree_node Root; + memory_arena *OctreeMemory; + octree_node_freelist OctreeNodeFreelist; + octree_node_freelist OctreeNodeDeferFreelist; // Chunks that were queued, to be freed later. + +#define MAX_OCTREE_NODES_QUEUED_TOTAL (64) +#define MAX_OCTREE_NODES_QUEUED_PER_FRAME (32) + s32 MaxOctreeNodesToQueuePerFrame = MAX_OCTREE_NODES_QUEUED_PER_FRAME; +#undef MAX_OCTREE_NODES_QUEUED_PER_FRAME + + s32 ChunksPerResolutionStep = 4; + + bonsai_futex ChunkFreelistFutex; poof(@ui_skip) + world_chunk ChunkFreelistSentinal; poof(@ui_skip) + s32 FreeChunkCount; + s32 TotalChunksAllocated; + s32 TotalGenChunksAllocated; + + v3i ChunkDim = V3i(64); poof(@ui_skip) + memory_arena *ChunkMemory; poof(@ui_skip) +}; + + +struct octree_stats +{ + s32 NewQueues = 0; + s32 TotalQueued = 0; + s32 TotalLeaves = 0; + s32 TotalBranches = 0; +}; + + + +inline canonical_position +Canonicalize( world *World, canonical_position CP ) +{ + canonical_position Result = Canonicalize( World->ChunkDim, CP.Offset, CP.WorldP ); + return Result; +} + +// NOTE(Jesse): Technically, these should always be strictly less than the chunkdim, +// but because of float-ness we can actually hit directly on it. +inline b32 +IsCanonical( world *World, canonical_position CP ) +{ + b32 Result = CP.Offset <= V3(World->ChunkDim); + return Result; +} + +link_internal v3 +GetSimSpaceP(world *World, world_position P) +{ + v3i CenterToP = P - World->Center; + v3 Result = V3(CenterToP*World->ChunkDim); + return Result; +} + +link_internal v3 +GetSimSpaceP(world *World, canonical_position P) +{ + cp WorldCenter = Canonical_Position(V3(0), World->Center); + cp CenterToP = P - WorldCenter; + v3 Result = CenterToP.Offset + (CenterToP.WorldP*World->ChunkDim); + return Result; +} + +link_internal v3 +GetSimSpaceP(world *World, picked_voxel *P, picked_voxel_position Pos = PickedVoxel_FirstFilled) +{ + v3 Result = GetSimSpaceP(World, Canonical_Position(P, Pos)); + return Result; +} + +link_internal v3i +GetSimSpacePi(world *World, world_chunk *Chunk) +{ + world_position CenterToP = Chunk->WorldP - World->Center; + v3i Result = CenterToP*World->ChunkDim; + return Result; +} + +link_internal v3 +GetSimSpaceP(world *World, world_chunk *Chunk) +{ + v3 Result = V3(GetSimSpacePi(World, Chunk)); + return Result; +} + +link_internal rect3i +GetSimSpaceAABBi(world *World, world_chunk *Chunk) +{ + v3i SimSpaceMin = GetSimSpacePi(World, Chunk); + rect3i Result = Rect3iMinDim(SimSpaceMin, World->ChunkDim ); + return Result; +} + +link_internal aabb +GetSimSpaceAABB(world *World, world_chunk *Chunk) +{ + v3 SimSpaceMin = GetSimSpaceP(World, Chunk); + aabb Result = AABBMinDim(SimSpaceMin, V3(World->ChunkDim) ); + return Result; +} + +link_internal v3 +GetSimSpaceCenterP(world *World, standing_spot *Spot) +{ + v3 Result = GetSimSpaceP(World, Spot->P) + Global_StandingSpotHalfDim; + return Result; +} + +link_internal v3 +GetSimSpaceBaseP(world *World, standing_spot *Spot) +{ + v3 Result = GetSimSpaceP(World, Spot->P) + V3(Global_StandingSpotHalfDim.xy, 0.f); + return Result; +} + +link_internal cp +GetSpotMidpoint(world *World, standing_spot *Spot) +{ + cp Result = Canonical_Position(World->ChunkDim, Spot->P.Offset+Global_StandingSpotHalfDim, Spot->P.WorldP); + return Result; +} + +link_internal rect3i +GetVisibleRegionRect(world *World) +{ + world_position CenterP = World->Center; + chunk_dimension Radius = V3i(World->VisibleRegionSize/2); + world_position Min = CenterP - Radius; + world_position Max = CenterP + Radius + 1; // Add one so we can pass to functions that expect an open-interval + + return RectMinMax(Min, Max); +} + +link_internal b32 +IsInsideVisibleRegion(world *World, v3i P) +{ + rect3i VRRect = GetVisibleRegionRect(World); + b32 Result = IsInside(P, VRRect); + return Result; +} + +#if 0 +inline voxel* +TryGetVoxel(world *World, cp P) +{ + voxel *Result = {}; + world_chunk *Chunk = GetWorldChunkFromHashtable(World, P.WorldP); + if (Chunk) + { + Result = TryGetVoxel(Chunk, V3i(P.Offset)); + } + return Result; +} +#endif + + +#define OCTREE_PRIORITY_QUEUE_LIST_COUNT (512) +#define OCTREE_PRIORITY_QUEUE_LIST_LENGTH (512) +struct octree_node_priority_queue +{ + octree_node_ptr_cursor Lists[OCTREE_PRIORITY_QUEUE_LIST_COUNT]; +}; + link_internal world * GetWorld(); link_internal void GatherRangesOverlapping(world *World, rect3i SimSpaceAABB, world_chunk_ptr_buffer *ChunkBuffer, rect3i_buffer *ResultRanges); +link_internal octree_node * +GetWorldChunkFromOctree(world *World, v3i QueryP); + +link_internal b32 +OctreeLeafShouldSplit(engine_resources *Engine, octree_node *Node); + +link_internal u32 +FreeOctreeChildren(engine_resources *Engine, octree_node *Node); + +link_internal world_chunk_ptr_buffer +GatherChunksOverlappingArea(world *World, rect3cp Region, memory_arena *Memory); + +link_internal void +InitOctreeNode(world *World, octree_node *Node, v3i WorldP, v3i DimInChunks, world_edit_ptr_paged_list *PotentialEdits); + +link_internal world * +AllocateWorld(world* World, v3i Center, visible_region_size VisibleRegion); + +link_internal rect3cp +GetBoundingBox(world *World, octree_node *Node); + +link_internal void +SplitOctreeNode_Recursive( engine_resources *Engine, octree_node_priority_queue *Queue, octree_node *NodeToSplit, octree_node *Parent, memory_arena *Memory); + +link_internal rect3 +GetSimSpaceAABB(world *World, octree_node *Node); + +link_internal b32 +PushOctreeNodeToPriorityQueue(world *World, camera *GameCamera, octree_node_priority_queue *Queue, octree_node *Node, octree_node *Parent); + +link_internal void +ReinitializeOctreeNode(engine_resources *Engine, octree_node *Node, octree_node *Parent, octree_node_priority_queue *Queue, octree_stats *Stats); + +link_internal b32 +AllChildrenAreInitialized(octree_node *Node); + +link_internal b32 +IsInitialized(octree_node *Node); diff --git a/src/engine/world_chunk.cpp b/src/engine/world_chunk.cpp index cc94ad3f2..34b24308c 100644 --- a/src/engine/world_chunk.cpp +++ b/src/engine/world_chunk.cpp @@ -1,3 +1,5 @@ +poof( block_array_c(entity_ptr, {8}) ) +#include poof(block_array_c(world_chunk_ptr, {32})) #include @@ -28,6 +30,7 @@ ClearChunkVoxels(voxel *Voxels, chunk_dimension Dim) #endif } +#if 0 link_internal void UnSetMeshBit(world_chunk *Chunk, world_chunk_mesh_bitfield MeshBit) { @@ -36,6 +39,7 @@ UnSetMeshBit(world_chunk *Chunk, world_chunk_mesh_bitfield MeshBit) Assert(Chunk->Meshes.MeshMask & MeshBit); Chunk->Meshes.MeshMask = Chunk->Meshes.MeshMask & (~MeshBit); } +#endif #if 0 link_internal untextured_3d_geometry_buffer * @@ -49,15 +53,31 @@ SetMesh(world_chunk *Chunk, world_chunk_mesh_bitfield MeshBit, mesh_freelist *Me #endif link_internal void -FinalizeChunkInitialization(world_chunk *Chunk) +FinalizeNodeInitializaion(octree_node *Node) { FullBarrier; - /* UnSetFlag(Chunk, Chunk_Garbage); */ - UnSetFlag(&Chunk->Flags, Chunk_Queued); - SetFlag(&Chunk->Flags, Chunk_VoxelsInitialized); + u32 Flags = Node->Flags; + if ( (Flags & Chunk_Freelist) != 0) + { + Info("%d", Flags); + RuntimeBreak(); + } + + if ( (Flags & Chunk_Queued) == 0) + { + Info("%d", Flags); + RuntimeBreak(); + } + + /* UnSetFlag(Node, Chunk_Garbage); */ + UnSetFlag(&Node->Flags, Chunk_Queued); + SetFlag(&Node->Flags, Chunk_VoxelsInitialized); + + FullBarrier; } +#if 0 inline b32 ChunkIsGarbage(world_chunk* Chunk) { @@ -67,28 +87,90 @@ ChunkIsGarbage(world_chunk* Chunk) b32 Garbage = IsSet(Chunk, Chunk_Garbage); return Garbage; } +#endif link_internal void -AllocateWorldChunk(world_chunk *Result, world_position WorldP, chunk_dimension Dim, memory_arena *Storage) +WorldChunk(world_chunk *Chunk, v3i WorldP, v3i Dim, v3i DimInChunks) +{ + Chunk->FilledCount = {}; + Chunk->WorldP = WorldP; + Chunk->Dim = Dim; + Chunk->DimInChunks = DimInChunks; +} + +#if 0 +link_internal world_chunk * +HeapAllocateWorldChunk( v3i WorldP, v3i Dim, v3i DimInChunks) { + TIMED_FUNCTION(); + world_chunk *Result = (world_chunk*)_aligned_malloc(sizeof(world_chunk), CACHE_LINE_SIZE); + memset(Result, 0, sizeof(world_chunk)); + u32 MaxLodMeshVerts = POINT_BUFFER_SIZE*3; - Result->Voxels = AllocateVoxels(Storage, Dim); - Result->WorldP = WorldP; + s32 VoxCount = Volume(Dim); + if (VoxCount) + { + umm OccupancyCount = (umm(VoxCount)+63u) / 64u; // Add seven so we round up when we divide if there's an extra one (or several) + Result->Occupancy = (u64*)_aligned_malloc(sizeof(u64)*OccupancyCount, CACHE_LINE_SIZE); + memset(Result->Occupancy, 0, sizeof(u64)*OccupancyCount); + + Result->xOccupancyBorder = (u64*)_aligned_malloc(sizeof(u64)*umm(xOccupancyBorder_ElementCount), CACHE_LINE_SIZE); + memset(Result->xOccupancyBorder, 0, sizeof(u64)*umm(xOccupancyBorder_ElementCount)); - Result->Dim = Dim; - /* Result->DimX = SafeTruncateU8(Dim.x); */ - /* Result->DimY = SafeTruncateU8(Dim.y); */ - /* Result->DimZ = SafeTruncateU8(Dim.z); */ + Result->FaceMasks = (u64*)_aligned_malloc(sizeof(u64)*6*OccupancyCount, CACHE_LINE_SIZE); + memset(Result->FaceMasks, 0, sizeof(u64)*6*OccupancyCount); + + Result->Voxels = (voxel*)_aligned_malloc(sizeof(voxel)*umm(VoxCount), CACHE_LINE_SIZE); + memset(Result->Voxels, 0, sizeof(voxel)*umm(VoxCount)); + } + + WorldChunk(Result, WorldP, Dim, DimInChunks); + return Result; + /* Result->StandingSpots = V3iCursor(WORLD_CHUNK_STANDING_SPOT_COUNT); */ +} + +link_internal void +HeapFreeWorldChunk( world_chunk *Chunk ) +{ + /* HISTOGRAM_FUNCTION(); */ + TIMED_FUNCTION(); + Assert(Chunk->Dim == V3i(64, 66, 66)); + _aligned_free(Chunk->Occupancy); + _aligned_free(Chunk->xOccupancyBorder); + _aligned_free(Chunk->FaceMasks); + _aligned_free(Chunk->Voxels); + _aligned_free(Chunk); +} +#endif + +link_internal void +AllocateWorldChunk(world_chunk *Result, v3i WorldP, v3i Dim, v3i DimInChunks, memory_arena *Storage) +{ + GetWorld()->TotalChunksAllocated++; + + u32 MaxLodMeshVerts = POINT_BUFFER_SIZE*3; + + s32 VoxCount = Volume(Dim); + if (VoxCount) + { + s32 OccupancyCount = (VoxCount+63) / 64; // Add seven so we round up when we divide if there's an extra one (or several) + Result->Occupancy = AllocateAlignedProtection(u64, Storage, OccupancyCount, CACHE_LINE_SIZE, false); + Result->xOccupancyBorder = AllocateAlignedProtection(u64, Storage, xOccupancyBorder_ElementCount, CACHE_LINE_SIZE, false); + Result->FaceMasks = AllocateAlignedProtection(u64, Storage, 6*OccupancyCount, CACHE_LINE_SIZE, false); + /* Result->Voxels = AllocateAlignedProtection(voxel, Storage, VoxCount, CACHE_LINE_SIZE, false); */ + } + + WorldChunk(Result, WorldP, Dim, DimInChunks); Result->StandingSpots = V3iCursor(WORLD_CHUNK_STANDING_SPOT_COUNT, Storage); } link_internal world_chunk * -AllocateWorldChunk(world_position WorldP, chunk_dimension Dim, memory_arena *Storage) +AllocateWorldChunk(v3i WorldP, v3i Dim, v3i DimInChunks, memory_arena *Storage) { world_chunk *Result = AllocateAlignedProtection(world_chunk, Storage, 1, CACHE_LINE_SIZE, false); - AllocateWorldChunk(Result, WorldP, Dim, Storage); + AllocateWorldChunk(Result, WorldP, Dim, DimInChunks, Storage); return Result; } @@ -116,6 +198,9 @@ GetWorldChunkHash(world_position P, chunk_dimension VisibleRegion, u32 WorldHash link_internal b32 InsertChunkIntoWorld(world_chunk **WorldChunkHash, world_chunk *Chunk, chunk_dimension VisibleRegion, u32 WorldHashSize) { + NotImplemented; + return {}; +#if 0 /* TIMED_FUNCTION(); */ GetWorld()->HashSlotsUsed += 1; @@ -172,12 +257,15 @@ InsertChunkIntoWorld(world_chunk **WorldChunkHash, world_chunk *Chunk, chunk_dim *Current = Chunk; return Result; +#endif } link_internal b32 InsertChunkIntoWorld(world *World, world_chunk *Chunk) { - b32 Result = InsertChunkIntoWorld(World->ChunkHash, Chunk, World->VisibleRegion, World->HashSize); + NotImplemented; + /* b32 Result = InsertChunkIntoWorld(World->ChunkHash, Chunk, World->VisibleRegion, World->HashSize); */ + b32 Result = {}; return Result; } @@ -186,7 +274,10 @@ AllocateAndInsertChunk(world *World, world_position P) { TIMED_FUNCTION(); + NotImplemented; + world_chunk *Result = 0; +#if 0 if (IsInsideVisibleRegion(World, P)) { @@ -213,9 +304,32 @@ AllocateAndInsertChunk(world *World, world_position P) } } +#endif return Result; } + + +link_internal b32 +HasGpuMesh(gpu_element_buffer_handles *Handles) +{ + b32 Result = (Handles->VAO != 0); + if (Result) + { + Assert(Handles->Handles[0]); + Assert(Handles->Handles[1]); + Assert(Handles->Handles[2]); + Assert(Handles->ElementCount); + } + return Result; +} + +link_internal b32 +HasGpuMesh(world_chunk *Chunk) +{ + return HasGpuMesh(&Chunk->Handles); +} + link_internal world_chunk * GetFreeWorldChunk(world *World) { @@ -229,20 +343,18 @@ GetFreeWorldChunk(world *World) World->FreeChunkCount -= 1; Result = (world_chunk*)Next; - Assert(Result->Flags == Chunk_Freelist); - Result->Flags = {}; + if (Result->IsOnFreelist == False) { RuntimeBreak(); } + Result->IsOnFreelist = False; ReleaseFutex(&World->ChunkFreelistFutex); } else { /* Info("Allocated World Chunk"); */ - Result = AllocateWorldChunk({}, World->ChunkDim, World->ChunkMemory); - Assert(Result->Flags == Chunk_Uninitialized); + Result = AllocateWorldChunk(INVALID_WORLD_CHUNK_POSITION, World->ChunkDim, {}, World->ChunkMemory); } - Assert(Result->Meshes.MeshMask == 0); - Result->WorldP = INVALID_WORLD_CHUNK_POSITION; - + Assert(Result->WorldP == INVALID_WORLD_CHUNK_POSITION); + Assert(HasGpuMesh(Result) == False); return Result; } @@ -279,9 +391,8 @@ GetAndInsertFreeWorldChunk(world *World, world_position P) if (Result) { Assert(Result->WorldP == P); - Assert(Result->Voxels); + /* Assert(Result->Voxels); */ Assert(Result->Dim == World->ChunkDim); - Assert(Result->Flags == Chunk_Uninitialized); } } @@ -289,16 +400,15 @@ GetAndInsertFreeWorldChunk(world *World, world_position P) return Result; } +#if 0 link_internal void DeallocateGpuBuffers(work_queue *RenderQueue, world_chunk *Chunk ) { - RangeIterator(MeshIndex, MeshIndex_Count) - { - PushDeallocateBuffersCommand(RenderQueue, &Chunk->Meshes.GpuBufferHandles[MeshIndex]); - Assert(Chunk->Meshes.GpuBufferHandles[MeshIndex].Mapped == False); - Assert(Chunk->Meshes.GpuBufferHandles[MeshIndex].ElementCount == 0); - } + PushDeallocateBuffersCommand(RenderQueue, &Chunk->Mesh.Handles); + Assert(Chunk->Mesh.Handles.Mapped == False); + Assert(Chunk->Mesh.Handles.ElementCount == 0); } +#endif link_internal void PushBonsaiRenderCommandDeallocateWorldChunk( work_queue *RenderQueue, world_chunk* Chunk); @@ -308,10 +418,31 @@ FreeWorldChunk(engine_resources *Engine, world_chunk *Chunk) TIMED_FUNCTION(); UNPACK_ENGINE_RESOURCES(Engine); + /* u32 Flags = Chunk->Flags; */ + + /* if ( (Flags & Chunk_Queued) != 0) */ + /* { */ + /* Info("%d", Flags); */ + /* RuntimeBreak(); */ + /* } */ + + /* if ( (Flags & Chunk_Freelist) != 0) */ + /* { */ + /* Info("%d", Flags); */ + /* RuntimeBreak(); */ + /* } */ + + /* if ( (Flags & (Chunk_Deallocate|Chunk_VoxelsInitialized)) == 0) */ + /* { */ + /* Info("%d", Flags); */ + /* RuntimeBreak(); */ + /* } */ + Assert(Chunk->Next == 0); - Assert(Chunk->Flags & Chunk_Deallocate|Chunk_VoxelsInitialized); + /* Assert(Chunk->Flags & Chunk_Deallocate|Chunk_VoxelsInitialized); */ /* Assert(NotSet(Chunk->Flags, Chunk_Queued)); */ + Assert(Chunk->IsOnFreelist == False); // NOTE(Jesse): Have to mark this chunk so the thing that collects unused // chunks doesn't free this multiple times. @@ -322,12 +453,21 @@ FreeWorldChunk(engine_resources *Engine, world_chunk *Chunk) /* PushBonsaiRenderCommandDeallocateWorldChunk(RenderQueue, Chunk); */ DeallocateAndClearWorldChunk(Engine, Chunk); + Assert(Chunk->WorldP == INVALID_WORLD_CHUNK_POSITION); AcquireFutex(&World->ChunkFreelistFutex); world_chunk *Next = World->ChunkFreelistSentinal.Next; - Chunk->Flags = Chunk_Freelist; - if (Next) { Assert(Next->Flags == Chunk_Freelist); } + Assert(Chunk->IsOnFreelist == False); + Chunk->IsOnFreelist = True; + if (Next) + { + if (Next->IsOnFreelist == False) + { + Info("%d", Next->IsOnFreelist); + RuntimeBreak(); + } + } World->ChunkFreelistSentinal.Next = Chunk; World->ChunkFreelistSentinal.Next->Next = Next; @@ -341,6 +481,26 @@ GetWorldChunkFromHashtable(world *World, world_position P) { /* TIMED_FUNCTION(); */ // This makes things much slower + // nopush- + // nopush- + // nopush- + // nopush- + // nopush- + // nopush- + // nopush- + // nopush- + // nopush- + // nopush- + // nopush- + // nopush- + // nopush- + // nopush- + // nopush- + // nopush- + // nopush- + // nopush- + return {}; +#if 0 u32 HashIndex = GetWorldChunkHash(P, World->VisibleRegion, World->HashSize); u32 StartingHashIndex = HashIndex; @@ -375,21 +535,26 @@ GetWorldChunkFromHashtable(world *World, world_position P) } return Result; +#endif } link_internal world_chunk** CurrentWorldHashtable(engine_resources *Engine) { - u32 Index = Engine->FrameIndex % 2; - world_chunk **Hashtable = Engine->World->ChunkHashMemory[Index]; + /* u32 Index = Engine->FrameIndex % 2; */ + /* world_chunk **Hashtable = Engine->World->ChunkHashMemory[Index]; */ + NotImplemented; + world_chunk **Hashtable = {}; return Hashtable; } link_internal world_chunk** NextWorldHashtable(engine_resources *Engine) { - u32 Index = (Engine->FrameIndex+1) % 2; - world_chunk **Hashtable = Engine->World->ChunkHashMemory[Index]; + /* u32 Index = (Engine->FrameIndex+1) % 2; */ + /* world_chunk **Hashtable = Engine->World->ChunkHashMemory[Index]; */ + NotImplemented; + world_chunk **Hashtable = {}; return Hashtable; } @@ -397,7 +562,9 @@ link_internal void CollectUnusedChunksAndClearCurrentTable(engine_resources *Engine, chunk_dimension VisibleRegion) { TIMED_FUNCTION(); + NotImplemented; +#if 0 UNPACK_ENGINE_RESOURCES(Engine); #if 1 @@ -484,6 +651,7 @@ CollectUnusedChunksAndClearCurrentTable(engine_resources *Engine, chunk_dimensio #endif return; +#endif } #if 0 @@ -523,6 +691,9 @@ MergeChunksOffset(world_chunk *Src, world_chunk *Dest, voxel_position Offset) TIMED_FUNCTION(); /* Assert(Dest->FilledCount == 0); */ + NotImplemented; + +#if 0 auto SrcChunkDim = Src->Dim; auto DestChunkDim = Dest->Dim; @@ -539,11 +710,19 @@ MergeChunksOffset(world_chunk *Src, world_chunk *Dest, voxel_position Offset) s32 DestIndex = GetIndex(Voxel_Position(x,y,z), DestChunkDim); voxel *SrcV = Src->Voxels+SrcIndex; voxel *DestV = Dest->Voxels+DestIndex; - DestV->Flags |= (SrcV->Flags & Voxel_Filled); - if (SrcV->Color) { DestV->Color = SrcV->Color; } + + // TODO(Jesse): Can we do this branchless ..? + s32 SrcOccupancy = GetOccupancyBit(Src, SrcIndex); + if (SrcOccupancy) { SetOccupancyBit(Dest, DestIndex, SrcOccupancy); } + /* DestV->Flags |= (SrcV->Flags & Voxel_Filled); */ + + if (SrcV->RGBColor) { DestV->RGBColor = SrcV->RGBColor; } /* if (!DestV->Color) { DestV->Color = SrcV->Color; } */ - Dest->FilledCount += DestV->Flags & Voxel_Filled; - CAssert(Voxel_Filled == 1); + + Dest->FilledCount += SrcOccupancy; + /* Dest->FilledCount += DestV->Flags & Voxel_Filled; */ + +/* CAssert(Voxel_Filled == 1); */ // At the moment at least, I'm running under the assumption that the // dest chunk will be ready for the face mask computation to be run @@ -555,6 +734,7 @@ MergeChunksOffset(world_chunk *Src, world_chunk *Dest, voxel_position Offset) } } } +#endif } link_internal void @@ -562,6 +742,10 @@ CopyChunkOffset(world_chunk *Src, v3i SrcChunkDim, world_chunk *Dest, v3i DestCh { TIMED_FUNCTION(); + NotImplemented; + +#if 0 + Assert(Src->Dim == SrcChunkDim); Assert(Dest->Dim == DestChunkDim); @@ -580,287 +764,21 @@ CopyChunkOffset(world_chunk *Src, v3i SrcChunkDim, world_chunk *Dest, v3i DestCh if (SrcIndex > -1) { s32 DestIndex = GetIndex(Voxel_Position(x,y,z), DestChunkDim); - Dest->Voxels[DestIndex] = Src->Voxels[SrcIndex]; - Dest->FilledCount += Dest->Voxels[DestIndex].Flags & Voxel_Filled; - CAssert(Voxel_Filled == 1); - } - } - } - } - -} -link_internal u32 -Terrain_Flat( world_chunk *Chunk, - v3i NoiseBasis, - void *NoiseParams, - void *UserData ) -{ - UNPACK_NOISE_PARAMS(NoiseParams); + // TODO(Jesse): We can definitely do this much more efficiently by + // doing 8 wide or something. + s32 SrcOccupancy = GetOccupancyBit(Src, SrcIndex); + SetOccupancyBit(Dest, DestIndex, SrcOccupancy); - u32 Result = 0; - for ( s32 z = 0; z < Chunk->Dim.z; ++ z) - { - /* s64 WorldZ = s64(z - zMin + NoiseBasis.z + (GetWorldChunkDim().z*Chunk->WorldP.z)); */ - for ( s32 y = 0; y < Chunk->Dim.y; ++ y) - { - for ( s32 x = 0; x < Chunk->Dim.x; ++ x) - { - if ((z + NoiseBasis.z) < Thresh) - { - s32 Index = GetIndex(Voxel_Position(x,y,z), Chunk->Dim); - Chunk->Voxels[Index].Flags = Voxel_Filled; - Chunk->Voxels[Index].Color = RGBtoPackedHSV(RGBColor); - ++Result; + Dest->Voxels[DestIndex] = Src->Voxels[SrcIndex]; + Dest->FilledCount += SrcOccupancy; + /* CAssert(Voxel_Filled == 1); */ } } } } - return Result;; -} - - -link_internal u32 -Terrain_FBM2D( world_chunk *Chunk, - v3i NoiseBasis, - void *NoiseParams, - void *OctaveCount ) -{ - TIMED_FUNCTION(); - - UNPACK_NOISE_PARAMS(NoiseParams); - - random_series GenColorEntropy = {12653763234231}; - - u32 ChunkSum = 0; - - s32 MinZ = Chunk->WorldP.z*WorldChunkDim.z; - s32 MaxZ = MinZ+WorldChunkDim.z ; - - if (MaxZ < -Amplitude) - { - s32 MaxIndex = Volume(Dim); - for ( s32 VoxIndex = 0; VoxIndex < MaxIndex; ++VoxIndex) - { - Chunk->Voxels[VoxIndex].Flags = Voxel_Filled; - Chunk->Voxels[VoxIndex].Color = RGBtoPackedHSV(RGBColor); - } - return (u32)MaxIndex; - } - - if (MinZ > Amplitude) - return ChunkSum; - -#if VOXEL_DEBUG_COLOR - memory_arena *TempArena = GetThreadLocalState(ThreadLocal_ThreadIndex)->PermMemory; -#else - memory_arena *TempArena = GetTranArena(); #endif - - v3i NoiseDim = Chunk->Dim + 2; - v3i NormalDim = Chunk->Dim; - r32 *NoiseValues = Allocate(r32, TempArena, Volume(NoiseDim)); - v3 *Normals = Allocate( v3, TempArena, Volume(NormalDim)); - -#if VOXEL_DEBUG_COLOR - Chunk->NoiseValues = NoiseValues; - Chunk->NormalValues = Normals; -#endif - - Period = Max(Period, V3(1.f)); - - u32 Octaves = *(u32*)OctaveCount; - for ( s32 z = 0; z < Dim.z; ++ z) - { - s64 WorldZ = z - SrcToDest.z + (WorldChunkDim.z*Chunk->WorldP.z); - s64 WorldZBiased = WorldZ - zMin; - /* s64 WorldZ = z + NoiseBasis.z; */ - /* s64 WorldZBiased = WorldZ - zMin; */ - for ( s32 y = 0; y < Dim.y; ++ y) - { - for ( s32 x = 0; x < Dim.x; ++ x) - { - r32 NoiseValue = 0.f; - s32 VoxIndex = GetIndex(Voxel_Position(x,y,z), Dim); - Chunk->Voxels[VoxIndex].Flags = Voxel_Empty; - Assert( NotSet(&Chunk->Voxels[VoxIndex], Voxel_Filled) ); - - v3 IPeriod = Period; // Interior Period - s32 InteriorAmp = Amplitude; - for (u32 OctaveIndex = 0; OctaveIndex < Octaves; ++OctaveIndex) - { - v3 NoiseInput = MapWorldPositionToNoiseInputValue(V3(NoiseBasis), V3(x,y,z), IPeriod); - - r32 Warp = 0.f; - r32 N = PerlinNoise(NoiseInput+Warp); - Assert(N <= 1.05f); - Assert(N > -1.05f); - - s32 zValue = (s32)Abs( (N*InteriorAmp) ); - - b32 IsUnderground = zValue < WorldZBiased; - b32 NoiseChoice = IsUnderground; - - NoiseValue += N*(r32(OctaveIndex+1)); - NoiseValue += N*InteriorAmp; - - InteriorAmp = Max(1, InteriorAmp/2); - IPeriod = Max(V3(1.f), IPeriod/2); - } - -#if VOXEL_DEBUG_COLOR - s32 NoiseIndex = GetIndex(V3i(x,y,z)+1, NoiseDim); - Chunk->NoiseValues[NoiseIndex] = NoiseValue; -#endif - b32 NoiseChoice = r64(NoiseValue) > r64(WorldZBiased); - - if (NoiseChoice) - { - u32 BreakHere = 54; - BreakHere ++; - } - - /* u16 ThisColor = SafeTruncateToU16(RandomBetween(u32(Color), &GenColorEntropy, u32(Color)+2));; */ - u16 ThisColor = RGBtoPackedHSV(RGBColor); - - SetFlag(&Chunk->Voxels[VoxIndex], (voxel_flag)(Voxel_Filled*NoiseChoice)); - Chunk->Voxels[VoxIndex].Color = ThisColor*u16(NoiseChoice); - ChunkSum += NoiseChoice; - - Assert( (Chunk->Voxels[VoxIndex].Flags&VoxelFaceMask) == 0); - - if (NoiseChoice) - { - Assert( IsSet(&Chunk->Voxels[VoxIndex], Voxel_Filled) ); - } - else - { - Assert( NotSet(&Chunk->Voxels[VoxIndex], Voxel_Filled) ); - } - } - } - } - - s64 ChunkWorldZThresh = SrcToDest.z + (WorldChunkDim.z*Chunk->WorldP.z) - zMin; - ComputeNormalsForChunkFromNoiseValues(ChunkWorldZThresh, NoiseValues, NoiseDim, Normals, NormalDim); - - return ChunkSum; -} - -link_internal u32 -Terrain_Perlin2D( world_chunk *Chunk, - v3i NoiseBasis, - void *NoiseParams, - void *UserData ) -{ - TIMED_FUNCTION(); - u32 SyntheticChunkSum = Terrain_FBM2D( Chunk, NoiseBasis, NoiseParams, UserData ); - return SyntheticChunkSum; -} - -link_internal u32 -Terrain_Perlin3D( world_chunk *Chunk, - v3i NoiseBasis, - void *NoiseParams, - void *UserData ) -{ - TIMED_FUNCTION(); - - UNPACK_NOISE_PARAMS(NoiseParams); - - u32 Result = 0; - - Assert(Chunk); - - for ( s32 z = 0; z < Dim.z; ++ z) - { - for ( s32 y = 0; y < Dim.y; ++ y) - { - for ( s32 x = 0; x < Dim.x; ++ x) - { - s32 i = GetIndex(Voxel_Position(x,y,z), Dim); - Chunk->Voxels[i].Flags = Voxel_Empty; - - Assert( NotSet(&Chunk->Voxels[i], Voxel_Filled) ); - - v3 NoiseInput = MapWorldPositionToNoiseInputValue(V3(NoiseBasis), V3(x,y,z), Period); - r32 NoiseValue = PerlinNoise(NoiseInput); - - s32 NoiseChoice = NoiseValue*Amplitude > Thresh; - Assert(NoiseChoice == 0 || NoiseChoice == 1); - - SetFlag(&Chunk->Voxels[i], (voxel_flag)(NoiseChoice * Voxel_Filled)); - - if (NoiseChoice) - { - Chunk->Voxels[i].Color = RGBtoPackedHSV(RGBColor); - Assert( IsSet(&Chunk->Voxels[i], Voxel_Filled) ); - ++Result; - } - else - { - Assert( NotSet(&Chunk->Voxels[i], Voxel_Filled) ); - } - - } - } - } - - return Result; -} - -link_internal u32 -Terrain_WhiteNoise( world_chunk *Chunk, - v3i NoiseBasis, - void *NoiseParams, - void *UserData ) -{ - TIMED_FUNCTION(); - - UNPACK_NOISE_PARAMS(NoiseParams); - - u32 Result = 0; - - Assert(Chunk); - - for ( s32 z = 0; z < Dim.z; ++ z) - { - for ( s32 y = 0; y < Dim.y; ++ y) - { - for ( s32 x = 0; x < Dim.x; ++ x) - { - s32 i = GetIndex(Voxel_Position(x,y,z), Dim); - Chunk->Voxels[i].Flags = Voxel_Empty; - - Assert( NotSet(&Chunk->Voxels[i], Voxel_Filled) ); - - v3 NoiseInput = MapWorldPositionToNoiseInputValue(V3(NoiseBasis), V3(x,y,z), Period); - random_series Entropy = RandomSeriesFromV3(NoiseInput); - - r32 NoiseValue = RandomUnilateral(&Entropy); - - s32 NoiseChoice = NoiseValue > Thresh; - Assert(NoiseChoice == 0 || NoiseChoice == 1); - - SetFlag(&Chunk->Voxels[i], (voxel_flag)(NoiseChoice * Voxel_Filled)); - - if (NoiseChoice) - { - Chunk->Voxels[i].Color = RGBtoPackedHSV(RGBColor); - Assert( IsSet(&Chunk->Voxels[i], Voxel_Filled) ); - ++Result; - } - else - { - Assert( NotSet(&Chunk->Voxels[i], Voxel_Filled) ); - } - - } - } - } - - return Result; } typedef u32 (*chunk_init_callback)( world_chunk *Chunk, @@ -880,6 +798,8 @@ TransparencyIncreases(voxel *SrcVox, voxel *DstVox) /* Assert(SrcVox->Flags & Voxel_Filled); */ b32 Result = False; + /* NotImplemented; */ +#if 0 if (SrcVox->Transparency) { // Transparent source voxels can only increase in transparency if the dest is unfilled @@ -904,6 +824,7 @@ TransparencyIncreases(voxel *SrcVox, voxel *DstVox) } } +#endif return Result; } @@ -914,9 +835,10 @@ TransparencyIncreases(voxel *Voxels, s32 SrcIndex, v3i DestP, v3i SrcChunkDim) voxel *SrcVox = Voxels+SrcIndex; voxel *DstVox = Voxels+DestIndex; - Assert(SrcVox->Flags & Voxel_Filled); + /* Assert(SrcVox->Flags & Voxel_Filled); */ b32 Result = False; +#if 0 if (SrcVox->Transparency) { // Transparent source voxels can only increase in transparency if the dest is unfilled @@ -941,10 +863,12 @@ TransparencyIncreases(voxel *Voxels, s32 SrcIndex, v3i DestP, v3i SrcChunkDim) } } +#endif return Result; } +#if 0 link_internal void MarkBoundaryVoxels_Debug( voxel *Voxels, chunk_dimension SrcChunkDim) { @@ -968,9 +892,11 @@ MarkBoundaryVoxels_Debug( voxel *Voxels, chunk_dimension SrcChunkDim) } } } +#endif link_internal s32 -MarkBoundaryVoxels_MakeExteriorFaces( voxel *Voxels, +MarkBoundaryVoxels_MakeExteriorFaces( u64 *Occupancy, + voxel *Voxels, chunk_dimension SrcChunkDim, chunk_dimension SrcChunkMin, chunk_dimension SrcChunkMax ) @@ -991,15 +917,14 @@ MarkBoundaryVoxels_MakeExteriorFaces( voxel *Voxels, { voxel_position DestP = Voxel_Position(x,y,z); s32 SrcIndex = GetIndex(DestP, SrcChunkDim); + s32 VOccupancy = GetOccupancyBit(Occupancy, SrcIndex); voxel *Voxel = Voxels + SrcIndex; - Result += Voxel->Flags&Voxel_Filled; + Result += VOccupancy; - if (Voxel->Flags&Voxel_Filled) + if (VOccupancy) { - Voxel->Flags = Voxel_Filled; - voxel_position rightVoxel = DestP + V3i(1, 0, 0); voxel_position leftVoxel = DestP - V3i(1, 0, 0); voxel_position topVoxel = DestP + V3i(0, 0, 1); @@ -1007,31 +932,35 @@ MarkBoundaryVoxels_MakeExteriorFaces( voxel *Voxels, voxel_position frontVoxel = DestP + V3i(0, 1, 0); voxel_position backVoxel = DestP - V3i(0, 1, 0); + NotImplemented; - if ( !Contains( ClampedDim, rightVoxel) || NotFilled( Voxels, rightVoxel, SrcChunkDim) || TransparencyIncreases( Voxels, SrcIndex, rightVoxel, SrcChunkDim) ) +#if 0 + if ( !Contains( ClampedDim, rightVoxel) || NotFilled( Occupancy, rightVoxel, SrcChunkDim) || TransparencyIncreases( Voxels, SrcIndex, rightVoxel, SrcChunkDim) ) { Voxel->Flags |= Voxel_RightFace; } - if ( !Contains( ClampedDim, leftVoxel) || NotFilled( Voxels, leftVoxel, SrcChunkDim) || TransparencyIncreases( Voxels, SrcIndex, leftVoxel, SrcChunkDim) ) + if ( !Contains( ClampedDim, leftVoxel) || NotFilled( Occupancy, leftVoxel, SrcChunkDim) || TransparencyIncreases( Voxels, SrcIndex, leftVoxel, SrcChunkDim) ) { Voxel->Flags |= Voxel_LeftFace; } - if ( !Contains( ClampedDim, botVoxel) || NotFilled( Voxels, botVoxel, SrcChunkDim) || TransparencyIncreases( Voxels, SrcIndex, botVoxel, SrcChunkDim) ) + if ( !Contains( ClampedDim, botVoxel) || NotFilled( Occupancy, botVoxel, SrcChunkDim) || TransparencyIncreases( Voxels, SrcIndex, botVoxel, SrcChunkDim) ) { Voxel->Flags |= Voxel_BottomFace; } - if ( !Contains( ClampedDim, topVoxel) || NotFilled( Voxels, topVoxel, SrcChunkDim) || TransparencyIncreases( Voxels, SrcIndex, topVoxel, SrcChunkDim) ) + if ( !Contains( ClampedDim, topVoxel) || NotFilled( Occupancy, topVoxel, SrcChunkDim) || TransparencyIncreases( Voxels, SrcIndex, topVoxel, SrcChunkDim) ) { Voxel->Flags |= Voxel_TopFace; } - if ( !Contains( ClampedDim, frontVoxel) || NotFilled( Voxels, frontVoxel, SrcChunkDim) || TransparencyIncreases( Voxels, SrcIndex, frontVoxel, SrcChunkDim) ) + if ( !Contains( ClampedDim, frontVoxel) || NotFilled( Occupancy, frontVoxel, SrcChunkDim) || TransparencyIncreases( Voxels, SrcIndex, frontVoxel, SrcChunkDim) ) { Voxel->Flags |= Voxel_FrontFace; } - if ( !Contains( ClampedDim, backVoxel) || NotFilled( Voxels, backVoxel, SrcChunkDim) || TransparencyIncreases( Voxels, SrcIndex, backVoxel, SrcChunkDim) ) + if ( !Contains( ClampedDim, backVoxel) || NotFilled( Occupancy, backVoxel, SrcChunkDim) || TransparencyIncreases( Voxels, SrcIndex, backVoxel, SrcChunkDim) ) { Voxel->Flags |= Voxel_BackFace; } +#endif + } } } @@ -1041,100 +970,75 @@ MarkBoundaryVoxels_MakeExteriorFaces( voxel *Voxels, } link_internal s32 -MarkBoundaryVoxels_NoExteriorFaces( voxel *Voxels, - v3i SrcChunkDim, - v3i SrcChunkMin, - v3i SrcChunkMax ) +MakeFaceMasks_NoExteriorFaces( u64 *Occupancy, + u64 *xOccupancyBorder, + u64 *FaceMasks, + voxel *Voxels, + v3i SrcChunkDim, + v3i SrcChunkMin, + v3i SrcChunkMax ) { /* HISTOGRAM_FUNCTION(); */ TIMED_FUNCTION(); auto MinDim = SrcChunkMin; - auto MaxDim = Min(SrcChunkDim, SrcChunkMax); // SrcChunkMin+DestChunkDim+1 + auto MaxDim = Min(SrcChunkDim, SrcChunkMax); v3i InnerDim = MaxDim-MinDim; - s32 MaxIndex = Volume(SrcChunkDim); + Assert(MinDim == V3i(0)); + Assert(MaxDim ==V3i(64, 66, 66)); + Assert(SrcChunkDim == V3i(64, 66, 66)); s32 Result = 0; - for ( s32 z = MinDim.z; z < MaxDim.z ; ++z ) + for ( s32 z = 1; z < SrcChunkDim.z-1; ++z ) { - for ( s32 y = MinDim.y; y < MaxDim.y ; ++y ) + for ( s32 y = 1; y < SrcChunkDim.y-1; ++y ) { - for ( s32 x = MinDim.x; x < MaxDim.x ; ++x ) - { - v3i SrcP = V3i(x,y,z); - s32 SrcIndex = GetIndex(SrcP, SrcChunkDim); - voxel *Voxel = Voxels + SrcIndex; + s32 OccupancyIndex = GetIndex(y, z, SrcChunkDim.yz); - Result += Voxel->Flags&Voxel_Filled; - if (Voxel->Flags & Voxel_Filled) - { - Voxel->Flags = Voxel_Filled; + u64 RightYRow = xOccupancyBorder[((z-1)*2)+1]; + u64 LeftYRow = xOccupancyBorder[ (z-1)*2 ]; - s32 RightIndex = TryGetIndex(SrcP + V3i(1, 0, 0), SrcChunkDim); - s32 LeftIndex = TryGetIndex(SrcP - V3i(1, 0, 0), SrcChunkDim); - s32 TopIndex = TryGetIndex(SrcP + V3i(0, 0, 1), SrcChunkDim); - s32 BottomIndex= TryGetIndex(SrcP - V3i(0, 0, 1), SrcChunkDim); - s32 FrontIndex = TryGetIndex(SrcP + V3i(0, 1, 0), SrcChunkDim); - s32 BackIndex = TryGetIndex(SrcP - V3i(0, 1, 0), SrcChunkDim); + // NOTE(Jesse): These look backwards, but they're not. In register ordering, + // the directions are reversed; the highest bit is the right-most voxel in + // 3D space. + // + // @register_ordering_looks_backwards + u64 RightBit = ((RightYRow >> (y-1)) & 1) << 63; + u64 LeftBit = ((LeftYRow >> (y-1)) & 1); - if ( RightIndex >= 0 && RightIndex < MaxIndex ) - { - voxel *NextVoxel = Voxels + RightIndex; - if ( !(NextVoxel->Flags&Voxel_Filled) || TransparencyIncreases(Voxel, NextVoxel)) - { - Voxel->Flags |= Voxel_RightFace; - } - } - if ( LeftIndex >= 0 && LeftIndex < MaxIndex ) - { - voxel *NextVoxel = Voxels + LeftIndex; - if ( !(NextVoxel->Flags&Voxel_Filled) || TransparencyIncreases(Voxel, NextVoxel)) - { - Voxel->Flags |= Voxel_LeftFace; - } - } + /* u64 RightBit = 1llu << 63; */ + /* u64 LeftBit = 1; */ - if ( TopIndex >= 0 && TopIndex < MaxIndex ) - { - voxel *NextVoxel = Voxels + TopIndex; - if ( !(NextVoxel->Flags&Voxel_Filled) || TransparencyIncreases(Voxel, NextVoxel)) - { - Voxel->Flags |= Voxel_TopFace; - } - } - if ( BottomIndex >= 0 && BottomIndex < MaxIndex ) - { - voxel *NextVoxel = Voxels + BottomIndex; - if ( !(NextVoxel->Flags&Voxel_Filled) || TransparencyIncreases(Voxel, NextVoxel)) - { - Voxel->Flags |= Voxel_BottomFace; - } - } + /* u64 RightBit = 0; */ + /* u64 LeftBit = 0; */ + u64 Bits = Occupancy[OccupancyIndex]; + u64 yBits = Occupancy[OccupancyIndex+1]; + u64 nyBits = Occupancy[OccupancyIndex-1]; + u64 zBits = Occupancy[OccupancyIndex+SrcChunkDim.z]; + u64 nzBits = Occupancy[OccupancyIndex-SrcChunkDim.z]; - if ( FrontIndex >= 0 && FrontIndex < MaxIndex ) - { - voxel *NextVoxel = Voxels + FrontIndex; - if ( !(NextVoxel->Flags&Voxel_Filled) || TransparencyIncreases(Voxel, NextVoxel)) - { - Voxel->Flags |= Voxel_FrontFace; - } - } - if ( BackIndex >= 0 && BackIndex < MaxIndex ) - { - voxel *NextVoxel = Voxels + BackIndex; - if ( !(NextVoxel->Flags&Voxel_Filled) || TransparencyIncreases(Voxel, NextVoxel)) - { - Voxel->Flags |= Voxel_BackFace; - } - } + /* u64 RightFaces = ( RightBit | (Bits>>1) ) & ~Bits; */ + /* u64 LeftFaces = ( LeftBit | (Bits<<1) ) & ~Bits; */ - } + // @register_ordering_looks_backwards + u64 RightFaces = ( Bits ) & ~(RightBit | (Bits>>1)); + u64 LeftFaces = ( Bits ) & ~(LeftBit | (Bits<<1)); - } + u64 FrontFaces = Bits & (~yBits); + u64 BackFaces = Bits & (~nyBits); + u64 TopFaces = Bits & (~zBits); + u64 BotFaces = Bits & (~nzBits); + + FaceMasks[(OccupancyIndex*6)+0] = LeftFaces; + FaceMasks[(OccupancyIndex*6)+1] = RightFaces; + FaceMasks[(OccupancyIndex*6)+2] = FrontFaces; + FaceMasks[(OccupancyIndex*6)+3] = BackFaces; + FaceMasks[(OccupancyIndex*6)+4] = TopFaces; + FaceMasks[(OccupancyIndex*6)+5] = BotFaces; } } @@ -1262,8 +1166,11 @@ DrawDebugVoxels( voxel *Voxels, // TODO(Jesse): This copy could be avoided in multiple ways, and should be. /* v3 Color = GetColorData(Voxel->Color); */ - FillArray(VertexMaterial(Voxel->Color, 0.f, 0.f), Materials, VERTS_PER_FACE); + FillArray(VertexMaterial(Voxel->RGBColor, 0.f, 0.f), Materials, VERTS_PER_FACE); + + NotImplemented; +#if 0 if (Voxel->Flags & Voxel_RightFace) { RightFaceVertexData( V3(SrcP-SrcChunkMin), Diameter, VertexData); @@ -1294,6 +1201,8 @@ DrawDebugVoxels( voxel *Voxels, BackFaceVertexData( V3(SrcP-SrcChunkMin), Diameter, VertexData); BufferFaceData(DestGeometry, VertexData, v3_BackFaceNormalData, Materials); } +#endif + } } } @@ -1330,6 +1239,7 @@ TransparencyIsSimilar(u8 T0, u8 T1) return Result; } +#if 0 link_internal b32 Step(voxel *Voxels, v3i SrcDim, v3i StepDir, v3i StepShape, v3i *AtP, voxel_flag FaceFlag, u16 PackedHSV, u8 Transparency) { @@ -1345,7 +1255,7 @@ Step(voxel *Voxels, v3i SrcDim, v3i StepDir, v3i StepShape, v3i *AtP, voxel_flag { s32 VoxI = GetIndex(Next, SrcDim); voxel *V = Voxels + VoxI; - if ( (V->Flags&FaceFlag) && V->Color == PackedHSV && TransparencyIsSimilar(V->Transparency, Transparency)) + if ( (V->Flags&FaceFlag) && V->RGBColor == PackedHSV && TransparencyIsSimilar(V->Transparency, Transparency)) { /* UnSetFlag((voxel_flag*)&V->Flags, FaceFlag); */ } @@ -1374,18 +1284,18 @@ Step(voxel *Voxels, v3i SrcDim, v3i StepDir, v3i StepShape, v3i *AtP, voxel_flag /* global_variable random_series ColorEntropy = {33453}; */ link_internal v3 -DoXStepping(voxel *Voxels, v3i SrcChunkDim, v3i SrcP, voxel_flag Face, u16 Color, u8 Transparency) +DoXStepping(voxel *Voxels, v3i SrcChunkDim, v3i SrcP, voxel_flag Face, u16 RGBColor, u8 Transparency) { v3i AtY = SrcP; s32 DidStepY = 0; - while (Step(Voxels, SrcChunkDim, {{0, 1, 0}}, {{0, 1, 0}}, &AtY, Face, Color, Transparency )) + while (Step(Voxels, SrcChunkDim, {{0, 1, 0}}, {{0, 1, 0}}, &AtY, Face, RGBColor, Transparency )) { DidStepY++; } s32 DidStepZ = 0; v3i AtZ = SrcP; - while (Step(Voxels, SrcChunkDim, {{0, 0, 1}}, {{0, DidStepY, 1}}, &AtZ, Face, Color, Transparency )) + while (Step(Voxels, SrcChunkDim, {{0, 0, 1}}, {{0, DidStepY, 1}}, &AtZ, Face, RGBColor, Transparency )) { DidStepZ++; } @@ -1406,18 +1316,18 @@ DoXStepping(voxel *Voxels, v3i SrcChunkDim, v3i SrcP, voxel_flag Face, u16 Color } link_internal v3 -DoYStepping(voxel *Voxels, v3i SrcChunkDim, v3i SrcP, voxel_flag Face, u16 Color, u8 Transparency) +DoYStepping(voxel *Voxels, v3i SrcChunkDim, v3i SrcP, voxel_flag Face, u16 RGBColor, u8 Transparency) { v3i AtX = SrcP; s32 DidStepX = 0; - while (Step(Voxels, SrcChunkDim, {{1, 0, 0}}, {{1, 0, 0}}, &AtX, Face, Color, Transparency)) + while (Step(Voxels, SrcChunkDim, {{1, 0, 0}}, {{1, 0, 0}}, &AtX, Face, RGBColor, Transparency)) { DidStepX++; } s32 DidStepZ = 0; v3i AtZ = SrcP; - while (Step(Voxels, SrcChunkDim, {{0, 0, 1}}, {{DidStepX, 0, 1}}, &AtZ, Face, Color, Transparency )) + while (Step(Voxels, SrcChunkDim, {{0, 0, 1}}, {{DidStepX, 0, 1}}, &AtZ, Face, RGBColor, Transparency )) { DidStepZ++; } @@ -1438,18 +1348,18 @@ DoYStepping(voxel *Voxels, v3i SrcChunkDim, v3i SrcP, voxel_flag Face, u16 Color } link_internal v3 -DoZStepping(voxel *Voxels, v3i SrcChunkDim, v3i SrcP, voxel_flag Face, u16 Color, u8 Transparency) +DoZStepping(voxel *Voxels, v3i SrcChunkDim, v3i SrcP, voxel_flag Face, u16 RGBColor, u8 Transparency) { v3i AtX = SrcP; s32 DidStepX = 0; - while (Step(Voxels, SrcChunkDim, {{1, 0, 0}}, {{1, 0, 0}}, &AtX, Face, Color, Transparency )) + while (Step(Voxels, SrcChunkDim, {{1, 0, 0}}, {{1, 0, 0}}, &AtX, Face, RGBColor, Transparency )) { DidStepX++; } s32 DidStepY = 0; v3i AtY = SrcP; - while (Step(Voxels, SrcChunkDim, {{0, 1, 0}}, {{DidStepX, 1, 0}}, &AtY, Face, Color, Transparency )) + while (Step(Voxels, SrcChunkDim, {{0, 1, 0}}, {{DidStepX, 1, 0}}, &AtY, Face, RGBColor, Transparency )) { DidStepY++; } @@ -1468,6 +1378,13 @@ DoZStepping(voxel *Voxels, v3i SrcChunkDim, v3i SrcP, voxel_flag Face, u16 Color v3 Result = V3(DidStepX, DidStepY, 0) + V3(1); return Result; } +#endif + +link_inline u16 +GetVoxelColor(s32 Index, voxel *Voxels) +{ + return Voxels[Index].RGBColor; +} #if 0 link_internal void @@ -1568,129 +1485,326 @@ poof( func world_chunk_mesh_functions(buffer_t, vert_t) { link_internal void - BuildWorldChunkMeshFromMarkedVoxels_Greedy_(vert_t.name)( voxel *Voxels, - v3i SrcChunkDim, + BuildWorldChunkMeshFromMarkedVoxels_Naieve_(vert_t.name)( voxel *Voxels, + u64 *FaceMasks, + v3i SrcChunkDim, - v3i SrcChunkMin, - v3i SrcChunkMax, + v3i SrcChunkMin, + v3i SrcChunkMax, - // TODO(Jesse)(immediate, poof): removing the braces here causes poof to bail .. why? - (buffer_t.name) *DestGeometry, - (buffer_t.name) *DestTransparentGeometry, - memory_arena *TempMemory, + // TODO(Jesse)(immediate, poof): @poof_parens_bug + (buffer_t.name) *Dest, + (buffer_t.name) *Unused, - // NOTE(Jesse): This is so we can offset vertices such that we center - // entity models about 0 and rotation works properly. - vert_t.name VertexOffset = {}) + // NOTE(Jesse): This is so we can offset vertices such that we center + // entity models about 0 and rotation works properly. + vert_t.name VertexOffset = {}) { /* HISTOGRAM_FUNCTION(); */ TIMED_FUNCTION(); - Assert(DestGeometry->Type == DataType_(vert_t.name)); + Assert(SrcChunkMin == V3i(0)); + Assert(SrcChunkMax == V3i(0)); + Assert(SrcChunkDim == V3i(64, 66, 66)); vert_t.name VertexData[VERTS_PER_FACE]; - matl Materials[VERTS_PER_FACE]; + vert_t.name NormalData[VERTS_PER_FACE]; + matl Materials[VERTS_PER_FACE]; - auto SrcMinP = SrcChunkMin; - auto MaxDim = Min(SrcChunkDim, SrcChunkMax); + for ( s32 zBlock = 1; zBlock < SrcChunkDim.z-1; ++zBlock ) + { + s32 z = zBlock-1; + for ( s32 yBlock = 1; yBlock < SrcChunkDim.y-1; ++yBlock ) + { + s32 y = yBlock-1; + s32 OccupancyIndex = GetIndex(yBlock, zBlock, SrcChunkDim.yz); - auto TmpDim = MaxDim-SrcMinP; + u64 LeftFaces = FaceMasks[(OccupancyIndex*6)+0]; + u64 RightFaces = FaceMasks[(OccupancyIndex*6)+1]; + u64 FrontFaces = FaceMasks[(OccupancyIndex*6)+2]; + u64 BackFaces = FaceMasks[(OccupancyIndex*6)+3]; + u64 TopFaces = FaceMasks[(OccupancyIndex*6)+4]; + u64 BotFaces = FaceMasks[(OccupancyIndex*6)+5]; - u32 TmpVol = u32(Volume(TmpDim)); - auto TempVoxels = Allocate(voxel, TempMemory, TmpVol); + v3 Dim = V3(1.f, 1.f, 1.f); - // NOTE(Jesse): It's necessary to copy the voxel data because the meshing - // algorithm unsets the face flags for the voxels instead of marking them - // as being processed. When complete, there should be no face-flags left on - // this data. (This is not asserted, but maybe should be?) - // - // TODO(Jesse): Assert there are no face flags left in this copy at the end of - // this process? - // - // TODO(Jesse): Copy data into here as the algorithm proceedes instead of in - // one shot at the start? - // - u32 TmpIndex = 0; - for ( s32 zIndex = 0; zIndex < TmpDim.z ; ++zIndex ) - { - for ( s32 yIndex = 0; yIndex < TmpDim.y ; ++yIndex ) - { - for ( s32 xIndex = 0; xIndex < TmpDim.x ; ++xIndex ) + f32 BendStrength = 8.f; + f32 NormalFactor = 1.f/BendStrength; + + u64 BaseVoxelOffset = u64(GetIndex(0, yBlock, zBlock, SrcChunkDim)); + while (LeftFaces) { - voxel_position SrcP = SrcMinP + Voxel_Position(xIndex, yIndex, zIndex); - s32 SrcIndex = GetIndex(SrcP, SrcChunkDim); - /* Assert(TmpIndex < TmpVol); */ - TempVoxels[TmpIndex] = Voxels[SrcIndex]; - TmpIndex++; + u64 This = UnsetLeastSignificantSetBit(&LeftFaces); + u64 xOffset = GetIndexOfSingleSetBit(This); + v3 P = V3(s32(xOffset), y, z); + + u16 RGB = Voxels[BaseVoxelOffset+xOffset].RGBColor; + + u16 PNormal = Voxels[BaseVoxelOffset+xOffset].Normal; + v3 Normal = Normalize((UnpackV3_15b(PNormal)) + (V3(-1,0,0) * NormalFactor)); + /* Assert(Length(Normal) > 0.f); */ + + Assert(BufferHasRoomFor(Dest, VERTS_PER_FACE)); + + vert_t.name *DestVerts = Cast( vert_t.name*, Dest->Verts) + Dest->At; + vert_t.name *DestNormals = Cast( vert_t.name*, Dest->Normals) + Dest->At; + vertex_material *DestMats = Dest->Mat + Dest->At; + + LeftFaceVertexData( VertexOffset+P, Dim, DestVerts); + FillArray(Normal, DestNormals, VERTS_PER_FACE); + FillArray(VertexMaterial(RGB, 0.f, 0.f), DestMats, VERTS_PER_FACE); + Dest->At += VERTS_PER_FACE; } - } - } - Assert(TmpIndex == TmpVol); + while (RightFaces) + { + u64 This = UnsetLeastSignificantSetBit(&RightFaces); + u64 xOffset = GetIndexOfSingleSetBit(This); + v3 P = V3(s32(xOffset), y, z); + u16 RGB = Voxels[BaseVoxelOffset+xOffset].RGBColor; - s32 Index = 0; - for ( s32 z = 0; z < TmpDim.z ; ++z ) - { - for ( s32 y = 0; y < TmpDim.y ; ++y ) - { - for ( s32 x = 0; x < TmpDim.x ; ++x ) + u16 PNormal = Voxels[BaseVoxelOffset+xOffset].Normal; + v3 Normal = Normalize((UnpackV3_15b(PNormal)) + (V3(1,0,0) * NormalFactor)); + /* Assert(Length(Normal) > 0.f); */ + + Assert(BufferHasRoomFor(Dest, VERTS_PER_FACE)); + + vert_t.name *DestVerts = Cast( vert_t.name*, Dest->Verts) + Dest->At; + vert_t.name *DestNormals = Cast( vert_t.name*, Dest->Normals) + Dest->At; + vertex_material *DestMats = Dest->Mat + Dest->At; + + RightFaceVertexData( VertexOffset+P, Dim, DestVerts); + FillArray(Normal, DestNormals, VERTS_PER_FACE); + FillArray(VertexMaterial(RGB, 0.f, 0.f), DestMats, VERTS_PER_FACE); + Dest->At += VERTS_PER_FACE; + } + + while (FrontFaces) { - v3i TmpVoxP = V3i(x,y,z); - voxel *Voxel = TempVoxels + Index; + u64 This = UnsetLeastSignificantSetBit(&FrontFaces); + u64 xOffset = GetIndexOfSingleSetBit(This); + v3 P = V3(s32(xOffset), y, z); + u16 RGB = Voxels[BaseVoxelOffset+xOffset].RGBColor; - FillArray(VertexMaterial(Voxel->Color, Voxel->Transparency, 0), Materials, VERTS_PER_FACE); + u16 PNormal = Voxels[BaseVoxelOffset+xOffset].Normal; + v3 Normal = Normalize((UnpackV3_15b(PNormal)) + (V3(0,1,0) * NormalFactor)); + /* Assert(Length(Normal) > 0.f); */ - (buffer_t.name) *Dest = {}; - if (Voxel->Transparency) { Dest = DestTransparentGeometry; } else { Dest = DestGeometry; } + Assert(BufferHasRoomFor(Dest, VERTS_PER_FACE)); - if (Dest) - { - if (Voxel->Flags & Voxel_RightFace) - { - v3 Dim = DoXStepping(TempVoxels, TmpDim, TmpVoxP, Voxel_RightFace, Voxel->Color, Voxel->Transparency); - RightFaceVertexData( VertexOffset+TmpVoxP, Dim, VertexData); - 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, (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, (vert_t.name)_BottomFaceNormalData, Materials); - } + vert_t.name *DestVerts = Cast( vert_t.name*, Dest->Verts) + Dest->At; + vert_t.name *DestNormals = Cast( vert_t.name*, Dest->Normals) + Dest->At; + vertex_material *DestMats = Dest->Mat + Dest->At; - 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, (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, (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, (vert_t.name)_BackFaceNormalData, Materials); - } - } + FrontFaceVertexData( VertexOffset+P, Dim, DestVerts); + FillArray(Normal, DestNormals, VERTS_PER_FACE); + FillArray(VertexMaterial(RGB, 0.f, 0.f), DestMats, VERTS_PER_FACE); + Dest->At += VERTS_PER_FACE; + } + + while (BackFaces) + { + u64 This = UnsetLeastSignificantSetBit(&BackFaces); + u64 xOffset = GetIndexOfSingleSetBit(This); + v3 P = V3(s32(xOffset), y, z); + u16 RGB = Voxels[BaseVoxelOffset+xOffset].RGBColor; - ++Index; + u16 PNormal = Voxels[BaseVoxelOffset+xOffset].Normal; + v3 Normal = Normalize((UnpackV3_15b(PNormal)) + (V3(0,-1,0) * NormalFactor)); + /* Assert(Length(Normal) > 0.f); */ + + Assert(BufferHasRoomFor(Dest, VERTS_PER_FACE)); + + vert_t.name *DestVerts = Cast( vert_t.name*, Dest->Verts) + Dest->At; + vert_t.name *DestNormals = Cast( vert_t.name*, Dest->Normals) + Dest->At; + vertex_material *DestMats = Dest->Mat + Dest->At; + + BackFaceVertexData( VertexOffset+P, Dim, DestVerts); + FillArray(Normal, DestNormals, VERTS_PER_FACE); + FillArray(VertexMaterial(RGB, 0.f, 0.f), DestMats, VERTS_PER_FACE); + Dest->At += VERTS_PER_FACE; } + + while (TopFaces) + { + u64 This = UnsetLeastSignificantSetBit(&TopFaces); + u64 xOffset = GetIndexOfSingleSetBit(This); + v3 P = V3(s32(xOffset), y, z); + u16 RGB = Voxels[BaseVoxelOffset+xOffset].RGBColor; + + u16 PNormal = Voxels[BaseVoxelOffset+xOffset].Normal; + v3 Normal = Normalize((UnpackV3_15b(PNormal)) + (V3(0,0,1) * NormalFactor)); + /* Assert(Length(Normal) > 0.f); */ + + Assert(BufferHasRoomFor(Dest, VERTS_PER_FACE)); + + vert_t.name *DestVerts = Cast( vert_t.name*, Dest->Verts) + Dest->At; + vert_t.name *DestNormals = Cast( vert_t.name*, Dest->Normals) + Dest->At; + vertex_material *DestMats = Dest->Mat + Dest->At; + + TopFaceVertexData( VertexOffset+P, Dim, DestVerts); + FillArray(Normal, DestNormals, VERTS_PER_FACE); + FillArray(VertexMaterial(RGB, 0.f, 0.f), DestMats, VERTS_PER_FACE); + Dest->At += VERTS_PER_FACE; + } + + while (BotFaces) + { + u64 This = UnsetLeastSignificantSetBit(&BotFaces); + u32 xOffset = GetIndexOfSingleSetBit(This); + v3 P = V3(s32(xOffset), y, z); + u16 RGB = Voxels[BaseVoxelOffset+xOffset].RGBColor; + + u16 PNormal = Voxels[BaseVoxelOffset+xOffset].Normal; + v3 Normal = Normalize((UnpackV3_15b(PNormal)) + (V3(0,0,-1) * NormalFactor)); + /* Assert(Length(Normal) > 0.f); */ + + Assert(BufferHasRoomFor(Dest, VERTS_PER_FACE)); + + vert_t.name *DestVerts = Cast( vert_t.name*, Dest->Verts) + Dest->At; + vert_t.name *DestNormals = Cast( vert_t.name*, Dest->Normals) + Dest->At; + vertex_material *DestMats = Dest->Mat + Dest->At; + + BottomFaceVertexData( VertexOffset+P, Dim, DestVerts); + FillArray(Normal, DestNormals, VERTS_PER_FACE); + FillArray(VertexMaterial(RGB, 0.f, 0.f), DestMats, VERTS_PER_FACE); + Dest->At += VERTS_PER_FACE; + } + + + } + } + } + + + link_internal void + BuildWorldChunkMeshFromMarkedVoxels_Greedy_(vert_t.name)( voxel *Voxels, + v3i SrcChunkDim, + + v3i SrcChunkMin, + v3i SrcChunkMax, + + // TODO(Jesse)(immediate, poof, @poof_parens_bug): removing the parens here causes poof to bail .. why? + (buffer_t.name) *DestGeometry, + (buffer_t.name) *DestTransparentGeometry, + memory_arena *TempMemory, + + // NOTE(Jesse): This is so we can offset vertices such that we center + // entity models about 0 and rotation works properly. + vert_t.name VertexOffset = {}) + { + /* HISTOGRAM_FUNCTION(); */ + TIMED_FUNCTION(); + + NotImplemented; +/* Assert(DestGeometry->Type == DataType_(vert_t.name)); */ + +/* vert_t.name VertexData[VERTS_PER_FACE]; */ +/* matl Materials[VERTS_PER_FACE]; */ + +/* auto SrcMinP = SrcChunkMin; */ +/* auto MaxDim = Min(SrcChunkDim, SrcChunkMax); */ + +/* auto TmpDim = MaxDim-SrcMinP; */ + +/* u32 TmpVol = u32(Volume(TmpDim)); */ +/* auto TempVoxels = Allocate(voxel, TempMemory, TmpVol); */ + +/* // NOTE(Jesse): It's necessary to copy the voxel data because the meshing */ +/* // algorithm unsets the face flags for the voxels instead of marking them */ +/* // as being processed. When complete, there should be no face-flags left on */ +/* // this data. (This is not asserted, but maybe should be?) */ +/* // */ +/* // TODO(Jesse): Assert there are no face flags left in this copy at the end of */ +/* // this process? */ +/* // */ +/* // TODO(Jesse): Copy data into here as the algorithm proceedes instead of in */ +/* // one shot at the start? */ +/* // */ +/* u32 TmpIndex = 0; */ +/* for ( s32 zIndex = 0; zIndex < TmpDim.z ; ++zIndex ) */ +/* { */ +/* for ( s32 yIndex = 0; yIndex < TmpDim.y ; ++yIndex ) */ +/* { */ +/* for ( s32 xIndex = 0; xIndex < TmpDim.x ; ++xIndex ) */ +/* { */ +/* voxel_position SrcP = SrcMinP + Voxel_Position(xIndex, yIndex, zIndex); */ +/* s32 SrcIndex = GetIndex(SrcP, SrcChunkDim); */ +/* /1* Assert(TmpIndex < TmpVol); *1/ */ +/* TempVoxels[TmpIndex] = Voxels[SrcIndex]; */ +/* TmpIndex++; */ +/* } */ +/* } */ +/* } */ + +/* Assert(TmpIndex == TmpVol); */ + +/* s32 Index = 0; */ +/* for ( s32 z = 0; z < TmpDim.z ; ++z ) */ +/* { */ +/* for ( s32 y = 0; y < TmpDim.y ; ++y ) */ +/* { */ +/* for ( s32 x = 0; x < TmpDim.x ; ++x ) */ +/* { */ +/* v3i TmpVoxP = V3i(x,y,z); */ +/* voxel *Voxel = TempVoxels + Index; */ + +/* FillArray(VertexMaterial(Voxel->Color, Voxel->Transparency, 0), Materials, VERTS_PER_FACE); */ + +/* (buffer_t.name) *Dest = {}; */ +/* if (Voxel->Transparency) { Dest = DestTransparentGeometry; } else { Dest = DestGeometry; } */ + +/* if (Dest) */ +/* { */ +/* if (Voxel->Flags & Voxel_RightFace) */ +/* { */ +/* v3 Dim = DoXStepping(TempVoxels, TmpDim, TmpVoxP, Voxel_RightFace, Voxel->Color, Voxel->Transparency); */ +/* RightFaceVertexData( VertexOffset+TmpVoxP, Dim, VertexData); */ +/* 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, (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, (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, (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, (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, (vert_t.name)_BackFaceNormalData, Materials); */ +/* } */ +/* } */ + +/* ++Index; */ +/* } */ +/* } */ +/* } */ + +/* if (DestGeometry) DestGeometry->Timestamp = __rdtsc(); */ +/* if (DestTransparentGeometry) DestTransparentGeometry->Timestamp = __rdtsc(); */ - if (DestGeometry) DestGeometry->Timestamp = __rdtsc(); - if (DestTransparentGeometry) DestTransparentGeometry->Timestamp = __rdtsc(); } link_internal void @@ -1700,7 +1814,8 @@ poof( memory_arena *TempMemory, vert_t.name VertexOffset = {}) { - BuildWorldChunkMeshFromMarkedVoxels_Greedy_(vert_t.name)(Vox->ChunkData->Voxels, Vox->ChunkData->Dim, {}, Vox->ChunkData->Dim, DestGeometry, DestTransparentGeometry, TempMemory, VertexOffset); + NotImplemented; + /* BuildWorldChunkMeshFromMarkedVoxels_Greedy_(vert_t.name)(Vox->ChunkData->Voxels, Vox->ChunkData->Dim, {}, Vox->ChunkData->Dim, DestGeometry, DestTransparentGeometry, TempMemory, VertexOffset); */ } link_internal void @@ -1998,11 +2113,7 @@ poof( /* // TODO(Jesse): This copy could be avoided in multiple ways, and should be. */ /* /1* FillColorArray(Voxel->Color, FaceColors, ColorPallette, VERTS_PER_FACE); *1/ */ -/* /1* #if VOXEL_DEBUG_COLOR *1/ */ - /* /1* v3 Color = Abs(Voxel->DebugColor); *1/ */ -/* /1* #else *1/ */ /* /1* v3 Color = GetColorData(Voxel->Color); *1/ */ -/* /1* #endif *1/ */ /* f32 Trans = (f32)Voxel->Transparency / 255.f; */ /* FillArray(VertexMaterial(Voxel->Color, Trans, 0.f), Materials, VERTS_PER_FACE); */ @@ -2060,6 +2171,35 @@ poof(world_chunk_mesh_functions(untextured_3d_geometry_buffer, v3)) poof(world_chunk_mesh_functions(untextured_3d_geometry_buffer, v3_u8)) #include +link_internal s32 +CountRequiredFacesForMesh_Naieve( u64 *FaceMasks, + v3i SrcChunkDim) +{ + /* HISTOGRAM_FUNCTION(); */ + TIMED_FUNCTION(); + + Assert(SrcChunkDim == V3i(64, 66, 66)); + + s32 Result = 0; + for ( s32 zBlock = 1; zBlock < SrcChunkDim.z; ++zBlock ) + { + s32 z = zBlock; + for ( s32 yBlock = 1; yBlock < SrcChunkDim.y; ++yBlock ) + { + s32 y = yBlock; + s32 OccupancyIndex = GetIndex(yBlock, zBlock, SrcChunkDim.yz); + + RangeIterator(MaskIndex, 6) + { + u64 Faces = FaceMasks[(OccupancyIndex*6)+MaskIndex]; + Result += CountBitsSet_Kernighan(Faces); + } + } + } + return Result; +} + + #if 0 link_internal void BuildWorldChunkMesh_Direct( voxel *Voxels, @@ -2557,30 +2697,9 @@ GetClosestPointRelativeTo(voxel_position* Query, voxel_position* Start, voxel_po return Result; } +#if 0 link_internal b32 -AboveVoxelIsUnfilled(s32 Index, voxel *Voxels, chunk_dimension ChunkDim) -{ - TIMED_FUNCTION(); - - /* Assert( IsSet(Chunk, Chunk_VoxelsInitialized) ); */ - - s32 VolumeChunkDim = Volume(ChunkDim); - Assert(Index < VolumeChunkDim); - - voxel_position CurrentP = GetPosition(Index, ChunkDim); - - voxel_position TopVoxel = CurrentP + Voxel_Position(0, 0, 1); - s32 TopVoxelReadIndex = GetIndexUnsafe(TopVoxel, ChunkDim); - - b32 Result = False; - - if (TopVoxelReadIndex > -1 && TopVoxelReadIndex < VolumeChunkDim) - Result |= NotFilled( Voxels+TopVoxelReadIndex ); - - return Result; -} -link_internal b32 -HasUnfilledNeighbors(s32 Index, world_chunk* Chunk, chunk_dimension ChunkDim) +HasUnfilledNeighbors(s32 Index, world_chunk *Chunk, chunk_dimension ChunkDim) { TIMED_FUNCTION(); @@ -2627,12 +2746,15 @@ HasUnfilledNeighbors(s32 Index, world_chunk* Chunk, chunk_dimension ChunkDim) return Result; } +#endif link_internal void GetBoundingVoxelsClippedTo(world_chunk* Chunk, chunk_dimension ChunkDim, boundary_voxels* Dest, aabb Clip) { /* TIMED_FUNCTION(); */ + NotImplemented; +#if 0 v3 MinClip = GetMin(Clip); v3 MaxClip = GetMax(Clip); @@ -2666,6 +2788,7 @@ GetBoundingVoxelsClippedTo(world_chunk* Chunk, chunk_dimension ChunkDim, boundar } } } +#endif return; } @@ -2748,7 +2871,7 @@ BigBits2015_BestFittingPlaneFor(boundary_voxels* BoundingPoints) InvalidCodePath(); } - Result.Plane = plane(Centroid, Normal); + Result.Plane = Plane(Centroid, Normal); Result.Complete = True; } } @@ -2859,6 +2982,8 @@ link_internal v3 ComputeNormalBonsai(world_chunk *DestChunk, v3i DestChunkDim, v3 BoundingVoxelMidpoint) { v3 Normal = {}; + NotImplemented; +#if 0 for ( s32 VoxelIndex = 0; VoxelIndex < Volume(DestChunkDim); ++VoxelIndex) @@ -2873,6 +2998,7 @@ ComputeNormalBonsai(world_chunk *DestChunk, v3i DestChunkDim, v3 BoundingVoxelMi } Normal = Normalize(Normal); +#endif return Normal; } @@ -2895,7 +3021,7 @@ GetBoundingVoxelsMidpoint(world_chunk *Chunk, v3i ChunkDim) /* // TODO(Jesse): This literally only accumulates an integer .. remove TempBoundingPoints and other ancillary shit */ standing_spot -ComputeStandingSpotFor8x8x2_V2(voxel *Voxels, v3i SrcChunkDim, v3i TileChunkOffset, v3i TileChunkDim) //, boundary_voxels *TempBoundingPoints) +ComputeStandingSpotFor8x8x2_V2(u64* Occupancy, voxel *Voxels, v3i SrcChunkDim, v3i TileChunkOffset, v3i TileChunkDim) //, boundary_voxels *TempBoundingPoints) { TIMED_FUNCTION(); standing_spot Result = {}; @@ -2915,10 +3041,14 @@ ComputeStandingSpotFor8x8x2_V2(voxel *Voxels, v3i SrcChunkDim, v3i TileChunkOffs s32 vIndex = GetIndex(P, SrcChunkDim); voxel *V = Voxels + vIndex; - if (IsSet(V, Voxel_Filled) && IsSet(V, Voxel_TopFace)) + s32 vOccupancy = GetOccupancyBit(Occupancy, vIndex); + +#if 0 + if (vOccupancy && IsSet(V, Voxel_TopFace)) { ++StandableCount; } +#endif } } } @@ -3067,6 +3197,7 @@ IsValidForDestChunk(v3i Spot, v3i DestChunkDim) link_internal void ComputeStandingSpots( v3i SrcChunkDim, + u64 *Occupancy, voxel *Voxels, v3i SrcChunkOffset, @@ -3102,7 +3233,7 @@ ComputeStandingSpots( v3i SrcChunkDim, for (s32 zIndex = MinDim.z; zIndex <= MaxDim.z; zIndex += 1) { v3i TileOffset = V3i(xIndex, yIndex, zIndex); - standing_spot Spot = ComputeStandingSpotFor8x8x2_V2(Voxels, SrcChunkDim, TileOffset, TileDim); //, TempBoundingPoints); + standing_spot Spot = ComputeStandingSpotFor8x8x2_V2(Occupancy, Voxels, SrcChunkDim, TileOffset, TileDim); //, TempBoundingPoints); if (Spot.CanStand) { @@ -3148,7 +3279,8 @@ ComputeStandingSpots( v3i SrcChunkDim, /* memory_arena *PermMemory, */ memory_arena *TempMemory ) { - ComputeStandingSpots( SrcChunkDim, SrcChunk->Voxels, SrcChunkOffset, SrcChunkToDestChunk, TileDim, DestChunkDim, DebugMesh, DestStandingSpots, /* PermMemory, */ TempMemory ); + NotImplemented; + /* ComputeStandingSpots( SrcChunkDim, SrcChunk->Occupancy, SrcChunk->Voxels, SrcChunkOffset, SrcChunkToDestChunk, TileDim, DestChunkDim, DebugMesh, DestStandingSpots, /1* PermMemory, *1/ TempMemory ); */ } #if 0 @@ -3428,13 +3560,7 @@ ComputeLodMesh( thread_local_state *Thread, #if 1 #endif -/* link_internal chunk_dimension */ -/* ChunkDimension(world_chunk* Chunk) */ -/* { */ -/* chunk_dimension Result = Chunk->Dim; */ -/* return Result; */ -/* } */ - +#if 0 link_internal void InitializeWorldChunkEmpty(world_chunk *DestChunk) { @@ -3448,11 +3574,10 @@ InitializeWorldChunkEmpty(world_chunk *DestChunk) ZeroChunk(DestChunk, Volume(WorldChunkDim)); #else for ( s32 VoxelIndex = 0; - VoxelIndex < Volume(DestChunk->Dim); - ++VoxelIndex) + VoxelIndex < Volume(DestChunk->Dim); + ++VoxelIndex) { voxel *Voxel = &DestChunk->Voxels[VoxelIndex]; - Voxel->Flags = Voxel_Empty; Voxel->Color = 0; } #endif @@ -3462,18 +3587,40 @@ InitializeWorldChunkEmpty(world_chunk *DestChunk) return; } +#endif -// TODO(Jesse)(hack): Remove this! -global_variable memory_arena Global_PermMemory = {}; +debug_global u32 TotalChunksQueued; inline void -QueueChunkForInit(work_queue *Queue, world_chunk *Chunk, world_chunk_mesh_bitfield MeshBit) +QueueChunkForInit(work_queue *Queue, octree_node *Node, world_chunk_mesh_bitfield MeshBit) { TIMED_FUNCTION(); - Assert( NotSet(Chunk->Flags, Chunk_Queued) ); -/* DebugLine("Queuing Chunk (%p)(%d, %d, %d)", Chunk, Chunk->WorldP.x, Chunk->WorldP.y, Chunk->WorldP.z); */ + Assert(Node->Chunk); + Assert(Node->Chunk->Dim.x); + Assert( NotSet(Node->Flags, Chunk_Queued) ); + + ++TotalChunksQueued; + AtomicIncrement(&GetEngineResources()->Graphics.TotalChunkJobsActive); + +#if 0 + { + Assert(Node->Chunk->Dim.x == 64); + DebugLine("Queuing Chunk (%p)(%d) WorldP(%d, %d, %d) DimInChunks(%d, %d, %d) Dim(%d, %d, %d)", Node->Chunk, Node->Chunk->Flags, + Node->Chunk->WorldP.x, + Node->Chunk->WorldP.y, + Node->Chunk->WorldP.z, + Node->Chunk->DimInChunks.x, + Node->Chunk->DimInChunks.y, + Node->Chunk->DimInChunks.z, + Node->Chunk->Dim.x, + Node->Chunk->Dim.y, + Node->Chunk->Dim.z); + } +#endif + +#if 0 work_queue_entry Entry = {}; { Entry.Type = type_work_queue_entry_init_world_chunk; @@ -3482,13 +3629,17 @@ QueueChunkForInit(work_queue *Queue, world_chunk *Chunk, world_chunk_mesh_bitfie /* Job->MeshBit = MeshBit; */ } - Assert( NotSet(Chunk->Flags, Chunk_Queued) ); - SetFlag(&Chunk->Flags, Chunk_Queued); PushWorkQueueEntry(Queue, &Entry); +#else + Assert( NotSet(Node->Flags, Chunk_Queued) ); + SetFlag(&Node->Flags, Chunk_Queued); + + PushBonsaiRenderCommandInitializeNoiseBuffer(Queue, Node); +#endif - return; } +#if 0 inline void QueueChunkForMeshRebuild(work_queue *Queue, world_chunk *Chunk, chunk_init_flags Flags = ChunkInitFlag_Noop) { @@ -3512,9 +3663,21 @@ QueueChunkForMeshRebuild(work_queue *Queue, world_chunk *Chunk, chunk_init_flags Job->Flags = Flags; /* Job->MeshBit = MeshBit; */ } - - SetFlag(&Chunk->Flags, Chunk_Queued); - PushWorkQueueEntry(Queue, &Entry); + + SetFlag(&Chunk->Flags, Chunk_Queued); + PushWorkQueueEntry(Queue, &Entry); +} +#endif + +link_internal void +BuildWorldChunkMeshFromMarkedVoxels_Naieve( voxel *Voxels, u64 *FaceMasks, v3i SrcChunkDim, v3i SrcChunkMin, v3i SrcChunkMax, untextured_3d_geometry_buffer *DestGeometry, untextured_3d_geometry_buffer *DestTransparentGeometry, v3 VertexOffset = {}) +{ + switch(DestGeometry->Type) + { + InvalidCase(DataType_Undefinded); + case DataType_v3: BuildWorldChunkMeshFromMarkedVoxels_Naieve_v3(Voxels, FaceMasks, SrcChunkDim, SrcChunkMin, SrcChunkMax, DestGeometry, DestTransparentGeometry, VertexOffset); break; + case DataType_v3_u8: BuildWorldChunkMeshFromMarkedVoxels_Naieve_v3_u8(Voxels, FaceMasks, SrcChunkDim, SrcChunkMin, SrcChunkMax, DestGeometry, DestTransparentGeometry, V3U8(VertexOffset)); break; + } } link_internal void @@ -3551,47 +3714,33 @@ BuildMipMesh( voxel *Voxels, v3i VoxDim, v3i InnerMin, v3i InnerMax, world_ch } } +#if 0 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 = {}) +RebuildWorldChunkMesh( + thread_local_state *Thread, + world_chunk *Chunk, + voxel *Voxels, + v3i MinOffset, + v3i MaxOffset, + world_chunk_mesh_bitfield MeshBit, + geo_u3d *Dest, + memory_arena *TempMem, + v3 VertexOffset = {}) { - engine_resources *Engine = GetEngineResources(); - - Assert(Chunk->DEBUG_OwnedByThread == 0); - Chunk->DEBUG_OwnedByThread = ThreadLocal_ThreadIndex; + /* HISTOGRAM_FUNCTION(); */ + TIMED_FUNCTION(); - Assert( IsSet(Chunk->Flags, Chunk_VoxelsInitialized) ); + engine_resources *Engine = GetEngineResources(); + /* Assert( IsSet(Chunk->Flags, Chunk_VoxelsInitialized) ); */ + Assert( MeshBit == MeshBit_Lod0 ); - if (MeshBit == MeshBit_Lod0) - { -#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, VertexOffset); + BuildWorldChunkMeshFromMarkedVoxels_Naieve( Voxels, Chunk->FaceMasks, Chunk->Dim, MinOffset, MaxOffset, Dest, 0); + /* if (Dest->At == 0) { PushDeallocateBuffersCommand(&Engine->Stdlib.Plat.LoRenderQ, &Chunk->Handles); } */ +} #endif - } - else - { - BuildMipMesh( Chunk->Voxels, Chunk->Dim, {}, Chunk->Dim, MeshBit, TempMesh, TempMem ); - } - - if (TempMesh->At) - { - 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, &Engine->world_chunk_MeshFreelist); } - } - else - { - PushDeallocateBuffersCommand(&Engine->Stdlib.Plat.RenderQ, &Chunk->Meshes.GpuBufferHandles[ToIndex(MeshBit)]); - /* DeallocateGpuBuffers(&Engine->Stdlib.Plat.RenderQ, Chunk); */ - } - Chunk->DEBUG_OwnedByThread = 0; - // NOTE(Jesse): Chunk flags modified by caller; this routine gets called multiple times per job -} +#if 0 link_internal void InitializeChunkWithNoise( chunk_init_callback NoiseCallback, thread_local_state *Thread, @@ -3605,7 +3754,21 @@ InitializeChunkWithNoise( chunk_init_callback NoiseCallback, b32 MakeExteriorFaces = False, v3i NoiseBasisOffset = {} ) { - TIMED_FUNCTION(); + /* HISTOGRAM_FUNCTION(); */ + /* TIMED_FUNCTION(); */ + + + u32 ChunkFlags = DestChunk->Flags; + if ( (ChunkFlags & Chunk_Queued) == 0) + { + Info("%d", ChunkFlags); + RuntimeBreak(); + } + if ( (ChunkFlags & Chunk_Freelist) != 0) + { + Info("%d", ChunkFlags); + RuntimeBreak(); + } engine_resources *EngineResources = GetEngineResources(); @@ -3614,148 +3777,26 @@ InitializeChunkWithNoise( chunk_init_callback NoiseCallback, Assert(Global_ChunkApronDim.y == Global_ChunkApronMinDim.y + Global_ChunkApronMaxDim.y); Assert(Global_ChunkApronDim.z == Global_ChunkApronMinDim.z + Global_ChunkApronMaxDim.z); - Assert(!ChunkIsGarbage(DestChunk)); - - /* Assert(MeshBit == MeshBit_Lod0); */ - - - - // TODO(Jesse): Pretty sure this is unnecessary - /* ClearChunkVoxels(DestChunk->Voxels, DestChunk->Dim); */ + /* Assert(!ChunkIsGarbage(DestChunk)); */ untextured_3d_geometry_buffer* Mesh = 0; - /* untextured_3d_geometry_buffer* DebugMesh = 0; */ - /* untextured_3d_geometry_buffer* TransparencyMesh = 0; */ - v3i SynChunkDim = (DestChunk->Dim + Global_ChunkApronDim); + /* v3i SynChunkDimMin = (DestChunk->Dim + Global_ChunkApronDim); */ + v3i SynChunkDimMin = (DestChunk->Dim); + Assert(SynChunkDimMin == V3i(64)); + /* v3i SynChunkDim = RoundToMultiple(SynChunkDimMin, V3i(MIN_TERRAIN_NOISE_WIDTH)); */ + /* v3i SynChunkDim = SynChunkDimMin + V3i(0, 2, 4); */ + v3i SynChunkDim = SynChunkDimMin + V3i(0, 2, 2); + /* v3i SynChunkDim = SynChunkDimMin; */ v3i SynChunkP = DestChunk->WorldP; + world_chunk *SyntheticChunk = AllocateWorldChunk(SynChunkP, SynChunkDim, DestChunk->DimInChunks, Thread->TempMemory); + SyntheticChunk->Flags = Chunk_Queued; - world_chunk *SyntheticChunk = AllocateWorldChunk(SynChunkP, SynChunkDim, Thread->TempMemory); - - - // Map to absolute space. Very bad, no good, do not try this at home. - // - v3i NoiseBasis = NoiseBasisOffset + (DestChunk->WorldP*GetWorldChunkDim()); - - u32 SyntheticChunkSum = NoiseCallback( SyntheticChunk, - NoiseBasis, - NoiseParams, - UserData ); - - Assert(SyntheticChunk->Dim == SynChunkDim); - -#if 1 && VOXEL_DEBUG_COLOR - DestChunk->NoiseValues = SyntheticChunk->NoiseValues; - DestChunk->NormalValues = SyntheticChunk->NormalValues; - -#if 1 - if (DestChunk->NoiseValues) - { - for ( s32 z = 0; z < SyntheticChunk->Dim.z; ++ z) - { - for ( s32 y = 0; y < SyntheticChunk->Dim.y; ++ y) - { - for ( s32 x = 0; x < SyntheticChunk->Dim.x; ++ x) - { - s32 NormalIndex = GetIndex(V3i(x,y,z), SyntheticChunk->Dim); - s32 NoiseIndex = GetIndex(V3i(x,y,z)+1, SyntheticChunk->Dim+2); - SyntheticChunk->Voxels[NormalIndex].DebugColor = SyntheticChunk->NormalValues[NormalIndex]; - SyntheticChunk->Voxels[NormalIndex].DebugNoiseValue = SyntheticChunk->NoiseValues[NoiseIndex]; - } - } - } - } -#endif - -#endif - - - if (MakeExteriorFaces) - { - MarkBoundaryVoxels_MakeExteriorFaces(SyntheticChunk->Voxels, SynChunkDim, Global_ChunkApronMinDim, SynChunkDim-Global_ChunkApronMaxDim); - } - else - { - MarkBoundaryVoxels_NoExteriorFaces(SyntheticChunk->Voxels, SynChunkDim, {}, SynChunkDim); - } - - CopyChunkOffset(SyntheticChunk, SynChunkDim, DestChunk, DestChunk->Dim, Global_ChunkApronMinDim); - - // 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; */ - - // NOTE(Jesse): The DestChunk is finalized at the end of the routine - /* SetFlag(DestChunk, Chunk_VoxelsInitialized); */ - FinalizeChunkInitialization(SyntheticChunk); - - if (Flags & ChunkInitFlag_ComputeStandingSpots) - { - ComputeStandingSpots( SynChunkDim, SyntheticChunk, {{1,1,0}}, {{0,0,1}}, Global_StandingSpotDim, - DestChunk->Dim, 0, &DestChunk->StandingSpots, - Thread->TempMemory); - } - -#if 0 - if (SyntheticChunkSum && (Flags & ChunkInitFlag_GenSmoothLODs) ) - { - untextured_3d_geometry_buffer *TempMesh = AllocateTempWorldChunkMesh(Thread->TempMemory); - ComputeLodMesh( Thread, DestChunk, DestChunk->Dim, SyntheticChunk, SynChunkDim, TempMesh, True); - - if (TempMesh->At) - { - LodMesh = GetPermMeshForChunk(&EngineResources->MeshFreelist, TempMesh, Thread->PermMemory); - DeepCopy(TempMesh, LodMesh); - } - } -#endif - - if (SyntheticChunkSum) - { - 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; - - if (Flags & ChunkInitFlag_GenLODs) - { - RebuildWorldChunkMesh(Thread, SyntheticChunk, Global_ChunkApronMinDim, Global_ChunkApronMinDim+DestChunk->Dim, MeshBit_Lod1, TempMesh, Thread->TempMemory); - TempMesh->At = 0; - - RebuildWorldChunkMesh(Thread, SyntheticChunk, Global_ChunkApronMinDim, Global_ChunkApronMinDim+DestChunk->Dim, MeshBit_Lod2, TempMesh, Thread->TempMemory); - TempMesh->At = 0; - - RebuildWorldChunkMesh(Thread, SyntheticChunk, Global_ChunkApronMinDim, Global_ChunkApronMinDim+DestChunk->Dim, MeshBit_Lod3, TempMesh, Thread->TempMemory); - TempMesh->At = 0; - - RebuildWorldChunkMesh(Thread, SyntheticChunk, Global_ChunkApronMinDim, Global_ChunkApronMinDim+DestChunk->Dim, MeshBit_Lod4, TempMesh, Thread->TempMemory); - TempMesh->At = 0; - } - } - -#define FINALIZE_MESH_FOR_CHUNK(Src, Dest, Bit) \ - { \ - auto *SrcMesh = (Src)->Meshes.E[ToIndex(Bit)]; \ - if (SrcMesh) { \ - if (SrcMesh->At) { \ - AtomicReplaceMesh(&(Dest)->Meshes, Bit, SrcMesh, SrcMesh->Timestamp); \ - } else { \ - DeallocateMesh(EngineResources, SrcMesh); \ - } \ - } \ - } - - FINALIZE_MESH_FOR_CHUNK(SyntheticChunk, DestChunk, MeshBit_Lod0 ); - FINALIZE_MESH_FOR_CHUNK(SyntheticChunk, DestChunk, MeshBit_Lod1 ); - FINALIZE_MESH_FOR_CHUNK(SyntheticChunk, DestChunk, MeshBit_Lod2 ); - FINALIZE_MESH_FOR_CHUNK(SyntheticChunk, DestChunk, MeshBit_Lod3 ); - FINALIZE_MESH_FOR_CHUNK(SyntheticChunk, DestChunk, MeshBit_Lod4 ); -#undef FINALIZE_MESH_FOR_CHUNK - - FinalizeChunkInitialization(DestChunk); + SyntheticChunk->FilledCount = s32(NoiseCallback( SyntheticChunk, + NoiseBasisOffset, + NoiseParams, UserData )); } // TODO(Jesse): Remove this thnk @@ -3782,6 +3823,7 @@ InitializeChunkWithNoise( chunk_init_callback NoiseCallback, generic_noise_params Params = {r32(Thresh), Period, r32(Amp), RGBColor}; InitializeChunkWithNoise(NoiseCallback, Thread, DestChunk, &Params, Flags, UserData, MakeExteriorFaces, NoiseBasisOffset); } +#endif // nochecking Move as much out of this block as possible. Only the last few of // the things in this block are actually related to drawing @@ -3792,9 +3834,25 @@ WorkQueueEntryRebuildMesh(world_chunk *Chunk, chunk_init_flags Flags) return Result; } +link_internal work_queue_entry_build_chunk_mesh +WorkQueueEntryBuildWorldChunkMesh(gen_chunk *SynChunk, octree_node *DestNode) +{ + work_queue_entry_build_chunk_mesh Result = {SynChunk, DestNode}; + return Result; +} + +link_internal work_queue_entry_finalize_noise_values +WorkQueueEntryFinalizeNoiseValues(gpu_readback_buffer PBOBuf, u32 *NoiseData, v3i NoiseDim, octree_node *Chunk) +{ + work_queue_entry_finalize_noise_values Result = { PBOBuf, NoiseData, NoiseDim, Chunk }; + return Result; +} + + +#if 0 link_internal work_queue_entry_update_world_region -WorkQueueEntryUpdateWorldRegion(world_edit_mode Mode, - world_edit_mode_modifier Modifier, +WorkQueueEntryUpdateWorldRegion(world_edit_blend_mode Mode, + world_edit_blend_mode_modifier Modifier, v3 SimFloodOrigin, world_edit_shape *Shape, v3 RGBColor, @@ -3810,7 +3868,6 @@ WorkQueueEntryUpdateWorldRegion(world_edit_mode Mode, *Shape, Mode, Modifier, - /* SimFloodOrigin, */ }, RGBColor, {}, @@ -3822,6 +3879,7 @@ WorkQueueEntryUpdateWorldRegion(world_edit_mode Mode, }; return Result; } +#endif link_internal work_queue_entry_copy_buffer_ref WorkQueueEntryCopyBufferRef(lod_element_buffer *Buf, world_chunk_mesh_bitfield MeshBit, untextured_3d_geometry_buffer* Dest, world_position ChunkP, camera* Camera, chunk_dimension WorldChunkDim) @@ -3871,15 +3929,15 @@ DebugHighlightWorldChunkBasedOnState(graphics *Graphics, world_chunk *Chunk, unt engine_debug *EngineDebug = GetEngineDebug(); if (Chunk) { - Assert (Chunk == EngineDebug->PickedChunk); + Assert (Chunk == EngineDebug->PickedNode->Chunk); v3 RGBColor = EngineDebug->PickedChunkState == PickedChunkState_None ? RGB_GREEN : RGB_YELLOW; untextured_3d_geometry_buffer Mesh = ReserveBufferSpace(Dest, VERTS_PER_AABB); - DEBUG_DrawChunkAABB( &Mesh, Graphics, EngineDebug->PickedChunk, EngineDebug->PickedChunk->Dim, RGBColor ); + DEBUG_DrawChunkAABB( &Mesh, Graphics, EngineDebug->PickedNode->Chunk, Chunk->Dim, RGBColor ); } #endif #if 0 - v3 RGBColor = 0; + v3 RGBColor = {}; if (Chunk) { @@ -4008,7 +4066,7 @@ GetStandingSpotsWithinRadiusSorted(world *World, standing_spot_buffer *Spots, cp v3 SimP = GetSimSpaceP(World, P); standing_spot_buffer UnsortedSpots = StandingSpotBuffer(Spots->Count, TempMemory); - sort_key_f *SortKeys = Allocate(sort_key_f, TempMemory, Spots->Count); + sort_key_f64 *SortKeys = Allocate(sort_key_f64, TempMemory, Spots->Count); r32 RadSq = Square(Radius); u32 ResultAt = 0; @@ -4137,12 +4195,13 @@ GetStandingSpotsWithinRadius_FilteredByStandable(world *World, canonical_positio link_internal picked_world_chunk GetChunksIntersectingRay(world *World, ray *Ray, picked_world_chunk_static_buffer *AllChunksBuffer) { - world_chunk *ClosestChunk = 0; + octree_node *ClosestNode = 0; - chunk_dimension VisibleRegion = World->VisibleRegion; - chunk_dimension Radius = VisibleRegion/2; - world_position Min = World->Center - Radius; - world_position Max = World->Center + Radius; + v3i VisibleRegion = V3i(World->VisibleRegionSize); + + v3i Radius = VisibleRegion/2; + v3i Min = World->Center - Radius; + v3i Max = World->Center + Radius; f32 tChunkMin = 0.f; for (s32 z = Min.z; z < Max.z; ++ z) @@ -4152,24 +4211,26 @@ GetChunksIntersectingRay(world *World, ray *Ray, picked_world_chunk_static_buffe for (s32 x = Min.x; x < Max.x; ++ x) { world_position P = World_Position(x,y,z); - world_chunk *Chunk = GetWorldChunkFromHashtable( World, P ); - - if (Chunk) + /* world_chunk *Chunk = GetWorldChunkFromHashtable( World, P ); */ + if (octree_node *Node = GetWorldChunkFromOctree( World, P )) { - /* aabb ChunkAABB = AABBMinDim( V3(World->ChunkDim*Chunk->WorldP), V3(World->ChunkDim) ); */ - aabb ChunkAABB = GetSimSpaceAABB(World, Chunk); - - aabb_intersect_result IntersectResult = Intersect(ChunkAABB, Ray); - if ( IntersectResult.Face != FaceIndex_None ) + if (world_chunk *Chunk = Node->Chunk) { - /* DEBUG_DrawSimSpaceAABB(GetEngineResources(), &ChunkAABB, RED); */ - r32 tChunk = IntersectResult.t; - if ( AllChunksBuffer ) { Push(AllChunksBuffer, Chunk, tChunk); } + /* aabb ChunkAABB = AABBMinDim( V3(World->ChunkDim*Chunk->WorldP), V3(World->ChunkDim) ); */ + aabb ChunkAABB = GetSimSpaceAABB(World, Chunk); - if (Chunk->FilledCount && tChunk < tChunkMin) + aabb_intersect_result IntersectResult = Intersect(ChunkAABB, Ray); + if ( IntersectResult.Face != FaceIndex_None ) { - ClosestChunk = Chunk; - tChunkMin = tChunk; + /* DEBUG_DrawSimSpaceAABB(GetEngineResources(), &ChunkAABB, RED); */ + r32 tChunk = IntersectResult.t; + if ( AllChunksBuffer ) { Push(AllChunksBuffer, Node, tChunk); } + + if (Chunk->FilledCount && tChunk < tChunkMin) + { + ClosestNode = Node; + tChunkMin = tChunk; + } } } } @@ -4177,7 +4238,57 @@ GetChunksIntersectingRay(world *World, ray *Ray, picked_world_chunk_static_buffe } } - return { .Chunk = ClosestChunk, .tChunk = r64(tChunkMin) }; + return { .Node = ClosestNode, .t = r64(tChunkMin) }; +} + +link_internal void +IntersectOctreeLeaves_Recursive(world *World, ray *Ray, octree_node *Node, picked_octree_node_block_array *Intersections) +{ + aabb Box = GetSimSpaceAABB(World, Node); + r32 t; + if (Intersect(&Box, Ray, &t)) + { + switch(Node->Type) + { + InvalidCase(OctreeNodeType_Undefined); + + case OctreeNodeType_Leaf: + { + /* if (Node->Chunk && (Node->Chunk->Flags&Chunk_VoxelsInitialized) && t > 0) */ + /* if (t > 0) */ + { + picked_octree_node PNode = {Node, t}; + Push(Intersections, &PNode); + } + } break; + + case OctreeNodeType_Branch: + { + /* aabb AABB = GetSimSpaceAABB(World, Node); */ + /* DEBUG_DrawSimSpaceAABB(GetEngineResources(), &AABB, RGB_GREEN, 2.f); */ + IntersectOctreeLeaves_Recursive(World, Ray, Node->Children[0], Intersections); + IntersectOctreeLeaves_Recursive(World, Ray, Node->Children[1], Intersections); + IntersectOctreeLeaves_Recursive(World, Ray, Node->Children[2], Intersections); + IntersectOctreeLeaves_Recursive(World, Ray, Node->Children[3], Intersections); + IntersectOctreeLeaves_Recursive(World, Ray, Node->Children[4], Intersections); + IntersectOctreeLeaves_Recursive(World, Ray, Node->Children[5], Intersections); + IntersectOctreeLeaves_Recursive(World, Ray, Node->Children[6], Intersections); + IntersectOctreeLeaves_Recursive(World, Ray, Node->Children[7], Intersections); + } break; + } + } +} + +link_internal picked_octree_node_block_array +GetOctreeLeafNodesIntersectingRay(world *World, ray *Ray, memory_arena *Memory) +{ + picked_octree_node_block_array Result = {}; + Result.Memory = Memory; + + octree_node *Current = &World->Root; + IntersectOctreeLeaves_Recursive(World, Ray, Current, &Result); + + return Result; } link_internal world_chunk* @@ -4194,12 +4305,13 @@ GetChunksFromMouseP(engine_resources *Engine, picked_world_chunk_static_buffer * ClosestChunk = GetChunksIntersectingRay(World, &MaybeRay.Ray, AllChunksBuffer); } - return ClosestChunk.Chunk; + return ClosestChunk.Node->Chunk; } link_internal aabb WorldChunkAABB(world_chunk *Chunk, v3 WorldChunkDim) { + NotImplemented; // NOTE(Jesse): Buggy, needs to account for chunk resolution v3 MinP = V3(Chunk->WorldP) * WorldChunkDim; v3 MaxP = MinP + WorldChunkDim; aabb Result = AABBMinMax(MinP, MaxP); @@ -4207,86 +4319,163 @@ WorldChunkAABB(world_chunk *Chunk, v3 WorldChunkDim) } link_internal picked_voxel -RayTraceCollision(engine_resources *Resources, canonical_position AbsRayOrigin, v3 RayDir) +RayTraceCollision(engine_resources *Engine, ray *Ray) { - UNPACK_ENGINE_RESOURCES(Resources); - Assert(Length(RayDir) <= 1.01f); - - /* { */ - /* untextured_3d_geometry_buffer VoxelMesh = ReserveBufferSpace(&GpuMap->Buffer, VERTS_PER_VOXEL); */ - /* v3 RenderP = GetRenderP(World->ChunkDim, AbsRayOrigin, Camera); */ - /* DrawVoxel( &VoxelMesh, RenderP, V4(1,1,0,1), V3(11.f) ); */ - /* } */ + UNPACK_ENGINE_RESOURCES(Engine); b32 Collision = False; v3 WorldChunkDim = V3(World->ChunkDim); picked_world_chunk_static_buffer AllChunksBuffer = {}; - // TODO(Jesse): Use pre-computed ray on resources. - maybe_ray MaybeRay = ComputeRayFromCursor(Resources, &gBuffer->ViewProjection, Camera, World->ChunkDim); - if (MaybeRay.Tag == Maybe_Yes) { GetChunksIntersectingRay(World, &MaybeRay.Ray, &AllChunksBuffer); } + /* DEBUG_DrawSimSpaceVectorAt(Engine, Ray->Origin+V3(1,1,1), Ray->Dir*10000.f, RGB_PINK, 1.f); */ + + picked_voxel Result = {}; +#if 1 + picked_octree_node_block_array NodeList = GetOctreeLeafNodesIntersectingRay(World, Ray, GetTranArena()); + + u32 NodeCount = u32(Count(&NodeList)); + sort_key_f32 *SortKeys = Allocate(sort_key_f32, GetTranArena(), NodeCount); - v3 Advance = MaybeRay.Ray.Dir; - // b32 Hit = False; + { + IterateOver(&NodeList, Node, NodeIndex) + { + umm I = GetIndex(&NodeIndex); + SortKeys[I].Index = Cast(u64, Node); + SortKeys[I].Value = Node->t; + } + } - BubbleSort((sort_key_f*)AllChunksBuffer.E, (u32)AllChunksBuffer.At); + BubbleSort_descending(SortKeys, NodeCount); - picked_voxel Result = {}; - for (s64 ClosestChunkIndex = s64(AllChunksBuffer.At)-1; ClosestChunkIndex > -1; --ClosestChunkIndex) + b32 Done = False; + /* IterateOver(&NodeList, PickedNode, NodeIndex) */ + RangeIterator_t(u32, SortKeyIndex, NodeCount) { - r32 tChunk = (r32)AllChunksBuffer.E[ClosestChunkIndex].tChunk; - world_chunk *ClosestChunk = AllChunksBuffer.E[ClosestChunkIndex].Chunk; + picked_octree_node *PickedNode = Cast(picked_octree_node*, SortKeys[SortKeyIndex].Index); + + if (Done) break; - if (ClosestChunk->FilledCount == 0) continue; + octree_node *Node = PickedNode->Node; + + r32 tChunk = PickedNode->t; + world_chunk *ClosestChunk = Node->Chunk; #if 0 { - aabb ChunkAABB = GetSimSpaceAABB(World, ClosestChunk); - DEBUG_DrawSimSpaceAABB(GetEngineResources(), &ChunkAABB, RED); + v3 Color = RGB_PINK; + if (Node->Chunk) + { + Color = RGB_YELLOW; + if (Node->Chunk->Flags & Chunk_VoxelsInitialized) + { + Color = RGB_GREEN; + } + } + else + { + Color = RGB_RED; + } + + aabb AABB = GetSimSpaceAABB(World, Node); + DEBUG_DrawSimSpaceAABB(Engine, &AABB, Color, 1.f); } #endif + if ( Node->Chunk && (Node->Flags & Chunk_VoxelsInitialized) ) + { + v3 Advance = Ray->Dir*0.01f; - v3 CollisionP = MaybeRay.Ray.Origin + (MaybeRay.Ray.Dir*tChunk); + // TODO(Jesse): This should pass. + /* Assert (ClosestChunk->FilledCount > 0); */ - v3 StartP = CollisionP + (Advance*0.1f); + v3 CollisionP = Ray->Origin + (Ray->Dir*tChunk); - v3 AtP = StartP - GetSimSpaceP(World, Canonical_Position(V3(0), ClosestChunk->WorldP)); + v3 StartP = CollisionP + (Advance*0.1f); - u32 AxisIndex = 0; - for (;;) - { - if ( AtP.x < 0 || AtP.x >= WorldChunkDim.x || - AtP.y < 0 || AtP.y >= WorldChunkDim.y || - AtP.z < 0 || AtP.z >= WorldChunkDim.z ) + v3 ChunkSimP = GetSimSpaceP(World, Canonical_Position(V3(0), ClosestChunk->WorldP)); + v3 AtP = (StartP - ChunkSimP) / V3(ClosestChunk->DimInChunks); + + u32 AxisIndex = 0; + for (;;) { - // Hit = False; - break; + if ( AtP.x < 0 || AtP.x >= WorldChunkDim.x || + AtP.y < 0 || AtP.y >= WorldChunkDim.y || + AtP.z < 0 || AtP.z >= WorldChunkDim.z ) + { + // Hit = False; + break; + } + + // TODO(Jesse): Instead of trucating, make ClosestCentroid(AtP) + voxel_position LocalTestP = Voxel_Position(AtP); + if (IsFilledInChunk(ClosestChunk, LocalTestP, World->ChunkDim)) + { + Done = True; + + Result.Chunks[PickedVoxel_FirstFilled] = {Node, r64(tChunk)}; + Result.Picks[PickedVoxel_FirstFilled] = Canonical_Position(AtP, ClosestChunk->WorldP); + +#if 0 + { + untextured_3d_geometry_buffer VoxMesh = ReserveBufferSpace(&GpuMap->Buffer, VERTS_PER_VOXEL); + v3 RenderMin = GetRenderP(Engine, ClosestChunk->WorldP) + V3(LocalTestP*ClosestChunk->DimInChunks); + /* v3 RenderMin = GetRenderP(Engine, ClosestChunk->WorldP) + V3(LocalTestP); */ + DrawVoxel_MinDim( &VoxMesh, RenderMin, RGB_GREEN, V3(ClosestChunk->DimInChunks)); + } +#endif + + break; + } + else + { + Result.Chunks[PickedVoxel_LastEmpty] = {Node, r64(tChunk)}; + Result.Picks[PickedVoxel_LastEmpty] = Canonical_Position(AtP, ClosestChunk->WorldP); + { + /* untextured_3d_geometry_buffer VoxMesh = ReserveBufferSpace(&GpuMap->Buffer, VERTS_PER_VOXEL); */ + /* v3 RenderMin = GetRenderP(Engine, ClosestChunk->WorldP) + V3(LocalTestP*ClosestChunk->DimInChunks); */ + /* v3 RenderMin = GetRenderP(Engine, ClosestChunk->WorldP) + V3(LocalTestP); */ + /* DrawVoxel_MinDim( &VoxMesh, RenderMin, RGB_BLUE, V3(ClosestChunk->DimInChunks)); */ + } + } + + AtP.E[AxisIndex] += Advance.E[AxisIndex]; + AxisIndex = (AxisIndex + 1) % 3; } + } - // TODO(Jesse): Instead of trucating, make ClosestCentroid(AtP) - voxel_position LocalTestP = Voxel_Position(AtP); - if (IsFilledInChunk(ClosestChunk, LocalTestP, World->ChunkDim)) - { - // Hit = True; - ClosestChunkIndex = -1; +#if 0 + { - Result.Chunks[PickedVoxel_FirstFilled] = {ClosestChunk, r64(tChunk)}; - Result.Picks[PickedVoxel_FirstFilled] = Canonical_Position(AtP, ClosestChunk->WorldP); +#if 0 + { + random_series Entropy = {u64(ClosestChunk)}; + v3 Color = RandomV3Unilateral(&Entropy); + untextured_3d_geometry_buffer VoxMesh = ReserveBufferSpace(&GpuMap->Buffer, VERTS_PER_VOXEL); + cp CollisionCP = SimSpaceToCanonical(World, CollisionP); + v3 RenderMin = GetRenderP(Engine, CollisionCP); + DrawVoxel_MinDim( &VoxMesh, RenderMin, Color, V3(ClosestChunk->DimInChunks)); + } +#endif - break; + v3 Color = RGB_RED; + if (ClosestChunk == Result.Chunks[PickedVoxel_FirstFilled].Chunk) + { + Color = RGB_GREEN; } - else + else if (ClosestChunk == Result.Chunks[PickedVoxel_LastEmpty].Chunk) { - Result.Chunks[PickedVoxel_LastEmpty] = {ClosestChunk, r64(tChunk)}; - Result.Picks[PickedVoxel_LastEmpty] = Canonical_Position(AtP, ClosestChunk->WorldP); + Color = RGB_BLUE; } - AtP.E[AxisIndex] += Advance.E[AxisIndex]; - AxisIndex = (AxisIndex + 1) % 3; + untextured_3d_geometry_buffer Mesh = ReserveBufferSpace(&GpuMap->Buffer, VERTS_PER_AABB); + DEBUG_DrawChunkAABB( &Mesh, Graphics, ClosestChunk, World->ChunkDim, Color, 2.f); + } +#endif + } +#endif return Result; } @@ -4326,7 +4515,7 @@ RayTraceCollision(world_chunk *Chunk, chunk_dimension Dim, v3 StartingP, v3 Ray, } link_internal maybe_picked_voxel -MousePickVoxel(engine_resources *Resources) +MousePickVoxel(engine_resources *Resources, ray *Ray) { TIMED_FUNCTION(); @@ -4334,24 +4523,20 @@ MousePickVoxel(engine_resources *Resources) UNPACK_ENGINE_RESOURCES(Resources); - maybe_ray MaybeRay = Resources->MaybeMouseRay; - if (MaybeRay.Tag == Maybe_Yes) + picked_voxel RayResult = RayTraceCollision(Resources, Ray); + if (octree_node *Node = RayResult.Chunks[PickedVoxel_FirstFilled].Node) { - picked_voxel RayResult = RayTraceCollision( Resources, Camera->CurrentP, MaybeRay.Ray.Dir); - - if (world_chunk *ClosestChunk = RayResult.Chunks[PickedVoxel_FirstFilled].Chunk) - { - v3 MinP = V3(ClosestChunk->WorldP * World->ChunkDim); - v3 VoxelP = MinP + Truncate(RayResult.Picks[PickedVoxel_FirstFilled].Offset); + v3 MinP = V3(Node->WorldP * World->ChunkDim); + v3 VoxelP = MinP + Truncate(RayResult.Picks[PickedVoxel_FirstFilled].Offset); - Result.Tag = Maybe_Yes; - Result.Value = RayResult; - } + Result.Tag = Maybe_Yes; + Result.Value = RayResult; } return Result; } +#if 0 link_internal voxel * TryGetVoxelPointer(world *World, cp Pos) { @@ -4375,21 +4560,27 @@ GetVoxelPointer(picked_voxel *Pick, picked_voxel_position Pos) { voxel *Result = 0; - if (Pick->Chunks[PickedVoxel_FirstFilled].Chunk) + if (Pick->Chunks[PickedVoxel_FirstFilled].Node) { - world_chunk *Chunk = Pick->Chunks[Pos].Chunk; - s32 Index = GetIndex(V3i(Pick->Picks[Pos].Offset), Chunk->Dim); - Result = Chunk->Voxels + Index; + if (auto *Chunk = Pick->Chunks[Pos].Node->Chunk) + { + s32 Index = GetIndex(V3i(Pick->Picks[Pos].Offset), Chunk->Dim); + Result = Chunk->Voxels + Index; + } } return Result; } +#endif link_internal v3 GetAbsoluteP(picked_voxel *Pick) { - world_chunk *Chunk = Pick->Chunks[PickedVoxel_FirstFilled].Chunk; - v3 MinP = V3(Chunk->WorldP * Chunk->Dim); + // NOTE(Jesse): Pretty sure this is buggy + NotImplemented; + + auto *Node = Pick->Chunks[PickedVoxel_FirstFilled].Node->Chunk; + v3 MinP = V3(Node->WorldP * Node->Dim); v3 VoxelP = MinP + Truncate(Pick->Picks[PickedVoxel_FirstFilled].Offset); return VoxelP; } @@ -4464,7 +4655,7 @@ struct renderer_2d; #if 0 link_internal void -PushChunkView(renderer_2d* Group, world_chunk* Chunk, window_layout* Window, render_entity_to_texture_group *PickedChunksRenderGroup) +PushChunkView(renderer_2d* Group, world_chunk* Chunk, window_layout* Window, render_to_texture_group *PickedChunksRenderGroup) { debug_state* DebugState = GetDebugState(); PushWindowStart(Group, Window); @@ -4538,17 +4729,17 @@ PushChunkDetails(renderer_2d* Group, world_chunk* Chunk, window_layout* Window) PushColumn(Group, CS(Chunk->WorldP.z)); PushNewRow(Group); - PushColumn(Group, CSz("PointsToLeaveRemaining")); - PushColumn(Group, CS(Chunk->PointsToLeaveRemaining)); - PushNewRow(Group); + /* PushColumn(Group, CSz("PointsToLeaveRemaining")); */ + /* PushColumn(Group, CS(Chunk->PointsToLeaveRemaining)); */ + /* PushNewRow(Group); */ - PushColumn(Group, CSz("BoundaryVoxels Count")); - PushColumn(Group, CS(Chunk->EdgeBoundaryVoxelCount)); - PushNewRow(Group); + /* PushColumn(Group, CSz("BoundaryVoxels Count")); */ + /* PushColumn(Group, CS(Chunk->EdgeBoundaryVoxelCount)); */ + /* PushNewRow(Group); */ - PushColumn(Group, CSz("Triangles")); - PushColumn(Group, CS(Chunk->TriCount)); - PushNewRow(Group); + /* PushColumn(Group, CSz("Triangles")); */ + /* PushColumn(Group, CS(Chunk->TriCount)); */ + /* PushNewRow(Group); */ PushColumn(Group, CSz("StandingSpots")); PushColumn(Group, CS(AtElements(&Chunk->StandingSpots))); @@ -4558,7 +4749,7 @@ PushChunkDetails(renderer_2d* Group, world_chunk* Chunk, window_layout* Window) } link_internal picked_world_chunk* -DrawPickedChunks(renderer_2d* Group, render_entity_to_texture_group *PickedChunksRenderGroup, picked_world_chunk_static_buffer *PickedChunks, picked_world_chunk *HotChunk) +DrawPickedChunks(renderer_2d* Group, render_to_texture_group *PickedChunksRenderGroup, picked_world_chunk_static_buffer *PickedChunks, picked_world_chunk *HotChunk) { TIMED_FUNCTION(); @@ -4631,14 +4822,14 @@ DrawPickedChunks(renderer_2d* Group, render_entity_to_texture_group *PickedChunk { // Draw hotchunk to the GameGeo FBO - GL.BindFramebuffer(GL_FRAMEBUFFER, PickedChunksRenderGroup->GameGeoFBO.ID); + GetGL()->BindFramebuffer(GL_FRAMEBUFFER, PickedChunksRenderGroup->GameGeoFBO.ID); FlushBuffersToCard(&PickedChunksRenderGroup->GameGeo); PickedChunksRenderGroup->ViewProjection = ProjectionMatrix(PickedChunksRenderGroup->Camera, DEBUG_TEXTURE_DIM, DEBUG_TEXTURE_DIM) * ViewMatrix(ChunkDimension(HotChunk->Chunk), PickedChunksRenderGroup->Camera); - GL.UseProgram(PickedChunksRenderGroup->GameGeoShader.ID); + GetGL()->UseProgram(PickedChunksRenderGroup->GameGeoShader.ID); SetViewport(V2(DEBUG_TEXTURE_DIM, DEBUG_TEXTURE_DIM)); @@ -4663,3 +4854,103 @@ DrawPickedChunks(renderer_2d* Group, render_entity_to_texture_group *PickedChunk } #endif // BONSAI_DEBUG_SYSTEM_API +link_internal u32 +FinalizeOccupancyMasksFromNoiseValues(world_chunk *Chunk, voxel *Voxels, v3i WorldBasis, v3i NoiseDim, u32 *NoiseValues, v3i SrcToDest, s64 zMin) +{ + TIMED_FUNCTION(); + /* HISTOGRAM_FUNCTION(); */ + u32 ChunkSum = 0; + + { + TIMED_NAMED_BLOCK(NoiseFinalize0); + for ( s32 zChunk = 0; zChunk < Chunk->Dim.z; ++ zChunk) + { + for ( s32 yChunk = 0; yChunk < Chunk->Dim.y; ++ yChunk) + { + u64 Mask = 0; + +#pragma unroll(2) + for ( s32 xChunk = 0; xChunk < Chunk->Dim.x; ++ xChunk) + { + /* Assert(xChunk < 64); */ + + v3i NoiseP = V3i(xChunk+1, yChunk, zChunk); + s32 NoiseIndex = GetIndex(NoiseP, NoiseDim); + + u32 ThisNoiseV = NoiseValues[NoiseIndex]; + u64 NoiseChoice = (ThisNoiseV >> 31); + /* Assert(NoiseChoice == 1 || NoiseChoice == 0); */ + + if (NoiseChoice == 1) + { + ChunkSum += NoiseChoice; + Mask |= (NoiseChoice << xChunk); + + v3i ChunkP = V3i(xChunk, yChunk, zChunk); + s32 ChunkIndex = GetIndex(ChunkP, Chunk->Dim); + u32 OccupancyBitMask = ~(1u << 31); + Voxels[ChunkIndex].Data = ThisNoiseV & OccupancyBitMask; + + /* if (GetEngineDebug()->MarkChunkBorderVoxels) */ + /* { */ + /* if (xChunk == 0) { Chunk->Voxels[ChunkIndex].RGBColor = PackV3_16b(RGB_RED)*u16(NoiseChoice); } */ + /* if (yChunk == 1) { Chunk->Voxels[ChunkIndex].RGBColor = PackV3_16b(RGB_PINK)*u16(NoiseChoice); } */ + /* if (zChunk == 1) { Chunk->Voxels[ChunkIndex].RGBColor = PackV3_16b(RGB_BLUE)*u16(NoiseChoice); } */ + /* } */ + } + } + + SetOccupancyMask(Chunk, yChunk + zChunk*Chunk->Dim.y, Mask); + } + } + } + + Assert(NoiseDim.x >= 66); + Assert(NoiseDim.y >= 66); + Assert(NoiseDim.z >= 66); + + Assert(Chunk->Dim.x == 64); + Assert(Chunk->Dim.y == 66); + Assert(Chunk->Dim.z == 66); + + { + TIMED_NAMED_BLOCK(NoiseFinalize1); + + for ( s32 zNoise = 1; zNoise < 65; ++ zNoise) + { + u64 x0Bits = {}; + u64 x1Bits = {}; + for ( s32 yNoise = 1; yNoise < 65; ++ yNoise) + { + + { + v3i BorderP = V3i(0, yNoise, zNoise); + s32 BorderIndex = GetIndex(BorderP, NoiseDim); + + u32 ThisNoiseV = NoiseValues[BorderIndex]; + u64 NoiseChoice = (ThisNoiseV >> 31); + Assert(NoiseChoice == 1 || NoiseChoice == 0); + u64 Bit = NoiseChoice << (yNoise-1); + x0Bits |= Bit; + } + + { + v3i BorderP = V3i(65, yNoise, zNoise); + s32 BorderIndex = GetIndex(BorderP, NoiseDim); + + u32 ThisNoiseV = NoiseValues[BorderIndex]; + u64 NoiseChoice = (ThisNoiseV >> 31); + Assert(NoiseChoice == 1 || NoiseChoice == 0); + u64 Bit = NoiseChoice << (yNoise-1); + x1Bits |= Bit; + } + + } + Chunk->xOccupancyBorder[(zNoise-1)*2] = x0Bits; + Chunk->xOccupancyBorder[((zNoise-1)*2)+1] = x1Bits; + } + } + + return ChunkSum; +} + diff --git a/src/engine/world_chunk.h b/src/engine/world_chunk.h index abbf20fd3..098170ec8 100644 --- a/src/engine/world_chunk.h +++ b/src/engine/world_chunk.h @@ -1,16 +1,16 @@ #define INVALID_WORLD_CHUNK_POSITION (V3i(s32_MAX, s32_MAX, s32_MAX)) -struct world; -struct world_chunk; struct heap_allocator; struct entity; +struct octree_node; + // NOTE(Jesse): Gets casted to sort_key_f, so Chunk and tChunk ahve to be 1st and second, in that order struct picked_world_chunk { - world_chunk *Chunk; - r64 tChunk; + octree_node *Node; + r64 t; }; enum picked_voxel_position @@ -45,12 +45,12 @@ struct picked_world_chunk_static_buffer }; link_internal void -Push(picked_world_chunk_static_buffer *Buf, world_chunk *Chunk, r32 t) +Push(picked_world_chunk_static_buffer *Buf, octree_node *Node, r32 t) { if (Buf->At < MAX_PICKED_WORLD_CHUNKS) { - Buf->E[Buf->At].Chunk = Chunk; - Buf->E[Buf->At].tChunk = r64(t); + Buf->E[Buf->At].Node = Node; + Buf->E[Buf->At].t = r64(t); ++Buf->At; } @@ -68,11 +68,8 @@ enum chunk_flag poof(@bitfield) Chunk_Queued = 1 << 0, Chunk_VoxelsInitialized = 1 << 1, - /* Chunk_MeshUploadedToGpu = 1 << 2, */ - /* Chunk_MeshDirty = 1 << 3, // Re-upload the */ - // This is an optimization to tell the thread queue to not initialize chunks - // we've already moved away from. + // This is an optimization to tell the thread queue to not initialize chunks we've already moved away from. Chunk_Garbage = 1 << 3, // Threads can set this to mark a chunk as ready to deallocate @@ -88,10 +85,11 @@ poof(string_and_value_tables(chunk_flag)) // If we make a mapping between these bit-flags and another face_index enum we // could delete a bit of code. // @duplicate_face_index_enum +#if 0 enum voxel_flag { Voxel_Empty = 0, - Voxel_Filled = 1 << 0, + /* Voxel_Filled = 1 << 0, // NOTE(Jesse): This now lives in the Occupancy buffer */ Voxel_LeftFace = 1 << 1, Voxel_RightFace = 1 << 2, @@ -107,25 +105,23 @@ enum voxel_flag Voxel_MarkBit = 1 << 7, }; CAssert(Voxel_MarkBit < u8_MAX); +#endif -global_variable u8 VoxelFaceMask = Voxel_LeftFace | Voxel_RightFace | Voxel_TopFace | Voxel_BottomFace | Voxel_FrontFace | Voxel_BackFace; - -#define VOXEL_DEBUG_COLOR (0) +/* global_variable u8 VoxelFaceMask = Voxel_LeftFace | Voxel_RightFace | Voxel_TopFace | Voxel_BottomFace | Voxel_FrontFace | Voxel_BackFace; */ // TODO(Jesse): Surely we can compress this.. but do we care? struct voxel { - u8 Flags; - u8 Transparency; - u16 Color; - - /* v3 Derivs; */ -#if VOXEL_DEBUG_COLOR - v3 DebugColor; poof(@no_serialize) - f32 DebugNoiseValue; poof(@no_serialize) -#endif + union poof(@no_serialize) + { + u32 Data; + struct + { + u16 RGBColor; + u16 Normal; + }; + }; }; -/* CAssert(sizeof(voxel) == 8); */ struct voxel_lighting { @@ -135,27 +131,11 @@ struct voxel_lighting poof(gen_constructor(voxel_lighting)) #include -#if 0 -link_internal b32 -IsValid(voxel *V) -{ - b32 Result = (V->Flags & Voxel_INVALID_BIT) == 0; - if (V->Flags & Voxel_Filled) - { - Result &= (V->Flags & Voxel_INVALID_BIT) == 0; - } - else - { - Result &= (V->Flags & VoxelFaceMask) == 0; - } - return Result; -} -#endif - b32 -operator ==(voxel &V1, voxel &V2) +operator==(voxel &V1, voxel &V2) { - b32 Result = V1.Flags == V2.Flags && V1.Color == V2.Color; + /* b32 Result = V1.Transparency == V2.Transparency && V1.RGBColor == V2.RGBColor; */ + b32 Result = V1.RGBColor == V2.RGBColor; return Result; } @@ -177,10 +157,10 @@ struct boundary_voxel this->Offset.y = y; this->Offset.z = z; - this->V.Color = w; + this->V.RGBColor = w; - this->V.Flags = Voxel_Empty; - this->V.Transparency = 0; + /* this->V.Flags = Voxel_Empty; */ + /* this->V.Transparency = 0; */ } boundary_voxel(voxel *V_in, voxel_position Offset_in) @@ -190,12 +170,19 @@ struct boundary_voxel } }; +// 2 planar slices (1 bit per slice), each bit corresponds to a y index (64 y indices), 66 z slices +#define xOccupancyBorder_Dim V3i(2, 1, 66) +#define xOccupancyBorder_ElementCount Volume(xOccupancyBorder_Dim) + struct chunk_data { - chunk_flag Flags; + /* chunk_flag Flags; */ v3i Dim; // TODO(Jesse): can (should?) be 3x u8 instead of 3x s32 - voxel *Voxels; - voxel_lighting *VoxelLighting; + u64 *Occupancy; + u64 *xOccupancyBorder; // [xOccupancyBorder_ElementCount]; + u64 *FaceMasks; + /* voxel *Voxels; */ + /* voxel_lighting *VoxelLighting; */ }; poof(maybe(chunk_data)) @@ -325,8 +312,9 @@ poof( struct entity; typedef entity* entity_ptr; -poof( block_array(entity_ptr, {8}) ) -#include +poof( block_array_h(entity_ptr, {8}, {}) ) +#include + struct world_chunk poof(@version(1)) { @@ -335,62 +323,65 @@ struct world_chunk poof(@version(1)) world_chunk *Next; poof(@no_serialize) // 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)))) + /* chunk_flag Flags; poof(@no_serialize) */ + v3i Dim; // could/should be compressed? + u64 *Occupancy; + u64 *xOccupancyBorder; // [xOccupancyBorder_ElementCount]; + u64 *FaceMasks; + /* voxel *Voxels; poof(@array_length( Cast(umm, Volume(Element->Dim)))) */ + /* voxel_lighting *VoxelLighting; poof(@array_length( Cast(umm, Volume(Element->Dim)))) */ // } + b32 IsOnFreelist; - // 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. - lod_element_buffer Meshes; poof(@no_serialize) - - /* threadsafe_geometry_buffer TransparentMeshes; */ - /* gpu_mapped_element_buffer GpuBuffers[MeshIndex_Count]; */ + gpu_element_buffer_handles Handles; poof(@no_serialize) + /* gpu_mapped_element_buffer Mesh; poof(@no_serialize) */ voxel_position_cursor StandingSpots; poof(@no_serialize) - v3i WorldP; + // TODO(Jesse): Rename + v3i DimInChunks; + /* v3i Resolution; */ - s32 FilledCount; poof(@no_serialize) - b32 DrawBoundingVoxels; poof(@no_serialize) - - s32 PointsToLeaveRemaining; poof(@no_serialize) - u32 TriCount; poof(@no_serialize) - s32 EdgeBoundaryVoxelCount; poof(@no_serialize) + v3i WorldP = INVALID_WORLD_CHUNK_POSITION; - u32 _Pad0; poof(@no_serialize) + s32 FilledCount; 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; poof(@no_serialize) +}; - // TODO(Jesse): Probably take this out? - s32 DEBUG_OwnedByThread; poof(@no_serialize) +struct gen_chunk +{ + // TODO(Jesse): Remove somehow ..? + gen_chunk *Next; -#if VOXEL_DEBUG_COLOR - f32 *NoiseValues; poof(@no_serialize @array_length(Volume(Element->Dim))) - v3 *NormalValues; poof(@no_serialize @array_length(Volume(Element->Dim))) - u8 _Pad1[16]; poof(@no_serialize) -#else - u8 _Pad1[28]; poof(@no_serialize) -#endif + world_chunk Chunk; + voxel *Voxels; + gpu_mapped_element_buffer Mesh; }; + + // TODO(Jesse, id: 87, tags: speed, cache_friendly): Re-enable this +// // @world-chunk-cache-line-size /* CAssert(sizeof(world_chunk) == CACHE_LINE_SIZE); */ // TODO(Jesse, id: 87, tags: speed, cache_friendly): Re-enable this // @world-chunk-cache-line-size -CAssert(sizeof(chunk_data) == 32); +/* CAssert(sizeof(chunk_data) == 32); */ /* CAssert(sizeof(threadsafe_geometry_buffer) == 112); */ CAssert(sizeof(voxel_position_cursor) == 24); /* CAssert(sizeof(world_chunk) == 32 + 112 + 24 + 48 + 40); */ /* CAssert(sizeof(world_chunk) % CACHE_LINE_SIZE == 0); */ +b32 IsAllocated(world_chunk *Chunk) +{ + b32 Result = Volume(Chunk->Dim) > 0; + return Result; +} @@ -401,7 +392,7 @@ struct world_chunk_0 world_chunk *Next; poof(@no_serialize) // chunk_data { - chunk_flag Flags; poof(@no_serialize) + /* chunk_flag Flags; poof(@no_serialize) */ v3i Dim; // could be compressed? voxel *Voxels; poof(@custom_marshal(MarshalMagicaVoxelEncodedColors(Stored->Voxels, Live->Voxels, Stored->Dim);) @array_length( Cast(umm, Volume(Element->Dim)))) @@ -420,7 +411,7 @@ struct world_chunk_0 voxel_position_cursor StandingSpots; poof(@no_serialize) - v3i WorldP; + v3i WorldP = INVALID_WORLD_CHUNK_POSITION; s32 FilledCount; poof(@no_serialize) b32 DrawBoundingVoxels; poof(@no_serialize) @@ -438,13 +429,7 @@ struct world_chunk_0 // TODO(Jesse): Probably take this out? s32 DEBUG_OwnedByThread; poof(@no_serialize) -#if VOXEL_DEBUG_COLOR - f32 *NoiseValues; poof(@no_serialize @array_length(Volume(Element->Dim))) - v3 *NormalValues; poof(@no_serialize @array_length(Volume(Element->Dim))) - u8 _Pad1[16]; poof(@no_serialize) -#else u8 _Pad1[28]; poof(@no_serialize) -#endif }; @@ -485,32 +470,6 @@ Volume(world_chunk* Chunk) return Result; } -enum world_flag -{ - WorldFlag_noop, - /* WorldFlag_WorldCenterFollowsCameraTarget = (1 << 0), */ -}; - -struct world -{ - v3i Center; - v3i VisibleRegion; // The number of chunks in xyz we're going to update and render - - u32 HashSlotsUsed; - u32 HashSize; - world_chunk **ChunkHashMemory[2]; poof(@ui_skip) - world_chunk **ChunkHash; poof(@array_length(Element->HashSize)) - - - bonsai_futex ChunkFreelistFutex; poof(@ui_skip) - world_chunk ChunkFreelistSentinal; poof(@ui_skip) - s32 FreeChunkCount; - - v3i ChunkDim; poof(@ui_skip) - memory_arena *ChunkMemory; poof(@ui_skip) - world_flag Flags; poof(@ui_skip) -}; - struct standing_spot { b32 CanStand; @@ -539,22 +498,6 @@ Canonical_Position(picked_voxel *V, picked_voxel_position Pos = PickedVoxel_Firs return Result; } -inline canonical_position -Canonicalize( world *World, canonical_position CP ) -{ - canonical_position Result = Canonicalize( World->ChunkDim, CP.Offset, CP.WorldP ); - return Result; -} - -// NOTE(Jesse): Technically, these should always be strictly less than the chunkdim, -// but because of float-ness we can actually hit directly on it. -inline b32 -IsCanonical( world *World, canonical_position CP ) -{ - b32 Result = CP.Offset <= V3(World->ChunkDim); - return Result; -} - inline b32 IsCanonical( v3i WorldChunkDim, canonical_position CP ) { @@ -572,61 +515,6 @@ poof(generate_stream(standing_spot)) poof(generate_stream_compact(standing_spot)) #include -link_internal v3 -GetSimSpaceP(world *World, world_position P) -{ - v3i CenterToP = P - World->Center; - v3 Result = V3(CenterToP*World->ChunkDim); - return Result; -} - -link_internal v3 -GetSimSpaceP(world *World, canonical_position P) -{ - cp WorldCenter = Canonical_Position(V3(0), World->Center); - cp CenterToP = P - WorldCenter; - v3 Result = CenterToP.Offset + (CenterToP.WorldP*World->ChunkDim); - return Result; -} - -link_internal v3 -GetSimSpaceP(world *World, picked_voxel *P, picked_voxel_position Pos = PickedVoxel_FirstFilled) -{ - v3 Result = GetSimSpaceP(World, Canonical_Position(P, Pos)); - return Result; -} - -link_internal v3i -GetSimSpacePi(world *World, world_chunk *Chunk) -{ - world_position CenterToP = Chunk->WorldP - World->Center; - v3i Result = CenterToP*World->ChunkDim; - return Result; -} - -link_internal v3 -GetSimSpaceP(world *World, world_chunk *Chunk) -{ - v3 Result = V3(GetSimSpacePi(World, Chunk)); - return Result; -} - -link_internal rect3i -GetSimSpaceAABBi(world *World, world_chunk *Chunk) -{ - v3i SimSpaceMin = GetSimSpacePi(World, Chunk); - rect3i Result = Rect3iMinDim(SimSpaceMin, World->ChunkDim ); - return Result; -} - -link_internal aabb -GetSimSpaceAABB(world *World, world_chunk *Chunk) -{ - v3 SimSpaceMin = GetSimSpaceP(World, Chunk); - aabb Result = AABBMinDim(SimSpaceMin, V3(World->ChunkDim) ); - return Result; -} - inline bool IsRightChunkBoundary( chunk_dimension ChunkDim, int idx ) { @@ -651,6 +539,8 @@ IsBottomChunkBoundary( chunk_dimension ChunkDim, int idx ) return (idx/(int)ChunkDim.x) % (int)ChunkDim.y == 0; } + + global_variable v3i Global_StandingSpotDim = V3i(8,8,3); global_variable v3 Global_StandingSpotHalfDim = Global_StandingSpotDim/2.f; @@ -668,34 +558,13 @@ global_variable v3i Global_ChunkApronMaxDim = V3i(1,1,3); /* CAssert(Global_ChunkApronDim.z == Global_ChunkApronMinDim.z + Global_ChunkApronMaxDim.z); */ -link_internal v3 -GetSimSpaceCenterP(world *World, standing_spot *Spot) -{ - v3 Result = GetSimSpaceP(World, Spot->P) + Global_StandingSpotHalfDim; - return Result; -} - -link_internal v3 -GetSimSpaceBaseP(world *World, standing_spot *Spot) -{ - v3 Result = GetSimSpaceP(World, Spot->P) + V3(Global_StandingSpotHalfDim.xy, 0.f); - return Result; -} - -link_internal cp -GetSpotMidpoint(world *World, standing_spot *Spot) -{ - cp Result = Canonical_Position(World->ChunkDim, Spot->P.Offset+Global_StandingSpotHalfDim, Spot->P.WorldP); - return Result; -} - struct mesh_freelist; link_internal void -AllocateWorldChunk(world_chunk *Result, world_position WorldP, chunk_dimension Dim, memory_arena *Storage); +AllocateWorldChunk(world_chunk *Result, v3i WorldP, v3i Dim, v3i DimInChunks, memory_arena *Storage); link_internal world_chunk * -AllocateWorldChunk(world_position WorldP, chunk_dimension Dim, memory_arena *Storage); +AllocateWorldChunk(v3i WorldP, v3i Dim, v3i DimInChunks, memory_arena *Storage); link_internal void BufferWorld(platform* Plat, untextured_3d_geometry_buffer*, untextured_3d_geometry_buffer*, world* World, graphics *Graphics, heap_allocator *Heap); @@ -706,14 +575,14 @@ BufferWorld(platform* Plat, untextured_3d_geometry_buffer*, untextured_3d_geomet link_internal untextured_3d_geometry_buffer* GetMeshForChunk(mesh_freelist* Freelist, u32 Mesh, memory_arena* PermMemory); -link_internal untextured_3d_geometry_buffer * -ReplaceMesh(lod_element_buffer *, world_chunk_mesh_bitfield , untextured_3d_geometry_buffer *, u64 ); +/* link_internal untextured_3d_geometry_buffer * */ +/* ReplaceMesh(lod_element_buffer *, world_chunk_mesh_bitfield , untextured_3d_geometry_buffer *, u64 ); */ /* link_internal untextured_3d_geometry_buffer * */ /* ReplaceMesh(threadsafe_geometry_buffer *, world_chunk_mesh_bitfield , untextured_3d_geometry_buffer *, u64 ); */ -link_internal untextured_3d_geometry_buffer * -AtomicReplaceMesh(lod_element_buffer *, world_chunk_mesh_bitfield , untextured_3d_geometry_buffer *, u64 ); +/* link_internal untextured_3d_geometry_buffer * */ +/* AtomicReplaceMesh(lod_element_buffer *, world_chunk_mesh_bitfield , untextured_3d_geometry_buffer *, u64 ); */ /* link_internal untextured_3d_geometry_buffer * */ /* AtomicReplaceMesh(threadsafe_geometry_buffer *, world_chunk_mesh_bitfield , untextured_3d_geometry_buffer *, u64 ); */ @@ -733,8 +602,8 @@ MapIntoQueryBox(v3i SimSpaceVoxP, v3i SimSpaceQueryMinP, voxel_position SimSpace link_internal world_chunk* GetWorldChunkFromHashtable(world *World, world_position P); -link_internal world_chunk_ptr_buffer -GatherChunksOverlappingArea(world *World, rect3cp Region, memory_arena *Memory); +/* link_internal octree_node_ptr_buffer */ +/* GatherChunksOverlappingArea(world *World, rect3cp Region, memory_arena *Memory); */ link_internal standing_spot_buffer GetStandingSpotsWithinRadius_FilteredByStandable(world *World, canonical_position P, r32 GatherRadius, v3 EntityRadius, memory_arena *Memory); @@ -742,25 +611,7 @@ GetStandingSpotsWithinRadius_FilteredByStandable(world *World, canonical_positio /* link_internal untextured_3d_geometry_buffer * */ /* SetMesh(world_chunk *Chunk, world_chunk_mesh_bitfield MeshBit, mesh_freelist *MeshFreelist, memory_arena *PermMemory); */ -link_internal rect3i -GetVisibleRegionRect(world *World) -{ - world_position CenterP = World->Center; - chunk_dimension Radius = (World->VisibleRegion/2); - world_position Min = CenterP - Radius; - world_position Max = CenterP + Radius + 1; // Add one so we can pass to functions that expect an open-interval - - return RectMinMax(Min, Max); -} - -link_internal b32 -IsInsideVisibleRegion(world *World, v3i P) -{ - rect3i VRRect = GetVisibleRegionRect(World); - b32 Result = IsInside(P, VRRect); - return Result; -} - +#if 0 inline voxel* TryGetVoxel(world_chunk* Chunk, voxel_position VoxelP) { @@ -777,18 +628,7 @@ GetVoxel(world_chunk* Chunk, voxel_position VoxelP) voxel *Result = Chunk->Voxels + VoxelIndex; return Result; } - -inline voxel* -TryGetVoxel(world *World, cp P) -{ - voxel *Result = {}; - world_chunk *Chunk = GetWorldChunkFromHashtable(World, P.WorldP); - if (Chunk) - { - Result = TryGetVoxel(Chunk, V3i(P.Offset)); - } - return Result; -} +#endif link_internal void MarshalMagicaVoxelEncodedColors(voxel *Src, voxel *Dest, v3i Dim) @@ -797,24 +637,42 @@ MarshalMagicaVoxelEncodedColors(voxel *Src, voxel *Dest, v3i Dim) RangeIterator(Index, Max) { Dest[Index] = Src[Index]; - Dest[Index].Color = PackHSVColor(MagicaVoxelDefaultPaletteToHSV(Src[Index].Color)); + Dest[Index].RGBColor = PackV3_16b(MagicaVoxelDefaultPaletteToRGB(Src[Index].RGBColor)); } } +struct octree_node; +struct octree_stats; +struct octree_node_priority_queue; + 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 ); +MarkBoundaryVoxels_MakeExteriorFaces(u64 *Occupancy, 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 */ +/* 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); +FinalizeNodeInitializaion(octree_node *Chunk); link_internal untextured_3d_geometry_buffer* AllocateTempMesh(memory_arena* TempMemory, data_type Type); + + +struct work_queue_entry_finalize_noise_values; +struct gpu_readback_buffer; + +link_internal work_queue_entry_finalize_noise_values +WorkQueueEntryBuildChunkMesh(gpu_readback_buffer PBOBuf, f32 *NoiseData, v3i NoiseDim, world_chunk *Chunk); + +inline void +QueueChunkForInit(work_queue *Queue, octree_node *Node, world_chunk_mesh_bitfield MeshBit); + +link_internal b32 +HasGpuMesh(world_chunk *Chunk); + diff --git a/src/engine/world_update.cpp b/src/engine/world_update.cpp index e49195512..6d21cf83e 100644 --- a/src/engine/world_update.cpp +++ b/src/engine/world_update.cpp @@ -1,168 +1,16 @@ -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, + world_edit_blend_mode Mode, + world_edit_blend_mode_modifier Modifier, + /* world_edit_shape *Shape, */ v3 HSVColor, b32 PersistWhitespace, memory_arena *Memory ) { TIMED_FUNCTION(); + NotImplemented; +#if 0 // TODO(Jesse): Should we just remove the paramter? Or do we sometimes not pass this? Assert(Memory == Engine->WorldUpdateMemory); @@ -304,6 +152,7 @@ QueueWorldUpdateForRegion( engine_resources *Engine, }; PushWorkQueueEntry(&Plat->WorldUpdateQ, &Entry); } +#endif } link_internal u32 @@ -326,7 +175,8 @@ MapIntoQueryBox(v3 SimSpaceVoxP, v3 UpdateMinP, v3i UpdateDim) link_internal void DEBUG_AssertVoxelFloodStartsInEmptyVoxel(v3i SimSphereP, rect3i *SimSpaceUpdateBounds, voxel *CopiedVoxels) { -#if 1 + NotImplemented; +#if 0 #if BONSAI_INTERNAL v3i UpdateDim = GetDim(*SimSpaceUpdateBounds); @@ -359,93 +209,99 @@ poof( { 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; + NotImplemented; - 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; - } - } - } + 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) */ + /* { */ + /* NotImplemented; */ + /* /1* if ( (V->Flags & Voxel_MarkBit) == 0) *1/ */ + /* { */ + /* 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) */ + + /* NotImplemented; */ + /* /1* V->Flags |= Voxel_MarkBit; *1/ */ + + /* if ( ((OverwriteVoxel == True) && (Invert == False)) || */ + /* ((OverwriteVoxel == False) && (Invert == True)) ) */ + /* { */ + /* /1* if (Mode == WorldEdit_Mode_Paint) *1/ */ + /* /1* { *1/ */ + /* /1* V->Color = NewVoxelValue->Color; *1/ */ + /* /1* } *1/ */ + /* /1* else *1/ */ + /* { */ + /* *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) */ + + /* NotImplemented; */ + /* /1* if ( (V->Flags&Voxel_MarkBit)) *1/ */ + /* { */ + /* 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)); */ + /* } */ + + /* NotImplemented; */ + /* /1* V->Flags &= ~Voxel_MarkBit; *1/ */ + /* } */ + /* } */ + /* } */ } ) @@ -453,44 +309,48 @@ poof( 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); - } - } - } + NotImplemented; + /* 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 )) ) */ + /* { */ + /* /1* if (Mode == WorldEdit_Mode_Paint) *1/ */ + /* /1* { *1/ */ + /* /1* V->Color = NewVoxelValue->Color; *1/ */ + /* /1* } *1/ */ + /* /1* else *1/ */ + /* { */ + /* if (Mode == WorldEdit_Mode_Subtractive) { *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. */ + /* NotImplemented; */ + /* /1* V->Flags = voxel_flag(V->Flags&~VoxelFaceMask); *1/ */ + /* } */ + /* } */ + /* } */ } ) // TODO(Jesse): Make this not a macro. -#define poof_check_for_unfilled_border() \ +#define poof_check_for_unfilled_border() NotImplemented + +#if 0 { \ if (voxel *Vn = TryGetVoxel(CopiedChunk, VoxP + V3(1,0,0))) \ { \ @@ -518,7 +378,8 @@ poof( { \ if ((Vn->Flags&VoxelFaceMask)) { IsUnfilledBorder = True; } \ } \ - } \ + } +#endif #if 0 poof( @@ -571,20 +432,22 @@ link_internal void WorldEdit_shape_sphere_Surface(apply_world_edit_params *Params, r32 RadiusSquared, v3i EditCenterP, voxel *NewVoxelValue) { UNPACK_APPLY_WORLD_EDIT_PARAMS(Params); +#if 0 switch (Mode) { case WorldEdit_Mode_Disabled: {} break; - case WorldEdit_Mode_Attach: + case WorldEdit_Mode_Additive: { poof(rectalinear_iteration_pattern({ v3i CenterToVoxP = SimVoxP - EditCenterP; - if (LengthSq(CenterToVoxP) < RadiusSquared && (V->Flags&Voxel_Filled) == False) + NotImplemented; + /* if (LengthSq(CenterToVoxP) < RadiusSquared && (V->Flags&Voxel_Filled) == False) */ { b32 IsUnfilledBorder = False; - poof_check_for_unfilled_border() - Assert(NewVoxelValue->Flags & Voxel_Filled); + poof_check_for_unfilled_border(); + /* Assert(NewVoxelValue->Flags & Voxel_Filled); */ if (IsUnfilledBorder) { OverwriteVoxel = True; @@ -594,12 +457,13 @@ WorldEdit_shape_sphere_Surface(apply_world_edit_params *Params, r32 RadiusSquare #include } break; - case WorldEdit_Mode_Paint: - case WorldEdit_Mode_Remove: + /* case WorldEdit_Mode_Paint: */ + case WorldEdit_Mode_Subtractive: { poof(rectalinear_iteration_pattern({ v3i CenterToVoxP = SimVoxP - EditCenterP; - if (LengthSq(CenterToVoxP) < RadiusSquared && (V->Flags&VoxelFaceMask)) + NotImplemented; + /* if (LengthSq(CenterToVoxP) < RadiusSquared && (V->Flags&VoxelFaceMask)) */ { OverwriteVoxel = True; } @@ -607,6 +471,7 @@ WorldEdit_shape_sphere_Surface(apply_world_edit_params *Params, r32 RadiusSquare #include } break; } +#endif } link_internal void @@ -615,29 +480,33 @@ WorldEdit_shape_sphere_Flood(apply_world_edit_params *Params, thread_local_state UNPACK_APPLY_WORLD_EDIT_PARAMS(Params); s32 TotalVoxels = Volume(UpdateDim); - Assert(Params->Mode == WorldEdit_Mode_Remove); + Assert(Params->Mode == WorldEdit_Mode_Subtractive); poof(flood_fill_iteration_pattern( { - if (LengthSq(CenterToVoxP) < RadiusSquared && (V->Flags&Voxel_Filled) == 0) + NotImplemented; + /* if (LengthSq(CenterToVoxP) < RadiusSquared && (V->Flags&Voxel_Filled) == 0) */ }, { - if ( Length(CenterToVoxP) < SquareRoot(RadiusSquared)-1.f && (V->Flags&Voxel_Filled) ) - { V->Flags = Voxel_Empty; } + NotImplemented; + /* 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) + NotImplemented; + /* if (V->Flags & Voxel_Filled) */ { - V->Color = MagicaVoxelDefaultPaletteToPackedHSV(SafeTruncateU8(RandomBetween((u32)MCV_GREY_5, &ColorEntropy, (u32)MCV_GREY_8+1))); + /* V->RGBColor = MagicaVoxelDefaultPaletteToPackedRGB(SafeTruncateU8(RandomBetween((u32)MCV_GREY_5, &ColorEntropy, (u32)MCV_GREY_8+1))); */ } } else if (LengthSq(CenterToVoxP) < RadiusSquared) { - V->Color = MagicaVoxelDefaultPaletteToPackedHSV(MCV_GREY_8); + NotImplemented; + /* V->RGBColor = MagicaVoxelDefaultPaletteToPackedRGB(MCV_GREY_8); */ } } )) @@ -671,19 +540,22 @@ WorldEdit_shape_rect_Surface(apply_world_edit_params *Params, voxel *NewVoxelVal { UNPACK_APPLY_WORLD_EDIT_PARAMS(Params); +#if 0 switch (Mode) { case WorldEdit_Mode_Disabled: {} break; - case WorldEdit_Mode_Attach: + case WorldEdit_Mode_Additive: { poof(rectalinear_iteration_pattern({ - if ((V->Flags&Voxel_Filled) == False) + NotImplemented; + /* if ((V->Flags&Voxel_Filled) == False) */ { b32 IsUnfilledBorder = False; - poof_check_for_unfilled_border() - Assert(NewVoxelValue->Flags & Voxel_Filled); + poof_check_for_unfilled_border(); + NotImplemented; + /* Assert(NewVoxelValue->Flags & Voxel_Filled); */ if (IsUnfilledBorder) { OverwriteVoxel = True; @@ -693,11 +565,12 @@ WorldEdit_shape_rect_Surface(apply_world_edit_params *Params, voxel *NewVoxelVal #include } break; - case WorldEdit_Mode_Paint: - case WorldEdit_Mode_Remove: + /* case WorldEdit_Mode_Paint: */ + case WorldEdit_Mode_Subtractive: { poof(rectalinear_iteration_pattern({ - if ( (V->Flags&VoxelFaceMask)) + NotImplemented; + /* if ( (V->Flags&VoxelFaceMask)) */ { OverwriteVoxel = True; } @@ -705,6 +578,7 @@ WorldEdit_shape_rect_Surface(apply_world_edit_params *Params, voxel *NewVoxelVal #include } break; } +#endif } link_internal void @@ -713,20 +587,25 @@ WorldEdit_shape_rect_Flood( apply_world_edit_params *Params, thread_local_state UNPACK_APPLY_WORLD_EDIT_PARAMS(Params); s32 TotalVoxels = Volume(UpdateDim); +#if 0 switch (Mode) { case WorldEdit_Mode_Disabled: {} break; - case WorldEdit_Mode_Paint: - case WorldEdit_Mode_Attach: - case WorldEdit_Mode_Remove: + /* case WorldEdit_Mode_Paint: */ + case WorldEdit_Mode_Additive: + case WorldEdit_Mode_Subtractive: { 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 + NotImplemented; + /* { if ( (V->Flags&Voxel_Filled) == (Voxel_Filled*(Mode==WorldEdit_Mode_Additive)) ) }, */ + }, + { + NotImplemented; + /* if ( Mode == WorldEdit_Mode_Additive && (V->Flags&Voxel_Filled) ) */ + /* { } */ + /* else */ { OverwriteVoxel = True; } @@ -736,17 +615,19 @@ WorldEdit_shape_rect_Flood( apply_world_edit_params *Params, thread_local_state #include } break; } +#endif } link_internal void WorldEdit_shape_rect_Default(apply_world_edit_params *Params, voxel *NewVoxelValue) { UNPACK_APPLY_WORLD_EDIT_PARAMS(Params); +#if 0 switch (Mode) { case WorldEdit_Mode_Disabled: {} break; - case WorldEdit_Mode_Attach: - case WorldEdit_Mode_Remove: + case WorldEdit_Mode_Additive: + case WorldEdit_Mode_Subtractive: { poof(rectalinear_iteration_pattern({ OverwriteVoxel = True; @@ -754,17 +635,19 @@ WorldEdit_shape_rect_Default(apply_world_edit_params *Params, voxel *NewVoxelVal #include } break; - case WorldEdit_Mode_Paint: - { - poof(rectalinear_iteration_pattern({ - if (V->Flags & Voxel_Filled) - { - OverwriteVoxel = True; - } - })) -#include - } break; + /* case WorldEdit_Mode_Paint: */ + /* { */ + /* poof(rectalinear_iteration_pattern({ */ + /* NotImplemented; */ + /* /1* if (V->Flags & Voxel_Filled) *1/ */ + /* { */ + /* OverwriteVoxel = True; */ + /* } */ + /* })) */ +/* #include */ + /* } break; */ } +#endif } @@ -783,21 +666,23 @@ WorldEdit_shape_chunk_data_Surface(apply_world_edit_params *Params, v3 SimOrigin { UNPACK_APPLY_WORLD_EDIT_PARAMS(Params); +#if 0 switch (Mode) { case WorldEdit_Mode_Disabled: {} break; - case WorldEdit_Mode_Attach: + case WorldEdit_Mode_Additive: { poof(rectalinear_iteration_pattern({ v3i OriginToCurrentVoxP = SimVoxP - SimOrigin; voxel *NewVoxelValue = TryGetVoxel(Data, OriginToCurrentVoxP); - if ((V->Flags&Voxel_Filled)==False) + NotImplemented; + /* if ((V->Flags&Voxel_Filled)==False) */ { b32 IsUnfilledBorder = False; - poof_check_for_unfilled_border() + poof_check_for_unfilled_border(); if (IsUnfilledBorder) { OverwriteVoxel = True; @@ -807,15 +692,16 @@ WorldEdit_shape_chunk_data_Surface(apply_world_edit_params *Params, v3 SimOrigin #include } break; - case WorldEdit_Mode_Paint: - case WorldEdit_Mode_Remove: + /* case WorldEdit_Mode_Paint: */ + case WorldEdit_Mode_Subtractive: { poof(rectalinear_iteration_pattern({ v3i OriginToCurrentVoxP = SimVoxP - SimOrigin; voxel *NewVoxelValue = TryGetVoxel(Data, OriginToCurrentVoxP); if (NewVoxelValue) { - if ( (V->Flags&VoxelFaceMask) && (NewVoxelValue->Flags&Voxel_Filled) ) + NotImplemented; + /* if ( (V->Flags&VoxelFaceMask) && (NewVoxelValue->Flags&Voxel_Filled) ) */ { OverwriteVoxel = True; } @@ -824,6 +710,7 @@ WorldEdit_shape_chunk_data_Surface(apply_world_edit_params *Params, v3 SimOrigin #include } break; } +#endif } link_internal void @@ -836,52 +723,59 @@ WorldEdit_shape_chunk_data_Flood( UNPACK_APPLY_WORLD_EDIT_PARAMS(Params); s32 TotalVoxels = Volume(UpdateDim); +#if 0 switch (Mode) { case WorldEdit_Mode_Disabled: {} break; - case WorldEdit_Mode_Attach: + case WorldEdit_Mode_Additive: { poof(flood_fill_iteration_pattern( { v3i OriginToCurrentVoxP = SimVoxP - SimOrigin; voxel *NewVoxelValue = TryGetVoxel(Data, OriginToCurrentVoxP); - if ((V->Flags&Voxel_Filled)) + NotImplemented; + /* if ((V->Flags&Voxel_Filled)) */ }, { - if ( ((V->Flags&Voxel_Filled) == 0) && NewVoxelValue && (NewVoxelValue->Flags&Voxel_Filled)) { *V = *NewVoxelValue; } + NotImplemented; + /* if ( ((V->Flags&Voxel_Filled) == 0) && NewVoxelValue && (NewVoxelValue->Flags&Voxel_Filled)) { *V = *NewVoxelValue; } */ }, {} )) #include } break; - case WorldEdit_Mode_Remove: + case WorldEdit_Mode_Subtractive: { poof(flood_fill_iteration_pattern( { v3i OriginToCurrentVoxP = SimVoxP - SimOrigin; voxel *NewVoxelValue = TryGetVoxel(Data, OriginToCurrentVoxP); - if (Contains(SSRect, SimVoxP) && (V->Flags&Voxel_Filled) == 0) + NotImplemented; + /* if (Contains(SSRect, SimVoxP) && (V->Flags&Voxel_Filled) == 0) */ }, { - if (NewVoxelValue && (NewVoxelValue->Flags&Voxel_Filled)) { *V = {}; } + NotImplemented; + /* 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; + /* case WorldEdit_Mode_Paint: */ + /* { */ + /* poof(rectalinear_iteration_pattern({ */ + /* v3i OriginToCurrentVoxP = SimVoxP - SimOrigin; */ + /* voxel *NewVoxelValue = TryGetVoxel(Data, OriginToCurrentVoxP); */ + /* NotImplemented; */ + /* /1* if (NewVoxelValue && (NewVoxelValue->Flags&Voxel_Filled)) { V->Color = NewVoxelValue->Color; } *1/ */ + /* })) */ +/* #include */ + /* } break; */ } +#endif } link_internal void @@ -889,21 +783,24 @@ WorldEdit_shape_chunk_data_Default(apply_world_edit_params *Params, v3 SimOrigin { UNPACK_APPLY_WORLD_EDIT_PARAMS(Params); - voxel InvertV = { Voxel_Filled, Params->Transparency, Params->Color }; + NotImplemented; +#if 0 + voxel InvertV = { Params->Transparency, Params->Color, 0xffff }; switch (Mode) { case WorldEdit_Mode_Disabled: {} break; - case WorldEdit_Mode_Paint: - case WorldEdit_Mode_Attach: - case WorldEdit_Mode_Remove: + /* case WorldEdit_Mode_Paint: */ + case WorldEdit_Mode_Additive: + case WorldEdit_Mode_Subtractive: { poof(rectalinear_iteration_pattern({ v3i OriginToCurrentVoxP = SimVoxP - SimOrigin; voxel *AssetV = TryGetVoxel(Data, OriginToCurrentVoxP); voxel *NewVoxelValue = &InvertV; - if ( (AssetV && (AssetV->Flags&Voxel_Filled)) || Params->PersistWhitespace ) + NotImplemented; + /* if ( (AssetV && (AssetV->Flags&Voxel_Filled)) || Params->PersistWhitespace ) */ { NewVoxelValue = AssetV; OverwriteVoxel = True; @@ -912,39 +809,38 @@ WorldEdit_shape_chunk_data_Default(apply_world_edit_params *Params, v3 SimOrigin #include } break; } +#endif } +#if 0 link_internal void ApplyUpdateToRegion(thread_local_state *Thread, work_queue_entry_update_world_region *Job, rect3i SimSpaceUpdateBounds, world_chunk *CopiedChunk, b32 Invert /* = False */, b32 PersistWhitespace /* = False */ ) { world *World = GetWorld(); + NotImplemented; 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_blend_mode Mode = Job->Brush.Mode; + world_edit_blend_mode_modifier Modifier = Job->Brush.Modifier; world_edit_shape Shape = Job->Brush.Shape; /* v3i FloodOrigin = V3i(Job->Brush.SimFloodOrigin); */ - u16 NewColor = PackHSVColor(Job->HSVColor); + u16 NewColor = PackV3_16b(Job->HSVColor); u8 NewTransparency = Job->Transparency; voxel _NewVoxelValue = {}; voxel *NewVoxelValue = &_NewVoxelValue; - if (Mode == WorldEdit_Mode_Attach || Mode == WorldEdit_Mode_Paint) + if (Mode == WorldEdit_Mode_Additive) // || Mode == WorldEdit_Mode_Paint) { -#if VOXEL_DEBUG_COLOR - _NewVoxelValue = { Voxel_Filled, NewTransparency, NewColor, {}, {}}; -#else - _NewVoxelValue = { Voxel_Filled, NewTransparency, NewColor}; -#endif + _NewVoxelValue = { NewTransparency, NewColor}; } switch (Shape.Type) @@ -975,16 +871,16 @@ ApplyUpdateToRegion(thread_local_state *Thread, work_queue_entry_update_world_re WorldEdit_shape_sphere_Default(&Params, RadiusSquared, EditCenterP, NewVoxelValue); } break; - case WorldEdit_Modifier_Surface: + case WorldEdit_ValueModifier_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; + /* case WorldEdit_Modifier_Flood: */ + /* { */ + /* v3i FloodOrigin = EditCenterP; */ + /* WorldEdit_shape_sphere_Flood(&Params, Thread, RadiusSquared, EditCenterP, FloodOrigin, NewVoxelValue); */ + /* } break; */ } } break; @@ -1076,18 +972,20 @@ ApplyUpdateToRegion(thread_local_state *Thread, work_queue_entry_update_world_re } } +#endif +#if 0 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_blend_mode Mode = Job->Brush.Mode; + world_edit_blend_mode_modifier Modifier = Job->Brush.Modifier; world_edit_shape Shape = Job->Brush.Shape; /* v3i FloodOrigin = V3i(Job->Brush.SimFloodOrigin); */ - u16 NewColor = PackHSVColor(Job->HSVColor); + u16 NewColor = PackV3_16b(Job->HSVColor); u8 NewTransparency = Job->Transparency; cp MaxP = Job->MaxP; cp MinP = Job->MinP; @@ -1127,7 +1025,7 @@ DoWorldUpdate(work_queue *Queue, world *World, thread_local_state *Thread, work_ { world_chunk *Chunk = DestChunkBuffer[ChunkIndex]; auto SimSpaceChunkRect = GetSimSpaceAABBi(World, Chunk); - auto SimSpaceIntersectionRect = Union(&SimSpaceChunkRect, &SimSpaceUpdateBounds); + auto SimSpaceIntersectionRect = Intersection(&SimSpaceChunkRect, &SimSpaceUpdateBounds); auto SimSpaceIntersectionMin = SimSpaceIntersectionRect.Min; auto SimSpaceIntersectionMax = SimSpaceIntersectionRect.Max; @@ -1146,7 +1044,8 @@ DoWorldUpdate(work_queue *Queue, world *World, thread_local_state *Thread, work_ { v3i RelVoxP = V3i(s32(xVoxel), s32(yVoxel), s32(zVoxel)); voxel *V = GetVoxel(Chunk, RelVoxP); - Assert( (V->Flags & Voxel_MarkBit) == 0); + NotImplemented; + /* Assert( (V->Flags & Voxel_MarkBit) == 0); */ v3i SimSpaceVoxPExact = V3i(xVoxel, yVoxel, zVoxel) + SimSpaceChunkMin; @@ -1180,7 +1079,7 @@ DoWorldUpdate(work_queue *Queue, world *World, thread_local_state *Thread, work_ // 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); + MakeFaceMasks_NoExteriorFaces( CopiedChunk.Occupancy, CopiedChunk.xOccupancyBorder, CopiedChunk.FaceMasks, 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); */ @@ -1191,7 +1090,7 @@ DoWorldUpdate(work_queue *Queue, world *World, thread_local_state *Thread, work_ { world_chunk *Chunk = DestChunkBuffer[ChunkIndex]; auto SimSpaceChunkRect = GetSimSpaceAABBi(World, Chunk); - auto SimSpaceIntersectionRect = Union(&SimSpaceChunkRect, &SimSpaceUpdateBounds); + auto SimSpaceIntersectionRect = Intersection(&SimSpaceChunkRect, &SimSpaceUpdateBounds); auto SimSpaceIntersectionMin = SimSpaceIntersectionRect.Min; auto SimSpaceIntersectionMax = SimSpaceIntersectionRect.Max; @@ -1218,21 +1117,18 @@ DoWorldUpdate(work_queue *Queue, world *World, thread_local_state *Thread, work_ 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].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 + NotImplemented; + /* Assert( (V->Flags & Voxel_MarkBit) == 0); */ + + StartedFilled += GetOccupancyBit(Chunk, s32(Index)); *V = CopiedChunk.Voxels[Index]; -#endif - EndedFilled += (V->Flags&Voxel_Filled); - Assert( (V->Flags & Voxel_MarkBit) == 0); + EndedFilled += GetOccupancyBit(&CopiedChunk, s32(Index)); + NotImplemented; + /* Assert( (V->Flags & Voxel_MarkBit) == 0); */ } } } @@ -1257,11 +1153,7 @@ DoWorldUpdate(work_queue *Queue, world *World, thread_local_state *Thread, work_ 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) ); */ @@ -1284,7 +1176,10 @@ DoWorldUpdate(work_queue *Queue, world *World, thread_local_state *Thread, work_ NotImplemented; #else { - ComputeStandingSpots( UpdateDim, CopiedChunk.Voxels, {}, + ComputeStandingSpots( UpdateDim, + CopiedChunk.Occupancy, + CopiedChunk.Voxels, + {}, {}, Global_StandingSpotDim, UpdateDim, @@ -1326,7 +1221,7 @@ DoWorldUpdate(work_queue *Queue, world *World, thread_local_state *Thread, work_ /* DrawStandingSpot(Mesh, V3(QueryRelChunkSpot), V3(Global_StandingSpotDim), TEAL, DEFAULT_STANDING_SPOT_THICKNESS*1.5f); */ } - auto SimSpaceSpotUnion = Union(&SimSpotAABB, &SimSpaceUpdateBounds); + auto SimSpaceSpotUnion = Intersection(&SimSpotAABB, &SimSpaceUpdateBounds); auto SimSpaceUnionDim = GetDim(SimSpaceSpotUnion); if (Volume(SimSpaceSpotUnion) == Volume(Global_StandingSpotDim)) // Cull { @@ -1364,7 +1259,7 @@ DoWorldUpdate(work_queue *Queue, world *World, thread_local_state *Thread, work_ voxel_position ChunkSpot = Chunk->StandingSpots.Start[ChunkStandingSpotIndex]; voxel_position ChunkSimSpot = ChunkSpot + SimSpaceChunkMin; rect3i ChunkSimSpotAABB = Rect3iMinDim(ChunkSimSpot, Global_StandingSpotDim); - if (Volume(Union(&SimSpotAABB, &ChunkSimSpotAABB))) + if (Volume(Intersection(&SimSpotAABB, &ChunkSimSpotAABB))) { Skip = true; break; @@ -1394,4 +1289,5 @@ DoWorldUpdate(work_queue *Queue, world *World, thread_local_state *Thread, work_ } } } +#endif diff --git a/src/engine/world_update.h b/src/engine/world_update.h index fd0c4ee2b..218beb4a5 100644 --- a/src/engine/world_update.h +++ b/src/engine/world_update.h @@ -1,20 +1,3 @@ -// 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 { @@ -41,7 +24,7 @@ poof(generate_cursor(voxel_stack_element)) struct apply_world_edit_params { - world_edit_mode Mode; + world_edit_blend_mode Mode; rect3i SSRect; rect3i SimSpaceUpdateBounds; world_chunk *CopiedChunk; @@ -53,7 +36,7 @@ struct apply_world_edit_params #define UNPACK_APPLY_WORLD_EDIT_PARAMS(P) \ - world_edit_mode Mode = P->Mode; \ + world_edit_blend_mode Mode = P->Mode; \ rect3i SSRect = P->SSRect; \ rect3i SimSpaceUpdateBounds = P->SimSpaceUpdateBounds; \ world_chunk *CopiedChunk = P->CopiedChunk; \ @@ -75,13 +58,13 @@ ChunkCountForDim(v3i Dim, v3i ChunkDim) -struct work_queue_entry_update_world_region; +/* 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, v3 HSVColor, b32 PersistWhitespace, memory_arena *Memory ); +/* link_internal void */ +/* QueueWorldUpdateForRegion( engine_resources *Engine, world_edit_blend_mode Mode, world_edit_blend_mode_modifier Modifier, /1* world_edit_shape *Shape, *1/ v3 HSVColor, b32 PersistWhitespace, 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, b32 PersistWhitespace = False); +/* link_internal void */ +/* ApplyUpdateToRegion(thread_local_state *Thread, work_queue_entry_update_world_region *Job, rect3i SimSpaceUpdateBounds, world_chunk *CopiedChunk, b32 Invert = False, b32 PersistWhitespace = False); */ -link_internal void -DoWorldUpdate(work_queue *Queue, world *World, thread_local_state *Thread, work_queue_entry_update_world_region *Job); +/* 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 5ac109ad7..4da1bd414 100644 --- a/src/game_loader.cpp +++ b/src/game_loader.cpp @@ -13,30 +13,8 @@ global_variable s64 LastGameLibTime; global_variable s64 LastDebugLibTime; -#include - /* #include */ -typedef struct stat bonsai_stat; - -link_internal b32 -LibIsNew(const char *LibPath, s64 *LastLibTime) -{ - b32 Result = False; - bonsai_stat StatStruct; - - if (stat(LibPath, &StatStruct) == 0) - { - if (StatStruct.st_mtime > *LastLibTime) - { - *LastLibTime = StatStruct.st_mtime; - Result = True; - } - } - - return Result; -} - #if 0 void @@ -105,7 +83,6 @@ PrintFiles(file_traversal_node *Node) global_variable const char * Global_ProjectSwitcherGameLibName = "./bin/game_libs/project_and_level_picker_loadable" PLATFORM_RUNTIME_LIB_EXTENSION; - s32 main( s32 ArgCount, const char ** Args ) { @@ -136,7 +113,6 @@ main( s32 ArgCount, const char ** Args ) engine_resources EngineResources_ = {}; engine_resources *EngineResources = &EngineResources_; - Global_EngineResources = EngineResources; const char* GameLibName = Global_ProjectSwitcherGameLibName; switch (ArgCount) @@ -152,24 +128,21 @@ main( s32 ArgCount, const char ** Args ) // kick off the worker threads. // shared_lib GameLib = {}; - application_api *GameApi = &EngineResources->GameApi; - engine_api EngineApi = {}; + application_api *GameApi = &EngineResources->Stdlib.AppApi; + engine_api *EngineApi = &EngineResources->EngineApi; { - LibIsNew(GameLibName, &LastGameLibTime); // Hack to initialize the lib timer statics - LibIsNew(DEFAULT_DEBUG_LIB, &LastDebugLibTime); + FileIsNew(GameLibName, &LastGameLibTime); // Hack to initialize the lib timer statics + FileIsNew(DEFAULT_DEBUG_LIB, &LastDebugLibTime); GameLib = OpenLibrary(GameLibName); if (!GameLib) { Error("Loading GameLib :( "); return 1; } if (!InitializeGameApi(GameApi, GameLib)) { Error("Initializing GameApi :( "); return 1; } - if (!InitializeEngineApi(&EngineApi, GameLib)) { Error("Initializing EngineApi :( "); return 1; } + if (!InitializeEngineApi(EngineApi, GameLib)) { Error("Initializing EngineApi :( "); return 1; } } - memory_arena BootstrapArena = {}; - memory_arena *GameMemory = AllocateArena(); - { temp_memory_handle TempHandle = BeginTemporaryMemory(&BootstrapArena); @@ -178,25 +151,26 @@ main( s32 ArgCount, const char ** Args ) EngineResources->Stdlib.Plat.ScreenDim = V2(SettingToValue(EngineResources->Settings.Graphics.WindowStartingSize)); - thread_main_callback_type Procs[2] = { RenderThread_Main, WorldUpdateThread_Main }; - thread_main_callback_type_buffer CustomWorkerProcs = {}; - CustomWorkerProcs.Start = Procs; - CustomWorkerProcs.Count = 2; + thread_main_callback_type Procs[1] = { RenderThread_Main }; + thread_main_callback_type_buffer CustomWorkerProcs = ThreadMainCallbackTypeBuffer(Procs, ArrayCount(Procs)); + + auto Flags = bonsai_init_flags( BonsaiInit_OpenWindow | + BonsaiInit_LaunchThreadPool | + BonsaiInit_InitDebugSystem | + BonsaiInit_ProfileContextSwitches ); - Ensure( InitializeBonsaiStdlib( bonsai_init_flags(BonsaiInit_OpenWindow|BonsaiInit_LaunchThreadPool|BonsaiInit_InitDebugSystem), + Ensure( InitializeBonsaiStdlib( Flags, GameApi, &EngineResources->Stdlib, &BootstrapArena, + EngineResources, &CustomWorkerProcs )); - while (EngineResources->Graphics.Initialized == False) { SleepMs(1); } - - /* EngineResources->DebugState = Global_DebugStatePointer; */ + while (FutexIsSignaled(&EngineResources->Graphics.Initialized) == False) { SleepMs(1); } Assert(EngineResources->Stdlib.ThreadStates); - Assert(Global_ThreadStates); - Ensure( EngineApi.OnLibraryLoad(EngineResources) ); + Ensure( EngineApi->OnLibraryLoad(EngineResources) ); Ensure( Bonsai_Init(EngineResources) ); // <-- EngineResources now initialized #if BONSAI_DEBUG_SYSTEM_API @@ -208,36 +182,35 @@ main( s32 ArgCount, const char ** Args ) memory_arena *WorkQueueMemory = AllocateArena(); InitQueue(&Plat->HighPriority, WorkQueueMemory); InitQueue(&Plat->LowPriority, WorkQueueMemory); - InitQueue(&Plat->RenderQ, WorkQueueMemory); - InitQueue(&Plat->WorldUpdateQ, WorkQueueMemory); - + InitQueue(&Plat->HiRenderQ, WorkQueueMemory); + InitQueue(&Plat->LoRenderQ, WorkQueueMemory); - DEBUG_REGISTER_ARENA(GameMemory, 0); DEBUG_REGISTER_ARENA(WorkQueueMemory, 0); DEBUG_REGISTER_ARENA(&BootstrapArena, 0); - thread_local_state *MainThread = GetThreadLocalState(ThreadLocal_ThreadIndex); if (GameApi->GameInit) { -#if PLATFORM_WINDOW_IMPLEMENTATIONS - // Block till RenderMain is initialized in case game wants to do rendering things in init..? - // TODO(Jesse): Is there any reason to actually do this? - while (EngineResources->Graphics.Initialized == False) { SleepMs(1); } -#endif EngineResources->GameState = GameApi->GameInit(EngineResources, MainThread); if (!EngineResources->GameState) { Error("Initializing Game :( "); return 1; } } + SignalFutex(&EngineResources->ReadyToStartMainLoop); + /* * Main Game loop */ + /* SleepMs(2000); */ + r32 LastMs = 0; while (Os->ContinueRunning) { + + /* Info("Frame (%d)", EngineResources->FrameIndex); */ + /* u32 CSwitchEventsThisFrame = CSwitchEventsPerFrame; */ /* CSwitchEventsPerFrame = 0; */ /* DebugLine("%u", CSwitchEventsThisFrame); */ @@ -253,8 +226,8 @@ main( s32 ArgCount, const char ** Args ) v2 LastMouseP = Plat->MouseP; while ( ProcessOsMessages(Os, Plat) ); Plat->MouseDP = LastMouseP - Plat->MouseP; - Assert(Plat->ScreenDim.x > 0); - Assert(Plat->ScreenDim.y > 0); + /* Assert(Plat->ScreenDim.x > 0); */ + /* Assert(Plat->ScreenDim.y > 0); */ BindHotkeysToInput(&EngineResources->Hotkeys, &Plat->Input); @@ -285,10 +258,12 @@ main( s32 ArgCount, const char ** Args ) DEBUG_FRAME_BEGIN(&EngineResources->Ui, Plat->dt, EngineResources->Hotkeys.Debug_ToggleMenu, EngineResources->Hotkeys.Debug_ToggleProfiling); #if !EMCC - if ( LibIsNew(GameLibName, &LastGameLibTime) ) + if ( FileIsNew(GameLibName, &LastGameLibTime) ) { Info("Reloading Game Lib"); + FreeOctreeChildren(EngineResources, &EngineResources->World->Root); + SignalAndWaitForWorkers(&Plat->WorkerThreadsSuspendFutex); DuplicateMetaTableNameStrings(EngineResources); @@ -296,20 +271,21 @@ main( s32 ArgCount, const char ** Args ) CloseLibrary(GameLib); GameLib = OpenLibrary(GameLibName); - Ensure(InitializeEngineApi(&EngineApi, GameLib)); + Ensure(InitializeEngineApi(EngineApi, GameLib)); Ensure(InitializeGameApi(GameApi, GameLib)); // Hook up global pointers - Ensure( EngineApi.OnLibraryLoad(EngineResources) ); + Ensure( EngineApi->OnLibraryLoad(EngineResources) ); if (EngineResources->RequestedGameLibReloadBehavior & GameLibReloadBehavior_FullInitialize) { EngineResources->RequestedGameLibReloadBehavior = game_lib_reload_behavior(EngineResources->RequestedGameLibReloadBehavior & ~GameLibReloadBehavior_FullInitialize); HardResetEngine(EngineResources); + /* ApplyEditBufferToOctree(Engine, &Editor->WorldEdits); */ - EngineResources->GameState = GameApi->GameInit(EngineResources, MainThread); - if (!EngineResources->GameState) { Error("Initializing Game :( "); return 1; } + /* EngineResources->GameState = GameApi->GameInit(EngineResources, MainThread); */ + /* if (!EngineResources->GameState) { Error("Initializing Game :( "); return 1; } */ } // Do game-specific reload code @@ -329,22 +305,24 @@ main( s32 ArgCount, const char ** Args ) /* if (IsDisconnected(&Plat->Network)) { ConnectToServer(&Plat->Network); } */ /* END_BLOCK("Network Ops"); */ - EngineApi.FrameBegin(EngineResources); + EngineApi->FrameBegin(EngineResources); TIMED_BLOCK("GameMain"); GameApi->GameMain(EngineResources, MainThread); END_BLOCK("GameMain"); - EngineApi.Simulate(EngineResources); + EngineApi->Simulate(EngineResources); DrainQueue(&Plat->HighPriority, MainThread, GameApi); WaitForWorkerThreads(&Plat->HighPriorityWorkerCount); - EngineApi.Render(EngineResources); + EngineApi->Render(EngineResources); + + Assert(FutexIsSignaled(&EngineResources->Graphics.RenderGate) == False); DEBUG_FRAME_END(Plat->dt); - EngineApi.FrameEnd(EngineResources); + EngineApi->FrameEnd(EngineResources); // NOTE(Jesse): We can't hold strings from PlatformTraverseDirectoryTreeUnordered @@ -352,6 +330,7 @@ main( s32 ArgCount, const char ** Args ) // has to happen before the end of the frame. if ( EngineResources->RequestedGameLibReloadNode.Name.Count ) { + Info("Requestin hot-reload of game lib (%S)", EngineResources->RequestedGameLibReloadNode.Name); LastGameLibTime = 0; // TODO(Jesse)(leak): We probably don't want to just leak these strings.. GameLibName = ConcatZ( EngineResources->RequestedGameLibReloadNode.Dir, CSz("/"), EngineResources->RequestedGameLibReloadNode.Name, &BootstrapArena ); @@ -360,18 +339,45 @@ main( s32 ArgCount, const char ** Args ) EngineResources->RequestedGameLibReloadBehavior = GameLibReloadBehavior_FullInitialize; } + { + // Have to call this at least once + SplitAndQueueOctreeNodesForInit(EngineResources); + + for (;;) + { + r32 CurrentMS = (r32)GetHighPrecisionClock(); + r32 ThisMs = (CurrentMS - LastMs); + r32 TargetMs = 32.f; + s32 MSUntilFrameTime = Max(0, s32(TargetMs - ThisMs)); + + if (MSUntilFrameTime > 10) + { + SplitAndQueueOctreeNodesForInit(EngineResources); + SleepMs(10); + } + else + { + SleepMs(MSUntilFrameTime); + break; + } + } + } + + { + r32 CurrentMS = (r32)GetHighPrecisionClock(); + r32 ThisMs = (CurrentMS - LastMs); + r32 RealDt = ThisMs/1000.0f; - Assert(ThreadLocal_ThreadIndex == 0); - thread_local_state *TLS = GetThreadLocalState(ThreadLocal_ThreadIndex); - Ensure( RewindArena(TLS->TempMemory) ); + LastMs = CurrentMS; + Plat->dt = RealDt; + Plat->GameTime += RealDt; - r32 CurrentMS = (r32)GetHighPrecisionClock(); - r32 RealDt = (CurrentMS - LastMs)/1000.0f; - LastMs = CurrentMS; - Plat->dt = RealDt; - Plat->GameTime += RealDt; + Assert(ThreadLocal_ThreadIndex == 0); + thread_local_state *TLS = GetThreadLocalState(ThreadLocal_ThreadIndex); + Ensure( RewindArena(TLS->TempMemory) ); - MAIN_THREAD_ADVANCE_DEBUG_SYSTEM(RealDt); + MAIN_THREAD_ADVANCE_DEBUG_SYSTEM(RealDt); + } } #if 0 diff --git a/src/poof_ctags_stub.cpp b/src/poof_ctags_stub.cpp new file mode 100644 index 000000000..efcccca48 --- /dev/null +++ b/src/poof_ctags_stub.cpp @@ -0,0 +1,18 @@ +#define PLATFORM_WINDOW_IMPLEMENTATIONS 1 +#define BONSAI_STDLIB_WORK_QUEUE_IMPLEMENTATION 1 + +#define BONSAI_DEBUG_SYSTEM_API 1 +#define BONSAI_DEBUG_SYSTEM_LOADER_API 1 + +#include "bonsai_types.h" + +poof( + for_datatypes(all) + @omit_include + @origin_comment_format(!_TAG_FILE_GENERATED_FROM (%S:%d)) + func (type) + { + type.name type.file type.line + } +) +// tags diff --git a/src/terrain_iterator.cpp b/src/terrain_iterator.cpp new file mode 100644 index 000000000..4a4b63a47 --- /dev/null +++ b/src/terrain_iterator.cpp @@ -0,0 +1,123 @@ +// src/engine/terrain.cpp:168:0 + +// NOTE(Jesse): This must hold true for using any Noise_16x func +Assert(Chunk->Dim % V3i(16) == V3i(0)); + +Period = Max(Period, V3(1.f)); + +auto PrimeX = U32_8X(501125321); +auto PrimeY = U32_8X(1136930381); +auto PrimeZ = U32_8X(1720413743); + +u64 CycleCountStart = GetCycleCount(); + +// TODO(Jesse): Make this dynamic +Assert(Octaves < 8); +perlin_params zParams[16]; +perlin_params yParams[16]; +perlin_params xParams[16]; + +for ( s32 z = 0; z < Dim.z; z += 1) +{ + f32 zCoord0 = COMPUTE_NOISE_INPUT(z, 0, Chunk); + /* f32 zCoord1 = COMPUTE_NOISE_INPUT(z, 1, Chunk); */ + + f32 WorldZBiased0 = zCoord0 - zMin; + /* f32 WorldZBiased1 = zCoord1 - zMin; */ + + u32 ParamsIndex = 0; + v3 InteriorPeriod = Period; + RangeIterator_t(u32, OctaveIndex, Octaves) + { + zParams[ParamsIndex++] = ComputePerlinParameters(F32_8X(zCoord0/InteriorPeriod.z), PrimeZ); + /* zParams[ParamsIndex++] = ComputePerlinParameters(F32_8X(zCoord1/InteriorPeriod.z), PrimeZ); */ + InteriorPeriod = Max(V3(1.f), InteriorPeriod/2.f); + } + /* Assert(ParamsIndex==16); */ + + for ( s32 y = 0; y < Dim.y; y += 1) + { + f32 yCoord0 = COMPUTE_NOISE_INPUT(y, 0, Chunk); + /* f32 yCoord1 = COMPUTE_NOISE_INPUT(y, 1, Chunk); */ + + ParamsIndex = 0; + InteriorPeriod = Period; + RangeIterator_t(u32, OctaveIndex, Octaves) + { + yParams[ParamsIndex++] = ComputePerlinParameters(F32_8X(yCoord0/InteriorPeriod.y), PrimeY); + /* yParams[ParamsIndex++] = ComputePerlinParameters(F32_8X(yCoord1/InteriorPeriod.y), PrimeY); */ + InteriorPeriod = Max(V3(1.f), InteriorPeriod/2.f); + } + /* Assert(ParamsIndex==16); */ + + for ( s32 x = 0; x < Dim.x; x += 16 ) + { + v3i VoxP = V3i(x,y,z); + s32 VoxIndex = GetIndex(VoxP, Dim); + + u16 PackedHSVColorValue = RGBtoPackedHSV(RGBColor); + + f32 xCoords[16]; + ParamsIndex = 0; + InteriorPeriod = Period; + for (u32 OctaveIndex = 0; OctaveIndex < Octaves; ++OctaveIndex) + { + RangeIterator(ValueIndex, 16) + { + xCoords[ValueIndex] = (COMPUTE_NOISE_INPUT(x, ValueIndex, Chunk)); + } + auto Index = 0; + auto xCoord0 = F32_8X( xCoords[0], xCoords[1], xCoords[2], xCoords[3], xCoords[4], xCoords[5], xCoords[6], xCoords[7] ); + auto xCoord1 = F32_8X( xCoords[8], xCoords[9], xCoords[10], xCoords[11], xCoords[12], xCoords[13], xCoords[14], xCoords[15] ); + xParams[ParamsIndex++] = ComputePerlinParameters(xCoord0/F32_8X(InteriorPeriod.x), PrimeX); + xParams[ParamsIndex++] = ComputePerlinParameters(xCoord1/F32_8X(InteriorPeriod.x), PrimeX); + InteriorPeriod = Max(V3(1.f), InteriorPeriod/2.f); + } + /* Assert(ParamsIndex==16); */ + + r32 InteriorAmp = r32(Amplitude); + for (u32 OctaveIndex = 0; OctaveIndex < Octaves; ++OctaveIndex) + { + f32 TmpPerlinResults[16*2*2]; + PerlinNoise_16x1x1_avx2(xParams+(OctaveIndex*2), yParams+(OctaveIndex*2), zParams, TmpPerlinResults); + + RangeIterator(zIndex, 1) + RangeIterator(yIndex, 1) + RangeIterator(xIndex, 16) + { + s32 TmpIndex = GetIndex(V3i(xIndex, yIndex, zIndex), V3i(16,1,1)); + s32 NoiseIndex = GetIndex(VoxP+V3i(xIndex, yIndex, zIndex), Dim); + NoiseValues[NoiseIndex] += TmpPerlinResults[TmpIndex]*InteriorAmp; + } + + InteriorAmp = Max(1.f, InteriorAmp/2.f); + } + + + RangeIterator(zIndex, 1) + { + /* r32 WorldZBiased = zIndex == 0 ? WorldZBiased0 : WorldZBiased1; */ + r32 WorldZBiased = WorldZBiased0; + RangeIterator(yIndex, 1) + { + RangeIterator(xIndex, 16) + { + s32 ThisIndex = GetIndex(VoxP+V3i(xIndex, yIndex, zIndex), Dim); + s32 NoiseChoice = NoiseValues[ThisIndex] > WorldZBiased; + ChunkSum += u32(NoiseChoice); + + SetOccupancyBit(Chunk, ThisIndex, NoiseChoice); + Chunk->Voxels[ThisIndex].Color = PackedHSVColorValue*u16(NoiseChoice); + } + } + } + } + } +} + +u64 CycleCountEnd = GetCycleCount(); +u64 CyclesElapsed = CycleCountEnd-CycleCountStart; + +engine_debug *ED = GetEngineDebug(); +ED->ChunkGenCyclesElapsed += CyclesElapsed; +ED->CellsGenerated += u64(Volume(Chunk->Dim)*s32(Octaves)); diff --git a/src/tests/chunk.cpp b/src/tests/chunk.cpp index 1d6f682c5..117f6c7c9 100644 --- a/src/tests/chunk.cpp +++ b/src/tests/chunk.cpp @@ -19,7 +19,7 @@ TestChunkCopy(memory_arena *Memory) temp_memory_handle TmpMemHandle = BeginTemporaryMemory(Memory); /* world_chunk *SyntheticChunk = AllocateWorldChunk(Memory, SynChunkP, SynChunkDim); */ - world_chunk *DestChunk = AllocateWorldChunk(DestChunkP, DestChunkDim, Memory); + world_chunk *DestChunk = AllocateWorldChunk(DestChunkP, DestChunkDim, V3i(1), Memory); // NOTE(Jesse): This is a hack because this function checks to make sure // it's called from a worker thread. Kinda janky, but worth the jank IMO @@ -55,8 +55,8 @@ TestChunkCopy(memory_arena *Memory) { // Ensure copy works as intended temp_memory_handle TmpMemHandle = BeginTemporaryMemory(Memory); - world_chunk *SyntheticChunk = AllocateWorldChunk(SynChunkP, SynChunkDim, Memory); - world_chunk *DestChunk = AllocateWorldChunk(DestChunkP, DestChunkDim, Memory); + world_chunk *SyntheticChunk = AllocateWorldChunk(SynChunkP, SynChunkDim, V3i(1), Memory); + world_chunk *DestChunk = AllocateWorldChunk(DestChunkP, DestChunkDim, V3i(1), Memory); // @set_chunk_queued_hack SetFlag(SyntheticChunk, Chunk_Queued); @@ -108,7 +108,7 @@ main(s32 ArgCount, const char** Args) memory_arena *Memory = AllocateArena(Megabytes(32)); Engine.World = Allocate(world, &BootstrapArena, 1); - AllocateWorld(Engine.World, {}, V3i(8), V3i(8)); + AllocateWorld(Engine.World, {}, V3i(8)); TestChunkCopy(Memory); diff --git a/src/tests/containers/block_array.cpp b/src/tests/containers/block_array.cpp index 21314d2de..8e0aa9a7f 100644 --- a/src/tests/containers/block_array.cpp +++ b/src/tests/containers/block_array.cpp @@ -3,6 +3,10 @@ #include #include +global_variable memory_arena _Memory; + +global_variable memory_arena *Memory = &_Memory; + link_internal void Print(u32_block_array *Array) @@ -16,7 +20,7 @@ Print(u32_block_array *Array) link_internal u32_block_array MakeOrderedBlockArray(u32 Count) { - u32_block_array Array = {}; + u32_block_array Array = U32BlockArray(Memory); // Insert 8 elements RangeIterator_t(u32, Index, Count) @@ -30,7 +34,7 @@ MakeOrderedBlockArray(u32 Count) link_internal void TrivialAddRemove() { - u32_block_array Array = {}; + u32_block_array Array = U32BlockArray(Memory); u32 Element = 69; @@ -49,32 +53,33 @@ TrivialAddRemove() RemoveUnordered(&Array, Last); - Assert( AtElements(&Array).BlockIndex == 0); - Assert( AtElements(&Array).ElementIndex == 0); + TestThat( AtElements(&Array).Index == 0); } link_internal void TwoBlocksRemoveFromEnd() { - u32_block_array Array = {}; + u32_block_array Array = U32BlockArray(Memory); // Insert 8 elements RangeIterator_t(u32, Index, 8) { Push(&Array, &Index); - - TestThat(LastIndex(&Array).BlockIndex == 0); - TestThat(LastIndex(&Array).ElementIndex == Index); + TestThat(LastIndex(&Array).Index == Index); } + TestThat(Array.BlockCount == 1); { u32 Index = 8; Push(&Array, &Index); + TestThat(Array.BlockCount == 2); Index = 9; Push(&Array, &Index); + TestThat(Array.BlockCount == 2); } + TestThat(Array.ElementCount == 10 ); IterateOver(&Array, Value, Index) { @@ -83,70 +88,52 @@ TwoBlocksRemoveFromEnd() TestThat( *P == IntIndex ); } - // 8 elements per block, (10-8 == 2) - TestThat( Array.Current->At == 2 ); - { auto Last = LastIndex(&Array); - - TestThat( Last.BlockIndex == 1 ); - TestThat( Last.ElementIndex == 1 ); - RemoveUnordered(&Array, Last); - TestThat( Array.First->Next == Last.Block ); - TestThat( Array.First->Next == Array.Current ); + TestThat(Array.ElementCount == 9 ); + TestThat(Array.BlockCount == 2); } - TestThat( Array.Current->At == 1 ); - { auto Last = LastIndex(&Array); - - TestThat( Last.BlockIndex == 1 ); - TestThat( Last.ElementIndex == 0 ); - RemoveUnordered(&Array, Last); - TestThat( Array.Current == Array.First); + TestThat(Array.ElementCount == 8 ); + TestThat(Array.BlockCount == 2); } - TestThat( Array.Current->At == 8 ); - { auto Last = LastIndex(&Array); - - TestThat( Last.BlockIndex == 0 ); - TestThat( Last.ElementIndex == 7 ); - RemoveUnordered(&Array, Last); - TestThat( Array.Current == Array.First); + TestThat(Array.ElementCount == 7 ); + TestThat(Array.BlockCount == 2); } - - /* TestThat( Last.ElementIndex = 1 ); */ } link_internal void TwoBlocksRemoveFromFront() { - u32_block_array Array = {}; + u32_block_array Array = U32BlockArray(Memory); // Insert 8 elements RangeIterator_t(u32, Index, 8) { Push(&Array, &Index); - - TestThat(LastIndex(&Array).BlockIndex == 0); - TestThat(LastIndex(&Array).ElementIndex == Index); + TestThat(LastIndex(&Array).Index == Index); } + TestThat(Array.BlockCount == 1); { u32 Index = 8; Push(&Array, &Index); + TestThat(Array.BlockCount == 2); Index = 9; Push(&Array, &Index); + TestThat(Array.BlockCount == 2); } @@ -157,101 +144,58 @@ TwoBlocksRemoveFromFront() TestThat( *P == IntIndex ); } - // 8 elements per block, (10-8 == 2) - TestThat( Array.Current->At == 2 ); - { auto I = ZerothIndex(&Array); RemoveUnordered(&Array, I); - - auto Last = LastIndex(&Array); - TestThat( Array.First->Next == Last.Block ); - TestThat( Array.First->Next == Array.Current ); - TestThat( Array.Current->At == 1 ); + TestThat(Array.ElementCount == 9); + TestThat(Array.BlockCount == 2); } { auto I = ZerothIndex(&Array); RemoveUnordered(&Array, I); - - TestThat( Array.Current == Array.First); - TestThat( Array.Current->At == 8 ); + TestThat(Array.ElementCount == 8); + TestThat(Array.BlockCount == 2); } { auto I = ZerothIndex(&Array); RemoveUnordered(&Array, I); - - TestThat( Array.Current == Array.First); - TestThat( Array.Current->At == 7 ); + TestThat(Array.ElementCount == 7); + TestThat(Array.BlockCount == 2); } } - link_internal void -PrintThreeBlocksRemoveFromMiddle() +RemoveAllBlocks() { auto Array = MakeOrderedBlockArray(32); - TestThat( Array.Current->At == 8 ); - - auto I = ZerothIndex(&Array); - - ++I; - - { - RemoveUnordered(&Array, I); - TestThat( Array.Current->At == 7 ); - Print(&Array); - Info("--"); - } - - { - RemoveUnordered(&Array, I); - TestThat( Array.Current->At == 6 ); - Print(&Array); - Info("--"); - } - - { - I.ElementIndex = 7; - RemoveUnordered(&Array, I); - /* TestThat( Array.Current->At == 6 ); */ - Print(&Array); - Info("--"); - } - - { - ++I; - RemoveUnordered(&Array, I); - /* TestThat( Array.Current->At == 6 ); */ - Print(&Array); - Info("--"); - } + RangeIterator(Index, 32) { - I = LastIndex(&Array);; - RemoveUnordered(&Array, I); - /* TestThat( Array.Current->At == 6 ); */ - Print(&Array); - Info("--"); - } + RemoveUnordered(&Array, ZerothIndex(&Array)); - { - I.ElementIndex = 0; - RemoveUnordered(&Array, I); - /* TestThat( Array.Current->At == 6 ); */ - Print(&Array); - Info("--"); + auto AtE = AtElements(&Array); + s32 Count = s32(GetIndex(&AtE)); + Assert( Count == 31 - Index ); } +} +link_internal void +Remove0thElementInTwoElementList() +{ + auto Array = MakeOrderedBlockArray(2); + auto Z = ZerothIndex(&Array); + RemoveUnordered(&Array, Z); + TestThat(Array.ElementCount == 1); - - + RemoveUnordered(&Array, Z); + TestThat(Array.ElementCount == 0); } s32 @@ -265,7 +209,9 @@ main(s32 ArgCount, const char** Args) TwoBlocksRemoveFromFront(); - PrintThreeBlocksRemoveFromMiddle(); + RemoveAllBlocks(); + + Remove0thElementInTwoElementList(); TestSuiteEnd(); exit(TestsFailed); diff --git a/src/tests/perlin_perf.cpp b/src/tests/perlin_perf.cpp new file mode 100644 index 000000000..3c7f10ff2 --- /dev/null +++ b/src/tests/perlin_perf.cpp @@ -0,0 +1,124 @@ +#include +#include + +s32 +main(s32 ArgCount, const char** Args) +{ + TestSuiteBegin("Perlin Performance", ArgCount, Args); + + memory_arena BootstrapArena = {}; + engine_resources Engine = {}; + Global_EngineResources = &Engine; + Ensure( InitializeBonsaiStdlib( BonsaiInit_Default, + {}, + &Engine.Stdlib, + &BootstrapArena ) ); + + timeBeginPeriod(1); + + s32 PhysicalProcessorIndex = 0; + + s32 ThreadIndex = 0; + SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *RelationshipBuffer = Allocate(SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX, GetTranArena(), 64); + unsigned long AllocatedSize = sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX)*64; + if (GetLogicalProcessorInformationEx(RelationProcessorCore, RelationshipBuffer, &AllocatedSize)) + { + // Count physical processors + SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *Info = RelationshipBuffer; + for (u32 Offset = 0; Offset < AllocatedSize; Offset += Info->Size) + { + Info = (SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX*)((u8*)RelationshipBuffer + Offset); + Assert(Info->Processor.GroupCount == 1); + if (PhysicalProcessorIndex == ThreadIndex) + { + SetThreadAffinityMask(GetCurrentThread(), Info->Processor.GroupMask->Mask); + } + + PhysicalProcessorIndex++; + } + + Info = RelationshipBuffer; + for (u32 Offset = 0; Offset < AllocatedSize; Offset += Info->Size) + { + Info = (SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX*)((u8*)RelationshipBuffer + Offset); + } + + } + else + { + SoftError("GetLogicalProcessorInformationEx Failed"); + } + + memory_arena *Memory = AllocateArena(Megabytes(32)); + + + v3i Dim = V3i(32); + r32 *NoiseValues = Allocate(r32, Memory, Volume(Dim)); + + auto PrimeX = U32_8X(501125321); + auto PrimeY = U32_8X(1136930381); + auto PrimeZ = U32_8X(1720413743); + + + f32_8x RunningInc = F32_8X(0.f, 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f); + + perlin_params zParams; + perlin_params yParams; + perlin_params xParams[2]; + + NotImplemented; +#if 0 + u64 CyclesElapsed = 0; + u64 CellsGenerated = 0; + RangeIterator(Index, 4096*32) + { + u64 CycleCountStart = GetCycleCount(); + + u32 DestIndex = 0; + for ( s32 z = 0; z < Dim.z; ++ z) + { + zParams = ComputePerlinParameters(F32_8X(z), PrimeZ); + + for ( s32 y = 0; y < Dim.y; ++ y) + { + yParams = ComputePerlinParameters(F32_8X(y), PrimeY); + + for ( s32 x = 0; x < Dim.x; x += 16 ) + { + u32 ParamsIndex = 0; + auto _x0 = F32_8X(x) + RunningInc; + auto _x1 = F32_8X(x) + RunningInc + RunningInc; + xParams[0] = ComputePerlinParameters(_x0, PrimeX); + xParams[1] = ComputePerlinParameters(_x1, PrimeX); + + PerlinNoise_16x_avx2_x(xParams, &yParams, &zParams, NoiseValues+DestIndex, 1.f); + DestIndex += 16; + } + } + } + + u64 CycleCountEnd = GetCycleCount(); + u64 Elapsed = CycleCountEnd-CycleCountStart; + + /* SleepMs(1); */ + + CyclesElapsed += Elapsed; + CellsGenerated += u64(Volume(Dim)); + + if (Index % 512 == 0) + { + r64 CyclesPerCell = r64(CyclesElapsed)/r64(CellsGenerated); + printf("CyclesPerCell (%.2f)\n", CyclesPerCell); + } + } +#endif + + + /* RangeIterator(Index, 4096) */ + /* { */ + /* PerlinNoise_16x_avx2(); */ + /* PerlinNoise_16x_avx2(perlin_params *perlinX, perlin_params *perlinY, perlin_params *perlinZ, f32 *Dest, f32 Amplitude) */ + /* } */ + + TestSuiteEnd(); +} diff --git a/white.bmp b/white.bmp index 73bd55fc2..763be1f7e 100644 Binary files a/white.bmp and b/white.bmp differ