aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorUbitUmarov2016-07-29 00:55:40 +0100
committerUbitUmarov2016-07-29 00:55:40 +0100
commit3d58198c55542e9554d545b2de7507c1a57bf786 (patch)
treed341722bb9b9f0cb976a3961dc01a40869bd2321 /OpenSim
parent a zero direction vector in llEdgeOfWorld() should return TRUE not FALSE, (SL... (diff)
downloadopensim-SC_OLD-3d58198c55542e9554d545b2de7507c1a57bf786.zip
opensim-SC_OLD-3d58198c55542e9554d545b2de7507c1a57bf786.tar.gz
opensim-SC_OLD-3d58198c55542e9554d545b2de7507c1a57bf786.tar.bz2
opensim-SC_OLD-3d58198c55542e9554d545b2de7507c1a57bf786.tar.xz
fix llEdgeOfWorld() for var regions (someone needs to test this better
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs86
1 files changed, 41 insertions, 45 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 4be90c7..fb35a54 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -6394,65 +6394,61 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6394 { 6394 {
6395 m_host.AddScriptLPS(1); 6395 m_host.AddScriptLPS(1);
6396 6396
6397 // edge will be used to pass the Region Coordinates offset 6397 if(dir.x == 0.0 && dir.y == 0.0)
6398 // we want to check for a neighboring sim 6398 return 1; // SL wiki
6399 LSL_Vector edge = new LSL_Vector(0, 0, 0); 6399
6400 float rsx = World.RegionInfo.RegionSizeX;
6401 float rsy = World.RegionInfo.RegionSizeY;
6402
6403 // can understand what sl does if position is not in region, so do something :)
6404 float px = (float)Util.Clamp(pos.x, 0.5, rsx - 0.5);
6405 float py = (float)Util.Clamp(pos.y, 0.5, rsy - 0.5);
6406
6407 float ex, ey;
6400 6408
6401 if (dir.x == 0) 6409 if (dir.x == 0)
6402 { 6410 {
6403 if (dir.y == 0) 6411 ex = px;
6404 { 6412 ey = dir.y > 0.0 ? rsy + 1.0f : -1.0f;
6405 // Direction vector is 0,0 so return 6413 }
6406 // false since we're staying in the sim 6414 else if(dir.y == 0.0f)
6407 // no SL says true 6415 {
6408 return 1; 6416 ex = dir.x > 0 ? rsx + 1.0f : -1.0f;
6409 } 6417 ey = py;
6410 else
6411 {
6412 // Y is the only valid direction
6413 edge.y = dir.y / Math.Abs(dir.y) * (World.RegionInfo.RegionSizeY / Constants.RegionSize);
6414 }
6415 } 6418 }
6416 else 6419 else
6417 { 6420 {
6418 LSL_Float mag; 6421 float dx = (float) dir.x;
6419 if (dir.x > 0) 6422 float dy = (float) dir.y;
6420 {
6421 mag = (World.RegionInfo.RegionSizeX - pos.x) / dir.x;
6422 }
6423 else
6424 {
6425 mag = (pos.x/dir.x);
6426 }
6427
6428 mag = Math.Abs(mag);
6429 6423
6430 edge.y = pos.y + (dir.y * mag); 6424 float t1 = dx * dx + dy * dy;
6425 dx /= t1;
6426 dy /= t1;
6431 6427
6432 if (edge.y > World.RegionInfo.RegionSizeY || edge.y < 0) 6428 if(dx > 0)
6433 { 6429 t1 = (rsx + 1f - px)/dx;
6434 // Y goes out of bounds first
6435 edge.y = dir.y / Math.Abs(dir.y) * (World.RegionInfo.RegionSizeY / Constants.RegionSize);
6436 }
6437 else 6430 else
6438 { 6431 t1 = -(px + 1f)/dx;
6439 // X goes out of bounds first or its a corner exit
6440 edge.y = 0;
6441 edge.x = dir.x / Math.Abs(dir.x) * (World.RegionInfo.RegionSizeY / Constants.RegionSize);
6442 }
6443 }
6444 6432
6445 List<GridRegion> neighbors = World.GridService.GetNeighbours(World.RegionInfo.ScopeID, World.RegionInfo.RegionID);
6446 6433
6447 uint neighborX = World.RegionInfo.RegionLocX + (uint)edge.x; 6434 float t2;
6448 uint neighborY = World.RegionInfo.RegionLocY + (uint)edge.y; 6435 if(dy > 0)
6436 t2 = (rsy + 1f - py)/dy;
6437 else
6438 t2 = -(py + 1f)/dy;
6449 6439
6450 foreach (GridRegion sri in neighbors) 6440 if(t1 > t2)
6451 { 6441 t1 = t2;
6452 if (sri.RegionCoordX == neighborX && sri.RegionCoordY == neighborY) 6442
6453 return 0; 6443 ex = px + t1 * dx;
6444 ey = py + t1 * dy;
6454 } 6445 }
6455 6446
6447 ex += World.RegionInfo.WorldLocX;
6448 ey += World.RegionInfo.WorldLocY;
6449
6450 if(World.GridService.GetRegionByPosition(World.RegionInfo.ScopeID, (int)ex, (int)ey) != null)
6451 return 0;
6456 return 1; 6452 return 1;
6457 } 6453 }
6458 6454