diff options
author | Tom | 2011-09-07 09:42:18 -0700 |
---|---|---|
committer | Tom | 2011-09-07 09:42:18 -0700 |
commit | 03f6734f4367b08e2b181ed68bc80b885e76148f (patch) | |
tree | fa8550771d3b5eb1a0315f107801b332f78bede5 /OpenSim/Region/Framework/Scenes/ScenePresence.cs | |
parent | Now merging the core changes. (diff) | |
download | opensim-SC-03f6734f4367b08e2b181ed68bc80b885e76148f.zip opensim-SC-03f6734f4367b08e2b181ed68bc80b885e76148f.tar.gz opensim-SC-03f6734f4367b08e2b181ed68bc80b885e76148f.tar.bz2 opensim-SC-03f6734f4367b08e2b181ed68bc80b885e76148f.tar.xz |
First set of merge fixes
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 309 |
1 files changed, 78 insertions, 231 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index de9b1f3..8ee7d89 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -1364,9 +1364,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1364 | /// <summary> | 1364 | /// <summary> |
1365 | /// This is the event handler for client movement. If a client is moving, this event is triggering. | 1365 | /// This is the event handler for client movement. If a client is moving, this event is triggering. |
1366 | /// </summary> | 1366 | /// </summary> |
1367 | /// <summary> | ||
1368 | /// This is the event handler for client movement. If a client is moving, this event is triggering. | ||
1369 | /// </summary> | ||
1367 | public void HandleAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData) | 1370 | public void HandleAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData) |
1368 | { | 1371 | { |
1369 | // m_log.DebugFormat("[SCENE PRESENCE]: Received agent update from {0}", remoteClient.Name); | 1372 | // m_log.DebugFormat("[SCENE PRESENCE]: Received agent update from {0}", remoteClient.Name); |
1370 | 1373 | ||
1371 | //if (m_isChildAgent) | 1374 | //if (m_isChildAgent) |
1372 | //{ | 1375 | //{ |
@@ -1389,7 +1392,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1389 | m_log.Error("[AVATAR]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error #9999902"); | 1392 | m_log.Error("[AVATAR]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error #9999902"); |
1390 | 1393 | ||
1391 | m_pos = m_LastFinitePos; | 1394 | m_pos = m_LastFinitePos; |
1392 | |||
1393 | if (!m_pos.IsFinite()) | 1395 | if (!m_pos.IsFinite()) |
1394 | { | 1396 | { |
1395 | m_pos.X = 127f; | 1397 | m_pos.X = 127f; |
@@ -1459,6 +1461,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1459 | m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(m_CameraCenter - posAdjusted), Vector3.Distance(m_CameraCenter, posAdjusted) + 0.3f, RayCastCameraCallback); | 1461 | m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(m_CameraCenter - posAdjusted), Vector3.Distance(m_CameraCenter, posAdjusted) + 0.3f, RayCastCameraCallback); |
1460 | } | 1462 | } |
1461 | } | 1463 | } |
1464 | |||
1462 | lock (scriptedcontrols) | 1465 | lock (scriptedcontrols) |
1463 | { | 1466 | { |
1464 | if (scriptedcontrols.Count > 0) | 1467 | if (scriptedcontrols.Count > 0) |
@@ -1473,9 +1476,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1473 | 1476 | ||
1474 | if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0) | 1477 | if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0) |
1475 | { | 1478 | { |
1476 | m_updateCount = 0; // Kill animation update burst so that the SIT_G.. will stick. | ||
1477 | Animator.TrySetMovementAnimation("SIT_GROUND_CONSTRAINED"); | ||
1478 | |||
1479 | // TODO: This doesn't prevent the user from walking yet. | 1479 | // TODO: This doesn't prevent the user from walking yet. |
1480 | // Setting parent ID would fix this, if we knew what value | 1480 | // Setting parent ID would fix this, if we knew what value |
1481 | // to use. Or we could add a m_isSitting variable. | 1481 | // to use. Or we could add a m_isSitting variable. |
@@ -1530,20 +1530,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1530 | if (actor.Flying != oldflying) | 1530 | if (actor.Flying != oldflying) |
1531 | update_movementflag = true; | 1531 | update_movementflag = true; |
1532 | 1532 | ||
1533 | if (m_animator.m_jumping) // add for jumping | ||
1534 | update_movementflag = true; | ||
1535 | |||
1536 | if (q != m_bodyRot) | ||
1537 | { | ||
1538 | m_bodyRot = q; | ||
1539 | update_rotation = true; | ||
1540 | } | ||
1541 | |||
1542 | //guilty until proven innocent.. | ||
1543 | bool Nudging = true; | ||
1544 | //Basically, if there is at least one non-nudge control then we don't need | ||
1545 | //to worry about stopping the avatar | ||
1546 | |||
1547 | if (m_parentID == 0) | 1533 | if (m_parentID == 0) |
1548 | { | 1534 | { |
1549 | bool bAllowUpdateMoveToPosition = false; | 1535 | bool bAllowUpdateMoveToPosition = false; |
@@ -1557,12 +1543,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1557 | else | 1543 | else |
1558 | dirVectors = Dir_Vectors; | 1544 | dirVectors = Dir_Vectors; |
1559 | 1545 | ||
1560 | bool[] isNudge = GetDirectionIsNudge(); | 1546 | // The fact that m_movementflag is a byte needs to be fixed |
1561 | 1547 | // it really should be a uint | |
1562 | 1548 | // A DIR_CONTROL_FLAG occurs when the user is trying to move in a particular direction. | |
1563 | 1549 | uint nudgehack = 250; | |
1564 | |||
1565 | |||
1566 | foreach (Dir_ControlFlags DCF in DIR_CONTROL_FLAGS) | 1550 | foreach (Dir_ControlFlags DCF in DIR_CONTROL_FLAGS) |
1567 | { | 1551 | { |
1568 | if (((uint)flags & (uint)DCF) != 0) | 1552 | if (((uint)flags & (uint)DCF) != 0) |
@@ -1572,30 +1556,43 @@ namespace OpenSim.Region.Framework.Scenes | |||
1572 | try | 1556 | try |
1573 | { | 1557 | { |
1574 | agent_control_v3 += dirVectors[i]; | 1558 | agent_control_v3 += dirVectors[i]; |
1575 | if (isNudge[i] == false) | 1559 | //m_log.DebugFormat("[Motion]: {0}, {1}",i, dirVectors[i]); |
1576 | { | ||
1577 | Nudging = false; | ||
1578 | } | ||
1579 | } | 1560 | } |
1580 | catch (IndexOutOfRangeException) | 1561 | catch (IndexOutOfRangeException) |
1581 | { | 1562 | { |
1582 | // Why did I get this? | 1563 | // Why did I get this? |
1583 | } | 1564 | } |
1584 | 1565 | ||
1585 | if ((m_movementflag & (uint)DCF) == 0) | 1566 | if ((m_movementflag & (byte)(uint)DCF) == 0) |
1586 | { | 1567 | { |
1568 | if (DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD_NUDGE || DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_BACK_NUDGE) | ||
1569 | { | ||
1570 | m_movementflag |= (byte)nudgehack; | ||
1571 | } | ||
1587 | 1572 | ||
1588 | // m_log.DebugFormat("[SCENE PRESENCE]: Updating m_movementflag for {0} with {1}", Name, DCF); | 1573 | // m_log.DebugFormat("[SCENE PRESENCE]: Updating m_movementflag for {0} with {1}", Name, DCF); |
1589 | m_movementflag += (byte)(uint)DCF; | 1574 | m_movementflag += (byte)(uint)DCF; |
1590 | update_movementflag = true; | 1575 | update_movementflag = true; |
1591 | } | 1576 | } |
1592 | } | 1577 | } |
1593 | else | 1578 | else |
1594 | { | 1579 | { |
1595 | if ((m_movementflag & (uint)DCF) != 0) | 1580 | if ((m_movementflag & (byte)(uint)DCF) != 0 || |
1581 | ((DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD_NUDGE || DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_BACK_NUDGE) | ||
1582 | && ((m_movementflag & (byte)nudgehack) == nudgehack)) | ||
1583 | ) // This or is for Nudge forward | ||
1596 | { | 1584 | { |
1597 | m_movementflag -= (byte)(uint)DCF; | 1585 | // m_log.DebugFormat("[SCENE PRESENCE]: Updating m_movementflag for {0} with lack of {1}", Name, DCF); |
1586 | m_movementflag -= ((byte)(uint)DCF); | ||
1598 | update_movementflag = true; | 1587 | update_movementflag = true; |
1588 | |||
1589 | /* | ||
1590 | if ((DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD_NUDGE || DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_BACKWARD_NUDGE) | ||
1591 | && ((m_movementflag & (byte)nudgehack) == nudgehack)) | ||
1592 | { | ||
1593 | m_log.Debug("Removed Hack flag"); | ||
1594 | } | ||
1595 | */ | ||
1599 | } | 1596 | } |
1600 | else | 1597 | else |
1601 | { | 1598 | { |
@@ -1605,128 +1602,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
1605 | 1602 | ||
1606 | i++; | 1603 | i++; |
1607 | } | 1604 | } |
1608 | if (MovingToTarget) | ||
1609 | { | ||
1610 | m_moveToPositionTarget = Vector3.Zero; | ||
1611 | m_moveToPositionInProgress = false; | ||
1612 | update_movementflag = true; | ||
1613 | bAllowUpdateMoveToPosition = false; | ||
1614 | } | ||
1615 | 1605 | ||
1616 | if (bAllowUpdateMoveToPosition && (m_moveToPositionInProgress && !m_autopilotMoving)) | 1606 | if (MovingToTarget) |
1617 | { | 1607 | { |
1618 | /* | 1608 | // If the user has pressed a key then we want to cancel any move to target. |
1619 | bool twoD = false; | 1609 | if (DCFlagKeyPressed) |
1620 | bool there = false; | ||
1621 | if (Animator != null) | ||
1622 | { | ||
1623 | switch (Animator.CurrentMovementAnimation) | ||
1624 | { | ||
1625 | case "STAND": | ||
1626 | case "WALK": | ||
1627 | case "RUN": | ||
1628 | case "CROUCH": | ||
1629 | case "CROUCHWALK": | ||
1630 | { | ||
1631 | twoD = true; | ||
1632 | } | ||
1633 | break; | ||
1634 | } | ||
1635 | } | ||
1636 | |||
1637 | if (twoD) | ||
1638 | { | ||
1639 | */ | ||
1640 | Vector3 abspos = new Vector3(AbsolutePosition.X, AbsolutePosition.Y, 0.0f); | ||
1641 | Vector3 tgt = new Vector3(m_moveToPositionTarget.X, m_moveToPositionTarget.Y, 0.0f); | ||
1642 | /* if (Util.GetDistanceTo(abspos, tgt) <= 0.5f) there = true; | ||
1643 | } | ||
1644 | else | ||
1645 | { | ||
1646 | if (Util.GetDistanceTo(AbsolutePosition, m_moveToPositionTarget) <= 0.5f) there = true; | ||
1647 | } | ||
1648 | */ | ||
1649 | //Check the error term of the current position in relation to the target position | ||
1650 | // if (Util.GetDistanceTo(AbsolutePosition, m_moveToPositionTarget) <= 0.5f) | ||
1651 | // if (there) | ||
1652 | if (Util.GetDistanceTo(abspos, tgt) <= 0.5f) | ||
1653 | { | 1610 | { |
1654 | ResetMoveToTarget(); | 1611 | ResetMoveToTarget(); |
1655 | update_movementflag = true; | 1612 | update_movementflag = true; |
1656 | } | 1613 | } |
1657 | else if (bAllowUpdateMoveToPosition) | 1614 | else if (bAllowUpdateMoveToPosition) |
1658 | { | 1615 | { |
1659 | try | 1616 | if (HandleMoveToTargetUpdate(ref agent_control_v3)) |
1660 | { | 1617 | update_movementflag = true; |
1661 | // move avatar in 2D at one meter/second towards target, in avatar coordinate frame. | ||
1662 | // This movement vector gets added to the velocity through AddNewMovement(). | ||
1663 | // Theoretically we might need a more complex PID approach here if other | ||
1664 | // unknown forces are acting on the avatar and we need to adaptively respond | ||
1665 | // to such forces, but the following simple approach seems to works fine. | ||
1666 | Vector3 LocalVectorToTarget3D = | ||
1667 | // (m_moveToPositionTarget - AbsolutePosition) // vector from cur. pos to target in global coords | ||
1668 | (tgt - abspos) | ||
1669 | * Matrix4.CreateFromQuaternion(Quaternion.Inverse(bodyRotation)); // change to avatar coords | ||
1670 | // Ignore z component of vector | ||
1671 | Vector3 LocalVectorToTarget2D = new Vector3((float)(LocalVectorToTarget3D.X), (float)(LocalVectorToTarget3D.Y), 0f); | ||
1672 | LocalVectorToTarget2D.Normalize(); | ||
1673 | |||
1674 | //We're not nudging | ||
1675 | Nudging = false; | ||
1676 | agent_control_v3 += LocalVectorToTarget2D; | ||
1677 | |||
1678 | // update avatar movement flags. the avatar coordinate system is as follows: | ||
1679 | // | ||
1680 | // +X (forward) | ||
1681 | // | ||
1682 | // ^ | ||
1683 | // | | ||
1684 | // | | ||
1685 | // | | ||
1686 | // | | ||
1687 | // (left) +Y <--------o--------> -Y | ||
1688 | // avatar | ||
1689 | // | | ||
1690 | // | | ||
1691 | // | | ||
1692 | // | | ||
1693 | // v | ||
1694 | // -X | ||
1695 | // | ||
1696 | |||
1697 | // based on the above avatar coordinate system, classify the movement into | ||
1698 | // one of left/right/back/forward. | ||
1699 | if (LocalVectorToTarget2D.Y > 0)//MoveLeft | ||
1700 | { | ||
1701 | m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT; | ||
1702 | //AgentControlFlags | ||
1703 | AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT; | ||
1704 | update_movementflag = true; | ||
1705 | } | ||
1706 | else if (LocalVectorToTarget2D.Y < 0) //MoveRight | ||
1707 | { | ||
1708 | m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT; | ||
1709 | AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT; | ||
1710 | update_movementflag = true; | ||
1711 | } | ||
1712 | if (LocalVectorToTarget2D.X < 0) //MoveBack | ||
1713 | { | ||
1714 | m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_BACK; | ||
1715 | AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_BACK; | ||
1716 | update_movementflag = true; | ||
1717 | } | ||
1718 | else if (LocalVectorToTarget2D.X > 0) //Move Forward | ||
1719 | { | ||
1720 | m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD; | ||
1721 | AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD; | ||
1722 | update_movementflag = true; | ||
1723 | } | ||
1724 | } | ||
1725 | catch (Exception e) | ||
1726 | { | ||
1727 | //Avoid system crash, can be slower but... | ||
1728 | m_log.DebugFormat("Crash! {0}", e.ToString()); | ||
1729 | } | ||
1730 | } | 1618 | } |
1731 | } | 1619 | } |
1732 | } | 1620 | } |
@@ -1759,31 +1647,26 @@ namespace OpenSim.Region.Framework.Scenes | |||
1759 | // which occurs later in the main scene loop | 1647 | // which occurs later in the main scene loop |
1760 | if (update_movementflag || (update_rotation && DCFlagKeyPressed)) | 1648 | if (update_movementflag || (update_rotation && DCFlagKeyPressed)) |
1761 | { | 1649 | { |
1762 | // m_log.DebugFormat( | 1650 | // m_log.DebugFormat( |
1763 | // "[SCENE PRESENCE]: In {0} adding velocity of {1} to {2}, umf = {3}, ur = {4}", | 1651 | // "[SCENE PRESENCE]: In {0} adding velocity of {1} to {2}, umf = {3}, ur = {4}", |
1764 | // m_scene.RegionInfo.RegionName, agent_control_v3, Name, update_movementflag, update_rotation); | 1652 | // m_scene.RegionInfo.RegionName, agent_control_v3, Name, update_movementflag, update_rotation); |
1765 | 1653 | ||
1766 | AddNewMovement(agent_control_v3, q, Nudging); | 1654 | AddNewMovement(agent_control_v3); |
1767 | |||
1768 | |||
1769 | } | 1655 | } |
1770 | // else | 1656 | // else |
1771 | // { | 1657 | // { |
1772 | // if (!update_movementflag) | 1658 | // if (!update_movementflag) |
1773 | // { | 1659 | // { |
1774 | // m_log.DebugFormat( | 1660 | // m_log.DebugFormat( |
1775 | // "[SCENE PRESENCE]: In {0} ignoring requested update of {1} for {2} as update_movementflag = false", | 1661 | // "[SCENE PRESENCE]: In {0} ignoring requested update of {1} for {2} as update_movementflag = false", |
1776 | // m_scene.RegionInfo.RegionName, agent_control_v3, Name); | 1662 | // m_scene.RegionInfo.RegionName, agent_control_v3, Name); |
1777 | // } | 1663 | // } |
1778 | // } | 1664 | // } |
1779 | 1665 | ||
1780 | if (update_movementflag && m_parentID == 0) | 1666 | if (update_movementflag && m_parentID == 0) |
1781 | Animator.UpdateMovementAnimations(); | 1667 | Animator.UpdateMovementAnimations(); |
1782 | } | 1668 | } |
1783 | 1669 | ||
1784 | if (update_movementflag && !SitGround) | ||
1785 | Animator.UpdateMovementAnimations(); | ||
1786 | |||
1787 | m_scene.EventManager.TriggerOnClientMovement(this); | 1670 | m_scene.EventManager.TriggerOnClientMovement(this); |
1788 | 1671 | ||
1789 | m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); | 1672 | m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); |
@@ -1799,24 +1682,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
1799 | /// <returns>True if movement has been updated in some way. False otherwise.</returns> | 1682 | /// <returns>True if movement has been updated in some way. False otherwise.</returns> |
1800 | public bool HandleMoveToTargetUpdate(ref Vector3 agent_control_v3) | 1683 | public bool HandleMoveToTargetUpdate(ref Vector3 agent_control_v3) |
1801 | { | 1684 | { |
1802 | // m_log.DebugFormat("[SCENE PRESENCE]: Called HandleMoveToTargetUpdate() for {0}", Name); | 1685 | // m_log.DebugFormat("[SCENE PRESENCE]: Called HandleMoveToTargetUpdate() for {0}", Name); |
1686 | |||
1803 | bool updated = false; | 1687 | bool updated = false; |
1804 | 1688 | ||
1805 | public void StopMoveToPosition() | 1689 | // m_log.DebugFormat( |
1806 | { | 1690 | // "[SCENE PRESENCE]: bAllowUpdateMoveToPosition {0}, m_moveToPositionInProgress {1}, m_autopilotMoving {2}", |
1807 | m_moveToPositionTarget = Vector3.Zero; | 1691 | // allowUpdate, m_moveToPositionInProgress, m_autopilotMoving); |
1808 | m_moveToPositionInProgress = false; | ||
1809 | } | ||
1810 | 1692 | ||
1811 | public void DoMoveToPosition(Object sender, string method, List<String> args) | 1693 | if (!m_autopilotMoving) |
1812 | { | ||
1813 | //Console.WriteLine("SP:DoMoveToPosition"); | ||
1814 | try | ||
1815 | { | 1694 | { |
1816 | double distanceToTarget = Util.GetDistanceTo(AbsolutePosition, MoveToPositionTarget); | 1695 | double distanceToTarget = Util.GetDistanceTo(AbsolutePosition, MoveToPositionTarget); |
1817 | // m_log.DebugFormat( | 1696 | // m_log.DebugFormat( |
1818 | // "[SCENE PRESENCE]: Abs pos of {0} is {1}, target {2}, distance {3}", | 1697 | // "[SCENE PRESENCE]: Abs pos of {0} is {1}, target {2}, distance {3}", |
1819 | // Name, AbsolutePosition, MoveToPositionTarget, distanceToTarget); | 1698 | // Name, AbsolutePosition, MoveToPositionTarget, distanceToTarget); |
1820 | 1699 | ||
1821 | // Check the error term of the current position in relation to the target position | 1700 | // Check the error term of the current position in relation to the target position |
1822 | if (distanceToTarget <= 1) | 1701 | if (distanceToTarget <= 1) |
@@ -1839,7 +1718,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1839 | (MoveToPositionTarget - AbsolutePosition) // vector from cur. pos to target in global coords | 1718 | (MoveToPositionTarget - AbsolutePosition) // vector from cur. pos to target in global coords |
1840 | * Matrix4.CreateFromQuaternion(Quaternion.Inverse(Rotation)); // change to avatar coords | 1719 | * Matrix4.CreateFromQuaternion(Quaternion.Inverse(Rotation)); // change to avatar coords |
1841 | // Ignore z component of vector | 1720 | // Ignore z component of vector |
1842 | // Vector3 LocalVectorToTarget2D = new Vector3((float)(LocalVectorToTarget3D.X), (float)(LocalVectorToTarget3D.Y), 0f); | 1721 | // Vector3 LocalVectorToTarget2D = new Vector3((float)(LocalVectorToTarget3D.X), (float)(LocalVectorToTarget3D.Y), 0f); |
1843 | LocalVectorToTarget3D.Normalize(); | 1722 | LocalVectorToTarget3D.Normalize(); |
1844 | 1723 | ||
1845 | // update avatar movement flags. the avatar coordinate system is as follows: | 1724 | // update avatar movement flags. the avatar coordinate system is as follows: |
@@ -1905,9 +1784,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1905 | updated = true; | 1784 | updated = true; |
1906 | } | 1785 | } |
1907 | 1786 | ||
1908 | // m_log.DebugFormat( | 1787 | // m_log.DebugFormat( |
1909 | // "[SCENE PRESENCE]: HandleMoveToTargetUpdate adding {0} to move vector {1} for {2}", | 1788 | // "[SCENE PRESENCE]: HandleMoveToTargetUpdate adding {0} to move vector {1} for {2}", |
1910 | // LocalVectorToTarget3D, agent_control_v3, Name); | 1789 | // LocalVectorToTarget3D, agent_control_v3, Name); |
1911 | 1790 | ||
1912 | agent_control_v3 += LocalVectorToTarget3D; | 1791 | agent_control_v3 += LocalVectorToTarget3D; |
1913 | } | 1792 | } |
@@ -1917,7 +1796,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1917 | m_log.DebugFormat("Crash! {0}", e.ToString()); | 1796 | m_log.DebugFormat("Crash! {0}", e.ToString()); |
1918 | } | 1797 | } |
1919 | } | 1798 | } |
1920 | } | 1799 | } |
1921 | 1800 | ||
1922 | return updated; | 1801 | return updated; |
1923 | } | 1802 | } |
@@ -2746,41 +2625,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
2746 | /// Rotate the avatar to the given rotation and apply a movement in the given relative vector | 2625 | /// Rotate the avatar to the given rotation and apply a movement in the given relative vector |
2747 | /// </summary> | 2626 | /// </summary> |
2748 | /// <param name="vec">The vector in which to move. This is relative to the rotation argument</param> | 2627 | /// <param name="vec">The vector in which to move. This is relative to the rotation argument</param> |
2749 | /// <param name="rotation">The direction in which this avatar should now face. | 2628 | public void AddNewMovement(Vector3 vec) |
2750 | public void AddNewMovement(Vector3 vec, Quaternion rotation, bool Nudging) | ||
2751 | { | 2629 | { |
2752 | if (m_isChildAgent) | ||
2753 | { | ||
2754 | // WHAT??? | ||
2755 | m_log.Debug("[SCENEPRESENCE]: AddNewMovement() called on child agent"); | ||
2756 | |||
2757 | return; | ||
2758 | } | ||
2759 | |||
2760 | m_perfMonMS = Util.EnvironmentTickCount(); | 2630 | m_perfMonMS = Util.EnvironmentTickCount(); |
2761 | 2631 | ||
2762 | Vector3 direc = vec * Rotation; | 2632 | Vector3 direc = vec * Rotation; |
2763 | direc.Normalize(); | 2633 | direc.Normalize(); |
2764 | PhysicsActor actor = m_physicsActor; | ||
2765 | |||
2766 | if (actor.Flying != m_flyingOld) // add for fly velocity control | ||
2767 | { | ||
2768 | m_flyingOld = actor.Flying; // add for fly velocity control | ||
2769 | if (!actor.Flying) m_wasFlying = true; // add for fly velocity control | ||
2770 | } | ||
2771 | |||
2772 | if (m_physicsActor.IsColliding == true) m_wasFlying = false; // add for fly velocity control | ||
2773 | |||
2774 | if ((vec.Z == 0f) && !actor.Flying) direc.Z = 0f; // Prevent camera WASD up. | ||
2775 | 2634 | ||
2776 | direc *= 0.03f * 128f * m_speedModifier; | 2635 | direc *= 0.03f * 128f * m_speedModifier; |
2777 | 2636 | ||
2637 | PhysicsActor actor = m_physicsActor; | ||
2778 | if (actor != null) | 2638 | if (actor != null) |
2779 | { | 2639 | { |
2780 | if (actor.Flying) | 2640 | if (actor.Flying) |
2781 | { | 2641 | { |
2782 | // rm speed mod direc *= 4.0f; | 2642 | direc *= 4.0f; |
2783 | direc *= 5.2f; // for speed mod | ||
2784 | //bool controlland = (((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || ((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); | 2643 | //bool controlland = (((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || ((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); |
2785 | //bool colliding = (m_physicsActor.IsColliding==true); | 2644 | //bool colliding = (m_physicsActor.IsColliding==true); |
2786 | //if (controlland) | 2645 | //if (controlland) |
@@ -2793,34 +2652,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
2793 | // m_log.Info("[AGENT]: Stop FLying"); | 2652 | // m_log.Info("[AGENT]: Stop FLying"); |
2794 | //} | 2653 | //} |
2795 | } | 2654 | } |
2796 | if (Animator.m_falling && m_wasFlying) // if falling from flying, disable motion add | ||
2797 | { | ||
2798 | direc *= 0.0f; | ||
2799 | } | ||
2800 | /* This jumping section removed to SPA | ||
2801 | else if (!actor.Flying && actor.IsColliding) | 2655 | else if (!actor.Flying && actor.IsColliding) |
2802 | { | 2656 | { |
2803 | if (direc.Z > 2.0f) | 2657 | if (direc.Z > 2.0f) |
2804 | { | 2658 | { |
2805 | if(m_animator.m_animTickJump == -1) | 2659 | direc.Z *= 3.0f; |
2806 | { | 2660 | |
2807 | direc.Z *= 3.0f; // jump | 2661 | // TODO: PreJump and jump happen too quickly. Many times prejump gets ignored. |
2808 | } | 2662 | Animator.TrySetMovementAnimation("PREJUMP"); |
2809 | else | 2663 | Animator.TrySetMovementAnimation("JUMP"); |
2810 | { | ||
2811 | direc.Z *= 0.1f; // prejump | ||
2812 | } | ||
2813 | / * Animations are controlled via GetMovementAnimation() in ScenePresenceAnimator.cs | ||
2814 | Animator.TrySetMovementAnimation("PREJUMP"); | ||
2815 | Animator.TrySetMovementAnimation("JUMP"); | ||
2816 | * / | ||
2817 | } | 2664 | } |
2818 | } */ | 2665 | } |
2819 | } | 2666 | } |
2820 | 2667 | ||
2821 | // TODO: Add the force instead of only setting it to support multiple forces per frame? | 2668 | // TODO: Add the force instead of only setting it to support multiple forces per frame? |
2822 | m_forceToApply = direc; | 2669 | m_forceToApply = direc; |
2823 | m_isNudging = Nudging; | 2670 | |
2824 | m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); | 2671 | m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); |
2825 | } | 2672 | } |
2826 | 2673 | ||
@@ -3961,7 +3808,7 @@ if (m_animator.m_jumping) force.Z = m_animator.m_jumpVelocity; // add for ju | |||
3961 | { | 3808 | { |
3962 | StartCollidingMessage.Colliders = colliding; | 3809 | StartCollidingMessage.Colliders = colliding; |
3963 | 3810 | ||
3964 | foreach (SceneObjectGroup att in Attachments) | 3811 | foreach (SceneObjectGroup att in GetAttachments()) |
3965 | Scene.EventManager.TriggerScriptCollidingStart(att.LocalId, StartCollidingMessage); | 3812 | Scene.EventManager.TriggerScriptCollidingStart(att.LocalId, StartCollidingMessage); |
3966 | } | 3813 | } |
3967 | } | 3814 | } |
@@ -3996,7 +3843,7 @@ if (m_animator.m_jumping) force.Z = m_animator.m_jumpVelocity; // add for ju | |||
3996 | { | 3843 | { |
3997 | EndCollidingMessage.Colliders = colliding; | 3844 | EndCollidingMessage.Colliders = colliding; |
3998 | 3845 | ||
3999 | foreach (SceneObjectGroup att in Attachments) | 3846 | foreach (SceneObjectGroup att in GetAttachments()) |
4000 | Scene.EventManager.TriggerScriptCollidingEnd(att.LocalId, EndCollidingMessage); | 3847 | Scene.EventManager.TriggerScriptCollidingEnd(att.LocalId, EndCollidingMessage); |
4001 | } | 3848 | } |
4002 | } | 3849 | } |
@@ -4517,7 +4364,7 @@ if (m_animator.m_jumping) force.Z = m_animator.m_jumpVelocity; // add for ju | |||
4517 | List<AvatarAttachment> attachments = m_appearance.GetAttachments(); | 4364 | List<AvatarAttachment> attachments = m_appearance.GetAttachments(); |
4518 | foreach (AvatarAttachment attach in attachments) | 4365 | foreach (AvatarAttachment attach in attachments) |
4519 | { | 4366 | { |
4520 | if (m_isDeleted) | 4367 | if (IsDeleted) |
4521 | return; | 4368 | return; |
4522 | 4369 | ||
4523 | int p = attach.AttachPoint; | 4370 | int p = attach.AttachPoint; |
@@ -4603,7 +4450,7 @@ if (m_animator.m_jumping) force.Z = m_animator.m_jumpVelocity; // add for ju | |||
4603 | public void SaveChangedAttachments() | 4450 | public void SaveChangedAttachments() |
4604 | { | 4451 | { |
4605 | // Need to copy this list because DetachToInventoryPrep mods it | 4452 | // Need to copy this list because DetachToInventoryPrep mods it |
4606 | List<SceneObjectGroup> attachments = new List<SceneObjectGroup>(Attachments.ToArray()); | 4453 | List<SceneObjectGroup> attachments = new List<SceneObjectGroup>(GetAttachments().ToArray()); |
4607 | 4454 | ||
4608 | IAttachmentsModule attachmentsModule = m_scene.AttachmentsModule; | 4455 | IAttachmentsModule attachmentsModule = m_scene.AttachmentsModule; |
4609 | if (attachmentsModule != null) | 4456 | if (attachmentsModule != null) |
@@ -4612,12 +4459,12 @@ if (m_animator.m_jumping) force.Z = m_animator.m_jumpVelocity; // add for ju | |||
4612 | { | 4459 | { |
4613 | if (grp.HasGroupChanged) // Resizer scripts? | 4460 | if (grp.HasGroupChanged) // Resizer scripts? |
4614 | { | 4461 | { |
4615 | grp.RootPart.IsAttachment = false; | 4462 | grp.IsAttachment = false; |
4616 | grp.AbsolutePosition = grp.RootPart.AttachedPos; | 4463 | grp.AbsolutePosition = grp.RootPart.AttachedPos; |
4617 | // grp.DetachToInventoryPrep(); | 4464 | // grp.DetachToInventoryPrep(); |
4618 | attachmentsModule.UpdateKnownItem(ControllingClient, | 4465 | attachmentsModule.UpdateKnownItem(ControllingClient, |
4619 | grp, grp.GetFromItemID(), grp.OwnerID); | 4466 | grp, grp.GetFromItemID(), grp.OwnerID); |
4620 | grp.RootPart.IsAttachment = true; | 4467 | grp.IsAttachment = true; |
4621 | } | 4468 | } |
4622 | } | 4469 | } |
4623 | } | 4470 | } |