diff options
author | meta7 | 2010-08-22 09:32:49 -0700 |
---|---|---|
committer | meta7 | 2010-08-22 09:32:49 -0700 |
commit | 8a1640f0a1838a0cfc05ec6bab6d5d6166fde221 (patch) | |
tree | 94c0d096eb9889f425269a926ef2090590f75ae7 /OpenSim/Region/ScriptEngine/Shared/Api | |
parent | Fix llGetLinkKey and llGetNumberOfPrims to play nice with avatars in the link... (diff) | |
parent | Refix the fix (diff) | |
download | opensim-SC_OLD-8a1640f0a1838a0cfc05ec6bab6d5d6166fde221.zip opensim-SC_OLD-8a1640f0a1838a0cfc05ec6bab6d5d6166fde221.tar.gz opensim-SC_OLD-8a1640f0a1838a0cfc05ec6bab6d5d6166fde221.tar.bz2 opensim-SC_OLD-8a1640f0a1838a0cfc05ec6bab6d5d6166fde221.tar.xz |
Merge branch 'careminster-presence-refactor' of ssh://3dhosting.de/var/git/careminster into careminster-presence-refactor
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 120 |
1 files changed, 88 insertions, 32 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index b4134a4..94b9d40 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -5122,7 +5122,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5122 | else if (src.Data[index] is LSL_Float) | 5122 | else if (src.Data[index] is LSL_Float) |
5123 | return Convert.ToDouble(((LSL_Float) src.Data[index]).value); | 5123 | return Convert.ToDouble(((LSL_Float) src.Data[index]).value); |
5124 | else if (src.Data[index] is LSL_String) | 5124 | else if (src.Data[index] is LSL_String) |
5125 | return Convert.ToDouble(Regex.Replace(((LSL_String)src.Data[index]).m_string, "[^0-9]", "")); | 5125 | { |
5126 | string str = ((LSL_String) src.Data[index]).m_string; | ||
5127 | Match m = Regex.Match(str, "^\\s*(-?\\+?[,0-9]+\\.?[0-9]*)"); | ||
5128 | if (m != Match.Empty) | ||
5129 | { | ||
5130 | str = m.Value; | ||
5131 | double d = 0.0; | ||
5132 | if (!Double.TryParse(str, out d)) | ||
5133 | return 0.0; | ||
5134 | |||
5135 | return d; | ||
5136 | } | ||
5137 | return 0.0; | ||
5138 | } | ||
5126 | return Convert.ToDouble(src.Data[index]); | 5139 | return Convert.ToDouble(src.Data[index]); |
5127 | } | 5140 | } |
5128 | catch (FormatException) | 5141 | catch (FormatException) |
@@ -7823,55 +7836,98 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7823 | m_host.AddScriptLPS(1); | 7836 | m_host.AddScriptLPS(1); |
7824 | UUID objID = UUID.Zero; | 7837 | UUID objID = UUID.Zero; |
7825 | LSL_List result = new LSL_List(); | 7838 | LSL_List result = new LSL_List(); |
7839 | |||
7840 | // If the ID is not valid, return null result | ||
7826 | if (!UUID.TryParse(obj, out objID)) | 7841 | if (!UUID.TryParse(obj, out objID)) |
7827 | { | 7842 | { |
7828 | result.Add(new LSL_Vector()); | 7843 | result.Add(new LSL_Vector()); |
7829 | result.Add(new LSL_Vector()); | 7844 | result.Add(new LSL_Vector()); |
7830 | return result; | 7845 | return result; |
7831 | } | 7846 | } |
7847 | |||
7848 | // Check if this is an attached prim. If so, replace | ||
7849 | // the UUID with the avatar UUID and report it's bounding box | ||
7850 | SceneObjectPart part = World.GetSceneObjectPart(objID); | ||
7851 | if (part != null && part.ParentGroup.IsAttachment) | ||
7852 | objID = part.ParentGroup.RootPart.AttachedAvatar; | ||
7853 | |||
7854 | // Find out if this is an avatar ID. If so, return it's box | ||
7832 | ScenePresence presence = World.GetScenePresence(objID); | 7855 | ScenePresence presence = World.GetScenePresence(objID); |
7833 | if (presence != null) | 7856 | if (presence != null) |
7834 | { | 7857 | { |
7835 | if (presence.ParentID == 0) // not sat on an object | 7858 | // As per LSL Wiki, there is no difference between sitting |
7859 | // and standing avatar since server 1.36 | ||
7860 | LSL_Vector lower; | ||
7861 | LSL_Vector upper; | ||
7862 | if (presence.Animator.Animations.DefaultAnimation.AnimID | ||
7863 | == AnimationSet.Animations.AnimsUUID["SIT_GROUND_CONSTRAINED"]) | ||
7836 | { | 7864 | { |
7837 | LSL_Vector lower; | 7865 | // This is for ground sitting avatars |
7838 | LSL_Vector upper; | 7866 | float height = presence.Appearance.AvatarHeight / 2.66666667f; |
7839 | if (presence.Animator.Animations.DefaultAnimation.AnimID | 7867 | lower = new LSL_Vector(-0.3375f, -0.45f, height * -1.0f); |
7840 | == AnimationSet.Animations.AnimsUUID["SIT_GROUND_CONSTRAINED"]) | 7868 | upper = new LSL_Vector(0.3375f, 0.45f, 0.0f); |
7841 | { | ||
7842 | // This is for ground sitting avatars | ||
7843 | float height = presence.Appearance.AvatarHeight / 2.66666667f; | ||
7844 | lower = new LSL_Vector(-0.3375f, -0.45f, height * -1.0f); | ||
7845 | upper = new LSL_Vector(0.3375f, 0.45f, 0.0f); | ||
7846 | } | ||
7847 | else | ||
7848 | { | ||
7849 | // This is for standing/flying avatars | ||
7850 | float height = presence.Appearance.AvatarHeight / 2.0f; | ||
7851 | lower = new LSL_Vector(-0.225f, -0.3f, height * -1.0f); | ||
7852 | upper = new LSL_Vector(0.225f, 0.3f, height + 0.05f); | ||
7853 | } | ||
7854 | result.Add(lower); | ||
7855 | result.Add(upper); | ||
7856 | return result; | ||
7857 | } | 7869 | } |
7858 | else | 7870 | else |
7859 | { | 7871 | { |
7860 | // sitting on an object so we need the bounding box of that | 7872 | // This is for standing/flying avatars |
7861 | // which should include the avatar so set the UUID to the | 7873 | float height = presence.Appearance.AvatarHeight / 2.0f; |
7862 | // UUID of the object the avatar is sat on and allow it to fall through | 7874 | lower = new LSL_Vector(-0.225f, -0.3f, height * -1.0f); |
7863 | // to processing an object | 7875 | upper = new LSL_Vector(0.225f, 0.3f, height + 0.05f); |
7864 | SceneObjectPart p = World.GetSceneObjectPart(presence.ParentID); | ||
7865 | objID = p.UUID; | ||
7866 | } | 7876 | } |
7877 | |||
7878 | // Adjust to the documented error offsets (see LSL Wiki) | ||
7879 | lower += new LSL_Vector(0.05f, 0.05f, 0.05f); | ||
7880 | upper -= new LSL_Vector(0.05f, 0.05f, 0.05f); | ||
7881 | |||
7882 | if (lower.x > upper.x) | ||
7883 | lower.x = upper.x; | ||
7884 | if (lower.y > upper.y) | ||
7885 | lower.y = upper.y; | ||
7886 | if (lower.z > upper.z) | ||
7887 | lower.z = upper.z; | ||
7888 | |||
7889 | result.Add(lower); | ||
7890 | result.Add(upper); | ||
7891 | return result; | ||
7867 | } | 7892 | } |
7868 | SceneObjectPart part = World.GetSceneObjectPart(objID); | 7893 | |
7894 | part = World.GetSceneObjectPart(objID); | ||
7869 | // Currently only works for single prims without a sitting avatar | 7895 | // Currently only works for single prims without a sitting avatar |
7870 | if (part != null) | 7896 | if (part != null) |
7871 | { | 7897 | { |
7872 | Vector3 halfSize = part.Scale / 2.0f; | 7898 | float minX; |
7873 | LSL_Vector lower = new LSL_Vector(halfSize.X * -1.0f, halfSize.Y * -1.0f, halfSize.Z * -1.0f); | 7899 | float maxX; |
7874 | LSL_Vector upper = new LSL_Vector(halfSize.X, halfSize.Y, halfSize.Z); | 7900 | float minY; |
7901 | float maxY; | ||
7902 | float minZ; | ||
7903 | float maxZ; | ||
7904 | |||
7905 | // This BBox is in sim coordinates, with the offset being | ||
7906 | // a contained point. | ||
7907 | Vector3[] offsets = World.GetCombinedBoundingBox(new List<SceneObjectGroup> { part.ParentGroup }, | ||
7908 | out minX, out maxX, out minY, out maxY, out minZ, out maxZ); | ||
7909 | |||
7910 | minX -= offsets[0].X; | ||
7911 | maxX -= offsets[0].X; | ||
7912 | minY -= offsets[0].Y; | ||
7913 | maxY -= offsets[0].Y; | ||
7914 | minZ -= offsets[0].Z; | ||
7915 | maxZ -= offsets[0].Z; | ||
7916 | |||
7917 | LSL_Vector lower; | ||
7918 | LSL_Vector upper; | ||
7919 | |||
7920 | // Adjust to the documented error offsets (see LSL Wiki) | ||
7921 | lower = new LSL_Vector(minX + 0.05f, minY + 0.05f, minZ + 0.05f); | ||
7922 | upper = new LSL_Vector(maxX - 0.05f, maxY - 0.05f, maxZ - 0.05f); | ||
7923 | |||
7924 | if (lower.x > upper.x) | ||
7925 | lower.x = upper.x; | ||
7926 | if (lower.y > upper.y) | ||
7927 | lower.y = upper.y; | ||
7928 | if (lower.z > upper.z) | ||
7929 | lower.z = upper.z; | ||
7930 | |||
7875 | result.Add(lower); | 7931 | result.Add(lower); |
7876 | result.Add(upper); | 7932 | result.Add(upper); |
7877 | return result; | 7933 | return result; |