Partial Linking of prim groups should work (its partial as currently only the root prim of the child group will actually get linked, working on linking the rest now).

Multiple prim groups are now stored in the sqlite database and are reloaded correctly.
afrisby
MW 2007-08-13 13:36:42 +00:00
parent ed1208d043
commit b59d9789f8
4 changed files with 201 additions and 60 deletions

View File

@ -459,7 +459,7 @@ namespace OpenSim.Region.Environment.Scenes
{
AddEntityFromStorage(prim);
}
MainLog.Instance.Verbose("Loaded " + PrimsFromDB.Count.ToString() + " object(s)");
MainLog.Instance.Verbose("Loaded " + PrimsFromDB.Count.ToString() + " SceneObject(s)");
}
/// <summary>
@ -520,6 +520,7 @@ namespace OpenSim.Region.Environment.Scenes
{
part.LocalID = this.PrimIDAllocate();
}
sceneObject.UpdateParentIDs();
this.AddEntity(sceneObject);
}

View File

@ -1,5 +1,9 @@
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
using System.IO;
using System;
using Axiom.Math;
using libsecondlife;
using libsecondlife.Packets;
@ -22,6 +26,7 @@ namespace OpenSim.Region.Environment.Scenes
public event PrimCountTaintedDelegate OnPrimCountTainted;
#region Properties
/// <summary>
///
/// </summary>
@ -111,6 +116,9 @@ namespace OpenSim.Region.Environment.Scenes
set { m_isSelected = value; }
}
#endregion
#region Constructors
/// <summary>
///
/// </summary>
@ -119,6 +127,31 @@ namespace OpenSim.Region.Environment.Scenes
}
/// <summary>
///
/// </summary>
public SceneObjectGroup(Scene scene, ulong regionHandle, string xmlData)
{
m_scene = scene;
m_regionHandle = regionHandle;
StringReader sr = new StringReader(xmlData);
XmlTextReader reader = new XmlTextReader(sr);
reader.ReadStartElement("SceneObjectGroup");
reader.ReadStartElement("RootPart");
this.m_rootPart = SceneObjectPart.FromXml(reader);
reader.ReadEndElement();
//TODO: read and create rest of the parts
reader.ReadEndElement();
reader.Close();
sr.Close();
this.m_parts.Add(m_rootPart.UUID, m_rootPart);
this.m_rootPart.LocalID = m_scene.PrimIDAllocate();
this.m_rootPart.RegionHandle = m_regionHandle;
m_scene.EventManager.OnBackup += this.ProcessBackup;
}
/// <summary>
///
/// </summary>
@ -142,7 +175,25 @@ namespace OpenSim.Region.Environment.Scenes
this.SetPartAsRoot(newPart);
m_scene.EventManager.OnBackup += this.ProcessBackup;
}
#endregion
public string ToXmlString()
{
StringWriter sw = new StringWriter();
//StreamWriter st = new StreamWriter("testxml.txt");
XmlTextWriter writer = new XmlTextWriter(sw);
writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty);
writer.WriteStartElement(String.Empty, "RootPart", String.Empty);
m_rootPart.ToXml(writer);
writer.WriteEndElement();
writer.WriteEndElement();
writer.Close();
// System.Console.WriteLine("prim: " + sw.ToString());
return sw.ToString();
// st.Close();
// return "";
}
#region Copying
/// <summary>
@ -169,23 +220,6 @@ namespace OpenSim.Region.Environment.Scenes
return dupe;
}
/// <summary>
/// Added as a way for the storage provider to reset the scene,
/// most likely a better way to do this sort of thing but for now...
/// </summary>
/// <param name="scene"></param>
public void SetScene(Scene scene)
{
m_scene = scene;
m_scene.EventManager.OnBackup += this.ProcessBackup;
}
public void AddPart(SceneObjectPart part)
{
part.SetParent(this);
this.m_parts.Add(part.UUID, part);
}
/// <summary>
///
/// </summary>
@ -209,6 +243,7 @@ namespace OpenSim.Region.Environment.Scenes
}
#endregion
#region Scheduling
/// <summary>
///
/// </summary>
@ -264,15 +299,9 @@ namespace OpenSim.Region.Environment.Scenes
}
}
/// <summary>
///
/// </summary>
/// <param name="objectGroup"></param>
public void LinkToGroup(SceneObjectGroup objectGroup)
{
}
#endregion
#region SceneGroupPart Methods
/// <summary>
///
/// </summary>
@ -339,26 +368,37 @@ namespace OpenSim.Region.Environment.Scenes
}
return false;
}
#endregion
#region Packet Handlers
/// <summary>
///
/// </summary>
public void TriggerTainted()
/// <param name="objectGroup"></param>
public void LinkToGroup(SceneObjectGroup objectGroup)
{
if (OnPrimCountTainted != null)
{
this.OnPrimCountTainted();
}
}
/// <summary>
/// Processes backup
/// </summary>
/// <param name="datastore"></param>
public void ProcessBackup(OpenSim.Region.Interfaces.IRegionDataStore datastore)
{
datastore.StoreObject(this);
SceneObjectPart linkPart = objectGroup.m_rootPart;
linkPart.OffsetPosition = linkPart.GroupPosition - this.Pos;
linkPart.GroupPosition = this.Pos;
Vector3 axPos = new Vector3(linkPart.OffsetPosition.X, linkPart.OffsetPosition.Y, linkPart.OffsetPosition.Z);
Quaternion parentRot = new Quaternion(this.m_rootPart.RotationOffset.W, this.m_rootPart.RotationOffset.X, this.m_rootPart.RotationOffset.Y, this.m_rootPart.RotationOffset.Z);
axPos = parentRot.Inverse() * axPos;
linkPart.OffsetPosition = new LLVector3(axPos.x, axPos.y, axPos.z);
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);
linkPart.ParentID = this.m_rootPart.LocalID;
this.m_parts.Add(linkPart.UUID, linkPart);
linkPart.SetParent(this);
//TODO: rest of parts
m_scene.EventManager.OnBackup -= objectGroup.ProcessBackup;
m_scene.DeleteEntity(objectGroup.UUID);
this.ScheduleGroupForFullUpdate();
}
/// <summary>
///
/// </summary>
@ -469,6 +509,7 @@ namespace OpenSim.Region.Environment.Scenes
part.UpdateTextureEntry(textureEntry);
}
}
#endregion
#region Shape
/// <summary>
@ -485,6 +526,7 @@ namespace OpenSim.Region.Environment.Scenes
}
#endregion
#region Resize
/// <summary>
///
/// </summary>
@ -498,6 +540,7 @@ namespace OpenSim.Region.Environment.Scenes
part.Resize(scale);
}
}
#endregion
#region Position
/// <summary>
@ -636,8 +679,6 @@ namespace OpenSim.Region.Environment.Scenes
private void SetPartAsRoot(SceneObjectPart part)
{
this.m_rootPart = part;
//this.m_uuid= part.UUID;
// this.m_localId = part.LocalID;
}
/// <summary>
@ -658,6 +699,29 @@ namespace OpenSim.Region.Environment.Scenes
return m_scene.RequestAvatarList();
}
#region Events
/// <summary>
///
/// </summary>
public void TriggerTainted()
{
if (OnPrimCountTainted != null)
{
this.OnPrimCountTainted();
}
}
/// <summary>
/// Processes backup
/// </summary>
/// <param name="datastore"></param>
public void ProcessBackup(OpenSim.Region.Interfaces.IRegionDataStore datastore)
{
datastore.StoreObject(this);
}
#endregion
#region Client Updating
public void SendFullUpdateToClient(IClientAPI remoteClient)
{
lock (this.m_parts)
@ -702,5 +766,41 @@ namespace OpenSim.Region.Environment.Scenes
part.SendTerseUpdateToClient(remoteClient);
}
}
#endregion
/// <summary>
/// Added as a way for the storage provider to reset the scene,
/// most likely a better way to do this sort of thing but for now...
/// </summary>
/// <param name="scene"></param>
public void SetScene(Scene scene)
{
m_scene = scene;
m_scene.EventManager.OnBackup += this.ProcessBackup;
}
/// <summary>
///
/// </summary>
/// <param name="part"></param>
public void AddPart(SceneObjectPart part)
{
part.SetParent(this);
this.m_parts.Add(part.UUID, part);
}
/// <summary>
///
/// </summary>
public void UpdateParentIDs()
{
foreach (SceneObjectPart part in this.m_parts.Values)
{
if (part.UUID != this.m_rootPart.UUID)
{
part.ParentID = this.m_rootPart.LocalID;
}
}
}
}
}

