diff --git a/src/mixer/mixer.c b/src/mixer/mixer.c deleted file mode 100644 index fb2354ff..00000000 --- a/src/mixer/mixer.c +++ /dev/null @@ -1,459 +0,0 @@ -// TODO: Cap max sounds playing. - -// Terminology: -// -// `Sample`: Once "PCM" data point representing the smallest unit of audio available for a single channel at a point in time. -// Examples: -// - Single 32 bit float output by mixer and consumed by playback API, that the API interprets as a sound sample for a single channel -// - Single 16 bit integer output by audio file decoder, that may represent a mono sound sample -// -// `Frame`: Represents a single data point of audio for all audio channels at a point in time. -// Examples: -// - Single 16 bit integer output by audio file decoder representing one mono sound sample -// - 2 16 bit integer samples output by audio file decoder representing two sound samples, one sample for each audio channel -// - 2 32 bit float samples output by mixer and consumed by playback API, one sample for each audio channel - -MIX_Ctx M = Zi; - -//////////////////////////////////////////////////////////// -//~ Bootstrap - -void MIX_Bootstrap(void) -{ - MIX.track_arena = AcquireArena(Gibi(64)); - MIX.listener_pos = VEC2(0, 0); - MIX.listener_dir = VEC2(0, -1); -} - -//////////////////////////////////////////////////////////// -//~ Track - -MIX_Handle MIX_HandleFromTrack(MIX_Track *track) -{ - MIX_Handle result = Zi; - result.gen = track->gen; - result.data = track; - return result; -} - -MIX_Track *MIX_TrackFromHandle(MIX_Handle handle) -{ - MIX_Track *track = (MIX_Track *)handle.data; - if (track && track->gen == handle.gen) - { - return track; - } - else - { - return 0; - } -} - -MIX_Track *MIX_AcquireTrackLocked(Lock *lock, SND_Sound *sound) -{ - AssertLockedE(lock, &MIX.mutex); - - MIX_Track *track = 0; - if (MIX.track_first_free) - { - // Take from free list - track = MIX.track_first_free; - MIX_Track *next_free = track->next; - MIX.track_first_free = next_free; - if (next_free) - { - next_free->prev = 0; - } - *track = (MIX_Track) { .gen = track->gen + 1 }; - } - else - { - // Acquire new - track = PushStruct(MIX.track_arena, MIX_Track); - track->gen = 1; - } - - track->sound = sound; - track->mix.source = sound; - track->mix.track_handle = MIX_HandleFromTrack(track); - - // Append to playing list - MIX_Track *prev = MIX.track_last_playing; - if (prev) - { - prev->next = track; - } - else - { - MIX.track_first_playing = track; - } - MIX.track_last_playing = track; - track->prev = prev; - ++MIX.track_playing_count; - - return track; -} - -void MIX_ReleaseTrackLocked(Lock *lock, MIX_Track *track) -{ - AssertLockedE(lock, &MIX.mutex); - - // Remove from playing list - MIX_Track *prev = track->prev; - MIX_Track *next = track->next; - if (prev) - { - prev->next = next; - } - else - { - // Track was first in list - MIX.track_first_playing = next; - } - if (next) - { - next->prev = prev; - } - else - { - // Track was last in list - MIX.track_last_playing = prev; - } - --MIX.track_playing_count; - ++track->gen; - - // Add to free list - track->prev = 0; - track->next = MIX.track_first_free; - if (MIX.track_first_free) - { - MIX.track_first_free->prev = track; - } - MIX.track_first_free = track; -} - -// TODO: Rework interface to be command based instead of directly modifying tracks. - -MIX_Handle MIX_PlaySound(SND_Sound *sound) -{ - return MIX_PlaySoundEx(sound, MIX_TRACKDESC()); -} - -MIX_Handle MIX_PlaySoundEx(SND_Sound *sound, MIX_TrackDesc desc) -{ - MIX_Track *track; - { - Lock lock = LockE(&MIX.mutex); - { - track = MIX_AcquireTrackLocked(&lock, sound); - track->desc = desc; - } - Unlock(&lock); - } - return MIX_HandleFromTrack(track); -} - -// NOTE: This is quite inefficient. -MIX_TrackDesc MIX_TrackDescFromHandle(MIX_Handle handle) -{ - MIX_TrackDesc result = Zi; - - MIX_Track *track = MIX_TrackFromHandle(handle); - if (track) - { - // TODO: Only lock mutex on track itself or something - Lock lock = LockE(&MIX.mutex); - { - // Confirm handle is still valid now that we're locked - track = MIX_TrackFromHandle(handle); - if (track) - { - result = track->desc; - } - } - Unlock(&lock); - } - - return result; -} - -// NOTE: This is quite inefficient. -void MIX_UpdateTrack(MIX_Handle handle, MIX_TrackDesc desc) -{ - MIX_Track *track = MIX_TrackFromHandle(handle); - if (track) - { - // TODO: Only lock mutex on track itself or something - Lock lock = LockE(&MIX.mutex); - { - // Confirm handle is still valid now that we're locked - track = MIX_TrackFromHandle(handle); - if (track) - { - track->desc = desc; - } - } - Unlock(&lock); - } -} - -void MIX_UpdateListener(Vec2 pos, Vec2 dir) -{ - Lock lock = LockE(&MIX.mutex); - { - MIX.listener_pos = pos; - MIX.listener_dir = NormVec2(dir); - } - Unlock(&lock); -} - -//////////////////////////////////////////////////////////// -//~ Mix - -i16 MIX_SampleSound(SND_Sound *sound, u64 sample_pos, b32 wrap) -{ - if (wrap) - { - return sound->samples[sample_pos % sound->samples_count]; - } - else if (sample_pos < sound->samples_count) - { - return sound->samples[sample_pos]; - } - else - { - return 0; - } -} - -// To be called once per audio playback interval -MIX_PcmF32 MIX_MixAllTracks(Arena *arena, u64 frame_count) -{ - TempArena scratch = BeginScratch(arena); - - MIX_PcmF32 result = Zi; - result.count = frame_count * 2; - result.samples = PushStructs(arena, f32, result.count); - - Vec2 listener_pos = VEC2(0, 0); - Vec2 listener_dir = VEC2(0, 0); - - //- Create temp mix array - - MIX_MixData **mixes = 0; - u64 mixes_count = 0; - { - Lock lock = LockE(&MIX.mutex); - - // Read listener info - listener_pos = MIX.listener_pos; - listener_dir = MIX.listener_dir; - - // Update & read mixes - mixes = PushStructsNoZero(scratch.arena, MIX_MixData *, MIX.track_playing_count); - for (MIX_Track *track = MIX.track_first_playing; track; track = track->next) - { - MIX_MixData *mix = &track->mix; - mix->desc = track->desc; - mixes[mixes_count++] = mix; - } - - Unlock(&lock); - } - - //- Process mix data - - for (u64 mix_index = 0; mix_index < mixes_count; ++mix_index) - { - MIX_MixData *mix = mixes[mix_index]; - - if (mix->source->samples_count <= 0) - { - // Skip empty sounds - continue; - } - - SND_Sound *source = mix->source; - MIX_TrackDesc desc = mix->desc; - MIX_EffectData *effect_data = &mix->effect_data; - b32 source_is_stereo = source->flags & SND_SoundFlag_Stereo; - f32 speed = MaxF32(0, desc.speed); - - //- Determine sample range - u64 source_samples_count = 0; - if (source_is_stereo) - { - source_samples_count = frame_count * 2; - // Round to nearest frame boundary (nearest multiple of 2) - source_samples_count = (u64)CeilF32ToI32((f32)source_samples_count * speed); - source_samples_count &= ~1; - } - else - { - source_samples_count = frame_count; - // Round to nearest sample - source_samples_count = (u64)RoundF32ToI32((f32)source_samples_count * speed); - } - - u64 source_sample_pos_start = mix->source_pos; - u64 source_sample_pos_end = source_sample_pos_start + source_samples_count; - if (source_sample_pos_end >= source->samples_count) - { - if (desc.looping) - { - source_sample_pos_end = source_sample_pos_end % source->samples_count; - } - else - { - source_sample_pos_end = source->samples_count; - mix->track_finished = 1; - } - } - u64 source_frames_count = source_is_stereo ? source_samples_count / 2 : source_samples_count; - u64 source_frame_pos_start = source_is_stereo ? source_sample_pos_start / 2 : source_sample_pos_start; - - mix->source_pos = source_sample_pos_end; - - MIX_PcmF32 mix_pcm = { - .count = result.count, - .samples = PushStructs(scratch.arena, f32, result.count) - }; - - //- Resample - // Transform 16 bit source -> 32 bit stereo at output duration - { - f32 *out_samples = mix_pcm.samples; - - u64 out_frames_count = mix_pcm.count / 2; - - // TODO: Fast path for 1:1 copy when speed = 1.0? - // TODO: Optimize - if (source_is_stereo) - { - // 16 bit Stereo -> 32 bit Stereo - for (u64 out_frame_pos = 0; out_frame_pos < out_frames_count; ++out_frame_pos) - { - f32 in_frame_pos_exact = source_frame_pos_start + (((f32)out_frame_pos / (f32)out_frames_count) * (f32)source_frames_count); - u32 in_frame_pos_prev = FloorF32ToI32(in_frame_pos_exact); - u32 in_frame_pos_next = CeilF32ToI32(in_frame_pos_exact); - - // Sample source - f32 sample1_prev = MIX_SampleSound(source, (in_frame_pos_prev * 2) + 0, desc.looping) * (1.f / 32768.f); - f32 sample1_next = MIX_SampleSound(source, (in_frame_pos_next * 2) + 0, desc.looping) * (1.f / 32768.f); - f32 sample2_prev = MIX_SampleSound(source, (in_frame_pos_prev * 2) + 1, desc.looping) * (1.f / 32768.f); - f32 sample2_next = MIX_SampleSound(source, (in_frame_pos_next * 2) + 1, desc.looping) * (1.f / 32768.f); - - // Lerp - f32 t = in_frame_pos_exact - (f32)in_frame_pos_prev; - f32 sample1 = LerpF32(sample1_prev, sample1_next, t); - f32 sample2 = LerpF32(sample2_prev, sample2_next, t); - - out_samples[(out_frame_pos * 2) + 0] += sample1; - out_samples[(out_frame_pos * 2) + 1] += sample2; - } - } - else - { - // 16 bit Mono -> 32 bit Stereo - for (u64 out_frame_pos = 0; out_frame_pos < out_frames_count; ++out_frame_pos) - { - f32 in_frame_pos_exact = source_frame_pos_start + (((f32)out_frame_pos / (f32)out_frames_count) * (f32)source_frames_count); - u32 in_frame_pos_prev = FloorF32ToI32(in_frame_pos_exact); - u32 in_frame_pos_next = CeilF32ToI32(in_frame_pos_exact); - - // Sample source - f32 sample_prev = MIX_SampleSound(source, in_frame_pos_prev, desc.looping) * (1.f / 32768.f); - f32 sample_next = MIX_SampleSound(source, in_frame_pos_next, desc.looping) * (1.f / 32768.f); - - // Lerp - f32 t = (f32)in_frame_pos_exact - in_frame_pos_prev; - f32 sample = LerpF32(sample_prev, sample_next, t); - - out_samples[(out_frame_pos * 2) + 0] += sample; - out_samples[(out_frame_pos * 2) + 1] += sample; - } - } - } - - //- Spatialize - if (desc.flags & MIX_TrackFlag_Spatialize) - { - // Algorithm constants - const f32 rolloff_height = 1.2f; - const f32 rolloff_scale = 6.0f; - const f32 pan_scale = 0.75; - - Vec2 pos = desc.pos; - - // If sound pos = listener pos, pretend sound is close in front of listener. - if (MatchVec2(listener_pos, pos)) - { - pos = AddVec2(listener_pos, MulVec2(listener_dir, 0.001f)); - } - Vec2 sound_rel = SubVec2(pos, listener_pos); - Vec2 sound_rel_dir = NormVec2(sound_rel); - - // Compute volume - f32 volume_start = effect_data->spatial_volume; - f32 volume_end; - { - // https://www.desmos.com/calculator/c2h941hobz - // h = `rolloff_height` - // s = `rolloff_scale` - f32 dist = Vec2Len(sound_rel); - f32 v = (dist / rolloff_scale) + 1.0f; - volume_end = rolloff_height * (1.0f / (v * v)); - } - effect_data->spatial_volume = volume_end; - - // Compute pan - f32 pan_start = effect_data->spatial_pan; - f32 pan_end = WedgeVec2(listener_dir, sound_rel_dir) * pan_scale; - effect_data->spatial_pan = pan_end; - - // Spatialize samples - for (u64 frame_pos = 0; frame_pos < frame_count; ++frame_pos) - { - f32 t = (f32)frame_pos / (f32)(frame_count - 1); - f32 volume = LerpF32(volume_start, volume_end, t); - f32 pan = LerpF32(pan_start, pan_end, t); - - u64 sample1_index = frame_pos * 2; - u64 sample2_index = sample1_index + 1; - - f32 sample_mono = ((mix_pcm.samples[sample1_index + 0] / 2.0f) + (mix_pcm.samples[sample2_index] / 2.0f)) * volume; - - mix_pcm.samples[sample1_index] = sample_mono * (1.0f - pan); - mix_pcm.samples[sample2_index] = sample_mono * (1.0f + pan); - } - } - - //- Mix into result - for (u64 i = 0; i < mix_pcm.count; ++i) - { - result.samples[i] += mix_pcm.samples[i] * desc.volume; - } - } - - //- Update track effect data - { - Lock lock = LockE(&MIX.mutex); - for (u64 i = 0; i < mixes_count; ++i) - { - MIX_MixData *mix = mixes[i]; - MIX_Track *track = MIX_TrackFromHandle(mix->track_handle); - if (track) - { - if (mix->track_finished) - { - // Release finished tracks - MIX_ReleaseTrackLocked(&lock, track); - } - } - } - Unlock(&lock); - } - - EndScratch(scratch); - return result; -} diff --git a/src/mixer/mixer.h b/src/mixer/mixer.h deleted file mode 100644 index 88a6be61..00000000 --- a/src/mixer/mixer.h +++ /dev/null @@ -1,120 +0,0 @@ -//////////////////////////////////////////////////////////// -//~ Track types - -Enum(MIX_TrackFlag) -{ - MIX_TrackFlag_None = 0, - MIX_TrackFlag_Spatialize = (1 << 0) -}; - -Struct(MIX_Handle) -{ - u64 gen; - void *data; -}; - -Struct(MIX_TrackDesc) -{ - MIX_TrackFlag flags; - f32 volume; // 0 -> 1.0+ - f32 speed; // 0 -> 1.0+ - b32 looping; - - Vec2 pos; -}; -#define MIX_TRACKDESC(...) ((MIX_TrackDesc) { \ - .flags = 0, \ - .volume = 1.0, \ - .speed = 1.0, \ - .looping = 0, \ - .pos = VEC2(0, 0), \ - __VA_ARGS__ \ -}) - -//////////////////////////////////////////////////////////// -//~ Mix types - -// Stereo mix of 32 bit float samples -Struct(MIX_PcmF32) -{ - u64 count; - f32 *samples; -}; - -Struct(MIX_EffectData) -{ - // Spatialization - f32 spatial_volume; - f32 spatial_pan; -}; - -Struct(MIX_MixData) -{ - MIX_Handle track_handle; - b32 track_finished; - - MIX_TrackDesc desc; - MIX_EffectData effect_data; - SND_Sound *source; - u64 source_pos; -}; - -Struct(MIX_Track){ - u64 gen; - - // Controlled via interface - SND_Sound *sound; - MIX_TrackDesc desc; - - // Internal - MIX_MixData mix; - - MIX_Track *next; - MIX_Track *prev; -}; - -//////////////////////////////////////////////////////////// -//~ State types - -Struct(MIX_Ctx) -{ - Mutex mutex; - - // Listener - Vec2 listener_pos; - Vec2 listener_dir; - - // Track list - Arena *track_arena; - MIX_Track *track_first_playing; - MIX_Track *track_last_playing; - u64 track_playing_count; - MIX_Track *track_first_free; -}; - -extern MIX_Ctx MIX; - -//////////////////////////////////////////////////////////// -//~ Bootstrap - -void MIX_Bootstrap(void); - -//////////////////////////////////////////////////////////// -//~ Track - -MIX_Handle MIX_HandleFromTrack(MIX_Track *track); -MIX_Track *MIX_TrackFromHandle(MIX_Handle handle); -MIX_Track *MIX_AcquireTrackLocked(Lock *lock, SND_Sound *sound); -void MIX_ReleaseTrackLocked(Lock *lock, MIX_Track *track); - -MIX_Handle MIX_PlaySound(SND_Sound *sound); -MIX_Handle MIX_PlaySoundEx(SND_Sound *sound, MIX_TrackDesc desc); -MIX_TrackDesc MIX_TrackDescFromHandle(MIX_Handle handle); -void MIX_UpdateTrack(MIX_Handle handle, MIX_TrackDesc desc); -void MIX_UpdateListener(Vec2 pos, Vec2 dir); - -//////////////////////////////////////////////////////////// -//~ Mix - -i16 MIX_SampleSound(SND_Sound *sound, u64 sample_pos, b32 wrap); -MIX_PcmF32 MIX_MixAllTracks(Arena *arena, u64 frame_count); diff --git a/src/mixer/mixer.lay b/src/mixer/mixer.lay deleted file mode 100644 index 871dcd24..00000000 --- a/src/mixer/mixer.lay +++ /dev/null @@ -1,19 +0,0 @@ -@Layer mixer - -////////////////////////////// -//- Dependencies - -@Dep platform -@Dep sound - -////////////////////////////// -//- Api - -@IncludeC mixer.h - -@Bootstrap MIX_Bootstrap - -////////////////////////////// -//- Impl - -@IncludeC mixer.c diff --git a/src/pp/pp.c b/src/pp/pp.c index 1e5a4720..665cfc45 100644 --- a/src/pp/pp.c +++ b/src/pp/pp.c @@ -215,28 +215,6 @@ P_Shape P_LocalShapeFromEnt(P_Ent *ent) .count = 1, .radius = TweakFloat("Guy radius", 0.25, 0, 1), ); - - // f32 guy_width = 0.75; - // f32 guy_height = 0.4; - // result = P_ShapeFromDesc( - // .mass = 10, - // .count = 2, - // .points = { VEC2(0, -guy_width / 2 + (guy_height / 2)), VEC2(0, guy_width / 2 - (guy_height / 2)) }, - // .radius = guy_height / 2, - // ); - - // Rng2 test_rect = Zi; - // test_rect.p0 = VEC2(-1, -1); - // test_rect.p1 = VEC2(1, 1); - // result = P_ShapeFromDesc( - // // .radius = 0.5, - // .radius = 0, - // .count = 4, - // .points[0] = VEC2(test_rect.p0.x, test_rect.p0.y), - // .points[1] = VEC2(test_rect.p1.x, test_rect.p0.y), - // .points[2] = VEC2(test_rect.p1.x, test_rect.p1.y), - // .points[3] = VEC2(test_rect.p0.x, test_rect.p1.y), - // ); } else if (ent->is_pickup) { @@ -776,30 +754,6 @@ P_CollisionResult P_CollisionResultFromShapes(P_Shape shape0, P_Shape shape1) // Insert new point into prototype proto[closest_b_index] = m; } - - // Debug draw - // { - // P_DebugDrawPoint(simplex.a.p, VEC4(1, 0, 0, 0.5)); - // P_DebugDrawPoint(simplex.b.p, VEC4(0, 1, 0, 0.5)); - // P_DebugDrawPoint(simplex.c.p, VEC4(0, 0, 1, 0.5)); - // P_DebugDrawLine(simplex.a.p, simplex.b.p, Color_Yellow); - // P_DebugDrawLine(simplex.b.p, simplex.c.p, Color_Yellow); - // P_DebugDrawLine(simplex.c.p, simplex.a.p, Color_Yellow); - // if (proto_count > 0) - // { - // for (i64 i = 0; i < proto_count; ++i) - // { - // i64 p1_idx = i + 1; - // if (p1_idx == proto_count) - // { - // p1_idx = 0; - // } - // Vec2 p0 = proto[i].p; - // Vec2 p1 = proto[p1_idx].p; - // P_DebugDrawLine(p0, p1, VEC4(0, 1, 0, 0.5)); - // } - // } - // } } else { @@ -1627,9 +1581,6 @@ void P_UniqueSpaceEntriesFromRay(Arena *arena, P_SpaceEntryList *result, i32 spa t_max.x += step_dir.x > 0; t_max.y += step_dir.y > 0; - - - t_max = MulVec2Vec2(t_max, inv_delta); if (IsInf(inv_delta.x)) { @@ -1640,9 +1591,6 @@ void P_UniqueSpaceEntriesFromRay(Arena *arena, P_SpaceEntryList *result, i32 spa t_max.y = inv_delta.y; } - - - Vec2I32 dda_pos = dda_start; b32 done = 0; u32 max_iterations = 512; @@ -1802,7 +1750,6 @@ void P_DebugDrawShape(P_Shape shape, Vec4 srgb) } } - void P_DebugDrawFrame(P_Frame *frame) { if (P_tl.debug_draw_enabled) @@ -1854,13 +1801,6 @@ void P_DebugDrawFrame(P_Frame *frame) EndScratch(scratch); } - for (i32 cell_y = 0; cell_y < world->walls_space.dims.y; ++cell_y) - { - for (i32 cell_x = 0; cell_x < world->walls_space.dims.x; ++cell_x) - { - } - } - ////////////////////////////// //- Draw entities @@ -2521,7 +2461,6 @@ void P_StepFrame(P_Frame *frame) if (guy->is_guy) { // Roll - // if (guy->control.roll_presses && !IsVec2Zero(guy->control.move)) if (guy->control.downs[P_Button_Roll]) { // TODO: Not like this @@ -2592,7 +2531,6 @@ void P_StepFrame(P_Frame *frame) b32 is_rolling = P_IsEntRolling(frame, guy); if (is_rolling) { - // Vec2 roll_dir = NormVec2(guy->last_roll_dir); Vec2 roll_dir = NormVec2(guy->xf.r); move = roll_dir; @@ -2602,7 +2540,6 @@ void P_StepFrame(P_Frame *frame) move_force *= roll_factor; max_speed *= roll_factor; - // if ((frame->time_ns - guy->last_roll_ns) > P_RollTurnTimeNs) { turn_rate = 0.1; } @@ -2657,12 +2594,10 @@ void P_StepFrame(P_Frame *frame) f32 solver_dt = sim_dt / solver_steps_count; // Solid params - // SoftSpring solid_spring = MakeSpring(TweakFloat("Contact spring hz", 25, 5, 200), TweakFloat("Contact spring damp", 10, 5, 100), solver_dt); SoftSpring solid_spring = MakeSpring(TweakFloat("Contact spring hz", 100, 5, 200), TweakFloat("Contact spring damp", 10, 5, 100), solver_dt); f32 solid_pushout_velocity = TweakFloat("Contact spring pushout", 3, 0, 50); // Gentle params - // f32 gentle_pushout_factor = TweakFloat("Gentle pushout factor", 10, 0, 50); f32 gentle_pushout_factor = TweakFloat("Gentle pushout factor", 0.5, 0, 50); ////////////////////////////// @@ -3161,23 +3096,6 @@ void P_StepFrame(P_Frame *frame) ////////////////////////////// //- Spawn bullets - - - - - - - - - - - - - - - - // TODO: Remove this - { P_EntList bullets_to_spawn = Zi; for (P_Ent *firer = P_FirstEnt(frame); !P_IsEntNil(firer); firer = P_NextEnt(firer)) @@ -3242,20 +3160,9 @@ void P_StepFrame(P_Frame *frame) P_SpawnEntsFromList(frame, bullets_to_spawn); } - - - - ////////////////////////////// //- Update bullets - - - - - - - { P_EntList ents_to_spawn = Zi; for (P_Ent *bullet = P_FirstEnt(frame); !P_IsEntNil(bullet); bullet = P_NextEnt(bullet)) @@ -3294,18 +3201,7 @@ void P_StepFrame(P_Frame *frame) } ////////////////////////////// - //- Initialize - - // if (bullet->created_at_tick != frame->tick) - // { - // Vec2 start = bullet->bullet_start; - // Vec2 end = bullet->bullet_end; - // Vec2 vel = SubVec2(end, start); - // bullet->bullet_start = end; - // bullet->bullet_end = AddVec2(end, vel); - // bullet->xf.t = bullet->bullet_start; - // bullet->xf.r = NormVec2(vel); - // } + //- Initialize bullet Struct(BulletPath) { @@ -3392,13 +3288,6 @@ void P_StepFrame(P_Frame *frame) // bullet->v = AddVec2(bullet->v, firer->v); } - - - - - - - // On bullet's first tick, we want to ensure that the firer/weapon // wasn't obstructed (e.g. to prevent shooting through walls), so we // insert a path from the bullet's base to its starting position before @@ -3581,185 +3470,6 @@ void P_StepFrame(P_Frame *frame) P_SpawnEntsFromList(frame, ents_to_spawn); } - - - - - - - - - - - - - - - - - // // TODO: Separate 'hits' from bullets, so that bullets can have multiple hits - - // for (P_Ent *bullet = P_FirstEnt(frame); !P_IsEntNil(bullet); bullet = P_NextEnt(bullet)) - // { - // if (bullet->is_bullet) - // { - // P_Ent *weapon = P_EntFromKey(frame, bullet->source); - // P_Ent *firer = P_EntFromKey(frame, weapon->source); - // P_Ent *damager = P_EntFromKey(frame, bullet->damage_attribution_player); - - - - // if (bullet->created_at_tick != frame->tick) - // { - // Vec2 start = bullet->bullet_start; - // Vec2 end = bullet->bullet_end; - // Vec2 vel = SubVec2(end, start); - // bullet->bullet_start = end; - // bullet->bullet_end = AddVec2(end, vel); - // bullet->xf.t = bullet->bullet_start; - // bullet->xf.r = NormVec2(vel); - // } - - - - - - // bullet->has_hit = 0; - - // Struct(BulletPath) - // { - // BulletPath *next; - // Vec2 start; - // Vec2 end; - // }; - // BulletPath *first_bullet_path = 0; - // BulletPath *last_bullet_path = 0; - - // if (bullet->created_at_tick == frame->tick) - // { - // // On bullet's first tick, we want to ensure that the firer/weapon - // // wasn't obstructed (e.g. to prevent shooting through walls), so we - // // insert a path from the bullet's base to its starting position before - // // its actual firing path - // { - // // Firer origin -> weapon chamber path - // BulletPath *path = PushStruct(scratch.arena, BulletPath); - // SllQueuePush(first_bullet_path, last_bullet_path, path); - // path->start = bullet->bullet_base0; - // path->end = bullet->bullet_base1; - // } - // { - // // Weapon chamber -> bullet start path - // BulletPath *path = PushStruct(scratch.arena, BulletPath); - // SllQueuePush(first_bullet_path, last_bullet_path, path); - // path->start = bullet->bullet_base1; - // path->end = bullet->bullet_start; - // } - // } - - // { - // BulletPath *path = PushStruct(scratch.arena, BulletPath); - // SllQueuePush(first_bullet_path, last_bullet_path, path); - // path->start = bullet->bullet_start; - // path->end = bullet->bullet_end; - // } - - // P_EntKey victim_key = Zi; - // P_RaycastResult victim_raycast = Zi; - // b32 hit = 0; - // { - // for (BulletPath *path = first_bullet_path; path && !hit; path = path->next) - // { - // Vec2 path_dir = SubVec2(path->end, path->start); - // P_Space *cast_spaces[] = { - // &world->walls_space, - // &post_solve_ents_space, - // }; - // P_SpaceEntryList cast_entries = Zi; - // P_UniqueSpaceEntriesFromRay( - // scratch.arena, - // &cast_entries, - // countof(cast_spaces), - // cast_spaces, - // path->start, - // path->end - // ); - // f32 closest_len_sq = Inf; - // for (P_SpaceEntryNode *entry_node = cast_entries.first; entry_node; entry_node = entry_node->next) - // { - // P_SpaceEntry *entry = &entry_node->entry; - // P_EntKey potential_victim_key = (P_EntKey) { .v = entry->shape_id }; - // if (!P_MatchEntKey(potential_victim_key, firer->key) || P_IsEntKeyNil(firer->key)) - // { - // P_Shape potential_victim_shape = entry->shape; - // P_RaycastResult entrance_raycast = P_RaycastShape(potential_victim_shape, path->start, path_dir); - // Vec2 entrance = entrance_raycast.p; - // if (entrance_raycast.is_intersecting) - // { - // P_RaycastResult exit_raycast = P_RaycastShape(potential_victim_shape, path->start, NegVec2(path_dir)); - // Vec2 exit = exit_raycast.p; - // f32 da = DotVec2(path_dir, SubVec2(entrance, path->start)); - // f32 db = DotVec2(path_dir, SubVec2(exit, path->start)); - // if (db > 0 && (da <= Vec2LenSq(path_dir) || da <= 0)) - // { - // f32 len_sq = Vec2LenSq(SubVec2(entrance_raycast.p, path->start)); - // if (len_sq < closest_len_sq) - // { - // closest_len_sq = len_sq; - // victim_key = potential_victim_key; - // victim_raycast = entrance_raycast; - // hit = 1; - // } - // } - // } - // } - // } - // } - // } - // P_Ent *victim = P_EntFromKey(frame, victim_key); - - // // TODO: Truncate bullet trail - // if (hit) - // { - // bullet->has_hit = 1; - // bullet->hit_entry = victim_raycast.p; - // bullet->hit_entry_normal = victim_raycast.normal; - // // bullet->bullet_end = bullet->hit_entry; - // bullet->exists = 0; - // if (victim->is_guy) - // { - // bullet->hit_material = P_MaterialKind_Flesh; - // } - // else - // { - // bullet->hit_material = P_MaterialKind_Wall; - // } - // } - - // // TODO: Remove this - // if (!P_IsEntNil(victim)) - // { - // if (damager->is_player) - // { - // victim->damage_attribution_player = damager->key; - // } - // victim->health -= 0.25; - // } - - // // Prune out of bounds bullet - // Rng2 bounds = Zi; - // bounds.p0 = VEC2(-P_WorldPitch / 2, -P_WorldPitch / 2); - // bounds.p1 = VEC2(P_WorldPitch / 2, P_WorldPitch / 2); - // if ( - // bullet->bullet_start.x < bounds.p0.x || bullet->bullet_start.y < bounds.p0.y || - // bullet->bullet_start.x > bounds.p1.x || bullet->bullet_start.y > bounds.p1.y - // ) - // { - // bullet->exists = 0; - // } - // } - // } - ////////////////////////////// //- Kill guys diff --git a/src/pp/pp.h b/src/pp/pp.h index 1a241d3f..bfe494d7 100644 --- a/src/pp/pp.h +++ b/src/pp/pp.h @@ -237,16 +237,11 @@ Struct(P_NetworkedEntState) Struct(P_LocalEntState) { - //- Observation info + //- Observation data i64 initial_observation_time_ns; i64 last_observation_time_ns; b32 is_first_observation; - - // Vec2 smoothed_v; - // Vec2 smoothed_v_dir; - // Vec2 smoothed_move_dir; - // f32 smoothed_w; }; Struct(P_Ent) @@ -401,7 +396,6 @@ Struct(P_Space) Struct(P_Frame) { - ////////////////////////////// //- Internal world state struct P_World *world; @@ -412,14 +406,12 @@ Struct(P_Frame) P_Frame *next_in_bin; P_Frame *prev_in_bin; - ////////////////////////////// //- Frame state i64 src_tick; i64 tick; i64 time_ns; - ////////////////////////////// //- Ents i64 ents_count; @@ -429,7 +421,6 @@ Struct(P_Frame) i64 ent_bins_count; P_EntBin *ent_bins; - ////////////////////////////// //- Constraints i64 constraints_count; @@ -439,7 +430,6 @@ Struct(P_Frame) i64 constraint_bins_count; P_ConstraintBin *constraint_bins; - ////////////////////////////// //- Snapshot-assembly state u64 fragments_count; diff --git a/src/pp/pp_sim/pp_sim_core.c b/src/pp/pp_sim/pp_sim_core.c index 35c27eb2..f63f207d 100644 --- a/src/pp/pp_sim/pp_sim_core.c +++ b/src/pp/pp_sim/pp_sim_core.c @@ -69,17 +69,12 @@ void S_TickForever(WaveLaneCtx *lane) BB_Buff packer_bb = BB_AcquireDynamicBuff(Gibi(64)); BB_Writer packer_bbw = BB_WriterFromBuff(&packer_bb); - // 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; - - - ////////////////////////////// //- Sim loop @@ -196,11 +191,6 @@ void S_TickForever(WaveLaneCtx *lane) } } - - - - - ////////////////////////////// //- Connect clients @@ -277,7 +267,7 @@ void S_TickForever(WaveLaneCtx *lane) } ////////////////////////////// - //- Create player entities (networked version of clients) + //- Create players { P_EntList new_players = Zi; @@ -343,7 +333,6 @@ void S_TickForever(WaveLaneCtx *lane) // // In case previous snapshots weren't received, backfill with newest snapshot // - // TODO: Not like this i64 max_propagate_count = SIM_TICKS_PER_SECOND; { // Propagate backwards @@ -423,13 +412,6 @@ void S_TickForever(WaveLaneCtx *lane) } } - - - - - - - ////////////////////////////// //- Apply bot controls @@ -484,133 +466,10 @@ void S_TickForever(WaveLaneCtx *lane) } } - - - - - - - // ////////////////////////////// - // //- Apply bot controls - - // { - // f32 move_bias = TweakFloat("Bot movement bias", 0, -1, 1); - // f32 move_frequency = TweakFloat("Bot movement frequency", 0, 0, 10); - // f32 turn_frequency = TweakFloat("Bot turn frequency", 0, 0, 10); - // // b32 bot_movement_enabled = TweakBool("Bot movement enabled", 1); - // for (P_Ent *bot = P_FirstEnt(world_frame); !P_IsEntNil(bot); bot = P_NextEnt(bot)) - // { - // if (bot->is_bot) - // { - // i64 alive_time_ns = world_frame->time_ns - bot->created_at_ns; - // f64 alive_time = SecondsFromNs(alive_time_ns); - // // i64 frequency_ns = NsFromSeconds(0.1); - // // bot->control.move.y = SinF32((f64)alive_time_ns / (f64)frequency_ns); - - // f32 move_t = alive_time * move_frequency * Tau; - // f32 look_t = alive_time * turn_frequency * Tau; - - // bot->control.move.y = SinF32(move_t); - // bot->control.move.y += move_bias; - // bot->control.look = MulVec2(VEC2(CosF32(look_t), SinF32(look_t)), 3); - // } - // } - // } - - - - - - - ////////////////////////////// - //- Process connection messages - - // { - // for (P_MsgNode *msg_node = in_msgs.first; msg_node; msg_node = msg_node->next) - // { - // P_Msg *msg = &msg_node->msg; - - // //- Register player - // if (msg->kind == P_MsgKind_RegisterUser) - // { - // P_Key user_key = msg->src_user; - // P_Ent *player = P_EntFromKey(world_frame, user_key); - // if (P_EntIsNil(player)) - // { - // P_EntList tmp_list = Zi; - // player = P_PushTempEnt(frame_arena, &tmp_list); - // player->key = user_key; - // player->is_user = 1; - // player->exists = 1; - - // // FIXME: Set net key here - - // i32 min_name_len = P_MinPlayerNameLen; - // i32 max_name_len = P_MaxPlayerNameLen; - - // // De-duplicate player name - // String user_name = msg->data; - // user_name = TrimWhitespace(user_name); - // user_name.len = MinI64(user_name.len, max_name_len); - // user_name = TrimWhitespace(user_name); - // if (user_name.len < min_name_len) - // { - // user_name = Lit("Player"); - // } - // { - // String orig_user_name = user_name; - // i64 duplicate_id = 0; - // while (duplicate_id < 1000) - // { - // b32 is_duplicate = 0; - // for (P_Ent *ent = P_FirstEnt(world_frame); !P_IsEntNil(ent); ent = P_NextEnt(ent)) - // { - // if (ent->is_user && MatchString(P_StringFromEnt(ent), user_name)) - // { - // is_duplicate = 1; - // break; - // } - // } - // if (is_duplicate) - // { - // duplicate_id += 1; - // user_name = StringF(frame_arena, "%F (%F)", FmtString(orig_user_name), FmtSint(duplicate_id)); - // } - // else - // { - // break; - // } - // } - // } - // P_SetEntString(player, user_name); - // P_Msg *msg = P_PushMsg( - // P_MsgKind_Chat, - // StringF( - // frame_arena, - // "Player %F connected", - // FmtString(user_name) - // )); - // ) - - // P_SpawnEntsFromList(world_frame, tmp_list); - // } - // { - // P_Msg *msg = P_PushMsg(P_MsgKind_RegisterSuccess, Zstr); - // msg->dst_user = player->key; - // } - // } - // } - // } - - - - - - ////////////////////////////// //- Process player edit messages - // FIXME: Only accept edits from privileged users + // TODO: Only accept edits from privileged users { u64 bots_count = 0; @@ -624,7 +483,7 @@ void S_TickForever(WaveLaneCtx *lane) //- Save world case P_MsgKind_SaveWorld: { - // FIXME: Only accept save from local player + // TODO: Only accept save from local player should_save = 1; } break; //- Reset world @@ -1087,14 +946,6 @@ void S_TickForever(WaveLaneCtx *lane) ////////////////////////////// //- End sim frame - // // Reset front input state - // { - // Arena *arena = input->arena; - // ResetArena(arena); - // ZeroStruct(input); - // input->arena = arena; - // } - i64 frame_end_ns = TimeNs(); ////////////////////////////// diff --git a/src/pp/pp_vis/pp_vis.lay b/src/pp/pp_vis/pp_vis.lay index c504116a..9b22ef3e 100644 --- a/src/pp/pp_vis/pp_vis.lay +++ b/src/pp/pp_vis/pp_vis.lay @@ -15,8 +15,6 @@ ////////////////////////////// //- Resources -@Shader V_BuildProfilerGraphCS (1, 128) // Vertical group dims so that profiler-sample access is uniform -@Shader V_PrepareShadeCS (16, 16) @Shader V_PrepareCellsCS (16, 16) @Shader V_BackdropDownCS (16, 16) @Shader V_BackdropUpCS (16, 16) @@ -25,7 +23,6 @@ @Shader V_QuadPS Pixel @Shader V_EmitParticlesCS (256) @Shader V_SimParticlesCS (256) -@Shader V_ShadeCS (16, 16) @Shader V_CompositeCS (16, 16) @Shader V_BloomDownCS (16, 16) @Shader V_BloomUpCS (16, 16) diff --git a/src/pp/pp_vis/pp_vis_core.c b/src/pp/pp_vis/pp_vis_core.c index 37929226..090a30f9 100644 --- a/src/pp/pp_vis/pp_vis_core.c +++ b/src/pp/pp_vis/pp_vis_core.c @@ -442,130 +442,6 @@ V_TextboxDeltaFlag V_ApplyTextboxDeltas(V_TextboxState *tb, V_TextboxDeltaList d PLT_SetClipboardText(selection); } } - - - - - - - - - - - - - - - - - // // Update text - // if (delta.flags & V_TextboxDeltaFlag_UpdateText) - // { - // RngI64 replace = Zi; - - // // Remove selected text - // { - // replace = RNGI64(MinI64(tb->start, tb->end), MaxI64(tb->start, tb->end)); - // if (replace.max > replace.min) - // { - // // FIXME: Truncate - // i64 move_len = ClampI64(tb->len - replace.max, 0, countof(tb->text) - replace.max); - // for (i64 src_pos = replace.max; src_pos < (replace.max + move_len); ++src_pos) - // { - // i64 dst_pos = src_pos + move_len; - // tb->text[dst_pos] = tb->text[src_pos]; - // } - // } - // tb->len -= replace.max - replace.min; - // } - - // // Insert new text - // if (delta_text32.len > 0) - // { - // i64 insert_len = ClampI64(delta_text32.len, 0, countof(tb->text) - replace.min); - - // // Make room - // // FIXME: Truncate - // i64 move_len = ClampI64(tb->len - replace.min, 0, countof(tb->text) - replace.min); - // for (i64 src_pos = replace.min; src_pos < (replace.min + move_len); ++src_pos) - // { - // i64 dst_pos = src_pos + move_len; - // tb->text[dst_pos] = tb->text[src_pos]; - // } - - // // Copy from delta - // for (i64 src_pos = 0; src_pos < insert_len; ++src_pos) - // { - // i64 dst_pos = replace.min + src_pos; - // tb->text[dst_pos] = delta_text32.text[src_pos]; - // } - // tb->len += insert_len; - // } - - // // FIXME: Expand selection on insert - // // tb->start = ClampI64(tb->start, 0, tb->len); - // // tb->end = ClampI64(tb->end, 0, tb->len); - - // tb->end = ClampI64(tb->end, 0, tb->len); - // tb->start = tb->end; - // } - - - - - - - - - - - - - // if (!(delta.flags & V_TextboxDeltaFlag_DontUpdateText)) - // { - // RngI64 replace = Zi; - - // // Remove selected text - // { - // replace = RNGI64(MinI64(delta.start, delta.end), MaxI64(delta.start, delta.end)); - // replace.min = MaxI64(replace.min, 0); - // replace.max = MinI64(replace.max, tb->len); - // if (replace.max > replace.min) - // { - // // FIXME: Truncate - // i64 move_len = ClampI64(tb->len - replace.max, 0, countof(tb->text) - replace.max); - // for (i64 src_pos = replace.max; src_pos < (replace.max + move_len); ++src_pos) - // { - // i64 dst_pos = src_pos + move_len; - // tb->text[dst_pos] = tb->text[src_pos]; - // } - // } - // tb->len -= replace.max - replace.min; - // } - - // // Insert new text - // if (delta.text.len > 0) - // { - // i64 insert_len = ClampI64(delta.text.len, 0, countof(tb->text) - replace.min); - - // // Make room - // // FIXME: Truncate - // i64 move_len = ClampI64(tb->len - replace.min, 0, countof(tb->text) - replace.min); - // for (i64 src_pos = replace.min; src_pos < (replace.min + move_len); ++src_pos) - // { - // i64 dst_pos = src_pos + move_len; - // tb->text[dst_pos] = tb->text[src_pos]; - // } - - // // Copy from delta - // for (i64 src_pos = 0; src_pos < insert_len; ++src_pos) - // { - // i64 dst_pos = replace.min + src_pos; - // tb->text[dst_pos] = delta.text.text[src_pos]; - // } - // tb->len += insert_len; - // } - // } } EndScratch(scratch); return applied_flags; @@ -617,7 +493,6 @@ V_WidgetTheme V_GetWidgetTheme(void) theme.chat_font = GC_FontKeyFromResource(ResourceKeyFromStore(&P_Resources, Lit("font/seguisb.ttf"))); theme.icon_font = UI_BuiltinIconFont(); - // theme.font_size = 14; theme.ui_font_size = TweakFloat("UI font size", 14, 8, 24, .precision = 1); theme.chat_font_size = TweakFloat("Chat font size", 16, 8, 24, .precision = 0); theme.tooltip_offset_px = VEC2(12, 0); @@ -640,12 +515,6 @@ V_WidgetTheme V_GetWidgetTheme(void) theme.col.window_bd = Rgb32(0xff343a3b); theme.col.window_fg = Rgb32(0xff1a1d1e); theme.col.window_bg = theme.col.window_fg; - - // theme.col.window_bg.r = theme.col.window_fg.r * 0.6375; - // theme.col.window_bg.g = theme.col.window_fg.g * 0.6375; - // theme.col.window_bg.b = theme.col.window_fg.b * 0.6375; - // theme.col.window_bg.a = 1; - theme.col.panel_bg = theme.col.window_bg; theme.col.panel_bd = theme.col.window_bd; theme.col.panel_opacity = TweakFloat("Panel opacity", 0.75, 0, 1); @@ -664,7 +533,6 @@ V_WidgetTheme V_GetWidgetTheme(void) theme.col.warn = VEC4(0.60, 0.60, 0.25, 1); theme.col.text = Rgb32(0xffdddee0); - // theme.col.hint = Rgb32(0xff71767f); theme.col.hint = Rgb32(0xff6b7078); return theme; @@ -754,11 +622,7 @@ void V_TickForever(WaveLaneCtx *lane) f64 rtt = 0; f64 prev_rtt = 0; - // i64 smoothed_rtt_ns = 0; f64 smoothed_rtt = 0.0; - // f64 smoothed_rtt = 0.300; - // f64 smoothed_rtt = 1.00; - // f64 smoothed_rtt = 2; f32 smooth_remote_buffered_ticks = 0; f32 smooth_remote_buffered_ticks_target = 2; @@ -767,7 +631,6 @@ void V_TickForever(WaveLaneCtx *lane) Vec2I32 cells_dims = VEC2I32(P_CellsPitch, P_CellsPitch); //- Init gpu state - G_BufferRef gpu_profiler_frames = Zi; G_TextureRef gpu_tiles = Zi; G_BufferRef gpu_particles = Zi; G_TextureRef gpu_particle_cells[V_ParticleLayer_COUNT]; @@ -779,14 +642,6 @@ void V_TickForever(WaveLaneCtx *lane) { G_CommandListHandle cl = G_PrepareCommandList(G_QueueKind_Direct); { - //- Init profiler frames buffer - gpu_profiler_frames = G_PushStructs( - cl, gpu_perm, - V_ProfilerFrame, V_ProfilerFramesCap, - .flags = G_MemoryFlag_HostRead | G_MemoryFlag_HostWrite, - .name = Lit("Profiler frames"), - ); - V.profiler_frames = G_Deref(gpu_profiler_frames, V_ProfilerFrame); //- Init tile map texture gpu_tiles = G_PushTexture2D( cl, gpu_perm, @@ -985,7 +840,6 @@ void V_TickForever(WaveLaneCtx *lane) if (frame->tick == 1) { - // frame->timeline.show = 1; frame->timeline.locked = 1; } @@ -1660,7 +1514,6 @@ void V_TickForever(WaveLaneCtx *lane) if (!NET_MatchKey(frame->sim_key, frame->desired_sim_key)) { i64 retry_rate_ns = NsFromSeconds(0.100); - // i64 retry_rate_ns = NsFromSeconds(0); b32 should_try = 0; if (!NET_MatchKey(prev_frame->desired_sim_key, frame->desired_sim_key)) @@ -1701,19 +1554,10 @@ void V_TickForever(WaveLaneCtx *lane) for (NET_Msg *net_msg = net_msgs.first; net_msg; net_msg = net_msg->next) { NET_Key net_key = net_msg->sender; - - // String address_str = NET_StringFromKey(frame->arena, net_key); - // LogDebugF("Received message from server \"%F\"", FmtString(address_str)); - if (NET_MatchKey(net_key, frame->desired_sim_key)) { frame->sim_key = net_key; - - // String address_str = NET_StringFromKey(frame->arena, net_key); - // LogDebugF("Received message from server \"%F\"", FmtString(address_str)); - String packed = net_msg->data; - P_MsgList server_msgs = P_UnpackMessages(frame->arena, packed, net_key); if (server_msgs.first) { @@ -1730,7 +1574,6 @@ void V_TickForever(WaveLaneCtx *lane) in_msgs.count += server_msgs.count; } } - } } @@ -1846,7 +1689,6 @@ void V_TickForever(WaveLaneCtx *lane) // Rtt time { - // f64 lerp_rate = 1.0 * frame->dt; f64 lerp_rate = (1000.0 / 150.0) * frame->dt; smoothed_rtt = LerpF64(smoothed_rtt, rtt, SaturateF64(lerp_rate)); if (rtt != 0 && prev_rtt == 0) @@ -1967,10 +1809,6 @@ void V_TickForever(WaveLaneCtx *lane) frame->predict_tick_accum = frame->target_predict_tick_accum; LogDebugF("Prediction reset"); } - - // We cannot simulate backwards - // frame->predict_tick_accum = MaxF64(prev_frame->predict_tick_accum, frame->predict_tick_accum); - // V_PushTimelineMarker(frame->predict_tick_accum, Color_Red, 1); // V_PushTimelineMarker(frame->target_predict_tick_accum, Color_Yellow, 1); } @@ -2142,16 +1980,12 @@ void V_TickForever(WaveLaneCtx *lane) i64 first_predict_tick = 0; i64 last_predict_tick = 0; { - // FIXME: Not like this i64 max_predict_ticks = SIM_TICKS_PER_SECOND; last_predict_tick = predict_to; first_predict_tick = ack; - // first_predict_tick = MaxI64(first_predict_tick, last_predict_tick - max_predict_ticks); } - // TODO: Remove this // TODO: Delete all frames except for prediction base & remote ack - // TODO: Limit max sim frames stored // Clear received sim frames { i64 bottom_tick = I64Max; @@ -2163,8 +1997,6 @@ void V_TickForever(WaveLaneCtx *lane) } P_ClearFrames(sim_world, I64Min, bottom_tick - 1); } - // P_ClearFrames(sim_world, I64Min, ack - SIM_TICKS_PER_SECOND); - // P_ClearFrames(sim_world, I64Min, sim_world->last_frame->tick - 1); // Clear predicted frames { @@ -2176,18 +2008,12 @@ void V_TickForever(WaveLaneCtx *lane) P_ClearFrames(predict_world, I64Min, bottom_tick - 1); } - - // Push prediction if new frame received from server if (ack != prev_frame_ack) { V_PushTimelineMarker(ack, Color_Green, 0); } - - - - // Predict P_Frame *predict_frame = predict_world->last_frame; ProfZoneDF("Predict simulation") @@ -2214,14 +2040,6 @@ void V_TickForever(WaveLaneCtx *lane) predict_player->control = *predict_control; } } - // for (P_Ent *ent = P_FirstEnt(predict_frame); !P_IsEntNil(ent); ent = P_NextEnt(ent)) - // { - // if (ent != predict_player) - // { - // ZeroStruct(&ent->control); - // } - // } - b32 old_debug_draw = P_tl.debug_draw_enabled; Vec4 old_debug_tint = P_tl.debug_tint; { @@ -2236,9 +2054,6 @@ void V_TickForever(WaveLaneCtx *lane) } predict_frame = predict_world->last_frame; - // P_DebugDrawFrame(predict_frame); - - // TODO: Extract information that occurred between first & last prediction, like bullet hits etc? // V_PushTimelineMarker(predict_frame->tick, Color_Purple, 1); @@ -2246,15 +2061,6 @@ void V_TickForever(WaveLaneCtx *lane) V_PushTimelineMarker(frame->predict_tick_accum, Color_Purple, 1); } - - - - - - - - - ////////////////////////////// //- Compute blend ticks @@ -2284,7 +2090,6 @@ void V_TickForever(WaveLaneCtx *lane) f64 target_blend_predict_tick = frame->predict_tick_accum - interp_ratio; { f64 lerp_rate = SaturateF64(2.0 * frame->dt); - // frame->blend_predict_tick += frame->dt * SIM_TICKS_PER_SECOND; frame->blend_predict_tick += (frame->dt + frame->dt * dilation_factor) * SIM_TICKS_PER_SECOND; frame->blend_predict_tick = LerpF64(frame->blend_predict_tick, target_blend_predict_tick, lerp_rate); frame->blend_predict_tick = MaxF64(frame->blend_predict_tick, prev_frame->blend_predict_tick); @@ -2299,23 +2104,9 @@ void V_TickForever(WaveLaneCtx *lane) V_PushTimelineMarker(frame->blend_predict_tick, Color_Red, 1); } - - - - - ////////////////////////////// //- Generate locally blended world - - - - - - - - - P_Frame *prev_local_frame = prev_frame->local_world->last_frame; P_Frame *local_frame = &P_NilFrame; ProfZoneDF("Blend worlds") @@ -2426,17 +2217,12 @@ void V_TickForever(WaveLaneCtx *lane) local_frame = P_PushFrame(frame->local_world, predict_world->last_frame, predict_world->last_frame->tick); } - P_DebugDrawFrame(local_frame); } - - ////////////////////////////// //- Observe entities - - ProfZoneDF("Observe Entities") for (P_Ent *ent = P_FirstEnt(local_frame); !P_IsEntNil(ent); ent = P_NextEnt(ent)) { @@ -2494,77 +2280,8 @@ void V_TickForever(WaveLaneCtx *lane) ent->is_first_observation = obs->initial_observation_time_ns == frame->time_ns; } - - - - - - // for (P_Ent *ent = P_FirstEnt(local_frame); !P_IsEntNil(ent); ent = P_NextEnt(ent)) - // { - // P_EntKey key = ent->key; - // i64 expiration_ns = P_ObservationLifetimeNs; - // i64 observation_time_ns = 0; - // { - // V_ObservationBin *bin = &V.observation_bins[key.v % countof(V.observation_bins)]; - // V_Observation *obs = bin->first; - // for (; obs; obs = obs->next) - // { - // if (obs->key == key.v) - // { - // break; - // } - // } - // if (obs) - // { - // if (obs->time_ns + expiration_ns > frame->time_ns) - // { - // // Re-observe matching expired observation - // DllQueueRemove(V.first_observation, V.last_observation, obs); - // DllQueuePush(V.first_observation, V.last_observation, obs); - // obs->time_ns = frame->time_ns; - // } - // } - // else - // { - // if (V.first_observation && V.first_observation->time_ns + expiration_ns <= frame->time_ns) - // { - // // Remove expired observation for reuse - // obs = V.first_observation; - // V_ObservationBin *old_bin = &V.observation_bins[obs->key % countof(V.observation_bins)]; - // DllQueueRemove(V.first_observation, V.last_observation, obs); - // DllQueueRemoveNP(old_bin->first, old_bin->last, obs, next_in_bin, prev_in_bin); - // } - // else - // { - // obs = PushStruct(perm, V_Observation); - // } - // obs->key = key.v; - // obs->time_ns = frame->time_ns; - // DllQueuePush(V.first_observation, V.last_observation, obs); - // DllQueuePushNP(bin->first, bin->last, obs, next_in_bin, prev_in_bin); - // } - // observation_time_ns = obs->time_ns; - // } - // ent->observation_time_ns = observation_time_ns; - // ent->has_observed = observation_time_ns < frame->time_ns; - // } - - - - - - - - - - - - - - - ////////////////////////////// - //- Query local player + //- Query local entities P_Ent *local_player = P_EntFromKey(frame->local_world->last_frame, V.player_key); P_Ent *local_guy = P_EntFromKey(frame->local_world->last_frame, local_player->guy); @@ -2578,8 +2295,6 @@ void V_TickForever(WaveLaneCtx *lane) ////////////////////////////// //- Compute crosshair position - // TODO: Alive / weapon check - if (!P_IsEntNil(local_guy)) { // P_Ent *ent = local_guy; @@ -3019,15 +2734,6 @@ void V_TickForever(WaveLaneCtx *lane) } } - - - - - - - - - ////////////////////////////// //- Process world events @@ -3064,97 +2770,17 @@ void V_TickForever(WaveLaneCtx *lane) { emitter.kind = V_ParticleKind_BulletSmoke; emitter.count = particles_count; - f32 angle_spread = Tau / 4.0; - emitter.angle.min = angle - angle_spread / 2; emitter.angle.max = angle + angle_spread / 2; - emitter.pos.p0 = p0; emitter.pos.p1 = p1; - - // emitter.color_lin = LinearFromSrgb(VEC4(0, 1, 0, 1)); - - // emitter.color_lin = LinearFromSrgb(VEC4(0.8, 0.6, 0.2, 1)); - emitter.speed.min = -1; emitter.speed.max = 1; } V_PushParticles(emitter); } - - //- Bullet trail - // { - // V_Emitter emitter = Zi; - // emitter.kind = V_ParticleKind_BulletTrail; - // f32 particles_count = trail_len * P_CellsPerMeter; - // emitter.count = particles_count; - - // f32 angle = AngleFromVec2(SubVec2(p1, p0)); - - // // f32 angle_spread = Tau / 4.0; - - // // emitter.angle.min = angle - angle_spread / 2; - // // emitter.angle.max = angle + angle_spread / 2; - - // emitter.angle.min = - // emitter.angle.max = angle; - - // emitter.pos.p0 = p0; - // emitter.pos.p1 = p1; - - // // emitter.speed.min = - // // emitter.speed.max = - - // // emitter.color_lin = LinearFromSrgb(VEC4(0, 1, 0, 1)); - - // // emitter.color_lin = LinearFromSrgb(VEC4(0.8, 0.6, 0.2, 1)); - // // emitter.speed.min = - // // emitter.speed.max = Vec2Len(SubVec2(p1, p0)) / frame->dt; - - // V_PushParticles(emitter); - // } - - - - - - - - // //- Bullet particle - // { - // V_Emitter emitter = Zi; - // emitter.kind = V_ParticleKind_Bullet; - // // emitter.count = MaxF32(1000 * frame->dt, 1); - // emitter.count = 1; - - // f32 angle = AngleFromVec2(SubVec2(p1, p0)); - - // // f32 angle_spread = Tau / 4.0; - - // // emitter.angle.min = angle - angle_spread / 2; - // // emitter.angle.max = angle + angle_spread / 2; - - // emitter.angle.min = - // emitter.angle.max = angle; - - // emitter.pos.p0 = - // emitter.pos.p1 = p1; - - // // emitter.speed.min = - // // emitter.speed.max = - - // // emitter.color_lin = LinearFromSrgb(VEC4(0, 1, 0, 1)); - - // // emitter.color_lin = LinearFromSrgb(VEC4(0.8, 0.6, 0.2, 1)); - // emitter.speed.min = - // emitter.speed.max = Vec2Len(SubVec2(p1, p0)) / frame->dt; - - // V_PushParticles(emitter); - // } - - // Bullet fired if (event->is_first_trail) { @@ -3162,30 +2788,17 @@ void V_TickForever(WaveLaneCtx *lane) //- Bullet particle { + // TODO: Don't use particle system for this, just draw a quad along the bullet's path V_Emitter emitter = Zi; emitter.kind = V_ParticleKind_Bullet; - // emitter.count = MaxF32(1000 * frame->dt, 1); emitter.count = 1; f32 angle = AngleFromVec2(SubVec2(p1, p0)); - - // f32 angle_spread = Tau / 4.0; - - // emitter.angle.min = angle - angle_spread / 2; - // emitter.angle.max = angle + angle_spread / 2; - emitter.angle.min = emitter.angle.max = angle; emitter.pos.p0 = emitter.pos.p1 = p0; - - // emitter.speed.min = - // emitter.speed.max = - - // emitter.color_lin = LinearFromSrgb(VEC4(0, 1, 0, 1)); - - // emitter.color_lin = LinearFromSrgb(VEC4(0.8, 0.6, 0.2, 1)); emitter.speed.min = emitter.speed.max = trail_speed; @@ -3196,8 +2809,6 @@ void V_TickForever(WaveLaneCtx *lane) { V_Emitter emitter = Zi; emitter.kind = V_ParticleKind_MuzzleWide; - // emitter.count = MaxF32(1000 * frame->dt, 1); - // emitter.count = 128; emitter.count = 2; f32 angle = AngleFromVec2(SubVec2(p1, p0)); @@ -3208,198 +2819,30 @@ void V_TickForever(WaveLaneCtx *lane) emitter.pos.p0 = emitter.pos.p1 = p0; - - // emitter.lifetime.min = 0.1 - // emitter.lifetime.max = 0.5; - - // emitter.color_lin = LinearFromSrgb(VEC4(0, 1, 0, 1)); - - // emitter.color_lin = LinearFromSrgb(VEC4(0.8, 0.6, 0.2, 1)); - emitter.speed.min = 10; emitter.speed.max = 20; - - // emitter.angle.min = angle - angle_spread / 2; - // emitter.angle.max = angle + angle_spread / 2; - - // emitter.angle.min = - // emitter.angle.max = angle; - emitter.pos.p0 = emitter.pos.p1 = p0; - - // emitter.speed.min = - // emitter.speed.max = - - // emitter.color_lin = LinearFromSrgb(VEC4(0, 1, 0, 1)); - - // emitter.color_lin = LinearFromSrgb(VEC4(0.8, 0.6, 0.2, 1)); - // emitter.speed.min = - // emitter.speed.max = Vec2Len(SubVec2(p1, p0)) / frame->dt; - V_PushParticles(emitter); } - - //- Spark particles - // { - // V_Emitter emitter = Zi; - // emitter.kind = V_ParticleKind_Spark; - // // emitter.count = MaxF32(1000 * frame->dt, 1); - // // emitter.count = 128; - // emitter.count = 1; - - // f32 angle = AngleFromVec2(SubVec2(p1, p0)); - - // f32 angle_spread = Tau / 2; - // emitter.angle.min = angle - angle_spread / 2; - // emitter.angle.max = angle + angle_spread / 2; - - // emitter.pos.p0 = - // emitter.pos.p1 = p0; - - // // emitter.lifetime.min = 0.1 - // // emitter.lifetime.max = 0.5; - - // // emitter.color_lin = LinearFromSrgb(VEC4(0, 1, 0, 1)); - - // // emitter.color_lin = LinearFromSrgb(VEC4(0.8, 0.6, 0.2, 1)); - - // emitter.speed.min = 20; - // emitter.speed.max = 100; - - // // emitter.angle.min = angle - angle_spread / 2; - // // emitter.angle.max = angle + angle_spread / 2; - - // // emitter.angle.min = - // // emitter.angle.max = angle; - - // emitter.pos.p0 = - // emitter.pos.p1 = p0; - - // // emitter.speed.min = - // // emitter.speed.max = - - // // emitter.color_lin = LinearFromSrgb(VEC4(0, 1, 0, 1)); - - // // emitter.color_lin = LinearFromSrgb(VEC4(0.8, 0.6, 0.2, 1)); - // // emitter.speed.min = - // // emitter.speed.max = Vec2Len(SubVec2(p1, p0)) / frame->dt; - - // V_PushParticles(emitter); - // } - - - - - - - //- Narrow muzzle flash particles { V_Emitter emitter = Zi; emitter.kind = V_ParticleKind_MuzzleNarrow; - // emitter.count = MaxF32(1000 * frame->dt, 1); - // emitter.count = 128; emitter.count = 1; - f32 angle = AngleFromVec2(SubVec2(p1, p0)); - - // f32 angle_spread = Tau / 64; f32 angle_spread = Tau / 64; emitter.angle.min = angle - angle_spread / 2; emitter.angle.max = angle + angle_spread / 2; - emitter.pos.p0 = emitter.pos.p1 = p0; - - // emitter.lifetime.min = 0.1 - // emitter.lifetime.max = 0.5; - - // emitter.color_lin = LinearFromSrgb(VEC4(0, 1, 0, 1)); - - // emitter.color_lin = LinearFromSrgb(VEC4(0.8, 0.6, 0.2, 1)); - emitter.speed.min = 45; emitter.speed.max = 45; - - // emitter.angle.min = angle - angle_spread / 2; - // emitter.angle.max = angle + angle_spread / 2; - - // emitter.angle.min = - // emitter.angle.max = angle; - emitter.pos.p0 = emitter.pos.p1 = p0; - - // emitter.speed.min = - // emitter.speed.max = - - // emitter.color_lin = LinearFromSrgb(VEC4(0, 1, 0, 1)); - - // emitter.color_lin = LinearFromSrgb(VEC4(0.8, 0.6, 0.2, 1)); - // emitter.speed.min = - // emitter.speed.max = Vec2Len(SubVec2(p1, p0)) / frame->dt; - V_PushParticles(emitter); } - - - - - - - - - - - - - - //- Test bullet casing - // { - // V_Emitter emitter = Zi; - // emitter.kind = V_ParticleKind_Fire; - // // emitter.count = MaxF32(1000 * frame->dt, 1); - // emitter.count = 8; - - // f32 angle = AngleFromVec2(SubVec2(p1, p0)); - - // f32 angle_spread = Tau / 4; - // emitter.angle.min = angle - angle_spread / 2; - // emitter.angle.max = angle + angle_spread / 2; - - // emitter.pos.p0 = - // emitter.pos.p1 = p0; - - // // emitter.color_lin = LinearFromSrgb(VEC4(0, 1, 0, 1)); - - // // emitter.color_lin = LinearFromSrgb(VEC4(0.8, 0.6, 0.2, 1)); - - // emitter.speed.min = 0; - // emitter.speed.max = 25; - - // // emitter.angle.min = angle - angle_spread / 2; - // // emitter.angle.max = angle + angle_spread / 2; - - // // emitter.angle.min = - // // emitter.angle.max = angle; - - // emitter.pos.p0 = - // emitter.pos.p1 = p0; - - // // emitter.speed.min = - // // emitter.speed.max = - - // // emitter.color_lin = LinearFromSrgb(VEC4(0, 1, 0, 1)); - - // // emitter.color_lin = LinearFromSrgb(VEC4(0.8, 0.6, 0.2, 1)); - // // emitter.speed.min = - // // emitter.speed.max = Vec2Len(SubVec2(p1, p0)) / frame->dt; - - // V_PushParticles(emitter); - // } - } } } @@ -3446,10 +2889,6 @@ void V_TickForever(WaveLaneCtx *lane) V_PushParticles(emitter); } - - - - //- Hot debris { V_Emitter emitter = Zi; @@ -3474,13 +2913,6 @@ void V_TickForever(WaveLaneCtx *lane) V_PushParticles(emitter); } - - - - - - - // Wall dust { V_Emitter emitter = Zi; @@ -3510,25 +2942,12 @@ void V_TickForever(WaveLaneCtx *lane) if (material == P_MaterialKind_Flesh) { V_Emitter emitter = Zi; - emitter.kind = V_ParticleKind_BloodTrail; - // emitter.kind = V_ParticleKind_BloodDebris; - Vec2 dir = NormVec2(NegVec2(impact_velocity)); - f32 angle = AngleFromVec2(dir); - // f32 angle = 0; - // f32 angle_spread = Tau * 0.25; - f32 angle_spread = TweakFloat("Emitter angle spread", 0.1, 0, 1) * Tau; - // f32 angle_spread = Tau; - // f32 angle_spread = 0; - - // f32 speed = 5; - // f32 speed = 25; + f32 angle_spread = TweakFloat("Blood angle spread", 0.1, 0, 1) * Tau; f32 speed = 50; - // f32 speed = 100; f32 speed_spread = speed * 2; - emitter.pos.p0 = emitter.pos.p1 = impact_pos; emitter.speed.min = speed - speed_spread * 0.5; emitter.speed.max = speed + speed_spread * 0.5; @@ -3537,9 +2956,6 @@ void V_TickForever(WaveLaneCtx *lane) emitter.count = TweakFloat("Emitter count", 32, 0, Kibi(64)); V_PushParticles(emitter); } - - // V_DrawPoint(victim_raycast.p, Color_Green); - // V_DrawLine(victim_raycast.p, AddVec2(victim_raycast.p, MulVec2(victim_raycast.normal, 0.5)), Color_White); } } @@ -3565,32 +2981,12 @@ void V_TickForever(WaveLaneCtx *lane) notif->victim = event->death_victim; } - - - //- Narrow blood particles { V_Emitter emitter = Zi; - emitter.kind = V_ParticleKind_BloodTrail; - // emitter.kind = V_ParticleKind_BloodDebris; - - // f32 angle = AngleFromVec2(frame->look); f32 angle = AngleFromVec2(death_dir); - // f32 angle_spread = Tau * 0.25; f32 angle_spread = Tau * 0.25; - // f32 angle_spread = Tau; - // f32 angle_spread = 0; - - // f32 speed = 5; - // f32 speed = 25; - - // f32 speed_spread_min = 25; - // f32 speed_spread_max = 50; - - // f32 speed = 100; - // f32 speed_spread = speed * 2; - emitter.pos.p0 = emitter.pos.p1 = death_pos; emitter.speed.min = -25; @@ -3598,30 +2994,17 @@ void V_TickForever(WaveLaneCtx *lane) emitter.angle.min = angle - angle_spread * 0.5; emitter.angle.max = angle + angle_spread * 0.5; - - // emitter.count = Kibi(32) * frame->dt; - // emitter.count = Kibi(1); - // emitter.count = Kibi(1); emitter.count = Kibi(1); V_PushParticles(emitter); } - - - - //- Wide blood particles { V_Emitter emitter = Zi; emitter.kind = V_ParticleKind_BloodTrail; - // emitter.kind = V_ParticleKind_BloodDebris; - - // f32 angle = AngleFromVec2(frame->look); f32 angle = AngleFromVec2(death_dir); - // f32 angle_spread = Tau * 0.25; - // f32 angle_spread = Tau * 0.5; f32 angle_spread = Tau; f32 speed = 50; @@ -3632,22 +3015,12 @@ void V_TickForever(WaveLaneCtx *lane) emitter.speed.max = speed + speed_spread * 0.5; emitter.angle.min = angle - angle_spread * 0.5; emitter.angle.max = angle + angle_spread * 0.5; - - // emitter.count = Kibi(32) * frame->dt; - // emitter.count = Kibi(1); - // emitter.count = Kibi(1); emitter.count = Kibi(4); 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); @@ -3692,45 +3065,18 @@ void V_TickForever(WaveLaneCtx *lane) } } - - - - - - - - - - - - - - - - ////////////////////////////// //- Push test emitter if (frame->held_buttons[Button_F]) - // if (frame->held_buttons[Button_F] && !prev_frame->held_buttons[Button_F]) - // if (0) { { V_Emitter emitter = Zi; emitter.kind = V_ParticleKind_BloodTrail; - // emitter.kind = V_ParticleKind_BloodDebris; - f32 angle = AngleFromVec2(frame->look); - // f32 angle = 0; - // f32 angle_spread = Tau * 0.25; f32 angle_spread = Tau; - // f32 angle_spread = 0; - - // f32 speed = 5; - // f32 speed = 25; f32 speed = 50; - // f32 speed = 100; f32 speed_spread = speed * 2; emitter.pos.p0 = prev_frame->world_cursor; @@ -3745,30 +3091,15 @@ void V_TickForever(WaveLaneCtx *lane) } } - - - - if (frame->held_buttons[Button_B]) - // if (frame->held_buttons[Button_F] && !prev_frame->held_buttons[Button_F]) - // if (0) { { V_Emitter emitter = Zi; emitter.kind = V_ParticleKind_BloodTrail; - // emitter.kind = V_ParticleKind_BloodDebris; - f32 angle = AngleFromVec2(frame->look); - // f32 angle = 0; - // f32 angle_spread = Tau * 0.25; f32 angle_spread = Tau; - // f32 angle_spread = 0; - - // f32 speed = 5; - // f32 speed = 25; f32 speed = 500; - // f32 speed = 100; f32 speed_spread = speed * 2; emitter.pos.p0 = prev_frame->world_cursor; @@ -3783,21 +3114,10 @@ void V_TickForever(WaveLaneCtx *lane) } } - - - - - - - - - ////////////////////////////// //- Push test explosion if (frame->held_buttons[Button_G]) - // if (frame->held_buttons[Button_G] && !prev_frame->held_buttons[Button_G]) - // if (0) { // Fire { @@ -3806,13 +3126,7 @@ void V_TickForever(WaveLaneCtx *lane) emitter.kind = V_ParticleKind_Fire; f32 angle = AngleFromVec2(frame->look); - // f32 angle = 0; - // f32 angle_spread = Tau * 0.25; f32 angle_spread = Tau; - // f32 angle_spread = 0; - - // f32 speed = 25; - // f32 speed = 50; f32 speed = 100; f32 speed_spread = speed * 2; @@ -3827,47 +3141,8 @@ void V_TickForever(WaveLaneCtx *lane) V_PushParticles(emitter); } - - // Smoke - // { - // V_Emitter emitter = Zi; - - // emitter.kind = V_ParticleKind_Smoke; - - // f32 angle = AngleFromVec2(frame->look); - // // f32 angle = 0; - // // f32 angle_spread = Tau * 0.25; - // f32 angle_spread = Tau; - // // f32 angle_spread = 0; - - // f32 speed = 25; - // // f32 speed = 50; - // // f32 speed = 50; - // f32 speed_spread = speed * 2; - - // emitter.pos.p0 = emitter.pos.p1 = frame->world_cursor; - // emitter.speed.min = speed - speed_spread * 0.5; - // emitter.speed.max = speed + speed_spread * 0.5; - // emitter.angle.min = angle - angle_spread * 0.5; - // emitter.angle.max = angle + angle_spread * 0.5; - - // // emitter.falloff.min = emitter.falloff.max = 0; - - // // emitter.count = CeilF32(Kibi(64) * frame->dt); - // // emitter.count = Mebi(16); - // // emitter.count = Mebi(2); - // // emitter.count = Kibi(32); - // emitter.count = Kibi(8); - // // emitter.count = Kibi(1); - // // emitter.count = 128; - // // emitter.count = 32; - // // emitter.count = 1; - - // V_PushParticles(emitter); - // } } - ////////////////////////////// //- Debug draw @@ -3931,13 +3206,6 @@ void V_TickForever(WaveLaneCtx *lane) P_tl.debug_draw_nodes_count = 0; } - - - - - - - ////////////////////////////// //- Collect profiler samples @@ -4053,132 +3321,10 @@ void V_TickForever(WaveLaneCtx *lane) } } - - - - - - ////////////////////////////// - //- Update panels from cmds - - - - - // TODO: Remove this - // if (frame->tick == 1) - // { - // frame->show_consoles = 1; - // } - - - - - - // b32 show_editor_panels = (frame->is_editing && !hide_editor_ui) || TweakBool("Show panels when not editing", 0); - // { - // Struct(PanelBfs) { PanelBfs *next; V_Panel *panel; }; - // PanelBfs *first_panel_bfs = PushStruct(frame->arena, PanelBfs); - // PanelBfs *last_panel_bfs = first_panel_bfs; - // first_panel_bfs->panel = V.root_panel; - // for (PanelBfs *bfs_parent = first_panel_bfs; bfs_parent; bfs_parent = first_panel_bfs) - // { - // SllQueuePop(first_panel_bfs, last_panel_bfs); - // V_Panel *parent_panel = bfs_parent->panel; - // for (V_Panel *panel = parent_panel->first; panel; panel = panel->next) - // { - // PanelBfs *bfs_panel = PushStruct(frame->arena, PanelBfs); - // bfs_panel->panel = panel; - // SllQueuePush(first_panel_bfs, last_panel_bfs, bfs_panel); - // { - // b32 should_show = 1; - // b32 is_editor_panel = !panel->is_organizational && !AnyBit(panel->flags, V_PanelFlag_Screen | V_PanelFlag_Console); - // should_show = should_show && (!is_editor_panel || show_editor_panels); - // should_show = should_show && (!AnyBit(panel->flags, V_PanelFlag_Console) || frame->show_consoles); - // should_show = should_show && (!AnyBit(panel->flags, V_PanelFlag_Profiler) || frame->show_profilers); - // panel->flags = SetBit(panel->flags, V_PanelFlag_Ignore, !should_show); - // } - // } - // } - // } - - - - - - - - - - - - - ////////////////////////////// //- Build panel contents - - - - - - - // 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 - // 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_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); @@ -4188,22 +3334,8 @@ void V_TickForever(WaveLaneCtx *lane) UI_SetNext(Parent, vis_panels_box); UI_BuildBoxEx(vis_screen_panel_box); - } - - - - - UI_Key profiler_graph_box = UI_KeyF("graph"); - b32 should_draw_profiler_graph = 0; - V.profiler_graph_dims = DimsFromRng2(UI_Rect(profiler_graph_box)); - // frame->profiler_graph_dims = frame->profiler.graph_dims; - // frame->profiler_frame_seq = V.profiler_frame_seq; - - - - if (V.root_panel && show_panels) { Struct(BfsPanel) { BfsPanel *next; V_Panel *panel; }; @@ -4232,11 +3364,6 @@ void V_TickForever(WaveLaneCtx *lane) ////////////////////////////// //- Build stats panel - - - - - if (panel->flags & V_PanelFlag_Stats) { UI_SetNext(Width, UI_Grow(1, 0)); @@ -4337,14 +3464,6 @@ void V_TickForever(WaveLaneCtx *lane) UI_SetNext(Width, UI_Shrink(0, 0)); UI_SetNext(ChildAlignment, UI_Region_Left); - if (is_name) - { - // UI_SetNext(ChildAlignment, UI_Region_Left); - } - else - { - // UI_BuildSpacer(UI_Grow(1, 0), Axis_X); - } UI_SetNext(ChildAlignment, UI_Region_Left); UI_SetNext(TextColor, text_color); @@ -4353,73 +3472,14 @@ void V_TickForever(WaveLaneCtx *lane) UI_SetNext(Flags, UI_BoxFlag_DrawText | UI_BoxFlag_Scissor | UI_BoxFlag_DontTruncateText); UI_BuildBox(); - // UI_SetNext(Width, UI_Shrink(0, 1)); - // UI_SetNext(Height, UI_Shrink(0, 1)); - // UI_SetNext(Text, stat.value); - // UI_SetNext(Flags, UI_BoxFlag_DrawText); - // UI_BuildBox(); - UI_BuildSpacer(padding, Axis_X); } - // UI_BuildDivider(divider_size, divider_color, Axis_Y); } } } - } } - - - // if (panel->flags & V_PanelFlag_Stats) - // { - // UI_SetNext(Width, UI_Grow(1, 0)); - // UI_PushDF(FontSize, UI_Top(FontSize) * 1.5) - // UI_PushDF(Parent, UI_BuildColumn()) - // { - // Struct(Stat) { String name; String value; }; - // Stat stats[] = { - // { Lit("Particle sequence"), StringF(frame->arena, "%F", FmtUint(V.particle_seq)) } - // }; - - // UI_Size padding = UI_Px(10, 1); - - // u64 stats_count = countof(stats); - // for (u64 stat_idx = 0; stat_idx < stats_count; ++stat_idx) - // { - // UI_BuildSpacer(padding, Axis_Y); - - // Stat stat = stats[stat_idx]; - // // UI_SetNext(Width - // UI_SetNext(Width, UI_Grow(1, 0)); - // UI_SetNext(Height, UI_Shrink(0, 1)); - // UI_SetNext(BorderSize, 1) - // UI_PushDF(Parent, UI_BuildRow()) - // { - // UI_BuildSpacer(padding, Axis_X); - - // UI_SetNext(TextColor, theme.col.hint); - // UI_SetNext(Width, UI_Grow(1, 0)); - // UI_SetNext(Height, UI_Shrink(0, 1)); - // UI_SetNext(Text, stat.name); - // UI_SetNext(Flags, UI_BoxFlag_DrawText); - // UI_BuildBox(); - - // UI_SetNext(Width, UI_Shrink(0, 1)); - // UI_SetNext(Height, UI_Shrink(0, 1)); - // UI_SetNext(Text, stat.value); - // UI_SetNext(Flags, UI_BoxFlag_DrawText); - // UI_BuildBox(); - - // UI_BuildSpacer(padding, Axis_X); - // } - // }; - // } - // } - - - - ////////////////////////////// //- Build console panel @@ -4471,15 +3531,8 @@ void V_TickForever(WaveLaneCtx *lane) //- Build log entries UI UI_PushDF(ChildAlignment, UI_Region_BottomLeft) - // UI_PushDF(Anchor, UI_Region_BottomLeft) - // UI_SetNext(Height, UI_Shrink(0, 1)); UI_PushDF(Parent, UI_BuildColumn()) { - // UI_SetNext(BackgroundColor, VEC4(0.1, 0.5, 0.5, 0.8)); - // UI_SetNext(Height, UI_Grow(1, 0)); - // UI_BuildBox(); - - // UI_SetNext(Flags, UI_BoxFlag_Floating) UI_SetNext(Height, UI_Shrink(0, 1)); UI_PushDF(Parent, UI_BuildColumn()) { @@ -4497,11 +3550,8 @@ void V_TickForever(WaveLaneCtx *lane) UI_SetNext(Height, UI_Shrink(0, 1)); UI_PushDF(Parent, UI_BuildRow()) { - // UI_BuildLabelF("%F", FmtString(text)); UI_SetNext(Height, UI_Shrink(0, 1)); UI_SetNext(Text, display_text); - // UI_SetNext(ChildAlignment, UI_Region_BottomLeft); - // UI_SetNext(ChildAlignment, UI_Region_TopLeft); UI_SetNext(Flags, UI_BoxFlag_DrawText); UI_BuildBox(); } @@ -4510,25 +3560,9 @@ void V_TickForever(WaveLaneCtx *lane) } } - - - - - - - - - - - ////////////////////////////// //- Build spawner panel - - - - - if (panel->flags & V_PanelFlag_Spawn) { UI_Size window_padding = UI_Fnt(0.60, 1); @@ -4551,8 +3585,6 @@ void V_TickForever(WaveLaneCtx *lane) UI_BuildRow(); } - // UI_BuildSpacer(window_padding, Axis_Y); - // UI_BuildDivider(UI_Px(1, 0), theme.col.divider, Axis_Y); UI_BuildSpacer(window_padding, Axis_Y); //- Tiles @@ -4580,7 +3612,6 @@ void V_TickForever(WaveLaneCtx *lane) ); Vec4 border_color = Zi; - // border_color = LerpSrgb(border_color, theme.col.button_selected, UI_Misc(tile_box)); border_color = LerpSrgb(border_color, theme.col.button_active, UI_Hot(tile_box)); UI_SetNext(BackgroundColor, bg_color); @@ -4652,7 +3683,6 @@ void V_TickForever(WaveLaneCtx *lane) ); Vec4 border_color = Zi; - // border_color = LerpSrgb(border_color, theme.col.button_selected, UI_Misc(prefab_box)); border_color = LerpSrgb(border_color, theme.col.button_active, UI_Hot(prefab_box)); UI_SetNext(BackgroundColor, bg_color); @@ -4701,91 +3731,25 @@ void V_TickForever(WaveLaneCtx *lane) } } - - - - - - - - - - - - - - - - - - - - - - - - - - ////////////////////////////// //- Build profiler panel if (panel->flags & V_PanelFlag_Profiler) ProfZoneDF("Build profiler panel") { - // FIXME: Finalize - panel->rounding = UI_Rpx(10 * theme.rounding); panel->resizer_opacity = 0; - - - // // FIXME: Remove this - // if (frame->tick == 1) - // { - // frame->profiler.is_showing = 1; - // } - - - - - - - - - - V_Profiler *profiler = &panel->profiler; f64 min_profiler_ns_per_px = 1; - // f64 max_profiler_ns_per_px = NsFromSeconds(100); f64 max_profiler_ns_per_px = frame->time_ns / 10; profiler->target_ns_per_px = ClampF64(profiler->target_ns_per_px, min_profiler_ns_per_px, max_profiler_ns_per_px); profiler->ns_per_px = ClampF64(profiler->ns_per_px, min_profiler_ns_per_px, max_profiler_ns_per_px); UI_PushDF(OmitFlags, UI_BoxFlag_CaptureMouse * !!(frame->is_looking)) - // if (profiler->is_showing) { - // FIXME: Remove this - - // if (frame->tick == 1) - // { - // // profiler->ns_per_px = NsFromSeconds(0.0001); - // profiler->target_ns_per_px = NsFromSeconds(0.01); - // } - - - // FIXME: Remove this - { - V_ProfilerFrame *pf = &V.profiler_frames[V.profiler_frame_seq % V_ProfilerFramesCap]; - V.profiler_frame_seq += 1; - } - - //- Build profiler - // UI_Key profiler_box = UI_KeyF("profiler"); - // // UI_PushDF(Tag, profiler_box.v) - // UI_PushDF(Parent, profiler_box) { UI_Key main_box = UI_KeyF("main"); @@ -4795,36 +3759,15 @@ void V_TickForever(WaveLaneCtx *lane) UI_Size footer_height = UI_Fnt(2, 1); UI_Size window_padding = UI_Fnt(0.60, 1); UI_Size minor_padding = UI_Fnt(0.15, 1); - // UI_Size graph_height = UI_Grow(0.25, 0); UI_Size graph_height = UI_Fnt(2, 1); UI_Size main_height = UI_Grow(1, 0); UI_Size zone_height = UI_Fnt(1.25, 0); - // UI_Size track_height = UI_Fnt(10, 0); - // UI_Size track_height = UI_Grow(1, 0); UI_Size track_height = UI_Shrink(0, 0); f32 zone_text_padding_px = UI_Top(FontSize) * 0.2; - // Vec2 old_main_dims = DimsFromRng2(UI_Rect(main_box)); - // old_main_dims.x = MaxF32(old_main_dims.x, 1); - // old_main_dims.y = MaxF32(old_main_dims.y, 1); - - - - // if (profiler->view_start_ns == 0 && profiler->view_end_ns == 0) - // { - // profiler->view_start_ns = NsFromSeconds(0); - // profiler->view_end_ns = NsFromSeconds(10); - // } - - - // f32 old_cursor_offset_px = frame->screen_cursor.x - UI_Rect(main_box).p0.x; - // i64 old_cursor_offset_ns = (old_cursor_offset_px / old_main_dims.x) * (profiler->view_end_ns - profiler->view_start_ns); - // i64 old_cursor_ns = profiler->view_start_ns + old_cursor_offset_ns; - f32 cursor_px = frame->screen_cursor.x - UI_Rect(main_box).p0.x; b32 is_main_hot = UI_HotAbsolute(main_box); - // if (is_main_hot) { profiler->cursor_ns = (cursor_px * profiler->ns_per_px) + profiler->view_ns; } @@ -4877,51 +3820,8 @@ void V_TickForever(WaveLaneCtx *lane) } } - - - - - - - - - - - - - - - - - - // if (profiler->is_dragging && !prev_frame->profiler.is_dragging) - // { - // profiler->drag_view_ns = profiler->view_ns; - // profiler->drag_cursor_px = cursor_px; - // } - - // if (profiler->is_dragging) - // { - // profiler->view_ns = profiler->drag_view_ns - ((cursor_px - profiler->drag_cursor_px) * profiler->ns_per_px); - // } - - - - - // FIXME: Recalc cursor after zoom - - - - - // if (is_main_hot) - { - profiler->cursor_ns = (cursor_px * profiler->ns_per_px) + profiler->view_ns; - } - - - - - + // Recalculate cursor after zoom + profiler->cursor_ns = (cursor_px * profiler->ns_per_px) + profiler->view_ns; // TODO: Drag in px units for sharper resolution if (UI_Downs(main_box, Button_M2) || UI_Downs(main_box, Button_M3)) @@ -4958,23 +3858,6 @@ void V_TickForever(WaveLaneCtx *lane) profiler->target_view_ns = profiler->view_ns; } - - - - - - - - // FIXME: Remove this - b32 do_break = frame->real_held_buttons[Button_B] && !prev_frame->real_held_buttons[Button_B]; - - - - - - - - // FIXME: Remove this f64 view_range_len_px = DimsFromRng2(UI_Rect(main_box)).x; f64 view_range_len_ns = view_range_len_px * profiler->ns_per_px; @@ -4984,23 +3867,7 @@ void V_TickForever(WaveLaneCtx *lane) f64 view_start_px = view_start_ns / profiler->ns_per_px; f64 view_end_px = view_end_ns / profiler->ns_per_px; - - - - - - - - - - - - - - - //- Generate visible zones - Struct(VisZone) { VisZone *parent; @@ -5136,14 +4003,6 @@ void V_TickForever(WaveLaneCtx *lane) f32 v = TweakFloat("Profiler zone brightness", 1.00, 0, 1); Vec4 zone_color = SrgbFromHsv(HSV(h, s, v)); - // b32 should_collapse_zone = visual_zone_len_px <= zone_collapse_threshold_px; - // b32 should_collapse_zone = 0; - - // if (visual_zone_start_ns > view_end_ns) - // { - // reached_end_of_view = 1; - // } - if (visual_zone_end_ns >= view_start_ns && visual_zone_start_ns <= view_end_ns) { VisZone *vis_zone = 0; @@ -5265,20 +4124,6 @@ void V_TickForever(WaveLaneCtx *lane) Vec4 collapsed_line_color = SrgbFromHsv(HSV(64, 1, 0.5)); Vec4 collapsed_text_color = SrgbFromHsv(HSV(64, 1, 0.75)); - // main_color_sampled.g += 0.05; - - // UI_SetNext(Parent, vis_screen_box); - // UI_SetNext(BorderColor, theme.col.window_bd); - // UI_SetNext(BorderSize, 2); - // UI_SetNext(BackgroundColor, profiler_color); - // UI_SetNext(Rounding, UI_Rpx(10 * theme.rounding)); - // UI_SetNext(Height, profiler_height); - // UI_SetNext(Flags, UI_BoxFlag_CaptureMouse); - // UI_SetNext(Opacity, profiler_opacity); - // UI_SetNext(Parent, panel->contents_box); - // UI_PushDF(Width, UI_Grow(1, 0)) - // UI_PushDF(Parent, UI_BuildColumnEx(profiler_box)) - // UI_PushDF(Parent, UI_BuildRow()) { UI_BuildSpacer(window_padding, Axis_X); UI_BuildSpacer(window_padding, Axis_X); @@ -5296,42 +4141,17 @@ void V_TickForever(WaveLaneCtx *lane) UI_BuildLabelF("Profiler"); } - // UI_BuildSpacer(window_padding, Axis_Y); - // UI_BuildSpacer(window_padding, Axis_Y); - // UI_BuildDivider(UI_Px(1, 1), theme.col.divider, Axis_Y); - - //- Graph - // UI_SetNext(BackgroundColor, Color_Cyan); - // UI_SetNext(Height, graph_height); - // UI_PushDF(Parent, UI_BuildBoxEx(profiler_graph_box)) - // { - // } - // UI_BuildDivider(UI_Px(1, 1), theme.col.divider, Axis_Y); - - // UI_BuildDivider(UI_Px(1, 1), theme.col.divider, Axis_Y); - - UI_BuildSpacer(window_padding, Axis_Y); - - - - - - UI_PushDF(Parent, UI_BuildRow()) { UI_BuildSpacer(window_padding, Axis_X); //- Main area - // UI_SetNext(BackgroundColor, main_color_unsampled); UI_SetNext(Height, main_height); UI_SetNext(Rounding, UI_Rpx(8 * theme.rounding)); - // UI_SetNext(BackgroundColor, theme.col.window_bg); UI_SetNext(BorderSize, 1); UI_SetNext(BorderColor, theme.col.divider); UI_SetNext(BackgroundColor, main_color_unsampled); - // UI_SetNext(Flags, UI_BoxFlag_CaptureMouse | UI_BoxFlag_CaptureThroughChildren | UI_BoxFlag_Scissor); UI_SetNext(Flags, UI_BoxFlag_CaptureMouse | UI_BoxFlag_CaptureThroughChildren); - // UI_SetNext(Flags, UI_BoxFlag_CaptureMouse); UI_PushDF(Parent, UI_BuildColumnEx(main_box)) { //- Active area background @@ -5350,29 +4170,6 @@ void V_TickForever(WaveLaneCtx *lane) UI_Size aabg_width = UI_Px(aabg_len_px, 1); Vec4 aabg_color = main_color_sampled; - - // { - // // UI_SetNext(BorderSize, 1); - // // UI_SetNext(BorderColor, Color_White); - // UI_SetNext(Width, aabg_width); - // UI_SetNext(FloatingPos, aabg_pos); - // UI_SetNext(BackgroundColor, aabg_color); - // UI_SetNext(Flags, UI_BoxFlag_Floating); - // UI_BuildBoxEx(UI_KeyF("active area background")); - // } - - // { - // // UI_SetNext(BorderSize, 1); - // // UI_SetNext(BorderColor, Color_White); - // // UI_SetNext(BackgroundColor, timeline_cursor_color); - // UI_SetNext(BackgroundColor, Color_White); - // UI_SetNext(Width, UI_Px(2, 0)); - // // UI_SetNext(Width, timeline_cursor_width); - // UI_SetNext(FloatingPos, VEC2(aabg_cursor_offset_px + aabg_width.v, 0)); - // UI_SetNext(Anchor, UI_Region_Top); - // UI_SetNext(Flags, UI_BoxFlag_Floating | UI_BoxFlag_DontClampFloatingX); - // UI_BuildBoxEx(UI_KeyF("aabg start cursor")); - // } } UI_Size track_padding = UI_Px(window_padding.v * 2, 0); @@ -5388,9 +4185,6 @@ void V_TickForever(WaveLaneCtx *lane) { for (VisTrack *vis_track = first_vis_track; vis_track; vis_track = vis_track->next) { - // TODO: Real wave/lane information - String wave_name = Lit("Vis wave"); - u32 lane_idx = 2; UI_Key track_box = UI_KeyF("vis track %F", FmtUint(vis_track->id)); Vec2 track_dims_rate = VEC2(Inf, Inf); @@ -5404,34 +4198,19 @@ void V_TickForever(WaveLaneCtx *lane) UI_PushDF(Tag, track_box.v) UI_PushDF(Parent, UI_BuildColumnEx(track_box)) { - // UI_BuildSpacer(window_padding, Axis_Y); - // UI_BuildSpacer(window_padding, Axis_Y); - UI_SetNext(Height, track_height); UI_PushDF(Parent, UI_BuildRow()) { - // UI_BuildSpacer(window_padding, Axis_X); - // UI_BuildSpacer(window_padding, Axis_X); - UI_SetNext(DimsRate, track_dims_rate); UI_SetNext(Height, track_height); UI_PushDF(Parent, UI_BuildColumnEx(UI_KeyF("track area"))) { UI_BuildSpacer(window_padding, Axis_Y); - // UI_BuildSpacer(window_padding, Axis_Y); - // UI_BuildSpacer(track_padding, Axis_Y); - // UI_BuildSpacer(track_padding, Axis_Y); - // UI_BuildDivider(UI_Px(1, 1), theme.col.divider, Axis_Y); - //- Wave/lane info { - // UI_SetNext(Height, zone_height); UI_SetNext(Height, UI_Shrink(0, 1)); - // UI_SetNext(BackgroundColor, VEC4(0.15, 0.15, 0.15, 0.15)); - // UI_SetNext(BackgroundColor, profiler_color); UI_SetNext(BackgroundColor, Color_Transparent); - // UI_SetNext(Text, wave_name); UI_PushDF(Parent, UI_BuildRow()) { UI_PushDF(Height, UI_Shrink(0, 1)) @@ -5440,7 +4219,6 @@ void V_TickForever(WaveLaneCtx *lane) UI_PushDF(Flags, UI_BoxFlag_DrawText) { UI_PushDF(Text, StringF(frame->arena, " %F ", FmtString(vis_track->lane->wave->name))) - // UI_PushDF(TextColor, theme.col.hint) UI_BuildBox(); UI_PushDF(Text, StringF(frame->arena, "Lane %F", FmtUint(vis_track->lane->idx))) @@ -5454,30 +4232,18 @@ void V_TickForever(WaveLaneCtx *lane) UI_SetNext(Height, track_height); UI_SetNext(DimsRate, track_dims_rate); - // UI_SetNext(Rounding, UI_Rpx(5 * theme.rounding)); - // UI_SetNext(BackgroundColor, profiler_color); - // UI_SetNext(BackgroundColor, theme.col.panel_bg); UI_SetNext(BorderColor, theme.col.window_bd); - // UI_SetNext(BorderSize, 1); - // UI_SetNext(Flags, UI_BoxFlag_Scissor); UI_PushDF(Parent, UI_BuildRowEx(UI_KeyF("zone rows"))) { - // UI_BuildSpacer(window_padding, Axis_Y); - UI_SetNext(Height, track_height); UI_PushDF(Parent, UI_BuildColumn()) { - - // UI_BuildSpacer(UI_Px(10, 0), Axis_Y); - // UI_BuildSpacer(UI_Grow(1, 0), Axis_Y); - //- Zone rows UI_Key *zone_row_boxes = PushStructs(frame->arena, UI_Key, vis_track->rows_count); for (u64 zone_row_box_idx = 0; zone_row_box_idx < vis_track->rows_count; ++zone_row_box_idx) { UI_Key zone_row_box = UI_KeyF("zone row %F", FmtUint(zone_row_box_idx)); zone_row_boxes[zone_row_box_idx] = zone_row_box; - // UI_SetNext(Height, zone_height); UI_SetNext(Height, zone_height); UI_PushDF(Parent, UI_BuildRowEx(zone_row_box)) { @@ -5520,33 +4286,8 @@ void V_TickForever(WaveLaneCtx *lane) zone_text_color.a *= 0.75; Vec4 zone_line_color = Zi; - - // b32 is_collapsed = zone->is_collapsed; b32 is_collapsed = zone->collapsed_count > 0; - // b32 is_collapsed = zone->collapsed_count > 0 || zone_len_px <= min_zone_width_px; - - // UI_Size collapsed_line_size = UI_Px(2, 1); UI_Size collapsed_line_size = UI_Px(1.5, 1); - // Vec4 collapsed_text_color = theme.col.positive; - // Vec4 collapsed_line_color = theme.col.negative; - // Vec4 collapsed_line_color = SrgbFromHsv(TweakFloat("RAAAAAAAAAH H", 100, 0, 360), TweakFloat("RAAAAAAAAAH S", 0.50, 0, 1), TweakFloat("RAAAAAAAAAH V", 1.00, 0, 1)); - // Vec4 collapsed_line_color = Color_Black; - // Vec4 collapsed_line_color = theme.col.hint; - // Vec4 collapsed_text_color = theme.col.positive; - // Vec4 collapsed_text_color = SrgbFromHsv(TweakFloat("RAAAAAAAAAH H", 100, 0, 360), TweakFloat("RAAAAAAAAAH S", 0.50, 0, 1), TweakFloat("RAAAAAAAAAH V", 1.00, 0, 1)); - - // Vec4 collapsed_line_color = SrgbFromHsv(32, 1, 0.5); - // Vec4 collapsed_text_color = SrgbFromHsv(32, 1, 1); - - // Vec4 collapsed_line_color = SrgbFromHsv(64, 1, 0.5); - // Vec4 collapsed_text_color = SrgbFromHsv(64, 1, 0.75); - - // collapsed_text_color = LerpSrgb(collapsed_text_color, Color_White, zone_hovered); - // collapsed_line_color = LerpSrgb(collapsed_line_color, Color_White, zone_hovered); - - - - String zone_text = zone->name; if (is_collapsed) @@ -5554,32 +4295,8 @@ void V_TickForever(WaveLaneCtx *lane) zone_text = StringF(frame->arena, "%F", FmtUint(zone->collapsed_count)); zone_text_color = collapsed_text_color; zone_line_color = collapsed_line_color; - - // zone_color = VEC4(0, 0, 0, 0); - // zone_color = VEC4(1, 0, 1, 1); - // zone_color = VEC4(0.15, 0.15, 0.15, 0.5); - // zone_color = VEC4(0.20, 0.20, 0.20, 0.5); - - zone_color = VEC4(0.25, 0.25, 0.25, 0.5); - - - // if (zone->collapsed_count > 1) - // { - // zone_color = VEC4(0.25, 0.25, 0.25, 0.5); - // } - // else - // { - // zone_color = Color_White; - // } - - - - // zone_color = VEC4(0.4, 0.4, 0.4, 0.5); zone_color_bd = VEC4(0, 0, 0, 0); - - // zone_color = LerpSrgb(zone_color, Color_Transparent, zone_hovered); - } if (zone_len_px < zone_name_hide_threshold_px) @@ -5590,19 +4307,9 @@ void V_TickForever(WaveLaneCtx *lane) zone_color_bd = LerpSrgb(zone_color_bd, Color_White, zone_hovered * !is_collapsed); zone_text_color = LerpSrgb(zone_text_color, Color_White, zone_hovered); zone_line_color = LerpSrgb(zone_line_color, Color_White, zone_hovered); - - f32 collapsed_zones_per_px = zone->collapsed_count / zone_len_px; - // f32 zag_intensity = 50 / collapsed_zones_per_px; - // zag_intensity = MaxF32(zag_intensity, 5); - - // f32 top_zag_information_density = 10; f32 top_zag_information_density = zone_collapse_threshold_px; f32 zag_intensity = SmoothstepF32(0, top_zag_information_density, collapsed_zones_per_px); - // f32 zag_intensity = 1; - // f32 zag_intensity = TweakFloat("RAAAAAAAAAAAAAH", 1, 0, 1); - - // f32 zag_intensity = 0.3; f32 period_max = 20; f32 period_min = 5; @@ -5628,11 +4335,6 @@ void V_TickForever(WaveLaneCtx *lane) UI_BoxFlag_Scissor ); UI_SetNext(Parent, zone_row_box); - // UI_PushDF(OrFlags, UI_Top(OrFlags) | (UI_BoxFlag_DontTruncateText * !!(is_collapsed))) - // UI_PushDF(OmitFlags, UI_Top(OmitFlags) | (UI_BoxFlag_Scissor * !!(is_collapsed))) - // UI_PushDF(ZagPeriod, UI_Top(FontSize) * 1) - // UI_PushDF(ZagPeriod, (collapsed_zones_per_px * UI_Top(FontSize)) * 0.1) - // UI_PushDF(ZagPeriod, collapsed_zones_per_px / (UI_Top(FontSize) * 1)) UI_PushDF(ZagPeriod, zag_period) UI_PushDF(ZagThickness, 1.5) UI_PushDF(ZagRoundness, 1) @@ -5655,7 +4357,6 @@ void V_TickForever(WaveLaneCtx *lane) if (zone_text.len > 0) { // Zone name - // if (zone_len_px > zone_collapse_threshold_px * 3) { if (is_collapsed) { @@ -5690,27 +4391,14 @@ void V_TickForever(WaveLaneCtx *lane) } } } - - // UI_BuildSpacer(window_padding, Axis_Y); } - UI_BuildSpacer(window_padding, Axis_Y); } - - // UI_BuildSpacer(window_padding, Axis_X); - // UI_BuildSpacer(window_padding, Axis_X); } - - // UI_BuildSpacer(window_padding, Axis_Y); - // UI_BuildSpacer(window_padding, Axis_Y); } } } - - - - //- Ruler UI_PushDF(Opacity, profiler->ruler_opacity) { @@ -5728,15 +4416,10 @@ void V_TickForever(WaveLaneCtx *lane) Vec2 ruler_cursor_pos = VEC2(ruler_cursor_offset_px, 0); Vec2 ruler_pos = VEC2(ruler_offset_px, 0); UI_Size ruler_width = UI_Px(ruler_len_px, 1); - - // Vec4 ruler_color = VEC4(0.25, 0.25, 0.25, 0.25); Vec4 ruler_color = VEC4(0.20, 0.20, 0.20, 0.25); // Ruler rect { - // UI_SetNext(BorderSize, 1); - // UI_SetNext(BorderColor, Color_White); - // UI_PushDF(Opacity, profiler->ruler_opacity) UI_SetNext(Width, ruler_width); UI_SetNext(FloatingPos, ruler_pos); UI_SetNext(BackgroundColor, ruler_color); @@ -5746,9 +4429,6 @@ void V_TickForever(WaveLaneCtx *lane) // Ruler cursor { - // UI_SetNext(BorderSize, 1); - // UI_SetNext(BorderColor, Color_White); - // UI_SetNext(BackgroundColor, timeline_cursor_color); UI_SetNext(BackgroundColor, ruler_color); UI_SetNext(Width, timeline_cursor_width); UI_SetNext(FloatingPos, ruler_cursor_pos); @@ -5761,7 +4441,6 @@ void V_TickForever(WaveLaneCtx *lane) //- Timeline cursor { - // Vec2 timeline_cursor_pos = VEC2(old_cursor_offset_px, 0); Vec2 timeline_cursor_pos = VEC2((profiler->cursor_ns - profiler->view_ns) / profiler->ns_per_px, 0); UI_SetNext(Width, timeline_cursor_width); @@ -5805,16 +4484,9 @@ void V_TickForever(WaveLaneCtx *lane) if (show_ruler_time) { - // UI_SetNext(TextColor, theme.col.positive); - // UI_SetNext(TextColor, theme.col.button_active); - - // UI_SetNext(TextColor, theme.col.button_selected); UI_SetNext(TextColor, VEC4(1, 0.8, 0, 1)); UI_BuildLabelF("%F", FmtTimeNs(ruler_len_ns, .p = 2)); - // UI_SetNext(TextColor, theme.col.button_selected); - // UI_BuildLabelF("Ruler"); - if (show_hovered_zone) { UI_BuildSpacer(minor_padding, Axis_Y); @@ -5840,13 +4512,6 @@ void V_TickForever(WaveLaneCtx *lane) { if (zone->collapsed_count == 1) { - // // UI_BuildLabelF(" (%F)", FmtUint(zone->collapsed_count)); - // UI_SetNext(TextColor, theme.col.hint); - // UI_BuildLabelF("%F", FmtString(zone->name)); - - // UI_SetNext(TextColor, collapsed_text_color); - // UI_BuildLabelF(" (Too small to display)"); - UI_SetNext(TextColor, collapsed_text_color); UI_BuildLabelF("1 zone too small to display: "); UI_SetNext(TextColor, theme.col.hint); @@ -5854,14 +4519,6 @@ void V_TickForever(WaveLaneCtx *lane) } else { - // UI_SetNext(TextColor, theme.col.hint); - // UI_BuildLabelF("Zones too small to display"); - - // UI_SetNext(TextColor, collapsed_text_color); - // UI_BuildLabelF(" (%F)", FmtUint(zone->collapsed_count)); - - - // UI_SetNext(TextColor, theme.col.hint); UI_SetNext(TextColor, collapsed_text_color); UI_BuildLabelF("%F zones too small to display", FmtUint(zone->collapsed_count)); } @@ -5886,10 +4543,6 @@ void V_TickForever(WaveLaneCtx *lane) UI_BuildSpacer(window_padding, Axis_X); } - // UI_BuildSpacer(window_padding, Axis_Y); - - // UI_BuildDivider(UI_Px(1, 1), theme.col.divider, Axis_Y); - //- Footer UI_PushDF(Height, footer_height) UI_PushDF(ChildAlignment, UI_Region_Center) @@ -5927,470 +4580,359 @@ void V_TickForever(WaveLaneCtx *lane) } - - - - - - - - - - - - - - - - - - - - - - - // ////////////////////////////// - // //- Init panel layout - - // // TODO: Allow for custom layouts stored in config files - // // TODO: Don't use rand keys for panels - - // if (!V.root_panel) - // { - // V.root_panel = PushStruct(perm, V_Panel); - // V_Panel *left_panel = PushStruct(perm, V_Panel); - // V_Panel *right_panel = PushStruct(perm, V_Panel); - - // //- Root panel - // { - // { - // V_Panel *panel = V.root_panel; - // panel->box = UI_KeyF("test root panel"); - // panel->contents_box = vis_panels_box; - // panel->resizer_box = UI_KeyF("panel resizer box %F", FmtUint(panel->box.v)); - // panel->pct = 1; - // panel->is_organizational = 1; - // panel->axis = Axis_X; - // V.root_panel = panel; - // } - - // //- Left panel - // { - // V_Panel *panel = left_panel; - // panel->parent = V.root_panel; - // panel->axis = Axis_Y; - // 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->pct = 0.10; - // panel->is_organizational = 1; - // } - - // //- Right panel - // { - // V_Panel *panel = right_panel; - // panel->parent = V.root_panel; - // panel->axis = Axis_Y; - // 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->pct = 0.90; - // panel->is_organizational = 1; - // } - // } - - // //- Test stats panel - // { - // V_Panel *parent = left_panel; - // V_Panel *panel = PushStruct(perm, V_Panel); - // panel->axis = Axis_X; - // DllQueuePush(parent->first, 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_stats; - // panel->pct = 0.25; - // } - - // //- 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); - // // 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 - // { - // 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 = vis_screen_panel_box; - // panel->resizer_box = UI_KeyF("panel resizer box %F", FmtUint(panel->box.v)); - // panel->flags |= V_PanelFlag_Screen; - // panel->pct = 1; - // } - - // // //- Test console panel - // // { - // // V_Panel *parent = right_panel; - // // V_Panel *panel = PushStruct(perm, V_Panel); - // // panel->axis = Axis_X; - // // DllQueuePush(parent->first, 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_Console; - // // // panel->flags |= V_PanelFlag_Spawn; - // // panel->pct = 0.25; - // // } - // } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ////////////////////////////// - //- - //- PROFILER DEMO panel layout - //- - - // FIXME: Remove this - - - - - - - - - - - - // // TODO: Allow for custom layouts stored in config files - // // TODO: Don't use rand keys for panels - - // if (!V.root_panel) - // { - // V.root_panel = PushStruct(perm, V_Panel); - // V_Panel *left_panel = PushStruct(perm, V_Panel); - // V_Panel *right_panel = PushStruct(perm, V_Panel); - - // //- Root panel - // { - // { - // V_Panel *panel = V.root_panel; - // panel->box = UI_KeyF("test root panel"); - // panel->contents_box = vis_panels_box; - // panel->resizer_box = UI_KeyF("panel resizer box %F", FmtUint(panel->box.v)); - // panel->pct = 1; - // panel->is_organizational = 1; - // panel->axis = Axis_X; - // V.root_panel = panel; - // } - - // //- Left panel - // { - // V_Panel *panel = left_panel; - // panel->parent = V.root_panel; - // panel->axis = Axis_Y; - // 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->pct = 0.20; - // panel->is_organizational = 1; - // } - - // //- Right panel - // { - // V_Panel *panel = right_panel; - // panel->parent = V.root_panel; - // panel->axis = Axis_Y; - // 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->pct = 0.90; - // panel->is_organizational = 1; - // } - // } - - - // //- Test stats panel - // { - // V_Panel *parent = left_panel; - // V_Panel *panel = PushStruct(perm, V_Panel); - // panel->axis = Axis_X; - // DllQueuePush(parent->first, 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_Stats; - // panel->pct = 0.5; - // } - - // //- 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); - // 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.15; - // } - - // //- Vis screen 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 = vis_screen_panel_box; - // panel->resizer_box = UI_KeyF("panel resizer box %F", FmtUint(panel->box.v)); - // panel->flags |= V_PanelFlag_Screen; - // panel->pct = 0.52; - // } - - // //- Test console panel - // { - // V_Panel *parent = right_panel; - // V_Panel *panel = PushStruct(perm, V_Panel); - // panel->axis = Axis_X; - // DllQueuePush(parent->first, 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_Console; - // // panel->flags |= V_PanelFlag_Spawn; - // panel->pct = 0.10; - // } - // } - - - - - - - - - - - - - - - - - - - - - ////////////////////////////// - //- - //- STATS DEMO panel layout - //- + //- Init panel layout // TODO: Allow for custom layouts stored in config files - // TODO: Don't use rand keys for panels - if (!V.root_panel) - { - V.root_panel = PushStruct(perm, V_Panel); - V_Panel *left_panel = PushStruct(perm, V_Panel); - V_Panel *right_panel = PushStruct(perm, V_Panel); - - //- Root panel + #if 0 + if (!V.root_panel) { + V.root_panel = PushStruct(perm, V_Panel); + V_Panel *left_panel = PushStruct(perm, V_Panel); + V_Panel *right_panel = PushStruct(perm, V_Panel); + + //- Root panel { - V_Panel *panel = V.root_panel; - panel->box = UI_KeyF("test root panel"); - panel->contents_box = vis_panels_box; - panel->resizer_box = UI_KeyF("panel resizer box %F", FmtUint(panel->box.v)); - panel->pct = 1; - panel->is_organizational = 1; + { + V_Panel *panel = V.root_panel; + panel->box = UI_KeyF("test root panel"); + panel->contents_box = vis_panels_box; + panel->resizer_box = UI_KeyF("panel resizer box %F", FmtUint(panel->box.v)); + panel->pct = 1; + panel->is_organizational = 1; + panel->axis = Axis_X; + V.root_panel = panel; + } + + //- Left panel + { + V_Panel *panel = left_panel; + panel->parent = V.root_panel; + panel->axis = Axis_Y; + 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->pct = 0.10; + panel->is_organizational = 1; + } + + //- Right panel + { + V_Panel *panel = right_panel; + panel->parent = V.root_panel; + panel->axis = Axis_Y; + 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->pct = 0.90; + panel->is_organizational = 1; + } + } + + //- Test stats panel + { + V_Panel *parent = left_panel; + V_Panel *panel = PushStruct(perm, V_Panel); panel->axis = Axis_X; - V.root_panel = panel; + DllQueuePush(parent->first, 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_Stats; + panel->pct = 0.25; } - //- Left panel + //- Test spawn panel { - V_Panel *panel = left_panel; - panel->parent = V.root_panel; - panel->axis = Axis_Y; + 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->pct = 0.4; - panel->is_organizational = 1; + panel->flags |= V_PanelFlag_Spawn; + panel->pct = 0.25; } - //- Right panel + // //- 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 { - V_Panel *panel = right_panel; - panel->parent = V.root_panel; - panel->axis = Axis_Y; + 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 = vis_screen_panel_box; + panel->resizer_box = UI_KeyF("panel resizer box %F", FmtUint(panel->box.v)); + panel->flags |= V_PanelFlag_Screen; + panel->pct = 1; + } + + // //- Test console panel + // { + // V_Panel *parent = right_panel; + // V_Panel *panel = PushStruct(perm, V_Panel); + // panel->axis = Axis_X; + // DllQueuePush(parent->first, 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_Console; + // // panel->flags |= V_PanelFlag_Spawn; + // panel->pct = 0.25; + // } + } + #endif + + //- Profiler demo panel layout + #if 0 + if (!V.root_panel) + { + V.root_panel = PushStruct(perm, V_Panel); + V_Panel *left_panel = PushStruct(perm, V_Panel); + V_Panel *right_panel = PushStruct(perm, V_Panel); + + //- Root panel + { + { + V_Panel *panel = V.root_panel; + panel->box = UI_KeyF("test root panel"); + panel->contents_box = vis_panels_box; + panel->resizer_box = UI_KeyF("panel resizer box %F", FmtUint(panel->box.v)); + panel->pct = 1; + panel->is_organizational = 1; + panel->axis = Axis_X; + V.root_panel = panel; + } + + //- Left panel + { + V_Panel *panel = left_panel; + panel->parent = V.root_panel; + panel->axis = Axis_Y; + 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->pct = 0.20; + panel->is_organizational = 1; + } + + //- Right panel + { + V_Panel *panel = right_panel; + panel->parent = V.root_panel; + panel->axis = Axis_Y; + 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->pct = 0.90; + panel->is_organizational = 1; + } + } + + + //- Test stats panel + { + V_Panel *parent = left_panel; + V_Panel *panel = PushStruct(perm, V_Panel); + panel->axis = Axis_X; + DllQueuePush(parent->first, 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_Stats; + panel->pct = 0.5; + } + + //- 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->pct = 0.90; - panel->is_organizational = 1; + panel->flags |= V_PanelFlag_Spawn; + 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.15; + } + + //- Vis screen 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 = vis_screen_panel_box; + panel->resizer_box = UI_KeyF("panel resizer box %F", FmtUint(panel->box.v)); + panel->flags |= V_PanelFlag_Screen; + panel->pct = 0.52; + } + + //- Test console panel + { + V_Panel *parent = right_panel; + V_Panel *panel = PushStruct(perm, V_Panel); + panel->axis = Axis_X; + DllQueuePush(parent->first, 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_Console; + // panel->flags |= V_PanelFlag_Spawn; + panel->pct = 0.10; } } + #endif - //- Test stats panel + //- Stats demo panel layout + if (1) + { + if (!V.root_panel) { - V_Panel *parent = left_panel; - V_Panel *panel = PushStruct(perm, V_Panel); - panel->axis = Axis_X; - DllQueuePush(parent->first, 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_Stats; - panel->pct = 0.5; + V.root_panel = PushStruct(perm, V_Panel); + V_Panel *left_panel = PushStruct(perm, V_Panel); + V_Panel *right_panel = PushStruct(perm, V_Panel); + + //- Root panel + { + { + V_Panel *panel = V.root_panel; + panel->box = UI_KeyF("test root panel"); + panel->contents_box = vis_panels_box; + panel->resizer_box = UI_KeyF("panel resizer box %F", FmtUint(panel->box.v)); + panel->pct = 1; + panel->is_organizational = 1; + panel->axis = Axis_X; + V.root_panel = panel; + } + + //- Left panel + { + V_Panel *panel = left_panel; + panel->parent = V.root_panel; + panel->axis = Axis_Y; + 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->pct = 0.4; + panel->is_organizational = 1; + } + + //- Right panel + { + V_Panel *panel = right_panel; + panel->parent = V.root_panel; + panel->axis = Axis_Y; + 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->pct = 0.90; + panel->is_organizational = 1; + } + } + + //- Test stats panel + { + V_Panel *parent = left_panel; + V_Panel *panel = PushStruct(perm, V_Panel); + panel->axis = Axis_X; + DllQueuePush(parent->first, 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_Stats; + panel->pct = 0.5; + } + + //- 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); + // 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 + { + 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 = vis_screen_panel_box; + panel->resizer_box = UI_KeyF("panel resizer box %F", FmtUint(panel->box.v)); + panel->flags |= V_PanelFlag_Screen; + panel->pct = 1; + } + + // //- Test console panel + // { + // V_Panel *parent = right_panel; + // V_Panel *panel = PushStruct(perm, V_Panel); + // panel->axis = Axis_X; + // DllQueuePush(parent->first, 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_Console; + // // panel->flags |= V_PanelFlag_Spawn; + // panel->pct = 0.25; + // } } - - //- 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); - // 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 - { - 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 = vis_screen_panel_box; - panel->resizer_box = UI_KeyF("panel resizer box %F", FmtUint(panel->box.v)); - panel->flags |= V_PanelFlag_Screen; - panel->pct = 1; - } - - // //- Test console panel - // { - // V_Panel *parent = right_panel; - // V_Panel *panel = PushStruct(perm, V_Panel); - // panel->axis = Axis_X; - // DllQueuePush(parent->first, 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_Console; - // // panel->flags |= V_PanelFlag_Spawn; - // panel->pct = 0.25; - // } } - - - - - - - - - - - - - - - - - - - - ////////////////////////////// //- Build vis panel contents @@ -6424,11 +4966,6 @@ void V_TickForever(WaveLaneCtx *lane) { f32 minimum_panel_pct = 0.05; - - // FIXME: Ignored panels should be skipped during sibling iteration as well - - - //- Resize panels for (V_Panel *panel = parent_panel->first; panel; panel = panel->next) { @@ -6470,9 +5007,6 @@ void V_TickForever(WaveLaneCtx *lane) } } - - - //- Adjust panel pcts to add to 1 { f32 pct_accum = 0; @@ -6490,44 +5024,6 @@ void V_TickForever(WaveLaneCtx *lane) } } - - - // //- Adjust panel pcts to add to 1 - // f32 children_pct_scale = 1; - // { - // f32 pct_accum = 0; - // for (V_Panel *panel = parent_panel->first; panel; panel = panel->next) - // { - // if (!V_ShouldIgnorePanel(panel)) - // { - // pct_accum += panel->pct; - // } - // } - // children_pct_scale = 1.0 / MinF32(pct_accum, 1); - // } - - - - // // //- Determine scale needed for sum of pcts to reach 1 - // // f32 children_pct_scale = 1; - // // { - // // f32 pct_accum = 0; - // // for (V_Panel *panel = parent_panel->first; panel; panel = panel->next) - // // { - // // if (!V_ShouldIgnorePanel(panel)) - // // { - // // pct_accum += panel->pct; - // // } - // // } - // // children_pct_scale = 1.0 / MaxF32(pct_accum, 0.0001); - // // } - - - - - - - //- Build panel boxes for (V_Panel *panel = parent_panel->first; panel; panel = panel->next) { @@ -6556,23 +5052,12 @@ void V_TickForever(WaveLaneCtx *lane) dims_rate.y = 20; } - // f32 panel_pct = panel->pct; - - // UI_SetNext(AxisSize, UI_Grow(panel_pct, 1), .axis = parent_axis); - // UI_SetNext(AxisSize, UI_Grow(panel_pct, 0), .axis = parent_axis); UI_SetNext(AxisSize, UI_Grow(panel->pct, 0), .axis = parent_axis); - // UI_SetNext(AxisSize, UI_Grow(panel->solved_pct * children_pct_scale, 1), .axis = parent_axis); - // UI_SetNext(AxisSize, UI_Px(panel_pct * parent_contents_size_px, 0), .axis = parent_axis); UI_SetNext(AxisSize, UI_Grow(1, 0), .axis = !parent_axis); UI_SetNext(ChildLayoutAxis, parent_axis); - // UI_SetNext(DimsRate, dims_rate); - // UI_PushDF(DimsRate, dims_rate) UI_PushDF(Tag, panel_box.v) UI_PushDF(Parent, UI_BuildBoxEx(panel_box)) { - // panel_bd.a = 0; - // resizer_color.a = 0; - b32 is_screen_panel_box = panel->flags & V_PanelFlag_Screen; if (is_screen_panel_box || panel->is_organizational) { @@ -6585,26 +5070,13 @@ void V_TickForever(WaveLaneCtx *lane) panel_bg.a = 0; } - //- Left null-resizer box - // if (!panel->prev && !V_ShouldIgnorePanel(panel->prev)) - // { - // UI_SetNext(AxisSize, resizer_size, .axis = parent_axis); - // UI_SetNext(BackgroundColor, resizer_color); - // UI_BuildBox(); - // } - //- Panel contents box { - // UI_SetNext(AxisSize, UI_Grow(panel_pct, 1), .axis = parent_axis); - // UI_SetNext(AxisSize, UI_Grow(1, 0), .axis = !parent_axis); UI_SetNext(ChildLayoutAxis, panel->axis); - // UI_SetNext(Width, UI_Px(500, 1)); - // UI_SetNext(Height, UI_Px(200, 1)); UI_SetNext(BackgroundColor, panel_bg); UI_SetNext(BorderColor, panel_bd); UI_SetNext(BorderSize, 2); UI_SetNext(DimsRate, dims_rate); - // UI_SetNext(Rounding, UI_Rpx(10 * theme.rounding)); UI_SetNext(Rounding, panel->rounding); UI_SetNext(Flags, UI_BoxFlag_Scissor | (UI_BoxFlag_CaptureMouse * (!is_screen_panel_box && !panel->is_organizational))); UI_PushDF(Parent, UI_BuildBoxEx(contents_box)) @@ -6612,8 +5084,6 @@ void V_TickForever(WaveLaneCtx *lane) } } - - //- Resizer box b32 can_resize = panel->next != 0; if (can_resize) @@ -6623,74 +5093,12 @@ void V_TickForever(WaveLaneCtx *lane) UI_SetNext(Flags, UI_BoxFlag_CaptureMouse * !!can_resize); UI_BuildBoxEx(resizer_box); } - - - // //- Overlay box - // { - // // UI_SetNext(AxisSize, resizer_size, .axis = parent_axis); - // // UI_SetNext(AxisSize, UI_Px(100, 1), .axis = parent_axis); - // // UI_SetNext(AxisSize, UI_Px(100, 1), .axis = !parent_axis); - // // UI_SetNext(AxisSize, UI_Grow(1, 1), .axis = !parent_axis); - // // UI_SetNext(AxisSize, UI_Grow(1, 1), .axis = !parent_axis); - // // UI_SetNext(BackgroundColor, Color_Cyan); - // // UI_SetNext(Anchor, UI_Region_Center); - // UI_SetNext(ChildLayoutAxis, parent_axis); - // UI_SetNext(Flags, UI_BoxFlag_Floating); - // UI_SetNext(Parent, contents_box); - // // FIXME: Don't use contents box - // UI_PushDF(Parent, UI_BuildBoxEx(UI_KeyF("overlay box"))) - // { - // UI_SetNext(AxisSize, UI_Grow(1, 0), .axis = parent_axis); - // UI_BuildBox(); - - // //- Resizer box - // if (panel->next) - // { - // UI_SetNext(AxisSize, resizer_size, .axis = parent_axis); - // // UI_SetNext(AxisSize, UI_Px(100, 1), .axis = parent_axis); - // // UI_SetNext(AxisSize, UI_Px(100, 1), .axis = !parent_axis); - // // UI_SetNext(AxisSize, UI_Grow(1, 1), .axis = !parent_axis); - // // UI_SetNext(BackgroundColor, theme.col.divider); - // UI_SetNext(Anchor, UI_Region_Center); - // UI_SetNext(Flags, UI_BoxFlag_CaptureMouse); - // UI_BuildBoxEx(resizer_box); - // } - // } - // } } } } } } - - - - - - - - - - - - - - - - - - - - - - - - - - - - ////////////////////////////// //- Build command palette @@ -6699,7 +5107,6 @@ void V_TickForever(WaveLaneCtx *lane) { UI_Push(Tag, HashF("developer command palette")); - // FIXME: Remove this if (frame->tick == 1) { palette->pos = VEC2(1000, 1000); @@ -6711,7 +5118,6 @@ void V_TickForever(WaveLaneCtx *lane) UI_Size window_padding = UI_Fnt(0.5, 1); UI_Size icon_col_width = UI_Fnt(1.75, 1); UI_Size item_col_width = UI_Fnt(30, 1); - // UI_Size col2_width = UI_Fnt(10, 1); UI_Size scrollbar_width = UI_Fnt(1, 1); f32 item_size_px = UI_Fnt(1.5, 1).v; @@ -6850,7 +5256,6 @@ void V_TickForever(WaveLaneCtx *lane) UI_BuildIcon(theme.icon_font, UI_Icon_Wrench); // Title box - // UI_SetNext(FontSize, UI_Top(FontSize) * theme.h3); UI_SetNext(Width, UI_Shrink(0, 1)); UI_SetNext(Text, Lit(" Developer Palette")); UI_SetNext(Flags, UI_BoxFlag_DrawText); @@ -6897,19 +5302,17 @@ void V_TickForever(WaveLaneCtx *lane) UI_SetNext(Rounding, UI_Rgrow(0.75 * theme.rounding)); UI_SetNext(ChildAlignment, UI_Region_Center); UI_SetNext(BackgroundColor, 0); - // UI_SetNext(BorderColor, reset_bd); UI_SetNext(BorderSize, 0); UI_SetNext(Rounding, 0); UI_SetNext(TextColor, theme.col.hint); UI_SetNext(Width, icon_col_width); UI_SetNext(Height, UI_Px(size_px * 1.5, 1)); - // UI_SetNext(Flags, UI_BoxFlag_CaptureMouse); UI_SetNext(FontSize, size_px * theme.h6); UI_BuildIcon(theme.icon_font, UI_Icon_Search); - // UI_BuildRow(); } //- Search box + // TODO: Move text-box functionality into a widget { UI_Key search_box = UI_KeyF("search box"); UI_Key search_scroll_box = UI_KeyF("search scroll box"); @@ -6918,12 +5321,10 @@ void V_TickForever(WaveLaneCtx *lane) f32 font_size = UI_Top(FontSize); GC_FontKey font = UI_Top(Font); - // Vec4 search_color = Color_Black; Vec4 search_color = Zi; b32 has_focus = UI_MatchKey(search_box, prev_frame->text_input_focus); { - // FIXME: Remove this has_focus = 1; if (UI_Downs(search_box, Button_M1)) { @@ -7004,22 +5405,11 @@ void V_TickForever(WaveLaneCtx *lane) } } - - - - - - - - UI_SetNext(Width, UI_Grow(1, 0)); UI_SetNext(Height, search_height); UI_SetNext(BackgroundColor, search_color); UI_SetNext(ChildAlignment, UI_Region_Right); - // UI_SetNext(BorderColor, item_border_color); - // UI_SetNext(Rounding, UI_Rpx(5)); UI_SetNext(Flags, UI_BoxFlag_CaptureMouse | UI_BoxFlag_Scissor); - // UI_PushDF(BorderSize, 0) UI_PushDF(Parent, UI_BuildRowEx(search_box)) { //- Compute caret / selection pos @@ -7054,10 +5444,6 @@ void V_TickForever(WaveLaneCtx *lane) caret_start_lerp_rate = 1; caret_end_lerp_rate = 1; } - // if (tb_applied_flags & V_TextboxDeltaFlag_UpdateText) - // { - // caret_end_lerp_rate = 1; - // } caret_start_lerp_rate = SaturateF32(caret_start_lerp_rate); caret_end_lerp_rate = SaturateF32(caret_end_lerp_rate); } @@ -7090,8 +5476,6 @@ void V_TickForever(WaveLaneCtx *lane) f32 s = TweakFloat("Text selection saturation", 1, 0, 1); f32 v = TweakFloat("Text selection brightness", 0.6, 0, 1); Vec4 selection_color = SrgbFromHsv(HSV(h, s, v)); - // Vec4 selection_color = theme.col.button_active; - // selection_color.a = 1; Vec4 caret_color = VEC4(1, 1, 1, 0.75); caret_color.a *= AbsF32(CosF32(SecondsFromNs(frame->time_ns - V.text_input_ns) * 3)); @@ -7316,7 +5700,6 @@ void V_TickForever(WaveLaneCtx *lane) } UI_SetNext(Tint, 0); - // UI_SetNext(Width, UI_Px(total_width.v - window_padding.v * 2, 1)); UI_SetNext(Width, UI_Grow(1, 0)); UI_SetNext(Height, UI_Fnt(1.5, 1)); UI_PushDF(Parent, UI_BuildRow()) @@ -7325,10 +5708,7 @@ void V_TickForever(WaveLaneCtx *lane) UI_SetNext(BorderColor, item_border_color); UI_SetNext(BorderSize, 1); UI_SetNext(Rounding, UI_Rpx(5)); - // UI_SetNext(Width, item_col_width); UI_SetNext(Width, UI_Grow(1, 0)); - // UI_SetNext(Height, UI_Px(item_size_px, 1)); - // UI_SetNext(Height, UI_Fnt(1, 0)); UI_SetNext(ChildAlignment, UI_Region_Left); UI_SetNext(Flags, UI_BoxFlag_DrawText | UI_BoxFlag_CaptureMouse); UI_PushDF(Parent, UI_BuildRowEx(item->key)) @@ -7370,12 +5750,7 @@ void V_TickForever(WaveLaneCtx *lane) } Vec4 reset_bg = Zi; - // reset_bg = LerpSrgb(reset_bg, theme.col.button_hot, UI_Hot(reset_key)); - // reset_bg = LerpSrgb(reset_bg, theme.col.button_active, UI_Active(reset_key)); - Vec4 reset_bd = Zi; - // reset_bd = LerpSrgb(reset_bd, theme.col.button_active, UI_Hot(reset_key)); - // reset_bd = LerpSrgb(reset_bd, theme.col.text, UI_Hot(reset_key)); Vec4 reset_text_col = theme.col.hint; reset_text_col = LerpSrgb(reset_text_col, theme.col.text, UI_Hot(reset_key)); @@ -7410,7 +5785,6 @@ void V_TickForever(WaveLaneCtx *lane) } UI_SetNext(FontSize, UI_Top(FontSize) * theme.h5); UI_SetNext(ChildAlignment, UI_Region_Left); - // UI_SetNext(Width, UI_Shrink(0, 1)); UI_SetNext(Width, icon_col_width); UI_SetNext(Height, UI_Shrink(0, 1)); UI_SetNext(Text, new_tweak_str); @@ -7612,14 +5986,6 @@ void V_TickForever(WaveLaneCtx *lane) } } - - - - - - - - //- Scrollbar if (scrollbar_visible) { @@ -7699,126 +6065,16 @@ void V_TickForever(WaveLaneCtx *lane) } UI_BuildSpacer(window_padding, Axis_X); - // UI_BuildSpacer(UI_Fnt(100, 1), Axis_Y); - - - - // FIXME: Remove this - // if (scrollbar_visible) - // { - - // Vec2 scrollbar_pos = scrollbar_reps.UI_Rect().p0; - // Vec2 scrollbar_dims = DimsFromRng2(scrollbar_reps.UI_Rect()); - // Vec2 thumb_dims = DimsFromRng2(UI_Rect(thumb_key)); - // // Vec2 half_thumb_dims = MulVec2(thumb_dims, 0.5); - - - // // f32 range_min = tweak_var.range.min; - // // f32 range_max = tweak_var.range.max; - // // if (range_max <= range_min) - // // { - // // range_max = range_min + 1; - // // } - - - - - - - // // f32 ratio = 0; - // // ratio = (tweak_float - range_min) / (range_max - range_min); - // // ratio = ClampF32(ratio, 0, 1); - - // if (thumb_reps.draw.buttons[Button_M1].downs) - // { - // palette->scroll_begin = palette->scroll; - // } - // if (thumb_reps.draw.buttons[Button_M1].held) - // { - // palette->scroll = palette->scroll_begin + (frame->screen_cursor.y - ui_frame->drag_cursor_pos.y); - // } - // palette->scroll = MaxF32(palette->scroll, 0); - - // // f32 thumb_offset = 50; - // f32 thumb_offset = palette->scroll; - - - - - - - // UI_SetNext(Width, scrollbar_width); - // UI_PushCp(UI_BuildBoxEx(scrollbar_key)); - // { - // UI_Size thumb_height = UI_Fnt(10, 1); - - // Vec4 thumb_color = VEC4(0, 0.5, 1, 1); - // thumb_color.a = thumb_reps.UI_Hot() * 0.5 + 0.5; - - // UI_SetNext(BackgroundColor, thumb_color); - // UI_SetNext(Width, UI_Grow(1, 0)); - // UI_SetNext(Height, thumb_height); - // UI_SetNext(Rounding, UI_Rgrow(1 * theme.rounding)); - // UI_SetNext(FloatingPos, VEC2(0, thumb_offset)); - // // UI_SetNext(Anchor, UI_Region_Center); - // UI_SetNext(Anchor, UI_Region_Top); - // UI_SetNext(Flags, UI_BoxFlag_CaptureMouse | UI_BoxFlag_Floating); - // UI_SetNext(Anchor, UI_Region_Top); - // UI_BuildBoxEx(thumb_key); - // } - // UI_PopCp(UI_TopCp()); - // } } - // UI_BuildSpacer(window_padding, Axis_Y); - - // UI_BuildDivider(UI_Px(1, 1), divider_color, Axis_Y); UI_BuildSpacer(header_height, Axis_Y); } } - // UI_PopCp(UI_TopCp()); UI_PopCp(palette_cp); } - UI_Pop(Tag); } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ////////////////////////////// //- Build notifications @@ -7855,21 +6111,14 @@ void V_TickForever(WaveLaneCtx *lane) Vec2 pos = Zi; pos.x = 10; - // pos.y = frame->screen_dims.y * 0.5 - DimsFromRng2(UI_Rect(notifs_key.screen_rect)).y * 0.5; pos.y = 10; - // Vec4 bg = VEC4(0, 0, 0, 0.25); Vec4 bg = VEC4(0, 0, 0, 0); UI_SetNext(Width, UI_Px(width, 0)); - // UI_SetNext(Height, UI_Px(height, 0)); - // UI_SetNext(Width, UI_Grow(0.9, 0)); - // UI_SetNext(Width, UI_Shrink(0, 0)); UI_SetNext(Height, UI_Shrink(0, 0)); - // UI_SetNext(FloatingPos, pos); UI_SetNext(BackgroundColor, bg); UI_SetNext(Rounding, 0); - // UI_SetNext(Flags, UI_BoxFlag_Floating); UI_PushDF(Parent, UI_BuildColumnEx(notifs_key)) { UI_Push(ChildAlignment, UI_Region_Left); @@ -7974,27 +6223,10 @@ void V_TickForever(WaveLaneCtx *lane) } } - - - - - - - - - - - - - - - - ////////////////////////////// //- Build timeline debug UI { - // FIXME: Remove this PERSIST i64 last_timeline_matchup_ns = 0; PERSIST i64 last_timeline_reset_ns = 0; PERSIST f64 timeline_start_tick = 0; @@ -8154,17 +6386,11 @@ void V_TickForever(WaveLaneCtx *lane) } } - ////////////////////////////// //- Build scoreboard UI if (frame->held_buttons[Button_Tab]) { - // UI_Size name_sz = UI_Grow(0.75, 0); - // UI_Size kills_sz = UI_Grow(0.25, 0); - // UI_Size deaths_sz = UI_Grow(0.25, 0); - // UI_Size spacing_sz = UI_Fnt(1, 0); - UI_Size name_sz = UI_Fnt(10, 0); UI_Size kills_sz = UI_Fnt(10, 0); UI_Size deaths_sz = UI_Fnt(10, 0); @@ -8334,15 +6560,10 @@ void V_TickForever(WaveLaneCtx *lane) UI_PushDF(FontSize, 12) UI_PushDF(Width, UI_Shrink(4, 1)) UI_PushDF(Height, UI_Shrink(1, 1)) - // UI_PushDF(BackgroundColor, Color_Black) UI_PushDF(ChildAlignment, UI_Region_Center) UI_PushDF(Opacity, 0.95) UI_PushDF(Rounding, UI_Rgrow(0.25)) - // UI_PushDF(BackgroundColor, Color_Cyan) - // UI_PushDF(FontSize, UI_Top(FontSize) * 1.5) UI_PushDF(FontSize, 16) - // UI_PushDF(TextColor, SrgbFromHsv(32, 1, 1)) - // UI_PushDF(TextColor, SrgbFromHsv(32, 0.75, 1)) UI_PushDF(TextColor, VEC4(0.95, 0.95, 0.95, 1)) UI_PushDF(Parent, vis_screen_overlay_box) UI_PushDF(Anchor, UI_Region_Bottom) @@ -8357,9 +6578,7 @@ void V_TickForever(WaveLaneCtx *lane) if (guy->is_guy && name.len > 0) { String display_text = name; - Vec2 guy_world_pos = guy->xf.t; - // guy_world_pos.y -= UI_Top(FontSize) * 0.01; guy_world_pos.y -= 0.25; Vec2 guy_screen_pos = MulAffineVec2(frame->af.world_to_screen, guy_world_pos); @@ -8368,10 +6587,8 @@ void V_TickForever(WaveLaneCtx *lane) text_pos.x = guy_screen_pos.x; text_pos.y = guy_screen_pos.y; - // UI_PushDF(Text, name) { // Name box - // UI_SetNext(TextColor, Color_Transparent); UI_SetNext(FloatingPos, text_pos); UI_PushDF(Parent, UI_BuildBox()) UI_PushDF(Text, display_text) @@ -8485,32 +6702,6 @@ void V_TickForever(WaveLaneCtx *lane) } } - // if (V_CountVisCmds(V_CmdKind_reset_world)) - // if (V_CountVisCmds(V_CmdKind_spawn)) - // { - // // Reset world - // Vec2 guy_pos = VEC2(5, 0); - // if (kind == V_CmdKind_reset_world) - // { - // P_Msg *msg = P_PushMsg(P_MsgKind_ResetWorld, Zstr); - // } - // else - // { - // guy_pos = frame->world_cursor; - // } - // // Spawn guy - // { - // P_Msg *msg = P_PushMsg(P_MsgKind_EntEdit, Zstr); - // P_Ent *ent = &cmd->ent; - // *ent = P_NilEnt; - // ent->key = V.guy_key; - // ent->af = AffineFromTranslation(guy_pos); - // ent->is_guy = 1; - // ent->has_weapon = 1; - // ent->exists = 1; - // } - // } - if (V_CountVisCmds(V_CmdKind_reset_world)) { P_Msg *msg = P_PushMsg(P_MsgKind_ResetWorld, Zstr); @@ -8558,14 +6749,6 @@ void V_TickForever(WaveLaneCtx *lane) } } - // if (V_CountVisCmds(V_CmdKind_save_level)) - // { - // if (frame->is_editing) - // { - // P_Msg *msg = P_PushMsg(P_MsgKind_SaveWorld, Zstr); - // } - // } - if (V_CountVisCmds(V_CmdKind_clear_particles)) { frame->should_clear_particles = 1; @@ -8650,22 +6833,6 @@ void V_TickForever(WaveLaneCtx *lane) .name = StringF(frame->arena, "Screen target [%F]", FmtSint(frame->tick)) ); - // Profiler graph - // if (should_draw_profiler_graph) - // { - // frame->profiler_graph = G_PushTexture2D( - // cl, gpu_frame_arena, - // G_TextureLayout_Family, - // G_Format_R16G16B16A16_Float, - // .flags = G_MemoryFlag_AllowTextureRW, - // .name = StringF(frame->arena, "Profiler graph [%F]", FmtSint(frame->tick)) - // ); - // { - // Rng2 uv = RNG2(VEC2(0, 0), VEC2(1, 1)); - // UI_SetRawTexture(profiler_graph_box, frame->profiler_graph, uv); - // } - // } - // Albedo texture frame->albedo = G_PushTexture2D( cl, gpu_frame_arena, @@ -8775,15 +6942,6 @@ void V_TickForever(WaveLaneCtx *lane) G_ProfZoneDF(cl, "Init") { - // Build profiler graph - if (should_draw_profiler_graph) - { - G_Compute2D(cl, V_BuildProfilerGraphCS, frame->profiler_graph_dims); - } - - // Prepare shade - G_Compute2D(cl, V_PrepareShadeCS, frame->shade_dims); - // Prepare cells G_Compute2D(cl, V_PrepareCellsCS, cells_dims); @@ -8876,19 +7034,6 @@ void V_TickForever(WaveLaneCtx *lane) G_Sync(cl); - ////////////////////////////// - //- Shading pass - - // TODO: Remove this - - G_ProfZoneDF(cl, "Shade") - if (0) - { - G_Compute2D(cl, V_ShadeCS, frame->shade_dims); - } - - G_Sync(cl); - ////////////////////////////// //- Composite pass diff --git a/src/pp/pp_vis/pp_vis_core.h b/src/pp/pp_vis/pp_vis_core.h index 9add753d..586d9ebe 100644 --- a/src/pp/pp_vis/pp_vis_core.h +++ b/src/pp/pp_vis/pp_vis_core.h @@ -297,7 +297,6 @@ Struct(V_ZoneTrack) V_Zone *open_zone; }; - Struct(V_Profiler) { b32 is_showing; @@ -469,10 +468,6 @@ Struct(V_Ctx) V_ZoneTrack *first_zone_track; V_ZoneTrack *last_zone_track; - - - - P_NetVarState nvars; V_Panel *root_panel; @@ -484,10 +479,6 @@ Struct(V_Ctx) P_Control queued_pp_control; - - - - i64 text_input_ns; i64 connect_try_ns; @@ -506,10 +497,6 @@ Struct(V_Ctx) Atomic32 shutdown; Fence shutdown_complete; - Vec2 profiler_graph_dims; - u64 profiler_frame_seq; - V_ProfilerFrame *profiler_frames; - f64 smooth_frame_time_seconds; i64 cur_frame_tick; diff --git a/src/pp/pp_vis/pp_vis_gpu.g b/src/pp/pp_vis/pp_vis_gpu.g index da1bdb57..3964b5ef 100644 --- a/src/pp/pp_vis/pp_vis_gpu.g +++ b/src/pp/pp_vis/pp_vis_gpu.g @@ -29,33 +29,19 @@ Vec4 V_ColorFromParticleDesc(V_ParticleDesc desc, u32 particle_idx, f32 alive_se { if (AnyBit(desc.flags, V_ParticleFlag_GasBlend)) { - // f32 t = saturate(density / 10.0); - // f32 t = smoothstep(-10, 32, density); f32 t = smoothstep(-10, 50, density); - // f32 t = smoothstep(0, 2, (f32)density); - result.a += (1.0 - result.a) * (t); } - else if (desc.kind == V_ParticleKind_BloodTrail) + else if (AnyBit(desc.flags, V_ParticleFlag_LiquidBlend)) { - // f32 t = (f32)density / 5; - // t = pow(t, 2); - // t = saturate(t); - // result.rgb *= 1.0 - (t * 0.9); - f32 t = (f32)density / 10; - // t = smoothstep(-10, 10, t); - // t = smoothstep(-5, 5, t); t = smoothstep(-50, 50, t); - // result.rgb *= 1.0 - (t * 0.9); - - // result.a = t; result.a += (1.0 - result.a) * (t); } } - result.rgb = result.rgb + (rand_color - 0.5) * 0.05; + // Apply lifetime fade if (desc.flags & V_ParticleFlag_FadeLifetime && desc.lifetime_min < Inf && alive_seconds > 0) { f32 lifetime = V_LifetimeFromParticleDesc(desc, particle_idx); @@ -63,71 +49,12 @@ Vec4 V_ColorFromParticleDesc(V_ParticleDesc desc, u32 particle_idx, f32 alive_se f32 v = lifetime_complete * lifetime_complete; result.a *= 1.0 - v; } - - - - - - // 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; } -//////////////////////////////////////////////////////////// -//~ Build profiler graph - -ComputeShader(V_BuildProfilerGraphCS) -{ - V_SharedFrame frame = G_Deref(V_GpuReg_Frame, StructuredBuffer)[0]; - RWTexture2D graph = G_Deref(frame.profiler_graph, RWTexture2D); - StructuredBuffer profiler_frames = G_Deref(frame.profiler_frames, StructuredBuffer); - - Vec2 graph_dims = frame.profiler_graph_dims; - u32 thread_id = SV_DispatchThreadID.x; - if (thread_id <= frame.profiler_frame_seq && thread_id < graph_dims.x) - { - - Vec2 graph_pos = SV_DispatchThreadID + 0.5; - graph_pos.x = graph_dims.x - graph_pos.x; - - u64 frame_seq = (frame.profiler_frame_seq - thread_id); - u64 frame_idx = frame_seq % V_ProfilerFramesCap; - V_ProfilerFrame prof_frame = profiler_frames[frame_idx]; - - Vec4 color = Color_Red; - color.g = Norm24(MixU64(frame_seq)); - graph[graph_pos] = color; - } -} - //////////////////////////////////////////////////////////// //~ Prepare frame -//- Prepare shade -ComputeShader(V_PrepareShadeCS) -{ - V_SharedFrame frame = G_Deref(V_GpuReg_Frame, StructuredBuffer)[0]; - RWTexture2D shade = G_Deref(frame.shade, RWTexture2D); - Vec2 shade_pos = SV_DispatchThreadID + 0.5; - if (all(shade_pos < G_Count2D(shade))) - { - // Clear shade - shade[shade_pos] = 0; - } -} - //- Prepare cells ComputeShader(V_PrepareCellsCS) { @@ -209,7 +136,6 @@ ComputeShader(V_PrepareCellsCS) } else { - // f32 dry_rate = saturate(frame.dt * 0.1); f32 dry_rate = saturate(frame.dt * 0.2); Vec4 before_stain = stains[cell_pos]; @@ -728,10 +654,6 @@ ComputeShader(V_SimParticlesCS) } f32 rand_falloff = Norm16(seed0 >> 48); - // f32 falloff = saturate(lerp(1, 2, rand_falloff) * frame.dt); - // f32 falloff = saturate(lerp(10, 20, rand_falloff * frame.dt)); - // f32 falloff = saturate(lerp(5, 10, rand_falloff * frame.dt)); - // f32 falloff = 20 * frame.dt; f32 falloff = V_FalloffFromParticleDesc(desc, particle_idx) * frame.dt; particle.velocity *= 1.0f - falloff; @@ -752,44 +674,6 @@ ComputeShader(V_SimParticlesCS) } } -//////////////////////////////////////////////////////////// -//~ Shade - -// TODO: Remove this - -ComputeShader(V_ShadeCS) -{ - V_SharedFrame frame = G_Deref(V_GpuReg_Frame, StructuredBuffer)[0]; - SamplerState sampler = G_Deref(frame.basic_samplers[G_BasicSamplerKind_PointClamp], SamplerState); - Texture2D tiles = G_Deref(frame.tiles, Texture2D); - Texture2D albedo_tex = G_Deref(frame.albedo, Texture2D); - RWTexture2D shade_tex = G_Deref(frame.shade, RWTexture2D); - Texture2D drynesses = G_Deref(frame.drynesses, Texture2D); - - Vec2 shade_pos = SV_DispatchThreadID + 0.5; - Vec2 world_pos = mul(frame.af.shade_to_world, Vec3(shade_pos, 1)); - Vec2 cell_pos = mul(frame.af.world_to_cell, Vec3(world_pos, 1)); - Vec2 tile_pos = mul(frame.af.world_to_tile, Vec3(world_pos, 1)); - - P_TileKind tile = tiles[tile_pos]; - - Vec2 half_world_dims = Vec2(P_WorldPitch, P_WorldPitch) * 0.5; - b32 is_in_world = IsInside(cell_pos, P_WorldCellsDims); - - ////////////////////////////// - //- Compute result - - Vec4 result = 0; - - ////////////////////////////// - //- Write result - - if (all(shade_pos < G_Count2D(shade_tex))) - { - shade_tex[shade_pos] = result; - } -} - //////////////////////////////////////////////////////////// //~ Composite @@ -868,16 +752,6 @@ ComputeShader(V_CompositeCS) Vec4 world_color = 0; if (is_in_world) { - ////////////////////////////// - //- Shade color - - Vec4 shade_color = 0; - // if (all(shade_pos >= Vec2(0, 0)) && all(shade_pos < countof(shade_tex))) - // { - // Vec2 shade_uv = shade_pos / countof(shade_tex); - // shade_color = shade_tex.SampleLevel(sampler, shade_uv, 0); - // } - ////////////////////////////// //- Tile @@ -934,18 +808,6 @@ ComputeShader(V_CompositeCS) Vec4 albedo_tex_color = albedo_tex[screen_pos]; - - - - - - - - - - - - ////////////////////////////// //- Particles / stains @@ -997,61 +859,6 @@ 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 cells = G_Deref(frame.particle_cells[layer], Texture2D); - // Texture2D densities = G_Deref(frame.particle_densities[layer], Texture2D); - // 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_ColorFromParticleDesc(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; - // } - - - - ////////////////////////////// //- Tile shadow @@ -1083,12 +890,8 @@ ComputeShader(V_CompositeCS) world_color = BlendPremul(stain_color, world_color); // Blend ground stain world_color = BlendPremul(ground_particle_color, world_color); // Blend ground particle - // TODO: Blend shadows over tex? + // TODO: Blend shadows over albedo? world_color = BlendPremul(tile_shadow_color, world_color); // Blend shadow - // if (tile_shadow_color.a != 0) - // { - // world_color.rgb *= 0.5; // Blend shadow - // } } world_color = BlendPremul(albedo_tex_color, world_color); if (tile_is_wall) @@ -1098,26 +901,6 @@ ComputeShader(V_CompositeCS) world_color = BlendPremul(ground_particle_color, world_color); // Blend wall particle } world_color = BlendPremul(air_particle_color, world_color); // Blend air particle - - - - // // world_color = BlendPremul(shade_color, world_color); - // world_color = BlendPremul(stain_particle_color, world_color); - // world_color = BlendPremul(ground_particle_color, world_color); - // if (!tile_is_wall) - // { - // world_color = BlendPremul(tile_color, world_color); // Blend ground tile - // world_color = BlendPremul(stain_particle_color, world_color); // Blend ground stain - // world_color = BlendPremul(ground_particle_color, world_color); // Blend ground particle - // } - // world_color = BlendPremul(albedo_tex_color, world_color); - // if (tile_is_wall) - // { - // world_color = BlendPremul(tile_color, world_color); // Blend wall tile - // world_color = BlendPremul(stain_particle_color, world_color); // Blend wall stain - // world_color = BlendPremul(ground_particle_color, world_color); // Blend wall particle - // } - // world_color = BlendPremul(air_particle_color, world_color); } ////////////////////////////// @@ -1157,11 +940,6 @@ ComputeShader(V_CompositeCS) dist = min(dist, screen_selection.p1.y - screen_pos.y); dist = -dist; - // if (dist >= -half_thickness && dist <= half_thickness) - // { - // selection_color = border_color; - // } - // else { if ( tile_pos.x >= tile_selection.p0.x && diff --git a/src/pp/pp_vis/pp_vis_gpu.gh b/src/pp/pp_vis/pp_vis_gpu.gh index 4e8fc411..b8e2eb69 100644 --- a/src/pp/pp_vis/pp_vis_gpu.gh +++ b/src/pp/pp_vis/pp_vis_gpu.gh @@ -51,11 +51,7 @@ Vec4 V_ColorFromParticleDesc(V_ParticleDesc desc, u32 particle_idx, f32 alive_se //////////////////////////////////////////////////////////// //~ Shaders -//- Build profiler graph -ComputeShader(V_BuildProfilerGraphCS); - //- Prepare frame -ComputeShader(V_PrepareShadeCS); ComputeShader(V_PrepareCellsCS); ComputeShader(V_ClearParticlesCS); @@ -71,9 +67,6 @@ PixelShader(V_QuadPS, V_QuadPSOutput, V_QuadPSInput input); ComputeShader(V_EmitParticlesCS); ComputeShader(V_SimParticlesCS); -//- Shade -ComputeShader(V_ShadeCS); - //- Composite ComputeShader(V_CompositeCS); diff --git a/src/pp/pp_vis/pp_vis_shared.cgh b/src/pp/pp_vis/pp_vis_shared.cgh index c8a930b8..8c25b8ee 100644 --- a/src/pp/pp_vis/pp_vis_shared.cgh +++ b/src/pp/pp_vis/pp_vis_shared.cgh @@ -34,9 +34,10 @@ Enum(V_ParticleFlag) V_ParticleFlag_StainWhenPruned = (1 << 1), V_ParticleFlag_NoReflect = (1 << 2), V_ParticleFlag_OnlyCollideWithWalls = (1 << 3), - V_ParticleFlag_GasBlend = (1 << 4), - V_ParticleFlag_FadeLifetime = (1 << 5), - V_ParticleFlag_HaltOnCollision = (1 << 6), + V_ParticleFlag_LiquidBlend = (1 << 4), + V_ParticleFlag_GasBlend = (1 << 5), + V_ParticleFlag_FadeLifetime = (1 << 6), + V_ParticleFlag_HaltOnCollision = (1 << 7), }; Enum(V_ParticleLayer) @@ -49,157 +50,157 @@ Enum(V_ParticleLayer) }; // NOTE: Higher particle enum values take priority over lower within the same layer ones when drawing / staining -#define V_ParticlesXList(X) \ - X( \ - /* Name */ None, \ - /* Flags */ V_ParticleFlag_None, \ - /* Layer */ V_ParticleLayer_Ground, \ - /* Stain rate, pen chance */ 30, 0, \ - /* Lifetime */ Inf, Inf, \ - /* Falloff */ 0, 0, \ - /* Prune speed threshold */ 0.01, \ - /* Base color */ VEC4(0, 0, 0, 0), \ - /* Dry color factor */ VEC4(1, 1, 1, 1) \ - ) \ - \ - /* Ground particles */ \ - X( \ - /* Name */ BloodTrail, \ - /* Flags */ V_ParticleFlag_NoReflect | V_ParticleFlag_StainWhenPruned, \ - /* Layer */ V_ParticleLayer_Ground, \ - /* Stain rate, pen chance */ 100, 0.25, \ - /* Lifetime */ Inf, Inf, \ - /* Falloff */ 10, 20, \ - /* 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) \ - ) \ - X( \ - /* Name */ Debris, \ - /* Flags */ V_ParticleFlag_StainWhenPruned, \ - /* Layer */ V_ParticleLayer_Mid, \ - /* Stain rate, pen chance */ 0, 0, \ - /* Lifetime */ Inf, Inf, \ - /* Falloff */ 20, 30, \ - /* Prune speed threshold */ 0.1, \ - /* Base color */ VEC4(0.4, 0.3, 0.2, 1), \ - /* Dry color factor */ VEC4(0.2, 0.1, 0.1, 1) \ - ) \ - X( \ +#define V_ParticlesXList(X) \ + X( \ + /* Name */ None, \ + /* Flags */ V_ParticleFlag_None, \ + /* Layer */ V_ParticleLayer_Ground, \ + /* Stain rate, pen chance */ 30, 0, \ + /* Lifetime */ Inf, Inf, \ + /* Falloff */ 0, 0, \ + /* Prune speed threshold */ 0.01, \ + /* Base color */ VEC4(0, 0, 0, 0), \ + /* Dry color factor */ VEC4(1, 1, 1, 1) \ + ) \ + \ + /* Ground particles */ \ + X( \ + /* Name */ BloodTrail, \ + /* Flags */ V_ParticleFlag_LiquidBlend | V_ParticleFlag_NoReflect | V_ParticleFlag_StainWhenPruned, \ + /* Layer */ V_ParticleLayer_Ground, \ + /* Stain rate, pen chance */ 100, 0.25, \ + /* Lifetime */ Inf, Inf, \ + /* Falloff */ 10, 20, \ + /* 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) \ + ) \ + X( \ + /* Name */ Debris, \ + /* Flags */ V_ParticleFlag_StainWhenPruned, \ + /* Layer */ V_ParticleLayer_Mid, \ + /* Stain rate, pen chance */ 0, 0, \ + /* Lifetime */ Inf, Inf, \ + /* Falloff */ 20, 30, \ + /* Prune speed threshold */ 0.1, \ + /* Base color */ VEC4(0.4, 0.3, 0.2, 1), \ + /* Dry color factor */ VEC4(0.2, 0.1, 0.1, 1) \ + ) \ + X( \ /* Name */ Fire, \ - /* Flags */ V_ParticleFlag_StainWhenPruned, \ - /* Layer */ V_ParticleLayer_Mid, \ - /* Stain rate, pen chance */ 0, 0, \ - /* Lifetime */ Inf, Inf, \ - /* Falloff */ 10, 20, \ - /* 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 */ HotDebris, \ - /* Flags */ V_ParticleFlag_StainWhenPruned, \ - /* Layer */ V_ParticleLayer_Mid, \ - /* Stain rate, pen chance */ 0, 0, \ - /* Lifetime */ Inf, Inf, \ - /* Falloff */ 20, 30, \ - /* Prune speed threshold */ 0.01, \ - /* Base color */ VEC4(2, 0.5, 0, 1), \ - /* Dry color factor */ VEC4(0.2, 0.1, 0.1, 1) \ - ) \ - X( \ - /* Name */ Spark, \ - /* Flags */ V_ParticleFlag_None, \ - /* Layer */ V_ParticleLayer_Mid, \ - /* Stain rate, pen chance */ 0, 0, \ - /* Lifetime */ 0.2, 0.3, \ - /* Falloff */ 10, 20, \ - /* Prune speed threshold */ 0.1, \ - /* Base color */ VEC4(2, 0.5, 0, 1), \ - /* Dry color factor */ VEC4(0.2, 0.1, 0.0, 1) \ - ) \ - \ - /* Air particles */ \ - X( \ - /* Name */ BulletSmoke, \ - /* Flags */ V_ParticleFlag_OnlyCollideWithWalls | V_ParticleFlag_GasBlend | V_ParticleFlag_FadeLifetime, \ - /* Layer */ V_ParticleLayer_Mid, \ - /* Stain rate, pen chance */ 0, 0, \ - /* Lifetime */ 0.075, 0.2, \ - /* Falloff */ 0, 0, \ - /* Prune speed threshold */ 0.00, \ - /* Base color */ VEC4(0.8, 0.6, 0.2, 0.005), \ - /* Dry color factor */ VEC4(1, 1, 1, 1) \ - ) \ - X( \ - /* Name */ MuzzleWide, \ - /* Flags */ V_ParticleFlag_None, \ - /* Layer */ V_ParticleLayer_Air, \ - /* Stain rate, pen chance */ 0, 0, \ - /* Lifetime */ 0.0, .05, \ - /* Falloff */ 0, 0, \ - /* Prune speed threshold */ 0, \ - /* Base color */ VEC4(10, 3.5, 0, 1), \ - /* Dry color factor */ VEC4(0.2, 0.1, 0.0, 1) \ - ) \ - X( \ - /* Name */ MuzzleNarrow, \ - /* Flags */ V_ParticleFlag_None, \ - /* Layer */ V_ParticleLayer_Air, \ - /* Stain rate, pen chance */ 0, 0, \ - /* Lifetime */ 0.0, 0.05, \ - /* Falloff */ 0, 0, \ - /* Prune speed threshold */ 0, \ - /* Base color */ VEC4(10, 3.5, 0, 1), \ - /* Dry color factor */ VEC4(0.2, 0.1, 0.0, 1) \ - ) \ - X( \ - /* Name */ BulletTrail, \ - /* Flags */ V_ParticleFlag_OnlyCollideWithWalls | V_ParticleFlag_FadeLifetime, \ - /* Layer */ V_ParticleLayer_Air, \ - /* Stain rate, pen chance */ 0, 0, \ - /* Lifetime */ 0.075, 0.075, \ - /* Falloff */ 0, 0, \ - /* Prune speed threshold */ 0, \ - /* Base color */ VEC4(3, 1.5, 0, 1), \ - /* Dry color factor */ VEC4(0.2, 0.1, 0.0, 1) \ - ) \ - X( \ - /* Name */ Bullet, \ - /* Flags */ V_ParticleFlag_NoReflect | V_ParticleFlag_HaltOnCollision, \ - /* Layer */ V_ParticleLayer_Air, \ - /* Stain rate, pen chance */ 0, 0, \ - /* Lifetime */ Inf, Inf, \ - /* Falloff */ 0, 0, \ - /* Prune speed threshold */ 0.01, \ - /* Base color */ VEC4(5, 1.75, 0.75, 1), \ - /* Dry color factor */ VEC4(0.2, 0.1, 0.0, 1) \ - ) \ - X( \ - /* Name */ WallDust, \ - /* Flags */ V_ParticleFlag_OnlyCollideWithWalls | V_ParticleFlag_GasBlend | V_ParticleFlag_FadeLifetime, \ - /* Layer */ V_ParticleLayer_Air, \ - /* Stain rate, pen chance */ 0, 0, \ - /* Lifetime */ 0.1, 0.25, \ - /* Falloff */ 10, 20, \ - /* Prune speed threshold */ 0.01, \ - /* Base color */ VEC4(0.5, 0.5, 0.5, 0.35), \ - /* Dry color factor */ VEC4(1, 1, 1, 1) \ - ) \ - \ - /* Test particles */ \ - X( \ - /* Name */ Test, \ - /* Flags */ V_ParticleFlag_None, \ - /* Layer */ V_ParticleLayer_Mid, \ - /* Stain rate, pen chance */ 0, 0, \ - /* Lifetime */ Inf, Inf, \ - /* Falloff */ 0, 0, \ - /* Prune speed threshold */ 0.01, \ - /* Base color */ VEC4(1, 1, 0, 1), \ - /* Dry color factor */ VEC4(1, 1, 1, 1) \ - ) \ -/* ----------------------------------------------------------------------------------------------------------------------------------- */ + /* Flags */ V_ParticleFlag_StainWhenPruned, \ + /* Layer */ V_ParticleLayer_Mid, \ + /* Stain rate, pen chance */ 0, 0, \ + /* Lifetime */ Inf, Inf, \ + /* Falloff */ 10, 20, \ + /* 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 */ HotDebris, \ + /* Flags */ V_ParticleFlag_StainWhenPruned, \ + /* Layer */ V_ParticleLayer_Mid, \ + /* Stain rate, pen chance */ 0, 0, \ + /* Lifetime */ Inf, Inf, \ + /* Falloff */ 20, 30, \ + /* Prune speed threshold */ 0.01, \ + /* Base color */ VEC4(2, 0.5, 0, 1), \ + /* Dry color factor */ VEC4(0.2, 0.1, 0.1, 1) \ + ) \ + X( \ + /* Name */ Spark, \ + /* Flags */ V_ParticleFlag_None, \ + /* Layer */ V_ParticleLayer_Mid, \ + /* Stain rate, pen chance */ 0, 0, \ + /* Lifetime */ 0.2, 0.3, \ + /* Falloff */ 10, 20, \ + /* Prune speed threshold */ 0.1, \ + /* Base color */ VEC4(2, 0.5, 0, 1), \ + /* Dry color factor */ VEC4(0.2, 0.1, 0.0, 1) \ + ) \ + \ + /* Air particles */ \ + X( \ + /* Name */ BulletSmoke, \ + /* Flags */ V_ParticleFlag_OnlyCollideWithWalls | V_ParticleFlag_GasBlend | V_ParticleFlag_FadeLifetime, \ + /* Layer */ V_ParticleLayer_Mid, \ + /* Stain rate, pen chance */ 0, 0, \ + /* Lifetime */ 0.075, 0.2, \ + /* Falloff */ 0, 0, \ + /* Prune speed threshold */ 0.00, \ + /* Base color */ VEC4(0.8, 0.6, 0.2, 0.005), \ + /* Dry color factor */ VEC4(1, 1, 1, 1) \ + ) \ + X( \ + /* Name */ MuzzleWide, \ + /* Flags */ V_ParticleFlag_None, \ + /* Layer */ V_ParticleLayer_Air, \ + /* Stain rate, pen chance */ 0, 0, \ + /* Lifetime */ 0.0, .05, \ + /* Falloff */ 0, 0, \ + /* Prune speed threshold */ 0, \ + /* Base color */ VEC4(10, 3.5, 0, 1), \ + /* Dry color factor */ VEC4(0.2, 0.1, 0.0, 1) \ + ) \ + X( \ + /* Name */ MuzzleNarrow, \ + /* Flags */ V_ParticleFlag_None, \ + /* Layer */ V_ParticleLayer_Air, \ + /* Stain rate, pen chance */ 0, 0, \ + /* Lifetime */ 0.0, 0.05, \ + /* Falloff */ 0, 0, \ + /* Prune speed threshold */ 0, \ + /* Base color */ VEC4(10, 3.5, 0, 1), \ + /* Dry color factor */ VEC4(0.2, 0.1, 0.0, 1) \ + ) \ + X( \ + /* Name */ BulletTrail, \ + /* Flags */ V_ParticleFlag_OnlyCollideWithWalls | V_ParticleFlag_FadeLifetime, \ + /* Layer */ V_ParticleLayer_Air, \ + /* Stain rate, pen chance */ 0, 0, \ + /* Lifetime */ 0.075, 0.075, \ + /* Falloff */ 0, 0, \ + /* Prune speed threshold */ 0, \ + /* Base color */ VEC4(3, 1.5, 0, 1), \ + /* Dry color factor */ VEC4(0.2, 0.1, 0.0, 1) \ + ) \ + X( \ + /* Name */ Bullet, \ + /* Flags */ V_ParticleFlag_NoReflect | V_ParticleFlag_HaltOnCollision, \ + /* Layer */ V_ParticleLayer_Air, \ + /* Stain rate, pen chance */ 0, 0, \ + /* Lifetime */ Inf, Inf, \ + /* Falloff */ 0, 0, \ + /* Prune speed threshold */ 0.01, \ + /* Base color */ VEC4(5, 1.75, 0.75, 1), \ + /* Dry color factor */ VEC4(0.2, 0.1, 0.0, 1) \ + ) \ + X( \ + /* Name */ WallDust, \ + /* Flags */ V_ParticleFlag_OnlyCollideWithWalls | V_ParticleFlag_GasBlend | V_ParticleFlag_FadeLifetime, \ + /* Layer */ V_ParticleLayer_Air, \ + /* Stain rate, pen chance */ 0, 0, \ + /* Lifetime */ 0.1, 0.25, \ + /* Falloff */ 10, 20, \ + /* Prune speed threshold */ 0.01, \ + /* Base color */ VEC4(0.5, 0.5, 0.5, 0.35), \ + /* Dry color factor */ VEC4(1, 1, 1, 1) \ + ) \ + \ + /* Test particles */ \ + X( \ + /* Name */ Test, \ + /* Flags */ V_ParticleFlag_None, \ + /* Layer */ V_ParticleLayer_Mid, \ + /* Stain rate, pen chance */ 0, 0, \ + /* Lifetime */ Inf, Inf, \ + /* Falloff */ 0, 0, \ + /* Prune speed threshold */ 0.01, \ + /* Base color */ VEC4(1, 1, 0, 1), \ + /* Dry color factor */ VEC4(1, 1, 1, 1) \ + ) \ +/* -------------------------------------------------------------------------------------------------------------------------------------- */ Enum(V_ParticleKind) { @@ -226,7 +227,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 + u32 prev_occluder; f32 alive_seconds; f32 stain_accum; u32 cells_count; @@ -285,33 +286,6 @@ Struct(V_DVert) Vec4 color_lin; }; -//////////////////////////////////////////////////////////// -//~ Profiler types - -#define V_ProfilerFramesCap Kibi(16) - -#define V_ProfilerZonesXList(X) \ - X(None, Color_Cyan) \ -/* ---------------------------- */ - -Enum(V_ProfilerZone) -{ - #define X(name, ...) CAT(V_ProfilerZone_,name), - V_ProfilerZonesXList(X) - #undef X - V_ProfilerZone_COUNT -}; - -Struct(V_ProfilerZoneInfo) -{ - f32 elapsed_seconds; -}; - -Struct(V_ProfilerFrame) -{ - V_ProfilerZoneInfo zones[V_ProfilerZone_COUNT]; -}; - //////////////////////////////////////////////////////////// //~ State types @@ -456,12 +430,6 @@ Struct(V_SharedFrame) G_SamplerRef basic_samplers[G_BasicSamplerKind_COUNT]; - u64 profiler_frame_seq; - G_BufferRef profiler_frames; - - Vec2 profiler_graph_dims; - G_TextureRef profiler_graph; - V_TileDesc tile_descs[P_TileKind_COUNT]; G_TextureRef tiles; diff --git a/src/settings/settings.c b/src/settings/settings.c deleted file mode 100644 index a5470859..00000000 --- a/src/settings/settings.c +++ /dev/null @@ -1,184 +0,0 @@ -//////////////////////////////////////////////////////////// -//~ Serialize - -String SETTINGS_StringFromWindowSettings(Arena *arena, const PLT_WindowSettings *settings) -{ - String minimized = settings->flags & PLT_WindowSettingsFlag_Minimized ? Lit("true") : Lit("false"); - String maximized = settings->flags & PLT_WindowSettingsFlag_Maximized ? Lit("true") : Lit("false"); - String fullscreen = settings->flags & PLT_WindowSettingsFlag_Fullscreen ? Lit("true") : Lit("false"); - i32 x = settings->floating_x; - i32 y = settings->floating_y; - i32 width = settings->floating_width; - i32 height = settings->floating_height; - - String fmt = Lit( - "{\n" - " \"window\": {\n" - " \"minimized\": %F,\n" - " \"maximized\": %F,\n" - " \"fullscreen\": %F,\n" - " \"x\": %F,\n" - " \"y\": %F,\n" - " \"width\": %F,\n" - " \"height\": %F\n" - " }\n" - "}\n" - ); - - String formatted = FormatString( - , - fmt, - FmtString(minimized), - FmtString(maximized), - FmtString(fullscreen), - FmtSint(x), - FmtSint(y), - FmtSint(width), - FmtSint(height) - ); - - return formatted; -} - -//////////////////////////////////////////////////////////// -//~ Deserialize - -PLT_WindowSettings *SETTINGS_WindowSettingsFromString(Arena *arena, String src, String *error_out) -{ - TempArena scratch = BeginScratch(arena); - - String error = ZI; - JSON_Error json_error = ZI; - - PLT_WindowSettings *settings = PushStruct(arena, PLT_WindowSettings); - JSON_Result parse_result = JSON_BlobFromString(scratch.arena, src); - - if (parse_result.errors.count > 0) - { - json_error = *parse_result.errors.first; - goto abort; - } - - JSON_Blob *root = parse_result.root; - if (!root) - { - error = Lit("Root object not found."); - goto abort; - } - - JSON_Blob *window = root->child_first; - if (!window || window->type != JSON_Type_Object || !MatchString(window->key, Lit("window"))) - { - error = Lit("\"window\" object not found"); - goto abort; - } - - b32 found_maximized = 0; - b32 found_fullscreen = 0; - b32 found_x = 0; - b32 found_y = 0; - b32 found_width = 0; - b32 found_height = 0; - for (JSON_Blob *child = window->child_first; child; child = child->next) - { - String key = child->key; - - if (MatchString(key, Lit("maximized"))) - { - if (child->type != JSON_Type_Bool) - { - error = Lit("Expected boolean for \"maximized\""); - goto abort; - } - if (child->value.boolean) - { - settings->flags |= PLT_WindowSettingsFlag_Maximized; - } - found_maximized = 1; - } - else if (MatchString(key, Lit("fullscreen"))) - { - if (child->type != JSON_Type_Bool) - { - error = Lit("Expected boolean for \"fulscreen\""); - goto abort; - } - if (child->value.boolean) - { - settings->flags |= PLT_WindowSettingsFlag_Fullscreen; - } - found_fullscreen = 1; - } - else if (MatchString(key, Lit("x"))) - { - if (child->type != JSON_Type_Number) - { - error = Lit("Expected number for \"x\""); - goto abort; - } - settings->floating_x = RoundF32ToI32(child->value.number); - found_x = 1; - } - else if (MatchString(key, Lit("y"))) - { - if (child->type != JSON_Type_Number) - { - error = Lit("Expected number for \"y\""); - goto abort; - } - settings->floating_y = RoundF32ToI32(child->value.number); - found_y = 1; - } - else if (MatchString(key, Lit("width"))) - { - if (child->type != JSON_Type_Number) - { - error = Lit("Expected number for \"width\""); - goto abort; - } - settings->floating_width = RoundF32ToI32(child->value.number); - found_width = 1; - } - else if (MatchString(key, Lit("height"))) - { - if (child->type != JSON_Type_Number) - { - error = Lit("Expected number for \"height\""); - goto abort; - } - settings->floating_height = RoundF32ToI32(child->value.number); - found_height = 1; - } - } - - if (!found_maximized) { error = Lit("Missing \"maximized\""); goto abort; } - if (!found_fullscreen) { error = Lit("Missing \"fullscreen\""); goto abort; } - if (!found_x) { error = Lit("Missing \"x\""); goto abort; } - if (!found_y) { error = Lit("Missing \"y\""); goto abort; } - if (!found_width) { error = Lit("Missing \"width\""); goto abort; } - if (!found_height) { error = Lit("Missing \"height\""); goto abort; } - - abort: - - if (error_out && (error.len > 0 || json_error.msg.len > 0)) - { - if (json_error.msg.len > 0) - { - *error_out = StringF( - arena, - Lit("%F\n(%F:%F)"), - FmtString(json_error.msg), - FmtUint(json_error.start), - FmtUint(json_error.end) - ); - } - else - { - *error_out = PushString(arena, error); - } - } - - EndScratch(scratch); - - return settings; -} diff --git a/src/settings/settings.h b/src/settings/settings.h deleted file mode 100644 index 9921c5e3..00000000 --- a/src/settings/settings.h +++ /dev/null @@ -1,2 +0,0 @@ -String SETTINGS_StringFromWindowSettings(Arena *arena, const PLT_WindowSettings *settings); -PLT_WindowSettings *SETTINGS_WindowSettingsFromString(Arena *arena, String src, String *error_out); diff --git a/src/settings/settings.lay b/src/settings/settings.lay deleted file mode 100644 index a101cb5b..00000000 --- a/src/settings/settings.lay +++ /dev/null @@ -1,18 +0,0 @@ -@Layer settings - -////////////////////////////// -//- Dependencies - -@Dep base -@Dep platform -@Dep json - -////////////////////////////// -//- Api - -@IncludeC settings_core.h - -////////////////////////////// -//- Impl - -@IncludeC settings_core.c