Browse Source

* Added helper method to the Sun module to Get the Linden hour based on the math in the sun module. This populates the sun phase slider on the terrain tab in the estate tools according to the current sun phase. Display purposes only for now. Need to go the other way for setting the sun phase based on the linden hour in the estate tools.

Teravus Ovares 16 years ago
parent
commit
d2aa2be788

+ 3 - 1
OpenSim/Framework/EstateSettings.cs

@@ -199,7 +199,9 @@ namespace OpenSim.Framework
             set
             {
                 m_sunHour = value;
-                configMember.forceSetConfigurationOption("sun_hour", m_sunHour.ToString());
+
+                if (useFixedSun)
+                    configMember.forceSetConfigurationOption("sun_hour", m_sunHour.ToString());
             }
         }
 

+ 2 - 1
OpenSim/Region/Environment/Modules/World/Estate/EstateManagementModule.cs

@@ -183,7 +183,8 @@ namespace OpenSim.Region.Environment.Modules.World.Estate
             // Time of day / fixed sun
             m_scene.RegionInfo.EstateSettings.useFixedSun = UseFixedSun;
             m_scene.RegionInfo.EstateSettings.sunHour = SunHour;
-
+            //m_log.Debug("[ESTATE]: UFS: " + UseFixedSun.ToString());
+            //m_log.Debug("[ESTATE]: SunHour: " + SunHour.ToString());
             sendRegionInfoPacketToAll();
         }
 

+ 16 - 0
OpenSim/Region/Environment/Modules/World/Sun/SunModule.cs

@@ -94,6 +94,9 @@ namespace OpenSim.Region.Environment.Modules
         private LLVector3 Position = new LLVector3(0,0,0);
         private LLVector3 Velocity = new LLVector3(0,0,0);
         private LLQuaternion  Tilt = new LLQuaternion(1,0,0,0);
+        private float LindenEstateHour = 6f;
+        private bool sunFixed = false;
+        private long estateTicksOffset = 0;
 
         private Dictionary<LLUUID, ulong> m_rootAgents = new Dictionary<LLUUID, ulong>();
 
@@ -101,9 +104,21 @@ namespace OpenSim.Region.Environment.Modules
         private ulong CurrentTime
         {
             get {
+                
                 return (ulong)(((System.DateTime.Now.Ticks) - TicksToEpoch + TicksOffset)/10000000);
             }
         }
+        private float GetLindenEstateHourFromCurrentTime()
+        {
+            float ticksleftover = ((float)((ulong)(((System.DateTime.Now.Ticks) - TicksToEpoch + TicksOffset) / 10000000))) % ((float)SecondsPerSunCycle);
+            //m_log.Debug("[TICKS]: " + ticksleftover.ToString());
+            float hour = (24 * (ticksleftover / SecondsPerSunCycle)) + 6;
+            //m_log.Debug("[LINDENHOUR]: " + hour.ToString());
+            //m_log.Debug("[SunCycle]: " + (ticksleftover / 3600));
+            //m_log.Debug("[DayLength]: " + m_day_length.ToString());
+
+            return hour;
+        }
 
         // Called immediately after the module is loaded for a given region
         // i.e. Immediately after instance creation.
@@ -256,6 +271,7 @@ namespace OpenSim.Region.Environment.Modules
 
             // set estate settings for region access to sun position
             m_scene.RegionInfo.EstateSettings.sunPosition = Position;
+            m_scene.RegionInfo.EstateSettings.sunHour = GetLindenEstateHourFromCurrentTime();
         }
 
         /// <summary>