protected void EventManager_OnRemovePresence(IScenePresence presence) { PerClientSelectionParticles particles = presence.RequestModuleInterface <PerClientSelectionParticles>(); if (particles != null) { particles.Close(); presence.UnregisterModuleInterface(particles); } }
/// <summary> /// Handle the deselection of a prim from the client. /// </summary> /// <param name = "primLocalID"></param> /// <param name = "remoteClient"></param> protected void DeselectPrim(uint primLocalID, IClientAPI remoteClient) { IScene scene = remoteClient.Scene; ISceneChildEntity part = scene.GetSceneObjectPart(primLocalID); //Do this first... As if its null, this wont be fired. IScenePresence SP; scene.TryGetScenePresence(remoteClient.AgentId, out SP); if (SP == null) { return; } PerClientSelectionParticles selection = SP.RequestModuleInterface <PerClientSelectionParticles>(); if (selection != null) { selection.SelectedUUID = null; selection.IsSelecting = false; } if (part == null) { return; } // The prim is in the process of being deleted. if (null == part.ParentEntity.RootChild) { return; } // A deselect packet contains all the local prims being deselected. However, since selection is still // group based we only want the root prim to trigger a full update - otherwise on objects with many prims // we end up sending many duplicate ObjectUpdates // if (part.ParentGroup.RootPart.LocalId != part.LocalId) // return; // part.ParentGroup.IsSelected = false; part.IsSelected = false; if (!part.ParentEntity.IsAttachment) //This NEEDS to be done because otherwise rotationalVelocity will break! Only for the editing av as the client stops the rotation for them when they are in edit { if (part.AngularVelocity != Vector3.Zero && !part.ParentEntity.IsDeleted) { SP.SceneViewer.QueuePartForUpdate(part, PrimUpdateFlags.ForcedFullUpdate); } } scene.AuroraEventManager.FireGenericEventHandler("ObjectDeselected", part); }
protected void ProcessViewerEffect(IClientAPI remoteClient, List <ViewerEffectEventHandlerArg> args) { IScene scene = remoteClient.Scene; // TODO: don't create new blocks if recycling an old packet ViewerEffectPacket.EffectBlock[] effectBlockArray = new ViewerEffectPacket.EffectBlock[args.Count]; IScenePresence SP; scene.TryGetScenePresence(remoteClient.AgentId, out SP); for (int i = 0; i < args.Count; i++) { ViewerEffectPacket.EffectBlock effect = new ViewerEffectPacket.EffectBlock { AgentID = args[i].AgentID, Color = args[i].Color, Duration = args[i].Duration, ID = args[i].ID, Type = args[i].Type, TypeData = args[i].TypeData }; effectBlockArray[i] = effect; //Save the color if (effect.Type == (int)EffectType.Beam || effect.Type == (int)EffectType.Point || effect.Type == (int)EffectType.Sphere) { Color4 color = new Color4(effect.Color, 0, false); if (SP != null && !(color.R == 0 && color.G == 0 && color.B == 0)) { PerClientSelectionParticles selection = SP.RequestModuleInterface <PerClientSelectionParticles>(); if (selection != null) { selection.EffectColor = args[i].Color; } } } #if (!ISWIN) foreach (IScenePresence client in scene.GetScenePresences()) { if (client.ControllingClient.AgentId != remoteClient.AgentId) { client.ControllingClient.SendViewerEffect(effectBlockArray); } } #else foreach (IScenePresence client in scene.GetScenePresences().Where(client => client.ControllingClient.AgentId != remoteClient.AgentId)) { client.ControllingClient.SendViewerEffect(effectBlockArray); } #endif } }
/// <summary> /// Handle the deselection of a prim from the client. /// </summary> /// <param name="primLocalID"></param> /// <param name="remoteClient"></param> protected void DeselectPrim(uint primLocalID, IClientAPI remoteClient) { IScene scene = remoteClient.Scene; ISceneChildEntity part = scene.GetSceneObjectPart(primLocalID); //Do this first... As if its null, this wont be fired. IScenePresence SP; scene.TryGetScenePresence(remoteClient.AgentId, out SP); if (SP == null) { return; } PerClientSelectionParticles selection = SP.RequestModuleInterface <PerClientSelectionParticles>(); if (selection != null) { selection.SelectedUUID = null; selection.IsSelecting = false; } if (part == null) { return; } // The prim is in the process of being deleted. if (null == part.ParentEntity.RootChild) { return; } part.ParentEntity.IsSelected = false; if (!part.ParentEntity.IsAttachment) //This NEEDS to be done because otherwise rotationalVelocity will break! Only for the editing av as the client stops the rotation for them when they are in edit { if (part.AngularVelocity != Vector3.Zero && !part.ParentEntity.IsDeleted) { SP.SceneViewer.QueuePartForUpdate(part, PrimUpdateFlags.ForcedFullUpdate); } } }
/// <summary> /// Invoked when the client selects a prim. /// </summary> /// <param name="primLocalIDs"></param> /// <param name="remoteClient"></param> protected void SelectPrim(List <uint> primLocalIDs, IClientAPI remoteClient) { IScene scene = remoteClient.Scene; List <ISceneChildEntity> EntitiesToUpdate = new List <ISceneChildEntity>(); ISceneChildEntity prim = null; foreach (uint primLocalID in primLocalIDs) { ISceneChildEntity entity = null; if (scene.SceneGraph.TryGetPart(primLocalID, out entity)) { if (entity is ISceneChildEntity) { prim = entity; // changed so that we send select to all the indicated prims // also to root prim (done in prim.IsSelected) // so "edit link parts" keep the object select and not moved by physics // similar changes on deselect // part.IsSelect is on SceneObjectPart.cs // Ubit prim.ParentEntity.IsSelected = true; } } //Check for avies! They arn't prims! if (scene.GetScenePresence(primLocalID) != null) { continue; } if (entity != null) { if (!EntitiesToUpdate.Contains(entity)) { EntitiesToUpdate.Add(entity); } } else { MainConsole.Instance.ErrorFormat( "[SCENEPACKETHANDLER]: Could not find prim {0} in SelectPrim, killing prim.", primLocalID); //Send a kill packet to the viewer so it doesn't come up again remoteClient.SendKillObject(scene.RegionInfo.RegionHandle, new uint[1] { primLocalID }); } } IScenePresence SP; scene.TryGetScenePresence(remoteClient.AgentId, out SP); if (SP == null) { return; } if (EntitiesToUpdate.Count != 0) { SP.SceneViewer.QueuePartsForPropertiesUpdate(EntitiesToUpdate.ToArray()); } PerClientSelectionParticles selection = SP.RequestModuleInterface <PerClientSelectionParticles>(); if (selection != null) { selection.SelectedUUID = prim; selection.IsSelecting = true; } }
/// <summary> /// Invoked when the client selects a prim. /// </summary> /// <param name="primLocalID"></param> /// <param name="remoteClient"></param> protected void SelectPrim(List <uint> primLocalIDs, IClientAPI remoteClient) { Scene scene = ((Scene)remoteClient.Scene); List <IEntity> EntitiesToUpdate = new List <IEntity> (); SceneObjectPart prim = null; foreach (uint primLocalID in primLocalIDs) { ISceneChildEntity entity = null; if (scene.SceneGraph.TryGetPart(primLocalID, out entity)) { if (entity is SceneObjectPart) { prim = entity as SceneObjectPart; // changed so that we send select to all the indicated prims // also to root prim (done in prim.IsSelected) // so "edit link parts" keep the object select and not moved by physics // similar changes on deselect // part.IsSelect is on SceneObjectPart.cs // Ubit // if (prim.IsRoot) { // prim.ParentGroup.IsSelected = true; prim.IsSelected = true; scene.AuroraEventManager.FireGenericEventHandler("ObjectSelected", prim); } } } //Check for avies! They arn't prims! if (scene.GetScenePresence(primLocalID) != null) { continue; } if (entity != null) { if (!EntitiesToUpdate.Contains(entity)) { EntitiesToUpdate.Add(entity); } } else { m_log.Error("[SCENEPACKETHANDLER]: Could not find prim in SelectPrim, killing prim."); //Send a kill packet to the viewer so it doesn't come up again remoteClient.SendKillObject(scene.RegionInfo.RegionHandle, new uint[1] { primLocalID }); } } if (EntitiesToUpdate.Count != 0) { remoteClient.SendObjectPropertiesReply(EntitiesToUpdate); } IScenePresence SP; scene.TryGetScenePresence(remoteClient.AgentId, out SP); PerClientSelectionParticles selection = SP.RequestModuleInterface <PerClientSelectionParticles>(); if (selection != null) { selection.SelectedUUID = prim; selection.IsSelecting = true; } }