From 9c81b8a430b7fc8b0181310132f4bc9de414f19d Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Wed, 5 Dec 2007 18:45:05 +0000 Subject: From Gary Chernega (IBM) This patch adds x, y, and z offsets to the load-xml command. If you had a prim at 100,100,20 thats where it would get loaded everytime. This patch lets you place it at an offset from 100,100,20.. as such: load-xml -newUI 3 1 2 Loading the prim at 103, 101, 22 --- OpenSim/Region/Application/OpenSimMain.cs | 15 ++++++++++++--- OpenSim/Region/Environment/Scenes/Scene.cs | 4 ++-- OpenSim/Region/Environment/Scenes/SceneManager.cs | 4 ++-- OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs | 9 ++++++--- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs index b941e2d..9ad6c5f 100644 --- a/OpenSim/Region/Application/OpenSimMain.cs +++ b/OpenSim/Region/Application/OpenSimMain.cs @@ -42,6 +42,7 @@ using OpenSim.Region.Environment; using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Physics.Manager; +using libsecondlife; using Mono.Addins; using Mono.Addins.Description; @@ -664,6 +665,7 @@ namespace OpenSim break; case "load-xml": + LLVector3 loadOffset = new LLVector3(0, 0, 0); if (cmdparams.Length > 0) { bool generateNewIDS = false; @@ -672,13 +674,20 @@ namespace OpenSim if (cmdparams[1] == "-newUID") { generateNewIDS = true; - } + } + if (cmdparams.Length > 2) + { + loadOffset.X = (float)Convert.ToDecimal(cmdparams[2]); + if (cmdparams.Length > 3) { loadOffset.Y = (float)Convert.ToDecimal(cmdparams[3]); } + if (cmdparams.Length > 4) { loadOffset.Z = (float)Convert.ToDecimal(cmdparams[4]); } + m_log.Error("loadOffsets = <" + loadOffset.X + "," + loadOffset.Y + "," + loadOffset.Z + ">"); + } } - m_sceneManager.LoadCurrentSceneFromXml(cmdparams[0], generateNewIDS); + m_sceneManager.LoadCurrentSceneFromXml(cmdparams[0], generateNewIDS, loadOffset); } else { - m_sceneManager.LoadCurrentSceneFromXml(DEFAULT_PRIM_BACKUP_FILENAME, false); + m_sceneManager.LoadCurrentSceneFromXml(DEFAULT_PRIM_BACKUP_FILENAME, false, loadOffset); } break; diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 5ae26d3..f3ea89a 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -885,9 +885,9 @@ namespace OpenSim.Region.Environment.Scenes prim.OnPrimCountTainted += m_LandManager.setPrimsTainted; } - public void LoadPrimsFromXml(string fileName, bool newIdsFlag) + public void LoadPrimsFromXml(string fileName, bool newIdsFlag, LLVector3 loadOffset) { - m_sceneXmlLoader.LoadPrimsFromXml(fileName, newIdsFlag); + m_sceneXmlLoader.LoadPrimsFromXml(fileName, newIdsFlag, loadOffset); } public void SavePrimsToXml(string fileName) diff --git a/OpenSim/Region/Environment/Scenes/SceneManager.cs b/OpenSim/Region/Environment/Scenes/SceneManager.cs index 2af9af2..3f88617 100644 --- a/OpenSim/Region/Environment/Scenes/SceneManager.cs +++ b/OpenSim/Region/Environment/Scenes/SceneManager.cs @@ -160,9 +160,9 @@ namespace OpenSim.Region.Environment.Scenes CurrentOrFirstScene.SavePrimsToXml(filename); } - public void LoadCurrentSceneFromXml(string filename, bool generateNewIDs) + public void LoadCurrentSceneFromXml(string filename, bool generateNewIDs, LLVector3 loadOffset) { - CurrentOrFirstScene.LoadPrimsFromXml(filename, generateNewIDs); + CurrentOrFirstScene.LoadPrimsFromXml(filename, generateNewIDs, loadOffset); } public void SaveCurrentSceneToXml2(string filename) diff --git a/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs b/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs index ab8f835..9316989 100644 --- a/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs +++ b/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs @@ -23,7 +23,7 @@ namespace OpenSim.Region.Environment.Scenes m_regInfo = regionInfo; } - public void LoadPrimsFromXml(string fileName, bool newIDS) + public void LoadPrimsFromXml(string fileName, bool newIDS, LLVector3 loadOffset) { XmlDocument doc = new XmlDocument(); XmlNode rootNode; @@ -48,14 +48,17 @@ namespace OpenSim.Region.Environment.Scenes m_innerScene.AddEntity(obj); SceneObjectPart rootPart = obj.GetChildPart(obj.UUID); + // Apply loadOffsets for load/import and move combinations + rootPart.GroupPosition = rootPart.AbsolutePosition + loadOffset; bool UsePhysics = (((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) > 0) && m_parentScene.m_physicalPrim); if ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0) { rootPart.PhysActor = m_innerScene.PhysicsScene.AddPrimShape( rootPart.Name, rootPart.Shape, - new PhysicsVector(rootPart.AbsolutePosition.X, rootPart.AbsolutePosition.Y, - rootPart.AbsolutePosition.Z), + new PhysicsVector(rootPart.AbsolutePosition.X + loadOffset.X, + rootPart.AbsolutePosition.Y + loadOffset.Y, + rootPart.AbsolutePosition.Z + loadOffset.Z), new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z), new Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X, rootPart.RotationOffset.Y, rootPart.RotationOffset.Z), UsePhysics); -- cgit v1.1