Exemplo n.º 1
0
        /// <summary>
        /// Applies the scene manipulation on the scene
        /// </summary>
        /// <param name="sceneUpdates">The scene manipulations to be considered</param>
        /// <param name="deepCopy">Specifies whether the scene manipulations are directly applied or a deep copy is performed</param>
        public virtual MBoolResponse Apply(MSceneUpdate sceneUpdate, bool deepCopy = false)
        {
            MBoolResponse result = new MBoolResponse(true);

            //Increment the frame id
            this.FrameID++;

            //Stores the history
            SceneHistory.Enqueue(new Tuple <int, MSceneUpdate>(FrameID, sceneUpdate));

            //Only allow the max buffer size
            while (SceneHistory.Count > this.HistoryBufferSize)
            {
                this.SceneHistory.Dequeue();
            }


            //Set the scene changes to the input of the present frame
            this.SceneUpdate = sceneUpdate;


            //Check if there are avatars to be added
            if (sceneUpdate.AddedAvatars?.Count > 0)
            {
                this.AddAvatars(sceneUpdate.AddedAvatars, deepCopy);
            }

            //Check if there are new scene objects which should be added
            if (sceneUpdate.AddedSceneObjects?.Count > 0)
            {
                this.AddSceneObjects(sceneUpdate.AddedSceneObjects, deepCopy);
            }

            //Check if there are changed avatars that need to be retransmitted
            if (sceneUpdate.ChangedAvatars?.Count > 0)
            {
                this.UpdateAvatars(sceneUpdate.ChangedAvatars, deepCopy);
            }

            //Check if there are changed sceneObjects that need to be retransmitted
            if (sceneUpdate.ChangedSceneObjects?.Count > 0)
            {
                this.UpdateSceneObjects(sceneUpdate.ChangedSceneObjects, deepCopy);
            }

            //Check if there are avatars that need to be removed
            if (sceneUpdate.RemovedAvatars?.Count > 0)
            {
                this.RemoveAvatars(sceneUpdate.RemovedAvatars, deepCopy);
            }

            //Check if there are scene objects that need to be removed
            if (sceneUpdate.RemovedSceneObjects?.Count > 0)
            {
                this.RemoveSceneObjects(sceneUpdate.RemovedSceneObjects, deepCopy);
            }


            return(result);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Synchronizes the scene
        /// </summary>
        /// <param name="transmitFullScene">Specified whether the full scene should be transferred</param>
        public void PushScene(bool transmitFullScene = false)
        {
            //Get the events
            MSceneUpdate sceneUpdates = this.SceneAccess.GetSceneChanges();

            if (transmitFullScene)
            {
                sceneUpdates = this.SceneAccess.GetFullScene();
            }


            int serversToSynchronize = this.Adapters.Count;
            int adapterCount         = this.Adapters.Count;

            //Perform every synchronization in parallel
            Parallel.For(0, serversToSynchronize, delegate(int index)
            {
                //Get the corresponding adapter
                IAdapter adapter = this.Adapters[index];

                //Set synchronized flag to false
                adapter.SceneSynchronized = false;
                adapter.PushScene(sceneUpdates, this.SessionId);
                adapter.SceneSynchronized = true;
            });
        }
Exemplo n.º 3
0
 /// <summary>
 /// Clears the whole scene
 /// </summary>
 public virtual void Clear()
 {
     this.SceneHistory              = new Queue <Tuple <int, MSceneUpdate> >();
     this.SceneUpdate               = new MSceneUpdate();
     this.sceneObjectsByID          = new Dictionary <string, MSceneObject>();
     this.avatarsByID               = new Dictionary <string, MAvatar>();
     this.FrameID                   = 0;
     this.nameIdMappingAvatars      = new Dictionary <string, List <string> >();
     this.nameIdMappingSceneObjects = new Dictionary <string, List <string> >();
 }
Exemplo n.º 4
0
        /// <summary>
        /// Returns the full scene in form of a list of scene manipulations
        /// </summary>
        /// <returns></returns>
        public virtual MSceneUpdate GetFullScene()
        {
            MSceneUpdate sceneUpdate = new MSceneUpdate()
            {
                AddedSceneObjects = this.GetSceneObjects(),
                AddedAvatars      = this.GetAvatars()
            };

            return(sceneUpdate);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Fetches the scene information from the adapter
        /// </summary>
        public MSceneUpdate FetchSceneChanges()
        {
            MSceneUpdate sceneUpdate = new MSceneUpdate();

            if (this.Adapters.Count > 0)
            {
                sceneUpdate = this.Adapters[0].GetSceneChanges(this.SessionId);
            }

            return(sceneUpdate);
        }
        public MBoolResponse ApplyUpdates(MSceneUpdate sceneUpdates)
        {
            MBoolResponse response = new MBoolResponse(false);

            //Execute on main thread
            MainThreadDispatcher.Instance.ExecuteBlocking(() =>
            {
                response = this.sceneAccess.ApplyUpdates(sceneUpdates);
            });

            return(response);
        }
        /// <summary>
        /// Should work
        /// </summary>
        /// <param name="sceneManipulations"></param>
        /// <param name="sessionID"></param>
        public virtual MBoolResponse PushScene(MSceneUpdate sceneUpdates, string sessionID)
        {
            SessionContent sessionContent = null;

            //Get the session content for the id
            MBoolResponse sessionResult = SessionData.GetSessionContent(sessionID, out sessionContent);

            //Skip if invalid session result
            if (!sessionResult.Successful)
            {
                Debug.Fail(sessionResult.LogData.ToString());
                return(sessionResult);
            }


            //Set the last access time
            sessionContent.UpdateLastAccessTime();

            //Synchronize the respective scene
            return(sessionContent.SceneBuffer.Apply(sceneUpdates));
        }
Exemplo n.º 8
0
 /// <summary>
 /// Synchronizes the scene of the module
 /// </summary>
 /// <param name="sceneUpdates"></param>
 /// <returns></returns>
 public MBoolResponse PushScene(MSceneUpdate sceneUpdates, string sessionId)
 {
     return(this.thriftClient.Access.PushScene(sceneUpdates, sessionId));
 }
Exemplo n.º 9
0
 public MBoolResponse PushScene(MSceneUpdate sceneUpdates, string sessionId)
 {
     return(this.instance.PushScene(sceneUpdates, sessionId));
 }