diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 99 |
1 files changed, 69 insertions, 30 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index ce6110a..4e5fee1 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -89,7 +89,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
89 | /// rotation, prim cut, prim twist, prim taper, and prim shear. See mantis | 89 | /// rotation, prim cut, prim twist, prim taper, and prim shear. See mantis |
90 | /// issue #1716 | 90 | /// issue #1716 |
91 | /// </summary> | 91 | /// </summary> |
92 | private static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.1f, 0.0f, 0.3f); | 92 | // private static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.1f, 0.0f, 0.3f); |
93 | private static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.0f, 0.0f, 0.418f); | ||
93 | 94 | ||
94 | public UUID currentParcelUUID = UUID.Zero; | 95 | public UUID currentParcelUUID = UUID.Zero; |
95 | 96 | ||
@@ -113,7 +114,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
113 | public Vector3 lastKnownAllowedPosition; | 114 | public Vector3 lastKnownAllowedPosition; |
114 | public bool sentMessageAboutRestrictedParcelFlyingDown; | 115 | public bool sentMessageAboutRestrictedParcelFlyingDown; |
115 | public Vector4 CollisionPlane = Vector4.UnitW; | 116 | public Vector4 CollisionPlane = Vector4.UnitW; |
116 | 117 | ||
118 | private Vector3 m_avInitialPos; // used to calculate unscripted sit rotation | ||
117 | private Vector3 m_lastPosition; | 119 | private Vector3 m_lastPosition; |
118 | private Quaternion m_lastRotation; | 120 | private Quaternion m_lastRotation; |
119 | private Vector3 m_lastVelocity; | 121 | private Vector3 m_lastVelocity; |
@@ -1575,7 +1577,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1575 | Velocity = Vector3.Zero; | 1577 | Velocity = Vector3.Zero; |
1576 | SendFullUpdateToAllClients(); | 1578 | SendFullUpdateToAllClients(); |
1577 | 1579 | ||
1578 | //HandleAgentSit(ControllingClient, m_requestedSitTargetUUID); | 1580 | HandleAgentSit(ControllingClient, m_requestedSitTargetUUID); //KF ?? |
1579 | } | 1581 | } |
1580 | //ControllingClient.SendSitResponse(m_requestedSitTargetID, m_requestedSitOffset, Quaternion.Identity, false, Vector3.Zero, Vector3.Zero, false); | 1582 | //ControllingClient.SendSitResponse(m_requestedSitTargetID, m_requestedSitOffset, Quaternion.Identity, false, Vector3.Zero, Vector3.Zero, false); |
1581 | m_requestedSitTargetUUID = UUID.Zero; | 1583 | m_requestedSitTargetUUID = UUID.Zero; |
@@ -1688,7 +1690,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1688 | bool SitTargetisSet = | 1690 | bool SitTargetisSet = |
1689 | (!(avSitOffSet.X == 0f && avSitOffSet.Y == 0f && avSitOffSet.Z == 0f && avSitOrientation.W == 1f && | 1691 | (!(avSitOffSet.X == 0f && avSitOffSet.Y == 0f && avSitOffSet.Z == 0f && avSitOrientation.W == 1f && |
1690 | avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 0f)); | 1692 | avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 0f)); |
1691 | 1693 | // this test is probably failing | |
1692 | if (SitTargetisSet && SitTargetUnOccupied) | 1694 | if (SitTargetisSet && SitTargetUnOccupied) |
1693 | { | 1695 | { |
1694 | //switch the target to this prim | 1696 | //switch the target to this prim |
@@ -1715,26 +1717,37 @@ namespace OpenSim.Region.Framework.Scenes | |||
1715 | { | 1717 | { |
1716 | // TODO: determine position to sit at based on scene geometry; don't trust offset from client | 1718 | // TODO: determine position to sit at based on scene geometry; don't trust offset from client |
1717 | // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it | 1719 | // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it |
1718 | 1720 | ||
1721 | // part is the prim to sit on | ||
1722 | // offset is the vector distance from that prim center to the click-spot | ||
1723 | // UUID is the UUID of the Avatar doing the clicking | ||
1724 | |||
1725 | m_avInitialPos = AbsolutePosition; // saved to calculate unscripted sit rotation | ||
1726 | |||
1719 | // Is a sit target available? | 1727 | // Is a sit target available? |
1720 | Vector3 avSitOffSet = part.SitTargetPosition; | 1728 | Vector3 avSitOffSet = part.SitTargetPosition; |
1721 | Quaternion avSitOrientation = part.SitTargetOrientation; | 1729 | Quaternion avSitOrientation = part.SitTargetOrientation; |
1722 | UUID avOnTargetAlready = part.GetAvatarOnSitTarget(); | 1730 | UUID avOnTargetAlready = part.GetAvatarOnSitTarget(); |
1723 | 1731 | ||
1724 | bool SitTargetUnOccupied = (!(avOnTargetAlready != UUID.Zero)); | 1732 | bool SitTargetUnOccupied = (!(avOnTargetAlready != UUID.Zero)); |
1725 | bool SitTargetisSet = | 1733 | // bool SitTargetisSet = |
1726 | (!(avSitOffSet.X == 0f && avSitOffSet.Y == 0f && avSitOffSet.Z == 0f && avSitOrientation.W == 0f && | 1734 | // (!(avSitOffSet.X == 0f && avSitOffSet.Y == 0f && avSitOffSet.Z == 0f && avSitOrientation.W == 0f && |
1727 | avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 1f)); | 1735 | // avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 1f)); |
1728 | 1736 | ||
1737 | bool SitTargetisSet = ((Vector3.Zero != avSitOffSet) || (Quaternion.Identity != avSitOrientation)); | ||
1738 | |||
1739 | //Console.WriteLine("SendSitResponse offset=" + offset + " UnOccup=" + SitTargetUnOccupied + | ||
1740 | // " TargSet=" + SitTargetisSet); | ||
1741 | |||
1729 | if (SitTargetisSet && SitTargetUnOccupied) | 1742 | if (SitTargetisSet && SitTargetUnOccupied) |
1730 | { | 1743 | { |
1731 | part.SetAvatarOnSitTarget(UUID); | 1744 | part.SetAvatarOnSitTarget(UUID); |
1732 | offset = new Vector3(avSitOffSet.X, avSitOffSet.Y, avSitOffSet.Z); | 1745 | offset = new Vector3(avSitOffSet.X, avSitOffSet.Y, avSitOffSet.Z); |
1733 | sitOrientation = avSitOrientation; | 1746 | sitOrientation = avSitOrientation; |
1734 | autopilot = false; | 1747 | autopilot = false; // Jump direct to scripted llSitPos() |
1735 | } | 1748 | } |
1736 | 1749 | ||
1737 | pos = part.AbsolutePosition + offset; | 1750 | pos = part.AbsolutePosition + offset; // Region position where clicked |
1738 | //if (Math.Abs(part.AbsolutePosition.Z - AbsolutePosition.Z) > 1) | 1751 | //if (Math.Abs(part.AbsolutePosition.Z - AbsolutePosition.Z) > 1) |
1739 | //{ | 1752 | //{ |
1740 | // offset = pos; | 1753 | // offset = pos; |
@@ -1747,17 +1760,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
1747 | m_sitAvatarHeight = m_physicsActor.Size.Z; | 1760 | m_sitAvatarHeight = m_physicsActor.Size.Z; |
1748 | 1761 | ||
1749 | if (autopilot) | 1762 | if (autopilot) |
1750 | { | 1763 | { // its not a scripted sit |
1751 | if (Util.GetDistanceTo(AbsolutePosition, pos) < 4.5) | 1764 | if (Util.GetDistanceTo(AbsolutePosition, pos) < 4.5) |
1752 | { | 1765 | { |
1753 | autopilot = false; | 1766 | autopilot = false; // close enough |
1754 | 1767 | ||
1755 | RemoveFromPhysicalScene(); | 1768 | RemoveFromPhysicalScene(); |
1756 | AbsolutePosition = pos + new Vector3(0.0f, 0.0f, m_sitAvatarHeight); | 1769 | AbsolutePosition = pos + new Vector3(0.0f, 0.0f, (m_sitAvatarHeight / 2.0f)); // Warp av to Prim |
1757 | } | 1770 | } // else the autopilot will get us close |
1758 | } | 1771 | } |
1759 | else | 1772 | else |
1760 | { | 1773 | { // its a scripted sit |
1761 | RemoveFromPhysicalScene(); | 1774 | RemoveFromPhysicalScene(); |
1762 | } | 1775 | } |
1763 | } | 1776 | } |
@@ -1860,26 +1873,41 @@ namespace OpenSim.Region.Framework.Scenes | |||
1860 | { | 1873 | { |
1861 | if (part.GetAvatarOnSitTarget() == UUID) | 1874 | if (part.GetAvatarOnSitTarget() == UUID) |
1862 | { | 1875 | { |
1876 | // Scripted sit | ||
1863 | Vector3 sitTargetPos = part.SitTargetPosition; | 1877 | Vector3 sitTargetPos = part.SitTargetPosition; |
1864 | Quaternion sitTargetOrient = part.SitTargetOrientation; | 1878 | Quaternion sitTargetOrient = part.SitTargetOrientation; |
1865 | |||
1866 | //Quaternion vq = new Quaternion(sitTargetPos.X, sitTargetPos.Y+0.2f, sitTargetPos.Z+0.2f, 0); | ||
1867 | //Quaternion nq = new Quaternion(-sitTargetOrient.X, -sitTargetOrient.Y, -sitTargetOrient.Z, sitTargetOrient.w); | ||
1868 | |||
1869 | //Quaternion result = (sitTargetOrient * vq) * nq; | ||
1870 | |||
1871 | m_pos = new Vector3(sitTargetPos.X, sitTargetPos.Y, sitTargetPos.Z); | 1879 | m_pos = new Vector3(sitTargetPos.X, sitTargetPos.Y, sitTargetPos.Z); |
1872 | m_pos += SIT_TARGET_ADJUSTMENT; | 1880 | m_pos += SIT_TARGET_ADJUSTMENT; |
1873 | m_bodyRot = sitTargetOrient; | 1881 | m_bodyRot = sitTargetOrient; |
1874 | //Rotation = sitTargetOrient; | ||
1875 | m_parentPosition = part.AbsolutePosition; | 1882 | m_parentPosition = part.AbsolutePosition; |
1876 | |||
1877 | //SendTerseUpdateToAllClients(); | ||
1878 | } | 1883 | } |
1879 | else | 1884 | else |
1880 | { | 1885 | { |
1881 | m_pos -= part.AbsolutePosition; | 1886 | // Non-scripted sit by Kitto Flora 21Nov09 |
1887 | // Calculate angle of line from prim to Av | ||
1888 | float y_diff = (m_avInitialPos.Y - part.AbsolutePosition.Y); | ||
1889 | float x_diff = ( m_avInitialPos.X - part.AbsolutePosition.X); | ||
1890 | if(Math.Abs(x_diff) < 0.001f) x_diff = 0.001f; // avoid div by 0 | ||
1891 | if(Math.Abs(y_diff) < 0.001f) y_diff = 0.001f; // avoid pol flip at 0 | ||
1892 | float sit_angle = (float)Math.Atan2( (double)y_diff, (double)x_diff); | ||
1893 | Quaternion partIRot = Quaternion.Inverse(part.GetWorldRotation()); | ||
1894 | // NOTE: when sitting m_ pos and m_bodyRot are *relative* to the prim location/rotation, not 'World'. | ||
1895 | // Av sits at world euler <0,0, z>, translated by part rotation | ||
1896 | m_bodyRot = partIRot * Quaternion.CreateFromEulers(0f, 0f, sit_angle); // sit at 0,0,inv-click | ||
1897 | m_pos = new Vector3(0f, 0f, 0.05f) + | ||
1898 | (new Vector3(0.0f, 0f, 0.625f) * partIRot) + | ||
1899 | (new Vector3(0.25f, 0f, 0.0f) * m_bodyRot); // sit at center of prim | ||
1882 | m_parentPosition = part.AbsolutePosition; | 1900 | m_parentPosition = part.AbsolutePosition; |
1901 | //Set up raytrace to find top surface of prim | ||
1902 | Vector3 size = part.Scale; | ||
1903 | float mag = 0.1f + (float)Math.Sqrt((size.X * size.X) + (size.Y * size.Y) + (size.Z * size.Z)); | ||
1904 | Vector3 start = part.AbsolutePosition + new Vector3(0f, 0f, mag); | ||
1905 | Vector3 down = new Vector3(0f, 0f, -1f); | ||
1906 | m_scene.PhysicsScene.RaycastWorld( | ||
1907 | start, // Vector3 position, | ||
1908 | down, // Vector3 direction, | ||
1909 | mag, // float length, | ||
1910 | SitAltitudeCallback); // retMethod | ||
1883 | } | 1911 | } |
1884 | } | 1912 | } |
1885 | else | 1913 | else |
@@ -1894,11 +1922,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
1894 | 1922 | ||
1895 | Animator.TrySetMovementAnimation(sitAnimation); | 1923 | Animator.TrySetMovementAnimation(sitAnimation); |
1896 | SendFullUpdateToAllClients(); | 1924 | SendFullUpdateToAllClients(); |
1897 | // This may seem stupid, but Our Full updates don't send avatar rotation :P | ||
1898 | // So we're also sending a terse update (which has avatar rotation) | ||
1899 | // [Update] We do now. | ||
1900 | //SendTerseUpdateToAllClients(); | ||
1901 | } | 1925 | } |
1926 | |||
1927 | public void SitAltitudeCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance) | ||
1928 | { | ||
1929 | // Console.WriteLine("[RAYCASTRESULT]: Hit={0}, Point={1}, ID={2}, Dist={3}", hitYN, collisionPoint, localid, distance); | ||
1930 | if(hitYN) | ||
1931 | { | ||
1932 | // m_pos = Av offset from prim center to make look like on center | ||
1933 | // m_parentPosition = Actual center pos of prim | ||
1934 | // collisionPoint = spot on prim where we want to sit | ||
1935 | SceneObjectPart part = m_scene.GetSceneObjectPart(localid); | ||
1936 | Vector3 offset = (collisionPoint - m_parentPosition) * Quaternion.Inverse(part.RotationOffset); | ||
1937 | m_pos += offset; | ||
1938 | // Console.WriteLine("m_pos={0}, offset={1} newsit={2}", m_pos, offset, newsit); | ||
1939 | } | ||
1940 | } | ||
1902 | 1941 | ||
1903 | /// <summary> | 1942 | /// <summary> |
1904 | /// Event handler for the 'Always run' setting on the client | 1943 | /// Event handler for the 'Always run' setting on the client |
@@ -3635,4 +3674,4 @@ namespace OpenSim.Region.Framework.Scenes | |||
3635 | } | 3674 | } |
3636 | } | 3675 | } |
3637 | } | 3676 | } |
3638 | } \ No newline at end of file | 3677 | } |