diff options
Diffstat (limited to 'OpenSim/Region/Framework')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 320 |
1 files changed, 146 insertions, 174 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 7eda10e..c46a5ad 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -1268,79 +1268,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1268 | 1268 | ||
1269 | m_scene.SwapRootAgentCount(false); | 1269 | m_scene.SwapRootAgentCount(false); |
1270 | 1270 | ||
1271 | // The initial login scene presence is already root when it gets here | ||
1272 | // and it has already rezzed the attachments and started their scripts. | ||
1273 | // We do the following only for non-login agents, because their scripts | ||
1274 | // haven't started yet. | ||
1275 | /* moved down | ||
1276 | if (PresenceType == PresenceType.Npc || (TeleportFlags & TeleportFlags.ViaLogin) != 0) | ||
1277 | { | ||
1278 | // Viewers which have a current outfit folder will actually rez their own attachments. However, | ||
1279 | // viewers without (e.g. v1 viewers) will not, so we still need to make this call. | ||
1280 | if (Scene.AttachmentsModule != null) | ||
1281 | Util.FireAndForget( | ||
1282 | o => | ||
1283 | { | ||
1284 | // if (PresenceType != PresenceType.Npc && Util.FireAndForgetMethod != FireAndForgetMethod.None) | ||
1285 | // System.Threading.Thread.Sleep(7000); | ||
1286 | |||
1287 | Scene.AttachmentsModule.RezAttachments(this); | ||
1288 | }); | ||
1289 | } | ||
1290 | else | ||
1291 | |||
1292 | { | ||
1293 | // We need to restart scripts here so that they receive the correct changed events (CHANGED_TELEPORT | ||
1294 | // and CHANGED_REGION) when the attachments have been rezzed in the new region. This cannot currently | ||
1295 | // be done in AttachmentsModule.CopyAttachments(AgentData ad, IScenePresence sp) itself since we are | ||
1296 | // not transporting the required data. | ||
1297 | // | ||
1298 | // We need to restart scripts here so that they receive the correct changed events (CHANGED_TELEPORT | ||
1299 | // and CHANGED_REGION) when the attachments have been rezzed in the new region. This cannot currently | ||
1300 | // be done in AttachmentsModule.CopyAttachments(AgentData ad, IScenePresence sp) itself since we are | ||
1301 | // not transporting the required data. | ||
1302 | // | ||
1303 | // We must take a copy of the attachments list here (rather than locking) to avoid a deadlock where a script in one of | ||
1304 | // the attachments may start processing an event (which locks ScriptInstance.m_Script) that then calls a method here | ||
1305 | // which needs to lock m_attachments. ResumeScripts() needs to take a ScriptInstance.m_Script lock to try to unset the Suspend status. | ||
1306 | // | ||
1307 | // FIXME: In theory, this deadlock should not arise since scripts should not be processing events until ResumeScripts(). | ||
1308 | // But XEngine starts all scripts unsuspended. Starting them suspended will not currently work because script rezzing | ||
1309 | // is placed in an asynchronous queue in XEngine and so the ResumeScripts() call will almost certainly execute before the | ||
1310 | // script is rezzed. This means the ResumeScripts() does absolutely nothing when using XEngine. | ||
1311 | // | ||
1312 | // One cannot simply iterate over attachments in a fire and forget thread because this would no longer | ||
1313 | // be locked, allowing race conditions if other code changes the attachments list. | ||
1314 | |||
1315 | List<SceneObjectGroup> attachments = GetAttachments(); | ||
1316 | |||
1317 | if (attachments.Count > 0) | ||
1318 | { | ||
1319 | m_log.DebugFormat( | ||
1320 | "[SCENE PRESENCE]: Restarting scripts in attachments for {0} in {1}", Name, Scene.Name); | ||
1321 | |||
1322 | // Resume scripts this possible should also be moved down after sending the avatar to viewer ? | ||
1323 | foreach (SceneObjectGroup sog in attachments) | ||
1324 | { | ||
1325 | // sending attachments before the avatar ? | ||
1326 | // moved to completemovement where it already was | ||
1327 | // sog.ScheduleGroupForFullUpdate(); | ||
1328 | sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); | ||
1329 | sog.ResumeScripts(); | ||
1330 | } | ||
1331 | } | ||
1332 | } | ||
1333 | */ | ||
1334 | /* | ||
1335 | SendAvatarDataToAllAgents(); | ||
1336 | |||
1337 | // send the animations of the other presences to me | ||
1338 | m_scene.ForEachRootScenePresence(delegate(ScenePresence presence) | ||
1339 | { | ||
1340 | if (presence != this) | ||
1341 | presence.Animator.SendAnimPackToClient(ControllingClient); | ||
1342 | }); | ||
1343 | */ | ||
1344 | 1271 | ||
1345 | // If we don't reset the movement flag here, an avatar that crosses to a neighbouring sim and returns will | 1272 | // If we don't reset the movement flag here, an avatar that crosses to a neighbouring sim and returns will |
1346 | // stall on the border crossing since the existing child agent will still have the last movement | 1273 | // stall on the border crossing since the existing child agent will still have the last movement |
@@ -4132,19 +4059,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4132 | cAgent.Far = DrawDistance; | 4059 | cAgent.Far = DrawDistance; |
4133 | 4060 | ||
4134 | // Throttles | 4061 | // Throttles |
4135 | float multiplier = 1; | 4062 | cAgent.Throttles = ControllingClient.GetThrottlesPacked(1); |
4136 | |||
4137 | /* this is also used to send to new main regions not children | ||
4138 | |||
4139 | int childRegions = KnownRegionCount; | ||
4140 | if (childRegions != 0) | ||
4141 | multiplier = 1f / childRegions; | ||
4142 | |||
4143 | // Minimum throttle for a child region is 1/4 of the root region throttle | ||
4144 | if (multiplier <= 0.25f) | ||
4145 | multiplier = 0.25f; | ||
4146 | */ | ||
4147 | cAgent.Throttles = ControllingClient.GetThrottlesPacked(multiplier); | ||
4148 | 4063 | ||
4149 | cAgent.HeadRotation = m_headrotation; | 4064 | cAgent.HeadRotation = m_headrotation; |
4150 | cAgent.BodyRotation = Rotation; | 4065 | cAgent.BodyRotation = Rotation; |
@@ -4756,118 +4671,167 @@ namespace OpenSim.Region.Framework.Scenes | |||
4756 | if (IsChildAgent) | 4671 | if (IsChildAgent) |
4757 | return; | 4672 | return; |
4758 | 4673 | ||
4759 | List<ScenePresence> allPresences = m_scene.GetScenePresences(); | 4674 | SceneObjectPart[] origparts = sog.Parts; |
4760 | foreach(ScenePresence p in allPresences) | 4675 | SceneObjectPart[] parts = new SceneObjectPart[origparts.Length]; |
4676 | PrimUpdateFlags[] flags = new PrimUpdateFlags[origparts.Length]; | ||
4677 | |||
4678 | SceneObjectPart rootpart = sog.RootPart; | ||
4679 | UpdateRequired rootreq = sog.RootPart.UpdateFlag; | ||
4680 | |||
4681 | int j = 0; | ||
4682 | bool allterse = true; | ||
4683 | |||
4684 | for (int i = 0; i < origparts.Length; i++) | ||
4761 | { | 4685 | { |
4762 | if (p != this) | 4686 | switch (origparts[i].UpdateFlag) |
4763 | { | 4687 | { |
4764 | if (sog.HasPrivateAttachmentPoint || | 4688 | case UpdateRequired.TERSE: |
4765 | (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200)) | 4689 | flags[j] = PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity |
4766 | return; | 4690 | | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity; |
4691 | parts[j] = origparts[i]; | ||
4692 | j++; | ||
4693 | break; | ||
4694 | |||
4695 | case UpdateRequired.FULL: | ||
4696 | flags[j] = PrimUpdateFlags.FullUpdate; | ||
4697 | parts[j] = origparts[i]; | ||
4698 | j++; | ||
4699 | allterse = false; | ||
4700 | break; | ||
4767 | } | 4701 | } |
4702 | origparts[i].UpdateFlag = 0; | ||
4703 | } | ||
4704 | |||
4705 | if (j == 0) | ||
4706 | return; | ||
4768 | 4707 | ||
4769 | SceneObjectPart[] parts = sog.Parts; | 4708 | if (rootreq == UpdateRequired.NONE) |
4709 | { | ||
4710 | if (allterse) | ||
4711 | rootreq = UpdateRequired.TERSE; | ||
4712 | else | ||
4713 | rootreq = UpdateRequired.FULL; | ||
4714 | } | ||
4770 | 4715 | ||
4771 | SendFullUpdateToClient(p.ControllingClient); | 4716 | PrimUpdateFlags rootflag = PrimUpdateFlags.FullUpdate; |
4717 | if (rootreq == UpdateRequired.TERSE) | ||
4718 | rootflag = PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity | ||
4719 | | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity; | ||
4772 | 4720 | ||
4773 | SceneObjectPart rootpart = sog.RootPart; | 4721 | int nparts = j; |
4774 | if (rootpart.UpdateFlag == UpdateRequired.TERSE) | 4722 | |
4775 | { | 4723 | bool priv = sog.HasPrivateAttachmentPoint; |
4776 | p.ControllingClient.SendEntityUpdate(rootpart, | 4724 | |
4777 | PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity | 4725 | List<ScenePresence> allPresences = m_scene.GetScenePresences(); |
4778 | | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity); | 4726 | foreach (ScenePresence p in allPresences) |
4779 | rootpart.UpdateFlag = 0; | 4727 | { |
4780 | } | 4728 | if (p != this) |
4781 | else if (rootpart.UpdateFlag == UpdateRequired.FULL) | ||
4782 | { | 4729 | { |
4783 | p.ControllingClient.SendEntityUpdate(rootpart, PrimUpdateFlags.FullUpdate); | 4730 | if (priv || |
4784 | rootpart.UpdateFlag = 0; | 4731 | (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200)) |
4732 | continue; | ||
4785 | } | 4733 | } |
4786 | 4734 | ||
4787 | for (int i = 0; i < parts.Length; i++) | 4735 | p.ControllingClient.SendEntityUpdate(rootpart, rootflag); |
4736 | |||
4737 | for (int i = 0; i < nparts; i++) | ||
4788 | { | 4738 | { |
4789 | SceneObjectPart part = parts[i]; | 4739 | SceneObjectPart part = parts[i]; |
4790 | if (part == rootpart) | 4740 | if (part == rootpart) |
4791 | continue; | 4741 | continue; |
4792 | if (part.UpdateFlag == UpdateRequired.TERSE) | 4742 | p.ControllingClient.SendEntityUpdate(part, flags[i]); |
4793 | { | ||
4794 | p.ControllingClient.SendEntityUpdate(part, | ||
4795 | PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity | ||
4796 | | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity); | ||
4797 | part.UpdateFlag = 0; | ||
4798 | } | ||
4799 | else if (part.UpdateFlag == UpdateRequired.FULL) | ||
4800 | { | ||
4801 | p.ControllingClient.SendEntityUpdate(part, PrimUpdateFlags.FullUpdate); | ||
4802 | part.UpdateFlag = 0; | ||
4803 | } | ||
4804 | } | 4743 | } |
4805 | } | 4744 | } |
4806 | } | 4745 | } |
4807 | 4746 | ||
4808 | public void SendAttachmentScheduleUpdate(SceneObjectPart part) | 4747 | public void SendAttachmentUpdate(SceneObjectGroup sog, UpdateRequired UpdateFlag) |
4809 | { | 4748 | { |
4810 | if (IsChildAgent) | 4749 | if (IsChildAgent) |
4811 | return; | 4750 | return; |
4812 | 4751 | ||
4813 | m_scene.ForEachScenePresence(delegate(ScenePresence p) | 4752 | PrimUpdateFlags flag; |
4753 | switch (UpdateFlag) | ||
4754 | { | ||
4755 | case UpdateRequired.TERSE: | ||
4756 | flag = PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity | ||
4757 | | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity; | ||
4758 | break; | ||
4759 | |||
4760 | case UpdateRequired.FULL: | ||
4761 | flag = PrimUpdateFlags.FullUpdate; | ||
4762 | break; | ||
4763 | |||
4764 | default: | ||
4765 | return; | ||
4766 | } | ||
4767 | |||
4768 | SceneObjectPart[] parts = sog.Parts; | ||
4769 | SceneObjectPart rootpart = sog.RootPart; | ||
4770 | |||
4771 | bool priv = sog.HasPrivateAttachmentPoint; | ||
4772 | |||
4773 | List<ScenePresence> allPresences = m_scene.GetScenePresences(); | ||
4774 | foreach (ScenePresence p in allPresences) | ||
4814 | { | 4775 | { |
4815 | if (p != this) | 4776 | if (p != this) |
4816 | { | 4777 | { |
4817 | 4778 | if (priv || | |
4818 | if (part.ParentGroup.HasPrivateAttachmentPoint || | ||
4819 | (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200)) | 4779 | (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200)) |
4820 | return; | 4780 | continue; |
4821 | } | 4781 | } |
4822 | 4782 | ||
4823 | if (part.UpdateFlag == UpdateRequired.TERSE) | 4783 | p.ControllingClient.SendEntityUpdate(rootpart, flag); |
4824 | { | 4784 | rootpart.UpdateFlag = 0; |
4825 | p.ControllingClient.SendEntityUpdate(part, | 4785 | |
4826 | PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity | 4786 | for (int i = 0; i < parts.Length; i++) |
4827 | | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity); | ||
4828 | part.UpdateFlag = 0; | ||
4829 | } | ||
4830 | else if (part.UpdateFlag == UpdateRequired.FULL) | ||
4831 | { | 4787 | { |
4832 | p.ControllingClient.SendEntityUpdate(part, PrimUpdateFlags.FullUpdate); | 4788 | SceneObjectPart part = parts[i]; |
4789 | if (part == rootpart) | ||
4790 | continue; | ||
4791 | p.ControllingClient.SendEntityUpdate(part, flag); | ||
4833 | part.UpdateFlag = 0; | 4792 | part.UpdateFlag = 0; |
4834 | } | 4793 | } |
4835 | }); | 4794 | } |
4836 | } | 4795 | } |
4837 | 4796 | ||
4838 | public void SendAttachmentUpdate(SceneObjectGroup sog, UpdateRequired UpdateFlag) | 4797 | public void SendAttachmentScheduleUpdate(SceneObjectPart part) |
4839 | { | 4798 | { |
4840 | if (IsChildAgent) | 4799 | if (IsChildAgent) |
4841 | return; | 4800 | return; |
4842 | 4801 | ||
4843 | m_scene.ForEachScenePresence(delegate(ScenePresence p) | 4802 | |
4803 | PrimUpdateFlags flag; | ||
4804 | switch (part.UpdateFlag) | ||
4844 | { | 4805 | { |
4845 | if (p != this) | 4806 | case UpdateRequired.TERSE: |
4846 | { | 4807 | flag = PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity |
4847 | if (sog.HasPrivateAttachmentPoint || | 4808 | | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity; |
4848 | (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200)) | 4809 | break; |
4810 | |||
4811 | case UpdateRequired.FULL: | ||
4812 | flag = PrimUpdateFlags.FullUpdate; | ||
4813 | break; | ||
4814 | |||
4815 | default: | ||
4849 | return; | 4816 | return; |
4850 | } | 4817 | } |
4851 | 4818 | ||
4852 | SceneObjectPart[] parts = sog.Parts; | 4819 | bool priv = part.ParentGroup.HasPrivateAttachmentPoint; |
4853 | 4820 | ||
4854 | for (int i = 0; i < parts.Length; i++) | 4821 | List<ScenePresence> allPresences = m_scene.GetScenePresences(); |
4822 | foreach (ScenePresence p in allPresences) | ||
4823 | { | ||
4824 | if (p != this) | ||
4855 | { | 4825 | { |
4856 | SceneObjectPart part = parts[i]; | 4826 | |
4857 | if (UpdateFlag == UpdateRequired.TERSE) | 4827 | if (priv || |
4858 | { | 4828 | (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200)) |
4859 | p.ControllingClient.SendEntityUpdate(part, | 4829 | continue; |
4860 | PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity | ||
4861 | | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity); | ||
4862 | part.UpdateFlag = 0; | ||
4863 | } | ||
4864 | else if (UpdateFlag == UpdateRequired.FULL) | ||
4865 | { | ||
4866 | p.ControllingClient.SendEntityUpdate(part, PrimUpdateFlags.FullUpdate); | ||
4867 | part.UpdateFlag = 0; | ||
4868 | } | ||
4869 | } | 4830 | } |
4870 | }); | 4831 | |
4832 | p.ControllingClient.SendEntityUpdate(part, flag); | ||
4833 | part.UpdateFlag = 0; | ||
4834 | } | ||
4871 | } | 4835 | } |
4872 | 4836 | ||
4873 | public void SendAttachmentUpdate(SceneObjectPart part, UpdateRequired UpdateFlag) | 4837 | public void SendAttachmentUpdate(SceneObjectPart part, UpdateRequired UpdateFlag) |
@@ -4875,29 +4839,37 @@ namespace OpenSim.Region.Framework.Scenes | |||
4875 | if (IsChildAgent) | 4839 | if (IsChildAgent) |
4876 | return; | 4840 | return; |
4877 | 4841 | ||
4878 | m_scene.ForEachScenePresence(delegate(ScenePresence p) | 4842 | PrimUpdateFlags flag; |
4843 | switch (UpdateFlag) | ||
4844 | { | ||
4845 | case UpdateRequired.TERSE: | ||
4846 | flag = PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity | ||
4847 | | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity; | ||
4848 | break; | ||
4849 | |||
4850 | case UpdateRequired.FULL: | ||
4851 | flag = PrimUpdateFlags.FullUpdate; | ||
4852 | break; | ||
4853 | |||
4854 | default: | ||
4855 | return; | ||
4856 | } | ||
4857 | |||
4858 | bool priv = part.ParentGroup.HasPrivateAttachmentPoint; | ||
4859 | |||
4860 | List<ScenePresence> allPresences = m_scene.GetScenePresences(); | ||
4861 | foreach (ScenePresence p in allPresences) | ||
4879 | { | 4862 | { |
4880 | if (p != this) | 4863 | if (p != this) |
4881 | { | 4864 | { |
4882 | 4865 | if ( priv || | |
4883 | if (part.ParentGroup.HasPrivateAttachmentPoint || | ||
4884 | (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200)) | 4866 | (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200)) |
4885 | return; | 4867 | continue; |
4886 | } | 4868 | } |
4887 | 4869 | ||
4888 | if (UpdateFlag == UpdateRequired.TERSE) | 4870 | p.ControllingClient.SendEntityUpdate(part, flag); |
4889 | { | 4871 | part.UpdateFlag = 0; |
4890 | p.ControllingClient.SendEntityUpdate(part, | 4872 | } |
4891 | PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity | ||
4892 | | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity); | ||
4893 | part.UpdateFlag = 0; | ||
4894 | } | ||
4895 | else if (UpdateFlag == UpdateRequired.FULL) | ||
4896 | { | ||
4897 | p.ControllingClient.SendEntityUpdate(part, PrimUpdateFlags.FullUpdate); | ||
4898 | part.UpdateFlag = 0; | ||
4899 | } | ||
4900 | }); | ||
4901 | } | 4873 | } |
4902 | 4874 | ||
4903 | /// <summary> | 4875 | /// <summary> |