aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs534
-rw-r--r--OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs2
-rw-r--r--OpenSim/Region/Framework/Interfaces/IAvatarFactoryModule.cs4
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs40
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs56
5 files changed, 318 insertions, 318 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
index 0c7c690..236a47c 100644
--- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
@@ -105,143 +105,143 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
105 client.OnAvatarNowWearing += Client_OnAvatarNowWearing; 105 client.OnAvatarNowWearing += Client_OnAvatarNowWearing;
106 } 106 }
107 107
108 #endregion 108 #endregion
109 109
110 #region IAvatarFactoryModule 110 #region IAvatarFactoryModule
111 111
112 /// <summary> 112 /// <summary>
113 /// Set appearance data (texture asset IDs and slider settings) 113 /// Set appearance data (texture asset IDs and slider settings)
114 /// </summary> 114 /// </summary>
115 /// <param name="sp"></param> 115 /// <param name="sp"></param>
116 /// <param name="texture"></param> 116 /// <param name="texture"></param>
117 /// <param name="visualParam"></param> 117 /// <param name="visualParam"></param>
118 public void SetAppearance(IScenePresence sp, Primitive.TextureEntry textureEntry, byte[] visualParams) 118 public void SetAppearance(IScenePresence sp, Primitive.TextureEntry textureEntry, byte[] visualParams)
119 { 119 {
120 // m_log.InfoFormat("[AVFACTORY]: start SetAppearance for {0}", client.AgentId); 120 // m_log.InfoFormat("[AVFACTORY]: start SetAppearance for {0}", client.AgentId);
121 121
122 // TODO: This is probably not necessary any longer, just assume the 122 // TODO: This is probably not necessary any longer, just assume the
123 // textureEntry set implies that the appearance transaction is complete 123 // textureEntry set implies that the appearance transaction is complete
124 bool changed = false; 124 bool changed = false;
125 125
126 // Process the texture entry transactionally, this doesn't guarantee that Appearance is 126 // Process the texture entry transactionally, this doesn't guarantee that Appearance is
127 // going to be handled correctly but it does serialize the updates to the appearance 127 // going to be handled correctly but it does serialize the updates to the appearance
128 lock (m_setAppearanceLock) 128 lock (m_setAppearanceLock)
129 { 129 {
130 // Process the visual params, this may change height as well 130 // Process the visual params, this may change height as well
131 if (visualParams != null) 131 if (visualParams != null)
132 { 132 {
133 // string[] visualParamsStrings = new string[visualParams.Length]; 133 // string[] visualParamsStrings = new string[visualParams.Length];
134 // for (int i = 0; i < visualParams.Length; i++) 134 // for (int i = 0; i < visualParams.Length; i++)
135 // visualParamsStrings[i] = visualParams[i].ToString(); 135 // visualParamsStrings[i] = visualParams[i].ToString();
136 // m_log.DebugFormat( 136 // m_log.DebugFormat(
137 // "[AVFACTORY]: Setting visual params for {0} to {1}", 137 // "[AVFACTORY]: Setting visual params for {0} to {1}",
138 // client.Name, string.Join(", ", visualParamsStrings)); 138 // client.Name, string.Join(", ", visualParamsStrings));
139 139
140 float oldHeight = sp.Appearance.AvatarHeight; 140 float oldHeight = sp.Appearance.AvatarHeight;
141 changed = sp.Appearance.SetVisualParams(visualParams); 141 changed = sp.Appearance.SetVisualParams(visualParams);
142 142
143 if (sp.Appearance.AvatarHeight != oldHeight && sp.Appearance.AvatarHeight > 0) 143 if (sp.Appearance.AvatarHeight != oldHeight && sp.Appearance.AvatarHeight > 0)
144 ((ScenePresence)sp).SetHeight(sp.Appearance.AvatarHeight); 144 ((ScenePresence)sp).SetHeight(sp.Appearance.AvatarHeight);
145 } 145 }
146 146
147 // Process the baked texture array 147 // Process the baked texture array
148 if (textureEntry != null) 148 if (textureEntry != null)
149 { 149 {
150 changed = sp.Appearance.SetTextureEntries(textureEntry) || changed; 150 changed = sp.Appearance.SetTextureEntries(textureEntry) || changed;
151 151
152 m_log.InfoFormat("[AVFACTORY]: received texture update for {0}", sp.UUID); 152 m_log.InfoFormat("[AVFACTORY]: received texture update for {0}", sp.UUID);
153 Util.FireAndForget(delegate(object o) { ValidateBakedTextureCache(sp, false); }); 153 Util.FireAndForget(delegate(object o) { ValidateBakedTextureCache(sp, false); });
154 154
155 // This appears to be set only in the final stage of the appearance 155 // This appears to be set only in the final stage of the appearance
156 // update transaction. In theory, we should be able to do an immediate 156 // update transaction. In theory, we should be able to do an immediate
157 // appearance send and save here. 157 // appearance send and save here.
158 158
159 } 159 }
160 // save only if there were changes, send no matter what (doesn't hurt to send twice) 160 // save only if there were changes, send no matter what (doesn't hurt to send twice)
161 if (changed) 161 if (changed)
162 QueueAppearanceSave(sp.ControllingClient.AgentId); 162 QueueAppearanceSave(sp.ControllingClient.AgentId);
163 163
164 QueueAppearanceSend(sp.ControllingClient.AgentId); 164 QueueAppearanceSend(sp.ControllingClient.AgentId);
165 } 165 }
166 166
167 // m_log.WarnFormat("[AVFACTORY]: complete SetAppearance for {0}:\n{1}",client.AgentId,sp.Appearance.ToString()); 167 // m_log.WarnFormat("[AVFACTORY]: complete SetAppearance for {0}:\n{1}",client.AgentId,sp.Appearance.ToString());
168 } 168 }
169 169
170 public bool SendAppearance(UUID agentId) 170 public bool SendAppearance(UUID agentId)
171 { 171 {
172 ScenePresence sp = m_scene.GetScenePresence(agentId); 172 ScenePresence sp = m_scene.GetScenePresence(agentId);
173 if (sp == null) 173 if (sp == null)
174 { 174 {
175 m_log.WarnFormat("[AVFACTORY]: Agent {0} no longer in the scene", agentId); 175 m_log.WarnFormat("[AVFACTORY]: Agent {0} no longer in the scene", agentId);
176 return false; 176 return false;
177 } 177 }
178 178
179 // Send the appearance to everyone in the scene 179 // Send the appearance to everyone in the scene
180 sp.SendAppearanceToAllOtherAgents(); 180 sp.SendAppearanceToAllOtherAgents();
181 181
182 // Send animations back to the avatar as well 182 // Send animations back to the avatar as well
183 sp.Animator.SendAnimPack(); 183 sp.Animator.SendAnimPack();
184 184
185 return true; 185 return true;
186 } 186 }
187 187
188 public Dictionary<BakeType, Primitive.TextureEntryFace> GetBakedTextureFaces(UUID agentId) 188 public Dictionary<BakeType, Primitive.TextureEntryFace> GetBakedTextureFaces(UUID agentId)
189 { 189 {
190 ScenePresence sp = m_scene.GetScenePresence(agentId); 190 ScenePresence sp = m_scene.GetScenePresence(agentId);
191 191
192 if (sp == null) 192 if (sp == null)
193 return new Dictionary<BakeType, Primitive.TextureEntryFace>(); 193 return new Dictionary<BakeType, Primitive.TextureEntryFace>();
194 194
195 return GetBakedTextureFaces(sp); 195 return GetBakedTextureFaces(sp);
196 } 196 }
197 197
198 public bool SaveBakedTextures(UUID agentId) 198 public bool SaveBakedTextures(UUID agentId)
199 { 199 {
200 ScenePresence sp = m_scene.GetScenePresence(agentId); 200 ScenePresence sp = m_scene.GetScenePresence(agentId);
201 201
202 if (sp == null) 202 if (sp == null)
203 return false; 203 return false;
204 204
205 m_log.DebugFormat( 205 m_log.DebugFormat(
206 "[AV FACTORY]: Permanently saving baked textures for {0} in {1}", 206 "[AV FACTORY]: Permanently saving baked textures for {0} in {1}",
207 sp.Name, m_scene.RegionInfo.RegionName); 207 sp.Name, m_scene.RegionInfo.RegionName);
208 208
209 Dictionary<BakeType, Primitive.TextureEntryFace> bakedTextures = GetBakedTextureFaces(sp); 209 Dictionary<BakeType, Primitive.TextureEntryFace> bakedTextures = GetBakedTextureFaces(sp);
210 210
211 if (bakedTextures.Count == 0) 211 if (bakedTextures.Count == 0)
212 return false; 212 return false;
213 213
214 foreach (BakeType bakeType in bakedTextures.Keys) 214 foreach (BakeType bakeType in bakedTextures.Keys)
215 { 215 {
216 Primitive.TextureEntryFace bakedTextureFace = bakedTextures[bakeType]; 216 Primitive.TextureEntryFace bakedTextureFace = bakedTextures[bakeType];
217 217
218 if (bakedTextureFace == null) 218 if (bakedTextureFace == null)
219 { 219 {
220 m_log.WarnFormat( 220 m_log.WarnFormat(
221 "[AV FACTORY]: No texture ID set for {0} for {1} in {2} not found when trying to save permanently", 221 "[AV FACTORY]: No texture ID set for {0} for {1} in {2} not found when trying to save permanently",
222 bakeType, sp.Name, m_scene.RegionInfo.RegionName); 222 bakeType, sp.Name, m_scene.RegionInfo.RegionName);
223 223
224 continue; 224 continue;
225 } 225 }
226 226
227 AssetBase asset = m_scene.AssetService.Get(bakedTextureFace.TextureID.ToString()); 227 AssetBase asset = m_scene.AssetService.Get(bakedTextureFace.TextureID.ToString());
228 228
229 if (asset != null) 229 if (asset != null)
230 { 230 {
231 asset.Temporary = false; 231 asset.Temporary = false;
232 asset.Local = false; 232 asset.Local = false;
233 m_scene.AssetService.Store(asset); 233 m_scene.AssetService.Store(asset);
234 } 234 }
235 else 235 else
236 { 236 {
237 m_log.WarnFormat( 237 m_log.WarnFormat(
238 "[AV FACTORY]: Baked texture id {0} not found for bake {1} for avatar {2} in {3} when trying to save permanently", 238 "[AV FACTORY]: Baked texture id {0} not found for bake {1} for avatar {2} in {3} when trying to save permanently",
239 bakedTextureFace.TextureID, bakeType, sp.Name, m_scene.RegionInfo.RegionName); 239 bakedTextureFace.TextureID, bakeType, sp.Name, m_scene.RegionInfo.RegionName);
240 } 240 }
241 } 241 }
242 return true; 242 return true;
243 } 243 }
244 244
245 /// <summary> 245 /// <summary>
246 /// Check for the existence of the baked texture assets. 246 /// Check for the existence of the baked texture assets.
247 /// </summary> 247 /// </summary>
@@ -249,42 +249,42 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
249 public bool ValidateBakedTextureCache(IScenePresence sp) 249 public bool ValidateBakedTextureCache(IScenePresence sp)
250 { 250 {
251 return ValidateBakedTextureCache(sp, true); 251 return ValidateBakedTextureCache(sp, true);
252 } 252 }
253 253
254 /// <summary> 254 /// <summary>
255 /// Queue up a request to send appearance, makes it possible to 255 /// Queue up a request to send appearance, makes it possible to
256 /// accumulate changes without sending out each one separately. 256 /// accumulate changes without sending out each one separately.
257 /// </summary> 257 /// </summary>
258 public void QueueAppearanceSend(UUID agentid) 258 public void QueueAppearanceSend(UUID agentid)
259 { 259 {
260 // m_log.WarnFormat("[AVFACTORY]: Queue appearance send for {0}", agentid); 260 // m_log.WarnFormat("[AVFACTORY]: Queue appearance send for {0}", agentid);
261 261
262 // 10000 ticks per millisecond, 1000 milliseconds per second 262 // 10000 ticks per millisecond, 1000 milliseconds per second
263 long timestamp = DateTime.Now.Ticks + Convert.ToInt64(m_sendtime * 1000 * 10000); 263 long timestamp = DateTime.Now.Ticks + Convert.ToInt64(m_sendtime * 1000 * 10000);
264 lock (m_sendqueue) 264 lock (m_sendqueue)
265 { 265 {
266 m_sendqueue[agentid] = timestamp; 266 m_sendqueue[agentid] = timestamp;
267 m_updateTimer.Start(); 267 m_updateTimer.Start();
268 } 268 }
269 } 269 }
270 270
271 public void QueueAppearanceSave(UUID agentid) 271 public void QueueAppearanceSave(UUID agentid)
272 { 272 {
273 // m_log.WarnFormat("[AVFACTORY]: Queue appearance save for {0}", agentid); 273 // m_log.WarnFormat("[AVFACTORY]: Queue appearance save for {0}", agentid);
274 274
275 // 10000 ticks per millisecond, 1000 milliseconds per second 275 // 10000 ticks per millisecond, 1000 milliseconds per second
276 long timestamp = DateTime.Now.Ticks + Convert.ToInt64(m_savetime * 1000 * 10000); 276 long timestamp = DateTime.Now.Ticks + Convert.ToInt64(m_savetime * 1000 * 10000);
277 lock (m_savequeue) 277 lock (m_savequeue)
278 { 278 {
279 m_savequeue[agentid] = timestamp; 279 m_savequeue[agentid] = timestamp;
280 m_updateTimer.Start(); 280 m_updateTimer.Start();
281 } 281 }
282 } 282 }
283 283
284 #endregion 284 #endregion
285 285
286 #region AvatarFactoryModule private methods 286 #region AvatarFactoryModule private methods
287 287
288 /// <summary> 288 /// <summary>
289 /// Check for the existence of the baked texture assets. Request a rebake 289 /// Check for the existence of the baked texture assets. Request a rebake
290 /// unless checkonly is true. 290 /// unless checkonly is true.
@@ -416,105 +416,105 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
416 416
417 if (m_savequeue.Count == 0 && m_sendqueue.Count == 0) 417 if (m_savequeue.Count == 0 && m_sendqueue.Count == 0)
418 m_updateTimer.Stop(); 418 m_updateTimer.Stop();
419 } 419 }
420 420
421 private void SaveAppearance(UUID agentid) 421 private void SaveAppearance(UUID agentid)
422 { 422 {
423 // We must set appearance parameters in the en_US culture in order to avoid issues where values are saved 423 // We must set appearance parameters in the en_US culture in order to avoid issues where values are saved
424 // in a culture where decimal points are commas and then reloaded in a culture which just treats them as 424 // in a culture where decimal points are commas and then reloaded in a culture which just treats them as
425 // number seperators. 425 // number seperators.
426 Culture.SetCurrentCulture(); 426 Culture.SetCurrentCulture();
427 427
428 ScenePresence sp = m_scene.GetScenePresence(agentid); 428 ScenePresence sp = m_scene.GetScenePresence(agentid);
429 if (sp == null) 429 if (sp == null)
430 { 430 {
431 m_log.WarnFormat("[AVFACTORY]: Agent {0} no longer in the scene", agentid); 431 m_log.WarnFormat("[AVFACTORY]: Agent {0} no longer in the scene", agentid);
432 return; 432 return;
433 } 433 }
434 434
435 // m_log.WarnFormat("[AVFACTORY] avatar {0} save appearance",agentid); 435 // m_log.WarnFormat("[AVFACTORY] avatar {0} save appearance",agentid);
436 436
437 // This could take awhile since it needs to pull inventory 437 // This could take awhile since it needs to pull inventory
438 // We need to do it at the point of save so that there is a sufficient delay for any upload of new body part/shape 438 // We need to do it at the point of save so that there is a sufficient delay for any upload of new body part/shape
439 // assets and item asset id changes to complete. 439 // assets and item asset id changes to complete.
440 // I don't think we need to worry about doing this within m_setAppearanceLock since the queueing avoids 440 // I don't think we need to worry about doing this within m_setAppearanceLock since the queueing avoids
441 // multiple save requests. 441 // multiple save requests.
442 SetAppearanceAssets(sp.UUID, sp.Appearance); 442 SetAppearanceAssets(sp.UUID, sp.Appearance);
443 443
444 m_scene.AvatarService.SetAppearance(agentid, sp.Appearance); 444 m_scene.AvatarService.SetAppearance(agentid, sp.Appearance);
445 } 445 }
446 446
447 private void SetAppearanceAssets(UUID userID, AvatarAppearance appearance) 447 private void SetAppearanceAssets(UUID userID, AvatarAppearance appearance)
448 { 448 {
449 IInventoryService invService = m_scene.InventoryService; 449 IInventoryService invService = m_scene.InventoryService;
450 450
451 if (invService.GetRootFolder(userID) != null) 451 if (invService.GetRootFolder(userID) != null)
452 { 452 {
453 for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++) 453 for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++)
454 { 454 {
455 for (int j = 0; j < appearance.Wearables[j].Count; j++) 455 for (int j = 0; j < appearance.Wearables[j].Count; j++)
456 { 456 {
457 if (appearance.Wearables[i][j].ItemID == UUID.Zero) 457 if (appearance.Wearables[i][j].ItemID == UUID.Zero)
458 continue; 458 continue;
459 459
460 // Ignore ruth's assets 460 // Ignore ruth's assets
461 if (appearance.Wearables[i][j].ItemID == AvatarWearable.DefaultWearables[i][0].ItemID) 461 if (appearance.Wearables[i][j].ItemID == AvatarWearable.DefaultWearables[i][0].ItemID)
462 continue; 462 continue;
463 InventoryItemBase baseItem = new InventoryItemBase(appearance.Wearables[i][j].ItemID, userID); 463 InventoryItemBase baseItem = new InventoryItemBase(appearance.Wearables[i][j].ItemID, userID);
464 baseItem = invService.GetItem(baseItem); 464 baseItem = invService.GetItem(baseItem);
465 465
466 if (baseItem != null) 466 if (baseItem != null)
467 { 467 {
468 appearance.Wearables[i].Add(appearance.Wearables[i][j].ItemID, baseItem.AssetID); 468 appearance.Wearables[i].Add(appearance.Wearables[i][j].ItemID, baseItem.AssetID);
469 } 469 }
470 else 470 else
471 { 471 {
472 m_log.ErrorFormat( 472 m_log.ErrorFormat(
473 "[AVFACTORY]: Can't find inventory item {0} for {1}, setting to default", 473 "[AVFACTORY]: Can't find inventory item {0} for {1}, setting to default",
474 appearance.Wearables[i][j].ItemID, (WearableType)i); 474 appearance.Wearables[i][j].ItemID, (WearableType)i);
475 475
476 appearance.Wearables[i].RemoveItem(appearance.Wearables[i][j].ItemID); 476 appearance.Wearables[i].RemoveItem(appearance.Wearables[i][j].ItemID);
477 } 477 }
478 } 478 }
479 } 479 }
480 } 480 }
481 else 481 else
482 { 482 {
483 m_log.WarnFormat("[AVFACTORY]: user {0} has no inventory, appearance isn't going to work", userID); 483 m_log.WarnFormat("[AVFACTORY]: user {0} has no inventory, appearance isn't going to work", userID);
484 } 484 }
485 } 485 }
486 486
487 #endregion 487 #endregion
488 488
489 #region Client Event Handlers 489 #region Client Event Handlers
490 /// <summary> 490 /// <summary>
491 /// Tell the client for this scene presence what items it should be wearing now 491 /// Tell the client for this scene presence what items it should be wearing now
492 /// </summary> 492 /// </summary>
493 /// <param name="client"></param> 493 /// <param name="client"></param>
494 private void Client_OnRequestWearables(IClientAPI client) 494 private void Client_OnRequestWearables(IClientAPI client)
495 { 495 {
496 // m_log.DebugFormat("[AVFACTORY]: Client_OnRequestWearables called for {0} ({1})", client.Name, client.AgentId); 496 // m_log.DebugFormat("[AVFACTORY]: Client_OnRequestWearables called for {0} ({1})", client.Name, client.AgentId);
497 ScenePresence sp = m_scene.GetScenePresence(client.AgentId); 497 ScenePresence sp = m_scene.GetScenePresence(client.AgentId);
498 if (sp != null) 498 if (sp != null)
499 client.SendWearables(sp.Appearance.Wearables, sp.Appearance.Serial++); 499 client.SendWearables(sp.Appearance.Wearables, sp.Appearance.Serial++);
500 else 500 else
501 m_log.WarnFormat("[AVFACTORY]: Client_OnRequestWearables unable to find presence for {0}", client.AgentId); 501 m_log.WarnFormat("[AVFACTORY]: Client_OnRequestWearables unable to find presence for {0}", client.AgentId);
502 } 502 }
503 503
504 /// <summary> 504 /// <summary>
505 /// Set appearance data (texture asset IDs and slider settings) received from a client 505 /// Set appearance data (texture asset IDs and slider settings) received from a client
506 /// </summary> 506 /// </summary>
507 /// <param name="client"></param> 507 /// <param name="client"></param>
508 /// <param name="texture"></param> 508 /// <param name="texture"></param>
509 /// <param name="visualParam"></param> 509 /// <param name="visualParam"></param>
510 private void Client_OnSetAppearance(IClientAPI client, Primitive.TextureEntry textureEntry, byte[] visualParams) 510 private void Client_OnSetAppearance(IClientAPI client, Primitive.TextureEntry textureEntry, byte[] visualParams)
511 { 511 {
512 // m_log.WarnFormat("[AVFACTORY]: Client_OnSetAppearance called for {0} ({1})", client.Name, client.AgentId); 512 // m_log.WarnFormat("[AVFACTORY]: Client_OnSetAppearance called for {0} ({1})", client.Name, client.AgentId);
513 ScenePresence sp = m_scene.GetScenePresence(client.AgentId); 513 ScenePresence sp = m_scene.GetScenePresence(client.AgentId);
514 if (sp != null) 514 if (sp != null)
515 SetAppearance(sp, textureEntry, visualParams); 515 SetAppearance(sp, textureEntry, visualParams);
516 else 516 else
517 m_log.WarnFormat("[AVFACTORY]: Client_OnSetAppearance unable to find presence for {0}", client.AgentId); 517 m_log.WarnFormat("[AVFACTORY]: Client_OnSetAppearance unable to find presence for {0}", client.AgentId);
518 } 518 }
519 519
520 /// <summary> 520 /// <summary>
@@ -523,7 +523,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
523 /// <param name="client"></param> 523 /// <param name="client"></param>
524 /// <param name="e"></param> 524 /// <param name="e"></param>
525 private void Client_OnAvatarNowWearing(IClientAPI client, AvatarWearingArgs e) 525 private void Client_OnAvatarNowWearing(IClientAPI client, AvatarWearingArgs e)
526 { 526 {
527 // m_log.WarnFormat("[AVFACTORY]: Client_OnAvatarNowWearing called for {0} ({1})", client.Name, client.AgentId); 527 // m_log.WarnFormat("[AVFACTORY]: Client_OnAvatarNowWearing called for {0} ({1})", client.Name, client.AgentId);
528 ScenePresence sp = m_scene.GetScenePresence(client.AgentId); 528 ScenePresence sp = m_scene.GetScenePresence(client.AgentId);
529 if (sp == null) 529 if (sp == null)
@@ -558,8 +558,8 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
558 // of visual param and baked texture changes. When those complete, the new appearance will be sent 558 // of visual param and baked texture changes. When those complete, the new appearance will be sent
559 559
560 QueueAppearanceSave(client.AgentId); 560 QueueAppearanceSave(client.AgentId);
561 } 561 }
562 } 562 }
563 #endregion 563 #endregion
564 } 564 }
565} 565}
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs
index 931d52f..11a0a86 100644
--- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs
@@ -82,7 +82,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
82 82
83 AvatarFactoryModule afm = new AvatarFactoryModule(); 83 AvatarFactoryModule afm = new AvatarFactoryModule();
84 TestScene scene = SceneHelpers.SetupScene(assetCache); 84 TestScene scene = SceneHelpers.SetupScene(assetCache);
85 SceneHelpers.SetupSceneModules(scene, afm); 85 SceneHelpers.SetupSceneModules(scene, afm);
86 ScenePresence sp = SceneHelpers.AddScenePresence(scene, userId); 86 ScenePresence sp = SceneHelpers.AddScenePresence(scene, userId);
87 87
88 // TODO: Use the actual BunchOfCaps functionality once we slot in the CapabilitiesModules 88 // TODO: Use the actual BunchOfCaps functionality once we slot in the CapabilitiesModules
diff --git a/OpenSim/Region/Framework/Interfaces/IAvatarFactoryModule.cs b/OpenSim/Region/Framework/Interfaces/IAvatarFactoryModule.cs
index 98228e4..26bc922 100644
--- a/OpenSim/Region/Framework/Interfaces/IAvatarFactoryModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IAvatarFactoryModule.cs
@@ -32,8 +32,8 @@ using OpenSim.Framework;
32namespace OpenSim.Region.Framework.Interfaces 32namespace OpenSim.Region.Framework.Interfaces
33{ 33{
34 public interface IAvatarFactoryModule 34 public interface IAvatarFactoryModule
35 { 35 {
36 36
37 void SetAppearance(IScenePresence sp, Primitive.TextureEntry textureEntry, byte[] visualParams); 37 void SetAppearance(IScenePresence sp, Primitive.TextureEntry textureEntry, byte[] visualParams);
38 38
39 /// <summary> 39 /// <summary>
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 724c635..64ed6c7 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -960,6 +960,46 @@ namespace OpenSim.Region.Framework.Scenes
960 return found; 960 return found;
961 } 961 }
962 962
963 /// <summary>
964 /// Checks whether this region has a neighbour in the given direction.
965 /// </summary>
966 /// <param name="car"></param>
967 /// <param name="fix"></param>
968 /// <returns>
969 /// An integer which represents a compass point. N == 1, going clockwise until we reach NW == 8.
970 /// Returns a positive integer if there is a region in that direction, a negative integer if not.
971 /// </returns>
972 public int HaveNeighbor(Cardinals car, ref int[] fix)
973 {
974 uint neighbourx = RegionInfo.RegionLocX;
975 uint neighboury = RegionInfo.RegionLocY;
976
977 int dir = (int)car;
978
979 if (dir > 1 && dir < 5) //Heading East
980 neighbourx++;
981 else if (dir > 5) // Heading West
982 neighbourx--;
983
984 if (dir < 3 || dir == 8) // Heading North
985 neighboury++;
986 else if (dir > 3 && dir < 7) // Heading Sout
987 neighboury--;
988
989 int x = (int)(neighbourx * Constants.RegionSize);
990 int y = (int)(neighboury * Constants.RegionSize);
991 GridRegion neighbourRegion = GridService.GetRegionByPosition(RegionInfo.ScopeID, x, y);
992
993 if (neighbourRegion == null)
994 {
995 fix[0] = (int)(RegionInfo.RegionLocX - neighbourx);
996 fix[1] = (int)(RegionInfo.RegionLocY - neighboury);
997 return dir * (-1);
998 }
999 else
1000 return dir;
1001 }
1002
963 // Alias IncomingHelloNeighbour OtherRegionUp, for now 1003 // Alias IncomingHelloNeighbour OtherRegionUp, for now
964 public GridRegion IncomingHelloNeighbour(RegionInfo neighbour) 1004 public GridRegion IncomingHelloNeighbour(RegionInfo neighbour)
965 { 1005 {
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 464f8f0..8eb069f 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -2782,17 +2782,17 @@ namespace OpenSim.Region.Framework.Scenes
2782 if (m_scene.TestBorderCross(pos2, Cardinals.S)) 2782 if (m_scene.TestBorderCross(pos2, Cardinals.S))
2783 { 2783 {
2784 needsTransit = true; 2784 needsTransit = true;
2785 neighbor = HaveNeighbor(Cardinals.SW, ref fix); 2785 neighbor = m_scene.HaveNeighbor(Cardinals.SW, ref fix);
2786 } 2786 }
2787 else if (m_scene.TestBorderCross(pos2, Cardinals.N)) 2787 else if (m_scene.TestBorderCross(pos2, Cardinals.N))
2788 { 2788 {
2789 needsTransit = true; 2789 needsTransit = true;
2790 neighbor = HaveNeighbor(Cardinals.NW, ref fix); 2790 neighbor = m_scene.HaveNeighbor(Cardinals.NW, ref fix);
2791 } 2791 }
2792 else 2792 else
2793 { 2793 {
2794 needsTransit = true; 2794 needsTransit = true;
2795 neighbor = HaveNeighbor(Cardinals.W, ref fix); 2795 neighbor = m_scene.HaveNeighbor(Cardinals.W, ref fix);
2796 } 2796 }
2797 } 2797 }
2798 else if (m_scene.TestBorderCross(pos2, Cardinals.E)) 2798 else if (m_scene.TestBorderCross(pos2, Cardinals.E))
@@ -2800,28 +2800,28 @@ namespace OpenSim.Region.Framework.Scenes
2800 if (m_scene.TestBorderCross(pos2, Cardinals.S)) 2800 if (m_scene.TestBorderCross(pos2, Cardinals.S))
2801 { 2801 {
2802 needsTransit = true; 2802 needsTransit = true;
2803 neighbor = HaveNeighbor(Cardinals.SE, ref fix); 2803 neighbor = m_scene.HaveNeighbor(Cardinals.SE, ref fix);
2804 } 2804 }
2805 else if (m_scene.TestBorderCross(pos2, Cardinals.N)) 2805 else if (m_scene.TestBorderCross(pos2, Cardinals.N))
2806 { 2806 {
2807 needsTransit = true; 2807 needsTransit = true;
2808 neighbor = HaveNeighbor(Cardinals.NE, ref fix); 2808 neighbor = m_scene.HaveNeighbor(Cardinals.NE, ref fix);
2809 } 2809 }
2810 else 2810 else
2811 { 2811 {
2812 needsTransit = true; 2812 needsTransit = true;
2813 neighbor = HaveNeighbor(Cardinals.E, ref fix); 2813 neighbor = m_scene.HaveNeighbor(Cardinals.E, ref fix);
2814 } 2814 }
2815 } 2815 }
2816 else if (m_scene.TestBorderCross(pos2, Cardinals.S)) 2816 else if (m_scene.TestBorderCross(pos2, Cardinals.S))
2817 { 2817 {
2818 needsTransit = true; 2818 needsTransit = true;
2819 neighbor = HaveNeighbor(Cardinals.S, ref fix); 2819 neighbor = m_scene.HaveNeighbor(Cardinals.S, ref fix);
2820 } 2820 }
2821 else if (m_scene.TestBorderCross(pos2, Cardinals.N)) 2821 else if (m_scene.TestBorderCross(pos2, Cardinals.N))
2822 { 2822 {
2823 needsTransit = true; 2823 needsTransit = true;
2824 neighbor = HaveNeighbor(Cardinals.N, ref fix); 2824 neighbor = m_scene.HaveNeighbor(Cardinals.N, ref fix);
2825 } 2825 }
2826 2826
2827 // Makes sure avatar does not end up outside region 2827 // Makes sure avatar does not end up outside region
@@ -2897,46 +2897,6 @@ namespace OpenSim.Region.Framework.Scenes
2897 } 2897 }
2898 2898
2899 /// <summary> 2899 /// <summary>
2900 /// Checks whether this region has a neighbour in the given direction.
2901 /// </summary>
2902 /// <param name="car"></param>
2903 /// <param name="fix"></param>
2904 /// <returns>
2905 /// An integer which represents a compass point. N == 1, going clockwise until we reach NW == 8.
2906 /// Returns a positive integer if there is a region in that direction, a negative integer if not.
2907 /// </returns>
2908 protected int HaveNeighbor(Cardinals car, ref int[] fix)
2909 {
2910 uint neighbourx = m_scene.RegionInfo.RegionLocX;
2911 uint neighboury = m_scene.RegionInfo.RegionLocY;
2912
2913 int dir = (int)car;
2914
2915 if (dir > 1 && dir < 5) //Heading East
2916 neighbourx++;
2917 else if (dir > 5) // Heading West
2918 neighbourx--;
2919
2920 if (dir < 3 || dir == 8) // Heading North
2921 neighboury++;
2922 else if (dir > 3 && dir < 7) // Heading Sout
2923 neighboury--;
2924
2925 int x = (int)(neighbourx * Constants.RegionSize);
2926 int y = (int)(neighboury * Constants.RegionSize);
2927 GridRegion neighbourRegion = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, x, y);
2928
2929 if (neighbourRegion == null)
2930 {
2931 fix[0] = (int)(m_scene.RegionInfo.RegionLocX - neighbourx);
2932 fix[1] = (int)(m_scene.RegionInfo.RegionLocY - neighboury);
2933 return dir * (-1);
2934 }
2935 else
2936 return dir;
2937 }
2938
2939 /// <summary>
2940 /// Moves the agent outside the region bounds 2900 /// Moves the agent outside the region bounds
2941 /// Tells neighbor region that we're crossing to it 2901 /// Tells neighbor region that we're crossing to it
2942 /// If the neighbor accepts, remove the agent's viewable avatar from this scene 2902 /// If the neighbor accepts, remove the agent's viewable avatar from this scene