panning & zooming

This commit is contained in:
jacob 2025-12-17 10:33:11 -06:00
parent 81990f81a4
commit 2cf7208920
3 changed files with 212 additions and 216 deletions

View File

@ -311,7 +311,7 @@ CLD_GjkData CLD_GjkDataFromShapes(CLD_Shape *shape0, CLD_Shape *shape1, Xform xf
////////////////////////////////////////////////////////////
//~ Epa
/* Expands upon result of GJK calculation to determine collision normal &
/* Expands upon result of GJK computation to determine collision normal &
* closest edge when shapes are overlapping
*/

View File

@ -40,21 +40,6 @@ void V_TickForever(WaveLaneCtx *lane)
//////////////////////////////
//- State
Struct(Persist)
{
V_CommandsWidget commands_widget;
b32 edit_mode;
Vec2 edit_camera_pos;
f32 edit_camera_zoom;
b32 ui_debug;
b32 show_command_palette;
b32 show_console;
};
Persist persist = Zi;
String window_restore = Zi;
/* Init shortcuts */
u64 shortcut_bins_count = 1024;
V_ShortcutBin *shortcut_bins = PushStructs(perm, V_ShortcutBin, shortcut_bins_count);
@ -86,22 +71,22 @@ void V_TickForever(WaveLaneCtx *lane)
//////////////////////////////
//- Swap in
if (IsSwappedIn())
{
TempArena scratch = BeginScratchNoConflict();
{
String swap_encoded = SwappedStateFromName(scratch.arena, Lit("pp_vis"));
BB_Buff bb = BB_BuffFromString(swap_encoded);
BB_Reader br = BB_ReaderFromBuff(&bb);
String swap_str = BB_ReadString(scratch.arena, &br);
if (swap_str.len == sizeof(Persist))
{
CopyBytes(&persist, swap_str.text, swap_str.len);
}
window_restore = BB_ReadString(perm, &br);
}
EndScratch(scratch);
}
// if (IsSwappedIn())
// {
// TempArena scratch = BeginScratchNoConflict();
// {
// String swap_encoded = SwappedStateFromName(scratch.arena, Lit("pp_vis"));
// BB_Buff bb = BB_BuffFromString(swap_encoded);
// BB_Reader br = BB_ReaderFromBuff(&bb);
// String swap_str = BB_ReadString(scratch.arena, &br);
// if (swap_str.len == sizeof(Persist))
// {
// CopyBytes(&persist, swap_str.text, swap_str.len);
// }
// window_restore = BB_ReadString(perm, &br);
// }
// EndScratch(scratch);
// }
//////////////////////////////
//- Begin vis loop
@ -109,9 +94,6 @@ void V_TickForever(WaveLaneCtx *lane)
b32 shutdown = 0;
while (!shutdown)
{
//////////////////////////////
//- Begin frame
u64 last_frame_idx = V.current_frame_idx;
u64 frame_idx = last_frame_idx + 1;
if (frame_idx >= countof(V.frames))
@ -119,10 +101,12 @@ void V_TickForever(WaveLaneCtx *lane)
frame_idx = 0;
}
V.current_frame_idx = frame_idx;
V_Frame *last_frame = &V.frames[last_frame_idx];
V_Frame *frame = &V.frames[frame_idx];
//////////////////////////////
//- Begin frame
{
Arena *old_arena = frame->arena;
Arena *old_dverts_arena = frame->dverts_arena;
@ -140,7 +124,16 @@ void V_TickForever(WaveLaneCtx *lane)
ResetArena(frame->dvert_idxs_arena);
G_ResetArena(frame->cl, frame->gpu_arena);
/* Persist state */
CopyBytes(frame->held_buttons, last_frame->held_buttons, sizeof(frame->held_buttons));
frame->commands_widget = last_frame->commands_widget;
frame->edit_mode = last_frame->edit_mode;
frame->ui_debug = last_frame->ui_debug;
frame->show_command_palette = last_frame->show_command_palette;
frame->show_console = last_frame->show_console;
frame->edit_camera_pos = last_frame->edit_camera_pos;
frame->edit_camera_zoom = last_frame->edit_camera_zoom;
frame->look = last_frame->look;
frame->time_ns = TimeNs();
frame->tick = last_frame->tick + 1;
@ -197,18 +190,18 @@ void V_TickForever(WaveLaneCtx *lane)
UI_FrameFlag ui_frame_flags = 0;
Vec4 swapchain_color = V_GetWidgetTheme().window_background_color;
ui_frame_flags |= UI_FrameFlag_Debug * !!persist.ui_debug;
ui_frame_flags |= UI_FrameFlag_Debug * !!frame->ui_debug;
ui_frame_flags |= UI_FrameFlag_Vsync * !!VSYNC;
UI_Frame *ui_frame = UI_BeginFrame(ui_frame_flags, swapchain_color);
WND_Frame window_frame = ui_frame->window_frame;
/* Restore window */
{
if (frame->tick == 1)
if (frame->window_restore.len > 0)
{
WND_PushCmd(window_frame, .kind = WND_CmdKind_Restore, .restore = window_restore);
WND_PushCmd(window_frame, .kind = WND_CmdKind_Restore, .restore = frame->window_restore);
}
window_restore = PushString(frame->arena, window_frame.restore);
frame->window_restore = PushString(frame->arena, window_frame.restore);
}
/* Set widget theme */
@ -221,14 +214,14 @@ void V_TickForever(WaveLaneCtx *lane)
UI_Key vis_box = UI_KeyF("vis box");
UI_Push(Parent, UI_BuildColumnEx(vis_box));
Vec2I32 draw_size = Zi;
{
/* TODO: Don't rely on ui report for draw size since it introduces one frame of delay when resizing */
UI_Report vis_rep = UI_ReportFromKey(vis_box);
draw_size = RoundVec2ToI32(DimsFromRng2(vis_rep.screen_rect));
frame->ui_dims = RoundVec2ToI32(DimsFromRng2(vis_rep.screen_rect));
}
draw_size.x = MaxI32(draw_size.x, 64);
draw_size.y = MaxI32(draw_size.y, 64);
frame->ui_dims.x = MaxI32(frame->ui_dims.x, 64);
frame->ui_dims.y = MaxI32(frame->ui_dims.y, 64);
frame->draw_dims = frame->ui_dims;
//////////////////////////////
//- Pop sim output
@ -301,57 +294,58 @@ void V_TickForever(WaveLaneCtx *lane)
//////////////////////////////
//- Update edit mode camera position
f32 zoom_rate = 2;
//////////////////////////////
//- Initialize world <-> draw <-> ui transforms
f32 zoom_rate = 1.75;
f32 min_zoom = 0.03;
f32 max_zoom = 50.0;
f32 world_size = 256;
// if (persist.edit_mode)
// {
// if (V.is_panning)
// {
// Vec2 pan_diff = SubVec2(V.pan_end, V.pan_start);
// persist.edit_camera_pos = pan_diff;
// }
// }
if (persist.edit_camera_zoom <= 0)
{
persist.edit_camera_zoom = 1;
}
persist.edit_camera_zoom = ClampF32(persist.edit_camera_zoom, min_zoom, max_zoom);
persist.edit_camera_pos.x = ClampF32(persist.edit_camera_pos.x, -world_size / 2, world_size / 2);
persist.edit_camera_pos.y = ClampF32(persist.edit_camera_pos.y, -world_size / 2, world_size / 2);
//////////////////////////////
//- Initialize camera
f32 meters_per_draw_width = 20;
/* World <-> ui */
frame->world_to_ui_xf = XformIdentity;
frame->ui_to_world_xf = XformIdentity;
{
f32 pos_lerp_ratio = 1;
f32 zoom_lerp_ratio = 1;
if (last_frame->tick > 0)
/* Determine target camera pos */
Vec2 target_camera_pos = Zi;
f32 target_camera_zoom = 0;
if (frame->edit_mode)
{
if (persist.edit_mode)
b32 pan_button = Button_M3;
frame->is_panning = frame->held_buttons[pan_button] != 0;
frame->edit_camera_zoom *= PowF32(zoom_rate, -last_frame->zooms);
if (frame->edit_camera_zoom <= 0)
{
pos_lerp_ratio = 30.0 * frame->dt;
zoom_lerp_ratio = 30.0 * frame->dt;
frame->edit_camera_zoom = 1;
}
/* Offset edit camera based on cursor if panning / zooming */
if (last_frame->edit_mode && (last_frame->zooms != 0 || (frame->is_panning && last_frame->is_panning)))
{
Xform last_frame_edit_to_ui_xf = Zi;
Xform edit_to_ui_xf = Zi;
{
f32 last_edit_camera_scale = (f32)last_frame->draw_dims.x / (meters_per_draw_width * last_frame->edit_camera_zoom);
f32 edit_camera_scale = (f32)frame->draw_dims.x / (meters_per_draw_width * frame->edit_camera_zoom);
last_frame_edit_to_ui_xf = XformFromScale(VEC2(last_edit_camera_scale, last_edit_camera_scale));
last_frame_edit_to_ui_xf = TranslateXform(last_frame_edit_to_ui_xf, NegVec2(last_frame->edit_camera_pos));
last_frame_edit_to_ui_xf = WorldTranslateXform(last_frame_edit_to_ui_xf, MulVec2(Vec2FromVec(frame->draw_dims), 0.5));
edit_to_ui_xf = XformFromScale(VEC2(edit_camera_scale, edit_camera_scale));
edit_to_ui_xf = TranslateXform(edit_to_ui_xf, NegVec2(frame->edit_camera_pos));
edit_to_ui_xf = WorldTranslateXform(edit_to_ui_xf, MulVec2(Vec2FromVec(frame->draw_dims), 0.5));
}
Vec2 last_target_cursor = MulXformV2(InvertXform(last_frame_edit_to_ui_xf), last_frame->ui_cursor);
Vec2 target_cursor = MulXformV2(InvertXform(edit_to_ui_xf), ui_frame->cursor_pos);
Vec2 diff = SubVec2(last_target_cursor, target_cursor);
frame->edit_camera_pos = AddVec2(frame->edit_camera_pos, diff);
}
frame->edit_camera_zoom = ClampF32(frame->edit_camera_zoom, min_zoom, max_zoom);
frame->edit_camera_pos.x = ClampF32(frame->edit_camera_pos.x, -world_size / 2, world_size / 2);
frame->edit_camera_pos.y = ClampF32(frame->edit_camera_pos.y, -world_size / 2, world_size / 2);
target_camera_pos = frame->edit_camera_pos;
target_camera_zoom = frame->edit_camera_zoom;
}
else
{
pos_lerp_ratio = 20.0 * frame->dt;
zoom_lerp_ratio = 20.0 * frame->dt;
}
}
// if (persist.edit_mode && V.is_panning)
// {
// persist.edit_camera_pos = V.pan_begin;
// }
Vec2 target_camera_pos = persist.edit_camera_pos;
f32 target_camera_zoom = persist.edit_camera_zoom;
{
if (!persist.edit_mode)
{
Vec2 look_ratio = Zi;
look_ratio.y = 0.25;
@ -361,62 +355,59 @@ void V_TickForever(WaveLaneCtx *lane)
target_camera_pos = AddVec2(target_camera_pos, MulVec2Vec2(player->look, look_ratio));
target_camera_zoom = 1;
}
if (target_camera_zoom <= 0)
target_camera_pos.x = ClampF32(target_camera_pos.x, -world_size / 2, world_size / 2);
target_camera_pos.y = ClampF32(target_camera_pos.y, -world_size / 2, world_size / 2);
target_camera_zoom = ClampF32(target_camera_zoom, min_zoom, max_zoom);
/* Create world <-> ui xforms */
{
target_camera_zoom = 1;
}
}
frame->camera_pos = LerpVec2(last_frame->camera_pos, target_camera_pos, pos_lerp_ratio);
frame->camera_zoom = LerpF32(last_frame->camera_zoom, target_camera_zoom, zoom_lerp_ratio);
frame->camera_zoom = ClampF32(frame->camera_zoom, min_zoom, max_zoom);
meters_per_draw_width /= frame->camera_zoom;
}
//////////////////////////////
//- Initialize V.world <-> draw <-> ui transforms
/* World <-> draw */
Xform world_to_draw_xf = XformIdentity;
Xform draw_to_world_xf = XformIdentity;
f32 lerp_ratio = 15.0 * frame->dt;
if (last_frame->tick == 0)
{
Vec2 scale = Zi;
scale.x = (f32)draw_size.x / meters_per_draw_width;
scale.y = scale.x;
world_to_draw_xf = XformFromScale(scale);
world_to_draw_xf = TranslateXform(world_to_draw_xf, NegVec2(frame->camera_pos));
world_to_draw_xf = WorldTranslateXform(world_to_draw_xf, MulVec2(Vec2FromVec(draw_size), 0.5));
draw_to_world_xf = InvertXform(world_to_draw_xf);
lerp_ratio = 1;
}
else if (frame->edit_mode)
{
lerp_ratio = 40.0 * frame->dt;
}
frame->camera_pos = LerpVec2(last_frame->camera_pos, target_camera_pos, lerp_ratio);
frame->camera_zoom = LerpF32(last_frame->camera_zoom, target_camera_zoom, lerp_ratio);
{
f32 camera_scale = (f32)frame->draw_dims.x / (meters_per_draw_width * frame->camera_zoom);
frame->world_to_ui_xf = XformFromScale(VEC2(camera_scale, camera_scale));
frame->world_to_ui_xf = TranslateXform(frame->world_to_ui_xf, NegVec2(frame->camera_pos));
frame->world_to_ui_xf = WorldTranslateXform(frame->world_to_ui_xf, MulVec2(Vec2FromVec(frame->draw_dims), 0.5));
frame->ui_to_world_xf = InvertXform(frame->world_to_ui_xf);
}
}
}
/* Draw <-> ui */
Xform draw_to_ui_xf = XformIdentity;
Xform ui_to_draw_xf = XformIdentity;
frame->draw_to_ui_xf = XformIdentity;
frame->ui_to_draw_xf = XformIdentity;
{
ui_to_draw_xf = InvertXform(draw_to_ui_xf);
frame->ui_to_draw_xf = InvertXform(frame->draw_to_ui_xf);
}
/* World <-> ui */
Xform world_to_ui_xf = XformIdentity;
Xform ui_to_world_xf = XformIdentity;
/* World <-> draw */
frame->world_to_draw_xf = XformIdentity;
frame->draw_to_world_xf = XformIdentity;
{
world_to_ui_xf = MulXform(world_to_draw_xf, draw_to_ui_xf);
ui_to_world_xf = InvertXform(world_to_ui_xf);
frame->world_to_draw_xf = MulXform(frame->world_to_ui_xf, frame->ui_to_draw_xf);
frame->draw_to_world_xf = InvertXform(frame->world_to_draw_xf);
}
/* Cursors */
Vec2 ui_cursor = ui_frame->cursor_pos;
Vec2 draw_cursor = MulXformV2(ui_to_draw_xf, ui_cursor);
Vec2 world_cursor = MulXformV2(ui_to_world_xf, ui_cursor);
frame->ui_cursor = ui_frame->cursor_pos;
frame->draw_cursor = MulXformV2(frame->ui_to_draw_xf, frame->ui_cursor);
frame->world_cursor = MulXformV2(frame->ui_to_world_xf, frame->ui_cursor);
//////////////////////////////
//- Build command palette
if (persist.show_command_palette)
if (frame->show_command_palette)
{
V_BeginCommandsWidget(&persist.commands_widget);
V_BeginCommandsWidget(&frame->commands_widget);
{
for (u64 i = 0; i < countof(V_cmd_descs); ++i)
{
@ -427,7 +418,7 @@ void V_TickForever(WaveLaneCtx *lane)
item_desc.display_name = desc.display_name;
/* FIXME: Attach active shortcuts instead of default hotkeys */
CopyStructs(item_desc.hotkeys, desc.default_hotkeys, MinU32(countof(item_desc.hotkeys), countof(desc.default_hotkeys)));
if (V_PushCommandsWidgetItem(&persist.commands_widget, item_desc).pressed > 0)
if (V_PushCommandsWidgetItem(&frame->commands_widget, item_desc).pressed > 0)
{
V_CmdNode *cmd_node = PushStruct(frame->arena, V_CmdNode);
cmd_node->cmd.name = desc.name;
@ -437,13 +428,13 @@ void V_TickForever(WaveLaneCtx *lane)
}
}
}
V_EndCommandsWidget(&persist.commands_widget);
V_EndCommandsWidget(&frame->commands_widget);
}
//////////////////////////////
//- Build console UI
if (persist.show_console)
if (frame->show_console)
{
b32 minimized = 0;
V_BuildConsoleWidget(minimized);
@ -452,7 +443,7 @@ void V_TickForever(WaveLaneCtx *lane)
//////////////////////////////
//- Build debug info UI
if (persist.show_console)
if (frame->show_console)
{
UI_PushCP(UI_BuildColumn());
{
@ -483,14 +474,13 @@ void V_TickForever(WaveLaneCtx *lane)
//////////////////////////////
//- Build edit mode UI
if (persist.edit_mode)
if (frame->edit_mode)
{
}
//////////////////////////////
//- Process vis commands
i32 edit_zooms = 0;
for (V_CmdNode *cmd_node = first_cmd_node; cmd_node; cmd_node = cmd_node->next)
{
String cmd_name = cmd_node->cmd.name;
@ -514,28 +504,28 @@ void V_TickForever(WaveLaneCtx *lane)
case V_CmdKind_toggle_command_palette:
{
persist.show_command_palette = !persist.show_command_palette;
frame->show_command_palette = !frame->show_command_palette;
} break;
case V_CmdKind_zoom_in:
{
if (persist.edit_mode)
if (frame->edit_mode)
{
edit_zooms += 1;
frame->zooms += 1;
}
} break;
case V_CmdKind_zoom_out:
{
if (persist.edit_mode)
if (frame->edit_mode)
{
edit_zooms -= 1;
frame->zooms -= 1;
}
} break;
case V_CmdKind_toggle_edit_mode:
{
b32 new = !persist.edit_mode;
b32 new = !frame->edit_mode;
if (new)
{
LogInfoF("Enabled edit mode");
@ -544,22 +534,18 @@ void V_TickForever(WaveLaneCtx *lane)
{
LogInfoF("Disabled edit mode");
}
persist.edit_mode = new;
frame->edit_mode = new;
} break;
case V_CmdKind_toggle_ui_debug:
{
persist.ui_debug = !persist.ui_debug;
frame->ui_debug = !frame->ui_debug;
} break;
case V_CmdKind_toggle_console:
{
b32 new = !persist.show_console;
if (new)
{
LogInfoF("Enabled console");
}
persist.show_console = new;
b32 new = !frame->show_console;
frame->show_console = new;
} break;
case V_CmdKind_toggle_fullscreen:
@ -583,33 +569,9 @@ void V_TickForever(WaveLaneCtx *lane)
}
//////////////////////////////
//- Update edit camera
//- Compute movement & look
if (persist.edit_mode)
{
b32 pan_button = Button_M3;
b32 old_is_panning = V.is_panning;
V.is_panning = frame->held_buttons[pan_button] != 0;
b32 is_begin_panning = V.is_panning && !old_is_panning;
if (is_begin_panning)
{
V.ui_pan_begin_cursor = ui_cursor;
}
if (V.is_panning)
{
Vec2 ui_pan_diff = SubVec2(ui_cursor, V.ui_pan_begin_cursor);
Vec2 world_pan_diff = MulXformBasisV2(ui_to_world_xf, ui_pan_diff);
persist.edit_camera_pos = SubVec2(persist.edit_camera_pos, world_pan_diff);
V.ui_pan_begin_cursor = ui_cursor;
}
persist.edit_camera_zoom *= PowF32(zoom_rate, edit_zooms);
}
//////////////////////////////
//- Calculate movement & look
frame->look = last_frame->look;
if (!persist.edit_mode)
if (!frame->edit_mode)
{
Vec2 move = Zi;
{
@ -622,7 +584,7 @@ void V_TickForever(WaveLaneCtx *lane)
{
S_Ent *player = S_EntFromKey(&V.lookup, V.player_key);
Vec2 center = MulXformV2(player->xf, player->local_shape.centroid);
look = SubVec2(world_cursor, center);
look = SubVec2(frame->world_cursor, center);
}
frame->move = move;
frame->look = look;
@ -686,7 +648,7 @@ void V_TickForever(WaveLaneCtx *lane)
for (S_Ent *ent = S_FirstEnt(&iter, V.world); ent->active; ent = S_NextEnt(&iter))
{
Xform ent_to_world_xf = ent->xf;
Xform ent_to_draw_xf = MulXform(world_to_draw_xf, ent_to_world_xf);
Xform ent_to_draw_xf = MulXform(frame->world_to_draw_xf, ent_to_world_xf);
b32 is_visible = 1;
if (is_visible)
@ -726,13 +688,13 @@ void V_TickForever(WaveLaneCtx *lane)
G_ResourceHandle draw_target = G_PushTexture2D(
frame->gpu_arena,
G_Format_R16G16B16A16_Float,
draw_size,
frame->draw_dims,
G_Layout_DirectQueue_ShaderReadWrite,
.flags = G_ResourceFlag_AllowShaderReadWrite | G_ResourceFlag_AllowRenderTarget
);
G_Texture2DRef draw_target_ro = G_PushTexture2DRef(frame->gpu_arena, draw_target);
G_RWTexture2DRef draw_target_rw = G_PushRWTexture2DRef(frame->gpu_arena, draw_target);
Rng3 viewport = RNG3(VEC3(0, 0, 0), VEC3(draw_size.x, draw_size.y, 1));
Rng3 viewport = RNG3(VEC3(0, 0, 0), VEC3(frame->draw_dims.x, frame->draw_dims.y, 1));
Rng2 scissor = RNG2(VEC2(viewport.p0.x, viewport.p0.y), VEC2(viewport.p1.x, viewport.p1.y));
/* Verts */
@ -744,11 +706,11 @@ void V_TickForever(WaveLaneCtx *lane)
/* Params */
V_DParams params = Zi;
{
params.target_size = draw_size;
params.target_size = frame->draw_dims;
params.target_ro = draw_target_ro;
params.target_rw = draw_target_rw;
params.shape_verts = dverts_ro;
params.target_cursor_pos = draw_cursor;
params.target_cursor_pos = frame->draw_cursor;
params.background_color_a = LinearFromSrgb(VEC4(0.30, 0.30, 0.30, 1));
params.background_color_b = LinearFromSrgb(VEC4(0.15, 0.15, 0.15, 1));
@ -758,8 +720,8 @@ void V_TickForever(WaveLaneCtx *lane)
params.world_size = world_size;
params.world_to_draw_xf = world_to_draw_xf;
params.draw_to_world_xf = draw_to_world_xf;
params.world_to_draw_xf = frame->world_to_draw_xf;
params.draw_to_world_xf = frame->draw_to_world_xf;
}
G_ResourceHandle params_buff = G_PushBufferFromString(frame->gpu_arena, frame->cl, StringFromStruct(&params));
G_StructuredBufferRef params_ro = G_PushStructuredBufferRef(frame->gpu_arena, params_buff, V_DParams);
@ -775,7 +737,7 @@ void V_TickForever(WaveLaneCtx *lane)
/* Backdrop pass */
{
G_Compute(frame->cl, V_BackdropCS, V_BackdropCSThreadSizeFromTexSize(draw_size));
G_Compute(frame->cl, V_BackdropCS, V_BackdropCSThreadSizeFromTexSize(frame->draw_dims));
}
//////////////////////////////
@ -801,7 +763,7 @@ void V_TickForever(WaveLaneCtx *lane)
Rng2 uv = Zi;
uv.p0 = Vec2FromVec(viewport.p0);
uv.p1 = Vec2FromVec(viewport.p1);
uv = DivRng2Vec2(uv, Vec2FromVec(draw_size));
uv = DivRng2Vec2(uv, Vec2FromVec(frame->draw_dims));
UI_SetRawTexture(vis_box, draw_target_ro, uv);
}
}
@ -819,20 +781,20 @@ void V_TickForever(WaveLaneCtx *lane)
//////////////////////////////
//- Swap out
if (IsSwappingOut())
{
TempArena scratch = BeginScratchNoConflict();
u64 max_size = Mebi(64);
u8 *bytes = PushStructsNoZero(scratch.arena, u8, max_size);
BB_Buff bb = BB_BuffFromString(STRING(max_size, bytes));
{
BB_Writer bw = BB_WriterFromBuff(&bb);
BB_WriteString(&bw, StringFromStruct(&persist));
BB_WriteString(&bw, window_restore);
WriteSwappedState(Lit("pp_vis"), STRING(BB_GetNumBytesWritten(&bw), BB_GetWrittenRaw(&bw)));
}
EndScratch(scratch);
}
// if (IsSwappingOut())
// {
// TempArena scratch = BeginScratchNoConflict();
// u64 max_size = Mebi(64);
// u8 *bytes = PushStructsNoZero(scratch.arena, u8, max_size);
// BB_Buff bb = BB_BuffFromString(STRING(max_size, bytes));
// {
// BB_Writer bw = BB_WriterFromBuff(&bb);
// BB_WriteString(&bw, StringFromStruct(&persist));
// BB_WriteString(&bw, window_restore);
// WriteSwappedState(Lit("pp_vis"), STRING(BB_GetNumBytesWritten(&bw), BB_GetWrittenRaw(&bw)));
// }
// EndScratch(scratch);
// }
FetchAddFence(&V.shutdown_complete, 1);
}

View File

@ -82,20 +82,57 @@ Struct(V_Frame)
Arena *dverts_arena;
Arena *dvert_idxs_arena;
G_ArenaHandle gpu_arena;
Button held_buttons[Button_Count];
Vec2 camera_pos;
f32 camera_zoom;
Vec2 move;
Vec2 look;
G_CommandListHandle cl;
i64 tick;
i64 time_ns;
i64 dt_ns;
f64 dt;
G_CommandListHandle cl;
Button held_buttons[Button_Count];
V_CommandsWidget commands_widget;
String window_restore;
i32 zooms;
Vec2I32 ui_dims;
Vec2I32 draw_dims;
/* Modes */
b32 edit_mode;
b32 ui_debug;
b32 show_command_palette;
b32 show_console;
/* Edit camera */
b32 is_panning;
Vec2 edit_camera_pos;
f32 edit_camera_zoom;
/* Camera */
Vec2 camera_pos;
f32 camera_zoom;
/* World <-> ui */
Xform world_to_ui_xf;
Xform ui_to_world_xf;
/* Draw <-> ui */
Xform draw_to_ui_xf;
Xform ui_to_draw_xf;
/* World <-> draw */
Xform world_to_draw_xf;
Xform draw_to_world_xf;
/* Cursors */
Vec2 ui_cursor;
Vec2 draw_cursor;
Vec2 world_cursor;
/* Control */
Vec2 move;
Vec2 look;
};
Struct(V_Ctx)
@ -105,9 +142,6 @@ Struct(V_Ctx)
S_Lookup lookup;
S_Key player_key;
b32 is_panning;
Vec2 ui_pan_begin_cursor;
Atomic32 shutdown;
Fence shutdown_complete;