muzzle flash testing

This commit is contained in:
jacob 2026-04-04 05:51:09 -05:00
parent 68b2f24aee
commit faf033bf5a
12 changed files with 1145 additions and 918 deletions

View File

@ -387,8 +387,9 @@
////////////////////////////////////////////////////////////
//~ Bit helper macros
#define AllBits(a, b) (((a) & (b)) == (b))
#define AnyBit(a, b) (((a) & (b)) != 0)
#define AllBits(a, b) (((a) & (b)) == (b))
#define AnyBit(a, b) (((a) & (b)) != 0)
#define SetBit(a, b, v) ((v) ? ((a) | (b)) : ((a) & ~(b)))
////////////////////////////////////////////////////////////
//~ Color helper macros

View File

@ -3477,7 +3477,10 @@ void P_StepFrame(P_Frame *frame)
trail->trail_p0 = p0;
trail->trail_p1 = bullet->xf.t;
trail->lifetime_seconds = 0;
if (is_first_bullet_tick)
{
trail->is_first_trail = 1;
}
}
// TODO: Remove this

View File

@ -145,7 +145,13 @@ Struct(P_Ent)
b32 is_bullet;
u32 bullet_hits_count;
//- Hit
//- Events
b32 is_trail;
Vec2 trail_p0;
Vec2 trail_p1;
b32 is_first_trail;
b32 is_hit;
Vec2 hit_entry;
@ -153,12 +159,6 @@ Struct(P_Ent)
Vec2 hit_entry_velocity;
P_MaterialKind hit_material;
//- Trail
b32 is_trail;
Vec2 trail_p0;
Vec2 trail_p1;
//- Bomb
b32 is_bomb;
@ -459,7 +459,7 @@ Enum(P_MsgKind)
// Server -> Client
P_MsgKind_Tiles,
P_MsgKind_PublicState,
P_MsgKind_NetVars,
P_MsgKind_COUNT
};
@ -554,12 +554,12 @@ Struct(P_RaycastResult)
//~ State types
// NOTE:
// Public state is scanned and reflected dumbly to clients each frame,
// so absurdly large data should not go here.
// Network vars are networked reliably to clients whenever any change is detected.
// Large or frequently updated data should not go here.
//
Struct(P_PublicState)
Struct(P_NetVarState)
{
b32 is_recording_demo;
f32 server_tweak;
};
Struct(P_SimStatistics)

View File

