work on improving level editing and camera

This commit is contained in:
Tuomas Katajisto 2026-07-27 12:45:02 +03:00
parent a5c617d2e4
commit 69e3dd26dc
8 changed files with 97 additions and 23 deletions

View File

@ -4,4 +4,5 @@ Engine todo list:
- Sokol should be fully under a platform abstraction layer but it's not, - 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 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. 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.

View File

@ -1,6 +1,6 @@
_______________ _______________
Vulkan Version: Vulkan Version:
- available: 1.4.309 - available: 1.3.296
- requesting: 1.3.0 - requesting: 1.3.0
______________________ ______________________
Used Instance Layers : Used Instance Layers :
@ -8,15 +8,17 @@ VK_LAYER_KHRONOS_validation
Used Instance Extensions : Used Instance Extensions :
____________________ ____________________
Devices : 1 Devices : 2
0: AMD Radeon RX 6950 XT 0: AMD Radeon RX 6700 XT (RADV NAVI22)
- Compatible - Compatible
Compatible physical devices found : 1 1: llvmpipe (LLVM 20.1.2, 256 bits)
- Compatible
Compatible physical devices found : 2
Using Device: Using Device:
- Device Name : AMD Radeon RX 6950 XT - Device Name : AMD Radeon RX 6700 XT (RADV NAVI22)
- Vendor : AMD - Vendor : AMD
- Driver Version : 2.0.341 - Driver Version : 25.2.8
- API Version : 1.4.308 - API Version : 1.4.318
- Device Type : Discrete GPU - Device Type : Discrete GPU
________________________ ________________________
Used Device Extensions : Used Device Extensions :
@ -24,4 +26,33 @@ VK_KHR_deferred_host_operations
VK_KHR_acceleration_structure VK_KHR_acceleration_structure
VK_KHR_ray_query 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)

View File

@ -1,4 +1,4 @@
master_volume 0.276042 master_volume 0.276042
music_volume 0 music_volume 0
sfx_volume 1 sfx_volume 1
fullscreen 0 fullscreen 1

View File

@ -78,7 +78,10 @@ draw_editor_ui :: (theme: *GR.Overall_Theme) {
draw_editor :: () { draw_editor :: () {
#if OS != .WASM { #if OS != .WASM {
disable_dof_post_process = false;
if !in_editor_view then return; if !in_editor_view then return;
disable_dof_post_process = true;
if current_editor_view == { if current_editor_view == {
case .Trile_Editor; case .Trile_Editor;
@ -107,10 +110,8 @@ tick_editor_ui :: () {
#if OS != .WASM { #if OS != .WASM {
if in_editor_view { if in_editor_view {
disable_dof_post_process = false;
if current_editor_view == { if current_editor_view == {
case .Trile_Editor; case .Trile_Editor;
disable_dof_post_process = true;
tick_trile_editor(); tick_trile_editor();
case .Level_Editor; case .Level_Editor;
tick_level_editor(); tick_level_editor();

View File

@ -646,15 +646,17 @@ create_level_editor_preview_tasks :: () {
name, orientation, found := get_trile_at(*curworld.world, xx px, xx py, xx pz); 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 ""); cursor_trile := ifx found then name else (ifx editor_current_trile then editor_current_trile.name else "");
if cursor_trile != "" { 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: [..]Trile_Instance;
positions.allocator = temp; 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: Rendering_Task_Trile;
task.trile = cursor_trile; task.trile = cursor_trile;
task.positions = positions; task.positions = positions;
task.worldConf = *curworld.world.conf; task.worldConf = *curworld.world.conf;
task.preview_mode = 1; 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); add_rendering_task(task);
} }
return; return;
@ -664,7 +666,8 @@ create_level_editor_preview_tasks :: () {
positions: [..]Vector4; positions: [..]Vector4;
positions.allocator = temp; positions.allocator = temp;
ori := cast(float) get_current_orientation(); ori_u8 := get_current_orientation();
ori := cast(float) ori_u8;
if current_tool_mode == .POINT { if current_tool_mode == .POINT {
array_add(*positions, .{cast(float)px, cast(float)py, cast(float)pz, ori}); 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) is_delete := (current_tool_mode == .AREA && area_active && area_delete)
|| (current_tool_mode == .LINE && line_active && line_delete); || (current_tool_mode == .LINE && line_active && line_delete);
task: Rendering_Task_Trile; chunk_groups: [..] struct { key: Chunk_Key; instances: [..]Trile_Instance; };
task.trile = editor_current_trile.name; chunk_groups.allocator = temp;
// task.positions = positions; for pos : positions {
task.worldConf = *curworld.world.conf; wx := cast(s32) pos.x; wy := cast(s32) pos.y; wz := cast(s32) pos.z;
task.preview_mode = ifx is_delete then cast(s32)2 else cast(s32)1; ck := world_to_chunk_coord(wx, wy, wz);
add_rendering_task(task); 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) { get_trile_at :: (world: *World, wx: s32, wy: s32, wz: s32) -> (name: string, orientation: u8, found: bool) {

View File

@ -1,7 +1,7 @@
Camera :: struct { Camera :: struct {
fov : float = 75.0 * 3.141 / 180.0; fov : float = 75.0 * 3.141 / 180.0;
near : float = 1.0; near : float = 0.5;
far : float = 20.0; far : float = 2000.0;
position : Vector3 = .{2, 2, 2}; position : Vector3 = .{2, 2, 2};
target : Vector3 = .{0, 0, 0}; target : Vector3 = .{0, 0, 0};
} }

View File

@ -46,7 +46,7 @@ Rendering_Task_Billboard :: struct {
t.type = .BILLBOARD; t.type = .BILLBOARD;
position : Vector3; position : Vector3;
animation : *Animation; animation : *Animation;
frame : s32; frame : s32;
flipX : bool; flipX : bool;
flipY : bool; flipY : bool;
faceDir : Vector3 = .{-100, -100, -100}; faceDir : Vector3 = .{-100, -100, -100};

View File

@ -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) { invalidate_buried_around :: (world: *World, wx: s32, wy: s32, wz: s32) {
recompute_buried_at_cell(world, wx, wy, wz); recompute_buried_at_cell(world, wx, wy, wz);
for axis: 0..5 { for axis: 0..5 {