From d468b7f2d33ac2562048f60de599e2e07cac270d Mon Sep 17 00:00:00 2001 From: Dahlia Trimble Date: Sun, 29 Mar 2009 23:59:14 +0000 Subject: Thank you Flyte Xevious for Mantis #3361 - Implementation of llEdgeOfWorld --- CONTRIBUTORS.txt | 1 + .../Shared/Api/Implementation/LSL_Api.cs | 62 +++++++++++++++++++++- 2 files changed, 61 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index 82babb7..722360b 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -58,6 +58,7 @@ Patches * Godfrey * Grumly57 * Fly-Man +* Flyte Xevious * jhurliman * jimbo2120 (IBM) * John R Sohn (XenReborn) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 9819ce0..3c1b87f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -4991,8 +4991,66 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer llEdgeOfWorld(LSL_Vector pos, LSL_Vector dir) { m_host.AddScriptLPS(1); - NotImplemented("llEdgeOfWorld"); - return 0; + + // edge will be used to pass the Region Coordinates offset + // we want to check for a neighboring sim + LSL_Vector edge = new LSL_Vector(0, 0, 0); + + if (dir.x == 0) + { + if (dir.y == 0) + { + // Direction vector is 0,0 so return + // false since we're staying in the sim + return 0; + } + else + { + // Y is the only valid direction + edge.y = dir.y / Math.Abs(dir.y); + } + } + else + { + LSL_Float mag; + if (dir.x > 0) + { + mag = (Constants.RegionSize - pos.x) / dir.x; + } + else + { + mag = (pos.x/dir.x); + } + + mag = Math.Abs(mag); + + edge.y = pos.y + (dir.y * mag); + + if (edge.y > Constants.RegionSize || edge.y < 0) + { + // Y goes out of bounds first + edge.y = dir.y / Math.Abs(dir.y); + } + else + { + // X goes out of bounds first or its a corner exit + edge.y = 0; + edge.x = dir.x / Math.Abs(dir.x); + } + } + + List neighbors = World.CommsManager.GridService.RequestNeighbours(World.RegionInfo.RegionLocX, World.RegionInfo.RegionLocY); + + uint neighborX = World.RegionInfo.RegionLocX + (uint)dir.x; + uint neighborY = World.RegionInfo.RegionLocY + (uint)dir.y; + + foreach (SimpleRegionInfo sri in neighbors) + { + if (sri.RegionLocX == neighborX && sri.RegionLocY == neighborY) + return 0; + } + + return 1; } /// -- cgit v1.1