View File

@ -1,5 +1,8 @@
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
using System.IO;
using System;
using Axiom.Math;
using libsecondlife;
@ -249,6 +252,27 @@ namespace OpenSim.Region.Environment.Scenes
}
#endregion
/// <summary>
///
/// </summary>
/// <param name="xmlreader"></param>
/// <returns></returns>
public static SceneObjectPart FromXml(XmlReader xmlReader)
{
XmlSerializer serializer = new XmlSerializer(typeof(SceneObjectPart));
return (SceneObjectPart)serializer.Deserialize(xmlReader);
}
/// <summary>
///
/// </summary>
/// <param name="xmlWriter"></param>
public void ToXml(XmlWriter xmlWriter)
{
XmlSerializer serializer = new XmlSerializer(typeof(SceneObjectPart));
serializer.Serialize(xmlWriter, this);
}
/// <summary>
///
/// </summary>

View File

@ -308,7 +308,6 @@ namespace OpenSim.DataStore.MonoSqliteStorage
private void fillPrimRow(DataRow row, SceneObjectPart prim, LLUUID sceneGroupID)
{
Console.WriteLine("scene Group for this prim is " + sceneGroupID);
row["UUID"] = prim.UUID;
row["ParentID"] = prim.ParentID;
row["CreationDate"] = prim.CreationDate;
@ -481,37 +480,54 @@ namespace OpenSim.DataStore.MonoSqliteStorage
public List<SceneObjectGroup> LoadObjects()
{
Dictionary<LLUUID, SceneObjectGroup> createdObjects = new Dictionary<LLUUID, SceneObjectGroup>();
List<SceneObjectGroup> retvals = new List<SceneObjectGroup>();
DataTable prims = ds.Tables["prims"];
DataTable shapes = ds.Tables["primshapes"];
// This only supports 1 prim per SceneObjectGroup. Need to fix later
foreach (DataRow primRow in prims.Rows)
{
SceneObjectGroup group = new SceneObjectGroup();
SceneObjectPart prim = buildPrim(primRow);
DataRow shapeRow = shapes.Rows.Find(prim.UUID);
if (shapeRow != null)
string uuid = (string)primRow["UUID"];
string objID = (string)primRow["SceneGroupID"];
if (uuid == objID) //is new SceneObjectGroup ?
{
prim.Shape = buildShape(shapeRow);
SceneObjectGroup group = new SceneObjectGroup();
SceneObjectPart prim = buildPrim(primRow);
DataRow shapeRow = shapes.Rows.Find(prim.UUID);
if (shapeRow != null)
{
prim.Shape = buildShape(shapeRow);
}
else
{
Console.WriteLine("No shape found for prim in storage, so setting default box shape");
prim.Shape = BoxShape.Default;
}
group.AddPart(prim);
group.RootPart = prim;
createdObjects.Add(group.UUID, group);
retvals.Add(group);
}
else
{
Console.WriteLine("No shape found for prim in storage, so setting default box shape");
prim.Shape = BoxShape.Default;
SceneObjectPart prim = buildPrim(primRow);
DataRow shapeRow = shapes.Rows.Find(prim.UUID);
if (shapeRow != null)
{
prim.Shape = buildShape(shapeRow);
}
else
{
Console.WriteLine("No shape found for prim in storage, so setting default box shape");
prim.Shape = BoxShape.Default;
}
createdObjects[new LLUUID(objID)].AddPart(prim);
}
group.AddPart(prim);
// TODO: there are a couple of known issues to get this to work
// * While we can add Children, we can't set the root part (or
// or even figure out which should be the root part)
// * region handle may need to be persisted, it isn't now
group.RootPart = prim;
retvals.Add(group);
}
MainLog.Instance.Verbose("DATASTORE", "Sqlite - LoadObjects found " + prims.Rows.Count + " objects");
MainLog.Instance.Verbose("DATASTORE", "Sqlite - LoadObjects found " + prims.Rows.Count + " primitives");
return retvals;
}