aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Api
diff options
context:
space:
mode:
authorMelanie2011-12-17 12:57:20 +0100
committerMelanie2011-12-17 12:57:20 +0100
commitc4f1906b0ac568dcb45824308baa9852cc399ce8 (patch)
treee388a858e9a9a22c61c2d96ef24fd5c470b6d628 /OpenSim/Region/ScriptEngine/Shared/Api
parentFix hit testing link sets properly. Fix raycasting for LSL. (diff)
downloadopensim-SC_OLD-c4f1906b0ac568dcb45824308baa9852cc399ce8.zip
opensim-SC_OLD-c4f1906b0ac568dcb45824308baa9852cc399ce8.tar.gz
opensim-SC_OLD-c4f1906b0ac568dcb45824308baa9852cc399ce8.tar.bz2
opensim-SC_OLD-c4f1906b0ac568dcb45824308baa9852cc399ce8.tar.xz
Make raycast more efficient by checking exclusion flags earlier
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs36
1 files changed, 21 insertions, 15 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 42a2044..21c0a27 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -11184,7 +11184,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11184 return contacts.ToArray(); 11184 return contacts.ToArray();
11185 } 11185 }
11186 11186
11187 private ContactResult[] ObjectIntersection(Vector3 rayStart, Vector3 rayEnd) 11187 private ContactResult[] ObjectIntersection(Vector3 rayStart, Vector3 rayEnd, bool includePhysical, bool includeNonPhysical, bool includePhantom)
11188 { 11188 {
11189 Ray ray = new Ray(rayStart, Vector3.Normalize(rayEnd - rayStart)); 11189 Ray ray = new Ray(rayStart, Vector3.Normalize(rayEnd - rayStart));
11190 List<ContactResult> contacts = new List<ContactResult>(); 11190 List<ContactResult> contacts = new List<ContactResult>();
@@ -11199,6 +11199,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11199 if (group.IsAttachment) 11199 if (group.IsAttachment)
11200 return; 11200 return;
11201 11201
11202 if (group.RootPart.PhysActor == null)
11203 {
11204 if (!includePhantom)
11205 return;
11206 }
11207 else
11208 {
11209 if (group.RootPart.PhysActor.IsPhysical)
11210 {
11211 if (!includePhysical)
11212 return;
11213 }
11214 else
11215 {
11216 if (!includeNonPhysical)
11217 return;
11218 }
11219 }
11220
11202 // Find the radius ouside of which we don't even need to hit test 11221 // Find the radius ouside of which we don't even need to hit test
11203 float minX; 11222 float minX;
11204 float maxX; 11223 float maxX;
@@ -11434,7 +11453,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11434 11453
11435 if (checkPhysical || checkNonPhysical) 11454 if (checkPhysical || checkNonPhysical)
11436 { 11455 {
11437 ContactResult[] objectHits = ObjectIntersection(rayStart, rayEnd); 11456 ContactResult[] objectHits = ObjectIntersection(rayStart, rayEnd, checkPhysical, checkNonPhysical, detectPhantom);
11438 foreach (ContactResult r in objectHits) 11457 foreach (ContactResult r in objectHits)
11439 results.Add(r); 11458 results.Add(r);
11440 } 11459 }
@@ -11454,19 +11473,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11454 // It's a prim! 11473 // It's a prim!
11455 if (part != null) 11474 if (part != null)
11456 { 11475 {
11457 if (part.PhysActor != null)
11458 {
11459 if (part.PhysActor.IsPhysical && !checkPhysical)
11460 continue;
11461 if (!part.PhysActor.IsPhysical && !checkNonPhysical)
11462 continue;
11463 }
11464 else
11465 {
11466 if (!detectPhantom)
11467 continue;
11468 }
11469
11470 if ((dataFlags & ScriptBaseClass.RC_GET_ROOT_KEY) == ScriptBaseClass.RC_GET_ROOT_KEY) 11476 if ((dataFlags & ScriptBaseClass.RC_GET_ROOT_KEY) == ScriptBaseClass.RC_GET_ROOT_KEY)
11471 itemID = part.ParentGroup.UUID; 11477 itemID = part.ParentGroup.UUID;
11472 else 11478 else