diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-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 1dedcf1..aa538dc 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; |
@@ -1531,7 +1533,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1531 | Velocity = Vector3.Zero; | 1533 | Velocity = Vector3.Zero; |
1532 | SendFullUpdateToAllClients(); | 1534 | SendFullUpdateToAllClients(); |
1533 | 1535 | ||
1534 | //HandleAgentSit(ControllingClient, m_requestedSitTargetUUID); | 1536 | HandleAgentSit(ControllingClient, m_requestedSitTargetUUID); //KF ?? |
1535 | } | 1537 | } |
1536 | //ControllingClient.SendSitResponse(m_requestedSitTargetID, m_requestedSitOffset, Quaternion.Identity, false, Vector3.Zero, Vector3.Zero, false); | 1538 | //ControllingClient.SendSitResponse(m_requestedSitTargetID, m_requestedSitOffset, Quaternion.Identity, false, Vector3.Zero, Vector3.Zero, false); |
1537 | m_requestedSitTargetUUID = UUID.Zero; | 1539 | m_requestedSitTargetUUID = UUID.Zero; |
@@ -1644,7 +1646,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1644 | bool SitTargetisSet = | 1646 | bool SitTargetisSet = |
1645 | (!(avSitOffSet.X == 0f && avSitOffSet.Y == 0f && avSitOffSet.Z == 0f && avSitOrientation.W == 1f && | 1647 | (!(avSitOffSet.X == 0f && avSitOffSet.Y == 0f && avSitOffSet.Z == 0f && avSitOrientation.W == 1f && |
1646 | avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 0f)); | 1648 | avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 0f)); |
1647 | 1649 | // this test is probably failing | |
1648 | if (SitTargetisSet && SitTargetUnOccupied) | 1650 | if (SitTargetisSet && SitTargetUnOccupied) |
1649 | { | 1651 | { |
1650 | //switch the target to this prim | 1652 | //switch the target to this prim |
@@ -1671,26 +1673,37 @@ namespace OpenSim.Region.Framework.Scenes | |||
1671 | { | 1673 | { |
1672 | // TODO: determine position to sit at based on scene geometry; don't trust offset from client | 1674 | // TODO: determine position to sit at based on scene geometry; don't trust offset from client |
1673 | // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it | 1675 | // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it |
1674 | 1676 | ||
1677 | // part is the prim to sit on | ||
1678 | // offset is the vector distance from that prim center to the click-spot | ||
1679 | // UUID is the UUID of the Avatar doing the clicking | ||
1680 | |||
1681 | m_avInitialPos = AbsolutePosition; // saved to calculate unscripted sit rotation | ||
1682 | |||
1675 | // Is a sit target available? | 1683 | // Is a sit target available? |
1676 | Vector3 avSitOffSet = part.SitTargetPosition; | 1684 | Vector3 avSitOffSet = part.SitTargetPosition; |
1677 | Quaternion avSitOrientation = part.SitTargetOrientation; | 1685 | Quaternion avSitOrientation = part.SitTargetOrientation; |
1678 | UUID avOnTargetAlready = part.GetAvatarOnSitTarget(); | 1686 | UUID avOnTargetAlready = part.GetAvatarOnSitTarget(); |
1679 | 1687 | ||
1680 | bool SitTargetUnOccupied = (!(avOnTargetAlready != UUID.Zero)); | 1688 | bool SitTargetUnOccupied = (!(avOnTargetAlready != UUID.Zero)); |
1681 | bool SitTargetisSet = | 1689 | // bool SitTargetisSet = |
1682 | (!(avSitOffSet.X == 0f && avSitOffSet.Y == 0f && avSitOffSet.Z == 0f && avSitOrientation.W == 0f && | 1690 | // (!(avSitOffSet.X == 0f && avSitOffSet.Y == 0f && avSitOffSet.Z == 0f && avSitOrientation.W == 0f && |
1683 | avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 1f)); | 1691 | // avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 1f)); |
1684 | 1692 | ||
1693 | bool SitTargetisSet = ((Vector3.Zero != avSitOffSet) || (Quaternion.Identity != avSitOrientation)); | ||
1694 | |||
1695 | //Console.WriteLine("SendSitResponse offset=" + offset + " UnOccup=" + SitTargetUnOccupied + | ||
1696 | // " TargSet=" + SitTargetisSet); | ||
1697 | |||
1685 | if (SitTargetisSet && SitTargetUnOccupied) | 1698 | if (SitTargetisSet && SitTargetUnOccupied) |
1686 | { | 1699 | { |
1687 | part.SetAvatarOnSitTarget(UUID); | 1700 | part.SetAvatarOnSitTarget(UUID); |
1688 | offset = new Vector3(avSitOffSet.X, avSitOffSet.Y, avSitOffSet.Z); | 1701 | offset = new Vector3(avSitOffSet.X, avSitOffSet.Y, avSitOffSet.Z); |
1689 | sitOrientation = avSitOrientation; | 1702 | sitOrientation = avSitOrientation; |
1690 | autopilot = false; | 1703 | autopilot = false; // Jump direct to scripted llSitPos() |
1691 | } | 1704 | } |
1692 | 1705 | ||
1693 | pos = part.AbsolutePosition + offset; | 1706 | pos = part.AbsolutePosition + offset; // Region position where clicked |
1694 | //if (Math.Abs(part.AbsolutePosition.Z - AbsolutePosition.Z) > 1) | 1707 | //if (Math.Abs(part.AbsolutePosition.Z - AbsolutePosition.Z) > 1) |
1695 | //{ | 1708 | //{ |
1696 | // offset = pos; | 1709 | // offset = pos; |
@@ -1703,17 +1716,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
1703 | m_sitAvatarHeight = m_physicsActor.Size.Z; | 1716 | m_sitAvatarHeight = m_physicsActor.Size.Z; |
1704 | 1717 | ||
1705 | if (autopilot) | 1718 | if (autopilot) |
1706 | { | 1719 | { // its not a scripted sit |
1707 | if (Util.GetDistanceTo(AbsolutePosition, pos) < 4.5) | 1720 | if (Util.GetDistanceTo(AbsolutePosition, pos) < 4.5) |
1708 | { | 1721 | { |
1709 | autopilot = false; | 1722 | autopilot = false; // close enough |
1710 | 1723 | ||
1711 | RemoveFromPhysicalScene(); | 1724 | RemoveFromPhysicalScene(); |
1712 | AbsolutePosition = pos + new Vector3(0.0f, 0.0f, m_sitAvatarHeight); | 1725 | AbsolutePosition = pos + new Vector3(0.0f, 0.0f, (m_sitAvatarHeight / 2.0f)); // Warp av to Prim |
1713 | } | 1726 | } // else the autopilot will get us close |
1714 | } | 1727 | } |
1715 | else | 1728 | else |
1716 | { | 1729 | { // its a scripted sit |
1717 | RemoveFromPhysicalScene(); | 1730 | RemoveFromPhysicalScene(); |
1718 | } | 1731 | } |
1719 | } | 1732 | } |
@@ -1816,26 +1829,41 @@ namespace OpenSim.Region.Framework.Scenes | |||
1816 | { | 1829 | { |
1817 | if (part.GetAvatarOnSitTarget() == UUID) | 1830 | if (part.GetAvatarOnSitTarget() == UUID) |
1818 | { | 1831 | { |
1832 | // Scripted sit | ||
1819 | Vector3 sitTargetPos = part.SitTargetPosition; | 1833 | Vector3 sitTargetPos = part.SitTargetPosition; |
1820 | Quaternion sitTargetOrient = part.SitTargetOrientation; | 1834 | Quaternion sitTargetOrient = part.SitTargetOrientation; |
1821 | |||
1822 | //Quaternion vq = new Quaternion(sitTargetPos.X, sitTargetPos.Y+0.2f, sitTargetPos.Z+0.2f, 0); | ||
1823 | //Quaternion nq = new Quaternion(-sitTargetOrient.X, -sitTargetOrient.Y, -sitTargetOrient.Z, sitTargetOrient.w); | ||
1824 | |||
1825 | //Quaternion result = (sitTargetOrient * vq) * nq; | ||
1826 | |||
1827 | m_pos = new Vector3(sitTargetPos.X, sitTargetPos.Y, sitTargetPos.Z); | 1835 | m_pos = new Vector3(sitTargetPos.X, sitTargetPos.Y, sitTargetPos.Z); |
1828 | m_pos += SIT_TARGET_ADJUSTMENT; | 1836 | m_pos += SIT_TARGET_ADJUSTMENT; |
1829 | m_bodyRot = sitTargetOrient; | 1837 | m_bodyRot = sitTargetOrient; |
1830 | //Rotation = sitTargetOrient; | ||
1831 | m_parentPosition = part.AbsolutePosition; | 1838 | m_parentPosition = part.AbsolutePosition; |
1832 | |||
1833 | //SendTerseUpdateToAllClients(); | ||
1834 | } | 1839 | } |
1835 | else | 1840 | else |
1836 | { | 1841 | { |
1837 | m_pos -= part.AbsolutePosition; | 1842 | // Non-scripted sit by Kitto Flora 21Nov09 |
1843 | // Calculate angle of line from prim to Av | ||
1844 | float y_diff = (m_avInitialPos.Y - part.AbsolutePosition.Y); | ||
1845 | float x_diff = ( m_avInitialPos.X - part.AbsolutePosition.X); | ||
1846 | if(Math.Abs(x_diff) < 0.001f) x_diff = 0.001f; // avoid div by 0 | ||
1847 | if(Math.Abs(y_diff) < 0.001f) y_diff = 0.001f; // avoid pol flip at 0 | ||
1848 | float sit_angle = (float)Math.Atan2( (double)y_diff, (double)x_diff); | ||
1849 | Quaternion partIRot = Quaternion.Inverse(part.GetWorldRotation()); | ||
1850 | // NOTE: when sitting m_ pos and m_bodyRot are *relative* to the prim location/rotation, not 'World'. | ||
1851 | // Av sits at world euler <0,0, z>, translated by part rotation | ||
1852 | m_bodyRot = partIRot * Quaternion.CreateFromEulers(0f, 0f, sit_angle); // sit at 0,0,inv-click | ||
1853 | m_pos = new Vector3(0f, 0f, 0.05f) + | ||
1854 | (new Vector3(0.0f, 0f, 0.625f) * partIRot) + | ||
1855 | (new Vector3(0.25f, 0f, 0.0f) * m_bodyRot); // sit at center of prim | ||
1838 | m_parentPosition = part.AbsolutePosition; | 1856 | m_parentPosition = part.AbsolutePosition; |
1857 | //Set up raytrace to find top surface of prim | ||
1858 | Vector3 size = part.Scale; | ||
1859 | float mag = 0.1f + (float)Math.Sqrt((size.X * size.X) + (size.Y * size.Y) + (size.Z * size.Z)); | ||
1860 | Vector3 start = part.AbsolutePosition + new Vector3(0f, 0f, mag); | ||
1861 | Vector3 down = new Vector3(0f, 0f, -1f); | ||
1862 | m_scene.PhysicsScene.RaycastWorld( | ||
1863 | start, // Vector3 position, | ||
1864 | down, // Vector3 direction, | ||
1865 | mag, // float length, | ||
1866 | SitAltitudeCallback); // retMethod | ||
1839 | } | 1867 | } |
1840 | } | 1868 | } |
1841 | else | 1869 | else |
@@ -1850,11 +1878,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
1850 | 1878 | ||
1851 | Animator.TrySetMovementAnimation(sitAnimation); | 1879 | Animator.TrySetMovementAnimation(sitAnimation); |
1852 | SendFullUpdateToAllClients(); | 1880 | SendFullUpdateToAllClients(); |
1853 | // This may seem stupid, but Our Full updates don't send avatar rotation :P | ||
1854 | // So we're also sending a terse update (which has avatar rotation) | ||
1855 | // [Update] We do now. | ||
1856 | //SendTerseUpdateToAllClients(); | ||
1857 | } | 1881 | } |
1882 | |||
1883 | public void SitAltitudeCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance) | ||
1884 | { | ||
1885 | // Console.WriteLine("[RAYCASTRESULT]: Hit={0}, Point={1}, ID={2}, Dist={3}", hitYN, collisionPoint, localid, distance); | ||
1886 | if(hitYN) | ||
1887 | { | ||
1888 | // m_pos = Av offset from prim center to make look like on center | ||
1889 | // m_parentPosition = Actual center pos of prim | ||
1890 | // collisionPoint = spot on prim where we want to sit | ||
1891 | SceneObjectPart part = m_scene.GetSceneObjectPart(localid); | ||
1892 | Vector3 offset = (collisionPoint - m_parentPosition) * Quaternion.Inverse(part.RotationOffset); | ||
1893 | m_pos += offset; | ||
1894 | // Console.WriteLine("m_pos={0}, offset={1} newsit={2}", m_pos, offset, newsit); | ||
1895 | } | ||
1896 | } | ||
1858 | 1897 | ||
1859 | /// <summary> | 1898 | /// <summary> |
1860 | /// Event handler for the 'Always run' setting on the client | 1899 | /// Event handler for the 'Always run' setting on the client |
@@ -3578,4 +3617,4 @@ namespace OpenSim.Region.Framework.Scenes | |||
3578 | } | 3617 | } |
3579 | } | 3618 | } |
3580 | } | 3619 | } |
3581 | } \ No newline at end of file | 3620 | } |