diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs
index e52cdffeaa..dde6afb21f 100755
--- a/OpenSim/Framework/IClientAPI.cs
+++ b/OpenSim/Framework/IClientAPI.cs
@@ -1286,21 +1286,8 @@ namespace OpenSim.Framework
void SendDialog(string objectname, UUID objectID, UUID ownerID, string ownerFirstName, string ownerLastName, string msg, UUID textureID, int ch,
string[] buttonlabels);
- ///
- /// Update the client as to where the sun is currently located.
- ///
- ///
- ///
- /// Seconds since Unix Epoch 01/01/1970 00:00:00
- ///
- ///
- /// The orbital position is given in radians, and must be "adjusted" for the linden client, see LLClientView
- //void SendSunPos(Vector3 sunPos, Vector3 sunVel, ulong CurrentTime, uint SecondsPerSunCycle, uint SecondsPerYear,
- // float OrbitalPosition);
- void SendSunPos(Vector3 sunPos, Vector3 sunVel, float sunAngle);
-
+ void SendViewerTime(Vector3 sunDir, float sunphase);
void SendViewerEffect(ViewerEffectPacket.EffectBlock[] effectBlocks);
- void SendViewerTime(int phase);
void SendAvatarProperties(UUID avatarID, string aboutText, string bornOn, Byte[] membershipType, string flAbout,
uint flags, UUID flImageID, UUID imageID, string profileURL, UUID partnerID);
diff --git a/OpenSim/Framework/ViewerEnviroment.cs b/OpenSim/Framework/ViewerEnviroment.cs
index 5d13a6abba..3b7fd1f9ee 100644
--- a/OpenSim/Framework/ViewerEnviroment.cs
+++ b/OpenSim/Framework/ViewerEnviroment.cs
@@ -27,6 +27,7 @@
using System;
using System.Collections.Generic;
+using System.Runtime.CompilerServices;
using OpenMetaverse;
using OpenMetaverse.StructuredData;
@@ -1208,46 +1209,40 @@ namespace OpenSim.Framework
return top;
}
- public bool getPositions(float altitude, float dayfrac, out Vector3 sundir, out Vector3 moondir,
- out Quaternion sunrot, out Quaternion moonrot)
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public List FindTrack(float altitude)
{
- sundir = Vector3.Zero;
- moondir = Vector3.Zero;
- sunrot = Quaternion.Identity;
- moonrot = Quaternion.Identity;
-
- List track = null;
if (altitude < Altitudes[0])
- track = Cycle.skyTrack0;
- else
- {
- int altindx = 2;
- for (; altindx > 0; --altindx)
- {
- if (Altitudes[altindx] < altitude)
- break;
- }
+ return Cycle.skyTrack0;
- while (altindx >= 0)
- {
- track = Cycle.skyTracks[altindx];
- if (track != null && track.Count > 0)
- break;
- --altindx;
- }
+ int altindx = 1;
+ for (; altindx < Altitudes.Length; ++altindx)
+ {
+ if (Altitudes[altindx] > altitude)
+ break;
}
- if (track == null || track.Count == 0)
- return false;
+ List track = null;
+ while (--altindx >= 0)
+ {
+ track = Cycle.skyTracks[altindx];
+ if (track != null && track.Count > 0)
+ break;
+ }
+ return track;
+ }
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public bool FindSkies(List track, float dayfrac, out float skyfrac, out SkyData sky1, out SkyData sky2)
+ {
+ sky1 = null;
+ sky2 = null;
+ skyfrac = dayfrac;
if (track.Count == 1 || track[0].time < 0)
{
- if (!Cycle.skyframes.TryGetValue(track[0].frameName, out SkyData sky) || sky == null)
+ if (!Cycle.skyframes.TryGetValue(track[0].frameName, out sky1) || sky1 == null)
return false;
- moonrot = sky.moon_rotation;
- moondir = Xrot(moonrot);
- sunrot = sky.sun_rotation;
- sundir = Xrot(sunrot);
return true;
}
@@ -1263,6 +1258,7 @@ namespace OpenSim.Framework
float secondFrac;
string first;
string second;
+
int ntracks = track.Count;
if (i == 0 || i == ntracks)
{
@@ -1281,22 +1277,50 @@ namespace OpenSim.Framework
first = track[i].frameName;
}
- if (!Cycle.skyframes.TryGetValue(first, out SkyData sky1) || sky1 == null)
+ if (!Cycle.skyframes.TryGetValue(first, out sky1) || sky1 == null)
firstFrac = -1;
- if (!Cycle.skyframes.TryGetValue(second, out SkyData sky2) || sky2 == null)
+ if (!Cycle.skyframes.TryGetValue(second, out sky2) || sky2 == null)
secondFrac = -1;
if (firstFrac < 0)
{
if (secondFrac < 0)
return false;
- moonrot = sky2.moon_rotation;
- moondir = Xrot(moonrot);
- sunrot = sky2.sun_rotation;
- sundir = Xrot(sunrot);
+
+ sky1 = sky2;
+ sky2 = null;
return true;
}
+
if (secondFrac < 0 || secondFrac == firstFrac)
+ {
+ sky2 = null;
+ return true;
+ }
+
+ dayfrac -= firstFrac;
+ secondFrac -= firstFrac;
+ dayfrac /= secondFrac;
+ skyfrac = Utils.Clamp(dayfrac, 0, 1f);
+ return true;
+ }
+
+ public bool getPositions(float altitude, float dayfrac, out Vector3 sundir, out Vector3 moondir,
+ out Quaternion sunrot, out Quaternion moonrot)
+ {
+ sundir = Vector3.Zero;
+ moondir = Vector3.Zero;
+ sunrot = Quaternion.Identity;
+ moonrot = Quaternion.Identity;
+
+ List track = FindTrack(altitude);
+ if (track == null || track.Count == 0)
+ return false;
+
+ if (!FindSkies(track, dayfrac, out dayfrac, out SkyData sky1, out SkyData sky2))
+ return false;
+
+ if (sky2 == null)
{
moonrot = sky1.moon_rotation;
moondir = Xrot(moonrot);
@@ -1305,10 +1329,6 @@ namespace OpenSim.Framework
return true;
}
- dayfrac -= firstFrac;
- secondFrac -= firstFrac;
- dayfrac /= secondFrac;
-
moonrot = Quaternion.Slerp(sky1.moon_rotation, sky2.moon_rotation, dayfrac);
moondir = Xrot(moonrot);
@@ -1321,93 +1341,21 @@ namespace OpenSim.Framework
{
sundir = Vector3.Zero;
- List track = null;
- if (altitude < Altitudes[0])
- track = Cycle.skyTrack0;
- else
- {
- int altindx = 2;
- for (; altindx > 0; --altindx)
- {
- if (Altitudes[altindx] < altitude)
- break;
- }
-
- while (altindx >= 0)
- {
- track = Cycle.skyTracks[altindx];
- if (track != null && track.Count > 0)
- break;
- --altindx;
- }
- }
-
+ List track = track = FindTrack(altitude);
if (track == null || track.Count == 0)
return false;
+ if (!FindSkies(track, dayfrac, out dayfrac, out SkyData sky1, out SkyData sky2))
+ return false;
+
Quaternion sunrot;
- if (track.Count == 1 || track[0].time < 0)
- {
- if (!Cycle.skyframes.TryGetValue(track[0].frameName, out SkyData sky) || sky == null)
- return false;
- sunrot = sky.sun_rotation;
- sundir = Xrot(sunrot);
- return true;
- }
- int i = 0;
- while (i < track.Count)
- {
- if (track[i].time > dayfrac)
- break;
- ++i;
- }
-
- float firstFrac;
- float secondFrac;
- string first;
- string second;
- int ntracks = track.Count;
- if (i == 0 || i == ntracks)
- {
- --ntracks;
- firstFrac = track[ntracks].time;
- first = track[ntracks].frameName;
- secondFrac = track[0].time + 1f;
- second = track[0].frameName;
- }
- else
- {
- secondFrac = track[i].time;
- second = track[i].frameName;
- --i;
- firstFrac = track[i].time;
- first = track[i].frameName;
- }
-
- if (!Cycle.skyframes.TryGetValue(first, out SkyData sky1) || sky1 == null)
- firstFrac = -1;
- if (!Cycle.skyframes.TryGetValue(second, out SkyData sky2) || sky2 == null)
- secondFrac = -1;
-
- if (firstFrac < 0)
- {
- if (secondFrac < 0)
- return false;
- sunrot = sky2.sun_rotation;
- sundir = Xrot(sunrot);
- return true;
- }
- if (secondFrac < 0 || secondFrac == firstFrac)
+ if (sky2 == null)
{
sunrot = sky1.sun_rotation;
sundir = Xrot(sunrot);
return true;
}
- dayfrac -= firstFrac;
- secondFrac -= firstFrac;
- dayfrac /= secondFrac;
-
sunrot = Quaternion.Slerp(sky1.sun_rotation, sky2.sun_rotation, dayfrac);
sundir = Xrot(sunrot);
return true;
diff --git a/OpenSim/Region/CoreModules/World/LightShare/EnvironmentModule.cs b/OpenSim/Region/CoreModules/World/LightShare/EnvironmentModule.cs
index 806559e630..7fa884445e 100644
--- a/OpenSim/Region/CoreModules/World/LightShare/EnvironmentModule.cs
+++ b/OpenSim/Region/CoreModules/World/LightShare/EnvironmentModule.cs
@@ -46,6 +46,8 @@ using Caps = OpenSim.Framework.Capabilities.Caps;
using OSDArray = OpenMetaverse.StructuredData.OSDArray;
using OSDMap = OpenMetaverse.StructuredData.OSDMap;
+using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
+
namespace OpenSim.Region.CoreModules.World.LightShare
{
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "EnvironmentModule")]
@@ -539,7 +541,7 @@ namespace OpenSim.Region.CoreModules.World.LightShare
// Name, agentID, caps.RegionName);
ViewerEnviroment VEnv = GetRegionEnviroment();
-
+
OSD d = VEnv.ToWLOSD(UUID.Zero, regionID);
string env = OSDParser.SerializeLLSDXmlString(d);
@@ -750,24 +752,27 @@ namespace OpenSim.Region.CoreModules.World.LightShare
private void UpdateClientsSunTime()
{
+ if(m_scene.GetNumberOfClients() == 0)
+ return;
+
ViewerEnviroment env = GetRegionEnviroment();
float dayFrac = GetDayFractionTime(env);
- // don't ask me what this mess is, just is
float wldayFrac = dayFrac;
- if (wldayFrac < 0.25f)
- wldayFrac += 1.5f;
- else if (wldayFrac > 0.75)
- wldayFrac += 0.5f;
- else if (wldayFrac > 0.33)
- wldayFrac = 3 * wldayFrac - 1;
- else
- wldayFrac = 3 * wldayFrac + 1;
- wldayFrac = Utils.Clamp(wldayFrac, 0, 2);
+ if (wldayFrac <= 0.25f)
+ wldayFrac += 1.5f;
+ else if (wldayFrac > 0.75f)
+ wldayFrac += 0.5f;
+ else if (wldayFrac >= 0.333333f)
+ wldayFrac = 3f * wldayFrac - 1f;
+ else
+ wldayFrac = 3f * wldayFrac + 1f;
+
+ wldayFrac = Utils.Clamp(wldayFrac, 0, 2f);
wldayFrac *= Utils.PI;
- dayFrac *= Utils.TWO_PI;
+ float eepDayFrac = dayFrac * Utils.TWO_PI;
m_scene.ForEachRootScenePresence(delegate (ScenePresence sp)
{
@@ -779,12 +784,12 @@ namespace OpenSim.Region.CoreModules.World.LightShare
if ((vflags & 0x8000) != 0)
{
- client.SendSunPos(Vector3.Zero, Vector3.Zero, dayFrac);
+ client.SendViewerTime(Vector3.Zero, eepDayFrac);
return;
}
env.getWLPositions(sp.AbsolutePosition.Z, dayFrac, out Vector3 m_sunDir);
- client.SendSunPos(m_sunDir, Vector3.Zero, wldayFrac);
+ client.SendViewerTime(m_sunDir, wldayFrac);
});
}
@@ -848,37 +853,37 @@ namespace OpenSim.Region.CoreModules.World.LightShare
return moonrot;
}
- [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
+ [System.Runtime.CompilerServices.MethodImpl(MethodImplOptions.AggressiveInlining)]
public int GetRegionDayLength()
{
return GetRegionEnviroment().DayLength;
}
- [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
+ [System.Runtime.CompilerServices.MethodImpl(MethodImplOptions.AggressiveInlining)]
public int GetRegionDayOffset()
{
return GetRegionEnviroment().DayOffset;
}
- [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
+ [System.Runtime.CompilerServices.MethodImpl(MethodImplOptions.AggressiveInlining)]
public Vector3 GetRegionSunDir(float altitude)
{
return GetSunDir(GetRegionEnviroment(), altitude);
}
- [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
+ [System.Runtime.CompilerServices.MethodImpl(MethodImplOptions.AggressiveInlining)]
public Quaternion GetRegionSunRot(float altitude)
{
return GetSunRot(GetRegionEnviroment(), altitude);
}
- [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
+ [System.Runtime.CompilerServices.MethodImpl(MethodImplOptions.AggressiveInlining)]
public Vector3 GetRegionMoonDir(float altitude)
{
return GetMoonDir(GetRegionEnviroment(), altitude);
}
- [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
+ [System.Runtime.CompilerServices.MethodImpl(MethodImplOptions.AggressiveInlining)]
public Quaternion GetRegionMoonRot(float altitude)
{
return GetMoonRot(GetRegionEnviroment(), altitude);
diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
index 40c8dba84b..2569f489ad 100755
--- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
+++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
@@ -1235,8 +1235,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
{
}
- //public void SendSunPos(Vector3 sunPos, Vector3 sunVel, ulong CurrentTime, uint SecondsPerSunCycle, uint SecondsPerYear, float OrbitalPosition)
- public void SendSunPos(Vector3 sunPos, Vector3 sunVel, float sunAngle)
+ public void SendViewerTime(Vector3 sunDir, float sunphase)
{
}
@@ -1244,11 +1243,6 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
{
}
- public void SendViewerTime(int phase)
- {
-
- }
-
public void SendAvatarProperties(UUID avatarID, string aboutText, string bornOn, byte[] membershipType, string flAbout, uint flags, UUID flImageID, UUID imageID, string profileURL, UUID partnerID)
{
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
index afde78aea0..96b6a64886 100755
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
@@ -988,8 +988,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
{
}
- //public void SendSunPos(Vector3 sunPos, Vector3 sunVel, ulong time, uint dlen, uint ylen, float phase)
- public void SendSunPos(Vector3 sunPos, Vector3 sunVel, float sunAngle)
+ public void SendViewerTime(Vector3 sunDir, float sunphase)
{
}
@@ -997,10 +996,6 @@ namespace OpenSim.Region.OptionalModules.World.NPC
{
}
- public void SendViewerTime(int phase)
- {
- }
-
public void SendAvatarProperties(UUID avatarID, string aboutText, string bornOn, Byte[] membershipType,
string flAbout, uint flags, UUID flImageID, UUID imageID, string profileURL,
UUID partnerID)
diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs
index 2dd77dbd25..898d504ff5 100755
--- a/OpenSim/Tests/Common/Mock/TestClient.cs
+++ b/OpenSim/Tests/Common/Mock/TestClient.cs
@@ -981,16 +981,13 @@ namespace OpenSim.Tests.Common
public void SendAdminResponse(UUID Token, uint AdminLevel)
{
-
}
public void SendGroupMembership(GroupMembershipData[] GroupMembership)
{
-
}
- //public void SendSunPos(Vector3 sunPos, Vector3 sunVel, ulong time, uint dlen, uint ylen, float phase)
- public void SendSunPos(Vector3 sunPos, Vector3 sunVel, float sunAngle)
+ public void SendViewerTime(Vector3 sunDir, float sunphase)
{
}
@@ -998,10 +995,6 @@ namespace OpenSim.Tests.Common
{
}
- public void SendViewerTime(int phase)
- {
- }
-
public void SendAvatarProperties(UUID avatarID, string aboutText, string bornOn, Byte[] membershipType,
string flAbout, uint flags, UUID flImageID, UUID imageID, string profileURL,
UUID partnerID)