Skip to content

Commit

Permalink
fix hack to stop busted animation when minimized - just bounds check …
Browse files Browse the repository at this point in the history
…the content rectangle
  • Loading branch information
ryanfleury committed Jan 7, 2025
1 parent 6682613 commit 7fea553
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 36 deletions.
57 changes: 22 additions & 35 deletions src/raddbg/raddbg_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,18 +206,6 @@ rd_entity_from_handle(RD_Handle handle)
return result;
}

internal RD_HandleList
rd_handle_list_from_entity_list(Arena *arena, RD_EntityList entities)
{
RD_HandleList result = {0};
for(RD_EntityNode *n = entities.first; n != 0; n = n->next)
{
RD_Handle handle = rd_handle_from_entity(n->entity);
rd_handle_list_push(arena, &result, handle);
}
return result;
}

//- rjf: entity recursion iterators

internal RD_EntityRec
Expand Down Expand Up @@ -6889,34 +6877,33 @@ rd_window_frame(RD_Window *ws)
////////////////////////////
//- rjf: animate panels
//
// TODO(rjf): @hack investigate why we were ever animating to a busted
// rectangle when minimized...
//
if(!os_window_is_minimized(ws->os))
{
F32 rate = rd_setting_val_from_code(RD_SettingCode_MenuAnimations).s32 ? 1 - pow_f32(2, (-50.f * rd_state->frame_dt)) : 1.f;
Vec2F32 content_rect_dim = dim_2f32(content_rect);
for(RD_Panel *panel = ws->root_panel; !rd_panel_is_nil(panel); panel = rd_panel_rec_depth_first_pre(panel).next)
if(content_rect_dim.x > 0 && content_rect_dim.y > 0)
{
Rng2F32 target_rect_px = rd_target_rect_from_panel(content_rect, ws->root_panel, panel);
Rng2F32 target_rect_pct = r2f32p(target_rect_px.x0/content_rect_dim.x,
target_rect_px.y0/content_rect_dim.y,
target_rect_px.x1/content_rect_dim.x,
target_rect_px.y1/content_rect_dim.y);
if(abs_f32(target_rect_pct.x0 - panel->animated_rect_pct.x0) > 0.005f ||
abs_f32(target_rect_pct.y0 - panel->animated_rect_pct.y0) > 0.005f ||
abs_f32(target_rect_pct.x1 - panel->animated_rect_pct.x1) > 0.005f ||
abs_f32(target_rect_pct.y1 - panel->animated_rect_pct.y1) > 0.005f)
{
rd_request_frame();
}
panel->animated_rect_pct.x0 += rate * (target_rect_pct.x0 - panel->animated_rect_pct.x0);
panel->animated_rect_pct.y0 += rate * (target_rect_pct.y0 - panel->animated_rect_pct.y0);
panel->animated_rect_pct.x1 += rate * (target_rect_pct.x1 - panel->animated_rect_pct.x1);
panel->animated_rect_pct.y1 += rate * (target_rect_pct.y1 - panel->animated_rect_pct.y1);
if(ws->frames_alive < 5 || is_changing_panel_boundaries)
for(RD_Panel *panel = ws->root_panel; !rd_panel_is_nil(panel); panel = rd_panel_rec_depth_first_pre(panel).next)
{
panel->animated_rect_pct = target_rect_pct;
Rng2F32 target_rect_px = rd_target_rect_from_panel(content_rect, ws->root_panel, panel);
Rng2F32 target_rect_pct = r2f32p(target_rect_px.x0/content_rect_dim.x,
target_rect_px.y0/content_rect_dim.y,
target_rect_px.x1/content_rect_dim.x,
target_rect_px.y1/content_rect_dim.y);
if(abs_f32(target_rect_pct.x0 - panel->animated_rect_pct.x0) > 0.005f ||
abs_f32(target_rect_pct.y0 - panel->animated_rect_pct.y0) > 0.005f ||
abs_f32(target_rect_pct.x1 - panel->animated_rect_pct.x1) > 0.005f ||
abs_f32(target_rect_pct.y1 - panel->animated_rect_pct.y1) > 0.005f)
{
rd_request_frame();
}
panel->animated_rect_pct.x0 += rate * (target_rect_pct.x0 - panel->animated_rect_pct.x0);
panel->animated_rect_pct.y0 += rate * (target_rect_pct.y0 - panel->animated_rect_pct.y0);
panel->animated_rect_pct.x1 += rate * (target_rect_pct.x1 - panel->animated_rect_pct.x1);
panel->animated_rect_pct.y1 += rate * (target_rect_pct.y1 - panel->animated_rect_pct.y1);
if(ws->frames_alive < 5 || is_changing_panel_boundaries)
{
panel->animated_rect_pct = target_rect_pct;
}
}
}
}
Expand Down
1 change: 0 additions & 1 deletion src/raddbg/raddbg_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,6 @@ internal B32 rd_entity_is_nil(RD_Entity *entity);
internal U64 rd_index_from_entity(RD_Entity *entity);
internal RD_Handle rd_handle_from_entity(RD_Entity *entity);
internal RD_Entity *rd_entity_from_handle(RD_Handle handle);
internal RD_HandleList rd_handle_list_from_entity_list(Arena *arena, RD_EntityList entities);

//- rjf: entity recursion iterators
internal RD_EntityRec rd_entity_rec_depth_first(RD_Entity *entity, RD_Entity *subtree_root, U64 sib_off, U64 child_off);
Expand Down

0 comments on commit 7fea553

Please sign in to comment.