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