diff options
author | UbitUmarov | 2012-04-16 16:35:35 +0100 |
---|---|---|
committer | UbitUmarov | 2012-04-16 16:35:35 +0100 |
commit | f05a977afaacca2df4406f2d4aefed960a4b7f1c (patch) | |
tree | cf865bc1ce7ae2d9c479257ef4f70d1d92bfff40 /OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |
parent | added suport funtions for ubitODE raycastFiltered (diff) | |
download | opensim-SC-f05a977afaacca2df4406f2d4aefed960a4b7f1c.zip opensim-SC-f05a977afaacca2df4406f2d4aefed960a4b7f1c.tar.gz opensim-SC-f05a977afaacca2df4406f2d4aefed960a4b7f1c.tar.bz2 opensim-SC-f05a977afaacca2df4406f2d4aefed960a4b7f1c.tar.xz |
Let llCastRay use ubitODE raycast if avaiable plus a few changes/fixes that should be checked. PROBLEM: it will not detect nonphysical phantons :(
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 108 |
1 files changed, 86 insertions, 22 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 2f61b70..5b5e23e 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -11869,38 +11869,101 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11869 | bool checkNonPhysical = !((rejectTypes & ScriptBaseClass.RC_REJECT_NONPHYSICAL) == ScriptBaseClass.RC_REJECT_NONPHYSICAL); | 11869 | bool checkNonPhysical = !((rejectTypes & ScriptBaseClass.RC_REJECT_NONPHYSICAL) == ScriptBaseClass.RC_REJECT_NONPHYSICAL); |
11870 | bool checkPhysical = !((rejectTypes & ScriptBaseClass.RC_REJECT_PHYSICAL) == ScriptBaseClass.RC_REJECT_PHYSICAL); | 11870 | bool checkPhysical = !((rejectTypes & ScriptBaseClass.RC_REJECT_PHYSICAL) == ScriptBaseClass.RC_REJECT_PHYSICAL); |
11871 | 11871 | ||
11872 | if (checkTerrain) | ||
11873 | { | ||
11874 | ContactResult? groundContact = GroundIntersection(rayStart, rayEnd); | ||
11875 | if (groundContact != null) | ||
11876 | results.Add((ContactResult)groundContact); | ||
11877 | } | ||
11878 | 11872 | ||
11879 | if (checkAgents) | 11873 | if (World.SuportsRayCastFiltered()) |
11880 | { | 11874 | { |
11881 | ContactResult[] agentHits = AvatarIntersection(rayStart, rayEnd); | 11875 | if (dist == 0) |
11882 | foreach (ContactResult r in agentHits) | 11876 | return list; |
11883 | results.Add(r); | 11877 | |
11884 | } | 11878 | RayFilterFlags rayfilter = RayFilterFlags.ClosestAndBackCull; |
11879 | if (checkTerrain) | ||
11880 | rayfilter |= RayFilterFlags.land; | ||
11881 | // if (checkAgents) | ||
11882 | // rayfilter |= RayFilterFlags.agent; | ||
11883 | if (checkPhysical) | ||
11884 | rayfilter |= RayFilterFlags.physical; | ||
11885 | if (checkNonPhysical) | ||
11886 | rayfilter |= RayFilterFlags.nonphysical; | ||
11887 | if (detectPhantom) | ||
11888 | rayfilter |= RayFilterFlags.LSLPhanton; | ||
11889 | |||
11890 | Vector3 direction = dir * ( 1/dist); | ||
11891 | |||
11892 | if(rayfilter == 0) | ||
11893 | { | ||
11894 | list.Add(new LSL_Integer(0)); | ||
11895 | return list; | ||
11896 | } | ||
11897 | |||
11898 | // get some more contacts to sort ??? | ||
11899 | int physcount = 4 * count; | ||
11900 | if (physcount > 20) | ||
11901 | physcount = 20; | ||
11902 | |||
11903 | object physresults; | ||
11904 | physresults = World.RayCastFiltered(rayStart, direction, dist, physcount, rayfilter); | ||
11885 | 11905 | ||
11886 | if (checkPhysical || checkNonPhysical) | 11906 | if (physresults == null) |
11907 | { | ||
11908 | list.Add(new LSL_Integer(-3)); // timeout error | ||
11909 | return list; | ||
11910 | } | ||
11911 | |||
11912 | results = (List<ContactResult>)physresults; | ||
11913 | |||
11914 | // for now physics doesn't detect sitted avatars so do it outside physics | ||
11915 | if (checkAgents) | ||
11916 | { | ||
11917 | ContactResult[] agentHits = AvatarIntersection(rayStart, rayEnd); | ||
11918 | foreach (ContactResult r in agentHits) | ||
11919 | results.Add(r); | ||
11920 | } | ||
11921 | |||
11922 | // bug: will not detect phantom unless they are physical | ||
11923 | // don't use ObjectIntersection because its also bad | ||
11924 | |||
11925 | } | ||
11926 | else | ||
11887 | { | 11927 | { |
11888 | ContactResult[] objectHits = ObjectIntersection(rayStart, rayEnd, checkPhysical, checkNonPhysical, detectPhantom); | 11928 | if (checkTerrain) |
11889 | foreach (ContactResult r in objectHits) | 11929 | { |
11890 | results.Add(r); | 11930 | ContactResult? groundContact = GroundIntersection(rayStart, rayEnd); |
11931 | if (groundContact != null) | ||
11932 | results.Add((ContactResult)groundContact); | ||
11933 | } | ||
11934 | |||
11935 | if (checkAgents) | ||
11936 | { | ||
11937 | ContactResult[] agentHits = AvatarIntersection(rayStart, rayEnd); | ||
11938 | foreach (ContactResult r in agentHits) | ||
11939 | results.Add(r); | ||
11940 | } | ||
11941 | |||
11942 | if (checkPhysical || checkNonPhysical || detectPhantom) | ||
11943 | { | ||
11944 | ContactResult[] objectHits = ObjectIntersection(rayStart, rayEnd, checkPhysical, checkNonPhysical, detectPhantom); | ||
11945 | foreach (ContactResult r in objectHits) | ||
11946 | results.Add(r); | ||
11947 | } | ||
11891 | } | 11948 | } |
11892 | 11949 | ||
11893 | results.Sort(delegate(ContactResult a, ContactResult b) | 11950 | results.Sort(delegate(ContactResult a, ContactResult b) |
11894 | { | 11951 | { |
11895 | return (int)(a.Depth - b.Depth); | 11952 | return a.Depth.CompareTo(b.Depth); |
11896 | }); | 11953 | }); |
11897 | 11954 | ||
11898 | int values = 0; | 11955 | int values = 0; |
11956 | SceneObjectGroup thisgrp = m_host.ParentGroup; | ||
11957 | |||
11899 | foreach (ContactResult result in results) | 11958 | foreach (ContactResult result in results) |
11900 | { | 11959 | { |
11901 | if (result.Depth > dist) | 11960 | if (result.Depth > dist) |
11902 | continue; | 11961 | continue; |
11903 | 11962 | ||
11963 | // physics ray can return colisions with host prim | ||
11964 | if (m_host.LocalId == result.ConsumerID) | ||
11965 | continue; | ||
11966 | |||
11904 | UUID itemID = UUID.Zero; | 11967 | UUID itemID = UUID.Zero; |
11905 | int linkNum = 0; | 11968 | int linkNum = 0; |
11906 | 11969 | ||
@@ -11908,6 +11971,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11908 | // It's a prim! | 11971 | // It's a prim! |
11909 | if (part != null) | 11972 | if (part != null) |
11910 | { | 11973 | { |
11974 | // dont detect members of same object ??? | ||
11975 | if (part.ParentGroup == thisgrp) | ||
11976 | continue; | ||
11977 | |||
11911 | if ((dataFlags & ScriptBaseClass.RC_GET_ROOT_KEY) == ScriptBaseClass.RC_GET_ROOT_KEY) | 11978 | if ((dataFlags & ScriptBaseClass.RC_GET_ROOT_KEY) == ScriptBaseClass.RC_GET_ROOT_KEY) |
11912 | itemID = part.ParentGroup.UUID; | 11979 | itemID = part.ParentGroup.UUID; |
11913 | else | 11980 | else |
@@ -11918,7 +11985,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11918 | else | 11985 | else |
11919 | { | 11986 | { |
11920 | ScenePresence sp = World.GetScenePresence(result.ConsumerID); | 11987 | ScenePresence sp = World.GetScenePresence(result.ConsumerID); |
11921 | /// It it a boy? a girl? | 11988 | /// It it a boy? a girl? |
11922 | if (sp != null) | 11989 | if (sp != null) |
11923 | itemID = sp.UUID; | 11990 | itemID = sp.UUID; |
11924 | } | 11991 | } |
@@ -11929,14 +11996,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11929 | if ((dataFlags & ScriptBaseClass.RC_GET_LINK_NUM) == ScriptBaseClass.RC_GET_LINK_NUM) | 11996 | if ((dataFlags & ScriptBaseClass.RC_GET_LINK_NUM) == ScriptBaseClass.RC_GET_LINK_NUM) |
11930 | list.Add(new LSL_Integer(linkNum)); | 11997 | list.Add(new LSL_Integer(linkNum)); |
11931 | 11998 | ||
11932 | |||
11933 | if ((dataFlags & ScriptBaseClass.RC_GET_NORMAL) == ScriptBaseClass.RC_GET_NORMAL) | 11999 | if ((dataFlags & ScriptBaseClass.RC_GET_NORMAL) == ScriptBaseClass.RC_GET_NORMAL) |
11934 | list.Add(new LSL_Vector(result.Normal.X, result.Normal.Y, result.Normal.Z)); | 12000 | list.Add(new LSL_Vector(result.Normal.X, result.Normal.Y, result.Normal.Z)); |
11935 | |||
11936 | values++; | ||
11937 | count--; | ||
11938 | 12001 | ||
11939 | if (count == 0) | 12002 | values++; |
12003 | if (values >= count) | ||
11940 | break; | 12004 | break; |
11941 | } | 12005 | } |
11942 | 12006 | ||