aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorUbitUmarov2015-11-05 03:07:25 +0000
committerUbitUmarov2015-11-05 03:07:25 +0000
commitdc752e8d823f8a633c11942ac0d5998639bb2890 (patch)
tree5127f9e551294870a9fb18232067e824d9a0cd0b /OpenSim/Region
parentapply OtakuMegane code changes to irc channel chat so some characters are not... (diff)
downloadopensim-SC-dc752e8d823f8a633c11942ac0d5998639bb2890.zip
opensim-SC-dc752e8d823f8a633c11942ac0d5998639bb2890.tar.gz
opensim-SC-dc752e8d823f8a633c11942ac0d5998639bb2890.tar.bz2
opensim-SC-dc752e8d823f8a633c11942ac0d5998639bb2890.tar.xz
fix get/set parameters on avatars
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs77
1 files changed, 38 insertions, 39 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 33e34fb..34a72c9 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -10133,7 +10133,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10133 SceneObjectPart parentPart = sp.ParentPart; 10133 SceneObjectPart parentPart = sp.ParentPart;
10134 10134
10135 if (parentPart != null) 10135 if (parentPart != null)
10136 sp.Rotation = m_host.GetWorldRotation() * inRot; 10136 sp.Rotation = m_host.GetWorldRotation() * inRot;
10137 10137
10138 break; 10138 break;
10139 10139
@@ -13466,27 +13466,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
13466 case ScriptBaseClass.OBJECT_POS: 13466 case ScriptBaseClass.OBJECT_POS:
13467 Vector3 avpos; 13467 Vector3 avpos;
13468 13468
13469 if (av.ParentID != 0 && av.ParentPart != null) 13469 if (av.ParentID != 0 && av.ParentPart != null &&
13470 av.ParentPart.ParentGroup != null && av.ParentPart.ParentGroup.RootPart != null )
13470 { 13471 {
13471 avpos = av.OffsetPosition; 13472 avpos = av.OffsetPosition;
13472 13473
13473 Vector3 sitOffset = (Zrot(av.Rotation)) * (av.Appearance.AvatarHeight * 0.02638f *2.0f); 13474 Vector3 sitOffset = (Zrot(av.Rotation)) * (av.Appearance.AvatarHeight * 0.02638f *2.0f);
13474 avpos -= sitOffset; 13475 avpos -= sitOffset;
13475 13476 SceneObjectPart sitRoot = av.ParentPart.ParentGroup.RootPart;
13476 avpos = av.ParentPart.GetWorldPosition() + avpos * av.ParentPart.GetWorldRotation(); 13477 avpos = sitRoot.GetWorldPosition() + avpos * sitRoot.GetWorldRotation();
13477 } 13478 }
13478 else 13479 else
13479 avpos = av.AbsolutePosition; 13480 avpos = av.AbsolutePosition;
13480 13481
13481 ret.Add(new LSL_Vector((double)avpos.X, (double)avpos.Y, (double)avpos.Z)); 13482 ret.Add(new LSL_Vector((double)avpos.X, (double)avpos.Y, (double)avpos.Z));
13482 break; 13483 break;
13483 case ScriptBaseClass.OBJECT_ROT: 13484 case ScriptBaseClass.OBJECT_ROT:
13484 Quaternion avrot = av.Rotation; 13485 Quaternion avrot = av.GetWorldRotation();
13485 if (av.ParentID != 0 && av.ParentPart != null) 13486 ret.Add(new LSL_Rotation(avrot));
13486 {
13487 avrot = av.ParentPart.GetWorldRotation() * avrot;
13488 }
13489 ret.Add(new LSL_Rotation((double)avrot.X, (double)avrot.Y, (double)avrot.Z, (double)avrot.W));
13490 break; 13487 break;
13491 case ScriptBaseClass.OBJECT_VELOCITY: 13488 case ScriptBaseClass.OBJECT_VELOCITY:
13492 Vector3 avvel = av.GetWorldVelocity(); 13489 Vector3 avvel = av.GetWorldVelocity();
@@ -15695,14 +15692,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
15695 15692
15696 protected LSL_List SetPrimParams(ScenePresence av, LSL_List rules, string originFunc, ref uint rulesParsed) 15693 protected LSL_List SetPrimParams(ScenePresence av, LSL_List rules, string originFunc, ref uint rulesParsed)
15697 { 15694 {
15698 //This is a special version of SetPrimParams to deal with avatars which are sat on the linkset. 15695 //This is a special version of SetPrimParams to deal with avatars which are sitting on the linkset.
15699 15696
15700 int idx = 0; 15697 int idx = 0;
15701 int idxStart = 0; 15698 int idxStart = 0;
15702 15699
15703 bool positionChanged = false; 15700 bool positionChanged = false;
15704 Vector3 finalPos = Vector3.Zero;
15705
15706 try 15701 try
15707 { 15702 {
15708 while (idx < rules.Length) 15703 while (idx < rules.Length)
@@ -15729,13 +15724,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
15729 v = v + 2 * sitOffset; 15724 v = v + 2 * sitOffset;
15730 15725
15731 av.OffsetPosition = new Vector3((float)v.x, (float)v.y, (float)v.z); 15726 av.OffsetPosition = new Vector3((float)v.x, (float)v.y, (float)v.z);
15732 av.SendAvatarDataToAllAgents(); 15727 positionChanged = true;
15728 }
15729 break;
15730
15731 case (int)ScriptBaseClass.PRIM_ROTATION:
15732 {
15733 if (remain < 1)
15734 return new LSL_List();
15735
15736 Quaternion r;
15737 r = rules.GetQuaternionItem(idx++);
15733 15738
15739 av.Rotation = m_host.GetWorldRotation() * r;
15740 positionChanged = true;
15734 } 15741 }
15735 break; 15742 break;
15736 15743
15737 case (int)ScriptBaseClass.PRIM_ROT_LOCAL: 15744 case (int)ScriptBaseClass.PRIM_ROT_LOCAL:
15738 case (int)ScriptBaseClass.PRIM_ROTATION:
15739 { 15745 {
15740 if (remain < 1) 15746 if (remain < 1)
15741 return new LSL_List(); 15747 return new LSL_List();
@@ -15743,8 +15749,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
15743 LSL_Rotation r; 15749 LSL_Rotation r;
15744 r = rules.GetQuaternionItem(idx++); 15750 r = rules.GetQuaternionItem(idx++);
15745 15751
15746 av.Rotation = r * llGetRootRotation(); 15752 av.Rotation = r;
15747 av.SendAvatarDataToAllAgents(); 15753 positionChanged = true;
15748 } 15754 }
15749 break; 15755 break;
15750 15756
@@ -15848,12 +15854,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
15848 finally 15854 finally
15849 { 15855 {
15850 if (positionChanged) 15856 if (positionChanged)
15851 {
15852 av.OffsetPosition = finalPos;
15853// av.SendAvatarDataToAllAgents();
15854 av.SendTerseUpdateToAllClients(); 15857 av.SendTerseUpdateToAllClients();
15855 positionChanged = false;
15856 }
15857 } 15858 }
15858 return new LSL_List(); 15859 return new LSL_List();
15859 } 15860 }
@@ -15891,11 +15892,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
15891 break; 15892 break;
15892 15893
15893 case (int)ScriptBaseClass.PRIM_POSITION: 15894 case (int)ScriptBaseClass.PRIM_POSITION:
15895 Vector3 pos;
15894 15896
15895 Vector3 pos = avatar.OffsetPosition; 15897 if (sitPart.ParentGroup.RootPart != null)
15898 {
15899 pos = avatar.OffsetPosition;
15896 15900
15897 Vector3 sitOffset = (Zrot(avatar.Rotation)) * (avatar.Appearance.AvatarHeight * 0.02638f *2.0f); 15901 Vector3 sitOffset = (Zrot(avatar.Rotation)) * (avatar.Appearance.AvatarHeight * 0.02638f *2.0f);
15898 pos -= sitOffset; 15902 pos -= sitOffset;
15903
15904 SceneObjectPart sitroot = sitPart.ParentGroup.RootPart;
15905 pos = sitroot.AbsolutePosition + pos * sitroot.GetWorldRotation();
15906 }
15907 else
15908 pos = avatar.AbsolutePosition;
15899 15909
15900 res.Add(new LSL_Vector(pos.X,pos.Y,pos.Z)); 15910 res.Add(new LSL_Vector(pos.X,pos.Y,pos.Z));
15901 break; 15911 break;
@@ -15907,9 +15917,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
15907 break; 15917 break;
15908 15918
15909 case (int)ScriptBaseClass.PRIM_ROTATION: 15919 case (int)ScriptBaseClass.PRIM_ROTATION:
15910 LSL_Rotation rot = new LSL_Rotation(avatar.Rotation.X, avatar.Rotation.Y, avatar.Rotation.Z, avatar.Rotation.W) / llGetRootRotation(); 15920 res.Add(new LSL_Rotation(avatar.GetWorldRotation()));
15911
15912 res.Add(rot);
15913 break; 15921 break;
15914 15922
15915 case (int)ScriptBaseClass.PRIM_TYPE: 15923 case (int)ScriptBaseClass.PRIM_TYPE:
@@ -16079,23 +16087,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
16079 16087
16080 case (int)ScriptBaseClass.PRIM_ROT_LOCAL: 16088 case (int)ScriptBaseClass.PRIM_ROT_LOCAL:
16081 Quaternion lrot = avatar.Rotation; 16089 Quaternion lrot = avatar.Rotation;
16082
16083 if (sitPart != null && sitPart != sitPart.ParentGroup.RootPart)
16084 {
16085 lrot = sitPart.RotationOffset * lrot; // apply sit part rotation offset
16086 }
16087 res.Add(new LSL_Rotation(lrot.X, lrot.Y, lrot.Z, lrot.W)); 16090 res.Add(new LSL_Rotation(lrot.X, lrot.Y, lrot.Z, lrot.W));
16088 break; 16091 break;
16089 16092
16090 case (int)ScriptBaseClass.PRIM_POS_LOCAL: 16093 case (int)ScriptBaseClass.PRIM_POS_LOCAL:
16091 Vector3 lpos = avatar.OffsetPosition; // pos relative to sit part 16094 Vector3 lpos = avatar.OffsetPosition;
16092 Vector3 lsitOffset = (Zrot(avatar.Rotation)) * (avatar.Appearance.AvatarHeight * 0.02638f * 2.0f); 16095 Vector3 lsitOffset = (Zrot(avatar.Rotation)) * (avatar.Appearance.AvatarHeight * 0.02638f * 2.0f);
16093 lpos -= lsitOffset; 16096 lpos -= lsitOffset;
16094 16097
16095 if (sitPart != null && sitPart != sitPart.ParentGroup.RootPart)
16096 {
16097 lpos = sitPart.OffsetPosition + (lpos * sitPart.RotationOffset); // make it relative to root prim
16098 }
16099 res.Add(new LSL_Vector(lpos.X,lpos.Y,lpos.Z)); 16098 res.Add(new LSL_Vector(lpos.X,lpos.Y,lpos.Z));
16100 break; 16099 break;
16101 16100