diff options
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Data/Migration.cs | 5 | ||||
-rw-r--r-- | OpenSim/Data/MySQL/MySQLRegionData.cs | 3 | ||||
-rw-r--r-- | OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs | 10 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/EntityBase.cs | 2 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 2 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 27 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 92 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 8659 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs | 42 | ||||
-rw-r--r-- | OpenSim/Services/GridService/HypergridLinker.cs | 25 |
10 files changed, 4456 insertions, 4411 deletions
diff --git a/OpenSim/Data/Migration.cs b/OpenSim/Data/Migration.cs index c177097..86531d9 100644 --- a/OpenSim/Data/Migration.cs +++ b/OpenSim/Data/Migration.cs | |||
@@ -407,9 +407,8 @@ scan_old_style: | |||
407 | } | 407 | } |
408 | 408 | ||
409 | if (migrations.Count < 1) | 409 | if (migrations.Count < 1) |
410 | { | 410 | m_log.DebugFormat("[MIGRATIONS]: {0} data tables already up to date at revision {1}", _type, after); |
411 | m_log.InfoFormat("[MIGRATIONS]: {0} up to date, no migrations to apply", _type); | 411 | |
412 | } | ||
413 | return migrations; | 412 | return migrations; |
414 | } | 413 | } |
415 | } | 414 | } |
diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index 878b8e8..baa948e 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs | |||
@@ -210,6 +210,9 @@ namespace OpenSim.Data.MySQL | |||
210 | if (data.Data.ContainsKey("locY")) | 210 | if (data.Data.ContainsKey("locY")) |
211 | data.Data.Remove("locY"); | 211 | data.Data.Remove("locY"); |
212 | 212 | ||
213 | if (data.RegionName.Length > 32) | ||
214 | data.RegionName = data.RegionName.Substring(0, 32); | ||
215 | |||
213 | string[] fields = new List<string>(data.Data.Keys).ToArray(); | 216 | string[] fields = new List<string>(data.Data.Keys).ToArray(); |
214 | 217 | ||
215 | using (MySqlCommand cmd = new MySqlCommand()) | 218 | using (MySqlCommand cmd = new MySqlCommand()) |
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index a0e5521..800de8a 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs | |||
@@ -4634,6 +4634,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4634 | } | 4634 | } |
4635 | } | 4635 | } |
4636 | 4636 | ||
4637 | // m_log.DebugFormat( | ||
4638 | // "[LLCLIENTVIEW]: Constructing client update for part {0} {1} with flags {2}, localId {3}", | ||
4639 | // data.Name, update.FullID, flags, update.ID); | ||
4640 | |||
4637 | update.UpdateFlags = (uint)flags; | 4641 | update.UpdateFlags = (uint)flags; |
4638 | 4642 | ||
4639 | #endregion PrimFlags | 4643 | #endregion PrimFlags |
@@ -4766,7 +4770,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4766 | AddLocalPacketHandler(PacketType.ObjectScale, HandleObjectScale); | 4770 | AddLocalPacketHandler(PacketType.ObjectScale, HandleObjectScale); |
4767 | AddLocalPacketHandler(PacketType.ObjectRotation, HandleObjectRotation); | 4771 | AddLocalPacketHandler(PacketType.ObjectRotation, HandleObjectRotation); |
4768 | AddLocalPacketHandler(PacketType.ObjectFlagUpdate, HandleObjectFlagUpdate); | 4772 | AddLocalPacketHandler(PacketType.ObjectFlagUpdate, HandleObjectFlagUpdate); |
4769 | AddLocalPacketHandler(PacketType.ObjectImage, HandleObjectImage); | 4773 | |
4774 | // Handle ObjectImage (TextureEntry) updates synchronously, since when updating multiple prim faces at once, | ||
4775 | // some clients will send out a separate ObjectImage packet for each face | ||
4776 | AddLocalPacketHandler(PacketType.ObjectImage, HandleObjectImage, false); | ||
4777 | |||
4770 | AddLocalPacketHandler(PacketType.ObjectGrab, HandleObjectGrab, false); | 4778 | AddLocalPacketHandler(PacketType.ObjectGrab, HandleObjectGrab, false); |
4771 | AddLocalPacketHandler(PacketType.ObjectGrabUpdate, HandleObjectGrabUpdate, false); | 4779 | AddLocalPacketHandler(PacketType.ObjectGrabUpdate, HandleObjectGrabUpdate, false); |
4772 | AddLocalPacketHandler(PacketType.ObjectDeGrab, HandleObjectDeGrab); | 4780 | AddLocalPacketHandler(PacketType.ObjectDeGrab, HandleObjectDeGrab); |
diff --git a/OpenSim/Region/Framework/Scenes/EntityBase.cs b/OpenSim/Region/Framework/Scenes/EntityBase.cs index 4e25c46..e183f9d 100644 --- a/OpenSim/Region/Framework/Scenes/EntityBase.cs +++ b/OpenSim/Region/Framework/Scenes/EntityBase.cs | |||
@@ -130,8 +130,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
130 | { | 130 | { |
131 | return (EntityBase) MemberwiseClone(); | 131 | return (EntityBase) MemberwiseClone(); |
132 | } | 132 | } |
133 | |||
134 | public abstract void SetText(string text, Vector3 color, double alpha); | ||
135 | } | 133 | } |
136 | 134 | ||
137 | //Nested Classes | 135 | //Nested Classes |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 05036f1..7e83634 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -1363,7 +1363,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1363 | m_regInfo.EstateSettings.Save(); | 1363 | m_regInfo.EstateSettings.Save(); |
1364 | } | 1364 | } |
1365 | else | 1365 | else |
1366 | m_log.ErrorFormat("[SCENE]: Unable to store account. If this simulator is connected to a grid,\n you must create the estate owner account first."); | 1366 | m_log.ErrorFormat("[SCENE]: Unable to store account. If this simulator is connected to a grid, you must create the estate owner account first."); |
1367 | } | 1367 | } |
1368 | else | 1368 | else |
1369 | { | 1369 | { |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 4f6bc52..ffe2094 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -1629,7 +1629,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1629 | ScheduleGroupForFullUpdate(); | 1629 | ScheduleGroupForFullUpdate(); |
1630 | } | 1630 | } |
1631 | 1631 | ||
1632 | public override void SetText(string text, Vector3 color, double alpha) | 1632 | public void SetText(string text, Vector3 color, double alpha) |
1633 | { | 1633 | { |
1634 | Color = Color.FromArgb(0xff - (int) (alpha * 0xff), | 1634 | Color = Color.FromArgb(0xff - (int) (alpha * 0xff), |
1635 | (int) (color.X * 0xff), | 1635 | (int) (color.X * 0xff), |
@@ -1868,10 +1868,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1868 | dupe.RootPart.DoPhysicsPropertyUpdate(dupe.RootPart.PhysActor.IsPhysical, true); | 1868 | dupe.RootPart.DoPhysicsPropertyUpdate(dupe.RootPart.PhysActor.IsPhysical, true); |
1869 | } | 1869 | } |
1870 | 1870 | ||
1871 | List<SceneObjectPart> partList; | ||
1872 | |||
1873 | lockPartsForRead(true); | 1871 | lockPartsForRead(true); |
1874 | 1872 | ||
1873 | List<SceneObjectPart> partList; | ||
1874 | |||
1875 | partList = new List<SceneObjectPart>(m_parts.Values); | 1875 | partList = new List<SceneObjectPart>(m_parts.Values); |
1876 | 1876 | ||
1877 | lockPartsForRead(false); | 1877 | lockPartsForRead(false); |
@@ -1890,8 +1890,26 @@ namespace OpenSim.Region.Framework.Scenes | |||
1890 | 1890 | ||
1891 | newPart.LinkNum = part.LinkNum; | 1891 | newPart.LinkNum = part.LinkNum; |
1892 | } | 1892 | } |
1893 | } | ||
1894 | 1893 | ||
1894 | // Need to duplicate the physics actor as well | ||
1895 | if (part.PhysActor != null && userExposed) | ||
1896 | { | ||
1897 | PrimitiveBaseShape pbs = part.Shape; | ||
1898 | |||
1899 | part.PhysActor | ||
1900 | = m_scene.PhysicsScene.AddPrimShape( | ||
1901 | part.Name, | ||
1902 | pbs, | ||
1903 | part.AbsolutePosition, | ||
1904 | part.Scale, | ||
1905 | part.RotationOffset, | ||
1906 | part.PhysActor.IsPhysical); | ||
1907 | |||
1908 | part.PhysActor.LocalID = part.LocalId; | ||
1909 | part.DoPhysicsPropertyUpdate(part.PhysActor.IsPhysical, true); | ||
1910 | } | ||
1911 | |||
1912 | } | ||
1895 | if (userExposed) | 1913 | if (userExposed) |
1896 | { | 1914 | { |
1897 | dupe.UpdateParentIDs(); | 1915 | dupe.UpdateParentIDs(); |
@@ -1900,6 +1918,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1900 | 1918 | ||
1901 | ScheduleGroupForFullUpdate(); | 1919 | ScheduleGroupForFullUpdate(); |
1902 | } | 1920 | } |
1921 | |||
1903 | } | 1922 | } |
1904 | finally | 1923 | finally |
1905 | { | 1924 | { |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 77581af..fbe1da9 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -151,8 +151,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
151 | // TODO: This needs to be persisted in next XML version update! | 151 | // TODO: This needs to be persisted in next XML version update! |
152 | [XmlIgnore] | 152 | [XmlIgnore] |
153 | public int[] PayPrice = {-2,-2,-2,-2,-2}; | 153 | public int[] PayPrice = {-2,-2,-2,-2,-2}; |
154 | |||
154 | [XmlIgnore] | 155 | [XmlIgnore] |
155 | public PhysicsActor PhysActor; | 156 | public PhysicsActor PhysActor |
157 | { | ||
158 | get { return m_physActor; } | ||
159 | set | ||
160 | { | ||
161 | // m_log.DebugFormat("[SOP]: PhysActor set to {0} for {1} {2}", value, Name, UUID); | ||
162 | m_physActor = value; | ||
163 | } | ||
164 | } | ||
156 | 165 | ||
157 | //Xantor 20080528 Sound stuff: | 166 | //Xantor 20080528 Sound stuff: |
158 | // Note: This isn't persisted in the database right now, as the fields for that aren't just there yet. | 167 | // Note: This isn't persisted in the database right now, as the fields for that aren't just there yet. |
@@ -307,6 +316,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
307 | /// </summary> | 316 | /// </summary> |
308 | private byte m_updateFlag; | 317 | private byte m_updateFlag; |
309 | 318 | ||
319 | private PhysicsActor m_physActor; | ||
310 | protected Vector3 m_acceleration; | 320 | protected Vector3 m_acceleration; |
311 | protected Vector3 m_angularVelocity; | 321 | protected Vector3 m_angularVelocity; |
312 | 322 | ||
@@ -406,7 +416,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
406 | // this appears to have the same UUID (!) as the prim. If this isn't the case, one can't drag items from | 416 | // this appears to have the same UUID (!) as the prim. If this isn't the case, one can't drag items from |
407 | // the prim into an agent inventory (Linden client reports that the "Object not found for drop" in its log | 417 | // the prim into an agent inventory (Linden client reports that the "Object not found for drop" in its log |
408 | 418 | ||
409 | _flags = 0; | 419 | Flags = 0; |
410 | CreateSelected = true; | 420 | CreateSelected = true; |
411 | 421 | ||
412 | TrimPermissions(); | 422 | TrimPermissions(); |
@@ -434,7 +444,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
434 | private uint _groupMask = (uint)PermissionMask.None; | 444 | private uint _groupMask = (uint)PermissionMask.None; |
435 | private uint _everyoneMask = (uint)PermissionMask.None; | 445 | private uint _everyoneMask = (uint)PermissionMask.None; |
436 | private uint _nextOwnerMask = (uint)PermissionMask.All; | 446 | private uint _nextOwnerMask = (uint)PermissionMask.All; |
437 | private PrimFlags _flags = 0; | 447 | private PrimFlags _flags = PrimFlags.None; |
438 | private DateTime m_expires; | 448 | private DateTime m_expires; |
439 | private DateTime m_rezzed; | 449 | private DateTime m_rezzed; |
440 | private bool m_createSelected = false; | 450 | private bool m_createSelected = false; |
@@ -485,10 +495,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
485 | } | 495 | } |
486 | } | 496 | } |
487 | 497 | ||
498 | /// <summary> | ||
499 | /// This is idential to the Flags property, except that the returned value is uint rather than PrimFlags | ||
500 | /// </summary> | ||
501 | [Obsolete("Use Flags property instead")] | ||
488 | public uint ObjectFlags | 502 | public uint ObjectFlags |
489 | { | 503 | { |
490 | get { return (uint)_flags; } | 504 | get { return (uint)Flags; } |
491 | set { _flags = (PrimFlags)value; } | 505 | set { Flags = (PrimFlags)value; } |
492 | } | 506 | } |
493 | 507 | ||
494 | public UUID UUID | 508 | public UUID UUID |
@@ -718,20 +732,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
718 | 732 | ||
719 | // Tell the physics engines that this prim changed. | 733 | // Tell the physics engines that this prim changed. |
720 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); | 734 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); |
721 | } | 735 | } |
722 | 736 | ||
723 | if (!m_parentGroup.m_dupeInProgress) | 737 | if (!m_parentGroup.m_dupeInProgress) |
724 | { | 738 | { |
725 | List<ScenePresence> avs = ParentGroup.GetLinkedAvatars(); | 739 | List<ScenePresence> avs = ParentGroup.GetLinkedAvatars(); |
726 | foreach (ScenePresence av in avs) | 740 | foreach (ScenePresence av in avs) |
727 | { | 741 | { |
728 | if (av.LinkedPrim == m_uuid) | 742 | if (av.LinkedPrim == m_uuid) |
729 | { | 743 | { |
730 | Vector3 offset = (m_offsetPosition - oldpos); | 744 | Vector3 offset = (m_offsetPosition - oldpos); |
731 | av.OffsetPosition += offset; | 745 | av.OffsetPosition += offset; |
732 | av.SendFullUpdateToAllClients(); | 746 | av.SendFullUpdateToAllClients(); |
733 | } | 747 | } |
734 | } | 748 | } |
735 | } | 749 | } |
736 | } | 750 | } |
737 | TriggerScriptChangedEvent(Changed.POSITION); | 751 | TriggerScriptChangedEvent(Changed.POSITION); |
@@ -1026,7 +1040,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1026 | public bool CreateSelected | 1040 | public bool CreateSelected |
1027 | { | 1041 | { |
1028 | get { return m_createSelected; } | 1042 | get { return m_createSelected; } |
1029 | set { m_createSelected = value; } | 1043 | set |
1044 | { | ||
1045 | // m_log.DebugFormat("[SOP]: Setting CreateSelected to {0} for {1} {2}", value, Name, UUID); | ||
1046 | m_createSelected = value; | ||
1047 | } | ||
1030 | } | 1048 | } |
1031 | 1049 | ||
1032 | #endregion | 1050 | #endregion |
@@ -1194,7 +1212,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1194 | public PrimFlags Flags | 1212 | public PrimFlags Flags |
1195 | { | 1213 | { |
1196 | get { return _flags; } | 1214 | get { return _flags; } |
1197 | set { _flags = value; } | 1215 | set |
1216 | { | ||
1217 | // m_log.DebugFormat("[SOP]: Setting flags for {0} {1} to {2}", UUID, Name, value); | ||
1218 | _flags = value; | ||
1219 | } | ||
1198 | } | 1220 | } |
1199 | 1221 | ||
1200 | [XmlIgnore] | 1222 | [XmlIgnore] |
@@ -1329,7 +1351,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1329 | if ((ObjectFlags & (uint) flag) == 0) | 1351 | if ((ObjectFlags & (uint) flag) == 0) |
1330 | { | 1352 | { |
1331 | //m_log.Debug("Adding flag: " + ((PrimFlags) flag).ToString()); | 1353 | //m_log.Debug("Adding flag: " + ((PrimFlags) flag).ToString()); |
1332 | _flags |= flag; | 1354 | Flags |= flag; |
1333 | 1355 | ||
1334 | if (flag == PrimFlags.TemporaryOnRez) | 1356 | if (flag == PrimFlags.TemporaryOnRez) |
1335 | ResetExpire(); | 1357 | ResetExpire(); |
@@ -1554,7 +1576,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1554 | } | 1576 | } |
1555 | else | 1577 | else |
1556 | { | 1578 | { |
1557 | m_log.DebugFormat("[SPEW]: physics actor is null for {0} with parent {1}", UUID, this.ParentGroup.UUID); | 1579 | m_log.DebugFormat("[SOP]: physics actor is null for {0} with parent {1}", UUID, this.ParentGroup.UUID); |
1558 | } | 1580 | } |
1559 | } | 1581 | } |
1560 | } | 1582 | } |
@@ -1824,7 +1846,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1824 | /// that's not wholesome. Had to make Scene public | 1846 | /// that's not wholesome. Had to make Scene public |
1825 | //PhysActor = null; | 1847 | //PhysActor = null; |
1826 | 1848 | ||
1827 | if ((ObjectFlags & (uint)PrimFlags.Phantom) == 0) | 1849 | if ((Flags & PrimFlags.Phantom) == 0) |
1828 | { | 1850 | { |
1829 | if (UsePhysics) | 1851 | if (UsePhysics) |
1830 | { | 1852 | { |
@@ -1971,12 +1993,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1971 | } | 1993 | } |
1972 | 1994 | ||
1973 | public uint GetEffectiveObjectFlags() | 1995 | public uint GetEffectiveObjectFlags() |
1974 | { | 1996 | { |
1975 | PrimFlags f = _flags; | 1997 | // Commenting this section of code out since it doesn't actually do anything, as enums are handled by |
1976 | if (m_parentGroup == null || m_parentGroup.RootPart == this) | 1998 | // value rather than reference |
1977 | f &= ~(PrimFlags.Touch | PrimFlags.Money); | 1999 | // PrimFlags f = _flags; |
2000 | // if (m_parentGroup == null || m_parentGroup.RootPart == this) | ||
2001 | // f &= ~(PrimFlags.Touch | PrimFlags.Money); | ||
1978 | 2002 | ||
1979 | return (uint)_flags | (uint)LocalFlags; | 2003 | return (uint)Flags | (uint)LocalFlags; |
1980 | } | 2004 | } |
1981 | 2005 | ||
1982 | public Vector3 GetGeometricCenter() | 2006 | public Vector3 GetGeometricCenter() |
@@ -2733,10 +2757,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2733 | public void RemFlag(PrimFlags flag) | 2757 | public void RemFlag(PrimFlags flag) |
2734 | { | 2758 | { |
2735 | // PrimFlags prevflag = Flags; | 2759 | // PrimFlags prevflag = Flags; |
2736 | if ((ObjectFlags & (uint) flag) != 0) | 2760 | if ((Flags & flag) != 0) |
2737 | { | 2761 | { |
2738 | //m_log.Debug("Removing flag: " + ((PrimFlags)flag).ToString()); | 2762 | //m_log.Debug("Removing flag: " + ((PrimFlags)flag).ToString()); |
2739 | _flags &= ~flag; | 2763 | Flags &= ~flag; |
2740 | } | 2764 | } |
2741 | //m_log.Debug("prev: " + prevflag.ToString() + " curr: " + Flags.ToString()); | 2765 | //m_log.Debug("prev: " + prevflag.ToString() + " curr: " + Flags.ToString()); |
2742 | //ScheduleFullUpdate(); | 2766 | //ScheduleFullUpdate(); |
@@ -2999,10 +3023,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2999 | 3023 | ||
3000 | if (remoteClient.AgentId == _ownerID) | 3024 | if (remoteClient.AgentId == _ownerID) |
3001 | { | 3025 | { |
3002 | if ((uint) (_flags & PrimFlags.CreateSelected) != 0) | 3026 | if ((Flags & PrimFlags.CreateSelected) != 0) |
3003 | { | 3027 | { |
3004 | clientFlags |= (uint) PrimFlags.CreateSelected; | 3028 | clientFlags |= (uint) PrimFlags.CreateSelected; |
3005 | _flags &= ~PrimFlags.CreateSelected; | 3029 | Flags &= ~PrimFlags.CreateSelected; |
3006 | } | 3030 | } |
3007 | } | 3031 | } |
3008 | //bool isattachment = IsAttachment; | 3032 | //bool isattachment = IsAttachment; |
@@ -3308,6 +3332,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3308 | texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f); | 3332 | texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f); |
3309 | tex.FaceTextures[face].RGBA = texcolor; | 3333 | tex.FaceTextures[face].RGBA = texcolor; |
3310 | UpdateTexture(tex); | 3334 | UpdateTexture(tex); |
3335 | TriggerScriptChangedEvent(Changed.COLOR); | ||
3311 | return; | 3336 | return; |
3312 | } | 3337 | } |
3313 | else if (face == ALL_SIDES) | 3338 | else if (face == ALL_SIDES) |
@@ -3329,6 +3354,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3329 | tex.DefaultTexture.RGBA = texcolor; | 3354 | tex.DefaultTexture.RGBA = texcolor; |
3330 | } | 3355 | } |
3331 | UpdateTexture(tex); | 3356 | UpdateTexture(tex); |
3357 | TriggerScriptChangedEvent(Changed.COLOR); | ||
3332 | return; | 3358 | return; |
3333 | } | 3359 | } |
3334 | } | 3360 | } |
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index fc8e0d7..3154872 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -1,4332 +1,4327 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSimulator Project nor the | 12 | * * Neither the name of the OpenSimulator Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Xml; | 29 | using System.Xml; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Reflection; | 31 | using System.Reflection; |
32 | using System.Timers; | 32 | using System.Timers; |
33 | using OpenMetaverse; | 33 | using OpenMetaverse; |
34 | using log4net; | 34 | using log4net; |
35 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
36 | using OpenSim.Framework.Client; | 36 | using OpenSim.Framework.Client; |
37 | using OpenSim.Region.Framework.Interfaces; | 37 | using OpenSim.Region.Framework.Interfaces; |
38 | using OpenSim.Region.Framework.Scenes.Animation; | 38 | using OpenSim.Region.Framework.Scenes.Animation; |
39 | using OpenSim.Region.Framework.Scenes.Types; | 39 | using OpenSim.Region.Framework.Scenes.Types; |
40 | using OpenSim.Region.Physics.Manager; | 40 | using OpenSim.Region.Physics.Manager; |
41 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | 41 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; |
42 | using OpenSim.Services.Interfaces; | 42 | using OpenSim.Services.Interfaces; |
43 | 43 | ||
44 | namespace OpenSim.Region.Framework.Scenes | 44 | namespace OpenSim.Region.Framework.Scenes |
45 | { | 45 | { |
46 | enum ScriptControlled : uint | 46 | enum ScriptControlled : uint |
47 | { | 47 | { |
48 | CONTROL_ZERO = 0, | 48 | CONTROL_ZERO = 0, |
49 | CONTROL_FWD = 1, | 49 | CONTROL_FWD = 1, |
50 | CONTROL_BACK = 2, | 50 | CONTROL_BACK = 2, |
51 | CONTROL_LEFT = 4, | 51 | CONTROL_LEFT = 4, |
52 | CONTROL_RIGHT = 8, | 52 | CONTROL_RIGHT = 8, |
53 | CONTROL_UP = 16, | 53 | CONTROL_UP = 16, |
54 | CONTROL_DOWN = 32, | 54 | CONTROL_DOWN = 32, |
55 | CONTROL_ROT_LEFT = 256, | 55 | CONTROL_ROT_LEFT = 256, |
56 | CONTROL_ROT_RIGHT = 512, | 56 | CONTROL_ROT_RIGHT = 512, |
57 | CONTROL_LBUTTON = 268435456, | 57 | CONTROL_LBUTTON = 268435456, |
58 | CONTROL_ML_LBUTTON = 1073741824 | 58 | CONTROL_ML_LBUTTON = 1073741824 |
59 | } | 59 | } |
60 | 60 | ||
61 | struct ScriptControllers | 61 | struct ScriptControllers |
62 | { | 62 | { |
63 | public UUID itemID; | 63 | public UUID itemID; |
64 | public ScriptControlled ignoreControls; | 64 | public ScriptControlled ignoreControls; |
65 | public ScriptControlled eventControls; | 65 | public ScriptControlled eventControls; |
66 | } | 66 | } |
67 | 67 | ||
68 | public delegate void SendCourseLocationsMethod(UUID scene, ScenePresence presence, List<Vector3> coarseLocations, List<UUID> avatarUUIDs); | 68 | public delegate void SendCourseLocationsMethod(UUID scene, ScenePresence presence, List<Vector3> coarseLocations, List<UUID> avatarUUIDs); |
69 | 69 | ||
70 | public class ScenePresence : EntityBase, ISceneEntity | 70 | public class ScenePresence : EntityBase, ISceneEntity |
71 | { | 71 | { |
72 | // ~ScenePresence() | 72 | // ~ScenePresence() |
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 }; |
80 | // private static readonly byte[] DEFAULT_TEXTURE = AvatarAppearance.GetDefaultTexture().GetBytes(); | 80 | // private static readonly byte[] DEFAULT_TEXTURE = AvatarAppearance.GetDefaultTexture().GetBytes(); |
81 | private static readonly Array DIR_CONTROL_FLAGS = Enum.GetValues(typeof(Dir_ControlFlags)); | 81 | private static readonly Array DIR_CONTROL_FLAGS = Enum.GetValues(typeof(Dir_ControlFlags)); |
82 | private static readonly Vector3 HEAD_ADJUSTMENT = new Vector3(0f, 0f, 0.3f); | 82 | private static readonly Vector3 HEAD_ADJUSTMENT = new Vector3(0f, 0f, 0.3f); |
83 | 83 | ||
84 | /// <summary> | 84 | /// <summary> |
85 | /// Experimentally determined "fudge factor" to make sit-target positions | 85 | /// Experimentally determined "fudge factor" to make sit-target positions |
86 | /// the same as in SecondLife. Fudge factor was tested for 36 different | 86 | /// the same as in SecondLife. Fudge factor was tested for 36 different |
87 | /// test cases including prims of type box, sphere, cylinder, and torus, | 87 | /// test cases including prims of type box, sphere, cylinder, and torus, |
88 | /// with varying parameters for sit target location, prim size, prim | 88 | /// with varying parameters for sit target location, prim size, prim |
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 | // Value revised by KF 091121 by comparison with SL. | 93 | // Value revised by KF 091121 by comparison with SL. |
94 | private static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.0f, 0.0f, 0.418f); | 94 | private static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.0f, 0.0f, 0.418f); |
95 | 95 | ||
96 | public UUID currentParcelUUID = UUID.Zero; | 96 | public UUID currentParcelUUID = UUID.Zero; |
97 | 97 | ||
98 | private ISceneViewer m_sceneViewer; | 98 | private ISceneViewer m_sceneViewer; |
99 | 99 | ||
100 | /// <value> | 100 | /// <value> |
101 | /// The animator for this avatar | 101 | /// The animator for this avatar |
102 | /// </value> | 102 | /// </value> |
103 | public ScenePresenceAnimator Animator | 103 | public ScenePresenceAnimator Animator |
104 | { | 104 | { |
105 | get { return m_animator; } | 105 | get { return m_animator; } |
106 | } | 106 | } |
107 | protected ScenePresenceAnimator m_animator; | 107 | protected ScenePresenceAnimator m_animator; |
108 | 108 | ||
109 | /// <value> | 109 | /// <value> |
110 | /// The scene objects attached to this avatar. Do not change this list directly - use methods such as | 110 | /// The scene objects attached to this avatar. Do not change this list directly - use methods such as |
111 | /// AddAttachment() and RemoveAttachment(). Lock this list when performing any read operations upon it. | 111 | /// AddAttachment() and RemoveAttachment(). Lock this list when performing any read operations upon it. |
112 | /// </value> | 112 | /// </value> |
113 | public List<SceneObjectGroup> Attachments | 113 | public List<SceneObjectGroup> Attachments |
114 | { | 114 | { |
115 | get { return m_attachments; } | 115 | get { return m_attachments; } |
116 | } | 116 | } |
117 | protected List<SceneObjectGroup> m_attachments = new List<SceneObjectGroup>(); | 117 | protected List<SceneObjectGroup> m_attachments = new List<SceneObjectGroup>(); |
118 | 118 | ||
119 | private Dictionary<UUID, ScriptControllers> scriptedcontrols = new Dictionary<UUID, ScriptControllers>(); | 119 | private Dictionary<UUID, ScriptControllers> scriptedcontrols = new Dictionary<UUID, ScriptControllers>(); |
120 | private ScriptControlled IgnoredControls = ScriptControlled.CONTROL_ZERO; | 120 | private ScriptControlled IgnoredControls = ScriptControlled.CONTROL_ZERO; |
121 | private ScriptControlled LastCommands = ScriptControlled.CONTROL_ZERO; | 121 | private ScriptControlled LastCommands = ScriptControlled.CONTROL_ZERO; |
122 | private bool MouseDown = false; | 122 | private bool MouseDown = false; |
123 | private SceneObjectGroup proxyObjectGroup; | 123 | private SceneObjectGroup proxyObjectGroup; |
124 | //private SceneObjectPart proxyObjectPart = null; | 124 | //private SceneObjectPart proxyObjectPart = null; |
125 | public Vector3 lastKnownAllowedPosition; | 125 | public Vector3 lastKnownAllowedPosition; |
126 | public bool sentMessageAboutRestrictedParcelFlyingDown; | 126 | public bool sentMessageAboutRestrictedParcelFlyingDown; |
127 | public Vector4 CollisionPlane = Vector4.UnitW; | 127 | public Vector4 CollisionPlane = Vector4.UnitW; |
128 | 128 | ||
129 | private Vector3 m_avInitialPos; // used to calculate unscripted sit rotation | 129 | private Vector3 m_avInitialPos; // used to calculate unscripted sit rotation |
130 | private Vector3 m_avUnscriptedSitPos; // for non-scripted prims | 130 | private Vector3 m_avUnscriptedSitPos; // for non-scripted prims |
131 | private Vector3 m_lastPosition; | 131 | private Vector3 m_lastPosition; |
132 | private Vector3 m_lastWorldPosition; | 132 | private Vector3 m_lastWorldPosition; |
133 | private Quaternion m_lastRotation; | 133 | private Quaternion m_lastRotation; |
134 | private Vector3 m_lastVelocity; | 134 | private Vector3 m_lastVelocity; |
135 | //private int m_lastTerseSent; | 135 | //private int m_lastTerseSent; |
136 | 136 | ||
137 | private bool m_updateflag; | 137 | private bool m_updateflag; |
138 | private byte m_movementflag; | 138 | private byte m_movementflag; |
139 | private Vector3? m_forceToApply; | 139 | private Vector3? m_forceToApply; |
140 | private uint m_requestedSitTargetID; | 140 | private uint m_requestedSitTargetID; |
141 | private UUID m_requestedSitTargetUUID; | 141 | private UUID m_requestedSitTargetUUID; |
142 | public bool SitGround = false; | 142 | public bool SitGround = false; |
143 | 143 | ||
144 | private SendCourseLocationsMethod m_sendCourseLocationsMethod; | 144 | private SendCourseLocationsMethod m_sendCourseLocationsMethod; |
145 | 145 | ||
146 | private bool m_startAnimationSet; | 146 | private bool m_startAnimationSet; |
147 | 147 | ||
148 | //private Vector3 m_requestedSitOffset = new Vector3(); | 148 | //private Vector3 m_requestedSitOffset = new Vector3(); |
149 | 149 | ||
150 | private Vector3 m_LastFinitePos; | 150 | private Vector3 m_LastFinitePos; |
151 | 151 | ||
152 | private float m_sitAvatarHeight = 2.0f; | 152 | private float m_sitAvatarHeight = 2.0f; |
153 | 153 | ||
154 | private int m_godLevel; | 154 | private int m_godLevel; |
155 | private int m_userLevel; | 155 | private int m_userLevel; |
156 | 156 | ||
157 | private bool m_invulnerable = true; | 157 | private bool m_invulnerable = true; |
158 | 158 | ||
159 | private Vector3 m_lastChildAgentUpdatePosition; | 159 | private Vector3 m_lastChildAgentUpdatePosition; |
160 | private Vector3 m_lastChildAgentUpdateCamPosition; | 160 | private Vector3 m_lastChildAgentUpdateCamPosition; |
161 | 161 | ||
162 | private int m_perfMonMS; | 162 | private int m_perfMonMS; |
163 | 163 | ||
164 | private bool m_setAlwaysRun; | 164 | private bool m_setAlwaysRun; |
165 | private bool m_forceFly; | 165 | private bool m_forceFly; |
166 | private bool m_flyDisabled; | 166 | private bool m_flyDisabled; |
167 | 167 | ||
168 | private float m_speedModifier = 1.0f; | 168 | private float m_speedModifier = 1.0f; |
169 | 169 | ||
170 | private Quaternion m_bodyRot= Quaternion.Identity; | 170 | private Quaternion m_bodyRot= Quaternion.Identity; |
171 | 171 | ||
172 | private Quaternion m_bodyRotPrevious = Quaternion.Identity; | 172 | private Quaternion m_bodyRotPrevious = Quaternion.Identity; |
173 | 173 | ||
174 | private const int LAND_VELOCITYMAG_MAX = 12; | 174 | private const int LAND_VELOCITYMAG_MAX = 12; |
175 | 175 | ||
176 | public bool IsRestrictedToRegion; | 176 | public bool IsRestrictedToRegion; |
177 | 177 | ||
178 | public string JID = String.Empty; | 178 | public string JID = String.Empty; |
179 | 179 | ||
180 | private float m_health = 100f; | 180 | private float m_health = 100f; |
181 | 181 | ||
182 | // Default AV Height | 182 | // Default AV Height |
183 | private float m_avHeight = 127.0f; | 183 | private float m_avHeight = 127.0f; |
184 | 184 | ||
185 | protected RegionInfo m_regionInfo; | 185 | protected RegionInfo m_regionInfo; |
186 | protected ulong crossingFromRegion; | 186 | protected ulong crossingFromRegion; |
187 | 187 | ||
188 | private readonly Vector3[] Dir_Vectors = new Vector3[11]; | 188 | private readonly Vector3[] Dir_Vectors = new Vector3[11]; |
189 | private bool m_isNudging = false; | 189 | private bool m_isNudging = false; |
190 | 190 | ||
191 | // Position of agent's camera in world (region cordinates) | 191 | // Position of agent's camera in world (region cordinates) |
192 | protected Vector3 m_CameraCenter; | 192 | protected Vector3 m_CameraCenter; |
193 | protected Vector3 m_lastCameraCenter; | 193 | protected Vector3 m_lastCameraCenter; |
194 | 194 | ||
195 | protected Timer m_reprioritization_timer; | 195 | protected Timer m_reprioritization_timer; |
196 | protected bool m_reprioritizing; | 196 | protected bool m_reprioritizing; |
197 | protected bool m_reprioritization_called; | 197 | protected bool m_reprioritization_called; |
198 | 198 | ||
199 | // Use these three vectors to figure out what the agent is looking at | 199 | // Use these three vectors to figure out what the agent is looking at |
200 | // Convert it to a Matrix and/or Quaternion | 200 | // Convert it to a Matrix and/or Quaternion |
201 | protected Vector3 m_CameraAtAxis; | 201 | protected Vector3 m_CameraAtAxis; |
202 | protected Vector3 m_CameraLeftAxis; | 202 | protected Vector3 m_CameraLeftAxis; |
203 | protected Vector3 m_CameraUpAxis; | 203 | protected Vector3 m_CameraUpAxis; |
204 | private AgentManager.ControlFlags m_AgentControlFlags; | 204 | private AgentManager.ControlFlags m_AgentControlFlags; |
205 | private Quaternion m_headrotation = Quaternion.Identity; | 205 | private Quaternion m_headrotation = Quaternion.Identity; |
206 | private byte m_state; | 206 | private byte m_state; |
207 | 207 | ||
208 | //Reuse the Vector3 instead of creating a new one on the UpdateMovement method | 208 | //Reuse the Vector3 instead of creating a new one on the UpdateMovement method |
209 | // private Vector3 movementvector; | 209 | // private Vector3 movementvector; |
210 | 210 | ||
211 | private bool m_autopilotMoving; | 211 | private bool m_autopilotMoving; |
212 | private Vector3 m_autoPilotTarget; | 212 | private Vector3 m_autoPilotTarget; |
213 | private bool m_sitAtAutoTarget; | 213 | private bool m_sitAtAutoTarget; |
214 | private Vector3 m_initialSitTarget = Vector3.Zero; //KF: First estimate of where to sit | 214 | private Vector3 m_initialSitTarget = Vector3.Zero; //KF: First estimate of where to sit |
215 | 215 | ||
216 | private string m_nextSitAnimation = String.Empty; | 216 | private string m_nextSitAnimation = String.Empty; |
217 | 217 | ||
218 | //PauPaw:Proper PID Controler for autopilot************ | 218 | //PauPaw:Proper PID Controler for autopilot************ |
219 | private bool m_moveToPositionInProgress; | 219 | private bool m_moveToPositionInProgress; |
220 | private Vector3 m_moveToPositionTarget; | 220 | private Vector3 m_moveToPositionTarget; |
221 | private Quaternion m_offsetRotation = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); | 221 | private Quaternion m_offsetRotation = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); |
222 | 222 | ||
223 | private bool m_followCamAuto; | 223 | private bool m_followCamAuto; |
224 | 224 | ||
225 | private int m_movementUpdateCount; | 225 | private int m_movementUpdateCount; |
226 | private int m_lastColCount = -1; //KF: Look for Collision chnages | 226 | private int m_lastColCount = -1; //KF: Look for Collision chnages |
227 | private int m_updateCount = 0; //KF: Update Anims for a while | 227 | private int m_updateCount = 0; //KF: Update Anims for a while |
228 | private static readonly int UPDATE_COUNT = 10; // how many frames to update for | 228 | private static readonly int UPDATE_COUNT = 10; // how many frames to update for |
229 | private const int NumMovementsBetweenRayCast = 5; | 229 | private const int NumMovementsBetweenRayCast = 5; |
230 | private List<uint> m_lastColliders = new List<uint>(); | 230 | private List<uint> m_lastColliders = new List<uint>(); |
231 | 231 | ||
232 | private bool CameraConstraintActive; | 232 | private bool CameraConstraintActive; |
233 | //private int m_moveToPositionStateStatus; | 233 | //private int m_moveToPositionStateStatus; |
234 | //***************************************************** | 234 | //***************************************************** |
235 | 235 | ||
236 | // Agent's Draw distance. | 236 | // Agent's Draw distance. |
237 | protected float m_DrawDistance; | 237 | protected float m_DrawDistance; |
238 | 238 | ||
239 | protected AvatarAppearance m_appearance; | 239 | protected AvatarAppearance m_appearance; |
240 | 240 | ||
241 | // neighbouring regions we have enabled a child agent in | 241 | // neighbouring regions we have enabled a child agent in |
242 | // holds the seed cap for the child agent in that region | 242 | // holds the seed cap for the child agent in that region |
243 | private Dictionary<ulong, string> m_knownChildRegions = new Dictionary<ulong, string>(); | 243 | private Dictionary<ulong, string> m_knownChildRegions = new Dictionary<ulong, string>(); |
244 | 244 | ||
245 | /// <summary> | 245 | /// <summary> |
246 | /// Implemented Control Flags | 246 | /// Implemented Control Flags |
247 | /// </summary> | 247 | /// </summary> |
248 | private enum Dir_ControlFlags | 248 | private enum Dir_ControlFlags |
249 | { | 249 | { |
250 | DIR_CONTROL_FLAG_FORWARD = AgentManager.ControlFlags.AGENT_CONTROL_AT_POS, | 250 | DIR_CONTROL_FLAG_FORWARD = AgentManager.ControlFlags.AGENT_CONTROL_AT_POS, |
251 | DIR_CONTROL_FLAG_BACK = AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG, | 251 | DIR_CONTROL_FLAG_BACK = AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG, |
252 | DIR_CONTROL_FLAG_LEFT = AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS, | 252 | DIR_CONTROL_FLAG_LEFT = AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS, |
253 | DIR_CONTROL_FLAG_RIGHT = AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG, | 253 | DIR_CONTROL_FLAG_RIGHT = AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG, |
254 | DIR_CONTROL_FLAG_UP = AgentManager.ControlFlags.AGENT_CONTROL_UP_POS, | 254 | DIR_CONTROL_FLAG_UP = AgentManager.ControlFlags.AGENT_CONTROL_UP_POS, |
255 | DIR_CONTROL_FLAG_DOWN = AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG, | 255 | DIR_CONTROL_FLAG_DOWN = AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG, |
256 | DIR_CONTROL_FLAG_FORWARD_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS, | 256 | DIR_CONTROL_FLAG_FORWARD_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS, |
257 | DIR_CONTROL_FLAG_BACK_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG, | 257 | DIR_CONTROL_FLAG_BACK_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG, |
258 | DIR_CONTROL_FLAG_LEFT_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS, | 258 | DIR_CONTROL_FLAG_LEFT_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS, |
259 | DIR_CONTROL_FLAG_RIGHT_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG, | 259 | DIR_CONTROL_FLAG_RIGHT_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG, |
260 | DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG | 260 | DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG |
261 | } | 261 | } |
262 | 262 | ||
263 | /// <summary> | 263 | /// <summary> |
264 | /// Position at which a significant movement was made | 264 | /// Position at which a significant movement was made |
265 | /// </summary> | 265 | /// </summary> |
266 | private Vector3 posLastSignificantMove; | 266 | private Vector3 posLastSignificantMove; |
267 | 267 | ||
268 | // For teleports and crossings callbacks | 268 | // For teleports and crossings callbacks |
269 | string m_callbackURI; | 269 | string m_callbackURI; |
270 | UUID m_originRegionID; | 270 | UUID m_originRegionID; |
271 | 271 | ||
272 | ulong m_rootRegionHandle; | 272 | ulong m_rootRegionHandle; |
273 | 273 | ||
274 | /// <value> | 274 | /// <value> |
275 | /// Script engines present in the scene | 275 | /// Script engines present in the scene |
276 | /// </value> | 276 | /// </value> |
277 | private IScriptModule[] m_scriptEngines; | 277 | private IScriptModule[] m_scriptEngines; |
278 | 278 | ||
279 | #region Properties | 279 | #region Properties |
280 | 280 | ||
281 | /// <summary> | 281 | /// <summary> |
282 | /// Physical scene representation of this Avatar. | 282 | /// Physical scene representation of this Avatar. |
283 | /// </summary> | 283 | /// </summary> |
284 | public PhysicsActor PhysicsActor | 284 | public PhysicsActor PhysicsActor |
285 | { | 285 | { |
286 | set { m_physicsActor = value; } | 286 | set { m_physicsActor = value; } |
287 | get { return m_physicsActor; } | 287 | get { return m_physicsActor; } |
288 | } | 288 | } |
289 | 289 | ||
290 | public byte MovementFlag | 290 | public byte MovementFlag |
291 | { | 291 | { |
292 | set { m_movementflag = value; } | 292 | set { m_movementflag = value; } |
293 | get { return m_movementflag; } | 293 | get { return m_movementflag; } |
294 | } | 294 | } |
295 | 295 | ||
296 | public bool Updated | 296 | public bool Updated |
297 | { | 297 | { |
298 | set { m_updateflag = value; } | 298 | set { m_updateflag = value; } |
299 | get { return m_updateflag; } | 299 | get { return m_updateflag; } |
300 | } | 300 | } |
301 | 301 | ||
302 | public bool Invulnerable | 302 | public bool Invulnerable |
303 | { | 303 | { |
304 | set { m_invulnerable = value; } | 304 | set { m_invulnerable = value; } |
305 | get { return m_invulnerable; } | 305 | get { return m_invulnerable; } |
306 | } | 306 | } |
307 | 307 | ||
308 | public int UserLevel | 308 | public int UserLevel |
309 | { | 309 | { |
310 | get { return m_userLevel; } | 310 | get { return m_userLevel; } |
311 | } | 311 | } |
312 | 312 | ||
313 | public int GodLevel | 313 | public int GodLevel |
314 | { | 314 | { |
315 | get { return m_godLevel; } | 315 | get { return m_godLevel; } |
316 | } | 316 | } |
317 | 317 | ||
318 | public ulong RegionHandle | 318 | public ulong RegionHandle |
319 | { | 319 | { |
320 | get { return m_rootRegionHandle; } | 320 | get { return m_rootRegionHandle; } |
321 | } | 321 | } |
322 | 322 | ||
323 | public Vector3 CameraPosition | 323 | public Vector3 CameraPosition |
324 | { | 324 | { |
325 | get { return m_CameraCenter; } | 325 | get { return m_CameraCenter; } |
326 | } | 326 | } |
327 | 327 | ||
328 | public Quaternion CameraRotation | 328 | public Quaternion CameraRotation |
329 | { | 329 | { |
330 | get { return Util.Axes2Rot(m_CameraAtAxis, m_CameraLeftAxis, m_CameraUpAxis); } | 330 | get { return Util.Axes2Rot(m_CameraAtAxis, m_CameraLeftAxis, m_CameraUpAxis); } |
331 | } | 331 | } |
332 | 332 | ||
333 | public Vector3 CameraAtAxis | 333 | public Vector3 CameraAtAxis |
334 | { | 334 | { |
335 | get { return m_CameraAtAxis; } | 335 | get { return m_CameraAtAxis; } |
336 | } | 336 | } |
337 | 337 | ||
338 | public Vector3 CameraLeftAxis | 338 | public Vector3 CameraLeftAxis |
339 | { | 339 | { |
340 | get { return m_CameraLeftAxis; } | 340 | get { return m_CameraLeftAxis; } |
341 | } | 341 | } |
342 | 342 | ||
343 | public Vector3 CameraUpAxis | 343 | public Vector3 CameraUpAxis |
344 | { | 344 | { |
345 | get { return m_CameraUpAxis; } | 345 | get { return m_CameraUpAxis; } |
346 | } | 346 | } |
347 | 347 | ||
348 | public Vector3 Lookat | 348 | public Vector3 Lookat |
349 | { | 349 | { |
350 | get | 350 | get |
351 | { | 351 | { |
352 | Vector3 a = new Vector3(m_CameraAtAxis.X, m_CameraAtAxis.Y, 0); | 352 | Vector3 a = new Vector3(m_CameraAtAxis.X, m_CameraAtAxis.Y, 0); |
353 | 353 | ||
354 | if (a == Vector3.Zero) | 354 | if (a == Vector3.Zero) |
355 | return a; | 355 | return a; |
356 | 356 | ||
357 | return Util.GetNormalizedVector(a); | 357 | return Util.GetNormalizedVector(a); |
358 | } | 358 | } |
359 | } | 359 | } |
360 | 360 | ||
361 | private readonly string m_firstname; | 361 | private readonly string m_firstname; |
362 | 362 | ||
363 | public string Firstname | 363 | public string Firstname |
364 | { | 364 | { |
365 | get { return m_firstname; } | 365 | get { return m_firstname; } |
366 | } | 366 | } |
367 | 367 | ||
368 | private readonly string m_lastname; | 368 | private readonly string m_lastname; |
369 | 369 | ||
370 | public string Lastname | 370 | public string Lastname |
371 | { | 371 | { |
372 | get { return m_lastname; } | 372 | get { return m_lastname; } |
373 | } | 373 | } |
374 | 374 | ||
375 | private string m_grouptitle; | 375 | private string m_grouptitle; |
376 | 376 | ||
377 | public string Grouptitle | 377 | public string Grouptitle |
378 | { | 378 | { |
379 | get { return m_grouptitle; } | 379 | get { return m_grouptitle; } |
380 | set { m_grouptitle = value; } | 380 | set { m_grouptitle = value; } |
381 | } | 381 | } |
382 | 382 | ||
383 | public float DrawDistance | 383 | public float DrawDistance |
384 | { | 384 | { |
385 | get { return m_DrawDistance; } | 385 | get { return m_DrawDistance; } |
386 | } | 386 | } |
387 | 387 | ||
388 | protected bool m_allowMovement = true; | 388 | protected bool m_allowMovement = true; |
389 | 389 | ||
390 | public bool AllowMovement | 390 | public bool AllowMovement |
391 | { | 391 | { |
392 | get { return m_allowMovement; } | 392 | get { return m_allowMovement; } |
393 | set { m_allowMovement = value; } | 393 | set { m_allowMovement = value; } |
394 | } | 394 | } |
395 | 395 | ||
396 | public bool SetAlwaysRun | 396 | public bool SetAlwaysRun |
397 | { | 397 | { |
398 | get | 398 | get |
399 | { | 399 | { |
400 | if (PhysicsActor != null) | 400 | if (PhysicsActor != null) |
401 | { | 401 | { |
402 | return PhysicsActor.SetAlwaysRun; | 402 | return PhysicsActor.SetAlwaysRun; |
403 | } | 403 | } |
404 | else | 404 | else |
405 | { | 405 | { |
406 | return m_setAlwaysRun; | 406 | return m_setAlwaysRun; |
407 | } | 407 | } |
408 | } | 408 | } |
409 | set | 409 | set |
410 | { | 410 | { |
411 | m_setAlwaysRun = value; | 411 | m_setAlwaysRun = value; |
412 | if (PhysicsActor != null) | 412 | if (PhysicsActor != null) |
413 | { | 413 | { |
414 | PhysicsActor.SetAlwaysRun = value; | 414 | PhysicsActor.SetAlwaysRun = value; |
415 | } | 415 | } |
416 | } | 416 | } |
417 | } | 417 | } |
418 | 418 | ||
419 | public byte State | 419 | public byte State |
420 | { | 420 | { |
421 | get { return m_state; } | 421 | get { return m_state; } |
422 | set { m_state = value; } | 422 | set { m_state = value; } |
423 | } | 423 | } |
424 | 424 | ||
425 | public uint AgentControlFlags | 425 | public uint AgentControlFlags |
426 | { | 426 | { |
427 | get { return (uint)m_AgentControlFlags; } | 427 | get { return (uint)m_AgentControlFlags; } |
428 | set { m_AgentControlFlags = (AgentManager.ControlFlags)value; } | 428 | set { m_AgentControlFlags = (AgentManager.ControlFlags)value; } |
429 | } | 429 | } |
430 | 430 | ||
431 | /// <summary> | 431 | /// <summary> |
432 | /// This works out to be the ClientView object associated with this avatar, or it's client connection manager | 432 | /// This works out to be the ClientView object associated with this avatar, or it's client connection manager |
433 | /// </summary> | 433 | /// </summary> |
434 | private IClientAPI m_controllingClient; | 434 | private IClientAPI m_controllingClient; |
435 | 435 | ||
436 | protected PhysicsActor m_physicsActor; | 436 | protected PhysicsActor m_physicsActor; |
437 | 437 | ||
438 | /// <value> | 438 | /// <value> |
439 | /// The client controlling this presence | 439 | /// The client controlling this presence |
440 | /// </value> | 440 | /// </value> |
441 | public IClientAPI ControllingClient | 441 | public IClientAPI ControllingClient |
442 | { | 442 | { |
443 | get { return m_controllingClient; } | 443 | get { return m_controllingClient; } |
444 | } | 444 | } |
445 | 445 | ||
446 | public IClientCore ClientView | 446 | public IClientCore ClientView |
447 | { | 447 | { |
448 | get { return (IClientCore) m_controllingClient; } | 448 | get { return (IClientCore) m_controllingClient; } |
449 | } | 449 | } |
450 | 450 | ||
451 | protected Vector3 m_parentPosition; | 451 | protected Vector3 m_parentPosition; |
452 | public Vector3 ParentPosition | 452 | public Vector3 ParentPosition |
453 | { | 453 | { |
454 | get { return m_parentPosition; } | 454 | get { return m_parentPosition; } |
455 | set { m_parentPosition = value; } | 455 | set { m_parentPosition = value; } |
456 | } | 456 | } |
457 | 457 | ||
458 | /// <summary> | 458 | /// <summary> |
459 | /// Position of this avatar relative to the region the avatar is in | 459 | /// Position of this avatar relative to the region the avatar is in |
460 | /// </summary> | 460 | /// </summary> |
461 | public override Vector3 AbsolutePosition | 461 | public override Vector3 AbsolutePosition |
462 | { | 462 | { |
463 | get | 463 | get |
464 | { | 464 | { |
465 | PhysicsActor actor = m_physicsActor; | 465 | PhysicsActor actor = m_physicsActor; |
466 | // if (actor != null) | 466 | // if (actor != null) |
467 | if ((actor != null) && (m_parentID == 0)) // KF Do NOT update m_pos here if Av is sitting! | 467 | if ((actor != null) && (m_parentID == 0)) // KF Do NOT update m_pos here if Av is sitting! |
468 | m_pos = actor.Position; | 468 | m_pos = actor.Position; |
469 | 469 | ||
470 | // If we're sitting, we need to update our position | 470 | // If we're sitting, we need to update our position |
471 | if (m_parentID != 0) | 471 | if (m_parentID != 0) |
472 | { | 472 | { |
473 | SceneObjectPart part = m_scene.GetSceneObjectPart(m_parentID); | 473 | SceneObjectPart part = m_scene.GetSceneObjectPart(m_parentID); |
474 | if (part != null) | 474 | if (part != null) |
475 | m_parentPosition = part.AbsolutePosition; | 475 | m_parentPosition = part.AbsolutePosition; |
476 | } | 476 | } |
477 | 477 | ||
478 | return m_parentPosition + m_pos; | 478 | return m_parentPosition + m_pos; |
479 | } | 479 | } |
480 | set | 480 | set |
481 | { | 481 | { |
482 | PhysicsActor actor = m_physicsActor; | 482 | PhysicsActor actor = m_physicsActor; |
483 | if (actor != null) | 483 | if (actor != null) |
484 | { | 484 | { |
485 | try | 485 | try |
486 | { | 486 | { |
487 | lock (m_scene.SyncRoot) | 487 | lock (m_scene.SyncRoot) |
488 | m_physicsActor.Position = value; | 488 | m_physicsActor.Position = value; |
489 | } | 489 | } |
490 | catch (Exception e) | 490 | catch (Exception e) |
491 | { | 491 | { |
492 | m_log.Error("[SCENEPRESENCE]: ABSOLUTE POSITION " + e.Message); | 492 | m_log.Error("[SCENEPRESENCE]: ABSOLUTE POSITION " + e.Message); |
493 | } | 493 | } |
494 | } | 494 | } |
495 | 495 | ||
496 | if (m_parentID == 0) // KF Do NOT update m_pos here if Av is sitting! | 496 | if (m_parentID == 0) // KF Do NOT update m_pos here if Av is sitting! |
497 | m_pos = value; | 497 | m_pos = value; |
498 | m_parentPosition = Vector3.Zero; | 498 | m_parentPosition = Vector3.Zero; |
499 | } | 499 | } |
500 | } | 500 | } |
501 | 501 | ||
502 | public Vector3 OffsetPosition | 502 | public Vector3 OffsetPosition |
503 | { | 503 | { |
504 | get { return m_pos; } | 504 | get { return m_pos; } |
505 | set { m_pos = value; } | 505 | set { m_pos = value; } |
506 | } | 506 | } |
507 | 507 | ||
508 | /// <summary> | 508 | /// <summary> |
509 | /// Current velocity of the avatar. | 509 | /// Current velocity of the avatar. |
510 | /// </summary> | 510 | /// </summary> |
511 | public override Vector3 Velocity | 511 | public override Vector3 Velocity |
512 | { | 512 | { |
513 | get | 513 | get |
514 | { | 514 | { |
515 | PhysicsActor actor = m_physicsActor; | 515 | PhysicsActor actor = m_physicsActor; |
516 | if (actor != null) | 516 | if (actor != null) |
517 | m_velocity = actor.Velocity; | 517 | m_velocity = actor.Velocity; |
518 | 518 | ||
519 | return m_velocity; | 519 | return m_velocity; |
520 | } | 520 | } |
521 | set | 521 | set |
522 | { | 522 | { |
523 | PhysicsActor actor = m_physicsActor; | 523 | PhysicsActor actor = m_physicsActor; |
524 | if (actor != null) | 524 | if (actor != null) |
525 | { | 525 | { |
526 | try | 526 | try |
527 | { | 527 | { |
528 | lock (m_scene.SyncRoot) | 528 | lock (m_scene.SyncRoot) |
529 | actor.Velocity = value; | 529 | actor.Velocity = value; |
530 | } | 530 | } |
531 | catch (Exception e) | 531 | catch (Exception e) |
532 | { | 532 | { |
533 | m_log.Error("[SCENEPRESENCE]: VELOCITY " + e.Message); | 533 | m_log.Error("[SCENEPRESENCE]: VELOCITY " + e.Message); |
534 | } | 534 | } |
535 | } | 535 | } |
536 | 536 | ||
537 | m_velocity = value; | 537 | m_velocity = value; |
538 | } | 538 | } |
539 | } | 539 | } |
540 | 540 | ||
541 | public Quaternion OffsetRotation | 541 | public Quaternion OffsetRotation |
542 | { | 542 | { |
543 | get { return m_offsetRotation; } | 543 | get { return m_offsetRotation; } |
544 | set { m_offsetRotation = value; } | 544 | set { m_offsetRotation = value; } |
545 | } | 545 | } |
546 | 546 | ||
547 | public Quaternion Rotation | 547 | public Quaternion Rotation |
548 | { | 548 | { |
549 | get { | 549 | get { |
550 | if (m_parentID != 0) | 550 | if (m_parentID != 0) |
551 | { | 551 | { |
552 | if (m_offsetRotation != null) | 552 | if (m_offsetRotation != null) |
553 | { | 553 | { |
554 | return m_offsetRotation; | 554 | return m_offsetRotation; |
555 | } | 555 | } |
556 | else | 556 | else |
557 | { | 557 | { |
558 | return new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); | 558 | return new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); |
559 | } | 559 | } |
560 | 560 | ||
561 | } | 561 | } |
562 | else | 562 | else |
563 | { | 563 | { |
564 | return m_bodyRot; | 564 | return m_bodyRot; |
565 | } | 565 | } |
566 | } | 566 | } |
567 | set { | 567 | set { |
568 | m_bodyRot = value; | 568 | m_bodyRot = value; |
569 | if (m_parentID != 0) | 569 | if (m_parentID != 0) |
570 | { | 570 | { |
571 | m_offsetRotation = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); | 571 | m_offsetRotation = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); |
572 | } | 572 | } |
573 | } | 573 | } |
574 | } | 574 | } |
575 | 575 | ||
576 | public Quaternion PreviousRotation | 576 | public Quaternion PreviousRotation |
577 | { | 577 | { |
578 | get { return m_bodyRotPrevious; } | 578 | get { return m_bodyRotPrevious; } |
579 | set { m_bodyRotPrevious = value; } | 579 | set { m_bodyRotPrevious = value; } |
580 | } | 580 | } |
581 | 581 | ||
582 | /// <summary> | 582 | /// <summary> |
583 | /// If this is true, agent doesn't have a representation in this scene. | 583 | /// If this is true, agent doesn't have a representation in this scene. |
584 | /// this is an agent 'looking into' this scene from a nearby scene(region) | 584 | /// this is an agent 'looking into' this scene from a nearby scene(region) |
585 | /// | 585 | /// |
586 | /// if False, this agent has a representation in this scene | 586 | /// if False, this agent has a representation in this scene |
587 | /// </summary> | 587 | /// </summary> |
588 | private bool m_isChildAgent = true; | 588 | private bool m_isChildAgent = true; |
589 | 589 | ||
590 | public bool IsChildAgent | 590 | public bool IsChildAgent |
591 | { | 591 | { |
592 | get { return m_isChildAgent; } | 592 | get { return m_isChildAgent; } |
593 | set { m_isChildAgent = value; } | 593 | set { m_isChildAgent = value; } |
594 | } | 594 | } |
595 | 595 | ||
596 | private uint m_parentID; | 596 | private uint m_parentID; |
597 | 597 | ||
598 | 598 | ||
599 | private UUID m_linkedPrim; | 599 | private UUID m_linkedPrim; |
600 | 600 | ||
601 | public uint ParentID | 601 | public uint ParentID |
602 | { | 602 | { |
603 | get { return m_parentID; } | 603 | get { return m_parentID; } |
604 | set { m_parentID = value; } | 604 | set { m_parentID = value; } |
605 | } | 605 | } |
606 | 606 | ||
607 | public UUID LinkedPrim | 607 | public UUID LinkedPrim |
608 | { | 608 | { |
609 | get { return m_linkedPrim; } | 609 | get { return m_linkedPrim; } |
610 | set { m_linkedPrim = value; } | 610 | set { m_linkedPrim = value; } |
611 | } | 611 | } |
612 | 612 | ||
613 | public float Health | 613 | public float Health |
614 | { | 614 | { |
615 | get { return m_health; } | 615 | get { return m_health; } |
616 | set { m_health = value; } | 616 | set { m_health = value; } |
617 | } | 617 | } |
618 | 618 | ||
619 | /// <summary> | 619 | /// <summary> |
620 | /// These are the region handles known by the avatar. | 620 | /// These are the region handles known by the avatar. |
621 | /// </summary> | 621 | /// </summary> |
622 | public List<ulong> KnownChildRegionHandles | 622 | public List<ulong> KnownChildRegionHandles |
623 | { | 623 | { |
624 | get | 624 | get |
625 | { | 625 | { |
626 | if (m_knownChildRegions.Count == 0) | 626 | if (m_knownChildRegions.Count == 0) |
627 | return new List<ulong>(); | 627 | return new List<ulong>(); |
628 | else | 628 | else |
629 | return new List<ulong>(m_knownChildRegions.Keys); | 629 | return new List<ulong>(m_knownChildRegions.Keys); |
630 | } | 630 | } |
631 | } | 631 | } |
632 | 632 | ||
633 | public Dictionary<ulong, string> KnownRegions | 633 | public Dictionary<ulong, string> KnownRegions |
634 | { | 634 | { |
635 | get { return m_knownChildRegions; } | 635 | get { return m_knownChildRegions; } |
636 | set | 636 | set |
637 | { | 637 | { |
638 | m_knownChildRegions = value; | 638 | m_knownChildRegions = value; |
639 | } | 639 | } |
640 | } | 640 | } |
641 | 641 | ||
642 | public ISceneViewer SceneViewer | 642 | public ISceneViewer SceneViewer |
643 | { | 643 | { |
644 | get { return m_sceneViewer; } | 644 | get { return m_sceneViewer; } |
645 | } | 645 | } |
646 | 646 | ||
647 | public void AdjustKnownSeeds() | 647 | public void AdjustKnownSeeds() |
648 | { | 648 | { |
649 | Dictionary<ulong, string> seeds; | 649 | Dictionary<ulong, string> seeds; |
650 | 650 | ||
651 | if (Scene.CapsModule != null) | 651 | if (Scene.CapsModule != null) |
652 | seeds = Scene.CapsModule.GetChildrenSeeds(UUID); | 652 | seeds = Scene.CapsModule.GetChildrenSeeds(UUID); |
653 | else | 653 | else |
654 | seeds = new Dictionary<ulong, string>(); | 654 | seeds = new Dictionary<ulong, string>(); |
655 | 655 | ||
656 | List<ulong> old = new List<ulong>(); | 656 | List<ulong> old = new List<ulong>(); |
657 | foreach (ulong handle in seeds.Keys) | 657 | foreach (ulong handle in seeds.Keys) |
658 | { | 658 | { |
659 | uint x, y; | 659 | uint x, y; |
660 | Utils.LongToUInts(handle, out x, out y); | 660 | Utils.LongToUInts(handle, out x, out y); |
661 | x = x / Constants.RegionSize; | 661 | x = x / Constants.RegionSize; |
662 | y = y / Constants.RegionSize; | 662 | y = y / Constants.RegionSize; |
663 | if (Util.IsOutsideView(x, Scene.RegionInfo.RegionLocX, y, Scene.RegionInfo.RegionLocY)) | 663 | if (Util.IsOutsideView(x, Scene.RegionInfo.RegionLocX, y, Scene.RegionInfo.RegionLocY)) |
664 | { | 664 | { |
665 | old.Add(handle); | 665 | old.Add(handle); |
666 | } | 666 | } |
667 | } | 667 | } |
668 | DropOldNeighbours(old); | 668 | DropOldNeighbours(old); |
669 | 669 | ||
670 | if (Scene.CapsModule != null) | 670 | if (Scene.CapsModule != null) |
671 | Scene.CapsModule.SetChildrenSeed(UUID, seeds); | 671 | Scene.CapsModule.SetChildrenSeed(UUID, seeds); |
672 | 672 | ||
673 | KnownRegions = seeds; | 673 | KnownRegions = seeds; |
674 | //m_log.Debug(" ++++++++++AFTER+++++++++++++ "); | 674 | //m_log.Debug(" ++++++++++AFTER+++++++++++++ "); |
675 | //DumpKnownRegions(); | 675 | //DumpKnownRegions(); |
676 | } | 676 | } |
677 | 677 | ||
678 | public void DumpKnownRegions() | 678 | public void DumpKnownRegions() |
679 | { | 679 | { |
680 | m_log.Info("================ KnownRegions "+Scene.RegionInfo.RegionName+" ================"); | 680 | m_log.Info("================ KnownRegions "+Scene.RegionInfo.RegionName+" ================"); |
681 | foreach (KeyValuePair<ulong, string> kvp in KnownRegions) | 681 | foreach (KeyValuePair<ulong, string> kvp in KnownRegions) |
682 | { | 682 | { |
683 | uint x, y; | 683 | uint x, y; |
684 | Utils.LongToUInts(kvp.Key, out x, out y); | 684 | Utils.LongToUInts(kvp.Key, out x, out y); |
685 | x = x / Constants.RegionSize; | 685 | x = x / Constants.RegionSize; |
686 | y = y / Constants.RegionSize; | 686 | y = y / Constants.RegionSize; |
687 | m_log.Info(" >> "+x+", "+y+": "+kvp.Value); | 687 | m_log.Info(" >> "+x+", "+y+": "+kvp.Value); |
688 | } | 688 | } |
689 | } | 689 | } |
690 | 690 | ||
691 | private bool m_inTransit; | 691 | private bool m_inTransit; |
692 | private bool m_mouseLook; | 692 | private bool m_mouseLook; |
693 | private bool m_leftButtonDown; | 693 | private bool m_leftButtonDown; |
694 | 694 | ||
695 | public bool IsInTransit | 695 | public bool IsInTransit |
696 | { | 696 | { |
697 | get { return m_inTransit; } | 697 | get { return m_inTransit; } |
698 | set { m_inTransit = value; } | 698 | set { m_inTransit = value; } |
699 | } | 699 | } |
700 | 700 | ||
701 | public float SpeedModifier | 701 | public float SpeedModifier |
702 | { | 702 | { |
703 | get { return m_speedModifier; } | 703 | get { return m_speedModifier; } |
704 | set { m_speedModifier = value; } | 704 | set { m_speedModifier = value; } |
705 | } | 705 | } |
706 | 706 | ||
707 | public bool ForceFly | 707 | public bool ForceFly |
708 | { | 708 | { |
709 | get { return m_forceFly; } | 709 | get { return m_forceFly; } |
710 | set { m_forceFly = value; } | 710 | set { m_forceFly = value; } |
711 | } | 711 | } |
712 | 712 | ||
713 | public bool FlyDisabled | 713 | public bool FlyDisabled |
714 | { | 714 | { |
715 | get { return m_flyDisabled; } | 715 | get { return m_flyDisabled; } |
716 | set { m_flyDisabled = value; } | 716 | set { m_flyDisabled = value; } |
717 | } | 717 | } |
718 | 718 | ||
719 | public string Viewer | 719 | public string Viewer |
720 | { | 720 | { |
721 | get { return m_scene.AuthenticateHandler.GetAgentCircuitData(ControllingClient.CircuitCode).Viewer; } | 721 | get { return m_scene.AuthenticateHandler.GetAgentCircuitData(ControllingClient.CircuitCode).Viewer; } |
722 | } | 722 | } |
723 | 723 | ||
724 | #endregion | 724 | #endregion |
725 | 725 | ||
726 | #region Constructor(s) | 726 | #region Constructor(s) |
727 | 727 | ||
728 | public ScenePresence() | 728 | public ScenePresence() |
729 | { | 729 | { |
730 | m_sendCourseLocationsMethod = SendCoarseLocationsDefault; | 730 | m_sendCourseLocationsMethod = SendCoarseLocationsDefault; |
731 | CreateSceneViewer(); | 731 | CreateSceneViewer(); |
732 | m_animator = new ScenePresenceAnimator(this); | 732 | m_animator = new ScenePresenceAnimator(this); |
733 | } | 733 | } |
734 | 734 | ||
735 | private ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo) : this() | 735 | private ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo) : this() |
736 | { | 736 | { |
737 | m_rootRegionHandle = reginfo.RegionHandle; | 737 | m_rootRegionHandle = reginfo.RegionHandle; |
738 | m_controllingClient = client; | 738 | m_controllingClient = client; |
739 | m_firstname = m_controllingClient.FirstName; | 739 | m_firstname = m_controllingClient.FirstName; |
740 | m_lastname = m_controllingClient.LastName; | 740 | m_lastname = m_controllingClient.LastName; |
741 | m_name = String.Format("{0} {1}", m_firstname, m_lastname); | 741 | m_name = String.Format("{0} {1}", m_firstname, m_lastname); |
742 | m_scene = world; | 742 | m_scene = world; |
743 | m_uuid = client.AgentId; | 743 | m_uuid = client.AgentId; |
744 | m_regionInfo = reginfo; | 744 | m_regionInfo = reginfo; |
745 | m_localId = m_scene.AllocateLocalId(); | 745 | m_localId = m_scene.AllocateLocalId(); |
746 | 746 | ||
747 | UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, m_uuid); | 747 | UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, m_uuid); |
748 | 748 | ||
749 | if (account != null) | 749 | if (account != null) |
750 | m_userLevel = account.UserLevel; | 750 | m_userLevel = account.UserLevel; |
751 | 751 | ||
752 | IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); | 752 | IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); |
753 | if (gm != null) | 753 | if (gm != null) |
754 | m_grouptitle = gm.GetGroupTitle(m_uuid); | 754 | m_grouptitle = gm.GetGroupTitle(m_uuid); |
755 | 755 | ||
756 | m_scriptEngines = m_scene.RequestModuleInterfaces<IScriptModule>(); | 756 | m_scriptEngines = m_scene.RequestModuleInterfaces<IScriptModule>(); |
757 | 757 | ||
758 | AbsolutePosition = posLastSignificantMove = m_CameraCenter = | 758 | AbsolutePosition = posLastSignificantMove = m_CameraCenter = |
759 | m_lastCameraCenter = m_controllingClient.StartPos; | 759 | m_lastCameraCenter = m_controllingClient.StartPos; |
760 | 760 | ||
761 | m_reprioritization_timer = new Timer(world.ReprioritizationInterval); | 761 | m_reprioritization_timer = new Timer(world.ReprioritizationInterval); |
762 | m_reprioritization_timer.Elapsed += new ElapsedEventHandler(Reprioritize); | 762 | m_reprioritization_timer.Elapsed += new ElapsedEventHandler(Reprioritize); |
763 | m_reprioritization_timer.AutoReset = false; | 763 | m_reprioritization_timer.AutoReset = false; |
764 | 764 | ||
765 | AdjustKnownSeeds(); | 765 | AdjustKnownSeeds(); |
766 | Animator.TrySetMovementAnimation("STAND"); | 766 | Animator.TrySetMovementAnimation("STAND"); |
767 | // we created a new ScenePresence (a new child agent) in a fresh region. | 767 | // we created a new ScenePresence (a new child agent) in a fresh region. |
768 | // Request info about all the (root) agents in this region | 768 | // Request info about all the (root) agents in this region |
769 | // Note: This won't send data *to* other clients in that region (children don't send) | 769 | // Note: This won't send data *to* other clients in that region (children don't send) |
770 | SendInitialFullUpdateToAllClients(); | 770 | SendInitialFullUpdateToAllClients(); |
771 | RegisterToEvents(); | 771 | RegisterToEvents(); |
772 | if (m_controllingClient != null) | 772 | if (m_controllingClient != null) |
773 | { | 773 | { |
774 | m_controllingClient.ProcessPendingPackets(); | 774 | m_controllingClient.ProcessPendingPackets(); |
775 | } | 775 | } |
776 | SetDirectionVectors(); | 776 | SetDirectionVectors(); |
777 | } | 777 | } |
778 | 778 | ||
779 | public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, byte[] visualParams, | 779 | public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, byte[] visualParams, |
780 | AvatarWearable[] wearables) | 780 | AvatarWearable[] wearables) |
781 | : this(client, world, reginfo) | 781 | : this(client, world, reginfo) |
782 | { | 782 | { |
783 | m_appearance = new AvatarAppearance(m_uuid, wearables, visualParams); | 783 | m_appearance = new AvatarAppearance(m_uuid, wearables, visualParams); |
784 | } | 784 | } |
785 | 785 | ||
786 | public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, AvatarAppearance appearance) | 786 | public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, AvatarAppearance appearance) |
787 | : this(client, world, reginfo) | 787 | : this(client, world, reginfo) |
788 | { | 788 | { |
789 | m_appearance = appearance; | 789 | m_appearance = appearance; |
790 | } | 790 | } |
791 | 791 | ||
792 | private void CreateSceneViewer() | 792 | private void CreateSceneViewer() |
793 | { | 793 | { |
794 | m_sceneViewer = new SceneViewer(this); | 794 | m_sceneViewer = new SceneViewer(this); |
795 | } | 795 | } |
796 | 796 | ||
797 | public void RegisterToEvents() | 797 | public void RegisterToEvents() |
798 | { | 798 | { |
799 | m_controllingClient.OnRequestWearables += SendWearables; | 799 | m_controllingClient.OnRequestWearables += SendWearables; |
800 | m_controllingClient.OnSetAppearance += SetAppearance; | 800 | m_controllingClient.OnSetAppearance += SetAppearance; |
801 | m_controllingClient.OnCompleteMovementToRegion += CompleteMovement; | 801 | m_controllingClient.OnCompleteMovementToRegion += CompleteMovement; |
802 | //m_controllingClient.OnCompleteMovementToRegion += SendInitialData; | 802 | //m_controllingClient.OnCompleteMovementToRegion += SendInitialData; |
803 | m_controllingClient.OnAgentUpdate += HandleAgentUpdate; | 803 | m_controllingClient.OnAgentUpdate += HandleAgentUpdate; |
804 | m_controllingClient.OnAgentRequestSit += HandleAgentRequestSit; | 804 | m_controllingClient.OnAgentRequestSit += HandleAgentRequestSit; |
805 | m_controllingClient.OnAgentSit += HandleAgentSit; | 805 | m_controllingClient.OnAgentSit += HandleAgentSit; |
806 | m_controllingClient.OnSetAlwaysRun += HandleSetAlwaysRun; | 806 | m_controllingClient.OnSetAlwaysRun += HandleSetAlwaysRun; |
807 | m_controllingClient.OnStartAnim += HandleStartAnim; | 807 | m_controllingClient.OnStartAnim += HandleStartAnim; |
808 | m_controllingClient.OnStopAnim += HandleStopAnim; | 808 | m_controllingClient.OnStopAnim += HandleStopAnim; |
809 | m_controllingClient.OnForceReleaseControls += HandleForceReleaseControls; | 809 | m_controllingClient.OnForceReleaseControls += HandleForceReleaseControls; |
810 | m_controllingClient.OnAutoPilotGo += DoAutoPilot; | 810 | m_controllingClient.OnAutoPilotGo += DoAutoPilot; |
811 | m_controllingClient.AddGenericPacketHandler("autopilot", DoMoveToPosition); | 811 | m_controllingClient.AddGenericPacketHandler("autopilot", DoMoveToPosition); |
812 | 812 | ||
813 | // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); | 813 | // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); |
814 | // ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); | 814 | // ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); |
815 | } | 815 | } |
816 | 816 | ||
817 | private void SetDirectionVectors() | 817 | private void SetDirectionVectors() |
818 | { | 818 | { |
819 | Dir_Vectors[0] = Vector3.UnitX; //FORWARD | 819 | Dir_Vectors[0] = Vector3.UnitX; //FORWARD |
820 | Dir_Vectors[1] = -Vector3.UnitX; //BACK | 820 | Dir_Vectors[1] = -Vector3.UnitX; //BACK |
821 | Dir_Vectors[2] = Vector3.UnitY; //LEFT | 821 | Dir_Vectors[2] = Vector3.UnitY; //LEFT |
822 | Dir_Vectors[3] = -Vector3.UnitY; //RIGHT | 822 | Dir_Vectors[3] = -Vector3.UnitY; //RIGHT |
823 | Dir_Vectors[4] = Vector3.UnitZ; //UP | 823 | Dir_Vectors[4] = Vector3.UnitZ; //UP |
824 | Dir_Vectors[5] = -Vector3.UnitZ; //DOWN | 824 | Dir_Vectors[5] = -Vector3.UnitZ; //DOWN |
825 | Dir_Vectors[6] = new Vector3(0.5f, 0f, 0f); //FORWARD_NUDGE | 825 | Dir_Vectors[6] = new Vector3(0.5f, 0f, 0f); //FORWARD_NUDGE |
826 | Dir_Vectors[7] = new Vector3(-0.5f, 0f, 0f); //BACK_NUDGE | 826 | Dir_Vectors[7] = new Vector3(-0.5f, 0f, 0f); //BACK_NUDGE |
827 | Dir_Vectors[8] = new Vector3(0f, 0.5f, 0f); //LEFT_NUDGE | 827 | Dir_Vectors[8] = new Vector3(0f, 0.5f, 0f); //LEFT_NUDGE |
828 | Dir_Vectors[9] = new Vector3(0f, -0.5f, 0f); //RIGHT_NUDGE | 828 | Dir_Vectors[9] = new Vector3(0f, -0.5f, 0f); //RIGHT_NUDGE |
829 | Dir_Vectors[10] = new Vector3(0f, 0f, -0.5f); //DOWN_Nudge | 829 | Dir_Vectors[10] = new Vector3(0f, 0f, -0.5f); //DOWN_Nudge |
830 | } | 830 | } |
831 | 831 | ||
832 | private Vector3[] GetWalkDirectionVectors() | 832 | private Vector3[] GetWalkDirectionVectors() |
833 | { | 833 | { |
834 | Vector3[] vector = new Vector3[11]; | 834 | Vector3[] vector = new Vector3[11]; |
835 | vector[0] = new Vector3(m_CameraUpAxis.Z, 0f, -m_CameraAtAxis.Z); //FORWARD | 835 | vector[0] = new Vector3(m_CameraUpAxis.Z, 0f, -m_CameraAtAxis.Z); //FORWARD |
836 | vector[1] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK | 836 | vector[1] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK |
837 | vector[2] = Vector3.UnitY; //LEFT | 837 | vector[2] = Vector3.UnitY; //LEFT |
838 | vector[3] = -Vector3.UnitY; //RIGHT | 838 | vector[3] = -Vector3.UnitY; //RIGHT |
839 | vector[4] = new Vector3(m_CameraAtAxis.Z, 0f, m_CameraUpAxis.Z); //UP | 839 | vector[4] = new Vector3(m_CameraAtAxis.Z, 0f, m_CameraUpAxis.Z); //UP |
840 | vector[5] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN | 840 | vector[5] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN |
841 | vector[6] = new Vector3(m_CameraUpAxis.Z, 0f, -m_CameraAtAxis.Z); //FORWARD_NUDGE | 841 | vector[6] = new Vector3(m_CameraUpAxis.Z, 0f, -m_CameraAtAxis.Z); //FORWARD_NUDGE |
842 | vector[7] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK_NUDGE | 842 | vector[7] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK_NUDGE |
843 | vector[8] = Vector3.UnitY; //LEFT_NUDGE | 843 | vector[8] = Vector3.UnitY; //LEFT_NUDGE |
844 | vector[9] = -Vector3.UnitY; //RIGHT_NUDGE | 844 | vector[9] = -Vector3.UnitY; //RIGHT_NUDGE |
845 | vector[10] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN_NUDGE | 845 | vector[10] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN_NUDGE |
846 | return vector; | 846 | return vector; |
847 | } | 847 | } |
848 | 848 | ||
849 | private bool[] GetDirectionIsNudge() | 849 | private bool[] GetDirectionIsNudge() |
850 | { | 850 | { |
851 | bool[] isNudge = new bool[11]; | 851 | bool[] isNudge = new bool[11]; |
852 | isNudge[0] = false; //FORWARD | 852 | isNudge[0] = false; //FORWARD |
853 | isNudge[1] = false; //BACK | 853 | isNudge[1] = false; //BACK |
854 | isNudge[2] = false; //LEFT | 854 | isNudge[2] = false; //LEFT |
855 | isNudge[3] = false; //RIGHT | 855 | isNudge[3] = false; //RIGHT |
856 | isNudge[4] = false; //UP | 856 | isNudge[4] = false; //UP |
857 | isNudge[5] = false; //DOWN | 857 | isNudge[5] = false; //DOWN |
858 | isNudge[6] = true; //FORWARD_NUDGE | 858 | isNudge[6] = true; //FORWARD_NUDGE |
859 | isNudge[7] = true; //BACK_NUDGE | 859 | isNudge[7] = true; //BACK_NUDGE |
860 | isNudge[8] = true; //LEFT_NUDGE | 860 | isNudge[8] = true; //LEFT_NUDGE |
861 | isNudge[9] = true; //RIGHT_NUDGE | 861 | isNudge[9] = true; //RIGHT_NUDGE |
862 | isNudge[10] = true; //DOWN_Nudge | 862 | isNudge[10] = true; //DOWN_Nudge |
863 | return isNudge; | 863 | return isNudge; |
864 | } | 864 | } |
865 | 865 | ||
866 | 866 | ||
867 | #endregion | 867 | #endregion |
868 | 868 | ||
869 | public uint GenerateClientFlags(UUID ObjectID) | 869 | public uint GenerateClientFlags(UUID ObjectID) |
870 | { | 870 | { |
871 | return m_scene.Permissions.GenerateClientFlags(m_uuid, ObjectID); | 871 | return m_scene.Permissions.GenerateClientFlags(m_uuid, ObjectID); |
872 | } | 872 | } |
873 | 873 | ||
874 | /// <summary> | 874 | /// <summary> |
875 | /// Send updates to the client about prims which have been placed on the update queue. We don't | 875 | /// Send updates to the client about prims which have been placed on the update queue. We don't |
876 | /// necessarily send updates for all the parts on the queue, e.g. if an updates with a more recent | 876 | /// necessarily send updates for all the parts on the queue, e.g. if an updates with a more recent |
877 | /// timestamp has already been sent. | 877 | /// timestamp has already been sent. |
878 | /// </summary> | 878 | /// </summary> |
879 | public void SendPrimUpdates() | 879 | public void SendPrimUpdates() |
880 | { | 880 | { |
881 | m_perfMonMS = Util.EnvironmentTickCount(); | 881 | m_perfMonMS = Util.EnvironmentTickCount(); |
882 | 882 | ||
883 | m_sceneViewer.SendPrimUpdates(); | 883 | m_sceneViewer.SendPrimUpdates(); |
884 | 884 | ||
885 | m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); | 885 | m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); |
886 | } | 886 | } |
887 | 887 | ||
888 | #region Status Methods | 888 | #region Status Methods |
889 | 889 | ||
890 | /// <summary> | 890 | /// <summary> |
891 | /// This turns a child agent, into a root agent | 891 | /// This turns a child agent, into a root agent |
892 | /// This is called when an agent teleports into a region, or if an | 892 | /// This is called when an agent teleports into a region, or if an |
893 | /// agent crosses into this region from a neighbor over the border | 893 | /// agent crosses into this region from a neighbor over the border |
894 | /// </summary> | 894 | /// </summary> |
895 | public void MakeRootAgent(Vector3 pos, bool isFlying) | 895 | public void MakeRootAgent(Vector3 pos, bool isFlying) |
896 | { | 896 | { |
897 | m_log.DebugFormat( | 897 | m_log.DebugFormat( |
898 | "[SCENE]: Upgrading child to root agent for {0} in {1}", | 898 | "[SCENE]: Upgrading child to root agent for {0} in {1}", |
899 | Name, m_scene.RegionInfo.RegionName); | 899 | Name, m_scene.RegionInfo.RegionName); |
900 | 900 | ||
901 | //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count); | 901 | //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count); |
902 | 902 | ||
903 | IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); | 903 | IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); |
904 | if (gm != null) | 904 | if (gm != null) |
905 | m_grouptitle = gm.GetGroupTitle(m_uuid); | 905 | m_grouptitle = gm.GetGroupTitle(m_uuid); |
906 | 906 | ||
907 | m_rootRegionHandle = m_scene.RegionInfo.RegionHandle; | 907 | m_rootRegionHandle = m_scene.RegionInfo.RegionHandle; |
908 | m_scene.SetRootAgentScene(m_uuid); | 908 | m_scene.SetRootAgentScene(m_uuid); |
909 | 909 | ||
910 | // Moved this from SendInitialData to ensure that m_appearance is initialized | 910 | // Moved this from SendInitialData to ensure that m_appearance is initialized |
911 | // before the inventory is processed in MakeRootAgent. This fixes a race condition | 911 | // before the inventory is processed in MakeRootAgent. This fixes a race condition |
912 | // related to the handling of attachments | 912 | // related to the handling of attachments |
913 | //m_scene.GetAvatarAppearance(m_controllingClient, out m_appearance); | 913 | //m_scene.GetAvatarAppearance(m_controllingClient, out m_appearance); |
914 | if (m_scene.TestBorderCross(pos, Cardinals.E)) | 914 | if (m_scene.TestBorderCross(pos, Cardinals.E)) |
915 | { | 915 | { |
916 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E); | 916 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E); |
917 | pos.X = crossedBorder.BorderLine.Z - 1; | 917 | pos.X = crossedBorder.BorderLine.Z - 1; |
918 | } | 918 | } |
919 | 919 | ||
920 | if (m_scene.TestBorderCross(pos, Cardinals.N)) | 920 | if (m_scene.TestBorderCross(pos, Cardinals.N)) |
921 | { | 921 | { |
922 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N); | 922 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N); |
923 | pos.Y = crossedBorder.BorderLine.Z - 1; | 923 | pos.Y = crossedBorder.BorderLine.Z - 1; |
924 | } | 924 | } |
925 | 925 | ||
926 | //If they're TP'ing in or logging in, we haven't had time to add any known child regions yet. | 926 | //If they're TP'ing in or logging in, we haven't had time to add any known child regions yet. |
927 | //This has the unfortunate consequence that if somebody is TP'ing who is already a child agent, | 927 | //This has the unfortunate consequence that if somebody is TP'ing who is already a child agent, |
928 | //they'll bypass the landing point. But I can't think of any decent way of fixing this. | 928 | //they'll bypass the landing point. But I can't think of any decent way of fixing this. |
929 | if (KnownChildRegionHandles.Count == 0) | 929 | if (KnownChildRegionHandles.Count == 0) |
930 | { | 930 | { |
931 | ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y); | 931 | ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y); |
932 | if (land != null) | 932 | if (land != null) |
933 | { | 933 | { |
934 | //Don't restrict gods, estate managers, or land owners to the TP point. This behaviour mimics agni. | 934 | //Don't restrict gods, estate managers, or land owners to the TP point. This behaviour mimics agni. |
935 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero && UserLevel < 200 && !m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid) && land.LandData.OwnerID != m_uuid) | 935 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero && UserLevel < 200 && !m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid) && land.LandData.OwnerID != m_uuid) |
936 | { | 936 | { |
937 | pos = land.LandData.UserLocation; | 937 | pos = land.LandData.UserLocation; |
938 | } | 938 | } |
939 | } | 939 | } |
940 | } | 940 | } |
941 | 941 | ||
942 | if (pos.X < 0 || pos.Y < 0 || pos.Z < 0) | 942 | if (pos.X < 0 || pos.Y < 0 || pos.Z < 0) |
943 | { | 943 | { |
944 | Vector3 emergencyPos = new Vector3(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 128); | 944 | Vector3 emergencyPos = new Vector3(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 128); |
945 | 945 | ||
946 | if (pos.X < 0) | 946 | if (pos.X < 0) |
947 | { | 947 | { |
948 | emergencyPos.X = (int)Constants.RegionSize + pos.X; | 948 | emergencyPos.X = (int)Constants.RegionSize + pos.X; |
949 | if (!(pos.Y < 0)) | 949 | if (!(pos.Y < 0)) |
950 | emergencyPos.Y = pos.Y; | 950 | emergencyPos.Y = pos.Y; |
951 | if (!(pos.Z < 0)) | 951 | if (!(pos.Z < 0)) |
952 | emergencyPos.Z = pos.Z; | 952 | emergencyPos.Z = pos.Z; |
953 | } | 953 | } |
954 | if (pos.Y < 0) | 954 | if (pos.Y < 0) |
955 | { | 955 | { |
956 | emergencyPos.Y = (int)Constants.RegionSize + pos.Y; | 956 | emergencyPos.Y = (int)Constants.RegionSize + pos.Y; |
957 | if (!(pos.X < 0)) | 957 | if (!(pos.X < 0)) |
958 | emergencyPos.X = pos.X; | 958 | emergencyPos.X = pos.X; |
959 | if (!(pos.Z < 0)) | 959 | if (!(pos.Z < 0)) |
960 | emergencyPos.Z = pos.Z; | 960 | emergencyPos.Z = pos.Z; |
961 | } | 961 | } |
962 | if (pos.Z < 0) | 962 | if (pos.Z < 0) |
963 | { | 963 | { |
964 | emergencyPos.Z = 128; | 964 | emergencyPos.Z = 128; |
965 | if (!(pos.Y < 0)) | 965 | if (!(pos.Y < 0)) |
966 | emergencyPos.Y = pos.Y; | 966 | emergencyPos.Y = pos.Y; |
967 | if (!(pos.X < 0)) | 967 | if (!(pos.X < 0)) |
968 | emergencyPos.X = pos.X; | 968 | emergencyPos.X = pos.X; |
969 | } | 969 | } |
970 | } | 970 | } |
971 | 971 | ||
972 | if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) | 972 | if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) |
973 | { | 973 | { |
974 | m_log.WarnFormat( | 974 | m_log.WarnFormat( |
975 | "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping", | 975 | "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping", |
976 | pos, Name, UUID); | 976 | pos, Name, UUID); |
977 | 977 | ||
978 | if (pos.X < 0f) pos.X = 0f; | 978 | if (pos.X < 0f) pos.X = 0f; |
979 | if (pos.Y < 0f) pos.Y = 0f; | 979 | if (pos.Y < 0f) pos.Y = 0f; |
980 | if (pos.Z < 0f) pos.Z = 0f; | 980 | if (pos.Z < 0f) pos.Z = 0f; |
981 | } | 981 | } |
982 | 982 | ||
983 | float localAVHeight = 1.56f; | 983 | float localAVHeight = 1.56f; |
984 | if (m_avHeight != 127.0f) | 984 | if (m_avHeight != 127.0f) |
985 | { | 985 | { |
986 | localAVHeight = m_avHeight; | 986 | localAVHeight = m_avHeight; |
987 | } | 987 | } |
988 | 988 | ||
989 | float posZLimit = 0; | 989 | float posZLimit = 0; |
990 | 990 | ||
991 | if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize) | 991 | if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize) |
992 | posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; | 992 | posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; |
993 | 993 | ||
994 | float newPosZ = posZLimit + localAVHeight / 2; | 994 | float newPosZ = posZLimit + localAVHeight / 2; |
995 | if (posZLimit >= (pos.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) | 995 | if (posZLimit >= (pos.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) |
996 | { | 996 | { |
997 | pos.Z = newPosZ; | 997 | pos.Z = newPosZ; |
998 | } | 998 | } |
999 | AbsolutePosition = pos; | 999 | AbsolutePosition = pos; |
1000 | 1000 | ||
1001 | AddToPhysicalScene(isFlying); | 1001 | AddToPhysicalScene(isFlying); |
1002 | 1002 | ||
1003 | if (m_forceFly) | 1003 | if (m_forceFly) |
1004 | { | 1004 | { |
1005 | m_physicsActor.Flying = true; | 1005 | m_physicsActor.Flying = true; |
1006 | } | 1006 | } |
1007 | else if (m_flyDisabled) | 1007 | else if (m_flyDisabled) |
1008 | { | 1008 | { |
1009 | m_physicsActor.Flying = false; | 1009 | m_physicsActor.Flying = false; |
1010 | } | 1010 | } |
1011 | 1011 | ||
1012 | if (m_appearance != null) | 1012 | if (m_appearance != null) |
1013 | { | 1013 | { |
1014 | if (m_appearance.AvatarHeight > 0) | 1014 | if (m_appearance.AvatarHeight > 0) |
1015 | SetHeight(m_appearance.AvatarHeight); | 1015 | SetHeight(m_appearance.AvatarHeight); |
1016 | } | 1016 | } |
1017 | else | 1017 | else |
1018 | { | 1018 | { |
1019 | m_log.ErrorFormat("[SCENE PRESENCE]: null appearance in MakeRoot in {0}", Scene.RegionInfo.RegionName); | 1019 | m_log.ErrorFormat("[SCENE PRESENCE]: null appearance in MakeRoot in {0}", Scene.RegionInfo.RegionName); |
1020 | // emergency; this really shouldn't happen | 1020 | // emergency; this really shouldn't happen |
1021 | m_appearance = new AvatarAppearance(UUID); | 1021 | m_appearance = new AvatarAppearance(UUID); |
1022 | } | 1022 | } |
1023 | 1023 | ||
1024 | // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying | 1024 | // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying |
1025 | // avatar to return to the standing position in mid-air. On login it looks like this is being sent | 1025 | // avatar to return to the standing position in mid-air. On login it looks like this is being sent |
1026 | // elsewhere anyway | 1026 | // elsewhere anyway |
1027 | // Animator.SendAnimPack(); | 1027 | // Animator.SendAnimPack(); |
1028 | 1028 | ||
1029 | m_scene.SwapRootAgentCount(false); | 1029 | m_scene.SwapRootAgentCount(false); |
1030 | 1030 | ||
1031 | //CachedUserInfo userInfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(m_uuid); | 1031 | //CachedUserInfo userInfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(m_uuid); |
1032 | //if (userInfo != null) | 1032 | //if (userInfo != null) |
1033 | // userInfo.FetchInventory(); | 1033 | // userInfo.FetchInventory(); |
1034 | //else | 1034 | //else |
1035 | // m_log.ErrorFormat("[SCENE]: Could not find user info for {0} when making it a root agent", m_uuid); | 1035 | // m_log.ErrorFormat("[SCENE]: Could not find user info for {0} when making it a root agent", m_uuid); |
1036 | 1036 | ||
1037 | // On the next prim update, all objects will be sent | 1037 | // On the next prim update, all objects will be sent |
1038 | // | 1038 | // |
1039 | m_sceneViewer.Reset(); | 1039 | m_sceneViewer.Reset(); |
1040 | 1040 | ||
1041 | m_isChildAgent = false; | 1041 | m_isChildAgent = false; |
1042 | 1042 | ||
1043 | // send the animations of the other presences to me | 1043 | // send the animations of the other presences to me |
1044 | m_scene.ForEachScenePresence(delegate(ScenePresence presence) | 1044 | m_scene.ForEachScenePresence(delegate(ScenePresence presence) |
1045 | { | 1045 | { |
1046 | if (presence != this) | 1046 | if (presence != this) |
1047 | presence.Animator.SendAnimPackToClient(ControllingClient); | 1047 | presence.Animator.SendAnimPackToClient(ControllingClient); |
1048 | }); | 1048 | }); |
1049 | 1049 | ||
1050 | m_scene.EventManager.TriggerOnMakeRootAgent(this); | 1050 | m_scene.EventManager.TriggerOnMakeRootAgent(this); |
1051 | } | 1051 | } |
1052 | 1052 | ||
1053 | /// <summary> | 1053 | /// <summary> |
1054 | /// This turns a root agent into a child agent | 1054 | /// This turns a root agent into a child agent |
1055 | /// when an agent departs this region for a neighbor, this gets called. | 1055 | /// when an agent departs this region for a neighbor, this gets called. |
1056 | /// | 1056 | /// |
1057 | /// It doesn't get called for a teleport. Reason being, an agent that | 1057 | /// It doesn't get called for a teleport. Reason being, an agent that |
1058 | /// teleports out may not end up anywhere near this region | 1058 | /// teleports out may not end up anywhere near this region |
1059 | /// </summary> | 1059 | /// </summary> |
1060 | public void MakeChildAgent() | 1060 | public void MakeChildAgent() |
1061 | { | 1061 | { |
1062 | // It looks like m_animator is set to null somewhere, and MakeChild | 1062 | // It looks like m_animator is set to null somewhere, and MakeChild |
1063 | // is called after that. Probably in aborted teleports. | 1063 | // is called after that. Probably in aborted teleports. |
1064 | if (m_animator == null) | 1064 | if (m_animator == null) |
1065 | m_animator = new ScenePresenceAnimator(this); | 1065 | m_animator = new ScenePresenceAnimator(this); |
1066 | else | 1066 | else |
1067 | Animator.ResetAnimations(); | 1067 | Animator.ResetAnimations(); |
1068 | 1068 | ||
1069 | // m_log.DebugFormat( | 1069 | // m_log.DebugFormat( |
1070 | // "[SCENEPRESENCE]: Downgrading root agent {0}, {1} to a child agent in {2}", | 1070 | // "[SCENEPRESENCE]: Downgrading root agent {0}, {1} to a child agent in {2}", |
1071 | // Name, UUID, m_scene.RegionInfo.RegionName); | 1071 | // Name, UUID, m_scene.RegionInfo.RegionName); |
1072 | 1072 | ||
1073 | // Don't zero out the velocity since this can cause problems when an avatar is making a region crossing, | 1073 | // Don't zero out the velocity since this can cause problems when an avatar is making a region crossing, |
1074 | // depending on the exact timing. This shouldn't matter anyway since child agent positions are not updated. | 1074 | // depending on the exact timing. This shouldn't matter anyway since child agent positions are not updated. |
1075 | //Velocity = new Vector3(0, 0, 0); | 1075 | //Velocity = new Vector3(0, 0, 0); |
1076 | 1076 | ||
1077 | m_isChildAgent = true; | 1077 | m_isChildAgent = true; |
1078 | m_scene.SwapRootAgentCount(true); | 1078 | m_scene.SwapRootAgentCount(true); |
1079 | RemoveFromPhysicalScene(); | 1079 | RemoveFromPhysicalScene(); |
1080 | 1080 | ||
1081 | // FIXME: Set m_rootRegionHandle to the region handle of the scene this agent is moving into | 1081 | // FIXME: Set m_rootRegionHandle to the region handle of the scene this agent is moving into |
1082 | 1082 | ||
1083 | m_scene.EventManager.TriggerOnMakeChildAgent(this); | 1083 | m_scene.EventManager.TriggerOnMakeChildAgent(this); |
1084 | } | 1084 | } |
1085 | 1085 | ||
1086 | /// <summary> | 1086 | /// <summary> |
1087 | /// Removes physics plugin scene representation of this agent if it exists. | 1087 | /// Removes physics plugin scene representation of this agent if it exists. |
1088 | /// </summary> | 1088 | /// </summary> |
1089 | private void RemoveFromPhysicalScene() | 1089 | private void RemoveFromPhysicalScene() |
1090 | { | 1090 | { |
1091 | if (PhysicsActor != null) | 1091 | if (PhysicsActor != null) |
1092 | { | 1092 | { |
1093 | m_physicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients; | 1093 | m_physicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients; |
1094 | m_physicsActor.OnOutOfBounds -= OutOfBoundsCall; | 1094 | m_physicsActor.OnOutOfBounds -= OutOfBoundsCall; |
1095 | m_scene.PhysicsScene.RemoveAvatar(PhysicsActor); | 1095 | m_scene.PhysicsScene.RemoveAvatar(PhysicsActor); |
1096 | m_physicsActor.UnSubscribeEvents(); | 1096 | m_physicsActor.UnSubscribeEvents(); |
1097 | m_physicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate; | 1097 | m_physicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate; |
1098 | PhysicsActor = null; | 1098 | PhysicsActor = null; |
1099 | } | 1099 | } |
1100 | } | 1100 | } |
1101 | 1101 | ||
1102 | /// <summary> | 1102 | /// <summary> |
1103 | /// | 1103 | /// |
1104 | /// </summary> | 1104 | /// </summary> |
1105 | /// <param name="pos"></param> | 1105 | /// <param name="pos"></param> |
1106 | public void Teleport(Vector3 pos) | 1106 | public void Teleport(Vector3 pos) |
1107 | { | 1107 | { |
1108 | bool isFlying = false; | 1108 | bool isFlying = false; |
1109 | 1109 | ||
1110 | if (m_physicsActor != null) | 1110 | if (m_physicsActor != null) |
1111 | isFlying = m_physicsActor.Flying; | 1111 | isFlying = m_physicsActor.Flying; |
1112 | 1112 | ||
1113 | RemoveFromPhysicalScene(); | 1113 | RemoveFromPhysicalScene(); |
1114 | Velocity = Vector3.Zero; | 1114 | Velocity = Vector3.Zero; |
1115 | AbsolutePosition = pos; | 1115 | AbsolutePosition = pos; |
1116 | AddToPhysicalScene(isFlying); | 1116 | AddToPhysicalScene(isFlying); |
1117 | if (m_appearance != null) | 1117 | if (m_appearance != null) |
1118 | { | 1118 | { |
1119 | if (m_appearance.AvatarHeight > 0) | 1119 | if (m_appearance.AvatarHeight > 0) |
1120 | SetHeight(m_appearance.AvatarHeight); | 1120 | SetHeight(m_appearance.AvatarHeight); |
1121 | } | 1121 | } |
1122 | 1122 | ||
1123 | SendTerseUpdateToAllClients(); | 1123 | SendTerseUpdateToAllClients(); |
1124 | 1124 | ||
1125 | } | 1125 | } |
1126 | 1126 | ||
1127 | public void TeleportWithMomentum(Vector3 pos) | 1127 | public void TeleportWithMomentum(Vector3 pos) |
1128 | { | 1128 | { |
1129 | bool isFlying = false; | 1129 | bool isFlying = false; |
1130 | if (m_physicsActor != null) | 1130 | if (m_physicsActor != null) |
1131 | isFlying = m_physicsActor.Flying; | 1131 | isFlying = m_physicsActor.Flying; |
1132 | 1132 | ||
1133 | RemoveFromPhysicalScene(); | 1133 | RemoveFromPhysicalScene(); |
1134 | AbsolutePosition = pos; | 1134 | AbsolutePosition = pos; |
1135 | AddToPhysicalScene(isFlying); | 1135 | AddToPhysicalScene(isFlying); |
1136 | if (m_appearance != null) | 1136 | if (m_appearance != null) |
1137 | { | 1137 | { |
1138 | if (m_appearance.AvatarHeight > 0) | 1138 | if (m_appearance.AvatarHeight > 0) |
1139 | SetHeight(m_appearance.AvatarHeight); | 1139 | SetHeight(m_appearance.AvatarHeight); |
1140 | } | 1140 | } |
1141 | 1141 | ||
1142 | SendTerseUpdateToAllClients(); | 1142 | SendTerseUpdateToAllClients(); |
1143 | } | 1143 | } |
1144 | 1144 | ||
1145 | /// <summary> | 1145 | /// <summary> |
1146 | /// | 1146 | /// |
1147 | /// </summary> | 1147 | /// </summary> |
1148 | public void StopMovement() | 1148 | public void StopMovement() |
1149 | { | 1149 | { |
1150 | } | 1150 | } |
1151 | 1151 | ||
1152 | public void StopFlying() | 1152 | public void StopFlying() |
1153 | { | 1153 | { |
1154 | ControllingClient.StopFlying(this); | 1154 | ControllingClient.StopFlying(this); |
1155 | } | 1155 | } |
1156 | 1156 | ||
1157 | public void AddNeighbourRegion(ulong regionHandle, string cap) | 1157 | public void AddNeighbourRegion(ulong regionHandle, string cap) |
1158 | { | 1158 | { |
1159 | lock (m_knownChildRegions) | 1159 | lock (m_knownChildRegions) |
1160 | { | 1160 | { |
1161 | if (!m_knownChildRegions.ContainsKey(regionHandle)) | 1161 | if (!m_knownChildRegions.ContainsKey(regionHandle)) |
1162 | { | 1162 | { |
1163 | uint x, y; | 1163 | uint x, y; |
1164 | Utils.LongToUInts(regionHandle, out x, out y); | 1164 | Utils.LongToUInts(regionHandle, out x, out y); |
1165 | m_knownChildRegions.Add(regionHandle, cap); | 1165 | m_knownChildRegions.Add(regionHandle, cap); |
1166 | } | 1166 | } |
1167 | } | 1167 | } |
1168 | } | 1168 | } |
1169 | 1169 | ||
1170 | public void RemoveNeighbourRegion(ulong regionHandle) | 1170 | public void RemoveNeighbourRegion(ulong regionHandle) |
1171 | { | 1171 | { |
1172 | lock (m_knownChildRegions) | 1172 | lock (m_knownChildRegions) |
1173 | { | 1173 | { |
1174 | if (m_knownChildRegions.ContainsKey(regionHandle)) | 1174 | if (m_knownChildRegions.ContainsKey(regionHandle)) |
1175 | { | 1175 | { |
1176 | m_knownChildRegions.Remove(regionHandle); | 1176 | m_knownChildRegions.Remove(regionHandle); |
1177 | //m_log.Debug(" !!! removing known region {0} in {1}. Count = {2}", regionHandle, Scene.RegionInfo.RegionName, m_knownChildRegions.Count); | 1177 | //m_log.Debug(" !!! removing known region {0} in {1}. Count = {2}", regionHandle, Scene.RegionInfo.RegionName, m_knownChildRegions.Count); |
1178 | } | 1178 | } |
1179 | } | 1179 | } |
1180 | } | 1180 | } |
1181 | 1181 | ||
1182 | public void DropOldNeighbours(List<ulong> oldRegions) | 1182 | public void DropOldNeighbours(List<ulong> oldRegions) |
1183 | { | 1183 | { |
1184 | foreach (ulong handle in oldRegions) | 1184 | foreach (ulong handle in oldRegions) |
1185 | { | 1185 | { |
1186 | RemoveNeighbourRegion(handle); | 1186 | RemoveNeighbourRegion(handle); |
1187 | Scene.CapsModule.DropChildSeed(UUID, handle); | 1187 | Scene.CapsModule.DropChildSeed(UUID, handle); |
1188 | } | 1188 | } |
1189 | } | 1189 | } |
1190 | 1190 | ||
1191 | public List<ulong> GetKnownRegionList() | 1191 | public List<ulong> GetKnownRegionList() |
1192 | { | 1192 | { |
1193 | return new List<ulong>(m_knownChildRegions.Keys); | 1193 | return new List<ulong>(m_knownChildRegions.Keys); |
1194 | } | 1194 | } |
1195 | 1195 | ||
1196 | #endregion | 1196 | #endregion |
1197 | 1197 | ||
1198 | #region Event Handlers | 1198 | #region Event Handlers |
1199 | 1199 | ||
1200 | /// <summary> | 1200 | /// <summary> |
1201 | /// Sets avatar height in the phyiscs plugin | 1201 | /// Sets avatar height in the phyiscs plugin |
1202 | /// </summary> | 1202 | /// </summary> |
1203 | internal void SetHeight(float height) | 1203 | internal void SetHeight(float height) |
1204 | { | 1204 | { |
1205 | m_avHeight = height; | 1205 | m_avHeight = height; |
1206 | if (PhysicsActor != null && !IsChildAgent) | 1206 | if (PhysicsActor != null && !IsChildAgent) |
1207 | { | 1207 | { |
1208 | Vector3 SetSize = new Vector3(0.45f, 0.6f, m_avHeight); | 1208 | Vector3 SetSize = new Vector3(0.45f, 0.6f, m_avHeight); |
1209 | PhysicsActor.Size = SetSize; | 1209 | PhysicsActor.Size = SetSize; |
1210 | } | 1210 | } |
1211 | } | 1211 | } |
1212 | 1212 | ||
1213 | /// <summary> | 1213 | /// <summary> |
1214 | /// Complete Avatar's movement into the region. | 1214 | /// Complete Avatar's movement into the region. |
1215 | /// This is called upon a very important packet sent from the client, | 1215 | /// This is called upon a very important packet sent from the client, |
1216 | /// so it's client-controlled. Never call this method directly. | 1216 | /// so it's client-controlled. Never call this method directly. |
1217 | /// </summary> | 1217 | /// </summary> |
1218 | public void CompleteMovement(IClientAPI client) | 1218 | public void CompleteMovement(IClientAPI client) |
1219 | { | 1219 | { |
1220 | //m_log.Debug("[SCENE PRESENCE]: CompleteMovement"); | 1220 | //m_log.Debug("[SCENE PRESENCE]: CompleteMovement"); |
1221 | 1221 | ||
1222 | Vector3 look = Velocity; | 1222 | Vector3 look = Velocity; |
1223 | if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) | 1223 | if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) |
1224 | { | 1224 | { |
1225 | look = new Vector3(0.99f, 0.042f, 0); | 1225 | look = new Vector3(0.99f, 0.042f, 0); |
1226 | } | 1226 | } |
1227 | 1227 | ||
1228 | // Prevent teleporting to an underground location | 1228 | // Prevent teleporting to an underground location |
1229 | // (may crash client otherwise) | 1229 | // (may crash client otherwise) |
1230 | // | 1230 | // |
1231 | Vector3 pos = AbsolutePosition; | 1231 | Vector3 pos = AbsolutePosition; |
1232 | float ground = m_scene.GetGroundHeight(pos.X, pos.Y); | 1232 | float ground = m_scene.GetGroundHeight(pos.X, pos.Y); |
1233 | if (pos.Z < ground + 1.5f) | 1233 | if (pos.Z < ground + 1.5f) |
1234 | { | 1234 | { |
1235 | pos.Z = ground + 1.5f; | 1235 | pos.Z = ground + 1.5f; |
1236 | AbsolutePosition = pos; | 1236 | AbsolutePosition = pos; |
1237 | } | 1237 | } |
1238 | m_isChildAgent = false; | 1238 | m_isChildAgent = false; |
1239 | bool m_flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); | 1239 | bool m_flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); |
1240 | MakeRootAgent(AbsolutePosition, m_flying); | 1240 | MakeRootAgent(AbsolutePosition, m_flying); |
1241 | 1241 | ||
1242 | if ((m_callbackURI != null) && !m_callbackURI.Equals("")) | 1242 | if ((m_callbackURI != null) && !m_callbackURI.Equals("")) |
1243 | { | 1243 | { |
1244 | m_log.DebugFormat("[SCENE PRESENCE]: Releasing agent in URI {0}", m_callbackURI); | 1244 | m_log.DebugFormat("[SCENE PRESENCE]: Releasing agent in URI {0}", m_callbackURI); |
1245 | Scene.SimulationService.ReleaseAgent(m_originRegionID, UUID, m_callbackURI); | 1245 | Scene.SimulationService.ReleaseAgent(m_originRegionID, UUID, m_callbackURI); |
1246 | m_callbackURI = null; | 1246 | m_callbackURI = null; |
1247 | } | 1247 | } |
1248 | 1248 | ||
1249 | //m_log.DebugFormat("Completed movement"); | 1249 | //m_log.DebugFormat("Completed movement"); |
1250 | 1250 | ||
1251 | m_controllingClient.MoveAgentIntoRegion(m_regionInfo, AbsolutePosition, look); | 1251 | m_controllingClient.MoveAgentIntoRegion(m_regionInfo, AbsolutePosition, look); |
1252 | SendInitialData(); | 1252 | SendInitialData(); |
1253 | 1253 | ||
1254 | // Create child agents in neighbouring regions | 1254 | // Create child agents in neighbouring regions |
1255 | if (!m_isChildAgent) | 1255 | if (!m_isChildAgent) |
1256 | { | 1256 | { |
1257 | IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>(); | 1257 | IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>(); |
1258 | if (m_agentTransfer != null) | 1258 | if (m_agentTransfer != null) |
1259 | m_agentTransfer.EnableChildAgents(this); | 1259 | m_agentTransfer.EnableChildAgents(this); |
1260 | else | 1260 | else |
1261 | m_log.DebugFormat("[SCENE PRESENCE]: Unable to create child agents in neighbours, because AgentTransferModule is not active"); | 1261 | m_log.DebugFormat("[SCENE PRESENCE]: Unable to create child agents in neighbours, because AgentTransferModule is not active"); |
1262 | 1262 | ||
1263 | IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>(); | 1263 | IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>(); |
1264 | if (friendsModule != null) | 1264 | if (friendsModule != null) |
1265 | friendsModule.SendFriendsOnlineIfNeeded(ControllingClient); | 1265 | friendsModule.SendFriendsOnlineIfNeeded(ControllingClient); |
1266 | } | 1266 | } |
1267 | 1267 | ||
1268 | } | 1268 | } |
1269 | 1269 | ||
1270 | /// <summary> | 1270 | /// <summary> |
1271 | /// Callback for the Camera view block check. Gets called with the results of the camera view block test | 1271 | /// Callback for the Camera view block check. Gets called with the results of the camera view block test |
1272 | /// hitYN is true when there's something in the way. | 1272 | /// hitYN is true when there's something in the way. |
1273 | /// </summary> | 1273 | /// </summary> |
1274 | /// <param name="hitYN"></param> | 1274 | /// <param name="hitYN"></param> |
1275 | /// <param name="collisionPoint"></param> | 1275 | /// <param name="collisionPoint"></param> |
1276 | /// <param name="localid"></param> | 1276 | /// <param name="localid"></param> |
1277 | /// <param name="distance"></param> | 1277 | /// <param name="distance"></param> |
1278 | public void RayCastCameraCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 pNormal) | 1278 | public void RayCastCameraCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 pNormal) |
1279 | { | 1279 | { |
1280 | const float POSITION_TOLERANCE = 0.02f; | 1280 | const float POSITION_TOLERANCE = 0.02f; |
1281 | const float VELOCITY_TOLERANCE = 0.02f; | 1281 | const float VELOCITY_TOLERANCE = 0.02f; |
1282 | const float ROTATION_TOLERANCE = 0.02f; | 1282 | const float ROTATION_TOLERANCE = 0.02f; |
1283 | 1283 | ||
1284 | if (m_followCamAuto) | 1284 | if (m_followCamAuto) |
1285 | { | 1285 | { |
1286 | if (hitYN) | 1286 | if (hitYN) |
1287 | { | 1287 | { |
1288 | CameraConstraintActive = true; | 1288 | CameraConstraintActive = true; |
1289 | //m_log.DebugFormat("[RAYCASTRESULT]: {0}, {1}, {2}, {3}", hitYN, collisionPoint, localid, distance); | 1289 | //m_log.DebugFormat("[RAYCASTRESULT]: {0}, {1}, {2}, {3}", hitYN, collisionPoint, localid, distance); |
1290 | 1290 | ||
1291 | Vector3 normal = Vector3.Normalize(new Vector3(0f, 0f, collisionPoint.Z) - collisionPoint); | 1291 | Vector3 normal = Vector3.Normalize(new Vector3(0f, 0f, collisionPoint.Z) - collisionPoint); |
1292 | ControllingClient.SendCameraConstraint(new Vector4(normal.X, normal.Y, normal.Z, -1 * Vector3.Distance(new Vector3(0,0,collisionPoint.Z),collisionPoint))); | 1292 | ControllingClient.SendCameraConstraint(new Vector4(normal.X, normal.Y, normal.Z, -1 * Vector3.Distance(new Vector3(0,0,collisionPoint.Z),collisionPoint))); |
1293 | } | 1293 | } |
1294 | else | 1294 | else |
1295 | { | 1295 | { |
1296 | if (!m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || | 1296 | if (!m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || |
1297 | !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || | 1297 | !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || |
1298 | !m_bodyRot.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE)) | 1298 | !m_bodyRot.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE)) |
1299 | { | 1299 | { |
1300 | if (CameraConstraintActive) | 1300 | if (CameraConstraintActive) |
1301 | { | 1301 | { |
1302 | ControllingClient.SendCameraConstraint(new Vector4(0f, 0.5f, 0.9f, -3000f)); | 1302 | ControllingClient.SendCameraConstraint(new Vector4(0f, 0.5f, 0.9f, -3000f)); |
1303 | CameraConstraintActive = false; | 1303 | CameraConstraintActive = false; |
1304 | } | 1304 | } |
1305 | } | 1305 | } |
1306 | } | 1306 | } |
1307 | } | 1307 | } |
1308 | } | 1308 | } |
1309 | 1309 | ||
1310 | /// <summary> | 1310 | /// <summary> |
1311 | /// This is the event handler for client movement. If a client is moving, this event is triggering. | 1311 | /// This is the event handler for client movement. If a client is moving, this event is triggering. |
1312 | /// </summary> | 1312 | /// </summary> |
1313 | public void HandleAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData) | 1313 | public void HandleAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData) |
1314 | { | 1314 | { |
1315 | //if (m_isChildAgent) | 1315 | //if (m_isChildAgent) |
1316 | //{ | 1316 | //{ |
1317 | // // m_log.Debug("DEBUG: HandleAgentUpdate: child agent"); | 1317 | // // m_log.Debug("DEBUG: HandleAgentUpdate: child agent"); |
1318 | // return; | 1318 | // return; |
1319 | //} | 1319 | //} |
1320 | 1320 | ||
1321 | m_perfMonMS = Util.EnvironmentTickCount(); | 1321 | m_perfMonMS = Util.EnvironmentTickCount(); |
1322 | 1322 | ||
1323 | ++m_movementUpdateCount; | 1323 | ++m_movementUpdateCount; |
1324 | if (m_movementUpdateCount < 1) | 1324 | if (m_movementUpdateCount < 1) |
1325 | m_movementUpdateCount = 1; | 1325 | m_movementUpdateCount = 1; |
1326 | 1326 | ||
1327 | #region Sanity Checking | 1327 | #region Sanity Checking |
1328 | 1328 | ||
1329 | // This is irritating. Really. | 1329 | // This is irritating. Really. |
1330 | if (!AbsolutePosition.IsFinite()) | 1330 | if (!AbsolutePosition.IsFinite()) |
1331 | { | 1331 | { |
1332 | RemoveFromPhysicalScene(); | 1332 | RemoveFromPhysicalScene(); |
1333 | m_log.Error("[AVATAR]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error #9999902"); | 1333 | m_log.Error("[AVATAR]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error #9999902"); |
1334 | 1334 | ||
1335 | m_pos = m_LastFinitePos; | 1335 | m_pos = m_LastFinitePos; |
1336 | 1336 | ||
1337 | if (!m_pos.IsFinite()) | 1337 | if (!m_pos.IsFinite()) |
1338 | { | 1338 | { |
1339 | m_pos.X = 127f; | 1339 | m_pos.X = 127f; |
1340 | m_pos.Y = 127f; | 1340 | m_pos.Y = 127f; |
1341 | m_pos.Z = 127f; | 1341 | m_pos.Z = 127f; |
1342 | m_log.Error("[AVATAR]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error #9999903"); | 1342 | m_log.Error("[AVATAR]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error #9999903"); |
1343 | } | 1343 | } |
1344 | 1344 | ||
1345 | AddToPhysicalScene(false); | 1345 | AddToPhysicalScene(false); |
1346 | } | 1346 | } |
1347 | else | 1347 | else |
1348 | { | 1348 | { |
1349 | m_LastFinitePos = m_pos; | 1349 | m_LastFinitePos = m_pos; |
1350 | } | 1350 | } |
1351 | 1351 | ||
1352 | #endregion Sanity Checking | 1352 | #endregion Sanity Checking |
1353 | 1353 | ||
1354 | #region Inputs | 1354 | #region Inputs |
1355 | 1355 | ||
1356 | AgentManager.ControlFlags flags = (AgentManager.ControlFlags)agentData.ControlFlags; | 1356 | AgentManager.ControlFlags flags = (AgentManager.ControlFlags)agentData.ControlFlags; |
1357 | Quaternion bodyRotation = agentData.BodyRotation; | 1357 | Quaternion bodyRotation = agentData.BodyRotation; |
1358 | 1358 | ||
1359 | // Camera location in world. We'll need to raytrace | 1359 | // Camera location in world. We'll need to raytrace |
1360 | // from this location from time to time. | 1360 | // from this location from time to time. |
1361 | m_CameraCenter = agentData.CameraCenter; | 1361 | m_CameraCenter = agentData.CameraCenter; |
1362 | if (Vector3.Distance(m_lastCameraCenter, m_CameraCenter) >= Scene.RootReprioritizationDistance) | 1362 | if (Vector3.Distance(m_lastCameraCenter, m_CameraCenter) >= Scene.RootReprioritizationDistance) |
1363 | { | 1363 | { |
1364 | ReprioritizeUpdates(); | 1364 | ReprioritizeUpdates(); |
1365 | m_lastCameraCenter = m_CameraCenter; | 1365 | m_lastCameraCenter = m_CameraCenter; |
1366 | } | 1366 | } |
1367 | 1367 | ||
1368 | // Use these three vectors to figure out what the agent is looking at | 1368 | // Use these three vectors to figure out what the agent is looking at |
1369 | // Convert it to a Matrix and/or Quaternion | 1369 | // Convert it to a Matrix and/or Quaternion |
1370 | m_CameraAtAxis = agentData.CameraAtAxis; | 1370 | m_CameraAtAxis = agentData.CameraAtAxis; |
1371 | m_CameraLeftAxis = agentData.CameraLeftAxis; | 1371 | m_CameraLeftAxis = agentData.CameraLeftAxis; |
1372 | m_CameraUpAxis = agentData.CameraUpAxis; | 1372 | m_CameraUpAxis = agentData.CameraUpAxis; |
1373 | 1373 | ||
1374 | // The Agent's Draw distance setting | 1374 | // The Agent's Draw distance setting |
1375 | m_DrawDistance = agentData.Far; | 1375 | m_DrawDistance = agentData.Far; |
1376 | 1376 | ||
1377 | // Check if Client has camera in 'follow cam' or 'build' mode. | 1377 | // Check if Client has camera in 'follow cam' or 'build' mode. |
1378 | Vector3 camdif = (Vector3.One * m_bodyRot - Vector3.One * CameraRotation); | 1378 | Vector3 camdif = (Vector3.One * m_bodyRot - Vector3.One * CameraRotation); |
1379 | 1379 | ||
1380 | m_followCamAuto = ((m_CameraUpAxis.Z > 0.959f && m_CameraUpAxis.Z < 0.98f) | 1380 | m_followCamAuto = ((m_CameraUpAxis.Z > 0.959f && m_CameraUpAxis.Z < 0.98f) |
1381 | && (Math.Abs(camdif.X) < 0.4f && Math.Abs(camdif.Y) < 0.4f)) ? true : false; | 1381 | && (Math.Abs(camdif.X) < 0.4f && Math.Abs(camdif.Y) < 0.4f)) ? true : false; |
1382 | 1382 | ||
1383 | m_mouseLook = (flags & AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0; | 1383 | m_mouseLook = (flags & AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0; |
1384 | m_leftButtonDown = (flags & AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0; | 1384 | m_leftButtonDown = (flags & AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0; |
1385 | 1385 | ||
1386 | #endregion Inputs | 1386 | #endregion Inputs |
1387 | 1387 | ||
1388 | if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_STAND_UP) != 0) | 1388 | if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_STAND_UP) != 0) |
1389 | { | 1389 | { |
1390 | StandUp(); | 1390 | StandUp(); |
1391 | } | 1391 | } |
1392 | 1392 | ||
1393 | //m_log.DebugFormat("[FollowCam]: {0}", m_followCamAuto); | 1393 | //m_log.DebugFormat("[FollowCam]: {0}", m_followCamAuto); |
1394 | // Raycast from the avatar's head to the camera to see if there's anything blocking the view | 1394 | // Raycast from the avatar's head to the camera to see if there's anything blocking the view |
1395 | if ((m_movementUpdateCount % NumMovementsBetweenRayCast) == 0 && m_scene.PhysicsScene.SupportsRayCast()) | 1395 | if ((m_movementUpdateCount % NumMovementsBetweenRayCast) == 0 && m_scene.PhysicsScene.SupportsRayCast()) |
1396 | { | 1396 | { |
1397 | if (m_followCamAuto) | 1397 | if (m_followCamAuto) |
1398 | { | 1398 | { |
1399 | Vector3 posAdjusted = m_pos + HEAD_ADJUSTMENT; | 1399 | Vector3 posAdjusted = m_pos + HEAD_ADJUSTMENT; |
1400 | m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(m_CameraCenter - posAdjusted), Vector3.Distance(m_CameraCenter, posAdjusted) + 0.3f, RayCastCameraCallback); | 1400 | m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(m_CameraCenter - posAdjusted), Vector3.Distance(m_CameraCenter, posAdjusted) + 0.3f, RayCastCameraCallback); |
1401 | } | 1401 | } |
1402 | } | 1402 | } |
1403 | lock (scriptedcontrols) | 1403 | lock (scriptedcontrols) |
1404 | { | 1404 | { |
1405 | if (scriptedcontrols.Count > 0) | 1405 | if (scriptedcontrols.Count > 0) |
1406 | { | 1406 | { |
1407 | SendControlToScripts((uint)flags); | 1407 | SendControlToScripts((uint)flags); |
1408 | flags = RemoveIgnoredControls(flags, IgnoredControls); | 1408 | flags = RemoveIgnoredControls(flags, IgnoredControls); |
1409 | } | 1409 | } |
1410 | } | 1410 | } |
1411 | 1411 | ||
1412 | if (m_autopilotMoving) | 1412 | if (m_autopilotMoving) |
1413 | CheckAtSitTarget(); | 1413 | CheckAtSitTarget(); |
1414 | 1414 | ||
1415 | if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0) | 1415 | if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0) |
1416 | { | 1416 | { |
1417 | m_updateCount = 0; // Kill animation update burst so that the SIT_G.. will stick. | 1417 | m_updateCount = 0; // Kill animation update burst so that the SIT_G.. will stick. |
1418 | Animator.TrySetMovementAnimation("SIT_GROUND_CONSTRAINED"); | 1418 | Animator.TrySetMovementAnimation("SIT_GROUND_CONSTRAINED"); |
1419 | 1419 | ||
1420 | // TODO: This doesn't prevent the user from walking yet. | 1420 | // TODO: This doesn't prevent the user from walking yet. |
1421 | // Setting parent ID would fix this, if we knew what value | 1421 | // Setting parent ID would fix this, if we knew what value |
1422 | // to use. Or we could add a m_isSitting variable. | 1422 | // to use. Or we could add a m_isSitting variable. |
1423 | //Animator.TrySetMovementAnimation("SIT_GROUND_CONSTRAINED"); | 1423 | //Animator.TrySetMovementAnimation("SIT_GROUND_CONSTRAINED"); |
1424 | SitGround = true; | 1424 | SitGround = true; |
1425 | } | 1425 | } |
1426 | 1426 | ||
1427 | // In the future, these values might need to go global. | 1427 | // In the future, these values might need to go global. |
1428 | // Here's where you get them. | 1428 | // Here's where you get them. |
1429 | m_AgentControlFlags = flags; | 1429 | m_AgentControlFlags = flags; |
1430 | m_headrotation = agentData.HeadRotation; | 1430 | m_headrotation = agentData.HeadRotation; |
1431 | m_state = agentData.State; | 1431 | m_state = agentData.State; |
1432 | 1432 | ||
1433 | PhysicsActor actor = PhysicsActor; | 1433 | PhysicsActor actor = PhysicsActor; |
1434 | if (actor == null) | 1434 | if (actor == null) |
1435 | { | 1435 | { |
1436 | return; | 1436 | return; |
1437 | } | 1437 | } |
1438 | 1438 | ||
1439 | bool update_movementflag = false; | 1439 | bool update_movementflag = false; |
1440 | 1440 | ||
1441 | if (m_allowMovement && !SitGround) | 1441 | if (m_allowMovement && !SitGround) |
1442 | { | 1442 | { |
1443 | if (agentData.UseClientAgentPosition) | 1443 | if (agentData.UseClientAgentPosition) |
1444 | { | 1444 | { |
1445 | m_moveToPositionInProgress = (agentData.ClientAgentPosition - AbsolutePosition).Length() > 0.2f; | 1445 | m_moveToPositionInProgress = (agentData.ClientAgentPosition - AbsolutePosition).Length() > 0.2f; |
1446 | m_moveToPositionTarget = agentData.ClientAgentPosition; | 1446 | m_moveToPositionTarget = agentData.ClientAgentPosition; |
1447 | } | 1447 | } |
1448 | 1448 | ||
1449 | int i = 0; | 1449 | int i = 0; |
1450 | 1450 | ||
1451 | bool update_rotation = false; | 1451 | bool update_rotation = false; |
1452 | bool DCFlagKeyPressed = false; | 1452 | bool DCFlagKeyPressed = false; |
1453 | Vector3 agent_control_v3 = Vector3.Zero; | 1453 | Vector3 agent_control_v3 = Vector3.Zero; |
1454 | Quaternion q = bodyRotation; | 1454 | Quaternion q = bodyRotation; |
1455 | 1455 | ||
1456 | bool oldflying = PhysicsActor.Flying; | 1456 | bool oldflying = PhysicsActor.Flying; |
1457 | 1457 | ||
1458 | if (m_forceFly) | 1458 | if (m_forceFly) |
1459 | actor.Flying = true; | 1459 | actor.Flying = true; |
1460 | else if (m_flyDisabled) | 1460 | else if (m_flyDisabled) |
1461 | actor.Flying = false; | 1461 | actor.Flying = false; |
1462 | else | 1462 | else |
1463 | actor.Flying = ((flags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); | 1463 | actor.Flying = ((flags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); |
1464 | 1464 | ||
1465 | if (actor.Flying != oldflying) | 1465 | if (actor.Flying != oldflying) |
1466 | update_movementflag = true; | 1466 | update_movementflag = true; |
1467 | 1467 | ||
1468 | if (q != m_bodyRot) | 1468 | if (q != m_bodyRot) |
1469 | { | 1469 | { |
1470 | m_bodyRot = q; | 1470 | m_bodyRot = q; |
1471 | update_rotation = true; | 1471 | update_rotation = true; |
1472 | } | 1472 | } |
1473 | 1473 | ||
1474 | //guilty until proven innocent.. | 1474 | //guilty until proven innocent.. |
1475 | bool Nudging = true; | 1475 | bool Nudging = true; |
1476 | //Basically, if there is at least one non-nudge control then we don't need | 1476 | //Basically, if there is at least one non-nudge control then we don't need |
1477 | //to worry about stopping the avatar | 1477 | //to worry about stopping the avatar |
1478 | 1478 | ||
1479 | if (m_parentID == 0) | 1479 | if (m_parentID == 0) |
1480 | { | 1480 | { |
1481 | bool bAllowUpdateMoveToPosition = false; | 1481 | bool bAllowUpdateMoveToPosition = false; |
1482 | bool bResetMoveToPosition = false; | 1482 | bool bResetMoveToPosition = false; |
1483 | 1483 | ||
1484 | Vector3[] dirVectors; | 1484 | Vector3[] dirVectors; |
1485 | 1485 | ||
1486 | // use camera up angle when in mouselook and not flying or when holding the left mouse button down and not flying | 1486 | // use camera up angle when in mouselook and not flying or when holding the left mouse button down and not flying |
1487 | // this prevents 'jumping' in inappropriate situations. | 1487 | // this prevents 'jumping' in inappropriate situations. |
1488 | if ((m_mouseLook && !m_physicsActor.Flying) || (m_leftButtonDown && !m_physicsActor.Flying)) | 1488 | if ((m_mouseLook && !m_physicsActor.Flying) || (m_leftButtonDown && !m_physicsActor.Flying)) |
1489 | dirVectors = GetWalkDirectionVectors(); | 1489 | dirVectors = GetWalkDirectionVectors(); |
1490 | else | 1490 | else |
1491 | dirVectors = Dir_Vectors; | 1491 | dirVectors = Dir_Vectors; |
1492 | 1492 | ||
1493 | bool[] isNudge = GetDirectionIsNudge(); | 1493 | bool[] isNudge = GetDirectionIsNudge(); |
1494 | 1494 | ||
1495 | 1495 | ||
1496 | 1496 | ||
1497 | 1497 | ||
1498 | 1498 | ||
1499 | foreach (Dir_ControlFlags DCF in DIR_CONTROL_FLAGS) | 1499 | foreach (Dir_ControlFlags DCF in DIR_CONTROL_FLAGS) |
1500 | { | 1500 | { |
1501 | if (((uint)flags & (uint)DCF) != 0) | 1501 | if (((uint)flags & (uint)DCF) != 0) |
1502 | { | 1502 | { |
1503 | bResetMoveToPosition = true; | 1503 | bResetMoveToPosition = true; |
1504 | DCFlagKeyPressed = true; | 1504 | DCFlagKeyPressed = true; |
1505 | try | 1505 | try |
1506 | { | 1506 | { |
1507 | agent_control_v3 += dirVectors[i]; | 1507 | agent_control_v3 += dirVectors[i]; |
1508 | if (isNudge[i] == false) | 1508 | if (isNudge[i] == false) |
1509 | { | 1509 | { |
1510 | Nudging = false; | 1510 | Nudging = false; |
1511 | } | 1511 | } |
1512 | } | 1512 | } |
1513 | catch (IndexOutOfRangeException) | 1513 | catch (IndexOutOfRangeException) |
1514 | { | 1514 | { |
1515 | // Why did I get this? | 1515 | // Why did I get this? |
1516 | } | 1516 | } |
1517 | 1517 | ||
1518 | if ((m_movementflag & (uint)DCF) == 0) | 1518 | if ((m_movementflag & (uint)DCF) == 0) |
1519 | { | 1519 | { |
1520 | m_movementflag += (byte)(uint)DCF; | 1520 | m_movementflag += (byte)(uint)DCF; |
1521 | update_movementflag = true; | 1521 | update_movementflag = true; |
1522 | } | 1522 | } |
1523 | } | 1523 | } |
1524 | else | 1524 | else |
1525 | { | 1525 | { |
1526 | if ((m_movementflag & (uint)DCF) != 0) | 1526 | if ((m_movementflag & (uint)DCF) != 0) |
1527 | { | 1527 | { |
1528 | m_movementflag -= (byte)(uint)DCF; | 1528 | m_movementflag -= (byte)(uint)DCF; |
1529 | update_movementflag = true; | 1529 | update_movementflag = true; |
1530 | } | 1530 | } |
1531 | else | 1531 | else |
1532 | { | 1532 | { |
1533 | bAllowUpdateMoveToPosition = true; | 1533 | bAllowUpdateMoveToPosition = true; |
1534 | } | 1534 | } |
1535 | } | 1535 | } |
1536 | i++; | 1536 | i++; |
1537 | } | 1537 | } |
1538 | //Paupaw:Do Proper PID for Autopilot here | 1538 | //Paupaw:Do Proper PID for Autopilot here |
1539 | if (bResetMoveToPosition) | 1539 | if (bResetMoveToPosition) |
1540 | { | 1540 | { |
1541 | m_moveToPositionTarget = Vector3.Zero; | 1541 | m_moveToPositionTarget = Vector3.Zero; |
1542 | m_moveToPositionInProgress = false; | 1542 | m_moveToPositionInProgress = false; |
1543 | update_movementflag = true; | 1543 | update_movementflag = true; |
1544 | bAllowUpdateMoveToPosition = false; | 1544 | bAllowUpdateMoveToPosition = false; |
1545 | } | 1545 | } |
1546 | 1546 | ||
1547 | if (bAllowUpdateMoveToPosition && (m_moveToPositionInProgress && !m_autopilotMoving)) | 1547 | if (bAllowUpdateMoveToPosition && (m_moveToPositionInProgress && !m_autopilotMoving)) |
1548 | { | 1548 | { |
1549 | //Check the error term of the current position in relation to the target position | 1549 | //Check the error term of the current position in relation to the target position |
1550 | if (Util.GetDistanceTo(AbsolutePosition, m_moveToPositionTarget) <= 0.5f) | 1550 | if (Util.GetDistanceTo(AbsolutePosition, m_moveToPositionTarget) <= 0.5f) |
1551 | { | 1551 | { |
1552 | // we are close enough to the target | 1552 | // we are close enough to the target |
1553 | m_moveToPositionTarget = Vector3.Zero; | 1553 | m_moveToPositionTarget = Vector3.Zero; |
1554 | m_moveToPositionInProgress = false; | 1554 | m_moveToPositionInProgress = false; |
1555 | update_movementflag = true; | 1555 | update_movementflag = true; |
1556 | } | 1556 | } |
1557 | else | 1557 | else |
1558 | { | 1558 | { |
1559 | try | 1559 | try |
1560 | { | 1560 | { |
1561 | // move avatar in 2D at one meter/second towards target, in avatar coordinate frame. | 1561 | // move avatar in 2D at one meter/second towards target, in avatar coordinate frame. |
1562 | // This movement vector gets added to the velocity through AddNewMovement(). | 1562 | // This movement vector gets added to the velocity through AddNewMovement(). |
1563 | // Theoretically we might need a more complex PID approach here if other | 1563 | // Theoretically we might need a more complex PID approach here if other |
1564 | // unknown forces are acting on the avatar and we need to adaptively respond | 1564 | // unknown forces are acting on the avatar and we need to adaptively respond |
1565 | // to such forces, but the following simple approach seems to works fine. | 1565 | // to such forces, but the following simple approach seems to works fine. |
1566 | Vector3 LocalVectorToTarget3D = | 1566 | Vector3 LocalVectorToTarget3D = |
1567 | (m_moveToPositionTarget - AbsolutePosition) // vector from cur. pos to target in global coords | 1567 | (m_moveToPositionTarget - AbsolutePosition) // vector from cur. pos to target in global coords |
1568 | * Matrix4.CreateFromQuaternion(Quaternion.Inverse(bodyRotation)); // change to avatar coords | 1568 | * Matrix4.CreateFromQuaternion(Quaternion.Inverse(bodyRotation)); // change to avatar coords |
1569 | // Ignore z component of vector | 1569 | // Ignore z component of vector |
1570 | Vector3 LocalVectorToTarget2D = new Vector3((float)(LocalVectorToTarget3D.X), (float)(LocalVectorToTarget3D.Y), 0f); | 1570 | Vector3 LocalVectorToTarget2D = new Vector3((float)(LocalVectorToTarget3D.X), (float)(LocalVectorToTarget3D.Y), 0f); |
1571 | LocalVectorToTarget2D.Normalize(); | 1571 | LocalVectorToTarget2D.Normalize(); |
1572 | 1572 | ||
1573 | //We're not nudging | 1573 | //We're not nudging |
1574 | Nudging = false; | 1574 | Nudging = false; |
1575 | agent_control_v3 += LocalVectorToTarget2D; | 1575 | agent_control_v3 += LocalVectorToTarget2D; |
1576 | 1576 | ||
1577 | // update avatar movement flags. the avatar coordinate system is as follows: | 1577 | // update avatar movement flags. the avatar coordinate system is as follows: |
1578 | // | 1578 | // |
1579 | // +X (forward) | 1579 | // +X (forward) |
1580 | // | 1580 | // |
1581 | // ^ | 1581 | // ^ |
1582 | // | | 1582 | // | |
1583 | // | | 1583 | // | |
1584 | // | | 1584 | // | |
1585 | // | | 1585 | // | |
1586 | // (left) +Y <--------o--------> -Y | 1586 | // (left) +Y <--------o--------> -Y |
1587 | // avatar | 1587 | // avatar |
1588 | // | | 1588 | // | |
1589 | // | | 1589 | // | |
1590 | // | | 1590 | // | |
1591 | // | | 1591 | // | |
1592 | // v | 1592 | // v |
1593 | // -X | 1593 | // -X |
1594 | // | 1594 | // |
1595 | 1595 | ||
1596 | // based on the above avatar coordinate system, classify the movement into | 1596 | // based on the above avatar coordinate system, classify the movement into |
1597 | // one of left/right/back/forward. | 1597 | // one of left/right/back/forward. |
1598 | if (LocalVectorToTarget2D.Y > 0)//MoveLeft | 1598 | if (LocalVectorToTarget2D.Y > 0)//MoveLeft |
1599 | { | 1599 | { |
1600 | m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT; | 1600 | m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT; |
1601 | //AgentControlFlags | 1601 | //AgentControlFlags |
1602 | AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT; | 1602 | AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT; |
1603 | update_movementflag = true; | 1603 | update_movementflag = true; |
1604 | } | 1604 | } |
1605 | else if (LocalVectorToTarget2D.Y < 0) //MoveRight | 1605 | else if (LocalVectorToTarget2D.Y < 0) //MoveRight |
1606 | { | 1606 | { |
1607 | m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT; | 1607 | m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT; |
1608 | AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT; | 1608 | AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT; |
1609 | update_movementflag = true; | 1609 | update_movementflag = true; |
1610 | } | 1610 | } |
1611 | if (LocalVectorToTarget2D.X < 0) //MoveBack | 1611 | if (LocalVectorToTarget2D.X < 0) //MoveBack |
1612 | { | 1612 | { |
1613 | m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_BACK; | 1613 | m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_BACK; |
1614 | AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_BACK; | 1614 | AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_BACK; |
1615 | update_movementflag = true; | 1615 | update_movementflag = true; |
1616 | } | 1616 | } |
1617 | else if (LocalVectorToTarget2D.X > 0) //Move Forward | 1617 | else if (LocalVectorToTarget2D.X > 0) //Move Forward |
1618 | { | 1618 | { |
1619 | m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD; | 1619 | m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD; |
1620 | AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD; | 1620 | AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD; |
1621 | update_movementflag = true; | 1621 | update_movementflag = true; |
1622 | } | 1622 | } |
1623 | } | 1623 | } |
1624 | catch (Exception e) | 1624 | catch (Exception e) |
1625 | { | 1625 | { |
1626 | //Avoid system crash, can be slower but... | 1626 | //Avoid system crash, can be slower but... |
1627 | m_log.DebugFormat("Crash! {0}", e.ToString()); | 1627 | m_log.DebugFormat("Crash! {0}", e.ToString()); |
1628 | } | 1628 | } |
1629 | } | 1629 | } |
1630 | } | 1630 | } |
1631 | } | 1631 | } |
1632 | 1632 | ||
1633 | // Cause the avatar to stop flying if it's colliding | 1633 | // Cause the avatar to stop flying if it's colliding |
1634 | // with something with the down arrow pressed. | 1634 | // with something with the down arrow pressed. |
1635 | 1635 | ||
1636 | // Only do this if we're flying | 1636 | // Only do this if we're flying |
1637 | if (m_physicsActor != null && m_physicsActor.Flying && !m_forceFly) | 1637 | if (m_physicsActor != null && m_physicsActor.Flying && !m_forceFly) |
1638 | { | 1638 | { |
1639 | // Landing detection code | 1639 | // Landing detection code |
1640 | 1640 | ||
1641 | // Are the landing controls requirements filled? | 1641 | // Are the landing controls requirements filled? |
1642 | bool controlland = (((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || | 1642 | bool controlland = (((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || |
1643 | ((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); | 1643 | ((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); |
1644 | 1644 | ||
1645 | // Are the collision requirements fulfilled? | 1645 | // Are the collision requirements fulfilled? |
1646 | bool colliding = (m_physicsActor.IsColliding == true); | 1646 | bool colliding = (m_physicsActor.IsColliding == true); |
1647 | 1647 | ||
1648 | if (m_physicsActor.Flying && colliding && controlland) | 1648 | if (m_physicsActor.Flying && colliding && controlland) |
1649 | { | 1649 | { |
1650 | // nesting this check because LengthSquared() is expensive and we don't | 1650 | // nesting this check because LengthSquared() is expensive and we don't |
1651 | // want to do it every step when flying. | 1651 | // want to do it every step when flying. |
1652 | if ((Velocity.LengthSquared() <= LAND_VELOCITYMAG_MAX)) | 1652 | if ((Velocity.LengthSquared() <= LAND_VELOCITYMAG_MAX)) |
1653 | StopFlying(); | 1653 | StopFlying(); |
1654 | } | 1654 | } |
1655 | } | 1655 | } |
1656 | 1656 | ||
1657 | if (update_movementflag || (update_rotation && DCFlagKeyPressed)) | 1657 | if (update_movementflag || (update_rotation && DCFlagKeyPressed)) |
1658 | { | 1658 | { |
1659 | // m_log.DebugFormat("{0} {1}", update_movementflag, (update_rotation && DCFlagKeyPressed)); | 1659 | // m_log.DebugFormat("{0} {1}", update_movementflag, (update_rotation && DCFlagKeyPressed)); |
1660 | // m_log.DebugFormat( | 1660 | // m_log.DebugFormat( |
1661 | // "In {0} adding velocity to {1} of {2}", m_scene.RegionInfo.RegionName, Name, agent_control_v3); | 1661 | // "In {0} adding velocity to {1} of {2}", m_scene.RegionInfo.RegionName, Name, agent_control_v3); |
1662 | 1662 | ||
1663 | AddNewMovement(agent_control_v3, q, Nudging); | 1663 | AddNewMovement(agent_control_v3, q, Nudging); |
1664 | 1664 | ||
1665 | 1665 | ||
1666 | } | 1666 | } |
1667 | } | 1667 | } |
1668 | 1668 | ||
1669 | if (update_movementflag && !SitGround) | 1669 | if (update_movementflag && !SitGround) |
1670 | Animator.UpdateMovementAnimations(); | 1670 | Animator.UpdateMovementAnimations(); |
1671 | 1671 | ||
1672 | m_scene.EventManager.TriggerOnClientMovement(this); | 1672 | m_scene.EventManager.TriggerOnClientMovement(this); |
1673 | 1673 | ||
1674 | m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); | 1674 | m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); |
1675 | } | 1675 | } |
1676 | 1676 | ||
1677 | public void DoAutoPilot(uint not_used, Vector3 Pos, IClientAPI remote_client) | 1677 | public void DoAutoPilot(uint not_used, Vector3 Pos, IClientAPI remote_client) |
1678 | { | 1678 | { |
1679 | m_autopilotMoving = true; | 1679 | m_autopilotMoving = true; |
1680 | m_autoPilotTarget = Pos; | 1680 | m_autoPilotTarget = Pos; |
1681 | m_sitAtAutoTarget = false; | 1681 | m_sitAtAutoTarget = false; |
1682 | PrimitiveBaseShape proxy = PrimitiveBaseShape.Default; | 1682 | PrimitiveBaseShape proxy = PrimitiveBaseShape.Default; |
1683 | //proxy.PCode = (byte)PCode.ParticleSystem; | 1683 | //proxy.PCode = (byte)PCode.ParticleSystem; |
1684 | proxyObjectGroup = new SceneObjectGroup(UUID, Pos, Rotation, proxy); | 1684 | proxyObjectGroup = new SceneObjectGroup(UUID, Pos, Rotation, proxy); |
1685 | proxyObjectGroup.AttachToScene(m_scene); | 1685 | proxyObjectGroup.AttachToScene(m_scene); |
1686 | 1686 | ||
1687 | // Commented out this code since it could never have executed, but might still be informative. | 1687 | // Commented out this code since it could never have executed, but might still be informative. |
1688 | // if (proxyObjectGroup != null) | 1688 | // if (proxyObjectGroup != null) |
1689 | // { | 1689 | // { |
1690 | proxyObjectGroup.SendGroupFullUpdate(); | 1690 | proxyObjectGroup.SendGroupFullUpdate(); |
1691 | remote_client.SendSitResponse(proxyObjectGroup.UUID, Vector3.Zero, Quaternion.Identity, true, Vector3.Zero, Vector3.Zero, false); | 1691 | remote_client.SendSitResponse(proxyObjectGroup.UUID, Vector3.Zero, Quaternion.Identity, true, Vector3.Zero, Vector3.Zero, false); |
1692 | m_scene.DeleteSceneObject(proxyObjectGroup, false); | 1692 | m_scene.DeleteSceneObject(proxyObjectGroup, false); |
1693 | // } | 1693 | // } |
1694 | // else | 1694 | // else |
1695 | // { | 1695 | // { |
1696 | // m_autopilotMoving = false; | 1696 | // m_autopilotMoving = false; |
1697 | // m_autoPilotTarget = Vector3.Zero; | 1697 | // m_autoPilotTarget = Vector3.Zero; |
1698 | // ControllingClient.SendAlertMessage("Autopilot cancelled"); | 1698 | // ControllingClient.SendAlertMessage("Autopilot cancelled"); |
1699 | // } | 1699 | // } |
1700 | } | 1700 | } |
1701 | 1701 | ||
1702 | public void DoMoveToPosition(Object sender, string method, List<String> args) | 1702 | public void DoMoveToPosition(Object sender, string method, List<String> args) |
1703 | { | 1703 | { |
1704 | try | 1704 | try |
1705 | { | 1705 | { |
1706 | float locx = 0f; | 1706 | float locx = 0f; |
1707 | float locy = 0f; | 1707 | float locy = 0f; |
1708 | float locz = 0f; | 1708 | float locz = 0f; |
1709 | uint regionX = 0; | 1709 | uint regionX = 0; |
1710 | uint regionY = 0; | 1710 | uint regionY = 0; |
1711 | try | 1711 | try |
1712 | { | 1712 | { |
1713 | Utils.LongToUInts(Scene.RegionInfo.RegionHandle, out regionX, out regionY); | 1713 | Utils.LongToUInts(Scene.RegionInfo.RegionHandle, out regionX, out regionY); |
1714 | locx = Convert.ToSingle(args[0]) - (float)regionX; | 1714 | locx = Convert.ToSingle(args[0]) - (float)regionX; |
1715 | locy = Convert.ToSingle(args[1]) - (float)regionY; | 1715 | locy = Convert.ToSingle(args[1]) - (float)regionY; |
1716 | locz = Convert.ToSingle(args[2]); | 1716 | locz = Convert.ToSingle(args[2]); |
1717 | } | 1717 | } |
1718 | catch (InvalidCastException) | 1718 | catch (InvalidCastException) |
1719 | { | 1719 | { |
1720 | m_log.Error("[CLIENT]: Invalid autopilot request"); | 1720 | m_log.Error("[CLIENT]: Invalid autopilot request"); |
1721 | return; | 1721 | return; |
1722 | } | 1722 | } |
1723 | m_moveToPositionInProgress = true; | 1723 | m_moveToPositionInProgress = true; |
1724 | m_moveToPositionTarget = new Vector3(locx, locy, locz); | 1724 | m_moveToPositionTarget = new Vector3(locx, locy, locz); |
1725 | } | 1725 | } |
1726 | catch (Exception ex) | 1726 | catch (Exception ex) |
1727 | { | 1727 | { |
1728 | //Why did I get this error? | 1728 | //Why did I get this error? |
1729 | m_log.Error("[SCENEPRESENCE]: DoMoveToPosition" + ex); | 1729 | m_log.Error("[SCENEPRESENCE]: DoMoveToPosition" + ex); |
1730 | } | 1730 | } |
1731 | } | 1731 | } |
1732 | 1732 | ||
1733 | private void CheckAtSitTarget() | 1733 | private void CheckAtSitTarget() |
1734 | { | 1734 | { |
1735 | //m_log.Debug("[AUTOPILOT]: " + Util.GetDistanceTo(AbsolutePosition, m_autoPilotTarget).ToString()); | 1735 | //m_log.Debug("[AUTOPILOT]: " + Util.GetDistanceTo(AbsolutePosition, m_autoPilotTarget).ToString()); |
1736 | if (Util.GetDistanceTo(AbsolutePosition, m_autoPilotTarget) <= 1.5) | 1736 | if (Util.GetDistanceTo(AbsolutePosition, m_autoPilotTarget) <= 1.5) |
1737 | { | 1737 | { |
1738 | if (m_sitAtAutoTarget) | 1738 | if (m_sitAtAutoTarget) |
1739 | { | 1739 | { |
1740 | SceneObjectPart part = m_scene.GetSceneObjectPart(m_requestedSitTargetUUID); | 1740 | SceneObjectPart part = m_scene.GetSceneObjectPart(m_requestedSitTargetUUID); |
1741 | if (part != null) | 1741 | if (part != null) |
1742 | { | 1742 | { |
1743 | AbsolutePosition = part.AbsolutePosition; | 1743 | AbsolutePosition = part.AbsolutePosition; |
1744 | Velocity = Vector3.Zero; | 1744 | Velocity = Vector3.Zero; |
1745 | SendFullUpdateToAllClients(); | 1745 | SendFullUpdateToAllClients(); |
1746 | 1746 | ||
1747 | HandleAgentSit(ControllingClient, m_requestedSitTargetUUID); //KF ?? | 1747 | HandleAgentSit(ControllingClient, m_requestedSitTargetUUID); //KF ?? |
1748 | } | 1748 | } |
1749 | //ControllingClient.SendSitResponse(m_requestedSitTargetID, m_requestedSitOffset, Quaternion.Identity, false, Vector3.Zero, Vector3.Zero, false); | 1749 | //ControllingClient.SendSitResponse(m_requestedSitTargetID, m_requestedSitOffset, Quaternion.Identity, false, Vector3.Zero, Vector3.Zero, false); |
1750 | m_requestedSitTargetUUID = UUID.Zero; | 1750 | m_requestedSitTargetUUID = UUID.Zero; |
1751 | } | 1751 | } |
1752 | /* | 1752 | /* |
1753 | else | 1753 | else |
1754 | { | 1754 | { |
1755 | //ControllingClient.SendAlertMessage("Autopilot cancelled"); | 1755 | //ControllingClient.SendAlertMessage("Autopilot cancelled"); |
1756 | //SendTerseUpdateToAllClients(); | 1756 | //SendTerseUpdateToAllClients(); |
1757 | //PrimitiveBaseShape proxy = PrimitiveBaseShape.Default; | 1757 | //PrimitiveBaseShape proxy = PrimitiveBaseShape.Default; |
1758 | //proxy.PCode = (byte)PCode.ParticleSystem; | 1758 | //proxy.PCode = (byte)PCode.ParticleSystem; |
1759 | ////uint nextUUID = m_scene.NextLocalId; | 1759 | ////uint nextUUID = m_scene.NextLocalId; |
1760 | 1760 | ||
1761 | //proxyObjectGroup = new SceneObjectGroup(m_scene, m_scene.RegionInfo.RegionHandle, UUID, nextUUID, m_autoPilotTarget, Quaternion.Identity, proxy); | 1761 | //proxyObjectGroup = new SceneObjectGroup(m_scene, m_scene.RegionInfo.RegionHandle, UUID, nextUUID, m_autoPilotTarget, Quaternion.Identity, proxy); |
1762 | //if (proxyObjectGroup != null) | 1762 | //if (proxyObjectGroup != null) |
1763 | //{ | 1763 | //{ |
1764 | //proxyObjectGroup.SendGroupFullUpdate(); | 1764 | //proxyObjectGroup.SendGroupFullUpdate(); |
1765 | //ControllingClient.SendSitResponse(UUID.Zero, m_autoPilotTarget, Quaternion.Identity, true, Vector3.Zero, Vector3.Zero, false); | 1765 | //ControllingClient.SendSitResponse(UUID.Zero, m_autoPilotTarget, Quaternion.Identity, true, Vector3.Zero, Vector3.Zero, false); |
1766 | //m_scene.DeleteSceneObject(proxyObjectGroup); | 1766 | //m_scene.DeleteSceneObject(proxyObjectGroup); |
1767 | //} | 1767 | //} |
1768 | } | 1768 | } |
1769 | */ | 1769 | */ |
1770 | m_autoPilotTarget = Vector3.Zero; | 1770 | m_autoPilotTarget = Vector3.Zero; |
1771 | m_autopilotMoving = false; | 1771 | m_autopilotMoving = false; |
1772 | } | 1772 | } |
1773 | } | 1773 | } |
1774 | /// <summary> | 1774 | /// <summary> |
1775 | /// Perform the logic necessary to stand the avatar up. This method also executes | 1775 | /// Perform the logic necessary to stand the avatar up. This method also executes |
1776 | /// the stand animation. | 1776 | /// the stand animation. |
1777 | /// </summary> | 1777 | /// </summary> |
1778 | public void StandUp() | 1778 | public void StandUp() |
1779 | { | 1779 | { |
1780 | SitGround = false; | 1780 | SitGround = false; |
1781 | 1781 | ||
1782 | if (m_parentID != 0) | 1782 | if (m_parentID != 0) |
1783 | { | 1783 | { |
1784 | SceneObjectPart part = m_scene.GetSceneObjectPart(m_requestedSitTargetID); | 1784 | SceneObjectPart part = m_scene.GetSceneObjectPart(m_requestedSitTargetID); |
1785 | if (part != null) | 1785 | if (part != null) |
1786 | { | 1786 | { |
1787 | part.TaskInventory.LockItemsForRead(true); | 1787 | part.TaskInventory.LockItemsForRead(true); |
1788 | TaskInventoryDictionary taskIDict = part.TaskInventory; | 1788 | TaskInventoryDictionary taskIDict = part.TaskInventory; |
1789 | if (taskIDict != null) | 1789 | if (taskIDict != null) |
1790 | { | 1790 | { |
1791 | foreach (UUID taskID in taskIDict.Keys) | 1791 | foreach (UUID taskID in taskIDict.Keys) |
1792 | { | 1792 | { |
1793 | UnRegisterControlEventsToScript(LocalId, taskID); | 1793 | UnRegisterControlEventsToScript(LocalId, taskID); |
1794 | taskIDict[taskID].PermsMask &= ~( | 1794 | taskIDict[taskID].PermsMask &= ~( |
1795 | 2048 | //PERMISSION_CONTROL_CAMERA | 1795 | 2048 | //PERMISSION_CONTROL_CAMERA |
1796 | 4); // PERMISSION_TAKE_CONTROLS | 1796 | 4); // PERMISSION_TAKE_CONTROLS |
1797 | } | 1797 | } |
1798 | } | 1798 | } |
1799 | part.TaskInventory.LockItemsForRead(false); | 1799 | part.TaskInventory.LockItemsForRead(false); |
1800 | // Reset sit target. | 1800 | // Reset sit target. |
1801 | if (part.GetAvatarOnSitTarget() == UUID) | 1801 | if (part.GetAvatarOnSitTarget() == UUID) |
1802 | part.SetAvatarOnSitTarget(UUID.Zero); | 1802 | part.SetAvatarOnSitTarget(UUID.Zero); |
1803 | m_parentPosition = part.GetWorldPosition(); | 1803 | m_parentPosition = part.GetWorldPosition(); |
1804 | ControllingClient.SendClearFollowCamProperties(part.ParentUUID); | 1804 | ControllingClient.SendClearFollowCamProperties(part.ParentUUID); |
1805 | } | 1805 | } |
1806 | // part.GetWorldRotation() is the rotation of the object being sat on | 1806 | // part.GetWorldRotation() is the rotation of the object being sat on |
1807 | // Rotation is the sittiing Av's rotation | 1807 | // Rotation is the sittiing Av's rotation |
1808 | 1808 | ||
1809 | Quaternion partRot; | 1809 | Quaternion partRot; |
1810 | // if (part.LinkNum == 1) | 1810 | // if (part.LinkNum == 1) |
1811 | // { // Root prim of linkset | 1811 | // { // Root prim of linkset |
1812 | // partRot = part.ParentGroup.RootPart.RotationOffset; | 1812 | // partRot = part.ParentGroup.RootPart.RotationOffset; |
1813 | // } | 1813 | // } |
1814 | // else | 1814 | // else |
1815 | // { // single or child prim | 1815 | // { // single or child prim |
1816 | 1816 | ||
1817 | // } | 1817 | // } |
1818 | if (part == null) //CW: Part may be gone. llDie() for example. | 1818 | if (part == null) //CW: Part may be gone. llDie() for example. |
1819 | { | 1819 | { |
1820 | partRot = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); | 1820 | partRot = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); |
1821 | } | 1821 | } |
1822 | else | 1822 | else |
1823 | { | 1823 | { |
1824 | partRot = part.GetWorldRotation(); | 1824 | partRot = part.GetWorldRotation(); |
1825 | } | 1825 | } |
1826 | 1826 | ||
1827 | Quaternion partIRot = Quaternion.Inverse(partRot); | 1827 | Quaternion partIRot = Quaternion.Inverse(partRot); |
1828 | 1828 | ||
1829 | Quaternion avatarRot = Quaternion.Inverse(Quaternion.Inverse(Rotation) * partIRot); // world or. of the av | 1829 | Quaternion avatarRot = Quaternion.Inverse(Quaternion.Inverse(Rotation) * partIRot); // world or. of the av |
1830 | Vector3 avStandUp = new Vector3(1.0f, 0f, 0f) * avatarRot; // 1M infront of av | 1830 | Vector3 avStandUp = new Vector3(1.0f, 0f, 0f) * avatarRot; // 1M infront of av |
1831 | 1831 | ||
1832 | 1832 | ||
1833 | if (m_physicsActor == null) | 1833 | if (m_physicsActor == null) |
1834 | { | 1834 | { |
1835 | AddToPhysicalScene(false); | 1835 | AddToPhysicalScene(false); |
1836 | } | 1836 | } |
1837 | //CW: If the part isn't null then we can set the current position | 1837 | //CW: If the part isn't null then we can set the current position |
1838 | if (part != null) | 1838 | if (part != null) |
1839 | { | 1839 | { |
1840 | Vector3 avWorldStandUp = avStandUp + part.GetWorldPosition() + ((m_pos - part.OffsetPosition) * partRot); // + av sit offset! | 1840 | Vector3 avWorldStandUp = avStandUp + part.GetWorldPosition() + ((m_pos - part.OffsetPosition) * partRot); // + av sit offset! |
1841 | AbsolutePosition = avWorldStandUp; //KF: Fix stand up. | 1841 | AbsolutePosition = avWorldStandUp; //KF: Fix stand up. |
1842 | part.IsOccupied = false; | 1842 | part.IsOccupied = false; |
1843 | part.ParentGroup.DeleteAvatar(ControllingClient.AgentId); | 1843 | part.ParentGroup.DeleteAvatar(ControllingClient.AgentId); |
1844 | } | 1844 | } |
1845 | else | 1845 | else |
1846 | { | 1846 | { |
1847 | //CW: Since the part doesn't exist, a coarse standup position isn't an issue | 1847 | //CW: Since the part doesn't exist, a coarse standup position isn't an issue |
1848 | AbsolutePosition = m_lastWorldPosition; | 1848 | AbsolutePosition = m_lastWorldPosition; |
1849 | } | 1849 | } |
1850 | 1850 | ||
1851 | m_parentPosition = Vector3.Zero; | 1851 | m_parentPosition = Vector3.Zero; |
1852 | m_parentID = 0; | 1852 | m_parentID = 0; |
1853 | m_linkedPrim = UUID.Zero; | 1853 | m_linkedPrim = UUID.Zero; |
1854 | m_offsetRotation = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); | 1854 | m_offsetRotation = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); |
1855 | SendFullUpdateToAllClients(); | 1855 | SendFullUpdateToAllClients(); |
1856 | m_requestedSitTargetID = 0; | 1856 | m_requestedSitTargetID = 0; |
1857 | 1857 | ||
1858 | if ((m_physicsActor != null) && (m_avHeight > 0)) | 1858 | if ((m_physicsActor != null) && (m_avHeight > 0)) |
1859 | { | 1859 | { |
1860 | SetHeight(m_avHeight); | 1860 | SetHeight(m_avHeight); |
1861 | } | 1861 | } |
1862 | } | 1862 | } |
1863 | Animator.TrySetMovementAnimation("STAND"); | 1863 | Animator.TrySetMovementAnimation("STAND"); |
1864 | } | 1864 | } |
1865 | 1865 | ||
1866 | private SceneObjectPart FindNextAvailableSitTarget(UUID targetID) | 1866 | private SceneObjectPart FindNextAvailableSitTarget(UUID targetID) |
1867 | { | 1867 | { |
1868 | SceneObjectPart targetPart = m_scene.GetSceneObjectPart(targetID); | 1868 | SceneObjectPart targetPart = m_scene.GetSceneObjectPart(targetID); |
1869 | if (targetPart == null) | 1869 | if (targetPart == null) |
1870 | return null; | 1870 | return null; |
1871 | 1871 | ||
1872 | // If the primitive the player clicked on has a sit target and that sit target is not full, that sit target is used. | 1872 | // If the primitive the player clicked on has a sit target and that sit target is not full, that sit target is used. |
1873 | // If the primitive the player clicked on has no sit target, and one or more other linked objects have sit targets that are not full, the sit target of the object with the lowest link number will be used. | 1873 | // If the primitive the player clicked on has no sit target, and one or more other linked objects have sit targets that are not full, the sit target of the object with the lowest link number will be used. |
1874 | 1874 | ||
1875 | // Get our own copy of the part array, and sort into the order we want to test | 1875 | // Get our own copy of the part array, and sort into the order we want to test |
1876 | SceneObjectPart[] partArray = targetPart.ParentGroup.GetParts(); | 1876 | SceneObjectPart[] partArray = targetPart.ParentGroup.GetParts(); |
1877 | Array.Sort(partArray, delegate(SceneObjectPart p1, SceneObjectPart p2) | 1877 | Array.Sort(partArray, delegate(SceneObjectPart p1, SceneObjectPart p2) |
1878 | { | 1878 | { |
1879 | // we want the originally selected part first, then the rest in link order -- so make the selected part link num (-1) | 1879 | // we want the originally selected part first, then the rest in link order -- so make the selected part link num (-1) |
1880 | int linkNum1 = p1==targetPart ? -1 : p1.LinkNum; | 1880 | int linkNum1 = p1==targetPart ? -1 : p1.LinkNum; |
1881 | int linkNum2 = p2==targetPart ? -1 : p2.LinkNum; | 1881 | int linkNum2 = p2==targetPart ? -1 : p2.LinkNum; |
1882 | return linkNum1 - linkNum2; | 1882 | return linkNum1 - linkNum2; |
1883 | } | 1883 | } |
1884 | ); | 1884 | ); |
1885 | 1885 | ||
1886 | //look for prims with explicit sit targets that are available | 1886 | //look for prims with explicit sit targets that are available |
1887 | foreach (SceneObjectPart part in partArray) | 1887 | foreach (SceneObjectPart part in partArray) |
1888 | { | 1888 | { |
1889 | // Is a sit target available? | 1889 | // Is a sit target available? |
1890 | Vector3 avSitOffSet = part.SitTargetPosition; | 1890 | Vector3 avSitOffSet = part.SitTargetPosition; |
1891 | Quaternion avSitOrientation = part.SitTargetOrientation; | 1891 | Quaternion avSitOrientation = part.SitTargetOrientation; |
1892 | UUID avOnTargetAlready = part.GetAvatarOnSitTarget(); | 1892 | UUID avOnTargetAlready = part.GetAvatarOnSitTarget(); |
1893 | bool SitTargetOccupied = (avOnTargetAlready != UUID.Zero); | 1893 | bool SitTargetOccupied = (avOnTargetAlready != UUID.Zero); |
1894 | bool SitTargetisSet = (Vector3.Zero != avSitOffSet); //NB Latest SL Spec shows Sit Rotation setting is ignored. | 1894 | bool SitTargetisSet = (Vector3.Zero != avSitOffSet); //NB Latest SL Spec shows Sit Rotation setting is ignored. |
1895 | if (SitTargetisSet && !SitTargetOccupied) | 1895 | if (SitTargetisSet && !SitTargetOccupied) |
1896 | { | 1896 | { |
1897 | //switch the target to this prim | 1897 | //switch the target to this prim |
1898 | return part; | 1898 | return part; |
1899 | } | 1899 | } |
1900 | } | 1900 | } |
1901 | 1901 | ||
1902 | // no explicit sit target found - use original target | 1902 | // no explicit sit target found - use original target |
1903 | return targetPart; | 1903 | return targetPart; |
1904 | } | 1904 | } |
1905 | 1905 | ||
1906 | private void SendSitResponse(IClientAPI remoteClient, UUID targetID, Vector3 offset, Quaternion pSitOrientation) | 1906 | private void SendSitResponse(IClientAPI remoteClient, UUID targetID, Vector3 offset, Quaternion pSitOrientation) |
1907 | { | 1907 | { |
1908 | bool autopilot = true; | 1908 | bool autopilot = true; |
1909 | Vector3 autopilotTarget = new Vector3(); | 1909 | Vector3 autopilotTarget = new Vector3(); |
1910 | Quaternion sitOrientation = Quaternion.Identity; | 1910 | Quaternion sitOrientation = Quaternion.Identity; |
1911 | Vector3 pos = new Vector3(); | 1911 | Vector3 pos = new Vector3(); |
1912 | Vector3 cameraEyeOffset = Vector3.Zero; | 1912 | Vector3 cameraEyeOffset = Vector3.Zero; |
1913 | Vector3 cameraAtOffset = Vector3.Zero; | 1913 | Vector3 cameraAtOffset = Vector3.Zero; |
1914 | bool forceMouselook = false; | 1914 | bool forceMouselook = false; |
1915 | 1915 | ||
1916 | //SceneObjectPart part = m_scene.GetSceneObjectPart(targetID); | 1916 | //SceneObjectPart part = m_scene.GetSceneObjectPart(targetID); |
1917 | SceneObjectPart part = FindNextAvailableSitTarget(targetID); | 1917 | SceneObjectPart part = FindNextAvailableSitTarget(targetID); |
1918 | if (part == null) return; | 1918 | if (part == null) return; |
1919 | 1919 | ||
1920 | // TODO: determine position to sit at based on scene geometry; don't trust offset from client | 1920 | // TODO: determine position to sit at based on scene geometry; don't trust offset from client |
1921 | // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it | 1921 | // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it |
1922 | 1922 | ||
1923 | // part is the prim to sit on | 1923 | // part is the prim to sit on |
1924 | // offset is the world-ref vector distance from that prim center to the click-spot | 1924 | // offset is the world-ref vector distance from that prim center to the click-spot |
1925 | // UUID is the UUID of the Avatar doing the clicking | 1925 | // UUID is the UUID of the Avatar doing the clicking |
1926 | 1926 | ||
1927 | m_avInitialPos = AbsolutePosition; // saved to calculate unscripted sit rotation | 1927 | m_avInitialPos = AbsolutePosition; // saved to calculate unscripted sit rotation |
1928 | 1928 | ||
1929 | // Is a sit target available? | 1929 | // Is a sit target available? |
1930 | Vector3 avSitOffSet = part.SitTargetPosition; | 1930 | Vector3 avSitOffSet = part.SitTargetPosition; |
1931 | Quaternion avSitOrientation = part.SitTargetOrientation; | 1931 | Quaternion avSitOrientation = part.SitTargetOrientation; |
1932 | 1932 | ||
1933 | bool SitTargetisSet = (Vector3.Zero != avSitOffSet); //NB Latest SL Spec shows Sit Rotation setting is ignored. | 1933 | bool SitTargetisSet = (Vector3.Zero != avSitOffSet); //NB Latest SL Spec shows Sit Rotation setting is ignored. |
1934 | // Quaternion partIRot = Quaternion.Inverse(part.GetWorldRotation()); | 1934 | // Quaternion partIRot = Quaternion.Inverse(part.GetWorldRotation()); |
1935 | Quaternion partRot; | 1935 | Quaternion partRot; |
1936 | // if (part.LinkNum == 1) | 1936 | // if (part.LinkNum == 1) |
1937 | // { // Root prim of linkset | 1937 | // { // Root prim of linkset |
1938 | // partRot = part.ParentGroup.RootPart.RotationOffset; | 1938 | // partRot = part.ParentGroup.RootPart.RotationOffset; |
1939 | // } | 1939 | // } |
1940 | // else | 1940 | // else |
1941 | // { // single or child prim | 1941 | // { // single or child prim |
1942 | partRot = part.GetWorldRotation(); | 1942 | partRot = part.GetWorldRotation(); |
1943 | // } | 1943 | // } |
1944 | Quaternion partIRot = Quaternion.Inverse(partRot); | 1944 | Quaternion partIRot = Quaternion.Inverse(partRot); |
1945 | //Console.WriteLine("SendSitResponse offset=" + offset + " Occup=" + part.IsOccupied + " TargSet=" + SitTargetisSet); | 1945 | //Console.WriteLine("SendSitResponse offset=" + offset + " Occup=" + part.IsOccupied + " TargSet=" + SitTargetisSet); |
1946 | // Sit analysis rewritten by KF 091125 | 1946 | // Sit analysis rewritten by KF 091125 |
1947 | if (SitTargetisSet) // scipted sit | 1947 | if (SitTargetisSet) // scipted sit |
1948 | { | 1948 | { |
1949 | if (!part.IsOccupied) | 1949 | if (!part.IsOccupied) |
1950 | { | 1950 | { |
1951 | //Console.WriteLine("Scripted, unoccupied"); | 1951 | //Console.WriteLine("Scripted, unoccupied"); |
1952 | part.SetAvatarOnSitTarget(UUID); // set that Av will be on it | 1952 | part.SetAvatarOnSitTarget(UUID); // set that Av will be on it |
1953 | offset = new Vector3(avSitOffSet.X, avSitOffSet.Y, avSitOffSet.Z); // change ofset to the scripted one | 1953 | offset = new Vector3(avSitOffSet.X, avSitOffSet.Y, avSitOffSet.Z); // change ofset to the scripted one |
1954 | 1954 | ||
1955 | Quaternion nrot = avSitOrientation; | 1955 | Quaternion nrot = avSitOrientation; |
1956 | if (!part.IsRoot) | 1956 | if (!part.IsRoot) |
1957 | { | 1957 | { |
1958 | nrot = part.RotationOffset * avSitOrientation; | 1958 | nrot = part.RotationOffset * avSitOrientation; |
1959 | } | 1959 | } |
1960 | sitOrientation = nrot; // Change rotatione to the scripted one | 1960 | sitOrientation = nrot; // Change rotatione to the scripted one |
1961 | OffsetRotation = nrot; | 1961 | OffsetRotation = nrot; |
1962 | autopilot = false; // Jump direct to scripted llSitPos() | 1962 | autopilot = false; // Jump direct to scripted llSitPos() |
1963 | } | 1963 | } |
1964 | else | 1964 | else |
1965 | { | 1965 | { |
1966 | //Console.WriteLine("Scripted, occupied"); | 1966 | //Console.WriteLine("Scripted, occupied"); |
1967 | return; | 1967 | return; |
1968 | } | 1968 | } |
1969 | } | 1969 | } |
1970 | else // Not Scripted | 1970 | else // Not Scripted |
1971 | { | 1971 | { |
1972 | if ( (Math.Abs(offset.X) > 0.5f) || (Math.Abs(offset.Y) > 0.5f) ) | 1972 | if ( (Math.Abs(offset.X) > 0.5f) || (Math.Abs(offset.Y) > 0.5f) ) |
1973 | { | 1973 | { |
1974 | // large prim & offset, ignore if other Avs sitting | 1974 | // large prim & offset, ignore if other Avs sitting |
1975 | // offset.Z -= 0.05f; | 1975 | // offset.Z -= 0.05f; |
1976 | m_avUnscriptedSitPos = offset * partIRot; // (non-zero) sit where clicked | 1976 | m_avUnscriptedSitPos = offset * partIRot; // (non-zero) sit where clicked |
1977 | autopilotTarget = part.AbsolutePosition + offset; // World location of clicked point | 1977 | autopilotTarget = part.AbsolutePosition + offset; // World location of clicked point |
1978 | 1978 | ||
1979 | //Console.WriteLine(" offset ={0}", offset); | 1979 | //Console.WriteLine(" offset ={0}", offset); |
1980 | //Console.WriteLine(" UnscriptedSitPos={0}", m_avUnscriptedSitPos); | 1980 | //Console.WriteLine(" UnscriptedSitPos={0}", m_avUnscriptedSitPos); |
1981 | //Console.WriteLine(" autopilotTarget={0}", autopilotTarget); | 1981 | //Console.WriteLine(" autopilotTarget={0}", autopilotTarget); |
1982 | 1982 | ||
1983 | } | 1983 | } |
1984 | else // small offset | 1984 | else // small offset |
1985 | { | 1985 | { |
1986 | //Console.WriteLine("Small offset"); | 1986 | //Console.WriteLine("Small offset"); |
1987 | if (!part.IsOccupied) | 1987 | if (!part.IsOccupied) |
1988 | { | 1988 | { |
1989 | m_avUnscriptedSitPos = Vector3.Zero; // Zero = Sit on prim center | 1989 | m_avUnscriptedSitPos = Vector3.Zero; // Zero = Sit on prim center |
1990 | autopilotTarget = part.AbsolutePosition; | 1990 | autopilotTarget = part.AbsolutePosition; |
1991 | //Console.WriteLine("UsSmall autopilotTarget={0}", autopilotTarget); | 1991 | //Console.WriteLine("UsSmall autopilotTarget={0}", autopilotTarget); |
1992 | } | 1992 | } |
1993 | else return; // occupied small | 1993 | else return; // occupied small |
1994 | } // end large/small | 1994 | } // end large/small |
1995 | } // end Scripted/not | 1995 | } // end Scripted/not |
1996 | cameraAtOffset = part.GetCameraAtOffset(); | 1996 | cameraAtOffset = part.GetCameraAtOffset(); |
1997 | cameraEyeOffset = part.GetCameraEyeOffset(); | 1997 | cameraEyeOffset = part.GetCameraEyeOffset(); |
1998 | forceMouselook = part.GetForceMouselook(); | 1998 | forceMouselook = part.GetForceMouselook(); |
1999 | if(cameraAtOffset == Vector3.Zero) cameraAtOffset = new Vector3(0f, 0f, 0.1f); // | 1999 | if(cameraAtOffset == Vector3.Zero) cameraAtOffset = new Vector3(0f, 0f, 0.1f); // |
2000 | if(cameraEyeOffset == Vector3.Zero) cameraEyeOffset = new Vector3(0f, 0f, 0.1f); // | 2000 | if(cameraEyeOffset == Vector3.Zero) cameraEyeOffset = new Vector3(0f, 0f, 0.1f); // |
2001 | 2001 | ||
2002 | if (m_physicsActor != null) | 2002 | if (m_physicsActor != null) |
2003 | { | 2003 | { |
2004 | // If we're not using the client autopilot, we're immediately warping the avatar to the location | 2004 | // If we're not using the client autopilot, we're immediately warping the avatar to the location |
2005 | // We can remove the physicsActor until they stand up. | 2005 | // We can remove the physicsActor until they stand up. |
2006 | m_sitAvatarHeight = m_physicsActor.Size.Z; | 2006 | m_sitAvatarHeight = m_physicsActor.Size.Z; |
2007 | if (autopilot) | 2007 | if (autopilot) |
2008 | { // its not a scripted sit | 2008 | { // its not a scripted sit |
2009 | // if (Util.GetDistanceTo(AbsolutePosition, autopilotTarget) < 4.5) | 2009 | // if (Util.GetDistanceTo(AbsolutePosition, autopilotTarget) < 4.5) |
2010 | if( (Math.Abs(AbsolutePosition.X - autopilotTarget.X) < 256.0f) && (Math.Abs(AbsolutePosition.Y - autopilotTarget.Y) < 256.0f) ) | 2010 | if( (Math.Abs(AbsolutePosition.X - autopilotTarget.X) < 256.0f) && (Math.Abs(AbsolutePosition.Y - autopilotTarget.Y) < 256.0f) ) |
2011 | { | 2011 | { |
2012 | autopilot = false; // close enough | 2012 | autopilot = false; // close enough |
2013 | m_lastWorldPosition = m_pos; /* CW - This give us a position to return the avatar to if the part is killed before standup. | 2013 | m_lastWorldPosition = m_pos; /* CW - This give us a position to return the avatar to if the part is killed before standup. |
2014 | Not using the part's position because returning the AV to the last known standing | 2014 | Not using the part's position because returning the AV to the last known standing |
2015 | position is likely to be more friendly, isn't it? */ | 2015 | position is likely to be more friendly, isn't it? */ |
2016 | RemoveFromPhysicalScene(); | 2016 | RemoveFromPhysicalScene(); |
2017 | Velocity = Vector3.Zero; | 2017 | Velocity = Vector3.Zero; |
2018 | AbsolutePosition = autopilotTarget + new Vector3(0.0f, 0.0f, (m_sitAvatarHeight / 2.0f)); // Warp av to over sit target | 2018 | AbsolutePosition = autopilotTarget + new Vector3(0.0f, 0.0f, (m_sitAvatarHeight / 2.0f)); // Warp av to over sit target |
2019 | } // else the autopilot will get us close | 2019 | } // else the autopilot will get us close |
2020 | } | 2020 | } |
2021 | else | 2021 | else |
2022 | { // its a scripted sit | 2022 | { // its a scripted sit |
2023 | m_lastWorldPosition = part.AbsolutePosition; /* CW - This give us a position to return the avatar to if the part is killed before standup. | 2023 | m_lastWorldPosition = part.AbsolutePosition; /* CW - This give us a position to return the avatar to if the part is killed before standup. |
2024 | I *am* using the part's position this time because we have no real idea how far away | 2024 | I *am* using the part's position this time because we have no real idea how far away |
2025 | the avatar is from the sit target. */ | 2025 | the avatar is from the sit target. */ |
2026 | RemoveFromPhysicalScene(); | 2026 | RemoveFromPhysicalScene(); |
2027 | Velocity = Vector3.Zero; | 2027 | Velocity = Vector3.Zero; |
2028 | } | 2028 | } |
2029 | } | 2029 | } |
2030 | else return; // physactor is null! | 2030 | else return; // physactor is null! |
2031 | 2031 | ||
2032 | Vector3 offsetr; // = offset * partIRot; | 2032 | Vector3 offsetr; // = offset * partIRot; |
2033 | // KF: In a linkset, offsetr needs to be relative to the group root! 091208 | 2033 | // KF: In a linkset, offsetr needs to be relative to the group root! 091208 |
2034 | // offsetr = (part.OffsetPosition * Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset)) + (offset * partIRot); | 2034 | // offsetr = (part.OffsetPosition * Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset)) + (offset * partIRot); |
2035 | // if (part.LinkNum < 2) 091216 All this was necessary because of the GetWorldRotation error. | 2035 | // if (part.LinkNum < 2) 091216 All this was necessary because of the GetWorldRotation error. |
2036 | // { // Single, or Root prim of linkset, target is ClickOffset * RootRot | 2036 | // { // Single, or Root prim of linkset, target is ClickOffset * RootRot |
2037 | //offsetr = offset * partIRot; | 2037 | //offsetr = offset * partIRot; |
2038 | // | 2038 | // |
2039 | // else | 2039 | // else |
2040 | // { // Child prim, offset is (ChildOffset * RootRot) + (ClickOffset * ChildRot) | 2040 | // { // Child prim, offset is (ChildOffset * RootRot) + (ClickOffset * ChildRot) |
2041 | // offsetr = //(part.OffsetPosition * Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset)) + | 2041 | // offsetr = //(part.OffsetPosition * Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset)) + |
2042 | // (offset * partRot); | 2042 | // (offset * partRot); |
2043 | // } | 2043 | // } |
2044 | 2044 | ||
2045 | //Console.WriteLine(" "); | 2045 | //Console.WriteLine(" "); |
2046 | //Console.WriteLine("link number ={0}", part.LinkNum); | 2046 | //Console.WriteLine("link number ={0}", part.LinkNum); |
2047 | //Console.WriteLine("Prim offset ={0}", part.OffsetPosition ); | 2047 | //Console.WriteLine("Prim offset ={0}", part.OffsetPosition ); |
2048 | //Console.WriteLine("Root Rotate ={0}", part.ParentGroup.RootPart.RotationOffset); | 2048 | //Console.WriteLine("Root Rotate ={0}", part.ParentGroup.RootPart.RotationOffset); |
2049 | //Console.WriteLine("Click offst ={0}", offset); | 2049 | //Console.WriteLine("Click offst ={0}", offset); |
2050 | //Console.WriteLine("Prim Rotate ={0}", part.GetWorldRotation()); | 2050 | //Console.WriteLine("Prim Rotate ={0}", part.GetWorldRotation()); |
2051 | //Console.WriteLine("offsetr ={0}", offsetr); | 2051 | //Console.WriteLine("offsetr ={0}", offsetr); |
2052 | //Console.WriteLine("Camera At ={0}", cameraAtOffset); | 2052 | //Console.WriteLine("Camera At ={0}", cameraAtOffset); |
2053 | //Console.WriteLine("Camera Eye ={0}", cameraEyeOffset); | 2053 | //Console.WriteLine("Camera Eye ={0}", cameraEyeOffset); |
2054 | 2054 | ||
2055 | //NOTE: SendSitResponse should be relative to the GROUP *NOT* THE PRIM if we're sitting on a child | 2055 | //NOTE: SendSitResponse should be relative to the GROUP *NOT* THE PRIM if we're sitting on a child |
2056 | ControllingClient.SendSitResponse(part.ParentGroup.UUID, ((offset * part.RotationOffset) + part.OffsetPosition), sitOrientation, autopilot, cameraAtOffset, cameraEyeOffset, forceMouselook); | 2056 | ControllingClient.SendSitResponse(part.ParentGroup.UUID, ((offset * part.RotationOffset) + part.OffsetPosition), sitOrientation, autopilot, cameraAtOffset, cameraEyeOffset, forceMouselook); |
2057 | 2057 | ||
2058 | m_requestedSitTargetUUID = part.UUID; //KF: Correct autopilot target | 2058 | m_requestedSitTargetUUID = part.UUID; //KF: Correct autopilot target |
2059 | // This calls HandleAgentSit twice, once from here, and the client calls | 2059 | // This calls HandleAgentSit twice, once from here, and the client calls |
2060 | // HandleAgentSit itself after it gets to the location | 2060 | // HandleAgentSit itself after it gets to the location |
2061 | // It doesn't get to the location until we've moved them there though | 2061 | // It doesn't get to the location until we've moved them there though |
2062 | // which happens in HandleAgentSit :P | 2062 | // which happens in HandleAgentSit :P |
2063 | m_autopilotMoving = autopilot; | 2063 | m_autopilotMoving = autopilot; |
2064 | m_autoPilotTarget = autopilotTarget; | 2064 | m_autoPilotTarget = autopilotTarget; |
2065 | m_sitAtAutoTarget = autopilot; | 2065 | m_sitAtAutoTarget = autopilot; |
2066 | m_initialSitTarget = autopilotTarget; | 2066 | m_initialSitTarget = autopilotTarget; |
2067 | if (!autopilot) | 2067 | if (!autopilot) |
2068 | HandleAgentSit(remoteClient, UUID); | 2068 | HandleAgentSit(remoteClient, UUID); |
2069 | } | 2069 | } |
2070 | 2070 | ||
2071 | public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset) | 2071 | public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset) |
2072 | { | 2072 | { |
2073 | if (m_parentID != 0) | 2073 | if (m_parentID != 0) |
2074 | { | 2074 | { |
2075 | StandUp(); | 2075 | StandUp(); |
2076 | } | 2076 | } |
2077 | m_nextSitAnimation = "SIT"; | 2077 | m_nextSitAnimation = "SIT"; |
2078 | 2078 | ||
2079 | //SceneObjectPart part = m_scene.GetSceneObjectPart(targetID); | 2079 | //SceneObjectPart part = m_scene.GetSceneObjectPart(targetID); |
2080 | SceneObjectPart part = FindNextAvailableSitTarget(targetID); | 2080 | SceneObjectPart part = FindNextAvailableSitTarget(targetID); |
2081 | 2081 | ||
2082 | if (part != null) | 2082 | if (part != null) |
2083 | { | 2083 | { |
2084 | if (!String.IsNullOrEmpty(part.SitAnimation)) | 2084 | if (!String.IsNullOrEmpty(part.SitAnimation)) |
2085 | { | 2085 | { |
2086 | m_nextSitAnimation = part.SitAnimation; | 2086 | m_nextSitAnimation = part.SitAnimation; |
2087 | } | 2087 | } |
2088 | m_requestedSitTargetID = part.LocalId; | 2088 | m_requestedSitTargetID = part.LocalId; |
2089 | //m_requestedSitOffset = offset; | 2089 | //m_requestedSitOffset = offset; |
2090 | m_requestedSitTargetUUID = targetID; | 2090 | m_requestedSitTargetUUID = targetID; |
2091 | 2091 | ||
2092 | m_log.DebugFormat("[SIT]: Client requested Sit Position: {0}", offset); | 2092 | m_log.DebugFormat("[SIT]: Client requested Sit Position: {0}", offset); |
2093 | 2093 | ||
2094 | if (m_scene.PhysicsScene.SupportsRayCast()) | 2094 | if (m_scene.PhysicsScene.SupportsRayCast()) |
2095 | { | 2095 | { |
2096 | //m_scene.PhysicsScene.RaycastWorld(Vector3.Zero,Vector3.Zero, 0.01f,new RaycastCallback()); | 2096 | //m_scene.PhysicsScene.RaycastWorld(Vector3.Zero,Vector3.Zero, 0.01f,new RaycastCallback()); |
2097 | //SitRayCastAvatarPosition(part); | 2097 | //SitRayCastAvatarPosition(part); |
2098 | //return; | 2098 | //return; |
2099 | } | 2099 | } |
2100 | } | 2100 | } |
2101 | else | 2101 | else |
2102 | { | 2102 | { |
2103 | 2103 | ||
2104 | m_log.Warn("Sit requested on unknown object: " + targetID.ToString()); | 2104 | m_log.Warn("Sit requested on unknown object: " + targetID.ToString()); |
2105 | } | 2105 | } |
2106 | 2106 | ||
2107 | 2107 | ||
2108 | 2108 | ||
2109 | SendSitResponse(remoteClient, targetID, offset, Quaternion.Identity); | 2109 | SendSitResponse(remoteClient, targetID, offset, Quaternion.Identity); |
2110 | } | 2110 | } |
2111 | /* | 2111 | /* |
2112 | public void SitRayCastAvatarPosition(SceneObjectPart part) | 2112 | public void SitRayCastAvatarPosition(SceneObjectPart part) |
2113 | { | 2113 | { |
2114 | Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; | 2114 | Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; |
2115 | Vector3 StartRayCastPosition = AbsolutePosition; | 2115 | Vector3 StartRayCastPosition = AbsolutePosition; |
2116 | Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); | 2116 | Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); |
2117 | float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); | 2117 | float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); |
2118 | m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastAvatarPositionResponse); | 2118 | m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastAvatarPositionResponse); |
2119 | } | 2119 | } |
2120 | 2120 | ||
2121 | public void SitRayCastAvatarPositionResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) | 2121 | public void SitRayCastAvatarPositionResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) |
2122 | { | 2122 | { |
2123 | SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); | 2123 | SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); |
2124 | if (part != null) | 2124 | if (part != null) |
2125 | { | 2125 | { |
2126 | if (hitYN) | 2126 | if (hitYN) |
2127 | { | 2127 | { |
2128 | if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) | 2128 | if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) |
2129 | { | 2129 | { |
2130 | SitRaycastFindEdge(collisionPoint, normal); | 2130 | SitRaycastFindEdge(collisionPoint, normal); |
2131 | m_log.DebugFormat("[SIT]: Raycast Avatar Position succeeded at point: {0}, normal:{1}", collisionPoint, normal); | 2131 | m_log.DebugFormat("[SIT]: Raycast Avatar Position succeeded at point: {0}, normal:{1}", collisionPoint, normal); |
2132 | } | 2132 | } |
2133 | else | 2133 | else |
2134 | { | 2134 | { |
2135 | SitRayCastAvatarPositionCameraZ(part); | 2135 | SitRayCastAvatarPositionCameraZ(part); |
2136 | } | 2136 | } |
2137 | } | 2137 | } |
2138 | else | 2138 | else |
2139 | { | 2139 | { |
2140 | SitRayCastAvatarPositionCameraZ(part); | 2140 | SitRayCastAvatarPositionCameraZ(part); |
2141 | } | 2141 | } |
2142 | } | 2142 | } |
2143 | else | 2143 | else |
2144 | { | 2144 | { |
2145 | ControllingClient.SendAlertMessage("Sit position no longer exists"); | 2145 | ControllingClient.SendAlertMessage("Sit position no longer exists"); |
2146 | m_requestedSitTargetUUID = UUID.Zero; | 2146 | m_requestedSitTargetUUID = UUID.Zero; |
2147 | m_requestedSitTargetID = 0; | 2147 | m_requestedSitTargetID = 0; |
2148 | m_requestedSitOffset = Vector3.Zero; | 2148 | m_requestedSitOffset = Vector3.Zero; |
2149 | } | 2149 | } |
2150 | 2150 | ||
2151 | } | 2151 | } |
2152 | 2152 | ||
2153 | public void SitRayCastAvatarPositionCameraZ(SceneObjectPart part) | 2153 | public void SitRayCastAvatarPositionCameraZ(SceneObjectPart part) |
2154 | { | 2154 | { |
2155 | // Next, try to raycast from the camera Z position | 2155 | // Next, try to raycast from the camera Z position |
2156 | Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; | 2156 | Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; |
2157 | Vector3 StartRayCastPosition = AbsolutePosition; StartRayCastPosition.Z = CameraPosition.Z; | 2157 | Vector3 StartRayCastPosition = AbsolutePosition; StartRayCastPosition.Z = CameraPosition.Z; |
2158 | Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); | 2158 | Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); |
2159 | float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); | 2159 | float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); |
2160 | m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastAvatarPositionCameraZResponse); | 2160 | m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastAvatarPositionCameraZResponse); |
2161 | } | 2161 | } |
2162 | 2162 | ||
2163 | public void SitRayCastAvatarPositionCameraZResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) | 2163 | public void SitRayCastAvatarPositionCameraZResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) |
2164 | { | 2164 | { |
2165 | SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); | 2165 | SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); |
2166 | if (part != null) | 2166 | if (part != null) |
2167 | { | 2167 | { |
2168 | if (hitYN) | 2168 | if (hitYN) |
2169 | { | 2169 | { |
2170 | if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) | 2170 | if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) |
2171 | { | 2171 | { |
2172 | SitRaycastFindEdge(collisionPoint, normal); | 2172 | SitRaycastFindEdge(collisionPoint, normal); |
2173 | m_log.DebugFormat("[SIT]: Raycast Avatar Position + CameraZ succeeded at point: {0}, normal:{1}", collisionPoint, normal); | 2173 | m_log.DebugFormat("[SIT]: Raycast Avatar Position + CameraZ succeeded at point: {0}, normal:{1}", collisionPoint, normal); |
2174 | } | 2174 | } |
2175 | else | 2175 | else |
2176 | { | 2176 | { |
2177 | SitRayCastCameraPosition(part); | 2177 | SitRayCastCameraPosition(part); |
2178 | } | 2178 | } |
2179 | } | 2179 | } |
2180 | else | 2180 | else |
2181 | { | 2181 | { |
2182 | SitRayCastCameraPosition(part); | 2182 | SitRayCastCameraPosition(part); |
2183 | } | 2183 | } |
2184 | } | 2184 | } |
2185 | else | 2185 | else |
2186 | { | 2186 | { |
2187 | ControllingClient.SendAlertMessage("Sit position no longer exists"); | 2187 | ControllingClient.SendAlertMessage("Sit position no longer exists"); |
2188 | m_requestedSitTargetUUID = UUID.Zero; | 2188 | m_requestedSitTargetUUID = UUID.Zero; |
2189 | m_requestedSitTargetID = 0; | 2189 | m_requestedSitTargetID = 0; |
2190 | m_requestedSitOffset = Vector3.Zero; | 2190 | m_requestedSitOffset = Vector3.Zero; |
2191 | } | 2191 | } |
2192 | 2192 | ||
2193 | } | 2193 | } |
2194 | 2194 | ||
2195 | public void SitRayCastCameraPosition(SceneObjectPart part) | 2195 | public void SitRayCastCameraPosition(SceneObjectPart part) |
2196 | { | 2196 | { |
2197 | // Next, try to raycast from the camera position | 2197 | // Next, try to raycast from the camera position |
2198 | Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; | 2198 | Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; |
2199 | Vector3 StartRayCastPosition = CameraPosition; | 2199 | Vector3 StartRayCastPosition = CameraPosition; |
2200 | Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); | 2200 | Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); |
2201 | float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); | 2201 | float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); |
2202 | m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastCameraPositionResponse); | 2202 | m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastCameraPositionResponse); |
2203 | } | 2203 | } |
2204 | 2204 | ||
2205 | public void SitRayCastCameraPositionResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) | 2205 | public void SitRayCastCameraPositionResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) |
2206 | { | 2206 | { |
2207 | SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); | 2207 | SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); |
2208 | if (part != null) | 2208 | if (part != null) |
2209 | { | 2209 | { |
2210 | if (hitYN) | 2210 | if (hitYN) |
2211 | { | 2211 | { |
2212 | if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) | 2212 | if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) |
2213 | { | 2213 | { |
2214 | SitRaycastFindEdge(collisionPoint, normal); | 2214 | SitRaycastFindEdge(collisionPoint, normal); |
2215 | m_log.DebugFormat("[SIT]: Raycast Camera Position succeeded at point: {0}, normal:{1}", collisionPoint, normal); | 2215 | m_log.DebugFormat("[SIT]: Raycast Camera Position succeeded at point: {0}, normal:{1}", collisionPoint, normal); |
2216 | } | 2216 | } |
2217 | else | 2217 | else |
2218 | { | 2218 | { |
2219 | SitRayHorizontal(part); | 2219 | SitRayHorizontal(part); |
2220 | } | 2220 | } |
2221 | } | 2221 | } |
2222 | else | 2222 | else |
2223 | { | 2223 | { |
2224 | SitRayHorizontal(part); | 2224 | SitRayHorizontal(part); |
2225 | } | 2225 | } |
2226 | } | 2226 | } |
2227 | else | 2227 | else |
2228 | { | 2228 | { |
2229 | ControllingClient.SendAlertMessage("Sit position no longer exists"); | 2229 | ControllingClient.SendAlertMessage("Sit position no longer exists"); |
2230 | m_requestedSitTargetUUID = UUID.Zero; | 2230 | m_requestedSitTargetUUID = UUID.Zero; |
2231 | m_requestedSitTargetID = 0; | 2231 | m_requestedSitTargetID = 0; |
2232 | m_requestedSitOffset = Vector3.Zero; | 2232 | m_requestedSitOffset = Vector3.Zero; |
2233 | } | 2233 | } |
2234 | 2234 | ||
2235 | } | 2235 | } |
2236 | 2236 | ||
2237 | public void SitRayHorizontal(SceneObjectPart part) | 2237 | public void SitRayHorizontal(SceneObjectPart part) |
2238 | { | 2238 | { |
2239 | // Next, try to raycast from the avatar position to fwd | 2239 | // Next, try to raycast from the avatar position to fwd |
2240 | Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; | 2240 | Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; |
2241 | Vector3 StartRayCastPosition = CameraPosition; | 2241 | Vector3 StartRayCastPosition = CameraPosition; |
2242 | Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); | 2242 | Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); |
2243 | float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); | 2243 | float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); |
2244 | m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastHorizontalResponse); | 2244 | m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastHorizontalResponse); |
2245 | } | 2245 | } |
2246 | 2246 | ||
2247 | public void SitRayCastHorizontalResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) | 2247 | public void SitRayCastHorizontalResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) |
2248 | { | 2248 | { |
2249 | SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); | 2249 | SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); |
2250 | if (part != null) | 2250 | if (part != null) |
2251 | { | 2251 | { |
2252 | if (hitYN) | 2252 | if (hitYN) |
2253 | { | 2253 | { |
2254 | if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) | 2254 | if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) |
2255 | { | 2255 | { |
2256 | SitRaycastFindEdge(collisionPoint, normal); | 2256 | SitRaycastFindEdge(collisionPoint, normal); |
2257 | m_log.DebugFormat("[SIT]: Raycast Horizontal Position succeeded at point: {0}, normal:{1}", collisionPoint, normal); | 2257 | m_log.DebugFormat("[SIT]: Raycast Horizontal Position succeeded at point: {0}, normal:{1}", collisionPoint, normal); |
2258 | // Next, try to raycast from the camera position | 2258 | // Next, try to raycast from the camera position |
2259 | Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; | 2259 | Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; |
2260 | Vector3 StartRayCastPosition = CameraPosition; | 2260 | Vector3 StartRayCastPosition = CameraPosition; |
2261 | Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); | 2261 | Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); |
2262 | float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); | 2262 | float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); |
2263 | //m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastResponseAvatarPosition); | 2263 | //m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastResponseAvatarPosition); |
2264 | } | 2264 | } |
2265 | else | 2265 | else |
2266 | { | 2266 | { |
2267 | ControllingClient.SendAlertMessage("Sit position not accessable."); | 2267 | ControllingClient.SendAlertMessage("Sit position not accessable."); |
2268 | m_requestedSitTargetUUID = UUID.Zero; | 2268 | m_requestedSitTargetUUID = UUID.Zero; |
2269 | m_requestedSitTargetID = 0; | 2269 | m_requestedSitTargetID = 0; |
2270 | m_requestedSitOffset = Vector3.Zero; | 2270 | m_requestedSitOffset = Vector3.Zero; |
2271 | } | 2271 | } |
2272 | } | 2272 | } |
2273 | else | 2273 | else |
2274 | { | 2274 | { |
2275 | ControllingClient.SendAlertMessage("Sit position not accessable."); | 2275 | ControllingClient.SendAlertMessage("Sit position not accessable."); |
2276 | m_requestedSitTargetUUID = UUID.Zero; | 2276 | m_requestedSitTargetUUID = UUID.Zero; |
2277 | m_requestedSitTargetID = 0; | 2277 | m_requestedSitTargetID = 0; |
2278 | m_requestedSitOffset = Vector3.Zero; | 2278 | m_requestedSitOffset = Vector3.Zero; |
2279 | } | 2279 | } |
2280 | } | 2280 | } |
2281 | else | 2281 | else |
2282 | { | 2282 | { |
2283 | ControllingClient.SendAlertMessage("Sit position no longer exists"); | 2283 | ControllingClient.SendAlertMessage("Sit position no longer exists"); |
2284 | m_requestedSitTargetUUID = UUID.Zero; | 2284 | m_requestedSitTargetUUID = UUID.Zero; |
2285 | m_requestedSitTargetID = 0; | 2285 | m_requestedSitTargetID = 0; |
2286 | m_requestedSitOffset = Vector3.Zero; | 2286 | m_requestedSitOffset = Vector3.Zero; |
2287 | } | 2287 | } |
2288 | 2288 | ||
2289 | } | 2289 | } |
2290 | 2290 | ||
2291 | private void SitRaycastFindEdge(Vector3 collisionPoint, Vector3 collisionNormal) | 2291 | private void SitRaycastFindEdge(Vector3 collisionPoint, Vector3 collisionNormal) |
2292 | { | 2292 | { |
2293 | int i = 0; | 2293 | int i = 0; |
2294 | //throw new NotImplementedException(); | 2294 | //throw new NotImplementedException(); |
2295 | //m_requestedSitTargetUUID = UUID.Zero; | 2295 | //m_requestedSitTargetUUID = UUID.Zero; |
2296 | //m_requestedSitTargetID = 0; | 2296 | //m_requestedSitTargetID = 0; |
2297 | //m_requestedSitOffset = Vector3.Zero; | 2297 | //m_requestedSitOffset = Vector3.Zero; |
2298 | 2298 | ||
2299 | SendSitResponse(ControllingClient, m_requestedSitTargetUUID, collisionPoint - m_requestedSitOffset, Quaternion.Identity); | 2299 | SendSitResponse(ControllingClient, m_requestedSitTargetUUID, collisionPoint - m_requestedSitOffset, Quaternion.Identity); |
2300 | } | 2300 | } |
2301 | */ | 2301 | */ |
2302 | public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset, string sitAnimation) | 2302 | public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset, string sitAnimation) |
2303 | { | 2303 | { |
2304 | if (m_parentID != 0) | 2304 | if (m_parentID != 0) |
2305 | { | 2305 | { |
2306 | StandUp(); | 2306 | StandUp(); |
2307 | } | 2307 | } |
2308 | if (!String.IsNullOrEmpty(sitAnimation)) | 2308 | if (!String.IsNullOrEmpty(sitAnimation)) |
2309 | { | 2309 | { |
2310 | m_nextSitAnimation = sitAnimation; | 2310 | m_nextSitAnimation = sitAnimation; |
2311 | } | 2311 | } |
2312 | else | 2312 | else |
2313 | { | 2313 | { |
2314 | m_nextSitAnimation = "SIT"; | 2314 | m_nextSitAnimation = "SIT"; |
2315 | } | 2315 | } |
2316 | 2316 | ||
2317 | //SceneObjectPart part = m_scene.GetSceneObjectPart(targetID); | 2317 | //SceneObjectPart part = m_scene.GetSceneObjectPart(targetID); |
2318 | SceneObjectPart part = FindNextAvailableSitTarget(targetID); | 2318 | SceneObjectPart part = FindNextAvailableSitTarget(targetID); |
2319 | if (part != null) | 2319 | if (part != null) |
2320 | { | 2320 | { |
2321 | m_requestedSitTargetID = part.LocalId; | 2321 | m_requestedSitTargetID = part.LocalId; |
2322 | //m_requestedSitOffset = offset; | 2322 | //m_requestedSitOffset = offset; |
2323 | m_requestedSitTargetUUID = targetID; | 2323 | m_requestedSitTargetUUID = targetID; |
2324 | 2324 | ||
2325 | m_log.DebugFormat("[SIT]: Client requested Sit Position: {0}", offset); | 2325 | m_log.DebugFormat("[SIT]: Client requested Sit Position: {0}", offset); |
2326 | 2326 | ||
2327 | if (m_scene.PhysicsScene.SupportsRayCast()) | 2327 | if (m_scene.PhysicsScene.SupportsRayCast()) |
2328 | { | 2328 | { |
2329 | //SitRayCastAvatarPosition(part); | 2329 | //SitRayCastAvatarPosition(part); |
2330 | //return; | 2330 | //return; |
2331 | } | 2331 | } |
2332 | } | 2332 | } |
2333 | else | 2333 | else |
2334 | { | 2334 | { |
2335 | m_log.Warn("Sit requested on unknown object: " + targetID); | 2335 | m_log.Warn("Sit requested on unknown object: " + targetID); |
2336 | } | 2336 | } |
2337 | 2337 | ||
2338 | SendSitResponse(remoteClient, targetID, offset, Quaternion.Identity); | 2338 | SendSitResponse(remoteClient, targetID, offset, Quaternion.Identity); |
2339 | } | 2339 | } |
2340 | 2340 | ||
2341 | public void HandleAgentSit(IClientAPI remoteClient, UUID agentID) | 2341 | public void HandleAgentSit(IClientAPI remoteClient, UUID agentID) |
2342 | { | 2342 | { |
2343 | if (!String.IsNullOrEmpty(m_nextSitAnimation)) | 2343 | if (!String.IsNullOrEmpty(m_nextSitAnimation)) |
2344 | { | 2344 | { |
2345 | HandleAgentSit(remoteClient, agentID, m_nextSitAnimation); | 2345 | HandleAgentSit(remoteClient, agentID, m_nextSitAnimation); |
2346 | } | 2346 | } |
2347 | else | 2347 | else |
2348 | { | 2348 | { |
2349 | HandleAgentSit(remoteClient, agentID, "SIT"); | 2349 | HandleAgentSit(remoteClient, agentID, "SIT"); |
2350 | } | 2350 | } |
2351 | } | 2351 | } |
2352 | 2352 | ||
2353 | public void HandleAgentSit(IClientAPI remoteClient, UUID agentID, string sitAnimation) | 2353 | public void HandleAgentSit(IClientAPI remoteClient, UUID agentID, string sitAnimation) |
2354 | { | 2354 | { |
2355 | SceneObjectPart part = m_scene.GetSceneObjectPart(m_requestedSitTargetID); | 2355 | SceneObjectPart part = m_scene.GetSceneObjectPart(m_requestedSitTargetID); |
2356 | 2356 | ||
2357 | if (m_sitAtAutoTarget || !m_autopilotMoving) | 2357 | if (m_sitAtAutoTarget || !m_autopilotMoving) |
2358 | { | 2358 | { |
2359 | if (part != null) | 2359 | if (part != null) |
2360 | { | 2360 | { |
2361 | //Console.WriteLine("Link #{0}, Rot {1}", part.LinkNum, part.GetWorldRotation()); | 2361 | //Console.WriteLine("Link #{0}, Rot {1}", part.LinkNum, part.GetWorldRotation()); |
2362 | if (part.GetAvatarOnSitTarget() == UUID) | 2362 | if (part.GetAvatarOnSitTarget() == UUID) |
2363 | { | 2363 | { |
2364 | //Console.WriteLine("Scripted Sit"); | 2364 | //Console.WriteLine("Scripted Sit"); |
2365 | // Scripted sit | 2365 | // Scripted sit |
2366 | Vector3 sitTargetPos = part.SitTargetPosition; | 2366 | Vector3 sitTargetPos = part.SitTargetPosition; |
2367 | Quaternion sitTargetOrient = part.SitTargetOrientation; | 2367 | Quaternion sitTargetOrient = part.SitTargetOrientation; |
2368 | m_pos = new Vector3(sitTargetPos.X, sitTargetPos.Y, sitTargetPos.Z); | 2368 | m_pos = new Vector3(sitTargetPos.X, sitTargetPos.Y, sitTargetPos.Z); |
2369 | m_pos += SIT_TARGET_ADJUSTMENT; | 2369 | m_pos += SIT_TARGET_ADJUSTMENT; |
2370 | if (!part.IsRoot) | 2370 | if (!part.IsRoot) |
2371 | { | 2371 | { |
2372 | m_pos *= part.RotationOffset; | 2372 | m_pos *= part.RotationOffset; |
2373 | } | 2373 | } |
2374 | m_bodyRot = sitTargetOrient; | 2374 | m_bodyRot = sitTargetOrient; |
2375 | m_parentPosition = part.AbsolutePosition; | 2375 | m_parentPosition = part.AbsolutePosition; |
2376 | part.IsOccupied = true; | 2376 | part.IsOccupied = true; |
2377 | part.ParentGroup.AddAvatar(agentID); | 2377 | part.ParentGroup.AddAvatar(agentID); |
2378 | } | 2378 | } |
2379 | else | 2379 | else |
2380 | { | 2380 | { |
2381 | // if m_avUnscriptedSitPos is zero then Av sits above center | 2381 | // if m_avUnscriptedSitPos is zero then Av sits above center |
2382 | // Else Av sits at m_avUnscriptedSitPos | 2382 | // Else Av sits at m_avUnscriptedSitPos |
2383 | 2383 | ||
2384 | // Non-scripted sit by Kitto Flora 21Nov09 | 2384 | // Non-scripted sit by Kitto Flora 21Nov09 |
2385 | // Calculate angle of line from prim to Av | 2385 | // Calculate angle of line from prim to Av |
2386 | Quaternion partIRot; | 2386 | Quaternion partIRot; |
2387 | // if (part.LinkNum == 1) | 2387 | // if (part.LinkNum == 1) |
2388 | // { // Root prim of linkset | 2388 | // { // Root prim of linkset |
2389 | // partIRot = Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset); | 2389 | // partIRot = Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset); |
2390 | // } | 2390 | // } |
2391 | // else | 2391 | // else |
2392 | // { // single or child prim | 2392 | // { // single or child prim |
2393 | partIRot = Quaternion.Inverse(part.GetWorldRotation()); | 2393 | partIRot = Quaternion.Inverse(part.GetWorldRotation()); |
2394 | // } | 2394 | // } |
2395 | Vector3 sitTargetPos= part.AbsolutePosition + m_avUnscriptedSitPos; | 2395 | Vector3 sitTargetPos= part.AbsolutePosition + m_avUnscriptedSitPos; |
2396 | float y_diff = (m_avInitialPos.Y - sitTargetPos.Y); | 2396 | float y_diff = (m_avInitialPos.Y - sitTargetPos.Y); |
2397 | float x_diff = ( m_avInitialPos.X - sitTargetPos.X); | 2397 | float x_diff = ( m_avInitialPos.X - sitTargetPos.X); |
2398 | if(Math.Abs(x_diff) < 0.001f) x_diff = 0.001f; // avoid div by 0 | 2398 | if(Math.Abs(x_diff) < 0.001f) x_diff = 0.001f; // avoid div by 0 |
2399 | if(Math.Abs(y_diff) < 0.001f) y_diff = 0.001f; // avoid pol flip at 0 | 2399 | if(Math.Abs(y_diff) < 0.001f) y_diff = 0.001f; // avoid pol flip at 0 |
2400 | float sit_angle = (float)Math.Atan2( (double)y_diff, (double)x_diff); | 2400 | float sit_angle = (float)Math.Atan2( (double)y_diff, (double)x_diff); |
2401 | // NOTE: when sitting m_ pos and m_bodyRot are *relative* to the prim location/rotation, not 'World'. | 2401 | // NOTE: when sitting m_ pos and m_bodyRot are *relative* to the prim location/rotation, not 'World'. |
2402 | // Av sits at world euler <0,0, z>, translated by part rotation | 2402 | // Av sits at world euler <0,0, z>, translated by part rotation |
2403 | m_bodyRot = partIRot * Quaternion.CreateFromEulers(0f, 0f, sit_angle); // sit at 0,0,inv-click | 2403 | m_bodyRot = partIRot * Quaternion.CreateFromEulers(0f, 0f, sit_angle); // sit at 0,0,inv-click |
2404 | 2404 | ||
2405 | m_parentPosition = part.AbsolutePosition; | 2405 | m_parentPosition = part.AbsolutePosition; |
2406 | part.IsOccupied = true; | 2406 | part.IsOccupied = true; |
2407 | part.ParentGroup.AddAvatar(agentID); | 2407 | part.ParentGroup.AddAvatar(agentID); |
2408 | m_pos = new Vector3(0f, 0f, 0.05f) + // corrections to get Sit Animation | 2408 | m_pos = new Vector3(0f, 0f, 0.05f) + // corrections to get Sit Animation |
2409 | (new Vector3(0.0f, 0f, 0.61f) * partIRot) + // located on center | 2409 | (new Vector3(0.0f, 0f, 0.61f) * partIRot) + // located on center |
2410 | (new Vector3(0.34f, 0f, 0.0f) * m_bodyRot) + | 2410 | (new Vector3(0.34f, 0f, 0.0f) * m_bodyRot) + |
2411 | m_avUnscriptedSitPos; // adds click offset, if any | 2411 | m_avUnscriptedSitPos; // adds click offset, if any |
2412 | //Set up raytrace to find top surface of prim | 2412 | //Set up raytrace to find top surface of prim |
2413 | Vector3 size = part.Scale; | 2413 | Vector3 size = part.Scale; |
2414 | float mag = 2.0f; // 0.1f + (float)Math.Sqrt((size.X * size.X) + (size.Y * size.Y) + (size.Z * size.Z)); | 2414 | float mag = 2.0f; // 0.1f + (float)Math.Sqrt((size.X * size.X) + (size.Y * size.Y) + (size.Z * size.Z)); |
2415 | Vector3 start = part.AbsolutePosition + new Vector3(0f, 0f, mag); | 2415 | Vector3 start = part.AbsolutePosition + new Vector3(0f, 0f, mag); |
2416 | Vector3 down = new Vector3(0f, 0f, -1f); | 2416 | Vector3 down = new Vector3(0f, 0f, -1f); |
2417 | //Console.WriteLine("st={0} do={1} ma={2}", start, down, mag); | 2417 | //Console.WriteLine("st={0} do={1} ma={2}", start, down, mag); |
2418 | m_scene.PhysicsScene.RaycastWorld( | 2418 | m_scene.PhysicsScene.RaycastWorld( |
2419 | start, // Vector3 position, | 2419 | start, // Vector3 position, |
2420 | down, // Vector3 direction, | 2420 | down, // Vector3 direction, |
2421 | mag, // float length, | 2421 | mag, // float length, |
2422 | SitAltitudeCallback); // retMethod | 2422 | SitAltitudeCallback); // retMethod |
2423 | } // end scripted/not | 2423 | } // end scripted/not |
2424 | } | 2424 | } |
2425 | else // no Av | 2425 | else // no Av |
2426 | { | 2426 | { |
2427 | return; | 2427 | return; |
2428 | } | 2428 | } |
2429 | } | 2429 | } |
2430 | 2430 | ||
2431 | //We want our offsets to reference the root prim, not the child we may have sat on | 2431 | //We want our offsets to reference the root prim, not the child we may have sat on |
2432 | if (!part.IsRoot) | 2432 | if (!part.IsRoot) |
2433 | { | 2433 | { |
2434 | m_parentID = part.ParentGroup.RootPart.LocalId; | 2434 | m_parentID = part.ParentGroup.RootPart.LocalId; |
2435 | m_pos += part.OffsetPosition; | 2435 | m_pos += part.OffsetPosition; |
2436 | } | 2436 | } |
2437 | else | 2437 | else |
2438 | { | 2438 | { |
2439 | m_parentID = m_requestedSitTargetID; | 2439 | m_parentID = m_requestedSitTargetID; |
2440 | } | 2440 | } |
2441 | 2441 | ||
2442 | m_linkedPrim = part.UUID; | 2442 | m_linkedPrim = part.UUID; |
2443 | if (part.GetAvatarOnSitTarget() != UUID) | 2443 | if (part.GetAvatarOnSitTarget() != UUID) |
2444 | { | 2444 | { |
2445 | m_offsetRotation = m_offsetRotation / part.RotationOffset; | 2445 | m_offsetRotation = m_offsetRotation / part.RotationOffset; |
2446 | } | 2446 | } |
2447 | Velocity = Vector3.Zero; | 2447 | Velocity = Vector3.Zero; |
2448 | RemoveFromPhysicalScene(); | 2448 | RemoveFromPhysicalScene(); |
2449 | Animator.TrySetMovementAnimation(sitAnimation); | 2449 | Animator.TrySetMovementAnimation(sitAnimation); |
2450 | SendFullUpdateToAllClients(); | 2450 | SendFullUpdateToAllClients(); |
2451 | SendTerseUpdateToAllClients(); | 2451 | SendTerseUpdateToAllClients(); |
2452 | } | 2452 | } |
2453 | 2453 | ||
2454 | public void SitAltitudeCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 normal) | 2454 | public void SitAltitudeCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 normal) |
2455 | { | 2455 | { |
2456 | // KF: 091202 There appears to be a bug in Prim Edit Size - the process sometimes make a prim that RayTrace no longer | 2456 | // KF: 091202 There appears to be a bug in Prim Edit Size - the process sometimes make a prim that RayTrace no longer |
2457 | // sees. Take/re-rez, or sim restart corrects the condition. Result of bug is incorrect sit height. | 2457 | // sees. Take/re-rez, or sim restart corrects the condition. Result of bug is incorrect sit height. |
2458 | if(hitYN) | 2458 | if(hitYN) |
2459 | { | 2459 | { |
2460 | // m_pos = Av offset from prim center to make look like on center | 2460 | // m_pos = Av offset from prim center to make look like on center |
2461 | // m_parentPosition = Actual center pos of prim | 2461 | // m_parentPosition = Actual center pos of prim |
2462 | // collisionPoint = spot on prim where we want to sit | 2462 | // collisionPoint = spot on prim where we want to sit |
2463 | // collisionPoint.Z = global sit surface height | 2463 | // collisionPoint.Z = global sit surface height |
2464 | SceneObjectPart part = m_scene.GetSceneObjectPart(localid); | 2464 | SceneObjectPart part = m_scene.GetSceneObjectPart(localid); |
2465 | Quaternion partIRot; | 2465 | Quaternion partIRot; |
2466 | // if (part.LinkNum == 1) | 2466 | // if (part.LinkNum == 1) |
2467 | /// { // Root prim of linkset | 2467 | /// { // Root prim of linkset |
2468 | // partIRot = Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset); | 2468 | // partIRot = Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset); |
2469 | // } | 2469 | // } |
2470 | // else | 2470 | // else |
2471 | // { // single or child prim | 2471 | // { // single or child prim |
2472 | partIRot = Quaternion.Inverse(part.GetWorldRotation()); | 2472 | partIRot = Quaternion.Inverse(part.GetWorldRotation()); |
2473 | // } | 2473 | // } |
2474 | if (m_initialSitTarget != null) | 2474 | if (m_initialSitTarget != null) |
2475 | { | 2475 | { |
2476 | float offZ = collisionPoint.Z - m_initialSitTarget.Z; | 2476 | float offZ = collisionPoint.Z - m_initialSitTarget.Z; |
2477 | Vector3 offset = new Vector3(0.0f, 0.0f, offZ) * partIRot; // Altitude correction | 2477 | Vector3 offset = new Vector3(0.0f, 0.0f, offZ) * partIRot; // Altitude correction |
2478 | //Console.WriteLine("sitPoint={0}, offset={1}", sitPoint, offset); | 2478 | //Console.WriteLine("sitPoint={0}, offset={1}", sitPoint, offset); |
2479 | m_pos += offset; | 2479 | m_pos += offset; |
2480 | // ControllingClient.SendClearFollowCamProperties(part.UUID); | 2480 | // ControllingClient.SendClearFollowCamProperties(part.UUID); |
2481 | } | 2481 | } |
2482 | 2482 | ||
2483 | } | 2483 | } |
2484 | } // End SitAltitudeCallback KF. | 2484 | } // End SitAltitudeCallback KF. |
2485 | 2485 | ||
2486 | /// <summary> | 2486 | /// <summary> |
2487 | /// Event handler for the 'Always run' setting on the client | 2487 | /// Event handler for the 'Always run' setting on the client |
2488 | /// Tells the physics plugin to increase speed of movement. | 2488 | /// Tells the physics plugin to increase speed of movement. |
2489 | /// </summary> | 2489 | /// </summary> |
2490 | public void HandleSetAlwaysRun(IClientAPI remoteClient, bool pSetAlwaysRun) | 2490 | public void HandleSetAlwaysRun(IClientAPI remoteClient, bool pSetAlwaysRun) |
2491 | { | 2491 | { |
2492 | m_setAlwaysRun = pSetAlwaysRun; | 2492 | m_setAlwaysRun = pSetAlwaysRun; |
2493 | if (PhysicsActor != null) | 2493 | if (PhysicsActor != null) |
2494 | { | 2494 | { |
2495 | PhysicsActor.SetAlwaysRun = pSetAlwaysRun; | 2495 | PhysicsActor.SetAlwaysRun = pSetAlwaysRun; |
2496 | } | 2496 | } |
2497 | } | 2497 | } |
2498 | 2498 | ||
2499 | public void HandleStartAnim(IClientAPI remoteClient, UUID animID) | 2499 | public void HandleStartAnim(IClientAPI remoteClient, UUID animID) |
2500 | { | 2500 | { |
2501 | Animator.AddAnimation(animID, UUID.Zero); | 2501 | Animator.AddAnimation(animID, UUID.Zero); |
2502 | } | 2502 | } |
2503 | 2503 | ||
2504 | public void HandleStopAnim(IClientAPI remoteClient, UUID animID) | 2504 | public void HandleStopAnim(IClientAPI remoteClient, UUID animID) |
2505 | { | 2505 | { |
2506 | Animator.RemoveAnimation(animID); | 2506 | Animator.RemoveAnimation(animID); |
2507 | } | 2507 | } |
2508 | 2508 | ||
2509 | /// <summary> | 2509 | /// <summary> |
2510 | /// Rotate the avatar to the given rotation and apply a movement in the given relative vector | 2510 | /// Rotate the avatar to the given rotation and apply a movement in the given relative vector |
2511 | /// </summary> | 2511 | /// </summary> |
2512 | /// <param name="vec">The vector in which to move. This is relative to the rotation argument</param> | 2512 | /// <param name="vec">The vector in which to move. This is relative to the rotation argument</param> |
2513 | /// <param name="rotation">The direction in which this avatar should now face. | 2513 | /// <param name="rotation">The direction in which this avatar should now face. |
2514 | public void AddNewMovement(Vector3 vec, Quaternion rotation, bool Nudging) | 2514 | public void AddNewMovement(Vector3 vec, Quaternion rotation, bool Nudging) |
2515 | { | 2515 | { |
2516 | if (m_isChildAgent) | 2516 | if (m_isChildAgent) |
2517 | { | 2517 | { |
2518 | // WHAT??? | 2518 | // WHAT??? |
2519 | m_log.Debug("[SCENEPRESENCE]: AddNewMovement() called on child agent, making root agent!"); | 2519 | m_log.Debug("[SCENEPRESENCE]: AddNewMovement() called on child agent, making root agent!"); |
2520 | 2520 | ||
2521 | // we have to reset the user's child agent connections. | 2521 | // we have to reset the user's child agent connections. |
2522 | // Likely, here they've lost the eventqueue for other regions so border | 2522 | // Likely, here they've lost the eventqueue for other regions so border |
2523 | // crossings will fail at this point unless we reset them. | 2523 | // crossings will fail at this point unless we reset them. |
2524 | 2524 | ||
2525 | List<ulong> regions = new List<ulong>(KnownChildRegionHandles); | 2525 | List<ulong> regions = new List<ulong>(KnownChildRegionHandles); |
2526 | regions.Remove(m_scene.RegionInfo.RegionHandle); | 2526 | regions.Remove(m_scene.RegionInfo.RegionHandle); |
2527 | 2527 | ||
2528 | MakeRootAgent(new Vector3(127f, 127f, 127f), true); | 2528 | MakeRootAgent(new Vector3(127f, 127f, 127f), true); |
2529 | 2529 | ||
2530 | // Async command | 2530 | // Async command |
2531 | if (m_scene.SceneGridService != null) | 2531 | if (m_scene.SceneGridService != null) |
2532 | { | 2532 | { |
2533 | m_scene.SceneGridService.SendCloseChildAgentConnections(UUID, regions); | 2533 | m_scene.SceneGridService.SendCloseChildAgentConnections(UUID, regions); |
2534 | 2534 | ||
2535 | // Give the above command some time to try and close the connections. | 2535 | // Give the above command some time to try and close the connections. |
2536 | // this is really an emergency.. so sleep, or we'll get all discombobulated. | 2536 | // this is really an emergency.. so sleep, or we'll get all discombobulated. |
2537 | System.Threading.Thread.Sleep(500); | 2537 | System.Threading.Thread.Sleep(500); |
2538 | } | 2538 | } |
2539 | 2539 | ||
2540 | if (m_scene.SceneGridService != null) | 2540 | if (m_scene.SceneGridService != null) |
2541 | { | 2541 | { |
2542 | IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>(); | 2542 | IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>(); |
2543 | if (m_agentTransfer != null) | 2543 | if (m_agentTransfer != null) |
2544 | m_agentTransfer.EnableChildAgents(this); | 2544 | m_agentTransfer.EnableChildAgents(this); |
2545 | } | 2545 | } |
2546 | 2546 | ||
2547 | return; | 2547 | return; |
2548 | } | 2548 | } |
2549 | 2549 | ||
2550 | m_perfMonMS = Util.EnvironmentTickCount(); | 2550 | m_perfMonMS = Util.EnvironmentTickCount(); |
2551 | 2551 | ||
2552 | Rotation = rotation; | 2552 | Rotation = rotation; |
2553 | Vector3 direc = vec * rotation; | 2553 | Vector3 direc = vec * rotation; |
2554 | direc.Normalize(); | 2554 | direc.Normalize(); |
2555 | PhysicsActor actor = m_physicsActor; | 2555 | PhysicsActor actor = m_physicsActor; |
2556 | if ((vec.Z == 0f) && !actor.Flying) direc.Z = 0f; // Prevent camera WASD up. | 2556 | if ((vec.Z == 0f) && !actor.Flying) direc.Z = 0f; // Prevent camera WASD up. |
2557 | 2557 | ||
2558 | direc *= 0.03f * 128f * m_speedModifier; | 2558 | direc *= 0.03f * 128f * m_speedModifier; |
2559 | 2559 | ||
2560 | if (actor != null) | 2560 | if (actor != null) |
2561 | { | 2561 | { |
2562 | if (actor.Flying) | 2562 | if (actor.Flying) |
2563 | { | 2563 | { |
2564 | direc *= 4.0f; | 2564 | direc *= 4.0f; |
2565 | //bool controlland = (((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || ((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); | 2565 | //bool controlland = (((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || ((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); |
2566 | //bool colliding = (m_physicsActor.IsColliding==true); | 2566 | //bool colliding = (m_physicsActor.IsColliding==true); |
2567 | //if (controlland) | 2567 | //if (controlland) |
2568 | // m_log.Info("[AGENT]: landCommand"); | 2568 | // m_log.Info("[AGENT]: landCommand"); |
2569 | //if (colliding) | 2569 | //if (colliding) |
2570 | // m_log.Info("[AGENT]: colliding"); | 2570 | // m_log.Info("[AGENT]: colliding"); |
2571 | //if (m_physicsActor.Flying && colliding && controlland) | 2571 | //if (m_physicsActor.Flying && colliding && controlland) |
2572 | //{ | 2572 | //{ |
2573 | // StopFlying(); | 2573 | // StopFlying(); |
2574 | // m_log.Info("[AGENT]: Stop FLying"); | 2574 | // m_log.Info("[AGENT]: Stop FLying"); |
2575 | //} | 2575 | //} |
2576 | } | 2576 | } |
2577 | else if (!actor.Flying && actor.IsColliding) | 2577 | else if (!actor.Flying && actor.IsColliding) |
2578 | { | 2578 | { |
2579 | if (direc.Z > 2.0f) | 2579 | if (direc.Z > 2.0f) |
2580 | { | 2580 | { |
2581 | if(m_animator.m_animTickJump == -1) | 2581 | if(m_animator.m_animTickJump == -1) |
2582 | { | 2582 | { |
2583 | direc.Z *= 3.0f; // jump | 2583 | direc.Z *= 3.0f; // jump |
2584 | } | 2584 | } |
2585 | else | 2585 | else |
2586 | { | 2586 | { |
2587 | direc.Z *= 0.1f; // prejump | 2587 | direc.Z *= 0.1f; // prejump |
2588 | } | 2588 | } |
2589 | /* Animations are controlled via GetMovementAnimation() in ScenePresenceAnimator.cs | 2589 | /* Animations are controlled via GetMovementAnimation() in ScenePresenceAnimator.cs |
2590 | Animator.TrySetMovementAnimation("PREJUMP"); | 2590 | Animator.TrySetMovementAnimation("PREJUMP"); |
2591 | Animator.TrySetMovementAnimation("JUMP"); | 2591 | Animator.TrySetMovementAnimation("JUMP"); |
2592 | */ | 2592 | */ |
2593 | } | 2593 | } |
2594 | } | 2594 | } |
2595 | } | 2595 | } |
2596 | 2596 | ||
2597 | // TODO: Add the force instead of only setting it to support multiple forces per frame? | 2597 | // TODO: Add the force instead of only setting it to support multiple forces per frame? |
2598 | m_forceToApply = direc; | 2598 | m_forceToApply = direc; |
2599 | m_isNudging = Nudging; | 2599 | m_isNudging = Nudging; |
2600 | m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); | 2600 | m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); |
2601 | } | 2601 | } |
2602 | 2602 | ||
2603 | #endregion | 2603 | #endregion |
2604 | 2604 | ||
2605 | #region Overridden Methods | 2605 | #region Overridden Methods |
2606 | 2606 | ||
2607 | public override void Update() | 2607 | public override void Update() |
2608 | { | 2608 | { |
2609 | const float ROTATION_TOLERANCE = 0.01f; | 2609 | const float ROTATION_TOLERANCE = 0.01f; |
2610 | const float VELOCITY_TOLERANCE = 0.001f; | 2610 | const float VELOCITY_TOLERANCE = 0.001f; |
2611 | const float POSITION_TOLERANCE = 0.05f; | 2611 | const float POSITION_TOLERANCE = 0.05f; |
2612 | //const int TIME_MS_TOLERANCE = 3000; | 2612 | //const int TIME_MS_TOLERANCE = 3000; |
2613 | 2613 | ||
2614 | 2614 | ||
2615 | 2615 | ||
2616 | if (m_isChildAgent == false) | 2616 | if (m_isChildAgent == false) |
2617 | { | 2617 | { |
2618 | // PhysicsActor actor = m_physicsActor; | 2618 | // PhysicsActor actor = m_physicsActor; |
2619 | 2619 | ||
2620 | // NOTE: Velocity is not the same as m_velocity. Velocity will attempt to | 2620 | // NOTE: Velocity is not the same as m_velocity. Velocity will attempt to |
2621 | // grab the latest PhysicsActor velocity, whereas m_velocity is often | 2621 | // grab the latest PhysicsActor velocity, whereas m_velocity is often |
2622 | // storing a requested force instead of an actual traveling velocity | 2622 | // storing a requested force instead of an actual traveling velocity |
2623 | 2623 | ||
2624 | // Throw away duplicate or insignificant updates | 2624 | // Throw away duplicate or insignificant updates |
2625 | if (!m_bodyRot.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) || | 2625 | if (!m_bodyRot.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) || |
2626 | !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || | 2626 | !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || |
2627 | !m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE)) | 2627 | !m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE)) |
2628 | //Environment.TickCount - m_lastTerseSent > TIME_MS_TOLERANCE) | 2628 | //Environment.TickCount - m_lastTerseSent > TIME_MS_TOLERANCE) |
2629 | { | 2629 | { |
2630 | SendTerseUpdateToAllClients(); | 2630 | SendTerseUpdateToAllClients(); |
2631 | 2631 | ||
2632 | // Update the "last" values | 2632 | // Update the "last" values |
2633 | m_lastPosition = m_pos; | 2633 | m_lastPosition = m_pos; |
2634 | m_lastRotation = m_bodyRot; | 2634 | m_lastRotation = m_bodyRot; |
2635 | m_lastVelocity = Velocity; | 2635 | m_lastVelocity = Velocity; |
2636 | //m_lastTerseSent = Environment.TickCount; | 2636 | //m_lastTerseSent = Environment.TickCount; |
2637 | } | 2637 | } |
2638 | 2638 | ||
2639 | // followed suggestion from mic bowman. reversed the two lines below. | 2639 | // followed suggestion from mic bowman. reversed the two lines below. |
2640 | if (m_parentID == 0 && m_physicsActor != null || m_parentID != 0) // Check that we have a physics actor or we're sitting on something | 2640 | if (m_parentID == 0 && m_physicsActor != null || m_parentID != 0) // Check that we have a physics actor or we're sitting on something |
2641 | CheckForBorderCrossing(); | 2641 | CheckForBorderCrossing(); |
2642 | CheckForSignificantMovement(); // sends update to the modules. | 2642 | CheckForSignificantMovement(); // sends update to the modules. |
2643 | } | 2643 | } |
2644 | 2644 | ||
2645 | //Sending prim updates AFTER the avatar terse updates are sent | 2645 | //Sending prim updates AFTER the avatar terse updates are sent |
2646 | SendPrimUpdates(); | 2646 | SendPrimUpdates(); |
2647 | } | 2647 | } |
2648 | 2648 | ||
2649 | #endregion | 2649 | #endregion |
2650 | 2650 | ||
2651 | #region Update Client(s) | 2651 | #region Update Client(s) |
2652 | 2652 | ||
2653 | /// <summary> | 2653 | /// <summary> |
2654 | /// Sends a location update to the client connected to this scenePresence | 2654 | /// Sends a location update to the client connected to this scenePresence |
2655 | /// </summary> | 2655 | /// </summary> |
2656 | /// <param name="remoteClient"></param> | 2656 | /// <param name="remoteClient"></param> |
2657 | public void SendTerseUpdateToClient(IClientAPI remoteClient) | 2657 | public void SendTerseUpdateToClient(IClientAPI remoteClient) |
2658 | { | 2658 | { |
2659 | // If the client is inactive, it's getting its updates from another | 2659 | // If the client is inactive, it's getting its updates from another |
2660 | // server. | 2660 | // server. |
2661 | if (remoteClient.IsActive) | 2661 | if (remoteClient.IsActive) |
2662 | { | 2662 | { |
2663 | m_perfMonMS = Util.EnvironmentTickCount(); | 2663 | m_perfMonMS = Util.EnvironmentTickCount(); |
2664 | 2664 | ||
2665 | PhysicsActor actor = m_physicsActor; | 2665 | PhysicsActor actor = m_physicsActor; |
2666 | Vector3 velocity = (actor != null) ? actor.Velocity : Vector3.Zero; | 2666 | Vector3 velocity = (actor != null) ? actor.Velocity : Vector3.Zero; |
2667 | 2667 | ||
2668 | Vector3 pos = m_pos; | 2668 | Vector3 pos = m_pos; |
2669 | pos.Z += m_appearance.HipOffset; | 2669 | pos.Z += m_appearance.HipOffset; |
2670 | 2670 | ||
2671 | //m_log.DebugFormat("[SCENEPRESENCE]: TerseUpdate: Pos={0} Rot={1} Vel={2}", m_pos, m_bodyRot, m_velocity); | 2671 | //m_log.DebugFormat("[SCENEPRESENCE]: TerseUpdate: Pos={0} Rot={1} Vel={2}", m_pos, m_bodyRot, m_velocity); |
2672 | 2672 | ||
2673 | remoteClient.SendPrimUpdate(this, PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity); | 2673 | remoteClient.SendPrimUpdate(this, PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity); |
2674 | 2674 | ||
2675 | m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); | 2675 | m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); |
2676 | m_scene.StatsReporter.AddAgentUpdates(1); | 2676 | m_scene.StatsReporter.AddAgentUpdates(1); |
2677 | } | 2677 | } |
2678 | } | 2678 | } |
2679 | 2679 | ||
2680 | /// <summary> | 2680 | /// <summary> |
2681 | /// Send a location/velocity/accelleration update to all agents in scene | 2681 | /// Send a location/velocity/accelleration update to all agents in scene |
2682 | /// </summary> | 2682 | /// </summary> |
2683 | public void SendTerseUpdateToAllClients() | 2683 | public void SendTerseUpdateToAllClients() |
2684 | { | 2684 | { |
2685 | m_perfMonMS = Util.EnvironmentTickCount(); | 2685 | m_perfMonMS = Util.EnvironmentTickCount(); |
2686 | 2686 | ||
2687 | m_scene.ForEachClient(SendTerseUpdateToClient); | 2687 | m_scene.ForEachClient(SendTerseUpdateToClient); |
2688 | 2688 | ||
2689 | m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); | 2689 | m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); |
2690 | } | 2690 | } |
2691 | 2691 | ||
2692 | public void SendCoarseLocations(List<Vector3> coarseLocations, List<UUID> avatarUUIDs) | 2692 | public void SendCoarseLocations(List<Vector3> coarseLocations, List<UUID> avatarUUIDs) |
2693 | { | 2693 | { |
2694 | SendCourseLocationsMethod d = m_sendCourseLocationsMethod; | 2694 | SendCourseLocationsMethod d = m_sendCourseLocationsMethod; |
2695 | if (d != null) | 2695 | if (d != null) |
2696 | { | 2696 | { |
2697 | d.Invoke(m_scene.RegionInfo.originRegionID, this, coarseLocations, avatarUUIDs); | 2697 | d.Invoke(m_scene.RegionInfo.originRegionID, this, coarseLocations, avatarUUIDs); |
2698 | } | 2698 | } |
2699 | } | 2699 | } |
2700 | 2700 | ||
2701 | public void SetSendCourseLocationMethod(SendCourseLocationsMethod d) | 2701 | public void SetSendCourseLocationMethod(SendCourseLocationsMethod d) |
2702 | { | 2702 | { |
2703 | if (d != null) | 2703 | if (d != null) |
2704 | m_sendCourseLocationsMethod = d; | 2704 | m_sendCourseLocationsMethod = d; |
2705 | } | 2705 | } |
2706 | 2706 | ||
2707 | public void SendCoarseLocationsDefault(UUID sceneId, ScenePresence p, List<Vector3> coarseLocations, List<UUID> avatarUUIDs) | 2707 | public void SendCoarseLocationsDefault(UUID sceneId, ScenePresence p, List<Vector3> coarseLocations, List<UUID> avatarUUIDs) |
2708 | { | 2708 | { |
2709 | m_perfMonMS = Util.EnvironmentTickCount(); | 2709 | m_perfMonMS = Util.EnvironmentTickCount(); |
2710 | m_controllingClient.SendCoarseLocationUpdate(avatarUUIDs, coarseLocations); | 2710 | m_controllingClient.SendCoarseLocationUpdate(avatarUUIDs, coarseLocations); |
2711 | m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); | 2711 | m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); |
2712 | } | 2712 | } |
2713 | 2713 | ||
2714 | /// <summary> | 2714 | /// <summary> |
2715 | /// Tell other client about this avatar (The client previously didn't know or had outdated details about this avatar) | 2715 | /// Tell other client about this avatar (The client previously didn't know or had outdated details about this avatar) |
2716 | /// </summary> | 2716 | /// </summary> |
2717 | /// <param name="remoteAvatar"></param> | 2717 | /// <param name="remoteAvatar"></param> |
2718 | public void SendFullUpdateToOtherClient(ScenePresence remoteAvatar) | 2718 | public void SendFullUpdateToOtherClient(ScenePresence remoteAvatar) |
2719 | { | 2719 | { |
2720 | // 2 stage check is needed. | 2720 | // 2 stage check is needed. |
2721 | if (remoteAvatar == null) | 2721 | if (remoteAvatar == null) |
2722 | return; | 2722 | return; |
2723 | IClientAPI cl=remoteAvatar.ControllingClient; | 2723 | IClientAPI cl=remoteAvatar.ControllingClient; |
2724 | if (cl == null) | 2724 | if (cl == null) |
2725 | return; | 2725 | return; |
2726 | if (m_appearance.Texture == null) | 2726 | if (m_appearance.Texture == null) |
2727 | return; | 2727 | return; |
2728 | 2728 | ||
2729 | Vector3 pos = m_pos; | 2729 | Vector3 pos = m_pos; |
2730 | pos.Z += m_appearance.HipOffset; | 2730 | pos.Z += m_appearance.HipOffset; |
2731 | 2731 | ||
2732 | remoteAvatar.m_controllingClient.SendAvatarDataImmediate(this); | 2732 | remoteAvatar.m_controllingClient.SendAvatarDataImmediate(this); |
2733 | m_scene.StatsReporter.AddAgentUpdates(1); | 2733 | m_scene.StatsReporter.AddAgentUpdates(1); |
2734 | } | 2734 | } |
2735 | 2735 | ||
2736 | /// <summary> | 2736 | /// <summary> |
2737 | /// Tell *ALL* agents about this agent | 2737 | /// Tell *ALL* agents about this agent |
2738 | /// </summary> | 2738 | /// </summary> |
2739 | public void SendInitialFullUpdateToAllClients() | 2739 | public void SendInitialFullUpdateToAllClients() |
2740 | { | 2740 | { |
2741 | m_perfMonMS = Util.EnvironmentTickCount(); | 2741 | m_perfMonMS = Util.EnvironmentTickCount(); |
2742 | int avUpdates = 0; | 2742 | int avUpdates = 0; |
2743 | m_scene.ForEachScenePresence(delegate(ScenePresence avatar) | 2743 | m_scene.ForEachScenePresence(delegate(ScenePresence avatar) |
2744 | { | 2744 | { |
2745 | ++avUpdates; | 2745 | ++avUpdates; |
2746 | // only send if this is the root (children are only "listening posts" in a foreign region) | 2746 | // only send if this is the root (children are only "listening posts" in a foreign region) |
2747 | if (!IsChildAgent) | 2747 | if (!IsChildAgent) |
2748 | { | 2748 | { |
2749 | SendFullUpdateToOtherClient(avatar); | 2749 | SendFullUpdateToOtherClient(avatar); |
2750 | } | 2750 | } |
2751 | 2751 | ||
2752 | if (avatar.LocalId != LocalId) | 2752 | if (avatar.LocalId != LocalId) |
2753 | { | 2753 | { |
2754 | if (!avatar.IsChildAgent) | 2754 | if (!avatar.IsChildAgent) |
2755 | { | 2755 | { |
2756 | avatar.SendFullUpdateToOtherClient(this); | 2756 | avatar.SendFullUpdateToOtherClient(this); |
2757 | avatar.SendAppearanceToOtherAgent(this); | 2757 | avatar.SendAppearanceToOtherAgent(this); |
2758 | avatar.Animator.SendAnimPackToClient(ControllingClient); | 2758 | avatar.Animator.SendAnimPackToClient(ControllingClient); |
2759 | } | 2759 | } |
2760 | } | 2760 | } |
2761 | }); | 2761 | }); |
2762 | 2762 | ||
2763 | m_scene.StatsReporter.AddAgentUpdates(avUpdates); | 2763 | m_scene.StatsReporter.AddAgentUpdates(avUpdates); |
2764 | m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); | 2764 | m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); |
2765 | 2765 | ||
2766 | //Animator.SendAnimPack(); | 2766 | //Animator.SendAnimPack(); |
2767 | } | 2767 | } |
2768 | 2768 | ||
2769 | public void SendFullUpdateToAllClients() | 2769 | public void SendFullUpdateToAllClients() |
2770 | { | 2770 | { |
2771 | m_perfMonMS = Util.EnvironmentTickCount(); | 2771 | m_perfMonMS = Util.EnvironmentTickCount(); |
2772 | 2772 | ||
2773 | // only send update from root agents to other clients; children are only "listening posts" | 2773 | // only send update from root agents to other clients; children are only "listening posts" |
2774 | int count = 0; | 2774 | int count = 0; |
2775 | m_scene.ForEachScenePresence(delegate(ScenePresence sp) | 2775 | m_scene.ForEachScenePresence(delegate(ScenePresence sp) |
2776 | { | 2776 | { |
2777 | if (sp.IsChildAgent) | 2777 | if (sp.IsChildAgent) |
2778 | return; | 2778 | return; |
2779 | SendFullUpdateToOtherClient(sp); | 2779 | SendFullUpdateToOtherClient(sp); |
2780 | ++count; | 2780 | ++count; |
2781 | }); | 2781 | }); |
2782 | m_scene.StatsReporter.AddAgentUpdates(count); | 2782 | m_scene.StatsReporter.AddAgentUpdates(count); |
2783 | m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); | 2783 | m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); |
2784 | 2784 | ||
2785 | Animator.SendAnimPack(); | 2785 | Animator.SendAnimPack(); |
2786 | } | 2786 | } |
2787 | 2787 | ||
2788 | /// <summary> | 2788 | /// <summary> |
2789 | /// Do everything required once a client completes its movement into a region | 2789 | /// Do everything required once a client completes its movement into a region |
2790 | /// </summary> | 2790 | /// </summary> |
2791 | public void SendInitialData() | 2791 | public void SendInitialData() |
2792 | { | 2792 | { |
2793 | // Moved this into CompleteMovement to ensure that m_appearance is initialized before | 2793 | // Moved this into CompleteMovement to ensure that m_appearance is initialized before |
2794 | // the inventory arrives | 2794 | // the inventory arrives |
2795 | // m_scene.GetAvatarAppearance(m_controllingClient, out m_appearance); | 2795 | // m_scene.GetAvatarAppearance(m_controllingClient, out m_appearance); |
2796 | 2796 | ||
2797 | Vector3 pos = m_pos; | 2797 | Vector3 pos = m_pos; |
2798 | pos.Z += m_appearance.HipOffset; | 2798 | pos.Z += m_appearance.HipOffset; |
2799 | 2799 | ||
2800 | m_controllingClient.SendAvatarDataImmediate(this); | 2800 | m_controllingClient.SendAvatarDataImmediate(this); |
2801 | 2801 | ||
2802 | SendInitialFullUpdateToAllClients(); | 2802 | SendInitialFullUpdateToAllClients(); |
2803 | SendAppearanceToAllOtherAgents(); | 2803 | SendAppearanceToAllOtherAgents(); |
2804 | } | 2804 | } |
2805 | 2805 | ||
2806 | /// <summary> | 2806 | /// <summary> |
2807 | /// Tell the client for this scene presence what items it should be wearing now | 2807 | /// Tell the client for this scene presence what items it should be wearing now |
2808 | /// </summary> | 2808 | /// </summary> |
2809 | public void SendWearables() | 2809 | public void SendWearables() |
2810 | { | 2810 | { |
2811 | m_log.DebugFormat("[SCENE]: Received request for wearables of {0}", Name); | 2811 | m_log.DebugFormat("[SCENE]: Received request for wearables of {0}", Name); |
2812 | 2812 | ||
2813 | ControllingClient.SendWearables(m_appearance.Wearables, m_appearance.Serial++); | 2813 | ControllingClient.SendWearables(m_appearance.Wearables, m_appearance.Serial++); |
2814 | } | 2814 | } |
2815 | 2815 | ||
2816 | /// <summary> | 2816 | /// <summary> |
2817 | /// | 2817 | /// |
2818 | /// </summary> | 2818 | /// </summary> |
2819 | public void SendAppearanceToAllOtherAgents() | 2819 | public void SendAppearanceToAllOtherAgents() |
2820 | { | 2820 | { |
2821 | m_perfMonMS = Util.EnvironmentTickCount(); | 2821 | m_perfMonMS = Util.EnvironmentTickCount(); |
2822 | 2822 | ||
2823 | m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) | 2823 | m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) |
2824 | { | 2824 | { |
2825 | if (scenePresence.UUID != UUID) | 2825 | if (scenePresence.UUID != UUID) |
2826 | { | 2826 | { |
2827 | SendAppearanceToOtherAgent(scenePresence); | 2827 | SendAppearanceToOtherAgent(scenePresence); |
2828 | } | 2828 | } |
2829 | }); | 2829 | }); |
2830 | 2830 | ||
2831 | m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); | 2831 | m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); |
2832 | } | 2832 | } |
2833 | 2833 | ||
2834 | /// <summary> | 2834 | /// <summary> |
2835 | /// Send appearance data to an agent that isn't this one. | 2835 | /// Send appearance data to an agent that isn't this one. |
2836 | /// </summary> | 2836 | /// </summary> |
2837 | /// <param name="avatar"></param> | 2837 | /// <param name="avatar"></param> |
2838 | public void SendAppearanceToOtherAgent(ScenePresence avatar) | 2838 | public void SendAppearanceToOtherAgent(ScenePresence avatar) |
2839 | { | 2839 | { |
2840 | avatar.ControllingClient.SendAppearance( | 2840 | avatar.ControllingClient.SendAppearance( |
2841 | m_appearance.Owner, m_appearance.VisualParams, m_appearance.Texture.GetBytes()); | 2841 | m_appearance.Owner, m_appearance.VisualParams, m_appearance.Texture.GetBytes()); |
2842 | } | 2842 | } |
2843 | 2843 | ||
2844 | /// <summary> | 2844 | /// <summary> |
2845 | /// Set appearance data (textureentry and slider settings) received from the client | 2845 | /// Set appearance data (textureentry and slider settings) received from the client |
2846 | /// </summary> | 2846 | /// </summary> |
2847 | /// <param name="texture"></param> | 2847 | /// <param name="texture"></param> |
2848 | /// <param name="visualParam"></param> | 2848 | /// <param name="visualParam"></param> |
2849 | public void SetAppearance(Primitive.TextureEntry textureEntry, byte[] visualParams) | 2849 | public void SetAppearance(Primitive.TextureEntry textureEntry, byte[] visualParams) |
2850 | { | 2850 | { |
2851 | if (m_physicsActor != null) | 2851 | if (m_physicsActor != null) |
2852 | { | 2852 | { |
2853 | if (!IsChildAgent) | 2853 | if (!IsChildAgent) |
2854 | { | 2854 | { |
2855 | // This may seem like it's redundant, remove the avatar from the physics scene | 2855 | // This may seem like it's redundant, remove the avatar from the physics scene |
2856 | // just to add it back again, but it saves us from having to update | 2856 | // just to add it back again, but it saves us from having to update |
2857 | // 3 variables 10 times a second. | 2857 | // 3 variables 10 times a second. |
2858 | bool flyingTemp = m_physicsActor.Flying; | 2858 | bool flyingTemp = m_physicsActor.Flying; |
2859 | RemoveFromPhysicalScene(); | 2859 | RemoveFromPhysicalScene(); |
2860 | //m_scene.PhysicsScene.RemoveAvatar(m_physicsActor); | 2860 | //m_scene.PhysicsScene.RemoveAvatar(m_physicsActor); |
2861 | 2861 | ||
2862 | //PhysicsActor = null; | 2862 | //PhysicsActor = null; |
2863 | 2863 | ||
2864 | AddToPhysicalScene(flyingTemp); | 2864 | AddToPhysicalScene(flyingTemp); |
2865 | } | 2865 | } |
2866 | } | 2866 | } |
2867 | 2867 | ||
2868 | #region Bake Cache Check | 2868 | #region Bake Cache Check |
2869 | 2869 | ||
2870 | if (textureEntry != null) | 2870 | if (textureEntry != null) |
2871 | { | 2871 | { |
2872 | for (int i = 0; i < BAKE_INDICES.Length; i++) | 2872 | for (int i = 0; i < BAKE_INDICES.Length; i++) |
2873 | { | 2873 | { |
2874 | int j = BAKE_INDICES[i]; | 2874 | int j = BAKE_INDICES[i]; |
2875 | Primitive.TextureEntryFace face = textureEntry.FaceTextures[j]; | 2875 | Primitive.TextureEntryFace face = textureEntry.FaceTextures[j]; |
2876 | 2876 | ||
2877 | if (face != null && face.TextureID != AppearanceManager.DEFAULT_AVATAR_TEXTURE) | 2877 | if (face != null && face.TextureID != AppearanceManager.DEFAULT_AVATAR_TEXTURE) |
2878 | { | 2878 | { |
2879 | if (m_scene.AssetService.Get(face.TextureID.ToString()) == null) | 2879 | if (m_scene.AssetService.Get(face.TextureID.ToString()) == null) |
2880 | { | 2880 | { |
2881 | m_log.Warn("[APPEARANCE]: Missing baked texture " + face.TextureID + " (" + j + ") for avatar " + this.Name); | 2881 | m_log.Warn("[APPEARANCE]: Missing baked texture " + face.TextureID + " (" + j + ") for avatar " + this.Name); |
2882 | this.ControllingClient.SendRebakeAvatarTextures(face.TextureID); | 2882 | this.ControllingClient.SendRebakeAvatarTextures(face.TextureID); |
2883 | } | 2883 | } |
2884 | } | 2884 | } |
2885 | } | 2885 | } |
2886 | 2886 | ||
2887 | } | 2887 | } |
2888 | 2888 | ||
2889 | 2889 | ||
2890 | #endregion Bake Cache Check | 2890 | #endregion Bake Cache Check |
2891 | 2891 | ||
2892 | m_appearance.SetAppearance(textureEntry, visualParams); | 2892 | m_appearance.SetAppearance(textureEntry, visualParams); |
2893 | if (m_appearance.AvatarHeight > 0) | 2893 | if (m_appearance.AvatarHeight > 0) |
2894 | SetHeight(m_appearance.AvatarHeight); | 2894 | SetHeight(m_appearance.AvatarHeight); |
2895 | 2895 | ||
2896 | // This is not needed, because only the transient data changed | 2896 | // This is not needed, because only the transient data changed |
2897 | //AvatarData adata = new AvatarData(m_appearance); | 2897 | //AvatarData adata = new AvatarData(m_appearance); |
2898 | //m_scene.AvatarService.SetAvatar(m_controllingClient.AgentId, adata); | 2898 | //m_scene.AvatarService.SetAvatar(m_controllingClient.AgentId, adata); |
2899 | 2899 | ||
2900 | SendAppearanceToAllOtherAgents(); | 2900 | SendAppearanceToAllOtherAgents(); |
2901 | if (!m_startAnimationSet) | 2901 | if (!m_startAnimationSet) |
2902 | { | 2902 | { |
2903 | Animator.UpdateMovementAnimations(); | 2903 | Animator.UpdateMovementAnimations(); |
2904 | m_startAnimationSet = true; | 2904 | m_startAnimationSet = true; |
2905 | } | 2905 | } |
2906 | 2906 | ||
2907 | Vector3 pos = m_pos; | 2907 | Vector3 pos = m_pos; |
2908 | pos.Z += m_appearance.HipOffset; | 2908 | pos.Z += m_appearance.HipOffset; |
2909 | 2909 | ||
2910 | m_controllingClient.SendAvatarDataImmediate(this); | 2910 | m_controllingClient.SendAvatarDataImmediate(this); |
2911 | } | 2911 | } |
2912 | 2912 | ||
2913 | public void SetWearable(int wearableId, AvatarWearable wearable) | 2913 | public void SetWearable(int wearableId, AvatarWearable wearable) |
2914 | { | 2914 | { |
2915 | m_appearance.SetWearable(wearableId, wearable); | 2915 | m_appearance.SetWearable(wearableId, wearable); |
2916 | AvatarData adata = new AvatarData(m_appearance); | 2916 | AvatarData adata = new AvatarData(m_appearance); |
2917 | m_scene.AvatarService.SetAvatar(m_controllingClient.AgentId, adata); | 2917 | m_scene.AvatarService.SetAvatar(m_controllingClient.AgentId, adata); |
2918 | m_controllingClient.SendWearables(m_appearance.Wearables, m_appearance.Serial++); | 2918 | m_controllingClient.SendWearables(m_appearance.Wearables, m_appearance.Serial++); |
2919 | } | 2919 | } |
2920 | 2920 | ||
2921 | // Because appearance setting is in a module, we actually need | 2921 | // Because appearance setting is in a module, we actually need |
2922 | // to give it access to our appearance directly, otherwise we | 2922 | // to give it access to our appearance directly, otherwise we |
2923 | // get a synchronization issue. | 2923 | // get a synchronization issue. |
2924 | public AvatarAppearance Appearance | 2924 | public AvatarAppearance Appearance |
2925 | { | 2925 | { |
2926 | get { return m_appearance; } | 2926 | get { return m_appearance; } |
2927 | set { m_appearance = value; } | 2927 | set { m_appearance = value; } |
2928 | } | 2928 | } |
2929 | 2929 | ||
2930 | #endregion | 2930 | #endregion |
2931 | 2931 | ||
2932 | #region Significant Movement Method | 2932 | #region Significant Movement Method |
2933 | 2933 | ||
2934 | /// <summary> | 2934 | /// <summary> |
2935 | /// This checks for a significant movement and sends a courselocationchange update | 2935 | /// This checks for a significant movement and sends a courselocationchange update |
2936 | /// </summary> | 2936 | /// </summary> |
2937 | protected void CheckForSignificantMovement() | 2937 | protected void CheckForSignificantMovement() |
2938 | { | 2938 | { |
2939 | // Movement updates for agents in neighboring regions are sent directly to clients. | 2939 | // Movement updates for agents in neighboring regions are sent directly to clients. |
2940 | // This value only affects how often agent positions are sent to neighbor regions | 2940 | // This value only affects how often agent positions are sent to neighbor regions |
2941 | // for things such as distance-based update prioritization | 2941 | // for things such as distance-based update prioritization |
2942 | const float SIGNIFICANT_MOVEMENT = 2.0f; | 2942 | const float SIGNIFICANT_MOVEMENT = 2.0f; |
2943 | 2943 | ||
2944 | if (Util.GetDistanceTo(AbsolutePosition, posLastSignificantMove) > SIGNIFICANT_MOVEMENT) | 2944 | if (Util.GetDistanceTo(AbsolutePosition, posLastSignificantMove) > SIGNIFICANT_MOVEMENT) |
2945 | { | 2945 | { |
2946 | posLastSignificantMove = AbsolutePosition; | 2946 | posLastSignificantMove = AbsolutePosition; |
2947 | m_scene.EventManager.TriggerSignificantClientMovement(m_controllingClient); | 2947 | m_scene.EventManager.TriggerSignificantClientMovement(m_controllingClient); |
2948 | } | 2948 | } |
2949 | 2949 | ||
2950 | // Minimum Draw distance is 64 meters, the Radius of the draw distance sphere is 32m | 2950 | // Minimum Draw distance is 64 meters, the Radius of the draw distance sphere is 32m |
2951 | if (Util.GetDistanceTo(AbsolutePosition, m_lastChildAgentUpdatePosition) >= Scene.ChildReprioritizationDistance || | 2951 | if (Util.GetDistanceTo(AbsolutePosition, m_lastChildAgentUpdatePosition) >= Scene.ChildReprioritizationDistance || |
2952 | Util.GetDistanceTo(CameraPosition, m_lastChildAgentUpdateCamPosition) >= Scene.ChildReprioritizationDistance) | 2952 | Util.GetDistanceTo(CameraPosition, m_lastChildAgentUpdateCamPosition) >= Scene.ChildReprioritizationDistance) |
2953 | { | 2953 | { |
2954 | m_lastChildAgentUpdatePosition = AbsolutePosition; | 2954 | m_lastChildAgentUpdatePosition = AbsolutePosition; |
2955 | m_lastChildAgentUpdateCamPosition = CameraPosition; | 2955 | m_lastChildAgentUpdateCamPosition = CameraPosition; |
2956 | 2956 | ||
2957 | ChildAgentDataUpdate cadu = new ChildAgentDataUpdate(); | 2957 | ChildAgentDataUpdate cadu = new ChildAgentDataUpdate(); |
2958 | cadu.ActiveGroupID = UUID.Zero.Guid; | 2958 | cadu.ActiveGroupID = UUID.Zero.Guid; |
2959 | cadu.AgentID = UUID.Guid; | 2959 | cadu.AgentID = UUID.Guid; |
2960 | cadu.alwaysrun = m_setAlwaysRun; | 2960 | cadu.alwaysrun = m_setAlwaysRun; |
2961 | cadu.AVHeight = m_avHeight; | 2961 | cadu.AVHeight = m_avHeight; |
2962 | Vector3 tempCameraCenter = m_CameraCenter; | 2962 | Vector3 tempCameraCenter = m_CameraCenter; |
2963 | cadu.cameraPosition = tempCameraCenter; | 2963 | cadu.cameraPosition = tempCameraCenter; |
2964 | cadu.drawdistance = m_DrawDistance; | 2964 | cadu.drawdistance = m_DrawDistance; |
2965 | cadu.GroupAccess = 0; | 2965 | cadu.GroupAccess = 0; |
2966 | cadu.Position = AbsolutePosition; | 2966 | cadu.Position = AbsolutePosition; |
2967 | cadu.regionHandle = m_rootRegionHandle; | 2967 | cadu.regionHandle = m_rootRegionHandle; |
2968 | float multiplier = 1; | 2968 | float multiplier = 1; |
2969 | int innacurateNeighbors = m_scene.GetInaccurateNeighborCount(); | 2969 | int innacurateNeighbors = m_scene.GetInaccurateNeighborCount(); |
2970 | if (innacurateNeighbors != 0) | 2970 | if (innacurateNeighbors != 0) |
2971 | { | 2971 | { |
2972 | multiplier = 1f / (float)innacurateNeighbors; | 2972 | multiplier = 1f / (float)innacurateNeighbors; |
2973 | } | 2973 | } |
2974 | if (multiplier <= 0f) | 2974 | if (multiplier <= 0f) |
2975 | { | 2975 | { |
2976 | multiplier = 0.25f; | 2976 | multiplier = 0.25f; |
2977 | } | 2977 | } |
2978 | 2978 | ||
2979 | //m_log.Info("[NeighborThrottle]: " + m_scene.GetInaccurateNeighborCount().ToString() + " - m: " + multiplier.ToString()); | 2979 | //m_log.Info("[NeighborThrottle]: " + m_scene.GetInaccurateNeighborCount().ToString() + " - m: " + multiplier.ToString()); |
2980 | cadu.throttles = ControllingClient.GetThrottlesPacked(multiplier); | 2980 | cadu.throttles = ControllingClient.GetThrottlesPacked(multiplier); |
2981 | cadu.Velocity = Velocity; | 2981 | cadu.Velocity = Velocity; |
2982 | 2982 | ||
2983 | AgentPosition agentpos = new AgentPosition(); | 2983 | AgentPosition agentpos = new AgentPosition(); |
2984 | agentpos.CopyFrom(cadu); | 2984 | agentpos.CopyFrom(cadu); |
2985 | 2985 | ||
2986 | m_scene.SendOutChildAgentUpdates(agentpos, this); | 2986 | m_scene.SendOutChildAgentUpdates(agentpos, this); |
2987 | } | 2987 | } |
2988 | } | 2988 | } |
2989 | 2989 | ||
2990 | #endregion | 2990 | #endregion |
2991 | 2991 | ||
2992 | #region Border Crossing Methods | 2992 | #region Border Crossing Methods |
2993 | 2993 | ||
2994 | /// <summary> | 2994 | /// <summary> |
2995 | /// Checks to see if the avatar is in range of a border and calls CrossToNewRegion | 2995 | /// Checks to see if the avatar is in range of a border and calls CrossToNewRegion |
2996 | /// </summary> | 2996 | /// </summary> |
2997 | protected void CheckForBorderCrossing() | 2997 | protected void CheckForBorderCrossing() |
2998 | { | 2998 | { |
2999 | if (IsChildAgent) | 2999 | if (IsChildAgent) |
3000 | return; | 3000 | return; |
3001 | 3001 | ||
3002 | Vector3 pos2 = AbsolutePosition; | 3002 | Vector3 pos2 = AbsolutePosition; |
3003 | Vector3 vel = Velocity; | 3003 | Vector3 vel = Velocity; |
3004 | int neighbor = 0; | 3004 | int neighbor = 0; |
3005 | int[] fix = new int[2]; | 3005 | int[] fix = new int[2]; |
3006 | 3006 | ||
3007 | float timeStep = 0.1f; | 3007 | float timeStep = 0.1f; |
3008 | pos2.X = pos2.X + (vel.X*timeStep); | 3008 | pos2.X = pos2.X + (vel.X*timeStep); |
3009 | pos2.Y = pos2.Y + (vel.Y*timeStep); | 3009 | pos2.Y = pos2.Y + (vel.Y*timeStep); |
3010 | pos2.Z = pos2.Z + (vel.Z*timeStep); | 3010 | pos2.Z = pos2.Z + (vel.Z*timeStep); |
3011 | 3011 | ||
3012 | if (!IsInTransit) | 3012 | if (!IsInTransit) |
3013 | { | 3013 | { |
3014 | // Checks if where it's headed exists a region | 3014 | // Checks if where it's headed exists a region |
3015 | 3015 | ||
3016 | bool needsTransit = false; | 3016 | bool needsTransit = false; |
3017 | if (m_scene.TestBorderCross(pos2, Cardinals.W)) | 3017 | if (m_scene.TestBorderCross(pos2, Cardinals.W)) |
3018 | { | 3018 | { |
3019 | if (m_scene.TestBorderCross(pos2, Cardinals.S)) | 3019 | if (m_scene.TestBorderCross(pos2, Cardinals.S)) |
3020 | { | 3020 | { |
3021 | needsTransit = true; | 3021 | needsTransit = true; |
3022 | neighbor = HaveNeighbor(Cardinals.SW, ref fix); | 3022 | neighbor = HaveNeighbor(Cardinals.SW, ref fix); |
3023 | } | 3023 | } |
3024 | else if (m_scene.TestBorderCross(pos2, Cardinals.N)) | 3024 | else if (m_scene.TestBorderCross(pos2, Cardinals.N)) |
3025 | { | 3025 | { |
3026 | needsTransit = true; | 3026 | needsTransit = true; |
3027 | neighbor = HaveNeighbor(Cardinals.NW, ref fix); | 3027 | neighbor = HaveNeighbor(Cardinals.NW, ref fix); |
3028 | } | 3028 | } |
3029 | else | 3029 | else |
3030 | { | 3030 | { |
3031 | needsTransit = true; | 3031 | needsTransit = true; |
3032 | neighbor = HaveNeighbor(Cardinals.W, ref fix); | 3032 | neighbor = HaveNeighbor(Cardinals.W, ref fix); |
3033 | } | 3033 | } |
3034 | } | 3034 | } |
3035 | else if (m_scene.TestBorderCross(pos2, Cardinals.E)) | 3035 | else if (m_scene.TestBorderCross(pos2, Cardinals.E)) |
3036 | { | 3036 | { |
3037 | if (m_scene.TestBorderCross(pos2, Cardinals.S)) | 3037 | if (m_scene.TestBorderCross(pos2, Cardinals.S)) |
3038 | { | 3038 | { |
3039 | needsTransit = true; | 3039 | needsTransit = true; |
3040 | neighbor = HaveNeighbor(Cardinals.SE, ref fix); | 3040 | neighbor = HaveNeighbor(Cardinals.SE, ref fix); |
3041 | } | 3041 | } |
3042 | else if (m_scene.TestBorderCross(pos2, Cardinals.N)) | 3042 | else if (m_scene.TestBorderCross(pos2, Cardinals.N)) |
3043 | { | 3043 | { |
3044 | needsTransit = true; | 3044 | needsTransit = true; |
3045 | neighbor = HaveNeighbor(Cardinals.NE, ref fix); | 3045 | neighbor = HaveNeighbor(Cardinals.NE, ref fix); |
3046 | } | 3046 | } |
3047 | else | 3047 | else |
3048 | { | 3048 | { |
3049 | needsTransit = true; | 3049 | needsTransit = true; |
3050 | neighbor = HaveNeighbor(Cardinals.E, ref fix); | 3050 | neighbor = HaveNeighbor(Cardinals.E, ref fix); |
3051 | } | 3051 | } |
3052 | } | 3052 | } |
3053 | else if (m_scene.TestBorderCross(pos2, Cardinals.S)) | 3053 | else if (m_scene.TestBorderCross(pos2, Cardinals.S)) |
3054 | { | 3054 | { |
3055 | needsTransit = true; | 3055 | needsTransit = true; |
3056 | neighbor = HaveNeighbor(Cardinals.S, ref fix); | 3056 | neighbor = HaveNeighbor(Cardinals.S, ref fix); |
3057 | } | 3057 | } |
3058 | else if (m_scene.TestBorderCross(pos2, Cardinals.N)) | 3058 | else if (m_scene.TestBorderCross(pos2, Cardinals.N)) |
3059 | { | 3059 | { |
3060 | needsTransit = true; | 3060 | needsTransit = true; |
3061 | neighbor = HaveNeighbor(Cardinals.N, ref fix); | 3061 | neighbor = HaveNeighbor(Cardinals.N, ref fix); |
3062 | } | 3062 | } |
3063 | 3063 | ||
3064 | 3064 | ||
3065 | // Makes sure avatar does not end up outside region | 3065 | // Makes sure avatar does not end up outside region |
3066 | if (neighbor <= 0) | 3066 | if (neighbor <= 0) |
3067 | { | 3067 | { |
3068 | if (!needsTransit) | 3068 | if (!needsTransit) |
3069 | { | 3069 | { |
3070 | if (m_requestedSitTargetUUID == UUID.Zero) | 3070 | if (m_requestedSitTargetUUID == UUID.Zero) |
3071 | { | 3071 | { |
3072 | Vector3 pos = AbsolutePosition; | 3072 | Vector3 pos = AbsolutePosition; |
3073 | if (AbsolutePosition.X < 0) | 3073 | if (AbsolutePosition.X < 0) |
3074 | pos.X += Velocity.X; | 3074 | pos.X += Velocity.X; |
3075 | else if (AbsolutePosition.X > Constants.RegionSize) | 3075 | else if (AbsolutePosition.X > Constants.RegionSize) |
3076 | pos.X -= Velocity.X; | 3076 | pos.X -= Velocity.X; |
3077 | if (AbsolutePosition.Y < 0) | 3077 | if (AbsolutePosition.Y < 0) |
3078 | pos.Y += Velocity.Y; | 3078 | pos.Y += Velocity.Y; |
3079 | else if (AbsolutePosition.Y > Constants.RegionSize) | 3079 | else if (AbsolutePosition.Y > Constants.RegionSize) |
3080 | pos.Y -= Velocity.Y; | 3080 | pos.Y -= Velocity.Y; |
3081 | AbsolutePosition = pos; | 3081 | AbsolutePosition = pos; |
3082 | } | 3082 | } |
3083 | } | 3083 | } |
3084 | } | 3084 | } |
3085 | else if (neighbor > 0) | 3085 | else if (neighbor > 0) |
3086 | CrossToNewRegion(); | 3086 | CrossToNewRegion(); |
3087 | } | 3087 | } |
3088 | else | 3088 | else |
3089 | { | 3089 | { |
3090 | RemoveFromPhysicalScene(); | 3090 | RemoveFromPhysicalScene(); |
3091 | // This constant has been inferred from experimentation | 3091 | // This constant has been inferred from experimentation |
3092 | // I'm not sure what this value should be, so I tried a few values. | 3092 | // I'm not sure what this value should be, so I tried a few values. |
3093 | timeStep = 0.04f; | 3093 | timeStep = 0.04f; |
3094 | pos2 = AbsolutePosition; | 3094 | pos2 = AbsolutePosition; |
3095 | pos2.X = pos2.X + (vel.X * timeStep); | 3095 | pos2.X = pos2.X + (vel.X * timeStep); |
3096 | pos2.Y = pos2.Y + (vel.Y * timeStep); | 3096 | pos2.Y = pos2.Y + (vel.Y * timeStep); |
3097 | pos2.Z = pos2.Z + (vel.Z * timeStep); | 3097 | pos2.Z = pos2.Z + (vel.Z * timeStep); |
3098 | m_pos = pos2; | 3098 | m_pos = pos2; |
3099 | } | 3099 | } |
3100 | } | 3100 | } |
3101 | 3101 | ||
3102 | protected int HaveNeighbor(Cardinals car, ref int[] fix) | 3102 | protected int HaveNeighbor(Cardinals car, ref int[] fix) |
3103 | { | 3103 | { |
3104 | uint neighbourx = m_regionInfo.RegionLocX; | 3104 | uint neighbourx = m_regionInfo.RegionLocX; |
3105 | uint neighboury = m_regionInfo.RegionLocY; | 3105 | uint neighboury = m_regionInfo.RegionLocY; |
3106 | 3106 | ||
3107 | int dir = (int)car; | 3107 | int dir = (int)car; |
3108 | 3108 | ||
3109 | if (dir > 1 && dir < 5) //Heading East | 3109 | if (dir > 1 && dir < 5) //Heading East |
3110 | neighbourx++; | 3110 | neighbourx++; |
3111 | else if (dir > 5) // Heading West | 3111 | else if (dir > 5) // Heading West |
3112 | neighbourx--; | 3112 | neighbourx--; |
3113 | 3113 | ||
3114 | if (dir < 3 || dir == 8) // Heading North | 3114 | if (dir < 3 || dir == 8) // Heading North |
3115 | neighboury++; | 3115 | neighboury++; |
3116 | else if (dir > 3 && dir < 7) // Heading Sout | 3116 | else if (dir > 3 && dir < 7) // Heading Sout |
3117 | neighboury--; | 3117 | neighboury--; |
3118 | 3118 | ||
3119 | int x = (int)(neighbourx * Constants.RegionSize); | 3119 | int x = (int)(neighbourx * Constants.RegionSize); |
3120 | int y = (int)(neighboury * Constants.RegionSize); | 3120 | int y = (int)(neighboury * Constants.RegionSize); |
3121 | GridRegion neighbourRegion = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, x, y); | 3121 | GridRegion neighbourRegion = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, x, y); |
3122 | 3122 | ||
3123 | if (neighbourRegion == null) | 3123 | if (neighbourRegion == null) |
3124 | { | 3124 | { |
3125 | fix[0] = (int)(m_regionInfo.RegionLocX - neighbourx); | 3125 | fix[0] = (int)(m_regionInfo.RegionLocX - neighbourx); |
3126 | fix[1] = (int)(m_regionInfo.RegionLocY - neighboury); | 3126 | fix[1] = (int)(m_regionInfo.RegionLocY - neighboury); |
3127 | return dir * (-1); | 3127 | return dir * (-1); |
3128 | } | 3128 | } |
3129 | else | 3129 | else |
3130 | return dir; | 3130 | return dir; |
3131 | } | 3131 | } |
3132 | 3132 | ||
3133 | /// <summary> | 3133 | /// <summary> |
3134 | /// Moves the agent outside the region bounds | 3134 | /// Moves the agent outside the region bounds |
3135 | /// Tells neighbor region that we're crossing to it | 3135 | /// Tells neighbor region that we're crossing to it |
3136 | /// If the neighbor accepts, remove the agent's viewable avatar from this scene | 3136 | /// If the neighbor accepts, remove the agent's viewable avatar from this scene |
3137 | /// set them to a child agent. | 3137 | /// set them to a child agent. |
3138 | /// </summary> | 3138 | /// </summary> |
3139 | protected void CrossToNewRegion() | 3139 | protected void CrossToNewRegion() |
3140 | { | 3140 | { |
3141 | InTransit(); | 3141 | InTransit(); |
3142 | try | 3142 | try |
3143 | { | 3143 | { |
3144 | m_scene.CrossAgentToNewRegion(this, m_physicsActor.Flying); | 3144 | m_scene.CrossAgentToNewRegion(this, m_physicsActor.Flying); |
3145 | } | 3145 | } |
3146 | catch | 3146 | catch |
3147 | { | 3147 | { |
3148 | m_scene.CrossAgentToNewRegion(this, false); | 3148 | m_scene.CrossAgentToNewRegion(this, false); |
3149 | } | 3149 | } |
3150 | } | 3150 | } |
3151 | 3151 | ||
3152 | public void InTransit() | 3152 | public void InTransit() |
3153 | { | 3153 | { |
3154 | m_inTransit = true; | 3154 | m_inTransit = true; |
3155 | 3155 | ||
3156 | if ((m_physicsActor != null) && m_physicsActor.Flying) | 3156 | if ((m_physicsActor != null) && m_physicsActor.Flying) |
3157 | m_AgentControlFlags |= AgentManager.ControlFlags.AGENT_CONTROL_FLY; | 3157 | m_AgentControlFlags |= AgentManager.ControlFlags.AGENT_CONTROL_FLY; |
3158 | else if ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0) | 3158 | else if ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0) |
3159 | m_AgentControlFlags &= ~AgentManager.ControlFlags.AGENT_CONTROL_FLY; | 3159 | m_AgentControlFlags &= ~AgentManager.ControlFlags.AGENT_CONTROL_FLY; |
3160 | } | 3160 | } |
3161 | 3161 | ||
3162 | public void NotInTransit() | 3162 | public void NotInTransit() |
3163 | { | 3163 | { |
3164 | m_inTransit = false; | 3164 | m_inTransit = false; |
3165 | } | 3165 | } |
3166 | 3166 | ||
3167 | public void RestoreInCurrentScene() | 3167 | public void RestoreInCurrentScene() |
3168 | { | 3168 | { |
3169 | AddToPhysicalScene(false); // not exactly false | 3169 | AddToPhysicalScene(false); // not exactly false |
3170 | } | 3170 | } |
3171 | 3171 | ||
3172 | public void Reset() | 3172 | public void Reset() |
3173 | { | 3173 | { |
3174 | // Put the child agent back at the center | 3174 | // Put the child agent back at the center |
3175 | AbsolutePosition | 3175 | AbsolutePosition |
3176 | = new Vector3(((float)Constants.RegionSize * 0.5f), ((float)Constants.RegionSize * 0.5f), 70); | 3176 | = new Vector3(((float)Constants.RegionSize * 0.5f), ((float)Constants.RegionSize * 0.5f), 70); |
3177 | Animator.ResetAnimations(); | 3177 | Animator.ResetAnimations(); |
3178 | } | 3178 | } |
3179 | 3179 | ||
3180 | /// <summary> | 3180 | /// <summary> |
3181 | /// Computes which child agents to close when the scene presence moves to another region. | 3181 | /// Computes which child agents to close when the scene presence moves to another region. |
3182 | /// Removes those regions from m_knownRegions. | 3182 | /// Removes those regions from m_knownRegions. |
3183 | /// </summary> | 3183 | /// </summary> |
3184 | /// <param name="newRegionX">The new region's x on the map</param> | 3184 | /// <param name="newRegionX">The new region's x on the map</param> |
3185 | /// <param name="newRegionY">The new region's y on the map</param> | 3185 | /// <param name="newRegionY">The new region's y on the map</param> |
3186 | /// <returns></returns> | 3186 | /// <returns></returns> |
3187 | public void CloseChildAgents(uint newRegionX, uint newRegionY) | 3187 | public void CloseChildAgents(uint newRegionX, uint newRegionY) |
3188 | { | 3188 | { |
3189 | List<ulong> byebyeRegions = new List<ulong>(); | 3189 | List<ulong> byebyeRegions = new List<ulong>(); |
3190 | m_log.DebugFormat( | 3190 | m_log.DebugFormat( |
3191 | "[SCENE PRESENCE]: Closing child agents. Checking {0} regions in {1}", | 3191 | "[SCENE PRESENCE]: Closing child agents. Checking {0} regions in {1}", |
3192 | m_knownChildRegions.Keys.Count, Scene.RegionInfo.RegionName); | 3192 | m_knownChildRegions.Keys.Count, Scene.RegionInfo.RegionName); |
3193 | //DumpKnownRegions(); | 3193 | //DumpKnownRegions(); |
3194 | 3194 | ||
3195 | lock (m_knownChildRegions) | 3195 | lock (m_knownChildRegions) |
3196 | { | 3196 | { |
3197 | foreach (ulong handle in m_knownChildRegions.Keys) | 3197 | foreach (ulong handle in m_knownChildRegions.Keys) |
3198 | { | 3198 | { |
3199 | // Don't close the agent on this region yet | 3199 | // Don't close the agent on this region yet |
3200 | if (handle != Scene.RegionInfo.RegionHandle) | 3200 | if (handle != Scene.RegionInfo.RegionHandle) |
3201 | { | 3201 | { |
3202 | uint x, y; | 3202 | uint x, y; |
3203 | Utils.LongToUInts(handle, out x, out y); | 3203 | Utils.LongToUInts(handle, out x, out y); |
3204 | x = x / Constants.RegionSize; | 3204 | x = x / Constants.RegionSize; |
3205 | y = y / Constants.RegionSize; | 3205 | y = y / Constants.RegionSize; |
3206 | 3206 | ||
3207 | //m_log.Debug("---> x: " + x + "; newx:" + newRegionX + "; Abs:" + (int)Math.Abs((int)(x - newRegionX))); | 3207 | //m_log.Debug("---> x: " + x + "; newx:" + newRegionX + "; Abs:" + (int)Math.Abs((int)(x - newRegionX))); |
3208 | //m_log.Debug("---> y: " + y + "; newy:" + newRegionY + "; Abs:" + (int)Math.Abs((int)(y - newRegionY))); | 3208 | //m_log.Debug("---> y: " + y + "; newy:" + newRegionY + "; Abs:" + (int)Math.Abs((int)(y - newRegionY))); |
3209 | if (Util.IsOutsideView(x, newRegionX, y, newRegionY)) | 3209 | if (Util.IsOutsideView(x, newRegionX, y, newRegionY)) |
3210 | { | 3210 | { |
3211 | byebyeRegions.Add(handle); | 3211 | byebyeRegions.Add(handle); |
3212 | } | 3212 | } |
3213 | } | 3213 | } |
3214 | } | 3214 | } |
3215 | } | 3215 | } |
3216 | 3216 | ||
3217 | if (byebyeRegions.Count > 0) | 3217 | if (byebyeRegions.Count > 0) |
3218 | { | 3218 | { |
3219 | m_log.Debug("[SCENE PRESENCE]: Closing " + byebyeRegions.Count + " child agents"); | 3219 | m_log.Debug("[SCENE PRESENCE]: Closing " + byebyeRegions.Count + " child agents"); |
3220 | m_scene.SceneGridService.SendCloseChildAgentConnections(m_controllingClient.AgentId, byebyeRegions); | 3220 | m_scene.SceneGridService.SendCloseChildAgentConnections(m_controllingClient.AgentId, byebyeRegions); |
3221 | } | 3221 | } |
3222 | 3222 | ||
3223 | foreach (ulong handle in byebyeRegions) | 3223 | foreach (ulong handle in byebyeRegions) |
3224 | { | 3224 | { |
3225 | RemoveNeighbourRegion(handle); | 3225 | RemoveNeighbourRegion(handle); |
3226 | } | 3226 | } |
3227 | } | 3227 | } |
3228 | 3228 | ||
3229 | #endregion | 3229 | #endregion |
3230 | 3230 | ||
3231 | /// <summary> | 3231 | /// <summary> |
3232 | /// This allows the Sim owner the abiility to kick users from their sim currently. | 3232 | /// This allows the Sim owner the abiility to kick users from their sim currently. |
3233 | /// It tells the client that the agent has permission to do so. | 3233 | /// It tells the client that the agent has permission to do so. |
3234 | /// </summary> | 3234 | /// </summary> |
3235 | public void GrantGodlikePowers(UUID agentID, UUID sessionID, UUID token, bool godStatus) | 3235 | public void GrantGodlikePowers(UUID agentID, UUID sessionID, UUID token, bool godStatus) |
3236 | { | 3236 | { |
3237 | if (godStatus) | 3237 | if (godStatus) |
3238 | { | 3238 | { |
3239 | // For now, assign god level 200 to anyone | 3239 | // For now, assign god level 200 to anyone |
3240 | // who is granted god powers, but has no god level set. | 3240 | // who is granted god powers, but has no god level set. |
3241 | // | 3241 | // |
3242 | UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, agentID); | 3242 | UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, agentID); |
3243 | if (account != null) | 3243 | if (account != null) |
3244 | { | 3244 | { |
3245 | if (account.UserLevel > 0) | 3245 | if (account.UserLevel > 0) |
3246 | m_godLevel = account.UserLevel; | 3246 | m_godLevel = account.UserLevel; |
3247 | else | 3247 | else |
3248 | m_godLevel = 200; | 3248 | m_godLevel = 200; |
3249 | } | 3249 | } |
3250 | } | 3250 | } |
3251 | else | 3251 | else |
3252 | { | 3252 | { |
3253 | m_godLevel = 0; | 3253 | m_godLevel = 0; |
3254 | } | 3254 | } |
3255 | 3255 | ||
3256 | ControllingClient.SendAdminResponse(token, (uint)m_godLevel); | 3256 | ControllingClient.SendAdminResponse(token, (uint)m_godLevel); |
3257 | } | 3257 | } |
3258 | 3258 | ||
3259 | #region Child Agent Updates | 3259 | #region Child Agent Updates |
3260 | 3260 | ||
3261 | public void ChildAgentDataUpdate(AgentData cAgentData) | 3261 | public void ChildAgentDataUpdate(AgentData cAgentData) |
3262 | { | 3262 | { |
3263 | //m_log.Debug(" >>> ChildAgentDataUpdate <<< " + Scene.RegionInfo.RegionName); | 3263 | //m_log.Debug(" >>> ChildAgentDataUpdate <<< " + Scene.RegionInfo.RegionName); |
3264 | if (!IsChildAgent) | 3264 | if (!IsChildAgent) |
3265 | return; | 3265 | return; |
3266 | 3266 | ||
3267 | CopyFrom(cAgentData); | 3267 | CopyFrom(cAgentData); |
3268 | } | 3268 | } |
3269 | 3269 | ||
3270 | /// <summary> | 3270 | /// <summary> |
3271 | /// This updates important decision making data about a child agent | 3271 | /// This updates important decision making data about a child agent |
3272 | /// The main purpose is to figure out what objects to send to a child agent that's in a neighboring region | 3272 | /// The main purpose is to figure out what objects to send to a child agent that's in a neighboring region |
3273 | /// </summary> | 3273 | /// </summary> |
3274 | public void ChildAgentDataUpdate(AgentPosition cAgentData, uint tRegionX, uint tRegionY, uint rRegionX, uint rRegionY) | 3274 | public void ChildAgentDataUpdate(AgentPosition cAgentData, uint tRegionX, uint tRegionY, uint rRegionX, uint rRegionY) |
3275 | { | 3275 | { |
3276 | if (!IsChildAgent) | 3276 | if (!IsChildAgent) |
3277 | return; | 3277 | return; |
3278 | 3278 | ||
3279 | //m_log.Debug(" >>> ChildAgentPositionUpdate <<< " + rRegionX + "-" + rRegionY); | 3279 | //m_log.Debug(" >>> ChildAgentPositionUpdate <<< " + rRegionX + "-" + rRegionY); |
3280 | int shiftx = ((int)rRegionX - (int)tRegionX) * (int)Constants.RegionSize; | 3280 | int shiftx = ((int)rRegionX - (int)tRegionX) * (int)Constants.RegionSize; |
3281 | int shifty = ((int)rRegionY - (int)tRegionY) * (int)Constants.RegionSize; | 3281 | int shifty = ((int)rRegionY - (int)tRegionY) * (int)Constants.RegionSize; |
3282 | 3282 | ||
3283 | Vector3 offset = new Vector3(shiftx, shifty, 0f); | 3283 | Vector3 offset = new Vector3(shiftx, shifty, 0f); |
3284 | 3284 | ||
3285 | m_DrawDistance = cAgentData.Far; | 3285 | m_DrawDistance = cAgentData.Far; |
3286 | if (cAgentData.Position != new Vector3(-1f, -1f, -1f)) // UGH!! | 3286 | if (cAgentData.Position != new Vector3(-1f, -1f, -1f)) // UGH!! |
3287 | m_pos = cAgentData.Position + offset; | 3287 | m_pos = cAgentData.Position + offset; |
3288 | 3288 | ||
3289 | if (Vector3.Distance(AbsolutePosition, posLastSignificantMove) >= Scene.ChildReprioritizationDistance) | 3289 | if (Vector3.Distance(AbsolutePosition, posLastSignificantMove) >= Scene.ChildReprioritizationDistance) |
3290 | { | 3290 | { |
3291 | posLastSignificantMove = AbsolutePosition; | 3291 | posLastSignificantMove = AbsolutePosition; |
3292 | ReprioritizeUpdates(); | 3292 | ReprioritizeUpdates(); |
3293 | } | 3293 | } |
3294 | 3294 | ||
3295 | m_CameraCenter = cAgentData.Center + offset; | 3295 | m_CameraCenter = cAgentData.Center + offset; |
3296 | 3296 | ||
3297 | m_avHeight = cAgentData.Size.Z; | 3297 | m_avHeight = cAgentData.Size.Z; |
3298 | //SetHeight(cAgentData.AVHeight); | 3298 | //SetHeight(cAgentData.AVHeight); |
3299 | 3299 | ||
3300 | if ((cAgentData.Throttles != null) && cAgentData.Throttles.Length > 0) | 3300 | if ((cAgentData.Throttles != null) && cAgentData.Throttles.Length > 0) |
3301 | ControllingClient.SetChildAgentThrottle(cAgentData.Throttles); | 3301 | ControllingClient.SetChildAgentThrottle(cAgentData.Throttles); |
3302 | 3302 | ||
3303 | // Sends out the objects in the user's draw distance if m_sendTasksToChild is true. | 3303 | // Sends out the objects in the user's draw distance if m_sendTasksToChild is true. |
3304 | if (m_scene.m_seeIntoRegionFromNeighbor) | 3304 | if (m_scene.m_seeIntoRegionFromNeighbor) |
3305 | m_sceneViewer.Reset(); | 3305 | m_sceneViewer.Reset(); |
3306 | 3306 | ||
3307 | //cAgentData.AVHeight; | 3307 | //cAgentData.AVHeight; |
3308 | m_rootRegionHandle = cAgentData.RegionHandle; | 3308 | m_rootRegionHandle = cAgentData.RegionHandle; |
3309 | //m_velocity = cAgentData.Velocity; | 3309 | //m_velocity = cAgentData.Velocity; |
3310 | } | 3310 | } |
3311 | 3311 | ||
3312 | public void CopyTo(AgentData cAgent) | 3312 | public void CopyTo(AgentData cAgent) |
3313 | { | 3313 | { |
3314 | cAgent.AgentID = UUID; | 3314 | cAgent.AgentID = UUID; |
3315 | cAgent.RegionID = Scene.RegionInfo.RegionID; | 3315 | cAgent.RegionID = Scene.RegionInfo.RegionID; |
3316 | 3316 | ||
3317 | cAgent.Position = AbsolutePosition; | 3317 | cAgent.Position = AbsolutePosition; |
3318 | cAgent.Velocity = m_velocity; | 3318 | cAgent.Velocity = m_velocity; |
3319 | cAgent.Center = m_CameraCenter; | 3319 | cAgent.Center = m_CameraCenter; |
3320 | // Don't copy the size; it is inferred from apearance parameters | 3320 | // Don't copy the size; it is inferred from apearance parameters |
3321 | //cAgent.Size = new Vector3(0, 0, m_avHeight); | 3321 | //cAgent.Size = new Vector3(0, 0, m_avHeight); |
3322 | cAgent.AtAxis = m_CameraAtAxis; | 3322 | cAgent.AtAxis = m_CameraAtAxis; |
3323 | cAgent.LeftAxis = m_CameraLeftAxis; | 3323 | cAgent.LeftAxis = m_CameraLeftAxis; |
3324 | cAgent.UpAxis = m_CameraUpAxis; | 3324 | cAgent.UpAxis = m_CameraUpAxis; |
3325 | 3325 | ||
3326 | cAgent.Far = m_DrawDistance; | 3326 | cAgent.Far = m_DrawDistance; |
3327 | 3327 | ||
3328 | // Throttles | 3328 | // Throttles |
3329 | float multiplier = 1; | 3329 | float multiplier = 1; |
3330 | int innacurateNeighbors = m_scene.GetInaccurateNeighborCount(); | 3330 | int innacurateNeighbors = m_scene.GetInaccurateNeighborCount(); |
3331 | if (innacurateNeighbors != 0) | 3331 | if (innacurateNeighbors != 0) |
3332 | { | 3332 | { |
3333 | multiplier = 1f / innacurateNeighbors; | 3333 | multiplier = 1f / innacurateNeighbors; |
3334 | } | 3334 | } |
3335 | if (multiplier <= 0f) | 3335 | if (multiplier <= 0f) |
3336 | { | 3336 | { |
3337 | multiplier = 0.25f; | 3337 | multiplier = 0.25f; |
3338 | } | 3338 | } |
3339 | //m_log.Info("[NeighborThrottle]: " + m_scene.GetInaccurateNeighborCount().ToString() + " - m: " + multiplier.ToString()); | 3339 | //m_log.Info("[NeighborThrottle]: " + m_scene.GetInaccurateNeighborCount().ToString() + " - m: " + multiplier.ToString()); |
3340 | cAgent.Throttles = ControllingClient.GetThrottlesPacked(multiplier); | 3340 | cAgent.Throttles = ControllingClient.GetThrottlesPacked(multiplier); |
3341 | 3341 | ||
3342 | cAgent.HeadRotation = m_headrotation; | 3342 | cAgent.HeadRotation = m_headrotation; |
3343 | cAgent.BodyRotation = m_bodyRot; | 3343 | cAgent.BodyRotation = m_bodyRot; |
3344 | cAgent.ControlFlags = (uint)m_AgentControlFlags; | 3344 | cAgent.ControlFlags = (uint)m_AgentControlFlags; |
3345 | 3345 | ||
3346 | if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID))) | 3346 | if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID))) |
3347 | cAgent.GodLevel = (byte)m_godLevel; | 3347 | cAgent.GodLevel = (byte)m_godLevel; |
3348 | else | 3348 | else |
3349 | cAgent.GodLevel = (byte) 0; | 3349 | cAgent.GodLevel = (byte) 0; |
3350 | 3350 | ||
3351 | cAgent.AlwaysRun = m_setAlwaysRun; | 3351 | cAgent.AlwaysRun = m_setAlwaysRun; |
3352 | 3352 | ||
3353 | try | 3353 | try |
3354 | { | 3354 | { |
3355 | // We might not pass the Wearables in all cases... | 3355 | // We might not pass the Wearables in all cases... |
3356 | // They're only needed so that persistent changes to the appearance | 3356 | // They're only needed so that persistent changes to the appearance |
3357 | // are preserved in the new region where the user is moving to. | 3357 | // are preserved in the new region where the user is moving to. |
3358 | // But in Hypergrid we might not let this happen. | 3358 | // But in Hypergrid we might not let this happen. |
3359 | int i = 0; | 3359 | int i = 0; |
3360 | UUID[] wears = new UUID[m_appearance.Wearables.Length * 2]; | 3360 | UUID[] wears = new UUID[m_appearance.Wearables.Length * 2]; |
3361 | foreach (AvatarWearable aw in m_appearance.Wearables) | 3361 | foreach (AvatarWearable aw in m_appearance.Wearables) |
3362 | { | 3362 | { |
3363 | if (aw != null) | 3363 | if (aw != null) |
3364 | { | 3364 | { |
3365 | wears[i++] = aw.ItemID; | 3365 | wears[i++] = aw.ItemID; |
3366 | wears[i++] = aw.AssetID; | 3366 | wears[i++] = aw.AssetID; |
3367 | } | 3367 | } |
3368 | else | 3368 | else |
3369 | { | 3369 | { |
3370 | wears[i++] = UUID.Zero; | 3370 | wears[i++] = UUID.Zero; |
3371 | wears[i++] = UUID.Zero; | 3371 | wears[i++] = UUID.Zero; |
3372 | } | 3372 | } |
3373 | } | 3373 | } |
3374 | cAgent.Wearables = wears; | 3374 | cAgent.Wearables = wears; |
3375 | 3375 | ||
3376 | cAgent.VisualParams = m_appearance.VisualParams; | 3376 | cAgent.VisualParams = m_appearance.VisualParams; |
3377 | 3377 | ||
3378 | if (m_appearance.Texture != null) | 3378 | if (m_appearance.Texture != null) |
3379 | cAgent.AgentTextures = m_appearance.Texture.GetBytes(); | 3379 | cAgent.AgentTextures = m_appearance.Texture.GetBytes(); |
3380 | } | 3380 | } |
3381 | catch (Exception e) | 3381 | catch (Exception e) |
3382 | { | 3382 | { |
3383 | m_log.Warn("[SCENE PRESENCE]: exception in CopyTo " + e.Message); | 3383 | m_log.Warn("[SCENE PRESENCE]: exception in CopyTo " + e.Message); |
3384 | } | 3384 | } |
3385 | 3385 | ||
3386 | //Attachments | 3386 | //Attachments |
3387 | List<int> attPoints = m_appearance.GetAttachedPoints(); | 3387 | List<int> attPoints = m_appearance.GetAttachedPoints(); |
3388 | if (attPoints != null) | 3388 | if (attPoints != null) |
3389 | { | 3389 | { |
3390 | //m_log.DebugFormat("[SCENE PRESENCE]: attachments {0}", attPoints.Count); | 3390 | //m_log.DebugFormat("[SCENE PRESENCE]: attachments {0}", attPoints.Count); |
3391 | int i = 0; | 3391 | int i = 0; |
3392 | AttachmentData[] attachs = new AttachmentData[attPoints.Count]; | 3392 | AttachmentData[] attachs = new AttachmentData[attPoints.Count]; |
3393 | foreach (int point in attPoints) | 3393 | foreach (int point in attPoints) |
3394 | { | 3394 | { |
3395 | attachs[i++] = new AttachmentData(point, m_appearance.GetAttachedItem(point), m_appearance.GetAttachedAsset(point)); | 3395 | attachs[i++] = new AttachmentData(point, m_appearance.GetAttachedItem(point), m_appearance.GetAttachedAsset(point)); |
3396 | } | 3396 | } |
3397 | cAgent.Attachments = attachs; | 3397 | cAgent.Attachments = attachs; |
3398 | } | 3398 | } |
3399 | 3399 | ||
3400 | lock (scriptedcontrols) | 3400 | lock (scriptedcontrols) |
3401 | { | 3401 | { |
3402 | ControllerData[] controls = new ControllerData[scriptedcontrols.Count]; | 3402 | ControllerData[] controls = new ControllerData[scriptedcontrols.Count]; |
3403 | int i = 0; | 3403 | int i = 0; |
3404 | 3404 | ||
3405 | foreach (ScriptControllers c in scriptedcontrols.Values) | 3405 | foreach (ScriptControllers c in scriptedcontrols.Values) |
3406 | { | 3406 | { |
3407 | controls[i++] = new ControllerData(c.itemID, (uint)c.ignoreControls, (uint)c.eventControls); | 3407 | controls[i++] = new ControllerData(c.itemID, (uint)c.ignoreControls, (uint)c.eventControls); |
3408 | } | 3408 | } |
3409 | cAgent.Controllers = controls; | 3409 | cAgent.Controllers = controls; |
3410 | } | 3410 | } |
3411 | 3411 | ||
3412 | // Animations | 3412 | // Animations |
3413 | try | 3413 | try |
3414 | { | 3414 | { |
3415 | cAgent.Anims = Animator.Animations.ToArray(); | 3415 | cAgent.Anims = Animator.Animations.ToArray(); |
3416 | } | 3416 | } |
3417 | catch { } | 3417 | catch { } |
3418 | 3418 | ||
3419 | // cAgent.GroupID = ?? | 3419 | // cAgent.GroupID = ?? |
3420 | // Groups??? | 3420 | // Groups??? |
3421 | 3421 | ||
3422 | } | 3422 | } |
3423 | 3423 | ||
3424 | public void CopyFrom(AgentData cAgent) | 3424 | public void CopyFrom(AgentData cAgent) |
3425 | { | 3425 | { |
3426 | m_originRegionID = cAgent.RegionID; | 3426 | m_originRegionID = cAgent.RegionID; |
3427 | 3427 | ||
3428 | m_callbackURI = cAgent.CallbackURI; | 3428 | m_callbackURI = cAgent.CallbackURI; |
3429 | 3429 | ||
3430 | m_pos = cAgent.Position; | 3430 | m_pos = cAgent.Position; |
3431 | 3431 | ||
3432 | m_velocity = cAgent.Velocity; | 3432 | m_velocity = cAgent.Velocity; |
3433 | m_CameraCenter = cAgent.Center; | 3433 | m_CameraCenter = cAgent.Center; |
3434 | //m_avHeight = cAgent.Size.Z; | 3434 | //m_avHeight = cAgent.Size.Z; |
3435 | m_CameraAtAxis = cAgent.AtAxis; | 3435 | m_CameraAtAxis = cAgent.AtAxis; |
3436 | m_CameraLeftAxis = cAgent.LeftAxis; | 3436 | m_CameraLeftAxis = cAgent.LeftAxis; |
3437 | m_CameraUpAxis = cAgent.UpAxis; | 3437 | m_CameraUpAxis = cAgent.UpAxis; |
3438 | 3438 | ||
3439 | m_DrawDistance = cAgent.Far; | 3439 | m_DrawDistance = cAgent.Far; |
3440 | 3440 | ||
3441 | if ((cAgent.Throttles != null) && cAgent.Throttles.Length > 0) | 3441 | if ((cAgent.Throttles != null) && cAgent.Throttles.Length > 0) |
3442 | ControllingClient.SetChildAgentThrottle(cAgent.Throttles); | 3442 | ControllingClient.SetChildAgentThrottle(cAgent.Throttles); |
3443 | 3443 | ||
3444 | m_headrotation = cAgent.HeadRotation; | 3444 | m_headrotation = cAgent.HeadRotation; |
3445 | m_bodyRot = cAgent.BodyRotation; | 3445 | m_bodyRot = cAgent.BodyRotation; |
3446 | m_AgentControlFlags = (AgentManager.ControlFlags)cAgent.ControlFlags; | 3446 | m_AgentControlFlags = (AgentManager.ControlFlags)cAgent.ControlFlags; |
3447 | 3447 | ||
3448 | if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID))) | 3448 | if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID))) |
3449 | m_godLevel = cAgent.GodLevel; | 3449 | m_godLevel = cAgent.GodLevel; |
3450 | m_setAlwaysRun = cAgent.AlwaysRun; | 3450 | m_setAlwaysRun = cAgent.AlwaysRun; |
3451 | 3451 | ||
3452 | uint i = 0; | 3452 | uint i = 0; |
3453 | try | 3453 | try |
3454 | { | 3454 | { |
3455 | if (cAgent.Wearables == null) | 3455 | if (cAgent.Wearables == null) |
3456 | cAgent.Wearables = new UUID[0]; | 3456 | cAgent.Wearables = new UUID[0]; |
3457 | AvatarWearable[] wears = new AvatarWearable[cAgent.Wearables.Length / 2]; | 3457 | AvatarWearable[] wears = new AvatarWearable[cAgent.Wearables.Length / 2]; |
3458 | for (uint n = 0; n < cAgent.Wearables.Length; n += 2) | 3458 | for (uint n = 0; n < cAgent.Wearables.Length; n += 2) |
3459 | { | 3459 | { |
3460 | UUID itemId = cAgent.Wearables[n]; | 3460 | UUID itemId = cAgent.Wearables[n]; |
3461 | UUID assetId = cAgent.Wearables[n + 1]; | 3461 | UUID assetId = cAgent.Wearables[n + 1]; |
3462 | wears[i++] = new AvatarWearable(itemId, assetId); | 3462 | wears[i++] = new AvatarWearable(itemId, assetId); |
3463 | } | 3463 | } |
3464 | m_appearance.Wearables = wears; | 3464 | m_appearance.Wearables = wears; |
3465 | Primitive.TextureEntry te; | 3465 | Primitive.TextureEntry te; |
3466 | if (cAgent.AgentTextures != null && cAgent.AgentTextures.Length > 1) | 3466 | if (cAgent.AgentTextures != null && cAgent.AgentTextures.Length > 1) |
3467 | te = new Primitive.TextureEntry(cAgent.AgentTextures, 0, cAgent.AgentTextures.Length); | 3467 | te = new Primitive.TextureEntry(cAgent.AgentTextures, 0, cAgent.AgentTextures.Length); |
3468 | else | 3468 | else |
3469 | te = AvatarAppearance.GetDefaultTexture(); | 3469 | te = AvatarAppearance.GetDefaultTexture(); |
3470 | if ((cAgent.VisualParams == null) || (cAgent.VisualParams.Length < AvatarAppearance.VISUALPARAM_COUNT)) | 3470 | if ((cAgent.VisualParams == null) || (cAgent.VisualParams.Length < AvatarAppearance.VISUALPARAM_COUNT)) |
3471 | cAgent.VisualParams = AvatarAppearance.GetDefaultVisualParams(); | 3471 | cAgent.VisualParams = AvatarAppearance.GetDefaultVisualParams(); |
3472 | m_appearance.SetAppearance(te, (byte[])cAgent.VisualParams.Clone()); | 3472 | m_appearance.SetAppearance(te, (byte[])cAgent.VisualParams.Clone()); |
3473 | } | 3473 | } |
3474 | catch (Exception e) | 3474 | catch (Exception e) |
3475 | { | 3475 | { |
3476 | m_log.Warn("[SCENE PRESENCE]: exception in CopyFrom " + e.Message); | 3476 | m_log.Warn("[SCENE PRESENCE]: exception in CopyFrom " + e.Message); |
3477 | } | 3477 | } |
3478 | 3478 | ||
3479 | // Attachments | 3479 | // Attachments |
3480 | try | 3480 | try |
3481 | { | 3481 | { |
3482 | if (cAgent.Attachments != null) | 3482 | if (cAgent.Attachments != null) |
3483 | { | 3483 | { |
3484 | m_appearance.ClearAttachments(); | 3484 | m_appearance.ClearAttachments(); |
3485 | foreach (AttachmentData att in cAgent.Attachments) | 3485 | foreach (AttachmentData att in cAgent.Attachments) |
3486 | { | 3486 | { |
3487 | m_appearance.SetAttachment(att.AttachPoint, att.ItemID, att.AssetID); | 3487 | m_appearance.SetAttachment(att.AttachPoint, att.ItemID, att.AssetID); |
3488 | } | 3488 | } |
3489 | } | 3489 | } |
3490 | } | 3490 | } |
3491 | catch { } | 3491 | catch { } |
3492 | 3492 | ||
3493 | try | 3493 | try |
3494 | { | 3494 | { |
3495 | lock (scriptedcontrols) | 3495 | lock (scriptedcontrols) |
3496 | { | 3496 | { |
3497 | if (cAgent.Controllers != null) | 3497 | if (cAgent.Controllers != null) |
3498 | { | 3498 | { |
3499 | scriptedcontrols.Clear(); | 3499 | scriptedcontrols.Clear(); |
3500 | 3500 | ||
3501 | foreach (ControllerData c in cAgent.Controllers) | 3501 | foreach (ControllerData c in cAgent.Controllers) |
3502 | { | 3502 | { |
3503 | ScriptControllers sc = new ScriptControllers(); | 3503 | ScriptControllers sc = new ScriptControllers(); |
3504 | sc.itemID = c.ItemID; | 3504 | sc.itemID = c.ItemID; |
3505 | sc.ignoreControls = (ScriptControlled)c.IgnoreControls; | 3505 | sc.ignoreControls = (ScriptControlled)c.IgnoreControls; |
3506 | sc.eventControls = (ScriptControlled)c.EventControls; | 3506 | sc.eventControls = (ScriptControlled)c.EventControls; |
3507 | 3507 | ||
3508 | scriptedcontrols[sc.itemID] = sc; | 3508 | scriptedcontrols[sc.itemID] = sc; |
3509 | } | 3509 | } |
3510 | } | 3510 | } |
3511 | } | 3511 | } |
3512 | } | 3512 | } |
3513 | catch { } | 3513 | catch { } |
3514 | // Animations | 3514 | // Animations |
3515 | try | 3515 | try |
3516 | { | 3516 | { |
3517 | Animator.ResetAnimations(); | 3517 | Animator.ResetAnimations(); |
3518 | Animator.Animations.FromArray(cAgent.Anims); | 3518 | Animator.Animations.FromArray(cAgent.Anims); |
3519 | } | 3519 | } |
3520 | catch { } | 3520 | catch { } |
3521 | 3521 | ||
3522 | //cAgent.GroupID = ?? | 3522 | //cAgent.GroupID = ?? |
3523 | //Groups??? | 3523 | //Groups??? |
3524 | } | 3524 | } |
3525 | 3525 | ||
3526 | public bool CopyAgent(out IAgentData agent) | 3526 | public bool CopyAgent(out IAgentData agent) |
3527 | { | 3527 | { |
3528 | agent = new CompleteAgentData(); | 3528 | agent = new CompleteAgentData(); |
3529 | CopyTo((AgentData)agent); | 3529 | CopyTo((AgentData)agent); |
3530 | return true; | 3530 | return true; |
3531 | } | 3531 | } |
3532 | 3532 | ||
3533 | #endregion Child Agent Updates | 3533 | #endregion Child Agent Updates |
3534 | 3534 | ||
3535 | /// <summary> | 3535 | /// <summary> |
3536 | /// Handles part of the PID controller function for moving an avatar. | 3536 | /// Handles part of the PID controller function for moving an avatar. |
3537 | /// </summary> | 3537 | /// </summary> |
3538 | public override void UpdateMovement() | 3538 | public override void UpdateMovement() |
3539 | { | 3539 | { |
3540 | if (m_forceToApply.HasValue) | 3540 | if (m_forceToApply.HasValue) |
3541 | { | 3541 | { |
3542 | 3542 | ||
3543 | Vector3 force = m_forceToApply.Value; | 3543 | Vector3 force = m_forceToApply.Value; |
3544 | m_updateflag = true; | 3544 | m_updateflag = true; |
3545 | Velocity = force; | 3545 | Velocity = force; |
3546 | 3546 | ||
3547 | m_forceToApply = null; | 3547 | m_forceToApply = null; |
3548 | } | 3548 | } |
3549 | else | 3549 | else |
3550 | { | 3550 | { |
3551 | if (m_isNudging) | 3551 | if (m_isNudging) |
3552 | { | 3552 | { |
3553 | Vector3 force = Vector3.Zero; | 3553 | Vector3 force = Vector3.Zero; |
3554 | 3554 | ||
3555 | m_updateflag = true; | 3555 | m_updateflag = true; |
3556 | Velocity = force; | 3556 | Velocity = force; |
3557 | m_isNudging = false; | 3557 | m_isNudging = false; |
3558 | m_updateCount = UPDATE_COUNT; //KF: Update anims to pickup "STAND" | 3558 | m_updateCount = UPDATE_COUNT; //KF: Update anims to pickup "STAND" |
3559 | } | 3559 | } |
3560 | } | 3560 | } |
3561 | } | 3561 | } |
3562 | 3562 | ||
3563 | public override void SetText(string text, Vector3 color, double alpha) | 3563 | /// <summary> |
3564 | { | 3564 | /// Adds a physical representation of the avatar to the Physics plugin |
3565 | throw new Exception("Can't set Text on avatar."); | 3565 | /// </summary> |
3566 | } | 3566 | public void AddToPhysicalScene(bool isFlying) |
3567 | 3567 | { | |
3568 | /// <summary> | 3568 | PhysicsScene scene = m_scene.PhysicsScene; |
3569 | /// Adds a physical representation of the avatar to the Physics plugin | 3569 | |
3570 | /// </summary> | 3570 | Vector3 pVec = AbsolutePosition; |
3571 | public void AddToPhysicalScene(bool isFlying) | 3571 | |
3572 | { | 3572 | // Old bug where the height was in centimeters instead of meters |
3573 | PhysicsScene scene = m_scene.PhysicsScene; | 3573 | if (m_avHeight == 127.0f) |
3574 | 3574 | { | |
3575 | Vector3 pVec = AbsolutePosition; | 3575 | m_physicsActor = scene.AddAvatar(Firstname + "." + Lastname, pVec, new Vector3(0f, 0f, 1.56f), |
3576 | 3576 | isFlying); | |
3577 | // Old bug where the height was in centimeters instead of meters | 3577 | } |
3578 | if (m_avHeight == 127.0f) | 3578 | else |
3579 | { | 3579 | { |
3580 | m_physicsActor = scene.AddAvatar(Firstname + "." + Lastname, pVec, new Vector3(0f, 0f, 1.56f), | 3580 | m_physicsActor = scene.AddAvatar(Firstname + "." + Lastname, pVec, |
3581 | isFlying); | 3581 | new Vector3(0f, 0f, m_avHeight), isFlying); |
3582 | } | 3582 | } |
3583 | else | 3583 | scene.AddPhysicsActorTaint(m_physicsActor); |
3584 | { | 3584 | //m_physicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; |
3585 | m_physicsActor = scene.AddAvatar(Firstname + "." + Lastname, pVec, | 3585 | m_physicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; |
3586 | new Vector3(0f, 0f, m_avHeight), isFlying); | 3586 | m_physicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong |
3587 | } | 3587 | m_physicsActor.SubscribeEvents(500); |
3588 | scene.AddPhysicsActorTaint(m_physicsActor); | 3588 | m_physicsActor.LocalID = LocalId; |
3589 | //m_physicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; | 3589 | } |
3590 | m_physicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; | 3590 | |
3591 | m_physicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong | 3591 | private void OutOfBoundsCall(Vector3 pos) |
3592 | m_physicsActor.SubscribeEvents(500); | 3592 | { |
3593 | m_physicsActor.LocalID = LocalId; | 3593 | //bool flying = m_physicsActor.Flying; |
3594 | } | 3594 | //RemoveFromPhysicalScene(); |
3595 | 3595 | ||
3596 | private void OutOfBoundsCall(Vector3 pos) | 3596 | //AddToPhysicalScene(flying); |
3597 | { | 3597 | if (ControllingClient != null) |
3598 | //bool flying = m_physicsActor.Flying; | 3598 | ControllingClient.SendAgentAlertMessage("Physics is having a problem with your avatar. You may not be able to move until you relog.", true); |
3599 | //RemoveFromPhysicalScene(); | 3599 | } |
3600 | 3600 | ||
3601 | //AddToPhysicalScene(flying); | 3601 | // Event called by the physics plugin to tell the avatar about a collision. |
3602 | if (ControllingClient != null) | 3602 | private void PhysicsCollisionUpdate(EventArgs e) |
3603 | ControllingClient.SendAgentAlertMessage("Physics is having a problem with your avatar. You may not be able to move until you relog.", true); | 3603 | { |
3604 | } | 3604 | if (e == null) |
3605 | 3605 | return; | |
3606 | // Event called by the physics plugin to tell the avatar about a collision. | 3606 | |
3607 | private void PhysicsCollisionUpdate(EventArgs e) | 3607 | // The Physics Scene will send (spam!) updates every 500 ms grep: m_physicsActor.SubscribeEvents( |
3608 | { | 3608 | // as of this comment the interval is set in AddToPhysicalScene |
3609 | if (e == null) | 3609 | if (Animator!=null) |
3610 | return; | 3610 | { |
3611 | 3611 | if (m_updateCount > 0) //KF: DO NOT call UpdateMovementAnimations outside of the m_updateCount wrapper, | |
3612 | // The Physics Scene will send (spam!) updates every 500 ms grep: m_physicsActor.SubscribeEvents( | 3612 | { // else its will lock out other animation changes, like ground sit. |
3613 | // as of this comment the interval is set in AddToPhysicalScene | 3613 | Animator.UpdateMovementAnimations(); |
3614 | if (Animator!=null) | 3614 | m_updateCount--; |
3615 | { | 3615 | } |
3616 | if (m_updateCount > 0) //KF: DO NOT call UpdateMovementAnimations outside of the m_updateCount wrapper, | 3616 | } |
3617 | { // else its will lock out other animation changes, like ground sit. | 3617 | |
3618 | Animator.UpdateMovementAnimations(); | 3618 | CollisionEventUpdate collisionData = (CollisionEventUpdate)e; |
3619 | m_updateCount--; | 3619 | Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList; |
3620 | } | 3620 | |
3621 | } | 3621 | CollisionPlane = Vector4.UnitW; |
3622 | 3622 | ||
3623 | CollisionEventUpdate collisionData = (CollisionEventUpdate)e; | 3623 | if (m_lastColCount != coldata.Count) |
3624 | Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList; | 3624 | { |
3625 | 3625 | m_updateCount = UPDATE_COUNT; | |
3626 | CollisionPlane = Vector4.UnitW; | 3626 | m_lastColCount = coldata.Count; |
3627 | 3627 | } | |
3628 | if (m_lastColCount != coldata.Count) | 3628 | |
3629 | { | 3629 | if (coldata.Count != 0 && Animator != null) |
3630 | m_updateCount = UPDATE_COUNT; | 3630 | { |
3631 | m_lastColCount = coldata.Count; | 3631 | switch (Animator.CurrentMovementAnimation) |
3632 | } | 3632 | { |
3633 | 3633 | case "STAND": | |
3634 | if (coldata.Count != 0 && Animator != null) | 3634 | case "WALK": |
3635 | { | 3635 | case "RUN": |
3636 | switch (Animator.CurrentMovementAnimation) | 3636 | case "CROUCH": |
3637 | { | 3637 | case "CROUCHWALK": |
3638 | case "STAND": | 3638 | { |
3639 | case "WALK": | 3639 | ContactPoint lowest; |
3640 | case "RUN": | 3640 | lowest.SurfaceNormal = Vector3.Zero; |
3641 | case "CROUCH": | 3641 | lowest.Position = Vector3.Zero; |
3642 | case "CROUCHWALK": | 3642 | lowest.Position.Z = Single.NaN; |
3643 | { | 3643 | |
3644 | ContactPoint lowest; | 3644 | foreach (ContactPoint contact in coldata.Values) |
3645 | lowest.SurfaceNormal = Vector3.Zero; | 3645 | { |
3646 | lowest.Position = Vector3.Zero; | 3646 | if (Single.IsNaN(lowest.Position.Z) || contact.Position.Z < lowest.Position.Z) |
3647 | lowest.Position.Z = Single.NaN; | 3647 | { |
3648 | 3648 | lowest = contact; | |
3649 | foreach (ContactPoint contact in coldata.Values) | 3649 | } |
3650 | { | 3650 | } |
3651 | if (Single.IsNaN(lowest.Position.Z) || contact.Position.Z < lowest.Position.Z) | 3651 | |
3652 | { | 3652 | CollisionPlane = new Vector4(-lowest.SurfaceNormal, -Vector3.Dot(lowest.Position, lowest.SurfaceNormal)); |
3653 | lowest = contact; | 3653 | } |
3654 | } | 3654 | break; |
3655 | } | 3655 | } |
3656 | 3656 | } | |
3657 | CollisionPlane = new Vector4(-lowest.SurfaceNormal, -Vector3.Dot(lowest.Position, lowest.SurfaceNormal)); | 3657 | |
3658 | } | 3658 | List<uint> thisHitColliders = new List<uint>(); |
3659 | break; | 3659 | List<uint> endedColliders = new List<uint>(); |
3660 | } | 3660 | List<uint> startedColliders = new List<uint>(); |
3661 | } | 3661 | |
3662 | 3662 | foreach (uint localid in coldata.Keys) | |
3663 | List<uint> thisHitColliders = new List<uint>(); | 3663 | { |
3664 | List<uint> endedColliders = new List<uint>(); | 3664 | thisHitColliders.Add(localid); |
3665 | List<uint> startedColliders = new List<uint>(); | 3665 | if (!m_lastColliders.Contains(localid)) |
3666 | 3666 | { | |
3667 | foreach (uint localid in coldata.Keys) | 3667 | startedColliders.Add(localid); |
3668 | { | 3668 | } |
3669 | thisHitColliders.Add(localid); | 3669 | //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); |
3670 | if (!m_lastColliders.Contains(localid)) | 3670 | } |
3671 | { | 3671 | |
3672 | startedColliders.Add(localid); | 3672 | // calculate things that ended colliding |
3673 | } | 3673 | foreach (uint localID in m_lastColliders) |
3674 | //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); | 3674 | { |
3675 | } | 3675 | if (!thisHitColliders.Contains(localID)) |
3676 | 3676 | { | |
3677 | // calculate things that ended colliding | 3677 | endedColliders.Add(localID); |
3678 | foreach (uint localID in m_lastColliders) | 3678 | } |
3679 | { | 3679 | } |
3680 | if (!thisHitColliders.Contains(localID)) | 3680 | //add the items that started colliding this time to the last colliders list. |
3681 | { | 3681 | foreach (uint localID in startedColliders) |
3682 | endedColliders.Add(localID); | 3682 | { |
3683 | } | 3683 | m_lastColliders.Add(localID); |
3684 | } | 3684 | } |
3685 | //add the items that started colliding this time to the last colliders list. | 3685 | // remove things that ended colliding from the last colliders list |
3686 | foreach (uint localID in startedColliders) | 3686 | foreach (uint localID in endedColliders) |
3687 | { | 3687 | { |
3688 | m_lastColliders.Add(localID); | 3688 | m_lastColliders.Remove(localID); |
3689 | } | 3689 | } |
3690 | // remove things that ended colliding from the last colliders list | 3690 | |
3691 | foreach (uint localID in endedColliders) | 3691 | // do event notification |
3692 | { | 3692 | if (startedColliders.Count > 0) |
3693 | m_lastColliders.Remove(localID); | 3693 | { |
3694 | } | 3694 | ColliderArgs StartCollidingMessage = new ColliderArgs(); |
3695 | 3695 | List<DetectedObject> colliding = new List<DetectedObject>(); | |
3696 | // do event notification | 3696 | foreach (uint localId in startedColliders) |
3697 | if (startedColliders.Count > 0) | 3697 | { |
3698 | { | 3698 | if (localId == 0) |
3699 | ColliderArgs StartCollidingMessage = new ColliderArgs(); | 3699 | continue; |
3700 | List<DetectedObject> colliding = new List<DetectedObject>(); | 3700 | |
3701 | foreach (uint localId in startedColliders) | 3701 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); |
3702 | { | 3702 | string data = ""; |
3703 | if (localId == 0) | 3703 | if (obj != null) |
3704 | continue; | 3704 | { |
3705 | 3705 | DetectedObject detobj = new DetectedObject(); | |
3706 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | 3706 | detobj.keyUUID = obj.UUID; |
3707 | string data = ""; | 3707 | detobj.nameStr = obj.Name; |
3708 | if (obj != null) | 3708 | detobj.ownerUUID = obj.OwnerID; |
3709 | { | 3709 | detobj.posVector = obj.AbsolutePosition; |
3710 | DetectedObject detobj = new DetectedObject(); | 3710 | detobj.rotQuat = obj.GetWorldRotation(); |
3711 | detobj.keyUUID = obj.UUID; | 3711 | detobj.velVector = obj.Velocity; |
3712 | detobj.nameStr = obj.Name; | 3712 | detobj.colliderType = 0; |
3713 | detobj.ownerUUID = obj.OwnerID; | 3713 | detobj.groupUUID = obj.GroupID; |
3714 | detobj.posVector = obj.AbsolutePosition; | 3714 | colliding.Add(detobj); |
3715 | detobj.rotQuat = obj.GetWorldRotation(); | 3715 | } |
3716 | detobj.velVector = obj.Velocity; | 3716 | } |
3717 | detobj.colliderType = 0; | 3717 | |
3718 | detobj.groupUUID = obj.GroupID; | 3718 | if (colliding.Count > 0) |
3719 | colliding.Add(detobj); | 3719 | { |
3720 | } | 3720 | StartCollidingMessage.Colliders = colliding; |
3721 | } | 3721 | |
3722 | 3722 | foreach (SceneObjectGroup att in Attachments) | |
3723 | if (colliding.Count > 0) | 3723 | Scene.EventManager.TriggerScriptCollidingStart(att.LocalId, StartCollidingMessage); |
3724 | { | 3724 | } |
3725 | StartCollidingMessage.Colliders = colliding; | 3725 | } |
3726 | 3726 | ||
3727 | foreach (SceneObjectGroup att in Attachments) | 3727 | if (endedColliders.Count > 0) |
3728 | Scene.EventManager.TriggerScriptCollidingStart(att.LocalId, StartCollidingMessage); | 3728 | { |
3729 | } | 3729 | ColliderArgs EndCollidingMessage = new ColliderArgs(); |
3730 | } | 3730 | List<DetectedObject> colliding = new List<DetectedObject>(); |
3731 | 3731 | foreach (uint localId in endedColliders) | |
3732 | if (endedColliders.Count > 0) | 3732 | { |
3733 | { | 3733 | if (localId == 0) |
3734 | ColliderArgs EndCollidingMessage = new ColliderArgs(); | 3734 | continue; |
3735 | List<DetectedObject> colliding = new List<DetectedObject>(); | 3735 | |
3736 | foreach (uint localId in endedColliders) | 3736 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); |
3737 | { | 3737 | string data = ""; |
3738 | if (localId == 0) | 3738 | if (obj != null) |
3739 | continue; | 3739 | { |
3740 | 3740 | DetectedObject detobj = new DetectedObject(); | |
3741 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | 3741 | detobj.keyUUID = obj.UUID; |
3742 | string data = ""; | 3742 | detobj.nameStr = obj.Name; |
3743 | if (obj != null) | 3743 | detobj.ownerUUID = obj.OwnerID; |
3744 | { | 3744 | detobj.posVector = obj.AbsolutePosition; |
3745 | DetectedObject detobj = new DetectedObject(); | 3745 | detobj.rotQuat = obj.GetWorldRotation(); |
3746 | detobj.keyUUID = obj.UUID; | 3746 | detobj.velVector = obj.Velocity; |
3747 | detobj.nameStr = obj.Name; | 3747 | detobj.colliderType = 0; |
3748 | detobj.ownerUUID = obj.OwnerID; | 3748 | detobj.groupUUID = obj.GroupID; |
3749 | detobj.posVector = obj.AbsolutePosition; | 3749 | colliding.Add(detobj); |
3750 | detobj.rotQuat = obj.GetWorldRotation(); | 3750 | } |
3751 | detobj.velVector = obj.Velocity; | 3751 | } |
3752 | detobj.colliderType = 0; | 3752 | |
3753 | detobj.groupUUID = obj.GroupID; | 3753 | if (colliding.Count > 0) |
3754 | colliding.Add(detobj); | 3754 | { |
3755 | } | 3755 | EndCollidingMessage.Colliders = colliding; |
3756 | } | 3756 | |
3757 | 3757 | foreach (SceneObjectGroup att in Attachments) | |
3758 | if (colliding.Count > 0) | 3758 | Scene.EventManager.TriggerScriptCollidingEnd(att.LocalId, EndCollidingMessage); |
3759 | { | 3759 | } |
3760 | EndCollidingMessage.Colliders = colliding; | 3760 | } |
3761 | 3761 | ||
3762 | foreach (SceneObjectGroup att in Attachments) | 3762 | if (thisHitColliders.Count > 0) |
3763 | Scene.EventManager.TriggerScriptCollidingEnd(att.LocalId, EndCollidingMessage); | 3763 | { |
3764 | } | 3764 | ColliderArgs CollidingMessage = new ColliderArgs(); |
3765 | } | 3765 | List<DetectedObject> colliding = new List<DetectedObject>(); |
3766 | 3766 | foreach (uint localId in thisHitColliders) | |
3767 | if (thisHitColliders.Count > 0) | 3767 | { |
3768 | { | 3768 | if (localId == 0) |
3769 | ColliderArgs CollidingMessage = new ColliderArgs(); | 3769 | continue; |
3770 | List<DetectedObject> colliding = new List<DetectedObject>(); | 3770 | |
3771 | foreach (uint localId in thisHitColliders) | 3771 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); |
3772 | { | 3772 | string data = ""; |
3773 | if (localId == 0) | 3773 | if (obj != null) |
3774 | continue; | 3774 | { |
3775 | 3775 | DetectedObject detobj = new DetectedObject(); | |
3776 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | 3776 | detobj.keyUUID = obj.UUID; |
3777 | string data = ""; | 3777 | detobj.nameStr = obj.Name; |
3778 | if (obj != null) | 3778 | detobj.ownerUUID = obj.OwnerID; |
3779 | { | 3779 | detobj.posVector = obj.AbsolutePosition; |
3780 | DetectedObject detobj = new DetectedObject(); | 3780 | detobj.rotQuat = obj.GetWorldRotation(); |
3781 | detobj.keyUUID = obj.UUID; | 3781 | detobj.velVector = obj.Velocity; |
3782 | detobj.nameStr = obj.Name; | 3782 | detobj.colliderType = 0; |
3783 | detobj.ownerUUID = obj.OwnerID; | 3783 | detobj.groupUUID = obj.GroupID; |
3784 | detobj.posVector = obj.AbsolutePosition; | 3784 | colliding.Add(detobj); |
3785 | detobj.rotQuat = obj.GetWorldRotation(); | 3785 | } |
3786 | detobj.velVector = obj.Velocity; | 3786 | } |
3787 | detobj.colliderType = 0; | 3787 | |
3788 | detobj.groupUUID = obj.GroupID; | 3788 | if (colliding.Count > 0) |
3789 | colliding.Add(detobj); | 3789 | { |
3790 | } | 3790 | CollidingMessage.Colliders = colliding; |
3791 | } | 3791 | |
3792 | 3792 | lock (m_attachments) | |
3793 | if (colliding.Count > 0) | 3793 | { |
3794 | { | 3794 | foreach (SceneObjectGroup att in m_attachments) |
3795 | CollidingMessage.Colliders = colliding; | 3795 | Scene.EventManager.TriggerScriptColliding(att.LocalId, CollidingMessage); |
3796 | 3796 | } | |
3797 | lock (m_attachments) | 3797 | } |
3798 | { | 3798 | } |
3799 | foreach (SceneObjectGroup att in m_attachments) | 3799 | |
3800 | Scene.EventManager.TriggerScriptColliding(att.LocalId, CollidingMessage); | 3800 | if (m_invulnerable) |
3801 | } | 3801 | return; |
3802 | } | 3802 | |
3803 | } | 3803 | float starthealth = Health; |
3804 | 3804 | uint killerObj = 0; | |
3805 | if (m_invulnerable) | 3805 | foreach (uint localid in coldata.Keys) |
3806 | return; | 3806 | { |
3807 | 3807 | SceneObjectPart part = Scene.GetSceneObjectPart(localid); | |
3808 | float starthealth = Health; | 3808 | |
3809 | uint killerObj = 0; | 3809 | if (part != null && part.ParentGroup.Damage != -1.0f) |
3810 | foreach (uint localid in coldata.Keys) | 3810 | Health -= part.ParentGroup.Damage; |
3811 | { | 3811 | else |
3812 | SceneObjectPart part = Scene.GetSceneObjectPart(localid); | 3812 | { |
3813 | 3813 | if (coldata[localid].PenetrationDepth >= 0.10f) | |
3814 | if (part != null && part.ParentGroup.Damage != -1.0f) | 3814 | Health -= coldata[localid].PenetrationDepth * 5.0f; |
3815 | Health -= part.ParentGroup.Damage; | 3815 | } |
3816 | else | 3816 | |
3817 | { | 3817 | if (Health <= 0.0f) |
3818 | if (coldata[localid].PenetrationDepth >= 0.10f) | 3818 | { |
3819 | Health -= coldata[localid].PenetrationDepth * 5.0f; | 3819 | if (localid != 0) |
3820 | } | 3820 | killerObj = localid; |
3821 | 3821 | } | |
3822 | if (Health <= 0.0f) | 3822 | //m_log.Debug("[AVATAR]: Collision with localid: " + localid.ToString() + " at depth: " + coldata[localid].ToString()); |
3823 | { | 3823 | } |
3824 | if (localid != 0) | 3824 | //Health = 100; |
3825 | killerObj = localid; | 3825 | if (!m_invulnerable) |
3826 | } | 3826 | { |
3827 | //m_log.Debug("[AVATAR]: Collision with localid: " + localid.ToString() + " at depth: " + coldata[localid].ToString()); | 3827 | if (starthealth != Health) |
3828 | } | 3828 | { |
3829 | //Health = 100; | 3829 | ControllingClient.SendHealth(Health); |
3830 | if (!m_invulnerable) | 3830 | } |
3831 | { | 3831 | if (m_health <= 0) |
3832 | if (starthealth != Health) | 3832 | m_scene.EventManager.TriggerAvatarKill(killerObj, this); |
3833 | { | 3833 | } |
3834 | ControllingClient.SendHealth(Health); | 3834 | } |
3835 | } | 3835 | |
3836 | if (m_health <= 0) | 3836 | public void setHealthWithUpdate(float health) |
3837 | m_scene.EventManager.TriggerAvatarKill(killerObj, this); | 3837 | { |
3838 | } | 3838 | Health = health; |
3839 | } | 3839 | ControllingClient.SendHealth(Health); |
3840 | 3840 | } | |
3841 | public void setHealthWithUpdate(float health) | 3841 | |
3842 | { | 3842 | public void Close() |
3843 | Health = health; | 3843 | { |
3844 | ControllingClient.SendHealth(Health); | 3844 | lock (m_attachments) |
3845 | } | 3845 | { |
3846 | 3846 | // Delete attachments from scene | |
3847 | public void Close() | 3847 | // Don't try to save, as this thread won't live long |
3848 | { | 3848 | // enough to complete the save. This would cause no copy |
3849 | lock (m_attachments) | 3849 | // attachments to poof! |
3850 | { | 3850 | // |
3851 | // Delete attachments from scene | 3851 | foreach (SceneObjectGroup grp in m_attachments) |
3852 | // Don't try to save, as this thread won't live long | 3852 | { |
3853 | // enough to complete the save. This would cause no copy | 3853 | m_scene.DeleteSceneObject(grp, false); |
3854 | // attachments to poof! | 3854 | } |
3855 | // | 3855 | m_attachments.Clear(); |
3856 | foreach (SceneObjectGroup grp in m_attachments) | 3856 | } |
3857 | { | 3857 | |
3858 | m_scene.DeleteSceneObject(grp, false); | 3858 | lock (m_knownChildRegions) |
3859 | } | 3859 | { |
3860 | m_attachments.Clear(); | 3860 | m_knownChildRegions.Clear(); |
3861 | } | 3861 | } |
3862 | 3862 | ||
3863 | lock (m_knownChildRegions) | 3863 | lock (m_reprioritization_timer) |
3864 | { | 3864 | { |
3865 | m_knownChildRegions.Clear(); | 3865 | m_reprioritization_timer.Enabled = false; |
3866 | } | 3866 | m_reprioritization_timer.Elapsed -= new ElapsedEventHandler(Reprioritize); |
3867 | 3867 | } | |
3868 | lock (m_reprioritization_timer) | 3868 | |
3869 | { | 3869 | // I don't get it but mono crashes when you try to dispose of this timer, |
3870 | m_reprioritization_timer.Enabled = false; | 3870 | // unsetting the elapsed callback should be enough to allow for cleanup however. |
3871 | m_reprioritization_timer.Elapsed -= new ElapsedEventHandler(Reprioritize); | 3871 | // m_reprioritizationTimer.Dispose(); |
3872 | } | 3872 | |
3873 | 3873 | m_sceneViewer.Close(); | |
3874 | // I don't get it but mono crashes when you try to dispose of this timer, | 3874 | |
3875 | // unsetting the elapsed callback should be enough to allow for cleanup however. | 3875 | RemoveFromPhysicalScene(); |
3876 | // m_reprioritizationTimer.Dispose(); | 3876 | m_animator.Close(); |
3877 | 3877 | m_animator = null; | |
3878 | m_sceneViewer.Close(); | 3878 | } |
3879 | 3879 | ||
3880 | RemoveFromPhysicalScene(); | 3880 | public void AddAttachment(SceneObjectGroup gobj) |
3881 | m_animator.Close(); | 3881 | { |
3882 | m_animator = null; | 3882 | lock (m_attachments) |
3883 | } | 3883 | { |
3884 | 3884 | m_attachments.Add(gobj); | |
3885 | public void AddAttachment(SceneObjectGroup gobj) | 3885 | } |
3886 | { | 3886 | } |
3887 | lock (m_attachments) | 3887 | |
3888 | { | 3888 | public bool HasAttachments() |
3889 | m_attachments.Add(gobj); | 3889 | { |
3890 | } | 3890 | return m_attachments.Count > 0; |
3891 | } | 3891 | } |
3892 | 3892 | ||
3893 | public bool HasAttachments() | 3893 | public bool HasScriptedAttachments() |
3894 | { | 3894 | { |
3895 | return m_attachments.Count > 0; | 3895 | lock (m_attachments) |
3896 | } | 3896 | { |
3897 | 3897 | foreach (SceneObjectGroup gobj in m_attachments) | |
3898 | public bool HasScriptedAttachments() | 3898 | { |
3899 | { | 3899 | if (gobj != null) |
3900 | lock (m_attachments) | 3900 | { |
3901 | { | 3901 | if (gobj.RootPart.Inventory.ContainsScripts()) |
3902 | foreach (SceneObjectGroup gobj in m_attachments) | 3902 | return true; |
3903 | { | 3903 | } |
3904 | if (gobj != null) | 3904 | } |
3905 | { | 3905 | } |
3906 | if (gobj.RootPart.Inventory.ContainsScripts()) | 3906 | return false; |
3907 | return true; | 3907 | } |
3908 | } | 3908 | |
3909 | } | 3909 | public void RemoveAttachment(SceneObjectGroup gobj) |
3910 | } | 3910 | { |
3911 | return false; | 3911 | lock (m_attachments) |
3912 | } | 3912 | { |
3913 | 3913 | if (m_attachments.Contains(gobj)) | |
3914 | public void RemoveAttachment(SceneObjectGroup gobj) | 3914 | { |
3915 | { | 3915 | m_attachments.Remove(gobj); |
3916 | lock (m_attachments) | 3916 | } |
3917 | { | 3917 | } |
3918 | if (m_attachments.Contains(gobj)) | 3918 | } |
3919 | { | 3919 | |
3920 | m_attachments.Remove(gobj); | 3920 | public bool ValidateAttachments() |
3921 | } | 3921 | { |
3922 | } | 3922 | lock (m_attachments) |
3923 | } | 3923 | { |
3924 | 3924 | // Validate | |
3925 | public bool ValidateAttachments() | 3925 | foreach (SceneObjectGroup gobj in m_attachments) |
3926 | { | 3926 | { |
3927 | lock (m_attachments) | 3927 | if (gobj == null) |
3928 | { | 3928 | return false; |
3929 | // Validate | 3929 | |
3930 | foreach (SceneObjectGroup gobj in m_attachments) | 3930 | if (gobj.IsDeleted) |
3931 | { | 3931 | return false; |
3932 | if (gobj == null) | 3932 | } |
3933 | return false; | 3933 | } |
3934 | 3934 | return true; | |
3935 | if (gobj.IsDeleted) | 3935 | } |
3936 | return false; | 3936 | |
3937 | } | 3937 | /// <summary> |
3938 | } | 3938 | /// Send a script event to this scene presence's attachments |
3939 | return true; | 3939 | /// </summary> |
3940 | } | 3940 | /// <param name="eventName">The name of the event</param> |
3941 | 3941 | /// <param name="args">The arguments for the event</param> | |
3942 | /// <summary> | 3942 | public void SendScriptEventToAttachments(string eventName, Object[] args) |
3943 | /// Send a script event to this scene presence's attachments | 3943 | { |
3944 | /// </summary> | 3944 | if (m_scriptEngines != null) |
3945 | /// <param name="eventName">The name of the event</param> | 3945 | { |
3946 | /// <param name="args">The arguments for the event</param> | 3946 | lock (m_attachments) |
3947 | public void SendScriptEventToAttachments(string eventName, Object[] args) | 3947 | { |
3948 | { | 3948 | foreach (SceneObjectGroup grp in m_attachments) |
3949 | if (m_scriptEngines != null) | 3949 | { |
3950 | { | 3950 | // 16384 is CHANGED_ANIMATION |
3951 | lock (m_attachments) | 3951 | // |
3952 | { | 3952 | // Send this to all attachment root prims |
3953 | foreach (SceneObjectGroup grp in m_attachments) | 3953 | // |
3954 | { | 3954 | foreach (IScriptModule m in m_scriptEngines) |
3955 | // 16384 is CHANGED_ANIMATION | 3955 | { |
3956 | // | 3956 | if (m == null) // No script engine loaded |
3957 | // Send this to all attachment root prims | 3957 | continue; |
3958 | // | 3958 | |
3959 | foreach (IScriptModule m in m_scriptEngines) | 3959 | m.PostObjectEvent(grp.RootPart.UUID, "changed", new Object[] { (int)Changed.ANIMATION }); |
3960 | { | 3960 | } |
3961 | if (m == null) // No script engine loaded | 3961 | } |
3962 | continue; | 3962 | } |
3963 | 3963 | } | |
3964 | m.PostObjectEvent(grp.RootPart.UUID, "changed", new Object[] { (int)Changed.ANIMATION }); | 3964 | } |
3965 | } | 3965 | |
3966 | } | 3966 | |
3967 | } | 3967 | public void initializeScenePresence(IClientAPI client, RegionInfo region, Scene scene) |
3968 | } | 3968 | { |
3969 | } | 3969 | m_controllingClient = client; |
3970 | 3970 | m_regionInfo = region; | |
3971 | 3971 | m_scene = scene; | |
3972 | public void initializeScenePresence(IClientAPI client, RegionInfo region, Scene scene) | 3972 | |
3973 | { | 3973 | RegisterToEvents(); |
3974 | m_controllingClient = client; | 3974 | if (m_controllingClient != null) |
3975 | m_regionInfo = region; | 3975 | { |
3976 | m_scene = scene; | 3976 | m_controllingClient.ProcessPendingPackets(); |
3977 | 3977 | } | |
3978 | RegisterToEvents(); | 3978 | /* |
3979 | if (m_controllingClient != null) | 3979 | AbsolutePosition = client.StartPos; |
3980 | { | 3980 | |
3981 | m_controllingClient.ProcessPendingPackets(); | 3981 | Animations = new AvatarAnimations(); |
3982 | } | 3982 | Animations.LoadAnims(); |
3983 | /* | 3983 | |
3984 | AbsolutePosition = client.StartPos; | 3984 | m_animations = new List<UUID>(); |
3985 | 3985 | m_animations.Add(Animations.AnimsUUID["STAND"]); | |
3986 | Animations = new AvatarAnimations(); | 3986 | m_animationSeqs.Add(m_controllingClient.NextAnimationSequenceNumber); |
3987 | Animations.LoadAnims(); | 3987 | |
3988 | 3988 | SetDirectionVectors(); | |
3989 | m_animations = new List<UUID>(); | 3989 | */ |
3990 | m_animations.Add(Animations.AnimsUUID["STAND"]); | 3990 | } |
3991 | m_animationSeqs.Add(m_controllingClient.NextAnimationSequenceNumber); | 3991 | |
3992 | 3992 | internal void PushForce(Vector3 impulse) | |
3993 | SetDirectionVectors(); | 3993 | { |
3994 | */ | 3994 | if (PhysicsActor != null) |
3995 | } | 3995 | { |
3996 | 3996 | PhysicsActor.AddForce(impulse,true); | |
3997 | internal void PushForce(Vector3 impulse) | 3997 | } |
3998 | { | 3998 | } |
3999 | if (PhysicsActor != null) | 3999 | |
4000 | { | 4000 | public void RegisterControlEventsToScript(int controls, int accept, int pass_on, uint Obj_localID, UUID Script_item_UUID) |
4001 | PhysicsActor.AddForce(impulse,true); | 4001 | { |
4002 | } | 4002 | ScriptControllers obj = new ScriptControllers(); |
4003 | } | 4003 | obj.ignoreControls = ScriptControlled.CONTROL_ZERO; |
4004 | 4004 | obj.eventControls = ScriptControlled.CONTROL_ZERO; | |
4005 | public void RegisterControlEventsToScript(int controls, int accept, int pass_on, uint Obj_localID, UUID Script_item_UUID) | 4005 | |
4006 | { | 4006 | obj.itemID = Script_item_UUID; |
4007 | ScriptControllers obj = new ScriptControllers(); | 4007 | if (pass_on == 0 && accept == 0) |
4008 | obj.ignoreControls = ScriptControlled.CONTROL_ZERO; | 4008 | { |
4009 | obj.eventControls = ScriptControlled.CONTROL_ZERO; | 4009 | IgnoredControls |= (ScriptControlled)controls; |
4010 | 4010 | obj.ignoreControls = (ScriptControlled)controls; | |
4011 | obj.itemID = Script_item_UUID; | 4011 | } |
4012 | if (pass_on == 0 && accept == 0) | 4012 | |
4013 | { | 4013 | if (pass_on == 0 && accept == 1) |
4014 | IgnoredControls |= (ScriptControlled)controls; | 4014 | { |
4015 | obj.ignoreControls = (ScriptControlled)controls; | 4015 | IgnoredControls |= (ScriptControlled)controls; |
4016 | } | 4016 | obj.ignoreControls = (ScriptControlled)controls; |
4017 | 4017 | obj.eventControls = (ScriptControlled)controls; | |
4018 | if (pass_on == 0 && accept == 1) | 4018 | } |
4019 | { | 4019 | if (pass_on == 1 && accept == 1) |
4020 | IgnoredControls |= (ScriptControlled)controls; | 4020 | { |
4021 | obj.ignoreControls = (ScriptControlled)controls; | 4021 | IgnoredControls = ScriptControlled.CONTROL_ZERO; |
4022 | obj.eventControls = (ScriptControlled)controls; | 4022 | obj.eventControls = (ScriptControlled)controls; |
4023 | } | 4023 | obj.ignoreControls = ScriptControlled.CONTROL_ZERO; |
4024 | if (pass_on == 1 && accept == 1) | 4024 | } |
4025 | { | 4025 | |
4026 | IgnoredControls = ScriptControlled.CONTROL_ZERO; | 4026 | lock (scriptedcontrols) |
4027 | obj.eventControls = (ScriptControlled)controls; | 4027 | { |
4028 | obj.ignoreControls = ScriptControlled.CONTROL_ZERO; | 4028 | if (pass_on == 1 && accept == 0) |
4029 | } | 4029 | { |
4030 | 4030 | IgnoredControls &= ~(ScriptControlled)controls; | |
4031 | lock (scriptedcontrols) | 4031 | if (scriptedcontrols.ContainsKey(Script_item_UUID)) |
4032 | { | 4032 | scriptedcontrols.Remove(Script_item_UUID); |
4033 | if (pass_on == 1 && accept == 0) | 4033 | } |
4034 | { | 4034 | else |
4035 | IgnoredControls &= ~(ScriptControlled)controls; | 4035 | { |
4036 | if (scriptedcontrols.ContainsKey(Script_item_UUID)) | 4036 | scriptedcontrols[Script_item_UUID] = obj; |
4037 | scriptedcontrols.Remove(Script_item_UUID); | 4037 | } |
4038 | } | 4038 | } |
4039 | else | 4039 | ControllingClient.SendTakeControls(controls, pass_on == 1 ? true : false, true); |
4040 | { | 4040 | } |
4041 | scriptedcontrols[Script_item_UUID] = obj; | 4041 | |
4042 | } | 4042 | public void HandleForceReleaseControls(IClientAPI remoteClient, UUID agentID) |
4043 | } | 4043 | { |
4044 | ControllingClient.SendTakeControls(controls, pass_on == 1 ? true : false, true); | 4044 | IgnoredControls = ScriptControlled.CONTROL_ZERO; |
4045 | } | 4045 | lock (scriptedcontrols) |
4046 | 4046 | { | |
4047 | public void HandleForceReleaseControls(IClientAPI remoteClient, UUID agentID) | 4047 | scriptedcontrols.Clear(); |
4048 | { | 4048 | } |
4049 | IgnoredControls = ScriptControlled.CONTROL_ZERO; | 4049 | ControllingClient.SendTakeControls(int.MaxValue, false, false); |
4050 | lock (scriptedcontrols) | 4050 | } |
4051 | { | 4051 | |
4052 | scriptedcontrols.Clear(); | 4052 | public void UnRegisterControlEventsToScript(uint Obj_localID, UUID Script_item_UUID) |
4053 | } | 4053 | { |
4054 | ControllingClient.SendTakeControls(int.MaxValue, false, false); | 4054 | ScriptControllers takecontrols; |
4055 | } | 4055 | |
4056 | 4056 | lock (scriptedcontrols) | |
4057 | public void UnRegisterControlEventsToScript(uint Obj_localID, UUID Script_item_UUID) | 4057 | { |
4058 | { | 4058 | if (scriptedcontrols.TryGetValue(Script_item_UUID, out takecontrols)) |
4059 | ScriptControllers takecontrols; | 4059 | { |
4060 | 4060 | ScriptControlled sctc = takecontrols.eventControls; | |
4061 | lock (scriptedcontrols) | 4061 | |
4062 | { | 4062 | ControllingClient.SendTakeControls((int)sctc, false, false); |
4063 | if (scriptedcontrols.TryGetValue(Script_item_UUID, out takecontrols)) | 4063 | ControllingClient.SendTakeControls((int)sctc, true, false); |
4064 | { | 4064 | |
4065 | ScriptControlled sctc = takecontrols.eventControls; | 4065 | scriptedcontrols.Remove(Script_item_UUID); |
4066 | 4066 | IgnoredControls = ScriptControlled.CONTROL_ZERO; | |
4067 | ControllingClient.SendTakeControls((int)sctc, false, false); | 4067 | foreach (ScriptControllers scData in scriptedcontrols.Values) |
4068 | ControllingClient.SendTakeControls((int)sctc, true, false); | 4068 | { |
4069 | 4069 | IgnoredControls |= scData.ignoreControls; | |
4070 | scriptedcontrols.Remove(Script_item_UUID); | 4070 | } |
4071 | IgnoredControls = ScriptControlled.CONTROL_ZERO; | 4071 | } |
4072 | foreach (ScriptControllers scData in scriptedcontrols.Values) | 4072 | } |
4073 | { | 4073 | } |
4074 | IgnoredControls |= scData.ignoreControls; | 4074 | |
4075 | } | 4075 | internal void SendControlToScripts(uint flags) |
4076 | } | 4076 | { |
4077 | } | 4077 | ScriptControlled allflags = ScriptControlled.CONTROL_ZERO; |
4078 | } | 4078 | |
4079 | 4079 | if (MouseDown) | |
4080 | internal void SendControlToScripts(uint flags) | 4080 | { |
4081 | { | 4081 | allflags = LastCommands & (ScriptControlled.CONTROL_ML_LBUTTON | ScriptControlled.CONTROL_LBUTTON); |
4082 | ScriptControlled allflags = ScriptControlled.CONTROL_ZERO; | 4082 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_UP) != 0 || (flags & unchecked((uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_UP)) != 0) |
4083 | 4083 | { | |
4084 | if (MouseDown) | 4084 | allflags = ScriptControlled.CONTROL_ZERO; |
4085 | { | 4085 | MouseDown = true; |
4086 | allflags = LastCommands & (ScriptControlled.CONTROL_ML_LBUTTON | ScriptControlled.CONTROL_LBUTTON); | 4086 | } |
4087 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_UP) != 0 || (flags & unchecked((uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_UP)) != 0) | 4087 | } |
4088 | { | 4088 | |
4089 | allflags = ScriptControlled.CONTROL_ZERO; | 4089 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_DOWN) != 0) |
4090 | MouseDown = true; | 4090 | { |
4091 | } | 4091 | allflags |= ScriptControlled.CONTROL_ML_LBUTTON; |
4092 | } | 4092 | MouseDown = true; |
4093 | 4093 | } | |
4094 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_DOWN) != 0) | 4094 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0) |
4095 | { | 4095 | { |
4096 | allflags |= ScriptControlled.CONTROL_ML_LBUTTON; | 4096 | allflags |= ScriptControlled.CONTROL_LBUTTON; |
4097 | MouseDown = true; | 4097 | MouseDown = true; |
4098 | } | 4098 | } |
4099 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0) | 4099 | |
4100 | { | 4100 | // find all activated controls, whether the scripts are interested in them or not |
4101 | allflags |= ScriptControlled.CONTROL_LBUTTON; | 4101 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS) != 0) |
4102 | MouseDown = true; | 4102 | { |
4103 | } | 4103 | allflags |= ScriptControlled.CONTROL_FWD; |
4104 | 4104 | } | |
4105 | // find all activated controls, whether the scripts are interested in them or not | 4105 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG) != 0) |
4106 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS) != 0) | 4106 | { |
4107 | { | 4107 | allflags |= ScriptControlled.CONTROL_BACK; |
4108 | allflags |= ScriptControlled.CONTROL_FWD; | 4108 | } |
4109 | } | 4109 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_POS) != 0) |
4110 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG) != 0) | 4110 | { |
4111 | { | 4111 | allflags |= ScriptControlled.CONTROL_UP; |
4112 | allflags |= ScriptControlled.CONTROL_BACK; | 4112 | } |
4113 | } | 4113 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0) |
4114 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_POS) != 0) | 4114 | { |
4115 | { | 4115 | allflags |= ScriptControlled.CONTROL_DOWN; |
4116 | allflags |= ScriptControlled.CONTROL_UP; | 4116 | } |
4117 | } | 4117 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS) != 0) |
4118 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0) | 4118 | { |
4119 | { | 4119 | allflags |= ScriptControlled.CONTROL_LEFT; |
4120 | allflags |= ScriptControlled.CONTROL_DOWN; | 4120 | } |
4121 | } | 4121 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG) != 0) |
4122 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS) != 0) | 4122 | { |
4123 | { | 4123 | allflags |= ScriptControlled.CONTROL_RIGHT; |
4124 | allflags |= ScriptControlled.CONTROL_LEFT; | 4124 | } |
4125 | } | 4125 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0) |
4126 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG) != 0) | 4126 | { |
4127 | { | 4127 | allflags |= ScriptControlled.CONTROL_ROT_RIGHT; |
4128 | allflags |= ScriptControlled.CONTROL_RIGHT; | 4128 | } |
4129 | } | 4129 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0) |
4130 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0) | 4130 | { |
4131 | { | 4131 | allflags |= ScriptControlled.CONTROL_ROT_LEFT; |
4132 | allflags |= ScriptControlled.CONTROL_ROT_RIGHT; | 4132 | } |
4133 | } | 4133 | // optimization; we have to check per script, but if nothing is pressed and nothing changed, we can skip that |
4134 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0) | 4134 | if (allflags != ScriptControlled.CONTROL_ZERO || allflags != LastCommands) |
4135 | { | 4135 | { |
4136 | allflags |= ScriptControlled.CONTROL_ROT_LEFT; | 4136 | lock (scriptedcontrols) |
4137 | } | 4137 | { |
4138 | // optimization; we have to check per script, but if nothing is pressed and nothing changed, we can skip that | 4138 | foreach (KeyValuePair<UUID, ScriptControllers> kvp in scriptedcontrols) |
4139 | if (allflags != ScriptControlled.CONTROL_ZERO || allflags != LastCommands) | 4139 | { |
4140 | { | 4140 | UUID scriptUUID = kvp.Key; |
4141 | lock (scriptedcontrols) | 4141 | ScriptControllers scriptControlData = kvp.Value; |
4142 | { | 4142 | |
4143 | foreach (KeyValuePair<UUID, ScriptControllers> kvp in scriptedcontrols) | 4143 | ScriptControlled localHeld = allflags & scriptControlData.eventControls; // the flags interesting for us |
4144 | { | 4144 | ScriptControlled localLast = LastCommands & scriptControlData.eventControls; // the activated controls in the last cycle |
4145 | UUID scriptUUID = kvp.Key; | 4145 | ScriptControlled localChange = localHeld ^ localLast; // the changed bits |
4146 | ScriptControllers scriptControlData = kvp.Value; | 4146 | if (localHeld != ScriptControlled.CONTROL_ZERO || localChange != ScriptControlled.CONTROL_ZERO) |
4147 | 4147 | { | |
4148 | ScriptControlled localHeld = allflags & scriptControlData.eventControls; // the flags interesting for us | 4148 | // only send if still pressed or just changed |
4149 | ScriptControlled localLast = LastCommands & scriptControlData.eventControls; // the activated controls in the last cycle | 4149 | m_scene.EventManager.TriggerControlEvent(scriptUUID, UUID, (uint)localHeld, (uint)localChange); |
4150 | ScriptControlled localChange = localHeld ^ localLast; // the changed bits | 4150 | } |
4151 | if (localHeld != ScriptControlled.CONTROL_ZERO || localChange != ScriptControlled.CONTROL_ZERO) | 4151 | } |
4152 | { | 4152 | } |
4153 | // only send if still pressed or just changed | 4153 | } |
4154 | m_scene.EventManager.TriggerControlEvent(scriptUUID, UUID, (uint)localHeld, (uint)localChange); | 4154 | |
4155 | } | 4155 | LastCommands = allflags; |
4156 | } | 4156 | } |
4157 | } | 4157 | |
4158 | } | 4158 | internal static AgentManager.ControlFlags RemoveIgnoredControls(AgentManager.ControlFlags flags, ScriptControlled ignored) |
4159 | 4159 | { | |
4160 | LastCommands = allflags; | 4160 | if (ignored == ScriptControlled.CONTROL_ZERO) |
4161 | } | 4161 | return flags; |
4162 | 4162 | ||
4163 | internal static AgentManager.ControlFlags RemoveIgnoredControls(AgentManager.ControlFlags flags, ScriptControlled ignored) | 4163 | if ((ignored & ScriptControlled.CONTROL_BACK) != 0) |
4164 | { | 4164 | flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG); |
4165 | if (ignored == ScriptControlled.CONTROL_ZERO) | 4165 | if ((ignored & ScriptControlled.CONTROL_FWD) != 0) |
4166 | return flags; | 4166 | flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS | AgentManager.ControlFlags.AGENT_CONTROL_AT_POS); |
4167 | 4167 | if ((ignored & ScriptControlled.CONTROL_DOWN) != 0) | |
4168 | if ((ignored & ScriptControlled.CONTROL_BACK) != 0) | 4168 | flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG); |
4169 | flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG); | 4169 | if ((ignored & ScriptControlled.CONTROL_UP) != 0) |
4170 | if ((ignored & ScriptControlled.CONTROL_FWD) != 0) | 4170 | flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_POS | AgentManager.ControlFlags.AGENT_CONTROL_UP_POS); |
4171 | flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS | AgentManager.ControlFlags.AGENT_CONTROL_AT_POS); | 4171 | if ((ignored & ScriptControlled.CONTROL_LEFT) != 0) |
4172 | if ((ignored & ScriptControlled.CONTROL_DOWN) != 0) | 4172 | flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS); |
4173 | flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG); | 4173 | if ((ignored & ScriptControlled.CONTROL_RIGHT) != 0) |
4174 | if ((ignored & ScriptControlled.CONTROL_UP) != 0) | 4174 | flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG | AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG); |
4175 | flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_POS | AgentManager.ControlFlags.AGENT_CONTROL_UP_POS); | 4175 | if ((ignored & ScriptControlled.CONTROL_ROT_LEFT) != 0) |
4176 | if ((ignored & ScriptControlled.CONTROL_LEFT) != 0) | 4176 | flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG); |
4177 | flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS); | 4177 | if ((ignored & ScriptControlled.CONTROL_ROT_RIGHT) != 0) |
4178 | if ((ignored & ScriptControlled.CONTROL_RIGHT) != 0) | 4178 | flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS); |
4179 | flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG | AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG); | 4179 | if ((ignored & ScriptControlled.CONTROL_ML_LBUTTON) != 0) |
4180 | if ((ignored & ScriptControlled.CONTROL_ROT_LEFT) != 0) | 4180 | flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_DOWN); |
4181 | flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG); | 4181 | if ((ignored & ScriptControlled.CONTROL_LBUTTON) != 0) |
4182 | if ((ignored & ScriptControlled.CONTROL_ROT_RIGHT) != 0) | 4182 | flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_UP | AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN); |
4183 | flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS); | 4183 | |
4184 | if ((ignored & ScriptControlled.CONTROL_ML_LBUTTON) != 0) | 4184 | //DIR_CONTROL_FLAG_FORWARD = AgentManager.ControlFlags.AGENT_CONTROL_AT_POS, |
4185 | flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_DOWN); | 4185 | //DIR_CONTROL_FLAG_BACK = AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG, |
4186 | if ((ignored & ScriptControlled.CONTROL_LBUTTON) != 0) | 4186 | //DIR_CONTROL_FLAG_LEFT = AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS, |
4187 | flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_UP | AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN); | 4187 | //DIR_CONTROL_FLAG_RIGHT = AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG, |
4188 | 4188 | //DIR_CONTROL_FLAG_UP = AgentManager.ControlFlags.AGENT_CONTROL_UP_POS, | |
4189 | //DIR_CONTROL_FLAG_FORWARD = AgentManager.ControlFlags.AGENT_CONTROL_AT_POS, | 4189 | //DIR_CONTROL_FLAG_DOWN = AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG, |
4190 | //DIR_CONTROL_FLAG_BACK = AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG, | 4190 | //DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG |
4191 | //DIR_CONTROL_FLAG_LEFT = AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS, | 4191 | |
4192 | //DIR_CONTROL_FLAG_RIGHT = AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG, | 4192 | return flags; |
4193 | //DIR_CONTROL_FLAG_UP = AgentManager.ControlFlags.AGENT_CONTROL_UP_POS, | 4193 | } |
4194 | //DIR_CONTROL_FLAG_DOWN = AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG, | 4194 | |
4195 | //DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG | 4195 | /// <summary> |
4196 | 4196 | /// RezAttachments. This should only be called upon login on the first region. | |
4197 | return flags; | 4197 | /// Attachment rezzings on crossings and TPs are done in a different way. |
4198 | } | 4198 | /// </summary> |
4199 | 4199 | public void RezAttachments() | |
4200 | /// <summary> | 4200 | { |
4201 | /// RezAttachments. This should only be called upon login on the first region. | 4201 | if (null == m_appearance) |
4202 | /// Attachment rezzings on crossings and TPs are done in a different way. | 4202 | { |
4203 | /// </summary> | 4203 | m_log.WarnFormat("[ATTACHMENT]: Appearance has not been initialized for agent {0}", UUID); |
4204 | public void RezAttachments() | 4204 | return; |
4205 | { | 4205 | } |
4206 | if (null == m_appearance) | 4206 | |
4207 | { | 4207 | XmlDocument doc = new XmlDocument(); |
4208 | m_log.WarnFormat("[ATTACHMENT]: Appearance has not been initialized for agent {0}", UUID); | 4208 | string stateData = String.Empty; |
4209 | return; | 4209 | |
4210 | } | 4210 | IAttachmentsService attServ = m_scene.RequestModuleInterface<IAttachmentsService>(); |
4211 | 4211 | if (attServ != null) | |
4212 | XmlDocument doc = new XmlDocument(); | 4212 | { |
4213 | string stateData = String.Empty; | 4213 | m_log.DebugFormat("[ATTACHMENT]: Loading attachment data from attachment service"); |
4214 | 4214 | stateData = attServ.Get(ControllingClient.AgentId.ToString()); | |
4215 | IAttachmentsService attServ = m_scene.RequestModuleInterface<IAttachmentsService>(); | 4215 | if (stateData != String.Empty) |
4216 | if (attServ != null) | 4216 | { |
4217 | { | 4217 | try |
4218 | m_log.DebugFormat("[ATTACHMENT]: Loading attachment data from attachment service"); | 4218 | { |
4219 | stateData = attServ.Get(ControllingClient.AgentId.ToString()); | 4219 | doc.LoadXml(stateData); |
4220 | if (stateData != String.Empty) | 4220 | } |
4221 | { | 4221 | catch { } |
4222 | try | 4222 | } |
4223 | { | 4223 | } |
4224 | doc.LoadXml(stateData); | 4224 | |
4225 | } | 4225 | Dictionary<UUID, string> itemData = new Dictionary<UUID, string>(); |
4226 | catch { } | 4226 | |
4227 | } | 4227 | XmlNodeList nodes = doc.GetElementsByTagName("Attachment"); |
4228 | } | 4228 | if (nodes.Count > 0) |
4229 | 4229 | { | |
4230 | Dictionary<UUID, string> itemData = new Dictionary<UUID, string>(); | 4230 | foreach (XmlNode n in nodes) |
4231 | 4231 | { | |
4232 | XmlNodeList nodes = doc.GetElementsByTagName("Attachment"); | 4232 | XmlElement elem = (XmlElement)n; |
4233 | if (nodes.Count > 0) | 4233 | string itemID = elem.GetAttribute("ItemID"); |
4234 | { | 4234 | string xml = elem.InnerXml; |
4235 | foreach (XmlNode n in nodes) | 4235 | |
4236 | { | 4236 | itemData[new UUID(itemID)] = xml; |
4237 | XmlElement elem = (XmlElement)n; | 4237 | } |
4238 | string itemID = elem.GetAttribute("ItemID"); | 4238 | } |
4239 | string xml = elem.InnerXml; | 4239 | |
4240 | 4240 | List<int> attPoints = m_appearance.GetAttachedPoints(); | |
4241 | itemData[new UUID(itemID)] = xml; | 4241 | foreach (int p in attPoints) |
4242 | } | 4242 | { |
4243 | } | 4243 | if (m_isDeleted) |
4244 | 4244 | return; | |
4245 | List<int> attPoints = m_appearance.GetAttachedPoints(); | 4245 | |
4246 | foreach (int p in attPoints) | 4246 | UUID itemID = m_appearance.GetAttachedItem(p); |
4247 | { | 4247 | UUID assetID = m_appearance.GetAttachedAsset(p); |
4248 | if (m_isDeleted) | 4248 | |
4249 | return; | 4249 | // For some reason assetIDs are being written as Zero's in the DB -- need to track tat down |
4250 | 4250 | // But they're not used anyway, the item is being looked up for now, so let's proceed. | |
4251 | UUID itemID = m_appearance.GetAttachedItem(p); | 4251 | //if (UUID.Zero == assetID) |
4252 | UUID assetID = m_appearance.GetAttachedAsset(p); | 4252 | //{ |
4253 | 4253 | // m_log.DebugFormat("[ATTACHMENT]: Cannot rez attachment in point {0} with itemID {1}", p, itemID); | |
4254 | // For some reason assetIDs are being written as Zero's in the DB -- need to track tat down | 4254 | // continue; |
4255 | // But they're not used anyway, the item is being looked up for now, so let's proceed. | 4255 | //} |
4256 | //if (UUID.Zero == assetID) | 4256 | |
4257 | //{ | 4257 | try |
4258 | // m_log.DebugFormat("[ATTACHMENT]: Cannot rez attachment in point {0} with itemID {1}", p, itemID); | 4258 | { |
4259 | // continue; | 4259 | string xmlData; |
4260 | //} | 4260 | XmlDocument d = new XmlDocument(); |
4261 | 4261 | UUID asset; | |
4262 | try | 4262 | if (itemData.TryGetValue(itemID, out xmlData)) |
4263 | { | 4263 | { |
4264 | string xmlData; | 4264 | d.LoadXml(xmlData); |
4265 | XmlDocument d = new XmlDocument(); | 4265 | m_log.InfoFormat("[ATTACHMENT]: Found saved state for item {0}, loading it", itemID); |
4266 | UUID asset; | 4266 | |
4267 | if (itemData.TryGetValue(itemID, out xmlData)) | 4267 | // Rez from inventory |
4268 | { | 4268 | asset |
4269 | d.LoadXml(xmlData); | 4269 | = m_scene.AttachmentsModule.RezSingleAttachmentFromInventory(ControllingClient, itemID, (uint)p, true, d); |
4270 | m_log.InfoFormat("[ATTACHMENT]: Found saved state for item {0}, loading it", itemID); | 4270 | |
4271 | 4271 | } | |
4272 | // Rez from inventory | 4272 | else |
4273 | asset | 4273 | { |
4274 | = m_scene.AttachmentsModule.RezSingleAttachmentFromInventory(ControllingClient, itemID, (uint)p, true, d); | 4274 | // Rez from inventory (with a null doc to let |
4275 | 4275 | // CHANGED_OWNER happen) | |
4276 | } | 4276 | asset |
4277 | else | 4277 | = m_scene.AttachmentsModule.RezSingleAttachmentFromInventory(ControllingClient, itemID, (uint)p, true, null); |
4278 | { | 4278 | } |
4279 | // Rez from inventory (with a null doc to let | 4279 | |
4280 | // CHANGED_OWNER happen) | 4280 | m_log.InfoFormat( |
4281 | asset | 4281 | "[ATTACHMENT]: Rezzed attachment in point {0} from item {1} and asset {2} ({3})", |
4282 | = m_scene.AttachmentsModule.RezSingleAttachmentFromInventory(ControllingClient, itemID, (uint)p, true, null); | 4282 | p, itemID, assetID, asset); |
4283 | } | 4283 | } |
4284 | 4284 | catch (Exception e) | |
4285 | m_log.InfoFormat( | 4285 | { |
4286 | "[ATTACHMENT]: Rezzed attachment in point {0} from item {1} and asset {2} ({3})", | 4286 | m_log.ErrorFormat("[ATTACHMENT]: Unable to rez attachment: {0}", e.ToString()); |
4287 | p, itemID, assetID, asset); | 4287 | } |
4288 | } | 4288 | } |
4289 | catch (Exception e) | 4289 | } |
4290 | { | 4290 | |
4291 | m_log.ErrorFormat("[ATTACHMENT]: Unable to rez attachment: {0}", e.ToString()); | 4291 | private void ReprioritizeUpdates() |
4292 | } | 4292 | { |
4293 | } | 4293 | if (Scene.IsReprioritizationEnabled && Scene.UpdatePrioritizationScheme != UpdatePrioritizationSchemes.Time) |
4294 | } | 4294 | { |
4295 | 4295 | lock (m_reprioritization_timer) | |
4296 | private void ReprioritizeUpdates() | 4296 | { |
4297 | { | 4297 | if (!m_reprioritizing) |
4298 | if (Scene.IsReprioritizationEnabled && Scene.UpdatePrioritizationScheme != UpdatePrioritizationSchemes.Time) | 4298 | m_reprioritization_timer.Enabled = m_reprioritizing = true; |
4299 | { | 4299 | else |
4300 | lock (m_reprioritization_timer) | 4300 | m_reprioritization_called = true; |
4301 | { | 4301 | } |
4302 | if (!m_reprioritizing) | 4302 | } |
4303 | m_reprioritization_timer.Enabled = m_reprioritizing = true; | 4303 | } |
4304 | else | 4304 | |
4305 | m_reprioritization_called = true; | 4305 | private void Reprioritize(object sender, ElapsedEventArgs e) |
4306 | } | 4306 | { |
4307 | } | 4307 | m_controllingClient.ReprioritizeUpdates(); |
4308 | } | 4308 | |
4309 | 4309 | lock (m_reprioritization_timer) | |
4310 | private void Reprioritize(object sender, ElapsedEventArgs e) | 4310 | { |
4311 | { | 4311 | m_reprioritization_timer.Enabled = m_reprioritizing = m_reprioritization_called; |
4312 | m_controllingClient.ReprioritizeUpdates(); | 4312 | m_reprioritization_called = false; |
4313 | 4313 | } | |
4314 | lock (m_reprioritization_timer) | 4314 | } |
4315 | { | 4315 | |
4316 | m_reprioritization_timer.Enabled = m_reprioritizing = m_reprioritization_called; | 4316 | private Vector3 Quat2Euler(Quaternion rot){ |
4317 | m_reprioritization_called = false; | 4317 | float x = Utils.RAD_TO_DEG * (float)Math.Atan2((double)((2.0f * rot.X * rot.W) - (2.0f * rot.Y * rot.Z)) , |
4318 | } | 4318 | (double)(1 - (2.0f * rot.X * rot.X) - (2.0f * rot.Z * rot.Z))); |
4319 | } | 4319 | float y = Utils.RAD_TO_DEG * (float)Math.Asin ((double)((2.0f * rot.X * rot.Y) + (2.0f * rot.Z * rot.W))); |
4320 | 4320 | float z = Utils.RAD_TO_DEG * (float)Math.Atan2(((double)(2.0f * rot.Y * rot.W) - (2.0f * rot.X * rot.Z)) , | |
4321 | private Vector3 Quat2Euler(Quaternion rot){ | 4321 | (double)(1 - (2.0f * rot.Y * rot.Y) - (2.0f * rot.Z * rot.Z))); |
4322 | float x = Utils.RAD_TO_DEG * (float)Math.Atan2((double)((2.0f * rot.X * rot.W) - (2.0f * rot.Y * rot.Z)) , | 4322 | return(new Vector3(x,y,z)); |
4323 | (double)(1 - (2.0f * rot.X * rot.X) - (2.0f * rot.Z * rot.Z))); | 4323 | } |
4324 | float y = Utils.RAD_TO_DEG * (float)Math.Asin ((double)((2.0f * rot.X * rot.Y) + (2.0f * rot.Z * rot.W))); | 4324 | |
4325 | float z = Utils.RAD_TO_DEG * (float)Math.Atan2(((double)(2.0f * rot.Y * rot.W) - (2.0f * rot.X * rot.Z)) , | 4325 | |
4326 | (double)(1 - (2.0f * rot.Y * rot.Y) - (2.0f * rot.Z * rot.Z))); | 4326 | } |
4327 | return(new Vector3(x,y,z)); | 4327 | } |
4328 | } | ||
4329 | |||
4330 | |||
4331 | } | ||
4332 | } | ||
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs index 8a103d7..c9662ef 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs | |||
@@ -48,24 +48,42 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
48 | TestHelper.InMethod(); | 48 | TestHelper.InMethod(); |
49 | Scene scene = SceneSetupHelpers.SetupScene(); | 49 | Scene scene = SceneSetupHelpers.SetupScene(); |
50 | 50 | ||
51 | UUID ownerUuid = new UUID("00000000-0000-0000-0000-000000000010"); | 51 | UUID ownerId = new UUID("00000000-0000-0000-0000-000000000010"); |
52 | string objName = "obj1"; | 52 | string part1Name = "part1"; |
53 | UUID objUuid = new UUID("00000000-0000-0000-0000-000000000001"); | 53 | UUID part1Id = new UUID("00000000-0000-0000-0000-000000000001"); |
54 | string part2Name = "part2"; | ||
55 | UUID part2Id = new UUID("00000000-0000-0000-0000-000000000002"); | ||
54 | 56 | ||
55 | SceneObjectPart part | 57 | SceneObjectPart part1 |
56 | = new SceneObjectPart(ownerUuid, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) | 58 | = new SceneObjectPart(ownerId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) |
57 | { Name = objName, UUID = objUuid }; | 59 | { Name = part1Name, UUID = part1Id }; |
60 | SceneObjectGroup so = new SceneObjectGroup(part1); | ||
61 | SceneObjectPart part2 | ||
62 | = new SceneObjectPart(ownerId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) | ||
63 | { Name = part2Name, UUID = part2Id }; | ||
64 | so.AddPart(part2); | ||
58 | 65 | ||
59 | scene.AddNewSceneObject(new SceneObjectGroup(part), false); | 66 | scene.AddNewSceneObject(so, false); |
60 | 67 | ||
61 | SceneObjectGroup duplicatedSo | 68 | SceneObjectGroup dupeSo |
62 | = scene.SceneGraph.DuplicateObject( | 69 | = scene.SceneGraph.DuplicateObject( |
63 | part.LocalId, new Vector3(10, 0, 0), 0, ownerUuid, UUID.Zero, Quaternion.Identity); | 70 | part1.LocalId, new Vector3(10, 0, 0), 0, ownerId, UUID.Zero, Quaternion.Identity); |
71 | Assert.That(dupeSo.Children.Count, Is.EqualTo(2)); | ||
64 | 72 | ||
65 | Assert.That(duplicatedSo.Children.Count, Is.EqualTo(1)); | 73 | SceneObjectPart dupePart1 = dupeSo.GetLinkNumPart(1); |
66 | Assert.That(duplicatedSo.RootPart.LocalId, Is.Not.EqualTo(part.LocalId)); | 74 | SceneObjectPart dupePart2 = dupeSo.GetLinkNumPart(2); |
75 | Assert.That(dupePart1.LocalId, Is.Not.EqualTo(part1.LocalId)); | ||
76 | Assert.That(dupePart2.LocalId, Is.Not.EqualTo(part2.LocalId)); | ||
67 | 77 | ||
68 | //SceneObjectPart retrievedPart = scene.GetSceneObjectPart(objUuid); | 78 | Assert.That(dupePart1.Flags, Is.EqualTo(part1.Flags)); |
79 | Assert.That(dupePart2.Flags, Is.EqualTo(part2.Flags)); | ||
80 | |||
81 | /* | ||
82 | Assert.That(part1.PhysActor, Is.Not.Null); | ||
83 | Assert.That(part2.PhysActor, Is.Not.Null); | ||
84 | Assert.That(dupePart1.PhysActor, Is.Not.Null); | ||
85 | Assert.That(dupePart2.PhysActor, Is.Not.Null); | ||
86 | */ | ||
69 | } | 87 | } |
70 | } | 88 | } |
71 | } \ No newline at end of file | 89 | } \ No newline at end of file |
diff --git a/OpenSim/Services/GridService/HypergridLinker.cs b/OpenSim/Services/GridService/HypergridLinker.cs index b190f93..3d722ec 100644 --- a/OpenSim/Services/GridService/HypergridLinker.cs +++ b/OpenSim/Services/GridService/HypergridLinker.cs | |||
@@ -247,21 +247,8 @@ namespace OpenSim.Services.GridService | |||
247 | } | 247 | } |
248 | 248 | ||
249 | regInfo.RegionID = regionID; | 249 | regInfo.RegionID = regionID; |
250 | Uri uri = null; | 250 | if (regInfo.RegionName == string.Empty) |
251 | try | 251 | regInfo.RegionName = regInfo.ExternalHostName; |
252 | { | ||
253 | uri = new Uri(externalName); | ||
254 | regInfo.ExternalHostName = uri.Host; | ||
255 | regInfo.HttpPort = (uint)uri.Port; | ||
256 | } | ||
257 | catch | ||
258 | { | ||
259 | m_log.WarnFormat("[HYPERGRID LINKER]: Remote Gatekeeper at {0} provided malformed ExternalName {1}", regInfo.ExternalHostName, externalName); | ||
260 | } | ||
261 | string name = regInfo.RegionName; | ||
262 | regInfo.RegionName = regInfo.ExternalHostName + ":" + regInfo.HttpPort; | ||
263 | if (name != string.Empty) | ||
264 | regInfo.RegionName += ":" + name; | ||
265 | 252 | ||
266 | // Try get the map image | 253 | // Try get the map image |
267 | //regInfo.TerrainImage = m_GatekeeperConnector.GetMapImage(regionID, imageURL); | 254 | //regInfo.TerrainImage = m_GatekeeperConnector.GetMapImage(regionID, imageURL); |
@@ -384,8 +371,6 @@ namespace OpenSim.Services.GridService | |||
384 | 371 | ||
385 | private void AddHyperlinkRegion(GridRegion regionInfo, ulong regionHandle) | 372 | private void AddHyperlinkRegion(GridRegion regionInfo, ulong regionHandle) |
386 | { | 373 | { |
387 | //m_HyperlinkRegions[regionInfo.RegionID] = regionInfo; | ||
388 | //m_HyperlinkHandles[regionInfo.RegionID] = regionHandle; | ||
389 | 374 | ||
390 | RegionData rdata = m_GridService.RegionInfo2RegionData(regionInfo); | 375 | RegionData rdata = m_GridService.RegionInfo2RegionData(regionInfo); |
391 | int flags = (int)OpenSim.Data.RegionFlags.Hyperlink + (int)OpenSim.Data.RegionFlags.NoDirectLogin + (int)OpenSim.Data.RegionFlags.RegionOnline; | 376 | int flags = (int)OpenSim.Data.RegionFlags.Hyperlink + (int)OpenSim.Data.RegionFlags.NoDirectLogin + (int)OpenSim.Data.RegionFlags.RegionOnline; |
@@ -397,12 +382,6 @@ namespace OpenSim.Services.GridService | |||
397 | 382 | ||
398 | private void RemoveHyperlinkRegion(UUID regionID) | 383 | private void RemoveHyperlinkRegion(UUID regionID) |
399 | { | 384 | { |
400 | //// Try the hyperlink collection | ||
401 | //if (m_HyperlinkRegions.ContainsKey(regionID)) | ||
402 | //{ | ||
403 | // m_HyperlinkRegions.Remove(regionID); | ||
404 | // m_HyperlinkHandles.Remove(regionID); | ||
405 | //} | ||
406 | m_Database.Delete(regionID); | 385 | m_Database.Delete(regionID); |
407 | } | 386 | } |
408 | 387 | ||