aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
diff options
context:
space:
mode:
authorMaster ScienceSim2010-10-29 13:37:13 -0700
committerMaster ScienceSim2010-10-29 13:43:35 -0700
commitf5c9a56c8b73ef93db712fefe9f0366c4983e04f (patch)
tree23f47ca462584b41f2151d7a3962aaca11478b2d /OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
parentConfiguration of persistent baked textures and save/send delays. (diff)
downloadopensim-SC_OLD-f5c9a56c8b73ef93db712fefe9f0366c4983e04f.zip
opensim-SC_OLD-f5c9a56c8b73ef93db712fefe9f0366c4983e04f.tar.gz
opensim-SC_OLD-f5c9a56c8b73ef93db712fefe9f0366c4983e04f.tar.bz2
opensim-SC_OLD-f5c9a56c8b73ef93db712fefe9f0366c4983e04f.tar.xz
Bunch of fixes that reduce the number of times appearance
and avatar data are sent. And the number of times they are stored.
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs73
1 files changed, 49 insertions, 24 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
index 5f8b4f6..bfbbcf8 100644
--- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
@@ -42,10 +42,9 @@ using OpenSim.Services.Interfaces;
42 42
43namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory 43namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
44{ 44{
45 public class AvatarFactoryModule : IRegionModule 45 public class AvatarFactoryModule : IAvatarFactory, IRegionModule
46 { 46 {
47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48 private static readonly byte[] BAKE_INDICES = new byte[] { 8, 9, 10, 11, 19, 20 };
49 private Scene m_scene = null; 48 private Scene m_scene = null;
50 49
51 private int m_savetime = 5; // seconds to wait before saving changed appearance 50 private int m_savetime = 5; // seconds to wait before saving changed appearance
@@ -60,8 +59,9 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
60 59
61 public void Initialise(Scene scene, IConfigSource config) 60 public void Initialise(Scene scene, IConfigSource config)
62 { 61 {
62 scene.RegisterModuleInterface<IAvatarFactory>(this);
63 scene.EventManager.OnNewClient += NewClient; 63 scene.EventManager.OnNewClient += NewClient;
64 64
65 if (config != null) 65 if (config != null)
66 { 66 {
67 IConfig sconfig = config.Configs["Startup"]; 67 IConfig sconfig = config.Configs["Startup"];
@@ -112,6 +112,34 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
112 112
113 #endregion 113 #endregion
114 114
115 public bool ValidateBakedTextureCache(IClientAPI client)
116 {
117 ScenePresence sp = m_scene.GetScenePresence(client.AgentId);
118 if (sp == null)
119 {
120 m_log.WarnFormat("[AVFACTORY] SetAppearance unable to find presence for {0}",client.AgentId);
121 return false;
122 }
123
124 bool cached = true;
125
126 // Process the texture entry
127 for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++)
128 {
129 int idx = AvatarAppearance.BAKE_INDICES[i];
130 Primitive.TextureEntryFace face = sp.Appearance.Texture.FaceTextures[idx];
131 if (face != null && face.TextureID != AppearanceManager.DEFAULT_AVATAR_TEXTURE)
132 if (! CheckBakedTextureAsset(client,face.TextureID,idx))
133 {
134 sp.Appearance.Texture.FaceTextures[idx] = null;
135 cached = false;
136 }
137 }
138
139 return cached;
140 }
141
142
115 /// <summary> 143 /// <summary>
116 /// Set appearance data (textureentry and slider settings) received from the client 144 /// Set appearance data (textureentry and slider settings) received from the client
117 /// </summary> 145 /// </summary>
@@ -137,12 +165,15 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
137 { 165 {
138 changed = sp.Appearance.SetTextureEntries(textureEntry); 166 changed = sp.Appearance.SetTextureEntries(textureEntry);
139 167
140 for (int i = 0; i < BAKE_INDICES.Length; i++) 168 for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++)
141 { 169 {
142 int idx = BAKE_INDICES[i]; 170 int idx = AvatarAppearance.BAKE_INDICES[i];
143 Primitive.TextureEntryFace face = sp.Appearance.Texture.FaceTextures[idx]; 171 Primitive.TextureEntryFace face = sp.Appearance.Texture.FaceTextures[idx];
144 if (face != null && face.TextureID != AppearanceManager.DEFAULT_AVATAR_TEXTURE) 172 if (face != null && face.TextureID != AppearanceManager.DEFAULT_AVATAR_TEXTURE)
145 Util.FireAndForget(delegate(object o) { CheckBakedTextureAssets(client,face.TextureID,idx); }); 173 Util.FireAndForget(delegate(object o) {
174 if (! CheckBakedTextureAsset(client,face.TextureID,idx))
175 client.SendRebakeAvatarTextures(face.TextureID);
176 });
146 } 177 }
147 } 178 }
148 179
@@ -165,9 +196,9 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
165 QueueAppearanceSend(client.AgentId); 196 QueueAppearanceSend(client.AgentId);
166 197
167 // Send the appearance back to the avatar 198 // Send the appearance back to the avatar
168 AvatarAppearance avp = sp.Appearance; 199 // AvatarAppearance avp = sp.Appearance;
169 sp.ControllingClient.SendAvatarDataImmediate(sp); 200 // sp.ControllingClient.SendAvatarDataImmediate(sp);
170 sp.ControllingClient.SendAppearance(avp.Owner,avp.VisualParams,avp.Texture.GetBytes()); 201 // sp.ControllingClient.SendAppearance(avp.Owner,avp.VisualParams,avp.Texture.GetBytes());
171 } 202 }
172 203
173 /// <summary> 204 /// <summary>
@@ -177,14 +208,15 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
177 /// <param name="client"></param> 208 /// <param name="client"></param>
178 /// <param name="textureID"></param> 209 /// <param name="textureID"></param>
179 /// <param name="idx"></param> 210 /// <param name="idx"></param>
180 private void CheckBakedTextureAssets(IClientAPI client, UUID textureID, int idx) 211 private bool CheckBakedTextureAsset(IClientAPI client, UUID textureID, int idx)
181 { 212 {
182 if (m_scene.AssetService.Get(textureID.ToString()) == null) 213 if (m_scene.AssetService.Get(textureID.ToString()) == null)
183 { 214 {
184 m_log.WarnFormat("[AVFACTORY]: Missing baked texture {0} ({1}) for avatar {2}", 215 m_log.WarnFormat("[AVFACTORY]: Missing baked texture {0} ({1}) for avatar {2}",
185 textureID,idx,client.Name); 216 textureID,idx,client.Name);
186 client.SendRebakeAvatarTextures(textureID); 217 return false;
187 } 218 }
219 return true;
188 } 220 }
189 221
190 #region UpdateAppearanceTimer 222 #region UpdateAppearanceTimer
@@ -229,16 +261,16 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
229 } 261 }
230 262
231// DEBUG ON 263// DEBUG ON
232 m_log.WarnFormat("[AVFACTORY] Handle appearance send for {0}\n{1}",agentid,sp.Appearance.ToString()); 264 m_log.WarnFormat("[AVFACTORY] Handle appearance send for {0}",agentid);
233// DEBUG OFF 265// DEBUG OFF
234 266
235 // Send the appearance to everyone in the scene 267 // Send the appearance to everyone in the scene
236 sp.SendAppearanceToAllOtherAgents(); 268 sp.SendAppearanceToAllOtherAgents();
269 sp.ControllingClient.SendAvatarDataImmediate(sp);
237 270
238 // Send the appearance back to the avatar 271 // Send the appearance back to the avatar
239 AvatarAppearance avp = sp.Appearance; 272 // AvatarAppearance avp = sp.Appearance;
240 sp.ControllingClient.SendAvatarDataImmediate(sp); 273 // sp.ControllingClient.SendAppearance(avp.Owner,avp.VisualParams,avp.Texture.GetBytes());
241 sp.ControllingClient.SendAppearance(avp.Owner,avp.VisualParams,avp.Texture.GetBytes());
242 274
243/* 275/*
244// this needs to be fixed, the flag should be on scene presence not the region module 276// this needs to be fixed, the flag should be on scene presence not the region module
@@ -337,14 +369,6 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
337 369
338 AvatarAppearance avatAppearance = new AvatarAppearance(sp.Appearance); 370 AvatarAppearance avatAppearance = new AvatarAppearance(sp.Appearance);
339 371
340 //if (!TryGetAvatarAppearance(client.AgentId, out avatAppearance))
341 //{
342 // m_log.Warn("[AVFACTORY]: We didn't seem to find the appearance, falling back to ScenePresence");
343 // avatAppearance = sp.Appearance;
344 //}
345
346 //m_log.DebugFormat("[AVFACTORY]: Received wearables for {0}", client.Name);
347
348 foreach (AvatarWearingArgs.Wearable wear in e.NowWearing) 372 foreach (AvatarWearingArgs.Wearable wear in e.NowWearing)
349 { 373 {
350 if (wear.Type < AvatarWearable.MAX_WEARABLES) 374 if (wear.Type < AvatarWearable.MAX_WEARABLES)
@@ -354,10 +378,11 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
354 } 378 }
355 } 379 }
356 380
381 // This could take awhile since it needs to pull inventory
357 SetAppearanceAssets(sp.UUID, ref avatAppearance); 382 SetAppearanceAssets(sp.UUID, ref avatAppearance);
358 383
359 m_scene.AvatarService.SetAppearance(client.AgentId, avatAppearance);
360 sp.Appearance = avatAppearance; 384 sp.Appearance = avatAppearance;
385 m_scene.AvatarService.SetAppearance(client.AgentId, sp.Appearance);
361 } 386 }
362 387
363 private void SetAppearanceAssets(UUID userID, ref AvatarAppearance appearance) 388 private void SetAppearanceAssets(UUID userID, ref AvatarAppearance appearance)