Extracted the code that handles the sending of prim updates to the client, from ScenePresence into ISceneViewer/SceneViewer. Currently ScenePresence "has" a ISceneViewer, although if we had a proper Node based scenegraph then it would most likely be attached directly to the nodes.
By extracting this code, it should make it easier to experiment with different ways of managing the update process. [Next step to make this module based, could be to create a SceneViewerFactoryModule]0.6.6-post-fixes
parent
febd54499b
commit
7a2c41dea0
|
@ -0,0 +1,14 @@
|
||||||
|
using System;
|
||||||
|
using OpenSim.Region.Framework.Scenes;
|
||||||
|
|
||||||
|
namespace OpenSim.Region.Framework.Interfaces
|
||||||
|
{
|
||||||
|
public interface ISceneViewer
|
||||||
|
{
|
||||||
|
void Reset();
|
||||||
|
void Close();
|
||||||
|
int MaxPrimsPerFrame { get; set; }
|
||||||
|
void QueuePartForUpdate(SceneObjectPart part);
|
||||||
|
void SendPrimUpdates();
|
||||||
|
}
|
||||||
|
}
|
|
@ -1145,13 +1145,13 @@ if (m_shape != null) {
|
||||||
List<ScenePresence> avatars = m_parentGroup.Scene.GetScenePresences();
|
List<ScenePresence> avatars = m_parentGroup.Scene.GetScenePresences();
|
||||||
for (int i = 0; i < avatars.Count; i++)
|
for (int i = 0; i < avatars.Count; i++)
|
||||||
{
|
{
|
||||||
avatars[i].QueuePartForUpdate(this);
|
avatars[i].SceneViewer.QueuePartForUpdate(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddFullUpdateToAvatar(ScenePresence presence)
|
public void AddFullUpdateToAvatar(ScenePresence presence)
|
||||||
{
|
{
|
||||||
presence.QueuePartForUpdate(this);
|
presence.SceneViewer.QueuePartForUpdate(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddNewParticleSystem(Primitive.ParticleSystem pSystem)
|
public void AddNewParticleSystem(Primitive.ParticleSystem pSystem)
|
||||||
|
@ -1170,13 +1170,13 @@ if (m_shape != null) {
|
||||||
List<ScenePresence> avatars = m_parentGroup.Scene.GetScenePresences();
|
List<ScenePresence> avatars = m_parentGroup.Scene.GetScenePresences();
|
||||||
for (int i = 0; i < avatars.Count; i++)
|
for (int i = 0; i < avatars.Count; i++)
|
||||||
{
|
{
|
||||||
avatars[i].QueuePartForUpdate(this);
|
avatars[i].SceneViewer.QueuePartForUpdate(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddTerseUpdateToAvatar(ScenePresence presence)
|
public void AddTerseUpdateToAvatar(ScenePresence presence)
|
||||||
{
|
{
|
||||||
presence.QueuePartForUpdate(this);
|
presence.SceneViewer.QueuePartForUpdate(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddTextureAnimation(Primitive.TextureAnimation pTexAnim)
|
public void AddTextureAnimation(Primitive.TextureAnimation pTexAnim)
|
||||||
|
|
|
@ -74,6 +74,9 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
public static byte[] DefaultTexture;
|
public static byte[] DefaultTexture;
|
||||||
|
|
||||||
public UUID currentParcelUUID = UUID.Zero;
|
public UUID currentParcelUUID = UUID.Zero;
|
||||||
|
|
||||||
|
private ISceneViewer m_sceneViewer;
|
||||||
|
|
||||||
private AnimationSet m_animations = new AnimationSet();
|
private AnimationSet m_animations = new AnimationSet();
|
||||||
private Dictionary<UUID, ScriptControllers> scriptedcontrols = new Dictionary<UUID, ScriptControllers>();
|
private Dictionary<UUID, ScriptControllers> scriptedcontrols = new Dictionary<UUID, ScriptControllers>();
|
||||||
private ScriptControlled IgnoredControls = ScriptControlled.CONTROL_ZERO;
|
private ScriptControlled IgnoredControls = ScriptControlled.CONTROL_ZERO;
|
||||||
|
@ -222,11 +225,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private Vector3 posLastSignificantMove;
|
private Vector3 posLastSignificantMove;
|
||||||
|
|
||||||
private UpdateQueue m_partsUpdateQueue = new UpdateQueue();
|
|
||||||
private Queue<SceneObjectGroup> m_pendingObjects;
|
|
||||||
|
|
||||||
private Dictionary<UUID, ScenePartUpdate> m_updateTimes = new Dictionary<UUID, ScenePartUpdate>();
|
|
||||||
|
|
||||||
// For teleports and crossings callbacks
|
// For teleports and crossings callbacks
|
||||||
string m_callbackURI;
|
string m_callbackURI;
|
||||||
ulong m_rootRegionHandle;
|
ulong m_rootRegionHandle;
|
||||||
|
@ -396,8 +394,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
public int MaxPrimsPerFrame
|
public int MaxPrimsPerFrame
|
||||||
{
|
{
|
||||||
get { return m_maxPrimsPerFrame; }
|
get { return m_sceneViewer.MaxPrimsPerFrame; }
|
||||||
set { m_maxPrimsPerFrame = value; }
|
set { m_sceneViewer.MaxPrimsPerFrame = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -527,6 +525,11 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ISceneViewer SceneViewer
|
||||||
|
{
|
||||||
|
get { return m_sceneViewer; }
|
||||||
|
}
|
||||||
|
|
||||||
public void AdjustKnownSeeds()
|
public void AdjustKnownSeeds()
|
||||||
{
|
{
|
||||||
Dictionary<ulong, string> seeds = Scene.CapsModule.GetChildrenSeeds(UUID);
|
Dictionary<ulong, string> seeds = Scene.CapsModule.GetChildrenSeeds(UUID);
|
||||||
|
@ -601,7 +604,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
private ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo)
|
private ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo)
|
||||||
{
|
{
|
||||||
|
CreateSceneViewer();
|
||||||
m_regionHandle = reginfo.RegionHandle;
|
m_regionHandle = reginfo.RegionHandle;
|
||||||
m_controllingClient = client;
|
m_controllingClient = client;
|
||||||
m_firstname = m_controllingClient.FirstName;
|
m_firstname = m_controllingClient.FirstName;
|
||||||
|
@ -643,15 +646,22 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
AvatarWearable[] wearables)
|
AvatarWearable[] wearables)
|
||||||
: this(client, world, reginfo)
|
: this(client, world, reginfo)
|
||||||
{
|
{
|
||||||
|
CreateSceneViewer();
|
||||||
m_appearance = new AvatarAppearance(m_uuid, wearables, visualParams);
|
m_appearance = new AvatarAppearance(m_uuid, wearables, visualParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, AvatarAppearance appearance)
|
public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, AvatarAppearance appearance)
|
||||||
: this(client, world, reginfo)
|
: this(client, world, reginfo)
|
||||||
{
|
{
|
||||||
|
CreateSceneViewer();
|
||||||
m_appearance = appearance;
|
m_appearance = appearance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void CreateSceneViewer()
|
||||||
|
{
|
||||||
|
m_sceneViewer = new SceneViewer(this);
|
||||||
|
}
|
||||||
|
|
||||||
public void RegisterToEvents()
|
public void RegisterToEvents()
|
||||||
{
|
{
|
||||||
m_controllingClient.OnRequestWearables += SendWearables;
|
m_controllingClient.OnRequestWearables += SendWearables;
|
||||||
|
@ -704,13 +714,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
/// <param name="part"></param>
|
/// <param name="part"></param>
|
||||||
public void QueuePartForUpdate(SceneObjectPart part)
|
public void QueuePartForUpdate(SceneObjectPart part)
|
||||||
{
|
{
|
||||||
//if (InterestList.Contains(part.ParentGroup))
|
m_sceneViewer.QueuePartForUpdate(part);
|
||||||
//{
|
|
||||||
lock (m_partsUpdateQueue)
|
|
||||||
{
|
|
||||||
m_partsUpdateQueue.Enqueue(part);
|
|
||||||
}
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public uint GenerateClientFlags(UUID ObjectID)
|
public uint GenerateClientFlags(UUID ObjectID)
|
||||||
|
@ -725,122 +729,9 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void SendPrimUpdates()
|
public void SendPrimUpdates()
|
||||||
{
|
{
|
||||||
// if (m_scene.QuadTree.GetNodeID(this.AbsolutePosition.X, this.AbsolutePosition.Y) != m_currentQuadNode)
|
|
||||||
//{
|
|
||||||
// this.UpdateQuadTreeNode();
|
|
||||||
//this.RefreshQuadObject();
|
|
||||||
//}
|
|
||||||
m_perfMonMS = Environment.TickCount;
|
m_perfMonMS = Environment.TickCount;
|
||||||
|
|
||||||
if (m_pendingObjects == null)
|
m_sceneViewer.SendPrimUpdates();
|
||||||
{
|
|
||||||
if (!m_isChildAgent || m_scene.m_seeIntoRegionFromNeighbor)
|
|
||||||
{
|
|
||||||
m_pendingObjects = new Queue<SceneObjectGroup>();
|
|
||||||
|
|
||||||
List<EntityBase> ents = new List<EntityBase>(m_scene.Entities);
|
|
||||||
if (!m_isChildAgent) // Proximity sort makes no sense for
|
|
||||||
{ // Child agents
|
|
||||||
ents.Sort(delegate(EntityBase a, EntityBase b)
|
|
||||||
{
|
|
||||||
return Vector3.Distance(AbsolutePosition, a.AbsolutePosition).CompareTo(Vector3.Distance(AbsolutePosition, b.AbsolutePosition));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (EntityBase e in ents)
|
|
||||||
{
|
|
||||||
if (e is SceneObjectGroup)
|
|
||||||
m_pendingObjects.Enqueue((SceneObjectGroup)e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
while (m_pendingObjects != null && m_pendingObjects.Count > 0 && m_partsUpdateQueue.Count < m_maxPrimsPerFrame)
|
|
||||||
{
|
|
||||||
SceneObjectGroup g = m_pendingObjects.Dequeue();
|
|
||||||
|
|
||||||
// This is where we should check for draw distance
|
|
||||||
// do culling and stuff. Problem with that is that until
|
|
||||||
// we recheck in movement, that won't work right.
|
|
||||||
// So it's not implemented now.
|
|
||||||
//
|
|
||||||
|
|
||||||
// Don't even queue if we have sent this one
|
|
||||||
//
|
|
||||||
if (!m_updateTimes.ContainsKey(g.UUID))
|
|
||||||
g.ScheduleFullUpdateToAvatar(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
while (m_partsUpdateQueue.Count > 0)
|
|
||||||
{
|
|
||||||
SceneObjectPart part = m_partsUpdateQueue.Dequeue();
|
|
||||||
|
|
||||||
if (part.ParentGroup == null || part.ParentGroup.IsDeleted)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (m_updateTimes.ContainsKey(part.UUID))
|
|
||||||
{
|
|
||||||
ScenePartUpdate update = m_updateTimes[part.UUID];
|
|
||||||
|
|
||||||
// We deal with the possibility that two updates occur at
|
|
||||||
// the same unix time at the update point itself.
|
|
||||||
|
|
||||||
if ((update.LastFullUpdateTime < part.TimeStampFull) ||
|
|
||||||
part.IsAttachment)
|
|
||||||
{
|
|
||||||
// m_log.DebugFormat(
|
|
||||||
// "[SCENE PRESENCE]: Fully updating prim {0}, {1} - part timestamp {2}",
|
|
||||||
// part.Name, part.UUID, part.TimeStampFull);
|
|
||||||
|
|
||||||
part.SendFullUpdate(ControllingClient,
|
|
||||||
GenerateClientFlags(part.UUID));
|
|
||||||
|
|
||||||
// We'll update to the part's timestamp rather than
|
|
||||||
// the current time to avoid the race condition
|
|
||||||
// whereby the next tick occurs while we are doing
|
|
||||||
// this update. If this happened, then subsequent
|
|
||||||
// updates which occurred on the same tick or the
|
|
||||||
// next tick of the last update would be ignored.
|
|
||||||
|
|
||||||
update.LastFullUpdateTime = part.TimeStampFull;
|
|
||||||
|
|
||||||
}
|
|
||||||
else if (update.LastTerseUpdateTime <= part.TimeStampTerse)
|
|
||||||
{
|
|
||||||
// m_log.DebugFormat(
|
|
||||||
// "[SCENE PRESENCE]: Tersely updating prim {0}, {1} - part timestamp {2}",
|
|
||||||
// part.Name, part.UUID, part.TimeStampTerse);
|
|
||||||
|
|
||||||
part.SendTerseUpdateToClient(ControllingClient);
|
|
||||||
|
|
||||||
update.LastTerseUpdateTime = part.TimeStampTerse;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//never been sent to client before so do full update
|
|
||||||
ScenePartUpdate update = new ScenePartUpdate();
|
|
||||||
update.FullID = part.UUID;
|
|
||||||
update.LastFullUpdateTime = part.TimeStampFull;
|
|
||||||
m_updateTimes.Add(part.UUID, update);
|
|
||||||
|
|
||||||
// Attachment handling
|
|
||||||
//
|
|
||||||
if (part.ParentGroup.RootPart.Shape.PCode == 9 && part.ParentGroup.RootPart.Shape.State != 0)
|
|
||||||
{
|
|
||||||
if (part != part.ParentGroup.RootPart)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
part.ParentGroup.SendFullUpdateToClient(ControllingClient);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
part.SendFullUpdate(ControllingClient,
|
|
||||||
GenerateClientFlags(part.UUID));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ControllingClient.FlushPrimUpdates();
|
|
||||||
|
|
||||||
m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS);
|
m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS);
|
||||||
}
|
}
|
||||||
|
@ -935,7 +826,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
// On the next prim update, all objects will be sent
|
// On the next prim update, all objects will be sent
|
||||||
//
|
//
|
||||||
m_pendingObjects = null;
|
m_sceneViewer.Reset();
|
||||||
|
|
||||||
m_isChildAgent = false;
|
m_isChildAgent = false;
|
||||||
|
|
||||||
|
@ -3062,7 +2953,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
// Sends out the objects in the user's draw distance if m_sendTasksToChild is true.
|
// Sends out the objects in the user's draw distance if m_sendTasksToChild is true.
|
||||||
if (m_scene.m_seeIntoRegionFromNeighbor)
|
if (m_scene.m_seeIntoRegionFromNeighbor)
|
||||||
m_pendingObjects = null;
|
m_sceneViewer.Reset();
|
||||||
|
|
||||||
//cAgentData.AVHeight;
|
//cAgentData.AVHeight;
|
||||||
//cAgentData.regionHandle;
|
//cAgentData.regionHandle;
|
||||||
|
@ -3269,7 +3160,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
{
|
{
|
||||||
Primitive.TextureEntry textu = AvatarAppearance.GetDefaultTexture();
|
Primitive.TextureEntry textu = AvatarAppearance.GetDefaultTexture();
|
||||||
DefaultTexture = textu.GetBytes();
|
DefaultTexture = textu.GetBytes();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class NewForce
|
public class NewForce
|
||||||
|
@ -3279,20 +3169,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
public float Z;
|
public float Z;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ScenePartUpdate
|
|
||||||
{
|
|
||||||
public UUID FullID;
|
|
||||||
public uint LastFullUpdateTime;
|
|
||||||
public uint LastTerseUpdateTime;
|
|
||||||
|
|
||||||
public ScenePartUpdate()
|
|
||||||
{
|
|
||||||
FullID = UUID.Zero;
|
|
||||||
LastFullUpdateTime = 0;
|
|
||||||
LastTerseUpdateTime = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void SetText(string text, Vector3 color, double alpha)
|
public override void SetText(string text, Vector3 color, double alpha)
|
||||||
{
|
{
|
||||||
throw new Exception("Can't set Text on avatar.");
|
throw new Exception("Can't set Text on avatar.");
|
||||||
|
@ -3394,14 +3270,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
{
|
{
|
||||||
m_knownChildRegions.Clear();
|
m_knownChildRegions.Clear();
|
||||||
}
|
}
|
||||||
lock (m_updateTimes)
|
m_sceneViewer.Close();
|
||||||
{
|
|
||||||
m_updateTimes.Clear();
|
|
||||||
}
|
|
||||||
lock (m_partsUpdateQueue)
|
|
||||||
{
|
|
||||||
m_partsUpdateQueue.Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
RemoveFromPhysicalScene();
|
RemoveFromPhysicalScene();
|
||||||
GC.Collect();
|
GC.Collect();
|
||||||
|
@ -3414,6 +3283,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
Primitive.TextureEntry textu = AvatarAppearance.GetDefaultTexture();
|
Primitive.TextureEntry textu = AvatarAppearance.GetDefaultTexture();
|
||||||
DefaultTexture = textu.GetBytes();
|
DefaultTexture = textu.GetBytes();
|
||||||
}
|
}
|
||||||
|
CreateSceneViewer();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddAttachment(SceneObjectGroup gobj)
|
public void AddAttachment(SceneObjectGroup gobj)
|
||||||
|
|
|
@ -0,0 +1,226 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://opensimulator.org/
|
||||||
|
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the OpenSimulator Project nor the
|
||||||
|
* names of its contributors may be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using OpenMetaverse;
|
||||||
|
using log4net;
|
||||||
|
using OpenSim.Framework;
|
||||||
|
using OpenSim.Framework.Client;
|
||||||
|
using OpenSim.Framework.Communications.Cache;
|
||||||
|
using OpenSim.Region.Framework.Interfaces;
|
||||||
|
using OpenSim.Region.Framework.Scenes.Types;
|
||||||
|
|
||||||
|
namespace OpenSim.Region.Framework.Scenes
|
||||||
|
{
|
||||||
|
public class SceneViewer : ISceneViewer
|
||||||
|
{
|
||||||
|
protected ScenePresence m_presence;
|
||||||
|
protected UpdateQueue m_partsUpdateQueue = new UpdateQueue();
|
||||||
|
protected Queue<SceneObjectGroup> m_pendingObjects;
|
||||||
|
|
||||||
|
protected Dictionary<UUID, ScenePartUpdate> m_updateTimes = new Dictionary<UUID, ScenePartUpdate>();
|
||||||
|
|
||||||
|
protected int m_maxPrimsPerFrame = 200;
|
||||||
|
|
||||||
|
public int MaxPrimsPerFrame
|
||||||
|
{
|
||||||
|
get { return m_maxPrimsPerFrame; }
|
||||||
|
set { m_maxPrimsPerFrame = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public SceneViewer()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public SceneViewer(ScenePresence presence)
|
||||||
|
{
|
||||||
|
m_presence = presence;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Add the part to the queue of parts for which we need to send an update to the client
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="part"></param>
|
||||||
|
public void QueuePartForUpdate(SceneObjectPart part)
|
||||||
|
{
|
||||||
|
lock (m_partsUpdateQueue)
|
||||||
|
{
|
||||||
|
m_partsUpdateQueue.Enqueue(part);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SendPrimUpdates()
|
||||||
|
{
|
||||||
|
if (m_pendingObjects == null)
|
||||||
|
{
|
||||||
|
if (!m_presence.IsChildAgent || (m_presence.Scene.m_seeIntoRegionFromNeighbor))
|
||||||
|
{
|
||||||
|
m_pendingObjects = new Queue<SceneObjectGroup>();
|
||||||
|
|
||||||
|
List<EntityBase> ents = new List<EntityBase>(m_presence.Scene.Entities);
|
||||||
|
if (!m_presence.IsChildAgent) // Proximity sort makes no sense for
|
||||||
|
{ // Child agents
|
||||||
|
ents.Sort(delegate(EntityBase a, EntityBase b)
|
||||||
|
{
|
||||||
|
return Vector3.Distance(m_presence.AbsolutePosition, a.AbsolutePosition).CompareTo(Vector3.Distance(m_presence.AbsolutePosition, b.AbsolutePosition));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (EntityBase e in ents)
|
||||||
|
{
|
||||||
|
if (e is SceneObjectGroup)
|
||||||
|
m_pendingObjects.Enqueue((SceneObjectGroup)e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
while (m_pendingObjects != null && m_pendingObjects.Count > 0 && m_partsUpdateQueue.Count < m_maxPrimsPerFrame)
|
||||||
|
{
|
||||||
|
SceneObjectGroup g = m_pendingObjects.Dequeue();
|
||||||
|
|
||||||
|
// This is where we should check for draw distance
|
||||||
|
// do culling and stuff. Problem with that is that until
|
||||||
|
// we recheck in movement, that won't work right.
|
||||||
|
// So it's not implemented now.
|
||||||
|
//
|
||||||
|
|
||||||
|
// Don't even queue if we have sent this one
|
||||||
|
//
|
||||||
|
if (!m_updateTimes.ContainsKey(g.UUID))
|
||||||
|
g.ScheduleFullUpdateToAvatar(m_presence);
|
||||||
|
}
|
||||||
|
|
||||||
|
while (m_partsUpdateQueue.Count > 0)
|
||||||
|
{
|
||||||
|
SceneObjectPart part = m_partsUpdateQueue.Dequeue();
|
||||||
|
|
||||||
|
if (part.ParentGroup == null || part.ParentGroup.IsDeleted)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (m_updateTimes.ContainsKey(part.UUID))
|
||||||
|
{
|
||||||
|
ScenePartUpdate update = m_updateTimes[part.UUID];
|
||||||
|
|
||||||
|
// We deal with the possibility that two updates occur at
|
||||||
|
// the same unix time at the update point itself.
|
||||||
|
|
||||||
|
if ((update.LastFullUpdateTime < part.TimeStampFull) ||
|
||||||
|
part.IsAttachment)
|
||||||
|
{
|
||||||
|
// m_log.DebugFormat(
|
||||||
|
// "[SCENE PRESENCE]: Fully updating prim {0}, {1} - part timestamp {2}",
|
||||||
|
// part.Name, part.UUID, part.TimeStampFull);
|
||||||
|
|
||||||
|
part.SendFullUpdate(m_presence.ControllingClient,
|
||||||
|
m_presence.GenerateClientFlags(part.UUID));
|
||||||
|
|
||||||
|
// We'll update to the part's timestamp rather than
|
||||||
|
// the current time to avoid the race condition
|
||||||
|
// whereby the next tick occurs while we are doing
|
||||||
|
// this update. If this happened, then subsequent
|
||||||
|
// updates which occurred on the same tick or the
|
||||||
|
// next tick of the last update would be ignored.
|
||||||
|
|
||||||
|
update.LastFullUpdateTime = part.TimeStampFull;
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (update.LastTerseUpdateTime <= part.TimeStampTerse)
|
||||||
|
{
|
||||||
|
// m_log.DebugFormat(
|
||||||
|
// "[SCENE PRESENCE]: Tersely updating prim {0}, {1} - part timestamp {2}",
|
||||||
|
// part.Name, part.UUID, part.TimeStampTerse);
|
||||||
|
|
||||||
|
part.SendTerseUpdateToClient(m_presence.ControllingClient);
|
||||||
|
|
||||||
|
update.LastTerseUpdateTime = part.TimeStampTerse;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//never been sent to client before so do full update
|
||||||
|
ScenePartUpdate update = new ScenePartUpdate();
|
||||||
|
update.FullID = part.UUID;
|
||||||
|
update.LastFullUpdateTime = part.TimeStampFull;
|
||||||
|
m_updateTimes.Add(part.UUID, update);
|
||||||
|
|
||||||
|
// Attachment handling
|
||||||
|
//
|
||||||
|
if (part.ParentGroup.RootPart.Shape.PCode == 9 && part.ParentGroup.RootPart.Shape.State != 0)
|
||||||
|
{
|
||||||
|
if (part != part.ParentGroup.RootPart)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
part.ParentGroup.SendFullUpdateToClient(m_presence.ControllingClient);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
part.SendFullUpdate(m_presence.ControllingClient,
|
||||||
|
m_presence.GenerateClientFlags(part.UUID));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_presence.ControllingClient.FlushPrimUpdates();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Reset()
|
||||||
|
{
|
||||||
|
lock (m_pendingObjects)
|
||||||
|
{
|
||||||
|
m_pendingObjects.Clear();
|
||||||
|
m_pendingObjects = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Close()
|
||||||
|
{
|
||||||
|
lock (m_updateTimes)
|
||||||
|
{
|
||||||
|
m_updateTimes.Clear();
|
||||||
|
}
|
||||||
|
lock (m_partsUpdateQueue)
|
||||||
|
{
|
||||||
|
m_partsUpdateQueue.Clear();
|
||||||
|
}
|
||||||
|
Reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ScenePartUpdate
|
||||||
|
{
|
||||||
|
public UUID FullID;
|
||||||
|
public uint LastFullUpdateTime;
|
||||||
|
public uint LastTerseUpdateTime;
|
||||||
|
|
||||||
|
public ScenePartUpdate()
|
||||||
|
{
|
||||||
|
FullID = UUID.Zero;
|
||||||
|
LastFullUpdateTime = 0;
|
||||||
|
LastTerseUpdateTime = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue