diff options
Diffstat (limited to 'OpenSim/Region/Framework')
7 files changed, 39 insertions, 342 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index de4c5fb..a90e0f3 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs | |||
@@ -131,7 +131,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
131 | anim, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, m_scenePresence.UUID)) | 131 | anim, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, m_scenePresence.UUID)) |
132 | { | 132 | { |
133 | // 16384 is CHANGED_ANIMATION | 133 | // 16384 is CHANGED_ANIMATION |
134 | m_scenePresence.SendScriptEventToAttachments("changed", new Object[] { 16384 }); | 134 | m_scenePresence.SendScriptEventToAttachments("changed", new Object[] { (int)Changed.ANIMATION}); |
135 | SendAnimPack(); | 135 | SendAnimPack(); |
136 | } | 136 | } |
137 | } | 137 | } |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs index 0033900..4e80bf2 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs | |||
@@ -64,6 +64,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
64 | public delegate bool RunConsoleCommandHandler(UUID user, Scene requestFromScene); | 64 | public delegate bool RunConsoleCommandHandler(UUID user, Scene requestFromScene); |
65 | public delegate bool IssueEstateCommandHandler(UUID user, Scene requestFromScene, bool ownerCommand); | 65 | public delegate bool IssueEstateCommandHandler(UUID user, Scene requestFromScene, bool ownerCommand); |
66 | public delegate bool IsGodHandler(UUID user, Scene requestFromScene); | 66 | public delegate bool IsGodHandler(UUID user, Scene requestFromScene); |
67 | public delegate bool IsAdministratorHandler(UUID user); | ||
67 | public delegate bool EditParcelHandler(UUID user, ILandObject parcel, Scene scene); | 68 | public delegate bool EditParcelHandler(UUID user, ILandObject parcel, Scene scene); |
68 | public delegate bool SellParcelHandler(UUID user, ILandObject parcel, Scene scene); | 69 | public delegate bool SellParcelHandler(UUID user, ILandObject parcel, Scene scene); |
69 | public delegate bool AbandonParcelHandler(UUID user, ILandObject parcel, Scene scene); | 70 | public delegate bool AbandonParcelHandler(UUID user, ILandObject parcel, Scene scene); |
@@ -124,6 +125,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
124 | public event RunConsoleCommandHandler OnRunConsoleCommand; | 125 | public event RunConsoleCommandHandler OnRunConsoleCommand; |
125 | public event IssueEstateCommandHandler OnIssueEstateCommand; | 126 | public event IssueEstateCommandHandler OnIssueEstateCommand; |
126 | public event IsGodHandler OnIsGod; | 127 | public event IsGodHandler OnIsGod; |
128 | public event IsAdministratorHandler OnIsAdministrator; | ||
127 | public event EditParcelHandler OnEditParcel; | 129 | public event EditParcelHandler OnEditParcel; |
128 | public event SellParcelHandler OnSellParcel; | 130 | public event SellParcelHandler OnSellParcel; |
129 | public event AbandonParcelHandler OnAbandonParcel; | 131 | public event AbandonParcelHandler OnAbandonParcel; |
@@ -656,6 +658,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
656 | } | 658 | } |
657 | return true; | 659 | return true; |
658 | } | 660 | } |
661 | |||
662 | public bool IsAdministrator(UUID user) | ||
663 | { | ||
664 | IsAdministratorHandler handler = OnIsAdministrator; | ||
665 | if (handler != null) | ||
666 | { | ||
667 | Delegate[] list = handler.GetInvocationList(); | ||
668 | foreach (IsAdministratorHandler h in list) | ||
669 | { | ||
670 | if (h(user) == false) | ||
671 | return false; | ||
672 | } | ||
673 | } | ||
674 | return true; | ||
675 | } | ||
659 | #endregion | 676 | #endregion |
660 | 677 | ||
661 | #region EDIT PARCEL | 678 | #region EDIT PARCEL |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index e8dce08..dcd7f3d 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -2727,7 +2727,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2727 | IUserAgentVerificationModule userVerification = RequestModuleInterface<IUserAgentVerificationModule>(); | 2727 | IUserAgentVerificationModule userVerification = RequestModuleInterface<IUserAgentVerificationModule>(); |
2728 | if (userVerification != null && ep != null) | 2728 | if (userVerification != null && ep != null) |
2729 | { | 2729 | { |
2730 | if (!userVerification.VerifyClient(aCircuit, ep.Address.ToString())) | 2730 | System.Net.IPAddress addr = NetworkUtil.GetExternalIPOf(ep.Address); |
2731 | |||
2732 | if (!userVerification.VerifyClient(aCircuit, /*ep.Address.ToString() */ addr.ToString())) | ||
2731 | { | 2733 | { |
2732 | // uh-oh, this is fishy | 2734 | // uh-oh, this is fishy |
2733 | m_log.DebugFormat("[Scene]: User Client Verification for {0} {1} in {2} returned false", aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName); | 2735 | m_log.DebugFormat("[Scene]: User Client Verification for {0} {1} in {2} returned false", aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName); |
@@ -2785,17 +2787,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
2785 | SubscribeToClientPrimEvents(client); | 2787 | SubscribeToClientPrimEvents(client); |
2786 | SubscribeToClientPrimRezEvents(client); | 2788 | SubscribeToClientPrimRezEvents(client); |
2787 | SubscribeToClientInventoryEvents(client); | 2789 | SubscribeToClientInventoryEvents(client); |
2788 | SubscribeToClientAttachmentEvents(client); | ||
2789 | SubscribeToClientTeleportEvents(client); | 2790 | SubscribeToClientTeleportEvents(client); |
2790 | SubscribeToClientScriptEvents(client); | 2791 | SubscribeToClientScriptEvents(client); |
2791 | SubscribeToClientParcelEvents(client); | 2792 | SubscribeToClientParcelEvents(client); |
2792 | SubscribeToClientGridEvents(client); | 2793 | SubscribeToClientGridEvents(client); |
2793 | SubscribeToClientGodEvents(client); | ||
2794 | |||
2795 | SubscribeToClientNetworkEvents(client); | 2794 | SubscribeToClientNetworkEvents(client); |
2796 | |||
2797 | |||
2798 | // EventManager.TriggerOnNewClient(client); | ||
2799 | } | 2795 | } |
2800 | 2796 | ||
2801 | public virtual void SubscribeToClientTerrainEvents(IClientAPI client) | 2797 | public virtual void SubscribeToClientTerrainEvents(IClientAPI client) |
@@ -2805,8 +2801,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2805 | } | 2801 | } |
2806 | 2802 | ||
2807 | public virtual void SubscribeToClientPrimEvents(IClientAPI client) | 2803 | public virtual void SubscribeToClientPrimEvents(IClientAPI client) |
2808 | { | 2804 | { |
2809 | |||
2810 | client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimPosition; | 2805 | client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimPosition; |
2811 | client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; | 2806 | client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; |
2812 | client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimRotation; | 2807 | client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimRotation; |
@@ -2876,18 +2871,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2876 | client.OnMoveTaskItem += ClientMoveTaskInventoryItem; | 2871 | client.OnMoveTaskItem += ClientMoveTaskInventoryItem; |
2877 | } | 2872 | } |
2878 | 2873 | ||
2879 | public virtual void SubscribeToClientAttachmentEvents(IClientAPI client) | ||
2880 | { | ||
2881 | if (AttachmentsModule != null) | ||
2882 | { | ||
2883 | client.OnRezSingleAttachmentFromInv += AttachmentsModule.RezSingleAttachmentFromInventory; | ||
2884 | client.OnRezMultipleAttachmentsFromInv += AttachmentsModule.RezMultipleAttachmentsFromInventory; | ||
2885 | client.OnObjectAttach += AttachmentsModule.AttachObject; | ||
2886 | client.OnObjectDetach += AttachmentsModule.DetachObject; | ||
2887 | client.OnDetachAttachmentIntoInv += AttachmentsModule.ShowDetachInUserInventory; | ||
2888 | } | ||
2889 | } | ||
2890 | |||
2891 | public virtual void SubscribeToClientTeleportEvents(IClientAPI client) | 2874 | public virtual void SubscribeToClientTeleportEvents(IClientAPI client) |
2892 | { | 2875 | { |
2893 | client.OnTeleportLocationRequest += RequestTeleportLocation; | 2876 | client.OnTeleportLocationRequest += RequestTeleportLocation; |
@@ -2917,44 +2900,29 @@ namespace OpenSim.Region.Framework.Scenes | |||
2917 | client.OnSetStartLocationRequest += SetHomeRezPoint; | 2900 | client.OnSetStartLocationRequest += SetHomeRezPoint; |
2918 | client.OnRegionHandleRequest += RegionHandleRequest; | 2901 | client.OnRegionHandleRequest += RegionHandleRequest; |
2919 | } | 2902 | } |
2920 | 2903 | ||
2921 | public virtual void SubscribeToClientGodEvents(IClientAPI client) | ||
2922 | { | ||
2923 | IGodsModule godsModule = RequestModuleInterface<IGodsModule>(); | ||
2924 | client.OnGodKickUser += godsModule.KickUser; | ||
2925 | client.OnRequestGodlikePowers += godsModule.RequestGodlikePowers; | ||
2926 | } | ||
2927 | |||
2928 | public virtual void SubscribeToClientNetworkEvents(IClientAPI client) | 2904 | public virtual void SubscribeToClientNetworkEvents(IClientAPI client) |
2929 | { | 2905 | { |
2930 | client.OnNetworkStatsUpdate += StatsReporter.AddPacketsStats; | 2906 | client.OnNetworkStatsUpdate += StatsReporter.AddPacketsStats; |
2931 | client.OnViewerEffect += ProcessViewerEffect; | 2907 | client.OnViewerEffect += ProcessViewerEffect; |
2932 | } | 2908 | } |
2933 | 2909 | ||
2934 | protected virtual void UnsubscribeToClientEvents(IClientAPI client) | ||
2935 | { | ||
2936 | } | ||
2937 | |||
2938 | /// <summary> | 2910 | /// <summary> |
2939 | /// Register for events from the client | 2911 | /// Unsubscribe the client from events. |
2940 | /// </summary> | 2912 | /// </summary> |
2941 | /// <param name="client">The IClientAPI of the connected client</param> | 2913 | /// FIXME: Not called anywhere! |
2914 | /// <param name="client">The IClientAPI of the client</param> | ||
2942 | public virtual void UnSubscribeToClientEvents(IClientAPI client) | 2915 | public virtual void UnSubscribeToClientEvents(IClientAPI client) |
2943 | { | 2916 | { |
2944 | UnSubscribeToClientTerrainEvents(client); | 2917 | UnSubscribeToClientTerrainEvents(client); |
2945 | UnSubscribeToClientPrimEvents(client); | 2918 | UnSubscribeToClientPrimEvents(client); |
2946 | UnSubscribeToClientPrimRezEvents(client); | 2919 | UnSubscribeToClientPrimRezEvents(client); |
2947 | UnSubscribeToClientInventoryEvents(client); | 2920 | UnSubscribeToClientInventoryEvents(client); |
2948 | UnSubscribeToClientAttachmentEvents(client); | ||
2949 | UnSubscribeToClientTeleportEvents(client); | 2921 | UnSubscribeToClientTeleportEvents(client); |
2950 | UnSubscribeToClientScriptEvents(client); | 2922 | UnSubscribeToClientScriptEvents(client); |
2951 | UnSubscribeToClientParcelEvents(client); | 2923 | UnSubscribeToClientParcelEvents(client); |
2952 | UnSubscribeToClientGridEvents(client); | 2924 | UnSubscribeToClientGridEvents(client); |
2953 | UnSubscribeToClientGodEvents(client); | ||
2954 | |||
2955 | UnSubscribeToClientNetworkEvents(client); | 2925 | UnSubscribeToClientNetworkEvents(client); |
2956 | |||
2957 | // EventManager.TriggerOnNewClient(client); | ||
2958 | } | 2926 | } |
2959 | 2927 | ||
2960 | public virtual void UnSubscribeToClientTerrainEvents(IClientAPI client) | 2928 | public virtual void UnSubscribeToClientTerrainEvents(IClientAPI client) |
@@ -3031,18 +2999,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3031 | client.OnMoveTaskItem -= ClientMoveTaskInventoryItem; | 2999 | client.OnMoveTaskItem -= ClientMoveTaskInventoryItem; |
3032 | } | 3000 | } |
3033 | 3001 | ||
3034 | public virtual void UnSubscribeToClientAttachmentEvents(IClientAPI client) | ||
3035 | { | ||
3036 | if (AttachmentsModule != null) | ||
3037 | { | ||
3038 | client.OnRezSingleAttachmentFromInv -= AttachmentsModule.RezSingleAttachmentFromInventory; | ||
3039 | client.OnRezMultipleAttachmentsFromInv -= AttachmentsModule.RezMultipleAttachmentsFromInventory; | ||
3040 | client.OnObjectAttach -= AttachmentsModule.AttachObject; | ||
3041 | client.OnObjectDetach -= AttachmentsModule.DetachObject; | ||
3042 | client.OnDetachAttachmentIntoInv -= AttachmentsModule.ShowDetachInUserInventory; | ||
3043 | } | ||
3044 | } | ||
3045 | |||
3046 | public virtual void UnSubscribeToClientTeleportEvents(IClientAPI client) | 3002 | public virtual void UnSubscribeToClientTeleportEvents(IClientAPI client) |
3047 | { | 3003 | { |
3048 | client.OnTeleportLocationRequest -= RequestTeleportLocation; | 3004 | client.OnTeleportLocationRequest -= RequestTeleportLocation; |
@@ -3074,13 +3030,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3074 | client.OnRegionHandleRequest -= RegionHandleRequest; | 3030 | client.OnRegionHandleRequest -= RegionHandleRequest; |
3075 | } | 3031 | } |
3076 | 3032 | ||
3077 | public virtual void UnSubscribeToClientGodEvents(IClientAPI client) | ||
3078 | { | ||
3079 | IGodsModule godsModule = RequestModuleInterface<IGodsModule>(); | ||
3080 | client.OnGodKickUser -= godsModule.KickUser; | ||
3081 | client.OnRequestGodlikePowers -= godsModule.RequestGodlikePowers; | ||
3082 | } | ||
3083 | |||
3084 | public virtual void UnSubscribeToClientNetworkEvents(IClientAPI client) | 3033 | public virtual void UnSubscribeToClientNetworkEvents(IClientAPI client) |
3085 | { | 3034 | { |
3086 | client.OnNetworkStatsUpdate -= StatsReporter.AddPacketsStats; | 3035 | client.OnNetworkStatsUpdate -= StatsReporter.AddPacketsStats; |
@@ -5294,4 +5243,4 @@ namespace OpenSim.Region.Framework.Scenes | |||
5294 | return offsets.ToArray(); | 5243 | return offsets.ToArray(); |
5295 | } | 5244 | } |
5296 | } | 5245 | } |
5297 | } | 5246 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 40332a6..f47450f 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs | |||
@@ -78,8 +78,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
78 | // protected internal Dictionary<UUID, EntityBase> Entities = new Dictionary<UUID, EntityBase>(); | 78 | // protected internal Dictionary<UUID, EntityBase> Entities = new Dictionary<UUID, EntityBase>(); |
79 | protected internal Dictionary<UUID, ScenePresence> RestorePresences = new Dictionary<UUID, ScenePresence>(); | 79 | protected internal Dictionary<UUID, ScenePresence> RestorePresences = new Dictionary<UUID, ScenePresence>(); |
80 | 80 | ||
81 | protected internal BasicQuadTreeNode QuadTree; | ||
82 | |||
83 | protected RegionInfo m_regInfo; | 81 | protected RegionInfo m_regInfo; |
84 | protected Scene m_parentScene; | 82 | protected Scene m_parentScene; |
85 | protected Dictionary<UUID, SceneObjectGroup> m_updateList = new Dictionary<UUID, SceneObjectGroup>(); | 83 | protected Dictionary<UUID, SceneObjectGroup> m_updateList = new Dictionary<UUID, SceneObjectGroup>(); |
@@ -107,9 +105,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
107 | { | 105 | { |
108 | m_parentScene = parent; | 106 | m_parentScene = parent; |
109 | m_regInfo = regInfo; | 107 | m_regInfo = regInfo; |
110 | QuadTree = new BasicQuadTreeNode(null, "/0/", 0, 0, (short)Constants.RegionSize, (short)Constants.RegionSize); | ||
111 | QuadTree.Subdivide(); | ||
112 | QuadTree.Subdivide(); | ||
113 | } | 108 | } |
114 | 109 | ||
115 | public PhysicsScene PhysicsScene | 110 | public PhysicsScene PhysicsScene |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 32332f7..3dac0ad 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -56,10 +56,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
56 | LINK = 32, | 56 | LINK = 32, |
57 | ALLOWED_DROP = 64, | 57 | ALLOWED_DROP = 64, |
58 | OWNER = 128, | 58 | OWNER = 128, |
59 | REGION_RESTART = 256, | 59 | REGION = 256, |
60 | REGION = 512, | 60 | TELEPORT = 512, |
61 | TELEPORT = 1024, | 61 | REGION_RESTART = 1024, |
62 | MEDIA = 2048 | 62 | MEDIA = 2048, |
63 | ANIMATION = 16384 | ||
63 | } | 64 | } |
64 | 65 | ||
65 | // I don't really know where to put this except here. | 66 | // I don't really know where to put this except here. |
@@ -871,7 +872,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
871 | set | 872 | set |
872 | { | 873 | { |
873 | m_color = value; | 874 | m_color = value; |
874 | TriggerScriptChangedEvent(Changed.COLOR); | ||
875 | 875 | ||
876 | /* ScheduleFullUpdate() need not be called b/c after | 876 | /* ScheduleFullUpdate() need not be called b/c after |
877 | * setting the color, the text will be set, so then | 877 | * setting the color, the text will be set, so then |
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 1e8ce22..4c17615 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -929,7 +929,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
929 | /// </summary> | 929 | /// </summary> |
930 | public void MakeChildAgent() | 930 | public void MakeChildAgent() |
931 | { | 931 | { |
932 | Animator.ResetAnimations(); | 932 | // It looks like m_animator is set to null somewhere, and MakeChild |
933 | // is called after that. Probably in aborted teleports. | ||
934 | if (m_animator == null) | ||
935 | m_animator = new ScenePresenceAnimator(this); | ||
936 | else | ||
937 | Animator.ResetAnimations(); | ||
933 | 938 | ||
934 | // m_log.DebugFormat( | 939 | // m_log.DebugFormat( |
935 | // "[SCENEPRESENCE]: Downgrading root agent {0}, {1} to a child agent in {2}", | 940 | // "[SCENEPRESENCE]: Downgrading root agent {0}, {1} to a child agent in {2}", |
@@ -3455,7 +3460,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3455 | if (m == null) // No script engine loaded | 3460 | if (m == null) // No script engine loaded |
3456 | continue; | 3461 | continue; |
3457 | 3462 | ||
3458 | m.PostObjectEvent(grp.RootPart.UUID, "changed", new Object[] { 16384 }); | 3463 | m.PostObjectEvent(grp.RootPart.UUID, "changed", new Object[] { (int)Changed.ANIMATION }); |
3459 | } | 3464 | } |
3460 | } | 3465 | } |
3461 | } | 3466 | } |
diff --git a/OpenSim/Region/Framework/Scenes/Types/BasicQuadTreeNode.cs b/OpenSim/Region/Framework/Scenes/Types/BasicQuadTreeNode.cs deleted file mode 100644 index 38a9203..0000000 --- a/OpenSim/Region/Framework/Scenes/Types/BasicQuadTreeNode.cs +++ /dev/null | |||
@@ -1,269 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
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 | ||
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 | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using OpenSim.Region.Framework.Scenes; | ||
31 | |||
32 | namespace OpenSim.Region.Framework.Scenes.Types | ||
33 | { | ||
34 | public class BasicQuadTreeNode | ||
35 | { | ||
36 | private List<SceneObjectGroup> m_objects = new List<SceneObjectGroup>(); | ||
37 | private BasicQuadTreeNode[] m_childNodes = null; | ||
38 | private BasicQuadTreeNode m_parent = null; | ||
39 | |||
40 | private short m_leftX; | ||
41 | private short m_leftY; | ||
42 | private short m_width; | ||
43 | private short m_height; | ||
44 | //private int m_quadNumber; | ||
45 | private string m_quadID; | ||
46 | |||
47 | public BasicQuadTreeNode(BasicQuadTreeNode parent, string quadID, short leftX, short leftY, short width, | ||
48 | short height) | ||
49 | { | ||
50 | m_parent = parent; | ||
51 | m_quadID = quadID; | ||
52 | m_leftX = leftX; | ||
53 | m_leftY = leftY; | ||
54 | m_width = width; | ||
55 | m_height = height; | ||
56 | // m_log.Debug("creating quadtree node " + m_quadID); | ||
57 | } | ||
58 | |||
59 | public void AddObject(SceneObjectGroup obj) | ||
60 | { | ||
61 | if (m_childNodes == null) | ||
62 | { | ||
63 | if (!m_objects.Contains(obj)) | ||
64 | { | ||
65 | m_objects.Add(obj); | ||
66 | } | ||
67 | } | ||
68 | else | ||
69 | { | ||
70 | if (obj.AbsolutePosition.X < (m_leftX + (m_width/2))) | ||
71 | { | ||
72 | if (obj.AbsolutePosition.Y < (m_leftY + (m_height/2))) | ||
73 | { | ||
74 | m_childNodes[0].AddObject(obj); | ||
75 | } | ||
76 | else | ||
77 | { | ||
78 | m_childNodes[2].AddObject(obj); | ||
79 | } | ||
80 | } | ||
81 | else | ||
82 | { | ||
83 | if (obj.AbsolutePosition.Y < (m_leftY + (m_height/2))) | ||
84 | { | ||
85 | m_childNodes[1].AddObject(obj); | ||
86 | } | ||
87 | else | ||
88 | { | ||
89 | m_childNodes[3].AddObject(obj); | ||
90 | } | ||
91 | } | ||
92 | } | ||
93 | } | ||
94 | |||
95 | public void Subdivide() | ||
96 | { | ||
97 | if (m_childNodes == null) | ||
98 | { | ||
99 | m_childNodes = new BasicQuadTreeNode[4]; | ||
100 | m_childNodes[0] = | ||
101 | new BasicQuadTreeNode(this, m_quadID + "1/", m_leftX, m_leftY, (short) (m_width/2), | ||
102 | (short) (m_height/2)); | ||
103 | m_childNodes[1] = | ||
104 | new BasicQuadTreeNode(this, m_quadID + "2/", (short) (m_leftX + (m_width/2)), m_leftY, | ||
105 | (short) (m_width/2), (short) (m_height/2)); | ||
106 | m_childNodes[2] = | ||
107 | new BasicQuadTreeNode(this, m_quadID + "3/", m_leftX, (short) (m_leftY + (m_height/2)), | ||
108 | (short) (m_width/2), (short) (m_height/2)); | ||
109 | m_childNodes[3] = | ||
110 | new BasicQuadTreeNode(this, m_quadID + "4/", (short) (m_leftX + (m_width/2)), | ||
111 | (short) (m_height + (m_height/2)), (short) (m_width/2), (short) (m_height/2)); | ||
112 | } | ||
113 | else | ||
114 | { | ||
115 | for (int i = 0; i < m_childNodes.Length; i++) | ||
116 | { | ||
117 | m_childNodes[i].Subdivide(); | ||
118 | } | ||
119 | } | ||
120 | } | ||
121 | |||
122 | public List<SceneObjectGroup> GetObjectsFrom(float x, float y) | ||
123 | { | ||
124 | if (m_childNodes == null) | ||
125 | { | ||
126 | return new List<SceneObjectGroup>(m_objects); | ||
127 | } | ||
128 | else | ||
129 | { | ||
130 | if (x < m_leftX + (m_width/2)) | ||
131 | { | ||
132 | if (y < m_leftY + (m_height/2)) | ||
133 | { | ||
134 | return m_childNodes[0].GetObjectsFrom(x, y); | ||
135 | } | ||
136 | else | ||
137 | { | ||
138 | return m_childNodes[2].GetObjectsFrom(x, y); | ||
139 | } | ||
140 | } | ||
141 | else | ||
142 | { | ||
143 | if (y < m_leftY + (m_height/2)) | ||
144 | { | ||
145 | return m_childNodes[1].GetObjectsFrom(x, y); | ||
146 | } | ||
147 | else | ||
148 | { | ||
149 | return m_childNodes[3].GetObjectsFrom(x, y); | ||
150 | } | ||
151 | } | ||
152 | } | ||
153 | } | ||
154 | |||
155 | public List<SceneObjectGroup> GetObjectsFrom(string nodeName) | ||
156 | { | ||
157 | if (nodeName == m_quadID) | ||
158 | { | ||
159 | return new List<SceneObjectGroup>(m_objects); | ||
160 | } | ||
161 | else if (m_childNodes != null) | ||
162 | { | ||
163 | for (int i = 0; i < 4; i++) | ||
164 | { | ||
165 | List<SceneObjectGroup> retVal; | ||
166 | retVal = m_childNodes[i].GetObjectsFrom(nodeName); | ||
167 | if (retVal != null) | ||
168 | { | ||
169 | return retVal; | ||
170 | } | ||
171 | } | ||
172 | } | ||
173 | return null; | ||
174 | } | ||
175 | |||
176 | public string GetNodeID(float x, float y) | ||
177 | { | ||
178 | if (m_childNodes == null) | ||
179 | { | ||
180 | return m_quadID; | ||
181 | } | ||
182 | else | ||
183 | { | ||
184 | if (x < m_leftX + (m_width/2)) | ||
185 | { | ||
186 | if (y < m_leftY + (m_height/2)) | ||
187 | { | ||
188 | return m_childNodes[0].GetNodeID(x, y); | ||
189 | } | ||
190 | else | ||
191 | { | ||
192 | return m_childNodes[2].GetNodeID(x, y); | ||
193 | } | ||
194 | } | ||
195 | else | ||
196 | { | ||
197 | if (y < m_leftY + (m_height/2)) | ||
198 | { | ||
199 | return m_childNodes[1].GetNodeID(x, y); | ||
200 | } | ||
201 | else | ||
202 | { | ||
203 | return m_childNodes[3].GetNodeID(x, y); | ||
204 | } | ||
205 | } | ||
206 | } | ||
207 | } | ||
208 | |||
209 | public void Update() | ||
210 | { | ||
211 | if (m_childNodes != null) | ||
212 | { | ||
213 | for (int i = 0; i < 4; i++) | ||
214 | { | ||
215 | m_childNodes[i].Update(); | ||
216 | } | ||
217 | } | ||
218 | else | ||
219 | { | ||
220 | List<SceneObjectGroup> outBounds = new List<SceneObjectGroup>(); | ||
221 | foreach (SceneObjectGroup group in m_objects) | ||
222 | { | ||
223 | if (((group.AbsolutePosition.X > m_leftX) && (group.AbsolutePosition.X < (m_leftX + m_width))) && | ||
224 | ((group.AbsolutePosition.Y > m_leftY) && (group.AbsolutePosition.Y < (m_leftY + m_height)))) | ||
225 | { | ||
226 | //still in bounds | ||
227 | } | ||
228 | else | ||
229 | { | ||
230 | outBounds.Add(group); | ||
231 | } | ||
232 | } | ||
233 | |||
234 | foreach (SceneObjectGroup removee in outBounds) | ||
235 | { | ||
236 | m_objects.Remove(removee); | ||
237 | if (m_parent != null) | ||
238 | { | ||
239 | m_parent.PassUp(removee); | ||
240 | } | ||
241 | } | ||
242 | outBounds.Clear(); | ||
243 | } | ||
244 | } | ||
245 | |||
246 | public void PassUp(SceneObjectGroup group) | ||
247 | { | ||
248 | if (((group.AbsolutePosition.X > m_leftX) && (group.AbsolutePosition.X < (m_leftX + m_width))) && | ||
249 | ((group.AbsolutePosition.Y > m_leftY) && (group.AbsolutePosition.Y < (m_leftY + m_height)))) | ||
250 | { | ||
251 | AddObject(group); | ||
252 | } | ||
253 | else | ||
254 | { | ||
255 | if (m_parent != null) | ||
256 | { | ||
257 | m_parent.PassUp(group); | ||
258 | } | ||
259 | } | ||
260 | } | ||
261 | |||
262 | public string[] GetNeighbours(string nodeName) | ||
263 | { | ||
264 | string[] retVal = new string[1]; | ||
265 | retVal[0] = String.Empty; | ||
266 | return retVal; | ||
267 | } | ||
268 | } | ||
269 | } | ||