aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes')
-rw-r--r--OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs17
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs265
2 files changed, 183 insertions, 99 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
index 5529a25..c1394aa 100644
--- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
+++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
@@ -420,11 +420,18 @@ namespace OpenSim.Region.Framework.Scenes.Animation
420 Falling = false; 420 Falling = false;
421 // Walking / crouchwalking / running 421 // Walking / crouchwalking / running
422 if (move.Z < 0f) 422 if (move.Z < 0f)
423 {
423 return "CROUCHWALK"; 424 return "CROUCHWALK";
424 else if (m_scenePresence.SetAlwaysRun) 425 }
425 return "RUN"; 426 // We need to prevent these animations if the user tries to make their avatar walk or run whilst
426 else 427 // specifying AGENT_CONTROL_STOP (pressing down space on viewers).
427 return "WALK"; 428 else if (!m_scenePresence.AgentControlStopActive)
429 {
430 if (m_scenePresence.SetAlwaysRun)
431 return "RUN";
432 else
433 return "WALK";
434 }
428 } 435 }
429 else if (!m_jumping) 436 else if (!m_jumping)
430 { 437 {
@@ -452,6 +459,8 @@ namespace OpenSim.Region.Framework.Scenes.Animation
452 /// <returns>'true' if the animation was changed</returns> 459 /// <returns>'true' if the animation was changed</returns>
453 public bool UpdateMovementAnimations() 460 public bool UpdateMovementAnimations()
454 { 461 {
462// m_log.DebugFormat("[SCENE PRESENCE ANIMATOR]: Updating movement animations for {0}", m_scenePresence.Name);
463
455 bool ret = false; 464 bool ret = false;
456 lock (m_animations) 465 lock (m_animations)
457 { 466 {
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 9f330fd..3c749aa 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -360,15 +360,12 @@ namespace OpenSim.Region.Framework.Scenes
360 /// <summary> 360 /// <summary>
361 /// Record user movement inputs. 361 /// Record user movement inputs.
362 /// </summary> 362 /// </summary>
363 public byte MovementFlag { get; private set; } 363 public uint MovementFlag { get; private set; }
364 364
365 private bool m_updateflag; 365 /// <summary>
366 366 /// Is the agent stop control flag currently active?
367 public bool Updated 367 /// </summary>
368 { 368 public bool AgentControlStopActive { get; private set; }
369 set { m_updateflag = value; }
370 get { return m_updateflag; }
371 }
372 369
373 private bool m_invulnerable = true; 370 private bool m_invulnerable = true;
374 371
@@ -513,6 +510,7 @@ namespace OpenSim.Region.Framework.Scenes
513 } 510 }
514 else 511 else
515 { 512 {
513// m_log.DebugFormat("[SCENE PRESENCE]: Fetching abs pos where PhysicsActor == null and parent part {0} for {1}", Name, Scene.Name);
516 // Obtain the correct position of a seated avatar. 514 // Obtain the correct position of a seated avatar.
517 // In addition to providing the correct position while 515 // In addition to providing the correct position while
518 // the avatar is seated, this value will also 516 // the avatar is seated, this value will also
@@ -536,7 +534,7 @@ namespace OpenSim.Region.Framework.Scenes
536 } 534 }
537 set 535 set
538 { 536 {
539// m_log.DebugFormat("[SCENE PRESENCE]: Setting position of {0} in {1} to {2}", Name, Scene.Name, value); 537// m_log.DebugFormat("[SCENE PRESENCE]: Setting position of {0} to {1} in {2}", Name, value, Scene.Name);
540// Util.PrintCallStack(); 538// Util.PrintCallStack();
541 539
542 if (PhysicsActor != null) 540 if (PhysicsActor != null)
@@ -553,10 +551,7 @@ namespace OpenSim.Region.Framework.Scenes
553 551
554 // Don't update while sitting. The PhysicsActor above is null whilst sitting. 552 // Don't update while sitting. The PhysicsActor above is null whilst sitting.
555 if (ParentID == 0) 553 if (ParentID == 0)
556 {
557 m_pos = value; 554 m_pos = value;
558// ParentPosition = Vector3.Zero;
559 }
560 555
561 //m_log.DebugFormat( 556 //m_log.DebugFormat(
562 // "[ENTITY BASE]: In {0} set AbsolutePosition of {1} to {2}", 557 // "[ENTITY BASE]: In {0} set AbsolutePosition of {1} to {2}",
@@ -819,6 +814,14 @@ namespace OpenSim.Region.Framework.Scenes
819 set { m_speedModifier = value; } 814 set { m_speedModifier = value; }
820 } 815 }
821 816
817 /// <summary>
818 /// Modifier for agent movement if we get an AGENT_CONTROL_STOP whilst walking or running
819 /// </summary>
820 /// <remarks>
821 /// AGENT_CONTRL_STOP comes about if user holds down space key on viewers.
822 /// </remarks>
823 private float AgentControlStopSlowWhilstMoving = 0.5f;
824
822 private bool m_forceFly; 825 private bool m_forceFly;
823 826
824 public bool ForceFly 827 public bool ForceFly
@@ -1899,7 +1902,6 @@ namespace OpenSim.Region.Framework.Scenes
1899 if ((oldState & (uint)AgentState.Editing) != 0 && State == (uint)AgentState.None) 1902 if ((oldState & (uint)AgentState.Editing) != 0 && State == (uint)AgentState.None)
1900 ControllingClient.SendAgentTerseUpdate(this); 1903 ControllingClient.SendAgentTerseUpdate(this);
1901 1904
1902
1903 PhysicsActor actor = PhysicsActor; 1905 PhysicsActor actor = PhysicsActor;
1904 if (actor == null) 1906 if (actor == null)
1905 { 1907 {
@@ -1909,12 +1911,13 @@ namespace OpenSim.Region.Framework.Scenes
1909 1911
1910 if (AllowMovement && !SitGround) 1912 if (AllowMovement && !SitGround)
1911 { 1913 {
1912 Quaternion bodyRotation = agentData.BodyRotation; 1914// m_log.DebugFormat("[SCENE PRESENCE]: Initial body rotation {0} for {1}", agentData.BodyRotation, Name);
1915
1913 bool update_rotation = false; 1916 bool update_rotation = false;
1914 1917
1915 if (bodyRotation != Rotation) 1918 if (agentData.BodyRotation != Rotation)
1916 { 1919 {
1917 Rotation = bodyRotation; 1920 Rotation = agentData.BodyRotation;
1918 update_rotation = true; 1921 update_rotation = true;
1919 } 1922 }
1920 1923
@@ -1960,10 +1963,7 @@ namespace OpenSim.Region.Framework.Scenes
1960 else 1963 else
1961 dirVectors = Dir_Vectors; 1964 dirVectors = Dir_Vectors;
1962 1965
1963 // The fact that MovementFlag is a byte needs to be fixed
1964 // it really should be a uint
1965 // A DIR_CONTROL_FLAG occurs when the user is trying to move in a particular direction. 1966 // A DIR_CONTROL_FLAG occurs when the user is trying to move in a particular direction.
1966 uint nudgehack = 250;
1967 foreach (Dir_ControlFlags DCF in DIR_CONTROL_FLAGS) 1967 foreach (Dir_ControlFlags DCF in DIR_CONTROL_FLAGS)
1968 { 1968 {
1969 if (((uint)flags & (uint)DCF) != 0) 1969 if (((uint)flags & (uint)DCF) != 0)
@@ -1980,29 +1980,19 @@ namespace OpenSim.Region.Framework.Scenes
1980 // Why did I get this? 1980 // Why did I get this?
1981 } 1981 }
1982 1982
1983 if ((MovementFlag & (byte)(uint)DCF) == 0) 1983 if (((MovementFlag & (uint)DCF) == 0) & !AgentControlStopActive)
1984 { 1984 {
1985 if (DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD_NUDGE || DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_BACKWARD_NUDGE ||
1986 DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT_NUDGE || DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT_NUDGE)
1987 {
1988 MovementFlag |= (byte)nudgehack;
1989 }
1990
1991 //m_log.DebugFormat("[SCENE PRESENCE]: Updating MovementFlag for {0} with {1}", Name, DCF); 1985 //m_log.DebugFormat("[SCENE PRESENCE]: Updating MovementFlag for {0} with {1}", Name, DCF);
1992 MovementFlag += (byte)(uint)DCF; 1986 MovementFlag += (uint)DCF;
1993 update_movementflag = true; 1987 update_movementflag = true;
1994 } 1988 }
1995 } 1989 }
1996 else 1990 else
1997 { 1991 {
1998 if ((MovementFlag & (byte)(uint)DCF) != 0 || 1992 if ((MovementFlag & (uint)DCF) != 0)
1999 ((DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD_NUDGE || DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_BACKWARD_NUDGE ||
2000 DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT_NUDGE || DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT_NUDGE)
2001 && ((MovementFlag & (byte)nudgehack) == nudgehack))
2002 ) // This or is for Nudge forward
2003 { 1993 {
2004 //m_log.DebugFormat("[SCENE PRESENCE]: Updating MovementFlag for {0} with lack of {1}", Name, DCF); 1994 //m_log.DebugFormat("[SCENE PRESENCE]: Updating MovementFlag for {0} with lack of {1}", Name, DCF);
2005 MovementFlag -= ((byte)(uint)DCF); 1995 MovementFlag -= (uint)DCF;
2006 update_movementflag = true; 1996 update_movementflag = true;
2007 1997
2008 /* 1998 /*
@@ -2022,6 +2012,13 @@ namespace OpenSim.Region.Framework.Scenes
2022 i++; 2012 i++;
2023 } 2013 }
2024 2014
2015 // Detect AGENT_CONTROL_STOP state changes
2016 if (AgentControlStopActive != ((flags & AgentManager.ControlFlags.AGENT_CONTROL_STOP) != 0))
2017 {
2018 AgentControlStopActive = !AgentControlStopActive;
2019 update_movementflag = true;
2020 }
2021
2025 if (MovingToTarget) 2022 if (MovingToTarget)
2026 { 2023 {
2027 // If the user has pressed a key then we want to cancel any move to target. 2024 // If the user has pressed a key then we want to cancel any move to target.
@@ -2047,53 +2044,79 @@ namespace OpenSim.Region.Framework.Scenes
2047 // Only do this if we're flying 2044 // Only do this if we're flying
2048 if (Flying && !ForceFly) 2045 if (Flying && !ForceFly)
2049 { 2046 {
2050 // Landing detection code 2047 // Need to stop in mid air if user holds down AGENT_CONTROL_STOP
2051 2048 if (AgentControlStopActive)
2052 // Are the landing controls requirements filled?
2053 bool controlland = (((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) ||
2054 ((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0));
2055
2056 //m_log.Debug("[CONTROL]: " +flags);
2057 // Applies a satisfying roll effect to the avatar when flying.
2058 if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) != 0 && (flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0)
2059 {
2060 ApplyFlyingRoll(
2061 FLY_ROLL_RADIANS_PER_UPDATE,
2062 (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0,
2063 (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0);
2064 }
2065 else if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) != 0 &&
2066 (flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0)
2067 { 2049 {
2068 ApplyFlyingRoll( 2050 agent_control_v3 = Vector3.Zero;
2069 -FLY_ROLL_RADIANS_PER_UPDATE,
2070 (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0,
2071 (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0);
2072 } 2051 }
2073 else 2052 else
2074 { 2053 {
2075 if (m_AngularVelocity.Z != 0) 2054 // Landing detection code
2076 m_AngularVelocity.Z += CalculateFlyingRollResetToZero(FLY_ROLL_RESET_RADIANS_PER_UPDATE);
2077 }
2078 2055
2079 if (Flying && IsColliding && controlland) 2056 // Are the landing controls requirements filled?
2080 { 2057 bool controlland = (((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) ||
2081 // nesting this check because LengthSquared() is expensive and we don't 2058 ((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0));
2082 // want to do it every step when flying. 2059
2083 if ((Velocity.LengthSquared() <= LAND_VELOCITYMAG_MAX)) 2060 //m_log.Debug("[CONTROL]: " +flags);
2084 StopFlying(); 2061 // Applies a satisfying roll effect to the avatar when flying.
2062 if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) != 0 && (flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0)
2063 {
2064 ApplyFlyingRoll(
2065 FLY_ROLL_RADIANS_PER_UPDATE,
2066 (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0,
2067 (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0);
2068 }
2069 else if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) != 0 &&
2070 (flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0)
2071 {
2072 ApplyFlyingRoll(
2073 -FLY_ROLL_RADIANS_PER_UPDATE,
2074 (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0,
2075 (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0);
2076 }
2077 else
2078 {
2079 if (m_AngularVelocity.Z != 0)
2080 m_AngularVelocity.Z += CalculateFlyingRollResetToZero(FLY_ROLL_RESET_RADIANS_PER_UPDATE);
2081 }
2082
2083 if (Flying && IsColliding && controlland)
2084 {
2085 // nesting this check because LengthSquared() is expensive and we don't
2086 // want to do it every step when flying.
2087 if ((Velocity.LengthSquared() <= LAND_VELOCITYMAG_MAX))
2088 StopFlying();
2089 }
2085 } 2090 }
2086 } 2091 }
2087 2092
2093// m_log.DebugFormat("[SCENE PRESENCE]: MovementFlag {0} for {1}", MovementFlag, Name);
2094
2088 // If the agent update does move the avatar, then calculate the force ready for the velocity update, 2095 // If the agent update does move the avatar, then calculate the force ready for the velocity update,
2089 // which occurs later in the main scene loop 2096 // which occurs later in the main scene loop
2090 if (update_movementflag || (update_rotation && DCFlagKeyPressed)) 2097 // We also need to update if the user rotates their avatar whilst it is slow walking/running (if they
2098 // held down AGENT_CONTROL_STOP whilst normal walking/running). However, we do not want to update
2099 // if the user rotated whilst holding down AGENT_CONTROL_STOP when already still (which locks the
2100 // avatar location in place).
2101 if (update_movementflag
2102 || (update_rotation && DCFlagKeyPressed && (!AgentControlStopActive || MovementFlag != 0)))
2091 { 2103 {
2092// m_log.DebugFormat( 2104// if (update_movementflag || !AgentControlStopActive || MovementFlag != 0)
2093// "[SCENE PRESENCE]: In {0} adding velocity of {1} to {2}, umf = {3}, ur = {4}", 2105// {
2094// m_scene.RegionInfo.RegionName, agent_control_v3, Name, update_movementflag, update_rotation); 2106// m_log.DebugFormat(
2107// "[SCENE PRESENCE]: In {0} adding velocity of {1} to {2}, umf = {3}, mf = {4}, ur = {5}",
2108// m_scene.RegionInfo.RegionName, agent_control_v3, Name,
2109// update_movementflag, MovementFlag, update_rotation);
2110
2111 float speedModifier;
2112
2113 if (AgentControlStopActive)
2114 speedModifier = AgentControlStopSlowWhilstMoving;
2115 else
2116 speedModifier = 1;
2095 2117
2096 AddNewMovement(agent_control_v3); 2118 AddNewMovement(agent_control_v3, speedModifier);
2119// }
2097 } 2120 }
2098// else 2121// else
2099// { 2122// {
@@ -2106,7 +2129,10 @@ namespace OpenSim.Region.Framework.Scenes
2106// } 2129// }
2107 2130
2108 if (update_movementflag && ParentID == 0) 2131 if (update_movementflag && ParentID == 0)
2132 {
2133// m_log.DebugFormat("[SCENE PRESENCE]: Updating movement animations for {0}", Name);
2109 Animator.UpdateMovementAnimations(); 2134 Animator.UpdateMovementAnimations();
2135 }
2110 2136
2111 SendControlsToScripts(flagsForScripts); 2137 SendControlsToScripts(flagsForScripts);
2112 } 2138 }
@@ -2435,17 +2461,13 @@ namespace OpenSim.Region.Framework.Scenes
2435 { 2461 {
2436// m_log.DebugFormat("[SCENE PRESENCE]: StandUp() for {0}", Name); 2462// m_log.DebugFormat("[SCENE PRESENCE]: StandUp() for {0}", Name);
2437 2463
2464 bool satOnObject = IsSatOnObject;
2465 SceneObjectPart part = ParentPart;
2438 SitGround = false; 2466 SitGround = false;
2439 2467
2440/* move this down so avatar gets physical in the new position and not where it is siting 2468 if (satOnObject)
2441 if (PhysicsActor == null)
2442 AddToPhysicalScene(false);
2443 */
2444
2445 if (ParentID != 0)
2446 { 2469 {
2447 PrevSitOffset = m_pos; // Save sit offset 2470 PrevSitOffset = m_pos; // Save sit offset
2448 SceneObjectPart part = ParentPart;
2449 UnRegisterSeatControls(part.ParentGroup.UUID); 2471 UnRegisterSeatControls(part.ParentGroup.UUID);
2450 2472
2451 TaskInventoryDictionary taskIDict = part.TaskInventory; 2473 TaskInventoryDictionary taskIDict = part.TaskInventory;
@@ -2464,28 +2486,64 @@ namespace OpenSim.Region.Framework.Scenes
2464 } 2486 }
2465 2487
2466 part.ParentGroup.DeleteAvatar(UUID); 2488 part.ParentGroup.DeleteAvatar(UUID);
2467// ParentPosition = part.GetWorldPosition(); 2489 Vector3 sitPartWorldPosition = part.GetWorldPosition();
2468 ControllingClient.SendClearFollowCamProperties(part.ParentUUID); 2490 ControllingClient.SendClearFollowCamProperties(part.ParentUUID);
2469 2491
2470// m_pos += ParentPosition + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight);
2471// ParentPosition = Vector3.Zero;
2472 m_pos = part.AbsolutePosition + (m_pos * part.GetWorldRotation()) + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight);
2473 if (part.SitTargetAvatar == UUID)
2474 m_bodyRot = part.GetWorldRotation() * part.SitTargetOrientation;
2475
2476 ParentID = 0; 2492 ParentID = 0;
2477 ParentPart = null; 2493 ParentPart = null;
2478 2494
2479 if (PhysicsActor == null) 2495 Quaternion standRotation;
2480 AddToPhysicalScene(false); 2496
2497 if (part.SitTargetAvatar == UUID)
2498 {
2499 standRotation = part.GetWorldRotation();
2500
2501 if (!part.IsRoot)
2502 standRotation = standRotation * part.SitTargetOrientation;
2503// standRotation = part.RotationOffset * part.SitTargetOrientation;
2504// else
2505// standRotation = part.SitTargetOrientation;
2506
2507 }
2508 else
2509 {
2510 standRotation = Rotation;
2511 }
2512
2513 //Vector3 standPos = ParentPosition + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight);
2514 //Vector3 standPos = ParentPosition;
2515
2516// Vector3 standPositionAdjustment
2517// = part.SitTargetPosition + new Vector3(0.5f, 0f, m_sitAvatarHeight / 2f);
2518 Vector3 adjustmentForSitPosition = part.SitTargetPosition * part.GetWorldRotation();
2481 2519
2520 // XXX: This is based on the physics capsule sizes. Need to find a better way to read this rather than
2521 // hardcoding here.
2522 Vector3 adjustmentForSitPose = new Vector3(0.74f, 0f, 0f) * standRotation;
2523
2524 Vector3 standPos = sitPartWorldPosition + adjustmentForSitPosition + adjustmentForSitPose;
2525
2526// m_log.DebugFormat(
2527// "[SCENE PRESENCE]: Setting stand to pos {0}, (adjustmentForSitPosition {1}, adjustmentForSitPose {2}) rotation {3} for {4} in {5}",
2528// standPos, adjustmentForSitPosition, adjustmentForSitPose, standRotation, Name, Scene.Name);
2529
2530 Rotation = standRotation;
2531 AbsolutePosition = standPos;
2532 }
2533
2534 // We need to wait until we have calculated proper stand positions before sitting up the physical
2535 // avatar to avoid race conditions.
2536 if (PhysicsActor == null)
2537 AddToPhysicalScene(false);
2538
2539 if (satOnObject)
2540 {
2482 SendAvatarDataToAllAgents(); 2541 SendAvatarDataToAllAgents();
2483 m_requestedSitTargetID = 0; 2542 m_requestedSitTargetID = 0;
2484 2543
2485 part.RemoveSittingAvatar(UUID); 2544 part.RemoveSittingAvatar(UUID);
2486 2545
2487 if (part != null) 2546 part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK);
2488 part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK);
2489 } 2547 }
2490 2548
2491 else if (PhysicsActor == null) 2549 else if (PhysicsActor == null)
@@ -2543,7 +2601,6 @@ namespace OpenSim.Region.Framework.Scenes
2543 m_sitAvatarHeight = PhysicsActor.Size.Z * 0.5f; 2601 m_sitAvatarHeight = PhysicsActor.Size.Z * 0.5f;
2544 2602
2545 bool canSit = false; 2603 bool canSit = false;
2546 Vector3 pos = part.AbsolutePosition + offset;
2547 2604
2548 if (part.IsSitTargetSet && part.SitTargetAvatar == UUID.Zero) 2605 if (part.IsSitTargetSet && part.SitTargetAvatar == UUID.Zero)
2549 { 2606 {
@@ -2553,6 +2610,17 @@ namespace OpenSim.Region.Framework.Scenes
2553 2610
2554 offset = part.SitTargetPosition; 2611 offset = part.SitTargetPosition;
2555 sitOrientation = part.SitTargetOrientation; 2612 sitOrientation = part.SitTargetOrientation;
2613
2614 if (!part.IsRoot)
2615 {
2616 // m_log.DebugFormat("Old sit orient {0}", sitOrientation);
2617 sitOrientation = part.RotationOffset * sitOrientation;
2618 // m_log.DebugFormat("New sit orient {0}", sitOrientation);
2619// m_log.DebugFormat("Old sit offset {0}", offset);
2620 offset = offset * part.RotationOffset;
2621// m_log.DebugFormat("New sit offset {0}", offset);
2622 }
2623
2556 canSit = true; 2624 canSit = true;
2557 } 2625 }
2558 else 2626 else
@@ -2560,9 +2628,10 @@ namespace OpenSim.Region.Framework.Scenes
2560 if (PhysicsSit(part,offset)) // physics engine 2628 if (PhysicsSit(part,offset)) // physics engine
2561 return; 2629 return;
2562 2630
2631 Vector3 pos = part.AbsolutePosition + offset;
2632
2563 if (Util.GetDistanceTo(AbsolutePosition, pos) <= 10) 2633 if (Util.GetDistanceTo(AbsolutePosition, pos) <= 10)
2564 { 2634 {
2565
2566 AbsolutePosition = pos + new Vector3(0.0f, 0.0f, m_sitAvatarHeight); 2635 AbsolutePosition = pos + new Vector3(0.0f, 0.0f, m_sitAvatarHeight);
2567 canSit = true; 2636 canSit = true;
2568 } 2637 }
@@ -2588,8 +2657,12 @@ namespace OpenSim.Region.Framework.Scenes
2588 cameraEyeOffset = part.GetCameraEyeOffset(); 2657 cameraEyeOffset = part.GetCameraEyeOffset();
2589 forceMouselook = part.GetForceMouselook(); 2658 forceMouselook = part.GetForceMouselook();
2590 2659
2660 // An viewer expects to specify sit positions as offsets to the root prim, even if a child prim is
2661 // being sat upon.
2662 offset += part.OffsetPosition;
2663
2591 ControllingClient.SendSitResponse( 2664 ControllingClient.SendSitResponse(
2592 part.UUID, offset, sitOrientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); 2665 part.ParentGroup.UUID, offset, sitOrientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook);
2593 2666
2594 m_requestedSitTargetUUID = part.UUID; 2667 m_requestedSitTargetUUID = part.UUID;
2595 2668
@@ -2870,10 +2943,13 @@ namespace OpenSim.Region.Framework.Scenes
2870 /// Rotate the avatar to the given rotation and apply a movement in the given relative vector 2943 /// Rotate the avatar to the given rotation and apply a movement in the given relative vector
2871 /// </summary> 2944 /// </summary>
2872 /// <param name="vec">The vector in which to move. This is relative to the rotation argument</param> 2945 /// <param name="vec">The vector in which to move. This is relative to the rotation argument</param>
2873 public void AddNewMovement(Vector3 vec) 2946 /// <param name="thisAddSpeedModifier">
2947 /// Optional additional speed modifier for this particular add. Default is 1</param>
2948 public void AddNewMovement(Vector3 vec, float thisAddSpeedModifier = 1)
2874 { 2949 {
2875// m_log.DebugFormat( 2950// m_log.DebugFormat(
2876// "[SCENE PRESENCE]: Adding new movement {0} with rotation {1} for {2}", vec, Rotation, Name); 2951// "[SCENE PRESENCE]: Adding new movement {0} with rotation {1}, thisAddSpeedModifier {2} for {3}",
2952// vec, Rotation, thisAddSpeedModifier, Name);
2877 2953
2878 Vector3 direc = vec * Rotation; 2954 Vector3 direc = vec * Rotation;
2879 direc.Normalize(); 2955 direc.Normalize();
@@ -2891,7 +2967,7 @@ namespace OpenSim.Region.Framework.Scenes
2891 if ((vec.Z == 0f) && !Flying) 2967 if ((vec.Z == 0f) && !Flying)
2892 direc.Z = 0f; // Prevent camera WASD up. 2968 direc.Z = 0f; // Prevent camera WASD up.
2893 2969
2894 direc *= 0.03f * 128f * SpeedModifier; 2970 direc *= 0.03f * 128f * SpeedModifier * thisAddSpeedModifier;
2895 2971
2896// m_log.DebugFormat("[SCENE PRESENCE]: Force to apply before modification was {0} for {1}", direc, Name); 2972// m_log.DebugFormat("[SCENE PRESENCE]: Force to apply before modification was {0} for {1}", direc, Name);
2897 2973
@@ -3037,6 +3113,7 @@ namespace OpenSim.Region.Framework.Scenes
3037 lastTerseUpdateToAllClientsTick = currentTick; 3113 lastTerseUpdateToAllClientsTick = currentTick;
3038 lastPositionSentToAllClients = OffsetPosition; 3114 lastPositionSentToAllClients = OffsetPosition;
3039 3115
3116// Console.WriteLine("Scheduled update for {0} in {1}", Name, Scene.Name);
3040 m_scene.ForEachClient(SendTerseUpdateToClient); 3117 m_scene.ForEachClient(SendTerseUpdateToClient);
3041 } 3118 }
3042 TriggerScenePresenceUpdated(); 3119 TriggerScenePresenceUpdated();
@@ -3806,8 +3883,6 @@ namespace OpenSim.Region.Framework.Scenes
3806 { 3883 {
3807 Vector3 force = m_forceToApply.Value; 3884 Vector3 force = m_forceToApply.Value;
3808 3885
3809 Updated = true;
3810
3811 Velocity = force; 3886 Velocity = force;
3812 3887
3813 m_forceToApply = null; 3888 m_forceToApply = null;