aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Api/Implementation
diff options
context:
space:
mode:
authorMelanie2012-04-17 01:50:49 +0100
committerMelanie2012-04-17 01:50:49 +0100
commitab1a3688e24db08071f74c9804d552d5763bbeb2 (patch)
tree030bafc8ce646fbf80bd20a1e7647618222e7fc2 /OpenSim/Region/ScriptEngine/Shared/Api/Implementation
parentMerge branch 'master' into careminster (diff)
parentMerge branch 'ubitwork' (diff)
downloadopensim-SC-ab1a3688e24db08071f74c9804d552d5763bbeb2.zip
opensim-SC-ab1a3688e24db08071f74c9804d552d5763bbeb2.tar.gz
opensim-SC-ab1a3688e24db08071f74c9804d552d5763bbeb2.tar.bz2
opensim-SC-ab1a3688e24db08071f74c9804d552d5763bbeb2.tar.xz
Merge branch 'master' of ssh://melanie@3dhosting.de/var/git/careminster into careminster
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs133
1 files changed, 109 insertions, 24 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 9564d46..3a7eb32 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -9980,7 +9980,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9980 // return total object mass 9980 // return total object mass
9981 SceneObjectGroup obj = World.GetGroupByPrim(World.Entities[key].LocalId); 9981 SceneObjectGroup obj = World.GetGroupByPrim(World.Entities[key].LocalId);
9982 if (obj != null) 9982 if (obj != null)
9983 return (double)obj.GetMass(); 9983 return obj.GetMass();
9984 9984
9985 // the object is null so the key is for an avatar 9985 // the object is null so the key is for an avatar
9986 ScenePresence avatar = World.GetScenePresence(key); 9986 ScenePresence avatar = World.GetScenePresence(key);
@@ -9990,7 +9990,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9990 // child agents have a mass of 1.0 9990 // child agents have a mass of 1.0
9991 return 1; 9991 return 1;
9992 else 9992 else
9993 return (double)avatar.PhysicsActor.Mass; 9993 return avatar.GetMass();
9994 } 9994 }
9995 catch (KeyNotFoundException) 9995 catch (KeyNotFoundException)
9996 { 9996 {
@@ -11834,6 +11834,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11834 11834
11835 return contacts[0]; 11835 return contacts[0];
11836 } 11836 }
11837/*
11838 // not done:
11839 private ContactResult[] testRay2NonPhysicalPhantom(Vector3 rayStart, Vector3 raydir, float raylenght)
11840 {
11841 ContactResult[] contacts = null;
11842 World.ForEachSOG(delegate(SceneObjectGroup group)
11843 {
11844 if (m_host.ParentGroup == group)
11845 return;
11846
11847 if (group.IsAttachment)
11848 return;
11849
11850 if(group.RootPart.PhysActor != null)
11851 return;
11852
11853 contacts = group.RayCastGroupPartsOBBNonPhysicalPhantom(rayStart, raydir, raylenght);
11854 });
11855 return contacts;
11856 }
11857*/
11837 11858
11838 public LSL_List llCastRay(LSL_Vector start, LSL_Vector end, LSL_List options) 11859 public LSL_List llCastRay(LSL_Vector start, LSL_Vector end, LSL_List options)
11839 { 11860 {
@@ -11874,38 +11895,101 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11874 bool checkNonPhysical = !((rejectTypes & ScriptBaseClass.RC_REJECT_NONPHYSICAL) == ScriptBaseClass.RC_REJECT_NONPHYSICAL); 11895 bool checkNonPhysical = !((rejectTypes & ScriptBaseClass.RC_REJECT_NONPHYSICAL) == ScriptBaseClass.RC_REJECT_NONPHYSICAL);
11875 bool checkPhysical = !((rejectTypes & ScriptBaseClass.RC_REJECT_PHYSICAL) == ScriptBaseClass.RC_REJECT_PHYSICAL); 11896 bool checkPhysical = !((rejectTypes & ScriptBaseClass.RC_REJECT_PHYSICAL) == ScriptBaseClass.RC_REJECT_PHYSICAL);
11876 11897
11877 if (checkTerrain)
11878 {
11879 ContactResult? groundContact = GroundIntersection(rayStart, rayEnd);
11880 if (groundContact != null)
11881 results.Add((ContactResult)groundContact);
11882 }
11883 11898
11884 if (checkAgents) 11899 if (World.SuportsRayCastFiltered())
11885 { 11900 {
11886 ContactResult[] agentHits = AvatarIntersection(rayStart, rayEnd); 11901 if (dist == 0)
11887 foreach (ContactResult r in agentHits) 11902 return list;
11888 results.Add(r); 11903
11889 } 11904 RayFilterFlags rayfilter = RayFilterFlags.ClosestAndBackCull;
11905 if (checkTerrain)
11906 rayfilter |= RayFilterFlags.land;
11907// if (checkAgents)
11908// rayfilter |= RayFilterFlags.agent;
11909 if (checkPhysical)
11910 rayfilter |= RayFilterFlags.physical;
11911 if (checkNonPhysical)
11912 rayfilter |= RayFilterFlags.nonphysical;
11913 if (detectPhantom)
11914 rayfilter |= RayFilterFlags.LSLPhanton;
11915
11916 Vector3 direction = dir * ( 1/dist);
11917
11918 if(rayfilter == 0)
11919 {
11920 list.Add(new LSL_Integer(0));
11921 return list;
11922 }
11923
11924 // get some more contacts to sort ???
11925 int physcount = 4 * count;
11926 if (physcount > 20)
11927 physcount = 20;
11928
11929 object physresults;
11930 physresults = World.RayCastFiltered(rayStart, direction, dist, physcount, rayfilter);
11931
11932 if (physresults == null)
11933 {
11934 list.Add(new LSL_Integer(-3)); // timeout error
11935 return list;
11936 }
11937
11938 results = (List<ContactResult>)physresults;
11939
11940 // for now physics doesn't detect sitted avatars so do it outside physics
11941 if (checkAgents)
11942 {
11943 ContactResult[] agentHits = AvatarIntersection(rayStart, rayEnd);
11944 foreach (ContactResult r in agentHits)
11945 results.Add(r);
11946 }
11947
11948 // bug: will not detect phantom unless they are physical
11949 // don't use ObjectIntersection because its also bad
11890 11950
11891 if (checkPhysical || checkNonPhysical) 11951 }
11952 else
11892 { 11953 {
11893 ContactResult[] objectHits = ObjectIntersection(rayStart, rayEnd, checkPhysical, checkNonPhysical, detectPhantom); 11954 if (checkTerrain)
11894 foreach (ContactResult r in objectHits) 11955 {
11895 results.Add(r); 11956 ContactResult? groundContact = GroundIntersection(rayStart, rayEnd);
11957 if (groundContact != null)
11958 results.Add((ContactResult)groundContact);
11959 }
11960
11961 if (checkAgents)
11962 {
11963 ContactResult[] agentHits = AvatarIntersection(rayStart, rayEnd);
11964 foreach (ContactResult r in agentHits)
11965 results.Add(r);
11966 }
11967
11968 if (checkPhysical || checkNonPhysical || detectPhantom)
11969 {
11970 ContactResult[] objectHits = ObjectIntersection(rayStart, rayEnd, checkPhysical, checkNonPhysical, detectPhantom);
11971 foreach (ContactResult r in objectHits)
11972 results.Add(r);
11973 }
11896 } 11974 }
11897 11975
11898 results.Sort(delegate(ContactResult a, ContactResult b) 11976 results.Sort(delegate(ContactResult a, ContactResult b)
11899 { 11977 {
11900 return (int)(a.Depth - b.Depth); 11978 return a.Depth.CompareTo(b.Depth);
11901 }); 11979 });
11902 11980
11903 int values = 0; 11981 int values = 0;
11982 SceneObjectGroup thisgrp = m_host.ParentGroup;
11983
11904 foreach (ContactResult result in results) 11984 foreach (ContactResult result in results)
11905 { 11985 {
11906 if (result.Depth > dist) 11986 if (result.Depth > dist)
11907 continue; 11987 continue;
11908 11988
11989 // physics ray can return colisions with host prim
11990 if (m_host.LocalId == result.ConsumerID)
11991 continue;
11992
11909 UUID itemID = UUID.Zero; 11993 UUID itemID = UUID.Zero;
11910 int linkNum = 0; 11994 int linkNum = 0;
11911 11995
@@ -11913,6 +11997,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11913 // It's a prim! 11997 // It's a prim!
11914 if (part != null) 11998 if (part != null)
11915 { 11999 {
12000 // dont detect members of same object ???
12001 if (part.ParentGroup == thisgrp)
12002 continue;
12003
11916 if ((dataFlags & ScriptBaseClass.RC_GET_ROOT_KEY) == ScriptBaseClass.RC_GET_ROOT_KEY) 12004 if ((dataFlags & ScriptBaseClass.RC_GET_ROOT_KEY) == ScriptBaseClass.RC_GET_ROOT_KEY)
11917 itemID = part.ParentGroup.UUID; 12005 itemID = part.ParentGroup.UUID;
11918 else 12006 else
@@ -11923,7 +12011,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11923 else 12011 else
11924 { 12012 {
11925 ScenePresence sp = World.GetScenePresence(result.ConsumerID); 12013 ScenePresence sp = World.GetScenePresence(result.ConsumerID);
11926 /// It it a boy? a girl? 12014 /// It it a boy? a girl?
11927 if (sp != null) 12015 if (sp != null)
11928 itemID = sp.UUID; 12016 itemID = sp.UUID;
11929 } 12017 }
@@ -11934,14 +12022,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11934 if ((dataFlags & ScriptBaseClass.RC_GET_LINK_NUM) == ScriptBaseClass.RC_GET_LINK_NUM) 12022 if ((dataFlags & ScriptBaseClass.RC_GET_LINK_NUM) == ScriptBaseClass.RC_GET_LINK_NUM)
11935 list.Add(new LSL_Integer(linkNum)); 12023 list.Add(new LSL_Integer(linkNum));
11936 12024
11937
11938 if ((dataFlags & ScriptBaseClass.RC_GET_NORMAL) == ScriptBaseClass.RC_GET_NORMAL) 12025 if ((dataFlags & ScriptBaseClass.RC_GET_NORMAL) == ScriptBaseClass.RC_GET_NORMAL)
11939 list.Add(new LSL_Vector(result.Normal.X, result.Normal.Y, result.Normal.Z)); 12026 list.Add(new LSL_Vector(result.Normal.X, result.Normal.Y, result.Normal.Z));
11940
11941 values++;
11942 count--;
11943 12027
11944 if (count == 0) 12028 values++;
12029 if (values >= count)
11945 break; 12030 break;
11946 } 12031 }
11947 12032