aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Api
diff options
context:
space:
mode:
authorUbitUmarov2012-06-12 05:21:49 +0100
committerUbitUmarov2012-06-12 05:21:49 +0100
commit8b5342f613d66ac9158231494471bcc81ce9189c (patch)
tree8ad1a618426aca9e8bd7f9cf5e74f72770d61540 /OpenSim/Region/ScriptEngine/Shared/Api
parent Moved auxiliar funtions of last commit from sop to lsl api since they are on... (diff)
downloadopensim-SC_OLD-8b5342f613d66ac9158231494471bcc81ce9189c.zip
opensim-SC_OLD-8b5342f613d66ac9158231494471bcc81ce9189c.tar.gz
opensim-SC_OLD-8b5342f613d66ac9158231494471bcc81ce9189c.tar.bz2
opensim-SC_OLD-8b5342f613d66ac9158231494471bcc81ce9189c.tar.xz
more changes to Get and Get primitiveparams: Let Get remove avatarheight adjust,add Get PRIM_LINK_TARGET handling, changed avatar Set positions code...
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs120
1 files changed, 94 insertions, 26 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 4f6803f..5760b36 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -7902,11 +7902,35 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7902 ScriptSleep(200); 7902 ScriptSleep(200);
7903 } 7903 }
7904 7904
7905 // vector up using libomv (c&p from sop )
7906 // vector up rotated by r
7907 private Vector3 Zrot(Quaternion r)
7908 {
7909 double x, y, z, m;
7910
7911 m = r.X * r.X + r.Y * r.Y + r.Z * r.Z + r.W * r.W;
7912 if (Math.Abs(1.0 - m) > 0.000001)
7913 {
7914 m = 1.0 / Math.Sqrt(m);
7915 r.X *= (float)m;
7916 r.Y *= (float)m;
7917 r.Z *= (float)m;
7918 r.W *= (float)m;
7919 }
7920
7921 x = 2 * (r.X * r.Z + r.Y * r.W);
7922 y = 2 * (-r.X * r.W + r.Y * r.Z);
7923 z = -r.X * r.X - r.Y * r.Y + r.Z * r.Z + r.W * r.W;
7924
7925 return new Vector3((float)x, (float)y, (float)z);
7926 }
7927
7905 protected void SetPrimParams(ScenePresence av, LSL_List rules) 7928 protected void SetPrimParams(ScenePresence av, LSL_List rules)
7906 { 7929 {
7907 //This is a special version of SetPrimParams to deal with avatars which are sat on the linkset. 7930 //This is a special version of SetPrimParams to deal with avatars which are sat on the linkset.
7908 7931
7909 int idx = 0; 7932 int idx = 0;
7933 SceneObjectPart sitpart = World.GetSceneObjectPart(av.ParentID); // betting this will be used
7910 7934
7911 while (idx < rules.Length) 7935 while (idx < rules.Length)
7912 { 7936 {
@@ -7916,13 +7940,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7916 7940
7917 switch (code) 7941 switch (code)
7918 { 7942 {
7943 // a avatar is a child
7919 case (int)ScriptBaseClass.PRIM_POSITION: 7944 case (int)ScriptBaseClass.PRIM_POSITION:
7945 case (int)ScriptBaseClass.PRIM_POS_LOCAL:
7920 { 7946 {
7921 if (remain < 1) 7947 if (remain < 1)
7922 return; 7948 return;
7923 LSL_Vector v; 7949 LSL_Vector v;
7924 v = rules.GetVector3Item(idx++); 7950 v = rules.GetVector3Item(idx++);
7925 7951
7952/* use the sitpart
7926 SceneObjectPart part = World.GetSceneObjectPart(av.ParentID); 7953 SceneObjectPart part = World.GetSceneObjectPart(av.ParentID);
7927 if (part == null) 7954 if (part == null)
7928 break; 7955 break;
@@ -7937,43 +7964,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7937 7964
7938 v -= localPos; 7965 v -= localPos;
7939 v /= localRot; 7966 v /= localRot;
7967*/
7968 if (sitpart == null)
7969 break;
7940 7970
7941 LSL_Vector sitOffset = (llRot2Up(new LSL_Rotation(av.Rotation.X, av.Rotation.Y, av.Rotation.Z, av.Rotation.W)) * av.Appearance.AvatarHeight * 0.02638f); 7971 Vector3 pos = new Vector3((float)v.x, (float)v.y, (float)v.z); // requested absolute position
7942
7943 v = v + 2 * sitOffset;
7944
7945 av.OffsetPosition = new Vector3((float)v.x, (float)v.y, (float)v.z);
7946 av.SendAvatarDataToAllAgents();
7947
7948 }
7949 break;
7950 7972
7951 case (int)ScriptBaseClass.PRIM_POS_LOCAL: 7973 pos -= sitpart.OffsetPosition; // remove sit part offset
7952 {
7953 if (remain < 1)
7954 return;
7955 LSL_Vector v;
7956 v = rules.GetVector3Item(idx++);
7957 7974
7958 SceneObjectPart part = World.GetSceneObjectPart(av.ParentID); 7975 Quaternion rot = sitpart.RotationOffset;
7959 if (part == null) 7976 pos *= Quaternion.Conjugate(rot); // removed sit part rotation
7960 break;
7961 7977
7962 LSL_Vector sitOffset = (llRot2Up(new LSL_Rotation(av.Rotation.X, av.Rotation.Y, av.Rotation.Z, av.Rotation.W)) * av.Appearance.AvatarHeight * 0.02638f); 7978 Vector3 sitOffset = (Zrot(av.Rotation)) * (av.Appearance.AvatarHeight * 0.02638f);
7963 7979
7964 v += 2 * sitOffset; 7980 pos += sitOffset;
7965 7981
7966 av.OffsetPosition = new Vector3((float)v.x, (float)v.y, (float)v.z); 7982 av.OffsetPosition = pos;
7967 av.SendAvatarDataToAllAgents(); 7983 av.SendAvatarDataToAllAgents();
7968
7969 } 7984 }
7970 break; 7985 break;
7971 7986
7987
7972 case (int)ScriptBaseClass.PRIM_ROTATION: 7988 case (int)ScriptBaseClass.PRIM_ROTATION:
7973 { 7989 {
7974 if (remain < 1) 7990 if (remain < 1)
7975 return; 7991 return;
7976 7992/*
7977 LSL_Rotation localRot = ScriptBaseClass.ZERO_ROTATION; 7993 LSL_Rotation localRot = ScriptBaseClass.ZERO_ROTATION;
7978 LSL_Vector localPos = ScriptBaseClass.ZERO_VECTOR; 7994 LSL_Vector localPos = ScriptBaseClass.ZERO_VECTOR;
7979 if (llGetLinkNumber() > 1) 7995 if (llGetLinkNumber() > 1)
@@ -7986,6 +8002,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7986 r = rules.GetQuaternionItem(idx++); 8002 r = rules.GetQuaternionItem(idx++);
7987 r = r * llGetRootRotation() / localRot; 8003 r = r * llGetRootRotation() / localRot;
7988 av.Rotation = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s); 8004 av.Rotation = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s);
8005 */
8006 if (sitpart == null)
8007 break;
8008
8009 LSL_Rotation r = rules.GetQuaternionItem(idx++);
8010 Quaternion rot = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s); // requested world rotation
8011
8012 Quaternion srot = sitpart.GetWorldRotation();
8013 rot *= Quaternion.Conjugate(srot); // removed sit part world rotation
8014
8015 av.Rotation = rot;
7989 av.SendAvatarDataToAllAgents(); 8016 av.SendAvatarDataToAllAgents();
7990 } 8017 }
7991 break; 8018 break;
@@ -7994,11 +8021,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7994 { 8021 {
7995 if (remain < 1) 8022 if (remain < 1)
7996 return; 8023 return;
7997 8024/*
7998 LSL_Rotation r; 8025 LSL_Rotation r;
7999 r = rules.GetQuaternionItem(idx++); 8026 r = rules.GetQuaternionItem(idx++);
8000 av.Rotation = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s); 8027 av.Rotation = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s);
8001 av.SendAvatarDataToAllAgents(); 8028 av.SendAvatarDataToAllAgents();
8029*/
8030 if (sitpart == null)
8031 break;
8032
8033 LSL_Rotation r = rules.GetQuaternionItem(idx++);
8034 Quaternion rot = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s); // requested offset rotation
8035
8036 Quaternion srot = sitpart.RotationOffset;
8037 rot *= Quaternion.Conjugate(srot); // remove sit part offset rotation
8038
8039 av.Rotation = rot;
8040 av.SendAvatarDataToAllAgents();
8002 } 8041 }
8003 break; 8042 break;
8004 8043
@@ -8914,7 +8953,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8914 // replies as SL wiki 8953 // replies as SL wiki
8915 8954
8916 LSL_List res = new LSL_List(); 8955 LSL_List res = new LSL_List();
8917 SceneObjectPart sitPart = avatar.ParentPart; // most likelly it will be needed 8956// SceneObjectPart sitPart = avatar.ParentPart; // most likelly it will be needed
8957 SceneObjectPart sitPart = World.GetSceneObjectPart(avatar.ParentID); // maybe better do this expensive search for it in case it's gone??
8958
8918 int idx = 0; 8959 int idx = 0;
8919 while (idx < rules.Length) 8960 while (idx < rules.Length)
8920 { 8961 {
@@ -8941,6 +8982,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8941 8982
8942 case (int)ScriptBaseClass.PRIM_POSITION: 8983 case (int)ScriptBaseClass.PRIM_POSITION:
8943 Vector3 pos = avatar.AbsolutePosition; 8984 Vector3 pos = avatar.AbsolutePosition;
8985 Vector3 sitOffset = (Zrot(avatar.Rotation)) * (avatar.Appearance.AvatarHeight * 0.02638f);
8986 pos -= sitOffset;
8944 res.Add(new LSL_Vector(pos.X,pos.Y,pos.Z)); 8987 res.Add(new LSL_Vector(pos.X,pos.Y,pos.Z));
8945 break; 8988 break;
8946 8989
@@ -9139,8 +9182,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9139 { 9182 {
9140 lpos = sitPart.OffsetPosition + (lpos * sitPart.RotationOffset); // make it relative to root prim 9183 lpos = sitPart.OffsetPosition + (lpos * sitPart.RotationOffset); // make it relative to root prim
9141 } 9184 }
9185 Vector3 lsitOffset = (Zrot(avatar.Rotation)) * (avatar.Appearance.AvatarHeight * 0.02638f);
9186 lpos -= lsitOffset;
9142 res.Add(new LSL_Vector(lpos.X,lpos.Y,lpos.Z)); 9187 res.Add(new LSL_Vector(lpos.X,lpos.Y,lpos.Z));
9143 break; 9188 break;
9189
9190 case (int)ScriptBaseClass.PRIM_LINK_TARGET:
9191 if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless.
9192 return res;
9193 LSL_Integer new_linknumber = rules.GetLSLIntegerItem(idx++);
9194 LSL_List new_rules = rules.GetSublist(idx, -1);
9195
9196 res += llGetLinkPrimitiveParams((int)new_linknumber, new_rules);
9197 return res;
9144 } 9198 }
9145 } 9199 }
9146 return res; 9200 return res;
@@ -9532,6 +9586,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9532 res.Add(new LSL_Float(primglow)); 9586 res.Add(new LSL_Float(primglow));
9533 } 9587 }
9534 break; 9588 break;
9589
9535 case (int)ScriptBaseClass.PRIM_TEXT: 9590 case (int)ScriptBaseClass.PRIM_TEXT:
9536 Color4 textColor = part.GetTextColor(); 9591 Color4 textColor = part.GetTextColor();
9537 res.Add(new LSL_String(part.Text)); 9592 res.Add(new LSL_String(part.Text));
@@ -9540,18 +9595,31 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9540 textColor.B)); 9595 textColor.B));
9541 res.Add(new LSL_Float(textColor.A)); 9596 res.Add(new LSL_Float(textColor.A));
9542 break; 9597 break;
9598
9543 case (int)ScriptBaseClass.PRIM_NAME: 9599 case (int)ScriptBaseClass.PRIM_NAME:
9544 res.Add(new LSL_String(part.Name)); 9600 res.Add(new LSL_String(part.Name));
9545 break; 9601 break;
9602
9546 case (int)ScriptBaseClass.PRIM_DESC: 9603 case (int)ScriptBaseClass.PRIM_DESC:
9547 res.Add(new LSL_String(part.Description)); 9604 res.Add(new LSL_String(part.Description));
9548 break; 9605 break;
9606
9549 case (int)ScriptBaseClass.PRIM_ROT_LOCAL: 9607 case (int)ScriptBaseClass.PRIM_ROT_LOCAL:
9550 res.Add(new LSL_Rotation(part.RotationOffset.X, part.RotationOffset.Y, part.RotationOffset.Z, part.RotationOffset.W)); 9608 res.Add(new LSL_Rotation(part.RotationOffset.X, part.RotationOffset.Y, part.RotationOffset.Z, part.RotationOffset.W));
9551 break; 9609 break;
9610
9552 case (int)ScriptBaseClass.PRIM_POS_LOCAL: 9611 case (int)ScriptBaseClass.PRIM_POS_LOCAL:
9553 res.Add(new LSL_Vector(GetPartLocalPos(part))); 9612 res.Add(new LSL_Vector(GetPartLocalPos(part)));
9554 break; 9613 break;
9614
9615 case (int)ScriptBaseClass.PRIM_LINK_TARGET:
9616 if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless.
9617 return res;
9618 LSL_Integer new_linknumber = rules.GetLSLIntegerItem(idx++);
9619 LSL_List new_rules = rules.GetSublist(idx, -1);
9620 LSL_List tres = llGetLinkPrimitiveParams((int)new_linknumber, new_rules);
9621 res += tres;
9622 return res;
9555 } 9623 }
9556 } 9624 }
9557 return res; 9625 return res;