Thank you Flyte Xevious for Mantis #3361 - Implementation of llEdgeOfWorld
parent
c3e604c46c
commit
d468b7f2d3
|
@ -58,6 +58,7 @@ Patches
|
|||
* Godfrey
|
||||
* Grumly57
|
||||
* Fly-Man
|
||||
* Flyte Xevious
|
||||
* jhurliman
|
||||
* jimbo2120 (IBM)
|
||||
* John R Sohn (XenReborn)
|
||||
|
|
|
@ -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<SimpleRegionInfo> 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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
Loading…
Reference in New Issue