From 87799c1f3ddfbc4b0994cac4e54498520899e4d4 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 24 Jan 2012 00:32:10 +0000 Subject: Change Telehubs to store only the data that is really needed and not additional redundant information. --- OpenSim/Framework/RegionSettings.cs | 116 ++++++++++++++---------------------- 1 file changed, 45 insertions(+), 71 deletions(-) (limited to 'OpenSim/Framework/RegionSettings.cs') diff --git a/OpenSim/Framework/RegionSettings.cs b/OpenSim/Framework/RegionSettings.cs index 9b5bbf2..0a59f43 100644 --- a/OpenSim/Framework/RegionSettings.cs +++ b/OpenSim/Framework/RegionSettings.cs @@ -32,6 +32,47 @@ using OpenMetaverse; 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 delegate void SaveDelegate(RegionSettings rs); @@ -398,28 +439,13 @@ namespace OpenSim.Framework set { m_LoadedCreationID = value; } } - // Telehub support - private bool m_TelehubEnabled = false; - public bool HasTelehub - { - get { return m_TelehubEnabled; } - set { m_TelehubEnabled = value; } - } - // Connected Telehub object private UUID m_TelehubObject; public UUID TelehubObject { get { - if (HasTelehub) - { - return m_TelehubObject; - } - else - { - return UUID.Zero; - } + return m_TelehubObject; } set { @@ -427,66 +453,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 - public List l_SpawnPoints = new List(); + public List l_SpawnPoints = new List(); // Add a SpawnPoint // ** These are not region coordinates ** // They are relative to the Telehub coordinates // - public void AddSpawnPoint(Vector3 point) + public void AddSpawnPoint(SpawnPoint point) { l_SpawnPoints.Add(point); } @@ -498,7 +472,7 @@ namespace OpenSim.Framework } // Return the List of SpawnPoints - public List SpawnPoints() + public List SpawnPoints() { return l_SpawnPoints; -- cgit v1.1