diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 169 |
1 files changed, 74 insertions, 95 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 5946979..e6a366d 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -287,14 +287,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
287 | set { PhysicsActor.Flying = value; } | 287 | set { PhysicsActor.Flying = value; } |
288 | } | 288 | } |
289 | 289 | ||
290 | // add for fly velocity control | 290 | public bool IsColliding |
291 | private bool FlyingOld {get; set;} | ||
292 | public bool WasFlying | ||
293 | { | ||
294 | get; private set; | ||
295 | } | ||
296 | |||
297 | public bool IsColliding | ||
298 | { | 291 | { |
299 | get { return PhysicsActor != null && PhysicsActor.IsColliding; } | 292 | get { return PhysicsActor != null && PhysicsActor.IsColliding; } |
300 | // We would expect setting IsColliding to be private but it's used by a hack in Scene | 293 | // We would expect setting IsColliding to be private but it's used by a hack in Scene |
@@ -936,7 +929,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
936 | /// <remarks> | 929 | /// <remarks> |
937 | /// AGENT_CONTRL_STOP comes about if user holds down space key on viewers. | 930 | /// AGENT_CONTRL_STOP comes about if user holds down space key on viewers. |
938 | /// </remarks> | 931 | /// </remarks> |
939 | private float AgentControlStopSlowWhilstMoving = 0.5f; | 932 | private float AgentControlStopSlowWhilstMoving = 0.2f; |
940 | 933 | ||
941 | private bool m_forceFly; | 934 | private bool m_forceFly; |
942 | 935 | ||
@@ -2174,7 +2167,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2174 | bool DCFlagKeyPressed = false; | 2167 | bool DCFlagKeyPressed = false; |
2175 | Vector3 agent_control_v3 = Vector3.Zero; | 2168 | Vector3 agent_control_v3 = Vector3.Zero; |
2176 | 2169 | ||
2177 | bool newFlying = actor.Flying; | 2170 | bool newFlying = false; |
2178 | 2171 | ||
2179 | if (ForceFly) | 2172 | if (ForceFly) |
2180 | newFlying = true; | 2173 | newFlying = true; |
@@ -2286,11 +2279,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
2286 | if (Flying && !ForceFly) | 2279 | if (Flying && !ForceFly) |
2287 | { | 2280 | { |
2288 | // Need to stop in mid air if user holds down AGENT_CONTROL_STOP | 2281 | // Need to stop in mid air if user holds down AGENT_CONTROL_STOP |
2289 | if (AgentControlStopActive) | 2282 | // if (AgentControlStopActive) |
2290 | { | 2283 | // { |
2291 | agent_control_v3 = Vector3.Zero; | 2284 | // agent_control_v3 = Vector3.Zero; |
2292 | } | 2285 | // } |
2293 | else | 2286 | // else |
2294 | { | 2287 | { |
2295 | // Landing detection code | 2288 | // Landing detection code |
2296 | 2289 | ||
@@ -2298,38 +2291,44 @@ namespace OpenSim.Region.Framework.Scenes | |||
2298 | bool controlland = (((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || | 2291 | bool controlland = (((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || |
2299 | ((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); | 2292 | ((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); |
2300 | 2293 | ||
2301 | //m_log.Debug("[CONTROL]: " +flags); | 2294 | //m_log.Debug("[CONTROL]: " +flags); |
2302 | // Applies a satisfying roll effect to the avatar when flying. | 2295 | // Applies a satisfying roll effect to the avatar when flying. |
2303 | if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) != 0 && (flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0) | 2296 | if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) != 0 && (flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0) |
2304 | { | 2297 | { |
2305 | ApplyFlyingRoll( | 2298 | ApplyFlyingRoll( |
2306 | FLY_ROLL_RADIANS_PER_UPDATE, | 2299 | FLY_ROLL_RADIANS_PER_UPDATE, |
2307 | (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0, | 2300 | (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0, |
2308 | (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0); | 2301 | (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0); |
2309 | } | 2302 | } |
2310 | else if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) != 0 && | 2303 | else if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) != 0 && |
2311 | (flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0) | 2304 | (flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0) |
2312 | { | 2305 | { |
2313 | ApplyFlyingRoll( | 2306 | ApplyFlyingRoll( |
2314 | -FLY_ROLL_RADIANS_PER_UPDATE, | 2307 | -FLY_ROLL_RADIANS_PER_UPDATE, |
2315 | (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0, | 2308 | (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0, |
2316 | (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0); | 2309 | (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0); |
2317 | } | 2310 | } |
2318 | else | 2311 | else |
2319 | { | 2312 | { |
2320 | if (m_AngularVelocity.Z != 0) | 2313 | if (m_AngularVelocity.Z != 0) |
2321 | m_AngularVelocity.Z += CalculateFlyingRollResetToZero(FLY_ROLL_RESET_RADIANS_PER_UPDATE); | 2314 | m_AngularVelocity.Z += CalculateFlyingRollResetToZero(FLY_ROLL_RESET_RADIANS_PER_UPDATE); |
2322 | } | ||
2323 | |||
2324 | if (Flying && IsColliding && controlland) | ||
2325 | { | ||
2326 | // nesting this check because LengthSquared() is expensive and we don't | ||
2327 | // want to do it every step when flying. | ||
2328 | if ((Velocity.LengthSquared() <= LAND_VELOCITYMAG_MAX)) | ||
2329 | StopFlying(); | ||
2330 | } | 2315 | } |
2316 | |||
2317 | /* | ||
2318 | if (Flying && IsColliding && controlland) | ||
2319 | { | ||
2320 | // nesting this check because LengthSquared() is expensive and we don't | ||
2321 | // want to do it every step when flying. | ||
2322 | if ((Velocity.LengthSquared() <= LAND_VELOCITYMAG_MAX)) | ||
2323 | StopFlying(); | ||
2324 | } | ||
2325 | */ | ||
2331 | } | 2326 | } |
2332 | } | 2327 | } |
2328 | else if (IsColliding && agent_control_v3.Z < 0f) | ||
2329 | agent_control_v3.Z = 0; | ||
2330 | // else if(AgentControlStopActive %% Velocity.Z <0.01f) | ||
2331 | |||
2333 | 2332 | ||
2334 | // m_log.DebugFormat("[SCENE PRESENCE]: MovementFlag {0} for {1}", MovementFlag, Name); | 2333 | // m_log.DebugFormat("[SCENE PRESENCE]: MovementFlag {0} for {1}", MovementFlag, Name); |
2335 | 2334 | ||
@@ -2342,32 +2341,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
2342 | if (update_movementflag | 2341 | if (update_movementflag |
2343 | || (update_rotation && DCFlagKeyPressed && (!AgentControlStopActive || MovementFlag != 0))) | 2342 | || (update_rotation && DCFlagKeyPressed && (!AgentControlStopActive || MovementFlag != 0))) |
2344 | { | 2343 | { |
2345 | // if (update_movementflag || !AgentControlStopActive || MovementFlag != 0) | ||
2346 | // { | ||
2347 | // m_log.DebugFormat( | ||
2348 | // "[SCENE PRESENCE]: In {0} adding velocity of {1} to {2}, umf = {3}, mf = {4}, ur = {5}", | ||
2349 | // m_scene.RegionInfo.RegionName, agent_control_v3, Name, | ||
2350 | // update_movementflag, MovementFlag, update_rotation); | ||
2351 | |||
2352 | float speedModifier; | ||
2353 | 2344 | ||
2354 | if (AgentControlStopActive) | 2345 | if (AgentControlStopActive) |
2355 | speedModifier = AgentControlStopSlowWhilstMoving; | 2346 | { |
2347 | // if (MovementFlag == 0 && Animator.Falling) | ||
2348 | if (MovementFlag == 0 && Animator.currentControlState == ScenePresenceAnimator.motionControlStates.falling) | ||
2349 | { | ||
2350 | AddNewMovement(agent_control_v3, AgentControlStopSlowWhilstMoving, true); | ||
2351 | } | ||
2356 | else | 2352 | else |
2357 | speedModifier = 1; | 2353 | AddNewMovement(agent_control_v3, AgentControlStopSlowWhilstMoving); |
2354 | } | ||
2355 | |||
2356 | else | ||
2357 | AddNewMovement(agent_control_v3); | ||
2358 | 2358 | ||
2359 | AddNewMovement(agent_control_v3, speedModifier); | ||
2360 | // } | ||
2361 | } | 2359 | } |
2362 | // else | ||
2363 | // { | ||
2364 | // if (!update_movementflag) | ||
2365 | // { | ||
2366 | // m_log.DebugFormat( | ||
2367 | // "[SCENE PRESENCE]: In {0} ignoring requested update of {1} for {2} as update_movementflag = false", | ||
2368 | // m_scene.RegionInfo.RegionName, agent_control_v3, Name); | ||
2369 | // } | ||
2370 | // } | ||
2371 | 2360 | ||
2372 | if (update_movementflag && ParentID == 0) | 2361 | if (update_movementflag && ParentID == 0) |
2373 | { | 2362 | { |
@@ -3246,68 +3235,58 @@ namespace OpenSim.Region.Framework.Scenes | |||
3246 | /// <param name="vec">The vector in which to move. This is relative to the rotation argument</param> | 3235 | /// <param name="vec">The vector in which to move. This is relative to the rotation argument</param> |
3247 | /// <param name="thisAddSpeedModifier"> | 3236 | /// <param name="thisAddSpeedModifier"> |
3248 | /// Optional additional speed modifier for this particular add. Default is 1</param> | 3237 | /// Optional additional speed modifier for this particular add. Default is 1</param> |
3249 | public void AddNewMovement(Vector3 vec, float thisAddSpeedModifier = 1) | 3238 | public void AddNewMovement(Vector3 vec, float thisAddSpeedModifier = 1, bool breaking = false) |
3250 | { | 3239 | { |
3251 | // m_log.DebugFormat( | 3240 | // m_log.DebugFormat( |
3252 | // "[SCENE PRESENCE]: Adding new movement {0} with rotation {1}, thisAddSpeedModifier {2} for {3}", | 3241 | // "[SCENE PRESENCE]: Adding new movement {0} with rotation {1}, thisAddSpeedModifier {2} for {3}", |
3253 | // vec, Rotation, thisAddSpeedModifier, Name); | 3242 | // vec, Rotation, thisAddSpeedModifier, Name); |
3254 | 3243 | ||
3255 | Vector3 direc = vec * Rotation; | 3244 | Vector3 direc = vec * Rotation; |
3256 | direc.Normalize(); | 3245 | direc.Normalize(); |
3257 | 3246 | ||
3258 | if (Flying != FlyingOld) // add for fly velocity control | ||
3259 | { | ||
3260 | FlyingOld = Flying; // add for fly velocity control | ||
3261 | if (!Flying) | ||
3262 | WasFlying = true; // add for fly velocity control | ||
3263 | } | ||
3264 | |||
3265 | if (IsColliding) | ||
3266 | WasFlying = false; // add for fly velocity control | ||
3267 | |||
3268 | if ((vec.Z == 0f) && !Flying) | 3247 | if ((vec.Z == 0f) && !Flying) |
3269 | direc.Z = 0f; // Prevent camera WASD up. | 3248 | direc.Z = 0f; // Prevent camera WASD up. |
3270 | 3249 | ||
3271 | direc *= 0.03f * 128f * SpeedModifier * thisAddSpeedModifier; | 3250 | direc *= 0.03f * 128f * SpeedModifier * thisAddSpeedModifier; |
3272 | 3251 | ||
3273 | // m_log.DebugFormat("[SCENE PRESENCE]: Force to apply before modification was {0} for {1}", direc, Name); | 3252 | // m_log.DebugFormat("[SCENE PRESENCE]: Force to apply before modification was {0} for {1}", direc, Name); |
3274 | 3253 | ||
3275 | if (PhysicsActor != null) | 3254 | if (Animator.currentControlState == ScenePresenceAnimator.motionControlStates.falling) |
3276 | { | 3255 | { |
3277 | if (Flying) | 3256 | if (breaking) |
3278 | { | 3257 | direc.Z = -9999f; //hack |
3258 | else | ||
3259 | direc = Vector3.Zero; | ||
3260 | } | ||
3261 | else if (Flying) | ||
3262 | { | ||
3263 | if(IsColliding) | ||
3264 | direc = Vector3.Zero; | ||
3265 | else | ||
3279 | direc *= 4.0f; | 3266 | direc *= 4.0f; |
3280 | //bool controlland = (((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || ((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); | 3267 | } |
3281 | //if (controlland) | 3268 | else if (IsColliding) |
3282 | // m_log.Info("[AGENT]: landCommand"); | 3269 | { |
3283 | //if (IsColliding) | 3270 | if (direc.Z > 2.0f) |
3284 | // m_log.Info("[AGENT]: colliding"); | ||
3285 | //if (Flying && IsColliding && controlland) | ||
3286 | //{ | ||
3287 | // StopFlying(); | ||
3288 | // m_log.Info("[AGENT]: Stop Flying"); | ||
3289 | //} | ||
3290 | } | ||
3291 | if (Animator.Falling && WasFlying) // if falling from flying, disable motion add | ||
3292 | { | 3271 | { |
3293 | direc *= 0.0f; | 3272 | direc.Z *= 2.6f; |
3294 | } | 3273 | } |
3295 | else if (!Flying && IsColliding) | 3274 | else if (direc.Z < 0) |
3275 | direc.Z = 0; | ||
3276 | /* | ||
3277 | float c = CollisionPlane.Z; | ||
3278 | if (c > 0.2f && c < 0.94f && (direc.X != 0 || direc.Y != 0)) | ||
3296 | { | 3279 | { |
3297 | if (direc.Z > 2.0f) | 3280 | float p = direc.X * CollisionPlane.X + direc.Y * CollisionPlane.Y; |
3298 | { | 3281 | direc.X -= p * CollisionPlane.X; |
3299 | direc.Z *= 2.6f; | 3282 | direc.Y -= p * CollisionPlane.Y; |
3300 | 3283 | direc.Z -= p * c; | |
3301 | // TODO: PreJump and jump happen too quickly. Many times prejump gets ignored. | ||
3302 | // Animator.TrySetMovementAnimation("PREJUMP"); | ||
3303 | // Animator.TrySetMovementAnimation("JUMP"); | ||
3304 | } | ||
3305 | } | 3284 | } |
3285 | */ | ||
3306 | } | 3286 | } |
3307 | 3287 | ||
3308 | // m_log.DebugFormat("[SCENE PRESENCE]: Setting force to apply to {0} for {1}", direc, Name); | 3288 | // m_log.DebugFormat("[SCENE PRESENCE]: Setting force to apply to {0} for {1}", direc, Name); |
3309 | 3289 | ||
3310 | // TODO: Add the force instead of only setting it to support multiple forces per frame? | ||
3311 | m_forceToApply = direc; | 3290 | m_forceToApply = direc; |
3312 | Animator.UpdateMovementAnimations(); | 3291 | Animator.UpdateMovementAnimations(); |
3313 | } | 3292 | } |