Merge branch 'remove-scene-viewer'

iar_mods
Dan Lake 2011-11-14 12:37:48 -08:00
commit ed19284d85
7 changed files with 22 additions and 427 deletions

View File

@ -1049,24 +1049,6 @@ namespace OpenSim
MainConsole.Instance.Output(handlers.ToString());
break;
case "pending-objects":
System.Text.StringBuilder pending = new System.Text.StringBuilder("Pending objects:\n");
m_sceneManager.ForEachScene(
delegate(Scene scene)
{
scene.ForEachScenePresence(
delegate(ScenePresence sp)
{
pending.AppendFormat("{0}: {1} {2} pending\n",
scene.RegionInfo.RegionName, sp.Name, sp.SceneViewer.GetPendingObjectsCount());
}
);
}
);
MainConsole.Instance.Output(pending.ToString());
break;
case "modules":
MainConsole.Instance.Output("The currently loaded shared modules are:");
foreach (IRegionModule module in m_moduleLoader.GetLoadedSharedModules)

View File

@ -1,50 +0,0 @@
/*
* 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 OpenSim.Region.Framework.Scenes;
namespace OpenSim.Region.Framework.Interfaces
{
/// <summary>
/// Sends scheduled updates to it's associated ScenePresence.
/// </summary>
public interface ISceneViewer
{
// void Reset();
void Close();
/// <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>
void QueuePartForUpdate(SceneObjectPart part);
void SendPrimUpdates();
int GetPendingObjectsCount();
}
}

View File

@ -2540,6 +2540,16 @@ namespace OpenSim.Region.Framework.Scenes
if (vialogin)
EventManager.TriggerOnClientLogin(client);
}
// Send all scene object to the new client
Util.FireAndForget(delegate
{
Entities.ForEach(delegate(EntityBase e)
{
if (e != null && e is SceneObjectGroup)
((SceneObjectGroup)e).SendFullUpdateToClient(client);
});
});
}
/// <summary>

View File

@ -1760,30 +1760,6 @@ namespace OpenSim.Region.Framework.Scenes
}
}
public void ScheduleFullUpdateToAvatar(ScenePresence presence)
{
// m_log.DebugFormat("[SOG]: Scheduling full update for {0} {1} just to avatar {2}", Name, UUID, presence.Name);
RootPart.AddFullUpdateToAvatar(presence);
SceneObjectPart[] parts = m_parts.GetArray();
for (int i = 0; i < parts.Length; i++)
{
SceneObjectPart part = parts[i];
if (part != RootPart)
part.AddFullUpdateToAvatar(presence);
}
}
public void ScheduleTerseUpdateToAvatar(ScenePresence presence)
{
// m_log.DebugFormat("[SOG]: Scheduling terse update for {0} {1} just to avatar {2}", Name, UUID, presence.Name);
SceneObjectPart[] parts = m_parts.GetArray();
for (int i = 0; i < parts.Length; i++)
parts[i].AddTerseUpdateToAvatar(presence);
}
/// <summary>
/// Schedule a full update for this scene object
/// </summary>

View File

@ -1373,25 +1373,6 @@ namespace OpenSim.Region.Framework.Scenes
// m_log.Debug("Aprev: " + prevflag.ToString() + " curr: " + Flags.ToString());
}
/// <summary>
/// Tell all scene presences that they should send updates for this part to their clients
/// </summary>
public void AddFullUpdateToAllAvatars()
{
ParentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar)
{
AddFullUpdateToAvatar(avatar);
});
}
/// <summary>
/// Tell the scene presence that it should send updates for this part to its client
/// </summary>
public void AddFullUpdateToAvatar(ScenePresence presence)
{
presence.SceneViewer.QueuePartForUpdate(this);
}
public void AddNewParticleSystem(Primitive.ParticleSystem pSystem)
{
m_particleSystem = pSystem.GetBytes();
@ -1402,20 +1383,6 @@ namespace OpenSim.Region.Framework.Scenes
m_particleSystem = new byte[0];
}
/// Terse updates
public void AddTerseUpdateToAllAvatars()
{
ParentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar)
{
AddTerseUpdateToAvatar(avatar);
});
}
public void AddTerseUpdateToAvatar(ScenePresence presence)
{
presence.SceneViewer.QueuePartForUpdate(this);
}
public void AddTextureAnimation(Primitive.TextureAnimation pTexAnim)
{
byte[] data = new byte[16];
@ -2650,8 +2617,6 @@ namespace OpenSim.Region.Framework.Scenes
//ParentGroup.RootPart.m_groupPosition = newpos;
}
ScheduleTerseUpdate();
//SendTerseUpdateToAllClients();
}
public void PreloadSound(string sound)
@ -2834,6 +2799,13 @@ namespace OpenSim.Region.Framework.Scenes
if (ParentGroup == null)
return;
// This was pulled from SceneViewer. Attachments always receive full updates.
// I could not verify if this is a requirement but this maintains existing behavior
if (ParentGroup.IsAttachment)
{
ScheduleFullUpdate();
}
if (UpdateFlag == UpdateRequired.NONE)
{
ParentGroup.HasGroupChanged = true;
@ -2927,23 +2899,6 @@ namespace OpenSim.Region.Framework.Scenes
});
}
/// <summary>
/// Send a full update to all clients except the one nominated.
/// </summary>
/// <param name="agentID"></param>
public void SendFullUpdateToAllClientsExcept(UUID agentID)
{
if (ParentGroup == null)
return;
ParentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar)
{
// Ugly reference :(
if (avatar.UUID != agentID)
SendFullUpdate(avatar.ControllingClient, avatar.GenerateClientFlags(UUID));
});
}
/// <summary>
/// Sends a full update to the client
/// </summary>
@ -3020,7 +2975,8 @@ namespace OpenSim.Region.Framework.Scenes
!OffsetPosition.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) ||
Environment.TickCount - m_lastTerseSent > TIME_MS_TOLERANCE)
{
AddTerseUpdateToAllAvatars();
SendTerseUpdateToAllClients();
ClearUpdateSchedule();
// Update the "last" values
@ -3035,7 +2991,7 @@ namespace OpenSim.Region.Framework.Scenes
}
case UpdateRequired.FULL:
{
AddFullUpdateToAllAvatars();
SendFullUpdateToAllClients();
break;
}
}
@ -3140,9 +3096,9 @@ namespace OpenSim.Region.Framework.Scenes
/// </summary>
public void SendTerseUpdateToAllClients()
{
ParentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar)
ParentGroup.Scene.ForEachClient(delegate(IClientAPI client)
{
SendTerseUpdateToClient(avatar.ControllingClient);
SendTerseUpdateToClient(client);
});
}

View File

@ -135,7 +135,6 @@ namespace OpenSim.Region.Framework.Scenes
private Vector3 m_lastPosition;
private Quaternion m_lastRotation;
private Vector3 m_lastVelocity;
//private int m_lastTerseSent;
private Vector3? m_forceToApply;
private int m_userFlags;
@ -644,14 +643,6 @@ namespace OpenSim.Region.Framework.Scenes
set { m_health = value; }
}
private ISceneViewer m_sceneViewer;
public ISceneViewer SceneViewer
{
get { return m_sceneViewer; }
private set { m_sceneViewer = value; }
}
public void AdjustKnownSeeds()
{
Dictionary<ulong, string> seeds;
@ -755,7 +746,6 @@ namespace OpenSim.Region.Framework.Scenes
AttachmentsSyncLock = new Object();
m_sendCourseLocationsMethod = SendCoarseLocationsDefault;
SceneViewer = new SceneViewer(this);
Animator = new ScenePresenceAnimator(this);
PresenceType = type;
DrawDistance = world.DefaultDrawDistance;
@ -866,16 +856,6 @@ namespace OpenSim.Region.Framework.Scenes
return m_scene.Permissions.GenerateClientFlags(m_uuid, ObjectID);
}
/// <summary>
/// Send updates to the client about prims which have been placed on the update queue. We don't
/// necessarily send updates for all the parts on the queue, e.g. if an updates with a more recent
/// timestamp has already been sent.
/// </summary>
public void SendPrimUpdates()
{
SceneViewer.SendPrimUpdates();
}
#region Status Methods
/// <summary>
@ -2412,10 +2392,6 @@ namespace OpenSim.Region.Framework.Scenes
const float ROTATION_TOLERANCE = 0.01f;
const float VELOCITY_TOLERANCE = 0.001f;
const float POSITION_TOLERANCE = 0.05f;
//const int TIME_MS_TOLERANCE = 3000;
if (!sendingPrims)
Util.FireAndForget(delegate { sendingPrims = true; SendPrimUpdates(); sendingPrims = false; });
if (IsChildAgent == false)
{
@ -2427,7 +2403,6 @@ namespace OpenSim.Region.Framework.Scenes
if (!Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) ||
!Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) ||
!m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE))
//Environment.TickCount - m_lastTerseSent > TIME_MS_TOLERANCE)
{
SendTerseUpdateToAllClients();
@ -2435,7 +2410,6 @@ namespace OpenSim.Region.Framework.Scenes
m_lastPosition = m_pos;
m_lastRotation = Rotation;
m_lastVelocity = Velocity;
//m_lastTerseSent = Environment.TickCount;
}
// followed suggestion from mic bowman. reversed the two lines below.
@ -3420,8 +3394,6 @@ namespace OpenSim.Region.Framework.Scenes
// unsetting the elapsed callback should be enough to allow for cleanup however.
// m_reprioritizationTimer.Dispose();
SceneViewer.Close();
RemoveFromPhysicalScene();
Animator.Close();
Animator = null;

View File

@ -1,251 +0,0 @@
/*
* 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.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes.Types;
namespace OpenSim.Region.Framework.Scenes
{
public class SceneViewer : ISceneViewer
{
/// <summary>
/// Is this scene viewer enabled?
/// </summary>
private bool IsEnabled { get; set; }
/// <summary>
/// The scene presence serviced by this viewer.
/// </summary>
protected ScenePresence m_presence;
/// <summary>
/// The queue of parts for which we need to send out updates.
/// </summary>
protected UpdateQueue m_partsUpdateQueue = new UpdateQueue();
/// <summary>
/// The queue of objects for which we need to send out updates.
/// </summary>
protected Queue<SceneObjectGroup> m_pendingObjects;
/// <summary>
/// The last update assocated with a given part update.
/// </summary>
protected Dictionary<UUID, ScenePartUpdate> m_updateTimes = new Dictionary<UUID, ScenePartUpdate>();
public SceneViewer(ScenePresence presence)
{
m_presence = presence;
IsEnabled = true;
}
public void QueuePartForUpdate(SceneObjectPart part)
{
if (!IsEnabled)
return;
lock (m_partsUpdateQueue)
{
m_partsUpdateQueue.Enqueue(part);
}
}
public void SendPrimUpdates()
{
if (m_pendingObjects == null)
{
m_pendingObjects = new Queue<SceneObjectGroup>();
lock (m_pendingObjects)
{
EntityBase[] entities = m_presence.Scene.Entities.GetEntities();
foreach (EntityBase e in entities)
{
if (e != null && e is SceneObjectGroup)
m_pendingObjects.Enqueue((SceneObjectGroup)e);
}
}
}
lock (m_pendingObjects)
{
// We must do this under lock so that we don't suffer a race condition if another thread closes the
// viewer
if (!IsEnabled)
return;
while (m_pendingObjects != null && m_pendingObjects.Count > 0)
{
SceneObjectGroup g = m_pendingObjects.Dequeue();
// Yes, this can really happen
if (g == null)
continue;
// 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.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.ParentGroup.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));
}
}
}
}
// public void Reset()
// {
// if (m_pendingObjects == null)
// return;
//
// lock (m_pendingObjects)
// {
// if (m_pendingObjects != null)
// {
// m_pendingObjects.Clear();
// m_pendingObjects = null;
// }
// }
// }
public void Close()
{
lock (m_pendingObjects)
{
// We perform this under the m_pendingObjects lock in order to avoid a race condition with another
// thread on SendPrimUpdates()
IsEnabled = false;
lock (m_updateTimes)
{
m_updateTimes.Clear();
}
lock (m_partsUpdateQueue)
{
m_partsUpdateQueue.Clear();
}
}
}
public int GetPendingObjectsCount()
{
if (m_pendingObjects != null)
lock (m_pendingObjects)
return m_pendingObjects.Count;
return 0;
}
public class ScenePartUpdate
{
public UUID FullID;
public uint LastFullUpdateTime;
public uint LastTerseUpdateTime;
public ScenePartUpdate()
{
FullID = UUID.Zero;
LastFullUpdateTime = 0;
LastTerseUpdateTime = 0;
}
}
}
}