From a89f5b95f334455924a30563250bd34ec59c982d Mon Sep 17 00:00:00 2001 From: Tater Date: Thu, 2 Jan 2025 19:09:36 -0600 Subject: [PATCH] trail speed coloring --- src/engine/shared/tater_variables.h | 1 + src/game/client/components/tclient/trails.cpp | 24 ++++++++++++++----- src/game/client/components/tclient/trails.h | 3 ++- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/engine/shared/tater_variables.h b/src/engine/shared/tater_variables.h index 690126d3727..0913a16f8db 100644 --- a/src/engine/shared/tater_variables.h +++ b/src/engine/shared/tater_variables.h @@ -178,6 +178,7 @@ MACRO_CONFIG_INT(ClTeeTrailUseTeeColor, tc_tee_trail_use_tee_color, 1, 0, 1, CFG MACRO_CONFIG_INT(ClTeeTrailTaper, tc_tee_trail_taper, 1, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Taper tee trail over length") MACRO_CONFIG_INT(ClTeeTrailFade, tc_tee_trail_fade, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Fade trail alpha over length") MACRO_CONFIG_INT(ClTeeTrailRainbow, tc_tee_trail_rainbow, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Rainbow tee trails") +MACRO_CONFIG_INT(ClTeeTrailSpeed, tc_tee_trail_speed, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Speed color tee trails") diff --git a/src/game/client/components/tclient/trails.cpp b/src/game/client/components/tclient/trails.cpp index 6d2e1991747..3abd988f5bd 100644 --- a/src/game/client/components/tclient/trails.cpp +++ b/src/game/client/components/tclient/trails.cpp @@ -105,13 +105,8 @@ void CTrails::OnRender() vec2 CurServerPos = vec2(GameClient()->m_Snap.m_aCharacters[ClientId].m_Cur.m_X, GameClient()->m_Snap.m_aCharacters[ClientId].m_Cur.m_Y); vec2 PrevServerPos = vec2(GameClient()->m_Snap.m_aCharacters[ClientId].m_Prev.m_X, GameClient()->m_Snap.m_aCharacters[ClientId].m_Prev.m_Y); - m_PositionHistory[ClientId][GameTick % 200] = mix(PrevServerPos, CurServerPos, Client()->IntraGameTick(g_Config.m_ClDummy)); m_PositionTick[ClientId][GameTick % 200] = GameTick; - // Slightly messy way to make the position of our player accurate without ugly logic in the loop - vec2 SavedTempPredPos = GameClient()->m_aClients[ClientId].m_aPredPos[PredTick % 200]; - GameClient()->m_aClients[ClientId].m_aPredPos[PredTick % 200] = GameClient()->m_aClients[ClientId].m_RenderPos; - IGraphics::CLineItem LineItem; bool LineMode = g_Config.m_ClTeeTrailWidth == 0; @@ -152,6 +147,8 @@ void CTrails::OnRender() continue; Part.Pos = m_PositionHistory[ClientId][PosTick % 200]; } + Part.Tick = PosTick; + Part.UnMovedPos = Part.Pos; Trail.push_back(Part); } @@ -166,6 +163,11 @@ void CTrails::OnRender() if((int)Trail.size() < 3) continue; + if(PredictPlayer) + Trail.at(0).Pos = GameClient()->m_aClients[ClientId].m_RenderPos; + else + Trail.at(0).Pos = mix(PrevServerPos, CurServerPos, Client()->IntraGameTick(g_Config.m_ClDummy)); + Trail.at(Trail.size() - 1).Pos = mix(Trail.at(Trail.size() - 1).Pos, Trail.at(Trail.size() - 2).Pos, std::fmod(IntraTick, 1.0f)); // Set progress @@ -188,6 +190,17 @@ void CTrails::OnRender() float Hue = std::fmod(((StartTick - i + 6361 * ClientId) % 1000000) * Cycle, 1.0f); Part.Col = color_cast(ColorHSLA(Hue, 1.0f, 0.5f)); } + if(g_Config.m_ClTeeTrailSpeed) + { + float Speed = 0.0f; + if(i == 0) + Speed = distance(Trail.at(i + 1).UnMovedPos, Trail.at(i).UnMovedPos) / std::abs(Trail.at(i + 1).Tick - Trail.at(i).Tick); + else + Speed = distance(Part.UnMovedPos, Trail.at(i - 1).UnMovedPos) / std::abs(Part.Tick - Trail.at(i - 1).Tick); + float Hue = std::fmod(Speed * 0.05f, 1.0f); + Part.Col = color_cast(ColorHSLA(Hue, 1.0f, 0.5f)); + Part.Col = color_cast(ColorHSLA(65280 * ((int)(Speed * 4.0f) + 1)).UnclampLighting(ColorHSLA::DARKEST_LGT)); + } Part.Width = g_Config.m_ClTeeTrailWidth; if(g_Config.m_ClTeeTrailTaper) @@ -329,7 +342,6 @@ void CTrails::OnRender() else Graphics()->TrianglesEnd(); - GameClient()->m_aClients[ClientId].m_aPredPos[PredTick % 200] = SavedTempPredPos; m_PositionHistory[ClientId][GameTick % 200] = CurServerPos; } } \ No newline at end of file diff --git a/src/game/client/components/tclient/trails.h b/src/game/client/components/tclient/trails.h index 678899c0cff..5fb60291301 100644 --- a/src/game/client/components/tclient/trails.h +++ b/src/game/client/components/tclient/trails.h @@ -5,6 +5,7 @@ struct STrailPart { vec2 Pos = vec2(0, 0); + vec2 UnMovedPos = vec2(0, 0); ColorRGBA Col = {}; float Alpha = 1.0f; float Width = 0.0f; @@ -13,7 +14,7 @@ struct STrailPart vec2 Bot = vec2(0, 0); bool Flip = false; float Progress = 1.0f; - + int Tick = -1; bool operator==(const STrailPart &Other) const {