* Added Sit Target persistence over sim restarts for mySQL and MonoSQLite.

* SAVE YOUR PRIM DATA, THIS MAKES CHANGES TO YOUR PRIMS TABLE
* The first time you run OpenSim after updating past this revision, you'll see a lot of Errors.   Be calm, shutdown the simulator, and start it again and your prims table will be updated.
* MSSQL added the fields to the Initial CreateTable section, however, you'll need to add the fields to your prims table if you want it to persist.
afrisby
Teravus Ovares 2007-12-27 05:37:48 +00:00
parent af406bf6fa
commit cbf5ff4a93
4 changed files with 163 additions and 0 deletions

View File

@ -523,6 +523,16 @@ namespace OpenSim.Framework.Data.MySQL
createCol(prims, "RotationY", typeof(Double)); createCol(prims, "RotationY", typeof(Double));
createCol(prims, "RotationZ", typeof(Double)); createCol(prims, "RotationZ", typeof(Double));
createCol(prims, "RotationW", typeof(Double)); createCol(prims, "RotationW", typeof(Double));
// sit target
createCol(prims, "SitTargetOffsetX", typeof(Double));
createCol(prims, "SitTargetOffsetY", typeof(Double));
createCol(prims, "SitTargetOffsetZ", typeof(Double));
createCol(prims, "SitTargetOrientW", typeof(Double));
createCol(prims, "SitTargetOrientX", typeof(Double));
createCol(prims, "SitTargetOrientY", typeof(Double));
createCol(prims, "SitTargetOrientZ", typeof(Double));
// Add in contraints // Add in contraints
prims.PrimaryKey = new DataColumn[] { prims.Columns["UUID"] }; prims.PrimaryKey = new DataColumn[] { prims.Columns["UUID"] };
@ -688,7 +698,26 @@ namespace OpenSim.Framework.Data.MySQL
Convert.ToSingle(row["RotationZ"]), Convert.ToSingle(row["RotationZ"]),
Convert.ToSingle(row["RotationW"]) Convert.ToSingle(row["RotationW"])
); );
try
{
prim.SetSitTargetLL(new LLVector3(
Convert.ToSingle(row["SitTargetOffsetX"]),
Convert.ToSingle(row["SitTargetOffsetX"]),
Convert.ToSingle(row["SitTargetOffsetZ"])), new LLQuaternion(
Convert.ToSingle(row["SitTargetOrientW"]),
Convert.ToSingle(row["SitTargetOrientX"]),
Convert.ToSingle(row["SitTargetOrientY"]),
Convert.ToSingle(row["SitTargetOrientX"])));
}
catch (System.InvalidCastException)
{
// Database table was created before we got here and needs to be created! :P
using (MySqlCommand cmd = new MySqlCommand("ALTER TABLE `prims` ADD COLUMN `SitTargetOffsetX` float NOT NULL default 0, ADD COLUMN `SitTargetOffsetY` float NOT NULL default 0, ADD COLUMN `SitTargetOffsetZ` float NOT NULL default 0, ADD COLUMN `SitTargetOrientW` float NOT NULL default 0, ADD COLUMN `SitTargetOrientX` float NOT NULL default 0, ADD COLUMN `SitTargetOrientY` float NOT NULL default 0, ADD COLUMN `SitTargetOrientZ` float NOT NULL default 0;", m_connection))
{
cmd.ExecuteNonQuery();
}
}
return prim; return prim;
} }
@ -798,6 +827,19 @@ namespace OpenSim.Framework.Data.MySQL
row["RotationY"] = prim.RotationOffset.Y; row["RotationY"] = prim.RotationOffset.Y;
row["RotationZ"] = prim.RotationOffset.Z; row["RotationZ"] = prim.RotationOffset.Z;
row["RotationW"] = prim.RotationOffset.W; row["RotationW"] = prim.RotationOffset.W;
// Sit target
LLVector3 sitTargetPos = prim.GetSitTargetPositionLL();
row["SitTargetOffsetX"] = sitTargetPos.X;
row["SitTargetOffsetY"] = sitTargetPos.Y;
row["SitTargetOffsetZ"] = sitTargetPos.Z;
LLQuaternion sitTargetOrient = prim.GetSitTargetOrientationLL();
row["SitTargetOrientW"] = sitTargetOrient.W;
row["SitTargetOrientX"] = sitTargetOrient.X;
row["SitTargetOrientY"] = sitTargetOrient.Y;
row["SitTargetOrientZ"] = sitTargetOrient.Z;
} }
private void fillLandRow(DataRow row, LandData land, LLUUID regionUUID) private void fillLandRow(DataRow row, LandData land, LLUUID regionUUID)

View File

