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
parent
ed1208d043
commit
b59d9789f8
|
@ -459,7 +459,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
{
|
{
|
||||||
AddEntityFromStorage(prim);
|
AddEntityFromStorage(prim);
|
||||||
}
|
}
|
||||||
MainLog.Instance.Verbose("Loaded " + PrimsFromDB.Count.ToString() + " object(s)");
|
MainLog.Instance.Verbose("Loaded " + PrimsFromDB.Count.ToString() + " SceneObject(s)");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -520,6 +520,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
{
|
{
|
||||||
part.LocalID = this.PrimIDAllocate();
|
part.LocalID = this.PrimIDAllocate();
|
||||||
}
|
}
|
||||||
|
sceneObject.UpdateParentIDs();
|
||||||
this.AddEntity(sceneObject);
|
this.AddEntity(sceneObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Xml;
|
||||||
|
using System.Xml.Serialization;
|
||||||
|
using System.IO;
|
||||||
|
using System;
|
||||||
using Axiom.Math;
|
using Axiom.Math;
|
||||||
using libsecondlife;
|
using libsecondlife;
|
||||||
using libsecondlife.Packets;
|
using libsecondlife.Packets;
|
||||||
|
@ -22,6 +26,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
|
|
||||||
public event PrimCountTaintedDelegate OnPrimCountTainted;
|
public event PrimCountTaintedDelegate OnPrimCountTainted;
|
||||||
|
|
||||||
|
#region Properties
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -111,6 +116,9 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
set { m_isSelected = value; }
|
set { m_isSelected = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Constructors
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </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>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -142,7 +175,25 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
this.SetPartAsRoot(newPart);
|
this.SetPartAsRoot(newPart);
|
||||||
m_scene.EventManager.OnBackup += this.ProcessBackup;
|
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
|
#region Copying
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -169,23 +220,6 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
return dupe;
|
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>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -209,6 +243,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Scheduling
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -264,15 +299,9 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
#endregion
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="objectGroup"></param>
|
|
||||||
public void LinkToGroup(SceneObjectGroup objectGroup)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
#region SceneGroupPart Methods
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -339,27 +368,38 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Packet Handlers
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void TriggerTainted()
|
/// <param name="objectGroup"></param>
|
||||||
|
public void LinkToGroup(SceneObjectGroup objectGroup)
|
||||||
{
|
{
|
||||||
if (OnPrimCountTainted != null)
|
SceneObjectPart linkPart = objectGroup.m_rootPart;
|
||||||
{
|
linkPart.OffsetPosition = linkPart.GroupPosition - this.Pos;
|
||||||
this.OnPrimCountTainted();
|
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>
|
||||||
/// Processes backup
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="datastore"></param>
|
|
||||||
public void ProcessBackup(OpenSim.Region.Interfaces.IRegionDataStore datastore)
|
|
||||||
{
|
|
||||||
datastore.StoreObject(this);
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="offset"></param>
|
/// <param name="offset"></param>
|
||||||
|
@ -469,6 +509,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
part.UpdateTextureEntry(textureEntry);
|
part.UpdateTextureEntry(textureEntry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region Shape
|
#region Shape
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -485,6 +526,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Resize
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -498,6 +540,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
part.Resize(scale);
|
part.Resize(scale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region Position
|
#region Position
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -636,8 +679,6 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
private void SetPartAsRoot(SceneObjectPart part)
|
private void SetPartAsRoot(SceneObjectPart part)
|
||||||
{
|
{
|
||||||
this.m_rootPart = part;
|
this.m_rootPart = part;
|
||||||
//this.m_uuid= part.UUID;
|
|
||||||
// this.m_localId = part.LocalID;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -658,6 +699,29 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
return m_scene.RequestAvatarList();
|
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)
|
public void SendFullUpdateToClient(IClientAPI remoteClient)
|
||||||
{
|
{
|
||||||
lock (this.m_parts)
|
lock (this.m_parts)
|
||||||
|
@ -702,5 +766,41 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
part.SendTerseUpdateToClient(remoteClient);
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Xml;
|
||||||
|
using System.Xml.Serialization;
|
||||||
|
using System.IO;
|
||||||
using System;
|
using System;
|
||||||
using Axiom.Math;
|
using Axiom.Math;
|
||||||
using libsecondlife;
|
using libsecondlife;
|
||||||
|
@ -249,6 +252,27 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
}
|
}
|
||||||
#endregion
|
#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>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -308,7 +308,6 @@ namespace OpenSim.DataStore.MonoSqliteStorage
|
||||||
|
|
||||||
private void fillPrimRow(DataRow row, SceneObjectPart prim, LLUUID sceneGroupID)
|
private void fillPrimRow(DataRow row, SceneObjectPart prim, LLUUID sceneGroupID)
|
||||||
{
|
{
|
||||||
Console.WriteLine("scene Group for this prim is " + sceneGroupID);
|
|
||||||
row["UUID"] = prim.UUID;
|
row["UUID"] = prim.UUID;
|
||||||
row["ParentID"] = prim.ParentID;
|
row["ParentID"] = prim.ParentID;
|
||||||
row["CreationDate"] = prim.CreationDate;
|
row["CreationDate"] = prim.CreationDate;
|
||||||
|
@ -481,13 +480,17 @@ namespace OpenSim.DataStore.MonoSqliteStorage
|
||||||
|
|
||||||
public List<SceneObjectGroup> LoadObjects()
|
public List<SceneObjectGroup> LoadObjects()
|
||||||
{
|
{
|
||||||
|
Dictionary<LLUUID, SceneObjectGroup> createdObjects = new Dictionary<LLUUID, SceneObjectGroup>();
|
||||||
List<SceneObjectGroup> retvals = new List<SceneObjectGroup>();
|
List<SceneObjectGroup> retvals = new List<SceneObjectGroup>();
|
||||||
|
|
||||||
DataTable prims = ds.Tables["prims"];
|
DataTable prims = ds.Tables["prims"];
|
||||||
DataTable shapes = ds.Tables["primshapes"];
|
DataTable shapes = ds.Tables["primshapes"];
|
||||||
|
|
||||||
// This only supports 1 prim per SceneObjectGroup. Need to fix later
|
|
||||||
foreach (DataRow primRow in prims.Rows)
|
foreach (DataRow primRow in prims.Rows)
|
||||||
|
{
|
||||||
|
string uuid = (string)primRow["UUID"];
|
||||||
|
string objID = (string)primRow["SceneGroupID"];
|
||||||
|
if (uuid == objID) //is new SceneObjectGroup ?
|
||||||
{
|
{
|
||||||
SceneObjectGroup group = new SceneObjectGroup();
|
SceneObjectGroup group = new SceneObjectGroup();
|
||||||
SceneObjectPart prim = buildPrim(primRow);
|
SceneObjectPart prim = buildPrim(primRow);
|
||||||
|
@ -502,16 +505,29 @@ namespace OpenSim.DataStore.MonoSqliteStorage
|
||||||
prim.Shape = BoxShape.Default;
|
prim.Shape = BoxShape.Default;
|
||||||
}
|
}
|
||||||
group.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;
|
group.RootPart = prim;
|
||||||
|
|
||||||
|
createdObjects.Add(group.UUID, group);
|
||||||
retvals.Add(group);
|
retvals.Add(group);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MainLog.Instance.Verbose("DATASTORE", "Sqlite - LoadObjects found " + prims.Rows.Count + " objects");
|
MainLog.Instance.Verbose("DATASTORE", "Sqlite - LoadObjects found " + prims.Rows.Count + " primitives");
|
||||||
|
|
||||||
return retvals;
|
return retvals;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue