* refactor: allocate local ids to prims only when an object is attached to a scene
parent
2184f4b2a9
commit
ebd9f22b29
|
@ -176,7 +176,7 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
|
||||||
if (null != objectAsset)
|
if (null != objectAsset)
|
||||||
{
|
{
|
||||||
string xml = Utils.BytesToString(objectAsset.Data);
|
string xml = Utils.BytesToString(objectAsset.Data);
|
||||||
SceneObjectGroup sog = new SceneObjectGroup(m_scene, m_scene.RegionInfo.RegionHandle, xml);
|
SceneObjectGroup sog = new SceneObjectGroup(xml, true);
|
||||||
GetSceneObjectAssetUuids(sog, assetUuids);
|
GetSceneObjectAssetUuids(sog, assetUuids);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
rootNode = doc.FirstChild;
|
rootNode = doc.FirstChild;
|
||||||
foreach (XmlNode aPrimNode in rootNode.ChildNodes)
|
foreach (XmlNode aPrimNode in rootNode.ChildNodes)
|
||||||
{
|
{
|
||||||
SceneObjectGroup obj = new SceneObjectGroup(scene, scene.RegionInfo.RegionHandle, aPrimNode.OuterXml);
|
SceneObjectGroup obj = new SceneObjectGroup(aPrimNode.OuterXml, true);
|
||||||
|
|
||||||
if (newIDS)
|
if (newIDS)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1953,8 +1953,10 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
if (rezAsset != null)
|
if (rezAsset != null)
|
||||||
{
|
{
|
||||||
string xmlData = Utils.BytesToString(rezAsset.Data);
|
string xmlData = Utils.BytesToString(rezAsset.Data);
|
||||||
SceneObjectGroup group = new SceneObjectGroup(this, m_regionHandle, xmlData);
|
SceneObjectGroup group = new SceneObjectGroup(xmlData, true);
|
||||||
if (!ExternalChecks.ExternalChecksCanRezObject(group.Children.Count, remoteClient.AgentId, pos) && !attachment)
|
if (!ExternalChecks.ExternalChecksCanRezObject(
|
||||||
|
group.Children.Count, remoteClient.AgentId, pos)
|
||||||
|
&& !attachment)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -2091,7 +2093,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
if (rezAsset != null)
|
if (rezAsset != null)
|
||||||
{
|
{
|
||||||
string xmlData = Utils.BytesToString(rezAsset.Data);
|
string xmlData = Utils.BytesToString(rezAsset.Data);
|
||||||
SceneObjectGroup group = new SceneObjectGroup(this, m_regionHandle, xmlData);
|
SceneObjectGroup group = new SceneObjectGroup(xmlData, true);
|
||||||
|
|
||||||
if (!ExternalChecks.ExternalChecksCanRezObject(group.Children.Count, ownerID, pos))
|
if (!ExternalChecks.ExternalChecksCanRezObject(group.Children.Count, ownerID, pos))
|
||||||
{
|
{
|
||||||
|
|
|
@ -1890,7 +1890,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
|
|
||||||
public void LoadPrimsFromXml(string fileName, bool newIdsFlag, Vector3 loadOffset)
|
public void LoadPrimsFromXml(string fileName, bool newIdsFlag, Vector3 loadOffset)
|
||||||
{
|
{
|
||||||
m_log.InfoFormat("[SCENE]: Loading prims in xml format to region {0} from {1}", RegionInfo.RegionName);
|
m_log.InfoFormat("[SCENE]: Loading prims in xml format to region {0} from {1}", RegionInfo.RegionName, fileName);
|
||||||
|
|
||||||
m_serialiser.LoadPrimsFromXml(this, fileName, newIdsFlag, loadOffset);
|
m_serialiser.LoadPrimsFromXml(this, fileName, newIdsFlag, loadOffset);
|
||||||
}
|
}
|
||||||
|
|
|
@ -381,10 +381,16 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create an object using serialized data in OpenSim's original xml format.
|
/// Create an object using serialized data in OpenSim's original xml format.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public SceneObjectGroup(Scene scene, ulong regionHandle, string xmlData)
|
/// <param name="xmlData"></param>
|
||||||
|
/// <param name="isOriginalXmlFormat">
|
||||||
|
/// This parameter only exists to separate the two different xml constructors. In the future, versions should
|
||||||
|
/// be specified within the xml itself.
|
||||||
|
/// </param>
|
||||||
|
public SceneObjectGroup(string xmlData, bool isOriginalXmlFormat)
|
||||||
{
|
{
|
||||||
m_scene = scene;
|
if (!isOriginalXmlFormat)
|
||||||
m_regionHandle = regionHandle;
|
throw new Exception("This constructor must specify the xml is in OpenSim's original format");
|
||||||
|
|
||||||
// libomv.types changes UUID to Guid
|
// libomv.types changes UUID to Guid
|
||||||
xmlData = xmlData.Replace("<UUID>", "<Guid>");
|
xmlData = xmlData.Replace("<UUID>", "<Guid>");
|
||||||
xmlData = xmlData.Replace("</UUID>", "</Guid>");
|
xmlData = xmlData.Replace("</UUID>", "</Guid>");
|
||||||
|
@ -416,16 +422,15 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
{
|
{
|
||||||
reader.Read();
|
reader.Read();
|
||||||
SceneObjectPart part = SceneObjectPart.FromXml(reader);
|
SceneObjectPart part = SceneObjectPart.FromXml(reader);
|
||||||
part.LocalId = m_scene.PrimIDAllocate();
|
|
||||||
linkNum = part.LinkNum;
|
linkNum = part.LinkNum;
|
||||||
AddPart(part);
|
AddPart(part);
|
||||||
part.LinkNum = linkNum;
|
part.LinkNum = linkNum;
|
||||||
part.RegionHandle = m_regionHandle;
|
|
||||||
|
|
||||||
part.TrimPermissions();
|
part.TrimPermissions();
|
||||||
part.StoreUndoState();
|
part.StoreUndoState();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case XmlNodeType.EndElement:
|
case XmlNodeType.EndElement:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -440,11 +445,6 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
|
|
||||||
reader.Close();
|
reader.Close();
|
||||||
sr.Close();
|
sr.Close();
|
||||||
|
|
||||||
m_rootPart.LocalId = m_scene.PrimIDAllocate();
|
|
||||||
m_rootPart.ParentID = 0;
|
|
||||||
m_rootPart.RegionHandle = m_regionHandle;
|
|
||||||
UpdateParentIDs();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -571,7 +571,23 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
public void AttachToScene(Scene scene)
|
public void AttachToScene(Scene scene)
|
||||||
{
|
{
|
||||||
m_scene = scene;
|
m_scene = scene;
|
||||||
RegionHandle = scene.RegionInfo.RegionHandle;
|
RegionHandle = m_scene.RegionInfo.RegionHandle;
|
||||||
|
|
||||||
|
m_rootPart.ParentID = 0;
|
||||||
|
m_rootPart.LocalId = m_scene.PrimIDAllocate();
|
||||||
|
|
||||||
|
//UpdateParentIDs();
|
||||||
|
|
||||||
|
// No need to lock here since part isn't yet in a scene
|
||||||
|
foreach (SceneObjectPart part in m_parts.Values)
|
||||||
|
{
|
||||||
|
if (Object.ReferenceEquals(part, m_rootPart))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
part.LocalId = m_scene.PrimIDAllocate();
|
||||||
|
part.ParentID = m_rootPart.LocalId;
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
ApplyPhysics(m_scene.m_physicalPrim);
|
ApplyPhysics(m_scene.m_physicalPrim);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue