Vixen
02b45cc4
csharp
public readonly record struct QuantizeRange

A float, sent in fewer bits than a float takes, by saying what it is a float of.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

A position in a level a kilometre across, to the nearest three centimetres, is sixteen bits rather than thirty-two. A normalised intensity is eight. The saving is not the point on its own — the point is that it is declared, at the field, so the precision a packet costs is a number somebody chose rather than whatever float happens to be, and MaxError says what was given up.

Encoding is a round to the nearest level, so the error is bounded by half a level and is symmetric. Values outside the range are clamped rather than wrapped: a player who walks through the wall of the declared range should stop at it in the packet, not appear at the other end of the level.

Fields and properties (6)

  • public float Min

    The smallest value that can be sent exactly.

  • public float Max

    The largest.

  • public int Bits

    How many bits to spend, from 1 to 32.

  • public uint Levels

    How many steps the range is divided into.

  • public float MaxError

    The most a value can be changed by a round trip through this range.

  • public bool IsValid

    Whether this range can be encoded with.

Methods (3)

  • public QuantizeRange(float Min, float Max, int Bits)

    A float, sent in fewer bits than a float takes, by saying what it is a float of.

  • public uint Encode(float value)

    Turns a value into the bits that will be sent.

  • public float Decode(uint encoded)

    Turns received bits back into a value.

Used by (26)

  • AvatarControllerMultiplayer
  • LocalMatchMultiplayer
  • BitCodecTestsVixen.Net.Tests
  • BitExactnessTestsVixen.Net.Tests
  • BitReaderVixen.Net
  • BitReaderTargetVixen.Net.Fuzz
  • BitWriterVixen.Net
  • ClientPredictionTestsVixen.Net.Tests
  • DeltaTestsVixen.Net.Tests
  • GeneratedTurretVixen.Net.Generators.Tests
  • HandWrittenTransformReplicatorVixen.Net.Generators.Tests
  • MathCodecVixen.Net
  • MotionTestsVixen.Net.Tests
  • NetworkAnimatorReplicatorVixen.Net.Animation
  • NetworkAudioSourceReplicatorVixen.Net.Audio
  • NetworkRigidBodyReplicatorVixen.Net.Physics
  • NetworkRigidBodyTestsVixen.Net.Physics.Tests
  • NetworkTransformReplicatorVixen.Net
  • PlayerMoveInputVixen.Net.Engine
  • PlayerMoveInputTestsVixen.Net.Engine.Tests
  • PositionReplicatorVixen.Net.Tests
  • ReplicationGeneratorTestsVixen.Net.Generators.Tests
  • ReplicationTestsVixen.Net.Tests
  • RpcGeneratorTestsVixen.Net.Generators.Tests
  • Vixen_Net_Generators_Tests_GeneratedPoseReplicatorVixen.Net.Generators.Tests
  • Vixen_Net_Generators_Tests_GeneratedTransformReplicatorVixen.Net.Generators.Tests