From 014cd1ab428feff96484c666694c33822344269e Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 6 Nov 2016 03:53:12 +0000 Subject: [PATCH] restrict ubOde castray with terrain range only on horizontal plane, let it find physical avatars. --- .../ubOde/ODERayCastRequestManager.cs | 11 +++++++++- .../Shared/Api/Implementation/LSL_Api.cs | 22 +++++++++++-------- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODERayCastRequestManager.cs b/OpenSim/Region/PhysicsModules/ubOde/ODERayCastRequestManager.cs index b82d5930b4..adefd5edf5 100644 --- a/OpenSim/Region/PhysicsModules/ubOde/ODERayCastRequestManager.cs +++ b/OpenSim/Region/PhysicsModules/ubOde/ODERayCastRequestManager.cs @@ -317,8 +317,17 @@ namespace OpenSim.Region.PhysicsModule.ubOde // current ode land to ray collisions is very bad // so for now limit its range badly if (req.length > 60.0f) - d.GeomRaySetLength(ray, 60.0f); + { + Vector3 t = req.Normal * req.length; + float tmp = t.X * t.X + t.Y * t.Y; + if(tmp > 2500) + { + float tmp2 = req.length * req.length - tmp + 2500; + tmp2 = (float)Math.Sqrt(tmp2); + d.GeomRaySetLength(ray, tmp2); + } + } d.SpaceCollide2(ray, m_scene.GroundSpace, IntPtr.Zero, nearCallback); } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 02a9ebcab5..33d5757b14 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -14216,18 +14216,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return false; } - private ContactResult[] AvatarIntersection(Vector3 rayStart, Vector3 rayEnd) + private ContactResult[] AvatarIntersection(Vector3 rayStart, Vector3 rayEnd, bool skipPhys) { List contacts = new List(); Vector3 ab = rayEnd - rayStart; + float ablen = ab.Length(); World.ForEachScenePresence(delegate(ScenePresence sp) { - Vector3 ac = sp.AbsolutePosition - rayStart; -// Vector3 bc = sp.AbsolutePosition - rayEnd; + if(skipPhys && sp.PhysicsActor != null) + return; - double d = Math.Abs(Vector3.Mag(Vector3.Cross(ab, ac)) / Vector3.Distance(rayStart, rayEnd)); + Vector3 ac = sp.AbsolutePosition - rayStart; + + double d = Math.Abs(Vector3.Mag(Vector3.Cross(ab, ac)) / ablen); if (d > 1.5) return; @@ -14553,8 +14556,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api RayFilterFlags rayfilter = RayFilterFlags.BackFaceCull; if (checkTerrain) rayfilter |= RayFilterFlags.land; -// if (checkAgents) -// rayfilter |= RayFilterFlags.agent; + if (checkAgents) + rayfilter |= RayFilterFlags.agent; if (checkPhysical) rayfilter |= RayFilterFlags.physical; if (checkNonPhysical) @@ -14578,18 +14581,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api object physresults; physresults = World.RayCastFiltered(rayStart, direction, dist, physcount, rayfilter); +/* if (physresults == null) { list.Add(new LSL_Integer(-3)); // timeout error return list; } - +*/ results = (List)physresults; // for now physics doesn't detect sitted avatars so do it outside physics if (checkAgents) { - ContactResult[] agentHits = AvatarIntersection(rayStart, rayEnd); + ContactResult[] agentHits = AvatarIntersection(rayStart, rayEnd, true); foreach (ContactResult r in agentHits) results.Add(r); } @@ -14610,7 +14614,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { if (checkAgents) { - ContactResult[] agentHits = AvatarIntersection(rayStart, rayEnd); + ContactResult[] agentHits = AvatarIntersection(rayStart, rayEnd, false); foreach (ContactResult r in agentHits) results.Add(r); }