aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/ScenePresence.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs194
1 files changed, 69 insertions, 125 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 00a1487..fe4a7d1 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -2340,12 +2340,14 @@ namespace OpenSim.Region.Framework.Scenes
2340 2340
2341 #region Update Client(s) 2341 #region Update Client(s)
2342 2342
2343
2343 /// <summary> 2344 /// <summary>
2344 /// Sends a location update to the client connected to this scenePresence 2345 /// Sends a location update to the client connected to this scenePresence
2345 /// </summary> 2346 /// </summary>
2346 /// <param name="remoteClient"></param> 2347 /// <param name="remoteClient"></param>
2347 public void SendTerseUpdateToClient(IClientAPI remoteClient) 2348 public void SendTerseUpdateToClient(IClientAPI remoteClient)
2348 { 2349 {
2350
2349 // If the client is inactive, it's getting its updates from another 2351 // If the client is inactive, it's getting its updates from another
2350 // server. 2352 // server.
2351 if (remoteClient.IsActive) 2353 if (remoteClient.IsActive)
@@ -2358,8 +2360,8 @@ namespace OpenSim.Region.Framework.Scenes
2358 //m_log.DebugFormat("[SCENEPRESENCE]: TerseUpdate: Pos={0} Rot={1} Vel={2}", m_pos, m_bodyRot, m_velocity); 2360 //m_log.DebugFormat("[SCENEPRESENCE]: TerseUpdate: Pos={0} Rot={1} Vel={2}", m_pos, m_bodyRot, m_velocity);
2359 2361
2360 remoteClient.SendPrimUpdate( 2362 remoteClient.SendPrimUpdate(
2361 this, 2363 this,
2362 PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity 2364 PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity
2363 | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity); 2365 | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity);
2364 2366
2365 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); 2367 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
@@ -2367,16 +2369,31 @@ namespace OpenSim.Region.Framework.Scenes
2367 } 2369 }
2368 } 2370 }
2369 2371
2372
2373 // vars to support reduced update frequency when velocity is unchanged
2374 private Vector3 lastVelocitySentToAllClients = Vector3.Zero;
2375 private int lastTerseUpdateToAllClientsTick = Util.EnvironmentTickCount();
2376
2370 /// <summary> 2377 /// <summary>
2371 /// Send a location/velocity/accelleration update to all agents in scene 2378 /// Send a location/velocity/accelleration update to all agents in scene
2372 /// </summary> 2379 /// </summary>
2373 public void SendTerseUpdateToAllClients() 2380 public void SendTerseUpdateToAllClients()
2374 { 2381 {
2375 m_perfMonMS = Util.EnvironmentTickCount(); 2382 int currentTick = Util.EnvironmentTickCount();
2376
2377 m_scene.ForEachClient(SendTerseUpdateToClient);
2378 2383
2379 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); 2384 // decrease update frequency when avatar is moving but velocity is not changing
2385 if (m_velocity.Length() < 0.01f
2386 || Vector3.Distance(lastVelocitySentToAllClients, m_velocity) > 0.01f
2387 || currentTick - lastTerseUpdateToAllClientsTick > 1500)
2388 {
2389 m_perfMonMS = currentTick;
2390 lastVelocitySentToAllClients = m_velocity;
2391 lastTerseUpdateToAllClientsTick = currentTick;
2392
2393 m_scene.ForEachClient(SendTerseUpdateToClient);
2394
2395 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
2396 }
2380 } 2397 }
2381 2398
2382 public void SendCoarseLocations(List<Vector3> coarseLocations, List<UUID> avatarUUIDs) 2399 public void SendCoarseLocations(List<Vector3> coarseLocations, List<UUID> avatarUUIDs)
@@ -2632,18 +2649,17 @@ namespace OpenSim.Region.Framework.Scenes
2632 cadu.GroupAccess = 0; 2649 cadu.GroupAccess = 0;
2633 cadu.Position = AbsolutePosition; 2650 cadu.Position = AbsolutePosition;
2634 cadu.regionHandle = m_rootRegionHandle; 2651 cadu.regionHandle = m_rootRegionHandle;
2652
2653 // Throttles
2635 float multiplier = 1; 2654 float multiplier = 1;
2636 int innacurateNeighbors = m_scene.GetInaccurateNeighborCount(); 2655 int childRegions = m_knownChildRegions.Count;
2637 if (innacurateNeighbors != 0) 2656 if (childRegions != 0)
2638 { 2657 multiplier = 1f / childRegions;
2639 multiplier = 1f / (float)innacurateNeighbors; 2658
2640 } 2659 // Minimum throttle for a child region is 1/4 of the root region throttle
2641 if (multiplier <= 0f) 2660 if (multiplier <= 0.25f)
2642 {
2643 multiplier = 0.25f; 2661 multiplier = 0.25f;
2644 }
2645 2662
2646 //m_log.Info("[NeighborThrottle]: " + m_scene.GetInaccurateNeighborCount().ToString() + " - m: " + multiplier.ToString());
2647 cadu.throttles = ControllingClient.GetThrottlesPacked(multiplier); 2663 cadu.throttles = ControllingClient.GetThrottlesPacked(multiplier);
2648 cadu.Velocity = Velocity; 2664 cadu.Velocity = Velocity;
2649 2665
@@ -3039,16 +3055,14 @@ namespace OpenSim.Region.Framework.Scenes
3039 3055
3040 // Throttles 3056 // Throttles
3041 float multiplier = 1; 3057 float multiplier = 1;
3042 int innacurateNeighbors = m_scene.GetInaccurateNeighborCount(); 3058 int childRegions = m_knownChildRegions.Count;
3043 if (innacurateNeighbors != 0) 3059 if (childRegions != 0)
3044 { 3060 multiplier = 1f / childRegions;
3045 multiplier = 1f / innacurateNeighbors; 3061
3046 } 3062 // Minimum throttle for a child region is 1/4 of the root region throttle
3047 if (multiplier <= 0f) 3063 if (multiplier <= 0.25f)
3048 {
3049 multiplier = 0.25f; 3064 multiplier = 0.25f;
3050 } 3065
3051 //m_log.Info("[NeighborThrottle]: " + m_scene.GetInaccurateNeighborCount().ToString() + " - m: " + multiplier.ToString());
3052 cAgent.Throttles = ControllingClient.GetThrottlesPacked(multiplier); 3066 cAgent.Throttles = ControllingClient.GetThrottlesPacked(multiplier);
3053 3067
3054 cAgent.HeadRotation = m_headrotation; 3068 cAgent.HeadRotation = m_headrotation;
@@ -3064,54 +3078,6 @@ namespace OpenSim.Region.Framework.Scenes
3064 3078
3065 cAgent.Appearance = new AvatarAppearance(m_appearance); 3079 cAgent.Appearance = new AvatarAppearance(m_appearance);
3066 3080
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) 3081 lock (scriptedcontrols)
3116 { 3082 {
3117 ControllerData[] controls = new ControllerData[scriptedcontrols.Count]; 3083 ControllerData[] controls = new ControllerData[scriptedcontrols.Count];
@@ -3131,9 +3097,24 @@ namespace OpenSim.Region.Framework.Scenes
3131 } 3097 }
3132 catch { } 3098 catch { }
3133 3099
3134 // cAgent.GroupID = ?? 3100 // Attachment objects
3135 // Groups??? 3101 if (m_attachments != null && m_attachments.Count > 0)
3136 3102 {
3103 cAgent.AttachmentObjects = new List<ISceneObject>();
3104 cAgent.AttachmentObjectStates = new List<string>();
3105 IScriptModule se = m_scene.RequestModuleInterface<IScriptModule>();
3106 foreach (SceneObjectGroup sog in m_attachments)
3107 {
3108 // We need to make a copy and pass that copy
3109 // because of transfers withn the same sim
3110 ISceneObject clone = sog.CloneForNewScene();
3111 // Attachment module assumes that GroupPosition holds the offsets...!
3112 ((SceneObjectGroup)clone).RootPart.GroupPosition = sog.RootPart.AttachedPos;
3113 ((SceneObjectGroup)clone).RootPart.IsAttachment = false;
3114 cAgent.AttachmentObjects.Add(clone);
3115 cAgent.AttachmentObjectStates.Add(sog.GetStateSnapshot());
3116 }
3117 }
3137 } 3118 }
3138 3119
3139 public void CopyFrom(AgentData cAgent) 3120 public void CopyFrom(AgentData cAgent)
@@ -3174,50 +3155,6 @@ namespace OpenSim.Region.Framework.Scenes
3174 AddToPhysicalScene(isFlying); 3155 AddToPhysicalScene(isFlying);
3175 } 3156 }
3176 3157
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 3158 try
3222 { 3159 {
3223 lock (scriptedcontrols) 3160 lock (scriptedcontrols)
@@ -3247,8 +3184,18 @@ namespace OpenSim.Region.Framework.Scenes
3247 } 3184 }
3248 catch { } 3185 catch { }
3249 3186
3250 //cAgent.GroupID = ?? 3187 if (cAgent.AttachmentObjects != null && cAgent.AttachmentObjects.Count > 0)
3251 //Groups??? 3188 {
3189 m_attachments = new List<SceneObjectGroup>();
3190 int i = 0;
3191 foreach (ISceneObject so in cAgent.AttachmentObjects)
3192 {
3193 ((SceneObjectGroup)so).LocalId = 0;
3194 ((SceneObjectGroup)so).RootPart.UpdateFlag = 0;
3195 so.SetState(cAgent.AttachmentObjectStates[i++], m_scene);
3196 m_scene.IncomingCreateObject(so);
3197 }
3198 }
3252 } 3199 }
3253 3200
3254 public bool CopyAgent(out IAgentData agent) 3201 public bool CopyAgent(out IAgentData agent)
@@ -3271,10 +3218,7 @@ namespace OpenSim.Region.Framework.Scenes
3271 3218
3272 m_updateflag = true; 3219 m_updateflag = true;
3273 3220
3274 // The magic constant 0.95f seems to make walking feel less jerky, 3221 Velocity = force;
3275 // probably because it hackishly accounts for the overall latency of
3276 // these Velocity updates -- Diva
3277 Velocity = force * .95F;
3278 3222
3279 m_forceToApply = null; 3223 m_forceToApply = null;
3280 } 3224 }