diff options
author | Justin Clarke Casey | 2008-11-07 18:46:11 +0000 |
---|---|---|
committer | Justin Clarke Casey | 2008-11-07 18:46:11 +0000 |
commit | ebd9f22b29bfbe0cfb0689405984f856e0413405 (patch) | |
tree | afc766dad4e3888fd773ac0e5186a9fdb45fb88f /OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs | |
parent | * Apply patch in http://opensimulator.org/mantis/view.php?id=2397 (diff) | |
download | opensim-SC-ebd9f22b29bfbe0cfb0689405984f856e0413405.zip opensim-SC-ebd9f22b29bfbe0cfb0689405984f856e0413405.tar.gz opensim-SC-ebd9f22b29bfbe0cfb0689405984f856e0413405.tar.bz2 opensim-SC-ebd9f22b29bfbe0cfb0689405984f856e0413405.tar.xz |
* refactor: allocate local ids to prims only when an object is attached to a scene
Diffstat (limited to 'OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs')
-rw-r--r-- | OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs | 42 |
1 files changed, 29 insertions, 13 deletions
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs index a19564f..5926445 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs | |||
@@ -381,10 +381,16 @@ namespace OpenSim.Region.Environment.Scenes | |||
381 | /// <summary> | 381 | /// <summary> |
382 | /// Create an object using serialized data in OpenSim's original xml format. | 382 | /// Create an object using serialized data in OpenSim's original xml format. |
383 | /// </summary> | 383 | /// </summary> |
384 | public SceneObjectGroup(Scene scene, ulong regionHandle, string xmlData) | 384 | /// <param name="xmlData"></param> |
385 | { | 385 | /// <param name="isOriginalXmlFormat"> |
386 | m_scene = scene; | 386 | /// This parameter only exists to separate the two different xml constructors. In the future, versions should |
387 | m_regionHandle = regionHandle; | 387 | /// be specified within the xml itself. |
388 | /// </param> | ||
389 | public SceneObjectGroup(string xmlData, bool isOriginalXmlFormat) | ||
390 | { | ||
391 | if (!isOriginalXmlFormat) | ||
392 | throw new Exception("This constructor must specify the xml is in OpenSim's original format"); | ||
393 | |||
388 | // libomv.types changes UUID to Guid | 394 | // libomv.types changes UUID to Guid |
389 | xmlData = xmlData.Replace("<UUID>", "<Guid>"); | 395 | xmlData = xmlData.Replace("<UUID>", "<Guid>"); |
390 | xmlData = xmlData.Replace("</UUID>", "</Guid>"); | 396 | xmlData = xmlData.Replace("</UUID>", "</Guid>"); |
@@ -416,16 +422,15 @@ namespace OpenSim.Region.Environment.Scenes | |||
416 | { | 422 | { |
417 | reader.Read(); | 423 | reader.Read(); |
418 | SceneObjectPart part = SceneObjectPart.FromXml(reader); | 424 | SceneObjectPart part = SceneObjectPart.FromXml(reader); |
419 | part.LocalId = m_scene.PrimIDAllocate(); | ||
420 | linkNum = part.LinkNum; | 425 | linkNum = part.LinkNum; |
421 | AddPart(part); | 426 | AddPart(part); |
422 | part.LinkNum = linkNum; | 427 | part.LinkNum = linkNum; |
423 | part.RegionHandle = m_regionHandle; | ||
424 | 428 | ||
425 | part.TrimPermissions(); | 429 | part.TrimPermissions(); |
426 | part.StoreUndoState(); | 430 | part.StoreUndoState(); |
427 | } | 431 | } |
428 | break; | 432 | break; |
433 | |||
429 | case XmlNodeType.EndElement: | 434 | case XmlNodeType.EndElement: |
430 | break; | 435 | break; |
431 | } | 436 | } |
@@ -440,11 +445,6 @@ namespace OpenSim.Region.Environment.Scenes | |||
440 | 445 | ||
441 | reader.Close(); | 446 | reader.Close(); |
442 | sr.Close(); | 447 | sr.Close(); |
443 | |||
444 | m_rootPart.LocalId = m_scene.PrimIDAllocate(); | ||
445 | m_rootPart.ParentID = 0; | ||
446 | m_rootPart.RegionHandle = m_regionHandle; | ||
447 | UpdateParentIDs(); | ||
448 | } | 448 | } |
449 | 449 | ||
450 | /// <summary> | 450 | /// <summary> |
@@ -570,8 +570,24 @@ namespace OpenSim.Region.Environment.Scenes | |||
570 | /// <param name="scene"></param> | 570 | /// <param name="scene"></param> |
571 | public void AttachToScene(Scene scene) | 571 | public void AttachToScene(Scene scene) |
572 | { | 572 | { |
573 | m_scene = scene; | 573 | m_scene = scene; |
574 | RegionHandle = scene.RegionInfo.RegionHandle; | 574 | RegionHandle = m_scene.RegionInfo.RegionHandle; |
575 | |||
576 | m_rootPart.ParentID = 0; | ||
577 | m_rootPart.LocalId = m_scene.PrimIDAllocate(); | ||
578 | |||
579 | //UpdateParentIDs(); | ||
580 | |||
581 | // No need to lock here since part isn't yet in a scene | ||
582 | foreach (SceneObjectPart part in m_parts.Values) | ||
583 | { | ||
584 | if (Object.ReferenceEquals(part, m_rootPart)) | ||
585 | continue; | ||
586 | |||
587 | part.LocalId = m_scene.PrimIDAllocate(); | ||
588 | part.ParentID = m_rootPart.LocalId; | ||
589 | m_log.DebugFormat("[SCENE]: Given local id {0} to part {1}, linknum {2}, parent {3} {4}", part.LocalId, part.UUID, part.LinkNum, part.ParentID, part.ParentUUID); | ||
590 | } | ||
575 | 591 | ||
576 | ApplyPhysics(m_scene.m_physicalPrim); | 592 | ApplyPhysics(m_scene.m_physicalPrim); |
577 | 593 | ||