mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-06-02 17:48:21 -04:00
add alternate to interp callbacks, flags on the leafdraw
This commit is contained in:
@@ -16,7 +16,7 @@ void ensure_initialized();
|
||||
|
||||
void begin_record();
|
||||
void end_record();
|
||||
void begin_frame(bool is_sim_frame, float step);
|
||||
void begin_frame(bool enabled, bool is_sim_frame, float step);
|
||||
void interpolate();
|
||||
float get_interpolation_step();
|
||||
|
||||
@@ -29,6 +29,8 @@ bool is_enabled();
|
||||
void set_ui_tick_pending(bool value);
|
||||
bool get_ui_tick_pending();
|
||||
|
||||
bool is_sim_frame();
|
||||
|
||||
void record_camera(::camera_process_class* cam, int camera_id);
|
||||
void interp_view(::view_class* view);
|
||||
void record_final_mtx(Mtx m, const void *key);
|
||||
|
||||
@@ -25,7 +25,7 @@ typedef struct leafdraw_class : base_process_class {
|
||||
#endif
|
||||
/* 0xB8 */ leafdraw_method_class* leaf_methods;
|
||||
/* 0xBC */ s8 unk_0xBC;
|
||||
/* 0xBD */ u8 unk_0xBD;
|
||||
/* 0xBD */ u8 draw_interp_frame;
|
||||
/* 0xBE */ draw_priority_class draw_priority;
|
||||
} leafdraw_class;
|
||||
|
||||
|
||||
+4
-12
@@ -8106,23 +8106,11 @@ void dKankyo_HIO_c::genMessage(JORMContext* mctx) {
|
||||
|
||||
#endif
|
||||
|
||||
#if TARGET_PC
|
||||
static void interp_callback(bool isSimFrame, void* pUserWork) {
|
||||
if (!isSimFrame) {
|
||||
g_env_light.drawKankyo();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void dScnKy_env_light_c::drawKankyo() {
|
||||
setSunpos();
|
||||
SetBaseLight();
|
||||
setLight();
|
||||
dKy_setLight_nowroom(g_env_light.PrevCol);
|
||||
|
||||
#if TARGET_PC
|
||||
dusk::frame_interp::add_interpolation_callback(interp_callback, nullptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
void dKy_undwater_filter_draw() {
|
||||
@@ -8264,6 +8252,10 @@ static int dKy_Create(void* i_this) {
|
||||
kankyo_class* kankyo = (kankyo_class*)i_this;
|
||||
BOOL next_time_set = false;
|
||||
|
||||
#if TARGET_PC
|
||||
kankyo->base.draw_interp_frame = true;
|
||||
#endif
|
||||
|
||||
stage_envr_info_class* stage_envr_p = dComIfGp_getStageEnvrInfo();
|
||||
if (stage_envr_p != NULL && dComIfGp_getStartStageRoomNo() != -1) {
|
||||
stage_envr_p += dComIfGp_getStartStageRoomNo();
|
||||
|
||||
@@ -53,16 +53,6 @@ struct InterpolationCallBackWork {
|
||||
|
||||
std::vector<InterpolationCallBackWork> s_interpolationCallBackWork;
|
||||
|
||||
void set_enabled(bool enabled) {
|
||||
if (g_enabled == enabled)
|
||||
return;
|
||||
|
||||
g_enabled = enabled;
|
||||
|
||||
if (!g_enabled)
|
||||
s_interpolationCallBackWork.clear();
|
||||
}
|
||||
|
||||
void copy_view_to_snap(CameraSnapshot* dst, const view_class& v) {
|
||||
dst->eye = v.lookat.eye;
|
||||
dst->center = v.lookat.center;
|
||||
@@ -134,20 +124,24 @@ void clear_replacements() {
|
||||
|
||||
namespace dusk::frame_interp {
|
||||
void ensure_initialized() {
|
||||
set_enabled(getSettings().game.enableFrameInterpolation);
|
||||
s_initialized = true;
|
||||
}
|
||||
|
||||
void begin_frame(bool enabled, bool is_sim_frame, float step) {
|
||||
g_enabled = enabled;
|
||||
g_is_sim_frame = is_sim_frame;
|
||||
g_step = std::clamp(step, 0.0f, 1.0f);
|
||||
if (is_sim_frame) {
|
||||
s_interpolationCallBackWork.clear();
|
||||
}
|
||||
}
|
||||
|
||||
bool is_enabled() {
|
||||
return g_enabled;
|
||||
}
|
||||
|
||||
void begin_frame(bool is_sim_frame, float step) {
|
||||
g_is_sim_frame = is_sim_frame;
|
||||
g_step = std::clamp(step, 0.0f, 1.0f);
|
||||
if (is_sim_frame) {
|
||||
s_interpolationCallBackWork.clear();
|
||||
}
|
||||
bool is_sim_frame() {
|
||||
return g_is_sim_frame;
|
||||
}
|
||||
|
||||
void begin_record() {
|
||||
@@ -285,6 +279,12 @@ void record_camera(::camera_process_class* cam, int camera_id) {
|
||||
}
|
||||
|
||||
void interp_view(::view_class* view) {
|
||||
if (!g_enabled)
|
||||
return;
|
||||
|
||||
if (!s_cam_prev.valid || !s_cam_curr.valid)
|
||||
return;
|
||||
|
||||
const f32 step = get_interpolation_step();
|
||||
cXyz eye;
|
||||
cXyz center;
|
||||
|
||||
@@ -6,6 +6,10 @@
|
||||
#include "f_pc/f_pc_leaf.h"
|
||||
#include "f_pc/f_pc_debug_sv.h"
|
||||
|
||||
#if TARGET_PC
|
||||
#include "dusk/frame_interpolation.h"
|
||||
#endif
|
||||
|
||||
s16 fpcLf_GetPriority(const leafdraw_class* i_leaf) {
|
||||
return fpcDwPi_Get(&i_leaf->draw_priority);
|
||||
}
|
||||
@@ -16,6 +20,11 @@ int fpcLf_DrawMethod(leafdraw_method_class* i_methods, void* i_process) {
|
||||
|
||||
int fpcLf_Draw(leafdraw_class* i_leaf) {
|
||||
int ret = 0;
|
||||
#if TARGET_PC
|
||||
if (!i_leaf->draw_interp_frame && !dusk::frame_interp::is_sim_frame()) {
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
if (i_leaf->unk_0xBC == 0) {
|
||||
ret = fpcLf_DrawMethod(i_leaf->leaf_methods, i_leaf);
|
||||
}
|
||||
@@ -56,6 +65,9 @@ int fpcLf_Create(leafdraw_class* i_leaf) {
|
||||
LEAFDRAW_BASE(i_leaf).subtype = fpcBs_MakeOfType(&g_fpcLf_type);
|
||||
fpcDwPi_Init(&i_leaf->draw_priority, pprofile->priority);
|
||||
i_leaf->unk_0xBC = 0;
|
||||
#if TARGET_PC
|
||||
i_leaf->draw_interp_frame = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
int ret = fpcMtd_Create(&i_leaf->leaf_methods->base, i_leaf);
|
||||
|
||||
@@ -70,6 +70,7 @@
|
||||
#include "dusk/config.hpp"
|
||||
#include "dusk/imgui/ImGuiConsole.hpp"
|
||||
#include "tracy/Tracy.hpp"
|
||||
#include "f_pc/f_pc_draw.h"
|
||||
|
||||
// --- GLOBALS ---
|
||||
s8 mDoMain::developmentMode = -1;
|
||||
@@ -233,8 +234,8 @@ void main01(void) {
|
||||
|
||||
mDoGph_gInf_c::updateRenderSize();
|
||||
|
||||
dusk::frame_interp::begin_frame(pacing.is_interpolating, pacing.do_sim_tick, pacing.interpolation_step);
|
||||
if (pacing.is_interpolating) {
|
||||
dusk::frame_interp::begin_frame(pacing.do_sim_tick, pacing.interpolation_step);
|
||||
if (pacing.do_sim_tick) {
|
||||
dusk::frame_interp::set_ui_tick_pending(true);
|
||||
mDoCPd_c::read();
|
||||
@@ -242,6 +243,9 @@ void main01(void) {
|
||||
fapGm_Execute();
|
||||
mDoAud_Execute();
|
||||
dusk::game_clock::reset_accumulator();
|
||||
} else {
|
||||
// run draw functions for anything specially marked to handle interp on non-sim ticks
|
||||
fpcM_DrawIterater((fpcM_DrawIteraterFunc)fpcM_Draw);
|
||||
}
|
||||
dusk::frame_interp::interpolate();
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user