aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes
diff options
context:
space:
mode:
Diffstat (limited to '')
-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.cs26
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs3
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs232
5 files changed, 164 insertions, 155 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Prioritizer.cs b/OpenSim/Region/Framework/Scenes/Prioritizer.cs
index 17b2da1..0f35894 100644
--- a/OpenSim/Region/Framework/Scenes/Prioritizer.cs
+++ b/OpenSim/Region/Framework/Scenes/Prioritizer.cs
@@ -88,7 +88,7 @@ namespace OpenSim.Region.Framework.Scenes
88 88
89 // If this is an update for our own avatar give it the highest priority 89 // If this is an update for our own avatar give it the highest priority
90 if (client.AgentId == entity.UUID) 90 if (client.AgentId == entity.UUID)
91 return PriorityQueue.ImmediateQueue; 91 return 0;
92 92
93 uint priority; 93 uint priority;
94 94
@@ -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
@@ -143,18 +167,20 @@ namespace OpenSim.Region.Framework.Scenes
143 { 167 {
144 if (!presence.IsChildAgent) 168 if (!presence.IsChildAgent)
145 { 169 {
170 // All avatars other than our own go into pqueue 1
171 if (entity is ScenePresence)
172 return 1;
173
146 if (entity is SceneObjectPart) 174 if (entity is SceneObjectPart)
147 { 175 {
176 // Attachments are high priority,
177 if (((SceneObjectPart)entity).ParentGroup.RootPart.IsAttachment)
178 return 1;
179
148 // Non physical prims are lower priority than physical prims 180 // Non physical prims are lower priority than physical prims
149 PhysicsActor physActor = ((SceneObjectPart)entity).ParentGroup.RootPart.PhysActor; 181 PhysicsActor physActor = ((SceneObjectPart)entity).ParentGroup.RootPart.PhysActor;
150 if (physActor == null || !physActor.IsPhysical) 182 if (physActor == null || !physActor.IsPhysical)
151 pqueue++; 183 pqueue++;
152
153 // Attachments are high priority,
154 // MIC: shouldn't these already be in the highest priority queue already
155 // since their root position is same as the avatars?
156 if (((SceneObjectPart)entity).ParentGroup.RootPart.IsAttachment)
157 pqueue = 1;
158 } 184 }
159 } 185 }
160 } 186 }
@@ -205,8 +231,10 @@ namespace OpenSim.Region.Framework.Scenes
205 231
206 // And convert the distance to a priority queue, this computation gives queues 232 // And convert the distance to a priority queue, this computation gives queues
207 // at 10, 20, 40, 80, 160, 320, 640, and 1280m 233 // at 10, 20, 40, 80, 160, 320, 640, and 1280m
208 uint pqueue = 1; 234 uint pqueue = PriorityQueue.NumberOfImmediateQueues;
209 for (int i = 0; i < 8; i++) 235 uint queues = PriorityQueue.NumberOfQueues - PriorityQueue.NumberOfImmediateQueues;
236
237 for (int i = 0; i < queues - 1; i++)
210 { 238 {
211 if (distance < 10 * Math.Pow(2.0,i)) 239 if (distance < 10 * Math.Pow(2.0,i))
212 break; 240 break;
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index f41c6b9..5b7a297 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -1449,6 +1449,10 @@ namespace OpenSim.Region.Framework.Scenes
1449 } 1449 }
1450 else // Updating existing item with new perms etc 1450 else // Updating existing item with new perms etc
1451 { 1451 {
1452// m_log.DebugFormat(
1453// "[PRIM INVENTORY]: Updating item {0} in {1} for UpdateTaskInventory()",
1454// currentItem.Name, part.Name);
1455
1452 IAgentAssetTransactions agentTransactions = this.RequestModuleInterface<IAgentAssetTransactions>(); 1456 IAgentAssetTransactions agentTransactions = this.RequestModuleInterface<IAgentAssetTransactions>();
1453 if (agentTransactions != null) 1457 if (agentTransactions != null)
1454 { 1458 {
@@ -2089,6 +2093,12 @@ namespace OpenSim.Region.Framework.Scenes
2089 if (rot != null) 2093 if (rot != null)
2090 group.UpdateGroupRotationR((Quaternion)rot); 2094 group.UpdateGroupRotationR((Quaternion)rot);
2091 2095
2096 // TODO: This needs to be refactored with the similar code in
2097 // SceneGraph.AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, Vector3 pos, Quaternion rot, Vector3 vel)
2098 // possibly by allowing this method to take a null rotation.
2099 if (group.RootPart.PhysActor != null && group.RootPart.PhysActor.IsPhysical && vel != Vector3.Zero)
2100 group.RootPart.ApplyImpulse((vel * group.GetMass()), false);
2101
2092 // We can only call this after adding the scene object, since the scene object references the scene 2102 // We can only call this after adding the scene object, since the scene object references the scene
2093 // to find out if scripts should be activated at all. 2103 // to find out if scripts should be activated at all.
2094 group.CreateScriptInstances(param, true, DefaultScriptEngine, 3); 2104 group.CreateScriptInstances(param, true, DefaultScriptEngine, 3);
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 4d619c3..1d06889 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -1255,7 +1255,6 @@ namespace OpenSim.Region.Framework.Scenes
1255 1255
1256 // Increment the frame counter 1256 // Increment the frame counter
1257 ++Frame; 1257 ++Frame;
1258
1259 try 1258 try
1260 { 1259 {
1261 // Check if any objects have reached their targets 1260 // Check if any objects have reached their targets
@@ -2383,7 +2382,9 @@ namespace OpenSim.Region.Framework.Scenes
2383 /// <returns></returns> 2382 /// <returns></returns>
2384 public bool IncomingCreateObject(ISceneObject sog) 2383 public bool IncomingCreateObject(ISceneObject sog)
2385 { 2384 {
2386 //m_log.Debug(" >>> IncomingCreateObject(sog) <<< " + ((SceneObjectGroup)sog).AbsolutePosition + " deleted? " + ((SceneObjectGroup)sog).IsDeleted); 2385 //m_log.DebugFormat(" >>> IncomingCreateObject(sog) <<< {0} deleted? {1} isAttach? {2}", ((SceneObjectGroup)sog).AbsolutePosition,
2386 // ((SceneObjectGroup)sog).IsDeleted, ((SceneObjectGroup)sog).RootPart.IsAttachment);
2387
2387 SceneObjectGroup newObject; 2388 SceneObjectGroup newObject;
2388 try 2389 try
2389 { 2390 {
@@ -2401,9 +2402,13 @@ namespace OpenSim.Region.Framework.Scenes
2401 return false; 2402 return false;
2402 } 2403 }
2403 2404
2404 newObject.RootPart.ParentGroup.CreateScriptInstances(0, false, DefaultScriptEngine, GetStateSource(newObject)); 2405 // For attachments, we need to wait until the agent is root
2405 2406 // before we restart the scripts, or else some functions won't work.
2406 newObject.ResumeScripts(); 2407 if (!newObject.IsAttachment)
2408 {
2409 newObject.RootPart.ParentGroup.CreateScriptInstances(0, false, DefaultScriptEngine, GetStateSource(newObject));
2410 newObject.ResumeScripts();
2411 }
2407 2412
2408 // Do this as late as possible so that listeners have full access to the incoming object 2413 // Do this as late as possible so that listeners have full access to the incoming object
2409 EventManager.TriggerOnIncomingSceneObject(newObject); 2414 EventManager.TriggerOnIncomingSceneObject(newObject);
@@ -2540,17 +2545,8 @@ namespace OpenSim.Region.Framework.Scenes
2540 ScenePresence sp = GetScenePresence(sog.OwnerID); 2545 ScenePresence sp = GetScenePresence(sog.OwnerID);
2541 2546
2542 if (sp != null) 2547 if (sp != null)
2543 { 2548 return sp.GetStateSource();
2544 AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(sp.UUID);
2545
2546 if (aCircuit != null && (aCircuit.teleportFlags != (uint)TeleportFlags.Default))
2547 {
2548 // This will get your attention
2549 //m_log.Error("[XXX] Triggering CHANGED_TELEPORT");
2550 2549
2551 return 5; // StateSource.Teleporting
2552 }
2553 }
2554 return 2; // StateSource.PrimCrossing 2550 return 2; // StateSource.PrimCrossing
2555 } 2551 }
2556 2552
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index 3e0241c..56680df 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -884,6 +884,8 @@ namespace OpenSim.Region.Framework.Scenes
884 884
885 if (m_items.ContainsKey(item.ItemID)) 885 if (m_items.ContainsKey(item.ItemID))
886 { 886 {
887// m_log.DebugFormat("[PRIM INVENTORY]: Updating item {0} in {1}", item.Name, m_part.Name);
888
887 item.ParentID = m_part.UUID; 889 item.ParentID = m_part.UUID;
888 item.ParentPartID = m_part.UUID; 890 item.ParentPartID = m_part.UUID;
889 891
@@ -899,6 +901,7 @@ namespace OpenSim.Region.Framework.Scenes
899 m_inventorySerial++; 901 m_inventorySerial++;
900 if (fireScriptEvents) 902 if (fireScriptEvents)
901 m_part.TriggerScriptChangedEvent(Changed.INVENTORY); 903 m_part.TriggerScriptChangedEvent(Changed.INVENTORY);
904
902 if (considerChanged) 905 if (considerChanged)
903 { 906 {
904 HasInventoryChanged = true; 907 HasInventoryChanged = true;
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 9e48447..cdf8366 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -924,6 +924,9 @@ namespace OpenSim.Region.Framework.Scenes
924 924
925 //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count); 925 //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count);
926 926
927 bool wasChild = m_isChildAgent;
928 m_isChildAgent = false;
929
927 IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); 930 IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>();
928 if (gm != null) 931 if (gm != null)
929 m_grouptitle = gm.GetGroupTitle(m_uuid); 932 m_grouptitle = gm.GetGroupTitle(m_uuid);
@@ -1069,14 +1072,21 @@ namespace OpenSim.Region.Framework.Scenes
1069 // Animator.SendAnimPack(); 1072 // Animator.SendAnimPack();
1070 1073
1071 m_scene.SwapRootAgentCount(false); 1074 m_scene.SwapRootAgentCount(false);
1072 1075
1073 //CachedUserInfo userInfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(m_uuid); 1076 // The initial login scene presence is already root when it gets here
1074 //if (userInfo != null) 1077 // and it has already rezzed the attachments and started their scripts.
1075 // userInfo.FetchInventory(); 1078 // We do the following only for non-login agents, because their scripts
1076 //else 1079 // haven't started yet.
1077 // m_log.ErrorFormat("[SCENE]: Could not find user info for {0} when making it a root agent", m_uuid); 1080 if (wasChild)
1078 1081 {
1079 m_isChildAgent = false; 1082 m_log.DebugFormat("[SCENE PRESENCE]: Restarting scripts in attachments...");
1083 // Resume scripts
1084 Attachments.ForEach(delegate(SceneObjectGroup sog)
1085 {
1086 sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource());
1087 sog.ResumeScripts();
1088 });
1089 }
1080 1090
1081 // send the animations of the other presences to me 1091 // send the animations of the other presences to me
1082 m_scene.ForEachScenePresence(delegate(ScenePresence presence) 1092 m_scene.ForEachScenePresence(delegate(ScenePresence presence)
@@ -1088,6 +1098,20 @@ namespace OpenSim.Region.Framework.Scenes
1088 m_scene.EventManager.TriggerOnMakeRootAgent(this); 1098 m_scene.EventManager.TriggerOnMakeRootAgent(this);
1089 } 1099 }
1090 1100
1101 public int GetStateSource()
1102 {
1103 AgentCircuitData aCircuit = m_scene.AuthenticateHandler.GetAgentCircuitData(UUID);
1104
1105 if (aCircuit != null && (aCircuit.teleportFlags != (uint)TeleportFlags.Default))
1106 {
1107 // This will get your attention
1108 //m_log.Error("[XXX] Triggering CHANGED_TELEPORT");
1109
1110 return 5; // StateSource.Teleporting
1111 }
1112 return 2; // StateSource.PrimCrossing
1113 }
1114
1091 /// <summary> 1115 /// <summary>
1092 /// This turns a root agent into a child agent 1116 /// This turns a root agent into a child agent
1093 /// when an agent departs this region for a neighbor, this gets called. 1117 /// when an agent departs this region for a neighbor, this gets called.
@@ -1288,7 +1312,6 @@ namespace OpenSim.Region.Framework.Scenes
1288 AbsolutePosition = pos; 1312 AbsolutePosition = pos;
1289 } 1313 }
1290 1314
1291 m_isChildAgent = false;
1292 bool m_flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); 1315 bool m_flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0);
1293 MakeRootAgent(AbsolutePosition, m_flying); 1316 MakeRootAgent(AbsolutePosition, m_flying);
1294 1317
@@ -2757,12 +2780,14 @@ namespace OpenSim.Region.Framework.Scenes
2757 2780
2758 #region Update Client(s) 2781 #region Update Client(s)
2759 2782
2783
2760 /// <summary> 2784 /// <summary>
2761 /// Sends a location update to the client connected to this scenePresence 2785 /// Sends a location update to the client connected to this scenePresence
2762 /// </summary> 2786 /// </summary>
2763 /// <param name="remoteClient"></param> 2787 /// <param name="remoteClient"></param>
2764 public void SendTerseUpdateToClient(IClientAPI remoteClient) 2788 public void SendTerseUpdateToClient(IClientAPI remoteClient)
2765 { 2789 {
2790
2766 // If the client is inactive, it's getting its updates from another 2791 // If the client is inactive, it's getting its updates from another
2767 // server. 2792 // server.
2768 if (remoteClient.IsActive) 2793 if (remoteClient.IsActive)
@@ -2775,8 +2800,8 @@ namespace OpenSim.Region.Framework.Scenes
2775 //m_log.DebugFormat("[SCENEPRESENCE]: TerseUpdate: Pos={0} Rot={1} Vel={2}", m_pos, m_bodyRot, m_velocity); 2800 //m_log.DebugFormat("[SCENEPRESENCE]: TerseUpdate: Pos={0} Rot={1} Vel={2}", m_pos, m_bodyRot, m_velocity);
2776 2801
2777 remoteClient.SendPrimUpdate( 2802 remoteClient.SendPrimUpdate(
2778 this, 2803 this,
2779 PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity 2804 PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity
2780 | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity); 2805 | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity);
2781 2806
2782 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); 2807 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
@@ -2784,16 +2809,31 @@ namespace OpenSim.Region.Framework.Scenes
2784 } 2809 }
2785 } 2810 }
2786 2811
2812
2813 // vars to support reduced update frequency when velocity is unchanged
2814 private Vector3 lastVelocitySentToAllClients = Vector3.Zero;
2815 private int lastTerseUpdateToAllClientsTick = Util.EnvironmentTickCount();
2816
2787 /// <summary> 2817 /// <summary>
2788 /// Send a location/velocity/accelleration update to all agents in scene 2818 /// Send a location/velocity/accelleration update to all agents in scene
2789 /// </summary> 2819 /// </summary>
2790 public void SendTerseUpdateToAllClients() 2820 public void SendTerseUpdateToAllClients()
2791 { 2821 {
2792 m_perfMonMS = Util.EnvironmentTickCount(); 2822 int currentTick = Util.EnvironmentTickCount();
2793
2794 m_scene.ForEachClient(SendTerseUpdateToClient);
2795 2823
2796 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); 2824 // decrease update frequency when avatar is moving but velocity is not changing
2825 if (m_velocity.Length() < 0.01f
2826 || Vector3.Distance(lastVelocitySentToAllClients, m_velocity) > 0.01f
2827 || currentTick - lastTerseUpdateToAllClientsTick > 1500)
2828 {
2829 m_perfMonMS = currentTick;
2830 lastVelocitySentToAllClients = m_velocity;
2831 lastTerseUpdateToAllClientsTick = currentTick;
2832
2833 m_scene.ForEachClient(SendTerseUpdateToClient);
2834
2835 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
2836 }
2797 } 2837 }
2798 2838
2799 public void SendCoarseLocations(List<Vector3> coarseLocations, List<UUID> avatarUUIDs) 2839 public void SendCoarseLocations(List<Vector3> coarseLocations, List<UUID> avatarUUIDs)
@@ -3049,18 +3089,17 @@ namespace OpenSim.Region.Framework.Scenes
3049 cadu.GroupAccess = 0; 3089 cadu.GroupAccess = 0;
3050 cadu.Position = AbsolutePosition; 3090 cadu.Position = AbsolutePosition;
3051 cadu.regionHandle = m_rootRegionHandle; 3091 cadu.regionHandle = m_rootRegionHandle;
3092
3093 // Throttles
3052 float multiplier = 1; 3094 float multiplier = 1;
3053 int innacurateNeighbors = m_scene.GetInaccurateNeighborCount(); 3095 int childRegions = m_knownChildRegions.Count;
3054 if (innacurateNeighbors != 0) 3096 if (childRegions != 0)
3055 { 3097 multiplier = 1f / childRegions;
3056 multiplier = 1f / (float)innacurateNeighbors; 3098
3057 } 3099 // Minimum throttle for a child region is 1/4 of the root region throttle
3058 if (multiplier <= 0f) 3100 if (multiplier <= 0.25f)
3059 {
3060 multiplier = 0.25f; 3101 multiplier = 0.25f;
3061 }
3062 3102
3063 //m_log.Info("[NeighborThrottle]: " + m_scene.GetInaccurateNeighborCount().ToString() + " - m: " + multiplier.ToString());
3064 cadu.throttles = ControllingClient.GetThrottlesPacked(multiplier); 3103 cadu.throttles = ControllingClient.GetThrottlesPacked(multiplier);
3065 cadu.Velocity = Velocity; 3104 cadu.Velocity = Velocity;
3066 3105
@@ -3456,16 +3495,14 @@ namespace OpenSim.Region.Framework.Scenes
3456 3495
3457 // Throttles 3496 // Throttles
3458 float multiplier = 1; 3497 float multiplier = 1;
3459 int innacurateNeighbors = m_scene.GetInaccurateNeighborCount(); 3498 int childRegions = m_knownChildRegions.Count;
3460 if (innacurateNeighbors != 0) 3499 if (childRegions != 0)
3461 { 3500 multiplier = 1f / childRegions;
3462 multiplier = 1f / innacurateNeighbors; 3501
3463 } 3502 // Minimum throttle for a child region is 1/4 of the root region throttle
3464 if (multiplier <= 0f) 3503 if (multiplier <= 0.25f)
3465 {
3466 multiplier = 0.25f; 3504 multiplier = 0.25f;
3467 } 3505
3468 //m_log.Info("[NeighborThrottle]: " + m_scene.GetInaccurateNeighborCount().ToString() + " - m: " + multiplier.ToString());
3469 cAgent.Throttles = ControllingClient.GetThrottlesPacked(multiplier); 3506 cAgent.Throttles = ControllingClient.GetThrottlesPacked(multiplier);
3470 3507
3471 cAgent.HeadRotation = m_headrotation; 3508 cAgent.HeadRotation = m_headrotation;
@@ -3481,54 +3518,6 @@ namespace OpenSim.Region.Framework.Scenes
3481 3518
3482 cAgent.Appearance = new AvatarAppearance(m_appearance); 3519 cAgent.Appearance = new AvatarAppearance(m_appearance);
3483 3520
3484/*
3485 try
3486 {
3487 // We might not pass the Wearables in all cases...
3488 // They're only needed so that persistent changes to the appearance
3489 // are preserved in the new region where the user is moving to.
3490 // But in Hypergrid we might not let this happen.
3491 int i = 0;
3492 UUID[] wears = new UUID[m_appearance.Wearables.Length * 2];
3493 foreach (AvatarWearable aw in m_appearance.Wearables)
3494 {
3495 if (aw != null)
3496 {
3497 wears[i++] = aw.ItemID;
3498 wears[i++] = aw.AssetID;
3499 }
3500 else
3501 {
3502 wears[i++] = UUID.Zero;
3503 wears[i++] = UUID.Zero;
3504 }
3505 }
3506 cAgent.Wearables = wears;
3507
3508 cAgent.VisualParams = m_appearance.VisualParams;
3509
3510 if (m_appearance.Texture != null)
3511 cAgent.AgentTextures = m_appearance.Texture.GetBytes();
3512 }
3513 catch (Exception e)
3514 {
3515 m_log.Warn("[SCENE PRESENCE]: exception in CopyTo " + e.Message);
3516 }
3517
3518 //Attachments
3519 List<int> attPoints = m_appearance.GetAttachedPoints();
3520 if (attPoints != null)
3521 {
3522 //m_log.DebugFormat("[SCENE PRESENCE]: attachments {0}", attPoints.Count);
3523 int i = 0;
3524 AvatarAttachment[] attachs = new AvatarAttachment[attPoints.Count];
3525 foreach (int point in attPoints)
3526 {
3527 attachs[i++] = new AvatarAttachment(point, m_appearance.GetAttachedItem(point), m_appearance.GetAttachedAsset(point));
3528 }
3529 cAgent.Attachments = attachs;
3530 }
3531*/
3532 lock (scriptedcontrols) 3521 lock (scriptedcontrols)
3533 { 3522 {
3534 ControllerData[] controls = new ControllerData[scriptedcontrols.Count]; 3523 ControllerData[] controls = new ControllerData[scriptedcontrols.Count];
@@ -3548,9 +3537,26 @@ namespace OpenSim.Region.Framework.Scenes
3548 } 3537 }
3549 catch { } 3538 catch { }
3550 3539
3551 // cAgent.GroupID = ?? 3540 // Attachment objects
3552 // Groups??? 3541 if (m_attachments != null && m_attachments.Count > 0)
3553 3542 {
3543 cAgent.AttachmentObjects = new List<ISceneObject>();
3544 cAgent.AttachmentObjectStates = new List<string>();
3545 IScriptModule se = m_scene.RequestModuleInterface<IScriptModule>();
3546 foreach (SceneObjectGroup sog in m_attachments)
3547 {
3548 // We need to make a copy and pass that copy
3549 // because of transfers withn the same sim
3550 ISceneObject clone = sog.CloneForNewScene();
3551 // Attachment module assumes that GroupPosition holds the offsets...!
3552 ((SceneObjectGroup)clone).RootPart.GroupPosition = sog.RootPart.AttachedPos;
3553 ((SceneObjectGroup)clone).RootPart.IsAttachment = false;
3554 cAgent.AttachmentObjects.Add(clone);
3555 cAgent.AttachmentObjectStates.Add(sog.GetStateSnapshot());
3556 // Let's remove the scripts of the original object here
3557 sog.RemoveScriptInstances(true);
3558 }
3559 }
3554 } 3560 }
3555 3561
3556 public void CopyFrom(AgentData cAgent) 3562 public void CopyFrom(AgentData cAgent)
@@ -3592,50 +3598,6 @@ namespace OpenSim.Region.Framework.Scenes
3592 AddToPhysicalScene(isFlying); 3598 AddToPhysicalScene(isFlying);
3593 } 3599 }
3594 3600
3595/*
3596 uint i = 0;
3597 try
3598 {
3599 if (cAgent.Wearables == null)
3600 cAgent.Wearables = new UUID[0];
3601 AvatarWearable[] wears = new AvatarWearable[cAgent.Wearables.Length / 2];
3602 for (uint n = 0; n < cAgent.Wearables.Length; n += 2)
3603 {
3604 UUID itemId = cAgent.Wearables[n];
3605 UUID assetId = cAgent.Wearables[n + 1];
3606 wears[i++] = new AvatarWearable(itemId, assetId);
3607 }
3608 // m_appearance.Wearables = wears;
3609 Primitive.TextureEntry textures = null;
3610 if (cAgent.AgentTextures != null && cAgent.AgentTextures.Length > 1)
3611 textures = new Primitive.TextureEntry(cAgent.AgentTextures, 0, cAgent.AgentTextures.Length);
3612
3613 byte[] visuals = null;
3614
3615 if ((cAgent.VisualParams != null) && (cAgent.VisualParams.Length < AvatarAppearance.VISUALPARAM_COUNT))
3616 visuals = (byte[])cAgent.VisualParams.Clone();
3617
3618 m_appearance = new AvatarAppearance(cAgent.AgentID,wears,textures,visuals);
3619 }
3620 catch (Exception e)
3621 {
3622 m_log.Warn("[SCENE PRESENCE]: exception in CopyFrom " + e.Message);
3623 }
3624
3625 // Attachments
3626 try
3627 {
3628 if (cAgent.Attachments != null)
3629 {
3630 m_appearance.ClearAttachments();
3631 foreach (AvatarAttachment att in cAgent.Attachments)
3632 {
3633 m_appearance.SetAttachment(att.AttachPoint, att.ItemID, att.AssetID);
3634 }
3635 }
3636 }
3637 catch { }
3638*/
3639 try 3601 try
3640 { 3602 {
3641 lock (scriptedcontrols) 3603 lock (scriptedcontrols)
@@ -3665,8 +3627,18 @@ namespace OpenSim.Region.Framework.Scenes
3665 } 3627 }
3666 catch { } 3628 catch { }
3667 3629
3668 //cAgent.GroupID = ?? 3630 if (cAgent.AttachmentObjects != null && cAgent.AttachmentObjects.Count > 0)
3669 //Groups??? 3631 {
3632 m_attachments = new List<SceneObjectGroup>();
3633 int i = 0;
3634 foreach (ISceneObject so in cAgent.AttachmentObjects)
3635 {
3636 ((SceneObjectGroup)so).LocalId = 0;
3637 ((SceneObjectGroup)so).RootPart.UpdateFlag = 0;
3638 so.SetState(cAgent.AttachmentObjectStates[i++], m_scene);
3639 m_scene.IncomingCreateObject(so);
3640 }
3641 }
3670 } 3642 }
3671 3643
3672 public bool CopyAgent(out IAgentData agent) 3644 public bool CopyAgent(out IAgentData agent)