Merge branch 'master' into careminster

Conflicts:
	OpenSim/Data/MySQL/MySQLSimulationData.cs
	OpenSim/Framework/RegionSettings.cs
avinationmerge
Melanie 2012-01-24 00:36:42 +00:00
commit 07ad821157
5 changed files with 151 additions and 213 deletions

View File

@ -1012,9 +1012,7 @@ namespace OpenSim.Data.MySQL
"covenant, Sandbox, sunvectorx, sunvectory, " + "covenant, Sandbox, sunvectorx, sunvectory, " +
"sunvectorz, loaded_creation_datetime, " + "sunvectorz, loaded_creation_datetime, " +
"loaded_creation_id, map_tile_ID, block_search, casino, " + "loaded_creation_id, map_tile_ID, block_search, casino, " +
"TelehubEnabled, TelehubObject, TelehubName, " + "TelehubObject) " +
"TelehubPosX, TelehubPosY, TelehubPosZ, " +
"TelehubRotX, TelehubRotY, TelehubRotZ, TelehubRotW) " +
"values (?RegionUUID, ?BlockTerraform, " + "values (?RegionUUID, ?BlockTerraform, " +
"?BlockFly, ?AllowDamage, ?RestrictPushing, " + "?BlockFly, ?AllowDamage, ?RestrictPushing, " +
"?AllowLandResell, ?AllowLandJoinDivide, " + "?AllowLandResell, ?AllowLandJoinDivide, " +
@ -1031,9 +1029,7 @@ namespace OpenSim.Data.MySQL
"?SunVectorX, ?SunVectorY, ?SunVectorZ, " + "?SunVectorX, ?SunVectorY, ?SunVectorZ, " +
"?LoadedCreationDateTime, ?LoadedCreationID, " + "?LoadedCreationDateTime, ?LoadedCreationID, " +
"?TerrainImageID, ?block_search, ?casino, " + "?TerrainImageID, ?block_search, ?casino, " +
"?TelehubEnabled, ?TelehubObject, ?TelehubName, " + "?TelehubObject, " +
"?TelehubPosX, ?TelehubPosY, ?TelehubPosZ, " +
"?TelehubRotX, ?TelehubRotY, ?TelehubRotZ, ?TelehubRotW )";
FillRegionSettingsCommand(cmd, rs); FillRegionSettingsCommand(cmd, rs);
@ -1321,20 +1317,7 @@ namespace OpenSim.Data.MySQL
newSettings.LoadedCreationID = (String) row["loaded_creation_id"]; newSettings.LoadedCreationID = (String) row["loaded_creation_id"];
newSettings.TerrainImageID = DBGuid.FromDB(row["map_tile_ID"]); newSettings.TerrainImageID = DBGuid.FromDB(row["map_tile_ID"]);
newSettings.HasTelehub = Convert.ToBoolean(row["TelehubEnabled"]);
newSettings.TelehubObject = DBGuid.FromDB(row["TelehubObject"]); newSettings.TelehubObject = DBGuid.FromDB(row["TelehubObject"]);
newSettings.TelehubName = (string) row["TelehubName"];
newSettings.TelehubPos = new Vector3 (
Convert.ToSingle(row["TelehubPosX"]),
Convert.ToSingle(row["TelehubPosY"]),
Convert.ToSingle(row["TelehubPosZ"])
);
newSettings.TelehubRot = new Quaternion (
Convert.ToSingle(row["TelehubRotX"]),
Convert.ToSingle(row["TelehubRotY"]),
Convert.ToSingle(row["TelehubRotZ"]),
Convert.ToSingle(row["TelehubRotW"])
);
newSettings.GodBlockSearch = Convert.ToBoolean(row["block_search"]); newSettings.GodBlockSearch = Convert.ToBoolean(row["block_search"]);
newSettings.Casino = Convert.ToBoolean(row["casino"]); newSettings.Casino = Convert.ToBoolean(row["casino"]);
@ -1675,16 +1658,7 @@ namespace OpenSim.Data.MySQL
cmd.Parameters.AddWithValue("block_search", settings.GodBlockSearch); cmd.Parameters.AddWithValue("block_search", settings.GodBlockSearch);
cmd.Parameters.AddWithValue("casino", settings.Casino); cmd.Parameters.AddWithValue("casino", settings.Casino);
cmd.Parameters.AddWithValue("TelehubEnabled", settings.HasTelehub);
cmd.Parameters.AddWithValue("TelehubObject", settings.TelehubObject); cmd.Parameters.AddWithValue("TelehubObject", settings.TelehubObject);
cmd.Parameters.AddWithValue("TelehubName", settings.TelehubName);
cmd.Parameters.AddWithValue("TelehubPosX", settings.TelehubPos.X);
cmd.Parameters.AddWithValue("TelehubPosY", settings.TelehubPos.Y);
cmd.Parameters.AddWithValue("TelehubPosZ", settings.TelehubPos.Z);
cmd.Parameters.AddWithValue("TelehubRotX", settings.TelehubRot.X);
cmd.Parameters.AddWithValue("TelehubRotY", settings.TelehubRot.Y);
cmd.Parameters.AddWithValue("TelehubRotZ", settings.TelehubRot.Z);
cmd.Parameters.AddWithValue("TelehubRotW", settings.TelehubRot.W);
} }
/// <summary> /// <summary>
@ -1899,20 +1873,20 @@ namespace OpenSim.Data.MySQL
using (MySqlCommand cmd = dbcon.CreateCommand()) using (MySqlCommand cmd = dbcon.CreateCommand())
{ {
cmd.CommandText = "select PointX, PointY, PointZ from spawn_points where RegionID = ?RegionID"; cmd.CommandText = "select Yaw, Pitch, Distance from spawn_points where RegionID = ?RegionID";
cmd.Parameters.AddWithValue("?RegionID", rs.RegionUUID.ToString()); cmd.Parameters.AddWithValue("?RegionID", rs.RegionUUID.ToString());
using (IDataReader r = cmd.ExecuteReader()) using (IDataReader r = cmd.ExecuteReader())
{ {
while (r.Read()) while (r.Read())
{ {
Vector3 point = new Vector3(); SpawnPoint sp = new SpawnPoint();
point.X = (float)r["PointX"]; sp.Yaw = (float)r["Yaw"];
point.Y = (float)r["PointY"]; sp.Pitch = (float)r["Pitch"];
point.Z = (float)r["PointZ"]; sp.Distance = (float)r["Distance"];
rs.AddSpawnPoint(point); rs.AddSpawnPoint(sp);
} }
} }
} }
@ -1937,14 +1911,14 @@ namespace OpenSim.Data.MySQL
cmd.Parameters.Clear(); cmd.Parameters.Clear();
cmd.CommandText = "insert into spawn_points (RegionID, PointX, PointY, PointZ) values ( ?RegionID, ?PointX, ?PointY,?PointZ)"; cmd.CommandText = "insert into spawn_points (RegionID, Yaw, Pitch, Distance) values ( ?RegionID, ?Yaw, ?Pitch, ?Distance)";
foreach (Vector3 p in rs.SpawnPoints()) foreach (SpawnPoint p in rs.SpawnPoints())
{ {
cmd.Parameters.AddWithValue("?RegionID", rs.RegionUUID.ToString()); cmd.Parameters.AddWithValue("?RegionID", rs.RegionUUID.ToString());
cmd.Parameters.AddWithValue("?PointX", p.X); cmd.Parameters.AddWithValue("?Yaw", p.Yaw);
cmd.Parameters.AddWithValue("?PointY", p.Y); cmd.Parameters.AddWithValue("?Pitch", p.Pitch);
cmd.Parameters.AddWithValue("?PointZ", p.Z); cmd.Parameters.AddWithValue("?Distance", p.Distance);
cmd.ExecuteNonQuery(); cmd.ExecuteNonQuery();
cmd.Parameters.Clear(); cmd.Parameters.Clear();

View File

@ -848,21 +848,12 @@ COMMIT;
BEGIN; BEGIN;
CREATE TABLE IF NOT EXISTS `spawn_points` ( CREATE TABLE IF NOT EXISTS `spawn_points` (
`RegionID` varchar(36) COLLATE utf8_unicode_ci NOT NULL, `RegionID` varchar(36) COLLATE utf8_unicode_ci NOT NULL,
`PointX` float NOT NULL, `Yaw` float NOT NULL,
`PointY` float NOT NULL, `Pitch` float NOT NULL,
`PointZ` float NOT NULL, `Distance` float NOT NULL,
KEY `RegionID` (`RegionID`) KEY `RegionID` (`RegionID`)
) ENGINE=Innodb; ) ENGINE=Innodb;
ALTER TABLE `regionsettings` ADD COLUMN `TelehubObject` varchar(36) NOT NULL; ALTER TABLE `regionsettings` ADD COLUMN `TelehubObject` varchar(36) NOT NULL;
ALTER TABLE `regionsettings` ADD COLUMN `TelehubName` varchar(255) NOT NULL;
ALTER TABLE `regionsettings` ADD COLUMN `TelehubEnabled` tinyint(4) NOT NULL;
ALTER TABLE `regionsettings` ADD COLUMN `TelehubPosX` float NOT NULL;
ALTER TABLE `regionsettings` ADD COLUMN `TelehubPosY` float NOT NULL;
ALTER TABLE `regionsettings` ADD COLUMN `TelehubPosZ` float NOT NULL;
ALTER TABLE `regionsettings` ADD COLUMN `TelehubRotX` float NOT NULL;
ALTER TABLE `regionsettings` ADD COLUMN `TelehubRotY` float NOT NULL;
ALTER TABLE `regionsettings` ADD COLUMN `TelehubRotZ` float NOT NULL;
ALTER TABLE `regionsettings` ADD COLUMN `TelehubRotW` float NOT NULL;
COMMIT; COMMIT;

View File

@ -32,6 +32,47 @@ using OpenMetaverse;
namespace OpenSim.Framework namespace OpenSim.Framework
{ {
public struct SpawnPoint
{
public float Yaw;
public float Pitch;
public float Distance;
public void SetLocation(Vector3 pos, Quaternion rot, Vector3 point)
{
// The point is an absolute position, so we need the relative
// location to the spawn point
Vector3 offset = pos - point;
Distance = Vector3.Mag(offset);
// Next we need to rotate this vector into the spawn point's
// coordinate system
offset = offset * rot;
Vector3 dir = Vector3.Normalize(offset);
// Get the bearing (yaw)
Yaw = (float)Math.Atan2(dir.Y, dir.X);
// Get the elevation (pitch)
Pitch = (float)-Math.Atan2(dir.Z, Math.Sqrt(dir.X * dir.X + dir.Y * dir.Y));
}
public Vector3 GetLocation(Vector3 pos, Quaternion rot)
{
Quaternion y = Quaternion.CreateFromEulers(0, 0, Yaw);
Quaternion p = Quaternion.CreateFromEulers(0, Pitch, 0);
Vector3 dir = new Vector3(1, 0, 0) * p * y;
Vector3 offset = dir * (float)Distance;
rot.W = -rot.W;
offset *= rot;
return pos + offset;
}
}
public class RegionSettings public class RegionSettings
{ {
public delegate void SaveDelegate(RegionSettings rs); public delegate void SaveDelegate(RegionSettings rs);
@ -426,14 +467,7 @@ namespace OpenSim.Framework
{ {
get get
{ {
if (HasTelehub) return m_TelehubObject;
{
return m_TelehubObject;
}
else
{
return UUID.Zero;
}
} }
set set
{ {
@ -441,66 +475,14 @@ namespace OpenSim.Framework
} }
} }
// Connected Telehub name
private string m_TelehubName;
public string TelehubName
{
get
{
if (HasTelehub)
{
return m_TelehubName;
}
else
{
return String.Empty;
}
}
set
{
m_TelehubName = value;
}
}
// Connected Telehub position
private Vector3 m_TelehubPos;
public Vector3 TelehubPos
{
get
{
if (HasTelehub)
{
return m_TelehubPos;
}
else
{
return Vector3.Zero;
}
}
set
{
m_TelehubPos = value;
}
}
// Connected Telehub rotation
private Quaternion m_TelehubRot;
public Quaternion TelehubRot
{
get
{ return m_TelehubRot; }
set
{ m_TelehubRot = value; }
}
// Our Connected Telehub's SpawnPoints // Our Connected Telehub's SpawnPoints
public List<Vector3> l_SpawnPoints = new List<Vector3>(); public List<SpawnPoint> l_SpawnPoints = new List<SpawnPoint>();
// Add a SpawnPoint // Add a SpawnPoint
// ** These are not region coordinates ** // ** These are not region coordinates **
// They are relative to the Telehub coordinates // They are relative to the Telehub coordinates
// //
public void AddSpawnPoint(Vector3 point) public void AddSpawnPoint(SpawnPoint point)
{ {
l_SpawnPoints.Add(point); l_SpawnPoints.Add(point);
} }
@ -512,7 +494,7 @@ namespace OpenSim.Framework
} }
// Return the List of SpawnPoints // Return the List of SpawnPoints
public List<Vector3> SpawnPoints() public List<SpawnPoint> SpawnPoints()
{ {
return l_SpawnPoints; return l_SpawnPoints;

View File

@ -624,59 +624,37 @@ namespace OpenSim.Region.CoreModules.World.Estate
{ {
case "info ui": case "info ui":
// Send info: // Send info:
if (Scene.RegionInfo.RegionSettings.HasTelehub) SendTelehubInfo(client);
{
RegionSettings settings = this.Scene.RegionInfo.RegionSettings;
client.SendTelehubInfo(settings.TelehubObject, settings.TelehubName, settings.TelehubPos,
settings.TelehubRot, settings.SpawnPoints());
}
else
{
return;
}
break; break;
case "connect": case "connect":
// Add the Telehub // Add the Telehub
part = Scene.GetSceneObjectPart((uint)param1); part = Scene.GetSceneObjectPart((uint)param1);
if (m_Telehub.Connect(part)) if (part == null)
{ return;
RegionSettings settings = this.Scene.RegionInfo.RegionSettings; SceneObjectGroup grp = part.ParentGroup;
client.SendTelehubInfo(settings.TelehubObject, settings.TelehubName, settings.TelehubPos,
settings.TelehubRot, settings.SpawnPoints()); if (m_Telehub.Connect(grp))
} SendTelehubInfo(client);
break; break;
case "delete": case "delete":
// Disconnect Telehub // Disconnect Telehub
part = Scene.GetSceneObjectPart((uint)param1); if (m_Telehub.Disconnect())
if (m_Telehub.DisConnect(part)) SendTelehubInfo(client);
{
RegionSettings settings = this.Scene.RegionInfo.RegionSettings;
client.SendTelehubInfo(settings.TelehubObject, settings.TelehubName, settings.TelehubPos,
settings.TelehubRot, settings.SpawnPoints());
}
break; break;
case "spawnpoint add": case "spawnpoint add":
// Add SpawnPoint to the Telehub // Add SpawnPoint to the Telehub
part = Scene.GetSceneObjectPart((uint)param1); part = Scene.GetSceneObjectPart((uint)param1);
if( m_Telehub.AddSpawnPoint(part.AbsolutePosition)) if( m_Telehub.AddSpawnPoint(part.AbsolutePosition))
{ SendTelehubInfo(client);
RegionSettings settings = this.Scene.RegionInfo.RegionSettings;
client.SendTelehubInfo(settings.TelehubObject, settings.TelehubName, settings.TelehubPos,
settings.TelehubRot, settings.SpawnPoints());
}
break; break;
case "spawnpoint remove": case "spawnpoint remove":
// Remove SpawnPoint from Telehub // Remove SpawnPoint from Telehub
if (m_Telehub.RemoveSpawnPoint((int)param1)) if (m_Telehub.RemoveSpawnPoint((int)param1))
{ SendTelehubInfo(client);
RegionSettings settings = this.Scene.RegionInfo.RegionSettings;
client.SendTelehubInfo(settings.TelehubObject, settings.TelehubName, settings.TelehubPos,
settings.TelehubRot, settings.SpawnPoints());
}
break; break;
default: default:
@ -1365,5 +1343,39 @@ namespace OpenSim.Region.CoreModules.World.Estate
if (onmessage != null) if (onmessage != null)
onmessage(Scene.RegionInfo.RegionID, fromID, fromName, message); onmessage(Scene.RegionInfo.RegionID, fromID, fromName, message);
} }
private void SendTelehubInfo(IClientAPI client)
{
RegionSettings settings =
this.Scene.RegionInfo.RegionSettings;
SceneObjectGroup telehub = null;
if (settings.TelehubObject != UUID.Zero &&
(telehub = Scene.GetSceneObjectGroup(settings.TelehubObject)) != null)
{
List<Vector3> spawnPoints = new List<Vector3>();
foreach (SpawnPoint sp in settings.SpawnPoints())
{
spawnPoints.Add(sp.GetLocation(telehub.AbsolutePosition, telehub.GroupRotation));
}
client.SendTelehubInfo(settings.TelehubObject,
telehub.Name,
telehub.AbsolutePosition,
telehub.GroupRotation,
spawnPoints);
}
else
{
client.SendTelehubInfo(UUID.Zero,
String.Empty,
Vector3.Zero,
Quaternion.Identity,
new List<Vector3>());
}
}
} }
} }

View File

@ -35,103 +35,82 @@ namespace OpenSim.Region.CoreModules.World.Estate
{ {
public class TelehubManager public class TelehubManager
{ {
private UUID ObjectID;
private string ObjectName;
private Vector3 ObjectPosition;
Quaternion ObjectRotation;
List<Vector3> SpawnPoint = new List<Vector3>();
UUID EstateID;
bool m_HasTelehub = false;
Scene m_Scene; Scene m_Scene;
// This will get an option...
Vector3 InitialSpawnPoint = new Vector3(0.0f,0.0f,0.0f);
public bool HasTelehub
{
get { return m_HasTelehub; }
}
public TelehubManager(Scene scene) public TelehubManager(Scene scene)
{ {
m_Scene = scene; m_Scene = scene;
} }
// Fill our Telehub struct with values
// public Telehub TelehubVals()
// {
// // Telehub telehub = new Telehub();
// EstateSettings telehub = m_EstateSettings;
//
// telehub.TelehubObject = ObjectID;
// telehub.TelehubName = ObjectName;
// telehub.TelehubPos = ObjectPosition;
// telehub.TelehubRot = ObjectRotation;
// telehub. = SpawnPoint;
// return telehub;
// }
// Connect the Telehub // Connect the Telehub
public bool Connect(SceneObjectPart part) public bool Connect(SceneObjectGroup grp)
{ {
m_Scene.RegionInfo.RegionSettings.ClearSpawnPoints(); try
{
m_Scene.RegionInfo.RegionSettings.TelehubObject = part.UUID;
m_Scene.RegionInfo.RegionSettings.TelehubName = part.Name;
m_Scene.RegionInfo.RegionSettings.TelehubPos = part.AbsolutePosition;
m_Scene.RegionInfo.RegionSettings.TelehubRot = part.GetWorldRotation();
// Clear this for now
m_Scene.RegionInfo.RegionSettings.AddSpawnPoint(InitialSpawnPoint);
m_Scene.RegionInfo.RegionSettings.HasTelehub = true;
m_Scene.RegionInfo.RegionSettings.Save();
return true;
}
// Disconnect the Telehub: Clear it out for now, look at just disableing
public bool DisConnect(SceneObjectPart part)
{
bool result = false;
try{
m_Scene.RegionInfo.RegionSettings.TelehubObject = UUID.Zero;
m_Scene.RegionInfo.RegionSettings.TelehubName = String.Empty;
m_Scene.RegionInfo.RegionSettings.TelehubPos = Vector3.Zero;
// This is probably wrong! But, HasTelehub will block access
m_Scene.RegionInfo.RegionSettings.TelehubRot = Quaternion.Identity;
m_Scene.RegionInfo.RegionSettings.ClearSpawnPoints(); m_Scene.RegionInfo.RegionSettings.ClearSpawnPoints();
m_Scene.RegionInfo.RegionSettings.HasTelehub = false;
m_Scene.RegionInfo.RegionSettings.TelehubObject = grp.UUID;
m_Scene.RegionInfo.RegionSettings.Save(); m_Scene.RegionInfo.RegionSettings.Save();
result = true;
} }
catch (Exception ex) catch (Exception ex)
{ {
result = false; return false;
} }
finally
return true;
}
// Disconnect the Telehub:
public bool Disconnect()
{
if (m_Scene.RegionInfo.RegionSettings.TelehubObject == UUID.Zero)
return false;
try
{ {
m_Scene.RegionInfo.RegionSettings.TelehubObject = UUID.Zero;
m_Scene.RegionInfo.RegionSettings.ClearSpawnPoints();
m_Scene.RegionInfo.RegionSettings.Save();
}
catch (Exception ex)
{
return false;
} }
return result; return true;
} }
// Add a SpawnPoint to the Telehub // Add a SpawnPoint to the Telehub
public bool AddSpawnPoint(Vector3 point) public bool AddSpawnPoint(Vector3 point)
{ {
if (m_Scene.RegionInfo.RegionSettings.TelehubObject == UUID.Zero)
return false;
float dist = (float) Util.GetDistanceTo(m_Scene.RegionInfo.RegionSettings.TelehubPos, point); SceneObjectGroup grp = m_Scene.GetSceneObjectGroup(m_Scene.RegionInfo.RegionSettings.TelehubObject);
Vector3 nvec = Util.GetNormalizedVector(point - m_Scene.RegionInfo.RegionSettings.TelehubPos); if (grp == null)
Vector3 spoint = nvec * dist; return false;
try
{
SpawnPoint sp = new SpawnPoint();
sp.SetLocation(grp.AbsolutePosition, grp.GroupRotation, point);
m_Scene.RegionInfo.RegionSettings.AddSpawnPoint(sp);
m_Scene.RegionInfo.RegionSettings.Save();
}
catch (Exception ex)
{
return false;
}
m_Scene.RegionInfo.RegionSettings.AddSpawnPoint(spoint);
m_Scene.RegionInfo.RegionSettings.Save();
return true; return true;
} }
// Remove a SpawnPoint from the Telehub // Remove a SpawnPoint from the Telehub
public bool RemoveSpawnPoint(int spawnpoint) public bool RemoveSpawnPoint(int spawnpoint)
{ {
if (m_Scene.RegionInfo.RegionSettings.TelehubObject == UUID.Zero)
return false;
m_Scene.RegionInfo.RegionSettings.RemoveSpawnPoint(spawnpoint); m_Scene.RegionInfo.RegionSettings.RemoveSpawnPoint(spawnpoint);
m_Scene.RegionInfo.RegionSettings.Save(); m_Scene.RegionInfo.RegionSettings.Save();