diff options
author | UbitUmarov | 2016-11-07 11:36:43 +0000 |
---|---|---|
committer | UbitUmarov | 2016-11-07 11:36:43 +0000 |
commit | 93ea7bd7f470a7fd80b6400d39091ffb1780fbd9 (patch) | |
tree | f00524dd18c7d865b2a8a755b4ce1284ff005de3 /OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |
parent | Merge branch 'master' into httptests (diff) | |
parent | add a few more lsl constants for attachments (diff) | |
download | opensim-SC-93ea7bd7f470a7fd80b6400d39091ffb1780fbd9.zip opensim-SC-93ea7bd7f470a7fd80b6400d39091ffb1780fbd9.tar.gz opensim-SC-93ea7bd7f470a7fd80b6400d39091ffb1780fbd9.tar.bz2 opensim-SC-93ea7bd7f470a7fd80b6400d39091ffb1780fbd9.tar.xz |
Merge branch 'master' into httptests
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 158 |
1 files changed, 116 insertions, 42 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index ced81ad..1a73c3e 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -113,7 +113,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
113 | protected float m_MinTimerInterval = 0.5f; | 113 | protected float m_MinTimerInterval = 0.5f; |
114 | protected float m_recoilScaleFactor = 0.0f; | 114 | protected float m_recoilScaleFactor = 0.0f; |
115 | 115 | ||
116 | protected DateTime m_timer = DateTime.Now; | 116 | protected double m_timer = Util.GetTimeStampMS(); |
117 | protected bool m_waitingForScriptAnswer = false; | 117 | protected bool m_waitingForScriptAnswer = false; |
118 | protected bool m_automaticLinkPermission = false; | 118 | protected bool m_automaticLinkPermission = false; |
119 | protected IMessageTransferModule m_TransferModule = null; | 119 | protected IMessageTransferModule m_TransferModule = null; |
@@ -662,15 +662,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
662 | List<SceneObjectPart> ret = new List<SceneObjectPart>(); | 662 | List<SceneObjectPart> ret = new List<SceneObjectPart>(); |
663 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | 663 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) |
664 | return ret; | 664 | return ret; |
665 | ret.Add(part); | ||
666 | 665 | ||
667 | switch (linkType) | 666 | switch (linkType) |
668 | { | 667 | { |
669 | case ScriptBaseClass.LINK_SET: | 668 | case ScriptBaseClass.LINK_SET: |
670 | return new List<SceneObjectPart>(part.ParentGroup.Parts); | 669 | return new List<SceneObjectPart>(part.ParentGroup.Parts); |
671 | 670 | ||
672 | case ScriptBaseClass.LINK_ROOT: | 671 | case ScriptBaseClass.LINK_ROOT: |
673 | ret = new List<SceneObjectPart>(); | ||
674 | ret.Add(part.ParentGroup.RootPart); | 672 | ret.Add(part.ParentGroup.RootPart); |
675 | return ret; | 673 | return ret; |
676 | 674 | ||
@@ -690,16 +688,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
690 | return ret; | 688 | return ret; |
691 | 689 | ||
692 | case ScriptBaseClass.LINK_THIS: | 690 | case ScriptBaseClass.LINK_THIS: |
691 | ret.Add(part); | ||
693 | return ret; | 692 | return ret; |
694 | 693 | ||
695 | default: | 694 | default: |
696 | if (linkType < 0) | 695 | if (linkType < 0) |
697 | return new List<SceneObjectPart>(); | 696 | return ret; |
698 | 697 | ||
699 | SceneObjectPart target = part.ParentGroup.GetLinkNumPart(linkType); | 698 | SceneObjectPart target = part.ParentGroup.GetLinkNumPart(linkType); |
700 | if (target == null) | 699 | if (target == null) |
701 | return new List<SceneObjectPart>(); | 700 | return ret; |
702 | ret = new List<SceneObjectPart>(); | ||
703 | ret.Add(target); | 701 | ret.Add(target); |
704 | return ret; | 702 | return ret; |
705 | } | 703 | } |
@@ -3050,22 +3048,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3050 | public LSL_Float llGetTime() | 3048 | public LSL_Float llGetTime() |
3051 | { | 3049 | { |
3052 | m_host.AddScriptLPS(1); | 3050 | m_host.AddScriptLPS(1); |
3053 | TimeSpan ScriptTime = DateTime.Now - m_timer; | 3051 | double ScriptTime = Util.GetTimeStampMS() - m_timer; |
3054 | return (double)(ScriptTime.TotalMilliseconds / 1000); | 3052 | return (ScriptTime / 1000.0); |
3055 | } | 3053 | } |
3056 | 3054 | ||
3057 | public void llResetTime() | 3055 | public void llResetTime() |
3058 | { | 3056 | { |
3059 | m_host.AddScriptLPS(1); | 3057 | m_host.AddScriptLPS(1); |
3060 | m_timer = DateTime.Now; | 3058 | m_timer = Util.GetTimeStampMS(); |
3061 | } | 3059 | } |
3062 | 3060 | ||
3063 | public LSL_Float llGetAndResetTime() | 3061 | public LSL_Float llGetAndResetTime() |
3064 | { | 3062 | { |
3065 | m_host.AddScriptLPS(1); | 3063 | m_host.AddScriptLPS(1); |
3066 | TimeSpan ScriptTime = DateTime.Now - m_timer; | 3064 | double now = Util.GetTimeStampMS(); |
3067 | m_timer = DateTime.Now; | 3065 | double ScriptTime = now - m_timer; |
3068 | return (double)(ScriptTime.TotalMilliseconds / 1000); | 3066 | m_timer = now; |
3067 | return (ScriptTime / 1000.0); | ||
3069 | } | 3068 | } |
3070 | 3069 | ||
3071 | public void llSound(string sound, double volume, int queue, int loop) | 3070 | public void llSound(string sound, double volume, int queue, int loop) |
@@ -10086,6 +10085,53 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10086 | part.UpdateSlice((float)slice.x, (float)slice.y); | 10085 | part.UpdateSlice((float)slice.x, (float)slice.y); |
10087 | break; | 10086 | break; |
10088 | 10087 | ||
10088 | case ScriptBaseClass.PRIM_SIT_TARGET: | ||
10089 | if (remain < 3) | ||
10090 | return new LSL_List(); | ||
10091 | |||
10092 | int active; | ||
10093 | try | ||
10094 | { | ||
10095 | active = rules.GetLSLIntegerItem(idx++); | ||
10096 | } | ||
10097 | catch(InvalidCastException) | ||
10098 | { | ||
10099 | Error(originFunc, string.Format("Error running rule #{0} -> PRIM_SIT_TARGET: arg #{1} - parameter 1 must be integer", rulesParsed, idx - idxStart - 1)); | ||
10100 | return new LSL_List(); | ||
10101 | } | ||
10102 | LSL_Vector offset; | ||
10103 | try | ||
10104 | { | ||
10105 | offset = rules.GetVector3Item(idx++); | ||
10106 | } | ||
10107 | catch(InvalidCastException) | ||
10108 | { | ||
10109 | Error(originFunc, string.Format("Error running rule #{0} -> PRIM_SIT_TARGET: arg #{1} - parameter 2 must be vector", rulesParsed, idx - idxStart - 1)); | ||
10110 | return new LSL_List(); | ||
10111 | } | ||
10112 | LSL_Rotation sitrot; | ||
10113 | try | ||
10114 | { | ||
10115 | sitrot = rules.GetQuaternionItem(idx++); | ||
10116 | } | ||
10117 | catch(InvalidCastException) | ||
10118 | { | ||
10119 | Error(originFunc, string.Format("Error running rule #{0} -> PRIM_SIT_TARGET: arg #{1} - parameter 3 must be rotation", rulesParsed, idx - idxStart - 1)); | ||
10120 | return new LSL_List(); | ||
10121 | } | ||
10122 | |||
10123 | // not SL compatible since we don't have a independent flag to control active target but use the values of offset and rotation | ||
10124 | if(active == 1) | ||
10125 | { | ||
10126 | if(offset.x == 0 && offset.y == 0 && offset.z == 0 && sitrot.s == 1.0) | ||
10127 | offset.z = 1e-5f; // hack | ||
10128 | SitTarget(part,offset,sitrot); | ||
10129 | } | ||
10130 | else if(active == 0) | ||
10131 | SitTarget(part, Vector3.Zero , Quaternion.Identity); | ||
10132 | |||
10133 | break; | ||
10134 | |||
10089 | case ScriptBaseClass.PRIM_LINK_TARGET: | 10135 | case ScriptBaseClass.PRIM_LINK_TARGET: |
10090 | if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless. | 10136 | if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless. |
10091 | return new LSL_List(); | 10137 | return new LSL_List(); |
@@ -11182,7 +11228,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11182 | res.Add(new LSL_Float(spin)); | 11228 | res.Add(new LSL_Float(spin)); |
11183 | res.Add(new LSL_Float(gain)); | 11229 | res.Add(new LSL_Float(gain)); |
11184 | break; | 11230 | break; |
11185 | 11231 | ||
11232 | case (int)ScriptBaseClass.PRIM_SIT_TARGET: | ||
11233 | if(part.IsSitTargetSet) | ||
11234 | { | ||
11235 | res.Add(new LSL_Integer(1)); | ||
11236 | res.Add(new LSL_Vector(part.SitTargetPosition)); | ||
11237 | res.Add(new LSL_Rotation(part.SitTargetOrientation)); | ||
11238 | } | ||
11239 | else | ||
11240 | { | ||
11241 | res.Add(new LSL_Integer(0)); | ||
11242 | res.Add(new LSL_Vector(Vector3.Zero)); | ||
11243 | res.Add(new LSL_Rotation(Quaternion.Identity)); | ||
11244 | } | ||
11245 | break; | ||
11246 | |||
11186 | case (int)ScriptBaseClass.PRIM_LINK_TARGET: | 11247 | case (int)ScriptBaseClass.PRIM_LINK_TARGET: |
11187 | 11248 | ||
11188 | // TODO: Should be issuing a runtime script warning in this case. | 11249 | // TODO: Should be issuing a runtime script warning in this case. |
@@ -14155,18 +14216,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
14155 | return false; | 14216 | return false; |
14156 | } | 14217 | } |
14157 | 14218 | ||
14158 | private ContactResult[] AvatarIntersection(Vector3 rayStart, Vector3 rayEnd) | 14219 | private ContactResult[] AvatarIntersection(Vector3 rayStart, Vector3 rayEnd, bool skipPhys) |
14159 | { | 14220 | { |
14160 | List<ContactResult> contacts = new List<ContactResult>(); | 14221 | List<ContactResult> contacts = new List<ContactResult>(); |
14161 | 14222 | ||
14162 | Vector3 ab = rayEnd - rayStart; | 14223 | Vector3 ab = rayEnd - rayStart; |
14224 | float ablen = ab.Length(); | ||
14163 | 14225 | ||
14164 | World.ForEachScenePresence(delegate(ScenePresence sp) | 14226 | World.ForEachScenePresence(delegate(ScenePresence sp) |
14165 | { | 14227 | { |
14228 | if(skipPhys && sp.PhysicsActor != null) | ||
14229 | return; | ||
14230 | |||
14166 | Vector3 ac = sp.AbsolutePosition - rayStart; | 14231 | Vector3 ac = sp.AbsolutePosition - rayStart; |
14167 | // Vector3 bc = sp.AbsolutePosition - rayEnd; | ||
14168 | 14232 | ||
14169 | 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); |
14170 | 14234 | ||
14171 | if (d > 1.5) | 14235 | if (d > 1.5) |
14172 | return; | 14236 | return; |
@@ -14455,7 +14519,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
14455 | Vector3 rayEnd = end; | 14519 | Vector3 rayEnd = end; |
14456 | Vector3 dir = rayEnd - rayStart; | 14520 | Vector3 dir = rayEnd - rayStart; |
14457 | 14521 | ||
14458 | float dist = Vector3.Mag(dir); | 14522 | float dist = dir.Length(); |
14459 | 14523 | ||
14460 | int count = 1; | 14524 | int count = 1; |
14461 | bool detectPhantom = false; | 14525 | bool detectPhantom = false; |
@@ -14484,7 +14548,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
14484 | bool checkNonPhysical = !((rejectTypes & ScriptBaseClass.RC_REJECT_NONPHYSICAL) == ScriptBaseClass.RC_REJECT_NONPHYSICAL); | 14548 | bool checkNonPhysical = !((rejectTypes & ScriptBaseClass.RC_REJECT_NONPHYSICAL) == ScriptBaseClass.RC_REJECT_NONPHYSICAL); |
14485 | bool checkPhysical = !((rejectTypes & ScriptBaseClass.RC_REJECT_PHYSICAL) == ScriptBaseClass.RC_REJECT_PHYSICAL); | 14549 | bool checkPhysical = !((rejectTypes & ScriptBaseClass.RC_REJECT_PHYSICAL) == ScriptBaseClass.RC_REJECT_PHYSICAL); |
14486 | 14550 | ||
14487 | |||
14488 | if (World.SupportsRayCastFiltered()) | 14551 | if (World.SupportsRayCastFiltered()) |
14489 | { | 14552 | { |
14490 | if (dist == 0) | 14553 | if (dist == 0) |
@@ -14493,8 +14556,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
14493 | RayFilterFlags rayfilter = RayFilterFlags.BackFaceCull; | 14556 | RayFilterFlags rayfilter = RayFilterFlags.BackFaceCull; |
14494 | if (checkTerrain) | 14557 | if (checkTerrain) |
14495 | rayfilter |= RayFilterFlags.land; | 14558 | rayfilter |= RayFilterFlags.land; |
14496 | // if (checkAgents) | 14559 | if (checkAgents) |
14497 | // rayfilter |= RayFilterFlags.agent; | 14560 | rayfilter |= RayFilterFlags.agent; |
14498 | if (checkPhysical) | 14561 | if (checkPhysical) |
14499 | rayfilter |= RayFilterFlags.physical; | 14562 | rayfilter |= RayFilterFlags.physical; |
14500 | if (checkNonPhysical) | 14563 | if (checkNonPhysical) |
@@ -14520,16 +14583,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
14520 | 14583 | ||
14521 | if (physresults == null) | 14584 | if (physresults == null) |
14522 | { | 14585 | { |
14523 | list.Add(new LSL_Integer(-3)); // timeout error | 14586 | // list.Add(new LSL_Integer(-3)); // timeout error |
14524 | return list; | 14587 | // return list; |
14588 | results = new List<ContactResult>(); | ||
14525 | } | 14589 | } |
14526 | 14590 | else | |
14527 | results = (List<ContactResult>)physresults; | 14591 | results = (List<ContactResult>)physresults; |
14528 | 14592 | ||
14529 | // 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 |
14530 | if (checkAgents) | 14594 | if (checkAgents) |
14531 | { | 14595 | { |
14532 | ContactResult[] agentHits = AvatarIntersection(rayStart, rayEnd); | 14596 | ContactResult[] agentHits = AvatarIntersection(rayStart, rayEnd, true); |
14533 | foreach (ContactResult r in agentHits) | 14597 | foreach (ContactResult r in agentHits) |
14534 | results.Add(r); | 14598 | results.Add(r); |
14535 | } | 14599 | } |
@@ -14545,12 +14609,34 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
14545 | foreach (ContactResult r in objectHits) | 14609 | foreach (ContactResult r in objectHits) |
14546 | results.Add(r); | 14610 | results.Add(r); |
14547 | } | 14611 | } |
14612 | // Double check this because of current ODE distance problems | ||
14613 | if (checkTerrain && dist > 60) | ||
14614 | { | ||
14615 | bool skipGroundCheck = false; | ||
14616 | |||
14617 | foreach (ContactResult c in results) | ||
14618 | { | ||
14619 | if (c.ConsumerID == 0) // Physics gave us a ground collision | ||
14620 | skipGroundCheck = true; | ||
14621 | } | ||
14622 | |||
14623 | if (!skipGroundCheck) | ||
14624 | { | ||
14625 | float tmp = dir.X * dir.X + dir.Y * dir.Y; | ||
14626 | if(tmp > 2500) | ||
14627 | { | ||
14628 | ContactResult? groundContact = GroundIntersection(rayStart, rayEnd); | ||
14629 | if (groundContact != null) | ||
14630 | results.Add((ContactResult)groundContact); | ||
14631 | } | ||
14632 | } | ||
14633 | } | ||
14548 | } | 14634 | } |
14549 | else | 14635 | else |
14550 | { | 14636 | { |
14551 | if (checkAgents) | 14637 | if (checkAgents) |
14552 | { | 14638 | { |
14553 | ContactResult[] agentHits = AvatarIntersection(rayStart, rayEnd); | 14639 | ContactResult[] agentHits = AvatarIntersection(rayStart, rayEnd, false); |
14554 | foreach (ContactResult r in agentHits) | 14640 | foreach (ContactResult r in agentHits) |
14555 | results.Add(r); | 14641 | results.Add(r); |
14556 | } | 14642 | } |
@@ -14565,20 +14651,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
14565 | results.Add(objectHits[iter]); | 14651 | results.Add(objectHits[iter]); |
14566 | } | 14652 | } |
14567 | } | 14653 | } |
14568 | } | ||
14569 | 14654 | ||
14570 | // Double check this | 14655 | if (checkTerrain) |
14571 | if (checkTerrain) | ||
14572 | { | ||
14573 | bool skipGroundCheck = false; | ||
14574 | |||
14575 | foreach (ContactResult c in results) | ||
14576 | { | ||
14577 | if (c.ConsumerID == 0) // Physics gave us a ground collision | ||
14578 | skipGroundCheck = true; | ||
14579 | } | ||
14580 | |||
14581 | if (!skipGroundCheck) | ||
14582 | { | 14656 | { |
14583 | ContactResult? groundContact = GroundIntersection(rayStart, rayEnd); | 14657 | ContactResult? groundContact = GroundIntersection(rayStart, rayEnd); |
14584 | if (groundContact != null) | 14658 | if (groundContact != null) |
@@ -14590,7 +14664,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
14590 | { | 14664 | { |
14591 | return a.Depth.CompareTo(b.Depth); | 14665 | return a.Depth.CompareTo(b.Depth); |
14592 | }); | 14666 | }); |
14593 | 14667 | ||
14594 | int values = 0; | 14668 | int values = 0; |
14595 | SceneObjectGroup thisgrp = m_host.ParentGroup; | 14669 | SceneObjectGroup thisgrp = m_host.ParentGroup; |
14596 | 14670 | ||
@@ -14644,7 +14718,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
14644 | } | 14718 | } |
14645 | 14719 | ||
14646 | list.Add(new LSL_Integer(values)); | 14720 | list.Add(new LSL_Integer(values)); |
14647 | |||
14648 | return list; | 14721 | return list; |
14649 | } | 14722 | } |
14650 | 14723 | ||
@@ -15919,6 +15992,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
15919 | case (int)ScriptBaseClass.PRIM_TEXT: | 15992 | case (int)ScriptBaseClass.PRIM_TEXT: |
15920 | case (int)ScriptBaseClass.PRIM_BUMP_SHINY: | 15993 | case (int)ScriptBaseClass.PRIM_BUMP_SHINY: |
15921 | case (int)ScriptBaseClass.PRIM_OMEGA: | 15994 | case (int)ScriptBaseClass.PRIM_OMEGA: |
15995 | case (int)ScriptBaseClass.PRIM_SIT_TARGET: | ||
15922 | if (remain < 3) | 15996 | if (remain < 3) |
15923 | return new LSL_List(); | 15997 | return new LSL_List(); |
15924 | idx += 3; | 15998 | idx += 3; |