mirror of
https://github.com/opensim/opensim.git
synced 2026-08-04 16:22:50 +08:00
Thank you Flyte Xevious for Mantis #3361 - Implementation of llEdgeOfWorld
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user