From 8714833986cef44787fd57a61699b7bdcfd3d3bb Mon Sep 17 00:00:00 2001
From: Justin Clarke Casey
Date: Thu, 12 Jun 2008 17:49:08 +0000
Subject: * refactor: For new objects, move attach to backup to occur when
adding to a scene, rather than on creation of the group * Adding to a scene
is now parameterized such that one can choose not to actually persist that
group * This is to support a use case where a module wants a scene which
consists of both objects which are persisted, and ones which are just
temporary for the lifetime of that server instance
---
.../Modules/World/Serialiser/SceneXmlLoader.cs | 5 +--
OpenSim/Region/Environment/Scenes/InnerScene.cs | 12 +++++-
.../Region/Environment/Scenes/Scene.Inventory.cs | 21 ++++++----
OpenSim/Region/Environment/Scenes/Scene.cs | 10 +++--
.../Scenes/SceneObjectGroup.Inventory.cs | 1 +
.../Region/Environment/Scenes/SceneObjectGroup.cs | 49 +++++-----------------
.../Region/Examples/SimpleModule/RegionModule.cs | 6 +--
7 files changed, 46 insertions(+), 58 deletions(-)
diff --git a/OpenSim/Region/Environment/Modules/World/Serialiser/SceneXmlLoader.cs b/OpenSim/Region/Environment/Modules/World/Serialiser/SceneXmlLoader.cs
index 0c4887f..54538d8 100644
--- a/OpenSim/Region/Environment/Modules/World/Serialiser/SceneXmlLoader.cs
+++ b/OpenSim/Region/Environment/Modules/World/Serialiser/SceneXmlLoader.cs
@@ -64,7 +64,7 @@ namespace OpenSim.Region.Environment.Scenes
//if we want this to be a import method then we need new uuids for the object to avoid any clashes
//obj.RegenerateFullIDs();
- scene.AddSceneObject(obj);
+ scene.AddSceneObject(obj, true);
SceneObjectPart rootPart = obj.GetChildPart(obj.UUID);
// Apply loadOffsets for load/import and move combinations
@@ -193,8 +193,7 @@ namespace OpenSim.Region.Environment.Scenes
///
protected static void CreatePrimFromXml2(Scene scene, string xmlData)
{
- SceneObjectGroup obj = new SceneObjectGroup(xmlData);
-
+ SceneObjectGroup obj = new SceneObjectGroup(xmlData);
LLVector3 receivedVelocity = obj.RootPart.Velocity;
//System.Console.WriteLine(obj.RootPart.Velocity.ToString());
diff --git a/OpenSim/Region/Environment/Scenes/InnerScene.cs b/OpenSim/Region/Environment/Scenes/InnerScene.cs
index 3cd32c6..d09efd8 100644
--- a/OpenSim/Region/Environment/Scenes/InnerScene.cs
+++ b/OpenSim/Region/Environment/Scenes/InnerScene.cs
@@ -193,6 +193,7 @@ namespace OpenSim.Region.Environment.Scenes
{
sceneObject.RegionHandle = m_regInfo.RegionHandle;
sceneObject.SetScene(m_parentScene);
+
foreach (SceneObjectPart part in sceneObject.Children.Values)
{
part.LocalId = m_parentScene.PrimIDAllocate();
@@ -200,16 +201,20 @@ namespace OpenSim.Region.Environment.Scenes
}
sceneObject.UpdateParentIDs();
- AddSceneObject(sceneObject);
+ AddSceneObject(sceneObject, true);
}
///
/// Add an object to the scene.
///
///
+ ///
+ /// If true, the object is made persistent into the scene.
+ /// If false, the object will not persist over server restarts
+ ///
/// true if the object was added, false if an object with the same uuid was already in the scene
///
- protected internal bool AddSceneObject(SceneObjectGroup sceneObject)
+ protected internal bool AddSceneObject(SceneObjectGroup sceneObject, bool attachToBackup)
{
lock (Entities)
{
@@ -218,6 +223,9 @@ namespace OpenSim.Region.Environment.Scenes
// QuadTree.AddSceneObject(sceneObject);
Entities.Add(sceneObject.UUID, sceneObject);
m_numPrim += sceneObject.Children.Count;
+
+ if (attachToBackup)
+ sceneObject.AttachToBackup();
return true;
}
diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
index ead7f23..ebc721f 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
@@ -1483,8 +1483,6 @@ namespace OpenSim.Region.Environment.Scenes
RayStart, RayEnd, RayTargetID, new LLQuaternion(0, 0, 0, 1),
BypassRayCast, bRayEndIsIntersection,true,scale, false);
-
-
// Rez object
CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
if (userInfo != null)
@@ -1508,7 +1506,7 @@ namespace OpenSim.Region.Environment.Scenes
group.ResetIDs();
- AddSceneObject(group);
+ AddSceneObject(group, true);
// if attachment we set it's asset id so object updates can reflect that
// if not, we set it's position in world.
@@ -1601,6 +1599,15 @@ namespace OpenSim.Region.Environment.Scenes
return null;
}
+ ///
+ /// Rez an object in the scene
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
public virtual SceneObjectGroup RezObject(TaskInventoryItem item, LLVector3 pos, LLQuaternion rot, LLVector3 vel, int param)
{
// Rez object
@@ -1621,7 +1628,7 @@ namespace OpenSim.Region.Environment.Scenes
}
group.ResetIDs();
- AddSceneObject(group);
+ AddSceneObject(group, true);
// Set the startup parameter for on_rez event and llGetStartParameter() function
group.StartParameter = param;
@@ -1678,10 +1685,11 @@ namespace OpenSim.Region.Environment.Scenes
rootPart.ScheduleFullUpdate();
return rootPart.ParentGroup;
}
-
}
+
return null;
}
+
public virtual bool returnObjects(SceneObjectGroup[] returnobjects, LLUUID AgentId)
{
string message = "";
@@ -1699,9 +1707,6 @@ namespace OpenSim.Region.Environment.Scenes
//}
//returnstring += "\n";
-
-
-
bool permissionToDelete = false;
for (int i = 0; i < returnobjects.Length; i++)
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index 526c125..43bb709 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -1492,7 +1492,7 @@ namespace OpenSim.Region.Environment.Scenes
{
SceneObjectGroup sceneOb =
new SceneObjectGroup(this, m_regionHandle, ownerID, PrimIDAllocate(), pos, rot, shape);
- AddSceneObject(sceneOb);
+ AddSceneObject(sceneOb, true);
SceneObjectPart rootPart = sceneOb.GetChildPart(sceneOb.UUID);
// if grass or tree, make phantom
//rootPart.TrimPermissions();
@@ -1556,9 +1556,13 @@ namespace OpenSim.Region.Environment.Scenes
/// Add an object to the scene
///
///
- public void AddSceneObject(SceneObjectGroup sceneObject)
+ ///
+ /// If true, the object is made persistent into the scene.
+ /// If false, the object will not persist over server restarts
+ ///
+ public void AddSceneObject(SceneObjectGroup sceneObject, bool attachToBackup)
{
- m_innerScene.AddSceneObject(sceneObject);
+ m_innerScene.AddSceneObject(sceneObject, attachToBackup);
}
///
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs
index 3e84af0..aea433e 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs
@@ -124,6 +124,7 @@ namespace OpenSim.Region.Environment.Scenes
}
}
+ ///
/// Start a given script.
///
///
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
index 67e2c70..336009b 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
@@ -351,15 +351,13 @@ namespace OpenSim.Region.Environment.Scenes
RegionHandle = regionHandle;
- AttachToBackup();
-
ApplyPhysics(scene.m_physicalPrim);
ScheduleGroupForFullUpdate();
}
///
- /// Restore the object from its serialized xml representation.
+ /// Create an object using serialized data in OpenSim's original xml format.
///
public SceneObjectGroup(Scene scene, ulong regionHandle, string xmlData)
{
@@ -417,15 +415,13 @@ namespace OpenSim.Region.Environment.Scenes
m_rootPart.RegionHandle = m_regionHandle;
UpdateParentIDs();
- AttachToBackup();
-
ApplyPhysics(scene.m_physicalPrim);
ScheduleGroupForFullUpdate();
}
///
- ///
+ /// Create an object using serialized data in OpenSim's xml2 format.
///
public SceneObjectGroup(string xmlData)
{
@@ -495,6 +491,7 @@ namespace OpenSim.Region.Environment.Scenes
//ApplyPhysics(scene.m_physicalPrim);
}
+
///
///
///
@@ -527,7 +524,7 @@ namespace OpenSim.Region.Environment.Scenes
///
/// Hooks this object up to the backup event so that it is persisted to the database when the update thread executes.
///
- private void AttachToBackup()
+ public void AttachToBackup()
{
if (InSceneBackup)
{
@@ -822,7 +819,6 @@ namespace OpenSim.Region.Environment.Scenes
public void SetScene(Scene scene)
{
m_scene = scene;
- AttachToBackup();
}
///
@@ -1848,38 +1844,9 @@ namespace OpenSim.Region.Environment.Scenes
linkPart.RotationOffset = worldRot;
- // This chunk is probably unnecesary now - delete later on
- /*
- Quaternion oldRot
- = new Quaternion(
- linkPart.RotationOffset.W,
- linkPart.RotationOffset.X,
- linkPart.RotationOffset.Y,
- linkPart.RotationOffset.Z);
- Quaternion newRot = parentRot*oldRot;
- linkPart.RotationOffset = new LLQuaternion(newRot.x, newRot.y, newRot.z, newRot.w);
- */
-
- // Add physics information back to delinked part if appropriate
- // XXX This is messy and should be refactorable with the similar section in
- // SceneObjectPart.UpdatePrimFlags()
- //if (m_rootPart.PhysActor != null)
- //{
- //linkPart.PhysActor = m_scene.PhysicsScene.AddPrimShape(
- //linkPart.Name,
- //linkPart.Shape,
- //new PhysicsVector(linkPart.AbsolutePosition.X, linkPart.AbsolutePosition.Y,
- //linkPart.AbsolutePosition.Z),
- //new PhysicsVector(linkPart.Scale.X, linkPart.Scale.Y, linkPart.Scale.Z),
- //new Quaternion(linkPart.RotationOffset.W, linkPart.RotationOffset.X,
- //linkPart.RotationOffset.Y, linkPart.RotationOffset.Z),
- //m_rootPart.PhysActor.IsPhysical);
- //m_rootPart.DoPhysicsPropertyUpdate(m_rootPart.PhysActor.IsPhysical, true);
- //}
-
SceneObjectGroup objectGroup = new SceneObjectGroup(m_scene, m_regionHandle, linkPart);
- m_scene.AddSceneObject(objectGroup);
+ m_scene.AddSceneObject(objectGroup, true);
ScheduleGroupForFullUpdate();
}
@@ -1891,7 +1858,11 @@ namespace OpenSim.Region.Environment.Scenes
}
}
- private void DetachFromBackup(SceneObjectGroup objectGroup)
+ ///
+ /// Stop this object from being persisted over server restarts.
+ ///
+ ///
+ public void DetachFromBackup(SceneObjectGroup objectGroup)
{
m_scene.EventManager.OnBackup -= objectGroup.ProcessBackup;
}
diff --git a/OpenSim/Region/Examples/SimpleModule/RegionModule.cs b/OpenSim/Region/Examples/SimpleModule/RegionModule.cs
index 7be2684..ab643a2 100644
--- a/OpenSim/Region/Examples/SimpleModule/RegionModule.cs
+++ b/OpenSim/Region/Examples/SimpleModule/RegionModule.cs
@@ -76,7 +76,7 @@ namespace OpenSim.Region.Examples.SimpleModule
}
FileSystemObject fileObject = new FileSystemObject(m_scene, fileInfo, filePos);
- m_scene.AddSceneObject(fileObject);
+ m_scene.AddSceneObject(fileObject, true);
fileObject.ScheduleGroupForFullUpdate();
}
}
@@ -107,7 +107,7 @@ namespace OpenSim.Region.Examples.SimpleModule
ComplexObject complexObject =
new ComplexObject(m_scene, regionInfo.RegionHandle, LLUUID.Zero, m_scene.PrimIDAllocate(),
pos + posOffset);
- m_scene.AddSceneObject(complexObject);
+ m_scene.AddSceneObject(complexObject, true);
}
}
@@ -116,7 +116,7 @@ namespace OpenSim.Region.Examples.SimpleModule
SceneObjectGroup sceneObject =
new CpuCounterObject(m_scene, regionInfo.RegionHandle, LLUUID.Zero, m_scene.PrimIDAllocate(),
pos + new LLVector3(1f, 1f, 1f));
- m_scene.AddSceneObject(sceneObject);
+ m_scene.AddSceneObject(sceneObject, true);
}
public void Close()
--
cgit v1.1