Skip to content

Commit 78b8dc5

Browse files
committed
Added Ray read & write
1 parent d629244 commit 78b8dc5

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

MLAPI/NetworkingManagerComponents/Binary/BitStream.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,26 @@ public void WriteDoublePacked(double value)
334334
}
335335
}
336336

337+
/// <summary>
338+
/// Convenience method that writes two non-packed Vector3 from the ray to the stream
339+
/// </summary>
340+
/// <param name="ray">Ray to write</param>
341+
public void WriteRay(Ray ray)
342+
{
343+
WriteVector3(ray.origin);
344+
WriteVector3(ray.direction);
345+
}
346+
347+
/// <summary>
348+
/// Convenience method that writes two packed Vector3 from the ray to the stream
349+
/// </summary>
350+
/// <param name="ray">Ray to write</param>
351+
public void WriteRayPacked(Ray ray)
352+
{
353+
WriteVector3Packed(ray.origin);
354+
WriteVector3Packed(ray.direction);
355+
}
356+
337357
/// <summary>
338358
/// Convenience method that writes four non-varint floats from the color to the stream
339359
/// </summary>
@@ -603,6 +623,18 @@ public double ReadDoublePacked()
603623
/// <returns>The Color32 read from the stream.</returns>
604624
public Color32 ReadColor32() => new Color32((byte)ReadByte(), (byte)ReadByte(), (byte)ReadByte(), (byte)ReadByte());
605625

626+
/// <summary>
627+
/// Read a Ray from the stream.
628+
/// </summary>
629+
/// <returns>The Ray read from the stream.</returns>
630+
public Ray ReadRay() => new Ray(ReadVector3(), ReadVector3());
631+
632+
/// <summary>
633+
/// Read a Ray from the stream.
634+
/// </summary>
635+
/// <returns>The Ray read from the stream.</returns>
636+
public Ray ReadRayPacked() => new Ray(ReadVector3Packed(), ReadVector3Packed());
637+
606638
/// <summary>
607639
/// Read a single-precision floating point value from the stream. The value is between (inclusive) the minValue and maxValue.
608640
/// </summary>

0 commit comments

Comments
 (0)