private void SendPhysicsUpdate(float timestamp)
        {
            if (LocalUser == null)
            {
                return;
            }

            PhysicsBridgePatch physicsPatch = new PhysicsBridgePatch(LocalUser.Id,
                                                                     PhysicsBridge.GenerateSnapshot(timestamp, SceneRoot));

            // send only updates if there are any, to save band with
            // in order to produce any updates for settled bodies this should be handled within the physics bridge
            if (physicsPatch.DoSendThisPatch())
            {
                EventManager.QueueEvent(new PhysicsBridgeUpdated(InstanceId, physicsPatch));
            }

            //low frequency server upload transform stream
            {
                float systemTime = OS.GetTicksMsec() * 0.001f;
                if (PhysicsBridge.shouldSendLowFrequencyTransformUpload(systemTime))
                {
                    PhysicsTranformServerUploadPatch serverUploadPatch =
                        PhysicsBridge.GenerateServerTransformUploadPatch(InstanceId, systemTime);
                    // upload only if there is a real difference in the transforms
                    if (serverUploadPatch.IsPatched())
                    {
                        EventManager.QueueEvent(new PhysicsTranformServerUploadUpdated(InstanceId, serverUploadPatch));
                    }
                }
            }

            _shouldSendPhysicsUpdate    = false;
            _timeSinceLastPhysicsUpdate = 0.0f;
        }
Ejemplo n.º 2
0
        private void SendPhysicsUpdate()
        {
            PhysicsBridgePatch physicsPatch = new PhysicsBridgePatch(InstanceId,
                                                                     _physicsBridge.GenerateSnapshot(UnityEngine.Time.fixedTime, SceneRoot.transform));

            // send only updates if there are any, to save band with
            // in order to produce any updates for settled bodies this should be handled within the physics bridge
            if (physicsPatch.TransformCount > 0)
            {
                EventManager.QueueEvent(new PhysicsBridgeUpdated(InstanceId, physicsPatch));
            }
        }
 public PhysicsBridgeUpdated(Guid id, PhysicsBridgePatch physicsBridgePatch)
     : base(id)
 {
     _physicsBridgePatch = physicsBridgePatch;
 }