Skip to content

Commit

Permalink
Add bxt_tas_editor_show_from_last_frames (#442)
Browse files Browse the repository at this point in the history
* Add bxt_tas_editor_show_from_last_frames

* Change from command to cvar

* Change text

* also hiding camera line

* changes requested

* changes requested
  • Loading branch information
khanghugo committed Jun 24, 2023
1 parent bf539bc commit b76702b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
1 change: 1 addition & 0 deletions BunnymodXT/cvars.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
X(bxt_tas_editor_apply_smoothing_over_s, "0.15") \
X(_bxt_tas_editor_apply_smoothing_high_weight_duration, "0.03") \
X(_bxt_tas_editor_apply_smoothing_high_weight_multiplier, "3") \
X(bxt_tas_editor_show_only_last_frames, "0") \
X(bxt_tas_norefresh_until_last_frames, "0") \
X(bxt_tas_write_log, "0") \
X(bxt_tas_playback_speed, "1") \
Expand Down
1 change: 1 addition & 0 deletions BunnymodXT/modules/HwDLL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5074,6 +5074,7 @@ void HwDLL::RegisterCVarsAndCommandsIfNeeded()
RegisterCVar(CVars::bxt_tas_editor_apply_smoothing_over_s);
RegisterCVar(CVars::_bxt_tas_editor_apply_smoothing_high_weight_duration);
RegisterCVar(CVars::_bxt_tas_editor_apply_smoothing_high_weight_multiplier);
RegisterCVar(CVars::bxt_tas_editor_show_only_last_frames);
RegisterCVar(CVars::bxt_disable_vgui);
RegisterCVar(CVars::bxt_wallhack);
RegisterCVar(CVars::bxt_wallhack_additive);
Expand Down
26 changes: 24 additions & 2 deletions BunnymodXT/triangle_drawing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,12 @@ namespace TriangleDrawing
const auto& normalzs = input.normalzs;
const auto& frame_bulk_starts = input.frame_bulk_starts;

const auto show_only_last_frames = CVars::bxt_tas_editor_show_only_last_frames.GetInt();
unsigned start_frame = 1;
if (show_only_last_frames > 0 && (unsigned) show_only_last_frames < input.player_datas.size()) {
start_frame = input.player_datas.size() - show_only_last_frames;
}

if (input.frame_bulks.size() == 0)
return;

Expand Down Expand Up @@ -698,6 +704,9 @@ namespace TriangleDrawing

float selected_px_dist = INFINITY;
for (const auto& key_frame : key_frames) {
if (key_frame.frame < start_frame)
continue;

const auto origin = Vector(player_datas[key_frame.frame].Origin);
auto disp = origin - view;
if (DotProduct(forward, disp) > 0) {
Expand All @@ -722,7 +731,7 @@ namespace TriangleDrawing
auto smoothing_region_it = large_enough_same_yaw_regions.cbegin();

// Draw the camera angles.
for (size_t frame = 1; frame < player_datas.size(); ++frame) {
for (size_t frame = start_frame; frame < player_datas.size(); ++frame) {
const auto origin = Vector(player_datas[frame].Origin);

float brightness = 0.4f;
Expand All @@ -748,7 +757,7 @@ namespace TriangleDrawing
float closest_frame_px_dist = INFINITY;

// Draw the path.
for (size_t frame = 1; frame < player_datas.size(); ++frame) {
for (size_t frame = start_frame; frame < player_datas.size(); ++frame) {
const auto origin = Vector(player_datas[frame].Origin);

float brightness;
Expand Down Expand Up @@ -793,6 +802,9 @@ namespace TriangleDrawing
const auto frame = item.frame;
const auto& line = input.frame_bulks[item.frame_bulk_index];

if (frame < start_frame)
continue;

if (item.frame_bulk_index == selection.frame_bulk_index && item.frame == selection.last_frame)
pTriAPI->Color4f(1, 1, 1, 1);
else
Expand Down Expand Up @@ -1551,6 +1563,8 @@ namespace TriangleDrawing
} else {
for (size_t i = 1; i < frame_bulk_starts.size(); ++i) {
auto frame = frame_bulk_starts[i];
if (frame < start_frame)
continue;

const auto origin = Vector(player_datas[frame].Origin);
auto disp = origin - view;
Expand Down Expand Up @@ -1610,6 +1624,14 @@ namespace TriangleDrawing
Vector last_shown_view_angle_origin;

for (size_t frame = 1; frame < player_datas.size(); ++frame) {
if (frame < start_frame) {
// Incrementing next_frame_bulk_start_index
// when frames are skipped to correctly render perpendicular line.
while (next_frame_bulk_start_index + 1 != frame_bulk_starts.size()
&& frame == frame_bulk_starts[next_frame_bulk_start_index])
++next_frame_bulk_start_index;
continue;
}
const auto origin = Vector(player_datas[frame].Origin);

// Draw the pushables.
Expand Down

0 comments on commit b76702b

Please sign in to comment.