diff options
Diffstat (limited to 'OpenSim/Region/Environment/Scenes')
-rw-r--r-- | OpenSim/Region/Environment/Scenes/SceneObjectPart.cs | 299 |
1 files changed, 193 insertions, 106 deletions
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs index 2a9ad0a..614726e 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs | |||
@@ -2860,137 +2860,224 @@ namespace OpenSim.Region.Environment.Scenes | |||
2860 | endedColliders.Add(localID); | 2860 | endedColliders.Add(localID); |
2861 | } | 2861 | } |
2862 | } | 2862 | } |
2863 | // remove things that ended colliding from the last colliders list | 2863 | |
2864 | foreach (uint localID in endedColliders) | ||
2865 | { | ||
2866 | m_lastColliders.Remove(localID); | ||
2867 | } | ||
2868 | 2864 | ||
2869 | //add the items that started colliding this time to the last colliders list. | 2865 | //add the items that started colliding this time to the last colliders list. |
2870 | foreach (uint localID in startedColliders) | 2866 | foreach (uint localID in startedColliders) |
2871 | { | 2867 | { |
2872 | m_lastColliders.Add(localID); | 2868 | m_lastColliders.Add(localID); |
2873 | } | 2869 | } |
2874 | // do event notification | 2870 | // remove things that ended colliding from the last colliders list |
2875 | if (startedColliders.Count > 0) | 2871 | foreach (uint localID in endedColliders) |
2876 | { | 2872 | { |
2877 | ColliderArgs StartCollidingMessage = new ColliderArgs(); | 2873 | m_lastColliders.Remove(localID); |
2878 | List<DetectedObject> colliding = new List<DetectedObject>(); | 2874 | } |
2879 | foreach (uint localId in startedColliders) | 2875 | if (m_parentGroup == null) |
2876 | return; | ||
2877 | if (m_parentGroup.RootPart == null) | ||
2878 | return; | ||
2879 | |||
2880 | if ((m_parentGroup.RootPart.ScriptEvents & scriptEvents.collision_start) != 0) | ||
2881 | { | ||
2882 | // do event notification | ||
2883 | if (startedColliders.Count > 0) | ||
2880 | { | 2884 | { |
2881 | // always running this check because if the user deletes the object it would return a null reference. | 2885 | ColliderArgs StartCollidingMessage = new ColliderArgs(); |
2882 | if (m_parentGroup == null) | 2886 | List<DetectedObject> colliding = new List<DetectedObject>(); |
2883 | return; | 2887 | foreach (uint localId in startedColliders) |
2884 | if (m_parentGroup.Scene == null) | ||
2885 | return; | ||
2886 | SceneObjectPart obj = m_parentGroup.Scene.GetSceneObjectPart(localId); | ||
2887 | if (obj != null) | ||
2888 | { | 2888 | { |
2889 | DetectedObject detobj = new DetectedObject(); | 2889 | // always running this check because if the user deletes the object it would return a null reference. |
2890 | detobj.keyUUID = obj.UUID; | 2890 | if (m_parentGroup == null) |
2891 | detobj.nameStr = obj.Name; | 2891 | return; |
2892 | detobj.ownerUUID = obj.OwnerID; | 2892 | if (m_parentGroup.Scene == null) |
2893 | detobj.posVector = obj.AbsolutePosition; | 2893 | return; |
2894 | detobj.rotQuat = obj.GetWorldRotation(); | 2894 | SceneObjectPart obj = m_parentGroup.Scene.GetSceneObjectPart(localId); |
2895 | detobj.velVector = obj.Velocity; | 2895 | if (obj != null) |
2896 | detobj.colliderType = 0; | 2896 | { |
2897 | detobj.groupUUID = obj.GroupID; | 2897 | DetectedObject detobj = new DetectedObject(); |
2898 | colliding.Add(detobj); | 2898 | detobj.keyUUID = obj.UUID; |
2899 | detobj.nameStr = obj.Name; | ||
2900 | detobj.ownerUUID = obj.OwnerID; | ||
2901 | detobj.posVector = obj.AbsolutePosition; | ||
2902 | detobj.rotQuat = obj.GetWorldRotation(); | ||
2903 | detobj.velVector = obj.Velocity; | ||
2904 | detobj.colliderType = 0; | ||
2905 | detobj.groupUUID = obj.GroupID; | ||
2906 | colliding.Add(detobj); | ||
2907 | } | ||
2908 | else | ||
2909 | { | ||
2910 | List<ScenePresence> avlist = m_parentGroup.Scene.GetScenePresences(); | ||
2911 | if (avlist != null) | ||
2912 | { | ||
2913 | foreach (ScenePresence av in avlist) | ||
2914 | { | ||
2915 | if (av.LocalId == localId) | ||
2916 | { | ||
2917 | DetectedObject detobj = new DetectedObject(); | ||
2918 | detobj.keyUUID = av.UUID; | ||
2919 | detobj.nameStr = av.ControllingClient.Name; | ||
2920 | detobj.ownerUUID = av.UUID; | ||
2921 | detobj.posVector = av.AbsolutePosition; | ||
2922 | detobj.rotQuat = new LLQuaternion(av.Rotation.x, av.Rotation.y, av.Rotation.z, av.Rotation.w); | ||
2923 | detobj.velVector = av.Velocity; | ||
2924 | detobj.colliderType = 0; | ||
2925 | detobj.groupUUID = av.ControllingClient.ActiveGroupId; | ||
2926 | colliding.Add(detobj); | ||
2927 | } | ||
2928 | } | ||
2929 | |||
2930 | } | ||
2931 | } | ||
2932 | } | ||
2933 | if (colliding.Count > 0) | ||
2934 | { | ||
2935 | StartCollidingMessage.Colliders = colliding; | ||
2936 | // always running this check because if the user deletes the object it would return a null reference. | ||
2937 | if (m_parentGroup == null) | ||
2938 | return; | ||
2939 | if (m_parentGroup.Scene == null) | ||
2940 | return; | ||
2941 | m_parentGroup.Scene.EventManager.TriggerScriptCollidingStart(LocalId, StartCollidingMessage); | ||
2899 | } | 2942 | } |
2900 | } | ||
2901 | if (colliding.Count > 0) | ||
2902 | { | ||
2903 | StartCollidingMessage.Colliders = colliding; | ||
2904 | // always running this check because if the user deletes the object it would return a null reference. | ||
2905 | if (m_parentGroup == null) | ||
2906 | return; | ||
2907 | if (m_parentGroup.Scene == null) | ||
2908 | return; | ||
2909 | m_parentGroup.Scene.EventManager.TriggerScriptCollidingStart(LocalId, StartCollidingMessage); | ||
2910 | } | ||
2911 | 2943 | ||
2944 | } | ||
2912 | } | 2945 | } |
2913 | if (m_lastColliders.Count > 0) | 2946 | if ((m_parentGroup.RootPart.ScriptEvents & scriptEvents.collision) != 0) |
2914 | { | 2947 | { |
2915 | ColliderArgs CollidingMessage = new ColliderArgs(); | 2948 | if (m_lastColliders.Count > 0) |
2916 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
2917 | foreach (uint localId in m_lastColliders) | ||
2918 | { | 2949 | { |
2919 | // always running this check because if the user deletes the object it would return a null reference. | 2950 | ColliderArgs CollidingMessage = new ColliderArgs(); |
2920 | if (localId == 0) | 2951 | List<DetectedObject> colliding = new List<DetectedObject>(); |
2921 | continue; | 2952 | foreach (uint localId in m_lastColliders) |
2953 | { | ||
2954 | // always running this check because if the user deletes the object it would return a null reference. | ||
2955 | if (localId == 0) | ||
2956 | continue; | ||
2957 | |||
2958 | if (m_parentGroup == null) | ||
2959 | return; | ||
2960 | if (m_parentGroup.Scene == null) | ||
2961 | return; | ||
2962 | SceneObjectPart obj = m_parentGroup.Scene.GetSceneObjectPart(localId); | ||
2963 | if (obj != null) | ||
2964 | { | ||
2965 | DetectedObject detobj = new DetectedObject(); | ||
2966 | detobj.keyUUID = obj.UUID; | ||
2967 | detobj.nameStr = obj.Name; | ||
2968 | detobj.ownerUUID = obj.OwnerID; | ||
2969 | detobj.posVector = obj.AbsolutePosition; | ||
2970 | detobj.rotQuat = obj.GetWorldRotation(); | ||
2971 | detobj.velVector = obj.Velocity; | ||
2972 | detobj.colliderType = 0; | ||
2973 | detobj.groupUUID = obj.GroupID; | ||
2974 | colliding.Add(detobj); | ||
2975 | } | ||
2976 | else | ||
2977 | { | ||
2978 | List<ScenePresence> avlist = m_parentGroup.Scene.GetScenePresences(); | ||
2979 | if (avlist != null) | ||
2980 | { | ||
2981 | foreach (ScenePresence av in avlist) | ||
2982 | { | ||
2983 | if (av.LocalId == localId) | ||
2984 | { | ||
2985 | DetectedObject detobj = new DetectedObject(); | ||
2986 | detobj.keyUUID = av.UUID; | ||
2987 | detobj.nameStr = av.Name; | ||
2988 | detobj.ownerUUID = av.UUID; | ||
2989 | detobj.posVector = av.AbsolutePosition; | ||
2990 | detobj.rotQuat = new LLQuaternion(av.Rotation.x, av.Rotation.y, av.Rotation.z, av.Rotation.w); | ||
2991 | detobj.velVector = av.Velocity; | ||
2992 | detobj.colliderType = 0; | ||
2993 | detobj.groupUUID = av.ControllingClient.ActiveGroupId; | ||
2994 | colliding.Add(detobj); | ||
2995 | } | ||
2996 | } | ||
2922 | 2997 | ||
2923 | if (m_parentGroup == null) | 2998 | } |
2924 | return; | 2999 | } |
2925 | if (m_parentGroup.Scene == null) | 3000 | } |
2926 | return; | 3001 | if (colliding.Count > 0) |
2927 | SceneObjectPart obj = m_parentGroup.Scene.GetSceneObjectPart(localId); | ||
2928 | if (obj != null) | ||
2929 | { | 3002 | { |
2930 | DetectedObject detobj = new DetectedObject(); | 3003 | CollidingMessage.Colliders = colliding; |
2931 | detobj.keyUUID = obj.UUID; | 3004 | // always running this check because if the user deletes the object it would return a null reference. |
2932 | detobj.nameStr = obj.Name; | 3005 | if (m_parentGroup == null) |
2933 | detobj.ownerUUID = obj.OwnerID; | 3006 | return; |
2934 | detobj.posVector = obj.AbsolutePosition; | 3007 | if (m_parentGroup.Scene == null) |
2935 | detobj.rotQuat = obj.GetWorldRotation(); | 3008 | return; |
2936 | detobj.velVector = obj.Velocity; | 3009 | m_parentGroup.Scene.EventManager.TriggerScriptColliding(LocalId, CollidingMessage); |
2937 | detobj.colliderType = 0; | ||
2938 | detobj.groupUUID = obj.GroupID; | ||
2939 | colliding.Add(detobj); | ||
2940 | } | 3010 | } |
2941 | } | ||
2942 | if (colliding.Count > 0) | ||
2943 | { | ||
2944 | CollidingMessage.Colliders = colliding; | ||
2945 | // always running this check because if the user deletes the object it would return a null reference. | ||
2946 | if (m_parentGroup == null) | ||
2947 | return; | ||
2948 | if (m_parentGroup.Scene == null) | ||
2949 | return; | ||
2950 | m_parentGroup.Scene.EventManager.TriggerScriptCollidingStart(LocalId, CollidingMessage); | ||
2951 | } | ||
2952 | 3011 | ||
3012 | } | ||
2953 | } | 3013 | } |
2954 | if (endedColliders.Count > 0) | 3014 | if ((m_parentGroup.RootPart.ScriptEvents & scriptEvents.collision_end) != 0) |
2955 | { | 3015 | { |
2956 | ColliderArgs EndCollidingMessage = new ColliderArgs(); | 3016 | if (endedColliders.Count > 0) |
2957 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
2958 | foreach (uint localId in endedColliders) | ||
2959 | { | 3017 | { |
2960 | if (localId == 0) | 3018 | ColliderArgs EndCollidingMessage = new ColliderArgs(); |
2961 | continue; | 3019 | List<DetectedObject> colliding = new List<DetectedObject>(); |
3020 | foreach (uint localId in endedColliders) | ||
3021 | { | ||
3022 | if (localId == 0) | ||
3023 | continue; | ||
3024 | |||
3025 | // always running this check because if the user deletes the object it would return a null reference. | ||
3026 | if (m_parentGroup == null) | ||
3027 | return; | ||
3028 | if (m_parentGroup.Scene == null) | ||
3029 | return; | ||
3030 | SceneObjectPart obj = m_parentGroup.Scene.GetSceneObjectPart(localId); | ||
3031 | if (obj != null) | ||
3032 | { | ||
3033 | DetectedObject detobj = new DetectedObject(); | ||
3034 | detobj.keyUUID = obj.UUID; | ||
3035 | detobj.nameStr = obj.Name; | ||
3036 | detobj.ownerUUID = obj.OwnerID; | ||
3037 | detobj.posVector = obj.AbsolutePosition; | ||
3038 | detobj.rotQuat = obj.GetWorldRotation(); | ||
3039 | detobj.velVector = obj.Velocity; | ||
3040 | detobj.colliderType = 0; | ||
3041 | detobj.groupUUID = obj.GroupID; | ||
3042 | colliding.Add(detobj); | ||
3043 | } | ||
3044 | else | ||
3045 | { | ||
3046 | List<ScenePresence> avlist = m_parentGroup.Scene.GetScenePresences(); | ||
3047 | if (avlist != null) | ||
3048 | { | ||
3049 | foreach (ScenePresence av in avlist) | ||
3050 | { | ||
3051 | if (av.LocalId == localId) | ||
3052 | { | ||
3053 | DetectedObject detobj = new DetectedObject(); | ||
3054 | detobj.keyUUID = av.UUID; | ||
3055 | detobj.nameStr = av.Name; | ||
3056 | detobj.ownerUUID = av.UUID; | ||
3057 | detobj.posVector = av.AbsolutePosition; | ||
3058 | detobj.rotQuat = new LLQuaternion(av.Rotation.x, av.Rotation.y, av.Rotation.z, av.Rotation.w); | ||
3059 | detobj.velVector = av.Velocity; | ||
3060 | detobj.colliderType = 0; | ||
3061 | detobj.groupUUID = av.ControllingClient.ActiveGroupId; | ||
3062 | colliding.Add(detobj); | ||
3063 | } | ||
3064 | } | ||
2962 | 3065 | ||
2963 | // always running this check because if the user deletes the object it would return a null reference. | 3066 | } |
2964 | if (m_parentGroup == null) | 3067 | } |
2965 | return; | 3068 | } |
2966 | if (m_parentGroup.Scene == null) | 3069 | if (colliding.Count > 0) |
2967 | return; | ||
2968 | SceneObjectPart obj = m_parentGroup.Scene.GetSceneObjectPart(localId); | ||
2969 | if (obj != null) | ||
2970 | { | 3070 | { |
2971 | DetectedObject detobj = new DetectedObject(); | 3071 | EndCollidingMessage.Colliders = colliding; |
2972 | detobj.keyUUID = obj.UUID; | 3072 | // always running this check because if the user deletes the object it would return a null reference. |
2973 | detobj.nameStr = obj.Name; | 3073 | if (m_parentGroup == null) |
2974 | detobj.ownerUUID = obj.OwnerID; | 3074 | return; |
2975 | detobj.posVector = obj.AbsolutePosition; | 3075 | if (m_parentGroup.Scene == null) |
2976 | detobj.rotQuat = obj.GetWorldRotation(); | 3076 | return; |
2977 | detobj.velVector = obj.Velocity; | 3077 | m_parentGroup.Scene.EventManager.TriggerScriptCollidingEnd(LocalId, EndCollidingMessage); |
2978 | detobj.colliderType = 0; | ||
2979 | detobj.groupUUID = obj.GroupID; | ||
2980 | colliding.Add(detobj); | ||
2981 | } | 3078 | } |
2982 | } | ||
2983 | if (colliding.Count > 0) | ||
2984 | { | ||
2985 | EndCollidingMessage.Colliders = colliding; | ||
2986 | // always running this check because if the user deletes the object it would return a null reference. | ||
2987 | if (m_parentGroup == null) | ||
2988 | return; | ||
2989 | if (m_parentGroup.Scene == null) | ||
2990 | return; | ||
2991 | m_parentGroup.Scene.EventManager.TriggerScriptCollidingStart(LocalId, EndCollidingMessage); | ||
2992 | } | ||
2993 | 3079 | ||
3080 | } | ||
2994 | } | 3081 | } |
2995 | } | 3082 | } |
2996 | 3083 | ||