in-world death text

This commit is contained in:
jacob 2026-04-05 22:22:52 -05:00
parent fb1a1572e6
commit f17bdc9d76
9 changed files with 635 additions and 494 deletions

View File

@ -342,26 +342,6 @@ Vec4 SrgbFromLinear(Vec4 lin)
return result; return result;
} }
Vec4 SrgbFromHsv(f32 h, f32 s, f32 v)
{
h = ModF32(h, 360.0f);
if (h < 0)
{
h += 360.0f;
}
f32 c = v * s;
f32 x = c * (1.0f - AbsF32(ModF32(h / 60.0f, 2.0f) - 1.0f));
f32 m = v - c;
Vec4 result = VEC4(0, 0, 0, 1);
if (h < 60.0f) { result.r = c; result.g = x; result.b = 0; }
else if (h < 120.0f) { result.r = x; result.g = c; result.b = 0; }
else if (h < 180.0f) { result.r = 0; result.g = c; result.b = x; }
else if (h < 240.0f) { result.r = 0; result.g = x; result.b = c; }
else if (h < 300.0f) { result.r = x; result.g = 0; result.b = c; }
else { result.r = c; result.g = 0; result.b = x; }
return result;
}
Vec4 PremulFromLinear(Vec4 lin) Vec4 PremulFromLinear(Vec4 lin)
{ {
Vec4 result = Zi; Vec4 result = Zi;
@ -389,6 +369,60 @@ Vec4 LerpSrgb(Vec4 a, Vec4 b, f32 t)
return result; return result;
} }
Vec4 SrgbFromHsv(Hsv hsv)
{
f32 h = ModF32(hsv.h, 360);
f32 s = hsv.s;
f32 v = hsv.v;
if (h < 0)
{
h += 360;
}
f32 c = v * s;
f32 x = c * (1 - AbsF32(ModF32(h / 60, 2) - 1));
f32 m = v - c;
Vec4 result = VEC4(0, 0, 0, 1);
if (h < 60) { result.r = c; result.g = x; result.b = 0; }
else if (h < 120) { result.r = x; result.g = c; result.b = 0; }
else if (h < 180) { result.r = 0; result.g = c; result.b = x; }
else if (h < 240) { result.r = 0; result.g = x; result.b = c; }
else if (h < 300) { result.r = x; result.g = 0; result.b = c; }
else { result.r = c; result.g = 0; result.b = x; }
return result;
}
Hsv HsvFromSrgb(Vec4 srgb)
{
f32 r = srgb.r;
f32 g = srgb.g;
f32 b = srgb.b;
f32 max = MaxF32(r, MaxF32(g, b));
f32 min = MinF32(r, MinF32(g, b));
f32 delta = max - min;
Hsv result = Zi;
{
result.v = max;
if (max <= 0) {
result.s = 0;
} else {
result.s = delta / max;
}
if (delta <= 0) {
result.h = 0;
} else if (max == r) {
result.h = 60 * ModF32((g - b) / delta, 6);
} else if (max == g) {
result.h = 60 * (((b - r) / delta) + 2);
} else {
result.h = 60 * (((r - g) / delta) + 4);
}
if (result.h < 0) {
result.h += 360;
}
}
return result;
}
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
//~ Vec2 //~ Vec2

View File

@ -194,6 +194,15 @@ Union(Mat4x4)
f32 e[4][4]; f32 e[4][4];
}; };
////////////////////////////////////////////////////////////
//~ Color types
#define HSV(h, s, v) ((Hsv) { (h), (s), (v) })
Struct(Hsv)
{
f32 h, s, v;
};
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
//~ Min / max //~ Min / max
@ -339,13 +348,15 @@ f32 LinearFromSrgbF32(f32 srgb);
Vec4 LinearFromSrgb(Vec4 srgb); Vec4 LinearFromSrgb(Vec4 srgb);
Vec4 SrgbFromLinear(Vec4 lin); Vec4 SrgbFromLinear(Vec4 lin);
Vec4 SrgbFromHsv(f32 h, f32 s, f32 v);
Vec4 PremulFromLinear(Vec4 lin); Vec4 PremulFromLinear(Vec4 lin);
Vec4 PremulFromSrgb(Vec4 srgb); Vec4 PremulFromSrgb(Vec4 srgb);
Vec4 LerpSrgb(Vec4 a, Vec4 b, f32 t); Vec4 LerpSrgb(Vec4 a, Vec4 b, f32 t);
Vec4 SrgbFromHsv(Hsv hsv);
Hsv HsvFromSrgb(Vec4 srgb);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
//~ Vec2 //~ Vec2

View File

