aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared
diff options
context:
space:
mode:
authorteravus2013-01-23 21:58:51 -0500
committerteravus2013-01-23 21:58:51 -0500
commit878df52515ea3519130ba646a050c8d8c1f09b29 (patch)
tree2fbccc21e6e45e8ad552b4bece3f331322a6e838 /OpenSim/Region/ScriptEngine/Shared
parentRemove unnecessary System.Linq reference from Compiler.cs (diff)
downloadopensim-SC-878df52515ea3519130ba646a050c8d8c1f09b29.zip
opensim-SC-878df52515ea3519130ba646a050c8d8c1f09b29.tar.gz
opensim-SC-878df52515ea3519130ba646a050c8d8c1f09b29.tar.bz2
opensim-SC-878df52515ea3519130ba646a050c8d8c1f09b29.tar.xz
* This makes the non-physics llCastRay 'better'. It's not 'correctly working', and if you look deep enough, you see that the results are not really stable depending on the direction of the ray.
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs21
1 files changed, 17 insertions, 4 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 63f4800..001f4d9 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -11152,12 +11152,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11152 radius = Math.Abs(maxY); 11152 radius = Math.Abs(maxY);
11153 if (Math.Abs(maxZ) > radius) 11153 if (Math.Abs(maxZ) > radius)
11154 radius = Math.Abs(maxZ); 11154 radius = Math.Abs(maxZ);
11155 11155 radius = radius*1.413f;
11156 Vector3 ac = group.AbsolutePosition - rayStart; 11156 Vector3 ac = group.AbsolutePosition - rayStart;
11157 Vector3 bc = group.AbsolutePosition - rayEnd; 11157 Vector3 bc = group.AbsolutePosition - rayEnd;
11158 11158
11159 double d = Math.Abs(Vector3.Mag(Vector3.Cross(ab, ac)) / Vector3.Distance(rayStart, rayEnd)); 11159 double d = Math.Abs(Vector3.Mag(Vector3.Cross(ab, ac)) / Vector3.Distance(rayStart, rayEnd));
11160 11160
11161 // Too far off ray, don't bother 11161 // Too far off ray, don't bother
11162 if (d > radius) 11162 if (d > radius)
11163 return; 11163 return;
@@ -11167,11 +11167,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11167 if (d2 > 0) 11167 if (d2 > 0)
11168 return; 11168 return;
11169 11169
11170 ray = new Ray(rayStart, Vector3.Normalize(rayEnd - rayStart));
11170 EntityIntersection intersection = group.TestIntersection(ray, true, false); 11171 EntityIntersection intersection = group.TestIntersection(ray, true, false);
11171 // Miss. 11172 // Miss.
11172 if (!intersection.HitTF) 11173 if (!intersection.HitTF)
11173 return; 11174 return;
11174 11175
11176 Vector3 b1 = group.AbsolutePosition + new Vector3(minX, minY, minZ);
11177 Vector3 b2 = group.AbsolutePosition + new Vector3(maxX, maxY, maxZ);
11178 //m_log.DebugFormat("[LLCASTRAY]: min<{0},{1},{2}>, max<{3},{4},{5}> = hitp<{6},{7},{8}>", b1.X,b1.Y,b1.Z,b2.X,b2.Y,b2.Z,intersection.ipoint.X,intersection.ipoint.Y,intersection.ipoint.Z);
11179 if (!(intersection.ipoint.X >= b1.X && intersection.ipoint.X <= b2.X &&
11180 intersection.ipoint.Y >= b1.Y && intersection.ipoint.Y <= b2.Y &&
11181 intersection.ipoint.Z >= b1.Z && intersection.ipoint.Z <= b2.Z))
11182 return;
11183
11175 ContactResult result = new ContactResult (); 11184 ContactResult result = new ContactResult ();
11176 result.ConsumerID = group.LocalId; 11185 result.ConsumerID = group.LocalId;
11177 result.Depth = intersection.distance; 11186 result.Depth = intersection.distance;
@@ -11423,8 +11432,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11423 if (checkPhysical || checkNonPhysical || detectPhantom) 11432 if (checkPhysical || checkNonPhysical || detectPhantom)
11424 { 11433 {
11425 ContactResult[] objectHits = ObjectIntersection(rayStart, rayEnd, checkPhysical, checkNonPhysical, detectPhantom); 11434 ContactResult[] objectHits = ObjectIntersection(rayStart, rayEnd, checkPhysical, checkNonPhysical, detectPhantom);
11426 foreach (ContactResult r in objectHits) 11435 for (int iter = 0; iter < objectHits.Length; iter++)
11427 results.Add(r); 11436 {
11437 // Redistance the Depth because the Scene RayCaster returns distance from center to make the rezzing code simpler.
11438 objectHits[iter].Depth = Vector3.Distance(objectHits[iter].Pos, rayStart);
11439 results.Add(objectHits[iter]);
11440 }
11428 } 11441 }
11429 } 11442 }
11430 11443