perf: PredictedRigidbody syncs a blittable struct once instead of doing 5 separate reads/writes

This commit is contained in:
mischa 2024-03-14 11:50:54 +08:00
parent fb1d2ee683
commit a4f42194cf
2 changed files with 3 additions and 13 deletions

View File

@ -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>();
}
}
}

View File

@ -10,3 +10,4 @@
[assembly: InternalsVisibleTo("Mirror.Tests.Performance.Editor")]
[assembly: InternalsVisibleTo("Mirror.Tests.Performance.Runtime")]
[assembly: InternalsVisibleTo("Mirror.Editor")]
[assembly: InternalsVisibleTo("Mirror.Components")]