@ -72,6 +72,8 @@ namespace OpenSim.Region.Environment.Scenes
private Quaternion m_sitTargetOrientation = new Quaternion(0, 0, 0, 1); private Quaternion m_sitTargetOrientation = new Quaternion(0, 0, 0, 1);
private LLUUID m_SitTargetAvatar = LLUUID.Zero; private LLUUID m_SitTargetAvatar = LLUUID.Zero;
// Main grid has default permissions as follows // Main grid has default permissions as follows
// //
@ -345,6 +347,15 @@ namespace OpenSim.Region.Environment.Scenes
private string m_text = ""; private string m_text = "";
public Vector3 SitTargetPosition
{
get { return m_sitTargetPosition; }
}
public Quaternion SitTargetOrientation
{
get { return m_sitTargetOrientation; }
}
public string Text public string Text
{ {
get { return m_text; } get { return m_text; }
@ -786,6 +797,22 @@ namespace OpenSim.Region.Environment.Scenes
m_sitTargetPosition = offset; m_sitTargetPosition = offset;
m_sitTargetOrientation = orientation; m_sitTargetOrientation = orientation;
} }
public LLVector3 GetSitTargetPositionLL()
{
return new LLVector3(m_sitTargetPosition.x, m_sitTargetPosition.y, m_sitTargetPosition.z);
}
public LLQuaternion GetSitTargetOrientationLL()
{
return new LLQuaternion(m_sitTargetOrientation.w, m_sitTargetOrientation.x, m_sitTargetOrientation.y, m_sitTargetOrientation.z);
}
// Utility function so the databases don't have to reference axiom.math
public void SetSitTargetLL(LLVector3 offset, LLQuaternion orientation)
{
m_sitTargetPosition = new Vector3(offset.X, offset.Y, offset.Z);
m_sitTargetOrientation = new Quaternion(orientation.W, orientation.X, orientation.Y, orientation.Z);
}
public Vector3 GetSitTargetPosition() public Vector3 GetSitTargetPosition()
{ {

View File

@ -391,6 +391,16 @@ namespace OpenSim.DataStore.MSSQL
createCol(prims, "RotationZ", typeof(System.Double)); createCol(prims, "RotationZ", typeof(System.Double));
createCol(prims, "RotationW", typeof(System.Double)); createCol(prims, "RotationW", typeof(System.Double));
// sit target
createCol(prims, "SitTargetOffsetX", typeof(System.Double));
createCol(prims, "SitTargetOffsetY", typeof(System.Double));
createCol(prims, "SitTargetOffsetZ", typeof(System.Double));
createCol(prims, "SitTargetOrientW", typeof(System.Double));
createCol(prims, "SitTargetOrientX", typeof(System.Double));
createCol(prims, "SitTargetOrientY", typeof(System.Double));
createCol(prims, "SitTargetOrientZ", typeof(System.Double));
// Add in contraints // Add in contraints
prims.PrimaryKey = new DataColumn[] { prims.Columns["UUID"] }; prims.PrimaryKey = new DataColumn[] { prims.Columns["UUID"] };
@ -508,6 +518,22 @@ namespace OpenSim.DataStore.MSSQL
Convert.ToSingle(row["RotationW"]) Convert.ToSingle(row["RotationW"])
); );
try
{
prim.SetSitTargetLL(new LLVector3(
Convert.ToSingle(row["SitTargetOffsetX"]),
Convert.ToSingle(row["SitTargetOffsetX"]),
Convert.ToSingle(row["SitTargetOffsetZ"])), new LLQuaternion(
Convert.ToSingle(row["SitTargetOrientW"]),
Convert.ToSingle(row["SitTargetOrientX"]),
Convert.ToSingle(row["SitTargetOrientY"]),
Convert.ToSingle(row["SitTargetOrientX"])));
}
catch (System.InvalidCastException)
{
// Database table was created before we got here and now has null values :P
}
return prim; return prim;
} }
@ -557,6 +583,26 @@ namespace OpenSim.DataStore.MSSQL
row["RotationY"] = prim.RotationOffset.Y; row["RotationY"] = prim.RotationOffset.Y;
row["RotationZ"] = prim.RotationOffset.Z; row["RotationZ"] = prim.RotationOffset.Z;
row["RotationW"] = prim.RotationOffset.W; row["RotationW"] = prim.RotationOffset.W;
try
{
// Sit target
LLVector3 sitTargetPos = prim.GetSitTargetPositionLL();
row["SitTargetOffsetX"] = sitTargetPos.X;
row["SitTargetOffsetY"] = sitTargetPos.Y;
row["SitTargetOffsetZ"] = sitTargetPos.Z;
LLQuaternion sitTargetOrient = prim.GetSitTargetOrientationLL();
row["SitTargetOrientW"] = sitTargetOrient.W;
row["SitTargetOrientX"] = sitTargetOrient.X;
row["SitTargetOrientY"] = sitTargetOrient.Y;
row["SitTargetOrientZ"] = sitTargetOrient.Z;
}
catch (System.Exception)
{
// TODO: Add Sit Target Rows!
}
} }
private PrimitiveBaseShape buildShape(DataRow row) private PrimitiveBaseShape buildShape(DataRow row)

View File