@ -260,6 +260,16 @@ P_Shape P_WorldShapeFromEnt(P_Ent *ent)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
//~ Status helpers //~ Status helpers
b32 P_IsEntRolling(P_Frame *frame, P_Ent *ent)
{
b32 result = (
ent->last_roll_ns > 0 &&
(frame->time_ns - ent->last_roll_ns) > 0 &&
(frame->time_ns - ent->last_roll_ns) < P_RollTimeNs
);
return result;
}
P_Anim P_AnimFromEnt(P_Frame *frame, P_Ent *ent) P_Anim P_AnimFromEnt(P_Frame *frame, P_Ent *ent)
{ {
P_Anim result = Zi; P_Anim result = Zi;
@ -368,14 +378,17 @@ P_Anim P_AnimFromEnt(P_Frame *frame, P_Ent *ent)
return result; return result;
} }
b32 P_IsEntRolling(P_Frame *frame, P_Ent *ent) Vec4 P_ColorFromEnt(P_Ent *ent)
{ {
b32 result = ( String ent_str = P_StringFromEnt(ent);
ent->last_roll_ns > 0 && u64 color_seed = MixU64s(P_EntityColorBasis, HashString(ent_str));
(frame->time_ns - ent->last_roll_ns) > 0 && f32 hue_offset = TweakFloat("Entity color hue offset", 135, 0, 360);
(frame->time_ns - ent->last_roll_ns) < P_RollTimeNs f32 h = (Norm16(color_seed >> 2) * 1) * 360 + hue_offset;
); f32 s = TweakFloat("Entity color saturation", 0.7, 0, 1);
return result; f32 v = TweakFloat("Entity color brightness", 1, 0, 1);
// f32 s = TweakFloat("Entity color saturation", 0.3, 0, 1);
// f32 v = TweakFloat("Entity color brightness", 0.6, 0, 1);
return SrgbFromHsv(HSV(h, s, v));
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////

View File

@ -12,6 +12,7 @@
#define P_BulletTrailBasis 0x27c011f891c571feull #define P_BulletTrailBasis 0x27c011f891c571feull
#define P_DeathBasis 0x2e3c75a3286d872aull #define P_DeathBasis 0x2e3c75a3286d872aull
#define P_KillfeedBasis 0xd1f84bd6f7c3cf1eull #define P_KillfeedBasis 0xd1f84bd6f7c3cf1eull
#define P_EntityColorBasis 0x3d2ddd9778146eccull
Struct(P_EntKey) Struct(P_EntKey)
{ {
@ -190,8 +191,6 @@ Struct(P_NetworkedEntState)
b32 is_player; b32 is_player;
P_EntKey guy; P_EntKey guy;
f32 ping;
u64 kills; u64 kills;
u64 deaths; u64 deaths;
@ -715,8 +714,9 @@ P_Shape P_WorldShapeFromEnt(P_Ent *ent);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
//~ Status helpers //~ Status helpers
P_Anim P_AnimFromEnt(P_Frame *frame, P_Ent *ent);
b32 P_IsEntRolling(P_Frame *frame, P_Ent *ent); b32 P_IsEntRolling(P_Frame *frame, P_Ent *ent);
P_Anim P_AnimFromEnt(P_Frame *frame, P_Ent *ent);
Vec4 P_ColorFromEnt(P_Ent *ent);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
//~ Collision //~ Collision

View File

@ -12,7 +12,6 @@ PERSIST Readonly String P_KillTerms[] = {
CompLit("terminated"), CompLit("terminated"),
CompLit("demoted"), CompLit("demoted"),
CompLit("restructured"), CompLit("restructured"),
CompLit("shredded"),
CompLit("decommissioned"), CompLit("decommissioned"),
CompLit("finalized"), CompLit("finalized"),
CompLit("offboarded"), CompLit("offboarded"),

View File

@ -680,7 +680,7 @@ void V_PushWidgetThemeStyles(V_WidgetTheme theme)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
//~ Notification helpers //~ Notification helpers
void V_PushNotif(String msg) V_Notif *V_PushNotif(String msg)
{ {
Arena *perm = PermArena(); Arena *perm = PermArena();
V_Notif *notif = PushStruct(perm, V_Notif); V_Notif *notif = PushStruct(perm, V_Notif);
@ -693,6 +693,7 @@ void V_PushNotif(String msg)
} }
SllQueuePushFront(V.first_notif, V.last_notif, notif); SllQueuePushFront(V.first_notif, V.last_notif, notif);
LogInfoF("[Notif] %F", FmtString(notif->msg)); LogInfoF("[Notif] %F", FmtString(notif->msg));
return notif;
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
@ -2497,6 +2498,7 @@ void V_TickForever(WaveLaneCtx *lane)
} }
//- Observe //- Observe
ent->initial_observation_time_ns = obs->initial_observation_time_ns;
ent->last_observation_time_ns = frame->time_ns; ent->last_observation_time_ns = frame->time_ns;
ent->is_first_observation = obs->initial_observation_time_ns == frame->time_ns; ent->is_first_observation = obs->initial_observation_time_ns == frame->time_ns;
} }
@ -2940,19 +2942,16 @@ void V_TickForever(WaveLaneCtx *lane)
Vec4 legs_mask_color_lin = Zi; Vec4 legs_mask_color_lin = Zi;
if (ent->is_guy) if (ent->is_guy)
{ {
f32 body_hue_offset = TweakFloat("Guy body hue offset", 135, 0, 360);
f32 body_s = TweakFloat("Guy body saturation", 0.7, 0, 1);
f32 body_v = TweakFloat("Guy body brightness", 1, 0, 1);
f32 legs_hue_offset = TweakFloat("Guy legs hue offset", 180, 0, 360); f32 legs_hue_offset = TweakFloat("Guy legs hue offset", 180, 0, 360);
f32 legs_s = TweakFloat("Guy legs saturation", 1, 0, 1); f32 legs_s = TweakFloat("Guy legs saturation", 1, 0, 1);
f32 legs_v = TweakFloat("Guy legs brightness", 1, 0, 1); f32 legs_v = TweakFloat("Guy legs brightness", 1, 0, 1);
{ {
P_Ent *player = P_EntFromKey(local_frame, ent->source); P_Ent *player = P_EntFromKey(local_frame, ent->source);
u64 color_seed = HashString(P_StringFromEnt(player)); Vec4 body_color = P_ColorFromEnt(player);
f32 body_hue = (Norm16(color_seed >> 2) * 1) * 360 + body_hue_offset; f32 body_hue = HsvFromSrgb(body_color).h;
f32 legs_hue = ModF32(body_hue + legs_hue_offset, 360); f32 legs_hue = ModF32(body_hue + legs_hue_offset, 360);
body_mask_color_lin = LinearFromSrgb(SrgbFromHsv(body_hue, body_s, body_v)); body_mask_color_lin = body_color;
legs_mask_color_lin = LinearFromSrgb(SrgbFromHsv(legs_hue, legs_s, legs_v)); legs_mask_color_lin = LinearFromSrgb(SrgbFromHsv(HSV(legs_hue, legs_s, legs_v)));
} }
} }
@ -3042,8 +3041,6 @@ void V_TickForever(WaveLaneCtx *lane)
//- Process world events //- Process world events
for (P_Ent *event = P_FirstEnt(local_frame); !P_IsEntNil(event); event = P_NextEnt(event)) for (P_Ent *event = P_FirstEnt(local_frame); !P_IsEntNil(event); event = P_NextEnt(event))
{
if (event->is_first_observation)
{ {
f64 seconds_since_observation = SecondsFromNs(frame->time_ns - event->initial_observation_time_ns); f64 seconds_since_observation = SecondsFromNs(frame->time_ns - event->initial_observation_time_ns);
u64 angle_offset_basis = 0xf55070bae6e1d70c; u64 angle_offset_basis = 0xf55070bae6e1d70c;
@ -3052,11 +3049,9 @@ void V_TickForever(WaveLaneCtx *lane)
////////////////////////////// //////////////////////////////
//- Trail //- Trail
// TODO: Remove this
if (event->is_trail) if (event->is_trail)
{
if (event->is_first_observation)
{ {
Vec2 p0 = event->trail_p0; Vec2 p0 = event->trail_p0;
Vec2 p1 = event->trail_p1; Vec2 p1 = event->trail_p1;
@ -3416,15 +3411,14 @@ void V_TickForever(WaveLaneCtx *lane)
} }
} }
}
////////////////////////////// //////////////////////////////
//- Hit //- Hit
if (event->is_hit) if (event->is_hit)
{
if (event->is_first_observation)
{ {
P_MaterialKind material = event->hit_material; P_MaterialKind material = event->hit_material;
@ -3556,9 +3550,7 @@ void V_TickForever(WaveLaneCtx *lane)
// V_DrawPoint(victim_raycast.p, Color_Green); // V_DrawPoint(victim_raycast.p, Color_Green);
// V_DrawLine(victim_raycast.p, AddVec2(victim_raycast.p, MulVec2(victim_raycast.normal, 0.5)), Color_White); // V_DrawLine(victim_raycast.p, AddVec2(victim_raycast.p, MulVec2(victim_raycast.normal, 0.5)), Color_White);
} }
}
////////////////////////////// //////////////////////////////
//- Death //- Death
@ -3566,29 +3558,17 @@ void V_TickForever(WaveLaneCtx *lane)
if (event->is_death) if (event->is_death)
{ {
Vec2 death_pos = event->death_pos; Vec2 death_pos = event->death_pos;
//- Killfeed
{
P_Ent *victim = P_EntFromKey(local_frame, event->death_victim);
P_Ent *killer = P_EntFromKey(local_frame, event->death_killer);
String victim_name = P_StringFromEnt(victim);
String killer_name = P_StringFromEnt(killer);
if (victim_name.len > 0)
{
u64 killfeed_term_seed = MixU64s(event->key.v, P_KillfeedBasis); u64 killfeed_term_seed = MixU64s(event->key.v, P_KillfeedBasis);
String killfeed_term = UpperString(frame->arena, P_KillTerms[killfeed_term_seed % countof(P_KillTerms)]); String killfeed_term = UpperString(frame->arena, P_KillTerms[killfeed_term_seed % countof(P_KillTerms)]);
String msg = Zi;
if (killer_name.len > 0) if (event->is_first_observation)
{ {
msg = StringF(frame->arena, "%F %F %F", FmtString(killer_name), FmtString(killfeed_term), FmtString(victim_name)); //- Killfeed notification
}
else
{ {
msg = StringF(frame->arena, "%F was %F", FmtString(killfeed_term), FmtString(victim_name)); V_Notif *notif = V_PushNotif(killfeed_term);
} notif->flags |= V_NotifFlag_Kill;
V_PushNotif(msg); notif->killer = event->death_killer;
} notif->victim = event->death_victim;
} }
//- Death particles //- Death particles
@ -3623,6 +3603,55 @@ void V_TickForever(WaveLaneCtx *lane)
V_PushParticles(emitter); V_PushParticles(emitter);
} }
} }
// P_Ent *victim = P_EntFromKey(local_frame, event->death_victim);
// P_Ent *killer = P_EntFromKey(local_frame, event->death_killer);
// String victim_name = P_StringFromEnt(victim);
// String killer_name = P_StringFromEnt(killer);
f32 event_seconds = SecondsFromNs(frame->time_ns - event->initial_observation_time_ns);
f32 duration_seconds = 0.5;
f32 progress = SaturateF32(event_seconds / duration_seconds);
f32 opacity = 1.0 - progress;
u64 text_dir_basis = 0x2f2b82acccbcf025ull;
u64 text_dir_seed = MixU64s(event->key.v, text_dir_basis);
f32 move_dir_spread = Tau / 4;
f32 move_meters = 1;
// Vec4 text_color = LinearFromSrgb(VEC4(0.75, 0.2, 0.2, 1));
Vec4 text_color = Color_White;
Vec2 move_dir = VEC2(0, -1);
Vec2 text_world_pos = AddVec2(death_pos, MulVec2(move_dir, progress));
text_world_pos.y -= 0.25;
Vec2 text_screen_pos = MulAffineVec2(frame->af.world_to_screen, text_world_pos);
UI_PushDF(Parent, vis_screen_overlay_box)
UI_PushDF(FontSize, 32)
UI_PushDF(Opacity, opacity)
UI_PushDF(Flags, UI_BoxFlag_Floating | UI_BoxFlag_DrawText | UI_BoxFlag_DontClampFloatingX | UI_BoxFlag_DontClampFloatingY)
UI_PushDF(Font, theme.player_name_font)
{
String text = killfeed_term;
// Name box
UI_SetNext(FloatingPos, text_screen_pos);
UI_PushDF(TextColor, text_color)
UI_PushDF(Parent, UI_BuildBox())
UI_PushDF(Text, text)
{
// Drop-shadow
UI_SetNext(TextColor, Color_Black);
UI_SetNext(FloatingPos, VEC2(2, 2));
UI_BuildBox();
// Name text
UI_BuildBox();
}
}
} }
} }
@ -4038,12 +4067,80 @@ void V_TickForever(WaveLaneCtx *lane)
// UI_PushDF(Parent, vis_root_box)
// b32 show_panels = 1;
// if (!show_panels)
// {
// UI_SetNext(Flags, UI_BoxFlag_Floating);
// UI_SetNext(Parent, vis_screen_box);
// UI_BuildBoxEx(vis_panels_box);
// UI_SetNext(Parent, vis_panels_box);
// UI_BuildColumnEx(vis_screen_panel_box);
// UI_BuildBoxEx(vis_panels_box);
// }
// {
// b32 lock_screen_to_panel = TweakBool("Lock screen to panel", 0);
// if (lock_screen_to_panel)
// {
// UI_SetNext(Parent, vis_screen_panel_box);
// }
// else
// {
// UI_SetNext(Parent, vis_root_box);
// }
// UI_BuildBoxEx(vis_screen_box);
// }
// if (!show_panels)
// {
// UI_SetNext(Parent, vis_root_box);
// UI_BuildBoxEx(vis_screen_box);
// }
// FIXME: Limit dims based on sample buffer capacity // FIXME: Limit dims based on sample buffer capacity
// b32 should_draw_profiler_graph = frame->profiler.is_showing && frame->profiler.graph_dims.x > 0 && frame->profiler.graph_dims.y > 0; // b32 should_draw_profiler_graph = frame->profiler.is_showing && frame->profiler.graph_dims.x > 0 && frame->profiler.graph_dims.y > 0;
// frame->profiler_graph_dims = frame->profiler.graph_dims; // frame->profiler_graph_dims = frame->profiler.graph_dims;
// frame->profiler_frame_seq = V.profiler_frame_seq; // frame->profiler_frame_seq = V.profiler_frame_seq;
b32 show_panels = frame->is_editing;
// UI_PushDF(Parent, vis_root_box)
// if (!show_panels)
// {
// // UI_SetNext(Flags, UI_BoxFlag_Floating);
// // UI_SetNext(Parent, vis_root_box);
// // UI_BuildColumnEx(vis_screen_panel_box);
// UI_SetNext(Flags, UI_BoxFlag_Floating);
// UI_SetNext(Parent, vis_root_box);
// UI_BuildColumnEx(vis_panels_box);
// }
{
UI_SetNext(Parent, vis_root_box);
UI_BuildBoxEx(vis_screen_box);
UI_SetNext(Parent, vis_screen_box);
UI_BuildBoxEx(vis_panels_box);
UI_SetNext(Parent, vis_panels_box);
UI_BuildBoxEx(vis_screen_panel_box);
}
UI_Key profiler_graph_box = UI_KeyF("graph"); UI_Key profiler_graph_box = UI_KeyF("graph");
b32 should_draw_profiler_graph = 0; b32 should_draw_profiler_graph = 0;
V.profiler_graph_dims = DimsFromRng2(UI_Rect(profiler_graph_box)); V.profiler_graph_dims = DimsFromRng2(UI_Rect(profiler_graph_box));
@ -4053,7 +4150,7 @@ void V_TickForever(WaveLaneCtx *lane)
if (V.root_panel) if (V.root_panel && show_panels)
{ {
Struct(BfsPanel) { BfsPanel *next; V_Panel *panel; }; Struct(BfsPanel) { BfsPanel *next; V_Panel *panel; };
BfsPanel *first_bfs_panel = PushStruct(frame->arena, BfsPanel); BfsPanel *first_bfs_panel = PushStruct(frame->arena, BfsPanel);
@ -4780,7 +4877,7 @@ void V_TickForever(WaveLaneCtx *lane)
f32 h = (Norm16(color_seed >> 0) * 1) * 360; f32 h = (Norm16(color_seed >> 0) * 1) * 360;
f32 s = TweakFloat("Profiler zone saturation", 0.50, 0, 1); f32 s = TweakFloat("Profiler zone saturation", 0.50, 0, 1);
f32 v = TweakFloat("Profiler zone brightness", 1.00, 0, 1); f32 v = TweakFloat("Profiler zone brightness", 1.00, 0, 1);
Vec4 zone_color = SrgbFromHsv(h, s, v); Vec4 zone_color = SrgbFromHsv(HSV(h, s, v));
// b32 should_collapse_zone = visual_zone_len_px <= zone_collapse_threshold_px; // b32 should_collapse_zone = visual_zone_len_px <= zone_collapse_threshold_px;
// b32 should_collapse_zone = 0; // b32 should_collapse_zone = 0;
@ -4865,8 +4962,8 @@ void V_TickForever(WaveLaneCtx *lane)
main_color_unsampled.g *= 0.85; main_color_unsampled.g *= 0.85;
main_color_unsampled.b *= 0.85; main_color_unsampled.b *= 0.85;
Vec4 collapsed_line_color = SrgbFromHsv(64, 1, 0.5); Vec4 collapsed_line_color = SrgbFromHsv(HSV(64, 1, 0.5));
Vec4 collapsed_text_color = SrgbFromHsv(64, 1, 0.75); Vec4 collapsed_text_color = SrgbFromHsv(HSV(64, 1, 0.75));
// main_color_sampled.g += 0.05; // main_color_sampled.g += 0.05;
@ -5559,18 +5656,18 @@ void V_TickForever(WaveLaneCtx *lane)
V.root_panel = panel; V.root_panel = panel;
} }
// //- Left panel //- Left panel
// { {
// V_Panel *panel = left_panel; V_Panel *panel = left_panel;
// panel->parent = V.root_panel; panel->parent = V.root_panel;
// panel->axis = Axis_X; panel->axis = Axis_X;
// DllQueuePush(panel->parent->first, panel->parent->last, panel); DllQueuePush(panel->parent->first, panel->parent->last, panel);
// panel->box = UI_RandKey(); panel->box = UI_RandKey();
// panel->contents_box = UI_KeyF("panel contents box %F", FmtUint(panel->box.v)); panel->contents_box = UI_KeyF("panel contents box %F", FmtUint(panel->box.v));
// panel->resizer_box = UI_KeyF("panel resizer box %F", FmtUint(panel->box.v)); panel->resizer_box = UI_KeyF("panel resizer box %F", FmtUint(panel->box.v));
// panel->pct = 0.10; panel->pct = 0.10;
// panel->is_organizational = 1; panel->is_organizational = 1;
// } }
//- Right panel //- Right panel
{ {
@ -5586,32 +5683,32 @@ void V_TickForever(WaveLaneCtx *lane)
} }
} }
// //- Test spawn panel //- Test spawn panel
// {
// V_Panel *panel = PushStruct(perm, V_Panel);
// panel->parent = left_panel;
// panel->axis = Axis_X;
// DllQueuePush(panel->parent->first, panel->parent->last, panel);
// panel->box = UI_RandKey();
// panel->contents_box = UI_KeyF("panel contents box %F", FmtUint(panel->box.v));
// panel->resizer_box = UI_KeyF("panel resizer box %F", FmtUint(panel->box.v));
// panel->flags |= V_PanelFlag_Spawn;
// panel->pct = 0.25;
// }
//- Test profiler panel
{ {
V_Panel *panel = PushStruct(perm, V_Panel); V_Panel *panel = PushStruct(perm, V_Panel);
panel->parent = right_panel; panel->parent = left_panel;
panel->axis = Axis_X; panel->axis = Axis_X;
DllQueuePush(panel->parent->first, panel->parent->last, panel); DllQueuePush(panel->parent->first, panel->parent->last, panel);
panel->box = UI_RandKey(); panel->box = UI_RandKey();
panel->contents_box = UI_KeyF("panel contents box %F", FmtUint(panel->box.v)); panel->contents_box = UI_KeyF("panel contents box %F", FmtUint(panel->box.v));
panel->resizer_box = UI_KeyF("panel resizer box %F", FmtUint(panel->box.v)); panel->resizer_box = UI_KeyF("panel resizer box %F", FmtUint(panel->box.v));
panel->flags |= V_PanelFlag_Profiler; panel->flags |= V_PanelFlag_Spawn;
panel->pct = 0.5; panel->pct = 0.25;
} }
// //- Test profiler panel
// {
// V_Panel *panel = PushStruct(perm, V_Panel);
// panel->parent = right_panel;
// panel->axis = Axis_X;
// DllQueuePush(panel->parent->first, panel->parent->last, panel);
// panel->box = UI_RandKey();
// panel->contents_box = UI_KeyF("panel contents box %F", FmtUint(panel->box.v));
// panel->resizer_box = UI_KeyF("panel resizer box %F", FmtUint(panel->box.v));
// panel->flags |= V_PanelFlag_Profiler;
// panel->pct = 0.5;
// }
//- Vis screen panel //- Vis screen panel
{ {
V_Panel *panel = PushStruct(perm, V_Panel); V_Panel *panel = PushStruct(perm, V_Panel);
@ -5648,45 +5745,8 @@ void V_TickForever(WaveLaneCtx *lane)
////////////////////////////// //////////////////////////////
//- Build vis panel contents //- Build vis panel contents
if (show_panels)
UI_PushDF(Tag, HashF("vis panels")) UI_PushDF(Tag, HashF("vis panels"))
{
// FIXME: Remove this
//////////////////////////////
//- Init test panels
// UI_PushDF(Parent, vis_root_box)
// if (!show_panels)
// {
// UI_SetNext(Flags, UI_BoxFlag_Floating);
// UI_SetNext(Parent, vis_root_box);
// UI_BuildColumnEx(vis_screen_panel_box);
// }
{
b32 lock_screen_to_panel = TweakBool("Lock screen to panel", 0);
if (lock_screen_to_panel)
{
UI_SetNext(Parent, vis_screen_panel_box);
}
else
{
UI_SetNext(Parent, vis_root_box);
}
UI_BuildBoxEx(vis_screen_box);
}
{ {
UI_SetNext(Flags, UI_BoxFlag_Floating); UI_SetNext(Flags, UI_BoxFlag_Floating);
UI_SetNext(Parent, vis_root_box); UI_SetNext(Parent, vis_root_box);
@ -5944,7 +6004,6 @@ void V_TickForever(WaveLaneCtx *lane)
} }
} }
} }
}
@ -7491,7 +7550,7 @@ void V_TickForever(WaveLaneCtx *lane)
f32 h = TweakFloat("Text selection hue", 200, 0, 360); f32 h = TweakFloat("Text selection hue", 200, 0, 360);
f32 s = TweakFloat("Text selection saturation", 1, 0, 1); f32 s = TweakFloat("Text selection saturation", 1, 0, 1);
f32 v = TweakFloat("Text selection brightness", 0.6, 0, 1); f32 v = TweakFloat("Text selection brightness", 0.6, 0, 1);
Vec4 selection_color = SrgbFromHsv(h, s, v); Vec4 selection_color = SrgbFromHsv(HSV(h, s, v));
// Vec4 selection_color = theme.col.button_active; // Vec4 selection_color = theme.col.button_active;
// selection_color.a = 1; // selection_color.a = 1;
@ -8260,7 +8319,7 @@ void V_TickForever(WaveLaneCtx *lane)
UI_SetNext(BackgroundColor, bg); UI_SetNext(BackgroundColor, bg);
UI_SetNext(Rounding, 0); UI_SetNext(Rounding, 0);
// UI_SetNext(Flags, UI_BoxFlag_Floating); // UI_SetNext(Flags, UI_BoxFlag_Floating);
UI_PushCp(UI_BuildColumnEx(notifs_key)); UI_PushDF(Parent, UI_BuildColumnEx(notifs_key))
{ {
UI_Push(ChildAlignment, UI_Region_Left); UI_Push(ChildAlignment, UI_Region_Left);
UI_Push(Font, theme.chat_font); UI_Push(Font, theme.chat_font);
@ -8276,41 +8335,77 @@ void V_TickForever(WaveLaneCtx *lane)
opacity = PowF64(((f64)remaining_ns / (f64)duration_ns), fade_curve); opacity = PowF64(((f64)remaining_ns / (f64)duration_ns), fade_curve);
} }
b32 is_kill_msg = AnyBit(notif->flags, V_NotifFlag_Kill);
UI_SetNext(Tint, 0); UI_SetNext(Tint, 0);
UI_SetNext(Width, UI_Shrink(0, 0)); UI_SetNext(Width, UI_Shrink(0, 0));
UI_SetNext(Height, UI_Shrink(0, 0)); UI_SetNext(Height, UI_Shrink(0, 0));
UI_PushCp(UI_BuildRow()); UI_PushDF(Tint, VEC4(1, 1, 1, opacity))
UI_PushDF(Width, UI_Shrink(0, 0))
UI_PushDF(Height, UI_Shrink(0, 0))
UI_PushDF(Parent, UI_BuildRow())
if (is_kill_msg)
{ {
UI_Push(Tint, VEC4(1, 1, 1, opacity)); P_Ent *killer = P_EntFromKey(local_frame, notif->killer);
UI_Push(Width, UI_Shrink(0, 0)); P_Ent *victim = P_EntFromKey(local_frame, notif->victim);
UI_Push(Height, UI_Shrink(0, 0)); String killer_name = P_StringFromEnt(killer);
String victim_name = P_StringFromEnt(victim);
Vec4 killer_color = P_ColorFromEnt(killer);
Vec4 victim_color = P_ColorFromEnt(victim);
//- Killer name
{ {
String msg = StringF( UI_SetNext(TextColor, killer_color);
UI_SetNext(Text, StringF(frame->arena, "%F", FmtString(killer_name)));
UI_SetNext(Flags, UI_BoxFlag_DrawText);
UI_BuildRow();
}
//- Msg text
{
String msg = StringF(frame->arena, " %F ", FmtString(notif->msg));
UI_SetNext(Text, msg);
UI_SetNext(Font, theme.player_name_font);
UI_SetNext(FontSize, 16);
UI_SetNext(Flags, UI_BoxFlag_DrawText);
UI_BuildRow();
}
//- Victim name
{
UI_SetNext(TextColor, victim_color);
UI_SetNext(Text, StringF(frame->arena, "%F", FmtString(victim_name)));
UI_SetNext(Flags, UI_BoxFlag_DrawText);
UI_BuildRow();
}
}
else
{
//- Time
{
String time_msg = StringF(
frame->arena, frame->arena,
"[%F:%F:%F] ", "[%F:%F:%F] ",
FmtUint(notif->datetime.hour % 12, .z = 2), FmtUint(notif->datetime.hour % 12, .z = 2),
FmtUint(notif->datetime.minute, .z = 2), FmtUint(notif->datetime.minute, .z = 2),
FmtUint(notif->datetime.second, .z = 2) FmtUint(notif->datetime.second, .z = 2)
); );
Vec4 col = UI_Top(TextColor); Vec4 seq_color = UI_Top(TextColor);
if (notif->seq % 2 == 0) if (notif->seq % 2 == 0)
{ {
col.x = 0.55; seq_color.x = 0.55;
col.y = 0.52; seq_color.y = 0.52;
col.z = 0.49; seq_color.z = 0.49;
} }
else else
{ {
col.x = 0.49; seq_color.x = 0.49;
col.y = 0.52; seq_color.y = 0.52;
col.z = 0.55; seq_color.z = 0.55;
} }
UI_SetNext(TextColor, seq_color);
UI_SetNext(TextColor, col); UI_SetNext(Text, time_msg);
UI_SetNext(Text, msg);
UI_SetNext(Flags, UI_BoxFlag_DrawText); UI_SetNext(Flags, UI_BoxFlag_DrawText);
UI_BuildRow(); UI_BuildRow();
} }
//- Msg text
{ {
String msg = notif->msg; String msg = notif->msg;
UI_SetNext(Text, msg); UI_SetNext(Text, msg);
@ -8318,7 +8413,6 @@ void V_TickForever(WaveLaneCtx *lane)
UI_BuildRow(); UI_BuildRow();
} }
} }
UI_PopCp(UI_TopCp());
if (notif_idx != 0) if (notif_idx != 0)
{ {
@ -8326,8 +8420,6 @@ void V_TickForever(WaveLaneCtx *lane)
} }
} }
} }
UI_PopCp(UI_TopCp());
} }
} }
@ -8645,13 +8737,11 @@ void V_TickForever(WaveLaneCtx *lane)
// UI_Size name_sz = UI_Grow(0.75, 0); // UI_Size name_sz = UI_Grow(0.75, 0);
// UI_Size kills_sz = UI_Grow(0.25, 0); // UI_Size kills_sz = UI_Grow(0.25, 0);
// UI_Size deaths_sz = UI_Grow(0.25, 0); // UI_Size deaths_sz = UI_Grow(0.25, 0);
// UI_Size ping_sz = UI_Grow(0.25, 0);
// UI_Size spacing_sz = UI_Fnt(1, 0); // UI_Size spacing_sz = UI_Fnt(1, 0);
UI_Size name_sz = UI_Fnt(10, 0); UI_Size name_sz = UI_Fnt(10, 0);
UI_Size kills_sz = UI_Fnt(10, 0); UI_Size kills_sz = UI_Fnt(10, 0);
UI_Size deaths_sz = UI_Fnt(10, 0); UI_Size deaths_sz = UI_Fnt(10, 0);
UI_Size ping_sz = UI_Fnt(5, 0);
UI_Size spacing_sz = UI_Fnt(1, 0); UI_Size spacing_sz = UI_Fnt(1, 0);
Enum(BoardRowFlag) Enum(BoardRowFlag)
@ -8664,7 +8754,6 @@ void V_TickForever(WaveLaneCtx *lane)
BoardRow *next; BoardRow *next;
BoardRowFlag flags; BoardRowFlag flags;
String name; String name;
f32 ping;
f32 kills; f32 kills;
f32 deaths; f32 deaths;
}; };
@ -8690,7 +8779,6 @@ void V_TickForever(WaveLaneCtx *lane)
board_rows_count += 1; board_rows_count += 1;
String name = P_StringFromEnt(player); String name = P_StringFromEnt(player);
row->name = name; row->name = name;
row->ping = player->ping;
row->kills = player->kills; row->kills = player->kills;
row->deaths = player->deaths; row->deaths = player->deaths;
} }
@ -8790,22 +8878,6 @@ void V_TickForever(WaveLaneCtx *lane)
} }
} }
UI_PopCp(UI_TopCp()); UI_PopCp(UI_TopCp());
UI_BuildDivider(UI_Px(1, 1), theme.col.divider, Axis_X);
UI_BuildSpacer(spacing_sz, Axis_X);
UI_SetNext(Width, ping_sz);
UI_PushCp(UI_BuildColumn()); // Ping column
{
if (is_header)
{
UI_BuildLabelF("Ping");
}
else
{
UI_BuildLabelF("%F", FmtFloat(board_row->ping, .p = 2));
}
}
UI_PopCp(UI_TopCp());
} }
UI_PopCp(UI_TopCp()); UI_PopCp(UI_TopCp());
@ -8884,7 +8956,6 @@ void V_TickForever(WaveLaneCtx *lane)
// Name text // Name text
UI_BuildBox(); UI_BuildBox();
} }
} }
} }
} }

