Skip to content

Commit

Permalink
Add bxt-rs camera replay related hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
khanghugo committed Mar 30, 2024
1 parent 76aefb2 commit f6db538
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
22 changes: 22 additions & 0 deletions BunnymodXT/modules/HwDLL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ struct on_tas_playback_frame_data {
unsigned strafe_cycle_frame_count;
std::array<float, 4> prev_predicted_trace_fractions;
std::array<float, 4> prev_predicted_trace_normal_zs;
std::array<float, 3> rendered_viewangles;
};

// Change the variable name if you change the parameters!
Expand Down Expand Up @@ -2460,6 +2461,26 @@ cvar_t* HwDLL::FindCVar(const char* name)
return ORIG_Cvar_FindVar(name);
}

std::array<float, 3> HwDLL::GetRenderedViewangles() {
std::array<float, 3> res = {player.Viewangles[0], player.Viewangles[1], player.Viewangles[2]};

if (!PitchOverrides.empty()) {
res[0] = PitchOverrides[PitchOverrideIndex];
}
if (!RenderPitchOverrides.empty()) {
res[0] = RenderPitchOverrides[RenderPitchOverrideIndex];
}

if (!TargetYawOverrides.empty()) {
res[1] = TargetYawOverrides[TargetYawOverrideIndex];
}
if (!RenderYawOverrides.empty()) {
res[1] = RenderYawOverrides[RenderYawOverrideIndex];
}

return res;
}

int HwDLL::CallOnTASPlaybackFrame() {
if (!bxt_on_tas_playback_frame)
return 0;
Expand All @@ -2468,6 +2489,7 @@ int HwDLL::CallOnTASPlaybackFrame() {
StrafeState.StrafeCycleFrameCount,
PrevFractions,
PrevNormalzs,
GetRenderedViewangles(),
});
}

Expand Down
2 changes: 2 additions & 0 deletions BunnymodXT/modules/HwDLL.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,8 @@ class HwDLL : public IHookableNameFilterOrdered

bool is_cof_steam = false; // Cry of Fear-specific

// For bxt-rs rendered view playback.
std::array<float, 3> GetRenderedViewangles();
int CallOnTASPlaybackFrame();
void CallOnTASPlaybackStopped();
void ResetTASPlaybackState();
Expand Down

0 comments on commit f6db538

Please sign in to comment.