Skip to content

Commit 32ab0e8

Browse files
committed
update image cache docs for the offer model
1 parent e170133 commit 32ab0e8

4 files changed

Lines changed: 20 additions & 31 deletions

File tree

‎Basis Server/BasisNetworkServer/BasisNetworking/BasisNetworkImageCache.cs‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,19 @@
88
namespace Basis.Network.Server.Generic
99
{
1010
/// <summary>
11-
/// Keeps the bytes of every shared image in server RAM so a joining player can be handed the
12-
/// images already in the instance, instead of the original sharer having to send them all over
13-
/// again to each arrival.
11+
/// Keeps the bytes of every shared image in server RAM so the rest of the room can be given a
12+
/// picture the sharer only sent to the players standing near it, instead of the sharer having to
13+
/// send it again to every arrival.
1414
///
1515
/// The cache is deliberately dumb about what an image *is*: it retains the client's own scene
1616
/// payloads verbatim and replays them stamped with the original owner's player id. A receiving
1717
/// client therefore sees exactly the OpSpawn/OpChunk stream it would have got from the owner,
1818
/// and needs no knowledge that the server answered instead.
1919
///
20+
/// It is just as dumb about *where* an image is. What it hands a player first is an offer - the
21+
/// sharer's own spawn header, opcode swapped - and the position inside is bytes it copies without
22+
/// reading. Nothing moves until that client measures the distance for itself and asks.
23+
///
2024
/// Lifetime matches what clients already do with images, so the cache can never show a joiner
2125
/// something the room cannot see: an entry is dropped on despawn and when its owner disconnects.
2226
/// </summary>

‎Basis Server/BasisServerTests/BasisNetworkImageCacheTests.cs‎

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ public class BasisNetworkImageCacheTests : IDisposable
6363

6464
private const byte OpSpawn = 1;
6565
private const byte OpChunk = 2;
66-
private const byte OpTransform = 3;
6766
private const byte OpDespawn = 4;
6867
private const byte OpAnimationSpawn = 6;
6968
private const byte OpAnimationChunk = 7;
@@ -165,25 +164,6 @@ private static byte[] EncodeSpawn(
165164
return stream.ToArray();
166165
}
167166

168-
/// <summary>OpTransform as the client encodes it: pose then uniform scale.</summary>
169-
private static byte[] EncodeTransform(Guid id, float x, float y, float z)
170-
{
171-
using MemoryStream stream = new MemoryStream();
172-
using BinaryWriter writer = new BinaryWriter(stream, Encoding.UTF8);
173-
writer.Write(OpTransform);
174-
writer.Write(id.ToByteArray());
175-
writer.Write(x);
176-
writer.Write(y);
177-
writer.Write(z);
178-
for (int axis = 0; axis < 4; axis++)
179-
{
180-
writer.Write(0f);
181-
}
182-
writer.Write(1f);
183-
writer.Flush();
184-
return stream.ToArray();
185-
}
186-
187167
private static byte[] EncodeChunk(Guid id, int chunkIndex, int payloadBytes, byte opcode = OpChunk)
188168
{
189169
using MemoryStream stream = new MemoryStream();

‎Basis/Packages/com.basis.imagepickup/BasisImagePickupManager.cs‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ namespace Basis.ImagePickup
2222
{
2323
/// <summary>
2424
/// Per-client image pickup service. It shares a deterministic network identity across all clients, so any
25-
/// client can message the others. The server (or the P2P link) relays the bytes and never stores them: an
26-
/// image exists only while its spawner is connected, and a late joiner is served by the owner re-sending.
27-
/// Anyone may delete any image for everyone.
25+
/// client can message the others. A sharer sends the picture only to the players it judges close enough;
26+
/// the server keeps a copy and offers it to everyone else, who measure the distance themselves and ask for
27+
/// it once they are near enough to want it. An image exists only while its spawner is connected, and
28+
/// anyone may delete any image for everyone.
2829
///
2930
/// The animation scheduler lives here too. It advances image-pickup animations only while their front face
3031
/// is visible to a gameplay camera: a per-frame CPU facing/frustum broad phase rejects cards before depth,
@@ -2019,8 +2020,8 @@ private static void RefreshRangeRecipients(float now)
20192020
if (owned?.Object == null)
20202021
continue;
20212022

2022-
// The server holds this one and hands it to arrivals itself, range-filtered the same
2023-
// way we filter, so re-uploading it is pure waste.
2023+
// The server holds this one and offers it to everyone else itself, so re-uploading it
2024+
// is pure waste. It tells us the moment it stops holding it and we start providing again.
20242025
if (_serverHeldImages.Contains(entry.Key))
20252026
continue;
20262027

‎Basis/Packages/com.basis.server/BasisNetworkServer/BasisNetworking/BasisNetworkImageCache.cs‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,19 @@
88
namespace Basis.Network.Server.Generic
99
{
1010
/// <summary>
11-
/// Keeps the bytes of every shared image in server RAM so a joining player can be handed the
12-
/// images already in the instance, instead of the original sharer having to send them all over
13-
/// again to each arrival.
11+
/// Keeps the bytes of every shared image in server RAM so the rest of the room can be given a
12+
/// picture the sharer only sent to the players standing near it, instead of the sharer having to
13+
/// send it again to every arrival.
1414
///
1515
/// The cache is deliberately dumb about what an image *is*: it retains the client's own scene
1616
/// payloads verbatim and replays them stamped with the original owner's player id. A receiving
1717
/// client therefore sees exactly the OpSpawn/OpChunk stream it would have got from the owner,
1818
/// and needs no knowledge that the server answered instead.
1919
///
20+
/// It is just as dumb about *where* an image is. What it hands a player first is an offer - the
21+
/// sharer's own spawn header, opcode swapped - and the position inside is bytes it copies without
22+
/// reading. Nothing moves until that client measures the distance for itself and asks.
23+
///
2024
/// Lifetime matches what clients already do with images, so the cache can never show a joiner
2125
/// something the room cannot see: an entry is dropped on despawn and when its owner disconnects.
2226
/// </summary>

0 commit comments

Comments
 (0)