Skip to content

Commit e0b1d27

Browse files
committed
feat(serialization): Adds non packed quaternion writing
1 parent 287b0e8 commit e0b1d27

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

MLAPI/NetworkingManagerComponents/Binary/BitReader.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,20 @@ public Quaternion ReadRotation(int bytesPerAngle)
352352
return ReadRotationPacked();
353353
}
354354

355+
/// <summary>
356+
/// Reads the rotation from the stream
357+
/// </summary>
358+
/// <returns>The rotation read from the stream</returns>
359+
public Quaternion ReadRotation()
360+
{
361+
float x = ReadSingle();
362+
float y = ReadSingle();
363+
float z = ReadSingle();
364+
float w = ReadSingle();
365+
366+
return new Quaternion(x, y, z, w);
367+
}
368+
355369
/// <summary>
356370
/// Read a certain amount of bits from the stream.
357371
/// </summary>

MLAPI/NetworkingManagerComponents/Binary/BitWriter.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,18 @@ public void WriteRotation(Quaternion rotation, int bytesPerAngle)
414414
WriteRotationPacked(rotation);
415415
}
416416

417+
/// <summary>
418+
/// Writes the rotation to the stream.
419+
/// </summary>
420+
/// <param name="rotation">Rotation to write</param>
421+
public void WriteRotation(Quaternion rotation)
422+
{
423+
WriteSingle(rotation.x);
424+
WriteSingle(rotation.y);
425+
WriteSingle(rotation.z);
426+
WriteSingle(rotation.w);
427+
}
428+
417429
/// <summary>
418430
/// Writes a single bit
419431
/// </summary>

0 commit comments

Comments
 (0)