Skip to content

Commit 4913f17

Browse files
committed
feat: sar_trace_reveal
cinematic? useful? idk bro
1 parent 8682462 commit 4913f17

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

docs/cvars.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,7 @@
661661
|sar_trace_portal_oval|0|Draw trace portals as ovals rather than rectangles.|
662662
|sar_trace_portal_record|1|Record portal locations.|
663663
|sar_trace_record|0|Record the trace to a slot. Set to 0 for not recording|
664+
|sar_trace_reveal|0|Only draw traces until the specified tick. Set to bbox to draw until the bbox tick.|
664665
|sar_trace_show|cmd|sar_trace_show [trace name] - show the trace with the given name|
665666
|sar_trace_teleport_at|cmd|sar_trace_teleport_at \<tick> [player slot] [trace name] - teleports the player at the given trace tick on the given trace ID (defaults to hovered one or the first one ever made) in the given slot (defaults to 0).|
666667
|sar_trace_teleport_eye|cmd|sar_trace_teleport_eye \<tick> [player slot] [trace name] - teleports the player to the eye position at the given trace tick on the given trace (defaults to hovered one or the first one ever made) in the given slot (defaults to 0).|

src/Features/PlayerTrace.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ Variable sar_trace_font_size("sar_trace_font_size", "3.0", 0.1, "The size of tex
3939

4040
Variable sar_trace_vphys_record("sar_trace_vphys_record", "1", 0, 1, "Record vphysics locations of dynamic entities for analysis.\n");
4141

42+
Variable 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+
4244
Variable sar_trace_bbox_at("sar_trace_bbox_at", "-1", -1, "Display a player-sized bbox at the given tick.\n");
4345
Variable 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");
4446
Variable sar_trace_bbox_ent_record("sar_trace_bbox_ent_record", "1", "Record hitboxes of nearby entities in the trace. You may want to disable this if memory consumption gets too high.\n");
@@ -274,7 +276,14 @@ void PlayerTrace::DrawInWorld() const {
274276
float speed = trace.velocities[slot][0].Length2D();
275277
unsigned groundframes = trace.grounded[slot][0];
276278

277-
for (size_t i = 0; i < trace.positions[slot].size(); i++) {
279+
size_t end_tick = trace.positions[slot].size() - 1;
280+
if (sar_trace_reveal.GetInt() > 0) {
281+
end_tick = (std::min)(end_tick, (size_t)tickUserToInternal(sar_trace_reveal.GetInt() + 1, trace));
282+
} else if (!strcmp(sar_trace_reveal.GetString(), "bbox")) {
283+
end_tick = (std::min)(end_tick, (size_t)tickUserToInternal(sar_trace_bbox_at.GetInt() + 1, trace));
284+
}
285+
286+
for (size_t i = 0; i < end_tick; i++) {
278287
Vector new_pos = trace.positions[slot][i];
279288
speed = trace.velocities[slot][i].Length2D();
280289

0 commit comments

Comments
 (0)