aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes')
-rw-r--r--OpenSim/Region/Framework/Scenes/Prioritizer.cs48
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs10
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs42
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs7
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs237
5 files changed, 183 insertions, 161 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Prioritizer.cs b/OpenSim/Region/Framework/Scenes/Prioritizer.cs
index e3ed905..4595a29 100644
--- a/OpenSim/Region/Framework/Scenes/Prioritizer.cs
+++ b/OpenSim/Region/Framework/Scenes/Prioritizer.cs
@@ -119,16 +119,40 @@ namespace OpenSim.Region.Framework.Scenes
119 119
120 private uint GetPriorityByTime(IClientAPI client, ISceneEntity entity) 120 private uint GetPriorityByTime(IClientAPI client, ISceneEntity entity)
121 { 121 {
122 return 1; 122 // And anything attached to this avatar gets top priority as well
123 if (entity is SceneObjectPart)
124 {
125 SceneObjectPart sop = (SceneObjectPart)entity;
126 if (sop.ParentGroup.RootPart.IsAttachment && client.AgentId == sop.ParentGroup.RootPart.AttachedAvatar)
127 return 1;
128 }
129
130 return PriorityQueue.NumberOfImmediateQueues; // first queue past the immediate queues
123 } 131 }
124 132
125 private uint GetPriorityByDistance(IClientAPI client, ISceneEntity entity) 133 private uint GetPriorityByDistance(IClientAPI client, ISceneEntity entity)
126 { 134 {
135 // And anything attached to this avatar gets top priority as well
136 if (entity is SceneObjectPart)
137 {
138 SceneObjectPart sop = (SceneObjectPart)entity;
139 if (sop.ParentGroup.RootPart.IsAttachment && client.AgentId == sop.ParentGroup.RootPart.AttachedAvatar)
140 return 1;
141 }
142
127 return ComputeDistancePriority(client,entity,false); 143 return ComputeDistancePriority(client,entity,false);
128 } 144 }
129 145
130 private uint GetPriorityByFrontBack(IClientAPI client, ISceneEntity entity) 146 private uint GetPriorityByFrontBack(IClientAPI client, ISceneEntity entity)
131 { 147 {
148 // And anything attached to this avatar gets top priority as well
149 if (entity is SceneObjectPart)
150 {
151 SceneObjectPart sop = (SceneObjectPart)entity;
152 if (sop.ParentGroup.RootPart.IsAttachment && client.AgentId == sop.ParentGroup.RootPart.AttachedAvatar)
153 return 1;
154 }
155
132 return ComputeDistancePriority(client,entity,true); 156 return ComputeDistancePriority(client,entity,true);
133 } 157 }
134 158
@@ -141,18 +165,20 @@ namespace OpenSim.Region.Framework.Scenes
141 { 165 {
142 if (!presence.IsChildAgent) 166 if (!presence.IsChildAgent)
143 { 167 {
168 // All avatars other than our own go into pqueue 1
169 if (entity is ScenePresence)
170 return 1;
171
144 if (entity is SceneObjectPart) 172 if (entity is SceneObjectPart)
145 { 173 {
174 // Attachments are high priority,
175 if (((SceneObjectPart)entity).ParentGroup.RootPart.IsAttachment)
176 return 1;
177
146 // Non physical prims are lower priority than physical prims 178 // Non physical prims are lower priority than physical prims
147 PhysicsActor physActor = ((SceneObjectPart)entity).ParentGroup.RootPart.PhysActor; 179 PhysicsActor physActor = ((SceneObjectPart)entity).ParentGroup.RootPart.PhysActor;
148 if (physActor == null || !physActor.IsPhysical) 180 if (physActor == null || !physActor.IsPhysical)
149 pqueue++; 181 pqueue++;
150
151 // Attachments are high priority,
152 // MIC: shouldn't these already be in the highest priority queue already
153 // since their root position is same as the avatars?
154 if (((SceneObjectPart)entity).ParentGroup.RootPart.IsAttachment)
155 pqueue = 1;
156 } 182 }
157 } 183 }
158 } 184 }
@@ -172,7 +198,7 @@ namespace OpenSim.Region.Framework.Scenes
172 198
173 // m_log.WarnFormat("[PRIORITIZER] attempt to use agent {0} not in the scene",client.AgentId); 199 // m_log.WarnFormat("[PRIORITIZER] attempt to use agent {0} not in the scene",client.AgentId);
174 // throw new InvalidOperationException("Prioritization agent not defined"); 200 // throw new InvalidOperationException("Prioritization agent not defined");
175 return Int32.MaxValue; 201 return PriorityQueue.NumberOfQueues - 1;
176 } 202 }
177 203
178 // Use group position for child prims, since we are putting child prims in 204 // Use group position for child prims, since we are putting child prims in
@@ -197,8 +223,10 @@ namespace OpenSim.Region.Framework.Scenes
197 223
198 // And convert the distance to a priority queue, this computation gives queues 224 // And convert the distance to a priority queue, this computation gives queues
199 // at 10, 20, 40, 80, 160, 320, 640, and 1280m 225 // at 10, 20, 40, 80, 160, 320, 640, and 1280m
200 uint pqueue = 1; 226 uint pqueue = PriorityQueue.NumberOfImmediateQueues;
201 for (int i = 0; i < 8; i++) 227 uint queues = PriorityQueue.NumberOfQueues - PriorityQueue.NumberOfImmediateQueues;
228
229 for (int i = 0; i < queues - 1; i++)
202 { 230 {
203 if (distance < 10 * Math.Pow(2.0,i)) 231 if (distance < 10 * Math.Pow(2.0,i))
204 break; 232 break;
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 0f85925..b0f0de6 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -1430,6 +1430,10 @@ namespace OpenSim.Region.Framework.Scenes
1430 } 1430 }
1431 else // Updating existing item with new perms etc 1431 else // Updating existing item with new perms etc
1432 { 1432 {
1433// m_log.DebugFormat(
1434// "[PRIM INVENTORY]: Updating item {0} in {1} for UpdateTaskInventory()",
1435// currentItem.Name, part.Name);
1436
1433 IAgentAssetTransactions agentTransactions = this.RequestModuleInterface<IAgentAssetTransactions>(); 1437 IAgentAssetTransactions agentTransactions = this.RequestModuleInterface<IAgentAssetTransactions>();
1434 if (agentTransactions != null) 1438 if (agentTransactions != null)
1435 { 1439 {
@@ -2039,6 +2043,12 @@ namespace OpenSim.Region.Framework.Scenes
2039 if (rot != null) 2043 if (rot != null)
2040 group.UpdateGroupRotationR((Quaternion)rot); 2044 group.UpdateGroupRotationR((Quaternion)rot);
2041 2045
2046 // TODO: This needs to be refactored with the similar code in
2047 // SceneGraph.AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, Vector3 pos, Quaternion rot, Vector3 vel)
2048 // possibly by allowing this method to take a null rotation.
2049 if (group.RootPart.PhysActor != null && group.RootPart.PhysActor.IsPhysical && vel != Vector3.Zero)
2050 group.RootPart.ApplyImpulse((vel * group.GetMass()), false);
2051
2042 // We can only call this after adding the scene object, since the scene object references the scene 2052 // We can only call this after adding the scene object, since the scene object references the scene
2043 // to find out if scripts should be activated at all. 2053 // to find out if scripts should be activated at all.
2044 group.CreateScriptInstances(param, true, DefaultScriptEngine, 3); 2054 group.CreateScriptInstances(param, true, DefaultScriptEngine, 3);
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 01de824..7c5e246 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -1229,7 +1229,6 @@ namespace OpenSim.Region.Framework.Scenes
1229 1229
1230 // Increment the frame counter 1230 // Increment the frame counter
1231 ++Frame; 1231 ++Frame;
1232
1233 try 1232 try
1234 { 1233 {
1235 // Check if any objects have reached their targets 1234 // Check if any objects have reached their targets
@@ -2316,7 +2315,9 @@ namespace OpenSim.Region.Framework.Scenes
2316 /// <returns></returns> 2315 /// <returns></returns>
2317 public bool IncomingCreateObject(ISceneObject sog) 2316 public bool IncomingCreateObject(ISceneObject sog)
2318 { 2317 {
2319 //m_log.Debug(" >>> IncomingCreateObject(sog) <<< " + ((SceneObjectGroup)sog).AbsolutePosition + " deleted? " + ((SceneObjectGroup)sog).IsDeleted); 2318 //m_log.DebugFormat(" >>> IncomingCreateObject(sog) <<< {0} deleted? {1} isAttach? {2}", ((SceneObjectGroup)sog).AbsolutePosition,
2319 // ((SceneObjectGroup)sog).IsDeleted, ((SceneObjectGroup)sog).RootPart.IsAttachment);
2320
2320 SceneObjectGroup newObject; 2321 SceneObjectGroup newObject;
2321 try 2322 try
2322 { 2323 {
@@ -2334,9 +2335,29 @@ namespace OpenSim.Region.Framework.Scenes
2334 return false; 2335 return false;
2335 } 2336 }
2336 2337
2337 newObject.RootPart.ParentGroup.CreateScriptInstances(0, false, DefaultScriptEngine, GetStateSource(newObject)); 2338 // For attachments, we need to wait until the agent is root
2338 2339 // before we restart the scripts, or else some functions won't work.
2339 newObject.ResumeScripts(); 2340 if (!newObject.IsAttachment)
2341 {
2342 newObject.RootPart.ParentGroup.CreateScriptInstances(0, false, DefaultScriptEngine, GetStateSource(newObject));
2343 newObject.ResumeScripts();
2344 }
2345 else
2346 {
2347 ScenePresence sp;
2348 if (TryGetScenePresence(newObject.OwnerID, out sp))
2349 {
2350 // If the scene presence is here and already a root
2351 // agent, we came from a ;egacy region. Start the scripts
2352 // here as they used to start.
2353 // TODO: Remove in 0.7.3
2354 if (!sp.IsChildAgent)
2355 {
2356 newObject.RootPart.ParentGroup.CreateScriptInstances(0, false, DefaultScriptEngine, GetStateSource(newObject));
2357 newObject.ResumeScripts();
2358 }
2359 }
2360 }
2340 2361
2341 // Do this as late as possible so that listeners have full access to the incoming object 2362 // Do this as late as possible so that listeners have full access to the incoming object
2342 EventManager.TriggerOnIncomingSceneObject(newObject); 2363 EventManager.TriggerOnIncomingSceneObject(newObject);
@@ -2453,17 +2474,8 @@ namespace OpenSim.Region.Framework.Scenes
2453 ScenePresence sp = GetScenePresence(sog.OwnerID); 2474 ScenePresence sp = GetScenePresence(sog.OwnerID);
2454 2475
2455 if (sp != null) 2476 if (sp != null)
2456 { 2477 return sp.GetStateSource();
2457 AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(sp.UUID);
2458 2478
2459 if (aCircuit != null && (aCircuit.teleportFlags != (uint)TeleportFlags.Default))
2460 {
2461 // This will get your attention
2462 //m_log.Error("[XXX] Triggering CHANGED_TELEPORT");
2463
2464 return 5; // StateSource.Teleporting
2465 }
2466 }
2467 return 2; // StateSource.PrimCrossing 2479 return 2; // StateSource.PrimCrossing
2468 } 2480 }
2469 2481
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index 3281eab..3b60f8c 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -693,8 +693,9 @@ namespace OpenSim.Region.Framework.Scenes
693 { 693 {
694 TaskInventoryItem it = GetInventoryItem(item.ItemID); 694 TaskInventoryItem it = GetInventoryItem(item.ItemID);
695 if (it != null) 695 if (it != null)
696
697 { 696 {
697// m_log.DebugFormat("[PRIM INVENTORY]: Updating item {0} in {1}", item.Name, m_part.Name);
698
698 item.ParentID = m_part.UUID; 699 item.ParentID = m_part.UUID;
699 item.ParentPartID = m_part.UUID; 700 item.ParentPartID = m_part.UUID;
700 701
@@ -711,14 +712,16 @@ namespace OpenSim.Region.Framework.Scenes
711 m_items[item.ItemID] = item; 712 m_items[item.ItemID] = item;
712 m_inventorySerial++; 713 m_inventorySerial++;
713 } 714 }
714 715
715 if (fireScriptEvents) 716 if (fireScriptEvents)
716 m_part.TriggerScriptChangedEvent(Changed.INVENTORY); 717 m_part.TriggerScriptChangedEvent(Changed.INVENTORY);
718
717 if (considerChanged) 719 if (considerChanged)
718 { 720 {
719 HasInventoryChanged = true; 721 HasInventoryChanged = true;
720 m_part.ParentGroup.HasGroupChanged = true; 722 m_part.ParentGroup.HasGroupChanged = true;
721 } 723 }
724
722 return true; 725 return true;
723 } 726 }
724 else 727 else
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 00a1487..5b86735 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -840,6 +840,9 @@ namespace OpenSim.Region.Framework.Scenes
840 840
841 //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count); 841 //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count);
842 842
843 bool wasChild = m_isChildAgent;
844 m_isChildAgent = false;
845
843 IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); 846 IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>();
844 if (gm != null) 847 if (gm != null)
845 m_grouptitle = gm.GetGroupTitle(m_uuid); 848 m_grouptitle = gm.GetGroupTitle(m_uuid);
@@ -929,14 +932,21 @@ namespace OpenSim.Region.Framework.Scenes
929 // Animator.SendAnimPack(); 932 // Animator.SendAnimPack();
930 933
931 m_scene.SwapRootAgentCount(false); 934 m_scene.SwapRootAgentCount(false);
932 935
933 //CachedUserInfo userInfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(m_uuid); 936 // The initial login scene presence is already root when it gets here
934 //if (userInfo != null) 937 // and it has already rezzed the attachments and started their scripts.
935 // userInfo.FetchInventory(); 938 // We do the following only for non-login agents, because their scripts
936 //else 939 // haven't started yet.
937 // m_log.ErrorFormat("[SCENE]: Could not find user info for {0} when making it a root agent", m_uuid); 940 if (wasChild && Attachments != null && Attachments.Count > 0)
938 941 {
939 m_isChildAgent = false; 942 m_log.DebugFormat("[SCENE PRESENCE]: Restarting scripts in attachments...");
943 // Resume scripts
944 Attachments.ForEach(delegate(SceneObjectGroup sog)
945 {
946 sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource());
947 sog.ResumeScripts();
948 });
949 }
940 950
941 // send the animations of the other presences to me 951 // send the animations of the other presences to me
942 m_scene.ForEachScenePresence(delegate(ScenePresence presence) 952 m_scene.ForEachScenePresence(delegate(ScenePresence presence)
@@ -948,6 +958,20 @@ namespace OpenSim.Region.Framework.Scenes
948 m_scene.EventManager.TriggerOnMakeRootAgent(this); 958 m_scene.EventManager.TriggerOnMakeRootAgent(this);
949 } 959 }
950 960
961 public int GetStateSource()
962 {
963 AgentCircuitData aCircuit = m_scene.AuthenticateHandler.GetAgentCircuitData(UUID);
964
965 if (aCircuit != null && (aCircuit.teleportFlags != (uint)TeleportFlags.Default))
966 {
967 // This will get your attention
968 //m_log.Error("[XXX] Triggering CHANGED_TELEPORT");
969
970 return 5; // StateSource.Teleporting
971 }
972 return 2; // StateSource.PrimCrossing
973 }
974
951 /// <summary> 975 /// <summary>
952 /// This turns a root agent into a child agent 976 /// This turns a root agent into a child agent
953 /// when an agent departs this region for a neighbor, this gets called. 977 /// when an agent departs this region for a neighbor, this gets called.
@@ -1139,7 +1163,6 @@ namespace OpenSim.Region.Framework.Scenes
1139 AbsolutePosition = pos; 1163 AbsolutePosition = pos;
1140 } 1164 }
1141 1165
1142 m_isChildAgent = false;
1143 bool m_flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); 1166 bool m_flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0);
1144 MakeRootAgent(AbsolutePosition, m_flying); 1167 MakeRootAgent(AbsolutePosition, m_flying);
1145 1168
@@ -2340,12 +2363,14 @@ namespace OpenSim.Region.Framework.Scenes
2340 2363
2341 #region Update Client(s) 2364 #region Update Client(s)
2342 2365
2366
2343 /// <summary> 2367 /// <summary>
2344 /// Sends a location update to the client connected to this scenePresence 2368 /// Sends a location update to the client connected to this scenePresence
2345 /// </summary> 2369 /// </summary>
2346 /// <param name="remoteClient"></param> 2370 /// <param name="remoteClient"></param>
2347 public void SendTerseUpdateToClient(IClientAPI remoteClient) 2371 public void SendTerseUpdateToClient(IClientAPI remoteClient)
2348 { 2372 {
2373
2349 // If the client is inactive, it's getting its updates from another 2374 // If the client is inactive, it's getting its updates from another
2350 // server. 2375 // server.
2351 if (remoteClient.IsActive) 2376 if (remoteClient.IsActive)
@@ -2358,8 +2383,8 @@ namespace OpenSim.Region.Framework.Scenes
2358 //m_log.DebugFormat("[SCENEPRESENCE]: TerseUpdate: Pos={0} Rot={1} Vel={2}", m_pos, m_bodyRot, m_velocity); 2383 //m_log.DebugFormat("[SCENEPRESENCE]: TerseUpdate: Pos={0} Rot={1} Vel={2}", m_pos, m_bodyRot, m_velocity);
2359 2384
2360 remoteClient.SendPrimUpdate( 2385 remoteClient.SendPrimUpdate(
2361 this, 2386 this,
2362 PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity 2387 PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity
2363 | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity); 2388 | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity);
2364 2389
2365 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); 2390 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
@@ -2367,16 +2392,31 @@ namespace OpenSim.Region.Framework.Scenes
2367 } 2392 }
2368 } 2393 }
2369 2394
2395
2396 // vars to support reduced update frequency when velocity is unchanged
2397 private Vector3 lastVelocitySentToAllClients = Vector3.Zero;
2398 private int lastTerseUpdateToAllClientsTick = Util.EnvironmentTickCount();
2399
2370 /// <summary> 2400 /// <summary>
2371 /// Send a location/velocity/accelleration update to all agents in scene 2401 /// Send a location/velocity/accelleration update to all agents in scene
2372 /// </summary> 2402 /// </summary>
2373 public void SendTerseUpdateToAllClients() 2403 public void SendTerseUpdateToAllClients()
2374 { 2404 {
2375 m_perfMonMS = Util.EnvironmentTickCount(); 2405 int currentTick = Util.EnvironmentTickCount();
2376
2377 m_scene.ForEachClient(SendTerseUpdateToClient);
2378 2406
2379 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); 2407 // decrease update frequency when avatar is moving but velocity is not changing
2408 if (m_velocity.Length() < 0.01f
2409 || Vector3.Distance(lastVelocitySentToAllClients, m_velocity) > 0.01f
2410 || currentTick - lastTerseUpdateToAllClientsTick > 1500)
2411 {
2412 m_perfMonMS = currentTick;
2413 lastVelocitySentToAllClients = m_velocity;
2414 lastTerseUpdateToAllClientsTick = currentTick;
2415
2416 m_scene.ForEachClient(SendTerseUpdateToClient);
2417
2418 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
2419 }
2380 } 2420 }
2381 2421
2382 public void SendCoarseLocations(List<Vector3> coarseLocations, List<UUID> avatarUUIDs) 2422 public void SendCoarseLocations(List<Vector3> coarseLocations, List<UUID> avatarUUIDs)
@@ -2632,18 +2672,17 @@ namespace OpenSim.Region.Framework.Scenes
2632 cadu.GroupAccess = 0; 2672 cadu.GroupAccess = 0;
2633 cadu.Position = AbsolutePosition; 2673 cadu.Position = AbsolutePosition;
2634 cadu.regionHandle = m_rootRegionHandle; 2674 cadu.regionHandle = m_rootRegionHandle;
2675
2676 // Throttles
2635 float multiplier = 1; 2677 float multiplier = 1;
2636 int innacurateNeighbors = m_scene.GetInaccurateNeighborCount(); 2678 int childRegions = m_knownChildRegions.Count;
2637 if (innacurateNeighbors != 0) 2679 if (childRegions != 0)
2638 { 2680 multiplier = 1f / childRegions;
2639 multiplier = 1f / (float)innacurateNeighbors; 2681
2640 } 2682 // Minimum throttle for a child region is 1/4 of the root region throttle
2641 if (multiplier <= 0f) 2683 if (multiplier <= 0.25f)
2642 {
2643 multiplier = 0.25f; 2684 multiplier = 0.25f;
2644 }
2645 2685
2646 //m_log.Info("[NeighborThrottle]: " + m_scene.GetInaccurateNeighborCount().ToString() + " - m: " + multiplier.ToString());
2647 cadu.throttles = ControllingClient.GetThrottlesPacked(multiplier); 2686 cadu.throttles = ControllingClient.GetThrottlesPacked(multiplier);
2648 cadu.Velocity = Velocity; 2687 cadu.Velocity = Velocity;
2649 2688
@@ -3039,16 +3078,14 @@ namespace OpenSim.Region.Framework.Scenes
3039 3078
3040 // Throttles 3079 // Throttles
3041 float multiplier = 1; 3080 float multiplier = 1;
3042 int innacurateNeighbors = m_scene.GetInaccurateNeighborCount(); 3081 int childRegions = m_knownChildRegions.Count;
3043 if (innacurateNeighbors != 0) 3082 if (childRegions != 0)
3044 { 3083 multiplier = 1f / childRegions;
3045 multiplier = 1f / innacurateNeighbors; 3084
3046 } 3085 // Minimum throttle for a child region is 1/4 of the root region throttle
3047 if (multiplier <= 0f) 3086 if (multiplier <= 0.25f)
3048 {
3049 multiplier = 0.25f; 3087 multiplier = 0.25f;
3050 } 3088
3051 //m_log.Info("[NeighborThrottle]: " + m_scene.GetInaccurateNeighborCount().ToString() + " - m: " + multiplier.ToString());
3052 cAgent.Throttles = ControllingClient.GetThrottlesPacked(multiplier); 3089 cAgent.Throttles = ControllingClient.GetThrottlesPacked(multiplier);
3053 3090
3054 cAgent.HeadRotation = m_headrotation; 3091 cAgent.HeadRotation = m_headrotation;
@@ -3064,54 +3101,6 @@ namespace OpenSim.Region.Framework.Scenes
3064 3101
3065 cAgent.Appearance = new AvatarAppearance(m_appearance); 3102 cAgent.Appearance = new AvatarAppearance(m_appearance);
3066 3103
3067/*
3068 try
3069 {
3070 // We might not pass the Wearables in all cases...
3071 // They're only needed so that persistent changes to the appearance
3072 // are preserved in the new region where the user is moving to.
3073 // But in Hypergrid we might not let this happen.
3074 int i = 0;
3075 UUID[] wears = new UUID[m_appearance.Wearables.Length * 2];
3076 foreach (AvatarWearable aw in m_appearance.Wearables)
3077 {
3078 if (aw != null)
3079 {
3080 wears[i++] = aw.ItemID;
3081 wears[i++] = aw.AssetID;
3082 }
3083 else
3084 {
3085 wears[i++] = UUID.Zero;
3086 wears[i++] = UUID.Zero;
3087 }
3088 }
3089 cAgent.Wearables = wears;
3090
3091 cAgent.VisualParams = m_appearance.VisualParams;
3092
3093 if (m_appearance.Texture != null)
3094 cAgent.AgentTextures = m_appearance.Texture.GetBytes();
3095 }
3096 catch (Exception e)
3097 {
3098 m_log.Warn("[SCENE PRESENCE]: exception in CopyTo " + e.Message);
3099 }
3100
3101 //Attachments
3102 List<int> attPoints = m_appearance.GetAttachedPoints();
3103 if (attPoints != null)
3104 {
3105 //m_log.DebugFormat("[SCENE PRESENCE]: attachments {0}", attPoints.Count);
3106 int i = 0;
3107 AvatarAttachment[] attachs = new AvatarAttachment[attPoints.Count];
3108 foreach (int point in attPoints)
3109 {
3110 attachs[i++] = new AvatarAttachment(point, m_appearance.GetAttachedItem(point), m_appearance.GetAttachedAsset(point));
3111 }
3112 cAgent.Attachments = attachs;
3113 }
3114*/
3115 lock (scriptedcontrols) 3104 lock (scriptedcontrols)
3116 { 3105 {
3117 ControllerData[] controls = new ControllerData[scriptedcontrols.Count]; 3106 ControllerData[] controls = new ControllerData[scriptedcontrols.Count];
@@ -3131,9 +3120,26 @@ namespace OpenSim.Region.Framework.Scenes
3131 } 3120 }
3132 catch { } 3121 catch { }
3133 3122
3134 // cAgent.GroupID = ?? 3123 // Attachment objects
3135 // Groups??? 3124 if (m_attachments != null && m_attachments.Count > 0)
3136 3125 {
3126 cAgent.AttachmentObjects = new List<ISceneObject>();
3127 cAgent.AttachmentObjectStates = new List<string>();
3128 IScriptModule se = m_scene.RequestModuleInterface<IScriptModule>();
3129 foreach (SceneObjectGroup sog in m_attachments)
3130 {
3131 // We need to make a copy and pass that copy
3132 // because of transfers withn the same sim
3133 ISceneObject clone = sog.CloneForNewScene();
3134 // Attachment module assumes that GroupPosition holds the offsets...!
3135 ((SceneObjectGroup)clone).RootPart.GroupPosition = sog.RootPart.AttachedPos;
3136 ((SceneObjectGroup)clone).RootPart.IsAttachment = false;
3137 cAgent.AttachmentObjects.Add(clone);
3138 cAgent.AttachmentObjectStates.Add(sog.GetStateSnapshot());
3139 // Let's remove the scripts of the original object here
3140 sog.RemoveScriptInstances(true);
3141 }
3142 }
3137 } 3143 }
3138 3144
3139 public void CopyFrom(AgentData cAgent) 3145 public void CopyFrom(AgentData cAgent)
@@ -3174,50 +3180,6 @@ namespace OpenSim.Region.Framework.Scenes
3174 AddToPhysicalScene(isFlying); 3180 AddToPhysicalScene(isFlying);
3175 } 3181 }
3176 3182
3177/*
3178 uint i = 0;
3179 try
3180 {
3181 if (cAgent.Wearables == null)
3182 cAgent.Wearables = new UUID[0];
3183 AvatarWearable[] wears = new AvatarWearable[cAgent.Wearables.Length / 2];
3184 for (uint n = 0; n < cAgent.Wearables.Length; n += 2)
3185 {
3186 UUID itemId = cAgent.Wearables[n];
3187 UUID assetId = cAgent.Wearables[n + 1];
3188 wears[i++] = new AvatarWearable(itemId, assetId);
3189 }
3190 // m_appearance.Wearables = wears;
3191 Primitive.TextureEntry textures = null;
3192 if (cAgent.AgentTextures != null && cAgent.AgentTextures.Length > 1)
3193 textures = new Primitive.TextureEntry(cAgent.AgentTextures, 0, cAgent.AgentTextures.Length);
3194
3195 byte[] visuals = null;
3196
3197 if ((cAgent.VisualParams != null) && (cAgent.VisualParams.Length < AvatarAppearance.VISUALPARAM_COUNT))
3198 visuals = (byte[])cAgent.VisualParams.Clone();
3199
3200 m_appearance = new AvatarAppearance(cAgent.AgentID,wears,textures,visuals);
3201 }
3202 catch (Exception e)
3203 {
3204 m_log.Warn("[SCENE PRESENCE]: exception in CopyFrom " + e.Message);
3205 }
3206
3207 // Attachments
3208 try
3209 {
3210 if (cAgent.Attachments != null)
3211 {
3212 m_appearance.ClearAttachments();
3213 foreach (AvatarAttachment att in cAgent.Attachments)
3214 {
3215 m_appearance.SetAttachment(att.AttachPoint, att.ItemID, att.AssetID);
3216 }
3217 }
3218 }
3219 catch { }
3220*/
3221 try 3183 try
3222 { 3184 {
3223 lock (scriptedcontrols) 3185 lock (scriptedcontrols)
@@ -3247,8 +3209,18 @@ namespace OpenSim.Region.Framework.Scenes
3247 } 3209 }
3248 catch { } 3210 catch { }
3249 3211
3250 //cAgent.GroupID = ?? 3212 if (cAgent.AttachmentObjects != null && cAgent.AttachmentObjects.Count > 0)
3251 //Groups??? 3213 {
3214 m_attachments = new List<SceneObjectGroup>();
3215 int i = 0;
3216 foreach (ISceneObject so in cAgent.AttachmentObjects)
3217 {
3218 ((SceneObjectGroup)so).LocalId = 0;
3219 ((SceneObjectGroup)so).RootPart.UpdateFlag = 0;
3220 so.SetState(cAgent.AttachmentObjectStates[i++], m_scene);
3221 m_scene.IncomingCreateObject(so);
3222 }
3223 }
3252 } 3224 }
3253 3225
3254 public bool CopyAgent(out IAgentData agent) 3226 public bool CopyAgent(out IAgentData agent)
@@ -3271,10 +3243,7 @@ namespace OpenSim.Region.Framework.Scenes
3271 3243
3272 m_updateflag = true; 3244 m_updateflag = true;
3273 3245
3274 // The magic constant 0.95f seems to make walking feel less jerky, 3246 Velocity = force;
3275 // probably because it hackishly accounts for the overall latency of
3276 // these Velocity updates -- Diva
3277 Velocity = force * .95F;
3278 3247
3279 m_forceToApply = null; 3248 m_forceToApply = null;
3280 } 3249 }