From 6efb16689aa2ca364f738342a1173c27fef54b86 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Wed, 23 Apr 2008 10:16:26 +0000 Subject: [PATCH] From: Kurt Taylor Attached is a patch for adding the llGetSunDirection functionality. It was implemented by adding a parameter to estate settings for storing the sun position. The sun position is calculated and stored via the sun module everytime the client's sun position is updated. It was tested with several different srcipts on Linux and Windows --- OpenSim/Framework/EstateSettings.cs | 12 ++++++++++++ OpenSim/Region/Environment/Modules/SunModule.cs | 3 +++ .../ScriptEngine/Common/LSL_BuiltIn_Commands.cs | 14 ++++++++++++-- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/OpenSim/Framework/EstateSettings.cs b/OpenSim/Framework/EstateSettings.cs index 98052fcd0c..efb55fe8f7 100644 --- a/OpenSim/Framework/EstateSettings.cs +++ b/OpenSim/Framework/EstateSettings.cs @@ -159,6 +159,18 @@ namespace OpenSim.Framework } } + private LLVector3 m_sunPosition; + + public LLVector3 sunPosition + { + get { return m_sunPosition; } + set + { + //Just set - does not need to be written to settings file + m_sunPosition = value; + } + } + private float m_terrainRaiseLimit; public float terrainRaiseLimit diff --git a/OpenSim/Region/Environment/Modules/SunModule.cs b/OpenSim/Region/Environment/Modules/SunModule.cs index 37519ede1c..e6801e8cd3 100644 --- a/OpenSim/Region/Environment/Modules/SunModule.cs +++ b/OpenSim/Region/Environment/Modules/SunModule.cs @@ -108,6 +108,9 @@ namespace OpenSim.Region.Environment.Modules { avatar.ControllingClient.SendSunPos(SunPos(HourOfTheDay()), new LLVector3(0, 0.0f, 10.0f)); } + // set estate settings for region access to sun position + m_scene.RegionInfo.EstateSettings.sunPosition = SunPos(HourOfTheDay()); + m_frame = 0; } diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs index 41c395691c..f4a3bd37dd 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs @@ -2444,8 +2444,18 @@ namespace OpenSim.Region.ScriptEngine.Common public LSL_Types.Vector3 llGetSunDirection() { m_host.AddScriptLPS(1); - NotImplemented("llGetSunDirection"); - return new LSL_Types.Vector3(); + + LSL_Types.Vector3 SunDoubleVector3; + LLVector3 SunFloatVector3; + + // sunPosition estate setting is set in OpenSim.Region.Environment.Modules.SunModule + // have to convert from LLVector3 (float) to LSL_Types.Vector3 (double) + SunFloatVector3 = World.RegionInfo.EstateSettings.sunPosition; + SunDoubleVector3.x = (double)SunFloatVector3.X; + SunDoubleVector3.y = (double)SunFloatVector3.Y; + SunDoubleVector3.z = (double)SunFloatVector3.Z; + + return SunDoubleVector3; } public LSL_Types.Vector3 llGetTextureOffset(int face)