mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-06-03 01:58:44 -04:00
frame interp: fix b&c chain links (#724)
This commit is contained in:
@@ -4552,6 +4552,18 @@ public:
|
||||
void handleWolfHowl();
|
||||
void handleQuickTransform();
|
||||
bool checkGyroAimContext();
|
||||
|
||||
void onIronBallChainInterpCallback();
|
||||
|
||||
static const int IRON_BALL_CHAIN_COUNT = 102;
|
||||
cXyz mIBChainInterpPrevPos[IRON_BALL_CHAIN_COUNT];
|
||||
cXyz mIBChainInterpCurrPos[IRON_BALL_CHAIN_COUNT];
|
||||
csXyz mIBChainInterpPrevAngle[IRON_BALL_CHAIN_COUNT];
|
||||
csXyz mIBChainInterpCurrAngle[IRON_BALL_CHAIN_COUNT];
|
||||
cXyz mIBChainInterpPrevHandRoot;
|
||||
cXyz mIBChainInterpCurrHandRoot;
|
||||
bool mIBChainInterpPrevValid;
|
||||
bool mIBChainInterpCurrValid;
|
||||
#endif
|
||||
}; // Size: 0x385C
|
||||
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
#include "d/actor/d_a_ni.h"
|
||||
#include "d/d_s_play.h"
|
||||
|
||||
#include "dusk/frame_interpolation.h"
|
||||
#include "dusk/settings.h"
|
||||
#include "res/Object/Alink.h"
|
||||
#include <cstring>
|
||||
@@ -14787,6 +14788,10 @@ void daAlink_c::deleteEquipItem(BOOL i_isPlaySound, BOOL i_isDeleteKantera) {
|
||||
mIronBallChainPos = NULL;
|
||||
mIronBallChainAngle = NULL;
|
||||
field_0x3848 = NULL;
|
||||
#if TARGET_PC
|
||||
mIBChainInterpPrevValid = false;
|
||||
mIBChainInterpCurrValid = false;
|
||||
#endif
|
||||
field_0x0774 = NULL;
|
||||
field_0x0778 = NULL;
|
||||
mpHookshotLinChk = NULL;
|
||||
@@ -19717,6 +19722,27 @@ int daAlink_c::draw() {
|
||||
)
|
||||
{
|
||||
dComIfGd_getOpaListDark()->entryImm(mpHookChain, 0);
|
||||
|
||||
#if TARGET_PC
|
||||
if (dusk::getSettings().game.enableFrameInterpolation &&
|
||||
mEquipItem == dItemNo_IRONBALL_e &&
|
||||
mIronBallChainPos != NULL && mIronBallChainAngle != NULL)
|
||||
{
|
||||
if (mIBChainInterpCurrValid) {
|
||||
memcpy(mIBChainInterpPrevPos, mIBChainInterpCurrPos, IRON_BALL_CHAIN_COUNT * sizeof(cXyz));
|
||||
memcpy(mIBChainInterpPrevAngle, mIBChainInterpCurrAngle, IRON_BALL_CHAIN_COUNT * sizeof(csXyz));
|
||||
mIBChainInterpPrevHandRoot = mIBChainInterpCurrHandRoot;
|
||||
mIBChainInterpPrevValid = true;
|
||||
}
|
||||
|
||||
memcpy(mIBChainInterpCurrPos, mIronBallChainPos, IRON_BALL_CHAIN_COUNT * sizeof(cXyz));
|
||||
memcpy(mIBChainInterpCurrAngle, mIronBallChainAngle, IRON_BALL_CHAIN_COUNT * sizeof(csXyz));
|
||||
mIBChainInterpCurrHandRoot = mHookshotTopPos;
|
||||
mIBChainInterpCurrValid = true;
|
||||
|
||||
dusk::frame_interp::add_interpolation_callback(&ironBallChainInterpCallback, this);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
#include "d/actor/d_a_obj_swhang.h"
|
||||
#include "d/actor/d_a_obj_chandelier.h"
|
||||
#include "JSystem/J3DGraphBase/J3DMaterial.h"
|
||||
#include "dusk/frame_interpolation.h"
|
||||
#include "dusk/settings.h"
|
||||
|
||||
enum {
|
||||
HS_MODE_NONE_e,
|
||||
@@ -235,6 +237,31 @@ void daAlink_c::hsChainShape_c::draw() {
|
||||
}
|
||||
}
|
||||
|
||||
#if TARGET_PC
|
||||
static void ironBallChainInterpCallback(bool isSimFrame, void* pUserWork) {
|
||||
static_cast<daAlink_c*>(pUserWork)->onIronBallChainInterpCallback();
|
||||
}
|
||||
|
||||
void daAlink_c::onIronBallChainInterpCallback() {
|
||||
if (!mIBChainInterpPrevValid || !mIBChainInterpCurrValid) {
|
||||
return;
|
||||
}
|
||||
if (mIronBallChainPos == NULL || mIronBallChainAngle == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
const f32 alpha = dusk::frame_interp::get_interpolation_step();
|
||||
|
||||
for (int i = 0; i < IRON_BALL_CHAIN_COUNT; i++) {
|
||||
mIronBallChainPos[i] = mIBChainInterpPrevPos[i] + (mIBChainInterpCurrPos[i] - mIBChainInterpPrevPos[i]) * alpha;
|
||||
mIronBallChainAngle[i].x = mIBChainInterpPrevAngle[i].x + (s16)((s16)(mIBChainInterpCurrAngle[i].x - mIBChainInterpPrevAngle[i].x) * alpha);
|
||||
mIronBallChainAngle[i].y = mIBChainInterpPrevAngle[i].y + (s16)((s16)(mIBChainInterpCurrAngle[i].y - mIBChainInterpPrevAngle[i].y) * alpha);
|
||||
mIronBallChainAngle[i].z = mIBChainInterpPrevAngle[i].z + (s16)((s16)(mIBChainInterpCurrAngle[i].z - mIBChainInterpPrevAngle[i].z) * alpha);
|
||||
}
|
||||
mHookshotTopPos = mIBChainInterpPrevHandRoot + (mIBChainInterpCurrHandRoot - mIBChainInterpPrevHandRoot) * alpha;
|
||||
}
|
||||
#endif
|
||||
|
||||
void daAlink_c::hookshotAtHitCallBack(dCcD_GObjInf* i_atObjInf, fopAc_ac_c* i_tgActor,
|
||||
dCcD_GObjInf* i_tgObjInf) {
|
||||
if (i_tgActor != NULL && fopAcM_IsActor(i_tgActor) && !i_tgObjInf->ChkTgHookshotThrough()) {
|
||||
|
||||
Reference in New Issue
Block a user