aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorKittoFlora2009-11-26 20:37:08 +0100
committerKittoFlora2009-11-26 20:37:08 +0100
commit5dedacca3c9692948f29f5198dd444efe7c8526d (patch)
tree8fac64e888fb094b703a0090f3c0ac45a0cf79e9
parentFixed animation sequencing: SitHere, Falling, Stand/Walk etc. Login Init (diff)
downloadopensim-SC-5dedacca3c9692948f29f5198dd444efe7c8526d.zip
opensim-SC-5dedacca3c9692948f29f5198dd444efe7c8526d.tar.gz
opensim-SC-5dedacca3c9692948f29f5198dd444efe7c8526d.tar.bz2
opensim-SC-5dedacca3c9692948f29f5198dd444efe7c8526d.tar.xz
First attempt at mult-sit on large single prims.
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs91
1 files changed, 58 insertions, 33 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index a65b84b..e677cfd 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -117,6 +117,7 @@ namespace OpenSim.Region.Framework.Scenes
117 public Vector4 CollisionPlane = Vector4.UnitW; 117 public Vector4 CollisionPlane = Vector4.UnitW;
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_lastPosition; 121 private Vector3 m_lastPosition;
121 private Quaternion m_lastRotation; 122 private Quaternion m_lastRotation;
122 private Vector3 m_lastVelocity; 123 private Vector3 m_lastVelocity;
@@ -1644,9 +1645,9 @@ namespace OpenSim.Region.Framework.Scenes
1644 { 1645 {
1645 AddToPhysicalScene(false); 1646 AddToPhysicalScene(false);
1646 } 1647 }
1647
1648 m_pos += m_parentPosition + new Vector3(0.0f, 0.0f, 2.0f*m_sitAvatarHeight); 1648 m_pos += m_parentPosition + new Vector3(0.0f, 0.0f, 2.0f*m_sitAvatarHeight);
1649 m_parentPosition = Vector3.Zero; 1649 m_parentPosition = Vector3.Zero;
1650//Console.WriteLine("Stand Pos {0}", m_pos);
1650 1651
1651 m_parentID = 0; 1652 m_parentID = 0;
1652 SendFullUpdateToAllClients(); 1653 SendFullUpdateToAllClients();
@@ -1740,21 +1741,37 @@ namespace OpenSim.Region.Framework.Scenes
1740 1741
1741//Console.WriteLine("SendSitResponse offset=" + offset + " UnOccup=" + SitTargetUnOccupied + 1742//Console.WriteLine("SendSitResponse offset=" + offset + " UnOccup=" + SitTargetUnOccupied +
1742// " TargSet=" + SitTargetisSet); 1743// " TargSet=" + SitTargetisSet);
1743 1744 // Sit analysis rewritten by KF 091125
1744 if (SitTargetisSet && SitTargetUnOccupied) 1745 if (SitTargetisSet) // scipted sit
1745 { 1746 {
1746 part.SetAvatarOnSitTarget(UUID); 1747 if (SitTargetUnOccupied)
1747 offset = new Vector3(avSitOffSet.X, avSitOffSet.Y, avSitOffSet.Z); 1748 {
1748 sitOrientation = avSitOrientation; 1749 part.SetAvatarOnSitTarget(UUID); // set that Av will be on it
1749 autopilot = false; // Jump direct to scripted llSitPos() 1750 offset = new Vector3(avSitOffSet.X, avSitOffSet.Y, avSitOffSet.Z); // change ofset to the scripted one
1750 } 1751 sitOrientation = avSitOrientation; // Change rotatione to the scripted one
1752 autopilot = false; // Jump direct to scripted llSitPos()
1753 }
1754 else return;
1755 }
1756 else // Not Scripted
1757 {
1758 if ( (Math.Abs(offset.X) > 0.5f) || (Math.Abs(offset.Y) > 0.5f) ) // large prim
1759 {
1760 Quaternion partIRot = Quaternion.Inverse(part.GetWorldRotation());
1761 m_avUnscriptedSitPos = offset * partIRot; // sit where clicked
1762 pos = part.AbsolutePosition + (offset * partIRot);
1763 }
1764 else // small prim
1765 {
1766 if (SitTargetUnOccupied)
1767 {
1768 m_avUnscriptedSitPos = Vector3.Zero; // Sit on unoccupied small prim center
1769 pos = part.AbsolutePosition;
1770 }
1771 else return; // occupied small
1772 } // end large/small
1773 } // end Scripted/not
1751 1774
1752 pos = part.AbsolutePosition + offset; // Region position where clicked
1753 //if (Math.Abs(part.AbsolutePosition.Z - AbsolutePosition.Z) > 1)
1754 //{
1755 // offset = pos;
1756 //autopilot = false;
1757 //}
1758 if (m_physicsActor != null) 1775 if (m_physicsActor != null)
1759 { 1776 {
1760 // If we're not using the client autopilot, we're immediately warping the avatar to the location 1777 // If we're not using the client autopilot, we're immediately warping the avatar to the location
@@ -1887,8 +1904,9 @@ namespace OpenSim.Region.Framework.Scenes
1887 { 1904 {
1888 // Non-scripted sit by Kitto Flora 21Nov09 1905 // Non-scripted sit by Kitto Flora 21Nov09
1889 // Calculate angle of line from prim to Av 1906 // Calculate angle of line from prim to Av
1890 float y_diff = (m_avInitialPos.Y - part.AbsolutePosition.Y); 1907 Vector3 sitTargetPos= part.AbsolutePosition + m_avUnscriptedSitPos;
1891 float x_diff = ( m_avInitialPos.X - part.AbsolutePosition.X); 1908 float y_diff = (m_avInitialPos.Y - sitTargetPos.Y);
1909 float x_diff = ( m_avInitialPos.X - sitTargetPos.X);
1892 if(Math.Abs(x_diff) < 0.001f) x_diff = 0.001f; // avoid div by 0 1910 if(Math.Abs(x_diff) < 0.001f) x_diff = 0.001f; // avoid div by 0
1893 if(Math.Abs(y_diff) < 0.001f) y_diff = 0.001f; // avoid pol flip at 0 1911 if(Math.Abs(y_diff) < 0.001f) y_diff = 0.001f; // avoid pol flip at 0
1894 float sit_angle = (float)Math.Atan2( (double)y_diff, (double)x_diff); 1912 float sit_angle = (float)Math.Atan2( (double)y_diff, (double)x_diff);
@@ -1896,23 +1914,30 @@ namespace OpenSim.Region.Framework.Scenes
1896 // NOTE: when sitting m_ pos and m_bodyRot are *relative* to the prim location/rotation, not 'World'. 1914 // NOTE: when sitting m_ pos and m_bodyRot are *relative* to the prim location/rotation, not 'World'.
1897 // Av sits at world euler <0,0, z>, translated by part rotation 1915 // Av sits at world euler <0,0, z>, translated by part rotation
1898 m_bodyRot = partIRot * Quaternion.CreateFromEulers(0f, 0f, sit_angle); // sit at 0,0,inv-click 1916 m_bodyRot = partIRot * Quaternion.CreateFromEulers(0f, 0f, sit_angle); // sit at 0,0,inv-click
1899 m_pos = new Vector3(0f, 0f, 0.05f) +
1900 (new Vector3(0.0f, 0f, 0.625f) * partIRot) +
1901 (new Vector3(0.25f, 0f, 0.0f) * m_bodyRot); // sit at center of prim
1902 m_parentPosition = part.AbsolutePosition; 1917 m_parentPosition = part.AbsolutePosition;
1903 //Set up raytrace to find top surface of prim 1918 if(m_avUnscriptedSitPos != Vector3.Zero)
1904 Vector3 size = part.Scale; 1919 { // sit where clicked on big prim
1905 float mag = 0.1f + (float)Math.Sqrt((size.X * size.X) + (size.Y * size.Y) + (size.Z * size.Z)); 1920 m_pos = m_avUnscriptedSitPos + (new Vector3(0.0f, 0f, 0.625f) * partIRot);
1906 Vector3 start = part.AbsolutePosition + new Vector3(0f, 0f, mag); 1921 }
1907 Vector3 down = new Vector3(0f, 0f, -1f); 1922 else
1908 m_scene.PhysicsScene.RaycastWorld( 1923 { // sit at center of small prim
1909 start, // Vector3 position, 1924 m_pos = new Vector3(0f, 0f, 0.05f) +
1910 down, // Vector3 direction, 1925 (new Vector3(0.0f, 0f, 0.625f) * partIRot) +
1911 mag, // float length, 1926 (new Vector3(0.25f, 0f, 0.0f) * m_bodyRot);
1912 SitAltitudeCallback); // retMethod 1927 //Set up raytrace to find top surface of prim
1913 } 1928 Vector3 size = part.Scale;
1914 } 1929 float mag = 0.1f + (float)Math.Sqrt((size.X * size.X) + (size.Y * size.Y) + (size.Z * size.Z));
1915 else 1930 Vector3 start = part.AbsolutePosition + new Vector3(0f, 0f, mag);
1931 Vector3 down = new Vector3(0f, 0f, -1f);
1932 m_scene.PhysicsScene.RaycastWorld(
1933 start, // Vector3 position,
1934 down, // Vector3 direction,
1935 mag, // float length,
1936 SitAltitudeCallback); // retMethod
1937 } // end small/big
1938 } // end scripted/not
1939 }
1940 else // no Av
1916 { 1941 {
1917 return; 1942 return;
1918 } 1943 }