diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs (renamed from OpenSim/Region/CoreModules/World/Land/RegionCombinerModule.cs) | 480 |
1 files changed, 255 insertions, 225 deletions
diff --git a/OpenSim/Region/CoreModules/World/Land/RegionCombinerModule.cs b/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs index d8c5ed9..7ec1d4b 100644 --- a/OpenSim/Region/CoreModules/World/Land/RegionCombinerModule.cs +++ b/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs | |||
@@ -36,9 +36,15 @@ using OpenSim.Framework.Client; | |||
36 | using OpenSim.Region.Framework.Interfaces; | 36 | using OpenSim.Region.Framework.Interfaces; |
37 | using OpenSim.Region.Framework.Scenes; | 37 | using OpenSim.Region.Framework.Scenes; |
38 | using OpenSim.Framework.Console; | 38 | using OpenSim.Framework.Console; |
39 | using OpenSim.Region.Physics.Manager; | ||
40 | using Mono.Addins; | ||
39 | 41 | ||
40 | namespace OpenSim.Region.CoreModules.World.Land | 42 | [assembly: Addin("RegionCombinerModule", "0.1")] |
43 | [assembly: AddinDependency("OpenSim", "0.5")] | ||
44 | namespace OpenSim.Region.RegionCombinerModule | ||
41 | { | 45 | { |
46 | |||
47 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] | ||
42 | public class RegionCombinerModule : ISharedRegionModule | 48 | public class RegionCombinerModule : ISharedRegionModule |
43 | { | 49 | { |
44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 50 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
@@ -299,76 +305,13 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
299 | //xxy | 305 | //xxy |
300 | //xxx | 306 | //xxx |
301 | 307 | ||
308 | |||
302 | if ((((int)conn.X * (int)Constants.RegionSize) + conn.XEnd | 309 | if ((((int)conn.X * (int)Constants.RegionSize) + conn.XEnd |
303 | >= (regionConnections.X * (int)Constants.RegionSize)) | 310 | >= (regionConnections.X * (int)Constants.RegionSize)) |
304 | && (((int)conn.Y * (int)Constants.RegionSize) | 311 | && (((int)conn.Y * (int)Constants.RegionSize) |
305 | >= (regionConnections.Y * (int)Constants.RegionSize))) | 312 | >= (regionConnections.Y * (int)Constants.RegionSize))) |
306 | { | 313 | { |
307 | Vector3 offset = Vector3.Zero; | 314 | connectedYN = DoWorkForOneRegionOverPlusXY(conn, regionConnections, scene); |
308 | offset.X = (((regionConnections.X * (int)Constants.RegionSize)) - | ||
309 | ((conn.X * (int)Constants.RegionSize))); | ||
310 | offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) - | ||
311 | ((conn.Y * (int)Constants.RegionSize))); | ||
312 | |||
313 | Vector3 extents = Vector3.Zero; | ||
314 | extents.Y = conn.YEnd; | ||
315 | extents.X = conn.XEnd + regionConnections.XEnd; | ||
316 | |||
317 | conn.UpdateExtents(extents); | ||
318 | |||
319 | m_log.DebugFormat("Scene: {0} to the west of Scene{1} Offset: {2}. Extents:{3}", | ||
320 | conn.RegionScene.RegionInfo.RegionName, | ||
321 | regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); | ||
322 | |||
323 | scene.BordersLocked = true; | ||
324 | conn.RegionScene.BordersLocked = true; | ||
325 | |||
326 | RegionData ConnectedRegion = new RegionData(); | ||
327 | ConnectedRegion.Offset = offset; | ||
328 | ConnectedRegion.RegionId = scene.RegionInfo.originRegionID; | ||
329 | ConnectedRegion.RegionScene = scene; | ||
330 | conn.ConnectedRegions.Add(ConnectedRegion); | ||
331 | |||
332 | // Inform root region Physics about the extents of this region | ||
333 | conn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents); | ||
334 | |||
335 | // Inform Child region that it needs to forward it's terrain to the root region | ||
336 | scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, Vector3.Zero); | ||
337 | |||
338 | // Extend the borders as appropriate | ||
339 | lock (conn.RegionScene.EastBorders) | ||
340 | conn.RegionScene.EastBorders[0].BorderLine.Z += (int)Constants.RegionSize; | ||
341 | |||
342 | lock (conn.RegionScene.NorthBorders) | ||
343 | conn.RegionScene.NorthBorders[0].BorderLine.Y += (int)Constants.RegionSize; | ||
344 | |||
345 | lock (conn.RegionScene.SouthBorders) | ||
346 | conn.RegionScene.SouthBorders[0].BorderLine.Y += (int)Constants.RegionSize; | ||
347 | |||
348 | lock (scene.WestBorders) | ||
349 | { | ||
350 | |||
351 | |||
352 | scene.WestBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocX - conn.RegionScene.RegionInfo.RegionLocX) * (int)Constants.RegionSize); //auto teleport West | ||
353 | |||
354 | // Trigger auto teleport to root region | ||
355 | scene.WestBorders[0].TriggerRegionX = conn.RegionScene.RegionInfo.RegionLocX; | ||
356 | scene.WestBorders[0].TriggerRegionY = conn.RegionScene.RegionInfo.RegionLocY; | ||
357 | } | ||
358 | |||
359 | // Reset Terrain.. since terrain loads before we get here, we need to load | ||
360 | // it again so it loads in the root region | ||
361 | |||
362 | scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised()); | ||
363 | |||
364 | // Unlock borders | ||
365 | conn.RegionScene.BordersLocked = false; | ||
366 | scene.BordersLocked = false; | ||
367 | |||
368 | // Create a client event forwarder and add this region's events to the root region. | ||
369 | if (conn.ClientEventForwarder != null) | ||
370 | conn.ClientEventForwarder.AddSceneToEventForwarding(scene); | ||
371 | connectedYN = true; | ||
372 | break; | 315 | break; |
373 | } | 316 | } |
374 | 317 | ||
@@ -381,57 +324,8 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
381 | && (((int)conn.Y * (int)Constants.RegionSize) + conn.YEnd | 324 | && (((int)conn.Y * (int)Constants.RegionSize) + conn.YEnd |
382 | >= (regionConnections.Y * (int)Constants.RegionSize))) | 325 | >= (regionConnections.Y * (int)Constants.RegionSize))) |
383 | { | 326 | { |
384 | Vector3 offset = Vector3.Zero; | 327 | connectedYN = DoWorkForOneRegionOverXPlusY(conn, regionConnections, scene); |
385 | offset.X = (((regionConnections.X * (int)Constants.RegionSize)) - | 328 | break; |
386 | ((conn.X * (int)Constants.RegionSize))); | ||
387 | offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) - | ||
388 | ((conn.Y * (int)Constants.RegionSize))); | ||
389 | |||
390 | Vector3 extents = Vector3.Zero; | ||
391 | extents.Y = regionConnections.YEnd + conn.YEnd; | ||
392 | extents.X = conn.XEnd; | ||
393 | conn.UpdateExtents(extents); | ||
394 | |||
395 | scene.BordersLocked = true; | ||
396 | conn.RegionScene.BordersLocked = true; | ||
397 | |||
398 | RegionData ConnectedRegion = new RegionData(); | ||
399 | ConnectedRegion.Offset = offset; | ||
400 | ConnectedRegion.RegionId = scene.RegionInfo.originRegionID; | ||
401 | ConnectedRegion.RegionScene = scene; | ||
402 | conn.ConnectedRegions.Add(ConnectedRegion); | ||
403 | |||
404 | m_log.DebugFormat("Scene: {0} to the northeast of Scene{1} Offset: {2}. Extents:{3}", | ||
405 | conn.RegionScene.RegionInfo.RegionName, | ||
406 | regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); | ||
407 | |||
408 | conn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents); | ||
409 | scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, Vector3.Zero); | ||
410 | |||
411 | lock (conn.RegionScene.NorthBorders) | ||
412 | conn.RegionScene.NorthBorders[0].BorderLine.Z += (int)Constants.RegionSize; | ||
413 | lock (conn.RegionScene.EastBorders) | ||
414 | conn.RegionScene.EastBorders[0].BorderLine.Y += (int)Constants.RegionSize; | ||
415 | lock (conn.RegionScene.WestBorders) | ||
416 | conn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize; | ||
417 | lock (scene.SouthBorders) | ||
418 | { | ||
419 | scene.SouthBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocY - conn.RegionScene.RegionInfo.RegionLocY) * (int)Constants.RegionSize); //auto teleport south | ||
420 | scene.SouthBorders[0].TriggerRegionX = conn.RegionScene.RegionInfo.RegionLocX; | ||
421 | scene.SouthBorders[0].TriggerRegionY = conn.RegionScene.RegionInfo.RegionLocY; | ||
422 | } | ||
423 | |||
424 | // Reset Terrain.. since terrain normally loads first. | ||
425 | //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); | ||
426 | scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised()); | ||
427 | //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); | ||
428 | |||
429 | scene.BordersLocked = false; | ||
430 | conn.RegionScene.BordersLocked = false; | ||
431 | if (conn.ClientEventForwarder != null) | ||
432 | conn.ClientEventForwarder.AddSceneToEventForwarding(scene); | ||
433 | connectedYN = true; | ||
434 | break; | ||
435 | } | 329 | } |
436 | 330 | ||
437 | // If we're one region over +x +y | 331 | // If we're one region over +x +y |
@@ -443,140 +337,276 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
443 | && (((int)conn.Y * (int)Constants.RegionSize) + conn.YEnd | 337 | && (((int)conn.Y * (int)Constants.RegionSize) + conn.YEnd |
444 | >= (regionConnections.Y * (int)Constants.RegionSize))) | 338 | >= (regionConnections.Y * (int)Constants.RegionSize))) |
445 | { | 339 | { |
446 | Vector3 offset = Vector3.Zero; | 340 | connectedYN = DoWorkForOneRegionOverPlusXPlusY(conn, regionConnections, scene); |
447 | offset.X = (((regionConnections.X * (int)Constants.RegionSize)) - | 341 | break; |
448 | ((conn.X * (int)Constants.RegionSize))); | ||
449 | offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) - | ||
450 | ((conn.Y * (int)Constants.RegionSize))); | ||
451 | 342 | ||
452 | Vector3 extents = Vector3.Zero; | 343 | } |
453 | extents.Y = regionConnections.YEnd + conn.YEnd; | 344 | } |
454 | extents.X = regionConnections.XEnd + conn.XEnd; | ||
455 | conn.UpdateExtents(extents); | ||
456 | 345 | ||
457 | scene.BordersLocked = true; | 346 | // If !connectYN means that this region is a root region |
458 | conn.RegionScene.BordersLocked = true; | 347 | if (!connectedYN) |
348 | { | ||
349 | DoWorkForRootRegion(regionConnections, scene); | ||
459 | 350 | ||
460 | RegionData ConnectedRegion = new RegionData(); | 351 | } |
461 | ConnectedRegion.Offset = offset; | 352 | } |
462 | ConnectedRegion.RegionId = scene.RegionInfo.originRegionID; | 353 | // Set up infinite borders around the entire AABB of the combined ConnectedRegions |
463 | ConnectedRegion.RegionScene = scene; | 354 | AdjustLargeRegionBounds(); |
355 | } | ||
464 | 356 | ||
465 | conn.ConnectedRegions.Add(ConnectedRegion); | 357 | private bool DoWorkForOneRegionOverPlusXY(RegionConnections conn, RegionConnections regionConnections, Scene scene) |
358 | { | ||
359 | Vector3 offset = Vector3.Zero; | ||
360 | offset.X = (((regionConnections.X * (int)Constants.RegionSize)) - | ||
361 | ((conn.X * (int)Constants.RegionSize))); | ||
362 | offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) - | ||
363 | ((conn.Y * (int)Constants.RegionSize))); | ||
466 | 364 | ||
467 | m_log.DebugFormat("Scene: {0} to the NorthEast of Scene{1} Offset: {2}. Extents:{3}", | 365 | Vector3 extents = Vector3.Zero; |
468 | conn.RegionScene.RegionInfo.RegionName, | 366 | extents.Y = conn.YEnd; |
469 | regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); | 367 | extents.X = conn.XEnd + regionConnections.XEnd; |
470 | 368 | ||
471 | conn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents); | 369 | conn.UpdateExtents(extents); |
472 | scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, Vector3.Zero); | ||
473 | lock (conn.RegionScene.NorthBorders) | ||
474 | { | ||
475 | if (conn.RegionScene.NorthBorders.Count == 1)// && 2) | ||
476 | { | ||
477 | //compound border | ||
478 | // already locked above | ||
479 | conn.RegionScene.NorthBorders[0].BorderLine.Z += (int)Constants.RegionSize; | ||
480 | |||
481 | lock (conn.RegionScene.EastBorders) | ||
482 | conn.RegionScene.EastBorders[0].BorderLine.Y += (int)Constants.RegionSize; | ||
483 | lock (conn.RegionScene.WestBorders) | ||
484 | conn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize; | ||
485 | } | ||
486 | } | ||
487 | 370 | ||
488 | lock (scene.SouthBorders) | 371 | m_log.DebugFormat("Scene: {0} to the west of Scene{1} Offset: {2}. Extents:{3}", |
489 | { | 372 | conn.RegionScene.RegionInfo.RegionName, |
490 | scene.SouthBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocY - conn.RegionScene.RegionInfo.RegionLocY) * (int)Constants.RegionSize); //auto teleport south | 373 | regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); |
491 | scene.SouthBorders[0].TriggerRegionX = conn.RegionScene.RegionInfo.RegionLocX; | ||
492 | scene.SouthBorders[0].TriggerRegionY = conn.RegionScene.RegionInfo.RegionLocY; | ||
493 | } | ||
494 | 374 | ||
495 | lock (conn.RegionScene.EastBorders) | 375 | scene.BordersLocked = true; |
496 | { | 376 | conn.RegionScene.BordersLocked = true; |
497 | if (conn.RegionScene.EastBorders.Count == 1)// && conn.RegionScene.EastBorders.Count == 2) | ||
498 | { | ||
499 | 377 | ||
500 | conn.RegionScene.EastBorders[0].BorderLine.Z += (int)Constants.RegionSize; | 378 | RegionData ConnectedRegion = new RegionData(); |
501 | lock (conn.RegionScene.NorthBorders) | 379 | ConnectedRegion.Offset = offset; |
502 | conn.RegionScene.NorthBorders[0].BorderLine.Y += (int)Constants.RegionSize; | 380 | ConnectedRegion.RegionId = scene.RegionInfo.originRegionID; |
503 | lock (conn.RegionScene.SouthBorders) | 381 | ConnectedRegion.RegionScene = scene; |
504 | conn.RegionScene.SouthBorders[0].BorderLine.Y += (int)Constants.RegionSize; | 382 | conn.ConnectedRegions.Add(ConnectedRegion); |
505 | 383 | ||
384 | // Inform root region Physics about the extents of this region | ||
385 | conn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents); | ||
506 | 386 | ||
507 | } | 387 | // Inform Child region that it needs to forward it's terrain to the root region |
508 | } | 388 | scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, Vector3.Zero); |
509 | 389 | ||
510 | lock (scene.WestBorders) | 390 | // Extend the borders as appropriate |
511 | { | 391 | lock (conn.RegionScene.EastBorders) |
512 | scene.WestBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocX - conn.RegionScene.RegionInfo.RegionLocX) * (int)Constants.RegionSize); //auto teleport West | 392 | conn.RegionScene.EastBorders[0].BorderLine.Z += (int)Constants.RegionSize; |
513 | scene.WestBorders[0].TriggerRegionX = conn.RegionScene.RegionInfo.RegionLocX; | ||
514 | scene.WestBorders[0].TriggerRegionY = conn.RegionScene.RegionInfo.RegionLocY; | ||
515 | } | ||
516 | 393 | ||
517 | /* | 394 | lock (conn.RegionScene.NorthBorders) |
518 | else | 395 | conn.RegionScene.NorthBorders[0].BorderLine.Y += (int)Constants.RegionSize; |
519 | { | 396 | |
520 | conn.RegionScene.NorthBorders[0].BorderLine.Z += (int)Constants.RegionSize; | 397 | lock (conn.RegionScene.SouthBorders) |
521 | conn.RegionScene.EastBorders[0].BorderLine.Y += (int)Constants.RegionSize; | 398 | conn.RegionScene.SouthBorders[0].BorderLine.Y += (int)Constants.RegionSize; |
522 | conn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize; | ||
523 | scene.SouthBorders[0].BorderLine.Z += (int)Constants.RegionSize; //auto teleport south | ||
524 | } | ||
525 | */ | ||
526 | 399 | ||
400 | lock (scene.WestBorders) | ||
401 | { | ||
527 | 402 | ||
528 | // Reset Terrain.. since terrain normally loads first. | ||
529 | //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); | ||
530 | scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised()); | ||
531 | //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); | ||
532 | scene.BordersLocked = false; | ||
533 | conn.RegionScene.BordersLocked = false; | ||
534 | 403 | ||
535 | if (conn.ClientEventForwarder != null) | 404 | scene.WestBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocX - conn.RegionScene.RegionInfo.RegionLocX) * (int)Constants.RegionSize); //auto teleport West |
536 | conn.ClientEventForwarder.AddSceneToEventForwarding(scene); | ||
537 | 405 | ||
538 | connectedYN = true; | 406 | // Trigger auto teleport to root region |
407 | scene.WestBorders[0].TriggerRegionX = conn.RegionScene.RegionInfo.RegionLocX; | ||
408 | scene.WestBorders[0].TriggerRegionY = conn.RegionScene.RegionInfo.RegionLocY; | ||
409 | } | ||
539 | 410 | ||
540 | //scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset,extents); | 411 | // Reset Terrain.. since terrain loads before we get here, we need to load |
412 | // it again so it loads in the root region | ||
541 | 413 | ||
542 | break; | 414 | scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised()); |
543 | } | 415 | |
416 | // Unlock borders | ||
417 | conn.RegionScene.BordersLocked = false; | ||
418 | scene.BordersLocked = false; | ||
419 | |||
420 | // Create a client event forwarder and add this region's events to the root region. | ||
421 | if (conn.ClientEventForwarder != null) | ||
422 | conn.ClientEventForwarder.AddSceneToEventForwarding(scene); | ||
423 | |||
424 | return true; | ||
425 | } | ||
426 | |||
427 | private bool DoWorkForOneRegionOverXPlusY(RegionConnections conn, RegionConnections regionConnections, Scene scene) | ||
428 | { | ||
429 | Vector3 offset = Vector3.Zero; | ||
430 | offset.X = (((regionConnections.X * (int)Constants.RegionSize)) - | ||
431 | ((conn.X * (int)Constants.RegionSize))); | ||
432 | offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) - | ||
433 | ((conn.Y * (int)Constants.RegionSize))); | ||
434 | |||
435 | Vector3 extents = Vector3.Zero; | ||
436 | extents.Y = regionConnections.YEnd + conn.YEnd; | ||
437 | extents.X = conn.XEnd; | ||
438 | conn.UpdateExtents(extents); | ||
439 | |||
440 | scene.BordersLocked = true; | ||
441 | conn.RegionScene.BordersLocked = true; | ||
442 | |||
443 | RegionData ConnectedRegion = new RegionData(); | ||
444 | ConnectedRegion.Offset = offset; | ||
445 | ConnectedRegion.RegionId = scene.RegionInfo.originRegionID; | ||
446 | ConnectedRegion.RegionScene = scene; | ||
447 | conn.ConnectedRegions.Add(ConnectedRegion); | ||
448 | |||
449 | m_log.DebugFormat("Scene: {0} to the northeast of Scene{1} Offset: {2}. Extents:{3}", | ||
450 | conn.RegionScene.RegionInfo.RegionName, | ||
451 | regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); | ||
452 | |||
453 | conn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents); | ||
454 | scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, Vector3.Zero); | ||
455 | |||
456 | lock (conn.RegionScene.NorthBorders) | ||
457 | conn.RegionScene.NorthBorders[0].BorderLine.Z += (int)Constants.RegionSize; | ||
458 | lock (conn.RegionScene.EastBorders) | ||
459 | conn.RegionScene.EastBorders[0].BorderLine.Y += (int)Constants.RegionSize; | ||
460 | lock (conn.RegionScene.WestBorders) | ||
461 | conn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize; | ||
462 | lock (scene.SouthBorders) | ||
463 | { | ||
464 | scene.SouthBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocY - conn.RegionScene.RegionInfo.RegionLocY) * (int)Constants.RegionSize); //auto teleport south | ||
465 | scene.SouthBorders[0].TriggerRegionX = conn.RegionScene.RegionInfo.RegionLocX; | ||
466 | scene.SouthBorders[0].TriggerRegionY = conn.RegionScene.RegionInfo.RegionLocY; | ||
467 | } | ||
468 | |||
469 | // Reset Terrain.. since terrain normally loads first. | ||
470 | //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); | ||
471 | scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised()); | ||
472 | //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); | ||
473 | |||
474 | scene.BordersLocked = false; | ||
475 | conn.RegionScene.BordersLocked = false; | ||
476 | if (conn.ClientEventForwarder != null) | ||
477 | conn.ClientEventForwarder.AddSceneToEventForwarding(scene); | ||
478 | return true; | ||
479 | } | ||
480 | |||
481 | private bool DoWorkForOneRegionOverPlusXPlusY(RegionConnections conn, RegionConnections regionConnections, Scene scene) | ||
482 | { | ||
483 | Vector3 offset = Vector3.Zero; | ||
484 | offset.X = (((regionConnections.X * (int)Constants.RegionSize)) - | ||
485 | ((conn.X * (int)Constants.RegionSize))); | ||
486 | offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) - | ||
487 | ((conn.Y * (int)Constants.RegionSize))); | ||
488 | |||
489 | Vector3 extents = Vector3.Zero; | ||
490 | extents.Y = regionConnections.YEnd + conn.YEnd; | ||
491 | extents.X = regionConnections.XEnd + conn.XEnd; | ||
492 | conn.UpdateExtents(extents); | ||
493 | |||
494 | scene.BordersLocked = true; | ||
495 | conn.RegionScene.BordersLocked = true; | ||
496 | |||
497 | RegionData ConnectedRegion = new RegionData(); | ||
498 | ConnectedRegion.Offset = offset; | ||
499 | ConnectedRegion.RegionId = scene.RegionInfo.originRegionID; | ||
500 | ConnectedRegion.RegionScene = scene; | ||
501 | |||
502 | conn.ConnectedRegions.Add(ConnectedRegion); | ||
503 | |||
504 | m_log.DebugFormat("Scene: {0} to the NorthEast of Scene{1} Offset: {2}. Extents:{3}", | ||
505 | conn.RegionScene.RegionInfo.RegionName, | ||
506 | regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); | ||
507 | |||
508 | conn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents); | ||
509 | scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, Vector3.Zero); | ||
510 | lock (conn.RegionScene.NorthBorders) | ||
511 | { | ||
512 | if (conn.RegionScene.NorthBorders.Count == 1)// && 2) | ||
513 | { | ||
514 | //compound border | ||
515 | // already locked above | ||
516 | conn.RegionScene.NorthBorders[0].BorderLine.Z += (int)Constants.RegionSize; | ||
517 | |||
518 | lock (conn.RegionScene.EastBorders) | ||
519 | conn.RegionScene.EastBorders[0].BorderLine.Y += (int)Constants.RegionSize; | ||
520 | lock (conn.RegionScene.WestBorders) | ||
521 | conn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize; | ||
544 | } | 522 | } |
523 | } | ||
545 | 524 | ||
546 | // If !connectYN means that this region is a root region | 525 | lock (scene.SouthBorders) |
547 | if (!connectedYN) | 526 | { |
527 | scene.SouthBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocY - conn.RegionScene.RegionInfo.RegionLocY) * (int)Constants.RegionSize); //auto teleport south | ||
528 | scene.SouthBorders[0].TriggerRegionX = conn.RegionScene.RegionInfo.RegionLocX; | ||
529 | scene.SouthBorders[0].TriggerRegionY = conn.RegionScene.RegionInfo.RegionLocY; | ||
530 | } | ||
531 | |||
532 | lock (conn.RegionScene.EastBorders) | ||
533 | { | ||
534 | if (conn.RegionScene.EastBorders.Count == 1)// && conn.RegionScene.EastBorders.Count == 2) | ||
548 | { | 535 | { |
549 | RegionData rdata = new RegionData(); | ||
550 | rdata.Offset = Vector3.Zero; | ||
551 | rdata.RegionId = scene.RegionInfo.originRegionID; | ||
552 | rdata.RegionScene = scene; | ||
553 | // save it's land channel | ||
554 | regionConnections.RegionLandChannel = scene.LandChannel; | ||
555 | |||
556 | // Substitue our landchannel | ||
557 | RegionCombinerLargeLandChannel lnd = new RegionCombinerLargeLandChannel(rdata, scene.LandChannel, | ||
558 | regionConnections.ConnectedRegions); | ||
559 | scene.LandChannel = lnd; | ||
560 | // Forward the permissions modules of each of the connected regions to the root region | ||
561 | lock (m_regions) | ||
562 | { | ||
563 | foreach (RegionData r in regionConnections.ConnectedRegions) | ||
564 | { | ||
565 | ForwardPermissionRequests(regionConnections, r.RegionScene); | ||
566 | } | ||
567 | } | ||
568 | // Create the root region's Client Event Forwarder | ||
569 | regionConnections.ClientEventForwarder = new RegionCombinerClientEventForwarder(regionConnections); | ||
570 | 536 | ||
571 | // Sets up the CoarseLocationUpdate forwarder for this root region | 537 | conn.RegionScene.EastBorders[0].BorderLine.Z += (int)Constants.RegionSize; |
572 | scene.EventManager.OnNewPresence += SetCourseLocationDelegate; | 538 | lock (conn.RegionScene.NorthBorders) |
539 | conn.RegionScene.NorthBorders[0].BorderLine.Y += (int)Constants.RegionSize; | ||
540 | lock (conn.RegionScene.SouthBorders) | ||
541 | conn.RegionScene.SouthBorders[0].BorderLine.Y += (int)Constants.RegionSize; | ||
542 | |||
573 | 543 | ||
574 | // Adds this root region to a dictionary of regions that are connectable | ||
575 | m_regions.Add(scene.RegionInfo.originRegionID, regionConnections); | ||
576 | } | 544 | } |
577 | } | 545 | } |
578 | // Set up infinite borders around the entire AABB of the combined ConnectedRegions | 546 | |
579 | AdjustLargeRegionBounds(); | 547 | lock (scene.WestBorders) |
548 | { | ||
549 | scene.WestBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocX - conn.RegionScene.RegionInfo.RegionLocX) * (int)Constants.RegionSize); //auto teleport West | ||
550 | scene.WestBorders[0].TriggerRegionX = conn.RegionScene.RegionInfo.RegionLocX; | ||
551 | scene.WestBorders[0].TriggerRegionY = conn.RegionScene.RegionInfo.RegionLocY; | ||
552 | } | ||
553 | |||
554 | /* | ||
555 | else | ||
556 | { | ||
557 | conn.RegionScene.NorthBorders[0].BorderLine.Z += (int)Constants.RegionSize; | ||
558 | conn.RegionScene.EastBorders[0].BorderLine.Y += (int)Constants.RegionSize; | ||
559 | conn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize; | ||
560 | scene.SouthBorders[0].BorderLine.Z += (int)Constants.RegionSize; //auto teleport south | ||
561 | } | ||
562 | */ | ||
563 | |||
564 | |||
565 | // Reset Terrain.. since terrain normally loads first. | ||
566 | //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); | ||
567 | scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised()); | ||
568 | //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); | ||
569 | scene.BordersLocked = false; | ||
570 | conn.RegionScene.BordersLocked = false; | ||
571 | |||
572 | if (conn.ClientEventForwarder != null) | ||
573 | conn.ClientEventForwarder.AddSceneToEventForwarding(scene); | ||
574 | |||
575 | return true; | ||
576 | |||
577 | //scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset,extents); | ||
578 | |||
579 | } | ||
580 | |||
581 | private void DoWorkForRootRegion(RegionConnections regionConnections, Scene scene) | ||
582 | { | ||
583 | RegionData rdata = new RegionData(); | ||
584 | rdata.Offset = Vector3.Zero; | ||
585 | rdata.RegionId = scene.RegionInfo.originRegionID; | ||
586 | rdata.RegionScene = scene; | ||
587 | // save it's land channel | ||
588 | regionConnections.RegionLandChannel = scene.LandChannel; | ||
589 | |||
590 | // Substitue our landchannel | ||
591 | RegionCombinerLargeLandChannel lnd = new RegionCombinerLargeLandChannel(rdata, scene.LandChannel, | ||
592 | regionConnections.ConnectedRegions); | ||
593 | scene.LandChannel = lnd; | ||
594 | // Forward the permissions modules of each of the connected regions to the root region | ||
595 | lock (m_regions) | ||
596 | { | ||
597 | foreach (RegionData r in regionConnections.ConnectedRegions) | ||
598 | { | ||
599 | ForwardPermissionRequests(regionConnections, r.RegionScene); | ||
600 | } | ||
601 | } | ||
602 | // Create the root region's Client Event Forwarder | ||
603 | regionConnections.ClientEventForwarder = new RegionCombinerClientEventForwarder(regionConnections); | ||
604 | |||
605 | // Sets up the CoarseLocationUpdate forwarder for this root region | ||
606 | scene.EventManager.OnNewPresence += SetCourseLocationDelegate; | ||
607 | |||
608 | // Adds this root region to a dictionary of regions that are connectable | ||
609 | m_regions.Add(scene.RegionInfo.originRegionID, regionConnections); | ||
580 | } | 610 | } |
581 | 611 | ||
582 | private void SetCourseLocationDelegate(ScenePresence presence) | 612 | private void SetCourseLocationDelegate(ScenePresence presence) |