diff options
author | Justin Clark-Casey (justincc) | 2010-07-20 21:57:03 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2010-07-20 21:57:03 +0100 |
commit | 79d33418f0950a75d64d2779bf7eeacc97ac3e31 (patch) | |
tree | ce0f3741579e68845cfe46ffed7a7bf4ebfc7225 /OpenSim/Region/ScriptEngine | |
parent | Add region name on the end of script startup debug messages (diff) | |
parent | Relaxed the ultra-conservative lock on m_items. Needs testing under linux and... (diff) | |
download | opensim-SC_OLD-79d33418f0950a75d64d2779bf7eeacc97ac3e31.zip opensim-SC_OLD-79d33418f0950a75d64d2779bf7eeacc97ac3e31.tar.gz opensim-SC_OLD-79d33418f0950a75d64d2779bf7eeacc97ac3e31.tar.bz2 opensim-SC_OLD-79d33418f0950a75d64d2779bf7eeacc97ac3e31.tar.xz |
Merge branch '0.7-post-fixes' of ssh://opensimulator.org/var/git/opensim into 0.7-post-fixes
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 48 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 130 |
2 files changed, 96 insertions, 82 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index c5226ba..f3f7269 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -465,22 +465,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
465 | 465 | ||
466 | //Now we start getting into quaternions which means sin/cos, matrices and vectors. ckrinke | 466 | //Now we start getting into quaternions which means sin/cos, matrices and vectors. ckrinke |
467 | 467 | ||
468 | // Utility function for llRot2Euler | 468 | // Old implementation of llRot2Euler. Normalization not required as Atan2 function will |
469 | 469 | // only return values >= -PI (-180 degrees) and <= PI (180 degrees). | |
470 | // normalize an angle between -PI and PI (-180 to +180 degrees) | ||
471 | protected double NormalizeAngle(double angle) | ||
472 | { | ||
473 | if (angle > -Math.PI && angle < Math.PI) | ||
474 | return angle; | ||
475 | |||
476 | int numPis = (int)(Math.PI / angle); | ||
477 | double remainder = angle - Math.PI * numPis; | ||
478 | if (numPis % 2 == 1) | ||
479 | return Math.PI - angle; | ||
480 | return remainder; | ||
481 | } | ||
482 | |||
483 | // Old implementation of llRot2Euler, now normalized | ||
484 | 470 | ||
485 | public LSL_Vector llRot2Euler(LSL_Rotation r) | 471 | public LSL_Vector llRot2Euler(LSL_Rotation r) |
486 | { | 472 | { |
@@ -492,13 +478,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
492 | double n = 2 * (r.y * r.s + r.x * r.z); | 478 | double n = 2 * (r.y * r.s + r.x * r.z); |
493 | double p = m * m - n * n; | 479 | double p = m * m - n * n; |
494 | if (p > 0) | 480 | if (p > 0) |
495 | return new LSL_Vector(NormalizeAngle(Math.Atan2(2.0 * (r.x * r.s - r.y * r.z), (-t.x - t.y + t.z + t.s))), | 481 | return new LSL_Vector(Math.Atan2(2.0 * (r.x * r.s - r.y * r.z), (-t.x - t.y + t.z + t.s)), |
496 | NormalizeAngle(Math.Atan2(n, Math.Sqrt(p))), | 482 | Math.Atan2(n, Math.Sqrt(p)), |
497 | NormalizeAngle(Math.Atan2(2.0 * (r.z * r.s - r.x * r.y), (t.x - t.y - t.z + t.s)))); | 483 | Math.Atan2(2.0 * (r.z * r.s - r.x * r.y), (t.x - t.y - t.z + t.s))); |
498 | else if (n > 0) | 484 | else if (n > 0) |
499 | return new LSL_Vector(0.0, Math.PI * 0.5, NormalizeAngle(Math.Atan2((r.z * r.s + r.x * r.y), 0.5 - t.x - t.z))); | 485 | return new LSL_Vector(0.0, Math.PI * 0.5, Math.Atan2((r.z * r.s + r.x * r.y), 0.5 - t.x - t.z)); |
500 | else | 486 | else |
501 | return new LSL_Vector(0.0, -Math.PI * 0.5, NormalizeAngle(Math.Atan2((r.z * r.s + r.x * r.y), 0.5 - t.x - t.z))); | 487 | return new LSL_Vector(0.0, -Math.PI * 0.5, Math.Atan2((r.z * r.s + r.x * r.y), 0.5 - t.x - t.z)); |
502 | } | 488 | } |
503 | 489 | ||
504 | /* From wiki: | 490 | /* From wiki: |
@@ -5874,6 +5860,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5874 | PSYS_PART_MAX_AGE = 7, | 5860 | PSYS_PART_MAX_AGE = 7, |
5875 | PSYS_SRC_ACCEL = 8, | 5861 | PSYS_SRC_ACCEL = 8, |
5876 | PSYS_SRC_PATTERN = 9, | 5862 | PSYS_SRC_PATTERN = 9, |
5863 | PSYS_SRC_INNERANGLE = 10, | ||
5864 | PSYS_SRC_OUTERANGLE = 11, | ||
5877 | PSYS_SRC_TEXTURE = 12, | 5865 | PSYS_SRC_TEXTURE = 12, |
5878 | PSYS_SRC_BURST_RATE = 13, | 5866 | PSYS_SRC_BURST_RATE = 13, |
5879 | PSYS_SRC_BURST_PART_COUNT = 15, | 5867 | PSYS_SRC_BURST_PART_COUNT = 15, |
@@ -6006,6 +5994,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6006 | prules.Pattern = (Primitive.ParticleSystem.SourcePattern)tmpi; | 5994 | prules.Pattern = (Primitive.ParticleSystem.SourcePattern)tmpi; |
6007 | break; | 5995 | break; |
6008 | 5996 | ||
5997 | // PSYS_SRC_INNERANGLE and PSYS_SRC_ANGLE_BEGIN use the same variables. The | ||
5998 | // PSYS_SRC_OUTERANGLE and PSYS_SRC_ANGLE_END also use the same variable. The | ||
5999 | // client tells the difference between the two by looking at the 0x02 bit in | ||
6000 | // the PartFlags variable. | ||
6001 | case (int)ScriptBaseClass.PSYS_SRC_INNERANGLE: | ||
6002 | tempf = (float)rules.GetLSLFloatItem(i + 1); | ||
6003 | prules.InnerAngle = (float)tempf; | ||
6004 | prules.PartFlags &= 0xFFFFFFFD; // Make sure new angle format is off. | ||
6005 | break; | ||
6006 | |||
6007 | case (int)ScriptBaseClass.PSYS_SRC_OUTERANGLE: | ||
6008 | tempf = (float)rules.GetLSLFloatItem(i + 1); | ||
6009 | prules.OuterAngle = (float)tempf; | ||
6010 | prules.PartFlags &= 0xFFFFFFFD; // Make sure new angle format is off. | ||
6011 | break; | ||
6012 | |||
6009 | case (int)ScriptBaseClass.PSYS_SRC_TEXTURE: | 6013 | case (int)ScriptBaseClass.PSYS_SRC_TEXTURE: |
6010 | prules.Texture = KeyOrName(rules.GetLSLStringItem(i + 1)); | 6014 | prules.Texture = KeyOrName(rules.GetLSLStringItem(i + 1)); |
6011 | break; | 6015 | break; |
@@ -6062,11 +6066,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6062 | case (int)ScriptBaseClass.PSYS_SRC_ANGLE_BEGIN: | 6066 | case (int)ScriptBaseClass.PSYS_SRC_ANGLE_BEGIN: |
6063 | tempf = (float)rules.GetLSLFloatItem(i + 1); | 6067 | tempf = (float)rules.GetLSLFloatItem(i + 1); |
6064 | prules.InnerAngle = (float)tempf; | 6068 | prules.InnerAngle = (float)tempf; |
6069 | prules.PartFlags |= 0x02; // Set new angle format. | ||
6065 | break; | 6070 | break; |
6066 | 6071 | ||
6067 | case (int)ScriptBaseClass.PSYS_SRC_ANGLE_END: | 6072 | case (int)ScriptBaseClass.PSYS_SRC_ANGLE_END: |
6068 | tempf = (float)rules.GetLSLFloatItem(i + 1); | 6073 | tempf = (float)rules.GetLSLFloatItem(i + 1); |
6069 | prules.OuterAngle = (float)tempf; | 6074 | prules.OuterAngle = (float)tempf; |
6075 | prules.PartFlags |= 0x02; // Set new angle format. | ||
6070 | break; | 6076 | break; |
6071 | } | 6077 | } |
6072 | 6078 | ||
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index bc5df11..cc9e58c 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | |||
@@ -701,9 +701,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
701 | } | 701 | } |
702 | } | 702 | } |
703 | 703 | ||
704 | ScriptInstance instance = null; | ||
704 | lock (m_Scripts) | 705 | lock (m_Scripts) |
705 | { | 706 | { |
706 | ScriptInstance instance = null; | ||
707 | // Create the object record | 707 | // Create the object record |
708 | 708 | ||
709 | if ((!m_Scripts.ContainsKey(itemID)) || | 709 | if ((!m_Scripts.ContainsKey(itemID)) || |
@@ -786,28 +786,29 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
786 | 786 | ||
787 | m_Scripts[itemID] = instance; | 787 | m_Scripts[itemID] = instance; |
788 | } | 788 | } |
789 | } | ||
789 | 790 | ||
790 | lock (m_PrimObjects) | 791 | lock (m_PrimObjects) |
791 | { | 792 | { |
792 | if (!m_PrimObjects.ContainsKey(localID)) | 793 | if (!m_PrimObjects.ContainsKey(localID)) |
793 | m_PrimObjects[localID] = new List<UUID>(); | 794 | m_PrimObjects[localID] = new List<UUID>(); |
794 | |||
795 | if (!m_PrimObjects[localID].Contains(itemID)) | ||
796 | m_PrimObjects[localID].Add(itemID); | ||
797 | 795 | ||
798 | } | 796 | if (!m_PrimObjects[localID].Contains(itemID)) |
797 | m_PrimObjects[localID].Add(itemID); | ||
799 | 798 | ||
800 | if (!m_Assemblies.ContainsKey(assetID)) | 799 | } |
801 | m_Assemblies[assetID] = assembly; | ||
802 | 800 | ||
803 | lock (m_AddingAssemblies) | 801 | if (!m_Assemblies.ContainsKey(assetID)) |
804 | { | 802 | m_Assemblies[assetID] = assembly; |
805 | m_AddingAssemblies[assembly]--; | ||
806 | } | ||
807 | 803 | ||
808 | if (instance!=null) | 804 | lock (m_AddingAssemblies) |
809 | instance.Init(); | 805 | { |
806 | m_AddingAssemblies[assembly]--; | ||
810 | } | 807 | } |
808 | |||
809 | if (instance != null) | ||
810 | instance.Init(); | ||
811 | |||
811 | return true; | 812 | return true; |
812 | } | 813 | } |
813 | 814 | ||
@@ -820,60 +821,60 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
820 | m_CompileDict.Remove(itemID); | 821 | m_CompileDict.Remove(itemID); |
821 | } | 822 | } |
822 | 823 | ||
824 | IScriptInstance instance = null; | ||
825 | |||
823 | lock (m_Scripts) | 826 | lock (m_Scripts) |
824 | { | 827 | { |
825 | // Do we even have it? | 828 | // Do we even have it? |
826 | if (!m_Scripts.ContainsKey(itemID)) | 829 | if (!m_Scripts.ContainsKey(itemID)) |
827 | return; | 830 | return; |
828 | 831 | ||
829 | IScriptInstance instance=m_Scripts[itemID]; | 832 | instance=m_Scripts[itemID]; |
830 | m_Scripts.Remove(itemID); | 833 | m_Scripts.Remove(itemID); |
834 | } | ||
831 | 835 | ||
832 | instance.ClearQueue(); | 836 | instance.ClearQueue(); |
833 | instance.Stop(0); | 837 | instance.Stop(0); |
834 | |||
835 | // bool objectRemoved = false; | 838 | // bool objectRemoved = false; |
836 | 839 | ||
837 | lock (m_PrimObjects) | 840 | lock (m_PrimObjects) |
841 | { | ||
842 | // Remove the script from it's prim | ||
843 | if (m_PrimObjects.ContainsKey(localID)) | ||
838 | { | 844 | { |
839 | // Remove the script from it's prim | 845 | // Remove inventory item record |
840 | if (m_PrimObjects.ContainsKey(localID)) | 846 | if (m_PrimObjects[localID].Contains(itemID)) |
841 | { | 847 | m_PrimObjects[localID].Remove(itemID); |
842 | // Remove inventory item record | ||
843 | if (m_PrimObjects[localID].Contains(itemID)) | ||
844 | m_PrimObjects[localID].Remove(itemID); | ||
845 | 848 | ||
846 | // If there are no more scripts, remove prim | 849 | // If there are no more scripts, remove prim |
847 | if (m_PrimObjects[localID].Count == 0) | 850 | if (m_PrimObjects[localID].Count == 0) |
848 | { | 851 | { |
849 | m_PrimObjects.Remove(localID); | 852 | m_PrimObjects.Remove(localID); |
850 | // objectRemoved = true; | 853 | // objectRemoved = true; |
851 | } | ||
852 | } | 854 | } |
853 | } | 855 | } |
856 | } | ||
854 | 857 | ||
855 | instance.RemoveState(); | 858 | instance.RemoveState(); |
856 | instance.DestroyScriptInstance(); | 859 | instance.DestroyScriptInstance(); |
857 | |||
858 | m_DomainScripts[instance.AppDomain].Remove(instance.ItemID); | ||
859 | if (m_DomainScripts[instance.AppDomain].Count == 0) | ||
860 | { | ||
861 | m_DomainScripts.Remove(instance.AppDomain); | ||
862 | UnloadAppDomain(instance.AppDomain); | ||
863 | } | ||
864 | 860 | ||
865 | instance = null; | 861 | m_DomainScripts[instance.AppDomain].Remove(instance.ItemID); |
862 | if (m_DomainScripts[instance.AppDomain].Count == 0) | ||
863 | { | ||
864 | m_DomainScripts.Remove(instance.AppDomain); | ||
865 | UnloadAppDomain(instance.AppDomain); | ||
866 | } | ||
866 | 867 | ||
867 | ObjectRemoved handlerObjectRemoved = OnObjectRemoved; | 868 | instance = null; |
868 | if (handlerObjectRemoved != null) | ||
869 | { | ||
870 | SceneObjectPart part = m_Scene.GetSceneObjectPart(localID); | ||
871 | handlerObjectRemoved(part.UUID); | ||
872 | } | ||
873 | 869 | ||
874 | CleanAssemblies(); | 870 | ObjectRemoved handlerObjectRemoved = OnObjectRemoved; |
871 | if (handlerObjectRemoved != null) | ||
872 | { | ||
873 | SceneObjectPart part = m_Scene.GetSceneObjectPart(localID); | ||
874 | handlerObjectRemoved(part.UUID); | ||
875 | } | 875 | } |
876 | 876 | ||
877 | |||
877 | ScriptRemoved handlerScriptRemoved = OnScriptRemoved; | 878 | ScriptRemoved handlerScriptRemoved = OnScriptRemoved; |
878 | if (handlerScriptRemoved != null) | 879 | if (handlerScriptRemoved != null) |
879 | handlerScriptRemoved(itemID); | 880 | handlerScriptRemoved(itemID); |
@@ -1007,26 +1008,33 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1007 | public bool PostObjectEvent(uint localID, EventParams p) | 1008 | public bool PostObjectEvent(uint localID, EventParams p) |
1008 | { | 1009 | { |
1009 | bool result = false; | 1010 | bool result = false; |
1010 | 1011 | List<UUID> uuids = null; | |
1012 | |||
1011 | lock (m_PrimObjects) | 1013 | lock (m_PrimObjects) |
1012 | { | 1014 | { |
1013 | if (!m_PrimObjects.ContainsKey(localID)) | 1015 | if (!m_PrimObjects.ContainsKey(localID)) |
1014 | return false; | 1016 | return false; |
1015 | 1017 | ||
1016 | 1018 | uuids = m_PrimObjects[localID]; | |
1017 | foreach (UUID itemID in m_PrimObjects[localID]) | 1019 | } |
1020 | |||
1021 | foreach (UUID itemID in uuids) | ||
1022 | { | ||
1023 | IScriptInstance instance = null; | ||
1024 | try | ||
1018 | { | 1025 | { |
1019 | if (m_Scripts.ContainsKey(itemID)) | 1026 | if (m_Scripts.ContainsKey(itemID)) |
1020 | { | 1027 | instance = m_Scripts[itemID]; |
1021 | IScriptInstance instance = m_Scripts[itemID]; | 1028 | } |
1022 | if (instance != null) | 1029 | catch { /* ignore race conditions */ } |
1023 | { | 1030 | |
1024 | instance.PostEvent(p); | 1031 | if (instance != null) |
1025 | result = true; | 1032 | { |
1026 | } | 1033 | instance.PostEvent(p); |
1027 | } | 1034 | result = true; |
1028 | } | 1035 | } |
1029 | } | 1036 | } |
1037 | |||
1030 | return result; | 1038 | return result; |
1031 | } | 1039 | } |
1032 | 1040 | ||