mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
perf: PredictedRigidbody syncs a blittable struct once instead of doing 5 separate reads/writes
This commit is contained in:
parent
fb1d2ee683
commit
a4f42194cf
@ -39,23 +39,12 @@ public static class PredictedSyncDataReadWrite
|
||||
{
|
||||
public static void WritePredictedSyncData(this NetworkWriter writer, PredictedSyncData data)
|
||||
{
|
||||
writer.WriteFloat(data.deltaTime);
|
||||
writer.WriteVector3(data.position);
|
||||
writer.WriteQuaternion(data.rotation);
|
||||
writer.WriteVector3(data.velocity);
|
||||
writer.WriteVector3(data.angularVelocity);
|
||||
writer.WriteBlittable(data);
|
||||
}
|
||||
|
||||
public static PredictedSyncData ReadPredictedSyncData(this NetworkReader reader)
|
||||
{
|
||||
return new PredictedSyncData
|
||||
{
|
||||
deltaTime = reader.ReadFloat(),
|
||||
position = reader.ReadVector3(),
|
||||
rotation = reader.ReadQuaternion(),
|
||||
velocity = reader.ReadVector3(),
|
||||
angularVelocity = reader.ReadVector3()
|
||||
};
|
||||
return reader.ReadBlittable<PredictedSyncData>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,3 +10,4 @@
|
||||
[assembly: InternalsVisibleTo("Mirror.Tests.Performance.Editor")]
|
||||
[assembly: InternalsVisibleTo("Mirror.Tests.Performance.Runtime")]
|
||||
[assembly: InternalsVisibleTo("Mirror.Editor")]
|
||||
[assembly: InternalsVisibleTo("Mirror.Components")]
|
||||
|
Loading…
Reference in New Issue
Block a user