From 98a9ae40c5522eb0b41e92733b315c11740fd359 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Tue, 4 May 2010 17:12:53 -0700 Subject: [PATCH] * Moved special PrimFlags.CreateSelected handling into LLClientView * Changed many SendXUpdateToY() methods to SendUpdateToY(PrimUpdateFlags updateFlags), consolidated several methods --- .../ClientStack/LindenUDP/LLClientView.cs | 24 +++++- .../Framework/Scenes/Scene.PacketHandlers.cs | 2 +- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 8 +- .../Framework/Scenes/SceneObjectGroup.cs | 45 ++--------- .../Framework/Scenes/SceneObjectPart.cs | 74 +++---------------- .../Region/Framework/Scenes/SceneViewer.cs | 9 ++- .../ContentManagementSystem/MetaEntity.cs | 12 +-- .../Shared/Api/Implementation/LSL_Api.cs | 20 ++--- 8 files changed, 65 insertions(+), 129 deletions(-) diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 6a72476e3c..9c135db07a 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -3508,7 +3508,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (update.Entity is ScenePresence) objectUpdateBlocks.Value.Add(CreateAvatarUpdateBlock((ScenePresence)update.Entity)); else - objectUpdateBlocks.Value.Add(CreatePrimUpdateBlock((SceneObjectPart)update.Entity)); + objectUpdateBlocks.Value.Add(CreatePrimUpdateBlock((SceneObjectPart)update.Entity, this.m_agentId)); } else if (!canUseImproved) { @@ -4444,7 +4444,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP return update; } - protected ObjectUpdatePacket.ObjectDataBlock CreatePrimUpdateBlock(SceneObjectPart data) + protected ObjectUpdatePacket.ObjectDataBlock CreatePrimUpdateBlock(SceneObjectPart data, UUID recipientID) { byte[] objectData = new byte[60]; data.RelativePosition.ToBytes(objectData, 0); @@ -4502,8 +4502,28 @@ namespace OpenSim.Region.ClientStack.LindenUDP update.TextureEntry = data.Shape.TextureEntry ?? Utils.EmptyBytes; update.Scale = data.Shape.Scale; update.Text = Util.StringToBytes256(data.Text); + + #region PrimFlags + + PrimFlags flags = data.Flags; + + // Don't send the CreateSelected flag to everyone + flags &= ~PrimFlags.CreateSelected; + + if (recipientID == data.OwnerID) + { + if ((data.Flags & PrimFlags.CreateSelected) != 0) + { + // Only send this flag once, then unset it + flags |= PrimFlags.CreateSelected; + data.Flags &= ~PrimFlags.CreateSelected; + } + } + update.UpdateFlags = (uint)data.Flags; + #endregion PrimFlags + if (data.Sound != UUID.Zero) { update.Sound = data.Sound; diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs index bc1023075d..600c9cd1be 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs @@ -124,7 +124,7 @@ namespace OpenSim.Region.Framework.Scenes { if (((SceneObjectGroup)ent).LocalId == primLocalID) { - ((SceneObjectGroup)ent).SendFullUpdateToClient(remoteClient); + ((SceneObjectGroup)ent).SendUpdateToClient(remoteClient, PrimUpdateFlags.FullUpdate); return; } } diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index ce11267196..cc314d7244 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -1297,7 +1297,9 @@ namespace OpenSim.Region.Framework.Scenes // so that if the object is locked the client moving the object // get's it's position on the simulator even if it was the same as before // This keeps the moving user's client in sync with the rest of the world. - group.SendGroupTerseUpdate(); + SceneObjectPart movingPart = group.GetChildPart(objectID); + if (movingPart != null) + movingPart.SendUpdateToAllClients(PrimUpdateFlags.Position); } } @@ -1338,7 +1340,9 @@ namespace OpenSim.Region.Framework.Scenes // so that if the object is locked the client moving the object // get's it's position on the simulator even if it was the same as before // This keeps the moving user's client in sync with the rest of the world. - group.SendGroupTerseUpdate(); + SceneObjectPart rotatingPart = group.GetChildPart(objectID); + if (rotatingPart != null) + rotatingPart.SendUpdateToAllClients(PrimUpdateFlags.Rotation); } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index bd2ce500a7..e2bc94834c 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1488,17 +1488,17 @@ namespace OpenSim.Region.Framework.Scenes #endregion - public void SendFullUpdateToClient(IClientAPI remoteClient) + public void SendUpdateToClient(IClientAPI remoteClient, PrimUpdateFlags updateFlags) { - RootPart.SendFullUpdateToClient( - remoteClient, m_scene.Permissions.GenerateClientFlags(remoteClient.AgentId, RootPart.UUID), PrimUpdateFlags.FullUpdate); + RootPart.SendUpdateToClient( + remoteClient, m_scene.Permissions.GenerateClientFlags(remoteClient.AgentId, RootPart.UUID), updateFlags); lock (m_parts) { foreach (SceneObjectPart part in m_parts.Values) { if (part != RootPart) - part.SendFullUpdateToClient(remoteClient, m_scene.Permissions.GenerateClientFlags(remoteClient.AgentId, part.UUID), PrimUpdateFlags.FullUpdate); + part.SendUpdateToClient(remoteClient, m_scene.Permissions.GenerateClientFlags(remoteClient.AgentId, part.UUID), updateFlags); } } } @@ -2035,32 +2035,18 @@ namespace OpenSim.Region.Framework.Scenes // m_log.DebugFormat("[SOG]: Sending immediate full group update for {0} {1}", Name, UUID); - RootPart.SendFullUpdateToAllClients(); + RootPart.SendUpdateToAllClients(PrimUpdateFlags.FullUpdate); lock (m_parts) { foreach (SceneObjectPart part in m_parts.Values) { if (part != RootPart) - part.SendFullUpdateToAllClients(); + part.SendUpdateToAllClients(PrimUpdateFlags.FullUpdate); } } } - /// - /// Immediately send an update for this scene object's root prim only. - /// This is for updates regarding the object as a whole, and none of its parts in particular. - /// Note: this may not be used by opensim (it probably should) but it's used by - /// external modules. - /// - public void SendGroupRootTerseUpdate() - { - if (IsDeleted) - return; - - RootPart.SendTerseUpdateToAllClients(); - } - public void QueueForUpdateCheck() { if (m_scene == null) // Need to check here as it's null during object creation @@ -2069,23 +2055,6 @@ namespace OpenSim.Region.Framework.Scenes m_scene.SceneGraph.AddToUpdateList(this); } - /// - /// Immediately send a terse update for this scene object. - /// - public void SendGroupTerseUpdate() - { - if (IsDeleted) - return; - - lock (m_parts) - { - foreach (SceneObjectPart part in m_parts.Values) - { - part.SendTerseUpdateToAllClients(); - } - } - } - #endregion #region SceneGroupPart Methods @@ -2491,7 +2460,7 @@ namespace OpenSim.Region.Framework.Scenes public void NonPhysicalGrabMovement(Vector3 pos) { AbsolutePosition = pos; - m_rootPart.SendTerseUpdateToAllClients(); + m_rootPart.SendUpdateToAllClients(PrimUpdateFlags.Position); } /// diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index cea5348859..3ae364948f 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2851,11 +2851,11 @@ namespace OpenSim.Region.Framework.Scenes /// /// Send a full update for this part to all clients. /// - public void SendFullUpdateToAllClients() + public void SendUpdateToAllClients(PrimUpdateFlags updateFlags) { m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar) { - SendFullUpdateToClient(avatar.ControllingClient, avatar.GenerateClientFlags(UUID), PrimUpdateFlags.FullUpdate); + SendUpdateToClient(avatar.ControllingClient, avatar.GenerateClientFlags(UUID), updateFlags); }); } @@ -2863,13 +2863,13 @@ namespace OpenSim.Region.Framework.Scenes /// Send a full update to all clients except the one nominated. /// /// - public void SendFullUpdateToAllClientsExcept(UUID agentID) + public void SendUpdateToAllClientsExcept(PrimUpdateFlags updateFlags, UUID agentID) { m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar) { // Ugly reference :( if (avatar.UUID != agentID) - SendFullUpdateToClient(avatar.ControllingClient, avatar.GenerateClientFlags(UUID), PrimUpdateFlags.FullUpdate); + SendUpdateToClient(avatar.ControllingClient, avatar.GenerateClientFlags(UUID), updateFlags); }); } @@ -2879,57 +2879,17 @@ namespace OpenSim.Region.Framework.Scenes /// /// /// - public void SendFullUpdateToClient(IClientAPI remoteClient, uint clientFlags, PrimUpdateFlags updateFlags) - { - // Suppress full updates during attachment editing - // - if (ParentGroup.IsSelected && IsAttachment) - return; - - if (ParentGroup.IsDeleted) - return; - - clientFlags &= ~(uint) PrimFlags.CreateSelected; - - if (remoteClient.AgentId == _ownerID) - { - if ((uint) (_flags & PrimFlags.CreateSelected) != 0) - { - clientFlags |= (uint) PrimFlags.CreateSelected; - _flags &= ~PrimFlags.CreateSelected; - } - } - //bool isattachment = IsAttachment; - //if (LocalId != ParentGroup.RootPart.LocalId) - //isattachment = ParentGroup.RootPart.IsAttachment; - - remoteClient.SendEntityUpdate(ParentGroup.GetUpdatePriority(remoteClient), this, updateFlags); - } - - public void SendTerseUpdateToClient(IClientAPI remoteClient) + public void SendUpdateToClient(IClientAPI remoteClient, uint clientFlags, PrimUpdateFlags updateFlags) { + // Sanity check if (ParentGroup == null || ParentGroup.IsDeleted) return; - Vector3 lPos = OffsetPosition; + // Suppress full updates during attachment editing + if (ParentGroup.IsSelected && IsAttachment && updateFlags == PrimUpdateFlags.FullUpdate) + return; - if (IsAttachment) - { - if (ParentGroup.RootPart != this) - return; - - lPos = ParentGroup.RootPart.AttachedPos; - } - else - { - if (ParentGroup.RootPart == this) - lPos = AbsolutePosition; - } - - // Causes this thread to dig into the Client Thread Data. - // Remember your locking here! - remoteClient.SendEntityUpdate(ParentGroup.GetUpdatePriority(remoteClient), this, PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | - PrimUpdateFlags.Velocity | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity); + remoteClient.SendEntityUpdate(ParentGroup.GetUpdatePriority(remoteClient), this, updateFlags); } /// @@ -3075,17 +3035,6 @@ namespace OpenSim.Region.Framework.Scenes } } - /// - /// Send a terse update to all clients - /// - public void SendTerseUpdateToAllClients() - { - m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar) - { - SendTerseUpdateToClient(avatar.ControllingClient); - }); - } - public void SetAttachmentPoint(uint AttachmentPoint) { this.AttachmentPoint = AttachmentPoint; @@ -4111,10 +4060,9 @@ namespace OpenSim.Region.Framework.Scenes baseMask; break; } - SendFullUpdateToAllClients(); + SendUpdateToAllClients(PrimUpdateFlags.PrimFlags); SendObjectPropertiesToClient(AgentID); - } } diff --git a/OpenSim/Region/Framework/Scenes/SceneViewer.cs b/OpenSim/Region/Framework/Scenes/SceneViewer.cs index 898d1c32fd..c9df174d1a 100644 --- a/OpenSim/Region/Framework/Scenes/SceneViewer.cs +++ b/OpenSim/Region/Framework/Scenes/SceneViewer.cs @@ -118,7 +118,7 @@ namespace OpenSim.Region.Framework.Scenes // "[SCENE PRESENCE]: Fully updating prim {0}, {1} - part timestamp {2}", // part.Name, part.UUID, part.TimeStampFull); - part.SendFullUpdateToClient(m_presence.ControllingClient, + part.SendUpdateToClient(m_presence.ControllingClient, m_presence.GenerateClientFlags(part.UUID), PrimUpdateFlags.FullUpdate); // We'll update to the part's timestamp rather than @@ -137,7 +137,8 @@ namespace OpenSim.Region.Framework.Scenes // "[SCENE PRESENCE]: Tersely updating prim {0}, {1} - part timestamp {2}", // part.Name, part.UUID, part.TimeStampTerse); - part.SendTerseUpdateToClient(m_presence.ControllingClient); + part.SendUpdateToClient(m_presence.ControllingClient, m_presence.GenerateClientFlags(part.UUID), PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | + PrimUpdateFlags.Velocity | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity); update.LastTerseUpdateTime = part.TimeStampTerse; } @@ -157,11 +158,11 @@ namespace OpenSim.Region.Framework.Scenes if (part != part.ParentGroup.RootPart) continue; - part.ParentGroup.SendFullUpdateToClient(m_presence.ControllingClient); + part.ParentGroup.SendUpdateToClient(m_presence.ControllingClient, PrimUpdateFlags.FullUpdate); continue; } - part.SendFullUpdateToClient(m_presence.ControllingClient, m_presence.GenerateClientFlags(part.UUID), PrimUpdateFlags.FullUpdate); + part.SendUpdateToClient(m_presence.ControllingClient, m_presence.GenerateClientFlags(part.UUID), PrimUpdateFlags.FullUpdate); } } } diff --git a/OpenSim/Region/OptionalModules/ContentManagementSystem/MetaEntity.cs b/OpenSim/Region/OptionalModules/ContentManagementSystem/MetaEntity.cs index 1a72971b56..65dcb9d4bb 100644 --- a/OpenSim/Region/OptionalModules/ContentManagementSystem/MetaEntity.cs +++ b/OpenSim/Region/OptionalModules/ContentManagementSystem/MetaEntity.cs @@ -193,20 +193,14 @@ namespace OpenSim.Region.OptionalModules.ContentManagement public void SendFullUpdate(IClientAPI client) { - // Not sure what clientFlags should be but 0 seems to work - SendFullUpdate(client, 0); - } - - public void SendFullUpdate(IClientAPI client, uint clientFlags) - { - m_Entity.SendFullUpdateToClient(client); + m_Entity.SendUpdateToClient(client, PrimUpdateFlags.FullUpdate); } public void SendFullUpdateToAll() { m_Entity.Scene.ForEachClient( - delegate(IClientAPI controller) - { m_Entity.SendFullUpdateToClient(controller); } + delegate(IClientAPI client) + { m_Entity.SendUpdateToClient(client, PrimUpdateFlags.FullUpdate); } ); } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 3ccbb3abc6..839255e17c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -1329,7 +1329,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api tmp.Y = (float)scale.y; tmp.Z = (float)scale.z; part.Scale = tmp; - part.SendFullUpdateToAllClients(); + part.SendUpdateToAllClients(PrimUpdateFlags.Scale); } public LSL_Vector llGetScale() @@ -2246,7 +2246,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.SoundRadius = 20; // Magic number, 20 seems reasonable. Make configurable? m_host.ScheduleFullUpdate(); - m_host.SendFullUpdateToAllClients(); + m_host.SendUpdateToAllClients(PrimUpdateFlags.Sound); } public void llLoopSoundMaster(string sound, double volume) @@ -2266,7 +2266,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api prim.SoundRadius = 20; // Magic number, 20 seems reasonable. Make configurable? prim.ScheduleFullUpdate(); - prim.SendFullUpdateToAllClients(); + prim.SendUpdateToAllClients(PrimUpdateFlags.Sound); } } if (m_host.Sound != UUID.Zero) @@ -2278,7 +2278,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.SoundRadius = 20; // Magic number, 20 seems reasonable. Make configurable? m_host.ScheduleFullUpdate(); - m_host.SendFullUpdateToAllClients(); + m_host.SendUpdateToAllClients(PrimUpdateFlags.Sound); } public void llLoopSoundSlave(string sound, double volume) @@ -2320,7 +2320,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api part.SoundFlags = 0; part.SoundRadius = 0; part.ScheduleFullUpdate(); - part.SendFullUpdateToAllClients(); + part.SendUpdateToAllClients(PrimUpdateFlags.Sound); } m_host.ParentGroup.LoopSoundMasterPrim = null; m_host.ParentGroup.LoopSoundSlavePrims.Clear(); @@ -2332,7 +2332,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.SoundFlags = 0; m_host.SoundRadius = 0; m_host.ScheduleFullUpdate(); - m_host.SendFullUpdateToAllClients(); + m_host.SendUpdateToAllClients(PrimUpdateFlags.Sound); } } else @@ -2342,7 +2342,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.SoundFlags = 0; m_host.SoundRadius = 0; m_host.ScheduleFullUpdate(); - m_host.SendFullUpdateToAllClients(); + m_host.SendUpdateToAllClients(PrimUpdateFlags.Sound); } } @@ -3241,7 +3241,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); m_host.AngularVelocity = new Vector3((float)(axis.x * spinrate), (float)(axis.y * spinrate), (float)(axis.z * spinrate)); m_host.ScheduleTerseUpdate(); - m_host.SendTerseUpdateToAllClients(); + m_host.SendUpdateToAllClients(PrimUpdateFlags.AngularVelocity); m_host.ParentGroup.HasGroupChanged = true; } @@ -5467,7 +5467,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api pTexAnim.Start = (float)start; part.AddTextureAnimation(pTexAnim); - part.SendFullUpdateToAllClients(); + part.SendUpdateToAllClients(PrimUpdateFlags.TextureAnim); part.ParentGroup.HasGroupChanged = true; } @@ -6029,7 +6029,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api part.AddNewParticleSystem(prules); part.ParentGroup.HasGroupChanged = true; } - part.SendFullUpdateToAllClients(); + part.SendUpdateToAllClients(PrimUpdateFlags.Particles); } public void llGroundRepel(double height, int water, double tau)