Beispiel #1
0
        /// <param name="forcedUpdate">Indicates that this update is expected, so there will be no bool bit before it indicating whether it was sent.</param>
        /// <returns></returns>
        public override bool ReadFromBitstream(ref UdpKit.UdpBitStream bitstream, MsgType msgType, Frame targetFrame, int i, bool forcedUpdate, bool isKeyframe)
        {
            // Only read for the sent bit if not forced, there is no check bit for forced updates (since all clients and server know it is forced)
            bool hasChanged = forcedUpdate || bitstream.ReadBool();

            if (!hasChanged)
            {
                targetFrame.positions[i] = GenericX.NULL;
                return(false);
            }

            for (int axis = 0; axis < 3; axis++)
            {
                if (axisRanges[axis].useAxis)
                {
                    xyz[axis] =
                        (compression == Compression.HalfFloat) ? bitstream.ReadHalf() :
                        //(compression == Compression.Global) ? NSTCompressVector.ReadAxisFromBitstream(ref bitstream, axis, (cullUpperBits && !isKeyframe)) :
                        (compression == Compression.LocalRange) ? axisRanges[axis].Decode(bitstream.ReadUInt(axisRanges[axis].bits)) :
                        bitstream.ReadFloat();
                }
            }

            targetFrame.positions[i] = new Vector3
                                       (
                (axisRanges[0].useAxis) ? xyz[0] : Localized[0],
                (axisRanges[1].useAxis) ? xyz[1] : Localized[1],
                (axisRanges[2].useAxis) ? xyz[2] : Localized[2]
                                       );

            return(true);
        }