From c4f1906b0ac568dcb45824308baa9852cc399ce8 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 17 Dec 2011 12:57:20 +0100 Subject: Make raycast more efficient by checking exclusion flags earlier --- .../Shared/Api/Implementation/LSL_Api.cs | 36 +++++++++++++--------- 1 file changed, 21 insertions(+), 15 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared/Api') 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 return contacts.ToArray(); } - private ContactResult[] ObjectIntersection(Vector3 rayStart, Vector3 rayEnd) + private ContactResult[] ObjectIntersection(Vector3 rayStart, Vector3 rayEnd, bool includePhysical, bool includeNonPhysical, bool includePhantom) { Ray ray = new Ray(rayStart, Vector3.Normalize(rayEnd - rayStart)); List contacts = new List(); @@ -11199,6 +11199,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (group.IsAttachment) return; + if (group.RootPart.PhysActor == null) + { + if (!includePhantom) + return; + } + else + { + if (group.RootPart.PhysActor.IsPhysical) + { + if (!includePhysical) + return; + } + else + { + if (!includeNonPhysical) + return; + } + } + // Find the radius ouside of which we don't even need to hit test float minX; float maxX; @@ -11434,7 +11453,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (checkPhysical || checkNonPhysical) { - ContactResult[] objectHits = ObjectIntersection(rayStart, rayEnd); + ContactResult[] objectHits = ObjectIntersection(rayStart, rayEnd, checkPhysical, checkNonPhysical, detectPhantom); foreach (ContactResult r in objectHits) results.Add(r); } @@ -11454,19 +11473,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // It's a prim! if (part != null) { - if (part.PhysActor != null) - { - if (part.PhysActor.IsPhysical && !checkPhysical) - continue; - if (!part.PhysActor.IsPhysical && !checkNonPhysical) - continue; - } - else - { - if (!detectPhantom) - continue; - } - if ((dataFlags & ScriptBaseClass.RC_GET_ROOT_KEY) == ScriptBaseClass.RC_GET_ROOT_KEY) itemID = part.ParentGroup.UUID; else -- cgit v1.1