aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment')
-rw-r--r--OpenSim/Region/Environment/Scenes/EventManager.cs38
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectPart.cs186
2 files changed, 211 insertions, 13 deletions
diff --git a/OpenSim/Region/Environment/Scenes/EventManager.cs b/OpenSim/Region/Environment/Scenes/EventManager.cs
index eee4e4a..5c750e4 100644
--- a/OpenSim/Region/Environment/Scenes/EventManager.cs
+++ b/OpenSim/Region/Environment/Scenes/EventManager.cs
@@ -158,9 +158,17 @@ namespace OpenSim.Region.Environment.Scenes
158 public event ScriptAtTargetEvent OnScriptAtTargetEvent; 158 public event ScriptAtTargetEvent OnScriptAtTargetEvent;
159 159
160 public delegate void ScriptNotAtTargetEvent(uint localID); 160 public delegate void ScriptNotAtTargetEvent(uint localID);
161 161
162 public event ScriptNotAtTargetEvent OnScriptNotAtTargetEvent; 162 public event ScriptNotAtTargetEvent OnScriptNotAtTargetEvent;
163 163
164 public delegate void ScriptColliding(uint localID, ColliderArgs colliders);
165
166 public event ScriptColliding OnScriptColliderStart;
167 public event ScriptColliding OnScriptColliding;
168 public event ScriptColliding OnScriptCollidingEnd;
169
170
171
164 public delegate void OnMakeChildAgentDelegate(ScenePresence presence); 172 public delegate void OnMakeChildAgentDelegate(ScenePresence presence);
165 public event OnMakeChildAgentDelegate OnMakeChildAgent; 173 public event OnMakeChildAgentDelegate OnMakeChildAgent;
166 174
@@ -293,6 +301,8 @@ namespace OpenSim.Region.Environment.Scenes
293 } 301 }
294 } 302 }
295 303
304
305
296 public delegate void MoneyTransferEvent(Object sender, MoneyTransferArgs e); 306 public delegate void MoneyTransferEvent(Object sender, MoneyTransferArgs e);
297 307
298 public delegate void LandBuy(Object sender, LandBuyArgs e); 308 public delegate void LandBuy(Object sender, LandBuyArgs e);
@@ -357,6 +367,11 @@ namespace OpenSim.Region.Environment.Scenes
357 private ScriptTimerEvent handlerScriptTimerEvent = null; 367 private ScriptTimerEvent handlerScriptTimerEvent = null;
358 private EstateToolsTimeUpdate handlerEstateToolsTimeUpdate = null; 368 private EstateToolsTimeUpdate handlerEstateToolsTimeUpdate = null;
359 369
370 private ScriptColliding handlerCollidingStart = null;
371 private ScriptColliding handlerColliding = null;
372 private ScriptColliding handlerCollidingEnd = null;
373
374
360 private SunLindenHour handlerSunGetLindenHour = null; 375 private SunLindenHour handlerSunGetLindenHour = null;
361 376
362 public void TriggerOnScriptChangedEvent(uint localID, uint change) 377 public void TriggerOnScriptChangedEvent(uint localID, uint change)
@@ -838,5 +853,26 @@ namespace OpenSim.Region.Environment.Scenes
838 } 853 }
839 return 6; 854 return 6;
840 } 855 }
856
857 public void TriggerScriptCollidingStart(uint localId, ColliderArgs colliders)
858 {
859 handlerCollidingStart = OnScriptColliderStart;
860 if (handlerCollidingStart != null)
861 handlerCollidingStart(localId, colliders);
862 }
863 public void TriggerScriptColliding(uint localId, ColliderArgs colliders)
864 {
865
866 handlerColliding = OnScriptColliding;
867 if (handlerColliding != null)
868 handlerColliding(localId, colliders);
869 }
870 public void TriggerScriptCollidingEnd(uint localId, ColliderArgs colliders)
871 {
872 handlerCollidingEnd = OnScriptCollidingEnd;
873 if (handlerCollidingEnd != null)
874 handlerCollidingEnd(localId, colliders);
875 }
876
841 } 877 }
842} 878}
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
index ce7497d..532d003 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
@@ -113,6 +113,8 @@ namespace OpenSim.Region.Environment.Scenes
113 public Int32 CreationDate; 113 public Int32 CreationDate;
114 public uint ParentID = 0; 114 public uint ParentID = 0;
115 115
116 private List<uint> m_lastColliders = new List<uint>();
117
116 private PhysicsVector m_lastRotationalVelocity = PhysicsVector.Zero; 118 private PhysicsVector m_lastRotationalVelocity = PhysicsVector.Zero;
117 private Vector3 m_sitTargetPosition = new Vector3(0, 0, 0); 119 private Vector3 m_sitTargetPosition = new Vector3(0, 0, 0);
118 private Quaternion m_sitTargetOrientation = new Quaternion(0, 0, 0, 1); 120 private Quaternion m_sitTargetOrientation = new Quaternion(0, 0, 0, 1);
@@ -2807,21 +2809,181 @@ namespace OpenSim.Region.Environment.Scenes
2807 } 2809 }
2808 public void PhysicsCollision(EventArgs e) 2810 public void PhysicsCollision(EventArgs e)
2809 { 2811 {
2810 return; 2812 //return;
2811 2813
2812 // 2814 // single threaded here
2813 //if (e == null) 2815 if (e == null)
2814 //{ 2816 {
2815 // return; 2817 return;
2816 //} 2818 }
2817 //CollisionEventUpdate a = (CollisionEventUpdate)e; 2819
2818 //Dictionary<uint, float> collissionswith = a.m_objCollisionList; 2820 CollisionEventUpdate a = (CollisionEventUpdate)e;
2819 //foreach (uint localid in collissionswith.Keys) 2821 Dictionary<uint, float> collissionswith = a.m_objCollisionList;
2820 //{ 2822 List<uint> thisHitColliders = new List<uint>();
2821 // m_log.Debug("[OBJECT]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); 2823 List<uint> endedColliders = new List<uint>();
2822 //} 2824 List<uint> startedColliders = new List<uint>();
2825
2826 // calculate things that started colliding this time
2827 // and build up list of colliders this time
2828 foreach (uint localid in collissionswith.Keys)
2829 {
2830 if (localid != 0)
2831 {
2832 thisHitColliders.Add(localid);
2833 if (!m_lastColliders.Contains(localid))
2834 {
2835 startedColliders.Add(localid);
2836 }
2837
2838
2839 //m_log.Debug("[OBJECT]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString());
2840 }
2841 }
2842
2843 // calculate things that ended colliding
2844 foreach (uint localID in m_lastColliders)
2845 {
2846 if (!thisHitColliders.Contains(localID))
2847 {
2848 endedColliders.Add(localID);
2849 }
2850 }
2851 // remove things that ended colliding from the last colliders list
2852 foreach (uint localID in endedColliders)
2853 {
2854 m_lastColliders.Remove(localID);
2855 }
2856
2857 //add the items that started colliding this time to the last colliders list.
2858 foreach (uint localID in startedColliders)
2859 {
2860 m_lastColliders.Add(localID);
2861 }
2862 // do event notification
2863 if (startedColliders.Count > 0)
2864 {
2865 ColliderArgs StartCollidingMessage = new ColliderArgs();
2866 List<DetectedObject> colliding = new List<DetectedObject>();
2867 foreach (uint localId in startedColliders)
2868 {
2869 // always running this check because if the user deletes the object it would return a null reference.
2870 if (m_parentGroup == null)
2871 return;
2872 if (m_parentGroup.Scene == null)
2873 return;
2874 SceneObjectPart obj = m_parentGroup.Scene.GetSceneObjectPart(localId);
2875 if (obj != null)
2876 {
2877 DetectedObject detobj = new DetectedObject();
2878 detobj.keyUUID = obj.UUID;
2879 detobj.nameStr = obj.Name;
2880 detobj.ownerUUID = obj.OwnerID;
2881 detobj.posVector = obj.AbsolutePosition;
2882 detobj.rotQuat = obj.GetWorldRotation();
2883 detobj.velVector = obj.Velocity;
2884 detobj.colliderType = 0;
2885 detobj.groupUUID = obj.GroupID;
2886 colliding.Add(detobj);
2887 }
2888 }
2889 if (colliding.Count > 0)
2890 {
2891 StartCollidingMessage.Colliders = colliding;
2892 // always running this check because if the user deletes the object it would return a null reference.
2893 if (m_parentGroup == null)
2894 return;
2895 if (m_parentGroup.Scene == null)
2896 return;
2897 m_parentGroup.Scene.EventManager.TriggerScriptCollidingStart(LocalId, StartCollidingMessage);
2898 }
2899
2900 }
2901 if (m_lastColliders.Count > 0)
2902 {
2903 ColliderArgs CollidingMessage = new ColliderArgs();
2904 List<DetectedObject> colliding = new List<DetectedObject>();
2905 foreach (uint localId in m_lastColliders)
2906 {
2907 // always running this check because if the user deletes the object it would return a null reference.
2908 if (localId == 0)
2909 continue;
2910
2911 if (m_parentGroup == null)
2912 return;
2913 if (m_parentGroup.Scene == null)
2914 return;
2915 SceneObjectPart obj = m_parentGroup.Scene.GetSceneObjectPart(localId);
2916 if (obj != null)
2917 {
2918 DetectedObject detobj = new DetectedObject();
2919 detobj.keyUUID = obj.UUID;
2920 detobj.nameStr = obj.Name;
2921 detobj.ownerUUID = obj.OwnerID;
2922 detobj.posVector = obj.AbsolutePosition;
2923 detobj.rotQuat = obj.GetWorldRotation();
2924 detobj.velVector = obj.Velocity;
2925 detobj.colliderType = 0;
2926 detobj.groupUUID = obj.GroupID;
2927 colliding.Add(detobj);
2928 }
2929 }
2930 if (colliding.Count > 0)
2931 {
2932 CollidingMessage.Colliders = colliding;
2933 // always running this check because if the user deletes the object it would return a null reference.
2934 if (m_parentGroup == null)
2935 return;
2936 if (m_parentGroup.Scene == null)
2937 return;
2938 m_parentGroup.Scene.EventManager.TriggerScriptCollidingStart(LocalId, CollidingMessage);
2939 }
2940
2941 }
2942 if (endedColliders.Count > 0)
2943 {
2944 ColliderArgs EndCollidingMessage = new ColliderArgs();
2945 List<DetectedObject> colliding = new List<DetectedObject>();
2946 foreach (uint localId in endedColliders)
2947 {
2948 if (localId == 0)
2949 continue;
2950
2951 // always running this check because if the user deletes the object it would return a null reference.
2952 if (m_parentGroup == null)
2953 return;
2954 if (m_parentGroup.Scene == null)
2955 return;
2956 SceneObjectPart obj = m_parentGroup.Scene.GetSceneObjectPart(localId);
2957 if (obj != null)
2958 {
2959 DetectedObject detobj = new DetectedObject();
2960 detobj.keyUUID = obj.UUID;
2961 detobj.nameStr = obj.Name;
2962 detobj.ownerUUID = obj.OwnerID;
2963 detobj.posVector = obj.AbsolutePosition;
2964 detobj.rotQuat = obj.GetWorldRotation();
2965 detobj.velVector = obj.Velocity;
2966 detobj.colliderType = 0;
2967 detobj.groupUUID = obj.GroupID;
2968 colliding.Add(detobj);
2969 }
2970 }
2971 if (colliding.Count > 0)
2972 {
2973 EndCollidingMessage.Colliders = colliding;
2974 // always running this check because if the user deletes the object it would return a null reference.
2975 if (m_parentGroup == null)
2976 return;
2977 if (m_parentGroup.Scene == null)
2978 return;
2979 m_parentGroup.Scene.EventManager.TriggerScriptCollidingStart(LocalId, EndCollidingMessage);
2980 }
2981
2982 }
2823 } 2983 }
2824 2984
2985
2986
2825 public void SetDieAtEdge(bool p) 2987 public void SetDieAtEdge(bool p)
2826 { 2988 {
2827 if (m_parentGroup == null) 2989 if (m_parentGroup == null)