diff options
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 54 |
1 files changed, 41 insertions, 13 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index cbd169a..a3ad7ca 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -118,7 +118,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
118 | 118 | ||
119 | private Vector3 m_avInitialPos; // used to calculate unscripted sit rotation | 119 | private Vector3 m_avInitialPos; // used to calculate unscripted sit rotation |
120 | private Vector3 m_avUnscriptedSitPos; // for non-scripted prims | 120 | private Vector3 m_avUnscriptedSitPos; // for non-scripted prims |
121 | private Vector3 m_lastPosition; | 121 | private Vector3 m_lastPosition; |
122 | private Vector3 m_lastWorldPosition; | ||
122 | private Quaternion m_lastRotation; | 123 | private Quaternion m_lastRotation; |
123 | private Vector3 m_lastVelocity; | 124 | private Vector3 m_lastVelocity; |
124 | //private int m_lastTerseSent; | 125 | //private int m_lastTerseSent; |
@@ -1667,24 +1668,45 @@ namespace OpenSim.Region.Framework.Scenes | |||
1667 | // } | 1668 | // } |
1668 | // else | 1669 | // else |
1669 | // { // single or child prim | 1670 | // { // single or child prim |
1670 | partRot = part.GetWorldRotation(); | 1671 | |
1671 | // } | 1672 | // } |
1673 | if (part == null) //CW: Part may be gone. llDie() for example. | ||
1674 | { | ||
1675 | partRot = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); | ||
1676 | } | ||
1677 | else | ||
1678 | { | ||
1679 | partRot = part.GetWorldRotation(); | ||
1680 | } | ||
1681 | |||
1672 | Quaternion partIRot = Quaternion.Inverse(partRot); | 1682 | Quaternion partIRot = Quaternion.Inverse(partRot); |
1673 | 1683 | ||
1674 | Quaternion avatarRot = Quaternion.Inverse(Quaternion.Inverse(Rotation) * partIRot); // world or. of the av | 1684 | Quaternion avatarRot = Quaternion.Inverse(Quaternion.Inverse(Rotation) * partIRot); // world or. of the av |
1675 | Vector3 avStandUp = new Vector3(1.0f, 0f, 0f) * avatarRot; // 1M infront of av | 1685 | Vector3 avStandUp = new Vector3(1.0f, 0f, 0f) * avatarRot; // 1M infront of av |
1676 | Vector3 avWorldStandUp = avStandUp + part.GetWorldPosition() + ( m_pos * partRot); // + av sit offset! | ||
1677 | 1686 | ||
1678 | if (m_physicsActor == null) | 1687 | |
1679 | { | 1688 | if (m_physicsActor == null) |
1680 | AddToPhysicalScene(false); | 1689 | { |
1690 | AddToPhysicalScene(false); | ||
1691 | } | ||
1692 | //CW: If the part isn't null then we can set the current position | ||
1693 | if (part != null) | ||
1694 | { | ||
1695 | Vector3 avWorldStandUp = avStandUp + part.GetWorldPosition() + (m_pos * partRot); // + av sit offset! | ||
1696 | AbsolutePosition = avWorldStandUp; //KF: Fix stand up. | ||
1697 | part.IsOccupied = false; | ||
1698 | } | ||
1699 | else | ||
1700 | { | ||
1701 | //CW: Since the part doesn't exist, a coarse standup position isn't an issue | ||
1702 | AbsolutePosition = m_lastWorldPosition; | ||
1681 | } | 1703 | } |
1682 | AbsolutePosition = avWorldStandUp; //KF: Fix stand up. | 1704 | |
1683 | m_parentPosition = Vector3.Zero; | 1705 | m_parentPosition = Vector3.Zero; |
1684 | m_parentID = 0; | 1706 | m_parentID = 0; |
1685 | part.IsOccupied = false; | ||
1686 | SendFullUpdateToAllClients(); | 1707 | SendFullUpdateToAllClients(); |
1687 | m_requestedSitTargetID = 0; | 1708 | m_requestedSitTargetID = 0; |
1709 | |||
1688 | if ((m_physicsActor != null) && (m_avHeight > 0)) | 1710 | if ((m_physicsActor != null) && (m_avHeight > 0)) |
1689 | { | 1711 | { |
1690 | SetHeight(m_avHeight); | 1712 | SetHeight(m_avHeight); |
@@ -1778,7 +1800,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1778 | { | 1800 | { |
1779 | if (!part.IsOccupied) | 1801 | if (!part.IsOccupied) |
1780 | { | 1802 | { |
1781 | //Console.WriteLine("Scripted, unoccupied"); | 1803 | //Console.WriteLine("Scripted, unoccupied"); |
1782 | part.SetAvatarOnSitTarget(UUID); // set that Av will be on it | 1804 | part.SetAvatarOnSitTarget(UUID); // set that Av will be on it |
1783 | offset = new Vector3(avSitOffSet.X, avSitOffSet.Y, avSitOffSet.Z); // change ofset to the scripted one | 1805 | offset = new Vector3(avSitOffSet.X, avSitOffSet.Y, avSitOffSet.Z); // change ofset to the scripted one |
1784 | sitOrientation = avSitOrientation; // Change rotatione to the scripted one | 1806 | sitOrientation = avSitOrientation; // Change rotatione to the scripted one |
@@ -1831,13 +1853,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
1831 | // if (Util.GetDistanceTo(AbsolutePosition, autopilotTarget) < 4.5) | 1853 | // if (Util.GetDistanceTo(AbsolutePosition, autopilotTarget) < 4.5) |
1832 | if( (Math.Abs(AbsolutePosition.X - autopilotTarget.X) < 2.0f) && (Math.Abs(AbsolutePosition.Y - autopilotTarget.Y) < 2.0f) ) | 1854 | if( (Math.Abs(AbsolutePosition.X - autopilotTarget.X) < 2.0f) && (Math.Abs(AbsolutePosition.Y - autopilotTarget.Y) < 2.0f) ) |
1833 | { | 1855 | { |
1834 | autopilot = false; // close enough | 1856 | autopilot = false; // close enough |
1857 | m_lastWorldPosition = m_pos; /* CW - This give us a position to return the avatar to if the part is killed before standup. | ||
1858 | Not using the part's position because returning the AV to the last known standing | ||
1859 | position is likely to be more friendly, isn't it? */ | ||
1835 | RemoveFromPhysicalScene(); | 1860 | RemoveFromPhysicalScene(); |
1836 | AbsolutePosition = autopilotTarget + new Vector3(0.0f, 0.0f, (m_sitAvatarHeight / 2.0f)); // Warp av to over sit target | 1861 | AbsolutePosition = autopilotTarget + new Vector3(0.0f, 0.0f, (m_sitAvatarHeight / 2.0f)); // Warp av to over sit target |
1837 | } // else the autopilot will get us close | 1862 | } // else the autopilot will get us close |
1838 | } | 1863 | } |
1839 | else | 1864 | else |
1840 | { // its a scripted sit | 1865 | { // its a scripted sit |
1866 | m_lastWorldPosition = part.AbsolutePosition; /* CW - This give us a position to return the avatar to if the part is killed before standup. | ||
1867 | I *am* using the part's position this time because we have no real idea how far away | ||
1868 | the avatar is from the sit target. */ | ||
1841 | RemoveFromPhysicalScene(); | 1869 | RemoveFromPhysicalScene(); |
1842 | } | 1870 | } |
1843 | } | 1871 | } |