mirror of
https://github.com/MonsterDruide1/OdysseyDecomp
synced 2026-04-23 09:04:21 +00:00
all: Fix HackFork and some MathUtil functions (#798)
This commit is contained in:
parent
23f87c31d2
commit
bbf93327c5
|
|
@ -72428,7 +72428,7 @@ MapObj/HackFork.o:
|
|||
- offset: 0x29c6a4
|
||||
size: 1772
|
||||
label: _ZN8HackFork4initERKN2al13ActorInitInfoE
|
||||
status: NonMatchingMinor
|
||||
status: Matching
|
||||
- offset: 0x29cd90
|
||||
size: 348
|
||||
label: _ZN8HackFork17initBasicPoseInfoEv
|
||||
|
|
@ -260220,7 +260220,7 @@ Library/Math/MathUtil.o:
|
|||
- offset: 0x92783c
|
||||
size: 324
|
||||
label: _ZN2al16rotateQuatRadianEPN4sead4QuatIfEERKS2_RKNS0_7Vector3IfEEf
|
||||
status: NonMatchingMinor
|
||||
status: Matching
|
||||
- offset: 0x927980
|
||||
size: 88
|
||||
label: _ZN2al15makeQuatXDegreeEPN4sead4QuatIfEEf
|
||||
|
|
@ -260236,15 +260236,15 @@ Library/Math/MathUtil.o:
|
|||
- offset: 0x927a8c
|
||||
size: 292
|
||||
label: _ZN2al20rotateQuatXDirDegreeEPN4sead4QuatIfEERKS2_f
|
||||
status: NonMatchingMinor
|
||||
status: Matching
|
||||
- offset: 0x927bb0
|
||||
size: 292
|
||||
label: _ZN2al20rotateQuatYDirDegreeEPN4sead4QuatIfEERKS2_f
|
||||
status: NonMatchingMinor
|
||||
status: Matching
|
||||
- offset: 0x927cd4
|
||||
size: 292
|
||||
label: _ZN2al20rotateQuatZDirDegreeEPN4sead4QuatIfEERKS2_f
|
||||
status: NonMatchingMinor
|
||||
status: Matching
|
||||
- offset: 0x927df8
|
||||
size: 284
|
||||
label: _ZN2al24rotateQuatLocalDirDegreeEPN4sead4QuatIfEERKS2_if
|
||||
|
|
|
|||
|
|
@ -314,14 +314,11 @@ bool tryNormalizeOrZero(sead::Vector2f* out, const sead::Vector2f& vec) {
|
|||
}
|
||||
|
||||
bool tryNormalizeOrDirZ(sead::Vector3f* vec) {
|
||||
if (isNearZero(*vec)) {
|
||||
// mismatches if this isn't set twice
|
||||
vec->set(0.0f, 0.0f, 0.0f);
|
||||
if (!tryNormalizeOrZero(vec)) {
|
||||
vec->set(sead::Vector3f::ez);
|
||||
return false;
|
||||
}
|
||||
|
||||
normalize(vec);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -1243,20 +1240,11 @@ void makeQuatSideNoSupport(sead::Quatf* outQuat, const sead::Vector3f& side) {
|
|||
mtx.toQuat(*outQuat);
|
||||
}
|
||||
|
||||
// https://decomp.me/scratch/MqKUQ
|
||||
// NON_MATCHING: Regswap on Mult and Add
|
||||
void rotateQuatRadian(sead::Quatf* outQuat, const sead::Quatf& quat, const sead::Vector3f& vec,
|
||||
f32 angle) {
|
||||
f32 cos = sead::Mathf::cos(angle * 0.5f);
|
||||
f32 sin = sead::Mathf::sin(angle * 0.5f);
|
||||
|
||||
void rotateQuatRadian(sead::Quatf* outQuat, const sead::Quatf& quat, const sead::Vector3f& axis,
|
||||
f32 radian) {
|
||||
sead::Quatf rotation;
|
||||
rotation.w = cos;
|
||||
rotation.x = sin * vec.x;
|
||||
rotation.y = sin * vec.y;
|
||||
rotation.z = sin * vec.z;
|
||||
|
||||
*outQuat = rotation * quat;
|
||||
rotation.setAxisRadian(axis, radian);
|
||||
outQuat->setMul(rotation, quat);
|
||||
outQuat->normalize();
|
||||
}
|
||||
|
||||
|
|
@ -1290,30 +1278,24 @@ void makeQuatZDegree(sead::Quatf* outQuat, f32 angle) {
|
|||
outQuat->z = sin;
|
||||
}
|
||||
|
||||
// https://decomp.me/scratch/utMuy
|
||||
// NON_MATCHING: Regswap on Add
|
||||
void rotateQuatXDirDegree(sead::Quatf* outQuat, const sead::Quatf& quat, f32 angle) {
|
||||
sead::Quatf rotation;
|
||||
makeQuatXDegree(&rotation, angle);
|
||||
*outQuat = quat * rotation;
|
||||
outQuat->setMul(quat, rotation);
|
||||
outQuat->normalize();
|
||||
}
|
||||
|
||||
// https://decomp.me/scratch/DEZoH
|
||||
// NON_MATCHING: Regswap on Add
|
||||
void rotateQuatYDirDegree(sead::Quatf* outQuat, const sead::Quatf& quat, f32 angle) {
|
||||
sead::Quatf rotation;
|
||||
makeQuatYDegree(&rotation, angle);
|
||||
*outQuat = quat * rotation;
|
||||
outQuat->setMul(quat, rotation);
|
||||
outQuat->normalize();
|
||||
}
|
||||
|
||||
// https://decomp.me/scratch/iJBbn
|
||||
// NON_MATCHING: Regswap on Add
|
||||
void rotateQuatZDirDegree(sead::Quatf* outQuat, const sead::Quatf& quat, f32 angle) {
|
||||
sead::Quatf rotation;
|
||||
makeQuatZDegree(&rotation, angle);
|
||||
*outQuat = quat * rotation;
|
||||
outQuat->setMul(quat, rotation);
|
||||
outQuat->normalize();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -45,15 +45,18 @@ NERVE_IMPL(HackFork, HackWait);
|
|||
NERVE_IMPL(HackFork, HackBend);
|
||||
NERVE_IMPL(HackFork, HackShoot);
|
||||
|
||||
NERVES_MAKE_STRUCT(HackFork, Wait, HackStartWait, Damping, HackStart, HackWait, HackBend,
|
||||
HackShoot);
|
||||
} // namespace
|
||||
// TODO: Find a memory layout that fits these globals perfectly
|
||||
struct {
|
||||
NERVES_MAKE_STRUCT(HackFork, Wait, HackStartWait, Damping, HackStart, HackWait, HackBend,
|
||||
HackShoot);
|
||||
|
||||
PlayerHackStartShaderParam sPlayerHackStartShaderParam(true, 100.0f, 10, 20);
|
||||
PlayerHackStartShaderParam sPlayerHackStartShaderParam = {true, 100.0f, 10, 20};
|
||||
} HackForkData;
|
||||
|
||||
} // namespace
|
||||
|
||||
HackFork::HackFork(const char* name) : al::LiveActor(name) {}
|
||||
|
||||
// NON_MATCHING: Regswap and missing instructions https://decomp.me/scratch/NeUHJ
|
||||
void HackFork::init(const al::ActorInitInfo& info) {
|
||||
const char* modelName = nullptr;
|
||||
if (alPlacementFunction::tryGetModelName(&modelName, info))
|
||||
|
|
@ -72,7 +75,7 @@ void HackFork::init(const al::ActorInitInfo& info) {
|
|||
al::initJointLocalXRotator(this, &mDampingStrength, jointNames[i]);
|
||||
}
|
||||
|
||||
al::initNerve(this, &NrvHackFork.Wait, 0);
|
||||
al::initNerve(this, &HackForkData.NrvHackFork.Wait, 0);
|
||||
al::tryGetArg(&mIsLimitterFree, info, "LimitterFree");
|
||||
bool hasCamera = false;
|
||||
bool isValid = al::tryGetArg(&hasCamera, info, "Camera");
|
||||
|
|
@ -125,7 +128,8 @@ void HackFork::init(const al::ActorInitInfo& info) {
|
|||
mInvInitialHackDir.setInverse(mUpsideDownInitialHackDir);
|
||||
|
||||
initBasicPoseInfo();
|
||||
mHackStartShaderCtrl = new PlayerHackStartShaderCtrl(this, &sPlayerHackStartShaderParam);
|
||||
mHackStartShaderCtrl =
|
||||
new PlayerHackStartShaderCtrl(this, &HackForkData.sPlayerHackStartShaderParam);
|
||||
}
|
||||
|
||||
void HackFork::attackSensor(al::HitSensor* self, al::HitSensor* other) {
|
||||
|
|
@ -174,7 +178,7 @@ bool HackFork::receiveMsg(const al::SensorMsg* message, al::HitSensor* other, al
|
|||
mTouchForce = 0.0f;
|
||||
resetCapMtx(self);
|
||||
rs::setRouteHeadGuidePosPtr(this, &mHeadGuidePos);
|
||||
al::setNerve(this, &NrvHackFork.HackStartWait);
|
||||
al::setNerve(this, &HackForkData.NrvHackFork.HackStartWait);
|
||||
al::startHitReaction(this, "ひょうい開始");
|
||||
return true;
|
||||
}
|
||||
|
|
@ -200,7 +204,7 @@ bool HackFork::receiveMsg(const al::SensorMsg* message, al::HitSensor* other, al
|
|||
rs::endHack(&mPlayerHack);
|
||||
rs::resetRouteHeadGuidePosPtr(this);
|
||||
al::tryStartAction(this, "HackEnd");
|
||||
al::setNerve(this, &NrvHackFork.Damping);
|
||||
al::setNerve(this, &HackForkData.NrvHackFork.Damping);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -222,7 +226,7 @@ bool HackFork::receiveMsg(const al::SensorMsg* message, al::HitSensor* other, al
|
|||
}
|
||||
rs::resetRouteHeadGuidePosPtr(this);
|
||||
al::tryStartAction(this, "HackEnd");
|
||||
al::setNerve(this, &NrvHackFork.Damping);
|
||||
al::setNerve(this, &HackForkData.NrvHackFork.Damping);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -230,7 +234,7 @@ bool HackFork::receiveMsg(const al::SensorMsg* message, al::HitSensor* other, al
|
|||
rs::endHack(&mPlayerHack);
|
||||
rs::resetRouteHeadGuidePosPtr(this);
|
||||
al::tryStartAction(this, "HackEnd");
|
||||
al::setNerve(this, &NrvHackFork.Damping);
|
||||
al::setNerve(this, &HackForkData.NrvHackFork.Damping);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -246,7 +250,7 @@ void HackFork::initBasicPoseInfo() {
|
|||
al::calcFrontDir(&frontDir, this);
|
||||
|
||||
sead::Quatf rotation;
|
||||
sead::QuatCalcCommon<f32>::setAxisAngle(rotation, frontDir, 180.0f);
|
||||
rotation.setAxisAngle(frontDir, 180.0f);
|
||||
mUpsideDownInitialHackDir = rotation * mHackDir;
|
||||
|
||||
sead::Vector3f frontDir2;
|
||||
|
|
@ -278,7 +282,7 @@ bool HackFork::tryTouch(f32 force, const char* reactionName) {
|
|||
if (isNerveHackable()) {
|
||||
mTouchForce = force;
|
||||
mTouchDelay = 30;
|
||||
al::setNerve(this, &NrvHackFork.Damping);
|
||||
al::setNerve(this, &HackForkData.NrvHackFork.Damping);
|
||||
al::startHitReaction(this, reactionName);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -323,13 +327,16 @@ void HackFork::resetCapMtx(al::HitSensor* sensor) {
|
|||
}
|
||||
|
||||
bool HackFork::isNerveHackable() const {
|
||||
return al::isNerve(this, &NrvHackFork.Wait) || al::isNerve(this, &NrvHackFork.Damping);
|
||||
return al::isNerve(this, &HackForkData.NrvHackFork.Wait) ||
|
||||
al::isNerve(this, &HackForkData.NrvHackFork.Damping);
|
||||
}
|
||||
|
||||
bool HackFork::isHack() const {
|
||||
return al::isNerve(this, &NrvHackFork.HackStartWait) ||
|
||||
al::isNerve(this, &NrvHackFork.HackStart) || al::isNerve(this, &NrvHackFork.HackWait) ||
|
||||
al::isNerve(this, &NrvHackFork.HackBend) || al::isNerve(this, &NrvHackFork.HackShoot);
|
||||
return al::isNerve(this, &HackForkData.NrvHackFork.HackStartWait) ||
|
||||
al::isNerve(this, &HackForkData.NrvHackFork.HackStart) ||
|
||||
al::isNerve(this, &HackForkData.NrvHackFork.HackWait) ||
|
||||
al::isNerve(this, &HackForkData.NrvHackFork.HackBend) ||
|
||||
al::isNerve(this, &HackForkData.NrvHackFork.HackShoot);
|
||||
}
|
||||
|
||||
void HackFork::controlSpring() {
|
||||
|
|
@ -375,7 +382,7 @@ bool HackFork::trySwingJump() {
|
|||
al::calcFrontDir(&frontDir, this);
|
||||
bendAndTwist(mPullDirection, frontDir);
|
||||
mIsSwingJump = true;
|
||||
al::setNerve(this, &NrvHackFork.HackShoot);
|
||||
al::setNerve(this, &HackForkData.NrvHackFork.HackShoot);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -566,7 +573,7 @@ void HackFork::exeHackStartWait() {
|
|||
checkSwing();
|
||||
|
||||
if (rs::isHackStartDemoEnterMario(mPlayerHack))
|
||||
al::setNerve(this, &NrvHackFork.HackStart);
|
||||
al::setNerve(this, &HackForkData.NrvHackFork.HackStart);
|
||||
}
|
||||
|
||||
void HackFork::exeDamping() {
|
||||
|
|
@ -579,7 +586,7 @@ void HackFork::exeDamping() {
|
|||
mDampingForce = 0.0f;
|
||||
mTouchForce = 0.0f;
|
||||
al::validateClipping(this);
|
||||
al::setNerve(this, &NrvHackFork.Wait);
|
||||
al::setNerve(this, &HackForkData.NrvHackFork.Wait);
|
||||
return;
|
||||
}
|
||||
mDampingStrength *= 0.9f;
|
||||
|
|
@ -597,7 +604,7 @@ void HackFork::exeHackStart() {
|
|||
checkSwing();
|
||||
if (al::isActionEnd(this)) {
|
||||
rs::endHackStartDemo(mPlayerHack, this);
|
||||
al::setNerve(this, &NrvHackFork.HackWait);
|
||||
al::setNerve(this, &HackForkData.NrvHackFork.HackWait);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -612,7 +619,7 @@ void HackFork::exeHackWait() {
|
|||
sead::Mathf::cos(sead::Mathf::deg2rad(getJumpRange()))) {
|
||||
mPullDirection.set(pullDirection);
|
||||
mIsPullDown = mPullDirection.dot(mUpDir) < 0.0f;
|
||||
al::setNerve(this, &NrvHackFork.HackBend);
|
||||
al::setNerve(this, &HackForkData.NrvHackFork.HackBend);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -633,9 +640,9 @@ void HackFork::exeHackBend() {
|
|||
mAirVel = 60;
|
||||
mIsSwingJump = true;
|
||||
}
|
||||
al::setNerve(this, &NrvHackFork.HackShoot);
|
||||
al::setNerve(this, &HackForkData.NrvHackFork.HackShoot);
|
||||
} else {
|
||||
al::setNerve(this, &NrvHackFork.HackWait);
|
||||
al::setNerve(this, &HackForkData.NrvHackFork.HackWait);
|
||||
}
|
||||
}
|
||||
sead::Vector3f oldPullDirection = mPullDirection;
|
||||
|
|
@ -664,6 +671,6 @@ void HackFork::exeHackShoot() {
|
|||
controlSpring();
|
||||
if (mDampingForce < 0.0f) {
|
||||
shoot();
|
||||
al::setNerve(this, &NrvHackFork.Damping);
|
||||
al::setNerve(this, &HackForkData.NrvHackFork.Damping);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue