diff --git a/files.cmake b/files.cmake index bb5bebeaf1..665ce62330 100644 --- a/files.cmake +++ b/files.cmake @@ -1432,7 +1432,6 @@ set(DUSK_FILES src/dusk/dvd_asset.cpp src/dusk/dvd_asset.hpp src/dusk/extras.c - src/dusk/frame_interpolation.cpp src/dusk/commands.cpp src/dusk/commands.hpp src/dusk/game_clock.cpp @@ -1462,6 +1461,8 @@ set(DUSK_FILES src/dusk/imgui/ImGuiStateShare.cpp src/dusk/imgui/ImGuiStateShare.hpp src/dusk/imgui/ImGuiStubLog.cpp + src/dusk/interp/camera.cpp + src/dusk/interp/frame_interpolation.cpp src/dusk/io.cpp src/dusk/iso_validate.cpp src/dusk/language.cpp diff --git a/include/d/actor/d_a_npc_zra.h b/include/d/actor/d_a_npc_zra.h index ee786522f9..825076e192 100644 --- a/include/d/actor/d_a_npc_zra.h +++ b/include/d/actor/d_a_npc_zra.h @@ -370,6 +370,9 @@ public: u32 getAngleNoFromParam() { return (u8)(fopAcM_GetParam(this) >> 8); } void setBlastFlag(u8 i_flag) { mBlastFlag = i_flag; } MtxP getHeadMtx() { return mAnm_p->getModel()->getAnmMtx(4); } +#if TARGET_PC + friend void daNpc_zrA_interp_callback(void* pUserWork); +#endif /* 0x0B48 */ Z2Creature mCreatureSound; /* 0x0BD8 */ J3DModel* mpObjectModel[3]; diff --git a/include/d/actor/d_a_obj_keyhole.h b/include/d/actor/d_a_obj_keyhole.h index b8a813776d..dac1b02696 100644 --- a/include/d/actor/d_a_obj_keyhole.h +++ b/include/d/actor/d_a_obj_keyhole.h @@ -75,9 +75,7 @@ public: #endif }; -#if !TARGET_PC STATIC_ASSERT(sizeof(obj_keyhole_class) == 0x2CB8); -#endif class daObj_Keyhole_HIO_c : public JORReflexible { public: diff --git a/include/d/actor/d_a_obj_lv8Lift.h b/include/d/actor/d_a_obj_lv8Lift.h index 5c2ab58219..4f243d0906 100644 --- a/include/d/actor/d_a_obj_lv8Lift.h +++ b/include/d/actor/d_a_obj_lv8Lift.h @@ -59,7 +59,7 @@ public: int Draw(); int Delete(); #if TARGET_PC - friend void daL8Lift_interp_callback(bool isSimFrame, void* pUserWork); + friend void daL8Lift_interp_callback(void* pUserWork); #endif u8 getPthID() { return fopAcM_GetParamBit(this, 0, 8); } diff --git a/libs/JSystem/include/JSystem/J3DGraphAnimator/J3DModel.h b/libs/JSystem/include/JSystem/J3DGraphAnimator/J3DModel.h index d55bb82465..a7edb19b70 100644 --- a/libs/JSystem/include/JSystem/J3DGraphAnimator/J3DModel.h +++ b/libs/JSystem/include/JSystem/J3DGraphAnimator/J3DModel.h @@ -79,7 +79,9 @@ public: virtual ~J3DModel() {} #if TARGET_PC - static void interp_callback(bool isSimFrame, void* pUserWork); + static void interp_callback(void* pUserWork); + void calc_presentation_base_mtx(); + void prepare_presentation_view(); #endif J3DModelData* getModelData() { return mModelData; } @@ -133,6 +135,9 @@ public: /* 0xD0 */ J3DVtxColorCalc* mVtxColorCalc; /* 0xD4 */ J3DUnkCalc1* mUnkCalc1; /* 0xD8 */ J3DUnkCalc2* mUnkCalc2; +#if TARGET_PC + Mtx mPresentationBase; +#endif }; #endif /* J3DMODEL_H */ diff --git a/libs/JSystem/src/J3DGraphAnimator/J3DModel.cpp b/libs/JSystem/src/J3DGraphAnimator/J3DModel.cpp index 51f3951e38..dfb9050cbd 100644 --- a/libs/JSystem/src/J3DGraphAnimator/J3DModel.cpp +++ b/libs/JSystem/src/J3DGraphAnimator/J3DModel.cpp @@ -10,7 +10,7 @@ #include "JSystem/JKernel/JKRHeap.h" #if TARGET_PC -#include "dusk/frame_interpolation.h" +#include "dusk/interp/frame_interpolation.h" #endif #define J3D_ASSERTMSG(LINE, COND, MSG) JUT_ASSERT_MSG(LINE, (COND) != 0, MSG) @@ -29,6 +29,7 @@ void J3DModel::initialize() { MTXIdentity(mBaseTransformMtx); MTXIdentity(mInternalView); + IF_DUSK(MTXIdentity(mPresentationBase)); mMtxBuffer = NULL; mMatPacket = NULL; @@ -101,17 +102,32 @@ s32 J3DModel::entryModelData(J3DModelData* pModelData, u32 mdlFlags, u32 mtxNum) } #if TARGET_PC -void J3DModel::interp_callback(bool isSimFrame, void* pUserWork) { +void J3DModel::interp_callback(void* pUserWork) { J3DModel* i_this = static_cast(pUserWork); - if (!isSimFrame) { - i_this->calcMaterial(); - i_this->diff(); - } + i_this->calcMaterial(); + i_this->diff(); } void J3DModel::setAnmMtx(int jointNo, Mtx m) { mMtxBuffer->setAnmMtx(jointNo, m); - dusk::frame_interp::record_final_mtx(mMtxBuffer->getAnmMtx(jointNo)); + dusk::interp::record_final_mtx(mMtxBuffer->getAnmMtx(jointNo)); +} + +void J3DModel::calc_presentation_base_mtx() { + Mtx identity; + MTXIdentity(identity); + J3DCalcViewBaseMtx(identity, mBaseScale, mBaseTransformMtx, mPresentationBase); + dusk::interp::record_final_mtx(mPresentationBase); + prepare_presentation_view(); +} + +void J3DModel::prepare_presentation_view() { + Mtx replacement; + MtxP presentationBase = mPresentationBase; + if (dusk::interp::lookup_replacement(mPresentationBase, replacement)) { + presentationBase = replacement; + } + MTXConcat(j3dSys.getViewMtx(), presentationBase, mInternalView); } #endif @@ -470,11 +486,11 @@ void J3DModel::calc() { #ifdef TARGET_PC for (u16 i = 0; i < mModelData->getJointNum(); ++i) { - dusk::frame_interp::record_final_mtx(getAnmMtx(i)); + dusk::interp::record_final_mtx(getAnmMtx(i)); } for (u16 i = 0; i < mModelData->getWEvlpMtxNum(); ++i) { - dusk::frame_interp::record_final_mtx(getWeightAnmMtx(i)); + dusk::interp::record_final_mtx(getWeightAnmMtx(i)); } #endif } @@ -505,8 +521,9 @@ void J3DModel::entry() { } #if TARGET_PC - if (mModelData->needsInterpCallBack()) - dusk::frame_interp::add_interpolation_callback(&J3DModel::interp_callback, this); + if (mModelData->needsInterpCallBack()) { + dusk::interp::add_interpolation_callback(&J3DModel::interp_callback, this); + } #endif } @@ -516,18 +533,20 @@ void J3DModel::viewCalc() { if (getModelData()->checkFlag(0x10)) { if (getMtxCalcMode() == 2) { +#if TARGET_PC + calc_presentation_base_mtx(); +#else J3DCalcViewBaseMtx(j3dSys.getViewMtx(), mBaseScale, mBaseTransformMtx, (MtxP)&mInternalView); -#ifdef TARGET_PC - dusk::frame_interp::record_final_mtx(mInternalView); #endif } } else if (isCpuSkinningOn()) { if (getMtxCalcMode() == 2) { +#if TARGET_PC + calc_presentation_base_mtx(); +#else J3DCalcViewBaseMtx(j3dSys.getViewMtx(), mBaseScale, mBaseTransformMtx, (MtxP)&mInternalView); -#ifdef TARGET_PC - dusk::frame_interp::record_final_mtx(mInternalView); #endif } } else if (checkFlag(J3DMdlFlag_SkinPosCpu)) { @@ -549,15 +568,6 @@ void J3DModel::viewCalc() { DCStoreRange(getNrmMtxPtr(), mModelData->getDrawMtxNum() * sizeof(Mtx33)); } -#ifdef TARGET_PC - Mtx* drawMtx = getDrawMtxPtr(); - if (drawMtx != J3DMtxBuffer::sNoUseDrawMtxPtr) { - for (u16 i = 0; i < mModelData->getDrawMtxNum(); ++i) { - dusk::frame_interp::record_final_mtx(drawMtx[i]); - } - } -#endif - prepareShapePackets(); } diff --git a/libs/JSystem/src/J3DGraphBase/J3DMaterial.cpp b/libs/JSystem/src/J3DGraphBase/J3DMaterial.cpp index 48d4731ed9..ac3b393c81 100644 --- a/libs/JSystem/src/J3DGraphBase/J3DMaterial.cpp +++ b/libs/JSystem/src/J3DGraphBase/J3DMaterial.cpp @@ -373,6 +373,10 @@ s32 J3DMaterial::newSingleSharedDisplayList(u32 dlSize) { #if TARGET_PC bool J3DMaterial::needsInterpCallBack() const { + if (mMaterialAnm != NULL) { + return true; + } + for (int i = 0, n = getTexGenNum(); i < n; i++) { J3DTexMtx* pTexMtx = mTexGenBlock->getTexMtx(i); if (pTexMtx != NULL) { diff --git a/libs/JSystem/src/J3DGraphBase/J3DPacket.cpp b/libs/JSystem/src/J3DGraphBase/J3DPacket.cpp index 38cfddd260..fb82b8244d 100644 --- a/libs/JSystem/src/J3DGraphBase/J3DPacket.cpp +++ b/libs/JSystem/src/J3DGraphBase/J3DPacket.cpp @@ -342,6 +342,11 @@ int J3DShapePacket::newDifferedDisplayList(u32 diffFlags) { void J3DShapePacket::prepareDraw() const { mpModel->getVertexBuffer()->setArray(); j3dSys.setModel(mpModel); +#if TARGET_PC + if (mpModel->getMtxCalcMode() == 2) { + mpModel->prepare_presentation_view(); + } +#endif j3dSys.setShapePacket((J3DShapePacket*)this); J3DShapeMtx::setLODFlag(mpModel->checkFlag(J3DMdlFlag_EnableLOD) != 0); diff --git a/libs/JSystem/src/J3DGraphBase/J3DShapeMtx.cpp b/libs/JSystem/src/J3DGraphBase/J3DShapeMtx.cpp index cedc451cb4..ae9021f76c 100644 --- a/libs/JSystem/src/J3DGraphBase/J3DShapeMtx.cpp +++ b/libs/JSystem/src/J3DGraphBase/J3DShapeMtx.cpp @@ -8,14 +8,14 @@ #include "JSystem/J3DGraphBase/J3DTexture.h" #if TARGET_PC -#include "dusk/frame_interpolation.h" +#include "dusk/interp/frame_interpolation.h" #endif DUSK_GAME_DATA u16 J3DShapeMtx::sMtxLoadCache[10]; #if TARGET_PC static void J3DFrameInterpConcat(MtxP lhs, MtxP rhs, Mtx out) { - if (!dusk::frame_interp::lookup_concat_replacement(lhs, rhs, out)) { + if (!dusk::interp::lookup_concat_replacement(lhs, rhs, out)) { MTXConcat(lhs, rhs, out); } } diff --git a/libs/JSystem/src/J3DGraphBase/J3DSys.cpp b/libs/JSystem/src/J3DGraphBase/J3DSys.cpp index f1810ca158..0f5beb9db5 100644 --- a/libs/JSystem/src/J3DGraphBase/J3DSys.cpp +++ b/libs/JSystem/src/J3DGraphBase/J3DSys.cpp @@ -7,7 +7,7 @@ #include "global.h" #if TARGET_PC -#include "dusk/frame_interpolation.h" +#include "dusk/interp/frame_interpolation.h" #include "helpers/gx_helper.h" #include @@ -379,7 +379,7 @@ void J3DSys::reinitPixelProc() { #if TARGET_PC void J3DSys::setViewMtx(const Mtx m) { Mtx patched; - if (dusk::frame_interp::lookup_replacement(m, patched)) { + if (dusk::interp::lookup_replacement(m, patched)) { m = patched; } MTXCopy(m, mViewMtx); diff --git a/libs/JSystem/src/JFramework/JFWDisplay.cpp b/libs/JSystem/src/JFramework/JFWDisplay.cpp index 8d6f4eb868..0524cb86f7 100644 --- a/libs/JSystem/src/JFramework/JFWDisplay.cpp +++ b/libs/JSystem/src/JFramework/JFWDisplay.cpp @@ -14,7 +14,7 @@ #if TARGET_PC #include "dusk/dusk.h" -#include "dusk/frame_interpolation.h" +#include "dusk/interp/frame_interpolation.h" #include "dusk/logging.h" #include "dusk/settings.h" #include "dusk/time.h" @@ -218,8 +218,8 @@ void JFWDisplay::endGX() { if (mFader != NULL) { ortho.setPort(); -#ifdef TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) { +#if TARGET_PC + if (dusk::interp::get_ui_tick_pending()) { mFader->advance(); } if (mFader->getStatus() != JUTFader::Wait) { @@ -382,7 +382,7 @@ static void waitForTick(u32 p1, u16 p2) { #if TARGET_PC static Limiter limiter; - if (dusk::frame_interp::is_enabled() || dusk::getTransientSettings().turboMode) { + if (dusk::interp::is_enabled() || dusk::getTransientSettings().turboMode) { limiter.Reset(); dusk::frameUsagePct = 0.f; return; diff --git a/libs/JSystem/src/JParticle/JPABaseShape.cpp b/libs/JSystem/src/JParticle/JPABaseShape.cpp index bab7e89646..bebf947fec 100644 --- a/libs/JSystem/src/JParticle/JPABaseShape.cpp +++ b/libs/JSystem/src/JParticle/JPABaseShape.cpp @@ -10,7 +10,7 @@ #include #if TARGET_PC -#include "dusk/frame_interpolation.h" +#include "dusk/interp/frame_interpolation.h" #include #endif @@ -552,7 +552,7 @@ static void submit_particle_quad( void JPAInterpBillboard(JPAEmitterWorkData* work, JPABaseParticle* ptcl) { Mtx ptclPosMtx; MTXTrans(ptclPosMtx, ptcl->mPosition.x, ptcl->mPosition.y, ptcl->mPosition.z); - dusk::frame_interp::record_final_mtx(ptclPosMtx, ptcl); + dusk::interp::record_final_mtx(ptclPosMtx, ptcl); } void JPAInterpRotBillboard(JPAEmitterWorkData* work, JPABaseParticle* ptcl) { @@ -564,7 +564,7 @@ void JPAInterpRotBillboard(JPAEmitterWorkData* work, JPABaseParticle* ptcl) { ptclPosMtx[0][1] = -sinRot; ptclPosMtx[1][0] = sinRot; ptclPosMtx[1][1] = cosRot; - dusk::frame_interp::record_final_mtx(ptclPosMtx, ptcl); + dusk::interp::record_final_mtx(ptclPosMtx, ptcl); } #endif @@ -577,7 +577,7 @@ void JPADrawBillboard(JPAEmitterWorkData* work, JPABaseParticle* ptcl JPA_DRAW_C JGeometry::TVec3 pos; #if TARGET_PC Mtx ptclPosMtx; - if (dusk::frame_interp::lookup_replacement(ptcl, ptclPosMtx)) { + if (dusk::interp::lookup_replacement(ptcl, ptclPosMtx)) { pos.set(ptclPosMtx[0][3], ptclPosMtx[1][3], ptclPosMtx[2][3]); MTXMultVec(work->mPosCamMtx, &pos, &pos); } else @@ -617,7 +617,7 @@ void JPADrawRotBillboard(JPAEmitterWorkData* work, JPABaseParticle* ptcl JPA_DRA #if TARGET_PC Mtx ptclPosMtx; MTXTrans(ptclPosMtx, ptcl->mPosition.x, ptcl->mPosition.y, ptcl->mPosition.z); - if (dusk::frame_interp::lookup_replacement(ptcl, ptclPosMtx)) { + if (dusk::interp::lookup_replacement(ptcl, ptclPosMtx)) { pos.set(ptclPosMtx[0][3], ptclPosMtx[1][3], ptclPosMtx[2][3]); sinRot = ptclPosMtx[1][0]; cosRot = ptclPosMtx[0][0]; @@ -994,7 +994,7 @@ void JPAInterpDirection(JPAEmitterWorkData* work, JPABaseParticle* ptcl) { posMtx[2][2] = axisZ.z; posMtx[2][3] = ptcl->mPosition.z; p_plane[work->mPlaneType](posMtx, scaleX, scaleY); - dusk::frame_interp::record_final_mtx(posMtx, ptcl); + dusk::interp::record_final_mtx(posMtx, ptcl); } void JPAInterpRotDirection(JPAEmitterWorkData* work, JPABaseParticle* ptcl) { @@ -1037,7 +1037,7 @@ void JPAInterpRotDirection(JPAEmitterWorkData* work, JPABaseParticle* ptcl) { mtx2[2][2] = axisZ.z; mtx2[2][3] = ptcl->mPosition.z; MTXConcat(mtx2, mtx1, mtx1); - dusk::frame_interp::record_final_mtx(mtx1, ptcl); + dusk::interp::record_final_mtx(mtx1, ptcl); } #endif @@ -1050,7 +1050,7 @@ void JPADrawDirection(JPAEmitterWorkData* work, JPABaseParticle* ptcl JPA_DRAW_C Mtx posMtx; #if TARGET_PC - if (!dusk::frame_interp::lookup_replacement(ptcl, posMtx) && + if (!dusk::interp::lookup_replacement(ptcl, posMtx) && !make_direction_mtx(work, ptcl, posMtx)) { return; @@ -1113,7 +1113,7 @@ void JPADrawRotDirection(JPAEmitterWorkData* work, JPABaseParticle* ptcl JPA_DRA Mtx mtx1; Mtx mtx2; #if TARGET_PC - if (!dusk::frame_interp::lookup_replacement(ptcl, mtx1) && + if (!dusk::interp::lookup_replacement(ptcl, mtx1) && !make_rot_direction_mtx(work, ptcl, mtx1)) { return; diff --git a/libs/JSystem/src/JParticle/JPAParticle.cpp b/libs/JSystem/src/JParticle/JPAParticle.cpp index 99ba95453c..0bb03d607a 100644 --- a/libs/JSystem/src/JParticle/JPAParticle.cpp +++ b/libs/JSystem/src/JParticle/JPAParticle.cpp @@ -8,7 +8,7 @@ #include "JSystem/JParticle/JPAExtraShape.h" #if TARGET_PC -#include "dusk/frame_interpolation.h" +#include "dusk/interp/frame_interpolation.h" #endif JPAParticleCallBack::~JPAParticleCallBack() { @@ -210,7 +210,7 @@ void JPABaseParticle::init_c(JPAEmitterWorkData* work, JPABaseParticle* parent) #if TARGET_PC void JPABaseParticle::interp(JPAEmitterWorkData* work, void const* drawFunc) { - if (!dusk::frame_interp::is_enabled()) + if (!dusk::interp::is_enabled()) return; // don't interpolate the first frame diff --git a/libs/JSystem/src/JParticle/JPAResource.cpp b/libs/JSystem/src/JParticle/JPAResource.cpp index 1eef1b08a5..8a4d931e16 100644 --- a/libs/JSystem/src/JParticle/JPAResource.cpp +++ b/libs/JSystem/src/JParticle/JPAResource.cpp @@ -15,7 +15,7 @@ #include "global.h" #if TARGET_PC -#include "dusk/frame_interpolation.h" +#include "dusk/interp/frame_interpolation.h" #include @@ -839,7 +839,7 @@ bool JPAResource::calc(JPAEmitterWorkData* work, JPABaseEmitter* emtr) { #ifdef TARGET_PC if (((pBsp && pBsp->getDirType() == 3) || (pCsp && pCsp->getDirType() == 3)) && - dusk::frame_interp::is_enabled()) + dusk::interp::is_enabled()) { // ensure mGlobalEmtrDir is valid calcWorkData_d(work); diff --git a/libs/JSystem/src/JStudio/JStudio/jstudio-object.cpp b/libs/JSystem/src/JStudio/JStudio/jstudio-object.cpp index 2f408d6184..b6f41098e5 100644 --- a/libs/JSystem/src/JStudio/JStudio/jstudio-object.cpp +++ b/libs/JSystem/src/JStudio/JStudio/jstudio-object.cpp @@ -4,7 +4,7 @@ #if TARGET_PC #include "dusk/audio.h" -#include "dusk/frame_interpolation.h" +#include "dusk/interp/frame_interpolation.h" #include "dusk/settings.h" #endif @@ -655,10 +655,10 @@ value_or_fun: value: #if TARGET_PC - if (dusk::frame_interp::is_enabled() && u <= 5 && + if (dusk::interp::is_enabled() && u <= 5 && (operation == data::UNK_0x2 || operation == data::UNK_0x3 || operation == data::UNK_0x12)) { - dusk::frame_interp::request_presentation_sync(); + dusk::interp::request_presentation_sync(); } #endif adaptor->adaptor_setVariableValue(control, u, operation, param_2, param_3); @@ -666,11 +666,11 @@ value: value_n: #if TARGET_PC - if (dusk::frame_interp::is_enabled() && + if (dusk::interp::is_enabled() && (pN == TAdaptor_camera::sauVariableValue_3_POSITION_XYZ || pN == TAdaptor_camera::sauVariableValue_3_TARGET_POSITION_XYZ) && (operation == data::UNK_0x2 || operation == data::UNK_0x3 || operation == data::UNK_0x12)) { - dusk::frame_interp::request_presentation_sync(); + dusk::interp::request_presentation_sync(); } #endif adaptor->adaptor_setVariableValue_n(control, pN, u, operation, param_2, param_3); diff --git a/libs/JSystem/src/JUtility/JUTFader.cpp b/libs/JSystem/src/JUtility/JUTFader.cpp index a8d9fe6028..2e937b176e 100644 --- a/libs/JSystem/src/JUtility/JUTFader.cpp +++ b/libs/JSystem/src/JUtility/JUTFader.cpp @@ -9,8 +9,9 @@ #include "JSystem/J2DGraph/J2DOrthoGraph.h" #ifdef TARGET_PC +#include "dusk/interp/frame_interpolation.h" + #include -#include "dusk/frame_interpolation.h" #endif JUTFader::JUTFader(int x, int y, int width, int height, JUtility::TColor pColor) @@ -74,8 +75,8 @@ void JUTFader::control() { void JUTFader::draw() { if (mColor.a != 0) { #ifdef TARGET_PC - if (dusk::frame_interp::is_enabled() && mDuration != 0) { - const auto step = dusk::frame_interp::get_interpolation_step(); + if (dusk::interp::is_enabled() && mDuration != 0) { + const auto step = dusk::interp::get_interpolation_step(); const auto progress = static_cast(mTimer) / static_cast(mDuration); const auto timer = mTimer - 1 + step + progress; auto alpha = timer / mDuration; diff --git a/src/d/actor/d_a_alink.cpp b/src/d/actor/d_a_alink.cpp index 4d1bf182db..c9a2969914 100644 --- a/src/d/actor/d_a_alink.cpp +++ b/src/d/actor/d_a_alink.cpp @@ -53,11 +53,13 @@ #if TARGET_PC #include "dusk/action_bindings.h" -#include "dusk/frame_interpolation.h" +#include "dusk/interp/frame_interpolation.h" #include "dusk/settings.h" +#include "helpers/string.hpp" + #include "res/Object/Alink.h" + #include -#include #endif static int daAlink_Create(fopAc_ac_c* i_this); @@ -5993,7 +5995,7 @@ void daAlink_c::setItemMatrix(int param_0) { mDoMtx_stack_c::XrotS(-0x8000); #ifdef TARGET_PC - if (dusk::frame_interp::is_enabled()) { + if (dusk::interp::is_enabled()) { Mtx boot_mtx; mDoMtx_concat(mpLinkModel->getAnmMtx(0x18), mDoMtx_stack_c::get(), boot_mtx); mpLinkBootModels[1]->setAnmMtx(1, boot_mtx); @@ -19792,7 +19794,7 @@ int daAlink_c::draw() { dComIfGd_getOpaListDark()->entryImm(mpHookChain, 0); #if TARGET_PC - if (dusk::frame_interp::is_enabled()) { + if (dusk::interp::is_enabled()) { if (mEquipItem == dItemNo_IRONBALL_e && mIronBallChainPos != NULL && mIronBallChainAngle != NULL) { @@ -19808,7 +19810,7 @@ int daAlink_c::draw() { mIBChainInterpCurrHandRoot = mHookshotTopPos; mIBChainInterpCurrValid = true; - dusk::frame_interp::add_interpolation_callback(&ironBallChainInterpCallback, this); + dusk::interp::add_interpolation_callback(&ironBallChainInterpCallback, this); } else { if (mHsChainInterpCurrValid) { mHsChainInterpPrevTop = mHsChainInterpCurrTop; diff --git a/src/d/actor/d_a_alink_hook.inc b/src/d/actor/d_a_alink_hook.inc index cbc8bdc664..1f82ef98c1 100644 --- a/src/d/actor/d_a_alink_hook.inc +++ b/src/d/actor/d_a_alink_hook.inc @@ -10,7 +10,7 @@ #include "JSystem/J3DGraphBase/J3DMaterial.h" #if TARGET_PC -#include "dusk/frame_interpolation.h" +#include "dusk/interp/frame_interpolation.h" #include "dusk/settings.h" static const int HS_CHAIN_MAX_LINKS = 600; @@ -137,8 +137,8 @@ void daAlink_c::hsChainShape_c::draw() { } else { #if TARGET_PC cXyz hsInterpTop, hsInterpRoot, hsInterpSubRoot, hsInterpSubTop; - if (dusk::frame_interp::is_enabled() && alink->mHsChainInterpPrevValid && alink->mHsChainInterpCurrValid) { - const f32 alpha = dusk::frame_interp::get_interpolation_step(); + if (dusk::interp::is_enabled() && alink->mHsChainInterpPrevValid && alink->mHsChainInterpCurrValid) { + const f32 alpha = dusk::interp::get_interpolation_step(); hsInterpTop = alink->mHsChainInterpPrevTop + (alink->mHsChainInterpCurrTop - alink->mHsChainInterpPrevTop) * alpha; hsInterpRoot = alink->mHsChainInterpPrevRoot + (alink->mHsChainInterpCurrRoot - alink->mHsChainInterpPrevRoot) * alpha; hsInterpSubRoot = alink->mHsChainInterpPrevSubRoot + (alink->mHsChainInterpCurrSubRoot - alink->mHsChainInterpPrevSubRoot) * alpha; @@ -244,7 +244,7 @@ void daAlink_c::hsChainShape_c::draw() { } #if TARGET_PC -static void ironBallChainInterpCallback(bool isSimFrame, void* pUserWork) { +static void ironBallChainInterpCallback(void* pUserWork) { static_cast(pUserWork)->onIronBallChainInterpCallback(); } @@ -256,7 +256,7 @@ void daAlink_c::onIronBallChainInterpCallback() { return; } - const f32 alpha = dusk::frame_interp::get_interpolation_step(); + const f32 alpha = dusk::interp::get_interpolation_step(); for (int i = 0; i < IRON_BALL_CHAIN_COUNT; i++) { mIronBallChainPos[i] = mIBChainInterpPrevPos[i] + (mIBChainInterpCurrPos[i] - mIBChainInterpPrevPos[i]) * alpha; diff --git a/src/d/actor/d_a_alink_horse.inc b/src/d/actor/d_a_alink_horse.inc index 7389decb73..f271ed401e 100644 --- a/src/d/actor/d_a_alink_horse.inc +++ b/src/d/actor/d_a_alink_horse.inc @@ -340,18 +340,31 @@ void daAlink_c::setHorseStirrup() { mDoMtx_stack_c::copy(mpLinkModel->getAnmMtx(field_0x30bc)); mDoMtx_stack_c::transM(-2.0f, -11.0f, 1.5f); mDoMtx_stack_c::ZXYrotM(0, -0x8000, 0x4000); +#if TARGET_PC + horse->m_model->setAnmMtx(0x17, mDoMtx_stack_c::get()); +#else mDoMtx_copy(mDoMtx_stack_c::get(), horse->getLeftStirrupMtx()); +#endif } if (field_0x2fab & 2) { mDoMtx_stack_c::copy(mpLinkModel->getAnmMtx(field_0x30be)); mDoMtx_stack_c::transM(-2.0f, 11.0f, 1.5f); mDoMtx_stack_c::ZrotM(-0x4000); +#if TARGET_PC + horse->m_model->setAnmMtx(0x19, mDoMtx_stack_c::get()); +#else mDoMtx_copy(mDoMtx_stack_c::get(), horse->getRightStirrupMtx()); +#endif } if (field_0x2fab & 3) { horse->calcWeightEnvMtx(); +#if TARGET_PC + for (u16 i = 0; i < horse->m_model->getModelData()->getWEvlpMtxNum(); i++) { + dusk::interp::record_final_mtx(horse->m_model->getWeightAnmMtx(i)); + } +#endif } int hand_type = getReinHandType(); diff --git a/src/d/actor/d_a_b_gnd.cpp b/src/d/actor/d_a_b_gnd.cpp index 80cca37f6e..518590d854 100644 --- a/src/d/actor/d_a_b_gnd.cpp +++ b/src/d/actor/d_a_b_gnd.cpp @@ -17,10 +17,10 @@ #include "Z2AudioLib/Z2Instances.h" -#include "dusk/frame_interpolation.h" -#include "dusk/settings.h" #if TARGET_PC #include "dusk/achievements.h" +#include "dusk/interp/frame_interpolation.h" +#include "dusk/settings.h" #endif class daB_GND_HIO_c : public JORReflexible { @@ -286,12 +286,12 @@ static int h_nodeCallBack(J3DJoint* i_joint, int param_2) { } #if TARGET_PC -static void b_gnd_rein_interp_callback(bool isSimFrame, void* pUserWork) { +static void b_gnd_rein_interp_callback(void* pUserWork) { b_gnd_class* i_this = (b_gnd_class*)pUserWork; if (!i_this->mReinsInterpPrevValid || !i_this->mReinsInterpCurrValid) { return; } - const f32 alpha = dusk::frame_interp::get_interpolation_step(); + const f32 alpha = dusk::interp::get_interpolation_step(); for (int r = 0; r < 2; r++) { cXyz* dst = i_this->mHorseReins[r].getPos(0); for (int i = 0; i < 16; i++) { @@ -397,7 +397,7 @@ static int daB_GND_Draw(b_gnd_class* i_this) { i_this->field_0x21e8.update(2, l_color, &a_this->tevStr); dComIfGd_set3DlineMat(&i_this->field_0x21e8); #if TARGET_PC - if (dusk::frame_interp::is_enabled()) { + if (dusk::interp::is_enabled()) { if (i_this->mReinsInterpCurrValid) { memcpy(i_this->mReinsInterpPrev, i_this->mReinsInterpCurr, sizeof(i_this->mReinsInterpCurr)); memcpy(i_this->mReinsTexInterpPrev, i_this->mReinsTexInterpCurr, sizeof(i_this->mReinsTexInterpCurr)); @@ -408,7 +408,7 @@ static int daB_GND_Draw(b_gnd_class* i_this) { } memcpy(i_this->mReinsTexInterpCurr, i_this->field_0x21e8.getPos(0), 2 * sizeof(cXyz)); i_this->mReinsInterpCurrValid = true; - dusk::frame_interp::add_interpolation_callback(&b_gnd_rein_interp_callback, i_this); + dusk::interp::add_interpolation_callback(&b_gnd_rein_interp_callback, i_this); } #endif } @@ -3791,7 +3791,7 @@ static void demo_camera(b_gnd_class* i_this) { i_this->mDemoCamSyncTicks = 2; } if (i_this->mDemoCamSyncTicks > 0) { - dusk::frame_interp::request_presentation_sync(); + dusk::interp::request_presentation_sync(); i_this->mDemoCamSyncTicks--; } #endif diff --git a/src/d/actor/d_a_balloon_2D.cpp b/src/d/actor/d_a_balloon_2D.cpp index a9d6d0db4f..5d5923abc3 100644 --- a/src/d/actor/d_a_balloon_2D.cpp +++ b/src/d/actor/d_a_balloon_2D.cpp @@ -6,7 +6,6 @@ #include "d/dolzel_rel.h" // IWYU pragma: keep #include "d/actor/d_a_balloon_2D.h" -#include "dusk/frame_interpolation.h" #include "JSystem/J2DGraph/J2DGrafContext.h" #include "JSystem/J2DGraph/J2DScreen.h" #include "JSystem/J2DGraph/J2DTextBox.h" @@ -21,6 +20,10 @@ #include "m_Do/m_Do_lib.h" #include +#if TARGET_PC +#include "dusk/interp/frame_interpolation.h" +#endif + class daBalloon2D_HIO_c : public mDoHIO_entry_c { public: inline daBalloon2D_HIO_c() { @@ -439,12 +442,9 @@ void daBalloon2D_c::setComboAlpha() { void daBalloon2D_c::drawAddScore() { for (s32 i = 19; i >= 0; i--) { if (field_0x5f8[i].field_0xe != 0) { -#ifdef TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) -#endif - { - field_0x5f8[i].field_0xe--; - } + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) + field_0x5f8[i].field_0xe--; + IF_DUSK_BLOCK_END s32 score3; s32 score2; s32 score = field_0x5f8[i].field_0xc; @@ -452,13 +452,10 @@ void daBalloon2D_c::drawAddScore() { u8 local_88 = 0xff; f32 dVar11 = 30.0f; f32 dVar9 = 30.0f; -#ifdef TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) -#endif - { - field_0x5f8[i].field_0x0.x += cM_ssin(temp0) * 0.3f; - field_0x5f8[i].field_0x0.y -= 1.0f; - } + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) + field_0x5f8[i].field_0x0.x += cM_ssin(temp0) * 0.3f; + field_0x5f8[i].field_0x0.y -= 1.0f; + IF_DUSK_BLOCK_END if (field_0x5f8[i].field_0xe < 10) { f32 fVar5 = field_0x5f8[i].field_0xe / 10.0f; local_88 = fVar5 * 255.0f; diff --git a/src/d/actor/d_a_e_bee.cpp b/src/d/actor/d_a_e_bee.cpp index 09909f9e0a..3cfadae812 100644 --- a/src/d/actor/d_a_e_bee.cpp +++ b/src/d/actor/d_a_e_bee.cpp @@ -15,6 +15,10 @@ #include "SSystem/SComponent/c_math.h" #include "Z2AudioLib/Z2Instances.h" +#if TARGET_PC +#include "dusk/interp/frame_interpolation.h" +#endif + static bool hio_set; static daE_Bee_HIO_c l_HIO; @@ -50,6 +54,26 @@ static int daE_Bee_Draw(e_bee_class* i_this) { return 1; } +#if TARGET_PC +static void bee_interp(bee_s* i_bee) { + if (!dusk::interp::is_enabled()) { + return; + } + + J3DModel* models[] = { + i_bee->mpModel1, + i_bee->mpModel2, + i_bee->mpModel3, + i_bee->mpModel4, + }; + MtxP mtx = mDoMtx_stack_c::get(); + for (int i = 0; i < 4; i++) { + models[i]->setBaseTRMtx(mtx); + models[i]->calc(); + } +} +#endif + static void bee_mtxset(bee_s* i_bee) { mDoMtx_stack_c::transS(i_bee->mPos.x, i_bee->mPos.y, i_bee->mPos.z); mDoMtx_stack_c::YrotM(i_bee->mAngle.y); @@ -62,6 +86,7 @@ static void bee_mtxset(bee_s* i_bee) { } else { i_bee->mpModel2->setBaseTRMtx(mDoMtx_stack_c::get()); } + IF_DUSK(bee_interp(i_bee)); } static void bee_ground_ang_set(bee_s* i_bee) { @@ -332,6 +357,7 @@ static void bee_nest_action(e_bee_class* i_this, bee_s* i_bee, s8 i_nestHealth) i_bee->mpModel4->setBaseTRMtx(mDoMtx_stack_c::get()); } } + IF_DUSK(bee_interp(i_bee)); if (i_nestHealth == 1) { i_bee->mAction = bee_s::ACT_FLY; diff --git a/src/d/actor/d_a_e_db.cpp b/src/d/actor/d_a_e_db.cpp index dcc3849756..217e32e16e 100644 --- a/src/d/actor/d_a_e_db.cpp +++ b/src/d/actor/d_a_e_db.cpp @@ -11,7 +11,7 @@ #include "f_op/f_op_actor_enemy.h" #if TARGET_PC -#include "dusk/frame_interpolation.h" +#include "dusk/interp/frame_interpolation.h" #endif class daE_DB_HIO_c : public JORReflexible { @@ -71,12 +71,12 @@ static BOOL leaf_anm_init(e_db_class* i_this, int i_anm, f32 i_morf, u8 i_mode, } #if TARGET_PC -static void daE_DB_interp_callback(bool isSimFrame, void* pUserWork) { +static void daE_DB_interp_callback(void* pUserWork) { e_db_class* i_this = (e_db_class*)pUserWork; if (!i_this->mStalkLineInterpPrevValid || !i_this->mStalkLineInterpCurrValid) { return; } - const f32 alpha = dusk::frame_interp::get_interpolation_step(); + const f32 alpha = dusk::interp::get_interpolation_step(); cXyz* dst = i_this->stalkLine.getPos(0); for (int i = 0; i < 12; i++) { const cXyz& p0 = i_this->mStalkLineInterpPrev[i]; @@ -116,14 +116,14 @@ static int daE_DB_Draw(e_db_class* i_this) { i_this->stalkLine.update(12, l_color, &actor->tevStr); dComIfGd_set3DlineMat(&i_this->stalkLine); #if TARGET_PC - if (dusk::frame_interp::is_enabled()) { + if (dusk::interp::is_enabled()) { if (i_this->mStalkLineInterpCurrValid) { memcpy(i_this->mStalkLineInterpPrev, i_this->mStalkLineInterpCurr, sizeof(i_this->mStalkLineInterpCurr)); i_this->mStalkLineInterpPrevValid = true; } memcpy(i_this->mStalkLineInterpCurr, i_this->stalkLine.getPos(0), 12 * sizeof(cXyz)); i_this->mStalkLineInterpCurrValid = true; - dusk::frame_interp::add_interpolation_callback(&daE_DB_interp_callback, i_this); + dusk::interp::add_interpolation_callback(&daE_DB_interp_callback, i_this); } #endif diff --git a/src/d/actor/d_a_e_hb.cpp b/src/d/actor/d_a_e_hb.cpp index f0dfbda3a6..f73e2bae0b 100644 --- a/src/d/actor/d_a_e_hb.cpp +++ b/src/d/actor/d_a_e_hb.cpp @@ -10,7 +10,7 @@ #include "f_op/f_op_actor_enemy.h" #if TARGET_PC -#include "dusk/frame_interpolation.h" +#include "dusk/interp/frame_interpolation.h" #endif enum daE_HB_ACTION { @@ -69,12 +69,12 @@ static BOOL leaf_anm_init(e_hb_class* i_this, int i_anm, f32 i_morf, u8 i_mode, } #if TARGET_PC -static void daE_HB_interp_callback(bool isSimFrame, void* pUserWork) { +static void daE_HB_interp_callback(void* pUserWork) { e_hb_class* i_this = (e_hb_class*)pUserWork; if (!i_this->mStalkLineInterpPrevValid || !i_this->mStalkLineInterpCurrValid) { return; } - const f32 alpha = dusk::frame_interp::get_interpolation_step(); + const f32 alpha = dusk::interp::get_interpolation_step(); cXyz* dst = i_this->stalkLine.getPos(0); for (int i = 0; i < 12; i++) { const cXyz& p0 = i_this->mStalkLineInterpPrev[i]; @@ -103,14 +103,14 @@ static int daE_HB_Draw(e_hb_class* i_this) { i_this->stalkLine.update(12, l_color, &actor->tevStr); dComIfGd_set3DlineMat(&i_this->stalkLine); #if TARGET_PC - if (dusk::frame_interp::is_enabled()) { + if (dusk::interp::is_enabled()) { if (i_this->mStalkLineInterpCurrValid) { memcpy(i_this->mStalkLineInterpPrev, i_this->mStalkLineInterpCurr, sizeof(i_this->mStalkLineInterpCurr)); i_this->mStalkLineInterpPrevValid = true; } memcpy(i_this->mStalkLineInterpCurr, i_this->stalkLine.getPos(0), 12 * sizeof(cXyz)); i_this->mStalkLineInterpCurrValid = true; - dusk::frame_interp::add_interpolation_callback(&daE_HB_interp_callback, i_this); + dusk::interp::add_interpolation_callback(&daE_HB_interp_callback, i_this); } #endif diff --git a/src/d/actor/d_a_e_mb.cpp b/src/d/actor/d_a_e_mb.cpp index 1fff337b33..8e40e92baa 100644 --- a/src/d/actor/d_a_e_mb.cpp +++ b/src/d/actor/d_a_e_mb.cpp @@ -12,8 +12,10 @@ #include "d/d_bomb.h" #include "c/c_damagereaction.h" #include "Z2AudioLib/Z2Instances.h" -#include "dusk/frame_interpolation.h" -#include "dusk/settings.h" + +#if TARGET_PC +#include "dusk/interp/frame_interpolation.h" +#endif #define ACTION_STANDBY 0 #define ACTION_WALK1 1 @@ -66,12 +68,12 @@ static void anm_init(e_mb_class* i_this, int i_anmID, f32 i_morf, u8 i_attr, f32 } #if TARGET_PC -static void e_mb_rope_interp_callback(bool isSimFrame, void* pUserWork) { +static void e_mb_rope_interp_callback(void* pUserWork) { e_mb_class* i_this = (e_mb_class*)pUserWork; if (!i_this->mRopeInterpPrevValid || !i_this->mRopeInterpCurrValid) { return; } - const f32 alpha = dusk::frame_interp::get_interpolation_step(); + const f32 alpha = dusk::interp::get_interpolation_step(); cXyz* dst = i_this->mRopeMat.getPos(0); for (int i = 0; i < 16; i++) { const cXyz& p0 = i_this->mRopeInterpPrev[i]; @@ -105,14 +107,14 @@ static int daE_MB_Draw(e_mb_class* i_this) { i_this->mRopeMat.update(16, l_color, &a_this->tevStr); dComIfGd_set3DlineMat(&i_this->mRopeMat); #if TARGET_PC - if (dusk::frame_interp::is_enabled()) { + if (dusk::interp::is_enabled()) { if (i_this->mRopeInterpCurrValid) { memcpy(i_this->mRopeInterpPrev, i_this->mRopeInterpCurr, sizeof(i_this->mRopeInterpCurr)); i_this->mRopeInterpPrevValid = true; } memcpy(i_this->mRopeInterpCurr, i_this->mRopeMat.getPos(0), 16 * sizeof(cXyz)); i_this->mRopeInterpCurrValid = true; - dusk::frame_interp::add_interpolation_callback(&e_mb_rope_interp_callback, i_this); + dusk::interp::add_interpolation_callback(&e_mb_rope_interp_callback, i_this); } #endif return 1; diff --git a/src/d/actor/d_a_e_s1.cpp b/src/d/actor/d_a_e_s1.cpp index cd48a103e1..4f6b6c3c95 100644 --- a/src/d/actor/d_a_e_s1.cpp +++ b/src/d/actor/d_a_e_s1.cpp @@ -14,10 +14,12 @@ #include "d/d_s_play.h" #include "f_op/f_op_actor_enemy.h" #include "f_op/f_op_camera_mng.h" -#include "dusk/frame_interpolation.h" -#include "dusk/settings.h" #include +#if TARGET_PC +#include "dusk/interp/frame_interpolation.h" +#endif + class daE_S1_HIO_c { public: daE_S1_HIO_c(); @@ -102,12 +104,12 @@ static void anm_init(e_s1_class* i_this, int i_resNo, f32 i_morf, u8 i_attr, f32 } #if TARGET_PC -static void daE_S1_interp_callback(bool isSimFrame, void* pUserWork) { +static void daE_S1_interp_callback(void* pUserWork) { e_s1_class* i_this = (e_s1_class*)pUserWork; if (!i_this->mHairInterpPrevValid || !i_this->mHairInterpCurrValid) { return; } - const f32 alpha = dusk::frame_interp::get_interpolation_step(); + const f32 alpha = dusk::interp::get_interpolation_step(); for (int s = 0; s < e_s1_class::HAIR_STRAND_COUNT; s++) { cXyz* dst = i_this->mLineMat.getPos(s); for (int i = 0; i < e_s1_class::HAIR_SEGMENT_COUNT; i++) { @@ -161,7 +163,7 @@ static int daE_S1_Draw(e_s1_class* i_this) { dComIfGd_set3DlineMatDark(&i_this->mLineMat); #if TARGET_PC - if (dusk::frame_interp::is_enabled()) { + if (dusk::interp::is_enabled()) { if (i_this->mHairInterpCurrValid) { memcpy(i_this->mHairInterpPrev, i_this->mHairInterpCurr, sizeof(i_this->mHairInterpCurr)); i_this->mHairInterpPrevValid = true; @@ -172,7 +174,7 @@ static int daE_S1_Draw(e_s1_class* i_this) { e_s1_class::HAIR_SEGMENT_COUNT * sizeof(cXyz)); } i_this->mHairInterpCurrValid = true; - dusk::frame_interp::add_interpolation_callback(&daE_S1_interp_callback, i_this); + dusk::interp::add_interpolation_callback(&daE_S1_interp_callback, i_this); } #endif diff --git a/src/d/actor/d_a_e_sm2.cpp b/src/d/actor/d_a_e_sm2.cpp index 808301527e..96f718ce0b 100644 --- a/src/d/actor/d_a_e_sm2.cpp +++ b/src/d/actor/d_a_e_sm2.cpp @@ -15,7 +15,7 @@ #include #if TARGET_PC -#include "dusk/frame_interpolation.h" +#include "dusk/interp/frame_interpolation.h" #endif class daE_SM2_HIO_c : public fOpAcm_HIO_entry_c { @@ -81,7 +81,7 @@ static int nodeCallBack(J3DJoint* i_joint, int param_1) { } #if TARGET_PC -static void daE_SM2_interp_callback(bool isSimFrame, void* pUserWork) { +static void daE_SM2_interp_callback(void* pUserWork) { e_sm2_class* i_this = static_cast(pUserWork); if (i_this == NULL) { return; @@ -133,7 +133,7 @@ static int daE_SM2_Draw(e_sm2_class* i_this) { fopAc_ac_c* actor = (fopAc_ac_c*)&i_this->enemy; #if TARGET_PC - dusk::frame_interp::add_interpolation_callback(&daE_SM2_interp_callback, i_this); + dusk::interp::add_interpolation_callback(&daE_SM2_interp_callback, i_this); #endif g_env_light.settingTevStruct(0, &actor->current.pos, &actor->tevStr); diff --git a/src/d/actor/d_a_e_wb.cpp b/src/d/actor/d_a_e_wb.cpp index a7f2e4f7b3..cadbaf4aed 100644 --- a/src/d/actor/d_a_e_wb.cpp +++ b/src/d/actor/d_a_e_wb.cpp @@ -18,10 +18,11 @@ #include "m_Do/m_Do_controller_pad.h" #include "m_Do/m_Do_graphic.h" #include "res/Object/Always.h" -#include "dusk/dusk.h" -#include "dusk/frame_interpolation.h" #include +#if TARGET_PC +#include "dusk/interp/frame_interpolation.h" +#endif class daE_WB_HIO_c : public JORReflexible { public: @@ -187,12 +188,12 @@ static bool hio_set; static daE_WB_HIO_c l_HIO; #if TARGET_PC -static void e_wb_rein_interp_callback(bool isSimFrame, void* pUserWork) { +static void e_wb_rein_interp_callback(void* pUserWork) { e_wb_class* i_this = (e_wb_class*)pUserWork; if (!i_this->himo_interp_prev_valid || !i_this->himo_interp_curr_valid) { return; } - const f32 alpha = dusk::frame_interp::get_interpolation_step(); + const f32 alpha = dusk::interp::get_interpolation_step(); for (int r = 0; r < 2; r++) { cXyz* dst = i_this->himo_mat[r].getPos(0); for (int i = 0; i < 16; i++) { @@ -535,7 +536,7 @@ static int daE_WB_Draw(e_wb_class* i_this) { i_this->himo_tex.update(2, l_color, &actor->tevStr); dComIfGd_set3DlineMat(&i_this->himo_tex); #if TARGET_PC - if (dusk::frame_interp::is_enabled()) { + if (dusk::interp::is_enabled()) { if (i_this->himo_interp_curr_valid) { memcpy(i_this->himo_mat_interp_prev, i_this->himo_mat_interp_curr, sizeof(i_this->himo_mat_interp_curr)); memcpy(i_this->himo_tex_interp_prev, i_this->himo_tex_interp_curr, sizeof(i_this->himo_tex_interp_curr)); @@ -546,7 +547,7 @@ static int daE_WB_Draw(e_wb_class* i_this) { } memcpy(i_this->himo_tex_interp_curr, i_this->himo_tex.getPos(0), 2 * sizeof(cXyz)); i_this->himo_interp_curr_valid = true; - dusk::frame_interp::add_interpolation_callback(&e_wb_rein_interp_callback, i_this); + dusk::interp::add_interpolation_callback(&e_wb_rein_interp_callback, i_this); } #endif } @@ -4542,7 +4543,7 @@ static void demo_camera(e_wb_class* i_this) { i_this->demo_cam_way_spd.z = fabsf(i_this->demo_cam_way.z - i_this->demo_cam_ctr.z); i_this->demo_cam_morf = 0; pla->setPlayerPosAndAngle(&pla->current.pos, pla->shape_angle.y - 4000, 0); - IF_DUSK(dusk::frame_interp::request_presentation_sync()); + IF_DUSK(dusk::interp::request_presentation_sync()); } if (i_this->demo_timer == 345) { daPy_getPlayerActorClass()->setThrowDamage(boss->enemy.shape_angle.y - 8000 + TREG_S(8), @@ -4789,7 +4790,7 @@ static void demo_camera(e_wb_class* i_this) { i_this->demo_cam_eye.x += 300.0f + VREG_F(8); i_this->demo_cam_eye.y += 150.0f + VREG_F(9); i_this->demo_cam_eye.z -= 1400.0f + VREG_F(10); - IF_DUSK(dusk::frame_interp::request_presentation_sync()); + IF_DUSK(dusk::interp::request_presentation_sync()); } } else { i_this->demo_cam_eye = enemy->current.pos; @@ -5050,7 +5051,7 @@ static void demo_camera(e_wb_class* i_this) { i_this->demo_cam_sync_ticks = 2; } if (i_this->demo_cam_sync_ticks > 0) { - dusk::frame_interp::request_presentation_sync(); + dusk::interp::request_presentation_sync(); i_this->demo_cam_sync_ticks--; } #endif diff --git a/src/d/actor/d_a_e_yd.cpp b/src/d/actor/d_a_e_yd.cpp index 52a5be7fdc..198e59ac06 100644 --- a/src/d/actor/d_a_e_yd.cpp +++ b/src/d/actor/d_a_e_yd.cpp @@ -13,7 +13,7 @@ #include "f_op/f_op_actor_enemy.h" #if TARGET_PC -#include "dusk/frame_interpolation.h" +#include "dusk/interp/frame_interpolation.h" #endif class daE_YD_HIO_c { @@ -78,12 +78,12 @@ static s32 leaf_anm_init(e_yd_class* i_this, int param_1, f32 param_2, u8 param_ } #if TARGET_PC -static void daE_YD_interp_callback(bool isSimFrame, void* pUserWork) { +static void daE_YD_interp_callback(void* pUserWork) { e_yd_class* i_this = (e_yd_class*)pUserWork; if (!i_this->mLineMatInterpPrevValid || !i_this->mLineMatInterpCurrValid) { return; } - const f32 alpha = dusk::frame_interp::get_interpolation_step(); + const f32 alpha = dusk::interp::get_interpolation_step(); cXyz* dst = i_this->mLineMat.getPos(0); for (int i = 0; i < 12; i++) { const cXyz& p0 = i_this->mLineMatInterpPrev[i]; @@ -107,14 +107,14 @@ static s32 daE_YD_Draw(e_yd_class* i_this) { i_this->mLineMat.update(12, l_color, &i_this->actor.tevStr); dComIfGd_set3DlineMat(&i_this->mLineMat); #if TARGET_PC - if (dusk::frame_interp::is_enabled()) { + if (dusk::interp::is_enabled()) { if (i_this->mLineMatInterpCurrValid) { memcpy(i_this->mLineMatInterpPrev, i_this->mLineMatInterpCurr, sizeof(i_this->mLineMatInterpCurr)); i_this->mLineMatInterpPrevValid = true; } memcpy(i_this->mLineMatInterpCurr, i_this->mLineMat.getPos(0), 12 * sizeof(cXyz)); i_this->mLineMatInterpCurrValid = true; - dusk::frame_interp::add_interpolation_callback(&daE_YD_interp_callback, i_this); + dusk::interp::add_interpolation_callback(&daE_YD_interp_callback, i_this); } #endif for (s32 i = 1; i < 11; i++) { diff --git a/src/d/actor/d_a_e_yg.cpp b/src/d/actor/d_a_e_yg.cpp index 71756d6f57..2267004353 100644 --- a/src/d/actor/d_a_e_yg.cpp +++ b/src/d/actor/d_a_e_yg.cpp @@ -10,10 +10,12 @@ #include "f_op/f_op_kankyo_mng.h" #include "d/actor/d_a_obj_carry.h" #include "Z2AudioLib/Z2Instances.h" -#include "dusk/frame_interpolation.h" -#include "dusk/settings.h" #include "f_op/f_op_actor_enemy.h" +#if TARGET_PC +#include "dusk/interp/frame_interpolation.h" +#endif + enum E_yg_RES_File_ID { /* BCK */ /* 0x04 */ BCK_YG_BITE_DIE = 0x4, @@ -137,13 +139,13 @@ static BOOL pl_check(e_yg_class* i_this, f32 i_dist) { } #if TARGET_PC -static void daE_YG_interp_callback(bool isSimFrame, void* pUserWork) { +static void daE_YG_interp_callback(void* pUserWork) { e_yg_class* i_this = (e_yg_class*)pUserWork; fopAc_ac_c* actor = (fopAc_ac_c*)&i_this->actor; if (!i_this->mTentacleInterpPrevValid || !i_this->mTentacleInterpCurrValid) { return; } - const f32 alpha = dusk::frame_interp::get_interpolation_step(); + const f32 alpha = dusk::interp::get_interpolation_step(); for (int s = 0; s < e_yg_class::TENTACLE_STRAND_COUNT; s++) { cXyz* dst = i_this->mLineMat.getPos(s); for (int i = 0; i < e_yg_class::TENTACLE_SEGMENT_COUNT; i++) { @@ -191,7 +193,7 @@ static int daE_YG_Draw(e_yg_class* i_this) { dComIfGd_set3DlineMatDark(&i_this->mLineMat); #if TARGET_PC - if (dusk::frame_interp::is_enabled()) { + if (dusk::interp::is_enabled()) { if (i_this->mTentacleInterpCurrValid) { memcpy(i_this->mTentacleInterpPrev, i_this->mTentacleInterpCurr, sizeof(i_this->mTentacleInterpCurr)); i_this->mTentacleInterpPrevValid = true; @@ -202,7 +204,7 @@ static int daE_YG_Draw(e_yg_class* i_this) { e_yg_class::TENTACLE_SEGMENT_COUNT * sizeof(cXyz)); } i_this->mTentacleInterpCurrValid = true; - dusk::frame_interp::add_interpolation_callback(&daE_YG_interp_callback, i_this); + dusk::interp::add_interpolation_callback(&daE_YG_interp_callback, i_this); } #endif diff --git a/src/d/actor/d_a_e_yh.cpp b/src/d/actor/d_a_e_yh.cpp index fb00a4bab1..137f87fc92 100644 --- a/src/d/actor/d_a_e_yh.cpp +++ b/src/d/actor/d_a_e_yh.cpp @@ -13,7 +13,7 @@ #include "f_op/f_op_kankyo_mng.h" #if TARGET_PC -#include "dusk/frame_interpolation.h" +#include "dusk/interp/frame_interpolation.h" #endif class daE_YH_HIO_c : public JORReflexible { @@ -90,12 +90,12 @@ static BOOL leaf_anm_init(e_yh_class* i_this, int param_2, f32 param_3, u8 param } #if TARGET_PC -static void daE_YH_interp_callback(bool isSimFrame, void* pUserWork) { +static void daE_YH_interp_callback(void* pUserWork) { e_yh_class* i_this = (e_yh_class*)pUserWork; if (!i_this->mLineInterpPrevValid || !i_this->mLineInterpCurrValid) { return; } - const f32 alpha = dusk::frame_interp::get_interpolation_step(); + const f32 alpha = dusk::interp::get_interpolation_step(); cXyz* dst = i_this->mLine.getPos(0); for (int i = 0; i < 12; i++) { const cXyz& p0 = i_this->mLineInterpPrev[i]; @@ -135,14 +135,14 @@ static int daE_YH_Draw(e_yh_class* i_this) { i_this->mLine.update(12, l_color, &a_this->tevStr); dComIfGd_set3DlineMat(&i_this->mLine); #if TARGET_PC - if (dusk::frame_interp::is_enabled()) { + if (dusk::interp::is_enabled()) { if (i_this->mLineInterpCurrValid) { memcpy(i_this->mLineInterpPrev, i_this->mLineInterpCurr, sizeof(i_this->mLineInterpCurr)); i_this->mLineInterpPrevValid = true; } memcpy(i_this->mLineInterpCurr, i_this->mLine.getPos(0), 12 * sizeof(cXyz)); i_this->mLineInterpCurrValid = true; - dusk::frame_interp::add_interpolation_callback(&daE_YH_interp_callback, i_this); + dusk::interp::add_interpolation_callback(&daE_YH_interp_callback, i_this); } #endif diff --git a/src/d/actor/d_a_horse.cpp b/src/d/actor/d_a_horse.cpp index 72b1fb1e7b..76cd1404eb 100644 --- a/src/d/actor/d_a_horse.cpp +++ b/src/d/actor/d_a_horse.cpp @@ -21,8 +21,7 @@ #include #if TARGET_PC -#include "dusk/dusk.h" -#include "dusk/frame_interpolation.h" +#include "dusk/interp/frame_interpolation.h" namespace { // FRAME INTERP NOTE: Sim tick control point snapshots for interpolation @@ -3035,7 +3034,7 @@ void daHorse_c::copyReinPos() { } #if TARGET_PC if (field_0x1204 > 0) { - const uint64_t simSeq = dusk::frame_interp::sim_tick_seq(); + const uint64_t simSeq = dusk::interp::sim_tick_seq(); if (simSeq != s_horseReinSimRolledSeq) { s_horseReinSimRolledSeq = simSeq; if (s_horseReinSimCurrValid && s_horseReinSimNumCurr > 0) { @@ -3165,7 +3164,7 @@ void daHorse_c::setReinPosNormalSubstance() { #if TARGET_PC void daHorse_c::lerpControlPoints(f32 alpha) { // FRAME INTERP NOTE: Currently only lerping points for Epona's reins. Need a more global solution. - if (!dusk::frame_interp::is_enabled() || !s_horseReinSimPrevValid || !s_horseReinSimCurrValid) { + if (!dusk::interp::is_enabled() || !s_horseReinSimPrevValid || !s_horseReinSimCurrValid) { return; } const int nCurr = s_horseReinSimNumCurr; diff --git a/src/d/actor/d_a_mant.cpp b/src/d/actor/d_a_mant.cpp index 3f9c2deae1..4f175e794f 100644 --- a/src/d/actor/d_a_mant.cpp +++ b/src/d/actor/d_a_mant.cpp @@ -12,7 +12,7 @@ #if TARGET_PC #include "dusk/dvd_asset.hpp" -#include "dusk/frame_interpolation.h" +#include "dusk/interp/frame_interpolation.h" #include @@ -212,8 +212,8 @@ void daMant_packet_c::draw() { MtxP src25 = model->getAnmMtx(25); Mtx joint_34_scratch; Mtx joint_25_scratch; - MtxP joint_34 = dusk::frame_interp::lookup_replacement(src34, joint_34_scratch) ? joint_34_scratch : src34; - MtxP joint_25 = dusk::frame_interp::lookup_replacement(src25, joint_25_scratch) ? joint_25_scratch : src25; + MtxP joint_34 = dusk::interp::lookup_replacement(src34, joint_34_scratch) ? joint_34_scratch : src34; + MtxP joint_25 = dusk::interp::lookup_replacement(src25, joint_25_scratch) ? joint_25_scratch : src25; cXyz presented_anchor_a; cXyz presented_anchor_b; @@ -232,7 +232,7 @@ void daMant_packet_c::draw() { } } - const f32 step = dusk::frame_interp::get_interpolation_step(); + const f32 step = dusk::interp::get_interpolation_step(); for (int i = 0; i < 169; ++i) { cXyz curr_local; MTXMultVec(curr_frame_inverse, &curr_pos[i], &curr_local); diff --git a/src/d/actor/d_a_mg_rod.cpp b/src/d/actor/d_a_mg_rod.cpp index 6cf1e76024..07d6b7b10c 100644 --- a/src/d/actor/d_a_mg_rod.cpp +++ b/src/d/actor/d_a_mg_rod.cpp @@ -26,7 +26,7 @@ #include #if TARGET_PC -#include "dusk/frame_interpolation.h" +#include "dusk/interp/frame_interpolation.h" #include "dusk/mods/item.hpp" #include "dusk/settings.h" #include "dusk/version.hpp" @@ -184,12 +184,12 @@ static int Worm_nodeCallBack(J3DJoint* i_joint, int param_1) { } #if TARGET_PC -static void dmg_rod_interp_callback(bool isSimFrame, void* pUserWork) { +static void dmg_rod_interp_callback(void* pUserWork) { dmg_rod_class* i_this = (dmg_rod_class*)pUserWork; if (!i_this->mLineInterpPrevValid || !i_this->mLineInterpCurrValid) { return; } - const f32 alpha = dusk::frame_interp::get_interpolation_step(); + const f32 alpha = dusk::interp::get_interpolation_step(); const int count = i_this->kind == MG_ROD_KIND_LURE ? MG_ROD_LURE_LINE_LEN : MG_ROD_UKI_LINE_LEN; cXyz* dst = i_this->linemat.getPos(0); for (int i = 0; i < count; i++) { @@ -243,14 +243,14 @@ static int dmg_rod_Draw(dmg_rod_class* i_this) { dComIfGd_set3DlineMat(&i_this->linemat); #if TARGET_PC - if (dusk::frame_interp::is_enabled()) { + if (dusk::interp::is_enabled()) { if (i_this->mLineInterpCurrValid) { memcpy(i_this->mLineInterpPrev, i_this->mLineInterpCurr, MG_ROD_LURE_LINE_LEN * sizeof(cXyz)); i_this->mLineInterpPrevValid = true; } memcpy(i_this->mLineInterpCurr, i_this->linemat.getPos(0), MG_ROD_LURE_LINE_LEN * sizeof(cXyz)); i_this->mLineInterpCurrValid = true; - dusk::frame_interp::add_interpolation_callback(&dmg_rod_interp_callback, i_this); + dusk::interp::add_interpolation_callback(&dmg_rod_interp_callback, i_this); } #endif @@ -279,14 +279,14 @@ static int dmg_rod_Draw(dmg_rod_class* i_this) { dComIfGd_set3DlineMat(&i_this->linemat); #if TARGET_PC - if (dusk::frame_interp::is_enabled()) { + if (dusk::interp::is_enabled()) { if (i_this->mLineInterpCurrValid) { memcpy(i_this->mLineInterpPrev, i_this->mLineInterpCurr, MG_ROD_UKI_LINE_LEN * sizeof(cXyz)); i_this->mLineInterpPrevValid = true; } memcpy(i_this->mLineInterpCurr, i_this->linemat.getPos(0), MG_ROD_UKI_LINE_LEN * sizeof(cXyz)); i_this->mLineInterpCurrValid = true; - dusk::frame_interp::add_interpolation_callback(&dmg_rod_interp_callback, i_this); + dusk::interp::add_interpolation_callback(&dmg_rod_interp_callback, i_this); } #endif diff --git a/src/d/actor/d_a_midna.cpp b/src/d/actor/d_a_midna.cpp index 47d3da98c8..794dbe1d64 100644 --- a/src/d/actor/d_a_midna.cpp +++ b/src/d/actor/d_a_midna.cpp @@ -16,7 +16,7 @@ #include "d/d_debug_viewer.h" #if TARGET_PC -#include "dusk/frame_interpolation.h" +#include "dusk/interp/frame_interpolation.h" #endif static f32 dummy_lit_3777(int idx, u8 foo) { @@ -1110,10 +1110,10 @@ void daMidna_c::setBodyPartMatrix() { mpModel->setAnmMtx(i, mpShadowModel->getAnmMtx(i)); } mpModel->calcWeightEnvelopeMtx(); -#ifdef TARGET_PC +#if TARGET_PC // FRAME INTERP NOTE: Record weight envelopes for Midna here, as they are otherwise missed causing distortion for (u16 i = 0; i < mpModel->getModelData()->getWEvlpMtxNum(); i++) { - dusk::frame_interp::record_final_mtx(mpModel->getWeightAnmMtx(i)); + dusk::interp::record_final_mtx(mpModel->getWeightAnmMtx(i)); } #endif } diff --git a/src/d/actor/d_a_mirror.cpp b/src/d/actor/d_a_mirror.cpp index d02d81d834..123279e8af 100644 --- a/src/d/actor/d_a_mirror.cpp +++ b/src/d/actor/d_a_mirror.cpp @@ -14,10 +14,6 @@ #include #include "m_Do/m_Do_lib.h" -#if TARGET_PC -#include "dusk/frame_interpolation.h" -#endif - static BOOL daMirror_c_createHeap(fopAc_ac_c* i_this) { return ((daMirror_c*)i_this)->createHeap(); } diff --git a/src/d/actor/d_a_npc_ne.cpp b/src/d/actor/d_a_npc_ne.cpp index de48a76851..530654400f 100644 --- a/src/d/actor/d_a_npc_ne.cpp +++ b/src/d/actor/d_a_npc_ne.cpp @@ -21,7 +21,7 @@ #include #if TARGET_PC -#include "dusk/frame_interpolation.h" +#include "dusk/interp/frame_interpolation.h" #endif static home_path_pnt home_path[38] = { @@ -2659,7 +2659,7 @@ static void demo_camera(npc_ne_class* i_this) { i_this->mCameraFovY = 55.0f; camera->mCamera.SetTrimSize(3); daPy_getPlayerActorClass()->changeOriginalDemo(); - IF_DUSK(dusk::frame_interp::request_presentation_sync()); + IF_DUSK(dusk::interp::request_presentation_sync()); // fallthrough case 2: @@ -2688,7 +2688,7 @@ static void demo_camera(npc_ne_class* i_this) { if (i_this->mDemoCounter == 0) { i_this->mCameraCenter1.set(387.0f, 133.0f, -866.0f); i_this->mCameraEye1.set(284.0f, 208.0f, -585.0f); - IF_DUSK(dusk::frame_interp::request_presentation_sync()); + IF_DUSK(dusk::interp::request_presentation_sync()); } if (i_this->mDemoCounter == 12) { @@ -2725,7 +2725,7 @@ static void demo_camera(npc_ne_class* i_this) { i_this->mCameraFovY = 45.0f; camera->mCamera.SetTrimSize(3); daPy_getPlayerActorClass()->changeOriginalDemo(); - IF_DUSK(dusk::frame_interp::request_presentation_sync()); + IF_DUSK(dusk::interp::request_presentation_sync()); // fallthrough case 11: @@ -2806,10 +2806,10 @@ static void demo_camera(npc_ne_class* i_this) { MtxPosition(&vec, &i_this->mCameraEye2); i_this->mCameraEye2 += player->current.pos; player->changeDemoParam2(2); - IF_DUSK(dusk::frame_interp::request_presentation_sync()); + IF_DUSK(dusk::interp::request_presentation_sync()); } else if (i_this->mDemoCounter == 120) { player->changeDemoParam2(0); - IF_DUSK(dusk::frame_interp::request_presentation_sync()); + IF_DUSK(dusk::interp::request_presentation_sync()); } } } @@ -2862,7 +2862,7 @@ static void demo_camera(npc_ne_class* i_this) { i_this->mCameraCenter1 = _this->current.pos; i_this->mCameraCenter1.y += 20.0f; i_this->mCameraFovY = 55.0f; - IF_DUSK(dusk::frame_interp::request_presentation_sync()); + IF_DUSK(dusk::interp::request_presentation_sync()); } camera->mCamera.Set(i_this->mCameraCenter1, i_this->mCameraEye1, diff --git a/src/d/actor/d_a_npc_toby.cpp b/src/d/actor/d_a_npc_toby.cpp index 120cfac318..d42787e2a2 100644 --- a/src/d/actor/d_a_npc_toby.cpp +++ b/src/d/actor/d_a_npc_toby.cpp @@ -17,7 +17,7 @@ #include #if TARGET_PC -#include "dusk/frame_interpolation.h" +#include "dusk/interp/frame_interpolation.h" #endif DUSK_GAME_DATA const daNpc_Toby_HIOParam daNpc_Toby_Param_c::m = { @@ -1402,7 +1402,7 @@ int daNpc_Toby_c::cutRepairSCannon(int arg0) { old.pos = current.pos; setAngle(cM_deg2s(5.0f * f32(mPath.getArg0()))); mEventTimer = mPath.getArg2(); - IF_DUSK(dusk::frame_interp::request_presentation_sync()); + IF_DUSK(dusk::interp::request_presentation_sync()); } } else if (!mHide) { mHide = 1; diff --git a/src/d/actor/d_a_npc_zra.cpp b/src/d/actor/d_a_npc_zra.cpp index 9d97a3ac2c..f77200c514 100644 --- a/src/d/actor/d_a_npc_zra.cpp +++ b/src/d/actor/d_a_npc_zra.cpp @@ -20,6 +20,10 @@ #include "d/actor/d_a_obj_zraMark.h" #include +#if TARGET_PC +#include "dusk/interp/frame_interpolation.h" +#endif + static NPC_ZRA_HIO_CLASS l_HIO; DUSK_GAME_DATA daNpc_zrA_HIOParam const daNpc_zrA_Param_c::m = { @@ -686,6 +690,69 @@ int daNpc_zrA_c::Execute() { return execute(); } +#if TARGET_PC +void daNpc_zrA_interp_callback(void* pUserWork) { + daNpc_zrA_c* i_this = static_cast(pUserWork); + if (i_this == NULL || i_this->mAnm_p == NULL || i_this->checkHide()) { + return; + } + + J3DModel* model = i_this->mAnm_p->getModel(); + if (model == NULL) { + return; + } + + J3DModelData* model_data = model->getModelData(); + model_data->getMaterialNodePointer(1)->setMaterialAnm(i_this->mpMatAnm); + + if (i_this->mTwilight) { + g_env_light.settingTevStruct(4, &i_this->current.pos, &i_this->tevStr); + } else { + g_env_light.settingTevStruct(0, &i_this->current.pos, &i_this->tevStr); + } + g_env_light.setLightTevColorType_MAJI(model, &i_this->tevStr); + + if (i_this->mWaterAnmFlags & daNpcF_c::ANM_PLAY_BTK) { + i_this->mWaterBtkAnm.entry(model_data); + } + if (i_this->mWaterAnmFlags & daNpcF_c::ANM_PLAY_BPK) { + i_this->mWaterBpkAnm.entry(model_data); + } + if (i_this->mAnmFlags & daNpcF_c::ANM_PLAY_BTP) { + i_this->mBtpAnm.entry(model_data); + } + if (i_this->mAnmFlags & daNpcF_c::ANM_PLAY_BTK) { + i_this->mBtkAnm.entry(model_data); + } + if (i_this->mAnmFlags & daNpcF_c::ANM_PLAY_BRK) { + i_this->mBrkAnm.entry(model_data); + } + + if (!i_this->mHide && !i_this->mTwilight) { + fopAcM_setEffectMtx(i_this, model_data); + } + + model->calcMaterial(); + model->diff(); + + if (i_this->mAnmFlags & daNpcF_c::ANM_PLAY_BTP) { + i_this->mBtpAnm.remove(model_data); + } + if (i_this->mAnmFlags & daNpcF_c::ANM_PLAY_BTK) { + i_this->mBtkAnm.remove(model_data); + } + if (i_this->mAnmFlags & daNpcF_c::ANM_PLAY_BRK) { + i_this->mBrkAnm.remove(model_data); + } + if (i_this->mWaterAnmFlags & daNpcF_c::ANM_PLAY_BPK) { + i_this->mWaterBpkAnm.remove(model_data); + } + if (i_this->mWaterAnmFlags & daNpcF_c::ANM_PLAY_BTK) { + i_this->mWaterBtkAnm.remove(model_data); + } +} +#endif + int daNpc_zrA_c::Draw() { BOOL bvar2 = false; J3DModel* model = mAnm_p->getModel(); @@ -737,6 +804,8 @@ int daNpc_zrA_c::Draw() { mAnm_p->entryDL(); } + IF_DUSK(dusk::interp::add_interpolation_callback(&daNpc_zrA_interp_callback, this)); + if (mAnmFlags & ANM_PLAY_BTP) { mBtpAnm.remove(model_data); } diff --git a/src/d/actor/d_a_obj_fchain.cpp b/src/d/actor/d_a_obj_fchain.cpp index b4d473c424..305a57ae34 100644 --- a/src/d/actor/d_a_obj_fchain.cpp +++ b/src/d/actor/d_a_obj_fchain.cpp @@ -10,10 +10,12 @@ #include "JSystem/J3DGraphBase/J3DDrawBuffer.h" #include "SSystem/SComponent/c_math.h" #include "d/d_com_inf_game.h" -#include "dusk/frame_interpolation.h" -#include "dusk/settings.h" #include +#if TARGET_PC +#include "dusk/interp/frame_interpolation.h" +#endif + static char const l_arcName[] = "Fchain"; int daObjFchain_c::createHeap() { @@ -296,7 +298,7 @@ void daObjFchain_shape_c::draw() { } #if TARGET_PC -static void fchain_interp_callback(bool isSimFrame, void* pUserWork) { +static void fchain_interp_callback(void* pUserWork) { static_cast(pUserWork)->onInterpCallback(); } @@ -305,7 +307,7 @@ void daObjFchain_c::onInterpCallback() { return; } - const f32 alpha = dusk::frame_interp::get_interpolation_step(); + const f32 alpha = dusk::interp::get_interpolation_step(); for (int i = 0; i < CHAIN_COUNT; i++) { const cXyz& p0 = mChainInterpPrev[i]; @@ -325,7 +327,7 @@ int daObjFchain_c::draw() { dComIfGd_getOpaListDark()->entryImm(&mShape, 0); #if TARGET_PC - if (dusk::frame_interp::is_enabled()) { + if (dusk::interp::is_enabled()) { if (mChainInterpCurrValid) { memcpy(mChainInterpPrev, mChainInterpCurr, sizeof(mChainInterpCurr)); mChainInterpPrevValid = true; @@ -333,7 +335,7 @@ int daObjFchain_c::draw() { memcpy(mChainInterpCurr, field_0x694, sizeof(mChainInterpCurr)); mChainInterpCurrValid = true; - dusk::frame_interp::add_interpolation_callback(&fchain_interp_callback, this); + dusk::interp::add_interpolation_callback(&fchain_interp_callback, this); } #endif } diff --git a/src/d/actor/d_a_obj_item.cpp b/src/d/actor/d_a_obj_item.cpp index e06eb37e50..9fbbb53738 100644 --- a/src/d/actor/d_a_obj_item.cpp +++ b/src/d/actor/d_a_obj_item.cpp @@ -17,7 +17,7 @@ #include "m_Do/m_Do_mtx.h" #if TARGET_PC -#include "dusk/frame_interpolation.h" +#include "dusk/interp/frame_interpolation.h" #endif static f32 Reflect(cXyz* i_vec, cBgS_PolyInfo const& i_polyinfo, f32 i_scale) { @@ -36,7 +36,7 @@ static f32 Reflect(cXyz* i_vec, cBgS_PolyInfo const& i_polyinfo, f32 i_scale) { } #if TARGET_PC -static void d_a_obj_item_interp_callback(bool isSimFrame, void* pUserWork) { +static void d_a_obj_item_interp_callback(void* pUserWork) { daItem_c* item = static_cast(pUserWork); if (item == NULL || item->mpModel == NULL || !item->chkDraw()) { return; @@ -412,7 +412,7 @@ int daItem_c::_daItem_draw() { } #if TARGET_PC - dusk::frame_interp::add_interpolation_callback(&d_a_obj_item_interp_callback, this); + dusk::interp::add_interpolation_callback(&d_a_obj_item_interp_callback, this); #endif if (chkDraw()) { diff --git a/src/d/actor/d_a_obj_keyhole.cpp b/src/d/actor/d_a_obj_keyhole.cpp index d56f39f40b..68df1e1784 100644 --- a/src/d/actor/d_a_obj_keyhole.cpp +++ b/src/d/actor/d_a_obj_keyhole.cpp @@ -10,8 +10,9 @@ #include "d/d_s_play.h" #include "d/actor/d_a_player.h" #include "Z2AudioLib/Z2Instances.h" + #if TARGET_PC -#include "dusk/frame_interpolation.h" +#include "dusk/interp/frame_interpolation.h" #endif daObj_Keyhole_HIO_c::daObj_Keyhole_HIO_c() { @@ -57,8 +58,8 @@ static int daObj_Keyhole_Draw(obj_keyhole_class* i_this) { kh_chain_s* chain_s = &i_this->chain_s[i]; for (int j = 0; j < i_this->chain_num; j++) { #if TARGET_PC - if (dusk::frame_interp::is_enabled() && i_this->mChainInterpPrevValid && i_this->mChainInterpCurrValid) { - const f32 alpha = dusk::frame_interp::get_interpolation_step(); + if (dusk::interp::is_enabled() && i_this->mChainInterpPrevValid && i_this->mChainInterpCurrValid) { + const f32 alpha = dusk::interp::get_interpolation_step(); Mtx mtx; const f32* p0 = (const f32*)i_this->mChainInterpPrev[i][j]; const f32* p1 = (const f32*)i_this->mChainInterpCurr[i][j]; @@ -390,7 +391,7 @@ static void chain_move(obj_keyhole_class* i_this) { } #if TARGET_PC - if (dusk::frame_interp::is_enabled()) { + if (dusk::interp::is_enabled()) { if (i_this->mChainInterpCurrValid) { memcpy(i_this->mChainInterpPrev, i_this->mChainInterpCurr, sizeof(i_this->mChainInterpCurr)); i_this->mChainInterpPrevValid = true; diff --git a/src/d/actor/d_a_obj_klift00.cpp b/src/d/actor/d_a_obj_klift00.cpp index fbccb64edb..8b9d485869 100644 --- a/src/d/actor/d_a_obj_klift00.cpp +++ b/src/d/actor/d_a_obj_klift00.cpp @@ -11,8 +11,10 @@ #include "d/d_bg_w.h" #include "d/d_cc_uty.h" #include "d/d_com_inf_game.h" -#include "dusk/frame_interpolation.h" -#include "dusk/settings.h" + +#if TARGET_PC +#include "dusk/interp/frame_interpolation.h" +#endif struct daObjKLift00_HIO_c : public mDoHIO_entry_c { daObjKLift00_HIO_c(); @@ -444,7 +446,7 @@ int daObjKLift00_c::Execute(Mtx** i_mtx) { } #if TARGET_PC -static void klift00_interp_callback(bool isSimFrame, void* pUserWork) { +static void klift00_interp_callback(void* pUserWork) { static_cast(pUserWork)->onInterpCallback(); } @@ -453,7 +455,7 @@ void daObjKLift00_c::onInterpCallback() { return; } - const f32 alpha = dusk::frame_interp::get_interpolation_step(); + const f32 alpha = dusk::interp::get_interpolation_step(); cXyz savedPositions[64]; for (int i = 0; i < mNumChains; i++) { @@ -493,7 +495,7 @@ int daObjKLift00_c::Draw() { dComIfGd_setList(); #if TARGET_PC - if (dusk::frame_interp::is_enabled()) { + if (dusk::interp::is_enabled()) { if (mChainInterpCurrValid) { memcpy(mChainInterpPrev, mChainInterpCurr, mNumChains * sizeof(cXyz)); mChainInterpPrevValid = true; @@ -504,7 +506,7 @@ int daObjKLift00_c::Draw() { } mChainInterpCurrValid = true; - dusk::frame_interp::add_interpolation_callback(&klift00_interp_callback, this); + dusk::interp::add_interpolation_callback(&klift00_interp_callback, this); } #endif diff --git a/src/d/actor/d_a_obj_lv8Lift.cpp b/src/d/actor/d_a_obj_lv8Lift.cpp index 9ac8206f6b..b77e098487 100644 --- a/src/d/actor/d_a_obj_lv8Lift.cpp +++ b/src/d/actor/d_a_obj_lv8Lift.cpp @@ -11,7 +11,7 @@ #include "d/d_bg_w.h" #if TARGET_PC -#include "dusk/frame_interpolation.h" +#include "dusk/interp/frame_interpolation.h" #endif daL8Lift_HIO_c::daL8Lift_HIO_c() { @@ -385,7 +385,7 @@ void daL8Lift_c::setNextPoint() { } #if TARGET_PC -void daL8Lift_interp_callback(bool isSimFrame, void* pUserWork) { +void daL8Lift_interp_callback(void* pUserWork) { daL8Lift_c* lift = static_cast(pUserWork); if (lift == NULL || lift->mpModel == NULL) { return; @@ -419,7 +419,7 @@ void daL8Lift_interp_callback(bool isSimFrame, void* pUserWork) { int daL8Lift_c::Draw() { #if TARGET_PC - dusk::frame_interp::add_interpolation_callback(&daL8Lift_interp_callback, this); + dusk::interp::add_interpolation_callback(&daL8Lift_interp_callback, this); #endif g_env_light.settingTevStruct(16, ¤t.pos, &tevStr); diff --git a/src/d/actor/d_a_obj_lv8OptiLift.cpp b/src/d/actor/d_a_obj_lv8OptiLift.cpp index e367b89b36..b63b0979f8 100644 --- a/src/d/actor/d_a_obj_lv8OptiLift.cpp +++ b/src/d/actor/d_a_obj_lv8OptiLift.cpp @@ -12,7 +12,7 @@ #include "d/d_path.h" #if TARGET_PC -#include "dusk/frame_interpolation.h" +#include "dusk/interp/frame_interpolation.h" #endif daOptiLift_HIO_c::daOptiLift_HIO_c() { @@ -417,7 +417,7 @@ void daOptiLift_c::setNextPoint() { } #if TARGET_PC -static void daOptiLift_interp_callback(bool isSimFrame, void* pUserWork) { +static void daOptiLift_interp_callback(void* pUserWork) { daOptiLift_c* lift = static_cast(pUserWork); if (lift == NULL || lift->mpModel == NULL) { return; @@ -451,7 +451,7 @@ static void daOptiLift_interp_callback(bool isSimFrame, void* pUserWork) { int daOptiLift_c::Draw() { #if TARGET_PC - dusk::frame_interp::add_interpolation_callback(&daOptiLift_interp_callback, this); + dusk::interp::add_interpolation_callback(&daOptiLift_interp_callback, this); #endif g_env_light.settingTevStruct(0x10, ¤t.pos, &tevStr); diff --git a/src/d/actor/d_a_title.cpp b/src/d/actor/d_a_title.cpp index fd550070f3..0d011f9213 100644 --- a/src/d/actor/d_a_title.cpp +++ b/src/d/actor/d_a_title.cpp @@ -19,7 +19,7 @@ #include "m_Do/m_Do_graphic.h" #if TARGET_PC -#include "dusk/frame_interpolation.h" +#include "dusk/interp/frame_interpolation.h" #include "dusk/version.hpp" #endif @@ -169,7 +169,7 @@ int daTitle_c::Execute() { } #ifdef TARGET_PC - if (!dusk::frame_interp::is_enabled()) { + if (!dusk::interp::is_enabled()) { #endif dMenu_Collect3D_c::setViewPortOffsetY(0.0f); #ifdef TARGET_PC @@ -352,7 +352,7 @@ void daTitle_c::fastLogoDispInit() { mWaitTimer = 30; mProcID = 5; - IF_DUSK(dusk::frame_interp::request_presentation_sync()); + IF_DUSK(dusk::interp::request_presentation_sync()); } void daTitle_c::fastLogoDisp() { diff --git a/src/d/actor/d_flower.inc b/src/d/actor/d_flower.inc index 91eba47906..e42cc7ded0 100644 --- a/src/d/actor/d_flower.inc +++ b/src/d/actor/d_flower.inc @@ -6,7 +6,7 @@ #include "SSystem/SComponent/c_counter.h" #if TARGET_PC -#include "dusk/frame_interpolation.h" +#include "dusk/interp/frame_interpolation.h" #endif const u16 l_J_Ohana00_64TEX__width = 63; @@ -1165,16 +1165,12 @@ void dFlower_packet_c::draw() { GXSetChanAmbColor(GX_COLOR0A0, sp64); if (!cLib_checkBit(sp44->m_state, 4) && !cLib_checkBit(sp44->m_state, 0x40)) { -#ifdef TARGET_PC - Mtx flower_mtx; - if (dusk::frame_interp::lookup_replacement(&sp44->m_modelMtx, flower_mtx)) { - cMtx_concat(j3dSys.getViewMtx(), flower_mtx, flower_mtx); - GXLoadPosMtxImm(flower_mtx, 0); - } else +#if TARGET_PC + Mtx flowerMtx; + GXLoadPosMtxImm(get_model_mtx(sp44->m_modelMtx, flowerMtx), 0); +#else + GXLoadPosMtxImm(sp44->m_modelMtx, 0); #endif - { - GXLoadPosMtxImm(sp44->m_modelMtx, 0); - } GXLoadNrmMtxImm(j3dSys.getViewMtx(), 0); #if TARGET_PC @@ -1324,16 +1320,12 @@ void dFlower_packet_c::draw() { sp30++; if (!cLib_checkBit(sp34->m_state, 4) && cLib_checkBit(sp34->m_state, 0x40)) { -#ifdef TARGET_PC - Mtx flower_mtx; - if (dusk::frame_interp::lookup_replacement(&sp34->m_modelMtx, flower_mtx)) { - cMtx_concat(j3dSys.getViewMtx(), flower_mtx, flower_mtx); - GXLoadPosMtxImm(flower_mtx, 0); - } else +#if TARGET_PC + Mtx flowerMtx; + GXLoadPosMtxImm(get_model_mtx(sp34->m_modelMtx, flowerMtx), 0); +#else + GXLoadPosMtxImm(sp34->m_modelMtx, 0); #endif - { - GXLoadPosMtxImm(sp34->m_modelMtx, 0); - } GXLoadNrmMtxImm(j3dSys.getViewMtx(), 0); #if TARGET_PC GXLoadTexObj(&mTexObj_l_J_Ohana01_64128_0419TEX, GX_TEXMAP0); @@ -1463,9 +1455,13 @@ void dFlower_packet_c::update() { mDoMtx_stack_c::copy(temp_r28); mDoMtx_stack_c::scaleM(temp_f31, temp_f31, temp_f31); +#if TARGET_PC + cMtx_copy(temp_r28, data_p->m_modelMtx); +#else cMtx_concat(j3dSys.getViewMtx(), temp_r28, data_p->m_modelMtx); +#endif #ifdef TARGET_PC - dusk::frame_interp::record_final_mtx(temp_r28, data_p->m_modelMtx); + dusk::interp::record_final_mtx(temp_r28, data_p->m_modelMtx); #endif } } diff --git a/src/d/actor/d_grass.inc b/src/d/actor/d_grass.inc index 780a7a052d..fd911083f4 100644 --- a/src/d/actor/d_grass.inc +++ b/src/d/actor/d_grass.inc @@ -13,7 +13,7 @@ #if TARGET_PC #include "dusk/dvd_asset.hpp" -#include "dusk/frame_interpolation.h" +#include "dusk/interp/frame_interpolation.h" using GameVersion = dusk::version::GameVersion; @@ -608,11 +608,12 @@ dGrass_packet_c::dGrass_packet_c() { #if TARGET_PC static MtxP get_model_mtx(Mtx modelMtx, Mtx storage) { - if (dusk::frame_interp::lookup_replacement(modelMtx, storage)) { + if (dusk::interp::lookup_replacement(modelMtx, storage)) { cMtx_concat(j3dSys.getViewMtx(), storage, storage); - return storage; + } else { + cMtx_concat(j3dSys.getViewMtx(), modelMtx, storage); } - return modelMtx; + return storage; } static void transform_positions( @@ -1193,16 +1194,12 @@ void dGrass_packet_c::draw() { GXSetChanAmbColor(GX_COLOR0A0, sp38); if (!cLib_checkBit(var_r29->field_0x01, 2)) { -#ifdef TARGET_PC - Mtx grass_mtx; - if (dusk::frame_interp::lookup_replacement(reinterpret_cast(&var_r29->m_modelMtx), grass_mtx)) { - cMtx_concat(j3dSys.getViewMtx(), grass_mtx, grass_mtx); - GXLoadPosMtxImm(grass_mtx, 0); - } else +#if TARGET_PC + Mtx grassMtx; + GXLoadPosMtxImm(get_model_mtx(var_r29->m_modelMtx, grassMtx), 0); +#else + GXLoadPosMtxImm(var_r29->m_modelMtx, 0); #endif - { - GXLoadPosMtxImm(var_r29->m_modelMtx, 0); - } GXLoadNrmMtxImm(j3dSys.getViewMtx(), 0); if (var_r29->field_0x05 <= 3 || var_r29->field_0x05 >= 10) { if (var_r29->field_0x02 < -1) { @@ -1445,7 +1442,11 @@ void dGrass_packet_c::update() { } } +#if TARGET_PC + cMtx_copy(mDoMtx_stack_c::get(), data_p->m_modelMtx); +#else cMtx_concat(j3dSys.getViewMtx(), mDoMtx_stack_c::get(), data_p->m_modelMtx); +#endif } else { mDoMtx_stack_c::transS(data_p->m_pos.x, data_p->m_pos.y, data_p->m_pos.z); mDoMtx_stack_c::YrotM(i * 3535); @@ -1456,11 +1457,13 @@ void dGrass_packet_c::update() { f32 scale = ((((s16)data_p->m_pos.x * 3535) & 0xFFF) / 4096.0f) * 0.3f + 0.7f; mDoMtx_stack_c::scaleM(scale, scale, scale); +#if TARGET_PC + cMtx_copy(mDoMtx_stack_c::get(), data_p->m_modelMtx); +#else cMtx_concat(j3dSys.getViewMtx(), mDoMtx_stack_c::get(), data_p->m_modelMtx); - } -#ifdef TARGET_PC - dusk::frame_interp::record_final_mtx(mDoMtx_stack_c::get(), data_p->m_modelMtx); #endif + } + IF_DUSK(dusk::interp::record_final_mtx(mDoMtx_stack_c::get(), data_p->m_modelMtx)); } } data_p++; diff --git a/src/d/d_camera.cpp b/src/d/d_camera.cpp index 9bb5b6f383..feb7148cc0 100644 --- a/src/d/d_camera.cpp +++ b/src/d/d_camera.cpp @@ -32,7 +32,9 @@ #include "dusk/action_bindings.h" #include "dusk/camera_operators.hpp" #include "dusk/commands.hpp" -#include "dusk/frame_interpolation.h" +#include "dusk/game_clock.h" +#include "dusk/interp/camera.h" +#include "dusk/interp/frame_interpolation.h" #include "dusk/logging.h" #include "dusk/mouse.h" #include "dusk/settings.h" @@ -10503,13 +10505,13 @@ bool dCamera_c::eventCamera(s32 param_0) { #endif #if TARGET_PC - if (dusk::frame_interp::is_enabled()) { + if (dusk::interp::is_enabled()) { switch (var_r29) { case 3: case 4: case 5: case 12: - dusk::frame_interp::request_presentation_sync(); + dusk::interp::request_presentation_sync(); break; default: DuskLog.debug( @@ -11359,7 +11361,7 @@ void widezoom_correction(camera_process_class* i_this, float trim_height) { trim_width = FB_WIDTH_BASE / 2.0f * (1.0f - target_ar_real / current_ar); } - if (dusk::frame_interp::is_sim_frame()) { + if (dusk::game_clock::is_sim_frame()) { constexpr auto base_ar = static_cast(FB_WIDTH_BASE) / static_cast(FB_HEIGHT_BASE); const auto ar_corr = base_ar / std::min(current_ar, target_ar_real); @@ -11397,8 +11399,8 @@ static int camera_execute(camera_process_class* i_this) { #ifdef TARGET_PC widezoom_correction(i_this, i_this->mCamera.TrimHeight()); - if (dusk::frame_interp::is_enabled()) { - dusk::frame_interp::add_interpolation_callback([](bool _, void* pUserWork) { + if (dusk::interp::is_enabled()) { + dusk::interp::add_interpolation_callback([](void* pUserWork) { const auto i_this = static_cast(pUserWork); const auto camera = &i_this->mCamera; @@ -11407,7 +11409,7 @@ static int camera_execute(camera_process_class* i_this) { if (camera->mCurState != 2 && trim_size >= 0 && trim_size <= 3) { // derive trim height at previous tick using current camera state const auto target = get_target_trim_height(i_this); - const auto step = dusk::frame_interp::get_interpolation_step(); + const auto step = dusk::interp::get_interpolation_step(); const auto cur = camera->TrimHeight(); const auto prev = (4.0f * cur - target) / 3.0f; const auto trim_height = prev + (cur - prev) * step; @@ -11418,10 +11420,10 @@ static int camera_execute(camera_process_class* i_this) { } // record new camera for our sim frame - dusk::frame_interp::record_camera(i_this, get_camera_id(i_this)); + dusk::interp::record_camera(i_this, get_camera_id(i_this)); // interpolate the view now so that this sim frame's view matrix matches what // we'll be rendering with later - dusk::frame_interp::interp_view(&i_this->view); + dusk::interp::interp_view(&i_this->view); #endif view_setup(i_this); diff --git a/src/d/d_drawlist.cpp b/src/d/d_drawlist.cpp index fd1a82ba2f..693b47eed3 100644 --- a/src/d/d_drawlist.cpp +++ b/src/d/d_drawlist.cpp @@ -14,7 +14,8 @@ #include "m_Do/m_Do_mtx.h" #if TARGET_PC -#include "dusk/frame_interpolation.h" +#include "dusk/game_clock.h" +#include "dusk/interp/frame_interpolation.h" #include "dusk/logging.h" #include "helpers/gx_helper.h" @@ -1081,7 +1082,7 @@ void dDlst_shadowReal_c::reset() { void dDlst_shadowReal_c::imageDraw(Mtx param_0) { #ifdef TARGET_PC Mtx render_proj_mtx; - if (dusk::frame_interp::lookup_replacement(getInterpKey(mpModels[0], 2), render_proj_mtx)) { + if (dusk::interp::lookup_replacement(getInterpKey(mpModels[0], 2), render_proj_mtx)) { GXSetProjection(render_proj_mtx, GX_ORTHOGRAPHIC); } else #endif @@ -1102,7 +1103,7 @@ void dDlst_shadowReal_c::imageDraw(Mtx param_0) { shape_pkt = (*models)->getShapePacket(j); #ifdef TARGET_PC Mtx view_mtx; - if (dusk::frame_interp::lookup_replacement(getInterpKey(mpModels[0], 1), view_mtx)) { + if (dusk::interp::lookup_replacement(getInterpKey(mpModels[0], 1), view_mtx)) { shape_pkt->setBaseMtxPtr(&view_mtx); } else #endif @@ -1131,8 +1132,8 @@ void dDlst_shadowReal_c::draw() { GXSetCurrentMtx(GX_PNMTX0); #ifdef TARGET_PC Mtx view_mtx, recv_proj_mtx; - const auto have_view_mtx = dusk::frame_interp::lookup_replacement(getInterpKey(mpModels[0], 1), view_mtx); - const auto have_recv_proj_mtx = dusk::frame_interp::lookup_replacement(getInterpKey(mpModels[0], 3), recv_proj_mtx); + const auto have_view_mtx = dusk::interp::lookup_replacement(getInterpKey(mpModels[0], 1), view_mtx); + const auto have_recv_proj_mtx = dusk::interp::lookup_replacement(getInterpKey(mpModels[0], 3), recv_proj_mtx); if (have_view_mtx && have_recv_proj_mtx) { cMtx_concat(recv_proj_mtx, view_mtx, recv_proj_mtx); GXLoadTexMtxImm(recv_proj_mtx, GX_TEXMTX0, GX_MTX3x4); @@ -1300,9 +1301,9 @@ u8 dDlst_shadowReal_c::setShadowRealMtx(cXyz* param_0, cXyz* param_1, f32 param_ #ifdef TARGET_PC const auto keybase = mpModels[0]; - dusk::frame_interp::record_final_mtx(mViewMtx, getInterpKey(keybase, 1)); - dusk::frame_interp::record_final_mtx(mRenderProjMtx, getInterpKey(keybase, 2)); - dusk::frame_interp::record_final_mtx(mReceiverProjMtx, getInterpKey(keybase, 3)); + dusk::interp::record_final_mtx(mViewMtx, getInterpKey(keybase, 1)); + dusk::interp::record_final_mtx(mRenderProjMtx, getInterpKey(keybase, 2)); + dusk::interp::record_final_mtx(mReceiverProjMtx, getInterpKey(keybase, 3)); #endif cMtx_concat(mReceiverProjMtx, mViewMtx, mReceiverProjMtx); return r29; @@ -1364,6 +1365,16 @@ bool dDlst_shadowReal_c::add(J3DModel* i_model) { return true; } +#if TARGET_PC +static MtxP get_simple_shadow_mtx(Mtx worldMtx, const void* key, Mtx storage) { + if (!dusk::interp::lookup_replacement(key, storage)) { + cMtx_copy(worldMtx, storage); + } + cMtx_concat(j3dSys.getViewMtx(), storage, storage); + return storage; +} +#endif + void dDlst_shadowSimple_c::draw() { static GXColor l_color = {0, 0, 0, 64}; l_color.a = mAlpha; @@ -1371,31 +1382,23 @@ void dDlst_shadowSimple_c::draw() { GXSetTevColor(GX_TEVREG0, l_color); GXClearVtxDesc(); GXSetVtxDesc(GX_VA_POS, GX_INDEX8); -#ifdef TARGET_PC - Mtx volume_mtx; - if (dusk::frame_interp::lookup_replacement(mVolumeMtxKey, volume_mtx)) { - cMtx_concat(j3dSys.getViewMtx(), volume_mtx, volume_mtx); - GXLoadPosMtxImm(volume_mtx, GX_PNMTX0); - } else +#if TARGET_PC + Mtx volumeMtx; + GXLoadPosMtxImm(get_simple_shadow_mtx(mVolumeMtx, mVolumeMtxKey, volumeMtx), GX_PNMTX0); +#else + GXLoadPosMtxImm(mVolumeMtx, GX_PNMTX0); #endif - { - GXLoadPosMtxImm(mVolumeMtx, GX_PNMTX0); - } GXSetCurrentMtx(GX_PNMTX0); GXCallDisplayList(l_frontMat, 0x40); GXCallDisplayList(l_shadowVolumeDL, 0x40); GXCallDisplayList(l_backSubMat, 0x20); GXCallDisplayList(l_shadowVolumeDL, 0x40); -#ifdef TARGET_PC - Mtx shadow_mtx; - if (dusk::frame_interp::lookup_replacement(mMtxKey, shadow_mtx)) { - cMtx_concat(j3dSys.getViewMtx(), shadow_mtx, shadow_mtx); - GXLoadPosMtxImm(shadow_mtx, GX_PNMTX1); - } else +#if TARGET_PC + Mtx shadowMtx; + GXLoadPosMtxImm(get_simple_shadow_mtx(mMtx, mMtxKey, shadowMtx), GX_PNMTX1); +#else + GXLoadPosMtxImm(mMtx, GX_PNMTX1); #endif - { - GXLoadPosMtxImm(mMtx, GX_PNMTX1); - } GXSetCurrentMtx(GX_PNMTX1); if (mpTexObj != NULL) { @@ -1450,9 +1453,11 @@ void dDlst_shadowSimple_c::set(cXyz* param_0, f32 param_1, f32 param_2, cXyz* pa mDoMtx_stack_c::scaleM(param_2, f30 + f30 + 16.0f, param_2 * param_5); #if TARGET_PC mVolumeMtxKey = getInterpKey(param_0, 0x1); - dusk::frame_interp::record_final_mtx(mDoMtx_stack_c::get(), mVolumeMtxKey); -#endif + dusk::interp::record_final_mtx(mDoMtx_stack_c::get(), mVolumeMtxKey); + cMtx_copy(mDoMtx_stack_c::get(), mVolumeMtx); +#else cMtx_concat(j3dSys.getViewMtx(), mDoMtx_stack_c::get(), mVolumeMtx); +#endif f32 f31 = JMAFastSqrt(1.0f - param_3->x * param_3->x); f32 f29; f32 f28; @@ -1477,11 +1482,13 @@ void dDlst_shadowSimple_c::set(cXyz* param_0, f32 param_1, f32 param_2, cXyz* pa mDoMtx_stack_c::get()[2][3] = param_0->z; mDoMtx_stack_c::YrotM(param_4); mDoMtx_stack_c::scaleM(param_2, 1.0f, param_2 * param_5); -#ifdef TARGET_PC +#if TARGET_PC mMtxKey = getInterpKey(param_0, 0x2); - dusk::frame_interp::record_final_mtx(mDoMtx_stack_c::get(), mMtxKey); -#endif + dusk::interp::record_final_mtx(mDoMtx_stack_c::get(), mMtxKey); + cMtx_copy(mDoMtx_stack_c::get(), mMtx); +#else cMtx_concat(j3dSys.getViewMtx(), mDoMtx_stack_c::get(), mMtx); +#endif mpTexObj = param_6; } @@ -1642,7 +1649,7 @@ void dDlst_shadowControl_c::draw(Mtx param_0) { GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0); #ifdef TARGET_PC Mtx draw_mtx; - if (dusk::frame_interp::lookup_replacement(param_0, draw_mtx)) { + if (dusk::interp::lookup_replacement(param_0, draw_mtx)) { GXLoadPosMtxImm(draw_mtx, GX_PNMTX0); } else { #endif @@ -1991,7 +1998,7 @@ void dDlst_list_c::drawXluListItem3d() { } int dDlst_list_c::set(dDlst_base_c**& p_start, dDlst_base_c**& p_end, dDlst_base_c* p_newDlst) { - if (p_start >= p_end) { + if (p_start >= p_end IF_DUSK(|| !dusk::game_clock::is_sim_frame())) { return 0; } *p_start = p_newDlst; diff --git a/src/d/d_kankyo.cpp b/src/d/d_kankyo.cpp index 1201da30e9..b8e397e0ad 100644 --- a/src/d/d_kankyo.cpp +++ b/src/d/d_kankyo.cpp @@ -32,11 +32,10 @@ #include "JSystem/JKernel/JKRSolidHeap.h" #include #include + #if TARGET_PC -#include "dusk/imgui/ImGuiBloomWindow.hpp" -#include "dusk/settings.h" -#include "dusk/frame_interpolation.h" #include "dusk/game_clock.h" +#include "dusk/imgui/ImGuiBloomWindow.hpp" static f32 timeScale = 1.0f; #endif diff --git a/src/d/d_kankyo_rain.cpp b/src/d/d_kankyo_rain.cpp index 02dcd94d68..5fbcef3b65 100644 --- a/src/d/d_kankyo_rain.cpp +++ b/src/d/d_kankyo_rain.cpp @@ -13,9 +13,9 @@ #include "m_Do/m_Do_lib.h" #include -#include "dusk/version.hpp" #if TARGET_PC -#include "dusk/frame_interpolation.h" +#include "dusk/interp/frame_interpolation.h" +#include "dusk/version.hpp" #endif static void vectle_calc(DOUBLE_POS* i_pos, cXyz* o_out) { @@ -45,31 +45,48 @@ void dKyr_get_vectle_calc(cXyz* i_vecA, cXyz* i_vecB, cXyz* o_out) { get_vectle_calc(i_vecA, i_vecB, o_out); } +#if TARGET_PC +static view_class* dKyr_draw_view(camera_class* camera) { + if (dusk::interp::is_presentation_active()) { + if (view_class* view = dComIfGd_getView()) { + return view; + } + } + return &camera->view; +} +#endif + static void dKy_set_eyevect_calc(camera_class* i_camera, Vec* o_out, f32 param_2, f32 param_3) { cXyz calc; - get_vectle_calc(&i_camera->view.lookat.eye, &i_camera->view.lookat.center, &calc); - o_out->x = i_camera->view.lookat.eye.x + calc.x * param_2; - o_out->y = (i_camera->view.lookat.eye.y + calc.y * param_3) - 200.0f; - o_out->z = i_camera->view.lookat.eye.z + calc.z * param_2; + IF_DUSK(view_class* const view = dKyr_draw_view(i_camera)); + get_vectle_calc(DUSK_IF_ELSE(&view->, &i_camera->view.)lookat.eye, + DUSK_IF_ELSE(&view->, &i_camera->view.)lookat.center, &calc); + o_out->x = DUSK_IF_ELSE(view->, i_camera->view.)lookat.eye.x + calc.x * param_2; + o_out->y = (DUSK_IF_ELSE(view->, i_camera->view.)lookat.eye.y + calc.y * param_3) - 200.0f; + o_out->z = DUSK_IF_ELSE(view->, i_camera->view.)lookat.eye.z + calc.z * param_2; } void dKy_set_eyevect_calc2(camera_class* i_camera, Vec* o_out, f32 param_2, f32 param_3) { cXyz calc; DOUBLE_POS pos; + IF_DUSK(view_class* const view = dKyr_draw_view(i_camera)); - pos.x = i_camera->view.lookat.center.x - i_camera->view.lookat.eye.x; + pos.x = DUSK_IF_ELSE(view->, i_camera->view.)lookat.center.x - + DUSK_IF_ELSE(view->, i_camera->view.)lookat.eye.x; if (param_3 != 0.0f) { - pos.y = i_camera->view.lookat.center.y - i_camera->view.lookat.eye.y; + pos.y = DUSK_IF_ELSE(view->, i_camera->view.)lookat.center.y - + DUSK_IF_ELSE(view->, i_camera->view.)lookat.eye.y; } else { pos.y = 0.0f; } - pos.z = i_camera->view.lookat.center.z - i_camera->view.lookat.eye.z; + pos.z = DUSK_IF_ELSE(view->, i_camera->view.)lookat.center.z - + DUSK_IF_ELSE(view->, i_camera->view.)lookat.eye.z; vectle_calc(&pos, &calc); - o_out->x = i_camera->view.lookat.eye.x + calc.x * param_2; - o_out->y = i_camera->view.lookat.eye.y + calc.y * param_3; - o_out->z = i_camera->view.lookat.eye.z + calc.z * param_2; + o_out->x = DUSK_IF_ELSE(view->, i_camera->view.)lookat.eye.x + calc.x * param_2; + o_out->y = DUSK_IF_ELSE(view->, i_camera->view.)lookat.eye.y + calc.y * param_3; + o_out->z = DUSK_IF_ELSE(view->, i_camera->view.)lookat.eye.z + calc.z * param_2; if (param_3 == 0.0f) { o_out->y = 0.0f; @@ -129,24 +146,74 @@ static GXTexObj* load_cached_tex(CachedTexObjs& cache, ResTIMG* img, GXTexMap } #endif +#if TARGET_PC +static void dKyr_place_sun(camera_class* camera, cXyz* o_sunpos) { + view_class* view = dKyr_draw_view(camera); + cXyz lightDir; + u32 stage_type = dStage_stagInfo_GetSTType(dComIfGp_getStage()->getStagInfo()); + if (g_env_light.base_light.mColor.r == 0 && stage_type != ST_ROOM) { + dKyr_get_vectle_calc(&view->lookat.eye, &g_env_light.base_light.mPosition, &lightDir); + } else { + dKyr_get_vectle_calc(&view->lookat.eye, &g_env_light.sun_light_pos, &lightDir); + } + o_sunpos->x = view->lookat.eye.x + 8000.0f * lightDir.x; + o_sunpos->y = view->lookat.eye.y + 8000.0f * lightDir.y; + o_sunpos->z = view->lookat.eye.z + 8000.0f * lightDir.z; +} + +static void dKyr_place_lenzflare(camera_class* camera, cXyz* sunpos, cXyz* o_positions) { + view_class* view = dKyr_draw_view(camera); + cXyz eyeVect; + cXyz sunDirSmth; + cXyz camFwd; + + dKy_set_eyevect_calc(camera, &eyeVect, 4000.0f, 4000.0f); + dKyr_get_vectle_calc(&eyeVect, sunpos, &sunDirSmth); + o_positions[0] = *sunpos; + o_positions[1] = *sunpos; + + dKyr_get_vectle_calc(&view->lookat.eye, &view->lookat.center, &camFwd); + + for (int i = 2; i < 8; i++) { + if (i == 2) { + f32 size = 250.0f + 600.0f * sunDirSmth.abs(camFwd); + o_positions[i].x = sunpos->x - sunDirSmth.x * size * i; + o_positions[i].y = sunpos->y - sunDirSmth.y * size * i; + o_positions[i].z = sunpos->z - sunDirSmth.z * size * i; + } else { + f32 size = 250.0f + 110.0f * sunDirSmth.abs(camFwd); + o_positions[i].x = sunpos->x - (4100.0f * sunDirSmth.x + sunDirSmth.x * size * i); + o_positions[i].y = sunpos->y - (4100.0f * sunDirSmth.y + sunDirSmth.y * size * i); + o_positions[i].z = sunpos->z - (4100.0f * sunDirSmth.z + sunDirSmth.z * size * i); + } + } +} +#endif + void dKyr_lenzflare_move() { dKankyo_sun_Packet* sun_packet = g_env_light.mpSunPacket; dKankyo_sunlenz_Packet* lenz_packet = g_env_light.mpSunLenzPacket; camera_process_class* camera = dComIfGp_getCamera(0); +#if !TARGET_PC cXyz eyeVect; cXyz field_0x3c; cXyz sunDirSmth; cXyz camFwd; +#endif if (sun_packet->mVisibility < 0.0001f) { return; } +#if TARGET_PC + dKyr_place_lenzflare(camera, sun_packet->mPos, lenz_packet->mPositions); +#else dKy_set_eyevect_calc(camera, &eyeVect, 4000.0f, 4000.0f); dKyr_get_vectle_calc(&eyeVect, sun_packet->mPos, &sunDirSmth); lenz_packet->mPositions[0] = sun_packet->mPos[0]; lenz_packet->mPositions[1] = sun_packet->mPos[0]; +#endif cXyz vect; cXyz proj; @@ -162,6 +229,7 @@ void dKyr_lenzflare_move() { lenz_packet->field_0x94 *= S2DEG_CONSTANT; // convert from short angle to degrees lenz_packet->field_0x94 += 180.0f; +#if !TARGET_PC dKyr_get_vectle_calc(&camera->view.lookat.eye, &camera->view.lookat.center, &camFwd); for (int i = 2; i < 8; i++) { @@ -177,6 +245,7 @@ void dKyr_lenzflare_move() { lenz_packet->mPositions[i].z = sun_packet->mPos[0].z - (4100.0f * sunDirSmth.z + sunDirSmth.z * size * i); } } +#endif } static BOOL dKyr_moon_arrival_check() { @@ -205,6 +274,10 @@ void dKyr_sun_move() { u32 stage_type = dStage_stagInfo_GetSTType(dComIfGp_getStage()->getStagInfo()); +#if TARGET_PC + dKyr_place_sun(camera_p2, &sun_packet->mPos[0]); + dKyr_get_vectle_calc(&camera_p2->view.lookat.eye, &sun_packet->mPos[0], &lightDir); +#else if (g_env_light.base_light.mColor.r == 0 && stage_type != ST_ROOM) { dKyr_get_vectle_calc(&camera_p2->view.lookat.eye, &g_env_light.base_light.mPosition, &lightDir); @@ -215,6 +288,7 @@ void dKyr_sun_move() { sun_packet->mPos[0].x = camera_p2->view.lookat.eye.x + 8000.0f * lightDir.x; sun_packet->mPos[0].y = camera_p2->view.lookat.eye.y + 8000.0f * lightDir.y; sun_packet->mPos[0].z = camera_p2->view.lookat.eye.z + 8000.0f * lightDir.z; +#endif f32 horizon_y = (sun_packet->mPos[0].y - camera_p2->view.lookat.eye.y) / 8000.0f; if (horizon_y < 0.0f) { @@ -2084,16 +2158,17 @@ static void dKyr_draw_rev_moon(Mtx drawMtx, u8** tex) { dKankyo_sun_Packet* sun_packet = g_env_light.mpSunPacket; dKankyo_sunlenz_Packet* lenz_packet = g_env_light.mpSunLenzPacket; camera_class* camera = (camera_class*)dComIfGp_getCamera(0); + IF_DUSK(view_class* const view = dKyr_draw_view(camera)); cXyz pos[4]; u16 date = dComIfGs_getDate(); - cXyz sp60 = camera->view.lookat.eye + g_env_light.moon_pos; - sp60.y = camera->view.lookat.eye.y - g_env_light.moon_pos.y; + cXyz sp60 = DUSK_IF_ELSE(view->, camera->view.)lookat.eye + g_env_light.moon_pos; + sp60.y = DUSK_IF_ELSE(view->, camera->view.)lookat.eye.y - g_env_light.moon_pos.y; cXyz moon_pos; - moon_pos.x = sp60.x - camera->view.lookat.eye.x; - moon_pos.y = sp60.y - camera->view.lookat.eye.y; - moon_pos.z = sp60.z - camera->view.lookat.eye.z; + moon_pos.x = sp60.x - DUSK_IF_ELSE(view->, camera->view.)lookat.eye.x; + moon_pos.y = sp60.y - DUSK_IF_ELSE(view->, camera->view.)lookat.eye.y; + moon_pos.z = sp60.z - DUSK_IF_ELSE(view->, camera->view.)lookat.eye.z; Vec vp, lp; @@ -2225,7 +2300,7 @@ static void dKyr_draw_rev_moon(Mtx drawMtx, u8** tex) { 1.0f, 0.78f, 0.6f, 0.83f, }; - dKyr_get_vectle_calc(&camera->view.lookat.eye, &camera->view.lookat.center, &camfwd); + dKyr_get_vectle_calc(&view->lookat.eye, &view->lookat.center, &camfwd); f32 cam_distXZ = JMAFastSqrt((camfwd.x * camfwd.x) + (camfwd.z * camfwd.z)); f32 cam_theta = atan2f(camfwd.x, camfwd.z); @@ -2414,35 +2489,40 @@ void dKyr_drawSun(Mtx drawMtx, cXyz* ppos, GXColor& unused, u8** tex) { sunpos.y = ppos->y; sunpos.z = ppos->z; +#if TARGET_PC + dKyr_place_sun(camera, &sunpos); + view_class* const view = dKyr_draw_view(camera); +#endif + u32 stage_type = dStage_stagInfo_GetSTType(dComIfGp_getStage()->getStagInfo()); if (g_env_light.base_light.mColor.r == 0 && stage_type != ST_ROOM) { if (g_env_light.daytime > 285.0f || g_env_light.daytime < 105.0f) { draw_moon = false; } - spB4.x = ppos->x; - spB4.y = ppos->y; - spB4.z = ppos->z; + spB4.x = DUSK_IF_ELSE(sunpos.x, ppos->x); + spB4.y = DUSK_IF_ELSE(sunpos.y, ppos->y); + spB4.z = DUSK_IF_ELSE(sunpos.z, ppos->z); } else { if (strcmp(dComIfGp_getStartStageName(), "F_SP200") == 0 && dComIfG_play_c::getLayerNo(0) == 0) { spB4 = envlight->moon_pos; moon_pos = spB4; } else { - spB4 = camera->view.lookat.eye + envlight->moon_pos; - moon_pos.x = spB4.x - camera->view.lookat.eye.x; - moon_pos.y = spB4.y - camera->view.lookat.eye.y; - moon_pos.z = spB4.z - camera->view.lookat.eye.z; + spB4 = DUSK_IF_ELSE(view->, camera->view.)lookat.eye + envlight->moon_pos; + moon_pos.x = spB4.x - DUSK_IF_ELSE(view->, camera->view.)lookat.eye.x; + moon_pos.y = spB4.y - DUSK_IF_ELSE(view->, camera->view.)lookat.eye.y; + moon_pos.z = spB4.z - DUSK_IF_ELSE(view->, camera->view.)lookat.eye.z; } } if (strcmp(dComIfGp_getStartStageName(), "F_SP103") == 0 && dKy_daynight_check()) { - spB4.x = 3900.0f + camera->view.lookat.eye.x; - spB4.y = 8052.0f + camera->view.lookat.eye.y; - spB4.z = -9072.0f + camera->view.lookat.eye.z; + spB4.x = 3900.0f + DUSK_IF_ELSE(view->, camera->view.)lookat.eye.x; + spB4.y = 8052.0f + DUSK_IF_ELSE(view->, camera->view.)lookat.eye.y; + spB4.z = -9072.0f + DUSK_IF_ELSE(view->, camera->view.)lookat.eye.z; - moon_pos.x = spB4.x - camera->view.lookat.eye.x; - moon_pos.y = spB4.y - camera->view.lookat.eye.y; - moon_pos.z = spB4.z - camera->view.lookat.eye.z; + moon_pos.x = spB4.x - DUSK_IF_ELSE(view->, camera->view.)lookat.eye.x; + moon_pos.y = spB4.y - DUSK_IF_ELSE(view->, camera->view.)lookat.eye.y; + moon_pos.z = spB4.z - DUSK_IF_ELSE(view->, camera->view.)lookat.eye.z; } int weekday = date % 8; @@ -2588,7 +2668,9 @@ void dKyr_drawSun(Mtx drawMtx, cXyz* ppos, GXColor& unused, u8** tex) { }; if (strcmp(dComIfGp_getStartStageName(), "F_SP200") != 0) { - dKyr_get_vectle_calc(&camera->view.lookat.eye, &camera->view.lookat.center, &camfwd); + dKyr_get_vectle_calc(DUSK_IF_ELSE(&view->, &camera->view.)lookat.eye, + DUSK_IF_ELSE(&view->, &camera->view.)lookat.center, + &camfwd); f32 cam_distXZ = JMAFastSqrt((camfwd.x * camfwd.x) + (camfwd.z * camfwd.z)); f32 cam_theta = atan2f(camfwd.x, camfwd.z); f32 cam_phi = atan2f(camfwd.y, cam_distXZ); @@ -2783,6 +2865,13 @@ void dKyr_drawLenzflare(Mtx drawMtx, cXyz* ppos, GXColor& param_2, u8** tex) { f32 spA8 = sun_packet->mVisibility * sun_packet->mVisibility; if (!(sun_visibility < 0.1f)) { +#if TARGET_PC + cXyz sunpos; + cXyz positions[8]; + dKyr_place_sun(camera, &sunpos); + dKyr_place_lenzflare(camera, &sunpos, positions); + ppos = positions; +#endif dKy_set_eyevect_calc2(camera, &spFC, 8000.0f, 8000.0f); GXColor color_reg0; @@ -2962,25 +3051,25 @@ void dKyr_drawLenzflare(Mtx drawMtx, cXyz* ppos, GXColor& param_2, u8** tex) { spE4.y = sp9C; spE4.z = 0.0f; cMtx_multVec(camMtx, &spE4, &spD8); - pos[0].x = sun_packet->mPos[0].x + spD8.x; - pos[0].y = sun_packet->mPos[0].y + spD8.y; - pos[0].z = sun_packet->mPos[0].z + spD8.z; + pos[0].x = DUSK_IF_ELSE(sunpos, sun_packet->mPos[0]).x + spD8.x; + pos[0].y = DUSK_IF_ELSE(sunpos, sun_packet->mPos[0]).y + spD8.y; + pos[0].z = DUSK_IF_ELSE(sunpos, sun_packet->mPos[0]).z + spD8.z; spE4.x = sp98; spE4.y = sp94; spE4.z = 0.0f; cMtx_multVec(camMtx, &spE4, &spD8); - pos[1].x = sun_packet->mPos[0].x + spD8.x; - pos[1].y = sun_packet->mPos[0].y + spD8.y; - pos[1].z = sun_packet->mPos[0].z + spD8.z; + pos[1].x = DUSK_IF_ELSE(sunpos, sun_packet->mPos[0]).x + spD8.x; + pos[1].y = DUSK_IF_ELSE(sunpos, sun_packet->mPos[0]).y + spD8.y; + pos[1].z = DUSK_IF_ELSE(sunpos, sun_packet->mPos[0]).z + spD8.z; spE4.x = sp90; spE4.y = sp8C; spE4.z = 0.0f; cMtx_multVec(camMtx, &spE4, &spD8); - pos[2].x = sun_packet->mPos[0].x + spD8.x; - pos[2].y = sun_packet->mPos[0].y + spD8.y; - pos[2].z = sun_packet->mPos[0].z + spD8.z; + pos[2].x = DUSK_IF_ELSE(sunpos, sun_packet->mPos[0]).x + spD8.x; + pos[2].y = DUSK_IF_ELSE(sunpos, sun_packet->mPos[0]).y + spD8.y; + pos[2].z = DUSK_IF_ELSE(sunpos, sun_packet->mPos[0]).z + spD8.z; GXBegin(GX_TRIANGLES, GX_VTXFMT0, 3); GXPosition3f32(pos[0].x, pos[0].y, pos[0].z); @@ -4265,14 +4354,16 @@ void dKyr_drawStar(Mtx drawMtx, u8** tex) { return; } + IF_DUSK(view_class* const view = dKyr_draw_view(camera)); + if (strcmp(dComIfGp_getStartStageName(), "F_SP200") == 0 && dComIfG_play_c::getLayerNo(0) == 0) { moon_pos = envlight->moon_pos; } else { - moon_pos = camera->view.lookat.eye + envlight->moon_pos; + moon_pos = DUSK_IF_ELSE(view->, camera->view.)lookat.eye + envlight->moon_pos; if (sp38) { - moon_pos.x = 3900.0f + camera->view.lookat.eye.x; - moon_pos.y = 8052.0f + camera->view.lookat.eye.y; - moon_pos.z = -9072.0f + camera->view.lookat.eye.z; + moon_pos.x = 3900.0f + DUSK_IF_ELSE(view->, camera->view.)lookat.eye.x; + moon_pos.y = 8052.0f + DUSK_IF_ELSE(view->, camera->view.)lookat.eye.y; + moon_pos.z = -9072.0f + DUSK_IF_ELSE(view->, camera->view.)lookat.eye.z; } } @@ -4312,9 +4403,9 @@ void dKyr_drawStar(Mtx drawMtx, u8** tex) { rot = 0.0f; } - spBC.x = camera->view.lookat.eye.x; - spBC.y = camera->view.lookat.eye.y; - spBC.z = camera->view.lookat.eye.z; + spBC.x = DUSK_IF_ELSE(view->, camera->view.)lookat.eye.x; + spBC.y = DUSK_IF_ELSE(view->, camera->view.)lookat.eye.y; + spBC.z = DUSK_IF_ELSE(view->, camera->view.)lookat.eye.z; f32 sp34 = -1.0f; int sp30 = 0; @@ -6207,12 +6298,9 @@ static void dKyr_evil_draw2(Mtx drawMtx, u8** tex) { dKyr_set_btitex(&texobj, (ResTIMG*)tex[1]); #endif -#if TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) -#endif - { - rot += 0.7f; - } + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) + rot += 0.7f; + IF_DUSK_BLOCK_END MTXRotRad(rotMtx, 'Z', DEG_TO_RAD(rot)); MTXConcat(camMtx, rotMtx, camMtx); @@ -6451,12 +6539,9 @@ void dKyr_evil_draw(Mtx drawMtx, u8** tex) { dKyr_set_btitex(&texobj, (ResTIMG*)tex[0]); #endif -#if TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) -#endif - { - rot += 1.0f; - } + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) + rot += 1.0f; + IF_DUSK_BLOCK_END MTXRotRad(rotMtx, 'Z', DEG_TO_RAD(rot)); MTXConcat(camMtx, rotMtx, camMtx); diff --git a/src/d/d_menu_dmap.cpp b/src/d/d_menu_dmap.cpp index b84b596aff..f8514e3817 100644 --- a/src/d/d_menu_dmap.cpp +++ b/src/d/d_menu_dmap.cpp @@ -26,7 +26,7 @@ #include #if TARGET_PC -#include "dusk/frame_interpolation.h" +#include "dusk/interp/frame_interpolation.h" #include "dusk/settings.h" #include "dusk/version.hpp" #include "helpers/string.hpp" @@ -1112,7 +1112,7 @@ void dMenu_DmapBg_c::draw() { -35.0f + (local_224.x - local_218.x), -35.0f + (local_224.y - local_218.y)); #if TARGET_PC - if (!dusk::frame_interp::is_enabled()) { + if (!dusk::interp::is_enabled()) { field_0xdda = 0; } #else @@ -2774,7 +2774,7 @@ void dMenu_Dmap_c::zoomIn_proc() { void dMenu_Dmap_c::zoomOut_init_proc() { #if TARGET_PC - if (dusk::frame_interp::is_enabled()) { + if (dusk::interp::is_enabled()) { mpDrawBg->resetScrollArrowMask(); } #endif diff --git a/src/d/d_menu_fmap.cpp b/src/d/d_menu_fmap.cpp index c2809c4e43..57c329a61f 100644 --- a/src/d/d_menu_fmap.cpp +++ b/src/d/d_menu_fmap.cpp @@ -24,7 +24,7 @@ #include "d/actor/d_a_midna.h" #if TARGET_PC -#include "dusk/frame_interpolation.h" +#include "dusk/interp/frame_interpolation.h" #include "dusk/memory.h" #include "dusk/version.hpp" #include "helpers/string.hpp" @@ -1152,7 +1152,7 @@ void dMenu_Fmap_c::zoom_spot_to_region_init() { field_0x1ec = 1.0f; #if TARGET_PC // Frame interp note: field_0x122d used to be set every draw, causing flickering. Do it here instead. - if (dusk::frame_interp::is_enabled()) { + if (dusk::interp::is_enabled()) { mpDraw2DBack->resetScrollArrowMask(); } #endif diff --git a/src/d/d_menu_fmap2D.cpp b/src/d/d_menu_fmap2D.cpp index 125bd91f39..58db87ee68 100644 --- a/src/d/d_menu_fmap2D.cpp +++ b/src/d/d_menu_fmap2D.cpp @@ -20,7 +20,7 @@ #include #if TARGET_PC -#include "dusk/frame_interpolation.h" +#include "dusk/interp/frame_interpolation.h" #include "dusk/ui/touch_controls.hpp" #include "dusk/version.hpp" @@ -358,13 +358,10 @@ void dMenu_Fmap2DBack_c::draw() { scrollAreaDraw(); } -#ifdef TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) -#endif - { - blinkMove(30); - moveLightDropAnime(); - } + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) + blinkMove(30); + moveLightDropAnime(); + IF_DUSK_BLOCK_END setCenterPosX(field_0x11dc, 1); drawIcon(mTransX, mTransZ, mAlphaRate, field_0xfa8 * mSpotTextureFadeAlpha); @@ -399,16 +396,13 @@ void dMenu_Fmap2DBack_c::draw() { (mArrowPos3DZ + control_ypos + fVar3) - fVar5, &mArrowPos2DX, &mArrowPos2DY); -#ifdef TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) -#endif - { - field_0x11e0 -= g_fmapHIO.mCursorSpeed; + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) + field_0x11e0 -= g_fmapHIO.mCursorSpeed; - if (field_0x11e0 < 0.0f) { - field_0x11e0 += 360.0f; - } + if (field_0x11e0 < 0.0f) { + field_0x11e0 += 360.0f; } + IF_DUSK_BLOCK_END mpPointParent->getPanePtr()->rotate(mpPointParent->getSizeX() / 2.0f, mpPointParent->getSizeY() / 2.0f, ROTATE_Z, @@ -448,7 +442,7 @@ void dMenu_Fmap2DBack_c::draw() { if (field_0x122d) { mpMeterHaihai->drawHaihai(field_0x122d); #if TARGET_PC - if (!dusk::frame_interp::is_enabled()) { + if (!dusk::interp::is_enabled()) { field_0x122d = 0; } #else @@ -1868,21 +1862,18 @@ void dMenu_Fmap2DBack_c::calcBlink() { t * (g_fmapHIO.mMapBlink[i + 1].mUnselectedRegion.mBlinkSpeed - g_fmapHIO.mMapBlink[i].mUnselectedRegion.mBlinkSpeed); -#if TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) -#endif - { - field_0x1218++; - if (field_0x1218 >= selected_blink_speed) { - field_0x1218 = 0; - } - - field_0x121a++; - if (field_0x121a >= unselected_blink_speed) { - field_0x121a = 0; - } + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) + field_0x1218++; + if (field_0x1218 >= selected_blink_speed) { + field_0x1218 = 0; } + field_0x121a++; + if (field_0x121a >= unselected_blink_speed) { + field_0x121a = 0; + } + IF_DUSK_BLOCK_END + f32 t_selected = 0.0f; f32 t_unselected = 0.0f; diff --git a/src/d/d_menu_ring.cpp b/src/d/d_menu_ring.cpp index 2b05a46fae..73832f8918 100644 --- a/src/d/d_menu_ring.cpp +++ b/src/d/d_menu_ring.cpp @@ -30,8 +30,8 @@ #include #if TARGET_PC -#include "dusk/frame_interpolation.h" #include "dusk/game_clock.h" +#include "dusk/interp/frame_interpolation.h" #include "dusk/menu_pointer.h" #include "dusk/settings.h" #include "dusk/ui/touch_controls.hpp" @@ -760,13 +760,13 @@ void dMenu_Ring_c::_draw() { f32 simX = 0.0f; f32 simY = 0.0f; bool restoreSimPos = false; - if (dusk::frame_interp::is_enabled() && mAlphaRate >= 1.0f) { + if (dusk::interp::is_enabled() && mAlphaRate >= 1.0f) { simX = mpDrawCursor->getPositionX(); simY = mpDrawCursor->getPositionY(); const bool isAngular = (mStatus == STATUS_MOVE) && !mDirectSelectActive; - if (dusk::frame_interp::get_ui_tick_pending()) { + if (dusk::interp::get_ui_tick_pending()) { mCursorInterpPrevX = mCursorInterpCurrX; mCursorInterpPrevY = mCursorInterpCurrY; mCursorInterpPrevAngle = mCursorInterpCurrAngle; @@ -790,7 +790,7 @@ void dMenu_Ring_c::_draw() { } } if (mCursorInterpInit) { - const f32 step = dusk::frame_interp::get_interpolation_step(); + const f32 step = dusk::interp::get_interpolation_step(); if (mCursorInterpPrevAngular && mCursorInterpCurrAngular) { const s16 delta = mCursorInterpCurrAngle - mCursorInterpPrevAngle; const s16 lerpedAngle = mCursorInterpPrevAngle + (s16)(delta * step); diff --git a/src/d/d_menu_save.cpp b/src/d/d_menu_save.cpp index aaa5fe622b..a2b1a5dd2c 100644 --- a/src/d/d_menu_save.cpp +++ b/src/d/d_menu_save.cpp @@ -22,7 +22,7 @@ #include "m_Do/m_Do_graphic.h" #if TARGET_PC -#include "dusk/frame_interpolation.h" +#include "dusk/interp/frame_interpolation.h" #include "dusk/menu_pointer.h" #include "dusk/mods/svc/save.hpp" #include "dusk/settings.h" @@ -828,44 +828,38 @@ void dMenu_save_c::saveSelAnm() { } void dMenu_save_c::selFileWakuAnm() { -#if TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) -#endif - { - mFileWakuAnmFrame += 2; - if (mFileWakuAnmFrame >= mpFileWakuAnm->getFrameMax()) { - mFileWakuAnmFrame -= mpFileWakuAnm->getFrameMax(); - } - - mFileWakuRotAnmFrame += 2; - if (mFileWakuRotAnmFrame >= mpFileWakuRotAnm->getFrameMax()) { - mFileWakuRotAnmFrame -= mpFileWakuRotAnm->getFrameMax(); - } + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) + mFileWakuAnmFrame += 2; + if (mFileWakuAnmFrame >= mpFileWakuAnm->getFrameMax()) { + mFileWakuAnmFrame -= mpFileWakuAnm->getFrameMax(); } + + mFileWakuRotAnmFrame += 2; + if (mFileWakuRotAnmFrame >= mpFileWakuRotAnm->getFrameMax()) { + mFileWakuRotAnmFrame -= mpFileWakuRotAnm->getFrameMax(); + } + IF_DUSK_BLOCK_END mpFileWakuAnm->setFrame(mFileWakuAnmFrame); mpFileWakuRotAnm->setFrame(mFileWakuRotAnmFrame); } void dMenu_save_c::bookIconAnm() { -#if TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) -#endif - { - field_0x154 += 2; - if (field_0x154 >= field_0x150->getFrameMax()) { - field_0x154 -= field_0x150->getFrameMax(); - } - - field_0x15c += 2; - if (field_0x15c >= field_0x158->getFrameMax()) { - field_0x15c -= field_0x158->getFrameMax(); - } - - field_0x164 += 2; - if (field_0x164 >= field_0x160->getFrameMax()) { - field_0x164 -= field_0x160->getFrameMax(); - } + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) + field_0x154 += 2; + if (field_0x154 >= field_0x150->getFrameMax()) { + field_0x154 -= field_0x150->getFrameMax(); } + + field_0x15c += 2; + if (field_0x15c >= field_0x158->getFrameMax()) { + field_0x15c -= field_0x158->getFrameMax(); + } + + field_0x164 += 2; + if (field_0x164 >= field_0x160->getFrameMax()) { + field_0x164 -= field_0x160->getFrameMax(); + } + IF_DUSK_BLOCK_END field_0x150->setFrame(field_0x154); field_0x158->setFrame(field_0x15c); field_0x160->setFrame(field_0x164); diff --git a/src/d/d_menu_window.cpp b/src/d/d_menu_window.cpp index 0e05e8ac4e..80f374cf46 100644 --- a/src/d/d_menu_window.cpp +++ b/src/d/d_menu_window.cpp @@ -27,7 +27,7 @@ #include "m_Do/m_Do_controller_pad.h" #if TARGET_PC -#include "dusk/frame_interpolation.h" +#include "dusk/interp/frame_interpolation.h" #endif class dDlst_MENU_CAPTURE_c : public dDlst_base_c { @@ -126,7 +126,7 @@ public: void setCaptureFlag() { mFlag = 1; #ifdef TARGET_PC - dusk::frame_interp::request_presentation_sync(); + dusk::interp::request_presentation_sync(); #endif } diff --git a/src/d/d_meter2_draw.cpp b/src/d/d_meter2_draw.cpp index bcefa0a3dc..742fe6762d 100644 --- a/src/d/d_meter2_draw.cpp +++ b/src/d/d_meter2_draw.cpp @@ -23,7 +23,7 @@ #include #if TARGET_PC -#include "dusk/frame_interpolation.h" +#include "dusk/interp/frame_interpolation.h" #include "dusk/settings.h" #include "dusk/ui/icon_provider.hpp" #include "dusk/version.hpp" @@ -769,42 +769,38 @@ void dMeter2Draw_c::draw() { if (field_0x756 >= 0) { var_f29 = g_drawHIO.mLightDrop.mDropPikariAnimSpeed_Completed; int temp_r5_2 = g_drawHIO.mLightDrop.mPikariInterval * 15; -#ifdef TARGET_PC - // FRAME INTERP NOTE: Set even if not advancing - var_f28 = g_drawHIO.mLightDrop.mPikariScaleComplete; - if (dusk::frame_interp::get_ui_tick_pending()) -#endif - { - if (field_0x756 <= temp_r5_2) { - int temp_r4 = (field_0x756 % g_drawHIO.mLightDrop.mPikariInterval); - int temp_r3_5 = field_0x756 / g_drawHIO.mLightDrop.mPikariInterval; + IF_DUSK(var_f28 = g_drawHIO.mLightDrop.mPikariScaleComplete); // FRAME INTERP NOTE: Set even if not advancing + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) + if (field_0x756 <= temp_r5_2) { + int temp_r4 = (field_0x756 % g_drawHIO.mLightDrop.mPikariInterval); + int temp_r3_5 = field_0x756 / g_drawHIO.mLightDrop.mPikariInterval; - if (temp_r4 == 0 && field_0x62c[temp_r3_5] == 0.0f) { - field_0x62c[temp_r3_5] = 18.0f; - } + if (temp_r4 == 0 && field_0x62c[temp_r3_5] == 0.0f) { + field_0x62c[temp_r3_5] = 18.0f; + } - var_f28 = g_drawHIO.mLightDrop.mPikariScaleComplete; - field_0x756++; - } else { - int temp_r5_3 = temp_r5_2 + 1; + var_f28 = g_drawHIO.mLightDrop.mPikariScaleComplete; + field_0x756++; + } else { + int temp_r5_3 = temp_r5_2 + 1; - if (field_0x756 == temp_r5_3) { - if (field_0x62c[15] == 0.0f) { - field_0x756++; - } - var_f28 = g_drawHIO.mLightDrop.mPikariScaleComplete; - } else if (field_0x756 >= g_drawHIO.mLightDrop.field_0x54 + temp_r5_3) { - for (int i = 0; i < 16; i++) { - field_0x62c[i] = 18.0f - var_f29; - field_0x66c[i] = 18.0f - g_drawHIO.mLightDrop.mPikariLoopAnimSpeed; - } - - field_0x756 = -1; - } else { + if (field_0x756 == temp_r5_3) { + if (field_0x62c[15] == 0.0f) { field_0x756++; } + var_f28 = g_drawHIO.mLightDrop.mPikariScaleComplete; + } else if (field_0x756 >= g_drawHIO.mLightDrop.field_0x54 + temp_r5_3) { + for (int i = 0; i < 16; i++) { + field_0x62c[i] = 18.0f - var_f29; + field_0x66c[i] = 18.0f - g_drawHIO.mLightDrop.mPikariLoopAnimSpeed; + } + + field_0x756 = -1; + } else { + field_0x756++; } } + IF_DUSK_BLOCK_END } for (int i = 0; i < 16; i++) { @@ -1494,26 +1490,23 @@ void dMeter2Draw_c::drawPikari(f32 i_posX, f32 i_posY, f32* i_framep, f32 i_scal if (param_9 != 3 && param_9 != 4 && param_9 != 5 && dMsgObject_isTalkNowCheck()) { *i_framep = 0.0f; } else { -#ifdef TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) -#endif - { - *i_framep += param_8; - if (*i_framep > var_f31) { - if (param_9 == 1 || param_9 == 2 || param_9 == 3) { - *i_framep = 18.0f; - } else { - *i_framep = 0.0f; - } - } - - if (*i_framep == 18.0f && param_9 == 1) { - mDoAud_seStart(Z2SE_NAVI_BLINK, NULL, 0, 0); - } else if (*i_framep == 18.0f && param_9 == 2) { - mDoAud_seStart(Z2SE_SY_ITEM_COMBINE_ICON, NULL, 0, 0); + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) + *i_framep += param_8; + if (*i_framep > var_f31) { + if (param_9 == 1 || param_9 == 2 || param_9 == 3) { + *i_framep = 18.0f; + } else { + *i_framep = 0.0f; } } + if (*i_framep == 18.0f && param_9 == 1) { + mDoAud_seStart(Z2SE_NAVI_BLINK, NULL, 0, 0); + } else if (*i_framep == 18.0f && param_9 == 2) { + mDoAud_seStart(Z2SE_SY_ITEM_COMBINE_ICON, NULL, 0, 0); + } + IF_DUSK_BLOCK_END + playPikariBckAnimation(*i_framep); playPikariBpkAnimation(*i_framep); diff --git a/src/d/d_meter_button.cpp b/src/d/d_meter_button.cpp index ac11d183ce..5c4207b2c8 100644 --- a/src/d/d_meter_button.cpp +++ b/src/d/d_meter_button.cpp @@ -19,7 +19,7 @@ #include #if TARGET_PC -#include "dusk/frame_interpolation.h" +#include "dusk/interp/frame_interpolation.h" #include "dusk/version.hpp" #include "helpers/string.hpp" #endif @@ -294,7 +294,7 @@ void dMeterButton_c::draw() { s16 temp_r6 = g_drawHIO.mEmpButton.mRepeatHitFrameNum; s16 temp_r6_2 = g_drawHIO.mEmpButton.mRepeatHitFrameNum / 2; - IF_DUSK_BLOCK(dusk::frame_interp::get_ui_tick_pending()) + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) field_0x4b8[i]++; if (field_0x4b8[i] >= temp_r6) { @@ -379,7 +379,7 @@ void dMeterButton_c::draw() { if (var_r3) { #if TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) { + if (dusk::interp::get_ui_tick_pending()) { mWasListen[i] = var_r22; mWasRepeat[i] = var_r23; } else { @@ -388,7 +388,7 @@ void dMeterButton_c::draw() { } #endif if (var_r22) { - if (field_0x2e8[i] == 18.0f IF_DUSK(&& dusk::frame_interp::get_ui_tick_pending())) + if (field_0x2e8[i] == 18.0f IF_DUSK(&& dusk::interp::get_ui_tick_pending())) { mDoAud_seStart(Z2SE_SY_HINT_BUTTON_BLINK, NULL, 0, 0); } diff --git a/src/d/d_meter_haihai.cpp b/src/d/d_meter_haihai.cpp index 5ea5dad5b7..59a69ed61e 100644 --- a/src/d/d_meter_haihai.cpp +++ b/src/d/d_meter_haihai.cpp @@ -11,7 +11,10 @@ #include "d/d_com_inf_game.h" #include "d/d_meter_HIO.h" #include "d/d_pane_class.h" -#include "dusk/frame_interpolation.h" + +#if TARGET_PC +#include "dusk/interp/frame_interpolation.h" +#endif dMeterHaihai_c::dMeterHaihai_c(u8 i_type) { mType = i_type; @@ -287,20 +290,17 @@ void dMeterHaihai_c::updateHaihai() { void dMeterHaihai_c::playBckAnime(J2DAnmTransformKey* i_bck) { if (checkPlayAnime(1)) { if (i_bck != NULL) { -#ifdef TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) -#endif - { - if (mType == 4) { - mBckFrame += g_drawHIO.mWiiLockArrowBCKAnimSpeed; - } else { - mBckFrame += g_drawHIO.mScrollArrowBCKAnimSpeed; - } - - if (mBckFrame >= i_bck->getFrameMax()) { - mBckFrame -= i_bck->getFrameMax(); - } + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) + if (mType == 4) { + mBckFrame += g_drawHIO.mWiiLockArrowBCKAnimSpeed; + } else { + mBckFrame += g_drawHIO.mScrollArrowBCKAnimSpeed; } + + if (mBckFrame >= i_bck->getFrameMax()) { + mBckFrame -= i_bck->getFrameMax(); + } + IF_DUSK_BLOCK_END } else { mBtkFrame = 1.0f; } @@ -315,20 +315,17 @@ void dMeterHaihai_c::playBckAnime(J2DAnmTransformKey* i_bck) { void dMeterHaihai_c::playBtkAnime(J2DAnmTextureSRTKey* i_btk) { if (checkPlayAnime(2)) { if (i_btk != NULL) { -#ifdef TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) -#endif - { - if (mType == 4) { - mBtkFrame += g_drawHIO.mWiiLockArrowBTKAnimSpeed; - } else { - mBtkFrame += g_drawHIO.mScrollArrowBTKAnimSpeed; - } - - if (mBtkFrame >= i_btk->getFrameMax()) { - mBtkFrame -= i_btk->getFrameMax(); - } + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) + if (mType == 4) { + mBtkFrame += g_drawHIO.mWiiLockArrowBTKAnimSpeed; + } else { + mBtkFrame += g_drawHIO.mScrollArrowBTKAnimSpeed; } + + if (mBtkFrame >= i_btk->getFrameMax()) { + mBtkFrame -= i_btk->getFrameMax(); + } + IF_DUSK_BLOCK_END } else { mBtkFrame = 1.0f; } @@ -342,20 +339,17 @@ void dMeterHaihai_c::playBtkAnime(J2DAnmTextureSRTKey* i_btk) { void dMeterHaihai_c::playBpkAnime(J2DAnmColor* i_bpk) { if (checkPlayAnime(0)) { if (i_bpk != NULL) { -#ifdef TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) -#endif - { - if (mType == 4) { - mBpkFrame += g_drawHIO.mWiiLockArrowBPKAnimSpeed; - } else { - mBpkFrame += g_drawHIO.mScrollArrowBPKAnimSpeed; - } - - if (mBpkFrame >= i_bpk->getFrameMax()) { - mBpkFrame -= i_bpk->getFrameMax(); - } + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) + if (mType == 4) { + mBpkFrame += g_drawHIO.mWiiLockArrowBPKAnimSpeed; + } else { + mBpkFrame += g_drawHIO.mScrollArrowBPKAnimSpeed; } + + if (mBpkFrame >= i_bpk->getFrameMax()) { + mBpkFrame -= i_bpk->getFrameMax(); + } + IF_DUSK_BLOCK_END } else { mBpkFrame = 1.0f; } diff --git a/src/d/d_meter_string.cpp b/src/d/d_meter_string.cpp index c99e7c564e..3bc5795dc0 100644 --- a/src/d/d_meter_string.cpp +++ b/src/d/d_meter_string.cpp @@ -16,9 +16,12 @@ #include "d/d_meter2_info.h" #include "d/d_meter_HIO.h" #include "d/d_pane_class.h" -#include "dusk/frame_interpolation.h" #include +#if TARGET_PC +#include "dusk/interp/frame_interpolation.h" +#endif + dMeterString_c::dMeterString_c(int i_stringID) { mpMapArchive = dComIfGp_getAllMapArchive(); field_0x28 = 0; @@ -106,27 +109,22 @@ void dMeterString_c::draw() { f32 var_f30 = 1.0f; if (mAnimFrame < 60.0f) { -#if TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) -#endif - { - mAnimFrame += g_drawHIO.mMiniGame.mReadyFightTextAnimSpeed; - if (mAnimFrame > 60.0f) { - mAnimFrame = 60.0f; - } + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) + mAnimFrame += g_drawHIO.mMiniGame.mReadyFightTextAnimSpeed; + if (mAnimFrame > 60.0f) { + mAnimFrame = 60.0f; } + IF_DUSK_BLOCK_END playBckAnimation(mAnimFrame); } else if (mAnimFrame < (f32)g_drawHIO.mMiniGame.mReadyFightTextWaitFrames + 60.0f) { -#if TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) -#endif - mAnimFrame += var_f30; + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) + mAnimFrame += var_f30; + IF_DUSK_BLOCK_END } else if (mAnimFrame < var_f31) { -#if TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) -#endif - mAnimFrame += var_f30; + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) + mAnimFrame += var_f30; + IF_DUSK_BLOCK_END var_f30 = acc(g_drawHIO.mMiniGame.field_0x172, var_f31 - mAnimFrame, 0); } @@ -139,23 +137,17 @@ void dMeterString_c::draw() { if (mPikariAnimFrame > 0.0f) { drawPikari(); - } else if (mPikariAnimFrame == -1.0f && -#if TARGET_PC - dusk::frame_interp::get_ui_tick_pending() && -#endif + } else if (mPikariAnimFrame == -1.0f IF_DUSK(&& dusk::interp::get_ui_tick_pending()) && mAnimFrame > g_drawHIO.mMiniGame.mReadyFightPikariAppearFrames) { mPikariAnimFrame = 18.0f - g_drawHIO.mMiniGame.mReadyFightPikariAnimSpeed; } -#if TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) -#endif - { - if (mAnimFrame >= var_f31) { - dMeter2Info_resetMeterString(); - } + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) + if (mAnimFrame >= var_f31) { + dMeter2Info_resetMeterString(); } + IF_DUSK_BLOCK_END } } } diff --git a/src/d/d_model.cpp b/src/d/d_model.cpp index bdff472367..c236b5f2db 100644 --- a/src/d/d_model.cpp +++ b/src/d/d_model.cpp @@ -6,7 +6,7 @@ #include "d/d_com_inf_game.h" #if TARGET_PC -#include "dusk/frame_interpolation.h" +#include "dusk/interp/frame_interpolation.h" #endif void dMdl_c::draw() { @@ -52,7 +52,7 @@ void dMdl_c::entryObj(dMdl_obj_c* i_obj) { #ifdef TARGET_PC // if field_0x1a is false, this dMdl_c is not in the drawlist // if true, we need to make sure with interp enabled - if (dusk::frame_interp::is_enabled() && field_0x1a) { + if (dusk::interp::is_enabled() && field_0x1a) { auto pkt = dComIfGd_getListPacket()->mpBuffer[0]; while (pkt && pkt != this) { pkt = pkt->getNextPacket(); diff --git a/src/d/d_msg_out_font.cpp b/src/d/d_msg_out_font.cpp index 57b85b18b2..ce5e97c2d0 100644 --- a/src/d/d_msg_out_font.cpp +++ b/src/d/d_msg_out_font.cpp @@ -8,7 +8,7 @@ #include "f_op/f_op_msg_mng.h" #if TARGET_PC -#include "dusk/frame_interpolation.h" +#include "dusk/interp/frame_interpolation.h" #include "dusk/version.hpp" #endif @@ -319,7 +319,7 @@ void COutFont_c::draw(J2DTextBox* i_textbox, f32 param_1, f32 param_2, f32 param } #if TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) { + if (dusk::interp::get_ui_tick_pending()) { for (int i = 0; i < 70; i++) { sp256[i] = -1; } @@ -528,7 +528,7 @@ void COutFont_c::draw(J2DTextBox* i_textbox, f32 param_1, f32 param_2, f32 param case 20: case 21: case 22: - IF_DUSK_BLOCK(dusk::frame_interp::get_ui_tick_pending()) + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) field_0x1b4[type]++; if (field_0x1b4[type] >= 28) { field_0x1b4[type] = 0; diff --git a/src/d/d_msg_scrn_howl.cpp b/src/d/d_msg_scrn_howl.cpp index 4e5c59546c..c87c4bbb0f 100644 --- a/src/d/d_msg_scrn_howl.cpp +++ b/src/d/d_msg_scrn_howl.cpp @@ -21,8 +21,7 @@ #include "m_Do/m_Do_graphic.h" #if TARGET_PC -#include "dusk/frame_interpolation.h" -#include "dusk/settings.h" +#include "dusk/interp/frame_interpolation.h" #endif // POSIX already defines a macro with this name, but we know that this specific name is @@ -596,15 +595,12 @@ void dMsgScrnHowl_c::drawWave() { f17 = local_60; f18 = local_64; } else { -#if TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) -#endif - { - field_0x2134++; - if (field_0x2134 > 30) { - field_0x2134 = 0; - } + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) + field_0x2134++; + if (field_0x2134 > 30) { + field_0x2134 = 0; } + IF_DUSK_BLOCK_END if (field_0x2134 < 15) { local_dc = field_0x2134 / 15.0f; } else { diff --git a/src/d/d_msg_scrn_light.cpp b/src/d/d_msg_scrn_light.cpp index 1f6a176066..0d9f409978 100644 --- a/src/d/d_msg_scrn_light.cpp +++ b/src/d/d_msg_scrn_light.cpp @@ -8,7 +8,7 @@ #include "d/d_pane_class.h" #if TARGET_PC -#include "dusk/frame_interpolation.h" +#include "dusk/interp/frame_interpolation.h" #endif class dMsgScrnLight_HIO_c { @@ -206,15 +206,12 @@ void dMsgScrnLight_c::draw(f32* i_anmFrame, f32 i_posX, f32 i_posY, f32 i_scaleX } if (mPlayAnim) { -#ifdef TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) -#endif - { - *i_anmFrame += 1.0f; - if (*i_anmFrame >= mpBck->getFrameMax()) { - *i_anmFrame = 0.0f; - } + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) + *i_anmFrame += 1.0f; + if (*i_anmFrame >= mpBck->getFrameMax()) { + *i_anmFrame = 0.0f; } + IF_DUSK_BLOCK_END mBckFrame = *i_anmFrame; mBpkFrame = *i_anmFrame; @@ -229,16 +226,13 @@ void dMsgScrnLight_c::draw(f32* i_anmFrame, f32 i_posX, f32 i_posY, f32 i_scaleX mpParent_c->setBlackWhite(i_black, i_white); if (mPlayAnim) { -#ifdef TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) -#endif - { - *i_anmFrame += i_anmRate; + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) + *i_anmFrame += i_anmRate; - if (*i_anmFrame >= mpBck->getFrameMax()) { - *i_anmFrame = 0.0f; - } + if (*i_anmFrame >= mpBck->getFrameMax()) { + *i_anmFrame = 0.0f; } + IF_DUSK_BLOCK_END mBckFrame = *i_anmFrame; mBpkFrame = *i_anmFrame; diff --git a/src/d/d_particle.cpp b/src/d/d_particle.cpp index 9e443aa81a..d1e175dfc1 100644 --- a/src/d/d_particle.cpp +++ b/src/d/d_particle.cpp @@ -26,7 +26,7 @@ #include "SSystem/SComponent/c_math.h" #if TARGET_PC -#include "dusk/frame_interpolation.h" +#include "dusk/game_clock.h" #include #endif @@ -1976,7 +1976,7 @@ void dPa_light8PcallBack::draw(JPABaseEmitter* param_1, JPABaseParticle* param_2 JGeometry::TVec3 local_160; JGeometry::TVec3 local_16c; #if TARGET_PC - if (dusk::frame_interp::is_sim_frame()) + if (dusk::game_clock::is_sim_frame()) #endif { dPa_setWindPower(param_2); diff --git a/src/d/d_select_cursor.cpp b/src/d/d_select_cursor.cpp index 640f8072cd..4fcc6fd5f8 100644 --- a/src/d/d_select_cursor.cpp +++ b/src/d/d_select_cursor.cpp @@ -5,9 +5,12 @@ #include "d/d_com_inf_game.h" #include "JSystem/J2DGraph/J2DAnimation.h" #include "JSystem/J2DGraph/J2DAnmLoader.h" -#include "dusk/frame_interpolation.h" #include +#if TARGET_PC +#include "dusk/interp/frame_interpolation.h" +#endif + dSelect_cursorHIO_c::dSelect_cursorHIO_c() { field_0x8 = 1.0f; mXAxisExpansion = 1.0f; @@ -281,21 +284,18 @@ void dSelect_cursor_c::update() { if (mUpdateFlag) { if (field_0x30) { if (chkPlayAnime(0)) { -#ifdef TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) -#endif - { - if (mNameIdx == 1) { - field_0x44 += mpCursorHIO->field_0x8 * fVar1; - } else { - field_0x44 += fVar1; - } - - if (field_0x44 >= field_0x30->getFrameMax()) { - field_0x44 -= field_0x30->getFrameMax(); - } + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) + if (mNameIdx == 1) { + field_0x44 += mpCursorHIO->field_0x8 * fVar1; + } else { + field_0x44 += fVar1; } + if (field_0x44 >= field_0x30->getFrameMax()) { + field_0x44 -= field_0x30->getFrameMax(); + } + IF_DUSK_BLOCK_END + field_0x30->setFrame(field_0x44); setBpkAnimation(field_0x30); } else { @@ -310,19 +310,16 @@ void dSelect_cursor_c::update() { for (int i = 0; i < 2; i++) { if (field_0x34[i]) { if ((i == 0 && chkPlayAnime(2)) || (i == 1 && chkPlayAnime(3))) { -#ifdef TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) -#endif - { - if (mNameIdx == 1) { - field_0x48[i] += mpCursorHIO->field_0x8 * fVar1; - } else { - field_0x48[i] += fVar1; - } - if (field_0x48[i] >= field_0x34[i]->getFrameMax()) { - field_0x48[i] -= field_0x34[i]->getFrameMax(); - } + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) + if (mNameIdx == 1) { + field_0x48[i] += mpCursorHIO->field_0x8 * fVar1; + } else { + field_0x48[i] += fVar1; } + if (field_0x48[i] >= field_0x34[i]->getFrameMax()) { + field_0x48[i] -= field_0x34[i]->getFrameMax(); + } + IF_DUSK_BLOCK_END field_0x34[i]->setFrame(field_0x48[i]); } @@ -331,19 +328,16 @@ void dSelect_cursor_c::update() { } if (field_0x2C && chkPlayAnime(1)) { -#ifdef TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) -#endif - { - if (mNameIdx == 1) { - field_0x40 += mpCursorHIO->field_0x8 * fVar1; - } else { - field_0x40 += fVar1; - } - if (field_0x40 >= field_0x2C->getFrameMax()) { - field_0x40 -= field_0x2C->getFrameMax(); - } + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) + if (mNameIdx == 1) { + field_0x40 += mpCursorHIO->field_0x8 * fVar1; + } else { + field_0x40 += fVar1; } + if (field_0x40 >= field_0x2C->getFrameMax()) { + field_0x40 -= field_0x2C->getFrameMax(); + } + IF_DUSK_BLOCK_END field_0x2C->setFrame(field_0x40); setBckAnimation(field_0x2C); @@ -351,12 +345,9 @@ void dSelect_cursor_c::update() { } if (chkPlayAnime(1) && mNameIdx == 0) { -#ifdef TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) -#endif - { - setCursorAnimation(); - } + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) + setCursorAnimation(); + IF_DUSK_BLOCK_END } mpScreen->animation(); diff --git a/src/d/d_select_icon.cpp b/src/d/d_select_icon.cpp index 32be9c15e2..e55beaf54c 100644 --- a/src/d/d_select_icon.cpp +++ b/src/d/d_select_icon.cpp @@ -2,31 +2,28 @@ #include "d/d_select_icon.h" #include "JSystem/J2DGraph/J2DAnimation.h" -#include "dusk/frame_interpolation.h" + +#if TARGET_PC +#include "dusk/interp/frame_interpolation.h" +#endif dSi_HIO_c::dSi_HIO_c() {} void dSelect_icon_c::animation() { if (field_0x10->getAlpha() != 0) { -#ifdef TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) -#endif - { - field_0x20 += field_0x2c; - if (field_0x20 >= field_0x1c->getFrameMax()) { - field_0x20 = 0.0f; - } - field_0x1c->setFrame(field_0x20); - - field_0x28 += field_0x2c; - if (field_0x28 >= field_0x24->getFrameMax()) { - field_0x28 = 0.0f; - } + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) + field_0x20 += field_0x2c; + if (field_0x20 >= field_0x1c->getFrameMax()) { + field_0x20 = 0.0f; } -#ifdef TARGET_PC - // FRAME INTERP NOTE: Set even if not advancing field_0x1c->setFrame(field_0x20); -#endif + + field_0x28 += field_0x2c; + if (field_0x28 >= field_0x24->getFrameMax()) { + field_0x28 = 0.0f; + } + IF_DUSK_BLOCK_END + IF_DUSK(field_0x1c->setFrame(field_0x20)); // FRAME INTERP NOTE: Set even if not advancing field_0x24->setFrame(field_0x28); field_0x8->animation(); diff --git a/src/d/d_timer.cpp b/src/d/d_timer.cpp index e07cc3af80..df1a3ef104 100644 --- a/src/d/d_timer.cpp +++ b/src/d/d_timer.cpp @@ -23,8 +23,10 @@ #include "m_Do/m_Do_lib.h" #include -#include "dusk/frame_interpolation.h" +#if TARGET_PC +#include "dusk/interp/frame_interpolation.h" #include "dusk/version.hpp" +#endif static int dTimer_createStart2D(s32 param_0, u16 param_1); @@ -1340,23 +1342,20 @@ void dDlst_TimerScrnDraw_c::draw() { ((f32)g_drawHIO.mMiniGame.mGetInTextWaitFrames + 60.0f); for (int i = 0; i < 51; i++) { -#if TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) -#endif - { - if (m_getin_info[i].bck_frame > 0.0f && m_getin_info[i].bck_frame < temp) { - if (m_getin_info[i].bck_frame < 60.0f) { - m_getin_info[i].bck_frame += g_drawHIO.mMiniGame.mGetInTextAnimSpeed; - if (m_getin_info[i].bck_frame > 60.0f) { - m_getin_info[i].bck_frame = 60.0f; - } - } else if (m_getin_info[i].bck_frame < g_drawHIO.mMiniGame.mGetInTextWaitFrames + 60.0f) { - m_getin_info[i].bck_frame++; - } else if (m_getin_info[i].bck_frame < temp) { - m_getin_info[i].bck_frame++; + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) + if (m_getin_info[i].bck_frame > 0.0f && m_getin_info[i].bck_frame < temp) { + if (m_getin_info[i].bck_frame < 60.0f) { + m_getin_info[i].bck_frame += g_drawHIO.mMiniGame.mGetInTextAnimSpeed; + if (m_getin_info[i].bck_frame > 60.0f) { + m_getin_info[i].bck_frame = 60.0f; } + } else if (m_getin_info[i].bck_frame < g_drawHIO.mMiniGame.mGetInTextWaitFrames + 60.0f) { + m_getin_info[i].bck_frame++; + } else if (m_getin_info[i].bck_frame < temp) { + m_getin_info[i].bck_frame++; } } + IF_DUSK_BLOCK_END if (m_getin_info[i].bck_frame > 0.0f && m_getin_info[i].bck_frame < temp) { f32 var_f29 = 1.0f; @@ -1396,20 +1395,17 @@ void dDlst_TimerScrnDraw_c::draw() { if (m_getin_info[i].pikari_frame > 0.0f) { drawPikari(i); } else if (m_getin_info[i].pikari_frame == -1.0f) { -#if TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) -#endif - { - if (m_getin_info[i].field_0xc == 0) { - if (m_getin_info[i].bck_frame > g_drawHIO.mMiniGame.mGetInPikariAppearFrames) { - m_getin_info[i].pikari_frame = - 18.0f - g_drawHIO.mMiniGame.mGetInPikariAnimSpeed; - } - } else if (m_getin_info[i].bck_frame > g_drawHIO.mMiniGame.mStartPikariAppearFrames) { + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) + if (m_getin_info[i].field_0xc == 0) { + if (m_getin_info[i].bck_frame > g_drawHIO.mMiniGame.mGetInPikariAppearFrames) { m_getin_info[i].pikari_frame = - 18.0f - g_drawHIO.mMiniGame.mStartPikariAnimSpeed; + 18.0f - g_drawHIO.mMiniGame.mGetInPikariAnimSpeed; } + } else if (m_getin_info[i].bck_frame > g_drawHIO.mMiniGame.mStartPikariAppearFrames) { + m_getin_info[i].pikari_frame = + 18.0f - g_drawHIO.mMiniGame.mStartPikariAnimSpeed; } + IF_DUSK_BLOCK_END } } } diff --git a/src/dusk/frame_interpolation.cpp b/src/dusk/frame_interpolation.cpp deleted file mode 100644 index ca30ec0db5..0000000000 --- a/src/dusk/frame_interpolation.cpp +++ /dev/null @@ -1,463 +0,0 @@ -#include "dusk/frame_interpolation.h" - -#include "f_op/f_op_camera_mng.h" -#include "m_Do/m_Do_graphic.h" -#include "mtx.h" - -#include - -namespace { - -struct Recording { - absl::flat_hash_map matrix_values; -}; - -bool s_initialized = false; - -bool g_enabled = false; -bool g_recording = false; -bool g_interpolating = false; -bool g_sync_presentation = false; - -float g_step = 0.0f; -bool g_is_sim_frame = false; -bool g_ui_tick_pending = false; -uint64_t g_sim_tick_seq = 0; - -Recording g_current_recording; -Recording g_previous_recording; - -absl::flat_hash_map g_replacements; - -struct CameraSnapshot { - cXyz eye{}; - cXyz center{}; - cXyz up{}; - s16 bank{}; - f32 fovy{}; - f32 aspect{}; - f32 near_{}; - f32 far_{}; - bool wideZoom{}; - bool valid{}; -}; - -CameraSnapshot s_cam_prev{}; -CameraSnapshot s_cam_curr{}; - -view_class s_presentation_view_backup{}; -int s_presentation_depth = 0; - -struct InterpolationCallBackWork { - dusk::frame_interp::InterpolationCallBack pCallBack; - void* pUserWork; -}; - -std::vector s_interpolationCallBackWork; - -void copy_view_to_snap(CameraSnapshot* dst, const view_class& v) { - dst->eye = v.lookat.eye; - dst->center = v.lookat.center; - dst->up = v.lookat.up; - dst->bank = v.bank; - dst->fovy = v.fovy; - dst->aspect = v.aspect; - dst->near_ = v.near_; - dst->far_ = v.far_; - dst->valid = true; -} - -inline void lerp_matrix(Mtx out, const Mtx lhs, const Mtx rhs, float step) { - for (size_t row = 0; row < 3; ++row) { - for (size_t col = 0; col < 4; ++col) { - const float l = lhs[row][col]; - out[row][col] = l + (rhs[row][col] - l) * step; - } - } -} - -inline void lerp_xyz(cXyz* out, const cXyz& lhs, const cXyz& rhs, float step) { - out->x = lhs.x + (rhs.x - lhs.x) * step; - out->y = lhs.y + (rhs.y - lhs.y) * step; - out->z = lhs.z + (rhs.z - lhs.z) * step; -} - -static s16 lerp_bank(s16 a, s16 b, f32 t) { - const f32 ra = S2RAD(a); - const f32 d = remainderf(S2RAD(b) - ra, 2.0f * static_cast(M_PI)); - return cAngle::Radian_to_SAngle(ra + d * t); -} - -inline bool matrix_differs(const Mtx lhs, const Mtx rhs, float epsilon = 0.0001f) { - for (size_t row = 0; row < 3; ++row) { - for (size_t col = 0; col < 4; ++col) { - if (std::abs(lhs[row][col] - rhs[row][col]) > epsilon) { - return true; - } - } - } - return false; -} - -const Mtx* resolve_replacement(const Mtx* source, Mtx* scratch) { - if (!g_interpolating || source == nullptr || dusk::frame_interp::presentation_sync_active()) { - return source; - } - - auto it = g_replacements.find(reinterpret_cast(source)); - if (it == g_replacements.end()) { - return source; - } - - MTXCopy(it->second, *scratch); - return scratch; -} - -bool has_recording_data(const Recording& recording) { - return !recording.matrix_values.empty(); -} - -void clear_replacements() { - g_replacements.clear(); -} - -} // namespace - -namespace dusk::frame_interp { -void ensure_initialized() { - s_initialized = true; -} - -void begin_sim_tick() { - ensure_initialized(); - if (!g_enabled) { - return; - } - - s_interpolationCallBackWork.clear(); - s_cam_prev = std::move(s_cam_curr); - ++g_sim_tick_seq; -} - -uint64_t sim_tick_seq() { - return g_sim_tick_seq; -} - -void begin_frame(FrameInterpMode mode, bool is_sim_frame, float step) { - g_enabled = mode != FrameInterpMode::Off; - g_is_sim_frame = is_sim_frame; - g_step = std::clamp(step, 0.0f, 1.0f); - if (!g_enabled) { - g_interpolating = false; - clear_replacements(); - } -} - -bool is_enabled() { - return g_enabled; -} - -bool is_sim_frame() { - return g_is_sim_frame; -} - -void begin_record() { - ensure_initialized(); - - if (!g_enabled) { - g_interpolating = false; - g_sync_presentation = false; - g_previous_recording = {}; - g_current_recording = {}; - clear_replacements(); - s_cam_prev.valid = false; - s_cam_curr.valid = false; - return; - } - - g_sync_presentation = false; - g_previous_recording = std::move(g_current_recording); - g_current_recording = {}; - g_recording = true; - g_interpolating = false; - clear_replacements(); - - ::camera_process_class* cam = dComIfGp_getCamera(0); - if (cam == nullptr) { - s_cam_prev.valid = false; - s_cam_curr.valid = false; - return; - } -} - -void end_record() { - g_recording = false; -} - -void interpolate() { - ensure_initialized(); - clear_replacements(); - g_interpolating = g_enabled && !g_recording && !g_sync_presentation && has_recording_data(g_current_recording); - if (!g_interpolating) { - return; - } - for (auto const& old : g_previous_recording.matrix_values) { - if (auto it = g_current_recording.matrix_values.find(old.first); - it != g_current_recording.matrix_values.end()) - { - lerp_matrix(g_replacements[old.first], old.second, it->second, g_step); - } - } -} - -void request_presentation_sync() { - ensure_initialized(); - if (!g_enabled) { - return; - } - g_sync_presentation = true; -} - -bool presentation_sync_active() { - if (!s_initialized || !g_enabled) { - return false; - } - return g_sync_presentation; -} - -float get_interpolation_step() { - ensure_initialized(); - return presentation_sync_active() ? 1.0f : g_step; -} - -void set_ui_tick_pending(bool value) { - if (g_ui_tick_pending == value) { return; } - g_ui_tick_pending = value; -} - -bool get_ui_tick_pending() { - ensure_initialized(); - return g_enabled ? g_ui_tick_pending : true; -} - -void record_final_mtx(Mtx m, const void* key) { - if (!s_initialized || !g_recording || m == nullptr) { - return; - } - - auto& it = g_current_recording.matrix_values[reinterpret_cast(key)]; - MTXCopy(m, it); -} - -void record_final_mtx(Mtx m) { - record_final_mtx(m, m); -} - -bool lookup_replacement(const void* key, Mtx out) { - if (presentation_sync_active() || !g_interpolating || key == nullptr) { - return false; - } - - auto it = g_replacements.find(reinterpret_cast(key)); - if (it == g_replacements.end()) { - return false; - } - - MTXCopy(it->second, out); - return true; -} - -bool lookup_concat_replacement(const void* lhs, const void* rhs, Mtx out) { - if (presentation_sync_active() || !g_interpolating || lhs == nullptr || rhs == nullptr) { - return false; - } - - Mtx lhs_scratch; - Mtx rhs_scratch; - const Mtx* resolved_lhs = resolve_replacement(reinterpret_cast(lhs), &lhs_scratch); - const Mtx* resolved_rhs = resolve_replacement(reinterpret_cast(rhs), &rhs_scratch); - if (resolved_lhs == reinterpret_cast(lhs) && resolved_rhs == reinterpret_cast(rhs)) { - return false; - } - - MTXConcat(*resolved_lhs, *resolved_rhs, out); - return true; -} - -void record_camera(::camera_process_class* cam, int camera_id) { - if (!g_enabled || camera_id != 0 || cam == nullptr) { - return; - } - copy_view_to_snap(&s_cam_curr, cam->view); -#if WIDESCREEN_SUPPORT - s_cam_curr.wideZoom = mDoGph_gInf_c::isWideZoom(); -#endif -} - -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(); - const bool is_cam_curr_authoritative = g_is_sim_frame && step <= 0.0f; - - cXyz eye; - cXyz center; - cXyz up; - if (is_cam_curr_authoritative) { - eye = s_cam_curr.eye; - center = s_cam_curr.center; - up = s_cam_curr.up; - } else { - lerp_xyz(&eye, s_cam_prev.eye, s_cam_curr.eye, step); - lerp_xyz(¢er, s_cam_prev.center, s_cam_curr.center, step); - lerp_xyz(&up, s_cam_prev.up, s_cam_curr.up, step); - } - if (!up.normalizeRS()) { - up = s_cam_curr.up; - up.normalizeRS(); - } - - view->lookat.eye = eye; - view->lookat.center = center; - view->lookat.up = up; - if (is_cam_curr_authoritative) { - view->bank = s_cam_curr.bank; - view->fovy = s_cam_curr.fovy; - view->aspect = s_cam_curr.aspect; - view->near_ = s_cam_curr.near_; - view->far_ = s_cam_curr.far_; - } else { - view->bank = lerp_bank(s_cam_prev.bank, s_cam_curr.bank, step); - view->fovy = s_cam_prev.fovy + (s_cam_curr.fovy - s_cam_prev.fovy) * step; - view->aspect = s_cam_prev.aspect + (s_cam_curr.aspect - s_cam_prev.aspect) * step; - view->near_ = s_cam_prev.near_ + (s_cam_curr.near_ - s_cam_prev.near_) * step; - view->far_ = s_cam_prev.far_ + (s_cam_curr.far_ - s_cam_prev.far_) * step; - } - - // FRAME INTERP TODO: It might be better if I rewired the game to not clear this flag until the - // next sim frame, but I don't care enough to right now -#if WIDESCREEN_SUPPORT - const f32 wide_step = is_cam_curr_authoritative ? 1.0f : step; - if (mDoGph_gInf_c::isWide() && !mDoGph_gInf_c::isWideZoom() && wide_step >= 0.5f ? s_cam_curr.wideZoom : s_cam_prev.wideZoom) { - mDoGph_gInf_c::onWideZoom(); - } -#endif -} - -static void run_interpolation_callbacks() { - for (size_t i = 0; i < s_interpolationCallBackWork.size(); i++) { - auto const& work = s_interpolationCallBackWork[i]; - work.pCallBack(g_is_sim_frame, work.pUserWork); - } -} - -void add_interpolation_callback(InterpolationCallBack pCallBack, void* pUserWork) { - if (!is_enabled() || s_presentation_depth > 0 || !g_is_sim_frame) - return; - - s_interpolationCallBackWork.emplace_back(pCallBack, pUserWork); -} - -void begin_presentation_camera() { - ensure_initialized(); - if (!g_enabled) { - return; - } - if (s_presentation_depth > 0) { - s_presentation_depth++; - return; - } - if (!s_cam_prev.valid || !s_cam_curr.valid) { - return; - } - - view_class* const view = dComIfGd_getView(); - if (view == nullptr) { - return; - } - - std::memcpy(&s_presentation_view_backup, view, sizeof(view_class)); - interp_view(view); - - // FRAME INTERP TODO: Largely copied from d_camera's camera_draw function from this point, got any better ideas? - C_MTXPerspective(view->projMtx, view->fovy, view->aspect, view->near_, view->far_); - mDoMtx_lookAt(view->viewMtx, &view->lookat.eye, &view->lookat.center, &view->lookat.up, view->bank); -#if WIDESCREEN_SUPPORT - mDoGph_gInf_c::setWideZoomProjection(view->projMtx); -#endif - j3dSys.setViewMtx(view->viewMtx); - cMtx_inverse(view->viewMtx, view->invViewMtx); - - bool camera_attention_status = dComIfGp_getCameraAttentionStatus(0) & 0x80; - Z2GetAudience()->setAudioCamera(view->viewMtx, view->lookat.eye, view->lookat.center, view->fovy, view->aspect, camera_attention_status, 0, false); - - dBgS_GndChk gndchk; - gndchk.OnWaterGrp(); - gndchk.SetPos(&view->lookat.eye); - f32 cross = dComIfG_Bgsp().GroundCross(&gndchk); - if (cross != -G_CM3D_F_INF) { - if (dComIfG_Bgsp().ChkGrpInf(gndchk, 0x100)) { - mDoAud_getCameraMapInfo(6); - } else { - mDoAud_getCameraMapInfo(dComIfG_Bgsp().GetMtrlSndId(gndchk)); - } - mDoAud_setCameraGroupInfo(dComIfG_Bgsp().GetGrpSoundId(gndchk)); - Vec spDC; - spDC.x = view->lookat.eye.x; - spDC.y = cross; - spDC.z = view->lookat.eye.z; - Z2AudioMgr::getInterface()->setCameraPolygonPos(&spDC); - } else { - Z2AudioMgr::getInterface()->setCameraPolygonPos(nullptr); - } - - MTXCopy(view->viewMtx, view->viewMtxNoTrans); - view->viewMtxNoTrans[0][3] = 0.0f; - view->viewMtxNoTrans[1][3] = 0.0f; - view->viewMtxNoTrans[2][3] = 0.0f; - cMtx_concatProjView(view->projMtx, view->viewMtx, view->projViewMtx); - - f32 far_; - f32 var_f30; - if (dComIfGp_getCameraAttentionStatus(0) & 8) { - far_ = view->far_; - } else { -#if DEBUG - if (g_envHIO.mOther.mAdjustCullFar != 0) { - var_f30 = g_envHIO.mOther.mCullFarValue; - } else -#endif - { - var_f30 = dStage_stagInfo_GetCullPoint(dComIfGp_getStageStagInfo()); - } - far_ = var_f30; - } - - mDoLib_clipper::setup(view->fovy, view->aspect, view->near_, far_); - - // FRAME INTERP NOTE: Removed the call to offWideZoom that was here, it causes problems with presentation during cutscenes. - - s_presentation_depth = 1; - - run_interpolation_callbacks(); -} - -void end_presentation_camera() { - if (s_presentation_depth == 0) { - return; - } - s_presentation_depth--; - if (s_presentation_depth > 0) { - return; - } - - view_class* const view = dComIfGd_getView(); - if (view != nullptr) { - std::memcpy(view, &s_presentation_view_backup, sizeof(view_class)); - } -} -} // namespace dusk::frame_interp diff --git a/src/dusk/frame_interpolation.h b/src/dusk/frame_interpolation.h deleted file mode 100644 index 5f2f3d134b..0000000000 --- a/src/dusk/frame_interpolation.h +++ /dev/null @@ -1,54 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include "settings.h" - -class camera_process_class; -class view_class; - -#ifdef __cplusplus -namespace dusk { -namespace frame_interp { - -void ensure_initialized(); - -void begin_record(); -void end_record(); -void begin_sim_tick(); -uint64_t sim_tick_seq(); -void begin_frame(FrameInterpMode mode, bool is_sim_frame, float step); -void interpolate(); -float get_interpolation_step(); - -void request_presentation_sync(); -bool presentation_sync_active(); - -bool is_enabled(); - -// TODO: These should be phased out as UI is progressively updated to use game_clock -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); -void record_final_mtx(Mtx m); - -bool lookup_replacement(const void* key, Mtx out); -bool lookup_concat_replacement(const void* lhs, const void* rhs, Mtx out); - -typedef void (*InterpolationCallBack)(bool isSimFrame, void* pUserWork); -// call on a sim tick, will get called during presentation -void add_interpolation_callback(InterpolationCallBack pCallBack, void* pUserWork); - -void begin_presentation_camera(); -void end_presentation_camera(); - -} // namespace frame_interp -} // namespace dusk -#endif diff --git a/src/dusk/game_clock.cpp b/src/dusk/game_clock.cpp index 178ec7803a..3a680fcca8 100644 --- a/src/dusk/game_clock.cpp +++ b/src/dusk/game_clock.cpp @@ -1,7 +1,5 @@ #include "dusk/game_clock.h" -#include "dusk/frame_interpolation.h" - #include #include @@ -13,18 +11,21 @@ namespace dusk::game_clock { using native_clock = aurora::time::native_clock; using game_clock = aurora::time::game_clock; -FrameTiming g_frameTiming; +FrameTiming g_frameTiming{.dt = kUiInitialDt}; namespace { bool s_initialized = false; -bool s_fixedStepActive = false; bool s_simTickActive = false; native_clock::time_point s_previousNativeSample{}; game_clock::time_point s_latestGameSample{}; game_clock::time_point s_currentSnapshotTime{}; game_clock::time_point s_pendingSimTime{}; - std::unordered_map s_intervalLastSample; +uint64_t s_presentationEpoch = 1; +bool s_timingModeInitialized = false; +bool s_previousSeparatePresentation = false; +bool s_previousInterpolating = false; +bool s_previousTimeStopped = false; constexpr game_clock::duration kSimPeriodDuration = std::chrono::duration_cast(std::chrono::duration(kSimPeriod)); @@ -49,6 +50,7 @@ void reset() { s_currentSnapshotTime = s_latestGameSample - kSimPeriodDuration; s_pendingSimTime = s_currentSnapshotTime; s_simTickActive = false; + ++s_presentationEpoch; } void set_sim_rate(float hz) { @@ -65,11 +67,15 @@ const FrameTiming& advance() { const auto nativeNow = native_clock::now(); const auto gameNow = game_clock::now(); const auto nativeFrameGap = nativeNow - s_previousNativeSample; + const auto gameFrameGap = gameNow - s_latestGameSample; s_previousNativeSample = nativeNow; s_latestGameSample = gameNow; auto& out = g_frameTiming; - out = {.dt = std::chrono::duration().count()}; + out = { + .dt = std::chrono::duration(gameFrameGap).count(), + .presentationEpoch = s_presentationEpoch, + }; const float timeScale = aurora::time::scale(); const bool interpolating = @@ -77,7 +83,21 @@ const FrameTiming& advance() { const bool separatePresentation = interpolating || timeScale != 1.0f; out.interpolating = interpolating; out.separatePresentation = separatePresentation; - s_fixedStepActive = separatePresentation; + + const bool timeStopped = timeScale == 0.0f; + const bool timingModeChanged = + s_timingModeInitialized && + (separatePresentation != s_previousSeparatePresentation || + interpolating != s_previousInterpolating || timeStopped != s_previousTimeStopped); + const bool abnormalGap = nativeFrameGap > kAbnormalGapResetThreshold; + if (timingModeChanged || abnormalGap) { + ++s_presentationEpoch; + out.presentationEpoch = s_presentationEpoch; + } + s_timingModeInitialized = true; + s_previousSeparatePresentation = separatePresentation; + s_previousInterpolating = interpolating; + s_previousTimeStopped = timeStopped; if (!separatePresentation) { s_currentSnapshotTime = gameNow; @@ -86,7 +106,7 @@ const FrameTiming& advance() { } const auto simulationTarget = interpolating ? gameNow - kSimPeriodDuration : gameNow; - if (timeScale == 0.f || nativeFrameGap > kAbnormalGapResetThreshold) { + if (timeStopped || abnormalGap) { s_currentSnapshotTime = simulationTarget; out.numSimTicks = 0; return out; @@ -109,8 +129,8 @@ const FrameTiming& advance() { } void begin_sim_tick() { - s_pendingSimTime = - s_fixedStepActive ? s_currentSnapshotTime + kSimPeriodDuration : s_latestGameSample; + s_pendingSimTime = g_frameTiming.separatePresentation ? s_currentSnapshotTime + kSimPeriodDuration : + s_latestGameSample; s_simTickActive = true; } @@ -123,6 +143,10 @@ void commit_sim_tick() { } } +bool is_sim_frame() { + return !g_frameTiming.separatePresentation || s_simTickActive; +} + float sample_interpolation_step() { const float step = std::chrono::duration(game_clock::now() - s_currentSnapshotTime).count() / diff --git a/src/dusk/game_clock.h b/src/dusk/game_clock.h index 5e71ea4c0f..3492456927 100644 --- a/src/dusk/game_clock.h +++ b/src/dusk/game_clock.h @@ -16,6 +16,8 @@ struct FrameTiming { bool separatePresentation; // Number of simulation ticks to run int numSimTicks; + // Changes whenever presentation history must be discarded and re-anchored. + uint64_t presentationEpoch; }; extern FrameTiming g_frameTiming; @@ -26,10 +28,12 @@ void begin_sim_tick(); void commit_sim_tick(); float sample_interpolation_step(); +bool is_sim_frame(); + float consume_interval(const void* consumer); // Sets the effective simulation rate through the game clock time scale. void set_sim_rate(float hz); float get_sim_rate(); -} // namespace dusk::game_clock +} // namespace dusk::game_clock diff --git a/src/dusk/imgui/ImGuiConsole.cpp b/src/dusk/imgui/ImGuiConsole.cpp index 97a13efc3d..badf7297c2 100644 --- a/src/dusk/imgui/ImGuiConsole.cpp +++ b/src/dusk/imgui/ImGuiConsole.cpp @@ -6,7 +6,6 @@ #include "dusk/action_bindings.h" #include "dusk/config.hpp" #include "dusk/data.hpp" -#include "dusk/frame_interpolation.h" #include "dusk/game_mode.hpp" #include "dusk/livesplit.h" #include "dusk/main.h" diff --git a/src/dusk/interp/camera.cpp b/src/dusk/interp/camera.cpp new file mode 100644 index 0000000000..19ab197214 --- /dev/null +++ b/src/dusk/interp/camera.cpp @@ -0,0 +1,218 @@ +#include "dusk/interp/camera.h" + +#include "dusk/game_clock.h" +#include "dusk/interp/frame_interpolation.h" +#include "dusk/interp/lerp.h" + +#include "d/d_com_inf_game.h" +#include "f_op/f_op_camera_mng.h" +#include "m_Do/m_Do_graphic.h" + +#include +#include + +namespace { + +struct CameraSnapshot { + cXyz eye{}; + cXyz center{}; + cXyz up{}; + s16 bank{}; + f32 fovy{}; + f32 aspect{}; + f32 near_{}; + f32 far_{}; + bool wideZoom{}; + bool valid{}; +}; + +CameraSnapshot s_camPrev{}; +CameraSnapshot s_camCurr{}; + +view_class s_presentationViewBackup{}; + +void copy_view_to_snap(CameraSnapshot* dst, const view_class& v) { + dst->eye = v.lookat.eye; + dst->center = v.lookat.center; + dst->up = v.lookat.up; + dst->bank = v.bank; + dst->fovy = v.fovy; + dst->aspect = v.aspect; + dst->near_ = v.near_; + dst->far_ = v.far_; + dst->valid = true; +} + +void apply_presented_view(view_class* view) { + // FRAME INTERP TODO: Largely copied from d_camera's camera_draw function from this point, got any + // better ideas? + C_MTXPerspective(view->projMtx, view->fovy, view->aspect, view->near_, view->far_); + mDoMtx_lookAt(view->viewMtx, &view->lookat.eye, &view->lookat.center, &view->lookat.up, + view->bank); +#if WIDESCREEN_SUPPORT + mDoGph_gInf_c::setWideZoomProjection(view->projMtx); +#endif + j3dSys.setViewMtx(view->viewMtx); + cMtx_inverse(view->viewMtx, view->invViewMtx); + + bool camera_attention_status = dComIfGp_getCameraAttentionStatus(0) & 0x80; + Z2GetAudience()->setAudioCamera(view->viewMtx, view->lookat.eye, view->lookat.center, view->fovy, + view->aspect, camera_attention_status, 0, false); + + dBgS_GndChk gndchk; + gndchk.OnWaterGrp(); + gndchk.SetPos(&view->lookat.eye); + f32 cross = dComIfG_Bgsp().GroundCross(&gndchk); + if (cross != -G_CM3D_F_INF) { + if (dComIfG_Bgsp().ChkGrpInf(gndchk, 0x100)) { + mDoAud_getCameraMapInfo(6); + } else { + mDoAud_getCameraMapInfo(dComIfG_Bgsp().GetMtrlSndId(gndchk)); + } + mDoAud_setCameraGroupInfo(dComIfG_Bgsp().GetGrpSoundId(gndchk)); + Vec spDC; + spDC.x = view->lookat.eye.x; + spDC.y = cross; + spDC.z = view->lookat.eye.z; + Z2AudioMgr::getInterface()->setCameraPolygonPos(&spDC); + } else { + Z2AudioMgr::getInterface()->setCameraPolygonPos(nullptr); + } + + MTXCopy(view->viewMtx, view->viewMtxNoTrans); + view->viewMtxNoTrans[0][3] = 0.0f; + view->viewMtxNoTrans[1][3] = 0.0f; + view->viewMtxNoTrans[2][3] = 0.0f; + cMtx_concatProjView(view->projMtx, view->viewMtx, view->projViewMtx); + + f32 far_; + f32 var_f30; + if (dComIfGp_getCameraAttentionStatus(0) & 8) { + far_ = view->far_; + } else { +#if DEBUG + if (g_envHIO.mOther.mAdjustCullFar != 0) { + var_f30 = g_envHIO.mOther.mCullFarValue; + } else +#endif + { + var_f30 = dStage_stagInfo_GetCullPoint(dComIfGp_getStageStagInfo()); + } + far_ = var_f30; + } + + mDoLib_clipper::setup(view->fovy, view->aspect, view->near_, far_); + + // FRAME INTERP NOTE: Removed the call to offWideZoom that was here, it causes problems with + // presentation during cutscenes. +} + +} // namespace + +namespace dusk::interp { + +void record_camera(::camera_process_class* cam, int camera_id) { + if (!is_enabled() || camera_id != 0 || cam == nullptr) { + return; + } + copy_view_to_snap(&s_camCurr, cam->view); +#if WIDESCREEN_SUPPORT + s_camCurr.wideZoom = mDoGph_gInf_c::isWideZoom(); +#endif +} + +void interp_view(::view_class* view) { + if (!is_enabled()) + return; + + if (!s_camPrev.valid || !s_camCurr.valid) + return; + + const f32 step = get_interpolation_step(); + const bool is_cam_curr_authoritative = game_clock::is_sim_frame() && step <= 0.0f; + + cXyz eye; + cXyz center; + cXyz up; + if (is_cam_curr_authoritative) { + eye = s_camCurr.eye; + center = s_camCurr.center; + up = s_camCurr.up; + } else { + lerp(eye, s_camPrev.eye, s_camCurr.eye, step); + lerp(center, s_camPrev.center, s_camCurr.center, step); + lerp(up, s_camPrev.up, s_camCurr.up, step); + } + if (!up.normalizeRS()) { + up = s_camCurr.up; + up.normalizeRS(); + } + + view->lookat.eye = eye; + view->lookat.center = center; + view->lookat.up = up; + if (is_cam_curr_authoritative) { + view->bank = s_camCurr.bank; + view->fovy = s_camCurr.fovy; + view->aspect = s_camCurr.aspect; + view->near_ = s_camCurr.near_; + view->far_ = s_camCurr.far_; + } else { + view->bank = lerp(s_camPrev.bank, s_camCurr.bank, step); + view->fovy = s_camPrev.fovy + (s_camCurr.fovy - s_camPrev.fovy) * step; + view->aspect = s_camPrev.aspect + (s_camCurr.aspect - s_camPrev.aspect) * step; + view->near_ = s_camPrev.near_ + (s_camCurr.near_ - s_camPrev.near_) * step; + view->far_ = s_camPrev.far_ + (s_camCurr.far_ - s_camPrev.far_) * step; + } + + // FRAME INTERP TODO: It might be better if I rewired the game to not clear this flag until the + // next sim frame, but I don't care enough to right now +#if WIDESCREEN_SUPPORT + const f32 wide_step = is_cam_curr_authoritative ? 1.0f : step; + if (mDoGph_gInf_c::isWide() && !mDoGph_gInf_c::isWideZoom() && + wide_step >= 0.5f ? s_camCurr.wideZoom : s_camPrev.wideZoom) + { + mDoGph_gInf_c::onWideZoom(); + } +#endif +} + +void camera_on_sim_tick() { + s_camPrev = std::move(s_camCurr); +} + +void camera_invalidate_snapshots() { + s_camPrev.valid = false; + s_camCurr.valid = false; +} + +void camera_on_begin_record() { + if (dComIfGp_getCamera(0) == nullptr) { + camera_invalidate_snapshots(); + } +} + +bool camera_apply_presentation() { + if (!s_camPrev.valid || !s_camCurr.valid) { + return false; + } + + view_class* const view = dComIfGd_getView(); + if (view == nullptr) { + return false; + } + + std::memcpy(&s_presentationViewBackup, view, sizeof(view_class)); + interp_view(view); + apply_presented_view(view); + return true; +} + +void camera_restore_presentation() { + view_class* const view = dComIfGd_getView(); + if (view != nullptr) { + std::memcpy(view, &s_presentationViewBackup, sizeof(view_class)); + } +} + +} // namespace dusk::interp diff --git a/src/dusk/interp/camera.h b/src/dusk/interp/camera.h new file mode 100644 index 0000000000..e4a1824979 --- /dev/null +++ b/src/dusk/interp/camera.h @@ -0,0 +1,13 @@ +#pragma once + +class camera_process_class; +class view_class; + +#ifdef __cplusplus +namespace dusk::interp { + +void record_camera(::camera_process_class* cam, int camera_id); +void interp_view(::view_class* view); + +} // namespace dusk::interp +#endif diff --git a/src/dusk/interp/frame_interpolation.cpp b/src/dusk/interp/frame_interpolation.cpp new file mode 100644 index 0000000000..ceceb710e0 --- /dev/null +++ b/src/dusk/interp/frame_interpolation.cpp @@ -0,0 +1,287 @@ +#include "dusk/interp/frame_interpolation.h" + +#include "dusk/game_clock.h" +#include "dusk/interp/lerp.h" + +#include "mtx.h" + +#include +#include +#include + +namespace dusk::interp { +void camera_on_sim_tick(); +void camera_on_begin_record(); +bool camera_apply_presentation(); +void camera_restore_presentation(); +void camera_invalidate_snapshots(); +} // namespace dusk::interp + +namespace { + +struct Recording { + absl::flat_hash_map matrix_values; +}; + +bool s_recording = false; +bool s_replacementsActive = false; +bool s_syncPresentation = false; + +float s_step = 0.0f; +bool s_uiTickPending = false; +uint64_t s_simTickSeq = 0; +uint64_t s_observedPresentationEpoch = 0; + +Recording s_currentRecording; +Recording s_previousRecording; + +absl::flat_hash_map g_replacements; + +int s_presentationDepth = 0; + +const Mtx* resolve_replacement(const Mtx* source, Mtx* scratch) { + if (!s_replacementsActive || source == nullptr || dusk::interp::presentation_sync_active()) { + return source; + } + + auto it = g_replacements.find(reinterpret_cast(source)); + if (it == g_replacements.end()) { + return source; + } + + MTXCopy(it->second, *scratch); + return scratch; +} + +bool has_recording_data(const Recording& recording) { + return !recording.matrix_values.empty(); +} + +void clear_replacements() { + g_replacements.clear(); +} + +void interpolate_replacements() { + clear_replacements(); + s_replacementsActive = dusk::interp::is_enabled() && !s_recording && !s_syncPresentation && + has_recording_data(s_currentRecording); + if (!s_replacementsActive) { + return; + } + for (auto const& old : s_previousRecording.matrix_values) { + if (auto it = s_currentRecording.matrix_values.find(old.first); + it != s_currentRecording.matrix_values.end()) + { + dusk::interp::lerp(g_replacements[old.first], old.second, it->second, s_step); + } + } +} + +struct InterpolationCallBackWork { + dusk::interp::InterpolationCallBack pCallBack; + void* pUserWork; +}; + +std::vector s_interpolationCallBackWork; + +void clear_callbacks() { + s_interpolationCallBackWork.clear(); +} + +void callbacks_run() { + for (const auto& work : s_interpolationCallBackWork) { + if (work.pCallBack != nullptr) { + work.pCallBack(work.pUserWork); + } + } +} + +void clear_interpolation_history() { + s_recording = false; + s_replacementsActive = false; + s_syncPresentation = false; + s_previousRecording = {}; + s_currentRecording = {}; + clear_replacements(); + clear_callbacks(); + dusk::interp::camera_invalidate_snapshots(); + s_presentationDepth = 0; +} + +} // namespace + +namespace dusk::interp { + +void begin_sim_tick() { + if (!is_enabled()) { + return; + } + + clear_callbacks(); + camera_on_sim_tick(); + ++s_simTickSeq; +} + +uint64_t sim_tick_seq() { + return s_simTickSeq; +} + +void begin_frame(float step) { + const game_clock::FrameTiming& timing = game_clock::g_frameTiming; + if (s_observedPresentationEpoch != timing.presentationEpoch) { + s_observedPresentationEpoch = timing.presentationEpoch; + clear_interpolation_history(); + } + + s_step = std::clamp(step, 0.0f, 1.0f); + if (!is_enabled()) { + clear_interpolation_history(); + } +} + +bool is_enabled() { + return game_clock::g_frameTiming.interpolating; +} + +void begin_record() { + if (!is_enabled()) { + clear_interpolation_history(); + return; + } + + s_syncPresentation = false; + s_previousRecording = std::move(s_currentRecording); + s_currentRecording = {}; + s_recording = true; + s_replacementsActive = false; + clear_replacements(); + camera_on_begin_record(); +} + +void end_record() { + s_recording = false; +} + +void request_presentation_sync() { + if (!is_enabled()) { + return; + } + s_syncPresentation = true; +} + +bool presentation_sync_active() { + if (!is_enabled()) { + return false; + } + return s_syncPresentation; +} + +float get_interpolation_step() { + return presentation_sync_active() ? 1.0f : s_step; +} + +void set_ui_tick_pending(bool value) { + if (s_uiTickPending == value) { + return; + } + s_uiTickPending = value; +} + +bool get_ui_tick_pending() { + return is_enabled() ? s_uiTickPending : true; +} + +void record_final_mtx(Mtx m, const void* key) { + if (!s_recording || m == nullptr) { + return; + } + + auto& it = s_currentRecording.matrix_values[reinterpret_cast(key)]; + MTXCopy(m, it); +} + +void record_final_mtx(Mtx m) { + record_final_mtx(m, m); +} + +bool lookup_replacement(const void* key, Mtx out) { + if (presentation_sync_active() || !s_replacementsActive || key == nullptr) { + return false; + } + + auto it = g_replacements.find(reinterpret_cast(key)); + if (it == g_replacements.end()) { + return false; + } + + MTXCopy(it->second, out); + return true; +} + +bool lookup_concat_replacement(const void* lhs, const void* rhs, Mtx out) { + if (presentation_sync_active() || !s_replacementsActive || lhs == nullptr || rhs == nullptr) { + return false; + } + + Mtx lhs_scratch; + Mtx rhs_scratch; + const Mtx* resolved_lhs = resolve_replacement(reinterpret_cast(lhs), &lhs_scratch); + const Mtx* resolved_rhs = resolve_replacement(reinterpret_cast(rhs), &rhs_scratch); + if (resolved_lhs == reinterpret_cast(lhs) && + resolved_rhs == reinterpret_cast(rhs)) + { + return false; + } + + MTXConcat(*resolved_lhs, *resolved_rhs, out); + return true; +} + +void begin_presentation(float step) { + begin_frame(step); + if (!is_enabled()) { + return; + } + + interpolate_replacements(); + + if (s_presentationDepth > 0) { + s_presentationDepth++; + return; + } + if (!camera_apply_presentation()) { + return; + } + + s_presentationDepth = 1; + callbacks_run(); +} + +void end_presentation() { + if (s_presentationDepth == 0) { + return; + } + s_presentationDepth--; + if (s_presentationDepth > 0) { + return; + } + + camera_restore_presentation(); +} + +bool is_presentation_active() { + return s_presentationDepth > 0; +} + +void add_interpolation_callback(InterpolationCallBack pCallBack, void* pUserWork) { + if (!is_enabled() || is_presentation_active() || !game_clock::is_sim_frame()) { + return; + } + if (pCallBack == nullptr) { + return; + } + + s_interpolationCallBackWork.push_back({pCallBack, pUserWork}); +} + +} // namespace dusk::interp diff --git a/src/dusk/interp/frame_interpolation.h b/src/dusk/interp/frame_interpolation.h new file mode 100644 index 0000000000..57f079ad00 --- /dev/null +++ b/src/dusk/interp/frame_interpolation.h @@ -0,0 +1,40 @@ +#pragma once + +#include + +#include + +#ifdef __cplusplus +namespace dusk::interp { + +void begin_record(); +void end_record(); +void begin_sim_tick(); +uint64_t sim_tick_seq(); +void begin_frame(float step); +float get_interpolation_step(); + +void request_presentation_sync(); +bool presentation_sync_active(); + +bool is_enabled(); + +// TODO: These should be phased out as UI is progressively updated to use game_clock +void set_ui_tick_pending(bool value); +bool get_ui_tick_pending(); + +void record_final_mtx(Mtx m, const void* key); +void record_final_mtx(Mtx m); + +bool lookup_replacement(const void* key, Mtx out); +bool lookup_concat_replacement(const void* lhs, const void* rhs, Mtx out); + +void begin_presentation(float step); +void end_presentation(); +bool is_presentation_active(); + +typedef void (*InterpolationCallBack)(void* pUserWork); +void add_interpolation_callback(InterpolationCallBack pCallBack, void* pUserWork); + +} // namespace dusk::interp +#endif diff --git a/src/dusk/interp/lerp.h b/src/dusk/interp/lerp.h new file mode 100644 index 0000000000..1f05f070fa --- /dev/null +++ b/src/dusk/interp/lerp.h @@ -0,0 +1,53 @@ +#pragma once + +#include "SSystem/SComponent/c_angle.h" +#include "SSystem/SComponent/c_sxyz.h" +#include "SSystem/SComponent/c_xyz.h" + +#include +#include + +#ifdef __cplusplus +namespace dusk::interp { + +inline s16 lerp(s16 lhs, s16 rhs, float step) { + const f32 ra = S2RAD(lhs); + const f32 d = remainderf(S2RAD(rhs) - ra, 2.0f * M_PI); + return cAngle::Radian_to_SAngle(ra + d * step); +} + +inline u16 lerp(u16 lhs, u16 rhs, float step) { + return static_cast(lerp(static_cast(lhs), static_cast(rhs), step)); +} + +inline f32 lerp(f32 lhs, f32 rhs, float step) { + return lhs + (rhs - lhs) * step; +} + +inline u8 lerp(u8 lhs, u8 rhs, float step) { + return static_cast(std::lround(lerp(static_cast(lhs), static_cast(rhs), step))); +} + +inline void lerp(cXyz& out, const cXyz& lhs, const cXyz& rhs, float step) { + out.x = lerp(lhs.x, rhs.x, step); + out.y = lerp(lhs.y, rhs.y, step); + out.z = lerp(lhs.z, rhs.z, step); +} + +inline void lerp(csXyz& out, const csXyz& lhs, const csXyz& rhs, float step) { + out.x = lerp(lhs.x, rhs.x, step); + out.y = lerp(lhs.y, rhs.y, step); + out.z = lerp(lhs.z, rhs.z, step); +} + +inline void lerp(Mtx& out, const Mtx& lhs, const Mtx& rhs, float step) { + for (size_t row = 0; row < 3; ++row) { + for (size_t col = 0; col < 4; ++col) { + const float l = lhs[row][col]; + out[row][col] = l + (rhs[row][col] - l) * step; + } + } +} + +} // namespace dusk::interp +#endif diff --git a/src/f_ap/f_ap_game.cpp b/src/f_ap/f_ap_game.cpp index cff78bb7cf..a3a981eaba 100644 --- a/src/f_ap/f_ap_game.cpp +++ b/src/f_ap/f_ap_game.cpp @@ -24,9 +24,9 @@ #if TARGET_PC #include "dusk/achievements.h" #include "dusk/autosave.h" -#include "dusk/frame_interpolation.h" #include "dusk/game_mode.hpp" #include "dusk/gamepad_color.h" +#include "dusk/interp/frame_interpolation.h" #include "dusk/logging.h" #include "dusk/menu_pointer.h" #include "dusk/mod_loader.hpp" @@ -735,11 +735,11 @@ void fapGm_After() { #ifdef TARGET_PC static void fapGm_Before() { - dusk::frame_interp::begin_record(); + dusk::interp::begin_record(); } static void fapGm_AfterRecord() { - dusk::frame_interp::end_record(); + dusk::interp::end_record(); fapGm_After(); } @@ -829,7 +829,8 @@ void fapGm_Execute() { #endif cCt_Counter(0); -#ifdef TARGET_PC +#if TARGET_PC + dComIfGp_particle_calcMenu(); const dusk::gamemode::GameMode* gameMode = dusk::gamemode::getGameModeManager().getCurrentGameMode(); if (gameMode) { diff --git a/src/f_pc/f_pc_leaf.cpp b/src/f_pc/f_pc_leaf.cpp index 7ae56974ca..e2fdd97fb0 100644 --- a/src/f_pc/f_pc_leaf.cpp +++ b/src/f_pc/f_pc_leaf.cpp @@ -7,7 +7,7 @@ #include "f_pc/f_pc_debug_sv.h" #if TARGET_PC -#include "dusk/frame_interpolation.h" +#include "dusk/game_clock.h" #endif s16 fpcLf_GetPriority(const leafdraw_class* i_leaf) { @@ -21,7 +21,7 @@ int fpcLf_DrawMethod(leafdraw_method_class DUSK_CONST* i_methods, void* i_proces 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()) { + if (!i_leaf->draw_interp_frame && !dusk::game_clock::is_sim_frame()) { return ret; } #endif diff --git a/src/f_pc/f_pc_manager.cpp b/src/f_pc/f_pc_manager.cpp index 0af7092da4..d2276bf8cb 100644 --- a/src/f_pc/f_pc_manager.cpp +++ b/src/f_pc/f_pc_manager.cpp @@ -101,11 +101,13 @@ void fpcM_Management(fpcM_ManagementFunc i_preExecuteFn, fpcM_ManagementFunc i_p fpcDw_Handler((fpcDw_HandlerFuncFunc)fpcM_DrawIterater, (fpcDw_HandlerFunc)fpcM_Draw); } + IF_DUSK(dComIfGp_drawSimpleModel()); + if (i_postExecuteFn != NULL) { i_postExecuteFn(); } - dComIfGp_drawSimpleModel(); + IF_NOT_DUSK(dComIfGp_drawSimpleModel()); } else if (!l_dvdError) { dLib_time_c::stopTime(); Z2GetSoundMgr()->pauseAllGameSound(true); diff --git a/src/f_pc/f_pc_node.cpp b/src/f_pc/f_pc_node.cpp index a8fd47bd9c..7cc88ec0db 100644 --- a/src/f_pc/f_pc_node.cpp +++ b/src/f_pc/f_pc_node.cpp @@ -8,7 +8,7 @@ #include "f_pc/f_pc_debug_sv.h" #if TARGET_PC -#include "dusk/frame_interpolation.h" +#include "dusk/game_clock.h" #include "f_op/f_op_draw_iter.h" #include "f_pc/f_pc_manager.h" @@ -26,7 +26,7 @@ int fpcNd_Draw(process_node_class* i_procNode) { layer_class* save_layer = fpcLy_CurrentLayer(); fpcLy_SetCurrentLayer(&var_r28->layer); #if TARGET_PC - if (!i_procNode->draw_interp_frame && !dusk::frame_interp::is_sim_frame()) { + if (!i_procNode->draw_interp_frame && !dusk::game_clock::is_sim_frame()) { for (create_tag_class* i = fopDwIt_Begin(); i != NULL; i = fopDwIt_Next(i)) { void* process = i->mpTagData; fpcM_Draw(process); diff --git a/src/m_Do/m_Do_ext.cpp b/src/m_Do/m_Do_ext.cpp index a4003d1689..bf00990942 100644 --- a/src/m_Do/m_Do_ext.cpp +++ b/src/m_Do/m_Do_ext.cpp @@ -26,7 +26,8 @@ #include #if TARGET_PC -#include "dusk/frame_interpolation.h" +#include "dusk/interp/frame_interpolation.h" +#include "dusk/game_clock.h" #include "dusk/logging.h" #include "dusk/version.hpp" #endif @@ -314,7 +315,7 @@ static void mDoExt_modelDiff(J3DModel* i_model) { i_model->calcMaterial(); i_model->diff(); #if TARGET_PC - if (!dusk::frame_interp::is_sim_frame()) { + if (!dusk::game_clock::is_sim_frame()) { return; } #endif @@ -360,10 +361,11 @@ void mDoExt_modelUpdateDL(J3DModel* i_model) { void mDoExt_modelEntryDL(J3DModel* i_model) { #if TARGET_PC - if (!dusk::frame_interp::is_sim_frame()) { + if (!dusk::game_clock::is_sim_frame()) { // FRAME INTERP NOTE: This fixes issue #355 where some lights would flicker. // This is likely better solved by updating J3DMaterial::needsInterpCallBack, // but it's unclear what exactly needs to be added. + i_model->calcMaterial(); i_model->diff(); return; } @@ -2421,7 +2423,7 @@ void mDoExt_3DlineMat0_c::draw() { } #if TARGET_PC - if (!dusk::frame_interp::is_enabled()) + if (!dusk::interp::is_enabled()) #endif { field_0x16 ^= (u8)1; @@ -2753,7 +2755,7 @@ void mDoExt_3DlineMat1_c::draw() { } GXSetTexCoordScaleManually(GX_TEXCOORD0, 0, 0, 0); #if TARGET_PC - if (!dusk::frame_interp::is_enabled()) + if (!dusk::interp::is_enabled()) #endif { mIsDrawn ^= (u8)1; @@ -2835,7 +2837,7 @@ void mDoExt_3DlineMat1_c::update(int param_0, f32 param_1, GXColor& param_2, u16 } #if TARGET_PC - const cXyz& lineEye = (presentationEye != nullptr && dusk::frame_interp::is_enabled()) ? *presentationEye : sp_3c->lookat.eye; + const cXyz& lineEye = (presentationEye != nullptr && dusk::interp::is_enabled()) ? *presentationEye : sp_3c->lookat.eye; sp_13c = *local_r27 - lineEye; #else sp_13c = *local_r27 - sp_3c->lookat.eye; @@ -2996,7 +2998,7 @@ void mDoExt_3DlineMat1_c::update(int param_0, GXColor& param_2, dKy_tevstr_c* pa local_r27 = sp_38[0].field_0x0; size_p = sp_38->field_0x4; #if TARGET_PC - if (presentationEye != nullptr && dusk::frame_interp::is_enabled() && size_p == NULL) { + if (presentationEye != nullptr && dusk::interp::is_enabled() && size_p == NULL) { sp_38 += 1; continue; } @@ -3015,7 +3017,7 @@ void mDoExt_3DlineMat1_c::update(int param_0, GXColor& param_2, dKy_tevstr_c* pa local_f30 = sp_130.abs(); local_f31 += local_f30 * 0.1f; #if TARGET_PC - const cXyz& lineEye = (presentationEye != nullptr && dusk::frame_interp::is_enabled()) ? *presentationEye : stack_3c->lookat.eye; + const cXyz& lineEye = (presentationEye != nullptr && dusk::interp::is_enabled()) ? *presentationEye : stack_3c->lookat.eye; sp_13c = local_r27[0] - lineEye; #else sp_13c = local_r27[0] - stack_3c->lookat.eye; @@ -3091,7 +3093,7 @@ void mDoExt_3DlineMat1_c::update(int param_0, GXColor& param_2, dKy_tevstr_c* pa #if TARGET_PC void mDoExt_3DlineMat1_c::refreshGeometryForPresentationEye(const cXyz& eye) { - if (!dusk::frame_interp::is_enabled()) { + if (!dusk::interp::is_enabled()) { return; } if (mInterpLineKind == 1) { @@ -3654,12 +3656,22 @@ void mDoExt_cylinderMPacket::draw() { GXSetCullMode(GX_CULL_BACK); GXSetClipMode(GX_CLIP_ENABLE); +#if TARGET_PC + Mtx modelViewMtx; + cMtx_concat(j3dSys.getViewMtx(), mMatrix, modelViewMtx); + GXLoadPosMtxImm(modelViewMtx, 0); + + Mtx normalMtx; + cMtx_inverseTranspose(modelViewMtx, normalMtx); + GXLoadNrmMtxImm(normalMtx, 0); +#else cMtx_concat(j3dSys.getViewMtx(), mMatrix, mMatrix); GXLoadPosMtxImm(mMatrix, 0); cMtx_inverseTranspose(mMatrix, mMatrix); GXLoadNrmMtxImm(mMatrix, 0); +#endif GXSetCurrentMtx(0); GXDrawCylinder(8); diff --git a/src/m_Do/m_Do_graphic.cpp b/src/m_Do/m_Do_graphic.cpp index 2c966059e9..a203163192 100644 --- a/src/m_Do/m_Do_graphic.cpp +++ b/src/m_Do/m_Do_graphic.cpp @@ -47,9 +47,9 @@ #if TARGET_PC #include "dusk/dusk.h" -#include "dusk/frame_interpolation.h" #include "dusk/gfx.hpp" #include "dusk/imgui/ImGuiConsole.hpp" +#include "dusk/interp/frame_interpolation.h" #include "dusk/logging.h" #include "dusk/settings.h" #include "helpers/endian.h" @@ -476,38 +476,35 @@ void darwFilter(GXColor matColor) { } void mDoGph_gInf_c::calcFade() { -#if TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) -#endif - { - if (mFade != 0) { - mFadeRate += mFadeSpeed; + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) + if (mFade != 0) { + mFadeRate += mFadeSpeed; - if (mFadeRate < 0.0f) { - mFadeRate = 0.0f; - mFade = 0; - } else { - if (mFadeRate > 1.0f) { - mFadeRate = 1.0f; - } - } - mFadeColor.a = 255.0f * mFadeRate; + if (mFadeRate < 0.0f) { + mFadeRate = 0.0f; + mFade = 0; } else { - if (dComIfG_getBrightness() != 255) { - mFadeColor.r = 0; - mFadeColor.g = 0; - mFadeColor.b = 0; - mFadeColor.a = 255 - dComIfG_getBrightness(); - } else { - mFadeColor.a = 0; + if (mFadeRate > 1.0f) { + mFadeRate = 1.0f; } } + mFadeColor.a = 255.0f * mFadeRate; + } else { + if (dComIfG_getBrightness() != 255) { + mFadeColor.r = 0; + mFadeColor.g = 0; + mFadeColor.b = 0; + mFadeColor.a = 255 - dComIfG_getBrightness(); + } else { + mFadeColor.a = 0; + } } + IF_DUSK_BLOCK_END if (mFadeColor.a != 0) { -#ifdef TARGET_PC - if (dusk::frame_interp::is_enabled() && mFade != 0) { - const auto step = dusk::frame_interp::get_interpolation_step(); +#if TARGET_PC + if (dusk::interp::is_enabled() && mFade != 0) { + const auto step = dusk::interp::get_interpolation_step(); const auto progress = mFadeSpeed < 0.0f ? 1.0f - mFadeRate : mFadeRate; const auto fade_amt = mFadeRate + mFadeSpeed * (step - 1.0f + progress); mFadeColor.a = 255.0f * std::clamp(fade_amt, 0.0f, 1.0f); @@ -2172,7 +2169,7 @@ static void captureScreenPerspDrawInfo(JPADrawInfo& info) { static void drawItem3D() { ZoneScoped; #ifdef TARGET_PC - if (dusk::frame_interp::is_enabled()) { + if (dusk::interp::is_enabled()) { // FRAME INTERP NOTE: Title screen needs 0.0f while everything else that runs through this is -100.0f. if (fopAcM_SearchByName(fpcNm_TITLE_e) != nullptr) { dMenu_Collect3D_c::setViewPortOffsetY(0.0f); @@ -2215,12 +2212,7 @@ int mDoGph_Painter() { drawHeapMap(); #endif -#ifdef TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) -#endif - { - dComIfGp_particle_calcMenu(); - } + IF_NOT_DUSK(dComIfGp_particle_calcMenu()); JFWDisplay::getManager()->setFader(mDoGph_gInf_c::getFader()); mDoGph_gInf_c::setClearColor(mDoGph_gInf_c::getBackColor()); @@ -2350,7 +2342,7 @@ int mDoGph_Painter() { #endif dKy_setLight(); #if TARGET_PC - if (dusk::frame_interp::is_enabled()) { + if (dusk::interp::is_enabled()) { dKy_setLight_again(); } #endif @@ -2413,10 +2405,10 @@ int mDoGph_Painter() { } #if TARGET_PC - if (dusk::frame_interp::is_enabled()) { + if (dusk::interp::is_enabled()) { // FRAME INTERP NOTE: Currently only recalculating points for Epona's reins. Need a more global solution. if (daHorse_c* horse = dComIfGp_getHorseActor()) { - horse->lerpControlPoints(dusk::frame_interp::get_interpolation_step()); + horse->lerpControlPoints(dusk::interp::get_interpolation_step()); } g_dComIfG_gameInfo.drawlist.refresh3DlineMats(camera_p->view.lookat.eye); } @@ -2776,12 +2768,9 @@ int mDoGph_Painter() { #endif GXSetClipMode(GX_CLIP_ENABLE); -#if TARGET_PC - if (dusk::frame_interp::get_ui_tick_pending()) -#endif - { - dDlst_list_c::calcWipe(); - } + IF_DUSK_BLOCK(dusk::interp::get_ui_tick_pending()) + dDlst_list_c::calcWipe(); + IF_DUSK_BLOCK_END j3dSys.reinitGX(); ortho.setOrtho(mDoGph_gInf_c::getMinXF(), mDoGph_gInf_c::getMinYF(), diff --git a/src/m_Do/m_Do_main.cpp b/src/m_Do/m_Do_main.cpp index 63aa2d8946..3b5606eaae 100644 --- a/src/m_Do/m_Do_main.cpp +++ b/src/m_Do/m_Do_main.cpp @@ -43,13 +43,13 @@ #include "dusk/data.hpp" #include "dusk/discord_presence.hpp" #include "dusk/dusk.h" -#include "dusk/frame_interpolation.h" #include "dusk/game_clock.h" #include "dusk/game_combos.h" #include "dusk/gyro.h" #include "dusk/hq_minimap.hpp" #include "dusk/imgui/ImGuiConsole.hpp" #include "dusk/imgui/ImGuiEngine.hpp" +#include "dusk/interp/frame_interpolation.h" #include "dusk/iso_validate.hpp" #include "dusk/logging.h" #include "dusk/main.h" @@ -282,14 +282,13 @@ void main01(void) { dusk::ui::update(); const auto timing = dusk::game_clock::advance(); - const auto interpolationMode = dusk::getSettings().game.enableFrameInterpolation.getValue(); if (timing.separatePresentation) { if (timing.numSimTicks > 0) { - dusk::frame_interp::begin_frame(interpolationMode, true, 0.0f); - dusk::frame_interp::set_ui_tick_pending(true); + dusk::interp::begin_frame(0.0f); + dusk::interp::set_ui_tick_pending(true); for (int i = 0; i < timing.numSimTicks; ++i) { if (timing.interpolating) { - dusk::frame_interp::begin_sim_tick(); + dusk::interp::begin_sim_tick(); } dusk::game_clock::begin_sim_tick(); mDoCPd_c::read(); @@ -303,23 +302,15 @@ void main01(void) { } } - const float interpolationStep = - timing.interpolating ? dusk::game_clock::sample_interpolation_step() : 1.0f; - dusk::frame_interp::begin_frame(interpolationMode, false, interpolationStep); - if (timing.interpolating) { - dusk::frame_interp::interpolate(); - dusk::frame_interp::begin_presentation_camera(); - } - + const float step = timing.interpolating ? dusk::game_clock::sample_interpolation_step() : 1.0f; + dusk::interp::begin_presentation(step); fpcM_DrawIterater((fpcM_DrawIteraterFunc)fpcM_Draw); cAPIGph_Painter(); - if (timing.interpolating) { - dusk::frame_interp::end_presentation_camera(); - } - dusk::frame_interp::set_ui_tick_pending(false); + dusk::interp::end_presentation(); + dusk::interp::set_ui_tick_pending(false); } else { - dusk::frame_interp::begin_frame(dusk::FrameInterpMode::Off, true, 0.0f); - dusk::frame_interp::set_ui_tick_pending(true); + dusk::interp::begin_frame(0.0f); + dusk::interp::set_ui_tick_pending(true); dusk::game_clock::begin_sim_tick(); // Game Inputs