aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/ScenePresence.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs110
1 files changed, 70 insertions, 40 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 990ef6e..5543964 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -801,6 +801,7 @@ namespace OpenSim.Region.Framework.Scenes
801 { 801 {
802 ControllingClient.OnCompleteMovementToRegion += CompleteMovement; 802 ControllingClient.OnCompleteMovementToRegion += CompleteMovement;
803 ControllingClient.OnAgentUpdate += HandleAgentUpdate; 803 ControllingClient.OnAgentUpdate += HandleAgentUpdate;
804 ControllingClient.OnAgentCameraUpdate += HandleAgentCamerasUpdate;
804 ControllingClient.OnAgentRequestSit += HandleAgentRequestSit; 805 ControllingClient.OnAgentRequestSit += HandleAgentRequestSit;
805 ControllingClient.OnAgentSit += HandleAgentSit; 806 ControllingClient.OnAgentSit += HandleAgentSit;
806 ControllingClient.OnSetAlwaysRun += HandleSetAlwaysRun; 807 ControllingClient.OnSetAlwaysRun += HandleSetAlwaysRun;
@@ -1438,9 +1439,9 @@ namespace OpenSim.Region.Framework.Scenes
1438 /// </summary> 1439 /// </summary>
1439 public void HandleAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData) 1440 public void HandleAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData)
1440 { 1441 {
1441// m_log.DebugFormat( 1442 //m_log.DebugFormat(
1442// "[SCENE PRESENCE]: In {0} received agent update from {1}, flags {2}", 1443 // "[SCENE PRESENCE]: In {0} received agent update from {1}, flags {2}",
1443// Scene.RegionInfo.RegionName, remoteClient.Name, (AgentManager.ControlFlags)agentData.ControlFlags); 1444 // Scene.RegionInfo.RegionName, remoteClient.Name, (AgentManager.ControlFlags)agentData.ControlFlags);
1444 1445
1445 if (IsChildAgent) 1446 if (IsChildAgent)
1446 { 1447 {
@@ -1448,10 +1449,6 @@ namespace OpenSim.Region.Framework.Scenes
1448 return; 1449 return;
1449 } 1450 }
1450 1451
1451 ++m_movementUpdateCount;
1452 if (m_movementUpdateCount < 1)
1453 m_movementUpdateCount = 1;
1454
1455 #region Sanity Checking 1452 #region Sanity Checking
1456 1453
1457 // This is irritating. Really. 1454 // This is irritating. Really.
@@ -1482,21 +1479,6 @@ namespace OpenSim.Region.Framework.Scenes
1482 1479
1483 AgentManager.ControlFlags flags = (AgentManager.ControlFlags)agentData.ControlFlags; 1480 AgentManager.ControlFlags flags = (AgentManager.ControlFlags)agentData.ControlFlags;
1484 1481
1485 // Camera location in world. We'll need to raytrace
1486 // from this location from time to time.
1487 CameraPosition = agentData.CameraCenter;
1488 if (Vector3.Distance(m_lastCameraPosition, CameraPosition) >= Scene.RootReprioritizationDistance)
1489 {
1490 ReprioritizeUpdates();
1491 m_lastCameraPosition = CameraPosition;
1492 }
1493
1494 // Use these three vectors to figure out what the agent is looking at
1495 // Convert it to a Matrix and/or Quaternion
1496 CameraAtAxis = agentData.CameraAtAxis;
1497 CameraLeftAxis = agentData.CameraLeftAxis;
1498 CameraUpAxis = agentData.CameraUpAxis;
1499
1500 // The Agent's Draw distance setting 1482 // The Agent's Draw distance setting
1501 // When we get to the point of re-computing neighbors everytime this 1483 // When we get to the point of re-computing neighbors everytime this
1502 // changes, then start using the agent's drawdistance rather than the 1484 // changes, then start using the agent's drawdistance rather than the
@@ -1504,12 +1486,6 @@ namespace OpenSim.Region.Framework.Scenes
1504 // DrawDistance = agentData.Far; 1486 // DrawDistance = agentData.Far;
1505 DrawDistance = Scene.DefaultDrawDistance; 1487 DrawDistance = Scene.DefaultDrawDistance;
1506 1488
1507 // Check if Client has camera in 'follow cam' or 'build' mode.
1508 Vector3 camdif = (Vector3.One * Rotation - Vector3.One * CameraRotation);
1509
1510 m_followCamAuto = ((CameraUpAxis.Z > 0.959f && CameraUpAxis.Z < 0.98f)
1511 && (Math.Abs(camdif.X) < 0.4f && Math.Abs(camdif.Y) < 0.4f)) ? true : false;
1512
1513 m_mouseLook = (flags & AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0; 1489 m_mouseLook = (flags & AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0;
1514 m_leftButtonDown = (flags & AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0; 1490 m_leftButtonDown = (flags & AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0;
1515 1491
@@ -1529,17 +1505,6 @@ namespace OpenSim.Region.Framework.Scenes
1529 StandUp(); 1505 StandUp();
1530 } 1506 }
1531 1507
1532 //m_log.DebugFormat("[FollowCam]: {0}", m_followCamAuto);
1533 // Raycast from the avatar's head to the camera to see if there's anything blocking the view
1534 if ((m_movementUpdateCount % NumMovementsBetweenRayCast) == 0 && m_scene.PhysicsScene.SupportsRayCast())
1535 {
1536 if (m_followCamAuto)
1537 {
1538 Vector3 posAdjusted = m_pos + HEAD_ADJUSTMENT;
1539 m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(CameraPosition - posAdjusted), Vector3.Distance(CameraPosition, posAdjusted) + 0.3f, RayCastCameraCallback);
1540 }
1541 }
1542
1543 uint flagsForScripts = (uint)flags; 1508 uint flagsForScripts = (uint)flags;
1544 flags = RemoveIgnoredControls(flags, IgnoredControls); 1509 flags = RemoveIgnoredControls(flags, IgnoredControls);
1545 1510
@@ -1764,9 +1729,74 @@ namespace OpenSim.Region.Framework.Scenes
1764 } 1729 }
1765 1730
1766 m_scene.EventManager.TriggerOnClientMovement(this); 1731 m_scene.EventManager.TriggerOnClientMovement(this);
1767 TriggerScenePresenceUpdated();
1768 } 1732 }
1769 1733
1734
1735 /// <summary>
1736 /// This is the event handler for client cameras. If a client is moving, or moving the camera, this event is triggering.
1737 /// </summary>
1738 public void HandleAgentCamerasUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData)
1739 {
1740 //m_log.DebugFormat(
1741 // "[SCENE PRESENCE]: In {0} received agent camera update from {1}, flags {2}",
1742 // Scene.RegionInfo.RegionName, remoteClient.Name, (AgentManager.ControlFlags)agentData.ControlFlags);
1743
1744 if (IsChildAgent)
1745 {
1746 // // m_log.Debug("DEBUG: HandleAgentUpdate: child agent");
1747 return;
1748 }
1749
1750 ++m_movementUpdateCount;
1751 if (m_movementUpdateCount < 1)
1752 m_movementUpdateCount = 1;
1753
1754
1755 AgentManager.ControlFlags flags = (AgentManager.ControlFlags)agentData.ControlFlags;
1756
1757 // Camera location in world. We'll need to raytrace
1758 // from this location from time to time.
1759 CameraPosition = agentData.CameraCenter;
1760 if (Vector3.Distance(m_lastCameraPosition, CameraPosition) >= Scene.RootReprioritizationDistance)
1761 {
1762 ReprioritizeUpdates();
1763 m_lastCameraPosition = CameraPosition;
1764 }
1765
1766 // Use these three vectors to figure out what the agent is looking at
1767 // Convert it to a Matrix and/or Quaternion
1768 CameraAtAxis = agentData.CameraAtAxis;
1769 CameraLeftAxis = agentData.CameraLeftAxis;
1770 CameraUpAxis = agentData.CameraUpAxis;
1771
1772 // The Agent's Draw distance setting
1773 // When we get to the point of re-computing neighbors everytime this
1774 // changes, then start using the agent's drawdistance rather than the
1775 // region's draw distance.
1776 // DrawDistance = agentData.Far;
1777 DrawDistance = Scene.DefaultDrawDistance;
1778
1779 // Check if Client has camera in 'follow cam' or 'build' mode.
1780 Vector3 camdif = (Vector3.One * Rotation - Vector3.One * CameraRotation);
1781
1782 m_followCamAuto = ((CameraUpAxis.Z > 0.959f && CameraUpAxis.Z < 0.98f)
1783 && (Math.Abs(camdif.X) < 0.4f && Math.Abs(camdif.Y) < 0.4f)) ? true : false;
1784
1785
1786 //m_log.DebugFormat("[FollowCam]: {0}", m_followCamAuto);
1787 // Raycast from the avatar's head to the camera to see if there's anything blocking the view
1788 if ((m_movementUpdateCount % NumMovementsBetweenRayCast) == 0 && m_scene.PhysicsScene.SupportsRayCast())
1789 {
1790 if (m_followCamAuto)
1791 {
1792 Vector3 posAdjusted = m_pos + HEAD_ADJUSTMENT;
1793 m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(CameraPosition - posAdjusted), Vector3.Distance(CameraPosition, posAdjusted) + 0.3f, RayCastCameraCallback);
1794 }
1795 }
1796
1797 TriggerScenePresenceUpdated();
1798 }
1799
1770 /// <summary> 1800 /// <summary>
1771 /// Calculate an update to move the presence to the set target. 1801 /// Calculate an update to move the presence to the set target.
1772 /// </summary> 1802 /// </summary>