From 2bf42f30af5030890b8e3ff5bb29074a1f0e9085 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Thu, 27 Sep 2012 00:12:34 +0100 Subject: [PATCH] Add MaxPrimsUndo config setting to [Startup] section of OpenSim.ini. This controls how many undo steps the simulator will store for each prim. Default is now 20 rather than 5 as it briefly was. The default number could be increased through this is a memory tradeoff which will scale with the number of prims in the sim and level of activity. --- OpenSim/Region/Framework/Scenes/Scene.cs | 5 ++--- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 8 -------- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 12 ++++++------ .../Framework/Scenes/Tests/SceneObjectResizeTests.cs | 2 -- .../Scenes/Tests/SceneObjectUndoRedoTests.cs | 4 ++++ bin/OpenSim.ini.example | 4 ++++ bin/OpenSimDefaults.ini | 4 ++++ 7 files changed, 20 insertions(+), 19 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 872c0611b3..2e03874c20 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -742,6 +742,8 @@ namespace OpenSim.Region.Framework.Scenes //Animation states m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); + MaxUndoCount = startupConfig.GetInt("MaxPrimUndos", 20); + PhysicalPrims = startupConfig.GetBoolean("physical_prim", PhysicalPrims); CollidablePrims = startupConfig.GetBoolean("collidable_prim", CollidablePrims); @@ -932,9 +934,6 @@ namespace OpenSim.Region.Framework.Scenes WestBorders.Add(westBorder); BordersLocked = false; - // TODO: At some point this should be made configurable. - MaxUndoCount = 5; - m_eventManager = new EventManager(); m_permissions = new ScenePermissions(this); diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 85a37e9ac3..45bbbda50a 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1119,14 +1119,6 @@ namespace OpenSim.Region.Framework.Scenes parts[i].UUID = UUID.Random(); } - // helper provided for parts. - public int GetSceneMaxUndo() - { - if (m_scene != null) - return m_scene.MaxUndoCount; - return 5; - } - // justincc: I don't believe this hack is needed any longer, especially since the physics // parts of set AbsolutePosition were already commented out. By changing HasGroupChanged to false // this method was preventing proper reload of scene objects. diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 3d4bc3c4af..3f10b34d7b 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -3209,13 +3209,13 @@ namespace OpenSim.Region.Framework.Scenes // "[SCENE OBJECT PART]: Storing undo state for {0} {1}, forGroup {2}, initial stack size {3}", // Name, LocalId, forGroup, m_undo.Count); - if (ParentGroup.GetSceneMaxUndo() > 0) + if (ParentGroup.Scene.MaxUndoCount > 0) { UndoState nUndo = new UndoState(this, forGroup); m_undo.Add(nUndo); - if (m_undo.Count > ParentGroup.GetSceneMaxUndo()) + if (m_undo.Count > ParentGroup.Scene.MaxUndoCount) m_undo.RemoveAt(0); if (m_redo.Count > 0) @@ -3255,7 +3255,7 @@ namespace OpenSim.Region.Framework.Scenes UndoState nUndo = null; - if (ParentGroup.GetSceneMaxUndo() > 0) + if (ParentGroup.Scene.MaxUndoCount > 0) { nUndo = new UndoState(this, goback.ForGroup); } @@ -3266,7 +3266,7 @@ namespace OpenSim.Region.Framework.Scenes { m_redo.Add(nUndo); - if (m_redo.Count > ParentGroup.GetSceneMaxUndo()) + if (m_redo.Count > ParentGroup.Scene.MaxUndoCount) m_redo.RemoveAt(0); } } @@ -3290,13 +3290,13 @@ namespace OpenSim.Region.Framework.Scenes UndoState gofwd = m_redo[m_redo.Count - 1]; m_redo.RemoveAt(m_redo.Count - 1); - if (ParentGroup.GetSceneMaxUndo() > 0) + if (ParentGroup.Scene.MaxUndoCount > 0) { UndoState nUndo = new UndoState(this, gofwd.ForGroup); m_undo.Add(nUndo); - if (m_undo.Count > ParentGroup.GetSceneMaxUndo()) + if (m_undo.Count > ParentGroup.Scene.MaxUndoCount) m_undo.RemoveAt(0); } diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs index e9318594ce..89647d68fc 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs @@ -62,8 +62,6 @@ namespace OpenSim.Region.Framework.Scenes.Tests Assert.That(g1Post.RootPart.Scale.X, Is.EqualTo(2)); Assert.That(g1Post.RootPart.Scale.Y, Is.EqualTo(3)); Assert.That(g1Post.RootPart.Scale.Z, Is.EqualTo(4)); - - Assert.That(g1Post.RootPart.UndoCount, Is.EqualTo(1)); } /// diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUndoRedoTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUndoRedoTests.cs index 133fac573a..96973de181 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUndoRedoTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUndoRedoTests.cs @@ -52,6 +52,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests Vector3 secondSize = new Vector3(5, 6, 7); Scene scene = new SceneHelpers().SetupScene(); + scene.MaxUndoCount = 20; SceneObjectGroup g1 = SceneHelpers.AddSceneObject(scene); // TODO: It happens to be the case that we are not storing undo states for SOPs which are not yet in a SOG, @@ -113,6 +114,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests Vector3 fourthSize = new Vector3(11, 12, 13); Scene scene = new SceneHelpers().SetupScene(); + scene.MaxUndoCount = 20; SceneObjectGroup g1 = SceneHelpers.CreateSceneObject(1, TestHelpers.ParseTail(0x1)); g1.GroupResize(firstSize); @@ -133,6 +135,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests Vector3 newSize = new Vector3(2, 3, 4); Scene scene = new SceneHelpers().SetupScene(); + scene.MaxUndoCount = 20; SceneObjectGroup g1 = SceneHelpers.AddSceneObject(scene); Vector3 originalSize = g1.GroupScale; @@ -160,6 +163,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests Vector3 newSize = new Vector3(2, 3, 4); Scene scene = new SceneHelpers().SetupScene(); + scene.MaxUndoCount = 20; SceneObjectGroup g1 = SceneHelpers.AddSceneObject(scene); Vector3 originalSize = g1.GroupScale; diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example index 6dbb61162a..4f0bb079f6 100644 --- a/bin/OpenSim.ini.example +++ b/bin/OpenSim.ini.example @@ -97,6 +97,10 @@ ;; from the selected region_info_source. ; allow_regionless = false + ;# {MaxPrimUndos} {} {Maximum number of undos avialable for position, rotation and scale changes of each prim} {} 20 + ;; Increasing the number of undos available number will increase memory usage. + MaxPrimUndos = 20 + ;# {NonPhysicalPrimMin} {} {Minimum size of nonphysical prims?} {} 0.001 ;; Minimum size for non-physical prims. Affects resizing of existing ;; prims. This can be overriden in the region config file (as diff --git a/bin/OpenSimDefaults.ini b/bin/OpenSimDefaults.ini index 744187baa7..046aa67b89 100644 --- a/bin/OpenSimDefaults.ini +++ b/bin/OpenSimDefaults.ini @@ -85,6 +85,10 @@ ;; from the selected region_info_source. allow_regionless = false + ; Maximum number of position, rotation and scale changes for each prim that the simulator will store for later undos + ; Increasing this number will increase memory usage. + MaxPrimUndos = 20 + ; Maximum size of non physical prims. Affects resizing of existing prims. This can be overriden in the region config file (as NonPhysicalPrimMax!). NonPhysicalPrimMax = 256