This commit is contained in:
MonsterDruide1 2024-04-07 20:36:03 +02:00
parent 26b03af44e
commit c5b04a098a
17 changed files with 683 additions and 176 deletions

View File

@ -26087,12 +26087,12 @@ Address,Quality,Size,Name
0x0000007100419128,U,000184,_ZN29PlayerActionSlopeSlideControl5setupEv
0x00000071004191e0,U,000284,_ZN29PlayerActionSlopeSlideControl24setupCutSlideOppositeDirEv
0x00000071004192fc,U,002068,_ZN29PlayerActionSlopeSlideControl6updateEffffffffffb
0x0000007100419b10,U,000124,_ZN23PlayerActionTurnControlC2EPN2al9LiveActorE
0x0000007100419b8c,U,000028,_ZN23PlayerActionTurnControl5setupEffffiii
0x0000007100419ba8,U,000024,_ZN23PlayerActionTurnControl5resetEv
0x0000007100419bc0,U,002832,_ZN23PlayerActionTurnControl6updateERKN4sead7Vector3IfEES4_
0x000000710041a6d0,U,000388,_ZN23PlayerActionTurnControl8calcTiltEPN4sead7Vector3IfEERKS2_f
0x000000710041a854,U,000100,_ZNK23PlayerActionTurnControl17calcTurnPowerRateERKN4sead7Vector3IfEE
0x0000007100419b10,W,000124,_ZN23PlayerActionTurnControlC1EPN2al9LiveActorE
0x0000007100419b8c,O,000028,_ZN23PlayerActionTurnControl5setupEffffiii
0x0000007100419ba8,O,000024,_ZN23PlayerActionTurnControl5resetEv
0x0000007100419bc0,W,002832,_ZN23PlayerActionTurnControl6updateERKN4sead7Vector3IfEES4_
0x000000710041a6d0,M,000388,_ZN23PlayerActionTurnControl8calcTiltEPN4sead7Vector3IfEERKS2_f
0x000000710041a854,O,000100,_ZNK23PlayerActionTurnControl17calcTurnPowerRateERKN4sead7Vector3IfEE
0x000000710041a8b8,U,000484,_ZN27PlayerActionVelocityControlC2EPN2al9LiveActorEPK19IUsePlayerCollision
0x000000710041aa9c,U,000036,_ZN27PlayerActionVelocityControl14calcFrontBrakeEf
0x000000710041aac0,U,000232,_ZN27PlayerActionVelocityControl21calcSideVelocityLimitERKN4sead7Vector3IfEEfff
@ -58791,12 +58791,12 @@ Address,Quality,Size,Name
0x0000007100923cd8,U,000208,_ZN2al26separateScalarAndDirectionEPfPN4sead7Vector2IfEERKS3_
0x0000007100923da8,U,000268,_ZN2al26separateScalarAndDirectionEPfPN4sead7Vector3IfEERKS3_
0x0000007100923eb4,U,000300,_ZN2al21limitVectorSeparateHVEPN4sead7Vector3IfEERKS2_ff
0x0000007100923fe0,U,000072,_ZN2al14parallelizeVecEPN4sead7Vector3IfEERKS2_S5_
0x0000007100924028,U,000280,_ZN2al20calcVectorSeparateHVEPN4sead7Vector3IfEERKS2_S5_ff
0x0000007100923fe0,O,000072,_ZN2al14parallelizeVecEPN4sead7Vector3IfEERKS2_S5_
0x0000007100924028,O,000280,_ZN2al20calcVectorSeparateHVEPN4sead7Vector3IfEERKS2_S5_ff
0x0000007100924140,U,000300,_ZN2al27limitVectorParallelVerticalEPN4sead7Vector3IfEERKS2_ff
0x000000710092426c,U,000116,_ZN2al30separateVectorParallelVerticalEPN4sead7Vector3IfEES3_RKS2_S5_
0x000000710092426c,O,000116,_ZN2al30separateVectorParallelVerticalEPN4sead7Vector3IfEES3_RKS2_S5_
0x00000071009242e0,U,000364,_ZN2al14addVectorLimitEPN4sead7Vector3IfEERKS2_f
0x000000710092444c,U,000684,_ZN2al18alongVectorNormalHEPN4sead7Vector3IfEERKS2_S5_S5_
0x000000710092444c,W,000684,_ZN2al18alongVectorNormalHEPN4sead7Vector3IfEERKS2_S5_S5_
0x00000071009246f8,U,000160,_ZN2al22calcDistanceVecToPlaneERKN4sead7Vector3IfEES4_S4_S4_
0x0000007100924798,U,000100,_ZN2al13limitPlanePosEPN4sead7Vector3IfEERKS2_S5_S5_
0x00000071009247fc,U,000264,_ZN2al18limitCylinderInPosEPN4sead7Vector3IfEERKS2_S5_S5_f

