mirror of
https://github.com/Milxnor/Project-Reboot-3.0.git
synced 2026-01-13 02:42:22 +01:00
idek
remove s18+ storm effect, fix teams on all versions, fix a crash, fix 1.11 restarting
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
#include "Rotator.h"
|
||||
#include "Quat.h"
|
||||
#include "UnrealMathUtility.h"
|
||||
|
||||
#define INV_PI (0.31830988618f)
|
||||
#define HALF_PI (1.57079632679f)
|
||||
@@ -47,7 +49,6 @@ static FORCEINLINE void SinCos(float* ScalarSin, float* ScalarCos, float Value)
|
||||
|
||||
struct FQuat FRotator::Quaternion()
|
||||
{
|
||||
|
||||
#if PLATFORM_ENABLE_VECTORINTRINSICS
|
||||
const VectorRegister Angles = MakeVectorRegister(Rotator.Pitch, Rotator.Yaw, Rotator.Roll, 0.0f);
|
||||
const VectorRegister HalfAngles = VectorMultiply(Angles, DEG_TO_RAD_HALF);
|
||||
@@ -111,4 +112,43 @@ FVector FRotator::Vector() const
|
||||
FVector V = FVector(CP * CY, CP * SY, SP);
|
||||
|
||||
return V;
|
||||
}
|
||||
|
||||
FRotator FQuat::Rotator() const
|
||||
{
|
||||
const float SingularityTest = Z * X - W * Y;
|
||||
const float YawY = 2.f * (W * Z + X * Y);
|
||||
const float YawX = (1.f - 2.f * (FMath::Square(Y) + FMath::Square(Z)));
|
||||
|
||||
// reference
|
||||
// http://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles
|
||||
// http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToEuler/
|
||||
|
||||
// this value was found from experience, the above websites recommend different values
|
||||
// but that isn't the case for us, so I went through different testing, and finally found the case
|
||||
// where both of world lives happily.
|
||||
const float SINGULARITY_THRESHOLD = 0.4999995f;
|
||||
const float RAD_TO_DEG = (180.f) / PI;
|
||||
FRotator RotatorFromQuat;
|
||||
|
||||
if (SingularityTest < -SINGULARITY_THRESHOLD)
|
||||
{
|
||||
RotatorFromQuat.Pitch = -90.f;
|
||||
RotatorFromQuat.Yaw = FMath::Atan2(YawY, YawX) * RAD_TO_DEG;
|
||||
RotatorFromQuat.Roll = FRotator::NormalizeAxis(-RotatorFromQuat.Yaw - (2.f * FMath::Atan2(X, W) * RAD_TO_DEG));
|
||||
}
|
||||
else if (SingularityTest > SINGULARITY_THRESHOLD)
|
||||
{
|
||||
RotatorFromQuat.Pitch = 90.f;
|
||||
RotatorFromQuat.Yaw = FMath::Atan2(YawY, YawX) * RAD_TO_DEG;
|
||||
RotatorFromQuat.Roll = FRotator::NormalizeAxis(RotatorFromQuat.Yaw - (2.f * FMath::Atan2(X, W) * RAD_TO_DEG));
|
||||
}
|
||||
else
|
||||
{
|
||||
RotatorFromQuat.Pitch = FMath::FastAsin(2.f * (SingularityTest)) * RAD_TO_DEG;
|
||||
RotatorFromQuat.Yaw = FMath::Atan2(YawY, YawX) * RAD_TO_DEG;
|
||||
RotatorFromQuat.Roll = FMath::Atan2(-2.f * (W * X + Y * Z), (1.f - 2.f * (FMath::Square(X) + FMath::Square(Y)))) * RAD_TO_DEG;
|
||||
}
|
||||
|
||||
return RotatorFromQuat;
|
||||
}
|
||||
Reference in New Issue
Block a user