mirror of
https://github.com/opensim/opensim.git
synced 2026-08-08 02:05:34 +08:00
Merge branch 'master' into vehicles
This commit is contained in:
@@ -34,7 +34,6 @@ namespace OpenSim.Region.Framework.Interfaces
|
||||
{
|
||||
void Reset();
|
||||
void Close();
|
||||
int MaxPrimsPerFrame { get; set; }
|
||||
void QueuePartForUpdate(SceneObjectPart part);
|
||||
void SendPrimUpdates();
|
||||
}
|
||||
|
||||
@@ -93,40 +93,31 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (m_lock)
|
||||
{
|
||||
return m_eb_uuid.Count;
|
||||
}
|
||||
return m_eb_uuid.Count;
|
||||
}
|
||||
}
|
||||
|
||||
public bool ContainsKey(UUID id)
|
||||
{
|
||||
lock (m_lock)
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
return m_eb_uuid.ContainsKey(id);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return m_eb_uuid.ContainsKey(id);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool ContainsKey(uint localID)
|
||||
{
|
||||
lock (m_lock)
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
return m_eb_localID.ContainsKey(localID);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return m_eb_localID.ContainsKey(localID);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,7 +127,11 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
{
|
||||
try
|
||||
{
|
||||
bool a = m_eb_uuid.Remove(m_eb_localID[localID].UUID);
|
||||
bool a = false;
|
||||
EntityBase entity;
|
||||
if (m_eb_localID.TryGetValue(localID, out entity))
|
||||
a = m_eb_uuid.Remove(entity.UUID);
|
||||
|
||||
bool b = m_eb_localID.Remove(localID);
|
||||
return a && b;
|
||||
}
|
||||
@@ -154,7 +149,11 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
{
|
||||
try
|
||||
{
|
||||
bool a = m_eb_localID.Remove(m_eb_uuid[id].LocalId);
|
||||
bool a = false;
|
||||
EntityBase entity;
|
||||
if (m_eb_uuid.TryGetValue(id, out entity))
|
||||
a = m_eb_localID.Remove(entity.LocalId);
|
||||
|
||||
bool b = m_eb_uuid.Remove(id);
|
||||
return a && b;
|
||||
}
|
||||
@@ -206,14 +205,11 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
{
|
||||
lock (m_lock)
|
||||
{
|
||||
try
|
||||
{
|
||||
return m_eb_uuid[id];
|
||||
}
|
||||
catch
|
||||
{
|
||||
EntityBase entity;
|
||||
if (m_eb_uuid.TryGetValue(id, out entity))
|
||||
return entity;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
set
|
||||
@@ -228,14 +224,11 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
{
|
||||
lock (m_lock)
|
||||
{
|
||||
try
|
||||
{
|
||||
return m_eb_localID[localID];
|
||||
}
|
||||
catch
|
||||
{
|
||||
EntityBase entity;
|
||||
if (m_eb_localID.TryGetValue(localID, out entity))
|
||||
return entity;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
set
|
||||
|
||||
@@ -2351,12 +2351,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
item = InventoryService.GetItem(item);
|
||||
|
||||
presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /*att.UUID*/);
|
||||
IAvatarFactory ava = RequestModuleInterface<IAvatarFactory>();
|
||||
if (ava != null)
|
||||
{
|
||||
ava.UpdateDatabase(remoteClient.AgentId, presence.Appearance);
|
||||
}
|
||||
|
||||
}
|
||||
return att.UUID;
|
||||
}
|
||||
@@ -2402,12 +2396,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
|
||||
item = InventoryService.GetItem(item);
|
||||
presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /*att.UUID*/);
|
||||
|
||||
if (m_AvatarFactory != null)
|
||||
{
|
||||
m_log.InfoFormat("[SCENE INVENTORY]: Saving avatar attachment. AgentID:{0} ItemID:{1} AttachmentPoint:{2}", remoteClient.AgentId, itemID, AttachmentPt);
|
||||
m_AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2447,12 +2435,13 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
if (TryGetAvatar(remoteClient.AgentId, out presence))
|
||||
{
|
||||
presence.Appearance.DetachAttachment(itemID);
|
||||
IAvatarFactory ava = RequestModuleInterface<IAvatarFactory>();
|
||||
if (ava != null)
|
||||
{
|
||||
ava.UpdateDatabase(remoteClient.AgentId, presence.Appearance);
|
||||
}
|
||||
|
||||
// Save avatar attachment information
|
||||
if (m_AvatarFactory != null)
|
||||
{
|
||||
m_log.Info("[SCENE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId + ", ItemID: " + itemID);
|
||||
m_AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance);
|
||||
}
|
||||
}
|
||||
|
||||
m_sceneGraph.DetachSingleAttachmentToInv(itemID, remoteClient);
|
||||
|
||||
@@ -57,6 +57,12 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|
||||
public partial class Scene : SceneBase
|
||||
{
|
||||
public enum UpdatePrioritizationSchemes {
|
||||
Time = 0,
|
||||
Distance = 1,
|
||||
SimpleAngularDistance = 2,
|
||||
}
|
||||
|
||||
public delegate void SynchronizeSceneHandler(Scene scene);
|
||||
public SynchronizeSceneHandler SynchronizeScene = null;
|
||||
|
||||
@@ -222,6 +228,10 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
protected IXMLRPC m_xmlrpcModule;
|
||||
protected IWorldComm m_worldCommModule;
|
||||
protected IAvatarFactory m_AvatarFactory;
|
||||
public IAvatarFactory AvatarFactory
|
||||
{
|
||||
get { return m_AvatarFactory; }
|
||||
}
|
||||
protected IConfigSource m_config;
|
||||
protected IRegionSerialiserModule m_serialiser;
|
||||
protected IInterregionCommsOut m_interregionCommsOut;
|
||||
@@ -269,9 +279,14 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
private volatile bool shuttingdown = false;
|
||||
|
||||
private int m_lastUpdate = Environment.TickCount;
|
||||
private int m_maxPrimsPerFrame = 200;
|
||||
private bool m_firstHeartbeat = true;
|
||||
|
||||
private UpdatePrioritizationSchemes m_update_prioritization_scheme = UpdatePrioritizationSchemes.Time;
|
||||
private bool m_reprioritization_enabled = true;
|
||||
private double m_reprioritization_interval = 2000.0;
|
||||
private double m_root_reprioritization_distance = 5.0;
|
||||
private double m_child_reprioritization_distance = 10.0;
|
||||
|
||||
private object m_deleting_scene_object = new object();
|
||||
|
||||
// the minimum time that must elapse before a changed object will be considered for persisted
|
||||
@@ -283,6 +298,12 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|
||||
#region Properties
|
||||
|
||||
public UpdatePrioritizationSchemes UpdatePrioritizationScheme { get { return this.m_update_prioritization_scheme; } }
|
||||
public bool IsReprioritizationEnabled { get { return m_reprioritization_enabled; } }
|
||||
public double ReprioritizationInterval { get { return m_reprioritization_interval; } }
|
||||
public double RootReprioritizationDistance { get { return m_root_reprioritization_distance; } }
|
||||
public double ChildReprioritizationDistance { get { return m_child_reprioritization_distance; } }
|
||||
|
||||
public AgentCircuitManager AuthenticateHandler
|
||||
{
|
||||
get { return m_authenticateHandler; }
|
||||
@@ -327,12 +348,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
get { return m_sceneGraph.m_syncRoot; }
|
||||
}
|
||||
|
||||
public int MaxPrimsPerFrame
|
||||
{
|
||||
get { return m_maxPrimsPerFrame; }
|
||||
set { m_maxPrimsPerFrame = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is for llGetRegionFPS
|
||||
/// </summary>
|
||||
@@ -346,13 +361,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
get { return m_defaultScriptEngine; }
|
||||
}
|
||||
|
||||
// Reference to all of the agents in the scene (root and child)
|
||||
protected Dictionary<UUID, ScenePresence> m_scenePresences
|
||||
{
|
||||
get { return m_sceneGraph.ScenePresences; }
|
||||
set { m_sceneGraph.ScenePresences = value; }
|
||||
}
|
||||
|
||||
public EntityManager Entities
|
||||
{
|
||||
get { return m_sceneGraph.Entities; }
|
||||
@@ -510,7 +518,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|
||||
m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "DotNetEngine");
|
||||
|
||||
m_maxPrimsPerFrame = startupConfig.GetInt("MaxPrimsPerFrame", 200);
|
||||
IConfig packetConfig = m_config.Configs["PacketPool"];
|
||||
if (packetConfig != null)
|
||||
{
|
||||
@@ -519,6 +526,35 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
}
|
||||
|
||||
m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl);
|
||||
|
||||
IConfig interest_management_config = m_config.Configs["InterestManagement"];
|
||||
if (interest_management_config != null)
|
||||
{
|
||||
string update_prioritization_scheme = interest_management_config.GetString("UpdatePrioritizationScheme", "Time").Trim().ToLower();
|
||||
switch (update_prioritization_scheme)
|
||||
{
|
||||
case "time":
|
||||
m_update_prioritization_scheme = UpdatePrioritizationSchemes.Time;
|
||||
break;
|
||||
case "distance":
|
||||
m_update_prioritization_scheme = UpdatePrioritizationSchemes.Distance;
|
||||
break;
|
||||
case "simpleangulardistance":
|
||||
m_update_prioritization_scheme = UpdatePrioritizationSchemes.SimpleAngularDistance;
|
||||
break;
|
||||
default:
|
||||
m_log.Warn("[SCENE]: UpdatePrioritizationScheme was not recognized, setting to default settomg of Time");
|
||||
m_update_prioritization_scheme = UpdatePrioritizationSchemes.Time;
|
||||
break;
|
||||
}
|
||||
|
||||
m_reprioritization_enabled = interest_management_config.GetBoolean("ReprioritizationEnabled", true);
|
||||
m_reprioritization_interval = interest_management_config.GetDouble("ReprioritizationInterval", 5000.0);
|
||||
m_root_reprioritization_distance = interest_management_config.GetDouble("RootReprioritizationDistance", 10.0);
|
||||
m_child_reprioritization_distance = interest_management_config.GetDouble("ChildReprioritizationDistance", 20.0);
|
||||
}
|
||||
|
||||
m_log.Info("[SCENE]: Using the " + m_update_prioritization_scheme + " prioritization scheme");
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -1144,14 +1180,13 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
/// <param name="stats">Stats on the Simulator's performance</param>
|
||||
private void SendSimStatsPackets(SimStats stats)
|
||||
{
|
||||
List<ScenePresence> StatSendAgents = GetScenePresences();
|
||||
foreach (ScenePresence agent in StatSendAgents)
|
||||
{
|
||||
if (!agent.IsChildAgent)
|
||||
ForEachScenePresence(
|
||||
delegate(ScenePresence agent)
|
||||
{
|
||||
agent.ControllingClient.SendSimStats(stats);
|
||||
if (!agent.IsChildAgent)
|
||||
agent.ControllingClient.SendSimStats(stats);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1199,15 +1234,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
m_eventManager.TriggerOnFrame();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Perform delegate action on all clients subscribing to updates from this region.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public void Broadcast(Action<IClientAPI> whatToDo)
|
||||
{
|
||||
ForEachScenePresence(delegate(ScenePresence presence) { whatToDo(presence.ControllingClient); });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Backup the scene. This acts as the main method of the backup thread.
|
||||
/// </summary>
|
||||
@@ -3054,17 +3080,13 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
}
|
||||
|
||||
m_eventManager.TriggerOnRemovePresence(agentID);
|
||||
Broadcast(delegate(IClientAPI client)
|
||||
{
|
||||
try
|
||||
{
|
||||
client.SendKillObject(avatar.RegionHandle, avatar.LocalId);
|
||||
}
|
||||
catch (NullReferenceException)
|
||||
{
|
||||
//We can safely ignore null reference exceptions. It means the avatar are dead and cleaned up anyway.
|
||||
}
|
||||
});
|
||||
ForEachClient(
|
||||
delegate(IClientAPI client)
|
||||
{
|
||||
//We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway
|
||||
try { client.SendKillObject(avatar.RegionHandle, avatar.LocalId); }
|
||||
catch (NullReferenceException) { }
|
||||
});
|
||||
|
||||
ForEachScenePresence(
|
||||
delegate(ScenePresence presence) { presence.CoarseLocationChange(); });
|
||||
@@ -3149,7 +3171,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
return;
|
||||
}
|
||||
}
|
||||
Broadcast(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, localID); });
|
||||
ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, localID); });
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -3475,10 +3497,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
{
|
||||
ScenePresence presence;
|
||||
|
||||
lock (m_scenePresences)
|
||||
{
|
||||
m_scenePresences.TryGetValue(agentID, out presence);
|
||||
}
|
||||
lock (m_sceneGraph.ScenePresences)
|
||||
m_sceneGraph.ScenePresences.TryGetValue(agentID, out presence);
|
||||
|
||||
if (presence != null)
|
||||
{
|
||||
@@ -3688,12 +3708,9 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
public void RequestTeleportLocation(IClientAPI remoteClient, ulong regionHandle, Vector3 position,
|
||||
Vector3 lookAt, uint teleportFlags)
|
||||
{
|
||||
ScenePresence sp = null;
|
||||
lock (m_scenePresences)
|
||||
{
|
||||
if (m_scenePresences.ContainsKey(remoteClient.AgentId))
|
||||
sp = m_scenePresences[remoteClient.AgentId];
|
||||
}
|
||||
ScenePresence sp;
|
||||
lock (m_sceneGraph.ScenePresences)
|
||||
m_sceneGraph.ScenePresences.TryGetValue(remoteClient.AgentId, out sp);
|
||||
|
||||
if (sp != null)
|
||||
{
|
||||
@@ -4142,7 +4159,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
public void ForEachScenePresence(Action<ScenePresence> action)
|
||||
{
|
||||
// We don't want to try to send messages if there are no avatars.
|
||||
if (m_scenePresences != null)
|
||||
if (m_sceneGraph != null && m_sceneGraph.ScenePresences != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -4222,7 +4239,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|
||||
public void ForEachClient(Action<IClientAPI> action)
|
||||
{
|
||||
m_sceneGraph.ForEachClient(action);
|
||||
ClientManager.ForEach(action);
|
||||
}
|
||||
|
||||
public void ForEachSOG(Action<SceneObjectGroup> action)
|
||||
|
||||
@@ -467,7 +467,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
protected internal void AttachObject(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, Quaternion rot, bool silent)
|
||||
{
|
||||
// If we can't take it, we can't attach it!
|
||||
//
|
||||
SceneObjectPart part = m_parentScene.GetSceneObjectPart(objectLocalID);
|
||||
if (part == null)
|
||||
return;
|
||||
@@ -477,9 +476,16 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
return;
|
||||
|
||||
// Calls attach with a Zero position
|
||||
//
|
||||
AttachObject(remoteClient, objectLocalID, AttachmentPt, rot, Vector3.Zero, false);
|
||||
m_parentScene.SendAttachEvent(objectLocalID, part.ParentGroup.GetFromItemID(), remoteClient.AgentId);
|
||||
|
||||
// Save avatar attachment information
|
||||
ScenePresence presence;
|
||||
if (m_parentScene.AvatarFactory != null && m_parentScene.TryGetAvatar(remoteClient.AgentId, out presence))
|
||||
{
|
||||
m_log.Info("[SCENE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId + ", AttachmentPoint: " + AttachmentPt);
|
||||
m_parentScene.AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance);
|
||||
}
|
||||
}
|
||||
|
||||
public SceneObjectGroup RezSingleAttachment(
|
||||
@@ -574,7 +580,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
}
|
||||
|
||||
|
||||
group.SetAttachmentPoint(Convert.ToByte(AttachmentPt));
|
||||
group.SetAttachmentPoint((byte)AttachmentPt);
|
||||
group.AbsolutePosition = attachPos;
|
||||
|
||||
// Saves and gets itemID
|
||||
@@ -613,7 +619,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|
||||
newAvatar = new ScenePresence(client, m_parentScene, m_regInfo, appearance);
|
||||
newAvatar.IsChildAgent = true;
|
||||
newAvatar.MaxPrimsPerFrame = m_parentScene.MaxPrimsPerFrame;
|
||||
|
||||
AddScenePresence(newAvatar);
|
||||
|
||||
@@ -847,7 +852,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
/// </summary>
|
||||
/// <param name="localID"></param>
|
||||
/// <returns>null if no scene object group containing that prim is found</returns>
|
||||
private SceneObjectGroup GetGroupByPrim(uint localID)
|
||||
public SceneObjectGroup GetGroupByPrim(uint localID)
|
||||
{
|
||||
if (Entities.ContainsKey(localID))
|
||||
return Entities[localID] as SceneObjectGroup;
|
||||
@@ -1107,23 +1112,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
return UUID.Zero;
|
||||
}
|
||||
|
||||
protected internal void ForEachClient(Action<IClientAPI> action)
|
||||
{
|
||||
List<ScenePresence> splist = GetScenePresences();
|
||||
foreach (ScenePresence presence in splist)
|
||||
{
|
||||
try
|
||||
{
|
||||
action(presence.ControllingClient);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// Catch it and move on. This includes situations where splist has inconsistent info
|
||||
m_log.WarnFormat("[SCENE]: Problem processing action in ForEachClient: ", e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected internal void ForEachSOG(Action<SceneObjectGroup> action)
|
||||
{
|
||||
List<SceneObjectGroup> objlist = new List<SceneObjectGroup>(SceneObjectGroupsByFullID.Values);
|
||||
|
||||
@@ -906,7 +906,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
SetAttachmentPoint(Convert.ToByte(attachmentpoint));
|
||||
|
||||
avatar.AddAttachment(this);
|
||||
m_log.DebugFormat("[SOG]: Added att {0} to avie {1}", UUID, avatar.UUID);
|
||||
m_log.Debug("[SOG]: Added attachment " + UUID + " to avatar " + avatar.UUID);
|
||||
|
||||
if (!silent)
|
||||
{
|
||||
@@ -1824,7 +1824,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
public void ServiceObjectPropertiesFamilyRequest(IClientAPI remoteClient, UUID AgentID, uint RequestFlags)
|
||||
{
|
||||
|
||||
remoteClient.SendObjectPropertiesFamilyData(RequestFlags, RootPart.UUID, RootPart.ObjectOwner, RootPart.GroupID, RootPart.BaseMask,
|
||||
remoteClient.SendObjectPropertiesFamilyData(RequestFlags, RootPart.UUID, RootPart.OwnerID, RootPart.GroupID, RootPart.BaseMask,
|
||||
RootPart.OwnerMask, RootPart.GroupMask, RootPart.EveryoneMask, RootPart.NextOwnerMask,
|
||||
RootPart.OwnershipCost, RootPart.ObjectSaleType, RootPart.SalePrice, RootPart.Category,
|
||||
RootPart.CreatorID, RootPart.Name, RootPart.Description);
|
||||
@@ -3355,5 +3355,77 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public double GetUpdatePriority(IClientAPI client)
|
||||
{
|
||||
switch (Scene.UpdatePrioritizationScheme)
|
||||
{
|
||||
case Scene.UpdatePrioritizationSchemes.Time:
|
||||
return GetPriorityByTime();
|
||||
case Scene.UpdatePrioritizationSchemes.Distance:
|
||||
return GetPriorityByDistance(client);
|
||||
case Scene.UpdatePrioritizationSchemes.SimpleAngularDistance:
|
||||
return GetPriorityBySimpleAngularDistance(client);
|
||||
default:
|
||||
throw new InvalidOperationException("UpdatePrioritizationScheme not defined");
|
||||
}
|
||||
}
|
||||
|
||||
private double GetPriorityByTime()
|
||||
{
|
||||
return DateTime.Now.ToOADate();
|
||||
}
|
||||
|
||||
private double GetPriorityByDistance(IClientAPI client)
|
||||
{
|
||||
ScenePresence presence = Scene.GetScenePresence(client.AgentId);
|
||||
if (presence != null)
|
||||
{
|
||||
return GetPriorityByDistance((presence.IsChildAgent) ?
|
||||
presence.AbsolutePosition : presence.CameraPosition);
|
||||
}
|
||||
return double.NaN;
|
||||
}
|
||||
|
||||
private double GetPriorityBySimpleAngularDistance(IClientAPI client)
|
||||
{
|
||||
ScenePresence presence = Scene.GetScenePresence(client.AgentId);
|
||||
if (presence != null)
|
||||
{
|
||||
return GetPriorityBySimpleAngularDistance((presence.IsChildAgent) ?
|
||||
presence.AbsolutePosition : presence.CameraPosition);
|
||||
}
|
||||
return double.NaN;
|
||||
}
|
||||
|
||||
public double GetPriorityByDistance(Vector3 position)
|
||||
{
|
||||
return Vector3.Distance(AbsolutePosition, position);
|
||||
}
|
||||
|
||||
public double GetPriorityBySimpleAngularDistance(Vector3 position)
|
||||
{
|
||||
double distance = Vector3.Distance(position, AbsolutePosition);
|
||||
if (distance >= double.Epsilon)
|
||||
{
|
||||
float height;
|
||||
Vector3 box = GetAxisAlignedBoundingBox(out height);
|
||||
|
||||
double angle = box.X / distance;
|
||||
double max = angle;
|
||||
|
||||
angle = box.Y / distance;
|
||||
if (max < angle)
|
||||
max = angle;
|
||||
|
||||
angle = box.Z / distance;
|
||||
if (max < angle)
|
||||
max = angle;
|
||||
|
||||
return -max;
|
||||
}
|
||||
else
|
||||
return double.MinValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -841,16 +841,6 @@ if (m_shape != null) {
|
||||
return m_offsetPosition + m_groupPosition; }
|
||||
}
|
||||
|
||||
public UUID ObjectCreator
|
||||
{
|
||||
get { return _creatorID; }
|
||||
}
|
||||
|
||||
public UUID ObjectOwner
|
||||
{
|
||||
get { return _ownerID; }
|
||||
}
|
||||
|
||||
public SceneObjectGroup ParentGroup
|
||||
{
|
||||
get { return m_parentGroup; }
|
||||
@@ -1427,7 +1417,7 @@ if (m_shape != null) {
|
||||
// Move afterwards ResetIDs as it clears the localID
|
||||
dupe.LocalId = localID;
|
||||
// This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated.
|
||||
dupe._lastOwnerID = ObjectOwner;
|
||||
dupe._lastOwnerID = OwnerID;
|
||||
|
||||
byte[] extraP = new byte[Shape.ExtraParams.Length];
|
||||
Array.Copy(Shape.ExtraParams, extraP, extraP.Length);
|
||||
@@ -2388,10 +2378,10 @@ if (m_shape != null) {
|
||||
//isattachment = ParentGroup.RootPart.IsAttachment;
|
||||
|
||||
byte[] color = new byte[] {m_color.R, m_color.G, m_color.B, m_color.A};
|
||||
remoteClient.SendPrimitiveToClient(m_regionHandle, (ushort)(m_parentGroup.GetTimeDilation() * (float)ushort.MaxValue), LocalId, m_shape,
|
||||
remoteClient.SendPrimitiveToClient(new SendPrimitiveData(m_regionHandle, (ushort)(m_parentGroup.GetTimeDilation() * (float)ushort.MaxValue), LocalId, m_shape,
|
||||
lPos, Velocity, Acceleration, RotationOffset, RotationalVelocity, clientFlags, m_uuid, _ownerID,
|
||||
m_text, color, _parentID, m_particleSystem, m_clickAction, (byte)m_material, m_TextureAnimation, IsAttachment,
|
||||
AttachmentPoint,FromItemID, Sound, SoundGain, SoundFlags, SoundRadius);
|
||||
AttachmentPoint,FromItemID, Sound, SoundGain, SoundFlags, SoundRadius, ParentGroup.GetUpdatePriority(remoteClient)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -3764,13 +3754,15 @@ if (m_shape != null) {
|
||||
if (ParentGroup.RootPart == this)
|
||||
lPos = AbsolutePosition;
|
||||
}
|
||||
|
||||
remoteClient.SendPrimTerseUpdate(m_regionHandle,
|
||||
|
||||
// Causes this thread to dig into the Client Thread Data.
|
||||
// Remember your locking here!
|
||||
remoteClient.SendPrimTerseUpdate(new SendPrimitiveTerseData(m_regionHandle,
|
||||
(ushort)(m_parentGroup.GetTimeDilation() *
|
||||
(float)ushort.MaxValue), LocalId, lPos,
|
||||
RotationOffset, Velocity,
|
||||
RotationOffset, Velocity, Acceleration,
|
||||
RotationalVelocity, state, FromItemID,
|
||||
OwnerID, (int)AttachmentPoint);
|
||||
OwnerID, (int)AttachmentPoint, null, ParentGroup.GetUpdatePriority(remoteClient)));
|
||||
}
|
||||
|
||||
public void AddScriptLPS(int count)
|
||||
|
||||
@@ -871,12 +871,15 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
{
|
||||
foreach (IScriptModule e in engines)
|
||||
{
|
||||
string n = e.GetAssemblyName(item.ItemID);
|
||||
if (n != "")
|
||||
if (e != null)
|
||||
{
|
||||
if (!ret.Contains(n))
|
||||
ret.Add(n);
|
||||
break;
|
||||
string n = e.GetAssemblyName(item.ItemID);
|
||||
if (n != String.Empty)
|
||||
{
|
||||
if (!ret.Contains(n))
|
||||
ret.Add(n);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -898,12 +901,15 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
{
|
||||
foreach (IScriptModule e in engines)
|
||||
{
|
||||
string n = e.GetXMLState(item.ItemID);
|
||||
if (n != "")
|
||||
if (e != null)
|
||||
{
|
||||
if (!ret.ContainsKey(item.ItemID))
|
||||
ret[item.ItemID] = n;
|
||||
break;
|
||||
string n = e.GetXMLState(item.ItemID);
|
||||
if (n != String.Empty)
|
||||
{
|
||||
if (!ret.ContainsKey(item.ItemID))
|
||||
ret[item.ItemID] = n;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Timers;
|
||||
using OpenMetaverse;
|
||||
using log4net;
|
||||
using OpenSim.Framework;
|
||||
@@ -127,8 +128,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|
||||
private bool m_setAlwaysRun;
|
||||
|
||||
private bool m_updatesAllowed = true;
|
||||
private List<AgentUpdateArgs> m_agentUpdates = new List<AgentUpdateArgs>();
|
||||
private string m_movementAnimation = "DEFAULT";
|
||||
private long m_animPersistUntil = 0;
|
||||
private bool m_allowFalling = false;
|
||||
@@ -172,6 +171,11 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|
||||
// Position of agent's camera in world (region cordinates)
|
||||
protected Vector3 m_CameraCenter = Vector3.Zero;
|
||||
protected Vector3 m_lastCameraCenter = Vector3.Zero;
|
||||
|
||||
protected Timer m_reprioritization_timer;
|
||||
protected bool m_reprioritizing = false;
|
||||
protected bool m_reprioritization_called = false;
|
||||
|
||||
// Use these three vectors to figure out what the agent is looking at
|
||||
// Convert it to a Matrix and/or Quaternion
|
||||
@@ -403,12 +407,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
set { m_parentPosition = value; }
|
||||
}
|
||||
|
||||
public int MaxPrimsPerFrame
|
||||
{
|
||||
get { return m_sceneViewer.MaxPrimsPerFrame; }
|
||||
set { m_sceneViewer.MaxPrimsPerFrame = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Absolute position of this avatar in 'region cordinates'
|
||||
/// </summary>
|
||||
@@ -645,7 +643,14 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|
||||
m_scriptEngines = m_scene.RequestModuleInterfaces<IScriptModule>();
|
||||
|
||||
AbsolutePosition = m_controllingClient.StartPos;
|
||||
AbsolutePosition = posLastSignificantMove = m_CameraCenter =
|
||||
m_lastCameraCenter = m_controllingClient.StartPos;
|
||||
|
||||
m_reprioritization_timer = new Timer(world.ReprioritizationInterval);
|
||||
m_reprioritization_timer.Elapsed += new ElapsedEventHandler(Reprioritize);
|
||||
m_reprioritization_timer.AutoReset = false;
|
||||
|
||||
|
||||
AdjustKnownSeeds();
|
||||
|
||||
TrySetMovementAnimation("STAND"); // TODO: I think, this won't send anything, as we are still a child here...
|
||||
@@ -1083,34 +1088,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|
||||
}
|
||||
|
||||
// These methods allow to queue up agent updates (like key presses)
|
||||
// until all attachment scripts are running and the animations from
|
||||
// AgentDataUpdate have been started. It is essential for combat
|
||||
// devices, weapons and AOs that keypresses are not processed
|
||||
// until scripts that are potentially interested in them are
|
||||
// up and running and that animations a script knows to be running
|
||||
// from before a crossing are running again
|
||||
//
|
||||
public void LockAgentUpdates()
|
||||
{
|
||||
m_updatesAllowed = false;
|
||||
}
|
||||
|
||||
public void UnlockAgentUpdates()
|
||||
{
|
||||
lock (m_agentUpdates)
|
||||
{
|
||||
if (m_updatesAllowed == false)
|
||||
{
|
||||
foreach (AgentUpdateArgs a in m_agentUpdates)
|
||||
RealHandleAgentUpdate(ControllingClient, a);
|
||||
m_agentUpdates.Clear();
|
||||
m_updatesAllowed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Callback for the Camera view block check. Gets called with the results of the camera view block test
|
||||
/// hitYN is true when there's something in the way.
|
||||
@@ -1148,24 +1125,12 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
}
|
||||
}
|
||||
|
||||
Array m_dirControlFlags = Enum.GetValues(typeof(Dir_ControlFlags));
|
||||
|
||||
/// <summary>
|
||||
/// This is the event handler for client movement. If a client is moving, this event is triggering.
|
||||
/// </summary>
|
||||
public void HandleAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData)
|
||||
{
|
||||
lock (m_agentUpdates)
|
||||
{
|
||||
if (m_updatesAllowed)
|
||||
{
|
||||
RealHandleAgentUpdate(remoteClient, agentData);
|
||||
return;
|
||||
}
|
||||
|
||||
m_agentUpdates.Add(agentData);
|
||||
}
|
||||
}
|
||||
|
||||
private void RealHandleAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData)
|
||||
{
|
||||
//if (m_isChildAgent)
|
||||
//{
|
||||
@@ -1173,18 +1138,17 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
// return;
|
||||
//}
|
||||
|
||||
|
||||
m_movementUpdateCount++;
|
||||
if (m_movementUpdateCount >= int.MaxValue)
|
||||
m_movementUpdateCount = 1;
|
||||
m_perfMonMS = Environment.TickCount;
|
||||
|
||||
++m_movementUpdateCount;
|
||||
if (m_movementUpdateCount < 1)
|
||||
m_movementUpdateCount = 1;
|
||||
|
||||
// Must check for standing up even when PhysicsActor is null,
|
||||
// since sitting currently removes avatar from physical scene
|
||||
//m_log.Debug("agentPos:" + AbsolutePosition.ToString());
|
||||
|
||||
// This is irritating. Really.
|
||||
|
||||
if (!AbsolutePosition.IsFinite())
|
||||
{
|
||||
RemoveFromPhysicalScene();
|
||||
@@ -1205,19 +1169,17 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
{
|
||||
m_LastFinitePos = m_pos;
|
||||
}
|
||||
//m_physicsActor.AddForce(new PhysicsVector(999999999, 99999999, 999999999999999), true);
|
||||
|
||||
//m_physicsActor.AddForce(new PhysicsVector(999999999, 99999999, 999999999999999), true);
|
||||
|
||||
//ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
|
||||
//if (land != null)
|
||||
//{
|
||||
//if (land.landData.landingType == (byte)1 && land.landData.userLocation != Vector3.Zero)
|
||||
//{
|
||||
// agent.startpos = land.landData.userLocation;
|
||||
//}
|
||||
//if (land.landData.landingType == (byte)1 && land.landData.userLocation != Vector3.Zero)
|
||||
//{
|
||||
// agent.startpos = land.landData.userLocation;
|
||||
//}
|
||||
//}
|
||||
|
||||
m_perfMonMS = Environment.TickCount;
|
||||
|
||||
uint flags = agentData.ControlFlags;
|
||||
Quaternion bodyRotation = agentData.BodyRotation;
|
||||
@@ -1225,6 +1187,11 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
// Camera location in world. We'll need to raytrace
|
||||
// from this location from time to time.
|
||||
m_CameraCenter = agentData.CameraCenter;
|
||||
if (Vector3.Distance(m_lastCameraCenter, m_CameraCenter) >= Scene.RootReprioritizationDistance)
|
||||
{
|
||||
ReprioritizeUpdates();
|
||||
m_lastCameraCenter = m_CameraCenter;
|
||||
}
|
||||
|
||||
// Use these three vectors to figure out what the agent is looking at
|
||||
// Convert it to a Matrix and/or Quaternion
|
||||
@@ -1235,7 +1202,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
// The Agent's Draw distance setting
|
||||
m_DrawDistance = agentData.Far;
|
||||
|
||||
if ((flags & (uint) AgentManager.ControlFlags.AGENT_CONTROL_STAND_UP) != 0)
|
||||
if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_STAND_UP) != 0)
|
||||
{
|
||||
StandUp();
|
||||
}
|
||||
@@ -1243,14 +1210,13 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
// Check if Client has camera in 'follow cam' or 'build' mode.
|
||||
Vector3 camdif = (Vector3.One * m_bodyRot - Vector3.One * CameraRotation);
|
||||
|
||||
m_followCamAuto = ((m_CameraUpAxis.Z > 0.959f && m_CameraUpAxis.Z < 0.98f)
|
||||
m_followCamAuto = ((m_CameraUpAxis.Z > 0.959f && m_CameraUpAxis.Z < 0.98f)
|
||||
&& (Math.Abs(camdif.X) < 0.4f && Math.Abs(camdif.Y) < 0.4f)) ? true : false;
|
||||
|
||||
//m_log.DebugFormat("[FollowCam]: {0}", m_followCamAuto);
|
||||
// Raycast from the avatar's head to the camera to see if there's anything blocking the view
|
||||
if ((m_movementUpdateCount % NumMovementsBetweenRayCast) == 0 && m_scene.PhysicsScene.SupportsRayCast())
|
||||
{
|
||||
|
||||
if (m_followCamAuto)
|
||||
{
|
||||
Vector3 headadjustment = new Vector3(0, 0, 0.3f);
|
||||
@@ -1258,24 +1224,18 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
}
|
||||
}
|
||||
|
||||
m_mouseLook = (flags & (uint) AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0;
|
||||
|
||||
|
||||
|
||||
m_mouseLook = (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0;
|
||||
m_leftButtonDown = (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0;
|
||||
|
||||
|
||||
|
||||
lock (scriptedcontrols)
|
||||
{
|
||||
if (scriptedcontrols.Count > 0)
|
||||
{
|
||||
SendControlToScripts(flags);
|
||||
flags = RemoveIgnoredControls(flags, IgnoredControls);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (PhysicsActor == null)
|
||||
{
|
||||
return;
|
||||
@@ -1284,7 +1244,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
if (m_autopilotMoving)
|
||||
CheckAtSitTarget();
|
||||
|
||||
if ((flags & (uint) AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0)
|
||||
if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0)
|
||||
{
|
||||
// TODO: This doesn't prevent the user from walking yet.
|
||||
// Setting parent ID would fix this, if we knew what value
|
||||
@@ -1317,13 +1277,13 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
PhysicsActor.Flying = false;
|
||||
else
|
||||
PhysicsActor.Flying = ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0);
|
||||
|
||||
|
||||
if (PhysicsActor.Flying != oldflying)
|
||||
{
|
||||
update_movementflag = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (q != m_bodyRot)
|
||||
{
|
||||
m_bodyRot = q;
|
||||
@@ -1339,15 +1299,15 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|
||||
// use camera up angle when in mouselook and not flying or when holding the left mouse button down and not flying
|
||||
// this prevents 'jumping' in inappropriate situations.
|
||||
if ((m_mouseLook && !m_physicsActor.Flying) || (m_leftButtonDown && !m_physicsActor.Flying))
|
||||
if ((m_mouseLook && !m_physicsActor.Flying) || (m_leftButtonDown && !m_physicsActor.Flying))
|
||||
dirVectors = GetWalkDirectionVectors();
|
||||
else
|
||||
dirVectors = Dir_Vectors;
|
||||
|
||||
|
||||
foreach (Dir_ControlFlags DCF in Enum.GetValues(typeof (Dir_ControlFlags)))
|
||||
foreach (Dir_ControlFlags DCF in m_dirControlFlags)
|
||||
{
|
||||
if ((flags & (uint) DCF) != 0)
|
||||
if ((flags & (uint)DCF) != 0)
|
||||
{
|
||||
bResetMoveToPosition = true;
|
||||
DCFlagKeyPressed = true;
|
||||
@@ -1359,18 +1319,18 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
{
|
||||
// Why did I get this?
|
||||
}
|
||||
|
||||
if ((m_movementflag & (uint) DCF) == 0)
|
||||
|
||||
if ((m_movementflag & (uint)DCF) == 0)
|
||||
{
|
||||
m_movementflag += (byte) (uint) DCF;
|
||||
m_movementflag += (byte)(uint)DCF;
|
||||
update_movementflag = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((m_movementflag & (uint) DCF) != 0)
|
||||
if ((m_movementflag & (uint)DCF) != 0)
|
||||
{
|
||||
m_movementflag -= (byte) (uint) DCF;
|
||||
m_movementflag -= (byte)(uint)DCF;
|
||||
update_movementflag = true;
|
||||
}
|
||||
else
|
||||
@@ -1461,14 +1421,12 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
//Avoid system crash, can be slower but...
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Cause the avatar to stop flying if it's colliding
|
||||
// with something with the down arrow pressed.
|
||||
|
||||
@@ -1476,8 +1434,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
if (m_physicsActor != null && m_physicsActor.Flying && !m_forceFly)
|
||||
{
|
||||
// Are the landing controls requirements filled?
|
||||
bool controlland = (((flags & (uint) AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) ||
|
||||
((flags & (uint) AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0));
|
||||
bool controlland = (((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) ||
|
||||
((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0));
|
||||
|
||||
// Are the collision requirements fulfilled?
|
||||
bool colliding = (m_physicsActor.IsColliding == true);
|
||||
@@ -1490,10 +1448,10 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|
||||
if (update_movementflag || (update_rotation && DCFlagKeyPressed))
|
||||
{
|
||||
// m_log.DebugFormat("{0} {1}", update_movementflag, (update_rotation && DCFlagKeyPressed));
|
||||
// m_log.DebugFormat(
|
||||
// "In {0} adding velocity to {1} of {2}", m_scene.RegionInfo.RegionName, Name, agent_control_v3);
|
||||
|
||||
// m_log.DebugFormat("{0} {1}", update_movementflag, (update_rotation && DCFlagKeyPressed));
|
||||
// m_log.DebugFormat(
|
||||
// "In {0} adding velocity to {1} of {2}", m_scene.RegionInfo.RegionName, Name, agent_control_v3);
|
||||
|
||||
AddNewMovement(agent_control_v3, q);
|
||||
|
||||
if (update_movementflag)
|
||||
@@ -2456,11 +2414,10 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
m_perfMonMS = Environment.TickCount;
|
||||
|
||||
Vector3 pos = m_pos;
|
||||
Vector3 vel = Velocity;
|
||||
Quaternion rot = m_bodyRot;
|
||||
pos.Z -= m_appearance.HipOffset;
|
||||
remoteClient.SendAvatarTerseUpdate(m_regionHandle, (ushort)(m_scene.TimeDilation * ushort.MaxValue), LocalId, new Vector3(pos.X, pos.Y, pos.Z),
|
||||
new Vector3(vel.X, vel.Y, vel.Z), rot, m_uuid);
|
||||
|
||||
remoteClient.SendAvatarTerseUpdate(new SendAvatarTerseData(m_regionHandle, (ushort)(m_scene.TimeDilation * ushort.MaxValue), LocalId,
|
||||
pos, m_velocity, Vector3.Zero, m_rotation, Vector4.Zero, m_uuid, null, GetUpdatePriority(remoteClient)));
|
||||
|
||||
m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS);
|
||||
m_scene.StatsReporter.AddAgentUpdates(1);
|
||||
@@ -2474,7 +2431,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
{
|
||||
m_perfMonMS = Environment.TickCount;
|
||||
|
||||
m_scene.Broadcast(SendTerseUpdateToClient);
|
||||
m_scene.ForEachClient(SendTerseUpdateToClient);
|
||||
|
||||
m_lastVelocity = m_velocity;
|
||||
lastPhysPos = AbsolutePosition;
|
||||
@@ -2566,9 +2523,9 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
Vector3 pos = m_pos;
|
||||
pos.Z -= m_appearance.HipOffset;
|
||||
|
||||
remoteAvatar.m_controllingClient.SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid,
|
||||
remoteAvatar.m_controllingClient.SendAvatarData(new SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid,
|
||||
LocalId, m_pos, m_appearance.Texture.GetBytes(),
|
||||
m_parentID, rot);
|
||||
m_parentID, rot));
|
||||
m_scene.StatsReporter.AddAgentUpdates(1);
|
||||
}
|
||||
|
||||
@@ -2637,8 +2594,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
Vector3 pos = m_pos;
|
||||
pos.Z -= m_appearance.HipOffset;
|
||||
|
||||
m_controllingClient.SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid, LocalId,
|
||||
m_pos, m_appearance.Texture.GetBytes(), m_parentID, rot);
|
||||
m_controllingClient.SendAvatarData(new SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid, LocalId,
|
||||
m_pos, m_appearance.Texture.GetBytes(), m_parentID, rot));
|
||||
|
||||
if (!m_isChildAgent)
|
||||
{
|
||||
@@ -2744,8 +2701,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
}
|
||||
|
||||
Quaternion rot = m_bodyRot;
|
||||
m_controllingClient.SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid, LocalId,
|
||||
m_pos, m_appearance.Texture.GetBytes(), m_parentID, rot);
|
||||
m_controllingClient.SendAvatarData(new SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid, LocalId,
|
||||
m_pos, m_appearance.Texture.GetBytes(), m_parentID, rot));
|
||||
|
||||
}
|
||||
|
||||
@@ -2776,7 +2733,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
if (m_isChildAgent)
|
||||
return;
|
||||
|
||||
m_scene.Broadcast(
|
||||
m_scene.ForEachClient(
|
||||
delegate(IClientAPI client) { client.SendAnimations(animations, seqs, m_controllingClient.AgentId, objectIDs); });
|
||||
}
|
||||
|
||||
@@ -2830,7 +2787,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
}
|
||||
|
||||
// Minimum Draw distance is 64 meters, the Radius of the draw distance sphere is 32m
|
||||
if (Util.GetDistanceTo(AbsolutePosition,m_LastChildAgentUpdatePosition) > 32)
|
||||
if (Util.GetDistanceTo(AbsolutePosition, m_LastChildAgentUpdatePosition) >= Scene.ChildReprioritizationDistance)
|
||||
{
|
||||
ChildAgentDataUpdate cadu = new ChildAgentDataUpdate();
|
||||
cadu.ActiveGroupID = UUID.Zero.Guid;
|
||||
@@ -3125,6 +3082,12 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
if (cAgentData.Position != new Vector3(-1, -1, -1)) // UGH!!
|
||||
m_pos = new Vector3(cAgentData.Position.X + shiftx, cAgentData.Position.Y + shifty, cAgentData.Position.Z);
|
||||
|
||||
if (Vector3.Distance(AbsolutePosition, posLastSignificantMove) >= Scene.ChildReprioritizationDistance)
|
||||
{
|
||||
posLastSignificantMove = AbsolutePosition;
|
||||
ReprioritizeUpdates();
|
||||
}
|
||||
|
||||
// It's hard to say here.. We can't really tell where the camera position is unless it's in world cordinates from the sending region
|
||||
m_CameraCenter = cAgentData.Center;
|
||||
|
||||
@@ -3487,7 +3450,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|
||||
public void Close()
|
||||
{
|
||||
|
||||
lock (m_attachments)
|
||||
{
|
||||
// Delete attachments from scene
|
||||
@@ -3505,10 +3467,19 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
{
|
||||
m_knownChildRegions.Clear();
|
||||
}
|
||||
|
||||
lock (m_reprioritization_timer)
|
||||
{
|
||||
m_reprioritization_timer.Enabled = false;
|
||||
m_reprioritization_timer.Elapsed -= new ElapsedEventHandler(Reprioritize);
|
||||
}
|
||||
// I don't get it but mono crashes when you try to dispose of this timer,
|
||||
// unsetting the elapsed callback should be enough to allow for cleanup however.
|
||||
//m_reprioritizationTimer.Dispose();
|
||||
|
||||
m_sceneViewer.Close();
|
||||
|
||||
RemoveFromPhysicalScene();
|
||||
GC.Collect();
|
||||
}
|
||||
|
||||
public ScenePresence()
|
||||
@@ -3884,5 +3855,115 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public double GetUpdatePriority(IClientAPI client)
|
||||
{
|
||||
switch (Scene.UpdatePrioritizationScheme)
|
||||
{
|
||||
case Scene.UpdatePrioritizationSchemes.Time:
|
||||
return GetPriorityByTime();
|
||||
case Scene.UpdatePrioritizationSchemes.Distance:
|
||||
return GetPriorityByDistance(client);
|
||||
case Scene.UpdatePrioritizationSchemes.SimpleAngularDistance:
|
||||
return GetPriorityByDistance(client);
|
||||
default:
|
||||
throw new InvalidOperationException("UpdatePrioritizationScheme not defined.");
|
||||
}
|
||||
}
|
||||
|
||||
private double GetPriorityByTime()
|
||||
{
|
||||
return DateTime.Now.ToOADate();
|
||||
}
|
||||
|
||||
private double GetPriorityByDistance(IClientAPI client)
|
||||
{
|
||||
ScenePresence presence = Scene.GetScenePresence(client.AgentId);
|
||||
if (presence != null)
|
||||
{
|
||||
return GetPriorityByDistance((presence.IsChildAgent) ?
|
||||
presence.AbsolutePosition : presence.CameraPosition);
|
||||
}
|
||||
return double.NaN;
|
||||
}
|
||||
|
||||
private double GetPriorityByDistance(Vector3 position)
|
||||
{
|
||||
return Vector3.Distance(AbsolutePosition, position);
|
||||
}
|
||||
|
||||
private double GetSOGUpdatePriority(SceneObjectGroup sog)
|
||||
{
|
||||
switch (Scene.UpdatePrioritizationScheme)
|
||||
{
|
||||
case Scene.UpdatePrioritizationSchemes.Time:
|
||||
throw new InvalidOperationException("UpdatePrioritizationScheme for time not supported for reprioritization");
|
||||
case Scene.UpdatePrioritizationSchemes.Distance:
|
||||
return sog.GetPriorityByDistance((IsChildAgent) ? AbsolutePosition : CameraPosition);
|
||||
case Scene.UpdatePrioritizationSchemes.SimpleAngularDistance:
|
||||
return sog.GetPriorityBySimpleAngularDistance((IsChildAgent) ? AbsolutePosition : CameraPosition);
|
||||
default:
|
||||
throw new InvalidOperationException("UpdatePrioritizationScheme not defined");
|
||||
}
|
||||
}
|
||||
|
||||
private double UpdatePriority(UpdatePriorityData data)
|
||||
{
|
||||
EntityBase entity;
|
||||
SceneObjectGroup group;
|
||||
|
||||
if (Scene.Entities.TryGetValue(data.localID, out entity))
|
||||
{
|
||||
group = entity as SceneObjectGroup;
|
||||
if (group != null)
|
||||
return GetSOGUpdatePriority(group);
|
||||
|
||||
ScenePresence presence = entity as ScenePresence;
|
||||
if (presence == null)
|
||||
throw new InvalidOperationException("entity found is neither SceneObjectGroup nor ScenePresence");
|
||||
switch (Scene.UpdatePrioritizationScheme)
|
||||
{
|
||||
case Scene.UpdatePrioritizationSchemes.Time:
|
||||
throw new InvalidOperationException("UpdatePrioritization for time not supported for reprioritization");
|
||||
case Scene.UpdatePrioritizationSchemes.Distance:
|
||||
case Scene.UpdatePrioritizationSchemes.SimpleAngularDistance:
|
||||
return GetPriorityByDistance((IsChildAgent) ? AbsolutePosition : CameraPosition);
|
||||
default:
|
||||
throw new InvalidOperationException("UpdatePrioritizationScheme not defined");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
group = Scene.SceneGraph.GetGroupByPrim(data.localID);
|
||||
if (group != null)
|
||||
return GetSOGUpdatePriority(group);
|
||||
}
|
||||
return double.NaN;
|
||||
}
|
||||
|
||||
private void ReprioritizeUpdates()
|
||||
{
|
||||
if (Scene.IsReprioritizationEnabled && Scene.UpdatePrioritizationScheme != Scene.UpdatePrioritizationSchemes.Time)
|
||||
{
|
||||
lock (m_reprioritization_timer)
|
||||
{
|
||||
if (!m_reprioritizing)
|
||||
m_reprioritization_timer.Enabled = m_reprioritizing = true;
|
||||
else
|
||||
m_reprioritization_called = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Reprioritize(object sender, ElapsedEventArgs e)
|
||||
{
|
||||
m_controllingClient.ReprioritizeUpdates(StateUpdateTypes.All, UpdatePriority);
|
||||
|
||||
lock (m_reprioritization_timer)
|
||||
{
|
||||
m_reprioritization_timer.Enabled = m_reprioritizing = m_reprioritization_called;
|
||||
m_reprioritization_called = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,14 +45,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|
||||
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()
|
||||
{
|
||||
}
|
||||
@@ -82,16 +74,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
{
|
||||
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)
|
||||
foreach (EntityBase e in m_presence.Scene.Entities)
|
||||
{
|
||||
if (e is SceneObjectGroup)
|
||||
m_pendingObjects.Enqueue((SceneObjectGroup)e);
|
||||
@@ -99,7 +82,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
}
|
||||
}
|
||||
|
||||
while (m_pendingObjects != null && m_pendingObjects.Count > 0 && m_partsUpdateQueue.Count < m_maxPrimsPerFrame)
|
||||
while (m_pendingObjects != null && m_pendingObjects.Count > 0)
|
||||
{
|
||||
SceneObjectGroup g = m_pendingObjects.Dequeue();
|
||||
|
||||
@@ -183,8 +166,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
m_presence.GenerateClientFlags(part.UUID));
|
||||
}
|
||||
}
|
||||
|
||||
m_presence.ControllingClient.FlushPrimUpdates();
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
|
||||
@@ -35,8 +35,8 @@ namespace OpenSim.Region.Framework.Scenes.Scripting
|
||||
string Description { get; set; }
|
||||
|
||||
UUID UUID { get; }
|
||||
UUID ObjectOwner { get; }
|
||||
UUID ObjectCreator { get; }
|
||||
UUID OwnerID { get; }
|
||||
UUID CreatorID { get; }
|
||||
Vector3 AbsolutePosition { get; }
|
||||
|
||||
string SitName { get; set; }
|
||||
|
||||
@@ -68,12 +68,12 @@ namespace OpenSim.Region.Framework.Scenes.Scripting
|
||||
get { return UUID.Zero; }
|
||||
}
|
||||
|
||||
public UUID ObjectOwner
|
||||
public UUID OwnerID
|
||||
{
|
||||
get { return UUID.Zero; }
|
||||
}
|
||||
|
||||
public UUID ObjectCreator
|
||||
public UUID CreatorID
|
||||
{
|
||||
get { return UUID.Zero; }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user