diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 77 |
1 files changed, 54 insertions, 23 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 39a885c..82bb759 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -559,16 +559,28 @@ namespace OpenSim.Region.Framework.Scenes | |||
559 | 559 | ||
560 | private Quaternion m_bodyRot = Quaternion.Identity; | 560 | private Quaternion m_bodyRot = Quaternion.Identity; |
561 | 561 | ||
562 | /// <summary> | ||
563 | /// The rotation of the avatar. | ||
564 | /// </summary> | ||
565 | /// <remarks> | ||
566 | /// If the avatar is not sitting, this is with respect to the world | ||
567 | /// If the avatar is sitting, this is a with respect to the part that it's sitting upon (a local rotation). | ||
568 | /// If you always want the world rotation, use GetWorldRotation() | ||
569 | /// </remarks> | ||
562 | public Quaternion Rotation | 570 | public Quaternion Rotation |
563 | { | 571 | { |
564 | get { return m_bodyRot; } | 572 | get |
573 | { | ||
574 | return m_bodyRot; | ||
575 | } | ||
576 | |||
565 | set | 577 | set |
566 | { | 578 | { |
567 | m_bodyRot = value; | 579 | m_bodyRot = value; |
580 | |||
568 | if (PhysicsActor != null) | 581 | if (PhysicsActor != null) |
569 | { | ||
570 | PhysicsActor.Orientation = m_bodyRot; | 582 | PhysicsActor.Orientation = m_bodyRot; |
571 | } | 583 | |
572 | // m_log.DebugFormat("[SCENE PRESENCE]: Body rot for {0} set to {1}", Name, m_bodyRot); | 584 | // m_log.DebugFormat("[SCENE PRESENCE]: Body rot for {0} set to {1}", Name, m_bodyRot); |
573 | } | 585 | } |
574 | } | 586 | } |
@@ -608,6 +620,26 @@ namespace OpenSim.Region.Framework.Scenes | |||
608 | set { m_health = value; } | 620 | set { m_health = value; } |
609 | } | 621 | } |
610 | 622 | ||
623 | /// <summary> | ||
624 | /// Gets the world rotation of this presence. | ||
625 | /// </summary> | ||
626 | /// <remarks> | ||
627 | /// Unlike Rotation, this returns the world rotation no matter whether the avatar is sitting on a prim or not. | ||
628 | /// </remarks> | ||
629 | /// <returns></returns> | ||
630 | public Quaternion GetWorldRotation() | ||
631 | { | ||
632 | if (IsSatOnObject) | ||
633 | { | ||
634 | SceneObjectPart sitPart = ParentPart; | ||
635 | |||
636 | if (sitPart != null) | ||
637 | return sitPart.GetWorldRotation() * Rotation; | ||
638 | } | ||
639 | |||
640 | return Rotation; | ||
641 | } | ||
642 | |||
611 | public void AdjustKnownSeeds() | 643 | public void AdjustKnownSeeds() |
612 | { | 644 | { |
613 | Dictionary<ulong, string> seeds; | 645 | Dictionary<ulong, string> seeds; |
@@ -709,8 +741,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
709 | 741 | ||
710 | #endregion | 742 | #endregion |
711 | 743 | ||
712 | |||
713 | |||
714 | #region Constructor(s) | 744 | #region Constructor(s) |
715 | 745 | ||
716 | public ScenePresence( | 746 | public ScenePresence( |
@@ -1613,32 +1643,28 @@ namespace OpenSim.Region.Framework.Scenes | |||
1613 | bool controlland = (((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || | 1643 | bool controlland = (((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || |
1614 | ((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); | 1644 | ((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); |
1615 | 1645 | ||
1616 | |||
1617 | //m_log.Debug("[CONTROL]: " +flags); | 1646 | //m_log.Debug("[CONTROL]: " +flags); |
1618 | // Applies a satisfying roll effect to the avatar when flying. | 1647 | // Applies a satisfying roll effect to the avatar when flying. |
1619 | if (((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) != 0) && ((flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0)) | 1648 | if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) != 0 && (flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0) |
1620 | { | 1649 | { |
1621 | 1650 | ApplyFlyingRoll( | |
1622 | ApplyFlyingRoll(FLY_ROLL_RADIANS_PER_UPDATE, ((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0), ((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0)); | 1651 | FLY_ROLL_RADIANS_PER_UPDATE, |
1623 | 1652 | (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0, | |
1624 | 1653 | (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0); | |
1625 | } | 1654 | } |
1626 | else if (((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) != 0) && | 1655 | else if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) != 0 && |
1627 | ((flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0)) | 1656 | (flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0) |
1628 | { | 1657 | { |
1629 | ApplyFlyingRoll(-FLY_ROLL_RADIANS_PER_UPDATE, ((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0), ((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0)); | 1658 | ApplyFlyingRoll( |
1630 | 1659 | -FLY_ROLL_RADIANS_PER_UPDATE, | |
1631 | 1660 | (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0, | |
1661 | (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0); | ||
1632 | } | 1662 | } |
1633 | else | 1663 | else |
1634 | { | 1664 | { |
1635 | if (m_AngularVelocity.Z != 0) | 1665 | if (m_AngularVelocity.Z != 0) |
1636 | m_AngularVelocity.Z += CalculateFlyingRollResetToZero(FLY_ROLL_RESET_RADIANS_PER_UPDATE); | 1666 | m_AngularVelocity.Z += CalculateFlyingRollResetToZero(FLY_ROLL_RESET_RADIANS_PER_UPDATE); |
1637 | 1667 | } | |
1638 | } | ||
1639 | |||
1640 | |||
1641 | |||
1642 | 1668 | ||
1643 | if (Flying && IsColliding && controlland) | 1669 | if (Flying && IsColliding && controlland) |
1644 | { | 1670 | { |
@@ -2400,7 +2426,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2400 | /// <param name="vec">The vector in which to move. This is relative to the rotation argument</param> | 2426 | /// <param name="vec">The vector in which to move. This is relative to the rotation argument</param> |
2401 | public void AddNewMovement(Vector3 vec) | 2427 | public void AddNewMovement(Vector3 vec) |
2402 | { | 2428 | { |
2403 | // m_log.DebugFormat("[SCENE PRESENCE]: Adding new movement {0} for {1}", vec, Name); | 2429 | // m_log.DebugFormat( |
2430 | // "[SCENE PRESENCE]: Adding new movement {0} with rotation {1} for {2}", vec, Rotation, Name); | ||
2404 | 2431 | ||
2405 | Vector3 direc = vec * Rotation; | 2432 | Vector3 direc = vec * Rotation; |
2406 | direc.Normalize(); | 2433 | direc.Normalize(); |
@@ -2420,6 +2447,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2420 | 2447 | ||
2421 | direc *= 0.03f * 128f * SpeedModifier; | 2448 | direc *= 0.03f * 128f * SpeedModifier; |
2422 | 2449 | ||
2450 | // m_log.DebugFormat("[SCENE PRESENCE]: Force to apply before modification was {0} for {1}", direc, Name); | ||
2451 | |||
2423 | if (PhysicsActor != null) | 2452 | if (PhysicsActor != null) |
2424 | { | 2453 | { |
2425 | if (Flying) | 2454 | if (Flying) |
@@ -2453,6 +2482,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2453 | } | 2482 | } |
2454 | } | 2483 | } |
2455 | 2484 | ||
2485 | // m_log.DebugFormat("[SCENE PRESENCE]: Setting force to apply to {0} for {1}", direc, Name); | ||
2486 | |||
2456 | // TODO: Add the force instead of only setting it to support multiple forces per frame? | 2487 | // TODO: Add the force instead of only setting it to support multiple forces per frame? |
2457 | m_forceToApply = direc; | 2488 | m_forceToApply = direc; |
2458 | } | 2489 | } |