From 69e3dd26dc271ee35502752cde335df866d4ef6c Mon Sep 17 00:00:00 2001 From: Katajisto Date: Mon, 27 Jul 2026 12:45:02 +0300 Subject: [PATCH] work on improving level editing and camera --- TODO.txt | 1 + log_nvprosample.txt | 47 ++++++++++++++++++++++++++++++------- settings.cfg | 2 +- src/editor/editor.jai | 5 ++-- src/editor/level_editor.jai | 46 +++++++++++++++++++++++++++++------- src/rendering/camera.jai | 4 ++-- src/rendering/tasks.jai | 2 +- src/world.jai | 13 ++++++++++ 8 files changed, 97 insertions(+), 23 deletions(-) diff --git a/TODO.txt b/TODO.txt index 754e459..3a54928 100644 --- a/TODO.txt +++ b/TODO.txt @@ -4,4 +4,5 @@ Engine todo list: - Sokol should be fully under a platform abstraction layer but it's not, currently it's fine but it would be really nice to be able to have a metal, vulkan webgpu backends at some point for the longevity of the engine. +- Backend sokol has a global named camera taking up the name which is fucking crazy. diff --git a/log_nvprosample.txt b/log_nvprosample.txt index 973a414..f278c22 100644 --- a/log_nvprosample.txt +++ b/log_nvprosample.txt @@ -1,6 +1,6 @@ _______________ Vulkan Version: - - available: 1.4.309 + - available: 1.3.296 - requesting: 1.3.0 ______________________ Used Instance Layers : @@ -8,15 +8,17 @@ VK_LAYER_KHRONOS_validation Used Instance Extensions : ____________________ -Devices : 1 -0: AMD Radeon RX 6950 XT +Devices : 2 +0: AMD Radeon RX 6700 XT (RADV NAVI22) - Compatible -Compatible physical devices found : 1 +1: llvmpipe (LLVM 20.1.2, 256 bits) + - Compatible +Compatible physical devices found : 2 Using Device: - - Device Name : AMD Radeon RX 6950 XT + - Device Name : AMD Radeon RX 6700 XT (RADV NAVI22) - Vendor : AMD - - Driver Version : 2.0.341 - - API Version : 1.4.308 + - Driver Version : 25.2.8 + - API Version : 1.4.318 - Device Type : Discrete GPU ________________________ Used Device Extensions : @@ -24,4 +26,33 @@ VK_KHR_deferred_host_operations VK_KHR_acceleration_structure VK_KHR_ray_query -BLAS Compaction: 1.8MB -> 0.6MB (1.2MB saved, 65.9% smaller) +BLAS Compaction: 0.3MB -> 0.2MB (0.1MB saved, 31.9% smaller) +_______________ +Vulkan Version: + - available: 1.3.296 + - requesting: 1.3.0 +______________________ +Used Instance Layers : +VK_LAYER_KHRONOS_validation + +Used Instance Extensions : +____________________ +Devices : 2 +0: AMD Radeon RX 6700 XT (RADV NAVI22) + - Compatible +1: llvmpipe (LLVM 20.1.2, 256 bits) + - Compatible +Compatible physical devices found : 2 +Using Device: + - Device Name : AMD Radeon RX 6700 XT (RADV NAVI22) + - Vendor : AMD + - Driver Version : 25.2.8 + - API Version : 1.4.318 + - Device Type : Discrete GPU +________________________ +Used Device Extensions : +VK_KHR_deferred_host_operations +VK_KHR_acceleration_structure +VK_KHR_ray_query + +BLAS Compaction: 0.3MB -> 0.2MB (0.1MB saved, 31.9% smaller) diff --git a/settings.cfg b/settings.cfg index 10cc065..88d4ab0 100644 --- a/settings.cfg +++ b/settings.cfg @@ -1,4 +1,4 @@ master_volume 0.276042 music_volume 0 sfx_volume 1 -fullscreen 0 +fullscreen 1 diff --git a/src/editor/editor.jai b/src/editor/editor.jai index 8752ca0..7fd7068 100644 --- a/src/editor/editor.jai +++ b/src/editor/editor.jai @@ -78,7 +78,10 @@ draw_editor_ui :: (theme: *GR.Overall_Theme) { draw_editor :: () { #if OS != .WASM { + disable_dof_post_process = false; if !in_editor_view then return; + disable_dof_post_process = true; + if current_editor_view == { case .Trile_Editor; @@ -107,10 +110,8 @@ tick_editor_ui :: () { #if OS != .WASM { if in_editor_view { - disable_dof_post_process = false; if current_editor_view == { case .Trile_Editor; - disable_dof_post_process = true; tick_trile_editor(); case .Level_Editor; tick_level_editor(); diff --git a/src/editor/level_editor.jai b/src/editor/level_editor.jai index eb411fb..d0de755 100644 --- a/src/editor/level_editor.jai +++ b/src/editor/level_editor.jai @@ -646,15 +646,17 @@ create_level_editor_preview_tasks :: () { name, orientation, found := get_trile_at(*curworld.world, xx px, xx py, xx pz); cursor_trile := ifx found then name else (ifx editor_current_trile then editor_current_trile.name else ""); if cursor_trile != "" { + ck := world_to_chunk_coord(xx px, xx py, xx pz); + lx, ly, lz := world_to_local(xx px, xx py, xx pz); positions: [..]Trile_Instance; positions.allocator = temp; - array_add(*positions, Trile_Instance.{xx (px % 32), xx (py % 32), xx (pz % 32), xx orientation}); + array_add(*positions, Trile_Instance.{lx, ly, lz, xx orientation}); task: Rendering_Task_Trile; task.trile = cursor_trile; task.positions = positions; task.worldConf = *curworld.world.conf; task.preview_mode = 1; - task.chunk_key = world_to_chunk_coord(xx px, xx py, xx pz); + task.chunk_key = ck; add_rendering_task(task); } return; @@ -664,7 +666,8 @@ create_level_editor_preview_tasks :: () { positions: [..]Vector4; positions.allocator = temp; - ori := cast(float) get_current_orientation(); + ori_u8 := get_current_orientation(); + ori := cast(float) ori_u8; if current_tool_mode == .POINT { array_add(*positions, .{cast(float)px, cast(float)py, cast(float)pz, ori}); @@ -720,12 +723,37 @@ create_level_editor_preview_tasks :: () { is_delete := (current_tool_mode == .AREA && area_active && area_delete) || (current_tool_mode == .LINE && line_active && line_delete); - task: Rendering_Task_Trile; - task.trile = editor_current_trile.name; - // task.positions = positions; - task.worldConf = *curworld.world.conf; - task.preview_mode = ifx is_delete then cast(s32)2 else cast(s32)1; - add_rendering_task(task); + chunk_groups: [..] struct { key: Chunk_Key; instances: [..]Trile_Instance; }; + chunk_groups.allocator = temp; + for pos : positions { + wx := cast(s32) pos.x; wy := cast(s32) pos.y; wz := cast(s32) pos.z; + ck := world_to_chunk_coord(wx, wy, wz); + lx, ly, lz := world_to_local(wx, wy, wz); + found := false; + for *grp : chunk_groups { + if grp.key == ck { + array_add(*grp.instances, Trile_Instance.{lx, ly, lz, ori_u8}); + found = true; + break; + } + } + if !found { + instances: [..]Trile_Instance; + instances.allocator = temp; + array_add(*instances, Trile_Instance.{lx, ly, lz, ori_u8}); + array_add(*chunk_groups, .{ck, instances}); + } + } + + for grp : chunk_groups { + task: Rendering_Task_Trile; + task.trile = editor_current_trile.name; + task.positions = grp.instances; + task.worldConf = *curworld.world.conf; + task.chunk_key = grp.key; + task.preview_mode = ifx is_delete then cast(s32)2 else cast(s32)1; + add_rendering_task(task); + } } get_trile_at :: (world: *World, wx: s32, wy: s32, wz: s32) -> (name: string, orientation: u8, found: bool) { diff --git a/src/rendering/camera.jai b/src/rendering/camera.jai index 2269f96..1e79433 100644 --- a/src/rendering/camera.jai +++ b/src/rendering/camera.jai @@ -1,7 +1,7 @@ Camera :: struct { fov : float = 75.0 * 3.141 / 180.0; - near : float = 1.0; - far : float = 20.0; + near : float = 0.5; + far : float = 2000.0; position : Vector3 = .{2, 2, 2}; target : Vector3 = .{0, 0, 0}; } diff --git a/src/rendering/tasks.jai b/src/rendering/tasks.jai index fb22003..c203ee5 100644 --- a/src/rendering/tasks.jai +++ b/src/rendering/tasks.jai @@ -46,7 +46,7 @@ Rendering_Task_Billboard :: struct { t.type = .BILLBOARD; position : Vector3; animation : *Animation; - frame : s32; + frame : s32; flipX : bool; flipY : bool; faceDir : Vector3 = .{-100, -100, -100}; diff --git a/src/world.jai b/src/world.jai index 041a4a9..b066399 100644 --- a/src/world.jai +++ b/src/world.jai @@ -329,6 +329,19 @@ recompute_buried_at_cell :: (world: *World, wx: s32, wy: s32, wz: s32) { } } +get_note_locations :: (note : string) -> []Vector3 { + result: [..]Vector3; + print("Looking for notes %\n", current_world.world.name); + for n: current_world.world.notes { + print("COMP: % %\n", n.text, note); + if n.text == note { + v: Vector3 = .{cast(float)n.position.x, cast(float)n.position.y, cast(float)n.position.z}; + array_add(*result, v); + } + } + return result; +} + invalidate_buried_around :: (world: *World, wx: s32, wy: s32, wz: s32) { recompute_buried_at_cell(world, wx, wy, wz); for axis: 0..5 {