diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 83 |
1 files changed, 35 insertions, 48 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index a43a8bb..6ec3081 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -2450,8 +2450,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2450 | 2450 | ||
2451 | public LSL_Rotation llGetLocalRot() | 2451 | public LSL_Rotation llGetLocalRot() |
2452 | { | 2452 | { |
2453 | return GetPartLocalRot(m_host); | ||
2454 | } | ||
2455 | |||
2456 | private LSL_Rotation GetPartLocalRot(SceneObjectPart part) | ||
2457 | { | ||
2453 | m_host.AddScriptLPS(1); | 2458 | m_host.AddScriptLPS(1); |
2454 | Quaternion rot = m_host.RotationOffset; | 2459 | Quaternion rot = part.RotationOffset; |
2455 | return new LSL_Rotation(rot.X, rot.Y, rot.Z, rot.W); | 2460 | return new LSL_Rotation(rot.X, rot.Y, rot.Z, rot.W); |
2456 | } | 2461 | } |
2457 | 2462 | ||
@@ -3708,7 +3713,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3708 | 3713 | ||
3709 | protected void TargetOmega(SceneObjectPart part, LSL_Vector axis, double spinrate, double gain) | 3714 | protected void TargetOmega(SceneObjectPart part, LSL_Vector axis, double spinrate, double gain) |
3710 | { | 3715 | { |
3711 | spinrate *= gain; | ||
3712 | part.UpdateAngularVelocity(new Vector3((float)(axis.x * spinrate), (float)(axis.y * spinrate), (float)(axis.z * spinrate))); | 3716 | part.UpdateAngularVelocity(new Vector3((float)(axis.x * spinrate), (float)(axis.y * spinrate), (float)(axis.z * spinrate))); |
3713 | } | 3717 | } |
3714 | 3718 | ||
@@ -7761,7 +7765,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7761 | //This is a special version of SetPrimParams to deal with avatars which are sat on the linkset. | 7765 | //This is a special version of SetPrimParams to deal with avatars which are sat on the linkset. |
7762 | 7766 | ||
7763 | int idx = 0; | 7767 | int idx = 0; |
7764 | SceneObjectPart sitpart = World.GetSceneObjectPart(av.ParentID); // betting this will be used | ||
7765 | 7768 | ||
7766 | bool positionChanged = false; | 7769 | bool positionChanged = false; |
7767 | Vector3 finalPos = Vector3.Zero; | 7770 | Vector3 finalPos = Vector3.Zero; |
@@ -7776,78 +7779,62 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7776 | 7779 | ||
7777 | switch (code) | 7780 | switch (code) |
7778 | { | 7781 | { |
7779 | // a avatar is a child | ||
7780 | case (int)ScriptBaseClass.PRIM_POSITION: | 7782 | case (int)ScriptBaseClass.PRIM_POSITION: |
7781 | case (int)ScriptBaseClass.PRIM_POS_LOCAL: | 7783 | case (int)ScriptBaseClass.PRIM_POS_LOCAL: |
7782 | { | 7784 | { |
7783 | if (remain < 1) | 7785 | if (remain < 1) |
7784 | return; | 7786 | return; |
7787 | |||
7785 | LSL_Vector v; | 7788 | LSL_Vector v; |
7786 | v = rules.GetVector3Item(idx++); | 7789 | v = rules.GetVector3Item(idx++); |
7787 | 7790 | ||
7788 | if (sitpart == null) | 7791 | SceneObjectPart part = World.GetSceneObjectPart(av.ParentID); |
7792 | if (part == null) | ||
7789 | break; | 7793 | break; |
7790 | 7794 | ||
7791 | Vector3 pos = new Vector3((float)v.x, (float)v.y, (float)v.z); // requested absolute position | 7795 | LSL_Rotation localRot = ScriptBaseClass.ZERO_ROTATION; |
7792 | 7796 | LSL_Vector localPos = ScriptBaseClass.ZERO_VECTOR; | |
7793 | if (sitpart != sitpart.ParentGroup.RootPart) | 7797 | if (part.LinkNum > 1) |
7794 | { | 7798 | { |
7795 | pos -= sitpart.OffsetPosition; // remove sit part offset | 7799 | localRot = GetPartLocalRot(part); |
7796 | Quaternion rot = sitpart.RotationOffset; | 7800 | localPos = GetPartLocalPos(part); |
7797 | pos *= Quaternion.Conjugate(rot); // removed sit part rotation | ||
7798 | } | 7801 | } |
7799 | Vector3 sitOffset = (Zrot(av.Rotation)) * (av.Appearance.AvatarHeight * 0.02638f * 2.0f); | ||
7800 | pos += sitOffset; | ||
7801 | 7802 | ||
7802 | finalPos = pos; | 7803 | v -= localPos; |
7803 | positionChanged = true; | 7804 | v /= localRot; |
7804 | } | ||
7805 | break; | ||
7806 | 7805 | ||
7807 | case (int)ScriptBaseClass.PRIM_ROTATION: | 7806 | LSL_Vector sitOffset = (llRot2Up(new LSL_Rotation(av.Rotation.X, av.Rotation.Y, av.Rotation.Z, av.Rotation.W)) * av.Appearance.AvatarHeight * 0.02638f); |
7808 | { | ||
7809 | if (remain < 1) | ||
7810 | return; | ||
7811 | 7807 | ||
7812 | if (sitpart == null) | 7808 | v = v + 2 * sitOffset; |
7813 | break; | ||
7814 | 7809 | ||
7815 | LSL_Rotation r = rules.GetQuaternionItem(idx++); | 7810 | av.OffsetPosition = new Vector3((float)v.x, (float)v.y, (float)v.z); |
7816 | Quaternion rot = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s); // requested world rotation | 7811 | av.SendAvatarDataToAllAgents(); |
7817 | 7812 | ||
7818 | // need to replicate SL bug | ||
7819 | SceneObjectGroup sitgrp = sitpart.ParentGroup; | ||
7820 | if (sitgrp != null && sitgrp.RootPart != sitpart) | ||
7821 | { | ||
7822 | rot = sitgrp.RootPart.RotationOffset * rot; | ||
7823 | } | ||
7824 | |||
7825 | Quaternion srot = sitpart.RotationOffset; | ||
7826 | rot = Quaternion.Conjugate(srot) * rot; // removed sit part offset rotation | ||
7827 | av.Rotation = rot; | ||
7828 | // av.SendAvatarDataToAllAgents(); | ||
7829 | av.SendTerseUpdateToAllClients(); | ||
7830 | } | 7813 | } |
7831 | break; | 7814 | break; |
7832 | 7815 | ||
7833 | case (int)ScriptBaseClass.PRIM_ROT_LOCAL: | 7816 | case (int)ScriptBaseClass.PRIM_ROT_LOCAL: |
7817 | case (int)ScriptBaseClass.PRIM_ROTATION: | ||
7834 | { | 7818 | { |
7835 | if (remain < 1) | 7819 | if (remain < 1) |
7836 | return; | 7820 | return; |
7837 | 7821 | ||
7838 | if (sitpart == null) | 7822 | LSL_Rotation r; |
7823 | r = rules.GetQuaternionItem(idx++); | ||
7824 | |||
7825 | SceneObjectPart part = World.GetSceneObjectPart(av.ParentID); | ||
7826 | if (part == null) | ||
7839 | break; | 7827 | break; |
7840 | 7828 | ||
7841 | LSL_Rotation r = rules.GetQuaternionItem(idx++); | 7829 | LSL_Rotation localRot = ScriptBaseClass.ZERO_ROTATION; |
7842 | Quaternion rot = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s); // requested offset rotation | 7830 | LSL_Vector localPos = ScriptBaseClass.ZERO_VECTOR; |
7843 | if (sitpart != sitpart.ParentGroup.RootPart) | 7831 | |
7844 | { | 7832 | if (part.LinkNum > 1) |
7845 | Quaternion srot = sitpart.RotationOffset; | 7833 | localRot = GetPartLocalRot(part); |
7846 | rot = Quaternion.Conjugate(srot) * rot; // remove sit part offset rotation | 7834 | |
7847 | } | 7835 | r = r * llGetRootRotation() / localRot; |
7848 | av.Rotation = rot; | 7836 | av.Rotation = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s); |
7849 | // av.SendAvatarDataToAllAgents(); | 7837 | av.SendAvatarDataToAllAgents(); |
7850 | av.SendTerseUpdateToAllClients(); | ||
7851 | } | 7838 | } |
7852 | break; | 7839 | break; |
7853 | 7840 | ||