overshoot UI animation targets. add vsync tweak.
This commit is contained in:
parent
0224b27902
commit
8fa00607cb
@ -86,6 +86,5 @@
|
||||
|
||||
// TODO: Move these to user-configurable settings
|
||||
|
||||
#define VSYNC 1
|
||||
#define AUDIO_ENABLED 0
|
||||
#define FPS_LIMIT 300
|
||||
|
||||
@ -637,7 +637,7 @@ void S_TickForever(WaveLaneCtx *lane)
|
||||
S_Shape shape0 = constraint->shape0;
|
||||
S_Shape shape1 = constraint->shape1;
|
||||
|
||||
S_DebugDrawShape(shape1, Color_Cyan);
|
||||
S_DebugDrawShape(shape1, Color_Orange);
|
||||
|
||||
// TODO: Real dir
|
||||
Vec2 shape_dir = NormVec2(SubVec2(shape1.centroid, shape0.centroid));
|
||||
|
||||
@ -485,10 +485,8 @@ void V_TickForever(WaveLaneCtx *lane)
|
||||
V_WidgetTheme theme = V_GetWidgetTheme();
|
||||
|
||||
UI_FrameFlag ui_frame_flags = 0;
|
||||
Vec4 swapchain_color = theme.col.window_bg;
|
||||
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);
|
||||
UI_Frame *ui_frame = UI_BeginFrame(ui_frame_flags);
|
||||
WND_Frame window_frame = ui_frame->window_frame;
|
||||
WND_SetCursor(window_frame, WND_CursorKind_Default);
|
||||
|
||||
@ -2587,6 +2585,8 @@ void V_TickForever(WaveLaneCtx *lane)
|
||||
//////////////////////////////
|
||||
//- End frame
|
||||
|
||||
i32 vsync = !!TweakBool("Vsync", 1);
|
||||
|
||||
{
|
||||
Arena *old_arena = sim_output->arena;
|
||||
ZeroStruct(sim_output);
|
||||
@ -2596,7 +2596,7 @@ void V_TickForever(WaveLaneCtx *lane)
|
||||
|
||||
G_CommitCommandList(frame->cl);
|
||||
|
||||
UI_EndFrame(ui_frame);
|
||||
UI_EndFrame(ui_frame, vsync);
|
||||
}
|
||||
|
||||
FetchAddFence(&V.shutdown_complete, 1);
|
||||
|
||||
@ -551,7 +551,7 @@ UI_BoxReports UI_ReportsFromKey(UI_Key key)
|
||||
////////////////////////////////////////////////////////////
|
||||
//~ Begin frame
|
||||
|
||||
UI_Frame *UI_BeginFrame(UI_FrameFlag frame_flags, Vec4 swapchain_color)
|
||||
UI_Frame *UI_BeginFrame(UI_FrameFlag frame_flags)
|
||||
{
|
||||
|
||||
//////////////////////////////
|
||||
@ -619,7 +619,6 @@ UI_Frame *UI_BeginFrame(UI_FrameFlag frame_flags, Vec4 swapchain_color)
|
||||
}
|
||||
|
||||
frame->frame_flags = frame_flags;
|
||||
frame->swapchain_color = swapchain_color;
|
||||
|
||||
//////////////////////////////
|
||||
//- Process controller events
|
||||
@ -791,37 +790,44 @@ UI_Frame *UI_BeginFrame(UI_FrameFlag frame_flags, Vec4 swapchain_color)
|
||||
}
|
||||
|
||||
// Update box reports
|
||||
for (u64 pre_index = 0; pre_index < UI.boxes_count; ++pre_index)
|
||||
{
|
||||
UI_Box *box = last_frame->boxes_pre[pre_index];
|
||||
UI_BoxReport *report = &box->reports.draw;
|
||||
report->is_hot = box == hot_box;
|
||||
|
||||
f32 target_exists = box->last_build_tick >= (frame->tick - 1);
|
||||
f32 target_hovered = report->is_hovered;
|
||||
f32 target_hot = report->is_hot;
|
||||
f32 target_active = box == active_box;
|
||||
f64 target_misc = box->desc.misc;
|
||||
|
||||
// TODO: Configurable per-box blend rates
|
||||
f32 exists_blend_rate = (30 * frame->dt);
|
||||
f32 hot_blend_rate = target_hot == 1 ? 1 : (15 * frame->dt);
|
||||
f32 active_blend_rate = target_active == 1 ? 1 : (15 * frame->dt);
|
||||
f32 hovered_blend_rate = target_hovered == 1 ? 1 : (15 * frame->dt);
|
||||
// f64 misc_blend_rate = (30 * frame->dt);
|
||||
f64 misc_blend_rate = 1;
|
||||
|
||||
report->exists = LerpF32(report->exists, target_exists, exists_blend_rate);
|
||||
report->hot = LerpF32(report->hot, target_hot, hot_blend_rate);
|
||||
report->active = LerpF32(report->active, target_active, active_blend_rate);
|
||||
report->hovered = LerpF32(report->hovered, target_hovered, hovered_blend_rate);
|
||||
report->misc = LerpF32(report->misc, target_misc, misc_blend_rate);
|
||||
|
||||
report->screen_rect = box->screen_rect;
|
||||
report->screen_anchor = box->screen_anchor;
|
||||
if (mouse_downs > 0)
|
||||
f32 lower_target = TweakFloat("UI lower blend target", -0.05, -1, 0);
|
||||
f32 upper_target = TweakFloat("UI upper blend target", 1.05, 1, 10);
|
||||
for (u64 pre_index = 0; pre_index < UI.boxes_count; ++pre_index)
|
||||
{
|
||||
box->reports.drag = *report;
|
||||
UI_Box *box = last_frame->boxes_pre[pre_index];
|
||||
UI_BoxReport *report = &box->reports.draw;
|
||||
report->is_hot = box == hot_box;
|
||||
|
||||
f32 target_exists = (box->last_build_tick >= (frame->tick - 1)) ? upper_target : lower_target;
|
||||
f32 target_hovered = report->is_hovered ? Inf : lower_target;
|
||||
f32 target_hot = report->is_hot ? Inf : lower_target;
|
||||
f32 target_active = box == active_box ? Inf : lower_target;
|
||||
f64 target_misc = box->desc.misc;
|
||||
|
||||
|
||||
|
||||
|
||||
// TODO: Configurable per-box blend rates
|
||||
f32 exists_blend_rate = (30 * frame->dt);
|
||||
f32 hot_blend_rate = (15 * frame->dt);
|
||||
f32 active_blend_rate = (15 * frame->dt);
|
||||
f32 hovered_blend_rate = (15 * frame->dt);
|
||||
// f64 misc_blend_rate = (30 * frame->dt);
|
||||
f64 misc_blend_rate = 1;
|
||||
|
||||
report->exists = SaturateF32(LerpF32(report->exists, target_exists, exists_blend_rate));
|
||||
report->hot = SaturateF32(LerpF32(report->hot, target_hot, hot_blend_rate));
|
||||
report->active = SaturateF32(LerpF32(report->active, target_active, active_blend_rate));
|
||||
report->hovered = SaturateF32(LerpF32(report->hovered, target_hovered, hovered_blend_rate));
|
||||
report->misc = SaturateF32(LerpF32(report->misc, target_misc, misc_blend_rate));
|
||||
|
||||
report->screen_rect = box->screen_rect;
|
||||
report->screen_anchor = box->screen_anchor;
|
||||
if (mouse_downs > 0)
|
||||
{
|
||||
box->reports.drag = *report;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -904,7 +910,7 @@ GC_Run UI_ScaleRun(Arena *arena, GC_Run unscaled_run, Vec2 scale)
|
||||
////////////////////////////////////////////////////////////
|
||||
//~ End frame
|
||||
|
||||
void UI_EndFrame(UI_Frame *frame)
|
||||
void UI_EndFrame(UI_Frame *frame, i32 vsync)
|
||||
{
|
||||
TempArena scratch = BeginScratchNoConflict();
|
||||
UI_BoxIter box_iter = Zi;
|
||||
@ -1128,16 +1134,6 @@ void UI_EndFrame(UI_Frame *frame)
|
||||
{
|
||||
box->solved_scale = MulVec2Vec2(parent->solved_scale, box->solved_scale);
|
||||
}
|
||||
|
||||
f32 scale_snap = TweakFloat("UI scale snap threshold", 0.0, 0, 0.01, .precision = 6);
|
||||
if (AbsF32(1.0 - box->solved_scale.x) < scale_snap)
|
||||
{
|
||||
box->solved_scale.x = 1;
|
||||
}
|
||||
if (AbsF32(1.0 - box->solved_scale.y) < scale_snap)
|
||||
{
|
||||
box->solved_scale.y = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1785,7 +1781,7 @@ void UI_EndFrame(UI_Frame *frame)
|
||||
//- End frame
|
||||
|
||||
G_CommitCommandList(frame->cl);
|
||||
WND_EndFrame(frame->window_frame, VSYNC);
|
||||
WND_EndFrame(frame->window_frame, vsync);
|
||||
|
||||
EndScratch(scratch);
|
||||
}
|
||||
|
||||
@ -364,7 +364,6 @@ Enum(UI_FrameFlag)
|
||||
{
|
||||
UI_FrameFlag_None = 0,
|
||||
UI_FrameFlag_Debug = (1 << 0),
|
||||
UI_FrameFlag_Vsync = (1 << 1),
|
||||
};
|
||||
|
||||
Struct(UI_Frame)
|
||||
@ -391,7 +390,6 @@ Struct(UI_Frame)
|
||||
UI_Key active_box;
|
||||
|
||||
// Cmds
|
||||
Vec4 swapchain_color;
|
||||
UI_FrameFlag frame_flags;
|
||||
UI_CmdNode *first_cmd_node;
|
||||
UI_CmdNode *last_cmd_node;
|
||||
@ -523,7 +521,7 @@ UI_BoxReports UI_ReportsFromKey(UI_Key key);
|
||||
////////////////////////////////////////////////////////////
|
||||
//~ Begin frame
|
||||
|
||||
UI_Frame *UI_BeginFrame(UI_FrameFlag frame_flags, Vec4 swapchain_color);
|
||||
UI_Frame *UI_BeginFrame(UI_FrameFlag frame_flags);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
//~ Frame helpers
|
||||
@ -541,4 +539,4 @@ GC_Run UI_ScaleRun(Arena *arena, GC_Run unscaled_run, Vec2 scale);
|
||||
////////////////////////////////////////////////////////////
|
||||
//~ End frame
|
||||
|
||||
void UI_EndFrame(UI_Frame *frame);
|
||||
void UI_EndFrame(UI_Frame *frame, i32 vsync);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user