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 | |
parent | * Apply patch in http://opensimulator.org/mantis/view.php?id=2397 (diff) | |
download | opensim-SC_OLD-ebd9f22b29bfbe0cfb0689405984f856e0413405.zip opensim-SC_OLD-ebd9f22b29bfbe0cfb0689405984f856e0413405.tar.gz opensim-SC_OLD-ebd9f22b29bfbe0cfb0689405984f856e0413405.tar.bz2 opensim-SC_OLD-ebd9f22b29bfbe0cfb0689405984f856e0413405.tar.xz |
* refactor: allocate local ids to prims only when an object is attached to a scene
5 files changed, 37 insertions, 19 deletions
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestPreparation.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestPreparation.cs index 1fbc20f..0202841 100644 --- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestPreparation.cs +++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestPreparation.cs | |||
@@ -176,7 +176,7 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
176 | if (null != objectAsset) | 176 | if (null != objectAsset) |
177 | { | 177 | { |
178 | string xml = Utils.BytesToString(objectAsset.Data); | 178 | string xml = Utils.BytesToString(objectAsset.Data); |
179 | SceneObjectGroup sog = new SceneObjectGroup(m_scene, m_scene.RegionInfo.RegionHandle, xml); | 179 | SceneObjectGroup sog = new SceneObjectGroup(xml, true); |
180 | GetSceneObjectAssetUuids(sog, assetUuids); | 180 | GetSceneObjectAssetUuids(sog, assetUuids); |
181 | } | 181 | } |
182 | } | 182 | } |
diff --git a/OpenSim/Region/Environment/Modules/World/Serialiser/SceneXmlLoader.cs b/OpenSim/Region/Environment/Modules/World/Serialiser/SceneXmlLoader.cs index af69707..a069ac3 100644 --- a/OpenSim/Region/Environment/Modules/World/Serialiser/SceneXmlLoader.cs +++ b/OpenSim/Region/Environment/Modules/World/Serialiser/SceneXmlLoader.cs | |||
@@ -58,7 +58,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
58 | rootNode = doc.FirstChild; | 58 | rootNode = doc.FirstChild; |
59 | foreach (XmlNode aPrimNode in rootNode.ChildNodes) | 59 | foreach (XmlNode aPrimNode in rootNode.ChildNodes) |
60 | { | 60 | { |
61 | SceneObjectGroup obj = new SceneObjectGroup(scene, scene.RegionInfo.RegionHandle, aPrimNode.OuterXml); | 61 | SceneObjectGroup obj = new SceneObjectGroup(aPrimNode.OuterXml, true); |
62 | 62 | ||
63 | if (newIDS) | 63 | if (newIDS) |
64 | { | 64 | { |
diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs index c59fffc..4e93551 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs | |||
@@ -1953,8 +1953,10 @@ namespace OpenSim.Region.Environment.Scenes | |||
1953 | if (rezAsset != null) | 1953 | if (rezAsset != null) |
1954 | { | 1954 | { |
1955 | string xmlData = Utils.BytesToString(rezAsset.Data); | 1955 | string xmlData = Utils.BytesToString(rezAsset.Data); |
1956 | SceneObjectGroup group = new SceneObjectGroup(this, m_regionHandle, xmlData); | 1956 | SceneObjectGroup group = new SceneObjectGroup(xmlData, true); |
1957 | if (!ExternalChecks.ExternalChecksCanRezObject(group.Children.Count, remoteClient.AgentId, pos) && !attachment) | 1957 | if (!ExternalChecks.ExternalChecksCanRezObject( |
1958 | group.Children.Count, remoteClient.AgentId, pos) | ||
1959 | && !attachment) | ||
1958 | { | 1960 | { |
1959 | return null; | 1961 | return null; |
1960 | } | 1962 | } |
@@ -2091,7 +2093,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
2091 | if (rezAsset != null) | 2093 | if (rezAsset != null) |
2092 | { | 2094 | { |
2093 | string xmlData = Utils.BytesToString(rezAsset.Data); | 2095 | string xmlData = Utils.BytesToString(rezAsset.Data); |
2094 | SceneObjectGroup group = new SceneObjectGroup(this, m_regionHandle, xmlData); | 2096 | SceneObjectGroup group = new SceneObjectGroup(xmlData, true); |
2095 | 2097 | ||
2096 | if (!ExternalChecks.ExternalChecksCanRezObject(group.Children.Count, ownerID, pos)) | 2098 | if (!ExternalChecks.ExternalChecksCanRezObject(group.Children.Count, ownerID, pos)) |
2097 | { | 2099 | { |
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 40f8605..95d9f2a 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs | |||
@@ -1890,7 +1890,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
1890 | 1890 | ||
1891 | public void LoadPrimsFromXml(string fileName, bool newIdsFlag, Vector3 loadOffset) | 1891 | public void LoadPrimsFromXml(string fileName, bool newIdsFlag, Vector3 loadOffset) |
1892 | { | 1892 | { |
1893 | m_log.InfoFormat("[SCENE]: Loading prims in xml format to region {0} from {1}", RegionInfo.RegionName); | 1893 | m_log.InfoFormat("[SCENE]: Loading prims in xml format to region {0} from {1}", RegionInfo.RegionName, fileName); |
1894 | 1894 | ||
1895 | m_serialiser.LoadPrimsFromXml(this, fileName, newIdsFlag, loadOffset); | 1895 | m_serialiser.LoadPrimsFromXml(this, fileName, newIdsFlag, loadOffset); |
1896 | } | 1896 | } |
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 | ||