diff options
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs | 15 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 125 |
2 files changed, 91 insertions, 49 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index ba11800..b031f61 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs | |||
@@ -53,8 +53,8 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
53 | { | 53 | { |
54 | get { return m_movementAnimation; } | 54 | get { return m_movementAnimation; } |
55 | } | 55 | } |
56 | protected string m_movementAnimation = "DEFAULT"; | 56 | // protected string m_movementAnimation = "DEFAULT"; //KF: 'DEFAULT' does not exist! |
57 | 57 | protected string m_movementAnimation = "CROUCH"; //KF: CROUCH ensures reliable Av Anim. init. | |
58 | private int m_animTickFall; | 58 | private int m_animTickFall; |
59 | private int m_animTickJump; | 59 | private int m_animTickJump; |
60 | 60 | ||
@@ -123,17 +123,22 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
123 | /// </summary> | 123 | /// </summary> |
124 | public void TrySetMovementAnimation(string anim) | 124 | public void TrySetMovementAnimation(string anim) |
125 | { | 125 | { |
126 | //m_log.DebugFormat("Updating movement animation to {0}", anim); | 126 | //Console.WriteLine("Updating movement animation to {0}", anim); |
127 | 127 | ||
128 | if (!m_scenePresence.IsChildAgent) | 128 | if (!m_scenePresence.IsChildAgent) |
129 | { | 129 | { |
130 | if (m_animations.TrySetDefaultAnimation( | 130 | if (m_animations.TrySetDefaultAnimation( |
131 | anim, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, UUID.Zero)) | 131 | anim, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, UUID.Zero)) |
132 | { | 132 | { |
133 | //Console.WriteLine("TSMA {0} success.", anim); | ||
133 | // 16384 is CHANGED_ANIMATION | 134 | // 16384 is CHANGED_ANIMATION |
134 | m_scenePresence.SendScriptEventToAttachments("changed", new Object[] { 16384 }); | 135 | m_scenePresence.SendScriptEventToAttachments("changed", new Object[] { 16384 }); |
135 | SendAnimPack(); | 136 | SendAnimPack(); |
136 | } | 137 | } |
138 | else | ||
139 | { | ||
140 | //Console.WriteLine("TSMA {0} fail.", anim); | ||
141 | } | ||
137 | } | 142 | } |
138 | } | 143 | } |
139 | 144 | ||
@@ -312,7 +317,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
312 | public void UpdateMovementAnimations() | 317 | public void UpdateMovementAnimations() |
313 | { | 318 | { |
314 | m_movementAnimation = GetMovementAnimation(); | 319 | m_movementAnimation = GetMovementAnimation(); |
315 | 320 | //Console.WriteLine("UMA got {0}", m_movementAnimation); | |
316 | if (m_movementAnimation == "PREJUMP" && !m_scenePresence.Scene.m_usePreJump) | 321 | if (m_movementAnimation == "PREJUMP" && !m_scenePresence.Scene.m_usePreJump) |
317 | { | 322 | { |
318 | // This was the previous behavior before PREJUMP | 323 | // This was the previous behavior before PREJUMP |
@@ -444,4 +449,4 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
444 | SendAnimPack(animIDs, sequenceNums, objectIDs); | 449 | SendAnimPack(animIDs, sequenceNums, objectIDs); |
445 | } | 450 | } |
446 | } | 451 | } |
447 | } \ No newline at end of file | 452 | } |
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index a1bb244..cebd108 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -90,6 +90,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
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 | // Value revised by KF 091121 by comparison with SL. | ||
93 | private static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.0f, 0.0f, 0.418f); | 94 | private static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.0f, 0.0f, 0.418f); |
94 | 95 | ||
95 | public UUID currentParcelUUID = UUID.Zero; | 96 | public UUID currentParcelUUID = UUID.Zero; |
@@ -116,6 +117,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
116 | public Vector4 CollisionPlane = Vector4.UnitW; | 117 | public Vector4 CollisionPlane = Vector4.UnitW; |
117 | 118 | ||
118 | 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 | ||
119 | private Vector3 m_lastPosition; | 121 | private Vector3 m_lastPosition; |
120 | private Quaternion m_lastRotation; | 122 | private Quaternion m_lastRotation; |
121 | private Vector3 m_lastVelocity; | 123 | private Vector3 m_lastVelocity; |
@@ -205,6 +207,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
205 | private bool m_followCamAuto; | 207 | private bool m_followCamAuto; |
206 | 208 | ||
207 | private int m_movementUpdateCount; | 209 | private int m_movementUpdateCount; |
210 | private int m_lastColCount = -1; //KF: Look for Collision chnages | ||
211 | private int m_updateCount = 0; //KF: Update Anims for a while | ||
212 | private static readonly int UPDATE_COUNT = 10; // how many frames to update for | ||
208 | 213 | ||
209 | private const int NumMovementsBetweenRayCast = 5; | 214 | private const int NumMovementsBetweenRayCast = 5; |
210 | 215 | ||
@@ -664,9 +669,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
664 | 669 | ||
665 | AdjustKnownSeeds(); | 670 | AdjustKnownSeeds(); |
666 | 671 | ||
667 | // TODO: I think, this won't send anything, as we are still a child here... | 672 | Animator.TrySetMovementAnimation("STAND"); |
668 | Animator.TrySetMovementAnimation("STAND"); | ||
669 | |||
670 | // we created a new ScenePresence (a new child agent) in a fresh region. | 673 | // we created a new ScenePresence (a new child agent) in a fresh region. |
671 | // Request info about all the (root) agents in this region | 674 | // Request info about all the (root) agents in this region |
672 | // Note: This won't send data *to* other clients in that region (children don't send) | 675 | // Note: This won't send data *to* other clients in that region (children don't send) |
@@ -1026,7 +1029,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1026 | { | 1029 | { |
1027 | AbsolutePosition = AbsolutePosition + new Vector3(0f, 0f, (1.56f / 6f)); | 1030 | AbsolutePosition = AbsolutePosition + new Vector3(0f, 0f, (1.56f / 6f)); |
1028 | } | 1031 | } |
1029 | 1032 | ||
1033 | m_updateCount = UPDATE_COUNT; //KF: Trigger Anim updates to catch falling anim. | ||
1034 | |||
1030 | ControllingClient.SendAvatarTerseUpdate(new SendAvatarTerseData(m_rootRegionHandle, (ushort)(m_scene.TimeDilation * ushort.MaxValue), LocalId, | 1035 | ControllingClient.SendAvatarTerseUpdate(new SendAvatarTerseData(m_rootRegionHandle, (ushort)(m_scene.TimeDilation * ushort.MaxValue), LocalId, |
1031 | AbsolutePosition, Velocity, Vector3.Zero, m_bodyRot, new Vector4(0,0,1,AbsolutePosition.Z - 0.5f), m_uuid, null, GetUpdatePriority(ControllingClient))); | 1036 | AbsolutePosition, Velocity, Vector3.Zero, m_bodyRot, new Vector4(0,0,1,AbsolutePosition.Z - 0.5f), m_uuid, null, GetUpdatePriority(ControllingClient))); |
1032 | } | 1037 | } |
@@ -1274,9 +1279,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1274 | 1279 | ||
1275 | if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0) | 1280 | if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0) |
1276 | { | 1281 | { |
1277 | // TODO: This doesn't prevent the user from walking yet. | 1282 | m_updateCount = 0; // Kill animation update burst so that the SIT_G.. will stick. |
1278 | // Setting parent ID would fix this, if we knew what value | ||
1279 | // to use. Or we could add a m_isSitting variable. | ||
1280 | Animator.TrySetMovementAnimation("SIT_GROUND_CONSTRAINED"); | 1283 | Animator.TrySetMovementAnimation("SIT_GROUND_CONSTRAINED"); |
1281 | } | 1284 | } |
1282 | 1285 | ||
@@ -1648,9 +1651,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1648 | { | 1651 | { |
1649 | AddToPhysicalScene(false); | 1652 | AddToPhysicalScene(false); |
1650 | } | 1653 | } |
1651 | |||
1652 | m_pos += m_parentPosition + new Vector3(0.0f, 0.0f, 2.0f*m_sitAvatarHeight); | 1654 | m_pos += m_parentPosition + new Vector3(0.0f, 0.0f, 2.0f*m_sitAvatarHeight); |
1653 | m_parentPosition = Vector3.Zero; | 1655 | m_parentPosition = Vector3.Zero; |
1656 | //Console.WriteLine("Stand Pos {0}", m_pos); | ||
1654 | 1657 | ||
1655 | m_parentID = 0; | 1658 | m_parentID = 0; |
1656 | SendFullUpdateToAllClients(); | 1659 | SendFullUpdateToAllClients(); |
@@ -1744,21 +1747,37 @@ namespace OpenSim.Region.Framework.Scenes | |||
1744 | 1747 | ||
1745 | //Console.WriteLine("SendSitResponse offset=" + offset + " UnOccup=" + SitTargetUnOccupied + | 1748 | //Console.WriteLine("SendSitResponse offset=" + offset + " UnOccup=" + SitTargetUnOccupied + |
1746 | // " TargSet=" + SitTargetisSet); | 1749 | // " TargSet=" + SitTargetisSet); |
1747 | 1750 | // Sit analysis rewritten by KF 091125 | |
1748 | if (SitTargetisSet && SitTargetUnOccupied) | 1751 | if (SitTargetisSet) // scipted sit |
1749 | { | 1752 | { |
1750 | part.SetAvatarOnSitTarget(UUID); | 1753 | if (SitTargetUnOccupied) |
1751 | offset = new Vector3(avSitOffSet.X, avSitOffSet.Y, avSitOffSet.Z); | 1754 | { |
1752 | sitOrientation = avSitOrientation; | 1755 | part.SetAvatarOnSitTarget(UUID); // set that Av will be on it |
1753 | autopilot = false; // Jump direct to scripted llSitPos() | 1756 | offset = new Vector3(avSitOffSet.X, avSitOffSet.Y, avSitOffSet.Z); // change ofset to the scripted one |
1754 | } | 1757 | sitOrientation = avSitOrientation; // Change rotatione to the scripted one |
1758 | autopilot = false; // Jump direct to scripted llSitPos() | ||
1759 | } | ||
1760 | else return; | ||
1761 | } | ||
1762 | else // Not Scripted | ||
1763 | { | ||
1764 | if ( (Math.Abs(offset.X) > 0.5f) || (Math.Abs(offset.Y) > 0.5f) ) // large prim | ||
1765 | { | ||
1766 | Quaternion partIRot = Quaternion.Inverse(part.GetWorldRotation()); | ||
1767 | m_avUnscriptedSitPos = offset * partIRot; // sit where clicked | ||
1768 | pos = part.AbsolutePosition + (offset * partIRot); | ||
1769 | } | ||
1770 | else // small prim | ||
1771 | { | ||
1772 | if (SitTargetUnOccupied) | ||
1773 | { | ||
1774 | m_avUnscriptedSitPos = Vector3.Zero; // Sit on unoccupied small prim center | ||
1775 | pos = part.AbsolutePosition; | ||
1776 | } | ||
1777 | else return; // occupied small | ||
1778 | } // end large/small | ||
1779 | } // end Scripted/not | ||
1755 | 1780 | ||
1756 | pos = part.AbsolutePosition + offset; // Region position where clicked | ||
1757 | //if (Math.Abs(part.AbsolutePosition.Z - AbsolutePosition.Z) > 1) | ||
1758 | //{ | ||
1759 | // offset = pos; | ||
1760 | //autopilot = false; | ||
1761 | //} | ||
1762 | if (m_physicsActor != null) | 1781 | if (m_physicsActor != null) |
1763 | { | 1782 | { |
1764 | // If we're not using the client autopilot, we're immediately warping the avatar to the location | 1783 | // If we're not using the client autopilot, we're immediately warping the avatar to the location |
@@ -1891,8 +1910,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1891 | { | 1910 | { |
1892 | // Non-scripted sit by Kitto Flora 21Nov09 | 1911 | // Non-scripted sit by Kitto Flora 21Nov09 |
1893 | // Calculate angle of line from prim to Av | 1912 | // Calculate angle of line from prim to Av |
1894 | float y_diff = (m_avInitialPos.Y - part.AbsolutePosition.Y); | 1913 | Vector3 sitTargetPos= part.AbsolutePosition + m_avUnscriptedSitPos; |
1895 | float x_diff = ( m_avInitialPos.X - part.AbsolutePosition.X); | 1914 | float y_diff = (m_avInitialPos.Y - sitTargetPos.Y); |
1915 | float x_diff = ( m_avInitialPos.X - sitTargetPos.X); | ||
1896 | if(Math.Abs(x_diff) < 0.001f) x_diff = 0.001f; // avoid div by 0 | 1916 | if(Math.Abs(x_diff) < 0.001f) x_diff = 0.001f; // avoid div by 0 |
1897 | if(Math.Abs(y_diff) < 0.001f) y_diff = 0.001f; // avoid pol flip at 0 | 1917 | if(Math.Abs(y_diff) < 0.001f) y_diff = 0.001f; // avoid pol flip at 0 |
1898 | float sit_angle = (float)Math.Atan2( (double)y_diff, (double)x_diff); | 1918 | float sit_angle = (float)Math.Atan2( (double)y_diff, (double)x_diff); |
@@ -1900,23 +1920,30 @@ namespace OpenSim.Region.Framework.Scenes | |||
1900 | // NOTE: when sitting m_ pos and m_bodyRot are *relative* to the prim location/rotation, not 'World'. | 1920 | // NOTE: when sitting m_ pos and m_bodyRot are *relative* to the prim location/rotation, not 'World'. |
1901 | // Av sits at world euler <0,0, z>, translated by part rotation | 1921 | // Av sits at world euler <0,0, z>, translated by part rotation |
1902 | m_bodyRot = partIRot * Quaternion.CreateFromEulers(0f, 0f, sit_angle); // sit at 0,0,inv-click | 1922 | m_bodyRot = partIRot * Quaternion.CreateFromEulers(0f, 0f, sit_angle); // sit at 0,0,inv-click |
1903 | m_pos = new Vector3(0f, 0f, 0.05f) + | ||
1904 | (new Vector3(0.0f, 0f, 0.625f) * partIRot) + | ||
1905 | (new Vector3(0.25f, 0f, 0.0f) * m_bodyRot); // sit at center of prim | ||
1906 | m_parentPosition = part.AbsolutePosition; | 1923 | m_parentPosition = part.AbsolutePosition; |
1907 | //Set up raytrace to find top surface of prim | 1924 | if(m_avUnscriptedSitPos != Vector3.Zero) |
1908 | Vector3 size = part.Scale; | 1925 | { // sit where clicked on big prim |
1909 | float mag = 0.1f + (float)Math.Sqrt((size.X * size.X) + (size.Y * size.Y) + (size.Z * size.Z)); | 1926 | m_pos = m_avUnscriptedSitPos + (new Vector3(0.0f, 0f, 0.625f) * partIRot); |
1910 | Vector3 start = part.AbsolutePosition + new Vector3(0f, 0f, mag); | 1927 | } |
1911 | Vector3 down = new Vector3(0f, 0f, -1f); | 1928 | else |
1912 | m_scene.PhysicsScene.RaycastWorld( | 1929 | { // sit at center of small prim |
1913 | start, // Vector3 position, | 1930 | m_pos = new Vector3(0f, 0f, 0.05f) + |
1914 | down, // Vector3 direction, | 1931 | (new Vector3(0.0f, 0f, 0.625f) * partIRot) + |
1915 | mag, // float length, | 1932 | (new Vector3(0.25f, 0f, 0.0f) * m_bodyRot); |
1916 | SitAltitudeCallback); // retMethod | 1933 | //Set up raytrace to find top surface of prim |
1917 | } | 1934 | Vector3 size = part.Scale; |
1918 | } | 1935 | float mag = 0.1f + (float)Math.Sqrt((size.X * size.X) + (size.Y * size.Y) + (size.Z * size.Z)); |
1919 | else | 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, | ||
1940 | down, // Vector3 direction, | ||
1941 | mag, // float length, | ||
1942 | SitAltitudeCallback); // retMethod | ||
1943 | } // end small/big | ||
1944 | } // end scripted/not | ||
1945 | } | ||
1946 | else // no Av | ||
1920 | { | 1947 | { |
1921 | return; | 1948 | return; |
1922 | } | 1949 | } |
@@ -1932,7 +1959,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1932 | 1959 | ||
1933 | public void SitAltitudeCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance) | 1960 | public void SitAltitudeCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance) |
1934 | { | 1961 | { |
1935 | // Console.WriteLine("[RAYCASTRESULT]: Hit={0}, Point={1}, ID={2}, Dist={3}", hitYN, collisionPoint, localid, distance); | ||
1936 | if(hitYN) | 1962 | if(hitYN) |
1937 | { | 1963 | { |
1938 | // m_pos = Av offset from prim center to make look like on center | 1964 | // m_pos = Av offset from prim center to make look like on center |
@@ -2970,6 +2996,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2970 | m_updateflag = true; | 2996 | m_updateflag = true; |
2971 | Velocity = force; | 2997 | Velocity = force; |
2972 | m_isNudging = false; | 2998 | m_isNudging = false; |
2999 | m_updateCount = UPDATE_COUNT; //KF: Update anims to pickup "STAND" | ||
2973 | } | 3000 | } |
2974 | } | 3001 | } |
2975 | } | 3002 | } |
@@ -3021,19 +3048,29 @@ namespace OpenSim.Region.Framework.Scenes | |||
3021 | // Event called by the physics plugin to tell the avatar about a collision. | 3048 | // Event called by the physics plugin to tell the avatar about a collision. |
3022 | private void PhysicsCollisionUpdate(EventArgs e) | 3049 | private void PhysicsCollisionUpdate(EventArgs e) |
3023 | { | 3050 | { |
3051 | if (m_updateCount > 0) //KF: Update Anims for a short period. Many Anim | ||
3052 | { // changes are very asynchronous. | ||
3053 | Animator.UpdateMovementAnimations(); | ||
3054 | m_updateCount--; | ||
3055 | } | ||
3056 | |||
3024 | if (e == null) | 3057 | if (e == null) |
3025 | return; | 3058 | return; |
3026 | 3059 | ||
3027 | //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f)) | ||
3028 | // The Physics Scene will send updates every 500 ms grep: m_physicsActor.SubscribeEvents( | 3060 | // The Physics Scene will send updates every 500 ms grep: m_physicsActor.SubscribeEvents( |
3029 | // as of this comment the interval is set in AddToPhysicalScene | 3061 | // as of this comment the interval is set in AddToPhysicalScene |
3030 | Animator.UpdateMovementAnimations(); | 3062 | |
3031 | |||
3032 | CollisionEventUpdate collisionData = (CollisionEventUpdate)e; | 3063 | CollisionEventUpdate collisionData = (CollisionEventUpdate)e; |
3033 | Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList; | 3064 | Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList; |
3034 | 3065 | ||
3035 | CollisionPlane = Vector4.UnitW; | 3066 | CollisionPlane = Vector4.UnitW; |
3036 | 3067 | ||
3068 | if (m_lastColCount != coldata.Count) | ||
3069 | { | ||
3070 | m_updateCount = 10; | ||
3071 | m_lastColCount = coldata.Count; | ||
3072 | } | ||
3073 | |||
3037 | if (coldata.Count != 0) | 3074 | if (coldata.Count != 0) |
3038 | { | 3075 | { |
3039 | switch (Animator.CurrentMovementAnimation) | 3076 | switch (Animator.CurrentMovementAnimation) |