mirror of
https://github.com/MonsterDruide1/OdysseyDecomp
synced 2026-04-23 09:04:21 +00:00
Library/Math: Implement random MathUtil functions (#973)
This commit is contained in:
parent
ebbcdfcaf0
commit
fc21c020ce
|
|
@ -259436,7 +259436,7 @@ Library/Math/MathUtil.o:
|
|||
- offset: 0x91f7b4
|
||||
size: 168
|
||||
label: _ZN2al18isReverseDirectionERKN4sead7Vector3IfEES4_f
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x91f85c
|
||||
size: 72
|
||||
label: _ZN2al15isNearDirectionERKN4sead7Vector2IfEES4_f
|
||||
|
|
@ -259444,7 +259444,7 @@ Library/Math/MathUtil.o:
|
|||
- offset: 0x91f8a4
|
||||
size: 168
|
||||
label: _ZN2al15isNearDirectionERKN4sead7Vector3IfEES4_f
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x91f94c
|
||||
size: 56
|
||||
label: _ZN2al9isInRangeEiii
|
||||
|
|
@ -259724,7 +259724,7 @@ Library/Math/MathUtil.o:
|
|||
- offset: 0x922108
|
||||
size: 120
|
||||
label: _ZN2al20isInRangeAngleDegreeEfff
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x922180
|
||||
size: 832
|
||||
label: _ZN2al24calcEyesAnimAngleInRangeEPfRKN4sead7Vector3IfEES5_S5_S5_ffff
|
||||
|
|
@ -259916,7 +259916,7 @@ Library/Math/MathUtil.o:
|
|||
- offset: 0x923fe0
|
||||
size: 72
|
||||
label: _ZN2al14parallelizeVecEPN4sead7Vector3IfEERKS2_S5_
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x924028
|
||||
size: 280
|
||||
label: _ZN2al20calcVectorSeparateHVEPN4sead7Vector3IfEERKS2_S5_ff
|
||||
|
|
@ -259928,7 +259928,7 @@ Library/Math/MathUtil.o:
|
|||
- offset: 0x92426c
|
||||
size: 116
|
||||
label: _ZN2al30separateVectorParallelVerticalEPN4sead7Vector3IfEES3_RKS2_S5_
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x9242e0
|
||||
size: 364
|
||||
label: _ZN2al14addVectorLimitEPN4sead7Vector3IfEERKS2_f
|
||||
|
|
@ -259940,11 +259940,11 @@ Library/Math/MathUtil.o:
|
|||
- offset: 0x9246f8
|
||||
size: 160
|
||||
label: _ZN2al22calcDistanceVecToPlaneERKN4sead7Vector3IfEES4_S4_S4_
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x924798
|
||||
size: 100
|
||||
label: _ZN2al13limitPlanePosEPN4sead7Vector3IfEERKS2_S5_S5_
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x9247fc
|
||||
size: 264
|
||||
label: _ZN2al18limitCylinderInPosEPN4sead7Vector3IfEERKS2_S5_S5_f
|
||||
|
|
@ -259960,7 +259960,7 @@ Library/Math/MathUtil.o:
|
|||
- offset: 0x924b30
|
||||
size: 32
|
||||
label: _ZN2al18limitCylinderInDirEPN4sead7Vector3IfEERKS2_S5_S5_
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x924b50
|
||||
size: 96
|
||||
label: _ZN2al11roundOffVecEPN4sead7Vector3IfEERKS2_
|
||||
|
|
@ -260076,11 +260076,11 @@ Library/Math/MathUtil.o:
|
|||
- offset: 0x925f3c
|
||||
size: 172
|
||||
label: _ZN2al20calcNearVecFromAxis3EPN4sead7Vector3IfEERKS2_RKNS0_4QuatIfEE
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x925fe8
|
||||
size: 136
|
||||
label: _ZN2al20calcQuatLocalAxisAllERKN4sead4QuatIfEEPNS0_7Vector3IfEES7_S7_
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x926070
|
||||
size: 212
|
||||
label: _ZN2al15addRandomVectorEPN4sead7Vector3IfEERKS2_f
|
||||
|
|
@ -260300,19 +260300,19 @@ Library/Math/MathUtil.o:
|
|||
- offset: 0x929658
|
||||
size: 400
|
||||
label: _ZN2al14tiltQuatDegreeEPN4sead4QuatIfEERKS2_RKNS0_7Vector3IfEES9_f
|
||||
status: NotDecompiled
|
||||
status: NonMatchingMinor
|
||||
- offset: 0x9297e8
|
||||
size: 128
|
||||
label: _ZN2al18tiltQuatXDirDegreeEPN4sead4QuatIfEERKS2_RKNS0_7Vector3IfEEf
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x929868
|
||||
size: 124
|
||||
label: _ZN2al18tiltQuatYDirDegreeEPN4sead4QuatIfEERKS2_RKNS0_7Vector3IfEEf
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x9298e4
|
||||
size: 124
|
||||
label: _ZN2al18tiltQuatZDirDegreeEPN4sead4QuatIfEERKS2_RKNS0_7Vector3IfEEf
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x929960
|
||||
size: 448
|
||||
label: _ZN2al22turnQuatWithAxisDegreeEPN4sead4QuatIfEERKS2_RKNS0_7Vector3IfEES9_S9_f
|
||||
|
|
@ -260372,7 +260372,7 @@ Library/Math/MathUtil.o:
|
|||
- offset: 0x92b1ac
|
||||
size: 24
|
||||
label: _ZN2al22turnVecToVecCosOnPlaneEPN4sead7Vector3IfEERKS2_S5_f
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x92b1c4
|
||||
size: 356
|
||||
label: _ZN2al24rotateVectorCenterDegreeEPN4sead7Vector3IfEERKS2_S5_S5_f
|
||||
|
|
@ -260396,7 +260396,7 @@ Library/Math/MathUtil.o:
|
|||
- offset: 0x92b6f4
|
||||
size: 148
|
||||
label: _ZN2al16calcAreaTriangleERKN4sead7Vector3IfEES4_S4_
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x92b788
|
||||
size: 196
|
||||
label: _ZN2al17createBoundingBoxEPKN4sead7Vector3IfEEjPS2_S5_
|
||||
|
|
@ -260404,7 +260404,7 @@ Library/Math/MathUtil.o:
|
|||
- offset: 0x92b84c
|
||||
size: 112
|
||||
label: _ZN2al17updateBoundingBoxEN4sead7Vector3IfEEPS2_S3_
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x92b8bc
|
||||
size: 188
|
||||
label: _ZN2al39calcDistanceToFarthestBoundingBoxVertexERKN4sead7Vector3IfEES4_S4_
|
||||
|
|
@ -260416,7 +260416,7 @@ Library/Math/MathUtil.o:
|
|||
- offset: 0x92bac4
|
||||
size: 128
|
||||
label: _ZN2al18calcCrossLinePointEPN4sead7Vector2IfEERKS2_S5_S5_S5_
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x92bb44
|
||||
size: 708
|
||||
label: _ZN2al35calcSquaredDistanceSegmentToSegmentERKN4sead7Vector3IfEES4_S4_S4_PS2_S5_
|
||||
|
|
@ -260440,7 +260440,7 @@ Library/Math/MathUtil.o:
|
|||
- offset: 0x92c1f8
|
||||
size: 120
|
||||
label: _ZN2al21calcCylinderRadiusDotERKN4sead7Vector3IfEES4_f
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x92c270
|
||||
size: 180
|
||||
label: _ZN2al21checkHitSemilinePlaneEPN4sead7Vector3IfEERKS2_S5_S5_S5_
|
||||
|
|
@ -260472,7 +260472,7 @@ Library/Math/MathUtil.o:
|
|||
- offset: 0x92d528
|
||||
size: 176
|
||||
label: _ZN2al22checkHitHalfLineSphereERKN4sead7Vector3IfEES4_S4_f
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x92d5d8
|
||||
size: 180
|
||||
label: _ZN9Intersect5calcXEPN4sead7Vector3IfEEfRKS2_S5_S5_S5_
|
||||
|
|
@ -260520,7 +260520,7 @@ Library/Math/MathUtil.o:
|
|||
- offset: 0x92e9f0
|
||||
size: 164
|
||||
label: _ZN2al23isNearCollideSphereAabbERKN4sead7Vector3IfEEfRKNS0_9BoundBox3IfEE
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x92ea94
|
||||
size: 372
|
||||
label: _ZN2al16calcBoxFacePointEPN4sead7Vector3IfEERKNS0_9BoundBox3IfEEi
|
||||
|
|
@ -260564,7 +260564,7 @@ Library/Math/MathUtil.o:
|
|||
- offset: 0x92faa8
|
||||
size: 44
|
||||
label: _ZN2al17calcDistanceToObbERKN4sead7Vector3IfEERKNS0_8Matrix34IfEES4_RKNS0_9BoundBox3IfEE
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x92fad4
|
||||
size: 424
|
||||
label: _ZN2al24calcSquaredDistanceToObbERKN4sead7Vector3IfEERKNS0_8Matrix34IfEE
|
||||
|
|
@ -260592,11 +260592,11 @@ Library/Math/MathUtil.o:
|
|||
- offset: 0x9309f8
|
||||
size: 168
|
||||
label: _ZN2al20calcReflectionVectorEPN4sead7Vector3IfEERKS2_ff
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x930aa0
|
||||
size: 96
|
||||
label: _ZN2al17calcReverseVectorEPN4sead7Vector3IfEERKS2_f
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x930b00
|
||||
size: 136
|
||||
label: _ZN2al26calcParabolicFunctionParamEPfS0_ff
|
||||
|
|
@ -260612,7 +260612,7 @@ Library/Math/MathUtil.o:
|
|||
- offset: 0x930e38
|
||||
size: 172
|
||||
label: _ZN2al15calcBezierPointEPN4sead7Vector3IfEERKS2_S5_S5_S5_f
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x930ee4
|
||||
size: 20
|
||||
label: _ZN2al21calcSpringDumperForceEffff
|
||||
|
|
@ -260636,7 +260636,7 @@ Library/Math/MathUtil.o:
|
|||
- offset: 0x931268
|
||||
size: 80
|
||||
label: _ZN2al17getHaltonSequenceEjj
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x9312b8
|
||||
size: 100
|
||||
label: _ZN2al11calcFractalEffjfffb
|
||||
|
|
@ -260648,7 +260648,7 @@ Library/Math/MathUtil.o:
|
|||
- offset: 0x931390
|
||||
size: 112
|
||||
label: _ZN2al22calcNormalDistributionEfff
|
||||
status: NotDecompiled
|
||||
status: Matching
|
||||
- offset: 0x931400
|
||||
size: 652
|
||||
label: _ZN2al16calcVecViewInputEPN4sead7Vector3IfEERKNS0_7Vector2IfEERKS2_PKNS0_8Matrix34IfEE
|
||||
|
|
|
|||
|
|
@ -19,10 +19,6 @@
|
|||
|
||||
namespace al {
|
||||
|
||||
inline f32 modDegree(f32 deg) {
|
||||
return modf(deg + 360.0f, 360.0f) + 0.0f;
|
||||
}
|
||||
|
||||
void resetPosition(LiveActor* actor) {
|
||||
if (actor->getPoseKeeper())
|
||||
actor->calcAnim();
|
||||
|
|
@ -1061,15 +1057,15 @@ f32 calcDistanceFront(const LiveActor* actor, const LiveActor* target) {
|
|||
}
|
||||
|
||||
void addRotateAndRepeatX(LiveActor* actor, f32 deg) {
|
||||
setRotateX(actor, modDegree(getRotate(actor).x + deg));
|
||||
setRotateX(actor, wrapAngle(getRotate(actor).x + deg));
|
||||
}
|
||||
|
||||
void addRotateAndRepeatY(LiveActor* actor, f32 deg) {
|
||||
setRotateY(actor, modDegree(getRotate(actor).y + deg));
|
||||
setRotateY(actor, wrapAngle(getRotate(actor).y + deg));
|
||||
}
|
||||
|
||||
void addRotateAndRepeatZ(LiveActor* actor, f32 deg) {
|
||||
setRotateZ(actor, modDegree(getRotate(actor).z + deg));
|
||||
setRotateZ(actor, wrapAngle(getRotate(actor).z + deg));
|
||||
}
|
||||
|
||||
void addRandomRotateY(LiveActor* actor) {
|
||||
|
|
|
|||
|
|
@ -233,7 +233,7 @@ void ClockMapParts::exeRotateSign() {
|
|||
if (isFirstStep(this))
|
||||
tryStartAction(this, "MiddleSign");
|
||||
|
||||
f32 angle = modf((f32)(mCurrentStep * mClockAngleDegree) + 360.0f, 360.0f) + 0.0f;
|
||||
f32 angle = wrapAngle(mCurrentStep * mClockAngleDegree);
|
||||
|
||||
rotateQuatLocalDirDegree(this, mQuat, mRotateAxis,
|
||||
angle + sead::Mathf::sin((f32)mTimer * sead::Mathf::pi2() / 18.0f));
|
||||
|
|
@ -245,7 +245,7 @@ void ClockMapParts::exeRotateSign() {
|
|||
|
||||
void ClockMapParts::exeRotate() {
|
||||
f32 time = (f32)(mTimer - mRotateSignTime) / (f32)(mRotateTimer + ~mRotateSignTime);
|
||||
f32 angle = modf((time + (f32)mCurrentStep) * (f32)mClockAngleDegree + 360.0f, 360.0f) + 0.0f;
|
||||
f32 angle = wrapAngle((time + mCurrentStep) * mClockAngleDegree);
|
||||
rotateQuatLocalDirDegree(this, mQuat, mRotateAxis, angle);
|
||||
|
||||
mTimer++;
|
||||
|
|
|
|||
|
|
@ -69,8 +69,7 @@ void ConveyerMapParts::init(const ActorInitInfo& info) {
|
|||
f32 startRate = 0.0f;
|
||||
tryGetArg(&startRate, info, "StartRate");
|
||||
|
||||
f32 rate = mPartsInterval * startRate;
|
||||
mOffsetCoord = modf(rate + mPartsInterval, mPartsInterval) + 0.0f;
|
||||
mOffsetCoord = wrapValue(mPartsInterval * startRate, mPartsInterval);
|
||||
|
||||
mConveyerStepGroup = new DeriveActorGroup<ConveyerStep>("コンベア足場リスト", groupCount);
|
||||
registerConveyerSteps(mConveyerStepGroup, info);
|
||||
|
|
@ -156,7 +155,7 @@ void ConveyerMapParts::exeMove() {
|
|||
if (!mIsRideOnlyMove || mRideActiveFrames >= 1) {
|
||||
f32 speedFactor =
|
||||
mIsRideOnlyMove ? (f32)mRideActiveFrames / (f32)mMaxRideActiveFrames : 1.0f;
|
||||
mOffsetCoord = modf(mOffsetCoord + speedFactor * mMoveSpeed + mMaxCoord, mMaxCoord) + 0.0f;
|
||||
mOffsetCoord = wrapValue(mOffsetCoord + speedFactor * mMoveSpeed, mMaxCoord);
|
||||
|
||||
bool isForwards = mMoveSpeed >= 0.0f;
|
||||
s32 actorCount = mConveyerStepGroup->getActorCount();
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ void ConveyerStep::setTransByCoord(f32 coord, bool isForwards) {
|
|||
}
|
||||
|
||||
void ConveyerStep::setTransByCoord(f32 coord, bool isForwards, bool isForceReset) {
|
||||
f32 newCoord = modf(mMaxCoord + coord, mMaxCoord) + 0.0f;
|
||||
f32 newCoord = wrapValue(coord, mMaxCoord);
|
||||
s32 index = -1;
|
||||
|
||||
mConveyerKeyKeeper->calcPosAndQuat(getTransPtr(this), getQuatPtr(this), &index, newCoord);
|
||||
|
|
|
|||
|
|
@ -240,6 +240,13 @@ bool isParallelDirection(const sead::Vector2f& a, const sead::Vector2f& b, f32 t
|
|||
return !(sead::Mathf::abs(a.cross(b)) > tolerance);
|
||||
}
|
||||
|
||||
bool isReverseDirection(const sead::Vector3f& a, const sead::Vector3f& b, f32 tolerance) {
|
||||
if (a.dot(b) >= 0.0f)
|
||||
return false;
|
||||
|
||||
return isParallelDirection(a, b, tolerance);
|
||||
}
|
||||
|
||||
bool isNearDirection(const sead::Vector2f& a, const sead::Vector2f& b, f32 tolerance) {
|
||||
if (a.dot(b) < 0.0f)
|
||||
return false;
|
||||
|
|
@ -247,6 +254,13 @@ bool isNearDirection(const sead::Vector2f& a, const sead::Vector2f& b, f32 toler
|
|||
return isParallelDirection(a, b, tolerance);
|
||||
}
|
||||
|
||||
bool isNearDirection(const sead::Vector3f& a, const sead::Vector3f& b, f32 tolerance) {
|
||||
if (a.dot(b) < 0.0f)
|
||||
return false;
|
||||
|
||||
return isParallelDirection(a, b, tolerance);
|
||||
}
|
||||
|
||||
bool isInRange(s32 x, s32 a, s32 b) {
|
||||
return (b < a) ? (a >= x && x >= b) : (b >= x && x >= a);
|
||||
}
|
||||
|
|
@ -474,8 +488,8 @@ f32 powerOut(f32 t, f32 exp) {
|
|||
|
||||
f32 logarithmIn(f32 t, f32 base) {
|
||||
f32 base1 = base + sead::Mathf::epsilon();
|
||||
f32 a = powf(base1 + 0.0f, 1.0 - t);
|
||||
f32 b = powf(base1 + 1.0f, t);
|
||||
f32 a = powerIn(base1 + 0.0f, 1.0 - t);
|
||||
f32 b = powerIn(base1 + 1.0f, t);
|
||||
return a * b - base1;
|
||||
}
|
||||
|
||||
|
|
@ -560,23 +574,23 @@ f32 lerpValue(f32 a, f32 b, f32 t, f32 clampA, f32 clampB) {
|
|||
}
|
||||
|
||||
f32 lerpDegree(f32 a, f32 b, f32 t) {
|
||||
a = modf(a + 360.0f, 360.0f) + 0.0f;
|
||||
b = modf(b + 360.0f, 360.0f) + 0.0f;
|
||||
a = wrapAngle(a);
|
||||
b = wrapAngle(b);
|
||||
|
||||
f32 aa = b - a > 180.0f ? a + 360.0f : a;
|
||||
f32 bb = b - a < -180.0f ? b + 360.0f : b;
|
||||
|
||||
return modf(lerpValue(aa, bb, t) + 360.0f, 360.0f) + 0.0f;
|
||||
return wrapAngle(lerpValue(aa, bb, t));
|
||||
}
|
||||
|
||||
f32 lerpRadian(f32 a, f32 b, f32 t) {
|
||||
a = modf(a + sead::Mathf::pi2(), sead::Mathf::pi2()) + 0.0f;
|
||||
b = modf(b + sead::Mathf::pi2(), sead::Mathf::pi2()) + 0.0f;
|
||||
a = wrapValue(a, sead::Mathf::pi2());
|
||||
b = wrapValue(b, sead::Mathf::pi2());
|
||||
|
||||
f32 aa = b - a > sead::Mathf::pi() ? a + sead::Mathf::pi2() : a;
|
||||
f32 bb = b - a < -sead::Mathf::pi() ? b + sead::Mathf::pi2() : b;
|
||||
|
||||
return modf(lerpValue(aa, bb, t) + sead::Mathf::pi2(), sead::Mathf::pi2()) + 0.0f;
|
||||
return wrapValue(lerpValue(aa, bb, t), sead::Mathf::pi2());
|
||||
}
|
||||
|
||||
void lerpVec(sead::Vector2f* outVec, const sead::Vector2f& a, const sead::Vector2f& b, f32 t) {
|
||||
|
|
@ -754,7 +768,7 @@ f32 convergeDegree(f32 current, f32 target, f32 step) {
|
|||
else if (current - (target - 360.0f) < 180.0f)
|
||||
target -= 360.0f;
|
||||
|
||||
return fmod(converge(current, target, step) + 360.0f, 360.0f) + 0.0f;
|
||||
return wrapAngle(converge(current, target, step));
|
||||
}
|
||||
|
||||
f32 convergeRadian(f32 current, f32 target, f32 step) {
|
||||
|
|
@ -764,7 +778,7 @@ f32 convergeRadian(f32 current, f32 target, f32 step) {
|
|||
else if (current - (target - sead::Mathf::pi2()) < sead::Mathf::pi())
|
||||
target -= sead::Mathf::pi2();
|
||||
|
||||
return fmod(converge(current, target, step) + sead::Mathf::pi2(), sead::Mathf::pi2()) + 0.0f;
|
||||
return wrapValue(converge(current, target, step), sead::Mathf::pi2());
|
||||
}
|
||||
|
||||
bool convergeVec(sead::Vector2f* outVec, const sead::Vector2f& current,
|
||||
|
|
@ -798,12 +812,18 @@ bool convergeVec(sead::Vector3f* outVec, const sead::Vector3f& current,
|
|||
}
|
||||
|
||||
f32 diffNearAngleDegree(f32 a, f32 b) {
|
||||
f32 angle = modf(b - a + 360.0f, 360.0f) + 0.0f;
|
||||
f32 angle = wrapAngle(b - a);
|
||||
if (angle >= 180.0f)
|
||||
angle -= 360.0f;
|
||||
return angle;
|
||||
}
|
||||
|
||||
bool isInRangeAngleDegree(f32 target, f32 start, f32 end) {
|
||||
f32 length = wrapAngle(end - start);
|
||||
f32 targetPos = wrapAngle(target - start);
|
||||
return 0.0f <= targetPos && targetPos <= length;
|
||||
}
|
||||
|
||||
bool isSameSign(f32 a, f32 b) {
|
||||
return a * b > 0.0f;
|
||||
}
|
||||
|
|
@ -1030,6 +1050,37 @@ f32 calcFriction(f32 accel, f32 speed) {
|
|||
return (accel + speed) / speed;
|
||||
}
|
||||
|
||||
void parallelizeVec(sead::Vector3f* outVec, const sead::Vector3f& dir, const sead::Vector3f& vec) {
|
||||
outVec->setScale(dir, dir.dot(vec));
|
||||
}
|
||||
|
||||
void separateVectorParallelVertical(sead::Vector3f* outH, sead::Vector3f* outV,
|
||||
const sead::Vector3f& dir, const sead::Vector3f& vec) {
|
||||
parallelizeVec(outH, dir, vec);
|
||||
outV->setSub(vec, *outH);
|
||||
}
|
||||
|
||||
// computes how many `vec`s are required to go from `origin` to plane
|
||||
f32 calcDistanceVecToPlane(const sead::Vector3f& vec, const sead::Vector3f& planePoint,
|
||||
const sead::Vector3f& planeNormal, const sead::Vector3f& origin) {
|
||||
f32 originToPlane = planeNormal.dot(planePoint - origin);
|
||||
f32 dirProjNormal = -vec.dot(planeNormal);
|
||||
f32 vecLength = vec.length();
|
||||
|
||||
return originToPlane / dirProjNormal * vecLength;
|
||||
}
|
||||
|
||||
void limitPlanePos(sead::Vector3f* outPos, const sead::Vector3f& pos,
|
||||
const sead::Vector3f& planeNormal, const sead::Vector3f& planePoint) {
|
||||
*outPos -= planeNormal * planeNormal.dot(pos - planePoint);
|
||||
}
|
||||
|
||||
// TODO: proper parameter names
|
||||
bool limitCylinderInDir(sead::Vector3f* outVec, const sead::Vector3f& vecA,
|
||||
const sead::Vector3f& vecB, const sead::Vector3f& vecC) {
|
||||
return limitCylinderInDir(outVec, *outVec, vecA, vecB, vecC);
|
||||
}
|
||||
|
||||
void roundOffVec(sead::Vector3f* outVec, const sead::Vector3f& vec) {
|
||||
outVec->x = sead::Mathf::round(vec.x);
|
||||
outVec->y = sead::Mathf::round(vec.y);
|
||||
|
|
@ -1204,6 +1255,23 @@ s32 getMinAbsElementValue(const sead::Vector3i& vec) {
|
|||
return vec.z;
|
||||
}
|
||||
|
||||
Axis calcNearVecFromAxis3(sead::Vector3f* outVec, const sead::Vector3f& vec,
|
||||
const sead::Quatf& quat) {
|
||||
sead::Vector3f side, up, front;
|
||||
calcQuatLocalAxisAll(quat, &side, &up, &front);
|
||||
return calcNearVecFromAxis3(outVec, vec, side, up, front);
|
||||
}
|
||||
|
||||
void calcQuatLocalAxisAll(const sead::Quatf& quat, sead::Vector3f* outSide, sead::Vector3f* outUp,
|
||||
sead::Vector3f* outFront) {
|
||||
sead::Matrix33f mtx;
|
||||
mtx.fromQuat(quat);
|
||||
|
||||
outSide->set(mtx.getBase(0));
|
||||
outUp->set(mtx.getBase(1));
|
||||
outFront->set(mtx.getBase(2));
|
||||
}
|
||||
|
||||
void makeQuatFromTwoAxis(sead::Quatf* outQuat, const sead::Vector3f& vectorA,
|
||||
const sead::Vector3f& vectorB, s32 axisA, s32 axisB) {
|
||||
sead::Matrix34f mtx = sead::Matrix34f::ident;
|
||||
|
|
@ -1276,8 +1344,7 @@ void makeQuatFromToQuat(sead::Quatf* outQuat, const sead::Quatf& quatA, const se
|
|||
|
||||
bool getAxisAngleFromTwoVec(sead::Vector3f* outAxis, f32* outRadians, const sead::Vector3f& vecA,
|
||||
const sead::Vector3f& vecB) {
|
||||
// isNearDirection(vecA, vecB, 0.01f)
|
||||
if (!(vecA.dot(vecB) >= 0.0f) && isParallelDirection(vecA, vecB, 0.01f)) {
|
||||
if (isReverseDirection(vecA, vecB, 0.01f)) {
|
||||
sead::Vector3f dir;
|
||||
calcDirVerticalAny(&dir, vecA);
|
||||
*outRadians = sead::Mathf::pi();
|
||||
|
|
@ -1407,7 +1474,7 @@ void calcQuatRotateAxisAndDegree(sead::Vector3f* outAxis, f32* outDegree, const
|
|||
*outAxis *= 1.0f / len;
|
||||
|
||||
f32 radian = sead::Mathf::atan2(len, quatW);
|
||||
f32 degree = modf(sead::Mathf::rad2deg(2.0f * radian) + 360.0f, 360.0f) + 0.0f;
|
||||
f32 degree = wrapAngle(sead::Mathf::rad2deg(2.0f * radian));
|
||||
|
||||
if (degree >= 180.0f)
|
||||
degree -= 360.0f;
|
||||
|
|
@ -1574,6 +1641,42 @@ bool turnQuatZDirRadian(sead::Quatf* outQuat, const sead::Quatf& quat, const sea
|
|||
return turnQuat(outQuat, quat, axis, dir, radian);
|
||||
}
|
||||
|
||||
// NON_MATCHING: Out of order multiplication https://decomp.me/scratch/kvdl1
|
||||
void tiltQuatDegree(sead::Quatf* outQuat, const sead::Quatf& quat, const sead::Vector3f& axis,
|
||||
const sead::Vector3f& dir, f32 degree) {
|
||||
sead::Vector3f parallelVec;
|
||||
parallelVec.setSub(dir, axis.dot(dir) * axis);
|
||||
if (!tryNormalizeOrZero(¶llelVec)) {
|
||||
outQuat->set(quat);
|
||||
return;
|
||||
}
|
||||
|
||||
sead::Vector3f rotationAxis = axis.cross(dir);
|
||||
tryNormalizeOrZero(&rotationAxis);
|
||||
rotateQuatRadian(outQuat, quat, rotationAxis, sead::Mathf::deg2rad(degree));
|
||||
}
|
||||
|
||||
void tiltQuatXDirDegree(sead::Quatf* outQuat, const sead::Quatf& quat, const sead::Vector3f& dir,
|
||||
f32 degree) {
|
||||
sead::Vector3f quatSide;
|
||||
calcQuatSide(&quatSide, quat);
|
||||
tiltQuatDegree(outQuat, quat, quatSide, dir, degree);
|
||||
}
|
||||
|
||||
void tiltQuatYDirDegree(sead::Quatf* outQuat, const sead::Quatf& quat, const sead::Vector3f& dir,
|
||||
f32 degree) {
|
||||
sead::Vector3f quatUp;
|
||||
calcQuatUp(&quatUp, quat);
|
||||
tiltQuatDegree(outQuat, quat, quatUp, dir, degree);
|
||||
}
|
||||
|
||||
void tiltQuatZDirDegree(sead::Quatf* outQuat, const sead::Quatf& quat, const sead::Vector3f& dir,
|
||||
f32 degree) {
|
||||
sead::Vector3f quatFront;
|
||||
calcQuatFront(&quatFront, quat);
|
||||
tiltQuatDegree(outQuat, quat, quatFront, dir, degree);
|
||||
}
|
||||
|
||||
bool turnQuatXDirWithYDirDegree(sead::Quatf* outQuat, const sead::Quatf& quat,
|
||||
const sead::Vector3f& axis, f32 degree) {
|
||||
sead::Vector3f side;
|
||||
|
|
@ -1634,6 +1737,61 @@ bool turnQuatZDirWithYDirDegree(sead::Quatf* outQuat, const sead::Quatf& quat,
|
|||
return turnQuatWithAxisDegree(outQuat, quat, front, axis, up, degree);
|
||||
}
|
||||
|
||||
f32 calcAreaTriangle(const sead::Vector3f& pointA, const sead::Vector3f& pointB,
|
||||
const sead::Vector3f& pointC) {
|
||||
return (pointB - pointA).cross(pointC - pointA).length() * 0.5f;
|
||||
}
|
||||
|
||||
// TODO: rename parameters
|
||||
bool turnVecToVecCosOnPlane(sead::Vector3f* outVec, const sead::Vector3f& vecA,
|
||||
const sead::Vector3f& vecB, f32 value) {
|
||||
return turnVecToVecCosOnPlane(outVec, *outVec, vecA, vecB, value);
|
||||
}
|
||||
|
||||
bool checkHitHalfLineSphere(const sead::Vector3f& center, const sead::Vector3f& rayStart,
|
||||
const sead::Vector3f& rayDir, f32 radius) {
|
||||
sead::Vector3f diff = center - rayStart;
|
||||
f32 dot = diff.dot(rayDir);
|
||||
|
||||
if (dot < 0.0f) {
|
||||
// NOTE: Some sort of is isNearDirection but reversed
|
||||
// BUG: returns `true` if the sphere is too far "behind" the ray
|
||||
return !(radius < -dot || radius * radius < (rayStart - center).squaredLength());
|
||||
}
|
||||
|
||||
return isNearZero(rayDir * dot - diff, radius);
|
||||
}
|
||||
|
||||
void updateBoundingBox(sead::Vector3f value, sead::Vector3f* min, sead::Vector3f* max) {
|
||||
if (value.x < min->x)
|
||||
min->x = value.x;
|
||||
else if (max->x < value.x)
|
||||
max->x = value.x;
|
||||
|
||||
if (value.y < min->y)
|
||||
min->y = value.y;
|
||||
else if (max->y < value.y)
|
||||
max->y = value.y;
|
||||
|
||||
if (value.z < min->z)
|
||||
min->z = value.z;
|
||||
else if (max->z < value.z)
|
||||
max->z = value.z;
|
||||
}
|
||||
|
||||
bool isNearCollideSphereAabb(const sead::Vector3f& center, f32 radius,
|
||||
const sead::BoundBox3f& boundBox) {
|
||||
const sead::Vector3f& min = boundBox.getMin();
|
||||
const sead::Vector3f& max = boundBox.getMax();
|
||||
if (center.x < min.x - radius || max.x + radius < center.x)
|
||||
return false;
|
||||
if (center.y < min.y - radius || max.y + radius < center.y)
|
||||
return false;
|
||||
if (center.z < min.z - radius || max.z + radius < center.z)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void calcBoxFacePoint(sead::Vector3f facePoints[4], const sead::BoundBox3f& boundBox, s32 axis) {
|
||||
const sead::Vector3f& min = boundBox.getMin();
|
||||
const sead::Vector3f& max = boundBox.getMax();
|
||||
|
|
@ -1725,6 +1883,29 @@ void pickUniformPointOnSphere(sead::Vector3f* outPoint) {
|
|||
calcSpherePointPicking(outPoint, getRandom(), getRandom());
|
||||
}
|
||||
|
||||
// TODO: rename parameters
|
||||
f32 calcDistanceToObb(const sead::Vector3f& vecA, const sead::Matrix34f& mtx,
|
||||
const sead::Vector3f& vecB, const sead::BoundBox3f& boundBox) {
|
||||
return sead::Mathf::sqrt(calcSquaredDistanceToObb(vecA, mtx, vecB, boundBox));
|
||||
}
|
||||
|
||||
bool calcReflectionVector(sead::Vector3f* vec, const sead::Vector3f& normal, f32 reboundRate,
|
||||
f32 minSink) {
|
||||
f32 dot = normal.dot(*vec);
|
||||
if (dot < -minSink) {
|
||||
calcReverseVector(vec, normal, reboundRate);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (dot < 0.0f)
|
||||
*vec -= dot * normal;
|
||||
return false;
|
||||
}
|
||||
|
||||
void calcReverseVector(sead::Vector3f* outVec, const sead::Vector3f& normal, f32 reboundRate) {
|
||||
*outVec -= normal.dot(*outVec) * normal * (reboundRate + 1.0f);
|
||||
}
|
||||
|
||||
void calcParabolicFunctionParam(f32* gravity, f32* initialVelY, f32 maxHeight,
|
||||
f32 verticalDistance) {
|
||||
f32 maxHeightSign = sign(maxHeight);
|
||||
|
|
@ -1735,6 +1916,20 @@ void calcParabolicFunctionParam(f32* gravity, f32* initialVelY, f32 maxHeight,
|
|||
*gravity = verticalDistance - *initialVelY;
|
||||
}
|
||||
|
||||
void calcBezierPoint(sead::Vector3f* outPoint, const sead::Vector3f& start,
|
||||
const sead::Vector3f& handleStart, const sead::Vector3f& handleEnd,
|
||||
const sead::Vector3f& end, f32 t) {
|
||||
f32 a = 1.0f - t;
|
||||
f32 a2 = a * a;
|
||||
f32 a3 = a * a * a;
|
||||
|
||||
f32 t2 = t * t;
|
||||
f32 t3 = t * t * t;
|
||||
|
||||
// This is (a + t)^3 = a3 + 3a2b + 3ab2 + b3
|
||||
*outPoint = a3 * start + (3.0f * a2 * t) * handleStart + (3.0f * a * t2) * handleEnd + t3 * end;
|
||||
}
|
||||
|
||||
f32 calcSpringDumperForce(f32 a, f32 b, f32 c, f32 d) {
|
||||
return -(a * c + b * d);
|
||||
}
|
||||
|
|
@ -1743,6 +1938,30 @@ f32 convertSpringEnergyToSpeed(f32 a, f32 b, f32 c) {
|
|||
return sead::Mathf::sqrt(a * c * a + b * b);
|
||||
}
|
||||
|
||||
static u32 sPrimeNumbers[64] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41,
|
||||
43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101,
|
||||
103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167,
|
||||
173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239,
|
||||
241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311};
|
||||
|
||||
f32 getHaltonSequence(u32 primeIndex, u32 index) {
|
||||
u32 base = sPrimeNumbers[primeIndex];
|
||||
f32 invBase = 1.0f / (f32)base;
|
||||
|
||||
f32 result = 0.0f;
|
||||
f32 f = invBase;
|
||||
do {
|
||||
u32 digit = index % base;
|
||||
u32 fraction = index - digit;
|
||||
|
||||
result += f * digit;
|
||||
index = fraction * invBase;
|
||||
f *= invBase;
|
||||
} while (index != 0);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
f32 calcFractal(f32 x, f32 y, u32 permutations, f32 amplitude, f32 scale, f32 nextOrderAmplitude,
|
||||
bool useSmoothPerlingNoise) {
|
||||
FractalGenerator generator(permutations, amplitude, scale, nextOrderAmplitude);
|
||||
|
|
@ -1755,6 +1974,11 @@ f32 calcMultiFractal(f32 x, f32 y, f32 baseAmplitude, u32 permutations, f32 ampl
|
|||
return generator.calcMultiFractal(x, y, baseAmplitude, useSmoothPerlingNoise);
|
||||
}
|
||||
|
||||
f32 calcNormalDistribution(f32 x, f32 mu, f32 sigma) {
|
||||
return (1.0f / sead::Mathf::sqrt(sigma * sead::Mathf::pi2())) *
|
||||
sead::Mathf::exp(sead::Mathf::pow(x - mu, 2) * -0.5f / sigma);
|
||||
}
|
||||
|
||||
const char* axisIndexToString(s32 axisIndex) {
|
||||
switch (axisIndex) {
|
||||
case 0:
|
||||
|
|
@ -1768,6 +1992,26 @@ const char* axisIndexToString(s32 axisIndex) {
|
|||
}
|
||||
}
|
||||
|
||||
bool calcCrossLinePoint(sead::Vector2f* crossPoint, const sead::Vector2f& pointA,
|
||||
const sead::Vector2f& dirA, const sead::Vector2f& pointB,
|
||||
const sead::Vector2f& dirB) {
|
||||
f32 det = dirB.y * dirA.x - dirA.y * dirB.x;
|
||||
if (isNearZero(det))
|
||||
return false;
|
||||
|
||||
f32 distance = (dirA.x * (pointA.y - pointB.y) + dirA.y * (pointB.x - pointA.x)) / det;
|
||||
|
||||
crossPoint->x = dirB.x * distance + pointB.x;
|
||||
crossPoint->y = dirB.y * distance + pointB.y;
|
||||
return true;
|
||||
}
|
||||
|
||||
f32 calcCylinderRadiusDot(const sead::Vector3f& vecA, const sead::Vector3f& vecB, f32 radius) {
|
||||
f32 cos = sead::Mathf::clamp(sead::Mathf::abs(vecB.dot(vecA)), -1.0f, 1.0f);
|
||||
|
||||
return sead::Mathf::sin(sead::Mathf::acos(cos)) * radius;
|
||||
}
|
||||
|
||||
} // namespace al
|
||||
|
||||
namespace Intersect {
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ bool convergeVec(sead::Vector2f* outVec, const sead::Vector2f& current,
|
|||
bool convergeVec(sead::Vector3f* outVec, const sead::Vector3f& current,
|
||||
const sead::Vector3f& target, f32 step);
|
||||
f32 diffNearAngleDegree(f32 a, f32 b);
|
||||
bool isInRangeAngleDegree(f32, f32, f32);
|
||||
bool isInRangeAngleDegree(f32 target, f32 start, f32 end);
|
||||
bool calcEyesAnimAngleInRange(f32*, const sead::Vector3f&, const sead::Vector3f&,
|
||||
const sead::Vector3f&, const sead::Vector3f&, f32, f32, f32, f32);
|
||||
bool isSameSign(f32 a, f32 b);
|
||||
|
|
@ -204,31 +204,41 @@ f32 calcBoxMullerRandomGauss();
|
|||
void makeBoxMullerRandomGauss(sead::Vector2f* outBox, f32 randA, f32 randB);
|
||||
f32 modf(f32 a, f32 b);
|
||||
s32 modi(s32 a, s32 b);
|
||||
|
||||
inline f32 wrapValue(f32 value, f32 maxRange) {
|
||||
return modf(value + maxRange, maxRange) + 0.0f;
|
||||
}
|
||||
|
||||
inline f32 wrapAngle(f32 value) {
|
||||
return wrapValue(value, 360.0);
|
||||
}
|
||||
|
||||
f32 calcSpeedMax(f32 accel, f32 friction);
|
||||
f32 calcAccel(f32 speed, f32 friction);
|
||||
f32 calcFriction(f32 accel, f32 speed);
|
||||
bool separateScalarAndDirection(f32*, sead::Vector2f*, const sead::Vector2f&);
|
||||
bool separateScalarAndDirection(f32*, sead::Vector3f*, const sead::Vector3f&);
|
||||
void limitVectorSeparateHV(sead::Vector3f*, const sead::Vector3f&, f32, f32);
|
||||
void parallelizeVec(sead::Vector3f*, const sead::Vector3f&, const sead::Vector3f&);
|
||||
void parallelizeVec(sead::Vector3f* outVec, const sead::Vector3f& dir, const sead::Vector3f& vec);
|
||||
void calcVectorSeparateHV(sead::Vector3f*, const sead::Vector3f&, const sead::Vector3f&, f32, f32);
|
||||
void limitVectorParallelVertical(sead::Vector3f*, const sead::Vector3f&, f32, f32);
|
||||
void separateVectorParallelVertical(sead::Vector3f*, sead::Vector3f*, const sead::Vector3f&,
|
||||
const sead::Vector3f&);
|
||||
void separateVectorParallelVertical(sead::Vector3f* outH, sead::Vector3f* outV,
|
||||
const sead::Vector3f& dir, const sead::Vector3f& vec);
|
||||
bool addVectorLimit(sead::Vector3f*, const sead::Vector3f&, f32);
|
||||
void alongVectorNormalH(sead::Vector3f*, const sead::Vector3f&, const sead::Vector3f&,
|
||||
const sead::Vector3f&);
|
||||
f32 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&);
|
||||
f32 calcDistanceVecToPlane(const sead::Vector3f& vec, const sead::Vector3f& planePoint,
|
||||
const sead::Vector3f& planeNormal, const sead::Vector3f& origin);
|
||||
void limitPlanePos(sead::Vector3f* outPos, const sead::Vector3f& pos,
|
||||
const sead::Vector3f& planeNormal, const sead::Vector3f& planePoint);
|
||||
bool limitCylinderInPos(sead::Vector3f*, const sead::Vector3f&, const sead::Vector3f&,
|
||||
const sead::Vector3f&, f32);
|
||||
bool limitCylinderInDir(sead::Vector3f*, const sead::Vector3f&, const sead::Vector3f&,
|
||||
const sead::Vector3f&, const sead::Vector3f&);
|
||||
bool limitCylinderInDir(sead::Vector3f* outVec, const sead::Vector3f& vecA,
|
||||
const sead::Vector3f& vecB, const sead::Vector3f& vecC,
|
||||
const sead::Vector3f& vecD);
|
||||
bool limitCylinderInPos(sead::Vector3f*, const sead::Vector3f&, const sead::Vector3f&, f32);
|
||||
bool limitCylinderInDir(sead::Vector3f*, const sead::Vector3f&, const sead::Vector3f&,
|
||||
const sead::Vector3f&);
|
||||
bool limitCylinderInDir(sead::Vector3f* outVec, const sead::Vector3f& vecA,
|
||||
const sead::Vector3f& vecB, const sead::Vector3f& vecC);
|
||||
void roundOffVec(sead::Vector3f* outVec, const sead::Vector3f& vec);
|
||||
void roundOffVec(sead::Vector3f* vec);
|
||||
void roundOffVec(sead::Vector2f* outVec, const sead::Vector2f& vec);
|
||||
|
|
@ -267,8 +277,10 @@ Axis calcNearVecFromAxis3(sead::Vector3f*, const sead::Vector3f&, const sead::Ve
|
|||
const sead::Vector3f&, const sead::Vector3f&);
|
||||
void calcDirVerticalAny(sead::Vector3f*, const sead::Vector3f&);
|
||||
void calcDirSlide(sead::Vector3f*, const sead::Vector3f&, const sead::Vector3f&);
|
||||
Axis calcNearVecFromAxis3(sead::Vector3f*, const sead::Vector3f&, const sead::Quatf&);
|
||||
void calcQuatLocalAxisAll(const sead::Quatf&, sead::Vector3f*, sead::Vector3f*, sead::Vector3f*);
|
||||
Axis calcNearVecFromAxis3(sead::Vector3f* outVec, const sead::Vector3f& vec,
|
||||
const sead::Quatf& quat);
|
||||
void calcQuatLocalAxisAll(const sead::Quatf& quat, sead::Vector3f* outSide, sead::Vector3f* outUp,
|
||||
sead::Vector3f* outFront);
|
||||
void addRandomVector(sead::Vector3f*, const sead::Vector3f&, f32);
|
||||
void turnRandomVector(sead::Vector3f*, const sead::Vector3f&, f32);
|
||||
void makeAxisFrontUp(sead::Vector3f*, sead::Vector3f*, const sead::Vector3f&,
|
||||
|
|
@ -339,11 +351,14 @@ bool turnQuatZDirRadian(sead::Quatf* outQuat, const sead::Quatf& quat, const sea
|
|||
void turnQuatXDirRate(sead::Quatf*, const sead::Quatf&, const sead::Vector3f&, f32);
|
||||
void turnQuatYDirRate(sead::Quatf*, const sead::Quatf&, const sead::Vector3f&, f32);
|
||||
void turnQuatZDirRate(sead::Quatf*, const sead::Quatf&, const sead::Vector3f&, f32);
|
||||
void tiltQuatDegree(sead::Quatf*, const sead::Quatf&, const sead::Vector3f&, const sead::Vector3f&,
|
||||
f32);
|
||||
void tiltQuatXDirDegree(sead::Quatf*, const sead::Quatf&, const sead::Vector3f&, f32);
|
||||
void tiltQuatYDirDegree(sead::Quatf*, const sead::Quatf&, const sead::Vector3f&, f32);
|
||||
void tiltQuatZDirDegree(sead::Quatf*, const sead::Quatf&, const sead::Vector3f&, f32);
|
||||
void tiltQuatDegree(sead::Quatf* outQuat, const sead::Quatf& quat, const sead::Vector3f& axis,
|
||||
const sead::Vector3f& dir, f32 degree);
|
||||
void tiltQuatXDirDegree(sead::Quatf* outQuat, const sead::Quatf& quat, const sead::Vector3f& dir,
|
||||
f32 degree);
|
||||
void tiltQuatYDirDegree(sead::Quatf* outQuat, const sead::Quatf& quat, const sead::Vector3f& dir,
|
||||
f32 degree);
|
||||
void tiltQuatZDirDegree(sead::Quatf* outQuat, const sead::Quatf& quat, const sead::Vector3f& dir,
|
||||
f32 degree);
|
||||
bool turnQuatWithAxisDegree(sead::Quatf*, const sead::Quatf&, const sead::Vector3f&,
|
||||
const sead::Vector3f&, const sead::Vector3f&, f32);
|
||||
bool turnQuatXDirWithYDirDegree(sead::Quatf* outQuat, const sead::Quatf& quat,
|
||||
|
|
@ -381,22 +396,25 @@ bool turnVecToVecCos(sead::Vector3f*, const sead::Vector3f&, const sead::Vector3
|
|||
const sead::Vector3f&, f32);
|
||||
bool turnVecToVecCosOnPlane(sead::Vector3f*, const sead::Vector3f&, const sead::Vector3f&,
|
||||
const sead::Vector3f&, f32);
|
||||
bool turnVecToVecCosOnPlane(sead::Vector3f*, const sead::Vector3f&, const sead::Vector3f&, f32);
|
||||
bool turnVecToVecCosOnPlane(sead::Vector3f* outVec, const sead::Vector3f& vecA,
|
||||
const sead::Vector3f& vecB, f32 value);
|
||||
void rotateVectorCenterDegree(sead::Vector3f*, const sead::Vector3f&, const sead::Vector3f&,
|
||||
const sead::Vector3f&, f32);
|
||||
void rotateVectorDegreeX(sead::Vector3f*, f32);
|
||||
void rotateVectorDegreeY(sead::Vector3f*, f32);
|
||||
void rotateVectorDegreeZ(sead::Vector3f*, f32);
|
||||
void rotateVectorQuat(sead::Vector3f*, const sead::Quatf&);
|
||||
f32 calcAreaTriangle(const sead::Vector3f&, const sead::Vector3f&, const sead::Vector3f&);
|
||||
f32 calcAreaTriangle(const sead::Vector3f& pointA, const sead::Vector3f& pointB,
|
||||
const sead::Vector3f& pointC);
|
||||
void createBoundingBox(const sead::Vector3f*, u32, sead::Vector3f*, sead::Vector3f*);
|
||||
void updateBoundingBox(sead::Vector3f, sead::Vector3f*, sead::Vector3f*);
|
||||
void updateBoundingBox(sead::Vector3f value, sead::Vector3f* min, sead::Vector3f* max);
|
||||
f32 calcDistanceToFarthestBoundingBoxVertex(const sead::Vector3f&, const sead::Vector3f&,
|
||||
const sead::Vector3f&);
|
||||
void calcSphereMargeSpheres(sead::Vector3f*, f32*, const sead::Vector3f&, f32,
|
||||
const sead::Vector3f&, f32);
|
||||
bool calcCrossLinePoint(sead::Vector2f*, const sead::Vector2f&, const sead::Vector2f&,
|
||||
const sead::Vector2f&, const sead::Vector2f&);
|
||||
bool calcCrossLinePoint(sead::Vector2f* crossPoint, const sead::Vector2f& point1A,
|
||||
const sead::Vector2f& point1B, const sead::Vector2f& point2A,
|
||||
const sead::Vector2f& point2B);
|
||||
f32 calcSquaredDistanceSegmentToSegment(const sead::Vector3f&, const sead::Vector3f&,
|
||||
const sead::Vector3f&, const sead::Vector3f&,
|
||||
sead::Vector3f*, sead::Vector3f*);
|
||||
|
|
@ -407,7 +425,7 @@ void calcPerpendicFootToLineInside(sead::Vector3f*, const sead::Vector3f&, const
|
|||
const sead::Vector3f&);
|
||||
void calcClosestSegmentPoint(sead::Vector3f*, const sead::Vector3f&, const sead::Vector3f&,
|
||||
const sead::Vector3f&);
|
||||
f32 calcCylinderRadiusDot(const sead::Vector3f&, const sead::Vector3f&, f32);
|
||||
f32 calcCylinderRadiusDot(const sead::Vector3f& vecA, const sead::Vector3f& vecB, f32 radius);
|
||||
bool checkHitSemilinePlane(sead::Vector3f*, const sead::Vector3f&, const sead::Vector3f&,
|
||||
const sead::Vector3f&, const sead::Vector3f&);
|
||||
bool checkHitSegmentPlane(sead::Vector3f*, const sead::Vector3f&, const sead::Vector3f&,
|
||||
|
|
@ -422,8 +440,8 @@ bool checkInCylinder(const sead::Vector3f&, const sead::Vector3f&, f32, const se
|
|||
bool checkHitSegmentCylinder(const sead::Vector3f&, f32, const sead::Vector3f&, f32,
|
||||
const sead::Vector3f&, const sead::Vector3f&, sead::Vector3f*,
|
||||
sead::Vector3f*);
|
||||
bool checkHitHalfLineSphere(const sead::Vector3f&, const sead::Vector3f&, const sead::Vector3f&,
|
||||
f32);
|
||||
bool checkHitHalfLineSphere(const sead::Vector3f& vecA, const sead::Vector3f& vecB,
|
||||
const sead::Vector3f& vecC, f32 tolerance);
|
||||
|
||||
} // namespace al
|
||||
|
||||
|
|
@ -452,7 +470,8 @@ bool calcBoundingSphereSpotLight(sead::Vector3f*, f32*, const sead::Vector3f&,
|
|||
const sead::Vector3f&, f32, f32);
|
||||
void calcBoundingSphereBox3f(sead::Vector3f*, f32*, const sead::BoundBox3f&);
|
||||
void calcArrowAabb(sead::BoundBox3f*, const sead::Vector3f&, const sead::Vector3f&);
|
||||
bool isNearCollideSphereAabb(const sead::Vector3f&, f32, const sead::BoundBox3f&);
|
||||
bool isNearCollideSphereAabb(const sead::Vector3f& center, f32 radius,
|
||||
const sead::BoundBox3f& boundBox);
|
||||
void calcBoxFacePoint(sead::Vector3f facePoints[4], const sead::BoundBox3f& boundBox, s32 axis);
|
||||
void calcBoxFacePoint(sead::Vector3f facePoints[4], const sead::BoundBox3f& boundBox, s32 axis,
|
||||
const sead::Matrix34f&);
|
||||
|
|
@ -467,8 +486,8 @@ f32 calcSquaredDistanceToObb(const sead::Vector3f&, const sead::Matrix34f&, cons
|
|||
f32 calcDistanceToObb(const sead::Vector3f&, const sead::Matrix34f&, const sead::Vector3f&);
|
||||
f32 calcSquaredDistanceToObb(const sead::Vector3f&, const sead::Matrix34f&, const sead::Vector3f&,
|
||||
const sead::BoundBox3f&);
|
||||
f32 calcDistanceToObb(const sead::Vector3f&, const sead::Matrix34f&, const sead::Vector3f&,
|
||||
const sead::BoundBox3f&);
|
||||
f32 calcDistanceToObb(const sead::Vector3f& vecA, const sead::Matrix34f& mtx,
|
||||
const sead::Vector3f& vecB, const sead::BoundBox3f& boundBox);
|
||||
f32 calcSquaredDistanceToObb(const sead::Vector3f&, const sead::Matrix34f&);
|
||||
f32 calcDistanceToObb(const sead::Vector3f&, const sead::Matrix34f&);
|
||||
void calcObbCorners(sead::Vector3f*, const sead::Matrix34f&, const sead::BoundBox3f&);
|
||||
|
|
@ -477,15 +496,17 @@ bool calcBetweenTwoLinkMtx(sead::Matrix34f*, sead::Matrix34f*, sead::Matrix34f*,
|
|||
const sead::Vector3f&, const sead::Vector3f&, f32, f32);
|
||||
bool calcBetweenTwoLinkPos(sead::Vector3f*, const sead::Vector3f&, const sead::Vector3f&, f32, f32,
|
||||
const sead::Vector3f&);
|
||||
bool calcReflectionVector(sead::Vector3f*, const sead::Vector3f&, f32, f32);
|
||||
void calcReverseVector(sead::Vector3f*, const sead::Vector3f&, f32);
|
||||
bool calcReflectionVector(sead::Vector3f* vec, const sead::Vector3f& normal, f32 reboundRate,
|
||||
f32 minSink);
|
||||
void calcReverseVector(sead::Vector3f* outVec, const sead::Vector3f& normal, f32 reboundRate);
|
||||
void calcParabolicFunctionParam(f32* gravity, f32* initialVelY, f32 maxHeight,
|
||||
f32 verticalDistance);
|
||||
f32 calcConvergeVibrationValue(f32, f32, f32, f32, f32);
|
||||
bool calcSphericalPolarCoordPY(sead::Vector2f*, const sead::Vector3f&, const sead::Vector3f&,
|
||||
const sead::Vector3f&);
|
||||
void calcBezierPoint(sead::Vector3f*, const sead::Vector3f&, const sead::Vector3f&,
|
||||
const sead::Vector3f&, const sead::Vector3f&, f32);
|
||||
void calcBezierPoint(sead::Vector3f* outPoint, const sead::Vector3f& start,
|
||||
const sead::Vector3f& handleStart, const sead::Vector3f& handleEnd,
|
||||
const sead::Vector3f& end, f32 t);
|
||||
// TODO: Find spring parameter names
|
||||
f32 calcSpringDumperForce(f32 a, f32 b, f32 c, f32 d);
|
||||
f32 convertSpringEnergyToSpeed(f32 a, f32 b, f32 c);
|
||||
|
|
@ -493,12 +514,12 @@ const char* axisIndexToString(s32 axisIndex);
|
|||
void visitCellsOverlapped(const sead::Vector3f&, const sead::Vector3f&, f32,
|
||||
const VisitCellCallBack&);
|
||||
f32 calcMultValueToDestination(u32, f32, f32);
|
||||
f32 getHaltonSequence(u32, u32);
|
||||
f32 getHaltonSequence(u32 primeIndex, u32 index);
|
||||
f32 calcFractal(f32 x, f32 y, u32 permutations, f32 amplitude, f32 scale, f32 nextOrderAmplitude,
|
||||
bool useSmoothPerlingNoise);
|
||||
f32 calcMultiFractal(f32 x, f32 y, f32 baseAmplitude, u32 permutations, f32 amplitude, f32 scale,
|
||||
f32 nextOrderAmplitude, bool useSmoothPerlingNoise);
|
||||
f32 calcNormalDistribution(f32, f32, f32);
|
||||
f32 calcNormalDistribution(f32 x, f32 mu, f32 sigma);
|
||||
bool calcVecViewInput(sead::Vector3f*, const sead::Vector2f&, const sead::Vector3f&,
|
||||
const sead::Matrix34f*);
|
||||
bool calcDirViewInput(sead::Vector3f*, const sead::Vector2f&, const sead::Vector3f&,
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ bool SwingMovement::updateRotate() {
|
|||
f32 rad = sead::Mathf::deg2rad(modf(degree + 90.0f + 180.0f, 180.0f) - 90.0f);
|
||||
mCurrentAngle = swingAngleSign * sead::Mathf::sin(rad) * 180.0f + mOffsetRotate;
|
||||
} else {
|
||||
mCurrentAngle = swingAngleSign * (modf(degree * 2 + 360.0f, 360.0f) + 0.0f) + mOffsetRotate;
|
||||
mCurrentAngle = swingAngleSign * wrapAngle(degree * 2) + mOffsetRotate;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ WheelMovement::WheelMovement(LiveActor* actor, const ActorInitInfo& info)
|
|||
mWheelAngle = -(railProgress * mMoveEndDegree);
|
||||
|
||||
rotateQuatLocalDirDegree(&mActorQuat, mInitialActorQuat, (s32)mRotateAxis,
|
||||
modf(mWheelAngle + 360.0f, 360.0f) + 0.0f);
|
||||
wrapAngle(mWheelAngle));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -119,11 +119,11 @@ void WheelMovement::updateRotate() {
|
|||
if (mIsInvertDirection)
|
||||
mNextDeltaAngle *= -0.2f;
|
||||
} else {
|
||||
mWheelAngle = modf(mWheelAngle + 360.0f, 360.0f) + 0.0f;
|
||||
mWheelAngle = wrapAngle(mWheelAngle);
|
||||
}
|
||||
mRotateWidth = 0.0f;
|
||||
rotateQuatLocalDirDegree(&mActorQuat, mInitialActorQuat, (s32)mRotateAxis,
|
||||
modf(mWheelAngle + 360.0f, 360.0f) + 0.0f);
|
||||
wrapAngle(mWheelAngle));
|
||||
}
|
||||
|
||||
void WheelMovement::updateActorPoseAndTrans(LiveActor* actor) {
|
||||
|
|
@ -139,7 +139,7 @@ void WheelMovement::reset() {
|
|||
mIsInvertDirection = false;
|
||||
mRailProgress = mInitialRailProgress;
|
||||
rotateQuatLocalDirDegree(&mActorQuat, mInitialActorQuat, (s32)mRotateAxis,
|
||||
modf(360.0f, 360.0f) + 0.0f);
|
||||
wrapAngle(mWheelAngle));
|
||||
}
|
||||
|
||||
void WheelMovement::reset(LiveActor* actor) {
|
||||
|
|
|
|||
|
|
@ -497,10 +497,6 @@ void calcRailDirAtCoord(sead::Vector3f* dir, const IUseRail* railHolder, f32 coo
|
|||
getRail(railHolder)->calcDirection(dir, coord);
|
||||
}
|
||||
|
||||
inline f32 modLimit(f32 value, f32 limit) {
|
||||
return modf(value + limit, limit) + 0.0f;
|
||||
}
|
||||
|
||||
// Mismatch: https://decomp.me/scratch/0vmMR
|
||||
void calcRailPosFront(sead::Vector3f* pos, const IUseRail* railHolder, f32 offset) {
|
||||
if (!isRailGoingToEnd(railHolder))
|
||||
|
|
@ -511,7 +507,7 @@ void calcRailPosFront(sead::Vector3f* pos, const IUseRail* railHolder, f32 offse
|
|||
|
||||
if (rail->isClosed()) {
|
||||
f32 totalLength = rail->getTotalLength();
|
||||
f32 distance = modLimit(coordOffset, totalLength);
|
||||
f32 distance = wrapValue(coordOffset, totalLength);
|
||||
rail->calcPos(pos, distance);
|
||||
return;
|
||||
}
|
||||
|
|
@ -531,7 +527,7 @@ void calcRailDirFront(sead::Vector3f* pos, const IUseRail* railHolder, f32 offse
|
|||
|
||||
if (rail->isClosed()) {
|
||||
f32 totalLength = rail->getTotalLength();
|
||||
f32 distance = modLimit(coordOffset, totalLength);
|
||||
f32 distance = wrapValue(coordOffset, totalLength);
|
||||
rail->calcDirection(pos, distance);
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,15 +89,11 @@ void CoinCirclePlacement::listenAppear() {
|
|||
makeActorAlive();
|
||||
}
|
||||
|
||||
inline f32 modDegree(f32 value) {
|
||||
return al::modf(value + 360.0f, 360.0f) + 0.0f;
|
||||
}
|
||||
|
||||
void CoinCirclePlacement::exeMove() {
|
||||
if (al::isNearZero(mRotateVelocity))
|
||||
return;
|
||||
|
||||
mCurrentAngle = modDegree(mCurrentAngle + mRotateVelocity);
|
||||
mCurrentAngle = al::wrapAngle(mCurrentAngle + mRotateVelocity);
|
||||
|
||||
s32 coinNum = mCoinNum;
|
||||
bool isNoCoinAlive = true;
|
||||
|
|
@ -105,7 +101,7 @@ void CoinCirclePlacement::exeMove() {
|
|||
if (al::isDead(mCoinArray[i]) || !mCoinArray[i]->isWait())
|
||||
continue;
|
||||
f32 prevY = al::getTrans(mCoinArray[i]).y;
|
||||
f32 coinAngle = sead::Mathf::deg2rad(modDegree(mCurrentAngle + (360.0f / coinNum) * i));
|
||||
f32 coinAngle = sead::Mathf::deg2rad(al::wrapAngle(mCurrentAngle + (360.0f / coinNum) * i));
|
||||
f32 xWidth = mCircleXWidth * sead::Mathf::cos(coinAngle) * 100.0f;
|
||||
f32 zWidth = mCircleZWidth * sead::Mathf::sin(coinAngle) * 100.0f;
|
||||
|
||||
|
|
|
|||
|
|
@ -8,13 +8,9 @@
|
|||
|
||||
CoinRotateCalculator::CoinRotateCalculator(al::LiveActor* actor) : mActor(actor) {}
|
||||
|
||||
inline f32 modDegree(f32 value) {
|
||||
return al::modf(value + 360.0f, 360.0f) + 0.0f;
|
||||
}
|
||||
|
||||
inline f32 getObjAngle(al::LiveActor* actor, bool isInWater, s32 objCountOffset) {
|
||||
al::StageSyncCounter* syncObj = al::getSceneObj<al::StageSyncCounter>(actor);
|
||||
f32 objCounter = modDegree(syncObj->getCounter() + objCountOffset);
|
||||
f32 objCounter = al::wrapAngle(syncObj->getCounter() + objCountOffset);
|
||||
|
||||
return (isInWater ? 2.0f : 3.0f) * objCounter;
|
||||
}
|
||||
|
|
@ -37,7 +33,7 @@ void CoinRotateCalculator::update(const sead::Vector3f& force, bool checkWater)
|
|||
|
||||
if (al::isNearZero(force)) {
|
||||
if (--mForceFrames <= 0) {
|
||||
mForceOffset = modDegree(mForceOffset) - 0.8f;
|
||||
mForceOffset = al::wrapAngle(mForceOffset) - 0.8f;
|
||||
if (mForceOffset < 0.0f)
|
||||
mForceOffset = 0.0f;
|
||||
} else {
|
||||
|
|
@ -50,7 +46,7 @@ void CoinRotateCalculator::update(const sead::Vector3f& force, bool checkWater)
|
|||
|
||||
mFishingLineOffset = sead::Mathf::clampMin(mFishingLineOffset - 0.8f, 0.0f);
|
||||
|
||||
if (sead::Mathf::abs(modDegree(objAngle) - modDegree(mLastObjAngle)) > 5.0f)
|
||||
if (sead::Mathf::abs(al::wrapAngle(objAngle) - al::wrapAngle(mLastObjAngle)) > 5.0f)
|
||||
objAngle = (mIsInWater ? 3.5f : 4.0f) + mLastObjAngle;
|
||||
|
||||
mRotate = objAngle + mForceOffset + mFishingLineOffset + mRotateOffset;
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ void Compass::appear() {
|
|||
return;
|
||||
|
||||
f32 angle = al::calcAngleOnPlaneDegree(northDir, camDir, -sead::Vector3f::ey);
|
||||
angle = al::modf(angle + 360.0f, 360.0f) + 0.0f;
|
||||
angle = al::wrapAngle(angle);
|
||||
|
||||
f32 maxFrame = al::getActionFrameMax(this, "Direction", "State");
|
||||
f32 frame = al::normalize(angle, 0.0f, maxFrame);
|
||||
|
|
|
|||
|
|
@ -12,5 +12,5 @@ void WorldMapEarth::init(const al::ActorInitInfo& info) {
|
|||
}
|
||||
|
||||
void WorldMapEarth::control() {
|
||||
al::setRotateY(this, al::modf(al::getRotate(this).y + 0.05f + 360.0f, 360.0f) + 0.0f);
|
||||
al::setRotateY(this, al::wrapAngle(al::getRotate(this).y + 0.05f));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue