@@ -40,6 +40,7 @@ Variable sar_trace_font_size("sar_trace_font_size", "3.0", 0.1, "The size of tex
4040Variable sar_trace_vphys_record (" sar_trace_vphys_record" , " 1" , 0 , 1 , " Record vphysics locations of dynamic entities for analysis.\n " );
4141
4242Variable sar_trace_reveal (" sar_trace_reveal" , " 0" , " Only draw traces until the specified tick. Set to bbox to draw until the bbox tick.\n " );
43+ Variable sar_trace_playback_rate (" sar_trace_playback_rate" , " 0" , " Playback rate of the trace bbox. Loops upon finishing.\n " );
4344
4445Variable sar_trace_bbox_at (" sar_trace_bbox_at" , " -1" , -1 , " Display a player-sized bbox at the given tick.\n " );
4546Variable sar_trace_bbox_use_hover (" sar_trace_bbox_use_hover" , " 0" , 0 , 1 , " Move trace bbox to hovered trace point tick on given trace.\n " );
@@ -828,6 +829,28 @@ ON_EVENT(SESSION_START) {
828829 playerTrace->ClearAll ();
829830}
830831
832+ ON_EVENT (PRE_TICK) {
833+ if (sar_trace_playback_rate.GetFloat () > 0 ) {
834+ playerTrace->Playback ();
835+ }
836+ }
837+
838+ void PlayerTrace::Playback () {
839+ float tick = sar_trace_bbox_at.GetFloat () + sar_trace_playback_rate.GetFloat ();
840+
841+ size_t max_tick = 0 ;
842+ for (auto it = playerTrace->traces .begin (); it != playerTrace->traces .end (); ++it) {
843+ const Trace &trace = it->second ;
844+ max_tick = (std::max)(max_tick, trace.positions [0 ].size ());
845+ max_tick = (std::max)(max_tick, trace.positions [1 ].size ());
846+ }
847+
848+ if ((size_t )tick > max_tick) {
849+ tick = 0 ;
850+ }
851+ sar_trace_bbox_at.SetValue (tick);
852+ }
853+
831854void PlayerTrace::DrawTraceHud (HudContext *ctx) {
832855 for (auto it = playerTrace->traces .begin (); it != playerTrace->traces .end (); ++it) {
833856 const char *name = it->first .c_str ();
0 commit comments