@ -56,6 +56,8 @@ namespace OpenSim.DataStore.MonoSqlite
private SqliteDataAdapter landDa; private SqliteDataAdapter landDa;
private SqliteDataAdapter landAccessListDa; private SqliteDataAdapter landAccessListDa;
private SqliteConnection m_conn;
private String m_connectionString; private String m_connectionString;
private bool persistPrimInventories; private bool persistPrimInventories;
@ -77,6 +79,9 @@ namespace OpenSim.DataStore.MonoSqlite
MainLog.Instance.Verbose("DATASTORE", "Sqlite - connecting: " + connectionString); MainLog.Instance.Verbose("DATASTORE", "Sqlite - connecting: " + connectionString);
SqliteConnection conn = new SqliteConnection(m_connectionString); SqliteConnection conn = new SqliteConnection(m_connectionString);
// Arg! Hate databases..
m_conn = conn;
SqliteCommand primSelectCmd = new SqliteCommand(primSelect, conn); SqliteCommand primSelectCmd = new SqliteCommand(primSelect, conn);
primDa = new SqliteDataAdapter(primSelectCmd); primDa = new SqliteDataAdapter(primSelectCmd);
// SqliteCommandBuilder primCb = new SqliteCommandBuilder(primDa); // SqliteCommandBuilder primCb = new SqliteCommandBuilder(primDa);
@ -564,6 +569,16 @@ namespace OpenSim.DataStore.MonoSqlite
createCol(prims, "RotationZ", typeof (Double)); createCol(prims, "RotationZ", typeof (Double));
createCol(prims, "RotationW", typeof (Double)); createCol(prims, "RotationW", typeof (Double));
// sit target
createCol(prims, "SitTargetOffsetX", typeof(Double));
createCol(prims, "SitTargetOffsetY", typeof(Double));
createCol(prims, "SitTargetOffsetZ", typeof(Double));
createCol(prims, "SitTargetOrientW", typeof(Double));
createCol(prims, "SitTargetOrientX", typeof(Double));
createCol(prims, "SitTargetOrientY", typeof(Double));
createCol(prims, "SitTargetOrientZ", typeof(Double));
// Add in contraints // Add in contraints
prims.PrimaryKey = new DataColumn[] {prims.Columns["UUID"]}; prims.PrimaryKey = new DataColumn[] {prims.Columns["UUID"]};
@ -764,6 +779,26 @@ namespace OpenSim.DataStore.MonoSqlite
Convert.ToSingle(row["RotationW"]) Convert.ToSingle(row["RotationW"])
); );
try
{
prim.SetSitTargetLL(new LLVector3(
Convert.ToSingle(row["SitTargetOffsetX"]),
Convert.ToSingle(row["SitTargetOffsetX"]),
Convert.ToSingle(row["SitTargetOffsetZ"])), new LLQuaternion(
Convert.ToSingle(row["SitTargetOrientW"]),
Convert.ToSingle(row["SitTargetOrientX"]),
Convert.ToSingle(row["SitTargetOrientY"]),
Convert.ToSingle(row["SitTargetOrientX"])));
}
catch (System.InvalidCastException)
{
// Database table was created before we got here and now has null values :P
using (SqliteCommand cmd = new SqliteCommand("ALTER TABLE `prims` ADD COLUMN `SitTargetOffsetX` float NOT NULL default 0, ADD COLUMN `SitTargetOffsetY` float NOT NULL default 0, ADD COLUMN `SitTargetOffsetZ` float NOT NULL default 0, ADD COLUMN `SitTargetOrientW` float NOT NULL default 0, ADD COLUMN `SitTargetOrientX` float NOT NULL default 0, ADD COLUMN `SitTargetOrientY` float NOT NULL default 0, ADD COLUMN `SitTargetOrientZ` float NOT NULL default 0;", m_conn))
{
cmd.ExecuteNonQuery();
}
}
return prim; return prim;
} }
@ -889,6 +924,18 @@ namespace OpenSim.DataStore.MonoSqlite
row["RotationY"] = prim.RotationOffset.Y; row["RotationY"] = prim.RotationOffset.Y;
row["RotationZ"] = prim.RotationOffset.Z; row["RotationZ"] = prim.RotationOffset.Z;
row["RotationW"] = prim.RotationOffset.W; row["RotationW"] = prim.RotationOffset.W;
// Sit target
LLVector3 sitTargetPos = prim.GetSitTargetPositionLL();
row["SitTargetOffsetX"] = sitTargetPos.X;
row["SitTargetOffsetY"] = sitTargetPos.Y;
row["SitTargetOffsetZ"] = sitTargetPos.Z;
LLQuaternion sitTargetOrient = prim.GetSitTargetOrientationLL();
row["SitTargetOrientW"] = sitTargetOrient.W;
row["SitTargetOrientX"] = sitTargetOrient.X;
row["SitTargetOrientY"] = sitTargetOrient.Y;
row["SitTargetOrientZ"] = sitTargetOrient.Z;
} }
private void fillLandRow(DataRow row, LandData land, LLUUID regionUUID) private void fillLandRow(DataRow row, LandData land, LLUUID regionUUID)
@ -1331,6 +1378,7 @@ namespace OpenSim.DataStore.MonoSqlite
DataSet tmpDS = new DataSet(); DataSet tmpDS = new DataSet();
try try
{ {
pDa.Fill(tmpDS, "prims"); pDa.Fill(tmpDS, "prims");
sDa.Fill(tmpDS, "primshapes"); sDa.Fill(tmpDS, "primshapes");