diff options
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 24 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 60 |
2 files changed, 68 insertions, 16 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 283de39..ec8716b 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -91,7 +91,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
91 | /// rotation, prim cut, prim twist, prim taper, and prim shear. See mantis | 91 | /// rotation, prim cut, prim twist, prim taper, and prim shear. See mantis |
92 | /// issue #1716 | 92 | /// issue #1716 |
93 | /// </summary> | 93 | /// </summary> |
94 | public static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.0f, 0.0f, 0.418f); | 94 | public static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.0f, 0.0f, 0.4f); |
95 | 95 | ||
96 | /// <summary> | 96 | /// <summary> |
97 | /// Movement updates for agents in neighboring regions are sent directly to clients. | 97 | /// Movement updates for agents in neighboring regions are sent directly to clients. |
@@ -2301,7 +2301,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
2301 | 2301 | ||
2302 | //Quaternion result = (sitTargetOrient * vq) * nq; | 2302 | //Quaternion result = (sitTargetOrient * vq) * nq; |
2303 | 2303 | ||
2304 | m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT; | 2304 | double x, y, z, m; |
2305 | |||
2306 | Quaternion r = sitTargetOrient; | ||
2307 | m = r.X * r.X + r.Y * r.Y + r.Z * r.Z + r.W * r.W; | ||
2308 | |||
2309 | if (Math.Abs(1.0 - m) > 0.000001) | ||
2310 | { | ||
2311 | m = 1.0 / Math.Sqrt(m); | ||
2312 | r.X *= (float)m; | ||
2313 | r.Y *= (float)m; | ||
2314 | r.Z *= (float)m; | ||
2315 | r.W *= (float)m; | ||
2316 | } | ||
2317 | |||
2318 | x = 2 * (r.X * r.Z + r.Y * r.W); | ||
2319 | y = 2 * (-r.X * r.W + r.Y * r.Z); | ||
2320 | z = -r.X * r.X - r.Y * r.Y + r.Z * r.Z + r.W * r.W; | ||
2321 | |||
2322 | Vector3 up = new Vector3((float)x, (float)y, (float)z); | ||
2323 | Vector3 sitOffset = up * Appearance.AvatarHeight * 0.02638f; | ||
2324 | m_pos = sitTargetPos + sitOffset + SIT_TARGET_ADJUSTMENT; | ||
2305 | Rotation = sitTargetOrient; | 2325 | Rotation = sitTargetOrient; |
2306 | ParentPosition = part.AbsolutePosition; | 2326 | ParentPosition = part.AbsolutePosition; |
2307 | part.ParentGroup.AddAvatar(UUID); | 2327 | part.ParentGroup.AddAvatar(UUID); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 2a23c59..84792c0 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -7542,27 +7542,59 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7542 | 7542 | ||
7543 | int remain = rules.Length - idx; | 7543 | int remain = rules.Length - idx; |
7544 | 7544 | ||
7545 | |||
7546 | |||
7547 | switch (code) | 7545 | switch (code) |
7548 | { | 7546 | { |
7549 | case (int)ScriptBaseClass.PRIM_POSITION: | 7547 | case (int)ScriptBaseClass.PRIM_POSITION: |
7550 | if (remain < 1) | 7548 | { |
7551 | return; | 7549 | if (remain < 1) |
7552 | LSL_Vector v; | 7550 | return; |
7553 | v = rules.GetVector3Item(idx++); | 7551 | LSL_Vector v; |
7554 | av.OffsetPosition = new Vector3((float)v.x, (float)v.y, (float)v.z); | 7552 | v = rules.GetVector3Item(idx++); |
7555 | av.SendAvatarDataToAllAgents(); | 7553 | |
7554 | SceneObjectPart part = World.GetSceneObjectPart(av.ParentID); | ||
7555 | if (part == null) | ||
7556 | break; | ||
7557 | |||
7558 | LSL_Rotation localRot = ScriptBaseClass.ZERO_ROTATION; | ||
7559 | LSL_Vector localPos = ScriptBaseClass.ZERO_VECTOR; | ||
7560 | if (llGetLinkNumber() > 1) | ||
7561 | { | ||
7562 | localRot = llGetLocalRot(); | ||
7563 | localPos = llGetLocalPos(); | ||
7564 | } | ||
7565 | |||
7566 | v -= localPos; | ||
7567 | v /= localRot; | ||
7556 | 7568 | ||
7569 | LSL_Vector sitOffset = (llRot2Up(new LSL_Rotation(av.Rotation.X, av.Rotation.Y, av.Rotation.Z, av.Rotation.W)) * av.Appearance.AvatarHeight * 0.02638f); | ||
7570 | |||
7571 | v = v + 2 * sitOffset; | ||
7572 | |||
7573 | av.OffsetPosition = new Vector3((float)v.x, (float)v.y, (float)v.z); | ||
7574 | av.SendAvatarDataToAllAgents(); | ||
7575 | |||
7576 | } | ||
7557 | break; | 7577 | break; |
7558 | 7578 | ||
7559 | case (int)ScriptBaseClass.PRIM_ROTATION: | 7579 | case (int)ScriptBaseClass.PRIM_ROTATION: |
7560 | if (remain < 1) | 7580 | { |
7561 | return; | 7581 | if (remain < 1) |
7562 | LSL_Rotation r; | 7582 | return; |
7563 | r = rules.GetQuaternionItem(idx++); | 7583 | |
7564 | av.Rotation = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s); | 7584 | LSL_Rotation localRot = ScriptBaseClass.ZERO_ROTATION; |
7565 | av.SendAvatarDataToAllAgents(); | 7585 | LSL_Vector localPos = ScriptBaseClass.ZERO_VECTOR; |
7586 | if (llGetLinkNumber() > 1) | ||
7587 | { | ||
7588 | localRot = llGetLocalRot(); | ||
7589 | localPos = llGetLocalPos(); | ||
7590 | } | ||
7591 | |||
7592 | LSL_Rotation r; | ||
7593 | r = rules.GetQuaternionItem(idx++); | ||
7594 | r = r * llGetRootRotation() / localRot; | ||
7595 | av.Rotation = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s); | ||
7596 | av.SendAvatarDataToAllAgents(); | ||
7597 | } | ||
7566 | break; | 7598 | break; |
7567 | } | 7599 | } |
7568 | } | 7600 | } |