diff options
Diffstat (limited to 'OpenSim/Region')
4 files changed, 180 insertions, 146 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 66a8ea7..6c58aac 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | |||
@@ -96,6 +96,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
96 | public event Action<IClientAPI, bool> OnCompleteMovementToRegion; | 96 | public event Action<IClientAPI, bool> OnCompleteMovementToRegion; |
97 | public event UpdateAgent OnPreAgentUpdate; | 97 | public event UpdateAgent OnPreAgentUpdate; |
98 | public event UpdateAgent OnAgentUpdate; | 98 | public event UpdateAgent OnAgentUpdate; |
99 | public event UpdateAgent OnAgentCameraUpdate; | ||
99 | public event AgentRequestSit OnAgentRequestSit; | 100 | public event AgentRequestSit OnAgentRequestSit; |
100 | public event AgentSit OnAgentSit; | 101 | public event AgentSit OnAgentSit; |
101 | public event AvatarPickerRequest OnAvatarPickerRequest; | 102 | public event AvatarPickerRequest OnAvatarPickerRequest; |
@@ -357,9 +358,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
357 | /// This does mean that agent updates must be processed synchronously, at least for each client, and called methods | 358 | /// This does mean that agent updates must be processed synchronously, at least for each client, and called methods |
358 | /// cannot retain a reference to it outside of that method. | 359 | /// cannot retain a reference to it outside of that method. |
359 | /// </remarks> | 360 | /// </remarks> |
360 | private AgentUpdateArgs m_lastAgentUpdateArgs = new AgentUpdateArgs(); | ||
361 | |||
362 | private AgentUpdateArgs m_thisAgentUpdateArgs = new AgentUpdateArgs(); | 361 | private AgentUpdateArgs m_thisAgentUpdateArgs = new AgentUpdateArgs(); |
362 | private float qdelta1; | ||
363 | private float qdelta2; | ||
364 | private float vdelta1; | ||
365 | private float vdelta2; | ||
366 | private float vdelta3; | ||
367 | private float vdelta4; | ||
363 | 368 | ||
364 | protected Dictionary<PacketType, PacketProcessor> m_packetHandlers = new Dictionary<PacketType, PacketProcessor>(); | 369 | protected Dictionary<PacketType, PacketProcessor> m_packetHandlers = new Dictionary<PacketType, PacketProcessor>(); |
365 | protected Dictionary<string, GenericMessage> m_genericPacketHandlers = new Dictionary<string, GenericMessage>(); //PauPaw:Local Generic Message handlers | 370 | protected Dictionary<string, GenericMessage> m_genericPacketHandlers = new Dictionary<string, GenericMessage>(); //PauPaw:Local Generic Message handlers |
@@ -5571,57 +5576,75 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5571 | 5576 | ||
5572 | #region Scene/Avatar | 5577 | #region Scene/Avatar |
5573 | 5578 | ||
5579 | private const float QDELTA = 0.01f; | ||
5580 | private const float VDELTA = 0.01f; | ||
5581 | |||
5574 | /// <summary> | 5582 | /// <summary> |
5575 | /// This checks the update significance against the last update made. | 5583 | /// This checks the update significance against the last update made. |
5576 | /// </summary> | 5584 | /// </summary> |
5577 | /// <remarks>Can only be called by one thread at a time</remarks> | 5585 | /// <remarks>Can only be called by one thread at a time</remarks> |
5578 | /// <returns>/returns> | 5586 | /// <returns></returns> |
5579 | /// <param name='x'></param> | 5587 | /// <param name='x'></param> |
5580 | public bool CheckAgentUpdateSignificance(AgentUpdatePacket.AgentDataBlock x) | 5588 | public bool CheckAgentUpdateSignificance(AgentUpdatePacket.AgentDataBlock x) |
5581 | { | 5589 | { |
5582 | // These should be ordered from most-likely to | 5590 | return CheckAgentMovementUpdateSignificance(x) || CheckAgentCameraUpdateSignificance(x); |
5583 | // least likely to change. I've made an initial | 5591 | } |
5584 | // guess at that. | 5592 | |
5593 | /// <summary> | ||
5594 | /// This checks the movement/state update significance against the last update made. | ||
5595 | /// </summary> | ||
5596 | /// <remarks>Can only be called by one thread at a time</remarks> | ||
5597 | /// <returns></returns> | ||
5598 | /// <param name='x'></param> | ||
5599 | public bool CheckAgentMovementUpdateSignificance(AgentUpdatePacket.AgentDataBlock x) | ||
5600 | { | ||
5601 | qdelta1 = 1 - (float)Math.Pow(Quaternion.Dot(x.BodyRotation, m_thisAgentUpdateArgs.BodyRotation), 2); | ||
5602 | qdelta2 = 1 - (float)Math.Pow(Quaternion.Dot(x.HeadRotation, m_thisAgentUpdateArgs.HeadRotation), 2); | ||
5603 | if ( | ||
5604 | (qdelta1 > QDELTA) || | ||
5605 | // Ignoring head rotation altogether, because it's not being used for anything interesting up the stack | ||
5606 | //(qdelta2 > QDELTA * 10) || | ||
5607 | (x.ControlFlags != m_thisAgentUpdateArgs.ControlFlags) || | ||
5608 | (x.Far != m_thisAgentUpdateArgs.Far) || | ||
5609 | (x.Flags != m_thisAgentUpdateArgs.Flags) || | ||
5610 | (x.State != m_thisAgentUpdateArgs.State) | ||
5611 | ) | ||
5612 | { | ||
5613 | //m_log.DebugFormat("[LLCLIENTVIEW]: Bod {0} {1}", | ||
5614 | // qdelta1, qdelta2); | ||
5615 | //m_log.DebugFormat("[LLCLIENTVIEW]: St {0} {1} {2} {3} (Thread {4})", | ||
5616 | // x.ControlFlags, x.Flags, x.Far, x.State, Thread.CurrentThread.Name); | ||
5617 | return true; | ||
5618 | } | ||
5619 | |||
5620 | return false; | ||
5621 | } | ||
5622 | |||
5623 | /// <summary> | ||
5624 | /// This checks the camera update significance against the last update made. | ||
5625 | /// </summary> | ||
5626 | /// <remarks>Can only be called by one thread at a time</remarks> | ||
5627 | /// <returns></returns> | ||
5628 | /// <param name='x'></param> | ||
5629 | public bool CheckAgentCameraUpdateSignificance(AgentUpdatePacket.AgentDataBlock x) | ||
5630 | { | ||
5631 | vdelta1 = Vector3.Distance(x.CameraAtAxis, m_thisAgentUpdateArgs.CameraAtAxis); | ||
5632 | vdelta2 = Vector3.Distance(x.CameraCenter, m_thisAgentUpdateArgs.CameraCenter); | ||
5633 | vdelta3 = Vector3.Distance(x.CameraLeftAxis, m_thisAgentUpdateArgs.CameraLeftAxis); | ||
5634 | vdelta4 = Vector3.Distance(x.CameraUpAxis, m_thisAgentUpdateArgs.CameraUpAxis); | ||
5585 | if ( | 5635 | if ( |
5586 | /* These 4 are the worst offenders! We should consider ignoring most of them. | 5636 | /* These 4 are the worst offenders! |
5587 | * With Singularity, there is a bug where sometimes the spam on these doesn't stop */ | 5637 | * With Singularity, there is a bug where sometimes the spam on these doesn't stop */ |
5588 | (x.CameraAtAxis != m_lastAgentUpdateArgs.CameraAtAxis) || | 5638 | (vdelta1 > VDELTA) || |
5589 | (x.CameraCenter != m_lastAgentUpdateArgs.CameraCenter) || | 5639 | (vdelta2 > VDELTA) || |
5590 | (x.CameraLeftAxis != m_lastAgentUpdateArgs.CameraLeftAxis) || | 5640 | (vdelta3 > VDELTA) || |
5591 | (x.CameraUpAxis != m_lastAgentUpdateArgs.CameraUpAxis) || | 5641 | (vdelta4 > VDELTA) |
5592 | /* */ | ||
5593 | (x.BodyRotation != m_lastAgentUpdateArgs.BodyRotation) || | ||
5594 | (x.ControlFlags != m_lastAgentUpdateArgs.ControlFlags) || | ||
5595 | (x.Far != m_lastAgentUpdateArgs.Far) || | ||
5596 | (x.Flags != m_lastAgentUpdateArgs.Flags) || | ||
5597 | (x.State != m_lastAgentUpdateArgs.State) || | ||
5598 | (x.HeadRotation != m_lastAgentUpdateArgs.HeadRotation) || | ||
5599 | (x.SessionID != m_lastAgentUpdateArgs.SessionID) || | ||
5600 | (x.AgentID != m_lastAgentUpdateArgs.AgentID) | ||
5601 | ) | 5642 | ) |
5602 | { | 5643 | { |
5603 | //m_log.DebugFormat("[LLCLIENTVIEW]: Cam1 {0} {1}", | 5644 | //m_log.DebugFormat("[LLCLIENTVIEW]: Cam1 {0} {1}", |
5604 | // x.CameraAtAxis, x.CameraCenter); | 5645 | // x.CameraAtAxis, x.CameraCenter); |
5605 | //m_log.DebugFormat("[LLCLIENTVIEW]: Cam2 {0} {1}", | 5646 | //m_log.DebugFormat("[LLCLIENTVIEW]: Cam2 {0} {1}", |
5606 | // x.CameraLeftAxis, x.CameraUpAxis); | 5647 | // x.CameraLeftAxis, x.CameraUpAxis); |
5607 | //m_log.DebugFormat("[LLCLIENTVIEW]: Bod {0} {1}", | ||
5608 | // x.BodyRotation, x.HeadRotation); | ||
5609 | //m_log.DebugFormat("[LLCLIENTVIEW]: St {0} {1} {2} {3}", | ||
5610 | // x.ControlFlags, x.Flags, x.Far, x.State); | ||
5611 | |||
5612 | m_lastAgentUpdateArgs.AgentID = x.AgentID; | ||
5613 | m_lastAgentUpdateArgs.BodyRotation = x.BodyRotation; | ||
5614 | m_lastAgentUpdateArgs.CameraAtAxis = x.CameraAtAxis; | ||
5615 | m_lastAgentUpdateArgs.CameraCenter = x.CameraCenter; | ||
5616 | m_lastAgentUpdateArgs.CameraLeftAxis = x.CameraLeftAxis; | ||
5617 | m_lastAgentUpdateArgs.CameraUpAxis = x.CameraUpAxis; | ||
5618 | m_lastAgentUpdateArgs.ControlFlags = x.ControlFlags; | ||
5619 | m_lastAgentUpdateArgs.Far = x.Far; | ||
5620 | m_lastAgentUpdateArgs.Flags = x.Flags; | ||
5621 | m_lastAgentUpdateArgs.HeadRotation = x.HeadRotation; | ||
5622 | m_lastAgentUpdateArgs.SessionID = x.SessionID; | ||
5623 | m_lastAgentUpdateArgs.State = x.State; | ||
5624 | |||
5625 | return true; | 5648 | return true; |
5626 | } | 5649 | } |
5627 | 5650 | ||
@@ -5629,75 +5652,54 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5629 | } | 5652 | } |
5630 | 5653 | ||
5631 | private bool HandleAgentUpdate(IClientAPI sener, Packet packet) | 5654 | private bool HandleAgentUpdate(IClientAPI sener, Packet packet) |
5632 | { | 5655 | { |
5633 | if (OnAgentUpdate != null) | 5656 | // We got here, which means that something in agent update was significant |
5634 | { | ||
5635 | AgentUpdatePacket agentUpdate = (AgentUpdatePacket)packet; | ||
5636 | 5657 | ||
5637 | // Now done earlier | 5658 | AgentUpdatePacket agentUpdate = (AgentUpdatePacket)packet; |
5638 | // #region Packet Session and User Check | 5659 | AgentUpdatePacket.AgentDataBlock x = agentUpdate.AgentData; |
5639 | // if (agentUpdate.AgentData.SessionID != SessionId || agentUpdate.AgentData.AgentID != AgentId) | 5660 | |
5640 | // { | 5661 | if (x.AgentID != AgentId || x.SessionID != SessionId) |
5641 | // PacketPool.Instance.ReturnPacket(packet); | 5662 | return false; |
5642 | // return false; | 5663 | |
5643 | // } | 5664 | // Before we update the current m_thisAgentUpdateArgs, let's check this again |
5644 | // #endregion | 5665 | // to see what exactly changed |
5645 | // | 5666 | bool movement = CheckAgentMovementUpdateSignificance(x); |
5646 | // bool update = false; | 5667 | bool camera = CheckAgentCameraUpdateSignificance(x); |
5647 | AgentUpdatePacket.AgentDataBlock x = agentUpdate.AgentData; | 5668 | |
5648 | // | 5669 | m_thisAgentUpdateArgs.AgentID = x.AgentID; |
5649 | // if (m_lastAgentUpdateArgs != null) | 5670 | m_thisAgentUpdateArgs.BodyRotation = x.BodyRotation; |
5650 | // { | 5671 | m_thisAgentUpdateArgs.CameraAtAxis = x.CameraAtAxis; |
5651 | // // These should be ordered from most-likely to | 5672 | m_thisAgentUpdateArgs.CameraCenter = x.CameraCenter; |
5652 | // // least likely to change. I've made an initial | 5673 | m_thisAgentUpdateArgs.CameraLeftAxis = x.CameraLeftAxis; |
5653 | // // guess at that. | 5674 | m_thisAgentUpdateArgs.CameraUpAxis = x.CameraUpAxis; |
5654 | // update = | 5675 | m_thisAgentUpdateArgs.ControlFlags = x.ControlFlags; |
5655 | // ( | 5676 | m_thisAgentUpdateArgs.Far = x.Far; |
5656 | // (x.BodyRotation != m_lastAgentUpdateArgs.BodyRotation) || | 5677 | m_thisAgentUpdateArgs.Flags = x.Flags; |
5657 | // (x.CameraAtAxis != m_lastAgentUpdateArgs.CameraAtAxis) || | 5678 | m_thisAgentUpdateArgs.HeadRotation = x.HeadRotation; |
5658 | // (x.CameraCenter != m_lastAgentUpdateArgs.CameraCenter) || | 5679 | m_thisAgentUpdateArgs.SessionID = x.SessionID; |
5659 | // (x.CameraLeftAxis != m_lastAgentUpdateArgs.CameraLeftAxis) || | 5680 | m_thisAgentUpdateArgs.State = x.State; |
5660 | // (x.CameraUpAxis != m_lastAgentUpdateArgs.CameraUpAxis) || | 5681 | |
5661 | // (x.ControlFlags != m_lastAgentUpdateArgs.ControlFlags) || | 5682 | UpdateAgent handlerAgentUpdate = OnAgentUpdate; |
5662 | // (x.Far != m_lastAgentUpdateArgs.Far) || | 5683 | UpdateAgent handlerPreAgentUpdate = OnPreAgentUpdate; |
5663 | // (x.Flags != m_lastAgentUpdateArgs.Flags) || | 5684 | UpdateAgent handlerAgentCameraUpdate = OnAgentCameraUpdate; |
5664 | // (x.State != m_lastAgentUpdateArgs.State) || | 5685 | |
5665 | // (x.HeadRotation != m_lastAgentUpdateArgs.HeadRotation) || | 5686 | // Was there a significant movement/state change? |
5666 | // (x.SessionID != m_lastAgentUpdateArgs.SessionID) || | 5687 | if (movement) |
5667 | // (x.AgentID != m_lastAgentUpdateArgs.AgentID) | 5688 | { |
5668 | // ); | 5689 | if (handlerPreAgentUpdate != null) |
5669 | // } | 5690 | OnPreAgentUpdate(this, m_thisAgentUpdateArgs); |
5670 | // | 5691 | |
5671 | // if (update) | 5692 | if (handlerAgentUpdate != null) |
5672 | // { | 5693 | OnAgentUpdate(this, m_thisAgentUpdateArgs); |
5673 | //// m_log.DebugFormat("[LLCLIENTVIEW]: Triggered AgentUpdate for {0}", sener.Name); | 5694 | } |
5674 | 5695 | // Was there a significant camera(s) change? | |
5675 | m_thisAgentUpdateArgs.AgentID = x.AgentID; | 5696 | if (camera) |
5676 | m_thisAgentUpdateArgs.BodyRotation = x.BodyRotation; | 5697 | if (handlerAgentCameraUpdate != null) |
5677 | m_thisAgentUpdateArgs.CameraAtAxis = x.CameraAtAxis; | 5698 | handlerAgentCameraUpdate(this, m_thisAgentUpdateArgs); |
5678 | m_thisAgentUpdateArgs.CameraCenter = x.CameraCenter; | 5699 | |
5679 | m_thisAgentUpdateArgs.CameraLeftAxis = x.CameraLeftAxis; | 5700 | handlerAgentUpdate = null; |
5680 | m_thisAgentUpdateArgs.CameraUpAxis = x.CameraUpAxis; | 5701 | handlerPreAgentUpdate = null; |
5681 | m_thisAgentUpdateArgs.ControlFlags = x.ControlFlags; | 5702 | handlerAgentCameraUpdate = null; |
5682 | m_thisAgentUpdateArgs.Far = x.Far; | ||
5683 | m_thisAgentUpdateArgs.Flags = x.Flags; | ||
5684 | m_thisAgentUpdateArgs.HeadRotation = x.HeadRotation; | ||
5685 | m_thisAgentUpdateArgs.SessionID = x.SessionID; | ||
5686 | m_thisAgentUpdateArgs.State = x.State; | ||
5687 | |||
5688 | UpdateAgent handlerAgentUpdate = OnAgentUpdate; | ||
5689 | UpdateAgent handlerPreAgentUpdate = OnPreAgentUpdate; | ||
5690 | |||
5691 | if (handlerPreAgentUpdate != null) | ||
5692 | OnPreAgentUpdate(this, m_thisAgentUpdateArgs); | ||
5693 | |||
5694 | if (handlerAgentUpdate != null) | ||
5695 | OnAgentUpdate(this, m_thisAgentUpdateArgs); | ||
5696 | |||
5697 | handlerAgentUpdate = null; | ||
5698 | handlerPreAgentUpdate = null; | ||
5699 | // } | ||
5700 | } | ||
5701 | 5703 | ||
5702 | PacketPool.Instance.ReturnPacket(packet); | 5704 | PacketPool.Instance.ReturnPacket(packet); |
5703 | 5705 | ||
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> |
diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs index 3726191..9b69da3 100644 --- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs +++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs | |||
@@ -687,6 +687,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server | |||
687 | public event Action<IClientAPI, bool> OnCompleteMovementToRegion; | 687 | public event Action<IClientAPI, bool> OnCompleteMovementToRegion; |
688 | public event UpdateAgent OnPreAgentUpdate; | 688 | public event UpdateAgent OnPreAgentUpdate; |
689 | public event UpdateAgent OnAgentUpdate; | 689 | public event UpdateAgent OnAgentUpdate; |
690 | public event UpdateAgent OnAgentCameraUpdate; | ||
690 | public event AgentRequestSit OnAgentRequestSit; | 691 | public event AgentRequestSit OnAgentRequestSit; |
691 | public event AgentSit OnAgentSit; | 692 | public event AgentSit OnAgentSit; |
692 | public event AvatarPickerRequest OnAvatarPickerRequest; | 693 | public event AvatarPickerRequest OnAvatarPickerRequest; |
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index 592e4e1..6c38b65 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs | |||
@@ -258,6 +258,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
258 | public event Action<IClientAPI, bool> OnCompleteMovementToRegion; | 258 | public event Action<IClientAPI, bool> OnCompleteMovementToRegion; |
259 | public event UpdateAgent OnPreAgentUpdate; | 259 | public event UpdateAgent OnPreAgentUpdate; |
260 | public event UpdateAgent OnAgentUpdate; | 260 | public event UpdateAgent OnAgentUpdate; |
261 | public event UpdateAgent OnAgentCameraUpdate; | ||
261 | public event AgentRequestSit OnAgentRequestSit; | 262 | public event AgentRequestSit OnAgentRequestSit; |
262 | public event AgentSit OnAgentSit; | 263 | public event AgentSit OnAgentSit; |
263 | public event AvatarPickerRequest OnAvatarPickerRequest; | 264 | public event AvatarPickerRequest OnAvatarPickerRequest; |