INCOMPLETE: Util/ObjUtil: Implement judgeEnableWallKeepHistory

This commit is contained in:
MonsterDruide1 2024-06-22 22:45:00 +02:00
parent fc31e83fd5
commit 989cc4e6a9
3 changed files with 58 additions and 0 deletions

View file

@ -13,6 +13,12 @@ public:
void recordWallJump(const sead::Vector3f& position, const sead::Vector3f& normal);
void recordWallLeave(const sead::Vector3f& position, const sead::Vector3f& normal);
bool isJumpStored() const { return mIsJumpStored; }
const sead::Vector3f& getJumpWallPosition() const { return mJumpWallPosition; }
const sead::Vector3f& getJumpWallNormal() const { return mJumpWallNormal; }
bool isLeaveStored() const { return mIsLeaveStored; }
const sead::Vector3f& getLeaveWallPosition() const { return mLeaveWallPosition; }
private:
bool mIsJumpStored = false;
sead::Vector3f mJumpWallPosition = {0.0f, 0.0f, 0.0f};

47
src/Util/ObjUtil.cpp Normal file
View file

@ -0,0 +1,47 @@
#include "Util/ObjUtil.h"
#include "Library/LiveActor/ActorPoseUtil.h"
#include "Library/Math/MathUtil.h"
#include "Player/PlayerWallActionHistory.h"
namespace rs {
bool judgeEnableWallKeepHistory(const al::LiveActor* player, const PlayerWallActionHistory* history,
const sead::Vector3f& calcPos, const sead::Vector3f& wallNormal,
f32 unk, bool unk2) {
sead::Vector3f up = -al::getGravity(player);
if (history->isLeaveStored() && up.dot(calcPos - history->getLeaveWallPosition()) > -unk)
return false;
if (!history->isJumpStored())
return true;
sead::Vector3f horizontalDiff = {0.0f, 0.0f, 0.0f};
sead::Vector3f diffToLastJumpPos;
diffToLastJumpPos.x = (calcPos - history->getJumpWallPosition()).x;
diffToLastJumpPos.y = (calcPos - history->getJumpWallPosition()).y;
diffToLastJumpPos.z = (calcPos - history->getJumpWallPosition()).z;
al::verticalizeVec(&horizontalDiff, up, diffToLastJumpPos);
f32 cosAngleOfWalls = wallNormal.dot(history->getJumpWallNormal());
if (cosAngleOfWalls > -0.34202f) { // cos(110°), smaller => larger angle
f32 v21 = 0.0f;
if (unk2) {
f32 horizontalDist = horizontalDiff.length();
if (cosAngleOfWalls <= 0.087156f) { // cos(85°)
v21 = ((sead::Mathf::clamp((1000.0f - horizontalDist) / 500.0f, -1.0f, 1.0f) - 1.0f) * 1500.0f) * 0.5f;
} else {
v21 = ((sead::Mathf::clamp((750.0f - horizontalDist) / 750.0f, -1.0f, 1.0f) - 1.0f) * 1500.0f) * 0.5f;
}
}
return up.dot(diffToLastJumpPos) <= v21;
}
if (!unk2)
return true;
f32 horizontalDist = horizontalDiff.length();
return horizontalDist <= 1500.0f || up.dot(diffToLastJumpPos) <= 1500.0f - horizontalDist;
}
} // namespace rs

View file

@ -14,6 +14,7 @@ class PlayerConst;
class PlayerModelHolder;
class PlayerInput;
class PlayerTrigger;
class PlayerWallActionHistory;
namespace rs {
@ -81,4 +82,8 @@ void moveInertiaSlide(sead::Vector3f*, al::LiveActor*, const IUsePlayerCollision
const sead::Vector3f&, f32, f32, f32, f32, f32, f32, f32);
void moveInertiaSlideOnSkate(sead::Vector3f*, al::LiveActor*, const IUsePlayerCollision*,
const sead::Vector3f&, f32, f32, f32, f32, f32, f32, f32);
bool judgeEnableWallKeepHistory(const al::LiveActor* player, const PlayerWallActionHistory* history,
const sead::Vector3f& calcPos, const sead::Vector3f& wallNormal, f32 unk, bool unk2);
} // namespace rs