diff options
author | SignpostMarv | 2012-07-12 12:25:08 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2012-07-14 01:45:34 +0100 |
commit | 8d59385eeaa26feab8b19905ad6491065e4e4bf9 (patch) | |
tree | a29d2750d59a981e632f32058bee742da5395efc /OpenSim/Region | |
parent | When generating a Warp3D texture, set the detailTexture[i] variable on resize... (diff) | |
download | opensim-SC-8d59385eeaa26feab8b19905ad6491065e4e4bf9.zip opensim-SC-8d59385eeaa26feab8b19905ad6491065e4e4bf9.tar.gz opensim-SC-8d59385eeaa26feab8b19905ad6491065e4e4bf9.tar.bz2 opensim-SC-8d59385eeaa26feab8b19905ad6491065e4e4bf9.tar.xz |
Implementation of llSetRegionPos(). Does not implement failure on object entry/prim limit/access restrictions.
Signed-off-by: SignpostMarv <github@signpostmarv.name>
Diffstat (limited to 'OpenSim/Region')
3 files changed, 45 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; |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs index d39b204..3fb463b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs | |||
@@ -359,6 +359,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
359 | void llSetPrimitiveParams(LSL_List rules); | 359 | void llSetPrimitiveParams(LSL_List rules); |
360 | void llSetLinkPrimitiveParamsFast(int linknum, LSL_List rules); | 360 | void llSetLinkPrimitiveParamsFast(int linknum, LSL_List rules); |
361 | void llSetPrimURL(string url); | 361 | void llSetPrimURL(string url); |
362 | LSL_Integer llSetRegionPos(LSL_Vector pos); | ||
362 | void llSetRemoteScriptAccessPin(int pin); | 363 | void llSetRemoteScriptAccessPin(int pin); |
363 | void llSetRot(LSL_Rotation rot); | 364 | void llSetRot(LSL_Rotation rot); |
364 | void llSetScale(LSL_Vector scale); | 365 | void llSetScale(LSL_Vector scale); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs index a0b3bc8..c457880 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs | |||
@@ -1618,6 +1618,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
1618 | m_LSL_Functions.llSetPrimURL(url); | 1618 | m_LSL_Functions.llSetPrimURL(url); |
1619 | } | 1619 | } |
1620 | 1620 | ||
1621 | public LSL_Integer llSetRegionPos(LSL_Vector pos) | ||
1622 | { | ||
1623 | return m_LSL_Functions.llSetRegionPos(pos); | ||
1624 | } | ||
1625 | |||
1621 | public void llSetRemoteScriptAccessPin(int pin) | 1626 | public void llSetRemoteScriptAccessPin(int pin) |
1622 | { | 1627 | { |
1623 | m_LSL_Functions.llSetRemoteScriptAccessPin(pin); | 1628 | m_LSL_Functions.llSetRemoteScriptAccessPin(pin); |