From ddbf81fa07aac8098d9fa8d979969fffd5436f75 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Fri, 13 Mar 2009 23:45:02 +0000 Subject: Thank you, mcortez, for a patch that fixes a number of long standing issues with the sun module. Fixes Mantis #3295 --- .../Region/ClientStack/LindenUDP/LLClientView.cs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs') diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 95519bc..10e5c5a 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -87,6 +87,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP private int m_inPacketsChecked; + // Used to adjust Sun Orbit values so Linden based viewers properly position sun + private const float m_sunPainDaHalfOrbitalCutoff = 4.712388980384689858f; + + /* protected variables */ protected static Dictionary PacketHandlers = @@ -2403,10 +2407,26 @@ namespace OpenSim.Region.ClientStack.LindenUDP public void SendSunPos(Vector3 Position, Vector3 Velocity, ulong CurrentTime, uint SecondsPerSunCycle, uint SecondsPerYear, float OrbitalPosition) { + // Viewers based on the Linden viwer code, do wacky things for oribital positions from Midnight to Sunrise + // So adjust for that + // Contributed by: Godfrey + + if (OrbitalPosition > m_sunPainDaHalfOrbitalCutoff) // things get weird from midnight to sunrise + { + OrbitalPosition = (OrbitalPosition - m_sunPainDaHalfOrbitalCutoff) * 0.6666666667f + m_sunPainDaHalfOrbitalCutoff; + } + + + SimulatorViewerTimeMessagePacket viewertime = (SimulatorViewerTimeMessagePacket)PacketPool.Instance.GetPacket(PacketType.SimulatorViewerTimeMessage); viewertime.TimeInfo.SunDirection = Position; viewertime.TimeInfo.SunAngVelocity = Velocity; - viewertime.TimeInfo.UsecSinceStart = CurrentTime; + + // Sun module used to add 6 hours to adjust for linden sun hour, adding here + // to prevent existing code from breaking if it assumed that 6 hours were included. + // 21600 == 6 hours * 60 minutes * 60 Seconds + viewertime.TimeInfo.UsecSinceStart = CurrentTime + 21600; + viewertime.TimeInfo.SecPerDay = SecondsPerSunCycle; viewertime.TimeInfo.SecPerYear = SecondsPerYear; viewertime.TimeInfo.SunPhase = OrbitalPosition; -- cgit v1.1