Esempio n. 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;
                }
            }
        }
Esempio n. 2
0
        // Construct
        public Frame(NetworkSyncTransform _nst, int _frameid, Vector3 _pos, CompressedElement _compPos, Quaternion _rot)         //, PositionElement[] positionElements, RotationElement[] rotationElements)
        {
            nst        = _nst;
            rootPos    = _pos;
            compPos    = _compPos;
            state      = nst.State;
            frameid    = _frameid;
            customData = new byte[128];              //TODO: Make this size a user setting

            // references
            tes = _nst.nstElementsEngine.transformElements;
            rootRotElementFrame = nst.rootRotationElement.frames[_frameid];
        }