diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 89 |
1 files changed, 87 insertions, 2 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 1a73c3e..bafee28 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -14358,6 +14358,91 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
14358 | return contacts.ToArray(); | 14358 | return contacts.ToArray(); |
14359 | } | 14359 | } |
14360 | 14360 | ||
14361 | private ContactResult? GroundIntersection2(Vector3 rayStart, Vector3 rayEnd) | ||
14362 | { | ||
14363 | // get work copies | ||
14364 | float sx = rayStart.X; | ||
14365 | float ex = rayEnd.X; | ||
14366 | float sy = rayStart.Y; | ||
14367 | float ey = rayEnd.Y; | ||
14368 | |||
14369 | float dx = ex - sx; | ||
14370 | float dy = ey - sy; | ||
14371 | |||
14372 | // region size info | ||
14373 | float rsx = World.RegionInfo.RegionSizeX; | ||
14374 | |||
14375 | float tmp; | ||
14376 | |||
14377 | // region bounds | ||
14378 | if(sx < 0) | ||
14379 | { | ||
14380 | if(ex < 0) // totally outside | ||
14381 | return null; | ||
14382 | if(dx <= 0) // out and going away | ||
14383 | return null; | ||
14384 | else if(ex >= rsx) | ||
14385 | ex = rsx - 0.001f; | ||
14386 | tmp = -sx / dx; | ||
14387 | sy += dy * dx; | ||
14388 | sx = 0; | ||
14389 | } | ||
14390 | else if(sx >= rsx) | ||
14391 | { | ||
14392 | if(ex >= rsx) // totally outside | ||
14393 | return null; | ||
14394 | if(dx >= 0) // out and going away | ||
14395 | return null; | ||
14396 | else if(ex < 0) | ||
14397 | ex = 0; | ||
14398 | tmp = (rsx - sx) / dx; | ||
14399 | sy += dy * dx; | ||
14400 | sx = rsx - 0.001f; | ||
14401 | } | ||
14402 | |||
14403 | float rsy = World.RegionInfo.RegionSizeY; | ||
14404 | if(sy < 0) | ||
14405 | { | ||
14406 | if(dy <= 0) // out and going away | ||
14407 | return null; | ||
14408 | else if(ey >= rsy) | ||
14409 | ey = rsy - 0.001f; | ||
14410 | tmp = -sy / dy; | ||
14411 | sx += dy * dx; | ||
14412 | sy = 0; | ||
14413 | } | ||
14414 | else if(sy >= rsy) | ||
14415 | { | ||
14416 | if(dy >= 0) // out and going away | ||
14417 | return null; | ||
14418 | else if(ey < 0) | ||
14419 | ey = 0; | ||
14420 | tmp = (rsy - sy) / dy; | ||
14421 | sx += dy * dx; | ||
14422 | sy = rsy - 0.001f; | ||
14423 | } | ||
14424 | |||
14425 | if(sx < 0 || sx >= rsx) | ||
14426 | return null; | ||
14427 | |||
14428 | float sz = rayStart.Z; | ||
14429 | float ez = rayEnd.Z; | ||
14430 | float dz = ez - sz; | ||
14431 | |||
14432 | float dist = dx * dx + dy * dy + dz * dz; | ||
14433 | if(dist < 0.001) | ||
14434 | return null; | ||
14435 | dist = (float)Math.Sqrt(dist); | ||
14436 | tmp = 1.0f / dist; | ||
14437 | Vector3 rayn = new Vector3(dx * tmp, dy * tmp, dz * tmp); | ||
14438 | |||
14439 | ContactResult? result = null; | ||
14440 | |||
14441 | |||
14442 | |||
14443 | return result; | ||
14444 | } | ||
14445 | |||
14361 | private ContactResult? GroundIntersection(Vector3 rayStart, Vector3 rayEnd) | 14446 | private ContactResult? GroundIntersection(Vector3 rayStart, Vector3 rayEnd) |
14362 | { | 14447 | { |
14363 | double[,] heightfield = World.Heightmap.GetDoubles(); | 14448 | double[,] heightfield = World.Heightmap.GetDoubles(); |
@@ -16024,8 +16109,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
16024 | catch (InvalidCastException e) | 16109 | catch (InvalidCastException e) |
16025 | { | 16110 | { |
16026 | Error(originFunc,string.Format( | 16111 | Error(originFunc,string.Format( |
16027 | " error running rule #{1}: arg #{2} ", | 16112 | " error running rule #{0}: arg #{1} {2}", |
16028 | rulesParsed, idx - idxStart) + e.Message); | 16113 | rulesParsed, idx - idxStart, e.Message)); |
16029 | } | 16114 | } |
16030 | finally | 16115 | finally |
16031 | { | 16116 | { |