Couldn't leave this one alone. Data is now flowing both ways in

sqlite *but* isn't being added back to the scene on load because 
some information (like rootpart) isn't currently exposed enough
to save/restore, and I don't want to change the SceneObjectGroup
definition without MW around to discuss.

A couple of minor changes on the object interface for SceneObjectGroup
and tweaks to this class, and we have persistant prims again.
afrisby
Sean Dague 2007-08-09 23:51:26 +00:00
parent 0443723ea5
commit 6063d2ce5f
1 changed files with 78 additions and 71 deletions

View File

@ -11,6 +11,7 @@ using OpenSim.Framework.Types;
using libsecondlife; using libsecondlife;
using System.Data; using System.Data;
using System.Data.SqlTypes;
// Yes, this won't compile on MS, need to deal with that later // Yes, this won't compile on MS, need to deal with that later
using Mono.Data.SqliteClient; using Mono.Data.SqliteClient;
@ -244,57 +245,59 @@ namespace OpenSim.DataStore.MonoSqliteStorage
// interesting has to be done to actually get these values // interesting has to be done to actually get these values
// back out. Not enough time to figure it out yet. // back out. Not enough time to figure it out yet.
SceneObjectPart prim = new SceneObjectPart(); SceneObjectPart prim = new SceneObjectPart();
prim.UUID = new LLUUID((string)row["UUID"]); prim.UUID = new LLUUID((String)row["UUID"]);
prim.ParentID = (uint)row["ParentID"]; // explicit conversion of integers is required, which sort
prim.CreationDate = (int)row["CreationDate"]; // of sucks. No idea if there is a shortcut here or not.
prim.PartName = (string)row["Name"]; prim.ParentID = Convert.ToUInt32(row["ParentID"]);
prim.CreationDate = Convert.ToInt32(row["CreationDate"]);
prim.PartName = (String)row["Name"];
// various text fields // various text fields
prim.Text = (string)row["Text"]; prim.Text = (String)row["Text"];
prim.Description = (string)row["Description"]; prim.Description = (String)row["Description"];
prim.SitName = (string)row["SitName"]; prim.SitName = (String)row["SitName"];
prim.TouchName = (string)row["TouchName"]; prim.TouchName = (String)row["TouchName"];
// permissions // permissions
prim.CreatorID = new LLUUID((string)row["CreatorID"]); prim.CreatorID = new LLUUID((String)row["CreatorID"]);
prim.OwnerID = new LLUUID((string)row["OwnerID"]); prim.OwnerID = new LLUUID((String)row["OwnerID"]);
prim.GroupID = new LLUUID((string)row["GroupID"]); prim.GroupID = new LLUUID((String)row["GroupID"]);
prim.LastOwnerID = new LLUUID((string)row["LastOwnerID"]); prim.LastOwnerID = new LLUUID((String)row["LastOwnerID"]);
prim.OwnerMask = (uint)row["OwnerMask"]; prim.OwnerMask = Convert.ToUInt32(row["OwnerMask"]);
prim.NextOwnerMask = (uint)row["NextOwnerMask"]; prim.NextOwnerMask = Convert.ToUInt32(row["NextOwnerMask"]);
prim.GroupMask = (uint)row["GroupMask"]; prim.GroupMask = Convert.ToUInt32(row["GroupMask"]);
prim.EveryoneMask = (uint)row["EveryoneMask"]; prim.EveryoneMask = Convert.ToUInt32(row["EveryoneMask"]);
prim.BaseMask = (uint)row["BaseMask"]; prim.BaseMask = Convert.ToUInt32(row["BaseMask"]);
// vectors // vectors
prim.OffsetPosition = new LLVector3( prim.OffsetPosition = new LLVector3(
(float)row["PositionX"], Convert.ToSingle(row["PositionX"]),
(float)row["PositionY"], Convert.ToSingle(row["PositionY"]),
(float)row["PositionZ"] Convert.ToSingle(row["PositionZ"])
); );
prim.GroupPosition = new LLVector3( prim.GroupPosition = new LLVector3(
(float)row["GroupPositionX"], Convert.ToSingle(row["GroupPositionX"]),
(float)row["GroupPositionY"], Convert.ToSingle(row["GroupPositionY"]),
(float)row["GroupPositionZ"] Convert.ToSingle(row["GroupPositionZ"])
); );
prim.Velocity = new LLVector3( prim.Velocity = new LLVector3(
(float)row["VelocityX"], Convert.ToSingle(row["VelocityX"]),
(float)row["VelocityY"], Convert.ToSingle(row["VelocityY"]),
(float)row["VelocityZ"] Convert.ToSingle(row["VelocityZ"])
); );
prim.AngularVelocity = new LLVector3( prim.AngularVelocity = new LLVector3(
(float)row["AngularVelocityX"], Convert.ToSingle(row["AngularVelocityX"]),
(float)row["AngularVelocityY"], Convert.ToSingle(row["AngularVelocityY"]),
(float)row["AngularVelocityZ"] Convert.ToSingle(row["AngularVelocityZ"])
); );
prim.Acceleration = new LLVector3( prim.Acceleration = new LLVector3(
(float)row["AccelerationX"], Convert.ToSingle(row["AccelerationX"]),
(float)row["AccelerationY"], Convert.ToSingle(row["AccelerationY"]),
(float)row["AccelerationZ"] Convert.ToSingle(row["AccelerationZ"])
); );
// quaternions // quaternions
prim.RotationOffset = new LLQuaternion( prim.RotationOffset = new LLQuaternion(
(float)row["RotationX"], Convert.ToSingle(row["RotationX"]),
(float)row["RotationY"], Convert.ToSingle(row["RotationY"]),
(float)row["RotationZ"], Convert.ToSingle(row["RotationZ"]),
(float)row["RotationW"] Convert.ToSingle(row["RotationW"])
); );
return prim; return prim;
} }
@ -347,34 +350,34 @@ namespace OpenSim.DataStore.MonoSqliteStorage
{ {
PrimitiveBaseShape s = new PrimitiveBaseShape(); PrimitiveBaseShape s = new PrimitiveBaseShape();
s.Scale = new LLVector3( s.Scale = new LLVector3(
(float)row["ScaleX"], Convert.ToSingle(row["ScaleX"]),
(float)row["ScaleY"], Convert.ToSingle(row["ScaleY"]),
(float)row["ScaleZ"] Convert.ToSingle(row["ScaleZ"])
); );
// paths // paths
s.PCode = (byte)row["PCode"]; s.PCode = Convert.ToByte(row["PCode"]);
s.PathBegin = (ushort)row["PathBegin"]; s.PathBegin = Convert.ToUInt16(row["PathBegin"]);
s.PathEnd = (ushort)row["PathEnd"]; s.PathEnd = Convert.ToUInt16(row["PathEnd"]);
s.PathScaleX = (byte)row["PathScaleX"]; s.PathScaleX = Convert.ToByte(row["PathScaleX"]);
s.PathScaleY = (byte)row["PathScaleY"]; s.PathScaleY = Convert.ToByte(row["PathScaleY"]);
s.PathShearX = (byte)row["PathShearX"]; s.PathShearX = Convert.ToByte(row["PathShearX"]);
s.PathShearY = (byte)row["PathShearY"]; s.PathShearY = Convert.ToByte(row["PathShearY"]);
s.PathSkew = (sbyte)row["PathSkew"]; s.PathSkew = Convert.ToSByte(row["PathSkew"]);
s.PathCurve = (byte)row["PathCurve"]; s.PathCurve = Convert.ToByte(row["PathCurve"]);
s.PathRadiusOffset = (sbyte)row["PathRadiusOffset"]; s.PathRadiusOffset = Convert.ToSByte(row["PathRadiusOffset"]);
s.PathRevolutions = (byte)row["PathRevolutions"]; s.PathRevolutions = Convert.ToByte(row["PathRevolutions"]);
s.PathTaperX = (sbyte)row["PathTaperX"]; s.PathTaperX = Convert.ToSByte(row["PathTaperX"]);
s.PathTaperY = (sbyte)row["PathTaperY"]; s.PathTaperY = Convert.ToSByte(row["PathTaperY"]);
s.PathTwist = (sbyte)row["PathTwist"]; s.PathTwist = Convert.ToSByte(row["PathTwist"]);
s.PathTwistBegin = (sbyte)row["PathTwistBegin"]; s.PathTwistBegin = Convert.ToSByte(row["PathTwistBegin"]);
// profile // profile
s.ProfileBegin = (ushort)row["ProfileBegin"]; s.ProfileBegin = Convert.ToUInt16(row["ProfileBegin"]);
s.ProfileEnd = (ushort)row["ProfileEnd"]; s.ProfileEnd = Convert.ToUInt16(row["ProfileEnd"]);
s.ProfileCurve = (byte)row["ProfileCurve"]; s.ProfileCurve = Convert.ToByte(row["ProfileCurve"]);
s.ProfileHollow = (byte)row["ProfileHollow"]; s.ProfileHollow = Convert.ToByte(row["ProfileHollow"]);
// text TODO: this isn't right] = but I'm not sure the right // text TODO: this isn't right] = but I'm not sure the right
// way to specify this as a blob atm // way to specify this as a blob atm
s.TextureEntry = (byte[])row["Texture"]; // s.TextureEntry = (byte[])row["Texture"];
return s; return s;
} }
@ -464,19 +467,23 @@ namespace OpenSim.DataStore.MonoSqliteStorage
DataTable shapes = ds.Tables["primshapes"]; DataTable shapes = ds.Tables["primshapes"];
// This only supports 1 prim per SceneObjectGroup. Need to fix later // This only supports 1 prim per SceneObjectGroup. Need to fix later
// foreach (DataRow primRow in prims.Rows) foreach (DataRow primRow in prims.Rows)
// { {
// SceneObjectGroup group = new SceneObjectGroup(); SceneObjectGroup group = new SceneObjectGroup();
// SceneObjectPart prim = buildPrim(primRow); SceneObjectPart prim = buildPrim(primRow);
// DataRow shapeRow = shapes.Rows.Find(prim.UUID); DataRow shapeRow = shapes.Rows.Find(prim.UUID);
// if (shapeRow != null) { if (shapeRow != null) {
// prim.Shape = buildShape(shapeRow); prim.Shape = buildShape(shapeRow);
// } }
// group.Children.Add(prim.UUID, prim); group.Children.Add(prim.UUID, prim);
// retvals.Add(group); // 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
// retvals.Add(group);
}
MainLog.Instance.Verbose("DATASTORE", "Sqlite - LoadObjects found " + " objects"); MainLog.Instance.Verbose("DATASTORE", "Sqlite - LoadObjects found " + prims.Rows.Count + " objects");
return retvals; return retvals;
} }