opensim-development – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | eva | 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 System.Reflection; |
||
31 | using log4net; |
||
32 | using Nini.Config; |
||
33 | using OpenMetaverse; |
||
34 | using OpenSim.Framework; |
||
35 | using OpenSim.Framework.Client; |
||
36 | using OpenSim.Region.Framework.Interfaces; |
||
37 | using OpenSim.Region.Framework.Scenes; |
||
38 | using OpenSim.Framework.Console; |
||
39 | using OpenSim.Region.Physics.Manager; |
||
40 | using Mono.Addins; |
||
41 | |||
42 | namespace OpenSim.Region.RegionCombinerModule |
||
43 | { |
||
44 | public class RegionCombinerModule : ISharedRegionModule, IRegionCombinerModule |
||
45 | { |
||
46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
||
47 | |||
48 | public string Name |
||
49 | { |
||
50 | get { return "RegionCombinerModule"; } |
||
51 | } |
||
52 | |||
53 | public Type ReplaceableInterface |
||
54 | { |
||
55 | get { return null; } |
||
56 | } |
||
57 | |||
58 | /// <summary> |
||
59 | /// Is this module enabled? |
||
60 | /// </summary> |
||
61 | private bool m_combineContiguousRegions = false; |
||
62 | |||
63 | /// <summary> |
||
64 | /// This holds the root regions for the megaregions. |
||
65 | /// </summary> |
||
66 | /// <remarks> |
||
67 | /// Usually there is only ever one megaregion (and hence only one entry here). |
||
68 | /// </remarks> |
||
69 | private Dictionary<UUID, RegionConnections> m_regions = new Dictionary<UUID, RegionConnections>(); |
||
70 | |||
71 | /// <summary> |
||
72 | /// The scenes that comprise the megaregion. |
||
73 | /// </summary> |
||
74 | private Dictionary<UUID, Scene> m_startingScenes = new Dictionary<UUID, Scene>(); |
||
75 | |||
76 | public void Initialise(IConfigSource source) |
||
77 | { |
||
78 | IConfig myConfig = source.Configs["Startup"]; |
||
79 | m_combineContiguousRegions = myConfig.GetBoolean("CombineContiguousRegions", false); |
||
80 | |||
81 | MainConsole.Instance.Commands.AddCommand( |
||
82 | "RegionCombinerModule", false, "fix-phantoms", "fix-phantoms", |
||
83 | "Fixes phantom objects after an import to a megaregion or a change from a megaregion back to normal regions", |
||
84 | FixPhantoms); |
||
85 | } |
||
86 | |||
87 | public void Close() |
||
88 | { |
||
89 | } |
||
90 | |||
91 | public void AddRegion(Scene scene) |
||
92 | { |
||
93 | if (m_combineContiguousRegions) |
||
94 | scene.RegisterModuleInterface<IRegionCombinerModule>(this); |
||
95 | } |
||
96 | |||
97 | public void RemoveRegion(Scene scene) |
||
98 | { |
||
99 | lock (m_startingScenes) |
||
100 | m_startingScenes.Remove(scene.RegionInfo.originRegionID); |
||
101 | } |
||
102 | |||
103 | public void RegionLoaded(Scene scene) |
||
104 | { |
||
105 | lock (m_startingScenes) |
||
106 | m_startingScenes.Add(scene.RegionInfo.originRegionID, scene); |
||
107 | |||
108 | if (m_combineContiguousRegions) |
||
109 | { |
||
110 | RegionLoadedDoWork(scene); |
||
111 | |||
112 | scene.EventManager.OnNewPresence += NewPresence; |
||
113 | } |
||
114 | } |
||
115 | |||
116 | public bool IsRootForMegaregion(UUID regionId) |
||
117 | { |
||
118 | lock (m_regions) |
||
119 | return m_regions.ContainsKey(regionId); |
||
120 | } |
||
121 | |||
122 | public Vector2 GetSizeOfMegaregion(UUID regionId) |
||
123 | { |
||
124 | lock (m_regions) |
||
125 | { |
||
126 | if (m_regions.ContainsKey(regionId)) |
||
127 | { |
||
128 | RegionConnections rootConn = m_regions[regionId]; |
||
129 | |||
130 | return new Vector2((float)rootConn.XEnd, (float)rootConn.YEnd); |
||
131 | } |
||
132 | } |
||
133 | |||
134 | throw new Exception(string.Format("Region with id {0} not found", regionId)); |
||
135 | } |
||
136 | |||
137 | private void NewPresence(ScenePresence presence) |
||
138 | { |
||
139 | if (presence.IsChildAgent) |
||
140 | { |
||
141 | byte[] throttleData; |
||
142 | |||
143 | try |
||
144 | { |
||
145 | throttleData = presence.ControllingClient.GetThrottlesPacked(1); |
||
146 | } |
||
147 | catch (NotImplementedException) |
||
148 | { |
||
149 | return; |
||
150 | } |
||
151 | |||
152 | if (throttleData == null) |
||
153 | return; |
||
154 | |||
155 | if (throttleData.Length == 0) |
||
156 | return; |
||
157 | |||
158 | if (throttleData.Length != 28) |
||
159 | return; |
||
160 | |||
161 | byte[] adjData; |
||
162 | int pos = 0; |
||
163 | |||
164 | if (!BitConverter.IsLittleEndian) |
||
165 | { |
||
166 | byte[] newData = new byte[7 * 4]; |
||
167 | Buffer.BlockCopy(throttleData, 0, newData, 0, 7 * 4); |
||
168 | |||
169 | for (int i = 0; i < 7; i++) |
||
170 | Array.Reverse(newData, i * 4, 4); |
||
171 | |||
172 | adjData = newData; |
||
173 | } |
||
174 | else |
||
175 | { |
||
176 | adjData = throttleData; |
||
177 | } |
||
178 | |||
179 | // 0.125f converts from bits to bytes |
||
180 | int resend = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4; |
||
181 | int land = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4; |
||
182 | int wind = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4; |
||
183 | int cloud = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4; |
||
184 | int task = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4; |
||
185 | int texture = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4; |
||
186 | int asset = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); |
||
187 | // State is a subcategory of task that we allocate a percentage to |
||
188 | |||
189 | |||
190 | //int total = resend + land + wind + cloud + task + texture + asset; |
||
191 | |||
192 | byte[] data = new byte[7 * 4]; |
||
193 | int ii = 0; |
||
194 | |||
195 | Buffer.BlockCopy(Utils.FloatToBytes(resend), 0, data, ii, 4); ii += 4; |
||
196 | Buffer.BlockCopy(Utils.FloatToBytes(land * 50), 0, data, ii, 4); ii += 4; |
||
197 | Buffer.BlockCopy(Utils.FloatToBytes(wind), 0, data, ii, 4); ii += 4; |
||
198 | Buffer.BlockCopy(Utils.FloatToBytes(cloud), 0, data, ii, 4); ii += 4; |
||
199 | Buffer.BlockCopy(Utils.FloatToBytes(task), 0, data, ii, 4); ii += 4; |
||
200 | Buffer.BlockCopy(Utils.FloatToBytes(texture), 0, data, ii, 4); ii += 4; |
||
201 | Buffer.BlockCopy(Utils.FloatToBytes(asset), 0, data, ii, 4); |
||
202 | |||
203 | try |
||
204 | { |
||
205 | presence.ControllingClient.SetChildAgentThrottle(data); |
||
206 | } |
||
207 | catch (NotImplementedException) |
||
208 | { |
||
209 | return; |
||
210 | } |
||
211 | } |
||
212 | } |
||
213 | |||
214 | private void RegionLoadedDoWork(Scene scene) |
||
215 | { |
||
216 | /* |
||
217 | // For testing on a single instance |
||
218 | if (scene.RegionInfo.RegionLocX == 1004 && scene.RegionInfo.RegionLocY == 1000) |
||
219 | return; |
||
220 | // |
||
221 | */ |
||
222 | |||
223 | // Give each region a standard set of non-infinite borders |
||
224 | Border northBorder = new Border(); |
||
225 | northBorder.BorderLine = new Vector3(0, (int)Constants.RegionSize, (int)Constants.RegionSize); //<--- |
||
226 | northBorder.CrossDirection = Cardinals.N; |
||
227 | scene.NorthBorders[0] = northBorder; |
||
228 | |||
229 | Border southBorder = new Border(); |
||
230 | southBorder.BorderLine = new Vector3(0, (int)Constants.RegionSize, 0); //---> |
||
231 | southBorder.CrossDirection = Cardinals.S; |
||
232 | scene.SouthBorders[0] = southBorder; |
||
233 | |||
234 | Border eastBorder = new Border(); |
||
235 | eastBorder.BorderLine = new Vector3(0, (int)Constants.RegionSize, (int)Constants.RegionSize); //<--- |
||
236 | eastBorder.CrossDirection = Cardinals.E; |
||
237 | scene.EastBorders[0] = eastBorder; |
||
238 | |||
239 | Border westBorder = new Border(); |
||
240 | westBorder.BorderLine = new Vector3(0, (int)Constants.RegionSize, 0); //---> |
||
241 | westBorder.CrossDirection = Cardinals.W; |
||
242 | scene.WestBorders[0] = westBorder; |
||
243 | |||
244 | RegionConnections newConn = new RegionConnections(); |
||
245 | newConn.ConnectedRegions = new List<RegionData>(); |
||
246 | newConn.RegionScene = scene; |
||
247 | newConn.RegionLandChannel = scene.LandChannel; |
||
248 | newConn.RegionId = scene.RegionInfo.originRegionID; |
||
249 | newConn.X = scene.RegionInfo.RegionLocX; |
||
250 | newConn.Y = scene.RegionInfo.RegionLocY; |
||
251 | newConn.XEnd = (int)Constants.RegionSize; |
||
252 | newConn.YEnd = (int)Constants.RegionSize; |
||
253 | |||
254 | lock (m_regions) |
||
255 | { |
||
256 | bool connectedYN = false; |
||
257 | |||
258 | foreach (RegionConnections rootConn in m_regions.Values) |
||
259 | { |
||
260 | #region commented |
||
261 | /* |
||
262 | // If we're one region over +x +y |
||
263 | //xxy |
||
264 | //xxx |
||
265 | //xxx |
||
266 | if ((((int)conn.X * (int)Constants.RegionSize) + conn.XEnd |
||
267 | == (regionConnections.X * (int)Constants.RegionSize)) |
||
268 | && (((int)conn.Y * (int)Constants.RegionSize) - conn.YEnd |
||
269 | == (regionConnections.Y * (int)Constants.RegionSize))) |
||
270 | { |
||
271 | Vector3 offset = Vector3.Zero; |
||
272 | offset.X = (((regionConnections.X * (int) Constants.RegionSize)) - |
||
273 | ((conn.X * (int) Constants.RegionSize))); |
||
274 | offset.Y = (((regionConnections.Y * (int) Constants.RegionSize)) - |
||
275 | ((conn.Y * (int) Constants.RegionSize))); |
||
276 | |||
277 | Vector3 extents = Vector3.Zero; |
||
278 | extents.Y = regionConnections.YEnd + conn.YEnd; |
||
279 | extents.X = conn.XEnd + conn.XEnd; |
||
280 | |||
281 | m_log.DebugFormat("Scene: {0} to the northwest of Scene{1}. Offset: {2}. Extents:{3}", |
||
282 | conn.RegionScene.RegionInfo.RegionName, |
||
283 | regionConnections.RegionScene.RegionInfo.RegionName, |
||
284 | offset, extents); |
||
285 | |||
286 | scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, extents); |
||
287 | |||
288 | connectedYN = true; |
||
289 | break; |
||
290 | } |
||
291 | */ |
||
292 | |||
293 | /* |
||
294 | //If we're one region over x +y |
||
295 | //xxx |
||
296 | //xxx |
||
297 | //xyx |
||
298 | if ((((int)conn.X * (int)Constants.RegionSize) |
||
299 | == (regionConnections.X * (int)Constants.RegionSize)) |
||
300 | && (((int)conn.Y * (int)Constants.RegionSize) - conn.YEnd |
||
301 | == (regionConnections.Y * (int)Constants.RegionSize))) |
||
302 | { |
||
303 | Vector3 offset = Vector3.Zero; |
||
304 | offset.X = (((regionConnections.X * (int)Constants.RegionSize)) - |
||
305 | ((conn.X * (int)Constants.RegionSize))); |
||
306 | offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) - |
||
307 | ((conn.Y * (int)Constants.RegionSize))); |
||
308 | |||
309 | Vector3 extents = Vector3.Zero; |
||
310 | extents.Y = regionConnections.YEnd + conn.YEnd; |
||
311 | extents.X = conn.XEnd; |
||
312 | |||
313 | m_log.DebugFormat("Scene: {0} to the north of Scene{1}. Offset: {2}. Extents:{3}", |
||
314 | conn.RegionScene.RegionInfo.RegionName, |
||
315 | regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); |
||
316 | |||
317 | scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, extents); |
||
318 | connectedYN = true; |
||
319 | break; |
||
320 | } |
||
321 | */ |
||
322 | |||
323 | /* |
||
324 | // If we're one region over -x +y |
||
325 | //xxx |
||
326 | //xxx |
||
327 | //yxx |
||
328 | if ((((int)conn.X * (int)Constants.RegionSize) - conn.XEnd |
||
329 | == (regionConnections.X * (int)Constants.RegionSize)) |
||
330 | && (((int)conn.Y * (int)Constants.RegionSize) - conn.YEnd |
||
331 | == (regionConnections.Y * (int)Constants.RegionSize))) |
||
332 | { |
||
333 | Vector3 offset = Vector3.Zero; |
||
334 | offset.X = (((regionConnections.X * (int)Constants.RegionSize)) - |
||
335 | ((conn.X * (int)Constants.RegionSize))); |
||
336 | offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) - |
||
337 | ((conn.Y * (int)Constants.RegionSize))); |
||
338 | |||
339 | Vector3 extents = Vector3.Zero; |
||
340 | extents.Y = regionConnections.YEnd + conn.YEnd; |
||
341 | extents.X = conn.XEnd + conn.XEnd; |
||
342 | |||
343 | m_log.DebugFormat("Scene: {0} to the northeast of Scene. Offset: {2}. Extents:{3}", |
||
344 | conn.RegionScene.RegionInfo.RegionName, |
||
345 | regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); |
||
346 | |||
347 | scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, extents); |
||
348 | |||
349 | |||
350 | connectedYN = true; |
||
351 | break; |
||
352 | } |
||
353 | */ |
||
354 | |||
355 | /* |
||
356 | // If we're one region over -x y |
||
357 | //xxx |
||
358 | //yxx |
||
359 | //xxx |
||
360 | if ((((int)conn.X * (int)Constants.RegionSize) - conn.XEnd |
||
361 | == (regionConnections.X * (int)Constants.RegionSize)) |
||
362 | && (((int)conn.Y * (int)Constants.RegionSize) |
||
363 | == (regionConnections.Y * (int)Constants.RegionSize))) |
||
364 | { |
||
365 | Vector3 offset = Vector3.Zero; |
||
366 | offset.X = (((regionConnections.X * (int)Constants.RegionSize)) - |
||
367 | ((conn.X * (int)Constants.RegionSize))); |
||
368 | offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) - |
||
369 | ((conn.Y * (int)Constants.RegionSize))); |
||
370 | |||
371 | Vector3 extents = Vector3.Zero; |
||
372 | extents.Y = regionConnections.YEnd; |
||
373 | extents.X = conn.XEnd + conn.XEnd; |
||
374 | |||
375 | m_log.DebugFormat("Scene: {0} to the east of Scene{1} Offset: {2}. Extents:{3}", |
||
376 | conn.RegionScene.RegionInfo.RegionName, |
||
377 | regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); |
||
378 | |||
379 | scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, extents); |
||
380 | |||
381 | connectedYN = true; |
||
382 | break; |
||
383 | } |
||
384 | */ |
||
385 | |||
386 | /* |
||
387 | // If we're one region over -x -y |
||
388 | //yxx |
||
389 | //xxx |
||
390 | //xxx |
||
391 | if ((((int)conn.X * (int)Constants.RegionSize) - conn.XEnd |
||
392 | == (regionConnections.X * (int)Constants.RegionSize)) |
||
393 | && (((int)conn.Y * (int)Constants.RegionSize) + conn.YEnd |
||
394 | == (regionConnections.Y * (int)Constants.RegionSize))) |
||
395 | { |
||
396 | Vector3 offset = Vector3.Zero; |
||
397 | offset.X = (((regionConnections.X * (int)Constants.RegionSize)) - |
||
398 | ((conn.X * (int)Constants.RegionSize))); |
||
399 | offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) - |
||
400 | ((conn.Y * (int)Constants.RegionSize))); |
||
401 | |||
402 | Vector3 extents = Vector3.Zero; |
||
403 | extents.Y = regionConnections.YEnd + conn.YEnd; |
||
404 | extents.X = conn.XEnd + conn.XEnd; |
||
405 | |||
406 | m_log.DebugFormat("Scene: {0} to the northeast of Scene{1} Offset: {2}. Extents:{3}", |
||
407 | conn.RegionScene.RegionInfo.RegionName, |
||
408 | regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); |
||
409 | |||
410 | scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, extents); |
||
411 | |||
412 | connectedYN = true; |
||
413 | break; |
||
414 | } |
||
415 | */ |
||
416 | #endregion |
||
417 | |||
418 | // If we're one region over +x y (i.e. root region is to the west) |
||
419 | //xxx |
||
420 | //xxy |
||
421 | //xxx |
||
422 | if (rootConn.PosX + rootConn.XEnd >= newConn.PosX && rootConn.PosY >= newConn.PosY) |
||
423 | { |
||
424 | connectedYN = DoWorkForOneRegionOverPlusXY(rootConn, newConn, scene); |
||
425 | break; |
||
426 | } |
||
427 | |||
428 | // If we're one region over x +y (i.e. root region is to the south) |
||
429 | //xyx |
||
430 | //xxx |
||
431 | //xxx |
||
432 | if (rootConn.PosX >= newConn.PosX && rootConn.PosY + rootConn.YEnd >= newConn.PosY) |
||
433 | { |
||
434 | connectedYN = DoWorkForOneRegionOverXPlusY(rootConn, newConn, scene); |
||
435 | break; |
||
436 | } |
||
437 | |||
438 | // If we're one region over +x +y (i.e. root region is to the south-west) |
||
439 | //xxy |
||
440 | //xxx |
||
441 | //xxx |
||
442 | if (rootConn.PosX + rootConn.XEnd >= newConn.PosX && rootConn.PosY + rootConn.YEnd >= newConn.PosY) |
||
443 | { |
||
444 | connectedYN = DoWorkForOneRegionOverPlusXPlusY(rootConn, newConn, scene); |
||
445 | break; |
||
446 | |||
447 | } |
||
448 | } |
||
449 | |||
450 | // If !connectYN means that this region is a root region |
||
451 | if (!connectedYN) |
||
452 | { |
||
453 | DoWorkForRootRegion(newConn, scene); |
||
454 | } |
||
455 | } |
||
456 | |||
457 | // Set up infinite borders around the entire AABB of the combined ConnectedRegions |
||
458 | AdjustLargeRegionBounds(); |
||
459 | } |
||
460 | |||
461 | private bool DoWorkForOneRegionOverPlusXY(RegionConnections rootConn, RegionConnections newConn, Scene scene) |
||
462 | { |
||
463 | Vector3 offset = Vector3.Zero; |
||
464 | offset.X = newConn.PosX - rootConn.PosX; |
||
465 | offset.Y = newConn.PosY - rootConn.PosY; |
||
466 | |||
467 | Vector3 extents = Vector3.Zero; |
||
468 | extents.Y = rootConn.YEnd; |
||
469 | extents.X = rootConn.XEnd + newConn.XEnd; |
||
470 | |||
471 | rootConn.UpdateExtents(extents); |
||
472 | |||
473 | m_log.DebugFormat( |
||
474 | "[REGION COMBINER MODULE]: Root region {0} is to the west of region {1}, Offset: {2}, Extents: {3}", |
||
475 | rootConn.RegionScene.RegionInfo.RegionName, |
||
476 | newConn.RegionScene.RegionInfo.RegionName, offset, extents); |
||
477 | |||
478 | scene.BordersLocked = true; |
||
479 | rootConn.RegionScene.BordersLocked = true; |
||
480 | |||
481 | RegionData ConnectedRegion = new RegionData(); |
||
482 | ConnectedRegion.Offset = offset; |
||
483 | ConnectedRegion.RegionId = scene.RegionInfo.originRegionID; |
||
484 | ConnectedRegion.RegionScene = scene; |
||
485 | rootConn.ConnectedRegions.Add(ConnectedRegion); |
||
486 | |||
487 | // Inform root region Physics about the extents of this region |
||
488 | rootConn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents); |
||
489 | |||
490 | // Inform Child region that it needs to forward it's terrain to the root region |
||
491 | scene.PhysicsScene.Combine(rootConn.RegionScene.PhysicsScene, offset, Vector3.Zero); |
||
492 | |||
493 | // Extend the borders as appropriate |
||
494 | lock (rootConn.RegionScene.EastBorders) |
||
495 | rootConn.RegionScene.EastBorders[0].BorderLine.Z += (int)Constants.RegionSize; |
||
496 | |||
497 | lock (rootConn.RegionScene.NorthBorders) |
||
498 | rootConn.RegionScene.NorthBorders[0].BorderLine.Y += (int)Constants.RegionSize; |
||
499 | |||
500 | lock (rootConn.RegionScene.SouthBorders) |
||
501 | rootConn.RegionScene.SouthBorders[0].BorderLine.Y += (int)Constants.RegionSize; |
||
502 | |||
503 | lock (scene.WestBorders) |
||
504 | { |
||
505 | scene.WestBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocX - rootConn.RegionScene.RegionInfo.RegionLocX) * (int)Constants.RegionSize); //auto teleport West |
||
506 | |||
507 | // Trigger auto teleport to root region |
||
508 | scene.WestBorders[0].TriggerRegionX = rootConn.RegionScene.RegionInfo.RegionLocX; |
||
509 | scene.WestBorders[0].TriggerRegionY = rootConn.RegionScene.RegionInfo.RegionLocY; |
||
510 | } |
||
511 | |||
512 | // Reset Terrain.. since terrain loads before we get here, we need to load |
||
513 | // it again so it loads in the root region |
||
514 | |||
515 | scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised()); |
||
516 | |||
517 | // Unlock borders |
||
518 | rootConn.RegionScene.BordersLocked = false; |
||
519 | scene.BordersLocked = false; |
||
520 | |||
521 | // Create a client event forwarder and add this region's events to the root region. |
||
522 | if (rootConn.ClientEventForwarder != null) |
||
523 | rootConn.ClientEventForwarder.AddSceneToEventForwarding(scene); |
||
524 | |||
525 | return true; |
||
526 | } |
||
527 | |||
528 | private bool DoWorkForOneRegionOverXPlusY(RegionConnections rootConn, RegionConnections newConn, Scene scene) |
||
529 | { |
||
530 | Vector3 offset = Vector3.Zero; |
||
531 | offset.X = newConn.PosX - rootConn.PosX; |
||
532 | offset.Y = newConn.PosY - rootConn.PosY; |
||
533 | |||
534 | Vector3 extents = Vector3.Zero; |
||
535 | extents.Y = newConn.YEnd + rootConn.YEnd; |
||
536 | extents.X = rootConn.XEnd; |
||
537 | rootConn.UpdateExtents(extents); |
||
538 | |||
539 | scene.BordersLocked = true; |
||
540 | rootConn.RegionScene.BordersLocked = true; |
||
541 | |||
542 | RegionData ConnectedRegion = new RegionData(); |
||
543 | ConnectedRegion.Offset = offset; |
||
544 | ConnectedRegion.RegionId = scene.RegionInfo.originRegionID; |
||
545 | ConnectedRegion.RegionScene = scene; |
||
546 | rootConn.ConnectedRegions.Add(ConnectedRegion); |
||
547 | |||
548 | m_log.DebugFormat( |
||
549 | "[REGION COMBINER MODULE]: Root region {0} is to the south of region {1}, Offset: {2}, Extents: {3}", |
||
550 | rootConn.RegionScene.RegionInfo.RegionName, |
||
551 | newConn.RegionScene.RegionInfo.RegionName, offset, extents); |
||
552 | |||
553 | rootConn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents); |
||
554 | scene.PhysicsScene.Combine(rootConn.RegionScene.PhysicsScene, offset, Vector3.Zero); |
||
555 | |||
556 | lock (rootConn.RegionScene.NorthBorders) |
||
557 | rootConn.RegionScene.NorthBorders[0].BorderLine.Z += (int)Constants.RegionSize; |
||
558 | |||
559 | lock (rootConn.RegionScene.EastBorders) |
||
560 | rootConn.RegionScene.EastBorders[0].BorderLine.Y += (int)Constants.RegionSize; |
||
561 | |||
562 | lock (rootConn.RegionScene.WestBorders) |
||
563 | rootConn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize; |
||
564 | |||
565 | lock (scene.SouthBorders) |
||
566 | { |
||
567 | scene.SouthBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocY - rootConn.RegionScene.RegionInfo.RegionLocY) * (int)Constants.RegionSize); //auto teleport south |
||
568 | scene.SouthBorders[0].TriggerRegionX = rootConn.RegionScene.RegionInfo.RegionLocX; |
||
569 | scene.SouthBorders[0].TriggerRegionY = rootConn.RegionScene.RegionInfo.RegionLocY; |
||
570 | } |
||
571 | |||
572 | // Reset Terrain.. since terrain normally loads first. |
||
573 | //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); |
||
574 | scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised()); |
||
575 | //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); |
||
576 | |||
577 | scene.BordersLocked = false; |
||
578 | rootConn.RegionScene.BordersLocked = false; |
||
579 | |||
580 | if (rootConn.ClientEventForwarder != null) |
||
581 | rootConn.ClientEventForwarder.AddSceneToEventForwarding(scene); |
||
582 | |||
583 | return true; |
||
584 | } |
||
585 | |||
586 | private bool DoWorkForOneRegionOverPlusXPlusY(RegionConnections rootConn, RegionConnections newConn, Scene scene) |
||
587 | { |
||
588 | Vector3 offset = Vector3.Zero; |
||
589 | offset.X = newConn.PosX - rootConn.PosX; |
||
590 | offset.Y = newConn.PosY - rootConn.PosY; |
||
591 | |||
592 | Vector3 extents = Vector3.Zero; |
||
593 | |||
594 | // We do not want to inflate the extents for regions strictly to the NE of the root region, since this |
||
595 | // would double count regions strictly to the north and east that have already been added. |
||
596 | // extents.Y = regionConnections.YEnd + conn.YEnd; |
||
597 | // extents.X = regionConnections.XEnd + conn.XEnd; |
||
598 | // conn.UpdateExtents(extents); |
||
599 | |||
600 | extents.Y = rootConn.YEnd; |
||
601 | extents.X = rootConn.XEnd; |
||
602 | |||
603 | scene.BordersLocked = true; |
||
604 | rootConn.RegionScene.BordersLocked = true; |
||
605 | |||
606 | RegionData ConnectedRegion = new RegionData(); |
||
607 | ConnectedRegion.Offset = offset; |
||
608 | ConnectedRegion.RegionId = scene.RegionInfo.originRegionID; |
||
609 | ConnectedRegion.RegionScene = scene; |
||
610 | |||
611 | rootConn.ConnectedRegions.Add(ConnectedRegion); |
||
612 | |||
613 | m_log.DebugFormat( |
||
614 | "[REGION COMBINER MODULE]: Region {0} is to the southwest of Scene {1}, Offset: {2}, Extents: {3}", |
||
615 | rootConn.RegionScene.RegionInfo.RegionName, |
||
616 | newConn.RegionScene.RegionInfo.RegionName, offset, extents); |
||
617 | |||
618 | rootConn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents); |
||
619 | scene.PhysicsScene.Combine(rootConn.RegionScene.PhysicsScene, offset, Vector3.Zero); |
||
620 | |||
621 | lock (rootConn.RegionScene.NorthBorders) |
||
622 | { |
||
623 | if (rootConn.RegionScene.NorthBorders.Count == 1)// && 2) |
||
624 | { |
||
625 | //compound border |
||
626 | // already locked above |
||
627 | rootConn.RegionScene.NorthBorders[0].BorderLine.Z += (int)Constants.RegionSize; |
||
628 | |||
629 | lock (rootConn.RegionScene.EastBorders) |
||
630 | rootConn.RegionScene.EastBorders[0].BorderLine.Y += (int)Constants.RegionSize; |
||
631 | |||
632 | lock (rootConn.RegionScene.WestBorders) |
||
633 | rootConn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize; |
||
634 | } |
||
635 | } |
||
636 | |||
637 | lock (scene.SouthBorders) |
||
638 | { |
||
639 | scene.SouthBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocY - rootConn.RegionScene.RegionInfo.RegionLocY) * (int)Constants.RegionSize); //auto teleport south |
||
640 | scene.SouthBorders[0].TriggerRegionX = rootConn.RegionScene.RegionInfo.RegionLocX; |
||
641 | scene.SouthBorders[0].TriggerRegionY = rootConn.RegionScene.RegionInfo.RegionLocY; |
||
642 | } |
||
643 | |||
644 | lock (rootConn.RegionScene.EastBorders) |
||
645 | { |
||
646 | if (rootConn.RegionScene.EastBorders.Count == 1)// && conn.RegionScene.EastBorders.Count == 2) |
||
647 | { |
||
648 | rootConn.RegionScene.EastBorders[0].BorderLine.Z += (int)Constants.RegionSize; |
||
649 | |||
650 | lock (rootConn.RegionScene.NorthBorders) |
||
651 | rootConn.RegionScene.NorthBorders[0].BorderLine.Y += (int)Constants.RegionSize; |
||
652 | |||
653 | lock (rootConn.RegionScene.SouthBorders) |
||
654 | rootConn.RegionScene.SouthBorders[0].BorderLine.Y += (int)Constants.RegionSize; |
||
655 | } |
||
656 | } |
||
657 | |||
658 | lock (scene.WestBorders) |
||
659 | { |
||
660 | scene.WestBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocX - rootConn.RegionScene.RegionInfo.RegionLocX) * (int)Constants.RegionSize); //auto teleport West |
||
661 | scene.WestBorders[0].TriggerRegionX = rootConn.RegionScene.RegionInfo.RegionLocX; |
||
662 | scene.WestBorders[0].TriggerRegionY = rootConn.RegionScene.RegionInfo.RegionLocY; |
||
663 | } |
||
664 | |||
665 | /* |
||
666 | else |
||
667 | { |
||
668 | conn.RegionScene.NorthBorders[0].BorderLine.Z += (int)Constants.RegionSize; |
||
669 | conn.RegionScene.EastBorders[0].BorderLine.Y += (int)Constants.RegionSize; |
||
670 | conn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize; |
||
671 | scene.SouthBorders[0].BorderLine.Z += (int)Constants.RegionSize; //auto teleport south |
||
672 | } |
||
673 | */ |
||
674 | |||
675 | |||
676 | // Reset Terrain.. since terrain normally loads first. |
||
677 | //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); |
||
678 | scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised()); |
||
679 | //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); |
||
680 | scene.BordersLocked = false; |
||
681 | rootConn.RegionScene.BordersLocked = false; |
||
682 | |||
683 | if (rootConn.ClientEventForwarder != null) |
||
684 | rootConn.ClientEventForwarder.AddSceneToEventForwarding(scene); |
||
685 | |||
686 | return true; |
||
687 | |||
688 | //scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset,extents); |
||
689 | } |
||
690 | |||
691 | private void DoWorkForRootRegion(RegionConnections rootConn, Scene scene) |
||
692 | { |
||
693 | m_log.DebugFormat("[REGION COMBINER MODULE]: Adding root region {0}", scene.RegionInfo.RegionName); |
||
694 | |||
695 | RegionData rdata = new RegionData(); |
||
696 | rdata.Offset = Vector3.Zero; |
||
697 | rdata.RegionId = scene.RegionInfo.originRegionID; |
||
698 | rdata.RegionScene = scene; |
||
699 | // save it's land channel |
||
700 | rootConn.RegionLandChannel = scene.LandChannel; |
||
701 | |||
702 | // Substitue our landchannel |
||
703 | RegionCombinerLargeLandChannel lnd = new RegionCombinerLargeLandChannel(rdata, scene.LandChannel, |
||
704 | rootConn.ConnectedRegions); |
||
705 | |||
706 | scene.LandChannel = lnd; |
||
707 | |||
708 | // Forward the permissions modules of each of the connected regions to the root region |
||
709 | lock (m_regions) |
||
710 | { |
||
711 | foreach (RegionData r in rootConn.ConnectedRegions) |
||
712 | { |
||
713 | ForwardPermissionRequests(rootConn, r.RegionScene); |
||
714 | } |
||
715 | |||
716 | // Create the root region's Client Event Forwarder |
||
717 | rootConn.ClientEventForwarder = new RegionCombinerClientEventForwarder(rootConn); |
||
718 | |||
719 | // Sets up the CoarseLocationUpdate forwarder for this root region |
||
720 | scene.EventManager.OnNewPresence += SetCoarseLocationDelegate; |
||
721 | |||
722 | // Adds this root region to a dictionary of regions that are connectable |
||
723 | m_regions.Add(scene.RegionInfo.originRegionID, rootConn); |
||
724 | } |
||
725 | } |
||
726 | |||
727 | private void SetCoarseLocationDelegate(ScenePresence presence) |
||
728 | { |
||
729 | presence.SetSendCoarseLocationMethod(SendCoarseLocationUpdates); |
||
730 | } |
||
731 | |||
732 | // This delegate was refactored for non-combined regions. |
||
733 | // This combined region version will not use the pre-compiled lists of locations and ids |
||
734 | private void SendCoarseLocationUpdates(UUID sceneId, ScenePresence presence, List<Vector3> coarseLocations, List<UUID> avatarUUIDs) |
||
735 | { |
||
736 | RegionConnections connectiondata = null; |
||
737 | lock (m_regions) |
||
738 | { |
||
739 | if (m_regions.ContainsKey(sceneId)) |
||
740 | connectiondata = m_regions[sceneId]; |
||
741 | else |
||
742 | return; |
||
743 | } |
||
744 | |||
745 | List<Vector3> CoarseLocations = new List<Vector3>(); |
||
746 | List<UUID> AvatarUUIDs = new List<UUID>(); |
||
747 | |||
748 | connectiondata.RegionScene.ForEachRootScenePresence(delegate(ScenePresence sp) |
||
749 | { |
||
750 | if (sp.UUID != presence.UUID) |
||
751 | { |
||
752 | CoarseLocations.Add(sp.AbsolutePosition); |
||
753 | AvatarUUIDs.Add(sp.UUID); |
||
754 | } |
||
755 | }); |
||
756 | |||
757 | DistributeCoarseLocationUpdates(CoarseLocations, AvatarUUIDs, connectiondata, presence); |
||
758 | } |
||
759 | |||
760 | private void DistributeCoarseLocationUpdates(List<Vector3> locations, List<UUID> uuids, |
||
761 | RegionConnections connectiondata, ScenePresence rootPresence) |
||
762 | { |
||
763 | RegionData[] rdata = connectiondata.ConnectedRegions.ToArray(); |
||
764 | //List<IClientAPI> clients = new List<IClientAPI>(); |
||
765 | Dictionary<Vector2, RegionCoarseLocationStruct> updates = new Dictionary<Vector2, RegionCoarseLocationStruct>(); |
||
766 | |||
767 | // Root Region entry |
||
768 | RegionCoarseLocationStruct rootupdatedata = new RegionCoarseLocationStruct(); |
||
769 | rootupdatedata.Locations = new List<Vector3>(); |
||
770 | rootupdatedata.Uuids = new List<UUID>(); |
||
771 | rootupdatedata.Offset = Vector2.Zero; |
||
772 | |||
773 | rootupdatedata.UserAPI = rootPresence.ControllingClient; |
||
774 | |||
775 | if (rootupdatedata.UserAPI != null) |
||
776 | updates.Add(Vector2.Zero, rootupdatedata); |
||
777 | |||
778 | //Each Region needs an entry or we will end up with dead minimap dots |
||
779 | foreach (RegionData regiondata in rdata) |
||
780 | { |
||
781 | Vector2 offset = new Vector2(regiondata.Offset.X, regiondata.Offset.Y); |
||
782 | RegionCoarseLocationStruct updatedata = new RegionCoarseLocationStruct(); |
||
783 | updatedata.Locations = new List<Vector3>(); |
||
784 | updatedata.Uuids = new List<UUID>(); |
||
785 | updatedata.Offset = offset; |
||
786 | |||
787 | if (offset == Vector2.Zero) |
||
788 | updatedata.UserAPI = rootPresence.ControllingClient; |
||
789 | else |
||
790 | updatedata.UserAPI = LocateUsersChildAgentIClientAPI(offset, rootPresence.UUID, rdata); |
||
791 | |||
792 | if (updatedata.UserAPI != null) |
||
793 | updates.Add(offset, updatedata); |
||
794 | } |
||
795 | |||
796 | // go over the locations and assign them to an IClientAPI |
||
797 | for (int i = 0; i < locations.Count; i++) |
||
798 | //{locations[i]/(int) Constants.RegionSize; |
||
799 | { |
||
800 | Vector3 pPosition = new Vector3((int)locations[i].X / (int)Constants.RegionSize, |
||
801 | (int)locations[i].Y / (int)Constants.RegionSize, locations[i].Z); |
||
802 | Vector2 offset = new Vector2(pPosition.X*(int) Constants.RegionSize, |
||
803 | pPosition.Y*(int) Constants.RegionSize); |
||
804 | |||
805 | if (!updates.ContainsKey(offset)) |
||
806 | { |
||
807 | // This shouldn't happen |
||
808 | RegionCoarseLocationStruct updatedata = new RegionCoarseLocationStruct(); |
||
809 | updatedata.Locations = new List<Vector3>(); |
||
810 | updatedata.Uuids = new List<UUID>(); |
||
811 | updatedata.Offset = offset; |
||
812 | |||
813 | if (offset == Vector2.Zero) |
||
814 | updatedata.UserAPI = rootPresence.ControllingClient; |
||
815 | else |
||
816 | updatedata.UserAPI = LocateUsersChildAgentIClientAPI(offset, rootPresence.UUID, rdata); |
||
817 | |||
818 | updates.Add(offset,updatedata); |
||
819 | } |
||
820 | |||
821 | updates[offset].Locations.Add(locations[i]); |
||
822 | updates[offset].Uuids.Add(uuids[i]); |
||
823 | } |
||
824 | |||
825 | // Send out the CoarseLocationupdates from their respective client connection based on where the avatar is |
||
826 | foreach (Vector2 offset in updates.Keys) |
||
827 | { |
||
828 | if (updates[offset].UserAPI != null) |
||
829 | { |
||
830 | updates[offset].UserAPI.SendCoarseLocationUpdate(updates[offset].Uuids,updates[offset].Locations); |
||
831 | } |
||
832 | } |
||
833 | } |
||
834 | |||
835 | /// <summary> |
||
836 | /// Locates a the Client of a particular region in an Array of RegionData based on offset |
||
837 | /// </summary> |
||
838 | /// <param name="offset"></param> |
||
839 | /// <param name="uUID"></param> |
||
840 | /// <param name="rdata"></param> |
||
841 | /// <returns>IClientAPI or null</returns> |
||
842 | private IClientAPI LocateUsersChildAgentIClientAPI(Vector2 offset, UUID uUID, RegionData[] rdata) |
||
843 | { |
||
844 | IClientAPI returnclient = null; |
||
845 | foreach (RegionData r in rdata) |
||
846 | { |
||
847 | if (r.Offset.X == offset.X && r.Offset.Y == offset.Y) |
||
848 | { |
||
849 | return r.RegionScene.SceneGraph.GetControllingClient(uUID); |
||
850 | } |
||
851 | } |
||
852 | |||
853 | return returnclient; |
||
854 | } |
||
855 | |||
856 | public void PostInitialise() |
||
857 | { |
||
858 | } |
||
859 | |||
860 | // /// <summary> |
||
861 | // /// TODO: |
||
862 | // /// </summary> |
||
863 | // /// <param name="rdata"></param> |
||
864 | // public void UnCombineRegion(RegionData rdata) |
||
865 | // { |
||
866 | // lock (m_regions) |
||
867 | // { |
||
868 | // if (m_regions.ContainsKey(rdata.RegionId)) |
||
869 | // { |
||
870 | // // uncombine root region and virtual regions |
||
871 | // } |
||
872 | // else |
||
873 | // { |
||
874 | // foreach (RegionConnections r in m_regions.Values) |
||
875 | // { |
||
876 | // foreach (RegionData rd in r.ConnectedRegions) |
||
877 | // { |
||
878 | // if (rd.RegionId == rdata.RegionId) |
||
879 | // { |
||
880 | // // uncombine virtual region |
||
881 | // } |
||
882 | // } |
||
883 | // } |
||
884 | // } |
||
885 | // } |
||
886 | // } |
||
887 | |||
888 | // Create a set of infinite borders around the whole aabb of the combined island. |
||
889 | private void AdjustLargeRegionBounds() |
||
890 | { |
||
891 | lock (m_regions) |
||
892 | { |
||
893 | foreach (RegionConnections rconn in m_regions.Values) |
||
894 | { |
||
895 | Vector3 offset = Vector3.Zero; |
||
896 | rconn.RegionScene.BordersLocked = true; |
||
897 | foreach (RegionData rdata in rconn.ConnectedRegions) |
||
898 | { |
||
899 | if (rdata.Offset.X > offset.X) offset.X = rdata.Offset.X; |
||
900 | if (rdata.Offset.Y > offset.Y) offset.Y = rdata.Offset.Y; |
||
901 | } |
||
902 | |||
903 | lock (rconn.RegionScene.NorthBorders) |
||
904 | { |
||
905 | Border northBorder = null; |
||
906 | // If we don't already have an infinite border, create one. |
||
907 | if (!TryGetInfiniteBorder(rconn.RegionScene.NorthBorders, out northBorder)) |
||
908 | { |
||
909 | northBorder = new Border(); |
||
910 | rconn.RegionScene.NorthBorders.Add(northBorder); |
||
911 | } |
||
912 | |||
913 | northBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, |
||
914 | offset.Y + (int) Constants.RegionSize); //<--- |
||
915 | northBorder.CrossDirection = Cardinals.N; |
||
916 | } |
||
917 | |||
918 | lock (rconn.RegionScene.SouthBorders) |
||
919 | { |
||
920 | Border southBorder = null; |
||
921 | // If we don't already have an infinite border, create one. |
||
922 | if (!TryGetInfiniteBorder(rconn.RegionScene.SouthBorders, out southBorder)) |
||
923 | { |
||
924 | southBorder = new Border(); |
||
925 | rconn.RegionScene.SouthBorders.Add(southBorder); |
||
926 | } |
||
927 | southBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, 0); //---> |
||
928 | southBorder.CrossDirection = Cardinals.S; |
||
929 | } |
||
930 | |||
931 | lock (rconn.RegionScene.EastBorders) |
||
932 | { |
||
933 | Border eastBorder = null; |
||
934 | // If we don't already have an infinite border, create one. |
||
935 | if (!TryGetInfiniteBorder(rconn.RegionScene.EastBorders, out eastBorder)) |
||
936 | { |
||
937 | eastBorder = new Border(); |
||
938 | rconn.RegionScene.EastBorders.Add(eastBorder); |
||
939 | } |
||
940 | eastBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, offset.X + (int)Constants.RegionSize); |
||
941 | //<--- |
||
942 | eastBorder.CrossDirection = Cardinals.E; |
||
943 | } |
||
944 | |||
945 | lock (rconn.RegionScene.WestBorders) |
||
946 | { |
||
947 | Border westBorder = null; |
||
948 | // If we don't already have an infinite border, create one. |
||
949 | if (!TryGetInfiniteBorder(rconn.RegionScene.WestBorders, out westBorder)) |
||
950 | { |
||
951 | westBorder = new Border(); |
||
952 | rconn.RegionScene.WestBorders.Add(westBorder); |
||
953 | |||
954 | } |
||
955 | westBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, 0); //---> |
||
956 | westBorder.CrossDirection = Cardinals.W; |
||
957 | } |
||
958 | |||
959 | rconn.RegionScene.BordersLocked = false; |
||
960 | } |
||
961 | } |
||
962 | } |
||
963 | |||
964 | /// <summary> |
||
965 | /// Try and get an Infinite border out of a listT of borders |
||
966 | /// </summary> |
||
967 | /// <param name="borders"></param> |
||
968 | /// <param name="oborder"></param> |
||
969 | /// <returns></returns> |
||
970 | public static bool TryGetInfiniteBorder(List<Border> borders, out Border oborder) |
||
971 | { |
||
972 | // Warning! Should be locked before getting here! |
||
973 | foreach (Border b in borders) |
||
974 | { |
||
975 | if (b.BorderLine.X == float.MinValue && b.BorderLine.Y == float.MaxValue) |
||
976 | { |
||
977 | oborder = b; |
||
978 | return true; |
||
979 | } |
||
980 | } |
||
981 | |||
982 | oborder = null; |
||
983 | return false; |
||
984 | } |
||
985 | |||
986 | public RegionData GetRegionFromPosition(Vector3 pPosition) |
||
987 | { |
||
988 | pPosition = pPosition/(int) Constants.RegionSize; |
||
989 | int OffsetX = (int) pPosition.X; |
||
990 | int OffsetY = (int) pPosition.Y; |
||
991 | |||
992 | lock (m_regions) |
||
993 | { |
||
994 | foreach (RegionConnections regConn in m_regions.Values) |
||
995 | { |
||
996 | foreach (RegionData reg in regConn.ConnectedRegions) |
||
997 | { |
||
998 | if (reg.Offset.X == OffsetX && reg.Offset.Y == OffsetY) |
||
999 | return reg; |
||
1000 | } |
||
1001 | } |
||
1002 | } |
||
1003 | |||
1004 | return new RegionData(); |
||
1005 | } |
||
1006 | |||
1007 | public void ForwardPermissionRequests(RegionConnections BigRegion, Scene VirtualRegion) |
||
1008 | { |
||
1009 | if (BigRegion.PermissionModule == null) |
||
1010 | BigRegion.PermissionModule = new RegionCombinerPermissionModule(BigRegion.RegionScene); |
||
1011 | |||
1012 | VirtualRegion.Permissions.OnBypassPermissions += BigRegion.PermissionModule.BypassPermissions; |
||
1013 | VirtualRegion.Permissions.OnSetBypassPermissions += BigRegion.PermissionModule.SetBypassPermissions; |
||
1014 | VirtualRegion.Permissions.OnPropagatePermissions += BigRegion.PermissionModule.PropagatePermissions; |
||
1015 | VirtualRegion.Permissions.OnGenerateClientFlags += BigRegion.PermissionModule.GenerateClientFlags; |
||
1016 | VirtualRegion.Permissions.OnAbandonParcel += BigRegion.PermissionModule.CanAbandonParcel; |
||
1017 | VirtualRegion.Permissions.OnReclaimParcel += BigRegion.PermissionModule.CanReclaimParcel; |
||
1018 | VirtualRegion.Permissions.OnDeedParcel += BigRegion.PermissionModule.CanDeedParcel; |
||
1019 | VirtualRegion.Permissions.OnDeedObject += BigRegion.PermissionModule.CanDeedObject; |
||
1020 | VirtualRegion.Permissions.OnIsGod += BigRegion.PermissionModule.IsGod; |
||
1021 | VirtualRegion.Permissions.OnDuplicateObject += BigRegion.PermissionModule.CanDuplicateObject; |
||
1022 | VirtualRegion.Permissions.OnDeleteObject += BigRegion.PermissionModule.CanDeleteObject; //MAYBE FULLY IMPLEMENTED |
||
1023 | VirtualRegion.Permissions.OnEditObject += BigRegion.PermissionModule.CanEditObject; //MAYBE FULLY IMPLEMENTED |
||
1024 | VirtualRegion.Permissions.OnEditParcelProperties += BigRegion.PermissionModule.CanEditParcelProperties; //MAYBE FULLY IMPLEMENTED |
||
1025 | VirtualRegion.Permissions.OnInstantMessage += BigRegion.PermissionModule.CanInstantMessage; |
||
1026 | VirtualRegion.Permissions.OnInventoryTransfer += BigRegion.PermissionModule.CanInventoryTransfer; //NOT YET IMPLEMENTED |
||
1027 | VirtualRegion.Permissions.OnIssueEstateCommand += BigRegion.PermissionModule.CanIssueEstateCommand; //FULLY IMPLEMENTED |
||
1028 | VirtualRegion.Permissions.OnMoveObject += BigRegion.PermissionModule.CanMoveObject; //MAYBE FULLY IMPLEMENTED |
||
1029 | VirtualRegion.Permissions.OnObjectEntry += BigRegion.PermissionModule.CanObjectEntry; |
||
1030 | VirtualRegion.Permissions.OnReturnObjects += BigRegion.PermissionModule.CanReturnObjects; //NOT YET IMPLEMENTED |
||
1031 | VirtualRegion.Permissions.OnRezObject += BigRegion.PermissionModule.CanRezObject; //MAYBE FULLY IMPLEMENTED |
||
1032 | VirtualRegion.Permissions.OnRunConsoleCommand += BigRegion.PermissionModule.CanRunConsoleCommand; |
||
1033 | VirtualRegion.Permissions.OnRunScript += BigRegion.PermissionModule.CanRunScript; //NOT YET IMPLEMENTED |
||
1034 | VirtualRegion.Permissions.OnCompileScript += BigRegion.PermissionModule.CanCompileScript; |
||
1035 | VirtualRegion.Permissions.OnSellParcel += BigRegion.PermissionModule.CanSellParcel; |
||
1036 | VirtualRegion.Permissions.OnTakeObject += BigRegion.PermissionModule.CanTakeObject; |
||
1037 | VirtualRegion.Permissions.OnTakeCopyObject += BigRegion.PermissionModule.CanTakeCopyObject; |
||
1038 | VirtualRegion.Permissions.OnTerraformLand += BigRegion.PermissionModule.CanTerraformLand; |
||
1039 | VirtualRegion.Permissions.OnLinkObject += BigRegion.PermissionModule.CanLinkObject; //NOT YET IMPLEMENTED |
||
1040 | VirtualRegion.Permissions.OnDelinkObject += BigRegion.PermissionModule.CanDelinkObject; //NOT YET IMPLEMENTED |
||
1041 | VirtualRegion.Permissions.OnBuyLand += BigRegion.PermissionModule.CanBuyLand; //NOT YET IMPLEMENTED |
||
1042 | VirtualRegion.Permissions.OnViewNotecard += BigRegion.PermissionModule.CanViewNotecard; //NOT YET IMPLEMENTED |
||
1043 | VirtualRegion.Permissions.OnViewScript += BigRegion.PermissionModule.CanViewScript; //NOT YET IMPLEMENTED |
||
1044 | VirtualRegion.Permissions.OnEditNotecard += BigRegion.PermissionModule.CanEditNotecard; //NOT YET IMPLEMENTED |
||
1045 | VirtualRegion.Permissions.OnEditScript += BigRegion.PermissionModule.CanEditScript; //NOT YET IMPLEMENTED |
||
1046 | VirtualRegion.Permissions.OnCreateObjectInventory += BigRegion.PermissionModule.CanCreateObjectInventory; //NOT IMPLEMENTED HERE |
||
1047 | VirtualRegion.Permissions.OnEditObjectInventory += BigRegion.PermissionModule.CanEditObjectInventory;//MAYBE FULLY IMPLEMENTED |
||
1048 | VirtualRegion.Permissions.OnCopyObjectInventory += BigRegion.PermissionModule.CanCopyObjectInventory; //NOT YET IMPLEMENTED |
||
1049 | VirtualRegion.Permissions.OnDeleteObjectInventory += BigRegion.PermissionModule.CanDeleteObjectInventory; //NOT YET IMPLEMENTED |
||
1050 | VirtualRegion.Permissions.OnResetScript += BigRegion.PermissionModule.CanResetScript; |
||
1051 | VirtualRegion.Permissions.OnCreateUserInventory += BigRegion.PermissionModule.CanCreateUserInventory; //NOT YET IMPLEMENTED |
||
1052 | VirtualRegion.Permissions.OnCopyUserInventory += BigRegion.PermissionModule.CanCopyUserInventory; //NOT YET IMPLEMENTED |
||
1053 | VirtualRegion.Permissions.OnEditUserInventory += BigRegion.PermissionModule.CanEditUserInventory; //NOT YET IMPLEMENTED |
||
1054 | VirtualRegion.Permissions.OnDeleteUserInventory += BigRegion.PermissionModule.CanDeleteUserInventory; //NOT YET IMPLEMENTED |
||
1055 | VirtualRegion.Permissions.OnTeleport += BigRegion.PermissionModule.CanTeleport; //NOT YET IMPLEMENTED |
||
1056 | } |
||
1057 | |||
1058 | #region console commands |
||
1059 | |||
1060 | public void FixPhantoms(string module, string[] cmdparams) |
||
1061 | { |
||
1062 | List<Scene> scenes = new List<Scene>(m_startingScenes.Values); |
||
1063 | |||
1064 | foreach (Scene s in scenes) |
||
1065 | { |
||
1066 | MainConsole.Instance.OutputFormat("Fixing phantoms for {0}", s.RegionInfo.RegionName); |
||
1067 | |||
1068 | s.ForEachSOG(so => so.AbsolutePosition = so.AbsolutePosition); |
||
1069 | } |
||
1070 | } |
||
1071 | |||
1072 | #endregion |
||
1073 | } |
||
1074 | } |