Can't render this file because it is too large.

View File

@ -1,37 +0,0 @@
#pragma once
#include <math/seadVector.h>
namespace al{
class LiveActor;
}
class PlayerActionTurnControl {
public:
PlayerActionTurnControl(al::LiveActor*);
void setup(float, float, float, float, int, int, int);
void reset();
void update(const sead::Vector3f&, const sead::Vector3f&);
void calcTilt(sead::Vector3f*, const sead::Vector3f&, float);
float calcTurnPowerRate(const sead::Vector3f&) const;
private:
const al::LiveActor *mLiveActor;
float val;
sead::Vector3f someVector;
sead::Vector3f someVectorTurnPowerRate;
sead::Vector3f someVector2;
float something;
int placeholder;
void *someArray;
int someThings[2];
int placeholder4[2];
sead::Vector3f someVector4;
sead::Vector3f someVector3;
bool gap[4];
float values[4];
int values2[3];
bool placeholder2[2];
};

View File

@ -0,0 +1,48 @@
#pragma once
// TODO: includes ActorActionKeeper.h
namespace al {
class ActorActionKeeper {
public:
al::LiveActor *mParentActor; // 0x0
char *mActorName; // 0x8
undefined ukn[8]; // 0x10
al::ActionAnimCtrl *mAnimCtrl; // 0x18
al::NerveActionCtrl *mNrvActionCtrl; // 0x20
al::ActionFlagCtrl *mFlagCtrl; // 0x28
al::ActionEffectCtrl *mEffectCtrl; // 0x30
al::ActionSeCtrl *mSeCtrl; // 0x38
al::ActionBgmCtrl *mBgmCtrl; // 0x40
al::ActionPadAndCameraCtrl *mPadAndCamCtrl; // 0x48
al::ActionScreenEffectCtrl *mScreenEffectCtrl; // 0x50
ActorActionKeeper(
al::LiveActor *parentActor,
char const *actorName,
al::ActionAnimCtrl *animCtrl,
al::NerveActionCtrl *nrvActionCtrl,
al::ActionFlagCtrl *flagCtrl,
al::ActionEffectCtrl *effectCtrl,
al::ActionSeCtrl *seCtrl,
al::ActionBgmCtrl *bgmCtrl,
al::ActionPadAndCameraCtrl *padAndCamCtrl,
al::ActionScreenEffectCtrl *screenEffectCtrl
);
void init();
void startAction(char const *actionName);
void tryStartActionNoAnim(char const *actionName);
void updatePost();
void updatePrev();
static al::ActorActionKeeper* tryCreate(
al::LiveActor *actor,
al::ActorResource const *actorResource,
char const *uknStr1,
char const *uknStr2
);
};
static_assert(sizeof(ActorActionKeeper) == 0x58, "");
}

View File

@ -0,0 +1,9 @@
#pragma once
#include <basis/seadTypes.h>
namespace al{
f32 converge(f32, f32, f32);
}

View File

@ -0,0 +1,21 @@
#pragma once
#include <math/seadQuat.h>
#include <math/seadVector.h>
namespace al {
void makeQuatFrontUp(sead::Quatf*,const sead::Vector3f&,const sead::Vector3f&);
void makeQuatRotationLimit(sead::Quatf*, const sead::Vector3f&, const sead::Vector3f&, float);
void calcQuatFront(sead::Vector3f*, const sead::Quatf&);
void calcQuatUp(sead::Vector3f*, const sead::Quatf&);
void turnVecToVecDegree(sead::Vector3f*, const sead::Vector3f&, const sead::Vector3f&, float);
void turnVecToVecRate(sead::Vector3f*, const sead::Vector3f&, const sead::Vector3f&, float);
bool turnQuatFrontToDirDegreeH(sead::Quatf* a1, const sead::Vector3f& a2, float a3);
bool turnQuat(sead::Quatf*, const sead::Quatf&, const sead::Vector3f&, const sead::Vector3f&, float);
bool turnQuatYDirRate(sead::Quatf*, const sead::Quatf&, const sead::Vector3f&, float);
} // namespace al

View File

