* 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
0.6.0-stable
Justin Clarke Casey 2008-06-12 17:49:08 +00:00
parent 74017a4331
commit 8714833986
7 changed files with 46 additions and 58 deletions

View File

@ -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
/// <param name="xmlData"></param>
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());

View File

@ -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);
}
/// <summary>
/// Add an object to the scene.
/// </summary>
/// <param name="sceneObject"></param>
/// <param name="attachToBackup">
/// If true, the object is made persistent into the scene.
/// If false, the object will not persist over server restarts
/// </param>
/// <returns>true if the object was added, false if an object with the same uuid was already in the scene
/// </returns>
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;
}

View File

@ -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;
}
/// <summary>
/// Rez an object in the scene
/// </summary>
/// <param name="item"></param>
/// <param name="pos"></param>
/// <param name="rot"></param>
/// <param name="vel"></param>
/// <param name="param"></param>
/// <returns></returns>
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 += "</scene>\n";
bool permissionToDelete = false;
for (int i = 0; i < returnobjects.Length; i++)

View File

@ -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
/// </summary>
/// <param name="sceneObject"></param>
public void AddSceneObject(SceneObjectGroup sceneObject)
/// <param name="attachToBackup">
/// If true, the object is made persistent into the scene.
/// If false, the object will not persist over server restarts
/// </param>
public void AddSceneObject(SceneObjectGroup sceneObject, bool attachToBackup)
{
m_innerScene.AddSceneObject(sceneObject);
m_innerScene.AddSceneObject(sceneObject, attachToBackup);
}
/// <summary>

View File

@ -124,6 +124,7 @@ namespace OpenSim.Region.Environment.Scenes
}
}
/// <summary>
/// Start a given script.
/// </summary>
/// <param name="localID">

View File

@ -351,15 +351,13 @@ namespace OpenSim.Region.Environment.Scenes
RegionHandle = regionHandle;
AttachToBackup();
ApplyPhysics(scene.m_physicalPrim);
ScheduleGroupForFullUpdate();
}
/// <summary>
/// Restore the object from its serialized xml representation.
/// Create an object using serialized data in OpenSim's original xml format.
/// </summary>
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();
}
/// <summary>
///
/// Create an object using serialized data in OpenSim's xml2 format.
/// </summary>
public SceneObjectGroup(string xmlData)
{
@ -495,6 +491,7 @@ namespace OpenSim.Region.Environment.Scenes
//ApplyPhysics(scene.m_physicalPrim);
}
/// <summary>
///
/// </summary>
@ -527,7 +524,7 @@ namespace OpenSim.Region.Environment.Scenes
/// <summary>
/// Hooks this object up to the backup event so that it is persisted to the database when the update thread executes.
/// </summary>
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();
}
/// <summary>
@ -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)
/// <summary>
/// Stop this object from being persisted over server restarts.
/// </summary>
/// <param name="objectGroup"></param>
public void DetachFromBackup(SceneObjectGroup objectGroup)
{
m_scene.EventManager.OnBackup -= objectGroup.ProcessBackup;
}

View File

@ -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()