diff options
author | UbitUmarov | 2016-11-06 03:53:12 +0000 |
---|---|---|
committer | UbitUmarov | 2016-11-06 03:53:12 +0000 |
commit | 014cd1ab428feff96484c666694c33822344269e (patch) | |
tree | 5c20753e4f1613d69f1a3aa7b1e2d80ce82248b1 | |
parent | change llGetTime() source clock (diff) | |
download | opensim-SC-014cd1ab428feff96484c666694c33822344269e.zip opensim-SC-014cd1ab428feff96484c666694c33822344269e.tar.gz opensim-SC-014cd1ab428feff96484c666694c33822344269e.tar.bz2 opensim-SC-014cd1ab428feff96484c666694c33822344269e.tar.xz |
restrict ubOde castray with terrain range only on horizontal plane, let it find physical avatars.
-rw-r--r-- | OpenSim/Region/PhysicsModules/ubOde/ODERayCastRequestManager.cs | 11 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 20 |
2 files changed, 22 insertions, 9 deletions
diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODERayCastRequestManager.cs b/OpenSim/Region/PhysicsModules/ubOde/ODERayCastRequestManager.cs index b82d593..adefd5e 100644 --- a/OpenSim/Region/PhysicsModules/ubOde/ODERayCastRequestManager.cs +++ b/OpenSim/Region/PhysicsModules/ubOde/ODERayCastRequestManager.cs | |||
@@ -317,8 +317,17 @@ namespace OpenSim.Region.PhysicsModule.ubOde | |||
317 | // current ode land to ray collisions is very bad | 317 | // current ode land to ray collisions is very bad |
318 | // so for now limit its range badly | 318 | // so for now limit its range badly |
319 | if (req.length > 60.0f) | 319 | if (req.length > 60.0f) |
320 | d.GeomRaySetLength(ray, 60.0f); | 320 | { |
321 | Vector3 t = req.Normal * req.length; | ||
322 | float tmp = t.X * t.X + t.Y * t.Y; | ||
323 | if(tmp > 2500) | ||
324 | { | ||
325 | float tmp2 = req.length * req.length - tmp + 2500; | ||
326 | tmp2 = (float)Math.Sqrt(tmp2); | ||
327 | d.GeomRaySetLength(ray, tmp2); | ||
328 | } | ||
321 | 329 | ||
330 | } | ||
322 | d.SpaceCollide2(ray, m_scene.GroundSpace, IntPtr.Zero, nearCallback); | 331 | d.SpaceCollide2(ray, m_scene.GroundSpace, IntPtr.Zero, nearCallback); |
323 | } | 332 | } |
324 | 333 | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 02a9ebc..33d5757 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 | |||
14216 | return false; | 14216 | return false; |
14217 | } | 14217 | } |
14218 | 14218 | ||
14219 | private ContactResult[] AvatarIntersection(Vector3 rayStart, Vector3 rayEnd) | 14219 | private ContactResult[] AvatarIntersection(Vector3 rayStart, Vector3 rayEnd, bool skipPhys) |
14220 | { | 14220 | { |
14221 | List<ContactResult> contacts = new List<ContactResult>(); | 14221 | List<ContactResult> contacts = new List<ContactResult>(); |
14222 | 14222 | ||
14223 | Vector3 ab = rayEnd - rayStart; | 14223 | Vector3 ab = rayEnd - rayStart; |
14224 | float ablen = ab.Length(); | ||
14224 | 14225 | ||
14225 | World.ForEachScenePresence(delegate(ScenePresence sp) | 14226 | World.ForEachScenePresence(delegate(ScenePresence sp) |
14226 | { | 14227 | { |
14228 | if(skipPhys && sp.PhysicsActor != null) | ||
14229 | return; | ||
14230 | |||
14227 | Vector3 ac = sp.AbsolutePosition - rayStart; | 14231 | Vector3 ac = sp.AbsolutePosition - rayStart; |
14228 | // Vector3 bc = sp.AbsolutePosition - rayEnd; | ||
14229 | 14232 | ||
14230 | double d = Math.Abs(Vector3.Mag(Vector3.Cross(ab, ac)) / Vector3.Distance(rayStart, rayEnd)); | 14233 | double d = Math.Abs(Vector3.Mag(Vector3.Cross(ab, ac)) / ablen); |
14231 | 14234 | ||
14232 | if (d > 1.5) | 14235 | if (d > 1.5) |
14233 | return; | 14236 | return; |
@@ -14553,8 +14556,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
14553 | RayFilterFlags rayfilter = RayFilterFlags.BackFaceCull; | 14556 | RayFilterFlags rayfilter = RayFilterFlags.BackFaceCull; |
14554 | if (checkTerrain) | 14557 | if (checkTerrain) |
14555 | rayfilter |= RayFilterFlags.land; | 14558 | rayfilter |= RayFilterFlags.land; |
14556 | // if (checkAgents) | 14559 | if (checkAgents) |
14557 | // rayfilter |= RayFilterFlags.agent; | 14560 | rayfilter |= RayFilterFlags.agent; |
14558 | if (checkPhysical) | 14561 | if (checkPhysical) |
14559 | rayfilter |= RayFilterFlags.physical; | 14562 | rayfilter |= RayFilterFlags.physical; |
14560 | if (checkNonPhysical) | 14563 | if (checkNonPhysical) |
@@ -14578,18 +14581,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
14578 | object physresults; | 14581 | object physresults; |
14579 | physresults = World.RayCastFiltered(rayStart, direction, dist, physcount, rayfilter); | 14582 | physresults = World.RayCastFiltered(rayStart, direction, dist, physcount, rayfilter); |
14580 | 14583 | ||
14584 | /* | ||
14581 | if (physresults == null) | 14585 | if (physresults == null) |
14582 | { | 14586 | { |
14583 | list.Add(new LSL_Integer(-3)); // timeout error | 14587 | list.Add(new LSL_Integer(-3)); // timeout error |
14584 | return list; | 14588 | return list; |
14585 | } | 14589 | } |
14586 | 14590 | */ | |
14587 | results = (List<ContactResult>)physresults; | 14591 | results = (List<ContactResult>)physresults; |
14588 | 14592 | ||
14589 | // for now physics doesn't detect sitted avatars so do it outside physics | 14593 | // for now physics doesn't detect sitted avatars so do it outside physics |
14590 | if (checkAgents) | 14594 | if (checkAgents) |
14591 | { | 14595 | { |
14592 | ContactResult[] agentHits = AvatarIntersection(rayStart, rayEnd); | 14596 | ContactResult[] agentHits = AvatarIntersection(rayStart, rayEnd, true); |
14593 | foreach (ContactResult r in agentHits) | 14597 | foreach (ContactResult r in agentHits) |
14594 | results.Add(r); | 14598 | results.Add(r); |
14595 | } | 14599 | } |
@@ -14610,7 +14614,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
14610 | { | 14614 | { |
14611 | if (checkAgents) | 14615 | if (checkAgents) |
14612 | { | 14616 | { |
14613 | ContactResult[] agentHits = AvatarIntersection(rayStart, rayEnd); | 14617 | ContactResult[] agentHits = AvatarIntersection(rayStart, rayEnd, false); |
14614 | foreach (ContactResult r in agentHits) | 14618 | foreach (ContactResult r in agentHits) |
14615 | results.Add(r); | 14619 | results.Add(r); |
14616 | } | 14620 | } |