diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 203 |
1 files changed, 149 insertions, 54 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 5604e3d..a1bb244 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -73,7 +73,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
73 | // { | 73 | // { |
74 | // m_log.Debug("[ScenePresence] Destructor called"); | 74 | // m_log.Debug("[ScenePresence] Destructor called"); |
75 | // } | 75 | // } |
76 | 76 | ||
77 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 77 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
78 | 78 | ||
79 | private static readonly byte[] BAKE_INDICES = new byte[] { 8, 9, 10, 11, 19, 20 }; | 79 | private static readonly byte[] BAKE_INDICES = new byte[] { 8, 9, 10, 11, 19, 20 }; |
@@ -89,7 +89,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
89 | /// rotation, prim cut, prim twist, prim taper, and prim shear. See mantis | 89 | /// rotation, prim cut, prim twist, prim taper, and prim shear. See mantis |
90 | /// issue #1716 | 90 | /// issue #1716 |
91 | /// </summary> | 91 | /// </summary> |
92 | private static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.1f, 0.0f, 0.3f); | 92 | // private static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.1f, 0.0f, 0.3f); |
93 | private static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.0f, 0.0f, 0.418f); | ||
93 | 94 | ||
94 | public UUID currentParcelUUID = UUID.Zero; | 95 | public UUID currentParcelUUID = UUID.Zero; |
95 | 96 | ||
@@ -113,7 +114,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
113 | public Vector3 lastKnownAllowedPosition; | 114 | public Vector3 lastKnownAllowedPosition; |
114 | public bool sentMessageAboutRestrictedParcelFlyingDown; | 115 | public bool sentMessageAboutRestrictedParcelFlyingDown; |
115 | public Vector4 CollisionPlane = Vector4.UnitW; | 116 | public Vector4 CollisionPlane = Vector4.UnitW; |
116 | 117 | ||
118 | private Vector3 m_avInitialPos; // used to calculate unscripted sit rotation | ||
117 | private Vector3 m_lastPosition; | 119 | private Vector3 m_lastPosition; |
118 | private Quaternion m_lastRotation; | 120 | private Quaternion m_lastRotation; |
119 | private Vector3 m_lastVelocity; | 121 | private Vector3 m_lastVelocity; |
@@ -144,7 +146,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
144 | private int m_perfMonMS; | 146 | private int m_perfMonMS; |
145 | 147 | ||
146 | private bool m_setAlwaysRun; | 148 | private bool m_setAlwaysRun; |
147 | |||
148 | private bool m_forceFly; | 149 | private bool m_forceFly; |
149 | private bool m_flyDisabled; | 150 | private bool m_flyDisabled; |
150 | 151 | ||
@@ -168,7 +169,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
168 | protected RegionInfo m_regionInfo; | 169 | protected RegionInfo m_regionInfo; |
169 | protected ulong crossingFromRegion; | 170 | protected ulong crossingFromRegion; |
170 | 171 | ||
171 | private readonly Vector3[] Dir_Vectors = new Vector3[6]; | 172 | private readonly Vector3[] Dir_Vectors = new Vector3[11]; |
173 | private bool m_isNudging = false; | ||
172 | 174 | ||
173 | // Position of agent's camera in world (region cordinates) | 175 | // Position of agent's camera in world (region cordinates) |
174 | protected Vector3 m_CameraCenter; | 176 | protected Vector3 m_CameraCenter; |
@@ -232,6 +234,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
232 | DIR_CONTROL_FLAG_RIGHT = AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG, | 234 | DIR_CONTROL_FLAG_RIGHT = AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG, |
233 | DIR_CONTROL_FLAG_UP = AgentManager.ControlFlags.AGENT_CONTROL_UP_POS, | 235 | DIR_CONTROL_FLAG_UP = AgentManager.ControlFlags.AGENT_CONTROL_UP_POS, |
234 | DIR_CONTROL_FLAG_DOWN = AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG, | 236 | DIR_CONTROL_FLAG_DOWN = AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG, |
237 | DIR_CONTROL_FLAG_FORWARD_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS, | ||
238 | DIR_CONTROL_FLAG_BACK_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG, | ||
239 | DIR_CONTROL_FLAG_LEFT_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS, | ||
240 | DIR_CONTROL_FLAG_RIGHT_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG, | ||
235 | DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG | 241 | DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG |
236 | } | 242 | } |
237 | 243 | ||
@@ -716,21 +722,47 @@ namespace OpenSim.Region.Framework.Scenes | |||
716 | Dir_Vectors[3] = -Vector3.UnitY; //RIGHT | 722 | Dir_Vectors[3] = -Vector3.UnitY; //RIGHT |
717 | Dir_Vectors[4] = Vector3.UnitZ; //UP | 723 | Dir_Vectors[4] = Vector3.UnitZ; //UP |
718 | Dir_Vectors[5] = -Vector3.UnitZ; //DOWN | 724 | Dir_Vectors[5] = -Vector3.UnitZ; //DOWN |
719 | Dir_Vectors[5] = new Vector3(0f, 0f, -0.5f); //DOWN_Nudge | 725 | Dir_Vectors[6] = new Vector3(0.5f, 0f, 0f); //FORWARD_NUDGE |
726 | Dir_Vectors[7] = new Vector3(-0.5f, 0f, 0f); //BACK_NUDGE | ||
727 | Dir_Vectors[8] = new Vector3(0f, 0.5f, 0f); //LEFT_NUDGE | ||
728 | Dir_Vectors[9] = new Vector3(0f, -0.5f, 0f); //RIGHT_NUDGE | ||
729 | Dir_Vectors[10] = new Vector3(0f, 0f, -0.5f); //DOWN_Nudge | ||
720 | } | 730 | } |
721 | 731 | ||
722 | private Vector3[] GetWalkDirectionVectors() | 732 | private Vector3[] GetWalkDirectionVectors() |
723 | { | 733 | { |
724 | Vector3[] vector = new Vector3[6]; | 734 | Vector3[] vector = new Vector3[11]; |
725 | vector[0] = new Vector3(m_CameraUpAxis.Z, 0f, -m_CameraAtAxis.Z); //FORWARD | 735 | vector[0] = new Vector3(m_CameraUpAxis.Z, 0f, -m_CameraAtAxis.Z); //FORWARD |
726 | vector[1] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK | 736 | vector[1] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK |
727 | vector[2] = Vector3.UnitY; //LEFT | 737 | vector[2] = Vector3.UnitY; //LEFT |
728 | vector[3] = -Vector3.UnitY; //RIGHT | 738 | vector[3] = -Vector3.UnitY; //RIGHT |
729 | vector[4] = new Vector3(m_CameraAtAxis.Z, 0f, m_CameraUpAxis.Z); //UP | 739 | vector[4] = new Vector3(m_CameraAtAxis.Z, 0f, m_CameraUpAxis.Z); //UP |
730 | vector[5] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN | 740 | vector[5] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN |
731 | vector[5] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN_Nudge | 741 | vector[6] = new Vector3(m_CameraUpAxis.Z, 0f, -m_CameraAtAxis.Z); //FORWARD_NUDGE |
742 | vector[7] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK_NUDGE | ||
743 | vector[8] = Vector3.UnitY; //LEFT_NUDGE | ||
744 | vector[9] = -Vector3.UnitY; //RIGHT_NUDGE | ||
745 | vector[10] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN_NUDGE | ||
732 | return vector; | 746 | return vector; |
733 | } | 747 | } |
748 | |||
749 | private bool[] GetDirectionIsNudge() | ||
750 | { | ||
751 | bool[] isNudge = new bool[11]; | ||
752 | isNudge[0] = false; //FORWARD | ||
753 | isNudge[1] = false; //BACK | ||
754 | isNudge[2] = false; //LEFT | ||
755 | isNudge[3] = false; //RIGHT | ||
756 | isNudge[4] = false; //UP | ||
757 | isNudge[5] = false; //DOWN | ||
758 | isNudge[6] = true; //FORWARD_NUDGE | ||
759 | isNudge[7] = true; //BACK_NUDGE | ||
760 | isNudge[8] = true; //LEFT_NUDGE | ||
761 | isNudge[9] = true; //RIGHT_NUDGE | ||
762 | isNudge[10] = true; //DOWN_Nudge | ||
763 | return isNudge; | ||
764 | } | ||
765 | |||
734 | 766 | ||
735 | #endregion | 767 | #endregion |
736 | 768 | ||
@@ -1147,7 +1179,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1147 | // // m_log.Debug("DEBUG: HandleAgentUpdate: child agent"); | 1179 | // // m_log.Debug("DEBUG: HandleAgentUpdate: child agent"); |
1148 | // return; | 1180 | // return; |
1149 | //} | 1181 | //} |
1150 | |||
1151 | m_perfMonMS = Environment.TickCount; | 1182 | m_perfMonMS = Environment.TickCount; |
1152 | 1183 | ||
1153 | ++m_movementUpdateCount; | 1184 | ++m_movementUpdateCount; |
@@ -1229,7 +1260,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1229 | m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(m_CameraCenter - posAdjusted), Vector3.Distance(m_CameraCenter, posAdjusted) + 0.3f, RayCastCameraCallback); | 1260 | m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(m_CameraCenter - posAdjusted), Vector3.Distance(m_CameraCenter, posAdjusted) + 0.3f, RayCastCameraCallback); |
1230 | } | 1261 | } |
1231 | } | 1262 | } |
1232 | |||
1233 | lock (scriptedcontrols) | 1263 | lock (scriptedcontrols) |
1234 | { | 1264 | { |
1235 | if (scriptedcontrols.Count > 0) | 1265 | if (scriptedcontrols.Count > 0) |
@@ -1261,7 +1291,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1261 | { | 1291 | { |
1262 | return; | 1292 | return; |
1263 | } | 1293 | } |
1264 | |||
1265 | if (m_allowMovement) | 1294 | if (m_allowMovement) |
1266 | { | 1295 | { |
1267 | int i = 0; | 1296 | int i = 0; |
@@ -1289,6 +1318,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1289 | update_rotation = true; | 1318 | update_rotation = true; |
1290 | } | 1319 | } |
1291 | 1320 | ||
1321 | //guilty until proven innocent.. | ||
1322 | bool Nudging = true; | ||
1323 | //Basically, if there is at least one non-nudge control then we don't need | ||
1324 | //to worry about stopping the avatar | ||
1325 | |||
1292 | if (m_parentID == 0) | 1326 | if (m_parentID == 0) |
1293 | { | 1327 | { |
1294 | bool bAllowUpdateMoveToPosition = false; | 1328 | bool bAllowUpdateMoveToPosition = false; |
@@ -1303,6 +1337,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1303 | else | 1337 | else |
1304 | dirVectors = Dir_Vectors; | 1338 | dirVectors = Dir_Vectors; |
1305 | 1339 | ||
1340 | bool[] isNudge = GetDirectionIsNudge(); | ||
1341 | |||
1342 | |||
1343 | |||
1344 | |||
1345 | |||
1306 | foreach (Dir_ControlFlags DCF in DIR_CONTROL_FLAGS) | 1346 | foreach (Dir_ControlFlags DCF in DIR_CONTROL_FLAGS) |
1307 | { | 1347 | { |
1308 | if (((uint)flags & (uint)DCF) != 0) | 1348 | if (((uint)flags & (uint)DCF) != 0) |
@@ -1312,6 +1352,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1312 | try | 1352 | try |
1313 | { | 1353 | { |
1314 | agent_control_v3 += dirVectors[i]; | 1354 | agent_control_v3 += dirVectors[i]; |
1355 | if (isNudge[i] == false) | ||
1356 | { | ||
1357 | Nudging = false; | ||
1358 | } | ||
1315 | } | 1359 | } |
1316 | catch (IndexOutOfRangeException) | 1360 | catch (IndexOutOfRangeException) |
1317 | { | 1361 | { |
@@ -1373,6 +1417,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1373 | // Ignore z component of vector | 1417 | // Ignore z component of vector |
1374 | Vector3 LocalVectorToTarget2D = new Vector3((float)(LocalVectorToTarget3D.X), (float)(LocalVectorToTarget3D.Y), 0f); | 1418 | Vector3 LocalVectorToTarget2D = new Vector3((float)(LocalVectorToTarget3D.X), (float)(LocalVectorToTarget3D.Y), 0f); |
1375 | LocalVectorToTarget2D.Normalize(); | 1419 | LocalVectorToTarget2D.Normalize(); |
1420 | |||
1421 | //We're not nudging | ||
1422 | Nudging = false; | ||
1376 | agent_control_v3 += LocalVectorToTarget2D; | 1423 | agent_control_v3 += LocalVectorToTarget2D; |
1377 | 1424 | ||
1378 | // update avatar movement flags. the avatar coordinate system is as follows: | 1425 | // update avatar movement flags. the avatar coordinate system is as follows: |
@@ -1455,7 +1502,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1455 | // m_log.DebugFormat( | 1502 | // m_log.DebugFormat( |
1456 | // "In {0} adding velocity to {1} of {2}", m_scene.RegionInfo.RegionName, Name, agent_control_v3); | 1503 | // "In {0} adding velocity to {1} of {2}", m_scene.RegionInfo.RegionName, Name, agent_control_v3); |
1457 | 1504 | ||
1458 | AddNewMovement(agent_control_v3, q); | 1505 | AddNewMovement(agent_control_v3, q, Nudging); |
1459 | 1506 | ||
1460 | if (update_movementflag) | 1507 | if (update_movementflag) |
1461 | Animator.UpdateMovementAnimations(); | 1508 | Animator.UpdateMovementAnimations(); |
@@ -1538,7 +1585,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1538 | Velocity = Vector3.Zero; | 1585 | Velocity = Vector3.Zero; |
1539 | SendFullUpdateToAllClients(); | 1586 | SendFullUpdateToAllClients(); |
1540 | 1587 | ||
1541 | //HandleAgentSit(ControllingClient, m_requestedSitTargetUUID); | 1588 | HandleAgentSit(ControllingClient, m_requestedSitTargetUUID); //KF ?? |
1542 | } | 1589 | } |
1543 | //ControllingClient.SendSitResponse(m_requestedSitTargetID, m_requestedSitOffset, Quaternion.Identity, false, Vector3.Zero, Vector3.Zero, false); | 1590 | //ControllingClient.SendSitResponse(m_requestedSitTargetID, m_requestedSitOffset, Quaternion.Identity, false, Vector3.Zero, Vector3.Zero, false); |
1544 | m_requestedSitTargetUUID = UUID.Zero; | 1591 | m_requestedSitTargetUUID = UUID.Zero; |
@@ -1576,21 +1623,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
1576 | SceneObjectPart part = m_scene.GetSceneObjectPart(m_parentID); | 1623 | SceneObjectPart part = m_scene.GetSceneObjectPart(m_parentID); |
1577 | if (part != null) | 1624 | if (part != null) |
1578 | { | 1625 | { |
1626 | part.TaskInventory.LockItemsForRead(true); | ||
1579 | TaskInventoryDictionary taskIDict = part.TaskInventory; | 1627 | TaskInventoryDictionary taskIDict = part.TaskInventory; |
1580 | if (taskIDict != null) | 1628 | if (taskIDict != null) |
1581 | { | 1629 | { |
1582 | lock (taskIDict) | 1630 | foreach (UUID taskID in taskIDict.Keys) |
1583 | { | 1631 | { |
1584 | foreach (UUID taskID in taskIDict.Keys) | 1632 | UnRegisterControlEventsToScript(LocalId, taskID); |
1585 | { | 1633 | taskIDict[taskID].PermsMask &= ~( |
1586 | UnRegisterControlEventsToScript(LocalId, taskID); | 1634 | 2048 | //PERMISSION_CONTROL_CAMERA |
1587 | taskIDict[taskID].PermsMask &= ~( | 1635 | 4); // PERMISSION_TAKE_CONTROLS |
1588 | 2048 | //PERMISSION_CONTROL_CAMERA | ||
1589 | 4); // PERMISSION_TAKE_CONTROLS | ||
1590 | } | ||
1591 | } | 1636 | } |
1592 | |||
1593 | } | 1637 | } |
1638 | part.TaskInventory.LockItemsForRead(false); | ||
1594 | // Reset sit target. | 1639 | // Reset sit target. |
1595 | if (part.GetAvatarOnSitTarget() == UUID) | 1640 | if (part.GetAvatarOnSitTarget() == UUID) |
1596 | part.SetAvatarOnSitTarget(UUID.Zero); | 1641 | part.SetAvatarOnSitTarget(UUID.Zero); |
@@ -1651,7 +1696,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1651 | bool SitTargetisSet = | 1696 | bool SitTargetisSet = |
1652 | (!(avSitOffSet.X == 0f && avSitOffSet.Y == 0f && avSitOffSet.Z == 0f && avSitOrientation.W == 1f && | 1697 | (!(avSitOffSet.X == 0f && avSitOffSet.Y == 0f && avSitOffSet.Z == 0f && avSitOrientation.W == 1f && |
1653 | avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 0f)); | 1698 | avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 0f)); |
1654 | 1699 | // this test is probably failing | |
1655 | if (SitTargetisSet && SitTargetUnOccupied) | 1700 | if (SitTargetisSet && SitTargetUnOccupied) |
1656 | { | 1701 | { |
1657 | //switch the target to this prim | 1702 | //switch the target to this prim |
@@ -1678,26 +1723,37 @@ namespace OpenSim.Region.Framework.Scenes | |||
1678 | { | 1723 | { |
1679 | // TODO: determine position to sit at based on scene geometry; don't trust offset from client | 1724 | // TODO: determine position to sit at based on scene geometry; don't trust offset from client |
1680 | // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it | 1725 | // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it |
1681 | 1726 | ||
1727 | // part is the prim to sit on | ||
1728 | // offset is the vector distance from that prim center to the click-spot | ||
1729 | // UUID is the UUID of the Avatar doing the clicking | ||
1730 | |||
1731 | m_avInitialPos = AbsolutePosition; // saved to calculate unscripted sit rotation | ||
1732 | |||
1682 | // Is a sit target available? | 1733 | // Is a sit target available? |
1683 | Vector3 avSitOffSet = part.SitTargetPosition; | 1734 | Vector3 avSitOffSet = part.SitTargetPosition; |
1684 | Quaternion avSitOrientation = part.SitTargetOrientation; | 1735 | Quaternion avSitOrientation = part.SitTargetOrientation; |
1685 | UUID avOnTargetAlready = part.GetAvatarOnSitTarget(); | 1736 | UUID avOnTargetAlready = part.GetAvatarOnSitTarget(); |
1686 | 1737 | ||
1687 | bool SitTargetUnOccupied = (!(avOnTargetAlready != UUID.Zero)); | 1738 | bool SitTargetUnOccupied = (!(avOnTargetAlready != UUID.Zero)); |
1688 | bool SitTargetisSet = | 1739 | // bool SitTargetisSet = |
1689 | (!(avSitOffSet.X == 0f && avSitOffSet.Y == 0f && avSitOffSet.Z == 0f && avSitOrientation.W == 0f && | 1740 | // (!(avSitOffSet.X == 0f && avSitOffSet.Y == 0f && avSitOffSet.Z == 0f && avSitOrientation.W == 0f && |
1690 | avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 1f)); | 1741 | // avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 1f)); |
1691 | 1742 | ||
1743 | bool SitTargetisSet = ((Vector3.Zero != avSitOffSet) || (Quaternion.Identity != avSitOrientation)); | ||
1744 | |||
1745 | //Console.WriteLine("SendSitResponse offset=" + offset + " UnOccup=" + SitTargetUnOccupied + | ||
1746 | // " TargSet=" + SitTargetisSet); | ||
1747 | |||
1692 | if (SitTargetisSet && SitTargetUnOccupied) | 1748 | if (SitTargetisSet && SitTargetUnOccupied) |
1693 | { | 1749 | { |
1694 | part.SetAvatarOnSitTarget(UUID); | 1750 | part.SetAvatarOnSitTarget(UUID); |
1695 | offset = new Vector3(avSitOffSet.X, avSitOffSet.Y, avSitOffSet.Z); | 1751 | offset = new Vector3(avSitOffSet.X, avSitOffSet.Y, avSitOffSet.Z); |
1696 | sitOrientation = avSitOrientation; | 1752 | sitOrientation = avSitOrientation; |
1697 | autopilot = false; | 1753 | autopilot = false; // Jump direct to scripted llSitPos() |
1698 | } | 1754 | } |
1699 | 1755 | ||
1700 | pos = part.AbsolutePosition + offset; | 1756 | pos = part.AbsolutePosition + offset; // Region position where clicked |
1701 | //if (Math.Abs(part.AbsolutePosition.Z - AbsolutePosition.Z) > 1) | 1757 | //if (Math.Abs(part.AbsolutePosition.Z - AbsolutePosition.Z) > 1) |
1702 | //{ | 1758 | //{ |
1703 | // offset = pos; | 1759 | // offset = pos; |
@@ -1710,17 +1766,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
1710 | m_sitAvatarHeight = m_physicsActor.Size.Z; | 1766 | m_sitAvatarHeight = m_physicsActor.Size.Z; |
1711 | 1767 | ||
1712 | if (autopilot) | 1768 | if (autopilot) |
1713 | { | 1769 | { // its not a scripted sit |
1714 | if (Util.GetDistanceTo(AbsolutePosition, pos) < 4.5) | 1770 | if (Util.GetDistanceTo(AbsolutePosition, pos) < 4.5) |
1715 | { | 1771 | { |
1716 | autopilot = false; | 1772 | autopilot = false; // close enough |
1717 | 1773 | ||
1718 | RemoveFromPhysicalScene(); | 1774 | RemoveFromPhysicalScene(); |
1719 | AbsolutePosition = pos + new Vector3(0.0f, 0.0f, m_sitAvatarHeight); | 1775 | AbsolutePosition = pos + new Vector3(0.0f, 0.0f, (m_sitAvatarHeight / 2.0f)); // Warp av to Prim |
1720 | } | 1776 | } // else the autopilot will get us close |
1721 | } | 1777 | } |
1722 | else | 1778 | else |
1723 | { | 1779 | { // its a scripted sit |
1724 | RemoveFromPhysicalScene(); | 1780 | RemoveFromPhysicalScene(); |
1725 | } | 1781 | } |
1726 | } | 1782 | } |
@@ -1823,26 +1879,41 @@ namespace OpenSim.Region.Framework.Scenes | |||
1823 | { | 1879 | { |
1824 | if (part.GetAvatarOnSitTarget() == UUID) | 1880 | if (part.GetAvatarOnSitTarget() == UUID) |
1825 | { | 1881 | { |
1882 | // Scripted sit | ||
1826 | Vector3 sitTargetPos = part.SitTargetPosition; | 1883 | Vector3 sitTargetPos = part.SitTargetPosition; |
1827 | Quaternion sitTargetOrient = part.SitTargetOrientation; | 1884 | Quaternion sitTargetOrient = part.SitTargetOrientation; |
1828 | |||
1829 | //Quaternion vq = new Quaternion(sitTargetPos.X, sitTargetPos.Y+0.2f, sitTargetPos.Z+0.2f, 0); | ||
1830 | //Quaternion nq = new Quaternion(-sitTargetOrient.X, -sitTargetOrient.Y, -sitTargetOrient.Z, sitTargetOrient.w); | ||
1831 | |||
1832 | //Quaternion result = (sitTargetOrient * vq) * nq; | ||
1833 | |||
1834 | m_pos = new Vector3(sitTargetPos.X, sitTargetPos.Y, sitTargetPos.Z); | 1885 | m_pos = new Vector3(sitTargetPos.X, sitTargetPos.Y, sitTargetPos.Z); |
1835 | m_pos += SIT_TARGET_ADJUSTMENT; | 1886 | m_pos += SIT_TARGET_ADJUSTMENT; |
1836 | m_bodyRot = sitTargetOrient; | 1887 | m_bodyRot = sitTargetOrient; |
1837 | //Rotation = sitTargetOrient; | ||
1838 | m_parentPosition = part.AbsolutePosition; | 1888 | m_parentPosition = part.AbsolutePosition; |
1839 | |||
1840 | //SendTerseUpdateToAllClients(); | ||
1841 | } | 1889 | } |
1842 | else | 1890 | else |
1843 | { | 1891 | { |
1844 | m_pos -= part.AbsolutePosition; | 1892 | // Non-scripted sit by Kitto Flora 21Nov09 |
1893 | // Calculate angle of line from prim to Av | ||
1894 | float y_diff = (m_avInitialPos.Y - part.AbsolutePosition.Y); | ||
1895 | float x_diff = ( m_avInitialPos.X - part.AbsolutePosition.X); | ||
1896 | if(Math.Abs(x_diff) < 0.001f) x_diff = 0.001f; // avoid div by 0 | ||
1897 | if(Math.Abs(y_diff) < 0.001f) y_diff = 0.001f; // avoid pol flip at 0 | ||
1898 | float sit_angle = (float)Math.Atan2( (double)y_diff, (double)x_diff); | ||
1899 | Quaternion partIRot = Quaternion.Inverse(part.GetWorldRotation()); | ||
1900 | // NOTE: when sitting m_ pos and m_bodyRot are *relative* to the prim location/rotation, not 'World'. | ||
1901 | // Av sits at world euler <0,0, z>, translated by part rotation | ||
1902 | m_bodyRot = partIRot * Quaternion.CreateFromEulers(0f, 0f, sit_angle); // sit at 0,0,inv-click | ||
1903 | m_pos = new Vector3(0f, 0f, 0.05f) + | ||
1904 | (new Vector3(0.0f, 0f, 0.625f) * partIRot) + | ||
1905 | (new Vector3(0.25f, 0f, 0.0f) * m_bodyRot); // sit at center of prim | ||
1845 | m_parentPosition = part.AbsolutePosition; | 1906 | m_parentPosition = part.AbsolutePosition; |
1907 | //Set up raytrace to find top surface of prim | ||
1908 | Vector3 size = part.Scale; | ||
1909 | float mag = 0.1f + (float)Math.Sqrt((size.X * size.X) + (size.Y * size.Y) + (size.Z * size.Z)); | ||
1910 | Vector3 start = part.AbsolutePosition + new Vector3(0f, 0f, mag); | ||
1911 | Vector3 down = new Vector3(0f, 0f, -1f); | ||
1912 | m_scene.PhysicsScene.RaycastWorld( | ||
1913 | start, // Vector3 position, | ||
1914 | down, // Vector3 direction, | ||
1915 | mag, // float length, | ||
1916 | SitAltitudeCallback); // retMethod | ||
1846 | } | 1917 | } |
1847 | } | 1918 | } |
1848 | else | 1919 | else |
@@ -1857,11 +1928,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
1857 | 1928 | ||
1858 | Animator.TrySetMovementAnimation(sitAnimation); | 1929 | Animator.TrySetMovementAnimation(sitAnimation); |
1859 | SendFullUpdateToAllClients(); | 1930 | SendFullUpdateToAllClients(); |
1860 | // This may seem stupid, but Our Full updates don't send avatar rotation :P | ||
1861 | // So we're also sending a terse update (which has avatar rotation) | ||
1862 | // [Update] We do now. | ||
1863 | //SendTerseUpdateToAllClients(); | ||
1864 | } | 1931 | } |
1932 | |||
1933 | public void SitAltitudeCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance) | ||
1934 | { | ||
1935 | // Console.WriteLine("[RAYCASTRESULT]: Hit={0}, Point={1}, ID={2}, Dist={3}", hitYN, collisionPoint, localid, distance); | ||
1936 | if(hitYN) | ||
1937 | { | ||
1938 | // m_pos = Av offset from prim center to make look like on center | ||
1939 | // m_parentPosition = Actual center pos of prim | ||
1940 | // collisionPoint = spot on prim where we want to sit | ||
1941 | SceneObjectPart part = m_scene.GetSceneObjectPart(localid); | ||
1942 | Vector3 offset = (collisionPoint - m_parentPosition) * Quaternion.Inverse(part.RotationOffset); | ||
1943 | m_pos += offset; | ||
1944 | // Console.WriteLine("m_pos={0}, offset={1} newsit={2}", m_pos, offset, newsit); | ||
1945 | } | ||
1946 | } | ||
1865 | 1947 | ||
1866 | /// <summary> | 1948 | /// <summary> |
1867 | /// Event handler for the 'Always run' setting on the client | 1949 | /// Event handler for the 'Always run' setting on the client |
@@ -1891,7 +1973,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1891 | /// </summary> | 1973 | /// </summary> |
1892 | /// <param name="vec">The vector in which to move. This is relative to the rotation argument</param> | 1974 | /// <param name="vec">The vector in which to move. This is relative to the rotation argument</param> |
1893 | /// <param name="rotation">The direction in which this avatar should now face. | 1975 | /// <param name="rotation">The direction in which this avatar should now face. |
1894 | public void AddNewMovement(Vector3 vec, Quaternion rotation) | 1976 | public void AddNewMovement(Vector3 vec, Quaternion rotation, bool Nudging) |
1895 | { | 1977 | { |
1896 | if (m_isChildAgent) | 1978 | if (m_isChildAgent) |
1897 | { | 1979 | { |
@@ -1965,7 +2047,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1965 | 2047 | ||
1966 | // TODO: Add the force instead of only setting it to support multiple forces per frame? | 2048 | // TODO: Add the force instead of only setting it to support multiple forces per frame? |
1967 | m_forceToApply = direc; | 2049 | m_forceToApply = direc; |
1968 | 2050 | m_isNudging = Nudging; | |
1969 | m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); | 2051 | m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); |
1970 | } | 2052 | } |
1971 | 2053 | ||
@@ -1980,7 +2062,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1980 | const float POSITION_TOLERANCE = 0.05f; | 2062 | const float POSITION_TOLERANCE = 0.05f; |
1981 | //const int TIME_MS_TOLERANCE = 3000; | 2063 | //const int TIME_MS_TOLERANCE = 3000; |
1982 | 2064 | ||
1983 | SendPrimUpdates(); | 2065 | |
1984 | 2066 | ||
1985 | if (m_newCoarseLocations) | 2067 | if (m_newCoarseLocations) |
1986 | { | 2068 | { |
@@ -2016,6 +2098,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2016 | CheckForBorderCrossing(); | 2098 | CheckForBorderCrossing(); |
2017 | CheckForSignificantMovement(); // sends update to the modules. | 2099 | CheckForSignificantMovement(); // sends update to the modules. |
2018 | } | 2100 | } |
2101 | |||
2102 | //Sending prim updates AFTER the avatar terse updates are sent | ||
2103 | SendPrimUpdates(); | ||
2019 | } | 2104 | } |
2020 | 2105 | ||
2021 | #endregion | 2106 | #endregion |
@@ -2869,14 +2954,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2869 | { | 2954 | { |
2870 | if (m_forceToApply.HasValue) | 2955 | if (m_forceToApply.HasValue) |
2871 | { | 2956 | { |
2872 | Vector3 force = m_forceToApply.Value; | ||
2873 | 2957 | ||
2958 | Vector3 force = m_forceToApply.Value; | ||
2874 | m_updateflag = true; | 2959 | m_updateflag = true; |
2875 | // movementvector = force; | ||
2876 | Velocity = force; | 2960 | Velocity = force; |
2877 | 2961 | ||
2878 | m_forceToApply = null; | 2962 | m_forceToApply = null; |
2879 | } | 2963 | } |
2964 | else | ||
2965 | { | ||
2966 | if (m_isNudging) | ||
2967 | { | ||
2968 | Vector3 force = Vector3.Zero; | ||
2969 | |||
2970 | m_updateflag = true; | ||
2971 | Velocity = force; | ||
2972 | m_isNudging = false; | ||
2973 | } | ||
2974 | } | ||
2880 | } | 2975 | } |
2881 | 2976 | ||
2882 | public override void SetText(string text, Vector3 color, double alpha) | 2977 | public override void SetText(string text, Vector3 color, double alpha) |
@@ -3585,4 +3680,4 @@ namespace OpenSim.Region.Framework.Scenes | |||
3585 | } | 3680 | } |
3586 | } | 3681 | } |
3587 | } | 3682 | } |
3588 | } \ No newline at end of file | 3683 | } |