예제 #1
0
            /// <summary>
            /// Synchronously delete the given object from the scene.
            /// </summary>
            /// <param name="group">Object Id</param>
            /// <param name="DeleteScripts">Remove the scripts from the ScriptEngine as well</param>
            /// <param name="removeFromDatabase">Remove from the database?</param>
            protected bool DeleteSceneObject(ISceneEntity group, bool DeleteScripts, bool removeFromDatabase)
            {
                //MainConsole.Instance.DebugFormat("[Backup]: Deleting scene object {0} {1}", group.Name, group.UUID);

                lock (group.SitTargetAvatar)
                {
                    if (group.SitTargetAvatar.Count != 0)
                    {
                        UUID[] ids = new UUID[group.SitTargetAvatar.Count];
                        group.SitTargetAvatar.CopyTo(ids);
                        foreach (UUID avID in ids)
                        {
                            //Don't screw up avatar's that are sitting on us!
                            IScenePresence SP = m_scene.GetScenePresence(avID);
                            if (SP != null)
                            {
                                SP.StandUp();
                            }
                        }
                    }
                }

                // Serialise calls to RemoveScriptInstances to avoid
                // deadlocking on m_parts inside SceneObjectGroup
                if (DeleteScripts)
                {
                    group.RemoveScriptInstances(true);
                }

                foreach (ISceneChildEntity part in group.ChildrenEntities())
                {
                    IScriptControllerModule m = m_scene.RequestModuleInterface <IScriptControllerModule>();
                    if (m != null)
                    {
                        m.RemoveAllScriptControllers(part);
                    }
                }
                if (group.RootChild.PhysActor != null)
                {
                    //Remove us from the physics sim
                    m_scene.PhysicsScene.DeletePrim(group.RootChild.PhysActor);
                    //We MUST leave this to the PhysicsScene or it will hate us forever!
                    //group.RootChild.PhysActor = null;
                }

                if (!group.IsAttachment)
                {
                    m_scene.SimulationDataService.Tainted();
                }
                if (m_scene.SceneGraph.DeleteEntity(group))
                {
                    // We need to keep track of this state in case this group is still queued for backup.
                    group.IsDeleted = true;
                    m_scene.EventManager.TriggerObjectBeingRemovedFromScene(group);
                    return(true);
                }

                //MainConsole.Instance.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID);
                return(false);
            }
예제 #2
0
            /// <summary>
            ///     Synchronously delete the given object from the scene.
            /// </summary>
            /// <param name="group">Object Id</param>
            /// <param name="DeleteScripts">Remove the scripts from the ScriptEngine as well</param>
            /// <param name="removeFromDatabase">Remove from the database?</param>
            protected bool DeleteSceneObject(ISceneEntity group, bool DeleteScripts, bool removeFromDatabase)
            {
                //MainConsole.Instance.DebugFormat("[Backup]: Deleting scene object {0} {1}", group.Name, group.UUID);

                if (group.SitTargetAvatar.Count != 0)
                {
                    foreach (UUID avID in group.SitTargetAvatar)
                    {
                        //Don't screw up avatar's that are sitting on us!
                        IScenePresence SP = m_scene.GetScenePresence(avID);
                        if (SP != null)
                            SP.StandUp();
                    }
                }

                // Serialise calls to RemoveScriptInstances to avoid
                // deadlocking on m_parts inside SceneObjectGroup
                if (DeleteScripts)
                {
                    group.RemoveScriptInstances(true);
                }

                foreach (ISceneChildEntity part in group.ChildrenEntities())
                {
                    IScriptControllerModule m = m_scene.RequestModuleInterface<IScriptControllerModule>();
                    if (m != null)
                        m.RemoveAllScriptControllers(part);
                }
                if (group.RootChild.PhysActor != null)
                {
                    //Remove us from the physics sim
                    m_scene.PhysicsScene.DeletePrim(group.RootChild.PhysActor);
                    group.RootChild.PhysActor = null;
                }

                if (!group.IsAttachment)
                    m_scene.SimulationDataService.Tainted();
                if (m_scene.SceneGraph.DeleteEntity(group))
                {
                    // We need to keep track of this state in case this group is still queued for backup.
                    group.IsDeleted = true;
                    m_scene.EventManager.TriggerObjectBeingRemovedFromScene(group);
                    return true;
                }

                //MainConsole.Instance.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID);
                return false;
            }
예제 #3
0
            /// <summary>
            /// Synchronously delete the given object from the scene.
            /// </summary>
            /// <param name="group">Object Id</param>
            /// <param name="DeleteScripts">Remove the scripts from the ScriptEngine as well</param>
            /// <param name="removeFromDatabase">Remove from the database?</param>
            protected bool DeleteSceneObject(ISceneEntity group, bool DeleteScripts, bool removeFromDatabase)
            {
                //m_log.DebugFormat("[Backup]: Deleting scene object {0} {1}", group.Name, group.UUID);

                lock (group.SitTargetAvatar)
                {
                    if (group.SitTargetAvatar.Count != 0)
                    {
                        UUID[] ids = new UUID[group.SitTargetAvatar.Count];
                        group.SitTargetAvatar.CopyTo(ids);
                        foreach (UUID avID in ids)
                        {
                            //Don't screw up avatar's that are sitting on us!
                            IScenePresence SP = m_scene.GetScenePresence(avID);
                            if (SP != null)
                                SP.StandUp();
                        }
                    }
                }

                // Serialise calls to RemoveScriptInstances to avoid
                // deadlocking on m_parts inside SceneObjectGroup
                if (DeleteScripts)
                {
                    group.RemoveScriptInstances(true);
                }

                foreach (ISceneChildEntity part in group.ChildrenEntities())
                {
                    IScriptControllerModule m = m_scene.RequestModuleInterface<IScriptControllerModule>();
                    if(m != null)
                        m.RemoveAllScriptControllers(part);
                    if (part.PhysActor != null)
                    {
                        //Remove us from the physics sim
                        m_scene.PhysicsScene.RemovePrim(part.PhysActor);
                        //We MUST leave this to the PhysicsScene or it will hate us forever!
                        //part.PhysActor = null;
                    }
                }

                m_scene.SimulationDataService.Tainted ();
                if (m_scene.SceneGraph.DeleteEntity(group))
                {
                    // We need to keep track of this state in case this group is still queued for backup.
                    group.IsDeleted = true;
                    //Clear the update schedule HERE so that IsDeleted will not have to fire as well

                    foreach (ISceneChildEntity part in group.ChildrenEntities ())
                    {
                        //Make sure it isn't going to be updated again
                        part.ClearUpdateSchedule ();
                    }
                    m_scene.EventManager.TriggerObjectBeingRemovedFromScene(group);
                    return true;
                }

                //m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID);
                return false;
            }