aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/ScenePresence.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs180
1 files changed, 25 insertions, 155 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index cdd1a85..1bee3c0 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -74,6 +74,9 @@ namespace OpenSim.Region.Framework.Scenes
74 public static byte[] DefaultTexture; 74 public static byte[] DefaultTexture;
75 75
76 public UUID currentParcelUUID = UUID.Zero; 76 public UUID currentParcelUUID = UUID.Zero;
77
78 private ISceneViewer m_sceneViewer;
79
77 private AnimationSet m_animations = new AnimationSet(); 80 private AnimationSet m_animations = new AnimationSet();
78 private Dictionary<UUID, ScriptControllers> scriptedcontrols = new Dictionary<UUID, ScriptControllers>(); 81 private Dictionary<UUID, ScriptControllers> scriptedcontrols = new Dictionary<UUID, ScriptControllers>();
79 private ScriptControlled IgnoredControls = ScriptControlled.CONTROL_ZERO; 82 private ScriptControlled IgnoredControls = ScriptControlled.CONTROL_ZERO;
@@ -222,11 +225,6 @@ namespace OpenSim.Region.Framework.Scenes
222 /// </summary> 225 /// </summary>
223 private Vector3 posLastSignificantMove; 226 private Vector3 posLastSignificantMove;
224 227
225 private UpdateQueue m_partsUpdateQueue = new UpdateQueue();
226 private Queue<SceneObjectGroup> m_pendingObjects;
227
228 private Dictionary<UUID, ScenePartUpdate> m_updateTimes = new Dictionary<UUID, ScenePartUpdate>();
229
230 // For teleports and crossings callbacks 228 // For teleports and crossings callbacks
231 string m_callbackURI; 229 string m_callbackURI;
232 ulong m_rootRegionHandle; 230 ulong m_rootRegionHandle;
@@ -396,8 +394,8 @@ namespace OpenSim.Region.Framework.Scenes
396 394
397 public int MaxPrimsPerFrame 395 public int MaxPrimsPerFrame
398 { 396 {
399 get { return m_maxPrimsPerFrame; } 397 get { return m_sceneViewer.MaxPrimsPerFrame; }
400 set { m_maxPrimsPerFrame = value; } 398 set { m_sceneViewer.MaxPrimsPerFrame = value; }
401 } 399 }
402 400
403 /// <summary> 401 /// <summary>
@@ -527,6 +525,11 @@ namespace OpenSim.Region.Framework.Scenes
527 } 525 }
528 } 526 }
529 527
528 public ISceneViewer SceneViewer
529 {
530 get { return m_sceneViewer; }
531 }
532
530 public void AdjustKnownSeeds() 533 public void AdjustKnownSeeds()
531 { 534 {
532 Dictionary<ulong, string> seeds = Scene.CapsModule.GetChildrenSeeds(UUID); 535 Dictionary<ulong, string> seeds = Scene.CapsModule.GetChildrenSeeds(UUID);
@@ -601,7 +604,7 @@ namespace OpenSim.Region.Framework.Scenes
601 604
602 private ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo) 605 private ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo)
603 { 606 {
604 607 CreateSceneViewer();
605 m_regionHandle = reginfo.RegionHandle; 608 m_regionHandle = reginfo.RegionHandle;
606 m_controllingClient = client; 609 m_controllingClient = client;
607 m_firstname = m_controllingClient.FirstName; 610 m_firstname = m_controllingClient.FirstName;
@@ -643,15 +646,22 @@ namespace OpenSim.Region.Framework.Scenes
643 AvatarWearable[] wearables) 646 AvatarWearable[] wearables)
644 : this(client, world, reginfo) 647 : this(client, world, reginfo)
645 { 648 {
649 CreateSceneViewer();
646 m_appearance = new AvatarAppearance(m_uuid, wearables, visualParams); 650 m_appearance = new AvatarAppearance(m_uuid, wearables, visualParams);
647 } 651 }
648 652
649 public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, AvatarAppearance appearance) 653 public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, AvatarAppearance appearance)
650 : this(client, world, reginfo) 654 : this(client, world, reginfo)
651 { 655 {
656 CreateSceneViewer();
652 m_appearance = appearance; 657 m_appearance = appearance;
653 } 658 }
654 659
660 private void CreateSceneViewer()
661 {
662 m_sceneViewer = new SceneViewer(this);
663 }
664
655 public void RegisterToEvents() 665 public void RegisterToEvents()
656 { 666 {
657 m_controllingClient.OnRequestWearables += SendWearables; 667 m_controllingClient.OnRequestWearables += SendWearables;
@@ -704,13 +714,7 @@ namespace OpenSim.Region.Framework.Scenes
704 /// <param name="part"></param> 714 /// <param name="part"></param>
705 public void QueuePartForUpdate(SceneObjectPart part) 715 public void QueuePartForUpdate(SceneObjectPart part)
706 { 716 {
707 //if (InterestList.Contains(part.ParentGroup)) 717 m_sceneViewer.QueuePartForUpdate(part);
708 //{
709 lock (m_partsUpdateQueue)
710 {
711 m_partsUpdateQueue.Enqueue(part);
712 }
713 // }
714 } 718 }
715 719
716 public uint GenerateClientFlags(UUID ObjectID) 720 public uint GenerateClientFlags(UUID ObjectID)
@@ -725,122 +729,9 @@ namespace OpenSim.Region.Framework.Scenes
725 /// </summary> 729 /// </summary>
726 public void SendPrimUpdates() 730 public void SendPrimUpdates()
727 { 731 {
728 // if (m_scene.QuadTree.GetNodeID(this.AbsolutePosition.X, this.AbsolutePosition.Y) != m_currentQuadNode)
729 //{
730 // this.UpdateQuadTreeNode();
731 //this.RefreshQuadObject();
732 //}
733 m_perfMonMS = Environment.TickCount; 732 m_perfMonMS = Environment.TickCount;
734 733
735 if (m_pendingObjects == null) 734 m_sceneViewer.SendPrimUpdates();
736 {
737 if (!m_isChildAgent || m_scene.m_seeIntoRegionFromNeighbor)
738 {
739 m_pendingObjects = new Queue<SceneObjectGroup>();
740
741 List<EntityBase> ents = new List<EntityBase>(m_scene.Entities);
742 if (!m_isChildAgent) // Proximity sort makes no sense for
743 { // Child agents
744 ents.Sort(delegate(EntityBase a, EntityBase b)
745 {
746 return Vector3.Distance(AbsolutePosition, a.AbsolutePosition).CompareTo(Vector3.Distance(AbsolutePosition, b.AbsolutePosition));
747 });
748 }
749
750 foreach (EntityBase e in ents)
751 {
752 if (e is SceneObjectGroup)
753 m_pendingObjects.Enqueue((SceneObjectGroup)e);
754 }
755 }
756 }
757
758 while (m_pendingObjects != null && m_pendingObjects.Count > 0 && m_partsUpdateQueue.Count < m_maxPrimsPerFrame)
759 {
760 SceneObjectGroup g = m_pendingObjects.Dequeue();
761
762 // This is where we should check for draw distance
763 // do culling and stuff. Problem with that is that until
764 // we recheck in movement, that won't work right.
765 // So it's not implemented now.
766 //
767
768 // Don't even queue if we have sent this one
769 //
770 if (!m_updateTimes.ContainsKey(g.UUID))
771 g.ScheduleFullUpdateToAvatar(this);
772 }
773
774 while (m_partsUpdateQueue.Count > 0)
775 {
776 SceneObjectPart part = m_partsUpdateQueue.Dequeue();
777
778 if (part.ParentGroup == null || part.ParentGroup.IsDeleted)
779 continue;
780
781 if (m_updateTimes.ContainsKey(part.UUID))
782 {
783 ScenePartUpdate update = m_updateTimes[part.UUID];
784
785 // We deal with the possibility that two updates occur at
786 // the same unix time at the update point itself.
787
788 if ((update.LastFullUpdateTime < part.TimeStampFull) ||
789 part.IsAttachment)
790 {
791// m_log.DebugFormat(
792// "[SCENE PRESENCE]: Fully updating prim {0}, {1} - part timestamp {2}",
793// part.Name, part.UUID, part.TimeStampFull);
794
795 part.SendFullUpdate(ControllingClient,
796 GenerateClientFlags(part.UUID));
797
798 // We'll update to the part's timestamp rather than
799 // the current time to avoid the race condition
800 // whereby the next tick occurs while we are doing
801 // this update. If this happened, then subsequent
802 // updates which occurred on the same tick or the
803 // next tick of the last update would be ignored.
804
805 update.LastFullUpdateTime = part.TimeStampFull;
806
807 }
808 else if (update.LastTerseUpdateTime <= part.TimeStampTerse)
809 {
810// m_log.DebugFormat(
811// "[SCENE PRESENCE]: Tersely updating prim {0}, {1} - part timestamp {2}",
812// part.Name, part.UUID, part.TimeStampTerse);
813
814 part.SendTerseUpdateToClient(ControllingClient);
815
816 update.LastTerseUpdateTime = part.TimeStampTerse;
817 }
818 }
819 else
820 {
821 //never been sent to client before so do full update
822 ScenePartUpdate update = new ScenePartUpdate();
823 update.FullID = part.UUID;
824 update.LastFullUpdateTime = part.TimeStampFull;
825 m_updateTimes.Add(part.UUID, update);
826
827 // Attachment handling
828 //
829 if (part.ParentGroup.RootPart.Shape.PCode == 9 && part.ParentGroup.RootPart.Shape.State != 0)
830 {
831 if (part != part.ParentGroup.RootPart)
832 continue;
833
834 part.ParentGroup.SendFullUpdateToClient(ControllingClient);
835 continue;
836 }
837
838 part.SendFullUpdate(ControllingClient,
839 GenerateClientFlags(part.UUID));
840 }
841 }
842
843 ControllingClient.FlushPrimUpdates();
844 735
845 m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); 736 m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS);
846 } 737 }
@@ -935,7 +826,7 @@ namespace OpenSim.Region.Framework.Scenes
935 826
936 // On the next prim update, all objects will be sent 827 // On the next prim update, all objects will be sent
937 // 828 //
938 m_pendingObjects = null; 829 m_sceneViewer.Reset();
939 830
940 m_isChildAgent = false; 831 m_isChildAgent = false;
941 832
@@ -3062,7 +2953,7 @@ namespace OpenSim.Region.Framework.Scenes
3062 2953
3063 // Sends out the objects in the user's draw distance if m_sendTasksToChild is true. 2954 // Sends out the objects in the user's draw distance if m_sendTasksToChild is true.
3064 if (m_scene.m_seeIntoRegionFromNeighbor) 2955 if (m_scene.m_seeIntoRegionFromNeighbor)
3065 m_pendingObjects = null; 2956 m_sceneViewer.Reset();
3066 2957
3067 //cAgentData.AVHeight; 2958 //cAgentData.AVHeight;
3068 //cAgentData.regionHandle; 2959 //cAgentData.regionHandle;
@@ -3269,7 +3160,6 @@ namespace OpenSim.Region.Framework.Scenes
3269 { 3160 {
3270 Primitive.TextureEntry textu = AvatarAppearance.GetDefaultTexture(); 3161 Primitive.TextureEntry textu = AvatarAppearance.GetDefaultTexture();
3271 DefaultTexture = textu.GetBytes(); 3162 DefaultTexture = textu.GetBytes();
3272
3273 } 3163 }
3274 3164
3275 public class NewForce 3165 public class NewForce
@@ -3279,20 +3169,6 @@ namespace OpenSim.Region.Framework.Scenes
3279 public float Z; 3169 public float Z;
3280 } 3170 }
3281 3171
3282 public class ScenePartUpdate
3283 {
3284 public UUID FullID;
3285 public uint LastFullUpdateTime;
3286 public uint LastTerseUpdateTime;
3287
3288 public ScenePartUpdate()
3289 {
3290 FullID = UUID.Zero;
3291 LastFullUpdateTime = 0;
3292 LastTerseUpdateTime = 0;
3293 }
3294 }
3295
3296 public override void SetText(string text, Vector3 color, double alpha) 3172 public override void SetText(string text, Vector3 color, double alpha)
3297 { 3173 {
3298 throw new Exception("Can't set Text on avatar."); 3174 throw new Exception("Can't set Text on avatar.");
@@ -3394,14 +3270,7 @@ namespace OpenSim.Region.Framework.Scenes
3394 { 3270 {
3395 m_knownChildRegions.Clear(); 3271 m_knownChildRegions.Clear();
3396 } 3272 }
3397 lock (m_updateTimes) 3273 m_sceneViewer.Close();
3398 {
3399 m_updateTimes.Clear();
3400 }
3401 lock (m_partsUpdateQueue)
3402 {
3403 m_partsUpdateQueue.Clear();
3404 }
3405 3274
3406 RemoveFromPhysicalScene(); 3275 RemoveFromPhysicalScene();
3407 GC.Collect(); 3276 GC.Collect();
@@ -3413,7 +3282,8 @@ namespace OpenSim.Region.Framework.Scenes
3413 { 3282 {
3414 Primitive.TextureEntry textu = AvatarAppearance.GetDefaultTexture(); 3283 Primitive.TextureEntry textu = AvatarAppearance.GetDefaultTexture();
3415 DefaultTexture = textu.GetBytes(); 3284 DefaultTexture = textu.GetBytes();
3416 } 3285 }
3286 CreateSceneViewer();
3417 } 3287 }
3418 3288
3419 public void AddAttachment(SceneObjectGroup gobj) 3289 public void AddAttachment(SceneObjectGroup gobj)