diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 433 |
1 files changed, 231 insertions, 202 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 83b761c..d354c0a 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -89,6 +89,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
89 | /// </summary> | 89 | /// </summary> |
90 | private static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.1f, 0.0f, 0.3f); | 90 | private static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.1f, 0.0f, 0.3f); |
91 | 91 | ||
92 | /// <summary> | ||
93 | /// Movement updates for agents in neighboring regions are sent directly to clients. | ||
94 | /// This value only affects how often agent positions are sent to neighbor regions | ||
95 | /// for things such as distance-based update prioritization | ||
96 | /// </summary> | ||
97 | public static readonly float SIGNIFICANT_MOVEMENT = 2.0f; | ||
98 | |||
92 | public UUID currentParcelUUID = UUID.Zero; | 99 | public UUID currentParcelUUID = UUID.Zero; |
93 | 100 | ||
94 | private ISceneViewer m_sceneViewer; | 101 | private ISceneViewer m_sceneViewer; |
@@ -116,7 +123,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
116 | private ScriptControlled IgnoredControls = ScriptControlled.CONTROL_ZERO; | 123 | private ScriptControlled IgnoredControls = ScriptControlled.CONTROL_ZERO; |
117 | private ScriptControlled LastCommands = ScriptControlled.CONTROL_ZERO; | 124 | private ScriptControlled LastCommands = ScriptControlled.CONTROL_ZERO; |
118 | private bool MouseDown = false; | 125 | private bool MouseDown = false; |
119 | private SceneObjectGroup proxyObjectGroup; | 126 | // private SceneObjectGroup proxyObjectGroup; |
120 | //private SceneObjectPart proxyObjectPart = null; | 127 | //private SceneObjectPart proxyObjectPart = null; |
121 | public Vector3 lastKnownAllowedPosition; | 128 | public Vector3 lastKnownAllowedPosition; |
122 | public bool sentMessageAboutRestrictedParcelFlyingDown; | 129 | public bool sentMessageAboutRestrictedParcelFlyingDown; |
@@ -210,8 +217,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
210 | private string m_nextSitAnimation = String.Empty; | 217 | private string m_nextSitAnimation = String.Empty; |
211 | 218 | ||
212 | //PauPaw:Proper PID Controler for autopilot************ | 219 | //PauPaw:Proper PID Controler for autopilot************ |
213 | private bool m_moveToPositionInProgress; | 220 | public bool MovingToTarget { get; private set; } |
214 | private Vector3 m_moveToPositionTarget; | 221 | public Vector3 MoveToPositionTarget { get; private set; } |
215 | 222 | ||
216 | private bool m_followCamAuto; | 223 | private bool m_followCamAuto; |
217 | 224 | ||
@@ -779,8 +786,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
779 | m_controllingClient.OnStartAnim += HandleStartAnim; | 786 | m_controllingClient.OnStartAnim += HandleStartAnim; |
780 | m_controllingClient.OnStopAnim += HandleStopAnim; | 787 | m_controllingClient.OnStopAnim += HandleStopAnim; |
781 | m_controllingClient.OnForceReleaseControls += HandleForceReleaseControls; | 788 | m_controllingClient.OnForceReleaseControls += HandleForceReleaseControls; |
782 | m_controllingClient.OnAutoPilotGo += DoAutoPilot; | 789 | m_controllingClient.OnAutoPilotGo += MoveToTarget; |
783 | m_controllingClient.AddGenericPacketHandler("autopilot", DoMoveToPosition); | ||
784 | 790 | ||
785 | // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); | 791 | // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); |
786 | // ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); | 792 | // ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); |
@@ -916,7 +922,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
916 | { | 922 | { |
917 | m_log.ErrorFormat("[SCENE PRESENCE]: null appearance in MakeRoot in {0}", Scene.RegionInfo.RegionName); | 923 | m_log.ErrorFormat("[SCENE PRESENCE]: null appearance in MakeRoot in {0}", Scene.RegionInfo.RegionName); |
918 | // emergency; this really shouldn't happen | 924 | // emergency; this really shouldn't happen |
919 | m_appearance = new AvatarAppearance(UUID); | 925 | m_appearance = new AvatarAppearance(); |
920 | } | 926 | } |
921 | 927 | ||
922 | AddToPhysicalScene(isFlying); | 928 | AddToPhysicalScene(isFlying); |
@@ -1076,13 +1082,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1076 | SendTerseUpdateToAllClients(); | 1082 | SendTerseUpdateToAllClients(); |
1077 | } | 1083 | } |
1078 | 1084 | ||
1079 | /// <summary> | ||
1080 | /// | ||
1081 | /// </summary> | ||
1082 | public void StopMovement() | ||
1083 | { | ||
1084 | } | ||
1085 | |||
1086 | public void StopFlying() | 1085 | public void StopFlying() |
1087 | { | 1086 | { |
1088 | ControllingClient.StopFlying(this); | 1087 | ControllingClient.StopFlying(this); |
@@ -1378,15 +1377,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
1378 | { | 1377 | { |
1379 | return; | 1378 | return; |
1380 | } | 1379 | } |
1381 | |||
1382 | bool update_movementflag = false; | ||
1383 | 1380 | ||
1384 | if (m_allowMovement && !SitGround) | 1381 | if (m_allowMovement && !SitGround) |
1385 | { | 1382 | { |
1383 | bool update_movementflag = false; | ||
1384 | |||
1386 | if (agentData.UseClientAgentPosition) | 1385 | if (agentData.UseClientAgentPosition) |
1387 | { | 1386 | { |
1388 | m_moveToPositionInProgress = (agentData.ClientAgentPosition - AbsolutePosition).Length() > 0.2f; | 1387 | MovingToTarget = (agentData.ClientAgentPosition - AbsolutePosition).Length() > 0.2f; |
1389 | m_moveToPositionTarget = agentData.ClientAgentPosition; | 1388 | MoveToPositionTarget = agentData.ClientAgentPosition; |
1390 | } | 1389 | } |
1391 | 1390 | ||
1392 | int i = 0; | 1391 | int i = 0; |
@@ -1417,7 +1416,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1417 | if (m_parentID == 0) | 1416 | if (m_parentID == 0) |
1418 | { | 1417 | { |
1419 | bool bAllowUpdateMoveToPosition = false; | 1418 | bool bAllowUpdateMoveToPosition = false; |
1420 | bool bResetMoveToPosition = false; | ||
1421 | 1419 | ||
1422 | Vector3[] dirVectors; | 1420 | Vector3[] dirVectors; |
1423 | 1421 | ||
@@ -1430,13 +1428,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1430 | 1428 | ||
1431 | // The fact that m_movementflag is a byte needs to be fixed | 1429 | // The fact that m_movementflag is a byte needs to be fixed |
1432 | // it really should be a uint | 1430 | // it really should be a uint |
1431 | // A DIR_CONTROL_FLAG occurs when the user is trying to move in a particular direction. | ||
1433 | uint nudgehack = 250; | 1432 | uint nudgehack = 250; |
1434 | foreach (Dir_ControlFlags DCF in DIR_CONTROL_FLAGS) | 1433 | foreach (Dir_ControlFlags DCF in DIR_CONTROL_FLAGS) |
1435 | { | 1434 | { |
1436 | if (((uint)flags & (uint)DCF) != 0) | 1435 | if (((uint)flags & (uint)DCF) != 0) |
1437 | { | 1436 | { |
1438 | bResetMoveToPosition = true; | ||
1439 | DCFlagKeyPressed = true; | 1437 | DCFlagKeyPressed = true; |
1438 | |||
1440 | try | 1439 | try |
1441 | { | 1440 | { |
1442 | agent_control_v3 += dirVectors[i]; | 1441 | agent_control_v3 += dirVectors[i]; |
@@ -1480,97 +1479,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
1480 | bAllowUpdateMoveToPosition = true; | 1479 | bAllowUpdateMoveToPosition = true; |
1481 | } | 1480 | } |
1482 | } | 1481 | } |
1483 | i++; | ||
1484 | } | ||
1485 | 1482 | ||
1486 | //Paupaw:Do Proper PID for Autopilot here | 1483 | i++; |
1487 | if (bResetMoveToPosition) | ||
1488 | { | ||
1489 | m_moveToPositionTarget = Vector3.Zero; | ||
1490 | m_moveToPositionInProgress = false; | ||
1491 | update_movementflag = true; | ||
1492 | bAllowUpdateMoveToPosition = false; | ||
1493 | } | 1484 | } |
1494 | 1485 | ||
1495 | if (bAllowUpdateMoveToPosition && (m_moveToPositionInProgress && !m_autopilotMoving)) | 1486 | if (MovingToTarget) |
1496 | { | 1487 | { |
1497 | //Check the error term of the current position in relation to the target position | 1488 | // If the user has pressed a key then we want to cancel any move to target. |
1498 | if (Util.GetDistanceTo(AbsolutePosition, m_moveToPositionTarget) <= 0.5f) | 1489 | if (DCFlagKeyPressed) |
1499 | { | 1490 | { |
1500 | // we are close enough to the target | 1491 | ResetMoveToTarget(); |
1501 | m_moveToPositionTarget = Vector3.Zero; | ||
1502 | m_moveToPositionInProgress = false; | ||
1503 | update_movementflag = true; | 1492 | update_movementflag = true; |
1504 | } | 1493 | } |
1505 | else | 1494 | else if (bAllowUpdateMoveToPosition) |
1506 | { | 1495 | { |
1507 | try | 1496 | if (HandleMoveToTargetUpdate(ref agent_control_v3, bodyRotation)) |
1508 | { | 1497 | update_movementflag = true; |
1509 | // move avatar in 2D at one meter/second towards target, in avatar coordinate frame. | ||
1510 | // This movement vector gets added to the velocity through AddNewMovement(). | ||
1511 | // Theoretically we might need a more complex PID approach here if other | ||
1512 | // unknown forces are acting on the avatar and we need to adaptively respond | ||
1513 | // to such forces, but the following simple approach seems to works fine. | ||
1514 | Vector3 LocalVectorToTarget3D = | ||
1515 | (m_moveToPositionTarget - AbsolutePosition) // vector from cur. pos to target in global coords | ||
1516 | * Matrix4.CreateFromQuaternion(Quaternion.Inverse(bodyRotation)); // change to avatar coords | ||
1517 | // Ignore z component of vector | ||
1518 | Vector3 LocalVectorToTarget2D = new Vector3((float)(LocalVectorToTarget3D.X), (float)(LocalVectorToTarget3D.Y), 0f); | ||
1519 | LocalVectorToTarget2D.Normalize(); | ||
1520 | agent_control_v3 += LocalVectorToTarget2D; | ||
1521 | |||
1522 | // update avatar movement flags. the avatar coordinate system is as follows: | ||
1523 | // | ||
1524 | // +X (forward) | ||
1525 | // | ||
1526 | // ^ | ||
1527 | // | | ||
1528 | // | | ||
1529 | // | | ||
1530 | // | | ||
1531 | // (left) +Y <--------o--------> -Y | ||
1532 | // avatar | ||
1533 | // | | ||
1534 | // | | ||
1535 | // | | ||
1536 | // | | ||
1537 | // v | ||
1538 | // -X | ||
1539 | // | ||
1540 | |||
1541 | // based on the above avatar coordinate system, classify the movement into | ||
1542 | // one of left/right/back/forward. | ||
1543 | if (LocalVectorToTarget2D.Y > 0)//MoveLeft | ||
1544 | { | ||
1545 | m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT; | ||
1546 | //AgentControlFlags | ||
1547 | AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT; | ||
1548 | update_movementflag = true; | ||
1549 | } | ||
1550 | else if (LocalVectorToTarget2D.Y < 0) //MoveRight | ||
1551 | { | ||
1552 | m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT; | ||
1553 | AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT; | ||
1554 | update_movementflag = true; | ||
1555 | } | ||
1556 | if (LocalVectorToTarget2D.X < 0) //MoveBack | ||
1557 | { | ||
1558 | m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_BACK; | ||
1559 | AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_BACK; | ||
1560 | update_movementflag = true; | ||
1561 | } | ||
1562 | else if (LocalVectorToTarget2D.X > 0) //Move Forward | ||
1563 | { | ||
1564 | m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD; | ||
1565 | AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD; | ||
1566 | update_movementflag = true; | ||
1567 | } | ||
1568 | } | ||
1569 | catch (Exception e) | ||
1570 | { | ||
1571 | //Avoid system crash, can be slower but... | ||
1572 | m_log.DebugFormat("Crash! {0}", e.ToString()); | ||
1573 | } | ||
1574 | } | 1498 | } |
1575 | } | 1499 | } |
1576 | } | 1500 | } |
@@ -1608,74 +1532,208 @@ namespace OpenSim.Region.Framework.Scenes | |||
1608 | // "In {0} adding velocity to {1} of {2}", m_scene.RegionInfo.RegionName, Name, agent_control_v3); | 1532 | // "In {0} adding velocity to {1} of {2}", m_scene.RegionInfo.RegionName, Name, agent_control_v3); |
1609 | 1533 | ||
1610 | AddNewMovement(agent_control_v3, q); | 1534 | AddNewMovement(agent_control_v3, q); |
1611 | |||
1612 | |||
1613 | } | 1535 | } |
1614 | } | ||
1615 | 1536 | ||
1616 | if (update_movementflag && ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) == 0) && (m_parentID == 0) && !SitGround) | 1537 | if (update_movementflag |
1617 | Animator.UpdateMovementAnimations(); | 1538 | && ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) == 0) |
1539 | && (m_parentID == 0) | ||
1540 | && !SitGround) | ||
1541 | Animator.UpdateMovementAnimations(); | ||
1542 | } | ||
1618 | 1543 | ||
1619 | m_scene.EventManager.TriggerOnClientMovement(this); | 1544 | m_scene.EventManager.TriggerOnClientMovement(this); |
1620 | 1545 | ||
1621 | m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); | 1546 | m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); |
1622 | } | 1547 | } |
1623 | 1548 | ||
1624 | public void DoAutoPilot(uint not_used, Vector3 Pos, IClientAPI remote_client) | 1549 | /// <summary> |
1550 | /// Calculate an update to move the presence to the set target. | ||
1551 | /// </summary> | ||
1552 | /// <remarks> | ||
1553 | /// This doesn't actually perform the movement. Instead, it adds its vector to agent_control_v3. | ||
1554 | /// </remarks> | ||
1555 | /// <param value="agent_control_v3">Cumulative agent movement that this method will update.</param> | ||
1556 | /// <param value="bodyRotation">New body rotation of the avatar.</param> | ||
1557 | /// <returns>True if movement has been updated in some way. False otherwise.</returns> | ||
1558 | public bool HandleMoveToTargetUpdate(ref Vector3 agent_control_v3, Quaternion bodyRotation) | ||
1625 | { | 1559 | { |
1626 | m_autopilotMoving = true; | 1560 | // m_log.DebugFormat("[SCENE PRESENCE]: Called HandleMoveToTargetUpdate() for {0}", Name); |
1627 | m_autoPilotTarget = Pos; | ||
1628 | m_sitAtAutoTarget = false; | ||
1629 | PrimitiveBaseShape proxy = PrimitiveBaseShape.Default; | ||
1630 | //proxy.PCode = (byte)PCode.ParticleSystem; | ||
1631 | 1561 | ||
1632 | proxyObjectGroup = new SceneObjectGroup(UUID, Pos, Rotation, proxy); | 1562 | bool updated = false; |
1633 | proxyObjectGroup.AttachToScene(m_scene); | ||
1634 | |||
1635 | // Commented out this code since it could never have executed, but might still be informative. | ||
1636 | // if (proxyObjectGroup != null) | ||
1637 | // { | ||
1638 | proxyObjectGroup.SendGroupFullUpdate(); | ||
1639 | remote_client.SendSitResponse(proxyObjectGroup.UUID, Vector3.Zero, Quaternion.Identity, true, Vector3.Zero, Vector3.Zero, false); | ||
1640 | m_scene.DeleteSceneObject(proxyObjectGroup, false); | ||
1641 | // } | ||
1642 | // else | ||
1643 | // { | ||
1644 | // m_autopilotMoving = false; | ||
1645 | // m_autoPilotTarget = Vector3.Zero; | ||
1646 | // ControllingClient.SendAlertMessage("Autopilot cancelled"); | ||
1647 | // } | ||
1648 | } | ||
1649 | 1563 | ||
1650 | public void DoMoveToPosition(Object sender, string method, List<String> args) | 1564 | // m_log.DebugFormat( |
1651 | { | 1565 | // "[SCENE PRESENCE]: bAllowUpdateMoveToPosition {0}, m_moveToPositionInProgress {1}, m_autopilotMoving {2}", |
1652 | try | 1566 | // allowUpdate, m_moveToPositionInProgress, m_autopilotMoving); |
1567 | |||
1568 | if (!m_autopilotMoving) | ||
1653 | { | 1569 | { |
1654 | float locx = 0f; | 1570 | double distanceToTarget = Util.GetDistanceTo(AbsolutePosition, MoveToPositionTarget); |
1655 | float locy = 0f; | 1571 | // m_log.DebugFormat( |
1656 | float locz = 0f; | 1572 | // "[SCENE PRESENCE]: Abs pos of {0} is {1}, target {2}, distance {3}", |
1657 | uint regionX = 0; | 1573 | // Name, AbsolutePosition, MoveToPositionTarget, distanceToTarget); |
1658 | uint regionY = 0; | 1574 | |
1659 | try | 1575 | // Check the error term of the current position in relation to the target position |
1576 | if (distanceToTarget <= 1) | ||
1660 | { | 1577 | { |
1661 | Utils.LongToUInts(Scene.RegionInfo.RegionHandle, out regionX, out regionY); | 1578 | // We are close enough to the target |
1662 | locx = Convert.ToSingle(args[0]) - (float)regionX; | 1579 | AbsolutePosition = MoveToPositionTarget; |
1663 | locy = Convert.ToSingle(args[1]) - (float)regionY; | 1580 | ResetMoveToTarget(); |
1664 | locz = Convert.ToSingle(args[2]); | 1581 | updated = true; |
1665 | } | 1582 | } |
1666 | catch (InvalidCastException) | 1583 | else |
1667 | { | 1584 | { |
1668 | m_log.Error("[CLIENT]: Invalid autopilot request"); | 1585 | try |
1669 | return; | 1586 | { |
1587 | // move avatar in 3D at one meter/second towards target, in avatar coordinate frame. | ||
1588 | // This movement vector gets added to the velocity through AddNewMovement(). | ||
1589 | // Theoretically we might need a more complex PID approach here if other | ||
1590 | // unknown forces are acting on the avatar and we need to adaptively respond | ||
1591 | // to such forces, but the following simple approach seems to works fine. | ||
1592 | Vector3 LocalVectorToTarget3D = | ||
1593 | (MoveToPositionTarget - AbsolutePosition) // vector from cur. pos to target in global coords | ||
1594 | * Matrix4.CreateFromQuaternion(Quaternion.Inverse(bodyRotation)); // change to avatar coords | ||
1595 | // Ignore z component of vector | ||
1596 | // Vector3 LocalVectorToTarget2D = new Vector3((float)(LocalVectorToTarget3D.X), (float)(LocalVectorToTarget3D.Y), 0f); | ||
1597 | LocalVectorToTarget3D.Normalize(); | ||
1598 | |||
1599 | // update avatar movement flags. the avatar coordinate system is as follows: | ||
1600 | // | ||
1601 | // +X (forward) | ||
1602 | // | ||
1603 | // ^ | ||
1604 | // | | ||
1605 | // | | ||
1606 | // | | ||
1607 | // | | ||
1608 | // (left) +Y <--------o--------> -Y | ||
1609 | // avatar | ||
1610 | // | | ||
1611 | // | | ||
1612 | // | | ||
1613 | // | | ||
1614 | // v | ||
1615 | // -X | ||
1616 | // | ||
1617 | |||
1618 | // based on the above avatar coordinate system, classify the movement into | ||
1619 | // one of left/right/back/forward. | ||
1620 | if (LocalVectorToTarget3D.X < 0) //MoveBack | ||
1621 | { | ||
1622 | m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_BACK; | ||
1623 | AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_BACK; | ||
1624 | updated = true; | ||
1625 | } | ||
1626 | else if (LocalVectorToTarget3D.X > 0) //Move Forward | ||
1627 | { | ||
1628 | m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD; | ||
1629 | AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD; | ||
1630 | updated = true; | ||
1631 | } | ||
1632 | |||
1633 | if (LocalVectorToTarget3D.Y > 0) //MoveLeft | ||
1634 | { | ||
1635 | m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT; | ||
1636 | AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT; | ||
1637 | updated = true; | ||
1638 | } | ||
1639 | else if (LocalVectorToTarget3D.Y < 0) //MoveRight | ||
1640 | { | ||
1641 | m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT; | ||
1642 | AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT; | ||
1643 | updated = true; | ||
1644 | } | ||
1645 | |||
1646 | if (LocalVectorToTarget3D.Z > 0) //Up | ||
1647 | { | ||
1648 | // Don't set these flags for up or down - doing so will make the avatar crouch or | ||
1649 | // keep trying to jump even if walking along level ground | ||
1650 | //m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_UP; | ||
1651 | //AgentControlFlags | ||
1652 | //AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_UP; | ||
1653 | updated = true; | ||
1654 | } | ||
1655 | else if (LocalVectorToTarget3D.Z < 0) //Down | ||
1656 | { | ||
1657 | //m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_DOWN; | ||
1658 | //AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_DOWN; | ||
1659 | updated = true; | ||
1660 | } | ||
1661 | |||
1662 | // m_log.DebugFormat( | ||
1663 | // "[SCENE PRESENCE]: HandleMoveToTargetUpdate adding {0} to move vector {1} for {2}", | ||
1664 | // LocalVectorToTarget3D, agent_control_v3, Name); | ||
1665 | |||
1666 | agent_control_v3 += LocalVectorToTarget3D; | ||
1667 | } | ||
1668 | catch (Exception e) | ||
1669 | { | ||
1670 | //Avoid system crash, can be slower but... | ||
1671 | m_log.DebugFormat("Crash! {0}", e.ToString()); | ||
1672 | } | ||
1670 | } | 1673 | } |
1671 | m_moveToPositionInProgress = true; | ||
1672 | m_moveToPositionTarget = new Vector3(locx, locy, locz); | ||
1673 | } | ||
1674 | catch (Exception ex) | ||
1675 | { | ||
1676 | //Why did I get this error? | ||
1677 | m_log.Error("[SCENEPRESENCE]: DoMoveToPosition" + ex); | ||
1678 | } | 1674 | } |
1675 | |||
1676 | return updated; | ||
1677 | } | ||
1678 | |||
1679 | /// <summary> | ||
1680 | /// Move to the given target over time. | ||
1681 | /// </summary> | ||
1682 | /// <param name="pos"></param> | ||
1683 | public void MoveToTarget(Vector3 pos) | ||
1684 | { | ||
1685 | // m_log.DebugFormat( | ||
1686 | // "[SCENE PRESENCE]: Avatar {0} received request to move to position {1} in {2}", | ||
1687 | // Name, pos, m_scene.RegionInfo.RegionName); | ||
1688 | |||
1689 | if (pos.X < 0 || pos.X >= Constants.RegionSize | ||
1690 | || pos.Y < 0 || pos.Y >= Constants.RegionSize | ||
1691 | || pos.Z < 0) | ||
1692 | return; | ||
1693 | |||
1694 | // Vector3 heightAdjust = new Vector3(0, 0, Appearance.AvatarHeight / 2); | ||
1695 | // pos += heightAdjust; | ||
1696 | // | ||
1697 | // // Anti duck-walking measure | ||
1698 | // if (Math.Abs(pos.Z - AbsolutePosition.Z) < 0.2f) | ||
1699 | // { | ||
1700 | //// m_log.DebugFormat("[SCENE PRESENCE]: Adjusting MoveToPosition from {0} to {1}", pos, AbsolutePosition); | ||
1701 | // pos.Z = AbsolutePosition.Z; | ||
1702 | // } | ||
1703 | |||
1704 | float terrainHeight = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; | ||
1705 | pos.Z = Math.Max(terrainHeight, pos.Z); | ||
1706 | |||
1707 | // Fudge factor. It appears that if one clicks "go here" on a piece of ground, the go here request is | ||
1708 | // always slightly higher than the actual terrain height. | ||
1709 | // FIXME: This constrains NOC movements as well, so should be somewhere else. | ||
1710 | if (pos.Z - terrainHeight < 0.2) | ||
1711 | pos.Z = terrainHeight; | ||
1712 | |||
1713 | m_log.DebugFormat( | ||
1714 | "[SCENE PRESENCE]: Avatar {0} set move to target {1} (terrain height {2}) in {3}", | ||
1715 | Name, pos, terrainHeight, m_scene.RegionInfo.RegionName); | ||
1716 | |||
1717 | if (pos.Z > terrainHeight) | ||
1718 | PhysicsActor.Flying = true; | ||
1719 | |||
1720 | MovingToTarget = true; | ||
1721 | MoveToPositionTarget = pos; | ||
1722 | |||
1723 | Vector3 agent_control_v3 = new Vector3(); | ||
1724 | HandleMoveToTargetUpdate(ref agent_control_v3, Rotation); | ||
1725 | AddNewMovement(agent_control_v3, Rotation); | ||
1726 | } | ||
1727 | |||
1728 | /// <summary> | ||
1729 | /// Reset the move to target. | ||
1730 | /// </summary> | ||
1731 | public void ResetMoveToTarget() | ||
1732 | { | ||
1733 | m_log.DebugFormat("[SCENE PRESENCE]: Resetting move to target for {0}", Name); | ||
1734 | |||
1735 | MovingToTarget = false; | ||
1736 | MoveToPositionTarget = Vector3.Zero; | ||
1679 | } | 1737 | } |
1680 | 1738 | ||
1681 | private void CheckAtSitTarget() | 1739 | private void CheckAtSitTarget() |
@@ -1832,7 +1890,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1832 | bool forceMouselook = false; | 1890 | bool forceMouselook = false; |
1833 | 1891 | ||
1834 | //SceneObjectPart part = m_scene.GetSceneObjectPart(targetID); | 1892 | //SceneObjectPart part = m_scene.GetSceneObjectPart(targetID); |
1835 | SceneObjectPart part = FindNextAvailableSitTarget(targetID); | 1893 | SceneObjectPart part = FindNextAvailableSitTarget(targetID); |
1836 | if (part != null) | 1894 | if (part != null) |
1837 | { | 1895 | { |
1838 | // TODO: determine position to sit at based on scene geometry; don't trust offset from client | 1896 | // TODO: determine position to sit at based on scene geometry; don't trust offset from client |
@@ -1908,14 +1966,23 @@ namespace OpenSim.Region.Framework.Scenes | |||
1908 | HandleAgentSit(remoteClient, UUID); | 1966 | HandleAgentSit(remoteClient, UUID); |
1909 | } | 1967 | } |
1910 | 1968 | ||
1969 | // public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset, string sitAnimation) | ||
1911 | public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset) | 1970 | public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset) |
1912 | { | 1971 | { |
1913 | if (m_parentID != 0) | 1972 | if (m_parentID != 0) |
1914 | { | 1973 | { |
1915 | StandUp(); | 1974 | StandUp(); |
1916 | } | 1975 | } |
1976 | |||
1977 | // if (!String.IsNullOrEmpty(sitAnimation)) | ||
1978 | // { | ||
1979 | // m_nextSitAnimation = sitAnimation; | ||
1980 | // } | ||
1981 | // else | ||
1982 | // { | ||
1917 | m_nextSitAnimation = "SIT"; | 1983 | m_nextSitAnimation = "SIT"; |
1918 | 1984 | // } | |
1985 | |||
1919 | //SceneObjectPart part = m_scene.GetSceneObjectPart(targetID); | 1986 | //SceneObjectPart part = m_scene.GetSceneObjectPart(targetID); |
1920 | SceneObjectPart part = FindNextAvailableSitTarget(targetID); | 1987 | SceneObjectPart part = FindNextAvailableSitTarget(targetID); |
1921 | 1988 | ||
@@ -1940,7 +2007,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1940 | } | 2007 | } |
1941 | else | 2008 | else |
1942 | { | 2009 | { |
1943 | |||
1944 | m_log.Warn("Sit requested on unknown object: " + targetID.ToString()); | 2010 | m_log.Warn("Sit requested on unknown object: " + targetID.ToString()); |
1945 | } | 2011 | } |
1946 | 2012 | ||
@@ -2138,44 +2204,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2138 | SendSitResponse(ControllingClient, m_requestedSitTargetUUID, collisionPoint - m_requestedSitOffset, Quaternion.Identity); | 2204 | SendSitResponse(ControllingClient, m_requestedSitTargetUUID, collisionPoint - m_requestedSitOffset, Quaternion.Identity); |
2139 | } | 2205 | } |
2140 | */ | 2206 | */ |
2141 | public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset, string sitAnimation) | ||
2142 | { | ||
2143 | if (m_parentID != 0) | ||
2144 | { | ||
2145 | StandUp(); | ||
2146 | } | ||
2147 | if (!String.IsNullOrEmpty(sitAnimation)) | ||
2148 | { | ||
2149 | m_nextSitAnimation = sitAnimation; | ||
2150 | } | ||
2151 | else | ||
2152 | { | ||
2153 | m_nextSitAnimation = "SIT"; | ||
2154 | } | ||
2155 | |||
2156 | //SceneObjectPart part = m_scene.GetSceneObjectPart(targetID); | ||
2157 | SceneObjectPart part = FindNextAvailableSitTarget(targetID); | ||
2158 | if (part != null) | ||
2159 | { | ||
2160 | m_requestedSitTargetID = part.LocalId; | ||
2161 | //m_requestedSitOffset = offset; | ||
2162 | m_requestedSitTargetUUID = targetID; | ||
2163 | 2207 | ||
2164 | m_log.DebugFormat("[SIT]: Client requested Sit Position: {0}", offset); | ||
2165 | |||
2166 | if (m_scene.PhysicsScene.SupportsRayCast()) | ||
2167 | { | ||
2168 | //SitRayCastAvatarPosition(part); | ||
2169 | //return; | ||
2170 | } | ||
2171 | } | ||
2172 | else | ||
2173 | { | ||
2174 | m_log.Warn("Sit requested on unknown object: " + targetID); | ||
2175 | } | ||
2176 | |||
2177 | SendSitResponse(remoteClient, targetID, offset, Quaternion.Identity); | ||
2178 | } | ||
2179 | 2208 | ||
2180 | public void HandleAgentSit(IClientAPI remoteClient, UUID agentID) | 2209 | public void HandleAgentSit(IClientAPI remoteClient, UUID agentID) |
2181 | { | 2210 | { |
@@ -2647,10 +2676,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
2647 | /// <param name="avatar"></param> | 2676 | /// <param name="avatar"></param> |
2648 | public void SendAppearanceToAgent(ScenePresence avatar) | 2677 | public void SendAppearanceToAgent(ScenePresence avatar) |
2649 | { | 2678 | { |
2650 | // m_log.WarnFormat("[SP] Send appearance from {0} to {1}",m_uuid,avatar.ControllingClient.AgentId); | 2679 | // m_log.DebugFormat( |
2680 | // "[SCENE PRESENCE] Send appearance from {0} {1} to {2} {3}", Name, m_uuid, avatar.Name, avatar.UUID); | ||
2651 | 2681 | ||
2652 | avatar.ControllingClient.SendAppearance( | 2682 | avatar.ControllingClient.SendAppearance( |
2653 | m_appearance.Owner, m_appearance.VisualParams, m_appearance.Texture.GetBytes()); | 2683 | UUID, m_appearance.VisualParams, m_appearance.Texture.GetBytes()); |
2654 | } | 2684 | } |
2655 | 2685 | ||
2656 | // Because appearance setting is in a module, we actually need | 2686 | // Because appearance setting is in a module, we actually need |
@@ -2659,7 +2689,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
2659 | public AvatarAppearance Appearance | 2689 | public AvatarAppearance Appearance |
2660 | { | 2690 | { |
2661 | get { return m_appearance; } | 2691 | get { return m_appearance; } |
2662 | set { m_appearance = value; } | 2692 | set |
2693 | { | ||
2694 | m_appearance = value; | ||
2695 | // m_log.DebugFormat("[SCENE PRESENCE]: Set appearance for {0} to {1}", Name, value); | ||
2696 | } | ||
2663 | } | 2697 | } |
2664 | 2698 | ||
2665 | #endregion | 2699 | #endregion |
@@ -2671,15 +2705,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2671 | /// </summary> | 2705 | /// </summary> |
2672 | protected void CheckForSignificantMovement() | 2706 | protected void CheckForSignificantMovement() |
2673 | { | 2707 | { |
2674 | // Movement updates for agents in neighboring regions are sent directly to clients. | ||
2675 | // This value only affects how often agent positions are sent to neighbor regions | ||
2676 | // for things such as distance-based update prioritization | ||
2677 | const float SIGNIFICANT_MOVEMENT = 2.0f; | ||
2678 | |||
2679 | if (Util.GetDistanceTo(AbsolutePosition, posLastSignificantMove) > SIGNIFICANT_MOVEMENT) | 2708 | if (Util.GetDistanceTo(AbsolutePosition, posLastSignificantMove) > SIGNIFICANT_MOVEMENT) |
2680 | { | 2709 | { |
2681 | posLastSignificantMove = AbsolutePosition; | 2710 | posLastSignificantMove = AbsolutePosition; |
2682 | m_scene.EventManager.TriggerSignificantClientMovement(m_controllingClient); | 2711 | m_scene.EventManager.TriggerSignificantClientMovement(this); |
2683 | } | 2712 | } |
2684 | 2713 | ||
2685 | // Minimum Draw distance is 64 meters, the Radius of the draw distance sphere is 32m | 2714 | // Minimum Draw distance is 64 meters, the Radius of the draw distance sphere is 32m |