aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorJeff Ames2007-11-07 02:42:18 +0000
committerJeff Ames2007-11-07 02:42:18 +0000
commitf86a65f14be58d6458efb2384a72180a0af8306d (patch)
treeb61d8123d4e3811688acc7900d19c7b044242897 /OpenSim
parent* Moved /branches/ruby to /trunk/share/ruby (diff)
downloadopensim-SC_OLD-f86a65f14be58d6458efb2384a72180a0af8306d.zip
opensim-SC_OLD-f86a65f14be58d6458efb2384a72180a0af8306d.tar.gz
opensim-SC_OLD-f86a65f14be58d6458efb2384a72180a0af8306d.tar.bz2
opensim-SC_OLD-f86a65f14be58d6458efb2384a72180a0af8306d.tar.xz
refactored some duplicate SceneObjectGroup searching code in Scene
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/Environment/Scenes/InnerScene.cs264
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.Inventory.cs70
2 files changed, 98 insertions, 236 deletions
diff --git a/OpenSim/Region/Environment/Scenes/InnerScene.cs b/OpenSim/Region/Environment/Scenes/InnerScene.cs
index 8ed2352..90478c6 100644
--- a/OpenSim/Region/Environment/Scenes/InnerScene.cs
+++ b/OpenSim/Region/Environment/Scenes/InnerScene.cs
@@ -226,40 +226,50 @@ namespace OpenSim.Region.Environment.Scenes
226 return null; 226 return null;
227 } 227 }
228 228
229 public SceneObjectPart GetSceneObjectPart(uint localID) 229 private SceneObjectGroup GetGroupByPrim(uint localID)
230 { 230 {
231 bool hasPrim = false;
232 foreach (EntityBase ent in Entities.Values) 231 foreach (EntityBase ent in Entities.Values)
233 { 232 {
234 if (ent is SceneObjectGroup) 233 if (ent is SceneObjectGroup)
235 { 234 {
236 hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); 235 if (((SceneObjectGroup)ent).HasChildPrim(localID))
237 if (hasPrim != false) 236 return (SceneObjectGroup)ent;
238 {
239 return ((SceneObjectGroup)ent).GetChildPart(localID);
240 }
241 } 237 }
242 } 238 }
243 return null; 239 return null;
244 } 240 }
245 241
246 public SceneObjectPart GetSceneObjectPart(LLUUID fullID) 242 private SceneObjectGroup GetGroupByPrim(LLUUID fullID)
247 { 243 {
248 bool hasPrim = false;
249 foreach (EntityBase ent in Entities.Values) 244 foreach (EntityBase ent in Entities.Values)
250 { 245 {
251 if (ent is SceneObjectGroup) 246 if (ent is SceneObjectGroup)
252 { 247 {
253 hasPrim = ((SceneObjectGroup)ent).HasChildPrim(fullID); 248 if (((SceneObjectGroup)ent).HasChildPrim(fullID))
254 if (hasPrim != false) 249 return (SceneObjectGroup)ent;
255 {
256 return ((SceneObjectGroup)ent).GetChildPart(fullID);
257 }
258 } 250 }
259 } 251 }
260 return null; 252 return null;
261 } 253 }
262 254
255 public SceneObjectPart GetSceneObjectPart(uint localID)
256 {
257 SceneObjectGroup group = GetGroupByPrim(localID);
258 if (group != null)
259 return group.GetChildPart(localID);
260 else
261 return null;
262 }
263
264 public SceneObjectPart GetSceneObjectPart(LLUUID fullID)
265 {
266 SceneObjectGroup group = GetGroupByPrim(fullID);
267 if (group != null)
268 return group.GetChildPart(fullID);
269 else
270 return null;
271 }
272
263 internal bool TryGetAvatar(LLUUID avatarId, out ScenePresence avatar) 273 internal bool TryGetAvatar(LLUUID avatarId, out ScenePresence avatar)
264 { 274 {
265 ScenePresence presence; 275 ScenePresence presence;
@@ -302,19 +312,11 @@ namespace OpenSim.Region.Environment.Scenes
302 312
303 public LLUUID ConvertLocalIDToFullID(uint localID) 313 public LLUUID ConvertLocalIDToFullID(uint localID)
304 { 314 {
305 bool hasPrim = false; 315 SceneObjectGroup group = GetGroupByPrim(localID);
306 foreach (EntityBase ent in Entities.Values) 316 if (group != null)
307 { 317 return group.GetPartsFullID(localID);
308 if (ent is SceneObjectGroup) 318 else
309 { 319 return LLUUID.Zero;
310 hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID);
311 if (hasPrim != false)
312 {
313 return ((SceneObjectGroup)ent).GetPartsFullID(localID);
314 }
315 }
316 }
317 return LLUUID.Zero;
318 } 320 }
319 321
320 public void SendAllSceneObjectsToClient(ScenePresence presence) 322 public void SendAllSceneObjectsToClient(ScenePresence presence)
@@ -346,19 +348,9 @@ namespace OpenSim.Region.Environment.Scenes
346 /// <param name="remoteClient"></param> 348 /// <param name="remoteClient"></param>
347 public void UpdatePrimScale(uint localID, LLVector3 scale, IClientAPI remoteClient) 349 public void UpdatePrimScale(uint localID, LLVector3 scale, IClientAPI remoteClient)
348 { 350 {
349 bool hasPrim = false; 351 SceneObjectGroup group = GetGroupByPrim(localID);
350 foreach (EntityBase ent in Entities.Values) 352 if (group != null)
351 { 353 group.Resize(scale, localID);
352 if (ent is SceneObjectGroup)
353 {
354 hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID);
355 if (hasPrim != false)
356 {
357 ((SceneObjectGroup)ent).Resize(scale, localID);
358 break;
359 }
360 }
361 }
362 } 354 }
363 355
364 /// <summary> 356 /// <summary>
@@ -369,19 +361,9 @@ namespace OpenSim.Region.Environment.Scenes
369 /// <param name="remoteClient"></param> 361 /// <param name="remoteClient"></param>
370 public void UpdatePrimSingleRotation(uint localID, LLQuaternion rot, IClientAPI remoteClient) 362 public void UpdatePrimSingleRotation(uint localID, LLQuaternion rot, IClientAPI remoteClient)
371 { 363 {
372 bool hasPrim = false; 364 SceneObjectGroup group = GetGroupByPrim(localID);
373 foreach (EntityBase ent in Entities.Values) 365 if (group != null)
374 { 366 group.UpdateSingleRotation(rot, localID);
375 if (ent is SceneObjectGroup)
376 {
377 hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID);
378 if (hasPrim != false)
379 {
380 ((SceneObjectGroup)ent).UpdateSingleRotation(rot, localID);
381 break;
382 }
383 }
384 }
385 } 367 }
386 368
387 /// <summary> 369 /// <summary>
@@ -392,19 +374,9 @@ namespace OpenSim.Region.Environment.Scenes
392 /// <param name="remoteClient"></param> 374 /// <param name="remoteClient"></param>
393 public void UpdatePrimRotation(uint localID, LLQuaternion rot, IClientAPI remoteClient) 375 public void UpdatePrimRotation(uint localID, LLQuaternion rot, IClientAPI remoteClient)
394 { 376 {
395 bool hasPrim = false; 377 SceneObjectGroup group = GetGroupByPrim(localID);
396 foreach (EntityBase ent in Entities.Values) 378 if (group != null)
397 { 379 group.UpdateGroupRotation(rot);
398 if (ent is SceneObjectGroup)
399 {
400 hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID);
401 if (hasPrim != false)
402 {
403 ((SceneObjectGroup)ent).UpdateGroupRotation(rot);
404 break;
405 }
406 }
407 }
408 } 380 }
409 381
410 /// <summary> 382 /// <summary>
@@ -416,36 +388,16 @@ namespace OpenSim.Region.Environment.Scenes
416 /// <param name="remoteClient"></param> 388 /// <param name="remoteClient"></param>
417 public void UpdatePrimRotation(uint localID, LLVector3 pos, LLQuaternion rot, IClientAPI remoteClient) 389 public void UpdatePrimRotation(uint localID, LLVector3 pos, LLQuaternion rot, IClientAPI remoteClient)
418 { 390 {
419 bool hasPrim = false; 391 SceneObjectGroup group = GetGroupByPrim(localID);
420 foreach (EntityBase ent in Entities.Values) 392 if (group != null)
421 { 393 group.UpdateGroupRotation(pos, rot);
422 if (ent is SceneObjectGroup)
423 {
424 hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID);
425 if (hasPrim != false)
426 {
427 ((SceneObjectGroup)ent).UpdateGroupRotation(pos, rot);
428 break;
429 }
430 }
431 }
432 } 394 }
433 395
434 public void UpdatePrimSinglePosition(uint localID, LLVector3 pos, IClientAPI remoteClient) 396 public void UpdatePrimSinglePosition(uint localID, LLVector3 pos, IClientAPI remoteClient)
435 { 397 {
436 bool hasPrim = false; 398 SceneObjectGroup group = GetGroupByPrim(localID);
437 foreach (EntityBase ent in Entities.Values) 399 if (group != null)
438 { 400 group.UpdateSinglePosition(pos, localID);
439 if (ent is SceneObjectGroup)
440 {
441 hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID);
442 if (hasPrim != false)
443 {
444 ((SceneObjectGroup)ent).UpdateSinglePosition(pos, localID);
445 break;
446 }
447 }
448 }
449 } 401 }
450 402
451 /// <summary> 403 /// <summary>
@@ -456,19 +408,9 @@ namespace OpenSim.Region.Environment.Scenes
456 /// <param name="remoteClient"></param> 408 /// <param name="remoteClient"></param>
457 public void UpdatePrimPosition(uint localID, LLVector3 pos, IClientAPI remoteClient) 409 public void UpdatePrimPosition(uint localID, LLVector3 pos, IClientAPI remoteClient)
458 { 410 {
459 bool hasPrim = false; 411 SceneObjectGroup group = GetGroupByPrim(localID);
460 foreach (EntityBase ent in Entities.Values) 412 if (group != null)
461 { 413 group.UpdateGroupPosition(pos);
462 if (ent is SceneObjectGroup)
463 {
464 hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID);
465 if (hasPrim != false)
466 {
467 ((SceneObjectGroup)ent).UpdateGroupPosition(pos);
468 break;
469 }
470 }
471 }
472 } 414 }
473 415
474 /// <summary> 416 /// <summary>
@@ -479,19 +421,9 @@ namespace OpenSim.Region.Environment.Scenes
479 /// <param name="remoteClient"></param> 421 /// <param name="remoteClient"></param>
480 public void UpdatePrimTexture(uint localID, byte[] texture, IClientAPI remoteClient) 422 public void UpdatePrimTexture(uint localID, byte[] texture, IClientAPI remoteClient)
481 { 423 {
482 bool hasPrim = false; 424 SceneObjectGroup group = GetGroupByPrim(localID);
483 foreach (EntityBase ent in Entities.Values) 425 if (group != null)
484 { 426 group.UpdateTextureEntry(localID, texture);
485 if (ent is SceneObjectGroup)
486 {
487 hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID);
488 if (hasPrim != false)
489 {
490 ((SceneObjectGroup)ent).UpdateTextureEntry(localID, texture);
491 break;
492 }
493 }
494 }
495 } 427 }
496 428
497 /// <summary> 429 /// <summary>
@@ -502,19 +434,9 @@ namespace OpenSim.Region.Environment.Scenes
502 /// <param name="remoteClient"></param> 434 /// <param name="remoteClient"></param>
503 public void UpdatePrimFlags(uint localID, Packet packet, IClientAPI remoteClient) 435 public void UpdatePrimFlags(uint localID, Packet packet, IClientAPI remoteClient)
504 { 436 {
505 bool hasprim = false; 437 SceneObjectGroup group = GetGroupByPrim(localID);
506 foreach (EntityBase ent in Entities.Values) 438 if (group != null)
507 { 439 group.UpdatePrimFlags(localID, (ushort)packet.Type, true, packet.ToBytes());
508 if (ent is SceneObjectGroup)
509 {
510 hasprim = ((SceneObjectGroup)ent).HasChildPrim(localID);
511 if (hasprim != false)
512 {
513 ((SceneObjectGroup)ent).UpdatePrimFlags(localID, (ushort)packet.Type, true, packet.ToBytes());
514 }
515 }
516 }
517
518 //System.Console.WriteLine("Got primupdate packet: " + packet.UsePhysics.ToString()); 440 //System.Console.WriteLine("Got primupdate packet: " + packet.UsePhysics.ToString());
519 } 441 }
520 442
@@ -522,19 +444,9 @@ namespace OpenSim.Region.Environment.Scenes
522 { 444 {
523 if (PermissionsMngr.CanEditObject(remoteClient.AgentId, objectID)) 445 if (PermissionsMngr.CanEditObject(remoteClient.AgentId, objectID))
524 { 446 {
525 bool hasPrim = false; 447 SceneObjectGroup group = GetGroupByPrim(objectID);
526 foreach (EntityBase ent in Entities.Values) 448 if (group != null)
527 { 449 group.GrabMovement(offset, pos, remoteClient);
528 if (ent is SceneObjectGroup)
529 {
530 hasPrim = ((SceneObjectGroup)ent).HasChildPrim(objectID);
531 if (hasPrim != false)
532 {
533 ((SceneObjectGroup)ent).GrabMovement(offset, pos, remoteClient);
534 break;
535 }
536 }
537 }
538 } 450 }
539 } 451 }
540 452
@@ -545,19 +457,9 @@ namespace OpenSim.Region.Environment.Scenes
545 /// <param name="description"></param> 457 /// <param name="description"></param>
546 public void PrimName(uint primLocalID, string name) 458 public void PrimName(uint primLocalID, string name)
547 { 459 {
548 bool hasPrim = false; 460 SceneObjectGroup group = GetGroupByPrim(primLocalID);
549 foreach (EntityBase ent in Entities.Values) 461 if (group != null)
550 { 462 group.SetPartName(name, primLocalID);
551 if (ent is SceneObjectGroup)
552 {
553 hasPrim = ((SceneObjectGroup)ent).HasChildPrim(primLocalID);
554 if (hasPrim != false)
555 {
556 ((SceneObjectGroup)ent).SetPartName(name, primLocalID);
557 break;
558 }
559 }
560 }
561 } 463 }
562 464
563 /// <summary> 465 /// <summary>
@@ -567,36 +469,16 @@ namespace OpenSim.Region.Environment.Scenes
567 /// <param name="description"></param> 469 /// <param name="description"></param>
568 public void PrimDescription(uint primLocalID, string description) 470 public void PrimDescription(uint primLocalID, string description)
569 { 471 {
570 bool hasPrim = false; 472 SceneObjectGroup group = GetGroupByPrim(primLocalID);
571 foreach (EntityBase ent in Entities.Values) 473 if (group != null)
572 { 474 group.SetPartDescription(description, primLocalID);
573 if (ent is SceneObjectGroup)
574 {
575 hasPrim = ((SceneObjectGroup)ent).HasChildPrim(primLocalID);
576 if (hasPrim != false)
577 {
578 ((SceneObjectGroup)ent).SetPartDescription(description, primLocalID);
579 break;
580 }
581 }
582 }
583 } 475 }
584 476
585 public void UpdateExtraParam(uint primLocalID, ushort type, bool inUse, byte[] data) 477 public void UpdateExtraParam(uint primLocalID, ushort type, bool inUse, byte[] data)
586 { 478 {
587 bool hasPrim = false; 479 SceneObjectGroup group = GetGroupByPrim(primLocalID);
588 foreach (EntityBase ent in Entities.Values) 480 if (group != null)
589 { 481 group.UpdateExtraParam(primLocalID, type, inUse, data);
590 if (ent is SceneObjectGroup)
591 {
592 hasPrim = ((SceneObjectGroup)ent).HasChildPrim(primLocalID);
593 if (hasPrim != false)
594 {
595 ((SceneObjectGroup)ent).UpdateExtraParam(primLocalID, type, inUse, data);
596 break;
597 }
598 }
599 }
600 } 482 }
601 483
602 /// <summary> 484 /// <summary>
@@ -606,19 +488,9 @@ namespace OpenSim.Region.Environment.Scenes
606 /// <param name="shapeBlock"></param> 488 /// <param name="shapeBlock"></param>
607 public void UpdatePrimShape(uint primLocalID, ObjectShapePacket.ObjectDataBlock shapeBlock) 489 public void UpdatePrimShape(uint primLocalID, ObjectShapePacket.ObjectDataBlock shapeBlock)
608 { 490 {
609 bool hasPrim = false; 491 SceneObjectGroup group = GetGroupByPrim(primLocalID);
610 foreach (EntityBase ent in Entities.Values) 492 if (group != null)
611 { 493 group.UpdateShape(shapeBlock, primLocalID);
612 if (ent is SceneObjectGroup)
613 {
614 hasPrim = ((SceneObjectGroup)ent).HasChildPrim(primLocalID);
615 if (hasPrim != false)
616 {
617 ((SceneObjectGroup)ent).UpdateShape(shapeBlock, primLocalID);
618 break;
619 }
620 }
621 }
622 } 494 }
623 495
624 /// <summary> 496 /// <summary>
diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
index 138cb20..f5e6f63 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
@@ -217,6 +217,19 @@ namespace OpenSim.Region.Environment.Scenes
217 } 217 }
218 } 218 }
219 219
220 private SceneObjectGroup GetGroupByPrim(uint localID)
221 {
222 foreach (EntityBase ent in Entities.Values)
223 {
224 if (ent is SceneObjectGroup)
225 {
226 if (((SceneObjectGroup)ent).HasChildPrim(localID))
227 return (SceneObjectGroup)ent;
228 }
229 }
230 return null;
231 }
232
220 /// <summary> 233 /// <summary>
221 /// 234 ///
222 /// </summary> 235 /// </summary>
@@ -224,23 +237,15 @@ namespace OpenSim.Region.Environment.Scenes
224 /// <param name="primLocalID"></param> 237 /// <param name="primLocalID"></param>
225 public void RequestTaskInventory(IClientAPI remoteClient, uint primLocalID) 238 public void RequestTaskInventory(IClientAPI remoteClient, uint primLocalID)
226 { 239 {
227 bool hasPrim = false; 240 SceneObjectGroup group = GetGroupByPrim(primLocalID);
228 foreach (EntityBase ent in Entities.Values) 241 if (group != null)
229 { 242 {
230 if (ent is SceneObjectGroup) 243 bool fileChange = group.GetPartInventoryFileName(remoteClient, primLocalID);
244 if (fileChange)
231 { 245 {
232 hasPrim = ((SceneObjectGroup) ent).HasChildPrim(primLocalID); 246 if (XferManager != null)
233 if (hasPrim != false)
234 { 247 {
235 bool fileChange = ((SceneObjectGroup) ent).GetPartInventoryFileName(remoteClient, primLocalID); 248 group.RequestInventoryFile(primLocalID, XferManager);
236 if (fileChange)
237 {
238 if (XferManager != null)
239 {
240 ((SceneObjectGroup) ent).RequestInventoryFile(primLocalID, XferManager);
241 }
242 }
243 break;
244 } 249 }
245 } 250 }
246 } 251 }
@@ -248,21 +253,14 @@ namespace OpenSim.Region.Environment.Scenes
248 253
249 public void RemoveTaskInventory(IClientAPI remoteClient, LLUUID itemID, uint localID) 254 public void RemoveTaskInventory(IClientAPI remoteClient, LLUUID itemID, uint localID)
250 { 255 {
251 bool hasPrim = false; 256 SceneObjectGroup group = GetGroupByPrim(localID);
252 foreach (EntityBase ent in Entities.Values) 257 if (group != null)
253 { 258 {
254 if (ent is SceneObjectGroup) 259 int type = group.RemoveInventoryItem(remoteClient, localID, itemID);
260 group.GetProperites(remoteClient);
261 if (type == 10)
255 { 262 {
256 hasPrim = ((SceneObjectGroup) ent).HasChildPrim(localID); 263 EventManager.TriggerRemoveScript(localID, itemID);
257 if (hasPrim != false)
258 {
259 int type = ((SceneObjectGroup) ent).RemoveInventoryItem(remoteClient, localID, itemID);
260 ((SceneObjectGroup) ent).GetProperites(remoteClient);
261 if (type == 10)
262 {
263 EventManager.TriggerRemoveScript(localID, itemID);
264 }
265 }
266 } 264 }
267 } 265 }
268 } 266 }
@@ -307,20 +305,12 @@ namespace OpenSim.Region.Environment.Scenes
307 305
308 if (rezzed) 306 if (rezzed)
309 { 307 {
310 bool hasPrim = false; 308 SceneObjectGroup group = GetGroupByPrim(localID);
311 foreach (EntityBase ent in Entities.Values) 309 if (group != null)
312 { 310 {
313 if (ent is SceneObjectGroup) 311 // TODO: do we care about the value of this bool?
314 { 312 bool added = group.AddInventoryItem(remoteClient, localID, item, copyID);
315 hasPrim = ((SceneObjectGroup) ent).HasChildPrim(localID); 313 group.GetProperites(remoteClient);
316 if (hasPrim != false)
317 {
318 bool added =
319 ((SceneObjectGroup) ent).AddInventoryItem(remoteClient, localID, item,
320 copyID);
321 ((SceneObjectGroup) ent).GetProperites(remoteClient);
322 }
323 }
324 } 314 }
325 } 315 }
326 } 316 }