@ -69,14 +69,13 @@ void S_TickForever(WaveLaneCtx *lane)
BB_Buff packer_bb = BB_AcquireDynamicBuff(Gibi(64));
BB_Writer packer_bbw = BB_WriterFromBuff(&packer_bb);
P_PublicState *public = &S.public_state;
// FIXME: Header
Rng user_msg_tick_range = RNG(SIM_TICKS_PER_SECOND * -SIM_MAX_PING, SIM_TICKS_PER_SECOND * SIM_MAX_PING);
P_MsgList queued_user_msgs = Zi;
P_MsgNode *first_free_user_msg_node = 0;
P_NetVarState *nvars = &S.nvars;
@ -406,98 +405,9 @@ void S_TickForever(WaveLaneCtx *lane)
}
}
//////////////////////////////
//- Apply demo controls
// FIXME: Remove this
PERSIST i64 current_demo_tick = 0;
PERSIST Demo *demo = 0;
PERSIST b32 is_playing_demo;
if (!demo)
{
demo = PushStruct(perm, Demo);
}
{
// FIXME: Remove this
if (is_playing_demo)
{
// Init tracks
{
P_EntList ents_to_spawn = Zi;
for (DemoTrack *track = demo->first_track; track; track = track->next)
{
P_Ent *player = P_EntFromKey(world_frame, track->player);
if (!player->is_player)
{
player = P_PushTempEnt(frame_arena, &ents_to_spawn);
player->key = P_RandEntKey();
player->is_player = 1;
}
for (DemoCmd *demo_cmd = track->first_cmd; demo_cmd; demo_cmd = demo_cmd->next)
{
P_Control control = demo_cmd->control;
}
}
P_SpawnEntsFromList(world_frame, ents_to_spawn);
}
// FIXME: No linear search
for (DemoTrack *track = demo->first_track; track; track = track->next)
{
P_Ent *player = P_EntFromKey(world_frame, track->player);
for (DemoCmd *demo_cmd = track->first_cmd; demo_cmd; demo_cmd = demo_cmd->next)
{
if (demo_cmd->demo_tick == current_demo_tick)
{
P_Control control = demo_cmd->control;
player->control = demo_cmd->control;
break;
}
}
}
}
}
//////////////////////////////
//- Apply client controls
for (S_Client *client = S.first_client; !S_IsClientNil(client); client = client->next)
{
P_Control *control = &client->controls[world_frame->tick % client->controls_cap];
@ -507,40 +417,10 @@ void S_TickForever(WaveLaneCtx *lane)
if (player->is_player)
{
player->control = *control;
if (client->is_recording_demo)
{
// FIXME: No linear search
DemoTrack *track = 0;
{
{
for (track = demo->first_track; track; track = track->next)
{
if (P_MatchEntKey(track->player, player->key))
{
break;
}
}
}
if (!track)
{
track = PushStruct(perm, DemoTrack);
track->player = player->key;
DllQueuePush(demo->first_track, demo->last_track, track);
}
}
DemoCmd *demo_cmd = PushStruct(perm, DemoCmd);
demo_cmd->demo_tick = current_demo_tick;
demo_cmd->control = player->control;
SllQueuePush(track->first_cmd, track->last_cmd, demo_cmd);
}
}
}
}
//////////////////////////////
//- Apply bot controls
@ -839,25 +719,31 @@ void S_TickForever(WaveLaneCtx *lane)
}
//////////////////////////////
//- Push public state messages
// TODO: Don't network reliably
// TODO: Delta compress
//- Push net vars
{
P_Msg *msg = P_PushMsg(P_MsgKind_PublicState, Zstr);
msg->kind = P_MsgKind_PublicState;
msg->data = StringFromStruct(public);
String nvars_str = StringFromStruct(nvars);
u64 nvars_hash = HashString(nvars_str);
for (S_Client *client = S.first_client; !S_IsClientNil(client); client = client->next)
{
if (client->sent_nvars_hash != nvars_hash)
{
P_Msg *msg = P_PushMsg(P_MsgKind_NetVars, Zstr);
msg->kind = P_MsgKind_NetVars;
msg->data = nvars_str;
msg->dst = client->net_key;
client->sent_nvars_hash = nvars_hash;
}
}
}
//////////////////////////////
//- Push tile messages
{
// TODO: Receive remote tile hashes via player snapshots
for (S_Client *client = S.first_client; !S_IsClientNil(client); client = client->next)
{
if (tiles_dirty || client->remote_tiles_hash != world->tiles_hash)
if (tiles_dirty || client->sent_tiles_hash != world->tiles_hash)
{
P_Msg *msg = P_PushMsg(P_MsgKind_Tiles, Zstr);
msg->kind = P_MsgKind_Tiles;
@ -866,7 +752,7 @@ void S_TickForever(WaveLaneCtx *lane)
msg->dst = client->net_key;
msg->data = STRING(P_TilesCount, world->tiles);
msg->xf = XformIdentity;
client->remote_tiles_hash = world->tiles_hash;
client->sent_tiles_hash = world->tiles_hash;
}
}
}

View File

@ -1,51 +1,3 @@
////////////////////////////////////////////////////////////
//~ Demo types
// FIXME: Remove this
Struct(DemoCmd)
{
DemoCmd *next;
i64 demo_tick;
P_Control control;
};
Struct(DemoTrack)
{
DemoTrack *next;
DemoTrack *prev;
P_EntKey player;
DemoCmd *first_cmd;
DemoCmd *last_cmd;
};
Struct(Demo)
{
DemoTrack *first_track;
DemoTrack *last_track;
};
////////////////////////////////////////////////////////////
//~ Client types
@ -74,7 +26,8 @@ Struct(S_Client)
i64 demo_record_tick_offset;
b32 is_recording_demo;
u64 remote_tiles_hash;
u64 sent_tiles_hash;
u64 sent_nvars_hash;
};
Struct(S_ClientBin)
@ -97,7 +50,7 @@ Struct(S_Ctx)
i64 client_bins_count;
S_ClientBin *client_bins;
P_PublicState public_state;
P_NetVarState nvars;
};
extern S_Ctx S;

