public void DecodeVector3(SendTableProp propInfo, out Vector3 vec3) // src_main\engine\dt_encode.cpp line 158 { vec3.X = DecodeFloat(propInfo); vec3.Y = DecodeFloat(propInfo); if (propInfo.FloatParseType == FloatParseType.Normal) { // Don't read in the third component for normals bool sign = ReadBool(); float distSqr = vec3.X * vec3.X + vec3.Y * vec3.Y; if (distSqr < 1) { vec3.Z = (float)Math.Sqrt(1 - distSqr); } else { vec3.Z = 0; } if (sign) { vec3.Z = -vec3.Z; } } else { vec3.Z = DecodeFloat(propInfo); } }
protected override void Parse(ref BitStreamReader bsr) { NeedsDecoder = bsr.ReadBool(); Name = bsr.ReadNullTerminatedString(); ExpectedPropCount = (int)bsr.ReadUInt(DemoInfo.Game == SourceGame.HL2_OE ? 9 : 10); SendProps = new List <SendTableProp>(ExpectedPropCount); for (int i = 0; i < ExpectedPropCount; i++) { var sendProp = new SendTableProp(DemoRef, this); SendProps.Add(sendProp); sendProp.ParseStream(ref bsr); } }
private float ReadBitCellCoord(SendTableProp propInfo) { uint intVal = (uint)ReadULong((int)propInfo.NumBits !.Value); if (propInfo.FloatParseType == FloatParseType.BitCellChordInt) { return(intVal); } else { bool lp = propInfo.FloatParseType == FloatParseType.BitCellChordLp; uint fractVal = ReadUInt(lp ? CoordFracBitsMpLp : CoordFracBits); return(intVal + fractVal * (lp ? CoordResLp : CoordRes)); } }
public float DecodeFloat(SendTableProp propInfo) { if (propInfo.FloatParseType == null) { SetFloatParseType(propInfo); } return(propInfo.FloatParseType switch { FloatParseType.Standard => ReadStandardFloat(propInfo), FloatParseType.Coord => ReadBitCoord(), FloatParseType.BitCoordMp => ReadBitCoordMp(propInfo), FloatParseType.BitCoordMpLp => ReadBitCoordMp(propInfo), FloatParseType.BitCoordMpInt => ReadBitCoordMp(propInfo), FloatParseType.NoScale => ReadFloat(), FloatParseType.Normal => ReadBitNormal(), FloatParseType.BitCellChord => ReadBitCellCoord(propInfo), FloatParseType.BitCellChordLp => ReadBitCellCoord(propInfo), FloatParseType.BitCellChordInt => ReadBitCellCoord(propInfo), _ => throw new ArgumentOutOfRangeException(nameof(propInfo.FloatParseType)) });
public void DecodeVector2(SendTableProp propInfo, out Vector2 vec2) // nice and easy { vec2.X = DecodeFloat(propInfo); vec2.Y = DecodeFloat(propInfo); }