diff options
author | KittoFlora | 2009-12-05 09:03:02 +0100 |
---|---|---|
committer | KittoFlora | 2009-12-05 09:03:02 +0100 |
commit | cc8246206d5044aff0b306a4bcaf4b321fb826c9 (patch) | |
tree | 5b331cdbc5a6c9da82b927fabf076845c473f59a /OpenSim/Region/Framework/Scenes/ScenePresence.cs | |
parent | Merge branch 'careminster' into tests (diff) | |
download | opensim-SC_OLD-cc8246206d5044aff0b306a4bcaf4b321fb826c9.zip opensim-SC_OLD-cc8246206d5044aff0b306a4bcaf4b321fb826c9.tar.gz opensim-SC_OLD-cc8246206d5044aff0b306a4bcaf4b321fb826c9.tar.bz2 opensim-SC_OLD-cc8246206d5044aff0b306a4bcaf4b321fb826c9.tar.xz |
Secnond revision of Sit and Stand for unscripted prims; Comment out
spammy debug messages in Interregion....
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 253 |
1 files changed, 140 insertions, 113 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index cebd108..817b9df 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -197,6 +197,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
197 | private bool m_autopilotMoving; | 197 | private bool m_autopilotMoving; |
198 | private Vector3 m_autoPilotTarget; | 198 | private Vector3 m_autoPilotTarget; |
199 | private bool m_sitAtAutoTarget; | 199 | private bool m_sitAtAutoTarget; |
200 | private Vector3 m_initialSitTarget; //KF: First estimate of where to sit | ||
200 | 201 | ||
201 | private string m_nextSitAnimation = String.Empty; | 202 | private string m_nextSitAnimation = String.Empty; |
202 | 203 | ||
@@ -1524,7 +1525,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1524 | m_sitAtAutoTarget = false; | 1525 | m_sitAtAutoTarget = false; |
1525 | PrimitiveBaseShape proxy = PrimitiveBaseShape.Default; | 1526 | PrimitiveBaseShape proxy = PrimitiveBaseShape.Default; |
1526 | //proxy.PCode = (byte)PCode.ParticleSystem; | 1527 | //proxy.PCode = (byte)PCode.ParticleSystem; |
1527 | |||
1528 | proxyObjectGroup = new SceneObjectGroup(UUID, Pos, Rotation, proxy); | 1528 | proxyObjectGroup = new SceneObjectGroup(UUID, Pos, Rotation, proxy); |
1529 | proxyObjectGroup.AttachToScene(m_scene); | 1529 | proxyObjectGroup.AttachToScene(m_scene); |
1530 | 1530 | ||
@@ -1566,7 +1566,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1566 | } | 1566 | } |
1567 | m_moveToPositionInProgress = true; | 1567 | m_moveToPositionInProgress = true; |
1568 | m_moveToPositionTarget = new Vector3(locx, locy, locz); | 1568 | m_moveToPositionTarget = new Vector3(locx, locy, locz); |
1569 | } | 1569 | } |
1570 | catch (Exception ex) | 1570 | catch (Exception ex) |
1571 | { | 1571 | { |
1572 | //Why did I get this error? | 1572 | //Why did I get this error? |
@@ -1646,16 +1646,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
1646 | m_parentPosition = part.GetWorldPosition(); | 1646 | m_parentPosition = part.GetWorldPosition(); |
1647 | ControllingClient.SendClearFollowCamProperties(part.ParentUUID); | 1647 | ControllingClient.SendClearFollowCamProperties(part.ParentUUID); |
1648 | } | 1648 | } |
1649 | // part.GetWorldRotation() is the rotation of the object being sat on | ||
1650 | // Rotation is the sittiing Av's rotation | ||
1651 | |||
1652 | Quaternion wr = Quaternion.Inverse(Quaternion.Inverse(Rotation) * Quaternion.Inverse(part.GetWorldRotation())); // world or. of the av | ||
1653 | Vector3 so = new Vector3(1.0f, 0f, 0f) * wr; // 1M infront of av | ||
1654 | Vector3 wso = so + part.GetWorldPosition() + ( m_pos * part.GetWorldRotation()); // + av sit offset! | ||
1649 | 1655 | ||
1650 | if (m_physicsActor == null) | 1656 | if (m_physicsActor == null) |
1651 | { | 1657 | { |
1652 | AddToPhysicalScene(false); | 1658 | AddToPhysicalScene(false); |
1653 | } | 1659 | } |
1654 | m_pos += m_parentPosition + new Vector3(0.0f, 0.0f, 2.0f*m_sitAvatarHeight); | 1660 | AbsolutePosition = wso; //KF: Fix stand up. |
1655 | m_parentPosition = Vector3.Zero; | 1661 | m_parentPosition = Vector3.Zero; |
1656 | //Console.WriteLine("Stand Pos {0}", m_pos); | 1662 | |
1657 | 1663 | m_parentID = 0; | |
1658 | m_parentID = 0; | 1664 | part.IsOccupied = false; |
1659 | SendFullUpdateToAllClients(); | 1665 | SendFullUpdateToAllClients(); |
1660 | m_requestedSitTargetID = 0; | 1666 | m_requestedSitTargetID = 0; |
1661 | if ((m_physicsActor != null) && (m_avHeight > 0)) | 1667 | if ((m_physicsActor != null) && (m_avHeight > 0)) |
@@ -1694,13 +1700,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1694 | Vector3 avSitOffSet = part.SitTargetPosition; | 1700 | Vector3 avSitOffSet = part.SitTargetPosition; |
1695 | Quaternion avSitOrientation = part.SitTargetOrientation; | 1701 | Quaternion avSitOrientation = part.SitTargetOrientation; |
1696 | UUID avOnTargetAlready = part.GetAvatarOnSitTarget(); | 1702 | UUID avOnTargetAlready = part.GetAvatarOnSitTarget(); |
1697 | 1703 | bool SitTargetOccupied = (avOnTargetAlready != UUID.Zero); | |
1698 | bool SitTargetUnOccupied = (!(avOnTargetAlready != UUID.Zero)); | 1704 | bool SitTargetisSet = (Vector3.Zero != avSitOffSet); //NB Latest SL Spec shows Sit Rotation setting is ignored. |
1699 | bool SitTargetisSet = | 1705 | if (SitTargetisSet && !SitTargetOccupied) |
1700 | (!(avSitOffSet.X == 0f && avSitOffSet.Y == 0f && avSitOffSet.Z == 0f && avSitOrientation.W == 1f && | ||
1701 | avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 0f)); | ||
1702 | // this test is probably failing | ||
1703 | if (SitTargetisSet && SitTargetUnOccupied) | ||
1704 | { | 1706 | { |
1705 | //switch the target to this prim | 1707 | //switch the target to this prim |
1706 | return part; | 1708 | return part; |
@@ -1714,7 +1716,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1714 | private void SendSitResponse(IClientAPI remoteClient, UUID targetID, Vector3 offset) | 1716 | private void SendSitResponse(IClientAPI remoteClient, UUID targetID, Vector3 offset) |
1715 | { | 1717 | { |
1716 | bool autopilot = true; | 1718 | bool autopilot = true; |
1717 | Vector3 pos = new Vector3(); | 1719 | Vector3 autopilotTarget = new Vector3(); |
1718 | Quaternion sitOrientation = Quaternion.Identity; | 1720 | Quaternion sitOrientation = Quaternion.Identity; |
1719 | Vector3 cameraEyeOffset = Vector3.Zero; | 1721 | Vector3 cameraEyeOffset = Vector3.Zero; |
1720 | Vector3 cameraAtOffset = Vector3.Zero; | 1722 | Vector3 cameraAtOffset = Vector3.Zero; |
@@ -1722,98 +1724,104 @@ namespace OpenSim.Region.Framework.Scenes | |||
1722 | 1724 | ||
1723 | //SceneObjectPart part = m_scene.GetSceneObjectPart(targetID); | 1725 | //SceneObjectPart part = m_scene.GetSceneObjectPart(targetID); |
1724 | SceneObjectPart part = FindNextAvailableSitTarget(targetID); | 1726 | SceneObjectPart part = FindNextAvailableSitTarget(targetID); |
1725 | if (part != null) | 1727 | if (part == null) return; |
1726 | { | 1728 | |
1727 | // TODO: determine position to sit at based on scene geometry; don't trust offset from client | 1729 | // TODO: determine position to sit at based on scene geometry; don't trust offset from client |
1728 | // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it | 1730 | // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it |
1729 | 1731 | ||
1730 | // part is the prim to sit on | 1732 | // part is the prim to sit on |
1731 | // offset is the vector distance from that prim center to the click-spot | 1733 | // offset is the world-ref vector distance from that prim center to the click-spot |
1732 | // UUID is the UUID of the Avatar doing the clicking | 1734 | // UUID is the UUID of the Avatar doing the clicking |
1733 | |||
1734 | m_avInitialPos = AbsolutePosition; // saved to calculate unscripted sit rotation | ||
1735 | 1735 | ||
1736 | // Is a sit target available? | 1736 | m_avInitialPos = AbsolutePosition; // saved to calculate unscripted sit rotation |
1737 | Vector3 avSitOffSet = part.SitTargetPosition; | 1737 | |
1738 | Quaternion avSitOrientation = part.SitTargetOrientation; | 1738 | // Is a sit target available? |
1739 | UUID avOnTargetAlready = part.GetAvatarOnSitTarget(); | 1739 | Vector3 avSitOffSet = part.SitTargetPosition; |
1740 | 1740 | Quaternion avSitOrientation = part.SitTargetOrientation; | |
1741 | bool SitTargetUnOccupied = (!(avOnTargetAlready != UUID.Zero)); | 1741 | |
1742 | // bool SitTargetisSet = | 1742 | bool SitTargetisSet = (Vector3.Zero != avSitOffSet); //NB Latest SL Spec shows Sit Rotation setting is ignored. |
1743 | // (!(avSitOffSet.X == 0f && avSitOffSet.Y == 0f && avSitOffSet.Z == 0f && avSitOrientation.W == 0f && | 1743 | Quaternion partIRot = Quaternion.Inverse(part.GetWorldRotation()); |
1744 | // avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 1f)); | 1744 | |
1745 | 1745 | //Console.WriteLine("SendSitResponse offset=" + offset + " Occup=" + part.IsOccupied + " TargSet=" + SitTargetisSet); | |
1746 | bool SitTargetisSet = ((Vector3.Zero != avSitOffSet) || (Quaternion.Identity != avSitOrientation)); | 1746 | // Sit analysis rewritten by KF 091125 |
1747 | 1747 | if (SitTargetisSet) // scipted sit | |
1748 | //Console.WriteLine("SendSitResponse offset=" + offset + " UnOccup=" + SitTargetUnOccupied + | 1748 | { |
1749 | // " TargSet=" + SitTargetisSet); | 1749 | if (!part.IsOccupied) |
1750 | // Sit analysis rewritten by KF 091125 | 1750 | { |
1751 | if (SitTargetisSet) // scipted sit | 1751 | //Console.WriteLine("Scripted, unoccupied"); |
1752 | { | 1752 | part.SetAvatarOnSitTarget(UUID); // set that Av will be on it |
1753 | if (SitTargetUnOccupied) | 1753 | offset = new Vector3(avSitOffSet.X, avSitOffSet.Y, avSitOffSet.Z); // change ofset to the scripted one |
1754 | { | 1754 | sitOrientation = avSitOrientation; // Change rotatione to the scripted one |
1755 | part.SetAvatarOnSitTarget(UUID); // set that Av will be on it | 1755 | autopilot = false; // Jump direct to scripted llSitPos() |
1756 | offset = new Vector3(avSitOffSet.X, avSitOffSet.Y, avSitOffSet.Z); // change ofset to the scripted one | ||
1757 | sitOrientation = avSitOrientation; // Change rotatione to the scripted one | ||
1758 | autopilot = false; // Jump direct to scripted llSitPos() | ||
1759 | } | ||
1760 | else return; | ||
1761 | } | 1756 | } |
1762 | else // Not Scripted | 1757 | else |
1763 | { | 1758 | { |
1764 | if ( (Math.Abs(offset.X) > 0.5f) || (Math.Abs(offset.Y) > 0.5f) ) // large prim | 1759 | //Console.WriteLine("Scripted, occupied"); |
1765 | { | 1760 | return; |
1766 | Quaternion partIRot = Quaternion.Inverse(part.GetWorldRotation()); | 1761 | } |
1767 | m_avUnscriptedSitPos = offset * partIRot; // sit where clicked | 1762 | } |
1768 | pos = part.AbsolutePosition + (offset * partIRot); | 1763 | else // Not Scripted |
1769 | } | 1764 | { |
1770 | else // small prim | 1765 | if ( (Math.Abs(offset.X) > 0.5f) || (Math.Abs(offset.Y) > 0.5f) ) |
1771 | { | 1766 | { |
1772 | if (SitTargetUnOccupied) | 1767 | // large prim & offset, ignore if other Avs sitting |
1773 | { | 1768 | // offset.Z -= 0.05f; |
1774 | m_avUnscriptedSitPos = Vector3.Zero; // Sit on unoccupied small prim center | 1769 | m_avUnscriptedSitPos = offset * partIRot; // (non-zero) sit where clicked |
1775 | pos = part.AbsolutePosition; | 1770 | autopilotTarget = part.AbsolutePosition + offset; // World location of clicked point |
1776 | } | 1771 | |
1777 | else return; // occupied small | 1772 | //Console.WriteLine(" offset ={0}", offset); |
1778 | } // end large/small | 1773 | //Console.WriteLine(" UnscriptedSitPos={0}", m_avUnscriptedSitPos); |
1779 | } // end Scripted/not | 1774 | //Console.WriteLine(" autopilotTarget={0}", autopilotTarget); |
1780 | 1775 | ||
1781 | if (m_physicsActor != null) | 1776 | } |
1782 | { | 1777 | else // small offset |
1783 | // If we're not using the client autopilot, we're immediately warping the avatar to the location | 1778 | { |
1784 | // We can remove the physicsActor until they stand up. | 1779 | //Console.WriteLine("Small offset"); |
1785 | m_sitAvatarHeight = m_physicsActor.Size.Z; | 1780 | if (!part.IsOccupied) |
1786 | 1781 | { | |
1787 | if (autopilot) | 1782 | m_avUnscriptedSitPos = Vector3.Zero; // Zero = Sit on prim center |
1788 | { // its not a scripted sit | 1783 | autopilotTarget = part.AbsolutePosition; |
1789 | if (Util.GetDistanceTo(AbsolutePosition, pos) < 4.5) | 1784 | } |
1790 | { | 1785 | else return; // occupied small |
1791 | autopilot = false; // close enough | 1786 | } // end large/small |
1787 | } // end Scripted/not | ||
1788 | cameraAtOffset = part.GetCameraAtOffset(); | ||
1789 | cameraEyeOffset = part.GetCameraEyeOffset(); | ||
1790 | forceMouselook = part.GetForceMouselook(); | ||
1792 | 1791 | ||
1793 | RemoveFromPhysicalScene(); | 1792 | if (m_physicsActor != null) |
1794 | AbsolutePosition = pos + new Vector3(0.0f, 0.0f, (m_sitAvatarHeight / 2.0f)); // Warp av to Prim | 1793 | { |
1795 | } // else the autopilot will get us close | 1794 | // If we're not using the client autopilot, we're immediately warping the avatar to the location |
1796 | } | 1795 | // We can remove the physicsActor until they stand up. |
1797 | else | 1796 | m_sitAvatarHeight = m_physicsActor.Size.Z; |
1798 | { // its a scripted sit | 1797 | if (autopilot) |
1798 | { // its not a scripted sit | ||
1799 | // if (Util.GetDistanceTo(AbsolutePosition, autopilotTarget) < 4.5) | ||
1800 | if( (Math.Abs(AbsolutePosition.X - autopilotTarget.X) < 2.0f) && (Math.Abs(AbsolutePosition.Y - autopilotTarget.Y) < 2.0f) ) | ||
1801 | { | ||
1802 | autopilot = false; // close enough | ||
1799 | RemoveFromPhysicalScene(); | 1803 | RemoveFromPhysicalScene(); |
1800 | } | 1804 | AbsolutePosition = autopilotTarget + new Vector3(0.0f, 0.0f, (m_sitAvatarHeight / 2.0f)); // Warp av to over sit target |
1805 | } // else the autopilot will get us close | ||
1806 | } | ||
1807 | else | ||
1808 | { // its a scripted sit | ||
1809 | RemoveFromPhysicalScene(); | ||
1801 | } | 1810 | } |
1802 | |||
1803 | cameraAtOffset = part.GetCameraAtOffset(); | ||
1804 | cameraEyeOffset = part.GetCameraEyeOffset(); | ||
1805 | forceMouselook = part.GetForceMouselook(); | ||
1806 | } | 1811 | } |
1812 | else return; // physactor is null! | ||
1807 | 1813 | ||
1808 | ControllingClient.SendSitResponse(targetID, offset, sitOrientation, autopilot, cameraAtOffset, cameraEyeOffset, forceMouselook); | 1814 | Vector3 offsetr = offset * partIRot; |
1809 | m_requestedSitTargetUUID = targetID; | 1815 | ControllingClient.SendSitResponse(part.UUID, offsetr, sitOrientation, autopilot, cameraAtOffset, cameraEyeOffset, forceMouselook); |
1816 | m_requestedSitTargetUUID = part.UUID; //KF: Correct autopilot target | ||
1810 | // This calls HandleAgentSit twice, once from here, and the client calls | 1817 | // This calls HandleAgentSit twice, once from here, and the client calls |
1811 | // HandleAgentSit itself after it gets to the location | 1818 | // HandleAgentSit itself after it gets to the location |
1812 | // It doesn't get to the location until we've moved them there though | 1819 | // It doesn't get to the location until we've moved them there though |
1813 | // which happens in HandleAgentSit :P | 1820 | // which happens in HandleAgentSit :P |
1814 | m_autopilotMoving = autopilot; | 1821 | m_autopilotMoving = autopilot; |
1815 | m_autoPilotTarget = pos; | 1822 | m_autoPilotTarget = autopilotTarget; |
1816 | m_sitAtAutoTarget = autopilot; | 1823 | m_sitAtAutoTarget = autopilot; |
1824 | m_initialSitTarget = autopilotTarget; | ||
1817 | if (!autopilot) | 1825 | if (!autopilot) |
1818 | HandleAgentSit(remoteClient, UUID); | 1826 | HandleAgentSit(remoteClient, UUID); |
1819 | } | 1827 | } |
@@ -1898,6 +1906,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1898 | { | 1906 | { |
1899 | if (part.GetAvatarOnSitTarget() == UUID) | 1907 | if (part.GetAvatarOnSitTarget() == UUID) |
1900 | { | 1908 | { |
1909 | //Console.WriteLine("Scripted Sit"); | ||
1901 | // Scripted sit | 1910 | // Scripted sit |
1902 | Vector3 sitTargetPos = part.SitTargetPosition; | 1911 | Vector3 sitTargetPos = part.SitTargetPosition; |
1903 | Quaternion sitTargetOrient = part.SitTargetOrientation; | 1912 | Quaternion sitTargetOrient = part.SitTargetOrientation; |
@@ -1905,42 +1914,44 @@ namespace OpenSim.Region.Framework.Scenes | |||
1905 | m_pos += SIT_TARGET_ADJUSTMENT; | 1914 | m_pos += SIT_TARGET_ADJUSTMENT; |
1906 | m_bodyRot = sitTargetOrient; | 1915 | m_bodyRot = sitTargetOrient; |
1907 | m_parentPosition = part.AbsolutePosition; | 1916 | m_parentPosition = part.AbsolutePosition; |
1917 | part.IsOccupied = true; | ||
1908 | } | 1918 | } |
1909 | else | 1919 | else |
1910 | { | 1920 | { |
1921 | //Console.WriteLine("NON Scripted Sit"); | ||
1922 | // if m_avUnscriptedSitPos is zero then Av sits above center | ||
1923 | // Else Av sits at m_avUnscriptedSitPos | ||
1924 | |||
1911 | // Non-scripted sit by Kitto Flora 21Nov09 | 1925 | // Non-scripted sit by Kitto Flora 21Nov09 |
1912 | // Calculate angle of line from prim to Av | 1926 | // Calculate angle of line from prim to Av |
1927 | Quaternion partIRot = Quaternion.Inverse(part.GetWorldRotation()); | ||
1913 | Vector3 sitTargetPos= part.AbsolutePosition + m_avUnscriptedSitPos; | 1928 | Vector3 sitTargetPos= part.AbsolutePosition + m_avUnscriptedSitPos; |
1914 | float y_diff = (m_avInitialPos.Y - sitTargetPos.Y); | 1929 | float y_diff = (m_avInitialPos.Y - sitTargetPos.Y); |
1915 | float x_diff = ( m_avInitialPos.X - sitTargetPos.X); | 1930 | float x_diff = ( m_avInitialPos.X - sitTargetPos.X); |
1916 | if(Math.Abs(x_diff) < 0.001f) x_diff = 0.001f; // avoid div by 0 | 1931 | if(Math.Abs(x_diff) < 0.001f) x_diff = 0.001f; // avoid div by 0 |
1917 | if(Math.Abs(y_diff) < 0.001f) y_diff = 0.001f; // avoid pol flip at 0 | 1932 | if(Math.Abs(y_diff) < 0.001f) y_diff = 0.001f; // avoid pol flip at 0 |
1918 | float sit_angle = (float)Math.Atan2( (double)y_diff, (double)x_diff); | 1933 | float sit_angle = (float)Math.Atan2( (double)y_diff, (double)x_diff); |
1919 | Quaternion partIRot = Quaternion.Inverse(part.GetWorldRotation()); | ||
1920 | // NOTE: when sitting m_ pos and m_bodyRot are *relative* to the prim location/rotation, not 'World'. | 1934 | // NOTE: when sitting m_ pos and m_bodyRot are *relative* to the prim location/rotation, not 'World'. |
1921 | // Av sits at world euler <0,0, z>, translated by part rotation | 1935 | // Av sits at world euler <0,0, z>, translated by part rotation |
1922 | m_bodyRot = partIRot * Quaternion.CreateFromEulers(0f, 0f, sit_angle); // sit at 0,0,inv-click | 1936 | m_bodyRot = partIRot * Quaternion.CreateFromEulers(0f, 0f, sit_angle); // sit at 0,0,inv-click |
1937 | |||
1923 | m_parentPosition = part.AbsolutePosition; | 1938 | m_parentPosition = part.AbsolutePosition; |
1924 | if(m_avUnscriptedSitPos != Vector3.Zero) | 1939 | part.IsOccupied = true; |
1925 | { // sit where clicked on big prim | 1940 | m_pos = new Vector3(0f, 0f, 0.05f) + // corrections to get Sit Animation |
1926 | m_pos = m_avUnscriptedSitPos + (new Vector3(0.0f, 0f, 0.625f) * partIRot); | 1941 | (new Vector3(0.0f, 0f, 0.61f) * partIRot) + // located on center |
1927 | } | 1942 | (new Vector3(0.34f, 0f, 0.0f) * m_bodyRot) + |
1928 | else | 1943 | m_avUnscriptedSitPos; // adds click offset, if any |
1929 | { // sit at center of small prim | 1944 | //Set up raytrace to find top surface of prim |
1930 | m_pos = new Vector3(0f, 0f, 0.05f) + | 1945 | Vector3 size = part.Scale; |
1931 | (new Vector3(0.0f, 0f, 0.625f) * partIRot) + | 1946 | float mag = 0.1f + (float)Math.Sqrt((size.X * size.X) + (size.Y * size.Y) + (size.Z * size.Z)); |
1932 | (new Vector3(0.25f, 0f, 0.0f) * m_bodyRot); | 1947 | Vector3 start = part.AbsolutePosition + new Vector3(0f, 0f, mag); |
1933 | //Set up raytrace to find top surface of prim | 1948 | Vector3 down = new Vector3(0f, 0f, -1f); |
1934 | Vector3 size = part.Scale; | 1949 | //Console.WriteLine("st={0} do={1} ma={2}", start, down, mag); |
1935 | float mag = 0.1f + (float)Math.Sqrt((size.X * size.X) + (size.Y * size.Y) + (size.Z * size.Z)); | 1950 | m_scene.PhysicsScene.RaycastWorld( |
1936 | Vector3 start = part.AbsolutePosition + new Vector3(0f, 0f, mag); | ||
1937 | Vector3 down = new Vector3(0f, 0f, -1f); | ||
1938 | m_scene.PhysicsScene.RaycastWorld( | ||
1939 | start, // Vector3 position, | 1951 | start, // Vector3 position, |
1940 | down, // Vector3 direction, | 1952 | down, // Vector3 direction, |
1941 | mag, // float length, | 1953 | mag, // float length, |
1942 | SitAltitudeCallback); // retMethod | 1954 | SitAltitudeCallback); // retMethod |
1943 | } // end small/big | ||
1944 | } // end scripted/not | 1955 | } // end scripted/not |
1945 | } | 1956 | } |
1946 | else // no Av | 1957 | else // no Av |
@@ -1957,19 +1968,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1957 | SendFullUpdateToAllClients(); | 1968 | SendFullUpdateToAllClients(); |
1958 | } | 1969 | } |
1959 | 1970 | ||
1960 | public void SitAltitudeCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance) | 1971 | public void SitAltitudeCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance) // KF: Nov 2009 |
1961 | { | 1972 | { |
1973 | // KF: 091202 There appears to be a bug in Prim Edit Size - the process sometimes make a prim that RayTrace no longer | ||
1974 | // sees. Take/re-rez, or sim restart corrects the condition. Result of bug is incorrect sit height. | ||
1962 | if(hitYN) | 1975 | if(hitYN) |
1963 | { | 1976 | { |
1964 | // m_pos = Av offset from prim center to make look like on center | 1977 | // m_pos = Av offset from prim center to make look like on center |
1965 | // m_parentPosition = Actual center pos of prim | 1978 | // m_parentPosition = Actual center pos of prim |
1966 | // collisionPoint = spot on prim where we want to sit | 1979 | // collisionPoint = spot on prim where we want to sit |
1980 | // collisionPoint.Z = global sit surface height | ||
1967 | SceneObjectPart part = m_scene.GetSceneObjectPart(localid); | 1981 | SceneObjectPart part = m_scene.GetSceneObjectPart(localid); |
1968 | Vector3 offset = (collisionPoint - m_parentPosition) * Quaternion.Inverse(part.RotationOffset); | 1982 | Quaternion partIRot = Quaternion.Inverse(part.GetWorldRotation()); |
1983 | float offZ = collisionPoint.Z - m_initialSitTarget.Z; | ||
1984 | Vector3 offset = new Vector3(0.0f, 0.0f, offZ) * partIRot; // Altitude correction | ||
1985 | //Console.WriteLine("sitPoint={0}, offset={1}", sitPoint, offset); | ||
1969 | m_pos += offset; | 1986 | m_pos += offset; |
1970 | // Console.WriteLine("m_pos={0}, offset={1} newsit={2}", m_pos, offset, newsit); | ||
1971 | } | 1987 | } |
1972 | } | 1988 | } // End SitAltitudeCallback KF. |
1973 | 1989 | ||
1974 | /// <summary> | 1990 | /// <summary> |
1975 | /// Event handler for the 'Always run' setting on the client | 1991 | /// Event handler for the 'Always run' setting on the client |
@@ -3716,5 +3732,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3716 | m_reprioritization_called = false; | 3732 | m_reprioritization_called = false; |
3717 | } | 3733 | } |
3718 | } | 3734 | } |
3735 | |||
3736 | private Vector3 Quat2Euler(Quaternion rot){ | ||
3737 | float x = Utils.RAD_TO_DEG * (float)Math.Atan2((double)((2.0f * rot.X * rot.W) - (2.0f * rot.Y * rot.Z)) , | ||
3738 | (double)(1 - (2.0f * rot.X * rot.X) - (2.0f * rot.Z * rot.Z))); | ||
3739 | float y = Utils.RAD_TO_DEG * (float)Math.Asin ((double)((2.0f * rot.X * rot.Y) + (2.0f * rot.Z * rot.W))); | ||
3740 | float z = Utils.RAD_TO_DEG * (float)Math.Atan2(((double)(2.0f * rot.Y * rot.W) - (2.0f * rot.X * rot.Z)) , | ||
3741 | (double)(1 - (2.0f * rot.Y * rot.Y) - (2.0f * rot.Z * rot.Z))); | ||
3742 | return(new Vector3(x,y,z)); | ||
3743 | } | ||
3744 | |||
3745 | |||
3719 | } | 3746 | } |
3720 | } | 3747 | } |