reduce some grid services calls on region crossings, sending more information on the agent update ( groups v2 needs change )

LSLKeyTest
UbitUmarov 2016-07-26 21:39:47 +01:00
parent 1a8a8e16ef
commit 52decfcc16
4 changed files with 122 additions and 150 deletions

View File

@ -353,6 +353,10 @@ namespace OpenSim.Framework
public UUID PreyAgent;
public Byte AgentAccess;
public UUID ActiveGroupID;
public string ActiveGroupName;
public string ActiveGroupTitle = null;
public UUID agentCOF;
public bool isCrossingUpdate;
public AgentGroupData[] Groups;
public Dictionary<ulong, string> ChildrenCapSeeds = null;
@ -374,12 +378,6 @@ namespace OpenSim.Framework
MethodBase.GetCurrentMethod().DeclaringType);
// DEBUG OFF
/*
public byte[] AgentTextures;
public byte[] VisualParams;
public UUID[] Wearables;
public AvatarAttachment[] Attachments;
*/
// Scripted
public ControllerData[] Controllers;
@ -393,8 +391,6 @@ namespace OpenSim.Framework
public virtual OSDMap Pack(EntityTransferContext ctx)
{
int wearablesCount = -1;
// m_log.InfoFormat("[CHILDAGENTDATAUPDATE] Pack data");
OSDMap args = new OSDMap();
@ -433,8 +429,14 @@ namespace OpenSim.Framework
args["prey_agent"] = OSD.FromUUID(PreyAgent);
args["agent_access"] = OSD.FromString(AgentAccess.ToString());
args["agent_cof"] = OSD.FromUUID(agentCOF);
args["crossingupdate"] = OSD.FromBoolean(isCrossingUpdate);
args["active_group_id"] = OSD.FromUUID(ActiveGroupID);
args["active_group_name"] = OSD.FromString(ActiveGroupName);
if(ActiveGroupTitle != null)
args["active_group_title"] = OSD.FromString(ActiveGroupTitle);
if ((Groups != null) && (Groups.Length > 0))
{
OSDArray groups = new OSDArray(Groups.Length);
@ -497,48 +499,6 @@ namespace OpenSim.Framework
if (Appearance != null)
args["packed_appearance"] = Appearance.Pack(ctx);
//if ((AgentTextures != null) && (AgentTextures.Length > 0))
//{
// OSDArray textures = new OSDArray(AgentTextures.Length);
// foreach (UUID uuid in AgentTextures)
// textures.Add(OSD.FromUUID(uuid));
// args["agent_textures"] = textures;
//}
// The code to pack textures, visuals, wearables and attachments
// should be removed; packed appearance contains the full appearance
// This is retained for backward compatibility only
/* then lets remove
if (Appearance.Texture != null)
{
byte[] rawtextures = Appearance.Texture.GetBytes();
args["texture_entry"] = OSD.FromBinary(rawtextures);
}
if ((Appearance.VisualParams != null) && (Appearance.VisualParams.Length > 0))
args["visual_params"] = OSD.FromBinary(Appearance.VisualParams);
// We might not pass this in all cases...
if ((Appearance.Wearables != null) && (Appearance.Wearables.Length > 0))
{
OSDArray wears = new OSDArray(Appearance.Wearables.Length);
foreach (AvatarWearable awear in Appearance.Wearables)
wears.Add(awear.Pack());
args["wearables"] = wears;
}
List<AvatarAttachment> attachments = Appearance.GetAttachments();
if ((attachments != null) && (attachments.Count > 0))
{
OSDArray attachs = new OSDArray(attachments.Count);
foreach (AvatarAttachment att in attachments)
attachs.Add(att.Pack());
args["attachments"] = attachs;
}
// End of code to remove
*/
if ((Controllers != null) && (Controllers.Length > 0))
{
OSDArray controls = new OSDArray(Controllers.Length);
@ -662,10 +622,22 @@ namespace OpenSim.Framework
if (args["agent_access"] != null)
Byte.TryParse(args["agent_access"].AsString(), out AgentAccess);
if (args["active_group_id"] != null)
if (args.ContainsKey("agent_cof") && args["agent_cof"] != null)
agentCOF = args["agent_cof"].AsUUID();
if (args.ContainsKey("crossingupdate") && args["crossingupdate"] != null)
isCrossingUpdate = args["crossingupdate"].AsBoolean();
if (args.ContainsKey("active_group_id") && args["active_group_id"] != null)
ActiveGroupID = args["active_group_id"].AsUUID();
if ((args["groups"] != null) && (args["groups"]).Type == OSDType.Array)
if (args.ContainsKey("active_group_name") && args["active_group_name"] != null)
ActiveGroupName = args["active_group_name"].AsString();
if(args.ContainsKey("active_group_title") && args["active_group_title"] != null)
ActiveGroupTitle = args["active_group_title"].AsString();
if (args.ContainsKey("groups") && (args["groups"] != null) && (args["groups"]).Type == OSDType.Array)
{
OSDArray groups = (OSDArray)(args["groups"]);
Groups = new AgentGroupData[groups.Count];

View File

@ -922,7 +922,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
// Let's send a full update of the agent. This is a synchronous call.
AgentData agent = new AgentData();
sp.CopyTo(agent);
sp.CopyTo(agent,false);
if ((teleportFlags & (uint)TeleportFlags.IsFlying) != 0)
agent.ControlFlags |= (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY;
@ -1142,7 +1142,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
// Let's send a full update of the agent.
AgentData agent = new AgentData();
sp.CopyTo(agent);
sp.CopyTo(agent,false);
agent.Position = agentCircuit.startpos;
if ((teleportFlags & (uint)TeleportFlags.IsFlying) != 0)
@ -1701,7 +1701,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
try
{
AgentData cAgent = new AgentData();
agent.CopyTo(cAgent);
agent.CopyTo(cAgent,true);
// agent.Appearance.WearableCacheItems = null;
@ -2534,11 +2534,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
if (newRegionSizeY == 0)
newRegionSizeY = Constants.RegionSize;
newpos.X = targetPosition.X - (neighbourRegion.RegionLocX - (int)scene.RegionInfo.WorldLocX);
newpos.Y = targetPosition.Y - (neighbourRegion.RegionLocY - (int)scene.RegionInfo.WorldLocY);
const float enterDistance = 0.2f;
newpos.X = Util.Clamp(newpos.X, enterDistance, newRegionSizeX - enterDistance);
newpos.Y = Util.Clamp(newpos.Y, enterDistance, newRegionSizeY - enterDistance);
@ -2546,72 +2544,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
return neighbourRegion;
}
/* not in use. -> CrossPrimGroupIntoNewRegion
/// <summary>
/// Move the given scene object into a new region depending on which region its absolute position has moved
/// into.
///
/// Using the objects new world location, ask the grid service for a the new region and adjust the prim
/// position to be relative to the new region.
/// </summary>
/// <param name="grp">the scene object that we're crossing</param>
/// <param name="attemptedPosition">the attempted out of region position of the scene object. This position is
/// relative to the region the object currently is in.</param>
/// <param name="silent">if 'true', the deletion of the client from the region is not broadcast to the clients</param>
public void Cross(SceneObjectGroup grp, Vector3 attemptedPosition, bool silent)
{
if (grp == null)
return;
if (grp.IsDeleted)
return;
Scene scene = grp.Scene;
if (scene == null)
return;
// Remember the old group position in case the region lookup fails so position can be restored.
Vector3 oldGroupPosition = grp.RootPart.GroupPosition;
// Compute the absolute position of the object.
double objectWorldLocX = (double)scene.RegionInfo.WorldLocX + attemptedPosition.X;
double objectWorldLocY = (double)scene.RegionInfo.WorldLocY + attemptedPosition.Y;
// Ask the grid service for the region that contains the passed address
GridRegion destination = GetRegionContainingWorldLocation(scene.GridService, scene.RegionInfo.ScopeID,
objectWorldLocX, objectWorldLocY);
Vector3 pos = Vector3.Zero;
if (destination != null)
{
// Adjust the object's relative position from the old region (attemptedPosition)
// to be relative to the new region (pos).
pos = new Vector3( (float)(objectWorldLocX - (double)destination.RegionLocX),
(float)(objectWorldLocY - (double)destination.RegionLocY),
attemptedPosition.Z);
}
if (destination == null || !CrossPrimGroupIntoNewRegion(destination, pos, grp, silent))
{
m_log.InfoFormat("[ENTITY TRANSFER MODULE] cross region transfer failed for object {0}", grp.UUID);
// We are going to move the object back to the old position so long as the old position
// is in the region
oldGroupPosition.X = Util.Clamp<float>(oldGroupPosition.X, 1.0f, (float)(scene.RegionInfo.RegionSizeX - 1));
oldGroupPosition.Y = Util.Clamp<float>(oldGroupPosition.Y, 1.0f, (float)(scene.RegionInfo.RegionSizeY - 1));
oldGroupPosition.Z = Util.Clamp<float>(oldGroupPosition.Z, 1.0f, Constants.RegionHeight);
grp.AbsolutePosition = oldGroupPosition;
grp.Velocity = Vector3.Zero;
if (grp.RootPart.PhysActor != null)
grp.RootPart.PhysActor.CrossingFailure();
if (grp.RootPart.KeyframeMotion != null)
grp.RootPart.KeyframeMotion.CrossingFailure();
grp.ScheduleGroupForFullUpdate();
}
}
*/
/// <summary>
/// Move the given scene object into a new region
/// </summary>

View File

@ -346,7 +346,7 @@ namespace OpenSim.Region.Framework.Scenes
private float m_healRate = 1f;
private float m_healRatePerFrame = 0.05f;
protected ulong crossingFromRegion;
// protected ulong crossingFromRegion;
private readonly Vector3[] Dir_Vectors = new Vector3[12];
@ -568,19 +568,16 @@ namespace OpenSim.Region.Framework.Scenes
public string Firstname { get; private set; }
public string Lastname { get; private set; }
public bool haveGroupInformation;
public bool gotCrossUpdate;
public string Grouptitle
{
get { return UseFakeGroupTitle ? "(Loading)" : m_groupTitle; }
get { return m_groupTitle; }
set { m_groupTitle = value; }
}
private string m_groupTitle;
/// <summary>
/// When this is 'true', return a dummy group title instead of the real group title. This is
/// used as part of a hack to force viewers to update the displayed avatar name.
/// </summary>
public bool UseFakeGroupTitle { get; set; }
// Agent's Draw distance.
private float m_drawDistance = 255f;
public float DrawDistance
@ -1062,9 +1059,9 @@ namespace OpenSim.Region.Framework.Scenes
if (account != null)
UserLevel = account.UserLevel;
IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>();
if (gm != null)
Grouptitle = gm.GetGroupTitle(m_uuid);
// IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>();
// if (gm != null)
// Grouptitle = gm.GetGroupTitle(m_uuid);
m_scriptEngines = m_scene.RequestModuleInterfaces<IScriptModule>();
@ -1258,11 +1255,6 @@ namespace OpenSim.Region.Framework.Scenes
// Should not be needed if we are not trying to tell this region to close
// DoNotCloseAfterTeleport = false;
IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>();
if (gm != null)
Grouptitle = gm.GetGroupTitle(m_uuid);
m_log.DebugFormat("[MakeRootAgent] Grouptitle: {0}ms", Util.EnvironmentTickCountSubtract(ts));
RegionHandle = m_scene.RegionInfo.RegionHandle;
@ -1511,6 +1503,8 @@ namespace OpenSim.Region.Framework.Scenes
/// </remarks>
public void MakeChildAgent(ulong newRegionHandle)
{
haveGroupInformation = false;
gotCrossUpdate = false;
m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd;
RegionHandle = newRegionHandle;
@ -1978,25 +1972,29 @@ namespace OpenSim.Region.Framework.Scenes
m_log.DebugFormat("[CompleteMovement] MakeRootAgent: {0}ms", Util.EnvironmentTickCountSubtract(ts));
// start sending terrain patchs
if (!isNPC)
Scene.SendLayerData(ControllingClient);
if (!IsChildAgent && !isNPC)
if(!haveGroupInformation && !IsChildAgent && !isNPC)
{
// oh crap.. lets retry it directly
IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>();
if (gm != null)
Grouptitle = gm.GetGroupTitle(m_uuid);
m_log.DebugFormat("[CompleteMovement] Missing Grouptitle: {0}ms", Util.EnvironmentTickCountSubtract(ts));
InventoryFolderBase cof = m_scene.InventoryService.GetFolderForType(client.AgentId, (FolderType)46);
if (cof == null)
COF = UUID.Zero;
else
COF = cof.ID;
m_log.DebugFormat("[ScenePresence]: CompleteMovement COF for {0} is {1}", client.AgentId, COF);
m_log.DebugFormat("[CompleteMovement]: Missing COF for {0} is {1}", client.AgentId, COF);
}
// Tell the client that we're totally ready
ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look);
m_log.DebugFormat("[CompleteMovement] MoveAgentIntoRegion: {0}ms", Util.EnvironmentTickCountSubtract(ts));
if (!string.IsNullOrEmpty(m_callbackURI))
@ -2029,6 +2027,10 @@ namespace OpenSim.Region.Framework.Scenes
m_log.DebugFormat("[CompleteMovement] ReleaseAgent: {0}ms", Util.EnvironmentTickCountSubtract(ts));
// start sending terrain patchs
if (!gotCrossUpdate && !isNPC)
Scene.SendLayerData(ControllingClient);
m_previusParcelHide = false;
m_previusParcelUUID = UUID.Zero;
m_currentParcelHide = false;
@ -2204,6 +2206,9 @@ namespace OpenSim.Region.Framework.Scenes
// m_currentParcelHide = newhide;
// }
haveGroupInformation = true;
gotCrossUpdate = false;
m_scene.EventManager.OnRegionHeartbeatEnd += RegionHeartbeatEnd;
m_log.DebugFormat("[CompleteMovement] end: {0}ms", Util.EnvironmentTickCountSubtract(ts));
@ -4470,7 +4475,7 @@ namespace OpenSim.Region.Framework.Scenes
checkRePrioritization();
}
public void CopyTo(AgentData cAgent)
public void CopyTo(AgentData cAgent, bool isCrossUpdate)
{
cAgent.CallbackURI = m_callbackURI;
@ -4534,6 +4539,29 @@ namespace OpenSim.Region.Framework.Scenes
if (Scene.AttachmentsModule != null)
Scene.AttachmentsModule.CopyAttachments(this, cAgent);
cAgent.isCrossingUpdate = isCrossUpdate;
if(isCrossUpdate && haveGroupInformation)
{
cAgent.agentCOF = COF;
cAgent.ActiveGroupID = ControllingClient.ActiveGroupId;
cAgent.ActiveGroupName = ControllingClient.ActiveGroupName;
cAgent.ActiveGroupTitle = Grouptitle;
Dictionary<UUID, ulong> gpowers = ControllingClient.GetGroupPowers();
if(gpowers.Count >0)
{
cAgent.Groups = new AgentGroupData[gpowers.Count];
int i = 0;
foreach (UUID gid in gpowers.Keys)
{
// WARNING we dont' have AcceptNotices in cache.. sending as true mb no one notices ;)
AgentGroupData agd = new AgentGroupData(gid,gpowers[gid],true);
cAgent.Groups[i++] = agd;
}
}
}
}
private void CopyFrom(AgentData cAgent)
@ -4629,6 +4657,45 @@ namespace OpenSim.Region.Framework.Scenes
if (Scene.AttachmentsModule != null)
Scene.AttachmentsModule.CopyAttachments(cAgent, this);
haveGroupInformation = false;
// using this as protocol detection don't want to mess with the numbers for now
if(cAgent.ActiveGroupTitle != null)
{
COF = cAgent.agentCOF;
ControllingClient.ActiveGroupId = cAgent.ActiveGroupID;
ControllingClient.ActiveGroupName = cAgent.ActiveGroupName;
ControllingClient.ActiveGroupPowers = 0;
Grouptitle = cAgent.ActiveGroupTitle;
int ngroups = cAgent.Groups.Length;
if(ngroups > 0)
{
Dictionary<UUID, ulong> gpowers = new Dictionary<UUID, ulong>(ngroups);
for(int i = 0 ; i < ngroups; i++)
{
AgentGroupData agd = cAgent.Groups[i];
gpowers[agd.GroupID] = agd.GroupPowers;
}
ControllingClient.SetGroupPowers(gpowers);
if(cAgent.ActiveGroupID == UUID.Zero)
haveGroupInformation = true;
else if(gpowers.ContainsKey(cAgent.ActiveGroupID))
{
ControllingClient.ActiveGroupPowers = gpowers[cAgent.ActiveGroupID];
haveGroupInformation = true;
}
}
else if(cAgent.ActiveGroupID == UUID.Zero)
{
haveGroupInformation = true;
}
}
gotCrossUpdate = cAgent.isCrossingUpdate;
lock (m_originRegionIDAccessLock)
m_originRegionID = cAgent.RegionID;
}
@ -4636,7 +4703,7 @@ namespace OpenSim.Region.Framework.Scenes
public bool CopyAgent(out IAgentData agent)
{
agent = new CompleteAgentData();
CopyTo((AgentData)agent);
CopyTo((AgentData)agent, false);
return true;
}

View File

@ -278,7 +278,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
// There might be some problem with the thread we're generating this on but not
// doing the update at this time causes problems (Mantis #7920 and #7915)
// TODO: move sending this update to a later time in the rootification of the client.
SendAgentGroupDataUpdate(sp.ControllingClient, false);
if(!sp.haveGroupInformation)
SendAgentGroupDataUpdate(sp.ControllingClient, false);
}
private void OnMakeChild(ScenePresence sp)