View File

@ -156,13 +156,25 @@ Global Readonly V_CmdDesc V_cmd_descs[V_CmdKind_COUNT] = {
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
//~ Notification types //~ Notification types
Enum(V_NotifFlag)
{
V_NotifFlag_None,
V_NotifFlag_Kill = (1 << 0),
};
Struct(V_Notif) Struct(V_Notif)
{ {
V_Notif *next; V_Notif *next;
V_NotifFlag flags;
String msg;
P_EntKey killer;
P_EntKey victim;
DateTime datetime; DateTime datetime;
i64 time_ns; i64 time_ns;
i64 seq; i64 seq;
String msg;
}; };
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
@ -245,7 +257,6 @@ Struct(V_Palette)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
//~ Profiler types //~ Profiler types
// #define V_CollapsedZoneBasis 0x4a06f782d21f18af
#define V_MinChunkCapacity 1 #define V_MinChunkCapacity 1
Struct(V_Zone) Struct(V_Zone)
@ -545,7 +556,7 @@ void V_PushWidgetThemeStyles(V_WidgetTheme theme);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
//~ Notification helpers //~ Notification helpers
void V_PushNotif(String msg); V_Notif *V_PushNotif(String msg);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
//~ Vis tick //~ Vis tick

View File

@ -621,6 +621,10 @@ UI_Frame *UI_BeginFrame(UI_FrameFlag frame_flags)
if (prev_frame->boxes_pre != 0) if (prev_frame->boxes_pre != 0)
{ {
ControllerEventsArray controller_events = frame->window_frame.controller_events; ControllerEventsArray controller_events = frame->window_frame.controller_events;
u64 boxes_pre_count = prev_frame->boxes_pre_count;
u64 boxes_post_count = prev_frame->boxes_post_count;
UI_Box **boxes_pre = prev_frame->boxes_pre;
UI_Box **boxes_post = prev_frame->boxes_post;
//- Locate boxes //- Locate boxes
UI_Box *prev_top_active_box = UI_BoxFromKey(prev_frame->top_active_box); UI_Box *prev_top_active_box = UI_BoxFromKey(prev_frame->top_active_box);
@ -639,9 +643,9 @@ UI_Frame *UI_BeginFrame(UI_FrameFlag frame_flags)
} }
//- Locate hovered box //- Locate hovered box
for (u64 pre_index = UI.boxes_count; pre_index-- > 0;) for (u64 pre_idx = boxes_pre_count; pre_idx-- > 0;)
{ {
UI_Box *box = prev_frame->boxes_pre[pre_index]; UI_Box *box = boxes_pre[pre_idx];
UI_ExecuteDebugBreak(box, UI_DebugBreakFlag_CheckCursorHover); UI_ExecuteDebugBreak(box, UI_DebugBreakFlag_CheckCursorHover);
//- Reset state //- Reset state
{ {
@ -830,9 +834,9 @@ UI_Frame *UI_BeginFrame(UI_FrameFlag frame_flags)
{ {
f32 lower_target = TweakFloat("UI lower blend target", -0.05, -1, 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); f32 upper_target = TweakFloat("UI upper blend target", 1.05, 1, 10);
for (u64 pre_index = UI.boxes_count; pre_index-- > 0;) for (u64 pre_idx = boxes_pre_count; pre_idx-- > 0;)
{ {
UI_Box *box = prev_frame->boxes_pre[pre_index]; UI_Box *box = boxes_pre[pre_idx];
UI_Box *parent = box->parent; UI_Box *parent = box->parent;
UI_Feedback *feedback = &box->feedback; UI_Feedback *feedback = &box->feedback;
UI_ExecuteDebugBreak(box, UI_DebugBreakFlag_BuildFeedback); UI_ExecuteDebugBreak(box, UI_DebugBreakFlag_BuildFeedback);
@ -1438,20 +1442,15 @@ void UI_EndFrame(UI_Frame *frame, i32 vsync)
} }
////////////////////////////// //////////////////////////////
//- Layout //- Layout prepass
u64 boxes_count = UI.boxes_count;
UI_Box **boxes_pre = PushStructsNoZero(frame->arena, UI_Box *, boxes_count);
UI_Box **boxes_post = PushStructsNoZero(frame->arena, UI_Box *, boxes_count);
frame->boxes_pre = boxes_pre;
frame->boxes_post = boxes_post;
ProfZoneDF("Layout UI")
{
//- Prepare layout data //- Prepare layout data
ProfZoneDF("Layout prepass") ProfZoneDF("Layout prepass")
{ {
u64 pre_index = 0; frame->boxes_pre_count = 0;
u64 post_index = 0; frame->boxes_post_count = 0;
frame->boxes_pre = PushStructsNoZero(frame->arena, UI_Box *, UI.boxes_count);
frame->boxes_post = PushStructsNoZero(frame->arena, UI_Box *, UI.boxes_count);
for (UI_BoxIterResult ir = UI_FirstBox(scratch.arena, &box_iter, UI_RootKey); ir.box; ir = UI_NextBox(scratch.arena, &box_iter)) for (UI_BoxIterResult ir = UI_FirstBox(scratch.arena, &box_iter, UI_RootKey); ir.box; ir = UI_NextBox(scratch.arena, &box_iter))
{ {
UI_Box *box = ir.box; UI_Box *box = ir.box;
@ -1459,43 +1458,50 @@ void UI_EndFrame(UI_Frame *frame, i32 vsync)
{ {
UI_ExecuteDebugBreak(box, UI_DebugBreakFlag_PrepLayout); UI_ExecuteDebugBreak(box, UI_DebugBreakFlag_PrepLayout);
box->pre_index = pre_index; box->pre_idx = frame->boxes_pre_count;
boxes_pre[pre_index] = box; frame->boxes_pre[box->pre_idx] = box;
pre_index += 1; frame->boxes_pre_count += 1;
// Reset layout data // Reset layout data
box->cursor = 0; box->cursor = 0;
box->final_children_size_accum = VEC2(0, 0); box->final_children_size_accum = VEC2(0, 0);
box->solved_dims = VEC2(0, 0); box->solved_dims = VEC2(0, 0);
// Solve scale & opacity // Solve scale
{ {
UI_Box *parent = box->parent; UI_Box *parent = box->parent;
box->solved_opacity = box->desc.opacity;
box->solved_scale = box->desc.scale; box->solved_scale = box->desc.scale;
if (parent) if (parent)
{ {
box->solved_opacity = parent->solved_opacity * box->solved_opacity;
box->solved_scale = MulVec2Vec2(parent->solved_scale, box->solved_scale); box->solved_scale = MulVec2Vec2(parent->solved_scale, box->solved_scale);
} }
} }
} }
else else
{ {
box->post_index = post_index; box->post_idx = frame->boxes_post_count;
boxes_post[post_index] = box; frame->boxes_post[box->post_idx] = box;
post_index += 1; frame->boxes_post_count += 1;
} }
} }
Assert(pre_index == boxes_count); Assert(frame->boxes_pre_count == UI.boxes_count);
Assert(post_index == boxes_count); Assert(frame->boxes_post_count == UI.boxes_count);
} }
u64 boxes_pre_count = frame->boxes_pre_count;
u64 boxes_post_count = frame->boxes_post_count;
UI_Box **boxes_pre = frame->boxes_pre;
UI_Box **boxes_post = frame->boxes_post;
//////////////////////////////
//- Layout
ProfZoneDF("Layout UI")
{
//- Solve independent sizes //- Solve independent sizes
ProfZoneDF("Solve independent sizes") ProfZoneDF("Solve independent sizes")
for (u64 pre_index = 0; pre_index < boxes_count; ++pre_index) for (u64 pre_idx = 0; pre_idx < boxes_pre_count; ++pre_idx)
{ {
UI_Box *box = boxes_pre[pre_index]; UI_Box *box = boxes_pre[pre_idx];
UI_ExecuteDebugBreak(box, UI_DebugBreakFlag_IndependentSolve); UI_ExecuteDebugBreak(box, UI_DebugBreakFlag_IndependentSolve);
for (Axis axis = 0; axis < Axis_COUNTXY; ++axis) for (Axis axis = 0; axis < Axis_COUNTXY; ++axis)
{ {
@ -1550,9 +1556,9 @@ void UI_EndFrame(UI_Frame *frame, i32 vsync)
//- Solve upwards-dependent sizes along layout axis //- Solve upwards-dependent sizes along layout axis
ProfZoneDF("Solve upwards-dependent sizes (along layout-axis)") ProfZoneDF("Solve upwards-dependent sizes (along layout-axis)")
for (u64 pre_index = 0; pre_index < boxes_count; ++pre_index) for (u64 pre_idx = 0; pre_idx < boxes_pre_count; ++pre_idx)
{ {
UI_Box *box = boxes_pre[pre_index]; UI_Box *box = boxes_pre[pre_idx];
UI_ExecuteDebugBreak(box, UI_DebugBreakFlag_UpwardsDependentSolveLayoutAxis); UI_ExecuteDebugBreak(box, UI_DebugBreakFlag_UpwardsDependentSolveLayoutAxis);
if (box->parent) if (box->parent)
{ {
@ -1588,9 +1594,9 @@ void UI_EndFrame(UI_Frame *frame, i32 vsync)
//- Solve downwards-dependent sizes //- Solve downwards-dependent sizes
ProfZoneDF("Solve downwards-dependent sizes") ProfZoneDF("Solve downwards-dependent sizes")
for (u64 post_index = 0; post_index < boxes_count; ++post_index) for (u64 post_idx = 0; post_idx < boxes_post_count; ++post_idx)
{ {
UI_Box *box = boxes_post[post_index]; UI_Box *box = boxes_post[post_idx];
UI_ExecuteDebugBreak(box, UI_DebugBreakFlag_DownwardsDependentSolve); UI_ExecuteDebugBreak(box, UI_DebugBreakFlag_DownwardsDependentSolve);
for (Axis axis = 0; axis < Axis_COUNTXY; ++axis) for (Axis axis = 0; axis < Axis_COUNTXY; ++axis)
{ {
@ -1621,9 +1627,9 @@ void UI_EndFrame(UI_Frame *frame, i32 vsync)
//- Solve upwards-dependent sizes along non-layout axis //- Solve upwards-dependent sizes along non-layout axis
ProfZoneDF("Solve upwards-dependent sizes (along non-layout-axis)") ProfZoneDF("Solve upwards-dependent sizes (along non-layout-axis)")
for (u64 pre_index = 0; pre_index < boxes_count; ++pre_index) for (u64 pre_idx = 0; pre_idx < boxes_pre_count; ++pre_idx)
{ {
UI_Box *box = boxes_pre[pre_index]; UI_Box *box = boxes_pre[pre_idx];
UI_ExecuteDebugBreak(box, UI_DebugBreakFlag_UpwardsDependentSolveNonLayoutAxis); UI_ExecuteDebugBreak(box, UI_DebugBreakFlag_UpwardsDependentSolveNonLayoutAxis);
if (box->parent) if (box->parent)
{ {
@ -1638,9 +1644,9 @@ void UI_EndFrame(UI_Frame *frame, i32 vsync)
//- Solve violations //- Solve violations
ProfZoneDF("Solve violations") ProfZoneDF("Solve violations")
for (u64 pre_index = 0; pre_index < boxes_count; ++pre_index) for (u64 pre_idx = 0; pre_idx < boxes_pre_count; ++pre_idx)
{ {
UI_Box *box = boxes_pre[pre_index]; UI_Box *box = boxes_pre[pre_idx];
UI_ExecuteDebugBreak(box, UI_DebugBreakFlag_SolveViolations); UI_ExecuteDebugBreak(box, UI_DebugBreakFlag_SolveViolations);
for (Axis axis = 0; axis < Axis_COUNTXY; ++axis) for (Axis axis = 0; axis < Axis_COUNTXY; ++axis)
{ {
@ -1722,9 +1728,9 @@ void UI_EndFrame(UI_Frame *frame, i32 vsync)
//- Solve final positions //- Solve final positions
ProfZoneDF("Solve final screen positions") ProfZoneDF("Solve final screen positions")
for (u64 pre_index = 0; pre_index < boxes_count; ++pre_index) for (u64 pre_idx = 0; pre_idx < boxes_pre_count; ++pre_idx)
{ {
UI_Box *box = boxes_pre[pre_index]; UI_Box *box = boxes_pre[pre_idx];
UI_ExecuteDebugBreak(box, UI_DebugBreakFlag_FinalSolve); UI_ExecuteDebugBreak(box, UI_DebugBreakFlag_FinalSolve);
UI_Box *parent = box->parent; UI_Box *parent = box->parent;
@ -1962,17 +1968,16 @@ void UI_EndFrame(UI_Frame *frame, i32 vsync)
//- Build render data //- Build render data
// Build GPU rect data // Build GPU rect data
ProfZoneDF("Build GPU rects") for (u64 pre_idx = 0; pre_idx < boxes_pre_count; ++pre_idx)
for (u64 pre_index = 0; pre_index < boxes_count; ++pre_index)
{ {
UI_Box *box = boxes_pre[pre_index]; UI_Box *box = boxes_pre[pre_idx];
UI_ExecuteDebugBreak(box, UI_DebugBreakFlag_BuildGpuData); UI_ExecuteDebugBreak(box, UI_DebugBreakFlag_BuildGpuData);
GC_Run raw_run_unscaled = box->glyph_run; GC_Run raw_run_unscaled = box->glyph_run;
GC_Run raw_run = UI_ScaleRun(frame->arena, raw_run_unscaled, box->solved_scale); GC_Run raw_run = UI_ScaleRun(frame->arena, raw_run_unscaled, box->solved_scale);
Vec4 final_tint_lin = LinearFromSrgb(box->desc.tint); Vec4 final_tint_lin = LinearFromSrgb(box->desc.tint);
final_tint_lin.a *= box->solved_opacity; final_tint_lin.a *= box->desc.opacity;
Vec4 final_border_color_lin = LinearFromSrgb(box->desc.border_color); Vec4 final_border_color_lin = LinearFromSrgb(box->desc.border_color);
@ -2011,7 +2016,6 @@ void UI_EndFrame(UI_Frame *frame, i32 vsync)
UI_AxisRegion y_alignment = child_alignment.v[Axis_Y]; UI_AxisRegion y_alignment = child_alignment.v[Axis_Y];
// Box rect // Box rect
ProfZoneDF("GPU box rect")
{ {
UI_GpuRect *rect = PushStruct(frame->rects_arena, UI_GpuRect); UI_GpuRect *rect = PushStruct(frame->rects_arena, UI_GpuRect);
rect->bounds = box->screen_rect; rect->bounds = box->screen_rect;
@ -2044,7 +2048,6 @@ void UI_EndFrame(UI_Frame *frame, i32 vsync)
// Text rects // Text rects
if (should_upload_text || AnyBit(frame->frame_flags, UI_FrameFlag_Debug)) if (should_upload_text || AnyBit(frame->frame_flags, UI_FrameFlag_Debug))
ProfZoneDF("GPU text rects")
{ {
f32 max_baseline_length = CeilF32(DimsFromRng2(box->screen_rect).x); f32 max_baseline_length = CeilF32(DimsFromRng2(box->screen_rect).x);
b32 should_truncate = FloorF32(raw_run.baseline_length) > max_baseline_length && !AnyBit(box->desc.flags, UI_BoxFlag_DontTruncateText); b32 should_truncate = FloorF32(raw_run.baseline_length) > max_baseline_length && !AnyBit(box->desc.flags, UI_BoxFlag_DontTruncateText);

View File

@ -374,12 +374,9 @@ Struct(UI_Box)
GC_Run glyph_run; GC_Run glyph_run;
SPR_Sprite sprite; SPR_Sprite sprite;
//- Pre-layout data
u64 pre_index;
u64 post_index;
//- Layout data //- Layout data
f32 solved_opacity; u64 pre_idx;
u64 post_idx;
Vec2 solved_scale; Vec2 solved_scale;
Rng2 solved_scissor; Rng2 solved_scissor;
Vec2 final_children_size_accum; Vec2 final_children_size_accum;
@ -476,6 +473,8 @@ Struct(UI_Frame)
UI_StyleNode *first_free_style_node; UI_StyleNode *first_free_style_node;
// Layout // Layout
u64 boxes_pre_count;
u64 boxes_post_count;
UI_Box **boxes_pre; UI_Box **boxes_pre;
UI_Box **boxes_post; UI_Box **boxes_post;
}; };