branchrust_reboot/main/optimize_position_updatecancel
11 Commits over 0 Days - Infinitycph!
merge from main -> optimize_position_update
Switch batches from channel 1 -> channel 0 so it's ordered with all the other packets (since we no longer use unordered for position packets)
Lower quant from 1cm -> 1mm for position
- switch from sending delta position to sending quantized acceleration so we can keep 1 byte per update after moving to a 10x smaller quant
- if acceleration is larger than 0.127m / tick then it will send full acceleration (allows it to support instant teleports and large changes in velocity)
- will fine-tune values further
Only check if quant settings have changed once per frame in flush instead of every single position packet
Switch from generic stream -> BufferStream in the EntityPositionBatchReader since both demos and network data share the same class of stream for packets
Send positions & rotations quantized
- reduce the 3x positions floats from 4 -> 1 bytes when they are within 1.27m per tick (1cm quantization)
- reduce the 3x rotations from 4 -> 1 byte when they are within 25 degrees per tick (0.2 degree quantization)
- will fine tune the values if it's too high a quant
- fallback to sending the full value when it changes by more than a delta
- tell the client what the quantization is so it can be changed during the session and be captured by demos
Store entity ID for position ticks in a 1000 sized cache
- reduces entity ID from 8 -> 5 -> 2 bytes (8 now, would be ~5 with VarInt encoding, 2 bytes with index lookup)
- also compresses the parent's network ID when parented
- overkill just for network IDs but basically free since we also want to do lossy compression for positions
- demos store the network ID lookup in the keyframes so it can skip forwards & backwards still
- make batch position packets ordered now (not a big deal since they are way smaller than old ones and max one per server frame)
▌ ▉▅▄ ▍▉▋▋▅▅▍▄▉▅▊▊▉ ▉▆▉ ▆▆▄▉▊ ▌▋▋▊▍▌▆▇▆ ▆▋▉▌▍▅▊ ▇▋█▆█▉▉█▅▍▉▋▊▊▉▉▊ █▅ ▌▄▅▅ ▆▊▋ ▇▌▌▄▊▊▅▍▌▉▊ ▇▆▆▅▇█▄ ▆█▊▉ ▋▆▍█▌▆▊▆▉▅ ▉▊▆ ▊▉▄ ▆▍▊▋ ▋▄▌▆▅▌ ▊▊▋▅▍▆ ▅▋▅▊▅ ▆▋▌▆ ▊▄▉▌▉▄█▋ █▋ ▇▌▌▌▋█▊▆▍▊▍▉▇▅▆▉█▉▍ ▍▍▅▋▉▄▄ ▇█▊▌▅ ▍▆▇▊▇▆▌▇ ▆█▄▌ ▆▆▅▊ ▇▉▄
Update demos to read the new batched packet format
Update SendNetworkPositions() to use the new batched path
- famous last words but batched position updates shouldn't break so we shouldn't need a ConVar to toggle behavior at runtime
Add batching for position ticks
- new packet type EntityPositionBatch so old demos keep working
- batches together entity position updates per player per server frame
- flushes batches after ServerMgr * Invokes
- skips sending time field if it's the same as the entity before it