Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bxt_tas_editor_show_from_last_frames #442

Merged
merged 6 commits into from
Jun 24, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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_from_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_from_last_frames);
RegisterCVar(CVars::bxt_disable_vgui);
RegisterCVar(CVars::bxt_wallhack);
RegisterCVar(CVars::bxt_wallhack_additive);
Expand Down
24 changes: 22 additions & 2 deletions BunnymodXT/triangle_drawing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,11 @@ namespace TriangleDrawing
const auto& normalzs = input.normalzs;
const auto& frame_bulk_starts = input.frame_bulk_starts;

const auto show_from_last_frames = CVars::bxt_tas_editor_show_from_last_frames.GetInt();
const auto start_frame = show_from_last_frames <= 0 ||
(unsigned) show_from_last_frames >= input.player_datas.size() ?
1 : input.player_datas.size() - show_from_last_frames;

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

Expand Down Expand Up @@ -698,6 +703,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 +730,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 +756,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 +801,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 +1562,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 +1623,13 @@ namespace TriangleDrawing
Vector last_shown_view_angle_origin;

for (size_t frame = 1; frame < player_datas.size(); ++frame) {
if (frame < start_frame) {
// Match inner advancing when skip showing some frame bulks
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't quite understand this comment, could you rephrase it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (frame == frame_bulk_starts[next_frame_bulk_start_index]) {

From here, it draws perpendicular lines and some basic interactions. Due to how everything is structured, if I don't change next_frame_bulk_start_index when skipping showing the current frame (meaning not going over that line), there will be no perpendicular lines and basic interactions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"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