@ -16,6 +16,8 @@ f32 powerOut(f32, f32);
f32 lerpValue(f32, f32, f32);
f32 calcRate01(f32, f32, f32);
template <typename T>
inline T clamp(T value, T min, T max) {
if (value < min)

View File

@ -6,17 +6,72 @@
namespace al {
void turnVecToVecDegree(sead::Vector3f*, const sead::Vector3f&, const sead::Vector3f&, f32);
void turnVecToVecRate(sead::Vector3f*, const sead::Vector3f&, const sead::Vector3f&, f32);
void calcQuatFront(sead::Vector3f*, const sead::Quatf&);
void calcQuatUp(sead::Vector3f*, const sead::Quatf&);
void makeQuatFrontUp(sead::Quatf*, const sead::Vector3f&, const sead::Vector3f&);
void makeMtxFrontUpPos(sead::Matrix34f*, const sead::Vector3f&, const sead::Vector3f&,
void separateScalarAndDirection(float*, sead::Vector2f*, const sead::Vector2f&);
void separateScalarAndDirection(float*, sead::Vector3f*, const sead::Vector3f&);
void limitVectorSeparateHV(sead::Vector3f*, const sead::Vector3f&, float, float);
void parallelizeVec(sead::Vector3f*, const sead::Vector3f&, const sead::Vector3f&);
void calcVectorSeparateHV(sead::Vector3f*, const sead::Vector3f&, const sead::Vector3f&, float,
float);
void limitVectorParallelVertical(sead::Vector3f*, const sead::Vector3f&, float, float);
void separateVectorParallelVertical(sead::Vector3f*, sead::Vector3f*, const sead::Vector3f&,
const sead::Vector3f&);
void makeMtxUpFrontPos(sead::Matrix34f*, const sead::Vector3f&, const sead::Vector3f&,
void addVectorLimit(sead::Vector3f*, const sead::Vector3f&, float);
void alongVectorNormalH(sead::Vector3f*, const sead::Vector3f&, const sead::Vector3f&,
const sead::Vector3f&);
void makeMtxRotateTrans(sead::Matrix34f*, const sead::Vector3f&, const sead::Vector3f&);
void calcDistanceVecToPlane(const sead::Vector3f&, const sead::Vector3f&, const sead::Vector3f&,
const sead::Vector3f&);
void limitPlanePos(sead::Vector3f*, const sead::Vector3f&, const sead::Vector3f&,
const sead::Vector3f&);
void limitCylinderInPos(sead::Vector3f*, const sead::Vector3f&, const sead::Vector3f&,
const sead::Vector3f&, float);
void limitCylinderInDir(sead::Vector3f*, const sead::Vector3f&, const sead::Vector3f&,
const sead::Vector3f&, const sead::Vector3f&);
void limitCylinderInPos(sead::Vector3f*, const sead::Vector3f&, const sead::Vector3f&, float);
void limitCylinderInDir(sead::Vector3f*, const sead::Vector3f&, const sead::Vector3f&,
const sead::Vector3f&);
void roundOffVec(sead::Vector3f*, const sead::Vector3f&);
void roundOffVec(sead::Vector3f*);
void roundOffVec(sead::Vector2f*, const sead::Vector2f&);
void roundOffVec(sead::Vector2f*);
void snapToGrid(float, float, float);
void snapVecToGrid(sead::Vector3f*, const sead::Vector3f&, float, const sead::Vector3f&);
void snapVecToGrid(sead::Vector3f*, const sead::Vector3f&, const sead::Vector3f&,
const sead::Vector3f&);
void limitVectorOppositeDir(sead::Vector3f*, const sead::Vector3f&, const sead::Vector3f&, float);
void scaleVectorDirection(sead::Vector3f*, const sead::Vector3f&, const sead::Vector3f&, float);
void scaleVectorExceptDirection(sead::Vector3f*, const sead::Vector3f&, const sead::Vector3f&,
float);
void snapVecToDirAxisY(sead::Vector3f*, const sead::Vector3f&, int);
void calcDir(sead::Vector3f*, const sead::Vector3f&, const sead::Vector3f&);
void calcDirH(sead::Vector3f*, const sead::Vector3f&, const sead::Vector3f&);
void calcDirOnPlane(sead::Vector3f*, const sead::Vector3f&, const sead::Vector3f&,
const sead::Vector3f&);
void mapRangeLogarithmic(float, float, float, float, float, float);
void calcDirFromLongitudeLatitude(sead::Vector3f*, float, float);
void calcLongitudeLatitudeFromDir(float*, float*, const sead::Vector3f&);
void getMaxAbsElementIndex(const sead::Vector3i&);
void getMaxAbsElementValue(const sead::Vector3f&);
void getMaxAbsElementValue(const sead::Vector3i&);
void getMinAbsElementIndex(const sead::Vector3f&);
void getMinAbsElementIndex(const sead::Vector3i&);
void getMinAbsElementValue(const sead::Vector3f&);
void getMinAbsElementValue(const sead::Vector3i&);
void calcNearVecFromAxis2(sead::Vector3f*, const sead::Vector3f&, const sead::Vector3f&,
const sead::Vector3f&);
void calcNearVecFromAxis3(sead::Vector3f*, const sead::Vector3f&, const sead::Vector3f&,
const sead::Vector3f&, const sead::Vector3f&);
void calcDirVerticalAny(sead::Vector3f*, const sead::Vector3f&);
void calcDirSlide(sead::Vector3f*, const sead::Vector3f&, const sead::Vector3f&);
void calcNearVecFromAxis3(sead::Vector3f*, const sead::Vector3f&, const sead::Quatf&);
void calcQuatLocalAxisAll(const sead::Quatf&, sead::Vector3f*, sead::Vector3f*, sead::Vector3f*);
void addRandomVector(sead::Vector3f*, const sead::Vector3f&, float);
void turnRandomVector(sead::Vector3f*, const sead::Vector3f&, float);
void makeAxisFrontUp(sead::Vector3f*, sead::Vector3f*, const sead::Vector3f&,
const sead::Vector3f&);
void makeAxisFrontSide(sead::Vector3f*, sead::Vector3f*, const sead::Vector3f&,
const sead::Vector3f&);
void makeAxisUpFront(sead::Vector3f*, sead::Vector3f*, const sead::Vector3f&,
const sead::Vector3f&);
void makeAxisUpSide(sead::Vector3f*, sead::Vector3f*, const sead::Vector3f&, const sead::Vector3f&);
} // namespace al

View File

@ -1,7 +1,8 @@
#include "Library/LiveActor/ActorPoseKeeper.h"
#include "Library/LiveActor/LiveActorUtil.h"
#include "Library/Math/VectorUtil.h"
#include "Library/Math/MathQuatUtil.h"
#include "Library/Math/MathUtil.h"
namespace al {

View File

@ -0,0 +1,40 @@
#include "Library/Math/MathQuatUtil.h"
namespace al {
sead::Vector3f someSubOperation(const sead::Quatf& a1, const sead::Vector3f& a2) {
return a1.vector().cross(a2) + a2*a1.scalar();
}
sead::Vector3f someOperation(const sead::Quatf& a1, const sead::Vector3f& a2) {
sead::Vector3f x1 = someSubOperation(a1, a2);
float x2 = a1.vector().dot(-a2);
return someSubOperation(a1, x1) - x2*a1.vector();
}
bool turnQuatFrontToDirDegreeH(sead::Quatf* a1, const sead::Vector3f& a2, float a3) {
sead::Vector3f x0 = a2;
x0.y = 0.0f;
if(x0.squaredLength() < 0.000001f) {
x0 = {0.0f, 0.0f, 0.0f};
return true;
}
x0.normalize();
sead::Vector3f x3 = someOperation(*a1, sead::Vector3f::ez);
if(!(
x3.dot(a2) >= 0.0f ||
sead::Mathf::abs(x3.cross(a2).x) > 0.01f ||
sead::Mathf::abs(x3.cross(a2).y) > 0.01f ||
sead::Mathf::abs(x3.cross(a2).z) > 0.01f
)) {
sead::Vector3f x6 = someOperation(*a1, sead::Vector3f::ex);
x0 = a2 + x6 * 0.01f;
}
bool check = turnQuat(a1, *a1, x3, x0, sead::Mathf::deg2rad(a3));
turnQuatYDirRate(a1, *a1, {0.0f, 1.0f, 0.0f}, 0.2f);
return check;
}
}

View File

@ -0,0 +1,74 @@
#include "Library/Math/VectorUtil.h"
namespace al {
void parallelizeVec(sead::Vector3f* out, const sead::Vector3f& parallel, const sead::Vector3f& vec) {
f32 factor = parallel.dot(vec);
out->x = parallel.x * factor;
out->y = parallel.y * factor;
out->z = parallel.z * factor;
}
void calcVectorSeparateHV(sead::Vector3f* out, const sead::Vector3f& a1, const sead::Vector3f& a2, float a3, float a4) {
f32 factor = a2.dot(a1);
sead::Vector3f x2;
x2.x = a1.x - (a2.x * factor);
x2.y = a1.y - (a2.y * factor);
x2.z = a1.z - (a2.z * factor);
if(x2.squaredLength() < 0.000001f) {
x2.x = 0;
x2.y = 0;
x2.z = 0;
} else {
x2.normalize();
}
*out = (x2 * a3) + (a2 * a4);
}
void separateVectorParallelVertical(sead::Vector3f* out1, sead::Vector3f* out2, const sead::Vector3f& a1, const sead::Vector3f& a2) {
f32 factor = a1.dot(a2);
out1->x = a1.x * factor;
out1->y = a1.y * factor;
out1->z = a1.z * factor;
out2->x = a2.x - out1->x;
out2->y = a2.y - out1->y;
out2->z = a2.z - out1->z;
}
void alongVectorNormalH(sead::Vector3f* out, const sead::Vector3f& a2p, const sead::Vector3f& a3, const sead::Vector3f& a4) {
const sead::Vector3f a2 = a2p;
sead::Vector3f x1 = a3.cross(a4);
f32 sqLenX1 = x1.squaredLength();
if (sqLenX1 < 0.000001f) {
f32 factor = a4.dot(a2p);
out->x = a2p.x - (a4.x * factor);
out->y = a2p.y - (a4.y * factor);
out->z = a2p.z - (a4.z * factor);
//sead::Vector3f nul;
//separateVectorParallelVertical(&nul, out, a4, a2p);
return;
}
sead::Vector3f nul;
sead::Vector3f x2;
separateVectorParallelVertical(&nul, &x2, a2, a3);
//sead::Vector3f x2 = a2 - (a3 * a2.dot(a3));
x1.normalize();
f32 v35 = a3.dot(a4);
f32 v39 = sead::Mathf::atan2(a3.cross(a4).length(), v35) * 0.5f;
f32 cos = sead::Mathf::cos(v39);
f32 sin = sead::Mathf::sin(v39);
sead::Vector3f x5 = sin*x1;
sead::Vector3f x6 = (cos*x2) + x2.cross(x5);
sead::Vector3f x8 = (cos*x6) + x6.cross(x5);
sead::Vector3f x7;
parallelizeVec(&x7, -x5, x2);
*out = x7 + x8;
}
}

@ -1 +1 @@
Subproject commit 19d98a993f3b7a30857c0ba026f9885c104a0cdb
Subproject commit 848314c0ceb12d6b5a8255e7d78e7fff227ca9ee

View File

@ -9,6 +9,7 @@
#include "Library/LiveActor/LiveActorUtil.h"
#include "Library/Math/MathAngleUtil.h"
#include "Library/Math/MathLengthUtil.h"
#include "Library/Math/MathQuatUtil.h"
#include "Library/Math/MathUtil.h"
#include "Library/Math/VectorUtil.h"
#include "Library/Nerve/NerveSetupUtil.h"

View File

@ -0,0 +1,12 @@
#pragma once
#include <math/seadVector.h>
namespace PlayerActionFunction {
bool isOppositeDir(const sead::Vector3f&, const sead::Vector3f&);
f32 accel(f32, f32, f32);
f32 brake(f32, u32, f32);
}

View File

@ -0,0 +1,348 @@
#include "Player/PlayerActionTurnControl.h"
#include <basis/seadNew.h>
#include "Library/LiveActor/ActorPoseKeeper.h"
#include "Library/Math/MathAngleUtil.h"
#include "Library/Math/MathLengthUtil.h"
#include "Library/Math/MathLerpUtil.h"
#include "Library/Math/MathQuatUtil.h"
#include "Library/Math/MathUtil.h"
#include "Library/Math/VectorUtil.h"
#include "Player/PlayerActionFunction.h"
PlayerActionTurnControl::PlayerActionTurnControl(al::LiveActor* liveActor) : mLiveActor(liveActor) {
float* arr = new (8, std::nothrow) float[5];
if (arr) {
_48 = 0;
this->mArr = arr;
mArrSize = 5;
_44 = 0;
}
}
void PlayerActionTurnControl::setup(float turnAngleStart, float turnAngleFast, float turnAngleLimit,
float turnAngleFastLimit, int turnAccelFrame,
int turnAccelFrameFast, int turnBrakeFrame) {
mTurnAngleStart = turnAngleStart;
mTurnAngleFast = turnAngleFast;
mTurnAngleLimit = turnAngleLimit;
mTurnAngleFastLimit = turnAngleFastLimit;
mTurnAccelFrame = turnAccelFrame;
mTurnAccelFrameFast = turnAccelFrameFast;
mTurnBrakeFrame = turnBrakeFrame;
}
void PlayerActionTurnControl::reset() {
_44 = 0;
_48 = 0;
_30 = 0.0;
_8 = 0.0;
_c = {0, 0, 0};
_18 = {0, 0, 0};
_24 = {0, 0, 0};
}
void PlayerActionTurnControl::update(const sead::Vector3f& a2, const sead::Vector3f& gravity) {
sead::Vector3f front = {0, 0, 0};
al::calcFrontDir(&front, mLiveActor);
sead::Vector3f up = {0, 0, 0};
al::calcUpDir(&up, mLiveActor);
sead::Vector3f& v1 = front; // get new name, but causes more mismatches if using new variable
al::alongVectorNormalH(&v1, front, up, gravity);
al::tryNormalizeOrZero(&v1);
_50 = v1;
sead::Vector3f v99 = {0, 0, 0};
if (!al::isNearZero(_c, 0.001f) || !al::isNearZero(_24, 0.001f)) {
al::alongVectorNormalH(&v99, _c, _24, gravity);
al::tryNormalizeOrZero(&v99);
}
sead::Vector3f normalizedGravity = {0, 0, 0};
bool hasGravity = al::tryNormalizeOrZero(&normalizedGravity, gravity);
sead::Vector3f actorGravity = al::getGravity(mLiveActor);
bool v89 = up.dot(-actorGravity) < 0.087156f && _89;
bool v14 = al::isNearZero(v1, 0.001f);
bool v15 = v89 || v14;
bool v16 = al::isNearZero(v99, 0.001f);
bool v17 = hasGravity && !v16;
bool v18 = v16 || !hasGravity;
float v19;
if (v18 || normalizedGravity.dot(v99) < 0.34202f) {
_44 = 0;
_48 = 0;
_30 = 0.0;
v19 = 0.0;
} else {
float v20;
if (hasGravity && !v16) {
v20 = sead::Mathf::abs(al::calcAngleDegree(v99, normalizedGravity));
} else {
v20 = 0.0;
}
int v48 = _48;
int loc_arrsize = mArrSize;
int v44 = _44;
int v24;
if (v48 < loc_arrsize)
goto LABEL_21;
v24 = v48 - 1;
if (v48 >= 1) {
int v25 = _44;
int v26;
if (v25 + 1 < loc_arrsize)
v26 = v25 + 1;
else
v26 = 0;
v48 = v24;
_44 = v26;
_48 = v24;
loc_arrsize = mArrSize;
v44 = _44;
}
if (v48 < loc_arrsize) {
LABEL_21:
int v27 = v48 + 1;
int v28 = v44 + v48;
if (v28 < loc_arrsize)
loc_arrsize = 0;
int v29 = v28 - loc_arrsize;
_48 = v27;
mArr[v29] = v20;
}
int v31 = _48;
_30 = 0.0;
int v32 = std::min(v31, 5);
// __OFSUB__ ?
int v33 = v31 - 1;
int v34 = v31 - 1;
float v38 = 0.0;
if (v34 < 0 == v33) {
int v35 = mArrSize;
int v36 = _44;
int i = 0;
do {
int v40;
if (v34 + v36 >= v35)
v40 = v35;
else
v40 = 0;
int v41 = v34 + v36 - v40;
--v34;
v38 += mArr[v41];
_30 = v38;
} while (++i < v32);
}
v19 = v38 / 5.0;
_30 = v38 / 5.0;
}
bool v42, v43, v44;
if (v89 || v14 || !hasGravity) {
v42 = false;
v43 = false;
v44 = hasGravity;
} else {
bool isOppositeDir = PlayerActionFunction::isOppositeDir(normalizedGravity, v1);
v42 = false;
if (v18 || (v17 && v19 <= 1.0f)) {
v44 = hasGravity;
v43 = false;
if (isOppositeDir) {
// there's more complicated stuff here
v43 = _88;
v42 = !_88;
v44 = hasGravity & v43;
}
} else {
v44 = hasGravity;
v43 = false;
}
}
_68 = v42;
_69 = v43;
_6a = v89;
sead::Vector3f v98 = {0, 0, 0};
// also seems more complicated
if ((v44 & (v15 ^ 1) & 1) == 0) {
if (hasGravity) {
if (v42) {
v98 = v1;
_8 = 0.0f;
} else {
v98 = normalizedGravity;
if (_89)
_8 = mTurnAngleFastLimit;
}
} else if (!_89) {
if (v15)
al::calcFrontDir(&v98, mLiveActor);
else
v98 = v1;
_c = {0, 0, 0};
_18 = {0, 0, 0};
_24 = {0, 0, 0};
_8 = PlayerActionFunction::brake(_8, mTurnBrakeFrame, mTurnAngleLimit);
} else {
al::calcFrontDir(&v98, mLiveActor);
if (up.dot(-actorGravity) < 0.0f) {
v98 *= (-1);
}
_c = {0, 0, 0};
_18 = {0, 0, 0};
_24 = {0, 0, 0};
_8 = mTurnAngleFastLimit;
}
_5c = v98;
return;
}
float v48;
if (v17) {
v48 = v99.dot(normalizedGravity);
} else {
v48 = v1.dot(normalizedGravity);
}
float v49 = sead::Mathf::clamp(v48, -1.0f, 1.0f);
float v50 = sead::Mathf::cos(v49);
float v53 = sead::Mathf::clamp(v1.dot(normalizedGravity), -1.0f, 1.0f);
float v54 = sead::Mathf::cos(v53);
sead::Vector3f v97 = v99.cross(normalizedGravity);
al::tryNormalizeOrZero(&v97);
bool v57, v58;
sead::Vector3f v95;
if (!v17 || al::isNearZero(_18, 0.001f)) {
v57 = false;
v58 = false;
} else {
float v55 = sead::Mathf::rad2deg(v50);
if (v97.dot(_18) <= 0.0f) {
v57 = false;
if (v55 >= sead::Mathf::max(mTurnAngleStart, _8)) {
_8 = 0.0f;
v58 = false;
} else {
_8 = al::converge(_8, 0.0f, v55);
v58 = v55 < mTurnAngleStart;
}
} else {
v95 = v1.cross(normalizedGravity);
if (!al::tryNormalizeOrZero(&v95) || v95.dot(v97) >= 0.0f) {
v57 = false;
v58 = false;
} else {
v57 = v19 > 10.0f || v55 > 3.0f;
v58 = v19 <= 10.0f && v55 <= 3.0f;
}
}
}
float v59 = sead::Mathf::rad2deg(v54);
float v60 = al::calcRate01(gravity.length(), 0.0f, 0.8f);
float v61 = sead::Mathf::clamp(v60, 0.25f, 1.0f);
if (v59 < mTurnAngleStart) {
_8 = PlayerActionFunction::brake(_8, mTurnBrakeFrame, mTurnAngleLimit);
} else if (v59 >= mTurnAngleFast) {
_8 = PlayerActionFunction::accel(_8, mTurnAngleFastLimit,
mTurnAngleFastLimit / (float)mTurnAccelFrameFast);
} else {
f32 x2 = v61 * mTurnAngleLimit;
if (_8 >= x2) {
_8 = PlayerActionFunction::brake(_8, mTurnBrakeFrame, mTurnAngleFastLimit);
} else {
_8 = PlayerActionFunction::accel(_8, x2, x2 / (float)mTurnAccelFrame);
}
}
sead::Vector3f v73v;
sead::Vector3f v96 = {0, 0, 0};
if (v57 || al::isReverseDirection(v1, normalizedGravity, 0.01f)) {
sead::Vector3f v67v = gravity;
if (v97.dot(gravity) <= 0.0) {
v67v = -v67v;
}
float v72 = sead::Mathf::deg2rad(_8) * 0.5f;
float cos = sead::Mathf::cos(v72);
float sin = sead::Mathf::sin(v72);
sead::Vector3f v78v = v67v * sin;
sead::Vector3f helper = v78v.cross(v1) + (cos * v1);
float v84 = -v78v.dot(v1);
v98 = v78v.cross(helper) + (cos * helper) - (v78v * v84);
al::tryNormalizeOrZero(&v98);
v73v = v67v;
v96 = v67v;
} else {
sead::Quatf quat = {0, 0, 0, 1};
al::makeQuatRotationLimit(&quat, v1, normalizedGravity, sead::Mathf::deg2rad(_8));
sead::Vector3f v78v = {quat.x, quat.y, quat.z};
float cos = quat.w;
sead::Vector3f helper = v78v.cross(v1) + (cos * v1);
float v84 = -v78v.dot(v1);
v98 = v78v.cross(helper) + (cos * helper) - (v78v * v84);
al::normalize(&v98);
v96 = v1.cross(normalizedGravity);
al::tryNormalizeOrZero(&v96);
if (v58 && v96.dot(_18) < 0.0f) {
v96 = -v96;
}
v73v = v96;
}
_18 = v73v;
_c = normalizedGravity;
_24 = gravity;
_5c = v98;
}
// NON_MATCHING: floating-point math
void PlayerActionTurnControl::calcTilt(sead::Vector3f* a1, const sead::Vector3f& a2, float a3) {
sead::Vector3f local5c = _5c;
float turnPowerRate = calcTurnPowerRate(a2);
float v13 = sead::Mathf::deg2rad(turnPowerRate * a3) * 0.5f;
float v14 = sead::Mathf::cos(v13);
float v15 = sead::Mathf::sin(v13);
sead::Vector3f sin5c = v15 * local5c;
sead::Vector3f another = sin5c.cross(a2) + (v14*a2);
float val = -sin5c.dot(a2);
*a1 = sin5c.cross(another) + (v14*another) - (sin5c*val);
}
float PlayerActionTurnControl::calcTurnPowerRate(const sead::Vector3f& a1) const {
float result = al::easeIn(al::calcRate01(_8, mTurnAngleStart, mTurnAngleLimit));
if (a1.dot(_18) > 0) {
return -result;
}
return result;
}

View File

@ -0,0 +1,49 @@
#pragma once
#include <math/seadVector.h>
namespace al {
class LiveActor;
}
class PlayerActionTurnControl {
public:
PlayerActionTurnControl(al::LiveActor*);
void setup(float turnAngleStart, float turnAngleFast, float turnAngleLimit,
float turnAngleFastLimit, int turnAccelFrame, int turnAccelFrameFast,
int turnBrakeFrame);
void reset();
void update(const sead::Vector3f&, const sead::Vector3f&);
void calcTilt(sead::Vector3f*, const sead::Vector3f&, float);
float calcTurnPowerRate(const sead::Vector3f&) const;
private:
const al::LiveActor* mLiveActor;
float _8 = 0;
sead::Vector3f _c = {0, 0, 0};
sead::Vector3f _18 = {0, 0, 0};
sead::Vector3f _24 = {0, 0, 0};
float _30 = 0;
int _34 = 0;
float* mArr = nullptr;
int mArrSize = 0;
int _44 = 0;
int _48 = 0;
int _4c = 0;
sead::Vector3f _50 = {0, 0, 0};
sead::Vector3f _5c = {0, 0, 0};
bool _68 = false;
bool _69 = false;
bool _6a = false;
bool pad;
float mTurnAngleStart = 0;
float mTurnAngleFast = 0;
float mTurnAngleLimit = 0;
float mTurnAngleFastLimit = 0;
int mTurnAccelFrame = 0;
int mTurnAccelFrameFast = 0;
int mTurnBrakeFrame = 0;
bool _88 = false;
bool _89 = false;
bool pad2[6];
};

View File

@ -1,3 +0,0 @@
target_sources(odyssey PRIVATE
PlayerActionTurnControl.cpp
)

View File

@ -1,113 +0,0 @@
#include "al/control/PlayerActionTurnControl.h"
#include <math.h>
#include "al/util/MathUtil.h"
void PlayerActionTurnControl::setup(float a1, float a2, float a3, float a4, int a5, int a6, int a7){
values[0] = a1;
values[1] = a2;
values[2] = a3;
values[3] = a4;
values2[0] = a5;
values2[1] = a6;
values2[2] = a7;
}
void PlayerActionTurnControl::reset(){
someThings[1] = 0;
placeholder4[0] = 0;
something = 0;
val = 0;
someVector = {0,0,0};
someVector2 = {0,0,0};
someVectorTurnPowerRate = {0,0,0};
}
void PlayerActionTurnControl::calcTilt(sead::Vector3f* a1, const sead::Vector3f& a2, float a3) {
float turnPowerRate = calcTurnPowerRate(a2);
float v13 = (turnPowerRate * a3) * 0.017453f * 0.5f;
float v14 = std::cosf(v13);
float v15 = std::sinf(v13);
float v18 = someVector3.x * v15;
float v19 = someVector3.y * v15;
float v20 = someVector3.z * v15;
//sead::Vector3f newSomeVector3 = someVector3 * v15;
float v21 = (v19 * a2.z) - (v20 * a2.y) + (v14 * a2.x);
float v22 = -(v18 * a2.x) - (v19 * a2.y);
float v23 = (v14 * a2.y) + ((v20 * a2.x) - (v18 * a2.z));
float v24 = (v14 * a2.z) + ((v18 * a2.y) - (v19 * a2.x));
float v25 = v22 - (a2.z * v20);
a1->x = (v19 * v24) + ((v14 * v21) - (v20 * v23)) - (v18 * v25);
a1->y = (v20 * v21) + (v14 * v23) - (v18 * v24) - (v19 * v25);
a1->z = (v14 * v24) + ((v18 * v23) - (v19 * v21)) - (v20 * v25);
/*float v7; // s10
float v8; // s11
float v10; // s12
float v11; // s0
float v12; // s0
float v13; // s8
float v14; // s9
float v15; // s0
float v16; // s1
float v17; // s3
float v18; // s4
float v19; // s5
float v20; // s0
float v21; // s6
float v22; // s2
float v23; // s16
float v24; // s3
float v25; // s1
v7 = this->someVector3.x;
v8 = this->someVector3.y;
v10 = this->someVector3.z;
v12 = calcTurnPowerRate(a2);
v13 = (float)((float)(v12 * a3) * 0.017453f) * 0.5f;
v14 = std::cosf(v13);
v15 = std::sinf(v13);
float a2x = a2.x;
v17 = a2.y;
v16 = a2.z;
v18 = v7 * v15;
v19 = v8 * v15;
v20 = v10 * v15;
float v211 = v19 * v16;
float v212 = v20 * v17;
float v213 = v211 - v212;
v21 = v213 + (v14 * a2x);
float v221 = (v18 * a2x);
float v222 = -v221;
float v223 = (v19 * v17);
v22 = v222 - v223;
float v231 = (v20 * a2x);
float v232 = (v16 * v18);
v23 = (v14 * v17) + (v231 - v232);
float v241 = (v18 * v17) - (v19 * a2x);
float v242 = (v14 * v16);
v24 = v242 + v241;
v25 = v22 - (v16 * v20);
a1->x = ((v19 * v24) + ((v14 * v21) - (v20 * v23))) - (v18 * v25);
a1->y = (((v20 * v21) + (v14 * v23)) - (v18 * v24)) - (v19 * v25);
a1->z = ((v14 * v24) + ((v18 * v23) - (v19 * v21))) - (v20 * v25);
/**/
}
float PlayerActionTurnControl::calcTurnPowerRate(const sead::Vector3f& a1) const {
float result = al::easeIn(al::calcRate01(val, values[0], values[2]));
if(sead::dot(a1, someVectorTurnPowerRate) > 0){
return -result;
}
return result;
}