diff options
author | Homer Horwitz | 2008-11-15 21:03:06 +0000 |
---|---|---|
committer | Homer Horwitz | 2008-11-15 21:03:06 +0000 |
commit | 448e4b0beb95822f0f97fbfc8578d866ce2d3edf (patch) | |
tree | cdd04af79c4d3c93b51c8e3be8cd5aa133f527c4 /OpenSim/Region | |
parent | Mantis#2552: Thanks idb, for a patch that fixes persistence of physical prims. (diff) | |
download | opensim-SC-448e4b0beb95822f0f97fbfc8578d866ce2d3edf.zip opensim-SC-448e4b0beb95822f0f97fbfc8578d866ce2d3edf.tar.gz opensim-SC-448e4b0beb95822f0f97fbfc8578d866ce2d3edf.tar.bz2 opensim-SC-448e4b0beb95822f0f97fbfc8578d866ce2d3edf.tar.xz |
- Change llSetRot behavior so it matches the SL behavior (in particular, the
rather strange behavior if used in a child prim).
- Small refactoring.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 52 |
1 files changed, 38 insertions, 14 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 4507583..0720f36 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -317,6 +317,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
317 | } | 317 | } |
318 | } | 318 | } |
319 | 319 | ||
320 | // convert a LSL_Rotation to a Quaternion | ||
321 | private Quaternion Rot2Quaternion(LSL_Rotation r) | ||
322 | { | ||
323 | return new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s); | ||
324 | } | ||
325 | |||
320 | //These are the implementations of the various ll-functions used by the LSL scripts. | 326 | //These are the implementations of the various ll-functions used by the LSL scripts. |
321 | public LSL_Float llSin(double f) | 327 | public LSL_Float llSin(double f) |
322 | { | 328 | { |
@@ -1791,14 +1797,39 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1791 | { | 1797 | { |
1792 | m_host.AddScriptLPS(1); | 1798 | m_host.AddScriptLPS(1); |
1793 | 1799 | ||
1794 | SetRot(m_host, rot); | 1800 | // try to let this work as in SL... |
1801 | if (m_host.ParentID == 0) | ||
1802 | { | ||
1803 | // special case: If we are root, rotate complete SOG to new rotation | ||
1804 | SetRot(m_host, Rot2Quaternion(rot)); | ||
1805 | } | ||
1806 | else | ||
1807 | { | ||
1808 | // we are a child. The rotation values will be set to the one of root modified by rot, as in SL. Don't ask. | ||
1809 | SceneObjectGroup group = m_host.ParentGroup; | ||
1810 | if (group != null) // a bit paranoid, maybe | ||
1811 | { | ||
1812 | SceneObjectPart rootPart = group.RootPart; | ||
1813 | if(rootPart != null) // again, better safe than sorry | ||
1814 | { | ||
1815 | SetRot(m_host, rootPart.RotationOffset * Rot2Quaternion(rot)); | ||
1816 | } | ||
1817 | } | ||
1818 | } | ||
1819 | |||
1820 | ScriptSleep(200); | ||
1821 | } | ||
1795 | 1822 | ||
1823 | public void llSetLocalRot(LSL_Rotation rot) | ||
1824 | { | ||
1825 | m_host.AddScriptLPS(1); | ||
1826 | SetRot(m_host, Rot2Quaternion(rot)); | ||
1796 | ScriptSleep(200); | 1827 | ScriptSleep(200); |
1797 | } | 1828 | } |
1798 | 1829 | ||
1799 | private void SetRot(SceneObjectPart part, LSL_Rotation rot) | 1830 | private void SetRot(SceneObjectPart part, Quaternion rot) |
1800 | { | 1831 | { |
1801 | part.UpdateRotation(new Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s)); | 1832 | part.UpdateRotation(rot); |
1802 | // Update rotation does not move the object in the physics scene if it's a linkset. | 1833 | // Update rotation does not move the object in the physics scene if it's a linkset. |
1803 | part.ParentGroup.AbsolutePosition = part.ParentGroup.AbsolutePosition; | 1834 | part.ParentGroup.AbsolutePosition = part.ParentGroup.AbsolutePosition; |
1804 | } | 1835 | } |
@@ -2414,7 +2445,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2414 | // need the magnitude later | 2445 | // need the magnitude later |
2415 | float velmag = (float)Util.GetMagnitude(llvel); | 2446 | float velmag = (float)Util.GetMagnitude(llvel); |
2416 | 2447 | ||
2417 | SceneObjectGroup new_group = World.RezObject(m_host, inv.Value, llpos, new Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s), llvel, param); | 2448 | SceneObjectGroup new_group = World.RezObject(m_host, inv.Value, llpos, Rot2Quaternion(rot), llvel, param); |
2418 | 2449 | ||
2419 | // If either of these are null, then there was an unknown error. | 2450 | // If either of these are null, then there was an unknown error. |
2420 | if (new_group == null) | 2451 | if (new_group == null) |
@@ -5484,7 +5515,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5484 | if (m_host.ParentGroup.RootPart != null) | 5515 | if (m_host.ParentGroup.RootPart != null) |
5485 | { | 5516 | { |
5486 | m_host.ParentGroup.RootPart.SetVehicleRotationParam(param, | 5517 | m_host.ParentGroup.RootPart.SetVehicleRotationParam(param, |
5487 | new Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s)); | 5518 | Rot2Quaternion(rot)); |
5488 | } | 5519 | } |
5489 | } | 5520 | } |
5490 | } | 5521 | } |
@@ -5509,7 +5540,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5509 | rot.z = 1; // ZERO_ROTATION = 0,0,0,1 | 5540 | rot.z = 1; // ZERO_ROTATION = 0,0,0,1 |
5510 | 5541 | ||
5511 | m_host.SitTargetPosition = new Vector3((float)offset.x, (float)offset.y, (float)offset.z); | 5542 | m_host.SitTargetPosition = new Vector3((float)offset.x, (float)offset.y, (float)offset.z); |
5512 | m_host.SitTargetOrientation = new Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s); | 5543 | m_host.SitTargetOrientation = Rot2Quaternion(rot); |
5513 | } | 5544 | } |
5514 | 5545 | ||
5515 | public LSL_String llAvatarOnSitTarget() | 5546 | public LSL_String llAvatarOnSitTarget() |
@@ -6104,7 +6135,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6104 | return; | 6135 | return; |
6105 | 6136 | ||
6106 | LSL_Rotation q = rules.GetQuaternionItem(idx++); | 6137 | LSL_Rotation q = rules.GetQuaternionItem(idx++); |
6107 | SetRot(part, q); | 6138 | SetRot(part, Rot2Quaternion(q)); |
6108 | 6139 | ||
6109 | break; | 6140 | break; |
6110 | 6141 | ||
@@ -7160,13 +7191,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7160 | return System.Environment.MachineName; | 7191 | return System.Environment.MachineName; |
7161 | } | 7192 | } |
7162 | 7193 | ||
7163 | public void llSetLocalRot(LSL_Rotation rot) | ||
7164 | { | ||
7165 | m_host.AddScriptLPS(1); | ||
7166 | m_host.RotationOffset = new Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s); | ||
7167 | // ScriptSleep(200); | ||
7168 | } | ||
7169 | |||
7170 | // <summary> | 7194 | // <summary> |
7171 | // Scan the string supplied in 'src' and | 7195 | // Scan the string supplied in 'src' and |
7172 | // tokenize it based upon two sets of | 7196 | // tokenize it based upon two sets of |