示例#1
0
        /// <summary>
        /// Unlike Extrapolate - Reconstruct is used when the buffer isn't empty, but rather we are dealing with a lost packet while there is a future frame in the buffer.
        /// </summary>
        public void OnReconstructMissing(Frame nextFrame, Frame currentFrame, Frame nextValidFrame, float t, bool svrWaitingForTeleportConfirm)
        {
            //List<XElement> currFrameElements = elements[currentFrame.frameid];
            //List<XElement> nextFrameElements = elements[nextFrame.frameid];
            //List<XElement> nextValidFrameElements = elements[nextValidFrame.frameid];

            // Reconstruct missing frames
            for (int eid = 0; eid < elementCount; ++eid)
            {
                TransformElement te = transformElements[eid];

                TransformElement.ElementFrame ce  = te.frames[currentFrame.frameid];             // currFrameElements[eid];
                TransformElement.ElementFrame ne  = te.frames[nextFrame.frameid];                // nextFrameElements[eid];
                TransformElement.ElementFrame nve = te.frames[nextValidFrame.frameid];


                //TODO are these if's needed for the null checking? Keep an eye on this.
                // Eliminate any Null genericX values = they indicate no changes
                if (ce.xform.type == XType.NULL)
                {
                    ce.xform     = te.Localized;
                    ce.compXform = te.Compress(ce.xform);

                    Debug.Log("Current element is null");
                }

                if (nve.xform.type == XType.NULL)
                {
                    nve.xform = ce.xform;
                    //Debug.LogError("nextvalid element is null");
                }


                // If server his holding for teleport confirm, keep using the same teleport value
                if (svrWaitingForTeleportConfirm && te.teleportOverride)
                {
                    ne.xform     = te.lastSentTransform;
                    ne.compXform = te.lastSentCompressed;
                }
                // There is a future frame to use as a guess target
                else if (nve.xform.type != XType.NULL)                 // nst.buffer.masks[eid].GetBitInMask(nextValidFrame.frameid))
                {
                    ne.xform     = te.Lerp(ce.xform, nve.xform, t);
                    ne.compXform = te.Compress(ne.xform);
                }
                // There is no future frame.
                else
                {
                    if (ce.xform.type == XType.NULL)
                    {
                        Debug.Log("Houston we have a null here.");
                    }

                    ne.xform     = ce.xform;
                    ne.compXform = ce.compXform;
                }
            }
        }
示例#2
0
        /// <summary>
        /// Extrapolate is used when the buffer is empty.
        /// </summary>
        public void OnExtrapolate(Frame targFr, Frame currFr, int extrapolationCount, bool svrWaitingForTeleportConfirm)
        {
            for (int eid = 0; eid < elementCount; ++eid)
            {
                TransformElement te = transformElements[eid];

                bool currIsNull = te.frames[currFr.frameid].xform.type == XType.NULL;

                // repeat teleportoverride if this is server and is waiting for a teleport confirm
                bool svrWaiting = svrWaitingForTeleportConfirm && te.teleportOverride;                 // || currFr.updateType.IsTeleport() && te.teleportOverride;

                // Don't extrapolate if this was a teleport or if we are exceeded the max number of sequential extrapolates
                bool dontExtrapolate = (currFr.updateType.IsTeleport() || extrapolationCount >= te.maxExtrapolates);

                te.frames[targFr.frameid].xform =
                    svrWaiting ? te.lastSentTransform :
                    dontExtrapolate ? currIsNull ? te.Localized : te.frames[currFr.frameid].xform :                     // If the current frame we are extrapolating was a teleport... just copy
                    te.Extrapolate();

                te.frames[targFr.frameid].compXform =
                    svrWaiting ? te.lastSentCompressed :
                    dontExtrapolate ? te.frames[currFr.frameid].compXform :                     // If the current frame we are extrapolating was a teleport... just copy
                    te.Compress(te.frames[targFr.frameid].xform);
            }
        }
示例#3
0
文件: Frame.cs 项目: vert0r/NetDemo2
        /// <summary>
        /// Apply all of the current transforms to this frames stored transforms.
        /// </summary>
        public void CaptureCurrentTransforms()
        {
            updateType   = UpdateType.Teleport;
            rootSendType = RootSendType.Full;

            RootPos = nst.transform.position;

            for (int eid = 0; eid < elements.Count; eid++)
            {
                TransformElement te = nstElementsEngine.transformElements[eid];

                elements[eid].transform = te.Localized;
                elements[eid].compTrans = te.Compress();
            }
        }
示例#4
0
        /// <summary>
        /// Apply all of the current transforms to this frames stored transforms.
        /// </summary>
        public void CaptureCurrentTransforms()
        {
            updateType       = UpdateType.Teleport;
            rootBitCullLevel = BitCullingLevel.NoCulling;

            RootPos = nst.transform.position;

            for (int eid = 0; eid < tes.Length; eid++)
            {
                TransformElement te = tes[eid];

                te.frames[frameid].xform     = te.Localized;
                te.frames[frameid].compXform = te.Compress();
            }
        }