Use quaternion differentiation to calibrate rotation
Hopefully fixes the wobbling issue
This commit is contained in:
@ -669,7 +669,7 @@ namespace RageCoop.Client
|
||||
{
|
||||
_lastDriveBy = true;
|
||||
Call(TASK_DRIVE_BY, MainPed, 0, 0, AimCoords.X, AimCoords.Y, AimCoords.Z,
|
||||
1, 100, 1, FiringPattern.SingleShot);
|
||||
100000, 100, 1, FiringPattern.SingleShot);
|
||||
}
|
||||
}
|
||||
else if (_lastDriveBy || MainPed.IsTaskActive(TaskType.CTaskAimGunVehicleDriveBy))
|
||||
|
@ -49,9 +49,6 @@ namespace RageCoop.Client
|
||||
|
||||
#region FIXED-DATA
|
||||
|
||||
internal bool IsFlipped => IsMotorcycle ||
|
||||
(Quaternion * Vector3.RelativeTop).Z - (Quaternion * Vector3.RelativeBottom).Z < 0.5;
|
||||
|
||||
internal bool IsMotorcycle;
|
||||
internal bool IsAircraft;
|
||||
internal bool HasRocketBoost;
|
||||
@ -60,14 +57,7 @@ namespace RageCoop.Client
|
||||
internal bool IsSubmarineCar;
|
||||
internal bool IsDeluxo;
|
||||
internal bool IsTrain;
|
||||
internal Vector3 TopExtent;
|
||||
internal Vector3 BottomExtent;
|
||||
internal Vector3 FrontExtent;
|
||||
internal Vector3 RearExtent;
|
||||
internal Vector3 LeftExtent;
|
||||
internal Vector3 RightExtent;
|
||||
private const float RotCalMult = 0.2f;
|
||||
private const float ExtentLength = 5;
|
||||
private const float RotCalMult = 10f;
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -177,13 +177,9 @@ namespace RageCoop.Client
|
||||
else MainVehicle.ApplyWorldForceCenterOfMass(cali, ForceType.InternalImpulse, true);
|
||||
}
|
||||
|
||||
Quaternion predictedQuat = updated ? Quaternion :
|
||||
Quaternion.Lerp(LastQuaternion, Quaternion, 1 + LastSyncedStopWatch.ElapsedMilliseconds / (float)LastSyncInterval);
|
||||
var curQuat = MainVehicle.Quaternion;
|
||||
MainVehicle.ApplyForce((predictedQuat * TopExtent - curQuat * TopExtent) * RotCalMult, TopExtent, ForceType.InternalImpulse);
|
||||
MainVehicle.ApplyForce((predictedQuat * FrontExtent - curQuat * FrontExtent) * RotCalMult, FrontExtent, ForceType.InternalImpulse);
|
||||
// MainVehicle.ApplyForce((predictedQuat * BottomExtent - curQuat * BottomExtent) * RotCalMult, BottomExtent);
|
||||
|
||||
// Calibrate rotation
|
||||
var diff = MainVehicle.ReadQuaternion().Differentiate(Quaternion);
|
||||
MainVehicle.WorldRotationVelocity = diff.ToEulerAngles()*RotCalMult;
|
||||
}
|
||||
|
||||
private bool CreateVehicle()
|
||||
@ -240,13 +236,6 @@ namespace RageCoop.Client
|
||||
IsSubmarineCar = MainVehicle.IsSubmarineCar;
|
||||
IsDeluxo = MainVehicle.Model == 1483171323;
|
||||
IsTrain = MainVehicle.IsTrain;
|
||||
// var (rbl, ftr) = MainVehicle.Model.Dimensions;
|
||||
FrontExtent = new Vector3(0, ExtentLength, 0);
|
||||
RearExtent = -FrontExtent;
|
||||
TopExtent = new Vector3(0, ExtentLength, 5);
|
||||
BottomExtent = -TopExtent;
|
||||
RightExtent = new Vector3(5, ExtentLength, 0);
|
||||
LeftExtent = -RightExtent;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -128,6 +128,11 @@ namespace RageCoop.Core
|
||||
return q.ToEulerAngles().ToDegree();
|
||||
}
|
||||
|
||||
public static Quaternion Differentiate(this Quaternion p, Quaternion q)
|
||||
{
|
||||
return q * Quaternion.Invert(p);
|
||||
}
|
||||
|
||||
public static Vector3 ToEulerAngles(this Quaternion q)
|
||||
{
|
||||
var angles = new Vector3();
|
||||
|
Submodule libs/ScriptHookVDotNetCore updated: f2505ef075...1d189d681a
Reference in New Issue
Block a user