aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs259
1 files changed, 44 insertions, 215 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index c4f4021..e510f75 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -91,6 +91,7 @@ namespace OpenSim.Region.Framework.Scenes
91 //private SceneObjectPart proxyObjectPart = null; 91 //private SceneObjectPart proxyObjectPart = null;
92 public Vector3 lastKnownAllowedPosition; 92 public Vector3 lastKnownAllowedPosition;
93 public bool sentMessageAboutRestrictedParcelFlyingDown; 93 public bool sentMessageAboutRestrictedParcelFlyingDown;
94 public Vector4 CollisionPlane = Vector4.UnitW;
94 95
95 private Vector3 m_lastPosition; 96 private Vector3 m_lastPosition;
96 private Quaternion m_lastRotation; 97 private Quaternion m_lastRotation;
@@ -130,10 +131,8 @@ namespace OpenSim.Region.Framework.Scenes
130 private bool m_setAlwaysRun; 131 private bool m_setAlwaysRun;
131 132
132 private string m_movementAnimation = "DEFAULT"; 133 private string m_movementAnimation = "DEFAULT";
133 private long m_animPersistUntil;
134 private int m_animTickFall; 134 private int m_animTickFall;
135 private int m_animTickJump; 135 private int m_animTickJump;
136 private bool m_allowFalling;
137 private bool m_useFlySlow; 136 private bool m_useFlySlow;
138 private bool m_usePreJump; 137 private bool m_usePreJump;
139 private bool m_forceFly; 138 private bool m_forceFly;
@@ -2045,208 +2044,10 @@ namespace OpenSim.Region.Framework.Scenes
2045 /// </summary> 2044 /// </summary>
2046 public string GetMovementAnimation() 2045 public string GetMovementAnimation()
2047 { 2046 {
2048 if ((m_animPersistUntil > 0) && (m_animPersistUntil > DateTime.Now.Ticks))
2049 {
2050 //We don't want our existing state to end yet.
2051 return m_movementAnimation;
2052
2053 }
2054 else if (m_movementflag != 0)
2055 {
2056 //We're moving
2057 m_allowFalling = true;
2058 if (PhysicsActor != null && PhysicsActor.IsColliding)
2059 {
2060 //And colliding. Can you guess what it is yet?
2061 if ((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0)
2062 {
2063 //Down key is being pressed.
2064 if ((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) + (m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) != 0)
2065 {
2066 return "CROUCHWALK";
2067 }
2068 else
2069 {
2070 return "CROUCH";
2071 }
2072 }
2073 else if (m_setAlwaysRun)
2074 {
2075 return "RUN";
2076 }
2077 else
2078 {
2079 //If we're prejumping then inhibit this, it's a problem
2080 //caused by a false positive on IsColliding
2081 if (m_movementAnimation == "PREJUMP")
2082 {
2083 return "PREJUMP";
2084 }
2085 else
2086 {
2087 return "WALK";
2088 }
2089 }
2090
2091 }
2092 else
2093 {
2094 //We're not colliding. Colliding isn't cool these days.
2095 if (PhysicsActor != null && PhysicsActor.Flying)
2096 {
2097 //Are we moving forwards or backwards?
2098 if ((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) != 0 || (m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) != 0)
2099 {
2100 //Then we really are flying
2101 if (m_setAlwaysRun)
2102 {
2103 return "FLY";
2104 }
2105 else
2106 {
2107 if (m_useFlySlow == false)
2108 {
2109 return "FLY";
2110 }
2111 else
2112 {
2113 return "FLYSLOW";
2114 }
2115 }
2116 }
2117 else
2118 {
2119 if ((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0)
2120 {
2121 return "HOVER_UP";
2122 }
2123 else
2124 {
2125 return "HOVER_DOWN";
2126 }
2127 }
2128
2129 }
2130 else if (m_movementAnimation == "JUMP")
2131 {
2132 //If we were already jumping, continue to jump until we collide
2133 return "JUMP";
2134
2135 }
2136 else if (m_movementAnimation == "PREJUMP" && (m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) == 0)
2137 {
2138 //If we were in a prejump, and the UP key is no longer being held down
2139 //then we're not going to fly, so we're jumping
2140 return "JUMP";
2141
2142 }
2143 else if ((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0)
2144 {
2145 //They're pressing up, so we're either going to fly or jump
2146 return "PREJUMP";
2147 }
2148 else
2149 {
2150 //If we're moving and not flying and not jumping and not colliding..
2151
2152 if (m_movementAnimation == "WALK" || m_movementAnimation == "RUN")
2153 {
2154 //Let's not enter a FALLDOWN state here, since we're probably
2155 //not colliding because we're going down hill.
2156 return m_movementAnimation;
2157 }
2158 //Record the time we enter this state so we know whether to "land" or not
2159 m_animPersistUntil = DateTime.Now.Ticks;
2160 return "FALLDOWN";
2161
2162 }
2163 }
2164 }
2165 else
2166 {
2167 //We're not moving.
2168 if (PhysicsActor != null && PhysicsActor.IsColliding)
2169 {
2170 //But we are colliding.
2171 if (m_movementAnimation == "FALLDOWN")
2172 {
2173 //We're re-using the m_animPersistUntil value here to see how long we've been falling
2174 if ((DateTime.Now.Ticks - m_animPersistUntil) > TimeSpan.TicksPerSecond)
2175 {
2176 //Make sure we don't change state for a bit
2177 m_animPersistUntil = DateTime.Now.Ticks + TimeSpan.TicksPerSecond;
2178 return "LAND";
2179 }
2180 else
2181 {
2182 //We haven't been falling very long, we were probably just walking down hill
2183 return "STAND";
2184 }
2185 }
2186 else if (m_movementAnimation == "JUMP" || m_movementAnimation == "HOVER_DOWN")
2187 {
2188 //Make sure we don't change state for a bit
2189 m_animPersistUntil = DateTime.Now.Ticks + (1 * TimeSpan.TicksPerSecond);
2190 return "SOFT_LAND";
2191
2192 }
2193 else if ((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0)
2194 {
2195 return "PREJUMP";
2196 }
2197 else if (PhysicsActor != null && PhysicsActor.Flying)
2198 {
2199 m_allowFalling = true;
2200 if ((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0)
2201 {
2202 return "HOVER_UP";
2203 }
2204 else if ((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0)
2205 {
2206 return "HOVER_DOWN";
2207 }
2208 else
2209 {
2210 return "HOVER";
2211 }
2212 }
2213 else
2214 {
2215 return "STAND";
2216 }
2217
2218 }
2219 else
2220 {
2221 //We're not colliding.
2222 if (PhysicsActor != null && PhysicsActor.Flying)
2223 {
2224
2225 return "HOVER";
2226
2227 }
2228 else if ((m_movementAnimation == "JUMP" || m_movementAnimation == "PREJUMP") && (m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) == 0)
2229 {
2230
2231 return "JUMP";
2232
2233 }
2234 else
2235 {
2236 //Record the time we enter this state so we know whether to "land" or not
2237 m_animPersistUntil = DateTime.Now.Ticks;
2238 return "FALLDOWN"; // this falling animation is invoked too frequently when capsule tilt correction is used - why?
2239 }
2240 }
2241 }
2242 }
2243
2244 public string GetMovementAnimation2()
2245 {
2246 const float FALL_DELAY = 0.33f; 2047 const float FALL_DELAY = 0.33f;
2247 const float PREJUMP_DELAY = 0.25f; 2048 const float PREJUMP_DELAY = 0.25f;
2248 2049
2249 m_allowFalling = true; 2050 #region Inputs
2250 2051
2251 AgentManager.ControlFlags controlFlags = (AgentManager.ControlFlags)m_AgentControlFlags; 2052 AgentManager.ControlFlags controlFlags = (AgentManager.ControlFlags)m_AgentControlFlags;
2252 PhysicsActor actor = m_physicsActor; 2053 PhysicsActor actor = m_physicsActor;
@@ -2281,6 +2082,8 @@ namespace OpenSim.Region.Framework.Scenes
2281 bool moving = (move != Vector3.Zero); 2082 bool moving = (move != Vector3.Zero);
2282 bool jumping = m_animTickJump != 0; 2083 bool jumping = m_animTickJump != 0;
2283 2084
2085 #endregion Inputs
2086
2284 #region Flying 2087 #region Flying
2285 2088
2286 if (actor != null && actor.Flying) 2089 if (actor != null && actor.Flying)
@@ -2410,24 +2213,16 @@ namespace OpenSim.Region.Framework.Scenes
2410 /// </summary> 2213 /// </summary>
2411 protected void UpdateMovementAnimations() 2214 protected void UpdateMovementAnimations()
2412 { 2215 {
2413 string movementAnimation = GetMovementAnimation2(); 2216 m_movementAnimation = GetMovementAnimation();
2414 2217
2415 if (movementAnimation == "FALLDOWN" && m_allowFalling == false) 2218 if (m_movementAnimation == "PREJUMP" && !m_usePreJump)
2416 {
2417 movementAnimation = m_movementAnimation;
2418 }
2419 else
2420 {
2421 m_movementAnimation = movementAnimation;
2422 }
2423 if (movementAnimation == "PREJUMP" && m_usePreJump == false)
2424 { 2219 {
2425 //This was the previous behavior before PREJUMP 2220 // This was the previous behavior before PREJUMP
2426 TrySetMovementAnimation("JUMP"); 2221 TrySetMovementAnimation("JUMP");
2427 } 2222 }
2428 else 2223 else
2429 { 2224 {
2430 TrySetMovementAnimation(movementAnimation); 2225 TrySetMovementAnimation(m_movementAnimation);
2431 } 2226 }
2432 } 2227 }
2433 2228
@@ -2574,13 +2369,16 @@ namespace OpenSim.Region.Framework.Scenes
2574 { 2369 {
2575 m_perfMonMS = Environment.TickCount; 2370 m_perfMonMS = Environment.TickCount;
2576 2371
2372 PhysicsActor actor = m_physicsActor;
2373 Vector3 velocity = (actor != null) ? actor.Velocity : Vector3.Zero;
2374
2577 Vector3 pos = m_pos; 2375 Vector3 pos = m_pos;
2578 pos.Z += m_appearance.HipOffset; 2376 pos.Z += m_appearance.HipOffset;
2579 2377
2580 //m_log.DebugFormat("[SCENEPRESENCE]: TerseUpdate: Pos={0} Rot={1} Vel={2}", m_pos, m_bodyRot, m_velocity); 2378 //m_log.DebugFormat("[SCENEPRESENCE]: TerseUpdate: Pos={0} Rot={1} Vel={2}", m_pos, m_bodyRot, m_velocity);
2581 2379
2582 remoteClient.SendAvatarTerseUpdate(new SendAvatarTerseData(m_regionHandle, (ushort)(m_scene.TimeDilation * ushort.MaxValue), LocalId, 2380 remoteClient.SendAvatarTerseUpdate(new SendAvatarTerseData(m_regionHandle, (ushort)(m_scene.TimeDilation * ushort.MaxValue), LocalId,
2583 pos, m_physicsActor.Velocity, Vector3.Zero, m_bodyRot, Vector4.UnitW, m_uuid, null, GetUpdatePriority(remoteClient))); 2381 pos, velocity, Vector3.Zero, m_bodyRot, CollisionPlane, m_uuid, null, GetUpdatePriority(remoteClient)));
2584 2382
2585 m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); 2383 m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS);
2586 m_scene.StatsReporter.AddAgentUpdates(1); 2384 m_scene.StatsReporter.AddAgentUpdates(1);
@@ -3527,6 +3325,37 @@ namespace OpenSim.Region.Framework.Scenes
3527 CollisionEventUpdate collisionData = (CollisionEventUpdate)e; 3325 CollisionEventUpdate collisionData = (CollisionEventUpdate)e;
3528 Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList; 3326 Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList;
3529 3327
3328 CollisionPlane = Vector4.UnitW;
3329
3330 if (coldata.Count != 0)
3331 {
3332 switch (m_movementAnimation)
3333 {
3334 case "STAND":
3335 case "WALK":
3336 case "RUN":
3337 case "CROUCH":
3338 case "CROUCHWALK":
3339 {
3340 ContactPoint lowest;
3341 lowest.SurfaceNormal = Vector3.Zero;
3342 lowest.Position = Vector3.Zero;
3343 lowest.Position.Z = Single.NaN;
3344
3345 foreach (ContactPoint contact in coldata.Values)
3346 {
3347 if (Single.IsNaN(lowest.Position.Z) || contact.Position.Z < lowest.Position.Z)
3348 {
3349 lowest = contact;
3350 }
3351 }
3352
3353 CollisionPlane = new Vector4(-lowest.SurfaceNormal, -Vector3.Dot(lowest.Position, lowest.SurfaceNormal));
3354 }
3355 break;
3356 }
3357 }
3358
3530 if (m_invulnerable) 3359 if (m_invulnerable)
3531 return; 3360 return;
3532 3361