changes to load oar with --merge: with option --mergeReplaceObjects it will replace objects already in region, without it, skip; with opetion merge-parcels will try to merge them, without it ignores oar parcels. as before without --merge all is replaced. renamed the options force* as merge* since they are merge suboptions

master
UbitUmarov 2020-02-28 18:36:52 +00:00
parent 665037e366
commit 3707301c59
3 changed files with 78 additions and 47 deletions

View File

@ -317,7 +317,8 @@ namespace OpenSim
m_console.Commands.AddCommand("Archiving", false, "load oar", m_console.Commands.AddCommand("Archiving", false, "load oar",
"load oar [-m|--merge] [-s|--skip-assets]" "load oar [-m|--merge] [-s|--skip-assets]"
+ " [--default-user \"User Name\"]" + " [--default-user \"User Name\"]"
+ " [--force-terrain] [--force-parcels]" + " [--merge-terrain] [--merge-parcels]"
+ " [--mergeReplaceObjects]"
+ " [--no-objects]" + " [--no-objects]"
+ " [--rotation degrees]" + " [--rotation degrees]"
+ " [--bounding-origin \"<x,y,z>\"]" + " [--bounding-origin \"<x,y,z>\"]"
@ -327,10 +328,13 @@ namespace OpenSim
+ " [<OAR path>]", + " [<OAR path>]",
"Load a region's data from an OAR archive.", "Load a region's data from an OAR archive.",
"--merge will merge the OAR with the existing scene (suppresses terrain and parcel info loading).\n" "--merge will merge the OAR with the existing scene (suppresses terrain and parcel info loading).\n"
+ " options with --merge\n"
+ " --merge-terrain also load the terrain, replacing original\n"
+ " --merge-parcels also load parcels, merging with original\n"
+ " --mergeReplaceObjects if scene as a object with same id, replace it\n"
+ " without this option, skip loading that object\n"
+ "--skip-assets will load the OAR but ignore the assets it contains.\n" + "--skip-assets will load the OAR but ignore the assets it contains.\n"
+ "--default-user will use this user for any objects with an owner whose UUID is not found in the grid.\n" + "--default-user will use this user for any objects with an owner whose UUID is not found in the grid.\n"
+ "--force-terrain forces the loading of terrain from the oar (undoes suppression done by --merge).\n"
+ "--force-parcels forces the loading of parcels from the oar (undoes suppression done by --merge).\n"
+ "--no-objects suppresses the addition of any objects (good for loading only the terrain).\n" + "--no-objects suppresses the addition of any objects (good for loading only the terrain).\n"
+ "--rotation specified rotation to be applied to the oar. Specified in degrees.\n" + "--rotation specified rotation to be applied to the oar. Specified in degrees.\n"
+ "--bounding-origin will only place objects that after displacement and rotation fall within the bounding cube who's position starts at <x,y,z>. Defaults to <0,0,0>.\n" + "--bounding-origin will only place objects that after displacement and rotation fall within the bounding cube who's position starts at <x,y,z>. Defaults to <0,0,0>.\n"

View File

@ -101,16 +101,17 @@ namespace OpenSim.Region.CoreModules.World.Archiver
/// Merging usually suppresses terrain and parcel loading /// Merging usually suppresses terrain and parcel loading
/// </value> /// </value>
protected bool m_merge; protected bool m_merge;
protected bool m_mergeReplaceObjects;
/// <value> /// <value>
/// If true, force the loading of terrain from the oar file /// If true, force the loading of terrain from the oar file
/// </value> /// </value>
protected bool m_forceTerrain; protected bool m_mergeTerrain;
/// <value> /// <value>
/// If true, force the loading of parcels from the oar file /// If true, force the merge of parcels from the oar file
/// </value> /// </value>
protected bool m_forceParcels; protected bool m_mergeParcels;
/// <value> /// <value>
/// Should we ignore any assets when reloading the archive? /// Should we ignore any assets when reloading the archive?
@ -210,8 +211,9 @@ namespace OpenSim.Region.CoreModules.World.Archiver
m_errorMessage = String.Empty; m_errorMessage = String.Empty;
m_merge = options.ContainsKey("merge"); m_merge = options.ContainsKey("merge");
m_forceTerrain = options.ContainsKey("force-terrain"); m_mergeReplaceObjects = options.ContainsKey("mReplaceObjects");
m_forceParcels = options.ContainsKey("force-parcels"); m_mergeTerrain = options.ContainsKey("merge-terrain");
m_mergeParcels = options.ContainsKey("merge-parcels");
m_noObjects = options.ContainsKey("no-objects"); m_noObjects = options.ContainsKey("no-objects");
m_skipAssets = options.ContainsKey("skipAssets"); m_skipAssets = options.ContainsKey("skipAssets");
m_requestId = requestId; m_requestId = requestId;
@ -270,6 +272,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
m_loadStream = loadStream; m_loadStream = loadStream;
m_skipAssets = options.ContainsKey("skipAssets"); m_skipAssets = options.ContainsKey("skipAssets");
m_merge = options.ContainsKey("merge"); m_merge = options.ContainsKey("merge");
m_mergeReplaceObjects = options.ContainsKey("mReplaceObjects");
m_requestId = requestId; m_requestId = requestId;
m_defaultUser = scene.RegionInfo.EstateSettings.EstateOwner; m_defaultUser = scene.RegionInfo.EstateSettings.EstateOwner;
@ -352,7 +355,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
if ((successfulAssetRestores + failedAssetRestores) % 250 == 0) if ((successfulAssetRestores + failedAssetRestores) % 250 == 0)
m_log.Debug("[ARCHIVER]: Loaded " + successfulAssetRestores + " assets and failed to load " + failedAssetRestores + " assets..."); m_log.Debug("[ARCHIVER]: Loaded " + successfulAssetRestores + " assets and failed to load " + failedAssetRestores + " assets...");
} }
else if (filePath.StartsWith(ArchiveConstants.TERRAINS_PATH) && (!m_merge || m_forceTerrain)) else if (filePath.StartsWith(ArchiveConstants.TERRAINS_PATH) && (!m_merge || m_mergeTerrain))
{ {
LoadTerrain(scene, filePath, data); LoadTerrain(scene, filePath, data);
} }
@ -360,7 +363,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
{ {
LoadRegionSettings(scene, filePath, data, dearchivedScenes); LoadRegionSettings(scene, filePath, data, dearchivedScenes);
} }
else if (filePath.StartsWith(ArchiveConstants.LANDDATA_PATH) && (!m_merge || m_forceParcels)) else if (filePath.StartsWith(ArchiveConstants.LANDDATA_PATH) && (!m_merge || m_mergeParcels))
{ {
sceneContext.SerialisedParcels.Add(Encoding.UTF8.GetString(data)); sceneContext.SerialisedParcels.Add(Encoding.UTF8.GetString(data));
} }
@ -546,23 +549,21 @@ namespace OpenSim.Region.CoreModules.World.Archiver
int sceneObjectsLoadedCount = 0; int sceneObjectsLoadedCount = 0;
Vector3 boundingExtent = new Vector3(m_boundingOrigin.X + m_boundingSize.X, m_boundingOrigin.Y + m_boundingSize.Y, m_boundingOrigin.Z + m_boundingSize.Z); Vector3 boundingExtent = new Vector3(m_boundingOrigin.X + m_boundingSize.X, m_boundingOrigin.Y + m_boundingSize.Y, m_boundingOrigin.Z + m_boundingSize.Z);
int mergeskip = 0;
foreach (string serialisedSceneObject in serialisedSceneObjects) foreach (string serialisedSceneObject in serialisedSceneObjects)
{ {
/*
m_log.DebugFormat("[ARCHIVER]: Loading xml with raw size {0}", serialisedSceneObject.Length);
// Really large xml files (multi megabyte) appear to cause
// memory problems
// when loading the xml. But don't enable this check yet
if (serialisedSceneObject.Length > 5000000)
{
m_log.Error("[ARCHIVER]: Ignoring xml since size > 5000000);");
continue;
}
*/
SceneObjectGroup sceneObject = serialiser.DeserializeGroupFromXml2(serialisedSceneObject); SceneObjectGroup sceneObject = serialiser.DeserializeGroupFromXml2(serialisedSceneObject);
if (m_merge)
{
if(scene.TryGetSceneObjectGroup(sceneObject.UUID, out SceneObjectGroup oldSog))
{
++mergeskip;
if (m_mergeReplaceObjects)
scene.DeleteSceneObject(oldSog, false);
else
continue;
}
}
Vector3 pos = sceneObject.AbsolutePosition; Vector3 pos = sceneObject.AbsolutePosition;
if (m_debug) if (m_debug)
@ -636,12 +637,18 @@ namespace OpenSim.Region.CoreModules.World.Archiver
} }
} }
m_log.InfoFormat("[ARCHIVER]: Restored {0} scene objects to the scene", sceneObjectsLoadedCount); m_log.InfoFormat("[ARCHIVER]: Loaded {0} scene objects to the scene", sceneObjectsLoadedCount);
int ignoredObjects = serialisedSceneObjects.Count - sceneObjectsLoadedCount - mergeskip;
int ignoredObjects = serialisedSceneObjects.Count - sceneObjectsLoadedCount;
if(mergeskip > 0)
{
if(m_mergeReplaceObjects)
m_log.InfoFormat("[ARCHIVER]: Replaced {0} scene objects", mergeskip);
else
m_log.InfoFormat("[ARCHIVER]: Skipped {0} scene objects that already existed in the scene", mergeskip);
}
if (ignoredObjects > 0) if (ignoredObjects > 0)
m_log.WarnFormat("[ARCHIVER]: Ignored {0} scene objects that already existed in the scene or were out of bounds", ignoredObjects); m_log.WarnFormat("[ARCHIVER]: Ignored {0} possible out of bounds", ignoredObjects);
if (oldTelehubUUID != UUID.Zero) if (oldTelehubUUID != UUID.Zero)
{ {
@ -730,6 +737,12 @@ namespace OpenSim.Region.CoreModules.World.Archiver
/// <param name="serialisedParcels"></param> /// <param name="serialisedParcels"></param>
protected void LoadParcels(Scene scene, List<string> serialisedParcels) protected void LoadParcels(Scene scene, List<string> serialisedParcels)
{ {
if(serialisedParcels.Count == 0)
{
m_log.Info("[ARCHIVER]: No parcels to load, or skiping load");
return;
}
// Reload serialized parcels // Reload serialized parcels
m_log.InfoFormat("[ARCHIVER]: Loading {0} parcels. Please wait.", serialisedParcels.Count); m_log.InfoFormat("[ARCHIVER]: Loading {0} parcels. Please wait.", serialisedParcels.Count);
List<LandData> landData = new List<LandData>(); List<LandData> landData = new List<LandData>();
@ -743,6 +756,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver
// Gather any existing parcels before we add any more. Later as we add parcels we can check if the new parcel // Gather any existing parcels before we add any more. Later as we add parcels we can check if the new parcel
// data overlays any of the old data, and we can modify and remove (if empty) the old parcel so that there's no conflict // data overlays any of the old data, and we can modify and remove (if empty) the old parcel so that there's no conflict
bool domerge = m_merge & m_mergeParcels;
parcels = scene.LandChannel.AllParcels(); parcels = scene.LandChannel.AllParcels();
foreach (string serialisedParcel in serialisedParcels) foreach (string serialisedParcel in serialisedParcels)
@ -787,7 +802,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
parcel.AABBMin = AABBMin; parcel.AABBMin = AABBMin;
parcel.AABBMax = AABBMax; parcel.AABBMax = AABBMax;
if (m_merge) if (domerge)
{ {
// give the remapped parcel a new GlobalID, in case we're using the same OAR twice and a bounding cube, displacement and --merge // give the remapped parcel a new GlobalID, in case we're using the same OAR twice and a bounding cube, displacement and --merge
parcel.GlobalID = UUID.Random(); parcel.GlobalID = UUID.Random();
@ -854,19 +869,26 @@ namespace OpenSim.Region.CoreModules.World.Archiver
landData.Add(parcel); landData.Add(parcel);
} }
if (m_merge)
{
for (int i = 0; i < parcels.Count; i++) //if merging then we need to also add back in any existing parcels
{
if (parcels[i] != null) landData.Add(parcels[i].LandData);
}
}
m_log.InfoFormat("[ARCHIVER]: Clearing {0} parcels.", parcels.Count); m_log.InfoFormat("[ARCHIVER]: Clearing {0} parcels.", parcels.Count);
bool setupDefaultParcel = (landData.Count == 0); bool setupDefaultParcel = (landData.Count == 0);
scene.LandChannel.Clear(setupDefaultParcel); scene.LandChannel.Clear(setupDefaultParcel);
if (domerge)
{
int j = 0;
for (int i = 0; i < parcels.Count; i++) //if merging then we need to also add back in any existing parcels
{
if (parcels[i] != null)
{
landData.Add(parcels[i].LandData);
j++;
}
}
m_log.InfoFormat("[ARCHIVER]: Keeping {0} old parcels.", j);
}
scene.EventManager.TriggerIncomingLandDataFromStorage(landData); scene.EventManager.TriggerIncomingLandDataFromStorage(landData);
m_log.InfoFormat("[ARCHIVER]: Restored {0} parcels.", landData.Count); m_log.InfoFormat("[ARCHIVER]: Added {0} total parcels.", landData.Count);
} }
/// <summary> /// <summary>

View File

@ -101,9 +101,10 @@ namespace OpenSim.Region.CoreModules.World.Archiver
public void HandleLoadOarConsoleCommand(string module, string[] cmdparams) public void HandleLoadOarConsoleCommand(string module, string[] cmdparams)
{ {
bool mergeOar = false; bool mergeOar = false;
bool mergeReplaceObjects = false;
bool skipAssets = false; bool skipAssets = false;
bool forceTerrain = false; bool mergeTerrain = false;
bool forceParcels = false; bool mergeParcels = false;
bool noObjects = false; bool noObjects = false;
Vector3 displacement = new Vector3(0f, 0f, 0f); Vector3 displacement = new Vector3(0f, 0f, 0f);
String defaultUser = ""; String defaultUser = "";
@ -112,14 +113,17 @@ namespace OpenSim.Region.CoreModules.World.Archiver
Vector3 boundingOrigin = new Vector3(0f, 0f, 0f); Vector3 boundingOrigin = new Vector3(0f, 0f, 0f);
Vector3 boundingSize = new Vector3(Scene.RegionInfo.RegionSizeX, Scene.RegionInfo.RegionSizeY, float.MaxValue); Vector3 boundingSize = new Vector3(Scene.RegionInfo.RegionSizeX, Scene.RegionInfo.RegionSizeY, float.MaxValue);
bool debug = false; bool debug = false;
OptionSet options = new OptionSet(); OptionSet options = new OptionSet();
options.Add("m|merge", delegate(string v) { mergeOar = (v != null); }); options.Add("m|merge", delegate(string v) { mergeOar = (v != null); });
options.Add("mergeReplaceObjects", delegate (string v) { mergeReplaceObjects = (v != null); });
options.Add("s|skip-assets", delegate(string v) { skipAssets = (v != null); }); options.Add("s|skip-assets", delegate(string v) { skipAssets = (v != null); });
options.Add("force-terrain", delegate(string v) { forceTerrain = (v != null); }); options.Add("merge-terrain", delegate(string v) { mergeTerrain = (v != null); });
options.Add("forceterrain", delegate(string v) { forceTerrain = (v != null); }); // downward compatibility options.Add("force-terrain", delegate (string v) { mergeTerrain = (v != null); }); // downward compatibility
options.Add("force-parcels", delegate(string v) { forceParcels = (v != null); }); options.Add("forceterrain", delegate (string v) { mergeTerrain = (v != null); }); // downward compatibility
options.Add("forceparcels", delegate(string v) { forceParcels = (v != null); }); // downward compatibility options.Add("merge-parcels", delegate(string v) { mergeParcels = (v != null); });
options.Add("force-parcels", delegate (string v) { mergeParcels = (v != null); }); // downward compatibility
options.Add("forceparcels", delegate (string v) { mergeParcels = (v != null); }); // downward compatibility
options.Add("no-objects", delegate(string v) { noObjects = (v != null); }); options.Add("no-objects", delegate(string v) { noObjects = (v != null); });
options.Add("default-user=", delegate(string v) { defaultUser = (v == null) ? "" : v; }); options.Add("default-user=", delegate(string v) { defaultUser = (v == null) ? "" : v; });
options.Add("displacement=", delegate(string v) options.Add("displacement=", delegate(string v)
@ -212,8 +216,9 @@ namespace OpenSim.Region.CoreModules.World.Archiver
Dictionary<string, object> archiveOptions = new Dictionary<string, object>(); Dictionary<string, object> archiveOptions = new Dictionary<string, object>();
if (mergeOar) archiveOptions.Add("merge", null); if (mergeOar) archiveOptions.Add("merge", null);
if (skipAssets) archiveOptions.Add("skipAssets", null); if (skipAssets) archiveOptions.Add("skipAssets", null);
if (forceTerrain) archiveOptions.Add("force-terrain", null); if (mergeReplaceObjects) archiveOptions.Add("mReplaceObjects", null);
if (forceParcels) archiveOptions.Add("force-parcels", null); if (mergeTerrain) archiveOptions.Add("merge-terrain", null);
if (mergeParcels) archiveOptions.Add("merge-parcels", null);
if (noObjects) archiveOptions.Add("no-objects", null); if (noObjects) archiveOptions.Add("no-objects", null);
if (defaultUser != "") if (defaultUser != "")
{ {