aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Framework/AvatarAppearance.cs4
-rw-r--r--OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs37
-rw-r--r--OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs58
3 files changed, 74 insertions, 25 deletions
diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs
index 5a6b265..716baab 100644
--- a/OpenSim/Framework/AvatarAppearance.cs
+++ b/OpenSim/Framework/AvatarAppearance.cs
@@ -196,6 +196,9 @@ namespace OpenSim.Framework
196 if (appearance.VisualParams != null) 196 if (appearance.VisualParams != null)
197 m_visualparams = (byte[])appearance.VisualParams.Clone(); 197 m_visualparams = (byte[])appearance.VisualParams.Clone();
198 198
199 m_avatarHeight = appearance.m_avatarHeight;
200 m_hipOffset = appearance.m_hipOffset;
201
199 // Copy the attachment, force append mode since that ensures consistency 202 // Copy the attachment, force append mode since that ensures consistency
200 m_attachments = new Dictionary<int, List<AvatarAttachment>>(); 203 m_attachments = new Dictionary<int, List<AvatarAttachment>>();
201 foreach (AvatarAttachment attachment in appearance.GetAttachments()) 204 foreach (AvatarAttachment attachment in appearance.GetAttachments())
@@ -237,7 +240,6 @@ namespace OpenSim.Framework
237 { 240 {
238 m_serial = 0; 241 m_serial = 0;
239 242
240 SetDefaultParams();
241 SetDefaultTexture(); 243 SetDefaultTexture();
242 244
243 //for (int i = 0; i < BAKE_INDICES.Length; i++) 245 //for (int i = 0; i < BAKE_INDICES.Length; i++)
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
index 75dbeb8..995a552 100644
--- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
@@ -210,7 +210,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
210 changed = sp.Appearance.SetVisualParams(visualParams); 210 changed = sp.Appearance.SetVisualParams(visualParams);
211 if (sp.Appearance.AvatarHeight > 0) 211 if (sp.Appearance.AvatarHeight > 0)
212 sp.SetHeight(sp.Appearance.AvatarHeight); 212 sp.SetHeight(sp.Appearance.AvatarHeight);
213 } 213 }
214 214
215 // Process the baked texture array 215 // Process the baked texture array
216 if (textureEntry != null) 216 if (textureEntry != null)
@@ -224,12 +224,12 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
224 // update transaction. In theory, we should be able to do an immediate 224 // update transaction. In theory, we should be able to do an immediate
225 // appearance send and save here. 225 // appearance send and save here.
226 226
227 // save only if there were changes, send no matter what (doesn't hurt to send twice)
228 if (changed)
229 QueueAppearanceSave(client.AgentId);
230
231 QueueAppearanceSend(client.AgentId);
232 } 227 }
228 // save only if there were changes, send no matter what (doesn't hurt to send twice)
229 if (changed)
230 QueueAppearanceSave(client.AgentId);
231
232 QueueAppearanceSend(client.AgentId);
233 } 233 }
234 234
235 // m_log.WarnFormat("[AVFACTORY]: complete SetAppearance for {0}:\n{1}",client.AgentId,sp.Appearance.ToString()); 235 // m_log.WarnFormat("[AVFACTORY]: complete SetAppearance for {0}:\n{1}",client.AgentId,sp.Appearance.ToString());
@@ -387,11 +387,11 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
387 // m_log.WarnFormat("[AVFACTORY]: AvatarIsWearing called for {0}", client.AgentId); 387 // m_log.WarnFormat("[AVFACTORY]: AvatarIsWearing called for {0}", client.AgentId);
388 388
389 // we need to clean out the existing textures 389 // we need to clean out the existing textures
390 sp.Appearance.ResetAppearance(); 390 sp.Appearance.ResetAppearance();
391 391
392 // operate on a copy of the appearance so we don't have to lock anything 392 // operate on a copy of the appearance so we don't have to lock anything yet
393 AvatarAppearance avatAppearance = new AvatarAppearance(sp.Appearance, false); 393 AvatarAppearance avatAppearance = new AvatarAppearance(sp.Appearance, false);
394 394
395 foreach (AvatarWearingArgs.Wearable wear in e.NowWearing) 395 foreach (AvatarWearingArgs.Wearable wear in e.NowWearing)
396 { 396 {
397 if (wear.Type < AvatarWearable.MAX_WEARABLES) 397 if (wear.Type < AvatarWearable.MAX_WEARABLES)
@@ -403,12 +403,19 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
403 // This could take awhile since it needs to pull inventory 403 // This could take awhile since it needs to pull inventory
404 SetAppearanceAssets(sp.UUID, ref avatAppearance); 404 SetAppearanceAssets(sp.UUID, ref avatAppearance);
405 405
406 // could get fancier with the locks here, but in the spirit of "last write wins" 406 lock (m_setAppearanceLock)
407 // this should work correctly, also, we don't need to send the appearance here 407 {
408 // since the "iswearing" will trigger a new set of visual param and baked texture changes 408 // Update only those fields that we have changed. This is important because the viewer
409 // when those complete, the new appearance will be sent 409 // often sends AvatarIsWearing and SetAppearance packets at once, and AvatarIsWearing
410 sp.Appearance = avatAppearance; 410 // shouldn't overwrite the changes made in SetAppearance.
411 QueueAppearanceSave(client.AgentId); 411 sp.Appearance.Wearables = avatAppearance.Wearables;
412 sp.Appearance.Texture = avatAppearance.Texture;
413
414 // We don't need to send the appearance here since the "iswearing" will trigger a new set
415 // of visual param and baked texture changes. When those complete, the new appearance will be sent
416
417 QueueAppearanceSave(client.AgentId);
418 }
412 } 419 }
413 420
414 private void SetAppearanceAssets(UUID userID, ref AvatarAppearance appearance) 421 private void SetAppearanceAssets(UUID userID, ref AvatarAppearance appearance)
diff --git a/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs b/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs
index f1da4fa..fdab254 100644
--- a/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs
@@ -48,6 +48,13 @@ namespace OpenSim.Services.Connectors
48 private string m_ServerURI = String.Empty; 48 private string m_ServerURI = String.Empty;
49 private IImprovedAssetCache m_Cache = null; 49 private IImprovedAssetCache m_Cache = null;
50 50
51 private delegate void AssetRetrievedEx(AssetBase asset);
52
53 // Keeps track of concurrent requests for the same asset, so that it's only loaded once.
54 // Maps: Asset ID -> Handlers which will be called when the asset has been loaded
55 private Dictionary<string, AssetRetrievedEx> m_AssetHandlers = new Dictionary<string, AssetRetrievedEx>();
56
57
51 public AssetServicesConnector() 58 public AssetServicesConnector()
52 { 59 {
53 } 60 }
@@ -178,23 +185,56 @@ namespace OpenSim.Services.Connectors
178 185
179 if (asset == null) 186 if (asset == null)
180 { 187 {
181 bool result = false; 188 lock (m_AssetHandlers)
182 189 {
183 AsynchronousRestObjectRequester. 190 AssetRetrievedEx handlerEx = new AssetRetrievedEx(delegate(AssetBase _asset) { handler(id, sender, _asset); });
184 MakeRequest<int, AssetBase>("GET", uri, 0, 191
192 AssetRetrievedEx handlers;
193 if (m_AssetHandlers.TryGetValue(id, out handlers))
194 {
195 // Someone else is already loading this asset. It will notify our handler when done.
196 handlers += handlerEx;
197 return true;
198 }
199
200 // Load the asset ourselves
201 handlers += handlerEx;
202 m_AssetHandlers.Add(id, handlers);
203 }
204
205 bool success = false;
206 try
207 {
208 AsynchronousRestObjectRequester.MakeRequest<int, AssetBase>("GET", uri, 0,
185 delegate(AssetBase a) 209 delegate(AssetBase a)
186 { 210 {
187 if (m_Cache != null) 211 if (m_Cache != null)
188 m_Cache.Cache(a); 212 m_Cache.Cache(a);
189 handler(id, sender, a);
190 result = true;
191 });
192 213
193 return result; 214 AssetRetrievedEx handlers;
215 lock (m_AssetHandlers)
216 {
217 handlers = m_AssetHandlers[id];
218 m_AssetHandlers.Remove(id);
219 }
220 handlers.Invoke(a);
221 });
222
223 success = true;
224 }
225 finally
226 {
227 if (!success)
228 {
229 lock (m_AssetHandlers)
230 {
231 m_AssetHandlers.Remove(id);
232 }
233 }
234 }
194 } 235 }
195 else 236 else
196 { 237 {
197 //Util.FireAndForget(delegate { handler(id, sender, asset); });
198 handler(id, sender, asset); 238 handler(id, sender, asset);
199 } 239 }
200 240