From 52decfcc16bab0332798745d59c43277f1c034b6 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Tue, 26 Jul 2016 21:39:47 +0100
Subject: reduce some grid services calls on region crossings, sending more
information on the agent update ( groups v2 needs change )
---
.../EntityTransfer/EntityTransferModule.cs | 74 +------------
OpenSim/Region/Framework/Scenes/ScenePresence.cs | 115 ++++++++++++++++-----
.../Avatar/XmlRpcGroups/GroupsModule.cs | 3 +-
3 files changed, 96 insertions(+), 96 deletions(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
index 696d1dd..a14fb25 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
@@ -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
- ///
- /// 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.
- ///
- /// the scene object that we're crossing
- /// the attempted out of region position of the scene object. This position is
- /// relative to the region the object currently is in.
- /// if 'true', the deletion of the client from the region is not broadcast to the clients
- 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(oldGroupPosition.X, 1.0f, (float)(scene.RegionInfo.RegionSizeX - 1));
- oldGroupPosition.Y = Util.Clamp(oldGroupPosition.Y, 1.0f, (float)(scene.RegionInfo.RegionSizeY - 1));
- oldGroupPosition.Z = Util.Clamp(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();
- }
- }
-*/
///
/// Move the given scene object into a new region
///
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 0ccdbf7..c925719 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -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;
- ///
- /// 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.
- ///
- 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();
- if (gm != null)
- Grouptitle = gm.GetGroupTitle(m_uuid);
+ // IGroupsModule gm = m_scene.RequestModuleInterface();
+ // if (gm != null)
+ // Grouptitle = gm.GetGroupTitle(m_uuid);
m_scriptEngines = m_scene.RequestModuleInterfaces();
@@ -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();
- 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
///
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));
+ if(!haveGroupInformation && !IsChildAgent && !isNPC)
+ {
+ // oh crap.. lets retry it directly
+ IGroupsModule gm = m_scene.RequestModuleInterface();
+ if (gm != null)
+ Grouptitle = gm.GetGroupTitle(m_uuid);
-// start sending terrain patchs
- if (!isNPC)
- Scene.SendLayerData(ControllingClient);
+ m_log.DebugFormat("[CompleteMovement] Missing Grouptitle: {0}ms", Util.EnvironmentTickCountSubtract(ts));
- if (!IsChildAgent && !isNPC)
- {
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 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 gpowers = new Dictionary(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;
}
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
index ddeac66..5205eae 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
@@ -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)
--
cgit v1.1