diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 43 |
1 files changed, 39 insertions, 4 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 0ebcd8d..b209e23 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -1917,11 +1917,40 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1917 | { | 1917 | { |
1918 | m_host.AddScriptLPS(1); | 1918 | m_host.AddScriptLPS(1); |
1919 | 1919 | ||
1920 | SetPos(m_host, pos); | 1920 | SetPos(m_host, pos, true); |
1921 | 1921 | ||
1922 | ScriptSleep(200); | 1922 | ScriptSleep(200); |
1923 | } | 1923 | } |
1924 | 1924 | ||
1925 | /// <summary> | ||
1926 | /// Tries to move the entire object so that the root prim is within 0.1m of position. http://wiki.secondlife.com/wiki/LlSetRegionPos | ||
1927 | /// Documentation indicates that the use of x/y coordinates up to 10 meters outside the bounds of a region will work but do not specify what happens if there is no adjacent region for the object to move into. | ||
1928 | /// Uses the RegionSize constant here rather than hard-coding 266.0 to alert any developer modifying OpenSim to support variable-sized regions that this method will need tweaking. | ||
1929 | /// </summary> | ||
1930 | /// <param name="pos"></param> | ||
1931 | /// <returns>1 if successful, 0 otherwise.</returns> | ||
1932 | public LSL_Integer llSetRegionPos(LSL_Vector pos) | ||
1933 | { | ||
1934 | m_host.AddScriptLPS(1); | ||
1935 | if ( | ||
1936 | llGetStatus((int)PrimFlags.Physics) == 1 || // return FALSE if physical. | ||
1937 | m_host.ParentGroup.IsAttachment || // return FALSE if attachment | ||
1938 | ( | ||
1939 | pos.x < -10.0 || // return FALSE if more than 10 meters into a west-adjacent region. | ||
1940 | pos.x > (Constants.RegionSize + 10) || // return FALSE if more than 10 meters into a east-adjacent region. | ||
1941 | pos.y < -10.0 || // return FALSE if more than 10 meters into a south-adjacent region. | ||
1942 | pos.y > (Constants.RegionSize + 10) || // return FALSE if more than 10 meters into a north-adjacent region. | ||
1943 | pos.z > 4096 // return FALSE if altitude than 4096m | ||
1944 | ) | ||
1945 | ){ | ||
1946 | return 0; | ||
1947 | } | ||
1948 | |||
1949 | SetPos(m_host.ParentGroup.RootPart, pos, false); | ||
1950 | |||
1951 | return llVecDist(pos, llGetRootPosition()) <= 0.1 ? 1 : 0; | ||
1952 | } | ||
1953 | |||
1925 | // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos) | 1954 | // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos) |
1926 | // note linked setpos is capped "differently" | 1955 | // note linked setpos is capped "differently" |
1927 | private LSL_Vector SetPosAdjust(LSL_Vector start, LSL_Vector end) | 1956 | private LSL_Vector SetPosAdjust(LSL_Vector start, LSL_Vector end) |
@@ -1953,7 +1982,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1953 | return real_vec; | 1982 | return real_vec; |
1954 | } | 1983 | } |
1955 | 1984 | ||
1956 | protected void SetPos(SceneObjectPart part, LSL_Vector targetPos) | 1985 | /// <summary> |
1986 | /// set object position, optionally capping the distance. | ||
1987 | /// </summary> | ||
1988 | /// <param name="part"></param> | ||
1989 | /// <param name="targetPos"></param> | ||
1990 | /// <param name="adjust">if TRUE, will cap the distance to 10m.</param> | ||
1991 | protected void SetPos(SceneObjectPart part, LSL_Vector targetPos, bool adjust) | ||
1957 | { | 1992 | { |
1958 | // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos) | 1993 | // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos) |
1959 | LSL_Vector currentPos = GetPartLocalPos(part); | 1994 | LSL_Vector currentPos = GetPartLocalPos(part); |
@@ -1966,12 +2001,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1966 | if ((targetPos.z < ground) && disable_underground_movement && m_host.ParentGroup.AttachmentPoint == 0) | 2001 | if ((targetPos.z < ground) && disable_underground_movement && m_host.ParentGroup.AttachmentPoint == 0) |
1967 | targetPos.z = ground; | 2002 | targetPos.z = ground; |
1968 | SceneObjectGroup parent = part.ParentGroup; | 2003 | SceneObjectGroup parent = part.ParentGroup; |
1969 | LSL_Vector real_vec = SetPosAdjust(currentPos, targetPos); | 2004 | LSL_Vector real_vec = !adjust ? targetPos : SetPosAdjust(currentPos, targetPos); |
1970 | parent.UpdateGroupPosition(new Vector3((float)real_vec.x, (float)real_vec.y, (float)real_vec.z)); | 2005 | parent.UpdateGroupPosition(new Vector3((float)real_vec.x, (float)real_vec.y, (float)real_vec.z)); |
1971 | } | 2006 | } |
1972 | else | 2007 | else |
1973 | { | 2008 | { |
1974 | LSL_Vector rel_vec = SetPosAdjust(currentPos, targetPos); | 2009 | LSL_Vector rel_vec = !adjust ? targetPos : SetPosAdjust(currentPos, targetPos); |
1975 | part.OffsetPosition = new Vector3((float)rel_vec.x, (float)rel_vec.y, (float)rel_vec.z); | 2010 | part.OffsetPosition = new Vector3((float)rel_vec.x, (float)rel_vec.y, (float)rel_vec.z); |
1976 | SceneObjectGroup parent = part.ParentGroup; | 2011 | SceneObjectGroup parent = part.ParentGroup; |
1977 | parent.HasGroupChanged = true; | 2012 | parent.HasGroupChanged = true; |