Improved vehicle sync
This commit is contained in:
@ -217,7 +217,7 @@ namespace RageCoop.Client
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if (!_gameLoaded && (_gameLoaded = true))
|
||||
if (!_gameLoaded && (_gameLoaded = true))
|
||||
{
|
||||
#if !NON_INTERACTIVE
|
||||
Notification.Show(NotificationIcon.AllPlayersConf, "RAGECOOP", "Welcome!",
|
||||
|
@ -1,4 +1,7 @@
|
||||
using System.Reflection;
|
||||
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Resources;
|
||||
|
||||
// General Information
|
||||
@ -12,7 +15,8 @@ using System.Resources;
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
|
||||
// Version informationr(
|
||||
[assembly: AssemblyVersion("1.6.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.6.0.0")]
|
||||
[assembly: NeutralResourcesLanguageAttribute("en-US")]
|
||||
// Version information
|
||||
[assembly: AssemblyVersion("1.6.0.1")]
|
||||
[assembly: AssemblyFileVersion("1.6.0.1")]
|
||||
[assembly: NeutralResourcesLanguageAttribute( "en-US" )]
|
||||
|
||||
|
@ -33,7 +33,7 @@ using System.Resources;
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
|
||||
// Version informationr(
|
||||
// Version information
|
||||
[assembly: AssemblyVersion("<#= this.major #>.<#= this.minor #>.<#= this.revision #>.<#= this.build #>")]
|
||||
[assembly: AssemblyFileVersion("<#= this.major #>.<#= this.minor #>.<#= this.revision #>.<#= this.build #>")]
|
||||
[assembly: NeutralResourcesLanguageAttribute( "en-US" )]
|
||||
|
@ -59,7 +59,11 @@ namespace RageCoop.Client
|
||||
internal bool HasRoof;
|
||||
internal bool IsSubmarineCar;
|
||||
internal bool IsDeluxo;
|
||||
|
||||
internal bool IsTrain;
|
||||
internal Vector3 TopExtent;
|
||||
internal Vector3 FrontExtent;
|
||||
internal Vector3 LeftExtent;
|
||||
internal Vector3 RightExtent;
|
||||
#endregion
|
||||
|
||||
#region PRIVATE
|
||||
|
@ -11,24 +11,10 @@ namespace RageCoop.Client
|
||||
/// </summary>
|
||||
public partial class SyncedVehicle : SyncedEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// VehicleSeat,ID
|
||||
/// </summary>
|
||||
internal override void Update()
|
||||
{
|
||||
#if DEBUG_VEH
|
||||
foreach(var s in _predictedTrace)
|
||||
{
|
||||
World.DrawMarker(MarkerType.DebugSphere, s, default, default, new Vector3(0.3f, 0.3f, 0.3f), Color.AliceBlue);
|
||||
}
|
||||
foreach (var s in _orgTrace)
|
||||
{
|
||||
World.DrawMarker(MarkerType.DebugSphere, s, default, default, new Vector3(0.3f, 0.3f, 0.3f), Color.Orange);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// Check if all data avalible
|
||||
// Check if all data available
|
||||
if (!IsReady || Owner == null) return;
|
||||
|
||||
// Check existence
|
||||
@ -174,10 +160,9 @@ namespace RageCoop.Client
|
||||
{
|
||||
_predictedPosition = Predict(Position);
|
||||
var current = MainVehicle.ReadPosition();
|
||||
var dist = current.DistanceTo(_predictedPosition);
|
||||
var cali = dist * (_predictedPosition - current);
|
||||
if (Velocity.Length() < 0.1) cali *= 10;
|
||||
if (dist > 10)
|
||||
var distSquared = current.DistanceToSquared(_predictedPosition);
|
||||
var cali = _predictedPosition - current + 0.5f * (Velocity - MainVehicle.Velocity);
|
||||
if (distSquared > 10 * 10)
|
||||
{
|
||||
MainVehicle.Position = _predictedPosition;
|
||||
MainVehicle.Velocity = Velocity;
|
||||
@ -185,17 +170,15 @@ namespace RageCoop.Client
|
||||
return;
|
||||
}
|
||||
|
||||
if (dist > 0.03) MainVehicle.Velocity = Velocity + cali;
|
||||
// Calibrate rotation
|
||||
var curQuat = MainVehicle.Quaternion;
|
||||
MainVehicle.ApplyForce(Quaternion * TopExtent - curQuat * TopExtent, TopExtent);
|
||||
MainVehicle.ApplyForce(Quaternion * FrontExtent - curQuat * FrontExtent, FrontExtent);
|
||||
|
||||
Vector3 calirot;
|
||||
if (IsFlipped || (calirot = GetCalibrationRotation()).Length() > 50)
|
||||
{
|
||||
MainVehicle.Quaternion = Quaternion.Slerp(MainVehicle.ReadQuaternion(), Quaternion, 0.5f);
|
||||
MainVehicle.RotationVelocity = RotationVelocity;
|
||||
return;
|
||||
}
|
||||
|
||||
MainVehicle.RotationVelocity = RotationVelocity + calirot * 0.2f;
|
||||
// Calibrate position
|
||||
if (distSquared < 0.03 * 0.03) return;
|
||||
if (!IsTrain && distSquared > 20 * 20) MainVehicle.Velocity = Velocity + cali;
|
||||
else MainVehicle.ApplyForce(cali);
|
||||
}
|
||||
|
||||
private Vector3 GetCalibrationRotation()
|
||||
@ -273,6 +256,12 @@ namespace RageCoop.Client
|
||||
HasRoof = MainVehicle.HasRoof;
|
||||
IsSubmarineCar = MainVehicle.IsSubmarineCar;
|
||||
IsDeluxo = MainVehicle.Model == 1483171323;
|
||||
IsTrain = MainVehicle.IsTrain;
|
||||
var (rbl, ftr) = MainVehicle.Model.Dimensions;
|
||||
FrontExtent = new Vector3(0, ftr.Y, 0);
|
||||
TopExtent = new Vector3(0, 0, ftr.Z);
|
||||
LeftExtent = new Vector3(rbl.X, 0, 0);
|
||||
RightExtent = new Vector3(ftr.X, 0, 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
Reference in New Issue
Block a user