File diff suppressed because it is too large Load Diff

View File

@ -317,9 +317,10 @@ Enum(V_PanelFlag)
{
V_PanelFlag_None = 0,
V_PanelFlag_Ignore = (1 << 0),
V_PanelFlag_Spawn = (1 << 1),
V_PanelFlag_Profiler = (1 << 2),
V_PanelFlag_Console = (1 << 3),
V_PanelFlag_Screen = (1 << 1),
V_PanelFlag_Spawn = (1 << 2),
V_PanelFlag_Profiler = (1 << 3),
V_PanelFlag_Console = (1 << 4),
};
Struct(V_Panel)
@ -426,9 +427,7 @@ Struct(V_Frame)
String window_restore;
// Vis commands
i64 cmds_count;
V_CmdNode *first_cmd_node;
V_CmdNode *last_cmd_node;
i64 cmd_counts_by_kind[V_CmdKind_COUNT];
// Unflattened emitters list
V_EmitterNode *first_emitter_node;
@ -452,14 +451,15 @@ Struct(V_Ctx)
P_PublicState public_state;
P_NetVarState nvars;
V_Panel *root_panel;
i64 queued_cmds_count;
V_CmdNode *first_queued_cmd_node;
V_CmdNode *last_queued_cmd_node;
V_CmdNode *first_free_cmd_node;
@ -504,6 +504,7 @@ void V_Shutdown(void);
V_Frame *V_CurrentFrame(void);
V_Frame *V_PrevFrame(void);
V_Cmd *V_PushVisCmd(String name);
i64 V_CountVisCmds(V_CmdKind kind);
String V_StringFromHotkey(Arena *arena, V_Hotkey hotkey);
void V_PushParticles(V_Emitter src);

View File

@ -9,11 +9,12 @@ f32 V_RandFromPos(Vec3 pos)
return rand;
}
Vec4 V_ColorFromParticle(V_ParticleDesc desc, u32 particle_idx, u32 density)
Vec4 V_ColorFromParticle(V_ParticleDesc desc, u32 particle_idx, f32 alive_seconds, u32 density)
{
Vec4 result = 0;
u64 seed = MixU64(V_ParticleColorBasis ^ particle_idx);
f32 rand_color = Norm16(seed >> 0);
f32 rand_lifetime = Norm16(seed >> 16);
result = desc.base_color;
@ -48,6 +49,36 @@ Vec4 V_ColorFromParticle(V_ParticleDesc desc, u32 particle_idx, u32 density)
result.rgb = result.rgb + (rand_color - 0.5) * 0.05;
if (desc.lifetime_min < Inf && alive_seconds > 0)
{
f32 lifetime = desc.lifetime_min + (desc.lifetime_max - desc.lifetime_min) * rand_lifetime;
f32 lifetime_complete = saturate(alive_seconds / lifetime);
f32 v = lifetime_complete * lifetime_complete;
// result.a *= 1.0 - lifetime_complete;
result.a *= 1.0 - v;
// result.rgb *= 1.0 - lifetime_complete;
}
// if (desc.lifetime < Inf && alive_seconds > 0)
// {
// // result.a *= desc.lifetime / alive_seconds;
// f32 lifetime_complete = alive_seconds / desc.lifetime;
// result.a *= lerp(1, 0, saturate(lifetime_complete));
// // result.a *= 0;
// // result.a *= 1.0 - saturate(alive_seconds / desc.lifetime);
// }
return result;
}
@ -103,6 +134,7 @@ ComputeShader(V_PrepareCellsCS)
RWTexture2D<Vec4> dry_stains = G_Deref(frame.dry_stains, RWTexture2D<Vec4>);
RWTexture2D<f32> drynesses = G_Deref(frame.drynesses, RWTexture2D<f32>);
RWTexture2D<u32> occluders = G_Deref(frame.occluders, RWTexture2D<u32>);
StructuredBuffer<V_Particle> particles = G_Deref(frame.particles, StructuredBuffer<V_Particle>);
Vec2 cell_pos = SV_DispatchThreadID + 0.5;
if (all(cell_pos < P_WorldCellsDims))
@ -137,8 +169,9 @@ ComputeShader(V_PrepareCellsCS)
V_ParticleDesc desc = V_DescFromParticleKind(particle_kind);
u32 density = densities[cell_pos];
u32 particle_idx = packed & ((1 << 24) - 1);
f32 alive_seconds = 0;
Vec4 base_color = V_ColorFromParticle(desc, particle_idx, density);
Vec4 base_color = V_ColorFromParticle(desc, particle_idx, 0, density);
Vec4 dry_color = base_color * desc.dry_factor;
base_color.rgb *= base_color.a;
@ -444,7 +477,7 @@ ComputeShader(V_SimParticlesCS)
particle = (V_Particle)0;
particle.kind = emitter.kind;
particle.life = 0;
particle.alive_seconds = 0;
particle.pos = lerp(emitter.pos.p0, emitter.pos.p1, rand_offset);
particle.velocity = Vec2(cos(initial_angle), sin(initial_angle)) * initial_speed;
}
@ -464,7 +497,7 @@ ComputeShader(V_SimParticlesCS)
StaticAssert(V_ParticlesCap <= (1 << 24)); // particle idx must fit in 24 bits
StaticAssert(V_ParticleKind_COUNT <= 0x7F); // particle kind must fit in 7 bits
if (particle.life == 0)
if (particle.alive_seconds == 0)
{
Vec2 cell_pos = mul(frame.af.world_to_cell, Vec3(particle.pos, 1));
if (IsInside(cell_pos, P_WorldCellsDims))
@ -663,13 +696,14 @@ ComputeShader(V_SimParticlesCS)
}
// f32 falloff = saturate(lerp(1, 2, rand_falloff) * frame.dt);
f32 falloff = saturate(lerp(10, 20, rand_falloff) * frame.dt);
// f32 falloff = saturate(lerp(10, 20, rand_falloff) * frame.dt);
f32 falloff = 0;
particle.velocity *= 1.0f - falloff;
particle.pos = p0 + (p1 - p0) * t;
}
particle.life += frame.dt;
particle.alive_seconds += frame.dt;
}
//////////////////////////////
@ -859,8 +893,20 @@ ComputeShader(V_CompositeCS)
Vec4 albedo_tex_color = albedo_tex[screen_pos];
//////////////////////////////
//- Particles
//- Particles / stains
// FIXME: Stain
Vec4 stain_color = 0;
@ -878,14 +924,17 @@ ComputeShader(V_CompositeCS)
{
Texture2D<u32> cells = G_Deref(frame.particle_cells[layer], Texture2D<u32>);
Texture2D<u32> densities = G_Deref(frame.particle_densities[layer], Texture2D<u32>);
u32 packed = cells[cell_pos];
V_ParticleKind particle_kind = (V_ParticleKind)((packed >> 24) & 0x7F);
if (particle_kind != V_ParticleKind_None)
{
u32 particle_idx = packed & ((1 << 24) - 1);
V_Particle particle = particles[particle_idx];
u32 density = densities[cell_pos];
V_ParticleDesc desc = V_DescFromParticleKind(particle_kind);
u32 particle_idx = packed & ((1 << 24) - 1);
Vec4 cell_color = V_ColorFromParticle(desc, particle_idx, density);
Vec4 cell_color = V_ColorFromParticle(desc, particle_idx, particle.alive_seconds, density);
cell_color.rgb *= cell_color.a;
if (layer == V_ParticleLayer_Ground)
@ -907,6 +956,64 @@ ComputeShader(V_CompositeCS)
stain_color *= 0.5;
}
// //////////////////////////////
// //- Particles / stains
// // FIXME: Stain
// Vec4 stain_color = 0;
// {
// Vec4 wet_stain = stains[cell_pos];
// Vec4 dry_stain = dry_stains[cell_pos];
// f32 dryness = drynesses[cell_pos];
// stain_color = max(lerp(wet_stain, dry_stain, dryness), 0);
// }
// Vec4 ground_particle_color = 0;
// Vec4 air_particle_color = 0;
// for (V_ParticleLayer layer = (V_ParticleLayer)0; layer < V_ParticleLayer_COUNT; layer += (V_ParticleLayer)1)
// {
// Texture2D<u32> cells = G_Deref(frame.particle_cells[layer], Texture2D<u32>);
// Texture2D<u32> densities = G_Deref(frame.particle_densities[layer], Texture2D<u32>);
// u32 packed = cells[cell_pos];
// V_ParticleKind particle_kind = (V_ParticleKind)((packed >> 24) & 0x7F);
// if (particle_kind != V_ParticleKind_None)
// {
// u32 density = densities[cell_pos];
// V_ParticleDesc desc = V_DescFromParticleKind(particle_kind);
// u32 particle_idx = packed & ((1 << 24) - 1);
// Vec4 cell_color = V_ColorFromParticle(desc, particle_idx, density);
// cell_color.rgb *= cell_color.a;
// if (layer == V_ParticleLayer_Ground)
// {
// ground_particle_color = BlendPremul(cell_color, ground_particle_color);
// }
// else
// {
// air_particle_color = BlendPremul(cell_color, air_particle_color);
// }
// }
// }
// // Darken wall particles / stains
// if (tile == P_TileKind_Wall)
// {
// ground_particle_color *= 0.5;
// air_particle_color *= 0.5;
// stain_color *= 0.5;
// }
//////////////////////////////
//- Compose world

View File

@ -45,7 +45,7 @@ Struct(V_DVertPSOutput)
//~ Helpers
f32 V_RandFromPos(Vec3 pos);
Vec4 V_ColorFromParticle(V_ParticleDesc desc, u32 particle_idx, u32 density);
Vec4 V_ColorFromParticle(V_ParticleDesc desc, u32 particle_idx, f32 alive_seconds, u32 density);
////////////////////////////////////////////////////////////
//~ Shaders

View File

@ -4,17 +4,18 @@
V_ParticleDesc V_DescFromParticleKind(V_ParticleKind kind)
{
V_ParticleDesc descs[V_ParticleKind_COUNT] = {
#define X(name, flags, layer, stain_rate, pen_rate, lifetime, prune_speed_threshold, base_color, dry_factor) \
{ \
V_ParticleKind_##name, \
flags, \
layer, \
stain_rate, \
pen_rate, \
lifetime, \
prune_speed_threshold, \
LinearFromSrgb(base_color), \
LinearFromSrgb(dry_factor) \
#define X(name, flags, layer, stain_rate, pen_rate, lifetime_min, lifetime_max, prune_speed_threshold, base_color, dry_factor) \
{ \
V_ParticleKind_##name, \
flags, \
layer, \
stain_rate, \
pen_rate, \
lifetime_min, \
lifetime_max, \
prune_speed_threshold, \
LinearFromSrgb(base_color), \
LinearFromSrgb(dry_factor) \
},
V_ParticlesXList(X)
#undef X

View File

@ -50,7 +50,7 @@ Enum(V_ParticleLayer)
/* Flags */ V_ParticleFlag_None, \
/* Layer */ V_ParticleLayer_Ground, \
/* Stain rate, pen chance */ 30, 0, \
/* Lifetime */ Inf, \
/* Lifetime */ Inf, Inf, \
/* Prune speed threshold */ 0.01, \
/* Base color */ VEC4(0, 0, 0, 0), \
/* Dry color factor */ VEC4(1, 1, 1, 1) \
@ -62,7 +62,7 @@ Enum(V_ParticleLayer)
/* Flags */ V_ParticleFlag_NoReflect | V_ParticleFlag_StainWhenPruned, \
/* Layer */ V_ParticleLayer_Ground, \
/* Stain rate, pen chance */ 100, 0.25, \
/* Lifetime */ Inf, \
/* Lifetime */ Inf, Inf, \
/* Prune speed threshold */ 0.5, \
/* Base color */ VEC4(0.6, 0.1, 0.1, 0.05), \
/* Dry color factor */ VEC4(0.4, 0.4, 0.4, 1) \
@ -72,7 +72,7 @@ Enum(V_ParticleLayer)
/* Flags */ V_ParticleFlag_StainWhenPruned, \
/* Layer */ V_ParticleLayer_Mid, \
/* Stain rate, pen chance */ 30, 0, \
/* Lifetime */ Inf, \
/* Lifetime */ Inf, Inf, \
/* Prune speed threshold */ 0.01, \
/* Base color */ VEC4(0.5, 0.1, 0.1, 0.8), \
/* Dry color factor */ VEC4(1, 1, 1, 1) \
@ -82,7 +82,7 @@ Enum(V_ParticleLayer)
/* Flags */ V_ParticleFlag_StainWhenPruned, \
/* Layer */ V_ParticleLayer_Mid, \
/* Stain rate, pen chance */ 0, 0, \
/* Lifetime */ Inf, \
/* Lifetime */ Inf, Inf, \
/* Prune speed threshold */ 0.01, \
/* Base color */ VEC4(0.4, 0.3, 0.2, 1), \
/* Dry color factor */ VEC4(1, 1, 1, 1) \
@ -92,7 +92,17 @@ Enum(V_ParticleLayer)
/* Flags */ V_ParticleFlag_StainWhenPruned, \
/* Layer */ V_ParticleLayer_Mid, \
/* Stain rate, pen chance */ 0, 0, \
/* Lifetime */ Inf, \
/* Lifetime */ Inf, Inf, \
/* Prune speed threshold */ 0.1, \
/* Base color */ VEC4(2, 0.5, 0, 1), \
/* Dry color factor */ VEC4(0.2, 0.1, 0.0, 1) \
) \
X( \
/* Name */ Spark, \
/* Flags */ V_ParticleFlag_StainWhenPruned, \
/* Layer */ V_ParticleLayer_Mid, \
/* Stain rate, pen chance */ 0, 0, \
/* Lifetime */ 0.2, 5, \
/* Prune speed threshold */ 0.1, \
/* Base color */ VEC4(2, 0.5, 0, 1), \
/* Dry color factor */ VEC4(0.2, 0.1, 0.0, 1) \
@ -104,7 +114,7 @@ Enum(V_ParticleLayer)
/* Flags */ V_ParticleFlag_OnlyCollideWithWalls | V_ParticleFlag_GasBlend, \
/* Layer */ V_ParticleLayer_Mid, \
/* Stain rate, pen chance */ 0, 0, \
/* Lifetime */ 0.075, \
/* Lifetime */ 0.075, 0.075, \
/* Prune speed threshold */ 0.01, \
/* Base color */ VEC4(0.8, 0.6, 0.2, 0.25), \
/* Dry color factor */ VEC4(1, 1, 1, 1) \
@ -114,10 +124,20 @@ Enum(V_ParticleLayer)
/* Flags */ V_ParticleFlag_OnlyCollideWithWalls | V_ParticleFlag_GasBlend, \
/* Layer */ V_ParticleLayer_Air, \
/* Stain rate, pen chance */ 0, 0, \
/* Lifetime */ Inf, \
/* Lifetime */ Inf, Inf, \
/* Prune speed threshold */ 0.01, \
/* Base color */ VEC4(0.25, 0.25, 0.25, 0.75), \
/* Dry color factor */ VEC4(1, 1, 1, 1) \
) \
X( \
/* Name */ Flash, \
/* Flags */ V_ParticleFlag_None, \
/* Layer */ V_ParticleLayer_Air, \
/* Stain rate, pen chance */ 0, 0, \
/* Lifetime */ 0.0, .05, \
/* Prune speed threshold */ 0, \
/* Base color */ VEC4(10, 3.5, 0, 1), \
/* Dry color factor */ VEC4(0.2, 0.1, 0.0, 1) \
) \
\
/* Test particles */ \
@ -126,7 +146,7 @@ Enum(V_ParticleLayer)
/* Flags */ V_ParticleFlag_None, \
/* Layer */ V_ParticleLayer_Mid, \
/* Stain rate, pen chance */ 0, 0, \
/* Lifetime */ Inf, \
/* Lifetime */ Inf, Inf, \
/* Prune speed threshold */ 0.01, \
/* Base color */ VEC4(1, 1, 0, 1), \
/* Dry color factor */ VEC4(1, 1, 1, 1) \
@ -159,7 +179,7 @@ Struct(V_Particle)
i32 kind; // If >= 0, then this maps to V_ParticleKind. Otherwise it represent a particle to be initialized using emitter at index [abs(kind) - 1]
u32 origin_occluder;
u32 prev_occluder; // TODO: Remove this
f32 life;
f32 alive_seconds;
f32 stain_accum;
u32 cells_count;
Vec2 pos;
@ -173,7 +193,8 @@ Struct(V_ParticleDesc)
V_ParticleLayer layer;
f32 stain_rate;
f32 pen_rate;
f32 lifetime;
f32 lifetime_min;
f32 lifetime_max;
f32 prune_speed_threshold;
Vec4 base_color;
Vec4 dry_factor;
@ -314,6 +335,8 @@ Struct(V_SharedFrame)
b32 is_looking;
b32 is_moving;
b32 show_consoles;
b32 show_profilers;
b32 is_editing;
b32 ui_debug;
b32 is_selecting;
@ -337,6 +360,7 @@ Struct(V_SharedFrame)
Vec2 world_selection_start;
Vec2 edit_camera_pos;
f32 edit_camera_zoom;
f32 camera_shake;
//- Camera

View File

@ -321,8 +321,8 @@ void UI_PushDefaults(void)
case UI_StyleKind_HotRate: { desc.style.HotRate = 15; } break;
case UI_StyleKind_HoveredRate: { desc.style.HoveredRate = 15; } break;
case UI_StyleKind_ExistsRate: { desc.style.ExistsRate = 30; } break;
case UI_StyleKind_MiscRate: { desc.style.MiscRate = Inf; } break;
case UI_StyleKind_DimsRate: { desc.style.DimsRate = VEC2(Inf, Inf); } break;
case UI_StyleKind_MiscRate: { desc.style.MiscRate = 1000; } break;
case UI_StyleKind_DimsRate: { desc.style.DimsRate = VEC2(1000, 1000); } break;
};
UI_PushStyle(desc);
}
@ -862,6 +862,30 @@ UI_Frame *UI_BeginFrame(UI_FrameFlag frame_flags)
f32 target_exists = feedback->exists_absolute ? upper_target : lower_target;
f64 target_misc = box->desc.misc;
// f32 delta_active_rate = box->desc.active_rate * frame->dt;
// f32 delta_hot_rate = box->desc.hot_rate * frame->dt;
// f32 delta_hovered_rate = box->desc.hovered_rate * frame->dt;
// f32 delta_exists_rate = box->desc.exists_rate * frame->dt;
// f32 delta_misc_rate = box->desc.misc_rate * frame->dt;
// // delta_active_rate = IsNan(delta_active_rate) ? 1 : delta_active_rate;
// // delta_hot_rate = IsNan(delta_hot_rate) ? 1 : delta_hot_rate;
// // delta_hovered_rate = IsNan(delta_hovered_rate) ? 1 : delta_hovered_rate;
// // delta_exists_rate = IsNan(delta_exists_rate) ? 1 : delta_exists_rate;
// // delta_misc_rate = IsNan(delta_misc_rate) ? 1 : delta_misc_rate;
// feedback->active_smooth = SaturateF32(LerpF32(feedback->active_smooth, target_active, delta_active_rate));
// feedback->hot_smooth = SaturateF32(LerpF32(feedback->hot_smooth, target_hot, delta_hot_rate));
// feedback->hovered_smooth = SaturateF32(LerpF32(feedback->hovered_smooth, target_hovered, delta_hovered_rate));
// feedback->exists_smooth = SaturateF32(LerpF32(feedback->exists_smooth, target_exists, delta_exists_rate));
// feedback->misc_smooth = SaturateF64(LerpF64(feedback->misc_smooth, target_misc, delta_misc_rate));
feedback->active_smooth = SaturateF32(LerpF32(feedback->active_smooth, target_active, box->desc.active_rate * frame->dt));
feedback->hot_smooth = SaturateF32(LerpF32(feedback->hot_smooth, target_hot, box->desc.hot_rate * frame->dt));
feedback->hovered_smooth = SaturateF32(LerpF32(feedback->hovered_smooth, target_hovered, box->desc.hovered_rate * frame->dt));
@ -869,6 +893,9 @@ UI_Frame *UI_BeginFrame(UI_FrameFlag frame_flags)
feedback->misc_smooth = SaturateF64(LerpF64(feedback->misc_smooth, target_misc, box->desc.misc_rate * frame->dt));
// f32 active_blend_rate = (15 * frame->dt);
// f32 hot_blend_rate = (15 * frame->dt);
// f32 hovered_blend_rate = (15 * frame->dt);